@agentclientprotocol/codex-acp 2.5.1-preview.12 → 2.5.1-preview.14
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 +112 -88
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36416,6 +36416,56 @@ function withSubagentUserAction(sessionId, request, itemId, signal) {
|
|
|
36416
36416
|
return context.foreground ? context.foreground.withUserAction(itemId ?? context.itemId, send, cancellation) : send();
|
|
36417
36417
|
}
|
|
36418
36418
|
|
|
36419
|
+
// src/PathUtils.ts
|
|
36420
|
+
import path5 from "node:path";
|
|
36421
|
+
function isAbsoluteProtocolPath(value) {
|
|
36422
|
+
return !value.includes("\0") && (path5.posix.isAbsolute(value) || isWindowsAbsolutePath(value));
|
|
36423
|
+
}
|
|
36424
|
+
function isAbsolutePathLike(value) {
|
|
36425
|
+
return isAbsoluteProtocolPath(value.trim());
|
|
36426
|
+
}
|
|
36427
|
+
function arePathsEqual(left, right) {
|
|
36428
|
+
return normalizePathForComparison(left) === normalizePathForComparison(right);
|
|
36429
|
+
}
|
|
36430
|
+
function arePathBasenamesEqual(left, right) {
|
|
36431
|
+
const leftBase = path5.posix.basename(normalizePathForComparison(left));
|
|
36432
|
+
const rightBase = path5.posix.basename(normalizePathForComparison(right));
|
|
36433
|
+
if (shouldComparePathCaseInsensitive(left) || shouldComparePathCaseInsensitive(right)) {
|
|
36434
|
+
return leftBase.toLowerCase() === rightBase.toLowerCase();
|
|
36435
|
+
}
|
|
36436
|
+
return leftBase === rightBase;
|
|
36437
|
+
}
|
|
36438
|
+
function normalizePathForComparison(value) {
|
|
36439
|
+
const trimmed = value.trim();
|
|
36440
|
+
if (trimmed.length === 0) {
|
|
36441
|
+
return "";
|
|
36442
|
+
}
|
|
36443
|
+
if (isWindowsAbsolutePath(trimmed)) {
|
|
36444
|
+
const normalized2 = path5.win32.normalize(trimmed).replace(/\\/g, "/");
|
|
36445
|
+
return trimTrailingPathSeparators(normalized2).toLowerCase();
|
|
36446
|
+
}
|
|
36447
|
+
const pathForComparison = path5.isAbsolute(trimmed) ? trimmed : trimmed.replace(/\\/g, "/");
|
|
36448
|
+
const normalized = path5.posix.normalize(pathForComparison);
|
|
36449
|
+
return trimTrailingPathSeparators(normalized);
|
|
36450
|
+
}
|
|
36451
|
+
function isWindowsAbsolutePath(value) {
|
|
36452
|
+
const portableValue = value.replace(/\\/g, "/");
|
|
36453
|
+
return /^[A-Za-z]:\//.test(portableValue) || /^\/\/[^/]+\/[^/]+/.test(portableValue);
|
|
36454
|
+
}
|
|
36455
|
+
function shouldComparePathCaseInsensitive(value) {
|
|
36456
|
+
return isWindowsAbsolutePath(value) || /^[A-Za-z]:/.test(value) || value.includes("\\");
|
|
36457
|
+
}
|
|
36458
|
+
function trimTrailingPathSeparators(value) {
|
|
36459
|
+
let trimmed = value;
|
|
36460
|
+
while (trimmed.endsWith("/") && !isRootPath(trimmed)) {
|
|
36461
|
+
trimmed = trimmed.slice(0, -1);
|
|
36462
|
+
}
|
|
36463
|
+
return trimmed;
|
|
36464
|
+
}
|
|
36465
|
+
function isRootPath(value) {
|
|
36466
|
+
return value === "/" || /^[A-Za-z]:\/$/.test(value) || /^\/\/[^/]+\/[^/]+\/$/.test(value);
|
|
36467
|
+
}
|
|
36468
|
+
|
|
36419
36469
|
// src/subagents/StandardSubagentEventRouter.ts
|
|
36420
36470
|
var StandardSubagentEventRouter = class {
|
|
36421
36471
|
constructor(rootSessionId, session, associations, onChildWorkEnded, capabilities = ClientCapabilities.DEFAULT, deferLive = false, ready = Promise.resolve(), runningTurnId = () => void 0, rootModels = () => null, configurationRuntime) {
|
|
@@ -36471,7 +36521,11 @@ var StandardSubagentEventRouter = class {
|
|
|
36471
36521
|
if (notification.method === "thread/settings/updated" && !this.appliedSettings.has(notification.params)) {
|
|
36472
36522
|
this.appliedSettings.add(notification.params);
|
|
36473
36523
|
const settings = notification.params.threadSettings;
|
|
36474
|
-
await this.observeConfiguration(threadId, {
|
|
36524
|
+
await this.observeConfiguration(threadId, {
|
|
36525
|
+
model: settings.model,
|
|
36526
|
+
effort: settings.effort,
|
|
36527
|
+
...this.children.has(threadId) ? { cwd: settings.cwd } : {}
|
|
36528
|
+
}, "settings");
|
|
36475
36529
|
}
|
|
36476
36530
|
if (this.deferLive) {
|
|
36477
36531
|
this.deferredLive.push(notification);
|
|
@@ -36757,10 +36811,14 @@ var StandardSubagentEventRouter = class {
|
|
|
36757
36811
|
}
|
|
36758
36812
|
async observeConfiguration(threadId, observed, source) {
|
|
36759
36813
|
const previous = this.configurations.get(threadId);
|
|
36760
|
-
|
|
36814
|
+
const cwd = observed.cwd !== void 0 && isAbsoluteProtocolPath(observed.cwd) ? observed.cwd : null;
|
|
36815
|
+
if (this.retired || !previous && !observed.model && observed.effort === null && cwd === null && source !== "settings") return;
|
|
36761
36816
|
this.configurationRequests.delete(threadId);
|
|
36762
36817
|
const next = { ...previous };
|
|
36763
36818
|
if (observed.model) next.model = preferredModel(previous?.model, { model: observed.model, source });
|
|
36819
|
+
if (cwd !== null && (!previous?.cwd || MODEL_SOURCE_RANK[source] >= MODEL_SOURCE_RANK[previous.cwd.source])) {
|
|
36820
|
+
next.cwd = { value: cwd, source };
|
|
36821
|
+
}
|
|
36764
36822
|
const changedModel = next.model?.model !== previous?.model?.model;
|
|
36765
36823
|
if (changedModel || !previous?.effort || MODEL_SOURCE_RANK[source] >= MODEL_SOURCE_RANK[previous.effort.source]) {
|
|
36766
36824
|
next.effort = { value: observed.effort, source };
|
|
@@ -36776,6 +36834,14 @@ var StandardSubagentEventRouter = class {
|
|
|
36776
36834
|
await this.ensureAnnounced(child);
|
|
36777
36835
|
const configuration = this.configurations.get(child.threadId);
|
|
36778
36836
|
if (!configuration || this.retired) return;
|
|
36837
|
+
if (configuration.cwd && configuration.cwd.value !== configuration.publishedCwd) {
|
|
36838
|
+
await this.session.update({
|
|
36839
|
+
sessionUpdate: "subagent_update",
|
|
36840
|
+
sessionId: child.sessionId,
|
|
36841
|
+
cwd: configuration.cwd.value
|
|
36842
|
+
}, child.parentSessionId);
|
|
36843
|
+
configuration.publishedCwd = configuration.cwd.value;
|
|
36844
|
+
}
|
|
36779
36845
|
const options = subagentConfigurationOptions(this.rootModels(), {
|
|
36780
36846
|
model: configuration.model?.model ?? null,
|
|
36781
36847
|
effort: configuration.effort?.value ?? null
|
|
@@ -37175,7 +37241,7 @@ function mergeRateLimitSnapshot(previous, update) {
|
|
|
37175
37241
|
|
|
37176
37242
|
// src/AgentFileChangeReport.ts
|
|
37177
37243
|
import fs2 from "node:fs";
|
|
37178
|
-
import
|
|
37244
|
+
import path6 from "node:path";
|
|
37179
37245
|
var AGENT_FILE_CHANGE_REPORT_VERSION = 1;
|
|
37180
37246
|
var AGENT_FILE_CHANGE_REPORT_MAX_PATHS = 1024;
|
|
37181
37247
|
var AGENT_FILE_CHANGE_REPORT_MAX_PATH_LENGTH = 4096;
|
|
@@ -37362,37 +37428,37 @@ function parseWorkspaceRoot(value) {
|
|
|
37362
37428
|
if (!isValidPathText(trimmed)) {
|
|
37363
37429
|
return null;
|
|
37364
37430
|
}
|
|
37365
|
-
if (
|
|
37431
|
+
if (isWindowsAbsolutePath2(trimmed)) {
|
|
37366
37432
|
return {
|
|
37367
|
-
value:
|
|
37433
|
+
value: path6.win32.normalize(trimmed.replace(/\//g, "\\")),
|
|
37368
37434
|
flavor: "windows"
|
|
37369
37435
|
};
|
|
37370
37436
|
}
|
|
37371
|
-
if (
|
|
37437
|
+
if (path6.posix.isAbsolute(trimmed)) {
|
|
37372
37438
|
return {
|
|
37373
|
-
value:
|
|
37439
|
+
value: path6.posix.normalize(trimmed.replace(/\\/g, "/")),
|
|
37374
37440
|
flavor: "posix"
|
|
37375
37441
|
};
|
|
37376
37442
|
}
|
|
37377
37443
|
return null;
|
|
37378
37444
|
}
|
|
37379
37445
|
function normalizeReportedPath(value, relativeRoot, roots) {
|
|
37380
|
-
if (!isValidPathText(value) || /^[A-Za-z]:[^\\/]/.test(value) || /^\\\\[?.]\\/.test(value) || /^(?:\\\\|\/\/)/.test(value) && !
|
|
37446
|
+
if (!isValidPathText(value) || /^[A-Za-z]:[^\\/]/.test(value) || /^\\\\[?.]\\/.test(value) || /^(?:\\\\|\/\/)/.test(value) && !isWindowsAbsolutePath2(value) || relativeRoot.flavor === "windows" && /^\\(?!\\)/.test(value) || /^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(value)) {
|
|
37381
37447
|
return null;
|
|
37382
37448
|
}
|
|
37383
37449
|
let candidate;
|
|
37384
|
-
if (
|
|
37385
|
-
candidate = { value:
|
|
37386
|
-
} else if (
|
|
37387
|
-
candidate = { value:
|
|
37450
|
+
if (isWindowsAbsolutePath2(value)) {
|
|
37451
|
+
candidate = { value: path6.win32.normalize(value.replace(/\//g, "\\")), flavor: "windows" };
|
|
37452
|
+
} else if (path6.posix.isAbsolute(value)) {
|
|
37453
|
+
candidate = { value: path6.posix.normalize(value.replace(/\\/g, "/")), flavor: "posix" };
|
|
37388
37454
|
} else if (relativeRoot.flavor === "windows") {
|
|
37389
37455
|
candidate = {
|
|
37390
|
-
value:
|
|
37456
|
+
value: path6.win32.resolve(relativeRoot.value, value.replace(/\//g, "\\")),
|
|
37391
37457
|
flavor: "windows"
|
|
37392
37458
|
};
|
|
37393
37459
|
} else {
|
|
37394
37460
|
candidate = {
|
|
37395
|
-
value:
|
|
37461
|
+
value: path6.posix.resolve(relativeRoot.value, value.replace(/\\/g, "/")),
|
|
37396
37462
|
flavor: "posix"
|
|
37397
37463
|
};
|
|
37398
37464
|
}
|
|
@@ -37401,7 +37467,7 @@ function normalizeReportedPath(value, relativeRoot, roots) {
|
|
|
37401
37467
|
}
|
|
37402
37468
|
function findDiffDisplayRoot(cwd) {
|
|
37403
37469
|
if (!isNativePathFlavor(cwd.flavor)) return cwd;
|
|
37404
|
-
const pathImplementation = cwd.flavor === "windows" ?
|
|
37470
|
+
const pathImplementation = cwd.flavor === "windows" ? path6.win32 : path6.posix;
|
|
37405
37471
|
let current = cwd.value;
|
|
37406
37472
|
while (true) {
|
|
37407
37473
|
if (fs2.existsSync(pathImplementation.join(current, ".git"))) {
|
|
@@ -37422,23 +37488,23 @@ function canonicalizeReportedPath(candidate) {
|
|
|
37422
37488
|
if (!isNativePathFlavor(candidate.flavor)) {
|
|
37423
37489
|
return candidate;
|
|
37424
37490
|
}
|
|
37425
|
-
const parent = canonicalizeFromExistingAncestor(
|
|
37426
|
-
return { ...candidate, value:
|
|
37491
|
+
const parent = canonicalizeFromExistingAncestor(path6.dirname(candidate.value));
|
|
37492
|
+
return { ...candidate, value: path6.resolve(parent, path6.basename(candidate.value)) };
|
|
37427
37493
|
}
|
|
37428
37494
|
function canonicalizeFromExistingAncestor(value) {
|
|
37429
|
-
const original =
|
|
37495
|
+
const original = path6.resolve(value);
|
|
37430
37496
|
let current = original;
|
|
37431
37497
|
const missingSegments = [];
|
|
37432
37498
|
while (true) {
|
|
37433
37499
|
try {
|
|
37434
37500
|
const canonical = fs2.realpathSync.native(current);
|
|
37435
|
-
return
|
|
37501
|
+
return path6.resolve(canonical, ...missingSegments.reverse());
|
|
37436
37502
|
} catch (error62) {
|
|
37437
37503
|
if (!isMissingPathError(error62)) return original;
|
|
37438
37504
|
}
|
|
37439
|
-
const parent =
|
|
37505
|
+
const parent = path6.dirname(current);
|
|
37440
37506
|
if (parent === current) return original;
|
|
37441
|
-
missingSegments.push(
|
|
37507
|
+
missingSegments.push(path6.basename(current));
|
|
37442
37508
|
current = parent;
|
|
37443
37509
|
}
|
|
37444
37510
|
}
|
|
@@ -37453,11 +37519,11 @@ function pathIsStrictlyInside(root, candidate) {
|
|
|
37453
37519
|
if (root.flavor !== candidate.flavor) {
|
|
37454
37520
|
return false;
|
|
37455
37521
|
}
|
|
37456
|
-
const pathImplementation = root.flavor === "windows" ?
|
|
37522
|
+
const pathImplementation = root.flavor === "windows" ? path6.win32 : path6.posix;
|
|
37457
37523
|
const relative = pathImplementation.relative(root.value, candidate.value);
|
|
37458
37524
|
return relative.length > 0 && !pathImplementation.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${pathImplementation.sep}`);
|
|
37459
37525
|
}
|
|
37460
|
-
function
|
|
37526
|
+
function isWindowsAbsolutePath2(value) {
|
|
37461
37527
|
const portable = value.replace(/\\/g, "/");
|
|
37462
37528
|
return /^[A-Za-z]:\//.test(portable) || /^\/\/[^/]+\/[^/]+(?:\/|$)/.test(portable);
|
|
37463
37529
|
}
|
|
@@ -37487,7 +37553,7 @@ function createSessionNotice(severity, title, description) {
|
|
|
37487
37553
|
}
|
|
37488
37554
|
|
|
37489
37555
|
// src/SessionIndexMutations.ts
|
|
37490
|
-
import
|
|
37556
|
+
import path7 from "node:path";
|
|
37491
37557
|
var ARCHIVED_SESSIONS_DIR = "archived_sessions";
|
|
37492
37558
|
function isMissingThreadError(err) {
|
|
37493
37559
|
return isUnknownThreadError(err) || isThreadNotFoundError(err);
|
|
@@ -37553,8 +37619,8 @@ async function readThreadArchived(client, threadId, codexHome) {
|
|
|
37553
37619
|
}
|
|
37554
37620
|
function isArchivedRolloutPath(threadPath, codexHome) {
|
|
37555
37621
|
if (codexHome !== null) {
|
|
37556
|
-
const relative =
|
|
37557
|
-
if (relative !== "" && !relative.startsWith("..") && !
|
|
37622
|
+
const relative = path7.relative(path7.join(codexHome, ARCHIVED_SESSIONS_DIR), threadPath);
|
|
37623
|
+
if (relative !== "" && !relative.startsWith("..") && !path7.isAbsolute(relative)) return true;
|
|
37558
37624
|
}
|
|
37559
37625
|
return threadPath.replace(/\\/g, "/").split("/").includes(ARCHIVED_SESSIONS_DIR);
|
|
37560
37626
|
}
|
|
@@ -40409,13 +40475,13 @@ function parseMcpStartupAwaitTimeoutMs(meta3) {
|
|
|
40409
40475
|
|
|
40410
40476
|
// node_modules/open/index.js
|
|
40411
40477
|
import process10 from "node:process";
|
|
40412
|
-
import
|
|
40478
|
+
import path9 from "node:path";
|
|
40413
40479
|
import { fileURLToPath } from "node:url";
|
|
40414
40480
|
import childProcess4 from "node:child_process";
|
|
40415
40481
|
import fs7, { constants as fsConstants2 } from "node:fs/promises";
|
|
40416
40482
|
|
|
40417
40483
|
// node_modules/wsl-utils/index.js
|
|
40418
|
-
import
|
|
40484
|
+
import path8 from "node:path";
|
|
40419
40485
|
import { promisify as promisify2 } from "node:util";
|
|
40420
40486
|
import childProcess2 from "node:child_process";
|
|
40421
40487
|
import fs6, { constants as fsConstants } from "node:fs/promises";
|
|
@@ -40595,7 +40661,7 @@ var wslDefaultBrowser = async () => {
|
|
|
40595
40661
|
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
40596
40662
|
const { stdout } = await executePowerShell(command, {
|
|
40597
40663
|
powerShellPath: psPath,
|
|
40598
|
-
cwd:
|
|
40664
|
+
cwd: path8.dirname(psPath)
|
|
40599
40665
|
});
|
|
40600
40666
|
return stdout.trim();
|
|
40601
40667
|
};
|
|
@@ -40803,8 +40869,8 @@ var is_in_ssh_default = isInSsh;
|
|
|
40803
40869
|
|
|
40804
40870
|
// node_modules/open/index.js
|
|
40805
40871
|
var fallbackAttemptSymbol = /* @__PURE__ */ Symbol("fallbackAttempt");
|
|
40806
|
-
var __dirname = import.meta.url ?
|
|
40807
|
-
var localXdgOpenPath =
|
|
40872
|
+
var __dirname = import.meta.url ? path9.dirname(fileURLToPath(import.meta.url)) : "";
|
|
40873
|
+
var localXdgOpenPath = path9.join(__dirname, "xdg-open");
|
|
40808
40874
|
var { platform, arch } = process10;
|
|
40809
40875
|
var tryEachApp = async (apps2, opener) => {
|
|
40810
40876
|
if (apps2.length === 0) {
|
|
@@ -40947,7 +41013,7 @@ var baseOpen = async (options) => {
|
|
|
40947
41013
|
childProcessOptions.stdio = "ignore";
|
|
40948
41014
|
}
|
|
40949
41015
|
if (is_wsl_default) {
|
|
40950
|
-
childProcessOptions.cwd =
|
|
41016
|
+
childProcessOptions.cwd = path9.dirname(command);
|
|
40951
41017
|
}
|
|
40952
41018
|
} else {
|
|
40953
41019
|
if (app) {
|
|
@@ -41256,7 +41322,7 @@ var package_default = {
|
|
|
41256
41322
|
publishConfig: {
|
|
41257
41323
|
access: "public"
|
|
41258
41324
|
},
|
|
41259
|
-
version: "2.5.1-preview.
|
|
41325
|
+
version: "2.5.1-preview.14",
|
|
41260
41326
|
description: "",
|
|
41261
41327
|
main: "dist/index.js",
|
|
41262
41328
|
bin: {
|
|
@@ -41366,56 +41432,6 @@ function createCodexCollaborationMode(mode, currentModelId) {
|
|
|
41366
41432
|
};
|
|
41367
41433
|
}
|
|
41368
41434
|
|
|
41369
|
-
// src/PathUtils.ts
|
|
41370
|
-
import path9 from "node:path";
|
|
41371
|
-
function isAbsoluteProtocolPath(value) {
|
|
41372
|
-
return !value.includes("\0") && (path9.posix.isAbsolute(value) || isWindowsAbsolutePath2(value));
|
|
41373
|
-
}
|
|
41374
|
-
function isAbsolutePathLike(value) {
|
|
41375
|
-
return isAbsoluteProtocolPath(value.trim());
|
|
41376
|
-
}
|
|
41377
|
-
function arePathsEqual(left, right) {
|
|
41378
|
-
return normalizePathForComparison(left) === normalizePathForComparison(right);
|
|
41379
|
-
}
|
|
41380
|
-
function arePathBasenamesEqual(left, right) {
|
|
41381
|
-
const leftBase = path9.posix.basename(normalizePathForComparison(left));
|
|
41382
|
-
const rightBase = path9.posix.basename(normalizePathForComparison(right));
|
|
41383
|
-
if (shouldComparePathCaseInsensitive(left) || shouldComparePathCaseInsensitive(right)) {
|
|
41384
|
-
return leftBase.toLowerCase() === rightBase.toLowerCase();
|
|
41385
|
-
}
|
|
41386
|
-
return leftBase === rightBase;
|
|
41387
|
-
}
|
|
41388
|
-
function normalizePathForComparison(value) {
|
|
41389
|
-
const trimmed = value.trim();
|
|
41390
|
-
if (trimmed.length === 0) {
|
|
41391
|
-
return "";
|
|
41392
|
-
}
|
|
41393
|
-
if (isWindowsAbsolutePath2(trimmed)) {
|
|
41394
|
-
const normalized2 = path9.win32.normalize(trimmed).replace(/\\/g, "/");
|
|
41395
|
-
return trimTrailingPathSeparators(normalized2).toLowerCase();
|
|
41396
|
-
}
|
|
41397
|
-
const pathForComparison = path9.isAbsolute(trimmed) ? trimmed : trimmed.replace(/\\/g, "/");
|
|
41398
|
-
const normalized = path9.posix.normalize(pathForComparison);
|
|
41399
|
-
return trimTrailingPathSeparators(normalized);
|
|
41400
|
-
}
|
|
41401
|
-
function isWindowsAbsolutePath2(value) {
|
|
41402
|
-
const portableValue = value.replace(/\\/g, "/");
|
|
41403
|
-
return /^[A-Za-z]:\//.test(portableValue) || /^\/\/[^/]+\/[^/]+/.test(portableValue);
|
|
41404
|
-
}
|
|
41405
|
-
function shouldComparePathCaseInsensitive(value) {
|
|
41406
|
-
return isWindowsAbsolutePath2(value) || /^[A-Za-z]:/.test(value) || value.includes("\\");
|
|
41407
|
-
}
|
|
41408
|
-
function trimTrailingPathSeparators(value) {
|
|
41409
|
-
let trimmed = value;
|
|
41410
|
-
while (trimmed.endsWith("/") && !isRootPath(trimmed)) {
|
|
41411
|
-
trimmed = trimmed.slice(0, -1);
|
|
41412
|
-
}
|
|
41413
|
-
return trimmed;
|
|
41414
|
-
}
|
|
41415
|
-
function isRootPath(value) {
|
|
41416
|
-
return value === "/" || /^[A-Za-z]:\/$/.test(value) || /^\/\/[^/]+\/[^/]+\/$/.test(value);
|
|
41417
|
-
}
|
|
41418
|
-
|
|
41419
41435
|
// src/subagents/CodexSubagentSubscriptions.ts
|
|
41420
41436
|
var CodexSubagentSubscriptions = class {
|
|
41421
41437
|
constructor(client) {
|
|
@@ -50206,7 +50222,7 @@ var CodexAcpServer = class {
|
|
|
50206
50222
|
async readSubagentConfiguration(threadId, parentThreadId) {
|
|
50207
50223
|
const thread = await this.codexAcpClient.readSubagentThread(threadId);
|
|
50208
50224
|
if (!thread || thread.id !== threadId || thread.parentThreadId !== parentThreadId || thread.status.type === "notLoaded") return null;
|
|
50209
|
-
return { model: thread.model, effort: thread.reasoningEffort };
|
|
50225
|
+
return { model: thread.model, effort: thread.reasoningEffort, cwd: thread.cwd };
|
|
50210
50226
|
}
|
|
50211
50227
|
getSubagentInteractionHandlers(router, rootSessionId) {
|
|
50212
50228
|
const existing = this.subagentInteractionHandlers.get(router);
|
|
@@ -53373,12 +53389,14 @@ You have been logged out. Please try again.`);
|
|
|
53373
53389
|
cancellers.clear();
|
|
53374
53390
|
}
|
|
53375
53391
|
async interruptPromptTurn(sessionState, turn, requestName) {
|
|
53392
|
+
const activePrompt = this.activePrompts.get(sessionState.sessionId);
|
|
53376
53393
|
this.codexAcpClient.markTurnStale({
|
|
53377
53394
|
threadId: turn.threadId,
|
|
53378
53395
|
turnId: turn.turnId
|
|
53379
53396
|
});
|
|
53380
53397
|
try {
|
|
53381
53398
|
await this.interruptStandardChildren(sessionState);
|
|
53399
|
+
if (this.activePrompts.get(sessionState.sessionId) !== activePrompt) return;
|
|
53382
53400
|
await this.requestTurnInterrupt(sessionState, turn.threadId, turn.turnId, requestName);
|
|
53383
53401
|
} finally {
|
|
53384
53402
|
this.codexAcpClient.resolveTurnInterrupted({
|
|
@@ -53393,13 +53411,17 @@ You have been logged out. Please try again.`);
|
|
|
53393
53411
|
* interrupt", and once it registers a later turn under a different id, "expected active turn
|
|
53394
53412
|
* id <completionTurnId> but found <Y>". Both are retried, with the id recomputed on every
|
|
53395
53413
|
* attempt so a `turn/started` that arrives between retries is picked up.
|
|
53414
|
+
* Retries belong to that prompt, not to a newer prompt that starts while a reply is pending.
|
|
53396
53415
|
*/
|
|
53397
53416
|
async requestTurnInterrupt(sessionState, threadId, completionTurnId, requestName) {
|
|
53398
53417
|
if (this.recovery !== null && !this.turnAppServerIsLive(threadId)) {
|
|
53399
53418
|
logger.log(`${requestName} - turnInterrupt skipped: the app-server of the turn is gone`, { sessionId: threadId });
|
|
53400
53419
|
return;
|
|
53401
53420
|
}
|
|
53402
|
-
|
|
53421
|
+
const activePrompt = this.activePrompts.get(sessionState.sessionId);
|
|
53422
|
+
const ownsRegisteredTurn = activePrompt?.currentTurn?.threadId === threadId && activePrompt.currentTurn.turnId === completionTurnId;
|
|
53423
|
+
const stillOwnsPrompt = () => ownsRegisteredTurn && activePrompt !== void 0 && this.activePrompts.get(sessionState.sessionId) === activePrompt;
|
|
53424
|
+
let turnId = ownsRegisteredTurn ? codexRunningTurnId(sessionState, completionTurnId) : completionTurnId;
|
|
53403
53425
|
for (let attempt = 0; ; attempt++) {
|
|
53404
53426
|
try {
|
|
53405
53427
|
await this.runWithProcessCheck(() => this.codexAcpClient.turnInterrupt({
|
|
@@ -53412,15 +53434,15 @@ You have been logged out. Please try again.`);
|
|
|
53412
53434
|
});
|
|
53413
53435
|
return;
|
|
53414
53436
|
} catch (err) {
|
|
53415
|
-
const promptStillActive = this.activePrompts.has(threadId);
|
|
53416
53437
|
const mismatch = parseExpectedActiveTurnMismatch(err);
|
|
53417
53438
|
const isMismatch = mismatch !== null && mismatch.expected === sessionState.currentTurnId && mismatch.found !== "";
|
|
53418
|
-
const retryable =
|
|
53439
|
+
const retryable = stillOwnsPrompt() && (isNoActiveTurnError(err) || isMismatch) && attempt < NO_ACTIVE_TURN_RETRY_DELAYS_MS.length;
|
|
53419
53440
|
if (!retryable) {
|
|
53420
53441
|
logger.error(`${requestName} - turnInterrupt failed`, err);
|
|
53421
53442
|
return;
|
|
53422
53443
|
}
|
|
53423
53444
|
await new Promise((resolve) => setTimeout(resolve, NO_ACTIVE_TURN_RETRY_DELAYS_MS[attempt]));
|
|
53445
|
+
if (!stillOwnsPrompt()) return;
|
|
53424
53446
|
turnId = sessionState.interruptTurnId ?? (isMismatch ? mismatch.found : completionTurnId);
|
|
53425
53447
|
logger.log(`${requestName} - turn not interruptible yet, retrying`, {
|
|
53426
53448
|
sessionId: threadId,
|
|
@@ -53442,9 +53464,11 @@ You have been logged out. Please try again.`);
|
|
|
53442
53464
|
return activePrompt.signal.aborted || this.activePrompts.get(sessionId) !== activePrompt || this.sessionIsClosing(sessionId);
|
|
53443
53465
|
}
|
|
53444
53466
|
async interruptSessionTurn(sessionState, requestName, resolveInterruptedTurn) {
|
|
53467
|
+
const activePrompt = this.activePrompts.get(sessionState.sessionId);
|
|
53445
53468
|
await this.interruptStandardChildren(sessionState);
|
|
53469
|
+
if (this.activePrompts.get(sessionState.sessionId) !== activePrompt) return;
|
|
53446
53470
|
const turnId = await this.getInterruptibleTurnId(sessionState, requestName);
|
|
53447
|
-
if (!turnId) {
|
|
53471
|
+
if (!turnId || this.activePrompts.get(sessionState.sessionId) !== activePrompt) {
|
|
53448
53472
|
return;
|
|
53449
53473
|
}
|
|
53450
53474
|
logger.log(`${requestName} session requested`, {
|