MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / serializeValue

Function serializeValue

packages/agent-core/src/logging/formatter.ts:89–109  ·  view source on GitHub ↗
(raw: unknown)

Source from the content-addressed store, hash-verified

87}
88
89function serializeValue(raw: unknown): string {
90 if (typeof raw === 'string') return redactString(raw);
91 if (raw === undefined) return 'undefined';
92 if (raw === null) return 'null';
93 if (
94 typeof raw === 'number' ||
95 typeof raw === 'boolean' ||
96 typeof raw === 'bigint' ||
97 typeof raw === 'symbol'
98 ) {
99 return String(raw);
100 }
101 try {
102 const json = JSON.stringify(raw);
103 if (json !== undefined) return json;
104 } catch {
105 // fall through to a stable non-contentful fallback
106 }
107 if (typeof raw === 'function') return raw.name === '' ? '[Function]' : `[Function: ${raw.name}]`;
108 return Object.prototype.toString.call(raw);
109}
110
111function redactString(value: string): string {
112 let out = value;

Callers 1

formatPairFunction · 0.85

Calls 1

redactStringFunction · 0.85

Tested by

no test coverage detected