@agentclientprotocol/codex-acp 2.5.1-preview.7 → 2.5.1-preview.8
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 +139 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32522,6 +32522,7 @@ var AcpClientDelivery = class {
|
|
|
32522
32522
|
sessionRequests = /* @__PURE__ */ new Map();
|
|
32523
32523
|
closedSessions = /* @__PURE__ */ new Set();
|
|
32524
32524
|
urlElicitations = /* @__PURE__ */ new Map();
|
|
32525
|
+
sessionSetups = /* @__PURE__ */ new Map();
|
|
32525
32526
|
sendElicitationCompletion;
|
|
32526
32527
|
/** v2's direct send path shares URL scope tracking without routing back through its v1 view. */
|
|
32527
32528
|
setElicitationCompletionTransport(send) {
|
|
@@ -32534,9 +32535,56 @@ var AcpClientDelivery = class {
|
|
|
32534
32535
|
openSession(sessionId) {
|
|
32535
32536
|
this.closedSessions.delete(sessionId);
|
|
32536
32537
|
}
|
|
32538
|
+
/** A new session cannot open client UI until its setup response has been written. */
|
|
32539
|
+
beginSessionSetup(sessionId) {
|
|
32540
|
+
if (this.sessionSetups.has(sessionId)) return;
|
|
32541
|
+
let release;
|
|
32542
|
+
const ready = new Promise((resolve) => {
|
|
32543
|
+
release = resolve;
|
|
32544
|
+
});
|
|
32545
|
+
this.sessionSetups.set(sessionId, { ready, release });
|
|
32546
|
+
}
|
|
32547
|
+
sessionSetupReady(sessionId) {
|
|
32548
|
+
return this.sessionSetups.get(sessionId)?.ready ?? null;
|
|
32549
|
+
}
|
|
32550
|
+
captureSessionSetupRelease(sessionId) {
|
|
32551
|
+
const setup = this.sessionSetups.get(sessionId);
|
|
32552
|
+
return () => {
|
|
32553
|
+
if (setup && this.sessionSetups.get(sessionId) === setup) this.finishSessionSetup(sessionId);
|
|
32554
|
+
};
|
|
32555
|
+
}
|
|
32556
|
+
finishSessionSetup(sessionId) {
|
|
32557
|
+
const setup = this.sessionSetups.get(sessionId);
|
|
32558
|
+
this.sessionSetups.delete(sessionId);
|
|
32559
|
+
setup?.release();
|
|
32560
|
+
}
|
|
32561
|
+
waitForSessionSetup(sessionId, signal) {
|
|
32562
|
+
const ready = this.sessionSetupReady(sessionId);
|
|
32563
|
+
if (!ready) return null;
|
|
32564
|
+
return new Promise((resolve, reject) => {
|
|
32565
|
+
const cancelled = () => reject(RequestError.requestCancelled(void 0, `Session ${sessionId} setup was cancelled`));
|
|
32566
|
+
if (signal?.aborted) {
|
|
32567
|
+
cancelled();
|
|
32568
|
+
return;
|
|
32569
|
+
}
|
|
32570
|
+
signal?.addEventListener("abort", cancelled, { once: true });
|
|
32571
|
+
void ready.then(() => {
|
|
32572
|
+
signal?.removeEventListener("abort", cancelled);
|
|
32573
|
+
if (signal?.aborted || !this.canRequestSession(sessionId)) cancelled();
|
|
32574
|
+
else resolve();
|
|
32575
|
+
});
|
|
32576
|
+
});
|
|
32577
|
+
}
|
|
32578
|
+
disposeSessionSetups() {
|
|
32579
|
+
for (const sessionId of this.sessionSetups.keys()) {
|
|
32580
|
+
this.closedSessions.add(sessionId);
|
|
32581
|
+
this.cancelSessionRequests(sessionId);
|
|
32582
|
+
}
|
|
32583
|
+
}
|
|
32537
32584
|
/** Final teardown updates have been sent. Nothing else may publish for this session lifetime. */
|
|
32538
32585
|
closeSession(sessionId) {
|
|
32539
32586
|
this.closedSessions.add(sessionId);
|
|
32587
|
+
this.finishSessionSetup(sessionId);
|
|
32540
32588
|
for (const [id, scope] of this.urlElicitations) {
|
|
32541
32589
|
if (scope.sessionId === sessionId) this.urlElicitations.delete(id);
|
|
32542
32590
|
}
|
|
@@ -32590,10 +32638,11 @@ var AcpClientDelivery = class {
|
|
|
32590
32638
|
for (const controller of this.sessionRequests.get(sessionId) ?? []) {
|
|
32591
32639
|
controller.abort(RequestError.requestCancelled(void 0, `Session ${sessionId} is closing`));
|
|
32592
32640
|
}
|
|
32641
|
+
this.finishSessionSetup(sessionId);
|
|
32593
32642
|
}
|
|
32594
32643
|
sendRequest(method, params, options) {
|
|
32595
32644
|
const sessionId = clientRequestSessionId(method, params);
|
|
32596
|
-
return this.withElicitationRequest(method, params, () =>
|
|
32645
|
+
return sessionId === null ? this.withElicitationRequest(method, params, () => this.client.request(method, params, options)) : this.sendSessionRequest(sessionId, method, params, options);
|
|
32597
32646
|
}
|
|
32598
32647
|
/** Direct v2 requests and the shared v1-shaped path keep the same URL scope. */
|
|
32599
32648
|
withElicitationRequest(method, params, send) {
|
|
@@ -32623,7 +32672,13 @@ var AcpClientDelivery = class {
|
|
|
32623
32672
|
requests.add(controller);
|
|
32624
32673
|
const cancellationSignal = options?.cancellationSignal ? AbortSignal.any([options.cancellationSignal, controller.signal]) : controller.signal;
|
|
32625
32674
|
try {
|
|
32626
|
-
|
|
32675
|
+
const setup = this.waitForSessionSetup(sessionId, cancellationSignal);
|
|
32676
|
+
if (setup) await setup;
|
|
32677
|
+
return await this.withElicitationRequest(
|
|
32678
|
+
method,
|
|
32679
|
+
params,
|
|
32680
|
+
() => this.client.request(method, params, { ...options, cancellationSignal })
|
|
32681
|
+
);
|
|
32627
32682
|
} finally {
|
|
32628
32683
|
requests.delete(controller);
|
|
32629
32684
|
if (requests.size === 0) this.sessionRequests.delete(sessionId);
|
|
@@ -32679,8 +32734,12 @@ var AcpV2Connection = class {
|
|
|
32679
32734
|
if (sessionId !== null && this.sessionDelivery && !this.sessionDelivery.canRequestSession(sessionId)) {
|
|
32680
32735
|
return Promise.reject(RequestError.requestCancelled(void 0, `Session ${sessionId} is closing or closed`));
|
|
32681
32736
|
}
|
|
32682
|
-
const send = () =>
|
|
32683
|
-
|
|
32737
|
+
const send = () => {
|
|
32738
|
+
const request = () => client.request(method, params, options);
|
|
32739
|
+
return this.sessionDelivery?.withElicitationRequest(method, params, request) ?? request();
|
|
32740
|
+
};
|
|
32741
|
+
const setup = sessionId === null ? null : this.sessionDelivery?.waitForSessionSetup(sessionId, options?.cancellationSignal);
|
|
32742
|
+
return setup ? setup.then(send) : send();
|
|
32684
32743
|
}
|
|
32685
32744
|
};
|
|
32686
32745
|
}
|
|
@@ -40012,6 +40071,16 @@ function failure2(serverName, message) {
|
|
|
40012
40071
|
|
|
40013
40072
|
// src/mcp/McpSessionStartup.ts
|
|
40014
40073
|
var McpSessionStartup = class {
|
|
40074
|
+
constructor(connection, codexAcpClient, runWithProcessCheck, signIn, capabilities, isSessionOpen, waitForSessionSetup = () => null) {
|
|
40075
|
+
this.waitForSessionSetup = waitForSessionSetup;
|
|
40076
|
+
this.connection = connection;
|
|
40077
|
+
this.codexAcpClient = codexAcpClient;
|
|
40078
|
+
this.runWithProcessCheck = runWithProcessCheck;
|
|
40079
|
+
this.signIn = signIn;
|
|
40080
|
+
this.capabilities = capabilities;
|
|
40081
|
+
this.isSessionOpen = isSessionOpen;
|
|
40082
|
+
}
|
|
40083
|
+
waitForSessionSetup;
|
|
40015
40084
|
connection;
|
|
40016
40085
|
codexAcpClient;
|
|
40017
40086
|
runWithProcessCheck;
|
|
@@ -40020,14 +40089,6 @@ var McpSessionStartup = class {
|
|
|
40020
40089
|
/** True when the session is open and does not close. */
|
|
40021
40090
|
isSessionOpen;
|
|
40022
40091
|
pendingSessions = /* @__PURE__ */ new Map();
|
|
40023
|
-
constructor(connection, codexAcpClient, runWithProcessCheck, signIn, capabilities, isSessionOpen) {
|
|
40024
|
-
this.connection = connection;
|
|
40025
|
-
this.codexAcpClient = codexAcpClient;
|
|
40026
|
-
this.runWithProcessCheck = runWithProcessCheck;
|
|
40027
|
-
this.signIn = signIn;
|
|
40028
|
-
this.capabilities = capabilities;
|
|
40029
|
-
this.isSessionOpen = isSessionOpen;
|
|
40030
|
-
}
|
|
40031
40092
|
/**
|
|
40032
40093
|
* Starts the startup wait of the session and publishes the report when the startup ends.
|
|
40033
40094
|
* It returns a promise only when it waits for the startup, and returns null otherwise.
|
|
@@ -40055,6 +40116,9 @@ var McpSessionStartup = class {
|
|
|
40055
40116
|
this.pendingSessions.get(sessionId)?.abort.abort();
|
|
40056
40117
|
this.pendingSessions.delete(sessionId);
|
|
40057
40118
|
}
|
|
40119
|
+
dispose() {
|
|
40120
|
+
for (const sessionId of this.pendingSessions.keys()) this.close(sessionId);
|
|
40121
|
+
}
|
|
40058
40122
|
isPending(sessionId) {
|
|
40059
40123
|
return this.pendingSessions.has(sessionId);
|
|
40060
40124
|
}
|
|
@@ -40092,6 +40156,8 @@ var McpSessionStartup = class {
|
|
|
40092
40156
|
}
|
|
40093
40157
|
try {
|
|
40094
40158
|
const mcpStartup = await pendingStartup.startup;
|
|
40159
|
+
const setup = this.waitForSessionSetup(sessionId, pendingStartup.abort.signal);
|
|
40160
|
+
if (setup) await setup;
|
|
40095
40161
|
if (!this.isSessionOpen(sessionId) || this.pendingSessions.get(sessionId) !== pendingStartup) {
|
|
40096
40162
|
return;
|
|
40097
40163
|
}
|
|
@@ -40998,7 +41064,7 @@ var package_default = {
|
|
|
40998
41064
|
publishConfig: {
|
|
40999
41065
|
access: "public"
|
|
41000
41066
|
},
|
|
41001
|
-
version: "2.5.1-preview.
|
|
41067
|
+
version: "2.5.1-preview.8",
|
|
41002
41068
|
description: "",
|
|
41003
41069
|
main: "dist/index.js",
|
|
41004
41070
|
bin: {
|
|
@@ -49761,6 +49827,7 @@ var CodexAcpServer = class {
|
|
|
49761
49827
|
connection;
|
|
49762
49828
|
mcpServerSignIn;
|
|
49763
49829
|
clientDelivery;
|
|
49830
|
+
setupResponseOrdering = false;
|
|
49764
49831
|
/** ACP protocol version of the connection this agent serves, fixed by the protocol router. */
|
|
49765
49832
|
protocolVersion;
|
|
49766
49833
|
/** The v2 client handle; `null` on a v1 connection. */
|
|
@@ -49884,7 +49951,8 @@ var CodexAcpServer = class {
|
|
|
49884
49951
|
(operation) => this.runWithProcessCheck(operation),
|
|
49885
49952
|
this.mcpServerSignIn,
|
|
49886
49953
|
() => this.capabilities,
|
|
49887
|
-
(sessionId) => this.sessions.has(sessionId) && !this.sessionIsClosing(sessionId)
|
|
49954
|
+
(sessionId) => this.sessions.has(sessionId) && !this.sessionIsClosing(sessionId),
|
|
49955
|
+
(sessionId, signal) => this.clientDelivery.waitForSessionSetup(sessionId, signal)
|
|
49888
49956
|
);
|
|
49889
49957
|
this.defaultAuthRequest = defaultAuthRequest ?? null;
|
|
49890
49958
|
this.codexProcessState = codexProcessState ?? null;
|
|
@@ -49924,6 +49992,10 @@ var CodexAcpServer = class {
|
|
|
49924
49992
|
const state = this.sessions.get(sessionId);
|
|
49925
49993
|
return state ? this.subagentModels(state) : null;
|
|
49926
49994
|
};
|
|
49995
|
+
const setupReady = this.clientDelivery.sessionSetupReady(sessionId);
|
|
49996
|
+
const transition = this.sessions.get(sessionId)?.subagentTransition;
|
|
49997
|
+
const ready = setupReady ? Promise.all([setupReady, transition]).then(() => {
|
|
49998
|
+
}) : transition;
|
|
49927
49999
|
const router = this.usesStandardSubagents() ? new StandardSubagentEventRouter(
|
|
49928
50000
|
sessionId,
|
|
49929
50001
|
session,
|
|
@@ -49931,7 +50003,7 @@ var CodexAcpServer = class {
|
|
|
49931
50003
|
release,
|
|
49932
50004
|
this.capabilities,
|
|
49933
50005
|
replay,
|
|
49934
|
-
|
|
50006
|
+
ready,
|
|
49935
50007
|
(id) => this.codexAcpClient.appServerClient.runningTurnId(id),
|
|
49936
50008
|
models,
|
|
49937
50009
|
{
|
|
@@ -50000,13 +50072,30 @@ var CodexAcpServer = class {
|
|
|
50000
50072
|
check2();
|
|
50001
50073
|
return check2;
|
|
50002
50074
|
}
|
|
50003
|
-
|
|
50004
|
-
|
|
50005
|
-
|
|
50006
|
-
|
|
50007
|
-
|
|
50008
|
-
|
|
50009
|
-
}
|
|
50075
|
+
/** Direct method callers have no transport response-write boundary. */
|
|
50076
|
+
observeSessionSetupResponses() {
|
|
50077
|
+
this.setupResponseOrdering = true;
|
|
50078
|
+
return () => {
|
|
50079
|
+
this.mcpSessionStartup.dispose();
|
|
50080
|
+
this.clientDelivery.disposeSessionSetups();
|
|
50081
|
+
};
|
|
50082
|
+
}
|
|
50083
|
+
captureSessionCreationPublication(sessionId) {
|
|
50084
|
+
return this.clientDelivery.captureSessionSetupRelease(sessionId);
|
|
50085
|
+
}
|
|
50086
|
+
captureSessionSetupPublication(sessionId) {
|
|
50087
|
+
const session = this.sessions.get(sessionId);
|
|
50088
|
+
const release = this.clientDelivery.captureSessionSetupRelease(sessionId);
|
|
50089
|
+
return async () => {
|
|
50090
|
+
release();
|
|
50091
|
+
if (!session || this.sessions.get(sessionId) !== session || this.sessionIsClosing(sessionId)) return;
|
|
50092
|
+
const router = session.subagents;
|
|
50093
|
+
if (!(router instanceof StandardSubagentEventRouter)) return;
|
|
50094
|
+
this.codexAcpClient.redispatchSessionNotifications(sessionId, router.releaseReplay(), () => router.publishReplaySnapshots());
|
|
50095
|
+
await this.codexAcpClient.waitForSessionNotifications(sessionId).catch((error62) => {
|
|
50096
|
+
logger.error("Failed to release child traffic after session setup", error62);
|
|
50097
|
+
});
|
|
50098
|
+
};
|
|
50010
50099
|
}
|
|
50011
50100
|
async interruptStandardChildren(session) {
|
|
50012
50101
|
if (!(session.subagents instanceof StandardSubagentEventRouter)) return;
|
|
@@ -50536,6 +50625,7 @@ You have been logged out. Please try again.`);
|
|
|
50536
50625
|
const sessionMcpServers = this.resolveSessionMcpServers(requestedMcpServers, operation === "resume");
|
|
50537
50626
|
const currentModel = this.findCurrentModel(models, currentModelId);
|
|
50538
50627
|
const currentModelSupportsFast = modelSupportsFast(currentModel);
|
|
50628
|
+
if (this.setupResponseOrdering && operation !== "resume") this.clientDelivery.beginSessionSetup(sessionId);
|
|
50539
50629
|
const sessionState = {
|
|
50540
50630
|
sessionId,
|
|
50541
50631
|
currentModelId,
|
|
@@ -54449,7 +54539,7 @@ var AcpResponseDelivery = class {
|
|
|
54449
54539
|
if ("method" in message || message.id === null) return;
|
|
54450
54540
|
const callback = this.callbacks.get(message.id);
|
|
54451
54541
|
this.callbacks.delete(message.id);
|
|
54452
|
-
callback?.();
|
|
54542
|
+
callback?.("result" in message);
|
|
54453
54543
|
},
|
|
54454
54544
|
close: async () => {
|
|
54455
54545
|
const writer = stream.writable.getWriter();
|
|
@@ -54542,7 +54632,15 @@ function createRouter(createAgent, responses) {
|
|
|
54542
54632
|
const setups = /* @__PURE__ */ new Map();
|
|
54543
54633
|
const setup = (sessionId, requestId, operation, signal) => {
|
|
54544
54634
|
const agent3 = getAgent({ sessionId });
|
|
54545
|
-
if (!agent3.usesStandardSubagents())
|
|
54635
|
+
if (!agent3.usesStandardSubagents()) {
|
|
54636
|
+
return operation().then((result) => {
|
|
54637
|
+
const publish = agent3.captureSessionSetupPublication(sessionId);
|
|
54638
|
+
responses.afterWrite(requestId, (successful) => {
|
|
54639
|
+
if (successful) void publish();
|
|
54640
|
+
});
|
|
54641
|
+
return result;
|
|
54642
|
+
});
|
|
54643
|
+
}
|
|
54546
54644
|
const assertCurrent = agent3.captureSessionSetup(sessionId);
|
|
54547
54645
|
const state = setups.get(sessionId) ?? { tail: Promise.resolve(), publication: Promise.resolve(), epoch: 0, pending: 0 };
|
|
54548
54646
|
setups.set(sessionId, state);
|
|
@@ -54560,7 +54658,7 @@ function createRouter(createAgent, responses) {
|
|
|
54560
54658
|
state.tail = state.tail.catch(() => {
|
|
54561
54659
|
}).then(async () => {
|
|
54562
54660
|
let registered = false;
|
|
54563
|
-
let
|
|
54661
|
+
let publish = null;
|
|
54564
54662
|
try {
|
|
54565
54663
|
for (; ; ) {
|
|
54566
54664
|
const publication = state.publication;
|
|
@@ -54569,14 +54667,14 @@ function createRouter(createAgent, responses) {
|
|
|
54569
54667
|
}
|
|
54570
54668
|
if (signal.aborted) throw new RequestError(-32800, "Session setup was cancelled");
|
|
54571
54669
|
assertCurrent();
|
|
54572
|
-
responses.afterWrite(requestId, () => {
|
|
54573
|
-
if (epoch === state.epoch &&
|
|
54670
|
+
responses.afterWrite(requestId, (successful) => {
|
|
54671
|
+
if (successful && epoch === state.epoch && publish) state.publication = publish();
|
|
54574
54672
|
void state.publication.then(finish, finish);
|
|
54575
54673
|
});
|
|
54576
54674
|
registered = true;
|
|
54577
54675
|
const result = await operation();
|
|
54578
54676
|
if (signal.aborted) throw new RequestError(-32800, "Session setup was cancelled");
|
|
54579
|
-
|
|
54677
|
+
publish = agent3.captureSessionSetupPublication(sessionId);
|
|
54580
54678
|
resolve(result);
|
|
54581
54679
|
} catch (error62) {
|
|
54582
54680
|
reject(error62);
|
|
@@ -54585,18 +54683,29 @@ function createRouter(createAgent, responses) {
|
|
|
54585
54683
|
});
|
|
54586
54684
|
return response;
|
|
54587
54685
|
};
|
|
54686
|
+
const createdSetup = async (requestId, operation) => {
|
|
54687
|
+
const agent3 = getAgent();
|
|
54688
|
+
const result = await operation();
|
|
54689
|
+
const publish = agent3.captureSessionCreationPublication(result.sessionId);
|
|
54690
|
+
responses.afterWrite(requestId, (successful) => {
|
|
54691
|
+
if (successful) publish();
|
|
54692
|
+
});
|
|
54693
|
+
return result;
|
|
54694
|
+
};
|
|
54588
54695
|
const attachAgent = (agent3, signal) => {
|
|
54589
54696
|
codexAcpServer = agent3;
|
|
54697
|
+
const stopSetupPublication = agent3.observeSessionSetupResponses();
|
|
54590
54698
|
signal.addEventListener("abort", () => {
|
|
54591
54699
|
setups.clear();
|
|
54700
|
+
stopSetupPublication();
|
|
54592
54701
|
agent3.sessionIndex.dispose();
|
|
54593
54702
|
if (codexAcpServer === agent3) {
|
|
54594
54703
|
codexAcpServer = null;
|
|
54595
54704
|
}
|
|
54596
54705
|
});
|
|
54597
54706
|
};
|
|
54598
|
-
const v1Agent = agent({ name: package_default.name }).onConnect((connection) => attachAgent(createAgent(connection.client), connection.signal)).onRequest(methods.agent.initialize, (ctx) => getAgent().initialize(ctx.params)).onRequest(methods.agent.session.new, (ctx) => 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) => 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)).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));
|
|
54599
|
-
const v2Agent = agent2({ name: package_default.name }).onConnect((connection) => attachAgent(createAgent(new AcpV2Connection(connection.client)), connection.signal)).onRequest(methods2.agent.initialize, (ctx) => getAgent().initializeV2(ctx.params)).onRequest(methods2.agent.session.new, (ctx) => 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) => 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)).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));
|
|
54707
|
+
const v1Agent = agent({ name: package_default.name }).onConnect((connection) => attachAgent(createAgent(connection.client), connection.signal)).onRequest(methods.agent.initialize, (ctx) => 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)).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));
|
|
54708
|
+
const v2Agent = agent2({ name: package_default.name }).onConnect((connection) => attachAgent(createAgent(new AcpV2Connection(connection.client)), connection.signal)).onRequest(methods2.agent.initialize, (ctx) => 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)).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));
|
|
54600
54709
|
return agentProtocolRouter().withV1(v1Agent).withV2(v2Agent);
|
|
54601
54710
|
}
|
|
54602
54711
|
|