@tangle-network/agent-runtime 0.95.0 → 0.97.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 (86) hide show
  1. package/README.md +64 -15
  2. package/dist/activation-B0ZD7nfX.d.ts +63 -0
  3. package/dist/agent.d.ts +5 -169
  4. package/dist/agent.js +8 -229
  5. package/dist/agent.js.map +1 -1
  6. package/dist/analyst-loop.d.ts +6 -9
  7. package/dist/analyst-loop.js +1 -2
  8. package/dist/candidate-execution/index.js +6 -7
  9. package/dist/chunk-3XKSBI2U.js +474 -0
  10. package/dist/chunk-3XKSBI2U.js.map +1 -0
  11. package/dist/{chunk-6YBA64Z2.js → chunk-6XKPVJAZ.js} +5 -18
  12. package/dist/chunk-6XKPVJAZ.js.map +1 -0
  13. package/dist/{chunk-MKGRLDWB.js → chunk-BLQIYRVR.js} +17 -2
  14. package/dist/chunk-BLQIYRVR.js.map +1 -0
  15. package/dist/{chunk-QDSOD7RC.js → chunk-FD2MBMOH.js} +13 -101
  16. package/dist/chunk-FD2MBMOH.js.map +1 -0
  17. package/dist/{chunk-YLUOTX6U.js → chunk-FXF2OL34.js} +7 -7
  18. package/dist/{chunk-EP6RVHMX.js → chunk-HZDEXTSL.js} +848 -2
  19. package/dist/chunk-HZDEXTSL.js.map +1 -0
  20. package/dist/chunk-PSOCBNM3.js +2069 -0
  21. package/dist/chunk-PSOCBNM3.js.map +1 -0
  22. package/dist/{chunk-BPGXIKK7.js → chunk-SGQ4YIQW.js} +4 -4
  23. package/dist/{chunk-IADLKE7I.js → chunk-UQ6PNNXM.js} +5 -7
  24. package/dist/{chunk-IADLKE7I.js.map → chunk-UQ6PNNXM.js.map} +1 -1
  25. package/dist/{chunk-Z5I642SY.js → chunk-WYC2XJF2.js} +2 -2
  26. package/dist/{chunk-ZEYAT33L.js → chunk-Y3SRWZMP.js} +2 -2
  27. package/dist/{chunk-WTZ37EQY.js → chunk-YOLKCWRV.js} +197 -90
  28. package/dist/chunk-YOLKCWRV.js.map +1 -0
  29. package/dist/conversation.js +0 -1
  30. package/dist/environment-provider.js +0 -1
  31. package/dist/{agentic-generator-hCaQRAes.d.ts → improve-g75IE2Cx.d.ts} +152 -3
  32. package/dist/{improvement-adapter-BieWeK5J.d.ts → improvement-adapter-HAZz-7vK.d.ts} +8 -31
  33. package/dist/index.d.ts +41 -11
  34. package/dist/index.js +180 -51
  35. package/dist/index.js.map +1 -1
  36. package/dist/intelligence.d.ts +16 -9
  37. package/dist/intelligence.js +13 -8
  38. package/dist/intelligence.js.map +1 -1
  39. package/dist/knowledge.d.ts +30 -13
  40. package/dist/knowledge.js +11 -10
  41. package/dist/{loop-runner-bin-BIQldFS8.d.ts → loop-runner-bin-Cn1N2rRo.d.ts} +1 -1
  42. package/dist/loop-runner-bin.d.ts +2 -2
  43. package/dist/loop-runner-bin.js +6 -8
  44. package/dist/loops.d.ts +1 -1
  45. package/dist/loops.js +4 -6
  46. package/dist/mcp/bin.js +3 -5
  47. package/dist/mcp/bin.js.map +1 -1
  48. package/dist/mcp/index.js +10 -12
  49. package/dist/mcp/index.js.map +1 -1
  50. package/dist/platform.js +0 -2
  51. package/dist/platform.js.map +1 -1
  52. package/dist/primeintellect/index.js +0 -1
  53. package/dist/primeintellect/index.js.map +1 -1
  54. package/dist/profiles.js +0 -1
  55. package/dist/profiles.js.map +1 -1
  56. package/dist/{types-BC3bZpH0.d.ts → types-CmYCMbFT.d.ts} +12 -54
  57. package/package.json +8 -13
  58. package/skills/build-with-agent-runtime/SKILL.md +122 -213
  59. package/dist/chunk-6O73TRHW.js +0 -142
  60. package/dist/chunk-6O73TRHW.js.map +0 -1
  61. package/dist/chunk-6YBA64Z2.js.map +0 -1
  62. package/dist/chunk-AP7CPGMZ.js +0 -334
  63. package/dist/chunk-AP7CPGMZ.js.map +0 -1
  64. package/dist/chunk-DGUM43GV.js +0 -11
  65. package/dist/chunk-DGUM43GV.js.map +0 -1
  66. package/dist/chunk-DHCHL6OG.js +0 -625
  67. package/dist/chunk-DHCHL6OG.js.map +0 -1
  68. package/dist/chunk-EP6RVHMX.js.map +0 -1
  69. package/dist/chunk-G55QE4IQ.js +0 -1137
  70. package/dist/chunk-G55QE4IQ.js.map +0 -1
  71. package/dist/chunk-ISTDY47H.js +0 -849
  72. package/dist/chunk-ISTDY47H.js.map +0 -1
  73. package/dist/chunk-MKGRLDWB.js.map +0 -1
  74. package/dist/chunk-QDSOD7RC.js.map +0 -1
  75. package/dist/chunk-WTZ37EQY.js.map +0 -1
  76. package/dist/generator-YkAQrOoD.d.ts +0 -382
  77. package/dist/improve-B-UYaEH5.d.ts +0 -172
  78. package/dist/lifecycle.d.ts +0 -870
  79. package/dist/lifecycle.js +0 -981
  80. package/dist/lifecycle.js.map +0 -1
  81. package/dist/mcp-serve-verifier-Bs_n0xPc.d.ts +0 -34
  82. package/skills/agent-runtime-adoption/SKILL.md +0 -246
  83. /package/dist/{chunk-YLUOTX6U.js.map → chunk-FXF2OL34.js.map} +0 -0
  84. /package/dist/{chunk-BPGXIKK7.js.map → chunk-SGQ4YIQW.js.map} +0 -0
  85. /package/dist/{chunk-Z5I642SY.js.map → chunk-WYC2XJF2.js.map} +0 -0
  86. /package/dist/{chunk-ZEYAT33L.js.map → chunk-Y3SRWZMP.js.map} +0 -0
@@ -1,217 +1,126 @@
1
1
  ---
2
2
  name: build-with-agent-runtime
3
- description: Use before hand-rolling a tool loop, driver, corpus, or optimizer wrapper. Create an agent genome, run it on a benchmark, optimize+gate it, observe/ship it with @tangle-network/agent-runtime. The genome→run→optimize→observe spine.
3
+ description: Use before adding an agent loop, benchmark, optimizer, trace wrapper, or candidate activation path. Find and compose the existing Runtime, Eval, Knowledge, and Interface primitives.
4
4
  ---
5
5
 
6
- # build-with-agent-runtime
7
-
8
- The one create→run→optimize→observe seam for `@tangle-network/agent-runtime`. A
9
- **genome** (an `AgentProfile`/`AgentSurfaces` systemPrompt + skills + tools +
10
- mcp + knowledge + memory + rag as ONE combined surface) runs as a
11
- **driver⟷worker** shape over a **benchmark**, gets **optimized by a gated loop**
12
- that evolves the genome and certifies wins on a **frozen holdout**, and is
13
- **observed** through the one lifecycle stream. The selector is never the judge;
14
- observation attaches to the loop, never to the portable genome.
15
-
16
- If you are about to write a `runConversation`, a "skill optimizer", a
17
- "profile-seam", a depth-vs-breadth A/B harness, a bootstrap loop, or a
18
- `new Sandbox(...)` + stream + read dance — **stop.** It exists, and a parallel
19
- silently breaks a load-bearing invariant (equal-k, selector≠judge,
20
- capture-integrity, or eval/prod parity).
21
-
22
- ## Load order point at source, never freeze snippets
23
-
24
- This skill carries **no API snippets**. The barrel MOVES (`./loops` is the
25
- runtime barrel), the agent-eval pin drifts, and signatures get
26
- corrected in place. Freezing a snippet here guarantees rot. Instead, read, in
27
- order, and re-verify against source:
28
-
29
- 1. **`docs/canonical-api.md`** the source of truth: the §2 decision table
30
- ("I want to X → use Y → NOT Z"), §3 per-subsystem signatures (each cited
31
- `file:line`), §4 the end-to-end recipe, §5 the recursive atom, §6 the
32
- two-substrate map. Every signature there was read from source.
33
- 2. **`grep` the export barrel** — `grep -nE 'export (function|const|type)' src/runtime/index.ts`
34
- (and `src/agent/index.ts`, `src/improvement/index.ts`, `src/mcp/index.ts`,
35
- `src/intelligence/index.ts`) for the live names + subpaths. `./loops` is the
36
- runtime barrel (`package.json` maps it to `src/runtime/index.ts`).
37
- 3. **`bench/HARNESS.md`** the experiment-harness map: commands, the
38
- `rollout corpus selector → CI → gate` flow, and the `ADAPTERS` registry
39
- (a harness-local export, `bench/src/adapters.ts`, not a package export).
40
-
41
- **Code wins.** If a name, subpath, or signature here or in `docs/canonical-api.md`
42
- disagrees with source, the **source is right** fix the map in the *same turn*
43
- (the anti-rediscovery law). Verify with Read/Edit, don't re-read to confirm.
44
-
45
- ## Decision table by altitude (each row ONE source, not a snippet)
46
-
47
- Read the cited `docs/canonical-api.md` row before writing; it carries the live
48
- signature + the exact "do NOT build".
49
-
50
- **The §1.5 law, inline:** an agent IS its full authored `AgentProfile`
51
- (prompt+skills+tools+mcp+subagents+hooks); you change behavior by AUTHORING the
52
- profile and letting the substrate materialize it into harness shapes —
53
- self-verification, iteration, and audit are profile levers (hooks/skills/
54
- subagents), never glue code.
55
-
56
- `AgentProfile` is owned by `@tangle-network/agent-interface` (the `/loops`
57
- barrel re-exports the sandbox alias as a one-stop import), which also owns
58
- `HarnessType` + `ReasoningEffort` and a capability layer
59
- (`harnessSupportsModel` / `reasoningEffortsFor`) — so harness/model/reasoning
60
- compatibility is a queryable contract, not an assumption.
61
-
62
- Harness is a RUN-layer coordinate, not part of the portable genome: it rides on
63
- agent-runtime's `AgentSpec { profile, harness }`. To sweep it as an eval axis,
64
- don't hand-declare a harness list expand one base profile across
65
- `CODING_HARNESSES` with `expandProfileAxes` (agent-eval), run with
66
- `runProfileMatrix`, and pivot results by the stamped `AgentProfileCell`
67
- (`groupRunsByAgentProfileCell`); `harnessSupportsModel` filters per harness,
68
- and a vendor-locked harness that supports none of the requested models SNAPS
69
- to its native default (`HARNESS_NATIVE_MODEL`) — never silently dropped.
70
-
71
- | Altitude I want to… | Use | Source |
72
- |---|---|---|
73
- | **Define a genome** (who the agent is + what it can do, ONE surface) | `AgentProfile` (runnable) / `AgentSurfaces` (the editable-coordinate map) — `/loops`, `/agent` | canonical-api §3.2 |
74
- | **Define the personified-run record** (model+prompt+tools+role+seams) | `definePersona(input)` — `/loops` | canonical-api §3.1 |
75
- | **Run a genome driver⟷worker, end-to-end** | `runPersonified({ persona, shape, task, budget })` — `/loops` | canonical-api §3.1 |
76
- | **Loop a worker over one evolving artifact, K rounds, stop-when-good** | `loopUntil(seed, spec)` as the `shape` — `/loops` | canonical-api §3.1 |
77
- | **Best-of-N / parallel-research at equal compute** | `fanout(items, opts)` — `/loops` | canonical-api §3.1 |
78
- | **Produce-then-gate / multi-judge quorum / fixed chain** | `verify` / `panel` / `pipeline` — `/loops` | canonical-api §3.1 |
79
- | **Run depth-vs-breadth (or a custom strategy) over a stateful tool domain** | `runAgentic({ surface, task, mode\|strategy, budget })` — `/loops` | canonical-api §3.3 |
80
- | **Author a new topology/strategy compactly** | `defineStrategy(name, body)` w/ `ctx.shot()`+`ctx.critique()` — `/loops` | canonical-api §3.3 |
81
- | **Add a stateful tool-using domain** | implement `AgenticSurface` (5 hooks) — `/loops` | canonical-api §3.3 |
82
- | **Drive a team of agents over a graded `AgenticSurface` task** (workers settle on its check, driver self-improves from the failing tests) | `superviseSurface(profile, task, { surface, worker })` — `/loops` | canonical-api §2 |
83
- | **Benchmark: compare strategies + significance + Pareto on a domain** | `runBenchmark({ environment, tasks, worker, strategies })` — `/loops` | canonical-api §3.3 |
84
- | **Author a PRODUCT eval leaderboard** (cases + prompt + grader → ranked board, standard flags, fresh run-dir, export, `toBenchmarkAdapter()`) | `defineLeaderboard({ name, cases, prompt, score, axis?, backends?, flags?, setup?/teardown?, onCellEvents?, resolveModel?, export?, dispatch?, judges?, matrix? })` — `/loops` — NOT a hand-assembled flag-parsing + `runProfileMatrix` frame; `runProfileMatrix` is the escape floor, the level-2 `dispatch` override is how in-process products plug in | `src/runtime/define-leaderboard.ts` (verify vs source) |
85
- | **Resolve a harness-in-box backend** (box / local cli-bridge / router leaf, one `SandboxClient` shape) | `resolveSandboxClient({ backend: 'sandbox' \| 'bridge' \| 'router' })` — `/loops` — NOT a per-product backend factory or a hand-faked box (`inlineSandboxClient` / the bridge executor already exist) | `src/runtime/resolve-sandbox-client.ts` |
86
- | **Resolve an in-process chat backend** (the one `--backend` branch for `runChatThroughRuntime` / `runAgentTaskStream`) | `resolveAgentBackend({ kind: 'router' \| 'tcloud' \| 'cli-bridge' \| 'sandbox' })` — root `.` | `src/resolve-agent-backend.ts` |
87
- | **Run ONE agent turn as one normalized event stream** (box, executor, or chat backend; guaranteed terminal result+usage) | `streamAgentTurn(backend, prompt, { signal, timeoutMs })` + `collectAgentTurn(stream)` — `/loops` | canonical-api §2 |
88
- | **Benchmark report: multi-profile × multi-axis leaderboard** (ranked board + score matrix + SVG/HTML charts, any `RunRecord[]`) | `leaderboard(records)` + `renderLeaderboardMarkdown` / `renderLeaderboardSvg` / `renderLeaderboardHtml` — `/loops` | canonical-api §2 |
89
- | **Meter one `openSandboxRun` cell's token/cost usage** | `sumSandboxUsage(events)` — `/loops` | canonical-api §2 |
90
- | **Sweep harness × model as an eval axis** (turn one base profile into the full harness × model set) | `expandProfileAxes({ base, harnesses, models })` over `CODING_HARNESSES` → `runProfileMatrix(...)`, pivot with `groupRunsByAgentProfileCell` — `agent-eval` root — NOT a hand-declared `HARNESSES` list | agent-eval root (verify vs source) |
91
- | **Benchmark: add/run an external benchmark from the harness** | `ADAPTERS`/`resolveAdapter(key)` + a bench gate (`*-gate.mts`) over `openSandboxRun` + `sandboxAgentRun` (`bench/src/sandbox-run.ts`) | canonical-api §3.3 |
92
- | **Spawn N coding agents on isolated git worktrees, keep the one whose patch passes checks** | `worktreeFanout` + `createWorktreeCliExecutor` + `gateOnDeliverable(DeliverableSpec)` over a raw `WorktreePatchArtifact`, winner via `selectValidWinner` — `/loops` — NOT a hand-rolled spawn-loop / "coder" role | canonical-api §3.1 / §5 |
93
- | **Sandbox coding rollout** (fresh box/round, or persistent+resume) | `runLoop(options)` / `openSandboxRun(client, opts, deliverable)` — `/loops` | canonical-api §3.1 |
94
- | **Optimize a CODE surface** in a gated loop | `improvementDriver({ worktree, generator })` — root `.` | canonical-api §3.4 |
95
- | **Freeze a measured profile/diff + code surface for execution** | `buildAgentCandidateBundle(...)` then `verifyAgentCandidateBundle(...)` — `/candidate-execution` | canonical-api §2 |
96
- | **Optimize any agent/code surface** (one call) — START HERE | `improve(profile, findings, { surface, gate })` — root `.`; prompt, skill-document, and curated-memory surfaces have built-in proposers, config/whole-profile surfaces accept a proposer, and code gets isolated incumbent/candidate worktrees. Workflow and rollout-policy files use code plus agent-eval's `parameterSweepProposer` for JSON sweeps; drop to `selfImprove({ agent, scenarios, judge, baselineSurface })` only for lower-level control | canonical-api §3.4 |
97
- | **Gate: ship/hold a candidate** (campaign ctx) | `defaultProductionGate` / `heldOutGate` / `composeGate` — `agent-eval/contract`; `neutralizationGate` (footprint-matched PLACEBO gate — proves a held-out lift is CONTENT, not added prompt/mount footprint) — `agent-eval/campaign` | canonical-api §3.4 |
98
- | **Gate: ship/hold from a `BenchmarkReport`** (per-task cells) | `promotionGate({ report, incumbent, candidate })` `/loops` | canonical-api §3.4 |
99
- | **Run the full multi-generation flywheel + certify** | `runStrategyEvolution(config)` `/loops` | canonical-api §3.4 |
100
- | **Observe a run** (cost/time waterfall, OTLP) | `createWaterfallCollector()` — `/loops`; `createOtelExporter` attached via `composeRuntimeHooks(...)` — root `.` | canonical-api §2 |
101
- | **State any A/B claim** | `pairedLift` (bench) over `pairedBootstrap`/`heldoutSignificance` (substrate) | canonical-api §3.5 |
102
- | **Observe + deliver on a live agent with billing-boundary** | `withIntelligence(agent, { project, target, effort })` — `/intelligence` | canonical-api §2 |
103
- | **Pull the certified profile from the Intelligence plane** (pull-by-default delivery: fold the gate-certified prompt onto the base surface) | `pullCertified` / `withIntelligence` / `composeCertifiedPrompt` — `/intelligence` | `src/intelligence/delivery.ts` |
104
-
105
- ## Do-NOT-reinvent the traps this skill exists to stop
106
-
107
- Each of these gets hand-rolled every session; the canonical primitive already
108
- holds the load-bearing invariant the parallel breaks:
109
-
110
- - `runConversation` / persona-runner / `while(!done)` steering loop **≈**
111
- `loopUntil` + `runPersonified` (threads executor seams; equal-k; selector≠judge
112
- firewall; journal/replay — a parallel runner silently fails to wire the seams).
113
- - "skill optimizer" / "topology mutator" that opens branches + applies patches
114
- **≈** `improvementDriver` (code surface) or `selfImprove`/`gepaProposer` (prompt
115
- surface) both gated on a frozen holdout.
116
- - "profile-seam" / agent-config wrapper carrying model+prompt+tools+role **≈**
117
- `AgentProfile` (it IS that bundle) + `definePersona` (the run record);
118
- `sandboxAgentRun({ profile })` is the box seam — never pass a router key into
119
- the box.
120
- - "drive N coding agents in worktrees + pick the passing patch" / a "coder" role
121
- **≈** `worktreeFanout` + `gateOnDeliverable` (each on its own worktree-CLI leaf,
122
- settled ⟺ delivered, winner via `selectValidWinner` — a hand-rolled spawn-loop
123
- skips the deliverable gate and the valid-only selection).
124
- - `new Sandbox()` + acquire + stream + `box.fs.read` + delete **≈**
125
- `openSandboxRun` (persistent + resume) or `runLoop` (fresh box/round).
126
- - `Promise.all` over N calls + manual argmax/merge **≈** `fanout` (bypassing the
127
- budget pool breaks equal-compute claims).
128
- - a per-step cost/token tally over events **≈** `createWaterfallCollector` (the
129
- sum of spans IS the billed run cost; a parallel tally drifts).
130
- - your own bootstrap loop / PRNG per gate **≈** `pairedLift` / `promotionGate`
131
- (seeded, identical run-to-run; never report a point lift without `low/high/pairs`).
132
- - a per-product `HARNESSES` / `HarnessBackend` list + a metadata-harness reader
133
- **≈** `CODING_HARNESSES` + `expandProfileAxes` (the one canonical harness list;
134
- vendor-locked harnesses SNAP to their native model via `HARNESS_NATIVE_MODEL`,
135
- never dropped) and the
136
- `AgentProfileCell` stamped by `runProfileMatrix`, pivoted via
137
- `groupRunsByAgentProfileCell` — never bake the harness into the model id so the
138
- same model can run under multiple harnesses.
139
- - a per-product leaderboard CLI (flag parsing + run-dir management + axis
140
- expansion + a `runProfileMatrix` call + export/markdown) **≈**
141
- `defineLeaderboard` (0.84+; it owns that whole frame — FRESH default run-dir,
142
- standard `--backend`/`--harnesses`/`--models`/`--cases`/`--shots`/`--reps`
143
- flags, `toBenchmarkAdapter()`; the product writes ~150-250 domain lines).
144
- - a backend factory / `if (backend === 'router') ... else ...` branch or a
145
- hand-faked box around a non-box executor **≈** `resolveSandboxClient`
146
- (harness-in-box: `'sandbox' | 'bridge' | 'router'`) or `resolveAgentBackend`
147
- (in-process: `'router' | 'tcloud' | 'cli-bridge' | 'sandbox'`) — grep the
148
- substrate first; `inlineSandboxClient` and the bridge executor exist.
149
- - a per-provider stream→event mapper for a single agent turn **≈**
150
- `streamAgentTurn` + `collectAgentTurn` (0.85+; one `RuntimeStreamEvent`
151
- contract over box / executor / chat, guaranteed terminal result+usage).
152
-
153
- ## End-to-end recipe
154
-
155
- `docs/canonical-api.md` §4 is the real composition — copy it from there, don't
156
- re-derive: **define a genome → run driver⟷worker via the reactive substrate over
157
- a multi-turn `AgenticSurface` → measure with `runBenchmark` → optimize a prompt
158
- surface with `selfImprove` → certify on a frozen holdout with the gate.** For the
159
- multi-generation flywheel, replace the measure/certify steps with one
160
- `runStrategyEvolution(...)` and read `report.verdict` (NOT `report.trajectory`)
161
- as the evidence. For a sandbox coding rollout judged by an external deterministic
162
- checker, use the bench-gate path: `resolveAdapter(...)` to pick the benchmark,
163
- then `openSandboxRun(client, { agentRun: sandboxAgentRun({ profile }), ... },
164
- deliverable)` per task, A/B-ing a blind arm against an `llmAnalyst`-steered arm
165
- at equal compute (both helpers live in `bench/src/sandbox-run.ts`; the blind arm
166
- is the mandatory equal-compute control). See `bench/src/commit0-gate.mts` /
167
- `gate.ts` for the live shape.
168
-
169
- ## Two substrates — pick one, don't invent a third
170
-
171
- Both implement the same recursive-decision atom over the one `Executor` port and
172
- share `defaultSelectWinner`. **Reactive** (`Supervisor`/`Scope` + personify
173
- combinators: `runPersonified`/`runAgentic`/`runBenchmark`) — prefer for NEW
174
- recursive work; equal-k by construction. **Round-synchronous** (`runLoop` driven
175
- by a caller-supplied `Driver`, plus the bench gates over `openSandboxRun`) —
176
- sandbox coding rollouts against external benchmarks. The full when-which map is
177
- `docs/canonical-api.md` §6.
178
-
179
- ## Observe / ship with the Intelligence SDK
180
-
181
- One hook wraps any agent with send + receive + billing boundary:
182
- `withIntelligence(agent, { project, target, effort })`, `effort ∈
183
- off|eco|standard|thorough|max` (`'off'` is the provable passthrough floor —
184
- intelligence spend clamped to 0). It SENDs a typed `RunRecord` and RECEIVEs the
185
- certified profile, building on `createOtelExporter` + `buildLoopOtelSpans` —
186
- don't hand-roll a trace-wrapper, a second receive path, or effort/tier config.
187
- Verify the live subpath against `src/intelligence/with-intelligence.ts`.
188
-
189
- Two operational facts every consumer must know:
190
-
191
- - **Send is a silent no-op without a tenant apiKey.** The export leg only ships
192
- when an `apiKey` (or `TANGLE_API_KEY`) is present — the ingest requires the
193
- tenant Bearer. One `baseUrl` (`TANGLE_INTELLIGENCE_URL`, default
194
- `https://intelligence.tangle.tools`) drives both the OTLP send (`/v1/otlp`)
195
- and the receive pull. The client's `doctor().exportConfigured` is the check
196
- that a send will actually land.
197
- - **Delivery pulls the certified profile from the plane.** `pullCertified` /
198
- `withIntelligence` hit
199
- `GET {baseUrl}/v1/profiles/:target/composed` with `Bearer TANGLE_API_KEY`;
200
- the pull deserializes the typed `agentProfileDiffs` (surfaced as PROPOSALS,
201
- never auto-applied) alongside the certified prompt. `withIntelligence` folds
202
- the certified prompt onto the base surface, refreshes at most every 5 minutes,
203
- and is fail-closed — a failed pull runs the agent on its base surface.
204
-
205
- ## Final check
206
-
207
- - Picked a primitive from the decision table, not a hand-rolled parallel?
208
- - Genome is ONE `AgentProfile`/`AgentSurfaces` surface, not split skill/tool/prompt knobs?
209
- - Equal compute preserved (budget pool, or `arms[0]` control) — no `Promise.all` zoo?
210
- - Selector ≠ judge: no judge score feeding a driver/another judge; holdout score write-only?
211
- - Any win certified on a FROZEN holdout via a gate, never on the training composite?
212
- - Map fixed in the same turn if source disagreed with `docs/canonical-api.md`?
213
-
214
- See `_common.md` for shared conventions (frontmatter, fail-loud, no AI attribution).
215
-
216
- Next: build the genome/loop/optimizer against `docs/canonical-api.md` §3–§4; if a
217
- strategy beats incumbent on the holdout gate, `/ship` it.
6
+ # Build with agent-runtime
7
+
8
+ Use this skill before writing product-local agent infrastructure.
9
+ The goal is one portable agent definition, one execution path, one measurement system, and one reviewed activation path.
10
+
11
+ ## Read first
12
+
13
+ 1. Read `docs/canonical-api.md` for the current decision table.
14
+ 2. Check exports in `src/index.ts`, `src/runtime/index.ts`, `src/improvement/index.ts`, `src/intelligence/index.ts`, and `src/knowledge/index.ts`.
15
+ 3. Read the nearest runnable example.
16
+ 4. Treat source as authoritative when docs disagree, then correct the stale doc in the same change.
17
+
18
+ ## Ownership
19
+
20
+ | Concern | Owner |
21
+ |---|---|
22
+ | Portable prompt, skills, tools, MCP, hooks, subagents, model hints | `AgentProfile` from `@tangle-network/agent-interface` |
23
+ | Agent execution, supervision, budgets, streaming, candidate execution | `@tangle-network/agent-runtime` |
24
+ | Tasks, graders, search, paired statistics, cost and latency comparison | `@tangle-network/agent-eval` |
25
+ | Sources, retrieval, citations, freshness, memory adapters, knowledge promotion | `@tangle-network/agent-knowledge` |
26
+ | Product records, permissions, funding, UI, and atomic storage writes | The consuming product |
27
+
28
+ Do not move shared measurement into Runtime or product code.
29
+ Do not move product storage transactions into a provider-neutral package.
30
+
31
+ ## Choose the entry point
32
+
33
+ | Need | Use |
34
+ |---|---|
35
+ | One product chat turn | `handleChatTurn(...)` |
36
+ | One normalized streamed agent turn | `streamAgentTurn(...)` and `collectAgentTurn(...)` |
37
+ | One task or multi-turn loop | `runAgentTask(...)`, `runAgentTaskStream(...)`, or `runLoop(...)` |
38
+ | Supervisor and workers | `supervise(...)` or `superviseSurface(...)` |
39
+ | Parallel work with a shared budget | `fanout(...)` |
40
+ | Fixed composition | `pipeline(...)`, `panel(...)`, or `verify(...)` |
41
+ | Product benchmark | `defineLeaderboard(...)` |
42
+ | Profile matrix | `expandProfileAxes(...)` and `runProfileMatrix(...)` from agent-eval |
43
+ | Search one agent surface | `improve(...)` |
44
+ | Analyze traces through a measured proposal | `proposeAgentImprovement(...)` |
45
+ | Review and authorize an exact proposal | `reviewAgentImprovementProposal(...)` and `createAgentImprovementActivation(...)` |
46
+ | Apply or restore an approved candidate | `executeAgentImprovementActivation(...)` with a product transaction |
47
+ | Build a knowledge candidate | `runKnowledgeImprovementJob(...)` |
48
+ | Apply a knowledge candidate | `createKnowledgeImprovementActivationExecutor(...)` through the same activation path |
49
+ | Observe and pull approved changes on a live agent | `withIntelligence(...)` |
50
+
51
+ ## Improvement flow
52
+
53
+ `improve(profile, findings, options)` searches one surface and returns a detached winner.
54
+ It never changes a profile, document, repository, memory store, or knowledge base.
55
+
56
+ Supported profile surfaces are prompt, one named inline skill, tools, MCP, hooks, subagents, whole profile, and curated memory in `profile.resources.instructions`.
57
+ Code uses isolated worktrees and returns a sealed patch candidate.
58
+ Knowledge uses `runKnowledgeImprovementJob(...)` and returns paired snapshots.
59
+
60
+ Use `proposeAgentImprovement(...)` for a production proposal.
61
+ It performs these steps in order:
62
+
63
+ 1. Analyze completed traces.
64
+ 2. Search for a candidate on development tasks.
65
+ 3. Freeze the baseline and winner into one exact experiment.
66
+ 4. Reject the experiment if its candidate differs from the search winner.
67
+ 5. Run baseline and candidate on the same held-back tasks.
68
+ 6. Produce findings, confidence intervals, quality, cost, latency, and a decision.
69
+
70
+ After a person or tenant policy approves the proposal, call `createAgentImprovementActivation(...)` with target identities, funding owner, authority, intent, and expiry.
71
+ Runtime derives the expected current digests from the measured experiment.
72
+ Call `executeAgentImprovementActivation(...)` with one product-owned transaction that compares current state, writes every target atomically, and stores the result under the activation digest.
73
+ Pass a read-only reconciliation function so retries can distinguish committed, uncommitted, and uncertain outcomes.
74
+
75
+ Never apply a change from analyst confidence alone.
76
+ Never measure one candidate and apply another.
77
+ Never let search code write live state.
78
+ Never treat a lost response as a failed write without reconciling it.
79
+
80
+ ## Surface rules
81
+
82
+ - Prompt changes `profile.prompt` only.
83
+ - Skill optimization selects one inline skill by `skills.resourceName`; profile resources must fail closed.
84
+ - Curated memory changes `profile.resources.instructions`; retrieval stores and memory databases belong in the knowledge flow.
85
+ - Tools, MCP, hooks, subagents, and whole-profile changes require an explicit proposer because Runtime cannot invent domain capabilities safely.
86
+ - Code candidates must come from the Runtime worktree path so patch identity and cleanup stay intact.
87
+ - Workflow and policy files are code surfaces; parameter sweeps come from agent-eval.
88
+ - Knowledge candidates remain detached until the shared activation path applies or restores their frozen snapshots.
89
+
90
+ ## Product integration
91
+
92
+ The product supplies only the pieces that vary by deployment:
93
+
94
+ - How traces and current profiles are loaded.
95
+ - How exact candidate execution is placed on compute.
96
+ - How proposal, review, activation, and result records are persisted.
97
+ - How a target is changed atomically.
98
+ - Who may approve, reject, request changes, fund, apply, or restore.
99
+ - How those records and actions appear in the UI or API.
100
+
101
+ The product must not recreate candidate hashing, paired comparison, confidence intervals, review binding, expiry, retry identity, or result validation.
102
+
103
+ ## Do not duplicate
104
+
105
+ - Do not write a provider-specific profile wrapper; extend `AgentProfile` and its materializer.
106
+ - Do not write a second optimizer loop; compose Eval proposers through `improve(...)`.
107
+ - Do not write a second candidate catalog; persist the immutable proposal records.
108
+ - Do not let an analyst or adapter commit, push, open a pull request, or edit a live store.
109
+ - Do not hand-roll SSE parsing, usage totals, profile matrices, bootstrap statistics, sandbox acquisition, or worktree cleanup.
110
+ - Do not add a product-local approval format for knowledge, code, or profile changes.
111
+
112
+ ## Finish
113
+
114
+ - The same agent definition runs in product and measurement paths.
115
+ - The held-back tasks were not visible during search.
116
+ - Candidate identity is checked before execution and again before activation.
117
+ - Quality, cost, latency, sample count, and uncertainty are retained.
118
+ - Rejection and request-changes are first-class outcomes.
119
+ - Activation is authorized, expiring, idempotent, and reconcilable.
120
+ - No customer write, message, trigger, or billing occurs in read-only proof mode.
121
+ - Public examples, package exports, generated API docs, type checks, tests, build, and package verification pass.
122
+
123
+ ## Then consider
124
+
125
+ - Use `critical-audit` when the change introduces or alters a public contract.
126
+ - Use `verify` before publishing or adopting the package in a product.
@@ -1,142 +0,0 @@
1
- // src/improvement/build-prompts.ts
2
- function findingLines(findings) {
3
- return findings.map((f) => {
4
- const where = f.subject ? ` [${f.subject}]` : "";
5
- const action = f.recommended_action ? ` \u2192 ${f.recommended_action}` : "";
6
- return `- (${f.severity})${where} ${f.claim}${action}`;
7
- });
8
- }
9
- function toolBuildPrompt(args) {
10
- return [
11
- "You are building a new TOOL for this codebase to address the gaps below.",
12
- "Write the tool as a small, self-contained module PLUS tests that exercise it.",
13
- "The tool must compile and its tests must pass \u2014 they will be run automatically;",
14
- "if verification fails you will get the error and another attempt. Do not commit;",
15
- "leave the changes in the working tree.",
16
- "",
17
- "Gaps the tool should close:",
18
- ...findingLines(args.findings)
19
- ].join("\n");
20
- }
21
- function mcpBuildPrompt(args) {
22
- return [
23
- "You are building a new MCP SERVER (Model Context Protocol) that exposes",
24
- "tool(s) addressing the gaps below, so any harness can mount it.",
25
- "Requirements that WILL be checked by booting the server:",
26
- "- it starts over stdio and answers the MCP `initialize` handshake,",
27
- "- `tools/list` returns at least one tool with a valid input schema.",
28
- "Newline-delimited JSON-RPC 2.0, protocol version 2024-11-05. Include a start",
29
- "command (e.g. a package.json `start` script or a clear entrypoint). If the",
30
- "boot-and-probe fails you will get the error and another attempt. Do not",
31
- "commit; leave the changes in the working tree.",
32
- "",
33
- "Capabilities the server should provide:",
34
- ...findingLines(args.findings)
35
- ].join("\n");
36
- }
37
-
38
- // src/improvement/mcp-serve-verifier.ts
39
- import { spawn } from "child_process";
40
- import { createInterface } from "readline";
41
- var PROTOCOL_VERSION = "2024-11-05";
42
- function mcpServeVerifier(spec) {
43
- const timeoutMs = spec.timeoutMs ?? 3e4;
44
- const minTools = spec.minTools ?? 1;
45
- return (worktreePath) => new Promise((resolve, reject) => {
46
- const child = spawn(spec.command, spec.args ?? [], {
47
- cwd: worktreePath,
48
- stdio: ["pipe", "pipe", "pipe"],
49
- env: { ...process.env, ...spec.env }
50
- });
51
- const stderr = [];
52
- let settled = false;
53
- let nextId = 1;
54
- const initId = nextId++;
55
- let listId = -1;
56
- const settle = (fn) => {
57
- if (settled) return;
58
- settled = true;
59
- clearTimeout(timer);
60
- rl.close();
61
- child.kill("SIGKILL");
62
- fn();
63
- };
64
- const withStderr = (msg) => stderr.length > 0 ? `${msg}
65
- stderr:
66
- ${stderr.join("").slice(-2e3)}` : msg;
67
- const pass = () => settle(() => resolve({ ok: true }));
68
- const failCandidate = (msg) => settle(() => resolve({ ok: false, feedback: withStderr(msg) }));
69
- const setupFault = (err) => settle(() => reject(err));
70
- const failStdin = (err) => failCandidate(`writing to MCP server stdin failed: ${err.message}`);
71
- const send = (msg) => {
72
- try {
73
- child.stdin.write(`${JSON.stringify(msg)}
74
- `);
75
- return true;
76
- } catch (err) {
77
- failStdin(err);
78
- return false;
79
- }
80
- };
81
- child.on("error", (err) => {
82
- const code = err.code;
83
- setupFault(
84
- code === "ENOENT" ? new Error(
85
- `mcpServeVerifier: '${spec.command}' not found in PATH (setup bug, not a failed candidate)`
86
- ) : new Error(`mcpServeVerifier: '${spec.command}' failed to spawn: ${err.message}`)
87
- );
88
- });
89
- child.on("exit", (code, signal) => {
90
- failCandidate(`MCP server exited (code ${code}, signal ${signal}) before serving`);
91
- });
92
- child.stdin.on("error", failStdin);
93
- child.stderr.on("data", (d) => stderr.push(String(d)));
94
- const rl = createInterface({ input: child.stdout });
95
- rl.on("line", (line) => {
96
- let msg;
97
- try {
98
- msg = JSON.parse(line);
99
- } catch {
100
- return;
101
- }
102
- if (!msg || typeof msg !== "object") return;
103
- if (msg.id === initId) {
104
- if (msg.error) return failCandidate(`initialize errored: ${JSON.stringify(msg.error)}`);
105
- if (!send({ jsonrpc: "2.0", method: "notifications/initialized" })) return;
106
- listId = nextId++;
107
- send({ jsonrpc: "2.0", id: listId, method: "tools/list" });
108
- return;
109
- }
110
- if (msg.id === listId) {
111
- if (msg.error) return failCandidate(`tools/list errored: ${JSON.stringify(msg.error)}`);
112
- const tools = msg.result?.tools;
113
- if (!Array.isArray(tools)) return failCandidate("tools/list result has no tools array");
114
- if (tools.length < minTools) {
115
- return failCandidate(`tools/list returned ${tools.length} tool(s), need >= ${minTools}`);
116
- }
117
- return pass();
118
- }
119
- });
120
- const timer = setTimeout(
121
- () => failCandidate(`MCP server did not complete the handshake within ${timeoutMs}ms`),
122
- timeoutMs
123
- );
124
- send({
125
- jsonrpc: "2.0",
126
- id: initId,
127
- method: "initialize",
128
- params: {
129
- protocolVersion: PROTOCOL_VERSION,
130
- capabilities: {},
131
- clientInfo: { name: "agent-runtime-mcp-verify", version: "0" }
132
- }
133
- });
134
- });
135
- }
136
-
137
- export {
138
- toolBuildPrompt,
139
- mcpBuildPrompt,
140
- mcpServeVerifier
141
- };
142
- //# sourceMappingURL=chunk-6O73TRHW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/improvement/build-prompts.ts","../src/improvement/mcp-serve-verifier.ts"],"sourcesContent":["/**\n * Build-prompt starting points for the two buildable artifact types. There is\n * NO `toolGenerator`/`mcpGenerator` wrapper — the factory is `agenticGenerator`\n * + a verifier (docs/artifact-lifecycle-frontier.md), so a tool or an MCP\n * server is built by composing the pieces directly:\n *\n * // a tool:\n * agenticGenerator({ buildPrompt: toolBuildPrompt, verify: commandVerifier('pnpm', ['test']) })\n * // an MCP server:\n * agenticGenerator({ buildPrompt: mcpBuildPrompt, verify: mcpServeVerifier({ command: 'node', args: ['server.mjs'] }) })\n *\n * These are the only type-specific bit (the phrasing that points the agent at a\n * tool vs. an MCP); the worktree, resume-on-failure loop, and improvement-loop\n * wrapper are shared. MCP is the load-bearing target — it is how a harness\n * acquires tools; raw tools matter where we control the loader.\n */\n\nimport type { AnalystFinding } from '@tangle-network/agent-eval'\n\ntype FindingsArg = { report: unknown; findings: AnalystFinding[] }\n\nfunction findingLines(findings: AnalystFinding[]): string[] {\n return findings.map((f) => {\n const where = f.subject ? ` [${f.subject}]` : ''\n const action = f.recommended_action ? ` → ${f.recommended_action}` : ''\n return `- (${f.severity})${where} ${f.claim}${action}`\n })\n}\n\n/** Build the starting instruction for a coder agent tasked with implementing a new tool. */\nexport function toolBuildPrompt(args: FindingsArg): string {\n return [\n 'You are building a new TOOL for this codebase to address the gaps below.',\n 'Write the tool as a small, self-contained module PLUS tests that exercise it.',\n 'The tool must compile and its tests must pass — they will be run automatically;',\n 'if verification fails you will get the error and another attempt. Do not commit;',\n 'leave the changes in the working tree.',\n '',\n 'Gaps the tool should close:',\n ...findingLines(args.findings),\n ].join('\\n')\n}\n\n/** Build the starting instruction for a coder agent tasked with implementing a new MCP server. */\nexport function mcpBuildPrompt(args: FindingsArg): string {\n return [\n 'You are building a new MCP SERVER (Model Context Protocol) that exposes',\n 'tool(s) addressing the gaps below, so any harness can mount it.',\n 'Requirements that WILL be checked by booting the server:',\n '- it starts over stdio and answers the MCP `initialize` handshake,',\n '- `tools/list` returns at least one tool with a valid input schema.',\n 'Newline-delimited JSON-RPC 2.0, protocol version 2024-11-05. Include a start',\n 'command (e.g. a package.json `start` script or a clear entrypoint). If the',\n 'boot-and-probe fails you will get the error and another attempt. Do not',\n 'commit; leave the changes in the working tree.',\n '',\n 'Capabilities the server should provide:',\n ...findingLines(args.findings),\n ].join('\\n')\n}\n","/**\n * `mcpServeVerifier` — the intrinsic verifier for a built MCP server: the\n * boot-and-probe checker named in docs/artifact-lifecycle-frontier.md. A\n * generated MCP server is only a candidate if it actually *serves* — so this\n * boots it over stdio (the default local MCP transport) and runs the real\n * handshake: `initialize` → `notifications/initialized` → `tools/list`, and\n * asserts the server answers with at least `minTools` tools.\n *\n * Outcomes follow the `Verifier` contract: a server that fails to start, exits\n * early, errors the handshake, times out, or exposes no tools is a FAILED\n * candidate (`{ok:false}`, fed back into the next generation shot); a missing\n * start binary or spawn fault THROWS (a setup bug, never a silent fallback).\n *\n * Protocol matches the runtime's own stdio MCP server (src/mcp/server.ts):\n * newline-delimited JSON-RPC 2.0, protocol version 2024-11-05.\n */\n\nimport { spawn } from 'node:child_process'\nimport { createInterface } from 'node:readline'\nimport type { Verifier, VerifyResult } from './agentic-generator'\n\nconst PROTOCOL_VERSION = '2024-11-05'\n\nexport interface McpServeSpec {\n /** Command that starts the built MCP server in the worktree (stdio transport). */\n command: string\n args?: string[]\n /** Extra env for the server process (merged over `process.env`). */\n env?: Record<string, string>\n /** Handshake timeout (ms). Default 30s. */\n timeoutMs?: number\n /** Minimum tools the server must expose to pass. Default 1. */\n minTools?: number\n}\n\ninterface JsonRpcResponse {\n jsonrpc?: string\n id?: number | string | null\n result?: unknown\n error?: { code: number; message: string }\n}\n\n/** Build a `Verifier` that boots a generated MCP server over stdio and checks it exposes tools. */\nexport function mcpServeVerifier(spec: McpServeSpec): Verifier {\n const timeoutMs = spec.timeoutMs ?? 30_000\n const minTools = spec.minTools ?? 1\n\n return (worktreePath: string): Promise<VerifyResult> =>\n new Promise<VerifyResult>((resolve, reject) => {\n const child = spawn(spec.command, spec.args ?? [], {\n cwd: worktreePath,\n stdio: ['pipe', 'pipe', 'pipe'],\n env: { ...process.env, ...spec.env },\n })\n\n const stderr: string[] = []\n let settled = false\n let nextId = 1\n const initId = nextId++\n let listId = -1\n\n const settle = (fn: () => void) => {\n if (settled) return\n settled = true\n clearTimeout(timer)\n rl.close()\n child.kill('SIGKILL')\n fn()\n }\n const withStderr = (msg: string) =>\n stderr.length > 0 ? `${msg}\\nstderr:\\n${stderr.join('').slice(-2000)}` : msg\n const pass = () => settle(() => resolve({ ok: true }))\n const failCandidate = (msg: string) =>\n settle(() => resolve({ ok: false, feedback: withStderr(msg) }))\n const setupFault = (err: Error) => settle(() => reject(err))\n const failStdin = (err: Error) =>\n failCandidate(`writing to MCP server stdin failed: ${err.message}`)\n\n const send = (msg: Record<string, unknown>): boolean => {\n try {\n child.stdin.write(`${JSON.stringify(msg)}\\n`)\n return true\n } catch (err) {\n // EPIPE: the server died mid-handshake — a failed candidate, not a fault.\n failStdin(err as Error)\n return false\n }\n }\n\n child.on('error', (err) => {\n const code = (err as NodeJS.ErrnoException).code\n setupFault(\n code === 'ENOENT'\n ? new Error(\n `mcpServeVerifier: '${spec.command}' not found in PATH (setup bug, not a failed candidate)`,\n )\n : new Error(`mcpServeVerifier: '${spec.command}' failed to spawn: ${err.message}`),\n )\n })\n child.on('exit', (code, signal) => {\n // An exit before the handshake completes is a failed candidate (the\n // server crashed on boot); after we settle, our own SIGKILL fires here.\n failCandidate(`MCP server exited (code ${code}, signal ${signal}) before serving`)\n })\n // Pipe failures normally arrive asynchronously, outside send()'s try/catch.\n child.stdin.on('error', failStdin)\n child.stderr.on('data', (d) => stderr.push(String(d)))\n\n const rl = createInterface({ input: child.stdout })\n rl.on('line', (line) => {\n let msg: JsonRpcResponse | undefined\n try {\n msg = JSON.parse(line) as JsonRpcResponse\n } catch {\n return // servers log to stdout too; skip non-JSON lines\n }\n if (!msg || typeof msg !== 'object') return\n\n if (msg.id === initId) {\n if (msg.error) return failCandidate(`initialize errored: ${JSON.stringify(msg.error)}`)\n if (!send({ jsonrpc: '2.0', method: 'notifications/initialized' })) return\n listId = nextId++\n send({ jsonrpc: '2.0', id: listId, method: 'tools/list' })\n return\n }\n if (msg.id === listId) {\n if (msg.error) return failCandidate(`tools/list errored: ${JSON.stringify(msg.error)}`)\n const tools = (msg.result as { tools?: unknown[] } | undefined)?.tools\n if (!Array.isArray(tools)) return failCandidate('tools/list result has no tools array')\n if (tools.length < minTools) {\n return failCandidate(`tools/list returned ${tools.length} tool(s), need >= ${minTools}`)\n }\n return pass()\n }\n })\n\n const timer = setTimeout(\n () => failCandidate(`MCP server did not complete the handshake within ${timeoutMs}ms`),\n timeoutMs,\n )\n\n send({\n jsonrpc: '2.0',\n id: initId,\n method: 'initialize',\n params: {\n protocolVersion: PROTOCOL_VERSION,\n capabilities: {},\n clientInfo: { name: 'agent-runtime-mcp-verify', version: '0' },\n },\n })\n })\n}\n"],"mappings":";AAqBA,SAAS,aAAa,UAAsC;AAC1D,SAAO,SAAS,IAAI,CAAC,MAAM;AACzB,UAAM,QAAQ,EAAE,UAAU,KAAK,EAAE,OAAO,MAAM;AAC9C,UAAM,SAAS,EAAE,qBAAqB,WAAM,EAAE,kBAAkB,KAAK;AACrE,WAAO,MAAM,EAAE,QAAQ,IAAI,KAAK,IAAI,EAAE,KAAK,GAAG,MAAM;AAAA,EACtD,CAAC;AACH;AAGO,SAAS,gBAAgB,MAA2B;AACzD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG,aAAa,KAAK,QAAQ;AAAA,EAC/B,EAAE,KAAK,IAA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