@lichao0223/lobehub-cli 0.0.103 → 0.0.104
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 +261 -35
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7986,6 +7986,11 @@ var init_agentExecution = __esmMin((() => {
|
|
|
7986
7986
|
* Experience); the topic's first dispatched run starts in it.
|
|
7987
7987
|
*/
|
|
7988
7988
|
heteroPermissionMode: _enum(HETERO_PERMISSION_MODES).optional(),
|
|
7989
|
+
/**
|
|
7990
|
+
* Codex Plan switch the composer showed (Better Coding Experience); the
|
|
7991
|
+
* topic's first native turn sends `plan` / `default` from it.
|
|
7992
|
+
*/
|
|
7993
|
+
heteroPlanMode: boolean().optional(),
|
|
7989
7994
|
repos: array(string()).optional(),
|
|
7990
7995
|
/**
|
|
7991
7996
|
* Cloud-sandbox placement the composer chose before any topic existed — an
|
|
@@ -11144,6 +11149,11 @@ var init_topic$1 = __esmMin((() => {
|
|
|
11144
11149
|
heteroSessionIdByWorkingDirectory: record(string(), string()).optional(),
|
|
11145
11150
|
heteroPermissionMode: _enum(HETERO_PERMISSION_MODES).optional(),
|
|
11146
11151
|
heteroPermissionModeFallback: _enum(["outdatedCli", "root"]).nullable().optional(),
|
|
11152
|
+
heteroPlanMode: boolean().optional(),
|
|
11153
|
+
codexPlanDecision: object$1({
|
|
11154
|
+
dismissed: boolean(),
|
|
11155
|
+
itemId: string().min(1)
|
|
11156
|
+
}).nullable().optional(),
|
|
11147
11157
|
heteroSpeed: _enum([
|
|
11148
11158
|
"default",
|
|
11149
11159
|
"normal",
|
|
@@ -12423,6 +12433,19 @@ var init_connector = __esmMin((() => {}));
|
|
|
12423
12433
|
//#region ../../packages/types/src/connectorToolIdentifier.ts
|
|
12424
12434
|
var init_connectorToolIdentifier = __esmMin((() => {}));
|
|
12425
12435
|
|
|
12436
|
+
//#endregion
|
|
12437
|
+
//#region ../../packages/types/src/worktreeMode.ts
|
|
12438
|
+
var init_worktreeMode = __esmMin((() => {}));
|
|
12439
|
+
|
|
12440
|
+
//#endregion
|
|
12441
|
+
//#region ../../packages/types/src/heteroPlanMode.ts
|
|
12442
|
+
var CODEX_COLLABORATION_MODES, isCodexCollaborationMode, CODEX_COLLABORATION_MODE_RUNTIME;
|
|
12443
|
+
var init_heteroPlanMode = __esmMin((() => {
|
|
12444
|
+
CODEX_COLLABORATION_MODES = ["plan", "default"];
|
|
12445
|
+
isCodexCollaborationMode = (value) => typeof value === "string" && CODEX_COLLABORATION_MODES.includes(value);
|
|
12446
|
+
CODEX_COLLABORATION_MODE_RUNTIME = "codex-collaboration-mode-v1";
|
|
12447
|
+
}));
|
|
12448
|
+
|
|
12426
12449
|
//#endregion
|
|
12427
12450
|
//#region ../../packages/types/src/inboundWebhook.ts
|
|
12428
12451
|
var GENERIC_WEBHOOK_TOPIC_MODES, GENERIC_WEBHOOK_IDENTIFIER_PATTERN, InboundWebhookChannelDeliverySchema, McpEventsWebhookConfigSchema, McpEventsWebhookStateSchema, McpEventsWebhookVerificationSchema, GenericWebhookConfigSchema, GenericWebhookStateSchema, GenericWebhookVerificationSchema, InboundWebhookDataSchema;
|
|
@@ -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();
|
|
@@ -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/
|
|
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 ===
|
|
61990
|
+
if (arg === "--dangerously-bypass-approvals-and-sandbox") {
|
|
61971
61991
|
if (hasSandboxFlag) unsupported.push(arg);
|
|
61972
61992
|
continue;
|
|
61973
61993
|
}
|
|
61974
|
-
if (arg ===
|
|
61994
|
+
if (arg === "--ephemeral") {
|
|
61975
61995
|
if (options.resume) unsupported.push(arg);
|
|
61976
61996
|
continue;
|
|
61977
61997
|
}
|
|
61978
|
-
if (arg ===
|
|
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 ===
|
|
62048
|
+
if (arg === "--dangerously-bypass-approvals-and-sandbox") {
|
|
62026
62049
|
sandbox = "danger-full-access";
|
|
62027
62050
|
continue;
|
|
62028
62051
|
}
|
|
62029
|
-
if (arg ===
|
|
62052
|
+
if (arg === "--full-auto") {
|
|
62030
62053
|
sandbox = "workspace-write";
|
|
62031
62054
|
continue;
|
|
62032
62055
|
}
|
|
62033
|
-
if (arg ===
|
|
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
|
};
|
|
@@ -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
|
-
/**
|
|
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? }`
|
|
585471
|
-
* primary prompt, reserves the fallback for a retry without
|
|
585472
|
-
* and takes the Claude Code permission mode
|
|
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
|
|
585626
|
-
*
|
|
585627
|
-
*
|
|
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
|
-
*
|
|
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
|
|
586418
|
+
...dispatchedModeSpawnOptions(options.type, resolved),
|
|
586193
586419
|
uploadImage
|
|
586194
586420
|
};
|
|
586195
586421
|
const first = await runOneAgent({
|
package/man/man1/lh.1
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.\" Code generated by `npm run man:generate`; DO NOT EDIT.
|
|
2
2
|
.\" Manual command details come from the Commander command tree.
|
|
3
|
-
.TH LH 1 "" "@lichao0223/lobehub\-cli 0.0.
|
|
3
|
+
.TH LH 1 "" "@lichao0223/lobehub\-cli 0.0.104" "User Commands"
|
|
4
4
|
.SH NAME
|
|
5
5
|
lh \- LobeHub CLI \- manage and connect to LobeHub services
|
|
6
6
|
.SH SYNOPSIS
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lichao0223/lobehub-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.104",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/lichao0223/lobehub",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"access": "public",
|
|
84
84
|
"registry": "https://registry.npmjs.org"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "510c0af3a05c8ab6519c9366b07bf2e782bc7af6"
|
|
87
87
|
}
|