@tangle-network/agent-runtime 0.337.2 → 0.338.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.
Files changed (112) hide show
  1. package/dist/{activation-DRHM55Oo.d.ts → activation-CsbNax2X.d.ts} +92 -4
  2. package/dist/activation-kbkAuSmY.js +889 -0
  3. package/dist/activation-kbkAuSmY.js.map +1 -0
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +3 -6
  6. package/dist/agent.js.map +1 -1
  7. package/dist/{bundle-BPGjESee.js → bundle-DM60AI2B.js} +2 -2
  8. package/dist/{bundle-BPGjESee.js.map → bundle-DM60AI2B.js.map} +1 -1
  9. package/dist/candidate-execution/index.d.ts +2 -2
  10. package/dist/candidate-execution/index.js +4 -5
  11. package/dist/candidate-execution/index.js.map +1 -1
  12. package/dist/content-digest-sBTLujlK.js +9 -0
  13. package/dist/content-digest-sBTLujlK.js.map +1 -0
  14. package/dist/{delegate-B-T_ZB50.js → delegate-Se1YZKMb.js} +2 -2
  15. package/dist/{delegate-B-T_ZB50.js.map → delegate-Se1YZKMb.js.map} +1 -1
  16. package/dist/{coordination-driver-BHkFVqIq.js → driver-control-acknowledgers-T2a1Ouay.js} +4514 -4440
  17. package/dist/driver-control-acknowledgers-T2a1Ouay.js.map +1 -0
  18. package/dist/durable.d.ts +1 -1
  19. package/dist/durable.js +223 -227
  20. package/dist/durable.js.map +1 -1
  21. package/dist/{graph-C4RFlWAJ.js → graph-CY0wH838.js} +65 -18
  22. package/dist/graph-CY0wH838.js.map +1 -0
  23. package/dist/{graph-registry-DAI6KNXB.js → graph-registry-By0tUj4S.js} +16 -15
  24. package/dist/graph-registry-By0tUj4S.js.map +1 -0
  25. package/dist/{improvement-cycle-D1I4hQvf.js → improve-CWGBT13K.js} +75 -1220
  26. package/dist/improve-CWGBT13K.js.map +1 -0
  27. package/dist/index.d.ts +6 -6
  28. package/dist/index.js +10 -13
  29. package/dist/index.js.map +1 -1
  30. package/dist/{integrations-DopfCC2a.d.ts → integrations-6xttbPi9.d.ts} +3 -3
  31. package/dist/integrations-dFi-ALk7.js.map +1 -1
  32. package/dist/intelligence.d.ts +7 -94
  33. package/dist/intelligence.js +505 -13
  34. package/dist/intelligence.js.map +1 -1
  35. package/dist/kernel.d.ts +2 -2
  36. package/dist/kernel.js +13 -12
  37. package/dist/{loop-runner-bin-DOuBIJ2O.d.ts → loop-runner-bin-CFnrAHpl.d.ts} +2 -2
  38. package/dist/{loop-runner-bin-Dv5QvYDH.js → loop-runner-bin-CdPlhy9g.js} +3 -3
  39. package/dist/{loop-runner-bin-Dv5QvYDH.js.map → loop-runner-bin-CdPlhy9g.js.map} +1 -1
  40. package/dist/loop-runner-bin.d.ts +1 -1
  41. package/dist/loop-runner-bin.js +1 -1
  42. package/dist/mcp/bin.js +3 -3
  43. package/dist/mcp/bin.js.map +1 -1
  44. package/dist/mcp/index.d.ts +7 -3
  45. package/dist/mcp/index.js +6 -8
  46. package/dist/mcp/index.js.map +1 -1
  47. package/dist/{openai-tools-Oxk4KQrY.d.ts → openai-tools-zh2I_uD7.d.ts} +2 -2
  48. package/dist/platform.d.ts +7 -2
  49. package/dist/platform.js +16 -8
  50. package/dist/platform.js.map +1 -1
  51. package/dist/{prepare-CER-ZkPp.js → prepare-Bt0IouPq.js} +1241 -586
  52. package/dist/prepare-Bt0IouPq.js.map +1 -0
  53. package/dist/{profile-gNUsHNIJ.js → profile-Do-5xO_D.js} +89 -3
  54. package/dist/profile-Do-5xO_D.js.map +1 -0
  55. package/dist/profiles.d.ts +1 -1
  56. package/dist/profiles.js +1 -3
  57. package/dist/profiles.js.map +1 -1
  58. package/dist/{protected-model-port-BhpQRTw-.d.ts → protected-model-port-DGxQ8_YM.d.ts} +3 -3
  59. package/dist/{provision-supervisor-DGegCUH4.js → provision-supervisor-0jMufp4h.js} +12 -9
  60. package/dist/provision-supervisor-0jMufp4h.js.map +1 -0
  61. package/dist/record-value-B6bwJxLa.js +12 -0
  62. package/dist/record-value-B6bwJxLa.js.map +1 -0
  63. package/dist/{run-layout-Cu8H7aeh.js → run-cancellation-BoW5Sg9Y.js} +174 -95
  64. package/dist/run-cancellation-BoW5Sg9Y.js.map +1 -0
  65. package/dist/{runtime-BOGpotnH.js → runtime-D37zRSs7.js} +431 -621
  66. package/dist/runtime-D37zRSs7.js.map +1 -0
  67. package/dist/{sandbox-profile-compat-QTkLe1Z6.js → sandbox-profile-compat-xSoVtdWw.js} +690 -697
  68. package/dist/sandbox-profile-compat-xSoVtdWw.js.map +1 -0
  69. package/dist/search-executor-DmgUm5p7.js +1916 -0
  70. package/dist/search-executor-DmgUm5p7.js.map +1 -0
  71. package/dist/{server-hZWM-G8w.js → server-DQHJszfk.js} +4 -4
  72. package/dist/server-DQHJszfk.js.map +1 -0
  73. package/dist/{search-executor-Cm1WZmL-.js → structural-rollout-DAvIE8mw.js} +2261 -3984
  74. package/dist/structural-rollout-DAvIE8mw.js.map +1 -0
  75. package/dist/{supervise-CvAKVfue.js → supervise-WuPAwfPh.js} +7793 -5338
  76. package/dist/supervise-WuPAwfPh.js.map +1 -0
  77. package/dist/{supervisor-Rz8AGpYb.js → supervisor-CPG1I9UN.js} +26590 -27196
  78. package/dist/supervisor-CPG1I9UN.js.map +1 -0
  79. package/dist/testing.d.ts +226 -1
  80. package/dist/testing.js +13 -14
  81. package/dist/testing.js.map +1 -1
  82. package/dist/{top-app-BaMw1W2z.js → top-app-C55Wa7uy.js} +339 -337
  83. package/dist/top-app-C55Wa7uy.js.map +1 -0
  84. package/dist/tui/bin.js +1 -1
  85. package/dist/tui/index.d.ts +17 -15
  86. package/dist/tui/index.js +2 -2
  87. package/dist/{types-Dl5L4r8Z.d.ts → types-CrNWif8-.d.ts} +17410 -17173
  88. package/dist/{workspace-streams-JLjh5DC6.d.ts → workspace-streams-BZZds1Fw.d.ts} +18 -16
  89. package/package.json +2 -2
  90. package/skills/agent-graphs/SKILL.md +10 -3
  91. package/skills/agent-graphs/references/authoring.md +17 -0
  92. package/skills/profile-authoring/SKILL.md +3 -3
  93. package/skills/supervise/SKILL.md +2 -2
  94. package/dist/activation-BDP6Eivv.js +0 -234
  95. package/dist/activation-BDP6Eivv.js.map +0 -1
  96. package/dist/coordination-driver-BHkFVqIq.js.map +0 -1
  97. package/dist/graph-C4RFlWAJ.js.map +0 -1
  98. package/dist/graph-registry-DAI6KNXB.js.map +0 -1
  99. package/dist/improvement-cycle-D1I4hQvf.js.map +0 -1
  100. package/dist/prepare-CER-ZkPp.js.map +0 -1
  101. package/dist/profile-gNUsHNIJ.js.map +0 -1
  102. package/dist/protected-model-port-BuRsviSL.js +0 -766
  103. package/dist/protected-model-port-BuRsviSL.js.map +0 -1
  104. package/dist/provision-supervisor-DGegCUH4.js.map +0 -1
  105. package/dist/run-layout-Cu8H7aeh.js.map +0 -1
  106. package/dist/runtime-BOGpotnH.js.map +0 -1
  107. package/dist/sandbox-profile-compat-QTkLe1Z6.js.map +0 -1
  108. package/dist/search-executor-Cm1WZmL-.js.map +0 -1
  109. package/dist/server-hZWM-G8w.js.map +0 -1
  110. package/dist/supervise-CvAKVfue.js.map +0 -1
  111. package/dist/supervisor-Rz8AGpYb.js.map +0 -1
  112. package/dist/top-app-BaMw1W2z.js.map +0 -1
@@ -523,16 +523,7 @@ declare const CANDIDATE_TRACE_ENV: {
523
523
  readonly traceRunId: "TANGLE_TRACE_RUN_ID";
524
524
  };
525
525
  //#endregion
526
- //#region src/candidate-execution/workspace-archive.d.ts
527
- interface AgentCandidateWorkspaceArchiveLimits {
528
- maxArchiveBytes: number;
529
- maxEmbeddedArtifactBytes: number;
530
- maxFiles: number;
531
- maxFileBytes: number;
532
- maxTotalFileBytes: number;
533
- maxPathBytes: number;
534
- maxRepositoryBundleBytes: number;
535
- }
526
+ //#region src/candidate-execution/workspace-archive-local.d.ts
536
527
  interface CaptureAgentCandidateWorkspaceOptions {
537
528
  /** Include Git HEAD so task preparation can prove its exact commit and tree. */
538
529
  includeRepository?: boolean;
@@ -554,17 +545,28 @@ interface CaptureAgentCandidateWorkspaceOptions {
554
545
  interface CreateAgentCandidateWorkspacePortOptions {
555
546
  limits?: Partial<AgentCandidateWorkspaceArchiveLimits>;
556
547
  }
548
+ /** Capture one exact regular-file workspace for immutable candidate execution. */
549
+ declare function captureAgentCandidateWorkspace(rootInput: string, options?: CaptureAgentCandidateWorkspaceOptions): Promise<CapturedAgentCandidateWorkspace>;
550
+ /** Create the standard bounded materializer for candidate execution ports. */
551
+ declare function createAgentCandidateWorkspacePort(options?: CreateAgentCandidateWorkspacePortOptions): AgentCandidateWorkspacePort;
552
+ //#endregion
553
+ //#region src/candidate-execution/workspace-archive.d.ts
554
+ interface AgentCandidateWorkspaceArchiveLimits {
555
+ maxArchiveBytes: number;
556
+ maxEmbeddedArtifactBytes: number;
557
+ maxFiles: number;
558
+ maxFileBytes: number;
559
+ maxTotalFileBytes: number;
560
+ maxPathBytes: number;
561
+ maxRepositoryBundleBytes: number;
562
+ }
557
563
  interface CapturedAgentCandidateWorkspace {
558
564
  readonly snapshot: AgentCandidateWorkspaceSnapshotEvidence;
559
565
  /** Caller-owned bytes accepted by createAgentCandidateWorkspacePort. */
560
566
  readonly archive: Uint8Array;
561
567
  }
562
- /** Capture one exact regular-file workspace for immutable candidate execution. */
563
- declare function captureAgentCandidateWorkspace(rootInput: string, options?: CaptureAgentCandidateWorkspaceOptions): Promise<CapturedAgentCandidateWorkspace>;
564
568
  /** Capture detached files returned by a remote executor into the standard archive. */
565
569
  declare function captureAgentCandidateWorkspaceFiles(input: readonly AgentCandidateExecutorWorkspaceFile[], options?: Omit<CaptureAgentCandidateWorkspaceOptions, 'includeRepository' | 'repositoryContents'>): Promise<CapturedAgentCandidateWorkspace>;
566
- /** Create the standard bounded materializer for candidate execution ports. */
567
- declare function createAgentCandidateWorkspacePort(options?: CreateAgentCandidateWorkspacePortOptions): AgentCandidateWorkspacePort;
568
570
  //#endregion
569
571
  //#region src/candidate-execution/workspace-streams.d.ts
570
572
  interface CaptureAgentCandidateWorkspaceToArtifactsOptions {
@@ -629,5 +631,5 @@ declare function materializeAgentCandidateWorkspaceFromArtifacts(input: AgentCan
629
631
  destination: string;
630
632
  }): Promise<void>;
631
633
  //#endregion
632
- export { PreparedAgentCandidateLaunch as $, AgentCandidateMemoryPort as A, AgentCandidateProtectedRunCapture as B, AgentCandidateExecutorPort as C, AgentCandidateExecutorTaskOutcomeCapture as D, AgentCandidateExecutorStopRequest as E, AgentCandidateOutputPurpose as F, AgentCandidateWorkspacePort as G, AgentCandidateRunFinalization as H, AgentCandidateProtectedModelActivation as I, CanonicalCandidateDocument as J, CANDIDATE_TRACE_ENV as K, AgentCandidateProtectedModelReservation as L, AgentCandidateModelLimits as M, AgentCandidateModelPort as N, AgentCandidateExecutorWorkspaceFile as O, AgentCandidateOutputArtifactPort as P, PreparedAgentCandidateKnowledge as Q, AgentCandidateProtectedModelSettlement as R, AgentCandidateExecutorMemoryCapture as S, AgentCandidateExecutorRequest as T, AgentCandidateTaskExecution as U, AgentCandidateRepositoryPort as V, AgentCandidateVerificationPorts as W, PreparedAgentCandidateExecution as X, PersistedTaskOutcomeEvidence as Y, PreparedAgentCandidateInstruction as Z, AgentCandidateBenchmarkGraderIdentity as _, captureAgentCandidateWorkspaceTreeToArtifacts as a, AgentCandidateExecutionPorts as b, verifyAgentCandidateWorkspaceTree as c, CapturedAgentCandidateWorkspace as d, PreparedAgentCandidateTrace as et, CreateAgentCandidateWorkspacePortOptions as f, AgentCandidateArtifactPort as g, createAgentCandidateWorkspacePort as h, captureAgentCandidateWorkspaceToArtifacts as i, AgentCandidateExecutionRoots as it, AgentCandidateMemoryResetResult as j, AgentCandidateExecutorWorkspaceInput as k, AgentCandidateWorkspaceArchiveLimits as l, captureAgentCandidateWorkspaceFiles as m, AgentCandidateWorkspaceTree as n, VerifiedAgentCandidate as nt, materializeAgentCandidateWorkspaceFromArtifacts as o, captureAgentCandidateWorkspace as p, CANDIDATE_TRACE_TAGS as q, CaptureAgentCandidateWorkspaceToArtifactsOptions as r, VerifiedAgentCandidateTaskOutcome as rt, verifyAgentCandidateWorkspaceArtifacts as s, AgentCandidateWorkspaceArtifactsOptions as t, ResolvedAgentCandidateContainer as tt, CaptureAgentCandidateWorkspaceOptions as u, AgentCandidateBenchmarkGraderPort as v, AgentCandidateExecutorProfileFile as w, AgentCandidateExecutorFinalCapture as x, AgentCandidateContainerPort as y, AgentCandidateProtectedModelSettlementCall as z };
633
- //# sourceMappingURL=workspace-streams-JLjh5DC6.d.ts.map
634
+ export { PreparedAgentCandidateLaunch as $, AgentCandidateMemoryPort as A, AgentCandidateProtectedRunCapture as B, AgentCandidateExecutorPort as C, AgentCandidateExecutorTaskOutcomeCapture as D, AgentCandidateExecutorStopRequest as E, AgentCandidateOutputPurpose as F, AgentCandidateWorkspacePort as G, AgentCandidateRunFinalization as H, AgentCandidateProtectedModelActivation as I, CanonicalCandidateDocument as J, CANDIDATE_TRACE_ENV as K, AgentCandidateProtectedModelReservation as L, AgentCandidateModelLimits as M, AgentCandidateModelPort as N, AgentCandidateExecutorWorkspaceFile as O, AgentCandidateOutputArtifactPort as P, PreparedAgentCandidateKnowledge as Q, AgentCandidateProtectedModelSettlement as R, AgentCandidateExecutorMemoryCapture as S, AgentCandidateExecutorRequest as T, AgentCandidateTaskExecution as U, AgentCandidateRepositoryPort as V, AgentCandidateVerificationPorts as W, PreparedAgentCandidateExecution as X, PersistedTaskOutcomeEvidence as Y, PreparedAgentCandidateInstruction as Z, AgentCandidateBenchmarkGraderIdentity as _, captureAgentCandidateWorkspaceTreeToArtifacts as a, AgentCandidateExecutionPorts as b, verifyAgentCandidateWorkspaceTree as c, captureAgentCandidateWorkspaceFiles as d, PreparedAgentCandidateTrace as et, CaptureAgentCandidateWorkspaceOptions as f, AgentCandidateArtifactPort as g, createAgentCandidateWorkspacePort as h, captureAgentCandidateWorkspaceToArtifacts as i, AgentCandidateExecutionRoots as it, AgentCandidateMemoryResetResult as j, AgentCandidateExecutorWorkspaceInput as k, AgentCandidateWorkspaceArchiveLimits as l, captureAgentCandidateWorkspace as m, AgentCandidateWorkspaceTree as n, VerifiedAgentCandidate as nt, materializeAgentCandidateWorkspaceFromArtifacts as o, CreateAgentCandidateWorkspacePortOptions as p, CANDIDATE_TRACE_TAGS as q, CaptureAgentCandidateWorkspaceToArtifactsOptions as r, VerifiedAgentCandidateTaskOutcome as rt, verifyAgentCandidateWorkspaceArtifacts as s, AgentCandidateWorkspaceArtifactsOptions as t, ResolvedAgentCandidateContainer as tt, CapturedAgentCandidateWorkspace as u, AgentCandidateBenchmarkGraderPort as v, AgentCandidateExecutorProfileFile as w, AgentCandidateExecutorFinalCapture as x, AgentCandidateContainerPort as y, AgentCandidateProtectedModelSettlementCall as z };
635
+ //# sourceMappingURL=workspace-streams-BZZds1Fw.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-runtime",
3
- "version": "0.337.2",
3
+ "version": "0.338.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": {
@@ -186,7 +186,7 @@
186
186
  "verify:package": "pnpm run verify:package:static && node scripts/verify-package-exports.mjs && pnpm run verify:edge-tool-loop",
187
187
  "verify:package:static": "pnpm run check:model-execution-boundary && pnpm run verify:static-imports && pnpm run build && pnpm run check:api-surface && pnpm run check:testing-fixture && pnpm run check:skills && publint && attw --pack --profile esm-only .",
188
188
  "verify:official-optimizers": "node scripts/verify-official-optimizers.mjs",
189
- "docs:api": "pnpm run build && typedoc && node scripts/gen-primitive-catalog.mjs",
189
+ "docs:api": "pnpm run build && typedoc && node scripts/generated-api-links.mjs --write && node scripts/gen-primitive-catalog.mjs",
190
190
  "docs:freshness": "node scripts/check-docs-freshness.mjs",
191
191
  "docs:check": "pnpm run docs:api && git diff --exit-code -- docs/api && pnpm run docs:freshness"
192
192
  }
@@ -1,11 +1,16 @@
1
1
  ---
2
2
  name: agent-graphs
3
- description: Author fixed AgentGraph roles with explicit delegation, analysis, completion, and budgets.
3
+ description: Author fixed AgentGraph roles, routes, delegation, analysis, completion and budgets.
4
4
  ---
5
5
 
6
6
  # Agent Graphs
7
7
 
8
8
  Use `runGraph` when roles are known before execution and their relationships must be explicit Runtime data.
9
+ When the order, branches, repair loops and stop rules are known too, author a flow graph: `entry` plus `routes` edges, with no root and no brain.
10
+ Parallel stages are a fork (`to` lists several nodes, spawned at once) and waiting for all of them is a join (`from` lists several nodes); converging plain routes into one running node throw `GraphRouteError` with reason `target-live`.
11
+ A loop per item is a flow graph inside a maps item, and a flow graph can run as a `run_graph` subtask.
12
+ A human approval in a flow is a gate (`gates: [{ id, question, choices }]` with one routes edge per choice matching `/choice`), answered by the caller's `decideGate` while the run is held; a wait of days without a held process belongs to a Platform workflow `wait.*` or `decision` action.
13
+ Keep a root (delegation edges) only when a model must decide what runs next; a root brain that only orders fixed stages is the anti-pattern a flow graph replaces.
9
14
  Use a smaller maintained composition when it provides the required behavior.
10
15
  Use dynamic supervision when the agent must discover or create roles while working.
11
16
  A request for review alone does not require a graph.
@@ -19,7 +24,7 @@ Define the artifact and independent completion check before choosing roles.
19
24
  Give each required role a complete AgentProfile and capabilities appropriate to its task.
20
25
  Preserve requested parallel instances and independent reviewers rather than collapsing their distinct work into a root prompt.
21
26
 
22
- When authoring nodes, directives, traversal limits, or analyst routes, read [the graph contract](references/authoring.md).
27
+ When authoring nodes, directives, routes, traversal limits, or analyst routes, read [the graph contract](references/authoring.md).
23
28
  The runtime validates structure and prompt references before execution.
24
29
  Keep the shared budget, per-worker allocation, concurrency, and supported limits in their actual API fields.
25
30
  Use measured execution cost when available; do not turn a prior run into a universal minimum budget.
@@ -31,7 +36,9 @@ Then exercise the intended backend, profiles, tools, and completion check on a r
31
36
  Offline control-flow tests do not establish that a real agent solves the task.
32
37
 
33
38
  Inspect the terminal result, complete cost and token accounting, edge delivery records, exhausted edges, and journal evidence.
34
- An expected edge with zero traversals did not exercise its intended relationship.
39
+ An expected edge with zero traversals did not exercise its intended relationship, unless it is a branch the test chose not to take.
40
+ A flow run that ends early names why on `stopped`; a settle no routes edge matches throws `GraphRouteError` with the ledger.
41
+ Each gate visit is one `gate:<id>` ledger row whose `gate.by` names who decided.
35
42
  Unknown usage is missing evidence, not zero cost.
36
43
  A passing check proves only the outcome it actually tests.
37
44
 
@@ -6,6 +6,7 @@ Start from a matching [example](https://github.com/tangle-network/agent-runtime/
6
6
  ## Nodes and work
7
7
 
8
8
  AgentGraph requires nodes, edges, a deliverable, and a shared budget.
9
+ Adding `entry` makes it a flow graph: Runtime spawns each entry node with its task and traverses `routes` edges itself, so no node is a root.
9
10
  Each node holds an id and a canonical AgentProfile; its profile name matches the node id for routing.
10
11
  Standing roles belong in the profile prompt, with explicit tools and resources.
11
12
  Put the concrete mission in the deliverable description and supply an independent completion check that rejects incomplete output.
@@ -43,10 +44,26 @@ A list longer than `maxItems`, a pointer that does not select an array, or a `co
43
44
  Each item reserves `itemBudget` from the shared budget.
44
45
  Map state is process-local: a restarted run does not re-expand a map whose source settled before the restart.
45
46
 
47
+ Routes edges run a flow graph and need `entry`; a flow graph takes no delegation or analysis edge.
48
+ On each usable settle of `from`, its routes edges are tried in declaration order and the first whose `when` holds fires; one settle fires at most one edge.
49
+ `when` compares JSON scalars only (`equals`, `in`, `exists` at an RFC 6901 pointer, or `all` of several); a numeric or stateful rule is a field the node settles, such as a boolean or a counter.
50
+ A match reads `from` unless it names a node listed in the edge's `evidence`; a pointer that does not resolve does not match.
51
+ An edge without `when` is the default branch: at most one per node, and last.
52
+ A node target receives `{ from: { node, result }, evidence }` and the edge directive; `{ stop: reason }` ends the run with no winner; `{ finish: reason }` makes this settle part of the output.
53
+ The output is `{ [node]: latest usable result }` over terminal nodes (no outgoing routes or map edge) and finish sources, and the deliverable decides it.
54
+ Every routes cycle, each subcycle included, must cross an edge with an explicit `maxTraversals`: a cap on `a -> b` does not bound a `b <-> c` loop beside it. An edge at its cap is skipped and matching continues, so give a repair loop a fallback edge.
55
+ `continuity: 'resume'` continues the target's latest settled session.
56
+ A fork lists two or more nodes in `to`: one traversal spawns them all at once, each under key `route:<edge>#<traversal>:<node>`.
57
+ A join lists two or more nodes in `from`: it fires once every member has settled usably since it last fired, its target's evidence holds each member's latest result, it carries no `when`, and it is the only routes edge leaving each member.
58
+ A route into a node that still has a running worker throws `GraphRouteError` with reason `target-live`; converging branches use a join.
59
+ A map edge may leave any flow node, and its join may have routes edges.
60
+ A maps edge's `graph` item and a `run_graph` subtask may be flow graphs (`entry` on the topology). Inside a maps item, every entry whose task is `{ item: true }` receives the item value, and a down settle ends that item only, so `onItemFailure` decides the join.
61
+
46
62
  ## Check the result
47
63
 
48
64
  Inspect delivered, stripped, empty, unpropagated, and failed edge records and their byte counts.
49
65
  A map edge records one expansion row, one row per item with its index, and one join row.
66
+ A flow records one `routes:entry-><node>` row per entry and one `routes:<from>#<ordinal>-><target>` row per traversal, cap skip or refused spawn; a fork records one row per spawned node, and a join's `<from>` and a fork's `<target>` join their nodes with `+`.
50
67
  Read exhausted edges even when execution ended through completion, budget, or cancellation rather than a thrown error.
51
68
  Check journal records when recovery or auditability is part of the task.
52
69
  Preserve run, profile, directive, and artifact identity so a resumed or measured run cannot silently change its inputs.
@@ -25,7 +25,7 @@ Start from a profile that already ran (in a Discovery play, `inputs/profile-exam
25
25
  | `prompt` | The role in `instructions[0]`, the procedure after it. No `systemPrompt`: it replaces the harness's own guidance (17,730 characters on Codex), and Discovery refuses one under 4,000 characters. No `appendSystemPrompt` on Codex or Gemini. |
26
26
  | `resources` | `failOnError: true`. Hand each file by path, `{"path": "<mount>", "resource": {"kind": "inline", "name": "<name>", "path": "<file in your workspace>"}}`: Runtime reads the bytes (UTF-8, at most 4 MiB). Never retype a file into `content`: a manager that did delivered 5 wrong characters in 24,008. |
27
27
 
28
- Native tool ids (agent-container `packages/agent-profile-materialize/src/control-maps.ts` and `execution-controls.ts`; matching ignores case and all but letters, digits and `_`):
28
+ Native tool ids (agent-container's `agent-profile-materialize` package (`control-maps` and `execution-controls`); matching ignores case and all but letters, digits and `_`):
29
29
 
30
30
  | Harness | Accepted | Refused |
31
31
  |---|---|---|
@@ -35,9 +35,9 @@ Native tool ids (agent-container `packages/agent-profile-materialize/src/control
35
35
  | pi | names in Pi's own registry: read, bash, edit, write (glob becomes find, shell becomes bash); a named tool Pi lacks ends the session | names Pi lacks |
36
36
  | any other | no `tools` and no `permissions` | every entry |
37
37
 
38
- A harness's own subagent runs outside Runtime: no journal row, no reservation from the shared budget, no grade. Turn native subagents on when the agent needs internal throughput (split and merge, maker and critic, best of N) and separate Runtime identity, budget and grading are unnecessary; their work counts only through the delivered artifact. Use Runtime spawn (`agent_runtime_coordination_spawn_worker`) when a child needs its own record, budget or check. agent-dev-container maps these tools in `packages/agent-profile-materialize/src/control-maps.ts`.
38
+ A harness's own subagent runs outside Runtime: no journal row, no reservation from the shared budget, no grade. Turn native subagents on when the agent needs internal throughput (split and merge, maker and critic, best of N) and separate Runtime identity, budget and grading are unnecessary; their work counts only through the delivered artifact. Use Runtime spawn (`agent_runtime_coordination_spawn_worker`) when a child needs its own record, budget or check. agent-dev-container maps these tools in its `agent-profile-materialize` package (`control-maps`).
39
39
 
40
- Runtime keys (agent-runtime `src/runtime/supervise/provider-visible-profile.ts`; verbs from `coordinationVerbNames` in `src/mcp/tools/coordination.ts`):
40
+ Runtime keys (agent-runtime `src/runtime/supervise/provider-visible-profile.ts`; verbs from `coordinationVerbNames` in `src/mcp/tools/coordination-events.ts`):
41
41
 
42
42
  - Runtime removes every key that starts with `agent_runtime_coordination_` before the harness sees the profile. Any other spelling reaches the harness and is refused: a bare `knowledge_record`, OpenCode's `agent-runtime-coordination_spawn_worker`, Claude Code's `mcp__agent-runtime-coordination__spawn_worker`, or `agent_runtime_spawn_worker`.
43
43
  - Verbs: `spawn_worker`, `cancel_worker`, `observe_agent`, `steer_agent`, `read_journal`, `submit_result`, `report_blocked`, `ask_parent`, `list_questions`, `answer_question`, `read_continuation`, `stop`, `list_analysts`, `run_analyst`, `define_analyst`, `run_graph`.
@@ -13,12 +13,12 @@ Author agents that can perform the required work, then direct them from checked
13
13
  Put research choices, methods, revision rules, and stopping criteria in each profile's prompt.
14
14
  Runtime owns shared budgets, recursion limits, concurrency, cancellation, journals, and recovery.
15
15
  The caller configures root execution through [SuperviseOptions](https://github.com/tangle-network/agent-runtime/blob/main/src/runtime/supervise/supervise.ts).
16
- Per-assignment budgets, continuity, and keys belong to the [coordination tools](https://github.com/tangle-network/agent-runtime/blob/main/src/mcp/tools/coordination.ts), not invented profile fields.
16
+ Per-assignment budgets, continuity, and keys belong to the [coordination tools](https://github.com/tangle-network/agent-runtime/blob/main/src/mcp/tools/coordination-worker-tools.ts), not invented profile fields.
17
17
 
18
18
  An agent receives recursive authority by declaring `agent_runtime_coordination_spawn_worker: true` in its tools.
19
19
  Declare each other Runtime tool it needs explicitly.
20
20
  Metadata describes work; it does not grant authority.
21
- Every profile that can spawn workers carries the complete `profile-authoring/SKILL.md` skill shipped beside this one, as an immutable inline snapshot with `resources.failOnError: true`.
21
+ Every profile that can spawn workers carries the complete `skills/profile-authoring/SKILL.md` skill shipped beside this one, as an immutable inline snapshot with `resources.failOnError: true`.
22
22
  The authored profile must explain its own ability to delegate; Runtime does not invent that policy.
23
23
 
24
24
  Before creating or changing any profile, follow [profile authoring](../profile-authoring/SKILL.md): the audience and its acceptance test, the probed proxy gap, the referee, the honest null, and the profile contract.
@@ -1,234 +0,0 @@
1
- import { F as canonicalCandidateDigest$1, H as verifyCanonicalCandidateDocument, I as canonicalCandidateDocument, z as immutableCandidateValue } from "./sandbox-profile-compat-QTkLe1Z6.js";
2
- import { A as agentImprovementTargetInput, M as agentProfileImprovementStateDigest, c as requireSealedCandidateExperiment, d as verifyAgentImprovementActivation, f as verifyAgentImprovementProposal, k as agentImprovementTargetDigest } from "./improvement-cycle-D1I4hQvf.js";
3
- import { agentImprovementActivationResultSchema, agentImprovementActivationSchema, agentProfileImprovementExperimentSchema } from "@tangle-network/agent-interface";
4
- //#region src/runtime-usage.ts
5
- function createRuntimeUsageTotals() {
6
- return {
7
- tokensIn: 0,
8
- tokensOut: 0,
9
- costUsd: 0,
10
- llmCalls: 0
11
- };
12
- }
13
- function isUsageAmount(value) {
14
- return typeof value === "number" && Number.isFinite(value) && value >= 0;
15
- }
16
- /** Fold normalized per-call events. Backend adapters own cumulative receipt reconciliation. */
17
- function addRuntimeUsage(totals, event) {
18
- totals.llmCalls += 1;
19
- for (const key of [
20
- "tokensIn",
21
- "tokensOut",
22
- "costUsd"
23
- ]) {
24
- const value = event[key];
25
- if (isUsageAmount(value)) totals[key] += value;
26
- else if (key === "costUsd") totals.usdKnown = false;
27
- else totals.tokensKnown = false;
28
- }
29
- if (event.tokensKnown === false) totals.tokensKnown = false;
30
- if (event.usdKnown === false) totals.usdKnown = false;
31
- if (isUsageAmount(event.estimatedCostUsd)) totals.estimatedCostUsd = (totals.estimatedCostUsd ?? 0) + event.estimatedCostUsd;
32
- }
33
- //#endregion
34
- //#region src/intelligence/activation.ts
35
- /** Create the exact result a product stores in the same transaction as its target write. */
36
- function createAgentImprovementActivationResult(transition, options) {
37
- const activation = verifyCanonicalCandidateDocument(agentImprovementActivationSchema.parse(transition.activation), "agent improvement activation");
38
- assertTransitionInput(activation, transition);
39
- const result = agentImprovementActivationResultSchema.parse(canonicalCandidateDocument({
40
- kind: "agent-improvement-activation-result",
41
- idempotencyKey: activation.digest,
42
- attemptedAt: transition.attemptedAt,
43
- completedAt: options.completedAt,
44
- outcome: options.outcome
45
- }).value);
46
- assertResultAgainstActivation(activation, result);
47
- assertOutcomeDesiredState(activation, result, new Map(transition.targets.map((target) => [targetIdentity(target), target.desiredDigest])));
48
- return immutableCandidateValue(result);
49
- }
50
- /**
51
- * Recompute one historical activation result against the exact measured proposal and authority.
52
- * The result records that attempt; it is not a query of the target's current state.
53
- */
54
- function verifyAgentImprovementActivationResult(input) {
55
- const proposal = verifyAgentImprovementProposal(input.proposal);
56
- const activation = verifyAgentImprovementActivation(input);
57
- const result = verifyCanonicalCandidateDocument(agentImprovementActivationResultSchema.parse(input.result), "agent improvement activation result");
58
- assertResultAgainstActivation(activation, result);
59
- assertResultDesiredState(proposal, activation, result);
60
- return result;
61
- }
62
- /** Validate and execute one product-owned activation transition. */
63
- async function executeAgentImprovementActivation(input, options) {
64
- const proposal = verifyAgentImprovementProposal(input.proposal);
65
- const activation = verifyAgentImprovementActivation(input);
66
- const observedAt = (options.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
67
- const attemptedAt = Date.parse(observedAt) < Date.parse(activation.authorizedAt) ? activation.authorizedAt : observedAt;
68
- const expired = Date.parse(attemptedAt) >= Date.parse(activation.expiresAt);
69
- const transition = immutableCandidateValue(proposal.evaluation.kind === "agent-improvement-measured-comparison" ? sealedCandidateTransition(proposal.evaluation.experiment, activation, attemptedAt, expired) : profileImprovementTransition(proposal.evaluation.experiment, activation, attemptedAt, expired));
70
- if (transition.expired) {
71
- if (!options.reconcile) return uncertainActivationResult(transition, "RECONCILIATION_UNAVAILABLE");
72
- let reconciled;
73
- try {
74
- reconciled = await options.reconcile(transition);
75
- } catch {
76
- return uncertainActivationResult(transition, "RECONCILIATION_THROW");
77
- }
78
- if (reconciled === void 0) return createAgentImprovementActivationResult(transition, {
79
- completedAt: transition.attemptedAt,
80
- outcome: { status: "expired" }
81
- });
82
- try {
83
- return verifyAgentImprovementActivationResult({
84
- ...input,
85
- result: reconciled
86
- });
87
- } catch {
88
- return uncertainActivationResult(transition, "INVALID_RECONCILIATION");
89
- }
90
- }
91
- let rawResult;
92
- try {
93
- rawResult = await options.transition(transition);
94
- } catch {
95
- return uncertainActivationResult(transition, "TRANSITION_THROW");
96
- }
97
- try {
98
- return verifyAgentImprovementActivationResult({
99
- ...input,
100
- result: rawResult
101
- });
102
- } catch {
103
- return uncertainActivationResult(transition, "INVALID_RESULT");
104
- }
105
- }
106
- function sealedCandidateTransition(experiment, activation, attemptedAt, expired) {
107
- const targetArm = activation.intent === "activate-candidate" ? "candidate" : "baseline";
108
- return {
109
- kind: "sealed-candidate",
110
- activation,
111
- candidateBundle: experiment.candidate,
112
- bundle: experiment[targetArm],
113
- targets: activation.targets.map((target) => ({
114
- ...target,
115
- desiredDigest: agentImprovementTargetDigest(experiment, targetArm, target.surface),
116
- desiredInput: agentImprovementTargetInput(experiment[targetArm], target.surface)
117
- })),
118
- attemptedAt,
119
- expired
120
- };
121
- }
122
- function profileImprovementTransition(experiment, activation, attemptedAt, expired) {
123
- const sourceArm = activation.intent === "activate-candidate" ? "baseline" : "candidate";
124
- const targetArm = activation.intent === "activate-candidate" ? "candidate" : "baseline";
125
- const operation = profileImprovementOperation(experiment, activation.intent);
126
- return {
127
- kind: "profile-improvement",
128
- activation,
129
- experiment,
130
- sourceStateDigest: agentProfileImprovementStateDigest(experiment, sourceArm),
131
- desiredStateDigest: agentProfileImprovementStateDigest(experiment, targetArm),
132
- operation,
133
- targets: activation.targets.map((target) => ({
134
- ...target,
135
- desiredDigest: agentProfileImprovementStateDigest(experiment, targetArm),
136
- desiredInput: operation
137
- })),
138
- attemptedAt,
139
- expired
140
- };
141
- }
142
- function profileImprovementOperation(experiment, intent) {
143
- return intent === "activate-candidate" ? {
144
- kind: "apply-change",
145
- changes: experiment.change
146
- } : { kind: "restore-state" };
147
- }
148
- function uncertainActivationResult(transition, code) {
149
- return createAgentImprovementActivationResult(transition, {
150
- completedAt: transition.attemptedAt,
151
- outcome: {
152
- status: "indeterminate",
153
- code,
154
- message: "The product transition did not return a trustworthy commit result."
155
- }
156
- });
157
- }
158
- function assertTransitionInput(activation, transition) {
159
- if (transition.kind === "sealed-candidate") {
160
- assertSealedCandidateTransitionInput(activation, transition);
161
- return;
162
- }
163
- assertProfileImprovementTransitionInput(activation, transition);
164
- }
165
- function assertSealedCandidateTransitionInput(activation, transition) {
166
- assertAuthorizedTransitionTargets(activation, transition.targets);
167
- const desiredInputsMatch = transition.targets.every((target) => canonicalCandidateDigest$1(target.desiredInput) === canonicalCandidateDigest$1(agentImprovementTargetInput(transition.bundle, target.surface)));
168
- if (transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) || transition.candidateBundle.digest !== activation.candidateDigest || !desiredInputsMatch || activation.intent === "activate-candidate" && transition.bundle.digest !== transition.candidateBundle.digest) throw new Error("activation transition does not match its authorization");
169
- }
170
- function assertProfileImprovementTransitionInput(activation, transition) {
171
- assertAuthorizedTransitionTargets(activation, transition.targets);
172
- const targetsAgentProfile = activation.targets.some((target) => target.surface === "agent-profile");
173
- const experiment = agentProfileImprovementExperimentSchema.parse(transition.experiment);
174
- const sourceArm = activation.intent === "activate-candidate" ? "baseline" : "candidate";
175
- const targetArm = activation.intent === "activate-candidate" ? "candidate" : "baseline";
176
- const sourceStateDigest = agentProfileImprovementStateDigest(experiment, sourceArm);
177
- const desiredStateDigest = agentProfileImprovementStateDigest(experiment, targetArm);
178
- const operation = profileImprovementOperation(experiment, activation.intent);
179
- const targetsMatch = transition.targets.every((target) => target.expectedBaseDigest === sourceStateDigest && target.desiredDigest === desiredStateDigest && canonicalCandidateDigest$1(target.desiredInput) === canonicalCandidateDigest$1(operation));
180
- if (transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) || experiment.digest !== activation.experimentDigest || experiment.candidate.stateDigest !== activation.candidateDigest || targetsAgentProfile && (activation.executionRef === void 0 || canonicalCandidateDigest$1(activation.executionRef) !== canonicalCandidateDigest$1(experiment.executionRef)) || transition.sourceStateDigest !== sourceStateDigest || transition.desiredStateDigest !== desiredStateDigest || canonicalCandidateDigest$1(transition.operation) !== canonicalCandidateDigest$1(operation) || !targetsMatch) throw new Error("activation transition does not match its authorization");
181
- }
182
- function assertAuthorizedTransitionTargets(activation, targets) {
183
- const authorized = targetMap(activation.targets);
184
- const planned = targetMap(targets);
185
- if (authorized.size !== planned.size || [...authorized.entries()].some(([identity, target]) => planned.get(identity)?.expectedBaseDigest !== target.expectedBaseDigest)) throw new Error("activation transition does not match its authorization");
186
- }
187
- function assertResultAgainstActivation(activation, result) {
188
- const attemptedAt = Date.parse(result.attemptedAt);
189
- const completedAt = Date.parse(result.completedAt);
190
- const expiresAt = Date.parse(activation.expiresAt);
191
- if (result.idempotencyKey !== activation.digest || attemptedAt < Date.parse(activation.authorizedAt) || completedAt < attemptedAt) throw new Error("activation result does not bind its authorization");
192
- const expired = attemptedAt >= expiresAt;
193
- if (result.outcome.status === "expired" && !expired || expired && ![
194
- "expired",
195
- "indeterminate",
196
- "already-applied"
197
- ].includes(result.outcome.status)) throw new Error("activation result does not honor its authorization expiry");
198
- if (!("targets" in result.outcome)) return;
199
- const authorized = targetMap(activation.targets);
200
- const observed = new Set(result.outcome.targets.map(targetIdentity));
201
- if (authorized.size !== observed.size || [...authorized.keys()].some((identity) => !observed.has(identity))) throw new Error("activation result must cover every authorized target exactly once");
202
- if (result.outcome.status === "applied" && result.outcome.targets.some((target) => target.beforeDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest)) throw new Error("applied activation did not start from its authorized base state");
203
- }
204
- function assertResultDesiredState(proposal, activation, result) {
205
- if (!("targets" in result.outcome)) return;
206
- const targetArm = activation.intent === "activate-candidate" ? "candidate" : "baseline";
207
- const desiredStateDigest = proposal.evaluation.kind === "agent-profile-improvement-measured-comparison" ? agentProfileImprovementStateDigest(proposal.evaluation.experiment, targetArm) : void 0;
208
- assertOutcomeDesiredState(activation, result, new Map(activation.targets.map((target) => [targetIdentity(target), desiredStateDigest ?? agentImprovementTargetDigest(requireSealedCandidateExperiment(proposal), targetArm, target.surface)])));
209
- }
210
- function assertOutcomeDesiredState(activation, result, desired) {
211
- if (!("targets" in result.outcome)) return;
212
- if (result.outcome.status === "applied") {
213
- if (result.outcome.targets.some((target) => target.afterDigest !== desired.get(targetIdentity(target)))) throw new Error("applied activation does not match the requested bundle");
214
- return;
215
- }
216
- const allDesired = result.outcome.targets.every((target) => target.currentDigest === desired.get(targetIdentity(target)));
217
- if (result.outcome.status === "already-applied") {
218
- if (!allDesired) throw new Error("already-applied activation is not at the requested state");
219
- return;
220
- }
221
- const authorized = targetMap(activation.targets);
222
- const hasStaleTarget = result.outcome.targets.some((target) => target.currentDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest);
223
- if (allDesired || !hasStaleTarget) throw new Error("activation conflict does not identify stale target state");
224
- }
225
- function targetMap(targets) {
226
- return new Map(targets.map((target) => [targetIdentity(target), target]));
227
- }
228
- function targetIdentity(target) {
229
- return `${target.surface}\u0000${target.identity}`;
230
- }
231
- //#endregion
232
- export { createRuntimeUsageTotals as a, addRuntimeUsage as i, executeAgentImprovementActivation as n, isUsageAmount as o, verifyAgentImprovementActivationResult as r, createAgentImprovementActivationResult as t };
233
-
234
- //# sourceMappingURL=activation-BDP6Eivv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"activation-BDP6Eivv.js","names":["canonicalCandidateDigest"],"sources":["../src/runtime-usage.ts","../src/intelligence/activation.ts"],"sourcesContent":["import type { RuntimeStreamEvent } from './types'\n\n/** Observed subtotals, with missing measurements kept separate from measured zeroes. */\nexport interface RuntimeUsageTotals {\n /** Observed input tokens across normalized per-call events. */\n tokensIn: number\n /** Observed output tokens across normalized per-call events. */\n tokensOut: number\n /** Observed dollar subtotal; incomplete when `usdKnown` is false. */\n costUsd: number\n /** Number of observed model calls, including unpriced or incompletely metered calls. */\n llmCalls: number\n /** False when any observed call has incomplete token usage. */\n tokensKnown?: false\n /** False when any observed call lacks complete provider-billed cost. */\n usdKnown?: false\n /** Sum of reported external estimates; never included in `costUsd` or proof of complete cost. */\n estimatedCostUsd?: number\n}\n\nexport function createRuntimeUsageTotals(): RuntimeUsageTotals {\n return { tokensIn: 0, tokensOut: 0, costUsd: 0, llmCalls: 0 }\n}\n\nexport function isUsageAmount(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value) && value >= 0\n}\n\n/** Fold normalized per-call events. Backend adapters own cumulative receipt reconciliation. */\nexport function addRuntimeUsage(\n totals: RuntimeUsageTotals,\n event: Extract<RuntimeStreamEvent, { type: 'llm_call' }>,\n): void {\n totals.llmCalls += 1\n for (const key of ['tokensIn', 'tokensOut', 'costUsd'] as const) {\n const value = event[key]\n if (isUsageAmount(value)) totals[key] += value\n else if (key === 'costUsd') totals.usdKnown = false\n else totals.tokensKnown = false\n }\n if (event.tokensKnown === false) totals.tokensKnown = false\n if (event.usdKnown === false) totals.usdKnown = false\n if (isUsageAmount(event.estimatedCostUsd)) {\n totals.estimatedCostUsd = (totals.estimatedCostUsd ?? 0) + event.estimatedCostUsd\n }\n}\n","import type {\n AgentCandidateBundle,\n AgentCandidateExperiment,\n AgentImprovementActivation,\n AgentImprovementActivationOutcome,\n AgentImprovementActivationResult,\n AgentImprovementActivationTarget,\n AgentImprovementProposal,\n AgentImprovementReview,\n AgentImprovementSurface,\n AgentProfileImprovementChange,\n AgentProfileImprovementExperiment,\n Sha256Digest,\n} from '@tangle-network/agent-interface'\nimport {\n agentImprovementActivationResultSchema,\n agentImprovementActivationSchema,\n agentProfileImprovementExperimentSchema,\n} from '@tangle-network/agent-interface'\n\nimport {\n canonicalCandidateDigest,\n canonicalCandidateDocument,\n immutableCandidateValue,\n verifyCanonicalCandidateDocument,\n} from '../candidate-execution/digest'\nimport {\n requireSealedCandidateExperiment,\n verifyAgentImprovementActivation,\n verifyAgentImprovementProposal,\n} from './improvement-cycle'\nimport {\n agentImprovementTargetDigest,\n agentImprovementTargetInput,\n agentProfileImprovementStateDigest,\n} from './improvement-surfaces'\n\nexport interface CreateAgentImprovementActivationResultOptions {\n completedAt: string\n outcome: AgentImprovementActivationOutcome\n}\n\nexport interface AgentImprovementActivationTargetPlan extends AgentImprovementActivationTarget {\n desiredDigest: Sha256Digest\n /**\n * Exact measured input the product must apply to reach `desiredDigest`.\n * Transition surfaces such as code and knowledge are applied operations, so\n * their resulting state digest is not the digest of this input document.\n */\n desiredInput: unknown\n}\n\nexport type AgentProfileImprovementActivationOperation =\n | {\n kind: 'apply-change'\n changes: AgentProfileImprovementChange\n }\n | {\n /** The product must load its own saved state at `desiredStateDigest`. */\n kind: 'restore-state'\n }\n\nexport interface AgentProfileImprovementActivationTargetPlan\n extends AgentImprovementActivationTarget {\n desiredDigest: Sha256Digest\n desiredInput: AgentProfileImprovementActivationOperation\n}\n\nexport interface SealedCandidateActivationTransitionInput {\n kind: 'sealed-candidate'\n activation: AgentImprovementActivation\n candidateBundle: AgentCandidateBundle\n bundle: AgentCandidateBundle\n targets: [AgentImprovementActivationTargetPlan, ...AgentImprovementActivationTargetPlan[]]\n attemptedAt: string\n expired: boolean\n}\n\n/**\n * A measured profile change without raw profile bytes.\n * The product owns the private state lookup and atomic write.\n */\nexport interface ProfileImprovementActivationTransitionInput {\n kind: 'profile-improvement'\n activation: AgentImprovementActivation\n experiment: AgentProfileImprovementExperiment\n sourceStateDigest: Sha256Digest\n desiredStateDigest: Sha256Digest\n operation: AgentProfileImprovementActivationOperation\n targets: [\n AgentProfileImprovementActivationTargetPlan,\n ...AgentProfileImprovementActivationTargetPlan[],\n ]\n attemptedAt: string\n expired: boolean\n}\n\nexport type AgentImprovementActivationTransitionInput =\n | SealedCandidateActivationTransitionInput\n | ProfileImprovementActivationTransitionInput\n\nexport interface AgentImprovementActivationResultStore {\n load(idempotencyKey: Sha256Digest): Promise<unknown | undefined>\n putIfAbsent(result: AgentImprovementActivationResult): Promise<unknown>\n}\n\n/**\n * Product-owned or Runtime-composed transition.\n *\n * Implementations resolve a stored result for `activation.digest`, compare\n * every target, and make the write durably idempotent. Co-located targets store\n * the all-or-none write with its result. Other targets throw when result\n * storage fails so a retry can reconcile it. Runtime never invokes this write\n * function after authorization expires.\n */\nexport type AgentImprovementActivationTransition = (\n input: AgentImprovementActivationTransitionInput,\n) => Promise<unknown>\n\n/**\n * Target-read-only check for a prior exact write.\n * It may persist recovered result metadata, but must not change an activation target.\n * Return undefined only when no target write can have committed.\n */\nexport type AgentImprovementActivationReconciliation = (\n input: AgentImprovementActivationTransitionInput,\n) => Promise<unknown | undefined>\n\nexport interface ExecuteAgentImprovementActivationInput {\n proposal: AgentImprovementProposal\n review: AgentImprovementReview\n activation: AgentImprovementActivation\n}\n\nexport interface ExecuteAgentImprovementActivationOptions {\n transition: AgentImprovementActivationTransition\n reconcile?: AgentImprovementActivationReconciliation\n now?: () => Date\n}\n\n/** Create the exact result a product stores in the same transaction as its target write. */\nexport function createAgentImprovementActivationResult(\n transition: AgentImprovementActivationTransitionInput,\n options: CreateAgentImprovementActivationResultOptions,\n): AgentImprovementActivationResult {\n const activation = verifyCanonicalCandidateDocument(\n agentImprovementActivationSchema.parse(transition.activation),\n 'agent improvement activation',\n )\n assertTransitionInput(activation, transition)\n const result = agentImprovementActivationResultSchema.parse(\n canonicalCandidateDocument<AgentImprovementActivationResult>({\n kind: 'agent-improvement-activation-result',\n idempotencyKey: activation.digest,\n attemptedAt: transition.attemptedAt,\n completedAt: options.completedAt,\n outcome: options.outcome,\n }).value,\n )\n assertResultAgainstActivation(activation, result)\n assertOutcomeDesiredState(\n activation,\n result,\n new Map(transition.targets.map((target) => [targetIdentity(target), target.desiredDigest])),\n )\n return immutableCandidateValue(result)\n}\n\n/**\n * Recompute one historical activation result against the exact measured proposal and authority.\n * The result records that attempt; it is not a query of the target's current state.\n */\nexport function verifyAgentImprovementActivationResult(input: {\n proposal: unknown\n review: unknown\n activation: unknown\n result: unknown\n}): AgentImprovementActivationResult {\n const proposal = verifyAgentImprovementProposal(input.proposal)\n const activation = verifyAgentImprovementActivation(input)\n const result = verifyCanonicalCandidateDocument(\n agentImprovementActivationResultSchema.parse(input.result),\n 'agent improvement activation result',\n )\n assertResultAgainstActivation(activation, result)\n assertResultDesiredState(proposal, activation, result)\n return result\n}\n\n/** Validate and execute one product-owned activation transition. */\nexport async function executeAgentImprovementActivation(\n input: ExecuteAgentImprovementActivationInput,\n options: ExecuteAgentImprovementActivationOptions,\n): Promise<AgentImprovementActivationResult> {\n const proposal = verifyAgentImprovementProposal(input.proposal)\n const activation = verifyAgentImprovementActivation(input)\n const observedAt = (options.now ?? (() => new Date()))().toISOString()\n const attemptedAt =\n Date.parse(observedAt) < Date.parse(activation.authorizedAt)\n ? activation.authorizedAt\n : observedAt\n const expired = Date.parse(attemptedAt) >= Date.parse(activation.expiresAt)\n const transition = immutableCandidateValue<AgentImprovementActivationTransitionInput>(\n proposal.evaluation.kind === 'agent-improvement-measured-comparison'\n ? sealedCandidateTransition(proposal.evaluation.experiment, activation, attemptedAt, expired)\n : profileImprovementTransition(\n proposal.evaluation.experiment,\n activation,\n attemptedAt,\n expired,\n ),\n )\n\n if (transition.expired) {\n if (!options.reconcile) {\n return uncertainActivationResult(transition, 'RECONCILIATION_UNAVAILABLE')\n }\n let reconciled: unknown\n try {\n reconciled = await options.reconcile(transition)\n } catch {\n return uncertainActivationResult(transition, 'RECONCILIATION_THROW')\n }\n if (reconciled === undefined) {\n return createAgentImprovementActivationResult(transition, {\n completedAt: transition.attemptedAt,\n outcome: { status: 'expired' },\n })\n }\n try {\n return verifyAgentImprovementActivationResult({ ...input, result: reconciled })\n } catch {\n return uncertainActivationResult(transition, 'INVALID_RECONCILIATION')\n }\n }\n\n let rawResult: unknown\n try {\n rawResult = await options.transition(transition)\n } catch {\n return uncertainActivationResult(transition, 'TRANSITION_THROW')\n }\n try {\n return verifyAgentImprovementActivationResult({ ...input, result: rawResult })\n } catch {\n return uncertainActivationResult(transition, 'INVALID_RESULT')\n }\n}\n\nfunction sealedCandidateTransition(\n experiment: AgentCandidateExperiment,\n activation: AgentImprovementActivation,\n attemptedAt: string,\n expired: boolean,\n): SealedCandidateActivationTransitionInput {\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n return {\n kind: 'sealed-candidate',\n activation,\n candidateBundle: experiment.candidate,\n bundle: experiment[targetArm],\n targets: activation.targets.map((target) => ({\n ...target,\n desiredDigest: agentImprovementTargetDigest(experiment, targetArm, target.surface),\n desiredInput: agentImprovementTargetInput(experiment[targetArm], target.surface),\n })) as SealedCandidateActivationTransitionInput['targets'],\n attemptedAt,\n expired,\n }\n}\n\nfunction profileImprovementTransition(\n experiment: AgentProfileImprovementExperiment,\n activation: AgentImprovementActivation,\n attemptedAt: string,\n expired: boolean,\n): ProfileImprovementActivationTransitionInput {\n const sourceArm = activation.intent === 'activate-candidate' ? 'baseline' : 'candidate'\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const operation = profileImprovementOperation(experiment, activation.intent)\n return {\n kind: 'profile-improvement',\n activation,\n experiment,\n sourceStateDigest: agentProfileImprovementStateDigest(experiment, sourceArm),\n desiredStateDigest: agentProfileImprovementStateDigest(experiment, targetArm),\n operation,\n targets: activation.targets.map((target) => ({\n ...target,\n desiredDigest: agentProfileImprovementStateDigest(experiment, targetArm),\n desiredInput: operation,\n })) as ProfileImprovementActivationTransitionInput['targets'],\n attemptedAt,\n expired,\n }\n}\n\nfunction profileImprovementOperation(\n experiment: AgentProfileImprovementExperiment,\n intent: AgentImprovementActivation['intent'],\n): AgentProfileImprovementActivationOperation {\n return intent === 'activate-candidate'\n ? { kind: 'apply-change', changes: experiment.change }\n : { kind: 'restore-state' }\n}\n\nfunction uncertainActivationResult(\n transition: AgentImprovementActivationTransitionInput,\n code: string,\n): AgentImprovementActivationResult {\n return createAgentImprovementActivationResult(transition, {\n completedAt: transition.attemptedAt,\n outcome: {\n status: 'indeterminate',\n code,\n message: 'The product transition did not return a trustworthy commit result.',\n },\n })\n}\n\nfunction assertTransitionInput(\n activation: AgentImprovementActivation,\n transition: AgentImprovementActivationTransitionInput,\n): void {\n if (transition.kind === 'sealed-candidate') {\n assertSealedCandidateTransitionInput(activation, transition)\n return\n }\n assertProfileImprovementTransitionInput(activation, transition)\n}\n\nfunction assertSealedCandidateTransitionInput(\n activation: AgentImprovementActivation,\n transition: SealedCandidateActivationTransitionInput,\n): void {\n assertAuthorizedTransitionTargets(activation, transition.targets)\n const desiredInputsMatch = transition.targets.every(\n (target) =>\n canonicalCandidateDigest(target.desiredInput) ===\n canonicalCandidateDigest(agentImprovementTargetInput(transition.bundle, target.surface)),\n )\n if (\n transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) ||\n transition.candidateBundle.digest !== activation.candidateDigest ||\n !desiredInputsMatch ||\n (activation.intent === 'activate-candidate' &&\n transition.bundle.digest !== transition.candidateBundle.digest)\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertProfileImprovementTransitionInput(\n activation: AgentImprovementActivation,\n transition: ProfileImprovementActivationTransitionInput,\n): void {\n assertAuthorizedTransitionTargets(activation, transition.targets)\n const targetsAgentProfile = activation.targets.some(\n (target) => target.surface === 'agent-profile',\n )\n const experiment = agentProfileImprovementExperimentSchema.parse(transition.experiment)\n const sourceArm = activation.intent === 'activate-candidate' ? 'baseline' : 'candidate'\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const sourceStateDigest = agentProfileImprovementStateDigest(experiment, sourceArm)\n const desiredStateDigest = agentProfileImprovementStateDigest(experiment, targetArm)\n const operation = profileImprovementOperation(experiment, activation.intent)\n const targetsMatch = transition.targets.every(\n (target) =>\n target.expectedBaseDigest === sourceStateDigest &&\n target.desiredDigest === desiredStateDigest &&\n canonicalCandidateDigest(target.desiredInput) === canonicalCandidateDigest(operation),\n )\n if (\n transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) ||\n experiment.digest !== activation.experimentDigest ||\n experiment.candidate.stateDigest !== activation.candidateDigest ||\n (targetsAgentProfile &&\n (activation.executionRef === undefined ||\n canonicalCandidateDigest(activation.executionRef) !==\n canonicalCandidateDigest(experiment.executionRef))) ||\n transition.sourceStateDigest !== sourceStateDigest ||\n transition.desiredStateDigest !== desiredStateDigest ||\n canonicalCandidateDigest(transition.operation) !== canonicalCandidateDigest(operation) ||\n !targetsMatch\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertAuthorizedTransitionTargets(\n activation: AgentImprovementActivation,\n targets: readonly AgentImprovementActivationTargetPlan[],\n): void {\n const authorized = targetMap(activation.targets)\n const planned = targetMap(targets)\n if (\n authorized.size !== planned.size ||\n [...authorized.entries()].some(\n ([identity, target]) =>\n planned.get(identity)?.expectedBaseDigest !== target.expectedBaseDigest,\n )\n ) {\n throw new Error('activation transition does not match its authorization')\n }\n}\n\nfunction assertResultAgainstActivation(\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n): void {\n const attemptedAt = Date.parse(result.attemptedAt)\n const completedAt = Date.parse(result.completedAt)\n const expiresAt = Date.parse(activation.expiresAt)\n if (\n result.idempotencyKey !== activation.digest ||\n attemptedAt < Date.parse(activation.authorizedAt) ||\n completedAt < attemptedAt\n ) {\n throw new Error('activation result does not bind its authorization')\n }\n const expired = attemptedAt >= expiresAt\n if (\n (result.outcome.status === 'expired' && !expired) ||\n (expired && !['expired', 'indeterminate', 'already-applied'].includes(result.outcome.status))\n ) {\n throw new Error('activation result does not honor its authorization expiry')\n }\n if (!('targets' in result.outcome)) return\n const authorized = targetMap(activation.targets)\n const observed = new Set(result.outcome.targets.map(targetIdentity))\n if (\n authorized.size !== observed.size ||\n [...authorized.keys()].some((identity) => !observed.has(identity))\n ) {\n throw new Error('activation result must cover every authorized target exactly once')\n }\n if (\n result.outcome.status === 'applied' &&\n result.outcome.targets.some(\n (target) =>\n target.beforeDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest,\n )\n ) {\n throw new Error('applied activation did not start from its authorized base state')\n }\n}\n\nfunction assertResultDesiredState(\n proposal: AgentImprovementProposal,\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n): void {\n if (!('targets' in result.outcome)) return\n const targetArm = activation.intent === 'activate-candidate' ? 'candidate' : 'baseline'\n const desiredStateDigest =\n proposal.evaluation.kind === 'agent-profile-improvement-measured-comparison'\n ? agentProfileImprovementStateDigest(proposal.evaluation.experiment, targetArm)\n : undefined\n const desired = new Map(\n activation.targets.map((target) => [\n targetIdentity(target),\n desiredStateDigest ??\n agentImprovementTargetDigest(\n requireSealedCandidateExperiment(proposal),\n targetArm,\n target.surface,\n ),\n ]),\n )\n assertOutcomeDesiredState(activation, result, desired)\n}\n\nfunction assertOutcomeDesiredState(\n activation: AgentImprovementActivation,\n result: AgentImprovementActivationResult,\n desired: ReadonlyMap<string, Sha256Digest>,\n): void {\n if (!('targets' in result.outcome)) return\n if (result.outcome.status === 'applied') {\n if (\n result.outcome.targets.some(\n (target) => target.afterDigest !== desired.get(targetIdentity(target)),\n )\n ) {\n throw new Error('applied activation does not match the requested bundle')\n }\n return\n }\n const allDesired = result.outcome.targets.every(\n (target) => target.currentDigest === desired.get(targetIdentity(target)),\n )\n if (result.outcome.status === 'already-applied') {\n if (!allDesired) throw new Error('already-applied activation is not at the requested state')\n return\n }\n const authorized = targetMap(activation.targets)\n const hasStaleTarget = result.outcome.targets.some(\n (target) => target.currentDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest,\n )\n if (allDesired || !hasStaleTarget) {\n throw new Error('activation conflict does not identify stale target state')\n }\n}\n\nfunction targetMap<T extends { surface: AgentImprovementSurface; identity: string }>(\n targets: readonly T[],\n): Map<string, T> {\n return new Map(targets.map((target) => [targetIdentity(target), target]))\n}\n\nfunction targetIdentity(target: { surface: AgentImprovementSurface; identity: string }): string {\n return `${target.surface}\\u0000${target.identity}`\n}\n"],"mappings":";;;;AAoBA,SAAgB,2BAA+C;CAC7D,OAAO;EAAE,UAAU;EAAG,WAAW;EAAG,SAAS;EAAG,UAAU;CAAE;AAC9D;AAEA,SAAgB,cAAc,OAAiC;CAC7D,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,SAAS;AACzE;;AAGA,SAAgB,gBACd,QACA,OACM;CACN,OAAO,YAAY;CACnB,KAAK,MAAM,OAAO;EAAC;EAAY;EAAa;CAAS,GAAY;EAC/D,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