@agentclientprotocol/codex-acp 2.5.1-preview.10 → 2.5.1-preview.12
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 +201 -40
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31968,6 +31968,9 @@ var AIR_CUSTOM_ANSWER_KEY = "customAnswer";
|
|
|
31968
31968
|
var LEGACY_AIR_CUSTOM_ANSWER_KEY = "_askUserQuestionCustomAnswer";
|
|
31969
31969
|
var AIR_EXTENSION_VERSION = 1;
|
|
31970
31970
|
function withAirMeta(meta3, key, value) {
|
|
31971
|
+
return withAirMetadata(meta3, { [key]: value });
|
|
31972
|
+
}
|
|
31973
|
+
function withAirMetadata(meta3, fields) {
|
|
31971
31974
|
const root = asRecord(meta3);
|
|
31972
31975
|
const jetbrains = asRecord(root[JETBRAINS_META_KEY]);
|
|
31973
31976
|
const air = asRecord(jetbrains[AIR_META_KEY]);
|
|
@@ -31978,11 +31981,19 @@ function withAirMeta(meta3, key, value) {
|
|
|
31978
31981
|
[AIR_META_KEY]: {
|
|
31979
31982
|
...air,
|
|
31980
31983
|
[AIR_EXTENSION_VERSION_KEY]: AIR_EXTENSION_VERSION,
|
|
31981
|
-
|
|
31984
|
+
...fields
|
|
31982
31985
|
}
|
|
31983
31986
|
}
|
|
31984
31987
|
};
|
|
31985
31988
|
}
|
|
31989
|
+
function publishAirSessionMetadata(session, key, value) {
|
|
31990
|
+
if (session.protocolVersion === 2) {
|
|
31991
|
+
return session.patchSessionMetadata((current) => ({
|
|
31992
|
+
[JETBRAINS_META_KEY]: withAirMeta(current, key, value)[JETBRAINS_META_KEY]
|
|
31993
|
+
}));
|
|
31994
|
+
}
|
|
31995
|
+
return session.update({ sessionUpdate: "session_info_update", _meta: withAirMeta(void 0, key, value) });
|
|
31996
|
+
}
|
|
31986
31997
|
function airOnlyMeta(airClient, key, value) {
|
|
31987
31998
|
return airClient ? withAirMeta(void 0, key, value) : void 0;
|
|
31988
31999
|
}
|
|
@@ -32216,6 +32227,77 @@ function normalizeJsonObject(value) {
|
|
|
32216
32227
|
);
|
|
32217
32228
|
}
|
|
32218
32229
|
|
|
32230
|
+
// src/AcpV2SessionInfo.ts
|
|
32231
|
+
var AcpV2SessionInfo = class {
|
|
32232
|
+
constructor(send, initialMetadata = null) {
|
|
32233
|
+
this.send = send;
|
|
32234
|
+
this.applyMetadata(JSON.parse(JSON.stringify({ _meta: initialMetadata }))._meta);
|
|
32235
|
+
}
|
|
32236
|
+
send;
|
|
32237
|
+
metadata = /* @__PURE__ */ new Map();
|
|
32238
|
+
tail = Promise.resolve();
|
|
32239
|
+
disposed = false;
|
|
32240
|
+
update(update, notificationMetadata) {
|
|
32241
|
+
let copy;
|
|
32242
|
+
try {
|
|
32243
|
+
copy = JSON.parse(JSON.stringify({ update, _meta: notificationMetadata }));
|
|
32244
|
+
} catch (error62) {
|
|
32245
|
+
return Promise.reject(error62);
|
|
32246
|
+
}
|
|
32247
|
+
return this.enqueue(async () => {
|
|
32248
|
+
this.applyMetadata(copy.update._meta);
|
|
32249
|
+
await this.publish(copy.update, copy._meta);
|
|
32250
|
+
});
|
|
32251
|
+
}
|
|
32252
|
+
patchMetadata(change, fields = {}) {
|
|
32253
|
+
const copy = JSON.parse(JSON.stringify(fields));
|
|
32254
|
+
return this.enqueue(async () => {
|
|
32255
|
+
const current = JSON.parse(JSON.stringify(Object.fromEntries(this.metadata)));
|
|
32256
|
+
const patch = change(current);
|
|
32257
|
+
if (patch === null) return;
|
|
32258
|
+
const update = JSON.parse(JSON.stringify({ ...copy, sessionUpdate: "session_info_update", _meta: patch }));
|
|
32259
|
+
this.applyMetadata(update._meta);
|
|
32260
|
+
await this.publish(update);
|
|
32261
|
+
});
|
|
32262
|
+
}
|
|
32263
|
+
seedMetadata(metadata) {
|
|
32264
|
+
const copy = JSON.parse(JSON.stringify({ _meta: metadata }))._meta;
|
|
32265
|
+
return this.enqueue(async () => {
|
|
32266
|
+
this.applyMetadata(copy);
|
|
32267
|
+
});
|
|
32268
|
+
}
|
|
32269
|
+
snapshot(title) {
|
|
32270
|
+
return this.enqueue(async () => {
|
|
32271
|
+
await this.publish({ sessionUpdate: "session_info_update", title, _meta: null });
|
|
32272
|
+
if (this.metadata.size > 0) {
|
|
32273
|
+
await this.publish({ sessionUpdate: "session_info_update", _meta: Object.fromEntries(this.metadata) });
|
|
32274
|
+
}
|
|
32275
|
+
});
|
|
32276
|
+
}
|
|
32277
|
+
dispose() {
|
|
32278
|
+
this.disposed = true;
|
|
32279
|
+
this.metadata.clear();
|
|
32280
|
+
}
|
|
32281
|
+
applyMetadata(patch) {
|
|
32282
|
+
if (patch === null) this.metadata.clear();
|
|
32283
|
+
else if (isRecord2(patch)) for (const [key, value] of Object.entries(patch)) {
|
|
32284
|
+
if (value === null) this.metadata.delete(key);
|
|
32285
|
+
else this.metadata.set(key, value);
|
|
32286
|
+
}
|
|
32287
|
+
}
|
|
32288
|
+
enqueue(operation) {
|
|
32289
|
+
const next = this.tail.then(async () => {
|
|
32290
|
+
if (!this.disposed) await operation();
|
|
32291
|
+
});
|
|
32292
|
+
this.tail = next.catch(() => {
|
|
32293
|
+
});
|
|
32294
|
+
return next;
|
|
32295
|
+
}
|
|
32296
|
+
publish(update, notificationMetadata) {
|
|
32297
|
+
return this.disposed ? Promise.resolve() : this.send(update, notificationMetadata);
|
|
32298
|
+
}
|
|
32299
|
+
};
|
|
32300
|
+
|
|
32219
32301
|
// src/JsonSnapshot.ts
|
|
32220
32302
|
import { types } from "node:util";
|
|
32221
32303
|
var JsonObject = class {
|
|
@@ -32773,6 +32855,10 @@ var AcpV2Connection = class {
|
|
|
32773
32855
|
if (method === methods2.client.elicitation.complete) return this.sendElicitationCompletion(params);
|
|
32774
32856
|
const sessionId = clientNotificationSessionId(method, params);
|
|
32775
32857
|
if (sessionId !== null && this.sessionDelivery && !this.sessionDelivery.canPublishSession(sessionId)) return Promise.resolve();
|
|
32858
|
+
if (sessionId !== null) {
|
|
32859
|
+
const { update, _meta } = params;
|
|
32860
|
+
if (SessionUpdate.isSessionInfoUpdate(update)) return this.sessionInfoFor(sessionId).update(update, _meta);
|
|
32861
|
+
}
|
|
32776
32862
|
return client.notify(method, params);
|
|
32777
32863
|
},
|
|
32778
32864
|
request: (method, params, options) => {
|
|
@@ -32793,6 +32879,7 @@ var AcpV2Connection = class {
|
|
|
32793
32879
|
client;
|
|
32794
32880
|
isTurnRunning = () => true;
|
|
32795
32881
|
foreground = /* @__PURE__ */ new Map();
|
|
32882
|
+
sessionInfo = /* @__PURE__ */ new Map();
|
|
32796
32883
|
sessionDelivery = null;
|
|
32797
32884
|
sendElicitationCompletion;
|
|
32798
32885
|
setClientDelivery(delivery) {
|
|
@@ -32817,9 +32904,12 @@ var AcpV2Connection = class {
|
|
|
32817
32904
|
* Sends a session update, rendered in the v2 wire shape, through the v2 `session/update`
|
|
32818
32905
|
* binding. One update can render to several v2 updates (or none), sent in order.
|
|
32819
32906
|
*/
|
|
32820
|
-
async updateSession(sessionId, update) {
|
|
32907
|
+
async updateSession(sessionId, update, metadata) {
|
|
32821
32908
|
for (const v2Update of toV2SessionUpdates(update)) {
|
|
32822
|
-
await this.client.notify(
|
|
32909
|
+
await this.client.notify(
|
|
32910
|
+
methods2.client.session.update,
|
|
32911
|
+
{ sessionId, update: v2Update, ...metadata !== void 0 ? { _meta: metadata } : {} }
|
|
32912
|
+
);
|
|
32823
32913
|
}
|
|
32824
32914
|
}
|
|
32825
32915
|
/** Sends a `state_update`, which only exists on v2 and so needs no rendering. */
|
|
@@ -32832,6 +32922,20 @@ var AcpV2Connection = class {
|
|
|
32832
32922
|
snapshotForegroundState(sessionId) {
|
|
32833
32923
|
return this.foregroundFor(sessionId).snapshot();
|
|
32834
32924
|
}
|
|
32925
|
+
resetSessionInfo(sessionId, metadata) {
|
|
32926
|
+
this.sessionInfo.get(sessionId)?.dispose();
|
|
32927
|
+
this.sessionInfo.delete(sessionId);
|
|
32928
|
+
this.sessionInfoFor(sessionId, metadata);
|
|
32929
|
+
}
|
|
32930
|
+
refreshSessionInfo(sessionId, metadata) {
|
|
32931
|
+
return metadata ? this.sessionInfoFor(sessionId).seedMetadata(metadata) : Promise.resolve();
|
|
32932
|
+
}
|
|
32933
|
+
snapshotSessionInfo(sessionId, title) {
|
|
32934
|
+
return this.sessionInfoFor(sessionId).snapshot(title);
|
|
32935
|
+
}
|
|
32936
|
+
patchSessionMetadata(sessionId, change, fields = {}) {
|
|
32937
|
+
return this.sessionInfoFor(sessionId).patchMetadata(change, fields);
|
|
32938
|
+
}
|
|
32835
32939
|
startForegroundItem(sessionId, itemId) {
|
|
32836
32940
|
return this.foregroundFor(sessionId).startItem(itemId);
|
|
32837
32941
|
}
|
|
@@ -32842,9 +32946,34 @@ var AcpV2Connection = class {
|
|
|
32842
32946
|
this.foregroundFor(sessionId, running);
|
|
32843
32947
|
}
|
|
32844
32948
|
forgetSession(sessionId) {
|
|
32949
|
+
this.forgetForegroundState(sessionId);
|
|
32950
|
+
this.sessionInfo.get(sessionId)?.dispose();
|
|
32951
|
+
this.sessionInfo.delete(sessionId);
|
|
32952
|
+
}
|
|
32953
|
+
forgetForegroundState(sessionId) {
|
|
32845
32954
|
this.foreground.get(sessionId)?.dispose();
|
|
32846
32955
|
this.foreground.delete(sessionId);
|
|
32847
32956
|
}
|
|
32957
|
+
sessionInfoFor(sessionId, metadata = null) {
|
|
32958
|
+
if (this.sessionDelivery && !this.sessionDelivery.canPublishSession(sessionId)) {
|
|
32959
|
+
const closed = new AcpV2SessionInfo(async () => {
|
|
32960
|
+
});
|
|
32961
|
+
closed.dispose();
|
|
32962
|
+
return closed;
|
|
32963
|
+
}
|
|
32964
|
+
let info = this.sessionInfo.get(sessionId);
|
|
32965
|
+
if (!info) {
|
|
32966
|
+
info = new AcpV2SessionInfo((update, notificationMetadata) => {
|
|
32967
|
+
if (this.sessionDelivery && !this.sessionDelivery.canPublishSession(sessionId)) return Promise.resolve();
|
|
32968
|
+
return this.transportClient.notify(
|
|
32969
|
+
methods2.client.session.update,
|
|
32970
|
+
{ sessionId, update, ...notificationMetadata !== void 0 ? { _meta: notificationMetadata } : {} }
|
|
32971
|
+
);
|
|
32972
|
+
}, metadata);
|
|
32973
|
+
this.sessionInfo.set(sessionId, info);
|
|
32974
|
+
}
|
|
32975
|
+
return info;
|
|
32976
|
+
}
|
|
32848
32977
|
foregroundFor(sessionId, running = false) {
|
|
32849
32978
|
if (this.sessionDelivery && !this.sessionDelivery.canPublishSession(sessionId)) {
|
|
32850
32979
|
const closed = new AcpV2ForegroundState(async () => {
|
|
@@ -32934,7 +33063,7 @@ var AcpV2Connection = class {
|
|
|
32934
33063
|
}
|
|
32935
33064
|
if (method === methods.client.session.update) {
|
|
32936
33065
|
const notification = params;
|
|
32937
|
-
return this.updateSession(notification.sessionId, notification.update);
|
|
33066
|
+
return this.updateSession(notification.sessionId, notification.update, notification._meta);
|
|
32938
33067
|
}
|
|
32939
33068
|
if (method === methods.client.elicitation.complete) {
|
|
32940
33069
|
return this.completeElicitation(params);
|
|
@@ -33003,6 +33132,10 @@ var ACPSessionConnection = class _ACPSessionConnection {
|
|
|
33003
33132
|
forSession(sessionId) {
|
|
33004
33133
|
return new _ACPSessionConnection(this.connection, sessionId);
|
|
33005
33134
|
}
|
|
33135
|
+
/** Domain writers can rebuild an owned metadata value without changing v2's shallow patch semantics. */
|
|
33136
|
+
patchSessionMetadata(change, fields = {}) {
|
|
33137
|
+
return this.v2Connection?.patchSessionMetadata(this.sessionId, change, fields) ?? Promise.resolve();
|
|
33138
|
+
}
|
|
33006
33139
|
/** Replay shares live report filtering, with v2 entity initialization after conversion. */
|
|
33007
33140
|
replayUpdate(update, initialized) {
|
|
33008
33141
|
return this.v2Connection ? this.v2Connection.replaySessionUpdate(this.sessionId, update, initialized) : this.update(update);
|
|
@@ -35185,6 +35318,9 @@ function goalSessionInfoUpdate(goal, airClient) {
|
|
|
35185
35318
|
_meta: withAirMeta(void 0, AIR_GOAL_KEY, goal)
|
|
35186
35319
|
};
|
|
35187
35320
|
}
|
|
35321
|
+
function publishGoalSessionInfo(session, goal, airClient) {
|
|
35322
|
+
return airClient ? publishAirSessionMetadata(session, AIR_GOAL_KEY, goal) : Promise.resolve();
|
|
35323
|
+
}
|
|
35188
35324
|
|
|
35189
35325
|
// src/tool-calls/ClientCapabilities.ts
|
|
35190
35326
|
var ClientCapabilities = class _ClientCapabilities {
|
|
@@ -37730,7 +37866,7 @@ ${diff}`, "");
|
|
|
37730
37866
|
await this.finishCompactionsForNotification(notification);
|
|
37731
37867
|
if (this.isAuthenticationRequiredError(notification.params.error.codexErrorInfo)) return;
|
|
37732
37868
|
if (notification.params.willRetry) {
|
|
37733
|
-
await this.
|
|
37869
|
+
await this.publishUpdate(this.createSessionFailureUpdate(this.recordRetryWarning(notification.params, false)));
|
|
37734
37870
|
return;
|
|
37735
37871
|
}
|
|
37736
37872
|
const failure3 = this.recordSessionFailure(
|
|
@@ -37741,7 +37877,7 @@ ${diff}`, "");
|
|
|
37741
37877
|
void 0,
|
|
37742
37878
|
false
|
|
37743
37879
|
);
|
|
37744
|
-
await this.
|
|
37880
|
+
await this.publishUpdate(this.createSessionFailureUpdate(failure3));
|
|
37745
37881
|
}
|
|
37746
37882
|
async flushPendingErrors() {
|
|
37747
37883
|
if (this.sessionState.currentTurnId === null || this.pendingErrors.length === 0) {
|
|
@@ -37751,7 +37887,7 @@ ${diff}`, "");
|
|
|
37751
37887
|
for (const error62 of errors) {
|
|
37752
37888
|
const update = await this.createErrorEvent(error62);
|
|
37753
37889
|
if (update) {
|
|
37754
|
-
await this.
|
|
37890
|
+
await this.publishUpdate(update);
|
|
37755
37891
|
}
|
|
37756
37892
|
}
|
|
37757
37893
|
}
|
|
@@ -37765,7 +37901,17 @@ ${diff}`, "");
|
|
|
37765
37901
|
}
|
|
37766
37902
|
}
|
|
37767
37903
|
async clearSessionFailure() {
|
|
37904
|
+
const failure3 = this.sessionState.sessionFailure;
|
|
37768
37905
|
delete this.sessionState.sessionFailure;
|
|
37906
|
+
if (!failure3 || this.session.protocolVersion !== 2) return;
|
|
37907
|
+
await this.session.patchSessionMetadata((metadata) => {
|
|
37908
|
+
const jetbrains = recordOrNull(metadata[JETBRAINS_META_KEY]);
|
|
37909
|
+
const air = recordOrNull(jetbrains?.[AIR_META_KEY]);
|
|
37910
|
+
const published = recordOrNull(air?.[AIR_SESSION_FAILURE_KEY]);
|
|
37911
|
+
if (!air || published?.["id"] !== failure3.id || published?.["revision"] !== failure3.revision) return null;
|
|
37912
|
+
const { [AIR_SESSION_FAILURE_KEY]: _failure, ...currentAir } = air;
|
|
37913
|
+
return { [JETBRAINS_META_KEY]: { ...jetbrains, [AIR_META_KEY]: currentAir } };
|
|
37914
|
+
});
|
|
37769
37915
|
}
|
|
37770
37916
|
async completeSuccessfulTurn(turnId) {
|
|
37771
37917
|
this.lastSessionNotice = void 0;
|
|
@@ -37773,7 +37919,7 @@ ${diff}`, "");
|
|
|
37773
37919
|
const active = this.sessionState.sessionFailure;
|
|
37774
37920
|
if (active?.id !== this.activeFailureIdByScope.get(turnId) || active?.severity !== "warning") return;
|
|
37775
37921
|
this.activeFailureIdByScope.delete(turnId);
|
|
37776
|
-
|
|
37922
|
+
await this.clearSessionFailure();
|
|
37777
37923
|
}
|
|
37778
37924
|
async handleFailedTurn(turn) {
|
|
37779
37925
|
if (turn.status === "failed" && this.isAuthenticationRequiredError(turn.error?.codexErrorInfo ?? null)) {
|
|
@@ -37852,7 +37998,7 @@ ${diff}`, "");
|
|
|
37852
37998
|
if (ignoredBySubagents) return;
|
|
37853
37999
|
if (updateEvent === void 0) updateEvent = await this.createUpdateEvent(notification);
|
|
37854
38000
|
if (updateEvent) {
|
|
37855
|
-
await this.
|
|
38001
|
+
await this.publishUpdate(updateEvent, this.subagents.notificationSessionId(notification));
|
|
37856
38002
|
}
|
|
37857
38003
|
}
|
|
37858
38004
|
async waitForNativeSubagentSession(childThreadId) {
|
|
@@ -38131,6 +38277,21 @@ ${params.turnId}`;
|
|
|
38131
38277
|
return null;
|
|
38132
38278
|
}
|
|
38133
38279
|
}
|
|
38280
|
+
/** These fact builders produce partial owned namespaces, unlike raw metadata patches. */
|
|
38281
|
+
publishUpdate(update, sessionId = this.sessionState.sessionId) {
|
|
38282
|
+
if (this.session.protocolVersion !== 2 || update.sessionUpdate !== "session_info_update" || update._meta == null) {
|
|
38283
|
+
return this.session.update(update, sessionId);
|
|
38284
|
+
}
|
|
38285
|
+
const { _meta, sessionUpdate: _tag, ...fields } = update;
|
|
38286
|
+
return this.session.forSession(sessionId).patchSessionMetadata((current) => {
|
|
38287
|
+
const metadata = { ..._meta };
|
|
38288
|
+
const codex = recordOrNull(_meta["codex"]);
|
|
38289
|
+
if (codex) metadata["codex"] = { ...recordOrNull(current["codex"]), ...codex };
|
|
38290
|
+
const air = recordOrNull(recordOrNull(_meta[JETBRAINS_META_KEY])?.[AIR_META_KEY]);
|
|
38291
|
+
if (air) metadata[JETBRAINS_META_KEY] = withAirMetadata(current, air)[JETBRAINS_META_KEY];
|
|
38292
|
+
return metadata;
|
|
38293
|
+
}, fields);
|
|
38294
|
+
}
|
|
38134
38295
|
createCodexSessionInfoUpdate(codexMetadata) {
|
|
38135
38296
|
return {
|
|
38136
38297
|
sessionUpdate: "session_info_update",
|
|
@@ -38502,7 +38663,7 @@ ${event.details}` : event.summary;
|
|
|
38502
38663
|
if (activeId === void 0 || this.failuresById.get(activeId)?.severity !== "warning") return;
|
|
38503
38664
|
this.activeFailureIdByScope.delete(turnId);
|
|
38504
38665
|
if (this.sessionState.sessionFailure?.id === activeId) {
|
|
38505
|
-
|
|
38666
|
+
void this.clearSessionFailure().catch((error62) => logger.error("Failed to clear session failure metadata", error62));
|
|
38506
38667
|
}
|
|
38507
38668
|
}
|
|
38508
38669
|
recordRetryWarning(params, attributeToTurn = true) {
|
|
@@ -41095,7 +41256,7 @@ var package_default = {
|
|
|
41095
41256
|
publishConfig: {
|
|
41096
41257
|
access: "public"
|
|
41097
41258
|
},
|
|
41098
|
-
version: "2.5.1-preview.
|
|
41259
|
+
version: "2.5.1-preview.12",
|
|
41099
41260
|
description: "",
|
|
41100
41261
|
main: "dist/index.js",
|
|
41101
41262
|
bin: {
|
|
@@ -49325,10 +49486,7 @@ var SessionIndexService = class {
|
|
|
49325
49486
|
}
|
|
49326
49487
|
});
|
|
49327
49488
|
if (archived ? open3 : this.host.session(sessionId) !== void 0) {
|
|
49328
|
-
await new ACPSessionConnection(this.host.connection(), sessionId)
|
|
49329
|
-
sessionUpdate: "session_info_update",
|
|
49330
|
-
_meta: withAirMeta(void 0, AIR_ARCHIVED_KEY, archived)
|
|
49331
|
-
});
|
|
49489
|
+
await publishAirSessionMetadata(new ACPSessionConnection(this.host.connection(), sessionId), AIR_ARCHIVED_KEY, archived);
|
|
49332
49490
|
}
|
|
49333
49491
|
} finally {
|
|
49334
49492
|
if (archived) this.host.endSessionCloseFence(sessionId);
|
|
@@ -50555,7 +50713,7 @@ You have been logged out. Please try again.`);
|
|
|
50555
50713
|
endSessionCloseFence(sessionId) {
|
|
50556
50714
|
const fence = this.closingSessions.get(sessionId);
|
|
50557
50715
|
if (!fence || --fence.count > 0) return;
|
|
50558
|
-
for (const closed of fence.closedSessions) this.
|
|
50716
|
+
for (const closed of fence.closedSessions) this.sealSessionDelivery(closed);
|
|
50559
50717
|
this.closingSessions.delete(sessionId);
|
|
50560
50718
|
}
|
|
50561
50719
|
/** Nested operations such as archive may still owe their final metadata update. */
|
|
@@ -50563,9 +50721,13 @@ You have been logged out. Please try again.`);
|
|
|
50563
50721
|
const fence = this.closingSessions.get(sessionId);
|
|
50564
50722
|
for (const closed of [sessionId, ...children]) {
|
|
50565
50723
|
if (fence) fence.closedSessions.add(closed);
|
|
50566
|
-
else this.
|
|
50724
|
+
else this.sealSessionDelivery(closed);
|
|
50567
50725
|
}
|
|
50568
50726
|
}
|
|
50727
|
+
sealSessionDelivery(sessionId) {
|
|
50728
|
+
this.clientDelivery.closeSession(sessionId);
|
|
50729
|
+
AcpV2Connection.of(this.connection)?.forgetSession(sessionId);
|
|
50730
|
+
}
|
|
50569
50731
|
getSessionGeneration(sessionId) {
|
|
50570
50732
|
return this.sessionGenerations.get(sessionId) ?? 0;
|
|
50571
50733
|
}
|
|
@@ -50702,7 +50864,7 @@ You have been logged out. Please try again.`);
|
|
|
50702
50864
|
this.sessionIndex.titleWriter(sessionId)
|
|
50703
50865
|
);
|
|
50704
50866
|
sessionState.promptSuggestions = this.createPromptSuggestions(sessionState);
|
|
50705
|
-
this.installSessionState(sessionState);
|
|
50867
|
+
this.installSessionState(sessionState, sessionMetadata.threadStatus);
|
|
50706
50868
|
AcpV2Connection.of(this.connection)?.restoreForegroundState(sessionId, sessionMetadata.threadStatus?.type === "active");
|
|
50707
50869
|
this.recovery?.markLoaded(sessionState, openGeneration);
|
|
50708
50870
|
if (settleTrackerReady) {
|
|
@@ -50865,12 +51027,22 @@ You have been logged out. Please try again.`);
|
|
|
50865
51027
|
new ACPSessionConnection(this.connection, sessionId)
|
|
50866
51028
|
);
|
|
50867
51029
|
}
|
|
50868
|
-
installSessionState(sessionState) {
|
|
51030
|
+
installSessionState(sessionState, threadStatus) {
|
|
50869
51031
|
const previous = this.sessions.get(sessionState.sessionId);
|
|
50870
51032
|
previous?.asyncTasks.clear();
|
|
50871
51033
|
void previous?.promptSuggestions?.clear();
|
|
50872
51034
|
this.sessions.set(sessionState.sessionId, sessionState);
|
|
50873
51035
|
this.clientDelivery.openSession(sessionState.sessionId);
|
|
51036
|
+
const v2 = AcpV2Connection.of(this.connection);
|
|
51037
|
+
if (v2) {
|
|
51038
|
+
const metadata = threadStatus ? { codex: { threadStatus } } : null;
|
|
51039
|
+
if (previous) {
|
|
51040
|
+
if (previous.sessionFailure) sessionState.sessionFailure = previous.sessionFailure;
|
|
51041
|
+
void v2.refreshSessionInfo(sessionState.sessionId, metadata);
|
|
51042
|
+
} else {
|
|
51043
|
+
v2.resetSessionInfo(sessionState.sessionId, metadata);
|
|
51044
|
+
}
|
|
51045
|
+
}
|
|
50874
51046
|
}
|
|
50875
51047
|
/**
|
|
50876
51048
|
* Installs a baseline session-scoped subscription, so a Codex-initiated turn starting before
|
|
@@ -51173,10 +51345,7 @@ You have been logged out. Please try again.`);
|
|
|
51173
51345
|
async snapshotSessionStateV2(sessionId) {
|
|
51174
51346
|
await this.codexAcpClient.waitForSessionNotifications(sessionId);
|
|
51175
51347
|
const state = this.getSessionState(sessionId);
|
|
51176
|
-
await
|
|
51177
|
-
sessionUpdate: "session_info_update",
|
|
51178
|
-
title: state.sessionTitle
|
|
51179
|
-
});
|
|
51348
|
+
await AcpV2Connection.of(this.connection).snapshotSessionInfo(sessionId, state.sessionTitle);
|
|
51180
51349
|
await AcpV2Connection.of(this.connection).snapshotForegroundState(sessionId);
|
|
51181
51350
|
}
|
|
51182
51351
|
async forkSession(params) {
|
|
@@ -51285,7 +51454,7 @@ You have been logged out. Please try again.`);
|
|
|
51285
51454
|
this.sessions.delete(params.sessionId);
|
|
51286
51455
|
this.asyncQuestions.get(params.sessionId)?.dispose();
|
|
51287
51456
|
this.asyncQuestions.delete(params.sessionId);
|
|
51288
|
-
AcpV2Connection.of(this.connection)?.
|
|
51457
|
+
AcpV2Connection.of(this.connection)?.forgetForegroundState(params.sessionId);
|
|
51289
51458
|
this.mcpSessionStartup.close(params.sessionId);
|
|
51290
51459
|
this.codexAcpClient.appServerClient.mcpStartup.forgetThread(params.sessionId);
|
|
51291
51460
|
this.pendingTurnStarts.delete(params.sessionId);
|
|
@@ -52358,9 +52527,11 @@ You have been logged out. Please try again.`);
|
|
|
52358
52527
|
return;
|
|
52359
52528
|
}
|
|
52360
52529
|
sessionState.currentGoal = snapshot;
|
|
52361
|
-
|
|
52362
|
-
|
|
52363
|
-
|
|
52530
|
+
await publishGoalSessionInfo(
|
|
52531
|
+
new ACPSessionConnection(this.connection, sessionState.sessionId),
|
|
52532
|
+
snapshot,
|
|
52533
|
+
sessionState.clientCapabilities.airClient
|
|
52534
|
+
);
|
|
52364
52535
|
}
|
|
52365
52536
|
/** The models of a root session, for the configuration of its native subagent sessions. */
|
|
52366
52537
|
subagentModels(sessionState) {
|
|
@@ -52499,7 +52670,7 @@ You have been logged out. Please try again.`);
|
|
|
52499
52670
|
this.sessionIndex.titleWriter(sessionId)
|
|
52500
52671
|
);
|
|
52501
52672
|
sessionState.promptSuggestions = this.createPromptSuggestions(sessionState);
|
|
52502
|
-
this.installSessionState(sessionState);
|
|
52673
|
+
this.installSessionState(sessionState, thread.status);
|
|
52503
52674
|
AcpV2Connection.of(this.connection)?.restoreForegroundState(sessionId, thread.status.type === "active");
|
|
52504
52675
|
this.recovery?.markLoaded(sessionState, openGeneration);
|
|
52505
52676
|
if (knownAccount === "pending") {
|
|
@@ -52869,17 +53040,7 @@ You have been logged out. Please try again.`);
|
|
|
52869
53040
|
}
|
|
52870
53041
|
try {
|
|
52871
53042
|
const session = new ACPSessionConnection(this.connection, sessionState.sessionId);
|
|
52872
|
-
await session
|
|
52873
|
-
sessionUpdate: "session_info_update",
|
|
52874
|
-
_meta: {
|
|
52875
|
-
[JETBRAINS_META_KEY]: {
|
|
52876
|
-
[AIR_META_KEY]: {
|
|
52877
|
-
[AIR_EXTENSION_VERSION_KEY]: AIR_EXTENSION_VERSION,
|
|
52878
|
-
[AIR_AGENT_FILE_CHANGE_REPORT_KEY]: report
|
|
52879
|
-
}
|
|
52880
|
-
}
|
|
52881
|
-
}
|
|
52882
|
-
});
|
|
53043
|
+
await publishAirSessionMetadata(session, AIR_AGENT_FILE_CHANGE_REPORT_KEY, report);
|
|
52883
53044
|
} catch (error62) {
|
|
52884
53045
|
logger.error("Failed to publish agent file-change report", error62);
|
|
52885
53046
|
}
|
|
@@ -53517,7 +53678,7 @@ You have been logged out. Please try again.`);
|
|
|
53517
53678
|
).finally(() => {
|
|
53518
53679
|
signal?.removeEventListener("abort", dropPendingRequest);
|
|
53519
53680
|
reservation.release();
|
|
53520
|
-
if (!this.sessions.has(sessionId)) AcpV2Connection.of(this.connection)?.
|
|
53681
|
+
if (!this.sessions.has(sessionId)) AcpV2Connection.of(this.connection)?.forgetForegroundState(sessionId);
|
|
53521
53682
|
});
|
|
53522
53683
|
});
|
|
53523
53684
|
}
|