@tangle-network/agent-runtime 0.102.0 → 0.102.2

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 (77) hide show
  1. package/dist/agent.d.ts +1 -1
  2. package/dist/agent.js +5 -3
  3. package/dist/agent.js.map +1 -1
  4. package/dist/analyst-loop.d.ts +1 -1
  5. package/dist/candidate-execution/index.js +5 -4
  6. package/dist/{chunk-SPCD4IQQ.js → chunk-377GOJHJ.js} +2 -2
  7. package/dist/{chunk-LKKIM5QD.js → chunk-3DW5DEKQ.js} +3 -3
  8. package/dist/{chunk-4AMAFNUD.js → chunk-7FJJUC73.js} +311 -40
  9. package/dist/chunk-7FJJUC73.js.map +1 -0
  10. package/dist/{chunk-DA7YL6I4.js → chunk-CK76OZPM.js} +3 -3
  11. package/dist/{chunk-KSBUSEUA.js → chunk-EKUMRQNR.js} +2 -2
  12. package/dist/{chunk-23Z7N5IG.js → chunk-J6V6DWWS.js} +5 -5
  13. package/dist/{chunk-AIBIRAJ6.js → chunk-KSM6GFHP.js} +2 -2
  14. package/dist/chunk-L5DST3QC.js +351 -0
  15. package/dist/chunk-L5DST3QC.js.map +1 -0
  16. package/dist/{chunk-TGDHHHH4.js → chunk-LJLG734E.js} +12 -253
  17. package/dist/chunk-LJLG734E.js.map +1 -0
  18. package/dist/{chunk-MAONWP4R.js → chunk-QCXD7NHM.js} +611 -1419
  19. package/dist/chunk-QCXD7NHM.js.map +1 -0
  20. package/dist/chunk-ROILMKDL.js +1338 -0
  21. package/dist/chunk-ROILMKDL.js.map +1 -0
  22. package/dist/{chunk-N2CEE5Q3.js → chunk-SCOHHMKU.js} +3 -3
  23. package/dist/chunk-SQ3ZJH3Y.js +3082 -0
  24. package/dist/chunk-SQ3ZJH3Y.js.map +1 -0
  25. package/dist/chunk-UPWGXKXB.js +254 -0
  26. package/dist/chunk-UPWGXKXB.js.map +1 -0
  27. package/dist/{chunk-KVJQV342.js → chunk-ZUCUAFVF.js} +26 -1778
  28. package/dist/chunk-ZUCUAFVF.js.map +1 -0
  29. package/dist/{completion-gate-C80jiRfN.d.ts → completion-gate-C6dhVN-N.d.ts} +2 -2
  30. package/dist/{coordination-BFE3Den7.d.ts → coordination-D9l_YmwW.d.ts} +6 -6
  31. package/dist/environment-provider.d.ts +2 -2
  32. package/dist/{improve-CIml6hT3.d.ts → improve-B40dRu0X.d.ts} +40 -19
  33. package/dist/index.d.ts +329 -21
  34. package/dist/index.js +541 -137
  35. package/dist/index.js.map +1 -1
  36. package/dist/intelligence.d.ts +5 -5
  37. package/dist/intelligence.js +7 -5
  38. package/dist/intelligence.js.map +1 -1
  39. package/dist/knowledge.d.ts +8 -8
  40. package/dist/knowledge.js +9 -7
  41. package/dist/{local-harness-ZqCx51u7.d.ts → local-harness-CtK9dSny.d.ts} +14 -2
  42. package/dist/{loop-runner-bin-Cn1N2rRo.d.ts → loop-runner-bin-PnWslIw4.d.ts} +2 -2
  43. package/dist/loop-runner-bin.d.ts +6 -6
  44. package/dist/loop-runner-bin.js +6 -4
  45. package/dist/loops.d.ts +231 -460
  46. package/dist/loops.js +58 -37
  47. package/dist/mcp/bin.js +2 -2
  48. package/dist/mcp/index.d.ts +184 -12
  49. package/dist/mcp/index.js +31 -9
  50. package/dist/mcp/index.js.map +1 -1
  51. package/dist/mcp/memory-bin.d.ts +1 -0
  52. package/dist/mcp/memory-bin.js +22 -0
  53. package/dist/mcp/memory-bin.js.map +1 -0
  54. package/dist/profiles.d.ts +3 -3
  55. package/dist/structural-rollout-D7xik9XR.d.ts +446 -0
  56. package/dist/{substrate-DO2GHNg2.d.ts → substrate-Dyiqmd3o.d.ts} +1 -1
  57. package/dist/{supervise-BLPI50-w.d.ts → supervise-BQdNAXtK.d.ts} +4 -4
  58. package/dist/testing.js +10 -8
  59. package/dist/testing.js.map +1 -1
  60. package/dist/{types-B3vAW0Oq.d.ts → types-CLat4bT9.d.ts} +1 -1
  61. package/dist/{types-CmnA2iL3.d.ts → types-D870JlH0.d.ts} +2 -2
  62. package/dist/{worktree-fanout-DCA3G4bO.d.ts → worktree-fanout-DsIR4d6w.d.ts} +234 -234
  63. package/package.json +4 -3
  64. package/dist/chunk-4AMAFNUD.js.map +0 -1
  65. package/dist/chunk-IKGCKPDX.js +0 -1115
  66. package/dist/chunk-IKGCKPDX.js.map +0 -1
  67. package/dist/chunk-KVJQV342.js.map +0 -1
  68. package/dist/chunk-MAONWP4R.js.map +0 -1
  69. package/dist/chunk-TGDHHHH4.js.map +0 -1
  70. package/dist/{chunk-SPCD4IQQ.js.map → chunk-377GOJHJ.js.map} +0 -0
  71. package/dist/{chunk-LKKIM5QD.js.map → chunk-3DW5DEKQ.js.map} +0 -0
  72. package/dist/{chunk-DA7YL6I4.js.map → chunk-CK76OZPM.js.map} +0 -0
  73. package/dist/{chunk-KSBUSEUA.js.map → chunk-EKUMRQNR.js.map} +0 -0
  74. package/dist/{chunk-23Z7N5IG.js.map → chunk-J6V6DWWS.js.map} +0 -0
  75. package/dist/{chunk-AIBIRAJ6.js.map → chunk-KSM6GFHP.js.map} +0 -0
  76. package/dist/{chunk-N2CEE5Q3.js.map → chunk-SCOHHMKU.js.map} +0 -0
  77. package/dist/{sanitize-BTSsdBXw.d.ts → sanitize-DEbPNtyI.d.ts} +58 -58
@@ -1,6 +1,6 @@
1
1
  import { WorkspacePlanReceipt } from '@tangle-network/agent-profile-materialize';
2
- import { L as LocalHarness, C as CodexTokenUsage, c as CodexExecutionPolicy } from './local-harness-ZqCx51u7.js';
3
- import { c as Executor } from './types-CmnA2iL3.js';
2
+ import { L as LocalHarness, C as CodexTokenUsage, c as CodexExecutionPolicy } from './local-harness-CtK9dSny.js';
3
+ import { c as Executor } from './types-D870JlH0.js';
4
4
 
5
5
  /**
6
6
  *
@@ -1,13 +1,13 @@
1
- import { E as ExecutorFactory, e as ExecutorRegistry, i as Spend, A as Agent, S as Scope, a as ResultBlobStore, B as Budget } from './types-CmnA2iL3.js';
1
+ import { E as ExecutorFactory, h as ExecutorRegistry, e as Spend, A as Agent, S as Scope, a as ResultBlobStore, B as Budget } from './types-D870JlH0.js';
2
2
  import { AgentProfile } from '@tangle-network/agent-interface';
3
- import { U as UiLens, a as UiFinding, C as CoderTask } from './substrate-DO2GHNg2.js';
4
- import { S as SandboxClient, E as ExecCtx, r as LoopTraceEmitter, b as LoopTraceEvent, A as AgentRunSpec } from './types-B3vAW0Oq.js';
3
+ import { a as UiLens, U as UiFinding, C as CoderTask } from './substrate-Dyiqmd3o.js';
4
+ import { S as SandboxClient, E as ExecCtx, d as LoopTraceEmitter, c as LoopTraceEvent, A as AgentRunSpec } from './types-CLat4bT9.js';
5
5
  import { BackendType, SandboxEvent, SandboxInstance } from '@tangle-network/sandbox';
6
6
  import { AgentEvalError } from '@tangle-network/agent-eval';
7
- import { b as ToolSpec, c as RuntimeTelemetryOptions, R as RouterConfig } from './sanitize-BTSsdBXw.js';
7
+ import { b as ToolSpec, c as RuntimeTelemetryOptions, R as RouterConfig } from './sanitize-DEbPNtyI.js';
8
8
  import { R as RuntimeStreamEvent } from './types-BwoZWq-i.js';
9
- import { G as GitRunner, a as WorktreeCheckRunner, D as DeliverableSpec } from './completion-gate-C80jiRfN.js';
10
- import { L as LocalHarness } from './local-harness-ZqCx51u7.js';
9
+ import { G as GitRunner, a as WorktreeCheckRunner, D as DeliverableSpec } from './completion-gate-C6dhVN-N.js';
10
+ import { L as LocalHarness } from './local-harness-CtK9dSny.js';
11
11
  import { ProviderExecutorOptions, AgentEnvironmentProviderRegistry } from './environment-provider.js';
12
12
  import { AgentEnvironmentProvider } from '@tangle-network/agent-interface/environment-provider';
13
13
 
@@ -2,8 +2,8 @@ import { AgentProfile, AgentProfileValidationResult } from '@tangle-network/agen
2
2
  import { CreateAgentEnvironmentInput, AgentTurnInput, AgentEnvironmentProvider, AgentEnvironmentCapabilities, AgentProfileRef } from '@tangle-network/agent-interface/environment-provider';
3
3
  export { AgentEnvironment, AgentEnvironmentCapabilities, AgentEnvironmentEvent, AgentEnvironmentProvider, AgentEnvironmentQuery, AgentEnvironmentStatus, AgentEnvironmentSummary, AgentProfileRef, AgentSession, AgentSessionRef, AgentSessionStatus, AgentTurnInput, AgentTurnResult, CheckpointRef, CheckpointRequest, CreateAgentEnvironmentInput, ExecRequest, ExecResult, ForkRequest, PlacementInfo, ResourceRequest, WorkspaceRequest } from '@tangle-network/agent-interface/environment-provider';
4
4
  import { CreateSandboxOptions, BackendType } from '@tangle-network/sandbox';
5
- import { R as Runtime, E as ExecutorFactory } from './types-CmnA2iL3.js';
6
- import { S as SandboxClient } from './types-B3vAW0Oq.js';
5
+ import { R as Runtime, E as ExecutorFactory } from './types-D870JlH0.js';
6
+ import { S as SandboxClient } from './types-CLat4bT9.js';
7
7
  import '@tangle-network/agent-eval';
8
8
  import './types-BwoZWq-i.js';
9
9
 
@@ -1,7 +1,7 @@
1
1
  import { LabeledScenarioStore, WorktreeAdapter, SurfaceProposer } from '@tangle-network/agent-eval/campaign';
2
2
  import { Scenario, SelfImproveOptions, SurfaceProposer as SurfaceProposer$1, MutableSurface, SelfImproveResult } from '@tangle-network/agent-eval/contract';
3
3
  import { AgentProfile, ReasoningEffort } from '@tangle-network/agent-interface';
4
- import { L as LocalHarness, C as CodexTokenUsage, a as CodexExecutionEvidence, b as LocalHarnessResult, r as runLocalHarness } from './local-harness-ZqCx51u7.js';
4
+ import { L as LocalHarness, C as CodexTokenUsage, a as CodexExecutionEvidence, b as LocalHarnessResult, r as runLocalHarness } from './local-harness-CtK9dSny.js';
5
5
  import { AnalystFinding, CostLedgerHandle, MaximumCharge } from '@tangle-network/agent-eval';
6
6
 
7
7
  /**
@@ -135,7 +135,7 @@ interface VerifyResult {
135
135
  /** Verifies the edited worktree. Sync or async; throws only on a setup fault
136
136
  * (a candidate that fails verification returns `{ok:false}`, it does not
137
137
  * throw). */
138
- type Verifier = (worktreePath: string) => Promise<VerifyResult> | VerifyResult;
138
+ type Verifier = (worktreePath: string, signal?: AbortSignal) => Promise<VerifyResult> | VerifyResult;
139
139
  interface AgenticGeneratorShotReceipt {
140
140
  readonly generation: number | null;
141
141
  readonly candidateIndex: number | null;
@@ -151,6 +151,8 @@ interface AgenticGeneratorShotReceipt {
151
151
  readonly durationMs: number;
152
152
  readonly exitCode: number | null;
153
153
  readonly timedOut: boolean;
154
+ /** True when caller cancellation reached the author process; absent in older receipts. */
155
+ readonly aborted?: boolean;
154
156
  readonly killedBySignal: NodeJS.Signals | null;
155
157
  readonly stdoutBytes: number | null;
156
158
  readonly stdoutSha256: `sha256:${string}` | null;
@@ -254,6 +256,12 @@ interface AgenticGeneratorOptions {
254
256
  }
255
257
  /** 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. */
256
258
  declare function agenticGenerator(opts?: AgenticGeneratorOptions): CandidateGenerator;
259
+ /** Turn the analyst's findings (+ optional report) into a concrete coder task —
260
+ * the senior scientific-method framing shared with the tool/MCP build prompts. */
261
+ declare function defaultBuildPrompt(args: {
262
+ report: unknown;
263
+ findings: AnalystFinding[];
264
+ }): string;
257
265
  /** A `Verifier` that runs a command in the worktree: exit 0 ⇒ ok, any other
258
266
  * exit ⇒ failed with stdout+stderr as feedback. The common case — verify by
259
267
  * `tsc --noEmit`, `pnpm build`, or a test command. A timeout is treated as a
@@ -278,6 +286,11 @@ declare function commandVerifier(command: string, args?: string[], timeoutMs?: n
278
286
  * - `surface: 'skills'` → `skillOptProposer` mutates one named inline skill.
279
287
  * - `surface: 'memory'` → `memoryCurationProposer` curates the profile's
280
288
  * additional instructions as bounded durable lessons.
289
+ * - `surface: 'rollout-policy'` → `rolloutPolicyProposer` mutates the
290
+ * inference-time `StructuralRolloutPolicy` dials ({ k, repairRounds, testgen })
291
+ * persisted in `profile.extensions['structural-rollout']` — deterministic
292
+ * bounded neighbor enumeration; the held-out gate does the deciding. No-op
293
+ * (nothing proposed, nothing shipped) when the profile has no such extension.
281
294
  * - `surface: 'agent-profile'` → caller-supplied proposer mutates the complete
282
295
  * canonical AgentProfile JSON in one candidate.
283
296
  * - `surface` ∈ {`tools`, `mcp`, `hooks`, `subagents`, `agent-profile`} → no zero-config default
@@ -297,8 +310,10 @@ declare function commandVerifier(command: string, args?: string[], timeoutMs?: n
297
310
 
298
311
  /** The executable agent lever `improve` optimizes. Profile fields remain
299
312
  * portable AgentProfile coordinates; implementation and orchestration files
300
- * use the code surface so a winner can be sealed into an exact candidate. */
301
- type ImproveSurface = 'prompt' | 'skills' | 'tools' | 'mcp' | 'hooks' | 'subagents' | 'agent-profile' | 'memory' | 'code';
313
+ * use the code surface so a winner can be sealed into an exact candidate.
314
+ * `rollout-policy` is the inference-time structuralRollout dials
315
+ * (`profile.extensions['structural-rollout']`). */
316
+ type ImproveSurface = 'prompt' | 'skills' | 'tools' | 'mcp' | 'hooks' | 'subagents' | 'agent-profile' | 'memory' | 'code' | 'rollout-policy';
302
317
  type ImproveOptions<TScenario extends Scenario, TArtifact> = Omit<SelfImproveOptions<TScenario, TArtifact>, 'analyzeGeneration' | 'baselineSurface' | 'findings' | 'gate' | 'proposer'> & {
303
318
  /** Which profile lever to optimize. Default `'prompt'`. Selects the default
304
319
  * generator + the baseline-surface extraction shape. */
@@ -316,22 +331,26 @@ type ImproveOptions<TScenario extends Scenario, TArtifact> = Omit<SelfImproveOpt
316
331
  * a `ConfigError` before the generator is built. Unset = unrestricted. */
317
332
  allowedModels?: readonly string[];
318
333
  /** Per-generation findings producer passthrough (see selfImprove.analyzeGeneration).
319
- * DEFAULT: the built-in failure distiller after each generation it turns the
320
- * worst-scoring/errored cells into structured findings ({ scenario, composite,
321
- * notes, error }) for the NEXT proposal round, so the proposer reasons over what
322
- * actually failed instead of a static seed. Pass your own producer (e.g. a
323
- * trace-analyst over the runDir's traces) to replace it; pass `null` to disable
324
- * and keep the static `findings` all the way through. */
334
+ * DEFAULT: with a real (non-`mem://`) `runDir`, the raw-trace distiller
335
+ * (`rawTraceDistiller`) typed `AnalystFinding`s pointing the proposer at the
336
+ * prior generation's actual on-disk traces; for in-memory runs (no traces on
337
+ * disk to point at), the built-in failure distiller the worst-scoring/errored
338
+ * cells distilled into typed `AnalystFinding`s for the NEXT proposal round.
339
+ * Pass your own producer to replace either; pass `null` to disable and keep the
340
+ * static `findings` all the way through. */
325
341
  analyzeGeneration?: SelfImproveOptions<TScenario, TArtifact>['analyzeGeneration'] | null;
326
- /** META-HARNESS mode: instead of the ~1500-char distilled findings, feed the
327
- * proposer RAW-TRACE FILESYSTEM CONTEXT — the PATHS into the prior generation's
342
+ /** META-HARNESS mode: instead of the distilled findings, feed the proposer
343
+ * RAW-TRACE FILESYSTEM CONTEXT — the PATHS into the prior generation's
328
344
  * real run traces under `runDir` (per-cell `spans.jsonl` event logs +
329
345
  * `cached-result.json` scores + artifacts) plus a `grep`/`cat`-to-diagnose
330
346
  * instruction — so the coding agent reads the actual failures itself rather than
331
- * a pre-summary. Requires a REAL `runDir` (that is where the traces live).
332
- * Ignored when `analyzeGeneration` is set explicitly (that wins) or is `null`
333
- * (disabled). Equivalent to `analyzeGeneration: rawTraceDistiller()`; this flag
334
- * is the one-line enable. Default `false` (the distiller stays the default). */
347
+ * a pre-summary. Unset (default): raw-trace findings whenever the run is durable
348
+ * (a real `runDir` — that is where the traces live), the distilled failure digest
349
+ * otherwise; the `memory` surface always defaults to its curation distiller.
350
+ * `true` forces `rawTraceDistiller()` even for an in-memory run (it emits a loud
351
+ * warning finding instead of paths); `false` forces the digest distiller even
352
+ * with a real `runDir`. Ignored when `analyzeGeneration` is set explicitly
353
+ * (that wins) or is `null` (disabled). */
335
354
  rawTraceContext?: boolean;
336
355
  /** CODE-surface wiring: name `surface: 'code'`, point at a repo, and the
337
356
  * facade assembles the whole candidate pipeline — an isolated incumbent plus git worktrees
@@ -385,8 +404,10 @@ interface ImproveResult<TScenario extends Scenario, TArtifact> {
385
404
  candidate: ImprovementCandidate;
386
405
  /** Held-out decision for this search result. */
387
406
  decision: SelfImproveResult<TScenario, TArtifact>['gateDecision'];
388
- /** Held-out lift (`winner − baseline` composite). */
389
- lift: number;
407
+ /** Held-out lift (`winner − baseline` composite). Absent iff
408
+ * `budget.holdout === 'deferred'` — no held-out measurement ran, so there
409
+ * is no lift to report (never a fabricated 0). */
410
+ lift?: number;
390
411
  /** Full `selfImprove` result for advanced inspection. For code runs,
391
412
  * `raw.winner.surface.worktreeRef` remains live after return whether the
392
413
  * candidate passed or held; call `dispose()` after consuming it. */
@@ -410,4 +431,4 @@ interface ImproveResult<TScenario extends Scenario, TArtifact> {
410
431
  */
411
432
  declare function improve<TScenario extends Scenario, TArtifact>(profile: AgentProfile, findings: unknown[], opts: ImproveOptions<TScenario, TArtifact>): Promise<ImproveResult<TScenario, TArtifact>>;
412
433
 
413
- export { AGENTIC_PROFILE_RESOURCE_ROOT as A, type CandidateGenerator as C, type ImproveOptions as I, type ManagedImprovementDriver as M, type Verifier as V, type ImproveResult as a, type AgenticGeneratorOptions as b, type AgenticGeneratorShotDisposition as c, type AgenticGeneratorShotExecution as d, type AgenticGeneratorShotReceipt as e, type ImproveCodeOptions as f, type ImproveSkillsOptions as g, type ImproveSurface as h, type ImprovementCandidate as i, type ImprovementDriverOptions as j, type VerifyResult as k, agenticGenerator as l, commandVerifier as m, improve as n, improvementDriver as o };
434
+ export { AGENTIC_PROFILE_RESOURCE_ROOT as A, type CandidateGenerator as C, type ImproveOptions as I, type ManagedImprovementDriver as M, type Verifier as V, type ImproveResult as a, type AgenticGeneratorOptions as b, type AgenticGeneratorShotDisposition as c, type AgenticGeneratorShotExecution as d, type AgenticGeneratorShotReceipt as e, type ImproveCodeOptions as f, type ImproveSkillsOptions as g, type ImproveSurface as h, type ImprovementCandidate as i, type ImprovementDriverOptions as j, type VerifyResult as k, agenticGenerator as l, commandVerifier as m, defaultBuildPrompt as n, improve as o, improvementDriver as p };
package/dist/index.d.ts CHANGED
@@ -6,37 +6,38 @@ export { AGENT_CANDIDATE_EXECUTION_SUPPORT, AgentCandidateBundleInput, AgentCand
6
6
  export { a as AgentCandidateExecutionAttemptRecord, b as AgentCandidateExecutionAttemptRef, c as AgentCandidateExecutionClaim, d as AgentCandidateExecutionClaimResult, A as AgentCandidateExecutionClaimStore, e as AgentCandidateExecutionCleanupHandles, f as AgentCandidateExecutionFailureClass, g as AgentCandidateExecutionFinishResult, h as AgentCandidateExecutionLease, i as AgentCandidateExecutionPhase, j as AgentCandidateExecutionPhaseResult, k as AgentCandidateExecutionRecoveryEvidence, l as AgentCandidateExecutionStageResult, m as AgentCandidateExecutionTerminalRecord, n as AgentCandidateExecutionTerminalResult, o as AgentCandidatePreparationEvidence, q as AgentCandidateRetryRejection, E as ExecutePreparedAgentCandidateOptions, I as InMemoryAgentCandidateExecutionClaimStore, P as PrepareAgentCandidateExecutionOptions, r as applyExactAgentProfileDiff, s as executePreparedAgentCandidate, t as parseExactAgentProfile, u as parseExactAgentProfileDiff, v as prepareAgentCandidateExecution } from './profile-DbfaMTdk.js';
7
7
  export { f as AgentCandidateArtifactPort, a as AgentCandidateBenchmarkGraderPort, g as AgentCandidateContainerPort, e as AgentCandidateExecutionPorts, h as AgentCandidateExecutorFinalCapture, i as AgentCandidateExecutorMemoryCapture, A as AgentCandidateExecutorPort, j as AgentCandidateExecutorProfileFile, k as AgentCandidateExecutorRequest, l as AgentCandidateExecutorStopRequest, m as AgentCandidateExecutorTaskOutcomeCapture, n as AgentCandidateExecutorWorkspaceFile, o as AgentCandidateExecutorWorkspaceInput, p as AgentCandidateMemoryPort, q as AgentCandidateMemoryResetResult, r as AgentCandidateModelLimits, s as AgentCandidateModelPort, b as AgentCandidateOutputArtifactPort, t as AgentCandidateOutputPurpose, u as AgentCandidateProtectedModelActivation, v as AgentCandidateProtectedModelReservation, w as AgentCandidateProtectedModelSettlement, x as AgentCandidateProtectedRunCapture, y as AgentCandidateRepositoryPort, c as AgentCandidateRunFinalization, d as AgentCandidateTaskExecution, z as AgentCandidateVerificationPorts, B as AgentCandidateWorkspacePort, C as CANDIDATE_TRACE_ENV, D as CANDIDATE_TRACE_TAGS, E as CanonicalCandidateDocument, P as PreparedAgentCandidateExecution, F as PreparedAgentCandidateInstruction, G as PreparedAgentCandidateKnowledge, H as PreparedAgentCandidateLaunch, I as PreparedAgentCandidateTrace, R as ResolvedAgentCandidateContainer, V as VerifiedAgentCandidate, J as VerifiedAgentCandidateTaskOutcome } from './types-CWqfCO8s.js';
8
8
  export { AuthSource, BackendCallPolicy, CircuitBreakerConfig, CircuitBreakerState, CircuitOpenError, Conversation, ConversationDriveState, ConversationJournal, ConversationJournalEntry, ConversationParticipant, ConversationPolicy, ConversationResult, ConversationStreamEvent, ConversationTurn, D1DatabaseLike, D1StmtLike, DEFAULT_MAX_DEPTH, DeadlineExceededError, FORWARD_HEADERS, FileConversationJournal, ForwardHeaderName, HaltContext, HaltPredicate, HaltReason, HaltSignal, InMemoryConversationJournal, PersonaConversationResult, PersonaDriver, PropagatedHeaders, RetryBackoff, RetryableErrorPredicate, RunConversationOptions, RunPersonaConfig, RunPersonaConversationOptions, SqlAdapter, SqlConversationJournal, TurnOrder, buildForwardHeaders, computeBackoff, createConversationBackend, d1ToSqlAdapter, defaultIsRetryable, defineConversation, isDepthExceeded, makePerAttemptSignal, readDepth, runConversation, runConversationStream, runPersonaConversation, runPersonaDispatch, sleep, slugifySpeaker, turnId } from './conversation.js';
9
- import { V as Verifier, C as CandidateGenerator } from './improve-CIml6hT3.js';
10
- export { A as AGENTIC_PROFILE_RESOURCE_ROOT, b as AgenticGeneratorOptions, c as AgenticGeneratorShotDisposition, d as AgenticGeneratorShotExecution, e as AgenticGeneratorShotReceipt, f as ImproveCodeOptions, I as ImproveOptions, a as ImproveResult, g as ImproveSkillsOptions, h as ImproveSurface, i as ImprovementCandidate, j as ImprovementDriverOptions, M as ManagedImprovementDriver, k as VerifyResult, l as agenticGenerator, m as commandVerifier, n as improve, o as improvementDriver } from './improve-CIml6hT3.js';
11
- import { ProposeContext, SurfaceProposer } from '@tangle-network/agent-eval/campaign';
9
+ import { V as Verifier, C as CandidateGenerator } from './improve-B40dRu0X.js';
10
+ export { A as AGENTIC_PROFILE_RESOURCE_ROOT, b as AgenticGeneratorOptions, c as AgenticGeneratorShotDisposition, d as AgenticGeneratorShotExecution, e as AgenticGeneratorShotReceipt, f as ImproveCodeOptions, I as ImproveOptions, a as ImproveResult, g as ImproveSkillsOptions, h as ImproveSurface, i as ImprovementCandidate, j as ImprovementDriverOptions, M as ManagedImprovementDriver, k as VerifyResult, l as agenticGenerator, m as commandVerifier, n as defaultBuildPrompt, o as improve, p as improvementDriver } from './improve-B40dRu0X.js';
11
+ import { ProposeContext, SurfaceProposer, MutableSurface } from '@tangle-network/agent-eval/campaign';
12
+ import { L as LocalHarness, r as runLocalHarness } from './local-harness-CtK9dSny.js';
13
+ import { T as ToolLoopChat, c as RuntimeTelemetryOptions } from './sanitize-DEbPNtyI.js';
14
+ export { d as RuntimeEventCollector, e as RuntimeStreamEventCollector, S as SanitizedKnowledgeReadinessReport, f as createRuntimeEventCollector, g as createRuntimeStreamEventCollector, s as sanitizeAgentRuntimeEvent, h as sanitizeKnowledgeReadinessReport, i as sanitizeRuntimeStreamEvent } from './sanitize-DEbPNtyI.js';
12
15
  import { AgentProfile, AgentProfileDiff } from '@tangle-network/agent-interface';
13
16
  export { AgentCandidateBenchmarkGraderIdentity } from '@tangle-network/agent-interface';
14
17
  import { Scenario, SelfImproveOptions } from '@tangle-network/agent-eval/contract';
15
18
  import { S as SurfaceImprovementEdit } from './improvement-adapter-HAZz-7vK.js';
16
19
  import { I as ImprovementProposalSource } from './types-CmYCMbFT.js';
20
+ import { S as StructuralRolloutPolicy } from './structural-rollout-D7xik9XR.js';
17
21
  export { AgentKnowledgeReadinessCheckOptions, CreateKnowledgeImprovementActivationExecutorOptions, KnowledgeImprovementActivationExecutor, KnowledgeImprovementCandidatePair, KnowledgeImprovementExperimentBundles, KnowledgeImprovementJobMeasurement, KnowledgeImprovementJobResult, KnowledgeReadinessCheck, KnowledgeReadinessCheckInput, KnowledgeReadinessCheckResult, RESEARCH_SUPERVISOR_SYSTEM_PROMPT, RunKnowledgeImprovementJobOptions, SupervisedKnowledgeUpdateInput, SupervisedKnowledgeUpdateOptions, SupervisedKnowledgeUpdateResult, SupervisedKnowledgeUpdater, buildKnowledgeImprovementExperimentBundles, createAgentKnowledgeReadinessCheck, createKnowledgeImprovementActivationExecutor, createSupervisedKnowledgeUpdater, formatSupervisedKnowledgeTask, knowledgeReadinessDeliverable, runKnowledgeImprovementJob, runSupervisedKnowledgeUpdate } from './knowledge.js';
18
- 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-Cn1N2rRo.js';
22
+ 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-PnWslIw4.js';
19
23
  export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-fnj6SRVg.js';
20
- export { b0 as EvalRunEvent, b1 as EvalRunGeneration, b2 as EvalRunsExportConfig, b3 as EvalRunsExportResult, b4 as INTELLIGENCE_WIRE_VERSION, b5 as LoopSpanNode, b6 as OtelAttribute, b7 as OtelExportConfig, b8 as OtelExporter, b9 as OtelSpan, ba as RuntimeEventOtelOptions, bb as buildLoopOtelSpans, bc as buildLoopSpanNodes, bd as buildRuntimeEventOtelSpans, be as createOtelExporter, bf as exportEvalRuns, bg as loopEventToOtelSpan } from './coordination-BFE3Den7.js';
24
+ export { b0 as EvalRunEvent, b1 as EvalRunGeneration, b2 as EvalRunsExportConfig, b3 as EvalRunsExportResult, b4 as INTELLIGENCE_WIRE_VERSION, b5 as LoopSpanNode, b6 as OtelAttribute, b7 as OtelExportConfig, b8 as OtelExporter, b9 as OtelSpan, ba as RuntimeEventOtelOptions, bb as buildLoopOtelSpans, bc as buildLoopSpanNodes, bd as buildRuntimeEventOtelSpans, be as createOtelExporter, bf as exportEvalRuns, bg as loopEventToOtelSpan } from './coordination-D9l_YmwW.js';
21
25
  import { K as KnowledgeReadinessDecision, A as AgentBackendInput, c as AgentExecutionBackend, h as RunAgentTaskOptions, i as AgentTaskRunResult, j as RunAgentTaskStreamOptions, R as RuntimeStreamEvent, k as RuntimeSessionStore, l as RuntimeSession } from './types-BwoZWq-i.js';
22
26
  export { m as AgentAdapter, d as AgentBackendContext, n as AgentKnowledgeProvider, e as AgentRuntimeEvent, o as AgentRuntimeEventSink, p as AgentTaskContext, g as AgentTaskSpec, f as AgentTaskStatus, B as BackendErrorDetail, b as OpenAIChatResponseFormat, O as OpenAIChatTool, a as OpenAIChatToolChoice } from './types-BwoZWq-i.js';
23
- import { R as RuntimeHooks } from './types-B3vAW0Oq.js';
24
- export { c as RuntimeDecisionEvidenceRef, d as RuntimeDecisionKind, e as RuntimeDecisionPoint, f as RuntimeHookContext, g as RuntimeHookErrorContext, h as RuntimeHookEvent, i as RuntimeHookPhase, j as RuntimeHookTarget, k as RuntimeRunHandle, l as RuntimeRunPersistenceAdapter, m as RuntimeRunRow, n as composeRuntimeHooks, o as defineRuntimeHooks, p as notifyRuntimeDecisionPoint, q as notifyRuntimeHookEvent, s as startRuntimeRun } from './types-B3vAW0Oq.js';
25
- import { c as RuntimeTelemetryOptions } from './sanitize-BTSsdBXw.js';
26
- export { d as RuntimeEventCollector, e as RuntimeStreamEventCollector, S as SanitizedKnowledgeReadinessReport, f as createRuntimeEventCollector, g as createRuntimeStreamEventCollector, s as sanitizeAgentRuntimeEvent, h as sanitizeKnowledgeReadinessReport, i as sanitizeRuntimeStreamEvent } from './sanitize-BTSsdBXw.js';
27
+ import { R as RuntimeHooks } from './types-CLat4bT9.js';
28
+ export { e as RuntimeDecisionEvidenceRef, f as RuntimeDecisionKind, g as RuntimeDecisionPoint, h as RuntimeHookContext, i as RuntimeHookErrorContext, j as RuntimeHookEvent, k as RuntimeHookPhase, l as RuntimeHookTarget, m as RuntimeRunHandle, n as RuntimeRunPersistenceAdapter, o as RuntimeRunRow, p as composeRuntimeHooks, q as defineRuntimeHooks, r as notifyRuntimeDecisionPoint, s as notifyRuntimeHookEvent, t as startRuntimeRun } from './types-CLat4bT9.js';
27
29
  import '@tangle-network/agent-interface/environment-provider';
28
- import './local-harness-ZqCx51u7.js';
29
30
  import 'node:child_process';
30
- import '@tangle-network/agent-knowledge';
31
- import './activation-Cm-9MMX1.js';
32
- import './supervise-BLPI50-w.js';
33
- import './types-CmnA2iL3.js';
31
+ import './worktree-fanout-DsIR4d6w.js';
32
+ import './types-D870JlH0.js';
34
33
  import '@tangle-network/sandbox';
35
- import './completion-gate-C80jiRfN.js';
34
+ import './completion-gate-C6dhVN-N.js';
36
35
  import '@tangle-network/agent-profile-materialize';
36
+ import '@tangle-network/agent-knowledge';
37
+ import './activation-Cm-9MMX1.js';
38
+ import './supervise-BQdNAXtK.js';
37
39
  import './kb-gate-CwHO0vz6.js';
38
- import './worktree-fanout-DCA3G4bO.js';
39
- import './substrate-DO2GHNg2.js';
40
+ import './substrate-Dyiqmd3o.js';
40
41
  import './environment-provider.js';
41
42
 
42
43
  /**
@@ -259,11 +260,188 @@ type FindingsArg = {
259
260
  report: unknown;
260
261
  findings: AnalystFinding[];
261
262
  };
263
+ /** Render findings as the ranked-evidence block every build prompt ends with. */
264
+ declare function findingLines(findings: AnalystFinding[]): string[];
262
265
  /** Build the starting instruction for a coder agent tasked with implementing a new tool. */
263
266
  declare function toolBuildPrompt(args: FindingsArg): string;
264
267
  /** Build the starting instruction for a coder agent tasked with implementing a new MCP server. */
265
268
  declare function mcpBuildPrompt(args: FindingsArg): string;
266
269
 
270
+ /**
271
+ * Campaign `spans.jsonl` → OTLP-flat JSONL — the missing converter between
272
+ * what the substrate RECORDS and what its trace analysts READ.
273
+ *
274
+ * agent-eval's `runCampaign` durably records one `spans.jsonl` per cell
275
+ * (`defaultBuildTraceWriter`): flat records
276
+ * `{ name, cellId, startMs, durationMs?, ...attributes }` with no trace/span
277
+ * ids. Its trace consumers (`OtlpFileTraceStore`, the trace-analyst registry,
278
+ * `haloProposer`/`traceAnalystProposer` via `resolveTraces`) read OTLP-flat
279
+ * JSONL (`trace_id`/`span_id`/ISO times/status/attributes — the shape
280
+ * `projectOtlpFlatLine` parses). Nothing shipped converts between the two, so
281
+ * the traces real optimization runs write could never reach the trace-native
282
+ * proposers. This module is that wire adapter:
283
+ *
284
+ * - {@link campaignCellSpansToOtlp} — one cell's `spans.jsonl` content →
285
+ * OTLP lines (a per-cell root AGENT anchor span + one child per record).
286
+ * - {@link convertCampaignDirToOtlp} — walk any campaign run/generation dir
287
+ * for `spans.jsonl` files and concatenate their OTLP lines.
288
+ * - {@link campaignTraceResolver} — the `resolveTraces` implementation for
289
+ * `traceAnalystProposer`/`haloProposer`: proposing generation g reads the
290
+ * traces the loop just recorded (`gen-<g-1>`, or `baseline` for g = 0)
291
+ * under the same `runDir` handed to `improve()`/`selfImprove()`.
292
+ *
293
+ * Trace identity: one trace per CELL, keyed on the cell's on-disk path — the
294
+ * same sanitized `cellId` recurs across the baseline and every candidate
295
+ * campaign, so folding the id alone would merge distinct runs into one trace.
296
+ * Ids are deterministic FNV-1a folds to OTLP's 32/16-hex width, so re-converts
297
+ * are stable and byte-identical.
298
+ */
299
+
300
+ interface CampaignOtlpOptions {
301
+ /** OTLP `service.name` on every emitted span. Default `'campaign'`. */
302
+ serviceName?: string;
303
+ }
304
+ /**
305
+ * Convert ONE cell's `spans.jsonl` content to OTLP-flat JSONL lines.
306
+ * `cellKey` is the identity the trace id folds from — pass the cell's on-disk
307
+ * path (unique per campaign); `cellId` is the display/attribute label.
308
+ * Returns `[]` for empty/recordless content (a dispatch that never touched
309
+ * `ctx.trace`/`ctx.cost` writes an empty file — that is data, not an error).
310
+ */
311
+ declare function campaignCellSpansToOtlp(content: string, cell: {
312
+ cellId: string;
313
+ cellKey?: string;
314
+ }, opts?: CampaignOtlpOptions): string[];
315
+ /**
316
+ * Walk `dir` (a campaign run dir, a generation dir, or a whole `selfImprove`
317
+ * run root) for `spans.jsonl` files and return their concatenated OTLP-flat
318
+ * JSONL — the exact string the `resolveTraces` contract expects. `''` when no
319
+ * spans exist (the proposers fail loud on empty by design).
320
+ */
321
+ declare function convertCampaignDirToOtlp(dir: string, opts?: CampaignOtlpOptions): string;
322
+ interface CampaignTraceResolverOptions extends CampaignOtlpOptions {
323
+ /** The `selfImprove`/`improve()` run root — the SAME `runDir` the loop
324
+ * records under (`<runDir>/baseline/...`, `<runDir>/gen-<g>/candidate-<i>/...`).
325
+ * Must be a real path; a `mem://` run records nothing to resolve. */
326
+ runDir: string;
327
+ }
328
+ /**
329
+ * Build the `resolveTraces` function `traceAnalystProposer`/`haloProposer`
330
+ * take: proposing generation g reads the traces of the campaigns the loop just
331
+ * scored — `gen-<g-1>` (or `baseline` when g = 0), falling back to every trace
332
+ * under the run root when that directory has none (e.g. a caller pointing at a
333
+ * single campaign dir rather than a loop root).
334
+ *
335
+ * traceAnalystProposer({ ..., resolveTraces: campaignTraceResolver({ runDir }) })
336
+ */
337
+ declare function campaignTraceResolver(opts: CampaignTraceResolverOptions): (ctx: Pick<ProposeContext, 'generation'>) => string;
338
+
339
+ /**
340
+ * `driverLoopGenerator` — the driver→worker `CandidateGenerator`: the build
341
+ * loop run by the ATOM instead of the canned respawn.
342
+ *
343
+ * `agenticGenerator` steers with three hardcoded conditions picking a canned
344
+ * note (`EMPTY_TREE_NOTE` / `failureNote`) and respawns. This generator swaps
345
+ * that respawn brain for a real driver: an LLM on the canonical tool-loop seam
346
+ * (`runBrainLoop` + `ToolLoopChat` — the exact loop `driverAgent` runs its
347
+ * brain on) that AUTHORS each worker instruction, OBSERVES what the session
348
+ * actually produced (diff, files, verifier output), RATES it, and DECIDES
349
+ * refine / re-scope / decompose — prompted with the senior scientific-method
350
+ * doctrine (`buildDriverSystem`).
351
+ *
352
+ * The worker stays the proven primitive: `runLocalHarness` in the candidate
353
+ * worktree, same as `agenticGenerator` — only the brain between sessions
354
+ * changes. The worktree machinery (`worktreeBuildCandidate`) and verifiers
355
+ * (`commandVerifier` / `mcpServeVerifier`) are reused verbatim.
356
+ *
357
+ * Completion-oracle invariant (the supervisor doctrine, kept): the driver's
358
+ * prose NEVER decides the outcome. After the loop, code re-checks ground
359
+ * truth — tree dirty, raw-trace evidence present, verifier green — and only
360
+ * that decides `applied`. A driver that claims success over a failing verifier
361
+ * produces a discarded candidate, not a shipped one.
362
+ *
363
+ * @experimental
364
+ */
365
+
366
+ interface DriverLoopGeneratorOptions {
367
+ /** The driver-LLM seam — ONE inference turn over the conversation + tool specs (the canonical
368
+ * `ToolLoopChat`, same seam as `driverAgent`): `routerBrain(cfg)` in production, a scripted
369
+ * mock in tests. */
370
+ brain: ToolLoopChat;
371
+ /** Local coding harness the driver's worker sessions run in the worktree. Default `claude`. */
372
+ harness?: LocalHarness;
373
+ /** Per-worker-session wall-clock timeout (ms). Default = `runLocalHarness` default (5m). */
374
+ timeoutMs?: number;
375
+ /** Build the driver's task briefing (domain framing + method + findings) — the same senior
376
+ * prompt the worker path uses (`toolBuildPrompt` / `mcpBuildPrompt`). The driver reads it and
377
+ * folds what each worker needs into its instruction. Default `defaultBuildPrompt`. */
378
+ buildPrompt?: (args: {
379
+ report: unknown;
380
+ findings: AnalystFinding[];
381
+ }) => string;
382
+ /** Verify the worktree (the intrinsic check). Exposed to the driver as `run_verifier` AND
383
+ * re-run by code as the final keep/discard gate. Omitted ⇒ the final gate is dirty-tree only
384
+ * (legacy `agenticGenerator` behavior sans verifier). */
385
+ verify?: Verifier;
386
+ /** Max driver inference turns. Default `max(8, 2 + maxShots * 3)` — room for one
387
+ * observe/rate/decide cycle per worker session plus orientation. */
388
+ maxTurns?: number;
389
+ /** The research seam (adopt-not-build): when set, the driver gets a
390
+ * `research{query}` tool + the `researchDriverNote` doctrine, so it can
391
+ * discover an EXISTING external MCP instead of building one. Wire a real
392
+ * web/search backend here — none is provisioned by default (the build
393
+ * harness has no live web access yet; flagged). */
394
+ research?: (query: string) => Promise<string>;
395
+ /** Test seam — inject the harness runner (defaults to `runLocalHarness`). */
396
+ runHarness?: typeof runLocalHarness;
397
+ /** Test seam — inject the worktree diff reader (defaults to `git diff` in the worktree). */
398
+ readDiff?: (worktreePath: string) => string;
399
+ /** Test seam — inject the changed-paths reader (defaults to `git status --porcelain`). */
400
+ changedPaths?: (worktreePath: string) => string[];
401
+ }
402
+ /** Driver→worker `CandidateGenerator`: an LLM driver on the canonical tool-loop authors, observes, rates, and steers coding-harness sessions in the worktree until the verifier passes or the session budget is spent. */
403
+ declare function driverLoopGenerator(opts: DriverLoopGeneratorOptions): CandidateGenerator;
404
+
405
+ /**
406
+ * Typed-findings accessor — the one place `unknown[]` findings become
407
+ * `AnalystFinding[]`.
408
+ *
409
+ * agent-eval's `ProposeContext.findings` is `TFindings[] = unknown[]` on the
410
+ * wire: the loop threads whatever the previous `analyzeGeneration` producer (or
411
+ * the caller's static seed) returned. Consumers that need the typed envelope
412
+ * (`claim`/`severity`/`recommended_action`) were down-casting with a bare
413
+ * `as AnalystFinding[]` — a lie at runtime whenever the seed was a raw string
414
+ * or an ad-hoc digest, which then rendered `undefined` into build prompts.
415
+ *
416
+ * `toAnalystFindings` replaces that cast: real findings pass through
417
+ * unchanged (structural guard, fail-closed), and non-conforming values are
418
+ * LIFTED into a real `AnalystFinding` envelope via `makeFinding` — the most
419
+ * actionable text becomes the claim, the original value rides in `metadata.raw`
420
+ * — so everything downstream of the accessor handles exactly one shape.
421
+ */
422
+
423
+ /** Analyst id stamped on findings lifted from untyped seed values. */
424
+ declare const LIFTED_FINDING_ANALYST_ID = "lifted-seed";
425
+ /** Structural guard for the schema-versioned `AnalystFinding` envelope.
426
+ * Strict on the identity fields `makeFinding` always populates — a partial
427
+ * look-alike is lifted (re-enveloped), not trusted. */
428
+ declare function isAnalystFinding(value: unknown): value is AnalystFinding;
429
+ interface ToAnalystFindingsOptions {
430
+ /** `analyst_id` stamped on lifted (non-conforming) values.
431
+ * Default {@link LIFTED_FINDING_ANALYST_ID}. */
432
+ analystId?: string;
433
+ /** `area` stamped on lifted values. Default `'seed'`. */
434
+ area?: string;
435
+ }
436
+ /**
437
+ * Normalize a mixed `unknown[]` findings array to `AnalystFinding[]`:
438
+ * conforming findings pass through by reference; strings and finding-ish
439
+ * objects are lifted into envelopes (claim = most actionable text, original
440
+ * value under `metadata.raw`); values with no extractable text are dropped.
441
+ * Never throws — a malformed seed must not kill a proposal round.
442
+ */
443
+ declare function toAnalystFindings(findings: readonly unknown[], opts?: ToAnalystFindingsOptions): AnalystFinding[];
444
+
267
445
  /**
268
446
  * `mcpServeVerifier` — the intrinsic verifier for a built MCP server: the
269
447
  * boot-and-probe checker named in docs/artifact-lifecycle-frontier.md. A
@@ -272,13 +450,15 @@ declare function mcpBuildPrompt(args: FindingsArg): string;
272
450
  * handshake: `initialize` → `notifications/initialized` → `tools/list`, and
273
451
  * asserts the server answers with at least `minTools` tools.
274
452
  *
453
+ * The spawn + handshake is the SHARED same-host stdio connection
454
+ * (`connectStdioMcp`) — the same code path that later serves the built server
455
+ * LIVE to a scored run (`materializeLocalMcp`), so "verified it serves" and
456
+ * "served while scored" can never drift apart.
457
+ *
275
458
  * Outcomes follow the `Verifier` contract: a server that fails to start, exits
276
459
  * early, errors the handshake, times out, or exposes no tools is a FAILED
277
460
  * candidate (`{ok:false}`, fed back into the next generation shot); a missing
278
461
  * start binary or spawn fault THROWS (a setup bug, never a silent fallback).
279
- *
280
- * Protocol matches the runtime's own stdio MCP server (src/mcp/server.ts):
281
- * newline-delimited JSON-RPC 2.0, protocol version 2024-11-05.
282
462
  */
283
463
 
284
464
  interface McpServeSpec {
@@ -295,6 +475,46 @@ interface McpServeSpec {
295
475
  /** Build a `Verifier` that boots a generated MCP server over stdio and checks it exposes tools. */
296
476
  declare function mcpServeVerifier(spec: McpServeSpec): Verifier;
297
477
 
478
+ /**
479
+ * The senior scientific-method optimizer doctrine — the ONE substantial prompt
480
+ * core shared by every builder/author surface (tool build, MCP build, codebase
481
+ * improvement, strategy authoring) and by the driver that steers build workers
482
+ * (`driverLoopGenerator`).
483
+ *
484
+ * Seeded from the proven senior prompts rather than invented: GEPA's
485
+ * `REFLECTION_SYSTEM` (localize → diagnose → minimal generalizable fix →
486
+ * preserve what works), the /evolve loop (one hypothesis with a mechanism and a
487
+ * falsifiable prediction; attack the largest measured gap first), /pursue (one
488
+ * coherent change set, no partial scaffolding), and the self-improving-loop /
489
+ * supervisor doctrine (a keep is decided by a real check, never by the author;
490
+ * observe → rate → decide). Generalized from "mutate a prompt string" to
491
+ * "build a code surface a held-out measurement will grade".
492
+ */
493
+ /**
494
+ * The shared method block every build/author prompt embeds. Domain framing
495
+ * (what a tool/MCP/codebase-edit deliverable looks like) wraps around it; this
496
+ * is the process itself.
497
+ */
498
+ declare const optimizerMethod: string;
499
+ /**
500
+ * The driver's stance for `driverLoopGenerator` — the build-domain instance of
501
+ * the supervisor doctrine (observe → rate → decide; refine / re-scope /
502
+ * decompose; the check decides delivery, never the driver's prose).
503
+ */
504
+ declare const buildDriverSystem: string;
505
+ /**
506
+ * The driver's ADOPT-not-build doctrine, appended to `buildDriverSystem` when
507
+ * a `research` tool is wired into the loop (`DriverLoopGeneratorOptions.
508
+ * research`). Kept separate so a driver WITHOUT the tool is never told to
509
+ * call a tool it does not have.
510
+ */
511
+ declare const researchDriverNote: string;
512
+ /**
513
+ * The senior authoring process for `authorStrategy` — the same method, shaped
514
+ * to the strategy contract (author-blind, conserved budget, one module out).
515
+ */
516
+ declare const strategyAuthorMethod: string;
517
+
298
518
  type ProfileDiffProposerContext<TFindings = unknown> = ProposeContext<TFindings> & {
299
519
  profile: AgentProfile;
300
520
  };
@@ -398,6 +618,94 @@ interface ReflectiveGeneratorOptions {
398
618
  /** Cheap no-sandbox `CandidateGenerator` (the `shots=1` setting): draft surface edits via the improvement adapter and apply them as one coherent candidate. */
399
619
  declare function reflectiveGenerator(opts: ReflectiveGeneratorOptions): CandidateGenerator;
400
620
 
621
+ /**
622
+ * `rolloutPolicyProposer` — the `'rollout-policy'` surface for `improve()`: the
623
+ * inference-time `StructuralRolloutPolicy` dials { k, repairRounds, testgen } as a
624
+ * held-out-gated optimizable surface.
625
+ *
626
+ * Why this seam: agent-eval's loop contract is already generic — `MutableSurface`
627
+ * admits any string, documented as "serialized tool config" — so the policy rides
628
+ * the SAME serialize→propose→gate→parse-back cycle the tools/mcp/hooks surfaces
629
+ * use. No agent-eval changes; the only net-new piece is this proposer.
630
+ *
631
+ * Why deterministic: prompt-wording proposals are a measured zero on this stack,
632
+ * and the policy space is tiny and fully enumerable. The proposer emits bounded
633
+ * single-dial neighbors (k±2 in [1,10], repairRounds±1 in [0,3], testgen±3 in
634
+ * [0,10], ≤4 per generation) and lets the held-out gate do ALL the deciding — an
635
+ * LLM proposer would add cost and nondeterminism with nothing to reason about.
636
+ *
637
+ * Persistence: the policy lives in `profile.extensions['structural-rollout']`
638
+ * (AgentProfile's designed slot for runtime-specific config). A gated winner is
639
+ * written back there by `improve()`, the same profile-field write-back every other
640
+ * config surface gets; `structuralRolloutPolicyFromProfile` is the read side a
641
+ * runtime caller feeds to `structuralRollout({ policy })`.
642
+ *
643
+ * @experimental
644
+ */
645
+
646
+ /** The profile extensions namespace the policy persists under. */
647
+ declare const ROLLOUT_POLICY_EXTENSION = "structural-rollout";
648
+ /** Proposal bounds per dial. These are the SEARCH bounds (what the proposer may
649
+ * explore), chosen so every reachable value is a measured-sane recipe: k=1 is the
650
+ * low-compute preset, testgen=0 disables check authoring, repairRounds caps where
651
+ * the measured increment flattens (+1–3pp beyond round 2). */
652
+ declare const ROLLOUT_POLICY_BOUNDS: {
653
+ readonly k: {
654
+ readonly min: 1;
655
+ readonly max: 10;
656
+ readonly step: 2;
657
+ };
658
+ readonly repairRounds: {
659
+ readonly min: 0;
660
+ readonly max: 3;
661
+ readonly step: 1;
662
+ };
663
+ readonly testgen: {
664
+ readonly min: 0;
665
+ readonly max: 10;
666
+ readonly step: 3;
667
+ };
668
+ };
669
+ /** Parse a serialized policy surface. Defensive by design — the proposer reads
670
+ * `ctx.currentSurface`, which the loop types as `string | CodeSurface`. Returns
671
+ * `undefined` (never throws) for non-strings, malformed JSON, or a shape that
672
+ * violates the policy's own invariants: the no-op signal. Unknown dials are
673
+ * dropped; `diverse`/`temperature` ride through untouched (the proposer never
674
+ * mutates them — `diverse` is a measured paired null). */
675
+ declare function parseRolloutPolicy(surface: MutableSurface): StructuralRolloutPolicy | undefined;
676
+ /** Normalize an untyped policy bag (a parsed surface or a profile extension) into
677
+ * a full `StructuralRolloutPolicy`, defaults merged. Returns `undefined` when any
678
+ * present dial violates the policy invariants (mirrors `resolvePolicy`: integer
679
+ * k ≥ 1, repairRounds ≥ 0, testgen ≥ 0) — a corrupt config must read as "not
680
+ * configured", never as a fabricated recipe. */
681
+ declare function normalizeRolloutPolicy(raw: unknown): StructuralRolloutPolicy | undefined;
682
+ /** Stable serialization — dial order is fixed so identical policies produce
683
+ * identical surfaces (the loop dedupes/hashes candidates by surface content). */
684
+ declare function serializeRolloutPolicy(policy: StructuralRolloutPolicy): string;
685
+ /** Read the persisted policy off the profile. `undefined` when the profile does
686
+ * not opt into structural rollout — the improve() surface no-ops then, because
687
+ * tuning dials nothing consumes would ship dead config. */
688
+ declare function structuralRolloutPolicyFromProfile(profile: AgentProfile): StructuralRolloutPolicy | undefined;
689
+ /** Persist a policy into the profile's extensions namespace. Shallow copy; never
690
+ * mutates the input profile (the applyWinnerToProfile contract). */
691
+ declare function applyRolloutPolicyToProfile(profile: AgentProfile, policy: StructuralRolloutPolicy): AgentProfile;
692
+ /** All bounded single-dial neighbors of `policy`, in a fixed priority order: k
693
+ * first (selection breadth carries 85–92% of the measured effect), then
694
+ * repairRounds, then testgen. Steps clamp to the dial's bounds; clamped-to-no-op
695
+ * and duplicate policies are dropped. */
696
+ declare function enumerateNeighborPolicies(policy: StructuralRolloutPolicy): StructuralRolloutPolicy[];
697
+ /**
698
+ * The deterministic `SurfaceProposer` for the `'rollout-policy'` surface.
699
+ *
700
+ * Each generation: parse the current policy surface, enumerate its bounded
701
+ * single-dial neighbors, and return at most `min(populationSize, 4)` of them,
702
+ * rotating the enumeration window by generation so successive generations explore
703
+ * different neighbors when nothing promoted. Proposes NOTHING when the surface
704
+ * carries no policy (the profile never opted in) — an empty proposal is the
705
+ * loop-native no-op, mirroring `improvementDriver`'s no-findings behavior.
706
+ */
707
+ declare function rolloutPolicyProposer(): SurfaceProposer;
708
+
401
709
  /**
402
710
  *
403
711
  * Chat-model resolution + catalog validation — the shared primitive every
@@ -823,4 +1131,4 @@ interface StreamToolLoopOptions<Raw> {
823
1131
  * `capped` if it stops for any non-completed reason with calls still pending. */
824
1132
  declare function streamToolLoop<Raw>(opts: StreamToolLoopOptions<Raw>): AsyncGenerator<StreamToolLoopYield<Raw>, void, unknown>;
825
1133
 
826
- export { AgentBackendInput, type AgentBackendKind, AgentExecutionBackend, AgentTaskRunResult, BackendTransportError, CandidateGenerator, type ChatStreamEvent, type ChatTurnHooks, type ChatTurnIdentity, type ChatTurnProducer, type ChatTurnResult, DEFAULT_ROUTER_BASE_URL, InMemoryRuntimeSessionStore, type McpServeSpec, type ModelInfo, PlannerError, type ProfileDiffProposerContext, type ProfileDiffProposerOptions, type RawTraceDistillerOptions, type ReflectiveGeneratorOptions, type ResolveAgentBackendOptions, type ResolvedChatModel, type RouterEnv, type RunChatTurnInput, type RunToolLoopOptions, RuntimeHooks, RuntimeRunStateError, RuntimeSessionStore, RuntimeStreamEvent, RuntimeTelemetryOptions, type StreamToolLoopOptions, type StreamToolLoopYield, type ToolCallOutcome, type ToolLoopAssistantToolCall, type ToolLoopCall, type ToolLoopEvent, type ToolLoopMessage, type ToolLoopResult, type ToolLoopStopReason, Verifier, applyRunRecordDefaults, cleanModelId, createOpenAICompatibleBackend, decideKnowledgeReadiness, deriveExecutionId, getModels, handleChatTurn, mcpBuildPrompt, mcpServeVerifier, profileDiffProposer, rawTraceDistiller, readinessServerSentEvent, reflectiveGenerator, resolveAgentBackend, resolveChatModel, resolveRouterBaseUrl, runAgentTask, runAgentTaskStream, runToolLoop, runtimeStreamServerSentEvent, streamToolLoop, toolBuildPrompt, validateChatModelId };
1134
+ export { AgentBackendInput, type AgentBackendKind, AgentExecutionBackend, AgentTaskRunResult, BackendTransportError, type CampaignOtlpOptions, type CampaignTraceResolverOptions, CandidateGenerator, type ChatStreamEvent, type ChatTurnHooks, type ChatTurnIdentity, type ChatTurnProducer, type ChatTurnResult, DEFAULT_ROUTER_BASE_URL, type DriverLoopGeneratorOptions, InMemoryRuntimeSessionStore, LIFTED_FINDING_ANALYST_ID, type McpServeSpec, type ModelInfo, PlannerError, type ProfileDiffProposerContext, type ProfileDiffProposerOptions, ROLLOUT_POLICY_BOUNDS, ROLLOUT_POLICY_EXTENSION, type RawTraceDistillerOptions, type ReflectiveGeneratorOptions, type ResolveAgentBackendOptions, type ResolvedChatModel, type RouterEnv, type RunChatTurnInput, type RunToolLoopOptions, RuntimeHooks, RuntimeRunStateError, RuntimeSessionStore, RuntimeStreamEvent, RuntimeTelemetryOptions, type StreamToolLoopOptions, type StreamToolLoopYield, type ToAnalystFindingsOptions, type ToolCallOutcome, type ToolLoopAssistantToolCall, type ToolLoopCall, type ToolLoopEvent, type ToolLoopMessage, type ToolLoopResult, type ToolLoopStopReason, Verifier, applyRolloutPolicyToProfile, applyRunRecordDefaults, buildDriverSystem, campaignCellSpansToOtlp, campaignTraceResolver, cleanModelId, convertCampaignDirToOtlp, createOpenAICompatibleBackend, decideKnowledgeReadiness, deriveExecutionId, driverLoopGenerator, enumerateNeighborPolicies, findingLines, getModels, handleChatTurn, isAnalystFinding, mcpBuildPrompt, mcpServeVerifier, normalizeRolloutPolicy, optimizerMethod, parseRolloutPolicy, profileDiffProposer, rawTraceDistiller, readinessServerSentEvent, reflectiveGenerator, researchDriverNote, resolveAgentBackend, resolveChatModel, resolveRouterBaseUrl, rolloutPolicyProposer, runAgentTask, runAgentTaskStream, runToolLoop, runtimeStreamServerSentEvent, serializeRolloutPolicy, strategyAuthorMethod, streamToolLoop, structuralRolloutPolicyFromProfile, toAnalystFindings, toolBuildPrompt, validateChatModelId };