@tangle-network/agent-runtime 0.78.0 → 0.79.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.
- package/dist/agent.js +3 -3
- package/dist/{chunk-O2UPHN7X.js → chunk-5JAUQZQA.js} +1 -1
- package/dist/chunk-5JAUQZQA.js.map +1 -0
- package/dist/{chunk-OLPH6W3J.js → chunk-EZ2QESTP.js} +833 -33
- package/dist/chunk-EZ2QESTP.js.map +1 -0
- package/dist/{chunk-OL2SEETC.js → chunk-F6G3SSHY.js} +2 -2
- package/dist/{chunk-QJ6BWENI.js → chunk-GZX3PI7V.js} +3 -3
- package/dist/{chunk-JPURCA2O.js → chunk-LWGVVP2C.js} +2 -2
- package/dist/{chunk-YHS6I2IS.js → chunk-N2JJDGLJ.js} +2 -2
- package/dist/chunk-N2JJDGLJ.js.map +1 -0
- package/dist/{coordination-Csxsy39a.d.ts → coordination-09JTQnlF.d.ts} +87 -24
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.js +2 -2
- package/dist/{local-harness-BE_h8szs.d.ts → local-harness-DU7yV6mG.d.ts} +1 -1
- package/dist/{loop-runner-bin-BTMpf1oY.d.ts → loop-runner-bin-Ddgf4DkS.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +4 -4
- package/dist/loop-runner-bin.js +4 -4
- package/dist/loops.d.ts +10 -9
- package/dist/loops.js +13 -3
- package/dist/mcp/bin.js +2 -2
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +10 -10
- package/dist/mcp/index.js +4 -4
- package/dist/mcp/index.js.map +1 -1
- package/dist/{mcp-serve-verifier-CT1KLTG_.d.ts → mcp-serve-verifier-BvMAV_8U.d.ts} +1 -1
- package/dist/{worktree-DH_Y0brm.d.ts → worktree-CUn0d-ZT.d.ts} +1 -1
- package/dist/{worktree-fanout-DGC7jS7i.d.ts → worktree-fanout-DwwatTdY.d.ts} +2 -2
- package/package.json +3 -3
- package/dist/chunk-O2UPHN7X.js.map +0 -1
- package/dist/chunk-OLPH6W3J.js.map +0 -1
- package/dist/chunk-YHS6I2IS.js.map +0 -1
- /package/dist/{chunk-OL2SEETC.js.map → chunk-F6G3SSHY.js.map} +0 -0
- /package/dist/{chunk-QJ6BWENI.js.map → chunk-GZX3PI7V.js.map} +0 -0
- /package/dist/{chunk-JPURCA2O.js.map → chunk-LWGVVP2C.js.map} +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { m as ExecutorFactory, E as ExecutorRegistry, l as DeliverableSpec, i as Spend, d as Agent, j as Scope, e as ResultBlobStore, B as Budget } from './worktree-
|
|
2
|
-
import { AgentProfile } from '@tangle-network/agent-interface';
|
|
1
|
+
import { m as Runtime, n as ExecutorFactory, E as ExecutorRegistry, l as DeliverableSpec, i as Spend, d as Agent, j as Scope, e as ResultBlobStore, B as Budget } from './worktree-CUn0d-ZT.js';
|
|
2
|
+
import { AgentProfile, AgentProfileValidationResult } from '@tangle-network/agent-interface';
|
|
3
3
|
import { U as UiLens, a as UiFinding, C as CoderTask } from './substrate-rNj6TDc3.js';
|
|
4
4
|
import { e as LoopTraceEmitter, c as LoopTraceEvent, S as SandboxClient, A as AgentRunSpec, E as ExecCtx } from './types-BF-MEsQB.js';
|
|
5
|
-
import { SandboxEvent, SandboxInstance, BackendType } from '@tangle-network/sandbox';
|
|
5
|
+
import { SandboxEvent, SandboxInstance, CreateSandboxOptions, BackendType } from '@tangle-network/sandbox';
|
|
6
6
|
import { AgentEvalError } from '@tangle-network/agent-eval';
|
|
7
7
|
import { O as OtelExporter } from './otel-export-BKmNwiCb.js';
|
|
8
8
|
import { T as ToolSpec, R as RouterConfig } from './router-client-CMAWGv1h.js';
|
|
9
|
-
import { L as LocalHarness } from './local-harness-
|
|
9
|
+
import { L as LocalHarness } from './local-harness-DU7yV6mG.js';
|
|
10
|
+
import { AgentEnvironmentProvider, AgentEnvironmentCapabilities, CreateAgentEnvironmentInput, AgentTurnInput, AgentProfileRef } from '@tangle-network/agent-interface/environment-provider';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @experimental
|
|
@@ -389,10 +390,10 @@ declare function traceContextToEnv(ctx: TraceContext): Record<string, string>;
|
|
|
389
390
|
* sees over the wire. These types are the contract; the JSON schemas under
|
|
390
391
|
* `tools/*` mirror them for the MCP `tools/list` advertisement.
|
|
391
392
|
*
|
|
392
|
-
* Async semantics: `
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
393
|
+
* Async semantics: `delegate_ui_audit` returns a `taskId` immediately. The
|
|
394
|
+
* product agent polls `delegation_status` until the task transitions to
|
|
395
|
+
* `completed` | `failed` | `cancelled`. `delegate_feedback` +
|
|
396
|
+
* `delegation_history` are synchronous reads / writes against the local
|
|
396
397
|
* task queue + feedback store.
|
|
397
398
|
*/
|
|
398
399
|
|
|
@@ -1436,9 +1437,9 @@ interface DetachedSessionDelegateOptions {
|
|
|
1436
1437
|
* the recursive worktree-CLI leaf does not yet have a journal-replay equivalent for.
|
|
1437
1438
|
*
|
|
1438
1439
|
* For NEW local-repo coding use `worktreeFanout` / `worktreeLoopRunner` (author an `AgentProfile`
|
|
1439
|
-
* per harness → `createWorktreeCliExecutor` leaves → `gateOnDeliverable`). This delegate
|
|
1440
|
-
*
|
|
1441
|
-
*
|
|
1440
|
+
* per harness → `createWorktreeCliExecutor` leaves → `gateOnDeliverable`). This delegate runs
|
|
1441
|
+
* held-stream by default and only its OPTIONAL cross-restart resume (the `driveTurn` tick) is opt-in
|
|
1442
|
+
* behind `MCP_ENABLE_DETACHED_RESUME`.
|
|
1442
1443
|
*
|
|
1443
1444
|
* @experimental
|
|
1444
1445
|
*/
|
|
@@ -1535,6 +1536,63 @@ declare class InMemoryFeedbackStore implements FeedbackStore {
|
|
|
1535
1536
|
*/
|
|
1536
1537
|
declare function eventToSnapshot(event: FeedbackEvent): DelegationFeedbackSnapshot;
|
|
1537
1538
|
|
|
1539
|
+
/** Provider object or registry name accepted by runtime provider adapters.
|
|
1540
|
+
* @experimental */
|
|
1541
|
+
type AgentEnvironmentProviderRef = AgentEnvironmentProvider | string;
|
|
1542
|
+
/** In-memory registry for named `AgentEnvironmentProvider` instances.
|
|
1543
|
+
* @experimental */
|
|
1544
|
+
interface AgentEnvironmentProviderRegistry {
|
|
1545
|
+
register(provider: AgentEnvironmentProvider, options?: {
|
|
1546
|
+
replace?: boolean;
|
|
1547
|
+
}): void;
|
|
1548
|
+
has(name: string): boolean;
|
|
1549
|
+
get(name: string): AgentEnvironmentProvider | undefined;
|
|
1550
|
+
require(name: string): AgentEnvironmentProvider;
|
|
1551
|
+
names(): string[];
|
|
1552
|
+
providers(): AgentEnvironmentProvider[];
|
|
1553
|
+
capabilities(name: string): Promise<AgentEnvironmentCapabilities>;
|
|
1554
|
+
}
|
|
1555
|
+
/** Create a registry that resolves provider names to concrete provider instances.
|
|
1556
|
+
* @experimental */
|
|
1557
|
+
declare function createAgentEnvironmentProviderRegistry(providers?: Iterable<AgentEnvironmentProvider>): AgentEnvironmentProviderRegistry;
|
|
1558
|
+
/** Resolve a provider instance or registry name, failing loudly when a name is unknown.
|
|
1559
|
+
* @experimental */
|
|
1560
|
+
declare function resolveAgentEnvironmentProvider(provider: AgentEnvironmentProviderRef, registry?: AgentEnvironmentProviderRegistry): AgentEnvironmentProvider;
|
|
1561
|
+
/** Options for exposing an `AgentEnvironmentProvider` through the legacy sandbox client port.
|
|
1562
|
+
* @experimental */
|
|
1563
|
+
interface ProviderAsSandboxClientOptions {
|
|
1564
|
+
defaults?: Partial<CreateAgentEnvironmentInput>;
|
|
1565
|
+
requireTerminalEvent?: boolean;
|
|
1566
|
+
mapCreateOptions?: (options: CreateSandboxOptions | undefined) => Partial<CreateAgentEnvironmentInput>;
|
|
1567
|
+
}
|
|
1568
|
+
/** Adapt a neutral environment provider to the `SandboxClient` interface used by existing loop paths.
|
|
1569
|
+
* @experimental */
|
|
1570
|
+
declare function providerAsSandboxClient(provider: AgentEnvironmentProvider, options?: ProviderAsSandboxClientOptions): SandboxClient;
|
|
1571
|
+
/** Options for wrapping the current Tangle sandbox client as an environment provider.
|
|
1572
|
+
* @experimental */
|
|
1573
|
+
interface SandboxClientProviderOptions {
|
|
1574
|
+
name?: string;
|
|
1575
|
+
defaultBackend?: BackendType;
|
|
1576
|
+
capabilities?: AgentEnvironmentCapabilities | (() => AgentEnvironmentCapabilities | Promise<AgentEnvironmentCapabilities>);
|
|
1577
|
+
validateProfile?: (profile: AgentProfileRef) => AgentProfileValidationResult | Promise<AgentProfileValidationResult>;
|
|
1578
|
+
mapCreateInput?: (input: CreateAgentEnvironmentInput) => CreateSandboxOptions;
|
|
1579
|
+
}
|
|
1580
|
+
/** Adapt a `SandboxClient` into the shared `AgentEnvironmentProvider` contract.
|
|
1581
|
+
* @experimental */
|
|
1582
|
+
declare function sandboxClientAsProvider(client: SandboxClient, options?: SandboxClientProviderOptions): AgentEnvironmentProvider;
|
|
1583
|
+
/** Options for running a provider as a supervise-mode executor.
|
|
1584
|
+
* @experimental */
|
|
1585
|
+
interface ProviderExecutorOptions {
|
|
1586
|
+
defaults?: Partial<CreateAgentEnvironmentInput>;
|
|
1587
|
+
runtime?: Runtime;
|
|
1588
|
+
destroyOnSettle?: boolean;
|
|
1589
|
+
requireTerminalEvent?: boolean;
|
|
1590
|
+
taskToTurn?: (task: unknown, specProfile: AgentProfile) => AgentTurnInput;
|
|
1591
|
+
}
|
|
1592
|
+
/** Adapt an environment provider into an `ExecutorFactory` for `createExecutor`.
|
|
1593
|
+
* @experimental */
|
|
1594
|
+
declare function providerAsExecutor(provider: AgentEnvironmentProvider, options?: ProviderExecutorOptions): ExecutorFactory<unknown>;
|
|
1595
|
+
|
|
1538
1596
|
/**
|
|
1539
1597
|
* @experimental
|
|
1540
1598
|
*
|
|
@@ -1638,6 +1696,13 @@ interface BridgeSeam {
|
|
|
1638
1696
|
* Mirrors `routerToolsInlineExecutor.maxTurns`; default 200 (runaway backstop). */
|
|
1639
1697
|
maxTurns?: number;
|
|
1640
1698
|
}
|
|
1699
|
+
/** Generic environment provider executor config. External packages implement
|
|
1700
|
+
* `AgentEnvironmentProvider`; this built-in wrapper lets `createExecutor`
|
|
1701
|
+
* consume them as backend data while preserving the existing usage channel. */
|
|
1702
|
+
interface ProviderSeam extends ProviderExecutorOptions {
|
|
1703
|
+
provider: AgentEnvironmentProvider | string;
|
|
1704
|
+
registry?: AgentEnvironmentProviderRegistry;
|
|
1705
|
+
}
|
|
1641
1706
|
/**
|
|
1642
1707
|
* Router seam WITH tool use — the tool-using router backend. Same direct
|
|
1643
1708
|
* OpenAI-compatible endpoint as `RouterSeam`, but each turn passes `tools`; when
|
|
@@ -1693,6 +1758,8 @@ type ExecutorConfig = ({
|
|
|
1693
1758
|
} & CliSeam) | ({
|
|
1694
1759
|
backend: 'cli-worktree';
|
|
1695
1760
|
} & CliWorktreeSeam) | ({
|
|
1761
|
+
backend: 'provider';
|
|
1762
|
+
} & ProviderSeam) | ({
|
|
1696
1763
|
backend: 'sandbox';
|
|
1697
1764
|
harness?: BackendType;
|
|
1698
1765
|
} & SandboxSeam);
|
|
@@ -1724,19 +1791,15 @@ declare function createExecutorRegistry(): ExecutorRegistry;
|
|
|
1724
1791
|
* `delegate` MCP tool — the ONE generic delegation verb, the agent-facing front door to
|
|
1725
1792
|
* `delegate()` / `supervise()`. The agent hands it an INTENT (what it wants done); a default
|
|
1726
1793
|
* authoring supervisor decomposes the intent and AUTHORS the worker profile it needs — there is no
|
|
1727
|
-
* hardcoded coder/researcher profile
|
|
1728
|
-
* `delegate_research`.
|
|
1794
|
+
* hardcoded coder/researcher profile, so one verb covers code, research, and anything else.
|
|
1729
1795
|
*
|
|
1730
|
-
* Unlike those async, queue-backed tools (kick off → return a taskId → poll `delegation_status`),
|
|
1731
1796
|
* `delegate` is SYNCHRONOUS: it awaits the full supervised run and returns the delivered output
|
|
1732
1797
|
* TOGETHER WITH `spentTotal` — the conserved cost of the whole delegation (`iterations` / `tokens` /
|
|
1733
|
-
* `usd` / `ms`)
|
|
1734
|
-
* which has no cost channel.
|
|
1798
|
+
* `usd` / `ms`), so the caller always learns what the delegation actually spent.
|
|
1735
1799
|
*
|
|
1736
1800
|
* The supervisor's substrate (its brain `router`, the worker `backend`, the completion `deliverable`)
|
|
1737
|
-
* is INJECTED at server construction — never an agent-supplied arg
|
|
1738
|
-
*
|
|
1739
|
-
* `runId`).
|
|
1801
|
+
* is INJECTED at server construction — never an agent-supplied arg. The agent supplies only the
|
|
1802
|
+
* intent (+ an optional per-call `model` / `runId`).
|
|
1740
1803
|
*/
|
|
1741
1804
|
|
|
1742
1805
|
/** @experimental */
|
|
@@ -1827,10 +1890,10 @@ declare function createDelegateHandler(options: DelegateHandlerOptions): (raw: u
|
|
|
1827
1890
|
/** @experimental */
|
|
1828
1891
|
interface McpServerOptions {
|
|
1829
1892
|
/**
|
|
1830
|
-
* Required to enable `delegate` — the ONE generic delegation verb
|
|
1831
|
-
*
|
|
1832
|
-
* worker
|
|
1833
|
-
*
|
|
1893
|
+
* Required to enable `delegate` — the ONE generic delegation verb. Inject the supervisor
|
|
1894
|
+
* substrate: its brain `router`, the worker `backend`, and the completion `deliverable`. The
|
|
1895
|
+
* supervisor AUTHORS its own worker from the agent's intent, so there is no worker profile to
|
|
1896
|
+
* wire here.
|
|
1834
1897
|
*/
|
|
1835
1898
|
delegateSupervisor?: DelegateHandlerOptions;
|
|
1836
1899
|
/**
|
|
@@ -2062,4 +2125,4 @@ interface CoordinationTools {
|
|
|
2062
2125
|
/** Build the driver's MCP tools over a live scope. */
|
|
2063
2126
|
declare function createCoordinationTools(opts: CoordinationToolsOptions): CoordinationTools;
|
|
2064
2127
|
|
|
2065
|
-
export { type DelegationTaskQueueOptions as $, type AnalystRegistry as A, type DelegateResearchArgs as B, type CappedDelegationTrace as C, type DelegationExecutor as D, type DelegateResearchConfig as E, type FleetHandle as F, type DelegateResearchResult as G, type DelegateResult as H, type DelegateRunCtx as I, type DelegateUiAuditConfig as J, type DelegateUiAuditRoute as K, type DelegationError as L, type DelegationFeedbackSnapshot as M, type DelegationHistoryEntry as N, DelegationPersistenceError as O, type DelegationProfile as P, type DelegationProgress as Q, type DelegationRecord as R, type DelegationResultPayload as S, type DelegationResumeContext as T, type UiAuditorDelegate as U, type DelegationResumeDriver as V, type DelegationResumeTick as W, type DelegationRunContext as X, DelegationStateCorruptError as Y, type DelegationStatus as Z, type DelegationStore as _, DelegationTaskQueue as a, type ExecutorConfig as a$, type DelegationTraceCaps as a0, type DelegationTraceCollector as a1, type DelegationTraceSpan as a2, type DetachedSessionDelegateOptions as a3, type DetachedSessionRefParts as a4, type DetachedTurn as a5, type DetachedTurnResumeDriverOptions as a6, type DetachedWinnerSelection as a7, type DriveTurnCapableBox as a8, type DriveTurnTick as a9, type SubmitOutput as aA, type TraceContext as aB, type UiAuditorDelegationOutput as aC, buildDelegationTraceSpans as aD, capDelegationTrace as aE, coderTaskFromArgs as aF, composeLoopTraceEmitters as aG, createCoordinationTools as aH, createDelegateHandler as aI, createDelegationTraceCollector as aJ, createDetachedTurnResumeDriver as aK, createFleetWorkspaceExecutor as aL, createInProcessTransport as aM, createMcpServer as aN, createPropagatingTraceEmitter as aO, createSiblingSandboxExecutor as aP, detachedSessionDelegate as aQ, detachedTurnEvents as aR, eventToSnapshot as aS, formatDetachedSessionRef as aT, hashIdempotencyInput as aU, parseDetachedSessionRef as aV, readTraceContextFromEnv as aW, runDetachedTurn as aX, settleDetachedCoderTurn as aY, traceContextToEnv as aZ, validateDelegateArgs as a_, type FeedbackEvent as aa, type FeedbackRating as ab, type FeedbackRefersTo as ac, FileDelegationStore as ad, type FileDelegationStoreOptions as ae, type FleetWorkspaceExecutorOptions as af, InMemoryDelegationStore as ag, InMemoryFeedbackStore as ah, type JsonRpcMessage as ai, type JsonRpcResponse as aj, type MakeWorkerAgent as ak, type McpServer as al, type McpServerOptions as am, type McpToolDescriptor as an, type McpTransport as ao, type Question as ap, type QuestionDecision as aq, type QuestionPolicy as ar, type QuestionRecord as as, type ResearchOutputShape as at, type ResearchSource as au, type RunDetachedTurnOptions as av, type SettleDetachedCoderTurnOptions as aw, type SettledWorker as ax, type SiblingSandboxExecutorOptions as ay, type SubmitInput as az, type FeedbackStore as b, type
|
|
2128
|
+
export { type DelegationTaskQueueOptions as $, type AnalystRegistry as A, type DelegateResearchArgs as B, type CappedDelegationTrace as C, type DelegationExecutor as D, type DelegateResearchConfig as E, type FleetHandle as F, type DelegateResearchResult as G, type DelegateResult as H, type DelegateRunCtx as I, type DelegateUiAuditConfig as J, type DelegateUiAuditRoute as K, type DelegationError as L, type DelegationFeedbackSnapshot as M, type DelegationHistoryEntry as N, DelegationPersistenceError as O, type DelegationProfile as P, type DelegationProgress as Q, type DelegationRecord as R, type DelegationResultPayload as S, type DelegationResumeContext as T, type UiAuditorDelegate as U, type DelegationResumeDriver as V, type DelegationResumeTick as W, type DelegationRunContext as X, DelegationStateCorruptError as Y, type DelegationStatus as Z, type DelegationStore as _, DelegationTaskQueue as a, type ExecutorConfig as a$, type DelegationTraceCaps as a0, type DelegationTraceCollector as a1, type DelegationTraceSpan as a2, type DetachedSessionDelegateOptions as a3, type DetachedSessionRefParts as a4, type DetachedTurn as a5, type DetachedTurnResumeDriverOptions as a6, type DetachedWinnerSelection as a7, type DriveTurnCapableBox as a8, type DriveTurnTick as a9, type SubmitOutput as aA, type TraceContext as aB, type UiAuditorDelegationOutput as aC, buildDelegationTraceSpans as aD, capDelegationTrace as aE, coderTaskFromArgs as aF, composeLoopTraceEmitters as aG, createCoordinationTools as aH, createDelegateHandler as aI, createDelegationTraceCollector as aJ, createDetachedTurnResumeDriver as aK, createFleetWorkspaceExecutor as aL, createInProcessTransport as aM, createMcpServer as aN, createPropagatingTraceEmitter as aO, createSiblingSandboxExecutor as aP, detachedSessionDelegate as aQ, detachedTurnEvents as aR, eventToSnapshot as aS, formatDetachedSessionRef as aT, hashIdempotencyInput as aU, parseDetachedSessionRef as aV, readTraceContextFromEnv as aW, runDetachedTurn as aX, settleDetachedCoderTurn as aY, traceContextToEnv as aZ, validateDelegateArgs as a_, type FeedbackEvent as aa, type FeedbackRating as ab, type FeedbackRefersTo as ac, FileDelegationStore as ad, type FileDelegationStoreOptions as ae, type FleetWorkspaceExecutorOptions as af, InMemoryDelegationStore as ag, InMemoryFeedbackStore as ah, type JsonRpcMessage as ai, type JsonRpcResponse as aj, type MakeWorkerAgent as ak, type McpServer as al, type McpServerOptions as am, type McpToolDescriptor as an, type McpTransport as ao, type Question as ap, type QuestionDecision as aq, type QuestionPolicy as ar, type QuestionRecord as as, type ResearchOutputShape as at, type ResearchSource as au, type RunDetachedTurnOptions as av, type SettleDetachedCoderTurnOptions as aw, type SettledWorker as ax, type SiblingSandboxExecutorOptions as ay, type SubmitInput as az, type FeedbackStore as b, type AgentEnvironmentProviderRef as b0, type AgentEnvironmentProviderRegistry as b1, type BusEvent as b2, type BusRecord as b3, type BusStats as b4, type EventBus as b5, type ProviderAsSandboxClientOptions as b6, type ProviderExecutorOptions as b7, type ProviderSeam as b8, type PublishOptions as b9, type SandboxClientProviderOptions as ba, cliWorktreeExecutor as bb, createAgentEnvironmentProviderRegistry as bc, createEventBus as bd, createExecutor as be, createExecutorRegistry as bf, providerAsExecutor as bg, providerAsSandboxClient as bh, resolveAgentEnvironmentProvider as bi, sandboxClientAsProvider as bj, type DelegateFeedbackResult as c, type DelegateFeedbackArgs as d, type DelegateUiAuditArgs as e, type DelegateUiAuditResult as f, type DelegationHistoryResult as g, type DelegationHistoryArgs as h, type DelegationStatusResult as i, type DelegationStatusArgs as j, type CoderDelegate as k, type CoderReview as l, type CoderReviewer as m, type CoordinationEvent as n, type CoordinationTools as o, type CoordinationToolsOptions as p, DELEGATE_DESCRIPTION as q, DELEGATE_INPUT_SCHEMA as r, DELEGATE_TOOL_NAME as s, DELEGATION_TRACE_MAX_BYTES as t, DELEGATION_TRACE_MAX_SPANS as u, type DelegateArgs as v, type DelegateCodeArgs as w, type DelegateCodeConfig as x, type DelegateCodeResult as y, type DelegateHandlerOptions as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,21 +3,21 @@ export { AgentEvalError, AgentEvalErrorCode, ConfigError, ControlBudget, Control
|
|
|
3
3
|
import { f as AgentBackendInput, g as AgentExecutionBackend, O as OpenAIChatTool, h as OpenAIChatToolChoice, i as OpenAIChatResponseFormat, j as AgentBackendContext, a as RuntimeStreamEvent, K as KnowledgeReadinessDecision, k as RunAgentTaskOptions, l as AgentTaskRunResult, m as RunAgentTaskStreamOptions, n as AgentRuntimeEvent, o as AgentTaskStatus, p as RuntimeSessionStore, q as RuntimeSession, R as RuntimeHooks } from './types-BF-MEsQB.js';
|
|
4
4
|
export { r as AgentAdapter, s as AgentKnowledgeProvider, t as AgentRuntimeEventSink, u as AgentTaskContext, v as AgentTaskSpec, B as BackendErrorDetail, w as RuntimeDecisionEvidenceRef, x as RuntimeDecisionKind, y as RuntimeDecisionPoint, z as RuntimeHookContext, C as RuntimeHookErrorContext, D as RuntimeHookEvent, F as RuntimeHookPhase, G as RuntimeHookTarget, H as RuntimeRunHandle, J as RuntimeRunPersistenceAdapter, M as RuntimeRunRow, N as composeRuntimeHooks, P as defineRuntimeHooks, Q as notifyRuntimeDecisionPoint, T as notifyRuntimeHookEvent, U as startRuntimeRun } from './types-BF-MEsQB.js';
|
|
5
5
|
import { Scenario, ProfileDispatchFn } from '@tangle-network/agent-eval/campaign';
|
|
6
|
-
import { C as CandidateGenerator } from './mcp-serve-verifier-
|
|
7
|
-
export { A as AgenticGeneratorOptions, I as ImprovementDriverOptions, M as McpServeSpec, V as Verifier, a as VerifyResult, b as agenticGenerator, c as commandVerifier, i as improvementDriver, m as mcpServeVerifier } from './mcp-serve-verifier-
|
|
6
|
+
import { C as CandidateGenerator } from './mcp-serve-verifier-BvMAV_8U.js';
|
|
7
|
+
export { A as AgenticGeneratorOptions, I as ImprovementDriverOptions, M as McpServeSpec, V as Verifier, a as VerifyResult, b as agenticGenerator, c as commandVerifier, i as improvementDriver, m as mcpServeVerifier } from './mcp-serve-verifier-BvMAV_8U.js';
|
|
8
8
|
import { Scenario as Scenario$1, SurfaceProposer, JudgeConfig, MutableSurface, DispatchContext, SelfImproveBudget, SelfImproveLlm, SelfImproveResult } from '@tangle-network/agent-eval/contract';
|
|
9
9
|
import { AgentProfile as AgentProfile$1 } from '@tangle-network/agent-interface';
|
|
10
10
|
import { S as SurfaceImprovementEdit } from './improvement-adapter-CioiEE2z.js';
|
|
11
11
|
import { I as ImprovementAdapter } from './types-BC3bZpH0.js';
|
|
12
|
-
export { D as DELEGATED_LOOP_MODES, a as DelegatedLoopMode, b as DelegatedLoopRegistry, c as DelegatedLoopResult, d as DelegatedLoopRunner, L as LoopRunnerCliArgs, e as LoopRunnerCliResult, R as ResearchLoopResult, f as ResearchLoopRunnerOptions, g as RunDelegatedLoopOptions, V as VetoedFact, W as WorktreeLoopRunnerOptions, h as auditLoopRunner, i as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, j as runDelegatedLoop, k as runLoopRunnerCli, s as selfImproveLoopRunner, w as worktreeLoopRunner } from './loop-runner-bin-
|
|
12
|
+
export { D as DELEGATED_LOOP_MODES, a as DelegatedLoopMode, b as DelegatedLoopRegistry, c as DelegatedLoopResult, d as DelegatedLoopRunner, L as LoopRunnerCliArgs, e as LoopRunnerCliResult, R as ResearchLoopResult, f as ResearchLoopRunnerOptions, g as RunDelegatedLoopOptions, V as VetoedFact, W as WorktreeLoopRunnerOptions, h as auditLoopRunner, i as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, j as runDelegatedLoop, k as runLoopRunnerCli, s as selfImproveLoopRunner, w as worktreeLoopRunner } from './loop-runner-bin-Ddgf4DkS.js';
|
|
13
13
|
export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-B-3v06BE.js';
|
|
14
14
|
export { E as EvalRunEvent, a as EvalRunGeneration, b as EvalRunsExportConfig, c as EvalRunsExportResult, I as INTELLIGENCE_WIRE_VERSION, L as LoopSpanNode, d as OtelAttribute, e as OtelExportConfig, O as OtelExporter, f as OtelSpan, g as buildLoopOtelSpans, h as buildLoopSpanNodes, i as createOtelExporter, j as exportEvalRuns, l as loopEventToOtelSpan } from './otel-export-BKmNwiCb.js';
|
|
15
15
|
import '@tangle-network/sandbox';
|
|
16
|
-
import './local-harness-
|
|
16
|
+
import './local-harness-DU7yV6mG.js';
|
|
17
17
|
import 'node:child_process';
|
|
18
18
|
import './kb-gate-CuzMYGYM.js';
|
|
19
|
-
import './worktree-
|
|
20
|
-
import './worktree-fanout-
|
|
19
|
+
import './worktree-CUn0d-ZT.js';
|
|
20
|
+
import './worktree-fanout-DwwatTdY.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @stable
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mcpToolsForRuntimeMcp,
|
|
3
3
|
mcpToolsForRuntimeMcpSubset
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-F6G3SSHY.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_ROUTER_BASE_URL,
|
|
7
7
|
cleanModelId,
|
|
@@ -20,16 +20,16 @@ import {
|
|
|
20
20
|
runLoopRunnerCli,
|
|
21
21
|
selfImproveLoopRunner,
|
|
22
22
|
worktreeLoopRunner
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-GZX3PI7V.js";
|
|
24
24
|
import "./chunk-FNMGYYSS.js";
|
|
25
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-N2JJDGLJ.js";
|
|
26
26
|
import {
|
|
27
27
|
assertModelAllowed,
|
|
28
28
|
composeRuntimeHooks,
|
|
29
29
|
defineRuntimeHooks,
|
|
30
30
|
notifyRuntimeDecisionPoint,
|
|
31
31
|
notifyRuntimeHookEvent
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-EZ2QESTP.js";
|
|
33
33
|
import {
|
|
34
34
|
INTELLIGENCE_WIRE_VERSION,
|
|
35
35
|
buildLoopOtelSpans,
|
|
@@ -46,8 +46,8 @@ import {
|
|
|
46
46
|
mcpBuildPrompt,
|
|
47
47
|
mcpServeVerifier,
|
|
48
48
|
toolBuildPrompt
|
|
49
|
-
} from "./chunk-
|
|
50
|
-
import "./chunk-
|
|
49
|
+
} from "./chunk-LWGVVP2C.js";
|
|
50
|
+
import "./chunk-5JAUQZQA.js";
|
|
51
51
|
import {
|
|
52
52
|
AgentEvalError,
|
|
53
53
|
BackendTransportError,
|
package/dist/lifecycle.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { AgentProfile } from '@tangle-network/agent-interface';
|
|
|
2
2
|
import { a as ProfileArtifact, A as ArtifactKind, b as ArtifactStatus, c as ArtifactInput, E as EvalRunner, d as EvalResult, G as GenerateContext, C as CandidateGenerator, e as PromotionVerdict, P as PromotionGate } from './generator-YkAQrOoD.js';
|
|
3
3
|
export { f as ArtifactPayloads, H as HeldOutPromotionGateOptions, M as MarginalLift, g as MeasureMarginalLiftOptions, h as heldOutPromotionGate, m as measureMarginalLift, t as thresholdPromotionGate } from './generator-YkAQrOoD.js';
|
|
4
4
|
import { LlmClientOptions, AnalystFinding } from '@tangle-network/agent-eval';
|
|
5
|
-
import { M as McpServeSpec } from './mcp-serve-verifier-
|
|
6
|
-
import { L as LocalHarness } from './local-harness-
|
|
5
|
+
import { M as McpServeSpec } from './mcp-serve-verifier-BvMAV_8U.js';
|
|
6
|
+
import { L as LocalHarness } from './local-harness-DU7yV6mG.js';
|
|
7
7
|
import '@tangle-network/agent-eval/campaign';
|
|
8
8
|
import 'node:child_process';
|
|
9
9
|
|
package/dist/lifecycle.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ChildProcess } from 'node:child_process';
|
|
|
5
5
|
*
|
|
6
6
|
* Subprocess wrappers for the local coding-harness CLIs installed in the
|
|
7
7
|
* sandbox image (claude-code, codex, opencode). Used by the in-process
|
|
8
|
-
* delegation executor (`createInProcessExecutor`) so a
|
|
8
|
+
* delegation executor (`createInProcessExecutor`) so a delegated coding task
|
|
9
9
|
* spawns a real harness on a real git worktree instead of provisioning a
|
|
10
10
|
* sibling sandbox.
|
|
11
11
|
*
|
|
@@ -2,8 +2,8 @@ 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
4
|
import { F as FactCandidate, C as CreateKbGateOptions } from './kb-gate-CuzMYGYM.js';
|
|
5
|
-
import { B as Budget } from './worktree-
|
|
6
|
-
import { A as AuthoredHarness, W as WinnerStrategy, a as WorktreeFanoutOptions, b as WorktreePatchArtifact } from './worktree-fanout-
|
|
5
|
+
import { B as Budget } from './worktree-CUn0d-ZT.js';
|
|
6
|
+
import { A as AuthoredHarness, W as WinnerStrategy, a as WorktreeFanoutOptions, b as WorktreePatchArtifact } from './worktree-fanout-DwwatTdY.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @experimental
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { L as LoopRunnerCliArgs, e as LoopRunnerCliResult, p as parseLoopRunnerArgv, k as runLoopRunnerCli } from './loop-runner-bin-
|
|
2
|
+
export { L as LoopRunnerCliArgs, e as LoopRunnerCliResult, p as parseLoopRunnerArgv, k as runLoopRunnerCli } from './loop-runner-bin-Ddgf4DkS.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
7
|
import './kb-gate-CuzMYGYM.js';
|
|
8
|
-
import './worktree-
|
|
8
|
+
import './worktree-CUn0d-ZT.js';
|
|
9
9
|
import '@tangle-network/agent-interface';
|
|
10
10
|
import '@tangle-network/sandbox';
|
|
11
11
|
import './types-BF-MEsQB.js';
|
|
12
|
-
import './worktree-fanout-
|
|
13
|
-
import './local-harness-
|
|
12
|
+
import './worktree-fanout-DwwatTdY.js';
|
|
13
|
+
import './local-harness-DU7yV6mG.js';
|
|
14
14
|
import 'node:child_process';
|
package/dist/loop-runner-bin.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
parseLoopRunnerArgv,
|
|
4
4
|
runLoopRunnerCli
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GZX3PI7V.js";
|
|
6
6
|
import "./chunk-FNMGYYSS.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-N2JJDGLJ.js";
|
|
8
|
+
import "./chunk-EZ2QESTP.js";
|
|
9
9
|
import "./chunk-VMNEQHJR.js";
|
|
10
10
|
import "./chunk-IODKUOBA.js";
|
|
11
11
|
import "./chunk-T2HVQVB4.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-5JAUQZQA.js";
|
|
13
13
|
import "./chunk-NBV35BR6.js";
|
|
14
14
|
import "./chunk-WIR4HOOJ.js";
|
|
15
15
|
import "./chunk-DGUM43GV.js";
|
package/dist/loops.d.ts
CHANGED
|
@@ -2,23 +2,24 @@ import { ChatClient, AnalystFinding, AgentProfile, AnalystRunInputs, ToolSpan, S
|
|
|
2
2
|
export { AnalystFinding, DefaultVerdict, computeFindingId, makeFinding } from '@tangle-network/agent-eval';
|
|
3
3
|
import { SandboxEvent, SandboxInstance, CreateSandboxOptions } from '@tangle-network/sandbox';
|
|
4
4
|
export { AgentProfile, CreateSandboxOptions, SandboxEvent, SandboxInstance } from '@tangle-network/sandbox';
|
|
5
|
-
import { e as ResultBlobStore, S as SpawnJournal, N as NodeId,
|
|
6
|
-
export { A as AgentSpec, k as Executor,
|
|
7
|
-
import { ak as MakeWorkerAgent, o as CoordinationTools, A as AnalystRegistry, n as CoordinationEvent, ar as QuestionPolicy, a$ as ExecutorConfig } from './coordination-
|
|
8
|
-
export { b0 as
|
|
5
|
+
import { e as ResultBlobStore, S as SpawnJournal, N as NodeId, o as SpawnEvent, n as ExecutorFactory, d as Agent, B as Budget, j as Scope, h as Settled, g as SupervisedResult, l as DeliverableSpec, i as Spend, U as UsageEvent, E as ExecutorRegistry, p as Supervisor } from './worktree-CUn0d-ZT.js';
|
|
6
|
+
export { A as AgentSpec, k as Executor, q as ExecutorContext, s as ExecutorResult, t as SupervisorOpts, T as TreeView, u as WidenGate, v as gateOnDeliverable } from './worktree-CUn0d-ZT.js';
|
|
7
|
+
import { ak as MakeWorkerAgent, o as CoordinationTools, A as AnalystRegistry, n as CoordinationEvent, ar as QuestionPolicy, a$ as ExecutorConfig } from './coordination-09JTQnlF.js';
|
|
8
|
+
export { b0 as AgentEnvironmentProviderRef, b1 as AgentEnvironmentProviderRegistry, b2 as BusEvent, b3 as BusRecord, b4 as BusStats, b5 as EventBus, b6 as ProviderAsSandboxClientOptions, b7 as ProviderExecutorOptions, b8 as ProviderSeam, b9 as PublishOptions, ba as SandboxClientProviderOptions, bb as cliWorktreeExecutor, bc as createAgentEnvironmentProviderRegistry, bd as createEventBus, be as createExecutor, bf as createExecutorRegistry, bg as providerAsExecutor, bh as providerAsSandboxClient, bi as resolveAgentEnvironmentProvider, bj as sandboxClientAsProvider } from './coordination-09JTQnlF.js';
|
|
9
9
|
import { R as RuntimeHooks, I as Iteration, S as SandboxClient, W as Driver, A as AgentRunSpec, b as OutputAdapter, V as Validator, E as ExecCtx, X as LoopWinner, Y as LoopLineageOptions, Z as LoopResult, L as LoopTokenUsage, a as RuntimeStreamEvent, _ as MountRecorder } from './types-BF-MEsQB.js';
|
|
10
10
|
export { $ as LoopDecisionPayload, a0 as LoopEndedPayload, a1 as LoopIterationDispatchPayload, a2 as LoopIterationEndedPayload, a3 as LoopIterationStartedPayload, a4 as LoopPlanDescription, a5 as LoopPlanPayload, d as LoopSandboxPlacement, a6 as LoopStartedPayload, a7 as LoopTeardownFailedPayload, e as LoopTraceEmitter, c as LoopTraceEvent, a8 as MountManifestEntry, a9 as RunProvenance, aa as SelectionReceipt, ab as ValidationCtx } from './types-BF-MEsQB.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-
|
|
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-
|
|
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-DwwatTdY.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-DwwatTdY.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
16
|
import { R as RouterConfig, a as ToolLoopChat } from './router-client-CMAWGv1h.js';
|
|
17
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-CMAWGv1h.js';
|
|
18
18
|
import { stuckLoopView, toolWasteView } from '@tangle-network/agent-eval/pipelines';
|
|
19
|
+
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';
|
|
19
20
|
import './substrate-rNj6TDc3.js';
|
|
20
21
|
import './otel-export-BKmNwiCb.js';
|
|
21
|
-
import './local-harness-
|
|
22
|
+
import './local-harness-DU7yV6mG.js';
|
|
22
23
|
import 'node:child_process';
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -2721,8 +2722,8 @@ declare function supervisorAgent(profile: SupervisorProfile, deps: SupervisorAge
|
|
|
2721
2722
|
* for free; nothing is hand-rolled. The result is `supervise()`'s `SupervisedResult` returned
|
|
2722
2723
|
* UNCHANGED, so its `spentTotal` (`{ iterations, tokens, usd, ms }`) rides straight back to the
|
|
2723
2724
|
* caller on BOTH paths — a `winner` carries the delivered worker's spend, a `no-winner` carries the
|
|
2724
|
-
* spend incurred before it failed. That cost channel
|
|
2725
|
-
*
|
|
2725
|
+
* spend incurred before it failed. That cost channel means a `delegate()` caller always learns what
|
|
2726
|
+
* the delegation actually spent.
|
|
2726
2727
|
*/
|
|
2727
2728
|
|
|
2728
2729
|
/** The conserved pool a `delegate()` call applies when the caller does not pass its own `budget`.
|
package/dist/loops.js
CHANGED
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
watchTrace,
|
|
77
77
|
widen,
|
|
78
78
|
worktreeFanout
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-N2JJDGLJ.js";
|
|
80
80
|
import {
|
|
81
81
|
InMemoryResultBlobStore,
|
|
82
82
|
InMemorySpawnJournal,
|
|
@@ -87,6 +87,7 @@ import {
|
|
|
87
87
|
authoredWorker,
|
|
88
88
|
cliWorktreeExecutor,
|
|
89
89
|
contentAddress,
|
|
90
|
+
createAgentEnvironmentProviderRegistry,
|
|
90
91
|
createBudgetPool,
|
|
91
92
|
createEventBus,
|
|
92
93
|
createExecutor,
|
|
@@ -106,11 +107,15 @@ import {
|
|
|
106
107
|
gateOnDeliverable,
|
|
107
108
|
probeSandboxCapabilities,
|
|
108
109
|
profileRichnessFinding,
|
|
110
|
+
providerAsExecutor,
|
|
111
|
+
providerAsSandboxClient,
|
|
112
|
+
resolveAgentEnvironmentProvider,
|
|
109
113
|
routerBrain,
|
|
110
114
|
routerChatWithTools,
|
|
111
115
|
routerChatWithUsage,
|
|
112
116
|
routerToolLoop,
|
|
113
117
|
runLoop,
|
|
118
|
+
sandboxClientAsProvider,
|
|
114
119
|
serveCoordinationMcp,
|
|
115
120
|
settledToIteration,
|
|
116
121
|
spendFromUsageEvents,
|
|
@@ -118,13 +123,13 @@ import {
|
|
|
118
123
|
supervisorAgent,
|
|
119
124
|
supervisorInstructions,
|
|
120
125
|
workerFromBackend
|
|
121
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-EZ2QESTP.js";
|
|
122
127
|
import "./chunk-VMNEQHJR.js";
|
|
123
128
|
import {
|
|
124
129
|
extractLlmCallEvent,
|
|
125
130
|
mapSandboxEvent
|
|
126
131
|
} from "./chunk-T2HVQVB4.js";
|
|
127
|
-
import "./chunk-
|
|
132
|
+
import "./chunk-5JAUQZQA.js";
|
|
128
133
|
import "./chunk-NBV35BR6.js";
|
|
129
134
|
import "./chunk-WIR4HOOJ.js";
|
|
130
135
|
import "./chunk-DGUM43GV.js";
|
|
@@ -153,6 +158,7 @@ export {
|
|
|
153
158
|
completionAuthorizes,
|
|
154
159
|
computeFindingId,
|
|
155
160
|
contentAddress,
|
|
161
|
+
createAgentEnvironmentProviderRegistry,
|
|
156
162
|
createBudgetPool,
|
|
157
163
|
createEventBus,
|
|
158
164
|
createExecutor,
|
|
@@ -211,6 +217,8 @@ export {
|
|
|
211
217
|
probeSandboxCapabilities,
|
|
212
218
|
profileRichnessFinding,
|
|
213
219
|
promotionGate,
|
|
220
|
+
providerAsExecutor,
|
|
221
|
+
providerAsSandboxClient,
|
|
214
222
|
refine,
|
|
215
223
|
registerShape,
|
|
216
224
|
registryScopeAnalyst,
|
|
@@ -218,6 +226,7 @@ export {
|
|
|
218
226
|
renderCorpusToInstructions,
|
|
219
227
|
renderReport,
|
|
220
228
|
reportLoopUsage,
|
|
229
|
+
resolveAgentEnvironmentProvider,
|
|
221
230
|
routerBrain,
|
|
222
231
|
routerChatWithTools,
|
|
223
232
|
routerChatWithUsage,
|
|
@@ -230,6 +239,7 @@ export {
|
|
|
230
239
|
runStrategyEvolution,
|
|
231
240
|
sample,
|
|
232
241
|
sampleThenRefine,
|
|
242
|
+
sandboxClientAsProvider,
|
|
233
243
|
sandboxSessionTraceSource,
|
|
234
244
|
selectChampion,
|
|
235
245
|
selectValidWinner,
|
package/dist/mcp/bin.js
CHANGED
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
DelegationTaskQueue,
|
|
10
10
|
FileDelegationStore,
|
|
11
11
|
createMcpServer
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-EZ2QESTP.js";
|
|
13
13
|
import "../chunk-VMNEQHJR.js";
|
|
14
14
|
import "../chunk-T2HVQVB4.js";
|
|
15
|
-
import "../chunk-
|
|
15
|
+
import "../chunk-5JAUQZQA.js";
|
|
16
16
|
import "../chunk-NBV35BR6.js";
|
|
17
17
|
import "../chunk-WIR4HOOJ.js";
|
|
18
18
|
import "../chunk-DGUM43GV.js";
|
package/dist/mcp/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/delegate-supervisor-provisioning.ts","../../src/mcp/bin.ts"],"sourcesContent":["/**\n * @experimental\n *\n * Resolve the `delegate` supervisor substrate (router brain + worker backend) from env, so the\n * `agent-runtime-mcp` bin can serve the ONE generic `delegate` verb the same way it serves\n * `delegate_code` — by env, over the SAME stdio invocation a consumer already mounts.\n *\n * `delegate` is wired into `createMcpServer` via `McpServerOptions.delegateSupervisor`, which needs a\n * router (the supervisor brain's substrate) and a backend (WHERE the authored workers run). Inside a\n * sandbox child the natural backend is `sandbox`: authored workers run as sub-sandboxes through the\n * SAME `SandboxClient` the bin already loads from `TANGLE_API_KEY` — the deployment shape\n * `delegate_code` used. The brain's router reuses the repo's `resolveRouterBaseUrl` convention\n * (`TANGLE_ROUTER_URL` / `TANGLE_ROUTER_BASE_URL`), normalised to an OpenAI-compatible `/v1` endpoint,\n * keyed by `TANGLE_API_KEY`.\n */\n\nimport type { BackendType } from '@tangle-network/sandbox'\nimport { type RouterEnv, resolveRouterBaseUrl } from '../model-resolution.js'\nimport type { SandboxClient } from '../runtime'\nimport type { RouterConfig } from '../runtime/router-client'\nimport type { ExecutorConfig } from '../runtime/supervise/runtime'\nimport type { DelegateHandlerOptions } from './tools/delegate'\n\nconst DEFAULT_SUPERVISOR_MODEL = 'moonshotai/kimi-k2.6'\nconst DEFAULT_WORKER_HARNESS = 'opencode'\n\nfunction trimmed(value: string | undefined): string | undefined {\n const v = value?.trim()\n return v ? v : undefined\n}\n\n/** True when the operator opted the generic `delegate` verb in (`MCP_ENABLE_DELEGATE=1`). Default off:\n * the wiring is additive, so existing `delegate_code` / `delegate_research` consumers are unaffected. */\nexport function delegateEnabled(env: NodeJS.ProcessEnv = process.env): boolean {\n return env.MCP_ENABLE_DELEGATE === '1'\n}\n\n/** Resolve the supervisor brain's router substrate from env. The key falls back through the platform\n * key the bin already requires; the base reuses `resolveRouterBaseUrl`, normalised to `/v1`. */\nfunction resolveRouter(env: NodeJS.ProcessEnv): RouterConfig {\n const routerKey = trimmed(env.MCP_SUPERVISOR_ROUTER_KEY) ?? trimmed(env.TANGLE_API_KEY) ?? ''\n const base = trimmed(env.MCP_SUPERVISOR_ROUTER_BASE_URL) ?? resolveRouterBaseUrl(env as RouterEnv)\n const routerBaseUrl = /\\/v\\d+\\/?$/.test(base)\n ? base.replace(/\\/$/, '')\n : `${base.replace(/\\/$/, '')}/v1`\n const model =\n trimmed(env.MCP_SUPERVISOR_MODEL) ??\n trimmed(env.MCP_WORKER_MODEL) ??\n trimmed(env.WORKER_MODEL) ??\n DEFAULT_SUPERVISOR_MODEL\n return { routerBaseUrl, routerKey, model }\n}\n\n/**\n * Build the `delegateSupervisor` substrate for `createMcpServer` from env + the bin's loaded\n * `SandboxClient`. Returns `undefined` when `delegate` is not opted in, so the caller mounts it only\n * when asked. The worker backend is `sandbox` (authored workers run as sub-sandboxes via the same\n * client) on the harness named by `MCP_DELEGATE_WORKER_HARNESS` (default `opencode`).\n */\nexport function resolveDelegateSupervisor(\n sandboxClient: SandboxClient,\n env: NodeJS.ProcessEnv = process.env,\n): DelegateHandlerOptions | undefined {\n if (!delegateEnabled(env)) return undefined\n const router = resolveRouter(env)\n const harness = (trimmed(env.MCP_DELEGATE_WORKER_HARNESS) ??\n DEFAULT_WORKER_HARNESS) as BackendType\n const backend: ExecutorConfig = {\n backend: 'sandbox',\n harness,\n sandboxClient,\n }\n return {\n router,\n backend,\n model: router.model,\n }\n}\n","#!/usr/bin/env node\n\n/**\n * @experimental\n *\n * `agent-runtime-mcp` — stdio MCP server entry point.\n *\n * Serves the ONE generic `delegate` verb (opt-in via `MCP_ENABLE_DELEGATE=1`): one intent → a\n * supervisor that authors + drives its own worker over `supervise()`, returning the delivered output\n * with its cost. The supervisor brain runs on the router; authored workers run as sub-sandboxes\n * through the same `SandboxClient` the bin loads from `TANGLE_API_KEY`. The queue-bound tools\n * (`delegate_feedback`, `delegation_status`, `delegation_history`) are always served.\n *\n * Environment variables:\n * TANGLE_API_KEY required — passed to `new Sandbox({ apiKey })`\n * SANDBOX_BASE_URL optional — sandbox-SDK base URL override\n * MCP_ENABLE_DELEGATE set to `1` to serve the generic `delegate` verb. Its authoring\n * supervisor runs the brain on the router and spawns authored\n * workers as sub-sandboxes via the same client; needs TANGLE_API_KEY.\n * MCP_SUPERVISOR_MODEL supervisor brain model id (falls back to MCP_WORKER_MODEL, then\n * WORKER_MODEL, then a default). Must be a tool-calling model.\n * MCP_SUPERVISOR_ROUTER_KEY router key for the supervisor brain (defaults to TANGLE_API_KEY)\n * MCP_SUPERVISOR_ROUTER_BASE_URL router base for the supervisor brain (defaults to the repo's\n * resolveRouterBaseUrl, normalized to `/v1`)\n * MCP_DELEGATE_WORKER_HARNESS harness the authored workers run on (default `opencode`)\n * AGENT_RUNTIME_DELEGATION_STATE_FILE\n * optional — absolute path of a JSON state\n * file. When set, delegation records persist\n * across MCP restarts (FileDelegationStore):\n * status/history survive and idempotency keys\n * dedupe across processes.\n * AGENT_RUNTIME_DELEGATION_STATE_RECOVER\n * set to `1` to archive a corrupt state file\n * (`<file>.corrupt-<ts>`) and start empty\n * instead of refusing to boot.\n * AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL\n * optional — positive integer cap on retained\n * terminal records. Unset = keep forever.\n */\n\nimport type { SandboxClient } from '../runtime'\nimport { delegateEnabled, resolveDelegateSupervisor } from './delegate-supervisor-provisioning'\nimport { FileDelegationStore } from './delegation-store'\nimport { createMcpServer } from './server'\nimport { DelegationTaskQueue } from './task-queue'\nimport { readTraceContextFromEnv, type TraceContext } from './trace-propagation'\n\nconst DEFAULT_SANDBOX_BASE_URL = 'https://sandbox.tangle.tools'\n\nasync function main(): Promise<void> {\n const wantDelegate = delegateEnabled(process.env)\n\n // The generic `delegate` verb needs the sandbox client: its authored workers run as sub-sandboxes\n // (the `sandbox` backend). When `delegate` is not opted in, the server runs the queue-only subset\n // (feedback + status + history) with no sandbox.\n let sandboxClient: SandboxClient | undefined\n if (wantDelegate) {\n const apiKey = process.env.TANGLE_API_KEY\n if (!apiKey && !process.env.AGENT_RUNTIME_MCP_ALLOW_NO_KEY) {\n process.stderr.write(\n 'agent-runtime-mcp: TANGLE_API_KEY is required to serve `delegate`. Set AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 to run without it for diagnostics, or unset MCP_ENABLE_DELEGATE to run the queue-only subset.\\n',\n )\n process.exit(2)\n }\n sandboxClient = await loadSandboxClient(apiKey)\n }\n\n // The supervisor's loop topology spans export to the OTLP / Tangle Intelligence sink when\n // OTEL_EXPORTER_OTLP_ENDPOINT is set (+ TRACE_ID / PARENT_SPAN_ID for correlation). The same\n // context is stamped onto every delegation record so journal consumers join records into the\n // caller's trace.\n const traceContext = readTraceContextFromEnv()\n if (process.env.OTEL_EXPORTER_OTLP_ENDPOINT) {\n process.stderr.write(\n `agent-runtime-mcp: exporting loop topology → ${process.env.OTEL_EXPORTER_OTLP_ENDPOINT}\\n`,\n )\n }\n\n // The ONE generic `delegate` verb — opt-in via MCP_ENABLE_DELEGATE=1. Its authoring supervisor\n // runs the brain on the router and spawns authored workers as sub-sandboxes through the SAME\n // client, so it needs the loaded `sandboxClient`. Gated on the client resolving (no key → no\n // delegate, fail-closed).\n const delegateSupervisor =\n wantDelegate && sandboxClient ? resolveDelegateSupervisor(sandboxClient) : undefined\n if (wantDelegate && delegateSupervisor) {\n process.stderr.write('agent-runtime-mcp: delegate enabled — generic authoring supervisor\\n')\n }\n\n const durableQueue = await buildDurableQueueFromEnv(traceContext)\n const server = createMcpServer({\n ...(delegateSupervisor ? { delegateSupervisor } : {}),\n traceContext,\n ...(durableQueue ? { queue: durableQueue } : {}),\n })\n\n const shutdown = () => {\n server.stop()\n // Drain journal writes so the state file reflects the final record\n // states before the process exits. A persist failure already routed\n // through onPersistError; swallow the duplicate rejection here.\n if (durableQueue) {\n void durableQueue\n .flush()\n .catch(() => {})\n .finally(() => process.exit(0))\n return\n }\n process.exit(0)\n }\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n\n await server.serve()\n}\n\nasync function buildDurableQueueFromEnv(\n traceContext: TraceContext,\n): Promise<DelegationTaskQueue | undefined> {\n const stateFile = process.env.AGENT_RUNTIME_DELEGATION_STATE_FILE?.trim()\n if (!stateFile) return undefined\n const store = new FileDelegationStore({\n filePath: stateFile,\n recoverCorrupt: process.env.AGENT_RUNTIME_DELEGATION_STATE_RECOVER === '1',\n })\n const maxTerminalRecords = parseRetention(process.env.AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL)\n const queue = await DelegationTaskQueue.restore({\n store,\n traceContext,\n ...(maxTerminalRecords !== undefined ? { maxTerminalRecords } : {}),\n onPersistError: (error) => {\n // Durable mode that can no longer write is a broken contract: crash\n // loud instead of degrading to memory-only behind the caller's back.\n process.stderr.write(`agent-runtime-mcp: ${error.message}\\n`)\n process.exit(1)\n },\n })\n process.stderr.write(`agent-runtime-mcp: durable delegation state → ${stateFile}\\n`)\n return queue\n}\n\nfunction parseRetention(raw: string | undefined): number | undefined {\n if (raw === undefined || raw.trim() === '') return undefined\n const n = Number(raw)\n if (!Number.isInteger(n) || n < 1) {\n process.stderr.write(\n `agent-runtime-mcp: AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL must be a positive integer, got \"${raw}\"\\n`,\n )\n process.exit(2)\n }\n return n\n}\n\nasync function loadSandboxClient(apiKey: string | undefined): Promise<SandboxClient> {\n // Diagnostic mode: AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 enables tools/list + the\n // queue-bound tools (status / history / feedback) without sandbox creds.\n // `delegate` requires a real client; the stub fails loud at create() so the\n // agent observes the cause instead of silent success.\n if (!apiKey) {\n return {\n async create() {\n throw new Error(\n 'agent-runtime-mcp: TANGLE_API_KEY is unset; `delegate` is disabled in diagnostic mode. Set TANGLE_API_KEY or unset MCP_ENABLE_DELEGATE to remove the unsupported tool from the tool list.',\n )\n },\n } satisfies SandboxClient\n }\n // Dynamic import keeps the bin importable in environments that haven't\n // installed `@tangle-network/sandbox` yet (the runtime package lists it\n // as a peer dep, not a hard dep).\n const mod = await import('@tangle-network/sandbox').catch((err) => {\n process.stderr.write(\n `agent-runtime-mcp: failed to load @tangle-network/sandbox (${err.message}); install the peer dependency\\n`,\n )\n process.exit(2)\n })\n const SandboxCtor = (mod as { Sandbox?: new (config: unknown) => SandboxClient }).Sandbox\n if (!SandboxCtor) {\n process.stderr.write(\n 'agent-runtime-mcp: @tangle-network/sandbox does not export Sandbox; cannot construct client\\n',\n )\n process.exit(2)\n }\n // @tangle-network/sandbox ≥0.6 makes baseUrl required; default it so the MCP server\n // starts without forcing every caller to set SANDBOX_BASE_URL. Treat empty/whitespace as\n // unset (|| not ??) so `SANDBOX_BASE_URL=` still resolves to the default.\n const baseUrl = process.env.SANDBOX_BASE_URL?.trim() || DEFAULT_SANDBOX_BASE_URL\n return new SandboxCtor({ apiKey, baseUrl })\n}\n\nmain().catch((err) => {\n process.stderr.write(`agent-runtime-mcp: ${err instanceof Error ? err.stack : String(err)}\\n`)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,IAAM,2BAA2B;AACjC,IAAM,yBAAyB;AAE/B,SAAS,QAAQ,OAA+C;AAC9D,QAAM,IAAI,OAAO,KAAK;AACtB,SAAO,IAAI,IAAI;AACjB;AAIO,SAAS,gBAAgB,MAAyB,QAAQ,KAAc;AAC7E,SAAO,IAAI,wBAAwB;AACrC;AAIA,SAAS,cAAc,KAAsC;AAC3D,QAAM,YAAY,QAAQ,IAAI,yBAAyB,KAAK,QAAQ,IAAI,cAAc,KAAK;AAC3F,QAAM,OAAO,QAAQ,IAAI,8BAA8B,KAAK,qBAAqB,GAAgB;AACjG,QAAM,gBAAgB,aAAa,KAAK,IAAI,IACxC,KAAK,QAAQ,OAAO,EAAE,IACtB,GAAG,KAAK,QAAQ,OAAO,EAAE,CAAC;AAC9B,QAAM,QACJ,QAAQ,IAAI,oBAAoB,KAChC,QAAQ,IAAI,gBAAgB,KAC5B,QAAQ,IAAI,YAAY,KACxB;AACF,SAAO,EAAE,eAAe,WAAW,MAAM;AAC3C;AAQO,SAAS,0BACd,eACA,MAAyB,QAAQ,KACG;AACpC,MAAI,CAAC,gBAAgB,GAAG,EAAG,QAAO;AAClC,QAAM,SAAS,cAAc,GAAG;AAChC,QAAM,UAAW,QAAQ,IAAI,2BAA2B,KACtD;AACF,QAAM,UAA0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QAAM,cAAe,IAA6D;AAClF,MAAI,CAAC,aAAa;AAChB,YAAQ,OAAO;AAAA,MACb;AAAA,IACF;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAIA,QAAM,UAAU,QAAQ,IAAI,kBAAkB,KAAK,KAAK;AACxD,SAAO,IAAI,YAAY,EAAE,QAAQ,QAAQ,CAAC;AAC5C;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,OAAO,MAAM,sBAAsB,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG,CAAC;AAAA,CAAI;AAC7F,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/delegate-supervisor-provisioning.ts","../../src/mcp/bin.ts"],"sourcesContent":["/**\n * @experimental\n *\n * Resolve the `delegate` supervisor substrate (router brain + worker backend) from env, so the\n * `agent-runtime-mcp` bin can serve the ONE generic `delegate` verb by env, over the SAME stdio\n * invocation a consumer already mounts.\n *\n * `delegate` is wired into `createMcpServer` via `McpServerOptions.delegateSupervisor`, which needs a\n * router (the supervisor brain's substrate) and a backend (WHERE the authored workers run). Inside a\n * sandbox child the natural backend is `sandbox`: authored workers run as sub-sandboxes through the\n * SAME `SandboxClient` the bin already loads from `TANGLE_API_KEY`. The brain's router reuses the\n * repo's `resolveRouterBaseUrl` convention\n * (`TANGLE_ROUTER_URL` / `TANGLE_ROUTER_BASE_URL`), normalised to an OpenAI-compatible `/v1` endpoint,\n * keyed by `TANGLE_API_KEY`.\n */\n\nimport type { BackendType } from '@tangle-network/sandbox'\nimport { type RouterEnv, resolveRouterBaseUrl } from '../model-resolution.js'\nimport type { SandboxClient } from '../runtime'\nimport type { RouterConfig } from '../runtime/router-client'\nimport type { ExecutorConfig } from '../runtime/supervise/runtime'\nimport type { DelegateHandlerOptions } from './tools/delegate'\n\nconst DEFAULT_SUPERVISOR_MODEL = 'moonshotai/kimi-k2.6'\nconst DEFAULT_WORKER_HARNESS = 'opencode'\n\nfunction trimmed(value: string | undefined): string | undefined {\n const v = value?.trim()\n return v ? v : undefined\n}\n\n/** True when the operator opted the generic `delegate` verb in (`MCP_ENABLE_DELEGATE=1`). Default off:\n * the wiring is additive, so consumers that do not enable it are unaffected. */\nexport function delegateEnabled(env: NodeJS.ProcessEnv = process.env): boolean {\n return env.MCP_ENABLE_DELEGATE === '1'\n}\n\n/** Resolve the supervisor brain's router substrate from env. The key falls back through the platform\n * key the bin already requires; the base reuses `resolveRouterBaseUrl`, normalised to `/v1`. */\nfunction resolveRouter(env: NodeJS.ProcessEnv): RouterConfig {\n const routerKey = trimmed(env.MCP_SUPERVISOR_ROUTER_KEY) ?? trimmed(env.TANGLE_API_KEY) ?? ''\n const base = trimmed(env.MCP_SUPERVISOR_ROUTER_BASE_URL) ?? resolveRouterBaseUrl(env as RouterEnv)\n const routerBaseUrl = /\\/v\\d+\\/?$/.test(base)\n ? base.replace(/\\/$/, '')\n : `${base.replace(/\\/$/, '')}/v1`\n const model =\n trimmed(env.MCP_SUPERVISOR_MODEL) ??\n trimmed(env.MCP_WORKER_MODEL) ??\n trimmed(env.WORKER_MODEL) ??\n DEFAULT_SUPERVISOR_MODEL\n return { routerBaseUrl, routerKey, model }\n}\n\n/**\n * Build the `delegateSupervisor` substrate for `createMcpServer` from env + the bin's loaded\n * `SandboxClient`. Returns `undefined` when `delegate` is not opted in, so the caller mounts it only\n * when asked. The worker backend is `sandbox` (authored workers run as sub-sandboxes via the same\n * client) on the harness named by `MCP_DELEGATE_WORKER_HARNESS` (default `opencode`).\n */\nexport function resolveDelegateSupervisor(\n sandboxClient: SandboxClient,\n env: NodeJS.ProcessEnv = process.env,\n): DelegateHandlerOptions | undefined {\n if (!delegateEnabled(env)) return undefined\n const router = resolveRouter(env)\n const harness = (trimmed(env.MCP_DELEGATE_WORKER_HARNESS) ??\n DEFAULT_WORKER_HARNESS) as BackendType\n const backend: ExecutorConfig = {\n backend: 'sandbox',\n harness,\n sandboxClient,\n }\n return {\n router,\n backend,\n model: router.model,\n }\n}\n","#!/usr/bin/env node\n\n/**\n * @experimental\n *\n * `agent-runtime-mcp` — stdio MCP server entry point.\n *\n * Serves the ONE generic `delegate` verb (opt-in via `MCP_ENABLE_DELEGATE=1`): one intent → a\n * supervisor that authors + drives its own worker over `supervise()`, returning the delivered output\n * with its cost. The supervisor brain runs on the router; authored workers run as sub-sandboxes\n * through the same `SandboxClient` the bin loads from `TANGLE_API_KEY`. The queue-bound tools\n * (`delegate_feedback`, `delegation_status`, `delegation_history`) are always served.\n *\n * Environment variables:\n * TANGLE_API_KEY required — passed to `new Sandbox({ apiKey })`\n * SANDBOX_BASE_URL optional — sandbox-SDK base URL override\n * MCP_ENABLE_DELEGATE set to `1` to serve the generic `delegate` verb. Its authoring\n * supervisor runs the brain on the router and spawns authored\n * workers as sub-sandboxes via the same client; needs TANGLE_API_KEY.\n * MCP_SUPERVISOR_MODEL supervisor brain model id (falls back to MCP_WORKER_MODEL, then\n * WORKER_MODEL, then a default). Must be a tool-calling model.\n * MCP_SUPERVISOR_ROUTER_KEY router key for the supervisor brain (defaults to TANGLE_API_KEY)\n * MCP_SUPERVISOR_ROUTER_BASE_URL router base for the supervisor brain (defaults to the repo's\n * resolveRouterBaseUrl, normalized to `/v1`)\n * MCP_DELEGATE_WORKER_HARNESS harness the authored workers run on (default `opencode`)\n * AGENT_RUNTIME_DELEGATION_STATE_FILE\n * optional — absolute path of a JSON state\n * file. When set, delegation records persist\n * across MCP restarts (FileDelegationStore):\n * status/history survive and idempotency keys\n * dedupe across processes.\n * AGENT_RUNTIME_DELEGATION_STATE_RECOVER\n * set to `1` to archive a corrupt state file\n * (`<file>.corrupt-<ts>`) and start empty\n * instead of refusing to boot.\n * AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL\n * optional — positive integer cap on retained\n * terminal records. Unset = keep forever.\n */\n\nimport type { SandboxClient } from '../runtime'\nimport { delegateEnabled, resolveDelegateSupervisor } from './delegate-supervisor-provisioning'\nimport { FileDelegationStore } from './delegation-store'\nimport { createMcpServer } from './server'\nimport { DelegationTaskQueue } from './task-queue'\nimport { readTraceContextFromEnv, type TraceContext } from './trace-propagation'\n\nconst DEFAULT_SANDBOX_BASE_URL = 'https://sandbox.tangle.tools'\n\nasync function main(): Promise<void> {\n const wantDelegate = delegateEnabled(process.env)\n\n // The generic `delegate` verb needs the sandbox client: its authored workers run as sub-sandboxes\n // (the `sandbox` backend). When `delegate` is not opted in, the server runs the queue-only subset\n // (feedback + status + history) with no sandbox.\n let sandboxClient: SandboxClient | undefined\n if (wantDelegate) {\n const apiKey = process.env.TANGLE_API_KEY\n if (!apiKey && !process.env.AGENT_RUNTIME_MCP_ALLOW_NO_KEY) {\n process.stderr.write(\n 'agent-runtime-mcp: TANGLE_API_KEY is required to serve `delegate`. Set AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 to run without it for diagnostics, or unset MCP_ENABLE_DELEGATE to run the queue-only subset.\\n',\n )\n process.exit(2)\n }\n sandboxClient = await loadSandboxClient(apiKey)\n }\n\n // The supervisor's loop topology spans export to the OTLP / Tangle Intelligence sink when\n // OTEL_EXPORTER_OTLP_ENDPOINT is set (+ TRACE_ID / PARENT_SPAN_ID for correlation). The same\n // context is stamped onto every delegation record so journal consumers join records into the\n // caller's trace.\n const traceContext = readTraceContextFromEnv()\n if (process.env.OTEL_EXPORTER_OTLP_ENDPOINT) {\n process.stderr.write(\n `agent-runtime-mcp: exporting loop topology → ${process.env.OTEL_EXPORTER_OTLP_ENDPOINT}\\n`,\n )\n }\n\n // The ONE generic `delegate` verb — opt-in via MCP_ENABLE_DELEGATE=1. Its authoring supervisor\n // runs the brain on the router and spawns authored workers as sub-sandboxes through the SAME\n // client, so it needs the loaded `sandboxClient`. Gated on the client resolving (no key → no\n // delegate, fail-closed).\n const delegateSupervisor =\n wantDelegate && sandboxClient ? resolveDelegateSupervisor(sandboxClient) : undefined\n if (wantDelegate && delegateSupervisor) {\n process.stderr.write('agent-runtime-mcp: delegate enabled — generic authoring supervisor\\n')\n }\n\n const durableQueue = await buildDurableQueueFromEnv(traceContext)\n const server = createMcpServer({\n ...(delegateSupervisor ? { delegateSupervisor } : {}),\n traceContext,\n ...(durableQueue ? { queue: durableQueue } : {}),\n })\n\n const shutdown = () => {\n server.stop()\n // Drain journal writes so the state file reflects the final record\n // states before the process exits. A persist failure already routed\n // through onPersistError; swallow the duplicate rejection here.\n if (durableQueue) {\n void durableQueue\n .flush()\n .catch(() => {})\n .finally(() => process.exit(0))\n return\n }\n process.exit(0)\n }\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n\n await server.serve()\n}\n\nasync function buildDurableQueueFromEnv(\n traceContext: TraceContext,\n): Promise<DelegationTaskQueue | undefined> {\n const stateFile = process.env.AGENT_RUNTIME_DELEGATION_STATE_FILE?.trim()\n if (!stateFile) return undefined\n const store = new FileDelegationStore({\n filePath: stateFile,\n recoverCorrupt: process.env.AGENT_RUNTIME_DELEGATION_STATE_RECOVER === '1',\n })\n const maxTerminalRecords = parseRetention(process.env.AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL)\n const queue = await DelegationTaskQueue.restore({\n store,\n traceContext,\n ...(maxTerminalRecords !== undefined ? { maxTerminalRecords } : {}),\n onPersistError: (error) => {\n // Durable mode that can no longer write is a broken contract: crash\n // loud instead of degrading to memory-only behind the caller's back.\n process.stderr.write(`agent-runtime-mcp: ${error.message}\\n`)\n process.exit(1)\n },\n })\n process.stderr.write(`agent-runtime-mcp: durable delegation state → ${stateFile}\\n`)\n return queue\n}\n\nfunction parseRetention(raw: string | undefined): number | undefined {\n if (raw === undefined || raw.trim() === '') return undefined\n const n = Number(raw)\n if (!Number.isInteger(n) || n < 1) {\n process.stderr.write(\n `agent-runtime-mcp: AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL must be a positive integer, got \"${raw}\"\\n`,\n )\n process.exit(2)\n }\n return n\n}\n\nasync function loadSandboxClient(apiKey: string | undefined): Promise<SandboxClient> {\n // Diagnostic mode: AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 enables tools/list + the\n // queue-bound tools (status / history / feedback) without sandbox creds.\n // `delegate` requires a real client; the stub fails loud at create() so the\n // agent observes the cause instead of silent success.\n if (!apiKey) {\n return {\n async create() {\n throw new Error(\n 'agent-runtime-mcp: TANGLE_API_KEY is unset; `delegate` is disabled in diagnostic mode. Set TANGLE_API_KEY or unset MCP_ENABLE_DELEGATE to remove the unsupported tool from the tool list.',\n )\n },\n } satisfies SandboxClient\n }\n // Dynamic import keeps the bin importable in environments that haven't\n // installed `@tangle-network/sandbox` yet (the runtime package lists it\n // as a peer dep, not a hard dep).\n const mod = await import('@tangle-network/sandbox').catch((err) => {\n process.stderr.write(\n `agent-runtime-mcp: failed to load @tangle-network/sandbox (${err.message}); install the peer dependency\\n`,\n )\n process.exit(2)\n })\n const SandboxCtor = (mod as { Sandbox?: new (config: unknown) => SandboxClient }).Sandbox\n if (!SandboxCtor) {\n process.stderr.write(\n 'agent-runtime-mcp: @tangle-network/sandbox does not export Sandbox; cannot construct client\\n',\n )\n process.exit(2)\n }\n // @tangle-network/sandbox ≥0.6 makes baseUrl required; default it so the MCP server\n // starts without forcing every caller to set SANDBOX_BASE_URL. Treat empty/whitespace as\n // unset (|| not ??) so `SANDBOX_BASE_URL=` still resolves to the default.\n const baseUrl = process.env.SANDBOX_BASE_URL?.trim() || DEFAULT_SANDBOX_BASE_URL\n return new SandboxCtor({ apiKey, baseUrl })\n}\n\nmain().catch((err) => {\n process.stderr.write(`agent-runtime-mcp: ${err instanceof Error ? err.stack : String(err)}\\n`)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,IAAM,2BAA2B;AACjC,IAAM,yBAAyB;AAE/B,SAAS,QAAQ,OAA+C;AAC9D,QAAM,IAAI,OAAO,KAAK;AACtB,SAAO,IAAI,IAAI;AACjB;AAIO,SAAS,gBAAgB,MAAyB,QAAQ,KAAc;AAC7E,SAAO,IAAI,wBAAwB;AACrC;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