@tangle-network/agent-runtime 0.79.0 → 0.79.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +3 -2
- package/dist/agent.js.map +1 -1
- package/dist/{chunk-GZX3PI7V.js → chunk-2DS6T46I.js} +3 -3
- package/dist/{chunk-N2JJDGLJ.js → chunk-75V2XXYJ.js} +8 -6
- package/dist/{chunk-N2JJDGLJ.js.map → chunk-75V2XXYJ.js.map} +1 -1
- package/dist/{chunk-F6G3SSHY.js → chunk-SONQUREI.js} +2 -2
- package/dist/{chunk-EZ2QESTP.js → chunk-TSDKBFZP.js} +34 -925
- package/dist/chunk-TSDKBFZP.js.map +1 -0
- package/dist/chunk-Z3RRRPRB.js +916 -0
- package/dist/chunk-Z3RRRPRB.js.map +1 -0
- package/dist/{coordination-09JTQnlF.d.ts → coordination-BoEPhGas.d.ts} +7 -62
- package/dist/environment-provider.d.ts +66 -0
- package/dist/environment-provider.js +16 -0
- package/dist/environment-provider.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/{loop-runner-bin-Ddgf4DkS.d.ts → loop-runner-bin-DCr5OMe5.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +4 -3
- package/dist/loop-runner-bin.js +4 -3
- package/dist/loops.d.ts +9 -6
- package/dist/loops.js +9 -7
- package/dist/mcp/bin.js +2 -1
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +6 -4
- package/dist/mcp/index.js +9 -7
- package/dist/mcp/index.js.map +1 -1
- package/dist/{worktree-CUn0d-ZT.d.ts → types-C1sozrte.d.ts} +1 -123
- package/dist/worktree-CpptK3oF.d.ts +125 -0
- package/dist/{worktree-fanout-DwwatTdY.d.ts → worktree-fanout-CtQrRDME.d.ts} +2 -1
- package/package.json +6 -1
- package/dist/chunk-EZ2QESTP.js.map +0 -1
- /package/dist/{chunk-GZX3PI7V.js.map → chunk-2DS6T46I.js.map} +0 -0
- /package/dist/{chunk-F6G3SSHY.js.map → chunk-SONQUREI.js.map} +0 -0
|
@@ -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 './
|
|
6
|
-
import { A as AuthoredHarness, W as WinnerStrategy, a as WorktreeFanoutOptions, b as WorktreePatchArtifact } from './worktree-fanout-
|
|
5
|
+
import { B as Budget } from './types-C1sozrte.js';
|
|
6
|
+
import { A as AuthoredHarness, W as WinnerStrategy, a as WorktreeFanoutOptions, b as WorktreePatchArtifact } from './worktree-fanout-CtQrRDME.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @experimental
|
|
@@ -1,14 +1,15 @@
|
|
|
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-DCr5OMe5.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 './
|
|
8
|
+
import './types-C1sozrte.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-
|
|
12
|
+
import './worktree-fanout-CtQrRDME.js';
|
|
13
|
+
import './worktree-CpptK3oF.js';
|
|
13
14
|
import './local-harness-DU7yV6mG.js';
|
|
14
15
|
import 'node:child_process';
|
package/dist/loop-runner-bin.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
parseLoopRunnerArgv,
|
|
4
4
|
runLoopRunnerCli
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2DS6T46I.js";
|
|
6
6
|
import "./chunk-FNMGYYSS.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-75V2XXYJ.js";
|
|
8
|
+
import "./chunk-TSDKBFZP.js";
|
|
9
9
|
import "./chunk-VMNEQHJR.js";
|
|
10
|
+
import "./chunk-Z3RRRPRB.js";
|
|
10
11
|
import "./chunk-IODKUOBA.js";
|
|
11
12
|
import "./chunk-T2HVQVB4.js";
|
|
12
13
|
import "./chunk-5JAUQZQA.js";
|
package/dist/loops.d.ts
CHANGED
|
@@ -2,19 +2,22 @@ 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 {
|
|
6
|
-
export { A as AgentSpec,
|
|
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 { d as ResultBlobStore, S as SpawnJournal, N as NodeId, j as SpawnEvent, E as ExecutorFactory, c as Agent, B as Budget, i as Scope, g as Settled, f as SupervisedResult, h as Spend, U as UsageEvent, b as ExecutorRegistry, k as Supervisor } from './types-C1sozrte.js';
|
|
6
|
+
export { A as AgentSpec, a as Executor, l as ExecutorContext, m as ExecutorResult, n as SupervisorOpts, T as TreeView, W as WidenGate } from './types-C1sozrte.js';
|
|
7
|
+
import { ak as MakeWorkerAgent, o as CoordinationTools, A as AnalystRegistry, n as CoordinationEvent, ar as QuestionPolicy, a$ as ExecutorConfig } from './coordination-BoEPhGas.js';
|
|
8
|
+
export { b0 as BusEvent, b1 as BusRecord, b2 as BusStats, b3 as EventBus, b4 as ProviderSeam, b5 as PublishOptions, b6 as cliWorktreeExecutor, b7 as createEventBus, b8 as createExecutor, b9 as createExecutorRegistry } from './coordination-BoEPhGas.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
|
-
|
|
12
|
-
|
|
11
|
+
export { AgentEnvironmentProviderRef, AgentEnvironmentProviderRegistry, ProviderAsSandboxClientOptions, ProviderExecutorOptions, SandboxClientProviderOptions, createAgentEnvironmentProviderRegistry, providerAsExecutor, providerAsSandboxClient, resolveAgentEnvironmentProvider, sandboxClientAsProvider } from './environment-provider.js';
|
|
12
|
+
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-CtQrRDME.js';
|
|
13
|
+
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-CtQrRDME.js';
|
|
13
14
|
import { Scenario, ProfileDispatchFn } from '@tangle-network/agent-eval/campaign';
|
|
14
15
|
import { b as AnalystRegistryLike } from './types-BC3bZpH0.js';
|
|
15
16
|
import { AgentProfile as AgentProfile$1 } from '@tangle-network/agent-interface';
|
|
16
17
|
import { R as RouterConfig, a as ToolLoopChat } from './router-client-CMAWGv1h.js';
|
|
17
18
|
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';
|
|
19
|
+
import { d as DeliverableSpec } from './worktree-CpptK3oF.js';
|
|
20
|
+
export { g as gateOnDeliverable } from './worktree-CpptK3oF.js';
|
|
18
21
|
import { stuckLoopView, toolWasteView } from '@tangle-network/agent-eval/pipelines';
|
|
19
22
|
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';
|
|
20
23
|
import './substrate-rNj6TDc3.js';
|
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-75V2XXYJ.js";
|
|
80
80
|
import {
|
|
81
81
|
InMemoryResultBlobStore,
|
|
82
82
|
InMemorySpawnJournal,
|
|
@@ -87,7 +87,6 @@ import {
|
|
|
87
87
|
authoredWorker,
|
|
88
88
|
cliWorktreeExecutor,
|
|
89
89
|
contentAddress,
|
|
90
|
-
createAgentEnvironmentProviderRegistry,
|
|
91
90
|
createBudgetPool,
|
|
92
91
|
createEventBus,
|
|
93
92
|
createExecutor,
|
|
@@ -107,15 +106,11 @@ import {
|
|
|
107
106
|
gateOnDeliverable,
|
|
108
107
|
probeSandboxCapabilities,
|
|
109
108
|
profileRichnessFinding,
|
|
110
|
-
providerAsExecutor,
|
|
111
|
-
providerAsSandboxClient,
|
|
112
|
-
resolveAgentEnvironmentProvider,
|
|
113
109
|
routerBrain,
|
|
114
110
|
routerChatWithTools,
|
|
115
111
|
routerChatWithUsage,
|
|
116
112
|
routerToolLoop,
|
|
117
113
|
runLoop,
|
|
118
|
-
sandboxClientAsProvider,
|
|
119
114
|
serveCoordinationMcp,
|
|
120
115
|
settledToIteration,
|
|
121
116
|
spendFromUsageEvents,
|
|
@@ -123,8 +118,15 @@ import {
|
|
|
123
118
|
supervisorAgent,
|
|
124
119
|
supervisorInstructions,
|
|
125
120
|
workerFromBackend
|
|
126
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-TSDKBFZP.js";
|
|
127
122
|
import "./chunk-VMNEQHJR.js";
|
|
123
|
+
import {
|
|
124
|
+
createAgentEnvironmentProviderRegistry,
|
|
125
|
+
providerAsExecutor,
|
|
126
|
+
providerAsSandboxClient,
|
|
127
|
+
resolveAgentEnvironmentProvider,
|
|
128
|
+
sandboxClientAsProvider
|
|
129
|
+
} from "./chunk-Z3RRRPRB.js";
|
|
128
130
|
import {
|
|
129
131
|
extractLlmCallEvent,
|
|
130
132
|
mapSandboxEvent
|
package/dist/mcp/bin.js
CHANGED
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
DelegationTaskQueue,
|
|
10
10
|
FileDelegationStore,
|
|
11
11
|
createMcpServer
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-TSDKBFZP.js";
|
|
13
13
|
import "../chunk-VMNEQHJR.js";
|
|
14
|
+
import "../chunk-Z3RRRPRB.js";
|
|
14
15
|
import "../chunk-T2HVQVB4.js";
|
|
15
16
|
import "../chunk-5JAUQZQA.js";
|
|
16
17
|
import "../chunk-NBV35BR6.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 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;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,UAA0B;AAAA,IAC9B,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,OAAO,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AAC;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;AAIA,SAAS,cAAc,KAAsC;AAC3D,QAAM,YAAY,QAAQ,IAAI,yBAAyB,KAAK,QAAQ,IAAI,cAAc,KAAK;AAC3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C,OAAO,UAAU,CAAC,KAAK,IAAI,GAAG;AACjC,YAAQ,OAAO;AAAA,MACb,gGAAgG,GAAG;AAAA;AAAA,IACrG;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAEA,eAAe,kBAAkB,QAAoD;AAKnF,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,MACL,MAAM,SAAS;AACb,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAIA,QAAM,MAAM,MAAM,OAAO,yBAAyB,EAAE,MAAM,CAAC,QAAQ;AACjE,YAAQ,OAAO;AAAA,MACb,8DAA8D,IAAI,OAAO;AAAA;AAAA,IAC3E;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACD,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":[]}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { S as SandboxClient, d as LoopSandboxPlacement } from '../types-BF-MEsQB.js';
|
|
2
|
-
import { F as FleetHandle, D as DelegationExecutor, a as DelegationTaskQueue, b as FeedbackStore, c as DelegateFeedbackResult, d as DelegateFeedbackArgs, U as UiAuditorDelegate, e as DelegateUiAuditArgs, f as DelegateUiAuditResult, g as DelegationHistoryResult, h as DelegationHistoryArgs, i as DelegationStatusResult, j as DelegationStatusArgs } from '../coordination-
|
|
3
|
-
export { A as AnalystRegistry, C as CappedDelegationTrace, k as CoderDelegate, l as CoderReview, m as CoderReviewer, n as CoordinationEvent, o as CoordinationTools, p as CoordinationToolsOptions, q as DELEGATE_DESCRIPTION, r as DELEGATE_INPUT_SCHEMA, s as DELEGATE_TOOL_NAME, t as DELEGATION_TRACE_MAX_BYTES, u as DELEGATION_TRACE_MAX_SPANS, v as DelegateArgs, w as DelegateCodeArgs, x as DelegateCodeConfig, y as DelegateCodeResult, z as DelegateHandlerOptions, B as DelegateResearchArgs, E as DelegateResearchConfig, G as DelegateResearchResult, H as DelegateResult, I as DelegateRunCtx, J as DelegateUiAuditConfig, K as DelegateUiAuditRoute, L as DelegationError, M as DelegationFeedbackSnapshot, N as DelegationHistoryEntry, O as DelegationPersistenceError, P as DelegationProfile, Q as DelegationProgress, R as DelegationRecord, S as DelegationResultPayload, T as DelegationResumeContext, V as DelegationResumeDriver, W as DelegationResumeTick, X as DelegationRunContext, Y as DelegationStateCorruptError, Z as DelegationStatus, _ as DelegationStore, $ as DelegationTaskQueueOptions, a0 as DelegationTraceCaps, a1 as DelegationTraceCollector, a2 as DelegationTraceSpan, a3 as DetachedSessionDelegateOptions, a4 as DetachedSessionRefParts, a5 as DetachedTurn, a6 as DetachedTurnResumeDriverOptions, a7 as DetachedWinnerSelection, a8 as DriveTurnCapableBox, a9 as DriveTurnTick, aa as FeedbackEvent, ab as FeedbackRating, ac as FeedbackRefersTo, ad as FileDelegationStore, ae as FileDelegationStoreOptions, af as FleetWorkspaceExecutorOptions, ag as InMemoryDelegationStore, ah as InMemoryFeedbackStore, ai as JsonRpcMessage, aj as JsonRpcResponse, ak as MakeWorkerAgent, al as McpServer, am as McpServerOptions, an as McpToolDescriptor, ao as McpTransport, ap as Question, aq as QuestionDecision, ar as QuestionPolicy, as as QuestionRecord, at as ResearchOutputShape, au as ResearchSource, av as RunDetachedTurnOptions, aw as SettleDetachedCoderTurnOptions, ax as SettledWorker, ay as SiblingSandboxExecutorOptions, az as SubmitInput, aA as SubmitOutput, aB as TraceContext, aC as UiAuditorDelegationOutput, aD as buildDelegationTraceSpans, aE as capDelegationTrace, aF as coderTaskFromArgs, aG as composeLoopTraceEmitters, aH as createCoordinationTools, aI as createDelegateHandler, aJ as createDelegationTraceCollector, aK as createDetachedTurnResumeDriver, aL as createFleetWorkspaceExecutor, aM as createInProcessTransport, aN as createMcpServer, aO as createPropagatingTraceEmitter, aP as createSiblingSandboxExecutor, aQ as detachedSessionDelegate, aR as detachedTurnEvents, aS as eventToSnapshot, aT as formatDetachedSessionRef, aU as hashIdempotencyInput, aV as parseDetachedSessionRef, aW as readTraceContextFromEnv, aX as runDetachedTurn, aY as settleDetachedCoderTurn, aZ as traceContextToEnv, a_ as validateDelegateArgs } from '../coordination-
|
|
2
|
+
import { F as FleetHandle, D as DelegationExecutor, a as DelegationTaskQueue, b as FeedbackStore, c as DelegateFeedbackResult, d as DelegateFeedbackArgs, U as UiAuditorDelegate, e as DelegateUiAuditArgs, f as DelegateUiAuditResult, g as DelegationHistoryResult, h as DelegationHistoryArgs, i as DelegationStatusResult, j as DelegationStatusArgs } from '../coordination-BoEPhGas.js';
|
|
3
|
+
export { A as AnalystRegistry, C as CappedDelegationTrace, k as CoderDelegate, l as CoderReview, m as CoderReviewer, n as CoordinationEvent, o as CoordinationTools, p as CoordinationToolsOptions, q as DELEGATE_DESCRIPTION, r as DELEGATE_INPUT_SCHEMA, s as DELEGATE_TOOL_NAME, t as DELEGATION_TRACE_MAX_BYTES, u as DELEGATION_TRACE_MAX_SPANS, v as DelegateArgs, w as DelegateCodeArgs, x as DelegateCodeConfig, y as DelegateCodeResult, z as DelegateHandlerOptions, B as DelegateResearchArgs, E as DelegateResearchConfig, G as DelegateResearchResult, H as DelegateResult, I as DelegateRunCtx, J as DelegateUiAuditConfig, K as DelegateUiAuditRoute, L as DelegationError, M as DelegationFeedbackSnapshot, N as DelegationHistoryEntry, O as DelegationPersistenceError, P as DelegationProfile, Q as DelegationProgress, R as DelegationRecord, S as DelegationResultPayload, T as DelegationResumeContext, V as DelegationResumeDriver, W as DelegationResumeTick, X as DelegationRunContext, Y as DelegationStateCorruptError, Z as DelegationStatus, _ as DelegationStore, $ as DelegationTaskQueueOptions, a0 as DelegationTraceCaps, a1 as DelegationTraceCollector, a2 as DelegationTraceSpan, a3 as DetachedSessionDelegateOptions, a4 as DetachedSessionRefParts, a5 as DetachedTurn, a6 as DetachedTurnResumeDriverOptions, a7 as DetachedWinnerSelection, a8 as DriveTurnCapableBox, a9 as DriveTurnTick, aa as FeedbackEvent, ab as FeedbackRating, ac as FeedbackRefersTo, ad as FileDelegationStore, ae as FileDelegationStoreOptions, af as FleetWorkspaceExecutorOptions, ag as InMemoryDelegationStore, ah as InMemoryFeedbackStore, ai as JsonRpcMessage, aj as JsonRpcResponse, ak as MakeWorkerAgent, al as McpServer, am as McpServerOptions, an as McpToolDescriptor, ao as McpTransport, ap as Question, aq as QuestionDecision, ar as QuestionPolicy, as as QuestionRecord, at as ResearchOutputShape, au as ResearchSource, av as RunDetachedTurnOptions, aw as SettleDetachedCoderTurnOptions, ax as SettledWorker, ay as SiblingSandboxExecutorOptions, az as SubmitInput, aA as SubmitOutput, aB as TraceContext, aC as UiAuditorDelegationOutput, aD as buildDelegationTraceSpans, aE as capDelegationTrace, aF as coderTaskFromArgs, aG as composeLoopTraceEmitters, aH as createCoordinationTools, aI as createDelegateHandler, aJ as createDelegationTraceCollector, aK as createDetachedTurnResumeDriver, aL as createFleetWorkspaceExecutor, aM as createInProcessTransport, aN as createMcpServer, aO as createPropagatingTraceEmitter, aP as createSiblingSandboxExecutor, aQ as detachedSessionDelegate, aR as detachedTurnEvents, aS as eventToSnapshot, aT as formatDetachedSessionRef, aU as hashIdempotencyInput, aV as parseDetachedSessionRef, aW as readTraceContextFromEnv, aX as runDetachedTurn, aY as settleDetachedCoderTurn, aZ as traceContextToEnv, a_ as validateDelegateArgs } from '../coordination-BoEPhGas.js';
|
|
4
4
|
import { L as LocalHarness, r as runLocalHarness } from '../local-harness-DU7yV6mG.js';
|
|
5
5
|
export { a as LocalHarnessResult, R as RunLocalHarnessOptions } from '../local-harness-DU7yV6mG.js';
|
|
6
|
-
import { G as GitRunner } from '../worktree-
|
|
7
|
-
export { C as CreateWorktreeOptions, D as DiffOptions, a as DiffResult, R as RemoveWorktreeOptions, W as WorktreeHandle, c as captureWorktreeDiff, b as createWorktree, r as removeWorktree } from '../worktree-
|
|
6
|
+
import { G as GitRunner } from '../worktree-CpptK3oF.js';
|
|
7
|
+
export { C as CreateWorktreeOptions, D as DiffOptions, a as DiffResult, R as RemoveWorktreeOptions, W as WorktreeHandle, c as captureWorktreeDiff, b as createWorktree, r as removeWorktree } from '../worktree-CpptK3oF.js';
|
|
8
8
|
export { C as CreateKbGateOptions, F as FactCandidate, a as FactJudge, b as FactJudgeVerdict, K as KbGateResult, c as createKbGate } from '../kb-gate-CuzMYGYM.js';
|
|
9
9
|
export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from '../openai-tools-B-3v06BE.js';
|
|
10
10
|
import { AnalystFinding } from '@tangle-network/agent-eval';
|
|
11
11
|
import { U as UiLens } from '../substrate-rNj6TDc3.js';
|
|
12
12
|
import '@tangle-network/sandbox';
|
|
13
|
+
import '../types-C1sozrte.js';
|
|
13
14
|
import '@tangle-network/agent-interface';
|
|
14
15
|
import '../otel-export-BKmNwiCb.js';
|
|
15
16
|
import '../router-client-CMAWGv1h.js';
|
|
17
|
+
import '../environment-provider.js';
|
|
16
18
|
import '@tangle-network/agent-interface/environment-provider';
|
|
17
19
|
import 'node:child_process';
|
|
18
20
|
|
package/dist/mcp/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
mcpToolsForRuntimeMcp,
|
|
8
8
|
mcpToolsForRuntimeMcpSubset
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-SONQUREI.js";
|
|
10
10
|
import {
|
|
11
11
|
createKbGate
|
|
12
12
|
} from "../chunk-FNMGYYSS.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
assertTraceDerivedFindings,
|
|
15
15
|
runCoderChecks,
|
|
16
16
|
selectValidWinner
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-75V2XXYJ.js";
|
|
18
18
|
import {
|
|
19
19
|
DELEGATE_DESCRIPTION,
|
|
20
20
|
DELEGATE_FEEDBACK_DESCRIPTION,
|
|
@@ -54,22 +54,24 @@ import {
|
|
|
54
54
|
createMcpServer,
|
|
55
55
|
createSandboxForSpec,
|
|
56
56
|
createWorktree,
|
|
57
|
-
deleteBoxSafe,
|
|
58
57
|
eventToSnapshot,
|
|
59
58
|
hashIdempotencyInput,
|
|
60
59
|
removeWorktree,
|
|
61
60
|
runLoop,
|
|
62
61
|
runWorktreeHarness,
|
|
63
|
-
sleep,
|
|
64
|
-
throwAbort,
|
|
65
|
-
throwIfAborted,
|
|
66
62
|
validateDelegateArgs,
|
|
67
63
|
validateDelegateFeedbackArgs,
|
|
68
64
|
validateDelegateUiAuditArgs,
|
|
69
65
|
validateDelegationHistoryArgs,
|
|
70
66
|
validateDelegationStatusArgs
|
|
71
|
-
} from "../chunk-
|
|
67
|
+
} from "../chunk-TSDKBFZP.js";
|
|
72
68
|
import "../chunk-VMNEQHJR.js";
|
|
69
|
+
import {
|
|
70
|
+
deleteBoxSafe,
|
|
71
|
+
sleep,
|
|
72
|
+
throwAbort,
|
|
73
|
+
throwIfAborted
|
|
74
|
+
} from "../chunk-Z3RRRPRB.js";
|
|
73
75
|
import "../chunk-T2HVQVB4.js";
|
|
74
76
|
import {
|
|
75
77
|
runLocalHarness
|