@tangle-network/agent-runtime 0.172.0 → 0.173.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{activation-DTleO7Fl.js → activation-DkZiIzqK.js} +2 -2
- package/dist/{activation-DTleO7Fl.js.map → activation-DkZiIzqK.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{authoring-c9yTIa3G.js → authoring-B4aR-Tea.js} +2 -2
- package/dist/{authoring-c9yTIa3G.js.map → authoring-B4aR-Tea.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +1 -1
- package/dist/{graph-CtMnqYYC.js → graph-CoSt0kup.js} +2 -2
- package/dist/{graph-CtMnqYYC.js.map → graph-CoSt0kup.js.map} +1 -1
- package/dist/graph.d.ts +2 -2
- package/dist/graph.js +3 -3
- package/dist/{improvement-cycle-ipnDcl3P.js → improvement-cycle-lP-F7B60.js} +30 -8
- package/dist/improvement-cycle-lP-F7B60.js.map +1 -0
- package/dist/{index-cFm21prV.d.ts → index-CIhkH7mq.d.ts} +40 -3
- package/dist/{index-DEEN055X.d.ts → index-Dk5X9eKg.d.ts} +3 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +3 -3
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +7 -7
- package/dist/{knowledge-BHfAAu6C.js → knowledge-DCepYOlH.js} +3 -3
- package/dist/{knowledge-BHfAAu6C.js.map → knowledge-DCepYOlH.js.map} +1 -1
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/{loop-runner-bin-B3ju0qWS.js → loop-runner-bin-CTCi_rSV.js} +3 -3
- package/dist/{loop-runner-bin-B3ju0qWS.js.map → loop-runner-bin-CTCi_rSV.js.map} +1 -1
- package/dist/{loop-runner-bin-BGcW6Gm7.d.ts → loop-runner-bin-DRYApMiu.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-CfsSJ2sn.js → openai-tools-B4BPplKi.js} +2 -2
- package/dist/{openai-tools-CfsSJ2sn.js.map → openai-tools-B4BPplKi.js.map} +1 -1
- package/dist/primeintellect/index.d.ts +1 -1
- package/dist/{redact-DkObldQP.d.ts → redact-6S20u4Ii.d.ts} +5 -3
- package/dist/{runtime-B0HZbuEv.d.ts → runtime-D5u1M6T5.d.ts} +150 -94
- package/dist/{runtime-ckAefgVV.js → runtime-l9Q9-Dal.js} +6 -6
- package/dist/{runtime-ckAefgVV.js.map → runtime-l9Q9-Dal.js.map} +1 -1
- package/dist/{structural-rollout-DjUoh2aA.js → structural-rollout-CIK7nvSH.js} +2 -2
- package/dist/{structural-rollout-DjUoh2aA.js.map → structural-rollout-CIK7nvSH.js.map} +1 -1
- package/dist/{supervise-CnHd8x54.js → supervise-Dq_D3QbE.js} +5 -3
- package/dist/{supervise-CnHd8x54.js.map → supervise-Dq_D3QbE.js.map} +1 -1
- package/dist/{supervisor-Dw-5mGKr.js → supervisor-cAFpYJWF.js} +363 -68
- package/dist/supervisor-cAFpYJWF.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +11 -11
- package/package.json +1 -1
- package/dist/improvement-cycle-ipnDcl3P.js.map +0 -1
- package/dist/supervisor-Dw-5mGKr.js.map +0 -1
|
@@ -13,7 +13,7 @@ import { estimateCost, isModelPriced } from "@tangle-network/agent-eval";
|
|
|
13
13
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
14
14
|
import { basename, delimiter, dirname, isAbsolute, join, resolve, sep, win32 } from "node:path";
|
|
15
15
|
import { applyWorkspacePlan, hashWorkspacePlan, materializeProfile, resolveAgentProfileResources } from "@tangle-network/agent-profile-materialize";
|
|
16
|
-
import { access, chmod, copyFile, mkdir, mkdtemp, open, readFile, realpath, rm, symlink, writeFile } from "node:fs/promises";
|
|
16
|
+
import { access, chmod, copyFile, mkdir, mkdtemp, open, readFile, realpath, rm, rmdir, stat, symlink, writeFile } from "node:fs/promises";
|
|
17
17
|
import { appendFileSync, constants, createReadStream } from "node:fs";
|
|
18
18
|
import { spawn } from "node:child_process";
|
|
19
19
|
import { homedir, tmpdir } from "node:os";
|
|
@@ -1814,32 +1814,22 @@ async function runWorktreeHarness(opts) {
|
|
|
1814
1814
|
...opts.runGit ? { runGit: opts.runGit } : {}
|
|
1815
1815
|
});
|
|
1816
1816
|
try {
|
|
1817
|
-
const applied =
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
dangerouslySkipPermissions: true,
|
|
1822
|
-
...opts.codexReproducible ? { codexReproducible: true } : {}
|
|
1823
|
-
});
|
|
1824
|
-
const harnessResult = await runHarness({
|
|
1817
|
+
const applied = applyProfilePlan(plan, worktree.path, "runWorktreeHarness");
|
|
1818
|
+
const harnessResult = await spawnProfiledHarness({
|
|
1819
|
+
workspacePath: worktree.path,
|
|
1820
|
+
profile,
|
|
1825
1821
|
harness: opts.harness,
|
|
1826
|
-
cwd: worktree.path,
|
|
1827
1822
|
taskPrompt: opts.taskPrompt,
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
},
|
|
1832
|
-
env: {
|
|
1833
|
-
...process.env,
|
|
1834
|
-
...resolvePublicPlanEnv(applied.env)
|
|
1835
|
-
},
|
|
1823
|
+
applied,
|
|
1824
|
+
resourceInstructions,
|
|
1825
|
+
dangerouslySkipPermissions: true,
|
|
1836
1826
|
...opts.codexReproducible ? { codexReproducible: true } : {},
|
|
1837
1827
|
...opts.codexReadDeniedPaths ? { codexReadDeniedPaths: opts.codexReadDeniedPaths } : {},
|
|
1838
|
-
...opts.harnessTimeoutMs !== void 0 ? {
|
|
1839
|
-
...opts.signal ? { signal: opts.signal } : {}
|
|
1828
|
+
...opts.harnessTimeoutMs !== void 0 ? { harnessTimeoutMs: opts.harnessTimeoutMs } : {},
|
|
1829
|
+
...opts.signal ? { signal: opts.signal } : {},
|
|
1830
|
+
runHarness,
|
|
1831
|
+
context: "runWorktreeHarness"
|
|
1840
1832
|
});
|
|
1841
|
-
if (harnessResult.aborted || opts.signal?.aborted) throw new Error("runWorktreeHarness: harness was cancelled by the caller", { cause: opts.signal?.reason });
|
|
1842
|
-
opts.signal?.throwIfAborted();
|
|
1843
1833
|
const diff = await captureWorktreeDiff({
|
|
1844
1834
|
worktree,
|
|
1845
1835
|
excludePaths: applied.written,
|
|
@@ -1863,28 +1853,7 @@ async function runWorktreeHarness(opts) {
|
|
|
1863
1853
|
patch: diff.patch,
|
|
1864
1854
|
stats: diff.stats,
|
|
1865
1855
|
profileMaterialization: profileMaterializationReceipt(applied, resourceInstructions),
|
|
1866
|
-
harness:
|
|
1867
|
-
name: opts.harness,
|
|
1868
|
-
exitCode: harnessResult.exitCode,
|
|
1869
|
-
timedOut: harnessResult.timedOut,
|
|
1870
|
-
killedBySignal: harnessResult.killedBySignal,
|
|
1871
|
-
durationMs: harnessResult.durationMs,
|
|
1872
|
-
stdout: harnessResult.stdout,
|
|
1873
|
-
stderr: harnessResult.stderr,
|
|
1874
|
-
...harnessResult.usage ? { usage: harnessResult.usage } : {},
|
|
1875
|
-
...harnessResult.evidence ? {
|
|
1876
|
-
cliVersion: harnessResult.evidence.cliVersion,
|
|
1877
|
-
executableSha256: harnessResult.evidence.executableSha256,
|
|
1878
|
-
requestedPromptSha256: harnessResult.evidence.requestedPromptSha256,
|
|
1879
|
-
effectivePromptSha256: harnessResult.evidence.effectivePromptSha256,
|
|
1880
|
-
nonPromptArgsSha256: harnessResult.evidence.nonPromptArgsSha256,
|
|
1881
|
-
controlledConfigSha256: harnessResult.evidence.controlledConfigSha256,
|
|
1882
|
-
readDeniedPaths: [...harnessResult.evidence.readDeniedPaths],
|
|
1883
|
-
readDeniedPathsSha256: harnessResult.evidence.readDeniedPathsSha256,
|
|
1884
|
-
readDeniedPathCount: harnessResult.evidence.readDeniedPathCount,
|
|
1885
|
-
executionPolicy: harnessResult.evidence.policy
|
|
1886
|
-
} : {}
|
|
1887
|
-
},
|
|
1856
|
+
harness: harnessRunRecord(opts.harness, harnessResult),
|
|
1888
1857
|
...checks ? { checks } : {}
|
|
1889
1858
|
},
|
|
1890
1859
|
cleanup
|
|
@@ -1898,6 +1867,54 @@ async function runWorktreeHarness(opts) {
|
|
|
1898
1867
|
throw err;
|
|
1899
1868
|
}
|
|
1900
1869
|
}
|
|
1870
|
+
/**
|
|
1871
|
+
* Run the one worktree-harness operation against a workspace the CALLER supplies, so the harness
|
|
1872
|
+
* edits that exact directory and its edits stay there after the call.
|
|
1873
|
+
*
|
|
1874
|
+
* The profile inputs this path materializes are removed again before it returns, whether the run
|
|
1875
|
+
* succeeded, threw, or was cancelled. That is what keeps the invariant a caller reads the directory
|
|
1876
|
+
* for: after the call the workspace holds the harness's own edits and nothing else, so a
|
|
1877
|
+
* `git status` over it answers "did the author change anything" and not "did Runtime write a
|
|
1878
|
+
* settings file". A harness edit to a materialized input is removed with it, exactly as
|
|
1879
|
+
* `runWorktreeHarness` excludes those paths from its captured patch.
|
|
1880
|
+
*
|
|
1881
|
+
* The workspace is NOT created, cleaned, or removed here: its lifecycle belongs to the caller,
|
|
1882
|
+
* which is the whole point of the placement.
|
|
1883
|
+
*/
|
|
1884
|
+
async function runInPlaceHarness(opts) {
|
|
1885
|
+
opts.signal?.throwIfAborted();
|
|
1886
|
+
const runHarness = opts.runHarness ?? runLocalHarness;
|
|
1887
|
+
if (!opts.workspacePath) throw new Error("runInPlaceHarness: workspacePath required");
|
|
1888
|
+
assertSupportedWorktreeProfile(opts.profile, opts.harness);
|
|
1889
|
+
assertSafeProfileResourcePaths(opts.profile);
|
|
1890
|
+
const profile = await resolveAgentProfileResources(opts.profile, resourceResolutionOptions(opts.resourceResolution, opts.signal));
|
|
1891
|
+
opts.signal?.throwIfAborted();
|
|
1892
|
+
const { plan, resourceInstructions } = prepareWorktreeProfile(profile, opts.harness);
|
|
1893
|
+
if (!(await stat(opts.workspacePath).catch(() => void 0))?.isDirectory()) throw new Error(`runInPlaceHarness: workspacePath is not an existing directory: ${opts.workspacePath}`);
|
|
1894
|
+
const applied = applyProfilePlan(plan, opts.workspacePath, "runInPlaceHarness");
|
|
1895
|
+
try {
|
|
1896
|
+
const harnessResult = await spawnProfiledHarness({
|
|
1897
|
+
workspacePath: opts.workspacePath,
|
|
1898
|
+
profile,
|
|
1899
|
+
harness: opts.harness,
|
|
1900
|
+
taskPrompt: opts.taskPrompt,
|
|
1901
|
+
applied,
|
|
1902
|
+
resourceInstructions,
|
|
1903
|
+
dangerouslySkipPermissions: true,
|
|
1904
|
+
...opts.harnessTimeoutMs !== void 0 ? { harnessTimeoutMs: opts.harnessTimeoutMs } : {},
|
|
1905
|
+
...opts.signal ? { signal: opts.signal } : {},
|
|
1906
|
+
runHarness,
|
|
1907
|
+
context: "runInPlaceHarness"
|
|
1908
|
+
});
|
|
1909
|
+
return {
|
|
1910
|
+
workspacePath: opts.workspacePath,
|
|
1911
|
+
profileMaterialization: profileMaterializationReceipt(applied, resourceInstructions),
|
|
1912
|
+
harness: harnessRunRecord(opts.harness, harnessResult)
|
|
1913
|
+
};
|
|
1914
|
+
} finally {
|
|
1915
|
+
await removeAppliedPlanFiles(opts.workspacePath, applied.written);
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1901
1918
|
/** Compute the same plan identity `runWorktreeHarness` consumes, with no repository or process IO. */
|
|
1902
1919
|
function worktreeProfileExecutionPlan(profile, harness) {
|
|
1903
1920
|
const { plan, resourceInstructions } = prepareWorktreeProfile(profile, harness);
|
|
@@ -1907,6 +1924,93 @@ function worktreeProfileExecutionPlan(profile, harness) {
|
|
|
1907
1924
|
resourceInstructions: resourceInstructionReceipt(resourceInstructions)
|
|
1908
1925
|
});
|
|
1909
1926
|
}
|
|
1927
|
+
/** Write the profile inputs into a workspace. A plan that could not be fully expressed, or whose
|
|
1928
|
+
* path is already occupied, fails here — before any external process starts. */
|
|
1929
|
+
function applyProfilePlan(plan, workspacePath, context) {
|
|
1930
|
+
const applied = applyWorkspacePlan(plan, workspacePath, { existingFiles: "reject" });
|
|
1931
|
+
if (applied.unsupported.length > 0) throw new Error(`${context}: applied profile unexpectedly retained unsupported rows`);
|
|
1932
|
+
return applied;
|
|
1933
|
+
}
|
|
1934
|
+
/**
|
|
1935
|
+
* The ONE profile-to-process step both placements share: §1.5 prompt/model delivery through
|
|
1936
|
+
* `harnessInvocation`, the materializer's flags and environment, and the `runLocalHarness` spawn
|
|
1937
|
+
* in `workspacePath`. Neither placement re-derives argv, so a harness capability added to the
|
|
1938
|
+
* invocation table reaches both.
|
|
1939
|
+
*/
|
|
1940
|
+
async function spawnProfiledHarness(args) {
|
|
1941
|
+
const invocationProfile = profileWithResourceInstructions(args.profile, args.resourceInstructions);
|
|
1942
|
+
const { command, args: invocationArgs } = harnessInvocation(args.harness, invocationProfile, args.taskPrompt, {
|
|
1943
|
+
dangerouslySkipPermissions: args.dangerouslySkipPermissions,
|
|
1944
|
+
...args.codexReproducible ? { codexReproducible: true } : {}
|
|
1945
|
+
});
|
|
1946
|
+
const harnessResult = await args.runHarness({
|
|
1947
|
+
harness: args.harness,
|
|
1948
|
+
cwd: args.workspacePath,
|
|
1949
|
+
taskPrompt: args.taskPrompt,
|
|
1950
|
+
invocation: {
|
|
1951
|
+
command,
|
|
1952
|
+
args: [...invocationArgs, ...args.applied.flags.map(publicPlanString)]
|
|
1953
|
+
},
|
|
1954
|
+
env: {
|
|
1955
|
+
...process.env,
|
|
1956
|
+
...resolvePublicPlanEnv(args.applied.env)
|
|
1957
|
+
},
|
|
1958
|
+
...args.codexReproducible ? { codexReproducible: true } : {},
|
|
1959
|
+
...args.codexReadDeniedPaths ? { codexReadDeniedPaths: args.codexReadDeniedPaths } : {},
|
|
1960
|
+
...args.harnessTimeoutMs !== void 0 ? { timeoutMs: args.harnessTimeoutMs } : {},
|
|
1961
|
+
...args.signal ? { signal: args.signal } : {}
|
|
1962
|
+
});
|
|
1963
|
+
if (harnessResult.aborted || args.signal?.aborted) throw new Error(`${args.context}: harness was cancelled by the caller`, { cause: args.signal?.reason });
|
|
1964
|
+
args.signal?.throwIfAborted();
|
|
1965
|
+
return harnessResult;
|
|
1966
|
+
}
|
|
1967
|
+
/** Project one `LocalHarnessResult` onto the harness record both placements report. */
|
|
1968
|
+
function harnessRunRecord(name, harnessResult) {
|
|
1969
|
+
return {
|
|
1970
|
+
name,
|
|
1971
|
+
exitCode: harnessResult.exitCode,
|
|
1972
|
+
timedOut: harnessResult.timedOut,
|
|
1973
|
+
killedBySignal: harnessResult.killedBySignal,
|
|
1974
|
+
durationMs: harnessResult.durationMs,
|
|
1975
|
+
stdout: harnessResult.stdout,
|
|
1976
|
+
stderr: harnessResult.stderr,
|
|
1977
|
+
...harnessResult.usage ? { usage: harnessResult.usage } : {},
|
|
1978
|
+
...harnessResult.evidence ? {
|
|
1979
|
+
cliVersion: harnessResult.evidence.cliVersion,
|
|
1980
|
+
executableSha256: harnessResult.evidence.executableSha256,
|
|
1981
|
+
requestedPromptSha256: harnessResult.evidence.requestedPromptSha256,
|
|
1982
|
+
effectivePromptSha256: harnessResult.evidence.effectivePromptSha256,
|
|
1983
|
+
nonPromptArgsSha256: harnessResult.evidence.nonPromptArgsSha256,
|
|
1984
|
+
controlledConfigSha256: harnessResult.evidence.controlledConfigSha256,
|
|
1985
|
+
readDeniedPaths: [...harnessResult.evidence.readDeniedPaths],
|
|
1986
|
+
readDeniedPathsSha256: harnessResult.evidence.readDeniedPathsSha256,
|
|
1987
|
+
readDeniedPathCount: harnessResult.evidence.readDeniedPathCount,
|
|
1988
|
+
executionPolicy: harnessResult.evidence.policy
|
|
1989
|
+
} : {}
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
/** Remove the profile inputs written into a caller-owned workspace, plus the directories that
|
|
1993
|
+
* application created and this removal empties. A file the harness deleted itself is already
|
|
1994
|
+
* gone, and a directory that still holds anything is left alone. */
|
|
1995
|
+
async function removeAppliedPlanFiles(workspacePath, written) {
|
|
1996
|
+
const root = resolve(workspacePath);
|
|
1997
|
+
const prunable = /* @__PURE__ */ new Set();
|
|
1998
|
+
for (const relPath of written) {
|
|
1999
|
+
const absolute = resolve(root, relPath);
|
|
2000
|
+
await rm(absolute, { force: true });
|
|
2001
|
+
let parent = dirname(absolute);
|
|
2002
|
+
while (parent.length > root.length && parent.startsWith(`${root}/`)) {
|
|
2003
|
+
prunable.add(parent);
|
|
2004
|
+
parent = dirname(parent);
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
for (const directory of [...prunable].sort((a, b) => b.length - a.length)) try {
|
|
2008
|
+
await rmdir(directory);
|
|
2009
|
+
} catch (error) {
|
|
2010
|
+
const code = error.code;
|
|
2011
|
+
if (code !== "ENOTEMPTY" && code !== "ENOENT" && code !== "EEXIST") throw error;
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
1910
2014
|
function prepareWorktreeProfile(profile, harness) {
|
|
1911
2015
|
const resourceInstructions = resolveResourceInstructions(profile);
|
|
1912
2016
|
const workspaceProfile = materializationOnlyProfile(profile);
|
|
@@ -5345,6 +5449,178 @@ function priceUnreceiptedWork(work) {
|
|
|
5345
5449
|
};
|
|
5346
5450
|
}
|
|
5347
5451
|
//#endregion
|
|
5452
|
+
//#region src/runtime/supervise/task-prompt.ts
|
|
5453
|
+
/**
|
|
5454
|
+
*
|
|
5455
|
+
* The one rule for reading a leaf task as prompt text. A `Scope` task is opaque (`unknown`) and
|
|
5456
|
+
* every leaf that speaks to a text-in/text-out backend has to project it the same way, or two
|
|
5457
|
+
* placements handed the identical task send the harness different bytes.
|
|
5458
|
+
*
|
|
5459
|
+
* Module-scoped, not package surface: it is shared between sibling leaf executors, never a
|
|
5460
|
+
* published verb.
|
|
5461
|
+
*/
|
|
5462
|
+
/** A leaf task is opaque (`unknown`). A string is the prompt verbatim; an object
|
|
5463
|
+
* with a `prompt`/`content`/`task` string field uses it; otherwise it serializes. */
|
|
5464
|
+
function taskToPrompt(task) {
|
|
5465
|
+
if (typeof task === "string") return task;
|
|
5466
|
+
if (task && typeof task === "object") {
|
|
5467
|
+
const obj = task;
|
|
5468
|
+
for (const k of [
|
|
5469
|
+
"prompt",
|
|
5470
|
+
"content",
|
|
5471
|
+
"task",
|
|
5472
|
+
"message"
|
|
5473
|
+
]) if (typeof obj[k] === "string") return obj[k];
|
|
5474
|
+
if (Array.isArray(obj.parts)) {
|
|
5475
|
+
const parsed = AgentTurnInputSchema.safeParse({ parts: obj.parts });
|
|
5476
|
+
if (parsed.success && parsed.data.parts) return renderInputPartsAsText(parsed.data.parts);
|
|
5477
|
+
}
|
|
5478
|
+
}
|
|
5479
|
+
return JSON.stringify(task);
|
|
5480
|
+
}
|
|
5481
|
+
//#endregion
|
|
5482
|
+
//#region src/runtime/supervise/in-place-cli-executor.ts
|
|
5483
|
+
/**
|
|
5484
|
+
*
|
|
5485
|
+
* The in-place CLI leaf executor — a supervisor-authored `AgentProfile` driving a local
|
|
5486
|
+
* coding-harness CLI (claude-code / codex / opencode / pi) on a workspace the CALLER supplies,
|
|
5487
|
+
* surfaced as the open `Executor<Out>` port (`./types`).
|
|
5488
|
+
*
|
|
5489
|
+
* The difference from `createWorktreeCliExecutor` is the whole point of it: that leaf cuts a git
|
|
5490
|
+
* worktree of its own and hands back the diff, so the directory it was pointed at is never edited;
|
|
5491
|
+
* this leaf runs the harness in the directory it was given, so the edits ARE that directory and
|
|
5492
|
+
* they are still there when the call returns. That is what a caller needs when the workspace has
|
|
5493
|
+
* to survive between calls — a multi-shot author that resumes on top of its own edits, or a
|
|
5494
|
+
* candidate directory the caller commits itself.
|
|
5495
|
+
*
|
|
5496
|
+
* Both leaves share one physical act (`runInPlaceHarness` / `runWorktreeHarness`, both in
|
|
5497
|
+
* `../../mcp/worktree-harness`): the same profile materializer, the same `harnessInvocation`
|
|
5498
|
+
* mapper, the same subprocess spawn. Only workspace ownership differs.
|
|
5499
|
+
*
|
|
5500
|
+
* The profile inputs this path materializes are removed before it returns, so the workspace the
|
|
5501
|
+
* caller reads holds the harness's own edits and nothing else.
|
|
5502
|
+
*
|
|
5503
|
+
* Token accounting: a harness CLI run reports no usage receipt, so this leaf is `budgetExempt` and
|
|
5504
|
+
* its `Spend` marks `tokensKnown: false` — the `{0,0}` is a floor, never a measured-free run.
|
|
5505
|
+
*
|
|
5506
|
+
* @experimental
|
|
5507
|
+
*/
|
|
5508
|
+
/**
|
|
5509
|
+
* Build an in-place CLI leaf `Executor`. Per-spawn, but NOT per-workspace: repeated spawns against
|
|
5510
|
+
* the same `workspacePath` run in the same directory on purpose, each seeing what the last one
|
|
5511
|
+
* wrote.
|
|
5512
|
+
*
|
|
5513
|
+
* Fail-loud: an empty `workspacePath`, an incomplete/unsupported profile, a separate harness
|
|
5514
|
+
* override, or an explicitly empty `taskPrompt` throws at construction. A `workspacePath` that is
|
|
5515
|
+
* not an existing directory throws before the harness launches. `resultArtifact()` before
|
|
5516
|
+
* `execute()` resolves throws.
|
|
5517
|
+
*
|
|
5518
|
+
* @experimental
|
|
5519
|
+
*/
|
|
5520
|
+
function createInPlaceCliExecutor(options) {
|
|
5521
|
+
if (!options.workspacePath) throw new ValidationError("createInPlaceCliExecutor: workspacePath required");
|
|
5522
|
+
if ("harness" in options) throw new ValidationError("createInPlaceCliExecutor: separate harness is forbidden; set AgentProfile.harness");
|
|
5523
|
+
const profile = executableAgentProfileSnapshot(options.profile, "createInPlaceCliExecutor");
|
|
5524
|
+
const harness = localHarnessFromProfile$1(profile);
|
|
5525
|
+
if (options.taskPrompt !== void 0 && (typeof options.taskPrompt !== "string" || options.taskPrompt.length === 0)) throw new ValidationError("createInPlaceCliExecutor: taskPrompt required");
|
|
5526
|
+
const executionId = randomUUID();
|
|
5527
|
+
const attemptId = options.executionAttemptId ?? newExecutionAttemptId(executionId);
|
|
5528
|
+
const controller = new AbortController();
|
|
5529
|
+
let artifact;
|
|
5530
|
+
const profilePlan = worktreeProfileExecutionPlan(profile, harness);
|
|
5531
|
+
const profileModel = concreteProfileModel(profile);
|
|
5532
|
+
if (!profileModel) throw new ValidationError("createInPlaceCliExecutor: exact profile model unexpectedly missing");
|
|
5533
|
+
return attestRuntimeOwnedExecutor({
|
|
5534
|
+
runtime: "cli",
|
|
5535
|
+
budgetExempt: true,
|
|
5536
|
+
async execute(task, signal) {
|
|
5537
|
+
const linked = linkAbort(signal, controller.signal).signal;
|
|
5538
|
+
const started = Date.now();
|
|
5539
|
+
const taskPrompt = executionTaskPrompt$1(task, options.taskPrompt);
|
|
5540
|
+
const result = await runInPlaceHarness({
|
|
5541
|
+
workspacePath: options.workspacePath,
|
|
5542
|
+
profile,
|
|
5543
|
+
harness,
|
|
5544
|
+
taskPrompt,
|
|
5545
|
+
...options.harnessTimeoutMs !== void 0 ? { harnessTimeoutMs: options.harnessTimeoutMs } : {},
|
|
5546
|
+
...linked ? { signal: linked } : {},
|
|
5547
|
+
...options.runHarness ? { runHarness: options.runHarness } : {}
|
|
5548
|
+
});
|
|
5549
|
+
const spent = {
|
|
5550
|
+
iterations: 1,
|
|
5551
|
+
tokens: {
|
|
5552
|
+
input: 0,
|
|
5553
|
+
output: 0
|
|
5554
|
+
},
|
|
5555
|
+
tokensKnown: false,
|
|
5556
|
+
usd: 0,
|
|
5557
|
+
ms: Date.now() - started
|
|
5558
|
+
};
|
|
5559
|
+
artifact = {
|
|
5560
|
+
outRef: contentAddress(result),
|
|
5561
|
+
out: result,
|
|
5562
|
+
spent
|
|
5563
|
+
};
|
|
5564
|
+
return artifact;
|
|
5565
|
+
},
|
|
5566
|
+
async teardown(_grace) {
|
|
5567
|
+
controller.abort();
|
|
5568
|
+
return { destroyed: true };
|
|
5569
|
+
},
|
|
5570
|
+
resultArtifact() {
|
|
5571
|
+
if (!artifact) throw new ValidationError("createInPlaceCliExecutor: resultArtifact() read before execute() resolved");
|
|
5572
|
+
return artifact;
|
|
5573
|
+
}
|
|
5574
|
+
}, {
|
|
5575
|
+
effectiveProfile: profile,
|
|
5576
|
+
backend: `cli-in-place:${harness}`,
|
|
5577
|
+
model: {
|
|
5578
|
+
status: "known",
|
|
5579
|
+
id: profileModel
|
|
5580
|
+
},
|
|
5581
|
+
execution: {
|
|
5582
|
+
kind: "in-place-run",
|
|
5583
|
+
id: executionId
|
|
5584
|
+
},
|
|
5585
|
+
materializer: "agent-profile-worktree-plan",
|
|
5586
|
+
plan: {
|
|
5587
|
+
kind: "cli-in-place",
|
|
5588
|
+
profilePlan,
|
|
5589
|
+
harness,
|
|
5590
|
+
harnessTimeoutMs: options.harnessTimeoutMs ?? null
|
|
5591
|
+
}
|
|
5592
|
+
}, {
|
|
5593
|
+
attemptId,
|
|
5594
|
+
binding: {
|
|
5595
|
+
workspacePath: options.workspacePath,
|
|
5596
|
+
executionId,
|
|
5597
|
+
harness,
|
|
5598
|
+
model: profileModel
|
|
5599
|
+
},
|
|
5600
|
+
descriptor: {
|
|
5601
|
+
kind: "in-place-cli-run",
|
|
5602
|
+
transport: "process",
|
|
5603
|
+
backend: harness
|
|
5604
|
+
}
|
|
5605
|
+
});
|
|
5606
|
+
}
|
|
5607
|
+
function localHarnessFromProfile$1(profile) {
|
|
5608
|
+
const harness = profile.harness;
|
|
5609
|
+
if (LOCAL_HARNESSES.includes(harness)) return harness;
|
|
5610
|
+
throw new ValidationError(`createInPlaceCliExecutor: AgentProfile.harness must select ${LOCAL_HARNESSES.join(", ")}`);
|
|
5611
|
+
}
|
|
5612
|
+
/** A scoped execution task is authoritative. The configured prompt remains the unambiguous
|
|
5613
|
+
* direct-call default for `execute(undefined, signal)` consumers. */
|
|
5614
|
+
function executionTaskPrompt$1(task, configuredPrompt) {
|
|
5615
|
+
if (task === void 0) {
|
|
5616
|
+
if (configuredPrompt !== void 0) return configuredPrompt;
|
|
5617
|
+
throw new ValidationError("createInPlaceCliExecutor: execute task required when taskPrompt is not configured");
|
|
5618
|
+
}
|
|
5619
|
+
const prompt = taskToPrompt(task);
|
|
5620
|
+
if (typeof prompt !== "string" || prompt.length === 0) throw new ValidationError("createInPlaceCliExecutor: execute task produced no prompt text");
|
|
5621
|
+
return prompt;
|
|
5622
|
+
}
|
|
5623
|
+
//#endregion
|
|
5348
5624
|
//#region src/runtime/supervise/node-status.ts
|
|
5349
5625
|
/**
|
|
5350
5626
|
* Which {@link NodeStatus} values mean the node is finished.
|
|
@@ -6505,7 +6781,8 @@ function readPromptOptions(loopCtx) {
|
|
|
6505
6781
|
* bridge stamps them into the harness child's environment at spawn.
|
|
6506
6782
|
* - `router`,
|
|
6507
6783
|
* `router-tools` NO — a direct model HTTP call. There is no worker process to inherit anything.
|
|
6508
|
-
* - `cli-worktree
|
|
6784
|
+
* - `cli-worktree`,
|
|
6785
|
+
* `cli-in-place` NO — the work is dispatched through a local harness transport that exposes
|
|
6509
6786
|
* no environment channel. Wiring it means adding that channel to the transport
|
|
6510
6787
|
* first; until then it is honestly unpropagated.
|
|
6511
6788
|
* - `provider` NO — `AgentEnvironmentProvider` has no environment field on its port.
|
|
@@ -6526,6 +6803,7 @@ const WORKER_TRACE_PROPAGATION = {
|
|
|
6526
6803
|
"router-tools": false,
|
|
6527
6804
|
bridge: true,
|
|
6528
6805
|
"cli-worktree": false,
|
|
6806
|
+
"cli-in-place": false,
|
|
6529
6807
|
provider: false
|
|
6530
6808
|
};
|
|
6531
6809
|
/**
|
|
@@ -6836,6 +7114,7 @@ const bridgeModelBaseUrlHeader = "x-cli-bridge-model-base-url";
|
|
|
6836
7114
|
const bridgeProfileMaterializationSchema = "cli-bridge.profile-materialization.v2";
|
|
6837
7115
|
const bridgeUsageCostSchema = "cli-bridge.usage-cost.v1";
|
|
6838
7116
|
const cliWorktreeSeamKey = "cli-worktree";
|
|
7117
|
+
const cliInPlaceSeamKey = "cli-in-place";
|
|
6839
7118
|
const providerSeamKey = "provider";
|
|
6840
7119
|
function isLoopbackBridgeHost(hostname) {
|
|
6841
7120
|
const host = hostname.trim().toLowerCase().replace(/^\[/, "").replace(/\]$/, "");
|
|
@@ -9504,6 +9783,26 @@ const cliWorktreeExecutor = (spec, ctx) => {
|
|
|
9504
9783
|
...ctx.node?.attemptId !== void 0 ? { executionAttemptId: ctx.node.attemptId } : {}
|
|
9505
9784
|
});
|
|
9506
9785
|
};
|
|
9786
|
+
/**
|
|
9787
|
+
* The leaf `createInPlaceCliExecutor` as a backend-as-data factory: a supervisor-authored
|
|
9788
|
+
* `AgentProfile` driving a local coding CLI in the workspace the caller supplied, so its edits are
|
|
9789
|
+
* still there for the next spawn. `budgetExempt` like the other CLI leaves; the authored
|
|
9790
|
+
* systemPrompt + model reach the harness via §1.5.
|
|
9791
|
+
*/
|
|
9792
|
+
const cliInPlaceExecutor = (spec, ctx) => {
|
|
9793
|
+
const seam = readSeam(ctx, cliInPlaceSeamKey, "cli-in-place");
|
|
9794
|
+
if (!seam.workspacePath) throw new ValidationError("cliInPlaceExecutor: CliInPlaceSeam.workspacePath required");
|
|
9795
|
+
const effectiveProfile = agentProfileSchema.parse(spec.profile);
|
|
9796
|
+
assertExecutableAgentProfile(effectiveProfile, "cliInPlaceExecutor");
|
|
9797
|
+
return createInPlaceCliExecutor({
|
|
9798
|
+
workspacePath: seam.workspacePath,
|
|
9799
|
+
profile: effectiveProfile,
|
|
9800
|
+
...seam.taskPrompt !== void 0 ? { taskPrompt: seam.taskPrompt } : {},
|
|
9801
|
+
...seam.harnessTimeoutMs !== void 0 ? { harnessTimeoutMs: seam.harnessTimeoutMs } : {},
|
|
9802
|
+
...seam.runHarness ? { runHarness: seam.runHarness } : {},
|
|
9803
|
+
...ctx.node?.attemptId !== void 0 ? { executionAttemptId: ctx.node.attemptId } : {}
|
|
9804
|
+
});
|
|
9805
|
+
};
|
|
9507
9806
|
function assertExactConfigKeys(value, allowed, context) {
|
|
9508
9807
|
const unknown = Object.keys(value).filter((key) => !allowed.has(key));
|
|
9509
9808
|
if (unknown.length > 0) throw new ValidationError(`${context}: unknown fields ${unknown.sort().join(", ")}; execution behavior belongs in AgentProfile`);
|
|
@@ -9549,6 +9848,21 @@ function snapshotExecutorConfig(config) {
|
|
|
9549
9848
|
...runCommand === void 0 ? {} : { runCommand }
|
|
9550
9849
|
});
|
|
9551
9850
|
}
|
|
9851
|
+
case "cli-in-place": {
|
|
9852
|
+
assertExactConfigKeys(config, /* @__PURE__ */ new Set([
|
|
9853
|
+
"backend",
|
|
9854
|
+
"harnessTimeoutMs",
|
|
9855
|
+
"runHarness",
|
|
9856
|
+
"taskPrompt",
|
|
9857
|
+
"workspacePath"
|
|
9858
|
+
]), "createExecutor cli-in-place config");
|
|
9859
|
+
const { runHarness, ...decisionData } = config;
|
|
9860
|
+
const snapshot = detachedSnapshot(decisionData, "createExecutor cli-in-place config");
|
|
9861
|
+
return Object.freeze({
|
|
9862
|
+
...snapshot,
|
|
9863
|
+
...runHarness === void 0 ? {} : { runHarness }
|
|
9864
|
+
});
|
|
9865
|
+
}
|
|
9552
9866
|
case "provider": {
|
|
9553
9867
|
const { provider, registry, profileForCreate, taskToTurn, ...decisionData } = config;
|
|
9554
9868
|
const snapshot = detachedSnapshot(decisionData, "createExecutor provider config");
|
|
@@ -9653,6 +9967,7 @@ function bindReusableExecutorExecutionId(captured, executionId) {
|
|
|
9653
9967
|
case "router":
|
|
9654
9968
|
case "router-tools":
|
|
9655
9969
|
case "cli":
|
|
9970
|
+
case "cli-in-place":
|
|
9656
9971
|
case "provider":
|
|
9657
9972
|
case "sandbox": return captured;
|
|
9658
9973
|
}
|
|
@@ -9684,6 +9999,7 @@ function createExecutor(config) {
|
|
|
9684
9999
|
case "bridge": return bridgeExecutor(spec, seamed);
|
|
9685
10000
|
case "cli": return cliExecutor(spec, seamed);
|
|
9686
10001
|
case "cli-worktree": return cliWorktreeExecutor(spec, seamed);
|
|
10002
|
+
case "cli-in-place": return cliInPlaceExecutor(spec, seamed);
|
|
9687
10003
|
case "provider": {
|
|
9688
10004
|
const providerSeam = readSeam(seamed, providerSeamKey, "provider");
|
|
9689
10005
|
const provider = resolveAgentEnvironmentProvider(providerSeam.provider, providerSeam.registry);
|
|
@@ -9827,27 +10143,6 @@ function readOptionalMcpAttachments(ctx, key, who) {
|
|
|
9827
10143
|
if (entries === void 0 || entries.length === 0 || entries.some(([, server]) => server === null || typeof server !== "object")) throw new ValidationError(`${who} executor: seam ${JSON.stringify(key)} must be a non-empty map of MCP servers`);
|
|
9828
10144
|
return value;
|
|
9829
10145
|
}
|
|
9830
|
-
/** A leaf task is opaque (`unknown`). A string is the prompt verbatim; an object
|
|
9831
|
-
* with a `prompt`/`content`/`task` string field uses it; otherwise it serializes.
|
|
9832
|
-
* Module-exported (not package surface) so sibling leaf executors read a task
|
|
9833
|
-
* identically instead of re-deriving the rule. */
|
|
9834
|
-
function taskToPrompt(task) {
|
|
9835
|
-
if (typeof task === "string") return task;
|
|
9836
|
-
if (task && typeof task === "object") {
|
|
9837
|
-
const obj = task;
|
|
9838
|
-
for (const k of [
|
|
9839
|
-
"prompt",
|
|
9840
|
-
"content",
|
|
9841
|
-
"task",
|
|
9842
|
-
"message"
|
|
9843
|
-
]) if (typeof obj[k] === "string") return obj[k];
|
|
9844
|
-
if (Array.isArray(obj.parts)) {
|
|
9845
|
-
const parsed = AgentTurnInputSchema.safeParse({ parts: obj.parts });
|
|
9846
|
-
if (parsed.success && parsed.data.parts) return renderInputPartsAsText(parsed.data.parts);
|
|
9847
|
-
}
|
|
9848
|
-
}
|
|
9849
|
-
return JSON.stringify(task);
|
|
9850
|
-
}
|
|
9851
10146
|
/** Validate and render every AgentProfile axis the direct Router path claims to carry.
|
|
9852
10147
|
* Unsupported behavioral axes fail before the HTTP request; inline resources become
|
|
9853
10148
|
* named system-prompt attachments because this executor has no workspace to mount. */
|
|
@@ -13408,6 +13703,6 @@ function isNonEmptySpend(s) {
|
|
|
13408
13703
|
return s.iterations > 0 || s.tokens.input > 0 || s.tokens.output > 0 || s.usd > 0 || s.ms > 0 || s.tokensKnown === false || s.usdKnown === false;
|
|
13409
13704
|
}
|
|
13410
13705
|
//#endregion
|
|
13411
|
-
export {
|
|
13706
|
+
export { createSteerableSandboxSession as $, runWorktreeHarness as $t, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as A, createPropagatingTraceEmitter as At, captureReusableExecutorConfig as B, exportEvalRuns as Bt, timerAt as C, validateProfileMaterialization as Cn, createSandboxLineage as Ct, freeSlots as D, runBrainLoop as Dt, effectiveConcurrency as E, routerBrain as Et, bindReusableExecutorExecutionId as F, buildLoopOtelSpans as Ft, snapshotExecutorConfig as G, padTraceId as Gt, cliWorktreeExecutor as H, generateSpanId as Ht, bridgeAdmissionRead as I, buildLoopSpanNodes as It, readWorkerTraceContext as J, createRuntimeStreamEventCollector as Jt, createWorktreeCliExecutor as K, toOtelAttributes as Kt, bridgeModelRouteRefusal as L, buildRuntimeEventOtelSpans as Lt, assertValidBudget as M, readTraceContextFromEnv as Mt, createBudgetPool as N, traceContextToEnv as Nt, queueOf as O, canonicalObservedModel as Ot, spendFromUsageEvents as P, INTELLIGENCE_WIRE_VERSION as Pt, DEFAULT_SANDBOX_STEERING_MAX_TURNS as Q, runSettledCommand as Qt, bridgeRuntimeAttachmentsKey as R, createOpenInferenceFileExporter as Rt, pollFor as S, unsupportedProfileDimensions as Sn, runAgentRounds as St, waitUntil as T, acquireSandbox as Tt, createExecutor as U, loopEventToOtelSpan as Ut, cliInPlaceExecutor as V, flatOtelSpan as Vt, createExecutorRegistry as W, padSpanId as Wt, workerTraceHeaders as X, sanitizeKnowledgeReadinessReport as Xt, workerTraceEnv as Y, sanitizeAgentRuntimeEvent as Yt, workerTraceSeamKey as Z, sanitizeRuntimeStreamEvent as Zt, recordScopeOwnerMaterialization as _, promptOnlyProfileMaterialization as _n, createInPlaceCliExecutor as _t, uncertainSpawnBudgets as a, harnessSupportsReasoningEffort as an, readWorkerProgress as at, createWaitProbes as b, renderUnsupported as bn, defaultSelectWinner as bt, pickBestDelivered as c, CodexExecutionDiagnosticError as cn, DEFAULT_PEER_MAIL_LIMITS as ct, driverChild as d, controlProfileMaterialization as dn, createPeerMailbox as dt, captureWorktreeDiff as en, createPushTraceSource as et, withDriverExecutor as f, defineProfileMaterializationContract as fn, isPeerMailEnvelope as ft, meterRuntimeOwnedProviderAttempt as g, promptModelProfileMaterialization as gn, isTerminalNodeStatus as gt, meterRuntimeOwnedAccounting as h, promptControlProfileMaterialization as hn, isLiveNodeStatus as ht, sumMeasuredSpendFromEvents as i, LOCAL_HARNESSES as in, createActivityLog as it, teardownExecutor as j, mergeTraceEnv as jt, rollingDispatch as k, observedModelMatchesDeclared as kt, runFinalizer as l, AGENT_PROFILE_MATERIALIZATION_AXES as ln, PEER_MAIL_WIRE_KEY as lt, deriveNodeExecutionIdentity as m, profileMaterializationAxes$1 as mn, peerMailVerbNames as mt, createSupervisor as n, removeWorktree as nn, sandboxSessionTraceSource as nt, bestDelivered as o, localHarnessExecutable as on, createInbox as ot, createScope as p, fullProfileMaterialization as pn, peerMailTools as pt, WORKER_TRACE_PROPAGATION as q, createRuntimeEventCollector as qt, maxSeqOf as r, DEFAULT_LOCAL_HARNESS as rn, DEFAULT_STALL_AFTER_MS as rt, collectDelivered as s, parseCodexTokenUsage as sn, AUTHORITY_MARKERS as st, createRootHandle as t, createWorktree as tn, decodeToolPart as tt, runTree as u, assertProfileMaterialization as un, claimsAuthority as ut, scopeOwnerExecutorNodeContext as v, promptResourceProfileMaterialization as vn, TERMINAL_DECISIONS as vt, validateWaitSpec as w, worktreeCliProfileMaterialization as wn, probeSandboxCapabilities as wt, isWaitOutcome as x, sandboxActProfileMaterialization as xn, isTerminalDecision as xt, settledToIteration as y, renderProfileMaterializationIssues as yn, createSandboxForSpec as yt, bridgeStopSignalKey as z, createOtelExporter as zt };
|
|
13412
13707
|
|
|
13413
|
-
//# sourceMappingURL=supervisor-
|
|
13708
|
+
//# sourceMappingURL=supervisor-cAFpYJWF.js.map
|