@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.
Files changed (46) 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/acp/session-store.d.ts +1 -1
  20. package/dist/acp/session-store.d.ts.map +1 -1
  21. package/dist/acp/session-store.js +1 -1
  22. package/dist/acp/session-store.js.map +1 -1
  23. package/dist/cli.js +373 -110
  24. package/dist/cli.js.map +4 -4
  25. package/dist/runtime/command/registry/index.d.ts.map +1 -1
  26. package/dist/runtime/command/registry/index.js +2 -1
  27. package/dist/runtime/command/registry/index.js.map +1 -1
  28. package/dist/runtime/command/registry/session.d.ts +3 -1
  29. package/dist/runtime/command/registry/session.d.ts.map +1 -1
  30. package/dist/runtime/command/registry/session.js +56 -6
  31. package/dist/runtime/command/registry/session.js.map +1 -1
  32. package/dist/runtime/relay/run-relay-connection.d.ts.map +1 -1
  33. package/dist/runtime/relay/run-relay-connection.js +49 -2
  34. package/dist/runtime/relay/run-relay-connection.js.map +1 -1
  35. package/dist/runtime/relay/session-event-publisher.d.ts +2 -1
  36. package/dist/runtime/relay/session-event-publisher.d.ts.map +1 -1
  37. package/dist/runtime/relay/session-event-publisher.js +1 -0
  38. package/dist/runtime/relay/session-event-publisher.js.map +1 -1
  39. package/dist/runtime/run.d.ts.map +1 -1
  40. package/dist/runtime/run.js +1 -0
  41. package/dist/runtime/run.js.map +1 -1
  42. package/dist/runtime/sessions.d.ts +8 -0
  43. package/dist/runtime/sessions.d.ts.map +1 -1
  44. package/dist/runtime.js +373 -110
  45. package/dist/runtime.js.map +4 -4
  46. package/package.json +2 -2
package/dist/runtime.js CHANGED
@@ -22148,6 +22148,23 @@ var decodeSessionConfigureCommand = (encoded) => decodeZodMessage(encoded, sessi
22148
22148
  var encodeSessionConfigureCommand = (message) => encodeZodMessage(message, sessionConfigureCommandSchema);
22149
22149
  var decodeSessionConfigUpdatedEvent = (encoded) => decodeZodMessage(encoded, sessionConfigUpdatedEventSchema);
22150
22150
  var encodeSessionConfigUpdatedEvent = (message) => encodeZodMessage(message, sessionConfigUpdatedEventSchema);
22151
+ var SESSION_CONFIG_READ_KIND = "session.config.read";
22152
+ var SESSION_CONFIG_READ_RESULT_KIND = "session.config.read.result";
22153
+ var sessionConfigReadCommandSchema = external_exports.object({
22154
+ kind: external_exports.literal(SESSION_CONFIG_READ_KIND),
22155
+ requestId: identifierStringSchema,
22156
+ sessionId: identifierStringSchema
22157
+ }).readonly();
22158
+ var sessionConfigReadResultSchema = external_exports.object({
22159
+ configOptions: sessionConfigOptionsSchema,
22160
+ kind: external_exports.literal(SESSION_CONFIG_READ_RESULT_KIND),
22161
+ requestId: identifierStringSchema,
22162
+ sessionId: identifierStringSchema
22163
+ }).readonly();
22164
+ var decodeSessionConfigReadCommand = (encoded) => decodeZodMessage(encoded, sessionConfigReadCommandSchema);
22165
+ var encodeSessionConfigReadCommand = (message) => encodeZodMessage(message, sessionConfigReadCommandSchema);
22166
+ var decodeSessionConfigReadResult = (encoded) => decodeZodMessage(encoded, sessionConfigReadResultSchema);
22167
+ var encodeSessionConfigReadResult = (message) => encodeZodMessage(message, sessionConfigReadResultSchema);
22151
22168
 
22152
22169
  // ../mobius-sdk/src/protocol/session/configuration/title.ts
22153
22170
  var SESSION_RENAME_KIND = "session.rename";
@@ -22222,6 +22239,66 @@ var encodeFileEndEvent = (message) => encodeZodMessage(message, fileEndEventSche
22222
22239
  var decodeFileFailedEvent = (encoded) => decodeZodMessage(encoded, fileFailedEventSchema);
22223
22240
  var encodeFileFailedEvent = (message) => encodeZodMessage(message, fileFailedEventSchema);
22224
22241
 
22242
+ // ../mobius-sdk/src/protocol/shared/tool-input.ts
22243
+ var MAX_CONTENT_LENGTH = 1e6;
22244
+ var MAX_COLLECTION_SIZE = 1e3;
22245
+ var MAX_JSON_DEPTH = 16;
22246
+ var MAX_JSON_KEYS = 1e3;
22247
+ var boundedString = external_exports.string().max(MAX_CONTENT_LENGTH);
22248
+ function boundedJsonIssue(value, depth = 0) {
22249
+ if (depth > MAX_JSON_DEPTH) {
22250
+ return "JSON nesting exceeds the maximum depth";
22251
+ }
22252
+ if (typeof value === "string") {
22253
+ return value.length <= MAX_CONTENT_LENGTH ? null : "JSON string exceeds the maximum length";
22254
+ }
22255
+ if (typeof value === "number") {
22256
+ return Number.isFinite(value) ? null : "JSON number must be finite";
22257
+ }
22258
+ if (typeof value === "boolean" || value === null) {
22259
+ return null;
22260
+ }
22261
+ if (Array.isArray(value)) {
22262
+ if (value.length > MAX_COLLECTION_SIZE) {
22263
+ return "JSON array exceeds the maximum length";
22264
+ }
22265
+ for (const item of value) {
22266
+ const issue2 = boundedJsonIssue(item, depth + 1);
22267
+ if (issue2 !== null) {
22268
+ return issue2;
22269
+ }
22270
+ }
22271
+ return null;
22272
+ }
22273
+ if (typeof value === "object" && value !== void 0) {
22274
+ const entries = Object.entries(value);
22275
+ if (entries.length > MAX_JSON_KEYS) {
22276
+ return "JSON object exceeds the maximum key count";
22277
+ }
22278
+ for (const [key, item] of entries) {
22279
+ if (key.length > 255) {
22280
+ return "JSON key exceeds the maximum length";
22281
+ }
22282
+ const issue2 = boundedJsonIssue(item, depth + 1);
22283
+ if (issue2 !== null) {
22284
+ return issue2;
22285
+ }
22286
+ }
22287
+ return null;
22288
+ }
22289
+ return "Value is not bounded JSON";
22290
+ }
22291
+ var boundedJsonSchema = external_exports.unknown().superRefine((value, context) => {
22292
+ const issue2 = boundedJsonIssue(value);
22293
+ if (issue2 !== null) {
22294
+ context.addIssue({ code: "custom", message: issue2 });
22295
+ }
22296
+ });
22297
+ var toolCallLocationSchema = external_exports.object({
22298
+ line: external_exports.number().int().nonnegative().safe().nullable().optional(),
22299
+ path: boundedString
22300
+ }).readonly();
22301
+
22225
22302
  // ../mobius-sdk/src/protocol/session/interactions/index.ts
22226
22303
  var SESSION_PERMISSION_REQUESTED_KIND = "session.permission.requested";
22227
22304
  var SESSION_PERMISSION_RESPOND_KIND = "session.permission.respond";
@@ -22259,6 +22336,12 @@ var elicitationFieldSchema = external_exports.object({
22259
22336
  }).readonly();
22260
22337
  var sessionPermissionRequestedEventSchema = external_exports.object({
22261
22338
  commandId: identifierStringSchema,
22339
+ // Absent only for events from older runtimes and saved history.
22340
+ details: external_exports.object({
22341
+ cwd: external_exports.string().min(1).max(4096),
22342
+ rawInput: boundedJsonSchema.optional(),
22343
+ locations: external_exports.array(toolCallLocationSchema).max(1e3).readonly()
22344
+ }).readonly().optional(),
22262
22345
  interactionId: identifierStringSchema,
22263
22346
  kind: external_exports.literal(SESSION_PERMISSION_REQUESTED_KIND),
22264
22347
  options: external_exports.array(permissionOptionSchema).min(1).max(20).readonly(),
@@ -22322,6 +22405,8 @@ var SESSION_RESTORE_KIND = "session.restore";
22322
22405
  var SESSION_RESTORED_KIND = "session.restored";
22323
22406
  var SESSION_CLOSE_KIND = "session.close";
22324
22407
  var SESSION_CLOSED_KIND = "session.closed";
22408
+ var SESSION_CLOSE_NOTICE_KIND = "session.close.notice";
22409
+ var SESSION_CLOSED_ERROR_CODE = "session_closed";
22325
22410
  var SESSION_STATUS_CHANGED_KIND = "session.status.changed";
22326
22411
  var SESSION_COMMANDS_UPDATED_KIND = "session.commands.updated";
22327
22412
  var SESSION_INFO_UPDATED_KIND = "session.info.updated";
@@ -22427,6 +22512,11 @@ var sessionClosedEventSchema = external_exports.object({
22427
22512
  requestId: identifierStringSchema,
22428
22513
  sessionId: identifierStringSchema
22429
22514
  }).readonly();
22515
+ var sessionCloseNoticeEventSchema = external_exports.object({
22516
+ kind: external_exports.literal(SESSION_CLOSE_NOTICE_KIND),
22517
+ reason: external_exports.string().min(1).max(500),
22518
+ sessionId: identifierStringSchema
22519
+ }).readonly();
22430
22520
  var sessionCommandsUpdatedEventSchema = external_exports.object({
22431
22521
  commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
22432
22522
  kind: external_exports.literal(SESSION_COMMANDS_UPDATED_KIND),
@@ -22463,6 +22553,8 @@ var decodeSessionCloseCommand = (encoded) => decodeZodMessage(encoded, sessionCl
22463
22553
  var encodeSessionCloseCommand = (message) => encodeZodMessage(message, sessionCloseCommandSchema);
22464
22554
  var decodeSessionClosedEvent = (encoded) => decodeZodMessage(encoded, sessionClosedEventSchema);
22465
22555
  var encodeSessionClosedEvent = (message) => encodeZodMessage(message, sessionClosedEventSchema);
22556
+ var decodeSessionCloseNoticeEvent = (encoded) => decodeZodMessage(encoded, sessionCloseNoticeEventSchema);
22557
+ var encodeSessionCloseNoticeEvent = (message) => encodeZodMessage(message, sessionCloseNoticeEventSchema);
22466
22558
  var decodeSessionStatusChangedEvent = (encoded) => decodeZodMessage(encoded, sessionStatusChangedEventSchema);
22467
22559
  var encodeSessionStatusChangedEvent = (message) => encodeZodMessage(message, sessionStatusChangedEventSchema);
22468
22560
  var decodeSessionPrepareCommand = (encoded) => decodeZodMessage(encoded, sessionPrepareCommandSchema);
@@ -22706,86 +22798,35 @@ var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSch
22706
22798
 
22707
22799
  // ../mobius-sdk/src/protocol/session/observability/event-log.ts
22708
22800
  var MAX_EVENT_COUNT = 1e4;
22709
- var MAX_COLLECTION_SIZE = 1e3;
22710
- var MAX_CONTENT_LENGTH = 1e6;
22711
- var MAX_JSON_DEPTH = 16;
22712
- var MAX_JSON_KEYS = 1e3;
22801
+ var MAX_COLLECTION_SIZE2 = 1e3;
22802
+ var MAX_CONTENT_LENGTH2 = 1e6;
22713
22803
  var SESSION_EVENT_KIND = "session.event.v2";
22714
22804
  var SESSION_EVENT_BATCH_MAX_SIZE = 1e3;
22715
- var boundedString = external_exports.string().max(MAX_CONTENT_LENGTH);
22805
+ var boundedString2 = external_exports.string().max(MAX_CONTENT_LENGTH2);
22716
22806
  var shortString = external_exports.string().max(2048);
22717
22807
  var externalContentKeySchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
22718
- function boundedJsonIssue(value, depth = 0) {
22719
- if (depth > MAX_JSON_DEPTH) {
22720
- return "JSON nesting exceeds the maximum depth";
22721
- }
22722
- if (typeof value === "string") {
22723
- return value.length <= MAX_CONTENT_LENGTH ? null : "JSON string exceeds the maximum length";
22724
- }
22725
- if (typeof value === "number") {
22726
- return Number.isFinite(value) ? null : "JSON number must be finite";
22727
- }
22728
- if (typeof value === "boolean" || value === null) {
22729
- return null;
22730
- }
22731
- if (Array.isArray(value)) {
22732
- if (value.length > MAX_COLLECTION_SIZE) {
22733
- return "JSON array exceeds the maximum length";
22734
- }
22735
- for (const item of value) {
22736
- const issue2 = boundedJsonIssue(item, depth + 1);
22737
- if (issue2 !== null) {
22738
- return issue2;
22739
- }
22740
- }
22741
- return null;
22742
- }
22743
- if (typeof value === "object" && value !== void 0) {
22744
- const entries = Object.entries(value);
22745
- if (entries.length > MAX_JSON_KEYS) {
22746
- return "JSON object exceeds the maximum key count";
22747
- }
22748
- for (const [key, item] of entries) {
22749
- if (key.length > 255) {
22750
- return "JSON key exceeds the maximum length";
22751
- }
22752
- const issue2 = boundedJsonIssue(item, depth + 1);
22753
- if (issue2 !== null) {
22754
- return issue2;
22755
- }
22756
- }
22757
- return null;
22758
- }
22759
- return "Value is not bounded JSON";
22760
- }
22761
- var boundedJsonSchema = external_exports.unknown().superRefine((value, context) => {
22762
- const issue2 = boundedJsonIssue(value);
22763
- if (issue2 !== null) {
22764
- context.addIssue({ code: "custom", message: issue2 });
22765
- }
22766
- });
22767
22808
  var annotationsSchema = external_exports.object({
22768
22809
  audience: external_exports.array(external_exports.enum(["assistant", "user"])).max(2).readonly().nullable().optional(),
22769
22810
  lastModified: shortString.nullable().optional(),
22770
22811
  priority: external_exports.number().finite().nullable().optional()
22771
22812
  }).readonly();
22772
22813
  var contentFields = { annotations: annotationsSchema.nullable().optional() };
22773
- var textContentSchema = external_exports.object({ ...contentFields, text: boundedString, type: external_exports.literal("text") }).readonly();
22814
+ var textContentSchema = external_exports.object({ ...contentFields, text: boundedString2, type: external_exports.literal("text") }).readonly();
22774
22815
  var imageContentSchema = external_exports.object({
22775
22816
  ...contentFields,
22776
- data: boundedString,
22817
+ data: boundedString2,
22777
22818
  mimeType: shortString,
22778
22819
  type: external_exports.literal("image"),
22779
- uri: boundedString.nullable().optional()
22820
+ uri: boundedString2.nullable().optional()
22780
22821
  }).readonly();
22781
- var audioContentSchema = external_exports.object({ ...contentFields, data: boundedString, mimeType: shortString, type: external_exports.literal("audio") }).readonly();
22822
+ var audioContentSchema = external_exports.object({ ...contentFields, data: boundedString2, mimeType: shortString, type: external_exports.literal("audio") }).readonly();
22782
22823
  var externalImageContentSchema = external_exports.object({
22783
22824
  ...contentFields,
22784
22825
  byteLength: external_exports.number().int().positive().safe(),
22785
22826
  imageKey: externalContentKeySchema,
22786
22827
  mimeType: shortString,
22787
22828
  type: external_exports.literal("external_image"),
22788
- uri: boundedString.nullable().optional()
22829
+ uri: boundedString2.nullable().optional()
22789
22830
  }).readonly();
22790
22831
  var externalAudioContentSchema = external_exports.object({
22791
22832
  ...contentFields,
@@ -22801,27 +22842,27 @@ var externalResourceContentSchema = external_exports.object({
22801
22842
  mimeType: shortString.nullable().optional(),
22802
22843
  resourceKey: externalContentKeySchema,
22803
22844
  type: external_exports.literal("external_resource"),
22804
- uri: boundedString
22845
+ uri: boundedString2
22805
22846
  }).readonly();
22806
22847
  var resourceLinkSchema = external_exports.object({
22807
22848
  ...contentFields,
22808
- description: boundedString.nullable().optional(),
22849
+ description: boundedString2.nullable().optional(),
22809
22850
  mimeType: shortString.nullable().optional(),
22810
22851
  name: shortString,
22811
22852
  size: external_exports.number().int().nonnegative().safe().nullable().optional(),
22812
22853
  title: shortString.nullable().optional(),
22813
22854
  type: external_exports.literal("resource_link"),
22814
- uri: boundedString
22855
+ uri: boundedString2
22815
22856
  }).readonly();
22816
22857
  var textResourceSchema = external_exports.object({
22817
22858
  mimeType: shortString.nullable().optional(),
22818
- text: boundedString,
22819
- uri: boundedString
22859
+ text: boundedString2,
22860
+ uri: boundedString2
22820
22861
  }).readonly();
22821
22862
  var blobResourceSchema = external_exports.object({
22822
- blob: boundedString,
22863
+ blob: boundedString2,
22823
22864
  mimeType: shortString.nullable().optional(),
22824
- uri: boundedString
22865
+ uri: boundedString2
22825
22866
  }).readonly();
22826
22867
  var embeddedResourceSchema = external_exports.object({
22827
22868
  ...contentFields,
@@ -22841,17 +22882,13 @@ var contentBlockSchema = external_exports.discriminatedUnion("type", [
22841
22882
  var toolCallContentSchema = external_exports.discriminatedUnion("type", [
22842
22883
  external_exports.object({ content: contentBlockSchema, type: external_exports.literal("content") }).readonly(),
22843
22884
  external_exports.object({
22844
- newText: boundedString,
22845
- oldText: boundedString.nullable().optional(),
22846
- path: boundedString,
22885
+ newText: boundedString2,
22886
+ oldText: boundedString2.nullable().optional(),
22887
+ path: boundedString2,
22847
22888
  type: external_exports.literal("diff")
22848
22889
  }).readonly(),
22849
22890
  external_exports.object({ terminalId: shortString, type: external_exports.literal("terminal") }).readonly()
22850
22891
  ]);
22851
- var toolCallLocationSchema = external_exports.object({
22852
- line: external_exports.number().int().nonnegative().safe().nullable().optional(),
22853
- path: boundedString
22854
- }).readonly();
22855
22892
  var toolKindSchema = external_exports.enum([
22856
22893
  "read",
22857
22894
  "edit",
@@ -22866,51 +22903,51 @@ var toolKindSchema = external_exports.enum([
22866
22903
  ]);
22867
22904
  var toolStatusSchema = external_exports.enum(["pending", "in_progress", "completed", "failed"]);
22868
22905
  var toolPatchFields = {
22869
- content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE).readonly().nullable().optional(),
22906
+ content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
22870
22907
  kind: toolKindSchema.nullable().optional(),
22871
- locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE).readonly().nullable().optional(),
22908
+ locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
22872
22909
  name: shortString.nullable().optional(),
22873
22910
  rawInput: boundedJsonSchema.optional(),
22874
22911
  rawOutput: boundedJsonSchema.optional(),
22875
22912
  status: toolStatusSchema.nullable().optional(),
22876
- title: boundedString.nullable().optional()
22913
+ title: boundedString2.nullable().optional()
22877
22914
  };
22878
22915
  var planEntrySchema = external_exports.object({
22879
- content: boundedString,
22916
+ content: boundedString2,
22880
22917
  priority: external_exports.enum(["high", "medium", "low"]),
22881
22918
  status: external_exports.enum(["pending", "in_progress", "completed"])
22882
22919
  }).readonly();
22883
22920
  var planContentSchema = external_exports.discriminatedUnion("type", [
22884
22921
  external_exports.object({
22885
- entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE).readonly(),
22922
+ entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
22886
22923
  planId: shortString,
22887
22924
  type: external_exports.literal("items")
22888
22925
  }).readonly(),
22889
- external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString }).readonly(),
22926
+ external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString2 }).readonly(),
22890
22927
  external_exports.object({
22891
- content: boundedString,
22928
+ content: boundedString2,
22892
22929
  planId: shortString,
22893
22930
  type: external_exports.literal("markdown")
22894
22931
  }).readonly()
22895
22932
  ]);
22896
22933
  var commandSchema = external_exports.object({
22897
- description: boundedString,
22898
- input: external_exports.object({ hint: boundedString }).readonly().nullable().optional(),
22934
+ description: boundedString2,
22935
+ input: external_exports.object({ hint: boundedString2 }).readonly().nullable().optional(),
22899
22936
  name: shortString
22900
22937
  }).readonly();
22901
22938
  var configSelectOptionSchema = external_exports.object({
22902
- description: boundedString.nullable().optional(),
22939
+ description: boundedString2.nullable().optional(),
22903
22940
  name: shortString,
22904
22941
  value: shortString
22905
22942
  }).readonly();
22906
22943
  var configSelectGroupSchema = external_exports.object({
22907
22944
  group: shortString,
22908
22945
  name: shortString,
22909
- options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE).readonly()
22946
+ options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly()
22910
22947
  }).readonly();
22911
22948
  var configBaseFields = {
22912
22949
  category: shortString.nullable().optional(),
22913
- description: boundedString.nullable().optional(),
22950
+ description: boundedString2.nullable().optional(),
22914
22951
  id: shortString,
22915
22952
  name: shortString
22916
22953
  };
@@ -22919,8 +22956,8 @@ var sessionConfigOptionSchema2 = external_exports.discriminatedUnion("type", [
22919
22956
  ...configBaseFields,
22920
22957
  currentValue: shortString,
22921
22958
  options: external_exports.union([
22922
- external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE).readonly(),
22923
- external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE).readonly()
22959
+ external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly(),
22960
+ external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE2).readonly()
22924
22961
  ]),
22925
22962
  type: external_exports.literal("select")
22926
22963
  }).readonly(),
@@ -22935,26 +22972,26 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
22935
22972
  external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_message_chunk") }).readonly(),
22936
22973
  external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_thought_chunk") }).readonly(),
22937
22974
  external_exports.object({
22938
- content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE).readonly().optional(),
22975
+ content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
22939
22976
  kind: toolKindSchema.optional(),
22940
- locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE).readonly().optional(),
22977
+ locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
22941
22978
  name: shortString.nullable().optional(),
22942
22979
  rawInput: boundedJsonSchema.optional(),
22943
22980
  rawOutput: boundedJsonSchema.optional(),
22944
22981
  sessionUpdate: external_exports.literal("tool_call"),
22945
22982
  status: toolStatusSchema.optional(),
22946
- title: boundedString,
22983
+ title: boundedString2,
22947
22984
  toolCallId: shortString
22948
22985
  }).readonly(),
22949
22986
  external_exports.object({ ...toolPatchFields, sessionUpdate: external_exports.literal("tool_call_update"), toolCallId: shortString }).readonly(),
22950
22987
  external_exports.object({
22951
- entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE).readonly(),
22988
+ entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
22952
22989
  sessionUpdate: external_exports.literal("plan")
22953
22990
  }).readonly(),
22954
22991
  external_exports.object({ plan: planContentSchema, sessionUpdate: external_exports.literal("plan_update") }).readonly(),
22955
22992
  external_exports.object({ planId: shortString, sessionUpdate: external_exports.literal("plan_removed") }).readonly(),
22956
22993
  external_exports.object({
22957
- availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE).readonly(),
22994
+ availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE2).readonly(),
22958
22995
  sessionUpdate: external_exports.literal("available_commands_update")
22959
22996
  }).readonly(),
22960
22997
  external_exports.object({
@@ -22962,12 +22999,12 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
22962
22999
  sessionUpdate: external_exports.literal("current_mode_update")
22963
23000
  }).readonly(),
22964
23001
  external_exports.object({
22965
- configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE).readonly(),
23002
+ configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE2).readonly(),
22966
23003
  sessionUpdate: external_exports.literal("config_option_update")
22967
23004
  }).readonly(),
22968
23005
  external_exports.object({
22969
23006
  sessionUpdate: external_exports.literal("session_info_update"),
22970
- title: boundedString.nullable().optional(),
23007
+ title: boundedString2.nullable().optional(),
22971
23008
  updatedAt: shortString.nullable().optional()
22972
23009
  }).readonly(),
22973
23010
  external_exports.object({
@@ -22978,10 +23015,10 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
22978
23015
  }).readonly(),
22979
23016
  external_exports.object({
22980
23017
  compactionId: shortString,
22981
- error: boundedString.nullable().optional(),
23018
+ error: boundedString2.nullable().optional(),
22982
23019
  sessionUpdate: external_exports.literal("compaction_update"),
22983
23020
  status: shortString,
22984
- summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE).readonly().nullable().optional()
23021
+ summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional()
22985
23022
  }).readonly(),
22986
23023
  external_exports.object({
22987
23024
  compactionId: shortString,
@@ -23111,7 +23148,7 @@ var queuedPromptRequestEventLogSchema = external_exports.object({
23111
23148
  }).readonly();
23112
23149
  var nativeSessionEventsSchema = external_exports.object({
23113
23150
  events: sessionEventLogPageSchema,
23114
- queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE).readonly()
23151
+ queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE2).readonly()
23115
23152
  }).readonly();
23116
23153
  function inputValue(value) {
23117
23154
  if (typeof value !== "string") {
@@ -23353,6 +23390,11 @@ var serviceToDaemonSignatures = {
23353
23390
  encodeSessionConfigureCommand,
23354
23391
  decodeSessionConfigureCommand
23355
23392
  ),
23393
+ [SESSION_CONFIG_READ_KIND]: defineMessageSignature(
23394
+ SESSION_CONFIG_READ_KIND,
23395
+ encodeSessionConfigReadCommand,
23396
+ decodeSessionConfigReadCommand
23397
+ ),
23356
23398
  [SESSION_RENAME_KIND]: defineMessageSignature(
23357
23399
  SESSION_RENAME_KIND,
23358
23400
  encodeSessionRenameCommand,
@@ -23409,6 +23451,11 @@ var daemonToServiceSignatures = {
23409
23451
  encodeSessionClosedEvent,
23410
23452
  decodeSessionClosedEvent
23411
23453
  ),
23454
+ [SESSION_CLOSE_NOTICE_KIND]: defineMessageSignature(
23455
+ SESSION_CLOSE_NOTICE_KIND,
23456
+ encodeSessionCloseNoticeEvent,
23457
+ decodeSessionCloseNoticeEvent
23458
+ ),
23412
23459
  [SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
23413
23460
  SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
23414
23461
  encodeSessionPreviewHistoryPageLoaded,
@@ -23419,6 +23466,11 @@ var daemonToServiceSignatures = {
23419
23466
  encodeSessionConfigUpdatedEvent,
23420
23467
  decodeSessionConfigUpdatedEvent
23421
23468
  ),
23469
+ [SESSION_CONFIG_READ_RESULT_KIND]: defineMessageSignature(
23470
+ SESSION_CONFIG_READ_RESULT_KIND,
23471
+ encodeSessionConfigReadResult,
23472
+ decodeSessionConfigReadResult
23473
+ ),
23422
23474
  [SESSION_RENAMED_KIND]: defineMessageSignature(
23423
23475
  SESSION_RENAMED_KIND,
23424
23476
  encodeSessionRenamedEvent,
@@ -76857,6 +76909,7 @@ var ActiveExecutions = class {
76857
76909
  };
76858
76910
 
76859
76911
  // src/acp/agent-session.ts
76912
+ import { setImmediate as yieldToRuntime2 } from "node:timers/promises";
76860
76913
  import {
76861
76914
  methods as methods10,
76862
76915
  PROTOCOL_VERSION as PROTOCOL_VERSION3
@@ -77229,6 +77282,36 @@ var AgentUpdateStream = class {
77229
77282
  };
77230
77283
  };
77231
77284
 
77285
+ // src/acp/announced-tool-calls.ts
77286
+ var MAX_ANNOUNCED_TOOL_CALLS = 256;
77287
+ var AnnouncedToolCalls = class {
77288
+ #calls = /* @__PURE__ */ new Map();
77289
+ record = (update) => {
77290
+ const merged = this.describe(update);
77291
+ this.#calls.delete(update.toolCallId);
77292
+ this.#calls.set(update.toolCallId, merged);
77293
+ if (this.#calls.size > MAX_ANNOUNCED_TOOL_CALLS) {
77294
+ const oldest = this.#calls.keys().next();
77295
+ if (oldest.done !== true) {
77296
+ this.#calls.delete(oldest.value);
77297
+ }
77298
+ }
77299
+ };
77300
+ /** Applies a partial update to what was announced for the same tool call. */
77301
+ describe = (update) => {
77302
+ const announced = this.#calls.get(update.toolCallId);
77303
+ return {
77304
+ title: update.title ?? announced?.title,
77305
+ kind: update.kind ?? announced?.kind,
77306
+ rawInput: update.rawInput ?? announced?.rawInput,
77307
+ locations: update.locations ?? announced?.locations
77308
+ };
77309
+ };
77310
+ clear = () => {
77311
+ this.#calls.clear();
77312
+ };
77313
+ };
77314
+
77232
77315
  // src/acp/runtime-operations.ts
77233
77316
  var RuntimeOperations = class {
77234
77317
  #shutdown = new AbortController();
@@ -78015,15 +78098,21 @@ var AcpSessionInteractions = class {
78015
78098
  };
78016
78099
  signal.addEventListener("abort", abort, { once: true });
78017
78100
  try {
78101
+ const toolCall = this.#context.describeToolCall(request.toolCall);
78018
78102
  await this.#notifyPermissionRequested({
78019
78103
  commandId: this.#context.commandId(),
78104
+ details: {
78105
+ cwd: this.#context.cwd(),
78106
+ rawInput: toolCall.rawInput,
78107
+ locations: toolCall.locations ?? []
78108
+ },
78020
78109
  interactionId,
78021
78110
  kind: SESSION_PERMISSION_REQUESTED_KIND,
78022
78111
  options,
78023
78112
  sessionId: this.#context.sessionId(),
78024
- title: truncate2(request.toolCall.title ?? "Permission required", 500),
78113
+ title: truncate2(toolCall.title ?? "Permission required", 500),
78025
78114
  toolCallId: truncate2(request.toolCall.toolCallId, 255),
78026
- toolKind: truncate2(request.toolCall.kind ?? "other", 64)
78115
+ toolKind: truncate2(toolCall.kind ?? "other", 64)
78027
78116
  });
78028
78117
  return await pending.completion.promise;
78029
78118
  } finally {
@@ -83536,8 +83625,8 @@ var CachedAcpSessionEventStore = class {
83536
83625
  var AcpStoredSession = class {
83537
83626
  additionalDirectories;
83538
83627
  agentId;
83539
- cwd;
83540
83628
  configurations;
83629
+ cwd;
83541
83630
  nativeSessionId;
83542
83631
  prompted;
83543
83632
  sessionId;
@@ -83685,6 +83774,7 @@ var AgentSession = class _AgentSession {
83685
83774
  #connection;
83686
83775
  #contentExternalizer;
83687
83776
  #interactions;
83777
+ #announcedToolCalls = new AnnouncedToolCalls();
83688
83778
  #additionalDirectories;
83689
83779
  #agentId;
83690
83780
  #cwd;
@@ -83725,6 +83815,8 @@ var AgentSession = class _AgentSession {
83725
83815
  this.#store = store;
83726
83816
  this.#verifiedAgentVersion = agent.agentVersion;
83727
83817
  this.#interactions = new AcpSessionInteractions({
83818
+ cwd: () => this.#cwd,
83819
+ describeToolCall: this.#announcedToolCalls.describe,
83728
83820
  sessionId: () => this.#mobiusSessionId,
83729
83821
  commandId: () => this.#turn.commandId,
83730
83822
  assertNativeSession: (sessionId) => this.assertNativeSession(sessionId),
@@ -84448,6 +84540,7 @@ var AgentSession = class _AgentSession {
84448
84540
  throw failure2;
84449
84541
  } finally {
84450
84542
  this.#turn = new IdleAcpTurn();
84543
+ this.#announcedToolCalls.clear();
84451
84544
  }
84452
84545
  };
84453
84546
  steer = async (options) => {
@@ -84554,7 +84647,12 @@ var AgentSession = class _AgentSession {
84554
84647
  };
84555
84648
  respondPermission = (options) => this.#interactions.respondPermission(options);
84556
84649
  respondElicitation = (options) => this.#interactions.respondElicitation(options);
84557
- onPermission = (request, signal) => this.#interactions.onPermission(request, signal);
84650
+ onPermission = async (request, signal) => {
84651
+ await yieldToRuntime2(void 0, { signal });
84652
+ await this.#updates.drained();
84653
+ signal.throwIfAborted();
84654
+ return await this.#interactions.onPermission(request, signal);
84655
+ };
84558
84656
  onElicitation = (request, signal) => this.#interactions.onElicitation(request, signal);
84559
84657
  onElicitationComplete = (notification) => this.#interactions.onElicitationComplete(notification);
84560
84658
  onUpdate = (notification) => this.#updates.receive(notification);
@@ -84596,6 +84694,9 @@ var AgentSession = class _AgentSession {
84596
84694
  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")) {
84597
84695
  return;
84598
84696
  }
84697
+ if (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") {
84698
+ this.#announcedToolCalls.record(update);
84699
+ }
84599
84700
  if (update.sessionUpdate === "available_commands_update") {
84600
84701
  const commands = update.availableCommands.slice(0, 500).map((command) => ({
84601
84702
  description: truncate2(command.description, 500),
@@ -84959,10 +85060,13 @@ var AgentRuntimeManager = class {
84959
85060
  #agentSettingsObserver = new NullAcpSessionObserver();
84960
85061
  #nativeOperations = /* @__PURE__ */ new Set();
84961
85062
  #sessionClosures = /* @__PURE__ */ new Map();
85063
+ /** Sessions that were closed and not reopened since. Only a prepare or restore of the Session reopens it. */
85064
+ #closedSessions = /* @__PURE__ */ new Set();
84962
85065
  #store;
84963
85066
  #adapters;
84964
85067
  #sessionIdentity;
84965
85068
  #onSessionStatusChanged;
85069
+ #onSessionClosed;
84966
85070
  #contentExternalizer;
84967
85071
  #timer;
84968
85072
  #observer;
@@ -84972,6 +85076,7 @@ var AgentRuntimeManager = class {
84972
85076
  adapters,
84973
85077
  sessionIdentity,
84974
85078
  onSessionStatusChanged,
85079
+ onSessionClosed = () => void 0,
84975
85080
  contentExternalizer,
84976
85081
  timer,
84977
85082
  maxProcesses
@@ -84982,6 +85087,7 @@ var AgentRuntimeManager = class {
84982
85087
  this.#adapters = adapters;
84983
85088
  this.#sessionIdentity = sessionIdentity;
84984
85089
  this.#onSessionStatusChanged = onSessionStatusChanged;
85090
+ this.#onSessionClosed = onSessionClosed;
84985
85091
  this.#contentExternalizer = contentExternalizer;
84986
85092
  this.#timer = timer;
84987
85093
  this.#queryProcesses = new AgentQueryProcesses(this.#processes, contentExternalizer);
@@ -85019,6 +85125,34 @@ var AgentRuntimeManager = class {
85019
85125
  }
85020
85126
  }
85021
85127
  }
85128
+ /**
85129
+ * Stops the process of a Session that is being closed. Unlike retiring it, this keeps the stored Session,
85130
+ * so the closed Session stays listed with its title and settings and can be reopened.
85131
+ */
85132
+ async #stopSessionProcess(sessionId, runtime) {
85133
+ this.#executionProcesses.detach(sessionId, runtime);
85134
+ await this.#processes.retire(runtime, () => runtime.close());
85135
+ }
85136
+ #isKnownSession(sessionId) {
85137
+ return this.#executionProcesses.get(sessionId) !== void 0 || this.#executionProcesses.pending(sessionId) !== void 0 || this.#store.read(sessionId) instanceof FoundAcpStoredSession;
85138
+ }
85139
+ /**
85140
+ * Marks a Session closed and tells every client why, once for each closing. Clients show `reason` to their
85141
+ * users as is. Unknown Sessions have nothing to close.
85142
+ */
85143
+ #announceClosed(sessionId, reason) {
85144
+ if (this.#closedSessions.has(sessionId) || !this.#isKnownSession(sessionId)) {
85145
+ return;
85146
+ }
85147
+ this.#closedSessions.add(sessionId);
85148
+ this.#onSessionClosed({ kind: SESSION_CLOSE_NOTICE_KIND, reason, sessionId });
85149
+ }
85150
+ /** A closed Session fails the operations that would silently reopen it, so a client learns that its view is stale. */
85151
+ #assertOpen(sessionId) {
85152
+ if (this.#closedSessions.has(sessionId)) {
85153
+ throw new AcpExecutionError("The Session is closed; reopen it to continue", {}, SESSION_CLOSED_ERROR_CODE);
85154
+ }
85155
+ }
85022
85156
  async #startRetainedSessionProcess(options, start) {
85023
85157
  const runtime = await this.#processes.startRetained(options.signal, start, this.#retention(options.sessionId));
85024
85158
  this.#executionProcesses.retain(options.sessionId, runtime);
@@ -85112,12 +85246,17 @@ var AgentRuntimeManager = class {
85112
85246
  return runtime;
85113
85247
  });
85114
85248
  }
85115
- async #prepareSession(options, recovery, metrics = unmeasuredOperationMetrics) {
85249
+ async #prepareSession(options, recovery, closed, metrics = unmeasuredOperationMetrics) {
85116
85250
  return await this.#operations.run(options, async (options2) => {
85117
85251
  const closing = this.#sessionClosures.get(options2.sessionId);
85118
85252
  if (closing !== void 0) {
85119
85253
  await waitForSharedOperation(closing, options2.signal);
85120
85254
  }
85255
+ if (closed === "reopen") {
85256
+ this.#closedSessions.delete(options2.sessionId);
85257
+ } else {
85258
+ this.#assertOpen(options2.sessionId);
85259
+ }
85121
85260
  const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
85122
85261
  if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
85123
85262
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -85138,7 +85277,7 @@ var AgentRuntimeManager = class {
85138
85277
  }
85139
85278
  return runtime2.prepared();
85140
85279
  }
85141
- return await this.#prepareSession(options2, recovery, metrics);
85280
+ return await this.#prepareSession(options2, recovery, closed, metrics);
85142
85281
  }
85143
85282
  const existing = this.#executionProcesses.get(options2.sessionId);
85144
85283
  if (existing !== void 0) {
@@ -85166,8 +85305,8 @@ var AgentRuntimeManager = class {
85166
85305
  return runtime.prepared();
85167
85306
  });
85168
85307
  }
85169
- prepareSession = async (options, metrics = unmeasuredOperationMetrics) => await this.#prepareSession(options, { kind: "interactive-only" }, metrics);
85170
- restoreSession = async (options, metrics = unmeasuredOperationMetrics) => await this.#prepareSession(options, { kind: "history-required" }, metrics);
85308
+ prepareSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "interactive-only" }, closed, metrics);
85309
+ restoreSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "history-required" }, closed, metrics);
85171
85310
  /**
85172
85311
  * Opens a short-lived native ACP session only to read the local Agent's
85173
85312
  * authoritative settings. Its identity and store are private to this
@@ -85238,6 +85377,7 @@ var AgentRuntimeManager = class {
85238
85377
  });
85239
85378
  });
85240
85379
  prepareExecutionSession = async (options) => this.#operations.run(options, async (options2) => {
85380
+ this.#assertOpen(options2.sessionId);
85241
85381
  const pending = this.#executionProcesses.pending(options2.sessionId);
85242
85382
  if (pending !== void 0) {
85243
85383
  await waitForSharedOperation(pending, options2.signal);
@@ -85275,6 +85415,7 @@ var AgentRuntimeManager = class {
85275
85415
  });
85276
85416
  });
85277
85417
  renameSession = async (sessionId, title2, signal) => await this.#operations.run({ sessionId, signal }, async (options) => {
85418
+ this.#assertOpen(options.sessionId);
85278
85419
  const runtime = this.#executionProcesses.get(options.sessionId);
85279
85420
  if (runtime !== void 0) {
85280
85421
  return await runtime.renameSession(title2, options.signal);
@@ -85350,6 +85491,7 @@ var AgentRuntimeManager = class {
85350
85491
  }
85351
85492
  });
85352
85493
  runPrompt = async (options) => this.#operations.run(options, async (options2) => {
85494
+ this.#assertOpen(options2.sessionId);
85353
85495
  const stored = this.#store.read(options2.sessionId);
85354
85496
  if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
85355
85497
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -85418,6 +85560,7 @@ var AgentRuntimeManager = class {
85418
85560
  }
85419
85561
  });
85420
85562
  respondPermission = async (options) => {
85563
+ this.#assertOpen(options.sessionId);
85421
85564
  const runtime = this.#executionProcesses.get(options.sessionId);
85422
85565
  if (runtime === void 0) {
85423
85566
  throw new AcpExecutionError("The permission request session is unavailable", {}, "session_not_found");
@@ -85425,6 +85568,7 @@ var AgentRuntimeManager = class {
85425
85568
  await runtime.respondPermission(options);
85426
85569
  };
85427
85570
  respondElicitation = async (options) => {
85571
+ this.#assertOpen(options.sessionId);
85428
85572
  const runtime = this.#executionProcesses.get(options.sessionId);
85429
85573
  if (runtime === void 0) {
85430
85574
  throw new AcpExecutionError("The elicitation request session is unavailable", {}, "session_not_found");
@@ -85437,11 +85581,12 @@ var AgentRuntimeManager = class {
85437
85581
  await waitForSharedOperation(existing, options.signal);
85438
85582
  return;
85439
85583
  }
85584
+ this.#announceClosed(options.sessionId, "This Session was closed on request.");
85440
85585
  const release = (async () => {
85441
85586
  const pending = this.#executionProcesses.pending(options.sessionId);
85442
85587
  const runtime = pending === void 0 ? this.#executionProcesses.get(options.sessionId) : await pending;
85443
85588
  if (runtime !== void 0) {
85444
- await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.close());
85589
+ await this.#stopSessionProcess(options.sessionId, runtime);
85445
85590
  }
85446
85591
  })();
85447
85592
  const deadline = Promise.withResolvers();
@@ -85523,6 +85668,7 @@ var AgentRuntimeManager = class {
85523
85668
  });
85524
85669
  });
85525
85670
  ensureSession = async (options) => this.#operations.run(options, async (options2) => {
85671
+ this.#assertOpen(options2.sessionId);
85526
85672
  const existing = this.#executionProcesses.get(options2.sessionId);
85527
85673
  if (existing !== void 0) {
85528
85674
  if (!existing.belongsTo(options2.agent.id, options2.cwd, options2.additionalDirectories)) {
@@ -85601,6 +85747,7 @@ var AgentRuntimeManager = class {
85601
85747
  const existing = linked[0];
85602
85748
  if (origin.kind === "import" && existing !== void 0) {
85603
85749
  return await this.#executionProcesses.use(existing.sessionId, async () => {
85750
+ this.#closedSessions.delete(existing.sessionId);
85604
85751
  const runtime = await this.ensureSession({
85605
85752
  ...options2,
85606
85753
  sessionId: existing.sessionId
@@ -87120,7 +87267,7 @@ import { WebSocket as WebSocket7 } from "undici";
87120
87267
  // package.json
87121
87268
  var package_default = {
87122
87269
  name: "@moxt-ai/mobius",
87123
- version: "0.0.276",
87270
+ version: "0.0.279",
87124
87271
  description: "Mobius CLI for pairing and running local AI agent services.",
87125
87272
  type: "module",
87126
87273
  bin: {
@@ -89011,7 +89158,7 @@ async function resolveCatalogAgent(config2, agentId, signal) {
89011
89158
  const agent = config2.catalog.find(agentId);
89012
89159
  return config2.resolveAgent === void 0 ? agent : await config2.resolveAgent(agent, signal);
89013
89160
  }
89014
- async function prepareSession(command, recovery, config2, directories, sessions, metrics, signal) {
89161
+ async function prepareSession(command, recovery, closed, config2, directories, sessions, metrics, signal) {
89015
89162
  return await metrics.measure("prepare-total", async () => {
89016
89163
  const resolved = await metrics.measure(
89017
89164
  "workspace-resolve",
@@ -89031,7 +89178,7 @@ async function prepareSession(command, recovery, config2, directories, sessions,
89031
89178
  sessionId: command.sessionId,
89032
89179
  signal
89033
89180
  };
89034
- const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
89181
+ 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);
89035
89182
  const configuration = command.configuration;
89036
89183
  const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
89037
89184
  "configuration",
@@ -89087,6 +89234,7 @@ async function executeSessionPrepare(socket, command, config2, directories, sess
89087
89234
  const readyEvent = await prepareSession(
89088
89235
  command,
89089
89236
  { kind: "interactive-only" },
89237
+ "reopen",
89090
89238
  config2,
89091
89239
  directories,
89092
89240
  sessions,
@@ -89133,6 +89281,7 @@ async function executeSessionRestore(socket, command, config2, directories, sess
89133
89281
  sessionState: "provisioned"
89134
89282
  },
89135
89283
  { kind: "history-required" },
89284
+ "reopen",
89136
89285
  config2,
89137
89286
  directories,
89138
89287
  sessions,
@@ -89278,6 +89427,76 @@ var sessionRenameCommand = {
89278
89427
  void executeSessionRename(context.socket, message, context.sessions, context.signal);
89279
89428
  }
89280
89429
  };
89430
+ async function executeSessionConfigRead(socket, command, config2, directories, sessions, nativeSessions, diagnostics, signal) {
89431
+ const metrics = new AccumulatingOperationMetrics();
89432
+ try {
89433
+ const entry = await metrics.measure("session-lookup", async () => {
89434
+ const [found] = await nativeSessions.querySessions([command.sessionId], signal);
89435
+ if (found === void 0) {
89436
+ throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
89437
+ }
89438
+ return found;
89439
+ });
89440
+ const ready = await prepareSession(
89441
+ {
89442
+ additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
89443
+ agentId: entry.agentId,
89444
+ bindingId: config2.bindingId,
89445
+ directoryId: entry.directoryId,
89446
+ kind: "session.prepare",
89447
+ requestId: command.requestId,
89448
+ sessionId: command.sessionId,
89449
+ sessionState: "provisioned"
89450
+ },
89451
+ // A settings read must not force history loading: Agents without
89452
+ // load support would fail even with a live process whose config is
89453
+ // already readable, and prepare reuses the current configuration.
89454
+ { kind: "interactive-only" },
89455
+ // Reading settings must not reopen a Session that a client closed.
89456
+ "keep-closed",
89457
+ config2,
89458
+ directories,
89459
+ sessions,
89460
+ metrics,
89461
+ signal
89462
+ );
89463
+ send(socket, {
89464
+ configOptions: ready.configOptions,
89465
+ kind: SESSION_CONFIG_READ_RESULT_KIND,
89466
+ requestId: command.requestId,
89467
+ sessionId: command.sessionId
89468
+ });
89469
+ } catch (error62) {
89470
+ diagnostics.daemonDiagnostic(
89471
+ "session_config_read_failed",
89472
+ command.requestId,
89473
+ {
89474
+ code: operationErrorCode(error62),
89475
+ sessionId: command.sessionId
89476
+ },
89477
+ error62
89478
+ );
89479
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
89480
+ }
89481
+ }
89482
+ var sessionConfigReadCommand = {
89483
+ kind: SESSION_CONFIG_READ_KIND,
89484
+ handle: (context, message) => {
89485
+ if (message.kind !== SESSION_CONFIG_READ_KIND) {
89486
+ throw new Error("Command kind mismatch");
89487
+ }
89488
+ void executeSessionConfigRead(
89489
+ context.socket,
89490
+ message,
89491
+ context.config,
89492
+ context.directories,
89493
+ context.sessions,
89494
+ context.nativeSessions,
89495
+ context.diagnostics,
89496
+ context.signal
89497
+ );
89498
+ }
89499
+ };
89281
89500
 
89282
89501
  // src/runtime/command/registry/history.ts
89283
89502
  function isAgentReasoning(event) {
@@ -90151,6 +90370,7 @@ function createCommandRegistry(context) {
90151
90370
  workspaceListCommand,
90152
90371
  sessionPrepareCommand,
90153
90372
  sessionConfigureCommand,
90373
+ sessionConfigReadCommand,
90154
90374
  sessionRenameCommand,
90155
90375
  sessionRestoreCommand,
90156
90376
  permissionRespondCommand,
@@ -90469,6 +90689,35 @@ function closeRelaySocket(socket, code, reason) {
90469
90689
  }
90470
90690
  }
90471
90691
  }
90692
+ function readCommandCorrelation(encoded) {
90693
+ let value;
90694
+ try {
90695
+ value = JSON.parse(encoded);
90696
+ } catch {
90697
+ return { requestId: "unsupported", sessionId: "" };
90698
+ }
90699
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
90700
+ return { requestId: "unsupported", sessionId: "" };
90701
+ }
90702
+ const requestId = Reflect.get(value, "requestId");
90703
+ const sessionId = Reflect.get(value, "sessionId");
90704
+ return {
90705
+ requestId: typeof requestId === "string" && isIdentifier(requestId) ? requestId : "unsupported",
90706
+ sessionId: typeof sessionId === "string" && isIdentifier(sessionId) ? sessionId : ""
90707
+ };
90708
+ }
90709
+ function rejectUnsupportedCommand(socket, correlation, rejection) {
90710
+ if (socket.readyState !== WebSocket7.OPEN) {
90711
+ return;
90712
+ }
90713
+ send(socket, {
90714
+ code: rejection.code,
90715
+ kind: SESSION_OPERATION_FAILED_KIND,
90716
+ message: "The Relay sent a command this daemon does not support",
90717
+ requestId: correlation.requestId,
90718
+ sessionId: correlation.sessionId
90719
+ });
90720
+ }
90472
90721
  async function runRelayConnection({
90473
90722
  config: config2,
90474
90723
  directories,
@@ -90626,11 +90875,23 @@ async function runRelayConnection({
90626
90875
  commands.dispatch(message);
90627
90876
  } catch (error62) {
90628
90877
  if (error62 instanceof UnsupportedProtocolMessageKindError) {
90629
- console.warn("Mobius daemon skipped an unsupported Relay message", {
90878
+ const correlation = readCommandCorrelation(encoded);
90879
+ console.warn("Mobius daemon rejected an unsupported Relay command", {
90630
90880
  code: error62.code,
90631
90881
  direction: error62.direction,
90632
90882
  messageKind: error62.messageKind
90633
90883
  });
90884
+ diagnostics.daemonDiagnostic(
90885
+ "relay_command_unsupported",
90886
+ correlation.requestId,
90887
+ {
90888
+ code: error62.code,
90889
+ direction: error62.direction,
90890
+ messageKind: error62.messageKind
90891
+ },
90892
+ error62
90893
+ );
90894
+ rejectUnsupportedCommand(socket, correlation, error62);
90634
90895
  return;
90635
90896
  }
90636
90897
  console.error("Mobius daemon rejected a message", error62);
@@ -90691,6 +90952,7 @@ var RuntimeSessionEventPublisher = class {
90691
90952
  };
90692
90953
  publishStatus = (event) => this.#send(event);
90693
90954
  publishInfo = (event) => this.#send(event);
90955
+ publishClosed = (event) => this.#send(event);
90694
90956
  #send = (message) => {
90695
90957
  const socket = this.#socket;
90696
90958
  if (socket === null || socket.readyState !== WebSocket8.OPEN) {
@@ -91438,6 +91700,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
91438
91700
  adapters: harnessAdapters,
91439
91701
  sessionIdentity: "native",
91440
91702
  onSessionStatusChanged: publisher.publishStatus,
91703
+ onSessionClosed: publisher.publishClosed,
91441
91704
  contentExternalizer: new AcpContentExternalizer(externalContent),
91442
91705
  timer,
91443
91706
  maxProcesses: resolveMaxAcpProcesses(config2.localContext.environment)