@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.
Files changed (217) hide show
  1. package/README.md +176 -42
  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 -1134
  40. package/dist/index.js +2134 -1972
  41. package/dist/index.js.map +1 -1
  42. package/dist/intelligence.d.ts +776 -888
  43. package/dist/intelligence.js +1466 -1410
  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 -17
  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 -437
  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 +150 -147
  84. package/dist/primeintellect/index.js +626 -1004
  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 -55
  130. package/skills/build-with-agent-runtime/SKILL.md +16 -9
  131. package/skills/loop-writer/SKILL.md +1 -1
  132. package/dist/activation-Cm-9MMX1.d.ts +0 -69
  133. package/dist/analyst-loop.js.map +0 -1
  134. package/dist/backends-BO4Jqoe2.d.ts +0 -134
  135. package/dist/candidate-execution/index.js.map +0 -1
  136. package/dist/chunk-2KGAN2HM.js +0 -1256
  137. package/dist/chunk-2KGAN2HM.js.map +0 -1
  138. package/dist/chunk-2QJSNOGK.js +0 -48
  139. package/dist/chunk-2QJSNOGK.js.map +0 -1
  140. package/dist/chunk-2UABGGUB.js +0 -474
  141. package/dist/chunk-2UABGGUB.js.map +0 -1
  142. package/dist/chunk-2VZYRB55.js +0 -834
  143. package/dist/chunk-2VZYRB55.js.map +0 -1
  144. package/dist/chunk-2X65HYMI.js +0 -3526
  145. package/dist/chunk-2X65HYMI.js.map +0 -1
  146. package/dist/chunk-3MDZX7YU.js +0 -125
  147. package/dist/chunk-3MDZX7YU.js.map +0 -1
  148. package/dist/chunk-3PPVCS75.js +0 -199
  149. package/dist/chunk-3PPVCS75.js.map +0 -1
  150. package/dist/chunk-5HNDYWUT.js +0 -6424
  151. package/dist/chunk-5HNDYWUT.js.map +0 -1
  152. package/dist/chunk-5IBQAPVB.js +0 -29
  153. package/dist/chunk-5IBQAPVB.js.map +0 -1
  154. package/dist/chunk-5QOB7H74.js +0 -387
  155. package/dist/chunk-5QOB7H74.js.map +0 -1
  156. package/dist/chunk-ATDFUJYI.js +0 -4728
  157. package/dist/chunk-ATDFUJYI.js.map +0 -1
  158. package/dist/chunk-B7K7V22Y.js +0 -699
  159. package/dist/chunk-B7K7V22Y.js.map +0 -1
  160. package/dist/chunk-DPEUKJRO.js +0 -27
  161. package/dist/chunk-DPEUKJRO.js.map +0 -1
  162. package/dist/chunk-FD2MBMOH.js +0 -494
  163. package/dist/chunk-FD2MBMOH.js.map +0 -1
  164. package/dist/chunk-FJI3EXU3.js +0 -2402
  165. package/dist/chunk-FJI3EXU3.js.map +0 -1
  166. package/dist/chunk-HAO4CXHP.js +0 -200
  167. package/dist/chunk-HAO4CXHP.js.map +0 -1
  168. package/dist/chunk-ISPWRSEC.js +0 -408
  169. package/dist/chunk-ISPWRSEC.js.map +0 -1
  170. package/dist/chunk-KRBFHMV6.js +0 -1228
  171. package/dist/chunk-KRBFHMV6.js.map +0 -1
  172. package/dist/chunk-L5DST3QC.js +0 -351
  173. package/dist/chunk-L5DST3QC.js.map +0 -1
  174. package/dist/chunk-M22PL4GH.js +0 -171
  175. package/dist/chunk-M22PL4GH.js.map +0 -1
  176. package/dist/chunk-NURIQBJQ.js +0 -72
  177. package/dist/chunk-NURIQBJQ.js.map +0 -1
  178. package/dist/chunk-PZZKQVQV.js +0 -52
  179. package/dist/chunk-PZZKQVQV.js.map +0 -1
  180. package/dist/chunk-Q2JSAVQ3.js +0 -671
  181. package/dist/chunk-Q2JSAVQ3.js.map +0 -1
  182. package/dist/chunk-SBTWKPVR.js +0 -5576
  183. package/dist/chunk-SBTWKPVR.js.map +0 -1
  184. package/dist/chunk-SGKPNBXE.js +0 -60
  185. package/dist/chunk-SGKPNBXE.js.map +0 -1
  186. package/dist/chunk-SNSMRT6H.js +0 -680
  187. package/dist/chunk-SNSMRT6H.js.map +0 -1
  188. package/dist/chunk-STJEHM5F.js +0 -1338
  189. package/dist/chunk-STJEHM5F.js.map +0 -1
  190. package/dist/chunk-UPWGXKXB.js +0 -254
  191. package/dist/chunk-UPWGXKXB.js.map +0 -1
  192. package/dist/chunk-YEJR7IXO.js +0 -68
  193. package/dist/chunk-YEJR7IXO.js.map +0 -1
  194. package/dist/chunk-ZXICDSAK.js +0 -907
  195. package/dist/chunk-ZXICDSAK.js.map +0 -1
  196. package/dist/completion-gate-Bv47cOnn.d.ts +0 -256
  197. package/dist/conversation.js.map +0 -1
  198. package/dist/coordination-CxtzMxSM.d.ts +0 -2570
  199. package/dist/environment-provider.js.map +0 -1
  200. package/dist/improve--2A0gK1-.d.ts +0 -440
  201. package/dist/improvement-adapter-HAZz-7vK.d.ts +0 -203
  202. package/dist/knowledge.js.map +0 -1
  203. package/dist/local-harness-CtK9dSny.d.ts +0 -175
  204. package/dist/loop-runner-bin-DUOGtvOl.d.ts +0 -207
  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-DzkUY3HQ.d.ts +0 -271
  209. package/dist/sanitize-DEbPNtyI.d.ts +0 -328
  210. package/dist/structural-rollout-C4mabf87.d.ts +0 -446
  211. package/dist/supervise-7q9F5brx.d.ts +0 -379
  212. package/dist/types-BCoemcXU.d.ts +0 -802
  213. package/dist/types-BwoZWq-i.d.ts +0 -510
  214. package/dist/types-Cbp72qyu.d.ts +0 -491
  215. package/dist/types-CmYCMbFT.d.ts +0 -203
  216. package/dist/types-CvNwMzQt.d.ts +0 -957
  217. package/dist/worktree-fanout-WsOzt8qu.d.ts +0 -999
@@ -1,175 +0,0 @@
1
- import { ChildProcess } from 'node:child_process';
2
-
3
- /**
4
- *
5
- * Subprocess wrappers for the local coding-harness CLIs installed in the
6
- * sandbox image (claude-code, codex, opencode). Used by the in-process
7
- * delegation executor (`createInProcessExecutor`) so a delegated coding task
8
- * spawns a real harness on a real git worktree instead of provisioning a
9
- * sibling sandbox.
10
- *
11
- * All harness invocations:
12
- * - run with `cwd` set to the worktree
13
- * - inherit env from the parent (the MCP server inside the sandbox has
14
- * the harness's auth already)
15
- * - capture stdout/stderr
16
- * - support cancellation via AbortSignal
17
- * - enforce a wall-clock timeout
18
- *
19
- * @experimental
20
- */
21
-
22
- /** Local coding harness available inside the sandbox. */
23
- type LocalHarness = 'claude' | 'codex' | 'opencode';
24
- /** @experimental */
25
- interface RunLocalHarnessOptions {
26
- harness: LocalHarness;
27
- /** Working directory for the subprocess (typically a worktree path). */
28
- cwd: string;
29
- /** Prompt forwarded as the harness CLI's task argument. */
30
- taskPrompt: string;
31
- /**
32
- * Pre-built command + args (e.g. from `harnessInvocation` so the full authored
33
- * `AgentProfile` — systemPrompt + model — reaches the harness). When set it OVERRIDES the
34
- * default prompt-only `buildArgs(taskPrompt)` path; `command` defaults to the harness's
35
- * default binary when only `args` is supplied. When absent the legacy prompt-only shape
36
- * is used unchanged.
37
- */
38
- invocation?: {
39
- command?: string;
40
- args: ReadonlyArray<string>;
41
- };
42
- /** Allow autonomous Claude edits without an interactive permission prompt.
43
- * Use only when `cwd` is an isolated candidate worktree. */
44
- dangerouslySkipPermissions?: boolean;
45
- /** Isolate Codex from ambient configuration/instructions and require JSONL token usage.
46
- * The invocation should come from `harnessInvocation(..., { codexReproducible: true })`. */
47
- codexReproducible?: boolean;
48
- /** Absolute host paths that reproducible Codex must not read. The normalized set is compiled
49
- * into the controlled permission profile and its digest is returned in execution evidence. */
50
- codexReadDeniedPaths?: ReadonlyArray<string>;
51
- /** Wall-clock kill deadline (ms). Default 5 min. Subprocess SIGTERMed on expiry. */
52
- timeoutMs?: number;
53
- /** Newest stdout/stderr bytes retained per stream. Default 64 MiB. */
54
- maxOutputBytes?: number;
55
- /** Caller cancellation. SIGTERM is sent on abort. */
56
- signal?: AbortSignal;
57
- /** Override env (defaults to inheriting from the parent). */
58
- env?: NodeJS.ProcessEnv;
59
- /**
60
- * Test seam — inject a custom spawner so unit tests can mock the
61
- * subprocess without touching the OS. Defaults to node's `child_process.spawn`.
62
- */
63
- spawn?: (command: string, args: ReadonlyArray<string>, opts: {
64
- cwd: string;
65
- env: NodeJS.ProcessEnv;
66
- stdio: 'pipe';
67
- detached: boolean;
68
- }) => ChildProcess;
69
- /** Test seam for locating the native Codex executable before it is staged in the worktree. */
70
- resolveCodexExecutable?: (command: string, env: NodeJS.ProcessEnv) => Promise<string>;
71
- }
72
- /** Exact aggregate usage emitted by Codex's terminal `turn.completed` JSONL event. */
73
- interface CodexTokenUsage {
74
- inputTokens: number;
75
- cachedInputTokens: number;
76
- outputTokens: number;
77
- reasoningOutputTokens: number;
78
- }
79
- /** Isolation settings asserted before a reproducible Codex run is allowed to start. */
80
- interface CodexExecutionPolicy {
81
- sessionPersistence: 'ephemeral';
82
- userConfig: false;
83
- rules: false;
84
- projectInstructions: false;
85
- skillInstructions: false;
86
- appInstructions: false;
87
- toolSuggestions: false;
88
- multiAgentInstructions: false;
89
- sandbox: 'workspace-write';
90
- permissionProfile: 'agent_runtime_reproducible';
91
- approvalPolicy: 'never';
92
- shellNetwork: false;
93
- webSearch: false;
94
- serviceTier: 'default';
95
- shellEnvironment: 'core-filtered';
96
- loginShell: false;
97
- credentialsReadable: false;
98
- hostHomeReadable: false;
99
- procEnvironment: 'private-sanitized';
100
- sensitiveEnvironmentNamesVisible: false;
101
- parentRepoRead: false;
102
- gitMetadata: false;
103
- temporaryDirectory: 'workspace-private';
104
- stagedExecutable: 'static-elf-read-only';
105
- callerReadDeniedPaths: 'enforced';
106
- containerSockets: false;
107
- }
108
- /** Zero-model-call evidence for the exact Codex process about to run. */
109
- interface CodexExecutionEvidence {
110
- cliVersion: string;
111
- executableSha256: string;
112
- /** SHA-256 of the exact composed prompt argument proved present in the rendered prompt. */
113
- requestedPromptSha256: string;
114
- effectivePromptSha256: string;
115
- nonPromptArgsSha256: string;
116
- controlledConfigSha256: string;
117
- /** Sorted normalized paths compiled into the permission profile. */
118
- readDeniedPaths: string[];
119
- readDeniedPathsSha256: string;
120
- readDeniedPathCount: number;
121
- policy: CodexExecutionPolicy;
122
- }
123
- /** @experimental */
124
- interface LocalHarnessResult {
125
- /** OS exit code. `null` when killed before exit. */
126
- exitCode: number | null;
127
- /** Concatenated stdout. */
128
- stdout: string;
129
- /** Concatenated stderr. */
130
- stderr: string;
131
- /** Set when the process exited via signal (timeout / abort). */
132
- killedBySignal: NodeJS.Signals | null;
133
- /** Wall-clock duration ms (spawn → exit). */
134
- durationMs: number;
135
- /** Set when timeoutMs elapsed before exit. */
136
- timedOut: boolean;
137
- /**
138
- * Set when the caller's AbortSignal fired before this result settled.
139
- * Optional so injected runners and stored results from older releases remain valid.
140
- */
141
- aborted?: boolean;
142
- /** Present for a reproducible Codex run; parsed from the real terminal JSONL event. */
143
- usage?: CodexTokenUsage;
144
- /** Present for reproducible Codex runs; generated and checked before model execution. */
145
- evidence?: CodexExecutionEvidence;
146
- }
147
- /**
148
- * Spawn a local coding harness CLI as a subprocess + collect its output.
149
- *
150
- * NOT responsible for parsing the harness's output or extracting a diff —
151
- * the in-process executor's `streamPrompt` orchestrates `git diff` against
152
- * the worktree after this resolves. This function is intentionally narrow:
153
- * spawn, wait, capture, return.
154
- *
155
- * Fails loud — throws when:
156
- * - `cwd` doesn't exist (subprocess emits ENOENT; surfaced as Error)
157
- * - the harness binary is not on PATH (ENOENT)
158
- * - the caller signal was already aborted before process launch
159
- *
160
- * Does NOT throw when:
161
- * - the subprocess exits non-zero (`result.exitCode` carries the code)
162
- * - a non-reproducible subprocess is aborted / timed out (`result.aborted` /
163
- * `result.timedOut` carries the reason even when a TERM-aware child exits zero)
164
- *
165
- * Reproducible Codex additionally requires a terminal usage event. If cancellation
166
- * prevents that event, this rejects with `CodexExecutionDiagnosticError` instead of
167
- * returning an incomplete reproducibility receipt.
168
- *
169
- * @experimental
170
- */
171
- declare function runLocalHarness(options: RunLocalHarnessOptions): Promise<LocalHarnessResult>;
172
- /** Parse and validate the one terminal usage event emitted by `codex exec --json`. */
173
- declare function parseCodexTokenUsage(stdout: string): CodexTokenUsage;
174
-
175
- export { type CodexTokenUsage as C, type LocalHarness as L, type RunLocalHarnessOptions as R, type CodexExecutionEvidence as a, type LocalHarnessResult as b, type CodexExecutionPolicy as c, parseCodexTokenUsage as p, runLocalHarness as r };
@@ -1,207 +0,0 @@
1
- import { Scenario } from '@tangle-network/agent-eval/campaign';
2
- import { SelfImproveOptions, SelfImproveResult } from '@tangle-network/agent-eval/contract';
3
- import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-CmYCMbFT.js';
4
- import { F as FactCandidate, C as CreateKbGateOptions } from './kb-gate-CwHO0vz6.js';
5
- import { B as Budget } from './types-CvNwMzQt.js';
6
- import { A as AuthoredHarness, W as WinnerStrategy, a as WorktreeFanoutOptions, b as WorktreePatchArtifact } from './worktree-fanout-WsOzt8qu.js';
7
-
8
- /**
9
- *
10
- * `runDelegatedLoop` — the configured delegated loop-runner.
11
- *
12
- * One typed entrypoint a worker agent (or a scheduled routine) calls to run a
13
- * disciplined loop in a chosen MODE, over agent-runtime's hardened engines:
14
- *
15
- * code → build-in-a-loop on the GENERIC recursive path (worktreeLoopRunner: author one
16
- * `AgentProfile` per harness → worktree-CLI leaves → `patchDelivered` gate)
17
- * review → caller-registered runner — a `code` runner with an approval gate over candidates
18
- * research → research-in-a-loop with valid-only KB growth (createKbGate)
19
- * audit → analyze trace/run data → findings (runAnalystLoop, caller-wired)
20
- * self-improve → closed-loop text/config optimization (selfImprove, held-out gated)
21
- *
22
- * It is intentionally a thin façade: the value is that EVERY product reuses the
23
- * one hardened engine instead of forking delegation logic. The dispatcher owns
24
- * mode routing, timing, fail-loud on an unregistered mode, and a uniform result
25
- * shape; each mode's engine is a pre-configured runner in the registry (build it
26
- * with the factories below, or inject your own / a stub).
27
- *
28
- * @experimental
29
- */
30
-
31
- /** All valid delegated-loop mode names — used for validation and CLI surfaces. @experimental */
32
- declare const DELEGATED_LOOP_MODES: readonly ["code", "review", "research", "audit", "self-improve"];
33
- /** @experimental */
34
- type DelegatedLoopMode = (typeof DELEGATED_LOOP_MODES)[number];
35
- /** Type guard — returns true when `value` is a valid `DelegatedLoopMode` string. @experimental */
36
- declare function isDelegatedLoopMode(value: unknown): value is DelegatedLoopMode;
37
- /** @experimental A pre-configured loop for one mode. Returns the mode's raw
38
- * output; the dispatcher wraps it in a {@link DelegatedLoopResult}. */
39
- type DelegatedLoopRunner<T = unknown> = (signal: AbortSignal) => Promise<T>;
40
- /** @experimental Mode → configured runner. Partial: only register the modes a
41
- * given product/routine actually uses. */
42
- type DelegatedLoopRegistry = Partial<Record<DelegatedLoopMode, DelegatedLoopRunner>>;
43
- /** @experimental Uniform result — never throws from a registered runner; a
44
- * thrown engine becomes `{ ok: false, error }` so a routine can record + move on. */
45
- interface DelegatedLoopResult<T = unknown> {
46
- mode: DelegatedLoopMode;
47
- ok: boolean;
48
- output?: T;
49
- error?: string;
50
- durationMs: number;
51
- }
52
- /** @experimental */
53
- interface RunDelegatedLoopOptions {
54
- signal?: AbortSignal;
55
- /** Clock override for deterministic tests. */
56
- now?: () => number;
57
- }
58
- /**
59
- *
60
- * Dispatch a configured loop by mode. Fails loud (throws `ConfigError`) when no
61
- * runner is registered for the mode — a routine pointed at an unwired mode is a
62
- * config bug, not a silent no-op. A runner that throws is captured as
63
- * `{ ok: false }` so unattended runs record the failure rather than crash.
64
- *
65
- * @experimental
66
- */
67
- declare function runDelegatedLoop<T = unknown>(mode: DelegatedLoopMode, registry: DelegatedLoopRegistry, options?: RunDelegatedLoopOptions): Promise<DelegatedLoopResult<T>>;
68
- /** @experimental Options for the local-repo `code` runner over the GENERIC recursive path. */
69
- interface WorktreeLoopRunnerOptions {
70
- /** Absolute path to the local git checkout each worktree is cut from. */
71
- repoRoot: string;
72
- /** The instruction handed to every authored harness (composed under each profile's systemPrompt). */
73
- taskPrompt: string;
74
- /** The supervisor-authored harness profiles — one fanout item (one worktree-CLI leaf) each. */
75
- harnesses: ReadonlyArray<AuthoredHarness>;
76
- /** Conserved budget pool bounding the fanout (equal-k holds by construction). */
77
- budget: Budget;
78
- /** Shell command run in each worktree to derive the tests-PASS signal. */
79
- testCmd?: string;
80
- /** Shell command run in each worktree to derive the typecheck-PASS signal. */
81
- typecheckCmd?: string;
82
- /** Which verification signals the deliverable REQUIRES present-and-passing (default none). */
83
- require?: ReadonlyArray<'tests' | 'typecheck'>;
84
- /** Diff-size cap (lines). */
85
- maxDiffLines?: number;
86
- /** Literal path prefixes the patch must not touch (the secret-floor is always on regardless). */
87
- forbiddenPaths?: string[];
88
- /** Winner-selection strategy among gated candidates. Default `highest-score`. */
89
- winnerStrategy?: WinnerStrategy;
90
- /** Test seams forwarded to the worktree-CLI leaves so the runner drives offline. */
91
- runGit?: WorktreeFanoutOptions['runGit'];
92
- runHarness?: WorktreeFanoutOptions['runHarness'];
93
- runCommand?: WorktreeFanoutOptions['runCommand'];
94
- }
95
- /**
96
- *
97
- * `code` mode on the GENERIC recursive path: author one `AgentProfile` per harness, run them as a
98
- * `worktreeFanout` (N `createWorktreeCliExecutor` leaves, each `gateOnDeliverable`) through
99
- * `runPersonified` on the keystone Supervisor. The sandbox-session counterpart that drives the in-box
100
- * harness over a `SandboxClient` is `detachedSessionDelegate` (`./mcp/delegates`); here there is no
101
- * `runAgentRounds` driver, no role-coupled delegate — the harness list is the fanout, the gate is
102
- * `patchDelivered`,
103
- * the winner is the shared valid-only selector (NOT `defaultSelectWinner`, whose non-valid fallback
104
- * would surface an ungated patch). Equal-k holds by the conserved budget pool. Returns the winning
105
- * patch artifact, or throws when no candidate is delivered (fail loud, never a vacuous done).
106
- *
107
- * @experimental
108
- */
109
- declare function worktreeLoopRunner(options: WorktreeLoopRunnerOptions): DelegatedLoopRunner<WorktreePatchArtifact>;
110
- /** @experimental A fact rejected at the KB gate — surfaced, never dropped. */
111
- interface VetoedFact {
112
- candidate: FactCandidate;
113
- vetoedBy?: string;
114
- reason?: string;
115
- }
116
- /** @experimental */
117
- interface ResearchLoopResult {
118
- /** Facts that passed the fail-closed gate — safe to write to the KB. */
119
- accepted: FactCandidate[];
120
- /** Facts the gate vetoed in the final round — escalate, do not silently drop. */
121
- vetoed: VetoedFact[];
122
- /** Research rounds actually run. */
123
- rounds: number;
124
- }
125
- /** @experimental Options for the default `research` runner. */
126
- interface ResearchLoopRunnerOptions {
127
- /**
128
- * The research engine (the consumer's web/doc searcher + extractor). Called
129
- * each round with the prior round's vetoes so it can re-research the gaps.
130
- * Returns fact candidates carrying their grounding (`verbatimPassage` +
131
- * `sourceText`).
132
- */
133
- research: (round: number, vetoed: VetoedFact[]) => Promise<FactCandidate[]>;
134
- /** Gate config (extra judges, self-artifact kinds, …). The floor is always on. */
135
- gate?: CreateKbGateOptions;
136
- /** Max research rounds (correct-on-veto remediation). Default 1. */
137
- maxRounds?: number;
138
- }
139
- /**
140
- * `research` mode — research-in-a-loop with valid-only KB growth.
141
- *
142
- * Each round: research → gate every candidate (fail-closed; passage MUST be in
143
- * the source) → accept the clean ones → re-research the vetoed ones next round,
144
- * up to `maxRounds`. Vetoed facts in the final round are RETURNED (escalate,
145
- * never silently dropped) so the caller audits vs retries.
146
- *
147
- * @experimental
148
- */
149
- declare function researchLoopRunner(o: ResearchLoopRunnerOptions): DelegatedLoopRunner<ResearchLoopResult>;
150
- /**
151
- * `self-improve` mode — agent-eval's one-call closed improvement loop (held-out gated).
152
- *
153
- * @experimental
154
- */
155
- declare function selfImproveLoopRunner<TScenario extends Scenario, TArtifact>(options: SelfImproveOptions<TScenario, TArtifact>): DelegatedLoopRunner<SelfImproveResult<TScenario, TArtifact>>;
156
- /**
157
- * `audit` mode — analyst loop over captured trace/run data.
158
- *
159
- * @experimental
160
- */
161
- declare function auditLoopRunner<TProposal = unknown, TEdit = unknown>(options: RunAnalystLoopOpts): DelegatedLoopRunner<RunAnalystLoopResult<TProposal, TEdit>>;
162
-
163
- /**
164
- *
165
- * `agent-runtime-loop` — the schedulable entrypoint for the configured
166
- * delegated loop-runner. A cron job / routine / Makefile target invokes:
167
- *
168
- * agent-runtime-loop --mode research --config ./loops.config.js
169
- *
170
- * The config module wires the registry (with full access to env / creds —
171
- * which is why the deps live there, not in this generic bin). It must default-
172
- * export a `DelegatedLoopRegistry`, or a `() => DelegatedLoopRegistry | Promise<…>`.
173
- * The bin runs the selected mode, prints the `DelegatedLoopResult` as JSON, and
174
- * exits 0 on `ok`, 1 on a recorded failure, 2 on a usage/config error.
175
- *
176
- * @experimental
177
- */
178
-
179
- /** @experimental Parsed CLI invocation. */
180
- interface LoopRunnerCliArgs {
181
- mode: string;
182
- /** Loads the registry — the bin wires this from `--config`; tests inject a stub. */
183
- loadRegistry: () => Promise<DelegatedLoopRegistry> | DelegatedLoopRegistry;
184
- now?: () => number;
185
- }
186
- /** @experimental */
187
- interface LoopRunnerCliResult {
188
- exitCode: number;
189
- result?: DelegatedLoopResult;
190
- error?: string;
191
- }
192
- /**
193
- *
194
- * Pure CLI core (no process / argv / IO) so it's unit-testable: validate the
195
- * mode, load the registry, dispatch, map to an exit code (0 ok / 1 failed /
196
- * 2 usage). Exported for embedding in custom runners + tests.
197
- *
198
- * @experimental
199
- */
200
- declare function runLoopRunnerCli(args: LoopRunnerCliArgs): Promise<LoopRunnerCliResult>;
201
- /** Parse `--mode X --config Y` from an argv tail (`process.argv.slice(2)`). */
202
- declare function parseLoopRunnerArgv(argv: string[]): {
203
- mode?: string;
204
- config?: string;
205
- };
206
-
207
- export { DELEGATED_LOOP_MODES as D, type LoopRunnerCliArgs as L, type ResearchLoopResult as R, type VetoedFact as V, type WorktreeLoopRunnerOptions as W, type DelegatedLoopMode as a, type DelegatedLoopRegistry as b, type DelegatedLoopResult as c, type DelegatedLoopRunner as d, type LoopRunnerCliResult as e, type ResearchLoopRunnerOptions as f, type RunDelegatedLoopOptions as g, auditLoopRunner as h, isDelegatedLoopMode as i, runDelegatedLoop as j, runLoopRunnerCli as k, parseLoopRunnerArgv as p, researchLoopRunner as r, selfImproveLoopRunner as s, worktreeLoopRunner as w };
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/loops.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,46 +0,0 @@
1
- import { O as OpenAIChatTool } from './types-BwoZWq-i.js';
2
-
3
- /**
4
- *
5
- * OpenAI Chat Completions `tools[]` projection of the queue-bound agent-runtime
6
- * MCP delegation tools.
7
- *
8
- * Use when configuring `createOpenAICompatibleBackend({ tools: ... })` so the
9
- * model can call `delegate_feedback`, `delegation_status`, and
10
- * `delegation_history` through the OpenAI-compat transport (tcloud, OpenRouter,
11
- * OpenAI direct, cli-bridge). The runtime surfaces tool calls as `tool_call`
12
- * stream events — execution is the caller's responsibility (typically the
13
- * parent sandbox runtime's MCP mount).
14
- *
15
- * Sandbox-SDK callers do NOT need this helper: the sandbox runtime mounts
16
- * MCP servers natively and the in-sandbox harness discovers tools via the
17
- * runtime, not via an OpenAI tools array.
18
- *
19
- * Tool name + description + JSON-schema are pulled from the canonical
20
- * `DELEGATE_*` constants exported by `./tools/*` so the projection cannot
21
- * drift from the server's own validators.
22
- *
23
- * @experimental
24
- */
25
-
26
- /**
27
- *
28
- * Returns the queue-bound delegation tools projected into OpenAI Chat
29
- * Completions `tools[]` shape. The order is stable: `delegate_feedback`,
30
- * `delegation_status`, `delegation_history`.
31
- *
32
- * @experimental
33
- */
34
- declare function mcpToolsForRuntimeMcp(): OpenAIChatTool[];
35
- /**
36
- *
37
- * Subset filter — return only the projected tools whose `function.name`
38
- * appears in `names`. Useful for curated mounts (e.g. only the queue-bound
39
- * delegation tools, omitting `delegate_feedback`). Unknown names are
40
- * silently ignored; pass an empty array to get an empty result.
41
- *
42
- * @experimental
43
- */
44
- declare function mcpToolsForRuntimeMcpSubset(names: ReadonlyArray<string>): OpenAIChatTool[];
45
-
46
- export { mcpToolsForRuntimeMcpSubset as a, mcpToolsForRuntimeMcp as m };