@ai-matrx/alchemy 0.8.60 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +2 -0
- package/dist/actions.cjs +1 -1
- package/dist/actions.cjs.map +1 -1
- package/dist/actions.d.cts +300 -3
- package/dist/actions.d.ts +300 -3
- package/dist/actions.js +1 -1
- package/dist/actions.js.map +1 -1
- package/dist/checks.cjs +1 -1
- package/dist/checks.cjs.map +1 -1
- package/dist/checks.d.cts +22 -1
- package/dist/checks.d.ts +22 -1
- package/dist/checks.js +2 -2
- package/dist/checks.js.map +1 -1
- package/dist/core.d.cts +141 -26
- package/dist/core.d.ts +141 -26
- package/dist/declare.cjs +1 -1
- package/dist/declare.cjs.map +1 -1
- package/dist/declare.d.cts +12 -4
- package/dist/declare.d.ts +12 -4
- package/dist/declare.js +1 -1
- package/dist/declare.js.map +1 -1
- package/dist/index.d.cts +141 -26
- package/dist/index.d.ts +141 -26
- package/dist/menu.cjs +1 -1
- package/dist/menu.cjs.map +1 -1
- package/dist/menu.d.cts +109 -2
- package/dist/menu.d.ts +109 -2
- package/dist/menu.js +1 -1
- package/dist/menu.js.map +1 -1
- package/dist/operate-server.d.cts +6 -0
- package/dist/operate-server.d.ts +6 -0
- package/dist/operate.d.cts +141 -26
- package/dist/operate.d.ts +141 -26
- package/dist/ports.cjs.map +1 -1
- package/dist/ports.d.cts +116 -1
- package/dist/ports.d.ts +116 -1
- package/dist/react-bar.cjs +1 -1
- package/dist/react-bar.cjs.map +1 -1
- package/dist/react-bar.d.cts +4 -2
- package/dist/react-bar.d.ts +4 -2
- package/dist/react-bar.js +1 -1
- package/dist/react-bar.js.map +1 -1
- package/dist/react-host.d.cts +109 -2
- package/dist/react-host.d.ts +109 -2
- package/dist/react-menu.cjs +1 -1
- package/dist/react-menu.cjs.map +1 -1
- package/dist/react-menu.d.cts +4 -2
- package/dist/react-menu.d.ts +4 -2
- package/dist/react-menu.js +1 -1
- package/dist/react-menu.js.map +1 -1
- package/dist/react-overflow.cjs +1 -1
- package/dist/react-overflow.cjs.map +1 -1
- package/dist/react-overflow.d.cts +109 -2
- package/dist/react-overflow.d.ts +109 -2
- package/dist/react-overflow.js +1 -1
- package/dist/react-overflow.js.map +1 -1
- package/dist/react-palette.cjs +1 -1
- package/dist/react-palette.cjs.map +1 -1
- package/dist/react-palette.d.cts +4 -2
- package/dist/react-palette.d.ts +4 -2
- package/dist/react-palette.js +1 -1
- package/dist/react-palette.js.map +1 -1
- package/dist/react-selection.cjs +1 -1
- package/dist/react-selection.cjs.map +1 -1
- package/dist/react-selection.d.cts +4 -2
- package/dist/react-selection.d.ts +4 -2
- package/dist/react-selection.js +1 -1
- package/dist/react-selection.js.map +1 -1
- package/dist/react-sheet.cjs +1 -1
- package/dist/react-sheet.cjs.map +1 -1
- package/dist/react-sheet.d.cts +4 -2
- package/dist/react-sheet.d.ts +4 -2
- package/dist/react-sheet.js +1 -1
- package/dist/react-sheet.js.map +1 -1
- package/package.json +1 -1
package/dist/declare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/declare/keys.ts","../src/declare/hash.ts","../src/declare/validate.ts","../src/declare/sensitivity.ts","../src/declare/registry.ts"],"sourcesContent":["import type { QualifiedValueKey } from \"./types\";\n\n/** Every value, write-target, item-type and group name (the DB CHECK rule). */\nexport const DECLARATION_NAME_RE = /^[a-z][a-z0-9_]*$/;\n\n/** \"<client>/<local>\" — the surface naming convention. */\nexport const SURFACE_NAME_RE = /^[a-z][a-z0-9-]*\\/[a-z0-9-/]+$/;\n\n/** A bare screen value (`status`) or an item value (`table_row.status`). */\nexport const QUALIFIED_VALUE_KEY_RE = /^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)?$/;\n\nexport interface ParsedValueKey {\n /** \"\" for a screen-level value. */\n itemType: string;\n name: string;\n}\n\n/** Split a qualified key; null when it is not a valid bare or qualified key. */\nexport function parseQualifiedValueKey(key: string): ParsedValueKey | null {\n if (!QUALIFIED_VALUE_KEY_RE.test(key)) return null;\n const dot = key.indexOf(\".\");\n if (dot === -1) return { itemType: \"\", name: key };\n return { itemType: key.slice(0, dot), name: key.slice(dot + 1) };\n}\n\nexport function qualifyValueKey(itemType: string, name: string): QualifiedValueKey {\n return itemType ? `${itemType}.${name}` : name;\n}\n\n/** The client that owns a surface: its name prefix. */\nexport function surfaceClientOf(surfaceName: string): string {\n return surfaceName.split(\"/\")[0] ?? \"\";\n}\n","import type { SurfaceDeclaration } from \"./types\";\n\n/** Canonical JSON: keys sorted, undefined dropped, arrays in order. */\nexport function canonicalJson(value: unknown): string {\n if (value === undefined) return \"null\";\n if (value === null || typeof value !== \"object\") return JSON.stringify(value);\n if (Array.isArray(value)) return `[${value.map((entry) => canonicalJson(entry)).join(\",\")}]`;\n const record = value as Record<string, unknown>;\n return `{${Object.keys(record)\n .filter((key) => record[key] !== undefined)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`)\n .join(\",\")}}`;\n}\n\nconst K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\n/** SHA-256 hex of a UTF-8 string. Pure, synchronous, runs anywhere (no crypto API needed). */\nexport function sha256Hex(input: string): string {\n const bytes = new TextEncoder().encode(input);\n const bitLength = bytes.length * 8;\n const padded = new Uint8Array(((bytes.length + 9 + 63) >> 6) << 6);\n padded.set(bytes);\n padded[bytes.length] = 0x80;\n const view = new DataView(padded.buffer);\n view.setUint32(padded.length - 8, Math.floor(bitLength / 0x100000000));\n view.setUint32(padded.length - 4, bitLength >>> 0);\n const h = new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n ]);\n const w = new Uint32Array(64);\n for (let offset = 0; offset < padded.length; offset += 64) {\n for (let i = 0; i < 16; i += 1) w[i] = view.getUint32(offset + i * 4);\n for (let i = 16; i < 64; i += 1) {\n const a = w[i - 15]!;\n const b = w[i - 2]!;\n const s0 = ((a >>> 7) | (a << 25)) ^ ((a >>> 18) | (a << 14)) ^ (a >>> 3);\n const s1 = ((b >>> 17) | (b << 15)) ^ ((b >>> 19) | (b << 13)) ^ (b >>> 10);\n w[i] = (w[i - 16]! + s0 + w[i - 7]! + s1) >>> 0;\n }\n let a = h[0]!, b = h[1]!, c = h[2]!, d = h[3]!, e = h[4]!, f = h[5]!, g = h[6]!, hh = h[7]!;\n for (let i = 0; i < 64; i += 1) {\n const S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));\n const ch = (e & f) ^ (~e & g);\n const t1 = (hh + S1 + ch + K[i]! + w[i]!) >>> 0;\n const S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const t2 = (S0 + maj) >>> 0;\n hh = g; g = f; f = e; e = (d + t1) >>> 0; d = c; c = b; b = a; a = (t1 + t2) >>> 0;\n }\n h[0] = (h[0]! + a) >>> 0; h[1] = (h[1]! + b) >>> 0; h[2] = (h[2]! + c) >>> 0; h[3] = (h[3]! + d) >>> 0;\n h[4] = (h[4]! + e) >>> 0; h[5] = (h[5]! + f) >>> 0; h[6] = (h[6]! + g) >>> 0; h[7] = (h[7]! + hh) >>> 0;\n }\n return Array.from(h, (word) => word.toString(16).padStart(8, \"0\")).join(\"\");\n}\n\n/**\n * Drift between clients. Computed, never authored: SHA-256 of the canonical JSON\n * of the declaration as authored (keys sorted, extension fields included).\n * Persisted as `ui_surface.content_hash` once that column exists.\n */\nexport function declarationHash(declaration: SurfaceDeclaration): string {\n return sha256Hex(canonicalJson(declaration));\n}\n","/**\n * Declaration validation — the ONE set of surface checks (CONTRACT §3 D5).\n * Ported from matrx-frontend `scripts/check-surface-drift.ts`; the app's own\n * check now runs this. Agent-owned slots (roles, client tools) validate through\n * their `DeclarationExtension`, never here.\n */\nimport { DECLARATION_NAME_RE, SURFACE_NAME_RE, surfaceClientOf } from \"./keys\";\nimport type {\n DeclarationExtension,\n DeclarationIssue,\n ResolvedSurfaceDeclaration,\n SurfaceDeclaration,\n} from \"./types\";\n\nexport const VALUE_TYPES = [\"string\", \"number\", \"boolean\", \"object\", \"array\", \"document\"] as const;\nexport const WRITE_MODES = [\"draft\", \"entity\", \"ui\", \"stream\"] as const;\nexport const APPLY_POLICIES = [\"manual\", \"ask\", \"auto\", \"queued\"] as const;\nexport const STREAM_OPS = [\"replace\", \"insert_before\", \"insert_after\", \"prepend\", \"append\", \"patch\"] as const;\nexport const EXECUTION_MODES = [\"python-stream\", \"nextjs-stream\", \"browser-realtime\", \"local-runtime\"] as const;\nexport const READINESS = [\"verified\", \"partial\", \"stub\"] as const;\nexport const LIVE_SLOTS = [\"selection\", \"on-demand\", \"errors\", \"requests\"] as const;\nexport const CLASSIFICATIONS = [\"ordinary\", \"secret\", \"credential\"] as const;\n\nconst STRUCTURED = new Set([\"object\", \"array\"]);\n\nexport interface ValidateOptions {\n /** Registered config namespaces; omitted = not checked. */\n knownNamespaces?: ReadonlySet<string>;\n /** Registered content-ir kind slugs; omitted = not checked. */\n isKnownKind?: (slug: string) => boolean;\n /** Names every declaration must expose unless `skipBaselineValues`. */\n baselineNames?: readonly string[];\n extensions?: readonly DeclarationExtension[];\n}\n\nfunction has<T extends string>(list: readonly T[], value: unknown): value is T {\n return typeof value === \"string\" && (list as readonly string[]).includes(value);\n}\n\nexport function validateDeclarations(\n declarations: readonly ResolvedSurfaceDeclaration[],\n options: ValidateOptions = {},\n): DeclarationIssue[] {\n const issues: DeclarationIssue[] = [];\n const seenSurfaces = new Set<string>();\n const labelsByClient = new Map<string, Map<string, string>>();\n\n for (const d of declarations) {\n const s = d.surfaceName;\n const push = (path: string, sentence: string, remedy: string, severity?: \"advisory\") =>\n issues.push({ surfaceName: s, path, sentence, remedy, ...(severity ? { severity } : {}) });\n\n if (seenSurfaces.has(s)) {\n push(\"surfaceName\", `Duplicate manifest surfaceName: \"${s}\" appears more than once.`, \"Keep one declaration per surface.\");\n }\n seenSurfaces.add(s);\n if (!SURFACE_NAME_RE.test(s)) {\n push(\"surfaceName\", `Surface \"${s}\" doesn't match the \"<client>/<local>\" convention.`, \"Rename it to <client>/<local>.\");\n }\n\n const prefix = surfaceClientOf(s);\n if (d.client !== prefix) {\n push(\"client\", `Surface \"${s}\" declares client \"${String(d.client)}\" but its name prefix is \"${prefix}\" — they must match.`, `Set client: \"${prefix}\".`);\n }\n if (!has(EXECUTION_MODES, d.executionMode)) {\n push(\"executionMode\", `Surface \"${s}\" has invalid executionMode \"${String(d.executionMode)}\".`, `Use one of ${EXECUTION_MODES.join(\" | \")}.`);\n }\n if (typeof d.description !== \"string\") {\n push(\"description\", `Surface \"${s}\" has no description.`, \"Add one sentence on what the surface is (\\\"\\\" only where the live row is empty).\");\n }\n\n const label = d.label?.trim();\n if (!label) {\n push(\"label\", `Surface \"${s}\" has no canonical label — label is required.`, \"Add the ONE canonical human display name.\");\n } else {\n const clientLabels = labelsByClient.get(prefix) ?? new Map<string, string>();\n const clash = clientLabels.get(label.toLowerCase());\n if (clash && clash !== s) {\n push(\"label\", `Canonical label \"${label}\" is used by both \"${clash}\" and \"${s}\" — labels must be unique per client.`, \"Give one of them a distinct label.\");\n }\n clientLabels.set(label.toLowerCase(), s);\n labelsByClient.set(prefix, clientLabels);\n }\n\n if (!has(READINESS, d.readiness)) {\n push(\"readiness\", `Surface \"${s}\" has invalid readiness \"${String(d.readiness)}\" (expected verified | partial | stub).`, \"Set a valid readiness.\");\n } else if (d.readiness !== \"verified\" && !d.readinessNote?.trim()) {\n push(\"readinessNote\", `Surface \"${s}\" is readiness \"${d.readiness}\" but has no readinessNote — say what's missing.`, \"Add a one-line readinessNote.\");\n }\n\n const groupKeys = new Set<string>();\n for (const g of d.groups ?? []) {\n groupKeys.add(g.key);\n const reserved = g.key === \"general\" || g.key === \"baseline\" || g.key.startsWith(\"inherited:\");\n if (reserved) continue;\n if (!DECLARATION_NAME_RE.test(g.key)) push(`groups/${g.key}`, `Surface \"${s}\" group \"${g.key}\" doesn't match /^[a-z][a-z0-9_]*$/.`, \"Rename the group key to lower_snake_case.\");\n if (g.sortOrder < 0 || g.sortOrder > 899) push(`groups/${g.key}/sortOrder`, `Surface \"${s}\" group \"${g.key}\" sortOrder ${g.sortOrder} is outside the curated band 0–899.`, \"Use a sortOrder between 0 and 899.\");\n if (!g.label?.trim()) push(`groups/${g.key}/label`, `Surface \"${s}\" group \"${g.key}\" has no canonical label.`, \"Add a label.\");\n }\n\n const seenNamespaces = new Set<string>();\n for (const ns of d.configNamespaces ?? []) {\n if (seenNamespaces.has(ns.namespace)) push(`configNamespaces/${ns.namespace}`, `Surface \"${s}\" declares duplicate config namespace \"${ns.namespace}\".`, \"Remove the duplicate.\");\n seenNamespaces.add(ns.namespace);\n if (options.knownNamespaces && !options.knownNamespaces.has(ns.namespace)) {\n push(`configNamespaces/${ns.namespace}`, `Surface \"${s}\" references config namespace \"${ns.namespace}\" which is not registered.`, \"Register the namespace first, or remove the reference.\");\n }\n }\n\n if (d.values.length === 0) {\n push(\"values\", `Surface \"${s}\" declares no values.`, \"Declare at least one value.\");\n continue;\n }\n\n const seenValues = new Set<string>();\n for (const v of d.values) {\n const at = `values/${v.name}`;\n if (seenValues.has(v.name)) push(at, `Surface \"${s}\" declares duplicate value \"${v.name}\".`, \"Remove the duplicate.\");\n seenValues.add(v.name);\n if (!DECLARATION_NAME_RE.test(v.name)) push(at, `Surface \"${s}\" value \"${v.name}\" doesn't match /^[a-z][a-z0-9_]*$/ — the DB CHECK constraint will reject this.`, \"Rename it to lower_snake_case.\");\n if (!has(VALUE_TYPES, v.valueType)) push(`${at}/valueType`, `Surface \"${s}\" value \"${v.name}\" has invalid valueType \"${String(v.valueType)}\".`, `Use one of ${VALUE_TYPES.join(\" | \")}.`);\n if (typeof v.typicalCharCount !== \"number\" || v.typicalCharCount < 0) push(`${at}/typicalCharCount`, `Surface \"${s}\" value \"${v.name}\" has invalid typicalCharCount.`, \"Use a non-negative number.\");\n if (v.sortOrder !== undefined && (typeof v.sortOrder !== \"number\" || v.sortOrder < 0)) push(`${at}/sortOrder`, `Surface \"${s}\" value \"${v.name}\" has invalid sortOrder.`, \"Use a non-negative number.\");\n if (v.groupKey && !groupKeys.has(v.groupKey)) push(`${at}/group`, `Surface \"${s}\" value \"${v.name}\" resolved to groupKey \"${v.groupKey}\" which is missing from the resolved groups list — registry group synthesis is broken.`, \"Fix the registry resolution.\");\n if (v.liveSlot !== undefined && !has(LIVE_SLOTS, v.liveSlot)) push(`${at}/liveSlot`, `Surface \"${s}\" value \"${v.name}\" has invalid liveSlot \"${String(v.liveSlot)}\".`, `Use one of ${LIVE_SLOTS.join(\" | \")}.`);\n if (v.role !== undefined && v.role !== \"data\" && v.role !== \"request\") push(`${at}/role`, `Surface \"${s}\" value \"${v.name}\" has invalid role \"${String(v.role)}\".`, \"Use data | request.\");\n if (v.sensitivity?.classification !== undefined && !has(CLASSIFICATIONS, v.sensitivity.classification)) push(`${at}/sensitivity/classification`, `Surface \"${s}\" value \"${v.name}\" has invalid classification \"${String(v.sensitivity.classification)}\".`, `Use one of ${CLASSIFICATIONS.join(\" | \")}.`);\n }\n\n for (const slot of d.liveSlots ?? []) {\n if (!has(LIVE_SLOTS, slot)) push(\"liveSlots\", `Surface \"${s}\" declares unknown live slot \"${String(slot)}\".`, `Use one of ${LIVE_SLOTS.join(\" | \")}.`);\n }\n\n const itemTypeNames = new Set<string>();\n for (const item of d.itemTypes ?? []) {\n const at = `itemTypes/${item.name}`;\n if (itemTypeNames.has(item.name)) push(at, `Surface \"${s}\" declares duplicate item type \"${item.name}\".`, \"Remove the duplicate.\");\n itemTypeNames.add(item.name);\n if (!DECLARATION_NAME_RE.test(item.name)) push(at, `Surface \"${s}\" item type \"${item.name}\" doesn't match /^[a-z][a-z0-9_]*$/.`, \"Rename it to lower_snake_case.\");\n if (!item.label?.trim() || !item.description?.trim()) push(at, `Surface \"${s}\" item type \"${item.name}\" needs a label and a description.`, \"Add both.\");\n const itemValues = new Set(item.values.map((v) => v.name));\n if (item.identity.length === 0) push(`${at}/identity`, `Surface \"${s}\" item type \"${item.name}\" has an empty identity.`, \"Name the value(s) that identify one item.\");\n for (const key of item.identity) {\n if (!itemValues.has(key)) push(`${at}/identity`, `Surface \"${s}\" item type \"${item.name}\" identity names \"${key}\", which is not one of its values.`, \"Declare it as an item value.\");\n }\n for (const t of item.writeTargets ?? []) {\n if (t.updatesValue && !itemValues.has(t.updatesValue)) push(`${at}/writeTargets/${t.name}`, `Surface \"${s}\" item type \"${item.name}\" write target \"${t.name}\" updatesValue \"${t.updatesValue}\" which is not an item value.`, \"Point it at a declared item value.\");\n }\n }\n\n const seenTargets = new Set<string>();\n const structuredWithoutKind: string[] = [];\n for (const w of d.writeTargets ?? []) {\n const at = `writeTargets/${w.name}`;\n if (seenTargets.has(w.name)) push(at, `Surface \"${s}\" declares duplicate write target \"${w.name}\".`, \"Remove the duplicate.\");\n seenTargets.add(w.name);\n if (!DECLARATION_NAME_RE.test(w.name)) push(at, `Surface \"${s}\" write target \"${w.name}\" doesn't match /^[a-z][a-z0-9_]*$/.`, \"Rename it to lower_snake_case.\");\n if (!w.label?.trim() || !w.description?.trim()) push(at, `Surface \"${s}\" write target \"${w.name}\" needs a label and a description.`, \"Add both.\");\n if (!has(VALUE_TYPES, w.valueType)) push(`${at}/valueType`, `Surface \"${s}\" write target \"${w.name}\" has invalid valueType \"${String(w.valueType)}\".`, `Use one of ${VALUE_TYPES.join(\" | \")}.`);\n if (!has(WRITE_MODES, w.mode)) push(`${at}/mode`, `Surface \"${s}\" write target \"${w.name}\" has invalid mode \"${String(w.mode)}\".`, `Use one of ${WRITE_MODES.join(\" | \")}.`);\n if (w.applyPolicy !== undefined && !has(APPLY_POLICIES, w.applyPolicy)) push(`${at}/applyPolicy`, `Surface \"${s}\" write target \"${w.name}\" has invalid applyPolicy \"${String(w.applyPolicy)}\".`, `Use one of ${APPLY_POLICIES.join(\" | \")}.`);\n if (w.itemType !== undefined && !itemTypeNames.has(w.itemType)) push(`${at}/itemType`, `Surface \"${s}\" write target \"${w.name}\" names item type \"${w.itemType}\", which the surface does not declare.`, \"Declare the item type or drop itemType.\");\n const readTwinDeclared = w.updatesValue ? seenValues.has(w.updatesValue) : false;\n if (w.updatesValue && !w.itemType && !readTwinDeclared) push(`${at}/updatesValue`, `Surface \"${s}\" write target \"${w.name}\" updatesValue \"${w.updatesValue}\" which is not a declared value.`, \"Point updatesValue at a declared value.\");\n if (w.patchable && !w.updatesValue) push(`${at}/patchable`, `Surface \"${s}\" write target \"${w.name}\" is patchable but declares no updatesValue — an anchored edit has nothing to read.`, \"Declare the read twin in updatesValue.\");\n if (w.patchable && w.valueType !== \"string\" && w.valueType !== \"document\") push(`${at}/patchable`, `Surface \"${s}\" write target \"${w.name}\" is patchable but valueType is \"${w.valueType}\" (patching is for \"string\" | \"document\").`, \"Drop patchable or change the value type.\");\n if (w.mode === \"stream\") {\n if (!w.streamOps || w.streamOps.length === 0) push(`${at}/streamOps`, `Surface \"${s}\" write target \"${w.name}\" is a stream target with no streamOps.`, \"List the ops it services.\");\n if (!w.updatesValue) push(`${at}/updatesValue`, `Surface \"${s}\" write target \"${w.name}\" is a stream target with no read twin.`, \"Declare updatesValue.\");\n } else if (w.streamOps !== undefined) {\n push(`${at}/streamOps`, `Surface \"${s}\" write target \"${w.name}\" lists streamOps but its mode is \"${w.mode}\".`, \"streamOps belong only to mode \\\"stream\\\".\");\n }\n for (const op of w.streamOps ?? []) {\n if (!has(STREAM_OPS, op)) push(`${at}/streamOps`, `Surface \"${s}\" write target \"${w.name}\" lists unknown stream op \"${String(op)}\".`, `Use ${STREAM_OPS.join(\" | \")}.`);\n }\n if (w.group && !groupKeys.has(w.group)) push(`${at}/group`, `Surface \"${s}\" write target \"${w.name}\" references undeclared group \"${w.group}\".`, \"Declare the group or drop it.\");\n if (w.valueKind !== undefined) {\n if (typeof w.valueKind !== \"string\" || !w.valueKind.trim()) {\n push(`${at}/valueKind`, `Surface \"${s}\" write target \"${w.name}\" has an empty valueKind.`, \"Name a registered kind slug or omit the field.\");\n } else if (options.isKnownKind && !options.isKnownKind(w.valueKind)) {\n push(`${at}/valueKind`, `Surface \"${s}\" write target \"${w.name}\" declares valueKind \"${w.valueKind}\", which is not a registered active kind.`, \"Name a registered kind slug, or register the kind first; never inline a JSON schema.\");\n }\n } else if (STRUCTURED.has(w.valueType)) {\n structuredWithoutKind.push(w.name);\n }\n }\n for (const name of structuredWithoutKind) {\n push(`writeTargets/${name}/valueKind`, `Surface \"${s}\" structured write target \"${name}\" declares no valueKind.`, \"Name a registered kind slug (the value contract ratchet).\", \"advisory\");\n }\n\n if (!d.skipBaselineValues && options.baselineNames) {\n const missing = options.baselineNames.filter((name) => !seenValues.has(name));\n if (missing.length > 0) {\n push(\"values\", `Surface \"${s}\" is missing baseline value(s): ${missing.join(\", \")}.`, \"The registry injects baselines automatically; opt out only with skipBaselineValues.\");\n }\n }\n }\n\n for (const extension of options.extensions ?? []) {\n if (!extension.validate) continue;\n for (const d of declarations) issues.push(...extension.validate(d as SurfaceDeclaration & ResolvedSurfaceDeclaration, { all: declarations }));\n }\n return issues;\n}\n\n/**\n * The runtime half: a loaded scope may carry only declared values. Returns one\n * issue per undeclared key (and per `__item` value its item type does not declare).\n */\nexport function validateLoadedValues(\n declaration: Pick<ResolvedSurfaceDeclaration, \"surfaceName\" | \"values\" | \"itemTypes\">,\n loaded: Record<string, unknown>,\n options: { ignore?: readonly string[] } = {},\n): DeclarationIssue[] {\n const declared = new Set(declaration.values.map((v) => v.name));\n const ignore = new Set(options.ignore ?? []);\n const issues: DeclarationIssue[] = [];\n for (const key of Object.keys(loaded)) {\n if (key === \"__item\" || declared.has(key) || ignore.has(key)) continue;\n issues.push({\n surfaceName: declaration.surfaceName,\n path: `values/${key}`,\n sentence: `Surface \"${declaration.surfaceName}\" loaded a value \"${key}\" it never declared.`,\n remedy: `Declare \"${key}\" in the surface's values, or stop emitting it.`,\n });\n }\n const item = loaded.__item as { itemType?: unknown; values?: unknown } | undefined;\n if (item && typeof item === \"object\") {\n const type = declaration.itemTypes?.find((t) => t.name === item.itemType);\n if (!type) {\n issues.push({\n surfaceName: declaration.surfaceName,\n path: \"__item/itemType\",\n sentence: `Surface \"${declaration.surfaceName}\" loaded an item of type \"${String(item.itemType)}\" it never declared.`,\n remedy: \"Declare the item type, or stop emitting the item.\",\n });\n } else if (item.values && typeof item.values === \"object\") {\n const itemDeclared = new Set(type.values.map((v) => v.name));\n for (const key of Object.keys(item.values)) {\n if (itemDeclared.has(key)) continue;\n issues.push({\n surfaceName: declaration.surfaceName,\n path: `__item/${type.name}.${key}`,\n sentence: `Surface \"${declaration.surfaceName}\" loaded item value \"${type.name}.${key}\" it never declared.`,\n remedy: `Declare \"${key}\" on item type \"${type.name}\".`,\n });\n }\n }\n }\n return issues;\n}\n\n/**\n * Ownership: no `ui.ui_surface` row may exist without a declaring owner\n * (CONTRACT §2.1a). `retired` rows (archived, not deleted) are exempt.\n */\nexport function findOrphanRows(\n rowNames: readonly string[],\n declaredNames: Iterable<string>,\n retired: Iterable<string> = [],\n): string[] {\n const owned = new Set(declaredNames);\n const archived = new Set(retired);\n return rowNames.filter((name) => !owned.has(name) && !archived.has(name)).sort();\n}\n","/**\n * Sensitivity defaults and resolution (CONTRACT §2.1). Its own module so the\n * lightweight entries (`/actions`, the T0 React host) can project without\n * pulling the declaration registry.\n */\nimport type { DeclaredValue, Sensitivity } from \"./types\";\n\nexport const DEFAULT_SENSITIVITY: Sensitivity = Object.freeze({\n exportable: true,\n classification: \"ordinary\",\n includedByDefault: true,\n});\n\nexport function resolveSensitivity(value: Pick<DeclaredValue, \"sensitivity\">): Sensitivity {\n return {\n exportable: value.sensitivity?.exportable ?? DEFAULT_SENSITIVITY.exportable,\n classification: value.sensitivity?.classification ?? DEFAULT_SENSITIVITY.classification,\n includedByDefault: value.sensitivity?.includedByDefault ?? DEFAULT_SENSITIVITY.includedByDefault,\n };\n}\n","/**\n * The declaration registry: inheritance, baseline injection, provenance and\n * group synthesis (CONTRACT §2.1 `DeclarationRegistry`). Ported verbatim in\n * behaviour from matrx-frontend `features/surfaces/manifests/registry.ts`\n * (ALC-14); the app now supplies its declarations and baselines.\n *\n * Guards are LOUD by design: an unknown parent, a cycle, a chain deeper than\n * the limit, a reserved or duplicate group key, a value naming an undeclared\n * group, or a reserved platform name throws on resolution — a build fails\n * instead of silently dropping values.\n */\nimport { declarationHash } from \"./hash\";\nimport type {\n DeclarationExtension,\n DeclarationIssue,\n DeclaredValue,\n ResolvedSurfaceDeclaration,\n ResolvedValue,\n Sensitivity,\n SurfaceDeclaration,\n ValueGroup,\n ValueProvenance,\n} from \"./types\";\nimport { validateDeclarations, type ValidateOptions } from \"./validate\";\n\nexport const RESERVED_GROUP_KEYS = {\n general: \"general\",\n baseline: \"baseline\",\n inheritedPrefix: \"inherited:\",\n} as const;\n\n/** Group sortOrder bands. Curated groups author 0–899; the rest is reserved. */\nexport const GENERAL_GROUP_ORDER = 850;\nexport const INHERITED_GROUP_ORDER_BASE = 9000;\nexport const BASELINE_GROUP_ORDER = 9900;\nexport const DEFAULT_MAX_INHERITANCE_DEPTH = 3;\n\nimport { DEFAULT_SENSITIVITY, resolveSensitivity } from \"./sensitivity\";\nexport { DEFAULT_SENSITIVITY, resolveSensitivity };\n\nexport type Resolved<D extends SurfaceDeclaration> = Omit<D, \"values\" | \"groups\"> & {\n values: readonly (D[\"values\"][number] & ResolvedValue)[];\n groups: readonly ValueGroup[];\n contentHash: string;\n};\n\nexport interface DeclarationRegistryOptions {\n /** Generic values injected into every declaration unless `skipBaselineValues`. */\n baselineValues?: readonly DeclaredValue[];\n /** Value names only the platform writes; a declaration claiming one is refused. */\n reservedValueNames?: readonly string[];\n /** Write-target names only the platform writes. */\n reservedWriteTargetNames?: readonly string[];\n maxInheritanceDepth?: number;\n}\n\nexport interface DeclarationRegistry<D extends SurfaceDeclaration> {\n /** Refuses a second declaration of the same surfaceName. */\n register(declaration: D): void;\n registerExtension(extension: DeclarationExtension<D>): void;\n extensions(): readonly DeclarationExtension<D>[];\n /** Declarations exactly as authored (inheritance unresolved, no baselines). */\n raw(): readonly D[];\n getRaw(surfaceName: string): D | undefined;\n /** Parent chain, ROOT FIRST. Unknown surfaces return []. */\n ancestry(surfaceName: string): string[];\n /** Direct children (declarations naming it in `inheritsFrom`), in declaration order. */\n children(surfaceName: string): string[];\n /** Inheritance + baseline + groups resolved; provenance kept. */\n all(): readonly Resolved<D>[];\n get(surfaceName: string): Resolved<D> | undefined;\n validate(options?: ValidateOptions): readonly DeclarationIssue[];\n}\n\nexport function createDeclarationRegistry<D extends SurfaceDeclaration>(\n options: DeclarationRegistryOptions = {},\n): DeclarationRegistry<D> {\n const baselineValues = options.baselineValues ?? [];\n const baselineNames = new Set(baselineValues.map((v) => v.name));\n const reservedValues = new Set(options.reservedValueNames ?? []);\n const reservedTargets = new Set(options.reservedWriteTargetNames ?? []);\n const maxDepth = options.maxInheritanceDepth ?? DEFAULT_MAX_INHERITANCE_DEPTH;\n const declarations: D[] = [];\n const index = new Map<string, D>();\n const extensionList: DeclarationExtension<D>[] = [];\n let resolvedCache: Resolved<D>[] | null = null;\n let resolvedIndex = new Map<string, Resolved<D>>();\n\n function ancestry(surfaceName: string): string[] {\n const chain: string[] = [];\n const seen = new Set<string>([surfaceName]);\n let current = index.get(surfaceName)?.inheritsFrom;\n while (current) {\n if (seen.has(current)) {\n throw new Error(\n `[surfaces] inheritsFrom CYCLE detected at \"${current}\" (from \"${surfaceName}\"). ` +\n `Fix the manifest chain: ${[...seen].join(\" → \")} → ${current}`,\n );\n }\n const parent = index.get(current);\n if (!parent) {\n throw new Error(\n `[surfaces] \"${surfaceName}\" inheritsFrom unknown surface \"${current}\" — ` +\n `the parent must be a registered declaration`,\n );\n }\n seen.add(current);\n chain.unshift(current);\n if (chain.length > maxDepth) {\n throw new Error(\n `[surfaces] inheritance chain for \"${surfaceName}\" exceeds depth ${maxDepth}: ` + chain.join(\" → \"),\n );\n }\n current = parent.inheritsFrom;\n }\n return chain;\n }\n\n function groupKeyFor(value: DeclaredValue, provenance: ValueProvenance): string {\n if (provenance.kind === \"own\" && value.group) return value.group;\n if (baselineNames.has(value.name)) return RESERVED_GROUP_KEYS.baseline;\n if (provenance.kind === \"inherited\") return `${RESERVED_GROUP_KEYS.inheritedPrefix}${provenance.from}`;\n if (provenance.kind === \"baseline\") return RESERVED_GROUP_KEYS.baseline;\n return RESERVED_GROUP_KEYS.general;\n }\n\n function resolve(declaration: D): Resolved<D> {\n const chain = ancestry(declaration.surfaceName);\n const lineage: { layer: D; from: string | null }[] = [\n ...chain.map((name) => {\n const layer = index.get(name);\n if (!layer) throw new Error(`[surfaces] missing inherited declaration \"${name}\"`);\n return { layer, from: name };\n }),\n { layer: declaration, from: null },\n ];\n\n const curatedKeys = new Set<string>();\n for (const group of declaration.groups ?? []) {\n if (\n group.key === RESERVED_GROUP_KEYS.general ||\n group.key === RESERVED_GROUP_KEYS.baseline ||\n group.key.startsWith(RESERVED_GROUP_KEYS.inheritedPrefix)\n ) {\n throw new Error(\n `[surfaces] \"${declaration.surfaceName}\" declares reserved group key \"${group.key}\" — ` +\n `general/baseline/inherited:* are synthesized by the registry`,\n );\n }\n if (curatedKeys.has(group.key)) {\n throw new Error(`[surfaces] \"${declaration.surfaceName}\" declares duplicate group key \"${group.key}\"`);\n }\n curatedKeys.add(group.key);\n }\n for (const value of declaration.values) {\n if (reservedValues.has(value.name)) {\n throw new Error(\n `[surfaces] \"${declaration.surfaceName}\" declares value \"${value.name}\" — that name is written by the platform; choose another name`,\n );\n }\n if (value.group && !curatedKeys.has(value.group)) {\n throw new Error(\n `[surfaces] \"${declaration.surfaceName}\" value \"${value.name}\" references undeclared ` +\n `group \"${value.group}\" — declare it in the manifest's \\`groups\\``,\n );\n }\n }\n for (const target of declaration.writeTargets ?? []) {\n if (reservedTargets.has(target.name)) {\n throw new Error(\n `[surfaces] \"${declaration.surfaceName}\" declares write target \"${target.name}\" — that name is written by the platform; choose another name`,\n );\n }\n }\n\n const valuesByName = new Map<string, D[\"values\"][number] & ResolvedValue>();\n const inheritedLists = new Map<string, Map<string, unknown>>();\n const coreLists: { field: string; identity(entry: unknown): string }[] = [\n { field: \"configNamespaces\", identity: (entry) => (entry as { namespace: string }).namespace },\n {\n field: \"evidenceSources\",\n identity: (entry) => `${(entry as { kind: string }).kind}:${(entry as { idValue: string }).idValue}`,\n },\n ];\n const lists = [...coreLists, ...extensionList.flatMap((extension) => extension.inheritedLists ?? [])];\n for (const { layer, from } of lineage) {\n for (const value of layer.values) {\n const provenance: ValueProvenance = from ? { kind: \"inherited\", from } : { kind: \"own\" };\n valuesByName.set(value.name, {\n ...value,\n provenance,\n groupKey: groupKeyFor(value, provenance),\n resolvedSensitivity: resolveSensitivity(value),\n });\n }\n for (const list of lists) {\n const entries = (layer as unknown as Record<string, unknown>)[list.field];\n if (!Array.isArray(entries)) continue;\n const byIdentity = inheritedLists.get(list.field) ?? new Map<string, unknown>();\n for (const entry of entries) byIdentity.set(list.identity(entry), entry);\n inheritedLists.set(list.field, byIdentity);\n }\n }\n\n if (!declaration.skipBaselineValues) {\n for (const baseline of baselineValues) {\n if (valuesByName.has(baseline.name)) continue;\n valuesByName.set(baseline.name, {\n ...baseline,\n provenance: { kind: \"baseline\" },\n groupKey: RESERVED_GROUP_KEYS.baseline,\n resolvedSensitivity: resolveSensitivity(baseline),\n } as D[\"values\"][number] & ResolvedValue);\n }\n }\n\n const usedGroupKeys = new Set(Array.from(valuesByName.values(), (value) => value.groupKey));\n const groups: ValueGroup[] = [...(declaration.groups ?? [])];\n if (usedGroupKeys.has(RESERVED_GROUP_KEYS.general)) {\n groups.push({ key: RESERVED_GROUP_KEYS.general, label: \"General\", sortOrder: GENERAL_GROUP_ORDER });\n }\n for (let i = chain.length - 1, distance = 0; i >= 0; i -= 1, distance += 1) {\n const parentName = chain[i]!;\n const key = `${RESERVED_GROUP_KEYS.inheritedPrefix}${parentName}`;\n if (!usedGroupKeys.has(key)) continue;\n const parentLabel = index.get(parentName)?.label ?? parentName;\n groups.push({\n key,\n label: `Inherited from ${parentLabel}`,\n sortOrder: INHERITED_GROUP_ORDER_BASE + distance * 10,\n });\n }\n if (usedGroupKeys.has(RESERVED_GROUP_KEYS.baseline)) {\n groups.push({ key: RESERVED_GROUP_KEYS.baseline, label: \"Generic baselines\", sortOrder: BASELINE_GROUP_ORDER });\n }\n groups.sort((a, b) => a.sortOrder - b.sortOrder);\n\n const groupOrder = new Map(groups.map((group) => [group.key, group.sortOrder] as const));\n const values = Array.from(valuesByName.values()).sort((a, b) => {\n const ga = groupOrder.get(a.groupKey) ?? GENERAL_GROUP_ORDER;\n const gb = groupOrder.get(b.groupKey) ?? GENERAL_GROUP_ORDER;\n if (ga !== gb) return ga - gb;\n return (a.sortOrder ?? 1000) - (b.sortOrder ?? 1000);\n });\n\n const merged: Record<string, unknown> = {};\n for (const [field, byIdentity] of inheritedLists) {\n if (byIdentity.size > 0) merged[field] = Array.from(byIdentity.values());\n }\n return {\n ...declaration,\n values,\n groups,\n ...merged,\n contentHash: declarationHash(declaration),\n } as Resolved<D>;\n }\n\n function resolvedAll(): Resolved<D>[] {\n if (!resolvedCache) {\n resolvedCache = declarations.map(resolve);\n resolvedIndex = new Map(resolvedCache.map((entry) => [entry.surfaceName, entry] as const));\n }\n return resolvedCache;\n }\n\n const registry: DeclarationRegistry<D> = {\n register(declaration) {\n if (index.has(declaration.surfaceName)) {\n throw new Error(`[surfaces] \"${declaration.surfaceName}\" is declared twice — one surface, one declaration`);\n }\n declarations.push(declaration);\n index.set(declaration.surfaceName, declaration);\n resolvedCache = null;\n },\n registerExtension(extension) {\n if (extensionList.some((existing) => existing.key === extension.key)) {\n throw new Error(`[surfaces] declaration extension \"${extension.key}\" is registered twice`);\n }\n extensionList.push(extension);\n resolvedCache = null;\n },\n extensions: () => extensionList,\n raw: () => declarations,\n getRaw: (surfaceName) => index.get(surfaceName),\n ancestry,\n children: (surfaceName) =>\n declarations.filter((d) => d.inheritsFrom === surfaceName).map((d) => d.surfaceName),\n all: () => resolvedAll(),\n get(surfaceName) {\n resolvedAll();\n return resolvedIndex.get(surfaceName);\n },\n validate: (validateOptions) =>\n validateDeclarations(resolvedAll() as unknown as readonly ResolvedSurfaceDeclaration[], {\n ...validateOptions,\n extensions: [...(validateOptions?.extensions ?? []), ...(extensionList as DeclarationExtension[])],\n baselineNames: validateOptions?.baselineNames ?? [...baselineNames],\n }),\n };\n return registry;\n}\n"],"mappings":"AAGO,IAAM,oBAAsB,oBAGtB,gBAAkB,iCAGlB,uBAAyB,wCAS/B,SAAS,uBAAuB,IAAoC,CACzE,GAAI,CAAC,uBAAuB,KAAK,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1
|
+
{"version":3,"sources":["../src/declare/keys.ts","../src/declare/hash.ts","../src/declare/validate.ts","../src/declare/sensitivity.ts","../src/declare/registry.ts"],"sourcesContent":["import type { QualifiedValueKey } from \"./types\";\n\n/** Every value, write-target, item-type and group name (the DB CHECK rule). */\nexport const DECLARATION_NAME_RE = /^[a-z][a-z0-9_]*$/;\n\n/** \"<client>/<local>\" — the surface naming convention. */\nexport const SURFACE_NAME_RE = /^[a-z][a-z0-9-]*\\/[a-z0-9-/]+$/;\n\n/** A bare screen value (`status`) or an item value (`table_row.status`). */\nexport const QUALIFIED_VALUE_KEY_RE = /^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)?$/;\n\nexport interface ParsedValueKey {\n /** \"\" for a screen-level value. */\n itemType: string;\n name: string;\n}\n\n/** Split a qualified key; null when it is not a valid bare or qualified key. */\nexport function parseQualifiedValueKey(key: string): ParsedValueKey | null {\n if (!QUALIFIED_VALUE_KEY_RE.test(key)) return null;\n const dot = key.indexOf(\".\");\n if (dot === -1) return { itemType: \"\", name: key };\n return { itemType: key.slice(0, dot), name: key.slice(dot + 1) };\n}\n\nexport function qualifyValueKey(itemType: string, name: string): QualifiedValueKey {\n return itemType ? `${itemType}.${name}` : name;\n}\n\n/** The client that owns a surface: its name prefix. */\nexport function surfaceClientOf(surfaceName: string): string {\n return surfaceName.split(\"/\")[0] ?? \"\";\n}\n","import type { SurfaceDeclaration } from \"./types\";\n\n/** Canonical JSON: keys sorted, undefined dropped, arrays in order. */\nexport function canonicalJson(value: unknown): string {\n if (value === undefined) return \"null\";\n if (value === null || typeof value !== \"object\") return JSON.stringify(value);\n if (Array.isArray(value)) return `[${value.map((entry) => canonicalJson(entry)).join(\",\")}]`;\n const record = value as Record<string, unknown>;\n return `{${Object.keys(record)\n .filter((key) => record[key] !== undefined)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`)\n .join(\",\")}}`;\n}\n\nconst K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\n/** SHA-256 hex of a UTF-8 string. Pure, synchronous, runs anywhere (no crypto API needed). */\nexport function sha256Hex(input: string): string {\n const bytes = new TextEncoder().encode(input);\n const bitLength = bytes.length * 8;\n const padded = new Uint8Array(((bytes.length + 9 + 63) >> 6) << 6);\n padded.set(bytes);\n padded[bytes.length] = 0x80;\n const view = new DataView(padded.buffer);\n view.setUint32(padded.length - 8, Math.floor(bitLength / 0x100000000));\n view.setUint32(padded.length - 4, bitLength >>> 0);\n const h = new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n ]);\n const w = new Uint32Array(64);\n for (let offset = 0; offset < padded.length; offset += 64) {\n for (let i = 0; i < 16; i += 1) w[i] = view.getUint32(offset + i * 4);\n for (let i = 16; i < 64; i += 1) {\n const a = w[i - 15]!;\n const b = w[i - 2]!;\n const s0 = ((a >>> 7) | (a << 25)) ^ ((a >>> 18) | (a << 14)) ^ (a >>> 3);\n const s1 = ((b >>> 17) | (b << 15)) ^ ((b >>> 19) | (b << 13)) ^ (b >>> 10);\n w[i] = (w[i - 16]! + s0 + w[i - 7]! + s1) >>> 0;\n }\n let a = h[0]!, b = h[1]!, c = h[2]!, d = h[3]!, e = h[4]!, f = h[5]!, g = h[6]!, hh = h[7]!;\n for (let i = 0; i < 64; i += 1) {\n const S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));\n const ch = (e & f) ^ (~e & g);\n const t1 = (hh + S1 + ch + K[i]! + w[i]!) >>> 0;\n const S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const t2 = (S0 + maj) >>> 0;\n hh = g; g = f; f = e; e = (d + t1) >>> 0; d = c; c = b; b = a; a = (t1 + t2) >>> 0;\n }\n h[0] = (h[0]! + a) >>> 0; h[1] = (h[1]! + b) >>> 0; h[2] = (h[2]! + c) >>> 0; h[3] = (h[3]! + d) >>> 0;\n h[4] = (h[4]! + e) >>> 0; h[5] = (h[5]! + f) >>> 0; h[6] = (h[6]! + g) >>> 0; h[7] = (h[7]! + hh) >>> 0;\n }\n return Array.from(h, (word) => word.toString(16).padStart(8, \"0\")).join(\"\");\n}\n\n/**\n * Drift between clients. Computed, never authored: SHA-256 of the canonical JSON\n * of the declaration as authored (keys sorted, extension fields included).\n * Persisted as `ui_surface.content_hash` once that column exists.\n */\nexport function declarationHash(declaration: SurfaceDeclaration): string {\n return sha256Hex(canonicalJson(declaration));\n}\n","/**\n * Declaration validation — the ONE set of surface checks (CONTRACT §3 D5).\n * Ported from matrx-frontend `scripts/check-surface-drift.ts`; the app's own\n * check now runs this. Agent-owned slots (roles, client tools) validate through\n * their `DeclarationExtension`, never here.\n */\nimport { DECLARATION_NAME_RE, SURFACE_NAME_RE, surfaceClientOf } from \"./keys\";\nimport type {\n DeclarationExtension,\n DeclarationIssue,\n ResolvedSurfaceDeclaration,\n SurfaceDeclaration,\n} from \"./types\";\n\nexport const VALUE_TYPES = [\"string\", \"number\", \"boolean\", \"object\", \"array\", \"document\"] as const;\nexport const WRITE_MODES = [\"draft\", \"entity\", \"ui\", \"stream\"] as const;\nexport const APPLY_POLICIES = [\"manual\", \"ask\", \"auto\", \"queued\"] as const;\nexport const STREAM_OPS = [\"replace\", \"insert_before\", \"insert_after\", \"prepend\", \"append\", \"patch\"] as const;\nexport const EXECUTION_MODES = [\"python-stream\", \"nextjs-stream\", \"browser-realtime\", \"local-runtime\"] as const;\nexport const READINESS = [\"verified\", \"partial\", \"stub\"] as const;\nexport const LIVE_SLOTS = [\"selection\", \"on-demand\", \"errors\", \"requests\"] as const;\nexport const CLASSIFICATIONS = [\"ordinary\", \"secret\", \"credential\"] as const;\n\nconst STRUCTURED = new Set([\"object\", \"array\"]);\n\nexport interface ValidateOptions {\n /** Registered config namespaces; omitted = not checked. */\n knownNamespaces?: ReadonlySet<string>;\n /** Registered content-ir kind slugs; omitted = not checked. */\n isKnownKind?: (slug: string) => boolean;\n /** Names every declaration must expose unless `skipBaselineValues`. */\n baselineNames?: readonly string[];\n extensions?: readonly DeclarationExtension[];\n}\n\nfunction has<T extends string>(list: readonly T[], value: unknown): value is T {\n return typeof value === \"string\" && (list as readonly string[]).includes(value);\n}\n\nexport function validateDeclarations(\n declarations: readonly ResolvedSurfaceDeclaration[],\n options: ValidateOptions = {},\n): DeclarationIssue[] {\n const issues: DeclarationIssue[] = [];\n const seenSurfaces = new Set<string>();\n const labelsByClient = new Map<string, Map<string, string>>();\n\n for (const d of declarations) {\n const s = d.surfaceName;\n const push = (path: string, sentence: string, remedy: string, severity?: \"advisory\") =>\n issues.push({ surfaceName: s, path, sentence, remedy, ...(severity ? { severity } : {}) });\n\n if (seenSurfaces.has(s)) {\n push(\"surfaceName\", `Duplicate manifest surfaceName: \"${s}\" appears more than once.`, \"Keep one declaration per surface.\");\n }\n seenSurfaces.add(s);\n if (!SURFACE_NAME_RE.test(s)) {\n push(\"surfaceName\", `Surface \"${s}\" doesn't match the \"<client>/<local>\" convention.`, \"Rename it to <client>/<local>.\");\n }\n\n const prefix = surfaceClientOf(s);\n if (d.client !== prefix) {\n push(\"client\", `Surface \"${s}\" declares client \"${String(d.client)}\" but its name prefix is \"${prefix}\" — they must match.`, `Set client: \"${prefix}\".`);\n }\n if (!has(EXECUTION_MODES, d.executionMode)) {\n push(\"executionMode\", `Surface \"${s}\" has invalid executionMode \"${String(d.executionMode)}\".`, `Use one of ${EXECUTION_MODES.join(\" | \")}.`);\n }\n if (typeof d.description !== \"string\") {\n push(\"description\", `Surface \"${s}\" has no description.`, \"Add one sentence on what the surface is (\\\"\\\" only where the live row is empty).\");\n }\n\n const label = d.label?.trim();\n if (!label) {\n push(\"label\", `Surface \"${s}\" has no canonical label — label is required.`, \"Add the ONE canonical human display name.\");\n } else {\n const clientLabels = labelsByClient.get(prefix) ?? new Map<string, string>();\n const clash = clientLabels.get(label.toLowerCase());\n if (clash && clash !== s) {\n push(\"label\", `Canonical label \"${label}\" is used by both \"${clash}\" and \"${s}\" — labels must be unique per client.`, \"Give one of them a distinct label.\");\n }\n clientLabels.set(label.toLowerCase(), s);\n labelsByClient.set(prefix, clientLabels);\n }\n\n if (!has(READINESS, d.readiness)) {\n push(\"readiness\", `Surface \"${s}\" has invalid readiness \"${String(d.readiness)}\" (expected verified | partial | stub).`, \"Set a valid readiness.\");\n } else if (d.readiness !== \"verified\" && !d.readinessNote?.trim()) {\n push(\"readinessNote\", `Surface \"${s}\" is readiness \"${d.readiness}\" but has no readinessNote — say what's missing.`, \"Add a one-line readinessNote.\");\n }\n\n const groupKeys = new Set<string>();\n for (const g of d.groups ?? []) {\n groupKeys.add(g.key);\n const reserved = g.key === \"general\" || g.key === \"baseline\" || g.key.startsWith(\"inherited:\");\n if (reserved) continue;\n if (!DECLARATION_NAME_RE.test(g.key)) push(`groups/${g.key}`, `Surface \"${s}\" group \"${g.key}\" doesn't match /^[a-z][a-z0-9_]*$/.`, \"Rename the group key to lower_snake_case.\");\n if (g.sortOrder < 0 || g.sortOrder > 899) push(`groups/${g.key}/sortOrder`, `Surface \"${s}\" group \"${g.key}\" sortOrder ${g.sortOrder} is outside the curated band 0–899.`, \"Use a sortOrder between 0 and 899.\");\n if (!g.label?.trim()) push(`groups/${g.key}/label`, `Surface \"${s}\" group \"${g.key}\" has no canonical label.`, \"Add a label.\");\n }\n\n const seenNamespaces = new Set<string>();\n for (const ns of d.configNamespaces ?? []) {\n if (seenNamespaces.has(ns.namespace)) push(`configNamespaces/${ns.namespace}`, `Surface \"${s}\" declares duplicate config namespace \"${ns.namespace}\".`, \"Remove the duplicate.\");\n seenNamespaces.add(ns.namespace);\n if (options.knownNamespaces && !options.knownNamespaces.has(ns.namespace)) {\n push(`configNamespaces/${ns.namespace}`, `Surface \"${s}\" references config namespace \"${ns.namespace}\" which is not registered.`, \"Register the namespace first, or remove the reference.\");\n }\n }\n\n if (d.values.length === 0) {\n push(\"values\", `Surface \"${s}\" declares no values.`, \"Declare at least one value.\");\n continue;\n }\n\n const seenValues = new Set<string>();\n for (const v of d.values) {\n const at = `values/${v.name}`;\n if (seenValues.has(v.name)) push(at, `Surface \"${s}\" declares duplicate value \"${v.name}\".`, \"Remove the duplicate.\");\n seenValues.add(v.name);\n if (!DECLARATION_NAME_RE.test(v.name)) push(at, `Surface \"${s}\" value \"${v.name}\" doesn't match /^[a-z][a-z0-9_]*$/ — the DB CHECK constraint will reject this.`, \"Rename it to lower_snake_case.\");\n if (!has(VALUE_TYPES, v.valueType)) push(`${at}/valueType`, `Surface \"${s}\" value \"${v.name}\" has invalid valueType \"${String(v.valueType)}\".`, `Use one of ${VALUE_TYPES.join(\" | \")}.`);\n if (typeof v.typicalCharCount !== \"number\" || v.typicalCharCount < 0) push(`${at}/typicalCharCount`, `Surface \"${s}\" value \"${v.name}\" has invalid typicalCharCount.`, \"Use a non-negative number.\");\n if (v.sortOrder !== undefined && (typeof v.sortOrder !== \"number\" || v.sortOrder < 0)) push(`${at}/sortOrder`, `Surface \"${s}\" value \"${v.name}\" has invalid sortOrder.`, \"Use a non-negative number.\");\n if (v.groupKey && !groupKeys.has(v.groupKey)) push(`${at}/group`, `Surface \"${s}\" value \"${v.name}\" resolved to groupKey \"${v.groupKey}\" which is missing from the resolved groups list — registry group synthesis is broken.`, \"Fix the registry resolution.\");\n if (v.liveSlot !== undefined && !has(LIVE_SLOTS, v.liveSlot)) push(`${at}/liveSlot`, `Surface \"${s}\" value \"${v.name}\" has invalid liveSlot \"${String(v.liveSlot)}\".`, `Use one of ${LIVE_SLOTS.join(\" | \")}.`);\n if (v.role !== undefined && v.role !== \"data\" && v.role !== \"request\") push(`${at}/role`, `Surface \"${s}\" value \"${v.name}\" has invalid role \"${String(v.role)}\".`, \"Use data | request.\");\n if (v.sensitivity?.classification !== undefined && !has(CLASSIFICATIONS, v.sensitivity.classification)) push(`${at}/sensitivity/classification`, `Surface \"${s}\" value \"${v.name}\" has invalid classification \"${String(v.sensitivity.classification)}\".`, `Use one of ${CLASSIFICATIONS.join(\" | \")}.`);\n }\n\n for (const slot of d.liveSlots ?? []) {\n if (!has(LIVE_SLOTS, slot)) push(\"liveSlots\", `Surface \"${s}\" declares unknown live slot \"${String(slot)}\".`, `Use one of ${LIVE_SLOTS.join(\" | \")}.`);\n }\n\n const itemTypeNames = new Set<string>();\n for (const item of d.itemTypes ?? []) {\n const at = `itemTypes/${item.name}`;\n if (itemTypeNames.has(item.name)) push(at, `Surface \"${s}\" declares duplicate item type \"${item.name}\".`, \"Remove the duplicate.\");\n itemTypeNames.add(item.name);\n if (!DECLARATION_NAME_RE.test(item.name)) push(at, `Surface \"${s}\" item type \"${item.name}\" doesn't match /^[a-z][a-z0-9_]*$/.`, \"Rename it to lower_snake_case.\");\n if (!item.label?.trim() || !item.description?.trim()) push(at, `Surface \"${s}\" item type \"${item.name}\" needs a label and a description.`, \"Add both.\");\n const itemValues = new Set(item.values.map((v) => v.name));\n if (item.identity.length === 0) push(`${at}/identity`, `Surface \"${s}\" item type \"${item.name}\" has an empty identity.`, \"Name the value(s) that identify one item.\");\n for (const key of item.identity) {\n if (!itemValues.has(key)) push(`${at}/identity`, `Surface \"${s}\" item type \"${item.name}\" identity names \"${key}\", which is not one of its values.`, \"Declare it as an item value.\");\n }\n for (const t of item.writeTargets ?? []) {\n if (t.updatesValue && !itemValues.has(t.updatesValue)) push(`${at}/writeTargets/${t.name}`, `Surface \"${s}\" item type \"${item.name}\" write target \"${t.name}\" updatesValue \"${t.updatesValue}\" which is not an item value.`, \"Point it at a declared item value.\");\n }\n }\n\n const seenTargets = new Set<string>();\n const structuredWithoutKind: string[] = [];\n for (const w of d.writeTargets ?? []) {\n const at = `writeTargets/${w.name}`;\n if (seenTargets.has(w.name)) push(at, `Surface \"${s}\" declares duplicate write target \"${w.name}\".`, \"Remove the duplicate.\");\n seenTargets.add(w.name);\n if (!DECLARATION_NAME_RE.test(w.name)) push(at, `Surface \"${s}\" write target \"${w.name}\" doesn't match /^[a-z][a-z0-9_]*$/.`, \"Rename it to lower_snake_case.\");\n if (!w.label?.trim() || !w.description?.trim()) push(at, `Surface \"${s}\" write target \"${w.name}\" needs a label and a description.`, \"Add both.\");\n if (!has(VALUE_TYPES, w.valueType)) push(`${at}/valueType`, `Surface \"${s}\" write target \"${w.name}\" has invalid valueType \"${String(w.valueType)}\".`, `Use one of ${VALUE_TYPES.join(\" | \")}.`);\n if (!has(WRITE_MODES, w.mode)) push(`${at}/mode`, `Surface \"${s}\" write target \"${w.name}\" has invalid mode \"${String(w.mode)}\".`, `Use one of ${WRITE_MODES.join(\" | \")}.`);\n if (w.applyPolicy !== undefined && !has(APPLY_POLICIES, w.applyPolicy)) push(`${at}/applyPolicy`, `Surface \"${s}\" write target \"${w.name}\" has invalid applyPolicy \"${String(w.applyPolicy)}\".`, `Use one of ${APPLY_POLICIES.join(\" | \")}.`);\n if (w.itemType !== undefined && !itemTypeNames.has(w.itemType)) push(`${at}/itemType`, `Surface \"${s}\" write target \"${w.name}\" names item type \"${w.itemType}\", which the surface does not declare.`, \"Declare the item type or drop itemType.\");\n const readTwinDeclared = w.updatesValue ? seenValues.has(w.updatesValue) : false;\n if (w.updatesValue && !w.itemType && !readTwinDeclared) push(`${at}/updatesValue`, `Surface \"${s}\" write target \"${w.name}\" updatesValue \"${w.updatesValue}\" which is not a declared value.`, \"Point updatesValue at a declared value.\");\n if (w.patchable && !w.updatesValue) push(`${at}/patchable`, `Surface \"${s}\" write target \"${w.name}\" is patchable but declares no updatesValue — an anchored edit has nothing to read.`, \"Declare the read twin in updatesValue.\");\n if (w.patchable && w.valueType !== \"string\" && w.valueType !== \"document\") push(`${at}/patchable`, `Surface \"${s}\" write target \"${w.name}\" is patchable but valueType is \"${w.valueType}\" (patching is for \"string\" | \"document\").`, \"Drop patchable or change the value type.\");\n if (w.mode === \"stream\") {\n if (!w.streamOps || w.streamOps.length === 0) push(`${at}/streamOps`, `Surface \"${s}\" write target \"${w.name}\" is a stream target with no streamOps.`, \"List the ops it services.\");\n if (!w.updatesValue) push(`${at}/updatesValue`, `Surface \"${s}\" write target \"${w.name}\" is a stream target with no read twin.`, \"Declare updatesValue.\");\n } else if (w.streamOps !== undefined) {\n push(`${at}/streamOps`, `Surface \"${s}\" write target \"${w.name}\" lists streamOps but its mode is \"${w.mode}\".`, \"streamOps belong only to mode \\\"stream\\\".\");\n }\n for (const op of w.streamOps ?? []) {\n if (!has(STREAM_OPS, op)) push(`${at}/streamOps`, `Surface \"${s}\" write target \"${w.name}\" lists unknown stream op \"${String(op)}\".`, `Use ${STREAM_OPS.join(\" | \")}.`);\n }\n if (w.group && !groupKeys.has(w.group)) push(`${at}/group`, `Surface \"${s}\" write target \"${w.name}\" references undeclared group \"${w.group}\".`, \"Declare the group or drop it.\");\n if (w.valueKind !== undefined) {\n if (typeof w.valueKind !== \"string\" || !w.valueKind.trim()) {\n push(`${at}/valueKind`, `Surface \"${s}\" write target \"${w.name}\" has an empty valueKind.`, \"Name a registered kind slug or omit the field.\");\n } else if (options.isKnownKind && !options.isKnownKind(w.valueKind)) {\n push(`${at}/valueKind`, `Surface \"${s}\" write target \"${w.name}\" declares valueKind \"${w.valueKind}\", which is not a registered active kind.`, \"Name a registered kind slug, or register the kind first; never inline a JSON schema.\");\n }\n } else if (STRUCTURED.has(w.valueType)) {\n structuredWithoutKind.push(w.name);\n }\n }\n for (const name of structuredWithoutKind) {\n push(`writeTargets/${name}/valueKind`, `Surface \"${s}\" structured write target \"${name}\" declares no valueKind.`, \"Name a registered kind slug (the value contract ratchet).\", \"advisory\");\n }\n\n if (!d.skipBaselineValues && options.baselineNames) {\n const missing = options.baselineNames.filter((name) => !seenValues.has(name));\n if (missing.length > 0) {\n push(\"values\", `Surface \"${s}\" is missing baseline value(s): ${missing.join(\", \")}.`, \"The registry injects baselines automatically; opt out only with skipBaselineValues.\");\n }\n }\n }\n\n for (const extension of options.extensions ?? []) {\n if (!extension.validate) continue;\n for (const d of declarations) issues.push(...extension.validate(d as SurfaceDeclaration & ResolvedSurfaceDeclaration, { all: declarations }));\n }\n return issues;\n}\n\n/**\n * The runtime half: a loaded scope may carry only declared values. Returns one\n * issue per undeclared key (and per `__item` value its item type does not declare).\n */\nexport function validateLoadedValues(\n declaration: Pick<ResolvedSurfaceDeclaration, \"surfaceName\" | \"values\" | \"itemTypes\">,\n loaded: Record<string, unknown>,\n options: { ignore?: readonly string[] } = {},\n): DeclarationIssue[] {\n const declared = new Set(declaration.values.map((v) => v.name));\n const ignore = new Set(options.ignore ?? []);\n const issues: DeclarationIssue[] = [];\n for (const key of Object.keys(loaded)) {\n if (key === \"__item\" || declared.has(key) || ignore.has(key)) continue;\n issues.push({\n surfaceName: declaration.surfaceName,\n path: `values/${key}`,\n sentence: `Surface \"${declaration.surfaceName}\" loaded a value \"${key}\" it never declared.`,\n remedy: `Declare \"${key}\" in the surface's values, or stop emitting it.`,\n });\n }\n const item = loaded.__item as { itemType?: unknown; values?: unknown } | undefined;\n if (item && typeof item === \"object\") {\n const type = declaration.itemTypes?.find((t) => t.name === item.itemType);\n if (!type) {\n issues.push({\n surfaceName: declaration.surfaceName,\n path: \"__item/itemType\",\n sentence: `Surface \"${declaration.surfaceName}\" loaded an item of type \"${String(item.itemType)}\" it never declared.`,\n remedy: \"Declare the item type, or stop emitting the item.\",\n });\n } else if (item.values && typeof item.values === \"object\") {\n const itemDeclared = new Set(type.values.map((v) => v.name));\n for (const key of Object.keys(item.values)) {\n if (itemDeclared.has(key)) continue;\n issues.push({\n surfaceName: declaration.surfaceName,\n path: `__item/${type.name}.${key}`,\n sentence: `Surface \"${declaration.surfaceName}\" loaded item value \"${type.name}.${key}\" it never declared.`,\n remedy: `Declare \"${key}\" on item type \"${type.name}\".`,\n });\n }\n }\n }\n return issues;\n}\n\n/** A `ui.ui_surface` row as the orphan check reads it. */\nexport interface SurfaceOwnershipRow {\n name: string;\n /** \"database\" rows are owned by their organization, never by code; absent reads as \"code\". */\n declared_by?: \"code\" | \"database\" | string | null;\n}\n\n/**\n * Ownership: no CODE `ui.ui_surface` row may exist without a declaring owner\n * (CONTRACT §2.1a). `retired` rows (archived, not deleted) are exempt, and so\n * is every row an organization declared in the database (`declared_by =\n * \"database\"`, Applets CONTRACTS §6). Rows may be bare names or `{ name, declared_by }`.\n */\nexport function findOrphanRows(\n rows: readonly (string | SurfaceOwnershipRow)[],\n declaredNames: Iterable<string>,\n retired: Iterable<string> = [],\n): string[] {\n const owned = new Set(declaredNames);\n const archived = new Set(retired);\n return rows\n .filter((row) => typeof row === \"string\" || row.declared_by !== \"database\")\n .map((row) => (typeof row === \"string\" ? row : row.name))\n .filter((name) => !owned.has(name) && !archived.has(name))\n .sort();\n}\n","/**\n * Sensitivity defaults and resolution (CONTRACT §2.1). Its own module so the\n * lightweight entries (`/actions`, the T0 React host) can project without\n * pulling the declaration registry.\n */\nimport type { DeclaredValue, Sensitivity } from \"./types\";\n\nexport const DEFAULT_SENSITIVITY: Sensitivity = Object.freeze({\n exportable: true,\n classification: \"ordinary\",\n includedByDefault: true,\n});\n\nexport function resolveSensitivity(value: Pick<DeclaredValue, \"sensitivity\">): Sensitivity {\n return {\n exportable: value.sensitivity?.exportable ?? DEFAULT_SENSITIVITY.exportable,\n classification: value.sensitivity?.classification ?? DEFAULT_SENSITIVITY.classification,\n includedByDefault: value.sensitivity?.includedByDefault ?? DEFAULT_SENSITIVITY.includedByDefault,\n };\n}\n","/**\n * The declaration registry: inheritance, baseline injection, provenance and\n * group synthesis (CONTRACT §2.1 `DeclarationRegistry`). Ported verbatim in\n * behaviour from matrx-frontend `features/surfaces/manifests/registry.ts`\n * (ALC-14); the app now supplies its declarations and baselines.\n *\n * Guards are LOUD by design: an unknown parent, a cycle, a chain deeper than\n * the limit, a reserved or duplicate group key, a value naming an undeclared\n * group, or a reserved platform name throws on resolution — a build fails\n * instead of silently dropping values.\n */\nimport { declarationHash } from \"./hash\";\nimport type {\n DeclarationExtension,\n DeclarationIssue,\n DeclaredValue,\n ResolvedSurfaceDeclaration,\n ResolvedValue,\n Sensitivity,\n SurfaceDeclaration,\n ValueGroup,\n ValueProvenance,\n} from \"./types\";\nimport { validateDeclarations, type ValidateOptions } from \"./validate\";\n\nexport const RESERVED_GROUP_KEYS = {\n general: \"general\",\n baseline: \"baseline\",\n inheritedPrefix: \"inherited:\",\n} as const;\n\n/** Group sortOrder bands. Curated groups author 0–899; the rest is reserved. */\nexport const GENERAL_GROUP_ORDER = 850;\nexport const INHERITED_GROUP_ORDER_BASE = 9000;\nexport const BASELINE_GROUP_ORDER = 9900;\nexport const DEFAULT_MAX_INHERITANCE_DEPTH = 3;\n\nimport { DEFAULT_SENSITIVITY, resolveSensitivity } from \"./sensitivity\";\nexport { DEFAULT_SENSITIVITY, resolveSensitivity };\n\nexport type Resolved<D extends SurfaceDeclaration> = Omit<D, \"values\" | \"groups\"> & {\n values: readonly (D[\"values\"][number] & ResolvedValue)[];\n groups: readonly ValueGroup[];\n contentHash: string;\n};\n\nexport interface DeclarationRegistryOptions {\n /** Generic values injected into every declaration unless `skipBaselineValues`. */\n baselineValues?: readonly DeclaredValue[];\n /** Value names only the platform writes; a declaration claiming one is refused. */\n reservedValueNames?: readonly string[];\n /** Write-target names only the platform writes. */\n reservedWriteTargetNames?: readonly string[];\n maxInheritanceDepth?: number;\n}\n\nexport interface DeclarationRegistry<D extends SurfaceDeclaration> {\n /** Refuses a second declaration of the same surfaceName. */\n register(declaration: D): void;\n registerExtension(extension: DeclarationExtension<D>): void;\n extensions(): readonly DeclarationExtension<D>[];\n /** Declarations exactly as authored (inheritance unresolved, no baselines). */\n raw(): readonly D[];\n getRaw(surfaceName: string): D | undefined;\n /** Parent chain, ROOT FIRST. Unknown surfaces return []. */\n ancestry(surfaceName: string): string[];\n /** Direct children (declarations naming it in `inheritsFrom`), in declaration order. */\n children(surfaceName: string): string[];\n /** Inheritance + baseline + groups resolved; provenance kept. */\n all(): readonly Resolved<D>[];\n get(surfaceName: string): Resolved<D> | undefined;\n validate(options?: ValidateOptions): readonly DeclarationIssue[];\n}\n\nexport function createDeclarationRegistry<D extends SurfaceDeclaration>(\n options: DeclarationRegistryOptions = {},\n): DeclarationRegistry<D> {\n const baselineValues = options.baselineValues ?? [];\n const baselineNames = new Set(baselineValues.map((v) => v.name));\n const reservedValues = new Set(options.reservedValueNames ?? []);\n const reservedTargets = new Set(options.reservedWriteTargetNames ?? []);\n const maxDepth = options.maxInheritanceDepth ?? DEFAULT_MAX_INHERITANCE_DEPTH;\n const declarations: D[] = [];\n const index = new Map<string, D>();\n const extensionList: DeclarationExtension<D>[] = [];\n let resolvedCache: Resolved<D>[] | null = null;\n let resolvedIndex = new Map<string, Resolved<D>>();\n\n function ancestry(surfaceName: string): string[] {\n const chain: string[] = [];\n const seen = new Set<string>([surfaceName]);\n let current = index.get(surfaceName)?.inheritsFrom;\n while (current) {\n if (seen.has(current)) {\n throw new Error(\n `[surfaces] inheritsFrom CYCLE detected at \"${current}\" (from \"${surfaceName}\"). ` +\n `Fix the manifest chain: ${[...seen].join(\" → \")} → ${current}`,\n );\n }\n const parent = index.get(current);\n if (!parent) {\n throw new Error(\n `[surfaces] \"${surfaceName}\" inheritsFrom unknown surface \"${current}\" — ` +\n `the parent must be a registered declaration`,\n );\n }\n seen.add(current);\n chain.unshift(current);\n if (chain.length > maxDepth) {\n throw new Error(\n `[surfaces] inheritance chain for \"${surfaceName}\" exceeds depth ${maxDepth}: ` + chain.join(\" → \"),\n );\n }\n current = parent.inheritsFrom;\n }\n return chain;\n }\n\n function groupKeyFor(value: DeclaredValue, provenance: ValueProvenance): string {\n if (provenance.kind === \"own\" && value.group) return value.group;\n if (baselineNames.has(value.name)) return RESERVED_GROUP_KEYS.baseline;\n if (provenance.kind === \"inherited\") return `${RESERVED_GROUP_KEYS.inheritedPrefix}${provenance.from}`;\n if (provenance.kind === \"baseline\") return RESERVED_GROUP_KEYS.baseline;\n return RESERVED_GROUP_KEYS.general;\n }\n\n function resolve(declaration: D): Resolved<D> {\n const chain = ancestry(declaration.surfaceName);\n const lineage: { layer: D; from: string | null }[] = [\n ...chain.map((name) => {\n const layer = index.get(name);\n if (!layer) throw new Error(`[surfaces] missing inherited declaration \"${name}\"`);\n return { layer, from: name };\n }),\n { layer: declaration, from: null },\n ];\n\n const curatedKeys = new Set<string>();\n for (const group of declaration.groups ?? []) {\n if (\n group.key === RESERVED_GROUP_KEYS.general ||\n group.key === RESERVED_GROUP_KEYS.baseline ||\n group.key.startsWith(RESERVED_GROUP_KEYS.inheritedPrefix)\n ) {\n throw new Error(\n `[surfaces] \"${declaration.surfaceName}\" declares reserved group key \"${group.key}\" — ` +\n `general/baseline/inherited:* are synthesized by the registry`,\n );\n }\n if (curatedKeys.has(group.key)) {\n throw new Error(`[surfaces] \"${declaration.surfaceName}\" declares duplicate group key \"${group.key}\"`);\n }\n curatedKeys.add(group.key);\n }\n for (const value of declaration.values) {\n if (reservedValues.has(value.name)) {\n throw new Error(\n `[surfaces] \"${declaration.surfaceName}\" declares value \"${value.name}\" — that name is written by the platform; choose another name`,\n );\n }\n if (value.group && !curatedKeys.has(value.group)) {\n throw new Error(\n `[surfaces] \"${declaration.surfaceName}\" value \"${value.name}\" references undeclared ` +\n `group \"${value.group}\" — declare it in the manifest's \\`groups\\``,\n );\n }\n }\n for (const target of declaration.writeTargets ?? []) {\n if (reservedTargets.has(target.name)) {\n throw new Error(\n `[surfaces] \"${declaration.surfaceName}\" declares write target \"${target.name}\" — that name is written by the platform; choose another name`,\n );\n }\n }\n\n const valuesByName = new Map<string, D[\"values\"][number] & ResolvedValue>();\n const inheritedLists = new Map<string, Map<string, unknown>>();\n const coreLists: { field: string; identity(entry: unknown): string }[] = [\n { field: \"configNamespaces\", identity: (entry) => (entry as { namespace: string }).namespace },\n {\n field: \"evidenceSources\",\n identity: (entry) => `${(entry as { kind: string }).kind}:${(entry as { idValue: string }).idValue}`,\n },\n ];\n const lists = [...coreLists, ...extensionList.flatMap((extension) => extension.inheritedLists ?? [])];\n for (const { layer, from } of lineage) {\n for (const value of layer.values) {\n const provenance: ValueProvenance = from ? { kind: \"inherited\", from } : { kind: \"own\" };\n valuesByName.set(value.name, {\n ...value,\n provenance,\n groupKey: groupKeyFor(value, provenance),\n resolvedSensitivity: resolveSensitivity(value),\n });\n }\n for (const list of lists) {\n const entries = (layer as unknown as Record<string, unknown>)[list.field];\n if (!Array.isArray(entries)) continue;\n const byIdentity = inheritedLists.get(list.field) ?? new Map<string, unknown>();\n for (const entry of entries) byIdentity.set(list.identity(entry), entry);\n inheritedLists.set(list.field, byIdentity);\n }\n }\n\n if (!declaration.skipBaselineValues) {\n for (const baseline of baselineValues) {\n if (valuesByName.has(baseline.name)) continue;\n valuesByName.set(baseline.name, {\n ...baseline,\n provenance: { kind: \"baseline\" },\n groupKey: RESERVED_GROUP_KEYS.baseline,\n resolvedSensitivity: resolveSensitivity(baseline),\n } as D[\"values\"][number] & ResolvedValue);\n }\n }\n\n const usedGroupKeys = new Set(Array.from(valuesByName.values(), (value) => value.groupKey));\n const groups: ValueGroup[] = [...(declaration.groups ?? [])];\n if (usedGroupKeys.has(RESERVED_GROUP_KEYS.general)) {\n groups.push({ key: RESERVED_GROUP_KEYS.general, label: \"General\", sortOrder: GENERAL_GROUP_ORDER });\n }\n for (let i = chain.length - 1, distance = 0; i >= 0; i -= 1, distance += 1) {\n const parentName = chain[i]!;\n const key = `${RESERVED_GROUP_KEYS.inheritedPrefix}${parentName}`;\n if (!usedGroupKeys.has(key)) continue;\n const parentLabel = index.get(parentName)?.label ?? parentName;\n groups.push({\n key,\n label: `Inherited from ${parentLabel}`,\n sortOrder: INHERITED_GROUP_ORDER_BASE + distance * 10,\n });\n }\n if (usedGroupKeys.has(RESERVED_GROUP_KEYS.baseline)) {\n groups.push({ key: RESERVED_GROUP_KEYS.baseline, label: \"Generic baselines\", sortOrder: BASELINE_GROUP_ORDER });\n }\n groups.sort((a, b) => a.sortOrder - b.sortOrder);\n\n const groupOrder = new Map(groups.map((group) => [group.key, group.sortOrder] as const));\n const values = Array.from(valuesByName.values()).sort((a, b) => {\n const ga = groupOrder.get(a.groupKey) ?? GENERAL_GROUP_ORDER;\n const gb = groupOrder.get(b.groupKey) ?? GENERAL_GROUP_ORDER;\n if (ga !== gb) return ga - gb;\n return (a.sortOrder ?? 1000) - (b.sortOrder ?? 1000);\n });\n\n const merged: Record<string, unknown> = {};\n for (const [field, byIdentity] of inheritedLists) {\n if (byIdentity.size > 0) merged[field] = Array.from(byIdentity.values());\n }\n return {\n ...declaration,\n values,\n groups,\n ...merged,\n contentHash: declarationHash(declaration),\n } as Resolved<D>;\n }\n\n function resolvedAll(): Resolved<D>[] {\n if (!resolvedCache) {\n resolvedCache = declarations.map(resolve);\n resolvedIndex = new Map(resolvedCache.map((entry) => [entry.surfaceName, entry] as const));\n }\n return resolvedCache;\n }\n\n const registry: DeclarationRegistry<D> = {\n register(declaration) {\n if (index.has(declaration.surfaceName)) {\n throw new Error(`[surfaces] \"${declaration.surfaceName}\" is declared twice — one surface, one declaration`);\n }\n declarations.push(declaration);\n index.set(declaration.surfaceName, declaration);\n resolvedCache = null;\n },\n registerExtension(extension) {\n if (extensionList.some((existing) => existing.key === extension.key)) {\n throw new Error(`[surfaces] declaration extension \"${extension.key}\" is registered twice`);\n }\n extensionList.push(extension);\n resolvedCache = null;\n },\n extensions: () => extensionList,\n raw: () => declarations,\n getRaw: (surfaceName) => index.get(surfaceName),\n ancestry,\n children: (surfaceName) =>\n declarations.filter((d) => d.inheritsFrom === surfaceName).map((d) => d.surfaceName),\n all: () => resolvedAll(),\n get(surfaceName) {\n resolvedAll();\n return resolvedIndex.get(surfaceName);\n },\n validate: (validateOptions) =>\n validateDeclarations(resolvedAll() as unknown as readonly ResolvedSurfaceDeclaration[], {\n ...validateOptions,\n extensions: [...(validateOptions?.extensions ?? []), ...(extensionList as DeclarationExtension[])],\n baselineNames: validateOptions?.baselineNames ?? [...baselineNames],\n }),\n };\n return registry;\n}\n"],"mappings":"AAGO,IAAM,oBAAsB,oBAGtB,gBAAkB,iCAGlB,uBAAyB,wCAS/B,SAAS,uBAAuB,IAAoC,CACzE,GAAI,CAAC,uBAAuB,KAAK,GAAG,EAAG,OAAO,KAC9C,IAAM,IAAM,IAAI,QAAQ,GAAG,EAC3B,OAAI,MAAQ,GAAW,CAAE,SAAU,GAAI,KAAM,GAAI,EAC1C,CAAE,SAAU,IAAI,MAAM,EAAG,GAAG,EAAG,KAAM,IAAI,MAAM,IAAM,CAAC,CAAE,CACjE,CAEO,SAAS,gBAAgB,SAAkB,KAAiC,CACjF,OAAO,SAAW,GAAG,QAAQ,IAAI,IAAI,GAAK,IAC5C,CAGO,SAAS,gBAAgB,YAA6B,CAC3D,OAAO,YAAY,MAAM,GAAG,EAAE,CAAC,GAAK,EACtC,CC7BO,SAAS,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,OAAK,gBACH,cAAgB,aAAa,IAAI,OAAO,EACxC,cAAgB,IAAI,IAAI,cAAc,IAAK,OAAU,CAAC,MAAM,YAAa,KAAK,CAAU,CAAC,GAEpF,aACT,CAoCA,MAlCyC,CACvC,SAAS,YAAa,CACpB,GAAI,MAAM,IAAI,YAAY,WAAW,EACnC,MAAM,IAAI,MAAM,eAAe,YAAY,WAAW,yDAAoD,EAE5G,aAAa,KAAK,WAAW,EAC7B,MAAM,IAAI,YAAY,YAAa,WAAW,EAC9C,cAAgB,IAClB,EACA,kBAAkB,UAAW,CAC3B,GAAI,cAAc,KAAM,UAAa,SAAS,MAAQ,UAAU,GAAG,EACjE,MAAM,IAAI,MAAM,qCAAqC,UAAU,GAAG,uBAAuB,EAE3F,cAAc,KAAK,SAAS,EAC5B,cAAgB,IAClB,EACA,WAAY,IAAM,cAClB,IAAK,IAAM,aACX,OAAS,aAAgB,MAAM,IAAI,WAAW,EAC9C,SACA,SAAW,aACT,aAAa,OAAQ,GAAM,EAAE,eAAiB,WAAW,EAAE,IAAK,GAAM,EAAE,WAAW,EACrF,IAAK,IAAM,YAAY,EACvB,IAAI,YAAa,CACf,mBAAY,EACL,cAAc,IAAI,WAAW,CACtC,EACA,SAAW,iBACT,qBAAqB,YAAY,EAAuD,CACtF,GAAG,gBACH,WAAY,CAAC,GAAI,iBAAiB,YAAc,CAAC,EAAI,GAAI,aAAwC,EACjG,cAAe,iBAAiB,eAAiB,CAAC,GAAG,aAAa,CACpE,CAAC,CACL,CAEF","names":["a","b"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Framework-neutral transfer contracts (Alchemy Operate, CONTRACT §2.3). All data crossing this boundary is JSON.
|
|
3
3
|
* Moved from `@ai-matrx/kit/content-transfer` in ALC-16; the format-adapter contract lives in `./contract`.
|
|
4
4
|
*/
|
|
5
|
-
type Json$
|
|
6
|
-
[key: string]: Json$
|
|
5
|
+
type Json$2 = null | boolean | number | string | Json$2[] | {
|
|
6
|
+
[key: string]: Json$2;
|
|
7
7
|
};
|
|
8
8
|
type Payload =
|
|
9
9
|
/** A text payload may name its language (code blocks): downloads take its extension, Markdown fences it. */
|
|
@@ -16,15 +16,15 @@ type Payload =
|
|
|
16
16
|
text: string;
|
|
17
17
|
} | {
|
|
18
18
|
kind: "json";
|
|
19
|
-
value: Json$
|
|
19
|
+
value: Json$2;
|
|
20
20
|
} | {
|
|
21
21
|
kind: "rows";
|
|
22
|
-
rows: Record<string, Json$
|
|
22
|
+
rows: Record<string, Json$2>[];
|
|
23
23
|
columns: Column[];
|
|
24
24
|
} | {
|
|
25
25
|
kind: "registered";
|
|
26
26
|
format: string;
|
|
27
|
-
value: Json$
|
|
27
|
+
value: Json$2;
|
|
28
28
|
};
|
|
29
29
|
type Column = {
|
|
30
30
|
id: string;
|
|
@@ -38,9 +38,9 @@ type Column = {
|
|
|
38
38
|
dataType?: string;
|
|
39
39
|
order?: number;
|
|
40
40
|
required?: boolean;
|
|
41
|
-
defaultValue?: Json$
|
|
42
|
-
validation?: Json$
|
|
43
|
-
metadata?: Json$
|
|
41
|
+
defaultValue?: Json$2;
|
|
42
|
+
validation?: Json$2;
|
|
43
|
+
metadata?: Json$2;
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
type ExportProjection = {
|
|
@@ -93,21 +93,21 @@ type Snapshot = RawSnapshot & {
|
|
|
93
93
|
type QuerySnapshot = {
|
|
94
94
|
sourceId: string;
|
|
95
95
|
revision: string;
|
|
96
|
-
query: Json$
|
|
96
|
+
query: Json$2;
|
|
97
97
|
order: {
|
|
98
98
|
field: string;
|
|
99
99
|
direction: "asc" | "desc";
|
|
100
100
|
}[];
|
|
101
101
|
};
|
|
102
102
|
type ExportPage = {
|
|
103
|
-
rows: Record<string, Json$
|
|
103
|
+
rows: Record<string, Json$2>[];
|
|
104
104
|
nextCursor: string | null;
|
|
105
105
|
coverage: Coverage;
|
|
106
106
|
consistencyToken: string | null;
|
|
107
107
|
};
|
|
108
108
|
type CapturedAllMatching = {
|
|
109
109
|
query: QuerySnapshot;
|
|
110
|
-
getRowId(row: Record<string, Json$
|
|
110
|
+
getRowId(row: Record<string, Json$2>): string;
|
|
111
111
|
page(request: {
|
|
112
112
|
query: QuerySnapshot;
|
|
113
113
|
cursor: string | null;
|
|
@@ -147,7 +147,7 @@ type Draft = {
|
|
|
147
147
|
};
|
|
148
148
|
type Transform = {
|
|
149
149
|
id: string;
|
|
150
|
-
apply(draft: Draft, options: Json$
|
|
150
|
+
apply(draft: Draft, options: Json$2, signal: AbortSignal): Promise<Draft>;
|
|
151
151
|
};
|
|
152
152
|
type Artifact = {
|
|
153
153
|
snapshotId: string;
|
|
@@ -338,9 +338,9 @@ type BoundAllMatching = {
|
|
|
338
338
|
type NormalizeTransferJsonOptions = {
|
|
339
339
|
omitUndefinedObjectProperties?: boolean;
|
|
340
340
|
};
|
|
341
|
-
declare function normalizeTransferJson(value: unknown, options?: NormalizeTransferJsonOptions): Json$
|
|
341
|
+
declare function normalizeTransferJson(value: unknown, options?: NormalizeTransferJsonOptions): Json$2;
|
|
342
342
|
/** Column ids are identities, never an alternative data address. */
|
|
343
|
-
declare function readTransferCell(row: Record<string, Json$
|
|
343
|
+
declare function readTransferCell(row: Record<string, Json$2>, column: Column): Json$2 | undefined;
|
|
344
344
|
declare function projectSnapshot(raw: RawSnapshot, projection: ExportProjection): Snapshot;
|
|
345
345
|
declare function directSource(payload: Payload, options?: Partial<Pick<RawSnapshot, "id" | "sourceId" | "revision" | "label" | "coverage" | "unsavedChanges" | "sections" | "limits"> & {
|
|
346
346
|
projection: ExportProjection;
|
|
@@ -385,7 +385,7 @@ declare function reduceJson(draft: Draft, options: {
|
|
|
385
385
|
maxArrayItems?: number | null;
|
|
386
386
|
}): Draft;
|
|
387
387
|
declare function collectAllMatching(c: BoundAllMatching, signal: AbortSignal): Promise<{
|
|
388
|
-
rows: Record<string, Json$
|
|
388
|
+
rows: Record<string, Json$2>[];
|
|
389
389
|
coverage: RawSnapshot["coverage"];
|
|
390
390
|
omissions: Omission[];
|
|
391
391
|
error?: ContentTransferError;
|
|
@@ -433,6 +433,16 @@ declare function createSurfaceTransferHandle(options: {
|
|
|
433
433
|
/** Applies explicit preparation/source limits with exact omissions; token target is advisory. */
|
|
434
434
|
declare function applyTransferLimits(draft: Draft, limits: Partial<TransferLimits>): Draft;
|
|
435
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Matrx Alchemy — Declare types (CONTRACT §2.1).
|
|
438
|
+
*
|
|
439
|
+
* A declaration is plain JSON data (chair ruling N2): no functions, no classes,
|
|
440
|
+
* no React. Runtime behaviour lives in `MountedSurface` (`/declare/host`) and in
|
|
441
|
+
* handler registrations, never here. Zero React, zero `@ai-matrx/agents`.
|
|
442
|
+
*/
|
|
443
|
+
type Json$1 = null | boolean | number | string | Json$1[] | {
|
|
444
|
+
[key: string]: Json$1;
|
|
445
|
+
};
|
|
436
446
|
/** Unchanged from `ui_surface_value_type_chk`. */
|
|
437
447
|
type ValueType = "string" | "number" | "boolean" | "object" | "array" | "document";
|
|
438
448
|
type Classification = "ordinary" | "secret" | "credential";
|
|
@@ -639,6 +649,75 @@ interface ClickTarget {
|
|
|
639
649
|
host?: unknown;
|
|
640
650
|
}
|
|
641
651
|
|
|
652
|
+
/**
|
|
653
|
+
* Surface Actions — the shapes (Applets CONTRACTS §6, FROZEN; exported here as a superset).
|
|
654
|
+
*
|
|
655
|
+
* An Action is one thing a surface can have done to it, by a person, an agent,
|
|
656
|
+
* an applet or an automation: a write target, a client tool, a Kind Action or a
|
|
657
|
+
* row in `ui.ui_surface_action`. All of them project onto `ActionDeclaration`
|
|
658
|
+
* (`./declarations.ts`) and run through ONE runner (`./surface-run.ts`). There is
|
|
659
|
+
* never a second registry: `name` IS the alchemy action id, and `category`
|
|
660
|
+
* defaults to "applet" in alchemy's closed `ActionCategory` union.
|
|
661
|
+
*
|
|
662
|
+
* Types only — no runtime code, no React, no `@ai-matrx/agents`. `/ports`
|
|
663
|
+
* imports from here, so this file imports nothing but local types.
|
|
664
|
+
*/
|
|
665
|
+
|
|
666
|
+
/** Who started a run. */
|
|
667
|
+
type ActionCaller = "person" | "agent" | "applet" | "automation";
|
|
668
|
+
/** Who may run it without a click: "manual" = only a person; "ask" = proposed first; "auto" = runs. */
|
|
669
|
+
type ActionPolicy = "ask" | "auto" | "manual";
|
|
670
|
+
interface ActionContext {
|
|
671
|
+
runId: string;
|
|
672
|
+
by: ActionCaller;
|
|
673
|
+
viewerId: string | null;
|
|
674
|
+
surfaceName?: string;
|
|
675
|
+
policy?: ActionPolicy;
|
|
676
|
+
}
|
|
677
|
+
/** The system's own sentence, never thrown into a UI. Superset of RecordsError (CONTRACTS §0 `AppletError`). */
|
|
678
|
+
interface ActionError {
|
|
679
|
+
code: string;
|
|
680
|
+
message: string;
|
|
681
|
+
retryable: boolean;
|
|
682
|
+
diagnostic?: string;
|
|
683
|
+
}
|
|
684
|
+
/** CONTRACTS §0 `Result<T>`. */
|
|
685
|
+
type ActionResult<T = unknown> = {
|
|
686
|
+
ok: true;
|
|
687
|
+
data: T;
|
|
688
|
+
} | {
|
|
689
|
+
ok: false;
|
|
690
|
+
error: ActionError;
|
|
691
|
+
};
|
|
692
|
+
/** `POST /actions/run` (aidream) — the request. */
|
|
693
|
+
interface ServerActionRunRequest {
|
|
694
|
+
name: string;
|
|
695
|
+
input: Json$1;
|
|
696
|
+
by: ActionCaller;
|
|
697
|
+
surface_name?: string;
|
|
698
|
+
policy?: ActionPolicy;
|
|
699
|
+
}
|
|
700
|
+
/** `POST /actions/run` (aidream) — the response. */
|
|
701
|
+
interface ServerActionRunResponse {
|
|
702
|
+
status: "applied" | "proposed" | "refused";
|
|
703
|
+
message: string;
|
|
704
|
+
receipts: Json$1[];
|
|
705
|
+
proposal?: Json$1;
|
|
706
|
+
}
|
|
707
|
+
/** A mandate run request: by alias (an Action's `target`) or by key. */
|
|
708
|
+
type MandateRunRequest = ({
|
|
709
|
+
alias: string;
|
|
710
|
+
key?: never;
|
|
711
|
+
} | {
|
|
712
|
+
key: string;
|
|
713
|
+
alias?: never;
|
|
714
|
+
}) & {
|
|
715
|
+
variables: Record<string, Json$1>;
|
|
716
|
+
userInput?: string;
|
|
717
|
+
by: ActionCaller;
|
|
718
|
+
policy: ActionPolicy;
|
|
719
|
+
};
|
|
720
|
+
|
|
642
721
|
/**
|
|
643
722
|
* `@ai-matrx/alchemy/ports` — the host ports (Matrx Alchemy CONTRACT §2.2).
|
|
644
723
|
*
|
|
@@ -687,6 +766,12 @@ interface ClickTarget {
|
|
|
687
766
|
* to an overlay carrying the session as data)
|
|
688
767
|
* transferKnobs absent → no organization default recipe; a person's own
|
|
689
768
|
* default (persistence) or the package's Full applies
|
|
769
|
+
* serverActions absent → `runs: "server"` Actions refuse with "not available here"
|
|
770
|
+
* mandates absent → `runs: "mandate"` Actions refuse the same way
|
|
771
|
+
* pageActions absent → `runs: "page"` Actions refuse the same way
|
|
772
|
+
* approvals absent → a policy "ask" Action started by an agent, applet or automation is refused
|
|
773
|
+
* ("needs a person's approval"); a person's own click is the approval
|
|
774
|
+
* (`runs: "navigate"` goes through `overlay.navigate`; overlay absent → refused)
|
|
690
775
|
*
|
|
691
776
|
* Types only: this entry has no runtime code.
|
|
692
777
|
*/
|
|
@@ -832,6 +917,36 @@ interface AlchemyHostPorts {
|
|
|
832
917
|
window?: WindowPort;
|
|
833
918
|
/** Organization default recipes, resolved by the host's Feature Knob ladder (platform → organization). */
|
|
834
919
|
transferKnobs?: TransferKnobsPort;
|
|
920
|
+
/** aidream `POST /actions/run`: a registered server action by name, as the caller, under the apply-policy cascade. */
|
|
921
|
+
serverActions?: ServerActionPort;
|
|
922
|
+
/** Runs a mandate by alias or key (the host binds `@ai-matrx/agents`; alchemy never imports it). */
|
|
923
|
+
mandates?: MandatePort;
|
|
924
|
+
/** The page's own handlers for `runs: "page"` Actions (in an applet frame: routed as `{ action, input, runId }`). */
|
|
925
|
+
pageActions?: PageActionPort;
|
|
926
|
+
/** Asks a person, in place, to approve an `ask` Action that an agent, applet or automation started. */
|
|
927
|
+
approvals?: ApprovalPort;
|
|
928
|
+
}
|
|
929
|
+
interface ServerActionPort {
|
|
930
|
+
run(request: ServerActionRunRequest): Promise<ServerActionRunResponse>;
|
|
931
|
+
}
|
|
932
|
+
interface MandatePort {
|
|
933
|
+
/** Resolves with the run's result (a kind envelope or JSON); rejects with the system's sentence. */
|
|
934
|
+
run(request: MandateRunRequest): Promise<unknown>;
|
|
935
|
+
}
|
|
936
|
+
interface ApprovalRequest {
|
|
937
|
+
action: string;
|
|
938
|
+
label: string;
|
|
939
|
+
description: string;
|
|
940
|
+
input: Json;
|
|
941
|
+
by: "agent" | "applet" | "automation";
|
|
942
|
+
surfaceName: string;
|
|
943
|
+
}
|
|
944
|
+
interface ApprovalPort {
|
|
945
|
+
/** Resolves true when the person approves; false when they decline or dismiss. */
|
|
946
|
+
ask(request: ApprovalRequest): Promise<boolean>;
|
|
947
|
+
}
|
|
948
|
+
interface PageActionPort {
|
|
949
|
+
dispatch(name: string, input: unknown, context: ActionContext): Promise<ActionResult<unknown>>;
|
|
835
950
|
}
|
|
836
951
|
/**
|
|
837
952
|
* Why a port and not `OverlayHostPort`: an overlay's `data` is `Json`, and a live preparation
|
|
@@ -983,7 +1098,7 @@ type TransferOperation = {
|
|
|
983
1098
|
} | {
|
|
984
1099
|
kind: "transform";
|
|
985
1100
|
transform: string;
|
|
986
|
-
options?: Json$
|
|
1101
|
+
options?: Json$2;
|
|
987
1102
|
} | {
|
|
988
1103
|
kind: "prepare-for-ai";
|
|
989
1104
|
instruction?: string;
|
|
@@ -1028,7 +1143,7 @@ interface ServerOperation {
|
|
|
1028
1143
|
statement: string;
|
|
1029
1144
|
supports(payload: Payload): boolean;
|
|
1030
1145
|
/** Projected draft only; sensitivity already applied. */
|
|
1031
|
-
toInput(draft: Draft): Json$
|
|
1146
|
+
toInput(draft: Draft): Json$2;
|
|
1032
1147
|
}
|
|
1033
1148
|
/** Delivery results: `copy` and `download` only ever deliver, degrade, cancel or fail (CONTRACT R16). */
|
|
1034
1149
|
type DeliveryOutcome = Extract<TransferOutcome, {
|
|
@@ -1110,7 +1225,7 @@ interface PreparationSession {
|
|
|
1110
1225
|
readonly snapshot: Snapshot;
|
|
1111
1226
|
readonly draft: Draft;
|
|
1112
1227
|
/** Deterministic transform, AI preparation or any registered transform — bumps draft.revision. */
|
|
1113
|
-
transform(id: string, options: Json$
|
|
1228
|
+
transform(id: string, options: Json$2, signal: AbortSignal): Promise<Draft>;
|
|
1114
1229
|
/** A manual edit. */
|
|
1115
1230
|
edit(payload: Payload): Draft;
|
|
1116
1231
|
/** Keep only these sections (ids from the snapshot). */
|
|
@@ -1228,19 +1343,19 @@ declare function patternBelow(pattern: string, pointer: string): boolean;
|
|
|
1228
1343
|
/** The path a person reads and copies: `/messages/*\/metadata` → `data.messages[*].metadata`. */
|
|
1229
1344
|
declare function displayPath(pointer: string, root?: string): string;
|
|
1230
1345
|
/** Exactly `JSON.stringify(value).length`, computed once per object (large sources stay cheap). */
|
|
1231
|
-
declare function jsonSize(value: Json$
|
|
1346
|
+
declare function jsonSize(value: Json$2): number;
|
|
1232
1347
|
/** The size a person expects for a node: a string's own length, else its JSON. */
|
|
1233
|
-
declare function nodeChars(value: Json$
|
|
1348
|
+
declare function nodeChars(value: Json$2): number;
|
|
1234
1349
|
/**
|
|
1235
1350
|
* The one-line stub that stands in for a node: its header (a string's first line, an object's
|
|
1236
1351
|
* short scalar members) and its original size.
|
|
1237
1352
|
*/
|
|
1238
|
-
declare function stubText(value: Json$
|
|
1353
|
+
declare function stubText(value: Json$2): string;
|
|
1239
1354
|
/** Every concrete pointer in `value` a pattern names (for counts, diffs and highlights). */
|
|
1240
|
-
declare function concretePointers(value: Json$
|
|
1355
|
+
declare function concretePointers(value: Json$2, pattern: string): string[];
|
|
1241
1356
|
/** Apply exclusions and per-node limits to a JSON value; returns the new value and what changed. */
|
|
1242
|
-
declare function applyStructureToJson(value: Json$
|
|
1243
|
-
value: Json$
|
|
1357
|
+
declare function applyStructureToJson(value: Json$2, recipe: StructureRecipe, labels?: Readonly<Record<string, string>>): {
|
|
1358
|
+
value: Json$2;
|
|
1244
1359
|
omissions: Omission[];
|
|
1245
1360
|
};
|
|
1246
1361
|
/** A JSON (or registered) draft with the person's structure choices applied. */
|
|
@@ -1250,7 +1365,7 @@ declare function applyJsonStructure(draft: Draft, recipe: StructureRecipe, label
|
|
|
1250
1365
|
* earlier sibling is excluded). Null when the node is excluded or cut; a stubbed ancestor answers
|
|
1251
1366
|
* with the stub's own pointer.
|
|
1252
1367
|
*/
|
|
1253
|
-
declare function outputPointer(value: Json$
|
|
1368
|
+
declare function outputPointer(value: Json$2, recipe: StructureRecipe, pointer: string): string | null;
|
|
1254
1369
|
declare function isProseSection(section: Section): boolean;
|
|
1255
1370
|
interface SectionLayout {
|
|
1256
1371
|
text: string;
|
|
@@ -1321,4 +1436,4 @@ declare function setPersonDefaultRecipe(ports: Pick<AlchemyHostPorts, "persisten
|
|
|
1321
1436
|
[key: string]: Json;
|
|
1322
1437
|
} | null): Promise<void>;
|
|
1323
1438
|
|
|
1324
|
-
export { type AgentPayloadEnvironment, type AgentPayloadInput, type AiPreparation, type Artifact, type BoundAllMatching, type BuiltInFormatId, type CapturedAllMatching, type CapturedSource, type Column, ContentTransferError, type Coverage, type Delivery, type DeliveryOutcome, type Draft, EMPTY_STRUCTURE, type ExportPage, type ExportProjection, FORMAT_ADAPTERS, type FormatAdapter, type FormatEngine, type FormatOptions, type Json$
|
|
1439
|
+
export { type AgentPayloadEnvironment, type AgentPayloadInput, type AiPreparation, type Artifact, type BoundAllMatching, type BuiltInFormatId, type CapturedAllMatching, type CapturedSource, type Column, ContentTransferError, type Coverage, type Delivery, type DeliveryOutcome, type Draft, EMPTY_STRUCTURE, type ExportPage, type ExportProjection, FORMAT_ADAPTERS, type FormatAdapter, type FormatEngine, type FormatOptions, type Json$2 as Json, type NodeLimit, type NormalizeTransferJsonOptions, type Notice, type Omission, type OutputSpan, type PageAction, type Payload, type PreparationOptions, type PreparationSession, type QuerySnapshot, type RawSnapshot, type Receipt, type RecipeOrigin, type ResolvedRecipe, type SealedArtifact, type Section, type SectionLayout, type ServerOperation, type Snapshot, type Source, type SpanMap, type StructureRecipe, type SurfaceHandle, TRANSFER_DEFAULT_RECIPE_SETTING, type TransferLimits, type TransferOperation, type TransferOutcome, type TransferPreferenceOverrides, type TransferPreferences, type TransferScope, type TransferSurfaceDeclaration, type TransferTarget, type Transform, type Transport, type WriteTargetRef, agentPayloadWithSpans, applyJsonStructure, applySectionSelection, applySectionStructure, applyStructureToJson, applyTransferLimits, assembleAgentPayload, buildAgentPayload, capture, collectAllMatching, concretePointers, createBrowserTransport, createDelivery, createDraft, createSurfaceTransferHandle, deriveDraft, directSource, displayPath, editDraft, eligibleFormats, exportedColumns, extensionForLanguage, fenceJsonBlock, formatAdapter, isProseSection, isSealed, joinPointer, jsonSize, jsonTextSpans, nodeChars, normalizeTransferJson, offsetSpans, openPreparation, outputPointer, patternBelow, patternCovers, patternMatches, pointerSegments, projectSnapshot, readTransferCell, recipeKey, reduceJson, refreshDraft, resetDraft, resolveDefaultRecipe, resolveTransferPreferences, resolveTransferRegistry, sealArtifact, sealDraft, sealTransferArtifact, sectionLayout, serialize, setPersonDefaultRecipe, sourceChanged, spanMap, stubText, transformRows, undoDraft };
|