/** * Deterministic normalization and canonical serialization for worker * manifests. * * Two manifests that describe the same worker must produce byte-identical * canonical output regardless of how their object keys were ordered in the * source, so the digest identifies the *content* rather than an accident of * construction. Serialization walks the declared manifest shape explicitly * instead of generically stringifying the input, which means an unknown extra * property can never leak into the canonical bytes and change a digest. * * @module worker/manifest/normalize */ import type { WorkerManifest } from './types.ts'; /** * Normalize a manifest into its canonical in-memory form. * * Field order follows the declared shape and every open-ended record is * rebuilt with its keys sorted. The result is a fresh value; the input is not * mutated. * * @example * ```ts * import { normalizeWorkerManifest, WORKER_MANIFEST_VERSION } from '@lostgradient/weft'; * * const normalized = normalizeWorkerManifest({ * manifestVersion: WORKER_MANIFEST_VERSION, * protocolVersion: 2, * sdkVersion: '0.18.0', * runtime: { name: 'bun', version: '1.3.14' }, * deployment: { name: 'billing', buildId: 'b3', artifactDigest: 'sha256:41d0' }, * workflows: {}, * capabilities: { zeta: 1, alpha: 2 }, * }); * console.log(Object.keys(normalized.capabilities)); // ['alpha', 'zeta'] * ``` */ export declare function normalizeWorkerManifest(manifest: WorkerManifest): WorkerManifest; /** * Serialize a manifest to its canonical JSON string. * * The output is the digest input: byte-identical for equivalent manifests and * different for any manifest that differs in a field the host cares about. * * @example * ```ts * import { canonicalWorkerManifestJson, WORKER_MANIFEST_VERSION } from '@lostgradient/weft'; * * const base = { * manifestVersion: WORKER_MANIFEST_VERSION, * protocolVersion: 2, * sdkVersion: '0.18.0', * runtime: { name: 'bun', version: '1.3.14' }, * deployment: { name: 'billing', buildId: 'b3', artifactDigest: 'sha256:41d0' }, * workflows: {}, * } as const; * * const left = canonicalWorkerManifestJson({ ...base, capabilities: { a: 1, b: 2 } }); * const right = canonicalWorkerManifestJson({ ...base, capabilities: { b: 2, a: 1 } }); * console.log(left === right); // true * ``` */ export declare function canonicalWorkerManifestJson(manifest: WorkerManifest): string;