@tangle-network/agent-runtime 0.23.1 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -498
- package/dist/agent.d.ts +5 -206
- package/dist/chunk-GLR25NG7.js +92 -0
- package/dist/chunk-GLR25NG7.js.map +1 -0
- package/dist/{chunk-IQHYOJU3.js → chunk-ZJACJZF7.js} +289 -1
- package/dist/chunk-ZJACJZF7.js.map +1 -0
- package/dist/improvement-adapter-CaZxFxTd.d.ts +207 -0
- package/dist/improvement.d.ts +120 -0
- package/dist/improvement.js +161 -0
- package/dist/improvement.js.map +1 -0
- package/dist/local-harness-KrdFTY5R.d.ts +82 -0
- package/dist/mcp/bin.js +2 -1
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +190 -2
- package/dist/mcp/index.js +20 -8
- package/dist/mcp/index.js.map +1 -1
- package/package.json +30 -14
- package/dist/chunk-IQHYOJU3.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/improvement/agentic-generator.ts","../src/improvement/improvement-driver.ts","../src/improvement/reflective-generator.ts"],"sourcesContent":["/**\n * @experimental\n *\n * `agenticGenerator` — the full-agentic `CandidateGenerator`: the\n * `shots=N, sandbox=on` setting of the one `improvementDriver`. It runs a real\n * coding harness (claude / codex / opencode) inside the candidate worktree the\n * driver already created, letting the agent read the codebase + the research\n * report and make the change in place. The driver then commits the worktree\n * into a `CodeSurface`.\n *\n * Mechanism: identical to the proven Phase-2.8 in-process executor — spawn the\n * harness as a subprocess with `cwd` = the worktree, on the same filesystem,\n * so edits land in place (no sandbox-mount round-trip). `runLocalHarness` is\n * the verified primitive. The OUTER sandbox is the improvement loop's own\n * execution context; the generator does not nest a second sandbox per\n * candidate (which would reintroduce a host↔sandbox worktree-transport\n * problem that does not need solving here).\n *\n * `maxShots` is the DEPTH dial: the harness runs once; if it produced no change\n * (the worktree stays clean), the generator refines the prompt and retries, up\n * to `maxShots` times. A harness that already changed files returns on shot 1.\n */\n\nimport { spawnSync } from 'node:child_process'\nimport type { AnalystFinding } from '@tangle-network/agent-eval'\nimport { type LocalHarness, runLocalHarness } from '../mcp/local-harness'\nimport type { CandidateGenerator } from './improvement-driver'\n\nexport interface AgenticGeneratorOptions {\n /** Local coding harness to run in the worktree. Default `claude`. */\n harness?: LocalHarness\n /** Per-shot wall-clock timeout (ms). Default = `runLocalHarness` default (5m). */\n timeoutMs?: number\n /** Build the harness task prompt from the report + findings. Override for\n * domain phrasing; the default turns findings into a concrete coder task. */\n buildPrompt?: (args: { report: unknown; findings: AnalystFinding[] }) => string\n /** Test seam — inject the harness runner (defaults to `runLocalHarness`). */\n runHarness?: typeof runLocalHarness\n /** Test seam — inject the worktree-dirty check (defaults to `git status`). */\n isDirty?: (worktreePath: string) => boolean\n}\n\nexport function agenticGenerator(opts: AgenticGeneratorOptions = {}): CandidateGenerator {\n const harness = opts.harness ?? 'claude'\n const buildPrompt = opts.buildPrompt ?? defaultBuildPrompt\n const run = opts.runHarness ?? runLocalHarness\n const dirty = opts.isDirty ?? worktreeDirty\n\n return {\n kind: `agentic:${harness}`,\n async generate({ worktreePath, report, findings, maxShots, signal }) {\n let prompt = buildPrompt({ report, findings })\n const shots = Math.max(1, maxShots)\n\n for (let shot = 0; shot < shots; shot++) {\n if (signal.aborted) break\n await run({\n harness,\n cwd: worktreePath,\n taskPrompt: prompt,\n timeoutMs: opts.timeoutMs,\n signal,\n })\n // The worktree IS the signal: if the harness touched files, we have a\n // candidate. We don't trust the harness's stdout — we trust the diff.\n if (dirty(worktreePath)) {\n return { applied: true, summary: summarize(findings) }\n }\n // No change this shot — give the next attempt explicit feedback.\n prompt = refine(prompt)\n }\n return { applied: false, summary: '' }\n },\n }\n}\n\n/** Turn the analyst's findings (+ optional report) into a concrete coder task. */\nfunction defaultBuildPrompt(args: { report: unknown; findings: AnalystFinding[] }): string {\n const lines: string[] = [\n 'You are improving this codebase based on an evaluation analysis.',\n 'Make the smallest set of edits that addresses the findings below, then stop.',\n 'Do not change unrelated code. Do not commit — leave changes in the working tree.',\n '',\n 'Findings:',\n ]\n for (const f of args.findings) {\n const where = f.subject ? ` [${f.subject}]` : ''\n lines.push(`- (${f.severity})${where} ${f.claim}`)\n if (f.recommended_action) lines.push(` → ${f.recommended_action}`)\n }\n return lines.join('\\n')\n}\n\nfunction refine(prompt: string): string {\n return `${prompt}\\n\\nNOTE: your previous attempt left the working tree unchanged. Make the concrete file edits now.`\n}\n\n/** A one-line summary for the commit message, derived from the findings. */\nfunction summarize(findings: AnalystFinding[]): string {\n if (findings.length === 0) return 'agentic improvement'\n if (findings.length === 1) return `agentic: ${truncate(findings[0]!.claim, 64)}`\n return `agentic: ${findings.length} findings addressed`\n}\n\nfunction truncate(s: string, n: number): string {\n return s.length <= n ? s : `${s.slice(0, n - 1)}…`\n}\n\n/** Non-empty `git status --porcelain` ⇒ the harness changed the worktree.\n * Fails loud: the worktree is a fresh checkout, so a git error here means\n * something is genuinely broken (git missing, corrupt index, killed mid-run).\n * Folding that into `false` would silently discard a candidate and mask the\n * real failure — forbidden by the no-silent-fallbacks doctrine. */\nfunction worktreeDirty(worktreePath: string): boolean {\n const result = spawnSync('git', ['status', '--porcelain'], {\n cwd: worktreePath,\n encoding: 'utf-8',\n })\n if (result.error) {\n throw new Error(\n `agenticGenerator: git status failed to spawn in ${worktreePath}: ${result.error.message}`,\n )\n }\n if (result.status !== 0) {\n throw new Error(\n `agenticGenerator: git status exited ${result.status} in ${worktreePath}: ${result.stderr.trim()}`,\n )\n }\n return result.stdout.trim().length > 0\n}\n","/**\n * @experimental\n *\n * `improvementDriver` — the ONE reflective/agentic improvement driver for\n * agent-eval's improvement loop. It implements `ImprovementDriver` and owns\n * the candidate lifecycle (worktree create → generate → finalize/discard,\n * × populationSize); it delegates the only thing that genuinely varies — HOW\n * a candidate change is produced — to a pluggable `CandidateGenerator`.\n *\n * There is no separate \"analyst driver\" vs \"autoresearch driver\": those are\n * the SAME driver at two settings of a dial.\n * - cheap reflective path → `reflectiveGenerator` (shots=1, no sandbox;\n * applies pre-drafted patches)\n * - full agentic path → `agenticGenerator` (shots=N, sandbox runLoop;\n * an agent reads code + report and edits)\n * Both emit changes into a worktree the driver finalizes into a\n * `CodeSurface{ worktreeRef }` the loop measures on the holdout. See\n * agent-eval's `docs/design/self-improvement-engine.md`.\n */\n\nimport type { AnalystFinding } from '@tangle-network/agent-eval'\nimport type {\n CodeSurface,\n ImprovementDriver,\n LabeledScenarioStore,\n ProposeContext,\n WorktreeAdapter,\n} from '@tangle-network/agent-eval/campaign'\n\n/** The byte-producing seam — the ONE thing that differs between the cheap\n * reflective path and the full agentic path. A generator makes (uncommitted)\n * changes inside `worktreePath`; the driver commits them via the worktree\n * adapter's `finalize`. */\nexport interface CandidateGenerator {\n kind: string\n generate(args: {\n /** The candidate worktree — a fresh checkout of baseRef. Write changes here. */\n worktreePath: string\n /** Phase-2 research report (analyst findings + diff), opaque. */\n report: unknown\n /** Findings resolved from the report or the loop context. */\n findings: AnalystFinding[]\n /** Handle to all captured data, to ground the change. */\n dataset?: LabeledScenarioStore\n /** DEPTH: max iterations the generator may take (agentic uses this; the\n * reflective generator ignores it). */\n maxShots: number\n signal: AbortSignal\n }): Promise<{ applied: boolean; summary: string }>\n}\n\nexport interface ImprovementDriverOptions {\n worktree: WorktreeAdapter\n generator: CandidateGenerator\n /** Base ref candidate worktrees fork from. Default `main`. */\n baseRef?: string\n}\n\nexport function improvementDriver(\n opts: ImprovementDriverOptions,\n): ImprovementDriver<AnalystFinding> {\n const baseRef = opts.baseRef ?? 'main'\n\n return {\n kind: `improvement:${opts.generator.kind}`,\n async propose(ctx) {\n const findings = resolveFindings(ctx)\n // No signal to act on — propose nothing rather than spin up worktrees.\n if (findings.length === 0 && ctx.report === undefined) return []\n\n const surfaces: CodeSurface[] = []\n for (let i = 0; i < ctx.populationSize; i++) {\n if (ctx.signal.aborted) break\n const wt = await opts.worktree.create({\n baseRef,\n label: `${opts.generator.kind}-gen${ctx.generation}-cand${i}`,\n })\n // Once a worktree exists it MUST be accounted for: finalized into a\n // surface, or discarded. A throw from generate()/finalize() must not\n // leak the worktree + branch — discard best-effort, then rethrow loud.\n try {\n const { applied, summary } = await opts.generator.generate({\n worktreePath: wt.path,\n report: ctx.report,\n findings,\n dataset: ctx.dataset,\n maxShots: ctx.maxImprovementShots ?? 1,\n signal: ctx.signal,\n })\n if (!applied) {\n await opts.worktree.discard(wt)\n continue\n }\n surfaces.push(await opts.worktree.finalize(wt, summary))\n } catch (err) {\n // Best-effort cleanup; never mask the original failure.\n await opts.worktree.discard(wt).catch(() => {})\n throw err\n }\n }\n return surfaces\n },\n }\n}\n\n/** Phase-2 report carries `findings` when present; else fall back to the\n * loop's `ctx.findings`. The report is opaque to the substrate, so probe it\n * structurally. */\nfunction resolveFindings(ctx: ProposeContext<AnalystFinding>): AnalystFinding[] {\n const report = ctx.report\n if (report && typeof report === 'object' && 'findings' in report) {\n const f = (report as { findings: unknown }).findings\n if (Array.isArray(f) && f.length > 0) return f as AnalystFinding[]\n }\n return ctx.findings\n}\n","/**\n * @experimental\n *\n * `reflectiveGenerator` — the cheap, no-sandbox `CandidateGenerator`. It drafts\n * surface edits via the existing improvement adapter (`proposeFromFindings`,\n * one LLM patch per finding) and applies them as ONE coherent improvement into\n * the candidate worktree. `maxShots` is ignored — reflection is single-shot by\n * construction (the patches are already drafted).\n *\n * This is the `shots=1, sandbox=off` setting of the one improvement driver.\n * The `agenticGenerator` (sandbox runLoop) is the `shots=N, sandbox=on`\n * setting — both plug into the same `improvementDriver`.\n */\n\nimport { spawnSync } from 'node:child_process'\nimport type { SurfaceImprovementEdit } from '../agent/improvement-adapter'\nimport type { ImprovementAdapter } from '../analyst-loop/types'\nimport type { CandidateGenerator } from './improvement-driver'\n\nexport interface ReflectiveGeneratorOptions {\n improvementAdapter: ImprovementAdapter<SurfaceImprovementEdit>\n}\n\nexport function reflectiveGenerator(opts: ReflectiveGeneratorOptions): CandidateGenerator {\n return {\n kind: 'reflective',\n async generate({ worktreePath, findings }) {\n const batch = await opts.improvementAdapter.proposeFromFindings(findings)\n if (batch.edits.length === 0) return { applied: false, summary: '' }\n\n let applied = 0\n for (const edit of batch.edits) {\n if (applyPatch(edit.patch, worktreePath)) applied++\n }\n if (applied === 0) return { applied: false, summary: '' }\n\n const summary =\n batch.edits.length === 1\n ? batch.edits[0]!.summary\n : `analyst: ${applied} surface edit${applied === 1 ? '' : 's'}`\n return { applied: true, summary }\n },\n }\n}\n\n/** Mirror the improvement adapter's proven apply invocation, run inside the\n * candidate worktree (a fresh checkout of baseRef, so `-p0` paths match). */\nfunction applyPatch(patch: string, cwd: string): boolean {\n const result = spawnSync('git', ['apply', '--whitespace=fix', '-p0', '-'], {\n cwd,\n input: patch,\n encoding: 'utf-8',\n })\n return result.status === 0\n}\n"],"mappings":";;;;;;AAuBA,SAAS,iBAAiB;AAmBnB,SAAS,iBAAiB,OAAgC,CAAC,GAAuB;AACvF,QAAM,UAAU,KAAK,WAAW;AAChC,QAAM,cAAc,KAAK,eAAe;AACxC,QAAM,MAAM,KAAK,cAAc;AAC/B,QAAM,QAAQ,KAAK,WAAW;AAE9B,SAAO;AAAA,IACL,MAAM,WAAW,OAAO;AAAA,IACxB,MAAM,SAAS,EAAE,cAAc,QAAQ,UAAU,UAAU,OAAO,GAAG;AACnE,UAAI,SAAS,YAAY,EAAE,QAAQ,SAAS,CAAC;AAC7C,YAAM,QAAQ,KAAK,IAAI,GAAG,QAAQ;AAElC,eAAS,OAAO,GAAG,OAAO,OAAO,QAAQ;AACvC,YAAI,OAAO,QAAS;AACpB,cAAM,IAAI;AAAA,UACR;AAAA,UACA,KAAK;AAAA,UACL,YAAY;AAAA,UACZ,WAAW,KAAK;AAAA,UAChB;AAAA,QACF,CAAC;AAGD,YAAI,MAAM,YAAY,GAAG;AACvB,iBAAO,EAAE,SAAS,MAAM,SAAS,UAAU,QAAQ,EAAE;AAAA,QACvD;AAEA,iB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M,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAG,QAAO;AAAA,EAC/C;AACA,SAAO,IAAI;AACb;;;ACrGA,SAAS,aAAAA,kBAAiB;AASnB,SAAS,oBAAoB,MAAsD;AACxF,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,SAAS,EAAE,cAAc,SAAS,GAAG;AACzC,YAAM,QAAQ,MAAM,KAAK,mBAAmB,oBAAoB,QAAQ;AACxE,UAAI,MAAM,MAAM,WAAW,EAAG,QAAO,EAAE,SAAS,OAAO,SAAS,GAAG;AAEnE,UAAI,UAAU;AACd,iBAAW,QAAQ,MAAM,OAAO;AAC9B,YAAI,WAAW,KAAK,OAAO,YAAY,EAAG;AAAA,MAC5C;AACA,UAAI,YAAY,EAAG,QAAO,EAAE,SAAS,OAAO,SAAS,GAAG;AAExD,YAAM,UACJ,MAAM,MAAM,WAAW,IACnB,MAAM,MAAM,CAAC,EAAG,UAChB,YAAY,OAAO,gBAAgB,YAAY,IAAI,KAAK,GAAG;AACjE,aAAO,EAAE,SAAS,MAAM,QAAQ;AAAA,IAClC;AAAA,EACF;AACF;AAIA,SAAS,WAAW,OAAe,KAAsB;AACvD,QAAM,SAASA,WAAU,OAAO,CAAC,SAAS,oBAAoB,OAAO,GAAG,GAAG;AAAA,IACzE;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AACD,SAAO,OAAO,WAAW;AAC3B;","names":["spawnSync"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ChildProcess } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @experimental
|
|
5
|
+
*
|
|
6
|
+
* Subprocess wrappers for the local coding-harness CLIs installed in the
|
|
7
|
+
* sandbox image (claude-code, codex, opencode). Used by the in-process
|
|
8
|
+
* delegation executor (`createInProcessExecutor`) so a `delegate_code` call
|
|
9
|
+
* spawns a real harness on a real git worktree instead of provisioning a
|
|
10
|
+
* sibling sandbox.
|
|
11
|
+
*
|
|
12
|
+
* All harness invocations:
|
|
13
|
+
* - run with `cwd` set to the worktree
|
|
14
|
+
* - inherit env from the parent (the MCP server inside the sandbox has
|
|
15
|
+
* the harness's auth already)
|
|
16
|
+
* - capture stdout/stderr
|
|
17
|
+
* - support cancellation via AbortSignal
|
|
18
|
+
* - enforce a wall-clock timeout
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** Local coding harness available inside the sandbox. */
|
|
22
|
+
type LocalHarness = 'claude' | 'codex' | 'opencode';
|
|
23
|
+
/** @experimental */
|
|
24
|
+
interface RunLocalHarnessOptions {
|
|
25
|
+
harness: LocalHarness;
|
|
26
|
+
/** Working directory for the subprocess (typically a worktree path). */
|
|
27
|
+
cwd: string;
|
|
28
|
+
/** Prompt forwarded as the harness CLI's task argument. */
|
|
29
|
+
taskPrompt: string;
|
|
30
|
+
/** Wall-clock kill deadline (ms). Default 5 min. Subprocess SIGTERMed on expiry. */
|
|
31
|
+
timeoutMs?: number;
|
|
32
|
+
/** Caller cancellation. SIGTERM is sent on abort. */
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
/** Override env (defaults to inheriting from the parent). */
|
|
35
|
+
env?: NodeJS.ProcessEnv;
|
|
36
|
+
/**
|
|
37
|
+
* Test seam — inject a custom spawner so unit tests can mock the
|
|
38
|
+
* subprocess without touching the OS. Defaults to node's `child_process.spawn`.
|
|
39
|
+
*/
|
|
40
|
+
spawn?: (command: string, args: ReadonlyArray<string>, opts: {
|
|
41
|
+
cwd: string;
|
|
42
|
+
env: NodeJS.ProcessEnv;
|
|
43
|
+
stdio: 'pipe';
|
|
44
|
+
}) => ChildProcess;
|
|
45
|
+
}
|
|
46
|
+
/** @experimental */
|
|
47
|
+
interface LocalHarnessResult {
|
|
48
|
+
/** OS exit code. `null` when killed before exit. */
|
|
49
|
+
exitCode: number | null;
|
|
50
|
+
/** Concatenated stdout. */
|
|
51
|
+
stdout: string;
|
|
52
|
+
/** Concatenated stderr. */
|
|
53
|
+
stderr: string;
|
|
54
|
+
/** Set when the process exited via signal (timeout / abort). */
|
|
55
|
+
killedBySignal: NodeJS.Signals | null;
|
|
56
|
+
/** Wall-clock duration ms (spawn → exit). */
|
|
57
|
+
durationMs: number;
|
|
58
|
+
/** Set when timeoutMs elapsed before exit. */
|
|
59
|
+
timedOut: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Spawn a local coding harness CLI as a subprocess + collect its output.
|
|
63
|
+
*
|
|
64
|
+
* NOT responsible for parsing the harness's output or extracting a diff —
|
|
65
|
+
* the in-process executor's `streamPrompt` orchestrates `git diff` against
|
|
66
|
+
* the worktree after this resolves. This function is intentionally narrow:
|
|
67
|
+
* spawn, wait, capture, return.
|
|
68
|
+
*
|
|
69
|
+
* Fails loud — throws when:
|
|
70
|
+
* - `cwd` doesn't exist (subprocess emits ENOENT; surfaced as Error)
|
|
71
|
+
* - the harness binary is not on PATH (ENOENT)
|
|
72
|
+
*
|
|
73
|
+
* Does NOT throw when:
|
|
74
|
+
* - the subprocess exits non-zero (`result.exitCode` carries the code)
|
|
75
|
+
* - the subprocess is aborted / timed out (`result.killedBySignal` /
|
|
76
|
+
* `result.timedOut` carries the reason)
|
|
77
|
+
*
|
|
78
|
+
* @experimental
|
|
79
|
+
*/
|
|
80
|
+
declare function runLocalHarness(options: RunLocalHarnessOptions): Promise<LocalHarnessResult>;
|
|
81
|
+
|
|
82
|
+
export { type LocalHarness as L, type RunLocalHarnessOptions as R, type LocalHarnessResult as a, runLocalHarness as r };
|
package/dist/mcp/bin.js
CHANGED
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 } 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 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 const coderDelegate =\n wantCoder && executor\n ? createDefaultCoderDelegate({\n executor,\n fanoutHarnesses,\n maxConcurrency,\n })\n : undefined\n\n const researcherDelegate =\n wantResearcher && executor\n ? await loadResearcherDelegate(executor.client, maxConcurrency)\n : undefined\n\n const server = createMcpServer({ coderDelegate, researcherDelegate })\n\n process.on('SIGINT', () => {\n server.stop()\n process.exit(0)\n })\n process.on('SIGTERM', () => {\n server.stop()\n process.exit(0)\n })\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): 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 },\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 },\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":";;;;;;;;;;;;;;;;AAuCA,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,YAAQ,OAAO,MAAM,kDAA6C,SAAS,SAAS,CAAC;AAAA,CAAI;AAAA,EAC3F;AAEA,QAAM,gBACJ,aA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AAC;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 } 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 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 const coderDelegate =\n wantCoder && executor\n ? createDefaultCoderDelegate({\n executor,\n fanoutHarnesses,\n maxConcurrency,\n })\n : undefined\n\n const researcherDelegate =\n wantResearcher && executor\n ? await loadResearcherDelegate(executor.client, maxConcurrency)\n : undefined\n\n const server = createMcpServer({ coderDelegate, researcherDelegate })\n\n process.on('SIGINT', () => {\n server.stop()\n process.exit(0)\n })\n process.on('SIGTERM', () => {\n server.stop()\n process.exit(0)\n })\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): 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 },\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 },\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":";;;;;;;;;;;;;;;;;AAuCA,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,oBAAg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AAS,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,11 +1,14 @@
|
|
|
1
|
-
import { h as LoopSandboxClient, k as LoopTraceEmitter } from '../types-DmkRGTBn.js';
|
|
1
|
+
import { h as LoopSandboxClient, i as LoopSandboxPlacement, k as LoopTraceEmitter } from '../types-DmkRGTBn.js';
|
|
2
2
|
import { SandboxInstance } from '@tangle-network/sandbox';
|
|
3
3
|
import { CoderOutput } from '../profiles.js';
|
|
4
|
+
import { L as LocalHarness, r as runLocalHarness } from '../local-harness-KrdFTY5R.js';
|
|
5
|
+
export { a as LocalHarnessResult, R as RunLocalHarnessOptions } from '../local-harness-KrdFTY5R.js';
|
|
4
6
|
import { b as OtelExporter } from '../otel-export-B33Cy_60.js';
|
|
5
7
|
export { m as mcpToolsForRuntimeMcp, e as mcpToolsForRuntimeMcpSubset } from '../otel-export-B33Cy_60.js';
|
|
6
8
|
import '../runtime-run-D5ItCKl_.js';
|
|
7
9
|
import '../types-BFgFD_sl.js';
|
|
8
10
|
import '@tangle-network/agent-eval';
|
|
11
|
+
import 'node:child_process';
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* @experimental
|
|
@@ -419,6 +422,191 @@ declare class InMemoryFeedbackStore implements FeedbackStore {
|
|
|
419
422
|
*/
|
|
420
423
|
declare function eventToSnapshot(event: FeedbackEvent): DelegationFeedbackSnapshot;
|
|
421
424
|
|
|
425
|
+
/**
|
|
426
|
+
* @experimental
|
|
427
|
+
*
|
|
428
|
+
* Git worktree helpers for the in-process delegation executor. Each
|
|
429
|
+
* delegation runs in its own worktree so multiple parallel harness
|
|
430
|
+
* subprocesses (claude / codex / opencode in a 3-way fanout) don't clobber
|
|
431
|
+
* each other's edits on the shared workspace.
|
|
432
|
+
*
|
|
433
|
+
* Worktrees live under `<repoRoot>/.coder-variants/<runId>/`. After the
|
|
434
|
+
* harness exits + the diff is captured, the worktree is removed.
|
|
435
|
+
*
|
|
436
|
+
* All operations spawn `git` via `child_process.spawn` synchronously
|
|
437
|
+
* (via a `runGit` helper). Stays narrow on purpose: no working-tree
|
|
438
|
+
* staging, no commits, no rebases.
|
|
439
|
+
*/
|
|
440
|
+
/** @experimental */
|
|
441
|
+
interface WorktreeHandle {
|
|
442
|
+
/** Absolute path to the worktree directory. */
|
|
443
|
+
path: string;
|
|
444
|
+
/** SHA the worktree was created at. */
|
|
445
|
+
baseSha: string;
|
|
446
|
+
/** Branch name created for this worktree (typically `delegate/<runId>`). */
|
|
447
|
+
branch: string;
|
|
448
|
+
}
|
|
449
|
+
/** @experimental */
|
|
450
|
+
interface CreateWorktreeOptions {
|
|
451
|
+
/** Absolute path to the main git checkout. */
|
|
452
|
+
repoRoot: string;
|
|
453
|
+
/** Unique id for the worktree path + branch. Use the delegation run id. */
|
|
454
|
+
runId: string;
|
|
455
|
+
/** Parent directory the worktree lives under. Defaults to `.coder-variants`. */
|
|
456
|
+
variantsDir?: string;
|
|
457
|
+
/** Override the base ref (default `HEAD`). */
|
|
458
|
+
baseRef?: string;
|
|
459
|
+
/** Test seam — inject a custom git runner. */
|
|
460
|
+
runGit?: GitRunner;
|
|
461
|
+
}
|
|
462
|
+
/** @experimental */
|
|
463
|
+
interface DiffOptions {
|
|
464
|
+
/** Worktree to diff. */
|
|
465
|
+
worktree: WorktreeHandle;
|
|
466
|
+
/** What to compare against. Default `worktree.baseSha`. */
|
|
467
|
+
baseRef?: string;
|
|
468
|
+
/** Test seam. */
|
|
469
|
+
runGit?: GitRunner;
|
|
470
|
+
}
|
|
471
|
+
/** @experimental */
|
|
472
|
+
interface DiffResult {
|
|
473
|
+
patch: string;
|
|
474
|
+
stats: {
|
|
475
|
+
filesChanged: number;
|
|
476
|
+
insertions: number;
|
|
477
|
+
deletions: number;
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
/** @experimental */
|
|
481
|
+
interface RemoveWorktreeOptions {
|
|
482
|
+
worktree: WorktreeHandle;
|
|
483
|
+
repoRoot: string;
|
|
484
|
+
/** Force removal even if dirty (default true; the loser of a fanout has uncommitted changes). */
|
|
485
|
+
force?: boolean;
|
|
486
|
+
/** Test seam. */
|
|
487
|
+
runGit?: GitRunner;
|
|
488
|
+
}
|
|
489
|
+
/** Pluggable git runner (sync) — replaceable in tests. */
|
|
490
|
+
type GitRunner = (args: ReadonlyArray<string>, opts: {
|
|
491
|
+
cwd: string;
|
|
492
|
+
}) => {
|
|
493
|
+
stdout: string;
|
|
494
|
+
stderr: string;
|
|
495
|
+
exitCode: number;
|
|
496
|
+
};
|
|
497
|
+
/** @experimental */
|
|
498
|
+
declare function createWorktree(options: CreateWorktreeOptions): Promise<WorktreeHandle>;
|
|
499
|
+
/** @experimental */
|
|
500
|
+
declare function captureWorktreeDiff(options: DiffOptions): Promise<DiffResult>;
|
|
501
|
+
/** @experimental */
|
|
502
|
+
declare function removeWorktree(options: RemoveWorktreeOptions): Promise<void>;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* @experimental
|
|
506
|
+
*
|
|
507
|
+
* In-process delegation executor — when `agent-runtime-mcp` is running
|
|
508
|
+
* inside a sandbox whose image carries the local coding-harness CLIs
|
|
509
|
+
* (claude / codex / opencode), delegations spawn the harness AS A
|
|
510
|
+
* SUBPROCESS against a git worktree on the SAME filesystem instead of
|
|
511
|
+
* provisioning a sibling sandbox.
|
|
512
|
+
*
|
|
513
|
+
* Why: zero provisioning latency, worker diffs land in-place, multi-harness
|
|
514
|
+
* fanout = N parallel subprocesses in N parallel worktrees.
|
|
515
|
+
*
|
|
516
|
+
* Selection:
|
|
517
|
+
* - env `AGENT_RUNTIME_IN_SANDBOX=1` (set by the parent harness at MCP
|
|
518
|
+
* server launch) → in-process executor
|
|
519
|
+
* - env `TANGLE_FLEET_ID=...` → fleet executor (Phase 2.5)
|
|
520
|
+
* - neither → sibling sandbox executor (default)
|
|
521
|
+
*
|
|
522
|
+
* Multi-harness rotation: pass `harnesses: ['claude', 'codex', 'opencode']`
|
|
523
|
+
* to round-robin across calls. A `runLoop` + `FanoutVote(n: 3)` against this
|
|
524
|
+
* executor produces three parallel iterations, each running a different
|
|
525
|
+
* harness on its own worktree.
|
|
526
|
+
*
|
|
527
|
+
* Architecture:
|
|
528
|
+
*
|
|
529
|
+
* client.create() → returns a fake SandboxInstance whose streamPrompt:
|
|
530
|
+
* 1. createWorktree() — git worktree add /workspace/.coder-variants/<id>
|
|
531
|
+
* 2. runLocalHarness() — spawn claude/codex/opencode subprocess
|
|
532
|
+
* 3. captureWorktreeDiff() — git diff HEAD → patch + stats
|
|
533
|
+
* 4. run testCmd + typecheckCmd if specified (the executor doesn't
|
|
534
|
+
* own these — caller wires via task-extractor callback)
|
|
535
|
+
* 5. emit ONE SandboxEvent { type: 'result', data: { result: CoderOutput } }
|
|
536
|
+
* 6. removeWorktree() in finally
|
|
537
|
+
*/
|
|
538
|
+
|
|
539
|
+
/** @experimental */
|
|
540
|
+
interface InProcessExecutorOptions {
|
|
541
|
+
/**
|
|
542
|
+
* Absolute path to the git repo (the workspace inside the sandbox). The
|
|
543
|
+
* executor creates worktrees under `<repoRoot>/.coder-variants/`.
|
|
544
|
+
*/
|
|
545
|
+
repoRoot: string;
|
|
546
|
+
/**
|
|
547
|
+
* Harnesses to round-robin across calls. With one entry every delegation
|
|
548
|
+
* uses that harness; with three you get fanout diversity for free.
|
|
549
|
+
* Default `['claude']`.
|
|
550
|
+
*/
|
|
551
|
+
harnesses?: ReadonlyArray<LocalHarness>;
|
|
552
|
+
/**
|
|
553
|
+
* Optional per-delegation test command. Run with `cwd = worktree.path`
|
|
554
|
+
* after the harness exits. The exit code populates
|
|
555
|
+
* `CoderOutput.testResult.passed`.
|
|
556
|
+
*/
|
|
557
|
+
testCmd?: string;
|
|
558
|
+
/**
|
|
559
|
+
* Optional per-delegation typecheck command. Same shape as `testCmd`.
|
|
560
|
+
*/
|
|
561
|
+
typecheckCmd?: string;
|
|
562
|
+
/** Wall-clock cap per harness subprocess (ms). Default 5min. */
|
|
563
|
+
harnessTimeoutMs?: number;
|
|
564
|
+
/** Wall-clock cap per test/typecheck subprocess (ms). Default 2min. */
|
|
565
|
+
postCheckTimeoutMs?: number;
|
|
566
|
+
/** Test seam — override the git runner used by the worktree helpers. */
|
|
567
|
+
runGit?: GitRunner;
|
|
568
|
+
/**
|
|
569
|
+
* Test seam — override the harness runner. Defaults to spawning the real
|
|
570
|
+
* CLI via `runLocalHarness`. Tests inject a stub that returns a scripted
|
|
571
|
+
* `LocalHarnessResult`.
|
|
572
|
+
*/
|
|
573
|
+
runHarness?: typeof runLocalHarness;
|
|
574
|
+
/**
|
|
575
|
+
* Test seam — override the post-check runner. Defaults to spawning the
|
|
576
|
+
* configured `testCmd` / `typecheckCmd` via `child_process.spawn`.
|
|
577
|
+
*/
|
|
578
|
+
runPostCheck?: (cmd: string, cwd: string, signal?: AbortSignal) => Promise<{
|
|
579
|
+
exitCode: number;
|
|
580
|
+
stdout: string;
|
|
581
|
+
stderr: string;
|
|
582
|
+
}>;
|
|
583
|
+
}
|
|
584
|
+
/** @experimental */
|
|
585
|
+
interface InProcessExecutorDescribePlacement extends LoopSandboxPlacement {
|
|
586
|
+
/**
|
|
587
|
+
* Worktree path in the parent sandbox's filesystem. Set so trace
|
|
588
|
+
* consumers can correlate dispatch events with on-disk artifacts after
|
|
589
|
+
* the worker exits.
|
|
590
|
+
*/
|
|
591
|
+
worktreePath?: string;
|
|
592
|
+
/** Which harness handled this delegation. */
|
|
593
|
+
harness?: LocalHarness;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Build an in-process executor.
|
|
597
|
+
*
|
|
598
|
+
* Returns a {@link DelegationExecutor} whose `client.create()` returns a
|
|
599
|
+
* minimal "virtual" SandboxInstance — the kernel calls `streamPrompt(msg)`
|
|
600
|
+
* on it, which runs the local harness on a worktree and emits one
|
|
601
|
+
* `result` event whose `data.result` is a `CoderOutput`-shaped record.
|
|
602
|
+
*
|
|
603
|
+
* Pairs with `coderProfile`'s event parser (it walks the event list
|
|
604
|
+
* back-to-front for the first `type === 'result'`).
|
|
605
|
+
*
|
|
606
|
+
* @experimental
|
|
607
|
+
*/
|
|
608
|
+
declare function createInProcessExecutor(options: InProcessExecutorOptions): DelegationExecutor;
|
|
609
|
+
|
|
422
610
|
/**
|
|
423
611
|
* @experimental
|
|
424
612
|
*
|
|
@@ -1006,4 +1194,4 @@ declare function createPropagatingTraceEmitter(ctx: TraceContext): {
|
|
|
1006
1194
|
*/
|
|
1007
1195
|
declare function traceContextToEnv(ctx: TraceContext): Record<string, string>;
|
|
1008
1196
|
|
|
1009
|
-
export { type CoderDelegate, type CreateDefaultCoderDelegateOptions, 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, type DelegateCodeArgs, type DelegateCodeConfig, type DelegateCodeResult, type DelegateFeedbackArgs, type DelegateFeedbackResult, type DelegateResearchArgs, type DelegateResearchConfig, type DelegateResearchResult, type DelegateRunCtx, type DelegationError, type DelegationExecutor, type DelegationFeedbackSnapshot, type DelegationHistoryArgs, type DelegationHistoryEntry, type DelegationHistoryResult, type DelegationProfile, type DelegationProgress, type DelegationRecord, type DelegationResultPayload, type DelegationStatus, type DelegationStatusArgs, type DelegationStatusResult, DelegationTaskQueue, type DelegationTaskQueueOptions, type DetectExecutorArgs, type FeedbackEvent, type FeedbackRating, type FeedbackRefersTo, type FeedbackStore, type FleetHandle, type FleetWorkspaceExecutorOptions, InMemoryFeedbackStore, type JsonRpcMessage, type JsonRpcResponse, type McpServer, type McpServerOptions, type McpToolDescriptor, type McpTransport, type ResearchOutputShape, type ResearchSource, type ResearcherDelegate, type SiblingSandboxExecutorOptions, type SubmitInput, type SubmitOutput, type TraceContext, createDefaultCoderDelegate, createDelegateCodeHandler, createDelegateFeedbackHandler, createDelegateResearchHandler, createDelegationHistoryHandler, createDelegationStatusHandler, createFleetWorkspaceExecutor, createInProcessTransport, createMcpServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, detectExecutor, eventToSnapshot, hashIdempotencyInput, readTraceContextFromEnv, traceContextToEnv, validateDelegateCodeArgs, validateDelegateFeedbackArgs, validateDelegateResearchArgs, validateDelegationHistoryArgs, validateDelegationStatusArgs };
|
|
1197
|
+
export { type CoderDelegate, type CreateDefaultCoderDelegateOptions, 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, type DelegateCodeArgs, type DelegateCodeConfig, type DelegateCodeResult, type DelegateFeedbackArgs, type DelegateFeedbackResult, type DelegateResearchArgs, type DelegateResearchConfig, type DelegateResearchResult, type DelegateRunCtx, type DelegationError, type DelegationExecutor, type DelegationFeedbackSnapshot, type DelegationHistoryArgs, type DelegationHistoryEntry, type DelegationHistoryResult, type DelegationProfile, type DelegationProgress, type DelegationRecord, type DelegationResultPayload, type DelegationStatus, type DelegationStatusArgs, type DelegationStatusResult, DelegationTaskQueue, type DelegationTaskQueueOptions, type DetectExecutorArgs, type DiffOptions, type DiffResult, type FeedbackEvent, type FeedbackRating, type FeedbackRefersTo, type FeedbackStore, type FleetHandle, type FleetWorkspaceExecutorOptions, type GitRunner, InMemoryFeedbackStore, type InProcessExecutorDescribePlacement, type InProcessExecutorOptions, type JsonRpcMessage, type JsonRpcResponse, LocalHarness, type McpServer, type McpServerOptions, type McpToolDescriptor, type McpTransport, type RemoveWorktreeOptions, type ResearchOutputShape, type ResearchSource, type ResearcherDelegate, type SiblingSandboxExecutorOptions, type SubmitInput, type SubmitOutput, type TraceContext, type WorktreeHandle, captureWorktreeDiff, createDefaultCoderDelegate, createDelegateCodeHandler, createDelegateFeedbackHandler, createDelegateResearchHandler, createDelegationHistoryHandler, createDelegationStatusHandler, createFleetWorkspaceExecutor, createInProcessExecutor, createInProcessTransport, createMcpServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, createWorktree, detectExecutor, eventToSnapshot, hashIdempotencyInput, readTraceContextFromEnv, removeWorktree, runLocalHarness, traceContextToEnv, validateDelegateCodeArgs, validateDelegateFeedbackArgs, validateDelegateResearchArgs, validateDelegationHistoryArgs, validateDelegationStatusArgs };
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
loopEventToOtelSpan,
|
|
4
|
-
mcpToolsForRuntimeMcp,
|
|
5
|
-
mcpToolsForRuntimeMcpSubset
|
|
6
|
-
} from "../chunk-QZEDHTT2.js";
|
|
7
|
-
import {
|
|
2
|
+
captureWorktreeDiff,
|
|
8
3
|
createDefaultCoderDelegate,
|
|
9
4
|
createFleetWorkspaceExecutor,
|
|
5
|
+
createInProcessExecutor,
|
|
10
6
|
createInProcessTransport,
|
|
11
7
|
createMcpServer,
|
|
12
8
|
createSiblingSandboxExecutor,
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
createWorktree,
|
|
10
|
+
detectExecutor,
|
|
11
|
+
removeWorktree
|
|
12
|
+
} from "../chunk-ZJACJZF7.js";
|
|
13
|
+
import {
|
|
14
|
+
createOtelExporter,
|
|
15
|
+
loopEventToOtelSpan,
|
|
16
|
+
mcpToolsForRuntimeMcp,
|
|
17
|
+
mcpToolsForRuntimeMcpSubset
|
|
18
|
+
} from "../chunk-QZEDHTT2.js";
|
|
15
19
|
import {
|
|
16
20
|
DELEGATE_CODE_DESCRIPTION,
|
|
17
21
|
DELEGATE_CODE_INPUT_SCHEMA,
|
|
@@ -43,6 +47,9 @@ import {
|
|
|
43
47
|
validateDelegationHistoryArgs,
|
|
44
48
|
validateDelegationStatusArgs
|
|
45
49
|
} from "../chunk-UNQM6XQO.js";
|
|
50
|
+
import {
|
|
51
|
+
runLocalHarness
|
|
52
|
+
} from "../chunk-GLR25NG7.js";
|
|
46
53
|
import "../chunk-TZ53F7M7.js";
|
|
47
54
|
import "../chunk-CBQVID7G.js";
|
|
48
55
|
import "../chunk-URDSRUPQ.js";
|
|
@@ -98,6 +105,7 @@ export {
|
|
|
98
105
|
DELEGATION_STATUS_TOOL_NAME,
|
|
99
106
|
DelegationTaskQueue,
|
|
100
107
|
InMemoryFeedbackStore,
|
|
108
|
+
captureWorktreeDiff,
|
|
101
109
|
createDefaultCoderDelegate,
|
|
102
110
|
createDelegateCodeHandler,
|
|
103
111
|
createDelegateFeedbackHandler,
|
|
@@ -105,16 +113,20 @@ export {
|
|
|
105
113
|
createDelegationHistoryHandler,
|
|
106
114
|
createDelegationStatusHandler,
|
|
107
115
|
createFleetWorkspaceExecutor,
|
|
116
|
+
createInProcessExecutor,
|
|
108
117
|
createInProcessTransport,
|
|
109
118
|
createMcpServer,
|
|
110
119
|
createPropagatingTraceEmitter,
|
|
111
120
|
createSiblingSandboxExecutor,
|
|
121
|
+
createWorktree,
|
|
112
122
|
detectExecutor,
|
|
113
123
|
eventToSnapshot,
|
|
114
124
|
hashIdempotencyInput,
|
|
115
125
|
mcpToolsForRuntimeMcp,
|
|
116
126
|
mcpToolsForRuntimeMcpSubset,
|
|
117
127
|
readTraceContextFromEnv,
|
|
128
|
+
removeWorktree,
|
|
129
|
+
runLocalHarness,
|
|
118
130
|
traceContextToEnv,
|
|
119
131
|
validateDelegateCodeArgs,
|
|
120
132
|
validateDelegateFeedbackArgs,
|
package/dist/mcp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/trace-propagation.ts"],"sourcesContent":["/**\n * @experimental\n *\n * Trace context propagation for MCP subprocess.\n *\n * When the MCP server is launched as a child process by a sandbox harness,\n * the parent passes trace context via environment variables:\n *\n * TRACE_ID=<current-run-trace-id>\n * PARENT_SPAN_ID=<span-that-dispatched-the-delegation>\n *\n * The MCP server reads these at startup and uses them as the root of its\n * internal trace tree. All spans emitted by `runLoop` invocations inside\n * the MCP are children of the parent's delegation span.\n *\n * When these env vars are absent, the MCP generates a fresh trace root —\n * the server operates standalone without trace joining.\n */\n\nimport type { LoopTraceEmitter, LoopTraceEvent } from '../loops/types'\nimport type { OtelExporter } from '../otel-export'\nimport { createOtelExporter, loopEventToOtelSpan } from '../otel-export'\n\nexport interface TraceContext {\n /** Trace id inherited from the parent process, or a fresh one. */\n traceId: string\n /** Parent span id from the delegation that launched this MCP server. */\n parentSpanId?: string\n}\n\n/**\n * Read trace context from the process environment.\n * Returns a context with inherited ids or a freshly generated root.\n */\nexport function readTraceContextFromEnv(): TraceContext {\n const traceId = process.env.TRACE_ID || generateTraceId()\n const parentSpanId = process.env.PARENT_SPAN_ID || undefined\n return { traceId, parentSpanId }\n}\n\n/**\n * Create a LoopTraceEmitter that:\n * 1. Parents all spans under the inherited PARENT_SPAN_ID.\n * 2. Exports spans to OTEL when OTEL_EXPORTER_OTLP_ENDPOINT is set.\n *\n * Returns both the emitter and the optional exporter handle for shutdown.\n */\nexport function createPropagatingTraceEmitter(ctx: TraceContext): {\n emitter: LoopTraceEmitter\n exporter: OtelExporter | undefined\n context: TraceContext\n} {\n const exporter = createOtelExporter()\n\n const emitter: LoopTraceEmitter = {\n emit(event: LoopTraceEvent) {\n if (!exporter) return\n const span = loopEventToOtelSpan(event, ctx.traceId, ctx.parentSpanId)\n exporter.exportSpan(span)\n },\n }\n\n return { emitter, exporter, context: ctx }\n}\n\n/**\n * Build env vars to pass to a child MCP subprocess so it inherits the\n * current trace context.\n */\nexport function traceContextToEnv(ctx: TraceContext): Record<string, string> {\n const env: Record<string, string> = { TRACE_ID: ctx.traceId }\n if (ctx.parentSpanId) env.PARENT_SPAN_ID = ctx.parentSpanId\n return env\n}\n\nfunction generateTraceId(): string {\n const bytes = new Uint8Array(16)\n if (typeof globalThis.crypto?.getRandomValues === 'function') {\n globalThis.crypto.getRandomValues(bytes)\n } else {\n for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256)\n }\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/trace-propagation.ts"],"sourcesContent":["/**\n * @experimental\n *\n * Trace context propagation for MCP subprocess.\n *\n * When the MCP server is launched as a child process by a sandbox harness,\n * the parent passes trace context via environment variables:\n *\n * TRACE_ID=<current-run-trace-id>\n * PARENT_SPAN_ID=<span-that-dispatched-the-delegation>\n *\n * The MCP server reads these at startup and uses them as the root of its\n * internal trace tree. All spans emitted by `runLoop` invocations inside\n * the MCP are children of the parent's delegation span.\n *\n * When these env vars are absent, the MCP generates a fresh trace root —\n * the server operates standalone without trace joining.\n */\n\nimport type { LoopTraceEmitter, LoopTraceEvent } from '../loops/types'\nimport type { OtelExporter } from '../otel-export'\nimport { createOtelExporter, loopEventToOtelSpan } from '../otel-export'\n\nexport interface TraceContext {\n /** Trace id inherited from the parent process, or a fresh one. */\n traceId: string\n /** Parent span id from the delegation that launched this MCP server. */\n parentSpanId?: string\n}\n\n/**\n * Read trace context from the process environment.\n * Returns a context with inherited ids or a freshly generated root.\n */\nexport function readTraceContextFromEnv(): TraceContext {\n const traceId = process.env.TRACE_ID || generateTraceId()\n const parentSpanId = process.env.PARENT_SPAN_ID || undefined\n return { traceId, parentSpanId }\n}\n\n/**\n * Create a LoopTraceEmitter that:\n * 1. Parents all spans under the inherited PARENT_SPAN_ID.\n * 2. Exports spans to OTEL when OTEL_EXPORTER_OTLP_ENDPOINT is set.\n *\n * Returns both the emitter and the optional exporter handle for shutdown.\n */\nexport function createPropagatingTraceEmitter(ctx: TraceContext): {\n emitter: LoopTraceEmitter\n exporter: OtelExporter | undefined\n context: TraceContext\n} {\n const exporter = createOtelExporter()\n\n const emitter: LoopTraceEmitter = {\n emit(event: LoopTraceEvent) {\n if (!exporter) return\n const span = loopEventToOtelSpan(event, ctx.traceId, ctx.parentSpanId)\n exporter.exportSpan(span)\n },\n }\n\n return { emitter, exporter, context: ctx }\n}\n\n/**\n * Build env vars to pass to a child MCP subprocess so it inherits the\n * current trace context.\n */\nexport function traceContextToEnv(ctx: TraceContext): Record<string, string> {\n const env: Record<string, string> = { TRACE_ID: ctx.traceId }\n if (ctx.parentSpanId) env.PARENT_SPAN_ID = ctx.parentSpanId\n return env\n}\n\nfunction generateTraceId(): string {\n const bytes = new Uint8Array(16)\n if (typeof globalThis.crypto?.getRandomValues === 'function') {\n globalThis.crypto.getRandomValues(bytes)\n } else {\n for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256)\n }\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,SAAS,0BAAwC;AACtD,QAAM,UAAU,QAAQ,IAAI,YAAY,gBAAgB;AACxD,QAAM,eAAe,QAAQ,IAAI,kBAAkB;AACnD,SAAO,EAAE,SAAS,aAAa;AACjC;AASO,SAAS,8BAA8B,KAI5C;AACA,QAAM,WAAW,mBAAmB;AAEpC,QAAM,UAA4B;AAAA,IAChC,KAAK,OAAuB;AAC1B,UAAI,CAAC,SAAU;AACf,YAAM,OAAO,oBAAoB,OAAO,IAAI,SAAS,IAAI,YAAY;AACrE,eAAS,WAAW,IAAI;AAAA,IAC1B;AAAA,EACF;AAEA,SAAO,EAAE,SAAS,UAAU,SAAS,IAAI;AAC3C;AAMO,SAAS,kBAAkB,KAA2C;AAC3E,QAAM,MAA8B,EAAE,UAAU,IAAI,QAAQ;AAC5D,MAAI,IAAI,aAAc,KAAI,iBAAiB,IAAI;AAC/C,SAAO;AACT;AAEA,SAAS,kBAA0B;AACjC,QAAM,QAAQ,IAAI,WAAW,EAAE;AAC/B,MAAI,OAAO,WAAW,QAAQ,oBAAoB,YAAY;AAC5D,eAAW,OAAO,gBAAgB,KAAK;AAAA,EACzC,OAAO;AACL,aAAS,IAAI,GAAG,IAAI,IAAI,IAAK,OAAM,CAAC,IAAI,KAAK,MAAM,KAAK,OAAO,IAAI,GAAG;AAAA,EACxE;AACA,SAAO,MAAM,KAAK,KAAK,EACpB,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAC1C,KAAK,EAAE;AACZ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"description": "Reusable runtime lifecycle for domain-specific agents.",
|
|
5
5
|
"homepage": "https://github.com/tangle-network/agent-runtime#readme",
|
|
6
6
|
"repository": {
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"import": "./dist/analyst-loop.js",
|
|
30
30
|
"default": "./dist/analyst-loop.js"
|
|
31
31
|
},
|
|
32
|
+
"./improvement": {
|
|
33
|
+
"types": "./dist/improvement.d.ts",
|
|
34
|
+
"import": "./dist/improvement.js",
|
|
35
|
+
"default": "./dist/improvement.js"
|
|
36
|
+
},
|
|
32
37
|
"./agent": {
|
|
33
38
|
"types": "./dist/agent.d.ts",
|
|
34
39
|
"import": "./dist/agent.js",
|
|
@@ -60,37 +65,48 @@
|
|
|
60
65
|
"publishConfig": {
|
|
61
66
|
"access": "public"
|
|
62
67
|
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsup",
|
|
70
|
+
"dev": "tsup --watch",
|
|
71
|
+
"prepare": "tsup",
|
|
72
|
+
"test": "vitest run",
|
|
73
|
+
"test:watch": "vitest",
|
|
74
|
+
"lint": "biome check src tests examples",
|
|
75
|
+
"lint:fix": "biome check --write src tests examples",
|
|
76
|
+
"typecheck": "tsc --noEmit"
|
|
77
|
+
},
|
|
63
78
|
"dependencies": {
|
|
64
|
-
"@tangle-network/agent-eval": "^0.
|
|
79
|
+
"@tangle-network/agent-eval": "^0.40.2"
|
|
65
80
|
},
|
|
66
81
|
"devDependencies": {
|
|
67
82
|
"@biomejs/biome": "^2.4.0",
|
|
68
|
-
"@tangle-network/sandbox": "^0.
|
|
83
|
+
"@tangle-network/sandbox": "^0.3.0",
|
|
69
84
|
"@types/node": "^25.6.0",
|
|
70
85
|
"tsup": "^8.0.0",
|
|
71
86
|
"typescript": "^5.7.0",
|
|
72
87
|
"vitest": "^3.0.0"
|
|
73
88
|
},
|
|
89
|
+
"pnpm": {
|
|
90
|
+
"minimumReleaseAge": 4320,
|
|
91
|
+
"minimumReleaseAgeExclude": [
|
|
92
|
+
"@tangle-network/agent-eval"
|
|
93
|
+
],
|
|
94
|
+
"onlyBuiltDependencies": [
|
|
95
|
+
"esbuild"
|
|
96
|
+
]
|
|
97
|
+
},
|
|
74
98
|
"engines": {
|
|
75
99
|
"node": ">=20"
|
|
76
100
|
},
|
|
77
101
|
"license": "MIT",
|
|
102
|
+
"packageManager": "pnpm@10.28.0",
|
|
78
103
|
"peerDependencies": {
|
|
79
104
|
"@tangle-network/agent-knowledge": ">=1.3.0 <2.0.0",
|
|
80
|
-
"@tangle-network/sandbox": ">=0.1.2 <0.
|
|
105
|
+
"@tangle-network/sandbox": ">=0.1.2 <0.4.0"
|
|
81
106
|
},
|
|
82
107
|
"peerDependenciesMeta": {
|
|
83
108
|
"@tangle-network/agent-knowledge": {
|
|
84
109
|
"optional": true
|
|
85
110
|
}
|
|
86
|
-
},
|
|
87
|
-
"scripts": {
|
|
88
|
-
"build": "tsup",
|
|
89
|
-
"dev": "tsup --watch",
|
|
90
|
-
"test": "vitest run",
|
|
91
|
-
"test:watch": "vitest",
|
|
92
|
-
"lint": "biome check src tests examples",
|
|
93
|
-
"lint:fix": "biome check --write src tests examples",
|
|
94
|
-
"typecheck": "tsc --noEmit"
|
|
95
111
|
}
|
|
96
|
-
}
|
|
112
|
+
}
|