@lichao0223/lobehub-cli 0.0.103 → 0.0.105

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/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 process$1, { cwd, execArgv, execPath, hrtime, platform as platform$1 } from "node:process";
18
+ import _w, { 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;
@@ -12520,10 +12543,6 @@ var init_trace = __esmMin((() => {
12520
12543
  //#region ../../packages/types/src/util.ts
12521
12544
  var init_util$2 = __esmMin((() => {}));
12522
12545
 
12523
- //#endregion
12524
- //#region ../../packages/types/src/worktreeMode.ts
12525
- var init_worktreeMode = __esmMin((() => {}));
12526
-
12527
12546
  //#endregion
12528
12547
  //#region ../../packages/types/src/zustand.ts
12529
12548
  var init_zustand = __esmMin((() => {}));
@@ -12637,6 +12656,7 @@ var init_src$2 = __esmMin((() => {
12637
12656
  init_connector();
12638
12657
  init_connectorToolIdentifier();
12639
12658
  init_heteroPermissionMode();
12659
+ init_heteroPlanMode();
12640
12660
  init_inboundWebhook();
12641
12661
  init_oauthApp();
12642
12662
  init_chat();
@@ -22205,7 +22225,7 @@ var require_command = /* @__PURE__ */ __commonJSMin$2(((exports) => {
22205
22225
  const childProcess$2 = __require("node:child_process");
22206
22226
  const path$16 = __require("node:path");
22207
22227
  const fs$17 = __require("node:fs");
22208
- const process$3 = __require("node:process");
22228
+ const process$2 = __require("node:process");
22209
22229
  const { Argument, humanReadableArgName } = require_argument();
22210
22230
  const { CommanderError } = require_error$1();
22211
22231
  const { Help, stripColor } = require_help();
@@ -22257,13 +22277,13 @@ var require_command = /* @__PURE__ */ __commonJSMin$2(((exports) => {
22257
22277
  this._showSuggestionAfterError = true;
22258
22278
  this._savedState = null;
22259
22279
  this._outputConfiguration = {
22260
- writeOut: (str) => process$3.stdout.write(str),
22261
- writeErr: (str) => process$3.stderr.write(str),
22280
+ writeOut: (str) => process$2.stdout.write(str),
22281
+ writeErr: (str) => process$2.stderr.write(str),
22262
22282
  outputError: (str, write) => write(str),
22263
- getOutHelpWidth: () => process$3.stdout.isTTY ? process$3.stdout.columns : void 0,
22264
- getErrHelpWidth: () => process$3.stderr.isTTY ? process$3.stderr.columns : void 0,
22265
- getOutHasColors: () => useColor() ?? (process$3.stdout.isTTY && process$3.stdout.hasColors?.()),
22266
- getErrHasColors: () => useColor() ?? (process$3.stderr.isTTY && process$3.stderr.hasColors?.()),
22283
+ getOutHelpWidth: () => process$2.stdout.isTTY ? process$2.stdout.columns : void 0,
22284
+ getErrHelpWidth: () => process$2.stderr.isTTY ? process$2.stderr.columns : void 0,
22285
+ getOutHasColors: () => useColor() ?? (process$2.stdout.isTTY && process$2.stdout.hasColors?.()),
22286
+ getErrHasColors: () => useColor() ?? (process$2.stderr.isTTY && process$2.stderr.hasColors?.()),
22267
22287
  stripColor: (str) => stripColor(str)
22268
22288
  };
22269
22289
  this._hidden = false;
@@ -22621,7 +22641,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
22621
22641
  */
22622
22642
  _exit(exitCode, code, message) {
22623
22643
  if (this._exitCallback) this._exitCallback(new CommanderError(exitCode, code, message));
22624
- process$3.exit(exitCode);
22644
+ process$2.exit(exitCode);
22625
22645
  }
22626
22646
  /**
22627
22647
  * Register callback `fn` for the command.
@@ -22960,11 +22980,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
22960
22980
  if (argv !== void 0 && !Array.isArray(argv)) throw new Error("first parameter to parse must be array or undefined");
22961
22981
  parseOptions = parseOptions || {};
22962
22982
  if (argv === void 0 && parseOptions.from === void 0) {
22963
- if (process$3.versions?.electron) parseOptions.from = "electron";
22964
- const execArgv = process$3.execArgv ?? [];
22983
+ if (process$2.versions?.electron) parseOptions.from = "electron";
22984
+ const execArgv = process$2.execArgv ?? [];
22965
22985
  if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) parseOptions.from = "eval";
22966
22986
  }
22967
- if (argv === void 0) argv = process$3.argv;
22987
+ if (argv === void 0) argv = process$2.argv;
22968
22988
  this.rawArgs = argv.slice();
22969
22989
  let userArgs;
22970
22990
  switch (parseOptions.from) {
@@ -22974,7 +22994,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
22974
22994
  userArgs = argv.slice(2);
22975
22995
  break;
22976
22996
  case "electron":
22977
- if (process$3.defaultApp) {
22997
+ if (process$2.defaultApp) {
22978
22998
  this._scriptPath = argv[1];
22979
22999
  userArgs = argv.slice(2);
22980
23000
  } else userArgs = argv.slice(1);
@@ -23139,16 +23159,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
23139
23159
  }
23140
23160
  launchWithNode = sourceExt.includes(path$16.extname(executableFile));
23141
23161
  let proc;
23142
- if (process$3.platform !== "win32") if (launchWithNode) {
23162
+ if (process$2.platform !== "win32") if (launchWithNode) {
23143
23163
  args.unshift(executableFile);
23144
- args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
23145
- proc = childProcess$2.spawn(process$3.argv[0], args, { stdio: "inherit" });
23164
+ args = incrementNodeInspectorPort(process$2.execArgv).concat(args);
23165
+ proc = childProcess$2.spawn(process$2.argv[0], args, { stdio: "inherit" });
23146
23166
  } else proc = childProcess$2.spawn(executableFile, args, { stdio: "inherit" });
23147
23167
  else {
23148
23168
  this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
23149
23169
  args.unshift(executableFile);
23150
- args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
23151
- proc = childProcess$2.spawn(process$3.execPath, args, { stdio: "inherit" });
23170
+ args = incrementNodeInspectorPort(process$2.execArgv).concat(args);
23171
+ proc = childProcess$2.spawn(process$2.execPath, args, { stdio: "inherit" });
23152
23172
  }
23153
23173
  if (!proc.killed) [
23154
23174
  "SIGUSR1",
@@ -23157,20 +23177,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
23157
23177
  "SIGINT",
23158
23178
  "SIGHUP"
23159
23179
  ].forEach((signal) => {
23160
- process$3.on(signal, () => {
23180
+ process$2.on(signal, () => {
23161
23181
  if (proc.killed === false && proc.exitCode === null) proc.kill(signal);
23162
23182
  });
23163
23183
  });
23164
23184
  const exitCallback = this._exitCallback;
23165
23185
  proc.on("close", (code) => {
23166
23186
  code = code ?? 1;
23167
- if (!exitCallback) process$3.exit(code);
23187
+ if (!exitCallback) process$2.exit(code);
23168
23188
  else exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
23169
23189
  });
23170
23190
  proc.on("error", (err) => {
23171
23191
  if (err.code === "ENOENT") this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
23172
23192
  else if (err.code === "EACCES") throw new Error(`'${executableFile}' not executable`);
23173
- if (!exitCallback) process$3.exit(1);
23193
+ if (!exitCallback) process$2.exit(1);
23174
23194
  else {
23175
23195
  const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
23176
23196
  wrappedError.nestedError = err;
@@ -23579,13 +23599,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
23579
23599
  */
23580
23600
  _parseOptionsEnv() {
23581
23601
  this.options.forEach((option) => {
23582
- if (option.envVar && option.envVar in process$3.env) {
23602
+ if (option.envVar && option.envVar in process$2.env) {
23583
23603
  const optionKey = option.attributeName();
23584
23604
  if (this.getOptionValue(optionKey) === void 0 || [
23585
23605
  "default",
23586
23606
  "config",
23587
23607
  "env"
23588
- ].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$3.env[option.envVar]);
23608
+ ].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$2.env[option.envVar]);
23589
23609
  else this.emit(`optionEnv:${option.name()}`);
23590
23610
  }
23591
23611
  });
@@ -24002,7 +24022,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
24002
24022
  */
24003
24023
  help(contextOptions) {
24004
24024
  this.outputHelp(contextOptions);
24005
- let exitCode = Number(process$3.exitCode ?? 0);
24025
+ let exitCode = Number(process$2.exitCode ?? 0);
24006
24026
  if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) exitCode = 1;
24007
24027
  this._exit(exitCode, "commander.help", "(outputHelp)");
24008
24028
  }
@@ -24092,8 +24112,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
24092
24112
  * @package
24093
24113
  */
24094
24114
  function useColor() {
24095
- if (process$3.env.NO_COLOR || process$3.env.FORCE_COLOR === "0" || process$3.env.FORCE_COLOR === "false") return false;
24096
- if (process$3.env.FORCE_COLOR || process$3.env.CLICOLOR_FORCE !== void 0) return true;
24115
+ if (process$2.env.NO_COLOR || process$2.env.FORCE_COLOR === "0" || process$2.env.FORCE_COLOR === "false") return false;
24116
+ if (process$2.env.FORCE_COLOR || process$2.env.CLICOLOR_FORCE !== void 0) return true;
24097
24117
  }
24098
24118
  exports.Command = Command;
24099
24119
  exports.useColor = useColor;
@@ -61920,7 +61940,7 @@ const codexQuotaReadings = (limits, capturedAt) => limits.flatMap((limit) => {
61920
61940
  });
61921
61941
 
61922
61942
  //#endregion
61923
- //#region ../../packages/heterogeneous-agents/src/codex/appServerParams.ts
61943
+ //#region ../../packages/heterogeneous-agents/src/codex/appServerArgs.ts
61924
61944
  const CODEX_DANGEROUS_BYPASS_FLAG = "--dangerously-bypass-approvals-and-sandbox";
61925
61945
  const CODEX_FULL_AUTO_FLAG = "--full-auto";
61926
61946
  const CODEX_APPROVAL_FLAGS = ["-a", "--ask-for-approval"];
@@ -61967,15 +61987,15 @@ const getCodexAppServerUnsupportedArgs = (args, options = {}) => {
61967
61987
  const hasSandboxFlag = args.some((arg) => CODEX_SANDBOX_FLAGS.includes(arg) || getFlagValue(arg, CODEX_SANDBOX_FLAGS) !== void 0);
61968
61988
  for (let index = 0; index < args.length; index += 1) {
61969
61989
  const arg = args[index];
61970
- if (arg === CODEX_DANGEROUS_BYPASS_FLAG) {
61990
+ if (arg === "--dangerously-bypass-approvals-and-sandbox") {
61971
61991
  if (hasSandboxFlag) unsupported.push(arg);
61972
61992
  continue;
61973
61993
  }
61974
- if (arg === CODEX_EPHEMERAL_FLAG) {
61994
+ if (arg === "--ephemeral") {
61975
61995
  if (options.resume) unsupported.push(arg);
61976
61996
  continue;
61977
61997
  }
61978
- if (arg === CODEX_FULL_AUTO_FLAG || arg === CODEX_IGNORE_USER_CONFIG_FLAG) {
61998
+ if (arg === "--full-auto" || arg === "--ignore-user-config") {
61979
61999
  unsupported.push(arg);
61980
62000
  continue;
61981
62001
  }
@@ -62012,6 +62032,9 @@ const getCodexAppServerUnsupportedArgs = (args, options = {}) => {
62012
62032
  }
62013
62033
  return unsupported;
62014
62034
  };
62035
+
62036
+ //#endregion
62037
+ //#region ../../packages/heterogeneous-agents/src/codex/appServerParams.ts
62015
62038
  const buildCodexAppServerThreadParams = (args, cwd, initialModel) => {
62016
62039
  const config = { "features.default_mode_request_user_input": true };
62017
62040
  let effectiveCwd = cwd;
@@ -62022,15 +62045,15 @@ const buildCodexAppServerThreadParams = (args, cwd, initialModel) => {
62022
62045
  let serviceTier;
62023
62046
  for (let index = 0; index < args.length; index += 1) {
62024
62047
  const arg = args[index];
62025
- if (arg === CODEX_DANGEROUS_BYPASS_FLAG) {
62048
+ if (arg === "--dangerously-bypass-approvals-and-sandbox") {
62026
62049
  sandbox = "danger-full-access";
62027
62050
  continue;
62028
62051
  }
62029
- if (arg === CODEX_FULL_AUTO_FLAG) {
62052
+ if (arg === "--full-auto") {
62030
62053
  sandbox = "workspace-write";
62031
62054
  continue;
62032
62055
  }
62033
- if (arg === CODEX_EPHEMERAL_FLAG) {
62056
+ if (arg === "--ephemeral") {
62034
62057
  ephemeral = true;
62035
62058
  continue;
62036
62059
  }
@@ -62518,17 +62541,19 @@ const buildHeterogeneousPrompt = (input) => new HeterogeneousPromptEngine(input)
62518
62541
  *
62519
62542
  * `permissionMode` (Claude Code, Better Coding Experience lab) rides the same
62520
62543
  * envelope for the same reason: an `lh` that predates it unwraps `content` and
62521
- * keeps allowing everything, rather than failing on an unknown flag.
62544
+ * keeps allowing everything, rather than failing on an unknown flag. The
62545
+ * Codex Plan switch (`collaborationMode`) rides it for the same reason.
62522
62546
  */
62523
62547
  const buildHeteroExecStdinPayload = (params) => {
62524
- const { imageList = [], isNewSession, permissionMode, prompt, resumeFallbackSystemContext, systemContext } = params;
62548
+ const { collaborationMode, imageList = [], isNewSession, permissionMode, prompt, resumeFallbackSystemContext, systemContext } = params;
62525
62549
  const blocks = buildHeterogeneousPrompt({
62526
62550
  imageList,
62527
62551
  isNewSession,
62528
62552
  prompt,
62529
62553
  systemContext
62530
62554
  });
62531
- if (resumeFallbackSystemContext !== void 0 || permissionMode) return JSON.stringify({
62555
+ if (resumeFallbackSystemContext !== void 0 || permissionMode || collaborationMode) return JSON.stringify({
62556
+ ...collaborationMode && { collaborationMode },
62532
62557
  content: blocks,
62533
62558
  ...permissionMode && { permissionMode },
62534
62559
  resumeFallback: resumeFallbackSystemContext === void 0 ? void 0 : buildHeterogeneousPrompt({
@@ -64149,6 +64174,13 @@ function splitLines(text) {
64149
64174
  return result;
64150
64175
  }
64151
64176
 
64177
+ //#endregion
64178
+ //#region ../../packages/heterogeneous-agents/src/codexPlanMode/index.ts
64179
+ /** `step_complete` phase carrying what a native Codex run reports about its collaboration mode. */
64180
+ const COLLABORATION_MODE_PHASE = "collaboration_mode";
64181
+ /** Tool api name of a completed Codex plan (`ThreadItem { type: 'plan' }`). */
64182
+ const CODEX_PROPOSED_PLAN_API_NAME = "proposed_plan";
64183
+
64152
64184
  //#endregion
64153
64185
  //#region ../../packages/heterogeneous-agents/src/utils/codexCommandOutput.ts
64154
64186
  const CODEX_COMMAND_OUTPUT_MAX_LENGTH = 25e3;
@@ -64457,6 +64489,8 @@ var CodexAppServerAdapter = class {
64457
64489
  pendingTools = /* @__PURE__ */ new Map();
64458
64490
  streamedAgentText = /* @__PURE__ */ new Map();
64459
64491
  streamedCommandOutput = /* @__PURE__ */ new Map();
64492
+ /** Plan-mode plans (`item/plan/delta`) streamed so far, by item id. */
64493
+ streamedPlans = /* @__PURE__ */ new Map();
64460
64494
  streamedReasoning = /* @__PURE__ */ new Set();
64461
64495
  toolStateSequence = /* @__PURE__ */ new Map();
64462
64496
  stepToolCalls = [];
@@ -64519,6 +64553,7 @@ var CodexAppServerAdapter = class {
64519
64553
  case "item/fileChange/patchUpdated": return this.handleFileChangeUpdate(rawParams);
64520
64554
  case "item/mcpToolCall/progress": return this.handleMcpProgress(rawParams);
64521
64555
  case "turn/plan/updated": return this.handlePlanUpdated(rawParams);
64556
+ case "item/plan/delta": return this.handleProposedPlanDelta(rawParams);
64522
64557
  case "thread/tokenUsage/updated": {
64523
64558
  const { tokenUsage } = rawParams;
64524
64559
  const cumulativeUsage = toUsage(tokenUsage.total);
@@ -64549,6 +64584,7 @@ var CodexAppServerAdapter = class {
64549
64584
  }
64550
64585
  handleItemStarted({ item }) {
64551
64586
  if (item.type === "userMessage") return this.handleSteeredUserMessage(item);
64587
+ if (item.type === "plan") return this.startProposedPlan(item);
64552
64588
  if (!isToolItem(item)) return [];
64553
64589
  const opening = this.openStepAfterSteer();
64554
64590
  this.hasToolActivity = true;
@@ -64595,6 +64631,7 @@ var CodexAppServerAdapter = class {
64595
64631
  }
64596
64632
  return message.text ? this.emitText(message.id, message.text) : [];
64597
64633
  }
64634
+ if (item.type === "plan") return this.completeProposedPlan(item);
64598
64635
  if (item.type === "reasoning") {
64599
64636
  const reasoningItem = item;
64600
64637
  if (this.streamedReasoning.delete(reasoningItem.id)) return [];
@@ -64662,6 +64699,75 @@ var CodexAppServerAdapter = class {
64662
64699
  status: "inProgress"
64663
64700
  })] : [];
64664
64701
  }
64702
+ /**
64703
+ * A plan-mode plan (`ThreadItem { type: 'plan' }`) shows as a `proposed_plan`
64704
+ * tool: `item/plan/delta` only streams its text, the completed item is the
64705
+ * plan of record (Codex does not promise the deltas add up to it).
64706
+ */
64707
+ startProposedPlan(item) {
64708
+ if (this.pendingTools.has(item.id)) return [];
64709
+ const opening = this.openStepAfterSteer();
64710
+ const payload = {
64711
+ apiName: CODEX_PROPOSED_PLAN_API_NAME,
64712
+ arguments: "{}",
64713
+ id: item.id,
64714
+ identifier: CODEX_IDENTIFIER$1,
64715
+ type: "default"
64716
+ };
64717
+ this.hasToolActivity = true;
64718
+ this.pendingTools.set(item.id, payload);
64719
+ this.stepToolCalls.push(payload);
64720
+ this.streamedPlans.set(item.id, item.text ?? "");
64721
+ return [
64722
+ ...opening,
64723
+ this.makeEvent("stream_chunk", {
64724
+ chunkType: "tools_calling",
64725
+ toolsCalling: [...this.stepToolCalls]
64726
+ }),
64727
+ this.makeEvent("tool_start", { toolCallId: item.id })
64728
+ ];
64729
+ }
64730
+ handleProposedPlanDelta(params) {
64731
+ if (!params.delta || !this.pendingTools.has(params.itemId)) return [];
64732
+ const text = `${this.streamedPlans.get(params.itemId) ?? ""}${params.delta}`;
64733
+ this.streamedPlans.set(params.itemId, text);
64734
+ return [this.toolState(params.itemId, { plan: {
64735
+ completed: false,
64736
+ text
64737
+ } })];
64738
+ }
64739
+ completeProposedPlan(item) {
64740
+ this.streamedPlans.delete(item.id);
64741
+ const payload = this.pendingTools.get(item.id) ?? {
64742
+ apiName: "proposed_plan",
64743
+ arguments: "{}",
64744
+ id: item.id,
64745
+ identifier: CODEX_IDENTIFIER$1,
64746
+ type: "default"
64747
+ };
64748
+ const events = this.pendingTools.has(item.id) ? [] : this.startLateTool(payload);
64749
+ this.pendingTools.delete(item.id);
64750
+ const pluginState = { plan: {
64751
+ completed: true,
64752
+ text: item.text
64753
+ } };
64754
+ events.push(this.makeEvent("tool_result", {
64755
+ content: item.text,
64756
+ isError: false,
64757
+ pluginState,
64758
+ toolCallId: item.id
64759
+ }), this.makeEvent("tool_end", {
64760
+ isSuccess: true,
64761
+ payload: { toolCalling: payload },
64762
+ result: {
64763
+ content: item.text,
64764
+ state: pluginState,
64765
+ success: true
64766
+ },
64767
+ toolCallId: item.id
64768
+ }));
64769
+ return events;
64770
+ }
64665
64771
  handlePlanUpdated(params) {
64666
64772
  const id = `turn-plan-${params.turnId}`;
64667
64773
  let foundProcessing = false;
@@ -64980,6 +65086,7 @@ const formatCodexAsyncReplies = (replies) => `<send_user_message_question_reply>
64980
65086
 
64981
65087
  //#endregion
64982
65088
  //#region ../../packages/heterogeneous-agents/src/codex/CodexThreadSession.ts
65089
+ init_src$2();
64983
65090
  init_object$1();
64984
65091
  const CODEX_APP_SERVER_TRANSPORT = "codex-app-server";
64985
65092
  /** An interrupted turn settled within 250 ms in probes; this bounds slow tool teardown. */
@@ -65009,6 +65116,15 @@ var CodexThreadSession = class {
65009
65116
  interruptRequested = false;
65010
65117
  lastOperationId;
65011
65118
  model;
65119
+ effort;
65120
+ /** The mode this run's turns send; a mid-run switch changes it for the next turn. */
65121
+ collaborationMode;
65122
+ /**
65123
+ * Modes sent since the last `turn/start`, oldest first, that Codex has not
65124
+ * acknowledged yet. A `thread/settings/updated` naming one of them answers
65125
+ * that request (and supersedes the older ones), not the latest pick.
65126
+ */
65127
+ pendingModeRequests = [];
65012
65128
  running = false;
65013
65129
  sessionUnsubscribers = [];
65014
65130
  threadId;
@@ -65031,6 +65147,7 @@ var CodexThreadSession = class {
65031
65147
  this.running = true;
65032
65148
  this.interruptRequested = false;
65033
65149
  this.lastOperationId = options.operationId;
65150
+ this.collaborationMode = options.collaborationMode;
65034
65151
  this.emitStatus("starting", options.operationId);
65035
65152
  const traceUnsubscribers = [];
65036
65153
  try {
@@ -65102,9 +65219,12 @@ var CodexThreadSession = class {
65102
65219
  transportInterrupted: false
65103
65220
  };
65104
65221
  this.activeTurn = activeTurn;
65222
+ const collaborationMode = this.collaborationModeParams(this.collaborationMode);
65223
+ this.pendingModeRequests = collaborationMode ? [collaborationMode.mode] : [];
65105
65224
  const turnParams = {
65106
65225
  input,
65107
- threadId
65226
+ threadId,
65227
+ ...collaborationMode && { collaborationMode }
65108
65228
  };
65109
65229
  this.canFallback = false;
65110
65230
  activeTurn.turnId = (await this.options.client.request("turn/start", turnParams))?.turn?.id;
@@ -65193,14 +65313,14 @@ var CodexThreadSession = class {
65193
65313
  this.releaseThread ??= this.options.client.acquireThread(this.threadId);
65194
65314
  const response = this.provenance ? await this.resumeWithShellEnv(this.threadId) : await this.options.client.request("thread/resume", toThreadResumeParams(this.threadId, this.threadParams));
65195
65315
  if (!response || this.closedByHost) return;
65196
- await this.attachThread(response.thread.id, response.model);
65316
+ await this.attachThread(response.thread.id, response.model, response.reasoningEffort);
65197
65317
  return;
65198
65318
  }
65199
65319
  const response = await this.options.client.request("thread/start", this.threadParams);
65200
65320
  if (this.closedByHost) return;
65201
65321
  const threadId = response?.thread?.id;
65202
65322
  if (!threadId) throw new CodexAppServerConnectionError("Codex app-server returned an incompatible thread/start response", { phase: "thread-start" });
65203
- await this.attachThread(threadId, response.model);
65323
+ await this.attachThread(threadId, response.model, response.reasoningEffort);
65204
65324
  if (!this.options.threadParams.ephemeral) {
65205
65325
  await this.setThreadName(threadId);
65206
65326
  this.options.onSessionId(threadId);
@@ -65245,12 +65365,13 @@ var CodexThreadSession = class {
65245
65365
  });
65246
65366
  }
65247
65367
  }
65248
- async attachThread(threadId, model) {
65368
+ async attachThread(threadId, model, effort) {
65249
65369
  this.releaseThread ??= this.options.client.acquireThread(threadId);
65250
65370
  this.threadId = threadId;
65251
65371
  this.attached = true;
65252
65372
  this.canFallback = false;
65253
65373
  if (model) this.updateModel(model);
65374
+ if (effort !== void 0) this.effort = effort;
65254
65375
  if (this.threadUnsubscribers.length > 0) return;
65255
65376
  this.threadUnsubscribers.push(this.options.client.subscribe(threadId, (method, params) => this.enqueueNotification(method, params)), this.options.client.subscribeServerRequests(threadId, (method, params) => {
65256
65377
  if (method === "item/commandExecution/requestApproval" || method === "item/fileChange/requestApproval") return { decision: "cancel" };
@@ -65263,10 +65384,73 @@ var CodexThreadSession = class {
65263
65384
  }
65264
65385
  }));
65265
65386
  }
65387
+ /**
65388
+ * The Plan switch flipped while this run goes: Codex takes the mode from its
65389
+ * next turn (`thread/settings/update` never changes the turn in flight), and
65390
+ * this run's own next turn — a continuation after async answers — sends it too.
65391
+ */
65392
+ async setCollaborationMode(mode) {
65393
+ this.collaborationMode = mode;
65394
+ if (!this.running || !this.attached || !this.threadId || this.closedByHost) return;
65395
+ const collaborationMode = this.collaborationModeParams(mode);
65396
+ if (!collaborationMode) return;
65397
+ this.pendingModeRequests.push(mode);
65398
+ await this.options.client.request("thread/settings/update", {
65399
+ collaborationMode,
65400
+ threadId: this.threadId
65401
+ });
65402
+ }
65403
+ /**
65404
+ * The `collaborationMode` for `mode`, carrying the thread's own model and
65405
+ * effort (`developer_instructions: null` keeps the mode's built-in
65406
+ * instructions; the thread's developer instructions stay in force, verified
65407
+ * on codex-cli 0.169.0). Undefined without a mode, or before the thread
65408
+ * reported its model.
65409
+ */
65410
+ collaborationModeParams(mode) {
65411
+ if (!mode || !this.model) return;
65412
+ return {
65413
+ mode,
65414
+ settings: {
65415
+ developer_instructions: null,
65416
+ model: this.model,
65417
+ reasoning_effort: this.effort ?? null
65418
+ }
65419
+ };
65420
+ }
65421
+ /**
65422
+ * Codex reports the thread's mode after `turn/start` set it, or after a
65423
+ * mid-run switch (it only reports a change). The report carries the request
65424
+ * it answers, so the topic follows Codex only where the two disagree. A
65425
+ * notification naming a pending request acknowledges that one: with Plan
65426
+ * flipped on and back off before Codex answered, its `plan` answers the
65427
+ * first flip and must not read as Codex refusing the second.
65428
+ */
65429
+ handleThreadSettingsUpdated(activeTurn, params) {
65430
+ const mode = params?.threadSettings?.collaborationMode?.mode;
65431
+ if (params?.threadId !== this.threadId || !this.collaborationMode) return Promise.resolve();
65432
+ if (!isCodexCollaborationMode(mode)) return Promise.resolve();
65433
+ const acknowledged = this.pendingModeRequests.indexOf(mode);
65434
+ const requested = acknowledged >= 0 ? mode : this.collaborationMode;
65435
+ if (acknowledged >= 0) this.pendingModeRequests.splice(0, acknowledged + 1);
65436
+ const data = {
65437
+ collaborationMode: mode,
65438
+ phase: COLLABORATION_MODE_PHASE,
65439
+ requested
65440
+ };
65441
+ activeTurn.notificationQueue = activeTurn.notificationQueue.then(() => this.options.onEvents([toStreamEvent({
65442
+ data,
65443
+ stepIndex: 0,
65444
+ timestamp: Date.now(),
65445
+ type: "step_complete"
65446
+ }, activeTurn.operationId)]));
65447
+ return activeTurn.notificationQueue;
65448
+ }
65266
65449
  async handleReconnect(response) {
65267
65450
  if (this.closedByHost) return;
65268
65451
  this.attached = true;
65269
65452
  if (response.model) this.updateModel(response.model);
65453
+ if (response.reasoningEffort !== void 0) this.effort = response.reasoningEffort;
65270
65454
  }
65271
65455
  async requestUserInput(params) {
65272
65456
  const request = parseCodexUserInput(params);
@@ -65313,6 +65497,7 @@ var CodexThreadSession = class {
65313
65497
  enqueueNotification(method, params) {
65314
65498
  const activeTurn = this.activeTurn;
65315
65499
  if (!activeTurn || !this.isCurrentTurnNotification(method, params, activeTurn)) return Promise.resolve();
65500
+ if (method === "thread/settings/updated") return this.handleThreadSettingsUpdated(activeTurn, params);
65316
65501
  if (method === "turn/completed") {
65317
65502
  if (params.turn.status !== "inProgress") {
65318
65503
  activeTurn.terminalNotificationReceived = true;
@@ -65505,6 +65690,7 @@ const createCodexAgentHandle = async (options) => {
65505
65690
  options.onStartupControl?.({ cancel });
65506
65691
  const turnOptions = {
65507
65692
  askUserBridge: options.askUserBridge,
65693
+ collaborationMode: options.collaborationMode,
65508
65694
  input: buildCodexAppServerInput(input),
65509
65695
  onRawMessage: (line) => options.onRawStdout?.(Buffer.from(line)),
65510
65696
  operationId: options.operationId,
@@ -65564,6 +65750,8 @@ const createCodexAgentHandle = async (options) => {
65564
65750
  get sessionId() {
65565
65751
  return nativeSessionId;
65566
65752
  },
65753
+ /** The Plan switch flipped mid-run: Codex takes it from the next turn. */
65754
+ setCollaborationMode: (mode) => session.setCollaborationMode(mode),
65567
65755
  stderr,
65568
65756
  supportsSteerImageAttachments: true
65569
65757
  };
@@ -334872,7 +335060,7 @@ var stdio_exports = /* @__PURE__ */ __exportAll$2({
334872
335060
  function getDefaultEnvironment() {
334873
335061
  const env = {};
334874
335062
  for (const key of DEFAULT_INHERITED_ENV_VARS) {
334875
- const value = process$1.env[key];
335063
+ const value = _w.env[key];
334876
335064
  if (value === void 0) continue;
334877
335065
  if (value.startsWith("()")) continue;
334878
335066
  env[key] = value;
@@ -334883,7 +335071,7 @@ var import_cross_spawn$1, DEFAULT_INHERITED_ENV_VARS, StdioClientTransport;
334883
335071
  var init_stdio = __esmMin((() => {
334884
335072
  init_src_CeKsbNLO();
334885
335073
  import_cross_spawn$1 = /* @__PURE__ */ __toESM$2(require_cross_spawn(), 1);
334886
- DEFAULT_INHERITED_ENV_VARS = process$1.platform === "win32" ? [
335074
+ DEFAULT_INHERITED_ENV_VARS = _w.platform === "win32" ? [
334887
335075
  "APPDATA",
334888
335076
  "COMSPEC",
334889
335077
  "HOMEDRIVE",
@@ -334940,7 +335128,7 @@ var init_stdio = __esmMin((() => {
334940
335128
  this._serverParams.stderr ?? "inherit"
334941
335129
  ],
334942
335130
  shell: false,
334943
- windowsHide: process$1.platform === "win32",
335131
+ windowsHide: _w.platform === "win32",
334944
335132
  cwd: this._serverParams.cwd
334945
335133
  });
334946
335134
  this._process.on("error", (error) => {
@@ -337974,9 +338162,9 @@ const getSubprocessResult = ({ stdout }) => {
337974
338162
  //#region node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/utils/standard-stream.js
337975
338163
  const isStandardStream = (stream) => STANDARD_STREAMS.includes(stream);
337976
338164
  const STANDARD_STREAMS = [
337977
- process$1.stdin,
337978
- process$1.stdout,
337979
- process$1.stderr
338165
+ _w.stdin,
338166
+ _w.stdout,
338167
+ _w.stderr
337980
338168
  ];
337981
338169
  const STANDARD_STREAMS_ALIASES = [
337982
338170
  "stdin",
@@ -338101,9 +338289,9 @@ const NO_ESCAPE_REGEXP = /^[\w./-]+$/;
338101
338289
  //#endregion
338102
338290
  //#region node_modules/.pnpm/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
338103
338291
  function isUnicodeSupported() {
338104
- const { env } = process$1;
338292
+ const { env } = _w;
338105
338293
  const { TERM, TERM_PROGRAM } = env;
338106
- if (process$1.platform !== "win32") return TERM !== "linux";
338294
+ if (_w.platform !== "win32") return TERM !== "linux";
338107
338295
  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";
338108
338296
  }
338109
338297
 
@@ -338638,7 +338826,7 @@ function traversePathUp(startPath) {
338638
338826
 
338639
338827
  //#endregion
338640
338828
  //#region node_modules/.pnpm/npm-run-path@6.0.0/node_modules/npm-run-path/index.js
338641
- const npmRunPath = ({ cwd = process$1.cwd(), path: pathOption = process$1.env[pathKey()], preferLocal = true, execPath = process$1.execPath, addExecPath = true } = {}) => {
338829
+ const npmRunPath = ({ cwd = _w.cwd(), path: pathOption = _w.env[pathKey()], preferLocal = true, execPath = _w.execPath, addExecPath = true } = {}) => {
338642
338830
  const cwdPath = path.resolve(toPath(cwd));
338643
338831
  const result = [];
338644
338832
  const pathParts = pathOption.split(path.delimiter);
@@ -338656,7 +338844,7 @@ const applyExecPath = (result, pathParts, execPath, cwdPath) => {
338656
338844
  const pathPart = path.resolve(cwdPath, toPath(execPath), "..");
338657
338845
  if (!pathParts.includes(pathPart)) result.push(pathPart);
338658
338846
  };
338659
- const npmRunPathEnv = ({ env = process$1.env, ...options } = {}) => {
338847
+ const npmRunPathEnv = ({ env = _w.env, ...options } = {}) => {
338660
338848
  env = { ...env };
338661
338849
  const pathName = pathKey({ env });
338662
338850
  options.path = env[pathName];
@@ -339791,7 +339979,7 @@ const normalizeCwd = (cwd = getDefaultCwd()) => {
339791
339979
  };
339792
339980
  const getDefaultCwd = () => {
339793
339981
  try {
339794
- return process$1.cwd();
339982
+ return _w.cwd();
339795
339983
  } catch (error) {
339796
339984
  error.message = `The current directory does not exist.\n${error.message}`;
339797
339985
  throw error;
@@ -339827,7 +340015,7 @@ const normalizeOptions = (filePath, rawArguments, rawOptions) => {
339827
340015
  options.killSignal = normalizeKillSignal(options.killSignal);
339828
340016
  options.forceKillAfterDelay = normalizeForceKillAfterDelay(options.forceKillAfterDelay);
339829
340017
  options.lines = options.lines.map((lines, fdNumber) => lines && !BINARY_ENCODINGS.has(options.encoding) && options.buffer[fdNumber]);
339830
- if (process$1.platform === "win32" && path.basename(file, ".exe") === "cmd") commandArguments.unshift("/q");
340018
+ if (_w.platform === "win32" && path.basename(file, ".exe") === "cmd") commandArguments.unshift("/q");
339831
340019
  return {
339832
340020
  file,
339833
340021
  commandArguments,
@@ -339854,7 +340042,7 @@ const addDefaultOptions = ({ extendEnv = true, preferLocal = false, cwd, localDi
339854
340042
  });
339855
340043
  const getEnv = ({ env: envOption, extendEnv, preferLocal, node, localDirectory, nodePath }) => {
339856
340044
  const env = extendEnv ? {
339857
- ...process$1.env,
340045
+ ..._w.env,
339858
340046
  ...envOption
339859
340047
  } : envOption;
339860
340048
  if (preferLocal || node) return npmRunPathEnv({
@@ -340856,12 +341044,12 @@ const guessStreamDirection = {
340856
341044
  }
340857
341045
  };
340858
341046
  const getStandardStreamDirection = (value) => {
340859
- if ([0, process$1.stdin].includes(value)) return "input";
341047
+ if ([0, _w.stdin].includes(value)) return "input";
340860
341048
  if ([
340861
341049
  1,
340862
341050
  2,
340863
- process$1.stdout,
340864
- process$1.stderr
341051
+ _w.stdout,
341052
+ _w.stderr
340865
341053
  ].includes(value)) return "output";
340866
341054
  };
340867
341055
  const DEFAULT_DIRECTION = "output";
@@ -341925,9 +342113,9 @@ const addIpcMethods = (subprocess, { ipc }) => {
341925
342113
  Object.assign(subprocess, getIpcMethods(subprocess, false, ipc));
341926
342114
  };
341927
342115
  const getIpcExport = () => {
341928
- const anyProcess = process$1;
342116
+ const anyProcess = _w;
341929
342117
  const isSubprocess = true;
341930
- const ipc = process$1.channel !== void 0;
342118
+ const ipc = _w.channel !== void 0;
341931
342119
  return {
341932
342120
  ...getIpcMethods(anyProcess, isSubprocess, ipc),
341933
342121
  getCancelSignal: getCancelSignal$1.bind(void 0, {
@@ -342404,7 +342592,7 @@ var SignalExitFallback = class extends SignalExitBase {
342404
342592
  };
342405
342593
  var SignalExit = class extends SignalExitBase {
342406
342594
  /* c8 ignore start */
342407
- #hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
342595
+ #hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
342408
342596
  /* c8 ignore stop */
342409
342597
  #emitter = new Emitter();
342410
342598
  #process;
@@ -342499,8 +342687,8 @@ var SignalExit = class extends SignalExitBase {
342499
342687
  } else return og.call(this.#process, ev, ...args);
342500
342688
  }
342501
342689
  };
342502
- const process$2 = globalThis.process;
342503
- const { onExit, load: load$1, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
342690
+ const process$1 = globalThis.process;
342691
+ const { onExit, load: load$1, unload } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
342504
342692
 
342505
342693
  //#endregion
342506
342694
  //#region node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/terminate/cleanup.js
@@ -345566,6 +345754,7 @@ const createFileSearchModule = (toolDetector) => {
345566
345754
  //#endregion
345567
345755
  //#region src/device/systemInfo.ts
345568
345756
  init_resolveCliCommand();
345757
+ init_src$2();
345569
345758
  /**
345570
345759
  * Checks the currently resolved Codex binary without creating a conversation.
345571
345760
  *
@@ -345620,9 +345809,12 @@ async function supportsNativeCodex() {
345620
345809
  client?.close();
345621
345810
  }
345622
345811
  }
345623
- /** Native agent runtimes the resolved binaries support; one handshake per call. */
345812
+ /**
345813
+ * Native agent runtimes the resolved binaries support; one handshake per call.
345814
+ * `codex-collaboration-mode-v1` says this `lh` also takes the Codex Plan switch.
345815
+ */
345624
345816
  async function probeNativeRuntimes() {
345625
- return await supportsNativeCodex() ? ["codex-app-server-v1"] : [];
345817
+ return await supportsNativeCodex() ? ["codex-app-server-v1", CODEX_COLLABORATION_MODE_RUNTIME] : [];
345626
345818
  }
345627
345819
  /**
345628
345820
  * The answer to a gateway `system_info_request`: host paths and live native capabilities.
@@ -555818,6 +556010,7 @@ function startHeteroAgentRun(params, accountEnv, logger) {
555818
556010
  ...extraArgs ?? []
555819
556011
  ];
555820
556012
  const stdinPayload = buildHeteroExecStdinPayload({
556013
+ collaborationMode: params.collaborationMode,
555821
556014
  imageList,
555822
556015
  isNewSession: !resumeSessionId,
555823
556016
  permissionMode: params.permissionMode,
@@ -558194,6 +558387,7 @@ function bindGatewayClientHandlers(client, ctx, connectionWorkspaceId) {
558194
558387
  args: request.args,
558195
558388
  claudeAccountRouting: request.claudeAccountRouting,
558196
558389
  claudeCodeEntrypoint: request.claudeCodeEntrypoint,
558390
+ collaborationMode: request.collaborationMode,
558197
558391
  cwd: request.cwd,
558198
558392
  imageList: request.imageList,
558199
558393
  jwt: request.jwt,
@@ -584996,6 +585190,25 @@ const dispatchHeteroControl = async (message, context) => {
584996
585190
  }
584997
585191
  };
584998
585192
 
585193
+ //#endregion
585194
+ //#region src/utils/heteroCollaborationMode.ts
585195
+ init_src$2();
585196
+ /** The control command the server queues when the Codex Plan switch flips mid-run. */
585197
+ const HETERO_SET_COLLABORATION_MODE_COMMAND = "set_collaboration_mode";
585198
+ /**
585199
+ * Switch a running native Codex thread's collaboration mode (the composer's
585200
+ * Plan switch). Codex takes it from the next turn: `thread/settings/update`
585201
+ * never changes the turn in flight. Reports the mode that was set.
585202
+ */
585203
+ const setCollaborationModeHandler = async ({ params, setCollaborationMode }) => {
585204
+ const mode = params?.mode;
585205
+ if (!isCodexCollaborationMode(mode)) throw new Error("set_collaboration_mode needs a valid mode");
585206
+ if (!setCollaborationMode) throw new Error("This run is not a native Codex thread");
585207
+ await setCollaborationMode(mode);
585208
+ return { mode };
585209
+ };
585210
+ registerHeteroControlHandler(HETERO_SET_COLLABORATION_MODE_COMMAND, setCollaborationModeHandler);
585211
+
584999
585212
  //#endregion
585000
585213
  //#region src/utils/heteroPermissionMode.ts
585001
585214
  init_src$2();
@@ -585092,6 +585305,7 @@ async function* withHeteroSteer(handle, context) {
585092
585305
  }
585093
585306
  const { operationId } = context;
585094
585307
  const sendControlRequest = handle.sendControlRequest;
585308
+ const setCollaborationMode = handle.setCollaborationMode;
585095
585309
  const delivered = /* @__PURE__ */ new Set();
585096
585310
  const abort = new AbortController();
585097
585311
  const handling = /* @__PURE__ */ new Set();
@@ -585122,7 +585336,8 @@ async function* withHeteroSteer(handle, context) {
585122
585336
  log$15.debug("Control %s: %s", control.id, control.command);
585123
585337
  await report(client, control, await dispatchHeteroControl(control, {
585124
585338
  operationId,
585125
- sendControlRequest,
585339
+ sendControlRequest: sendControlRequest ?? (() => void 0),
585340
+ setCollaborationMode,
585126
585341
  signal: abort.signal
585127
585342
  }));
585128
585343
  })().catch((error) => log$15.debug("Control %s failed: %s", control.id, String(error))).finally(() => handling.delete(task));
@@ -585130,7 +585345,7 @@ async function* withHeteroSteer(handle, context) {
585130
585345
  };
585131
585346
  const poll = async () => {
585132
585347
  const client = await context.getTrpcClient();
585133
- const acceptsControl = !!sendControlRequest && !!client.aiAgent.reportHeteroControlResult;
585348
+ const acceptsControl = (!!sendControlRequest || !!setCollaborationMode) && !!client.aiAgent.reportHeteroControlResult;
585134
585349
  while (!abort.signal.aborted) {
585135
585350
  let message;
585136
585351
  try {
@@ -585418,6 +585633,18 @@ const buildExtraArgs = (options) => {
585418
585633
  return extraArgs.length > 0 ? extraArgs : void 0;
585419
585634
  };
585420
585635
 
585636
+ //#endregion
585637
+ //#region src/commands/hetero/dispatchedModes.ts
585638
+ /**
585639
+ * The Better Coding Experience modes the dispatch envelope carried, as spawn
585640
+ * options for the agent they belong to: Claude Code's permission mode, and the
585641
+ * Codex Plan switch (collaboration mode).
585642
+ */
585643
+ const dispatchedModeSpawnOptions = (agentType, resolved) => ({
585644
+ ...agentType === "claude-code" && resolved.permissionMode && { permissionMode: resolved.permissionMode },
585645
+ ...agentType === "codex" && resolved.collaborationMode && { collaborationMode: resolved.collaborationMode }
585646
+ });
585647
+
585421
585648
  //#endregion
585422
585649
  //#region src/commands/hetero/prompt.ts
585423
585650
  init_src$2();
@@ -585467,9 +585694,10 @@ const parseImageArg = (value) => {
585467
585694
  * Accepts:
585468
585695
  * - `'plain text'` → single text block
585469
585696
  * - `[{ type: 'text', text }, { type: 'image', source }]` → content blocks
585470
- * - `{ content: [...], resumeFallback?: [...], permissionMode? }` → unwraps the
585471
- * primary prompt, reserves the fallback for a retry without native resume,
585472
- * and takes the Claude Code permission mode the run was dispatched with
585697
+ * - `{ content: [...], resumeFallback?: [...], permissionMode?, collaborationMode? }`
585698
+ * → unwraps the primary prompt, reserves the fallback for a retry without
585699
+ * native resume, and takes the Claude Code permission mode / Codex Plan
585700
+ * switch the run was dispatched with
585473
585701
  * - `{ type: 'text', ... } | { type: 'image', ... }` → single block
585474
585702
  */
585475
585703
  const coerceJsonPrompt = (parsed) => {
@@ -585479,6 +585707,7 @@ const coerceJsonPrompt = (parsed) => {
585479
585707
  const obj = parsed;
585480
585708
  if (Array.isArray(obj.content)) return {
585481
585709
  ...isHeteroPermissionMode(obj.permissionMode) && { permissionMode: obj.permissionMode },
585710
+ ...isCodexCollaborationMode(obj.collaborationMode) && { collaborationMode: obj.collaborationMode },
585482
585711
  prompt: obj.content,
585483
585712
  ...Array.isArray(obj.resumeFallback) ? { resumeFallbackPrompt: obj.resumeFallback } : {}
585484
585713
  };
@@ -585591,6 +585820,7 @@ const spawnAgentOrRuntime = (spawnOpts, onRawStdout, onStartupControl, nativeCod
585591
585820
  askUserBridge: spawnOpts.askUserBridge,
585592
585821
  clientVersion: cliVersion,
585593
585822
  args: spawnOpts.extraArgs ?? [],
585823
+ collaborationMode: spawnOpts.collaborationMode,
585594
585824
  commandPath: spawnOpts.command,
585595
585825
  cwd: spawnOpts.cwd ?? process.cwd(),
585596
585826
  env: {
@@ -585616,20 +585846,16 @@ const spawnAgentOrRuntime = (spawnOpts, onRawStdout, onStartupControl, nativeCod
585616
585846
  /**
585617
585847
  * Patterns that indicate a `--resume <sessionId>` run should be retried
585618
585848
  * without `--resume`. Two classes of failure:
585619
- *
585620
585849
  * 1. Session file missing (sandbox recycled): the container is ephemeral
585621
585850
  * (~1 h idle TTL), so a new sandbox has an empty `~/.claude/projects/`
585622
585851
  * and the stored session id is stale.
585623
- *
585624
585852
  * 2. Context overflow (long conversation): the resumed session carries all
585625
- * accumulated history; when the combined token count exceeds the model's
585626
- * context window the API rejects the request immediately after CC
585627
- * initialises. Starting fresh (no `--resume`) drops the old history and
585628
- * lets CC respond to the new prompt alone.
585853
+ * accumulated history past the model's context window, so the API rejects
585854
+ * the request right after CC initialises. Starting fresh (no `--resume`)
585855
+ * drops the old history and lets CC respond to the new prompt alone.
585629
585856
  *
585630
- * Checked against:
585631
- * - `error` stream events emitted by the CC adapter from CC's result event
585632
- * - Accumulated stderr output (fallback when CC exits without a result event)
585857
+ * Checked against `error` stream events (from CC's result event) and, when CC
585858
+ * exits without a result event, the accumulated stderr output.
585633
585859
  */
585634
585860
  const RESUME_RETRY_PATTERNS = [
585635
585861
  /no conversation found/i,
@@ -586189,7 +586415,7 @@ const exec = async (options) => {
586189
586415
  initialModel: usesHeterogeneousSessionInitialModel(options.type) ? options.model : void 0,
586190
586416
  liveInput: options.type === "claude-code" || options.type === "antigravity",
586191
586417
  operationId,
586192
- ...options.type === "claude-code" && resolved.permissionMode && { permissionMode: resolved.permissionMode },
586418
+ ...dispatchedModeSpawnOptions(options.type, resolved),
586193
586419
  uploadImage
586194
586420
  };
586195
586421
  const first = await runOneAgent({