@tangle-network/agent-runtime 0.43.0 → 0.45.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/README.md +96 -202
- package/dist/agent.d.ts +5 -4
- package/dist/agent.js +5 -7
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +65 -4
- package/dist/analyst-loop.js +6 -1
- package/dist/audit.d.ts +93 -0
- package/dist/audit.js +312 -0
- package/dist/audit.js.map +1 -0
- package/dist/chunk-4B6U4CVQ.js +15 -0
- package/dist/chunk-4B6U4CVQ.js.map +1 -0
- package/dist/chunk-FK53TXOP.js +603 -0
- package/dist/chunk-FK53TXOP.js.map +1 -0
- package/dist/{chunk-MJDGCRAT.js → chunk-IJ6FGOPO.js} +5 -5
- package/dist/chunk-IJ6FGOPO.js.map +1 -0
- package/dist/{chunk-HVYOHJHK.js → chunk-IJGS6J7X.js} +2 -2
- package/dist/chunk-IJGS6J7X.js.map +1 -0
- package/dist/chunk-KEWO4KI6.js +3599 -0
- package/dist/chunk-KEWO4KI6.js.map +1 -0
- package/dist/{chunk-NRZOXCJK.js → chunk-KSMX62JF.js} +2 -2
- package/dist/{chunk-C5HMTTNY.js → chunk-NYN5RTLP.js} +13 -12
- package/dist/chunk-NYN5RTLP.js.map +1 -0
- package/dist/chunk-PRX45WE2.js +264 -0
- package/dist/chunk-PRX45WE2.js.map +1 -0
- package/dist/{chunk-3HMHSN22.js → chunk-QR4UUC5P.js} +6 -6
- package/dist/chunk-QR4UUC5P.js.map +1 -0
- package/dist/chunk-WIR4HOOJ.js +27 -0
- package/dist/chunk-WIR4HOOJ.js.map +1 -0
- package/dist/{chunk-MNCB4SJ5.js → chunk-Z2QXVBA6.js} +296 -8
- package/dist/chunk-Z2QXVBA6.js.map +1 -0
- package/dist/coder-CczgMqFx.d.ts +114 -0
- package/dist/dynamic-BvllHV6M.d.ts +221 -0
- package/dist/{improvement-adapter-BC4HhuAR.d.ts → improvement-adapter-CWegd3vw.d.ts} +1 -1
- package/dist/improvement.d.ts +2 -3
- package/dist/improvement.js +0 -5
- package/dist/improvement.js.map +1 -1
- package/dist/index.d.ts +123 -10
- package/dist/index.js +407 -19
- package/dist/index.js.map +1 -1
- package/dist/{kb-gate-DTBum3vH.d.ts → kb-gate-D9GBocLN.d.ts} +82 -5
- package/dist/{loop-runner-bin-CVoCBmYk.d.ts → loop-runner-bin-CPrCoKqC.d.ts} +14 -10
- package/dist/loop-runner-bin.d.ts +9 -7
- package/dist/loop-runner-bin.js +6 -8
- package/dist/loops.d.ts +7 -371
- package/dist/loops.js +96 -19
- package/dist/mcp/bin.js +7 -7
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +284 -11
- package/dist/mcp/index.js +341 -9
- package/dist/mcp/index.js.map +1 -1
- package/dist/{otel-export-BzvF1Ela.d.ts → otel-export-Dy2DyUCU.d.ts} +1 -1
- package/dist/profiles.d.ts +385 -86
- package/dist/profiles.js +549 -4
- package/dist/profiles.js.map +1 -1
- package/dist/run-loop--hSoIknW.d.ts +112 -0
- package/dist/runtime-hooks-C7JwKb9E.d.ts +70 -0
- package/dist/runtime.d.ts +1860 -0
- package/dist/runtime.js +114 -0
- package/dist/runtime.js.map +1 -0
- package/dist/substrate-CUgk7F7s.d.ts +77 -0
- package/dist/topology.d.ts +73 -0
- package/dist/topology.js +111 -0
- package/dist/topology.js.map +1 -0
- package/dist/types-1HbsFa7H.d.ts +438 -0
- package/dist/{types-p8dWBIXL.d.ts → types-BtRLF2U3.d.ts} +1 -1
- package/dist/{types-Bcp071Jg.d.ts → types-DdzkffAm.d.ts} +95 -1
- package/dist/workflow.d.ts +551 -0
- package/dist/workflow.js +1778 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +53 -16
- package/skills/agent-runtime-adoption/SKILL.md +29 -26
- package/dist/chunk-3HMHSN22.js.map +0 -1
- package/dist/chunk-C5HMTTNY.js.map +0 -1
- package/dist/chunk-EKBSQYZE.js +0 -813
- package/dist/chunk-EKBSQYZE.js.map +0 -1
- package/dist/chunk-HVYOHJHK.js.map +0 -1
- package/dist/chunk-MJDGCRAT.js.map +0 -1
- package/dist/chunk-MNCB4SJ5.js.map +0 -1
- package/dist/chunk-PY6NMZYX.js +0 -52
- package/dist/chunk-PY6NMZYX.js.map +0 -1
- package/dist/chunk-SQSCRJ7U.js +0 -65
- package/dist/chunk-SQSCRJ7U.js.map +0 -1
- package/dist/chunk-VOX6Z3II.js +0 -90
- package/dist/chunk-VOX6Z3II.js.map +0 -1
- package/dist/chunk-XBUG326M.js +0 -261
- package/dist/chunk-XBUG326M.js.map +0 -1
- package/dist/dynamic-B_7GgCwu.d.ts +0 -108
- package/dist/optimize-prompt-D-urF2wW.d.ts +0 -129
- /package/dist/{chunk-NRZOXCJK.js.map → chunk-KSMX62JF.js.map} +0 -0
package/dist/loops.js
CHANGED
|
@@ -1,37 +1,114 @@
|
|
|
1
1
|
import {
|
|
2
|
+
FileCorpus,
|
|
3
|
+
FileResultBlobStore,
|
|
4
|
+
FileSpawnJournal,
|
|
5
|
+
InMemoryCorpus,
|
|
6
|
+
InMemoryResultBlobStore,
|
|
7
|
+
InMemorySpawnJournal,
|
|
8
|
+
acquireSandbox,
|
|
9
|
+
assertTraceDerivedFindings,
|
|
10
|
+
buildSteerContext,
|
|
11
|
+
builtinShapes,
|
|
12
|
+
cliExecutor,
|
|
13
|
+
completionAuthorizes,
|
|
14
|
+
contentAddress,
|
|
15
|
+
createBudgetPool,
|
|
2
16
|
createDynamicDriver,
|
|
3
|
-
|
|
17
|
+
createExecutorRegistry,
|
|
18
|
+
createRootHandle,
|
|
4
19
|
createSandboxForSpec,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
20
|
+
createSandboxLineage,
|
|
21
|
+
createScope,
|
|
22
|
+
createScopeAnalyst,
|
|
23
|
+
createShapeRegistry,
|
|
24
|
+
createSupervisor,
|
|
25
|
+
defaultSelectWinner,
|
|
26
|
+
definePersona,
|
|
27
|
+
deterministicCompletion,
|
|
28
|
+
equalKOnCost,
|
|
29
|
+
fanout,
|
|
30
|
+
flatWidenGate,
|
|
8
31
|
loopDispatch,
|
|
9
|
-
|
|
10
|
-
|
|
32
|
+
loopUntil,
|
|
33
|
+
materializeTreeView,
|
|
34
|
+
panel,
|
|
35
|
+
pipeline,
|
|
36
|
+
probeSandboxCapabilities,
|
|
37
|
+
registerShape,
|
|
38
|
+
renderAnalyses,
|
|
39
|
+
renderCorpusToInstructions,
|
|
40
|
+
replaySpawnTree,
|
|
11
41
|
reportLoopUsage,
|
|
42
|
+
routerInlineExecutor,
|
|
12
43
|
runLoop,
|
|
13
|
-
|
|
14
|
-
|
|
44
|
+
runPersonified,
|
|
45
|
+
sandboxExecutor,
|
|
46
|
+
sentinelCompletion,
|
|
47
|
+
settledToIteration,
|
|
48
|
+
spendFromUsageEvents,
|
|
49
|
+
stopSentinel,
|
|
50
|
+
trajectoryReport,
|
|
51
|
+
verify,
|
|
52
|
+
widen
|
|
53
|
+
} from "./chunk-KEWO4KI6.js";
|
|
15
54
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-SQSCRJ7U.js";
|
|
55
|
+
extractLlmCallEvent,
|
|
56
|
+
mapSandboxEvent
|
|
57
|
+
} from "./chunk-PRX45WE2.js";
|
|
20
58
|
import "./chunk-DGUM43GV.js";
|
|
21
59
|
export {
|
|
60
|
+
FileCorpus,
|
|
61
|
+
FileResultBlobStore,
|
|
62
|
+
FileSpawnJournal,
|
|
63
|
+
InMemoryCorpus,
|
|
64
|
+
InMemoryResultBlobStore,
|
|
65
|
+
InMemorySpawnJournal,
|
|
66
|
+
acquireSandbox,
|
|
67
|
+
assertTraceDerivedFindings,
|
|
68
|
+
buildSteerContext,
|
|
69
|
+
builtinShapes,
|
|
70
|
+
cliExecutor,
|
|
71
|
+
completionAuthorizes,
|
|
72
|
+
contentAddress,
|
|
73
|
+
createBudgetPool,
|
|
22
74
|
createDynamicDriver,
|
|
23
|
-
|
|
24
|
-
|
|
75
|
+
createExecutorRegistry,
|
|
76
|
+
createRootHandle,
|
|
25
77
|
createSandboxForSpec,
|
|
26
|
-
|
|
78
|
+
createSandboxLineage,
|
|
79
|
+
createScope,
|
|
80
|
+
createScopeAnalyst,
|
|
81
|
+
createShapeRegistry,
|
|
82
|
+
createSupervisor,
|
|
83
|
+
defaultSelectWinner,
|
|
84
|
+
definePersona,
|
|
85
|
+
deterministicCompletion,
|
|
86
|
+
equalKOnCost,
|
|
27
87
|
extractLlmCallEvent,
|
|
28
|
-
|
|
88
|
+
fanout,
|
|
89
|
+
flatWidenGate,
|
|
29
90
|
loopDispatch,
|
|
91
|
+
loopUntil,
|
|
30
92
|
mapSandboxEvent,
|
|
31
|
-
|
|
93
|
+
materializeTreeView,
|
|
94
|
+
panel,
|
|
95
|
+
pipeline,
|
|
96
|
+
probeSandboxCapabilities,
|
|
97
|
+
registerShape,
|
|
98
|
+
renderAnalyses,
|
|
99
|
+
renderCorpusToInstructions,
|
|
100
|
+
replaySpawnTree,
|
|
32
101
|
reportLoopUsage,
|
|
102
|
+
routerInlineExecutor,
|
|
33
103
|
runLoop,
|
|
34
|
-
|
|
35
|
-
|
|
104
|
+
runPersonified,
|
|
105
|
+
sandboxExecutor,
|
|
106
|
+
sentinelCompletion,
|
|
107
|
+
settledToIteration,
|
|
108
|
+
spendFromUsageEvents,
|
|
109
|
+
stopSentinel,
|
|
110
|
+
trajectoryReport,
|
|
111
|
+
verify,
|
|
112
|
+
widen
|
|
36
113
|
};
|
|
37
114
|
//# sourceMappingURL=loops.js.map
|
package/dist/mcp/bin.js
CHANGED
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
createPropagatingTraceEmitter,
|
|
5
5
|
detectExecutor,
|
|
6
6
|
readTraceContextFromEnv
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-Z2QXVBA6.js";
|
|
8
|
+
import "../chunk-WIR4HOOJ.js";
|
|
9
|
+
import "../chunk-IJGS6J7X.js";
|
|
9
10
|
import {
|
|
10
11
|
createDefaultCoderDelegate
|
|
11
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-IJ6FGOPO.js";
|
|
13
|
+
import "../chunk-QR4UUC5P.js";
|
|
12
14
|
import "../chunk-GLR25NG7.js";
|
|
13
15
|
import {
|
|
14
16
|
runLoop
|
|
15
|
-
} from "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-PY6NMZYX.js";
|
|
18
|
-
import "../chunk-SQSCRJ7U.js";
|
|
17
|
+
} from "../chunk-KEWO4KI6.js";
|
|
18
|
+
import "../chunk-PRX45WE2.js";
|
|
19
19
|
import "../chunk-DGUM43GV.js";
|
|
20
20
|
|
|
21
21
|
// src/mcp/bin.ts
|
package/dist/mcp/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * @experimental\n *\n * `agent-runtime-mcp` — stdio MCP server entry point.\n *\n * Spins up a server with the default coder delegate (wired against the\n * real `@tangle-network/sandbox` client) and, when the optional\n * `@tangle-network/agent-knowledge` peer is installed, a researcher\n * delegate against `multiHarnessResearcherFanout`.\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 * TANGLE_FLEET_ID optional — when set, delegations dispatch\n * INTO this fleet's shared workspace instead\n * of creating sibling sandboxes. Set by the\n * parent sandbox when launching this MCP\n * server so worker diffs land on the caller's\n * filesystem with no cross-sandbox boundary.\n * TANGLE_FLEET_EXCLUDE_MACHINES optional — comma-separated machine ids to\n * skip during fleet-mode round-robin\n * (typically the coordinator machine this\n * MCP server is running on).\n * MCP_MAX_CONCURRENT_SANDBOXES default 4 — kernel maxConcurrency cap\n * MCP_CODER_FANOUT_HARNESSES comma-separated harness ids to use for variants > 1\n * MCP_DISABLE_CODER set to `1` to omit `delegate_code`\n * MCP_DISABLE_RESEARCHER set to `1` to omit `delegate_research` even when peer is present\n */\n\nimport type { LoopSandboxClient, LoopTraceEmitter } from '../loops'\nimport { runLoop } from '../loops'\nimport { detectExecutor } from './bin-helpers'\nimport { createDefaultCoderDelegate, type ResearcherDelegate } from './delegates'\nimport type { DelegationExecutor } from './executor'\nimport { createMcpServer } from './server'\nimport { createPropagatingTraceEmitter, readTraceContextFromEnv } from './trace-propagation'\nimport type { ResearchOutputShape } from './types'\n\nasync function main(): Promise<void> {\n const fanoutHarnesses = parseHarnesses(process.env.MCP_CODER_FANOUT_HARNESSES)\n const maxConcurrency = parseConcurrency(process.env.MCP_MAX_CONCURRENT_SANDBOXES)\n const wantCoder = !process.env.MCP_DISABLE_CODER\n const wantResearcher = !process.env.MCP_DISABLE_RESEARCHER\n const fleetId = parseFleetId(process.env.TANGLE_FLEET_ID)\n\n // Skip the sandbox client load entirely when no profile delegate needs it —\n // the feedback + status + history tools are queue-bound and require no\n // sandbox. Useful for tooling that mounts the MCP server purely for\n // self-introspection.\n const needsSandbox = wantCoder || wantResearcher\n let sandboxClient: LoopSandboxClient | undefined\n let executor: DelegationExecutor | undefined\n if (needsSandbox) {\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. Set AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 to run without it for diagnostics, or MCP_DISABLE_CODER=1 MCP_DISABLE_RESEARCHER=1 to run the queue-only subset.\\n',\n )\n process.exit(2)\n }\n // Fleet mode against a diagnostic stub is meaningless — the stub can't\n // resolve a real fleet handle. Refuse rather than silently degrading,\n // otherwise a fleet-mounted MCP would behave differently than configured.\n if (fleetId && !apiKey) {\n process.stderr.write(\n 'agent-runtime-mcp: TANGLE_FLEET_ID was set but TANGLE_API_KEY is missing; cannot resolve fleet handle. Provide an api key or unset TANGLE_FLEET_ID.\\n',\n )\n process.exit(2)\n }\n sandboxClient = await loadSandboxClient(apiKey)\n executor = await detectExecutor({ sandboxClient })\n if (fleetId) {\n process.stderr.write(`agent-runtime-mcp: fleet-aware delegation: fleetId=${fleetId}\\n`)\n }\n process.stderr.write(`agent-runtime-mcp: delegation placement → ${executor.describe()}\\n`)\n }\n\n // Export delegated-loop topology spans to the OTLP / Tangle Intelligence sink\n // when OTEL_EXPORTER_OTLP_ENDPOINT is set (+ TRACE_ID / PARENT_SPAN_ID for\n // correlation with the caller's trace). A cheap no-op when the endpoint is\n // unset — the fleet forwards the env into this MCP's process to turn it on.\n const { emitter: traceEmitter, exporter: traceExporter } = createPropagatingTraceEmitter(\n readTraceContextFromEnv(),\n )\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 const coderDelegate =\n wantCoder && executor\n ? createDefaultCoderDelegate({\n executor,\n fanoutHarnesses,\n maxConcurrency,\n traceEmitter,\n })\n : undefined\n\n const researcherDelegate =\n wantResearcher && executor\n ? await loadResearcherDelegate(executor.client, maxConcurrency, traceEmitter)\n : undefined\n\n const server = createMcpServer({ coderDelegate, researcherDelegate })\n\n const shutdown = () => {\n server.stop()\n void traceExporter?.shutdown().finally(() => process.exit(0))\n if (!traceExporter) process.exit(0)\n }\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n\n await server.serve()\n}\n\nasync function loadSandboxClient(apiKey: string | undefined): Promise<LoopSandboxClient> {\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 // Coder + researcher delegations require a real client; the stub fails loud\n // at create() so the 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; coder/researcher delegations are disabled in diagnostic mode. Set TANGLE_API_KEY or use MCP_DISABLE_CODER=1 MCP_DISABLE_RESEARCHER=1 to remove the unsupported tools from the tool list.',\n )\n },\n } satisfies LoopSandboxClient\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) => LoopSandboxClient }).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 const baseUrl = process.env.SANDBOX_BASE_URL\n return new SandboxCtor({\n apiKey,\n ...(baseUrl ? { baseUrl } : {}),\n })\n}\n\ninterface ResearcherProfilePreset {\n agentRunSpec: Parameters<typeof runLoop>[0]['agentRun'] extends infer T ? NonNullable<T> : never\n output: Parameters<typeof runLoop>[0]['output']\n validator: Parameters<typeof runLoop>[0]['validator']\n}\n\ninterface ResearcherFanoutPreset {\n agentRuns: NonNullable<Parameters<typeof runLoop>[0]['agentRuns']>\n output: Parameters<typeof runLoop>[0]['output']\n validator: Parameters<typeof runLoop>[0]['validator']\n driver: Parameters<typeof runLoop>[0]['driver']\n}\n\nasync function loadResearcherDelegate(\n sandboxClient: LoopSandboxClient,\n maxConcurrency: number,\n traceEmitter?: LoopTraceEmitter,\n): Promise<ResearcherDelegate | undefined> {\n // Optional peer — when `@tangle-network/agent-knowledge` isn't installed,\n // we silently omit the researcher tool from the advertisement. The\n // dynamic-import path is resolved at runtime; TypeScript cannot see the\n // peer, so we type the module structurally rather than via its own\n // declaration file.\n const profilesSpecifier = '@tangle-network/agent-knowledge/profiles'\n const mod = await import(profilesSpecifier).catch(() => undefined)\n if (!mod) return undefined\n type SingleFactory = (opts: { task: unknown }) => ResearcherProfilePreset\n type FanoutFactory = (opts: { task: unknown }) => ResearcherFanoutPreset\n const fanoutFactory = (mod as { multiHarnessResearcherFanout?: FanoutFactory })\n .multiHarnessResearcherFanout\n const singleFactory = (mod as { researcherProfile?: SingleFactory }).researcherProfile\n if (!fanoutFactory || !singleFactory) return undefined\n\n return async (args, ctx) => {\n const task = {\n question: args.question,\n knowledgeNamespace: args.namespace,\n scope: args.scope,\n sources: args.sources,\n recencyWindow: args.config?.recencyWindow\n ? {\n since: args.config.recencyWindow.since\n ? new Date(args.config.recencyWindow.since)\n : undefined,\n until: args.config.recencyWindow.until\n ? new Date(args.config.recencyWindow.until)\n : undefined,\n }\n : undefined,\n maxItems: args.config?.maxItems,\n minConfidence: args.config?.minConfidence,\n }\n const variants = Math.max(1, Math.trunc(args.variants ?? 1))\n ctx.report({ iteration: 0, phase: 'starting' })\n if (variants <= 1) {\n const preset = singleFactory({ task })\n const result = await runLoop({\n driver: {\n name: 'mcp-researcher-single',\n async plan(t, history) {\n return history.length === 0 ? [t] : []\n },\n decide(history) {\n return history.length > 0 ? 'pick-winner' : 'fail'\n },\n },\n agentRun: preset.agentRunSpec,\n output: preset.output,\n validator: preset.validator,\n task,\n ctx: { sandboxClient, signal: ctx.signal, ...(traceEmitter ? { traceEmitter } : {}) },\n maxIterations: 1,\n maxConcurrency,\n })\n const output = result.winner?.output\n if (!output) throw new Error('researcher delegate produced no winner')\n ctx.report({ iteration: 1, phase: 'completed' })\n return output as ResearchOutputShape\n }\n const fanout = fanoutFactory({ task })\n const result = await runLoop({\n driver: fanout.driver,\n agentRuns: fanout.agentRuns.slice(0, variants),\n output: fanout.output,\n validator: fanout.validator,\n task,\n ctx: { sandboxClient, signal: ctx.signal, ...(traceEmitter ? { traceEmitter } : {}) },\n maxIterations: variants,\n maxConcurrency: Math.min(maxConcurrency, variants),\n })\n const output = result.winner?.output\n if (!output) throw new Error('researcher delegate fanout produced no winner')\n ctx.report({ iteration: result.iterations.length, phase: 'completed' })\n return output as ResearchOutputShape\n }\n}\n\nfunction parseHarnesses(raw: string | undefined): string[] | undefined {\n if (!raw) return undefined\n const list = raw\n .split(',')\n .map((entry) => entry.trim())\n .filter(Boolean)\n return list.length > 0 ? list : undefined\n}\n\nfunction parseFleetId(raw: string | undefined): string | undefined {\n if (typeof raw !== 'string') return undefined\n const trimmed = raw.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\nfunction parseConcurrency(raw: string | undefined): number {\n if (!raw) return 4\n const n = Number(raw)\n if (!Number.isFinite(n) || n < 1) return 4\n return Math.min(Math.trunc(n), 32)\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":";;;;;;;;;;;;;;;;;;;;;AAwCA,eAAe,OAAsB;AACnC,QAAM,kBAAkB,eAAe,QAAQ,IAAI,0BAA0B;AAC7E,QAAM,iBAAiB,iBAAiB,QAAQ,IAAI,4BAA4B;AAChF,QAAM,YAAY,CAAC,QAAQ,IAAI;AAC/B,QAAM,iBAAiB,CAAC,QAAQ,IAAI;AACpC,QAAM,UAAU,aAAa,QAAQ,IAAI,eAAe;AAMxD,QAAM,eAAe,aAAa;AAClC,MAAI;AACJ,MAAI;AACJ,MAAI,cAAc;AAChB,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,gCAAgC;AAC1D,cAAQ,OAAO;AAAA,QACb;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAIA,QAAI,WAAW,CAAC,QAAQ;AACtB,cAAQ,OAAO;AAAA,QACb;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,oBAAgB,MAAM,kBAAkB,MAAM;AAC9C,eAAW,MAAM,eAAe,EAAE,cAAc,CAAC;AACjD,QAAI,SAAS;AACX,cAAQ,OAAO,MAAM,sDAAsD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AAEA,SAAS,aAAa,KAA6C;AACjE,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,QAAM,UAAU,IAAI,KAAK;AACzB,SAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;AAEA,SAAS,iBAAiB,KAAiC;AACzD,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,IAAI,OAAO,GAAG;AACpB,MAAI,CAAC,OAAO,SAAS,CAAC,KAAK,IAAI,EAAG,QAAO;AACzC,SAAO,KAAK,IAAI,KAAK,MAAM,CAAC,GAAG,EAAE;AACnC;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":["result","output"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * @experimental\n *\n * `agent-runtime-mcp` — stdio MCP server entry point.\n *\n * Spins up a server with the default coder delegate (wired against the\n * real `@tangle-network/sandbox` client) and, when the optional\n * `@tangle-network/agent-knowledge` peer is installed, a researcher\n * delegate against `multiHarnessResearcherFanout`.\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 * TANGLE_FLEET_ID optional — when set, delegations dispatch\n * INTO this fleet's shared workspace instead\n * of creating sibling sandboxes. Set by the\n * parent sandbox when launching this MCP\n * server so worker diffs land on the caller's\n * filesystem with no cross-sandbox boundary.\n * TANGLE_FLEET_EXCLUDE_MACHINES optional — comma-separated machine ids to\n * skip during fleet-mode round-robin\n * (typically the coordinator machine this\n * MCP server is running on).\n * MCP_MAX_CONCURRENT_SANDBOXES default 4 — kernel maxConcurrency cap\n * MCP_CODER_FANOUT_HARNESSES comma-separated harness ids to use for variants > 1\n * MCP_DISABLE_CODER set to `1` to omit `delegate_code`\n * MCP_DISABLE_RESEARCHER set to `1` to omit `delegate_research` even when peer is present\n */\n\nimport type { LoopSandboxClient, LoopTraceEmitter } from '../runtime'\nimport { runLoop } from '../runtime'\nimport { detectExecutor } from './bin-helpers'\nimport { createDefaultCoderDelegate, type ResearcherDelegate } from './delegates'\nimport type { DelegationExecutor } from './executor'\nimport { createMcpServer } from './server'\nimport { createPropagatingTraceEmitter, readTraceContextFromEnv } from './trace-propagation'\nimport type { ResearchOutputShape } from './types'\n\nasync function main(): Promise<void> {\n const fanoutHarnesses = parseHarnesses(process.env.MCP_CODER_FANOUT_HARNESSES)\n const maxConcurrency = parseConcurrency(process.env.MCP_MAX_CONCURRENT_SANDBOXES)\n const wantCoder = !process.env.MCP_DISABLE_CODER\n const wantResearcher = !process.env.MCP_DISABLE_RESEARCHER\n const fleetId = parseFleetId(process.env.TANGLE_FLEET_ID)\n\n // Skip the sandbox client load entirely when no profile delegate needs it —\n // the feedback + status + history tools are queue-bound and require no\n // sandbox. Useful for tooling that mounts the MCP server purely for\n // self-introspection.\n const needsSandbox = wantCoder || wantResearcher\n let sandboxClient: LoopSandboxClient | undefined\n let executor: DelegationExecutor | undefined\n if (needsSandbox) {\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. Set AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 to run without it for diagnostics, or MCP_DISABLE_CODER=1 MCP_DISABLE_RESEARCHER=1 to run the queue-only subset.\\n',\n )\n process.exit(2)\n }\n // Fleet mode against a diagnostic stub is meaningless — the stub can't\n // resolve a real fleet handle. Refuse rather than silently degrading,\n // otherwise a fleet-mounted MCP would behave differently than configured.\n if (fleetId && !apiKey) {\n process.stderr.write(\n 'agent-runtime-mcp: TANGLE_FLEET_ID was set but TANGLE_API_KEY is missing; cannot resolve fleet handle. Provide an api key or unset TANGLE_FLEET_ID.\\n',\n )\n process.exit(2)\n }\n sandboxClient = await loadSandboxClient(apiKey)\n executor = await detectExecutor({ sandboxClient })\n if (fleetId) {\n process.stderr.write(`agent-runtime-mcp: fleet-aware delegation: fleetId=${fleetId}\\n`)\n }\n process.stderr.write(`agent-runtime-mcp: delegation placement → ${executor.describe()}\\n`)\n }\n\n // Export delegated-loop topology spans to the OTLP / Tangle Intelligence sink\n // when OTEL_EXPORTER_OTLP_ENDPOINT is set (+ TRACE_ID / PARENT_SPAN_ID for\n // correlation with the caller's trace). A cheap no-op when the endpoint is\n // unset — the fleet forwards the env into this MCP's process to turn it on.\n const { emitter: traceEmitter, exporter: traceExporter } = createPropagatingTraceEmitter(\n readTraceContextFromEnv(),\n )\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 const coderDelegate =\n wantCoder && executor\n ? createDefaultCoderDelegate({\n executor,\n fanoutHarnesses,\n maxConcurrency,\n traceEmitter,\n })\n : undefined\n\n const researcherDelegate =\n wantResearcher && executor\n ? await loadResearcherDelegate(executor.client, maxConcurrency, traceEmitter)\n : undefined\n\n const server = createMcpServer({ coderDelegate, researcherDelegate })\n\n const shutdown = () => {\n server.stop()\n void traceExporter?.shutdown().finally(() => process.exit(0))\n if (!traceExporter) process.exit(0)\n }\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n\n await server.serve()\n}\n\nasync function loadSandboxClient(apiKey: string | undefined): Promise<LoopSandboxClient> {\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 // Coder + researcher delegations require a real client; the stub fails loud\n // at create() so the 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; coder/researcher delegations are disabled in diagnostic mode. Set TANGLE_API_KEY or use MCP_DISABLE_CODER=1 MCP_DISABLE_RESEARCHER=1 to remove the unsupported tools from the tool list.',\n )\n },\n } satisfies LoopSandboxClient\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) => LoopSandboxClient }).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 const baseUrl = process.env.SANDBOX_BASE_URL\n return new SandboxCtor({\n apiKey,\n ...(baseUrl ? { baseUrl } : {}),\n })\n}\n\ninterface ResearcherProfilePreset {\n agentRunSpec: Parameters<typeof runLoop>[0]['agentRun'] extends infer T ? NonNullable<T> : never\n output: Parameters<typeof runLoop>[0]['output']\n validator: Parameters<typeof runLoop>[0]['validator']\n}\n\ninterface ResearcherFanoutPreset {\n agentRuns: NonNullable<Parameters<typeof runLoop>[0]['agentRuns']>\n output: Parameters<typeof runLoop>[0]['output']\n validator: Parameters<typeof runLoop>[0]['validator']\n driver: Parameters<typeof runLoop>[0]['driver']\n}\n\nasync function loadResearcherDelegate(\n sandboxClient: LoopSandboxClient,\n maxConcurrency: number,\n traceEmitter?: LoopTraceEmitter,\n): Promise<ResearcherDelegate | undefined> {\n // Optional peer — when `@tangle-network/agent-knowledge` isn't installed,\n // we silently omit the researcher tool from the advertisement. The\n // dynamic-import path is resolved at runtime; TypeScript cannot see the\n // peer, so we type the module structurally rather than via its own\n // declaration file.\n const profilesSpecifier = '@tangle-network/agent-knowledge/profiles'\n const mod = await import(profilesSpecifier).catch(() => undefined)\n if (!mod) return undefined\n type SingleFactory = (opts: { task: unknown }) => ResearcherProfilePreset\n type FanoutFactory = (opts: { task: unknown }) => ResearcherFanoutPreset\n const fanoutFactory = (mod as { multiHarnessResearcherFanout?: FanoutFactory })\n .multiHarnessResearcherFanout\n const singleFactory = (mod as { researcherProfile?: SingleFactory }).researcherProfile\n if (!fanoutFactory || !singleFactory) return undefined\n\n return async (args, ctx) => {\n const task = {\n question: args.question,\n knowledgeNamespace: args.namespace,\n scope: args.scope,\n sources: args.sources,\n recencyWindow: args.config?.recencyWindow\n ? {\n since: args.config.recencyWindow.since\n ? new Date(args.config.recencyWindow.since)\n : undefined,\n until: args.config.recencyWindow.until\n ? new Date(args.config.recencyWindow.until)\n : undefined,\n }\n : undefined,\n maxItems: args.config?.maxItems,\n minConfidence: args.config?.minConfidence,\n }\n const variants = Math.max(1, Math.trunc(args.variants ?? 1))\n ctx.report({ iteration: 0, phase: 'starting' })\n if (variants <= 1) {\n const preset = singleFactory({ task })\n const result = await runLoop({\n driver: {\n name: 'mcp-researcher-single',\n async plan(t, history) {\n return history.length === 0 ? [t] : []\n },\n decide(history) {\n return history.length > 0 ? 'pick-winner' : 'fail'\n },\n },\n agentRun: preset.agentRunSpec,\n output: preset.output,\n validator: preset.validator,\n task,\n ctx: { sandboxClient, signal: ctx.signal, ...(traceEmitter ? { traceEmitter } : {}) },\n maxIterations: 1,\n maxConcurrency,\n })\n const output = result.winner?.output\n if (!output) throw new Error('researcher delegate produced no winner')\n ctx.report({ iteration: 1, phase: 'completed' })\n return output as ResearchOutputShape\n }\n const fanout = fanoutFactory({ task })\n const result = await runLoop({\n driver: fanout.driver,\n agentRuns: fanout.agentRuns.slice(0, variants),\n output: fanout.output,\n validator: fanout.validator,\n task,\n ctx: { sandboxClient, signal: ctx.signal, ...(traceEmitter ? { traceEmitter } : {}) },\n maxIterations: variants,\n maxConcurrency: Math.min(maxConcurrency, variants),\n })\n const output = result.winner?.output\n if (!output) throw new Error('researcher delegate fanout produced no winner')\n ctx.report({ iteration: result.iterations.length, phase: 'completed' })\n return output as ResearchOutputShape\n }\n}\n\nfunction parseHarnesses(raw: string | undefined): string[] | undefined {\n if (!raw) return undefined\n const list = raw\n .split(',')\n .map((entry) => entry.trim())\n .filter(Boolean)\n return list.length > 0 ? list : undefined\n}\n\nfunction parseFleetId(raw: string | undefined): string | undefined {\n if (typeof raw !== 'string') return undefined\n const trimmed = raw.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\nfunction parseConcurrency(raw: string | undefined): number {\n if (!raw) return 4\n const n = Number(raw)\n if (!Number.isFinite(n) || n < 1) return 4\n return Math.min(Math.trunc(n), 32)\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":";;;;;;;;;;;;;;;;;;;;;AAwCA,eAAe,OAAsB;AACnC,QAAM,kBAAkB,eAAe,QAAQ,IAAI,0BAA0B;AAC7E,QAAM,iBAAiB,iBAAiB,QAAQ,IAAI,4BAA4B;AAChF,QAAM,YAAY,CAAC,QAAQ,IAAI;AAC/B,QAAM,iBAAiB,CAAC,QAAQ,IAAI;AACpC,QAAM,UAAU,aAAa,QAAQ,IAAI,eAAe;AAMxD,QAAM,eAAe,aAAa;AAClC,MAAI;AACJ,MAAI;AACJ,MAAI,cAAc;AAChB,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,gCAAgC;AAC1D,cAAQ,OAAO;AAAA,QACb;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAIA,QAAI,WAAW,CAAC,QAAQ;AACtB,cAAQ,OAAO;AAAA,QACb;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,oBAAgB,MAAM,kBAAkB,MAAM;AAC9C,eAAW,MAAM,eAAe,EAAE,cAAc,CAAC;AACjD,QAAI,SAAS;AACX,cAAQ,OAAO,MAAM,sDAAsD,OAAO;AAAA,CAAI;AAAA,IACxF;AACA,YAA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AO,QAAQ,SAAU,QAAO;AACpC,QAAM,UAAU,IAAI,KAAK;AACzB,SAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;AAEA,SAAS,iBAAiB,KAAiC;AACzD,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,IAAI,OAAO,GAAG;AACpB,MAAI,CAAC,OAAO,SAAS,CAAC,KAAK,IAAI,EAAG,QAAO;AACzC,SAAO,KAAK,IAAI,KAAK,MAAM,CAAC,GAAG,EAAE;AACnC;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":["result","output"]}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as FleetHandle, d as DelegationExecutor, e as DelegateFeedbackArgs, f as DelegationFeedbackSnapshot, g as DelegationProfile, D as DelegateCodeArgs, h as DelegateResearchArgs, i as
|
|
3
|
-
export {
|
|
1
|
+
import { b as LoopSandboxClient, g as LoopSandboxPlacement, f as LoopTraceEmitter } from '../types-DdzkffAm.js';
|
|
2
|
+
import { c as FleetHandle, d as DelegationExecutor, e as DelegateFeedbackArgs, f as DelegationFeedbackSnapshot, g as DelegationProfile, D as DelegateCodeArgs, h as DelegateResearchArgs, i as DelegateUiAuditArgs, j as DelegationStatus, k as DelegationProgress, l as DelegationResultPayload, m as DelegationError, n as DelegationStatusResult, o as DelegationHistoryArgs, p as DelegationHistoryEntry, q as CoderDelegate, R as ResearcherDelegate, U as UiAuditorDelegate, r as DelegateCodeResult, s as DelegateFeedbackResult, t as ResearchSource, u as DelegateResearchResult, v as DelegateUiAuditResult, w as DelegationHistoryResult, x as DelegationStatusArgs } from '../kb-gate-D9GBocLN.js';
|
|
3
|
+
export { y as CoderReview, C as CoderReviewer, a as CoderWinnerSelection, z as CreateDefaultCoderDelegateOptions, b as CreateKbGateOptions, A as DelegateCodeConfig, B as DelegateResearchConfig, E as DelegateRunCtx, G as DelegateUiAuditConfig, H as DelegateUiAuditRoute, F as FactCandidate, I as FactJudge, J as FactJudgeVerdict, K as FeedbackRating, L as FeedbackRefersTo, M as FleetWorkspaceExecutorOptions, N as KbGateResult, O as ResearchOutputShape, S as SiblingSandboxExecutorOptions, P as UiAuditorDelegationOutput, Q as createDefaultCoderDelegate, T as createFleetWorkspaceExecutor, V as createKbGate, W as createSiblingSandboxExecutor } from '../kb-gate-D9GBocLN.js';
|
|
4
4
|
export { B as BuildDelegationMcpServerOptions, C as ComposeProductionAgentProfileOptions, D as DELEGATION_MCP_SERVER_KEY, b as buildDelegationMcpServer, c as composeProductionAgentProfile } from '../delegation-profile-1GbW5yA3.js';
|
|
5
5
|
import { L as LocalHarness, r as runLocalHarness } from '../local-harness-KrdFTY5R.js';
|
|
6
6
|
export { a as LocalHarnessResult, R as RunLocalHarnessOptions } from '../local-harness-KrdFTY5R.js';
|
|
7
|
-
import { O as OtelExporter } from '../otel-export-
|
|
8
|
-
export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from '../otel-export-
|
|
9
|
-
import '@tangle-network/agent-eval';
|
|
7
|
+
import { O as OtelExporter } from '../otel-export-Dy2DyUCU.js';
|
|
8
|
+
export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from '../otel-export-Dy2DyUCU.js';
|
|
9
|
+
import { AnalystFinding } from '@tangle-network/agent-eval';
|
|
10
|
+
import { S as Scope, R as ResultBlobStore, A as Agent, B as Budget } from '../types-1HbsFa7H.js';
|
|
11
|
+
import { a as UiLens } from '../substrate-CUgk7F7s.js';
|
|
10
12
|
import '@tangle-network/sandbox';
|
|
11
|
-
import '../
|
|
13
|
+
import '../runtime-hooks-C7JwKb9E.js';
|
|
14
|
+
import '../coder-CczgMqFx.js';
|
|
12
15
|
import 'node:child_process';
|
|
13
16
|
|
|
14
17
|
/**
|
|
@@ -309,12 +312,13 @@ declare function createInProcessExecutor(options: InProcessExecutorOptions): Del
|
|
|
309
312
|
* pending delegations.
|
|
310
313
|
*/
|
|
311
314
|
|
|
315
|
+
type AnyDelegateArgs = DelegateCodeArgs | DelegateResearchArgs | DelegateUiAuditArgs;
|
|
312
316
|
/** @experimental */
|
|
313
317
|
interface DelegationRecord {
|
|
314
318
|
taskId: string;
|
|
315
319
|
profile: DelegationProfile;
|
|
316
320
|
namespace?: string;
|
|
317
|
-
args:
|
|
321
|
+
args: AnyDelegateArgs;
|
|
318
322
|
status: DelegationStatus;
|
|
319
323
|
progress?: DelegationProgress;
|
|
320
324
|
result?: DelegationResultPayload;
|
|
@@ -328,7 +332,7 @@ interface DelegationRecord {
|
|
|
328
332
|
feedback: DelegationFeedbackSnapshot[];
|
|
329
333
|
}
|
|
330
334
|
/** @experimental */
|
|
331
|
-
interface SubmitInput<Args extends
|
|
335
|
+
interface SubmitInput<Args extends AnyDelegateArgs> {
|
|
332
336
|
profile: DelegationProfile;
|
|
333
337
|
args: Args;
|
|
334
338
|
namespace?: string;
|
|
@@ -369,7 +373,7 @@ declare class DelegationTaskQueue {
|
|
|
369
373
|
* Kick off a delegation in the background. Returns immediately. The
|
|
370
374
|
* `taskId` is queryable via `status` once this method returns.
|
|
371
375
|
*/
|
|
372
|
-
submit<Args extends
|
|
376
|
+
submit<Args extends AnyDelegateArgs>(input: SubmitInput<Args>): SubmitOutput;
|
|
373
377
|
/**
|
|
374
378
|
* Snapshot the current state of a delegation. Returns `undefined` for
|
|
375
379
|
* unknown ids so callers can distinguish missing from terminal.
|
|
@@ -436,10 +440,24 @@ interface McpServerOptions {
|
|
|
436
440
|
* `researcherProfile` / `multiHarnessResearcherFanout`).
|
|
437
441
|
*/
|
|
438
442
|
researcherDelegate?: ResearcherDelegate;
|
|
443
|
+
/**
|
|
444
|
+
* Required to enable delegate_ui_audit. Wire one that closes over your
|
|
445
|
+
* `runLoop` + `uiAuditorProfile` + a `LoopSandboxClient` (the
|
|
446
|
+
* canonical in-process choice is `createInProcessUiAuditClient` from
|
|
447
|
+
* `@tangle-network/agent-runtime/profiles`) + your vision judge.
|
|
448
|
+
*/
|
|
449
|
+
uiAuditorDelegate?: UiAuditorDelegate;
|
|
439
450
|
/** Override the default in-memory feedback store. */
|
|
440
451
|
feedbackStore?: FeedbackStore;
|
|
441
452
|
/** Override the default in-memory task queue. */
|
|
442
453
|
queue?: DelegationTaskQueue;
|
|
454
|
+
/**
|
|
455
|
+
* Extra tools to serve alongside the delegation tools — e.g. the operator toolbox
|
|
456
|
+
* (`createCoordinationTools(...).tools`), which exposes the driver's spawn/observe/steer verbs over
|
|
457
|
+
* MCP so a sandbox agent can BE the driver. Registered after the built-ins; a duplicate name
|
|
458
|
+
* throws (fail loud — no silent shadowing of a delegation tool).
|
|
459
|
+
*/
|
|
460
|
+
extraTools?: McpToolDescriptor[];
|
|
443
461
|
/** Server display name surfaced via `initialize`. Default `'agent-runtime-mcp'`. */
|
|
444
462
|
serverName?: string;
|
|
445
463
|
/** Server version surfaced via `initialize`. Default = the package version baked at build time. */
|
|
@@ -506,6 +524,142 @@ declare function createInProcessTransport(): {
|
|
|
506
524
|
readServer(): Promise<JsonRpcResponse[]>;
|
|
507
525
|
};
|
|
508
526
|
|
|
527
|
+
/**
|
|
528
|
+
* @experimental
|
|
529
|
+
*
|
|
530
|
+
* The trace-analyst KIND directory — the operator's lenses, as composable DATA.
|
|
531
|
+
*
|
|
532
|
+
* An analyst is not one question. A kind is ONE lens (completeness, correctness, policy, efficiency,
|
|
533
|
+
* tool-use, …); each emits `AnalystFinding`s tagged by its `area`. The driver `list_analysts` to see
|
|
534
|
+
* the menu, `run_analyst(kind, worker)` to apply a lens, and `define_analyst` to author a new one —
|
|
535
|
+
* so at test time you compose the exact lenses a domain needs (maximum specificity), not one generic
|
|
536
|
+
* reviewer. The kinds are data, the runner is generic, and the finding shape + firewall are reused
|
|
537
|
+
* from agent-eval / the keystone — never re-derived.
|
|
538
|
+
*
|
|
539
|
+
* A kind here is a lightweight lens (`Check`); it is a deliberate SUBSET of agent-eval's full
|
|
540
|
+
* `TraceAnalystKindSpec`, so a kind that needs the heavy agentic actor (sub-agent recursion, tools,
|
|
541
|
+
* goldens) upgrades to `createTraceAnalystKind` without changing this directory's surface.
|
|
542
|
+
*/
|
|
543
|
+
|
|
544
|
+
/** One lens — a composable analyst kind. Identity fields mirror `TraceAnalystKindSpec` so a kind is
|
|
545
|
+
* upgradeable to the full agentic factory; `lookFor` is the lens question the actor applies. */
|
|
546
|
+
interface Check {
|
|
547
|
+
readonly id: string;
|
|
548
|
+
readonly description: string;
|
|
549
|
+
/** Coarse classification stamped on every finding this kind emits (the renderer groups by it). */
|
|
550
|
+
readonly area: string;
|
|
551
|
+
readonly version: string;
|
|
552
|
+
/** The lens — what this analyst looks for in the trace. */
|
|
553
|
+
readonly lookFor: string;
|
|
554
|
+
}
|
|
555
|
+
/** The built-in lens directory. Domain-blind (about any agent trace); compose at test time. */
|
|
556
|
+
declare const defaultChecks: Record<string, Check>;
|
|
557
|
+
/** Lift validated raw rows into `AnalystFinding`s (agent-eval `makeFinding` stamps `finding_id`/
|
|
558
|
+
* `produced_at`), then enforce the trace-derived firewall (selector ≠ judge). Pure — no LLM. */
|
|
559
|
+
declare function liftFindings(kind: Check, rows: unknown[], producedAt: string): AnalystFinding[];
|
|
560
|
+
/** Render a worker's trace (tool calls + results) into the text an analyst lens reads. Generic over
|
|
561
|
+
* the trace shape: a `{ messages }` conversation, a bare message array, else stringified. */
|
|
562
|
+
declare function renderTrace(trace: unknown): string;
|
|
563
|
+
interface CheckRunnerOptions {
|
|
564
|
+
routerBaseUrl: string;
|
|
565
|
+
routerKey: string;
|
|
566
|
+
model: string;
|
|
567
|
+
/** Test/override seam — replace the LLM call. Default: a router chat completion. */
|
|
568
|
+
chat?: (system: string, user: string) => Promise<string>;
|
|
569
|
+
}
|
|
570
|
+
/** Run ONE lens over a trace → findings. Generic over any kind: prompt = the lens + the agent-eval
|
|
571
|
+
* finding schema; the model's JSON array is parsed (`parseRawFinding`), lifted, and firewalled. */
|
|
572
|
+
declare function runCheck(kind: Check, trace: unknown, opts: CheckRunnerOptions, producedAt: string): Promise<AnalystFinding[]>;
|
|
573
|
+
/** Build a `run_analyst` runner over a kind directory — the seam the operator toolbox is wired with.
|
|
574
|
+
* Returns the findings, or a typed error for an unknown kind. `producedAt` is passed in (the runtime
|
|
575
|
+
* forbids `Date.now` in replay-safe paths; the caller stamps it). */
|
|
576
|
+
declare function makeCheckRunner(kinds: Record<string, Check>, opts: CheckRunnerOptions): (kindId: string, trace: unknown, producedAt: string) => Promise<AnalystFinding[] | {
|
|
577
|
+
error: string;
|
|
578
|
+
}>;
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @experimental
|
|
582
|
+
*
|
|
583
|
+
* COORDINATION TOOLS — the verbs a parent agent uses to coordinate the child agents it spawns,
|
|
584
|
+
* exposed as MCP tools backed by a live keystone `Scope`. This is `Scope`-as-MCP.
|
|
585
|
+
*
|
|
586
|
+
* NOT a transport. The cross-org message bus (`docs/agent-bus-protocol.md`) and the SDK's
|
|
587
|
+
* `dispatchPrompt`/`SessionMessage` are the *transports* the `steer` verb rides; THIS file is the
|
|
588
|
+
* verb set (the API). One verb, several bindings: in-process `Scope.send` is a direct call; across
|
|
589
|
+
* sandboxes it rides SDK session-messaging; across orgs it rides the agent-bus protocol.
|
|
590
|
+
*
|
|
591
|
+
* spawn_worker → scope.spawn (budget-bounded, fail-closed — equal-k holds even for an LLM driver)
|
|
592
|
+
* await_next → scope.next (THE wake event: block until the next spawned child settles)
|
|
593
|
+
* observe_worker→ scope.view + the result blob (a child's status, spend, and settled output)
|
|
594
|
+
* steer_worker → scope.send (deliver a next-instruction / interrupt to a RUNNING child)
|
|
595
|
+
* list_analysts → the check menu (the trace lenses the agent can apply — see checks.ts)
|
|
596
|
+
* run_analyst → apply a CHECK (run a kind over a child's trace → trace-derived findings)
|
|
597
|
+
* stop → declare the run complete (the terminal move)
|
|
598
|
+
*
|
|
599
|
+
* The check verbs are present only when the check seam (`analystKinds` + `runAnalyst`) is wired —
|
|
600
|
+
* an agent that does not review traces (a pure dispatcher) omits them. A trace check is a SEPARATE
|
|
601
|
+
* lens (selector ≠ judge: it reads the trace, never the score); authoring a NEW check at runtime is
|
|
602
|
+
* the next addition.
|
|
603
|
+
*
|
|
604
|
+
* A worker the driver spawns may itself carry the driver profile — `spawn_worker` does not care what
|
|
605
|
+
* the profile is, so drivers-of-drivers fall out for free (each sub-driver gets its own sub-scope,
|
|
606
|
+
* bounded by `maxDepth` + the conserved pool).
|
|
607
|
+
*/
|
|
608
|
+
|
|
609
|
+
/** A worker the driver has drained via `await_next` — the operator's running ledger of settled
|
|
610
|
+
* workers + their DEPLOYABLE verdict (the driver IS the selector, so it legitimately reads the
|
|
611
|
+
* verdict; the analyst, which reads only the trace, is the separate selector≠judge lens). The
|
|
612
|
+
* driver picks its deliverable from this ledger at `stop`. */
|
|
613
|
+
interface SettledWorker {
|
|
614
|
+
readonly id: string;
|
|
615
|
+
readonly status: 'done' | 'down';
|
|
616
|
+
/** Deployable score in [0,1] from the worker's verdict (done only). */
|
|
617
|
+
readonly score?: number;
|
|
618
|
+
/** Whether the deployable verdict passed (done only). */
|
|
619
|
+
readonly valid?: boolean;
|
|
620
|
+
/** Result-blob pointer for the worker's output/trace (done only). */
|
|
621
|
+
readonly outRef?: string;
|
|
622
|
+
/** Failure reason (down only). */
|
|
623
|
+
readonly reason?: string;
|
|
624
|
+
}
|
|
625
|
+
/** How a `spawn_worker` profile becomes a spawnable leaf `Agent`. The caller wires this (e.g. the
|
|
626
|
+
* surface registry turns a profile into a shot executor) so the toolbox stays domain-blind. */
|
|
627
|
+
type MakeWorkerAgent = (profile: unknown) => Agent<unknown, unknown>;
|
|
628
|
+
interface CoordinationToolsOptions {
|
|
629
|
+
/** The DRIVER's live scope — spawn/observe/steer all act on this. */
|
|
630
|
+
readonly scope: Scope<unknown>;
|
|
631
|
+
/** Result blobs, so `observe_worker` can rehydrate a settled worker's output. */
|
|
632
|
+
readonly blobs: ResultBlobStore;
|
|
633
|
+
/** Turn a spawn_worker `profile` into a leaf agent (registry-resolved on spawn). */
|
|
634
|
+
readonly makeWorkerAgent: MakeWorkerAgent;
|
|
635
|
+
/** Per-worker conserved budget the driver reserves on each spawn. */
|
|
636
|
+
readonly perWorker: Budget;
|
|
637
|
+
/** The analyst lens menu (for `list_analysts`) — id + one-line + area. Injected so the toolbox
|
|
638
|
+
* stays domain-blind; wire it from `analyst-kinds.ts`'s directory. Omit to disable analyst tools. */
|
|
639
|
+
readonly analystKinds?: ReadonlyArray<{
|
|
640
|
+
id: string;
|
|
641
|
+
description: string;
|
|
642
|
+
area: string;
|
|
643
|
+
}>;
|
|
644
|
+
/** Run a lens over a worker's trace → findings (or a typed error). Wire it from
|
|
645
|
+
* `makeCheckRunner(...)`. `run_analyst` fetches the worker's settled output and passes it here. */
|
|
646
|
+
readonly runAnalyst?: (kindId: string, trace: unknown) => Promise<unknown>;
|
|
647
|
+
}
|
|
648
|
+
interface CoordinationTools {
|
|
649
|
+
/** MCP tools — register on an `McpServer`, or call the handlers directly in-process. */
|
|
650
|
+
readonly tools: McpToolDescriptor[];
|
|
651
|
+
/** True once the driver called `stop` — the operator loop reads this to terminate. */
|
|
652
|
+
isStopped(): boolean;
|
|
653
|
+
/** The reason passed to `stop`, if any. */
|
|
654
|
+
stopReason(): string | undefined;
|
|
655
|
+
/** The workers drained so far via `await_next` (the driver's selection ledger). */
|
|
656
|
+
settled(): ReadonlyArray<SettledWorker>;
|
|
657
|
+
}
|
|
658
|
+
/** Build the operator toolbox over a live scope. The tools are the driver's verbs; their handlers
|
|
659
|
+
* are thin wrappers over the keystone (spawn/view/send), so the budget/journal/abort discipline of
|
|
660
|
+
* the Supervisor applies to a sandbox driver exactly as to the in-process one. */
|
|
661
|
+
declare function createCoordinationTools(opts: CoordinationToolsOptions): CoordinationTools;
|
|
662
|
+
|
|
509
663
|
/**
|
|
510
664
|
* @experimental
|
|
511
665
|
*
|
|
@@ -750,6 +904,125 @@ interface DelegateResearchHandlerOptions {
|
|
|
750
904
|
/** @experimental */
|
|
751
905
|
declare function createDelegateResearchHandler(options: DelegateResearchHandlerOptions): (raw: unknown) => Promise<DelegateResearchResult>;
|
|
752
906
|
|
|
907
|
+
/**
|
|
908
|
+
* @experimental
|
|
909
|
+
*
|
|
910
|
+
* `delegate_ui_audit` MCP tool — async kickoff for UI audit runs. Same
|
|
911
|
+
* async semantics as `delegate_code` / `delegate_research`: validates the
|
|
912
|
+
* input, computes an idempotency key over the canonical fields, hands
|
|
913
|
+
* the task to the queue, and returns a taskId. Identical inputs return
|
|
914
|
+
* the same taskId.
|
|
915
|
+
*
|
|
916
|
+
* The handler does not import the auditor profile directly — consumers
|
|
917
|
+
* inject a `UiAuditorDelegate` via `createMcpServer({ uiAuditorDelegate })`.
|
|
918
|
+
* The delegate is the seam where the consumer chooses the judge (vision
|
|
919
|
+
* model) and the `LoopSandboxClient` (in-process Playwright vs fleet vs
|
|
920
|
+
* remote browser). agent-runtime ships the in-process client under
|
|
921
|
+
* `./profiles` so consumers who want the canonical setup can wire it
|
|
922
|
+
* with a few lines.
|
|
923
|
+
*/
|
|
924
|
+
|
|
925
|
+
/** @experimental */
|
|
926
|
+
declare const DELEGATE_UI_AUDIT_TOOL_NAME = "delegate_ui_audit";
|
|
927
|
+
/** @experimental */
|
|
928
|
+
declare const DELEGATE_UI_AUDIT_DESCRIPTION: string;
|
|
929
|
+
/** @experimental */
|
|
930
|
+
declare const DELEGATE_UI_AUDIT_INPUT_SCHEMA: {
|
|
931
|
+
readonly type: "object";
|
|
932
|
+
readonly properties: {
|
|
933
|
+
readonly workspaceDir: {
|
|
934
|
+
readonly type: "string";
|
|
935
|
+
readonly description: "Absolute path for the audit workspace.";
|
|
936
|
+
};
|
|
937
|
+
readonly routes: {
|
|
938
|
+
readonly type: "array";
|
|
939
|
+
readonly items: {
|
|
940
|
+
readonly type: "object";
|
|
941
|
+
readonly properties: {
|
|
942
|
+
readonly name: {
|
|
943
|
+
readonly type: "string";
|
|
944
|
+
readonly description: "Stable route name (used in screenshot filenames).";
|
|
945
|
+
};
|
|
946
|
+
readonly url: {
|
|
947
|
+
readonly type: "string";
|
|
948
|
+
readonly description: "Fully-qualified URL.";
|
|
949
|
+
};
|
|
950
|
+
readonly viewports: {
|
|
951
|
+
readonly type: "array";
|
|
952
|
+
readonly items: {
|
|
953
|
+
readonly type: "object";
|
|
954
|
+
readonly properties: {
|
|
955
|
+
readonly width: {
|
|
956
|
+
readonly type: "integer";
|
|
957
|
+
readonly minimum: 1;
|
|
958
|
+
};
|
|
959
|
+
readonly height: {
|
|
960
|
+
readonly type: "integer";
|
|
961
|
+
readonly minimum: 1;
|
|
962
|
+
};
|
|
963
|
+
};
|
|
964
|
+
readonly required: readonly ["width", "height"];
|
|
965
|
+
readonly additionalProperties: false;
|
|
966
|
+
};
|
|
967
|
+
readonly description: "Viewports to capture at. Default [{1280, 800}].";
|
|
968
|
+
};
|
|
969
|
+
readonly fullPage: {
|
|
970
|
+
readonly type: "boolean";
|
|
971
|
+
};
|
|
972
|
+
readonly waitFor: {
|
|
973
|
+
readonly type: "string";
|
|
974
|
+
readonly description: "CSS selector to wait for before capturing.";
|
|
975
|
+
};
|
|
976
|
+
};
|
|
977
|
+
readonly required: readonly ["name", "url"];
|
|
978
|
+
readonly additionalProperties: false;
|
|
979
|
+
};
|
|
980
|
+
readonly minItems: 1;
|
|
981
|
+
};
|
|
982
|
+
readonly namespace: {
|
|
983
|
+
readonly type: "string";
|
|
984
|
+
readonly description: "Multi-tenant scope.";
|
|
985
|
+
};
|
|
986
|
+
readonly config: {
|
|
987
|
+
readonly type: "object";
|
|
988
|
+
readonly properties: {
|
|
989
|
+
readonly lenses: {
|
|
990
|
+
readonly type: "array";
|
|
991
|
+
readonly items: {
|
|
992
|
+
readonly type: "string";
|
|
993
|
+
readonly enum: readonly UiLens[];
|
|
994
|
+
};
|
|
995
|
+
readonly description: "Lenses to iterate. Default: every lens except \"other\".";
|
|
996
|
+
};
|
|
997
|
+
readonly maxIterations: {
|
|
998
|
+
readonly type: "integer";
|
|
999
|
+
readonly minimum: 1;
|
|
1000
|
+
};
|
|
1001
|
+
readonly maxConcurrency: {
|
|
1002
|
+
readonly type: "integer";
|
|
1003
|
+
readonly minimum: 1;
|
|
1004
|
+
};
|
|
1005
|
+
readonly productContext: {
|
|
1006
|
+
readonly type: "string";
|
|
1007
|
+
};
|
|
1008
|
+
};
|
|
1009
|
+
readonly additionalProperties: false;
|
|
1010
|
+
};
|
|
1011
|
+
};
|
|
1012
|
+
readonly required: readonly ["workspaceDir", "routes"];
|
|
1013
|
+
readonly additionalProperties: false;
|
|
1014
|
+
};
|
|
1015
|
+
/** @experimental */
|
|
1016
|
+
declare function validateDelegateUiAuditArgs(raw: unknown): DelegateUiAuditArgs;
|
|
1017
|
+
/** @experimental */
|
|
1018
|
+
interface DelegateUiAuditHandlerOptions {
|
|
1019
|
+
queue: DelegationTaskQueue;
|
|
1020
|
+
delegate: UiAuditorDelegate;
|
|
1021
|
+
estimateDurationMs?: (args: DelegateUiAuditArgs) => number;
|
|
1022
|
+
}
|
|
1023
|
+
/** @experimental */
|
|
1024
|
+
declare function createDelegateUiAuditHandler(options: DelegateUiAuditHandlerOptions): (raw: unknown) => Promise<DelegateUiAuditResult>;
|
|
1025
|
+
|
|
753
1026
|
/**
|
|
754
1027
|
* @experimental
|
|
755
1028
|
*
|
|
@@ -874,4 +1147,4 @@ declare function createPropagatingTraceEmitter(ctx: TraceContext): {
|
|
|
874
1147
|
*/
|
|
875
1148
|
declare function traceContextToEnv(ctx: TraceContext): Record<string, string>;
|
|
876
1149
|
|
|
877
|
-
export { CoderDelegate, type CreateWorktreeOptions, DELEGATE_CODE_DESCRIPTION, DELEGATE_CODE_INPUT_SCHEMA, DELEGATE_CODE_TOOL_NAME, DELEGATE_FEEDBACK_DESCRIPTION, DELEGATE_FEEDBACK_INPUT_SCHEMA, DELEGATE_FEEDBACK_TOOL_NAME, DELEGATE_RESEARCH_DESCRIPTION, DELEGATE_RESEARCH_INPUT_SCHEMA, DELEGATE_RESEARCH_TOOL_NAME, DELEGATION_HISTORY_DESCRIPTION, DELEGATION_HISTORY_INPUT_SCHEMA, DELEGATION_HISTORY_TOOL_NAME, DELEGATION_STATUS_DESCRIPTION, DELEGATION_STATUS_INPUT_SCHEMA, DELEGATION_STATUS_TOOL_NAME, DelegateCodeArgs, DelegateCodeResult, DelegateFeedbackArgs, DelegateFeedbackResult, DelegateResearchArgs, DelegateResearchResult, DelegationError, DelegationExecutor, DelegationFeedbackSnapshot, DelegationHistoryArgs, DelegationHistoryEntry, DelegationHistoryResult, DelegationProfile, DelegationProgress, type DelegationRecord, DelegationResultPayload, DelegationStatus, DelegationStatusArgs, DelegationStatusResult, DelegationTaskQueue, type DelegationTaskQueueOptions, type DetectExecutorArgs, type DiffOptions, type DiffResult, type FeedbackEvent, type FeedbackStore, FleetHandle, type GitRunner, InMemoryFeedbackStore, type InProcessExecutorDescribePlacement, type InProcessExecutorOptions, type JsonRpcMessage, type JsonRpcResponse, LocalHarness, type McpServer, type McpServerOptions, type McpToolDescriptor, type McpTransport, type RemoveWorktreeOptions, ResearchSource, ResearcherDelegate, type SubmitInput, type SubmitOutput, type TraceContext, type WorktreeHandle, captureWorktreeDiff, createDelegateCodeHandler, createDelegateFeedbackHandler, createDelegateResearchHandler, createDelegationHistoryHandler, createDelegationStatusHandler, createInProcessExecutor, createInProcessTransport, createMcpServer, createPropagatingTraceEmitter, createWorktree, detectExecutor, eventToSnapshot, hashIdempotencyInput, readTraceContextFromEnv, removeWorktree, runLocalHarness, traceContextToEnv, validateDelegateCodeArgs, validateDelegateFeedbackArgs, validateDelegateResearchArgs, validateDelegationHistoryArgs, validateDelegationStatusArgs };
|
|
1150
|
+
export { type Check, type CheckRunnerOptions, CoderDelegate, type CoordinationTools, type CoordinationToolsOptions, type CreateWorktreeOptions, DELEGATE_CODE_DESCRIPTION, DELEGATE_CODE_INPUT_SCHEMA, DELEGATE_CODE_TOOL_NAME, DELEGATE_FEEDBACK_DESCRIPTION, DELEGATE_FEEDBACK_INPUT_SCHEMA, DELEGATE_FEEDBACK_TOOL_NAME, DELEGATE_RESEARCH_DESCRIPTION, DELEGATE_RESEARCH_INPUT_SCHEMA, DELEGATE_RESEARCH_TOOL_NAME, DELEGATE_UI_AUDIT_DESCRIPTION, DELEGATE_UI_AUDIT_INPUT_SCHEMA, DELEGATE_UI_AUDIT_TOOL_NAME, DELEGATION_HISTORY_DESCRIPTION, DELEGATION_HISTORY_INPUT_SCHEMA, DELEGATION_HISTORY_TOOL_NAME, DELEGATION_STATUS_DESCRIPTION, DELEGATION_STATUS_INPUT_SCHEMA, DELEGATION_STATUS_TOOL_NAME, DelegateCodeArgs, DelegateCodeResult, DelegateFeedbackArgs, DelegateFeedbackResult, DelegateResearchArgs, DelegateResearchResult, DelegateUiAuditArgs, DelegateUiAuditResult, DelegationError, DelegationExecutor, DelegationFeedbackSnapshot, DelegationHistoryArgs, DelegationHistoryEntry, DelegationHistoryResult, DelegationProfile, DelegationProgress, type DelegationRecord, DelegationResultPayload, DelegationStatus, DelegationStatusArgs, DelegationStatusResult, DelegationTaskQueue, type DelegationTaskQueueOptions, type DetectExecutorArgs, type DiffOptions, type DiffResult, type FeedbackEvent, type FeedbackStore, FleetHandle, type GitRunner, InMemoryFeedbackStore, type InProcessExecutorDescribePlacement, type InProcessExecutorOptions, type JsonRpcMessage, type JsonRpcResponse, LocalHarness, type MakeWorkerAgent, type McpServer, type McpServerOptions, type McpToolDescriptor, type McpTransport, type RemoveWorktreeOptions, ResearchSource, ResearcherDelegate, type SettledWorker, type SubmitInput, type SubmitOutput, type TraceContext, UiAuditorDelegate, type WorktreeHandle, captureWorktreeDiff, createCoordinationTools, createDelegateCodeHandler, createDelegateFeedbackHandler, createDelegateResearchHandler, createDelegateUiAuditHandler, createDelegationHistoryHandler, createDelegationStatusHandler, createInProcessExecutor, createInProcessTransport, createMcpServer, createPropagatingTraceEmitter, createWorktree, defaultChecks, detectExecutor, eventToSnapshot, hashIdempotencyInput, liftFindings, makeCheckRunner, readTraceContextFromEnv, removeWorktree, renderTrace, runCheck, runLocalHarness, traceContextToEnv, validateDelegateCodeArgs, validateDelegateFeedbackArgs, validateDelegateResearchArgs, validateDelegateUiAuditArgs, validateDelegationHistoryArgs, validateDelegationStatusArgs };
|