@lobehub/cli 0.0.184 → 0.0.186
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/acceptance-report.html +234 -234
- package/dist/index.js +571 -60
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7986,6 +7986,11 @@ var init_agentExecution = __esmMin((() => {
|
|
|
7986
7986
|
* Experience); the topic's first dispatched run starts in it.
|
|
7987
7987
|
*/
|
|
7988
7988
|
heteroPermissionMode: _enum(HETERO_PERMISSION_MODES).optional(),
|
|
7989
|
+
/**
|
|
7990
|
+
* Codex Plan switch the composer showed (Better Coding Experience); the
|
|
7991
|
+
* topic's first native turn sends `plan` / `default` from it.
|
|
7992
|
+
*/
|
|
7993
|
+
heteroPlanMode: boolean().optional(),
|
|
7989
7994
|
repos: array(string()).optional(),
|
|
7990
7995
|
/**
|
|
7991
7996
|
* Cloud-sandbox placement the composer chose before any topic existed — an
|
|
@@ -11144,6 +11149,11 @@ var init_topic$1 = __esmMin((() => {
|
|
|
11144
11149
|
heteroSessionIdByWorkingDirectory: record(string(), string()).optional(),
|
|
11145
11150
|
heteroPermissionMode: _enum(HETERO_PERMISSION_MODES).optional(),
|
|
11146
11151
|
heteroPermissionModeFallback: _enum(["outdatedCli", "root"]).nullable().optional(),
|
|
11152
|
+
heteroPlanMode: boolean().optional(),
|
|
11153
|
+
codexPlanDecision: object$1({
|
|
11154
|
+
dismissed: boolean(),
|
|
11155
|
+
itemId: string().min(1)
|
|
11156
|
+
}).nullable().optional(),
|
|
11147
11157
|
heteroSpeed: _enum([
|
|
11148
11158
|
"default",
|
|
11149
11159
|
"normal",
|
|
@@ -12423,6 +12433,19 @@ var init_connector = __esmMin((() => {}));
|
|
|
12423
12433
|
//#region ../../packages/types/src/connectorToolIdentifier.ts
|
|
12424
12434
|
var init_connectorToolIdentifier = __esmMin((() => {}));
|
|
12425
12435
|
|
|
12436
|
+
//#endregion
|
|
12437
|
+
//#region ../../packages/types/src/worktreeMode.ts
|
|
12438
|
+
var init_worktreeMode = __esmMin((() => {}));
|
|
12439
|
+
|
|
12440
|
+
//#endregion
|
|
12441
|
+
//#region ../../packages/types/src/heteroPlanMode.ts
|
|
12442
|
+
var CODEX_COLLABORATION_MODES, isCodexCollaborationMode, CODEX_COLLABORATION_MODE_RUNTIME;
|
|
12443
|
+
var init_heteroPlanMode = __esmMin((() => {
|
|
12444
|
+
CODEX_COLLABORATION_MODES = ["plan", "default"];
|
|
12445
|
+
isCodexCollaborationMode = (value) => typeof value === "string" && CODEX_COLLABORATION_MODES.includes(value);
|
|
12446
|
+
CODEX_COLLABORATION_MODE_RUNTIME = "codex-collaboration-mode-v1";
|
|
12447
|
+
}));
|
|
12448
|
+
|
|
12426
12449
|
//#endregion
|
|
12427
12450
|
//#region ../../packages/types/src/inboundWebhook.ts
|
|
12428
12451
|
var GENERIC_WEBHOOK_TOPIC_MODES, GENERIC_WEBHOOK_IDENTIFIER_PATTERN, InboundWebhookChannelDeliverySchema, McpEventsWebhookConfigSchema, McpEventsWebhookStateSchema, McpEventsWebhookVerificationSchema, GenericWebhookConfigSchema, GenericWebhookStateSchema, GenericWebhookVerificationSchema, InboundWebhookDataSchema;
|
|
@@ -12516,10 +12539,6 @@ var init_trace = __esmMin((() => {
|
|
|
12516
12539
|
//#region ../../packages/types/src/util.ts
|
|
12517
12540
|
var init_util$2 = __esmMin((() => {}));
|
|
12518
12541
|
|
|
12519
|
-
//#endregion
|
|
12520
|
-
//#region ../../packages/types/src/worktreeMode.ts
|
|
12521
|
-
var init_worktreeMode = __esmMin((() => {}));
|
|
12522
|
-
|
|
12523
12542
|
//#endregion
|
|
12524
12543
|
//#region ../../packages/types/src/zustand.ts
|
|
12525
12544
|
var init_zustand = __esmMin((() => {}));
|
|
@@ -12633,6 +12652,7 @@ var init_src$2 = __esmMin((() => {
|
|
|
12633
12652
|
init_connector();
|
|
12634
12653
|
init_connectorToolIdentifier();
|
|
12635
12654
|
init_heteroPermissionMode();
|
|
12655
|
+
init_heteroPlanMode();
|
|
12636
12656
|
init_inboundWebhook();
|
|
12637
12657
|
init_oauthApp();
|
|
12638
12658
|
init_chat();
|
|
@@ -60370,10 +60390,234 @@ const buildAntigravityArgs = ({ extraArgs = [], resumeSessionId }) => {
|
|
|
60370
60390
|
];
|
|
60371
60391
|
};
|
|
60372
60392
|
|
|
60393
|
+
//#endregion
|
|
60394
|
+
//#region ../../packages/heterogeneous-agents/src/spawn/wsl.ts
|
|
60395
|
+
var WSL_COMMAND_PREFIX, isWslCommand, parseWslCommand, formatWslCommand, getWslExecutable, toWslPath, toWslArg, NEVER_FORWARDED, FORWARDED_PREFIXES, FORWARDED_PROXY, ENV_NAME, collectForwardedEnvNames, mergeWslEnv, buildWslSpawnPlan, WSL_PROBE_TIMEOUT_MS, WSL_LIST_TIMEOUT_MS, PATH_MARKER, COMMAND_MARKER, WSL_PROBED_COMMANDS, PROBE_SCRIPT, runWsl, decodeWslOutput, parseWslDistroList, parseWslProbeOutput, distrosPromise, distroProbes, settledPathEnv, listWslDistros, probeWslDistro, invalidateWslCache, findWslCommandCandidates, getWslPathEnv;
|
|
60396
|
+
var init_wsl = __esmMin((() => {
|
|
60397
|
+
init_config();
|
|
60398
|
+
WSL_COMMAND_PREFIX = "wsl://";
|
|
60399
|
+
isWslCommand = (command) => command.trim().toLowerCase().startsWith(WSL_COMMAND_PREFIX);
|
|
60400
|
+
parseWslCommand = (command) => {
|
|
60401
|
+
const trimmed = command.trim();
|
|
60402
|
+
if (!isWslCommand(trimmed)) return;
|
|
60403
|
+
const rest = trimmed.slice(6);
|
|
60404
|
+
const slash = rest.indexOf("/");
|
|
60405
|
+
if (slash <= 0) return;
|
|
60406
|
+
const linuxPath = rest.slice(slash);
|
|
60407
|
+
if (linuxPath.length < 2) return;
|
|
60408
|
+
return {
|
|
60409
|
+
distro: rest.slice(0, slash),
|
|
60410
|
+
linuxPath
|
|
60411
|
+
};
|
|
60412
|
+
};
|
|
60413
|
+
formatWslCommand = ({ distro, linuxPath }) => `${WSL_COMMAND_PREFIX}${distro}${linuxPath}`;
|
|
60414
|
+
getWslExecutable = (env = process.env) => `${(env.SystemRoot || env.SYSTEMROOT || "C:\\Windows").replace(/[\\/]+$/, "")}\\System32\\wsl.exe`;
|
|
60415
|
+
toWslPath = (value) => {
|
|
60416
|
+
const drive = value.match(/^([A-Za-z]):[\\/](.*)$/s);
|
|
60417
|
+
if (drive) {
|
|
60418
|
+
const rest = drive[2].replaceAll("\\", "/");
|
|
60419
|
+
return `/mnt/${drive[1].toLowerCase()}${rest ? `/${rest}` : ""}`;
|
|
60420
|
+
}
|
|
60421
|
+
const unc = value.match(/^\\\\wsl(?:\$|\.localhost)\\[^\\]+(\\.*)?$/i);
|
|
60422
|
+
if (unc) return (unc[1] ?? "\\").replaceAll("\\", "/");
|
|
60423
|
+
return value;
|
|
60424
|
+
};
|
|
60425
|
+
toWslArg = (arg) => {
|
|
60426
|
+
const translated = toWslPath(arg);
|
|
60427
|
+
if (translated !== arg) return translated;
|
|
60428
|
+
const flag = arg.match(/^(--?[\w-]+=)(.+)$/s);
|
|
60429
|
+
if (!flag) return arg;
|
|
60430
|
+
const value = toWslPath(flag[2]);
|
|
60431
|
+
return value === flag[2] ? arg : `${flag[1]}${value}`;
|
|
60432
|
+
};
|
|
60433
|
+
NEVER_FORWARDED = new Set([
|
|
60434
|
+
"appdata",
|
|
60435
|
+
"comspec",
|
|
60436
|
+
"home",
|
|
60437
|
+
"homedrive",
|
|
60438
|
+
"homepath",
|
|
60439
|
+
"localappdata",
|
|
60440
|
+
"path",
|
|
60441
|
+
"pathext",
|
|
60442
|
+
"programdata",
|
|
60443
|
+
"programfiles",
|
|
60444
|
+
"programfiles(x86)",
|
|
60445
|
+
"pwd",
|
|
60446
|
+
"shell",
|
|
60447
|
+
"systemroot",
|
|
60448
|
+
"temp",
|
|
60449
|
+
"tmp",
|
|
60450
|
+
"userprofile",
|
|
60451
|
+
"windir",
|
|
60452
|
+
"wslenv"
|
|
60453
|
+
]);
|
|
60454
|
+
FORWARDED_PREFIXES = [
|
|
60455
|
+
"ANTHROPIC_",
|
|
60456
|
+
"CLAUDE_",
|
|
60457
|
+
"CODEX_",
|
|
60458
|
+
"CURSOR_",
|
|
60459
|
+
"DEEPSEEK_",
|
|
60460
|
+
"DSH_",
|
|
60461
|
+
"LOBEHUB_",
|
|
60462
|
+
"OPENAI_"
|
|
60463
|
+
];
|
|
60464
|
+
FORWARDED_PROXY = /^(?:all|http|https|no)_proxy$/i;
|
|
60465
|
+
ENV_NAME = /^[A-Za-z_]\w*$/;
|
|
60466
|
+
collectForwardedEnvNames = (env) => Object.keys(env).filter((name) => {
|
|
60467
|
+
if (!ENV_NAME.test(name) || NEVER_FORWARDED.has(name.toLowerCase())) return false;
|
|
60468
|
+
if (env[name] === void 0) return false;
|
|
60469
|
+
return env[name] !== process.env[name] || FORWARDED_PREFIXES.some((prefix) => name.toUpperCase().startsWith(prefix)) || FORWARDED_PROXY.test(name);
|
|
60470
|
+
});
|
|
60471
|
+
mergeWslEnv = (current, names) => {
|
|
60472
|
+
const entries = (current ?? "").split(":").filter(Boolean);
|
|
60473
|
+
const present = new Set(entries.map((entry) => entry.split("/")[0].toLowerCase()));
|
|
60474
|
+
for (const name of names) if (!present.has(name.toLowerCase())) entries.push(`${name}/u`);
|
|
60475
|
+
return entries.join(":");
|
|
60476
|
+
};
|
|
60477
|
+
buildWslSpawnPlan = ({ distro, linuxPath }, args, env, pathEnv) => {
|
|
60478
|
+
const forwarded = env ? collectForwardedEnvNames(env) : [];
|
|
60479
|
+
return {
|
|
60480
|
+
args: [
|
|
60481
|
+
"--distribution",
|
|
60482
|
+
distro,
|
|
60483
|
+
"--exec",
|
|
60484
|
+
...pathEnv ? ["env", `PATH=${pathEnv}`] : [],
|
|
60485
|
+
linuxPath,
|
|
60486
|
+
...args.map(toWslArg)
|
|
60487
|
+
],
|
|
60488
|
+
command: getWslExecutable(env),
|
|
60489
|
+
env: env && forwarded.length > 0 ? {
|
|
60490
|
+
...env,
|
|
60491
|
+
WSLENV: mergeWslEnv(env.WSLENV, forwarded)
|
|
60492
|
+
} : env
|
|
60493
|
+
};
|
|
60494
|
+
};
|
|
60495
|
+
WSL_PROBE_TIMEOUT_MS = 2e4;
|
|
60496
|
+
WSL_LIST_TIMEOUT_MS = 5e3;
|
|
60497
|
+
PATH_MARKER = "__LOBEHUB_WSL_PATH__=";
|
|
60498
|
+
COMMAND_MARKER = "__LOBEHUB_WSL_CMD__=";
|
|
60499
|
+
WSL_PROBED_COMMANDS = [...new Set([
|
|
60500
|
+
...HETEROGENEOUS_AGENT_CONFIGS.map((config) => config.defaultCommand),
|
|
60501
|
+
"cursor-agent",
|
|
60502
|
+
"dsh"
|
|
60503
|
+
])].filter((name) => /^[\w.-]+$/.test(name));
|
|
60504
|
+
PROBE_SCRIPT = `lobehub_shell="\${SHELL:-/bin/sh}"
|
|
60505
|
+
case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/sh ;; esac
|
|
60506
|
+
"$lobehub_shell" -ilc 'printf "\\n${PATH_MARKER}%s\\n" "$PATH"; for c in "$@"; do p=$(command -v "$c" 2>/dev/null) || continue; case "$p" in /*) printf "${COMMAND_MARKER}%s=%s\\n" "$c" "$p" ;; esac; done' lobehub "$@" </dev/null
|
|
60507
|
+
`;
|
|
60508
|
+
runWsl = (args, { env, input, timeout }) => new Promise((resolve, reject) => {
|
|
60509
|
+
let settled = false;
|
|
60510
|
+
const finish = (error, output) => {
|
|
60511
|
+
if (settled) return;
|
|
60512
|
+
settled = true;
|
|
60513
|
+
clearTimeout(timer);
|
|
60514
|
+
if (error) reject(error);
|
|
60515
|
+
else resolve(output);
|
|
60516
|
+
};
|
|
60517
|
+
const child = spawn(getWslExecutable(env), args, {
|
|
60518
|
+
env: {
|
|
60519
|
+
...env ?? process.env,
|
|
60520
|
+
WSL_UTF8: "1"
|
|
60521
|
+
},
|
|
60522
|
+
stdio: [
|
|
60523
|
+
"pipe",
|
|
60524
|
+
"pipe",
|
|
60525
|
+
"ignore"
|
|
60526
|
+
],
|
|
60527
|
+
windowsHide: true
|
|
60528
|
+
});
|
|
60529
|
+
const chunks = [];
|
|
60530
|
+
const timer = setTimeout(() => {
|
|
60531
|
+
child.kill();
|
|
60532
|
+
finish(/* @__PURE__ */ new Error("Timed out waiting for WSL"));
|
|
60533
|
+
}, timeout);
|
|
60534
|
+
child.stdout?.on("data", (chunk) => chunks.push(chunk));
|
|
60535
|
+
child.on("error", (error) => finish(error));
|
|
60536
|
+
child.on("close", (code) => {
|
|
60537
|
+
if (code === 0) finish(void 0, Buffer.concat(chunks));
|
|
60538
|
+
else finish(/* @__PURE__ */ new Error(`wsl.exe exited with code ${code}`));
|
|
60539
|
+
});
|
|
60540
|
+
child.stdin?.on("error", () => {});
|
|
60541
|
+
child.stdin?.end(input ?? "");
|
|
60542
|
+
});
|
|
60543
|
+
decodeWslOutput = (output) => (output.includes(0) ? output.toString("utf16le") : output.toString("utf8")).replace(/^\uFEFF/, "");
|
|
60544
|
+
parseWslDistroList = (output) => output.split(/\r?\n/).map((line) => line.replaceAll("\0", "").trim()).filter((name) => name && !/^docker-desktop/i.test(name));
|
|
60545
|
+
parseWslProbeOutput = (output) => {
|
|
60546
|
+
const commands = /* @__PURE__ */ new Map();
|
|
60547
|
+
let pathEnv;
|
|
60548
|
+
for (const rawLine of output.split(/\r?\n/)) {
|
|
60549
|
+
const line = rawLine.trim();
|
|
60550
|
+
if (line.startsWith(PATH_MARKER)) pathEnv = line.slice(21) || void 0;
|
|
60551
|
+
else if (line.startsWith(COMMAND_MARKER)) {
|
|
60552
|
+
const entry = line.slice(20);
|
|
60553
|
+
const separator = entry.indexOf("=");
|
|
60554
|
+
const name = entry.slice(0, separator);
|
|
60555
|
+
const linuxPath = entry.slice(separator + 1);
|
|
60556
|
+
if (separator > 0 && linuxPath.startsWith("/")) commands.set(name, linuxPath);
|
|
60557
|
+
}
|
|
60558
|
+
}
|
|
60559
|
+
return {
|
|
60560
|
+
commands,
|
|
60561
|
+
pathEnv
|
|
60562
|
+
};
|
|
60563
|
+
};
|
|
60564
|
+
;
|
|
60565
|
+
distroProbes = /* @__PURE__ */ new Map();
|
|
60566
|
+
settledPathEnv = /* @__PURE__ */ new Map();
|
|
60567
|
+
listWslDistros = () => {
|
|
60568
|
+
distrosPromise ??= runWsl(["--list", "--quiet"], { timeout: WSL_LIST_TIMEOUT_MS }).then((output) => parseWslDistroList(decodeWslOutput(output))).catch(() => []);
|
|
60569
|
+
return distrosPromise;
|
|
60570
|
+
};
|
|
60571
|
+
probeWslDistro = (distro) => {
|
|
60572
|
+
let probe = distroProbes.get(distro);
|
|
60573
|
+
if (!probe) {
|
|
60574
|
+
probe = runWsl([
|
|
60575
|
+
"--distribution",
|
|
60576
|
+
distro,
|
|
60577
|
+
"--exec",
|
|
60578
|
+
"sh",
|
|
60579
|
+
"-s",
|
|
60580
|
+
"--",
|
|
60581
|
+
...WSL_PROBED_COMMANDS
|
|
60582
|
+
], {
|
|
60583
|
+
input: PROBE_SCRIPT,
|
|
60584
|
+
timeout: WSL_PROBE_TIMEOUT_MS
|
|
60585
|
+
}).then((output) => {
|
|
60586
|
+
const result = parseWslProbeOutput(decodeWslOutput(output));
|
|
60587
|
+
settledPathEnv.set(distro, result.pathEnv);
|
|
60588
|
+
return result;
|
|
60589
|
+
}).catch(() => {
|
|
60590
|
+
distroProbes.delete(distro);
|
|
60591
|
+
});
|
|
60592
|
+
distroProbes.set(distro, probe);
|
|
60593
|
+
}
|
|
60594
|
+
return probe;
|
|
60595
|
+
};
|
|
60596
|
+
invalidateWslCache = () => {
|
|
60597
|
+
distrosPromise = void 0;
|
|
60598
|
+
distroProbes.clear();
|
|
60599
|
+
settledPathEnv.clear();
|
|
60600
|
+
};
|
|
60601
|
+
findWslCommandCandidates = async (command) => {
|
|
60602
|
+
if (platform() !== "win32") return [];
|
|
60603
|
+
const distros = await listWslDistros();
|
|
60604
|
+
const probes = await Promise.all(distros.map((distro) => probeWslDistro(distro)));
|
|
60605
|
+
return distros.flatMap((distro, index) => {
|
|
60606
|
+
const linuxPath = probes[index]?.commands.get(command);
|
|
60607
|
+
return linuxPath ? [formatWslCommand({
|
|
60608
|
+
distro,
|
|
60609
|
+
linuxPath
|
|
60610
|
+
})] : [];
|
|
60611
|
+
});
|
|
60612
|
+
};
|
|
60613
|
+
getWslPathEnv = async (distro) => (await probeWslDistro(distro))?.pathEnv;
|
|
60614
|
+
}));
|
|
60615
|
+
|
|
60373
60616
|
//#endregion
|
|
60374
60617
|
//#region ../../packages/heterogeneous-agents/src/spawn/cliSpawn.ts
|
|
60375
|
-
var WINDOWS_EXE_EXT_PATTERN, WINDOWS_MAX_COMMAND_LINE_LENGTH, WINDOWS_NODE_EXE_PATTERN, isWindows$1, quoteWindowsCommandLineArgument, assertWindowsCommandLineFits, isPathLikeCommand$1, fileExists$1, execFileString, pickWindowsNodeExecutable, joinShimRelativePath, resolveShimPathToken, getExistingShimPathToken, resolveWindowsNodeCommand, getNodeCommand, getNodeScriptTarget, inferWindowsNodeScriptFromShim, inferWindowsExecutableFromShim, inferWindowsNpmShimTarget, resolveWindowsBareCommand, resolveCliSpawnPlan;
|
|
60618
|
+
var WINDOWS_EXE_EXT_PATTERN, WINDOWS_MAX_COMMAND_LINE_LENGTH, WINDOWS_NODE_EXE_PATTERN, isWindows$1, quoteWindowsCommandLineArgument, assertWindowsCommandLineFits, isPathLikeCommand$1, fileExists$1, execFileString, pickWindowsNodeExecutable, joinShimRelativePath, resolveShimPathToken, getExistingShimPathToken, resolveWindowsNodeCommand, getNodeCommand, getNodeScriptTarget, inferWindowsNodeScriptFromShim, inferWindowsExecutableFromShim, inferWindowsPowerShellShimTarget, inferWindowsNpmShimTarget, resolveWindowsBareCommand, resolveCliSpawnPlan;
|
|
60376
60619
|
var init_cliSpawn = __esmMin((() => {
|
|
60620
|
+
init_wsl();
|
|
60377
60621
|
WINDOWS_EXE_EXT_PATTERN = /\.exe$/i;
|
|
60378
60622
|
WINDOWS_MAX_COMMAND_LINE_LENGTH = 32767;
|
|
60379
60623
|
WINDOWS_NODE_EXE_PATTERN = /(?:^|[\\/])node(?:\.exe)?$/i;
|
|
@@ -60489,12 +60733,33 @@ var init_cliSpawn = __esmMin((() => {
|
|
|
60489
60733
|
if (await fileExists$1(command)) return { command };
|
|
60490
60734
|
}
|
|
60491
60735
|
};
|
|
60736
|
+
inferWindowsPowerShellShimTarget = async (shimPath, source, env) => {
|
|
60737
|
+
const match = source.match(/\b(powershell|pwsh)(?:\.exe)?\b[^\r\n]*?-File\s+"?(%(?:~dp0|dp0%))?\\?([^"\r\n]+?\.ps1)"?/i);
|
|
60738
|
+
if (!match) return;
|
|
60739
|
+
const [, host, relativeToShim, scriptToken] = match;
|
|
60740
|
+
const script = relativeToShim ? joinShimRelativePath(shimPath, scriptToken) : scriptToken.replaceAll("/", "\\");
|
|
60741
|
+
if (!path.win32.isAbsolute(script) || !await fileExists$1(script)) return;
|
|
60742
|
+
const systemRoot = env?.SystemRoot || process.env.SystemRoot || "C:\\Windows";
|
|
60743
|
+
const command = host.toLowerCase() === "pwsh" ? "pwsh.exe" : path.win32.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
60744
|
+
return {
|
|
60745
|
+
argsPrefix: [
|
|
60746
|
+
"-NoLogo",
|
|
60747
|
+
"-NoProfile",
|
|
60748
|
+
"-NonInteractive",
|
|
60749
|
+
"-ExecutionPolicy",
|
|
60750
|
+
"Bypass",
|
|
60751
|
+
"-File",
|
|
60752
|
+
script
|
|
60753
|
+
],
|
|
60754
|
+
command
|
|
60755
|
+
};
|
|
60756
|
+
};
|
|
60492
60757
|
inferWindowsNpmShimTarget = async (shimPath, env) => {
|
|
60493
60758
|
if (WINDOWS_EXE_EXT_PATTERN.test(shimPath)) return { command: shimPath };
|
|
60494
60759
|
if (!await fileExists$1(shimPath)) return;
|
|
60495
60760
|
try {
|
|
60496
60761
|
const source = await readFile(shimPath, "utf8");
|
|
60497
|
-
return await inferWindowsNodeScriptFromShim(shimPath, source, env) ?? await inferWindowsExecutableFromShim(shimPath, source);
|
|
60762
|
+
return await inferWindowsNodeScriptFromShim(shimPath, source, env) ?? await inferWindowsExecutableFromShim(shimPath, source) ?? await inferWindowsPowerShellShimTarget(shimPath, source, env);
|
|
60498
60763
|
} catch {
|
|
60499
60764
|
return;
|
|
60500
60765
|
}
|
|
@@ -60513,6 +60778,13 @@ var init_cliSpawn = __esmMin((() => {
|
|
|
60513
60778
|
};
|
|
60514
60779
|
resolveCliSpawnPlan = async (command, args, env) => {
|
|
60515
60780
|
const trimmedCommand = command.trim();
|
|
60781
|
+
const wslCommand = parseWslCommand(trimmedCommand);
|
|
60782
|
+
if (wslCommand) {
|
|
60783
|
+
if (!isWindows$1()) throw new Error(`A WSL command only runs on Windows: ${trimmedCommand}`);
|
|
60784
|
+
const wslPlan = buildWslSpawnPlan(wslCommand, args, env, await getWslPathEnv(wslCommand.distro));
|
|
60785
|
+
assertWindowsCommandLineFits(wslPlan);
|
|
60786
|
+
return wslPlan;
|
|
60787
|
+
}
|
|
60516
60788
|
if (!isWindows$1() || !trimmedCommand) return {
|
|
60517
60789
|
args,
|
|
60518
60790
|
command
|
|
@@ -60537,6 +60809,7 @@ var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
60537
60809
|
LOGIN_SHELL_TIMEOUT_STATUS_ERROR: () => LOGIN_SHELL_TIMEOUT_STATUS_ERROR,
|
|
60538
60810
|
LoginShellPathTimeoutError: () => LoginShellPathTimeoutError,
|
|
60539
60811
|
detectHeterogeneousCliCommand: () => detectHeterogeneousCliCommand,
|
|
60812
|
+
detectInWslWhenMissing: () => detectInWslWhenMissing,
|
|
60540
60813
|
detectValidatedCommand: () => detectValidatedCommand,
|
|
60541
60814
|
detectValidatedCommandCandidates: () => detectValidatedCommandCandidates,
|
|
60542
60815
|
invalidateLoginShellPathCache: () => invalidateLoginShellPathCache,
|
|
@@ -60544,10 +60817,11 @@ var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
60544
60817
|
resolveHeteroSpawnCommand: () => resolveHeteroSpawnCommand,
|
|
60545
60818
|
resolveUserSpawnPath: () => resolveUserSpawnPath
|
|
60546
60819
|
});
|
|
60547
|
-
var execFilePromise$2, VERSION_PATTERN, extractVersion, isWindows, shellPathPromise, registryPathPromise, WINDOWS_SHELL_METAS, WINDOWS_RUNNABLE_EXTS, WINDOWS_SHIM_EXTS, WINDOWS_SHELL_MAX_COMMAND_LINE_LENGTH, isWindowsRunnablePath, isWindowsShimPath, pickWindowsRunnables, isPathLikeCommand, LOGIN_SHELL_PATH_TIMEOUT_MS, LOGIN_SHELL_TIMEOUT_STATUS_ERROR, isLoginShellTimeoutStatus, LoginShellPathTimeoutError, getLoginShellPath, cachedShellPath, shellPathGeneration, getCurrentLoginShellPath, invalidateLoginShellPathCache, WINDOWS_REGISTRY_PATH_KEYS, WINDOWS_REGISTRY_PATH_VALUE, expandWindowsEnvRefs$1, readWindowsRegistryPathValue, readMergedWindowsRegistryPath, getWindowsRegistryPath, mergePathValues, resolveUserSpawnPath, recoverProbeEnvironment, getCommandPathLines, resolveCommandCandidates, quoteWindowsShellToken, buildWindowsShellProbe, UNRESOLVED_SHIM, execProbe, detectValidatedCommandInEnvironment, isProbeableCommand, detectValidatedCommandCandidates, detectValidatedCommand, HETEROGENEOUS_CLI_AGENT_OPTIONS, DEFAULT_HETERO_COMMAND, getWellKnownCommandPaths, detectHeterogeneousCliCommand, resolveHeteroSpawnCommand;
|
|
60820
|
+
var execFilePromise$2, VERSION_PATTERN, extractVersion, isWindows, shellPathPromise, registryPathPromise, WINDOWS_SHELL_METAS, WINDOWS_RUNNABLE_EXTS, WINDOWS_SHIM_EXTS, WINDOWS_SHELL_MAX_COMMAND_LINE_LENGTH, isWindowsRunnablePath, isWindowsShimPath, pickWindowsRunnables, isPathLikeCommand, LOGIN_SHELL_PATH_TIMEOUT_MS, LOGIN_SHELL_TIMEOUT_STATUS_ERROR, isLoginShellTimeoutStatus, LoginShellPathTimeoutError, getLoginShellPath, cachedShellPath, shellPathGeneration, getCurrentLoginShellPath, invalidateLoginShellPathCache, WINDOWS_REGISTRY_PATH_KEYS, WINDOWS_REGISTRY_PATH_VALUE, expandWindowsEnvRefs$1, readWindowsRegistryPathValue, readMergedWindowsRegistryPath, getWindowsRegistryPath, mergePathValues, resolveUserSpawnPath, recoverProbeEnvironment, getCommandPathLines, resolveCommandCandidates, quoteWindowsShellToken, buildWindowsShellProbe, UNRESOLVED_SHIM, execProbe, detectValidatedCommandInEnvironment, isProbeableCommand, detectValidatedCommandCandidates, detectValidatedCommand, HETEROGENEOUS_CLI_AGENT_OPTIONS, DEFAULT_HETERO_COMMAND, getWellKnownCommandPaths, detectHeterogeneousCliCommand, WSL_COMMAND_NAMES, detectInWslWhenMissing, resolveHeteroSpawnCommand;
|
|
60548
60821
|
var init_resolveCliCommand = __esmMin((() => {
|
|
60549
60822
|
init_config();
|
|
60550
60823
|
init_cliSpawn();
|
|
60824
|
+
init_wsl();
|
|
60551
60825
|
execFilePromise$2 = promisify(execFile);
|
|
60552
60826
|
VERSION_PATTERN = /v?(\d+\.\d+\.\d+(?:-[\dA-Za-z.-]+)?(?:\+[\dA-Za-z.-]+)?)/;
|
|
60553
60827
|
extractVersion = (versionBanner) => versionBanner.match(VERSION_PATTERN)?.[1];
|
|
@@ -60612,6 +60886,7 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
60612
60886
|
return shellPathPromise;
|
|
60613
60887
|
};
|
|
60614
60888
|
invalidateLoginShellPathCache = () => {
|
|
60889
|
+
invalidateWslCache();
|
|
60615
60890
|
cachedShellPath = void 0;
|
|
60616
60891
|
shellPathGeneration += 1;
|
|
60617
60892
|
shellPathPromise = void 0;
|
|
@@ -60743,7 +61018,7 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
60743
61018
|
const spawnPlan = await resolveCliSpawnPlan(command, args, env);
|
|
60744
61019
|
if (isWindows() && spawnPlan.command === command && isWindowsShimPath(command)) return UNRESOLVED_SHIM;
|
|
60745
61020
|
return execFilePromise$2(spawnPlan.command, spawnPlan.args, {
|
|
60746
|
-
env,
|
|
61021
|
+
env: spawnPlan.env ?? env,
|
|
60747
61022
|
timeout: 5e3,
|
|
60748
61023
|
windowsHide: true
|
|
60749
61024
|
});
|
|
@@ -60828,7 +61103,7 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
60828
61103
|
const inheritedStatus = await detectValidatedCommandInEnvironment(command, options, probeEnv);
|
|
60829
61104
|
if (inheritedStatus.available) return inheritedStatus;
|
|
60830
61105
|
lastStatus = inheritedStatus;
|
|
60831
|
-
if (!isProbeableCommand(command)) continue;
|
|
61106
|
+
if (!isProbeableCommand(command) || isWslCommand(command)) continue;
|
|
60832
61107
|
if (!recoveryAttempted) {
|
|
60833
61108
|
recoveryAttempted = true;
|
|
60834
61109
|
try {
|
|
@@ -60965,6 +61240,11 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
60965
61240
|
path.join(homedir(), "Library", "pnpm", "copilot")
|
|
60966
61241
|
];
|
|
60967
61242
|
case "cursor":
|
|
61243
|
+
if (platform() === "win32") {
|
|
61244
|
+
const localAppData = process.env.LOCALAPPDATA;
|
|
61245
|
+
if (!localAppData) return [];
|
|
61246
|
+
return [path.win32.join(localAppData, "cursor-agent", "agent.cmd")];
|
|
61247
|
+
}
|
|
60968
61248
|
if (platform() !== "darwin" && platform() !== "linux") return [];
|
|
60969
61249
|
return [path.join(homedir(), ".local", "bin", "agent"), path.join(homedir(), ".local", "bin", "cursor-agent")];
|
|
60970
61250
|
case "droid":
|
|
@@ -61036,7 +61316,19 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
61036
61316
|
detectHeterogeneousCliCommand = async (agentType, command, probeEnv) => {
|
|
61037
61317
|
const validator = HETEROGENEOUS_CLI_AGENT_OPTIONS[agentType];
|
|
61038
61318
|
if (!validator) return { available: false };
|
|
61039
|
-
|
|
61319
|
+
const isDefaultCommand = command.trim() === DEFAULT_HETERO_COMMAND[agentType];
|
|
61320
|
+
const status = await detectValidatedCommandCandidates(isDefaultCommand ? [command, ...getWellKnownCommandPaths(agentType)] : [command], validator, probeEnv);
|
|
61321
|
+
if (!isDefaultCommand) return status;
|
|
61322
|
+
return detectInWslWhenMissing(status, WSL_COMMAND_NAMES[agentType] ?? [command], validator);
|
|
61323
|
+
};
|
|
61324
|
+
WSL_COMMAND_NAMES = { cursor: ["agent", "cursor-agent"] };
|
|
61325
|
+
detectInWslWhenMissing = async (status, commandNames, options) => {
|
|
61326
|
+
if (status.available || !isWindows()) return status;
|
|
61327
|
+
const candidates = [];
|
|
61328
|
+
for (const name of commandNames) candidates.push(...await findWslCommandCandidates(name));
|
|
61329
|
+
if (candidates.length === 0) return status;
|
|
61330
|
+
const wslStatus = await detectValidatedCommandCandidates(candidates, options);
|
|
61331
|
+
return wslStatus.available ? wslStatus : status;
|
|
61040
61332
|
};
|
|
61041
61333
|
resolveHeteroSpawnCommand = async (agentType, command) => {
|
|
61042
61334
|
const requested = command?.trim();
|
|
@@ -61119,7 +61411,7 @@ const fetchAntigravityQuota = async (params = {}) => {
|
|
|
61119
61411
|
const query = execFilePromise$1(plan.command, plan.args, {
|
|
61120
61412
|
cwd: tmpdir(),
|
|
61121
61413
|
encoding: "utf8",
|
|
61122
|
-
env,
|
|
61414
|
+
env: plan.env ?? env,
|
|
61123
61415
|
killSignal: "SIGKILL",
|
|
61124
61416
|
maxBuffer: 1024 * 1024,
|
|
61125
61417
|
timeout: 2e4,
|
|
@@ -61643,7 +61935,7 @@ const codexQuotaReadings = (limits, capturedAt) => limits.flatMap((limit) => {
|
|
|
61643
61935
|
});
|
|
61644
61936
|
|
|
61645
61937
|
//#endregion
|
|
61646
|
-
//#region ../../packages/heterogeneous-agents/src/codex/
|
|
61938
|
+
//#region ../../packages/heterogeneous-agents/src/codex/appServerArgs.ts
|
|
61647
61939
|
const CODEX_DANGEROUS_BYPASS_FLAG = "--dangerously-bypass-approvals-and-sandbox";
|
|
61648
61940
|
const CODEX_FULL_AUTO_FLAG = "--full-auto";
|
|
61649
61941
|
const CODEX_APPROVAL_FLAGS = ["-a", "--ask-for-approval"];
|
|
@@ -61690,15 +61982,15 @@ const getCodexAppServerUnsupportedArgs = (args, options = {}) => {
|
|
|
61690
61982
|
const hasSandboxFlag = args.some((arg) => CODEX_SANDBOX_FLAGS.includes(arg) || getFlagValue(arg, CODEX_SANDBOX_FLAGS) !== void 0);
|
|
61691
61983
|
for (let index = 0; index < args.length; index += 1) {
|
|
61692
61984
|
const arg = args[index];
|
|
61693
|
-
if (arg ===
|
|
61985
|
+
if (arg === "--dangerously-bypass-approvals-and-sandbox") {
|
|
61694
61986
|
if (hasSandboxFlag) unsupported.push(arg);
|
|
61695
61987
|
continue;
|
|
61696
61988
|
}
|
|
61697
|
-
if (arg ===
|
|
61989
|
+
if (arg === "--ephemeral") {
|
|
61698
61990
|
if (options.resume) unsupported.push(arg);
|
|
61699
61991
|
continue;
|
|
61700
61992
|
}
|
|
61701
|
-
if (arg ===
|
|
61993
|
+
if (arg === "--full-auto" || arg === "--ignore-user-config") {
|
|
61702
61994
|
unsupported.push(arg);
|
|
61703
61995
|
continue;
|
|
61704
61996
|
}
|
|
@@ -61735,6 +62027,9 @@ const getCodexAppServerUnsupportedArgs = (args, options = {}) => {
|
|
|
61735
62027
|
}
|
|
61736
62028
|
return unsupported;
|
|
61737
62029
|
};
|
|
62030
|
+
|
|
62031
|
+
//#endregion
|
|
62032
|
+
//#region ../../packages/heterogeneous-agents/src/codex/appServerParams.ts
|
|
61738
62033
|
const buildCodexAppServerThreadParams = (args, cwd, initialModel) => {
|
|
61739
62034
|
const config = { "features.default_mode_request_user_input": true };
|
|
61740
62035
|
let effectiveCwd = cwd;
|
|
@@ -61745,15 +62040,15 @@ const buildCodexAppServerThreadParams = (args, cwd, initialModel) => {
|
|
|
61745
62040
|
let serviceTier;
|
|
61746
62041
|
for (let index = 0; index < args.length; index += 1) {
|
|
61747
62042
|
const arg = args[index];
|
|
61748
|
-
if (arg ===
|
|
62043
|
+
if (arg === "--dangerously-bypass-approvals-and-sandbox") {
|
|
61749
62044
|
sandbox = "danger-full-access";
|
|
61750
62045
|
continue;
|
|
61751
62046
|
}
|
|
61752
|
-
if (arg ===
|
|
62047
|
+
if (arg === "--full-auto") {
|
|
61753
62048
|
sandbox = "workspace-write";
|
|
61754
62049
|
continue;
|
|
61755
62050
|
}
|
|
61756
|
-
if (arg ===
|
|
62051
|
+
if (arg === "--ephemeral") {
|
|
61757
62052
|
ephemeral = true;
|
|
61758
62053
|
continue;
|
|
61759
62054
|
}
|
|
@@ -62241,17 +62536,19 @@ const buildHeterogeneousPrompt = (input) => new HeterogeneousPromptEngine(input)
|
|
|
62241
62536
|
*
|
|
62242
62537
|
* `permissionMode` (Claude Code, Better Coding Experience lab) rides the same
|
|
62243
62538
|
* envelope for the same reason: an `lh` that predates it unwraps `content` and
|
|
62244
|
-
* keeps allowing everything, rather than failing on an unknown flag.
|
|
62539
|
+
* keeps allowing everything, rather than failing on an unknown flag. The
|
|
62540
|
+
* Codex Plan switch (`collaborationMode`) rides it for the same reason.
|
|
62245
62541
|
*/
|
|
62246
62542
|
const buildHeteroExecStdinPayload = (params) => {
|
|
62247
|
-
const { imageList = [], isNewSession, permissionMode, prompt, resumeFallbackSystemContext, systemContext } = params;
|
|
62543
|
+
const { collaborationMode, imageList = [], isNewSession, permissionMode, prompt, resumeFallbackSystemContext, systemContext } = params;
|
|
62248
62544
|
const blocks = buildHeterogeneousPrompt({
|
|
62249
62545
|
imageList,
|
|
62250
62546
|
isNewSession,
|
|
62251
62547
|
prompt,
|
|
62252
62548
|
systemContext
|
|
62253
62549
|
});
|
|
62254
|
-
if (resumeFallbackSystemContext !== void 0 || permissionMode) return JSON.stringify({
|
|
62550
|
+
if (resumeFallbackSystemContext !== void 0 || permissionMode || collaborationMode) return JSON.stringify({
|
|
62551
|
+
...collaborationMode && { collaborationMode },
|
|
62255
62552
|
content: blocks,
|
|
62256
62553
|
...permissionMode && { permissionMode },
|
|
62257
62554
|
resumeFallback: resumeFallbackSystemContext === void 0 ? void 0 : buildHeterogeneousPrompt({
|
|
@@ -62930,7 +63227,7 @@ var CodexAppServerClient = class {
|
|
|
62930
63227
|
const child = spawnManaged(spawnPlan.command, spawnPlan.args, {
|
|
62931
63228
|
cwd: this.options.cwd,
|
|
62932
63229
|
detached: process.platform !== "win32",
|
|
62933
|
-
env: this.options.env,
|
|
63230
|
+
env: spawnPlan.env ?? this.options.env,
|
|
62934
63231
|
stdio: [
|
|
62935
63232
|
"pipe",
|
|
62936
63233
|
"pipe",
|
|
@@ -63872,6 +64169,13 @@ function splitLines(text) {
|
|
|
63872
64169
|
return result;
|
|
63873
64170
|
}
|
|
63874
64171
|
|
|
64172
|
+
//#endregion
|
|
64173
|
+
//#region ../../packages/heterogeneous-agents/src/codexPlanMode/index.ts
|
|
64174
|
+
/** `step_complete` phase carrying what a native Codex run reports about its collaboration mode. */
|
|
64175
|
+
const COLLABORATION_MODE_PHASE = "collaboration_mode";
|
|
64176
|
+
/** Tool api name of a completed Codex plan (`ThreadItem { type: 'plan' }`). */
|
|
64177
|
+
const CODEX_PROPOSED_PLAN_API_NAME = "proposed_plan";
|
|
64178
|
+
|
|
63875
64179
|
//#endregion
|
|
63876
64180
|
//#region ../../packages/heterogeneous-agents/src/utils/codexCommandOutput.ts
|
|
63877
64181
|
const CODEX_COMMAND_OUTPUT_MAX_LENGTH = 25e3;
|
|
@@ -64180,6 +64484,8 @@ var CodexAppServerAdapter = class {
|
|
|
64180
64484
|
pendingTools = /* @__PURE__ */ new Map();
|
|
64181
64485
|
streamedAgentText = /* @__PURE__ */ new Map();
|
|
64182
64486
|
streamedCommandOutput = /* @__PURE__ */ new Map();
|
|
64487
|
+
/** Plan-mode plans (`item/plan/delta`) streamed so far, by item id. */
|
|
64488
|
+
streamedPlans = /* @__PURE__ */ new Map();
|
|
64183
64489
|
streamedReasoning = /* @__PURE__ */ new Set();
|
|
64184
64490
|
toolStateSequence = /* @__PURE__ */ new Map();
|
|
64185
64491
|
stepToolCalls = [];
|
|
@@ -64242,6 +64548,7 @@ var CodexAppServerAdapter = class {
|
|
|
64242
64548
|
case "item/fileChange/patchUpdated": return this.handleFileChangeUpdate(rawParams);
|
|
64243
64549
|
case "item/mcpToolCall/progress": return this.handleMcpProgress(rawParams);
|
|
64244
64550
|
case "turn/plan/updated": return this.handlePlanUpdated(rawParams);
|
|
64551
|
+
case "item/plan/delta": return this.handleProposedPlanDelta(rawParams);
|
|
64245
64552
|
case "thread/tokenUsage/updated": {
|
|
64246
64553
|
const { tokenUsage } = rawParams;
|
|
64247
64554
|
const cumulativeUsage = toUsage(tokenUsage.total);
|
|
@@ -64272,6 +64579,7 @@ var CodexAppServerAdapter = class {
|
|
|
64272
64579
|
}
|
|
64273
64580
|
handleItemStarted({ item }) {
|
|
64274
64581
|
if (item.type === "userMessage") return this.handleSteeredUserMessage(item);
|
|
64582
|
+
if (item.type === "plan") return this.startProposedPlan(item);
|
|
64275
64583
|
if (!isToolItem(item)) return [];
|
|
64276
64584
|
const opening = this.openStepAfterSteer();
|
|
64277
64585
|
this.hasToolActivity = true;
|
|
@@ -64318,6 +64626,7 @@ var CodexAppServerAdapter = class {
|
|
|
64318
64626
|
}
|
|
64319
64627
|
return message.text ? this.emitText(message.id, message.text) : [];
|
|
64320
64628
|
}
|
|
64629
|
+
if (item.type === "plan") return this.completeProposedPlan(item);
|
|
64321
64630
|
if (item.type === "reasoning") {
|
|
64322
64631
|
const reasoningItem = item;
|
|
64323
64632
|
if (this.streamedReasoning.delete(reasoningItem.id)) return [];
|
|
@@ -64385,6 +64694,75 @@ var CodexAppServerAdapter = class {
|
|
|
64385
64694
|
status: "inProgress"
|
|
64386
64695
|
})] : [];
|
|
64387
64696
|
}
|
|
64697
|
+
/**
|
|
64698
|
+
* A plan-mode plan (`ThreadItem { type: 'plan' }`) shows as a `proposed_plan`
|
|
64699
|
+
* tool: `item/plan/delta` only streams its text, the completed item is the
|
|
64700
|
+
* plan of record (Codex does not promise the deltas add up to it).
|
|
64701
|
+
*/
|
|
64702
|
+
startProposedPlan(item) {
|
|
64703
|
+
if (this.pendingTools.has(item.id)) return [];
|
|
64704
|
+
const opening = this.openStepAfterSteer();
|
|
64705
|
+
const payload = {
|
|
64706
|
+
apiName: CODEX_PROPOSED_PLAN_API_NAME,
|
|
64707
|
+
arguments: "{}",
|
|
64708
|
+
id: item.id,
|
|
64709
|
+
identifier: CODEX_IDENTIFIER$1,
|
|
64710
|
+
type: "default"
|
|
64711
|
+
};
|
|
64712
|
+
this.hasToolActivity = true;
|
|
64713
|
+
this.pendingTools.set(item.id, payload);
|
|
64714
|
+
this.stepToolCalls.push(payload);
|
|
64715
|
+
this.streamedPlans.set(item.id, item.text ?? "");
|
|
64716
|
+
return [
|
|
64717
|
+
...opening,
|
|
64718
|
+
this.makeEvent("stream_chunk", {
|
|
64719
|
+
chunkType: "tools_calling",
|
|
64720
|
+
toolsCalling: [...this.stepToolCalls]
|
|
64721
|
+
}),
|
|
64722
|
+
this.makeEvent("tool_start", { toolCallId: item.id })
|
|
64723
|
+
];
|
|
64724
|
+
}
|
|
64725
|
+
handleProposedPlanDelta(params) {
|
|
64726
|
+
if (!params.delta || !this.pendingTools.has(params.itemId)) return [];
|
|
64727
|
+
const text = `${this.streamedPlans.get(params.itemId) ?? ""}${params.delta}`;
|
|
64728
|
+
this.streamedPlans.set(params.itemId, text);
|
|
64729
|
+
return [this.toolState(params.itemId, { plan: {
|
|
64730
|
+
completed: false,
|
|
64731
|
+
text
|
|
64732
|
+
} })];
|
|
64733
|
+
}
|
|
64734
|
+
completeProposedPlan(item) {
|
|
64735
|
+
this.streamedPlans.delete(item.id);
|
|
64736
|
+
const payload = this.pendingTools.get(item.id) ?? {
|
|
64737
|
+
apiName: "proposed_plan",
|
|
64738
|
+
arguments: "{}",
|
|
64739
|
+
id: item.id,
|
|
64740
|
+
identifier: CODEX_IDENTIFIER$1,
|
|
64741
|
+
type: "default"
|
|
64742
|
+
};
|
|
64743
|
+
const events = this.pendingTools.has(item.id) ? [] : this.startLateTool(payload);
|
|
64744
|
+
this.pendingTools.delete(item.id);
|
|
64745
|
+
const pluginState = { plan: {
|
|
64746
|
+
completed: true,
|
|
64747
|
+
text: item.text
|
|
64748
|
+
} };
|
|
64749
|
+
events.push(this.makeEvent("tool_result", {
|
|
64750
|
+
content: item.text,
|
|
64751
|
+
isError: false,
|
|
64752
|
+
pluginState,
|
|
64753
|
+
toolCallId: item.id
|
|
64754
|
+
}), this.makeEvent("tool_end", {
|
|
64755
|
+
isSuccess: true,
|
|
64756
|
+
payload: { toolCalling: payload },
|
|
64757
|
+
result: {
|
|
64758
|
+
content: item.text,
|
|
64759
|
+
state: pluginState,
|
|
64760
|
+
success: true
|
|
64761
|
+
},
|
|
64762
|
+
toolCallId: item.id
|
|
64763
|
+
}));
|
|
64764
|
+
return events;
|
|
64765
|
+
}
|
|
64388
64766
|
handlePlanUpdated(params) {
|
|
64389
64767
|
const id = `turn-plan-${params.turnId}`;
|
|
64390
64768
|
let foundProcessing = false;
|
|
@@ -64703,6 +65081,7 @@ const formatCodexAsyncReplies = (replies) => `<send_user_message_question_reply>
|
|
|
64703
65081
|
|
|
64704
65082
|
//#endregion
|
|
64705
65083
|
//#region ../../packages/heterogeneous-agents/src/codex/CodexThreadSession.ts
|
|
65084
|
+
init_src$2();
|
|
64706
65085
|
init_object$1();
|
|
64707
65086
|
const CODEX_APP_SERVER_TRANSPORT = "codex-app-server";
|
|
64708
65087
|
/** An interrupted turn settled within 250 ms in probes; this bounds slow tool teardown. */
|
|
@@ -64732,6 +65111,15 @@ var CodexThreadSession = class {
|
|
|
64732
65111
|
interruptRequested = false;
|
|
64733
65112
|
lastOperationId;
|
|
64734
65113
|
model;
|
|
65114
|
+
effort;
|
|
65115
|
+
/** The mode this run's turns send; a mid-run switch changes it for the next turn. */
|
|
65116
|
+
collaborationMode;
|
|
65117
|
+
/**
|
|
65118
|
+
* Modes sent since the last `turn/start`, oldest first, that Codex has not
|
|
65119
|
+
* acknowledged yet. A `thread/settings/updated` naming one of them answers
|
|
65120
|
+
* that request (and supersedes the older ones), not the latest pick.
|
|
65121
|
+
*/
|
|
65122
|
+
pendingModeRequests = [];
|
|
64735
65123
|
running = false;
|
|
64736
65124
|
sessionUnsubscribers = [];
|
|
64737
65125
|
threadId;
|
|
@@ -64754,6 +65142,7 @@ var CodexThreadSession = class {
|
|
|
64754
65142
|
this.running = true;
|
|
64755
65143
|
this.interruptRequested = false;
|
|
64756
65144
|
this.lastOperationId = options.operationId;
|
|
65145
|
+
this.collaborationMode = options.collaborationMode;
|
|
64757
65146
|
this.emitStatus("starting", options.operationId);
|
|
64758
65147
|
const traceUnsubscribers = [];
|
|
64759
65148
|
try {
|
|
@@ -64825,9 +65214,12 @@ var CodexThreadSession = class {
|
|
|
64825
65214
|
transportInterrupted: false
|
|
64826
65215
|
};
|
|
64827
65216
|
this.activeTurn = activeTurn;
|
|
65217
|
+
const collaborationMode = this.collaborationModeParams(this.collaborationMode);
|
|
65218
|
+
this.pendingModeRequests = collaborationMode ? [collaborationMode.mode] : [];
|
|
64828
65219
|
const turnParams = {
|
|
64829
65220
|
input,
|
|
64830
|
-
threadId
|
|
65221
|
+
threadId,
|
|
65222
|
+
...collaborationMode && { collaborationMode }
|
|
64831
65223
|
};
|
|
64832
65224
|
this.canFallback = false;
|
|
64833
65225
|
activeTurn.turnId = (await this.options.client.request("turn/start", turnParams))?.turn?.id;
|
|
@@ -64916,14 +65308,14 @@ var CodexThreadSession = class {
|
|
|
64916
65308
|
this.releaseThread ??= this.options.client.acquireThread(this.threadId);
|
|
64917
65309
|
const response = this.provenance ? await this.resumeWithShellEnv(this.threadId) : await this.options.client.request("thread/resume", toThreadResumeParams(this.threadId, this.threadParams));
|
|
64918
65310
|
if (!response || this.closedByHost) return;
|
|
64919
|
-
await this.attachThread(response.thread.id, response.model);
|
|
65311
|
+
await this.attachThread(response.thread.id, response.model, response.reasoningEffort);
|
|
64920
65312
|
return;
|
|
64921
65313
|
}
|
|
64922
65314
|
const response = await this.options.client.request("thread/start", this.threadParams);
|
|
64923
65315
|
if (this.closedByHost) return;
|
|
64924
65316
|
const threadId = response?.thread?.id;
|
|
64925
65317
|
if (!threadId) throw new CodexAppServerConnectionError("Codex app-server returned an incompatible thread/start response", { phase: "thread-start" });
|
|
64926
|
-
await this.attachThread(threadId, response.model);
|
|
65318
|
+
await this.attachThread(threadId, response.model, response.reasoningEffort);
|
|
64927
65319
|
if (!this.options.threadParams.ephemeral) {
|
|
64928
65320
|
await this.setThreadName(threadId);
|
|
64929
65321
|
this.options.onSessionId(threadId);
|
|
@@ -64968,12 +65360,13 @@ var CodexThreadSession = class {
|
|
|
64968
65360
|
});
|
|
64969
65361
|
}
|
|
64970
65362
|
}
|
|
64971
|
-
async attachThread(threadId, model) {
|
|
65363
|
+
async attachThread(threadId, model, effort) {
|
|
64972
65364
|
this.releaseThread ??= this.options.client.acquireThread(threadId);
|
|
64973
65365
|
this.threadId = threadId;
|
|
64974
65366
|
this.attached = true;
|
|
64975
65367
|
this.canFallback = false;
|
|
64976
65368
|
if (model) this.updateModel(model);
|
|
65369
|
+
if (effort !== void 0) this.effort = effort;
|
|
64977
65370
|
if (this.threadUnsubscribers.length > 0) return;
|
|
64978
65371
|
this.threadUnsubscribers.push(this.options.client.subscribe(threadId, (method, params) => this.enqueueNotification(method, params)), this.options.client.subscribeServerRequests(threadId, (method, params) => {
|
|
64979
65372
|
if (method === "item/commandExecution/requestApproval" || method === "item/fileChange/requestApproval") return { decision: "cancel" };
|
|
@@ -64986,10 +65379,73 @@ var CodexThreadSession = class {
|
|
|
64986
65379
|
}
|
|
64987
65380
|
}));
|
|
64988
65381
|
}
|
|
65382
|
+
/**
|
|
65383
|
+
* The Plan switch flipped while this run goes: Codex takes the mode from its
|
|
65384
|
+
* next turn (`thread/settings/update` never changes the turn in flight), and
|
|
65385
|
+
* this run's own next turn — a continuation after async answers — sends it too.
|
|
65386
|
+
*/
|
|
65387
|
+
async setCollaborationMode(mode) {
|
|
65388
|
+
this.collaborationMode = mode;
|
|
65389
|
+
if (!this.running || !this.attached || !this.threadId || this.closedByHost) return;
|
|
65390
|
+
const collaborationMode = this.collaborationModeParams(mode);
|
|
65391
|
+
if (!collaborationMode) return;
|
|
65392
|
+
this.pendingModeRequests.push(mode);
|
|
65393
|
+
await this.options.client.request("thread/settings/update", {
|
|
65394
|
+
collaborationMode,
|
|
65395
|
+
threadId: this.threadId
|
|
65396
|
+
});
|
|
65397
|
+
}
|
|
65398
|
+
/**
|
|
65399
|
+
* The `collaborationMode` for `mode`, carrying the thread's own model and
|
|
65400
|
+
* effort (`developer_instructions: null` keeps the mode's built-in
|
|
65401
|
+
* instructions; the thread's developer instructions stay in force, verified
|
|
65402
|
+
* on codex-cli 0.169.0). Undefined without a mode, or before the thread
|
|
65403
|
+
* reported its model.
|
|
65404
|
+
*/
|
|
65405
|
+
collaborationModeParams(mode) {
|
|
65406
|
+
if (!mode || !this.model) return;
|
|
65407
|
+
return {
|
|
65408
|
+
mode,
|
|
65409
|
+
settings: {
|
|
65410
|
+
developer_instructions: null,
|
|
65411
|
+
model: this.model,
|
|
65412
|
+
reasoning_effort: this.effort ?? null
|
|
65413
|
+
}
|
|
65414
|
+
};
|
|
65415
|
+
}
|
|
65416
|
+
/**
|
|
65417
|
+
* Codex reports the thread's mode after `turn/start` set it, or after a
|
|
65418
|
+
* mid-run switch (it only reports a change). The report carries the request
|
|
65419
|
+
* it answers, so the topic follows Codex only where the two disagree. A
|
|
65420
|
+
* notification naming a pending request acknowledges that one: with Plan
|
|
65421
|
+
* flipped on and back off before Codex answered, its `plan` answers the
|
|
65422
|
+
* first flip and must not read as Codex refusing the second.
|
|
65423
|
+
*/
|
|
65424
|
+
handleThreadSettingsUpdated(activeTurn, params) {
|
|
65425
|
+
const mode = params?.threadSettings?.collaborationMode?.mode;
|
|
65426
|
+
if (params?.threadId !== this.threadId || !this.collaborationMode) return Promise.resolve();
|
|
65427
|
+
if (!isCodexCollaborationMode(mode)) return Promise.resolve();
|
|
65428
|
+
const acknowledged = this.pendingModeRequests.indexOf(mode);
|
|
65429
|
+
const requested = acknowledged >= 0 ? mode : this.collaborationMode;
|
|
65430
|
+
if (acknowledged >= 0) this.pendingModeRequests.splice(0, acknowledged + 1);
|
|
65431
|
+
const data = {
|
|
65432
|
+
collaborationMode: mode,
|
|
65433
|
+
phase: COLLABORATION_MODE_PHASE,
|
|
65434
|
+
requested
|
|
65435
|
+
};
|
|
65436
|
+
activeTurn.notificationQueue = activeTurn.notificationQueue.then(() => this.options.onEvents([toStreamEvent({
|
|
65437
|
+
data,
|
|
65438
|
+
stepIndex: 0,
|
|
65439
|
+
timestamp: Date.now(),
|
|
65440
|
+
type: "step_complete"
|
|
65441
|
+
}, activeTurn.operationId)]));
|
|
65442
|
+
return activeTurn.notificationQueue;
|
|
65443
|
+
}
|
|
64989
65444
|
async handleReconnect(response) {
|
|
64990
65445
|
if (this.closedByHost) return;
|
|
64991
65446
|
this.attached = true;
|
|
64992
65447
|
if (response.model) this.updateModel(response.model);
|
|
65448
|
+
if (response.reasoningEffort !== void 0) this.effort = response.reasoningEffort;
|
|
64993
65449
|
}
|
|
64994
65450
|
async requestUserInput(params) {
|
|
64995
65451
|
const request = parseCodexUserInput(params);
|
|
@@ -65036,6 +65492,7 @@ var CodexThreadSession = class {
|
|
|
65036
65492
|
enqueueNotification(method, params) {
|
|
65037
65493
|
const activeTurn = this.activeTurn;
|
|
65038
65494
|
if (!activeTurn || !this.isCurrentTurnNotification(method, params, activeTurn)) return Promise.resolve();
|
|
65495
|
+
if (method === "thread/settings/updated") return this.handleThreadSettingsUpdated(activeTurn, params);
|
|
65039
65496
|
if (method === "turn/completed") {
|
|
65040
65497
|
if (params.turn.status !== "inProgress") {
|
|
65041
65498
|
activeTurn.terminalNotificationReceived = true;
|
|
@@ -65228,6 +65685,7 @@ const createCodexAgentHandle = async (options) => {
|
|
|
65228
65685
|
options.onStartupControl?.({ cancel });
|
|
65229
65686
|
const turnOptions = {
|
|
65230
65687
|
askUserBridge: options.askUserBridge,
|
|
65688
|
+
collaborationMode: options.collaborationMode,
|
|
65231
65689
|
input: buildCodexAppServerInput(input),
|
|
65232
65690
|
onRawMessage: (line) => options.onRawStdout?.(Buffer.from(line)),
|
|
65233
65691
|
operationId: options.operationId,
|
|
@@ -65287,6 +65745,8 @@ const createCodexAgentHandle = async (options) => {
|
|
|
65287
65745
|
get sessionId() {
|
|
65288
65746
|
return nativeSessionId;
|
|
65289
65747
|
},
|
|
65748
|
+
/** The Plan switch flipped mid-run: Codex takes it from the next turn. */
|
|
65749
|
+
setCollaborationMode: (mode) => session.setCollaborationMode(mode),
|
|
65290
65750
|
stderr,
|
|
65291
65751
|
supportsSteerImageAttachments: true
|
|
65292
65752
|
};
|
|
@@ -65343,7 +65803,7 @@ var AcpStdioClient = class {
|
|
|
65343
65803
|
const child = spawnManaged(spawnPlan.command, spawnPlan.args, {
|
|
65344
65804
|
cwd: this.options.cwd,
|
|
65345
65805
|
detached,
|
|
65346
|
-
env: this.options.env,
|
|
65806
|
+
env: spawnPlan.env ?? this.options.env,
|
|
65347
65807
|
stdio: [
|
|
65348
65808
|
"pipe",
|
|
65349
65809
|
"pipe",
|
|
@@ -74877,8 +75337,17 @@ const isSupportedDshVersion = (version) => {
|
|
|
74877
75337
|
* `--version` but has no `acp` profile, so it is reported unavailable here
|
|
74878
75338
|
* rather than failing every turn after the agent was created.
|
|
74879
75339
|
*/
|
|
75340
|
+
/**
|
|
75341
|
+
* `dsh` is installed with `npm i -g`. On Windows that drops `dsh.cmd` in npm's
|
|
75342
|
+
* global prefix (`%APPDATA%\npm`), a directory npm's installer only adds to the
|
|
75343
|
+
* registry User PATH, so an app started before it never sees it.
|
|
75344
|
+
*/
|
|
75345
|
+
const getDshWellKnownPaths = () => platform() === "win32" ? [path.win32.join(process.env.APPDATA || path.win32.join(homedir(), "AppData", "Roaming"), "npm", "dsh.cmd")] : [];
|
|
74880
75346
|
const detectDshCommand = async (command = "dsh", env) => {
|
|
74881
|
-
const
|
|
75347
|
+
const isDefaultCommand = command.trim() === "dsh";
|
|
75348
|
+
const validation = { validatePattern: DSH_VERSION_PATTERN };
|
|
75349
|
+
const nativeStatus = await detectValidatedCommandCandidates(isDefaultCommand ? [command, ...getDshWellKnownPaths()] : [command], validation, env);
|
|
75350
|
+
const status = isDefaultCommand ? await detectInWslWhenMissing(nativeStatus, ["dsh"], validation) : nativeStatus;
|
|
74882
75351
|
if (!status.available || isSupportedDshVersion(status.version)) return status;
|
|
74883
75352
|
return {
|
|
74884
75353
|
...status,
|
|
@@ -76304,7 +76773,7 @@ const spawnCliAgent = async (options, command, cwd, inputPlan, childEnv, codexJw
|
|
|
76304
76773
|
const proc = spawnManaged(cliSpawnPlan.command, cliSpawnPlan.args, {
|
|
76305
76774
|
cwd,
|
|
76306
76775
|
detached,
|
|
76307
|
-
env: childEnv,
|
|
76776
|
+
env: cliSpawnPlan.env ?? childEnv,
|
|
76308
76777
|
stdio: [
|
|
76309
76778
|
"pipe",
|
|
76310
76779
|
"pipe",
|
|
@@ -76745,14 +77214,15 @@ const requestViaRpc = async (options, { failureMessage, method, params, timeoutM
|
|
|
76745
77214
|
timeout = setTimeout(() => {
|
|
76746
77215
|
settleError(/* @__PURE__ */ new Error(`${failureMessage}: RPC timed out`), true);
|
|
76747
77216
|
}, timeoutMs);
|
|
76748
|
-
|
|
77217
|
+
const childEnv = {
|
|
77218
|
+
...process.env,
|
|
77219
|
+
...options.env,
|
|
77220
|
+
...options.codexHomePath ? { CODEX_HOME: options.codexHomePath } : {}
|
|
77221
|
+
};
|
|
77222
|
+
resolveCliSpawnPlan(options.command ?? "codex", rpcArgs, childEnv).then((spawnPlan) => {
|
|
76749
77223
|
if (finished) return;
|
|
76750
77224
|
child = spawn(spawnPlan.command, spawnPlan.args, {
|
|
76751
|
-
env:
|
|
76752
|
-
...process.env,
|
|
76753
|
-
...options.env,
|
|
76754
|
-
...options.codexHomePath ? { CODEX_HOME: options.codexHomePath } : {}
|
|
76755
|
-
},
|
|
77225
|
+
env: spawnPlan.env ?? childEnv,
|
|
76756
77226
|
stdio: [
|
|
76757
77227
|
"pipe",
|
|
76758
77228
|
"pipe",
|
|
@@ -306443,7 +306913,7 @@ const listHeterogeneousAgentModels = async (params) => {
|
|
|
306443
306913
|
const { stderr, stdout } = await execFilePromise(spawnPlan.command, spawnPlan.args, {
|
|
306444
306914
|
cwd,
|
|
306445
306915
|
encoding: "utf8",
|
|
306446
|
-
env,
|
|
306916
|
+
env: spawnPlan.env ?? env,
|
|
306447
306917
|
maxBuffer: MODEL_CATALOG_MAX_BUFFER,
|
|
306448
306918
|
timeout: MODEL_CATALOG_TIMEOUT_MS,
|
|
306449
306919
|
windowsHide: true
|
|
@@ -325331,7 +325801,7 @@ var init_shimsNode = __esmMin((() => {
|
|
|
325331
325801
|
}));
|
|
325332
325802
|
|
|
325333
325803
|
//#endregion
|
|
325334
|
-
//#region node_modules/.pnpm/pkce-challenge@5.0.
|
|
325804
|
+
//#region node_modules/.pnpm/pkce-challenge@5.0.2/node_modules/pkce-challenge/dist/index.node.js
|
|
325335
325805
|
/**
|
|
325336
325806
|
* Creates an array of length `size` of random bytes
|
|
325337
325807
|
* @param size
|
|
@@ -345279,6 +345749,7 @@ const createFileSearchModule = (toolDetector) => {
|
|
|
345279
345749
|
//#endregion
|
|
345280
345750
|
//#region src/device/systemInfo.ts
|
|
345281
345751
|
init_resolveCliCommand();
|
|
345752
|
+
init_src$2();
|
|
345282
345753
|
/**
|
|
345283
345754
|
* Checks the currently resolved Codex binary without creating a conversation.
|
|
345284
345755
|
*
|
|
@@ -345333,9 +345804,12 @@ async function supportsNativeCodex() {
|
|
|
345333
345804
|
client?.close();
|
|
345334
345805
|
}
|
|
345335
345806
|
}
|
|
345336
|
-
/**
|
|
345807
|
+
/**
|
|
345808
|
+
* Native agent runtimes the resolved binaries support; one handshake per call.
|
|
345809
|
+
* `codex-collaboration-mode-v1` says this `lh` also takes the Codex Plan switch.
|
|
345810
|
+
*/
|
|
345337
345811
|
async function probeNativeRuntimes() {
|
|
345338
|
-
return await supportsNativeCodex() ? ["codex-app-server-v1"] : [];
|
|
345812
|
+
return await supportsNativeCodex() ? ["codex-app-server-v1", CODEX_COLLABORATION_MODE_RUNTIME] : [];
|
|
345339
345813
|
}
|
|
345340
345814
|
/**
|
|
345341
345815
|
* The answer to a gateway `system_info_request`: host paths and live native capabilities.
|
|
@@ -555531,6 +556005,7 @@ function startHeteroAgentRun(params, accountEnv, logger) {
|
|
|
555531
556005
|
...extraArgs ?? []
|
|
555532
556006
|
];
|
|
555533
556007
|
const stdinPayload = buildHeteroExecStdinPayload({
|
|
556008
|
+
collaborationMode: params.collaborationMode,
|
|
555534
556009
|
imageList,
|
|
555535
556010
|
isNewSession: !resumeSessionId,
|
|
555536
556011
|
permissionMode: params.permissionMode,
|
|
@@ -555693,10 +556168,13 @@ const resolveRemotePlatformRuntime = async (type, baseEnv = process.env) => {
|
|
|
555693
556168
|
};
|
|
555694
556169
|
const validatedPath = status.path;
|
|
555695
556170
|
const env = buildRemotePlatformEnvironment(status, baseEnv);
|
|
555696
|
-
const prepareSpawn = async (args) =>
|
|
555697
|
-
|
|
555698
|
-
|
|
555699
|
-
|
|
556171
|
+
const prepareSpawn = async (args) => {
|
|
556172
|
+
const plan = await resolveCliSpawnPlan(validatedPath, args, env);
|
|
556173
|
+
return {
|
|
556174
|
+
...plan,
|
|
556175
|
+
env: plan.env ?? env
|
|
556176
|
+
};
|
|
556177
|
+
};
|
|
555700
556178
|
return {
|
|
555701
556179
|
available: true,
|
|
555702
556180
|
execute: async (args, options) => executeSpawnPlan(await prepareSpawn(args), options?.timeout),
|
|
@@ -557897,6 +558375,7 @@ function bindGatewayClientHandlers(client, ctx, connectionWorkspaceId) {
|
|
|
557897
558375
|
args: request.args,
|
|
557898
558376
|
claudeAccountRouting: request.claudeAccountRouting,
|
|
557899
558377
|
claudeCodeEntrypoint: request.claudeCodeEntrypoint,
|
|
558378
|
+
collaborationMode: request.collaborationMode,
|
|
557900
558379
|
cwd: request.cwd,
|
|
557901
558380
|
imageList: request.imageList,
|
|
557902
558381
|
jwt: request.jwt,
|
|
@@ -583425,7 +583904,7 @@ var RpcStdioClient = class {
|
|
|
583425
583904
|
const child = spawnManaged(spawnPlan.command, spawnPlan.args, {
|
|
583426
583905
|
cwd: this.options.cwd,
|
|
583427
583906
|
detached: process.platform !== "win32" && (this.options.detached ?? true),
|
|
583428
|
-
env: this.options.env,
|
|
583907
|
+
env: spawnPlan.env ?? this.options.env,
|
|
583429
583908
|
stdio: [
|
|
583430
583909
|
"pipe",
|
|
583431
583910
|
"pipe",
|
|
@@ -583820,7 +584299,7 @@ var PiRpcClient = class {
|
|
|
583820
584299
|
version = await new Promise((resolve, reject) => {
|
|
583821
584300
|
const probe = execFile(plan.command, plan.args, {
|
|
583822
584301
|
cwd: this.options.cwd,
|
|
583823
|
-
env: this.options.env,
|
|
584302
|
+
env: plan.env ?? this.options.env,
|
|
583824
584303
|
killSignal: "SIGKILL",
|
|
583825
584304
|
signal: this.probeAbort.signal,
|
|
583826
584305
|
timeout: 5e3,
|
|
@@ -584698,6 +585177,25 @@ const dispatchHeteroControl = async (message, context) => {
|
|
|
584698
585177
|
}
|
|
584699
585178
|
};
|
|
584700
585179
|
|
|
585180
|
+
//#endregion
|
|
585181
|
+
//#region src/utils/heteroCollaborationMode.ts
|
|
585182
|
+
init_src$2();
|
|
585183
|
+
/** The control command the server queues when the Codex Plan switch flips mid-run. */
|
|
585184
|
+
const HETERO_SET_COLLABORATION_MODE_COMMAND = "set_collaboration_mode";
|
|
585185
|
+
/**
|
|
585186
|
+
* Switch a running native Codex thread's collaboration mode (the composer's
|
|
585187
|
+
* Plan switch). Codex takes it from the next turn: `thread/settings/update`
|
|
585188
|
+
* never changes the turn in flight. Reports the mode that was set.
|
|
585189
|
+
*/
|
|
585190
|
+
const setCollaborationModeHandler = async ({ params, setCollaborationMode }) => {
|
|
585191
|
+
const mode = params?.mode;
|
|
585192
|
+
if (!isCodexCollaborationMode(mode)) throw new Error("set_collaboration_mode needs a valid mode");
|
|
585193
|
+
if (!setCollaborationMode) throw new Error("This run is not a native Codex thread");
|
|
585194
|
+
await setCollaborationMode(mode);
|
|
585195
|
+
return { mode };
|
|
585196
|
+
};
|
|
585197
|
+
registerHeteroControlHandler(HETERO_SET_COLLABORATION_MODE_COMMAND, setCollaborationModeHandler);
|
|
585198
|
+
|
|
584701
585199
|
//#endregion
|
|
584702
585200
|
//#region src/utils/heteroPermissionMode.ts
|
|
584703
585201
|
init_src$2();
|
|
@@ -584794,6 +585292,7 @@ async function* withHeteroSteer(handle, context) {
|
|
|
584794
585292
|
}
|
|
584795
585293
|
const { operationId } = context;
|
|
584796
585294
|
const sendControlRequest = handle.sendControlRequest;
|
|
585295
|
+
const setCollaborationMode = handle.setCollaborationMode;
|
|
584797
585296
|
const delivered = /* @__PURE__ */ new Set();
|
|
584798
585297
|
const abort = new AbortController();
|
|
584799
585298
|
const handling = /* @__PURE__ */ new Set();
|
|
@@ -584824,7 +585323,8 @@ async function* withHeteroSteer(handle, context) {
|
|
|
584824
585323
|
log$15.debug("Control %s: %s", control.id, control.command);
|
|
584825
585324
|
await report(client, control, await dispatchHeteroControl(control, {
|
|
584826
585325
|
operationId,
|
|
584827
|
-
sendControlRequest,
|
|
585326
|
+
sendControlRequest: sendControlRequest ?? (() => void 0),
|
|
585327
|
+
setCollaborationMode,
|
|
584828
585328
|
signal: abort.signal
|
|
584829
585329
|
}));
|
|
584830
585330
|
})().catch((error) => log$15.debug("Control %s failed: %s", control.id, String(error))).finally(() => handling.delete(task));
|
|
@@ -584832,7 +585332,7 @@ async function* withHeteroSteer(handle, context) {
|
|
|
584832
585332
|
};
|
|
584833
585333
|
const poll = async () => {
|
|
584834
585334
|
const client = await context.getTrpcClient();
|
|
584835
|
-
const acceptsControl = !!sendControlRequest && !!client.aiAgent.reportHeteroControlResult;
|
|
585335
|
+
const acceptsControl = (!!sendControlRequest || !!setCollaborationMode) && !!client.aiAgent.reportHeteroControlResult;
|
|
584836
585336
|
while (!abort.signal.aborted) {
|
|
584837
585337
|
let message;
|
|
584838
585338
|
try {
|
|
@@ -585120,6 +585620,18 @@ const buildExtraArgs = (options) => {
|
|
|
585120
585620
|
return extraArgs.length > 0 ? extraArgs : void 0;
|
|
585121
585621
|
};
|
|
585122
585622
|
|
|
585623
|
+
//#endregion
|
|
585624
|
+
//#region src/commands/hetero/dispatchedModes.ts
|
|
585625
|
+
/**
|
|
585626
|
+
* The Better Coding Experience modes the dispatch envelope carried, as spawn
|
|
585627
|
+
* options for the agent they belong to: Claude Code's permission mode, and the
|
|
585628
|
+
* Codex Plan switch (collaboration mode).
|
|
585629
|
+
*/
|
|
585630
|
+
const dispatchedModeSpawnOptions = (agentType, resolved) => ({
|
|
585631
|
+
...agentType === "claude-code" && resolved.permissionMode && { permissionMode: resolved.permissionMode },
|
|
585632
|
+
...agentType === "codex" && resolved.collaborationMode && { collaborationMode: resolved.collaborationMode }
|
|
585633
|
+
});
|
|
585634
|
+
|
|
585123
585635
|
//#endregion
|
|
585124
585636
|
//#region src/commands/hetero/prompt.ts
|
|
585125
585637
|
init_src$2();
|
|
@@ -585169,9 +585681,10 @@ const parseImageArg = (value) => {
|
|
|
585169
585681
|
* Accepts:
|
|
585170
585682
|
* - `'plain text'` → single text block
|
|
585171
585683
|
* - `[{ type: 'text', text }, { type: 'image', source }]` → content blocks
|
|
585172
|
-
* - `{ content: [...], resumeFallback?: [...], permissionMode? }`
|
|
585173
|
-
* primary prompt, reserves the fallback for a retry without
|
|
585174
|
-
* and takes the Claude Code permission mode
|
|
585684
|
+
* - `{ content: [...], resumeFallback?: [...], permissionMode?, collaborationMode? }`
|
|
585685
|
+
* → unwraps the primary prompt, reserves the fallback for a retry without
|
|
585686
|
+
* native resume, and takes the Claude Code permission mode / Codex Plan
|
|
585687
|
+
* switch the run was dispatched with
|
|
585175
585688
|
* - `{ type: 'text', ... } | { type: 'image', ... }` → single block
|
|
585176
585689
|
*/
|
|
585177
585690
|
const coerceJsonPrompt = (parsed) => {
|
|
@@ -585181,6 +585694,7 @@ const coerceJsonPrompt = (parsed) => {
|
|
|
585181
585694
|
const obj = parsed;
|
|
585182
585695
|
if (Array.isArray(obj.content)) return {
|
|
585183
585696
|
...isHeteroPermissionMode(obj.permissionMode) && { permissionMode: obj.permissionMode },
|
|
585697
|
+
...isCodexCollaborationMode(obj.collaborationMode) && { collaborationMode: obj.collaborationMode },
|
|
585184
585698
|
prompt: obj.content,
|
|
585185
585699
|
...Array.isArray(obj.resumeFallback) ? { resumeFallbackPrompt: obj.resumeFallback } : {}
|
|
585186
585700
|
};
|
|
@@ -585293,6 +585807,7 @@ const spawnAgentOrRuntime = (spawnOpts, onRawStdout, onStartupControl, nativeCod
|
|
|
585293
585807
|
askUserBridge: spawnOpts.askUserBridge,
|
|
585294
585808
|
clientVersion: cliVersion,
|
|
585295
585809
|
args: spawnOpts.extraArgs ?? [],
|
|
585810
|
+
collaborationMode: spawnOpts.collaborationMode,
|
|
585296
585811
|
commandPath: spawnOpts.command,
|
|
585297
585812
|
cwd: spawnOpts.cwd ?? process.cwd(),
|
|
585298
585813
|
env: {
|
|
@@ -585318,20 +585833,16 @@ const spawnAgentOrRuntime = (spawnOpts, onRawStdout, onStartupControl, nativeCod
|
|
|
585318
585833
|
/**
|
|
585319
585834
|
* Patterns that indicate a `--resume <sessionId>` run should be retried
|
|
585320
585835
|
* without `--resume`. Two classes of failure:
|
|
585321
|
-
*
|
|
585322
585836
|
* 1. Session file missing (sandbox recycled): the container is ephemeral
|
|
585323
585837
|
* (~1 h idle TTL), so a new sandbox has an empty `~/.claude/projects/`
|
|
585324
585838
|
* and the stored session id is stale.
|
|
585325
|
-
*
|
|
585326
585839
|
* 2. Context overflow (long conversation): the resumed session carries all
|
|
585327
|
-
* accumulated history
|
|
585328
|
-
*
|
|
585329
|
-
*
|
|
585330
|
-
* lets CC respond to the new prompt alone.
|
|
585840
|
+
* accumulated history past the model's context window, so the API rejects
|
|
585841
|
+
* the request right after CC initialises. Starting fresh (no `--resume`)
|
|
585842
|
+
* drops the old history and lets CC respond to the new prompt alone.
|
|
585331
585843
|
*
|
|
585332
|
-
* Checked against
|
|
585333
|
-
*
|
|
585334
|
-
* - Accumulated stderr output (fallback when CC exits without a result event)
|
|
585844
|
+
* Checked against `error` stream events (from CC's result event) and, when CC
|
|
585845
|
+
* exits without a result event, the accumulated stderr output.
|
|
585335
585846
|
*/
|
|
585336
585847
|
const RESUME_RETRY_PATTERNS = [
|
|
585337
585848
|
/no conversation found/i,
|
|
@@ -585891,7 +586402,7 @@ const exec = async (options) => {
|
|
|
585891
586402
|
initialModel: usesHeterogeneousSessionInitialModel(options.type) ? options.model : void 0,
|
|
585892
586403
|
liveInput: options.type === "claude-code" || options.type === "antigravity",
|
|
585893
586404
|
operationId,
|
|
585894
|
-
...options.type
|
|
586405
|
+
...dispatchedModeSpawnOptions(options.type, resolved),
|
|
585895
586406
|
uploadImage
|
|
585896
586407
|
};
|
|
585897
586408
|
const first = await runOneAgent({
|