@tangle-network/agent-runtime 0.55.0 → 0.56.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/dist/agent.js +3 -1
- package/dist/agent.js.map +1 -1
- package/dist/{chunk-JTH2FPCK.js → chunk-4H2FML7G.js} +392 -11
- package/dist/chunk-4H2FML7G.js.map +1 -0
- package/dist/{chunk-2BDXWZUC.js → chunk-6XKXWA7H.js} +2 -2
- package/dist/chunk-6XKXWA7H.js.map +1 -0
- package/dist/{chunk-KADIJAD4.js → chunk-7QYOXFCD.js} +75 -60
- package/dist/chunk-7QYOXFCD.js.map +1 -0
- package/dist/{chunk-ZMPQEPQ7.js → chunk-EXIV2C72.js} +10 -89
- package/dist/chunk-EXIV2C72.js.map +1 -0
- package/dist/{chunk-KJH62YEK.js → chunk-F5XQA43K.js} +2 -2
- package/dist/{chunk-A73RADPB.js → chunk-G4NIVG34.js} +6 -6
- package/dist/chunk-G4NIVG34.js.map +1 -0
- package/dist/{chunk-H2KWSZAN.js → chunk-GLMFBUKT.js} +27 -6
- package/dist/chunk-GLMFBUKT.js.map +1 -0
- package/dist/{coder-CEkUFv8h.d.ts → coder-COuOK8h8.d.ts} +51 -2
- package/dist/{coordination-BMzskrUR.d.ts → coordination-DWNGqygr.d.ts} +81 -2
- package/dist/{delegates-BPLIl8EC.d.ts → delegates-D9o5_VFj.d.ts} +17 -1
- package/dist/improvement.d.ts +1 -1
- package/dist/improvement.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/{local-harness-KrdFTY5R.d.ts → local-harness-BE_h8szs.d.ts} +11 -0
- package/dist/{loop-runner-bin-BGpVVyXp.d.ts → loop-runner-bin-CN2Se3jB.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +3 -3
- package/dist/loop-runner-bin.js +5 -4
- package/dist/loops.d.ts +6 -4
- package/dist/loops.js +13 -3
- package/dist/mcp/bin.js +7 -7
- package/dist/mcp/index.d.ts +8 -87
- package/dist/mcp/index.js +11 -11
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +4 -2
- package/dist/profiles.js.map +1 -1
- package/dist/runtime.d.ts +281 -5
- package/dist/runtime.js +13 -3
- package/dist/workflow.js +3 -1
- package/dist/workflow.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2BDXWZUC.js.map +0 -1
- package/dist/chunk-A73RADPB.js.map +0 -1
- package/dist/chunk-H2KWSZAN.js.map +0 -1
- package/dist/chunk-JTH2FPCK.js.map +0 -1
- package/dist/chunk-KADIJAD4.js.map +0 -1
- package/dist/chunk-ZMPQEPQ7.js.map +0 -1
- /package/dist/{chunk-KJH62YEK.js.map → chunk-F5XQA43K.js.map} +0 -0
|
@@ -3,17 +3,36 @@ import { spawn } from "child_process";
|
|
|
3
3
|
var HARNESS_INVOCATIONS = {
|
|
4
4
|
claude: {
|
|
5
5
|
command: "claude",
|
|
6
|
-
buildArgs: (taskPrompt) => ["--headless", "-p", taskPrompt]
|
|
6
|
+
buildArgs: (taskPrompt) => ["--headless", "-p", taskPrompt],
|
|
7
|
+
modelArgs: (model) => ["-m", model]
|
|
7
8
|
},
|
|
8
9
|
codex: {
|
|
9
10
|
command: "codex",
|
|
10
|
-
buildArgs: (taskPrompt) => ["run", taskPrompt]
|
|
11
|
+
buildArgs: (taskPrompt) => ["run", taskPrompt],
|
|
12
|
+
modelArgs: (model) => ["-m", model]
|
|
11
13
|
},
|
|
12
14
|
opencode: {
|
|
13
15
|
command: "opencode",
|
|
14
|
-
buildArgs: (taskPrompt) => ["run", taskPrompt]
|
|
16
|
+
buildArgs: (taskPrompt) => ["run", taskPrompt],
|
|
17
|
+
modelArgs: (model) => ["-m", model]
|
|
15
18
|
}
|
|
16
19
|
};
|
|
20
|
+
function harnessInvocation(harness, profile, taskPrompt) {
|
|
21
|
+
const invocation = HARNESS_INVOCATIONS[harness];
|
|
22
|
+
if (!invocation) {
|
|
23
|
+
throw new Error(`harnessInvocation: unknown harness ${String(harness)}`);
|
|
24
|
+
}
|
|
25
|
+
const systemPrompt = profile.prompt?.systemPrompt;
|
|
26
|
+
const composedPrompt = typeof systemPrompt === "string" && systemPrompt.trim().length > 0 ? `${systemPrompt}
|
|
27
|
+
|
|
28
|
+
${taskPrompt}` : taskPrompt;
|
|
29
|
+
const args = invocation.buildArgs(composedPrompt);
|
|
30
|
+
const model = profile.model?.default;
|
|
31
|
+
if (typeof model === "string" && model.length > 0) {
|
|
32
|
+
args.push(...invocation.modelArgs(model));
|
|
33
|
+
}
|
|
34
|
+
return { command: invocation.command, args };
|
|
35
|
+
}
|
|
17
36
|
var DEFAULT_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
18
37
|
function runLocalHarness(options) {
|
|
19
38
|
const { harness, cwd, taskPrompt } = options;
|
|
@@ -25,11 +44,12 @@ function runLocalHarness(options) {
|
|
|
25
44
|
return Promise.reject(new Error(`runLocalHarness: unknown harness ${String(harness)}`));
|
|
26
45
|
}
|
|
27
46
|
const startedAt = Date.now();
|
|
28
|
-
const
|
|
47
|
+
const command = options.invocation?.command ?? invocation.command;
|
|
48
|
+
const args = options.invocation ? [...options.invocation.args] : invocation.buildArgs(taskPrompt);
|
|
29
49
|
return new Promise((resolve, reject) => {
|
|
30
50
|
let child;
|
|
31
51
|
try {
|
|
32
|
-
child = spawnImpl(
|
|
52
|
+
child = spawnImpl(command, args, { cwd, env, stdio: "pipe" });
|
|
33
53
|
} catch (err) {
|
|
34
54
|
reject(err instanceof Error ? err : new Error(String(err)));
|
|
35
55
|
return;
|
|
@@ -88,6 +108,7 @@ function runLocalHarness(options) {
|
|
|
88
108
|
}
|
|
89
109
|
|
|
90
110
|
export {
|
|
111
|
+
harnessInvocation,
|
|
91
112
|
runLocalHarness
|
|
92
113
|
};
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-GLMFBUKT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mcp/local-harness.ts"],"sourcesContent":["/**\n * @experimental\n *\n * Subprocess wrappers for the local coding-harness CLIs installed in the\n * sandbox image (claude-code, codex, opencode). Used by the in-process\n * delegation executor (`createInProcessExecutor`) so a `delegate_code` call\n * spawns a real harness on a real git worktree instead of provisioning a\n * sibling sandbox.\n *\n * All harness invocations:\n * - run with `cwd` set to the worktree\n * - inherit env from the parent (the MCP server inside the sandbox has\n * the harness's auth already)\n * - capture stdout/stderr\n * - support cancellation via AbortSignal\n * - enforce a wall-clock timeout\n */\n\nimport { type ChildProcess, spawn } from 'node:child_process'\nimport type { AgentProfile } from '@tangle-network/sandbox'\n\n/** Local coding harness available inside the sandbox. */\nexport type LocalHarness = 'claude' | 'codex' | 'opencode'\n\n/**\n * Default per-harness command + arg shape. `buildArgs` takes ONLY the task prompt and\n * emits the prompt-only invocation (no model, no system prompt) — the historical shape\n * the in-process executor's `streamPrompt` drives. `modelArgs` maps a resolved model to\n * the harness's selector flag (every supported harness takes `-m <model>`). The §1.5\n * profile-aware mapper `harnessInvocation` composes these to thread the full\n * supervisor-authored profile (systemPrompt + model) into argv.\n */\nconst HARNESS_INVOCATIONS: Record<\n LocalHarness,\n {\n command: string\n buildArgs: (taskPrompt: string) => string[]\n /** Map a resolved model to the harness's model-selector flag. */\n modelArgs: (model: string) => string[]\n }\n> = {\n claude: {\n command: 'claude',\n buildArgs: (taskPrompt) => ['--headless', '-p', taskPrompt],\n modelArgs: (model) => ['-m', model],\n },\n codex: {\n command: 'codex',\n buildArgs: (taskPrompt) => ['run', taskPrompt],\n modelArgs: (model) => ['-m', model],\n },\n opencode: {\n command: 'opencode',\n buildArgs: (taskPrompt) => ['run', taskPrompt],\n modelArgs: (model) => ['-m', model],\n },\n}\n\n/** Result of mapping an `AgentProfile` + task prompt onto a harness invocation. */\nexport interface HarnessInvocation {\n command: string\n args: string[]\n}\n\n/**\n * Map a supervisor-authored `AgentProfile` + the per-task prompt onto a concrete harness\n * `command` + `args` (the §1.5 fix). UNLIKE the prompt-only `HARNESS_INVOCATIONS.buildArgs`\n * — which drops both the authored model and the system prompt — this threads the FULL\n * profile payload into argv:\n *\n * - `profile.prompt.systemPrompt` → the PROMPT channel: a portable, harness-agnostic\n * default that prepends the system prompt above the task prompt (`<system>\\n\\n<task>`),\n * so the authored standing instructions reach EVERY harness (none of the three CLIs\n * expose a portable replace-system-prompt flag for a one-shot non-interactive run).\n * - `profile.model.default` → the harness's `-m <model>` selector.\n *\n * The task prompt alone is the floor; an empty/absent profile yields exactly the legacy\n * `buildArgs(taskPrompt)` shape so existing callers are byte-identical.\n */\nexport function harnessInvocation(\n harness: LocalHarness,\n profile: AgentProfile,\n taskPrompt: string,\n): HarnessInvocation {\n const invocation = HARNESS_INVOCATIONS[harness]\n if (!invocation) {\n throw new Error(`harnessInvocation: unknown harness ${String(harness)}`)\n }\n\n const systemPrompt = profile.prompt?.systemPrompt\n const composedPrompt =\n typeof systemPrompt === 'string' && systemPrompt.trim().length > 0\n ? `${systemPrompt}\\n\\n${taskPrompt}`\n : taskPrompt\n\n const args = invocation.buildArgs(composedPrompt)\n\n const model = profile.model?.default\n if (typeof model === 'string' && model.length > 0) {\n args.push(...invocation.modelArgs(model))\n }\n\n return { command: invocation.command, args }\n}\n\n/** @experimental */\nexport interface RunLocalHarnessOptions {\n harness: LocalHarness\n /** Working directory for the subprocess (typically a worktree path). */\n cwd: string\n /** Prompt forwarded as the harness CLI's task argument. */\n taskPrompt: string\n /**\n * Pre-built command + args (e.g. from `harnessInvocation` so the full authored\n * `AgentProfile` — systemPrompt + model — reaches the harness). When set it OVERRIDES the\n * default prompt-only `buildArgs(taskPrompt)` path; `command` defaults to the harness's\n * default binary when only `args` is supplied. When absent the legacy prompt-only shape\n * is used unchanged.\n */\n invocation?: { command?: string; args: ReadonlyArray<string> }\n /** Wall-clock kill deadline (ms). Default 5 min. Subprocess SIGTERMed on expiry. */\n timeoutMs?: number\n /** Caller cancellation. SIGTERM is sent on abort. */\n signal?: AbortSignal\n /** Override env (defaults to inheriting from the parent). */\n env?: NodeJS.ProcessEnv\n /**\n * Test seam — inject a custom spawner so unit tests can mock the\n * subprocess without touching the OS. Defaults to node's `child_process.spawn`.\n */\n spawn?: (\n command: string,\n args: ReadonlyArray<string>,\n opts: {\n cwd: string\n env: NodeJS.ProcessEnv\n stdio: 'pipe'\n },\n ) => ChildProcess\n}\n\n/** @experimental */\nexport interface LocalHarnessResult {\n /** OS exit code. `null` when killed before exit. */\n exitCode: number | null\n /** Concatenated stdout. */\n stdout: string\n /** Concatenated stderr. */\n stderr: string\n /** Set when the process exited via signal (timeout / abort). */\n killedBySignal: NodeJS.Signals | null\n /** Wall-clock duration ms (spawn → exit). */\n durationMs: number\n /** Set when timeoutMs elapsed before exit. */\n timedOut: boolean\n}\n\nconst DEFAULT_TIMEOUT_MS = 5 * 60 * 1000\n\n/**\n * Spawn a local coding harness CLI as a subprocess + collect its output.\n *\n * NOT responsible for parsing the harness's output or extracting a diff —\n * the in-process executor's `streamPrompt` orchestrates `git diff` against\n * the worktree after this resolves. This function is intentionally narrow:\n * spawn, wait, capture, return.\n *\n * Fails loud — throws when:\n * - `cwd` doesn't exist (subprocess emits ENOENT; surfaced as Error)\n * - the harness binary is not on PATH (ENOENT)\n *\n * Does NOT throw when:\n * - the subprocess exits non-zero (`result.exitCode` carries the code)\n * - the subprocess is aborted / timed out (`result.killedBySignal` /\n * `result.timedOut` carries the reason)\n *\n * @experimental\n */\nexport function runLocalHarness(options: RunLocalHarnessOptions): Promise<LocalHarnessResult> {\n const { harness, cwd, taskPrompt } = options\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS\n const env = options.env ?? process.env\n const spawnImpl = options.spawn ?? spawn\n\n const invocation = HARNESS_INVOCATIONS[harness]\n if (!invocation) {\n return Promise.reject(new Error(`runLocalHarness: unknown harness ${String(harness)}`))\n }\n\n const startedAt = Date.now()\n const command = options.invocation?.command ?? invocation.command\n const args = options.invocation ? [...options.invocation.args] : invocation.buildArgs(taskPrompt)\n\n return new Promise<LocalHarnessResult>((resolve, reject) => {\n let child: ChildProcess\n try {\n child = spawnImpl(command, args, { cwd, env, stdio: 'pipe' })\n } catch (err) {\n reject(err instanceof Error ? err : new Error(String(err)))\n return\n }\n\n // The harness takes its task as an argv arg, not on stdin. Leaving stdin\n // OPEN makes a non-TTY `opencode run` (and likely the other harnesses)\n // BLOCK forever waiting on input — zero output, SIGTERM at the wall cap,\n // empty patch -> \"no candidate passed validation\". Close stdin so the\n // subprocess sees EOF and proceeds (the `cliExecutor` leaf does the same).\n child.stdin?.end()\n\n let stdout = ''\n let stderr = ''\n let timedOut = false\n let settled = false\n\n const timer =\n timeoutMs > 0\n ? setTimeout(() => {\n timedOut = true\n if (!child.killed) child.kill('SIGTERM')\n }, timeoutMs)\n : null\n if (timer && typeof (timer as { unref?: () => void }).unref === 'function') {\n ;(timer as { unref: () => void }).unref()\n }\n\n const onAbort = () => {\n if (!child.killed) child.kill('SIGTERM')\n }\n if (options.signal) {\n if (options.signal.aborted) onAbort()\n else options.signal.addEventListener('abort', onAbort, { once: true })\n }\n\n child.stdout?.on('data', (chunk) => {\n stdout += String(chunk)\n })\n child.stderr?.on('data', (chunk) => {\n stderr += String(chunk)\n })\n\n const finalize = (result: LocalHarnessResult) => {\n if (settled) return\n settled = true\n if (timer) clearTimeout(timer)\n options.signal?.removeEventListener('abort', onAbort)\n resolve(result)\n }\n\n child.on('error', (err) => {\n if (settled) return\n settled = true\n if (timer) clearTimeout(timer)\n options.signal?.removeEventListener('abort', onAbort)\n reject(err)\n })\n\n child.on('close', (code, signal) => {\n finalize({\n exitCode: code,\n stdout,\n stderr,\n killedBySignal: signal,\n durationMs: Date.now() - startedAt,\n timedOut,\n })\n })\n })\n}\n"],"mappings":";AAkBA,SAA4B,aAAa;AAczC,IAAM,sBAQF;AAAA,EACF,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,WAAW,CAAC,eAAe,CAAC,cAAc,MAAM,UAAU;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B,cAAQ,QAAQ,oBAAoB,SAAS,OAAO;AACpD,cAAQ,MAAM;AAAA,IAChB;AAEA,UAAM,GAAG,SAAS,CAAC,QAAQ;AACzB,UAAI,QAAS;AACb,gBAAU;AACV,UAAI,MAAO,cAAa,KAAK;AAC7B,cAAQ,QAAQ,oBAAoB,SAAS,OAAO;AACpD,aAAO,GAAG;AAAA,IACZ,CAAC;AAED,UAAM,GAAG,SAAS,CAAC,MAAM,WAAW;AAClC,eAAS;AAAA,QACP,UAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA,gBAAgB;AAAA,QAChB,YAAY,KAAK,IAAI,IAAI;AAAA,QACzB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AgentProfile } from '@tangle-network/sandbox';
|
|
2
2
|
import { O as OutputAdapter, V as Validator, A as AgentRunSpec, D as Driver } from './types-C8rNlxfV.js';
|
|
3
|
+
import { DefaultVerdict } from '@tangle-network/agent-eval';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @experimental
|
|
@@ -102,13 +103,61 @@ interface MultiHarnessCoderFanoutOptions {
|
|
|
102
103
|
/** Optional per-harness model override. Indexed parallel to `harnesses`. */
|
|
103
104
|
models?: (string | undefined)[];
|
|
104
105
|
}
|
|
105
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* The multi-harness coder fanout driving `createDefaultCoderDelegate`'s `variants>1`
|
|
108
|
+
* sandbox-session path. (`worktreeCoderFanout` is the local-repo generic counterpart for
|
|
109
|
+
* new code; both are first-class.)
|
|
110
|
+
*
|
|
111
|
+
* @experimental
|
|
112
|
+
*/
|
|
106
113
|
declare function multiHarnessCoderFanout(options?: MultiHarnessCoderFanoutOptions): {
|
|
107
114
|
agentRuns: AgentRunSpec<CoderTask>[];
|
|
108
115
|
output: OutputAdapter<CoderOutput>;
|
|
109
116
|
validator: Validator<CoderOutput>;
|
|
110
117
|
driver: Driver<CoderTask, CoderOutput, 'pick-winner' | 'fail'>;
|
|
111
118
|
};
|
|
119
|
+
/** @experimental Inputs the mechanical coder gate decides on — a captured patch plus the
|
|
120
|
+
* test/typecheck PASS signals derived for it. Shared by `createCoderValidator` (sandbox-event
|
|
121
|
+
* shape) and the generic worktree-CLI deliverable (which derives `testsPassed`/`typecheckPassed`
|
|
122
|
+
* by running the commands in the worktree). */
|
|
123
|
+
interface CoderCheckInput {
|
|
124
|
+
/** The unified diff produced by the run. */
|
|
125
|
+
patch: string;
|
|
126
|
+
/** Did `testCmd` exit clean? */
|
|
127
|
+
testsPassed: boolean;
|
|
128
|
+
/** Did `typecheckCmd` exit clean? */
|
|
129
|
+
typecheckPassed: boolean;
|
|
130
|
+
}
|
|
131
|
+
/** @experimental The per-task constraints the mechanical gate enforces. */
|
|
132
|
+
interface CoderCheckConstraints {
|
|
133
|
+
/** Default 400. Hard cap; gate fails when exceeded. */
|
|
134
|
+
maxDiffLines?: number;
|
|
135
|
+
/** Literal path prefixes the patch must not touch. */
|
|
136
|
+
forbiddenPaths?: string[];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @experimental
|
|
140
|
+
*
|
|
141
|
+
* The pure mechanical coder gate — the SINGLE source of the no-op / secret-path floor /
|
|
142
|
+
* diff-size / forbidden-path / test / typecheck checks. No I/O: it scores a patch + its
|
|
143
|
+
* already-derived pass signals. Both the `createCoderValidator` shim (sandbox `CoderOutput`)
|
|
144
|
+
* and the generic worktree-CLI `coderDeliverable` (which runs the commands itself) call this,
|
|
145
|
+
* so the gate logic never forks.
|
|
146
|
+
*
|
|
147
|
+
* Checks in order: (1) no-op rejection, (2) always-on secret-path floor (independent of
|
|
148
|
+
* `forbiddenPaths`), (3) forbidden-path, (4) diff-size cap, (5) tests, (6) typecheck.
|
|
149
|
+
* Aggregate score: `0.5*tests + 0.3*typecheck + 0.2*(1 - diffLines/maxDiff)`; `valid` is the
|
|
150
|
+
* conjunction of all six.
|
|
151
|
+
*/
|
|
152
|
+
declare function runCoderChecks(input: CoderCheckInput, constraints?: CoderCheckConstraints): DefaultVerdict;
|
|
153
|
+
/**
|
|
154
|
+
* The sandbox `CoderOutput` validator. A thin shim over the shared {@link runCoderChecks} gate
|
|
155
|
+
* (the single source of the no-op / secret-floor / forbidden / diff-size / test / typecheck logic),
|
|
156
|
+
* adapting the sandbox-parsed `CoderOutput` into the gate inputs. On the generic recursive path the
|
|
157
|
+
* same gate is reached via `coderDeliverable(...)` over the worktree-CLI artifact.
|
|
158
|
+
*
|
|
159
|
+
* @experimental
|
|
160
|
+
*/
|
|
112
161
|
declare function createCoderValidator(task: CoderTask): Validator<CoderOutput>;
|
|
113
162
|
|
|
114
|
-
export { type CoderOutput as C, type MultiHarnessCoderFanoutOptions as M, type
|
|
163
|
+
export { type CoderOutput as C, type MultiHarnessCoderFanoutOptions as M, type CoderCheckConstraints as a, type CoderCheckInput as b, type CoderProfileOptions as c, type CoderTask as d, coderProfile as e, createCoderValidator as f, multiHarnessCoderFanout as m, runCoderChecks as r };
|
|
@@ -2,7 +2,7 @@ import { DefaultVerdict } from '@tangle-network/agent-eval';
|
|
|
2
2
|
import { AgentProfile, BackendType } from '@tangle-network/sandbox';
|
|
3
3
|
import { R as RuntimeHooks } from './runtime-hooks-C7JwKb9E.js';
|
|
4
4
|
import { d as LoopTokenUsage } from './types-C8rNlxfV.js';
|
|
5
|
-
import { b as DelegateFeedbackArgs, c as DelegationFeedbackSnapshot, d as DelegationTaskQueue, e as CoderDelegate, R as ResearcherDelegate, U as UiAuditorDelegate, T as TraceContext } from './delegates-
|
|
5
|
+
import { b as DelegateFeedbackArgs, c as DelegationFeedbackSnapshot, d as DelegationTaskQueue, e as CoderDelegate, R as ResearcherDelegate, U as UiAuditorDelegate, T as TraceContext } from './delegates-D9o5_VFj.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @experimental
|
|
@@ -436,6 +436,85 @@ interface WidenGate<Out> {
|
|
|
436
436
|
readonly judgeExempt?: boolean;
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
+
/**
|
|
440
|
+
* @experimental
|
|
441
|
+
*
|
|
442
|
+
* Git worktree helpers for the in-process delegation executor. Each
|
|
443
|
+
* delegation runs in its own worktree so multiple parallel harness
|
|
444
|
+
* subprocesses (claude / codex / opencode in a 3-way fanout) don't clobber
|
|
445
|
+
* each other's edits on the shared workspace.
|
|
446
|
+
*
|
|
447
|
+
* Worktrees live under `<repoRoot>/.coder-variants/<runId>/`. After the
|
|
448
|
+
* harness exits + the diff is captured, the worktree is removed.
|
|
449
|
+
*
|
|
450
|
+
* All operations spawn `git` via `child_process.spawn` synchronously
|
|
451
|
+
* (via a `runGit` helper). Stays narrow on purpose: no working-tree
|
|
452
|
+
* staging, no commits, no rebases.
|
|
453
|
+
*/
|
|
454
|
+
/** @experimental */
|
|
455
|
+
interface WorktreeHandle {
|
|
456
|
+
/** Absolute path to the worktree directory. */
|
|
457
|
+
path: string;
|
|
458
|
+
/** SHA the worktree was created at. */
|
|
459
|
+
baseSha: string;
|
|
460
|
+
/** Branch name created for this worktree (typically `delegate/<runId>`). */
|
|
461
|
+
branch: string;
|
|
462
|
+
}
|
|
463
|
+
/** @experimental */
|
|
464
|
+
interface CreateWorktreeOptions {
|
|
465
|
+
/** Absolute path to the main git checkout. */
|
|
466
|
+
repoRoot: string;
|
|
467
|
+
/** Unique id for the worktree path + branch. Use the delegation run id. */
|
|
468
|
+
runId: string;
|
|
469
|
+
/** Parent directory the worktree lives under. Defaults to `.coder-variants`. */
|
|
470
|
+
variantsDir?: string;
|
|
471
|
+
/** Override the base ref (default `HEAD`). */
|
|
472
|
+
baseRef?: string;
|
|
473
|
+
/** Test seam — inject a custom git runner. */
|
|
474
|
+
runGit?: GitRunner;
|
|
475
|
+
}
|
|
476
|
+
/** @experimental */
|
|
477
|
+
interface DiffOptions {
|
|
478
|
+
/** Worktree to diff. */
|
|
479
|
+
worktree: WorktreeHandle;
|
|
480
|
+
/** What to compare against. Default `worktree.baseSha`. */
|
|
481
|
+
baseRef?: string;
|
|
482
|
+
/** Test seam. */
|
|
483
|
+
runGit?: GitRunner;
|
|
484
|
+
}
|
|
485
|
+
/** @experimental */
|
|
486
|
+
interface DiffResult {
|
|
487
|
+
patch: string;
|
|
488
|
+
stats: {
|
|
489
|
+
filesChanged: number;
|
|
490
|
+
insertions: number;
|
|
491
|
+
deletions: number;
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
/** @experimental */
|
|
495
|
+
interface RemoveWorktreeOptions {
|
|
496
|
+
worktree: WorktreeHandle;
|
|
497
|
+
repoRoot: string;
|
|
498
|
+
/** Force removal even if dirty (default true; the loser of a fanout has uncommitted changes). */
|
|
499
|
+
force?: boolean;
|
|
500
|
+
/** Test seam. */
|
|
501
|
+
runGit?: GitRunner;
|
|
502
|
+
}
|
|
503
|
+
/** Pluggable git runner (sync) — replaceable in tests. */
|
|
504
|
+
type GitRunner = (args: ReadonlyArray<string>, opts: {
|
|
505
|
+
cwd: string;
|
|
506
|
+
}) => {
|
|
507
|
+
stdout: string;
|
|
508
|
+
stderr: string;
|
|
509
|
+
exitCode: number;
|
|
510
|
+
};
|
|
511
|
+
/** @experimental */
|
|
512
|
+
declare function createWorktree(options: CreateWorktreeOptions): Promise<WorktreeHandle>;
|
|
513
|
+
/** @experimental */
|
|
514
|
+
declare function captureWorktreeDiff(options: DiffOptions): Promise<DiffResult>;
|
|
515
|
+
/** @experimental */
|
|
516
|
+
declare function removeWorktree(options: RemoveWorktreeOptions): Promise<void>;
|
|
517
|
+
|
|
439
518
|
/**
|
|
440
519
|
* @experimental
|
|
441
520
|
*
|
|
@@ -701,4 +780,4 @@ interface CoordinationTools {
|
|
|
701
780
|
/** Build the driver's MCP tools over a live scope. */
|
|
702
781
|
declare function createCoordinationTools(opts: CoordinationToolsOptions): CoordinationTools;
|
|
703
782
|
|
|
704
|
-
export { type AnalystRegistry as A, type Budget as B, type CoordinationEvent as C, type
|
|
783
|
+
export { type NodeSnapshot as $, type AnalystRegistry as A, type Budget as B, type CoordinationEvent as C, type DiffOptions as D, type ExecutorRegistry as E, type FeedbackStore as F, type GitRunner as G, type RootHandle as H, InMemoryFeedbackStore as I, type JsonRpcMessage as J, type SupervisedResult as K, type Spend as L, type MakeWorkerAgent as M, type NodeId as N, type Scope as O, type ExecutorFactory as P, type Question as Q, type RemoveWorktreeOptions as R, type SettledWorker as S, type TreeView as T, type Executor as U, type UsageEvent as V, type WorktreeHandle as W, type Supervisor as X, type ExecutorContext as Y, type ExecutorResult as Z, type Handle as _, type CoordinationTools as a, type NodeStatus as a0, type Restart as a1, type RootSignal as a2, type Runtime as a3, type SpawnOpts as a4, type SupervisorOpts as a5, type WidenGate as a6, type CoordinationToolsOptions as b, type CreateWorktreeOptions as c, type DiffResult as d, type FeedbackEvent as e, type JsonRpcResponse as f, type McpServer as g, type McpServerOptions as h, type McpToolDescriptor as i, type McpTransport as j, type QuestionDecision as k, type QuestionPolicy as l, type QuestionRecord as m, captureWorktreeDiff as n, createCoordinationTools as o, createInProcessTransport as p, createMcpServer as q, createWorktree as r, eventToSnapshot as s, removeWorktree as t, type ResultBlobStore as u, type SpawnJournal as v, type SpawnEvent as w, type Settled as x, type AgentSpec as y, type Agent as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CoderOutput,
|
|
1
|
+
import { C as CoderOutput, d as CoderTask } from './coder-COuOK8h8.js';
|
|
2
2
|
import { g as LoopTraceEmitter, e as LoopTraceEvent, S as SandboxClient, A as AgentRunSpec } from './types-C8rNlxfV.js';
|
|
3
3
|
import { SandboxEvent, SandboxInstance } from '@tangle-network/sandbox';
|
|
4
4
|
import { AgentEvalError } from '@tangle-network/agent-eval';
|
|
@@ -1459,6 +1459,16 @@ interface CreateDefaultCoderDelegateOptions {
|
|
|
1459
1459
|
* sandbox client + coder profile. When `args.variants > 1` it switches
|
|
1460
1460
|
* to the multi-harness fanout topology.
|
|
1461
1461
|
*
|
|
1462
|
+
* This is the SANDBOX-SESSION coder path: workers run the in-box harness via the
|
|
1463
|
+
* `SandboxClient`'s `streamPrompt`, and single-variant turns can dispatch DETACHED
|
|
1464
|
+
* (driveTurn ticks) so a durable queue resumes them across an MCP restart — a substrate
|
|
1465
|
+
* the recursive worktree-CLI leaf does not yet have a journal-replay equivalent for.
|
|
1466
|
+
*
|
|
1467
|
+
* For NEW local-repo coding, `worktreeCoderFanout` is a generic alternative (author an
|
|
1468
|
+
* `AgentProfile` per harness → `createWorktreeCliExecutor` leaves → `gateOnDeliverable`). This
|
|
1469
|
+
* factory remains first-class: it owns the sandbox-session + detached-resume substrate that the
|
|
1470
|
+
* worktree-CLI leaf does not yet replicate.
|
|
1471
|
+
*
|
|
1462
1472
|
* @experimental
|
|
1463
1473
|
*/
|
|
1464
1474
|
declare function createDefaultCoderDelegate(options: CreateDefaultCoderDelegateOptions): CoderDelegate;
|
|
@@ -1489,6 +1499,12 @@ interface SettleDetachedCoderTurnOptions {
|
|
|
1489
1499
|
* then the optional reviewer. Throws when nothing survives — a resumed or
|
|
1490
1500
|
* detached run must not return an unvalidated patch.
|
|
1491
1501
|
*
|
|
1502
|
+
* SCOPE NOTE (detached/resume): the detached `driveTurn`-tick + cross-restart resume path is
|
|
1503
|
+
* bound to the `runLoop` + sandbox-session substrate. The recursive `Scope`/worktree-CLI leaf has
|
|
1504
|
+
* journal→replay but no driveTurn-over-a-detached-sandbox-session equivalent yet, so resume is NOT
|
|
1505
|
+
* advertised on the generic `worktreeCoderFanout` path. This helper (with `coderTaskFromArgs` and
|
|
1506
|
+
* `createDriveTurnResumeDriver`) stays as the resume seam `bin.ts` wires for in-flight records.
|
|
1507
|
+
*
|
|
1492
1508
|
* @experimental
|
|
1493
1509
|
*/
|
|
1494
1510
|
declare function settleDetachedCoderTurn(turn: DetachedTurn, options: SettleDetachedCoderTurnOptions): Promise<CoderOutput>;
|
package/dist/improvement.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnalystFinding } from '@tangle-network/agent-eval';
|
|
2
|
-
import { L as LocalHarness, r as runLocalHarness } from './local-harness-
|
|
2
|
+
import { L as LocalHarness, r as runLocalHarness } from './local-harness-BE_h8szs.js';
|
|
3
3
|
import { LabeledScenarioStore, WorktreeAdapter, ImprovementDriver } from '@tangle-network/agent-eval/campaign';
|
|
4
4
|
import { S as SurfaceImprovementEdit } from './improvement-adapter-BC4HhuAR.js';
|
|
5
5
|
import { I as ImprovementAdapter } from './types-p8dWBIXL.js';
|
package/dist/improvement.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -3,16 +3,16 @@ export { AgentEvalError, AgentEvalErrorCode, ConfigError, ControlBudget, Control
|
|
|
3
3
|
import { h as AgentBackendInput, i as AgentExecutionBackend, c as OpenAIChatTool, j as OpenAIChatToolChoice, k as AgentBackendContext, R as RuntimeStreamEvent, K as KnowledgeReadinessDecision, l as RunAgentTaskOptions, m as AgentTaskRunResult, n as RunAgentTaskStreamOptions, o as AgentRuntimeEvent, p as AgentTaskStatus, q as RuntimeSessionStore, r as RuntimeSession } from './types-C8rNlxfV.js';
|
|
4
4
|
export { s as AgentAdapter, t as AgentKnowledgeProvider, u as AgentRuntimeEventSink, v as AgentTaskContext, w as AgentTaskSpec, B as BackendErrorDetail, x as RuntimeRunHandle, y as RuntimeRunPersistenceAdapter, z as RuntimeRunRow, C as startRuntimeRun } from './types-C8rNlxfV.js';
|
|
5
5
|
import { Scenario, ProfileDispatchFn } from '@tangle-network/agent-eval/campaign';
|
|
6
|
-
export { C as CoderLoopRunnerOptions, D as DELEGATED_LOOP_MODES, a as DelegatedLoopMode, b as DelegatedLoopRegistry, c as DelegatedLoopResult, d as DelegatedLoopRunner, L as LoopRunnerCliArgs, e as LoopRunnerCliResult, R as ResearchLoopResult, f as ResearchLoopRunnerOptions, g as RunDelegatedLoopOptions, V as VetoedFact, h as auditLoopRunner, i as coderLoopRunner, j as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, k as reviewLoopRunner, l as runDelegatedLoop, m as runLoopRunnerCli, s as selfImproveLoopRunner } from './loop-runner-bin-
|
|
6
|
+
export { C as CoderLoopRunnerOptions, D as DELEGATED_LOOP_MODES, a as DelegatedLoopMode, b as DelegatedLoopRegistry, c as DelegatedLoopResult, d as DelegatedLoopRunner, L as LoopRunnerCliArgs, e as LoopRunnerCliResult, R as ResearchLoopResult, f as ResearchLoopRunnerOptions, g as RunDelegatedLoopOptions, V as VetoedFact, h as auditLoopRunner, i as coderLoopRunner, j as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, k as reviewLoopRunner, l as runDelegatedLoop, m as runLoopRunnerCli, s as selfImproveLoopRunner } from './loop-runner-bin-CN2Se3jB.js';
|
|
7
7
|
export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-CoeLQ7Uo.js';
|
|
8
|
-
export { ax as EvalRunEvent, ay as EvalRunGeneration, az as EvalRunsExportConfig, aA as EvalRunsExportResult, aB as INTELLIGENCE_WIRE_VERSION, aC as LoopSpanNode, aD as OtelAttribute, aE as OtelExportConfig, aF as OtelExporter, aG as OtelSpan, aH as buildLoopOtelSpans, aI as buildLoopSpanNodes, aJ as createOtelExporter, aK as exportEvalRuns, aL as loopEventToOtelSpan } from './delegates-
|
|
8
|
+
export { ax as EvalRunEvent, ay as EvalRunGeneration, az as EvalRunsExportConfig, aA as EvalRunsExportResult, aB as INTELLIGENCE_WIRE_VERSION, aC as LoopSpanNode, aD as OtelAttribute, aE as OtelExportConfig, aF as OtelExporter, aG as OtelSpan, aH as buildLoopOtelSpans, aI as buildLoopSpanNodes, aJ as createOtelExporter, aK as exportEvalRuns, aL as loopEventToOtelSpan } from './delegates-D9o5_VFj.js';
|
|
9
9
|
import { R as RuntimeHooks } from './runtime-hooks-C7JwKb9E.js';
|
|
10
10
|
export { b as RuntimeDecisionEvidenceRef, c as RuntimeDecisionKind, d as RuntimeDecisionPoint, e as RuntimeHookContext, f as RuntimeHookErrorContext, a as RuntimeHookEvent, g as RuntimeHookPhase, h as RuntimeHookTarget, i as composeRuntimeHooks, j as defineRuntimeHooks, n as notifyRuntimeDecisionPoint, k as notifyRuntimeHookEvent } from './runtime-hooks-C7JwKb9E.js';
|
|
11
11
|
import '@tangle-network/sandbox';
|
|
12
12
|
import '@tangle-network/agent-eval/contract';
|
|
13
13
|
import './types-p8dWBIXL.js';
|
|
14
14
|
import './kb-gate-CuzMYGYM.js';
|
|
15
|
-
import './coder-
|
|
15
|
+
import './coder-COuOK8h8.js';
|
|
16
16
|
import './substrate-CUgk7F7s.js';
|
|
17
17
|
|
|
18
18
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mcpToolsForRuntimeMcp,
|
|
3
3
|
mcpToolsForRuntimeMcpSubset
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-F5XQA43K.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_ROUTER_BASE_URL,
|
|
7
7
|
cleanModelId,
|
|
@@ -21,17 +21,17 @@ import {
|
|
|
21
21
|
runDelegatedLoop,
|
|
22
22
|
runLoopRunnerCli,
|
|
23
23
|
selfImproveLoopRunner
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-6XKXWA7H.js";
|
|
25
25
|
import "./chunk-FNMGYYSS.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-KADIJAD4.js";
|
|
26
|
+
import "./chunk-G4NIVG34.js";
|
|
28
27
|
import "./chunk-P5OKDSLB.js";
|
|
29
28
|
import {
|
|
30
29
|
composeRuntimeHooks,
|
|
31
30
|
defineRuntimeHooks,
|
|
32
31
|
notifyRuntimeDecisionPoint,
|
|
33
32
|
notifyRuntimeHookEvent
|
|
34
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-4H2FML7G.js";
|
|
34
|
+
import "./chunk-7QYOXFCD.js";
|
|
35
35
|
import "./chunk-WIR4HOOJ.js";
|
|
36
36
|
import {
|
|
37
37
|
AgentEvalError,
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
SessionMismatchError,
|
|
45
45
|
ValidationError
|
|
46
46
|
} from "./chunk-VLF5RHEQ.js";
|
|
47
|
+
import "./chunk-GLMFBUKT.js";
|
|
47
48
|
import {
|
|
48
49
|
INTELLIGENCE_WIRE_VERSION,
|
|
49
50
|
buildLoopOtelSpans,
|