@tangle-network/agent-runtime 4.0.0 → 5.0.0
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 +5263 -0
- package/dist/{activation-B49A14V5.d.ts → activation-CtLdCiH3.d.ts} +2 -2
- package/dist/{activation-BiQYCayd.js → activation-DGLWxFJu.js} +2 -2
- package/dist/{activation-BiQYCayd.js.map → activation-DGLWxFJu.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +4 -4
- package/dist/candidate-execution/index.d.ts +1 -1
- package/dist/{coordination-manager-C-ZoeZ73.js → coordination-manager-D74AZg7m.js} +7 -7
- package/dist/{coordination-manager-C-ZoeZ73.js.map → coordination-manager-D74AZg7m.js.map} +1 -1
- package/dist/{coordination-map-routing-SnsZp287.js → coordination-map-routing-DVjW5Gx0.js} +2 -2
- package/dist/{coordination-map-routing-SnsZp287.js.map → coordination-map-routing-DVjW5Gx0.js.map} +1 -1
- package/dist/{delegate-d9HcOFC5.js → delegate-BVyFJ9AX.js} +2 -2
- package/dist/{delegate-d9HcOFC5.js.map → delegate-BVyFJ9AX.js.map} +1 -1
- package/dist/durable.d.ts +4 -2
- package/dist/durable.js +12 -184
- package/dist/durable.js.map +1 -1
- package/dist/{graph-C_Z0Ua10.js → graph-r8zcRxbi.js} +6 -8
- package/dist/{graph-C_Z0Ua10.js.map → graph-r8zcRxbi.js.map} +1 -1
- package/dist/{graph-registry-CI1o16DH.js → graph-registry-B25FxBZN.js} +5 -5
- package/dist/graph-registry-B25FxBZN.js.map +1 -0
- package/dist/{graph-registry-BU7pcrUW.js → graph-registry-C-hjRx2t.js} +1 -1
- package/dist/{improve-B4v4S8jY.js → improve-D12GulmK.js} +7 -7
- package/dist/{improve-B4v4S8jY.js.map → improve-D12GulmK.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +5 -5
- package/dist/{jsonl-file-CvPuwM0a.js → jsonl-file-CeVYTIQJ.js} +41 -32
- package/dist/jsonl-file-CeVYTIQJ.js.map +1 -0
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +14 -13
- package/dist/{loop-runner-DKvA0JJr.d.ts → loop-runner-BHBabRIw.d.ts} +2 -2
- package/dist/{loop-runner-DMZkwlND.js → loop-runner-CYcN11I4.js} +2 -2
- package/dist/{loop-runner-DMZkwlND.js.map → loop-runner-CYcN11I4.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +5 -5
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-Cjs4SQ9Q.js → provision-supervisor-BiqHJ-d4.js} +5 -5
- package/dist/{provision-supervisor-Cjs4SQ9Q.js.map → provision-supervisor-BiqHJ-d4.js.map} +1 -1
- package/dist/{run-cancellation-CGgk54Md.js → run-cancellation-D5R-7UQt.js} +3 -3
- package/dist/{run-cancellation-CGgk54Md.js.map → run-cancellation-D5R-7UQt.js.map} +1 -1
- package/dist/run-state-DRh8BOFi.js +350 -0
- package/dist/run-state-DRh8BOFi.js.map +1 -0
- package/dist/{runtime-BmxmsaNz.js → runtime-BX_9-DJB.js} +18 -17
- package/dist/runtime-BX_9-DJB.js.map +1 -0
- package/dist/{scope-CJ7xtrs8.js → scope-JcCkUy_z.js} +151 -106
- package/dist/scope-JcCkUy_z.js.map +1 -0
- package/dist/{search-executor-DSB6XAl1.js → search-executor-CdmaS5r4.js} +3 -3
- package/dist/{search-executor-DSB6XAl1.js.map → search-executor-CdmaS5r4.js.map} +1 -1
- package/dist/{server-FWT2Nt_w.js → server-BY6OluUf.js} +3 -3
- package/dist/{server-FWT2Nt_w.js.map → server-BY6OluUf.js.map} +1 -1
- package/dist/settle-record-BSDDf9Z4.js +130 -0
- package/dist/settle-record-BSDDf9Z4.js.map +1 -0
- package/dist/{structural-rollout-Bl23HSOd.js → structural-rollout-BjMUUXLn.js} +3 -3
- package/dist/{structural-rollout-Bl23HSOd.js.map → structural-rollout-BjMUUXLn.js.map} +1 -1
- package/dist/{supervise-MAzd0hOk.js → supervise-rYEsVVcn.js} +172 -384
- package/dist/supervise-rYEsVVcn.js.map +1 -0
- package/dist/{supervision-discovery-6EtvKCsU.js → supervision-discovery-D95Ack4J.js} +4 -129
- package/dist/supervision-discovery-D95Ack4J.js.map +1 -0
- package/dist/{supervisor-CwANBb9-.js → supervisor-B-bX69uL.js} +178 -120
- package/dist/supervisor-B-bX69uL.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/dist/{top-web-CZP3RRhD.js → top-web-D-wH9ipn.js} +13 -9
- package/dist/{top-web-CZP3RRhD.js.map → top-web-D-wH9ipn.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-ooyUaxq_.d.ts → types-DblV14Oe.d.ts} +187 -222
- package/package.json +7 -8
- package/dist/graph-registry-CI1o16DH.js.map +0 -1
- package/dist/jsonl-file-CvPuwM0a.js.map +0 -1
- package/dist/runtime-BmxmsaNz.js.map +0 -1
- package/dist/scope-CJ7xtrs8.js.map +0 -1
- package/dist/supervise-MAzd0hOk.js.map +0 -1
- package/dist/supervision-discovery-6EtvKCsU.js.map +0 -1
- package/dist/supervisor-CwANBb9-.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-runtime",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Shared task-lifecycle skeleton for agents: a recursive loop kernel for chat turns, one-shot tasks, and multi-attempt loops, with trace capture and eval-gated self-improvement. Domain behavior lives in adapters; scoring and ship-gates in @tangle-network/agent-eval.",
|
|
5
5
|
"homepage": "https://github.com/tangle-network/agent-runtime#readme",
|
|
6
6
|
"repository": {
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
},
|
|
109
109
|
"files": [
|
|
110
110
|
"dist",
|
|
111
|
-
"
|
|
111
|
+
"CHANGELOG.md",
|
|
112
112
|
"skills"
|
|
113
113
|
],
|
|
114
114
|
"publishConfig": {
|
|
@@ -120,12 +120,12 @@
|
|
|
120
120
|
"@biomejs/biome": "^2.6.3",
|
|
121
121
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
122
122
|
"@tangle-network/agent-eval": "1.0.0",
|
|
123
|
-
"@tangle-network/agent-interface": "5.10.
|
|
123
|
+
"@tangle-network/agent-interface": "5.10.19",
|
|
124
124
|
"@tangle-network/agent-provider-cli-bridge": "2.0.2",
|
|
125
125
|
"@tangle-network/agent-provider-daytona": "0.6.1",
|
|
126
126
|
"@tangle-network/agent-provider-e2b": "0.6.1",
|
|
127
|
-
"@tangle-network/agent-provider-tangle": "5.0.
|
|
128
|
-
"@tangle-network/sandbox": "1.0.
|
|
127
|
+
"@tangle-network/agent-provider-tangle": "5.0.12",
|
|
128
|
+
"@tangle-network/sandbox": "1.0.216",
|
|
129
129
|
"@tangle-network/sandbox-ui": "4.0.0",
|
|
130
130
|
"@types/node": "26.6.5",
|
|
131
131
|
"@types/tar-stream": "3.1.5",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"license": "MIT",
|
|
148
148
|
"peerDependencies": {
|
|
149
149
|
"@tangle-network/agent-eval": "^1.0.0",
|
|
150
|
-
"@tangle-network/agent-interface": "^5.10.
|
|
150
|
+
"@tangle-network/agent-interface": "^5.10.19",
|
|
151
151
|
"@tangle-network/sandbox": "^1.0.111"
|
|
152
152
|
},
|
|
153
153
|
"dependencies": {
|
|
@@ -176,11 +176,10 @@
|
|
|
176
176
|
"conformance:capacity": "vitest run scripts/full-capacity-acceptance.test.mjs scripts/full-capacity-collector.test.mjs",
|
|
177
177
|
"check:model-execution-boundary": "node scripts/check-model-execution-boundary.mjs",
|
|
178
178
|
"check:publish-workflow": "node scripts/check-publish-workflow.mjs",
|
|
179
|
-
"check:upstream-evidence-workflow": "node scripts/check-upstream-evidence-workflow.mjs",
|
|
180
179
|
"check:version-bump": "node scripts/check-version-bump.mjs",
|
|
181
180
|
"check:release-notes": "node scripts/release-notes.mjs",
|
|
182
181
|
"check:api-surface": "node scripts/check-api-surface.mjs",
|
|
183
|
-
"release:check": "pnpm run lint && pnpm run build && pnpm run test && pnpm run typecheck && pnpm run verify:package:static && node scripts/check-api-surface.mjs --record && rm -rf .release-admission && pnpm pack --pack-destination .release-admission >/dev/null && node scripts/check-version-bump.mjs --archive .release-admission/*.tgz --consumer 'its CHANGELOG'",
|
|
182
|
+
"release:check": "pnpm run check:publish-workflow && node --test scripts/release-publication.integration.mjs && pnpm run lint && pnpm run build && pnpm run test && pnpm run typecheck && pnpm run verify:package:static && node scripts/check-api-surface.mjs --record && rm -rf .release-admission && pnpm pack --pack-destination .release-admission >/dev/null && node scripts/check-release-archive.mjs .release-admission && node scripts/check-version-bump.mjs --archive .release-admission/*.tgz --consumer 'its CHANGELOG' && pnpm run verify:official-optimizers && pnpm run verify:bench",
|
|
184
183
|
"api:surface": "node scripts/check-api-surface.mjs --write",
|
|
185
184
|
"release:prepare": "node scripts/prepare-release.mjs",
|
|
186
185
|
"release:cohort": "node scripts/verify-release-cohort.mjs",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph-registry-CI1o16DH.js","names":[],"sources":["../src/runtime/supervise/graph-file-schema.ts","../src/runtime/supervise/graph-parameters.ts","../src/runtime/supervise/graph-registry.ts"],"sourcesContent":["import { z } from 'zod'\nimport { resolveJsonPointer } from '../../mcp/tools/coordination-map-routing'\nimport type { RouteWhen } from '../../mcp/tools/coordination-route-contracts'\n\nconst scalar = z.union([z.string(), z.number().finite(), z.boolean(), z.null()])\nconst pointer = z.string().regex(/^(?:\\/(?:[^~]|~[01])*)*$/)\nconst matchBase = { node: z.string().min(1).optional(), pointer }\nconst equals = z.strictObject({ ...matchBase, equals: scalar })\nconst oneOf = z.strictObject({ ...matchBase, in: z.array(scalar) })\nconst exists = z.strictObject({ ...matchBase, exists: z.boolean() })\nconst match = z.union([equals, oneOf, exists])\n\n/** The same data grammar as routes; no executable expressions or additional operators. */\nexport const graphRouteWhenSchema = z.union([match, z.strictObject({ all: z.array(match).min(1) })])\n\nconst parameter = z.strictObject({\n default: z.unknown().optional(),\n type: z.enum(['string', 'number', 'integer', 'boolean', 'object', 'array', 'null']).optional(),\n})\nconst command = z.strictObject({\n command: z.string().min(1),\n timeoutMs: z.number().int().positive().optional(),\n})\nconst nonnegativeInteger = z.number().int().nonnegative()\n\n/** Authoring envelope. Canonical profiles and topology are validated by their existing owners. */\nexport const graphFileSchema = z.strictObject({\n digest: z.string().min(1).optional(),\n graph: z.string().min(1).optional(),\n describe: z.string().optional(),\n params: z.record(z.string().min(1), parameter).optional(),\n nodes: z\n .array(\n z.strictObject({\n id: z.string().min(1),\n profile: z.record(z.string(), z.unknown()).optional(),\n seat: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).optional(),\n needs: z.array(z.string().min(1)).optional(),\n }),\n )\n .min(1),\n entry: z\n .array(\n z.union([z.string().min(1), z.strictObject({ node: z.string().min(1), task: z.unknown() })]),\n )\n .min(1)\n .optional(),\n edges: z.array(z.record(z.string(), z.unknown())),\n gates: z.array(z.unknown()).optional(),\n budget: z.strictObject({\n maxIterations: nonnegativeInteger,\n maxTokens: nonnegativeInteger,\n maxUsd: z.number().finite().nonnegative().optional(),\n deadlineMs: nonnegativeInteger.optional(),\n resources: z\n .record(z.string(), z.strictObject({ unit: z.string().min(1), limit: nonnegativeInteger }))\n .optional(),\n }),\n check: z\n .union([\n equals.extend({ describe: z.string().optional() }),\n oneOf.extend({ describe: z.string().optional() }),\n exists.extend({ describe: z.string().optional() }),\n z.strictObject({ describe: z.string().optional(), all: z.array(match).min(1) }),\n z.strictObject({ describe: z.string().optional(), command }),\n ])\n .optional(),\n deliverable: z\n .strictObject({\n describe: z.string().optional(),\n checkRef: z.string().min(1),\n command: command.optional(),\n when: graphRouteWhenSchema.optional(),\n })\n .optional(),\n on: z.unknown().optional(),\n})\n\n/** Judge the flow's terminal-output map with RouteWhen's own JSON-pointer semantics. */\nexport function checkGraphRoute(when: RouteWhen, output: unknown): boolean {\n return ('all' in when ? when.all : [when]).every((condition) => {\n let document = output\n if (condition.node !== undefined) {\n if (!output || typeof output !== 'object' || !Object.hasOwn(output, condition.node))\n return false\n document = (output as Record<string, unknown>)[condition.node]\n }\n const selected = resolveJsonPointer(document, condition.pointer)\n if ('exists' in condition) return selected.found === condition.exists\n if (!selected.found) return false\n return 'equals' in condition\n ? selected.value === condition.equals\n : condition.in.some((value) => value === selected.value)\n })\n}\n","import { z } from 'zod'\nimport { ValidationError } from '../../errors'\n\nexport interface GraphParameterBindings {\n readonly params?: Readonly<Record<string, unknown>>\n readonly trigger?: Readonly<Record<string, unknown>>\n}\n\nconst triggerPart = z.strictObject({ trigger: z.array(z.string()).min(1) })\nconst literalPart = z.strictObject({ literal: z.string() })\n/** Explicit authored trigger slots in compiled graph data. An empty list marks fully bound data. */\nexport const graphTriggerBindingsSchema = z.array(\n z\n .strictObject({\n path: z.array(z.union([z.string(), z.number().int().nonnegative()])).min(1),\n mode: z.enum(['value', 'text']),\n parts: z.array(z.union([literalPart, triggerPart])).min(1),\n })\n .superRefine((slot, context) => {\n if (\n !slot.parts.some((part) => 'trigger' in part) ||\n (slot.mode === 'value' && (slot.parts.length !== 1 || !('trigger' in slot.parts[0]!)))\n )\n context.addIssue({\n code: 'custom',\n message: 'binding requires authored trigger parts; value slots require one trigger',\n })\n }),\n)\n/** @useDeclaredType */\nexport type GraphTriggerBinding = z.infer<typeof graphTriggerBindingsSchema>[number]\n\ntype Part = GraphTriggerBinding['parts'][number]\n\nfunction readBinding(\n namespace: keyof GraphParameterBindings,\n keys: readonly string[],\n bindings: GraphParameterBindings,\n): unknown {\n let found: unknown = bindings[namespace]\n for (const key of keys) {\n if (!found || typeof found !== 'object' || !Object.hasOwn(found, key))\n throw new ValidationError(`graph parameters: missing ${[namespace, ...keys].join('.')}`)\n found = (found as Record<string, unknown>)[key]\n }\n if (found === undefined)\n throw new ValidationError(`graph parameters: missing ${[namespace, ...keys].join('.')}`)\n return structuredClone(found)\n}\n\nfunction textValue(value: unknown, expression: string): string {\n if (value !== null && typeof value === 'object')\n throw new ValidationError(`graph parameters: ${expression} needs a whole JSON slot`)\n return String(value)\n}\n\nfunction pendingText(parts: readonly Part[]): string {\n return parts\n .map((part) => ('literal' in part ? part.literal : `\\${trigger.${part.trigger.join('.')}}`))\n .join('')\n}\n\n/** Compile authored slots once. Inserted values are data, never recursively parsed templates. */\nexport function compileGraphParameters(\n value: unknown,\n bindings: GraphParameterBindings,\n options: { readonly defer?: readonly (keyof GraphParameterBindings)[] } = {},\n): { value: unknown; triggerBindings: GraphTriggerBinding[] } {\n const visiting = new Set<object>()\n const triggerBindings: GraphTriggerBinding[] = []\n const bind = (item: unknown, path: Array<string | number>): unknown => {\n if (typeof item === 'string') {\n if (item.replace(/\\$\\{[^{}]+\\}/g, '').includes('${'))\n throw new ValidationError('graph parameters: malformed reference')\n const whole = /^\\$\\{([^{}]+)\\}$/.exec(item)\n const parts: Part[] = []\n let cursor = 0\n let wholeValue: unknown\n let boundWhole = false\n for (const match of item.matchAll(/\\$\\{([^{}]+)\\}/g)) {\n if (match.index > cursor) parts.push({ literal: item.slice(cursor, match.index) })\n const [namespace, ...keys] = match[1]!.split('.')\n if ((namespace !== 'params' && namespace !== 'trigger') || keys.length === 0)\n throw new ValidationError(`graph parameters: unsupported reference \\${${match[1]}}`)\n if (options.defer?.includes(namespace)) {\n if (namespace === 'trigger') parts.push({ trigger: keys })\n else parts.push({ literal: match[0] })\n } else {\n const found = readBinding(namespace, keys, bindings)\n if (whole) {\n wholeValue = found\n boundWhole = true\n } else parts.push({ literal: textValue(found, match[1]!) })\n }\n cursor = match.index + match[0].length\n }\n if (boundWhole) return wholeValue\n if (cursor === 0) return item\n if (cursor < item.length) parts.push({ literal: item.slice(cursor) })\n if (parts.some((part) => 'trigger' in part))\n triggerBindings.push({ path, mode: whole ? 'value' : 'text', parts })\n return pendingText(parts)\n }\n if (!item || typeof item !== 'object') return item\n if (visiting.has(item)) throw new ValidationError('graph parameters: cyclic data is not JSON')\n visiting.add(item)\n const bound = Array.isArray(item)\n ? item.map((child, index) => bind(child, [...path, index]))\n : Object.fromEntries(\n Object.entries(item).map(([key, child]) => [key, bind(child, [...path, key])]),\n )\n visiting.delete(item)\n return bound\n }\n return { value: bind(value, []), triggerBindings }\n}\n\n/** Legacy authored-data binding. Compiled graphs use bindCompiledGraphTriggers instead. */\nexport function bindGraphParameters(\n value: unknown,\n bindings: GraphParameterBindings,\n options: { readonly defer?: readonly (keyof GraphParameterBindings)[] } = {},\n): unknown {\n return compileGraphParameters(value, bindings, options).value\n}\n\n/** Check provenance against the exact provisional values without reading trigger data. */\nexport function assertGraphTriggerBindings(\n value: unknown,\n slots: readonly GraphTriggerBinding[],\n): void {\n const seen = new Set<string>()\n for (const slot of graphTriggerBindingsSchema.parse(slots)) {\n const key = JSON.stringify(slot.path.map(String))\n if (seen.has(key)) throw new ValidationError('graph parameters: duplicate trigger binding path')\n seen.add(key)\n let found: unknown = value\n for (const key of slot.path) {\n if (!found || typeof found !== 'object' || !Object.hasOwn(found, key))\n throw new ValidationError('graph parameters: trigger binding path does not exist')\n found = (found as Record<string | number, unknown>)[key]\n }\n if (found !== pendingText(slot.parts))\n throw new ValidationError(\n 'graph parameters: trigger binding does not match its provisional value',\n )\n }\n}\n\n/** Only explicitly recorded authored slots bind. Literal parameter/trigger values are untouched. */\nexport function bindCompiledGraphTriggers<T>(\n value: T,\n slots: readonly GraphTriggerBinding[],\n trigger: GraphParameterBindings['trigger'],\n): T {\n assertGraphTriggerBindings(value, slots)\n const bound = structuredClone(value)\n for (const slot of slots) {\n let parent = bound as Record<string | number, unknown>\n for (const key of slot.path.slice(0, -1)) parent = parent[key] as typeof parent\n parent[slot.path.at(-1)!] =\n slot.mode === 'value'\n ? readBinding('trigger', (slot.parts[0]! as { trigger: string[] }).trigger, { trigger })\n : slot.parts\n .map((part) =>\n 'literal' in part\n ? part.literal\n : textValue(\n readBinding('trigger', part.trigger, { trigger }),\n `trigger.${part.trigger.join('.')}`,\n ),\n )\n .join('')\n }\n return bound\n}\n","/**\n * `graph-registry` — the designer's memory: graphs and their outcomes as files.\n *\n * The AgentGraph algebra makes a graph PLAIN DATA (nodes with pinned profiles,\n * edges with registry-versioned directives, a budget, a deliverable\n * description), which is the property that lets a graph be stored, replayed\n * byte-identical, and mutated like code. This module is the thin durable layer\n * on top: one JSONL record per run, the exact graph content-addressed beside\n * it. The natural home is a SANDBOX WORKSPACE — the platform's snapshot story\n * (Firecracker restore, warm leases, `continuity: 'resume'`) then makes the\n * registry the agent's compounding execution memory across runs: a rerun over\n * the same sandbox finds every graph the designer ever ran, what each cost,\n * and whether it delivered.\n *\n * ORACLES STAY ENVIRONMENT-OWNED. `DeliverableSpec.check` is a function and is\n * deliberately NOT stored: a stored graph keeps the deliverable's `describe`\n * and an optional `checkRef`, and replay re-binds the check from the caller's\n * environment. This is the graph contract's own doctrine — graders are\n * environment, never workers — applied to persistence.\n *\n * Scoring is a documented heuristic, not a learned model: delivered beats\n * failed, then cheaper (tokens, then iterations), then most recent. A designer\n * that needs better selection replaces `pickBest`, not the records.\n */\n\nimport { mkdir, readdir, readFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport { sha256 } from '../../content-digest'\nimport {\n isNoEntError,\n readCommittedJsonFile,\n upsertCommittedJsonLine,\n withJsonlFileLock,\n} from '../../durable/jsonl-file'\nimport { ValidationError } from '../../errors'\nimport { writeAtomicDurableFile } from './durable-file'\nimport type { AgentGraph, GraphEdge } from './graph'\nimport { checkGraphRoute } from './graph-file-schema'\nimport {\n bindCompiledGraphTriggers,\n bindGraphParameters,\n type GraphTriggerBinding,\n} from './graph-parameters'\n\nexport type { GraphTriggerBinding } from './graph-parameters'\n\nimport type { GraphFromStoredOptions } from './stored-graph-check'\n\nexport type { GraphCommandCheck, GraphFromStoredOptions } from './stored-graph-check'\n\n/** @inline */\ninterface StoredGraphContent {\n readonly digest: string\n /** Authored trigger-slot provenance; present (even empty) on compiled loader output. */\n readonly triggerBindings?: readonly GraphTriggerBinding[]\n readonly nodes: ReadonlyArray<{ readonly id: string; readonly profile: AgentProfile }>\n readonly deliverable: Pick<\n AgentGraph['deliverable'],\n 'describe' | 'checkRef' | 'command' | 'when'\n >\n /** A flow graph's entry and gates; absent for any other graph. */\n readonly entry?: AgentGraph['entry']\n readonly gates?: AgentGraph['gates']\n}\n\n/** A graph as stored. Observed imports retain unknown directives and budgets;\n * they describe what happened and cannot be replayed as executable graphs. */\nexport type StoredGraph = StoredGraphContent &\n (\n | {\n readonly observed?: false\n readonly edges: ReadonlyArray<GraphEdge>\n readonly budget: AgentGraph['budget']\n }\n | {\n readonly observed: true\n readonly edges: ReadonlyArray<\n | GraphEdge\n | {\n readonly from: string\n readonly to: string\n }\n >\n readonly budget?: AgentGraph['budget']\n }\n )\n\n/** Editable graph data; registration computes its digest when it is omitted. */\nexport type StoredGraphInput = Omit<\n Extract<StoredGraph, { readonly observed?: false }>,\n 'digest'\n> & {\n readonly digest?: string\n}\n\n/** One run or an explicitly incomplete observation of a graph, for one task shape. */\nexport interface GraphRunRecord {\n /** Content-address of the exact graph that ran. */\n readonly graphDigest: string\n /** Digest of the normalized task shape the designer computed for lookup. */\n readonly taskDigest: string\n readonly startedAt: string\n /** Absent while running or when completion was not established. */\n readonly finishedAt?: string\n readonly outcome:\n | { readonly kind: 'delivered'; readonly summary?: string }\n | { readonly kind: 'no-winner'; readonly reason?: string }\n | { readonly kind: 'unknown' | 'running'; readonly reason: string }\n /** Measured accounting; running observations are to date. Unknown channels omitted. */\n readonly cost: {\n readonly iterations?: number\n readonly tokens?: number\n readonly usd?: number\n readonly ms?: number\n readonly inputTokens?: number\n readonly outputTokens?: number\n readonly humanMessages?: number\n readonly leadMessages?: number\n /** Elapsed wall time from the task start to an independently verified merge. */\n readonly mergeMs?: number\n }\n /** Metered ledger size, absent when a source exposes relationships without traversals. */\n readonly traversals?: number\n readonly exhaustedEdges?: ReadonlyArray<string>\n /** Explicit source metadata, never classified from transcript or PR prose. */\n readonly taskType?: 'feature' | 'bugfix' | 'consolidation' | 'investigation' | 'ops'\n /** Stable run identity; re-ingesting this source replaces its observation. */\n readonly source?: { readonly kind: string; readonly id: string; readonly url?: string }\n readonly observedAt?: string\n /** Link to the canonical trace run; execution trees remain trace-owned. */\n readonly traceRunId?: string\n /** Canonical ordered adjacency. This is not a graph-isomorphism claim. */\n readonly topologyDigest?: string\n readonly evidence?: ReadonlyArray<{\n readonly kind: string\n readonly url: string\n readonly at?: string\n }>\n readonly nodeUsage?: ReadonlyArray<{\n readonly nodeId: string\n readonly sourceId?: string\n readonly startedAt?: string\n /** Latest recorded activity, not a claim that the node finished. */\n readonly lastRecordAt?: string\n readonly finishedAt?: string\n readonly inputTokens?: number\n readonly outputTokens?: number\n readonly humanMessages?: number\n readonly leadMessages?: number\n }>\n /** Missing or partial evidence, including incomplete accounting channels. */\n readonly unknowns?: ReadonlyArray<string>\n}\n\nexport interface GraphRegistryDir {\n readonly root: string\n}\n\nconst RECORDS_FILE = 'records.jsonl'\nconst GRAPHS_DIR = 'graphs'\n\n/** Canonical serialization for content-addressing: stable key order, sorted. */\nfunction canonicalJson(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`\n if (value && typeof value === 'object') {\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(',')}}`\n }\n return JSON.stringify(value)\n}\n\n/** Digest of the exact graph (nodes + edges + budget + deliverable describe, and a flow graph's\n * entry and gates). An absent key is not serialized, so a graph without `entry` keeps the digest\n * it had before flow graphs were stored. */\nexport function graphDigest(graph: Omit<StoredGraph, 'digest'>): string {\n return sha256(canonicalJson(graph))\n}\n\n/** Digest of the normalized task shape a designer looks records up by. */\nexport function taskShapeDigest(taskShape: Record<string, unknown>): string {\n return sha256(canonicalJson(taskShape))\n}\n\n/** Digest of a runnable graph exactly as the registry stores it — the value\n * `recordGraphRun` demands. Callers recording real runs hash through this,\n * never hand-rolled, so a record always matches its graph. */\nexport function digestOfGraph(graph: AgentGraph): string {\n return storeGraph(graph).digest\n}\n\nfunction storeGraph(graph: AgentGraph): StoredGraph {\n const { describe, checkRef, command, when } = graph.deliverable\n const content = {\n nodes: graph.nodes,\n edges: graph.edges,\n budget: graph.budget,\n ...(graph.triggerBindings === undefined ? {} : { triggerBindings: graph.triggerBindings }),\n deliverable: {\n ...(describe ? { describe } : {}),\n ...(checkRef ? { checkRef } : {}),\n ...(command ? { command } : {}),\n ...(when ? { when } : {}),\n },\n ...(graph.entry === undefined ? {} : { entry: graph.entry }),\n ...(graph.gates === undefined ? {} : { gates: graph.gates }),\n }\n return { digest: graphDigest(content), ...content }\n}\n\nfunction assertRecord(record: GraphRunRecord): void {\n if (typeof record.graphDigest !== 'string' || record.graphDigest.length === 0)\n throw new ValidationError('graph-registry: record.graphDigest is required')\n if (typeof record.taskDigest !== 'string' || record.taskDigest.length === 0)\n throw new ValidationError('graph-registry: record.taskDigest is required')\n if (!Number.isFinite(Date.parse(record.startedAt)))\n throw new ValidationError('graph-registry: record.startedAt must be a timestamp')\n if (!['delivered', 'no-winner', 'unknown', 'running'].includes(record.outcome.kind))\n throw new ValidationError('graph-registry: invalid record.outcome.kind')\n if (\n (record.outcome.kind === 'delivered' || record.outcome.kind === 'no-winner') &&\n (!record.finishedAt || !Number.isFinite(Date.parse(record.finishedAt)))\n )\n throw new ValidationError('graph-registry: terminal outcomes require record.finishedAt')\n if (\n (record.outcome.kind === 'unknown' || record.outcome.kind === 'running') &&\n !record.outcome.reason\n )\n throw new ValidationError('graph-registry: incomplete outcomes require a reason')\n if (record.source && (!record.source.kind || !record.source.id))\n throw new ValidationError('graph-registry: source.kind and source.id are required')\n if (\n record.finishedAt &&\n (!Number.isFinite(Date.parse(record.finishedAt)) ||\n Date.parse(record.finishedAt) < Date.parse(record.startedAt))\n )\n throw new ValidationError('graph-registry: finishedAt precedes startedAt or is invalid')\n for (const [channel, value] of Object.entries(record.cost)) {\n if (value !== undefined && (typeof value !== 'number' || !Number.isFinite(value) || value < 0))\n throw new ValidationError(`graph-registry: invalid cost.${channel}`)\n }\n}\n\nfunction recordKey(record: GraphRunRecord): string {\n assertRecord(record)\n if (record.source) return JSON.stringify(['source', record.source.kind, record.source.id])\n return JSON.stringify([record.taskDigest, record.graphDigest, record.startedAt])\n}\n\n/** Open (or lazily create) a registry rooted at a workspace directory. The\n * directory is the sandbox workspace; snapshots carry it across runs. */\nexport function graphRegistry(root: string): GraphRegistryDir {\n if (!root || root.trim().length === 0)\n throw new ValidationError('graphRegistry: root directory is required')\n return { root }\n}\n\n/** Append one run record; the exact graph is content-addressed beside it.\n * Idempotent per (taskDigest, graphDigest, startedAt): a replayed append with\n * the same key replaces the prior row rather than duplicating it. */\nexport async function recordGraphRun(\n reg: GraphRegistryDir,\n graph: AgentGraph,\n record: GraphRunRecord,\n): Promise<StoredGraph> {\n const stored = storeGraph(graph)\n return recordStoredGraphRun(reg, stored, record)\n}\n\n/** Store an executable graph or an observed external topology in the same registry.\n * Imported observations retain their source identity and never authorize replay.\n * A reader refreshing facts can preserve independently joined labels; an explicit\n * correction leaves preserveLabels unset and replaces the record. */\nexport async function recordStoredGraphRun(\n reg: GraphRegistryDir,\n definition: StoredGraph | StoredGraphInput,\n record?: GraphRunRecord,\n options: { readonly preserveLabels?: boolean } = {},\n): Promise<StoredGraph> {\n const { digest, ...content } = definition\n const stored = { ...content, digest: digest ?? graphDigest(content) } as StoredGraph\n if (stored.observed && !record)\n throw new ValidationError('graph-registry: observed graphs require a source run identity')\n if (record) {\n assertRecord(record)\n if (stored.observed && !record.source)\n throw new ValidationError('graph-registry: observed graphs require a source run identity')\n if (!stored.observed && !record.finishedAt)\n throw new ValidationError('graph-registry: native graph runs require a completion timestamp')\n if (\n (!stored.observed || record.traversals !== undefined) &&\n (!Number.isSafeInteger(record.traversals) || record.traversals! < 0)\n )\n throw new ValidationError(\n 'graph-registry: native graphs require metered traversals; observed counts must be non-negative integers',\n )\n if (stored.digest !== record.graphDigest) {\n throw new ValidationError(\n `graph-registry: record.graphDigest ${record.graphDigest} does not match the supplied graph (${stored.digest}) — record the graph that actually ran`,\n )\n }\n }\n if (graphDigest(content) !== stored.digest)\n throw new ValidationError('graph-registry: stored graph content does not match its digest')\n await mkdir(join(reg.root, GRAPHS_DIR), { recursive: true })\n const file = join(reg.root, RECORDS_FILE)\n return withJsonlFileLock(file, async (canonicalPath) => {\n if (!record) {\n await persistGraph(reg, stored)\n return stored\n }\n let persisted = record\n if (options.preserveLabels && record.source) {\n const prior = (await readCommittedJsonFile<GraphRunRecord>(canonicalPath)).find(\n (row) => row.source?.kind === record.source!.kind && row.source.id === record.source!.id,\n )\n if (prior) {\n const taskType = record.taskType ?? prior.taskType\n const priorTerminal =\n prior.outcome.kind === 'delivered' || prior.outcome.kind === 'no-winner'\n const incomingUnassessed =\n record.outcome.kind === 'unknown' || record.outcome.kind === 'running'\n if (priorTerminal && incomingUnassessed && prior.startedAt !== record.startedAt)\n throw new ValidationError(\n 'graph-registry: preserving labels requires the same task start and source identity',\n )\n const evidence = [...(prior.evidence ?? []), ...(record.evidence ?? [])]\n persisted = {\n ...record,\n ...(taskType ? { taskType } : {}),\n ...(record.unknowns\n ? {\n unknowns: record.unknowns.filter(\n (reason) => !(taskType && reason === 'task type not explicitly labeled'),\n ),\n }\n : {}),\n ...(evidence.length\n ? {\n evidence: [\n ...new Map(evidence.map((entry) => [canonicalJson(entry), entry])).values(),\n ],\n }\n : {}),\n ...(priorTerminal && incomingUnassessed\n ? {\n outcome: prior.outcome,\n finishedAt: prior.finishedAt,\n cost: {\n ...record.cost,\n ...(prior.cost.ms === undefined ? {} : { ms: prior.cost.ms }),\n ...(prior.cost.mergeMs === undefined ? {} : { mergeMs: prior.cost.mergeMs }),\n },\n }\n : {}),\n }\n }\n }\n assertRecord(persisted)\n await persistGraph(reg, stored)\n await upsertCommittedJsonLine(canonicalPath, persisted, recordKey)\n return stored\n })\n}\n\nasync function persistGraph(reg: GraphRegistryDir, stored: StoredGraph): Promise<void> {\n const revisionPath = join(reg.root, GRAPHS_DIR, `${stored.digest}.json`)\n try {\n const { digest: existingDigest, ...existing } = JSON.parse(\n await readFile(revisionPath, 'utf8'),\n ) as StoredGraph\n if (existingDigest !== stored.digest || graphDigest(existing) !== stored.digest)\n throw new ValidationError(\n 'graph-registry: stored graph revision is immutable but its content differs',\n )\n } catch (error) {\n if (!isNoEntError(error)) throw error\n // Content-addressed revisions are immutable. Rewriting one on every run adds\n // an unnecessary durable publication to the record lock's critical section.\n writeAtomicDurableFile(revisionPath, JSON.stringify(stored), { preserveMode: true })\n }\n}\n\n/** All records, newest last. */\nexport async function listGraphRuns(reg: GraphRegistryDir): Promise<GraphRunRecord[]> {\n return readCommittedJsonFile<GraphRunRecord>(join(reg.root, RECORDS_FILE))\n}\n\n/** Filters over the existing graph run records. Missing source kind is native. */\nexport interface GraphRunQuery {\n readonly taskDigest?: string\n readonly taskType?: GraphRunRecord['taskType'] | 'unknown'\n readonly topologyDigest?: string\n readonly sourceKind?: string\n}\n\nfunction observedTopology(record: GraphRunRecord): string {\n return record.topologyDigest ?? (record.source ? 'unknown' : record.graphDigest)\n}\n\n/** Records for one task shape or deterministic label query, newest last. */\nexport async function graphRunsFor(\n reg: GraphRegistryDir,\n query: string | GraphRunQuery = {},\n): Promise<GraphRunRecord[]> {\n const filters = typeof query === 'string' ? { taskDigest: query } : query\n return (await listGraphRuns(reg)).filter(\n (row) =>\n (filters.taskDigest === undefined || row.taskDigest === filters.taskDigest) &&\n (filters.taskType === undefined || (row.taskType ?? 'unknown') === filters.taskType) &&\n (filters.topologyDigest === undefined || observedTopology(row) === filters.topologyDigest) &&\n (filters.sourceKind === undefined || (row.source?.kind ?? 'native') === filters.sourceKind),\n )\n}\n\n/** Descriptive task-type/topology measurements, with every population explicit.\n * Unknown and running runs never enter the assessed denominator or medians. */\nexport interface GraphCorpusGroup {\n readonly taskType: NonNullable<GraphRunRecord['taskType']> | 'unknown'\n readonly topologyDigest: string\n readonly delivered: number\n readonly assessed: number\n readonly unknown: number\n readonly deliveredRate: number | null\n readonly medianWallMs: number | null\n readonly wallMsCount: number\n readonly medianMergeMs: number | null\n readonly mergeMsCount: number\n readonly medianTokens: number | null\n readonly tokenCount: number\n readonly medianHumanMessages: number | null\n readonly humanMessageCount: number\n readonly runs: readonly GraphRunRecord[]\n}\n\n/** The registry's observational view. It neither authorizes replay nor proves a causal win. */\nexport interface GraphCorpusSummary {\n readonly recordCount: number\n readonly groups: readonly GraphCorpusGroup[]\n}\n\nfunction medianKnown(values: readonly (number | undefined)[]): {\n median: number | null\n count: number\n} {\n const known = values\n .filter((value): value is number => value !== undefined && Number.isFinite(value) && value >= 0)\n .sort((a, b) => a - b)\n const middle = Math.floor(known.length / 2)\n return {\n count: known.length,\n median:\n known.length === 0\n ? null\n : known.length % 2\n ? known[middle]!\n : (known[middle - 1]! + known[middle]!) / 2,\n }\n}\n\n// The single observational policy used by both query and pickBestGraph. Native\n// selection below remains unchanged; this policy is an explicit descriptive opt-in.\nfunction observedGraphSummary(records: readonly GraphRunRecord[]): GraphCorpusSummary {\n const groups = new Map<string, GraphRunRecord[]>()\n for (const record of records) {\n const key = JSON.stringify([record.taskType ?? 'unknown', observedTopology(record)])\n const rows = groups.get(key)\n if (rows) rows.push(record)\n else groups.set(key, [record])\n }\n const summaries: GraphCorpusGroup[] = [...groups.values()].map((runs) => {\n const assessed = runs.filter(\n (run) => run.outcome.kind === 'delivered' || run.outcome.kind === 'no-winner',\n )\n const delivered = assessed.filter((run) => run.outcome.kind === 'delivered')\n const wall = medianKnown(assessed.map((run) => run.cost.ms))\n const merge = medianKnown(\n delivered\n .filter((run) => run.evidence?.some((entry) => entry.kind === 'pr-merged'))\n .map((run) => run.cost.mergeMs),\n )\n const tokens = medianKnown(assessed.map((run) => run.cost.tokens))\n const human = medianKnown(assessed.map((run) => run.cost.humanMessages))\n return {\n taskType: runs[0]!.taskType ?? 'unknown',\n topologyDigest: observedTopology(runs[0]!),\n delivered: delivered.length,\n assessed: assessed.length,\n unknown: runs.length - assessed.length,\n deliveredRate: assessed.length ? delivered.length / assessed.length : null,\n medianWallMs: wall.median,\n wallMsCount: wall.count,\n medianMergeMs: merge.median,\n mergeMsCount: merge.count,\n medianTokens: tokens.median,\n tokenCount: tokens.count,\n medianHumanMessages: human.median,\n humanMessageCount: human.count,\n runs,\n }\n })\n summaries.sort((a, b) => {\n const delivered = (b.deliveredRate ?? -1) - (a.deliveredRate ?? -1)\n if (delivered) return delivered\n for (const key of ['medianWallMs', 'medianTokens', 'medianHumanMessages'] as const) {\n if (a[key] === b[key]) continue\n if (a[key] === null) return 1\n if (b[key] === null) return -1\n return a[key]! - b[key]!\n }\n return a.taskType.localeCompare(b.taskType) || a.topologyDigest.localeCompare(b.topologyDigest)\n })\n return { recordCount: records.length, groups: summaries }\n}\n\n/** Query and rank the same registry records using the opt-in observational\n * policy: delivery rate, wall time, tokens, then human messages; unknowns last. */\nexport async function graphCorpusSummary(\n reg: GraphRegistryDir,\n query: GraphRunQuery = {},\n): Promise<GraphCorpusSummary> {\n return observedGraphSummary(await graphRunsFor(reg, query))\n}\n\nexport type GraphSelection =\n | { readonly kind: 'replay'; readonly graph: StoredGraph; readonly record: GraphRunRecord }\n | { readonly kind: 'author'; readonly reason: string }\n\n/** The documented heuristic: delivered beats failed; among delivered, cheaper\n * (tokens, then iterations) wins; ties go to the most recent. */\nexport function pickBestGraph(\n records: ReadonlyArray<GraphRunRecord>,\n options: { readonly policy?: 'native' | 'observed' } = {},\n): GraphRunRecord | undefined {\n if (options.policy === 'observed') {\n const group = observedGraphSummary(records).groups[0]\n return group && pickBestGraph(group.runs)\n }\n const delivered = records.filter((row) => row.outcome.kind === 'delivered')\n if (delivered.length === 0) return undefined\n const better = (a: GraphRunRecord, b: GraphRunRecord): GraphRunRecord => {\n const aTokens = a.cost.tokens ?? Number.POSITIVE_INFINITY\n const bTokens = b.cost.tokens ?? Number.POSITIVE_INFINITY\n if (aTokens !== bTokens) return aTokens < bTokens ? a : b\n const aIter = a.cost.iterations ?? Number.POSITIVE_INFINITY\n const bIter = b.cost.iterations ?? Number.POSITIVE_INFINITY\n if (aIter !== bIter) return aIter < bIter ? a : b\n return a.finishedAt! >= b.finishedAt! ? a : b\n }\n return delivered.reduce((best, row) => (better(best, row) === best ? best : row))\n}\n\n/** Load a stored graph by digest. */\nexport async function loadGraph(\n reg: GraphRegistryDir,\n digest: string,\n): Promise<StoredGraph | undefined> {\n try {\n return JSON.parse(\n await readFile(join(reg.root, GRAPHS_DIR, `${digest}.json`), 'utf8'),\n ) as StoredGraph\n } catch {\n return undefined\n }\n}\n\n/** The designer's lookup: replay the known-good graph for this task shape, or\n * author a new one — with the reason stated either way (the decision is data). */\nexport async function lookupGraph(\n reg: GraphRegistryDir,\n taskDigest: string,\n): Promise<GraphSelection> {\n const records = await graphRunsFor(reg, taskDigest)\n const candidates: GraphRunRecord[] = []\n const loaded = new Map<string, StoredGraph | undefined>()\n for (const record of records) {\n if (!loaded.has(record.graphDigest))\n loaded.set(record.graphDigest, await loadGraph(reg, record.graphDigest))\n const graph = loaded.get(record.graphDigest)\n if (!graph?.observed) candidates.push(record)\n }\n if (records.length && !candidates.length)\n return {\n kind: 'author',\n reason: 'only observed topologies are available; author an executable graph',\n }\n const best = pickBestGraph(candidates)\n if (best) {\n const graph = await loadGraph(reg, best.graphDigest)\n if (graph) return { kind: 'replay', graph, record: best }\n return {\n kind: 'author',\n reason: `best record's graph ${best.graphDigest.slice(0, 12)} is missing from the registry`,\n }\n }\n return {\n kind: 'author',\n reason:\n records.length === 0\n ? 'first run for this task shape'\n : 'no graph delivered for this task shape yet',\n }\n}\n\n/** Rehydrate a stored graph, binding trigger data and an environment-owned named check. */\nexport function graphFromStored(\n stored: StoredGraph | StoredGraphInput,\n environment: AgentGraph['deliverable']['check'] | GraphFromStoredOptions = {},\n): AgentGraph {\n if (stored.observed)\n throw new ValidationError('graphFromStored: observed topology cannot be replayed')\n const {\n digest: _digest,\n observed: _observed,\n triggerBindings: _triggerBindings,\n deliverable,\n ...topology\n } = (\n stored.triggerBindings !== undefined\n ? bindCompiledGraphTriggers(\n stored,\n stored.triggerBindings,\n typeof environment === 'function' ? undefined : (environment.trigger ?? {}),\n )\n : typeof environment === 'function'\n ? stored\n : bindGraphParameters(stored, { trigger: environment.trigger ?? {} })\n ) as typeof stored\n const selected =\n typeof environment === 'function'\n ? environment\n : environment.checks && Object.hasOwn(environment.checks, deliverable.checkRef ?? '')\n ? environment.checks[deliverable.checkRef!]\n : deliverable.checkRef === 'command'\n ? deliverable.command\n : deliverable.checkRef === 'route' && deliverable.when\n ? (((out, context) =>\n context\n ? context.originalVerdict?.valid !== false\n : checkGraphRoute(\n deliverable.when!,\n out,\n )) satisfies AgentGraph['deliverable']['check'])\n : undefined\n if (!selected)\n throw new ValidationError(\n `graphFromStored: unknown checkRef ${deliverable.checkRef ?? '(missing)'}`,\n )\n const materialized = stored.triggerBindings === undefined ? {} : { triggerBindings: [] as const }\n if (typeof selected === 'function') {\n const { command: _command, ...description } = deliverable\n return { ...topology, ...materialized, deliverable: { ...description, check: selected } }\n }\n const command =\n selected === deliverable.command\n ? selected\n : (bindGraphParameters(selected, {\n trigger: (environment as GraphFromStoredOptions).trigger ?? {},\n }) as typeof selected)\n return {\n ...topology,\n ...materialized,\n deliverable: {\n ...deliverable,\n command,\n check: () => false, // runGraph binds the independent command authority before execution.\n },\n }\n}\n\n/** Digests present on disk (integrity probe for tests and audits). */\nexport async function storedGraphDigests(reg: GraphRegistryDir): Promise<string[]> {\n try {\n return (await readdir(join(reg.root, GRAPHS_DIR)))\n .filter((name) => name.endsWith('.json'))\n .map((name) => name.slice(0, -'.json'.length))\n .sort()\n } catch {\n return []\n }\n}\n"],"mappings":";;;;;;;;AAIA,MAAM,SAAS,EAAE,MAAM;CAAC,EAAE,OAAO;CAAG,EAAE,OAAO,CAAC,CAAC,OAAO;CAAG,EAAE,QAAQ;CAAG,EAAE,KAAK;AAAC,CAAC;AAC/E,MAAM,UAAU,EAAE,OAAO,CAAC,CAAC,MAAM,0BAA0B;AAC3D,MAAM,YAAY;CAAE,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CAAG;AAAQ;AAChE,MAAM,SAAS,EAAE,aAAa;CAAE,GAAG;CAAW,QAAQ;AAAO,CAAC;AAC9D,MAAM,QAAQ,EAAE,aAAa;CAAE,GAAG;CAAW,IAAI,EAAE,MAAM,MAAM;AAAE,CAAC;AAClE,MAAM,SAAS,EAAE,aAAa;CAAE,GAAG;CAAW,QAAQ,EAAE,QAAQ;AAAE,CAAC;AACnE,MAAM,QAAQ,EAAE,MAAM;CAAC;CAAQ;CAAO;AAAM,CAAC;;AAG7C,MAAa,uBAAuB,EAAE,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAEnG,MAAM,YAAY,EAAE,aAAa;CAC/B,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC9B,MAAM,EAAE,KAAK;EAAC;EAAU;EAAU;EAAW;EAAW;EAAU;EAAS;CAAM,CAAC,CAAC,CAAC,SAAS;AAC/F,CAAC;AACD,MAAM,UAAU,EAAE,aAAa;CAC7B,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACzB,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,S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;GACH;GACA,aAAa;EACf;CACF;AACF;;AAGA,eAAsB,mBAAmB,KAA0C;CACjF,IAAI;EACF,QAAQ,MAAM,QAAQ,KAAK,IAAI,MAAM,UAAU,CAAC,EAAA,CAC7C,QAAQ,SAAS,KAAK,SAAS,OAAO,CAAC,CAAC,CACxC,KAAK,SAAS,KAAK,MAAM,GAAG,EAAe,CAAC,CAAC,CAC7C,KAAK;CACV,QAAQ;EACN,OAAO,CAAC;CACV;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl-file-CvPuwM0a.js","names":[],"sources":["../src/redact.ts","../src/runtime/supervise/error-message.ts","../src/runtime/supervise/snapshot.ts","../src/content-digest.ts","../src/durable/jsonl-append.ts","../src/durable/jsonl-file.ts"],"sourcesContent":["/**\n * Redaction for values that may leave the Runtime process. The built-in\n * redactor is agent-eval's redaction core (`@tangle-network/agent-eval/traces`,\n * default profile): credentials found by field name or value shape are\n * replaced whole, email, card, SSN and phone values in place, and token counts\n * such as `inputTokens` or `max_tokens` are kept. A customer with\n * domain-specific PII supplies their own `redact` hook.\n *\n * This is narrower than `src/sanitize.ts`, which drops fields of the runtime's\n * *event envelope* unless the caller opts in: here the value is opaque customer\n * payload, so the scrub is value-shaped, not schema-shaped.\n *\n * @experimental\n */\n\nimport { REDACTION_VERSION, redact } from '@tangle-network/agent-eval/traces'\n\n/** A redactor maps an arbitrary trace value to a safe-to-export value. Pure;\n * must not throw on cyclic input (the default tolerates cycles). */\nexport type Redactor = (value: unknown) => unknown\n\n/**\n * The built-in redactor. Cycle-safe, depth-bounded and total: it never throws\n * on customer input and never mutates it.\n */\nexport function defaultRedactor(value: unknown): unknown {\n return redact(value).value\n}\n\n/** Stable identity input for saved work that depends on built-in redaction behavior. */\nexport function defaultRedactorIdentityMaterial(): unknown {\n return {\n core: '@tangle-network/agent-eval/traces redact',\n profile: 'default',\n version: REDACTION_VERSION,\n }\n}\n\n/**\n * Resolve the redactor a client uses. A caller-supplied hook handles\n * domain-specific values first, then the built-in scrubber still removes\n * credentials and personal data. Returning `false` is the explicit opt-out for\n * already-reviewed public values.\n */\nexport function resolveRedactor(redact: Redactor | false | undefined): Redactor {\n if (redact === false) return (value) => value\n if (!redact) return defaultRedactor\n return (value) => defaultRedactor(redact(value))\n}\n","import { defaultRedactor } from '../../redact'\n\nconst maxCauseDepth = 4\nconst maxMessageLength = 32_768\nconst maxPartLength = 2_048\n\n/** A persisted failure must explain its wrappers without exporting credentials or unbounded data. */\nexport function errorText(value: unknown): string {\n let text: string\n try {\n text = typeof value === 'string' ? value : (JSON.stringify(value) ?? String(value))\n } catch {\n text = '[unprintable rejection]'\n }\n return String(defaultRedactor(text)).slice(0, maxMessageLength)\n}\n\nexport function errorProperty(\n error: Error,\n field: 'name' | 'message' | 'stack',\n): string | undefined {\n try {\n const value = error[field]\n return value === undefined\n ? undefined\n : errorText(value).slice(0, field === 'name' ? 256 : maxMessageLength)\n } catch {\n return `[unreadable error ${field}]`\n }\n}\n\n/** An HTTP status carried on a thrown error, read without trusting its getter. Provider SDKs put\n * one on their own error classes, so this is how a refusal is recognised outside the transport\n * taxonomy — for the persisted message here, and for the driver's retry verdict. */\nexport function errorHttpStatus(error: Error): number | undefined {\n try {\n const status: unknown = Reflect.get(error, 'status')\n return typeof status === 'number' && Number.isInteger(status) && status >= 100 && status <= 599\n ? status\n : undefined\n } catch {\n return undefined\n }\n}\n\n/** Shared by child settlements, driver attempts, and the final no-winner result. */\nexport function errMessage(error: unknown): string {\n const parts: string[] = []\n const seen = new Set<Error>()\n let current = error\n for (let depth = 0; depth <= maxCauseDepth; depth += 1) {\n try {\n if (!(current instanceof Error)) {\n parts.push(errorText(current).slice(0, maxPartLength))\n break\n }\n if (seen.has(current)) {\n parts.push('[circular]')\n break\n }\n seen.add(current)\n const status = errorHttpStatus(current)\n const message =\n (status === undefined ? '' : `HTTP ${status}: `) + (errorProperty(current, 'message') ?? '')\n // An AggregateError's members carry its evidence: name each, one level deep.\n const members: unknown = Reflect.get(current, 'errors')\n const named = Array.isArray(members)\n ? ` [${members.map((m) => (m instanceof Error ? `${errorProperty(m, 'name')}: ${errorProperty(m, 'message')}` : errorText(m))).join('; ')}]`\n : ''\n const part = depth === 0 ? message : `${errorProperty(current, 'name')}: ${message}`\n parts.push(`${part}${named}`.slice(0, maxPartLength))\n current = current.cause\n if (current === undefined || current === null) break\n if (depth === maxCauseDepth) parts.push('[cause chain truncated]')\n } catch {\n parts.push('[unreadable error cause]')\n break\n }\n }\n return parts.join(': caused by ').slice(0, maxMessageLength)\n}\n\n/** The error and its causes (`cause`, and `errors` members), bounded and cycle-safe. */\nexport function causeChain(error: unknown): object[] {\n const chain: object[] = []\n const queue: unknown[] = [error]\n while (queue.length > 0 && chain.length < 12) {\n const value = queue.shift()\n if (typeof value !== 'object' || value === null || chain.includes(value)) continue\n chain.push(value)\n try {\n const errors: unknown = Reflect.get(value, 'errors')\n if (Array.isArray(errors)) queue.push(...errors)\n queue.push(Reflect.get(value, 'cause'))\n } catch {\n // A cause that cannot be read ends this branch of the walk.\n }\n }\n return chain\n}\n","import { ValidationError } from '../../errors'\n\n/** Deeply detach and freeze untrusted data at a runtime decision boundary. The clone prevents the\n * caller from mutating it later; the freeze prevents downstream code from mutating the snapshot.\n * Strings are immutable, so the snapshot shares the caller's strings instead of copying them. */\nexport function detachedSnapshot<T>(value: T, context: string): T {\n let clone: T\n try {\n clone = structuredClone(value)\n } catch (error) {\n throw new ValidationError(`${context}: input must be structured-cloneable`, { cause: error })\n }\n return deepFreeze(shareSourceStrings(value, clone))\n}\n\n/** Detach a value from its caller and freeze it, without the `ValidationError` framing\n * {@link detachedSnapshot} adds. For a boundary that has already validated its input. */\nexport function detachedFrozen<T>(value: T): T {\n return deepFreeze(shareSourceStrings(value, structuredClone(value)))\n}\n\n/**\n * Point each string in a fresh structured clone at the equal string in its source.\n *\n * `structuredClone` copies every string, and a copied string buys no isolation: only objects and\n * arrays can change through a shared reference. A spawned profile passes several boundaries, and\n * each one kept its own copy: in a reproduction of Discovery's hosted coordinator, a child profile\n * that mounts a 5.3 MB file packet was held four times per spawned child. A scope keeps every\n * child it spawned, so the heap grew about 22 MB per spawn, and hosted coordinators died with V8\n * heap OOM after 37 spawns.\n *\n * The walk pairs only own data properties of plain objects and arrays. Accessors, Maps, Sets and\n * other cloned types keep the clone's values. A string is replaced only by a string equal to it,\n * so the snapshot holds exactly the clone's value. The snapshot keeps the source's strings alive.\n */\nfunction shareSourceStrings<T>(source: unknown, clone: T): T {\n const visited = new Set<object>()\n const visit = (from: unknown, to: unknown): void => {\n if (from === null || to === null || typeof from !== 'object' || typeof to !== 'object') return\n const array = Array.isArray(to)\n if (array !== Array.isArray(from)) return\n if (!array && Object.getPrototypeOf(to) !== Object.prototype) return\n if (visited.has(to)) return\n visited.add(to)\n const target = to as Record<string, unknown>\n for (const key of Object.keys(target)) {\n const own = Object.getOwnPropertyDescriptor(from, key)\n if (own === undefined || !('value' in own)) continue\n const cloned = target[key]\n if (typeof cloned === 'string') {\n if (own.value === cloned) target[key] = own.value\n } else visit(own.value, cloned)\n }\n }\n visit(source, clone)\n return clone\n}\n\n/**\n * Replace each string in a freshly parsed JSON value with an equal string already in `pool`, and\n * add the new ones. One recovery pass parses every interrupted child's profile from its own blob,\n * so children that carry the same file packet would otherwise hold one copy each. The value is\n * updated in place, so it must belong to the caller; frozen objects are left as they are.\n */\nexport function shareParsedStrings<T>(value: T, pool: Map<string, string>): T {\n const visit = (node: unknown): void => {\n if (node === null || typeof node !== 'object' || Object.isFrozen(node)) return\n if (!Array.isArray(node) && Object.getPrototypeOf(node) !== Object.prototype) return\n const target = node as Record<string, unknown>\n for (const key of Object.keys(target)) {\n const item = target[key]\n if (typeof item !== 'string') {\n visit(item)\n continue\n }\n const shared = pool.get(item)\n if (shared === undefined) pool.set(item, item)\n else target[key] = shared\n }\n }\n visit(value)\n return value\n}\n\nfunction deepFreeze<T>(value: T, seen = new Set<object>()): T {\n // `Object.freeze` throws `TypeError: Cannot freeze array buffer views with elements` on any\n // non-empty TypedArray or Buffer, so binary inside a payload must be handed back untouched\n // rather than frozen. Its bytes are already detached by the `structuredClone` above.\n if (value === null || typeof value !== 'object' || ArrayBuffer.isView(value) || seen.has(value)) {\n return value\n }\n seen.add(value)\n for (const child of Object.values(value as Record<string, unknown>)) deepFreeze(child, seen)\n return Object.freeze(value)\n}\n","import { createHash } from 'node:crypto'\n\nexport function sha256(value: string): string {\n return createHash('sha256').update(value).digest('hex')\n}\n","import {\n closeSync,\n fstatSync,\n fsync,\n fsyncSync,\n ftruncateSync,\n openSync,\n readSync,\n writeSync,\n} from 'node:fs'\nimport { promisify } from 'node:util'\nimport { fenceRunWrite } from './run-fence'\n\n/** Append one JSONL record under the caller's existing single-writer discipline.\n * The caller creates the parent directory. Recover only an uncommitted tail and handle short\n * writes under one generation fence; fsync after the fence, off the event loop (#2362), and\n * resolve only once the bytes are durable. An optional acknowledgement reads the same open\n * descriptor inside the fence (the spawn journal validates its file stamp here).\n * @internal\n */\nexport function appendCommittedJsonLine(path: string, record: unknown): Promise<void>\nexport function appendCommittedJsonLine<T>(\n path: string,\n record: unknown,\n acknowledge: (fd: number) => T,\n): Promise<T>\nexport async function appendCommittedJsonLine<T>(\n path: string,\n record: unknown,\n acknowledge?: (fd: number) => T,\n): Promise<T | undefined> {\n const encoded = JSON.stringify(record)\n if (encoded === undefined) throw new TypeError('JSONL records must be JSON serializable')\n let fd: number | undefined\n try {\n const acknowledged = fenceRunWrite(() => {\n const bytes = Buffer.from(`${prepareJsonlTail(path) ? '\\n' : ''}${encoded}\\n`)\n fd = openSync(path, 'a')\n let offset = 0\n while (offset < bytes.length) {\n const written = writeSync(fd, bytes, offset, bytes.length - offset)\n if (written <= 0)\n throw new Error(`append-only file write made no progress at byte ${offset}`)\n offset += written\n }\n return acknowledge?.(fd)\n })\n await promisify(fsync)(fd as number)\n return acknowledged\n } finally {\n if (fd !== undefined) closeSync(fd)\n }\n}\n\n/** Recover only an uncommitted tail. Caller holds the generation fence. @internal */\nexport function prepareJsonlTail(path: string): boolean {\n let fd: number\n try {\n fd = openSync(path, 'r+')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false\n throw error\n }\n try {\n const size = fstatSync(fd).size\n if (size === 0) return false\n const last = Buffer.allocUnsafe(1)\n readAt(fd, last, size - 1)\n if (last[0] === 0x0a) return false\n const chunks: Buffer[] = []\n let end = size\n let tailStart = 0\n while (end > 0) {\n const start = Math.max(0, end - 65_536)\n const chunk = Buffer.allocUnsafe(end - start)\n readAt(fd, chunk, start)\n const newline = chunk.lastIndexOf(0x0a)\n chunks.push(chunk.subarray(newline + 1))\n if (newline >= 0) {\n tailStart = start + newline + 1\n break\n }\n end = start\n }\n try {\n JSON.parse(Buffer.concat(chunks.reverse()).toString('utf8'))\n return true\n } catch (error) {\n if (!(error instanceof SyntaxError)) throw error\n ftruncateSync(fd, tailStart)\n fsyncSync(fd)\n return false\n }\n } finally {\n closeSync(fd)\n }\n}\n\nfunction readAt(fd: number, buffer: Buffer, position: number): void {\n let offset = 0\n while (offset < buffer.length) {\n const read = readSync(fd, buffer, offset, buffer.length - offset, position + offset)\n if (read === 0) throw new Error('journal changed while preparing its append tail')\n offset += read\n }\n}\n","import type { FileHandle } from 'node:fs/promises'\nimport { prepareJsonlTail } from './jsonl-append'\nimport { fenceRunWrite } from './run-fence'\n\n/** Parse in-memory evidence with the same commit boundary as streamed journal reads. */\nexport function parseCommittedJsonLines<T>(text: string, source: string): T[] {\n const lines = text.split('\\n')\n const records: T[] = []\n for (const [index, line] of lines.entries()) {\n const record = parseRecord<T>(line, source, index + 1, index < lines.length - 1)\n if (record !== undefined) records.push(record.value)\n }\n return records\n}\n\n/** Read a fixed file prefix one record at a time, never allocating the whole journal as a string.\n * A reader cannot chase concurrent appends forever. Missing files are empty only when requested;\n * corruption, short reads, and other I/O errors remain failures. Closing the iterator closes the fd. */\nexport async function* readCommittedJsonLines<T>(\n path: string,\n options: {\n allowMissing?: boolean\n allowWhitespaceLines?: boolean\n onBytes?: (bytes: Uint8Array) => void\n } = {},\n): AsyncGenerator<T> {\n const fs = await import('node:fs/promises')\n let handle: FileHandle\n try {\n handle = await fs.open(path, 'r')\n } catch (error) {\n if (options.allowMissing && isNoEntError(error)) return\n throw error\n }\n try {\n const { size } = await handle.stat()\n if (size === 0) return\n const { StringDecoder } = await import('node:string_decoder')\n const decoder = new StringDecoder('utf8')\n const stream = handle.createReadStream({ autoClose: false, end: size - 1 })\n const fragments: string[] = []\n let lineNumber = 1\n try {\n for await (const chunk of stream) {\n options.onBytes?.(chunk as Buffer)\n const text = decoder.write(chunk as Buffer)\n let start = 0\n let end = text.indexOf('\\n', start)\n while (end !== -1) {\n fragments.push(text.slice(start, end))\n const record = parseRecord<T>(\n fragments.join(''),\n path,\n lineNumber++,\n true,\n options.allowWhitespaceLines,\n )\n fragments.length = 0\n if (record !== undefined) yield record.value\n start = end + 1\n end = text.indexOf('\\n', start)\n }\n if (start < text.length) fragments.push(text.slice(start))\n }\n if (stream.bytesRead !== size) {\n throw new Error(`${path}: journal changed while reading its committed prefix`)\n }\n fragments.push(decoder.end())\n const record = parseRecord<T>(\n fragments.join(''),\n path,\n lineNumber,\n false,\n options.allowWhitespaceLines,\n )\n if (record !== undefined) yield record.value\n } finally {\n stream.destroy()\n }\n } finally {\n await handle.close()\n }\n}\n\n/** An invalid unterminated tail may be a torn write; other parse failures are not evidence of one. */\nfunction parseRecord<T>(\n line: string,\n source: string,\n lineNumber: number,\n terminated: boolean,\n allowWhitespaceLines = false,\n): { value: T } | undefined {\n if (line.length === 0 || (allowWhitespaceLines && line.trim().length === 0)) return undefined\n try {\n return { value: JSON.parse(line) as T }\n } catch (cause) {\n if (!(cause instanceof SyntaxError)) throw cause\n if (!terminated) return undefined\n throw new Error(`${source}: malformed JSONL record at line ${lineNumber}`, { cause })\n }\n}\n\nexport { appendCommittedJsonLine } from './jsonl-append'\n\n/** Serialize JSONL file updates across processes and aliases using Eval's existing file lock.\n * The caller owns validation and the record format. The lock path names the canonical file,\n * including its first write, so two directory aliases cannot acquire different write heads.\n * @internal\n */\nexport async function withJsonlFileLock<T>(\n path: string,\n operation: (canonicalPath: string) => Promise<T>,\n): Promise<T> {\n const fs = await import('node:fs/promises')\n const { dirname } = await import('node:path')\n const { tryAcquireAtomicFileLock } = await import('@tangle-network/agent-eval/ledger-core')\n await fs.mkdir(dirname(path), { recursive: true })\n const file = await fs.open(path, 'a')\n await file.close()\n const canonicalPath = await fs.realpath(path)\n const deadline = Date.now() + 5000\n for (;;) {\n const acquisition = tryAcquireAtomicFileLock({ lockPath: `${canonicalPath}.lock` })\n if (!acquisition.acquired) {\n if (Date.now() >= deadline) {\n throw new Error(`journal file lock unavailable after 5000ms: ${canonicalPath}`)\n }\n await new Promise((resolve) => setTimeout(resolve, 25))\n continue\n }\n try {\n return await operation(canonicalPath)\n } finally {\n acquisition.lock.release()\n }\n }\n}\n\n/** Read one keyed registry snapshot without an extra whole-file text allocation.\n * Historical registry files allow whitespace-only separators; append journals remain strict.\n * @internal\n */\nexport async function readCommittedJsonFile<T>(path: string): Promise<T[]> {\n const records: T[] = []\n for await (const record of readCommittedJsonLines<T>(path, {\n allowMissing: true,\n allowWhitespaceLines: true,\n })) {\n records.push(record)\n }\n return records\n}\n\n/** Replace one keyed row and publish one durable snapshot. The caller holds the file lock.\n * Keep unrelated rows in order and put the replacement last. No revision archive is retained.\n * @internal\n */\nexport async function upsertCommittedJsonLine<T>(\n path: string,\n record: T,\n key: (record: T) => string,\n): Promise<void> {\n const encoded = JSON.stringify(record)\n if (encoded === undefined) throw new Error('JSONL records must be JSON serializable')\n const snapshot: T = JSON.parse(encoded)\n const id = key(snapshot)\n const updated: T[] = []\n for await (const prior of readCommittedJsonLines<T>(path, {\n allowMissing: true,\n allowWhitespaceLines: true,\n })) {\n if (key(prior) !== id) updated.push(prior)\n }\n updated.push(snapshot)\n // Reuse Runtime's file publication owner; this module owns JSONL framing, not another\n // durability implementation. Preserve the existing snapshot's permissions across rename.\n const { writeAtomicDurableFile } = await import('../runtime/supervise/durable-file')\n writeAtomicDurableFile(path, `${updated.map((row) => JSON.stringify(row)).join('\\n')}\\n`, {\n preserveMode: true,\n })\n}\n\n/** Recover a torn tail under the same generation fence as durable publications. @internal */\nexport async function prepareJsonlAppend(path: string): Promise<boolean> {\n return fenceRunWrite(() => prepareJsonlTail(path))\n}\n\n/** True for a filesystem error meaning \"the file is not there yet\" — the one condition an\n * append-only reader treats as an empty log rather than a fault. */\nexport function isNoEntError(error: unknown): boolean {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n (error as { code: unknown }).code === 'ENOENT'\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,gBAAgB,OAAyB;CACvD,OAAO,OAAO,KAAK,CAAC,CAAC;AACvB;;AAGA,SAAgB,kCAA2C;CACzD,OAAO;EACL,MAAM;EACN,SAAS;EACT,SAAS;CACX;AACF;;;;;;;AAQA,SAAgB,gBAAgB,QAAgD;CAC9E,IAAI,WAAW,OAAO,QAAQ,UAAU;CACxC,IAAI,CAAC,QAAQ,OAAO;CACpB,QAAQ,UAAU,gBAAgB,OAAO,KAAK,CAAC;AACjD;;AC9CA,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;AACzB,MAAM,gBAAgB;;AAGtB,SAAgB,UAAU,OAAwB;CAChD,IAAI;CACJ,IAAI;EACF,OAAO,OAAO,UAAU,WAAW,QAAS,KAAK,UAAU,KAAK,KAAK,OAAO,KAAK;CACnF,QAAQ;EACN,OAAO;CACT;CACA,OAAO,OAAO,gBAAgB,IAAI,CAAC,CAAC,CAAC,MAAM,GAAG,gBAAgB;AAChE;AAEA,SAAgB,cACd,OACA,OACoB;CACpB,IAAI;EACF,MAAM,QAAQ,MAAM;EACpB,OAAO,UAAU,KAAA,IACb,KAAA,IACA,UAAU,KAAK,CAAC,CAAC,MAAM,GAAG,UAAU,SAAS,MAAM,gBAAgB;CACzE,QAAQ;EACN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