Files
PaperClipAI/server/src/services/plugin-idle-catalog.ts
T
2026-11-03 15:40:56 -06:00

10 lines
656 B
TypeScript

import { createHash } from "node:crypto";
import type { PaperclipPluginManifestV1 } from "@paperclipai/shared";
export interface IdlePluginCatalogEntry { pluginId: string; manifestGeneration: string }
export function pluginIdleManifestGeneration(manifest: PaperclipPluginManifestV1): string {
const ordered = (value: unknown): unknown => Array.isArray(value) ? value.map(ordered)
: value !== null && typeof value === "object"
? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, v]) => [key, ordered(v)])) : value;
return createHash("sha256").update(JSON.stringify(ordered(manifest))).digest("hex");
}