MCPcopy Create free account
hub / github.com/cortexkit/magic-context / redactConfigValue

Function redactConfigValue

packages/plugin/src/config/index.ts:201–214  ·  view source on GitHub ↗

* Render a config value for a warning message in a way that never leaks resolved * secrets from `{env:API_KEY}` / `{file:...}` substitution. * * Strings, numbers, booleans, and nulls are shown as type-plus-length so the * user can still diagnose the problem ("string, 48 chars", "number 200001")

(value: unknown)

Source from the content-addressed store, hash-verified

199 * `<missing>`.
200 */
201function redactConfigValue(value: unknown): string {
202 if (value === undefined) return "<missing>";
203 if (value === null) return "null";
204 if (typeof value === "string")
205 return `string, ${value.length} char${value.length === 1 ? "" : "s"}`;
206 if (typeof value === "number") return `number ${value}`;
207 if (typeof value === "boolean") return `boolean ${value}`;
208 if (Array.isArray(value)) return `array, ${value.length} item${value.length === 1 ? "" : "s"}`;
209 if (typeof value === "object") {
210 const keys = Object.keys(value as Record<string, unknown>);
211 return `object with keys [${keys.join(", ")}]`;
212 }
213 return typeof value;
214}
215
216function parsePluginConfig(
217 rawConfig: Record<string, unknown>,

Callers 1

parsePluginConfigFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected