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

Function capNormalizedValue

apps/sim/stores/terminal/console/utils.ts:190–207  ·  view source on GitHub ↗

* Applies a final serialized-size cap after recursive normalization.

(value: unknown)

Source from the content-addressed store, hash-verified

188 * Applies a final serialized-size cap after recursive normalization.
189 */
190function capNormalizedValue(value: unknown): unknown {
191 if (value === null || value === undefined) {
192 return value
193 }
194
195 const serialized = safeConsoleStringify(value)
196 const serializedBytes = getByteLength(serialized)
197
198 if (serializedBytes <= TERMINAL_CONSOLE_LIMITS.MAX_SERIALIZED_BYTES) {
199 return value
200 }
201
202 return {
203 __simTruncated: true,
204 __simByteLength: serializedBytes,
205 __simPreview: truncateString(serialized, TERMINAL_CONSOLE_LIMITS.MAX_SERIALIZED_PREVIEW_LENGTH),
206 }
207}
208
209/**
210 * Normalizes terminal input data before it is stored.

Callers 2

normalizeConsoleInputFunction · 0.85
normalizeConsoleOutputFunction · 0.85

Calls 3

safeConsoleStringifyFunction · 0.85
getByteLengthFunction · 0.85
truncateStringFunction · 0.70

Tested by

no test coverage detected