@tangle-network/agent-runtime 0.105.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.
Files changed (218) hide show
  1. package/README.md +2 -2
  2. package/dist/activation-CRjVfOiy.js +203 -0
  3. package/dist/activation-CRjVfOiy.js.map +1 -0
  4. package/dist/activation-DyWB0K6E.d.ts +98 -0
  5. package/dist/agent.d.ts +216 -234
  6. package/dist/agent.js +615 -547
  7. package/dist/agent.js.map +1 -1
  8. package/dist/analyst-loop-DGdtVENg.js +517 -0
  9. package/dist/analyst-loop-DGdtVENg.js.map +1 -0
  10. package/dist/analyst-loop.d.ts +10 -43
  11. package/dist/analyst-loop.js +2 -11
  12. package/dist/backends-Dy8NujB4.js +713 -0
  13. package/dist/backends-Dy8NujB4.js.map +1 -0
  14. package/dist/candidate-execution/index.d.ts +4 -192
  15. package/dist/candidate-execution/index.js +5 -66
  16. package/dist/candidate-execution-DqMbv1rU.js +488 -0
  17. package/dist/candidate-execution-DqMbv1rU.js.map +1 -0
  18. package/dist/coder-yhVWbdWc.js +40 -0
  19. package/dist/coder-yhVWbdWc.js.map +1 -0
  20. package/dist/conversation-XucG_K3l.js +1265 -0
  21. package/dist/conversation-XucG_K3l.js.map +1 -0
  22. package/dist/conversation.d.ts +2 -804
  23. package/dist/conversation.js +2 -55
  24. package/dist/environment-provider-CfLUmKmf.js +1168 -0
  25. package/dist/environment-provider-CfLUmKmf.js.map +1 -0
  26. package/dist/environment-provider-IUGU3epE.d.ts +964 -0
  27. package/dist/environment-provider.d.ts +2 -78
  28. package/dist/environment-provider.js +2 -18
  29. package/dist/errors-DEAvWQPy.js +111 -0
  30. package/dist/errors-DEAvWQPy.js.map +1 -0
  31. package/dist/improvement-adapter-Cr5TBSji.d.ts +166 -0
  32. package/dist/improvement-cycle-C095kS_g.js +2624 -0
  33. package/dist/improvement-cycle-C095kS_g.js.map +1 -0
  34. package/dist/index-BGdxAwfO.d.ts +838 -0
  35. package/dist/index-C-FYUuFG.d.ts +193 -0
  36. package/dist/index-CbNM40xG.d.ts +140 -0
  37. package/dist/index-DruSKs3Z.d.ts +7224 -0
  38. package/dist/index-Efjb3nrQ.d.ts +671 -0
  39. package/dist/index.d.ts +14 -1058
  40. package/dist/index.js +2106 -2082
  41. package/dist/index.js.map +1 -1
  42. package/dist/intelligence.d.ts +768 -889
  43. package/dist/intelligence.js +1466 -1367
  44. package/dist/intelligence.js.map +1 -1
  45. package/dist/{kb-gate-CwHO0vz6.d.ts → kb-gate-C8z2juK8.d.ts} +33 -31
  46. package/dist/kb-gate-DpaSwXVx.js +80 -0
  47. package/dist/kb-gate-DpaSwXVx.js.map +1 -0
  48. package/dist/knowledge-Ku-mPP4f.js +433 -0
  49. package/dist/knowledge-Ku-mPP4f.js.map +1 -0
  50. package/dist/knowledge.d.ts +2 -150
  51. package/dist/knowledge.js +2 -40
  52. package/dist/local-harness-Dh8PJ0ot.d.ts +455 -0
  53. package/dist/loop-runner-bin-BXsFEUcf.d.ts +162 -0
  54. package/dist/loop-runner-bin-BwjQ1NfH.js +268 -0
  55. package/dist/loop-runner-bin-BwjQ1NfH.js.map +1 -0
  56. package/dist/loop-runner-bin.d.ts +2 -15
  57. package/dist/loop-runner-bin.js +2 -24
  58. package/dist/loops.d.ts +5 -4164
  59. package/dist/loops.js +8 -419
  60. package/dist/mcp/bin.d.ts +1 -1
  61. package/dist/mcp/bin.js +116 -146
  62. package/dist/mcp/bin.js.map +1 -1
  63. package/dist/mcp/index.d.ts +295 -436
  64. package/dist/mcp/index.js +1242 -1177
  65. package/dist/mcp/index.js.map +1 -1
  66. package/dist/mcp/memory-bin.d.ts +1 -1
  67. package/dist/mcp/memory-bin.js +37 -16
  68. package/dist/mcp/memory-bin.js.map +1 -1
  69. package/dist/memory-server-DL6cE2Ag.js +234 -0
  70. package/dist/memory-server-DL6cE2Ag.js.map +1 -0
  71. package/dist/model-resolution-Btd9iIKV.js +98 -0
  72. package/dist/model-resolution-Btd9iIKV.js.map +1 -0
  73. package/dist/openai-tools-B68JaOCx.d.ts +24 -0
  74. package/dist/openai-tools-CKLy1C7M.js +44 -0
  75. package/dist/openai-tools-CKLy1C7M.js.map +1 -0
  76. package/dist/otel-export-D34IQW1C.js +843 -0
  77. package/dist/otel-export-D34IQW1C.js.map +1 -0
  78. package/dist/platform.d.ts +188 -185
  79. package/dist/platform.js +185 -218
  80. package/dist/platform.js.map +1 -1
  81. package/dist/prepare-B53sPV7M.js +4292 -0
  82. package/dist/prepare-B53sPV7M.js.map +1 -0
  83. package/dist/primeintellect/index.d.ts +149 -145
  84. package/dist/primeintellect/index.js +626 -1003
  85. package/dist/primeintellect/index.js.map +1 -1
  86. package/dist/profiles.d.ts +296 -490
  87. package/dist/profiles.js +722 -749
  88. package/dist/profiles.js.map +1 -1
  89. package/dist/protected-model-port-BLPH5VVv.js +722 -0
  90. package/dist/protected-model-port-BLPH5VVv.js.map +1 -0
  91. package/dist/protected-model-port-BP6Z4eau.d.ts +283 -0
  92. package/dist/protected-redaction--F3v1oo8.js +200 -0
  93. package/dist/protected-redaction--F3v1oo8.js.map +1 -0
  94. package/dist/redact-D-u-rrcn.js +82 -0
  95. package/dist/redact-D-u-rrcn.js.map +1 -0
  96. package/dist/redact-kbIOjfjM.d.ts +452 -0
  97. package/dist/researcher-CoVqNhfI.js +433 -0
  98. package/dist/researcher-CoVqNhfI.js.map +1 -0
  99. package/dist/runtime-BG0BziaP.js +5408 -0
  100. package/dist/runtime-BG0BziaP.js.map +1 -0
  101. package/dist/sandbox-events-DeI5xX8P.js +316 -0
  102. package/dist/sandbox-events-DeI5xX8P.js.map +1 -0
  103. package/dist/spawn-journal-CwPvKUTa.js +456 -0
  104. package/dist/spawn-journal-CwPvKUTa.js.map +1 -0
  105. package/dist/structural-rollout-IXUEplky.js +1445 -0
  106. package/dist/structural-rollout-IXUEplky.js.map +1 -0
  107. package/dist/substrate-B0TYNrXn.js +27 -0
  108. package/dist/substrate-B0TYNrXn.js.map +1 -0
  109. package/dist/{substrate-Dyiqmd3o.d.ts → substrate-BcnuSHXm.d.ts} +57 -54
  110. package/dist/supervise-BiRutHS9.js +7321 -0
  111. package/dist/supervise-BiRutHS9.js.map +1 -0
  112. package/dist/supervisor-DTKhF-RV.js +3826 -0
  113. package/dist/supervisor-DTKhF-RV.js.map +1 -0
  114. package/dist/testing.d.ts +4 -3
  115. package/dist/testing.js +2478 -2637
  116. package/dist/testing.js.map +1 -1
  117. package/dist/tool-server-RcWgLIsL.js +141 -0
  118. package/dist/tool-server-RcWgLIsL.js.map +1 -0
  119. package/dist/trace-propagation-CJJC7SVB.js +57 -0
  120. package/dist/trace-propagation-CJJC7SVB.js.map +1 -0
  121. package/dist/types-BaIpb0XT.d.ts +492 -0
  122. package/dist/types-BevOjfTY.d.ts +765 -0
  123. package/dist/types-C9j4qg6l.d.ts +500 -0
  124. package/dist/types-Cja5OTGh.d.ts +190 -0
  125. package/dist/util-MVgdwuIS.js +145 -0
  126. package/dist/util-MVgdwuIS.js.map +1 -0
  127. package/dist/workspace-archive-BosQiotA.js +575 -0
  128. package/dist/workspace-archive-BosQiotA.js.map +1 -0
  129. package/package.json +43 -56
  130. package/skills/build-with-agent-runtime/SKILL.md +1 -0
  131. package/dist/activation-Cm-9MMX1.d.ts +0 -69
  132. package/dist/analyst-loop.js.map +0 -1
  133. package/dist/backends-BO4Jqoe2.d.ts +0 -134
  134. package/dist/candidate-execution/index.js.map +0 -1
  135. package/dist/chunk-2KGAN2HM.js +0 -1256
  136. package/dist/chunk-2KGAN2HM.js.map +0 -1
  137. package/dist/chunk-2VZYRB55.js +0 -834
  138. package/dist/chunk-2VZYRB55.js.map +0 -1
  139. package/dist/chunk-3MDZX7YU.js +0 -125
  140. package/dist/chunk-3MDZX7YU.js.map +0 -1
  141. package/dist/chunk-5IBQAPVB.js +0 -29
  142. package/dist/chunk-5IBQAPVB.js.map +0 -1
  143. package/dist/chunk-5QOB7H74.js +0 -387
  144. package/dist/chunk-5QOB7H74.js.map +0 -1
  145. package/dist/chunk-C5RTIBNZ.js +0 -48
  146. package/dist/chunk-C5RTIBNZ.js.map +0 -1
  147. package/dist/chunk-CTRA64LY.js +0 -680
  148. package/dist/chunk-CTRA64LY.js.map +0 -1
  149. package/dist/chunk-DPEUKJRO.js +0 -27
  150. package/dist/chunk-DPEUKJRO.js.map +0 -1
  151. package/dist/chunk-FD2MBMOH.js +0 -494
  152. package/dist/chunk-FD2MBMOH.js.map +0 -1
  153. package/dist/chunk-H5QPIZNX.js +0 -907
  154. package/dist/chunk-H5QPIZNX.js.map +0 -1
  155. package/dist/chunk-HLKC4UYB.js +0 -3514
  156. package/dist/chunk-HLKC4UYB.js.map +0 -1
  157. package/dist/chunk-HNP72PNU.js +0 -192
  158. package/dist/chunk-HNP72PNU.js.map +0 -1
  159. package/dist/chunk-ISPWRSEC.js +0 -408
  160. package/dist/chunk-ISPWRSEC.js.map +0 -1
  161. package/dist/chunk-KRBFHMV6.js +0 -1228
  162. package/dist/chunk-KRBFHMV6.js.map +0 -1
  163. package/dist/chunk-M22PL4GH.js +0 -171
  164. package/dist/chunk-M22PL4GH.js.map +0 -1
  165. package/dist/chunk-NURIQBJQ.js +0 -72
  166. package/dist/chunk-NURIQBJQ.js.map +0 -1
  167. package/dist/chunk-OPVWXJ2H.js +0 -75
  168. package/dist/chunk-OPVWXJ2H.js.map +0 -1
  169. package/dist/chunk-PZZKQVQV.js +0 -52
  170. package/dist/chunk-PZZKQVQV.js.map +0 -1
  171. package/dist/chunk-Q2JSAVQ3.js +0 -671
  172. package/dist/chunk-Q2JSAVQ3.js.map +0 -1
  173. package/dist/chunk-RDOAVVHY.js +0 -699
  174. package/dist/chunk-RDOAVVHY.js.map +0 -1
  175. package/dist/chunk-SGKPNBXE.js +0 -60
  176. package/dist/chunk-SGKPNBXE.js.map +0 -1
  177. package/dist/chunk-SMQXZGLZ.js +0 -351
  178. package/dist/chunk-SMQXZGLZ.js.map +0 -1
  179. package/dist/chunk-UHEZW5BU.js +0 -2918
  180. package/dist/chunk-UHEZW5BU.js.map +0 -1
  181. package/dist/chunk-UPWGXKXB.js +0 -254
  182. package/dist/chunk-UPWGXKXB.js.map +0 -1
  183. package/dist/chunk-VISA6CI3.js +0 -200
  184. package/dist/chunk-VISA6CI3.js.map +0 -1
  185. package/dist/chunk-WMTCUOQL.js +0 -474
  186. package/dist/chunk-WMTCUOQL.js.map +0 -1
  187. package/dist/chunk-WRTOVNN4.js +0 -4728
  188. package/dist/chunk-WRTOVNN4.js.map +0 -1
  189. package/dist/chunk-WSTRQZYQ.js +0 -5576
  190. package/dist/chunk-WSTRQZYQ.js.map +0 -1
  191. package/dist/chunk-XBG2W2VW.js +0 -6434
  192. package/dist/chunk-XBG2W2VW.js.map +0 -1
  193. package/dist/chunk-YEJR7IXO.js +0 -68
  194. package/dist/chunk-YEJR7IXO.js.map +0 -1
  195. package/dist/chunk-YJZA2BIK.js +0 -1338
  196. package/dist/chunk-YJZA2BIK.js.map +0 -1
  197. package/dist/completion-gate-BMy5LGoP.d.ts +0 -256
  198. package/dist/conversation.js.map +0 -1
  199. package/dist/coordination-BZZSVYpZ.d.ts +0 -2570
  200. package/dist/environment-provider.js.map +0 -1
  201. package/dist/improvement-adapter-HAZz-7vK.d.ts +0 -203
  202. package/dist/knowledge.js.map +0 -1
  203. package/dist/local-harness-BDNcl6jI.d.ts +0 -175
  204. package/dist/loop-runner-bin-68aoM9-7.d.ts +0 -199
  205. package/dist/loop-runner-bin.js.map +0 -1
  206. package/dist/loops.js.map +0 -1
  207. package/dist/openai-tools-fnj6SRVg.d.ts +0 -46
  208. package/dist/protected-model-port-B4t-OQjL.d.ts +0 -271
  209. package/dist/redact-BuFjxBUJ.d.ts +0 -481
  210. package/dist/sanitize-DEbPNtyI.d.ts +0 -328
  211. package/dist/structural-rollout-DEh6CEsa.d.ts +0 -446
  212. package/dist/supervise-4_48wwvy.d.ts +0 -379
  213. package/dist/types-BCoemcXU.d.ts +0 -802
  214. package/dist/types-BwoZWq-i.d.ts +0 -510
  215. package/dist/types-Cbp72qyu.d.ts +0 -491
  216. package/dist/types-CmYCMbFT.d.ts +0 -203
  217. package/dist/types-CvNwMzQt.d.ts +0 -957
  218. package/dist/worktree-fanout-DxhAWr5Z.d.ts +0 -999
@@ -1,481 +0,0 @@
1
- import { LabeledScenarioStore, WorktreeAdapter, OptimizationMethod, CompareOptimizationMethodsOptions, OptimizationMethodComparison } from '@tangle-network/agent-eval/campaign';
2
- import { MutableSurface, Scenario, SelfImproveResult, SelfImproveOptions, SelfImproveBudget } from '@tangle-network/agent-eval/contract';
3
- import { AgentProfile, ReasoningEffort, Sha256Digest } from '@tangle-network/agent-interface';
4
- import { L as LocalHarness, C as CodexTokenUsage, b as CodexExecutionEvidence, c as LocalHarnessResult, r as runLocalHarness } from './local-harness-BDNcl6jI.js';
5
- import { AnalystFinding, CostLedgerHandle, MaximumCharge } from '@tangle-network/agent-eval';
6
-
7
- /**
8
- * Code-only candidate driver for Runtime-owned git worktrees.
9
- *
10
- * A `CandidateGenerator` edits an isolated checkout. This driver finalizes each
11
- * accepted edit as a `CodeSurface` and disposes rejected worktrees.
12
- *
13
- * @experimental
14
- */
15
-
16
- /** The byte-producing seam — the ONE thing that differs between the cheap
17
- * reflective path and the full agentic path. A generator makes (uncommitted)
18
- * changes inside `worktreePath`; the driver commits them via the worktree
19
- * adapter's `finalize`. */
20
- interface CandidateGenerator {
21
- kind: string;
22
- /** Whether this generator can produce a candidate from an EMPTY findings set
23
- * and no phase-2 report — i.e. it draws its change signal from the repo and
24
- * the raw-trace filesystem context on disk, not only from pre-summarized
25
- * findings. An agentic coder (`agenticGenerator`) sets this: the seed repo +
26
- * raw traces ARE the signal, so it must still run the full `populationSize`
27
- * when the distiller yielded nothing (this is the meta-harness contract — the
28
- * agent diagnoses from the raw traces itself). A patch-applier
29
- * (`reflectiveGenerator`) leaves it unset — with no findings there is no
30
- * patch to draft, so the driver short-circuits rather than spin up worktrees
31
- * for a guaranteed no-op. Default `false`. */
32
- proposesWithoutFindings?: boolean;
33
- generate(args: {
34
- /** The candidate worktree — a clean checkout of the current incumbent. */
35
- worktreePath: string;
36
- /** Phase-2 research report (analyst findings + diff), opaque. */
37
- report: unknown;
38
- /** Findings resolved from the report or the loop context. */
39
- findings: AnalystFinding[];
40
- /** Handle to all captured data, to ground the change. */
41
- dataset?: LabeledScenarioStore;
42
- /** DEPTH: max iterations the generator may take (agentic uses this; the
43
- * reflective generator ignores it). */
44
- maxShots: number;
45
- signal: AbortSignal;
46
- /** Generation coordinates supplied by Runtime's internal code candidate driver. */
47
- generation?: number;
48
- candidateIndex?: number;
49
- /** Shared run-wide paid-call account supplied by agent-eval 0.117+. */
50
- costLedger?: CostLedgerHandle;
51
- /** Receipt attribution phase supplied alongside `costLedger`. */
52
- costPhase?: string;
53
- }): Promise<{
54
- applied: boolean;
55
- summary: string;
56
- /** Short slug for the candidate. When present (with `rationale`), the
57
- * driver returns a `ProposedCandidate` wrapper so the label survives to
58
- * `GenerationRecord` and the emitted provenance. */
59
- label?: string;
60
- /** Why this change was proposed — bounded, derived from the findings the
61
- * shot addressed. Paired with `label`. */
62
- rationale?: string;
63
- }>;
64
- }
65
-
66
- /**
67
- *
68
- * `agenticGenerator` — the full-agentic `CandidateGenerator`. It runs a real
69
- * coding harness (claude / codex / opencode) inside the candidate worktree the
70
- * driver already created, letting the agent read the codebase + the research
71
- * report and make the change in place. The driver then commits the worktree
72
- * into a `CodeSurface`.
73
- *
74
- * Mechanism: identical to the proven Phase-2.8 in-process executor — spawn the
75
- * harness as a subprocess with `cwd` = the worktree, on the same filesystem,
76
- * so edits land in place (no sandbox-mount round-trip). `runLocalHarness` is
77
- * the verified primitive. The OUTER sandbox is the improvement loop's own
78
- * execution context; the generator does not nest a second sandbox per
79
- * candidate (which would reintroduce a host↔sandbox worktree-transport
80
- * problem that does not need solving here).
81
- *
82
- * `maxShots` is the DEPTH dial — a multi-shot verify-in-session loop, NOT the
83
- * kernel `runAgentRounds`. Each shot runs one full harness session in the (persistent)
84
- * worktree; between shots the loop refines based on what the last shot produced:
85
- * - empty tree → "you changed nothing, make the edits" → retry
86
- * - dirty + `verify` fails → feed the verifier's failure into the next shot
87
- * (the worktree persists, so the harness RESUMES atop its own failing
88
- * edits with the error in hand — no `--resume` session plumbing needed,
89
- * and harness-agnostic across claude/codex/opencode)
90
- * - dirty + `verify` ok (or no verifier configured) → return the candidate
91
- * A candidate that never verifies within `maxShots` is discarded (`applied:
92
- * false`), never shipped — if you configured a verifier, a non-passing tree is
93
- * not a candidate. With no verifier the legacy behavior holds: first dirty shot
94
- * is the candidate.
95
- *
96
- * @experimental
97
- */
98
-
99
- /** Dedicated ephemeral root for generic author-profile files. Every declared
100
- * file must live below this root so cleanup cannot alter candidate-owned files. */
101
- declare const AGENTIC_PROFILE_RESOURCE_ROOT = ".agent-runtime-profile-resources";
102
- /** Outcome of verifying a candidate worktree. `feedback` (compiler errors,
103
- * failing test output) is fed into the next shot when `ok` is false. */
104
- interface VerifyResult {
105
- ok: boolean;
106
- feedback?: string;
107
- }
108
- /** Verifies the edited worktree. Sync or async; throws only on a setup fault
109
- * (a candidate that fails verification returns `{ok:false}`, it does not
110
- * throw). */
111
- type Verifier = (worktreePath: string, signal?: AbortSignal) => Promise<VerifyResult> | VerifyResult;
112
- interface AgenticGeneratorShotReceipt {
113
- readonly generation: number | null;
114
- readonly candidateIndex: number | null;
115
- /** One-based shot number within this candidate. */
116
- readonly shot: number;
117
- readonly maxShots: number;
118
- readonly harness: LocalHarness;
119
- readonly model: string | null;
120
- readonly reasoningEffort: ReasoningEffort | null;
121
- readonly promptSha256: `sha256:${string}`;
122
- readonly startedAt: string;
123
- readonly completedAt: string;
124
- readonly durationMs: number;
125
- readonly exitCode: number | null;
126
- readonly timedOut: boolean;
127
- /** True when caller cancellation reached the author process; absent in older receipts. */
128
- readonly aborted?: boolean;
129
- readonly killedBySignal: NodeJS.Signals | null;
130
- readonly stdoutBytes: number | null;
131
- readonly stdoutSha256: `sha256:${string}` | null;
132
- readonly stderrBytes: number | null;
133
- readonly stderrSha256: `sha256:${string}` | null;
134
- readonly usage: CodexTokenUsage | null;
135
- /** Digest of the exact profile-file workspace plan applied for this shot. */
136
- readonly profileWorkspacePlanDigest: string | null;
137
- readonly profileWorkspaceFileCount: number;
138
- /** Shared run-ledger call id for this exact shot. */
139
- readonly costCallId: string | null;
140
- /** Whether dollars came from the provider, the pricing table, or are unknown. */
141
- readonly costBasis: 'provider-reported' | 'estimated-pricing' | 'unknown';
142
- readonly costUsd: number | null;
143
- /** True only for a provider-reported amount, never for a pricing estimate. */
144
- readonly costUsdKnown: boolean;
145
- readonly evidence: CodexExecutionEvidence | null;
146
- readonly error: {
147
- readonly name: string;
148
- readonly message: string;
149
- } | null;
150
- }
151
- /** Frozen exact harness result for an author shot: full streams, process state,
152
- * token usage, and execution-policy evidence.
153
- * The `onShotCompleted` callback receives `null` when execution failed before
154
- * the harness returned. */
155
- type AgenticGeneratorShotExecution = Readonly<Omit<LocalHarnessResult, 'usage' | 'evidence'> & {
156
- readonly usage?: Readonly<CodexTokenUsage>;
157
- readonly evidence?: Readonly<Omit<CodexExecutionEvidence, 'readDeniedPaths' | 'policy'>> & {
158
- readonly readDeniedPaths: ReadonlyArray<string>;
159
- readonly policy: Readonly<CodexExecutionEvidence['policy']>;
160
- };
161
- }>;
162
- /** Worktree decision emitted before a completed shot is retried, accepted, or
163
- * discarded. The callback runs while `worktreePath` is still available, so
164
- * callers can persist the exact diff. */
165
- type AgenticGeneratorShotDisposition = {
166
- readonly kind: 'clean';
167
- readonly worktreePath: string;
168
- } | {
169
- readonly kind: 'rejected';
170
- readonly worktreePath: string;
171
- readonly stage: 'raw-trace-evidence' | 'verification';
172
- readonly feedback: string | null;
173
- } | {
174
- readonly kind: 'accepted';
175
- readonly worktreePath: string;
176
- readonly verified: boolean;
177
- } | {
178
- readonly kind: 'setup-error';
179
- readonly worktreePath: string;
180
- readonly stage: 'worktree-inspection' | 'raw-trace-evidence' | 'verification';
181
- readonly error: {
182
- readonly name: string;
183
- readonly message: string;
184
- };
185
- };
186
- interface AgenticGeneratorOptions {
187
- /** Local coding harness to run in the worktree. Default `claude`. */
188
- harness?: LocalHarness;
189
- /** Author profile rendered through the canonical harness mapper. Required
190
- * for reproducible Codex so model and reasoning settings are explicit. */
191
- profile?: AgentProfile;
192
- /** Run Codex with isolated configuration, exact prompt evidence, and required
193
- * terminal token usage. Requires `harness: 'codex'` and `profile`. */
194
- codexReproducible?: boolean;
195
- /** Absolute paths reproducible Codex must not read. A function can derive
196
- * candidate-specific paths after the driver creates its worktree. */
197
- codexReadDeniedPaths?: ReadonlyArray<string> | ((worktreePath: string) => ReadonlyArray<string>);
198
- /** Awaited once for every attempted author shot, including process failures.
199
- * The second argument preserves the exact harness result, including stdout
200
- * and stderr, before worktree inspection or verification can reject the
201
- * shot. Throwing aborts the candidate so evidence persistence fails closed. */
202
- onShotCompleted?: (receipt: AgenticGeneratorShotReceipt, execution: AgenticGeneratorShotExecution | null) => void | Promise<void>;
203
- /** Awaited after worktree inspection and before the shot is accepted,
204
- * retried, or discarded. Throwing aborts the candidate. */
205
- onShotDisposition?: (receipt: AgenticGeneratorShotReceipt, disposition: AgenticGeneratorShotDisposition) => void | Promise<void>;
206
- /** Optional hard upper bound passed to the run-wide CostLedger before each
207
- * author shot. This MUST be enforced by the provider or executor; a planning
208
- * estimate is not an admissible bound. Omit for an uncapped ledger. A capped
209
- * ledger rejects before model dispatch when this is absent. */
210
- maximumCharge?: MaximumCharge;
211
- /** Per-shot wall-clock timeout (ms). Default = `runLocalHarness` default (5m). */
212
- timeoutMs?: number;
213
- /** Build the harness task prompt from the report + findings. Override for
214
- * domain phrasing; the default turns findings into a concrete coder task. */
215
- buildPrompt?: (args: {
216
- report: unknown;
217
- findings: AnalystFinding[];
218
- }) => string;
219
- /** Verify the worktree after each dirtying shot. When set, a candidate that
220
- * fails verification is NOT returned — the failure feeds the next shot
221
- * (verify-in-session), up to `maxShots`; a candidate that never verifies is
222
- * discarded (`applied:false`), never shipped. Omitted ⇒ legacy behavior:
223
- * the first dirty shot is the candidate. See `commandVerifier`. */
224
- verify?: Verifier;
225
- /** Test seam — inject the harness runner (defaults to `runLocalHarness`). */
226
- runHarness?: typeof runLocalHarness;
227
- /** Test seam — inject the worktree-dirty check (defaults to `git status`). */
228
- isDirty?: (worktreePath: string) => boolean;
229
- }
230
- /** Full-agentic `CandidateGenerator` (the `shots=N, sandbox=on` setting): run a real coding harness inside the candidate worktree so the agent makes the change in place. */
231
- declare function agenticGenerator(opts?: AgenticGeneratorOptions): CandidateGenerator;
232
- /** Turn the analyst's findings (+ optional report) into a concrete coder task —
233
- * the senior scientific-method framing shared with the tool/MCP build prompts. */
234
- declare function defaultBuildPrompt(args: {
235
- report: unknown;
236
- findings: AnalystFinding[];
237
- }): string;
238
- /** A `Verifier` that runs a command in the worktree: exit 0 ⇒ ok, any other
239
- * exit ⇒ failed with stdout+stderr as feedback. The common case — verify by
240
- * `tsc --noEmit`, `pnpm build`, or a test command. A timeout is treated as a
241
- * FAILED candidate (a change that hangs the build is a bad change); a missing
242
- * binary or spawn fault throws (a setup bug, not a failed candidate — no
243
- * silent fallback). */
244
- declare function commandVerifier(command: string, args?: string[], timeoutMs?: number): Verifier;
245
-
246
- type DeepReadonly<T> = T extends (...args: never[]) => unknown ? T : T extends readonly (infer TItem)[] ? readonly DeepReadonly<TItem>[] : T extends object ? {
247
- readonly [TKey in keyof T]: DeepReadonly<T[TKey]>;
248
- } : T;
249
- /** Complete immutable profile value used during measured execution. */
250
- type ReadonlyAgentProfile = DeepReadonly<AgentProfile>;
251
-
252
- /** The executable agent lever `improve` optimizes. Profile fields remain
253
- * portable AgentProfile coordinates; implementation and orchestration files
254
- * use the code surface so a winner can be sealed into an exact candidate.
255
- * `rollout-policy` is the inference-time structuralRollout dials
256
- * (`profile.extensions['structural-rollout']`). */
257
- type ImproveSurface = 'prompt' | 'skills' | 'tools' | 'mcp' | 'hooks' | 'subagents' | 'agent-profile' | 'memory' | 'code' | 'rollout-policy';
258
- type ImproveProfileSurface = Exclude<ImproveSurface, 'code'>;
259
- interface ImproveMethodContext {
260
- /** Validated baseline profile. */
261
- readonly profile: ReadonlyAgentProfile;
262
- /** Runtime-derived identity for upstream optimizer resume state. */
263
- readonly evaluationRef: Sha256Digest;
264
- /** Exact profile coordinate being optimized. */
265
- readonly surface: ImproveProfileSurface;
266
- /** Exact bytes supplied to the optimization method. */
267
- readonly baselineSurface: MutableSurface;
268
- /** Structured value represented by `baselineSurface`, before serialization. */
269
- readonly baselineValue: unknown;
270
- /** Findings produced before this search, if any. */
271
- readonly findings: readonly unknown[];
272
- }
273
- /** Build a complete method after trace findings are available. */
274
- type ImproveMethodFactory<TScenario extends Scenario, TArtifact> = (context: ImproveMethodContext) => OptimizationMethod<TScenario, TArtifact>;
275
- type ImproveMethodSource<TScenario extends Scenario, TArtifact> = OptimizationMethod<TScenario, TArtifact> | ImproveMethodFactory<TScenario, TArtifact>;
276
- /** Runs one exact materialized profile on one scenario. */
277
- type ImproveProfileAgent<TScenario extends Scenario, TArtifact> = (profile: ReadonlyAgentProfile, scenario: TScenario, ctx: Parameters<CompareOptimizationMethodsOptions<TScenario, TArtifact>['dispatchWithSurface']>[2]) => Promise<TArtifact>;
278
- /** Exact materialized profile presented for validation before any candidate run. */
279
- interface ImproveCandidateValidationInput {
280
- profile: ReadonlyAgentProfile;
281
- surface: ImproveProfileSurface;
282
- candidateSurface: MutableSurface;
283
- value: unknown;
284
- isBaseline: boolean;
285
- }
286
- type ImproveCandidateValidator = (input: ImproveCandidateValidationInput) => void;
287
- type ImproveOptimizationRunOptions<TScenario extends Scenario, TArtifact> = Omit<NonNullable<CompareOptimizationMethodsOptions<TScenario, TArtifact>['optimizationRunOptions']>, 'dispatchRef'>;
288
- /** Complete-method configuration for every non-code profile surface. */
289
- type ImproveMethodOptions<TScenario extends Scenario, TArtifact> = Omit<CompareOptimizationMethodsOptions<TScenario, TArtifact>, 'baselineSurface' | 'dispatchRef' | 'dispatchWithSurface' | 'methods' | 'optimizationConcurrency' | 'optimizationRunOptions'> & {
290
- /** Exact profile coordinate optimized by `method`. Default `'prompt'`. */
291
- surface?: ImproveProfileSurface;
292
- /**
293
- * Immutable digest of `agent`, profile component mapping, models, tools, and
294
- * every closure or external setting that can change measured behavior.
295
- */
296
- executionRef: Sha256Digest;
297
- /** A complete optimizer or a factory that can incorporate current findings. */
298
- method: ImproveMethodSource<TScenario, TArtifact>;
299
- /** Runs the exact complete profile materialized from one candidate surface. */
300
- agent: ImproveProfileAgent<TScenario, TArtifact>;
301
- /** Reject a materialized profile before it reaches the agent callback. */
302
- validateCandidate?: ImproveCandidateValidator;
303
- /** Trace or analyst findings available to a method factory. */
304
- findings?: readonly unknown[];
305
- /** Select the exact inline skill document for `surface: 'skills'`. */
306
- skills?: ImproveSkillsOptions;
307
- /**
308
- * Map a profile to named text components and apply the winning components.
309
- * Valid only with `surface: 'agent-profile'`.
310
- */
311
- profileComponents?: ImproveProfileComponents;
312
- /** Shared settings for method train and selection calls. */
313
- optimizationRunOptions?: ImproveOptimizationRunOptions<TScenario, TArtifact>;
314
- /** Ship only when the paired final-test interval is entirely above this lift. Default `0`. */
315
- minimumLift?: number;
316
- };
317
- /** Runtime-owned code search in isolated git worktrees. */
318
- type ImproveCodeRunOptions<TScenario extends Scenario, TArtifact> = Omit<SelfImproveOptions<TScenario, TArtifact>, 'analyzeGeneration' | 'baselineSurface' | 'budget' | 'findings' | 'gate' | 'llm' | 'method' | 'mutationPrimitives' | 'proposer' | 'proposerTarget' | 'selectionScenarios'> & {
319
- surface: 'code';
320
- /** Local code-search budget. Method-only selection controls do not apply. */
321
- budget?: Omit<SelfImproveBudget, 'selectionFraction'>;
322
- /** Findings supplied to Runtime's code candidate driver. */
323
- findings?: readonly unknown[];
324
- /** Gate mode. `'holdout'` (default) runs the held-out promotion gate;
325
- * `'none'` is a baseline-only run (`budget.generations = 0`). */
326
- gate?: 'holdout' | 'none';
327
- /** Per-generation findings producer for Runtime's code search.
328
- * Pass your own producer to replace the code-trace distiller; pass `null`
329
- * to keep the static findings for every generation. */
330
- analyzeGeneration?: SelfImproveOptions<TScenario, TArtifact>['analyzeGeneration'] | null;
331
- /** Feed code candidates paths to prior raw traces instead of a failure digest.
332
- * Defaults to true for durable runs and false for in-memory runs. */
333
- rawTraceContext?: boolean;
334
- /** Isolated repository and candidate generator settings. */
335
- code: ImproveCodeOptions;
336
- /** Custom held-back-exam decision. The string `gate` above controls whether
337
- * the exam runs; this callback controls how its evidence decides promotion. */
338
- promotionGate?: SelfImproveOptions<TScenario, TArtifact>['gate'];
339
- };
340
- /** The canonical improvement API: complete methods for profiles, worktrees for code. */
341
- type ImproveOptions<TScenario extends Scenario, TArtifact> = ImproveMethodOptions<TScenario, TArtifact> | ImproveCodeRunOptions<TScenario, TArtifact>;
342
- interface ImproveSkillsOptions {
343
- /** `name` of one inline entry in `profile.resources.skills`. */
344
- resourceName: string;
345
- }
346
- /** Caller-owned mapping for optimizing several profile fields as one candidate. */
347
- interface ImproveProfileComponents {
348
- /** Extract the exact named text components optimized together. */
349
- read(profile: ReadonlyAgentProfile): Readonly<Record<string, string>>;
350
- /** Apply a complete winning component map to a detached profile. */
351
- apply(profile: ReadonlyAgentProfile, components: Readonly<Record<string, string>>): ReadonlyAgentProfile;
352
- }
353
- interface ImproveCodeOptions {
354
- /** Repo root candidate worktrees fork from. */
355
- repoRoot: string;
356
- /** Base ref candidates fork from. Default `main`. */
357
- baseRef?: string;
358
- /** Directory worktrees are created under. Default `<repoRoot>/.worktrees`. */
359
- worktreeDir?: string;
360
- /** Git-compatible adapter override, primarily for tests. Candidate advancement
361
- * still requires normal Git worktree and commit semantics. */
362
- worktree?: WorktreeAdapter;
363
- /** Coding harness the agentic generator runs in each worktree. Default `claude`. */
364
- harness?: LocalHarness;
365
- /** Verify a candidate worktree before it becomes a measurable surface; failures
366
- * feed the next shot (see `agenticGenerator.verify` / `commandVerifier`). */
367
- verify?: Verifier;
368
- /** Per-shot wall-clock timeout for the harness (ms). */
369
- timeoutMs?: number;
370
- /** Byte-producer override, used for tests and custom candidate production.
371
- * When set, `harness`, `verify`, and `timeoutMs` are unused. */
372
- generator?: CandidateGenerator;
373
- }
374
- interface ImprovementProfileCandidate {
375
- /** Surface searched by this run. */
376
- surface: ImproveProfileSurface;
377
- /** Exact winning value returned by agent-eval. */
378
- value: MutableSurface;
379
- /** Exact complete profile instance measured on the final cases. */
380
- profile: ReadonlyAgentProfile;
381
- }
382
- interface ImprovementCodeCandidate {
383
- surface: 'code';
384
- value: MutableSurface;
385
- profile?: never;
386
- }
387
- type ImprovementCandidate = ImprovementProfileCandidate | ImprovementCodeCandidate;
388
- /** Normalized spend reported for one Runtime improvement run. */
389
- interface ImproveCost {
390
- totalCostUsd: number;
391
- accountingComplete: boolean;
392
- incompleteReasons: string[];
393
- }
394
- /** Optimizer ancestry sealed into downstream candidate experiments. */
395
- interface ImproveLineage {
396
- /** Unique Runtime invocation used to isolate this run's cost receipts. */
397
- invocationId: string;
398
- /** Upstream optimizer run when reported, otherwise this Runtime optimization invocation. */
399
- runId: string;
400
- /** Exact train-plus-selection scenario payloads exposed to candidate selection. */
401
- developmentSplitDigest: Sha256Digest;
402
- /** Complete callback, materializer, model, tool, and closure identity for a profile run. */
403
- executionRef?: Sha256Digest;
404
- /** Complete baseline profile identity for a profile run. */
405
- baselineProfileDigest?: Sha256Digest;
406
- }
407
- interface ImproveResultBase<TCandidate extends ImprovementCandidate> {
408
- /** Frozen candidate only. Live state is changed through an approved activation. */
409
- candidate: TCandidate;
410
- /** Final-test decision for this search result. */
411
- decision: SelfImproveResult<Scenario, unknown>['gateDecision'];
412
- /** Final-test lift when one was measured. */
413
- lift?: number;
414
- /** Paired final-test confidence interval for method-based profile runs. */
415
- liftInterval?: {
416
- low: number;
417
- high: number;
418
- };
419
- /** Full search and final-test spend. */
420
- cost: ImproveCost;
421
- /** Full wall-clock duration. */
422
- durationMs: number;
423
- /** Optimizer ancestry used when sealing a candidate experiment. */
424
- lineage: ImproveLineage;
425
- /** Number of generations explored by Runtime's code path. */
426
- generationsExplored?: number;
427
- /** Release resources owned by this result. Idempotent; currently disposes
428
- * the returned code worktree and is a no-op for profile-only surfaces. */
429
- dispose(): Promise<void>;
430
- }
431
- interface ImproveMethodResult extends ImproveResultBase<ImprovementProfileCandidate> {
432
- mode: 'method';
433
- method: string;
434
- /** External optimizer package and resumable run identity, when reported. */
435
- provenance?: OptimizationMethodComparison['best']['provenance'];
436
- decision: 'ship' | 'hold';
437
- lift: number;
438
- liftInterval: {
439
- low: number;
440
- high: number;
441
- };
442
- raw: OptimizationMethodComparison;
443
- }
444
- interface ImproveCodeResult<TScenario extends Scenario, TArtifact> extends ImproveResultBase<ImprovementCodeCandidate> {
445
- mode: 'code';
446
- raw: SelfImproveResult<TScenario, TArtifact>;
447
- }
448
- type ImproveResult<TScenario extends Scenario, TArtifact> = ImproveMethodResult | ImproveCodeResult<TScenario, TArtifact>;
449
-
450
- /**
451
- *
452
- * Redaction for values that may leave the Runtime process. The default scrubs
453
- * common leak classes (API keys, bearer tokens, emails, private keys) from
454
- * strings and walks nested objects and arrays. A customer with domain-specific
455
- * PII supplies their own `redact` hook.
456
- *
457
- * This is intentionally narrower than `src/sanitize.ts` (which redacts the
458
- * runtime's *event envelope* field-by-field): here the value is opaque
459
- * customer payload, so the scrub is value-shaped, not schema-shaped.
460
- *
461
- * @experimental
462
- */
463
- /** A redactor maps an arbitrary trace value to a safe-to-export value. Pure;
464
- * must not throw on cyclic input (the default tolerates cycles). */
465
- type Redactor = (value: unknown) => unknown;
466
- /**
467
- * The built-in redactor. Walks objects and arrays; replaces values under
468
- * secret-bearing keys wholesale; scrubs in-value patterns from every string.
469
- * Cycle-safe (a seen-set short-circuits self-referential payloads to
470
- * `'[circular]'`), depth-bounded, and total — never throws on customer input.
471
- */
472
- declare function defaultRedactor(value: unknown): unknown;
473
- /**
474
- * Resolve the redactor a client uses. A caller-supplied hook handles
475
- * domain-specific values first, then the built-in scrubber still removes
476
- * common credentials and email addresses. Returning `false` is the explicit
477
- * opt-out for already-reviewed public values.
478
- */
479
- declare function resolveRedactor(redact: Redactor | false | undefined): Redactor;
480
-
481
- export { AGENTIC_PROFILE_RESOURCE_ROOT as A, type ImprovementCandidate as B, type CandidateGenerator as C, type DeepReadonly as D, type ImprovementCodeCandidate as E, type ImprovementProfileCandidate as F, type VerifyResult as G, agenticGenerator as H, type ImproveOptions as I, commandVerifier as J, defaultBuildPrompt as K, type Redactor as R, type Verifier as V, type ImproveResult as a, type ImproveMethodResult as b, type ImproveMethodOptions as c, defaultRedactor as d, type ImproveCodeRunOptions as e, type ImproveCodeResult as f, type ImproveCandidateValidationInput as g, type ImproveMethodFactory as h, type ReadonlyAgentProfile as i, type AgenticGeneratorOptions as j, type AgenticGeneratorShotDisposition as k, type AgenticGeneratorShotExecution as l, type AgenticGeneratorShotReceipt as m, type ImproveCandidateValidator as n, type ImproveCodeOptions as o, type ImproveCost as p, type ImproveLineage as q, resolveRedactor as r, type ImproveMethodContext as s, type ImproveMethodSource as t, type ImproveOptimizationRunOptions as u, type ImproveProfileAgent as v, type ImproveProfileComponents as w, type ImproveProfileSurface as x, type ImproveSkillsOptions as y, type ImproveSurface as z };