@tangle-network/agent-runtime 0.93.1 → 0.93.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.js +3 -3
- package/dist/{chunk-UO2L5VTP.js → chunk-2BQMAZAB.js} +2 -2
- package/dist/{chunk-BVVRQ4YC.js → chunk-6K5CI33W.js} +2 -2
- package/dist/{chunk-CMYMTRGA.js → chunk-PX6SXX3M.js} +26 -3
- package/dist/chunk-PX6SXX3M.js.map +1 -0
- package/dist/{chunk-FRBHUNQ7.js → chunk-RTVVH2KL.js} +2 -2
- package/dist/{chunk-LQQPGRKT.js → chunk-TU73X3I6.js} +2 -2
- package/dist/{chunk-VMHKMNEU.js → chunk-WGR6QJ5H.js} +2 -2
- package/dist/{chunk-P6B3Z7PR.js → chunk-X5KJKS33.js} +3 -3
- package/dist/{chunk-TKJ3Q6CQ.js → chunk-Z7K5BPKZ.js} +2 -2
- package/dist/index.js +8 -8
- package/dist/intelligence.js +3 -3
- package/dist/knowledge.js +3 -3
- package/dist/lifecycle.js +2 -2
- package/dist/loop-runner-bin.js +4 -4
- package/dist/loops.js +3 -3
- package/dist/mcp/bin.js +2 -2
- package/dist/mcp/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-CMYMTRGA.js.map +0 -1
- /package/dist/{chunk-UO2L5VTP.js.map → chunk-2BQMAZAB.js.map} +0 -0
- /package/dist/{chunk-BVVRQ4YC.js.map → chunk-6K5CI33W.js.map} +0 -0
- /package/dist/{chunk-FRBHUNQ7.js.map → chunk-RTVVH2KL.js.map} +0 -0
- /package/dist/{chunk-LQQPGRKT.js.map → chunk-TU73X3I6.js.map} +0 -0
- /package/dist/{chunk-VMHKMNEU.js.map → chunk-WGR6QJ5H.js.map} +0 -0
- /package/dist/{chunk-P6B3Z7PR.js.map → chunk-X5KJKS33.js.map} +0 -0
- /package/dist/{chunk-TKJ3Q6CQ.js.map → chunk-Z7K5BPKZ.js.map} +0 -0
package/dist/agent.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-6K5CI33W.js";
|
|
2
2
|
import "./chunk-FDJ7AHXG.js";
|
|
3
3
|
import {
|
|
4
4
|
createSandboxForSpec
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2BQMAZAB.js";
|
|
6
6
|
import "./chunk-DPEUKJRO.js";
|
|
7
7
|
import "./chunk-J2K6WIG6.js";
|
|
8
8
|
import "./chunk-3D2RHC4K.js";
|
|
@@ -11,7 +11,7 @@ import "./chunk-3MDZX7YU.js";
|
|
|
11
11
|
import {
|
|
12
12
|
mapSandboxEvent
|
|
13
13
|
} from "./chunk-FVJ7M3DA.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-PX6SXX3M.js";
|
|
15
15
|
import {
|
|
16
16
|
ValidationError
|
|
17
17
|
} from "./chunk-YEJR7IXO.js";
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
import {
|
|
40
40
|
harnessInvocation,
|
|
41
41
|
runLocalHarness
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-PX6SXX3M.js";
|
|
43
43
|
import {
|
|
44
44
|
AgentEvalError,
|
|
45
45
|
ConfigError,
|
|
@@ -5263,4 +5263,4 @@ export {
|
|
|
5263
5263
|
workerFromBackend,
|
|
5264
5264
|
supervise
|
|
5265
5265
|
};
|
|
5266
|
-
//# sourceMappingURL=chunk-
|
|
5266
|
+
//# sourceMappingURL=chunk-2BQMAZAB.js.map
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
probeSandboxCapabilities,
|
|
16
16
|
runLoop,
|
|
17
17
|
supervise
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-2BQMAZAB.js";
|
|
19
19
|
import {
|
|
20
20
|
createSupervisor,
|
|
21
21
|
notifyRuntimeHookEvent,
|
|
@@ -5126,4 +5126,4 @@ export {
|
|
|
5126
5126
|
computeFindingId,
|
|
5127
5127
|
makeFinding
|
|
5128
5128
|
};
|
|
5129
|
-
//# sourceMappingURL=chunk-
|
|
5129
|
+
//# sourceMappingURL=chunk-6K5CI33W.js.map
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
// src/mcp/local-harness.ts
|
|
2
2
|
import { spawn } from "child_process";
|
|
3
|
+
var codexReasoningEffort = {
|
|
4
|
+
none: "none",
|
|
5
|
+
minimal: "minimal",
|
|
6
|
+
low: "low",
|
|
7
|
+
medium: "medium",
|
|
8
|
+
high: "high",
|
|
9
|
+
xhigh: "xhigh",
|
|
10
|
+
ultracode: "xhigh"
|
|
11
|
+
};
|
|
12
|
+
function codexReasoningArgs(reasoningEffort) {
|
|
13
|
+
const mapped = codexReasoningEffort[reasoningEffort];
|
|
14
|
+
if (mapped === void 0) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`harnessInvocation: unsupported Codex reasoning effort ${String(reasoningEffort)}`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return ["-c", `model_reasoning_effort="${mapped}"`];
|
|
20
|
+
}
|
|
3
21
|
var HARNESS_INVOCATIONS = {
|
|
4
22
|
claude: {
|
|
5
23
|
command: "claude",
|
|
@@ -10,8 +28,9 @@ var HARNESS_INVOCATIONS = {
|
|
|
10
28
|
},
|
|
11
29
|
codex: {
|
|
12
30
|
command: "codex",
|
|
13
|
-
buildArgs: (taskPrompt) => ["
|
|
14
|
-
modelArgs: (model) => ["-m", model]
|
|
31
|
+
buildArgs: (taskPrompt) => ["exec", taskPrompt],
|
|
32
|
+
modelArgs: (model) => ["-m", model],
|
|
33
|
+
reasoningArgs: codexReasoningArgs
|
|
15
34
|
},
|
|
16
35
|
opencode: {
|
|
17
36
|
command: "opencode",
|
|
@@ -40,6 +59,10 @@ ${taskPrompt}` : taskPrompt;
|
|
|
40
59
|
if (typeof model === "string" && model.length > 0) {
|
|
41
60
|
args.push(...invocation.modelArgs(model));
|
|
42
61
|
}
|
|
62
|
+
const reasoningEffort = profile.model?.reasoningEffort;
|
|
63
|
+
if (reasoningEffort !== void 0 && invocation.reasoningArgs) {
|
|
64
|
+
args.push(...invocation.reasoningArgs(reasoningEffort));
|
|
65
|
+
}
|
|
43
66
|
return { command: invocation.command, args };
|
|
44
67
|
}
|
|
45
68
|
var DEFAULT_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
@@ -120,4 +143,4 @@ export {
|
|
|
120
143
|
harnessInvocation,
|
|
121
144
|
runLocalHarness
|
|
122
145
|
};
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-PX6SXX3M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mcp/local-harness.ts"],"sourcesContent":["/**\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 delegated coding task\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 * @experimental\n */\n\nimport { type ChildProcess, spawn } from 'node:child_process'\nimport type { AgentProfile } from '@tangle-network/agent-interface'\n\n/** Local coding harness available inside the sandbox. */\nexport type LocalHarness = 'claude' | 'codex' | 'opencode'\n\ntype ReasoningEffort = NonNullable<NonNullable<AgentProfile['model']>['reasoningEffort']>\n\nconst codexReasoningEffort: Record<ReasoningEffort, string> = {\n none: 'none',\n minimal: 'minimal',\n low: 'low',\n medium: 'medium',\n high: 'high',\n xhigh: 'xhigh',\n ultracode: 'xhigh',\n}\n\nfunction codexReasoningArgs(reasoningEffort: ReasoningEffort): string[] {\n const mapped = codexReasoningEffort[reasoningEffort]\n if (mapped === undefined) {\n throw new Error(\n `harnessInvocation: unsupported Codex reasoning effort ${String(reasoningEffort)}`,\n )\n }\n return ['-c', `model_reasoning_effort=\"${mapped}\"`]\n}\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 safe default 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 /** Map portable reasoning effort when the harness exposes a native control. */\n reasoningArgs?: (reasoningEffort: ReasoningEffort) => string[]\n }\n> = {\n claude: {\n command: 'claude',\n // `-p` IS headless/print mode; the old `--headless` flag was removed from the CLI.\n // Permission bypass is an explicit per-run opt-in below, never the public default.\n buildArgs: (taskPrompt) => ['-p', taskPrompt],\n modelArgs: (model) => ['-m', model],\n },\n codex: {\n command: 'codex',\n buildArgs: (taskPrompt) => ['exec', taskPrompt],\n modelArgs: (model) => ['-m', model],\n reasoningArgs: codexReasoningArgs,\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\nexport interface HarnessInvocationOptions {\n /** Allow an unattended Claude process to edit its isolated candidate worktree.\n * Ignored by harnesses that do not use Claude's permission prompt. */\n dangerouslySkipPermissions?: boolean\n}\n\nfunction buildHarnessArgs(\n harness: LocalHarness,\n taskPrompt: string,\n options: HarnessInvocationOptions = {},\n): string[] {\n const args = HARNESS_INVOCATIONS[harness].buildArgs(taskPrompt)\n if (harness === 'claude' && options.dangerouslySkipPermissions) {\n args.push('--dangerously-skip-permissions')\n }\n return args\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 options: HarnessInvocationOptions = {},\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 = buildHarnessArgs(harness, composedPrompt, options)\n\n const model = profile.model?.default\n if (typeof model === 'string' && model.length > 0) {\n args.push(...invocation.modelArgs(model))\n }\n\n const reasoningEffort = profile.model?.reasoningEffort\n if (reasoningEffort !== undefined && invocation.reasoningArgs) {\n args.push(...invocation.reasoningArgs(reasoningEffort))\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 /** Allow autonomous Claude edits without an interactive permission prompt.\n * Use only when `cwd` is an isolated candidate worktree. */\n dangerouslySkipPermissions?: boolean\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\n ? [...options.invocation.args]\n : buildHarnessArgs(harness, taskPrompt, options)\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":";AAmBA,SAA4B,aAAa;AAQzC,IAAM,uBAAwD;AAAA,EAC5D,MAAM;AAAA,EACN,SAAS;AAAA,EACT,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,WAAW;AACb;AAEA,SAAS,mBAAmB,iBAA4C;AACtE,QAAM,SAAS,qBAAqB,eAAe;AACnD,MAAI,WAAW,QAAW;AACxB,UAAM,IAAI;AAAA,MACR,yDAAyD,OAAO,eAAe,CAAC;AAAA,IAClF;AAAA,EACF;AACA,SAAO,CAAC,MAAM,2BAA2B,MAAM,GAAG;AACpD;AAUA,IAAM,sBAUF;AAAA,EACF,QAAQ;AAAA,IACN,SAAS;AAAA;AAAA;AAAA,IAGT,WAAW,CAAC,eAAe,CAAC,MAAM,UAAU;AAAA,IAC5C,WAAW,CAAC,UAAU,CAAC,MAAM,KAAK;AAAA,EACpC;AAAA,EACA,OAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW,CAAC,eAAe,CAAC,QAAQ,UAAU;AAAA,IAC9C,WAAW,CAAC,UAAU,CAAC,MAAM,KAAK;AAAA,IAClC,eAAe;AAAA,EACjB;AAAA,EACA,UAAU;AAAA,IACR,SAAS;AAAA,IACT,WAAW,CAAC,eAAe,CAAC,OAAO,UAAU;AAAA,IAC7C,WAAW,CAAC,UAAU,CAAC,MAAM,KAAK;AAAA,EACpC;AACF;AAcA,SAAS,iBACP,SACA,YACA,UAAoC,CAAC,GAC3B;AACV,QAAM,OAAO,oBAAoB,OAAO,EAAE,UAAU,UAAU;AAC9D,MAAI,YAAY,YAAY,QAAQ,4BAA4B;AAC9D,SAAK,KAAK,gCAAgC;AAAA,EAC5C;AACA,SAAO;AACT;AAiBO,SAAS,k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B,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,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runLocalHarness
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PX6SXX3M.js";
|
|
4
4
|
|
|
5
5
|
// src/improvement/agentic-generator.ts
|
|
6
6
|
import { spawnSync } from "child_process";
|
|
@@ -207,4 +207,4 @@ export {
|
|
|
207
207
|
agenticGenerator,
|
|
208
208
|
commandVerifier
|
|
209
209
|
};
|
|
210
|
-
//# sourceMappingURL=chunk-
|
|
210
|
+
//# sourceMappingURL=chunk-RTVVH2KL.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-5QOB7H74.js";
|
|
4
4
|
import {
|
|
5
5
|
supervise
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2BQMAZAB.js";
|
|
7
7
|
|
|
8
8
|
// src/knowledge/improvement-job.ts
|
|
9
9
|
import {
|
|
@@ -211,4 +211,4 @@ export {
|
|
|
211
211
|
createAgentKnowledgeReadinessCheck,
|
|
212
212
|
runKnowledgeImprovementJob
|
|
213
213
|
};
|
|
214
|
-
//# sourceMappingURL=chunk-
|
|
214
|
+
//# sourceMappingURL=chunk-TU73X3I6.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-FDJ7AHXG.js";
|
|
4
4
|
import {
|
|
5
5
|
agenticGenerator
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RTVVH2KL.js";
|
|
7
7
|
import {
|
|
8
8
|
assertModelAllowed
|
|
9
9
|
} from "./chunk-J2K6WIG6.js";
|
|
@@ -685,4 +685,4 @@ export {
|
|
|
685
685
|
rolloutPolicyProposer,
|
|
686
686
|
improve
|
|
687
687
|
};
|
|
688
|
-
//# sourceMappingURL=chunk-
|
|
688
|
+
//# sourceMappingURL=chunk-WGR6QJ5H.js.map
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
definePersona,
|
|
6
6
|
runPersonified,
|
|
7
7
|
worktreeFanout
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6K5CI33W.js";
|
|
9
9
|
import {
|
|
10
10
|
runAnalystLoop
|
|
11
11
|
} from "./chunk-ZQZX77MM.js";
|
|
12
12
|
import {
|
|
13
13
|
createExecutorRegistry
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2BQMAZAB.js";
|
|
15
15
|
import {
|
|
16
16
|
ConfigError
|
|
17
17
|
} from "./chunk-YEJR7IXO.js";
|
|
@@ -196,4 +196,4 @@ export {
|
|
|
196
196
|
runLoopRunnerCli,
|
|
197
197
|
parseLoopRunnerArgv
|
|
198
198
|
};
|
|
199
|
-
//# sourceMappingURL=chunk-
|
|
199
|
+
//# sourceMappingURL=chunk-X5KJKS33.js.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
DELEGATION_STATUS_DESCRIPTION,
|
|
9
9
|
DELEGATION_STATUS_INPUT_SCHEMA,
|
|
10
10
|
DELEGATION_STATUS_TOOL_NAME
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2BQMAZAB.js";
|
|
12
12
|
|
|
13
13
|
// src/mcp/openai-tools.ts
|
|
14
14
|
function buildTool(name, description, parameters) {
|
|
@@ -45,4 +45,4 @@ export {
|
|
|
45
45
|
mcpToolsForRuntimeMcp,
|
|
46
46
|
mcpToolsForRuntimeMcpSubset
|
|
47
47
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-Z7K5BPKZ.js.map
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
mcpToolsForRuntimeMcp,
|
|
10
10
|
mcpToolsForRuntimeMcpSubset
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-Z7K5BPKZ.js";
|
|
12
12
|
import {
|
|
13
13
|
DEFAULT_ROUTER_BASE_URL,
|
|
14
14
|
cleanModelId,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
runLoopRunnerCli,
|
|
28
28
|
selfImproveLoopRunner,
|
|
29
29
|
worktreeLoopRunner
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-X5KJKS33.js";
|
|
31
31
|
import "./chunk-SGKPNBXE.js";
|
|
32
32
|
import {
|
|
33
33
|
ROLLOUT_POLICY_BOUNDS,
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
rolloutPolicyProposer,
|
|
43
43
|
serializeRolloutPolicy,
|
|
44
44
|
structuralRolloutPolicyFromProfile
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-WGR6QJ5H.js";
|
|
46
46
|
import {
|
|
47
47
|
CANDIDATE_TRACE_ENV,
|
|
48
48
|
CANDIDATE_TRACE_TAGS,
|
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
normalizeBackendStreamEvent,
|
|
64
64
|
nowIso,
|
|
65
65
|
touchSession
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-6K5CI33W.js";
|
|
67
67
|
import "./chunk-FDJ7AHXG.js";
|
|
68
68
|
import "./chunk-ZQZX77MM.js";
|
|
69
69
|
import {
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
import {
|
|
75
75
|
agenticGenerator,
|
|
76
76
|
commandVerifier
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-RTVVH2KL.js";
|
|
78
78
|
import {
|
|
79
79
|
RESEARCH_SUPERVISOR_SYSTEM_PROMPT,
|
|
80
80
|
createAgentKnowledgeReadinessCheck,
|
|
@@ -83,9 +83,9 @@ import {
|
|
|
83
83
|
knowledgeReadinessDeliverable,
|
|
84
84
|
runKnowledgeImprovementJob,
|
|
85
85
|
runSupervisedKnowledgeUpdate
|
|
86
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-TU73X3I6.js";
|
|
87
87
|
import "./chunk-5QOB7H74.js";
|
|
88
|
-
import "./chunk-
|
|
88
|
+
import "./chunk-2BQMAZAB.js";
|
|
89
89
|
import "./chunk-DPEUKJRO.js";
|
|
90
90
|
import {
|
|
91
91
|
INTELLIGENCE_WIRE_VERSION,
|
|
@@ -109,7 +109,7 @@ import "./chunk-3D2RHC4K.js";
|
|
|
109
109
|
import "./chunk-VSWBYWFK.js";
|
|
110
110
|
import "./chunk-3MDZX7YU.js";
|
|
111
111
|
import "./chunk-FVJ7M3DA.js";
|
|
112
|
-
import "./chunk-
|
|
112
|
+
import "./chunk-PX6SXX3M.js";
|
|
113
113
|
import {
|
|
114
114
|
AgentEvalError,
|
|
115
115
|
BackendTransportError,
|
package/dist/intelligence.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
improve
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WGR6QJ5H.js";
|
|
4
4
|
import {
|
|
5
5
|
assertCandidateProfileBinding,
|
|
6
6
|
canonicalCandidateDigest,
|
|
@@ -17,7 +17,7 @@ import "./chunk-FDJ7AHXG.js";
|
|
|
17
17
|
import {
|
|
18
18
|
runAnalystLoop
|
|
19
19
|
} from "./chunk-ZQZX77MM.js";
|
|
20
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-RTVVH2KL.js";
|
|
21
21
|
import {
|
|
22
22
|
buildLoopOtelSpans,
|
|
23
23
|
buildRuntimeEventOtelSpans,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
import "./chunk-3D2RHC4K.js";
|
|
28
28
|
import "./chunk-3MDZX7YU.js";
|
|
29
29
|
import "./chunk-FVJ7M3DA.js";
|
|
30
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-PX6SXX3M.js";
|
|
31
31
|
import "./chunk-YEJR7IXO.js";
|
|
32
32
|
import "./chunk-DGUM43GV.js";
|
|
33
33
|
|
package/dist/knowledge.js
CHANGED
|
@@ -6,16 +6,16 @@ import {
|
|
|
6
6
|
knowledgeReadinessDeliverable,
|
|
7
7
|
runKnowledgeImprovementJob,
|
|
8
8
|
runSupervisedKnowledgeUpdate
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TU73X3I6.js";
|
|
10
10
|
import "./chunk-5QOB7H74.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-2BQMAZAB.js";
|
|
12
12
|
import "./chunk-DPEUKJRO.js";
|
|
13
13
|
import "./chunk-J2K6WIG6.js";
|
|
14
14
|
import "./chunk-3D2RHC4K.js";
|
|
15
15
|
import "./chunk-VSWBYWFK.js";
|
|
16
16
|
import "./chunk-3MDZX7YU.js";
|
|
17
17
|
import "./chunk-FVJ7M3DA.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-PX6SXX3M.js";
|
|
19
19
|
import "./chunk-YEJR7IXO.js";
|
|
20
20
|
import "./chunk-DGUM43GV.js";
|
|
21
21
|
export {
|
package/dist/lifecycle.js
CHANGED
package/dist/loop-runner-bin.js
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
import {
|
|
3
3
|
parseLoopRunnerArgv,
|
|
4
4
|
runLoopRunnerCli
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-X5KJKS33.js";
|
|
6
6
|
import "./chunk-SGKPNBXE.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-6K5CI33W.js";
|
|
8
8
|
import "./chunk-FDJ7AHXG.js";
|
|
9
9
|
import "./chunk-ZQZX77MM.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-2BQMAZAB.js";
|
|
11
11
|
import "./chunk-DPEUKJRO.js";
|
|
12
12
|
import "./chunk-J2K6WIG6.js";
|
|
13
13
|
import "./chunk-3D2RHC4K.js";
|
|
14
14
|
import "./chunk-VSWBYWFK.js";
|
|
15
15
|
import "./chunk-3MDZX7YU.js";
|
|
16
16
|
import "./chunk-FVJ7M3DA.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-PX6SXX3M.js";
|
|
18
18
|
import "./chunk-YEJR7IXO.js";
|
|
19
19
|
import "./chunk-DGUM43GV.js";
|
|
20
20
|
export {
|
package/dist/loops.js
CHANGED
|
@@ -78,7 +78,7 @@ import {
|
|
|
78
78
|
watchTrace,
|
|
79
79
|
widen,
|
|
80
80
|
worktreeFanout
|
|
81
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-6K5CI33W.js";
|
|
82
82
|
import {
|
|
83
83
|
adaptiveRefine,
|
|
84
84
|
breadthStrategy,
|
|
@@ -133,7 +133,7 @@ import {
|
|
|
133
133
|
supervisorAgent,
|
|
134
134
|
supervisorInstructions,
|
|
135
135
|
workerFromBackend
|
|
136
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-2BQMAZAB.js";
|
|
137
137
|
import "./chunk-DPEUKJRO.js";
|
|
138
138
|
import {
|
|
139
139
|
assertModelAllowed,
|
|
@@ -167,7 +167,7 @@ import {
|
|
|
167
167
|
mapSandboxToolEvent,
|
|
168
168
|
sumSandboxUsage
|
|
169
169
|
} from "./chunk-FVJ7M3DA.js";
|
|
170
|
-
import "./chunk-
|
|
170
|
+
import "./chunk-PX6SXX3M.js";
|
|
171
171
|
import "./chunk-YEJR7IXO.js";
|
|
172
172
|
import "./chunk-DGUM43GV.js";
|
|
173
173
|
export {
|
package/dist/mcp/bin.js
CHANGED
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
DelegationTaskQueue,
|
|
10
10
|
FileDelegationStore,
|
|
11
11
|
createMcpServer
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-2BQMAZAB.js";
|
|
13
13
|
import "../chunk-DPEUKJRO.js";
|
|
14
14
|
import "../chunk-J2K6WIG6.js";
|
|
15
15
|
import "../chunk-3D2RHC4K.js";
|
|
16
16
|
import "../chunk-VSWBYWFK.js";
|
|
17
17
|
import "../chunk-3MDZX7YU.js";
|
|
18
18
|
import "../chunk-FVJ7M3DA.js";
|
|
19
|
-
import "../chunk-
|
|
19
|
+
import "../chunk-PX6SXX3M.js";
|
|
20
20
|
import "../chunk-YEJR7IXO.js";
|
|
21
21
|
import "../chunk-DGUM43GV.js";
|
|
22
22
|
|
package/dist/mcp/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
mcpToolsForRuntimeMcp,
|
|
11
11
|
mcpToolsForRuntimeMcpSubset
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-Z7K5BPKZ.js";
|
|
13
13
|
import {
|
|
14
14
|
createKbGate
|
|
15
15
|
} from "../chunk-SGKPNBXE.js";
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
assertTraceDerivedFindings,
|
|
18
18
|
runCoderChecks,
|
|
19
19
|
selectValidWinner
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-6K5CI33W.js";
|
|
21
21
|
import "../chunk-FDJ7AHXG.js";
|
|
22
22
|
import {
|
|
23
23
|
DELEGATE_DESCRIPTION,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
validateDelegateUiAuditArgs,
|
|
69
69
|
validateDelegationHistoryArgs,
|
|
70
70
|
validateDelegationStatusArgs
|
|
71
|
-
} from "../chunk-
|
|
71
|
+
} from "../chunk-2BQMAZAB.js";
|
|
72
72
|
import "../chunk-DPEUKJRO.js";
|
|
73
73
|
import "../chunk-J2K6WIG6.js";
|
|
74
74
|
import "../chunk-3D2RHC4K.js";
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
import "../chunk-FVJ7M3DA.js";
|
|
83
83
|
import {
|
|
84
84
|
runLocalHarness
|
|
85
|
-
} from "../chunk-
|
|
85
|
+
} from "../chunk-PX6SXX3M.js";
|
|
86
86
|
import {
|
|
87
87
|
ValidationError
|
|
88
88
|
} from "../chunk-YEJR7IXO.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-runtime",
|
|
3
|
-
"version": "0.93.
|
|
3
|
+
"version": "0.93.2",
|
|
4
4
|
"description": "Shared task-lifecycle skeleton for agents: a recursive loop kernel for chat turns, one-shot tasks, and multi-attempt loops, with trace capture and eval-gated self-improvement. Domain behavior lives in adapters; scoring and ship-gates in @tangle-network/agent-eval.",
|
|
5
5
|
"homepage": "https://github.com/tangle-network/agent-runtime#readme",
|
|
6
6
|
"repository": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mcp/local-harness.ts"],"sourcesContent":["/**\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 delegated coding task\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 * @experimental\n */\n\nimport { type ChildProcess, spawn } from 'node:child_process'\nimport type { AgentProfile } from '@tangle-network/agent-interface'\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 safe default 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 // `-p` IS headless/print mode; the old `--headless` flag was removed from the CLI.\n // Permission bypass is an explicit per-run opt-in below, never the public default.\n buildArgs: (taskPrompt) => ['-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\nexport interface HarnessInvocationOptions {\n /** Allow an unattended Claude process to edit its isolated candidate worktree.\n * Ignored by harnesses that do not use Claude's permission prompt. */\n dangerouslySkipPermissions?: boolean\n}\n\nfunction buildHarnessArgs(\n harness: LocalHarness,\n taskPrompt: string,\n options: HarnessInvocationOptions = {},\n): string[] {\n const args = HARNESS_INVOCATIONS[harness].buildArgs(taskPrompt)\n if (harness === 'claude' && options.dangerouslySkipPermissions) {\n args.push('--dangerously-skip-permissions')\n }\n return args\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 options: HarnessInvocationOptions = {},\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 = buildHarnessArgs(harness, composedPrompt, options)\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 /** Allow autonomous Claude edits without an interactive permission prompt.\n * Use only when `cwd` is an isolated candidate worktree. */\n dangerouslySkipPermissions?: boolean\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\n ? [...options.invocation.args]\n : buildHarnessArgs(harness, taskPrompt, options)\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":";AAmBA,SAA4B,aAAa;AAczC,IAAM,sBAQF;AAAA,EACF,QAAQ;AAAA,IACN,SAAS;AAAA;AAAA;AAAA,IAGT,WAAW,CAAC,eAAe,CAAC,MAAM,UAAU;AAAA,IAC5C,WAAW,CAAC,UAAU,CAAC,MAAM,KAAK;AAAA,EACpC;AAAA,EACA,OAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW,CAAC,eAAe,CAAC,OAAO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AC;AAED,UAAM,WAAW,CAAC,WAA+B;AAC/C,UAAI,QAAS;AACb,gBAAU;AACV,UAAI,MAAO,cAAa,KAAK;AAC7B,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":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|