@agentclientprotocol/codex-acp 2.5.1-preview.13 → 2.5.1-preview.15
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 +272 -193
- 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.15",
|
|
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) {
|
|
@@ -41687,6 +41703,83 @@ function isUnknownRecord(value) {
|
|
|
41687
41703
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41688
41704
|
}
|
|
41689
41705
|
|
|
41706
|
+
// src/RequestCancellation.ts
|
|
41707
|
+
function throwIfRequestCancelled(signal) {
|
|
41708
|
+
if (signal?.aborted) throw RequestError.requestCancelled();
|
|
41709
|
+
}
|
|
41710
|
+
function withRequestCancellation(operation, signal) {
|
|
41711
|
+
if (!signal) return operation;
|
|
41712
|
+
return new Promise((resolve, reject) => {
|
|
41713
|
+
const cancelled = () => {
|
|
41714
|
+
signal.removeEventListener("abort", cancelled);
|
|
41715
|
+
reject(RequestError.requestCancelled());
|
|
41716
|
+
};
|
|
41717
|
+
if (signal.aborted) cancelled();
|
|
41718
|
+
else signal.addEventListener("abort", cancelled, { once: true });
|
|
41719
|
+
void operation.then((value) => {
|
|
41720
|
+
signal.removeEventListener("abort", cancelled);
|
|
41721
|
+
if (signal.aborted) cancelled();
|
|
41722
|
+
else resolve(value);
|
|
41723
|
+
}, (error62) => {
|
|
41724
|
+
signal.removeEventListener("abort", cancelled);
|
|
41725
|
+
reject(error62);
|
|
41726
|
+
});
|
|
41727
|
+
});
|
|
41728
|
+
}
|
|
41729
|
+
|
|
41730
|
+
// src/CodexAccountLogin.ts
|
|
41731
|
+
async function runAccountLogin(client, params, show, signal) {
|
|
41732
|
+
throwIfRequestCancelled(signal);
|
|
41733
|
+
let expectedId;
|
|
41734
|
+
const buffered = [];
|
|
41735
|
+
let complete;
|
|
41736
|
+
let endWait;
|
|
41737
|
+
const notified = new Promise((resolve, reject) => {
|
|
41738
|
+
complete = resolve;
|
|
41739
|
+
endWait = reject;
|
|
41740
|
+
});
|
|
41741
|
+
const accept = (event) => {
|
|
41742
|
+
if (expectedId === void 0) buffered.push(event);
|
|
41743
|
+
else if ((event.loginId ?? null) === expectedId) complete(event);
|
|
41744
|
+
};
|
|
41745
|
+
const listener = client.connection.onNotification("account/login/completed", accept);
|
|
41746
|
+
const completed = client.waitWhileConnected("account/login/completed", notified);
|
|
41747
|
+
void completed.catch(() => {
|
|
41748
|
+
});
|
|
41749
|
+
let response = null;
|
|
41750
|
+
let finished2 = false;
|
|
41751
|
+
try {
|
|
41752
|
+
response = await client.accountLogin(params);
|
|
41753
|
+
expectedId = "loginId" in response ? response.loginId : null;
|
|
41754
|
+
for (const event of buffered) accept(event);
|
|
41755
|
+
buffered.length = 0;
|
|
41756
|
+
throwIfRequestCancelled(signal);
|
|
41757
|
+
const first = await withRequestCancellation(Promise.race([
|
|
41758
|
+
completed.then((result2) => ({ type: "completed", result: result2 })),
|
|
41759
|
+
show(response).then((accepted) => ({ type: "shown", accepted }))
|
|
41760
|
+
]), signal);
|
|
41761
|
+
if (first.type === "completed") {
|
|
41762
|
+
finished2 = true;
|
|
41763
|
+
return first.result.success;
|
|
41764
|
+
}
|
|
41765
|
+
if (!first.accepted) return false;
|
|
41766
|
+
const result = await withRequestCancellation(completed, signal);
|
|
41767
|
+
finished2 = true;
|
|
41768
|
+
return result.success;
|
|
41769
|
+
} finally {
|
|
41770
|
+
if (!finished2 && response && "loginId" in response) {
|
|
41771
|
+
await client.accountLoginCancel({ loginId: response.loginId }).catch((error62) => {
|
|
41772
|
+
logger.error("Failed to cancel Codex account login", error62);
|
|
41773
|
+
});
|
|
41774
|
+
} else if (signal?.aborted && response && expectedId === null) {
|
|
41775
|
+
await completed.catch(() => {
|
|
41776
|
+
});
|
|
41777
|
+
}
|
|
41778
|
+
endWait(new Error("Account login has ended"));
|
|
41779
|
+
listener.dispose();
|
|
41780
|
+
}
|
|
41781
|
+
}
|
|
41782
|
+
|
|
41690
41783
|
// src/ClientSystemPrompt.ts
|
|
41691
41784
|
function clientSystemPromptText(value) {
|
|
41692
41785
|
if (value == null) return void 0;
|
|
@@ -41842,7 +41935,7 @@ var CodexAcpClient = class _CodexAcpClient {
|
|
|
41842
41935
|
* routing). `authStatus` reports only the agent-owned one.
|
|
41843
41936
|
*/
|
|
41844
41937
|
gatewayConfigSource;
|
|
41845
|
-
|
|
41938
|
+
authenticationTail = Promise.resolve();
|
|
41846
41939
|
pendingAccountUpdated = null;
|
|
41847
41940
|
sessionNotificationQueues = /* @__PURE__ */ new Map();
|
|
41848
41941
|
subagents;
|
|
@@ -41902,48 +41995,46 @@ var CodexAcpClient = class _CodexAcpClient {
|
|
|
41902
41995
|
getHomePath() {
|
|
41903
41996
|
return this.configPath;
|
|
41904
41997
|
}
|
|
41905
|
-
|
|
41998
|
+
authenticate(authRequest, urlElicitationRequester, signal) {
|
|
41906
41999
|
if (!isCodexAuthRequest(authRequest)) {
|
|
41907
|
-
|
|
42000
|
+
return Promise.reject(RequestError.invalidParams());
|
|
41908
42001
|
}
|
|
42002
|
+
const run = this.authenticationTail.then(() => this.authenticateOnce(authRequest, urlElicitationRequester, signal));
|
|
42003
|
+
this.authenticationTail = run.then(() => {
|
|
42004
|
+
}, () => {
|
|
42005
|
+
});
|
|
42006
|
+
return withRequestCancellation(run, signal);
|
|
42007
|
+
}
|
|
42008
|
+
async authenticateOnce(authRequest, urlElicitationRequester, signal) {
|
|
42009
|
+
throwIfRequestCancelled(signal);
|
|
41909
42010
|
this.gatewayConfig = null;
|
|
41910
42011
|
this.gatewayConfigSource = null;
|
|
41911
42012
|
switch (authRequest.methodId) {
|
|
41912
42013
|
case "api-key":
|
|
41913
|
-
return await this.authenticateWithApiKey(authRequest);
|
|
42014
|
+
return await this.authenticateWithApiKey(authRequest, signal);
|
|
41914
42015
|
case "chat-gpt":
|
|
41915
|
-
return await this.authenticateWithChatGpt();
|
|
42016
|
+
return await this.authenticateWithChatGpt(signal);
|
|
41916
42017
|
case "chat-gpt-device-code":
|
|
41917
|
-
return await this.authenticateWithChatGptDeviceCode(urlElicitationRequester);
|
|
42018
|
+
return await this.authenticateWithChatGptDeviceCode(urlElicitationRequester, signal);
|
|
41918
42019
|
case "gateway":
|
|
41919
42020
|
return this.authenticateWithGateway(authRequest);
|
|
41920
42021
|
}
|
|
41921
42022
|
}
|
|
41922
|
-
async authenticateWithApiKey(authRequest) {
|
|
42023
|
+
async authenticateWithApiKey(authRequest, signal) {
|
|
41923
42024
|
const apiKey = authRequest._meta?.["api-key"]?.apiKey ?? this.readApiKeyFromEnv();
|
|
41924
|
-
|
|
41925
|
-
loginCompletedPromise.catch(() => {
|
|
41926
|
-
});
|
|
41927
|
-
await this.codexClient.accountLogin({
|
|
41928
|
-
type: "apiKey",
|
|
41929
|
-
apiKey
|
|
41930
|
-
});
|
|
41931
|
-
const result = await loginCompletedPromise;
|
|
41932
|
-
return result.success;
|
|
42025
|
+
return runAccountLogin(this.codexClient, { type: "apiKey", apiKey }, async () => true, signal);
|
|
41933
42026
|
}
|
|
41934
|
-
async authenticateWithChatGpt() {
|
|
42027
|
+
async authenticateWithChatGpt(signal) {
|
|
41935
42028
|
if (await this.hasWorkingChatGptLogin()) {
|
|
42029
|
+
throwIfRequestCancelled(signal);
|
|
41936
42030
|
return true;
|
|
41937
42031
|
}
|
|
41938
|
-
|
|
41939
|
-
|
|
41940
|
-
|
|
41941
|
-
|
|
41942
|
-
|
|
41943
|
-
|
|
41944
|
-
}
|
|
41945
|
-
const result = await loginCompletedPromise;
|
|
41946
|
-
return result.success;
|
|
42032
|
+
return runAccountLogin(this.codexClient, { type: "chatgpt" }, async (response) => {
|
|
42033
|
+
if (response.type !== "chatgpt") return false;
|
|
42034
|
+
throwIfRequestCancelled(signal);
|
|
42035
|
+
await open_default(response.authUrl);
|
|
42036
|
+
return true;
|
|
42037
|
+
}, signal);
|
|
41947
42038
|
}
|
|
41948
42039
|
/**
|
|
41949
42040
|
* Reads with a token refresh whether the agent has a ChatGPT login that a new login does not need to replace.
|
|
@@ -41969,56 +42060,27 @@ var CodexAcpClient = class _CodexAcpClient {
|
|
|
41969
42060
|
throw error62;
|
|
41970
42061
|
}
|
|
41971
42062
|
}
|
|
41972
|
-
async authenticateWithChatGptDeviceCode(urlElicitationRequester) {
|
|
42063
|
+
async authenticateWithChatGptDeviceCode(urlElicitationRequester, signal) {
|
|
41973
42064
|
if (await this.hasWorkingChatGptLogin()) {
|
|
42065
|
+
throwIfRequestCancelled(signal);
|
|
41974
42066
|
return true;
|
|
41975
42067
|
}
|
|
41976
42068
|
if (!urlElicitationRequester) {
|
|
41977
42069
|
throw RequestError.invalidRequest(void 0, "Device code authentication requires URL elicitation support");
|
|
41978
42070
|
}
|
|
41979
|
-
const loginCompletedPromise = this.awaitNextLoginCompleted();
|
|
41980
|
-
loginCompletedPromise.catch(() => {
|
|
41981
|
-
});
|
|
41982
|
-
const loginResponse = await this.codexClient.accountLogin({ type: "chatgptDeviceCode" });
|
|
41983
|
-
if (loginResponse.type !== "chatgptDeviceCode") {
|
|
41984
|
-
return false;
|
|
41985
|
-
}
|
|
41986
|
-
const elicitationResponsePromise = Promise.resolve(urlElicitationRequester.elicitUrl({
|
|
41987
|
-
url: loginResponse.verificationUrl,
|
|
41988
|
-
message: `Sign in to ChatGPT and enter this code: ${loginResponse.userCode}`,
|
|
41989
|
-
elicitationId: loginResponse.loginId
|
|
41990
|
-
}));
|
|
41991
42071
|
try {
|
|
41992
|
-
|
|
41993
|
-
|
|
41994
|
-
|
|
41995
|
-
|
|
41996
|
-
|
|
41997
|
-
|
|
41998
|
-
type: "elicitationResponse",
|
|
41999
|
-
response
|
|
42000
|
-
}))
|
|
42001
|
-
]);
|
|
42002
|
-
if (first.type === "loginCompleted") {
|
|
42003
|
-
await urlElicitationRequester.completeElicitation();
|
|
42004
|
-
return first.result.success;
|
|
42005
|
-
}
|
|
42006
|
-
if (!CreateElicitationResponse.isAccept(first.response)) {
|
|
42007
|
-
await this.codexClient.accountLoginCancel({ loginId: loginResponse.loginId });
|
|
42008
|
-
throw RequestError.requestCancelled(
|
|
42009
|
-
{ methodId: "chat-gpt-device-code", action: first.response.action },
|
|
42010
|
-
"ChatGPT device code sign-in was cancelled"
|
|
42011
|
-
);
|
|
42012
|
-
}
|
|
42013
|
-
const result = await loginCompletedPromise;
|
|
42014
|
-
await urlElicitationRequester.completeElicitation();
|
|
42015
|
-
return result.success;
|
|
42016
|
-
} catch (error62) {
|
|
42017
|
-
if (this.codexClient.connectionLoss.lost) {
|
|
42018
|
-
await Promise.resolve(urlElicitationRequester.completeElicitation()).catch(() => {
|
|
42072
|
+
return await runAccountLogin(this.codexClient, { type: "chatgptDeviceCode" }, async (response) => {
|
|
42073
|
+
if (response.type !== "chatgptDeviceCode") return false;
|
|
42074
|
+
const answer = await urlElicitationRequester.elicitUrl({
|
|
42075
|
+
url: response.verificationUrl,
|
|
42076
|
+
message: `Sign in to ChatGPT and enter this code: ${response.userCode}`,
|
|
42077
|
+
elicitationId: response.loginId
|
|
42019
42078
|
});
|
|
42020
|
-
|
|
42021
|
-
|
|
42079
|
+
return CreateElicitationResponse.isAccept(answer);
|
|
42080
|
+
}, signal);
|
|
42081
|
+
} finally {
|
|
42082
|
+
await urlElicitationRequester.completeElicitation().catch(() => {
|
|
42083
|
+
});
|
|
42022
42084
|
}
|
|
42023
42085
|
}
|
|
42024
42086
|
authenticateWithGateway(authRequest) {
|
|
@@ -42871,20 +42933,6 @@ var CodexAcpClient = class _CodexAcpClient {
|
|
|
42871
42933
|
async listSkills(params) {
|
|
42872
42934
|
return withoutUnsupportedSkills(await this.codexClient.listSkills(params ?? {}));
|
|
42873
42935
|
}
|
|
42874
|
-
async awaitNextLoginCompleted() {
|
|
42875
|
-
if (this.pendingLoginCompleted !== null) {
|
|
42876
|
-
return await this.pendingLoginCompleted;
|
|
42877
|
-
}
|
|
42878
|
-
this.pendingLoginCompleted = this.awaitSingleNotification(
|
|
42879
|
-
"account/login/completed",
|
|
42880
|
-
(event) => event
|
|
42881
|
-
);
|
|
42882
|
-
try {
|
|
42883
|
-
return await this.pendingLoginCompleted;
|
|
42884
|
-
} finally {
|
|
42885
|
-
this.pendingLoginCompleted = null;
|
|
42886
|
-
}
|
|
42887
|
-
}
|
|
42888
42936
|
async awaitNextAccountUpdated() {
|
|
42889
42937
|
if (this.pendingAccountUpdated !== null) {
|
|
42890
42938
|
return await this.pendingAccountUpdated;
|
|
@@ -50017,6 +50065,7 @@ var CodexAcpServer = class {
|
|
|
50017
50065
|
mcpServerSignIn;
|
|
50018
50066
|
clientDelivery;
|
|
50019
50067
|
setupResponseOrdering = false;
|
|
50068
|
+
initializeResponseDelivery = "direct";
|
|
50020
50069
|
/** ACP protocol version of the connection this agent serves, fixed by the protocol router. */
|
|
50021
50070
|
protocolVersion;
|
|
50022
50071
|
/** The v2 client handle; `null` on a v1 connection. */
|
|
@@ -50206,7 +50255,7 @@ var CodexAcpServer = class {
|
|
|
50206
50255
|
async readSubagentConfiguration(threadId, parentThreadId) {
|
|
50207
50256
|
const thread = await this.codexAcpClient.readSubagentThread(threadId);
|
|
50208
50257
|
if (!thread || thread.id !== threadId || thread.parentThreadId !== parentThreadId || thread.status.type === "notLoaded") return null;
|
|
50209
|
-
return { model: thread.model, effort: thread.reasoningEffort };
|
|
50258
|
+
return { model: thread.model, effort: thread.reasoningEffort, cwd: thread.cwd };
|
|
50210
50259
|
}
|
|
50211
50260
|
getSubagentInteractionHandlers(router, rootSessionId) {
|
|
50212
50261
|
const existing = this.subagentInteractionHandlers.get(router);
|
|
@@ -51534,41 +51583,53 @@ You have been logged out. Please try again.`);
|
|
|
51534
51583
|
...this.createSessionSetupResponseV2(this.getSessionState(sessionId))
|
|
51535
51584
|
};
|
|
51536
51585
|
}
|
|
51537
|
-
async authenticate(_params, requestId) {
|
|
51586
|
+
async authenticate(_params, requestId, signal) {
|
|
51538
51587
|
logger.log("Authenticate request received");
|
|
51588
|
+
throwIfRequestCancelled(signal);
|
|
51539
51589
|
const appServer = this.ensureAppServer();
|
|
51540
|
-
if (appServer) await appServer;
|
|
51541
|
-
const elicitationRequester = this.createUrlElicitationRequester(requestId);
|
|
51542
|
-
|
|
51543
|
-
|
|
51544
|
-
|
|
51545
|
-
|
|
51546
|
-
|
|
51547
|
-
|
|
51548
|
-
|
|
51549
|
-
|
|
51590
|
+
if (appServer) await withRequestCancellation(appServer, signal);
|
|
51591
|
+
const elicitationRequester = this.createUrlElicitationRequester(requestId, signal);
|
|
51592
|
+
try {
|
|
51593
|
+
const isAuthenticated = await this.runWithProcessCheck(() => this.codexAcpClient.authenticate(_params, elicitationRequester, signal));
|
|
51594
|
+
throwIfRequestCancelled(signal);
|
|
51595
|
+
if (!isAuthenticated) {
|
|
51596
|
+
logger.log("Authenticate request failed");
|
|
51597
|
+
throw RequestError.authRequired({ methodId: _params.methodId }, "Sign-in did not complete");
|
|
51598
|
+
}
|
|
51599
|
+
await withRequestCancellation(this.refreshAuthState(this.getAuthProviderForAuthenticateRequest(_params)), signal);
|
|
51600
|
+
logger.log("Authenticate request completed");
|
|
51601
|
+
return {};
|
|
51602
|
+
} finally {
|
|
51603
|
+
await elicitationRequester?.completeElicitation().catch(() => {
|
|
51604
|
+
});
|
|
51605
|
+
}
|
|
51550
51606
|
}
|
|
51551
|
-
createUrlElicitationRequester(requestId) {
|
|
51607
|
+
createUrlElicitationRequester(requestId, signal) {
|
|
51552
51608
|
if (requestId == null || !clientSupportsUrlElicitation(this.clientCapabilities)) {
|
|
51553
51609
|
return void 0;
|
|
51554
51610
|
}
|
|
51611
|
+
const lifetime = new AbortController();
|
|
51612
|
+
const cancellationSignal = signal ? AbortSignal.any([signal, lifetime.signal]) : lifetime.signal;
|
|
51555
51613
|
let elicitationId = null;
|
|
51556
51614
|
return {
|
|
51557
|
-
elicitUrl: (request) => {
|
|
51615
|
+
elicitUrl: async (request) => {
|
|
51558
51616
|
elicitationId = request.elicitationId;
|
|
51559
|
-
|
|
51617
|
+
const response = await this.connection.request(methods.client.elicitation.create, {
|
|
51560
51618
|
mode: "url",
|
|
51561
51619
|
requestId,
|
|
51562
51620
|
...request
|
|
51563
|
-
});
|
|
51621
|
+
}, { cancellationSignal });
|
|
51622
|
+
if (!CreateElicitationResponse.isAccept(response)) elicitationId = null;
|
|
51623
|
+
return response;
|
|
51564
51624
|
},
|
|
51565
51625
|
completeElicitation: async () => {
|
|
51566
51626
|
if (elicitationId === null) {
|
|
51567
51627
|
return;
|
|
51568
51628
|
}
|
|
51569
|
-
|
|
51570
|
-
|
|
51571
|
-
|
|
51629
|
+
const completedId = elicitationId;
|
|
51630
|
+
elicitationId = null;
|
|
51631
|
+
lifetime.abort();
|
|
51632
|
+
await this.connection.notify(methods.client.elicitation.complete, { elicitationId: completedId });
|
|
51572
51633
|
}
|
|
51573
51634
|
};
|
|
51574
51635
|
}
|
|
@@ -51581,11 +51642,11 @@ You have been logged out. Please try again.`);
|
|
|
51581
51642
|
logger.log("Logout request completed");
|
|
51582
51643
|
}
|
|
51583
51644
|
/** v2 `auth/login`: same params as v1 `authenticate`, only the method name changed. */
|
|
51584
|
-
async authenticateV2(params, requestId) {
|
|
51645
|
+
async authenticateV2(params, requestId, signal) {
|
|
51585
51646
|
if (!getCodexAuthMethodsV2(this.clientCapabilities).some((method) => method.methodId === params.methodId)) {
|
|
51586
51647
|
throw RequestError.invalidParams(void 0, `Unsupported authentication method: ${params.methodId}`);
|
|
51587
51648
|
}
|
|
51588
|
-
return await this.authenticate(params, requestId);
|
|
51649
|
+
return await this.authenticate(params, requestId, signal);
|
|
51589
51650
|
}
|
|
51590
51651
|
/** v2 `auth/logout`: same params as v1 `logout`, only the method name changed. */
|
|
51591
51652
|
async logoutV2(params) {
|
|
@@ -51848,16 +51909,23 @@ You have been logged out. Please try again.`);
|
|
|
51848
51909
|
* Schedules the connection's first `_auth/status_update`: one account read,
|
|
51849
51910
|
* pushed whatever it says, including `none`.
|
|
51850
51911
|
*
|
|
51851
|
-
*
|
|
51852
|
-
*
|
|
51853
|
-
* the read starts from a check-phase callback, which always runs after it.
|
|
51854
|
-
* `initialize` itself never waits for the read.
|
|
51912
|
+
* Routed connections publish at the response-write boundary. Direct callers
|
|
51913
|
+
* have no transport boundary, so they retain the asynchronous fallback.
|
|
51855
51914
|
*
|
|
51856
51915
|
* "Unconditional" costs nothing extra here: nothing has been pushed yet on
|
|
51857
51916
|
* this connection, so {@link setAuthStatus} cannot suppress this one.
|
|
51858
51917
|
*/
|
|
51859
51918
|
publishFirstAuthStatusAfterResponse() {
|
|
51860
|
-
|
|
51919
|
+
if (this.initializeResponseDelivery === "direct") {
|
|
51920
|
+
setImmediate(() => void this.publishAuthStatusRead());
|
|
51921
|
+
}
|
|
51922
|
+
}
|
|
51923
|
+
observeInitializeResponse() {
|
|
51924
|
+
this.initializeResponseDelivery = "pending";
|
|
51925
|
+
}
|
|
51926
|
+
afterInitializeResponse() {
|
|
51927
|
+
this.initializeResponseDelivery = "written";
|
|
51928
|
+
void this.publishAuthStatusRead();
|
|
51861
51929
|
}
|
|
51862
51930
|
/**
|
|
51863
51931
|
* Reads the agent-owned identity and pushes it.
|
|
@@ -51941,6 +52009,7 @@ You have been logged out. Please try again.`);
|
|
|
51941
52009
|
*/
|
|
51942
52010
|
async applyAccountUpdated(notification) {
|
|
51943
52011
|
this.lastReadAccount = accountFromUpdated(notification, this.lastReadAccount);
|
|
52012
|
+
if (this.initializeResponseDelivery === "pending") return;
|
|
51944
52013
|
try {
|
|
51945
52014
|
if (this.codexAcpClient.getAuthGatewayProviderName() !== null) {
|
|
51946
52015
|
return;
|
|
@@ -51971,6 +52040,7 @@ You have been logged out. Please try again.`);
|
|
|
51971
52040
|
*/
|
|
51972
52041
|
async setAuthStatus(next) {
|
|
51973
52042
|
this.authStatusVersion += 1;
|
|
52043
|
+
if (this.initializeResponseDelivery === "pending") return;
|
|
51974
52044
|
if (sameAuthStatus(this.currentAuthStatus, next)) {
|
|
51975
52045
|
return;
|
|
51976
52046
|
}
|
|
@@ -54865,6 +54935,7 @@ function createRouter(createAgent, responses) {
|
|
|
54865
54935
|
};
|
|
54866
54936
|
const attachAgent = (agent3, signal) => {
|
|
54867
54937
|
codexAcpServer = agent3;
|
|
54938
|
+
agent3.observeInitializeResponse();
|
|
54868
54939
|
const stopSetupPublication = agent3.observeSessionSetupResponses();
|
|
54869
54940
|
signal.addEventListener("abort", () => {
|
|
54870
54941
|
setups.clear();
|
|
@@ -54875,8 +54946,16 @@ function createRouter(createAgent, responses) {
|
|
|
54875
54946
|
}
|
|
54876
54947
|
});
|
|
54877
54948
|
};
|
|
54878
|
-
const
|
|
54879
|
-
|
|
54949
|
+
const initialize = async (requestId, operation) => {
|
|
54950
|
+
const agent3 = getAgent();
|
|
54951
|
+
const result = await operation();
|
|
54952
|
+
responses.afterWrite(requestId, (successful) => {
|
|
54953
|
+
if (successful) agent3.afterInitializeResponse();
|
|
54954
|
+
});
|
|
54955
|
+
return result;
|
|
54956
|
+
};
|
|
54957
|
+
const v1Agent = agent({ name: package_default.name }).onConnect((connection) => attachAgent(createAgent(connection.client), connection.signal)).onRequest(methods.agent.initialize, (ctx) => initialize(ctx.requestId, () => getAgent().initialize(ctx.params))).onRequest(methods.agent.session.new, (ctx) => createdSetup(ctx.requestId, () => getAgentForPaths(ctx.params).newSession(ctx.params))).onRequest(methods.agent.session.load, (ctx) => setup(ctx.params.sessionId, ctx.requestId, () => getAgentForPaths(ctx.params).loadSession(ctx.params), ctx.signal)).onRequest(methods.agent.session.fork, (ctx) => createdSetup(ctx.requestId, () => getAgentForPaths(ctx.params).forkSession(ctx.params))).onRequest(methods.agent.session.list, (ctx) => getAgentForPaths({ cwd: ctx.params.cwd ?? null }).listSessions(ctx.params)).onRequest(methods.agent.session.delete, (ctx) => getAgent(ctx.params).deleteSession(ctx.params)).onRequest(methods.agent.session.resume, (ctx) => setup(ctx.params.sessionId, ctx.requestId, () => getAgentForPaths(ctx.params).resumeSession(ctx.params), ctx.signal)).onRequest(methods.agent.session.close, (ctx) => getAgent(ctx.params).closeSession(ctx.params)).onRequest(methods.agent.session.setMode, (ctx) => getAgent(ctx.params).setSessionMode(ctx.params)).onRequest(methods.agent.session.setConfigOption, (ctx) => getAgent(ctx.params).setSessionConfigOption(ctx.params)).onRequest(methods.agent.authenticate, (ctx) => getAgent().authenticate(ctx.params, ctx.requestId, ctx.signal)).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(ctx.params).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(ctx.params).extMethod(LEGACY_SET_SESSION_MODEL_METHOD, ctx.params)).onRequest(SESSION_STEERING_METHOD, sessionSteerParamsParser, (ctx) => getAgent(ctx.params).extMethod(SESSION_STEERING_METHOD, ctx.params)).onRequest(ASYNC_TASK_STOP_METHOD, asyncTaskStopParamsParser, (ctx) => getAgent(ctx.params).extMethod(ASYNC_TASK_STOP_METHOD, ctx.params)).onRequest(CODEX_HOOKS_LIST_METHOD, hooksListParamsParser, (ctx) => getAgent().listHooks(ctx.params.cwd)).onRequest(CODEX_HOOKS_TRUST_METHOD, hooksTrustParamsParser, (ctx) => getAgent().trustHooks(ctx.params.cwd, ctx.params.hooks)).onRequest(GOAL_CONTROL_METHOD, goalControlParamsParser, (ctx) => getAgent(ctx.params).extMethod(GOAL_CONTROL_METHOD, ctx.params)).onRequest(SESSION_RENAME_METHOD, sessionRenameParamsParser, (ctx) => getAgent(ctx.params).sessionIndex.rename(ctx.params)).onRequest(SESSION_BATCH_GET_METHOD, sessionBatchGetParamsParser, (ctx) => getAgent().sessionIndex.batchGet(ctx.params)).onRequest(SESSION_ARCHIVE_METHOD, sessionArchiveParamsParser, (ctx) => getAgent(ctx.params).sessionIndex.setArchived(ctx.params, true)).onRequest(SESSION_UNARCHIVE_METHOD, sessionArchiveParamsParser, (ctx) => getAgent(ctx.params).sessionIndex.setArchived(ctx.params, false)).onRequest(SESSION_LIST_SUBSCRIBE_METHOD, sessionListSubscriptionParamsParser, (ctx) => getAgent().sessionIndex.subscribeList(ctx.params)).onRequest(SESSION_LIST_UNSUBSCRIBE_METHOD, sessionListSubscriptionParamsParser, (ctx) => getAgent().sessionIndex.unsubscribeList(ctx.params));
|
|
54958
|
+
const v2Agent = agent2({ name: package_default.name }).onConnect((connection) => attachAgent(createAgent(new AcpV2Connection(connection.client)), connection.signal)).onRequest(methods2.agent.initialize, (ctx) => initialize(ctx.requestId, () => getAgent().initializeV2(ctx.params))).onRequest(methods2.agent.session.new, (ctx) => createdSetup(ctx.requestId, () => getAgentForPaths(ctx.params).newSessionV2(ctx.params))).onRequest(methods2.agent.session.list, (ctx) => getAgentForPaths({ cwd: ctx.params.cwd ?? null }).listSessions(ctx.params)).onRequest(methods2.agent.session.delete, (ctx) => getAgent(ctx.params).deleteSession(ctx.params)).onRequest(methods2.agent.session.resume, (ctx) => setup(ctx.params.sessionId, ctx.requestId, () => getAgentForPaths(ctx.params).resumeSessionV2(ctx.params), ctx.signal)).onRequest(methods2.agent.session.fork, (ctx) => createdSetup(ctx.requestId, () => getAgentForPaths(ctx.params).forkSessionV2(ctx.params))).onRequest(methods2.agent.session.close, (ctx) => getAgent(ctx.params).closeSession(ctx.params)).onRequest(methods2.agent.session.setConfigOption, (ctx) => getAgent(ctx.params).setSessionConfigOptionV2(ctx.params)).onRequest(methods2.agent.auth.login, (ctx) => getAgent().authenticateV2(ctx.params, ctx.requestId, ctx.signal)).onRequest(methods2.agent.auth.logout, (ctx) => getAgent().logoutV2(ctx.params)).onRequest(methods2.agent.session.prompt, (ctx) => getAgent(ctx.params).promptV2(ctx.params, ctx.signal)).onNotification(methods2.agent.session.cancel, (ctx) => getAgent().cancel(ctx.params)).onRequest(methods2.agent.providers.list, (ctx) => getAgent().listProviders(ctx.params)).onRequest(methods2.agent.providers.set, (ctx) => getAgent().setProvider(ctx.params)).onRequest(methods2.agent.providers.disable, (ctx) => getAgent().disableProvider(ctx.params)).onRequest(SESSION_STEERING_METHOD, sessionSteerParamsParser, (ctx) => getAgent(ctx.params).extMethod(SESSION_STEERING_METHOD, ctx.params)).onRequest(GOAL_CONTROL_METHOD, goalControlParamsParser, (ctx) => getAgent(ctx.params).extMethod(GOAL_CONTROL_METHOD, ctx.params)).onRequest(ASYNC_TASK_STOP_METHOD, asyncTaskStopParamsParser, (ctx) => getAgent(ctx.params).extMethod(ASYNC_TASK_STOP_METHOD, ctx.params)).onRequest(SESSION_RENAME_METHOD, sessionRenameParamsParser, (ctx) => getAgent(ctx.params).sessionIndex.rename(ctx.params)).onRequest(SESSION_BATCH_GET_METHOD, sessionBatchGetParamsParser, (ctx) => getAgent().sessionIndex.batchGet(ctx.params)).onRequest(SESSION_ARCHIVE_METHOD, sessionArchiveParamsParser, (ctx) => getAgent(ctx.params).sessionIndex.setArchived(ctx.params, true)).onRequest(SESSION_UNARCHIVE_METHOD, sessionArchiveParamsParser, (ctx) => getAgent(ctx.params).sessionIndex.setArchived(ctx.params, false)).onRequest(SESSION_LIST_SUBSCRIBE_METHOD, sessionListSubscriptionParamsParser, (ctx) => getAgent().sessionIndex.subscribeList(ctx.params)).onRequest(SESSION_LIST_UNSUBSCRIBE_METHOD, sessionListSubscriptionParamsParser, (ctx) => getAgent().sessionIndex.unsubscribeList(ctx.params));
|
|
54880
54959
|
return agentProtocolRouter().withV1(v1Agent).withV2(v2Agent);
|
|
54881
54960
|
}
|
|
54882
54961
|
|