MCPcopy Index your code
hub / github.com/simstudioai/sim / collectRefs

Function collectRefs

apps/sim/lib/logs/execution/pii-large-values.ts:94–107  ·  view source on GitHub ↗

Depth-first sync walk collecting ref/manifest nodes (not recursing into them).

(value: unknown, out: object[], seen: WeakSet<object>)

Source from the content-addressed store, hash-verified

92
93/** Depth-first sync walk collecting ref/manifest nodes (not recursing into them). */
94function collectRefs(value: unknown, out: object[], seen: WeakSet<object>): void {
95 if (isLargeValueRef(value) || isLargeArrayManifest(value)) {
96 out.push(value as object)
97 return
98 }
99 if (value === null || typeof value !== 'object') return
100 if (seen.has(value)) return
101 seen.add(value)
102 if (Array.isArray(value)) {
103 for (const item of value) collectRefs(item, out, seen)
104 return
105 }
106 for (const v of Object.values(value)) collectRefs(v, out, seen)
107}
108
109/** Sync rebuild of `value` with each collected ref swapped for its replacement (by identity). */
110function substituteRefs(value: unknown, replacements: Map<object, unknown>): unknown {

Callers 1

redactValueRefsFunction · 0.85

Calls 4

isLargeValueRefFunction · 0.90
isLargeArrayManifestFunction · 0.90
pushMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected