@moxt-ai/mobius 0.0.276 → 0.0.279
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/acp/agent-runtime-manager.d.ts +8 -4
- package/dist/acp/agent-runtime-manager.d.ts.map +1 -1
- package/dist/acp/agent-runtime-manager.js +59 -6
- package/dist/acp/agent-runtime-manager.js.map +1 -1
- package/dist/acp/agent-session.d.ts.map +1 -1
- package/dist/acp/agent-session.js +20 -1
- package/dist/acp/agent-session.js.map +1 -1
- package/dist/acp/announced-tool-calls.d.ts +24 -0
- package/dist/acp/announced-tool-calls.d.ts.map +1 -0
- package/dist/acp/announced-tool-calls.js +37 -0
- package/dist/acp/announced-tool-calls.js.map +1 -0
- package/dist/acp/session-history.d.ts +2 -1
- package/dist/acp/session-history.d.ts.map +1 -1
- package/dist/acp/session-history.js.map +1 -1
- package/dist/acp/session-interactions.d.ts +4 -1
- package/dist/acp/session-interactions.d.ts.map +1 -1
- package/dist/acp/session-interactions.js +8 -2
- package/dist/acp/session-interactions.js.map +1 -1
- package/dist/acp/session-store.d.ts +1 -1
- package/dist/acp/session-store.d.ts.map +1 -1
- package/dist/acp/session-store.js +1 -1
- package/dist/acp/session-store.js.map +1 -1
- package/dist/cli.js +373 -110
- package/dist/cli.js.map +4 -4
- package/dist/runtime/command/registry/index.d.ts.map +1 -1
- package/dist/runtime/command/registry/index.js +2 -1
- package/dist/runtime/command/registry/index.js.map +1 -1
- package/dist/runtime/command/registry/session.d.ts +3 -1
- package/dist/runtime/command/registry/session.d.ts.map +1 -1
- package/dist/runtime/command/registry/session.js +56 -6
- package/dist/runtime/command/registry/session.js.map +1 -1
- package/dist/runtime/relay/run-relay-connection.d.ts.map +1 -1
- package/dist/runtime/relay/run-relay-connection.js +49 -2
- package/dist/runtime/relay/run-relay-connection.js.map +1 -1
- package/dist/runtime/relay/session-event-publisher.d.ts +2 -1
- package/dist/runtime/relay/session-event-publisher.d.ts.map +1 -1
- package/dist/runtime/relay/session-event-publisher.js +1 -0
- package/dist/runtime/relay/session-event-publisher.js.map +1 -1
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +1 -0
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/sessions.d.ts +8 -0
- package/dist/runtime/sessions.d.ts.map +1 -1
- package/dist/runtime.js +373 -110
- package/dist/runtime.js.map +4 -4
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -5398,7 +5398,7 @@ var program = new Command();
|
|
|
5398
5398
|
// package.json
|
|
5399
5399
|
var package_default = {
|
|
5400
5400
|
name: "@moxt-ai/mobius",
|
|
5401
|
-
version: "0.0.
|
|
5401
|
+
version: "0.0.279",
|
|
5402
5402
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
5403
5403
|
type: "module",
|
|
5404
5404
|
bin: {
|
|
@@ -25611,6 +25611,23 @@ var decodeSessionConfigureCommand = (encoded) => decodeZodMessage(encoded, sessi
|
|
|
25611
25611
|
var encodeSessionConfigureCommand = (message) => encodeZodMessage(message, sessionConfigureCommandSchema);
|
|
25612
25612
|
var decodeSessionConfigUpdatedEvent = (encoded) => decodeZodMessage(encoded, sessionConfigUpdatedEventSchema);
|
|
25613
25613
|
var encodeSessionConfigUpdatedEvent = (message) => encodeZodMessage(message, sessionConfigUpdatedEventSchema);
|
|
25614
|
+
var SESSION_CONFIG_READ_KIND = "session.config.read";
|
|
25615
|
+
var SESSION_CONFIG_READ_RESULT_KIND = "session.config.read.result";
|
|
25616
|
+
var sessionConfigReadCommandSchema = external_exports.object({
|
|
25617
|
+
kind: external_exports.literal(SESSION_CONFIG_READ_KIND),
|
|
25618
|
+
requestId: identifierStringSchema,
|
|
25619
|
+
sessionId: identifierStringSchema
|
|
25620
|
+
}).readonly();
|
|
25621
|
+
var sessionConfigReadResultSchema = external_exports.object({
|
|
25622
|
+
configOptions: sessionConfigOptionsSchema,
|
|
25623
|
+
kind: external_exports.literal(SESSION_CONFIG_READ_RESULT_KIND),
|
|
25624
|
+
requestId: identifierStringSchema,
|
|
25625
|
+
sessionId: identifierStringSchema
|
|
25626
|
+
}).readonly();
|
|
25627
|
+
var decodeSessionConfigReadCommand = (encoded) => decodeZodMessage(encoded, sessionConfigReadCommandSchema);
|
|
25628
|
+
var encodeSessionConfigReadCommand = (message) => encodeZodMessage(message, sessionConfigReadCommandSchema);
|
|
25629
|
+
var decodeSessionConfigReadResult = (encoded) => decodeZodMessage(encoded, sessionConfigReadResultSchema);
|
|
25630
|
+
var encodeSessionConfigReadResult = (message) => encodeZodMessage(message, sessionConfigReadResultSchema);
|
|
25614
25631
|
|
|
25615
25632
|
// ../mobius-sdk/src/protocol/session/configuration/title.ts
|
|
25616
25633
|
var SESSION_RENAME_KIND = "session.rename";
|
|
@@ -25685,6 +25702,66 @@ var encodeFileEndEvent = (message) => encodeZodMessage(message, fileEndEventSche
|
|
|
25685
25702
|
var decodeFileFailedEvent = (encoded) => decodeZodMessage(encoded, fileFailedEventSchema);
|
|
25686
25703
|
var encodeFileFailedEvent = (message) => encodeZodMessage(message, fileFailedEventSchema);
|
|
25687
25704
|
|
|
25705
|
+
// ../mobius-sdk/src/protocol/shared/tool-input.ts
|
|
25706
|
+
var MAX_CONTENT_LENGTH = 1e6;
|
|
25707
|
+
var MAX_COLLECTION_SIZE = 1e3;
|
|
25708
|
+
var MAX_JSON_DEPTH = 16;
|
|
25709
|
+
var MAX_JSON_KEYS = 1e3;
|
|
25710
|
+
var boundedString = external_exports.string().max(MAX_CONTENT_LENGTH);
|
|
25711
|
+
function boundedJsonIssue(value, depth = 0) {
|
|
25712
|
+
if (depth > MAX_JSON_DEPTH) {
|
|
25713
|
+
return "JSON nesting exceeds the maximum depth";
|
|
25714
|
+
}
|
|
25715
|
+
if (typeof value === "string") {
|
|
25716
|
+
return value.length <= MAX_CONTENT_LENGTH ? null : "JSON string exceeds the maximum length";
|
|
25717
|
+
}
|
|
25718
|
+
if (typeof value === "number") {
|
|
25719
|
+
return Number.isFinite(value) ? null : "JSON number must be finite";
|
|
25720
|
+
}
|
|
25721
|
+
if (typeof value === "boolean" || value === null) {
|
|
25722
|
+
return null;
|
|
25723
|
+
}
|
|
25724
|
+
if (Array.isArray(value)) {
|
|
25725
|
+
if (value.length > MAX_COLLECTION_SIZE) {
|
|
25726
|
+
return "JSON array exceeds the maximum length";
|
|
25727
|
+
}
|
|
25728
|
+
for (const item of value) {
|
|
25729
|
+
const issue2 = boundedJsonIssue(item, depth + 1);
|
|
25730
|
+
if (issue2 !== null) {
|
|
25731
|
+
return issue2;
|
|
25732
|
+
}
|
|
25733
|
+
}
|
|
25734
|
+
return null;
|
|
25735
|
+
}
|
|
25736
|
+
if (typeof value === "object" && value !== void 0) {
|
|
25737
|
+
const entries = Object.entries(value);
|
|
25738
|
+
if (entries.length > MAX_JSON_KEYS) {
|
|
25739
|
+
return "JSON object exceeds the maximum key count";
|
|
25740
|
+
}
|
|
25741
|
+
for (const [key, item] of entries) {
|
|
25742
|
+
if (key.length > 255) {
|
|
25743
|
+
return "JSON key exceeds the maximum length";
|
|
25744
|
+
}
|
|
25745
|
+
const issue2 = boundedJsonIssue(item, depth + 1);
|
|
25746
|
+
if (issue2 !== null) {
|
|
25747
|
+
return issue2;
|
|
25748
|
+
}
|
|
25749
|
+
}
|
|
25750
|
+
return null;
|
|
25751
|
+
}
|
|
25752
|
+
return "Value is not bounded JSON";
|
|
25753
|
+
}
|
|
25754
|
+
var boundedJsonSchema = external_exports.unknown().superRefine((value, context) => {
|
|
25755
|
+
const issue2 = boundedJsonIssue(value);
|
|
25756
|
+
if (issue2 !== null) {
|
|
25757
|
+
context.addIssue({ code: "custom", message: issue2 });
|
|
25758
|
+
}
|
|
25759
|
+
});
|
|
25760
|
+
var toolCallLocationSchema = external_exports.object({
|
|
25761
|
+
line: external_exports.number().int().nonnegative().safe().nullable().optional(),
|
|
25762
|
+
path: boundedString
|
|
25763
|
+
}).readonly();
|
|
25764
|
+
|
|
25688
25765
|
// ../mobius-sdk/src/protocol/session/interactions/index.ts
|
|
25689
25766
|
var SESSION_PERMISSION_REQUESTED_KIND = "session.permission.requested";
|
|
25690
25767
|
var SESSION_PERMISSION_RESPOND_KIND = "session.permission.respond";
|
|
@@ -25722,6 +25799,12 @@ var elicitationFieldSchema = external_exports.object({
|
|
|
25722
25799
|
}).readonly();
|
|
25723
25800
|
var sessionPermissionRequestedEventSchema = external_exports.object({
|
|
25724
25801
|
commandId: identifierStringSchema,
|
|
25802
|
+
// Absent only for events from older runtimes and saved history.
|
|
25803
|
+
details: external_exports.object({
|
|
25804
|
+
cwd: external_exports.string().min(1).max(4096),
|
|
25805
|
+
rawInput: boundedJsonSchema.optional(),
|
|
25806
|
+
locations: external_exports.array(toolCallLocationSchema).max(1e3).readonly()
|
|
25807
|
+
}).readonly().optional(),
|
|
25725
25808
|
interactionId: identifierStringSchema,
|
|
25726
25809
|
kind: external_exports.literal(SESSION_PERMISSION_REQUESTED_KIND),
|
|
25727
25810
|
options: external_exports.array(permissionOptionSchema).min(1).max(20).readonly(),
|
|
@@ -25785,6 +25868,8 @@ var SESSION_RESTORE_KIND = "session.restore";
|
|
|
25785
25868
|
var SESSION_RESTORED_KIND = "session.restored";
|
|
25786
25869
|
var SESSION_CLOSE_KIND = "session.close";
|
|
25787
25870
|
var SESSION_CLOSED_KIND = "session.closed";
|
|
25871
|
+
var SESSION_CLOSE_NOTICE_KIND = "session.close.notice";
|
|
25872
|
+
var SESSION_CLOSED_ERROR_CODE = "session_closed";
|
|
25788
25873
|
var SESSION_STATUS_CHANGED_KIND = "session.status.changed";
|
|
25789
25874
|
var SESSION_COMMANDS_UPDATED_KIND = "session.commands.updated";
|
|
25790
25875
|
var SESSION_INFO_UPDATED_KIND = "session.info.updated";
|
|
@@ -25890,6 +25975,11 @@ var sessionClosedEventSchema = external_exports.object({
|
|
|
25890
25975
|
requestId: identifierStringSchema,
|
|
25891
25976
|
sessionId: identifierStringSchema
|
|
25892
25977
|
}).readonly();
|
|
25978
|
+
var sessionCloseNoticeEventSchema = external_exports.object({
|
|
25979
|
+
kind: external_exports.literal(SESSION_CLOSE_NOTICE_KIND),
|
|
25980
|
+
reason: external_exports.string().min(1).max(500),
|
|
25981
|
+
sessionId: identifierStringSchema
|
|
25982
|
+
}).readonly();
|
|
25893
25983
|
var sessionCommandsUpdatedEventSchema = external_exports.object({
|
|
25894
25984
|
commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
|
|
25895
25985
|
kind: external_exports.literal(SESSION_COMMANDS_UPDATED_KIND),
|
|
@@ -25926,6 +26016,8 @@ var decodeSessionCloseCommand = (encoded) => decodeZodMessage(encoded, sessionCl
|
|
|
25926
26016
|
var encodeSessionCloseCommand = (message) => encodeZodMessage(message, sessionCloseCommandSchema);
|
|
25927
26017
|
var decodeSessionClosedEvent = (encoded) => decodeZodMessage(encoded, sessionClosedEventSchema);
|
|
25928
26018
|
var encodeSessionClosedEvent = (message) => encodeZodMessage(message, sessionClosedEventSchema);
|
|
26019
|
+
var decodeSessionCloseNoticeEvent = (encoded) => decodeZodMessage(encoded, sessionCloseNoticeEventSchema);
|
|
26020
|
+
var encodeSessionCloseNoticeEvent = (message) => encodeZodMessage(message, sessionCloseNoticeEventSchema);
|
|
25929
26021
|
var decodeSessionStatusChangedEvent = (encoded) => decodeZodMessage(encoded, sessionStatusChangedEventSchema);
|
|
25930
26022
|
var encodeSessionStatusChangedEvent = (message) => encodeZodMessage(message, sessionStatusChangedEventSchema);
|
|
25931
26023
|
var decodeSessionPrepareCommand = (encoded) => decodeZodMessage(encoded, sessionPrepareCommandSchema);
|
|
@@ -26169,86 +26261,35 @@ var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSch
|
|
|
26169
26261
|
|
|
26170
26262
|
// ../mobius-sdk/src/protocol/session/observability/event-log.ts
|
|
26171
26263
|
var MAX_EVENT_COUNT = 1e4;
|
|
26172
|
-
var
|
|
26173
|
-
var
|
|
26174
|
-
var MAX_JSON_DEPTH = 16;
|
|
26175
|
-
var MAX_JSON_KEYS = 1e3;
|
|
26264
|
+
var MAX_COLLECTION_SIZE2 = 1e3;
|
|
26265
|
+
var MAX_CONTENT_LENGTH2 = 1e6;
|
|
26176
26266
|
var SESSION_EVENT_KIND = "session.event.v2";
|
|
26177
26267
|
var SESSION_EVENT_BATCH_MAX_SIZE = 1e3;
|
|
26178
|
-
var
|
|
26268
|
+
var boundedString2 = external_exports.string().max(MAX_CONTENT_LENGTH2);
|
|
26179
26269
|
var shortString = external_exports.string().max(2048);
|
|
26180
26270
|
var externalContentKeySchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
26181
|
-
function boundedJsonIssue(value, depth = 0) {
|
|
26182
|
-
if (depth > MAX_JSON_DEPTH) {
|
|
26183
|
-
return "JSON nesting exceeds the maximum depth";
|
|
26184
|
-
}
|
|
26185
|
-
if (typeof value === "string") {
|
|
26186
|
-
return value.length <= MAX_CONTENT_LENGTH ? null : "JSON string exceeds the maximum length";
|
|
26187
|
-
}
|
|
26188
|
-
if (typeof value === "number") {
|
|
26189
|
-
return Number.isFinite(value) ? null : "JSON number must be finite";
|
|
26190
|
-
}
|
|
26191
|
-
if (typeof value === "boolean" || value === null) {
|
|
26192
|
-
return null;
|
|
26193
|
-
}
|
|
26194
|
-
if (Array.isArray(value)) {
|
|
26195
|
-
if (value.length > MAX_COLLECTION_SIZE) {
|
|
26196
|
-
return "JSON array exceeds the maximum length";
|
|
26197
|
-
}
|
|
26198
|
-
for (const item of value) {
|
|
26199
|
-
const issue2 = boundedJsonIssue(item, depth + 1);
|
|
26200
|
-
if (issue2 !== null) {
|
|
26201
|
-
return issue2;
|
|
26202
|
-
}
|
|
26203
|
-
}
|
|
26204
|
-
return null;
|
|
26205
|
-
}
|
|
26206
|
-
if (typeof value === "object" && value !== void 0) {
|
|
26207
|
-
const entries = Object.entries(value);
|
|
26208
|
-
if (entries.length > MAX_JSON_KEYS) {
|
|
26209
|
-
return "JSON object exceeds the maximum key count";
|
|
26210
|
-
}
|
|
26211
|
-
for (const [key, item] of entries) {
|
|
26212
|
-
if (key.length > 255) {
|
|
26213
|
-
return "JSON key exceeds the maximum length";
|
|
26214
|
-
}
|
|
26215
|
-
const issue2 = boundedJsonIssue(item, depth + 1);
|
|
26216
|
-
if (issue2 !== null) {
|
|
26217
|
-
return issue2;
|
|
26218
|
-
}
|
|
26219
|
-
}
|
|
26220
|
-
return null;
|
|
26221
|
-
}
|
|
26222
|
-
return "Value is not bounded JSON";
|
|
26223
|
-
}
|
|
26224
|
-
var boundedJsonSchema = external_exports.unknown().superRefine((value, context) => {
|
|
26225
|
-
const issue2 = boundedJsonIssue(value);
|
|
26226
|
-
if (issue2 !== null) {
|
|
26227
|
-
context.addIssue({ code: "custom", message: issue2 });
|
|
26228
|
-
}
|
|
26229
|
-
});
|
|
26230
26271
|
var annotationsSchema = external_exports.object({
|
|
26231
26272
|
audience: external_exports.array(external_exports.enum(["assistant", "user"])).max(2).readonly().nullable().optional(),
|
|
26232
26273
|
lastModified: shortString.nullable().optional(),
|
|
26233
26274
|
priority: external_exports.number().finite().nullable().optional()
|
|
26234
26275
|
}).readonly();
|
|
26235
26276
|
var contentFields = { annotations: annotationsSchema.nullable().optional() };
|
|
26236
|
-
var textContentSchema = external_exports.object({ ...contentFields, text:
|
|
26277
|
+
var textContentSchema = external_exports.object({ ...contentFields, text: boundedString2, type: external_exports.literal("text") }).readonly();
|
|
26237
26278
|
var imageContentSchema = external_exports.object({
|
|
26238
26279
|
...contentFields,
|
|
26239
|
-
data:
|
|
26280
|
+
data: boundedString2,
|
|
26240
26281
|
mimeType: shortString,
|
|
26241
26282
|
type: external_exports.literal("image"),
|
|
26242
|
-
uri:
|
|
26283
|
+
uri: boundedString2.nullable().optional()
|
|
26243
26284
|
}).readonly();
|
|
26244
|
-
var audioContentSchema = external_exports.object({ ...contentFields, data:
|
|
26285
|
+
var audioContentSchema = external_exports.object({ ...contentFields, data: boundedString2, mimeType: shortString, type: external_exports.literal("audio") }).readonly();
|
|
26245
26286
|
var externalImageContentSchema = external_exports.object({
|
|
26246
26287
|
...contentFields,
|
|
26247
26288
|
byteLength: external_exports.number().int().positive().safe(),
|
|
26248
26289
|
imageKey: externalContentKeySchema,
|
|
26249
26290
|
mimeType: shortString,
|
|
26250
26291
|
type: external_exports.literal("external_image"),
|
|
26251
|
-
uri:
|
|
26292
|
+
uri: boundedString2.nullable().optional()
|
|
26252
26293
|
}).readonly();
|
|
26253
26294
|
var externalAudioContentSchema = external_exports.object({
|
|
26254
26295
|
...contentFields,
|
|
@@ -26264,27 +26305,27 @@ var externalResourceContentSchema = external_exports.object({
|
|
|
26264
26305
|
mimeType: shortString.nullable().optional(),
|
|
26265
26306
|
resourceKey: externalContentKeySchema,
|
|
26266
26307
|
type: external_exports.literal("external_resource"),
|
|
26267
|
-
uri:
|
|
26308
|
+
uri: boundedString2
|
|
26268
26309
|
}).readonly();
|
|
26269
26310
|
var resourceLinkSchema = external_exports.object({
|
|
26270
26311
|
...contentFields,
|
|
26271
|
-
description:
|
|
26312
|
+
description: boundedString2.nullable().optional(),
|
|
26272
26313
|
mimeType: shortString.nullable().optional(),
|
|
26273
26314
|
name: shortString,
|
|
26274
26315
|
size: external_exports.number().int().nonnegative().safe().nullable().optional(),
|
|
26275
26316
|
title: shortString.nullable().optional(),
|
|
26276
26317
|
type: external_exports.literal("resource_link"),
|
|
26277
|
-
uri:
|
|
26318
|
+
uri: boundedString2
|
|
26278
26319
|
}).readonly();
|
|
26279
26320
|
var textResourceSchema = external_exports.object({
|
|
26280
26321
|
mimeType: shortString.nullable().optional(),
|
|
26281
|
-
text:
|
|
26282
|
-
uri:
|
|
26322
|
+
text: boundedString2,
|
|
26323
|
+
uri: boundedString2
|
|
26283
26324
|
}).readonly();
|
|
26284
26325
|
var blobResourceSchema = external_exports.object({
|
|
26285
|
-
blob:
|
|
26326
|
+
blob: boundedString2,
|
|
26286
26327
|
mimeType: shortString.nullable().optional(),
|
|
26287
|
-
uri:
|
|
26328
|
+
uri: boundedString2
|
|
26288
26329
|
}).readonly();
|
|
26289
26330
|
var embeddedResourceSchema = external_exports.object({
|
|
26290
26331
|
...contentFields,
|
|
@@ -26304,17 +26345,13 @@ var contentBlockSchema = external_exports.discriminatedUnion("type", [
|
|
|
26304
26345
|
var toolCallContentSchema = external_exports.discriminatedUnion("type", [
|
|
26305
26346
|
external_exports.object({ content: contentBlockSchema, type: external_exports.literal("content") }).readonly(),
|
|
26306
26347
|
external_exports.object({
|
|
26307
|
-
newText:
|
|
26308
|
-
oldText:
|
|
26309
|
-
path:
|
|
26348
|
+
newText: boundedString2,
|
|
26349
|
+
oldText: boundedString2.nullable().optional(),
|
|
26350
|
+
path: boundedString2,
|
|
26310
26351
|
type: external_exports.literal("diff")
|
|
26311
26352
|
}).readonly(),
|
|
26312
26353
|
external_exports.object({ terminalId: shortString, type: external_exports.literal("terminal") }).readonly()
|
|
26313
26354
|
]);
|
|
26314
|
-
var toolCallLocationSchema = external_exports.object({
|
|
26315
|
-
line: external_exports.number().int().nonnegative().safe().nullable().optional(),
|
|
26316
|
-
path: boundedString
|
|
26317
|
-
}).readonly();
|
|
26318
26355
|
var toolKindSchema = external_exports.enum([
|
|
26319
26356
|
"read",
|
|
26320
26357
|
"edit",
|
|
@@ -26329,51 +26366,51 @@ var toolKindSchema = external_exports.enum([
|
|
|
26329
26366
|
]);
|
|
26330
26367
|
var toolStatusSchema = external_exports.enum(["pending", "in_progress", "completed", "failed"]);
|
|
26331
26368
|
var toolPatchFields = {
|
|
26332
|
-
content: external_exports.array(toolCallContentSchema).max(
|
|
26369
|
+
content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
|
|
26333
26370
|
kind: toolKindSchema.nullable().optional(),
|
|
26334
|
-
locations: external_exports.array(toolCallLocationSchema).max(
|
|
26371
|
+
locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
|
|
26335
26372
|
name: shortString.nullable().optional(),
|
|
26336
26373
|
rawInput: boundedJsonSchema.optional(),
|
|
26337
26374
|
rawOutput: boundedJsonSchema.optional(),
|
|
26338
26375
|
status: toolStatusSchema.nullable().optional(),
|
|
26339
|
-
title:
|
|
26376
|
+
title: boundedString2.nullable().optional()
|
|
26340
26377
|
};
|
|
26341
26378
|
var planEntrySchema = external_exports.object({
|
|
26342
|
-
content:
|
|
26379
|
+
content: boundedString2,
|
|
26343
26380
|
priority: external_exports.enum(["high", "medium", "low"]),
|
|
26344
26381
|
status: external_exports.enum(["pending", "in_progress", "completed"])
|
|
26345
26382
|
}).readonly();
|
|
26346
26383
|
var planContentSchema = external_exports.discriminatedUnion("type", [
|
|
26347
26384
|
external_exports.object({
|
|
26348
|
-
entries: external_exports.array(planEntrySchema).max(
|
|
26385
|
+
entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
26349
26386
|
planId: shortString,
|
|
26350
26387
|
type: external_exports.literal("items")
|
|
26351
26388
|
}).readonly(),
|
|
26352
|
-
external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri:
|
|
26389
|
+
external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString2 }).readonly(),
|
|
26353
26390
|
external_exports.object({
|
|
26354
|
-
content:
|
|
26391
|
+
content: boundedString2,
|
|
26355
26392
|
planId: shortString,
|
|
26356
26393
|
type: external_exports.literal("markdown")
|
|
26357
26394
|
}).readonly()
|
|
26358
26395
|
]);
|
|
26359
26396
|
var commandSchema = external_exports.object({
|
|
26360
|
-
description:
|
|
26361
|
-
input: external_exports.object({ hint:
|
|
26397
|
+
description: boundedString2,
|
|
26398
|
+
input: external_exports.object({ hint: boundedString2 }).readonly().nullable().optional(),
|
|
26362
26399
|
name: shortString
|
|
26363
26400
|
}).readonly();
|
|
26364
26401
|
var configSelectOptionSchema = external_exports.object({
|
|
26365
|
-
description:
|
|
26402
|
+
description: boundedString2.nullable().optional(),
|
|
26366
26403
|
name: shortString,
|
|
26367
26404
|
value: shortString
|
|
26368
26405
|
}).readonly();
|
|
26369
26406
|
var configSelectGroupSchema = external_exports.object({
|
|
26370
26407
|
group: shortString,
|
|
26371
26408
|
name: shortString,
|
|
26372
|
-
options: external_exports.array(configSelectOptionSchema).max(
|
|
26409
|
+
options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
26373
26410
|
}).readonly();
|
|
26374
26411
|
var configBaseFields = {
|
|
26375
26412
|
category: shortString.nullable().optional(),
|
|
26376
|
-
description:
|
|
26413
|
+
description: boundedString2.nullable().optional(),
|
|
26377
26414
|
id: shortString,
|
|
26378
26415
|
name: shortString
|
|
26379
26416
|
};
|
|
@@ -26382,8 +26419,8 @@ var sessionConfigOptionSchema2 = external_exports.discriminatedUnion("type", [
|
|
|
26382
26419
|
...configBaseFields,
|
|
26383
26420
|
currentValue: shortString,
|
|
26384
26421
|
options: external_exports.union([
|
|
26385
|
-
external_exports.array(configSelectOptionSchema).max(
|
|
26386
|
-
external_exports.array(configSelectGroupSchema).max(
|
|
26422
|
+
external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
26423
|
+
external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
26387
26424
|
]),
|
|
26388
26425
|
type: external_exports.literal("select")
|
|
26389
26426
|
}).readonly(),
|
|
@@ -26398,26 +26435,26 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
|
|
|
26398
26435
|
external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_message_chunk") }).readonly(),
|
|
26399
26436
|
external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_thought_chunk") }).readonly(),
|
|
26400
26437
|
external_exports.object({
|
|
26401
|
-
content: external_exports.array(toolCallContentSchema).max(
|
|
26438
|
+
content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
|
|
26402
26439
|
kind: toolKindSchema.optional(),
|
|
26403
|
-
locations: external_exports.array(toolCallLocationSchema).max(
|
|
26440
|
+
locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
|
|
26404
26441
|
name: shortString.nullable().optional(),
|
|
26405
26442
|
rawInput: boundedJsonSchema.optional(),
|
|
26406
26443
|
rawOutput: boundedJsonSchema.optional(),
|
|
26407
26444
|
sessionUpdate: external_exports.literal("tool_call"),
|
|
26408
26445
|
status: toolStatusSchema.optional(),
|
|
26409
|
-
title:
|
|
26446
|
+
title: boundedString2,
|
|
26410
26447
|
toolCallId: shortString
|
|
26411
26448
|
}).readonly(),
|
|
26412
26449
|
external_exports.object({ ...toolPatchFields, sessionUpdate: external_exports.literal("tool_call_update"), toolCallId: shortString }).readonly(),
|
|
26413
26450
|
external_exports.object({
|
|
26414
|
-
entries: external_exports.array(planEntrySchema).max(
|
|
26451
|
+
entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
26415
26452
|
sessionUpdate: external_exports.literal("plan")
|
|
26416
26453
|
}).readonly(),
|
|
26417
26454
|
external_exports.object({ plan: planContentSchema, sessionUpdate: external_exports.literal("plan_update") }).readonly(),
|
|
26418
26455
|
external_exports.object({ planId: shortString, sessionUpdate: external_exports.literal("plan_removed") }).readonly(),
|
|
26419
26456
|
external_exports.object({
|
|
26420
|
-
availableCommands: external_exports.array(commandSchema).max(
|
|
26457
|
+
availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
26421
26458
|
sessionUpdate: external_exports.literal("available_commands_update")
|
|
26422
26459
|
}).readonly(),
|
|
26423
26460
|
external_exports.object({
|
|
@@ -26425,12 +26462,12 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
|
|
|
26425
26462
|
sessionUpdate: external_exports.literal("current_mode_update")
|
|
26426
26463
|
}).readonly(),
|
|
26427
26464
|
external_exports.object({
|
|
26428
|
-
configOptions: external_exports.array(sessionConfigOptionSchema2).max(
|
|
26465
|
+
configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE2).readonly(),
|
|
26429
26466
|
sessionUpdate: external_exports.literal("config_option_update")
|
|
26430
26467
|
}).readonly(),
|
|
26431
26468
|
external_exports.object({
|
|
26432
26469
|
sessionUpdate: external_exports.literal("session_info_update"),
|
|
26433
|
-
title:
|
|
26470
|
+
title: boundedString2.nullable().optional(),
|
|
26434
26471
|
updatedAt: shortString.nullable().optional()
|
|
26435
26472
|
}).readonly(),
|
|
26436
26473
|
external_exports.object({
|
|
@@ -26441,10 +26478,10 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
|
|
|
26441
26478
|
}).readonly(),
|
|
26442
26479
|
external_exports.object({
|
|
26443
26480
|
compactionId: shortString,
|
|
26444
|
-
error:
|
|
26481
|
+
error: boundedString2.nullable().optional(),
|
|
26445
26482
|
sessionUpdate: external_exports.literal("compaction_update"),
|
|
26446
26483
|
status: shortString,
|
|
26447
|
-
summary: external_exports.array(contentBlockSchema).max(
|
|
26484
|
+
summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional()
|
|
26448
26485
|
}).readonly(),
|
|
26449
26486
|
external_exports.object({
|
|
26450
26487
|
compactionId: shortString,
|
|
@@ -26574,7 +26611,7 @@ var queuedPromptRequestEventLogSchema = external_exports.object({
|
|
|
26574
26611
|
}).readonly();
|
|
26575
26612
|
var nativeSessionEventsSchema = external_exports.object({
|
|
26576
26613
|
events: sessionEventLogPageSchema,
|
|
26577
|
-
queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(
|
|
26614
|
+
queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
26578
26615
|
}).readonly();
|
|
26579
26616
|
function inputValue(value) {
|
|
26580
26617
|
if (typeof value !== "string") {
|
|
@@ -26816,6 +26853,11 @@ var serviceToDaemonSignatures = {
|
|
|
26816
26853
|
encodeSessionConfigureCommand,
|
|
26817
26854
|
decodeSessionConfigureCommand
|
|
26818
26855
|
),
|
|
26856
|
+
[SESSION_CONFIG_READ_KIND]: defineMessageSignature(
|
|
26857
|
+
SESSION_CONFIG_READ_KIND,
|
|
26858
|
+
encodeSessionConfigReadCommand,
|
|
26859
|
+
decodeSessionConfigReadCommand
|
|
26860
|
+
),
|
|
26819
26861
|
[SESSION_RENAME_KIND]: defineMessageSignature(
|
|
26820
26862
|
SESSION_RENAME_KIND,
|
|
26821
26863
|
encodeSessionRenameCommand,
|
|
@@ -26872,6 +26914,11 @@ var daemonToServiceSignatures = {
|
|
|
26872
26914
|
encodeSessionClosedEvent,
|
|
26873
26915
|
decodeSessionClosedEvent
|
|
26874
26916
|
),
|
|
26917
|
+
[SESSION_CLOSE_NOTICE_KIND]: defineMessageSignature(
|
|
26918
|
+
SESSION_CLOSE_NOTICE_KIND,
|
|
26919
|
+
encodeSessionCloseNoticeEvent,
|
|
26920
|
+
decodeSessionCloseNoticeEvent
|
|
26921
|
+
),
|
|
26875
26922
|
[SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
26876
26923
|
SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
|
|
26877
26924
|
encodeSessionPreviewHistoryPageLoaded,
|
|
@@ -26882,6 +26929,11 @@ var daemonToServiceSignatures = {
|
|
|
26882
26929
|
encodeSessionConfigUpdatedEvent,
|
|
26883
26930
|
decodeSessionConfigUpdatedEvent
|
|
26884
26931
|
),
|
|
26932
|
+
[SESSION_CONFIG_READ_RESULT_KIND]: defineMessageSignature(
|
|
26933
|
+
SESSION_CONFIG_READ_RESULT_KIND,
|
|
26934
|
+
encodeSessionConfigReadResult,
|
|
26935
|
+
decodeSessionConfigReadResult
|
|
26936
|
+
),
|
|
26885
26937
|
[SESSION_RENAMED_KIND]: defineMessageSignature(
|
|
26886
26938
|
SESSION_RENAMED_KIND,
|
|
26887
26939
|
encodeSessionRenamedEvent,
|
|
@@ -82313,6 +82365,7 @@ var ActiveExecutions = class {
|
|
|
82313
82365
|
};
|
|
82314
82366
|
|
|
82315
82367
|
// src/acp/agent-session.ts
|
|
82368
|
+
import { setImmediate as yieldToRuntime2 } from "node:timers/promises";
|
|
82316
82369
|
import {
|
|
82317
82370
|
methods as methods10,
|
|
82318
82371
|
PROTOCOL_VERSION as PROTOCOL_VERSION3
|
|
@@ -82685,6 +82738,36 @@ var AgentUpdateStream = class {
|
|
|
82685
82738
|
};
|
|
82686
82739
|
};
|
|
82687
82740
|
|
|
82741
|
+
// src/acp/announced-tool-calls.ts
|
|
82742
|
+
var MAX_ANNOUNCED_TOOL_CALLS = 256;
|
|
82743
|
+
var AnnouncedToolCalls = class {
|
|
82744
|
+
#calls = /* @__PURE__ */ new Map();
|
|
82745
|
+
record = (update) => {
|
|
82746
|
+
const merged = this.describe(update);
|
|
82747
|
+
this.#calls.delete(update.toolCallId);
|
|
82748
|
+
this.#calls.set(update.toolCallId, merged);
|
|
82749
|
+
if (this.#calls.size > MAX_ANNOUNCED_TOOL_CALLS) {
|
|
82750
|
+
const oldest = this.#calls.keys().next();
|
|
82751
|
+
if (oldest.done !== true) {
|
|
82752
|
+
this.#calls.delete(oldest.value);
|
|
82753
|
+
}
|
|
82754
|
+
}
|
|
82755
|
+
};
|
|
82756
|
+
/** Applies a partial update to what was announced for the same tool call. */
|
|
82757
|
+
describe = (update) => {
|
|
82758
|
+
const announced = this.#calls.get(update.toolCallId);
|
|
82759
|
+
return {
|
|
82760
|
+
title: update.title ?? announced?.title,
|
|
82761
|
+
kind: update.kind ?? announced?.kind,
|
|
82762
|
+
rawInput: update.rawInput ?? announced?.rawInput,
|
|
82763
|
+
locations: update.locations ?? announced?.locations
|
|
82764
|
+
};
|
|
82765
|
+
};
|
|
82766
|
+
clear = () => {
|
|
82767
|
+
this.#calls.clear();
|
|
82768
|
+
};
|
|
82769
|
+
};
|
|
82770
|
+
|
|
82688
82771
|
// src/acp/runtime-operations.ts
|
|
82689
82772
|
var RuntimeOperations = class {
|
|
82690
82773
|
#shutdown = new AbortController();
|
|
@@ -83471,15 +83554,21 @@ var AcpSessionInteractions = class {
|
|
|
83471
83554
|
};
|
|
83472
83555
|
signal.addEventListener("abort", abort, { once: true });
|
|
83473
83556
|
try {
|
|
83557
|
+
const toolCall = this.#context.describeToolCall(request.toolCall);
|
|
83474
83558
|
await this.#notifyPermissionRequested({
|
|
83475
83559
|
commandId: this.#context.commandId(),
|
|
83560
|
+
details: {
|
|
83561
|
+
cwd: this.#context.cwd(),
|
|
83562
|
+
rawInput: toolCall.rawInput,
|
|
83563
|
+
locations: toolCall.locations ?? []
|
|
83564
|
+
},
|
|
83476
83565
|
interactionId,
|
|
83477
83566
|
kind: SESSION_PERMISSION_REQUESTED_KIND,
|
|
83478
83567
|
options,
|
|
83479
83568
|
sessionId: this.#context.sessionId(),
|
|
83480
|
-
title: truncate2(
|
|
83569
|
+
title: truncate2(toolCall.title ?? "Permission required", 500),
|
|
83481
83570
|
toolCallId: truncate2(request.toolCall.toolCallId, 255),
|
|
83482
|
-
toolKind: truncate2(
|
|
83571
|
+
toolKind: truncate2(toolCall.kind ?? "other", 64)
|
|
83483
83572
|
});
|
|
83484
83573
|
return await pending.completion.promise;
|
|
83485
83574
|
} finally {
|
|
@@ -88992,8 +89081,8 @@ var CachedAcpSessionEventStore = class {
|
|
|
88992
89081
|
var AcpStoredSession = class {
|
|
88993
89082
|
additionalDirectories;
|
|
88994
89083
|
agentId;
|
|
88995
|
-
cwd;
|
|
88996
89084
|
configurations;
|
|
89085
|
+
cwd;
|
|
88997
89086
|
nativeSessionId;
|
|
88998
89087
|
prompted;
|
|
88999
89088
|
sessionId;
|
|
@@ -89141,6 +89230,7 @@ var AgentSession = class _AgentSession {
|
|
|
89141
89230
|
#connection;
|
|
89142
89231
|
#contentExternalizer;
|
|
89143
89232
|
#interactions;
|
|
89233
|
+
#announcedToolCalls = new AnnouncedToolCalls();
|
|
89144
89234
|
#additionalDirectories;
|
|
89145
89235
|
#agentId;
|
|
89146
89236
|
#cwd;
|
|
@@ -89181,6 +89271,8 @@ var AgentSession = class _AgentSession {
|
|
|
89181
89271
|
this.#store = store;
|
|
89182
89272
|
this.#verifiedAgentVersion = agent.agentVersion;
|
|
89183
89273
|
this.#interactions = new AcpSessionInteractions({
|
|
89274
|
+
cwd: () => this.#cwd,
|
|
89275
|
+
describeToolCall: this.#announcedToolCalls.describe,
|
|
89184
89276
|
sessionId: () => this.#mobiusSessionId,
|
|
89185
89277
|
commandId: () => this.#turn.commandId,
|
|
89186
89278
|
assertNativeSession: (sessionId) => this.assertNativeSession(sessionId),
|
|
@@ -89904,6 +89996,7 @@ var AgentSession = class _AgentSession {
|
|
|
89904
89996
|
throw failure2;
|
|
89905
89997
|
} finally {
|
|
89906
89998
|
this.#turn = new IdleAcpTurn();
|
|
89999
|
+
this.#announcedToolCalls.clear();
|
|
89907
90000
|
}
|
|
89908
90001
|
};
|
|
89909
90002
|
steer = async (options) => {
|
|
@@ -90010,7 +90103,12 @@ var AgentSession = class _AgentSession {
|
|
|
90010
90103
|
};
|
|
90011
90104
|
respondPermission = (options) => this.#interactions.respondPermission(options);
|
|
90012
90105
|
respondElicitation = (options) => this.#interactions.respondElicitation(options);
|
|
90013
|
-
onPermission = (request, signal) =>
|
|
90106
|
+
onPermission = async (request, signal) => {
|
|
90107
|
+
await yieldToRuntime2(void 0, { signal });
|
|
90108
|
+
await this.#updates.drained();
|
|
90109
|
+
signal.throwIfAborted();
|
|
90110
|
+
return await this.#interactions.onPermission(request, signal);
|
|
90111
|
+
};
|
|
90014
90112
|
onElicitation = (request, signal) => this.#interactions.onElicitation(request, signal);
|
|
90015
90113
|
onElicitationComplete = (notification) => this.#interactions.onElicitationComplete(notification);
|
|
90016
90114
|
onUpdate = (notification) => this.#updates.receive(notification);
|
|
@@ -90052,6 +90150,9 @@ var AgentSession = class _AgentSession {
|
|
|
90052
90150
|
if (this.#sessionLoad.kind === "capturing" && (update.sessionUpdate === "user_message_chunk" || update.sessionUpdate === "agent_message_chunk" || update.sessionUpdate === "agent_thought_chunk" || update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update" || update.sessionUpdate === "plan" || update.sessionUpdate === "plan_update" || update.sessionUpdate === "plan_removed")) {
|
|
90053
90151
|
return;
|
|
90054
90152
|
}
|
|
90153
|
+
if (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") {
|
|
90154
|
+
this.#announcedToolCalls.record(update);
|
|
90155
|
+
}
|
|
90055
90156
|
if (update.sessionUpdate === "available_commands_update") {
|
|
90056
90157
|
const commands = update.availableCommands.slice(0, 500).map((command) => ({
|
|
90057
90158
|
description: truncate2(command.description, 500),
|
|
@@ -90415,10 +90516,13 @@ var AgentRuntimeManager = class {
|
|
|
90415
90516
|
#agentSettingsObserver = new NullAcpSessionObserver();
|
|
90416
90517
|
#nativeOperations = /* @__PURE__ */ new Set();
|
|
90417
90518
|
#sessionClosures = /* @__PURE__ */ new Map();
|
|
90519
|
+
/** Sessions that were closed and not reopened since. Only a prepare or restore of the Session reopens it. */
|
|
90520
|
+
#closedSessions = /* @__PURE__ */ new Set();
|
|
90418
90521
|
#store;
|
|
90419
90522
|
#adapters;
|
|
90420
90523
|
#sessionIdentity;
|
|
90421
90524
|
#onSessionStatusChanged;
|
|
90525
|
+
#onSessionClosed;
|
|
90422
90526
|
#contentExternalizer;
|
|
90423
90527
|
#timer;
|
|
90424
90528
|
#observer;
|
|
@@ -90428,6 +90532,7 @@ var AgentRuntimeManager = class {
|
|
|
90428
90532
|
adapters,
|
|
90429
90533
|
sessionIdentity,
|
|
90430
90534
|
onSessionStatusChanged,
|
|
90535
|
+
onSessionClosed = () => void 0,
|
|
90431
90536
|
contentExternalizer,
|
|
90432
90537
|
timer,
|
|
90433
90538
|
maxProcesses
|
|
@@ -90438,6 +90543,7 @@ var AgentRuntimeManager = class {
|
|
|
90438
90543
|
this.#adapters = adapters;
|
|
90439
90544
|
this.#sessionIdentity = sessionIdentity;
|
|
90440
90545
|
this.#onSessionStatusChanged = onSessionStatusChanged;
|
|
90546
|
+
this.#onSessionClosed = onSessionClosed;
|
|
90441
90547
|
this.#contentExternalizer = contentExternalizer;
|
|
90442
90548
|
this.#timer = timer;
|
|
90443
90549
|
this.#queryProcesses = new AgentQueryProcesses(this.#processes, contentExternalizer);
|
|
@@ -90475,6 +90581,34 @@ var AgentRuntimeManager = class {
|
|
|
90475
90581
|
}
|
|
90476
90582
|
}
|
|
90477
90583
|
}
|
|
90584
|
+
/**
|
|
90585
|
+
* Stops the process of a Session that is being closed. Unlike retiring it, this keeps the stored Session,
|
|
90586
|
+
* so the closed Session stays listed with its title and settings and can be reopened.
|
|
90587
|
+
*/
|
|
90588
|
+
async #stopSessionProcess(sessionId, runtime) {
|
|
90589
|
+
this.#executionProcesses.detach(sessionId, runtime);
|
|
90590
|
+
await this.#processes.retire(runtime, () => runtime.close());
|
|
90591
|
+
}
|
|
90592
|
+
#isKnownSession(sessionId) {
|
|
90593
|
+
return this.#executionProcesses.get(sessionId) !== void 0 || this.#executionProcesses.pending(sessionId) !== void 0 || this.#store.read(sessionId) instanceof FoundAcpStoredSession;
|
|
90594
|
+
}
|
|
90595
|
+
/**
|
|
90596
|
+
* Marks a Session closed and tells every client why, once for each closing. Clients show `reason` to their
|
|
90597
|
+
* users as is. Unknown Sessions have nothing to close.
|
|
90598
|
+
*/
|
|
90599
|
+
#announceClosed(sessionId, reason) {
|
|
90600
|
+
if (this.#closedSessions.has(sessionId) || !this.#isKnownSession(sessionId)) {
|
|
90601
|
+
return;
|
|
90602
|
+
}
|
|
90603
|
+
this.#closedSessions.add(sessionId);
|
|
90604
|
+
this.#onSessionClosed({ kind: SESSION_CLOSE_NOTICE_KIND, reason, sessionId });
|
|
90605
|
+
}
|
|
90606
|
+
/** A closed Session fails the operations that would silently reopen it, so a client learns that its view is stale. */
|
|
90607
|
+
#assertOpen(sessionId) {
|
|
90608
|
+
if (this.#closedSessions.has(sessionId)) {
|
|
90609
|
+
throw new AcpExecutionError("The Session is closed; reopen it to continue", {}, SESSION_CLOSED_ERROR_CODE);
|
|
90610
|
+
}
|
|
90611
|
+
}
|
|
90478
90612
|
async #startRetainedSessionProcess(options, start) {
|
|
90479
90613
|
const runtime = await this.#processes.startRetained(options.signal, start, this.#retention(options.sessionId));
|
|
90480
90614
|
this.#executionProcesses.retain(options.sessionId, runtime);
|
|
@@ -90568,12 +90702,17 @@ var AgentRuntimeManager = class {
|
|
|
90568
90702
|
return runtime;
|
|
90569
90703
|
});
|
|
90570
90704
|
}
|
|
90571
|
-
async #prepareSession(options, recovery, metrics = unmeasuredOperationMetrics) {
|
|
90705
|
+
async #prepareSession(options, recovery, closed, metrics = unmeasuredOperationMetrics) {
|
|
90572
90706
|
return await this.#operations.run(options, async (options2) => {
|
|
90573
90707
|
const closing = this.#sessionClosures.get(options2.sessionId);
|
|
90574
90708
|
if (closing !== void 0) {
|
|
90575
90709
|
await waitForSharedOperation(closing, options2.signal);
|
|
90576
90710
|
}
|
|
90711
|
+
if (closed === "reopen") {
|
|
90712
|
+
this.#closedSessions.delete(options2.sessionId);
|
|
90713
|
+
} else {
|
|
90714
|
+
this.#assertOpen(options2.sessionId);
|
|
90715
|
+
}
|
|
90577
90716
|
const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
|
|
90578
90717
|
if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
|
|
90579
90718
|
throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
|
|
@@ -90594,7 +90733,7 @@ var AgentRuntimeManager = class {
|
|
|
90594
90733
|
}
|
|
90595
90734
|
return runtime2.prepared();
|
|
90596
90735
|
}
|
|
90597
|
-
return await this.#prepareSession(options2, recovery, metrics);
|
|
90736
|
+
return await this.#prepareSession(options2, recovery, closed, metrics);
|
|
90598
90737
|
}
|
|
90599
90738
|
const existing = this.#executionProcesses.get(options2.sessionId);
|
|
90600
90739
|
if (existing !== void 0) {
|
|
@@ -90622,8 +90761,8 @@ var AgentRuntimeManager = class {
|
|
|
90622
90761
|
return runtime.prepared();
|
|
90623
90762
|
});
|
|
90624
90763
|
}
|
|
90625
|
-
prepareSession = async (options, metrics = unmeasuredOperationMetrics) => await this.#prepareSession(options, { kind: "interactive-only" }, metrics);
|
|
90626
|
-
restoreSession = async (options, metrics = unmeasuredOperationMetrics) => await this.#prepareSession(options, { kind: "history-required" }, metrics);
|
|
90764
|
+
prepareSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "interactive-only" }, closed, metrics);
|
|
90765
|
+
restoreSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "history-required" }, closed, metrics);
|
|
90627
90766
|
/**
|
|
90628
90767
|
* Opens a short-lived native ACP session only to read the local Agent's
|
|
90629
90768
|
* authoritative settings. Its identity and store are private to this
|
|
@@ -90694,6 +90833,7 @@ var AgentRuntimeManager = class {
|
|
|
90694
90833
|
});
|
|
90695
90834
|
});
|
|
90696
90835
|
prepareExecutionSession = async (options) => this.#operations.run(options, async (options2) => {
|
|
90836
|
+
this.#assertOpen(options2.sessionId);
|
|
90697
90837
|
const pending = this.#executionProcesses.pending(options2.sessionId);
|
|
90698
90838
|
if (pending !== void 0) {
|
|
90699
90839
|
await waitForSharedOperation(pending, options2.signal);
|
|
@@ -90731,6 +90871,7 @@ var AgentRuntimeManager = class {
|
|
|
90731
90871
|
});
|
|
90732
90872
|
});
|
|
90733
90873
|
renameSession = async (sessionId, title2, signal) => await this.#operations.run({ sessionId, signal }, async (options) => {
|
|
90874
|
+
this.#assertOpen(options.sessionId);
|
|
90734
90875
|
const runtime = this.#executionProcesses.get(options.sessionId);
|
|
90735
90876
|
if (runtime !== void 0) {
|
|
90736
90877
|
return await runtime.renameSession(title2, options.signal);
|
|
@@ -90806,6 +90947,7 @@ var AgentRuntimeManager = class {
|
|
|
90806
90947
|
}
|
|
90807
90948
|
});
|
|
90808
90949
|
runPrompt = async (options) => this.#operations.run(options, async (options2) => {
|
|
90950
|
+
this.#assertOpen(options2.sessionId);
|
|
90809
90951
|
const stored = this.#store.read(options2.sessionId);
|
|
90810
90952
|
if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
|
|
90811
90953
|
throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
|
|
@@ -90874,6 +91016,7 @@ var AgentRuntimeManager = class {
|
|
|
90874
91016
|
}
|
|
90875
91017
|
});
|
|
90876
91018
|
respondPermission = async (options) => {
|
|
91019
|
+
this.#assertOpen(options.sessionId);
|
|
90877
91020
|
const runtime = this.#executionProcesses.get(options.sessionId);
|
|
90878
91021
|
if (runtime === void 0) {
|
|
90879
91022
|
throw new AcpExecutionError("The permission request session is unavailable", {}, "session_not_found");
|
|
@@ -90881,6 +91024,7 @@ var AgentRuntimeManager = class {
|
|
|
90881
91024
|
await runtime.respondPermission(options);
|
|
90882
91025
|
};
|
|
90883
91026
|
respondElicitation = async (options) => {
|
|
91027
|
+
this.#assertOpen(options.sessionId);
|
|
90884
91028
|
const runtime = this.#executionProcesses.get(options.sessionId);
|
|
90885
91029
|
if (runtime === void 0) {
|
|
90886
91030
|
throw new AcpExecutionError("The elicitation request session is unavailable", {}, "session_not_found");
|
|
@@ -90893,11 +91037,12 @@ var AgentRuntimeManager = class {
|
|
|
90893
91037
|
await waitForSharedOperation(existing, options.signal);
|
|
90894
91038
|
return;
|
|
90895
91039
|
}
|
|
91040
|
+
this.#announceClosed(options.sessionId, "This Session was closed on request.");
|
|
90896
91041
|
const release = (async () => {
|
|
90897
91042
|
const pending = this.#executionProcesses.pending(options.sessionId);
|
|
90898
91043
|
const runtime = pending === void 0 ? this.#executionProcesses.get(options.sessionId) : await pending;
|
|
90899
91044
|
if (runtime !== void 0) {
|
|
90900
|
-
await this.#
|
|
91045
|
+
await this.#stopSessionProcess(options.sessionId, runtime);
|
|
90901
91046
|
}
|
|
90902
91047
|
})();
|
|
90903
91048
|
const deadline = Promise.withResolvers();
|
|
@@ -90979,6 +91124,7 @@ var AgentRuntimeManager = class {
|
|
|
90979
91124
|
});
|
|
90980
91125
|
});
|
|
90981
91126
|
ensureSession = async (options) => this.#operations.run(options, async (options2) => {
|
|
91127
|
+
this.#assertOpen(options2.sessionId);
|
|
90982
91128
|
const existing = this.#executionProcesses.get(options2.sessionId);
|
|
90983
91129
|
if (existing !== void 0) {
|
|
90984
91130
|
if (!existing.belongsTo(options2.agent.id, options2.cwd, options2.additionalDirectories)) {
|
|
@@ -91057,6 +91203,7 @@ var AgentRuntimeManager = class {
|
|
|
91057
91203
|
const existing = linked[0];
|
|
91058
91204
|
if (origin.kind === "import" && existing !== void 0) {
|
|
91059
91205
|
return await this.#executionProcesses.use(existing.sessionId, async () => {
|
|
91206
|
+
this.#closedSessions.delete(existing.sessionId);
|
|
91060
91207
|
const runtime = await this.ensureSession({
|
|
91061
91208
|
...options2,
|
|
91062
91209
|
sessionId: existing.sessionId
|
|
@@ -93544,7 +93691,7 @@ async function resolveCatalogAgent(config2, agentId, signal) {
|
|
|
93544
93691
|
const agent = config2.catalog.find(agentId);
|
|
93545
93692
|
return config2.resolveAgent === void 0 ? agent : await config2.resolveAgent(agent, signal);
|
|
93546
93693
|
}
|
|
93547
|
-
async function prepareSession(command, recovery, config2, directories, sessions, metrics, signal) {
|
|
93694
|
+
async function prepareSession(command, recovery, closed, config2, directories, sessions, metrics, signal) {
|
|
93548
93695
|
return await metrics.measure("prepare-total", async () => {
|
|
93549
93696
|
const resolved = await metrics.measure(
|
|
93550
93697
|
"workspace-resolve",
|
|
@@ -93564,7 +93711,7 @@ async function prepareSession(command, recovery, config2, directories, sessions,
|
|
|
93564
93711
|
sessionId: command.sessionId,
|
|
93565
93712
|
signal
|
|
93566
93713
|
};
|
|
93567
|
-
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
93714
|
+
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics, closed) : await sessions.prepareSession(preparation, metrics, closed);
|
|
93568
93715
|
const configuration = command.configuration;
|
|
93569
93716
|
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
93570
93717
|
"configuration",
|
|
@@ -93620,6 +93767,7 @@ async function executeSessionPrepare(socket, command, config2, directories, sess
|
|
|
93620
93767
|
const readyEvent = await prepareSession(
|
|
93621
93768
|
command,
|
|
93622
93769
|
{ kind: "interactive-only" },
|
|
93770
|
+
"reopen",
|
|
93623
93771
|
config2,
|
|
93624
93772
|
directories,
|
|
93625
93773
|
sessions,
|
|
@@ -93666,6 +93814,7 @@ async function executeSessionRestore(socket, command, config2, directories, sess
|
|
|
93666
93814
|
sessionState: "provisioned"
|
|
93667
93815
|
},
|
|
93668
93816
|
{ kind: "history-required" },
|
|
93817
|
+
"reopen",
|
|
93669
93818
|
config2,
|
|
93670
93819
|
directories,
|
|
93671
93820
|
sessions,
|
|
@@ -93811,6 +93960,76 @@ var sessionRenameCommand = {
|
|
|
93811
93960
|
void executeSessionRename(context.socket, message, context.sessions, context.signal);
|
|
93812
93961
|
}
|
|
93813
93962
|
};
|
|
93963
|
+
async function executeSessionConfigRead(socket, command, config2, directories, sessions, nativeSessions, diagnostics, signal) {
|
|
93964
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
93965
|
+
try {
|
|
93966
|
+
const entry = await metrics.measure("session-lookup", async () => {
|
|
93967
|
+
const [found] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
93968
|
+
if (found === void 0) {
|
|
93969
|
+
throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
|
|
93970
|
+
}
|
|
93971
|
+
return found;
|
|
93972
|
+
});
|
|
93973
|
+
const ready = await prepareSession(
|
|
93974
|
+
{
|
|
93975
|
+
additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
|
|
93976
|
+
agentId: entry.agentId,
|
|
93977
|
+
bindingId: config2.bindingId,
|
|
93978
|
+
directoryId: entry.directoryId,
|
|
93979
|
+
kind: "session.prepare",
|
|
93980
|
+
requestId: command.requestId,
|
|
93981
|
+
sessionId: command.sessionId,
|
|
93982
|
+
sessionState: "provisioned"
|
|
93983
|
+
},
|
|
93984
|
+
// A settings read must not force history loading: Agents without
|
|
93985
|
+
// load support would fail even with a live process whose config is
|
|
93986
|
+
// already readable, and prepare reuses the current configuration.
|
|
93987
|
+
{ kind: "interactive-only" },
|
|
93988
|
+
// Reading settings must not reopen a Session that a client closed.
|
|
93989
|
+
"keep-closed",
|
|
93990
|
+
config2,
|
|
93991
|
+
directories,
|
|
93992
|
+
sessions,
|
|
93993
|
+
metrics,
|
|
93994
|
+
signal
|
|
93995
|
+
);
|
|
93996
|
+
send(socket, {
|
|
93997
|
+
configOptions: ready.configOptions,
|
|
93998
|
+
kind: SESSION_CONFIG_READ_RESULT_KIND,
|
|
93999
|
+
requestId: command.requestId,
|
|
94000
|
+
sessionId: command.sessionId
|
|
94001
|
+
});
|
|
94002
|
+
} catch (error62) {
|
|
94003
|
+
diagnostics.daemonDiagnostic(
|
|
94004
|
+
"session_config_read_failed",
|
|
94005
|
+
command.requestId,
|
|
94006
|
+
{
|
|
94007
|
+
code: operationErrorCode(error62),
|
|
94008
|
+
sessionId: command.sessionId
|
|
94009
|
+
},
|
|
94010
|
+
error62
|
|
94011
|
+
);
|
|
94012
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
94013
|
+
}
|
|
94014
|
+
}
|
|
94015
|
+
var sessionConfigReadCommand = {
|
|
94016
|
+
kind: SESSION_CONFIG_READ_KIND,
|
|
94017
|
+
handle: (context, message) => {
|
|
94018
|
+
if (message.kind !== SESSION_CONFIG_READ_KIND) {
|
|
94019
|
+
throw new Error("Command kind mismatch");
|
|
94020
|
+
}
|
|
94021
|
+
void executeSessionConfigRead(
|
|
94022
|
+
context.socket,
|
|
94023
|
+
message,
|
|
94024
|
+
context.config,
|
|
94025
|
+
context.directories,
|
|
94026
|
+
context.sessions,
|
|
94027
|
+
context.nativeSessions,
|
|
94028
|
+
context.diagnostics,
|
|
94029
|
+
context.signal
|
|
94030
|
+
);
|
|
94031
|
+
}
|
|
94032
|
+
};
|
|
93814
94033
|
|
|
93815
94034
|
// src/runtime/command/registry/history.ts
|
|
93816
94035
|
function isAgentReasoning(event) {
|
|
@@ -94684,6 +94903,7 @@ function createCommandRegistry(context) {
|
|
|
94684
94903
|
workspaceListCommand,
|
|
94685
94904
|
sessionPrepareCommand,
|
|
94686
94905
|
sessionConfigureCommand,
|
|
94906
|
+
sessionConfigReadCommand,
|
|
94687
94907
|
sessionRenameCommand,
|
|
94688
94908
|
sessionRestoreCommand,
|
|
94689
94909
|
permissionRespondCommand,
|
|
@@ -95002,6 +95222,35 @@ function closeRelaySocket(socket, code, reason) {
|
|
|
95002
95222
|
}
|
|
95003
95223
|
}
|
|
95004
95224
|
}
|
|
95225
|
+
function readCommandCorrelation(encoded) {
|
|
95226
|
+
let value;
|
|
95227
|
+
try {
|
|
95228
|
+
value = JSON.parse(encoded);
|
|
95229
|
+
} catch {
|
|
95230
|
+
return { requestId: "unsupported", sessionId: "" };
|
|
95231
|
+
}
|
|
95232
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
95233
|
+
return { requestId: "unsupported", sessionId: "" };
|
|
95234
|
+
}
|
|
95235
|
+
const requestId = Reflect.get(value, "requestId");
|
|
95236
|
+
const sessionId = Reflect.get(value, "sessionId");
|
|
95237
|
+
return {
|
|
95238
|
+
requestId: typeof requestId === "string" && isIdentifier(requestId) ? requestId : "unsupported",
|
|
95239
|
+
sessionId: typeof sessionId === "string" && isIdentifier(sessionId) ? sessionId : ""
|
|
95240
|
+
};
|
|
95241
|
+
}
|
|
95242
|
+
function rejectUnsupportedCommand(socket, correlation, rejection) {
|
|
95243
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
95244
|
+
return;
|
|
95245
|
+
}
|
|
95246
|
+
send(socket, {
|
|
95247
|
+
code: rejection.code,
|
|
95248
|
+
kind: SESSION_OPERATION_FAILED_KIND,
|
|
95249
|
+
message: "The Relay sent a command this daemon does not support",
|
|
95250
|
+
requestId: correlation.requestId,
|
|
95251
|
+
sessionId: correlation.sessionId
|
|
95252
|
+
});
|
|
95253
|
+
}
|
|
95005
95254
|
async function runRelayConnection({
|
|
95006
95255
|
config: config2,
|
|
95007
95256
|
directories,
|
|
@@ -95159,11 +95408,23 @@ async function runRelayConnection({
|
|
|
95159
95408
|
commands.dispatch(message);
|
|
95160
95409
|
} catch (error62) {
|
|
95161
95410
|
if (error62 instanceof UnsupportedProtocolMessageKindError) {
|
|
95162
|
-
|
|
95411
|
+
const correlation = readCommandCorrelation(encoded);
|
|
95412
|
+
console.warn("Mobius daemon rejected an unsupported Relay command", {
|
|
95163
95413
|
code: error62.code,
|
|
95164
95414
|
direction: error62.direction,
|
|
95165
95415
|
messageKind: error62.messageKind
|
|
95166
95416
|
});
|
|
95417
|
+
diagnostics.daemonDiagnostic(
|
|
95418
|
+
"relay_command_unsupported",
|
|
95419
|
+
correlation.requestId,
|
|
95420
|
+
{
|
|
95421
|
+
code: error62.code,
|
|
95422
|
+
direction: error62.direction,
|
|
95423
|
+
messageKind: error62.messageKind
|
|
95424
|
+
},
|
|
95425
|
+
error62
|
|
95426
|
+
);
|
|
95427
|
+
rejectUnsupportedCommand(socket, correlation, error62);
|
|
95167
95428
|
return;
|
|
95168
95429
|
}
|
|
95169
95430
|
console.error("Mobius daemon rejected a message", error62);
|
|
@@ -95224,6 +95485,7 @@ var RuntimeSessionEventPublisher = class {
|
|
|
95224
95485
|
};
|
|
95225
95486
|
publishStatus = (event) => this.#send(event);
|
|
95226
95487
|
publishInfo = (event) => this.#send(event);
|
|
95488
|
+
publishClosed = (event) => this.#send(event);
|
|
95227
95489
|
#send = (message) => {
|
|
95228
95490
|
const socket = this.#socket;
|
|
95229
95491
|
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
@@ -95971,6 +96233,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
|
|
|
95971
96233
|
adapters: harnessAdapters,
|
|
95972
96234
|
sessionIdentity: "native",
|
|
95973
96235
|
onSessionStatusChanged: publisher.publishStatus,
|
|
96236
|
+
onSessionClosed: publisher.publishClosed,
|
|
95974
96237
|
contentExternalizer: new AcpContentExternalizer(externalContent),
|
|
95975
96238
|
timer,
|
|
95976
96239
|
maxProcesses: resolveMaxAcpProcesses(config2.localContext.environment)
|