MCPcopy Create free account
hub / github.com/FIND-Lab/AgentWard / stableStringify

Function stableStringify

index.ts:51–58  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

49}
50
51function stableStringify(value: unknown): string {
52 if (value === null || value === undefined) return String(value);
53 if (typeof value !== "object") return JSON.stringify(value);
54 if (Array.isArray(value)) return `[${value.map((v) => stableStringify(v)).join(",")}]`;
55 const record = value as Record<string, unknown>;
56 const keys = Object.keys(record).sort();
57 return `{${keys.map((k) => `${JSON.stringify(k)}:${stableStringify(record[k])}`).join(",")}}`;
58}
59
60function computeOperationKey(toolName: string, params: Record<string, unknown>): string {
61 // "Exact match" key: stable stringify + hash for compact storage.

Callers 1

computeOperationKeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected