@agentclientprotocol/codex-acp 0.0.44 → 0.0.45
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 +378 -158
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -14441,6 +14441,7 @@ var AGENT_METHODS = {
|
|
|
14441
14441
|
document_did_save: "document/didSave",
|
|
14442
14442
|
initialize: "initialize",
|
|
14443
14443
|
logout: "logout",
|
|
14444
|
+
mcp_message: "mcp/message",
|
|
14444
14445
|
nes_accept: "nes/accept",
|
|
14445
14446
|
nes_close: "nes/close",
|
|
14446
14447
|
nes_reject: "nes/reject",
|
|
@@ -14451,6 +14452,7 @@ var AGENT_METHODS = {
|
|
|
14451
14452
|
providers_set: "providers/set",
|
|
14452
14453
|
session_cancel: "session/cancel",
|
|
14453
14454
|
session_close: "session/close",
|
|
14455
|
+
session_delete: "session/delete",
|
|
14454
14456
|
session_fork: "session/fork",
|
|
14455
14457
|
session_list: "session/list",
|
|
14456
14458
|
session_load: "session/load",
|
|
@@ -14466,6 +14468,9 @@ var CLIENT_METHODS = {
|
|
|
14466
14468
|
elicitation_create: "elicitation/create",
|
|
14467
14469
|
fs_read_text_file: "fs/read_text_file",
|
|
14468
14470
|
fs_write_text_file: "fs/write_text_file",
|
|
14471
|
+
mcp_connect: "mcp/connect",
|
|
14472
|
+
mcp_disconnect: "mcp/disconnect",
|
|
14473
|
+
mcp_message: "mcp/message",
|
|
14469
14474
|
session_request_permission: "session/request_permission",
|
|
14470
14475
|
session_update: "session/update",
|
|
14471
14476
|
terminal_create: "terminal/create",
|
|
@@ -14551,6 +14556,9 @@ var zCreateTerminalResponse = external_exports.object({
|
|
|
14551
14556
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14552
14557
|
terminalId: external_exports.string()
|
|
14553
14558
|
});
|
|
14559
|
+
var zDeleteSessionResponse = external_exports.object({
|
|
14560
|
+
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish()
|
|
14561
|
+
});
|
|
14554
14562
|
var zDiff = external_exports.object({
|
|
14555
14563
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14556
14564
|
newText: external_exports.string(),
|
|
@@ -14564,6 +14572,9 @@ var zDisableProvidersRequest = external_exports.object({
|
|
|
14564
14572
|
var zDisableProvidersResponse = external_exports.object({
|
|
14565
14573
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish()
|
|
14566
14574
|
});
|
|
14575
|
+
var zDisconnectMcpResponse = external_exports.object({
|
|
14576
|
+
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish()
|
|
14577
|
+
});
|
|
14567
14578
|
var zElicitationContentValue = external_exports.union([
|
|
14568
14579
|
external_exports.string(),
|
|
14569
14580
|
external_exports.number(),
|
|
@@ -14669,7 +14680,6 @@ var zListProvidersRequest = external_exports.object({
|
|
|
14669
14680
|
});
|
|
14670
14681
|
var zListSessionsRequest = external_exports.object({
|
|
14671
14682
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14672
|
-
additionalDirectories: external_exports.array(external_exports.string()).optional(),
|
|
14673
14683
|
cursor: external_exports.string().nullish(),
|
|
14674
14684
|
cwd: external_exports.string().nullish()
|
|
14675
14685
|
});
|
|
@@ -14696,9 +14706,29 @@ var zLogoutResponse = external_exports.object({
|
|
|
14696
14706
|
});
|
|
14697
14707
|
var zMcpCapabilities = external_exports.object({
|
|
14698
14708
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14709
|
+
acp: external_exports.boolean().optional().default(false),
|
|
14699
14710
|
http: external_exports.boolean().optional().default(false),
|
|
14700
14711
|
sse: external_exports.boolean().optional().default(false)
|
|
14701
14712
|
});
|
|
14713
|
+
var zMcpConnectionId = external_exports.string();
|
|
14714
|
+
var zConnectMcpResponse = external_exports.object({
|
|
14715
|
+
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14716
|
+
connectionId: zMcpConnectionId
|
|
14717
|
+
});
|
|
14718
|
+
var zDisconnectMcpRequest = external_exports.object({
|
|
14719
|
+
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14720
|
+
connectionId: zMcpConnectionId
|
|
14721
|
+
});
|
|
14722
|
+
var zMcpServerAcpId = external_exports.string();
|
|
14723
|
+
var zConnectMcpRequest = external_exports.object({
|
|
14724
|
+
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14725
|
+
acpId: zMcpServerAcpId
|
|
14726
|
+
});
|
|
14727
|
+
var zMcpServerAcp = external_exports.object({
|
|
14728
|
+
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14729
|
+
id: zMcpServerAcpId,
|
|
14730
|
+
name: external_exports.string()
|
|
14731
|
+
});
|
|
14702
14732
|
var zMcpServerHttp = external_exports.object({
|
|
14703
14733
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14704
14734
|
headers: external_exports.array(zHttpHeader),
|
|
@@ -14725,8 +14755,24 @@ var zMcpServer = external_exports.union([
|
|
|
14725
14755
|
zMcpServerSse.and(external_exports.object({
|
|
14726
14756
|
type: external_exports.literal("sse")
|
|
14727
14757
|
})),
|
|
14758
|
+
zMcpServerAcp.and(external_exports.object({
|
|
14759
|
+
type: external_exports.literal("acp")
|
|
14760
|
+
})),
|
|
14728
14761
|
zMcpServerStdio
|
|
14729
14762
|
]);
|
|
14763
|
+
var zMessageMcpNotification = external_exports.object({
|
|
14764
|
+
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14765
|
+
connectionId: zMcpConnectionId,
|
|
14766
|
+
method: external_exports.string(),
|
|
14767
|
+
params: external_exports.record(external_exports.string(), external_exports.unknown()).nullish()
|
|
14768
|
+
});
|
|
14769
|
+
var zMessageMcpRequest = external_exports.object({
|
|
14770
|
+
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
14771
|
+
connectionId: zMcpConnectionId,
|
|
14772
|
+
method: external_exports.string(),
|
|
14773
|
+
params: external_exports.record(external_exports.string(), external_exports.unknown()).nullish()
|
|
14774
|
+
});
|
|
14775
|
+
var zMessageMcpResponse = external_exports.unknown();
|
|
14730
14776
|
var zModelId = external_exports.string();
|
|
14731
14777
|
var zModelInfo = external_exports.object({
|
|
14732
14778
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
@@ -15134,6 +15180,9 @@ var zConfigOptionUpdate = external_exports.object({
|
|
|
15134
15180
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
15135
15181
|
configOptions: external_exports.array(zSessionConfigOption)
|
|
15136
15182
|
});
|
|
15183
|
+
var zSessionDeleteCapabilities = external_exports.object({
|
|
15184
|
+
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish()
|
|
15185
|
+
});
|
|
15137
15186
|
var zSessionForkCapabilities = external_exports.object({
|
|
15138
15187
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish()
|
|
15139
15188
|
});
|
|
@@ -15164,6 +15213,10 @@ var zCreateTerminalRequest = external_exports.object({
|
|
|
15164
15213
|
outputByteLimit: external_exports.number().nullish(),
|
|
15165
15214
|
sessionId: zSessionId
|
|
15166
15215
|
});
|
|
15216
|
+
var zDeleteSessionRequest = external_exports.object({
|
|
15217
|
+
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
15218
|
+
sessionId: zSessionId
|
|
15219
|
+
});
|
|
15167
15220
|
var zDidCloseDocumentNotification = external_exports.object({
|
|
15168
15221
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
15169
15222
|
sessionId: zSessionId,
|
|
@@ -15313,6 +15366,7 @@ var zSessionCapabilities = external_exports.object({
|
|
|
15313
15366
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
15314
15367
|
additionalDirectories: zSessionAdditionalDirectoriesCapabilities.nullish(),
|
|
15315
15368
|
close: zSessionCloseCapabilities.nullish(),
|
|
15369
|
+
delete: zSessionDeleteCapabilities.nullish(),
|
|
15316
15370
|
fork: zSessionForkCapabilities.nullish(),
|
|
15317
15371
|
list: zSessionListCapabilities.nullish(),
|
|
15318
15372
|
resume: zSessionResumeCapabilities.nullish()
|
|
@@ -15455,6 +15509,7 @@ var zClientNotification = external_exports.object({
|
|
|
15455
15509
|
zDidFocusDocumentNotification,
|
|
15456
15510
|
zAcceptNesNotification,
|
|
15457
15511
|
zRejectNesNotification,
|
|
15512
|
+
zMessageMcpNotification,
|
|
15458
15513
|
zExtNotification
|
|
15459
15514
|
]).nullish()
|
|
15460
15515
|
});
|
|
@@ -15487,7 +15542,11 @@ var zAgentCapabilities = external_exports.object({
|
|
|
15487
15542
|
_meta: external_exports.record(external_exports.string(), external_exports.unknown()).nullish(),
|
|
15488
15543
|
auth: zAgentAuthCapabilities.optional().default({}),
|
|
15489
15544
|
loadSession: external_exports.boolean().optional().default(false),
|
|
15490
|
-
mcpCapabilities: zMcpCapabilities.optional().default({
|
|
15545
|
+
mcpCapabilities: zMcpCapabilities.optional().default({
|
|
15546
|
+
acp: false,
|
|
15547
|
+
http: false,
|
|
15548
|
+
sse: false
|
|
15549
|
+
}),
|
|
15491
15550
|
nes: zNesCapabilities.nullish(),
|
|
15492
15551
|
positionEncoding: zPositionEncodingKind.nullish(),
|
|
15493
15552
|
promptCapabilities: zPromptCapabilities.optional().default({
|
|
@@ -15503,7 +15562,11 @@ var zInitializeResponse = external_exports.object({
|
|
|
15503
15562
|
agentCapabilities: zAgentCapabilities.optional().default({
|
|
15504
15563
|
auth: {},
|
|
15505
15564
|
loadSession: false,
|
|
15506
|
-
mcpCapabilities: {
|
|
15565
|
+
mcpCapabilities: {
|
|
15566
|
+
acp: false,
|
|
15567
|
+
http: false,
|
|
15568
|
+
sse: false
|
|
15569
|
+
},
|
|
15507
15570
|
promptCapabilities: {
|
|
15508
15571
|
audio: false,
|
|
15509
15572
|
embeddedContext: false,
|
|
@@ -15734,6 +15797,7 @@ var zAgentResponse = external_exports.union([
|
|
|
15734
15797
|
zNewSessionResponse,
|
|
15735
15798
|
zLoadSessionResponse,
|
|
15736
15799
|
zListSessionsResponse,
|
|
15800
|
+
zDeleteSessionResponse,
|
|
15737
15801
|
zForkSessionResponse,
|
|
15738
15802
|
zResumeSessionResponse,
|
|
15739
15803
|
zCloseSessionResponse,
|
|
@@ -15744,7 +15808,8 @@ var zAgentResponse = external_exports.union([
|
|
|
15744
15808
|
zStartNesResponse,
|
|
15745
15809
|
zSuggestNesResponse,
|
|
15746
15810
|
zCloseNesResponse,
|
|
15747
|
-
zExtResponse
|
|
15811
|
+
zExtResponse,
|
|
15812
|
+
zMessageMcpResponse
|
|
15748
15813
|
])
|
|
15749
15814
|
}),
|
|
15750
15815
|
external_exports.object({
|
|
@@ -15803,6 +15868,7 @@ var zAgentNotification = external_exports.object({
|
|
|
15803
15868
|
params: external_exports.union([
|
|
15804
15869
|
zSessionNotification,
|
|
15805
15870
|
zCompleteElicitationNotification,
|
|
15871
|
+
zMessageMcpNotification,
|
|
15806
15872
|
zExtNotification
|
|
15807
15873
|
]).nullish()
|
|
15808
15874
|
});
|
|
@@ -15841,6 +15907,7 @@ var zClientRequest = external_exports.object({
|
|
|
15841
15907
|
zNewSessionRequest,
|
|
15842
15908
|
zLoadSessionRequest,
|
|
15843
15909
|
zListSessionsRequest,
|
|
15910
|
+
zDeleteSessionRequest,
|
|
15844
15911
|
zForkSessionRequest,
|
|
15845
15912
|
zResumeSessionRequest,
|
|
15846
15913
|
zCloseSessionRequest,
|
|
@@ -15851,6 +15918,7 @@ var zClientRequest = external_exports.object({
|
|
|
15851
15918
|
zStartNesRequest,
|
|
15852
15919
|
zSuggestNesRequest,
|
|
15853
15920
|
zCloseNesRequest,
|
|
15921
|
+
zMessageMcpRequest,
|
|
15854
15922
|
zExtRequest
|
|
15855
15923
|
]).nullish()
|
|
15856
15924
|
});
|
|
@@ -15873,6 +15941,9 @@ var zAgentRequest = external_exports.object({
|
|
|
15873
15941
|
zWaitForTerminalExitRequest,
|
|
15874
15942
|
zKillTerminalRequest,
|
|
15875
15943
|
zCreateElicitationRequest,
|
|
15944
|
+
zConnectMcpRequest,
|
|
15945
|
+
zMessageMcpRequest,
|
|
15946
|
+
zDisconnectMcpRequest,
|
|
15876
15947
|
zExtRequest
|
|
15877
15948
|
]).nullish()
|
|
15878
15949
|
});
|
|
@@ -15892,7 +15963,10 @@ var zClientResponse = external_exports.union([
|
|
|
15892
15963
|
zWaitForTerminalExitResponse,
|
|
15893
15964
|
zKillTerminalResponse,
|
|
15894
15965
|
zCreateElicitationResponse,
|
|
15895
|
-
|
|
15966
|
+
zConnectMcpResponse,
|
|
15967
|
+
zDisconnectMcpResponse,
|
|
15968
|
+
zExtResponse,
|
|
15969
|
+
zMessageMcpResponse
|
|
15896
15970
|
])
|
|
15897
15971
|
}),
|
|
15898
15972
|
external_exports.object({
|
|
@@ -15967,6 +16041,15 @@ function ndJsonStream(output, input) {
|
|
|
15967
16041
|
}
|
|
15968
16042
|
|
|
15969
16043
|
// node_modules/@agentclientprotocol/sdk/dist/acp.js
|
|
16044
|
+
function emptyObjectResponse(response) {
|
|
16045
|
+
return response ?? {};
|
|
16046
|
+
}
|
|
16047
|
+
function rejectedPromise(error40) {
|
|
16048
|
+
const promise2 = Promise.reject(error40);
|
|
16049
|
+
promise2.catch(() => {
|
|
16050
|
+
});
|
|
16051
|
+
return promise2;
|
|
16052
|
+
}
|
|
15970
16053
|
var AgentSideConnection = class {
|
|
15971
16054
|
connection;
|
|
15972
16055
|
/**
|
|
@@ -16007,6 +16090,14 @@ var AgentSideConnection = class {
|
|
|
16007
16090
|
const validatedParams = zListSessionsRequest.parse(params);
|
|
16008
16091
|
return agent.listSessions(validatedParams);
|
|
16009
16092
|
}
|
|
16093
|
+
case AGENT_METHODS.session_delete: {
|
|
16094
|
+
if (!agent.unstable_deleteSession) {
|
|
16095
|
+
throw RequestError.methodNotFound(method);
|
|
16096
|
+
}
|
|
16097
|
+
const validatedParams = zDeleteSessionRequest.parse(params);
|
|
16098
|
+
const result = await agent.unstable_deleteSession(validatedParams);
|
|
16099
|
+
return result ?? {};
|
|
16100
|
+
}
|
|
16010
16101
|
case AGENT_METHODS.session_fork: {
|
|
16011
16102
|
if (!agent.unstable_forkSession) {
|
|
16012
16103
|
throw RequestError.methodNotFound(method);
|
|
@@ -16191,8 +16282,8 @@ var AgentSideConnection = class {
|
|
|
16191
16282
|
*
|
|
16192
16283
|
* See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
|
|
16193
16284
|
*/
|
|
16194
|
-
|
|
16195
|
-
return
|
|
16285
|
+
sessionUpdate(params) {
|
|
16286
|
+
return this.connection.sendNotification(CLIENT_METHODS.session_update, params);
|
|
16196
16287
|
}
|
|
16197
16288
|
/**
|
|
16198
16289
|
* Requests permission from the user for a tool call operation.
|
|
@@ -16206,8 +16297,8 @@ var AgentSideConnection = class {
|
|
|
16206
16297
|
*
|
|
16207
16298
|
* See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)
|
|
16208
16299
|
*/
|
|
16209
|
-
|
|
16210
|
-
return
|
|
16300
|
+
requestPermission(params) {
|
|
16301
|
+
return this.connection.sendRequest(CLIENT_METHODS.session_request_permission, params);
|
|
16211
16302
|
}
|
|
16212
16303
|
/**
|
|
16213
16304
|
* Reads content from a text file in the client's file system.
|
|
@@ -16217,8 +16308,8 @@ var AgentSideConnection = class {
|
|
|
16217
16308
|
*
|
|
16218
16309
|
* See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
|
|
16219
16310
|
*/
|
|
16220
|
-
|
|
16221
|
-
return
|
|
16311
|
+
readTextFile(params) {
|
|
16312
|
+
return this.connection.sendRequest(CLIENT_METHODS.fs_read_text_file, params);
|
|
16222
16313
|
}
|
|
16223
16314
|
/**
|
|
16224
16315
|
* Writes content to a text file in the client's file system.
|
|
@@ -16228,8 +16319,8 @@ var AgentSideConnection = class {
|
|
|
16228
16319
|
*
|
|
16229
16320
|
* See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
|
|
16230
16321
|
*/
|
|
16231
|
-
|
|
16232
|
-
return
|
|
16322
|
+
writeTextFile(params) {
|
|
16323
|
+
return this.connection.sendRequest(CLIENT_METHODS.fs_write_text_file, params, emptyObjectResponse);
|
|
16233
16324
|
}
|
|
16234
16325
|
/**
|
|
16235
16326
|
* Executes a command in a new terminal.
|
|
@@ -16243,9 +16334,8 @@ var AgentSideConnection = class {
|
|
|
16243
16334
|
* @param params - The terminal creation parameters
|
|
16244
16335
|
* @returns A handle to control and monitor the terminal
|
|
16245
16336
|
*/
|
|
16246
|
-
|
|
16247
|
-
|
|
16248
|
-
return new TerminalHandle(response.terminalId, params.sessionId, this.connection);
|
|
16337
|
+
createTerminal(params) {
|
|
16338
|
+
return this.connection.sendRequest(CLIENT_METHODS.terminal_create, params, (response) => new TerminalHandle(response.terminalId, params.sessionId, this.connection));
|
|
16249
16339
|
}
|
|
16250
16340
|
/**
|
|
16251
16341
|
* **UNSTABLE**
|
|
@@ -16256,8 +16346,8 @@ var AgentSideConnection = class {
|
|
|
16256
16346
|
*
|
|
16257
16347
|
* @experimental
|
|
16258
16348
|
*/
|
|
16259
|
-
|
|
16260
|
-
return
|
|
16349
|
+
unstable_createElicitation(params) {
|
|
16350
|
+
return this.connection.sendRequest(CLIENT_METHODS.elicitation_create, params);
|
|
16261
16351
|
}
|
|
16262
16352
|
/**
|
|
16263
16353
|
* **UNSTABLE**
|
|
@@ -16268,24 +16358,24 @@ var AgentSideConnection = class {
|
|
|
16268
16358
|
*
|
|
16269
16359
|
* @experimental
|
|
16270
16360
|
*/
|
|
16271
|
-
|
|
16272
|
-
return
|
|
16361
|
+
unstable_completeElicitation(params) {
|
|
16362
|
+
return this.connection.sendNotification(CLIENT_METHODS.elicitation_complete, params);
|
|
16273
16363
|
}
|
|
16274
16364
|
/**
|
|
16275
16365
|
* Extension method
|
|
16276
16366
|
*
|
|
16277
16367
|
* Allows the Agent to send an arbitrary request that is not part of the ACP spec.
|
|
16278
16368
|
*/
|
|
16279
|
-
|
|
16280
|
-
return
|
|
16369
|
+
extMethod(method, params) {
|
|
16370
|
+
return this.connection.sendRequest(method, params);
|
|
16281
16371
|
}
|
|
16282
16372
|
/**
|
|
16283
16373
|
* Extension notification
|
|
16284
16374
|
*
|
|
16285
16375
|
* Allows the Agent to send an arbitrary notification that is not part of the ACP spec.
|
|
16286
16376
|
*/
|
|
16287
|
-
|
|
16288
|
-
return
|
|
16377
|
+
extNotification(method, params) {
|
|
16378
|
+
return this.connection.sendNotification(method, params);
|
|
16289
16379
|
}
|
|
16290
16380
|
/**
|
|
16291
16381
|
* AbortSignal that aborts when the connection closes.
|
|
@@ -16349,8 +16439,8 @@ var TerminalHandle = class {
|
|
|
16349
16439
|
/**
|
|
16350
16440
|
* Gets the current terminal output without waiting for the command to exit.
|
|
16351
16441
|
*/
|
|
16352
|
-
|
|
16353
|
-
return
|
|
16442
|
+
currentOutput() {
|
|
16443
|
+
return this.connection.sendRequest(CLIENT_METHODS.terminal_output, {
|
|
16354
16444
|
sessionId: this.sessionId,
|
|
16355
16445
|
terminalId: this.id
|
|
16356
16446
|
});
|
|
@@ -16358,8 +16448,8 @@ var TerminalHandle = class {
|
|
|
16358
16448
|
/**
|
|
16359
16449
|
* Waits for the terminal command to complete and returns its exit status.
|
|
16360
16450
|
*/
|
|
16361
|
-
|
|
16362
|
-
return
|
|
16451
|
+
waitForExit() {
|
|
16452
|
+
return this.connection.sendRequest(CLIENT_METHODS.terminal_wait_for_exit, {
|
|
16363
16453
|
sessionId: this.sessionId,
|
|
16364
16454
|
terminalId: this.id
|
|
16365
16455
|
});
|
|
@@ -16374,11 +16464,11 @@ var TerminalHandle = class {
|
|
|
16374
16464
|
*
|
|
16375
16465
|
* Useful for implementing timeouts or cancellation.
|
|
16376
16466
|
*/
|
|
16377
|
-
|
|
16378
|
-
return
|
|
16467
|
+
kill() {
|
|
16468
|
+
return this.connection.sendRequest(CLIENT_METHODS.terminal_kill, {
|
|
16379
16469
|
sessionId: this.sessionId,
|
|
16380
16470
|
terminalId: this.id
|
|
16381
|
-
})
|
|
16471
|
+
}, emptyObjectResponse);
|
|
16382
16472
|
}
|
|
16383
16473
|
/**
|
|
16384
16474
|
* Releases the terminal and frees all associated resources.
|
|
@@ -16392,11 +16482,11 @@ var TerminalHandle = class {
|
|
|
16392
16482
|
*
|
|
16393
16483
|
* **Important:** Always call this method when done with the terminal.
|
|
16394
16484
|
*/
|
|
16395
|
-
|
|
16396
|
-
return
|
|
16485
|
+
release() {
|
|
16486
|
+
return this.connection.sendRequest(CLIENT_METHODS.terminal_release, {
|
|
16397
16487
|
sessionId: this.sessionId,
|
|
16398
16488
|
terminalId: this.id
|
|
16399
|
-
})
|
|
16489
|
+
}, emptyObjectResponse);
|
|
16400
16490
|
}
|
|
16401
16491
|
async [Symbol.asyncDispose]() {
|
|
16402
16492
|
await this.release();
|
|
@@ -16581,25 +16671,36 @@ var Connection = class {
|
|
|
16581
16671
|
console.error("Got response to unknown request", response.id);
|
|
16582
16672
|
}
|
|
16583
16673
|
}
|
|
16584
|
-
sendRequest(method, params) {
|
|
16585
|
-
this.
|
|
16674
|
+
sendRequest(method, params, mapResponse) {
|
|
16675
|
+
if (this.abortController.signal.aborted) {
|
|
16676
|
+
return rejectedPromise(this.closedReason());
|
|
16677
|
+
}
|
|
16586
16678
|
const id = this.nextRequestId++;
|
|
16587
16679
|
const responsePromise = new Promise((resolve, reject) => {
|
|
16588
|
-
this.pendingResponses.set(id, {
|
|
16680
|
+
this.pendingResponses.set(id, {
|
|
16681
|
+
resolve: (response) => {
|
|
16682
|
+
try {
|
|
16683
|
+
resolve(mapResponse ? mapResponse(response) : response);
|
|
16684
|
+
} catch (error40) {
|
|
16685
|
+
reject(error40);
|
|
16686
|
+
}
|
|
16687
|
+
},
|
|
16688
|
+
reject
|
|
16689
|
+
});
|
|
16589
16690
|
});
|
|
16590
16691
|
responsePromise.catch(() => {
|
|
16591
16692
|
});
|
|
16592
16693
|
void this.sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
16593
16694
|
return responsePromise;
|
|
16594
16695
|
}
|
|
16595
|
-
|
|
16596
|
-
this.throwIfClosed();
|
|
16597
|
-
await this.sendMessage({ jsonrpc: "2.0", method, params });
|
|
16598
|
-
}
|
|
16599
|
-
throwIfClosed() {
|
|
16696
|
+
sendNotification(method, params) {
|
|
16600
16697
|
if (this.abortController.signal.aborted) {
|
|
16601
|
-
|
|
16698
|
+
return rejectedPromise(this.closedReason());
|
|
16602
16699
|
}
|
|
16700
|
+
return this.sendMessage({ jsonrpc: "2.0", method, params });
|
|
16701
|
+
}
|
|
16702
|
+
closedReason() {
|
|
16703
|
+
return this.abortController.signal.reason ?? new Error("ACP connection closed");
|
|
16603
16704
|
}
|
|
16604
16705
|
async sendMessage(message) {
|
|
16605
16706
|
this.writeQueue = this.writeQueue.then(async () => {
|
|
@@ -17369,7 +17470,7 @@ function createCommandActionEvent(id, status, cwd, commandAction) {
|
|
|
17369
17470
|
toolCallId: id,
|
|
17370
17471
|
status: acpStatus,
|
|
17371
17472
|
kind: "read",
|
|
17372
|
-
title:
|
|
17473
|
+
title: `Read file '${commandAction.path}'`,
|
|
17373
17474
|
locations: [{ path: commandAction.path }]
|
|
17374
17475
|
};
|
|
17375
17476
|
} else if (commandAction.type === "search") {
|
|
@@ -17536,6 +17637,27 @@ var CodexEventHandler = class {
|
|
|
17536
17637
|
return null;
|
|
17537
17638
|
case "thread/tokenUsage/updated":
|
|
17538
17639
|
return this.createUsageUpdate(notification.params);
|
|
17640
|
+
case "thread/name/updated":
|
|
17641
|
+
return {
|
|
17642
|
+
sessionUpdate: "session_info_update",
|
|
17643
|
+
title: notification.params.threadName ?? null
|
|
17644
|
+
};
|
|
17645
|
+
case "thread/status/changed":
|
|
17646
|
+
return this.createCodexSessionInfoUpdate({
|
|
17647
|
+
threadStatus: notification.params.status
|
|
17648
|
+
});
|
|
17649
|
+
case "thread/archived":
|
|
17650
|
+
return this.createCodexSessionInfoUpdate({
|
|
17651
|
+
archived: true
|
|
17652
|
+
});
|
|
17653
|
+
case "thread/unarchived":
|
|
17654
|
+
return this.createCodexSessionInfoUpdate({
|
|
17655
|
+
archived: false
|
|
17656
|
+
});
|
|
17657
|
+
case "thread/closed":
|
|
17658
|
+
return this.createCodexSessionInfoUpdate({
|
|
17659
|
+
closed: true
|
|
17660
|
+
});
|
|
17539
17661
|
case "item/commandExecution/outputDelta":
|
|
17540
17662
|
return this.createCommandOutputDeltaEvent(notification.params);
|
|
17541
17663
|
case "item/mcpToolCall/progress":
|
|
@@ -17582,10 +17704,6 @@ var CodexEventHandler = class {
|
|
|
17582
17704
|
case "serverRequest/resolved":
|
|
17583
17705
|
case "model/verification":
|
|
17584
17706
|
case "windows/worldWritableWarning":
|
|
17585
|
-
case "thread/status/changed":
|
|
17586
|
-
case "thread/archived":
|
|
17587
|
-
case "thread/unarchived":
|
|
17588
|
-
case "thread/closed":
|
|
17589
17707
|
case "thread/realtime/started":
|
|
17590
17708
|
case "thread/realtime/itemAdded":
|
|
17591
17709
|
case "thread/realtime/transcript/delta":
|
|
@@ -17602,7 +17720,6 @@ var CodexEventHandler = class {
|
|
|
17602
17720
|
case "externalAgentConfig/import/completed":
|
|
17603
17721
|
case "rawResponseItem/completed":
|
|
17604
17722
|
case "thread/started":
|
|
17605
|
-
case "thread/name/updated":
|
|
17606
17723
|
case "item/plan/delta":
|
|
17607
17724
|
case "thread/goal/updated":
|
|
17608
17725
|
case "thread/goal/cleared":
|
|
@@ -17611,6 +17728,14 @@ var CodexEventHandler = class {
|
|
|
17611
17728
|
return null;
|
|
17612
17729
|
}
|
|
17613
17730
|
}
|
|
17731
|
+
createCodexSessionInfoUpdate(codexMetadata) {
|
|
17732
|
+
return {
|
|
17733
|
+
sessionUpdate: "session_info_update",
|
|
17734
|
+
_meta: {
|
|
17735
|
+
codex: codexMetadata
|
|
17736
|
+
}
|
|
17737
|
+
};
|
|
17738
|
+
}
|
|
17614
17739
|
async createTextEvent(event) {
|
|
17615
17740
|
return {
|
|
17616
17741
|
sessionUpdate: "agent_message_chunk",
|
|
@@ -18000,12 +18125,19 @@ var CodexApprovalHandler = class {
|
|
|
18000
18125
|
}
|
|
18001
18126
|
};
|
|
18002
18127
|
|
|
18128
|
+
// src/McpApprovalOptionId.ts
|
|
18129
|
+
var McpApprovalOptionId = {
|
|
18130
|
+
AllowOnce: "allow_once",
|
|
18131
|
+
AllowSession: "allow_session",
|
|
18132
|
+
AllowAlways: "allow_always",
|
|
18133
|
+
Decline: "decline"
|
|
18134
|
+
};
|
|
18135
|
+
|
|
18003
18136
|
// src/CodexElicitationHandler.ts
|
|
18004
18137
|
var ELICITATION_OPTIONS = [
|
|
18005
18138
|
{ optionId: "accept", name: "Accept", kind: "allow_once" },
|
|
18006
18139
|
{ optionId: "decline", name: "Decline", kind: "reject_once" }
|
|
18007
18140
|
];
|
|
18008
|
-
var OPTION_ALLOW_SESSION = "allow_session";
|
|
18009
18141
|
function parsePersistOptions(meta) {
|
|
18010
18142
|
const result = /* @__PURE__ */ new Set();
|
|
18011
18143
|
if (!meta || typeof meta !== "object") return result;
|
|
@@ -18025,15 +18157,15 @@ function isMcpToolCallApproval(meta) {
|
|
|
18025
18157
|
}
|
|
18026
18158
|
function buildToolApprovalOptions(persistOptions) {
|
|
18027
18159
|
const options = [
|
|
18028
|
-
{ optionId:
|
|
18160
|
+
{ optionId: McpApprovalOptionId.AllowOnce, name: "Allow", kind: "allow_once" }
|
|
18029
18161
|
];
|
|
18030
18162
|
if (persistOptions.has("session")) {
|
|
18031
|
-
options.push({ optionId:
|
|
18163
|
+
options.push({ optionId: McpApprovalOptionId.AllowSession, name: "Allow for This Session", kind: "allow_always" });
|
|
18032
18164
|
}
|
|
18033
18165
|
if (persistOptions.has("always")) {
|
|
18034
|
-
options.push({ optionId:
|
|
18166
|
+
options.push({ optionId: McpApprovalOptionId.AllowAlways, name: "Allow and Don't Ask Again", kind: "allow_always" });
|
|
18035
18167
|
}
|
|
18036
|
-
options.push({ optionId:
|
|
18168
|
+
options.push({ optionId: McpApprovalOptionId.Decline, name: "Decline", kind: "reject_once" });
|
|
18037
18169
|
return options;
|
|
18038
18170
|
}
|
|
18039
18171
|
var CodexElicitationHandler = class {
|
|
@@ -18080,7 +18212,7 @@ var CodexElicitationHandler = class {
|
|
|
18080
18212
|
const response = await this.connection.requestPermission(request);
|
|
18081
18213
|
if (correlatedCallId !== void 0 && response.outcome.outcome !== "cancelled") {
|
|
18082
18214
|
const optionId = response.outcome.optionId;
|
|
18083
|
-
if (optionId !==
|
|
18215
|
+
if (optionId !== McpApprovalOptionId.Decline) {
|
|
18084
18216
|
await this.connection.sessionUpdate({
|
|
18085
18217
|
sessionId: this.sessionState.sessionId,
|
|
18086
18218
|
update: { sessionUpdate: "tool_call_update", toolCallId: correlatedCallId, status: "in_progress" }
|
|
@@ -18158,13 +18290,13 @@ var CodexElicitationHandler = class {
|
|
|
18158
18290
|
return { action: "cancel", content: null, _meta: null };
|
|
18159
18291
|
}
|
|
18160
18292
|
const optionId = response.outcome.optionId;
|
|
18161
|
-
if (optionId ===
|
|
18293
|
+
if (optionId === McpApprovalOptionId.AllowSession) {
|
|
18162
18294
|
return { action: "accept", content: null, _meta: { persist: "session" } };
|
|
18163
18295
|
}
|
|
18164
|
-
if (optionId ===
|
|
18296
|
+
if (optionId === McpApprovalOptionId.AllowAlways) {
|
|
18165
18297
|
return { action: "accept", content: null, _meta: { persist: "always" } };
|
|
18166
18298
|
}
|
|
18167
|
-
if (optionId ===
|
|
18299
|
+
if (optionId === McpApprovalOptionId.AllowOnce || optionId === "accept") {
|
|
18168
18300
|
return { action: "accept", content: null, _meta: null };
|
|
18169
18301
|
}
|
|
18170
18302
|
return { action: "decline", content: null, _meta: null };
|
|
@@ -18958,7 +19090,7 @@ var package_default = {
|
|
|
18958
19090
|
publishConfig: {
|
|
18959
19091
|
access: "public"
|
|
18960
19092
|
},
|
|
18961
|
-
version: "0.0.
|
|
19093
|
+
version: "0.0.45",
|
|
18962
19094
|
description: "",
|
|
18963
19095
|
main: "dist/index.js",
|
|
18964
19096
|
bin: {
|
|
@@ -19016,7 +19148,7 @@ var package_default = {
|
|
|
19016
19148
|
vitest: "^4.0.10"
|
|
19017
19149
|
},
|
|
19018
19150
|
dependencies: {
|
|
19019
|
-
"@agentclientprotocol/sdk": "^0.
|
|
19151
|
+
"@agentclientprotocol/sdk": "^0.22.1",
|
|
19020
19152
|
"@openai/codex": "^0.128.0",
|
|
19021
19153
|
diff: "^8.0.3",
|
|
19022
19154
|
open: "^11.0.0",
|
|
@@ -19160,15 +19292,9 @@ var CodexAcpClient = class {
|
|
|
19160
19292
|
async resumeSession(request) {
|
|
19161
19293
|
await this.refreshSkills(request.cwd, request._meta);
|
|
19162
19294
|
const response = await this.codexClient.threadResume({
|
|
19163
|
-
approvalPolicy: null,
|
|
19164
|
-
sandbox: null,
|
|
19165
|
-
baseInstructions: null,
|
|
19166
19295
|
config: await this.createSessionConfig(request.cwd, request.mcpServers ?? []),
|
|
19167
19296
|
cwd: request.cwd,
|
|
19168
|
-
developerInstructions: null,
|
|
19169
|
-
model: null,
|
|
19170
19297
|
modelProvider: this.getResumeModelProvider(),
|
|
19171
|
-
personality: null,
|
|
19172
19298
|
threadId: request.sessionId
|
|
19173
19299
|
});
|
|
19174
19300
|
const codexModels = await this.fetchAvailableModels();
|
|
@@ -19176,20 +19302,15 @@ var CodexAcpClient = class {
|
|
|
19176
19302
|
return {
|
|
19177
19303
|
sessionId: request.sessionId,
|
|
19178
19304
|
currentModelId,
|
|
19179
|
-
models: codexModels
|
|
19305
|
+
models: codexModels,
|
|
19306
|
+
currentServiceTier: response.serviceTier ?? null
|
|
19180
19307
|
};
|
|
19181
19308
|
}
|
|
19182
19309
|
async loadSession(request) {
|
|
19183
19310
|
const response = await this.codexClient.threadResume({
|
|
19184
|
-
approvalPolicy: null,
|
|
19185
|
-
sandbox: null,
|
|
19186
|
-
baseInstructions: null,
|
|
19187
19311
|
config: await this.createSessionConfig(request.cwd, request.mcpServers ?? []),
|
|
19188
19312
|
cwd: request.cwd,
|
|
19189
|
-
developerInstructions: null,
|
|
19190
|
-
model: null,
|
|
19191
19313
|
modelProvider: this.getResumeModelProvider(),
|
|
19192
|
-
personality: null,
|
|
19193
19314
|
threadId: request.sessionId
|
|
19194
19315
|
});
|
|
19195
19316
|
const codexModels = await this.fetchAvailableModels();
|
|
@@ -19198,6 +19319,7 @@ var CodexAcpClient = class {
|
|
|
19198
19319
|
sessionId: request.sessionId,
|
|
19199
19320
|
currentModelId,
|
|
19200
19321
|
models: codexModels,
|
|
19322
|
+
currentServiceTier: response.serviceTier ?? null,
|
|
19201
19323
|
thread: response.thread
|
|
19202
19324
|
};
|
|
19203
19325
|
}
|
|
@@ -19206,14 +19328,7 @@ var CodexAcpClient = class {
|
|
|
19206
19328
|
const response = await this.codexClient.threadStart({
|
|
19207
19329
|
config: await this.createSessionConfig(request.cwd, request.mcpServers),
|
|
19208
19330
|
modelProvider: this.getModelProvider(),
|
|
19209
|
-
|
|
19210
|
-
cwd: request.cwd,
|
|
19211
|
-
approvalPolicy: null,
|
|
19212
|
-
sandbox: null,
|
|
19213
|
-
baseInstructions: null,
|
|
19214
|
-
developerInstructions: null,
|
|
19215
|
-
personality: null,
|
|
19216
|
-
ephemeral: null
|
|
19331
|
+
cwd: request.cwd
|
|
19217
19332
|
});
|
|
19218
19333
|
const codexModels = await this.fetchAvailableModels();
|
|
19219
19334
|
if (codexModels.length === 0) {
|
|
@@ -19223,7 +19338,8 @@ var CodexAcpClient = class {
|
|
|
19223
19338
|
return {
|
|
19224
19339
|
sessionId: response.thread.id,
|
|
19225
19340
|
currentModelId,
|
|
19226
|
-
models: codexModels
|
|
19341
|
+
models: codexModels,
|
|
19342
|
+
currentServiceTier: response.serviceTier ?? null
|
|
19227
19343
|
};
|
|
19228
19344
|
}
|
|
19229
19345
|
async awaitMcpServerStartup(serverNames, afterVersion) {
|
|
@@ -19287,13 +19403,17 @@ var CodexAcpClient = class {
|
|
|
19287
19403
|
*/
|
|
19288
19404
|
createMcpSeverConfig(mcpServer) {
|
|
19289
19405
|
if ("type" in mcpServer) {
|
|
19290
|
-
|
|
19291
|
-
|
|
19406
|
+
switch (mcpServer.type) {
|
|
19407
|
+
case "acp":
|
|
19408
|
+
throw RequestError.invalidRequest("Codex doesn't support MCP ACP transport protocol");
|
|
19409
|
+
case "sse":
|
|
19410
|
+
throw RequestError.invalidRequest("Codex doesn't support MCP SSE transport protocol");
|
|
19411
|
+
case "http":
|
|
19412
|
+
return {
|
|
19413
|
+
"url": mcpServer.url,
|
|
19414
|
+
"http_headers": Object.fromEntries(mcpServer.headers.map((h) => [h.name, h.value]))
|
|
19415
|
+
};
|
|
19292
19416
|
}
|
|
19293
|
-
return {
|
|
19294
|
-
"url": mcpServer.url,
|
|
19295
|
-
"http_headers": Object.fromEntries(mcpServer.headers.map((h) => [h.name, h.value]))
|
|
19296
|
-
};
|
|
19297
19417
|
}
|
|
19298
19418
|
return {
|
|
19299
19419
|
"command": mcpServer.command,
|
|
@@ -19317,21 +19437,19 @@ var CodexAcpClient = class {
|
|
|
19317
19437
|
this.codexClient.onApprovalRequest(sessionId, approvalHandler);
|
|
19318
19438
|
this.codexClient.onElicitationRequest(sessionId, elicitationHandler);
|
|
19319
19439
|
}
|
|
19320
|
-
async sendPrompt(request, agentMode, modelId, disableSummary, cwd) {
|
|
19440
|
+
async sendPrompt(request, agentMode, modelId, serviceTier, disableSummary, cwd) {
|
|
19321
19441
|
const input = buildPromptItems(request.prompt);
|
|
19322
19442
|
const effort = modelId.effort;
|
|
19323
19443
|
await this.refreshSkills(cwd, request._meta);
|
|
19324
19444
|
return await this.codexClient.runTurn({
|
|
19325
|
-
outputSchema: null,
|
|
19326
19445
|
threadId: request.sessionId,
|
|
19327
19446
|
input,
|
|
19328
19447
|
approvalPolicy: agentMode.approvalPolicy,
|
|
19329
19448
|
sandboxPolicy: agentMode.sandboxPolicy,
|
|
19330
19449
|
summary: disableSummary ? "none" : null,
|
|
19331
|
-
personality: null,
|
|
19332
|
-
cwd: null,
|
|
19333
19450
|
effort,
|
|
19334
|
-
model: modelId.model
|
|
19451
|
+
model: modelId.model,
|
|
19452
|
+
serviceTier
|
|
19335
19453
|
});
|
|
19336
19454
|
}
|
|
19337
19455
|
async listSkills(params) {
|
|
@@ -19374,8 +19492,8 @@ var CodexAcpClient = class {
|
|
|
19374
19492
|
});
|
|
19375
19493
|
});
|
|
19376
19494
|
}
|
|
19377
|
-
async listMcpServers(
|
|
19378
|
-
return this.codexClient.listMcpServerStatus(
|
|
19495
|
+
async listMcpServers() {
|
|
19496
|
+
return this.codexClient.listMcpServerStatus({});
|
|
19379
19497
|
}
|
|
19380
19498
|
async listSessions(request) {
|
|
19381
19499
|
const sourceKinds = [
|
|
@@ -19403,11 +19521,8 @@ var CodexAcpClient = class {
|
|
|
19403
19521
|
const modelProviders = preferredProvider ? [preferredProvider] : [];
|
|
19404
19522
|
const listResponse = await this.codexClient.threadList({
|
|
19405
19523
|
cursor: request.cursor ?? null,
|
|
19406
|
-
limit: null,
|
|
19407
|
-
sortKey: null,
|
|
19408
19524
|
modelProviders,
|
|
19409
|
-
sourceKinds
|
|
19410
|
-
archived: null
|
|
19525
|
+
sourceKinds
|
|
19411
19526
|
});
|
|
19412
19527
|
if (listResponse.data.length === 0) {
|
|
19413
19528
|
const diagnostics = await this.runSessionListDiagnostics();
|
|
@@ -19416,14 +19531,14 @@ var CodexAcpClient = class {
|
|
|
19416
19531
|
let sessions = listResponse.data.map((thread) => ({
|
|
19417
19532
|
sessionId: thread.id,
|
|
19418
19533
|
cwd: thread.cwd,
|
|
19419
|
-
title: thread.preview || null,
|
|
19534
|
+
title: (thread.name ?? thread.preview) || null,
|
|
19420
19535
|
updatedAt: new Date(thread.updatedAt * 1e3).toISOString()
|
|
19421
19536
|
}));
|
|
19422
19537
|
if (requestedCwd) {
|
|
19423
19538
|
const filtered = listResponse.data.filter(filterByCwd).map((thread) => ({
|
|
19424
19539
|
sessionId: thread.id,
|
|
19425
19540
|
cwd: thread.cwd,
|
|
19426
|
-
title: thread.preview || null,
|
|
19541
|
+
title: (thread.name ?? thread.preview) || null,
|
|
19427
19542
|
updatedAt: new Date(thread.updatedAt * 1e3).toISOString()
|
|
19428
19543
|
}));
|
|
19429
19544
|
if (filtered.length > 0 || path4.isAbsolute(requestedCwd)) {
|
|
@@ -19455,30 +19570,9 @@ var CodexAcpClient = class {
|
|
|
19455
19570
|
}
|
|
19456
19571
|
async runSessionListDiagnostics() {
|
|
19457
19572
|
const [allProviders, archivedAllProviders, customGateway] = await Promise.all([
|
|
19458
|
-
this.codexClient.threadList({
|
|
19459
|
-
|
|
19460
|
-
|
|
19461
|
-
sortKey: null,
|
|
19462
|
-
modelProviders: [],
|
|
19463
|
-
sourceKinds: null,
|
|
19464
|
-
archived: null
|
|
19465
|
-
}),
|
|
19466
|
-
this.codexClient.threadList({
|
|
19467
|
-
cursor: null,
|
|
19468
|
-
limit: null,
|
|
19469
|
-
sortKey: null,
|
|
19470
|
-
modelProviders: [],
|
|
19471
|
-
sourceKinds: null,
|
|
19472
|
-
archived: true
|
|
19473
|
-
}),
|
|
19474
|
-
this.codexClient.threadList({
|
|
19475
|
-
cursor: null,
|
|
19476
|
-
limit: null,
|
|
19477
|
-
sortKey: null,
|
|
19478
|
-
modelProviders: ["custom-gateway"],
|
|
19479
|
-
sourceKinds: null,
|
|
19480
|
-
archived: null
|
|
19481
|
-
})
|
|
19573
|
+
this.codexClient.threadList({}),
|
|
19574
|
+
this.codexClient.threadList({ archived: true }),
|
|
19575
|
+
this.codexClient.threadList({ modelProviders: ["custom-gateway"] })
|
|
19482
19576
|
]);
|
|
19483
19577
|
return {
|
|
19484
19578
|
allProviders: {
|
|
@@ -19583,13 +19677,6 @@ var CodexCommands = class {
|
|
|
19583
19677
|
logger.error(`Failed to publish available commands for session ${sessionId}`, err);
|
|
19584
19678
|
}
|
|
19585
19679
|
}
|
|
19586
|
-
async tryHandle(prompt, sessionState) {
|
|
19587
|
-
const command = this.parseCommand(prompt);
|
|
19588
|
-
if (command) {
|
|
19589
|
-
return this.handleCommand(command, sessionState);
|
|
19590
|
-
}
|
|
19591
|
-
return false;
|
|
19592
|
-
}
|
|
19593
19680
|
buildAvailableCommands(skillsEntries) {
|
|
19594
19681
|
const commands = /* @__PURE__ */ new Map();
|
|
19595
19682
|
for (const builtin of this.getBuiltinCommands()) {
|
|
@@ -19636,25 +19723,21 @@ var CodexCommands = class {
|
|
|
19636
19723
|
}
|
|
19637
19724
|
];
|
|
19638
19725
|
}
|
|
19639
|
-
|
|
19640
|
-
|
|
19641
|
-
|
|
19642
|
-
|
|
19643
|
-
if (
|
|
19644
|
-
const
|
|
19645
|
-
if (!trimmed.startsWith("/")) return null;
|
|
19646
|
-
const commandText = trimmed.slice(1).trim();
|
|
19726
|
+
getCommandName(prompt) {
|
|
19727
|
+
const firstBlock = prompt[0];
|
|
19728
|
+
if (!firstBlock || firstBlock.type != "text") return null;
|
|
19729
|
+
const text = firstBlock.text.trim();
|
|
19730
|
+
if (!text.startsWith("/")) return null;
|
|
19731
|
+
const commandText = text.slice(1).trim();
|
|
19647
19732
|
if (commandText.length === 0) return null;
|
|
19648
|
-
const [name
|
|
19649
|
-
|
|
19650
|
-
return {
|
|
19651
|
-
name: name.toLowerCase(),
|
|
19652
|
-
input: input.length > 0 ? input : null
|
|
19653
|
-
};
|
|
19733
|
+
const [name] = commandText.split(/\s+/);
|
|
19734
|
+
return name?.toLowerCase() ?? null;
|
|
19654
19735
|
}
|
|
19655
|
-
async
|
|
19736
|
+
async tryHandleCommand(prompt, sessionState) {
|
|
19737
|
+
const commandName = this.getCommandName(prompt);
|
|
19738
|
+
if (commandName === null) return false;
|
|
19656
19739
|
const sessionId = sessionState.sessionId;
|
|
19657
|
-
switch (
|
|
19740
|
+
switch (commandName) {
|
|
19658
19741
|
case "status": {
|
|
19659
19742
|
const session = new ACPSessionConnection(this.connection, sessionId);
|
|
19660
19743
|
const message = this.buildStatusMessage(sessionState);
|
|
@@ -19706,7 +19789,7 @@ var CodexCommands = class {
|
|
|
19706
19789
|
return true;
|
|
19707
19790
|
}
|
|
19708
19791
|
default:
|
|
19709
|
-
await this.sendUnknownCommandMessage(
|
|
19792
|
+
await this.sendUnknownCommandMessage(commandName, sessionId);
|
|
19710
19793
|
return true;
|
|
19711
19794
|
}
|
|
19712
19795
|
}
|
|
@@ -19863,8 +19946,47 @@ function isExtMethodRequest(request) {
|
|
|
19863
19946
|
return request.method === "authentication/status" || request.method === "authentication/logout";
|
|
19864
19947
|
}
|
|
19865
19948
|
|
|
19949
|
+
// src/FastModeConfig.ts
|
|
19950
|
+
var FAST_MODE_CONFIG_ID = "fast-mode";
|
|
19951
|
+
var FAST_MODE_ON = "on";
|
|
19952
|
+
var FAST_MODE_OFF = "off";
|
|
19953
|
+
var FAST_MODE_DESCRIPTION = "1.5x speed, increased usage";
|
|
19954
|
+
function modelSupportsFast(model) {
|
|
19955
|
+
return model?.additionalSpeedTiers?.includes("fast") ?? false;
|
|
19956
|
+
}
|
|
19957
|
+
function resolveFastServiceTier(fastModeEnabled, currentModelSupportsFast) {
|
|
19958
|
+
return fastModeEnabled && currentModelSupportsFast ? "fast" : null;
|
|
19959
|
+
}
|
|
19960
|
+
function createFastModeConfigOption(fastModeEnabled) {
|
|
19961
|
+
return {
|
|
19962
|
+
id: FAST_MODE_CONFIG_ID,
|
|
19963
|
+
name: "Fast mode",
|
|
19964
|
+
description: FAST_MODE_DESCRIPTION,
|
|
19965
|
+
category: FAST_MODE_CONFIG_ID,
|
|
19966
|
+
type: "select",
|
|
19967
|
+
currentValue: fastModeEnabled ? FAST_MODE_ON : FAST_MODE_OFF,
|
|
19968
|
+
options: [
|
|
19969
|
+
{
|
|
19970
|
+
value: FAST_MODE_OFF,
|
|
19971
|
+
name: "Off",
|
|
19972
|
+
description: "Default speed, normal usage"
|
|
19973
|
+
},
|
|
19974
|
+
{
|
|
19975
|
+
value: FAST_MODE_ON,
|
|
19976
|
+
name: "On",
|
|
19977
|
+
description: FAST_MODE_DESCRIPTION
|
|
19978
|
+
}
|
|
19979
|
+
]
|
|
19980
|
+
};
|
|
19981
|
+
}
|
|
19982
|
+
|
|
19866
19983
|
// src/CodexAcpServer.ts
|
|
19867
|
-
var CodexAcpServer = class {
|
|
19984
|
+
var CodexAcpServer = class _CodexAcpServer {
|
|
19985
|
+
static MODEL_NAME_TOKEN_OVERRIDES = {
|
|
19986
|
+
gpt: "GPT",
|
|
19987
|
+
mini: "Mini",
|
|
19988
|
+
codex: "Codex"
|
|
19989
|
+
};
|
|
19868
19990
|
codexAcpClient;
|
|
19869
19991
|
connection;
|
|
19870
19992
|
defaultAuthRequest;
|
|
@@ -19890,12 +20012,18 @@ var CodexAcpServer = class {
|
|
|
19890
20012
|
await this.runWithProcessCheck(() => this.codexAcpClient.initialize(_params));
|
|
19891
20013
|
return {
|
|
19892
20014
|
protocolVersion: PROTOCOL_VERSION,
|
|
20015
|
+
agentInfo: {
|
|
20016
|
+
name: package_default.name,
|
|
20017
|
+
title: "Codex",
|
|
20018
|
+
version: package_default.version
|
|
20019
|
+
},
|
|
19893
20020
|
agentCapabilities: {
|
|
19894
20021
|
auth: {
|
|
19895
20022
|
logout: {}
|
|
19896
20023
|
},
|
|
19897
20024
|
loadSession: true,
|
|
19898
20025
|
promptCapabilities: {
|
|
20026
|
+
embeddedContext: true,
|
|
19899
20027
|
image: true
|
|
19900
20028
|
},
|
|
19901
20029
|
sessionCapabilities: {
|
|
@@ -19903,6 +20031,7 @@ var CodexAcpServer = class {
|
|
|
19903
20031
|
list: {}
|
|
19904
20032
|
},
|
|
19905
20033
|
mcpCapabilities: {
|
|
20034
|
+
acp: false,
|
|
19906
20035
|
http: true,
|
|
19907
20036
|
sse: false
|
|
19908
20037
|
}
|
|
@@ -19941,6 +20070,23 @@ var CodexAcpServer = class {
|
|
|
19941
20070
|
}
|
|
19942
20071
|
}
|
|
19943
20072
|
async getOrCreateSession(request) {
|
|
20073
|
+
try {
|
|
20074
|
+
return await this.tryCreateSession(request);
|
|
20075
|
+
} catch (e) {
|
|
20076
|
+
const error40 = e instanceof Error ? e : new Error(String(e));
|
|
20077
|
+
await this.handleError(error40);
|
|
20078
|
+
throw e;
|
|
20079
|
+
}
|
|
20080
|
+
}
|
|
20081
|
+
async handleError(e) {
|
|
20082
|
+
if (e.message.includes("log out")) {
|
|
20083
|
+
await this.runWithProcessCheck(() => this.codexAcpClient.logout());
|
|
20084
|
+
throw RequestError.internalError(`${e.message}
|
|
20085
|
+
|
|
20086
|
+
You have been logged out. Please try again.`);
|
|
20087
|
+
}
|
|
20088
|
+
}
|
|
20089
|
+
async tryCreateSession(request) {
|
|
19944
20090
|
await this.checkAuthorization();
|
|
19945
20091
|
const requestedMcpServers = request.mcpServers ?? [];
|
|
19946
20092
|
const mcpServerStartupVersion = requestedMcpServers.length > 0 ? this.codexAcpClient.getMcpServerStartupVersion() : null;
|
|
@@ -19956,6 +20102,7 @@ var CodexAcpServer = class {
|
|
|
19956
20102
|
const { sessionId, currentModelId, models } = sessionMetadata;
|
|
19957
20103
|
const sessionMcpServers = this.resolveSessionMcpServers(requestedMcpServers, "sessionId" in request);
|
|
19958
20104
|
const currentModel = this.findCurrentModel(models, currentModelId);
|
|
20105
|
+
const currentModelSupportsFast = modelSupportsFast(currentModel);
|
|
19959
20106
|
const sessionState = {
|
|
19960
20107
|
sessionId,
|
|
19961
20108
|
currentModelId,
|
|
@@ -19969,6 +20116,8 @@ var CodexAcpServer = class {
|
|
|
19969
20116
|
rateLimits: null,
|
|
19970
20117
|
account,
|
|
19971
20118
|
cwd: request.cwd,
|
|
20119
|
+
fastModeEnabled: sessionMetadata.currentServiceTier === "fast",
|
|
20120
|
+
currentModelSupportsFast,
|
|
19972
20121
|
sessionMcpServers
|
|
19973
20122
|
};
|
|
19974
20123
|
this.sessions.set(sessionId, sessionState);
|
|
@@ -20007,7 +20156,8 @@ var CodexAcpServer = class {
|
|
|
20007
20156
|
});
|
|
20008
20157
|
return {
|
|
20009
20158
|
models: modelState,
|
|
20010
|
-
modes: modeState
|
|
20159
|
+
modes: modeState,
|
|
20160
|
+
configOptions: this.createSessionConfigOptions(this.getSessionState(sessionId))
|
|
20011
20161
|
};
|
|
20012
20162
|
}
|
|
20013
20163
|
async resumeSession(params) {
|
|
@@ -20020,7 +20170,8 @@ var CodexAcpServer = class {
|
|
|
20020
20170
|
});
|
|
20021
20171
|
return {
|
|
20022
20172
|
models: modelState,
|
|
20023
|
-
modes: modeState
|
|
20173
|
+
modes: modeState,
|
|
20174
|
+
configOptions: this.createSessionConfigOptions(this.getSessionState(sessionId))
|
|
20024
20175
|
};
|
|
20025
20176
|
}
|
|
20026
20177
|
async listSessions(params) {
|
|
@@ -20039,7 +20190,8 @@ var CodexAcpServer = class {
|
|
|
20039
20190
|
return {
|
|
20040
20191
|
sessionId,
|
|
20041
20192
|
models: modelState,
|
|
20042
|
-
modes: modeState
|
|
20193
|
+
modes: modeState,
|
|
20194
|
+
configOptions: this.createSessionConfigOptions(this.getSessionState(sessionId))
|
|
20043
20195
|
};
|
|
20044
20196
|
}
|
|
20045
20197
|
async authenticate(_params) {
|
|
@@ -20071,6 +20223,24 @@ var CodexAcpServer = class {
|
|
|
20071
20223
|
sessionState.agentMode = newMode;
|
|
20072
20224
|
return {};
|
|
20073
20225
|
}
|
|
20226
|
+
async setSessionConfigOption(params) {
|
|
20227
|
+
logger.log("Set session config option requested", {
|
|
20228
|
+
sessionId: params.sessionId,
|
|
20229
|
+
configId: params.configId
|
|
20230
|
+
});
|
|
20231
|
+
const sessionState = this.sessions.get(params.sessionId);
|
|
20232
|
+
if (!sessionState) throw new Error(`Session ${params.sessionId} not found`);
|
|
20233
|
+
if (params.configId !== FAST_MODE_CONFIG_ID || "type" in params && params.type === "boolean") {
|
|
20234
|
+
throw RequestError.invalidParams();
|
|
20235
|
+
}
|
|
20236
|
+
if (params.value !== FAST_MODE_ON && params.value !== FAST_MODE_OFF) {
|
|
20237
|
+
throw RequestError.invalidParams();
|
|
20238
|
+
}
|
|
20239
|
+
sessionState.fastModeEnabled = params.value === FAST_MODE_ON;
|
|
20240
|
+
return {
|
|
20241
|
+
configOptions: this.createSessionConfigOptions(sessionState)
|
|
20242
|
+
};
|
|
20243
|
+
}
|
|
20074
20244
|
async unstable_setSessionModel(params) {
|
|
20075
20245
|
logger.log("Set session model requested", {
|
|
20076
20246
|
sessionId: params.sessionId,
|
|
@@ -20100,8 +20270,14 @@ var CodexAcpServer = class {
|
|
|
20100
20270
|
sessionState.currentModelId = ModelId.fromComponents(model, reasoningEffort).toString();
|
|
20101
20271
|
sessionState.supportedReasoningEfforts = model.supportedReasoningEfforts;
|
|
20102
20272
|
sessionState.supportedInputModalities = model.inputModalities;
|
|
20273
|
+
sessionState.currentModelSupportsFast = modelSupportsFast(model);
|
|
20103
20274
|
return {};
|
|
20104
20275
|
}
|
|
20276
|
+
createSessionConfigOptions(sessionState) {
|
|
20277
|
+
return [
|
|
20278
|
+
createFastModeConfigOption(sessionState.fastModeEnabled)
|
|
20279
|
+
];
|
|
20280
|
+
}
|
|
20105
20281
|
publishAvailableCommandsAsync(sessionId) {
|
|
20106
20282
|
void this.availableCommands.publish(sessionId);
|
|
20107
20283
|
}
|
|
@@ -20109,11 +20285,14 @@ var CodexAcpServer = class {
|
|
|
20109
20285
|
const modelId = ModelId.fromString(currentModelId);
|
|
20110
20286
|
return models.find((m) => m.id === modelId.model);
|
|
20111
20287
|
}
|
|
20288
|
+
normalizeModelDisplayName(displayName) {
|
|
20289
|
+
return displayName.split("-").map((token) => _CodexAcpServer.MODEL_NAME_TOKEN_OVERRIDES[token.toLowerCase()] ?? token).join("-");
|
|
20290
|
+
}
|
|
20112
20291
|
createModelState(availableModels, selectedModelId) {
|
|
20113
20292
|
const allowedModels = availableModels.flatMap(
|
|
20114
20293
|
(model) => model.supportedReasoningEfforts.map((effort) => ({
|
|
20115
20294
|
modelId: ModelId.fromComponents(model, effort.reasoningEffort).toString(),
|
|
20116
|
-
name: `${model.displayName} (${effort.reasoningEffort})`,
|
|
20295
|
+
name: `${this.normalizeModelDisplayName(model.displayName)} (${effort.reasoningEffort})`,
|
|
20117
20296
|
description: `${model.description} ${effort.description}`
|
|
20118
20297
|
}))
|
|
20119
20298
|
);
|
|
@@ -20134,6 +20313,7 @@ var CodexAcpServer = class {
|
|
|
20134
20313
|
const { sessionId, currentModelId, models, thread } = sessionMetadata;
|
|
20135
20314
|
const sessionMcpServers = this.resolveSessionMcpServers(requestedMcpServers, true);
|
|
20136
20315
|
const currentModel = this.findCurrentModel(models, currentModelId);
|
|
20316
|
+
const currentModelSupportsFast = modelSupportsFast(currentModel);
|
|
20137
20317
|
const sessionState = {
|
|
20138
20318
|
sessionId,
|
|
20139
20319
|
currentModelId,
|
|
@@ -20147,6 +20327,8 @@ var CodexAcpServer = class {
|
|
|
20147
20327
|
rateLimits: null,
|
|
20148
20328
|
account,
|
|
20149
20329
|
cwd: request.cwd,
|
|
20330
|
+
fastModeEnabled: sessionMetadata.currentServiceTier === "fast",
|
|
20331
|
+
currentModelSupportsFast,
|
|
20150
20332
|
sessionMcpServers
|
|
20151
20333
|
};
|
|
20152
20334
|
this.sessions.set(sessionId, sessionState);
|
|
@@ -20439,7 +20621,7 @@ ${item.text}`
|
|
|
20439
20621
|
approvalHandler,
|
|
20440
20622
|
elicitationHandler
|
|
20441
20623
|
);
|
|
20442
|
-
if (await this.availableCommands.
|
|
20624
|
+
if (await this.availableCommands.tryHandleCommand(params.prompt, sessionState)) {
|
|
20443
20625
|
logger.log("Prompt handled by a command");
|
|
20444
20626
|
return {
|
|
20445
20627
|
stopReason: "end_turn",
|
|
@@ -20460,8 +20642,12 @@ ${item.text}`
|
|
|
20460
20642
|
throw RequestError.invalidRequest("The current model does not support image input");
|
|
20461
20643
|
}
|
|
20462
20644
|
const agentMode = sessionState.agentMode;
|
|
20645
|
+
const serviceTier = resolveFastServiceTier(
|
|
20646
|
+
sessionState.fastModeEnabled,
|
|
20647
|
+
sessionState.currentModelSupportsFast
|
|
20648
|
+
);
|
|
20463
20649
|
const turnCompleted = await this.runWithProcessCheck(
|
|
20464
|
-
() => this.codexAcpClient.sendPrompt(params, agentMode, modelId, disableSummary, sessionState.cwd)
|
|
20650
|
+
() => this.codexAcpClient.sendPrompt(params, agentMode, modelId, serviceTier, disableSummary, sessionState.cwd)
|
|
20465
20651
|
);
|
|
20466
20652
|
if (turnCompleted.turn.status === "interrupted") {
|
|
20467
20653
|
await this.connection.sessionUpdate({
|
|
@@ -20707,10 +20893,10 @@ var CodexAppServerClient = class {
|
|
|
20707
20893
|
threadResolvers.set(turnId, resolve);
|
|
20708
20894
|
});
|
|
20709
20895
|
}
|
|
20710
|
-
async listModels(params
|
|
20896
|
+
async listModels(params) {
|
|
20711
20897
|
return await this.sendRequest({ method: "model/list", params });
|
|
20712
20898
|
}
|
|
20713
|
-
async listSkills(params
|
|
20899
|
+
async listSkills(params) {
|
|
20714
20900
|
return await this.sendRequest({ method: "skills/list", params });
|
|
20715
20901
|
}
|
|
20716
20902
|
/**
|
|
@@ -20955,6 +21141,34 @@ async function runLoginCommand(args) {
|
|
|
20955
21141
|
return login(options);
|
|
20956
21142
|
}
|
|
20957
21143
|
|
|
21144
|
+
// src/CodexCli.ts
|
|
21145
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
21146
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
21147
|
+
function runCodexCli(codexPath, args) {
|
|
21148
|
+
const child = spawnCodexCli(codexPath, args);
|
|
21149
|
+
return new Promise((resolve, reject) => {
|
|
21150
|
+
child.on("error", reject);
|
|
21151
|
+
child.on("exit", (code, signal) => {
|
|
21152
|
+
if (signal) {
|
|
21153
|
+
process.kill(process.pid, signal);
|
|
21154
|
+
return;
|
|
21155
|
+
}
|
|
21156
|
+
resolve(code ?? 1);
|
|
21157
|
+
});
|
|
21158
|
+
});
|
|
21159
|
+
}
|
|
21160
|
+
function spawnCodexCli(codexPath, args) {
|
|
21161
|
+
const options = {
|
|
21162
|
+
env: process.env,
|
|
21163
|
+
stdio: "inherit"
|
|
21164
|
+
};
|
|
21165
|
+
if (codexPath) {
|
|
21166
|
+
return spawn2(codexPath, args, { ...options, shell: process.platform === "win32" });
|
|
21167
|
+
}
|
|
21168
|
+
const bundledCodexPath = createRequire2(import.meta.url).resolve("@openai/codex/bin/codex.js");
|
|
21169
|
+
return spawn2(process.execPath, [bundledCodexPath, ...args], options);
|
|
21170
|
+
}
|
|
21171
|
+
|
|
20958
21172
|
// src/index.ts
|
|
20959
21173
|
if (process.argv.includes("--version")) {
|
|
20960
21174
|
console.log(`${package_default.name} ${package_default.version}`);
|
|
@@ -20966,6 +21180,12 @@ if (process.argv[2] === "login") {
|
|
|
20966
21180
|
console.error("Login error:", error40.message);
|
|
20967
21181
|
process.exit(1);
|
|
20968
21182
|
});
|
|
21183
|
+
} else if (process.argv[2] === "cli") {
|
|
21184
|
+
const args = process.argv.slice(3);
|
|
21185
|
+
runCodexCli(process.env["CODEX_PATH"], args).then((exitCode) => process.exit(exitCode)).catch((error40) => {
|
|
21186
|
+
console.error("Codex CLI error:", error40.message);
|
|
21187
|
+
process.exit(1);
|
|
21188
|
+
});
|
|
20969
21189
|
} else {
|
|
20970
21190
|
startAcpServer();
|
|
20971
21191
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.45",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"bin": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"vitest": "^4.0.10"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@agentclientprotocol/sdk": "^0.
|
|
64
|
+
"@agentclientprotocol/sdk": "^0.22.1",
|
|
65
65
|
"@openai/codex": "^0.128.0",
|
|
66
66
|
"diff": "^8.0.3",
|
|
67
67
|
"open": "^11.0.0",
|