lody 0.72.0 → 0.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{directory-handle-D57OdGy1.js → directory-handle-zGmrHbmq.js} +11 -11
- package/dist/chunks/{index-Cbwwpq6s.js → index-Cuqd9gip.js} +184 -42
- package/dist/chunks/package-C4jJQVT8.js +4133 -0
- package/dist/chunks/{review-viewer-CkoswOhv.js → review-viewer-BTyuDovX.js} +2 -2
- package/dist/chunks/{schemas-CDSDDVK-.js → schemas-BDpQ67Nq.js} +89 -19
- package/dist/claude-acp.js +52 -3465
- package/dist/code-collab-watch-worker.js +102 -36
- package/dist/codex-acp.js +1 -1
- package/dist/file-index-scan-worker.js +2 -2
- package/dist/index.js +7320 -6467
- package/package.json +12 -10
- package/dist/chunks/package-CkkAIS-_.js +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as object, s as string, l as literal, b as boolean, a as _enum, u as union, n as number, d as discriminatedUnion, c as array, r as record,
|
|
1
|
+
import { o as object, s as string, l as literal, b as boolean, a as _enum, u as union, n as number, d as discriminatedUnion, c as array, r as record, I as tuple, e as unknown } from "./schemas-BDpQ67Nq.js";
|
|
2
2
|
import { execFile } from "node:child_process";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import path__default from "node:path";
|
|
@@ -1131,11 +1131,11 @@ async function closeDirectoryQuietly(directory) {
|
|
|
1131
1131
|
}
|
|
1132
1132
|
}
|
|
1133
1133
|
export {
|
|
1134
|
-
|
|
1135
|
-
|
|
1134
|
+
computeAllChanges as A,
|
|
1135
|
+
codeCollabFileIndexStatesEqual as B,
|
|
1136
1136
|
CodeCollabV2OpenTextRequestSchema as C,
|
|
1137
|
-
|
|
1138
|
-
|
|
1137
|
+
scanGitDirectoryEntries as D,
|
|
1138
|
+
closeDirectoryQuietly as E,
|
|
1139
1139
|
joinWorkspacePath as F,
|
|
1140
1140
|
isInsideGitWorktree as G,
|
|
1141
1141
|
pathSegmentComparisonKey as H,
|
|
@@ -1159,10 +1159,10 @@ export {
|
|
|
1159
1159
|
CodeCollabV2ErrorCodeSchema as r,
|
|
1160
1160
|
CodeCollabV2RpcResponseSchema as s,
|
|
1161
1161
|
deriveCodeCollabV2ContentKeyBytes as t,
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1162
|
+
readCodeCollabFileIndexSignalFromFlock as u,
|
|
1163
|
+
writeCodeCollabFileIndexToFlock as v,
|
|
1164
|
+
writeCodeCollabFileIndexSignalToFlock as w,
|
|
1165
|
+
buildCodeCollabFileIndexState as x,
|
|
1166
|
+
CODE_COLLAB_V2_TEXT_LIMITS as y,
|
|
1167
|
+
CODE_COLLAB_V2_ALL_CHANGES_DIFF_LIMITS as z
|
|
1168
1168
|
};
|
|
@@ -20804,6 +20804,16 @@ var ACP_EXT_SESSION_USAGE_UPDATE_METHOD = "_acp_ext:session_usage_update";
|
|
|
20804
20804
|
var ACP_EXT_SESSION_RATE_LIMITS_METHOD = "_acp_ext:session_rate_limits";
|
|
20805
20805
|
var ACP_EXT_CODEX_PROPOSED_PLAN_METHOD = "_acp_ext:codex_proposed_plan";
|
|
20806
20806
|
var CODEX_STEER_APPLIED_METHOD = "_codex/steerApplied";
|
|
20807
|
+
function getLodyForkTurnId(meta3) {
|
|
20808
|
+
if (typeof meta3 !== "object" || meta3 === null) return null;
|
|
20809
|
+
const lody = meta3["lody"];
|
|
20810
|
+
if (typeof lody !== "object" || lody === null) return null;
|
|
20811
|
+
const forkAtTurn = lody["forkAtTurn"];
|
|
20812
|
+
if (typeof forkAtTurn !== "object" || forkAtTurn === null) return null;
|
|
20813
|
+
const version2 = forkAtTurn["version"];
|
|
20814
|
+
const turnId = forkAtTurn["turnId"];
|
|
20815
|
+
return version2 === 1 && typeof turnId === "string" && turnId.length > 0 ? turnId : null;
|
|
20816
|
+
}
|
|
20807
20817
|
var CODEX_STEER_CAPABILITY = {
|
|
20808
20818
|
version: 1,
|
|
20809
20819
|
appliedNotification: CODEX_STEER_APPLIED_METHOD,
|
|
@@ -21720,22 +21730,24 @@ function createFuzzyFileSearchComplete(event) {
|
|
|
21720
21730
|
};
|
|
21721
21731
|
}
|
|
21722
21732
|
function createWebSearchStartUpdate(item) {
|
|
21733
|
+
const { results: _results, ...rawInput } = item;
|
|
21723
21734
|
return {
|
|
21724
21735
|
sessionUpdate: "tool_call",
|
|
21725
21736
|
toolCallId: item.id,
|
|
21726
21737
|
kind: "search",
|
|
21727
21738
|
title: formatWebSearchTitle(item),
|
|
21728
21739
|
status: "in_progress",
|
|
21729
|
-
rawInput
|
|
21740
|
+
rawInput
|
|
21730
21741
|
};
|
|
21731
21742
|
}
|
|
21732
21743
|
function createWebSearchCompleteUpdate(item) {
|
|
21744
|
+
const { results: _results, ...rawInput } = item;
|
|
21733
21745
|
return {
|
|
21734
21746
|
sessionUpdate: "tool_call_update",
|
|
21735
21747
|
toolCallId: item.id,
|
|
21736
21748
|
title: formatWebSearchTitle(item),
|
|
21737
21749
|
status: "completed",
|
|
21738
|
-
rawInput
|
|
21750
|
+
rawInput
|
|
21739
21751
|
};
|
|
21740
21752
|
}
|
|
21741
21753
|
function createCollabAgentToolCallUpdate(item) {
|
|
@@ -22180,6 +22192,12 @@ function createCodexMessagePhaseMeta(phase) {
|
|
|
22180
22192
|
}
|
|
22181
22193
|
return { codex: { phase } };
|
|
22182
22194
|
}
|
|
22195
|
+
function createCodexAgentMessageMeta(phase, turnId) {
|
|
22196
|
+
return {
|
|
22197
|
+
...phase ? { codex: { phase } } : {},
|
|
22198
|
+
lody: { turnId }
|
|
22199
|
+
};
|
|
22200
|
+
}
|
|
22183
22201
|
function createUserMessageChunk(content, messageId, meta3) {
|
|
22184
22202
|
if (messageId) {
|
|
22185
22203
|
return {
|
|
@@ -22346,6 +22364,8 @@ var CodexEventHandler = class {
|
|
|
22346
22364
|
return this.createTerminalInteractionEvent(notification.params);
|
|
22347
22365
|
// ignored events
|
|
22348
22366
|
case "thread/deleted":
|
|
22367
|
+
case "thread/environment/connected":
|
|
22368
|
+
case "thread/environment/disconnected":
|
|
22349
22369
|
case "command/exec/outputDelta":
|
|
22350
22370
|
case "hook/started":
|
|
22351
22371
|
case "hook/completed":
|
|
@@ -22375,6 +22395,7 @@ var CodexEventHandler = class {
|
|
|
22375
22395
|
case "mcpServer/oauthLogin/completed":
|
|
22376
22396
|
case "externalAgentConfig/import/completed":
|
|
22377
22397
|
case "rawResponseItem/completed":
|
|
22398
|
+
case "rawResponse/completed":
|
|
22378
22399
|
case "thread/started":
|
|
22379
22400
|
case "item/plan/delta":
|
|
22380
22401
|
case "remoteControl/status/changed":
|
|
@@ -22487,7 +22508,11 @@ var CodexEventHandler = class {
|
|
|
22487
22508
|
}
|
|
22488
22509
|
async createTextEvent(event) {
|
|
22489
22510
|
const phase = this.agentMessagePhases.get(event.itemId) ?? null;
|
|
22490
|
-
return createAgentTextMessageChunk(
|
|
22511
|
+
return createAgentTextMessageChunk(
|
|
22512
|
+
event.delta,
|
|
22513
|
+
event.itemId,
|
|
22514
|
+
createCodexAgentMessageMeta(phase, event.turnId)
|
|
22515
|
+
);
|
|
22491
22516
|
}
|
|
22492
22517
|
async createConfigWarningEvent(event) {
|
|
22493
22518
|
const detailsText = event.details ? `
|
|
@@ -22892,6 +22917,7 @@ ${event.stdin}
|
|
|
22892
22917
|
secondary: rateLimits.secondary ?? existing.secondary,
|
|
22893
22918
|
credits: rateLimits.credits ?? existing.credits,
|
|
22894
22919
|
individualLimit: rateLimits.individualLimit ?? existing.individualLimit,
|
|
22920
|
+
spendControlReached: rateLimits.spendControlReached ?? existing.spendControlReached,
|
|
22895
22921
|
planType: rateLimits.planType ?? existing.planType,
|
|
22896
22922
|
rateLimitReachedType: rateLimits.rateLimitReachedType ?? existing.rateLimitReachedType
|
|
22897
22923
|
} : rateLimits;
|
|
@@ -24599,7 +24625,7 @@ var package_default = {
|
|
|
24599
24625
|
publishConfig: {
|
|
24600
24626
|
access: "public"
|
|
24601
24627
|
},
|
|
24602
|
-
version: "1.
|
|
24628
|
+
version: "1.3.0",
|
|
24603
24629
|
description: "An ACP-compatible coding agent powered by Codex",
|
|
24604
24630
|
main: "dist/index.js",
|
|
24605
24631
|
bin: {
|
|
@@ -24665,7 +24691,7 @@ var package_default = {
|
|
|
24665
24691
|
},
|
|
24666
24692
|
dependencies: {
|
|
24667
24693
|
"@agentclientprotocol/sdk": "^1.2.1",
|
|
24668
|
-
"@openai/codex": "^0.
|
|
24694
|
+
"@openai/codex": "^0.145.0",
|
|
24669
24695
|
diff: "^9.0.0",
|
|
24670
24696
|
open: "^11.0.0",
|
|
24671
24697
|
"vscode-jsonrpc": "^9.0.1",
|
|
@@ -24673,6 +24699,7 @@ var package_default = {
|
|
|
24673
24699
|
}
|
|
24674
24700
|
};
|
|
24675
24701
|
var CUSTOM_GATEWAY_PROVIDER_ID = "custom-gateway";
|
|
24702
|
+
var SESSION_LIST_PAGE_SIZE = 100;
|
|
24676
24703
|
var SUPPORTED_GATEWAY_PROTOCOLS = {
|
|
24677
24704
|
openai: "responses"
|
|
24678
24705
|
};
|
|
@@ -24910,7 +24937,7 @@ var CodexAcpClient = class {
|
|
|
24910
24937
|
modelProvider: await this.getResumeModelProvider(),
|
|
24911
24938
|
threadId: request.sessionId
|
|
24912
24939
|
});
|
|
24913
|
-
onSubscribed?.();
|
|
24940
|
+
onSubscribed?.(request.sessionId);
|
|
24914
24941
|
const codexModels = await this.fetchAvailableModels();
|
|
24915
24942
|
const currentModelId = this.createModelId(codexModels, response.model, response.reasoningEffort).toString();
|
|
24916
24943
|
return {
|
|
@@ -24922,6 +24949,30 @@ var CodexAcpClient = class {
|
|
|
24922
24949
|
additionalDirectories
|
|
24923
24950
|
};
|
|
24924
24951
|
}
|
|
24952
|
+
async forkSession(request, onSubscribed) {
|
|
24953
|
+
const additionalDirectories = readAdditionalDirectories(request.cwd, request.additionalDirectories, request._meta);
|
|
24954
|
+
await this.refreshSkills(request.cwd, additionalDirectories);
|
|
24955
|
+
const forkTurnId = getLodyForkTurnId(request._meta);
|
|
24956
|
+
const response = await this.codexClient.threadFork({
|
|
24957
|
+
config: await this.createSessionConfig(request.cwd, additionalDirectories, request.mcpServers ?? []),
|
|
24958
|
+
cwd: request.cwd,
|
|
24959
|
+
excludeTurns: true,
|
|
24960
|
+
...forkTurnId ? { lastTurnId: forkTurnId } : {},
|
|
24961
|
+
modelProvider: await this.getResumeModelProvider(),
|
|
24962
|
+
threadId: request.sessionId
|
|
24963
|
+
});
|
|
24964
|
+
onSubscribed?.(response.thread.id);
|
|
24965
|
+
const codexModels = await this.fetchAvailableModels();
|
|
24966
|
+
const currentModelId = this.createModelId(codexModels, response.model, response.reasoningEffort).toString();
|
|
24967
|
+
return {
|
|
24968
|
+
sessionId: response.thread.id,
|
|
24969
|
+
currentModelId,
|
|
24970
|
+
models: codexModels,
|
|
24971
|
+
modelProvider: response.modelProvider,
|
|
24972
|
+
currentServiceTier: response.serviceTier ?? null,
|
|
24973
|
+
additionalDirectories
|
|
24974
|
+
};
|
|
24975
|
+
}
|
|
24925
24976
|
async loadSession(request, onSubscribed) {
|
|
24926
24977
|
const additionalDirectories = readAdditionalDirectories(request.cwd, request.additionalDirectories, request._meta);
|
|
24927
24978
|
await this.refreshSkills(request.cwd, additionalDirectories);
|
|
@@ -24948,7 +24999,7 @@ var CodexAcpClient = class {
|
|
|
24948
24999
|
additionalDirectories
|
|
24949
25000
|
};
|
|
24950
25001
|
}
|
|
24951
|
-
async newSession(request) {
|
|
25002
|
+
async newSession(request, onSubscribed) {
|
|
24952
25003
|
const additionalDirectories = readAdditionalDirectories(request.cwd, request.additionalDirectories, request._meta);
|
|
24953
25004
|
await this.refreshSkills(request.cwd, additionalDirectories);
|
|
24954
25005
|
const response = await this.codexClient.threadStart({
|
|
@@ -24956,6 +25007,7 @@ var CodexAcpClient = class {
|
|
|
24956
25007
|
modelProvider: this.getModelProvider(),
|
|
24957
25008
|
cwd: request.cwd
|
|
24958
25009
|
});
|
|
25010
|
+
onSubscribed?.(response.thread.id);
|
|
24959
25011
|
const codexModels = await this.fetchAvailableModels();
|
|
24960
25012
|
if (codexModels.length === 0) {
|
|
24961
25013
|
throw new Error("Codex did not return any models");
|
|
@@ -25271,8 +25323,12 @@ var CodexAcpClient = class {
|
|
|
25271
25323
|
const modelProviders = preferredProvider ? [preferredProvider] : [];
|
|
25272
25324
|
const listResponse = await this.codexClient.threadList({
|
|
25273
25325
|
cursor: request.cursor ?? null,
|
|
25326
|
+
limit: SESSION_LIST_PAGE_SIZE,
|
|
25327
|
+
sortKey: "updated_at",
|
|
25328
|
+
sortDirection: "desc",
|
|
25274
25329
|
modelProviders,
|
|
25275
|
-
sourceKinds
|
|
25330
|
+
sourceKinds,
|
|
25331
|
+
...requestedCwd && path__default.isAbsolute(requestedCwd) ? { cwd: requestedCwd } : {}
|
|
25276
25332
|
});
|
|
25277
25333
|
const mapThreadToSession = (thread) => ({
|
|
25278
25334
|
sessionId: thread.id,
|
|
@@ -25280,7 +25336,7 @@ var CodexAcpClient = class {
|
|
|
25280
25336
|
title: (thread.name ?? thread.preview) || null,
|
|
25281
25337
|
updatedAt: new Date(thread.updatedAt * 1e3).toISOString()
|
|
25282
25338
|
});
|
|
25283
|
-
if (listResponse.data.length === 0) {
|
|
25339
|
+
if (listResponse.data.length === 0 && !requestedCwd) {
|
|
25284
25340
|
const diagnostics = await this.runSessionListDiagnostics();
|
|
25285
25341
|
logger.log("Session list diagnostics", diagnostics);
|
|
25286
25342
|
}
|
|
@@ -25495,6 +25551,17 @@ var REASONING_EFFORT_CONFIG_ID = "reasoning_effort";
|
|
|
25495
25551
|
function capitalize(value) {
|
|
25496
25552
|
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
25497
25553
|
}
|
|
25554
|
+
var REASONING_EFFORT_DISPLAY_NAMES = {
|
|
25555
|
+
low: "Low",
|
|
25556
|
+
medium: "Medium",
|
|
25557
|
+
high: "High",
|
|
25558
|
+
xhigh: "XHigh",
|
|
25559
|
+
max: "Max",
|
|
25560
|
+
ultra: "Ultra"
|
|
25561
|
+
};
|
|
25562
|
+
function reasoningEffortDisplayName(effort) {
|
|
25563
|
+
return REASONING_EFFORT_DISPLAY_NAMES[effort] ?? capitalize(effort);
|
|
25564
|
+
}
|
|
25498
25565
|
function findSupportedEffort(options, effort) {
|
|
25499
25566
|
if (!effort) return void 0;
|
|
25500
25567
|
return options.find((o) => o.reasoningEffort === effort)?.reasoningEffort;
|
|
@@ -25532,7 +25599,7 @@ function createReasoningEffortConfigOption(supportedReasoningEfforts, currentEff
|
|
|
25532
25599
|
currentValue: currentEffort,
|
|
25533
25600
|
options: supportedReasoningEfforts.map((option) => ({
|
|
25534
25601
|
value: option.reasoningEffort,
|
|
25535
|
-
name:
|
|
25602
|
+
name: reasoningEffortDisplayName(option.reasoningEffort),
|
|
25536
25603
|
description: option.description
|
|
25537
25604
|
}))
|
|
25538
25605
|
};
|
|
@@ -27068,6 +27135,7 @@ var CodexAcpServer = class _CodexAcpServer {
|
|
|
27068
27135
|
},
|
|
27069
27136
|
sessionCapabilities: {
|
|
27070
27137
|
resume: {},
|
|
27138
|
+
fork: {},
|
|
27071
27139
|
list: {},
|
|
27072
27140
|
close: {},
|
|
27073
27141
|
delete: {},
|
|
@@ -27081,6 +27149,9 @@ var CodexAcpServer = class _CodexAcpServer {
|
|
|
27081
27149
|
_meta: {
|
|
27082
27150
|
codex: {
|
|
27083
27151
|
steer: CODEX_STEER_CAPABILITY
|
|
27152
|
+
},
|
|
27153
|
+
lody: {
|
|
27154
|
+
forkAtTurn: { version: 1 }
|
|
27084
27155
|
}
|
|
27085
27156
|
}
|
|
27086
27157
|
},
|
|
@@ -27128,6 +27199,15 @@ var CodexAcpServer = class _CodexAcpServer {
|
|
|
27128
27199
|
throw e;
|
|
27129
27200
|
}
|
|
27130
27201
|
}
|
|
27202
|
+
async getOrForkSession(request) {
|
|
27203
|
+
try {
|
|
27204
|
+
return await this.tryOpenSession({ kind: "fork", request });
|
|
27205
|
+
} catch (e) {
|
|
27206
|
+
const error48 = e instanceof Error ? e : new Error(String(e));
|
|
27207
|
+
await this.handleError(error48);
|
|
27208
|
+
throw e;
|
|
27209
|
+
}
|
|
27210
|
+
}
|
|
27131
27211
|
async handleError(e) {
|
|
27132
27212
|
if (e.message.includes("log out") || e.message.includes("cloud requirements")) {
|
|
27133
27213
|
await this.runWithProcessCheck(() => this.codexAcpClient.logout());
|
|
@@ -27192,47 +27272,93 @@ You have been logged out. Please try again.`);
|
|
|
27192
27272
|
return generation;
|
|
27193
27273
|
}
|
|
27194
27274
|
async tryCreateSession(request) {
|
|
27195
|
-
|
|
27275
|
+
return await this.tryOpenSession("sessionId" in request ? { kind: "resume", request } : { kind: "new", request });
|
|
27276
|
+
}
|
|
27277
|
+
async tryOpenSession(operation) {
|
|
27278
|
+
const { request } = operation;
|
|
27279
|
+
let openedSession = operation.kind === "resume" ? {
|
|
27280
|
+
sessionId: operation.request.sessionId,
|
|
27281
|
+
generation: this.beginSessionOpen(operation.request.sessionId)
|
|
27282
|
+
} : null;
|
|
27283
|
+
let subscribed = false;
|
|
27284
|
+
const onSubscribed = (reportedSessionId) => {
|
|
27285
|
+
const sessionId2 = reportedSessionId ?? (operation.kind === "resume" ? operation.request.sessionId : null);
|
|
27286
|
+
if (!sessionId2) {
|
|
27287
|
+
throw RequestError.internalError("Codex subscribed without reporting a session id");
|
|
27288
|
+
}
|
|
27289
|
+
subscribed = true;
|
|
27290
|
+
if (!openedSession) {
|
|
27291
|
+
openedSession = {
|
|
27292
|
+
sessionId: sessionId2,
|
|
27293
|
+
generation: this.beginSessionOpen(sessionId2)
|
|
27294
|
+
};
|
|
27295
|
+
}
|
|
27296
|
+
};
|
|
27196
27297
|
await this.checkAuthorization();
|
|
27197
27298
|
const requestedMcpServers = request.mcpServers ?? [];
|
|
27198
27299
|
const mcpServerStartupVersion = requestedMcpServers.length > 0 ? this.codexAcpClient.getMcpServerStartupVersion() : null;
|
|
27199
27300
|
let sessionMetadata;
|
|
27200
|
-
|
|
27201
|
-
|
|
27202
|
-
|
|
27203
|
-
|
|
27204
|
-
|
|
27205
|
-
|
|
27206
|
-
|
|
27207
|
-
|
|
27208
|
-
|
|
27209
|
-
|
|
27210
|
-
|
|
27211
|
-
|
|
27212
|
-
|
|
27213
|
-
|
|
27301
|
+
try {
|
|
27302
|
+
switch (operation.kind) {
|
|
27303
|
+
case "new":
|
|
27304
|
+
logger.log("Create new session...");
|
|
27305
|
+
sessionMetadata = await this.runWithProcessCheck(
|
|
27306
|
+
() => this.codexAcpClient.newSession(operation.request, onSubscribed)
|
|
27307
|
+
);
|
|
27308
|
+
break;
|
|
27309
|
+
case "resume":
|
|
27310
|
+
logger.log(`Resume existing session: ${operation.request.sessionId}...`);
|
|
27311
|
+
sessionMetadata = await this.runWithProcessCheck(
|
|
27312
|
+
() => this.codexAcpClient.resumeSession(operation.request, onSubscribed)
|
|
27313
|
+
);
|
|
27314
|
+
break;
|
|
27315
|
+
case "fork":
|
|
27316
|
+
logger.log(`Fork existing session: ${operation.request.sessionId}...`);
|
|
27317
|
+
sessionMetadata = await this.runWithProcessCheck(
|
|
27318
|
+
() => this.codexAcpClient.forkSession(operation.request, onSubscribed)
|
|
27319
|
+
);
|
|
27320
|
+
break;
|
|
27214
27321
|
}
|
|
27215
|
-
}
|
|
27216
|
-
|
|
27217
|
-
|
|
27322
|
+
} catch (err) {
|
|
27323
|
+
if (subscribed && openedSession) {
|
|
27324
|
+
await this.cleanupStaleSessionOpen(openedSession.sessionId, openedSession.generation);
|
|
27325
|
+
}
|
|
27326
|
+
throw err;
|
|
27218
27327
|
}
|
|
27219
27328
|
const { sessionId, currentModelId, models } = sessionMetadata;
|
|
27329
|
+
if (!openedSession) {
|
|
27330
|
+
openedSession = {
|
|
27331
|
+
sessionId,
|
|
27332
|
+
generation: this.beginSessionOpen(sessionId)
|
|
27333
|
+
};
|
|
27334
|
+
} else if (openedSession.sessionId !== sessionId) {
|
|
27335
|
+
if (subscribed) {
|
|
27336
|
+
await this.cleanupStaleSessionOpen(openedSession.sessionId, openedSession.generation);
|
|
27337
|
+
}
|
|
27338
|
+
throw RequestError.internalError(
|
|
27339
|
+
{ expectedSessionId: openedSession?.sessionId, actualSessionId: sessionId },
|
|
27340
|
+
"Codex opened a different session than it reported"
|
|
27341
|
+
);
|
|
27342
|
+
}
|
|
27343
|
+
subscribed = true;
|
|
27220
27344
|
const authProvider = sessionMetadata.modelProvider ?? this.codexAcpClient.getModelProvider();
|
|
27221
27345
|
let authState;
|
|
27222
27346
|
try {
|
|
27223
27347
|
authState = await this.getAuthStateForProvider(authProvider);
|
|
27224
27348
|
} catch (err) {
|
|
27225
|
-
if (
|
|
27226
|
-
await this.cleanupStaleSessionOpen(sessionId,
|
|
27349
|
+
if (subscribed) {
|
|
27350
|
+
await this.cleanupStaleSessionOpen(sessionId, openedSession.generation);
|
|
27227
27351
|
}
|
|
27228
27352
|
throw err;
|
|
27229
27353
|
}
|
|
27230
|
-
|
|
27231
|
-
|
|
27232
|
-
|
|
27233
|
-
await this.closeStaleSessionOpen(sessionId, sessionGeneration);
|
|
27354
|
+
if (!this.sessionOpenCanInstall(sessionId, openedSession.generation)) {
|
|
27355
|
+
subscribed = false;
|
|
27356
|
+
await this.closeStaleSessionOpen(sessionId, openedSession.generation);
|
|
27234
27357
|
}
|
|
27235
|
-
const sessionMcpServers = this.resolveSessionMcpServers(
|
|
27358
|
+
const sessionMcpServers = this.resolveSessionMcpServers(
|
|
27359
|
+
requestedMcpServers,
|
|
27360
|
+
operation.kind !== "new"
|
|
27361
|
+
);
|
|
27236
27362
|
const currentModel = this.findCurrentModel(models, currentModelId);
|
|
27237
27363
|
const currentModelSupportsFast = modelSupportsFast(currentModel);
|
|
27238
27364
|
const sessionState = {
|
|
@@ -27259,11 +27385,11 @@ You have been logged out. Please try again.`);
|
|
|
27259
27385
|
sessionMcpServers,
|
|
27260
27386
|
terminalOutputMode: this.terminalOutputMode,
|
|
27261
27387
|
sessionTitle: null,
|
|
27262
|
-
sessionTitleSource: "
|
|
27388
|
+
sessionTitleSource: operation.kind === "new" ? "unset" : "unknown"
|
|
27263
27389
|
};
|
|
27264
27390
|
this.sessions.set(sessionId, sessionState);
|
|
27265
27391
|
this.publishRateLimitsAsync(sessionState);
|
|
27266
|
-
|
|
27392
|
+
subscribed = false;
|
|
27267
27393
|
if (requestedMcpServers.length > 0 && mcpServerStartupVersion !== null) {
|
|
27268
27394
|
this.pendingMcpStartupSessions.set(sessionId, {
|
|
27269
27395
|
requestedServers: new Set(getRequestedMcpServerNames(requestedMcpServers)),
|
|
@@ -27364,6 +27490,20 @@ You have been logged out. Please try again.`);
|
|
|
27364
27490
|
...this.createSessionConfigOptionsResponse(this.getSessionState(sessionId))
|
|
27365
27491
|
};
|
|
27366
27492
|
}
|
|
27493
|
+
async unstable_forkSession(params) {
|
|
27494
|
+
logger.log("Forking session...", { sessionId: params.sessionId });
|
|
27495
|
+
const [sessionId, , modeState, availableCommands] = await this.getOrForkSession(params);
|
|
27496
|
+
this.publishAvailableCommandsAsync(sessionId, availableCommands);
|
|
27497
|
+
logger.log("Session forked", {
|
|
27498
|
+
sourceSessionId: params.sessionId,
|
|
27499
|
+
sessionId
|
|
27500
|
+
});
|
|
27501
|
+
return {
|
|
27502
|
+
sessionId,
|
|
27503
|
+
modes: modeState,
|
|
27504
|
+
...this.createSessionConfigOptionsResponse(this.getSessionState(sessionId))
|
|
27505
|
+
};
|
|
27506
|
+
}
|
|
27367
27507
|
async listSessions(params) {
|
|
27368
27508
|
logger.log("Listing sessions...", { cwd: params.cwd, cursor: params.cursor });
|
|
27369
27509
|
await this.checkAuthorization();
|
|
@@ -27794,7 +27934,7 @@ You have been logged out. Please try again.`);
|
|
|
27794
27934
|
const threadUpdates = [];
|
|
27795
27935
|
for (const turn of thread.turns) {
|
|
27796
27936
|
for (const item of turn.items) {
|
|
27797
|
-
const updates2 = await this.createHistoryUpdates(item, sessionState);
|
|
27937
|
+
const updates2 = await this.createHistoryUpdates(item, sessionState, turn.id);
|
|
27798
27938
|
threadUpdates.push(...updates2);
|
|
27799
27939
|
}
|
|
27800
27940
|
}
|
|
@@ -27844,7 +27984,7 @@ You have been logged out. Please try again.`);
|
|
|
27844
27984
|
const normalized = title?.replace(/\s+/g, " ").trim() ?? "";
|
|
27845
27985
|
return normalized.length > 0 ? normalized : null;
|
|
27846
27986
|
}
|
|
27847
|
-
async createHistoryUpdates(item, sessionState) {
|
|
27987
|
+
async createHistoryUpdates(item, sessionState, turnId) {
|
|
27848
27988
|
switch (item.type) {
|
|
27849
27989
|
case "userMessage":
|
|
27850
27990
|
return this.createUserMessageUpdates(item);
|
|
@@ -27853,12 +27993,11 @@ You have been logged out. Please try again.`);
|
|
|
27853
27993
|
case "sleep":
|
|
27854
27994
|
return [];
|
|
27855
27995
|
case "agentMessage": {
|
|
27856
|
-
const meta3 = createCodexMessagePhaseMeta(item.phase);
|
|
27857
27996
|
return [{
|
|
27858
27997
|
sessionUpdate: "agent_message_chunk",
|
|
27859
27998
|
messageId: item.id,
|
|
27860
27999
|
content: { type: "text", text: item.text },
|
|
27861
|
-
|
|
28000
|
+
_meta: createCodexAgentMessageMeta(item.phase, turnId)
|
|
27862
28001
|
}];
|
|
27863
28002
|
}
|
|
27864
28003
|
case "reasoning":
|
|
@@ -28946,6 +29085,9 @@ var CodexAppServerClient = class {
|
|
|
28946
29085
|
async threadResume(params) {
|
|
28947
29086
|
return await this.sendRequest({ method: "thread/resume", params });
|
|
28948
29087
|
}
|
|
29088
|
+
async threadFork(params) {
|
|
29089
|
+
return await this.sendRequest({ method: "thread/fork", params });
|
|
29090
|
+
}
|
|
28949
29091
|
async threadList(params) {
|
|
28950
29092
|
return await this.sendRequest({ method: "thread/list", params });
|
|
28951
29093
|
}
|
|
@@ -29562,5 +29704,5 @@ function startAcpServer() {
|
|
|
29562
29704
|
codexAcpServer = null;
|
|
29563
29705
|
}
|
|
29564
29706
|
});
|
|
29565
|
-
}).onRequest(methods.agent.initialize, (ctx) => getAgent().initialize(ctx.params)).onRequest(methods.agent.session.new, (ctx) => getAgent().newSession(ctx.params)).onRequest(methods.agent.session.load, (ctx) => getAgent().loadSession(ctx.params)).onRequest(methods.agent.session.list, (ctx) => getAgent().listSessions(ctx.params)).onRequest(methods.agent.session.delete, (ctx) => getAgent().deleteSession(ctx.params)).onRequest(methods.agent.session.resume, (ctx) => getAgent().resumeSession(ctx.params)).onRequest(methods.agent.session.close, (ctx) => getAgent().closeSession(ctx.params)).onRequest(methods.agent.session.setMode, (ctx) => getAgent().setSessionMode(ctx.params)).onRequest(methods.agent.session.setConfigOption, (ctx) => getAgent().setSessionConfigOption(ctx.params)).onRequest(methods.agent.authenticate, (ctx) => getAgent().authenticate(ctx.params)).onRequest(methods.agent.logout, (ctx) => getAgent().logout(ctx.params)).onRequest(methods.agent.providers.list, (ctx) => getAgent().listProviders(ctx.params)).onRequest(methods.agent.providers.set, (ctx) => getAgent().setProvider(ctx.params)).onRequest(methods.agent.providers.disable, (ctx) => getAgent().disableProvider(ctx.params)).onRequest(methods.agent.session.prompt, (ctx) => getAgent().prompt(ctx.params, ctx.signal)).onNotification(methods.agent.session.cancel, (ctx) => getAgent().cancel(ctx.params)).onRequest("authentication/status", emptyExtensionParamsParser, (ctx) => getAgent().extMethod("authentication/status", ctx.params)).onRequest("authentication/logout", emptyExtensionParamsParser, (ctx) => getAgent().extMethod("authentication/logout", ctx.params)).onRequest(LEGACY_SET_SESSION_MODEL_METHOD, legacySetSessionModelParamsParser, (ctx) => getAgent().extMethod(LEGACY_SET_SESSION_MODEL_METHOD, ctx.params)).connect(acpJsonStream);
|
|
29707
|
+
}).onRequest(methods.agent.initialize, (ctx) => getAgent().initialize(ctx.params)).onRequest(methods.agent.session.new, (ctx) => getAgent().newSession(ctx.params)).onRequest(methods.agent.session.load, (ctx) => getAgent().loadSession(ctx.params)).onRequest(methods.agent.session.fork, (ctx) => getAgent().unstable_forkSession(ctx.params)).onRequest(methods.agent.session.list, (ctx) => getAgent().listSessions(ctx.params)).onRequest(methods.agent.session.delete, (ctx) => getAgent().deleteSession(ctx.params)).onRequest(methods.agent.session.resume, (ctx) => getAgent().resumeSession(ctx.params)).onRequest(methods.agent.session.close, (ctx) => getAgent().closeSession(ctx.params)).onRequest(methods.agent.session.setMode, (ctx) => getAgent().setSessionMode(ctx.params)).onRequest(methods.agent.session.setConfigOption, (ctx) => getAgent().setSessionConfigOption(ctx.params)).onRequest(methods.agent.authenticate, (ctx) => getAgent().authenticate(ctx.params)).onRequest(methods.agent.logout, (ctx) => getAgent().logout(ctx.params)).onRequest(methods.agent.providers.list, (ctx) => getAgent().listProviders(ctx.params)).onRequest(methods.agent.providers.set, (ctx) => getAgent().setProvider(ctx.params)).onRequest(methods.agent.providers.disable, (ctx) => getAgent().disableProvider(ctx.params)).onRequest(methods.agent.session.prompt, (ctx) => getAgent().prompt(ctx.params, ctx.signal)).onNotification(methods.agent.session.cancel, (ctx) => getAgent().cancel(ctx.params)).onRequest("authentication/status", emptyExtensionParamsParser, (ctx) => getAgent().extMethod("authentication/status", ctx.params)).onRequest("authentication/logout", emptyExtensionParamsParser, (ctx) => getAgent().extMethod("authentication/logout", ctx.params)).onRequest(LEGACY_SET_SESSION_MODEL_METHOD, legacySetSessionModelParamsParser, (ctx) => getAgent().extMethod(LEGACY_SET_SESSION_MODEL_METHOD, ctx.params)).connect(acpJsonStream);
|
|
29566
29708
|
}
|