@agentclientprotocol/codex-acp 2.5.1-preview.12 → 2.5.1-preview.13
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 +13 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -41256,7 +41256,7 @@ var package_default = {
|
|
|
41256
41256
|
publishConfig: {
|
|
41257
41257
|
access: "public"
|
|
41258
41258
|
},
|
|
41259
|
-
version: "2.5.1-preview.
|
|
41259
|
+
version: "2.5.1-preview.13",
|
|
41260
41260
|
description: "",
|
|
41261
41261
|
main: "dist/index.js",
|
|
41262
41262
|
bin: {
|
|
@@ -53373,12 +53373,14 @@ You have been logged out. Please try again.`);
|
|
|
53373
53373
|
cancellers.clear();
|
|
53374
53374
|
}
|
|
53375
53375
|
async interruptPromptTurn(sessionState, turn, requestName) {
|
|
53376
|
+
const activePrompt = this.activePrompts.get(sessionState.sessionId);
|
|
53376
53377
|
this.codexAcpClient.markTurnStale({
|
|
53377
53378
|
threadId: turn.threadId,
|
|
53378
53379
|
turnId: turn.turnId
|
|
53379
53380
|
});
|
|
53380
53381
|
try {
|
|
53381
53382
|
await this.interruptStandardChildren(sessionState);
|
|
53383
|
+
if (this.activePrompts.get(sessionState.sessionId) !== activePrompt) return;
|
|
53382
53384
|
await this.requestTurnInterrupt(sessionState, turn.threadId, turn.turnId, requestName);
|
|
53383
53385
|
} finally {
|
|
53384
53386
|
this.codexAcpClient.resolveTurnInterrupted({
|
|
@@ -53393,13 +53395,17 @@ You have been logged out. Please try again.`);
|
|
|
53393
53395
|
* interrupt", and once it registers a later turn under a different id, "expected active turn
|
|
53394
53396
|
* id <completionTurnId> but found <Y>". Both are retried, with the id recomputed on every
|
|
53395
53397
|
* attempt so a `turn/started` that arrives between retries is picked up.
|
|
53398
|
+
* Retries belong to that prompt, not to a newer prompt that starts while a reply is pending.
|
|
53396
53399
|
*/
|
|
53397
53400
|
async requestTurnInterrupt(sessionState, threadId, completionTurnId, requestName) {
|
|
53398
53401
|
if (this.recovery !== null && !this.turnAppServerIsLive(threadId)) {
|
|
53399
53402
|
logger.log(`${requestName} - turnInterrupt skipped: the app-server of the turn is gone`, { sessionId: threadId });
|
|
53400
53403
|
return;
|
|
53401
53404
|
}
|
|
53402
|
-
|
|
53405
|
+
const activePrompt = this.activePrompts.get(sessionState.sessionId);
|
|
53406
|
+
const ownsRegisteredTurn = activePrompt?.currentTurn?.threadId === threadId && activePrompt.currentTurn.turnId === completionTurnId;
|
|
53407
|
+
const stillOwnsPrompt = () => ownsRegisteredTurn && activePrompt !== void 0 && this.activePrompts.get(sessionState.sessionId) === activePrompt;
|
|
53408
|
+
let turnId = ownsRegisteredTurn ? codexRunningTurnId(sessionState, completionTurnId) : completionTurnId;
|
|
53403
53409
|
for (let attempt = 0; ; attempt++) {
|
|
53404
53410
|
try {
|
|
53405
53411
|
await this.runWithProcessCheck(() => this.codexAcpClient.turnInterrupt({
|
|
@@ -53412,15 +53418,15 @@ You have been logged out. Please try again.`);
|
|
|
53412
53418
|
});
|
|
53413
53419
|
return;
|
|
53414
53420
|
} catch (err) {
|
|
53415
|
-
const promptStillActive = this.activePrompts.has(threadId);
|
|
53416
53421
|
const mismatch = parseExpectedActiveTurnMismatch(err);
|
|
53417
53422
|
const isMismatch = mismatch !== null && mismatch.expected === sessionState.currentTurnId && mismatch.found !== "";
|
|
53418
|
-
const retryable =
|
|
53423
|
+
const retryable = stillOwnsPrompt() && (isNoActiveTurnError(err) || isMismatch) && attempt < NO_ACTIVE_TURN_RETRY_DELAYS_MS.length;
|
|
53419
53424
|
if (!retryable) {
|
|
53420
53425
|
logger.error(`${requestName} - turnInterrupt failed`, err);
|
|
53421
53426
|
return;
|
|
53422
53427
|
}
|
|
53423
53428
|
await new Promise((resolve) => setTimeout(resolve, NO_ACTIVE_TURN_RETRY_DELAYS_MS[attempt]));
|
|
53429
|
+
if (!stillOwnsPrompt()) return;
|
|
53424
53430
|
turnId = sessionState.interruptTurnId ?? (isMismatch ? mismatch.found : completionTurnId);
|
|
53425
53431
|
logger.log(`${requestName} - turn not interruptible yet, retrying`, {
|
|
53426
53432
|
sessionId: threadId,
|
|
@@ -53442,9 +53448,11 @@ You have been logged out. Please try again.`);
|
|
|
53442
53448
|
return activePrompt.signal.aborted || this.activePrompts.get(sessionId) !== activePrompt || this.sessionIsClosing(sessionId);
|
|
53443
53449
|
}
|
|
53444
53450
|
async interruptSessionTurn(sessionState, requestName, resolveInterruptedTurn) {
|
|
53451
|
+
const activePrompt = this.activePrompts.get(sessionState.sessionId);
|
|
53445
53452
|
await this.interruptStandardChildren(sessionState);
|
|
53453
|
+
if (this.activePrompts.get(sessionState.sessionId) !== activePrompt) return;
|
|
53446
53454
|
const turnId = await this.getInterruptibleTurnId(sessionState, requestName);
|
|
53447
|
-
if (!turnId) {
|
|
53455
|
+
if (!turnId || this.activePrompts.get(sessionState.sessionId) !== activePrompt) {
|
|
53448
53456
|
return;
|
|
53449
53457
|
}
|
|
53450
53458
|
logger.log(`${requestName} session requested`, {
|