@tangle-network/agent-runtime 0.93.1 → 0.94.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 (74) hide show
  1. package/README.md +4 -3
  2. package/dist/agent.d.ts +1 -1
  3. package/dist/agent.js +4 -5
  4. package/dist/agent.js.map +1 -1
  5. package/dist/analyst-loop.d.ts +1 -1
  6. package/dist/candidate-execution/index.d.ts +10 -3
  7. package/dist/candidate-execution/index.js +8 -2
  8. package/dist/{chunk-XDSWWUKE.js → chunk-4E2GM63H.js} +6 -29
  9. package/dist/chunk-4E2GM63H.js.map +1 -0
  10. package/dist/{chunk-LQQPGRKT.js → chunk-4GBT4WQ6.js} +2 -2
  11. package/dist/{chunk-TKJ3Q6CQ.js → chunk-55P6V5JT.js} +2 -2
  12. package/dist/{chunk-OX3QRJOA.js → chunk-7I2AOKCI.js} +280 -250
  13. package/dist/chunk-7I2AOKCI.js.map +1 -0
  14. package/dist/{chunk-UO2L5VTP.js → chunk-FHZHADIM.js} +1328 -20
  15. package/dist/chunk-FHZHADIM.js.map +1 -0
  16. package/dist/{chunk-VMHKMNEU.js → chunk-H2D3DCEB.js} +8 -161
  17. package/dist/chunk-H2D3DCEB.js.map +1 -0
  18. package/dist/chunk-ISTDY47H.js +849 -0
  19. package/dist/chunk-ISTDY47H.js.map +1 -0
  20. package/dist/{chunk-P6B3Z7PR.js → chunk-MRYPFDHJ.js} +3 -3
  21. package/dist/{chunk-BVVRQ4YC.js → chunk-OO4EK3JB.js} +1228 -18
  22. package/dist/chunk-OO4EK3JB.js.map +1 -0
  23. package/dist/{chunk-CMYMTRGA.js → chunk-PX6SXX3M.js} +26 -3
  24. package/dist/chunk-PX6SXX3M.js.map +1 -0
  25. package/dist/{chunk-FRBHUNQ7.js → chunk-RTVVH2KL.js} +2 -2
  26. package/dist/{chunk-R5GWDTM3.js → chunk-ZEYAT33L.js} +2 -2
  27. package/dist/{completion-gate-BLaiN0-X.d.ts → completion-gate-BDkEYB_-.d.ts} +1 -1
  28. package/dist/{coordination-DxJ83oZA.d.ts → coordination-EGoRbbsd.d.ts} +4 -4
  29. package/dist/environment-provider.d.ts +2 -2
  30. package/dist/{improve-DDhQaaJT.d.ts → improve-ZzTEkpF_.d.ts} +11 -14
  31. package/dist/index.d.ts +35 -106
  32. package/dist/index.js +91 -35
  33. package/dist/index.js.map +1 -1
  34. package/dist/intelligence.d.ts +22 -5
  35. package/dist/intelligence.js +113 -19
  36. package/dist/intelligence.js.map +1 -1
  37. package/dist/knowledge.d.ts +6 -6
  38. package/dist/knowledge.js +4 -4
  39. package/dist/lifecycle.js +2 -2
  40. package/dist/{loop-runner-bin-kKUNGLyV.d.ts → loop-runner-bin-BRXC1RwC.d.ts} +2 -2
  41. package/dist/loop-runner-bin.d.ts +5 -5
  42. package/dist/loop-runner-bin.js +5 -6
  43. package/dist/loops.d.ts +456 -17
  44. package/dist/loops.js +38 -40
  45. package/dist/mcp/bin.js +4 -4
  46. package/dist/mcp/index.d.ts +8 -8
  47. package/dist/mcp/index.js +6 -7
  48. package/dist/mcp/index.js.map +1 -1
  49. package/dist/{openai-tools-E3woykz9.d.ts → openai-tools-D0ZSRCC6.d.ts} +1 -1
  50. package/dist/{prepare-DiVGKcwS.d.ts → prepare-BKxAiUcH.d.ts} +1 -1
  51. package/dist/profiles.d.ts +1 -1
  52. package/dist/{sanitize-C9go6tXj.d.ts → sanitize-C2jicjNf.d.ts} +1 -1
  53. package/dist/{supervise-T2pazU3G.d.ts → supervise-Gmf709kn.d.ts} +4 -4
  54. package/dist/{types-DAdIm4AC.d.ts → types-Cg_teUPO.d.ts} +2 -2
  55. package/dist/{types-B00NtbCs.d.ts → types-DWA64rbJ.d.ts} +1 -1
  56. package/dist/{worktree-fanout-BUb2Ag02.d.ts → worktree-fanout-BrB4att3.d.ts} +233 -233
  57. package/package.json +4 -4
  58. package/skills/build-with-agent-runtime/SKILL.md +1 -1
  59. package/dist/chunk-BVVRQ4YC.js.map +0 -1
  60. package/dist/chunk-CMYMTRGA.js.map +0 -1
  61. package/dist/chunk-FDJ7AHXG.js +0 -1229
  62. package/dist/chunk-FDJ7AHXG.js.map +0 -1
  63. package/dist/chunk-J2K6WIG6.js +0 -2172
  64. package/dist/chunk-J2K6WIG6.js.map +0 -1
  65. package/dist/chunk-OX3QRJOA.js.map +0 -1
  66. package/dist/chunk-UO2L5VTP.js.map +0 -1
  67. package/dist/chunk-VMHKMNEU.js.map +0 -1
  68. package/dist/chunk-XDSWWUKE.js.map +0 -1
  69. package/dist/structural-rollout-DHGDbhvR.d.ts +0 -446
  70. /package/dist/{chunk-LQQPGRKT.js.map → chunk-4GBT4WQ6.js.map} +0 -0
  71. /package/dist/{chunk-TKJ3Q6CQ.js.map → chunk-55P6V5JT.js.map} +0 -0
  72. /package/dist/{chunk-P6B3Z7PR.js.map → chunk-MRYPFDHJ.js.map} +0 -0
  73. /package/dist/{chunk-FRBHUNQ7.js.map → chunk-RTVVH2KL.js.map} +0 -0
  74. /package/dist/{chunk-R5GWDTM3.js.map → chunk-ZEYAT33L.js.map} +0 -0
@@ -1,5 +1,23 @@
1
1
  // src/mcp/local-harness.ts
2
2
  import { spawn } from "child_process";
3
+ var codexReasoningEffort = {
4
+ none: "none",
5
+ minimal: "minimal",
6
+ low: "low",
7
+ medium: "medium",
8
+ high: "high",
9
+ xhigh: "xhigh",
10
+ ultracode: "xhigh"
11
+ };
12
+ function codexReasoningArgs(reasoningEffort) {
13
+ const mapped = codexReasoningEffort[reasoningEffort];
14
+ if (mapped === void 0) {
15
+ throw new Error(
16
+ `harnessInvocation: unsupported Codex reasoning effort ${String(reasoningEffort)}`
17
+ );
18
+ }
19
+ return ["-c", `model_reasoning_effort="${mapped}"`];
20
+ }
3
21
  var HARNESS_INVOCATIONS = {
4
22
  claude: {
5
23
  command: "claude",
@@ -10,8 +28,9 @@ var HARNESS_INVOCATIONS = {
10
28
  },
11
29
  codex: {
12
30
  command: "codex",
13
- buildArgs: (taskPrompt) => ["run", taskPrompt],
14
- modelArgs: (model) => ["-m", model]
31
+ buildArgs: (taskPrompt) => ["exec", taskPrompt],
32
+ modelArgs: (model) => ["-m", model],
33
+ reasoningArgs: codexReasoningArgs
15
34
  },
16
35
  opencode: {
17
36
  command: "opencode",
@@ -40,6 +59,10 @@ ${taskPrompt}` : taskPrompt;
40
59
  if (typeof model === "string" && model.length > 0) {
41
60
  args.push(...invocation.modelArgs(model));
42
61
  }
62
+ const reasoningEffort = profile.model?.reasoningEffort;
63
+ if (reasoningEffort !== void 0 && invocation.reasoningArgs) {
64
+ args.push(...invocation.reasoningArgs(reasoningEffort));
65
+ }
43
66
  return { command: invocation.command, args };
44
67
  }
45
68
  var DEFAULT_TIMEOUT_MS = 5 * 60 * 1e3;
@@ -120,4 +143,4 @@ export {
120
143
  harnessInvocation,
121
144
  runLocalHarness
122
145
  };
123
- //# sourceMappingURL=chunk-CMYMTRGA.js.map
146
+ //# sourceMappingURL=chunk-PX6SXX3M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mcp/local-harness.ts"],"sourcesContent":["/**\n *\n * Subprocess wrappers for the local coding-harness CLIs installed in the\n * sandbox image (claude-code, codex, opencode). Used by the in-process\n * delegation executor (`createInProcessExecutor`) so a delegated coding task\n * spawns a real harness on a real git worktree instead of provisioning a\n * sibling sandbox.\n *\n * All harness invocations:\n * - run with `cwd` set to the worktree\n * - inherit env from the parent (the MCP server inside the sandbox has\n * the harness's auth already)\n * - capture stdout/stderr\n * - support cancellation via AbortSignal\n * - enforce a wall-clock timeout\n *\n * @experimental\n */\n\nimport { type ChildProcess, spawn } from 'node:child_process'\nimport type { AgentProfile } from '@tangle-network/agent-interface'\n\n/** Local coding harness available inside the sandbox. */\nexport type LocalHarness = 'claude' | 'codex' | 'opencode'\n\ntype ReasoningEffort = NonNullable<NonNullable<AgentProfile['model']>['reasoningEffort']>\n\nconst codexReasoningEffort: Record<ReasoningEffort, string> = {\n none: 'none',\n minimal: 'minimal',\n low: 'low',\n medium: 'medium',\n high: 'high',\n xhigh: 'xhigh',\n ultracode: 'xhigh',\n}\n\nfunction codexReasoningArgs(reasoningEffort: ReasoningEffort): string[] {\n const mapped = codexReasoningEffort[reasoningEffort]\n if (mapped === undefined) {\n throw new Error(\n `harnessInvocation: unsupported Codex reasoning effort ${String(reasoningEffort)}`,\n )\n }\n return ['-c', `model_reasoning_effort=\"${mapped}\"`]\n}\n\n/**\n * Default per-harness command + arg shape. `buildArgs` takes ONLY the task prompt and\n * emits the prompt-only invocation (no model, no system prompt) — the safe default shape\n * the in-process executor's `streamPrompt` drives. `modelArgs` maps a resolved model to\n * the harness's selector flag (every supported harness takes `-m <model>`). The §1.5\n * profile-aware mapper `harnessInvocation` composes these to thread the full\n * supervisor-authored profile (systemPrompt + model) into argv.\n */\nconst HARNESS_INVOCATIONS: Record<\n LocalHarness,\n {\n command: string\n buildArgs: (taskPrompt: string) => string[]\n /** Map a resolved model to the harness's model-selector flag. */\n modelArgs: (model: string) => string[]\n /** Map portable reasoning effort when the harness exposes a native control. */\n reasoningArgs?: (reasoningEffort: ReasoningEffort) => string[]\n }\n> = {\n claude: {\n command: 'claude',\n // `-p` IS headless/print mode; the old `--headless` flag was removed from the CLI.\n // Permission bypass is an explicit per-run opt-in below, never the public default.\n buildArgs: (taskPrompt) => ['-p', taskPrompt],\n modelArgs: (model) => ['-m', model],\n },\n codex: {\n command: 'codex',\n buildArgs: (taskPrompt) => ['exec', taskPrompt],\n modelArgs: (model) => ['-m', model],\n reasoningArgs: codexReasoningArgs,\n },\n opencode: {\n command: 'opencode',\n buildArgs: (taskPrompt) => ['run', taskPrompt],\n modelArgs: (model) => ['-m', model],\n },\n}\n\n/** Result of mapping an `AgentProfile` + task prompt onto a harness invocation. */\nexport interface HarnessInvocation {\n command: string\n args: string[]\n}\n\nexport interface HarnessInvocationOptions {\n /** Allow an unattended Claude process to edit its isolated candidate worktree.\n * Ignored by harnesses that do not use Claude's permission prompt. */\n dangerouslySkipPermissions?: boolean\n}\n\nfunction buildHarnessArgs(\n harness: LocalHarness,\n taskPrompt: string,\n options: HarnessInvocationOptions = {},\n): string[] {\n const args = HARNESS_INVOCATIONS[harness].buildArgs(taskPrompt)\n if (harness === 'claude' && options.dangerouslySkipPermissions) {\n args.push('--dangerously-skip-permissions')\n }\n return args\n}\n\n/**\n * Map a supervisor-authored `AgentProfile` + the per-task prompt onto a concrete harness\n * `command` + `args` (the §1.5 fix). UNLIKE the prompt-only `HARNESS_INVOCATIONS.buildArgs`\n * — which drops both the authored model and the system prompt — this threads the FULL\n * profile payload into argv:\n *\n * - `profile.prompt.systemPrompt` → the PROMPT channel: a portable, harness-agnostic\n * default that prepends the system prompt above the task prompt (`<system>\\n\\n<task>`),\n * so the authored standing instructions reach EVERY harness (none of the three CLIs\n * expose a portable replace-system-prompt flag for a one-shot non-interactive run).\n * - `profile.model.default` → the harness's `-m <model>` selector.\n *\n * The task prompt alone is the floor; an empty/absent profile yields exactly the legacy\n * `buildArgs(taskPrompt)` shape so existing callers are byte-identical.\n */\nexport function harnessInvocation(\n harness: LocalHarness,\n profile: AgentProfile,\n taskPrompt: string,\n options: HarnessInvocationOptions = {},\n): HarnessInvocation {\n const invocation = HARNESS_INVOCATIONS[harness]\n if (!invocation) {\n throw new Error(`harnessInvocation: unknown harness ${String(harness)}`)\n }\n\n const systemPrompt = profile.prompt?.systemPrompt\n const composedPrompt =\n typeof systemPrompt === 'string' && systemPrompt.trim().length > 0\n ? `${systemPrompt}\\n\\n${taskPrompt}`\n : taskPrompt\n\n const args = buildHarnessArgs(harness, composedPrompt, options)\n\n const model = profile.model?.default\n if (typeof model === 'string' && model.length > 0) {\n args.push(...invocation.modelArgs(model))\n }\n\n const reasoningEffort = profile.model?.reasoningEffort\n if (reasoningEffort !== undefined && invocation.reasoningArgs) {\n args.push(...invocation.reasoningArgs(reasoningEffort))\n }\n\n return { command: invocation.command, args }\n}\n\n/** @experimental */\nexport interface RunLocalHarnessOptions {\n harness: LocalHarness\n /** Working directory for the subprocess (typically a worktree path). */\n cwd: string\n /** Prompt forwarded as the harness CLI's task argument. */\n taskPrompt: string\n /**\n * Pre-built command + args (e.g. from `harnessInvocation` so the full authored\n * `AgentProfile` — systemPrompt + model — reaches the harness). When set it OVERRIDES the\n * default prompt-only `buildArgs(taskPrompt)` path; `command` defaults to the harness's\n * default binary when only `args` is supplied. When absent the legacy prompt-only shape\n * is used unchanged.\n */\n invocation?: { command?: string; args: ReadonlyArray<string> }\n /** Allow autonomous Claude edits without an interactive permission prompt.\n * Use only when `cwd` is an isolated candidate worktree. */\n dangerouslySkipPermissions?: boolean\n /** Wall-clock kill deadline (ms). Default 5 min. Subprocess SIGTERMed on expiry. */\n timeoutMs?: number\n /** Caller cancellation. SIGTERM is sent on abort. */\n signal?: AbortSignal\n /** Override env (defaults to inheriting from the parent). */\n env?: NodeJS.ProcessEnv\n /**\n * Test seam — inject a custom spawner so unit tests can mock the\n * subprocess without touching the OS. Defaults to node's `child_process.spawn`.\n */\n spawn?: (\n command: string,\n args: ReadonlyArray<string>,\n opts: {\n cwd: string\n env: NodeJS.ProcessEnv\n stdio: 'pipe'\n },\n ) => ChildProcess\n}\n\n/** @experimental */\nexport interface LocalHarnessResult {\n /** OS exit code. `null` when killed before exit. */\n exitCode: number | null\n /** Concatenated stdout. */\n stdout: string\n /** Concatenated stderr. */\n stderr: string\n /** Set when the process exited via signal (timeout / abort). */\n killedBySignal: NodeJS.Signals | null\n /** Wall-clock duration ms (spawn → exit). */\n durationMs: number\n /** Set when timeoutMs elapsed before exit. */\n timedOut: boolean\n}\n\nconst DEFAULT_TIMEOUT_MS = 5 * 60 * 1000\n\n/**\n * Spawn a local coding harness CLI as a subprocess + collect its output.\n *\n * NOT responsible for parsing the harness's output or extracting a diff —\n * the in-process executor's `streamPrompt` orchestrates `git diff` against\n * the worktree after this resolves. This function is intentionally narrow:\n * spawn, wait, capture, return.\n *\n * Fails loud — throws when:\n * - `cwd` doesn't exist (subprocess emits ENOENT; surfaced as Error)\n * - the harness binary is not on PATH (ENOENT)\n *\n * Does NOT throw when:\n * - the subprocess exits non-zero (`result.exitCode` carries the code)\n * - the subprocess is aborted / timed out (`result.killedBySignal` /\n * `result.timedOut` carries the reason)\n *\n * @experimental\n */\nexport function runLocalHarness(options: RunLocalHarnessOptions): Promise<LocalHarnessResult> {\n const { harness, cwd, taskPrompt } = options\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS\n const env = options.env ?? process.env\n const spawnImpl = options.spawn ?? spawn\n\n const invocation = HARNESS_INVOCATIONS[harness]\n if (!invocation) {\n return Promise.reject(new Error(`runLocalHarness: unknown harness ${String(harness)}`))\n }\n\n const startedAt = Date.now()\n const command = options.invocation?.command ?? invocation.command\n const args = options.invocation\n ? [...options.invocation.args]\n : buildHarnessArgs(harness, taskPrompt, options)\n\n return new Promise<LocalHarnessResult>((resolve, reject) => {\n let child: ChildProcess\n try {\n child = spawnImpl(command, args, { cwd, env, stdio: 'pipe' })\n } catch (err) {\n reject(err instanceof Error ? err : new Error(String(err)))\n return\n }\n\n // The harness takes its task as an argv arg, not on stdin. Leaving stdin\n // OPEN makes a non-TTY `opencode run` (and likely the other harnesses)\n // BLOCK forever waiting on input — zero output, SIGTERM at the wall cap,\n // empty patch -> \"no candidate passed validation\". Close stdin so the\n // subprocess sees EOF and proceeds (the `cliExecutor` leaf does the same).\n child.stdin?.end()\n\n let stdout = ''\n let stderr = ''\n let timedOut = false\n let settled = false\n\n const timer =\n timeoutMs > 0\n ? setTimeout(() => {\n timedOut = true\n if (!child.killed) child.kill('SIGTERM')\n }, timeoutMs)\n : null\n if (timer && typeof (timer as { unref?: () => void }).unref === 'function') {\n ;(timer as { unref: () => void }).unref()\n }\n\n const onAbort = () => {\n if (!child.killed) child.kill('SIGTERM')\n }\n if (options.signal) {\n if (options.signal.aborted) onAbort()\n else options.signal.addEventListener('abort', onAbort, { once: true })\n }\n\n child.stdout?.on('data', (chunk) => {\n stdout += String(chunk)\n })\n child.stderr?.on('data', (chunk) => {\n stderr += String(chunk)\n })\n\n const finalize = (result: LocalHarnessResult) => {\n if (settled) return\n settled = true\n if (timer) clearTimeout(timer)\n options.signal?.removeEventListener('abort', onAbort)\n resolve(result)\n }\n\n child.on('error', (err) => {\n if (settled) return\n settled = true\n if (timer) clearTimeout(timer)\n options.signal?.removeEventListener('abort', onAbort)\n reject(err)\n })\n\n child.on('close', (code, signal) => {\n finalize({\n exitCode: code,\n stdout,\n stderr,\n killedBySignal: signal,\n durationMs: Date.now() - startedAt,\n timedOut,\n })\n })\n })\n}\n"],"mappings":"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","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runLocalHarness
3
- } from "./chunk-CMYMTRGA.js";
3
+ } from "./chunk-PX6SXX3M.js";
4
4
 
5
5
  // src/improvement/agentic-generator.ts
6
6
  import { spawnSync } from "child_process";
@@ -207,4 +207,4 @@ export {
207
207
  agenticGenerator,
208
208
  commandVerifier
209
209
  };
210
- //# sourceMappingURL=chunk-FRBHUNQ7.js.map
210
+ //# sourceMappingURL=chunk-RTVVH2KL.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildLoopOtelSpans,
3
3
  createOtelExporter
4
- } from "./chunk-J2K6WIG6.js";
4
+ } from "./chunk-ISTDY47H.js";
5
5
 
6
6
  // src/mcp/trace-propagation.ts
7
7
  function readTraceContextFromEnv() {
@@ -49,4 +49,4 @@ export {
49
49
  createPropagatingTraceEmitter,
50
50
  traceContextToEnv
51
51
  };
52
- //# sourceMappingURL=chunk-R5GWDTM3.js.map
52
+ //# sourceMappingURL=chunk-ZEYAT33L.js.map
@@ -1,5 +1,5 @@
1
1
  import { L as LocalHarness } from './local-harness-dcD5WTTr.js';
2
- import { c as Executor } from './types-DAdIm4AC.js';
2
+ import { c as Executor } from './types-Cg_teUPO.js';
3
3
 
4
4
  /**
5
5
  *
@@ -1,11 +1,11 @@
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-DAdIm4AC.js';
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-Cg_teUPO.js';
2
2
  import { AgentProfile } from '@tangle-network/agent-interface';
3
3
  import { U as UiLens, a as UiFinding, C as CoderTask } from './substrate-DO2GHNg2.js';
4
- import { S as SandboxClient, E as ExecCtx, h as LoopTraceEmitter, g as LoopTraceEvent, b as RuntimeStreamEvent, e as AgentRunSpec } from './types-B00NtbCs.js';
4
+ import { S as SandboxClient, E as ExecCtx, g as LoopTraceEmitter, f as LoopTraceEvent, a as RuntimeStreamEvent, d as AgentRunSpec } from './types-DWA64rbJ.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-C9go6tXj.js';
8
- import { G as GitRunner, a as WorktreeCheckRunner, D as DeliverableSpec } from './completion-gate-BLaiN0-X.js';
7
+ import { b as ToolSpec, c as RuntimeTelemetryOptions, R as RouterConfig } from './sanitize-C2jicjNf.js';
8
+ import { G as GitRunner, a as WorktreeCheckRunner, D as DeliverableSpec } from './completion-gate-BDkEYB_-.js';
9
9
  import { L as LocalHarness } from './local-harness-dcD5WTTr.js';
10
10
  import { ProviderExecutorOptions, AgentEnvironmentProviderRegistry } from './environment-provider.js';
11
11
  import { AgentEnvironmentProvider } from '@tangle-network/agent-interface/environment-provider';
@@ -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-DAdIm4AC.js';
6
- import { S as SandboxClient } from './types-B00NtbCs.js';
5
+ import { R as Runtime, E as ExecutorFactory } from './types-Cg_teUPO.js';
6
+ import { S as SandboxClient } from './types-DWA64rbJ.js';
7
7
  import '@tangle-network/agent-eval';
8
8
 
9
9
  /** Provider object or registry name accepted by runtime provider adapters.
@@ -1,4 +1,4 @@
1
- import { Scenario, SelfImproveOptions, SurfaceProposer, SelfImproveResult } from '@tangle-network/agent-eval/contract';
1
+ import { Scenario, SelfImproveOptions, SurfaceProposer, SelfImproveResult, MutableSurface } from '@tangle-network/agent-eval/contract';
2
2
  import { AgentProfile } from '@tangle-network/agent-interface';
3
3
  import { L as LocalHarness } from './local-harness-dcD5WTTr.js';
4
4
  import { V as Verifier, C as CandidateGenerator } from './agentic-generator-B8oeE2Yv.js';
@@ -21,12 +21,7 @@ import { V as Verifier, C as CandidateGenerator } from './agentic-generator-B8oe
21
21
  * lesson document supplied through `opts.memory`.
22
22
  * - `surface: 'agent-profile'` → caller-supplied proposer mutates the complete
23
23
  * canonical AgentProfile JSON in one candidate.
24
- * - `surface: 'rollout-policy'` `rolloutPolicyProposer` mutates the
25
- * inference-time `StructuralRolloutPolicy` dials ({ k, repairRounds, testgen })
26
- * persisted in `profile.extensions['structural-rollout']` — deterministic
27
- * bounded neighbor enumeration; the held-out gate does the deciding. No-op
28
- * (nothing proposed, nothing shipped) when the profile has no such extension.
29
- * - `surface` ∈ {`tools`, `mcp`, `hooks`, `subagents`, `workflow`, `agent-profile`, `code`} → no zero-config default
24
+ * - `surface` ∈ {`tools`, `mcp`, `hooks`, `subagents`, `agent-profile`, `code`} → no zero-config default
30
25
  * proposer exists (a code/config proposer needs caller-supplied wiring — a
31
26
  * worktree repo root, a candidate generator, a serializer). The facade
32
27
  * requires an explicit `opts.generator` for these and throws a `ConfigError`
@@ -40,17 +35,16 @@ import { V as Verifier, C as CandidateGenerator } from './agentic-generator-B8oe
40
35
  * @experimental
41
36
  */
42
37
 
43
- /** The agent-profile lever `improve` optimizes. Mirrors the AgentProfile-law
44
- * profile levers; `code` is the implementation-tier surface, `rollout-policy`
45
- * the inference-time structuralRollout dials
46
- * (`profile.extensions['structural-rollout']`). */
47
- type ImproveSurface = 'prompt' | 'skills' | 'tools' | 'mcp' | 'hooks' | 'subagents' | 'workflow' | 'agent-profile' | 'memory' | 'code' | 'rollout-policy';
38
+ /** The executable agent lever `improve` optimizes. Profile fields remain
39
+ * portable AgentProfile coordinates; implementation and orchestration files
40
+ * use the code surface so a winner can be sealed into an exact candidate. */
41
+ type ImproveSurface = 'prompt' | 'skills' | 'tools' | 'mcp' | 'hooks' | 'subagents' | 'agent-profile' | 'memory' | 'code';
48
42
  type ImproveOptions<TScenario extends Scenario, TArtifact> = Omit<SelfImproveOptions<TScenario, TArtifact>, 'analyzeGeneration' | 'baselineSurface' | 'findings' | 'gate' | 'proposer'> & {
49
43
  /** Which profile lever to optimize. Default `'prompt'`. Selects the default
50
44
  * generator + the baseline-surface extraction shape. */
51
45
  surface?: ImproveSurface;
52
46
  /** The `SurfaceProposer` that mutates the surface. When unset, the facade
53
- * picks the default for prompt, skills, memory, and rollout policy; surfaces
47
+ * picks the default for prompt, skills, and memory; surfaces
54
48
  * with no default REQUIRE this (fail-loud otherwise). */
55
49
  generator?: SurfaceProposer;
56
50
  /** Gate mode. `'holdout'` (default) runs the held-out promotion gate;
@@ -146,6 +140,9 @@ interface ImproveResult<TScenario extends Scenario, TArtifact> {
146
140
  /** Full `selfImprove` result for advanced inspection. */
147
141
  raw: SelfImproveResult<TScenario, TArtifact>;
148
142
  }
143
+ /** Apply a promoted winner surface back into the profile field for `surface`.
144
+ * Returns a shallow copy; never mutates the input profile. */
145
+ declare function applyImprovementWinnerToProfile(profile: AgentProfile, surface: ImproveSurface, winner: MutableSurface): AgentProfile;
149
146
  /**
150
147
  * Run the held-out-gated self-improvement loop on ONE profile surface.
151
148
  *
@@ -161,4 +158,4 @@ interface ImproveResult<TScenario extends Scenario, TArtifact> {
161
158
  */
162
159
  declare function improve<TScenario extends Scenario, TArtifact>(profile: AgentProfile, findings: unknown[], opts: ImproveOptions<TScenario, TArtifact>): Promise<ImproveResult<TScenario, TArtifact>>;
163
160
 
164
- export { type ImproveSurface as I, type ImproveOptions as a, type ImproveResult as b, type ImproveCodeOptions as c, type ImproveMemoryOptions as d, type ImproveSkillsOptions as e, improve as i };
161
+ export { type ImproveSurface as I, type ImproveOptions as a, type ImproveResult as b, type ImproveCodeOptions as c, type ImproveMemoryOptions as d, type ImproveSkillsOptions as e, applyImprovementWinnerToProfile as f, improve as i };
package/dist/index.d.ts CHANGED
@@ -1,34 +1,33 @@
1
1
  import { AgentProfile, AgentEvalError, AnalystFinding, KnowledgeReadinessReport, RunRecord, ControlEvalResult } 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 { i as AgentBackendInput, O as OpenAIChatTool, j as OpenAIChatToolChoice, k as OpenAIChatResponseFormat, l as AgentExecutionBackend, m as AgentBackendContext, b as RuntimeStreamEvent, K as KnowledgeReadinessDecision, n as RunAgentTaskOptions, o as AgentTaskRunResult, p as RunAgentTaskStreamOptions, q as RuntimeSessionStore, r as RuntimeSession, R as RuntimeHooks } from './types-B00NtbCs.js';
4
- export { s as AgentAdapter, t as AgentKnowledgeProvider, A as AgentRuntimeEvent, u as AgentRuntimeEventSink, v as AgentTaskContext, w as AgentTaskSpec, c as AgentTaskStatus, B as BackendErrorDetail, x as RuntimeDecisionEvidenceRef, y as RuntimeDecisionKind, z as RuntimeDecisionPoint, C as RuntimeHookContext, F as RuntimeHookErrorContext, G as RuntimeHookEvent, H as RuntimeHookPhase, J as RuntimeHookTarget, M as RuntimeRunHandle, N as RuntimeRunPersistenceAdapter, P as RuntimeRunRow, Q as composeRuntimeHooks, T as defineRuntimeHooks, U as notifyRuntimeDecisionPoint, W as notifyRuntimeHookEvent, X as startRuntimeRun } from './types-B00NtbCs.js';
5
- export { AgentCandidateCodeSource, AgentCandidateCodeSurfaceSource, AgentCandidateModelGrantActivateInput, AgentCandidateModelGrantClient, AgentCandidateModelGrantReservation, AgentCandidateModelGrantReserveInput, AgentCandidateModelGrantSettleInput, AgentCandidateProfileSource, BuildAgentCandidateBundleInput, CreateProtectedAgentCandidateModelPortOptions, DisposePreparedAgentCandidateOptions, FileAgentCandidateExecutionClaimStore, FileAgentCandidateExecutionClaimStoreOptions, RecoverExpiredAgentCandidateOptions, buildAgentCandidateBundle, candidateExecutionClaim, createProtectedAgentCandidateModelPort, disposePreparedAgentCandidateExecution, persistCandidateOutputArtifact, recoverExpiredAgentCandidateExecution, verifyAgentCandidateBundle } from './candidate-execution/index.js';
6
- export { d as AgentCandidateArtifactPort, e as AgentCandidateBenchmarkGraderIdentity, f as AgentCandidateBenchmarkGraderPort, c as AgentCandidateBundleInput, g as AgentCandidateContainerPort, h as AgentCandidateExecutionAttemptRecord, i as AgentCandidateExecutionAttemptRef, j as AgentCandidateExecutionClaim, k as AgentCandidateExecutionClaimResult, l as AgentCandidateExecutionClaimStore, m as AgentCandidateExecutionCleanupHandles, n as AgentCandidateExecutionFailureClass, o as AgentCandidateExecutionFinishResult, p as AgentCandidateExecutionLease, q as AgentCandidateExecutionPhase, r as AgentCandidateExecutionPhaseResult, a as AgentCandidateExecutionPorts, s as AgentCandidateExecutionRecoveryEvidence, t as AgentCandidateExecutionStageResult, u as AgentCandidateExecutionTerminalRecord, v as AgentCandidateExecutionTerminalResult, w as AgentCandidateExecutionUsage, x as AgentCandidateExecutorFinalCapture, y as AgentCandidateExecutorMemoryCapture, z as AgentCandidateExecutorPort, B as AgentCandidateExecutorProfileFile, C as AgentCandidateExecutorRequest, D as AgentCandidateExecutorStopRequest, F as AgentCandidateExecutorTaskOutcomeCapture, G as AgentCandidateExecutorWorkspaceFile, H as AgentCandidateExecutorWorkspaceInput, I as AgentCandidateMemoryPort, J as AgentCandidateMemoryResetResult, K as AgentCandidateModelLimits, L as AgentCandidateModelPort, M as AgentCandidateOutputArtifactPort, N as AgentCandidateOutputPurpose, O as AgentCandidateProtectedModelActivation, Q as AgentCandidateProtectedModelCall, R as AgentCandidateProtectedModelReservation, S as AgentCandidateProtectedModelSettlement, T as AgentCandidateProtectedRunCapture, U as AgentCandidateRepositoryPort, V as AgentCandidateRetryRejection, b as AgentCandidateRunFinalization, A as AgentCandidateTaskExecution, W as AgentCandidateVerificationPorts, X as AgentCandidateWorkspacePort, Y as CANDIDATE_TRACE_ENV, Z as CANDIDATE_TRACE_TAGS, _ as CanonicalCandidateDocument, E as ExecutePreparedAgentCandidateOptions, $ as InMemoryAgentCandidateExecutionClaimStore, P as PrepareAgentCandidateExecutionOptions, a0 as PreparedAgentCandidateExecution, a1 as PreparedAgentCandidateInstruction, a2 as PreparedAgentCandidateLaunch, a3 as PreparedAgentCandidateTrace, a4 as ResolvedAgentCandidateContainer, a5 as VerifiedAgentCandidate, a6 as VerifiedAgentCandidateTaskOutcome, a7 as executePreparedAgentCandidate, a8 as prepareAgentCandidateExecution, a9 as sealAgentCandidateBundle } from './prepare-DiVGKcwS.js';
7
- import { Scenario, ProfileDispatchFn, MutableSurface, SurfaceProposer } from '@tangle-network/agent-eval/campaign';
3
+ import { h as AgentBackendInput, O as OpenAIChatTool, i as OpenAIChatToolChoice, j as OpenAIChatResponseFormat, k as AgentExecutionBackend, l as AgentBackendContext, a as RuntimeStreamEvent, K as KnowledgeReadinessDecision, m as RunAgentTaskOptions, n as AgentTaskRunResult, o as RunAgentTaskStreamOptions, p as RuntimeSessionStore, q as RuntimeSession, R as RuntimeHooks } from './types-DWA64rbJ.js';
4
+ export { r as AgentAdapter, s as AgentKnowledgeProvider, A as AgentRuntimeEvent, t as AgentRuntimeEventSink, u as AgentTaskContext, v as AgentTaskSpec, b as AgentTaskStatus, B as BackendErrorDetail, w as RuntimeDecisionEvidenceRef, x as RuntimeDecisionKind, y as RuntimeDecisionPoint, z as RuntimeHookContext, C as RuntimeHookErrorContext, F as RuntimeHookEvent, G as RuntimeHookPhase, H as RuntimeHookTarget, J as RuntimeRunHandle, M as RuntimeRunPersistenceAdapter, N as RuntimeRunRow, P as composeRuntimeHooks, Q as defineRuntimeHooks, T as notifyRuntimeDecisionPoint, U as notifyRuntimeHookEvent, W as startRuntimeRun } from './types-DWA64rbJ.js';
5
+ export { AgentCandidateCodeSource, AgentCandidateCodeSurfaceSource, AgentCandidateModelGrantActivateInput, AgentCandidateModelGrantClient, AgentCandidateModelGrantReservation, AgentCandidateModelGrantReserveInput, AgentCandidateModelGrantSettleInput, AgentCandidateProfileSource, BuildAgentCandidateBundleInput, CreateProtectedAgentCandidateModelPortOptions, DisposePreparedAgentCandidateOptions, FileAgentCandidateExecutionClaimStore, FileAgentCandidateExecutionClaimStoreOptions, RecoverExpiredAgentCandidateOptions, applyExactAgentProfileDiff, buildAgentCandidateBundle, candidateExecutionClaim, createProtectedAgentCandidateModelPort, disposePreparedAgentCandidateExecution, parseExactAgentProfile, parseExactAgentProfileDiff, persistCandidateOutputArtifact, recoverExpiredAgentCandidateExecution, verifyAgentCandidateBundle } from './candidate-execution/index.js';
6
+ export { d as AgentCandidateArtifactPort, e as AgentCandidateBenchmarkGraderIdentity, f as AgentCandidateBenchmarkGraderPort, A as AgentCandidateBundleInput, g as AgentCandidateContainerPort, h as AgentCandidateExecutionAttemptRecord, i as AgentCandidateExecutionAttemptRef, j as AgentCandidateExecutionClaim, k as AgentCandidateExecutionClaimResult, l as AgentCandidateExecutionClaimStore, m as AgentCandidateExecutionCleanupHandles, n as AgentCandidateExecutionFailureClass, o as AgentCandidateExecutionFinishResult, p as AgentCandidateExecutionLease, q as AgentCandidateExecutionPhase, r as AgentCandidateExecutionPhaseResult, b as AgentCandidateExecutionPorts, s as AgentCandidateExecutionRecoveryEvidence, t as AgentCandidateExecutionStageResult, u as AgentCandidateExecutionTerminalRecord, v as AgentCandidateExecutionTerminalResult, w as AgentCandidateExecutionUsage, x as AgentCandidateExecutorFinalCapture, y as AgentCandidateExecutorMemoryCapture, z as AgentCandidateExecutorPort, B as AgentCandidateExecutorProfileFile, C as AgentCandidateExecutorRequest, D as AgentCandidateExecutorStopRequest, F as AgentCandidateExecutorTaskOutcomeCapture, G as AgentCandidateExecutorWorkspaceFile, H as AgentCandidateExecutorWorkspaceInput, I as AgentCandidateMemoryPort, J as AgentCandidateMemoryResetResult, K as AgentCandidateModelLimits, L as AgentCandidateModelPort, M as AgentCandidateOutputArtifactPort, N as AgentCandidateOutputPurpose, O as AgentCandidateProtectedModelActivation, Q as AgentCandidateProtectedModelCall, R as AgentCandidateProtectedModelReservation, S as AgentCandidateProtectedModelSettlement, T as AgentCandidateProtectedRunCapture, U as AgentCandidateRepositoryPort, V as AgentCandidateRetryRejection, c as AgentCandidateRunFinalization, a as AgentCandidateTaskExecution, W as AgentCandidateVerificationPorts, X as AgentCandidateWorkspacePort, Y as CANDIDATE_TRACE_ENV, Z as CANDIDATE_TRACE_TAGS, _ as CanonicalCandidateDocument, E as ExecutePreparedAgentCandidateOptions, $ as InMemoryAgentCandidateExecutionClaimStore, P as PrepareAgentCandidateExecutionOptions, a0 as PreparedAgentCandidateExecution, a1 as PreparedAgentCandidateInstruction, a2 as PreparedAgentCandidateLaunch, a3 as PreparedAgentCandidateTrace, a4 as ResolvedAgentCandidateContainer, a5 as VerifiedAgentCandidate, a6 as VerifiedAgentCandidateTaskOutcome, a7 as executePreparedAgentCandidate, a8 as prepareAgentCandidateExecution, a9 as sealAgentCandidateBundle } from './prepare-BKxAiUcH.js';
7
+ import { Scenario, ProfileDispatchFn, ProposeContext, SurfaceProposer } from '@tangle-network/agent-eval/campaign';
8
8
  import { C as CandidateGenerator } from './agentic-generator-B8oeE2Yv.js';
9
9
  export { A as AgenticGeneratorOptions, I as ImprovementDriverOptions, M as ManagedImprovementDriver, V as Verifier, a as VerifyResult, b as agenticGenerator, c as commandVerifier, i as improvementDriver } from './agentic-generator-B8oeE2Yv.js';
10
- export { c as ImproveCodeOptions, d as ImproveMemoryOptions, a as ImproveOptions, b as ImproveResult, e as ImproveSkillsOptions, I as ImproveSurface, i as improve } from './improve-DDhQaaJT.js';
10
+ export { c as ImproveCodeOptions, d as ImproveMemoryOptions, a as ImproveOptions, b as ImproveResult, e as ImproveSkillsOptions, I as ImproveSurface, f as applyImprovementWinnerToProfile, i as improve } from './improve-ZzTEkpF_.js';
11
11
  export { M as McpServeSpec, m as mcpServeVerifier } from './mcp-serve-verifier-Bg4C3p5S.js';
12
+ import { AgentProfileDiff, AgentProfile as AgentProfile$1 } from '@tangle-network/agent-interface';
12
13
  import { Scenario as Scenario$1, SelfImproveOptions } from '@tangle-network/agent-eval/contract';
13
14
  import { S as SurfaceImprovementEdit } from './improvement-adapter-BieWeK5J.js';
14
15
  import { I as ImprovementAdapter } from './types-BC3bZpH0.js';
15
- import { AgentProfile as AgentProfile$1 } from '@tangle-network/agent-interface';
16
- import { S as StructuralRolloutPolicy } from './structural-rollout-DHGDbhvR.js';
17
16
  export { AgentKnowledgeReadinessCheckOptions, KnowledgeImprovementJobMeasurement, KnowledgeImprovementJobResult, KnowledgeReadinessCheck, KnowledgeReadinessCheckInput, KnowledgeReadinessCheckResult, RESEARCH_SUPERVISOR_SYSTEM_PROMPT, RunKnowledgeImprovementJobOptions, SupervisedKnowledgeUpdateInput, SupervisedKnowledgeUpdateOptions, SupervisedKnowledgeUpdateResult, SupervisedKnowledgeUpdater, createAgentKnowledgeReadinessCheck, 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-kKUNGLyV.js';
19
- export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-E3woykz9.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-DxJ83oZA.js';
21
- import { c as RuntimeTelemetryOptions } from './sanitize-C9go6tXj.js';
22
- 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-C9go6tXj.js';
17
+ 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-BRXC1RwC.js';
18
+ export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-D0ZSRCC6.js';
19
+ 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-EGoRbbsd.js';
20
+ import { c as RuntimeTelemetryOptions } from './sanitize-C2jicjNf.js';
21
+ 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-C2jicjNf.js';
23
22
  import '@tangle-network/sandbox';
24
23
  import './local-harness-dcD5WTTr.js';
25
24
  import 'node:child_process';
26
- import './worktree-fanout-BUb2Ag02.js';
27
- import './types-DAdIm4AC.js';
28
- import './completion-gate-BLaiN0-X.js';
29
25
  import '@tangle-network/agent-knowledge';
30
- import './supervise-T2pazU3G.js';
26
+ import './supervise-Gmf709kn.js';
27
+ import './types-Cg_teUPO.js';
28
+ import './completion-gate-BDkEYB_-.js';
31
29
  import './kb-gate-CwHO0vz6.js';
30
+ import './worktree-fanout-BrB4att3.js';
32
31
  import './substrate-DO2GHNg2.js';
33
32
  import './environment-provider.js';
34
33
  import '@tangle-network/agent-interface/environment-provider';
@@ -1174,6 +1173,24 @@ declare function toolBuildPrompt(args: FindingsArg): string;
1174
1173
  /** Build the starting instruction for a coder agent tasked with implementing a new MCP server. */
1175
1174
  declare function mcpBuildPrompt(args: FindingsArg): string;
1176
1175
 
1176
+ interface AgentProfileDiffProposal {
1177
+ diff: AgentProfileDiff;
1178
+ label?: string;
1179
+ rationale?: string;
1180
+ }
1181
+ type ProfileDiffProposerContext<TFindings = unknown> = ProposeContext<TFindings> & {
1182
+ profile: AgentProfile$1;
1183
+ };
1184
+ interface ProfileDiffProposerOptions<TFindings = unknown> {
1185
+ proposeDiffs(context: ProfileDiffProposerContext<TFindings>): Promise<readonly AgentProfileDiffProposal[]> | readonly AgentProfileDiffProposal[];
1186
+ }
1187
+ /**
1188
+ * Turn exact AgentProfileDiffs from any source into full profile candidates for
1189
+ * the shared optimization loop. Research, catalogs, humans, and trace miners
1190
+ * differ only in `proposeDiffs`; measurement and promotion stay identical.
1191
+ */
1192
+ declare function profileDiffProposer<TFindings = unknown>(options: ProfileDiffProposerOptions<TFindings>): SurfaceProposer<TFindings>;
1193
+
1177
1194
  /**
1178
1195
  *
1179
1196
  * `rawTraceDistiller` — the meta-harness `analyzeGeneration` producer.
@@ -1264,94 +1281,6 @@ interface ReflectiveGeneratorOptions {
1264
1281
  /** Cheap no-sandbox `CandidateGenerator` (the `shots=1` setting): draft surface edits via the improvement adapter and apply them as one coherent candidate. */
1265
1282
  declare function reflectiveGenerator(opts: ReflectiveGeneratorOptions): CandidateGenerator;
1266
1283
 
1267
- /**
1268
- * `rolloutPolicyProposer` — the `'rollout-policy'` surface for `improve()`: the
1269
- * inference-time `StructuralRolloutPolicy` dials { k, repairRounds, testgen } as a
1270
- * held-out-gated optimizable surface.
1271
- *
1272
- * Why this seam: agent-eval's loop contract is already generic — `MutableSurface`
1273
- * admits any string, documented as "serialized tool config" — so the policy rides
1274
- * the SAME serialize→propose→gate→parse-back cycle the tools/mcp/hooks surfaces
1275
- * use. No agent-eval changes; the only net-new piece is this proposer.
1276
- *
1277
- * Why deterministic: prompt-wording proposals are a measured zero on this stack,
1278
- * and the policy space is tiny and fully enumerable. The proposer emits bounded
1279
- * single-dial neighbors (k±2 in [1,10], repairRounds±1 in [0,3], testgen±3 in
1280
- * [0,10], ≤4 per generation) and lets the held-out gate do ALL the deciding — an
1281
- * LLM proposer would add cost and nondeterminism with nothing to reason about.
1282
- *
1283
- * Persistence: the policy lives in `profile.extensions['structural-rollout']`
1284
- * (AgentProfile's designed slot for runtime-specific config). A gated winner is
1285
- * written back there by `improve()`, the same profile-field write-back every other
1286
- * config surface gets; `structuralRolloutPolicyFromProfile` is the read side a
1287
- * runtime caller feeds to `structuralRollout({ policy })`.
1288
- *
1289
- * @experimental
1290
- */
1291
-
1292
- /** The profile extensions namespace the policy persists under. */
1293
- declare const ROLLOUT_POLICY_EXTENSION = "structural-rollout";
1294
- /** Proposal bounds per dial. These are the SEARCH bounds (what the proposer may
1295
- * explore), chosen so every reachable value is a measured-sane recipe: k=1 is the
1296
- * low-compute preset, testgen=0 disables check authoring, repairRounds caps where
1297
- * the measured increment flattens (+1–3pp beyond round 2). */
1298
- declare const ROLLOUT_POLICY_BOUNDS: {
1299
- readonly k: {
1300
- readonly min: 1;
1301
- readonly max: 10;
1302
- readonly step: 2;
1303
- };
1304
- readonly repairRounds: {
1305
- readonly min: 0;
1306
- readonly max: 3;
1307
- readonly step: 1;
1308
- };
1309
- readonly testgen: {
1310
- readonly min: 0;
1311
- readonly max: 10;
1312
- readonly step: 3;
1313
- };
1314
- };
1315
- /** Parse a serialized policy surface. Defensive by design — the proposer reads
1316
- * `ctx.currentSurface`, which the loop types as `string | CodeSurface`. Returns
1317
- * `undefined` (never throws) for non-strings, malformed JSON, or a shape that
1318
- * violates the policy's own invariants: the no-op signal. Unknown dials are
1319
- * dropped; `diverse`/`temperature` ride through untouched (the proposer never
1320
- * mutates them — `diverse` is a measured paired null). */
1321
- declare function parseRolloutPolicy(surface: MutableSurface): StructuralRolloutPolicy | undefined;
1322
- /** Normalize an untyped policy bag (a parsed surface or a profile extension) into
1323
- * a full `StructuralRolloutPolicy`, defaults merged. Returns `undefined` when any
1324
- * present dial violates the policy invariants (mirrors `resolvePolicy`: integer
1325
- * k ≥ 1, repairRounds ≥ 0, testgen ≥ 0) — a corrupt config must read as "not
1326
- * configured", never as a fabricated recipe. */
1327
- declare function normalizeRolloutPolicy(raw: unknown): StructuralRolloutPolicy | undefined;
1328
- /** Stable serialization — dial order is fixed so identical policies produce
1329
- * identical surfaces (the loop dedupes/hashes candidates by surface content). */
1330
- declare function serializeRolloutPolicy(policy: StructuralRolloutPolicy): string;
1331
- /** Read the persisted policy off the profile. `undefined` when the profile does
1332
- * not opt into structural rollout — the improve() surface no-ops then, because
1333
- * tuning dials nothing consumes would ship dead config. */
1334
- declare function structuralRolloutPolicyFromProfile(profile: AgentProfile$1): StructuralRolloutPolicy | undefined;
1335
- /** Persist a policy into the profile's extensions namespace. Shallow copy; never
1336
- * mutates the input profile (the applyWinnerToProfile contract). */
1337
- declare function applyRolloutPolicyToProfile(profile: AgentProfile$1, policy: StructuralRolloutPolicy): AgentProfile$1;
1338
- /** All bounded single-dial neighbors of `policy`, in a fixed priority order: k
1339
- * first (selection breadth carries 85–92% of the measured effect), then
1340
- * repairRounds, then testgen. Steps clamp to the dial's bounds; clamped-to-no-op
1341
- * and duplicate policies are dropped. */
1342
- declare function enumerateNeighborPolicies(policy: StructuralRolloutPolicy): StructuralRolloutPolicy[];
1343
- /**
1344
- * The deterministic `SurfaceProposer` for the `'rollout-policy'` surface.
1345
- *
1346
- * Each generation: parse the current policy surface, enumerate its bounded
1347
- * single-dial neighbors, and return at most `min(populationSize, 4)` of them,
1348
- * rotating the enumeration window by generation so successive generations explore
1349
- * different neighbors when nothing promoted. Proposes NOTHING when the surface
1350
- * carries no policy (the profile never opted in) — an empty proposal is the
1351
- * loop-native no-op, mirroring `improvementDriver`'s no-findings behavior.
1352
- */
1353
- declare function rolloutPolicyProposer(): SurfaceProposer;
1354
-
1355
1284
  /**
1356
1285
  *
1357
1286
  * Chat-model resolution + catalog validation — the shared primitive every
@@ -1777,4 +1706,4 @@ interface StreamToolLoopOptions<Raw> {
1777
1706
  * `capped` if it stops for any non-completed reason with calls still pending. */
1778
1707
  declare function streamToolLoop<Raw>(opts: StreamToolLoopOptions<Raw>): AsyncGenerator<StreamToolLoopYield<Raw>, void, unknown>;
1779
1708
 
1780
- export { AgentBackendContext, AgentBackendInput, type AgentBackendKind, AgentExecutionBackend, AgentTaskRunResult, 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, FORWARD_HEADERS, FileConversationJournal, type ForwardHeaderName, type HaltContext, type HaltPredicate, type HaltReason, type HaltSignal, InMemoryConversationJournal, InMemoryRuntimeSessionStore, type ModelInfo, OpenAIChatResponseFormat, OpenAIChatTool, OpenAIChatToolChoice, type PersonaConversationResult, type PersonaDriver, PlannerError, type PropagatedHeaders, ROLLOUT_POLICY_BOUNDS, ROLLOUT_POLICY_EXTENSION, type RawTraceDistillerOptions, type ReflectiveGeneratorOptions, type ResolveAgentBackendOptions, type ResolvedChatModel, type RetryBackoff, type RetryableErrorPredicate, type RouterEnv, type RunChatTurnInput, type RunConversationOptions, type RunPersonaConfig, type RunPersonaConversationOptions, type RunToolLoopOptions, RuntimeHooks, RuntimeRunStateError, RuntimeSessionStore, RuntimeStreamEvent, RuntimeTelemetryOptions, type SqlAdapter, SqlConversationJournal, type StreamToolLoopOptions, type StreamToolLoopYield, type ToolCallOutcome, type ToolLoopAssistantToolCall, type ToolLoopCall, type ToolLoopEvent, type ToolLoopMessage, type ToolLoopResult, type ToolLoopStopReason, type TurnOrder, applyRolloutPolicyToProfile, applyRunRecordDefaults, buildForwardHeaders, cleanModelId, computeBackoff, createConversationBackend, createIterableBackend, createOpenAICompatibleBackend, createSandboxPromptBackend, d1ToSqlAdapter, decideKnowledgeReadiness, defaultIsRetryable, defineConversation, deriveExecutionId, enumerateNeighborPolicies, getModels, handleChatTurn, isDepthExceeded, makePerAttemptSignal, mcpBuildPrompt, normalizeRolloutPolicy, parseRolloutPolicy, rawTraceDistiller, readDepth, readinessServerSentEvent, reflectiveGenerator, resolveAgentBackend, resolveChatModel, resolveRouterBaseUrl, rolloutPolicyProposer, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runPersonaConversation, runPersonaDispatch, runToolLoop, runtimeStreamServerSentEvent, serializeRolloutPolicy, sleep, slugifySpeaker, streamToolLoop, structuralRolloutPolicyFromProfile, toolBuildPrompt, turnId, validateChatModelId };
1709
+ export { AgentBackendContext, AgentBackendInput, type AgentBackendKind, AgentExecutionBackend, type AgentProfileDiffProposal, AgentTaskRunResult, 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, FORWARD_HEADERS, FileConversationJournal, type ForwardHeaderName, type HaltContext, type HaltPredicate, type HaltReason, type HaltSignal, InMemoryConversationJournal, InMemoryRuntimeSessionStore, type ModelInfo, OpenAIChatResponseFormat, OpenAIChatTool, OpenAIChatToolChoice, type PersonaConversationResult, type PersonaDriver, PlannerError, type ProfileDiffProposerContext, type ProfileDiffProposerOptions, type PropagatedHeaders, type RawTraceDistillerOptions, type ReflectiveGeneratorOptions, type ResolveAgentBackendOptions, type ResolvedChatModel, type RetryBackoff, type RetryableErrorPredicate, type RouterEnv, type RunChatTurnInput, type RunConversationOptions, type RunPersonaConfig, type RunPersonaConversationOptions, type RunToolLoopOptions, RuntimeHooks, RuntimeRunStateError, RuntimeSessionStore, RuntimeStreamEvent, RuntimeTelemetryOptions, 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, createSandboxPromptBackend, d1ToSqlAdapter, decideKnowledgeReadiness, defaultIsRetryable, defineConversation, deriveExecutionId, getModels, handleChatTurn, isDepthExceeded, makePerAttemptSignal, mcpBuildPrompt, profileDiffProposer, rawTraceDistiller, readDepth, readinessServerSentEvent, reflectiveGenerator, resolveAgentBackend, resolveChatModel, resolveRouterBaseUrl, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runPersonaConversation, runPersonaDispatch, runToolLoop, runtimeStreamServerSentEvent, sleep, slugifySpeaker, streamToolLoop, toolBuildPrompt, turnId, validateChatModelId };