@lobehub/cli 0.0.185 → 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 +309 -83
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { Buffer as Buffer$1 } from "node:buffer";
|
|
|
15
15
|
import * as net$1 from "node:net";
|
|
16
16
|
import net, { BlockList, connect, createServer, isIP } from "node:net";
|
|
17
17
|
import { scheduler, setImmediate as setImmediate$1, setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
18
|
-
import
|
|
18
|
+
import process$1, { cwd, execArgv, execPath, hrtime, platform as platform$1 } from "node:process";
|
|
19
19
|
import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
20
20
|
import { finished, pipeline } from "node:stream/promises";
|
|
21
21
|
import { Duplex, PassThrough, Readable, Transform, Writable, getDefaultHighWaterMark, pipeline as pipeline$1 } from "node:stream";
|
|
@@ -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();
|
|
@@ -22200,7 +22220,7 @@ var require_command = /* @__PURE__ */ __commonJSMin$2(((exports) => {
|
|
|
22200
22220
|
const childProcess$2 = __require("node:child_process");
|
|
22201
22221
|
const path$16 = __require("node:path");
|
|
22202
22222
|
const fs$17 = __require("node:fs");
|
|
22203
|
-
const process$
|
|
22223
|
+
const process$3 = __require("node:process");
|
|
22204
22224
|
const { Argument, humanReadableArgName } = require_argument();
|
|
22205
22225
|
const { CommanderError } = require_error$1();
|
|
22206
22226
|
const { Help, stripColor } = require_help();
|
|
@@ -22252,13 +22272,13 @@ var require_command = /* @__PURE__ */ __commonJSMin$2(((exports) => {
|
|
|
22252
22272
|
this._showSuggestionAfterError = true;
|
|
22253
22273
|
this._savedState = null;
|
|
22254
22274
|
this._outputConfiguration = {
|
|
22255
|
-
writeOut: (str) => process$
|
|
22256
|
-
writeErr: (str) => process$
|
|
22275
|
+
writeOut: (str) => process$3.stdout.write(str),
|
|
22276
|
+
writeErr: (str) => process$3.stderr.write(str),
|
|
22257
22277
|
outputError: (str, write) => write(str),
|
|
22258
|
-
getOutHelpWidth: () => process$
|
|
22259
|
-
getErrHelpWidth: () => process$
|
|
22260
|
-
getOutHasColors: () => useColor() ?? (process$
|
|
22261
|
-
getErrHasColors: () => useColor() ?? (process$
|
|
22278
|
+
getOutHelpWidth: () => process$3.stdout.isTTY ? process$3.stdout.columns : void 0,
|
|
22279
|
+
getErrHelpWidth: () => process$3.stderr.isTTY ? process$3.stderr.columns : void 0,
|
|
22280
|
+
getOutHasColors: () => useColor() ?? (process$3.stdout.isTTY && process$3.stdout.hasColors?.()),
|
|
22281
|
+
getErrHasColors: () => useColor() ?? (process$3.stderr.isTTY && process$3.stderr.hasColors?.()),
|
|
22262
22282
|
stripColor: (str) => stripColor(str)
|
|
22263
22283
|
};
|
|
22264
22284
|
this._hidden = false;
|
|
@@ -22616,7 +22636,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22616
22636
|
*/
|
|
22617
22637
|
_exit(exitCode, code, message) {
|
|
22618
22638
|
if (this._exitCallback) this._exitCallback(new CommanderError(exitCode, code, message));
|
|
22619
|
-
process$
|
|
22639
|
+
process$3.exit(exitCode);
|
|
22620
22640
|
}
|
|
22621
22641
|
/**
|
|
22622
22642
|
* Register callback `fn` for the command.
|
|
@@ -22955,11 +22975,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22955
22975
|
if (argv !== void 0 && !Array.isArray(argv)) throw new Error("first parameter to parse must be array or undefined");
|
|
22956
22976
|
parseOptions = parseOptions || {};
|
|
22957
22977
|
if (argv === void 0 && parseOptions.from === void 0) {
|
|
22958
|
-
if (process$
|
|
22959
|
-
const execArgv = process$
|
|
22978
|
+
if (process$3.versions?.electron) parseOptions.from = "electron";
|
|
22979
|
+
const execArgv = process$3.execArgv ?? [];
|
|
22960
22980
|
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) parseOptions.from = "eval";
|
|
22961
22981
|
}
|
|
22962
|
-
if (argv === void 0) argv = process$
|
|
22982
|
+
if (argv === void 0) argv = process$3.argv;
|
|
22963
22983
|
this.rawArgs = argv.slice();
|
|
22964
22984
|
let userArgs;
|
|
22965
22985
|
switch (parseOptions.from) {
|
|
@@ -22969,7 +22989,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22969
22989
|
userArgs = argv.slice(2);
|
|
22970
22990
|
break;
|
|
22971
22991
|
case "electron":
|
|
22972
|
-
if (process$
|
|
22992
|
+
if (process$3.defaultApp) {
|
|
22973
22993
|
this._scriptPath = argv[1];
|
|
22974
22994
|
userArgs = argv.slice(2);
|
|
22975
22995
|
} else userArgs = argv.slice(1);
|
|
@@ -23134,16 +23154,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23134
23154
|
}
|
|
23135
23155
|
launchWithNode = sourceExt.includes(path$16.extname(executableFile));
|
|
23136
23156
|
let proc;
|
|
23137
|
-
if (process$
|
|
23157
|
+
if (process$3.platform !== "win32") if (launchWithNode) {
|
|
23138
23158
|
args.unshift(executableFile);
|
|
23139
|
-
args = incrementNodeInspectorPort(process$
|
|
23140
|
-
proc = childProcess$2.spawn(process$
|
|
23159
|
+
args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
|
|
23160
|
+
proc = childProcess$2.spawn(process$3.argv[0], args, { stdio: "inherit" });
|
|
23141
23161
|
} else proc = childProcess$2.spawn(executableFile, args, { stdio: "inherit" });
|
|
23142
23162
|
else {
|
|
23143
23163
|
this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
23144
23164
|
args.unshift(executableFile);
|
|
23145
|
-
args = incrementNodeInspectorPort(process$
|
|
23146
|
-
proc = childProcess$2.spawn(process$
|
|
23165
|
+
args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
|
|
23166
|
+
proc = childProcess$2.spawn(process$3.execPath, args, { stdio: "inherit" });
|
|
23147
23167
|
}
|
|
23148
23168
|
if (!proc.killed) [
|
|
23149
23169
|
"SIGUSR1",
|
|
@@ -23152,20 +23172,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23152
23172
|
"SIGINT",
|
|
23153
23173
|
"SIGHUP"
|
|
23154
23174
|
].forEach((signal) => {
|
|
23155
|
-
process$
|
|
23175
|
+
process$3.on(signal, () => {
|
|
23156
23176
|
if (proc.killed === false && proc.exitCode === null) proc.kill(signal);
|
|
23157
23177
|
});
|
|
23158
23178
|
});
|
|
23159
23179
|
const exitCallback = this._exitCallback;
|
|
23160
23180
|
proc.on("close", (code) => {
|
|
23161
23181
|
code = code ?? 1;
|
|
23162
|
-
if (!exitCallback) process$
|
|
23182
|
+
if (!exitCallback) process$3.exit(code);
|
|
23163
23183
|
else exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
|
|
23164
23184
|
});
|
|
23165
23185
|
proc.on("error", (err) => {
|
|
23166
23186
|
if (err.code === "ENOENT") this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
23167
23187
|
else if (err.code === "EACCES") throw new Error(`'${executableFile}' not executable`);
|
|
23168
|
-
if (!exitCallback) process$
|
|
23188
|
+
if (!exitCallback) process$3.exit(1);
|
|
23169
23189
|
else {
|
|
23170
23190
|
const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
|
|
23171
23191
|
wrappedError.nestedError = err;
|
|
@@ -23574,13 +23594,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23574
23594
|
*/
|
|
23575
23595
|
_parseOptionsEnv() {
|
|
23576
23596
|
this.options.forEach((option) => {
|
|
23577
|
-
if (option.envVar && option.envVar in process$
|
|
23597
|
+
if (option.envVar && option.envVar in process$3.env) {
|
|
23578
23598
|
const optionKey = option.attributeName();
|
|
23579
23599
|
if (this.getOptionValue(optionKey) === void 0 || [
|
|
23580
23600
|
"default",
|
|
23581
23601
|
"config",
|
|
23582
23602
|
"env"
|
|
23583
|
-
].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$
|
|
23603
|
+
].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$3.env[option.envVar]);
|
|
23584
23604
|
else this.emit(`optionEnv:${option.name()}`);
|
|
23585
23605
|
}
|
|
23586
23606
|
});
|
|
@@ -23997,7 +24017,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23997
24017
|
*/
|
|
23998
24018
|
help(contextOptions) {
|
|
23999
24019
|
this.outputHelp(contextOptions);
|
|
24000
|
-
let exitCode = Number(process$
|
|
24020
|
+
let exitCode = Number(process$3.exitCode ?? 0);
|
|
24001
24021
|
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) exitCode = 1;
|
|
24002
24022
|
this._exit(exitCode, "commander.help", "(outputHelp)");
|
|
24003
24023
|
}
|
|
@@ -24087,8 +24107,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
24087
24107
|
* @package
|
|
24088
24108
|
*/
|
|
24089
24109
|
function useColor() {
|
|
24090
|
-
if (process$
|
|
24091
|
-
if (process$
|
|
24110
|
+
if (process$3.env.NO_COLOR || process$3.env.FORCE_COLOR === "0" || process$3.env.FORCE_COLOR === "false") return false;
|
|
24111
|
+
if (process$3.env.FORCE_COLOR || process$3.env.CLICOLOR_FORCE !== void 0) return true;
|
|
24092
24112
|
}
|
|
24093
24113
|
exports.Command = Command;
|
|
24094
24114
|
exports.useColor = useColor;
|
|
@@ -61915,7 +61935,7 @@ const codexQuotaReadings = (limits, capturedAt) => limits.flatMap((limit) => {
|
|
|
61915
61935
|
});
|
|
61916
61936
|
|
|
61917
61937
|
//#endregion
|
|
61918
|
-
//#region ../../packages/heterogeneous-agents/src/codex/
|
|
61938
|
+
//#region ../../packages/heterogeneous-agents/src/codex/appServerArgs.ts
|
|
61919
61939
|
const CODEX_DANGEROUS_BYPASS_FLAG = "--dangerously-bypass-approvals-and-sandbox";
|
|
61920
61940
|
const CODEX_FULL_AUTO_FLAG = "--full-auto";
|
|
61921
61941
|
const CODEX_APPROVAL_FLAGS = ["-a", "--ask-for-approval"];
|
|
@@ -61962,15 +61982,15 @@ const getCodexAppServerUnsupportedArgs = (args, options = {}) => {
|
|
|
61962
61982
|
const hasSandboxFlag = args.some((arg) => CODEX_SANDBOX_FLAGS.includes(arg) || getFlagValue(arg, CODEX_SANDBOX_FLAGS) !== void 0);
|
|
61963
61983
|
for (let index = 0; index < args.length; index += 1) {
|
|
61964
61984
|
const arg = args[index];
|
|
61965
|
-
if (arg ===
|
|
61985
|
+
if (arg === "--dangerously-bypass-approvals-and-sandbox") {
|
|
61966
61986
|
if (hasSandboxFlag) unsupported.push(arg);
|
|
61967
61987
|
continue;
|
|
61968
61988
|
}
|
|
61969
|
-
if (arg ===
|
|
61989
|
+
if (arg === "--ephemeral") {
|
|
61970
61990
|
if (options.resume) unsupported.push(arg);
|
|
61971
61991
|
continue;
|
|
61972
61992
|
}
|
|
61973
|
-
if (arg ===
|
|
61993
|
+
if (arg === "--full-auto" || arg === "--ignore-user-config") {
|
|
61974
61994
|
unsupported.push(arg);
|
|
61975
61995
|
continue;
|
|
61976
61996
|
}
|
|
@@ -62007,6 +62027,9 @@ const getCodexAppServerUnsupportedArgs = (args, options = {}) => {
|
|
|
62007
62027
|
}
|
|
62008
62028
|
return unsupported;
|
|
62009
62029
|
};
|
|
62030
|
+
|
|
62031
|
+
//#endregion
|
|
62032
|
+
//#region ../../packages/heterogeneous-agents/src/codex/appServerParams.ts
|
|
62010
62033
|
const buildCodexAppServerThreadParams = (args, cwd, initialModel) => {
|
|
62011
62034
|
const config = { "features.default_mode_request_user_input": true };
|
|
62012
62035
|
let effectiveCwd = cwd;
|
|
@@ -62017,15 +62040,15 @@ const buildCodexAppServerThreadParams = (args, cwd, initialModel) => {
|
|
|
62017
62040
|
let serviceTier;
|
|
62018
62041
|
for (let index = 0; index < args.length; index += 1) {
|
|
62019
62042
|
const arg = args[index];
|
|
62020
|
-
if (arg ===
|
|
62043
|
+
if (arg === "--dangerously-bypass-approvals-and-sandbox") {
|
|
62021
62044
|
sandbox = "danger-full-access";
|
|
62022
62045
|
continue;
|
|
62023
62046
|
}
|
|
62024
|
-
if (arg ===
|
|
62047
|
+
if (arg === "--full-auto") {
|
|
62025
62048
|
sandbox = "workspace-write";
|
|
62026
62049
|
continue;
|
|
62027
62050
|
}
|
|
62028
|
-
if (arg ===
|
|
62051
|
+
if (arg === "--ephemeral") {
|
|
62029
62052
|
ephemeral = true;
|
|
62030
62053
|
continue;
|
|
62031
62054
|
}
|
|
@@ -62513,17 +62536,19 @@ const buildHeterogeneousPrompt = (input) => new HeterogeneousPromptEngine(input)
|
|
|
62513
62536
|
*
|
|
62514
62537
|
* `permissionMode` (Claude Code, Better Coding Experience lab) rides the same
|
|
62515
62538
|
* envelope for the same reason: an `lh` that predates it unwraps `content` and
|
|
62516
|
-
* 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.
|
|
62517
62541
|
*/
|
|
62518
62542
|
const buildHeteroExecStdinPayload = (params) => {
|
|
62519
|
-
const { imageList = [], isNewSession, permissionMode, prompt, resumeFallbackSystemContext, systemContext } = params;
|
|
62543
|
+
const { collaborationMode, imageList = [], isNewSession, permissionMode, prompt, resumeFallbackSystemContext, systemContext } = params;
|
|
62520
62544
|
const blocks = buildHeterogeneousPrompt({
|
|
62521
62545
|
imageList,
|
|
62522
62546
|
isNewSession,
|
|
62523
62547
|
prompt,
|
|
62524
62548
|
systemContext
|
|
62525
62549
|
});
|
|
62526
|
-
if (resumeFallbackSystemContext !== void 0 || permissionMode) return JSON.stringify({
|
|
62550
|
+
if (resumeFallbackSystemContext !== void 0 || permissionMode || collaborationMode) return JSON.stringify({
|
|
62551
|
+
...collaborationMode && { collaborationMode },
|
|
62527
62552
|
content: blocks,
|
|
62528
62553
|
...permissionMode && { permissionMode },
|
|
62529
62554
|
resumeFallback: resumeFallbackSystemContext === void 0 ? void 0 : buildHeterogeneousPrompt({
|
|
@@ -64144,6 +64169,13 @@ function splitLines(text) {
|
|
|
64144
64169
|
return result;
|
|
64145
64170
|
}
|
|
64146
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
|
+
|
|
64147
64179
|
//#endregion
|
|
64148
64180
|
//#region ../../packages/heterogeneous-agents/src/utils/codexCommandOutput.ts
|
|
64149
64181
|
const CODEX_COMMAND_OUTPUT_MAX_LENGTH = 25e3;
|
|
@@ -64452,6 +64484,8 @@ var CodexAppServerAdapter = class {
|
|
|
64452
64484
|
pendingTools = /* @__PURE__ */ new Map();
|
|
64453
64485
|
streamedAgentText = /* @__PURE__ */ new Map();
|
|
64454
64486
|
streamedCommandOutput = /* @__PURE__ */ new Map();
|
|
64487
|
+
/** Plan-mode plans (`item/plan/delta`) streamed so far, by item id. */
|
|
64488
|
+
streamedPlans = /* @__PURE__ */ new Map();
|
|
64455
64489
|
streamedReasoning = /* @__PURE__ */ new Set();
|
|
64456
64490
|
toolStateSequence = /* @__PURE__ */ new Map();
|
|
64457
64491
|
stepToolCalls = [];
|
|
@@ -64514,6 +64548,7 @@ var CodexAppServerAdapter = class {
|
|
|
64514
64548
|
case "item/fileChange/patchUpdated": return this.handleFileChangeUpdate(rawParams);
|
|
64515
64549
|
case "item/mcpToolCall/progress": return this.handleMcpProgress(rawParams);
|
|
64516
64550
|
case "turn/plan/updated": return this.handlePlanUpdated(rawParams);
|
|
64551
|
+
case "item/plan/delta": return this.handleProposedPlanDelta(rawParams);
|
|
64517
64552
|
case "thread/tokenUsage/updated": {
|
|
64518
64553
|
const { tokenUsage } = rawParams;
|
|
64519
64554
|
const cumulativeUsage = toUsage(tokenUsage.total);
|
|
@@ -64544,6 +64579,7 @@ var CodexAppServerAdapter = class {
|
|
|
64544
64579
|
}
|
|
64545
64580
|
handleItemStarted({ item }) {
|
|
64546
64581
|
if (item.type === "userMessage") return this.handleSteeredUserMessage(item);
|
|
64582
|
+
if (item.type === "plan") return this.startProposedPlan(item);
|
|
64547
64583
|
if (!isToolItem(item)) return [];
|
|
64548
64584
|
const opening = this.openStepAfterSteer();
|
|
64549
64585
|
this.hasToolActivity = true;
|
|
@@ -64590,6 +64626,7 @@ var CodexAppServerAdapter = class {
|
|
|
64590
64626
|
}
|
|
64591
64627
|
return message.text ? this.emitText(message.id, message.text) : [];
|
|
64592
64628
|
}
|
|
64629
|
+
if (item.type === "plan") return this.completeProposedPlan(item);
|
|
64593
64630
|
if (item.type === "reasoning") {
|
|
64594
64631
|
const reasoningItem = item;
|
|
64595
64632
|
if (this.streamedReasoning.delete(reasoningItem.id)) return [];
|
|
@@ -64657,6 +64694,75 @@ var CodexAppServerAdapter = class {
|
|
|
64657
64694
|
status: "inProgress"
|
|
64658
64695
|
})] : [];
|
|
64659
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
|
+
}
|
|
64660
64766
|
handlePlanUpdated(params) {
|
|
64661
64767
|
const id = `turn-plan-${params.turnId}`;
|
|
64662
64768
|
let foundProcessing = false;
|
|
@@ -64975,6 +65081,7 @@ const formatCodexAsyncReplies = (replies) => `<send_user_message_question_reply>
|
|
|
64975
65081
|
|
|
64976
65082
|
//#endregion
|
|
64977
65083
|
//#region ../../packages/heterogeneous-agents/src/codex/CodexThreadSession.ts
|
|
65084
|
+
init_src$2();
|
|
64978
65085
|
init_object$1();
|
|
64979
65086
|
const CODEX_APP_SERVER_TRANSPORT = "codex-app-server";
|
|
64980
65087
|
/** An interrupted turn settled within 250 ms in probes; this bounds slow tool teardown. */
|
|
@@ -65004,6 +65111,15 @@ var CodexThreadSession = class {
|
|
|
65004
65111
|
interruptRequested = false;
|
|
65005
65112
|
lastOperationId;
|
|
65006
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 = [];
|
|
65007
65123
|
running = false;
|
|
65008
65124
|
sessionUnsubscribers = [];
|
|
65009
65125
|
threadId;
|
|
@@ -65026,6 +65142,7 @@ var CodexThreadSession = class {
|
|
|
65026
65142
|
this.running = true;
|
|
65027
65143
|
this.interruptRequested = false;
|
|
65028
65144
|
this.lastOperationId = options.operationId;
|
|
65145
|
+
this.collaborationMode = options.collaborationMode;
|
|
65029
65146
|
this.emitStatus("starting", options.operationId);
|
|
65030
65147
|
const traceUnsubscribers = [];
|
|
65031
65148
|
try {
|
|
@@ -65097,9 +65214,12 @@ var CodexThreadSession = class {
|
|
|
65097
65214
|
transportInterrupted: false
|
|
65098
65215
|
};
|
|
65099
65216
|
this.activeTurn = activeTurn;
|
|
65217
|
+
const collaborationMode = this.collaborationModeParams(this.collaborationMode);
|
|
65218
|
+
this.pendingModeRequests = collaborationMode ? [collaborationMode.mode] : [];
|
|
65100
65219
|
const turnParams = {
|
|
65101
65220
|
input,
|
|
65102
|
-
threadId
|
|
65221
|
+
threadId,
|
|
65222
|
+
...collaborationMode && { collaborationMode }
|
|
65103
65223
|
};
|
|
65104
65224
|
this.canFallback = false;
|
|
65105
65225
|
activeTurn.turnId = (await this.options.client.request("turn/start", turnParams))?.turn?.id;
|
|
@@ -65188,14 +65308,14 @@ var CodexThreadSession = class {
|
|
|
65188
65308
|
this.releaseThread ??= this.options.client.acquireThread(this.threadId);
|
|
65189
65309
|
const response = this.provenance ? await this.resumeWithShellEnv(this.threadId) : await this.options.client.request("thread/resume", toThreadResumeParams(this.threadId, this.threadParams));
|
|
65190
65310
|
if (!response || this.closedByHost) return;
|
|
65191
|
-
await this.attachThread(response.thread.id, response.model);
|
|
65311
|
+
await this.attachThread(response.thread.id, response.model, response.reasoningEffort);
|
|
65192
65312
|
return;
|
|
65193
65313
|
}
|
|
65194
65314
|
const response = await this.options.client.request("thread/start", this.threadParams);
|
|
65195
65315
|
if (this.closedByHost) return;
|
|
65196
65316
|
const threadId = response?.thread?.id;
|
|
65197
65317
|
if (!threadId) throw new CodexAppServerConnectionError("Codex app-server returned an incompatible thread/start response", { phase: "thread-start" });
|
|
65198
|
-
await this.attachThread(threadId, response.model);
|
|
65318
|
+
await this.attachThread(threadId, response.model, response.reasoningEffort);
|
|
65199
65319
|
if (!this.options.threadParams.ephemeral) {
|
|
65200
65320
|
await this.setThreadName(threadId);
|
|
65201
65321
|
this.options.onSessionId(threadId);
|
|
@@ -65240,12 +65360,13 @@ var CodexThreadSession = class {
|
|
|
65240
65360
|
});
|
|
65241
65361
|
}
|
|
65242
65362
|
}
|
|
65243
|
-
async attachThread(threadId, model) {
|
|
65363
|
+
async attachThread(threadId, model, effort) {
|
|
65244
65364
|
this.releaseThread ??= this.options.client.acquireThread(threadId);
|
|
65245
65365
|
this.threadId = threadId;
|
|
65246
65366
|
this.attached = true;
|
|
65247
65367
|
this.canFallback = false;
|
|
65248
65368
|
if (model) this.updateModel(model);
|
|
65369
|
+
if (effort !== void 0) this.effort = effort;
|
|
65249
65370
|
if (this.threadUnsubscribers.length > 0) return;
|
|
65250
65371
|
this.threadUnsubscribers.push(this.options.client.subscribe(threadId, (method, params) => this.enqueueNotification(method, params)), this.options.client.subscribeServerRequests(threadId, (method, params) => {
|
|
65251
65372
|
if (method === "item/commandExecution/requestApproval" || method === "item/fileChange/requestApproval") return { decision: "cancel" };
|
|
@@ -65258,10 +65379,73 @@ var CodexThreadSession = class {
|
|
|
65258
65379
|
}
|
|
65259
65380
|
}));
|
|
65260
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
|
+
}
|
|
65261
65444
|
async handleReconnect(response) {
|
|
65262
65445
|
if (this.closedByHost) return;
|
|
65263
65446
|
this.attached = true;
|
|
65264
65447
|
if (response.model) this.updateModel(response.model);
|
|
65448
|
+
if (response.reasoningEffort !== void 0) this.effort = response.reasoningEffort;
|
|
65265
65449
|
}
|
|
65266
65450
|
async requestUserInput(params) {
|
|
65267
65451
|
const request = parseCodexUserInput(params);
|
|
@@ -65308,6 +65492,7 @@ var CodexThreadSession = class {
|
|
|
65308
65492
|
enqueueNotification(method, params) {
|
|
65309
65493
|
const activeTurn = this.activeTurn;
|
|
65310
65494
|
if (!activeTurn || !this.isCurrentTurnNotification(method, params, activeTurn)) return Promise.resolve();
|
|
65495
|
+
if (method === "thread/settings/updated") return this.handleThreadSettingsUpdated(activeTurn, params);
|
|
65311
65496
|
if (method === "turn/completed") {
|
|
65312
65497
|
if (params.turn.status !== "inProgress") {
|
|
65313
65498
|
activeTurn.terminalNotificationReceived = true;
|
|
@@ -65500,6 +65685,7 @@ const createCodexAgentHandle = async (options) => {
|
|
|
65500
65685
|
options.onStartupControl?.({ cancel });
|
|
65501
65686
|
const turnOptions = {
|
|
65502
65687
|
askUserBridge: options.askUserBridge,
|
|
65688
|
+
collaborationMode: options.collaborationMode,
|
|
65503
65689
|
input: buildCodexAppServerInput(input),
|
|
65504
65690
|
onRawMessage: (line) => options.onRawStdout?.(Buffer.from(line)),
|
|
65505
65691
|
operationId: options.operationId,
|
|
@@ -65559,6 +65745,8 @@ const createCodexAgentHandle = async (options) => {
|
|
|
65559
65745
|
get sessionId() {
|
|
65560
65746
|
return nativeSessionId;
|
|
65561
65747
|
},
|
|
65748
|
+
/** The Plan switch flipped mid-run: Codex takes it from the next turn. */
|
|
65749
|
+
setCollaborationMode: (mode) => session.setCollaborationMode(mode),
|
|
65562
65750
|
stderr,
|
|
65563
65751
|
supportsSteerImageAttachments: true
|
|
65564
65752
|
};
|
|
@@ -325613,7 +325801,7 @@ var init_shimsNode = __esmMin((() => {
|
|
|
325613
325801
|
}));
|
|
325614
325802
|
|
|
325615
325803
|
//#endregion
|
|
325616
|
-
//#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
|
|
325617
325805
|
/**
|
|
325618
325806
|
* Creates an array of length `size` of random bytes
|
|
325619
325807
|
* @param size
|
|
@@ -334867,7 +335055,7 @@ var stdio_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
334867
335055
|
function getDefaultEnvironment() {
|
|
334868
335056
|
const env = {};
|
|
334869
335057
|
for (const key of DEFAULT_INHERITED_ENV_VARS) {
|
|
334870
|
-
const value =
|
|
335058
|
+
const value = process$1.env[key];
|
|
334871
335059
|
if (value === void 0) continue;
|
|
334872
335060
|
if (value.startsWith("()")) continue;
|
|
334873
335061
|
env[key] = value;
|
|
@@ -334878,7 +335066,7 @@ var import_cross_spawn$1, DEFAULT_INHERITED_ENV_VARS, StdioClientTransport;
|
|
|
334878
335066
|
var init_stdio = __esmMin((() => {
|
|
334879
335067
|
init_src_CeKsbNLO();
|
|
334880
335068
|
import_cross_spawn$1 = /* @__PURE__ */ __toESM$2(require_cross_spawn(), 1);
|
|
334881
|
-
DEFAULT_INHERITED_ENV_VARS =
|
|
335069
|
+
DEFAULT_INHERITED_ENV_VARS = process$1.platform === "win32" ? [
|
|
334882
335070
|
"APPDATA",
|
|
334883
335071
|
"COMSPEC",
|
|
334884
335072
|
"HOMEDRIVE",
|
|
@@ -334935,7 +335123,7 @@ var init_stdio = __esmMin((() => {
|
|
|
334935
335123
|
this._serverParams.stderr ?? "inherit"
|
|
334936
335124
|
],
|
|
334937
335125
|
shell: false,
|
|
334938
|
-
windowsHide:
|
|
335126
|
+
windowsHide: process$1.platform === "win32",
|
|
334939
335127
|
cwd: this._serverParams.cwd
|
|
334940
335128
|
});
|
|
334941
335129
|
this._process.on("error", (error) => {
|
|
@@ -337969,9 +338157,9 @@ const getSubprocessResult = ({ stdout }) => {
|
|
|
337969
338157
|
//#region node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/utils/standard-stream.js
|
|
337970
338158
|
const isStandardStream = (stream) => STANDARD_STREAMS.includes(stream);
|
|
337971
338159
|
const STANDARD_STREAMS = [
|
|
337972
|
-
|
|
337973
|
-
|
|
337974
|
-
|
|
338160
|
+
process$1.stdin,
|
|
338161
|
+
process$1.stdout,
|
|
338162
|
+
process$1.stderr
|
|
337975
338163
|
];
|
|
337976
338164
|
const STANDARD_STREAMS_ALIASES = [
|
|
337977
338165
|
"stdin",
|
|
@@ -338096,9 +338284,9 @@ const NO_ESCAPE_REGEXP = /^[\w./-]+$/;
|
|
|
338096
338284
|
//#endregion
|
|
338097
338285
|
//#region node_modules/.pnpm/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
|
|
338098
338286
|
function isUnicodeSupported() {
|
|
338099
|
-
const { env } =
|
|
338287
|
+
const { env } = process$1;
|
|
338100
338288
|
const { TERM, TERM_PROGRAM } = env;
|
|
338101
|
-
if (
|
|
338289
|
+
if (process$1.platform !== "win32") return TERM !== "linux";
|
|
338102
338290
|
return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
338103
338291
|
}
|
|
338104
338292
|
|
|
@@ -338633,7 +338821,7 @@ function traversePathUp(startPath) {
|
|
|
338633
338821
|
|
|
338634
338822
|
//#endregion
|
|
338635
338823
|
//#region node_modules/.pnpm/npm-run-path@6.0.0/node_modules/npm-run-path/index.js
|
|
338636
|
-
const npmRunPath = ({ cwd =
|
|
338824
|
+
const npmRunPath = ({ cwd = process$1.cwd(), path: pathOption = process$1.env[pathKey()], preferLocal = true, execPath = process$1.execPath, addExecPath = true } = {}) => {
|
|
338637
338825
|
const cwdPath = path.resolve(toPath(cwd));
|
|
338638
338826
|
const result = [];
|
|
338639
338827
|
const pathParts = pathOption.split(path.delimiter);
|
|
@@ -338651,7 +338839,7 @@ const applyExecPath = (result, pathParts, execPath, cwdPath) => {
|
|
|
338651
338839
|
const pathPart = path.resolve(cwdPath, toPath(execPath), "..");
|
|
338652
338840
|
if (!pathParts.includes(pathPart)) result.push(pathPart);
|
|
338653
338841
|
};
|
|
338654
|
-
const npmRunPathEnv = ({ env =
|
|
338842
|
+
const npmRunPathEnv = ({ env = process$1.env, ...options } = {}) => {
|
|
338655
338843
|
env = { ...env };
|
|
338656
338844
|
const pathName = pathKey({ env });
|
|
338657
338845
|
options.path = env[pathName];
|
|
@@ -339786,7 +339974,7 @@ const normalizeCwd = (cwd = getDefaultCwd()) => {
|
|
|
339786
339974
|
};
|
|
339787
339975
|
const getDefaultCwd = () => {
|
|
339788
339976
|
try {
|
|
339789
|
-
return
|
|
339977
|
+
return process$1.cwd();
|
|
339790
339978
|
} catch (error) {
|
|
339791
339979
|
error.message = `The current directory does not exist.\n${error.message}`;
|
|
339792
339980
|
throw error;
|
|
@@ -339822,7 +340010,7 @@ const normalizeOptions = (filePath, rawArguments, rawOptions) => {
|
|
|
339822
340010
|
options.killSignal = normalizeKillSignal(options.killSignal);
|
|
339823
340011
|
options.forceKillAfterDelay = normalizeForceKillAfterDelay(options.forceKillAfterDelay);
|
|
339824
340012
|
options.lines = options.lines.map((lines, fdNumber) => lines && !BINARY_ENCODINGS.has(options.encoding) && options.buffer[fdNumber]);
|
|
339825
|
-
if (
|
|
340013
|
+
if (process$1.platform === "win32" && path.basename(file, ".exe") === "cmd") commandArguments.unshift("/q");
|
|
339826
340014
|
return {
|
|
339827
340015
|
file,
|
|
339828
340016
|
commandArguments,
|
|
@@ -339849,7 +340037,7 @@ const addDefaultOptions = ({ extendEnv = true, preferLocal = false, cwd, localDi
|
|
|
339849
340037
|
});
|
|
339850
340038
|
const getEnv = ({ env: envOption, extendEnv, preferLocal, node, localDirectory, nodePath }) => {
|
|
339851
340039
|
const env = extendEnv ? {
|
|
339852
|
-
...
|
|
340040
|
+
...process$1.env,
|
|
339853
340041
|
...envOption
|
|
339854
340042
|
} : envOption;
|
|
339855
340043
|
if (preferLocal || node) return npmRunPathEnv({
|
|
@@ -340851,12 +341039,12 @@ const guessStreamDirection = {
|
|
|
340851
341039
|
}
|
|
340852
341040
|
};
|
|
340853
341041
|
const getStandardStreamDirection = (value) => {
|
|
340854
|
-
if ([0,
|
|
341042
|
+
if ([0, process$1.stdin].includes(value)) return "input";
|
|
340855
341043
|
if ([
|
|
340856
341044
|
1,
|
|
340857
341045
|
2,
|
|
340858
|
-
|
|
340859
|
-
|
|
341046
|
+
process$1.stdout,
|
|
341047
|
+
process$1.stderr
|
|
340860
341048
|
].includes(value)) return "output";
|
|
340861
341049
|
};
|
|
340862
341050
|
const DEFAULT_DIRECTION = "output";
|
|
@@ -341920,9 +342108,9 @@ const addIpcMethods = (subprocess, { ipc }) => {
|
|
|
341920
342108
|
Object.assign(subprocess, getIpcMethods(subprocess, false, ipc));
|
|
341921
342109
|
};
|
|
341922
342110
|
const getIpcExport = () => {
|
|
341923
|
-
const anyProcess =
|
|
342111
|
+
const anyProcess = process$1;
|
|
341924
342112
|
const isSubprocess = true;
|
|
341925
|
-
const ipc =
|
|
342113
|
+
const ipc = process$1.channel !== void 0;
|
|
341926
342114
|
return {
|
|
341927
342115
|
...getIpcMethods(anyProcess, isSubprocess, ipc),
|
|
341928
342116
|
getCancelSignal: getCancelSignal$1.bind(void 0, {
|
|
@@ -342399,7 +342587,7 @@ var SignalExitFallback = class extends SignalExitBase {
|
|
|
342399
342587
|
};
|
|
342400
342588
|
var SignalExit = class extends SignalExitBase {
|
|
342401
342589
|
/* c8 ignore start */
|
|
342402
|
-
#hupSig = process$
|
|
342590
|
+
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
342403
342591
|
/* c8 ignore stop */
|
|
342404
342592
|
#emitter = new Emitter();
|
|
342405
342593
|
#process;
|
|
@@ -342494,8 +342682,8 @@ var SignalExit = class extends SignalExitBase {
|
|
|
342494
342682
|
} else return og.call(this.#process, ev, ...args);
|
|
342495
342683
|
}
|
|
342496
342684
|
};
|
|
342497
|
-
const process$
|
|
342498
|
-
const { onExit, load: load$1, unload } = signalExitWrap(processOk(process$
|
|
342685
|
+
const process$2 = globalThis.process;
|
|
342686
|
+
const { onExit, load: load$1, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
342499
342687
|
|
|
342500
342688
|
//#endregion
|
|
342501
342689
|
//#region node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/terminate/cleanup.js
|
|
@@ -345561,6 +345749,7 @@ const createFileSearchModule = (toolDetector) => {
|
|
|
345561
345749
|
//#endregion
|
|
345562
345750
|
//#region src/device/systemInfo.ts
|
|
345563
345751
|
init_resolveCliCommand();
|
|
345752
|
+
init_src$2();
|
|
345564
345753
|
/**
|
|
345565
345754
|
* Checks the currently resolved Codex binary without creating a conversation.
|
|
345566
345755
|
*
|
|
@@ -345615,9 +345804,12 @@ async function supportsNativeCodex() {
|
|
|
345615
345804
|
client?.close();
|
|
345616
345805
|
}
|
|
345617
345806
|
}
|
|
345618
|
-
/**
|
|
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
|
+
*/
|
|
345619
345811
|
async function probeNativeRuntimes() {
|
|
345620
|
-
return await supportsNativeCodex() ? ["codex-app-server-v1"] : [];
|
|
345812
|
+
return await supportsNativeCodex() ? ["codex-app-server-v1", CODEX_COLLABORATION_MODE_RUNTIME] : [];
|
|
345621
345813
|
}
|
|
345622
345814
|
/**
|
|
345623
345815
|
* The answer to a gateway `system_info_request`: host paths and live native capabilities.
|
|
@@ -555813,6 +556005,7 @@ function startHeteroAgentRun(params, accountEnv, logger) {
|
|
|
555813
556005
|
...extraArgs ?? []
|
|
555814
556006
|
];
|
|
555815
556007
|
const stdinPayload = buildHeteroExecStdinPayload({
|
|
556008
|
+
collaborationMode: params.collaborationMode,
|
|
555816
556009
|
imageList,
|
|
555817
556010
|
isNewSession: !resumeSessionId,
|
|
555818
556011
|
permissionMode: params.permissionMode,
|
|
@@ -558182,6 +558375,7 @@ function bindGatewayClientHandlers(client, ctx, connectionWorkspaceId) {
|
|
|
558182
558375
|
args: request.args,
|
|
558183
558376
|
claudeAccountRouting: request.claudeAccountRouting,
|
|
558184
558377
|
claudeCodeEntrypoint: request.claudeCodeEntrypoint,
|
|
558378
|
+
collaborationMode: request.collaborationMode,
|
|
558185
558379
|
cwd: request.cwd,
|
|
558186
558380
|
imageList: request.imageList,
|
|
558187
558381
|
jwt: request.jwt,
|
|
@@ -584983,6 +585177,25 @@ const dispatchHeteroControl = async (message, context) => {
|
|
|
584983
585177
|
}
|
|
584984
585178
|
};
|
|
584985
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
|
+
|
|
584986
585199
|
//#endregion
|
|
584987
585200
|
//#region src/utils/heteroPermissionMode.ts
|
|
584988
585201
|
init_src$2();
|
|
@@ -585079,6 +585292,7 @@ async function* withHeteroSteer(handle, context) {
|
|
|
585079
585292
|
}
|
|
585080
585293
|
const { operationId } = context;
|
|
585081
585294
|
const sendControlRequest = handle.sendControlRequest;
|
|
585295
|
+
const setCollaborationMode = handle.setCollaborationMode;
|
|
585082
585296
|
const delivered = /* @__PURE__ */ new Set();
|
|
585083
585297
|
const abort = new AbortController();
|
|
585084
585298
|
const handling = /* @__PURE__ */ new Set();
|
|
@@ -585109,7 +585323,8 @@ async function* withHeteroSteer(handle, context) {
|
|
|
585109
585323
|
log$15.debug("Control %s: %s", control.id, control.command);
|
|
585110
585324
|
await report(client, control, await dispatchHeteroControl(control, {
|
|
585111
585325
|
operationId,
|
|
585112
|
-
sendControlRequest,
|
|
585326
|
+
sendControlRequest: sendControlRequest ?? (() => void 0),
|
|
585327
|
+
setCollaborationMode,
|
|
585113
585328
|
signal: abort.signal
|
|
585114
585329
|
}));
|
|
585115
585330
|
})().catch((error) => log$15.debug("Control %s failed: %s", control.id, String(error))).finally(() => handling.delete(task));
|
|
@@ -585117,7 +585332,7 @@ async function* withHeteroSteer(handle, context) {
|
|
|
585117
585332
|
};
|
|
585118
585333
|
const poll = async () => {
|
|
585119
585334
|
const client = await context.getTrpcClient();
|
|
585120
|
-
const acceptsControl = !!sendControlRequest && !!client.aiAgent.reportHeteroControlResult;
|
|
585335
|
+
const acceptsControl = (!!sendControlRequest || !!setCollaborationMode) && !!client.aiAgent.reportHeteroControlResult;
|
|
585121
585336
|
while (!abort.signal.aborted) {
|
|
585122
585337
|
let message;
|
|
585123
585338
|
try {
|
|
@@ -585405,6 +585620,18 @@ const buildExtraArgs = (options) => {
|
|
|
585405
585620
|
return extraArgs.length > 0 ? extraArgs : void 0;
|
|
585406
585621
|
};
|
|
585407
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
|
+
|
|
585408
585635
|
//#endregion
|
|
585409
585636
|
//#region src/commands/hetero/prompt.ts
|
|
585410
585637
|
init_src$2();
|
|
@@ -585454,9 +585681,10 @@ const parseImageArg = (value) => {
|
|
|
585454
585681
|
* Accepts:
|
|
585455
585682
|
* - `'plain text'` → single text block
|
|
585456
585683
|
* - `[{ type: 'text', text }, { type: 'image', source }]` → content blocks
|
|
585457
|
-
* - `{ content: [...], resumeFallback?: [...], permissionMode? }`
|
|
585458
|
-
* primary prompt, reserves the fallback for a retry without
|
|
585459
|
-
* 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
|
|
585460
585688
|
* - `{ type: 'text', ... } | { type: 'image', ... }` → single block
|
|
585461
585689
|
*/
|
|
585462
585690
|
const coerceJsonPrompt = (parsed) => {
|
|
@@ -585466,6 +585694,7 @@ const coerceJsonPrompt = (parsed) => {
|
|
|
585466
585694
|
const obj = parsed;
|
|
585467
585695
|
if (Array.isArray(obj.content)) return {
|
|
585468
585696
|
...isHeteroPermissionMode(obj.permissionMode) && { permissionMode: obj.permissionMode },
|
|
585697
|
+
...isCodexCollaborationMode(obj.collaborationMode) && { collaborationMode: obj.collaborationMode },
|
|
585469
585698
|
prompt: obj.content,
|
|
585470
585699
|
...Array.isArray(obj.resumeFallback) ? { resumeFallbackPrompt: obj.resumeFallback } : {}
|
|
585471
585700
|
};
|
|
@@ -585578,6 +585807,7 @@ const spawnAgentOrRuntime = (spawnOpts, onRawStdout, onStartupControl, nativeCod
|
|
|
585578
585807
|
askUserBridge: spawnOpts.askUserBridge,
|
|
585579
585808
|
clientVersion: cliVersion,
|
|
585580
585809
|
args: spawnOpts.extraArgs ?? [],
|
|
585810
|
+
collaborationMode: spawnOpts.collaborationMode,
|
|
585581
585811
|
commandPath: spawnOpts.command,
|
|
585582
585812
|
cwd: spawnOpts.cwd ?? process.cwd(),
|
|
585583
585813
|
env: {
|
|
@@ -585603,20 +585833,16 @@ const spawnAgentOrRuntime = (spawnOpts, onRawStdout, onStartupControl, nativeCod
|
|
|
585603
585833
|
/**
|
|
585604
585834
|
* Patterns that indicate a `--resume <sessionId>` run should be retried
|
|
585605
585835
|
* without `--resume`. Two classes of failure:
|
|
585606
|
-
*
|
|
585607
585836
|
* 1. Session file missing (sandbox recycled): the container is ephemeral
|
|
585608
585837
|
* (~1 h idle TTL), so a new sandbox has an empty `~/.claude/projects/`
|
|
585609
585838
|
* and the stored session id is stale.
|
|
585610
|
-
*
|
|
585611
585839
|
* 2. Context overflow (long conversation): the resumed session carries all
|
|
585612
|
-
* accumulated history
|
|
585613
|
-
*
|
|
585614
|
-
*
|
|
585615
|
-
* 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.
|
|
585616
585843
|
*
|
|
585617
|
-
* Checked against
|
|
585618
|
-
*
|
|
585619
|
-
* - 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.
|
|
585620
585846
|
*/
|
|
585621
585847
|
const RESUME_RETRY_PATTERNS = [
|
|
585622
585848
|
/no conversation found/i,
|
|
@@ -586176,7 +586402,7 @@ const exec = async (options) => {
|
|
|
586176
586402
|
initialModel: usesHeterogeneousSessionInitialModel(options.type) ? options.model : void 0,
|
|
586177
586403
|
liveInput: options.type === "claude-code" || options.type === "antigravity",
|
|
586178
586404
|
operationId,
|
|
586179
|
-
...options.type
|
|
586405
|
+
...dispatchedModeSpawnOptions(options.type, resolved),
|
|
586180
586406
|
uploadImage
|
|
586181
586407
|
};
|
|
586182
586408
|
const first = await runOneAgent({
|