@moxt-ai/mobius 0.0.277 → 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.
Files changed (35) hide show
  1. package/dist/acp/agent-runtime-manager.d.ts +8 -4
  2. package/dist/acp/agent-runtime-manager.d.ts.map +1 -1
  3. package/dist/acp/agent-runtime-manager.js +59 -6
  4. package/dist/acp/agent-runtime-manager.js.map +1 -1
  5. package/dist/acp/agent-session.d.ts.map +1 -1
  6. package/dist/acp/agent-session.js +20 -1
  7. package/dist/acp/agent-session.js.map +1 -1
  8. package/dist/acp/announced-tool-calls.d.ts +24 -0
  9. package/dist/acp/announced-tool-calls.d.ts.map +1 -0
  10. package/dist/acp/announced-tool-calls.js +37 -0
  11. package/dist/acp/announced-tool-calls.js.map +1 -0
  12. package/dist/acp/session-history.d.ts +2 -1
  13. package/dist/acp/session-history.d.ts.map +1 -1
  14. package/dist/acp/session-history.js.map +1 -1
  15. package/dist/acp/session-interactions.d.ts +4 -1
  16. package/dist/acp/session-interactions.d.ts.map +1 -1
  17. package/dist/acp/session-interactions.js +8 -2
  18. package/dist/acp/session-interactions.js.map +1 -1
  19. package/dist/cli.js +234 -108
  20. package/dist/cli.js.map +4 -4
  21. package/dist/runtime/command/registry/session.d.ts.map +1 -1
  22. package/dist/runtime/command/registry/session.js +8 -6
  23. package/dist/runtime/command/registry/session.js.map +1 -1
  24. package/dist/runtime/relay/session-event-publisher.d.ts +2 -1
  25. package/dist/runtime/relay/session-event-publisher.d.ts.map +1 -1
  26. package/dist/runtime/relay/session-event-publisher.js +1 -0
  27. package/dist/runtime/relay/session-event-publisher.js.map +1 -1
  28. package/dist/runtime/run.d.ts.map +1 -1
  29. package/dist/runtime/run.js +1 -0
  30. package/dist/runtime/run.js.map +1 -1
  31. package/dist/runtime/sessions.d.ts +8 -0
  32. package/dist/runtime/sessions.d.ts.map +1 -1
  33. package/dist/runtime.js +234 -108
  34. package/dist/runtime.js.map +4 -4
  35. 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.277",
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: {
@@ -25702,6 +25702,66 @@ var encodeFileEndEvent = (message) => encodeZodMessage(message, fileEndEventSche
25702
25702
  var decodeFileFailedEvent = (encoded) => decodeZodMessage(encoded, fileFailedEventSchema);
25703
25703
  var encodeFileFailedEvent = (message) => encodeZodMessage(message, fileFailedEventSchema);
25704
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
+
25705
25765
  // ../mobius-sdk/src/protocol/session/interactions/index.ts
25706
25766
  var SESSION_PERMISSION_REQUESTED_KIND = "session.permission.requested";
25707
25767
  var SESSION_PERMISSION_RESPOND_KIND = "session.permission.respond";
@@ -25739,6 +25799,12 @@ var elicitationFieldSchema = external_exports.object({
25739
25799
  }).readonly();
25740
25800
  var sessionPermissionRequestedEventSchema = external_exports.object({
25741
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(),
25742
25808
  interactionId: identifierStringSchema,
25743
25809
  kind: external_exports.literal(SESSION_PERMISSION_REQUESTED_KIND),
25744
25810
  options: external_exports.array(permissionOptionSchema).min(1).max(20).readonly(),
@@ -25802,6 +25868,8 @@ var SESSION_RESTORE_KIND = "session.restore";
25802
25868
  var SESSION_RESTORED_KIND = "session.restored";
25803
25869
  var SESSION_CLOSE_KIND = "session.close";
25804
25870
  var SESSION_CLOSED_KIND = "session.closed";
25871
+ var SESSION_CLOSE_NOTICE_KIND = "session.close.notice";
25872
+ var SESSION_CLOSED_ERROR_CODE = "session_closed";
25805
25873
  var SESSION_STATUS_CHANGED_KIND = "session.status.changed";
25806
25874
  var SESSION_COMMANDS_UPDATED_KIND = "session.commands.updated";
25807
25875
  var SESSION_INFO_UPDATED_KIND = "session.info.updated";
@@ -25907,6 +25975,11 @@ var sessionClosedEventSchema = external_exports.object({
25907
25975
  requestId: identifierStringSchema,
25908
25976
  sessionId: identifierStringSchema
25909
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();
25910
25983
  var sessionCommandsUpdatedEventSchema = external_exports.object({
25911
25984
  commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
25912
25985
  kind: external_exports.literal(SESSION_COMMANDS_UPDATED_KIND),
@@ -25943,6 +26016,8 @@ var decodeSessionCloseCommand = (encoded) => decodeZodMessage(encoded, sessionCl
25943
26016
  var encodeSessionCloseCommand = (message) => encodeZodMessage(message, sessionCloseCommandSchema);
25944
26017
  var decodeSessionClosedEvent = (encoded) => decodeZodMessage(encoded, sessionClosedEventSchema);
25945
26018
  var encodeSessionClosedEvent = (message) => encodeZodMessage(message, sessionClosedEventSchema);
26019
+ var decodeSessionCloseNoticeEvent = (encoded) => decodeZodMessage(encoded, sessionCloseNoticeEventSchema);
26020
+ var encodeSessionCloseNoticeEvent = (message) => encodeZodMessage(message, sessionCloseNoticeEventSchema);
25946
26021
  var decodeSessionStatusChangedEvent = (encoded) => decodeZodMessage(encoded, sessionStatusChangedEventSchema);
25947
26022
  var encodeSessionStatusChangedEvent = (message) => encodeZodMessage(message, sessionStatusChangedEventSchema);
25948
26023
  var decodeSessionPrepareCommand = (encoded) => decodeZodMessage(encoded, sessionPrepareCommandSchema);
@@ -26186,86 +26261,35 @@ var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSch
26186
26261
 
26187
26262
  // ../mobius-sdk/src/protocol/session/observability/event-log.ts
26188
26263
  var MAX_EVENT_COUNT = 1e4;
26189
- var MAX_COLLECTION_SIZE = 1e3;
26190
- var MAX_CONTENT_LENGTH = 1e6;
26191
- var MAX_JSON_DEPTH = 16;
26192
- var MAX_JSON_KEYS = 1e3;
26264
+ var MAX_COLLECTION_SIZE2 = 1e3;
26265
+ var MAX_CONTENT_LENGTH2 = 1e6;
26193
26266
  var SESSION_EVENT_KIND = "session.event.v2";
26194
26267
  var SESSION_EVENT_BATCH_MAX_SIZE = 1e3;
26195
- var boundedString = external_exports.string().max(MAX_CONTENT_LENGTH);
26268
+ var boundedString2 = external_exports.string().max(MAX_CONTENT_LENGTH2);
26196
26269
  var shortString = external_exports.string().max(2048);
26197
26270
  var externalContentKeySchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
26198
- function boundedJsonIssue(value, depth = 0) {
26199
- if (depth > MAX_JSON_DEPTH) {
26200
- return "JSON nesting exceeds the maximum depth";
26201
- }
26202
- if (typeof value === "string") {
26203
- return value.length <= MAX_CONTENT_LENGTH ? null : "JSON string exceeds the maximum length";
26204
- }
26205
- if (typeof value === "number") {
26206
- return Number.isFinite(value) ? null : "JSON number must be finite";
26207
- }
26208
- if (typeof value === "boolean" || value === null) {
26209
- return null;
26210
- }
26211
- if (Array.isArray(value)) {
26212
- if (value.length > MAX_COLLECTION_SIZE) {
26213
- return "JSON array exceeds the maximum length";
26214
- }
26215
- for (const item of value) {
26216
- const issue2 = boundedJsonIssue(item, depth + 1);
26217
- if (issue2 !== null) {
26218
- return issue2;
26219
- }
26220
- }
26221
- return null;
26222
- }
26223
- if (typeof value === "object" && value !== void 0) {
26224
- const entries = Object.entries(value);
26225
- if (entries.length > MAX_JSON_KEYS) {
26226
- return "JSON object exceeds the maximum key count";
26227
- }
26228
- for (const [key, item] of entries) {
26229
- if (key.length > 255) {
26230
- return "JSON key exceeds the maximum length";
26231
- }
26232
- const issue2 = boundedJsonIssue(item, depth + 1);
26233
- if (issue2 !== null) {
26234
- return issue2;
26235
- }
26236
- }
26237
- return null;
26238
- }
26239
- return "Value is not bounded JSON";
26240
- }
26241
- var boundedJsonSchema = external_exports.unknown().superRefine((value, context) => {
26242
- const issue2 = boundedJsonIssue(value);
26243
- if (issue2 !== null) {
26244
- context.addIssue({ code: "custom", message: issue2 });
26245
- }
26246
- });
26247
26271
  var annotationsSchema = external_exports.object({
26248
26272
  audience: external_exports.array(external_exports.enum(["assistant", "user"])).max(2).readonly().nullable().optional(),
26249
26273
  lastModified: shortString.nullable().optional(),
26250
26274
  priority: external_exports.number().finite().nullable().optional()
26251
26275
  }).readonly();
26252
26276
  var contentFields = { annotations: annotationsSchema.nullable().optional() };
26253
- var textContentSchema = external_exports.object({ ...contentFields, text: boundedString, type: external_exports.literal("text") }).readonly();
26277
+ var textContentSchema = external_exports.object({ ...contentFields, text: boundedString2, type: external_exports.literal("text") }).readonly();
26254
26278
  var imageContentSchema = external_exports.object({
26255
26279
  ...contentFields,
26256
- data: boundedString,
26280
+ data: boundedString2,
26257
26281
  mimeType: shortString,
26258
26282
  type: external_exports.literal("image"),
26259
- uri: boundedString.nullable().optional()
26283
+ uri: boundedString2.nullable().optional()
26260
26284
  }).readonly();
26261
- var audioContentSchema = external_exports.object({ ...contentFields, data: boundedString, mimeType: shortString, type: external_exports.literal("audio") }).readonly();
26285
+ var audioContentSchema = external_exports.object({ ...contentFields, data: boundedString2, mimeType: shortString, type: external_exports.literal("audio") }).readonly();
26262
26286
  var externalImageContentSchema = external_exports.object({
26263
26287
  ...contentFields,
26264
26288
  byteLength: external_exports.number().int().positive().safe(),
26265
26289
  imageKey: externalContentKeySchema,
26266
26290
  mimeType: shortString,
26267
26291
  type: external_exports.literal("external_image"),
26268
- uri: boundedString.nullable().optional()
26292
+ uri: boundedString2.nullable().optional()
26269
26293
  }).readonly();
26270
26294
  var externalAudioContentSchema = external_exports.object({
26271
26295
  ...contentFields,
@@ -26281,27 +26305,27 @@ var externalResourceContentSchema = external_exports.object({
26281
26305
  mimeType: shortString.nullable().optional(),
26282
26306
  resourceKey: externalContentKeySchema,
26283
26307
  type: external_exports.literal("external_resource"),
26284
- uri: boundedString
26308
+ uri: boundedString2
26285
26309
  }).readonly();
26286
26310
  var resourceLinkSchema = external_exports.object({
26287
26311
  ...contentFields,
26288
- description: boundedString.nullable().optional(),
26312
+ description: boundedString2.nullable().optional(),
26289
26313
  mimeType: shortString.nullable().optional(),
26290
26314
  name: shortString,
26291
26315
  size: external_exports.number().int().nonnegative().safe().nullable().optional(),
26292
26316
  title: shortString.nullable().optional(),
26293
26317
  type: external_exports.literal("resource_link"),
26294
- uri: boundedString
26318
+ uri: boundedString2
26295
26319
  }).readonly();
26296
26320
  var textResourceSchema = external_exports.object({
26297
26321
  mimeType: shortString.nullable().optional(),
26298
- text: boundedString,
26299
- uri: boundedString
26322
+ text: boundedString2,
26323
+ uri: boundedString2
26300
26324
  }).readonly();
26301
26325
  var blobResourceSchema = external_exports.object({
26302
- blob: boundedString,
26326
+ blob: boundedString2,
26303
26327
  mimeType: shortString.nullable().optional(),
26304
- uri: boundedString
26328
+ uri: boundedString2
26305
26329
  }).readonly();
26306
26330
  var embeddedResourceSchema = external_exports.object({
26307
26331
  ...contentFields,
@@ -26321,17 +26345,13 @@ var contentBlockSchema = external_exports.discriminatedUnion("type", [
26321
26345
  var toolCallContentSchema = external_exports.discriminatedUnion("type", [
26322
26346
  external_exports.object({ content: contentBlockSchema, type: external_exports.literal("content") }).readonly(),
26323
26347
  external_exports.object({
26324
- newText: boundedString,
26325
- oldText: boundedString.nullable().optional(),
26326
- path: boundedString,
26348
+ newText: boundedString2,
26349
+ oldText: boundedString2.nullable().optional(),
26350
+ path: boundedString2,
26327
26351
  type: external_exports.literal("diff")
26328
26352
  }).readonly(),
26329
26353
  external_exports.object({ terminalId: shortString, type: external_exports.literal("terminal") }).readonly()
26330
26354
  ]);
26331
- var toolCallLocationSchema = external_exports.object({
26332
- line: external_exports.number().int().nonnegative().safe().nullable().optional(),
26333
- path: boundedString
26334
- }).readonly();
26335
26355
  var toolKindSchema = external_exports.enum([
26336
26356
  "read",
26337
26357
  "edit",
@@ -26346,51 +26366,51 @@ var toolKindSchema = external_exports.enum([
26346
26366
  ]);
26347
26367
  var toolStatusSchema = external_exports.enum(["pending", "in_progress", "completed", "failed"]);
26348
26368
  var toolPatchFields = {
26349
- content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE).readonly().nullable().optional(),
26369
+ content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
26350
26370
  kind: toolKindSchema.nullable().optional(),
26351
- locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE).readonly().nullable().optional(),
26371
+ locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
26352
26372
  name: shortString.nullable().optional(),
26353
26373
  rawInput: boundedJsonSchema.optional(),
26354
26374
  rawOutput: boundedJsonSchema.optional(),
26355
26375
  status: toolStatusSchema.nullable().optional(),
26356
- title: boundedString.nullable().optional()
26376
+ title: boundedString2.nullable().optional()
26357
26377
  };
26358
26378
  var planEntrySchema = external_exports.object({
26359
- content: boundedString,
26379
+ content: boundedString2,
26360
26380
  priority: external_exports.enum(["high", "medium", "low"]),
26361
26381
  status: external_exports.enum(["pending", "in_progress", "completed"])
26362
26382
  }).readonly();
26363
26383
  var planContentSchema = external_exports.discriminatedUnion("type", [
26364
26384
  external_exports.object({
26365
- entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE).readonly(),
26385
+ entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
26366
26386
  planId: shortString,
26367
26387
  type: external_exports.literal("items")
26368
26388
  }).readonly(),
26369
- external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString }).readonly(),
26389
+ external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString2 }).readonly(),
26370
26390
  external_exports.object({
26371
- content: boundedString,
26391
+ content: boundedString2,
26372
26392
  planId: shortString,
26373
26393
  type: external_exports.literal("markdown")
26374
26394
  }).readonly()
26375
26395
  ]);
26376
26396
  var commandSchema = external_exports.object({
26377
- description: boundedString,
26378
- input: external_exports.object({ hint: boundedString }).readonly().nullable().optional(),
26397
+ description: boundedString2,
26398
+ input: external_exports.object({ hint: boundedString2 }).readonly().nullable().optional(),
26379
26399
  name: shortString
26380
26400
  }).readonly();
26381
26401
  var configSelectOptionSchema = external_exports.object({
26382
- description: boundedString.nullable().optional(),
26402
+ description: boundedString2.nullable().optional(),
26383
26403
  name: shortString,
26384
26404
  value: shortString
26385
26405
  }).readonly();
26386
26406
  var configSelectGroupSchema = external_exports.object({
26387
26407
  group: shortString,
26388
26408
  name: shortString,
26389
- options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE).readonly()
26409
+ options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly()
26390
26410
  }).readonly();
26391
26411
  var configBaseFields = {
26392
26412
  category: shortString.nullable().optional(),
26393
- description: boundedString.nullable().optional(),
26413
+ description: boundedString2.nullable().optional(),
26394
26414
  id: shortString,
26395
26415
  name: shortString
26396
26416
  };
@@ -26399,8 +26419,8 @@ var sessionConfigOptionSchema2 = external_exports.discriminatedUnion("type", [
26399
26419
  ...configBaseFields,
26400
26420
  currentValue: shortString,
26401
26421
  options: external_exports.union([
26402
- external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE).readonly(),
26403
- external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE).readonly()
26422
+ external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly(),
26423
+ external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE2).readonly()
26404
26424
  ]),
26405
26425
  type: external_exports.literal("select")
26406
26426
  }).readonly(),
@@ -26415,26 +26435,26 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
26415
26435
  external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_message_chunk") }).readonly(),
26416
26436
  external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_thought_chunk") }).readonly(),
26417
26437
  external_exports.object({
26418
- content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE).readonly().optional(),
26438
+ content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
26419
26439
  kind: toolKindSchema.optional(),
26420
- locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE).readonly().optional(),
26440
+ locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
26421
26441
  name: shortString.nullable().optional(),
26422
26442
  rawInput: boundedJsonSchema.optional(),
26423
26443
  rawOutput: boundedJsonSchema.optional(),
26424
26444
  sessionUpdate: external_exports.literal("tool_call"),
26425
26445
  status: toolStatusSchema.optional(),
26426
- title: boundedString,
26446
+ title: boundedString2,
26427
26447
  toolCallId: shortString
26428
26448
  }).readonly(),
26429
26449
  external_exports.object({ ...toolPatchFields, sessionUpdate: external_exports.literal("tool_call_update"), toolCallId: shortString }).readonly(),
26430
26450
  external_exports.object({
26431
- entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE).readonly(),
26451
+ entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
26432
26452
  sessionUpdate: external_exports.literal("plan")
26433
26453
  }).readonly(),
26434
26454
  external_exports.object({ plan: planContentSchema, sessionUpdate: external_exports.literal("plan_update") }).readonly(),
26435
26455
  external_exports.object({ planId: shortString, sessionUpdate: external_exports.literal("plan_removed") }).readonly(),
26436
26456
  external_exports.object({
26437
- availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE).readonly(),
26457
+ availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE2).readonly(),
26438
26458
  sessionUpdate: external_exports.literal("available_commands_update")
26439
26459
  }).readonly(),
26440
26460
  external_exports.object({
@@ -26442,12 +26462,12 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
26442
26462
  sessionUpdate: external_exports.literal("current_mode_update")
26443
26463
  }).readonly(),
26444
26464
  external_exports.object({
26445
- configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE).readonly(),
26465
+ configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE2).readonly(),
26446
26466
  sessionUpdate: external_exports.literal("config_option_update")
26447
26467
  }).readonly(),
26448
26468
  external_exports.object({
26449
26469
  sessionUpdate: external_exports.literal("session_info_update"),
26450
- title: boundedString.nullable().optional(),
26470
+ title: boundedString2.nullable().optional(),
26451
26471
  updatedAt: shortString.nullable().optional()
26452
26472
  }).readonly(),
26453
26473
  external_exports.object({
@@ -26458,10 +26478,10 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
26458
26478
  }).readonly(),
26459
26479
  external_exports.object({
26460
26480
  compactionId: shortString,
26461
- error: boundedString.nullable().optional(),
26481
+ error: boundedString2.nullable().optional(),
26462
26482
  sessionUpdate: external_exports.literal("compaction_update"),
26463
26483
  status: shortString,
26464
- summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE).readonly().nullable().optional()
26484
+ summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional()
26465
26485
  }).readonly(),
26466
26486
  external_exports.object({
26467
26487
  compactionId: shortString,
@@ -26591,7 +26611,7 @@ var queuedPromptRequestEventLogSchema = external_exports.object({
26591
26611
  }).readonly();
26592
26612
  var nativeSessionEventsSchema = external_exports.object({
26593
26613
  events: sessionEventLogPageSchema,
26594
- queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE).readonly()
26614
+ queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE2).readonly()
26595
26615
  }).readonly();
26596
26616
  function inputValue(value) {
26597
26617
  if (typeof value !== "string") {
@@ -26894,6 +26914,11 @@ var daemonToServiceSignatures = {
26894
26914
  encodeSessionClosedEvent,
26895
26915
  decodeSessionClosedEvent
26896
26916
  ),
26917
+ [SESSION_CLOSE_NOTICE_KIND]: defineMessageSignature(
26918
+ SESSION_CLOSE_NOTICE_KIND,
26919
+ encodeSessionCloseNoticeEvent,
26920
+ decodeSessionCloseNoticeEvent
26921
+ ),
26897
26922
  [SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
26898
26923
  SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
26899
26924
  encodeSessionPreviewHistoryPageLoaded,
@@ -82340,6 +82365,7 @@ var ActiveExecutions = class {
82340
82365
  };
82341
82366
 
82342
82367
  // src/acp/agent-session.ts
82368
+ import { setImmediate as yieldToRuntime2 } from "node:timers/promises";
82343
82369
  import {
82344
82370
  methods as methods10,
82345
82371
  PROTOCOL_VERSION as PROTOCOL_VERSION3
@@ -82712,6 +82738,36 @@ var AgentUpdateStream = class {
82712
82738
  };
82713
82739
  };
82714
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
+
82715
82771
  // src/acp/runtime-operations.ts
82716
82772
  var RuntimeOperations = class {
82717
82773
  #shutdown = new AbortController();
@@ -83498,15 +83554,21 @@ var AcpSessionInteractions = class {
83498
83554
  };
83499
83555
  signal.addEventListener("abort", abort, { once: true });
83500
83556
  try {
83557
+ const toolCall = this.#context.describeToolCall(request.toolCall);
83501
83558
  await this.#notifyPermissionRequested({
83502
83559
  commandId: this.#context.commandId(),
83560
+ details: {
83561
+ cwd: this.#context.cwd(),
83562
+ rawInput: toolCall.rawInput,
83563
+ locations: toolCall.locations ?? []
83564
+ },
83503
83565
  interactionId,
83504
83566
  kind: SESSION_PERMISSION_REQUESTED_KIND,
83505
83567
  options,
83506
83568
  sessionId: this.#context.sessionId(),
83507
- title: truncate2(request.toolCall.title ?? "Permission required", 500),
83569
+ title: truncate2(toolCall.title ?? "Permission required", 500),
83508
83570
  toolCallId: truncate2(request.toolCall.toolCallId, 255),
83509
- toolKind: truncate2(request.toolCall.kind ?? "other", 64)
83571
+ toolKind: truncate2(toolCall.kind ?? "other", 64)
83510
83572
  });
83511
83573
  return await pending.completion.promise;
83512
83574
  } finally {
@@ -89168,6 +89230,7 @@ var AgentSession = class _AgentSession {
89168
89230
  #connection;
89169
89231
  #contentExternalizer;
89170
89232
  #interactions;
89233
+ #announcedToolCalls = new AnnouncedToolCalls();
89171
89234
  #additionalDirectories;
89172
89235
  #agentId;
89173
89236
  #cwd;
@@ -89208,6 +89271,8 @@ var AgentSession = class _AgentSession {
89208
89271
  this.#store = store;
89209
89272
  this.#verifiedAgentVersion = agent.agentVersion;
89210
89273
  this.#interactions = new AcpSessionInteractions({
89274
+ cwd: () => this.#cwd,
89275
+ describeToolCall: this.#announcedToolCalls.describe,
89211
89276
  sessionId: () => this.#mobiusSessionId,
89212
89277
  commandId: () => this.#turn.commandId,
89213
89278
  assertNativeSession: (sessionId) => this.assertNativeSession(sessionId),
@@ -89931,6 +89996,7 @@ var AgentSession = class _AgentSession {
89931
89996
  throw failure2;
89932
89997
  } finally {
89933
89998
  this.#turn = new IdleAcpTurn();
89999
+ this.#announcedToolCalls.clear();
89934
90000
  }
89935
90001
  };
89936
90002
  steer = async (options) => {
@@ -90037,7 +90103,12 @@ var AgentSession = class _AgentSession {
90037
90103
  };
90038
90104
  respondPermission = (options) => this.#interactions.respondPermission(options);
90039
90105
  respondElicitation = (options) => this.#interactions.respondElicitation(options);
90040
- onPermission = (request, signal) => this.#interactions.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
+ };
90041
90112
  onElicitation = (request, signal) => this.#interactions.onElicitation(request, signal);
90042
90113
  onElicitationComplete = (notification) => this.#interactions.onElicitationComplete(notification);
90043
90114
  onUpdate = (notification) => this.#updates.receive(notification);
@@ -90079,6 +90150,9 @@ var AgentSession = class _AgentSession {
90079
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")) {
90080
90151
  return;
90081
90152
  }
90153
+ if (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") {
90154
+ this.#announcedToolCalls.record(update);
90155
+ }
90082
90156
  if (update.sessionUpdate === "available_commands_update") {
90083
90157
  const commands = update.availableCommands.slice(0, 500).map((command) => ({
90084
90158
  description: truncate2(command.description, 500),
@@ -90442,10 +90516,13 @@ var AgentRuntimeManager = class {
90442
90516
  #agentSettingsObserver = new NullAcpSessionObserver();
90443
90517
  #nativeOperations = /* @__PURE__ */ new Set();
90444
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();
90445
90521
  #store;
90446
90522
  #adapters;
90447
90523
  #sessionIdentity;
90448
90524
  #onSessionStatusChanged;
90525
+ #onSessionClosed;
90449
90526
  #contentExternalizer;
90450
90527
  #timer;
90451
90528
  #observer;
@@ -90455,6 +90532,7 @@ var AgentRuntimeManager = class {
90455
90532
  adapters,
90456
90533
  sessionIdentity,
90457
90534
  onSessionStatusChanged,
90535
+ onSessionClosed = () => void 0,
90458
90536
  contentExternalizer,
90459
90537
  timer,
90460
90538
  maxProcesses
@@ -90465,6 +90543,7 @@ var AgentRuntimeManager = class {
90465
90543
  this.#adapters = adapters;
90466
90544
  this.#sessionIdentity = sessionIdentity;
90467
90545
  this.#onSessionStatusChanged = onSessionStatusChanged;
90546
+ this.#onSessionClosed = onSessionClosed;
90468
90547
  this.#contentExternalizer = contentExternalizer;
90469
90548
  this.#timer = timer;
90470
90549
  this.#queryProcesses = new AgentQueryProcesses(this.#processes, contentExternalizer);
@@ -90502,6 +90581,34 @@ var AgentRuntimeManager = class {
90502
90581
  }
90503
90582
  }
90504
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
+ }
90505
90612
  async #startRetainedSessionProcess(options, start) {
90506
90613
  const runtime = await this.#processes.startRetained(options.signal, start, this.#retention(options.sessionId));
90507
90614
  this.#executionProcesses.retain(options.sessionId, runtime);
@@ -90595,12 +90702,17 @@ var AgentRuntimeManager = class {
90595
90702
  return runtime;
90596
90703
  });
90597
90704
  }
90598
- async #prepareSession(options, recovery, metrics = unmeasuredOperationMetrics) {
90705
+ async #prepareSession(options, recovery, closed, metrics = unmeasuredOperationMetrics) {
90599
90706
  return await this.#operations.run(options, async (options2) => {
90600
90707
  const closing = this.#sessionClosures.get(options2.sessionId);
90601
90708
  if (closing !== void 0) {
90602
90709
  await waitForSharedOperation(closing, options2.signal);
90603
90710
  }
90711
+ if (closed === "reopen") {
90712
+ this.#closedSessions.delete(options2.sessionId);
90713
+ } else {
90714
+ this.#assertOpen(options2.sessionId);
90715
+ }
90604
90716
  const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
90605
90717
  if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
90606
90718
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -90621,7 +90733,7 @@ var AgentRuntimeManager = class {
90621
90733
  }
90622
90734
  return runtime2.prepared();
90623
90735
  }
90624
- return await this.#prepareSession(options2, recovery, metrics);
90736
+ return await this.#prepareSession(options2, recovery, closed, metrics);
90625
90737
  }
90626
90738
  const existing = this.#executionProcesses.get(options2.sessionId);
90627
90739
  if (existing !== void 0) {
@@ -90649,8 +90761,8 @@ var AgentRuntimeManager = class {
90649
90761
  return runtime.prepared();
90650
90762
  });
90651
90763
  }
90652
- prepareSession = async (options, metrics = unmeasuredOperationMetrics) => await this.#prepareSession(options, { kind: "interactive-only" }, metrics);
90653
- 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);
90654
90766
  /**
90655
90767
  * Opens a short-lived native ACP session only to read the local Agent's
90656
90768
  * authoritative settings. Its identity and store are private to this
@@ -90721,6 +90833,7 @@ var AgentRuntimeManager = class {
90721
90833
  });
90722
90834
  });
90723
90835
  prepareExecutionSession = async (options) => this.#operations.run(options, async (options2) => {
90836
+ this.#assertOpen(options2.sessionId);
90724
90837
  const pending = this.#executionProcesses.pending(options2.sessionId);
90725
90838
  if (pending !== void 0) {
90726
90839
  await waitForSharedOperation(pending, options2.signal);
@@ -90758,6 +90871,7 @@ var AgentRuntimeManager = class {
90758
90871
  });
90759
90872
  });
90760
90873
  renameSession = async (sessionId, title2, signal) => await this.#operations.run({ sessionId, signal }, async (options) => {
90874
+ this.#assertOpen(options.sessionId);
90761
90875
  const runtime = this.#executionProcesses.get(options.sessionId);
90762
90876
  if (runtime !== void 0) {
90763
90877
  return await runtime.renameSession(title2, options.signal);
@@ -90833,6 +90947,7 @@ var AgentRuntimeManager = class {
90833
90947
  }
90834
90948
  });
90835
90949
  runPrompt = async (options) => this.#operations.run(options, async (options2) => {
90950
+ this.#assertOpen(options2.sessionId);
90836
90951
  const stored = this.#store.read(options2.sessionId);
90837
90952
  if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
90838
90953
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -90901,6 +91016,7 @@ var AgentRuntimeManager = class {
90901
91016
  }
90902
91017
  });
90903
91018
  respondPermission = async (options) => {
91019
+ this.#assertOpen(options.sessionId);
90904
91020
  const runtime = this.#executionProcesses.get(options.sessionId);
90905
91021
  if (runtime === void 0) {
90906
91022
  throw new AcpExecutionError("The permission request session is unavailable", {}, "session_not_found");
@@ -90908,6 +91024,7 @@ var AgentRuntimeManager = class {
90908
91024
  await runtime.respondPermission(options);
90909
91025
  };
90910
91026
  respondElicitation = async (options) => {
91027
+ this.#assertOpen(options.sessionId);
90911
91028
  const runtime = this.#executionProcesses.get(options.sessionId);
90912
91029
  if (runtime === void 0) {
90913
91030
  throw new AcpExecutionError("The elicitation request session is unavailable", {}, "session_not_found");
@@ -90920,11 +91037,12 @@ var AgentRuntimeManager = class {
90920
91037
  await waitForSharedOperation(existing, options.signal);
90921
91038
  return;
90922
91039
  }
91040
+ this.#announceClosed(options.sessionId, "This Session was closed on request.");
90923
91041
  const release = (async () => {
90924
91042
  const pending = this.#executionProcesses.pending(options.sessionId);
90925
91043
  const runtime = pending === void 0 ? this.#executionProcesses.get(options.sessionId) : await pending;
90926
91044
  if (runtime !== void 0) {
90927
- await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.close());
91045
+ await this.#stopSessionProcess(options.sessionId, runtime);
90928
91046
  }
90929
91047
  })();
90930
91048
  const deadline = Promise.withResolvers();
@@ -91006,6 +91124,7 @@ var AgentRuntimeManager = class {
91006
91124
  });
91007
91125
  });
91008
91126
  ensureSession = async (options) => this.#operations.run(options, async (options2) => {
91127
+ this.#assertOpen(options2.sessionId);
91009
91128
  const existing = this.#executionProcesses.get(options2.sessionId);
91010
91129
  if (existing !== void 0) {
91011
91130
  if (!existing.belongsTo(options2.agent.id, options2.cwd, options2.additionalDirectories)) {
@@ -91084,6 +91203,7 @@ var AgentRuntimeManager = class {
91084
91203
  const existing = linked[0];
91085
91204
  if (origin.kind === "import" && existing !== void 0) {
91086
91205
  return await this.#executionProcesses.use(existing.sessionId, async () => {
91206
+ this.#closedSessions.delete(existing.sessionId);
91087
91207
  const runtime = await this.ensureSession({
91088
91208
  ...options2,
91089
91209
  sessionId: existing.sessionId
@@ -93571,7 +93691,7 @@ async function resolveCatalogAgent(config2, agentId, signal) {
93571
93691
  const agent = config2.catalog.find(agentId);
93572
93692
  return config2.resolveAgent === void 0 ? agent : await config2.resolveAgent(agent, signal);
93573
93693
  }
93574
- async function prepareSession(command, recovery, config2, directories, sessions, metrics, signal) {
93694
+ async function prepareSession(command, recovery, closed, config2, directories, sessions, metrics, signal) {
93575
93695
  return await metrics.measure("prepare-total", async () => {
93576
93696
  const resolved = await metrics.measure(
93577
93697
  "workspace-resolve",
@@ -93591,7 +93711,7 @@ async function prepareSession(command, recovery, config2, directories, sessions,
93591
93711
  sessionId: command.sessionId,
93592
93712
  signal
93593
93713
  };
93594
- 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);
93595
93715
  const configuration = command.configuration;
93596
93716
  const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
93597
93717
  "configuration",
@@ -93647,6 +93767,7 @@ async function executeSessionPrepare(socket, command, config2, directories, sess
93647
93767
  const readyEvent = await prepareSession(
93648
93768
  command,
93649
93769
  { kind: "interactive-only" },
93770
+ "reopen",
93650
93771
  config2,
93651
93772
  directories,
93652
93773
  sessions,
@@ -93693,6 +93814,7 @@ async function executeSessionRestore(socket, command, config2, directories, sess
93693
93814
  sessionState: "provisioned"
93694
93815
  },
93695
93816
  { kind: "history-required" },
93817
+ "reopen",
93696
93818
  config2,
93697
93819
  directories,
93698
93820
  sessions,
@@ -93863,6 +93985,8 @@ async function executeSessionConfigRead(socket, command, config2, directories, s
93863
93985
  // load support would fail even with a live process whose config is
93864
93986
  // already readable, and prepare reuses the current configuration.
93865
93987
  { kind: "interactive-only" },
93988
+ // Reading settings must not reopen a Session that a client closed.
93989
+ "keep-closed",
93866
93990
  config2,
93867
93991
  directories,
93868
93992
  sessions,
@@ -95361,6 +95485,7 @@ var RuntimeSessionEventPublisher = class {
95361
95485
  };
95362
95486
  publishStatus = (event) => this.#send(event);
95363
95487
  publishInfo = (event) => this.#send(event);
95488
+ publishClosed = (event) => this.#send(event);
95364
95489
  #send = (message) => {
95365
95490
  const socket = this.#socket;
95366
95491
  if (socket === null || socket.readyState !== WebSocket8.OPEN) {
@@ -96108,6 +96233,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
96108
96233
  adapters: harnessAdapters,
96109
96234
  sessionIdentity: "native",
96110
96235
  onSessionStatusChanged: publisher.publishStatus,
96236
+ onSessionClosed: publisher.publishClosed,
96111
96237
  contentExternalizer: new AcpContentExternalizer(externalContent),
96112
96238
  timer,
96113
96239
  maxProcesses: resolveMaxAcpProcesses(config2.localContext.environment)