@tangle-network/agent-runtime 0.70.1 → 0.71.1

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 (38) hide show
  1. package/dist/agent.d.ts +1 -1
  2. package/dist/agent.js +2 -2
  3. package/dist/analyst-loop.d.ts +1 -1
  4. package/dist/{chunk-CRAH5EY2.js → chunk-4KGQHS7U.js} +2 -2
  5. package/dist/{chunk-YFOPWG74.js → chunk-5ISW5JUF.js} +275 -145
  6. package/dist/chunk-5ISW5JUF.js.map +1 -0
  7. package/dist/{chunk-LJZ5GC6C.js → chunk-74UAWZXE.js} +4 -4
  8. package/dist/{chunk-HY4YOQM2.js → chunk-INXDNX2W.js} +2 -2
  9. package/dist/{chunk-BGOLR66M.js → chunk-K3RM4MPM.js} +3 -3
  10. package/dist/{chunk-G3RGMA7C.js → chunk-VMNEQHJR.js} +6 -1
  11. package/dist/chunk-VMNEQHJR.js.map +1 -0
  12. package/dist/{coordination-C7WxwHXq.d.ts → coordination-BPQmuwv8.d.ts} +280 -2
  13. package/dist/{delegates-DqAgo32T.d.ts → delegates-CsXJPZDH.d.ts} +48 -2
  14. package/dist/index.d.ts +7 -7
  15. package/dist/index.js +5 -5
  16. package/dist/intelligence.d.ts +1 -1
  17. package/dist/intelligence.js +1 -1
  18. package/dist/{loop-runner-bin-a8bu4O5-.d.ts → loop-runner-bin-DLM_bVQO.d.ts} +3 -3
  19. package/dist/loop-runner-bin.d.ts +4 -4
  20. package/dist/loop-runner-bin.js +4 -4
  21. package/dist/loops.d.ts +120 -241
  22. package/dist/loops.js +6 -2
  23. package/dist/mcp/bin.js +51 -12
  24. package/dist/mcp/bin.js.map +1 -1
  25. package/dist/mcp/index.d.ts +7 -6
  26. package/dist/mcp/index.js +15 -5
  27. package/dist/mcp/index.js.map +1 -1
  28. package/dist/{openai-tools-DPx9Gzvn.d.ts → openai-tools-kdCS-T12.d.ts} +1 -1
  29. package/dist/profiles.d.ts +1 -1
  30. package/dist/{types-BYa2ZOAx.d.ts → types-CdnEAE3U.d.ts} +1 -1
  31. package/dist/{worktree-fanout-gNfl0Byj.d.ts → worktree-fanout-CK2ypmEm.d.ts} +3 -45
  32. package/package.json +1 -1
  33. package/dist/chunk-G3RGMA7C.js.map +0 -1
  34. package/dist/chunk-YFOPWG74.js.map +0 -1
  35. /package/dist/{chunk-CRAH5EY2.js.map → chunk-4KGQHS7U.js.map} +0 -0
  36. /package/dist/{chunk-LJZ5GC6C.js.map → chunk-74UAWZXE.js.map} +0 -0
  37. /package/dist/{chunk-HY4YOQM2.js.map → chunk-INXDNX2W.js.map} +0 -0
  38. /package/dist/{chunk-BGOLR66M.js.map → chunk-K3RM4MPM.js.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  buildLoopOtelSpans,
3
3
  createOtelExporter,
4
4
  loopEventToOtelSpan
5
- } from "./chunk-G3RGMA7C.js";
5
+ } from "./chunk-VMNEQHJR.js";
6
6
  import "./chunk-DGUM43GV.js";
7
7
 
8
8
  // src/intelligence/effort.ts
@@ -1,10 +1,10 @@
1
1
  import { Scenario } from '@tangle-network/agent-eval/campaign';
2
2
  import { SelfImproveOptions, SelfImproveResult } from '@tangle-network/agent-eval/contract';
3
3
  import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
4
- import { D as DelegateCodeArgs, C as CoderReviewer, a as DetachedWinnerSelection, B as Budget, b as CoderOutput } from './delegates-DqAgo32T.js';
4
+ import { D as DelegateCodeArgs, C as CoderReviewer, a as DetachedWinnerSelection, B as Budget, b as CoderOutput } from './delegates-CsXJPZDH.js';
5
5
  import { F as FactCandidate, C as CreateKbGateOptions } from './kb-gate-CuzMYGYM.js';
6
- import { S as SandboxClient } from './types-BYa2ZOAx.js';
7
- import { A as AuthoredHarness, W as WinnerStrategy, a as WorktreeFanoutOptions, b as WorktreePatchArtifact } from './worktree-fanout-gNfl0Byj.js';
6
+ import { S as SandboxClient } from './types-CdnEAE3U.js';
7
+ import { A as AuthoredHarness, W as WinnerStrategy, a as WorktreeFanoutOptions, b as WorktreePatchArtifact } from './worktree-fanout-CK2ypmEm.js';
8
8
 
9
9
  /**
10
10
  * @experimental
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- export { L as LoopRunnerCliArgs, e as LoopRunnerCliResult, p as parseLoopRunnerArgv, l as runLoopRunnerCli } from './loop-runner-bin-a8bu4O5-.js';
2
+ export { L as LoopRunnerCliArgs, e as LoopRunnerCliResult, p as parseLoopRunnerArgv, l as runLoopRunnerCli } from './loop-runner-bin-DLM_bVQO.js';
3
3
  import '@tangle-network/agent-eval/campaign';
4
4
  import '@tangle-network/agent-eval/contract';
5
5
  import './types-BC3bZpH0.js';
6
6
  import '@tangle-network/agent-eval';
7
- import './delegates-DqAgo32T.js';
7
+ import './delegates-CsXJPZDH.js';
8
8
  import 'node:child_process';
9
9
  import '@tangle-network/agent-interface';
10
10
  import '@tangle-network/sandbox';
11
- import './types-BYa2ZOAx.js';
11
+ import './types-CdnEAE3U.js';
12
12
  import './substrate-BoRXgvka.js';
13
13
  import './kb-gate-CuzMYGYM.js';
14
- import './worktree-fanout-gNfl0Byj.js';
14
+ import './worktree-fanout-CK2ypmEm.js';
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  parseLoopRunnerArgv,
4
4
  runLoopRunnerCli
5
- } from "./chunk-BGOLR66M.js";
5
+ } from "./chunk-K3RM4MPM.js";
6
6
  import "./chunk-P5OKDSLB.js";
7
7
  import "./chunk-FNMGYYSS.js";
8
- import "./chunk-HY4YOQM2.js";
9
- import "./chunk-YFOPWG74.js";
10
- import "./chunk-G3RGMA7C.js";
8
+ import "./chunk-INXDNX2W.js";
9
+ import "./chunk-5ISW5JUF.js";
10
+ import "./chunk-VMNEQHJR.js";
11
11
  import "./chunk-VLF5RHEQ.js";
12
12
  import "./chunk-DVQGYDN5.js";
13
13
  import "./chunk-WIR4HOOJ.js";
package/dist/loops.d.ts CHANGED
@@ -1,20 +1,20 @@
1
1
  import { ChatClient, AnalystFinding, AgentProfile, AnalystRunInputs, ToolSpan, StreamingDetector, DetectorSignal, buildTrajectory } from '@tangle-network/agent-eval';
2
2
  export { AnalystFinding, DefaultVerdict, computeFindingId, makeFinding } from '@tangle-network/agent-eval';
3
- import { SandboxInstance, CreateSandboxOptions, SandboxEvent, BackendType } from '@tangle-network/sandbox';
3
+ import { SandboxInstance, CreateSandboxOptions, SandboxEvent } from '@tangle-network/sandbox';
4
4
  export { AgentProfile, CreateSandboxOptions, SandboxEvent, SandboxInstance } from '@tangle-network/sandbox';
5
- import { g as ResultBlobStore, i as SpawnJournal, N as NodeId, bb as SpawnEvent, bc as ExecutorFactory, A as Agent, B as Budget, S as Scope, l as Settled, k as SupervisedResult, m as Spend, bd as UsageEvent, E as ExecutorRegistry, L as LocalHarness, be as Supervisor } from './delegates-DqAgo32T.js';
6
- export { h as AgentSpec, n as Executor, bf as ExecutorContext, bg as ExecutorResult, bh as SupervisorOpts, bi as TreeView, bj as WidenGate } from './delegates-DqAgo32T.js';
7
- import { M as MakeWorkerAgent, a as CoordinationTools, A as AnalystRegistry, C as CoordinationEvent, j as QuestionPolicy } from './coordination-C7WxwHXq.js';
8
- export { B as BusEvent, p as BusRecord, q as BusStats, E as EventBus, P as PublishOptions, r as createEventBus } from './coordination-C7WxwHXq.js';
9
- import { b as RuntimeHooks, I as Iteration, S as SandboxClient, T as Driver, A as AgentRunSpec, a as OutputAdapter, V as Validator, U as ExecCtx, W as LoopWinner, X as LoopLineageOptions, Y as LoopResult, d as LoopTokenUsage, R as RuntimeStreamEvent } from './types-BYa2ZOAx.js';
10
- export { Z as LoopDecisionPayload, _ as LoopEndedPayload, $ as LoopIterationDispatchPayload, a0 as LoopIterationEndedPayload, a1 as LoopIterationStartedPayload, a2 as LoopPlanDescription, a3 as LoopPlanPayload, c as LoopSandboxPlacement, a4 as LoopStartedPayload, a5 as LoopTeardownFailedPayload, e as LoopTraceEmitter, L as LoopTraceEvent, a6 as ValidationCtx } from './types-BYa2ZOAx.js';
11
- import { C as CorpusRecord, c as Corpus, O as Outcome, S as ScopeAnalyzeInput, d as AssertTraceDerivedFindings, e as SteerContext, f as ScopeAnalyst, F as FanoutOptions, g as CombinatorShape, h as ScopeWidenGate, L as LoopUntilSpec, P as PanelSpec, i as PipelineStage, W as WinnerStrategy, j as FanoutWinnerSelector, V as VerifySpec, k as WidenSpec, l as CorpusFilter, R as RenderCorpusToInstructionsOptions, D as DefinePersonaInput, m as Persona, n as RunPersonifiedOptions, o as ShapeRegistry, p as LoopShape, E as EqualKArm, q as EqualKOnCostOptions, r as EqualKVerdict, T as TrajectoryReportOptions, s as TrajectoryReport, t as DeliverableSpec } from './worktree-fanout-gNfl0Byj.js';
12
- export { A as AuthoredHarness, u as DefinePersona, v as EqualKOnCost, w as Fanout, x as FanoutSynthesis, y as FlatWidenGate, z as LoopUntil, B as LoopUntilState, G as Panel, H as PanelJudge, I as PanelVerdict, J as PatchDeliverableOptions, K as PersonaContext, M as PersonaExecutors, N as Pipeline, Q as RenderCorpusToInstructions, U as RunPersonified, X as ShapeBudget, Y as ShapeContext, Z as TrajectoryNode, _ as TrajectoryReportFn, $ as Verify, a0 as Widen, a1 as WidenDecision, a2 as WidenLineage, a3 as WorktreeCliExecutorOptions, a4 as WorktreeCommandResult, a as WorktreeFanoutOptions, b as WorktreePatchArtifact, a5 as createWorktreeCliExecutor, a6 as gateOnDeliverable, a7 as patchDelivered, a8 as worktreeFanout } from './worktree-fanout-gNfl0Byj.js';
5
+ import { j as ResultBlobStore, l as SpawnJournal, N as NodeId, bd as SpawnEvent, E as ExecutorFactory, A as Agent, B as Budget, i as Scope, o as Settled, n as SupervisedResult, f as DeliverableSpec, S as Spend, be as UsageEvent, e as ExecutorRegistry, bf as Supervisor } from './delegates-CsXJPZDH.js';
6
+ export { k as AgentSpec, p as Executor, bg as ExecutorContext, bh as ExecutorResult, bi as SupervisorOpts, bj as TreeView, bk as WidenGate, bl as gateOnDeliverable } from './delegates-CsXJPZDH.js';
7
+ import { M as MakeWorkerAgent, a as CoordinationTools, A as AnalystRegistry, C as CoordinationEvent, o as QuestionPolicy, E as ExecutorConfig } from './coordination-BPQmuwv8.js';
8
+ export { B as BusEvent, w as BusRecord, x as BusStats, y as EventBus, P as PublishOptions, z as cliWorktreeExecutor, G as createEventBus, H as createExecutor, K as createExecutorRegistry } from './coordination-BPQmuwv8.js';
9
+ import { b as RuntimeHooks, I as Iteration, S as SandboxClient, U as Driver, A as AgentRunSpec, a as OutputAdapter, V as Validator, E as ExecCtx, W as LoopWinner, X as LoopLineageOptions, Y as LoopResult, d as LoopTokenUsage, R as RuntimeStreamEvent } from './types-CdnEAE3U.js';
10
+ export { Z as LoopDecisionPayload, _ as LoopEndedPayload, $ as LoopIterationDispatchPayload, a0 as LoopIterationEndedPayload, a1 as LoopIterationStartedPayload, a2 as LoopPlanDescription, a3 as LoopPlanPayload, c as LoopSandboxPlacement, a4 as LoopStartedPayload, a5 as LoopTeardownFailedPayload, e as LoopTraceEmitter, L as LoopTraceEvent, a6 as ValidationCtx } from './types-CdnEAE3U.js';
11
+ import { C as CorpusRecord, c as Corpus, O as Outcome, S as ScopeAnalyzeInput, d as AssertTraceDerivedFindings, e as SteerContext, f as ScopeAnalyst, F as FanoutOptions, g as CombinatorShape, h as ScopeWidenGate, L as LoopUntilSpec, P as PanelSpec, i as PipelineStage, W as WinnerStrategy, j as FanoutWinnerSelector, V as VerifySpec, k as WidenSpec, l as CorpusFilter, R as RenderCorpusToInstructionsOptions, D as DefinePersonaInput, m as Persona, n as RunPersonifiedOptions, o as ShapeRegistry, p as LoopShape, E as EqualKArm, q as EqualKOnCostOptions, r as EqualKVerdict, T as TrajectoryReportOptions, s as TrajectoryReport } from './worktree-fanout-CK2ypmEm.js';
12
+ export { A as AuthoredHarness, t as DefinePersona, u as EqualKOnCost, v as Fanout, w as FanoutSynthesis, x as FlatWidenGate, y as LoopUntil, z as LoopUntilState, B as Panel, G as PanelJudge, H as PanelVerdict, I as PatchDeliverableOptions, J as PersonaContext, K as PersonaExecutors, M as Pipeline, N as RenderCorpusToInstructions, Q as RunPersonified, U as ShapeBudget, X as ShapeContext, Y as TrajectoryNode, Z as TrajectoryReportFn, _ as Verify, $ as Widen, a0 as WidenDecision, a1 as WidenLineage, a2 as WorktreeCliExecutorOptions, a3 as WorktreeCommandResult, a as WorktreeFanoutOptions, b as WorktreePatchArtifact, a4 as createWorktreeCliExecutor, a5 as patchDelivered, a6 as worktreeFanout } from './worktree-fanout-CK2ypmEm.js';
13
13
  import { Scenario, ProfileDispatchFn } from '@tangle-network/agent-eval/campaign';
14
14
  import { b as AnalystRegistryLike } from './types-BC3bZpH0.js';
15
15
  import { AgentProfile as AgentProfile$1 } from '@tangle-network/agent-interface';
16
- import { R as RouterConfig, a as ToolLoopChat, T as ToolSpec } from './router-client-C7kp_ECN.js';
17
- export { b as RouterChatResult, c as RouterChatToolsResult, d as RouterToolCall, e as RouterToolLoopResult, r as routerBrain, f as routerChatWithTools, g as routerChatWithUsage, h as routerToolLoop } from './router-client-C7kp_ECN.js';
16
+ import { R as RouterConfig, a as ToolLoopChat } from './router-client-C7kp_ECN.js';
17
+ export { b as RouterChatResult, c as RouterChatToolsResult, d as RouterToolCall, e as RouterToolLoopResult, T as ToolSpec, r as routerBrain, f as routerChatWithTools, g as routerChatWithUsage, h as routerToolLoop } from './router-client-C7kp_ECN.js';
18
18
  import { stuckLoopView, toolWasteView } from '@tangle-network/agent-eval/pipelines';
19
19
  import 'node:child_process';
20
20
  import './substrate-BoRXgvka.js';
@@ -2448,6 +2448,114 @@ declare function serveCoordinationMcp(opts: {
2448
2448
  questionPolicy?: QuestionPolicy;
2449
2449
  }): Promise<CoordinationMcpHandle>;
2450
2450
 
2451
+ /** The supervisor's profile — the subset of an `AgentProfile` that selects + shapes its brain.
2452
+ * `harness` is the backend-as-data discriminant; `systemPrompt` is the standing instruction. */
2453
+ interface SupervisorProfile {
2454
+ readonly name?: string;
2455
+ /** null/undefined → router brain (in-process tool-loop); a coding-CLI harness → sandboxed brain. */
2456
+ readonly harness?: string | null;
2457
+ /** The router model when the brain is router-driven (falls back to the deps router config). */
2458
+ readonly model?: string;
2459
+ /** The standing instructions ("you delegate, you do not solve"). */
2460
+ readonly systemPrompt?: string;
2461
+ }
2462
+ /** How to run a sandboxed harness as the DRIVER, with the coordination verbs mounted — the substrate
2463
+ * seam the caller supplies (mirrors `makeWorkerAgent` for spawned children). It runs `profile` on
2464
+ * `task` in its backend (sandbox / cli-bridge) with `coordinationMcpUrl` mounted as an MCP server,
2465
+ * so the harness calls spawn_agent / await_event / stop as native tools over the live scope. */
2466
+ type DriveHarness = (args: {
2467
+ readonly profile: SupervisorProfile;
2468
+ readonly task: unknown;
2469
+ readonly scope: Scope<unknown>;
2470
+ readonly coordinationMcpUrl: string;
2471
+ }) => Promise<void>;
2472
+ interface SupervisorAgentDeps {
2473
+ readonly blobs: ResultBlobStore;
2474
+ /** Resolve a spawned worker `profile` to a leaf agent — the recursion seam (same for both arms). */
2475
+ readonly makeWorkerAgent: MakeWorkerAgent;
2476
+ /** Per-child budget reserved from the conserved pool on each spawn. */
2477
+ readonly perWorker: Budget;
2478
+ /** Router substrate for a router-brained supervisor (`harness` null). The profile's model wins. */
2479
+ readonly router?: RouterConfig;
2480
+ /** Inject the brain directly (tests / advanced) instead of resolving `routerBrain` from the profile. */
2481
+ readonly brain?: ToolLoopChat;
2482
+ /** Required for a sandboxed-harness supervisor (`harness` set): runs the harness as the driver. */
2483
+ readonly driveHarness?: DriveHarness;
2484
+ /** WORK tools the supervisor may call DIRECTLY (router arm) — so it can do simple work ITSELF and
2485
+ * only delegate when it needs parallelism. Pair with `executeExtraTool`. */
2486
+ readonly extraTools?: ReadonlyArray<{
2487
+ readonly name: string;
2488
+ readonly description?: string;
2489
+ readonly parameters: Record<string, unknown>;
2490
+ }>;
2491
+ /** Runs an `extraTools` call; null/undefined falls through to the coordination dispatch. */
2492
+ readonly executeExtraTool?: (name: string, args: Record<string, unknown>) => Promise<string | null | undefined>;
2493
+ readonly maxTurns?: number;
2494
+ }
2495
+ declare function supervisorAgent(profile: SupervisorProfile, deps: SupervisorAgentDeps): Agent<unknown, unknown>;
2496
+
2497
+ /**
2498
+ * @experimental
2499
+ *
2500
+ * `delegate` — the one generic delegation verb. You hand it an INTENT (what you want done) and it
2501
+ * hands that intent to a default AUTHORING supervisor: a router-brained supervisor whose standing
2502
+ * instruction is `supervisorInstructions()` (the authoring-agent-profiles skill). The supervisor
2503
+ * DECOMPOSES the intent and AUTHORS the worker profile it needs per sub-task — there is NO hardcoded
2504
+ * coder/researcher profile here. That is the whole point: `delegate('fix the failing test', …)` and
2505
+ * `delegate('research X and cite sources', …)` route through the SAME front door; the supervisor
2506
+ * writes a code-shaped or research-shaped worker on its own.
2507
+ *
2508
+ * It is a thin wrapper over `supervise()` — the one front door — so the conserved-budget pool, the
2509
+ * completion oracle (`deliverable`), the coordination toolbox, and equal-compute accounting all come
2510
+ * for free; nothing is hand-rolled. The result is `supervise()`'s `SupervisedResult` returned
2511
+ * UNCHANGED, so its `spentTotal` (`{ iterations, tokens, usd, ms }`) rides straight back to the
2512
+ * caller on BOTH paths — a `winner` carries the delivered worker's spend, a `no-winner` carries the
2513
+ * spend incurred before it failed. That cost channel is exactly what `delegate_code` lacks — a
2514
+ * `delegate()` caller always learns what the delegation actually spent.
2515
+ */
2516
+
2517
+ /** The conserved pool a `delegate()` call applies when the caller does not pass its own `budget`.
2518
+ * A modest token ceiling + a small iteration ceiling — generous enough for a few-worker decompose,
2519
+ * bounded enough that an unsupervised intent cannot run away. Callers override via `opts.budget`. */
2520
+ declare const defaultDelegateBudget: Budget;
2521
+ /** Inputs to {@link delegate}. The intent is the first positional arg; everything here is optional
2522
+ * with sensible defaults, so the common call is `delegate(intent, { backend, router })`. */
2523
+ interface DelegateOptions<Out = unknown> {
2524
+ /** The completion oracle (settled ⟺ delivered) the authored workers settle against. Strongly
2525
+ * recommended — without it the supervisor trusts a worker's self-report. For a code intent,
2526
+ * `patchDelivered()` is the canonical example; for a free-form answer, a content check. */
2527
+ readonly deliverable?: DeliverableSpec<Out>;
2528
+ /** WHERE the authored workers run — the worker-execution backend (`router-tools` / `sandbox` /
2529
+ * `cli-worktree` / …). The supervisor authors the worker PROFILE; this is the substrate it runs
2530
+ * on. Provide this OR `makeWorkerAgent`-style wiring through `supervise()` is unavailable. */
2531
+ readonly backend?: ExecutorConfig;
2532
+ /** The conserved compute pool for the whole delegation. Defaults to {@link defaultDelegateBudget}. */
2533
+ readonly budget?: Budget;
2534
+ /** The model the supervisor BRAIN runs on (the router model). The brain must tool-call
2535
+ * (`spawn_agent` / `await_event`), so a delegator model, not a hidden-reasoning model. */
2536
+ readonly model?: string;
2537
+ /** The supervisor brain's router substrate. REQUIRED for the default router-brained supervisor
2538
+ * (the brain is resolved from this), unless a test injects `brain` directly. `model` overrides
2539
+ * `router.model`. (Design delta vs the bare `supervise()` profile: the brain needs a router.) */
2540
+ readonly router?: RouterConfig;
2541
+ /** Inject the supervisor brain directly (tests / advanced) instead of resolving it from `router`. */
2542
+ readonly brain?: ToolLoopChat;
2543
+ /** Override the default authoring-supervisor profile (name / extra system-prompt stance). The
2544
+ * default already carries the authoring skill; override only to add a goal or rename. */
2545
+ readonly supervisor?: Partial<Pick<SupervisorProfile, 'name' | 'systemPrompt'>>;
2546
+ /** Restrict the run to this subset of models (forwarded to `supervise()`). */
2547
+ readonly allowedModels?: readonly string[];
2548
+ readonly runId?: string;
2549
+ }
2550
+ /**
2551
+ * Delegate an INTENT to a default authoring supervisor and return its `SupervisedResult` unchanged.
2552
+ *
2553
+ * The supervisor authors + spawns whatever worker the intent needs over the conserved-budget pool;
2554
+ * `result.spentTotal` reports what the whole delegation actually cost. A `winner` result carries the
2555
+ * authored worker's delivered output; a `no-winner` result names why (never a fabricated success).
2556
+ */
2557
+ declare function delegate<Out = unknown>(intent: string, opts?: DelegateOptions<Out>): Promise<SupervisedResult<Out>>;
2558
+
2451
2559
  /**
2452
2560
  * @experimental
2453
2561
  *
@@ -2647,189 +2755,6 @@ interface InMemoryRunContext {
2647
2755
  */
2648
2756
  declare function createInMemoryRunContext(opts?: InMemoryRunContextOptions): InMemoryRunContext;
2649
2757
 
2650
- /**
2651
- * @experimental
2652
- *
2653
- * The leaf runtime — the built-in `Executor` IMPLEMENTATIONS behind the ONE
2654
- * open interface frozen in `./types`, plus the open resolver/registry that maps
2655
- * an `AgentSpec` to one of them OR accepts a bring-your-own executor verbatim.
2656
- *
2657
- * The interface is the extension point, not a closed `inline|sandbox|cli` union:
2658
- * - router/inline : a direct OpenAI-compatible Router call, no box (one-shot).
2659
- * - sandbox : COMPOSES the existing `runLoop` kernel as a single-task
2660
- * leaf and surfaces its token/cost usage as `UsageEvent`s;
2661
- * forwards PR #150's optional `lineage` passthrough WITHOUT
2662
- * reinventing checkpoint/fork (streaming).
2663
- * - cli : a Halo/RLM subprocess; `budgetExempt` (no token accounting),
2664
- * excluded from the equal-k arms by construction (streaming).
2665
- * Every metered runtime reports through the SAME normalized `UsageEvent` channel
2666
- * so the conserved budget pool meters them identically. A user's own agent is
2667
- * first-class the moment it implements `Executor` — register it by name or
2668
- * pass it as `AgentSpec.executor`.
2669
- *
2670
- * Layering: `estimateCost`/`isModelPriced` are substrate primitives from
2671
- * `@tangle-network/agent-eval`; `runLoop`/`acquireSandbox` are runtime kernels
2672
- * from this package. No per-vendor adapters live here.
2673
- */
2674
-
2675
- /**
2676
- * Router/inline connection seam. A direct OpenAI-compatible Router endpoint —
2677
- * the cheapest leaf, no box, no tools. `model` overrides the profile's model
2678
- * hint when present; otherwise the profile's `model.default` is required.
2679
- */
2680
- interface RouterSeam {
2681
- routerBaseUrl: string;
2682
- routerKey: string;
2683
- model?: string;
2684
- }
2685
- /**
2686
- * Sandbox executor seam. The `sandboxClient` the composed `runLoop` creates
2687
- * boxes through, plus the optional trace/run/lineage wiring forwarded into the
2688
- * loop. `lineage` is opaque here (PR #150's `RunLoopOptions.lineage`): forwarded
2689
- * forward-compatibly, never inspected — this executor does NOT reinvent
2690
- * checkpoint/fork.
2691
- */
2692
- interface SandboxSeam {
2693
- sandboxClient: SandboxClient;
2694
- /** Forwarded into the composed `runLoop`'s `ctx` (trace emitter, run handle, etc.). */
2695
- loopCtx?: Partial<Omit<ExecCtx, 'sandboxClient' | 'signal'>>;
2696
- /** PR #150 `RunLoopOptions.lineage` passthrough — opaque; forwarded, not parsed. */
2697
- lineage?: unknown;
2698
- /** Hard cap on the composed loop's iterations. The budget pool reserves against
2699
- * the spawn `Budget.maxIterations`; this is the leaf's own ceiling. Default 1. */
2700
- maxIterations?: number;
2701
- }
2702
- /** CLI subprocess seam. `bin` + `args` describe the Halo/RLM process to spawn. */
2703
- interface CliSeam {
2704
- bin: string;
2705
- args?: string[];
2706
- /** Extra environment for the subprocess (merged over `process.env`). */
2707
- env?: Record<string, string>;
2708
- /** Working directory for the subprocess. */
2709
- cwd?: string;
2710
- }
2711
- /**
2712
- * cli-worktree seam. A supervisor-authored `AgentProfile` driving a local coding-harness CLI
2713
- * (claude / codex / opencode) on its own git worktree — the leaf `createWorktreeCliExecutor`
2714
- * named as data. `harness` + `repoRoot` + `taskPrompt` are required; the authored
2715
- * `profile.prompt.systemPrompt` + `profile.model.default` reach the harness via the §1.5
2716
- * `harnessInvocation` mapper. Everything else mirrors `WorktreeCliExecutorOptions`.
2717
- */
2718
- interface CliWorktreeSeam {
2719
- repoRoot: string;
2720
- harness: LocalHarness;
2721
- taskPrompt: string;
2722
- runId?: string;
2723
- baseRef?: string;
2724
- harnessTimeoutMs?: number;
2725
- }
2726
- /**
2727
- * cli-bridge seam. A local OpenAI-compatible bridge that fronts harness CLIs
2728
- * (claude-code / opencode / kimi / pi) behind one HTTP surface; `model` doubles
2729
- * as the harness selector (e.g. `claude-code/sonnet`, `opencode/<provider>/<model>`).
2730
- * `agentProfile` is the bridge-dialect profile (metadata.disallowedTools, mcp)
2731
- * forwarded verbatim per request — how an arm disables native tools or injects
2732
- * a provider search MCP.
2733
- *
2734
- * The executor opens a RESUMABLE cli-bridge session — structurally identical to the
2735
- * sandbox executor's persistent box, just local. `sessionId` is the stable
2736
- * caller-owned id cli-bridge maps to the harness's internal conversation id; a
2737
- * follow-up steer/resume on the SAME id continues the SAME harness session (opencode
2738
- * `-s`, claude `--resume`, …). Omit it and the executor mints a stable one per spawn.
2739
- */
2740
- interface BridgeSeam {
2741
- bridgeUrl: string;
2742
- bridgeBearer: string;
2743
- model: string;
2744
- agentProfile?: Record<string, unknown>;
2745
- timeoutMs?: number;
2746
- /** Stable, caller-owned cli-bridge session id for harness-side resume. Defaults
2747
- * to a freshly minted per-spawn id so each worker is its own resumable session. */
2748
- sessionId?: string;
2749
- /** Per-resume-turn inference cap before the worker settles on its last output.
2750
- * Mirrors `routerToolsInlineExecutor.maxTurns`; default 200 (runaway backstop). */
2751
- maxTurns?: number;
2752
- }
2753
- /**
2754
- * Router seam WITH tool use — the tool-using router backend. Same direct
2755
- * OpenAI-compatible endpoint as `RouterSeam`, but each turn passes `tools`; when
2756
- * the model emits tool_calls they run via `executeToolCall` ON THIS HOST and the
2757
- * results fold back as `tool` messages, repeating until the model answers without
2758
- * a tool or `maxTurns` is hit. A real agentic loop, OFF-BOX — no sandbox, so it
2759
- * is unaffected by a box's egress allowlist. One turn = one completion = the
2760
- * equal-compute unit. `executeToolCall` receives the task so per-task tool
2761
- * surfaces (e.g. a gym keyed by task) can dispatch correctly.
2762
- */
2763
- interface RouterToolsSeam {
2764
- routerBaseUrl: string;
2765
- routerKey: string;
2766
- model?: string;
2767
- tools: ReadonlyArray<ToolSpec>;
2768
- executeToolCall: (name: string, args: Record<string, unknown>, task: unknown) => Promise<string>;
2769
- /** Online observer of each tool step — the seam a `DetectorMonitor` taps to watch the live pipe
2770
- * (raise a `finding` when the worker loops/errors). Called after every tool call resolves, with
2771
- * real per-call wall-clock (`startedAt`/`endedAt`/`durationMs`) so a push `TraceSource` can carry
2772
- * non-zero span durations onto the unified timeline. */
2773
- onToolStep?: (step: {
2774
- toolName: string;
2775
- args: Record<string, unknown>;
2776
- status: 'ok' | 'error';
2777
- startedAt?: number;
2778
- endedAt?: number;
2779
- durationMs?: number;
2780
- }) => void;
2781
- /** Max inference turns. Default 200 (runaway backstop — set far above any
2782
- * legitimate workflow). For tighter per-workflow limits use a cost budget
2783
- * or wall-clock deadline at the call site. */
2784
- maxTurns?: number;
2785
- }
2786
- /**
2787
- * The leaf `createWorktreeCliExecutor` as a backend-as-data factory: a supervisor-authored
2788
- * `AgentProfile` driving claude / codex / opencode on its own worktree. `budgetExempt` like
2789
- * the other CLI leaves; the authored systemPrompt + model reach the harness via §1.5.
2790
- */
2791
- declare const cliWorktreeExecutor: ExecutorFactory<unknown>;
2792
- /**
2793
- * Config for {@link createExecutor}: the backend is DATA — the cost dial a profile,
2794
- * an experiment config, or a replay journal can name — not an import choice. Each
2795
- * variant carries its backend's seam (router/router-tools/bridge/cli/cli-worktree/sandbox).
2796
- */
2797
- type ExecutorConfig = ({
2798
- backend: 'router';
2799
- } & RouterSeam) | ({
2800
- backend: 'router-tools';
2801
- } & RouterToolsSeam) | ({
2802
- backend: 'bridge';
2803
- } & BridgeSeam) | ({
2804
- backend: 'cli';
2805
- } & CliSeam) | ({
2806
- backend: 'cli-worktree';
2807
- } & CliWorktreeSeam) | ({
2808
- backend: 'sandbox';
2809
- harness?: BackendType;
2810
- } & SandboxSeam);
2811
- /**
2812
- * The single built-in executor factory. Picks a leaf backend by data (`config.backend`),
2813
- * injects the matching seam, and delegates to that backend's built-in implementation.
2814
- * The `Executor` port stays OPEN: bring-your-own agents implement `Executor` directly
2815
- * and never pass through here. Use this (or `createExecutorRegistry`) instead of a
2816
- * per-vendor adapter or a closed `inline|sandbox|cli` switch — those bypass the
2817
- * `UsageEvent` reporting channel.
2818
- */
2819
- declare function createExecutor(config: ExecutorConfig): ExecutorFactory<unknown>;
2820
- /**
2821
- * The open resolver/registry. Pre-registers the three built-ins under their
2822
- * runtime tags (`'router'`, `'sandbox'`, `'cli'`) and accepts `register(name,
2823
- * factory)` for any additional runtime — and a BYO `AgentSpec.executor` resolves
2824
- * without touching the registry at all. NOT a closed switch; registration + BYO
2825
- * ARE the extension points.
2826
- *
2827
- * `resolve` precedence (frozen in `ExecutorRegistry`): a BYO `spec.executor` →
2828
- * `harness === null` → the `'router'` factory; else a registered factory for the
2829
- * harness-derived runtime (`'sandbox'` for any `BackendType`); else fail loud.
2830
- */
2831
- declare function createExecutorRegistry(): ExecutorRegistry;
2832
-
2833
2758
  /**
2834
2759
  * @experimental
2835
2760
  *
@@ -2901,52 +2826,6 @@ declare function createScope<Out>(args: ScopeArgs): Scope<Out>;
2901
2826
  */
2902
2827
  declare function settledToIteration<Out>(settled: Settled<Out>): Iteration<unknown, Out>;
2903
2828
 
2904
- /** The supervisor's profile — the subset of an `AgentProfile` that selects + shapes its brain.
2905
- * `harness` is the backend-as-data discriminant; `systemPrompt` is the standing instruction. */
2906
- interface SupervisorProfile {
2907
- readonly name?: string;
2908
- /** null/undefined → router brain (in-process tool-loop); a coding-CLI harness → sandboxed brain. */
2909
- readonly harness?: string | null;
2910
- /** The router model when the brain is router-driven (falls back to the deps router config). */
2911
- readonly model?: string;
2912
- /** The standing instructions ("you delegate, you do not solve"). */
2913
- readonly systemPrompt?: string;
2914
- }
2915
- /** How to run a sandboxed harness as the DRIVER, with the coordination verbs mounted — the substrate
2916
- * seam the caller supplies (mirrors `makeWorkerAgent` for spawned children). It runs `profile` on
2917
- * `task` in its backend (sandbox / cli-bridge) with `coordinationMcpUrl` mounted as an MCP server,
2918
- * so the harness calls spawn_agent / await_event / stop as native tools over the live scope. */
2919
- type DriveHarness = (args: {
2920
- readonly profile: SupervisorProfile;
2921
- readonly task: unknown;
2922
- readonly scope: Scope<unknown>;
2923
- readonly coordinationMcpUrl: string;
2924
- }) => Promise<void>;
2925
- interface SupervisorAgentDeps {
2926
- readonly blobs: ResultBlobStore;
2927
- /** Resolve a spawned worker `profile` to a leaf agent — the recursion seam (same for both arms). */
2928
- readonly makeWorkerAgent: MakeWorkerAgent;
2929
- /** Per-child budget reserved from the conserved pool on each spawn. */
2930
- readonly perWorker: Budget;
2931
- /** Router substrate for a router-brained supervisor (`harness` null). The profile's model wins. */
2932
- readonly router?: RouterConfig;
2933
- /** Inject the brain directly (tests / advanced) instead of resolving `routerBrain` from the profile. */
2934
- readonly brain?: ToolLoopChat;
2935
- /** Required for a sandboxed-harness supervisor (`harness` set): runs the harness as the driver. */
2936
- readonly driveHarness?: DriveHarness;
2937
- /** WORK tools the supervisor may call DIRECTLY (router arm) — so it can do simple work ITSELF and
2938
- * only delegate when it needs parallelism. Pair with `executeExtraTool`. */
2939
- readonly extraTools?: ReadonlyArray<{
2940
- readonly name: string;
2941
- readonly description?: string;
2942
- readonly parameters: Record<string, unknown>;
2943
- }>;
2944
- /** Runs an `extraTools` call; null/undefined falls through to the coordination dispatch. */
2945
- readonly executeExtraTool?: (name: string, args: Record<string, unknown>) => Promise<string | null | undefined>;
2946
- readonly maxTurns?: number;
2947
- }
2948
- declare function supervisorAgent(profile: SupervisorProfile, deps: SupervisorAgentDeps): Agent<unknown, unknown>;
2949
-
2950
2829
  /** Build the worker seam from a backend (WHERE workers run) + an optional completion oracle (the
2951
2830
  * deliverable check that makes "settled ⟺ delivered" true — the guard against "ran but didn't
2952
2831
  * deliver"). The ONE place a backend becomes a spawnable worker. */
@@ -3148,4 +3027,4 @@ declare function runInWorkspace<T>(ws: Workspace, body: (cwd: string) => Promise
3148
3027
  commitOnInvalid?: boolean;
3149
3028
  }): Promise<WorkspaceRun<T>>;
3150
3029
 
3151
- export { Agent, AgentRunSpec, type AgenticOptions, type AgenticRunResult, type AgenticSurface, type AgenticTask, type AgenticTool, type AnytimeReport, type AnytimeStrategySummary, type AnytimeTaskCurve, type ArtifactHandle, AssertTraceDerivedFindings, type AuditIntentInput, type AuditIntentOptions, type AuthorStrategyOptions, type AuthoredProfile, type AuthoredStrategy, type BenchmarkCell, type BenchmarkConfig, type BenchmarkLift, type BenchmarkReport, type BenchmarkStrategySummary, type BenchmarkTaskRow, Budget, type BudgetPool, type BudgetReadout, type ChampionPick, type ChampionPolicy, type CheckpointCapableBox, CombinatorShape, type CompletionAnalyst, type CompletionEvidence, type CompletionPolicy, type CompletionVerdict, CoordinationEvent, type CoordinationMcpHandle, Corpus, CorpusFilter, CorpusRecord, type CreateScopeAnalystOptions, type CriuCapableClient, DefinePersonaInput, type Deliverable, DeliverableSpec, type DriveHarness, Driver, type DriverAgentOptions, type Environment, EqualKArm, EqualKOnCostOptions, EqualKVerdict, type EvolutionArchiveNode, type EvolutionAuthor, type EvolutionBandInfo, type EvolutionCandidate, type EvolutionGeneration, type EvolutionReport, ExecCtx, type ExecutorConfig, FanoutOptions, FanoutWinnerSelector, FileCorpus, type ForkCapableBox, type GitWorkspaceOptions, type HarvestCorpusOptions, type HarvestFailure, type HarvestReport, InMemoryCorpus, InMemoryResultBlobStore, type InMemoryRunContext, type InMemoryRunContextOptions, InMemorySpawnJournal, type Inbox, type InboxMessage, type IntentAudit, Iteration, type LoopDispatchOptions, LoopLineageOptions, type LoopOptionsForDispatch, LoopResult, LoopShape, LoopTokenUsage, LoopUntilSpec, LoopWinner, type McpEndpoint, type McpEnvironmentOptions, type Observation, type ObserveInput, type ObserveOptions, type OpenSandboxRunOptions, Outcome, OutputAdapter, PanelSpec, Persona, PipelineStage, type ProfileRichness, type ProfileRichnessThresholds, type PromotionGateOptions, type PromotionVerdict, type RegistryAnalyzeProjection, RenderCorpusToInstructionsOptions, type ReservationTicket, ResultBlobStore, RouterConfig, type RunAgenticOptions, RunPersonifiedOptions, type SandboxCapabilities, SandboxClient, type SandboxLineage, type SandboxLineageHandle, type SandboxRun, Scope, ScopeAnalyst, ScopeAnalyzeInput, ScopeWidenGate, type SessionCapableBox, type SessionTraceBox, Settled, ShapeRegistry, type Shell, type ShotPersona, type ShotSpec, Spend, SteerContext, type Strategy, type StrategyCtx, type StrategyEvolutionConfig, type StrategyResult, type SuperviseOptions, SupervisedResult, Supervisor, type SupervisorAgentDeps, type SupervisorProfile, type SurfaceScore, ToolLoopChat, ToolSpec, type TraceSource, type TrajectoryAnalysis, TrajectoryReport, TrajectoryReportOptions, type TurnResult, UsageEvent, type UsageSink, Validator, type VerifierEnvironmentOptions, VerifySpec, type WatchTraceOptions, type WaterfallCollector, type WaterfallReport, type WaterfallSpan, WidenSpec, WinnerStrategy, type Workspace, type WorkspaceCommit, type WorkspaceRun, acquireSandbox, adaptiveRefine, analyzeTrace, anytimeReport, asAuthoredProfile, assertModelAllowed, assertStrategyContract, assertTraceDerivedFindings, assessAuthoredProfile, auditIntent, authorStrategy, authoredWorker, breadthStrategy, buildSteerContext, builtinShapes, cliWorktreeExecutor, completionAuthorizes, contentAddress, createBudgetPool, createExecutor, createExecutorRegistry, createInMemoryRunContext, createInbox, createMcpEnvironment, createPushTraceSource, createSandboxLineage, createScope, createScopeAnalyst, createShapeRegistry, createSupervisor, createVerifierEnvironment, createWaterfallCollector, decodeToolPart, defaultAnalystInstruction, defaultAuditorInstruction, defaultProfileRichnessThresholds, defaultSelectWinner, defaultToolDetectors, definePersona, defineStrategy, depthStrategy, deterministicCompletion, discriminatingMeans, driverAgent, equalKOnCost, extractLlmCallEvent, fanout, finalizeBestDelivered, flatWidenGate, gitWorkspace, harvestCorpus, inlineSandboxClient, jjWorkspace, localShell, loopDispatch, loopUntil, mapSandboxEvent, observe, openSandboxRun, panel, pickChampion, pipeline, printBenchmarkReport, probeSandboxCapabilities, profileRichnessFinding, promotionGate, refine, registerShape, registryScopeAnalyst, renderAnytimeTable, renderCorpusToInstructions, renderReport, reportLoopUsage, runAgentic, runBenchmark, runInWorkspace, runLoop, runPersonified, runStrategyEvolution, sample, sampleThenRefine, sandboxSessionTraceSource, selectChampion, selectValidWinner, sentinelCompletion, serveCoordinationMcp, settledToIteration, spendFromUsageEvents, stopSentinel, strategyAuthorContract, supervise, supervisorAgent, supervisorInstructions, trajectoryReport, verify, watchTrace, widen, workerFromBackend };
3030
+ export { Agent, AgentRunSpec, type AgenticOptions, type AgenticRunResult, type AgenticSurface, type AgenticTask, type AgenticTool, type AnytimeReport, type AnytimeStrategySummary, type AnytimeTaskCurve, type ArtifactHandle, AssertTraceDerivedFindings, type AuditIntentInput, type AuditIntentOptions, type AuthorStrategyOptions, type AuthoredProfile, type AuthoredStrategy, type BenchmarkCell, type BenchmarkConfig, type BenchmarkLift, type BenchmarkReport, type BenchmarkStrategySummary, type BenchmarkTaskRow, Budget, type BudgetPool, type BudgetReadout, type ChampionPick, type ChampionPolicy, type CheckpointCapableBox, CombinatorShape, type CompletionAnalyst, type CompletionEvidence, type CompletionPolicy, type CompletionVerdict, CoordinationEvent, type CoordinationMcpHandle, Corpus, CorpusFilter, CorpusRecord, type CreateScopeAnalystOptions, type CriuCapableClient, DefinePersonaInput, type DelegateOptions, type Deliverable, DeliverableSpec, type DriveHarness, Driver, type DriverAgentOptions, type Environment, EqualKArm, EqualKOnCostOptions, EqualKVerdict, type EvolutionArchiveNode, type EvolutionAuthor, type EvolutionBandInfo, type EvolutionCandidate, type EvolutionGeneration, type EvolutionReport, ExecCtx, ExecutorConfig, FanoutOptions, FanoutWinnerSelector, FileCorpus, type ForkCapableBox, type GitWorkspaceOptions, type HarvestCorpusOptions, type HarvestFailure, type HarvestReport, InMemoryCorpus, InMemoryResultBlobStore, type InMemoryRunContext, type InMemoryRunContextOptions, InMemorySpawnJournal, type Inbox, type InboxMessage, type IntentAudit, Iteration, type LoopDispatchOptions, LoopLineageOptions, type LoopOptionsForDispatch, LoopResult, LoopShape, LoopTokenUsage, LoopUntilSpec, LoopWinner, type McpEndpoint, type McpEnvironmentOptions, type Observation, type ObserveInput, type ObserveOptions, type OpenSandboxRunOptions, Outcome, OutputAdapter, PanelSpec, Persona, PipelineStage, type ProfileRichness, type ProfileRichnessThresholds, type PromotionGateOptions, type PromotionVerdict, type RegistryAnalyzeProjection, RenderCorpusToInstructionsOptions, type ReservationTicket, ResultBlobStore, RouterConfig, type RunAgenticOptions, RunPersonifiedOptions, type SandboxCapabilities, SandboxClient, type SandboxLineage, type SandboxLineageHandle, type SandboxRun, Scope, ScopeAnalyst, ScopeAnalyzeInput, ScopeWidenGate, type SessionCapableBox, type SessionTraceBox, Settled, ShapeRegistry, type Shell, type ShotPersona, type ShotSpec, Spend, SteerContext, type Strategy, type StrategyCtx, type StrategyEvolutionConfig, type StrategyResult, type SuperviseOptions, SupervisedResult, Supervisor, type SupervisorAgentDeps, type SupervisorProfile, type SurfaceScore, ToolLoopChat, type TraceSource, type TrajectoryAnalysis, TrajectoryReport, TrajectoryReportOptions, type TurnResult, UsageEvent, type UsageSink, Validator, type VerifierEnvironmentOptions, VerifySpec, type WatchTraceOptions, type WaterfallCollector, type WaterfallReport, type WaterfallSpan, WidenSpec, WinnerStrategy, type Workspace, type WorkspaceCommit, type WorkspaceRun, acquireSandbox, adaptiveRefine, analyzeTrace, anytimeReport, asAuthoredProfile, assertModelAllowed, assertStrategyContract, assertTraceDerivedFindings, assessAuthoredProfile, auditIntent, authorStrategy, authoredWorker, breadthStrategy, buildSteerContext, builtinShapes, completionAuthorizes, contentAddress, createBudgetPool, createInMemoryRunContext, createInbox, createMcpEnvironment, createPushTraceSource, createSandboxLineage, createScope, createScopeAnalyst, createShapeRegistry, createSupervisor, createVerifierEnvironment, createWaterfallCollector, decodeToolPart, defaultAnalystInstruction, defaultAuditorInstruction, defaultDelegateBudget, defaultProfileRichnessThresholds, defaultSelectWinner, defaultToolDetectors, definePersona, defineStrategy, delegate, depthStrategy, deterministicCompletion, discriminatingMeans, driverAgent, equalKOnCost, extractLlmCallEvent, fanout, finalizeBestDelivered, flatWidenGate, gitWorkspace, harvestCorpus, inlineSandboxClient, jjWorkspace, localShell, loopDispatch, loopUntil, mapSandboxEvent, observe, openSandboxRun, panel, pickChampion, pipeline, printBenchmarkReport, probeSandboxCapabilities, profileRichnessFinding, promotionGate, refine, registerShape, registryScopeAnalyst, renderAnytimeTable, renderCorpusToInstructions, renderReport, reportLoopUsage, runAgentic, runBenchmark, runInWorkspace, runLoop, runPersonified, runStrategyEvolution, sample, sampleThenRefine, sandboxSessionTraceSource, selectChampion, selectValidWinner, sentinelCompletion, serveCoordinationMcp, settledToIteration, spendFromUsageEvents, stopSentinel, strategyAuthorContract, supervise, supervisorAgent, supervisorInstructions, trajectoryReport, verify, watchTrace, widen, workerFromBackend };
package/dist/loops.js CHANGED
@@ -41,11 +41,13 @@ import {
41
41
  decodeToolPart,
42
42
  defaultAnalystInstruction,
43
43
  defaultAuditorInstruction,
44
+ defaultDelegateBudget,
44
45
  defaultProfileRichnessThresholds,
45
46
  defaultSelectWinner,
46
47
  defaultToolDetectors,
47
48
  definePersona,
48
49
  defineStrategy,
50
+ delegate,
49
51
  depthStrategy,
50
52
  deterministicCompletion,
51
53
  discriminatingMeans,
@@ -110,8 +112,8 @@ import {
110
112
  widen,
111
113
  workerFromBackend,
112
114
  worktreeFanout
113
- } from "./chunk-YFOPWG74.js";
114
- import "./chunk-G3RGMA7C.js";
115
+ } from "./chunk-5ISW5JUF.js";
116
+ import "./chunk-VMNEQHJR.js";
115
117
  import {
116
118
  extractLlmCallEvent,
117
119
  mapSandboxEvent
@@ -161,11 +163,13 @@ export {
161
163
  decodeToolPart,
162
164
  defaultAnalystInstruction,
163
165
  defaultAuditorInstruction,
166
+ defaultDelegateBudget,
164
167
  defaultProfileRichnessThresholds,
165
168
  defaultSelectWinner,
166
169
  defaultToolDetectors,
167
170
  definePersona,
168
171
  defineStrategy,
172
+ delegate,
169
173
  depthStrategy,
170
174
  deterministicCompletion,
171
175
  discriminatingMeans,
package/dist/mcp/bin.js CHANGED
@@ -6,12 +6,12 @@ import {
6
6
  createPropagatingTraceEmitter,
7
7
  detectExecutor,
8
8
  readTraceContextFromEnv
9
- } from "../chunk-LJZ5GC6C.js";
9
+ } from "../chunk-74UAWZXE.js";
10
10
  import {
11
11
  coderTaskFromArgs,
12
12
  detachedSessionDelegate,
13
13
  settleDetachedCoderTurn
14
- } from "../chunk-HY4YOQM2.js";
14
+ } from "../chunk-INXDNX2W.js";
15
15
  import {
16
16
  DEFAULT_SANDBOX_BASE_URL
17
17
  } from "../chunk-XRYEZPR6.js";
@@ -26,8 +26,8 @@ import {
26
26
  parseDetachedSessionRef,
27
27
  runDetachedTurn,
28
28
  runLoop
29
- } from "../chunk-YFOPWG74.js";
30
- import "../chunk-G3RGMA7C.js";
29
+ } from "../chunk-5ISW5JUF.js";
30
+ import "../chunk-VMNEQHJR.js";
31
31
  import "../chunk-VLF5RHEQ.js";
32
32
  import {
33
33
  coderTaskToPrompt
@@ -35,10 +35,43 @@ import {
35
35
  import "../chunk-WIR4HOOJ.js";
36
36
  import "../chunk-DGUM43GV.js";
37
37
 
38
+ // src/mcp/delegate-supervisor-provisioning.ts
39
+ var DEFAULT_SUPERVISOR_MODEL = "moonshotai/kimi-k2.6";
40
+ var DEFAULT_WORKER_HARNESS = "opencode";
41
+ function trimmed(value) {
42
+ const v = value?.trim();
43
+ return v ? v : void 0;
44
+ }
45
+ function delegateEnabled(env = process.env) {
46
+ return env.MCP_ENABLE_DELEGATE === "1";
47
+ }
48
+ function resolveRouter(env) {
49
+ const routerKey = trimmed(env.MCP_SUPERVISOR_ROUTER_KEY) ?? trimmed(env.TANGLE_API_KEY) ?? "";
50
+ const base = trimmed(env.MCP_SUPERVISOR_ROUTER_BASE_URL) ?? resolveRouterBaseUrl(env);
51
+ const routerBaseUrl = /\/v\d+\/?$/.test(base) ? base.replace(/\/$/, "") : `${base.replace(/\/$/, "")}/v1`;
52
+ const model = trimmed(env.MCP_SUPERVISOR_MODEL) ?? trimmed(env.MCP_WORKER_MODEL) ?? trimmed(env.WORKER_MODEL) ?? DEFAULT_SUPERVISOR_MODEL;
53
+ return { routerBaseUrl, routerKey, model };
54
+ }
55
+ function resolveDelegateSupervisor(sandboxClient, env = process.env) {
56
+ if (!delegateEnabled(env)) return void 0;
57
+ const router = resolveRouter(env);
58
+ const harness = trimmed(env.MCP_DELEGATE_WORKER_HARNESS) ?? DEFAULT_WORKER_HARNESS;
59
+ const backend = {
60
+ backend: "sandbox",
61
+ harness,
62
+ sandboxClient
63
+ };
64
+ return {
65
+ router,
66
+ backend,
67
+ model: router.model
68
+ };
69
+ }
70
+
38
71
  // src/mcp/researcher-provisioning.ts
39
72
  var DEFAULT_HARNESS = "opencode";
40
73
  var DEFAULT_MODEL = "moonshotai/kimi-k2.6";
41
- function trimmed(value) {
74
+ function trimmed2(value) {
42
75
  const t = value?.trim();
43
76
  return t ? t : void 0;
44
77
  }
@@ -47,10 +80,10 @@ function csv(value) {
47
80
  return list && list.length > 0 ? list : void 0;
48
81
  }
49
82
  function resolveResearcherProvisioning(env = process.env) {
50
- const harness = trimmed(env.MCP_RESEARCHER_HARNESS) ?? DEFAULT_HARNESS;
51
- const model = trimmed(env.MCP_RESEARCHER_MODEL) ?? trimmed(env.MCP_WORKER_MODEL) ?? trimmed(env.WORKER_MODEL) ?? DEFAULT_MODEL;
52
- const routerKey = trimmed(env.MCP_RESEARCHER_ROUTER_KEY) ?? trimmed(env.TANGLE_API_KEY);
53
- const base = trimmed(env.MCP_RESEARCHER_ROUTER_BASE_URL) ?? resolveRouterBaseUrl(env);
83
+ const harness = trimmed2(env.MCP_RESEARCHER_HARNESS) ?? DEFAULT_HARNESS;
84
+ const model = trimmed2(env.MCP_RESEARCHER_MODEL) ?? trimmed2(env.MCP_WORKER_MODEL) ?? trimmed2(env.WORKER_MODEL) ?? DEFAULT_MODEL;
85
+ const routerKey = trimmed2(env.MCP_RESEARCHER_ROUTER_KEY) ?? trimmed2(env.TANGLE_API_KEY);
86
+ const base = trimmed2(env.MCP_RESEARCHER_ROUTER_BASE_URL) ?? resolveRouterBaseUrl(env);
54
87
  const routerBaseUrl = /\/v\d+\/?$/.test(base) ? base.replace(/\/$/, "") : `${base.replace(/\/$/, "")}/v1`;
55
88
  const fanoutHarnesses = csv(env.MCP_RESEARCHER_FANOUT_HARNESSES);
56
89
  const fanoutModels = csv(env.MCP_RESEARCHER_FANOUT_MODELS);
@@ -81,8 +114,9 @@ async function main() {
81
114
  const maxConcurrency = parseConcurrency(process.env.MCP_MAX_CONCURRENT_SANDBOXES);
82
115
  const wantCoder = !process.env.MCP_DISABLE_CODER;
83
116
  const wantResearcher = !process.env.MCP_DISABLE_RESEARCHER;
117
+ const wantDelegate = delegateEnabled(process.env);
84
118
  const fleetId = parseFleetId(process.env.TANGLE_FLEET_ID);
85
- const needsSandbox = wantCoder || wantResearcher;
119
+ const needsSandbox = wantCoder || wantResearcher || wantDelegate;
86
120
  let sandboxClient;
87
121
  let executor;
88
122
  if (needsSandbox) {
@@ -130,10 +164,15 @@ async function main() {
130
164
  );
131
165
  }
132
166
  const resumeDriver = detachedDispatch && sandboxClient ? buildResumeDriver({ sandboxClient, researcherResume: researcherSupport?.resume }) : void 0;
167
+ const delegateSupervisor = wantDelegate && sandboxClient ? resolveDelegateSupervisor(sandboxClient) : void 0;
168
+ if (wantDelegate && delegateSupervisor) {
169
+ process.stderr.write("agent-runtime-mcp: delegate enabled \u2014 generic authoring supervisor\n");
170
+ }
133
171
  const durableQueue = await buildDurableQueueFromEnv(resumeDriver, traceContext);
134
172
  const server = createMcpServer({
135
173
  coderDelegate,
136
174
  researcherDelegate: researcherSupport?.delegate,
175
+ ...delegateSupervisor ? { delegateSupervisor } : {},
137
176
  detachedDispatch,
138
177
  traceContext,
139
178
  ...durableQueue ? { queue: durableQueue } : {}
@@ -419,8 +458,8 @@ function parseHarnesses(raw) {
419
458
  }
420
459
  function parseFleetId(raw) {
421
460
  if (typeof raw !== "string") return void 0;
422
- const trimmed2 = raw.trim();
423
- return trimmed2.length > 0 ? trimmed2 : void 0;
461
+ const trimmed3 = raw.trim();
462
+ return trimmed3.length > 0 ? trimmed3 : void 0;
424
463
  }
425
464
  function parseConcurrency(raw) {
426
465
  if (!raw) return 4;