mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:01:23 +00:00
refactor(agents): dedupe lifecycle send assertions and stable payload stringify
This commit is contained in:
@@ -129,12 +129,18 @@ function stableStringify(value: unknown): string {
|
||||
});
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return `[${value.map((entry) => stableStringify(entry)).join(",")}]`;
|
||||
const serializedEntries: string[] = [];
|
||||
for (const entry of value) {
|
||||
serializedEntries.push(stableStringify(entry));
|
||||
}
|
||||
return `[${serializedEntries.join(",")}]`;
|
||||
}
|
||||
const record = value as Record<string, unknown>;
|
||||
const keys = Object.keys(record).toSorted();
|
||||
const entries = keys.map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`);
|
||||
return `{${entries.join(",")}}`;
|
||||
const serializedFields: string[] = [];
|
||||
for (const key of Object.keys(record).toSorted()) {
|
||||
serializedFields.push(`${JSON.stringify(key)}:${stableStringify(record[key])}`);
|
||||
}
|
||||
return `{${serializedFields.join(",")}}`;
|
||||
}
|
||||
|
||||
function digest(value: unknown): string {
|
||||
|
||||
Reference in New Issue
Block a user