export type JsonSchema = { "~openclawClosedObjectIdentity"?: symbol; type?: string | string[]; const?: boolean | number | string | null; properties?: Record; required?: string[]; items?: JsonSchema; enum?: Array; patternProperties?: Record; anyOf?: JsonSchema[]; oneOf?: JsonSchema[]; additionalProperties?: boolean | JsonSchema; }; function stableJson(value: unknown): unknown { if (Array.isArray(value)) { return value.map(stableJson); } if (value && typeof value === "object") { const record = value as Record; return Object.fromEntries( Object.keys(record) .toSorted() .map((key) => [key, stableJson(record[key])]), ); } return value; } export function schemaSignature(schema: JsonSchema): string { return JSON.stringify(stableJson(schema)); }