@nyssance/codex-acp-v2 0.7.4 → 0.7.6
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/CHANGELOG.md +30 -0
- package/dist/index.js +552 -167
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3406,7 +3406,7 @@ var require_main = __commonJS(function(exports) {
|
|
|
3406
3406
|
exports.createMessageConnection = createMessageConnection;
|
|
3407
3407
|
var ril_1 = __importDefault(require_ril());
|
|
3408
3408
|
ril_1.default.install();
|
|
3409
|
-
var
|
|
3409
|
+
var path9 = __importStar(__require("path"));
|
|
3410
3410
|
var os3 = __importStar(__require("os"));
|
|
3411
3411
|
var fs7 = __importStar(__require("fs"));
|
|
3412
3412
|
var crypto_1 = __require("crypto");
|
|
@@ -3564,7 +3564,7 @@ var require_main = __commonJS(function(exports) {
|
|
|
3564
3564
|
throw new Error(`Unable to generate a random pipe name with ${randomLength} characters.`);
|
|
3565
3565
|
}
|
|
3566
3566
|
const randomSuffix = (0, crypto_1.randomBytes)(Math.floor(randomLength / 2)).toString("hex");
|
|
3567
|
-
return
|
|
3567
|
+
return path9.join(tmpDir, `lsp-${randomSuffix}.sock`);
|
|
3568
3568
|
}
|
|
3569
3569
|
function createClientPipeTransport(pipeName, encoding = "utf-8") {
|
|
3570
3570
|
let connectResolve;
|
|
@@ -3681,9 +3681,7 @@ var AGENT_METHODS = {
|
|
|
3681
3681
|
var CLIENT_METHODS = {
|
|
3682
3682
|
session_request_permission: "session/request_permission",
|
|
3683
3683
|
session_update: "session/update",
|
|
3684
|
-
mcp_connect: "mcp/connect",
|
|
3685
3684
|
mcp_message: "mcp/message",
|
|
3686
|
-
mcp_disconnect: "mcp/disconnect",
|
|
3687
3685
|
elicitation_create: "elicitation/create",
|
|
3688
3686
|
elicitation_complete: "elicitation/complete"
|
|
3689
3687
|
};
|
|
@@ -15345,27 +15343,16 @@ var zCreateElicitationRequest = preserveCustomPayload(intersection(union([
|
|
|
15345
15343
|
})
|
|
15346
15344
|
})), "mode", ["form", "url"]);
|
|
15347
15345
|
var zMcpServerAcpId = string2();
|
|
15348
|
-
var
|
|
15349
|
-
serverId: zMcpServerAcpId,
|
|
15350
|
-
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
15351
|
-
return;
|
|
15352
|
-
})
|
|
15353
|
-
});
|
|
15354
|
-
var zMcpConnectionId = string2();
|
|
15346
|
+
var zMcpRequestId = string2();
|
|
15355
15347
|
var zMessageMcpRequest = object({
|
|
15356
|
-
|
|
15348
|
+
serverId: zMcpServerAcpId,
|
|
15349
|
+
requestId: zMcpRequestId,
|
|
15357
15350
|
method: string2(),
|
|
15358
15351
|
params: record(string2(), unknown()).nullish(),
|
|
15359
15352
|
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
15360
15353
|
return;
|
|
15361
15354
|
})
|
|
15362
15355
|
});
|
|
15363
|
-
var zDisconnectMcpRequest = object({
|
|
15364
|
-
connectionId: zMcpConnectionId,
|
|
15365
|
-
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
15366
|
-
return;
|
|
15367
|
-
})
|
|
15368
|
-
});
|
|
15369
15356
|
var zExtRequest = unknown();
|
|
15370
15357
|
var zAgentRequest = object({
|
|
15371
15358
|
id: zRequestId,
|
|
@@ -15373,9 +15360,7 @@ var zAgentRequest = object({
|
|
|
15373
15360
|
params: union([
|
|
15374
15361
|
zRequestPermissionRequest,
|
|
15375
15362
|
zCreateElicitationRequest,
|
|
15376
|
-
zConnectMcpRequest,
|
|
15377
15363
|
zMessageMcpRequest,
|
|
15378
|
-
zDisconnectMcpRequest,
|
|
15379
15364
|
zExtRequest
|
|
15380
15365
|
]).nullish()
|
|
15381
15366
|
});
|
|
@@ -15826,9 +15811,34 @@ var zSessionConfigOption = preserveCustomPayload(intersection(union([
|
|
|
15826
15811
|
return;
|
|
15827
15812
|
})
|
|
15828
15813
|
})), "type", ["boolean", "select"]);
|
|
15814
|
+
var zTextCommandInput = object({
|
|
15815
|
+
hint: string2(),
|
|
15816
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
15817
|
+
return;
|
|
15818
|
+
})
|
|
15819
|
+
});
|
|
15820
|
+
var zAvailableCommandInput = preserveCustomPayload(union([
|
|
15821
|
+
zTextCommandInput.and(object({
|
|
15822
|
+
type: literal("text")
|
|
15823
|
+
})),
|
|
15824
|
+
excludeKnownTags(object({
|
|
15825
|
+
type: string2()
|
|
15826
|
+
}), "type", ["text"])
|
|
15827
|
+
]), "type", ["text"]);
|
|
15828
|
+
var zAvailableCommand = object({
|
|
15829
|
+
name: string2(),
|
|
15830
|
+
description: string2(),
|
|
15831
|
+
input: defaultOnError(zAvailableCommandInput.nullish(), () => {
|
|
15832
|
+
return;
|
|
15833
|
+
}),
|
|
15834
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
15835
|
+
return;
|
|
15836
|
+
})
|
|
15837
|
+
});
|
|
15829
15838
|
var zNewSessionResponse = object({
|
|
15830
15839
|
sessionId: zSessionId,
|
|
15831
15840
|
configOptions: defaultOnError(vecSkipError(zSessionConfigOption).optional(), () => []),
|
|
15841
|
+
availableCommands: defaultOnError(vecSkipError(zAvailableCommand).optional(), () => []),
|
|
15832
15842
|
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
15833
15843
|
return;
|
|
15834
15844
|
})
|
|
@@ -15865,12 +15875,14 @@ var zDeleteSessionResponse = object({
|
|
|
15865
15875
|
var zForkSessionResponse = object({
|
|
15866
15876
|
sessionId: zSessionId,
|
|
15867
15877
|
configOptions: defaultOnError(vecSkipError(zSessionConfigOption).optional(), () => []),
|
|
15878
|
+
availableCommands: defaultOnError(vecSkipError(zAvailableCommand).optional(), () => []),
|
|
15868
15879
|
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
15869
15880
|
return;
|
|
15870
15881
|
})
|
|
15871
15882
|
});
|
|
15872
15883
|
var zResumeSessionResponse = object({
|
|
15873
15884
|
configOptions: defaultOnError(vecSkipError(zSessionConfigOption).optional(), () => []),
|
|
15885
|
+
availableCommands: defaultOnError(vecSkipError(zAvailableCommand).optional(), () => []),
|
|
15874
15886
|
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
15875
15887
|
return;
|
|
15876
15888
|
})
|
|
@@ -15993,7 +16005,6 @@ var zCloseNesResponse = object({
|
|
|
15993
16005
|
})
|
|
15994
16006
|
});
|
|
15995
16007
|
var zExtResponse = unknown();
|
|
15996
|
-
var zMessageMcpResponse = unknown();
|
|
15997
16008
|
var zErrorCode = union([
|
|
15998
16009
|
literal(-32700),
|
|
15999
16010
|
literal(-32600),
|
|
@@ -16037,8 +16048,7 @@ var zAgentResponse = union([
|
|
|
16037
16048
|
zStartNesResponse,
|
|
16038
16049
|
zSuggestNesResponse,
|
|
16039
16050
|
zCloseNesResponse,
|
|
16040
|
-
zExtResponse
|
|
16041
|
-
zMessageMcpResponse
|
|
16051
|
+
zExtResponse
|
|
16042
16052
|
])
|
|
16043
16053
|
}),
|
|
16044
16054
|
object({
|
|
@@ -16126,6 +16136,11 @@ var zRequiresActionStateUpdate = object({
|
|
|
16126
16136
|
return;
|
|
16127
16137
|
})
|
|
16128
16138
|
});
|
|
16139
|
+
var zUnknownStateUpdate = object({
|
|
16140
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
16141
|
+
return;
|
|
16142
|
+
})
|
|
16143
|
+
});
|
|
16129
16144
|
var zStateUpdate = preserveCustomPayload(union([
|
|
16130
16145
|
zRunningStateUpdate.and(object({
|
|
16131
16146
|
state: literal("running")
|
|
@@ -16136,10 +16151,13 @@ var zStateUpdate = preserveCustomPayload(union([
|
|
|
16136
16151
|
zRequiresActionStateUpdate.and(object({
|
|
16137
16152
|
state: literal("requires_action")
|
|
16138
16153
|
})),
|
|
16154
|
+
zUnknownStateUpdate.and(object({
|
|
16155
|
+
state: literal("unknown")
|
|
16156
|
+
})),
|
|
16139
16157
|
excludeKnownTags(object({
|
|
16140
16158
|
state: string2()
|
|
16141
|
-
}), "state", ["idle", "requires_action", "running"])
|
|
16142
|
-
]), "state", ["idle", "requires_action", "running"]);
|
|
16159
|
+
}), "state", ["idle", "requires_action", "running", "unknown"])
|
|
16160
|
+
]), "state", ["idle", "requires_action", "running", "unknown"]);
|
|
16143
16161
|
var zToolCallContentChunk = object({
|
|
16144
16162
|
toolCallId: zToolCallId,
|
|
16145
16163
|
content: zToolCallContent,
|
|
@@ -16261,30 +16279,6 @@ var zPlanRemoved = object({
|
|
|
16261
16279
|
return;
|
|
16262
16280
|
})
|
|
16263
16281
|
});
|
|
16264
|
-
var zTextCommandInput = object({
|
|
16265
|
-
hint: string2(),
|
|
16266
|
-
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
16267
|
-
return;
|
|
16268
|
-
})
|
|
16269
|
-
});
|
|
16270
|
-
var zAvailableCommandInput = preserveCustomPayload(union([
|
|
16271
|
-
zTextCommandInput.and(object({
|
|
16272
|
-
type: literal("text")
|
|
16273
|
-
})),
|
|
16274
|
-
excludeKnownTags(object({
|
|
16275
|
-
type: string2()
|
|
16276
|
-
}), "type", ["text"])
|
|
16277
|
-
]), "type", ["text"]);
|
|
16278
|
-
var zAvailableCommand = object({
|
|
16279
|
-
name: string2(),
|
|
16280
|
-
description: string2(),
|
|
16281
|
-
input: defaultOnError(zAvailableCommandInput.nullish(), () => {
|
|
16282
|
-
return;
|
|
16283
|
-
}),
|
|
16284
|
-
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
16285
|
-
return;
|
|
16286
|
-
})
|
|
16287
|
-
});
|
|
16288
16282
|
var zAvailableCommandsUpdate = object({
|
|
16289
16283
|
availableCommands: requiredDefaultOnError(vecSkipError(zAvailableCommand), () => []),
|
|
16290
16284
|
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
@@ -16369,6 +16363,65 @@ var zCompactionSummaryChunk = object({
|
|
|
16369
16363
|
return;
|
|
16370
16364
|
})
|
|
16371
16365
|
});
|
|
16366
|
+
var zSessionCancelCapabilities = object({
|
|
16367
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
16368
|
+
return;
|
|
16369
|
+
})
|
|
16370
|
+
});
|
|
16371
|
+
var zSubagentSessionCapabilities = object({
|
|
16372
|
+
cancel: defaultOnError(zSessionCancelCapabilities.nullish(), () => {
|
|
16373
|
+
return;
|
|
16374
|
+
}),
|
|
16375
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
16376
|
+
return;
|
|
16377
|
+
})
|
|
16378
|
+
});
|
|
16379
|
+
var zSubagentUpdate = object({
|
|
16380
|
+
sessionId: zSessionId,
|
|
16381
|
+
title: defaultOnError(string2().nullish(), () => {
|
|
16382
|
+
return;
|
|
16383
|
+
}),
|
|
16384
|
+
description: defaultOnError(string2().nullish(), () => {
|
|
16385
|
+
return;
|
|
16386
|
+
}),
|
|
16387
|
+
capabilities: defaultOnError(zSubagentSessionCapabilities.nullish(), () => {
|
|
16388
|
+
return;
|
|
16389
|
+
}),
|
|
16390
|
+
state: defaultOnError(zStateUpdate.nullish(), () => {
|
|
16391
|
+
return;
|
|
16392
|
+
}),
|
|
16393
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
16394
|
+
return;
|
|
16395
|
+
})
|
|
16396
|
+
});
|
|
16397
|
+
var zSessionMessage = object({
|
|
16398
|
+
messageId: zMessageId,
|
|
16399
|
+
senderSessionId: defaultOnError(zSessionId.nullish(), () => {
|
|
16400
|
+
return;
|
|
16401
|
+
}),
|
|
16402
|
+
recipientSessionId: defaultOnError(zSessionId.nullish(), () => {
|
|
16403
|
+
return;
|
|
16404
|
+
}),
|
|
16405
|
+
content: defaultOnError(vecSkipError(zContentBlock).nullish(), () => {
|
|
16406
|
+
return;
|
|
16407
|
+
}),
|
|
16408
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
16409
|
+
return;
|
|
16410
|
+
})
|
|
16411
|
+
});
|
|
16412
|
+
var zSessionMessageChunk = object({
|
|
16413
|
+
messageId: zMessageId,
|
|
16414
|
+
senderSessionId: defaultOnError(zSessionId.nullish(), () => {
|
|
16415
|
+
return;
|
|
16416
|
+
}),
|
|
16417
|
+
recipientSessionId: defaultOnError(zSessionId.nullish(), () => {
|
|
16418
|
+
return;
|
|
16419
|
+
}),
|
|
16420
|
+
content: zContentBlock,
|
|
16421
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
16422
|
+
return;
|
|
16423
|
+
})
|
|
16424
|
+
});
|
|
16372
16425
|
var zSessionUpdate = preserveCustomPayload(union([
|
|
16373
16426
|
zContentChunk.and(object({
|
|
16374
16427
|
sessionUpdate: literal("user_message_chunk")
|
|
@@ -16430,6 +16483,15 @@ var zSessionUpdate = preserveCustomPayload(union([
|
|
|
16430
16483
|
zCompactionSummaryChunk.and(object({
|
|
16431
16484
|
sessionUpdate: literal("compaction_summary_chunk")
|
|
16432
16485
|
})),
|
|
16486
|
+
zSubagentUpdate.and(object({
|
|
16487
|
+
sessionUpdate: literal("subagent_update")
|
|
16488
|
+
})),
|
|
16489
|
+
zSessionMessage.and(object({
|
|
16490
|
+
sessionUpdate: literal("session_message")
|
|
16491
|
+
})),
|
|
16492
|
+
zSessionMessageChunk.and(object({
|
|
16493
|
+
sessionUpdate: literal("session_message_chunk")
|
|
16494
|
+
})),
|
|
16433
16495
|
excludeKnownTags(object({
|
|
16434
16496
|
sessionUpdate: string2()
|
|
16435
16497
|
}), "sessionUpdate", [
|
|
@@ -16445,7 +16507,10 @@ var zSessionUpdate = preserveCustomPayload(union([
|
|
|
16445
16507
|
"plan_removed",
|
|
16446
16508
|
"plan_update",
|
|
16447
16509
|
"session_info_update",
|
|
16510
|
+
"session_message",
|
|
16511
|
+
"session_message_chunk",
|
|
16448
16512
|
"state_update",
|
|
16513
|
+
"subagent_update",
|
|
16449
16514
|
"terminal_output_chunk",
|
|
16450
16515
|
"terminal_update",
|
|
16451
16516
|
"tool_call_content_chunk",
|
|
@@ -16467,7 +16532,10 @@ var zSessionUpdate = preserveCustomPayload(union([
|
|
|
16467
16532
|
"plan_removed",
|
|
16468
16533
|
"plan_update",
|
|
16469
16534
|
"session_info_update",
|
|
16535
|
+
"session_message",
|
|
16536
|
+
"session_message_chunk",
|
|
16470
16537
|
"state_update",
|
|
16538
|
+
"subagent_update",
|
|
16471
16539
|
"terminal_output_chunk",
|
|
16472
16540
|
"terminal_update",
|
|
16473
16541
|
"tool_call_content_chunk",
|
|
@@ -16489,23 +16557,12 @@ var zCompleteElicitationNotification = object({
|
|
|
16489
16557
|
return;
|
|
16490
16558
|
})
|
|
16491
16559
|
});
|
|
16492
|
-
var zMessageMcpNotification = object({
|
|
16493
|
-
connectionId: zMcpConnectionId,
|
|
16494
|
-
method: string2(),
|
|
16495
|
-
params: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
16496
|
-
return;
|
|
16497
|
-
}),
|
|
16498
|
-
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
16499
|
-
return;
|
|
16500
|
-
})
|
|
16501
|
-
});
|
|
16502
16560
|
var zExtNotification = unknown();
|
|
16503
16561
|
var zAgentNotification = object({
|
|
16504
16562
|
method: string2(),
|
|
16505
16563
|
params: union([
|
|
16506
16564
|
zUpdateSessionNotification,
|
|
16507
16565
|
zCompleteElicitationNotification,
|
|
16508
|
-
zMessageMcpNotification,
|
|
16509
16566
|
zExtNotification
|
|
16510
16567
|
]).nullish()
|
|
16511
16568
|
});
|
|
@@ -16917,7 +16974,6 @@ var zClientRequest = object({
|
|
|
16917
16974
|
zStartNesRequest,
|
|
16918
16975
|
zSuggestNesRequest,
|
|
16919
16976
|
zCloseNesRequest,
|
|
16920
|
-
zMessageMcpRequest,
|
|
16921
16977
|
zExtRequest
|
|
16922
16978
|
]).nullish()
|
|
16923
16979
|
});
|
|
@@ -16972,25 +17028,35 @@ var zCreateElicitationResponse = preserveCustomPayload(intersection(union([
|
|
|
16972
17028
|
return;
|
|
16973
17029
|
})
|
|
16974
17030
|
})), "action", ["accept", "cancel", "decline"]);
|
|
16975
|
-
var
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
17031
|
+
var zMcpError = looseObject({
|
|
17032
|
+
code: int().min(-2147483648, {
|
|
17033
|
+
error: "Invalid value: Expected int32 to be >= -2147483648"
|
|
17034
|
+
}).max(2147483647, {
|
|
17035
|
+
error: "Invalid value: Expected int32 to be <= 2147483647"
|
|
17036
|
+
}),
|
|
17037
|
+
message: string2(),
|
|
17038
|
+
data: unknown().optional()
|
|
16980
17039
|
});
|
|
16981
|
-
var
|
|
16982
|
-
|
|
16983
|
-
|
|
17040
|
+
var zMessageMcpResponse = union([
|
|
17041
|
+
object({
|
|
17042
|
+
result: unknown(),
|
|
17043
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
17044
|
+
return;
|
|
17045
|
+
})
|
|
17046
|
+
}),
|
|
17047
|
+
object({
|
|
17048
|
+
error: zMcpError,
|
|
17049
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
17050
|
+
return;
|
|
17051
|
+
})
|
|
16984
17052
|
})
|
|
16985
|
-
|
|
17053
|
+
]);
|
|
16986
17054
|
var zClientResponse = union([
|
|
16987
17055
|
object({
|
|
16988
17056
|
id: zRequestId,
|
|
16989
17057
|
result: union([
|
|
16990
17058
|
zRequestPermissionResponse,
|
|
16991
17059
|
zCreateElicitationResponse,
|
|
16992
|
-
zConnectMcpResponse,
|
|
16993
|
-
zDisconnectMcpResponse,
|
|
16994
17060
|
zMessageMcpResponse,
|
|
16995
17061
|
zExtResponse
|
|
16996
17062
|
])
|
|
@@ -17080,6 +17146,15 @@ var zRejectNesNotification = object({
|
|
|
17080
17146
|
return;
|
|
17081
17147
|
})
|
|
17082
17148
|
});
|
|
17149
|
+
var zMessageMcpNotification = object({
|
|
17150
|
+
serverId: zMcpServerAcpId,
|
|
17151
|
+
requestId: zMcpRequestId,
|
|
17152
|
+
method: string2(),
|
|
17153
|
+
params: record(string2(), unknown()).nullish(),
|
|
17154
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
17155
|
+
return;
|
|
17156
|
+
})
|
|
17157
|
+
});
|
|
17083
17158
|
var zClientNotification = object({
|
|
17084
17159
|
method: string2(),
|
|
17085
17160
|
params: union([
|
|
@@ -17146,6 +17221,7 @@ var zGuardSessionConfigOptionCustom = object({
|
|
|
17146
17221
|
configId: zSessionConfigId,
|
|
17147
17222
|
name: string2()
|
|
17148
17223
|
});
|
|
17224
|
+
var zGuardAvailableCommandInputText = zTextCommandInput.and(object({ type: literal("text") }));
|
|
17149
17225
|
var zGuardNesSuggestionEdit = zNesEditSuggestion.and(object({ kind: literal("edit") }));
|
|
17150
17226
|
var zGuardNesSuggestionJump = zNesJumpSuggestion.and(object({ kind: literal("jump") }));
|
|
17151
17227
|
var zGuardNesSuggestionRename = zNesRenameSuggestion.and(object({ kind: literal("rename") }));
|
|
@@ -17173,14 +17249,17 @@ var zGuardSessionUpdateUsageUpdate = zUsageUpdate.and(object({ sessionUpdate: li
|
|
|
17173
17249
|
var zGuardSessionUpdateNotice = zNotice.and(object({ sessionUpdate: literal("notice") }));
|
|
17174
17250
|
var zGuardSessionUpdateCompactionUpdate = zCompactionUpdate.and(object({ sessionUpdate: literal("compaction_update") }));
|
|
17175
17251
|
var zGuardSessionUpdateCompactionSummaryChunk = zCompactionSummaryChunk.and(object({ sessionUpdate: literal("compaction_summary_chunk") }));
|
|
17252
|
+
var zGuardSessionUpdateSubagentUpdate = zSubagentUpdate.and(object({ sessionUpdate: literal("subagent_update") }));
|
|
17253
|
+
var zGuardSessionUpdateSessionMessage = zSessionMessage.and(object({ sessionUpdate: literal("session_message") }));
|
|
17254
|
+
var zGuardSessionUpdateSessionMessageChunk = zSessionMessageChunk.and(object({ sessionUpdate: literal("session_message_chunk") }));
|
|
17176
17255
|
var zGuardStateUpdateRunning = zRunningStateUpdate.and(object({ state: literal("running") }));
|
|
17177
17256
|
var zGuardStateUpdateIdle = zIdleStateUpdate.and(object({ state: literal("idle") }));
|
|
17178
17257
|
var zGuardStateUpdateRequiresAction = zRequiresActionStateUpdate.and(object({ state: literal("requires_action") }));
|
|
17258
|
+
var zGuardStateUpdateUnknown = zUnknownStateUpdate.and(object({ state: literal("unknown") }));
|
|
17179
17259
|
var zGuardPlanUpdateContentItems = zPlanItems.and(object({ type: literal("items") }));
|
|
17180
17260
|
var zGuardPlanUpdateContentFile = zPlanFile.and(object({ type: literal("file") }));
|
|
17181
17261
|
var zGuardPlanUpdateContentMarkdown = zPlanMarkdown.and(object({ type: literal("markdown") }));
|
|
17182
17262
|
var zGuardPlanUpdateContentCustom = object({ planId: zPlanId });
|
|
17183
|
-
var zGuardAvailableCommandInputText = zTextCommandInput.and(object({ type: literal("text") }));
|
|
17184
17263
|
var zGuardMcpServerHttp = zMcpServerHttp.and(object({ type: literal("http") }));
|
|
17185
17264
|
var zGuardMcpServerAcp = zMcpServerAcp.and(object({ type: literal("acp") }));
|
|
17186
17265
|
var zGuardMcpServerStdio = zMcpServerStdio.and(object({ type: literal("stdio") }));
|
|
@@ -17290,6 +17369,15 @@ var SessionUpdate = {
|
|
|
17290
17369
|
isCompactionSummaryChunk(value) {
|
|
17291
17370
|
return tagOf(value, "sessionUpdate") === "compaction_summary_chunk" && zGuardSessionUpdateCompactionSummaryChunk.safeParse(value).success;
|
|
17292
17371
|
},
|
|
17372
|
+
isSubagentUpdate(value) {
|
|
17373
|
+
return tagOf(value, "sessionUpdate") === "subagent_update" && zGuardSessionUpdateSubagentUpdate.safeParse(value).success;
|
|
17374
|
+
},
|
|
17375
|
+
isSessionMessage(value) {
|
|
17376
|
+
return tagOf(value, "sessionUpdate") === "session_message" && zGuardSessionUpdateSessionMessage.safeParse(value).success;
|
|
17377
|
+
},
|
|
17378
|
+
isSessionMessageChunk(value) {
|
|
17379
|
+
return tagOf(value, "sessionUpdate") === "session_message_chunk" && zGuardSessionUpdateSessionMessageChunk.safeParse(value).success;
|
|
17380
|
+
},
|
|
17293
17381
|
isCustom(value) {
|
|
17294
17382
|
const tag = tagOf(value, "sessionUpdate");
|
|
17295
17383
|
return typeof tag === "string" && ![
|
|
@@ -17305,7 +17393,10 @@ var SessionUpdate = {
|
|
|
17305
17393
|
"plan_removed",
|
|
17306
17394
|
"plan_update",
|
|
17307
17395
|
"session_info_update",
|
|
17396
|
+
"session_message",
|
|
17397
|
+
"session_message_chunk",
|
|
17308
17398
|
"state_update",
|
|
17399
|
+
"subagent_update",
|
|
17309
17400
|
"terminal_output_chunk",
|
|
17310
17401
|
"terminal_update",
|
|
17311
17402
|
"tool_call_content_chunk",
|
|
@@ -17326,9 +17417,12 @@ var StateUpdate = {
|
|
|
17326
17417
|
isRequiresAction(value) {
|
|
17327
17418
|
return tagOf(value, "state") === "requires_action" && zGuardStateUpdateRequiresAction.safeParse(value).success;
|
|
17328
17419
|
},
|
|
17420
|
+
isUnknown(value) {
|
|
17421
|
+
return tagOf(value, "state") === "unknown" && zGuardStateUpdateUnknown.safeParse(value).success;
|
|
17422
|
+
},
|
|
17329
17423
|
isCustom(value) {
|
|
17330
17424
|
const tag = tagOf(value, "state");
|
|
17331
|
-
return typeof tag === "string" && !["idle", "requires_action", "running"].includes(tag);
|
|
17425
|
+
return typeof tag === "string" && !["idle", "requires_action", "running", "unknown"].includes(tag);
|
|
17332
17426
|
}
|
|
17333
17427
|
};
|
|
17334
17428
|
var McpServer = {
|
|
@@ -18857,27 +18951,16 @@ var zCreateElicitationRequest2 = preserveCustomPayload(intersection(union([
|
|
|
18857
18951
|
})
|
|
18858
18952
|
})), "mode", ["form", "url"]);
|
|
18859
18953
|
var zMcpServerAcpId2 = string2();
|
|
18860
|
-
var
|
|
18861
|
-
serverId: zMcpServerAcpId2,
|
|
18862
|
-
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
18863
|
-
return;
|
|
18864
|
-
})
|
|
18865
|
-
});
|
|
18866
|
-
var zMcpConnectionId2 = string2();
|
|
18954
|
+
var zMcpRequestId2 = string2();
|
|
18867
18955
|
var zMessageMcpRequest2 = object({
|
|
18868
|
-
|
|
18956
|
+
serverId: zMcpServerAcpId2,
|
|
18957
|
+
requestId: zMcpRequestId2,
|
|
18869
18958
|
method: string2(),
|
|
18870
18959
|
params: record(string2(), unknown()).nullish(),
|
|
18871
18960
|
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
18872
18961
|
return;
|
|
18873
18962
|
})
|
|
18874
18963
|
});
|
|
18875
|
-
var zDisconnectMcpRequest2 = object({
|
|
18876
|
-
connectionId: zMcpConnectionId2,
|
|
18877
|
-
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
18878
|
-
return;
|
|
18879
|
-
})
|
|
18880
|
-
});
|
|
18881
18964
|
var zExtRequest2 = unknown();
|
|
18882
18965
|
var zAgentRequest2 = object({
|
|
18883
18966
|
id: zRequestId2,
|
|
@@ -18892,9 +18975,7 @@ var zAgentRequest2 = object({
|
|
|
18892
18975
|
zWaitForTerminalExitRequest,
|
|
18893
18976
|
zKillTerminalRequest,
|
|
18894
18977
|
zCreateElicitationRequest2,
|
|
18895
|
-
zConnectMcpRequest2,
|
|
18896
18978
|
zMessageMcpRequest2,
|
|
18897
|
-
zDisconnectMcpRequest2,
|
|
18898
18979
|
zExtRequest2
|
|
18899
18980
|
]).nullish()
|
|
18900
18981
|
});
|
|
@@ -19590,7 +19671,6 @@ var zCloseNesResponse2 = object({
|
|
|
19590
19671
|
})
|
|
19591
19672
|
});
|
|
19592
19673
|
var zExtResponse2 = unknown();
|
|
19593
|
-
var zMessageMcpResponse2 = unknown();
|
|
19594
19674
|
var zErrorCode2 = union([
|
|
19595
19675
|
literal(-32700),
|
|
19596
19676
|
literal(-32600),
|
|
@@ -19636,8 +19716,7 @@ var zAgentResponse2 = union([
|
|
|
19636
19716
|
zStartNesResponse2,
|
|
19637
19717
|
zSuggestNesResponse2,
|
|
19638
19718
|
zCloseNesResponse2,
|
|
19639
|
-
zExtResponse2
|
|
19640
|
-
zMessageMcpResponse2
|
|
19719
|
+
zExtResponse2
|
|
19641
19720
|
])
|
|
19642
19721
|
}),
|
|
19643
19722
|
object({
|
|
@@ -19855,6 +19934,108 @@ var zCompactionSummaryChunk2 = object({
|
|
|
19855
19934
|
return;
|
|
19856
19935
|
})
|
|
19857
19936
|
});
|
|
19937
|
+
var zSessionCancelCapabilities2 = object({
|
|
19938
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
19939
|
+
return;
|
|
19940
|
+
})
|
|
19941
|
+
});
|
|
19942
|
+
var zSubagentSessionCapabilities2 = object({
|
|
19943
|
+
cancel: defaultOnError(zSessionCancelCapabilities2.nullish(), () => {
|
|
19944
|
+
return;
|
|
19945
|
+
}),
|
|
19946
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
19947
|
+
return;
|
|
19948
|
+
})
|
|
19949
|
+
});
|
|
19950
|
+
var zRunningStateUpdate2 = object({
|
|
19951
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
19952
|
+
return;
|
|
19953
|
+
})
|
|
19954
|
+
});
|
|
19955
|
+
var zIdleStateUpdate2 = object({
|
|
19956
|
+
stopReason: defaultOnError(zStopReason2.nullish(), () => {
|
|
19957
|
+
return;
|
|
19958
|
+
}),
|
|
19959
|
+
usage: defaultOnError(zUsage2.nullish(), () => {
|
|
19960
|
+
return;
|
|
19961
|
+
}),
|
|
19962
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
19963
|
+
return;
|
|
19964
|
+
})
|
|
19965
|
+
});
|
|
19966
|
+
var zRequiresActionStateUpdate2 = object({
|
|
19967
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
19968
|
+
return;
|
|
19969
|
+
})
|
|
19970
|
+
});
|
|
19971
|
+
var zUnknownStateUpdate2 = object({
|
|
19972
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
19973
|
+
return;
|
|
19974
|
+
})
|
|
19975
|
+
});
|
|
19976
|
+
var zStateUpdate2 = preserveCustomPayload(union([
|
|
19977
|
+
zRunningStateUpdate2.and(object({
|
|
19978
|
+
state: literal("running")
|
|
19979
|
+
})),
|
|
19980
|
+
zIdleStateUpdate2.and(object({
|
|
19981
|
+
state: literal("idle")
|
|
19982
|
+
})),
|
|
19983
|
+
zRequiresActionStateUpdate2.and(object({
|
|
19984
|
+
state: literal("requires_action")
|
|
19985
|
+
})),
|
|
19986
|
+
zUnknownStateUpdate2.and(object({
|
|
19987
|
+
state: literal("unknown")
|
|
19988
|
+
})),
|
|
19989
|
+
excludeKnownTags(object({
|
|
19990
|
+
state: string2()
|
|
19991
|
+
}), "state", ["idle", "requires_action", "running", "unknown"])
|
|
19992
|
+
]), "state", ["idle", "requires_action", "running", "unknown"]);
|
|
19993
|
+
var zSubagentUpdate2 = object({
|
|
19994
|
+
sessionId: zSessionId2,
|
|
19995
|
+
title: defaultOnError(string2().nullish(), () => {
|
|
19996
|
+
return;
|
|
19997
|
+
}),
|
|
19998
|
+
description: defaultOnError(string2().nullish(), () => {
|
|
19999
|
+
return;
|
|
20000
|
+
}),
|
|
20001
|
+
capabilities: defaultOnError(zSubagentSessionCapabilities2.nullish(), () => {
|
|
20002
|
+
return;
|
|
20003
|
+
}),
|
|
20004
|
+
state: defaultOnError(zStateUpdate2.nullish(), () => {
|
|
20005
|
+
return;
|
|
20006
|
+
}),
|
|
20007
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
20008
|
+
return;
|
|
20009
|
+
})
|
|
20010
|
+
});
|
|
20011
|
+
var zSessionMessage2 = object({
|
|
20012
|
+
messageId: zMessageId2,
|
|
20013
|
+
senderSessionId: defaultOnError(zSessionId2.nullish(), () => {
|
|
20014
|
+
return;
|
|
20015
|
+
}),
|
|
20016
|
+
recipientSessionId: defaultOnError(zSessionId2.nullish(), () => {
|
|
20017
|
+
return;
|
|
20018
|
+
}),
|
|
20019
|
+
content: defaultOnError(vecSkipError(zContentBlock2).nullish(), () => {
|
|
20020
|
+
return;
|
|
20021
|
+
}),
|
|
20022
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
20023
|
+
return;
|
|
20024
|
+
})
|
|
20025
|
+
});
|
|
20026
|
+
var zSessionMessageChunk2 = object({
|
|
20027
|
+
messageId: zMessageId2,
|
|
20028
|
+
senderSessionId: defaultOnError(zSessionId2.nullish(), () => {
|
|
20029
|
+
return;
|
|
20030
|
+
}),
|
|
20031
|
+
recipientSessionId: defaultOnError(zSessionId2.nullish(), () => {
|
|
20032
|
+
return;
|
|
20033
|
+
}),
|
|
20034
|
+
content: zContentBlock2,
|
|
20035
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
20036
|
+
return;
|
|
20037
|
+
})
|
|
20038
|
+
});
|
|
19858
20039
|
var zSessionUpdate2 = union([
|
|
19859
20040
|
zContentChunk2.and(object({
|
|
19860
20041
|
sessionUpdate: literal("user_message_chunk")
|
|
@@ -19903,6 +20084,15 @@ var zSessionUpdate2 = union([
|
|
|
19903
20084
|
})),
|
|
19904
20085
|
zCompactionSummaryChunk2.and(object({
|
|
19905
20086
|
sessionUpdate: literal("compaction_summary_chunk")
|
|
20087
|
+
})),
|
|
20088
|
+
zSubagentUpdate2.and(object({
|
|
20089
|
+
sessionUpdate: literal("subagent_update")
|
|
20090
|
+
})),
|
|
20091
|
+
zSessionMessage2.and(object({
|
|
20092
|
+
sessionUpdate: literal("session_message")
|
|
20093
|
+
})),
|
|
20094
|
+
zSessionMessageChunk2.and(object({
|
|
20095
|
+
sessionUpdate: literal("session_message_chunk")
|
|
19906
20096
|
}))
|
|
19907
20097
|
]);
|
|
19908
20098
|
var zSessionNotification = object({
|
|
@@ -19918,23 +20108,12 @@ var zCompleteElicitationNotification2 = object({
|
|
|
19918
20108
|
return;
|
|
19919
20109
|
})
|
|
19920
20110
|
});
|
|
19921
|
-
var zMessageMcpNotification2 = object({
|
|
19922
|
-
connectionId: zMcpConnectionId2,
|
|
19923
|
-
method: string2(),
|
|
19924
|
-
params: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
19925
|
-
return;
|
|
19926
|
-
}),
|
|
19927
|
-
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
19928
|
-
return;
|
|
19929
|
-
})
|
|
19930
|
-
});
|
|
19931
20111
|
var zExtNotification2 = unknown();
|
|
19932
20112
|
var zAgentNotification2 = object({
|
|
19933
20113
|
method: string2(),
|
|
19934
20114
|
params: union([
|
|
19935
20115
|
zSessionNotification,
|
|
19936
20116
|
zCompleteElicitationNotification2,
|
|
19937
|
-
zMessageMcpNotification2,
|
|
19938
20117
|
zExtNotification2
|
|
19939
20118
|
]).nullish()
|
|
19940
20119
|
});
|
|
@@ -19974,6 +20153,11 @@ var zClientSessionCapabilities = object({
|
|
|
19974
20153
|
return;
|
|
19975
20154
|
})
|
|
19976
20155
|
});
|
|
20156
|
+
var zSubagentCapabilities = object({
|
|
20157
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
20158
|
+
return;
|
|
20159
|
+
})
|
|
20160
|
+
});
|
|
19977
20161
|
var zPlanCapabilities = object({
|
|
19978
20162
|
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
19979
20163
|
return;
|
|
@@ -20041,6 +20225,9 @@ var zClientCapabilities2 = object({
|
|
|
20041
20225
|
session: defaultOnError(zClientSessionCapabilities.nullish(), () => {
|
|
20042
20226
|
return;
|
|
20043
20227
|
}),
|
|
20228
|
+
subagents: defaultOnError(zSubagentCapabilities.nullish(), () => {
|
|
20229
|
+
return;
|
|
20230
|
+
}),
|
|
20044
20231
|
plan: defaultOnError(zPlanCapabilities.nullish(), () => {
|
|
20045
20232
|
return;
|
|
20046
20233
|
}),
|
|
@@ -20394,7 +20581,6 @@ var zClientRequest2 = object({
|
|
|
20394
20581
|
zStartNesRequest2,
|
|
20395
20582
|
zSuggestNesRequest2,
|
|
20396
20583
|
zCloseNesRequest2,
|
|
20397
|
-
zMessageMcpRequest2,
|
|
20398
20584
|
zExtRequest2
|
|
20399
20585
|
]).nullish()
|
|
20400
20586
|
});
|
|
@@ -20509,17 +20695,29 @@ var zCreateElicitationResponse2 = preserveCustomPayload(intersection(union([
|
|
|
20509
20695
|
return;
|
|
20510
20696
|
})
|
|
20511
20697
|
})), "action", ["accept", "cancel", "decline"]);
|
|
20512
|
-
var
|
|
20513
|
-
|
|
20514
|
-
|
|
20515
|
-
|
|
20516
|
-
|
|
20698
|
+
var zMcpError2 = looseObject({
|
|
20699
|
+
code: int().min(-2147483648, {
|
|
20700
|
+
error: "Invalid value: Expected int32 to be >= -2147483648"
|
|
20701
|
+
}).max(2147483647, {
|
|
20702
|
+
error: "Invalid value: Expected int32 to be <= 2147483647"
|
|
20703
|
+
}),
|
|
20704
|
+
message: string2(),
|
|
20705
|
+
data: unknown().optional()
|
|
20517
20706
|
});
|
|
20518
|
-
var
|
|
20519
|
-
|
|
20520
|
-
|
|
20707
|
+
var zMessageMcpResponse2 = union([
|
|
20708
|
+
object({
|
|
20709
|
+
result: unknown(),
|
|
20710
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
20711
|
+
return;
|
|
20712
|
+
})
|
|
20713
|
+
}),
|
|
20714
|
+
object({
|
|
20715
|
+
error: zMcpError2,
|
|
20716
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
20717
|
+
return;
|
|
20718
|
+
})
|
|
20521
20719
|
})
|
|
20522
|
-
|
|
20720
|
+
]);
|
|
20523
20721
|
var zClientResponse2 = union([
|
|
20524
20722
|
object({
|
|
20525
20723
|
id: zRequestId2,
|
|
@@ -20533,8 +20731,6 @@ var zClientResponse2 = union([
|
|
|
20533
20731
|
zWaitForTerminalExitResponse,
|
|
20534
20732
|
zKillTerminalResponse,
|
|
20535
20733
|
zCreateElicitationResponse2,
|
|
20536
|
-
zConnectMcpResponse2,
|
|
20537
|
-
zDisconnectMcpResponse2,
|
|
20538
20734
|
zMessageMcpResponse2,
|
|
20539
20735
|
zExtResponse2
|
|
20540
20736
|
])
|
|
@@ -20623,6 +20819,15 @@ var zRejectNesNotification2 = object({
|
|
|
20623
20819
|
return;
|
|
20624
20820
|
})
|
|
20625
20821
|
});
|
|
20822
|
+
var zMessageMcpNotification2 = object({
|
|
20823
|
+
serverId: zMcpServerAcpId2,
|
|
20824
|
+
requestId: zMcpRequestId2,
|
|
20825
|
+
method: string2(),
|
|
20826
|
+
params: record(string2(), unknown()).nullish(),
|
|
20827
|
+
_meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
|
|
20828
|
+
return;
|
|
20829
|
+
})
|
|
20830
|
+
});
|
|
20626
20831
|
var zClientNotification2 = object({
|
|
20627
20832
|
method: string2(),
|
|
20628
20833
|
params: union([
|
|
@@ -20675,7 +20880,7 @@ function assertV2BatchMethods(entries, requestMethods, notificationMethods) {
|
|
|
20675
20880
|
}
|
|
20676
20881
|
}
|
|
20677
20882
|
function parseV2InitializeRequest(params) {
|
|
20678
|
-
const request = zInitializeRequest.parse(params);
|
|
20883
|
+
const request = received(zInitializeRequest).parse(params);
|
|
20679
20884
|
if (request.protocolVersion !== PROTOCOL_VERSION) {
|
|
20680
20885
|
throw RequestError.invalidParams({
|
|
20681
20886
|
expectedProtocolVersion: PROTOCOL_VERSION,
|
|
@@ -20692,7 +20897,7 @@ function normalizeOutgoingV2InitializeRequest(params) {
|
|
|
20692
20897
|
});
|
|
20693
20898
|
}
|
|
20694
20899
|
function mapV2InitializeResponse(response) {
|
|
20695
|
-
const parsed = zInitializeResponse.parse(response);
|
|
20900
|
+
const parsed = received(zInitializeResponse).parse(response);
|
|
20696
20901
|
if (parsed.protocolVersion !== PROTOCOL_VERSION) {
|
|
20697
20902
|
throw RequestError.invalidRequest({
|
|
20698
20903
|
expectedProtocolVersion: PROTOCOL_VERSION,
|
|
@@ -20937,9 +21142,7 @@ var methods = {
|
|
|
20937
21142
|
update: CLIENT_METHODS.session_update
|
|
20938
21143
|
},
|
|
20939
21144
|
mcp: {
|
|
20940
|
-
|
|
20941
|
-
message: CLIENT_METHODS.mcp_message,
|
|
20942
|
-
disconnect: CLIENT_METHODS.mcp_disconnect
|
|
21145
|
+
message: CLIENT_METHODS.mcp_message
|
|
20943
21146
|
},
|
|
20944
21147
|
elicitation: {
|
|
20945
21148
|
create: CLIENT_METHODS.elicitation_create,
|
|
@@ -21453,6 +21656,9 @@ function parseParams(parser, params) {
|
|
|
21453
21656
|
}
|
|
21454
21657
|
return parser.parse(params);
|
|
21455
21658
|
}
|
|
21659
|
+
function received(validator) {
|
|
21660
|
+
return validator;
|
|
21661
|
+
}
|
|
21456
21662
|
function requestSpec(method, params, response, serializeResponse) {
|
|
21457
21663
|
return { method, params, response, serializeResponse };
|
|
21458
21664
|
}
|
|
@@ -21488,18 +21694,17 @@ var agentRequestSpecs = {
|
|
|
21488
21694
|
unstable_listProviders: requestSpec(AGENT_METHODS.providers_list, zListProvidersRequest, zListProvidersResponse),
|
|
21489
21695
|
unstable_setProvider: requestSpec(AGENT_METHODS.providers_set, zSetProviderRequest, zSetProviderResponse, emptyObjectResponse),
|
|
21490
21696
|
unstable_disableProvider: requestSpec(AGENT_METHODS.providers_disable, zDisableProviderRequest, zDisableProviderResponse, emptyObjectResponse),
|
|
21491
|
-
newSession: requestSpec(AGENT_METHODS.session_new, zNewSessionRequest, zNewSessionResponse),
|
|
21492
|
-
setSessionConfigOption: requestSpec(AGENT_METHODS.session_set_config_option, zSetSessionConfigOptionRequest, zSetSessionConfigOptionResponse),
|
|
21493
|
-
prompt: requestSpec(AGENT_METHODS.session_prompt, zPromptRequest, zPromptResponse),
|
|
21494
|
-
unstable_messageMcp: requestSpec(AGENT_METHODS.mcp_message, zMessageMcpRequest, zMessageMcpResponse),
|
|
21697
|
+
newSession: requestSpec(AGENT_METHODS.session_new, received(zNewSessionRequest), received(zNewSessionResponse)),
|
|
21698
|
+
setSessionConfigOption: requestSpec(AGENT_METHODS.session_set_config_option, received(zSetSessionConfigOptionRequest), received(zSetSessionConfigOptionResponse)),
|
|
21699
|
+
prompt: requestSpec(AGENT_METHODS.session_prompt, received(zPromptRequest), received(zPromptResponse)),
|
|
21495
21700
|
listSessions: requestSpec(AGENT_METHODS.session_list, zListSessionsRequest, zListSessionsResponse),
|
|
21496
21701
|
deleteSession: requestSpec(AGENT_METHODS.session_delete, zDeleteSessionRequest, zDeleteSessionResponse, emptyObjectResponse),
|
|
21497
|
-
unstable_forkSession: requestSpec(AGENT_METHODS.session_fork, zForkSessionRequest, zForkSessionResponse),
|
|
21498
|
-
resumeSession: requestSpec(AGENT_METHODS.session_resume, zResumeSessionRequest, zResumeSessionResponse),
|
|
21702
|
+
unstable_forkSession: requestSpec(AGENT_METHODS.session_fork, received(zForkSessionRequest), received(zForkSessionResponse)),
|
|
21703
|
+
resumeSession: requestSpec(AGENT_METHODS.session_resume, received(zResumeSessionRequest), received(zResumeSessionResponse)),
|
|
21499
21704
|
closeSession: requestSpec(AGENT_METHODS.session_close, zCloseSessionRequest, zCloseSessionResponse, emptyObjectResponse),
|
|
21500
21705
|
logoutAuth: requestSpec(AGENT_METHODS.auth_logout, zLogoutAuthRequest, zLogoutAuthResponse, emptyObjectResponse),
|
|
21501
21706
|
unstable_startNes: requestSpec(AGENT_METHODS.nes_start, zStartNesRequest, zStartNesResponse),
|
|
21502
|
-
unstable_suggestNes: requestSpec(AGENT_METHODS.nes_suggest, zSuggestNesRequest, zSuggestNesResponse),
|
|
21707
|
+
unstable_suggestNes: requestSpec(AGENT_METHODS.nes_suggest, received(zSuggestNesRequest), received(zSuggestNesResponse)),
|
|
21503
21708
|
unstable_closeNes: requestSpec(AGENT_METHODS.nes_close, zCloseNesRequest, zCloseNesResponse, emptyObjectResponse)
|
|
21504
21709
|
};
|
|
21505
21710
|
var agentNotificationSpecs = {
|
|
@@ -21514,15 +21719,12 @@ var agentNotificationSpecs = {
|
|
|
21514
21719
|
unstable_rejectNes: notificationSpec(AGENT_METHODS.nes_reject, zRejectNesNotification)
|
|
21515
21720
|
};
|
|
21516
21721
|
var clientRequestSpecs = {
|
|
21517
|
-
requestPermission: requestSpec(CLIENT_METHODS.session_request_permission, zRequestPermissionRequest, zRequestPermissionResponse),
|
|
21518
|
-
unstable_connectMcp: requestSpec(CLIENT_METHODS.mcp_connect, zConnectMcpRequest, zConnectMcpResponse),
|
|
21722
|
+
requestPermission: requestSpec(CLIENT_METHODS.session_request_permission, received(zRequestPermissionRequest), received(zRequestPermissionResponse)),
|
|
21519
21723
|
unstable_messageMcp: requestSpec(CLIENT_METHODS.mcp_message, zMessageMcpRequest, zMessageMcpResponse),
|
|
21520
|
-
|
|
21521
|
-
createElicitation: requestSpec(CLIENT_METHODS.elicitation_create, zCreateElicitationRequest, zCreateElicitationResponse)
|
|
21724
|
+
createElicitation: requestSpec(CLIENT_METHODS.elicitation_create, received(zCreateElicitationRequest), received(zCreateElicitationResponse))
|
|
21522
21725
|
};
|
|
21523
21726
|
var clientNotificationSpecs = {
|
|
21524
|
-
sessionUpdate: notificationSpec(CLIENT_METHODS.session_update, zUpdateSessionNotification),
|
|
21525
|
-
unstable_messageMcp: notificationSpec(CLIENT_METHODS.mcp_message, zMessageMcpNotification),
|
|
21727
|
+
sessionUpdate: notificationSpec(CLIENT_METHODS.session_update, received(zUpdateSessionNotification)),
|
|
21526
21728
|
completeElicitation: notificationSpec(CLIENT_METHODS.elicitation_complete, zCompleteElicitationNotification)
|
|
21527
21729
|
};
|
|
21528
21730
|
var agentRequestSpecsByMethod = specsByMethod(agentRequestSpecs);
|
|
@@ -21566,7 +21768,7 @@ class SessionUpdateRouter {
|
|
|
21566
21768
|
if (message.kind !== "notification" || message.method !== CLIENT_METHODS.session_update) {
|
|
21567
21769
|
return Handled.no(message);
|
|
21568
21770
|
}
|
|
21569
|
-
const notification = zUpdateSessionNotification.parse(message.params);
|
|
21771
|
+
const notification = received(zUpdateSessionNotification).parse(message.params);
|
|
21570
21772
|
const { update } = notification;
|
|
21571
21773
|
const isIdle = SessionUpdate.isStateUpdate(update) && StateUpdate.isIdle(update);
|
|
21572
21774
|
const activeSessions = this.activeSessions.get(notification.sessionId);
|
|
@@ -21844,7 +22046,7 @@ var package_default = {
|
|
|
21844
22046
|
publishConfig: {
|
|
21845
22047
|
access: "public"
|
|
21846
22048
|
},
|
|
21847
|
-
version: "0.7.
|
|
22049
|
+
version: "0.7.6",
|
|
21848
22050
|
description: "Native ACP v2 agent for the OpenAI Codex app-server",
|
|
21849
22051
|
packageManager: "bun@1.4.0",
|
|
21850
22052
|
engines: {
|
|
@@ -21910,7 +22112,7 @@ var package_default = {
|
|
|
21910
22112
|
vitest: "^4.1.11"
|
|
21911
22113
|
},
|
|
21912
22114
|
dependencies: {
|
|
21913
|
-
"@agentclientprotocol/sdk": "^1.
|
|
22115
|
+
"@agentclientprotocol/sdk": "^1.7.0",
|
|
21914
22116
|
diff: "^9.0.0",
|
|
21915
22117
|
open: "^11.0.2",
|
|
21916
22118
|
"vscode-jsonrpc": "^9.0.2"
|
|
@@ -22104,7 +22306,7 @@ function classifyTurnError(info) {
|
|
|
22104
22306
|
}
|
|
22105
22307
|
|
|
22106
22308
|
// src/agent/CodexAgent.ts
|
|
22107
|
-
import
|
|
22309
|
+
import path8 from "path";
|
|
22108
22310
|
|
|
22109
22311
|
// src/util/logger.ts
|
|
22110
22312
|
import fs from "fs";
|
|
@@ -23664,6 +23866,21 @@ function itemSnapshot(item) {
|
|
|
23664
23866
|
}
|
|
23665
23867
|
}
|
|
23666
23868
|
|
|
23869
|
+
// src/bridge/turnMetadata.ts
|
|
23870
|
+
function withTurnId(update, turnId, startedAt) {
|
|
23871
|
+
switch (update.sessionUpdate) {
|
|
23872
|
+
case "user_message":
|
|
23873
|
+
case "agent_message":
|
|
23874
|
+
case "agent_message_chunk": {
|
|
23875
|
+
const meta = update._meta;
|
|
23876
|
+
const codex = meta?.["codex"];
|
|
23877
|
+
return { ...update, _meta: { ...meta, codex: { ...codex, turnId, ...startedAt == null ? {} : { turnStartedAt: startedAt * 1000 } } } };
|
|
23878
|
+
}
|
|
23879
|
+
default:
|
|
23880
|
+
return update;
|
|
23881
|
+
}
|
|
23882
|
+
}
|
|
23883
|
+
|
|
23667
23884
|
// src/bridge/EventBridge.ts
|
|
23668
23885
|
var TURN_PLAN_ID = "codex-turn-plan";
|
|
23669
23886
|
var PLAN_STREAM_INTERVAL_MS = 150;
|
|
@@ -23675,9 +23892,11 @@ class EventBridge {
|
|
|
23675
23892
|
lastError = null;
|
|
23676
23893
|
completedPlan = null;
|
|
23677
23894
|
noticeSequence = 0;
|
|
23895
|
+
turnTime = null;
|
|
23678
23896
|
openToolCalls = new Set;
|
|
23679
23897
|
announcedTools = new Set;
|
|
23680
23898
|
messagePhases = new Map;
|
|
23899
|
+
promptMeta = new Map;
|
|
23681
23900
|
reasoningWithDeltas = new Set;
|
|
23682
23901
|
terminalItems = new Set;
|
|
23683
23902
|
imageGenerations = new Set;
|
|
@@ -23693,6 +23912,9 @@ class EventBridge {
|
|
|
23693
23912
|
this.client = client;
|
|
23694
23913
|
this.session = session;
|
|
23695
23914
|
}
|
|
23915
|
+
rememberPromptMeta(messageId, meta) {
|
|
23916
|
+
this.promptMeta.set(messageId, meta);
|
|
23917
|
+
}
|
|
23696
23918
|
beginTurn() {
|
|
23697
23919
|
this.lastError = null;
|
|
23698
23920
|
this.completedPlan = null;
|
|
@@ -23717,17 +23939,21 @@ class EventBridge {
|
|
|
23717
23939
|
this.completedPlan = null;
|
|
23718
23940
|
return plan;
|
|
23719
23941
|
}
|
|
23720
|
-
async restore(items) {
|
|
23942
|
+
async restore(items, turnId) {
|
|
23721
23943
|
for (const item of items) {
|
|
23722
23944
|
if (item.type === "commandExecution" && item.status === "inProgress" && usesTerminal(item))
|
|
23723
23945
|
this.terminalItems.add(item.id);
|
|
23724
23946
|
for (const update of itemSnapshot(item)) {
|
|
23725
23947
|
this.trackToolCall(update);
|
|
23726
|
-
await this.client.update(update);
|
|
23948
|
+
await this.client.update(withTurnId(update, turnId));
|
|
23727
23949
|
}
|
|
23728
23950
|
}
|
|
23729
23951
|
}
|
|
23730
23952
|
async handle(notification) {
|
|
23953
|
+
if (notification.method === "turn/started" || notification.method === "turn/completed") {
|
|
23954
|
+
const { id, startedAt } = notification.params.turn;
|
|
23955
|
+
this.turnTime = { id, startedAt };
|
|
23956
|
+
}
|
|
23731
23957
|
let updates = await this.translate(notification);
|
|
23732
23958
|
if (notification.method === "item/completed") {
|
|
23733
23959
|
const snapshots = itemSnapshot(notification.params.item);
|
|
@@ -23738,7 +23964,8 @@ class EventBridge {
|
|
|
23738
23964
|
}
|
|
23739
23965
|
for (const update of updates) {
|
|
23740
23966
|
this.trackToolCall(update);
|
|
23741
|
-
|
|
23967
|
+
const turnId = "turnId" in notification.params ? notification.params.turnId : null;
|
|
23968
|
+
await this.client.update(typeof turnId === "string" ? withTurnId(update, turnId, this.turnTime?.id === turnId ? this.turnTime.startedAt : null) : update);
|
|
23742
23969
|
}
|
|
23743
23970
|
}
|
|
23744
23971
|
async finishOpenToolCalls(status) {
|
|
@@ -23969,7 +24196,12 @@ ${details}` : summary)];
|
|
|
23969
24196
|
return [compactionUpdate(item.id, "in_progress")];
|
|
23970
24197
|
case "userMessage": {
|
|
23971
24198
|
const content = item.content.flatMap(fromUserInput);
|
|
23972
|
-
|
|
24199
|
+
if (content.length === 0)
|
|
24200
|
+
return [];
|
|
24201
|
+
const messageId = item.clientId ?? item.id;
|
|
24202
|
+
const meta = this.promptMeta.get(messageId);
|
|
24203
|
+
this.promptMeta.delete(messageId);
|
|
24204
|
+
return [{ sessionUpdate: "user_message", messageId, content, ...meta ? { _meta: meta } : {} }];
|
|
23973
24205
|
}
|
|
23974
24206
|
case "hookPrompt":
|
|
23975
24207
|
case "functionCallOutput":
|
|
@@ -26630,7 +26862,7 @@ function historyUpdates(turns) {
|
|
|
26630
26862
|
const updates = [];
|
|
26631
26863
|
for (const turn of turns) {
|
|
26632
26864
|
for (const item of turn.items) {
|
|
26633
|
-
updates.push(...itemSnapshot(item));
|
|
26865
|
+
updates.push(...itemSnapshot(item).map((update) => withTurnId(update, turn.id, turn.startedAt)));
|
|
26634
26866
|
}
|
|
26635
26867
|
}
|
|
26636
26868
|
return updates;
|
|
@@ -26656,6 +26888,93 @@ function firstLine(text2) {
|
|
|
26656
26888
|
return line.length > 120 ? `${line.slice(0, 117)}...` : line;
|
|
26657
26889
|
}
|
|
26658
26890
|
|
|
26891
|
+
// src/agent/forkIndex.ts
|
|
26892
|
+
import { createReadStream } from "fs";
|
|
26893
|
+
import { readdir, realpath } from "fs/promises";
|
|
26894
|
+
import path7 from "path";
|
|
26895
|
+
import { createInterface } from "readline";
|
|
26896
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
26897
|
+
var SOURCES = new Set(["cli", "vscode", "exec", "appServer", "unknown"]);
|
|
26898
|
+
var missing = (error40) => error40?.code === "ENOENT";
|
|
26899
|
+
async function nativeForks(codexHome, archived, cwd, read) {
|
|
26900
|
+
const root = path7.join(codexHome, archived ? "archived_sessions" : "sessions");
|
|
26901
|
+
const wantedCwd = cwd === null ? null : await realpath(cwd).catch((error40) => {
|
|
26902
|
+
if (missing(error40))
|
|
26903
|
+
return cwd;
|
|
26904
|
+
throw error40;
|
|
26905
|
+
});
|
|
26906
|
+
const result = [];
|
|
26907
|
+
for await (const file2 of rolloutFiles(root)) {
|
|
26908
|
+
const header = await firstLine2(file2);
|
|
26909
|
+
if (header === null)
|
|
26910
|
+
continue;
|
|
26911
|
+
let value;
|
|
26912
|
+
try {
|
|
26913
|
+
value = JSON.parse(header);
|
|
26914
|
+
} catch {
|
|
26915
|
+
continue;
|
|
26916
|
+
}
|
|
26917
|
+
if (!value || typeof value !== "object" || !("type" in value) || value.type !== "session_meta" || !("payload" in value))
|
|
26918
|
+
continue;
|
|
26919
|
+
const meta = value.payload;
|
|
26920
|
+
if (!meta || typeof meta["id"] !== "string" || !UUID.test(meta["id"]) || typeof meta["forked_from_id"] !== "string" || !UUID.test(meta["forked_from_id"]) || typeof meta["source"] !== "string" || !SOURCES.has(meta["source"]) || wantedCwd !== null && meta["cwd"] !== wantedCwd && meta["cwd"] !== cwd)
|
|
26921
|
+
continue;
|
|
26922
|
+
const thread = await read(meta["id"]).catch(async (error40) => {
|
|
26923
|
+
try {
|
|
26924
|
+
await realpath(file2);
|
|
26925
|
+
} catch (statError) {
|
|
26926
|
+
if (missing(statError))
|
|
26927
|
+
return null;
|
|
26928
|
+
}
|
|
26929
|
+
throw error40;
|
|
26930
|
+
});
|
|
26931
|
+
if (thread && thread.forkedFromId !== null) {
|
|
26932
|
+
try {
|
|
26933
|
+
await realpath(file2);
|
|
26934
|
+
} catch (error40) {
|
|
26935
|
+
if (missing(error40))
|
|
26936
|
+
continue;
|
|
26937
|
+
throw error40;
|
|
26938
|
+
}
|
|
26939
|
+
result.push(cwd === null ? thread : { ...thread, cwd });
|
|
26940
|
+
}
|
|
26941
|
+
}
|
|
26942
|
+
return result;
|
|
26943
|
+
}
|
|
26944
|
+
async function* rolloutFiles(directory) {
|
|
26945
|
+
let entries;
|
|
26946
|
+
try {
|
|
26947
|
+
entries = await readdir(directory, { withFileTypes: true });
|
|
26948
|
+
} catch (error40) {
|
|
26949
|
+
if (missing(error40))
|
|
26950
|
+
return;
|
|
26951
|
+
throw error40;
|
|
26952
|
+
}
|
|
26953
|
+
for (const entry of entries) {
|
|
26954
|
+
const file2 = path7.join(directory, entry.name);
|
|
26955
|
+
if (entry.isDirectory())
|
|
26956
|
+
yield* rolloutFiles(file2);
|
|
26957
|
+
else if (entry.isFile() && /^rollout-.*\.jsonl$/.test(entry.name))
|
|
26958
|
+
yield file2;
|
|
26959
|
+
}
|
|
26960
|
+
}
|
|
26961
|
+
async function firstLine2(file2) {
|
|
26962
|
+
const stream = createReadStream(file2, { encoding: "utf8" });
|
|
26963
|
+
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
26964
|
+
try {
|
|
26965
|
+
for await (const line of lines)
|
|
26966
|
+
return line;
|
|
26967
|
+
return null;
|
|
26968
|
+
} catch (error40) {
|
|
26969
|
+
if (missing(error40))
|
|
26970
|
+
return null;
|
|
26971
|
+
throw error40;
|
|
26972
|
+
} finally {
|
|
26973
|
+
lines.close();
|
|
26974
|
+
stream.destroy();
|
|
26975
|
+
}
|
|
26976
|
+
}
|
|
26977
|
+
|
|
26659
26978
|
// src/agent/session.ts
|
|
26660
26979
|
function createActiveTurn(threadId, clientUserMessageId = null) {
|
|
26661
26980
|
let resolveStarted = () => {};
|
|
@@ -26723,6 +27042,7 @@ class CodexAgent {
|
|
|
26723
27042
|
sessions = new Map;
|
|
26724
27043
|
capabilities = null;
|
|
26725
27044
|
codexInitialized = false;
|
|
27045
|
+
codexHome = null;
|
|
26726
27046
|
initializing = null;
|
|
26727
27047
|
terminalTurns = new WeakSet;
|
|
26728
27048
|
completedTurns = new WeakMap;
|
|
@@ -26773,10 +27093,11 @@ class CodexAgent {
|
|
|
26773
27093
|
};
|
|
26774
27094
|
if (!this.codexInitialized) {
|
|
26775
27095
|
this.initializing ??= this.withCodex(async () => {
|
|
26776
|
-
await this.codex.initialize({
|
|
27096
|
+
const initialized = await this.codex.initialize({
|
|
26777
27097
|
clientInfo: { name: params.info.name, title: params.info.title ?? null, version: params.info.version },
|
|
26778
27098
|
capabilities: { experimentalApi: true, requestAttestation: false }
|
|
26779
27099
|
});
|
|
27100
|
+
this.codexHome = initialized.codexHome;
|
|
26780
27101
|
this.codexInitialized = true;
|
|
26781
27102
|
}).finally(() => {
|
|
26782
27103
|
this.initializing = null;
|
|
@@ -26796,7 +27117,7 @@ class CodexAgent {
|
|
|
26796
27117
|
additionalDirectories: {}
|
|
26797
27118
|
},
|
|
26798
27119
|
providers: {},
|
|
26799
|
-
_meta: { alwith: { tools: { version: 1 }, turns: { version: 2 } }, codex: { archive: true, seedHistory: true, skills: true, plugins: true, providerCatalog: true, rename: true, account: true, fuzzyFileSearch: true } }
|
|
27120
|
+
_meta: { alwith: { tools: { version: 1 }, turns: { version: 2 } }, codex: { forkAtTurn: true, sessionLineage: true, archive: true, seedHistory: true, skills: true, plugins: true, providerCatalog: true, rename: true, account: true, fuzzyFileSearch: true } }
|
|
26800
27121
|
},
|
|
26801
27122
|
authMethods: authMethods(this.capabilities, this.env)
|
|
26802
27123
|
};
|
|
@@ -26971,16 +27292,16 @@ class CodexAgent {
|
|
|
26971
27292
|
}
|
|
26972
27293
|
async newSession(params, signal) {
|
|
26973
27294
|
const runtime = await this.openSession({ kind: "new", request: params }, signal);
|
|
26974
|
-
return { sessionId: runtime.session.id, configOptions: sessionConfigOptions(runtime.session) };
|
|
27295
|
+
return { sessionId: runtime.session.id, configOptions: sessionConfigOptions(runtime.session), _meta: { codex: runtime.lineage } };
|
|
26975
27296
|
}
|
|
26976
27297
|
async resumeSession(params, signal) {
|
|
26977
27298
|
const runtime = await this.openSession({ kind: "resume", request: params }, signal);
|
|
26978
27299
|
const configOptions = sessionConfigOptions(runtime.session);
|
|
26979
|
-
return
|
|
27300
|
+
return { configOptions, _meta: { codex: { ...runtime.lineage, ...runtime.readOnly ? { readOnly: true, reason: "active_writer" } : {} } } };
|
|
26980
27301
|
}
|
|
26981
27302
|
async forkSession(params, signal) {
|
|
26982
27303
|
const runtime = await this.openSession({ kind: "fork", request: params }, signal);
|
|
26983
|
-
return { sessionId: runtime.session.id, configOptions: sessionConfigOptions(runtime.session) };
|
|
27304
|
+
return { sessionId: runtime.session.id, configOptions: sessionConfigOptions(runtime.session), _meta: { codex: runtime.lineage } };
|
|
26984
27305
|
}
|
|
26985
27306
|
async openSession(open2, signal) {
|
|
26986
27307
|
if (signal?.aborted)
|
|
@@ -27012,7 +27333,8 @@ class CodexAgent {
|
|
|
27012
27333
|
if (open2.kind !== "new")
|
|
27013
27334
|
this.assertUnsubscribeSettled(open2.request.sessionId);
|
|
27014
27335
|
const { request } = open2;
|
|
27015
|
-
|
|
27336
|
+
const lastTurnId = open2.kind === "fork" ? forkTurnId(request._meta) : undefined;
|
|
27337
|
+
if (typeof request.cwd !== "string" || !path8.isAbsolute(request.cwd)) {
|
|
27016
27338
|
throw RequestError.invalidParams({ cwd: request.cwd }, "cwd must be an absolute path");
|
|
27017
27339
|
}
|
|
27018
27340
|
if (open2.kind === "resume" && open2.request.replayFrom != null && open2.request.replayFrom.type !== "start") {
|
|
@@ -27077,7 +27399,7 @@ class CodexAgent {
|
|
|
27077
27399
|
return readOnlyThread((await this.codex.threadRead({ threadId: open2.request.sessionId, includeTurns: false })).thread, request.cwd);
|
|
27078
27400
|
}
|
|
27079
27401
|
case "fork":
|
|
27080
|
-
return await this.codex.threadFork({ ...hostThreadOptions, threadId: open2.request.sessionId, config: config2, cwd: request.cwd, modelProvider, model: startModel, excludeTurns: true });
|
|
27402
|
+
return await this.codex.threadFork({ ...hostThreadOptions, ...lastTurnId === undefined ? {} : { lastTurnId }, threadId: open2.request.sessionId, config: config2, cwd: request.cwd, modelProvider, model: startModel, excludeTurns: true });
|
|
27081
27403
|
}
|
|
27082
27404
|
}) }));
|
|
27083
27405
|
const sessionId = thread.thread.id;
|
|
@@ -27127,7 +27449,7 @@ class CodexAgent {
|
|
|
27127
27449
|
contextWindow: null,
|
|
27128
27450
|
closed: false
|
|
27129
27451
|
};
|
|
27130
|
-
const runtime = this.installRuntime(session, capabilities, config2, gatewayId ?? thread.modelProvider, readOnly);
|
|
27452
|
+
const runtime = this.installRuntime(session, capabilities, config2, gatewayId ?? thread.modelProvider, threadLineage(thread.thread), readOnly);
|
|
27131
27453
|
const cancelOpening = () => {
|
|
27132
27454
|
runtime.session.closed = true;
|
|
27133
27455
|
runtime.lifetime.abort();
|
|
@@ -27174,7 +27496,7 @@ class CodexAgent {
|
|
|
27174
27496
|
stopObservingOpen();
|
|
27175
27497
|
}
|
|
27176
27498
|
}
|
|
27177
|
-
installRuntime(session, capabilities, config2, modelProvider, readOnly = false) {
|
|
27499
|
+
installRuntime(session, capabilities, config2, modelProvider, lineage, readOnly = false) {
|
|
27178
27500
|
const client = new ClientSession(session.id, this.link, capabilities);
|
|
27179
27501
|
const bridge = new EventBridge(client, session);
|
|
27180
27502
|
const turnContext = new TurnContext(session.id);
|
|
@@ -27184,7 +27506,7 @@ class CodexAgent {
|
|
|
27184
27506
|
};
|
|
27185
27507
|
const approval = new CodexApprovalHandler(client, turnContext, signal);
|
|
27186
27508
|
const elicitation = new CodexElicitationHandler(client, turnContext, signal);
|
|
27187
|
-
const runtime = { config: config2, modelProvider, stale: false, readOnly, session, client, bridge, turnContext, elicitation, lifetime: new AbortController, queue: Promise.resolve() };
|
|
27509
|
+
const runtime = { lineage, config: config2, modelProvider, stale: false, readOnly, session, client, bridge, turnContext, elicitation, lifetime: new AbortController, queue: Promise.resolve() };
|
|
27188
27510
|
const tools = new ClientTools(session, client, AbortSignal.any([runtime.lifetime.signal, this.codex.disconnectSignal]));
|
|
27189
27511
|
const drained = (operation) => async (params) => {
|
|
27190
27512
|
await abortable(this.drain(runtime), this.codex.disconnectSignal);
|
|
@@ -27271,10 +27593,31 @@ class CodexAgent {
|
|
|
27271
27593
|
await publishTitle(firstPage.data);
|
|
27272
27594
|
return;
|
|
27273
27595
|
}
|
|
27596
|
+
const parentTurns = new Set;
|
|
27597
|
+
if (thread.forkedFromId !== null) {
|
|
27598
|
+
let parentCursor = null;
|
|
27599
|
+
const seen = new Set;
|
|
27600
|
+
do {
|
|
27601
|
+
const page = await this.withCodex(() => this.codex.threadTurnsList({ threadId: thread.forkedFromId, cursor: parentCursor, limit: HISTORY_PAGE_SIZE, sortDirection: "asc", itemsView: "summary" }));
|
|
27602
|
+
for (const turn of page.data)
|
|
27603
|
+
parentTurns.add(turn.id);
|
|
27604
|
+
parentCursor = page.nextCursor;
|
|
27605
|
+
if (parentCursor !== null) {
|
|
27606
|
+
if (seen.has(parentCursor))
|
|
27607
|
+
throw RequestError.internalError(undefined, "Codex parent history repeated a cursor");
|
|
27608
|
+
seen.add(parentCursor);
|
|
27609
|
+
}
|
|
27610
|
+
} while (parentCursor !== null && !session.closed);
|
|
27611
|
+
runtime.lineage.forkedAtTurnId = null;
|
|
27612
|
+
}
|
|
27274
27613
|
const cursors = new Set;
|
|
27275
27614
|
let cursor = null;
|
|
27276
27615
|
do {
|
|
27277
27616
|
const page = await this.turnPage(session.id, cursor);
|
|
27617
|
+
for (const turn of page.data) {
|
|
27618
|
+
if (parentTurns.has(turn.id))
|
|
27619
|
+
runtime.lineage.forkedAtTurnId = turn.id;
|
|
27620
|
+
}
|
|
27278
27621
|
await publishTitle(page.data);
|
|
27279
27622
|
await client.updateAll(historyUpdates(page.data));
|
|
27280
27623
|
cursor = page.nextCursor;
|
|
@@ -27322,19 +27665,43 @@ class CodexAgent {
|
|
|
27322
27665
|
this.requireInitialized("session/list");
|
|
27323
27666
|
const cwd = params.cwd?.trim() || null;
|
|
27324
27667
|
const archived = archivedFilter(params._meta);
|
|
27325
|
-
const
|
|
27326
|
-
cursor
|
|
27668
|
+
const list = (cursor) => this.withCodex(() => this.codex.threadList({
|
|
27669
|
+
cursor,
|
|
27327
27670
|
...cwd ? { cwd } : {},
|
|
27328
27671
|
sourceKinds: ["cli", "vscode", "exec", "appServer", "unknown"],
|
|
27329
27672
|
...archived ? { archived: true } : {}
|
|
27330
27673
|
}));
|
|
27674
|
+
const response = await list(params.cursor ?? null);
|
|
27675
|
+
const home = this.codexHome;
|
|
27676
|
+
if (home === null)
|
|
27677
|
+
throw RequestError.internalError(undefined, "Codex home is unavailable after initialize");
|
|
27678
|
+
const forks = await this.withCodex(() => nativeForks(home, archived, cwd, async (id) => (await this.codex.threadRead({ threadId: id, includeTurns: false })).thread));
|
|
27679
|
+
const byId = new Map(forks.map((thread) => [thread.id, thread]));
|
|
27680
|
+
response.data = response.data.map((thread) => byId.get(thread.id) ?? thread);
|
|
27681
|
+
if (!params.cursor) {
|
|
27682
|
+
const missing2 = new Map(byId);
|
|
27683
|
+
for (const thread of response.data)
|
|
27684
|
+
missing2.delete(thread.id);
|
|
27685
|
+
let cursor = response.nextCursor;
|
|
27686
|
+
const cursors = new Set;
|
|
27687
|
+
while (missing2.size > 0 && cursor !== null) {
|
|
27688
|
+
if (cursors.has(cursor))
|
|
27689
|
+
throw RequestError.internalError(undefined, "Codex thread list repeated a cursor");
|
|
27690
|
+
cursors.add(cursor);
|
|
27691
|
+
const page = await list(cursor);
|
|
27692
|
+
for (const thread of page.data)
|
|
27693
|
+
missing2.delete(thread.id);
|
|
27694
|
+
cursor = page.nextCursor;
|
|
27695
|
+
}
|
|
27696
|
+
response.data.push(...missing2.values());
|
|
27697
|
+
}
|
|
27331
27698
|
return {
|
|
27332
27699
|
sessions: response.data.map((thread) => ({
|
|
27333
27700
|
sessionId: thread.id,
|
|
27334
27701
|
cwd: thread.cwd,
|
|
27335
27702
|
title: thread.name?.trim() || thread.preview.trim() || null,
|
|
27336
27703
|
updatedAt: new Date(thread.updatedAt * 1000).toISOString(),
|
|
27337
|
-
_meta: { codex: { archived } }
|
|
27704
|
+
_meta: { codex: { archived, ...threadLineage(thread) } }
|
|
27338
27705
|
})),
|
|
27339
27706
|
nextCursor: response.nextCursor
|
|
27340
27707
|
};
|
|
@@ -27567,6 +27934,8 @@ class CodexAgent {
|
|
|
27567
27934
|
throw RequestError.invalidParams(undefined, "prompt must contain at least one content block");
|
|
27568
27935
|
}
|
|
27569
27936
|
const { session } = runtime;
|
|
27937
|
+
if (params._meta && typeof params._meta === "object")
|
|
27938
|
+
runtime.bridge.rememberPromptMeta(messageId, params._meta);
|
|
27570
27939
|
this.providers.upstreamModel(session.model.model);
|
|
27571
27940
|
const model = findModel(session.catalog, session.model.model);
|
|
27572
27941
|
if (!modelSupportsImages(model) && params.prompt.some((block) => block.type === "image")) {
|
|
@@ -27600,8 +27969,12 @@ class CodexAgent {
|
|
|
27600
27969
|
async runPrompt(runtime, turn, params, observed, items = []) {
|
|
27601
27970
|
const { session, bridge } = runtime;
|
|
27602
27971
|
bridge.beginTurn();
|
|
27603
|
-
if (items.length)
|
|
27604
|
-
|
|
27972
|
+
if (items.length) {
|
|
27973
|
+
const turnId = turn.turnId;
|
|
27974
|
+
if (turnId === null)
|
|
27975
|
+
throw RequestError.internalError(undefined, "Cannot restore items without their turn id");
|
|
27976
|
+
runtime.queue = runtime.queue.then(() => bridge.restore(items, turnId));
|
|
27977
|
+
}
|
|
27605
27978
|
try {
|
|
27606
27979
|
const command = parseCommand(params.prompt);
|
|
27607
27980
|
const outcome = command ? resolveCommand(command, session) : { kind: "prompt" };
|
|
@@ -27861,7 +28234,7 @@ ${error40.additionalDetails}` : error40.message;
|
|
|
27861
28234
|
}
|
|
27862
28235
|
withSkillsContext(cwd, additionalDirectories, operation) {
|
|
27863
28236
|
const run = async () => {
|
|
27864
|
-
const roots = additionalDirectories.map((root) =>
|
|
28237
|
+
const roots = additionalDirectories.map((root) => path8.join(root, ".agents", "skills"));
|
|
27865
28238
|
if (roots.length !== this.skillRoots.length || roots.some((root, index) => root !== this.skillRoots[index])) {
|
|
27866
28239
|
this.changingSkillRoots = true;
|
|
27867
28240
|
try {
|
|
@@ -27895,7 +28268,7 @@ ${error40.additionalDetails}` : error40.message;
|
|
|
27895
28268
|
}
|
|
27896
28269
|
async refreshAvailableCommands(runtime) {
|
|
27897
28270
|
const run = async () => {
|
|
27898
|
-
const roots = runtime.session.additionalDirectories.map((root) =>
|
|
28271
|
+
const roots = runtime.session.additionalDirectories.map((root) => path8.join(root, ".agents", "skills"));
|
|
27899
28272
|
if (runtime.session.closed || roots.length !== this.skillRoots.length || roots.some((root, i) => root !== this.skillRoots[i]))
|
|
27900
28273
|
return;
|
|
27901
28274
|
return await this.loadSkills(runtime.session.cwd, runtime.session.additionalDirectories);
|
|
@@ -28130,6 +28503,18 @@ async function within(operation, ms) {
|
|
|
28130
28503
|
clearTimeout(timer);
|
|
28131
28504
|
}
|
|
28132
28505
|
}
|
|
28506
|
+
function threadLineage(thread) {
|
|
28507
|
+
return { nativeSessionId: thread.sessionId, forkedFromId: thread.forkedFromId };
|
|
28508
|
+
}
|
|
28509
|
+
function forkTurnId(meta) {
|
|
28510
|
+
const value = meta?.codex?.lastTurnId;
|
|
28511
|
+
if (value === undefined)
|
|
28512
|
+
return;
|
|
28513
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
28514
|
+
throw RequestError.invalidParams(undefined, "lastTurnId must be a non-empty Codex turn id");
|
|
28515
|
+
}
|
|
28516
|
+
return value;
|
|
28517
|
+
}
|
|
28133
28518
|
|
|
28134
28519
|
// src/agent/createAgent.ts
|
|
28135
28520
|
function createAgentApp(options) {
|
|
@@ -28608,7 +28993,7 @@ function threadIdOf(notification) {
|
|
|
28608
28993
|
// src/codex/process.ts
|
|
28609
28994
|
import { existsSync, mkdtempSync, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
28610
28995
|
import os3 from "os";
|
|
28611
|
-
import
|
|
28996
|
+
import path9 from "path";
|
|
28612
28997
|
import { spawn, spawnSync } from "child_process";
|
|
28613
28998
|
import { createRequire } from "module";
|
|
28614
28999
|
|
|
@@ -28901,11 +29286,11 @@ function resolveCodexLauncher(codexPath) {
|
|
|
28901
29286
|
const target = targets[platform2];
|
|
28902
29287
|
if (!target)
|
|
28903
29288
|
throw new Error(`Unsupported Codex platform: ${platform2}`);
|
|
28904
|
-
let vendor =
|
|
29289
|
+
let vendor = path9.resolve(path9.dirname(launcher), "..", "vendor");
|
|
28905
29290
|
try {
|
|
28906
|
-
vendor =
|
|
29291
|
+
vendor = path9.join(path9.dirname(platformRequire.resolve(`@openai/codex-${platform2}/package.json`)), "vendor");
|
|
28907
29292
|
} catch {}
|
|
28908
|
-
const command =
|
|
29293
|
+
const command = path9.join(vendor, target, "bin", process.platform === "win32" ? "codex.exe" : "codex");
|
|
28909
29294
|
if (!existsSync(command))
|
|
28910
29295
|
throw new Error(`Missing Codex platform binary: ${command}`);
|
|
28911
29296
|
return { command, prefixArgs: [], shell: false };
|
|
@@ -28951,7 +29336,7 @@ function mergedModelCatalog(launcher, env) {
|
|
|
28951
29336
|
const raw = env[EXTRA_MODEL_CATALOGS_ENV];
|
|
28952
29337
|
if (raw === undefined || raw.trim() === "")
|
|
28953
29338
|
return null;
|
|
28954
|
-
const files = raw.split(
|
|
29339
|
+
const files = raw.split(path9.delimiter).filter((file2) => file2.length > 0);
|
|
28955
29340
|
const dump = spawnSync(launcher.command, [...launcher.prefixArgs, "debug", "models"], {
|
|
28956
29341
|
shell: launcher.shell,
|
|
28957
29342
|
env,
|
|
@@ -28979,8 +29364,8 @@ function mergedModelCatalog(launcher, env) {
|
|
|
28979
29364
|
models.push({ ...entry, visibility: "hide" });
|
|
28980
29365
|
}
|
|
28981
29366
|
}
|
|
28982
|
-
const directory = mkdtempSync(
|
|
28983
|
-
const target =
|
|
29367
|
+
const directory = mkdtempSync(path9.join(os3.tmpdir(), "codex-acp-v2-catalog-"));
|
|
29368
|
+
const target = path9.join(directory, "models.json");
|
|
28984
29369
|
writeFileSync(target, JSON.stringify({ ...base, models }));
|
|
28985
29370
|
return target;
|
|
28986
29371
|
}
|