@tangle-network/agent-runtime 0.104.0 → 0.106.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/README.md +176 -42
- package/dist/activation-CRjVfOiy.js +203 -0
- package/dist/activation-CRjVfOiy.js.map +1 -0
- package/dist/activation-DyWB0K6E.d.ts +98 -0
- package/dist/agent.d.ts +216 -234
- package/dist/agent.js +615 -547
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop-DGdtVENg.js +517 -0
- package/dist/analyst-loop-DGdtVENg.js.map +1 -0
- package/dist/analyst-loop.d.ts +10 -43
- package/dist/analyst-loop.js +2 -11
- package/dist/backends-Dy8NujB4.js +713 -0
- package/dist/backends-Dy8NujB4.js.map +1 -0
- package/dist/candidate-execution/index.d.ts +4 -192
- package/dist/candidate-execution/index.js +5 -66
- package/dist/candidate-execution-DqMbv1rU.js +488 -0
- package/dist/candidate-execution-DqMbv1rU.js.map +1 -0
- package/dist/coder-yhVWbdWc.js +40 -0
- package/dist/coder-yhVWbdWc.js.map +1 -0
- package/dist/conversation-XucG_K3l.js +1265 -0
- package/dist/conversation-XucG_K3l.js.map +1 -0
- package/dist/conversation.d.ts +2 -804
- package/dist/conversation.js +2 -55
- package/dist/environment-provider-CfLUmKmf.js +1168 -0
- package/dist/environment-provider-CfLUmKmf.js.map +1 -0
- package/dist/environment-provider-IUGU3epE.d.ts +964 -0
- package/dist/environment-provider.d.ts +2 -78
- package/dist/environment-provider.js +2 -18
- package/dist/errors-DEAvWQPy.js +111 -0
- package/dist/errors-DEAvWQPy.js.map +1 -0
- package/dist/improvement-adapter-Cr5TBSji.d.ts +166 -0
- package/dist/improvement-cycle-C095kS_g.js +2624 -0
- package/dist/improvement-cycle-C095kS_g.js.map +1 -0
- package/dist/index-BGdxAwfO.d.ts +838 -0
- package/dist/index-C-FYUuFG.d.ts +193 -0
- package/dist/index-CbNM40xG.d.ts +140 -0
- package/dist/index-DruSKs3Z.d.ts +7224 -0
- package/dist/index-Efjb3nrQ.d.ts +671 -0
- package/dist/index.d.ts +14 -1134
- package/dist/index.js +2134 -1972
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +776 -888
- package/dist/intelligence.js +1466 -1410
- package/dist/intelligence.js.map +1 -1
- package/dist/{kb-gate-CwHO0vz6.d.ts → kb-gate-C8z2juK8.d.ts} +33 -31
- package/dist/kb-gate-DpaSwXVx.js +80 -0
- package/dist/kb-gate-DpaSwXVx.js.map +1 -0
- package/dist/knowledge-Ku-mPP4f.js +433 -0
- package/dist/knowledge-Ku-mPP4f.js.map +1 -0
- package/dist/knowledge.d.ts +2 -150
- package/dist/knowledge.js +2 -40
- package/dist/local-harness-Dh8PJ0ot.d.ts +455 -0
- package/dist/loop-runner-bin-BXsFEUcf.d.ts +162 -0
- package/dist/loop-runner-bin-BwjQ1NfH.js +268 -0
- package/dist/loop-runner-bin-BwjQ1NfH.js.map +1 -0
- package/dist/loop-runner-bin.d.ts +2 -17
- package/dist/loop-runner-bin.js +2 -24
- package/dist/loops.d.ts +5 -4164
- package/dist/loops.js +8 -419
- package/dist/mcp/bin.d.ts +1 -1
- package/dist/mcp/bin.js +116 -146
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +295 -437
- package/dist/mcp/index.js +1242 -1177
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.d.ts +1 -1
- package/dist/mcp/memory-bin.js +37 -16
- package/dist/mcp/memory-bin.js.map +1 -1
- package/dist/memory-server-DL6cE2Ag.js +234 -0
- package/dist/memory-server-DL6cE2Ag.js.map +1 -0
- package/dist/model-resolution-Btd9iIKV.js +98 -0
- package/dist/model-resolution-Btd9iIKV.js.map +1 -0
- package/dist/openai-tools-B68JaOCx.d.ts +24 -0
- package/dist/openai-tools-CKLy1C7M.js +44 -0
- package/dist/openai-tools-CKLy1C7M.js.map +1 -0
- package/dist/otel-export-D34IQW1C.js +843 -0
- package/dist/otel-export-D34IQW1C.js.map +1 -0
- package/dist/platform.d.ts +188 -185
- package/dist/platform.js +185 -218
- package/dist/platform.js.map +1 -1
- package/dist/prepare-B53sPV7M.js +4292 -0
- package/dist/prepare-B53sPV7M.js.map +1 -0
- package/dist/primeintellect/index.d.ts +150 -147
- package/dist/primeintellect/index.js +626 -1004
- package/dist/primeintellect/index.js.map +1 -1
- package/dist/profiles.d.ts +296 -490
- package/dist/profiles.js +722 -749
- package/dist/profiles.js.map +1 -1
- package/dist/protected-model-port-BLPH5VVv.js +722 -0
- package/dist/protected-model-port-BLPH5VVv.js.map +1 -0
- package/dist/protected-model-port-BP6Z4eau.d.ts +283 -0
- package/dist/protected-redaction--F3v1oo8.js +200 -0
- package/dist/protected-redaction--F3v1oo8.js.map +1 -0
- package/dist/redact-D-u-rrcn.js +82 -0
- package/dist/redact-D-u-rrcn.js.map +1 -0
- package/dist/redact-kbIOjfjM.d.ts +452 -0
- package/dist/researcher-CoVqNhfI.js +433 -0
- package/dist/researcher-CoVqNhfI.js.map +1 -0
- package/dist/runtime-BG0BziaP.js +5408 -0
- package/dist/runtime-BG0BziaP.js.map +1 -0
- package/dist/sandbox-events-DeI5xX8P.js +316 -0
- package/dist/sandbox-events-DeI5xX8P.js.map +1 -0
- package/dist/spawn-journal-CwPvKUTa.js +456 -0
- package/dist/spawn-journal-CwPvKUTa.js.map +1 -0
- package/dist/structural-rollout-IXUEplky.js +1445 -0
- package/dist/structural-rollout-IXUEplky.js.map +1 -0
- package/dist/substrate-B0TYNrXn.js +27 -0
- package/dist/substrate-B0TYNrXn.js.map +1 -0
- package/dist/{substrate-Dyiqmd3o.d.ts → substrate-BcnuSHXm.d.ts} +57 -54
- package/dist/supervise-BiRutHS9.js +7321 -0
- package/dist/supervise-BiRutHS9.js.map +1 -0
- package/dist/supervisor-DTKhF-RV.js +3826 -0
- package/dist/supervisor-DTKhF-RV.js.map +1 -0
- package/dist/testing.d.ts +4 -3
- package/dist/testing.js +2478 -2637
- package/dist/testing.js.map +1 -1
- package/dist/tool-server-RcWgLIsL.js +141 -0
- package/dist/tool-server-RcWgLIsL.js.map +1 -0
- package/dist/trace-propagation-CJJC7SVB.js +57 -0
- package/dist/trace-propagation-CJJC7SVB.js.map +1 -0
- package/dist/types-BaIpb0XT.d.ts +492 -0
- package/dist/types-BevOjfTY.d.ts +765 -0
- package/dist/types-C9j4qg6l.d.ts +500 -0
- package/dist/types-Cja5OTGh.d.ts +190 -0
- package/dist/util-MVgdwuIS.js +145 -0
- package/dist/util-MVgdwuIS.js.map +1 -0
- package/dist/workspace-archive-BosQiotA.js +575 -0
- package/dist/workspace-archive-BosQiotA.js.map +1 -0
- package/package.json +43 -55
- package/skills/build-with-agent-runtime/SKILL.md +16 -9
- package/skills/loop-writer/SKILL.md +1 -1
- package/dist/activation-Cm-9MMX1.d.ts +0 -69
- package/dist/analyst-loop.js.map +0 -1
- package/dist/backends-BO4Jqoe2.d.ts +0 -134
- package/dist/candidate-execution/index.js.map +0 -1
- package/dist/chunk-2KGAN2HM.js +0 -1256
- package/dist/chunk-2KGAN2HM.js.map +0 -1
- package/dist/chunk-2QJSNOGK.js +0 -48
- package/dist/chunk-2QJSNOGK.js.map +0 -1
- package/dist/chunk-2UABGGUB.js +0 -474
- package/dist/chunk-2UABGGUB.js.map +0 -1
- package/dist/chunk-2VZYRB55.js +0 -834
- package/dist/chunk-2VZYRB55.js.map +0 -1
- package/dist/chunk-2X65HYMI.js +0 -3526
- package/dist/chunk-2X65HYMI.js.map +0 -1
- package/dist/chunk-3MDZX7YU.js +0 -125
- package/dist/chunk-3MDZX7YU.js.map +0 -1
- package/dist/chunk-3PPVCS75.js +0 -199
- package/dist/chunk-3PPVCS75.js.map +0 -1
- package/dist/chunk-5HNDYWUT.js +0 -6424
- package/dist/chunk-5HNDYWUT.js.map +0 -1
- package/dist/chunk-5IBQAPVB.js +0 -29
- package/dist/chunk-5IBQAPVB.js.map +0 -1
- package/dist/chunk-5QOB7H74.js +0 -387
- package/dist/chunk-5QOB7H74.js.map +0 -1
- package/dist/chunk-ATDFUJYI.js +0 -4728
- package/dist/chunk-ATDFUJYI.js.map +0 -1
- package/dist/chunk-B7K7V22Y.js +0 -699
- package/dist/chunk-B7K7V22Y.js.map +0 -1
- package/dist/chunk-DPEUKJRO.js +0 -27
- package/dist/chunk-DPEUKJRO.js.map +0 -1
- package/dist/chunk-FD2MBMOH.js +0 -494
- package/dist/chunk-FD2MBMOH.js.map +0 -1
- package/dist/chunk-FJI3EXU3.js +0 -2402
- package/dist/chunk-FJI3EXU3.js.map +0 -1
- package/dist/chunk-HAO4CXHP.js +0 -200
- package/dist/chunk-HAO4CXHP.js.map +0 -1
- package/dist/chunk-ISPWRSEC.js +0 -408
- package/dist/chunk-ISPWRSEC.js.map +0 -1
- package/dist/chunk-KRBFHMV6.js +0 -1228
- package/dist/chunk-KRBFHMV6.js.map +0 -1
- package/dist/chunk-L5DST3QC.js +0 -351
- package/dist/chunk-L5DST3QC.js.map +0 -1
- package/dist/chunk-M22PL4GH.js +0 -171
- package/dist/chunk-M22PL4GH.js.map +0 -1
- package/dist/chunk-NURIQBJQ.js +0 -72
- package/dist/chunk-NURIQBJQ.js.map +0 -1
- package/dist/chunk-PZZKQVQV.js +0 -52
- package/dist/chunk-PZZKQVQV.js.map +0 -1
- package/dist/chunk-Q2JSAVQ3.js +0 -671
- package/dist/chunk-Q2JSAVQ3.js.map +0 -1
- package/dist/chunk-SBTWKPVR.js +0 -5576
- package/dist/chunk-SBTWKPVR.js.map +0 -1
- package/dist/chunk-SGKPNBXE.js +0 -60
- package/dist/chunk-SGKPNBXE.js.map +0 -1
- package/dist/chunk-SNSMRT6H.js +0 -680
- package/dist/chunk-SNSMRT6H.js.map +0 -1
- package/dist/chunk-STJEHM5F.js +0 -1338
- package/dist/chunk-STJEHM5F.js.map +0 -1
- package/dist/chunk-UPWGXKXB.js +0 -254
- package/dist/chunk-UPWGXKXB.js.map +0 -1
- package/dist/chunk-YEJR7IXO.js +0 -68
- package/dist/chunk-YEJR7IXO.js.map +0 -1
- package/dist/chunk-ZXICDSAK.js +0 -907
- package/dist/chunk-ZXICDSAK.js.map +0 -1
- package/dist/completion-gate-Bv47cOnn.d.ts +0 -256
- package/dist/conversation.js.map +0 -1
- package/dist/coordination-CxtzMxSM.d.ts +0 -2570
- package/dist/environment-provider.js.map +0 -1
- package/dist/improve--2A0gK1-.d.ts +0 -440
- package/dist/improvement-adapter-HAZz-7vK.d.ts +0 -203
- package/dist/knowledge.js.map +0 -1
- package/dist/local-harness-CtK9dSny.d.ts +0 -175
- package/dist/loop-runner-bin-DUOGtvOl.d.ts +0 -207
- package/dist/loop-runner-bin.js.map +0 -1
- package/dist/loops.js.map +0 -1
- package/dist/openai-tools-fnj6SRVg.d.ts +0 -46
- package/dist/protected-model-port-DzkUY3HQ.d.ts +0 -271
- package/dist/sanitize-DEbPNtyI.d.ts +0 -328
- package/dist/structural-rollout-C4mabf87.d.ts +0 -446
- package/dist/supervise-7q9F5brx.d.ts +0 -379
- package/dist/types-BCoemcXU.d.ts +0 -802
- package/dist/types-BwoZWq-i.d.ts +0 -510
- package/dist/types-Cbp72qyu.d.ts +0 -491
- package/dist/types-CmYCMbFT.d.ts +0 -203
- package/dist/types-CvNwMzQt.d.ts +0 -957
- package/dist/worktree-fanout-WsOzt8qu.d.ts +0 -999
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @tangle-network/agent-runtime
|
|
2
2
|
|
|
3
|
-
A TypeScript runtime for
|
|
3
|
+
A TypeScript runtime for chat agents, one-shot tasks, and agent teams.
|
|
4
|
+
It records each run so you can measure changes against real pass/fail checks and improve the agent without changing your product integration.
|
|
4
5
|
|
|
5
6
|
Domain behavior (models, tools, knowledge) plugs in as adapters; the scoring statistics and the ship decision come from [`@tangle-network/agent-eval`](https://www.npmjs.com/package/@tangle-network/agent-eval); sandboxed execution from [`@tangle-network/sandbox`](https://www.npmjs.com/package/@tangle-network/sandbox).
|
|
6
7
|
|
|
@@ -24,12 +25,15 @@ pnpm add @tangle-network/agent-runtime @tangle-network/agent-eval @tangle-networ
|
|
|
24
25
|
|
|
25
26
|
## Quickstart (offline, no API keys)
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
A driver runs a worker, reads its output, and writes the next prompt until a check passes.
|
|
29
|
+
This excerpt shows the driver from the runnable [`examples/quickstart/quickstart.ts`](./examples/quickstart/quickstart.ts).
|
|
30
|
+
That file defines the scripted `worker`, `output`, and `validator` used below so it runs without credentials.
|
|
31
|
+
Replace the scripted worker with a sandbox, CLI bridge, or router backend without changing the driver.
|
|
28
32
|
|
|
29
33
|
```ts
|
|
30
|
-
import { inProcessSandboxClient,
|
|
34
|
+
import { inProcessSandboxClient, runAgentRounds } from '@tangle-network/agent-runtime/loops'
|
|
31
35
|
|
|
32
|
-
const result = await
|
|
36
|
+
const result = await runAgentRounds<Task, Note, 'refine' | 'pick-winner' | 'fail'>({
|
|
33
37
|
task: { prompt: 'Write a one-line release note for one-click restore.' },
|
|
34
38
|
driver: {
|
|
35
39
|
name: 'refine',
|
|
@@ -56,12 +60,12 @@ Run it from a clone of this repo and you get exactly this:
|
|
|
56
60
|
```bash
|
|
57
61
|
$ pnpm i && pnpm build
|
|
58
62
|
$ pnpm tsx examples/quickstart/quickstart.ts
|
|
59
|
-
shot 0: reject
|
|
60
|
-
shot 1: PASS
|
|
61
|
-
decision: pick-winner
|
|
63
|
+
shot 0: reject: "Shipped one-click restore."
|
|
64
|
+
shot 1: PASS: "Shipped one-click restore with an instant rollback path."
|
|
65
|
+
decision: pick-winner: winner: shot 1
|
|
62
66
|
```
|
|
63
67
|
|
|
64
|
-
The
|
|
68
|
+
The annotated version is [`examples/driver-loop`](./examples/driver-loop).
|
|
65
69
|
|
|
66
70
|
## What you do with it
|
|
67
71
|
|
|
@@ -69,7 +73,7 @@ The fully annotated version of this loop, with every seam explained, is [`exampl
|
|
|
69
73
|
|---|---|
|
|
70
74
|
| Run a **chat turn** for a production product agent | `handleChatTurn(...)` |
|
|
71
75
|
| Have one agent **supervise a team of agents** toward a goal | `supervise(profile, task, opts)` |
|
|
72
|
-
| **Improve** an agent and prove the gain on fresh tasks | `improve(profile,
|
|
76
|
+
| **Improve** an agent and prove the gain on fresh tasks | `improve(profile, opts)` |
|
|
73
77
|
| Produce a measured knowledge-base candidate with agents and checks | `runKnowledgeImprovementJob(...)` |
|
|
74
78
|
| Evaluate or train the same agent on **PrimeIntellect** | `createPrimeIntellectPackage(...)` |
|
|
75
79
|
|
|
@@ -107,38 +111,150 @@ const result = await supervise(
|
|
|
107
111
|
|
|
108
112
|
### Improve an agent
|
|
109
113
|
|
|
110
|
-
`improve`
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
`improve` runs one complete `OptimizationMethod` against one profile field.
|
|
115
|
+
The method owns candidate generation and selection.
|
|
116
|
+
Runtime keeps the final test set out of the method, scores the baseline and selected candidate on it, and returns `ship` only when the paired confidence interval clears `minimumLift`.
|
|
117
|
+
The profile is never changed.
|
|
114
118
|
|
|
115
119
|
```ts
|
|
116
|
-
import { improve } from '@tangle-network/agent-runtime'
|
|
120
|
+
import { improve, officialGepa } from '@tangle-network/agent-runtime'
|
|
121
|
+
import { canonicalCandidateDigest } from '@tangle-network/agent-interface'
|
|
117
122
|
|
|
118
|
-
const
|
|
123
|
+
const executionRef = canonicalCandidateDigest({
|
|
124
|
+
deployment: process.env.AGENT_DEPLOYMENT_SHA!,
|
|
125
|
+
model: process.env.AGENT_MODEL!,
|
|
126
|
+
tools: process.env.AGENT_TOOLSET_SHA!,
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
const optimizer = {
|
|
130
|
+
model: process.env.OPTIMIZER_MODEL!,
|
|
131
|
+
baseUrl: process.env.OPTIMIZER_BASE_URL!,
|
|
132
|
+
apiKey: process.env.OPTIMIZER_API_KEY!,
|
|
133
|
+
budget: {
|
|
134
|
+
maxCostUsd: 10,
|
|
135
|
+
maxRequests: 50,
|
|
136
|
+
maxRequestBytes: 2_000_000,
|
|
137
|
+
maxResponseBytes: 2_000_000,
|
|
138
|
+
maxOutputTokensPerRequest: 16_384,
|
|
139
|
+
pricing: {
|
|
140
|
+
inputUsdPerMillion: Number(process.env.OPTIMIZER_INPUT_USD_PER_MILLION),
|
|
141
|
+
outputUsdPerMillion: Number(process.env.OPTIMIZER_OUTPUT_USD_PER_MILLION),
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const result = await improve(baseProfile, {
|
|
119
147
|
surface: 'prompt',
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
148
|
+
executionRef,
|
|
149
|
+
method: officialGepa({
|
|
150
|
+
objective: 'Improve the complete support-agent prompt.',
|
|
151
|
+
recipe: {
|
|
152
|
+
kind: 'engine',
|
|
153
|
+
run: {
|
|
154
|
+
engine: 'gepa',
|
|
155
|
+
maxEvaluations: 40,
|
|
156
|
+
maxProposerCostUsd: 10,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
optimizer,
|
|
160
|
+
resume: 'if-compatible',
|
|
161
|
+
trustResumeState: true,
|
|
162
|
+
describeScenario: ({ input }) => ({ input }),
|
|
163
|
+
}),
|
|
164
|
+
findings,
|
|
165
|
+
trainScenarios,
|
|
166
|
+
selectionScenarios,
|
|
167
|
+
testScenarios,
|
|
168
|
+
judges: [judge],
|
|
169
|
+
agent: (candidateProfile, scenario, ctx) =>
|
|
170
|
+
runProfile(candidateProfile, scenario, ctx),
|
|
171
|
+
runDir: '.runs/support-prompt',
|
|
172
|
+
costCeiling: 25,
|
|
124
173
|
})
|
|
125
174
|
|
|
126
|
-
if (decision === 'ship')
|
|
175
|
+
if (result.decision === 'ship') {
|
|
176
|
+
console.log(result.candidate.profile, result.liftInterval)
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`officialGepa(...)` delegates the complete search to GEPA's upstream Optimize Anything API through agent-eval.
|
|
181
|
+
Pass one explicit `engine`, `sequential`, `adaptive-sequential`, `best-of`, `vote`, or `omni` recipe.
|
|
182
|
+
Runtime derives the upstream resume identity from `executionRef`, the complete baseline profile, and the selected surface.
|
|
183
|
+
With `resume: 'if-compatible'`, agent-eval resumes only when the saved run identity matches the candidate, recipe, data, optimizer settings, runner, and derived execution identity.
|
|
184
|
+
Set `trustResumeState: true` only when that run directory is private to the current operator.
|
|
185
|
+
Use `resume: 'required'` to fail when no matching run exists.
|
|
186
|
+
`result.provenance` reports the upstream package, run ID, resume status, evaluation count, and artifact directory.
|
|
187
|
+
There is no local fallback.
|
|
188
|
+
Install its optional Python process before using it:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
python -m pip install "agent-eval-rpc==0.131.0"
|
|
192
|
+
python -m pip install "gepa[full]==0.1.4"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
The published GEPA 0.1.4 wheel supports the direct `gepa` engine.
|
|
196
|
+
Sequential, adaptive, best-of, vote, Omni, AutoResearch, Meta Harness, and Best-of-N require the tested official source revision:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
python -m pip install "gepa[full] @ git+https://github.com/gepa-ai/gepa.git@f919db0a622e2e9f9204779b81fe00cc1b2d808f"
|
|
127
200
|
```
|
|
128
201
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
202
|
+
Use `officialSkillOpt(...)` for Microsoft's SkillOpt:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
python -m pip install "agent-eval-rpc==0.131.0"
|
|
206
|
+
python -m pip install "skillopt @ git+https://github.com/microsoft/SkillOpt.git@61735e3922efc2b90c6d6cab561e62e98452ca90"
|
|
207
|
+
```
|
|
132
208
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
209
|
+
SkillOpt 0.2.0's published wheel omits prompt files required by `ReflACTTrainer`, so the tested SkillOpt source revision remains necessary.
|
|
210
|
+
SkillOpt and GEPA's standard reflection engine require `optimizer: { model, baseUrl, apiKey, budget }`.
|
|
211
|
+
Agent-based GEPA engines may own their model connection instead.
|
|
212
|
+
Agent Eval proxies those model calls, enforces the nested budget, and records their cost.
|
|
213
|
+
`costCeiling` is the total limit for optimizer calls, candidate runs, judges, and final scoring.
|
|
214
|
+
Runtime returns `hold` when any part of that cost is unknown.
|
|
215
|
+
Runtime rejects a reported total above the limit.
|
|
216
|
+
|
|
217
|
+
SkillOpt accepts one text surface.
|
|
218
|
+
GEPA accepts text or named components.
|
|
219
|
+
Any complete method from `@tangle-network/agent-eval` uses the same call.
|
|
220
|
+
The `agent` callback receives the complete immutable candidate profile, not a raw prompt or component fragment.
|
|
221
|
+
Runtime uses that exact profile for every candidate run and returns the same measured profile in `result.candidate.profile`.
|
|
222
|
+
`executionRef` is a content digest of the agent callback, profile component mapping, model, tools, and closure settings.
|
|
223
|
+
Runtime combines it with the complete baseline profile and selected surface for saved work.
|
|
224
|
+
Changing any of them runs the affected work again.
|
|
225
|
+
For a skill, set `surface: 'skills'` and `skills.resourceName`.
|
|
226
|
+
For the complete profile, set `surface: 'agent-profile'`.
|
|
227
|
+
To optimize several named profile fields together, also provide `profileComponents.read` and `profileComponents.apply`.
|
|
228
|
+
Tools, MCP, hooks, subagents, curated instructions, and rollout policy are also exact profile coordinates.
|
|
229
|
+
Runtime does not choose an optimizer for them.
|
|
230
|
+
|
|
231
|
+
Without `describeScenario`, the external optimizer receives only each development case ID.
|
|
232
|
+
Without `describeArtifact`, evaluation feedback contains no artifact body.
|
|
233
|
+
When either descriptor is present, its result passes through `redact` together with findings, background text, profile name, and judge notes.
|
|
234
|
+
The built-in redactor removes common credentials and email addresses.
|
|
235
|
+
Supply a domain redactor for customer names, account IDs, or other private data the built-in rules cannot identify.
|
|
236
|
+
Runtime applies that hook first and then still applies its built-in scrubber.
|
|
237
|
+
Set `redact: false` only when every outbound value is public and already reviewed.
|
|
238
|
+
|
|
239
|
+
The selected profile surface is the optimizer's candidate and cannot be redacted without changing the measured candidate.
|
|
240
|
+
Runtime always rejects recognized credentials in those bytes.
|
|
241
|
+
It also rejects structurally sensitive fields such as MCP env, headers, URLs, metadata, and extensions.
|
|
242
|
+
For `tools`, `mcp`, `hooks`, `subagents`, and `agent-profile`, Runtime treats the entire selected coordinate as execution-capable.
|
|
243
|
+
Use `authorizeSensitiveCandidate` to inspect and accept each exact immutable profile containing public values or safe references.
|
|
244
|
+
The callback runs for the baseline and every distinct candidate before either reaches your agent.
|
|
245
|
+
Its `sensitivePaths` includes `$` when the whole coordinate requires review.
|
|
246
|
+
|
|
247
|
+
Code is the exception.
|
|
248
|
+
It uses Runtime's isolated git worktrees and coding-agent candidate execution:
|
|
136
249
|
|
|
137
250
|
```ts
|
|
138
|
-
const
|
|
139
|
-
surface: '
|
|
140
|
-
|
|
141
|
-
scenarios,
|
|
251
|
+
const result = await improve({
|
|
252
|
+
surface: 'code',
|
|
253
|
+
code: { repoRoot, baseRef, generator },
|
|
254
|
+
scenarios,
|
|
255
|
+
judge,
|
|
256
|
+
agent,
|
|
257
|
+
budget,
|
|
142
258
|
})
|
|
143
259
|
```
|
|
144
260
|
|
|
@@ -159,7 +275,16 @@ const result = await proposeAgentImprovement({
|
|
|
159
275
|
runId,
|
|
160
276
|
profile: liveProfile,
|
|
161
277
|
analysis,
|
|
162
|
-
improvement: {
|
|
278
|
+
improvement: {
|
|
279
|
+
surface: 'prompt',
|
|
280
|
+
executionRef,
|
|
281
|
+
method,
|
|
282
|
+
trainScenarios,
|
|
283
|
+
selectionScenarios,
|
|
284
|
+
testScenarios,
|
|
285
|
+
judges: [judge],
|
|
286
|
+
agent,
|
|
287
|
+
},
|
|
163
288
|
buildExperiment: ({ improvement }) =>
|
|
164
289
|
buildExperimentMaterial({
|
|
165
290
|
baseline,
|
|
@@ -191,10 +316,16 @@ const outcome = await executeAgentImprovementActivation(
|
|
|
191
316
|
`buildExperimentMaterial`, `placeCell`, and the transaction functions are application ports because storage and compute differ by product.
|
|
192
317
|
The builder returns only baseline, candidate, tasks, and policy; Runtime adds the search ancestry and seals the final experiment.
|
|
193
318
|
Runtime owns candidate identity, measurement, review binding, expiry, retry identity, and result validation; the application owns its atomic write.
|
|
319
|
+
Official optimizer proposals carry the observed package versions, optimizer model, evaluation and token usage, separate optimization and final-test costs, and resumed-run identity.
|
|
320
|
+
`createOptimizationActivationReceipt(result)` exposes the same detached record for callers that need to inspect an `improve()` result before building a proposal.
|
|
194
321
|
|
|
195
322
|
### Improve a knowledge base
|
|
196
323
|
|
|
197
|
-
`runKnowledgeImprovementJob`
|
|
324
|
+
`runKnowledgeImprovementJob` runs KB, wiki, memory-backed, and RAG improvement jobs.
|
|
325
|
+
It creates a candidate copy, runs agents against it, checks it through `@tangle-network/agent-knowledge`, and returns frozen baseline and candidate snapshots with spend and timing.
|
|
326
|
+
It never changes the live knowledge base.
|
|
327
|
+
Use `improve(profile, { surface: 'memory', ... })` for the agent's curated lesson document.
|
|
328
|
+
Use this job for source, retrieval, and knowledge-store changes.
|
|
198
329
|
|
|
199
330
|
```ts
|
|
200
331
|
import { runKnowledgeImprovementJob } from '@tangle-network/agent-runtime/knowledge'
|
|
@@ -202,6 +333,7 @@ import { runKnowledgeImprovementJob } from '@tangle-network/agent-runtime/knowle
|
|
|
202
333
|
const result = await runKnowledgeImprovementJob({
|
|
203
334
|
root: './kb',
|
|
204
335
|
goal: 'Improve support refund-policy knowledge',
|
|
336
|
+
implementationRef: 'git:0123456789abcdef0123456789abcdef01234567',
|
|
205
337
|
readinessSpecs,
|
|
206
338
|
budget: { maxIterations: 8, maxTokens: 120_000, maxUsd: 10 },
|
|
207
339
|
backend,
|
|
@@ -211,11 +343,13 @@ console.log(result.knowledge?.reference.candidateHash, result.measurement.superv
|
|
|
211
343
|
```
|
|
212
344
|
|
|
213
345
|
Use it when the product needs one knob for "make this knowledge base better" instead of wiring `improveKnowledgeBase`, a runtime supervisor, candidate workspaces, and readiness checks by hand.
|
|
346
|
+
Set `implementationRef` to the deployed `git:<40 hex>` revision or a `sha256:<64 hex>` digest covering every callback, model, index, and external setting that can change the result.
|
|
347
|
+
The same run ID resumes only when this identity still matches.
|
|
214
348
|
Measure the returned bundle pair, record the review, then activate through `executeAgentImprovementActivation`; activation is the only write path.
|
|
215
349
|
|
|
216
350
|
### Run on PrimeIntellect
|
|
217
351
|
|
|
218
|
-
`@tangle-network/agent-runtime/primeintellect` packages typed train and eval tasks as a Verifiers
|
|
352
|
+
`@tangle-network/agent-runtime/primeintellect` packages typed train and eval tasks as a PrimeIntellect Verifiers environment.
|
|
219
353
|
Prime launches your actual runtime program against an intercepted model endpoint, so `runPersonified`, `runAgentic`, product agents, tool calls, and multiple rounds stay intact.
|
|
220
354
|
Reference answers remain in Prime's task process and never enter the agent workspace.
|
|
221
355
|
The runner file must be one executable bundle containing the app and its runtime dependencies.
|
|
@@ -229,7 +363,7 @@ import {
|
|
|
229
363
|
|
|
230
364
|
const bundledRunner = await readFile('./dist/prime-runner.mjs', 'utf8')
|
|
231
365
|
const bundle = createPrimeIntellectPackage({
|
|
232
|
-
name: 'support-agent
|
|
366
|
+
name: 'support-agent',
|
|
233
367
|
version: '1.0.0',
|
|
234
368
|
tasks: [
|
|
235
369
|
{
|
|
@@ -253,7 +387,7 @@ const bundle = createPrimeIntellectPackage({
|
|
|
253
387
|
},
|
|
254
388
|
})
|
|
255
389
|
|
|
256
|
-
await writePrimeIntellectPackage(bundle, './prime/support-agent
|
|
390
|
+
await writePrimeIntellectPackage(bundle, './prime/support-agent')
|
|
257
391
|
```
|
|
258
392
|
|
|
259
393
|
The runner reads the episode and uses the normal runtime APIs:
|
|
@@ -276,20 +410,20 @@ Use `importPrimeIntellectTraces(...)` to convert them to agent-eval `RunRecord`s
|
|
|
276
410
|
|
|
277
411
|
## How it works (the short version)
|
|
278
412
|
|
|
279
|
-
- **
|
|
280
|
-
- **
|
|
281
|
-
- **
|
|
282
|
-
- **
|
|
413
|
+
- **Roles are configuration.** Driver, worker, and coordinator describe what an agent does in a run. They are not separate agent types.
|
|
414
|
+
- **Runs are recorded.** A run can report tokens, dollars, time, outputs, and scores.
|
|
415
|
+
- **Candidates face fresh tasks.** The optimizer uses train and selection tasks. Promotion uses a separate final set.
|
|
416
|
+
- **Scores come from executed attempts.** Runtime recomputes results from the recorded cells and rejects incomplete cost or source evidence.
|
|
283
417
|
|
|
284
418
|
## Primitives
|
|
285
419
|
|
|
286
|
-
The general-purpose pieces, by import path. Every export with its one-line summary lives in the generated [`docs/api/primitive-catalog.md`](./docs/api/primitive-catalog.md)
|
|
420
|
+
The general-purpose pieces, by import path. Every export with its one-line summary lives in the generated [`docs/api/primitive-catalog.md`](./docs/api/primitive-catalog.md): check it before building anything new.
|
|
287
421
|
|
|
288
422
|
| Primitive | What it does | Import |
|
|
289
423
|
|---|---|---|
|
|
290
424
|
| Chat-turn runtime | Stream, trace, and persist one production chat turn (`handleChatTurn`); normalize any backend's stream into one event shape (`streamAgentTurn`) | root · `/loops` |
|
|
291
425
|
| Supervision | One agent spawns, budgets, and steers workers toward a goal (`supervise`, `delegate`), on an in-process loop or a sandboxed coding harness | `/loops` · `/mcp` |
|
|
292
|
-
| Loop kernel + combinators | Write a driver (`plan`/`decide`) and run it (`
|
|
426
|
+
| Loop kernel + combinators | Write a driver (`plan`/`decide`) and run it (`runAgentRounds`), or compose fixed shapes: refine (`loopUntil`), best-of-N (`fanout`), chain (`pipeline`), multi-judge (`panel`) | `/loops` |
|
|
293
427
|
| Improvement driver | Optimize one part of an agent and ship only if it wins on tasks it never practiced on (`improve`); production proposal/review/activation flow | root · `/intelligence` |
|
|
294
428
|
| Benchmarks + leaderboards | Compare strategies with significance stats (`runBenchmark`), stand up a harness×model leaderboard (`defineLeaderboard`, `leaderboard`) | `/loops` |
|
|
295
429
|
| Knowledge improvement | Produce a measured candidate copy of a KB/wiki/RAG corpus without touching the live one (`runKnowledgeImprovementJob`) | `/knowledge` |
|
|
@@ -324,7 +458,7 @@ All 29 live in [`examples/`](./examples).
|
|
|
324
458
|
- New here? [`docs/concepts.md`](./docs/concepts.md), the mental model in plain terms.
|
|
325
459
|
- [`docs/canonical-api.md`](./docs/canonical-api.md), find the primitive: "I want to ___ → use ___".
|
|
326
460
|
- [`docs/api/primitive-catalog.md`](./docs/api/primitive-catalog.md), every export in one generated, never-stale list with its import path. Check it before building anything new.
|
|
327
|
-
- [`docs/design.md`](./docs/design.md), the design philosophy and the internal research docs behind it
|
|
461
|
+
- [`docs/design.md`](./docs/design.md), the design philosophy and the internal research docs behind it: background reading, not required to use the package.
|
|
328
462
|
- [`bench/HARNESS.md`](./bench/HARNESS.md), the experiment harness and how to run a benchmark.
|
|
329
463
|
|
|
330
464
|
**Contributing:** `pnpm i && pnpm build && pnpm test` gets you running; the full local gate is the [`package.json`](./package.json) scripts (`lint`, `typecheck`, `docs:check`).
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { it as canonicalCandidateDocument, rt as canonicalCandidateDigest$1, st as immutableCandidateValue, ut as verifyCanonicalCandidateDocument } from "./prepare-B53sPV7M.js";
|
|
2
|
+
import { S as agentProfileImprovementStateDigest, b as agentImprovementTargetInput, d as verifyAgentImprovementProposal, s as requireSealedCandidateExperiment, u as verifyAgentImprovementActivation, y as agentImprovementTargetDigest } from "./improvement-cycle-C095kS_g.js";
|
|
3
|
+
import { agentImprovementActivationResultSchema, agentImprovementActivationSchema, agentProfileImprovementExperimentSchema } from "@tangle-network/agent-interface";
|
|
4
|
+
//#region src/intelligence/activation.ts
|
|
5
|
+
/** Create the exact result a product stores in the same transaction as its target write. */
|
|
6
|
+
function createAgentImprovementActivationResult(transition, options) {
|
|
7
|
+
const activation = verifyCanonicalCandidateDocument(agentImprovementActivationSchema.parse(transition.activation), "agent improvement activation");
|
|
8
|
+
assertTransitionInput(activation, transition);
|
|
9
|
+
const result = agentImprovementActivationResultSchema.parse(canonicalCandidateDocument({
|
|
10
|
+
kind: "agent-improvement-activation-result",
|
|
11
|
+
idempotencyKey: activation.digest,
|
|
12
|
+
attemptedAt: transition.attemptedAt,
|
|
13
|
+
completedAt: options.completedAt,
|
|
14
|
+
outcome: options.outcome
|
|
15
|
+
}).value);
|
|
16
|
+
assertResultAgainstActivation(activation, result);
|
|
17
|
+
assertOutcomeDesiredState(activation, result, new Map(transition.targets.map((target) => [targetIdentity(target), target.desiredDigest])));
|
|
18
|
+
return immutableCandidateValue(result);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Recompute one historical activation result against the exact measured proposal and authority.
|
|
22
|
+
* The result records that attempt; it is not a query of the target's current state.
|
|
23
|
+
*/
|
|
24
|
+
function verifyAgentImprovementActivationResult(input) {
|
|
25
|
+
const proposal = verifyAgentImprovementProposal(input.proposal);
|
|
26
|
+
const activation = verifyAgentImprovementActivation(input);
|
|
27
|
+
const result = verifyCanonicalCandidateDocument(agentImprovementActivationResultSchema.parse(input.result), "agent improvement activation result");
|
|
28
|
+
assertResultAgainstActivation(activation, result);
|
|
29
|
+
assertResultDesiredState(proposal, activation, result);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
/** Validate and execute one product-owned activation transition. */
|
|
33
|
+
async function executeAgentImprovementActivation(input, options) {
|
|
34
|
+
const proposal = verifyAgentImprovementProposal(input.proposal);
|
|
35
|
+
const activation = verifyAgentImprovementActivation(input);
|
|
36
|
+
const observedAt = (options.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
|
|
37
|
+
const attemptedAt = Date.parse(observedAt) < Date.parse(activation.authorizedAt) ? activation.authorizedAt : observedAt;
|
|
38
|
+
const expired = Date.parse(attemptedAt) >= Date.parse(activation.expiresAt);
|
|
39
|
+
const transition = immutableCandidateValue(proposal.evaluation.kind === "agent-improvement-measured-comparison" ? sealedCandidateTransition(proposal.evaluation.experiment, activation, attemptedAt, expired) : profileImprovementTransition(proposal.evaluation.experiment, activation, attemptedAt, expired));
|
|
40
|
+
if (transition.expired) {
|
|
41
|
+
if (!options.reconcile) return uncertainActivationResult(transition, "RECONCILIATION_UNAVAILABLE");
|
|
42
|
+
let reconciled;
|
|
43
|
+
try {
|
|
44
|
+
reconciled = await options.reconcile(transition);
|
|
45
|
+
} catch {
|
|
46
|
+
return uncertainActivationResult(transition, "RECONCILIATION_THROW");
|
|
47
|
+
}
|
|
48
|
+
if (reconciled === void 0) return createAgentImprovementActivationResult(transition, {
|
|
49
|
+
completedAt: transition.attemptedAt,
|
|
50
|
+
outcome: { status: "expired" }
|
|
51
|
+
});
|
|
52
|
+
try {
|
|
53
|
+
return verifyAgentImprovementActivationResult({
|
|
54
|
+
...input,
|
|
55
|
+
result: reconciled
|
|
56
|
+
});
|
|
57
|
+
} catch {
|
|
58
|
+
return uncertainActivationResult(transition, "INVALID_RECONCILIATION");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
let rawResult;
|
|
62
|
+
try {
|
|
63
|
+
rawResult = await options.transition(transition);
|
|
64
|
+
} catch {
|
|
65
|
+
return uncertainActivationResult(transition, "TRANSITION_THROW");
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
return verifyAgentImprovementActivationResult({
|
|
69
|
+
...input,
|
|
70
|
+
result: rawResult
|
|
71
|
+
});
|
|
72
|
+
} catch {
|
|
73
|
+
return uncertainActivationResult(transition, "INVALID_RESULT");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function sealedCandidateTransition(experiment, activation, attemptedAt, expired) {
|
|
77
|
+
const targetArm = activation.intent === "activate-candidate" ? "candidate" : "baseline";
|
|
78
|
+
return {
|
|
79
|
+
kind: "sealed-candidate",
|
|
80
|
+
activation,
|
|
81
|
+
candidateBundle: experiment.candidate,
|
|
82
|
+
bundle: experiment[targetArm],
|
|
83
|
+
targets: activation.targets.map((target) => ({
|
|
84
|
+
...target,
|
|
85
|
+
desiredDigest: agentImprovementTargetDigest(experiment, targetArm, target.surface),
|
|
86
|
+
desiredInput: agentImprovementTargetInput(experiment[targetArm], target.surface)
|
|
87
|
+
})),
|
|
88
|
+
attemptedAt,
|
|
89
|
+
expired
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function profileImprovementTransition(experiment, activation, attemptedAt, expired) {
|
|
93
|
+
const sourceArm = activation.intent === "activate-candidate" ? "baseline" : "candidate";
|
|
94
|
+
const targetArm = activation.intent === "activate-candidate" ? "candidate" : "baseline";
|
|
95
|
+
const operation = profileImprovementOperation(experiment, activation.intent);
|
|
96
|
+
return {
|
|
97
|
+
kind: "profile-improvement",
|
|
98
|
+
activation,
|
|
99
|
+
experiment,
|
|
100
|
+
sourceStateDigest: agentProfileImprovementStateDigest(experiment, sourceArm),
|
|
101
|
+
desiredStateDigest: agentProfileImprovementStateDigest(experiment, targetArm),
|
|
102
|
+
operation,
|
|
103
|
+
targets: activation.targets.map((target) => ({
|
|
104
|
+
...target,
|
|
105
|
+
desiredDigest: agentProfileImprovementStateDigest(experiment, targetArm),
|
|
106
|
+
desiredInput: operation
|
|
107
|
+
})),
|
|
108
|
+
attemptedAt,
|
|
109
|
+
expired
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function profileImprovementOperation(experiment, intent) {
|
|
113
|
+
return intent === "activate-candidate" ? {
|
|
114
|
+
kind: "apply-change",
|
|
115
|
+
changes: experiment.change
|
|
116
|
+
} : { kind: "restore-state" };
|
|
117
|
+
}
|
|
118
|
+
function uncertainActivationResult(transition, code) {
|
|
119
|
+
return createAgentImprovementActivationResult(transition, {
|
|
120
|
+
completedAt: transition.attemptedAt,
|
|
121
|
+
outcome: {
|
|
122
|
+
status: "indeterminate",
|
|
123
|
+
code,
|
|
124
|
+
message: "The product transition did not return a trustworthy commit result."
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function assertTransitionInput(activation, transition) {
|
|
129
|
+
if (transition.kind === "sealed-candidate") {
|
|
130
|
+
assertSealedCandidateTransitionInput(activation, transition);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
assertProfileImprovementTransitionInput(activation, transition);
|
|
134
|
+
}
|
|
135
|
+
function assertSealedCandidateTransitionInput(activation, transition) {
|
|
136
|
+
assertAuthorizedTransitionTargets(activation, transition.targets);
|
|
137
|
+
const desiredInputsMatch = transition.targets.every((target) => canonicalCandidateDigest$1(target.desiredInput) === canonicalCandidateDigest$1(agentImprovementTargetInput(transition.bundle, target.surface)));
|
|
138
|
+
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");
|
|
139
|
+
}
|
|
140
|
+
function assertProfileImprovementTransitionInput(activation, transition) {
|
|
141
|
+
assertAuthorizedTransitionTargets(activation, transition.targets);
|
|
142
|
+
const experiment = agentProfileImprovementExperimentSchema.parse(transition.experiment);
|
|
143
|
+
const sourceArm = activation.intent === "activate-candidate" ? "baseline" : "candidate";
|
|
144
|
+
const targetArm = activation.intent === "activate-candidate" ? "candidate" : "baseline";
|
|
145
|
+
const sourceStateDigest = agentProfileImprovementStateDigest(experiment, sourceArm);
|
|
146
|
+
const desiredStateDigest = agentProfileImprovementStateDigest(experiment, targetArm);
|
|
147
|
+
const operation = profileImprovementOperation(experiment, activation.intent);
|
|
148
|
+
const targetsMatch = transition.targets.every((target) => target.expectedBaseDigest === sourceStateDigest && target.desiredDigest === desiredStateDigest && canonicalCandidateDigest$1(target.desiredInput) === canonicalCandidateDigest$1(operation));
|
|
149
|
+
if (transition.expired !== Date.parse(transition.attemptedAt) >= Date.parse(activation.expiresAt) || experiment.digest !== activation.experimentDigest || experiment.candidate.stateDigest !== activation.candidateDigest || transition.sourceStateDigest !== sourceStateDigest || transition.desiredStateDigest !== desiredStateDigest || canonicalCandidateDigest$1(transition.operation) !== canonicalCandidateDigest$1(operation) || !targetsMatch) throw new Error("activation transition does not match its authorization");
|
|
150
|
+
}
|
|
151
|
+
function assertAuthorizedTransitionTargets(activation, targets) {
|
|
152
|
+
const authorized = targetMap(activation.targets);
|
|
153
|
+
const planned = targetMap(targets);
|
|
154
|
+
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");
|
|
155
|
+
}
|
|
156
|
+
function assertResultAgainstActivation(activation, result) {
|
|
157
|
+
const attemptedAt = Date.parse(result.attemptedAt);
|
|
158
|
+
const completedAt = Date.parse(result.completedAt);
|
|
159
|
+
const expiresAt = Date.parse(activation.expiresAt);
|
|
160
|
+
if (result.idempotencyKey !== activation.digest || attemptedAt < Date.parse(activation.authorizedAt) || completedAt < attemptedAt) throw new Error("activation result does not bind its authorization");
|
|
161
|
+
const expired = attemptedAt >= expiresAt;
|
|
162
|
+
if (result.outcome.status === "expired" && !expired || expired && ![
|
|
163
|
+
"expired",
|
|
164
|
+
"indeterminate",
|
|
165
|
+
"already-applied"
|
|
166
|
+
].includes(result.outcome.status)) throw new Error("activation result does not honor its authorization expiry");
|
|
167
|
+
if (!("targets" in result.outcome)) return;
|
|
168
|
+
const authorized = targetMap(activation.targets);
|
|
169
|
+
const observed = new Set(result.outcome.targets.map(targetIdentity));
|
|
170
|
+
if (authorized.size !== observed.size || [...authorized.keys()].some((identity) => !observed.has(identity))) throw new Error("activation result must cover every authorized target exactly once");
|
|
171
|
+
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");
|
|
172
|
+
}
|
|
173
|
+
function assertResultDesiredState(proposal, activation, result) {
|
|
174
|
+
if (!("targets" in result.outcome)) return;
|
|
175
|
+
const targetArm = activation.intent === "activate-candidate" ? "candidate" : "baseline";
|
|
176
|
+
const desiredStateDigest = proposal.evaluation.kind === "agent-profile-improvement-measured-comparison" ? agentProfileImprovementStateDigest(proposal.evaluation.experiment, targetArm) : void 0;
|
|
177
|
+
assertOutcomeDesiredState(activation, result, new Map(activation.targets.map((target) => [targetIdentity(target), desiredStateDigest ?? agentImprovementTargetDigest(requireSealedCandidateExperiment(proposal), targetArm, target.surface)])));
|
|
178
|
+
}
|
|
179
|
+
function assertOutcomeDesiredState(activation, result, desired) {
|
|
180
|
+
if (!("targets" in result.outcome)) return;
|
|
181
|
+
if (result.outcome.status === "applied") {
|
|
182
|
+
if (result.outcome.targets.some((target) => target.afterDigest !== desired.get(targetIdentity(target)))) throw new Error("applied activation does not match the requested bundle");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const allDesired = result.outcome.targets.every((target) => target.currentDigest === desired.get(targetIdentity(target)));
|
|
186
|
+
if (result.outcome.status === "already-applied") {
|
|
187
|
+
if (!allDesired) throw new Error("already-applied activation is not at the requested state");
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const authorized = targetMap(activation.targets);
|
|
191
|
+
const hasStaleTarget = result.outcome.targets.some((target) => target.currentDigest !== authorized.get(targetIdentity(target))?.expectedBaseDigest);
|
|
192
|
+
if (allDesired || !hasStaleTarget) throw new Error("activation conflict does not identify stale target state");
|
|
193
|
+
}
|
|
194
|
+
function targetMap(targets) {
|
|
195
|
+
return new Map(targets.map((target) => [targetIdentity(target), target]));
|
|
196
|
+
}
|
|
197
|
+
function targetIdentity(target) {
|
|
198
|
+
return `${target.surface}\u0000${target.identity}`;
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
export { executeAgentImprovementActivation as n, verifyAgentImprovementActivationResult as r, createAgentImprovementActivationResult as t };
|
|
202
|
+
|
|
203
|
+
//# sourceMappingURL=activation-CRjVfOiy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation-CRjVfOiy.js","names":["canonicalCandidateDigest"],"sources":["../src/intelligence/activation.ts"],"sourcesContent":["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 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 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":";;;;;AA6IA,SAAgB,uCACd,YACA,SACkC;CAClC,MAAM,aAAa,iCACjB,iCAAiC,MAAM,WAAW,UAAU,GAC5D,8BACF;CACA,sBAAsB,YAAY,UAAU;CAC5C,MAAM,SAAS,uCAAuC,MACpD,2BAA6D;EAC3D,MAAM;EACN,gBAAgB,WAAW;EAC3B,aAAa,WAAW;EACxB,aAAa,QAAQ;EACrB,SAAS,QAAQ;CACnB,CAAC,CAAC,CAAC,KACL;CACA,8BAA8B,YAAY,MAAM;CAChD,0BACE,YACA,QACA,IAAI,IAAI,WAAW,QAAQ,KAAK,WAAW,CAAC,eAAe,MAAM,GAAG,OAAO,aAAa,CAAC,CAAC,CAC5F;CACA,OAAO,wBAAwB,MAAM;AACvC;;;;;AAMA,SAAgB,uCAAuC,OAKlB;CACnC,MAAM,WAAW,+BAA+B,MAAM,QAAQ;CAC9D,MAAM,aAAa,iCAAiC,KAAK;CACzD,MAAM,SAAS,iCACb,uCAAuC,MAAM,MAAM,MAAM,GACzD,qCACF;CACA,8BAA8B,YAAY,MAAM;CAChD,yBAAyB,UAAU,YAAY,MAAM;CACrD,OAAO;AACT;;AAGA,eAAsB,kCACpB,OACA,SAC2C;CAC3C,MAAM,WAAW,+BAA+B,MAAM,QAAQ;CAC9D,MAAM,aAAa,iCAAiC,KAAK;CACzD,MAAM,cAAc,QAAQ,8BAAc,IAAI,KAAK,GAAA,CAAI,CAAC,CAAC,YAAY;CACrE,MAAM,cACJ,KAAK,MAAM,UAAU,IAAI,KAAK,MAAM,WAAW,YAAY,IACvD,WAAW,eACX;CACN,MAAM,UAAU,KAAK,MAAM,WAAW,KAAK,KAAK,MAAM,WAAW,SAAS;CAC1E,MAAM,aAAa,wBACjB,SAAS,WAAW,SAAS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