@tangle-network/agent-runtime 0.73.0 → 0.75.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 (44) hide show
  1. package/dist/agent.d.ts +34 -2
  2. package/dist/agent.js +3 -2
  3. package/dist/agent.js.map +1 -1
  4. package/dist/analyst-loop.d.ts +1 -1
  5. package/dist/chunk-JPURCA2O.js +266 -0
  6. package/dist/chunk-JPURCA2O.js.map +1 -0
  7. package/dist/{chunk-7ODB76J5.js → chunk-MRWXCFV5.js} +2 -2
  8. package/dist/chunk-O2UPHN7X.js +114 -0
  9. package/dist/chunk-O2UPHN7X.js.map +1 -0
  10. package/dist/{chunk-U56XGKVY.js → chunk-QKNBYHMK.js} +3 -3
  11. package/dist/{chunk-HPYWEFVY.js → chunk-SA5GCF2X.js} +2 -2
  12. package/dist/{chunk-NCH4XUZ7.js → chunk-ZKMOIEOB.js} +13 -119
  13. package/dist/chunk-ZKMOIEOB.js.map +1 -0
  14. package/dist/{coordination-DU0saWeg.d.ts → coordination-DEVknvQo.d.ts} +3 -2
  15. package/dist/generator-YkAQrOoD.d.ts +382 -0
  16. package/dist/index.d.ts +13 -167
  17. package/dist/index.js +16 -264
  18. package/dist/index.js.map +1 -1
  19. package/dist/intelligence.d.ts +1 -1
  20. package/dist/lifecycle.d.ts +788 -200
  21. package/dist/lifecycle.js +814 -9
  22. package/dist/lifecycle.js.map +1 -1
  23. package/dist/local-harness-BE_h8szs.d.ts +93 -0
  24. package/dist/{loop-runner-bin-eD3m0rHW.d.ts → loop-runner-bin-BPthX22l.d.ts} +2 -2
  25. package/dist/loop-runner-bin.d.ts +6 -5
  26. package/dist/loop-runner-bin.js +4 -3
  27. package/dist/loops.d.ts +10 -9
  28. package/dist/loops.js +3 -2
  29. package/dist/mcp/bin.js +2 -1
  30. package/dist/mcp/bin.js.map +1 -1
  31. package/dist/mcp/index.d.ts +8 -6
  32. package/dist/mcp/index.js +6 -4
  33. package/dist/mcp/index.js.map +1 -1
  34. package/dist/mcp-serve-verifier-CT1KLTG_.d.ts +162 -0
  35. package/dist/{openai-tools-CBurv8Cu.d.ts → openai-tools-D-VCAEmw.d.ts} +1 -1
  36. package/dist/profiles.d.ts +1 -1
  37. package/dist/{types-JufmXF2a.d.ts → types-YimN9PQP.d.ts} +1 -1
  38. package/dist/{worktree-DaxOvw-C.d.ts → worktree-CtuEQ7bZ.d.ts} +2 -93
  39. package/dist/{worktree-fanout-DIffZohV.d.ts → worktree-fanout-Cdez8GR7.d.ts} +3 -2
  40. package/package.json +3 -3
  41. package/dist/chunk-NCH4XUZ7.js.map +0 -1
  42. /package/dist/{chunk-7ODB76J5.js.map → chunk-MRWXCFV5.js.map} +0 -0
  43. /package/dist/{chunk-U56XGKVY.js.map → chunk-QKNBYHMK.js.map} +0 -0
  44. /package/dist/{chunk-HPYWEFVY.js.map → chunk-SA5GCF2X.js.map} +0 -0
@@ -1,11 +1,12 @@
1
- import { L as LocalHarness, p as ExecutorFactory, E as ExecutorRegistry, o as DeliverableSpec, l as Spend, g as Agent, m as Scope, h as ResultBlobStore, B as Budget } from './worktree-DaxOvw-C.js';
1
+ import { m as ExecutorFactory, E as ExecutorRegistry, l as DeliverableSpec, i as Spend, d as Agent, j as Scope, e as ResultBlobStore, B as Budget } from './worktree-CtuEQ7bZ.js';
2
2
  import { AgentProfile } from '@tangle-network/agent-interface';
3
3
  import { U as UiLens, a as UiFinding, C as CoderTask } from './substrate-rNj6TDc3.js';
4
- import { e as LoopTraceEmitter, c as LoopTraceEvent, S as SandboxClient, A as AgentRunSpec, E as ExecCtx } from './types-JufmXF2a.js';
4
+ import { e as LoopTraceEmitter, c as LoopTraceEvent, S as SandboxClient, A as AgentRunSpec, E as ExecCtx } from './types-YimN9PQP.js';
5
5
  import { SandboxEvent, SandboxInstance, BackendType } from '@tangle-network/sandbox';
6
6
  import { AgentEvalError } from '@tangle-network/agent-eval';
7
7
  import { O as OtelExporter } from './otel-export-BKmNwiCb.js';
8
8
  import { T as ToolSpec, R as RouterConfig } from './router-client-C7kp_ECN.js';
9
+ import { L as LocalHarness } from './local-harness-BE_h8szs.js';
9
10
 
10
11
  /**
11
12
  * @experimental
@@ -0,0 +1,382 @@
1
+ import { RunRecord, AnalystFinding } from '@tangle-network/agent-eval';
2
+ import { AgentProfileResourceRef, AgentProfileMcpServer, AgentProfileHookCommand, AgentSubagentProfile, AgentProfile } from '@tangle-network/agent-interface';
3
+
4
+ /**
5
+ * `@tangle-network/agent-runtime/lifecycle` — artifact-lifecycle FOUNDATION.
6
+ *
7
+ * The §1.5 law says an agent IS its `AgentProfile`, and the profile is the WHOLE
8
+ * agent: prompt + skills + tools + mcp + hooks + subagents. This module names the
9
+ * discrete, individually-promotable PIECES of that profile — "artifacts" — and
10
+ * gives them stable ids so the rest of a self-improvement lifecycle (propose →
11
+ * measure → promote → ship) has something concrete to hang off.
12
+ *
13
+ * This is PHASE 1: just the two primitives the rest hangs off.
14
+ * 1. `ArtifactRegistry` — a typed catalog of profile artifacts with stable ids.
15
+ * 2. `measureMarginalLift` — the with-vs-without ablation: how much score/cost a
16
+ * single artifact adds on top of a baseline profile.
17
+ *
18
+ * The per-surface lifecycles, the `BuildableSurface` author contract, and the
19
+ * promotion-gate wiring are deferred to later phases.
20
+ */
21
+
22
+ /**
23
+ * The profile levers an artifact can target. One-to-one with the §1.5 profile
24
+ * surface (`prompt + skills + tools + mcp + hooks + subagents`). Each kind maps to
25
+ * exactly one field of `AgentProfile`, so an artifact can be applied onto a
26
+ * baseline profile deterministically (see `applyArtifact`).
27
+ */
28
+ type ArtifactKind = 'skill' | 'tool' | 'mcp' | 'hook' | 'subagent' | 'prompt';
29
+ /**
30
+ * The payload for each `ArtifactKind`. The shapes are the SAME types the
31
+ * `AgentProfile` field carries, so applying an artifact is a structural merge
32
+ * onto the profile — never a bespoke per-kind transform.
33
+ *
34
+ * - `prompt` — an instruction line appended to `profile.prompt.instructions`.
35
+ * - `skill` — a `SKILL.md`-style resource ref added to `profile.resources.skills`.
36
+ * - `tool` — a tool grant: `{ enabled }` set under `profile.tools[name]`.
37
+ * - `mcp` — one MCP server added under `profile.mcp[name]`.
38
+ * - `hook` — one or more hook commands added under `profile.hooks[event]`.
39
+ * - `subagent` — one subagent profile added under `profile.subagents[name]`.
40
+ */
41
+ interface ArtifactPayloads {
42
+ prompt: {
43
+ instruction: string;
44
+ };
45
+ skill: {
46
+ resource: AgentProfileResourceRef;
47
+ };
48
+ tool: {
49
+ enabled: boolean;
50
+ };
51
+ mcp: {
52
+ server: AgentProfileMcpServer;
53
+ };
54
+ hook: {
55
+ event: string;
56
+ commands: AgentProfileHookCommand[];
57
+ };
58
+ subagent: {
59
+ profile: AgentSubagentProfile;
60
+ };
61
+ }
62
+ /**
63
+ * A discrete, individually-promotable piece of an agent profile.
64
+ *
65
+ * `kind` selects the profile lever; `payload` is the kind-specific value; `key`
66
+ * is the profile-field key the payload lands under (the tool name, the MCP server
67
+ * name, the subagent name — unused for `prompt`, which appends). `id` is stable:
68
+ * once registered, it never changes, so a marginal-lift measurement, a promotion
69
+ * decision, and a ship record all reference the same artifact.
70
+ */
71
+ interface ProfileArtifact<K extends ArtifactKind = ArtifactKind> {
72
+ /** Stable id. Assigned by the registry at register time; never reassigned. */
73
+ id: string;
74
+ kind: K;
75
+ /**
76
+ * The profile-field key this artifact lands under (e.g. the tool name, the MCP
77
+ * server name, the subagent name, the hook event). Optional for `prompt`
78
+ * (instructions append, they have no key). Defaults to `id` when applying a
79
+ * keyed artifact without an explicit key.
80
+ */
81
+ key?: string;
82
+ /** Human-facing label for review surfaces. */
83
+ name: string;
84
+ /** Optional one-line description of what this artifact does. */
85
+ description?: string;
86
+ payload: ArtifactPayloads[K];
87
+ /**
88
+ * Lifecycle status — the full artifact state machine:
89
+ *
90
+ * `candidate` → `active` → `decayed` (re-promotable)
91
+ * ↘ `retired` (terminal)
92
+ *
93
+ * - `candidate` — registered, not yet promoted. The default at register time.
94
+ * - `active` — passed the promotion gate and carries a measured held-back
95
+ * lift; the only status `composeProfile` folds into a profile.
96
+ * - `decayed` — was active, but a later re-measure (`driftWatch`) found its
97
+ * lift fell below the keep-bar. Demoted out of the composed
98
+ * profile; kept as an auditable record and a re-promotion
99
+ * candidate if a future re-measure recovers the lift.
100
+ * - `retired` — permanently removed from the active set (`dedupeArtifacts`
101
+ * retires the weaker half of a non-stacking pair). Terminal.
102
+ *
103
+ * The registry never auto-promotes; every transition is an explicit call
104
+ * (`promote`/`promoteWithLift`/`demote`/`retire`).
105
+ */
106
+ status: ArtifactStatus;
107
+ /** Free-form metadata (provenance, generation id, the measured lift, …). */
108
+ metadata?: Record<string, unknown>;
109
+ }
110
+ /**
111
+ * The artifact lifecycle states. `active` is the load-bearing one — it is the
112
+ * sole status `composeProfile` folds into a deployable profile, and it is gated
113
+ * by a measured held-back lift (the registry invariant). `decayed` and `retired`
114
+ * are the two ways an artifact LEAVES the active set: a decayed artifact lost its
115
+ * lift on re-measure (reversible — `driftWatch`), a retired one was deduped away
116
+ * (terminal — `dedupeArtifacts`).
117
+ */
118
+ type ArtifactStatus = 'candidate' | 'active' | 'decayed' | 'retired';
119
+ /** The input to `register` — everything on `ProfileArtifact` except the
120
+ * registry-owned `id` and `status`. An explicit `id` may be supplied for
121
+ * deterministic/idempotent registration; otherwise the registry assigns one. */
122
+ type ArtifactInput<K extends ArtifactKind = ArtifactKind> = Omit<ProfileArtifact<K>, 'id' | 'status'> & {
123
+ id?: string;
124
+ status?: ArtifactStatus;
125
+ };
126
+
127
+ /**
128
+ * `measureMarginalLift` — the with-vs-without ablation for one artifact.
129
+ *
130
+ * "What does THIS one piece add?" is the question a lifecycle has to answer
131
+ * before it can promote anything. The answer is an ablation: score the baseline
132
+ * profile, score the baseline-plus-candidate profile, and report the delta. This
133
+ * is the marginal contribution of the artifact — the same shape the project's
134
+ * `OutcomeMeasurement` reports for an apply pass, but isolated to ONE artifact so
135
+ * a registry can rank candidates by what they individually earn.
136
+ *
137
+ * The measurement is selector-agnostic: it takes an `EvalRunner` the caller
138
+ * supplies (any function that scores a profile and reports cost), runs it twice,
139
+ * and subtracts. It never judges, never picks a winner, never re-scores on a
140
+ * holdout — those are the gate's job. It only quantifies the ablation so the gate
141
+ * has a real number to decide on.
142
+ */
143
+
144
+ /**
145
+ * The result of running an eval over ONE profile: a composite score and the cost
146
+ * to obtain it. This mirrors the project's score/cost convention (`composite`
147
+ * from `OutcomeMeasurement`, `costUsd` from `LoopResult`), so a caller can pass a
148
+ * thin wrapper over `runLoop` / `runBenchmark` / `runAgentEval` directly.
149
+ */
150
+ interface EvalResult {
151
+ /** Composite score in `[0, 1]` (higher is better) for the profile under test. */
152
+ composite: number;
153
+ /** USD cost to produce this result. */
154
+ costUsd: number;
155
+ /**
156
+ * Per-task records the run produced, when the runner emits them. The marginal
157
+ * lift only needs `composite`, but the held-out promotion gate (`HeldOutGate`)
158
+ * pairs candidate vs baseline per-task holdout records by (experimentId, seed)
159
+ * — so a runner feeding `heldOutPromotionGate` MUST populate this with rows
160
+ * carrying both `search` and `holdout` split scores. Omit it for evals scored
161
+ * to a single composite (then use `thresholdPromotionGate`).
162
+ */
163
+ runs?: RunRecord[];
164
+ /** Optional opaque passthrough (per-task cells, the raw report, …). */
165
+ details?: unknown;
166
+ }
167
+ /**
168
+ * Scores a profile. The caller wires this to whatever eval they run — a
169
+ * `runLoop` rollout, a `runBenchmark` campaign, a `runAgentEval` cohort — and
170
+ * returns the composite + cost. `signal` is forwarded for cancellation.
171
+ */
172
+ type EvalRunner = (profile: AgentProfile, signal?: AbortSignal) => Promise<EvalResult>;
173
+ interface MeasureMarginalLiftOptions {
174
+ /** The profile the artifact is measured ON TOP OF (the "without" arm). */
175
+ baseline: AgentProfile;
176
+ /** The single artifact whose marginal contribution we want. */
177
+ candidate: ProfileArtifact;
178
+ /** The eval that scores a profile. Run once per arm (twice total). */
179
+ evalRunner: EvalRunner;
180
+ /**
181
+ * A pre-computed baseline result, to skip the "without" run when the caller
182
+ * already scored the baseline (e.g. measuring several candidates against the
183
+ * same baseline). When set, the baseline arm is NOT re-run.
184
+ */
185
+ baselineResult?: EvalResult;
186
+ /** Forwarded to both `evalRunner` invocations for cancellation. */
187
+ signal?: AbortSignal;
188
+ }
189
+ /**
190
+ * The marginal lift of one artifact: the with/without ablation.
191
+ *
192
+ * `scoreDelta = with.composite − without.composite`. A positive `scoreDelta` is
193
+ * the evidence a gate needs to promote; a negative one is the signal to drop the
194
+ * artifact. `costDelta` is the extra USD the artifact costs (often positive — a
195
+ * new tool/MCP adds calls) and lets the gate weigh lift against spend.
196
+ */
197
+ interface MarginalLift {
198
+ /** The artifact id this measurement is for (stable, from the registry). */
199
+ artifactId: string;
200
+ /** Eval of `applyArtifact(baseline, candidate)`. */
201
+ withArtifact: EvalResult;
202
+ /** Eval of `baseline` alone. */
203
+ withoutArtifact: EvalResult;
204
+ /** `withArtifact.composite − withoutArtifact.composite`. */
205
+ scoreDelta: number;
206
+ /** `withArtifact.costUsd − withoutArtifact.costUsd`. */
207
+ costDelta: number;
208
+ }
209
+ /**
210
+ * Run the with/without ablation for `candidate` over `baseline` and return its
211
+ * marginal score/cost contribution.
212
+ *
213
+ * The "without" arm scores the baseline profile unchanged; the "with" arm scores
214
+ * `applyArtifact(baseline, candidate)`. Both use the same `evalRunner`, so the
215
+ * delta isolates the artifact's effect (eval method held constant). The baseline
216
+ * arm is skipped when `baselineResult` is supplied.
217
+ *
218
+ * @example
219
+ * const lift = await measureMarginalLift({
220
+ * baseline,
221
+ * candidate: registry.get(id)!,
222
+ * evalRunner: (profile) => scoreProfileOnCohort(profile),
223
+ * })
224
+ * if (lift.scoreDelta > 0) registry.promote(lift.artifactId)
225
+ */
226
+ declare function measureMarginalLift(opts: MeasureMarginalLiftOptions): Promise<MarginalLift>;
227
+
228
+ /**
229
+ * `PromotionGate` — the held-back exam that decides whether a measured candidate
230
+ * artifact is promoted into the registry.
231
+ *
232
+ * The lifecycle measures each candidate's marginal lift (`measureMarginalLift`),
233
+ * but a positive ablation delta on the practice problems is NOT enough to ship —
234
+ * that is how you overfit. The gate is the SECOND, stricter test: it decides
235
+ * promotion from a held-back split (fresh problems the candidate never tuned on)
236
+ * with a significance bar, so a promoted artifact earned its place rather than
237
+ * memorized the practice set.
238
+ *
239
+ * The interface is small and pluggable on purpose: production wires
240
+ * `heldOutPromotionGate`, which delegates to agent-eval's paper-grade
241
+ * `HeldOutGate` (paired-bootstrap CI on the held-out delta + an overfit-gap
242
+ * check). A deterministic test can inject a stub gate. The orchestrator never
243
+ * imports `HeldOutGate` directly — it only knows this interface — so the gate
244
+ * policy is a configuration choice, not a hardcode.
245
+ */
246
+
247
+ /** The verdict a gate returns for one candidate. */
248
+ interface PromotionVerdict {
249
+ /** Whether to promote the candidate into the registry as `active`. */
250
+ promote: boolean;
251
+ /** Human-readable reason (surfaced in provenance + reports). */
252
+ reason: string;
253
+ /** Machine-readable rejection code, or `null` on promote. Mirrors the
254
+ * `HeldOutGate` rejection taxonomy when that gate is the backend. */
255
+ rejectionCode: string | null;
256
+ }
257
+ /**
258
+ * Decides whether ONE measured candidate is promoted. The lifecycle calls this
259
+ * once per candidate, after `measureMarginalLift` has produced the ablation.
260
+ *
261
+ * `lift` carries the with/without ablation (the marginal contribution); the gate
262
+ * MAY use it directly (the simple "positive lift on the held-back split" policy)
263
+ * OR ignore the scalar and decide from the paired per-task records the eval
264
+ * produced (`lift.withArtifact.runs` / `lift.withoutArtifact.runs`) when a
265
+ * significance gate like `HeldOutGate` is the backend.
266
+ */
267
+ interface PromotionGate {
268
+ /** Stable label for the gate policy (provenance). */
269
+ kind: string;
270
+ decide(lift: MarginalLift): PromotionVerdict;
271
+ }
272
+ /**
273
+ * The simplest honest gate: promote iff the candidate's marginal lift on the
274
+ * held-back split clears `minDelta` (default `> 0`). It reads only the scalar
275
+ * `scoreDelta`, so it works with any `EvalRunner` (no per-task records needed).
276
+ *
277
+ * Use this when the eval is already scored ON the held-back split and you want a
278
+ * threshold, not a significance test — e.g. a deterministic fixture domain, or a
279
+ * cheap first pass before a paired-bootstrap gate. For paper-grade promotion on
280
+ * noisy live evals, prefer `heldOutPromotionGate`.
281
+ */
282
+ declare function thresholdPromotionGate(minDelta?: number): PromotionGate;
283
+ interface HeldOutPromotionGateOptions {
284
+ /** Stable label of the baseline candidate the held-out records pair against. */
285
+ baselineKey: string;
286
+ /** Minimum paired (candidate, baseline) holdout observations. Default 3. */
287
+ minProductiveRuns?: number;
288
+ /** Lower-bound on the bootstrap-CI of the median paired holdout delta. Default 0. */
289
+ pairedDeltaThreshold?: number;
290
+ /** Max allowed worsening of the (search − holdout) overfit gap. Default 0.15. */
291
+ overfitGapThreshold?: number;
292
+ /** Deterministic bootstrap seed (reproducible CIs). Default unseeded. */
293
+ seed?: number;
294
+ /** Hard ceiling on the candidate's median per-task USD cost. Default none. */
295
+ costPerTaskCeiling?: number;
296
+ }
297
+ /**
298
+ * The paper-grade promotion gate: delegate to agent-eval's `HeldOutGate`, which
299
+ * pairs the candidate and baseline per-task holdout records by (experimentId,
300
+ * seed), runs a paired-bootstrap CI on the median delta, and checks the
301
+ * overfit gap. Promotes only when the held-out generalization is real, not luck.
302
+ *
303
+ * REQUIRES the eval to surface per-task records: `lift.withArtifact.runs` (the
304
+ * candidate arm) and `lift.withoutArtifact.runs` (the baseline arm), each
305
+ * carrying matched seeds with both `search` and `holdout` split scores. When the
306
+ * records are absent, this gate FAILS LOUD — a held-out significance claim with
307
+ * no per-task data behind it would be a fabricated number, which the
308
+ * no-silent-fallback doctrine forbids. Use `thresholdPromotionGate` for evals
309
+ * that only produce a scalar composite.
310
+ */
311
+ declare function heldOutPromotionGate(opts: HeldOutPromotionGateOptions): PromotionGate;
312
+
313
+ /**
314
+ * `CandidateGenerator` — the ONE per-surface seam of the artifact lifecycle.
315
+ *
316
+ * Everything else in the lifecycle (measure → gate → store → compose) is
317
+ * surface-agnostic: it operates on `ProfileArtifact`s regardless of whether they
318
+ * are skills, tools, prompts, or MCP servers. The ONLY thing that varies by
319
+ * surface is HOW a fresh candidate piece is produced from the agent's history —
320
+ * a skill is DISTILLED from traces then refined; a tool grant is proposed from a
321
+ * "the agent lacked an action" finding; a prompt line is drafted from a recurring
322
+ * mistake. That per-surface logic is isolated here, behind one interface, so the
323
+ * orchestrator never grows a `switch (surface)`.
324
+ *
325
+ * A generator is pure-ish: given the lifecycle context (the baseline profile, the
326
+ * captured traces/findings, the registry of what already exists), it returns zero
327
+ * or more `ArtifactInput`s — candidate pieces that have NOT been measured yet.
328
+ * The orchestrator owns registration, measurement, gating, and storage; the
329
+ * generator owns only "what new pieces could this surface contribute".
330
+ *
331
+ * This is the interface the per-surface stages (skills, tools, prompt, mcp)
332
+ * implement. The skill generator (`skillGenerator`) is the reference
333
+ * implementation and the literal answer to "an empty profile has no skills":
334
+ * its `distill` step CREATES a skill from traces (the step `skillOpt` cannot do),
335
+ * then `refine` optimizes it.
336
+ */
337
+
338
+ /**
339
+ * The read-only context a generator sees when proposing candidates. It is the
340
+ * agent's HISTORY (what to learn from) plus the agent's CURRENT shape (what
341
+ * already exists, so the generator does not re-propose a duplicate).
342
+ */
343
+ interface GenerateContext {
344
+ /** The baseline profile candidates are proposed on top of. A generator reads
345
+ * it to avoid re-proposing something the profile already has. */
346
+ baseline: AgentProfile;
347
+ /** The domain/agent id the lifecycle is running for — namespaces provenance
348
+ * and lets a generator scope its proposals (e.g. distill from this domain's
349
+ * traces only). */
350
+ domain: string;
351
+ /** Trace-analyst findings to ground proposals in observed behavior. The
352
+ * firewall holds: these are OBSERVED signals, never judge verdicts. */
353
+ findings: ReadonlyArray<AnalystFinding>;
354
+ /** Raw captured trace text/records to distill from, opaque to the
355
+ * orchestrator. A skill generator's `distill` reads this; a tool generator
356
+ * may ignore it and read `findings` instead. */
357
+ traces?: unknown;
358
+ /** Cooperative cancellation, forwarded from `runLifecycle`. */
359
+ signal?: AbortSignal;
360
+ }
361
+ /**
362
+ * Produces fresh, UNMEASURED candidate artifacts for ONE profile surface.
363
+ *
364
+ * `kind` is the `ArtifactKind` this generator targets (so the orchestrator can
365
+ * report and group by surface). `generate` returns candidate inputs the
366
+ * orchestrator will register, measure (`measureMarginalLift`), gate
367
+ * (`HeldOutGate`), and — on a pass — promote into the registry. Returning `[]`
368
+ * is valid: the surface had nothing to contribute this round.
369
+ */
370
+ interface CandidateGenerator<K extends ArtifactKind = ArtifactKind> {
371
+ /** The profile surface this generator targets. */
372
+ kind: K;
373
+ /**
374
+ * Propose candidate artifacts from the lifecycle context. MUST NOT measure,
375
+ * gate, or register — that is the orchestrator's job. MUST NOT mutate
376
+ * `ctx.baseline`. Returns unmeasured `ArtifactInput`s (no lift score yet); the
377
+ * orchestrator stamps provenance + the measured lift before promotion.
378
+ */
379
+ generate(ctx: GenerateContext): Promise<ArtifactInput<K>[]>;
380
+ }
381
+
382
+ export { type ArtifactKind as A, type CandidateGenerator as C, type EvalRunner as E, type GenerateContext as G, type HeldOutPromotionGateOptions as H, type MarginalLift as M, type PromotionGate as P, type ProfileArtifact as a, type ArtifactStatus as b, type ArtifactInput as c, type EvalResult as d, type PromotionVerdict as e, type ArtifactPayloads as f, type MeasureMarginalLiftOptions as g, heldOutPromotionGate as h, measureMarginalLift as m, thresholdPromotionGate as t };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,23 @@
1
1
  import { AgentProfile, AgentEvalError, AnalystFinding, KnowledgeReadinessReport, RunRecord, ControlEvalResult, KnowledgeRequirement } from '@tangle-network/agent-eval';
2
2
  export { AgentEvalError, AgentEvalErrorCode, ConfigError, ControlBudget, ControlDecision, ControlEvalResult, ControlRunResult, ControlStep, DataAcquisitionPlan, JudgeError, KnowledgeReadinessReport, KnowledgeRequirement, NotFoundError, RunRecord, ValidationError } from '@tangle-network/agent-eval';
3
- import { f as AgentBackendInput, g as AgentExecutionBackend, O as OpenAIChatTool, h as OpenAIChatToolChoice, i as AgentBackendContext, R as RuntimeStreamEvent, K as KnowledgeReadinessDecision, j as RunAgentTaskOptions, k as AgentTaskRunResult, l as RunAgentTaskStreamOptions, m as AgentRuntimeEvent, n as AgentTaskStatus, o as RuntimeSessionStore, p as RuntimeSession, b as RuntimeHooks } from './types-JufmXF2a.js';
4
- export { q as AgentAdapter, r as AgentKnowledgeProvider, s as AgentRuntimeEventSink, t as AgentTaskContext, u as AgentTaskSpec, B as BackendErrorDetail, v as RuntimeDecisionEvidenceRef, w as RuntimeDecisionKind, x as RuntimeDecisionPoint, y as RuntimeHookContext, z as RuntimeHookErrorContext, C as RuntimeHookEvent, D as RuntimeHookPhase, F as RuntimeHookTarget, G as RuntimeRunHandle, H as RuntimeRunPersistenceAdapter, J as RuntimeRunRow, M as composeRuntimeHooks, N as defineRuntimeHooks, P as notifyRuntimeDecisionPoint, Q as notifyRuntimeHookEvent, T as startRuntimeRun } from './types-JufmXF2a.js';
3
+ import { f as AgentBackendInput, g as AgentExecutionBackend, O as OpenAIChatTool, h as OpenAIChatToolChoice, i as AgentBackendContext, a as RuntimeStreamEvent, K as KnowledgeReadinessDecision, j as RunAgentTaskOptions, k as AgentTaskRunResult, l as RunAgentTaskStreamOptions, m as AgentRuntimeEvent, n as AgentTaskStatus, o as RuntimeSessionStore, p as RuntimeSession, R as RuntimeHooks } from './types-YimN9PQP.js';
4
+ export { q as AgentAdapter, r as AgentKnowledgeProvider, s as AgentRuntimeEventSink, t as AgentTaskContext, u as AgentTaskSpec, B as BackendErrorDetail, v as RuntimeDecisionEvidenceRef, w as RuntimeDecisionKind, x as RuntimeDecisionPoint, y as RuntimeHookContext, z as RuntimeHookErrorContext, C as RuntimeHookEvent, D as RuntimeHookPhase, F as RuntimeHookTarget, G as RuntimeRunHandle, H as RuntimeRunPersistenceAdapter, J as RuntimeRunRow, M as composeRuntimeHooks, N as defineRuntimeHooks, P as notifyRuntimeDecisionPoint, Q as notifyRuntimeHookEvent, T as startRuntimeRun } from './types-YimN9PQP.js';
5
5
  import { AgentProfile as AgentProfile$1 } from '@tangle-network/agent-interface';
6
- import { Scenario, ProfileDispatchFn, LabeledScenarioStore, WorktreeAdapter, SurfaceProposer } from '@tangle-network/agent-eval/campaign';
7
- import { L as LocalHarness, r as runLocalHarness } from './worktree-DaxOvw-C.js';
8
- import { Scenario as Scenario$1, SurfaceProposer as SurfaceProposer$1, JudgeConfig, MutableSurface, DispatchContext, SelfImproveBudget, SelfImproveLlm, SelfImproveResult } from '@tangle-network/agent-eval/contract';
6
+ import { Scenario, ProfileDispatchFn } from '@tangle-network/agent-eval/campaign';
7
+ import { C as CandidateGenerator } from './mcp-serve-verifier-CT1KLTG_.js';
8
+ export { A as AgenticGeneratorOptions, I as ImprovementDriverOptions, M as McpServeSpec, V as Verifier, a as VerifyResult, b as agenticGenerator, c as commandVerifier, i as improvementDriver, m as mcpServeVerifier } from './mcp-serve-verifier-CT1KLTG_.js';
9
+ import { Scenario as Scenario$1, SurfaceProposer, JudgeConfig, MutableSurface, DispatchContext, SelfImproveBudget, SelfImproveLlm, SelfImproveResult } from '@tangle-network/agent-eval/contract';
9
10
  import { S as SurfaceImprovementEdit } from './improvement-adapter-CioiEE2z.js';
10
11
  import { I as ImprovementAdapter } from './types-BC3bZpH0.js';
11
- export { D as DELEGATED_LOOP_MODES, a as DelegatedLoopMode, b as DelegatedLoopRegistry, c as DelegatedLoopResult, d as DelegatedLoopRunner, L as LoopRunnerCliArgs, e as LoopRunnerCliResult, R as ResearchLoopResult, f as ResearchLoopRunnerOptions, g as RunDelegatedLoopOptions, V as VetoedFact, W as WorktreeLoopRunnerOptions, h as auditLoopRunner, i as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, j as runDelegatedLoop, k as runLoopRunnerCli, s as selfImproveLoopRunner, w as worktreeLoopRunner } from './loop-runner-bin-eD3m0rHW.js';
12
- export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-CBurv8Cu.js';
12
+ export { D as DELEGATED_LOOP_MODES, a as DelegatedLoopMode, b as DelegatedLoopRegistry, c as DelegatedLoopResult, d as DelegatedLoopRunner, L as LoopRunnerCliArgs, e as LoopRunnerCliResult, R as ResearchLoopResult, f as ResearchLoopRunnerOptions, g as RunDelegatedLoopOptions, V as VetoedFact, W as WorktreeLoopRunnerOptions, h as auditLoopRunner, i as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, j as runDelegatedLoop, k as runLoopRunnerCli, s as selfImproveLoopRunner, w as worktreeLoopRunner } from './loop-runner-bin-BPthX22l.js';
13
+ export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-D-VCAEmw.js';
13
14
  export { E as EvalRunEvent, a as EvalRunGeneration, b as EvalRunsExportConfig, c as EvalRunsExportResult, I as INTELLIGENCE_WIRE_VERSION, L as LoopSpanNode, d as OtelAttribute, e as OtelExportConfig, O as OtelExporter, f as OtelSpan, g as buildLoopOtelSpans, h as buildLoopSpanNodes, i as createOtelExporter, j as exportEvalRuns, l as loopEventToOtelSpan } from './otel-export-BKmNwiCb.js';
14
15
  import '@tangle-network/sandbox';
16
+ import './local-harness-BE_h8szs.js';
15
17
  import 'node:child_process';
16
18
  import './kb-gate-CuzMYGYM.js';
17
- import './worktree-fanout-DIffZohV.js';
19
+ import './worktree-CtuEQ7bZ.js';
20
+ import './worktree-fanout-Cdez8GR7.js';
18
21
 
19
22
  /**
20
23
  * @stable
@@ -1156,133 +1159,6 @@ declare class PlannerError extends AgentEvalError {
1156
1159
  });
1157
1160
  }
1158
1161
 
1159
- /**
1160
- * @experimental
1161
- *
1162
- * `improvementDriver` — the ONE reflective/agentic improvement proposer for
1163
- * agent-eval's improvement loop. It implements `SurfaceProposer` and owns
1164
- * the candidate lifecycle (worktree create → generate → finalize/discard,
1165
- * × populationSize); it delegates the only thing that genuinely varies — HOW
1166
- * a candidate change is produced — to a pluggable `CandidateGenerator`.
1167
- *
1168
- * There is no separate "analyst driver" vs "autoresearch driver": those are
1169
- * the SAME driver at two settings of a dial.
1170
- * - cheap reflective path → `reflectiveGenerator` (shots=1, no sandbox;
1171
- * applies pre-drafted patches)
1172
- * - full agentic path → `agenticGenerator` (shots=N, multi-shot
1173
- * verify-in-session loop; an agent reads code +
1174
- * report, edits, and re-tries on verifier failure)
1175
- * Both emit changes into a worktree the driver finalizes into a
1176
- * `CodeSurface{ worktreeRef }` the loop measures on the holdout. See
1177
- * agent-eval's `docs/design/self-improvement-engine.md`.
1178
- */
1179
-
1180
- /** The byte-producing seam — the ONE thing that differs between the cheap
1181
- * reflective path and the full agentic path. A generator makes (uncommitted)
1182
- * changes inside `worktreePath`; the driver commits them via the worktree
1183
- * adapter's `finalize`. */
1184
- interface CandidateGenerator {
1185
- kind: string;
1186
- generate(args: {
1187
- /** The candidate worktree — a fresh checkout of baseRef. Write changes here. */
1188
- worktreePath: string;
1189
- /** Phase-2 research report (analyst findings + diff), opaque. */
1190
- report: unknown;
1191
- /** Findings resolved from the report or the loop context. */
1192
- findings: AnalystFinding[];
1193
- /** Handle to all captured data, to ground the change. */
1194
- dataset?: LabeledScenarioStore;
1195
- /** DEPTH: max iterations the generator may take (agentic uses this; the
1196
- * reflective generator ignores it). */
1197
- maxShots: number;
1198
- signal: AbortSignal;
1199
- }): Promise<{
1200
- applied: boolean;
1201
- summary: string;
1202
- }>;
1203
- }
1204
- interface ImprovementDriverOptions {
1205
- worktree: WorktreeAdapter;
1206
- generator: CandidateGenerator;
1207
- /** Base ref candidate worktrees fork from. Default `main`. */
1208
- baseRef?: string;
1209
- }
1210
- declare function improvementDriver(opts: ImprovementDriverOptions): SurfaceProposer<AnalystFinding>;
1211
-
1212
- /**
1213
- * @experimental
1214
- *
1215
- * `agenticGenerator` — the full-agentic `CandidateGenerator`: the
1216
- * `shots=N, sandbox=on` setting of the one `improvementDriver`. It runs a real
1217
- * coding harness (claude / codex / opencode) inside the candidate worktree the
1218
- * driver already created, letting the agent read the codebase + the research
1219
- * report and make the change in place. The driver then commits the worktree
1220
- * into a `CodeSurface`.
1221
- *
1222
- * Mechanism: identical to the proven Phase-2.8 in-process executor — spawn the
1223
- * harness as a subprocess with `cwd` = the worktree, on the same filesystem,
1224
- * so edits land in place (no sandbox-mount round-trip). `runLocalHarness` is
1225
- * the verified primitive. The OUTER sandbox is the improvement loop's own
1226
- * execution context; the generator does not nest a second sandbox per
1227
- * candidate (which would reintroduce a host↔sandbox worktree-transport
1228
- * problem that does not need solving here).
1229
- *
1230
- * `maxShots` is the DEPTH dial — a multi-shot verify-in-session loop, NOT the
1231
- * kernel `runLoop`. Each shot runs one full harness session in the (persistent)
1232
- * worktree; between shots the loop refines based on what the last shot produced:
1233
- * - empty tree → "you changed nothing, make the edits" → retry
1234
- * - dirty + `verify` fails → feed the verifier's failure into the next shot
1235
- * (the worktree persists, so the harness RESUMES atop its own failing
1236
- * edits with the error in hand — no `--resume` session plumbing needed,
1237
- * and harness-agnostic across claude/codex/opencode)
1238
- * - dirty + `verify` ok (or no verifier configured) → return the candidate
1239
- * A candidate that never verifies within `maxShots` is discarded (`applied:
1240
- * false`), never shipped — if you configured a verifier, a non-passing tree is
1241
- * not a candidate. With no verifier the legacy behavior holds: first dirty shot
1242
- * is the candidate.
1243
- */
1244
-
1245
- /** Outcome of verifying a candidate worktree. `feedback` (compiler errors,
1246
- * failing test output) is fed into the next shot when `ok` is false. */
1247
- interface VerifyResult {
1248
- ok: boolean;
1249
- feedback?: string;
1250
- }
1251
- /** Verifies the edited worktree. Sync or async; throws only on a setup fault
1252
- * (a candidate that fails verification returns `{ok:false}`, it does not
1253
- * throw). */
1254
- type Verifier = (worktreePath: string) => Promise<VerifyResult> | VerifyResult;
1255
- interface AgenticGeneratorOptions {
1256
- /** Local coding harness to run in the worktree. Default `claude`. */
1257
- harness?: LocalHarness;
1258
- /** Per-shot wall-clock timeout (ms). Default = `runLocalHarness` default (5m). */
1259
- timeoutMs?: number;
1260
- /** Build the harness task prompt from the report + findings. Override for
1261
- * domain phrasing; the default turns findings into a concrete coder task. */
1262
- buildPrompt?: (args: {
1263
- report: unknown;
1264
- findings: AnalystFinding[];
1265
- }) => string;
1266
- /** Verify the worktree after each dirtying shot. When set, a candidate that
1267
- * fails verification is NOT returned — the failure feeds the next shot
1268
- * (verify-in-session), up to `maxShots`; a candidate that never verifies is
1269
- * discarded (`applied:false`), never shipped. Omitted ⇒ legacy behavior:
1270
- * the first dirty shot is the candidate. See `commandVerifier`. */
1271
- verify?: Verifier;
1272
- /** Test seam — inject the harness runner (defaults to `runLocalHarness`). */
1273
- runHarness?: typeof runLocalHarness;
1274
- /** Test seam — inject the worktree-dirty check (defaults to `git status`). */
1275
- isDirty?: (worktreePath: string) => boolean;
1276
- }
1277
- declare function agenticGenerator(opts?: AgenticGeneratorOptions): CandidateGenerator;
1278
- /** A `Verifier` that runs a command in the worktree: exit 0 ⇒ ok, any other
1279
- * exit ⇒ failed with stdout+stderr as feedback. The common case — verify by
1280
- * `tsc --noEmit`, `pnpm build`, or a test command. A timeout is treated as a
1281
- * FAILED candidate (a change that hangs the build is a bad change); a missing
1282
- * binary or spawn fault throws (a setup bug, not a failed candidate — no
1283
- * silent fallback). */
1284
- declare function commandVerifier(command: string, args?: string[], timeoutMs?: number): Verifier;
1285
-
1286
1162
  /**
1287
1163
  * Build-prompt starting points for the two buildable artifact types. There is
1288
1164
  * NO `toolGenerator`/`mcpGenerator` wrapper — the factory is `agenticGenerator`
@@ -1343,7 +1219,7 @@ interface ImproveOptions<TScenario extends Scenario$1, TArtifact> {
1343
1219
  /** The `SurfaceProposer` that mutates the surface. When unset, the facade
1344
1220
  * picks the default for `surface` (`gepaProposer` for prompt, `skillOptProposer`
1345
1221
  * for skills); surfaces with no default REQUIRE this (fail-loud otherwise). */
1346
- generator?: SurfaceProposer$1;
1222
+ generator?: SurfaceProposer;
1347
1223
  /** Gate mode. `'holdout'` (default) runs the held-out promotion gate;
1348
1224
  * `'none'` is a baseline-only run (`budget.generations = 0`). */
1349
1225
  gate?: 'holdout' | 'none';
@@ -1392,36 +1268,6 @@ interface ImproveResult<TScenario extends Scenario$1, TArtifact> {
1392
1268
  */
1393
1269
  declare function improve<TScenario extends Scenario$1, TArtifact>(profile: AgentProfile$1, findings: unknown[], opts: ImproveOptions<TScenario, TArtifact>): Promise<ImproveResult<TScenario, TArtifact>>;
1394
1270
 
1395
- /**
1396
- * `mcpServeVerifier` — the intrinsic verifier for a built MCP server: the
1397
- * boot-and-probe checker named in docs/artifact-lifecycle-frontier.md. A
1398
- * generated MCP server is only a candidate if it actually *serves* — so this
1399
- * boots it over stdio (the default local MCP transport) and runs the real
1400
- * handshake: `initialize` → `notifications/initialized` → `tools/list`, and
1401
- * asserts the server answers with at least `minTools` tools.
1402
- *
1403
- * Outcomes follow the `Verifier` contract: a server that fails to start, exits
1404
- * early, errors the handshake, times out, or exposes no tools is a FAILED
1405
- * candidate (`{ok:false}`, fed back into the next generation shot); a missing
1406
- * start binary or spawn fault THROWS (a setup bug, never a silent fallback).
1407
- *
1408
- * Protocol matches the runtime's own stdio MCP server (src/mcp/server.ts):
1409
- * newline-delimited JSON-RPC 2.0, protocol version 2024-11-05.
1410
- */
1411
-
1412
- interface McpServeSpec {
1413
- /** Command that starts the built MCP server in the worktree (stdio transport). */
1414
- command: string;
1415
- args?: string[];
1416
- /** Extra env for the server process (merged over `process.env`). */
1417
- env?: Record<string, string>;
1418
- /** Handshake timeout (ms). Default 30s. */
1419
- timeoutMs?: number;
1420
- /** Minimum tools the server must expose to pass. Default 1. */
1421
- minTools?: number;
1422
- }
1423
- declare function mcpServeVerifier(spec: McpServeSpec): Verifier;
1424
-
1425
1271
  /**
1426
1272
  * @experimental
1427
1273
  *
@@ -1885,4 +1731,4 @@ interface StreamToolLoopOptions<Raw> {
1885
1731
  * `capped` if it stops for any non-completed reason with calls still pending. */
1886
1732
  declare function streamToolLoop<Raw>(opts: StreamToolLoopOptions<Raw>): AsyncGenerator<StreamToolLoopYield<Raw>, void, unknown>;
1887
1733
 
1888
- export { AgentBackendContext, AgentBackendInput, AgentExecutionBackend, AgentRuntimeEvent, AgentTaskRunResult, AgentTaskStatus, type AgenticGeneratorOptions, type AuthSource, type BackendCallPolicy, BackendTransportError, type CandidateGenerator, type ChatStreamEvent, type ChatTurnHooks, type ChatTurnIdentity, type ChatTurnProducer, type ChatTurnResult, type CircuitBreakerConfig, CircuitBreakerState, CircuitOpenError, type Conversation, type ConversationDriveState, type ConversationJournal, type ConversationJournalEntry, type ConversationParticipant, type ConversationPolicy, type ConversationResult, type ConversationStreamEvent, type ConversationTurn, type D1DatabaseLike, type D1StmtLike, DEFAULT_MAX_DEPTH, DEFAULT_ROUTER_BASE_URL, DeadlineExceededError, type EvalPersonaOptions, FORWARD_HEADERS, FileConversationJournal, type ForwardHeaderName, type HaltContext, type HaltPredicate, type HaltReason, type HaltSignal, type ImproveOptions, type ImproveResult, type ImproveSurface, type ImprovementDriverOptions, InMemoryConversationJournal, InMemoryRuntimeSessionStore, type McpServeSpec, type ModelInfo, OpenAIChatTool, OpenAIChatToolChoice, type PersonaConversationResult, type PersonaDriver, PlannerError, type PropagatedHeaders, type ReflectiveGeneratorOptions, type ResolvedChatModel, type RetryBackoff, type RetryableErrorPredicate, type RouterEnv, type RunChatTurnInput, type RunConversationOptions, type RunPersonaConfig, type RunPersonaConversationOptions, type RunToolLoopOptions, type RuntimeEventCollector, RuntimeHooks, RuntimeRunStateError, RuntimeSessionStore, RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SqlAdapter, SqlConversationJournal, type StreamToolLoopOptions, type StreamToolLoopYield, type ToolCallOutcome, type ToolLoopAssistantToolCall, type ToolLoopCall, type ToolLoopEvent, type ToolLoopMessage, type ToolLoopResult, type ToolLoopStopReason, type TurnOrder, type Verifier, type VerifyResult, agenticGenerator, applyRunRecordDefaults, buildForwardHeaders, cleanModelId, commandVerifier, computeBackoff, createConversationBackend, createIterableBackend, createOpenAICompatibleBackend, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, d1ToSqlAdapter, decideKnowledgeReadiness, defaultIsRetryable, defineConversation, deriveExecutionId, evalPersona, getModels, handleChatTurn, improve, improvementDriver, isDepthExceeded, makePerAttemptSignal, mcpBuildPrompt, mcpServeVerifier, readDepth, readinessServerSentEvent, reflectiveGenerator, resolveChatModel, resolveRouterBaseUrl, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runPersonaConversation, runPersonaDispatch, runToolLoop, runtimeStreamServerSentEvent, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, sleep, slugifySpeaker, streamToolLoop, toolBuildPrompt, turnId, validateChatModelId };
1734
+ export { AgentBackendContext, AgentBackendInput, AgentExecutionBackend, AgentRuntimeEvent, AgentTaskRunResult, AgentTaskStatus, type AuthSource, type BackendCallPolicy, BackendTransportError, CandidateGenerator, type ChatStreamEvent, type ChatTurnHooks, type ChatTurnIdentity, type ChatTurnProducer, type ChatTurnResult, type CircuitBreakerConfig, CircuitBreakerState, CircuitOpenError, type Conversation, type ConversationDriveState, type ConversationJournal, type ConversationJournalEntry, type ConversationParticipant, type ConversationPolicy, type ConversationResult, type ConversationStreamEvent, type ConversationTurn, type D1DatabaseLike, type D1StmtLike, DEFAULT_MAX_DEPTH, DEFAULT_ROUTER_BASE_URL, DeadlineExceededError, type EvalPersonaOptions, FORWARD_HEADERS, FileConversationJournal, type ForwardHeaderName, type HaltContext, type HaltPredicate, type HaltReason, type HaltSignal, type ImproveOptions, type ImproveResult, type ImproveSurface, InMemoryConversationJournal, InMemoryRuntimeSessionStore, type ModelInfo, OpenAIChatTool, OpenAIChatToolChoice, type PersonaConversationResult, type PersonaDriver, PlannerError, type PropagatedHeaders, type ReflectiveGeneratorOptions, type ResolvedChatModel, type RetryBackoff, type RetryableErrorPredicate, type RouterEnv, type RunChatTurnInput, type RunConversationOptions, type RunPersonaConfig, type RunPersonaConversationOptions, type RunToolLoopOptions, type RuntimeEventCollector, RuntimeHooks, RuntimeRunStateError, RuntimeSessionStore, RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SqlAdapter, SqlConversationJournal, type StreamToolLoopOptions, type StreamToolLoopYield, type ToolCallOutcome, type ToolLoopAssistantToolCall, type ToolLoopCall, type ToolLoopEvent, type ToolLoopMessage, type ToolLoopResult, type ToolLoopStopReason, type TurnOrder, applyRunRecordDefaults, buildForwardHeaders, cleanModelId, computeBackoff, createConversationBackend, createIterableBackend, createOpenAICompatibleBackend, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, d1ToSqlAdapter, decideKnowledgeReadiness, defaultIsRetryable, defineConversation, deriveExecutionId, evalPersona, getModels, handleChatTurn, improve, isDepthExceeded, makePerAttemptSignal, mcpBuildPrompt, readDepth, readinessServerSentEvent, reflectiveGenerator, resolveChatModel, resolveRouterBaseUrl, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runPersonaConversation, runPersonaDispatch, runToolLoop, runtimeStreamServerSentEvent, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, sleep, slugifySpeaker, streamToolLoop, toolBuildPrompt, turnId, validateChatModelId };