@moxt-ai/mobius 0.0.277 → 0.0.280

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 (49) 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 +289 -172
  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/diagnostics.d.ts +1 -1
  25. package/dist/runtime/relay/diagnostics.d.ts.map +1 -1
  26. package/dist/runtime/relay/diagnostics.js +1 -2
  27. package/dist/runtime/relay/diagnostics.js.map +1 -1
  28. package/dist/runtime/relay/liveness.d.ts +3 -3
  29. package/dist/runtime/relay/liveness.d.ts.map +1 -1
  30. package/dist/runtime/relay/liveness.js +11 -19
  31. package/dist/runtime/relay/liveness.js.map +1 -1
  32. package/dist/runtime/relay/run-relay-connection.js +3 -3
  33. package/dist/runtime/relay/run-relay-connection.js.map +1 -1
  34. package/dist/runtime/relay/session-event-publisher.d.ts +2 -1
  35. package/dist/runtime/relay/session-event-publisher.d.ts.map +1 -1
  36. package/dist/runtime/relay/session-event-publisher.js +1 -0
  37. package/dist/runtime/relay/session-event-publisher.js.map +1 -1
  38. package/dist/runtime/run.d.ts.map +1 -1
  39. package/dist/runtime/run.js +1 -0
  40. package/dist/runtime/run.js.map +1 -1
  41. package/dist/runtime/sessions.d.ts +8 -0
  42. package/dist/runtime/sessions.d.ts.map +1 -1
  43. package/dist/runtime/workspace/workspace-directory.d.ts +1 -1
  44. package/dist/runtime/workspace/workspace-directory.d.ts.map +1 -1
  45. package/dist/runtime/workspace/workspace-directory.js +6 -2
  46. package/dist/runtime/workspace/workspace-directory.js.map +1 -1
  47. package/dist/runtime.js +289 -172
  48. package/dist/runtime.js.map +4 -4
  49. package/package.json +2 -2
package/dist/runtime.js CHANGED
@@ -21750,8 +21750,17 @@ var decodeRuntimeDiagnosticsResult = (raw) => runtimeDiagnosticsResultSchema.par
21750
21750
  var encodeRuntimeDiagnosticsRequest = (value) => JSON.stringify(runtimeDiagnosticsRequestSchema.parse(value));
21751
21751
  var encodeRuntimeDiagnosticsResult = (value) => JSON.stringify(runtimeDiagnosticsResultSchema.parse(value));
21752
21752
 
21753
+ // ../mobius-sdk/src/protocol/shared/directory.ts
21754
+ var MAX_WORKSPACE_PATH_LENGTH = 4096;
21755
+ var MAX_DIRECTORY_IDENTIFIER_LENGTH = "path-".length + MAX_WORKSPACE_PATH_LENGTH * 4;
21756
+ var DIRECTORY_IDENTIFIER_PATTERN = new RegExp(
21757
+ `^[a-zA-Z0-9][a-zA-Z0-9_-]{0,${MAX_DIRECTORY_IDENTIFIER_LENGTH - 1}}$`,
21758
+ "u"
21759
+ );
21760
+ var DIRECTORY_IDENTIFIER = external_exports.string().min(1).max(MAX_DIRECTORY_IDENTIFIER_LENGTH).regex(DIRECTORY_IDENTIFIER_PATTERN);
21761
+ var isDirectoryIdentifier = (value) => typeof value === "string" && value.length <= MAX_DIRECTORY_IDENTIFIER_LENGTH && DIRECTORY_IDENTIFIER_PATTERN.test(value);
21762
+
21753
21763
  // ../mobius-sdk/src/protocol/shared/message-codec.ts
21754
- var DIRECTORY_IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
21755
21764
  var ProtocolMessageError = class extends Error {
21756
21765
  code = "invalid_protocol_message";
21757
21766
  constructor(message, options = {}) {
@@ -21809,7 +21818,7 @@ function readDirectoryIdentifiers(value, key, maximumCount) {
21809
21818
  const identifiers = [];
21810
21819
  const unique = /* @__PURE__ */ new Set();
21811
21820
  for (const candidate of field) {
21812
- if (typeof candidate !== "string" || !DIRECTORY_IDENTIFIER_PATTERN.test(candidate) || unique.has(candidate)) {
21821
+ if (!isDirectoryIdentifier(candidate) || unique.has(candidate)) {
21813
21822
  throw new ProtocolMessageError(`Invalid directory in field: ${key}`);
21814
21823
  }
21815
21824
  unique.add(candidate);
@@ -21825,8 +21834,8 @@ function readIdentifier(value, key) {
21825
21834
  }
21826
21835
  }
21827
21836
  function readDirectoryIdentifier(value, key) {
21828
- const field = readString(value, key, 2048);
21829
- if (!DIRECTORY_IDENTIFIER_PATTERN.test(field)) {
21837
+ const field = readString(value, key, MAX_DIRECTORY_IDENTIFIER_LENGTH);
21838
+ if (!isDirectoryIdentifier(field)) {
21830
21839
  throw new ProtocolMessageError(`Invalid directory identifier field: ${key}`);
21831
21840
  }
21832
21841
  return field;
@@ -21867,6 +21876,8 @@ var RUNTIME_HEARTBEAT_KIND = "runtime.heartbeat";
21867
21876
  var RUNTIME_HEARTBEAT_ACK_KIND = "runtime.heartbeat.ack";
21868
21877
  var RUNTIME_PING_KIND = "runtime.ping";
21869
21878
  var RUNTIME_PONG_KIND = "runtime.pong";
21879
+ var RUNTIME_HEARTBEAT_MESSAGE = `{"kind":"${RUNTIME_HEARTBEAT_KIND}"}`;
21880
+ var RUNTIME_HEARTBEAT_ACK_MESSAGE = `{"kind":"${RUNTIME_HEARTBEAT_ACK_KIND}"}`;
21870
21881
  function decodeRuntimeLivenessReadyEvent(encoded) {
21871
21882
  const value = parseJson(encoded);
21872
21883
  assertKind(value, RUNTIME_LIVENESS_READY_KIND);
@@ -21875,18 +21886,12 @@ function decodeRuntimeLivenessReadyEvent(encoded) {
21875
21886
  function decodeRuntimeHeartbeatEvent(encoded) {
21876
21887
  const value = parseJson(encoded);
21877
21888
  assertKind(value, RUNTIME_HEARTBEAT_KIND);
21878
- return {
21879
- heartbeatId: readIdentifier(value, "heartbeatId"),
21880
- kind: RUNTIME_HEARTBEAT_KIND
21881
- };
21889
+ return "heartbeatId" in value ? { heartbeatId: readIdentifier(value, "heartbeatId"), kind: RUNTIME_HEARTBEAT_KIND } : { kind: RUNTIME_HEARTBEAT_KIND };
21882
21890
  }
21883
21891
  function decodeRuntimeHeartbeatAckEvent(encoded) {
21884
21892
  const value = parseJson(encoded);
21885
21893
  assertKind(value, RUNTIME_HEARTBEAT_ACK_KIND);
21886
- return {
21887
- heartbeatId: readIdentifier(value, "heartbeatId"),
21888
- kind: RUNTIME_HEARTBEAT_ACK_KIND
21889
- };
21894
+ return "heartbeatId" in value ? { heartbeatId: readIdentifier(value, "heartbeatId"), kind: RUNTIME_HEARTBEAT_ACK_KIND } : { kind: RUNTIME_HEARTBEAT_ACK_KIND };
21890
21895
  }
21891
21896
  function decodeRuntimePingCommand(encoded) {
21892
21897
  const value = parseJson(encoded);
@@ -21902,10 +21907,12 @@ function encodeRuntimeLivenessReadyEvent(message) {
21902
21907
  return JSON.stringify(decodeRuntimeLivenessReadyEvent(JSON.stringify(message)));
21903
21908
  }
21904
21909
  function encodeRuntimeHeartbeatEvent(message) {
21905
- return JSON.stringify(decodeRuntimeHeartbeatEvent(JSON.stringify(message)));
21910
+ const decoded = decodeRuntimeHeartbeatEvent(JSON.stringify(message));
21911
+ return "heartbeatId" in decoded ? JSON.stringify(decoded) : RUNTIME_HEARTBEAT_MESSAGE;
21906
21912
  }
21907
21913
  function encodeRuntimeHeartbeatAckEvent(message) {
21908
- return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
21914
+ const decoded = decodeRuntimeHeartbeatAckEvent(JSON.stringify(message));
21915
+ return "heartbeatId" in decoded ? JSON.stringify(decoded) : RUNTIME_HEARTBEAT_ACK_MESSAGE;
21909
21916
  }
21910
21917
  function encodeRuntimePingCommand(message) {
21911
21918
  return JSON.stringify(decodeRuntimePingCommand(JSON.stringify(message)));
@@ -21944,8 +21951,6 @@ var decodeRuntimeUpgradeResult = (raw) => runtimeUpgradeResultSchema.parse(JSON.
21944
21951
  var encodeRuntimeUpgradeResult = (value) => JSON.stringify(runtimeUpgradeResultSchema.parse(value));
21945
21952
 
21946
21953
  // ../mobius-sdk/src/protocol/session/shared/index.ts
21947
- var DIRECTORY_IDENTIFIER_PATTERN2 = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
21948
- var DIRECTORY_IDENTIFIER = external_exports.string().min(1).max(2048).regex(DIRECTORY_IDENTIFIER_PATTERN2);
21949
21954
  var SHORT_TEXT = external_exports.string().max(500);
21950
21955
  var workspaceEntrySchema = external_exports.object({
21951
21956
  directoryId: DIRECTORY_IDENTIFIER,
@@ -22239,6 +22244,66 @@ var encodeFileEndEvent = (message) => encodeZodMessage(message, fileEndEventSche
22239
22244
  var decodeFileFailedEvent = (encoded) => decodeZodMessage(encoded, fileFailedEventSchema);
22240
22245
  var encodeFileFailedEvent = (message) => encodeZodMessage(message, fileFailedEventSchema);
22241
22246
 
22247
+ // ../mobius-sdk/src/protocol/shared/tool-input.ts
22248
+ var MAX_CONTENT_LENGTH = 1e6;
22249
+ var MAX_COLLECTION_SIZE = 1e3;
22250
+ var MAX_JSON_DEPTH = 16;
22251
+ var MAX_JSON_KEYS = 1e3;
22252
+ var boundedString = external_exports.string().max(MAX_CONTENT_LENGTH);
22253
+ function boundedJsonIssue(value, depth = 0) {
22254
+ if (depth > MAX_JSON_DEPTH) {
22255
+ return "JSON nesting exceeds the maximum depth";
22256
+ }
22257
+ if (typeof value === "string") {
22258
+ return value.length <= MAX_CONTENT_LENGTH ? null : "JSON string exceeds the maximum length";
22259
+ }
22260
+ if (typeof value === "number") {
22261
+ return Number.isFinite(value) ? null : "JSON number must be finite";
22262
+ }
22263
+ if (typeof value === "boolean" || value === null) {
22264
+ return null;
22265
+ }
22266
+ if (Array.isArray(value)) {
22267
+ if (value.length > MAX_COLLECTION_SIZE) {
22268
+ return "JSON array exceeds the maximum length";
22269
+ }
22270
+ for (const item of value) {
22271
+ const issue2 = boundedJsonIssue(item, depth + 1);
22272
+ if (issue2 !== null) {
22273
+ return issue2;
22274
+ }
22275
+ }
22276
+ return null;
22277
+ }
22278
+ if (typeof value === "object" && value !== void 0) {
22279
+ const entries = Object.entries(value);
22280
+ if (entries.length > MAX_JSON_KEYS) {
22281
+ return "JSON object exceeds the maximum key count";
22282
+ }
22283
+ for (const [key, item] of entries) {
22284
+ if (key.length > 255) {
22285
+ return "JSON key exceeds the maximum length";
22286
+ }
22287
+ const issue2 = boundedJsonIssue(item, depth + 1);
22288
+ if (issue2 !== null) {
22289
+ return issue2;
22290
+ }
22291
+ }
22292
+ return null;
22293
+ }
22294
+ return "Value is not bounded JSON";
22295
+ }
22296
+ var boundedJsonSchema = external_exports.unknown().superRefine((value, context) => {
22297
+ const issue2 = boundedJsonIssue(value);
22298
+ if (issue2 !== null) {
22299
+ context.addIssue({ code: "custom", message: issue2 });
22300
+ }
22301
+ });
22302
+ var toolCallLocationSchema = external_exports.object({
22303
+ line: external_exports.number().int().nonnegative().safe().nullable().optional(),
22304
+ path: boundedString
22305
+ }).readonly();
22306
+
22242
22307
  // ../mobius-sdk/src/protocol/session/interactions/index.ts
22243
22308
  var SESSION_PERMISSION_REQUESTED_KIND = "session.permission.requested";
22244
22309
  var SESSION_PERMISSION_RESPOND_KIND = "session.permission.respond";
@@ -22276,6 +22341,12 @@ var elicitationFieldSchema = external_exports.object({
22276
22341
  }).readonly();
22277
22342
  var sessionPermissionRequestedEventSchema = external_exports.object({
22278
22343
  commandId: identifierStringSchema,
22344
+ // Absent only for events from older runtimes and saved history.
22345
+ details: external_exports.object({
22346
+ cwd: external_exports.string().min(1).max(4096),
22347
+ rawInput: boundedJsonSchema.optional(),
22348
+ locations: external_exports.array(toolCallLocationSchema).max(1e3).readonly()
22349
+ }).readonly().optional(),
22279
22350
  interactionId: identifierStringSchema,
22280
22351
  kind: external_exports.literal(SESSION_PERMISSION_REQUESTED_KIND),
22281
22352
  options: external_exports.array(permissionOptionSchema).min(1).max(20).readonly(),
@@ -22339,6 +22410,8 @@ var SESSION_RESTORE_KIND = "session.restore";
22339
22410
  var SESSION_RESTORED_KIND = "session.restored";
22340
22411
  var SESSION_CLOSE_KIND = "session.close";
22341
22412
  var SESSION_CLOSED_KIND = "session.closed";
22413
+ var SESSION_CLOSE_NOTICE_KIND = "session.close.notice";
22414
+ var SESSION_CLOSED_ERROR_CODE = "session_closed";
22342
22415
  var SESSION_STATUS_CHANGED_KIND = "session.status.changed";
22343
22416
  var SESSION_COMMANDS_UPDATED_KIND = "session.commands.updated";
22344
22417
  var SESSION_INFO_UPDATED_KIND = "session.info.updated";
@@ -22352,7 +22425,7 @@ var sessionMetadataSchema = external_exports.object({
22352
22425
  additionalDirectories: external_exports.array(workspaceEntrySchema).max(16).readonly(),
22353
22426
  agentId: identifierStringSchema,
22354
22427
  directoryId: DIRECTORY_IDENTIFIER,
22355
- directoryLabel: external_exports.string().min(1).max(2048),
22428
+ directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
22356
22429
  prompted: external_exports.boolean(),
22357
22430
  sessionId: identifierStringSchema,
22358
22431
  status: sessionStatusSchema.default({ kind: "idle" }),
@@ -22426,7 +22499,7 @@ var sessionReadyEventSchema = external_exports.object({
22426
22499
  commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
22427
22500
  configOptions: sessionConfigOptionsSchema,
22428
22501
  directoryId: DIRECTORY_IDENTIFIER,
22429
- directoryLabel: external_exports.string().min(1).max(2048),
22502
+ directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
22430
22503
  kind: external_exports.literal(SESSION_READY_KIND),
22431
22504
  requestId: identifierStringSchema,
22432
22505
  restored: external_exports.boolean(),
@@ -22444,6 +22517,11 @@ var sessionClosedEventSchema = external_exports.object({
22444
22517
  requestId: identifierStringSchema,
22445
22518
  sessionId: identifierStringSchema
22446
22519
  }).readonly();
22520
+ var sessionCloseNoticeEventSchema = external_exports.object({
22521
+ kind: external_exports.literal(SESSION_CLOSE_NOTICE_KIND),
22522
+ reason: external_exports.string().min(1).max(500),
22523
+ sessionId: identifierStringSchema
22524
+ }).readonly();
22447
22525
  var sessionCommandsUpdatedEventSchema = external_exports.object({
22448
22526
  commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
22449
22527
  kind: external_exports.literal(SESSION_COMMANDS_UPDATED_KIND),
@@ -22480,6 +22558,8 @@ var decodeSessionCloseCommand = (encoded) => decodeZodMessage(encoded, sessionCl
22480
22558
  var encodeSessionCloseCommand = (message) => encodeZodMessage(message, sessionCloseCommandSchema);
22481
22559
  var decodeSessionClosedEvent = (encoded) => decodeZodMessage(encoded, sessionClosedEventSchema);
22482
22560
  var encodeSessionClosedEvent = (message) => encodeZodMessage(message, sessionClosedEventSchema);
22561
+ var decodeSessionCloseNoticeEvent = (encoded) => decodeZodMessage(encoded, sessionCloseNoticeEventSchema);
22562
+ var encodeSessionCloseNoticeEvent = (message) => encodeZodMessage(message, sessionCloseNoticeEventSchema);
22483
22563
  var decodeSessionStatusChangedEvent = (encoded) => decodeZodMessage(encoded, sessionStatusChangedEventSchema);
22484
22564
  var encodeSessionStatusChangedEvent = (message) => encodeZodMessage(message, sessionStatusChangedEventSchema);
22485
22565
  var decodeSessionPrepareCommand = (encoded) => decodeZodMessage(encoded, sessionPrepareCommandSchema);
@@ -22607,7 +22687,6 @@ var NATIVE_SESSION_RESULT_KIND = "native.session.result";
22607
22687
  var NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
22608
22688
  var SESSION_HISTORY_CHARACTER_LIMIT = 256e3;
22609
22689
  var SESSION_HISTORY_MESSAGE_LIMIT = 1e3;
22610
- var directoryId = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
22611
22690
  var envelope = {
22612
22691
  requestId: identifierStringSchema,
22613
22692
  sessionId: identifierStringSchema
@@ -22622,10 +22701,10 @@ var activeTurnSnapshotSchema = external_exports.object({
22622
22701
  var identity = {
22623
22702
  ...envelope,
22624
22703
  kind: external_exports.literal(NATIVE_SESSION_REQUEST_KIND),
22625
- additionalDirectoryIds: external_exports.array(directoryId).max(16).readonly(),
22704
+ additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
22626
22705
  agentId: identifierStringSchema,
22627
22706
  bindingId: identifierStringSchema,
22628
- directoryId
22707
+ directoryId: DIRECTORY_IDENTIFIER
22629
22708
  };
22630
22709
  var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
22631
22710
  external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
@@ -22662,10 +22741,10 @@ var nativeSessionEntrySchema = external_exports.object({
22662
22741
  mobiusSessionIds: external_exports.array(identifierStringSchema).max(500).readonly(),
22663
22742
  nativeSessionId: identifierStringSchema,
22664
22743
  title: external_exports.string().max(500),
22665
- directoryId,
22666
- directoryLabel: external_exports.string().min(1).max(2048),
22744
+ directoryId: DIRECTORY_IDENTIFIER,
22745
+ directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
22667
22746
  updatedAt: external_exports.iso.datetime({ offset: true }).nullable(),
22668
- additionalDirectories: external_exports.array(external_exports.object({ directoryId, name: external_exports.string().min(1).max(255) }).readonly()).max(16).readonly()
22747
+ additionalDirectories: external_exports.array(external_exports.object({ directoryId: DIRECTORY_IDENTIFIER, name: external_exports.string().min(1).max(255) }).readonly()).max(16).readonly()
22669
22748
  }).readonly();
22670
22749
  var resultEnvelope = {
22671
22750
  ...envelope,
@@ -22723,86 +22802,35 @@ var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSch
22723
22802
 
22724
22803
  // ../mobius-sdk/src/protocol/session/observability/event-log.ts
22725
22804
  var MAX_EVENT_COUNT = 1e4;
22726
- var MAX_COLLECTION_SIZE = 1e3;
22727
- var MAX_CONTENT_LENGTH = 1e6;
22728
- var MAX_JSON_DEPTH = 16;
22729
- var MAX_JSON_KEYS = 1e3;
22805
+ var MAX_COLLECTION_SIZE2 = 1e3;
22806
+ var MAX_CONTENT_LENGTH2 = 1e6;
22730
22807
  var SESSION_EVENT_KIND = "session.event.v2";
22731
22808
  var SESSION_EVENT_BATCH_MAX_SIZE = 1e3;
22732
- var boundedString = external_exports.string().max(MAX_CONTENT_LENGTH);
22809
+ var boundedString2 = external_exports.string().max(MAX_CONTENT_LENGTH2);
22733
22810
  var shortString = external_exports.string().max(2048);
22734
22811
  var externalContentKeySchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
22735
- function boundedJsonIssue(value, depth = 0) {
22736
- if (depth > MAX_JSON_DEPTH) {
22737
- return "JSON nesting exceeds the maximum depth";
22738
- }
22739
- if (typeof value === "string") {
22740
- return value.length <= MAX_CONTENT_LENGTH ? null : "JSON string exceeds the maximum length";
22741
- }
22742
- if (typeof value === "number") {
22743
- return Number.isFinite(value) ? null : "JSON number must be finite";
22744
- }
22745
- if (typeof value === "boolean" || value === null) {
22746
- return null;
22747
- }
22748
- if (Array.isArray(value)) {
22749
- if (value.length > MAX_COLLECTION_SIZE) {
22750
- return "JSON array exceeds the maximum length";
22751
- }
22752
- for (const item of value) {
22753
- const issue2 = boundedJsonIssue(item, depth + 1);
22754
- if (issue2 !== null) {
22755
- return issue2;
22756
- }
22757
- }
22758
- return null;
22759
- }
22760
- if (typeof value === "object" && value !== void 0) {
22761
- const entries = Object.entries(value);
22762
- if (entries.length > MAX_JSON_KEYS) {
22763
- return "JSON object exceeds the maximum key count";
22764
- }
22765
- for (const [key, item] of entries) {
22766
- if (key.length > 255) {
22767
- return "JSON key exceeds the maximum length";
22768
- }
22769
- const issue2 = boundedJsonIssue(item, depth + 1);
22770
- if (issue2 !== null) {
22771
- return issue2;
22772
- }
22773
- }
22774
- return null;
22775
- }
22776
- return "Value is not bounded JSON";
22777
- }
22778
- var boundedJsonSchema = external_exports.unknown().superRefine((value, context) => {
22779
- const issue2 = boundedJsonIssue(value);
22780
- if (issue2 !== null) {
22781
- context.addIssue({ code: "custom", message: issue2 });
22782
- }
22783
- });
22784
22812
  var annotationsSchema = external_exports.object({
22785
22813
  audience: external_exports.array(external_exports.enum(["assistant", "user"])).max(2).readonly().nullable().optional(),
22786
22814
  lastModified: shortString.nullable().optional(),
22787
22815
  priority: external_exports.number().finite().nullable().optional()
22788
22816
  }).readonly();
22789
22817
  var contentFields = { annotations: annotationsSchema.nullable().optional() };
22790
- var textContentSchema = external_exports.object({ ...contentFields, text: boundedString, type: external_exports.literal("text") }).readonly();
22818
+ var textContentSchema = external_exports.object({ ...contentFields, text: boundedString2, type: external_exports.literal("text") }).readonly();
22791
22819
  var imageContentSchema = external_exports.object({
22792
22820
  ...contentFields,
22793
- data: boundedString,
22821
+ data: boundedString2,
22794
22822
  mimeType: shortString,
22795
22823
  type: external_exports.literal("image"),
22796
- uri: boundedString.nullable().optional()
22824
+ uri: boundedString2.nullable().optional()
22797
22825
  }).readonly();
22798
- var audioContentSchema = external_exports.object({ ...contentFields, data: boundedString, mimeType: shortString, type: external_exports.literal("audio") }).readonly();
22826
+ var audioContentSchema = external_exports.object({ ...contentFields, data: boundedString2, mimeType: shortString, type: external_exports.literal("audio") }).readonly();
22799
22827
  var externalImageContentSchema = external_exports.object({
22800
22828
  ...contentFields,
22801
22829
  byteLength: external_exports.number().int().positive().safe(),
22802
22830
  imageKey: externalContentKeySchema,
22803
22831
  mimeType: shortString,
22804
22832
  type: external_exports.literal("external_image"),
22805
- uri: boundedString.nullable().optional()
22833
+ uri: boundedString2.nullable().optional()
22806
22834
  }).readonly();
22807
22835
  var externalAudioContentSchema = external_exports.object({
22808
22836
  ...contentFields,
@@ -22818,27 +22846,27 @@ var externalResourceContentSchema = external_exports.object({
22818
22846
  mimeType: shortString.nullable().optional(),
22819
22847
  resourceKey: externalContentKeySchema,
22820
22848
  type: external_exports.literal("external_resource"),
22821
- uri: boundedString
22849
+ uri: boundedString2
22822
22850
  }).readonly();
22823
22851
  var resourceLinkSchema = external_exports.object({
22824
22852
  ...contentFields,
22825
- description: boundedString.nullable().optional(),
22853
+ description: boundedString2.nullable().optional(),
22826
22854
  mimeType: shortString.nullable().optional(),
22827
22855
  name: shortString,
22828
22856
  size: external_exports.number().int().nonnegative().safe().nullable().optional(),
22829
22857
  title: shortString.nullable().optional(),
22830
22858
  type: external_exports.literal("resource_link"),
22831
- uri: boundedString
22859
+ uri: boundedString2
22832
22860
  }).readonly();
22833
22861
  var textResourceSchema = external_exports.object({
22834
22862
  mimeType: shortString.nullable().optional(),
22835
- text: boundedString,
22836
- uri: boundedString
22863
+ text: boundedString2,
22864
+ uri: boundedString2
22837
22865
  }).readonly();
22838
22866
  var blobResourceSchema = external_exports.object({
22839
- blob: boundedString,
22867
+ blob: boundedString2,
22840
22868
  mimeType: shortString.nullable().optional(),
22841
- uri: boundedString
22869
+ uri: boundedString2
22842
22870
  }).readonly();
22843
22871
  var embeddedResourceSchema = external_exports.object({
22844
22872
  ...contentFields,
@@ -22858,17 +22886,13 @@ var contentBlockSchema = external_exports.discriminatedUnion("type", [
22858
22886
  var toolCallContentSchema = external_exports.discriminatedUnion("type", [
22859
22887
  external_exports.object({ content: contentBlockSchema, type: external_exports.literal("content") }).readonly(),
22860
22888
  external_exports.object({
22861
- newText: boundedString,
22862
- oldText: boundedString.nullable().optional(),
22863
- path: boundedString,
22889
+ newText: boundedString2,
22890
+ oldText: boundedString2.nullable().optional(),
22891
+ path: boundedString2,
22864
22892
  type: external_exports.literal("diff")
22865
22893
  }).readonly(),
22866
22894
  external_exports.object({ terminalId: shortString, type: external_exports.literal("terminal") }).readonly()
22867
22895
  ]);
22868
- var toolCallLocationSchema = external_exports.object({
22869
- line: external_exports.number().int().nonnegative().safe().nullable().optional(),
22870
- path: boundedString
22871
- }).readonly();
22872
22896
  var toolKindSchema = external_exports.enum([
22873
22897
  "read",
22874
22898
  "edit",
@@ -22883,51 +22907,51 @@ var toolKindSchema = external_exports.enum([
22883
22907
  ]);
22884
22908
  var toolStatusSchema = external_exports.enum(["pending", "in_progress", "completed", "failed"]);
22885
22909
  var toolPatchFields = {
22886
- content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE).readonly().nullable().optional(),
22910
+ content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
22887
22911
  kind: toolKindSchema.nullable().optional(),
22888
- locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE).readonly().nullable().optional(),
22912
+ locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional(),
22889
22913
  name: shortString.nullable().optional(),
22890
22914
  rawInput: boundedJsonSchema.optional(),
22891
22915
  rawOutput: boundedJsonSchema.optional(),
22892
22916
  status: toolStatusSchema.nullable().optional(),
22893
- title: boundedString.nullable().optional()
22917
+ title: boundedString2.nullable().optional()
22894
22918
  };
22895
22919
  var planEntrySchema = external_exports.object({
22896
- content: boundedString,
22920
+ content: boundedString2,
22897
22921
  priority: external_exports.enum(["high", "medium", "low"]),
22898
22922
  status: external_exports.enum(["pending", "in_progress", "completed"])
22899
22923
  }).readonly();
22900
22924
  var planContentSchema = external_exports.discriminatedUnion("type", [
22901
22925
  external_exports.object({
22902
- entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE).readonly(),
22926
+ entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
22903
22927
  planId: shortString,
22904
22928
  type: external_exports.literal("items")
22905
22929
  }).readonly(),
22906
- external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString }).readonly(),
22930
+ external_exports.object({ planId: shortString, type: external_exports.literal("file"), uri: boundedString2 }).readonly(),
22907
22931
  external_exports.object({
22908
- content: boundedString,
22932
+ content: boundedString2,
22909
22933
  planId: shortString,
22910
22934
  type: external_exports.literal("markdown")
22911
22935
  }).readonly()
22912
22936
  ]);
22913
22937
  var commandSchema = external_exports.object({
22914
- description: boundedString,
22915
- input: external_exports.object({ hint: boundedString }).readonly().nullable().optional(),
22938
+ description: boundedString2,
22939
+ input: external_exports.object({ hint: boundedString2 }).readonly().nullable().optional(),
22916
22940
  name: shortString
22917
22941
  }).readonly();
22918
22942
  var configSelectOptionSchema = external_exports.object({
22919
- description: boundedString.nullable().optional(),
22943
+ description: boundedString2.nullable().optional(),
22920
22944
  name: shortString,
22921
22945
  value: shortString
22922
22946
  }).readonly();
22923
22947
  var configSelectGroupSchema = external_exports.object({
22924
22948
  group: shortString,
22925
22949
  name: shortString,
22926
- options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE).readonly()
22950
+ options: external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly()
22927
22951
  }).readonly();
22928
22952
  var configBaseFields = {
22929
22953
  category: shortString.nullable().optional(),
22930
- description: boundedString.nullable().optional(),
22954
+ description: boundedString2.nullable().optional(),
22931
22955
  id: shortString,
22932
22956
  name: shortString
22933
22957
  };
@@ -22936,8 +22960,8 @@ var sessionConfigOptionSchema2 = external_exports.discriminatedUnion("type", [
22936
22960
  ...configBaseFields,
22937
22961
  currentValue: shortString,
22938
22962
  options: external_exports.union([
22939
- external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE).readonly(),
22940
- external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE).readonly()
22963
+ external_exports.array(configSelectOptionSchema).max(MAX_COLLECTION_SIZE2).readonly(),
22964
+ external_exports.array(configSelectGroupSchema).max(MAX_COLLECTION_SIZE2).readonly()
22941
22965
  ]),
22942
22966
  type: external_exports.literal("select")
22943
22967
  }).readonly(),
@@ -22952,26 +22976,26 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
22952
22976
  external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_message_chunk") }).readonly(),
22953
22977
  external_exports.object({ ...contentChunkFields, sessionUpdate: external_exports.literal("agent_thought_chunk") }).readonly(),
22954
22978
  external_exports.object({
22955
- content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE).readonly().optional(),
22979
+ content: external_exports.array(toolCallContentSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
22956
22980
  kind: toolKindSchema.optional(),
22957
- locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE).readonly().optional(),
22981
+ locations: external_exports.array(toolCallLocationSchema).max(MAX_COLLECTION_SIZE2).readonly().optional(),
22958
22982
  name: shortString.nullable().optional(),
22959
22983
  rawInput: boundedJsonSchema.optional(),
22960
22984
  rawOutput: boundedJsonSchema.optional(),
22961
22985
  sessionUpdate: external_exports.literal("tool_call"),
22962
22986
  status: toolStatusSchema.optional(),
22963
- title: boundedString,
22987
+ title: boundedString2,
22964
22988
  toolCallId: shortString
22965
22989
  }).readonly(),
22966
22990
  external_exports.object({ ...toolPatchFields, sessionUpdate: external_exports.literal("tool_call_update"), toolCallId: shortString }).readonly(),
22967
22991
  external_exports.object({
22968
- entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE).readonly(),
22992
+ entries: external_exports.array(planEntrySchema).max(MAX_COLLECTION_SIZE2).readonly(),
22969
22993
  sessionUpdate: external_exports.literal("plan")
22970
22994
  }).readonly(),
22971
22995
  external_exports.object({ plan: planContentSchema, sessionUpdate: external_exports.literal("plan_update") }).readonly(),
22972
22996
  external_exports.object({ planId: shortString, sessionUpdate: external_exports.literal("plan_removed") }).readonly(),
22973
22997
  external_exports.object({
22974
- availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE).readonly(),
22998
+ availableCommands: external_exports.array(commandSchema).max(MAX_COLLECTION_SIZE2).readonly(),
22975
22999
  sessionUpdate: external_exports.literal("available_commands_update")
22976
23000
  }).readonly(),
22977
23001
  external_exports.object({
@@ -22979,12 +23003,12 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
22979
23003
  sessionUpdate: external_exports.literal("current_mode_update")
22980
23004
  }).readonly(),
22981
23005
  external_exports.object({
22982
- configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE).readonly(),
23006
+ configOptions: external_exports.array(sessionConfigOptionSchema2).max(MAX_COLLECTION_SIZE2).readonly(),
22983
23007
  sessionUpdate: external_exports.literal("config_option_update")
22984
23008
  }).readonly(),
22985
23009
  external_exports.object({
22986
23010
  sessionUpdate: external_exports.literal("session_info_update"),
22987
- title: boundedString.nullable().optional(),
23011
+ title: boundedString2.nullable().optional(),
22988
23012
  updatedAt: shortString.nullable().optional()
22989
23013
  }).readonly(),
22990
23014
  external_exports.object({
@@ -22995,10 +23019,10 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
22995
23019
  }).readonly(),
22996
23020
  external_exports.object({
22997
23021
  compactionId: shortString,
22998
- error: boundedString.nullable().optional(),
23022
+ error: boundedString2.nullable().optional(),
22999
23023
  sessionUpdate: external_exports.literal("compaction_update"),
23000
23024
  status: shortString,
23001
- summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE).readonly().nullable().optional()
23025
+ summary: external_exports.array(contentBlockSchema).max(MAX_COLLECTION_SIZE2).readonly().nullable().optional()
23002
23026
  }).readonly(),
23003
23027
  external_exports.object({
23004
23028
  compactionId: shortString,
@@ -23009,8 +23033,8 @@ var acpSessionUpdateSchema = external_exports.discriminatedUnion("sessionUpdate"
23009
23033
  var lifecycleBase = { commandId: identifierStringSchema };
23010
23034
  var promptExecutionContextSchema = external_exports.object({
23011
23035
  agentId: identifierStringSchema,
23012
- directoryId: shortString,
23013
- additionalDirectoryIds: external_exports.array(identifierStringSchema).max(16).readonly()
23036
+ directoryId: DIRECTORY_IDENTIFIER,
23037
+ additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly()
23014
23038
  }).readonly();
23015
23039
  var lifecycleMetadataSchema = external_exports.discriminatedUnion("kind", [
23016
23040
  external_exports.object({ kind: external_exports.literal("session.queue.changed") }).readonly(),
@@ -23128,7 +23152,7 @@ var queuedPromptRequestEventLogSchema = external_exports.object({
23128
23152
  }).readonly();
23129
23153
  var nativeSessionEventsSchema = external_exports.object({
23130
23154
  events: sessionEventLogPageSchema,
23131
- queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE).readonly()
23155
+ queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE2).readonly()
23132
23156
  }).readonly();
23133
23157
  function inputValue(value) {
23134
23158
  if (typeof value !== "string") {
@@ -23162,7 +23186,6 @@ var SESSION_HISTORY_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
23162
23186
  var SESSION_HISTORY_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
23163
23187
  var SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND = "session.preview-history.page.load";
23164
23188
  var SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND = "session.preview-history.page.loaded";
23165
- var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
23166
23189
  var pageRequestFields = {
23167
23190
  cursor: external_exports.string().min(1).max(512).nullable(),
23168
23191
  eventLimit: external_exports.number().int().min(1).max(1e4),
@@ -23173,10 +23196,10 @@ var pageRequestFields = {
23173
23196
  var sessionHistoryPageLoadSchema = external_exports.object({ ...pageRequestFields, kind: external_exports.literal(SESSION_HISTORY_PAGE_LOAD_KIND) }).readonly();
23174
23197
  var sessionPreviewHistoryPageLoadSchema = external_exports.object({
23175
23198
  ...pageRequestFields,
23176
- additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
23199
+ additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
23177
23200
  agentId: identifierStringSchema,
23178
23201
  bindingId: identifierStringSchema,
23179
- directoryId: directoryIdentifier,
23202
+ directoryId: DIRECTORY_IDENTIFIER,
23180
23203
  kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND)
23181
23204
  }).readonly();
23182
23205
  var pageLoadedFields = {
@@ -23285,10 +23308,10 @@ var workspaceListCommandSchema = external_exports.object({
23285
23308
  var workspaceEntriesEventSchema = external_exports.object({
23286
23309
  bindingId: identifierStringSchema,
23287
23310
  directoryId: DIRECTORY_IDENTIFIER,
23288
- directoryLabel: external_exports.string().min(1).max(2048),
23311
+ directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
23289
23312
  entries: external_exports.array(workspaceEntrySchema).max(500).readonly(),
23290
23313
  kind: external_exports.literal(WORKSPACE_ENTRIES_KIND),
23291
- parentDirectoryId: external_exports.string().max(2048),
23314
+ parentDirectoryId: external_exports.string().max(MAX_DIRECTORY_IDENTIFIER_LENGTH),
23292
23315
  requestId: identifierStringSchema
23293
23316
  }).readonly();
23294
23317
  var decodeWorkspaceListCommand = (encoded) => decodeZodMessage(encoded, workspaceListCommandSchema);
@@ -23431,6 +23454,11 @@ var daemonToServiceSignatures = {
23431
23454
  encodeSessionClosedEvent,
23432
23455
  decodeSessionClosedEvent
23433
23456
  ),
23457
+ [SESSION_CLOSE_NOTICE_KIND]: defineMessageSignature(
23458
+ SESSION_CLOSE_NOTICE_KIND,
23459
+ encodeSessionCloseNoticeEvent,
23460
+ decodeSessionCloseNoticeEvent
23461
+ ),
23434
23462
  [SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
23435
23463
  SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
23436
23464
  encodeSessionPreviewHistoryPageLoaded,
@@ -76884,6 +76912,7 @@ var ActiveExecutions = class {
76884
76912
  };
76885
76913
 
76886
76914
  // src/acp/agent-session.ts
76915
+ import { setImmediate as yieldToRuntime2 } from "node:timers/promises";
76887
76916
  import {
76888
76917
  methods as methods10,
76889
76918
  PROTOCOL_VERSION as PROTOCOL_VERSION3
@@ -77256,6 +77285,36 @@ var AgentUpdateStream = class {
77256
77285
  };
77257
77286
  };
77258
77287
 
77288
+ // src/acp/announced-tool-calls.ts
77289
+ var MAX_ANNOUNCED_TOOL_CALLS = 256;
77290
+ var AnnouncedToolCalls = class {
77291
+ #calls = /* @__PURE__ */ new Map();
77292
+ record = (update) => {
77293
+ const merged = this.describe(update);
77294
+ this.#calls.delete(update.toolCallId);
77295
+ this.#calls.set(update.toolCallId, merged);
77296
+ if (this.#calls.size > MAX_ANNOUNCED_TOOL_CALLS) {
77297
+ const oldest = this.#calls.keys().next();
77298
+ if (oldest.done !== true) {
77299
+ this.#calls.delete(oldest.value);
77300
+ }
77301
+ }
77302
+ };
77303
+ /** Applies a partial update to what was announced for the same tool call. */
77304
+ describe = (update) => {
77305
+ const announced = this.#calls.get(update.toolCallId);
77306
+ return {
77307
+ title: update.title ?? announced?.title,
77308
+ kind: update.kind ?? announced?.kind,
77309
+ rawInput: update.rawInput ?? announced?.rawInput,
77310
+ locations: update.locations ?? announced?.locations
77311
+ };
77312
+ };
77313
+ clear = () => {
77314
+ this.#calls.clear();
77315
+ };
77316
+ };
77317
+
77259
77318
  // src/acp/runtime-operations.ts
77260
77319
  var RuntimeOperations = class {
77261
77320
  #shutdown = new AbortController();
@@ -78042,15 +78101,21 @@ var AcpSessionInteractions = class {
78042
78101
  };
78043
78102
  signal.addEventListener("abort", abort, { once: true });
78044
78103
  try {
78104
+ const toolCall = this.#context.describeToolCall(request.toolCall);
78045
78105
  await this.#notifyPermissionRequested({
78046
78106
  commandId: this.#context.commandId(),
78107
+ details: {
78108
+ cwd: this.#context.cwd(),
78109
+ rawInput: toolCall.rawInput,
78110
+ locations: toolCall.locations ?? []
78111
+ },
78047
78112
  interactionId,
78048
78113
  kind: SESSION_PERMISSION_REQUESTED_KIND,
78049
78114
  options,
78050
78115
  sessionId: this.#context.sessionId(),
78051
- title: truncate2(request.toolCall.title ?? "Permission required", 500),
78116
+ title: truncate2(toolCall.title ?? "Permission required", 500),
78052
78117
  toolCallId: truncate2(request.toolCall.toolCallId, 255),
78053
- toolKind: truncate2(request.toolCall.kind ?? "other", 64)
78118
+ toolKind: truncate2(toolCall.kind ?? "other", 64)
78054
78119
  });
78055
78120
  return await pending.completion.promise;
78056
78121
  } finally {
@@ -83712,6 +83777,7 @@ var AgentSession = class _AgentSession {
83712
83777
  #connection;
83713
83778
  #contentExternalizer;
83714
83779
  #interactions;
83780
+ #announcedToolCalls = new AnnouncedToolCalls();
83715
83781
  #additionalDirectories;
83716
83782
  #agentId;
83717
83783
  #cwd;
@@ -83752,6 +83818,8 @@ var AgentSession = class _AgentSession {
83752
83818
  this.#store = store;
83753
83819
  this.#verifiedAgentVersion = agent.agentVersion;
83754
83820
  this.#interactions = new AcpSessionInteractions({
83821
+ cwd: () => this.#cwd,
83822
+ describeToolCall: this.#announcedToolCalls.describe,
83755
83823
  sessionId: () => this.#mobiusSessionId,
83756
83824
  commandId: () => this.#turn.commandId,
83757
83825
  assertNativeSession: (sessionId) => this.assertNativeSession(sessionId),
@@ -84475,6 +84543,7 @@ var AgentSession = class _AgentSession {
84475
84543
  throw failure2;
84476
84544
  } finally {
84477
84545
  this.#turn = new IdleAcpTurn();
84546
+ this.#announcedToolCalls.clear();
84478
84547
  }
84479
84548
  };
84480
84549
  steer = async (options) => {
@@ -84581,7 +84650,12 @@ var AgentSession = class _AgentSession {
84581
84650
  };
84582
84651
  respondPermission = (options) => this.#interactions.respondPermission(options);
84583
84652
  respondElicitation = (options) => this.#interactions.respondElicitation(options);
84584
- onPermission = (request, signal) => this.#interactions.onPermission(request, signal);
84653
+ onPermission = async (request, signal) => {
84654
+ await yieldToRuntime2(void 0, { signal });
84655
+ await this.#updates.drained();
84656
+ signal.throwIfAborted();
84657
+ return await this.#interactions.onPermission(request, signal);
84658
+ };
84585
84659
  onElicitation = (request, signal) => this.#interactions.onElicitation(request, signal);
84586
84660
  onElicitationComplete = (notification) => this.#interactions.onElicitationComplete(notification);
84587
84661
  onUpdate = (notification) => this.#updates.receive(notification);
@@ -84623,6 +84697,9 @@ var AgentSession = class _AgentSession {
84623
84697
  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")) {
84624
84698
  return;
84625
84699
  }
84700
+ if (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") {
84701
+ this.#announcedToolCalls.record(update);
84702
+ }
84626
84703
  if (update.sessionUpdate === "available_commands_update") {
84627
84704
  const commands = update.availableCommands.slice(0, 500).map((command) => ({
84628
84705
  description: truncate2(command.description, 500),
@@ -84986,10 +85063,13 @@ var AgentRuntimeManager = class {
84986
85063
  #agentSettingsObserver = new NullAcpSessionObserver();
84987
85064
  #nativeOperations = /* @__PURE__ */ new Set();
84988
85065
  #sessionClosures = /* @__PURE__ */ new Map();
85066
+ /** Sessions that were closed and not reopened since. Only a prepare or restore of the Session reopens it. */
85067
+ #closedSessions = /* @__PURE__ */ new Set();
84989
85068
  #store;
84990
85069
  #adapters;
84991
85070
  #sessionIdentity;
84992
85071
  #onSessionStatusChanged;
85072
+ #onSessionClosed;
84993
85073
  #contentExternalizer;
84994
85074
  #timer;
84995
85075
  #observer;
@@ -84999,6 +85079,7 @@ var AgentRuntimeManager = class {
84999
85079
  adapters,
85000
85080
  sessionIdentity,
85001
85081
  onSessionStatusChanged,
85082
+ onSessionClosed = () => void 0,
85002
85083
  contentExternalizer,
85003
85084
  timer,
85004
85085
  maxProcesses
@@ -85009,6 +85090,7 @@ var AgentRuntimeManager = class {
85009
85090
  this.#adapters = adapters;
85010
85091
  this.#sessionIdentity = sessionIdentity;
85011
85092
  this.#onSessionStatusChanged = onSessionStatusChanged;
85093
+ this.#onSessionClosed = onSessionClosed;
85012
85094
  this.#contentExternalizer = contentExternalizer;
85013
85095
  this.#timer = timer;
85014
85096
  this.#queryProcesses = new AgentQueryProcesses(this.#processes, contentExternalizer);
@@ -85046,6 +85128,34 @@ var AgentRuntimeManager = class {
85046
85128
  }
85047
85129
  }
85048
85130
  }
85131
+ /**
85132
+ * Stops the process of a Session that is being closed. Unlike retiring it, this keeps the stored Session,
85133
+ * so the closed Session stays listed with its title and settings and can be reopened.
85134
+ */
85135
+ async #stopSessionProcess(sessionId, runtime) {
85136
+ this.#executionProcesses.detach(sessionId, runtime);
85137
+ await this.#processes.retire(runtime, () => runtime.close());
85138
+ }
85139
+ #isKnownSession(sessionId) {
85140
+ return this.#executionProcesses.get(sessionId) !== void 0 || this.#executionProcesses.pending(sessionId) !== void 0 || this.#store.read(sessionId) instanceof FoundAcpStoredSession;
85141
+ }
85142
+ /**
85143
+ * Marks a Session closed and tells every client why, once for each closing. Clients show `reason` to their
85144
+ * users as is. Unknown Sessions have nothing to close.
85145
+ */
85146
+ #announceClosed(sessionId, reason) {
85147
+ if (this.#closedSessions.has(sessionId) || !this.#isKnownSession(sessionId)) {
85148
+ return;
85149
+ }
85150
+ this.#closedSessions.add(sessionId);
85151
+ this.#onSessionClosed({ kind: SESSION_CLOSE_NOTICE_KIND, reason, sessionId });
85152
+ }
85153
+ /** A closed Session fails the operations that would silently reopen it, so a client learns that its view is stale. */
85154
+ #assertOpen(sessionId) {
85155
+ if (this.#closedSessions.has(sessionId)) {
85156
+ throw new AcpExecutionError("The Session is closed; reopen it to continue", {}, SESSION_CLOSED_ERROR_CODE);
85157
+ }
85158
+ }
85049
85159
  async #startRetainedSessionProcess(options, start) {
85050
85160
  const runtime = await this.#processes.startRetained(options.signal, start, this.#retention(options.sessionId));
85051
85161
  this.#executionProcesses.retain(options.sessionId, runtime);
@@ -85139,12 +85249,17 @@ var AgentRuntimeManager = class {
85139
85249
  return runtime;
85140
85250
  });
85141
85251
  }
85142
- async #prepareSession(options, recovery, metrics = unmeasuredOperationMetrics) {
85252
+ async #prepareSession(options, recovery, closed, metrics = unmeasuredOperationMetrics) {
85143
85253
  return await this.#operations.run(options, async (options2) => {
85144
85254
  const closing = this.#sessionClosures.get(options2.sessionId);
85145
85255
  if (closing !== void 0) {
85146
85256
  await waitForSharedOperation(closing, options2.signal);
85147
85257
  }
85258
+ if (closed === "reopen") {
85259
+ this.#closedSessions.delete(options2.sessionId);
85260
+ } else {
85261
+ this.#assertOpen(options2.sessionId);
85262
+ }
85148
85263
  const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
85149
85264
  if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
85150
85265
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -85165,7 +85280,7 @@ var AgentRuntimeManager = class {
85165
85280
  }
85166
85281
  return runtime2.prepared();
85167
85282
  }
85168
- return await this.#prepareSession(options2, recovery, metrics);
85283
+ return await this.#prepareSession(options2, recovery, closed, metrics);
85169
85284
  }
85170
85285
  const existing = this.#executionProcesses.get(options2.sessionId);
85171
85286
  if (existing !== void 0) {
@@ -85193,8 +85308,8 @@ var AgentRuntimeManager = class {
85193
85308
  return runtime.prepared();
85194
85309
  });
85195
85310
  }
85196
- prepareSession = async (options, metrics = unmeasuredOperationMetrics) => await this.#prepareSession(options, { kind: "interactive-only" }, metrics);
85197
- restoreSession = async (options, metrics = unmeasuredOperationMetrics) => await this.#prepareSession(options, { kind: "history-required" }, metrics);
85311
+ prepareSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "interactive-only" }, closed, metrics);
85312
+ restoreSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "history-required" }, closed, metrics);
85198
85313
  /**
85199
85314
  * Opens a short-lived native ACP session only to read the local Agent's
85200
85315
  * authoritative settings. Its identity and store are private to this
@@ -85265,6 +85380,7 @@ var AgentRuntimeManager = class {
85265
85380
  });
85266
85381
  });
85267
85382
  prepareExecutionSession = async (options) => this.#operations.run(options, async (options2) => {
85383
+ this.#assertOpen(options2.sessionId);
85268
85384
  const pending = this.#executionProcesses.pending(options2.sessionId);
85269
85385
  if (pending !== void 0) {
85270
85386
  await waitForSharedOperation(pending, options2.signal);
@@ -85302,6 +85418,7 @@ var AgentRuntimeManager = class {
85302
85418
  });
85303
85419
  });
85304
85420
  renameSession = async (sessionId, title2, signal) => await this.#operations.run({ sessionId, signal }, async (options) => {
85421
+ this.#assertOpen(options.sessionId);
85305
85422
  const runtime = this.#executionProcesses.get(options.sessionId);
85306
85423
  if (runtime !== void 0) {
85307
85424
  return await runtime.renameSession(title2, options.signal);
@@ -85377,6 +85494,7 @@ var AgentRuntimeManager = class {
85377
85494
  }
85378
85495
  });
85379
85496
  runPrompt = async (options) => this.#operations.run(options, async (options2) => {
85497
+ this.#assertOpen(options2.sessionId);
85380
85498
  const stored = this.#store.read(options2.sessionId);
85381
85499
  if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
85382
85500
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -85445,6 +85563,7 @@ var AgentRuntimeManager = class {
85445
85563
  }
85446
85564
  });
85447
85565
  respondPermission = async (options) => {
85566
+ this.#assertOpen(options.sessionId);
85448
85567
  const runtime = this.#executionProcesses.get(options.sessionId);
85449
85568
  if (runtime === void 0) {
85450
85569
  throw new AcpExecutionError("The permission request session is unavailable", {}, "session_not_found");
@@ -85452,6 +85571,7 @@ var AgentRuntimeManager = class {
85452
85571
  await runtime.respondPermission(options);
85453
85572
  };
85454
85573
  respondElicitation = async (options) => {
85574
+ this.#assertOpen(options.sessionId);
85455
85575
  const runtime = this.#executionProcesses.get(options.sessionId);
85456
85576
  if (runtime === void 0) {
85457
85577
  throw new AcpExecutionError("The elicitation request session is unavailable", {}, "session_not_found");
@@ -85464,11 +85584,12 @@ var AgentRuntimeManager = class {
85464
85584
  await waitForSharedOperation(existing, options.signal);
85465
85585
  return;
85466
85586
  }
85587
+ this.#announceClosed(options.sessionId, "This Session was closed on request.");
85467
85588
  const release = (async () => {
85468
85589
  const pending = this.#executionProcesses.pending(options.sessionId);
85469
85590
  const runtime = pending === void 0 ? this.#executionProcesses.get(options.sessionId) : await pending;
85470
85591
  if (runtime !== void 0) {
85471
- await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.close());
85592
+ await this.#stopSessionProcess(options.sessionId, runtime);
85472
85593
  }
85473
85594
  })();
85474
85595
  const deadline = Promise.withResolvers();
@@ -85550,6 +85671,7 @@ var AgentRuntimeManager = class {
85550
85671
  });
85551
85672
  });
85552
85673
  ensureSession = async (options) => this.#operations.run(options, async (options2) => {
85674
+ this.#assertOpen(options2.sessionId);
85553
85675
  const existing = this.#executionProcesses.get(options2.sessionId);
85554
85676
  if (existing !== void 0) {
85555
85677
  if (!existing.belongsTo(options2.agent.id, options2.cwd, options2.additionalDirectories)) {
@@ -85628,6 +85750,7 @@ var AgentRuntimeManager = class {
85628
85750
  const existing = linked[0];
85629
85751
  if (origin.kind === "import" && existing !== void 0) {
85630
85752
  return await this.#executionProcesses.use(existing.sessionId, async () => {
85753
+ this.#closedSessions.delete(existing.sessionId);
85631
85754
  const runtime = await this.ensureSession({
85632
85755
  ...options2,
85633
85756
  sessionId: existing.sessionId
@@ -87095,12 +87218,11 @@ var RelayConnectionDiagnostics = class {
87095
87218
  false
87096
87219
  );
87097
87220
  };
87098
- heartbeatTimedOut = (connectionEpoch, heartbeatId, timeoutMilliseconds) => {
87221
+ heartbeatTimedOut = (connectionEpoch, timeoutMilliseconds) => {
87099
87222
  this.#record(
87100
87223
  "relay_heartbeat_timed_out",
87101
87224
  {
87102
87225
  connectionEpoch: connectionEpoch.toString(),
87103
- heartbeatId,
87104
87226
  relayOrigin: this.#relayOrigin,
87105
87227
  timeoutMilliseconds: timeoutMilliseconds.toString(),
87106
87228
  ...this.#route
@@ -87147,7 +87269,7 @@ import { WebSocket as WebSocket7 } from "undici";
87147
87269
  // package.json
87148
87270
  var package_default = {
87149
87271
  name: "@moxt-ai/mobius",
87150
- version: "0.0.277",
87272
+ version: "0.0.280",
87151
87273
  description: "Mobius CLI for pairing and running local AI agent services.",
87152
87274
  type: "module",
87153
87275
  bin: {
@@ -89013,8 +89135,8 @@ var ResolvedSessionDirectories = class {
89013
89135
  this.cwd = cwd;
89014
89136
  }
89015
89137
  };
89016
- async function resolveSessionDirectories(directories, bindingId, directoryId2, additionalDirectoryIds, signal) {
89017
- const cwd = await directories.resolve(bindingId, directoryId2, signal);
89138
+ async function resolveSessionDirectories(directories, bindingId, directoryId, additionalDirectoryIds, signal) {
89139
+ const cwd = await directories.resolve(bindingId, directoryId, signal);
89018
89140
  const additionalDirectories = [];
89019
89141
  const additionalDirectoryEntries = [];
89020
89142
  const unique = /* @__PURE__ */ new Set([cwd]);
@@ -89038,7 +89160,7 @@ async function resolveCatalogAgent(config2, agentId, signal) {
89038
89160
  const agent = config2.catalog.find(agentId);
89039
89161
  return config2.resolveAgent === void 0 ? agent : await config2.resolveAgent(agent, signal);
89040
89162
  }
89041
- async function prepareSession(command, recovery, config2, directories, sessions, metrics, signal) {
89163
+ async function prepareSession(command, recovery, closed, config2, directories, sessions, metrics, signal) {
89042
89164
  return await metrics.measure("prepare-total", async () => {
89043
89165
  const resolved = await metrics.measure(
89044
89166
  "workspace-resolve",
@@ -89058,7 +89180,7 @@ async function prepareSession(command, recovery, config2, directories, sessions,
89058
89180
  sessionId: command.sessionId,
89059
89181
  signal
89060
89182
  };
89061
- const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
89183
+ 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);
89062
89184
  const configuration = command.configuration;
89063
89185
  const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
89064
89186
  "configuration",
@@ -89114,6 +89236,7 @@ async function executeSessionPrepare(socket, command, config2, directories, sess
89114
89236
  const readyEvent = await prepareSession(
89115
89237
  command,
89116
89238
  { kind: "interactive-only" },
89239
+ "reopen",
89117
89240
  config2,
89118
89241
  directories,
89119
89242
  sessions,
@@ -89160,6 +89283,7 @@ async function executeSessionRestore(socket, command, config2, directories, sess
89160
89283
  sessionState: "provisioned"
89161
89284
  },
89162
89285
  { kind: "history-required" },
89286
+ "reopen",
89163
89287
  config2,
89164
89288
  directories,
89165
89289
  sessions,
@@ -89330,6 +89454,8 @@ async function executeSessionConfigRead(socket, command, config2, directories, s
89330
89454
  // load support would fail even with a live process whose config is
89331
89455
  // already readable, and prepare reuses the current configuration.
89332
89456
  { kind: "interactive-only" },
89457
+ // Reading settings must not reopen a Session that a client closed.
89458
+ "keep-closed",
89333
89459
  config2,
89334
89460
  directories,
89335
89461
  sessions,
@@ -90447,7 +90573,6 @@ function connectRelay(url2, signal) {
90447
90573
  }
90448
90574
 
90449
90575
  // src/runtime/relay/liveness.ts
90450
- import { randomUUID as randomUUID14 } from "node:crypto";
90451
90576
  var HEARTBEAT_ACK_TIMEOUT_MILLISECONDS = 1e4;
90452
90577
  var HEARTBEAT_INTERVAL_MILLISECONDS = 2e4;
90453
90578
  var RelayLivenessState = class {
@@ -90455,11 +90580,9 @@ var RelayLivenessState = class {
90455
90580
  var UnsupportedRelayLivenessState = class extends RelayLivenessState {
90456
90581
  };
90457
90582
  var AwaitingHeartbeatAckState = class extends RelayLivenessState {
90458
- heartbeatId;
90459
90583
  timeout;
90460
- constructor(heartbeatId, timeout) {
90584
+ constructor(timeout) {
90461
90585
  super();
90462
- this.heartbeatId = heartbeatId;
90463
90586
  this.timeout = timeout;
90464
90587
  }
90465
90588
  };
@@ -90480,13 +90603,10 @@ var RelayConnectionLiveness = class {
90480
90603
  this.#timer = timer;
90481
90604
  this.#transport = transport;
90482
90605
  }
90483
- acknowledge = (event) => {
90606
+ acknowledge = () => {
90484
90607
  if (!(this.#state instanceof AwaitingHeartbeatAckState)) {
90485
90608
  throw new Error("Unexpected relay heartbeat acknowledgement");
90486
90609
  }
90487
- if (event.heartbeatId !== this.#state.heartbeatId) {
90488
- throw new Error("Relay acknowledged the wrong heartbeat");
90489
- }
90490
90610
  this.#state.timeout.cancel();
90491
90611
  this.#state = new WaitingForHeartbeatState(
90492
90612
  this.#timer.schedule(this.#sendHeartbeat, HEARTBEAT_INTERVAL_MILLISECONDS)
@@ -90522,10 +90642,9 @@ var RelayConnectionLiveness = class {
90522
90642
  if (!(this.#state instanceof AwaitingHeartbeatAckState)) {
90523
90643
  throw new Error("Heartbeat timeout occurred in an invalid state");
90524
90644
  }
90525
- const heartbeatId = this.#state.heartbeatId;
90526
90645
  this.#state.timeout.cancel();
90527
90646
  this.#state = new FinishedRelayLivenessState();
90528
- this.#transport.unresponsive(heartbeatId, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS);
90647
+ this.#transport.unresponsive(HEARTBEAT_ACK_TIMEOUT_MILLISECONDS);
90529
90648
  };
90530
90649
  #sendHeartbeat = () => {
90531
90650
  if (this.#state instanceof WaitingForHeartbeatState) {
@@ -90536,17 +90655,13 @@ var RelayConnectionLiveness = class {
90536
90655
  }
90537
90656
  throw new Error("Heartbeat was scheduled in an invalid state");
90538
90657
  }
90539
- const heartbeatId = randomUUID14();
90540
- this.#state = new AwaitingHeartbeatAckState(
90541
- heartbeatId,
90658
+ const awaiting = new AwaitingHeartbeatAckState(
90542
90659
  this.#timer.schedule(this.#handleTimeout, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS)
90543
90660
  );
90544
- const sent = this.#transport.send({
90545
- heartbeatId,
90546
- kind: RUNTIME_HEARTBEAT_KIND
90547
- });
90548
- if (!sent && this.#state instanceof AwaitingHeartbeatAckState && this.#state.heartbeatId === heartbeatId) {
90549
- this.#state.timeout.cancel();
90661
+ this.#state = awaiting;
90662
+ const sent = this.#transport.send({ kind: RUNTIME_HEARTBEAT_KIND });
90663
+ if (!sent && this.#state === awaiting) {
90664
+ awaiting.timeout.cancel();
90550
90665
  this.#state = new FinishedRelayLivenessState();
90551
90666
  }
90552
90667
  };
@@ -90693,8 +90808,8 @@ async function runRelayConnection({
90693
90808
  throw error62;
90694
90809
  }
90695
90810
  },
90696
- unresponsive: (heartbeatId, timeoutMilliseconds) => {
90697
- diagnostics.heartbeatTimedOut(connectionEpoch, heartbeatId, timeoutMilliseconds);
90811
+ unresponsive: (timeoutMilliseconds) => {
90812
+ diagnostics.heartbeatTimedOut(connectionEpoch, timeoutMilliseconds);
90698
90813
  diagnostics.connectionClosed(
90699
90814
  connectionEpoch,
90700
90815
  4001,
@@ -90745,7 +90860,7 @@ async function runRelayConnection({
90745
90860
  return;
90746
90861
  }
90747
90862
  if (kind === RUNTIME_HEARTBEAT_ACK_KIND) {
90748
- connectionLiveness.acknowledge(message);
90863
+ connectionLiveness.acknowledge();
90749
90864
  return;
90750
90865
  }
90751
90866
  commands.dispatch(message);
@@ -90828,6 +90943,7 @@ var RuntimeSessionEventPublisher = class {
90828
90943
  };
90829
90944
  publishStatus = (event) => this.#send(event);
90830
90945
  publishInfo = (event) => this.#send(event);
90946
+ publishClosed = (event) => this.#send(event);
90831
90947
  #send = (message) => {
90832
90948
  const socket = this.#socket;
90833
90949
  if (socket === null || socket.readyState !== WebSocket8.OPEN) {
@@ -91067,7 +91183,7 @@ var RuntimeSessionEventProjection = class {
91067
91183
  };
91068
91184
 
91069
91185
  // src/runtime/session/turn/active-turn.ts
91070
- import { randomUUID as randomUUID15 } from "node:crypto";
91186
+ import { randomUUID as randomUUID14 } from "node:crypto";
91071
91187
  var ActiveRuntimeTurn = class {
91072
91188
  attemptId;
91073
91189
  command;
@@ -91077,7 +91193,7 @@ var ActiveRuntimeTurn = class {
91077
91193
  #dispatch;
91078
91194
  #sequence = 0;
91079
91195
  #interaction = null;
91080
- #epoch = decodeIdentifier(randomUUID15());
91196
+ #epoch = decodeIdentifier(randomUUID14());
91081
91197
  constructor(command, attemptId) {
91082
91198
  this.attemptId = attemptId;
91083
91199
  this.command = command;
@@ -91359,8 +91475,8 @@ var WorkspaceDirectoryListing = class {
91359
91475
  directoryLabel;
91360
91476
  entries;
91361
91477
  parentDirectoryId;
91362
- constructor(directoryId2, directoryLabel, entries, parentDirectoryId) {
91363
- this.directoryId = directoryId2;
91478
+ constructor(directoryId, directoryLabel, entries, parentDirectoryId) {
91479
+ this.directoryId = directoryId;
91364
91480
  this.directoryLabel = directoryLabel;
91365
91481
  this.entries = entries;
91366
91482
  this.parentDirectoryId = parentDirectoryId;
@@ -91368,7 +91484,7 @@ var WorkspaceDirectoryListing = class {
91368
91484
  };
91369
91485
  function encodePath(path7) {
91370
91486
  const encoded = Buffer.from(path7, "utf8").toString("base64url");
91371
- if (encoded.length === 0 || encoded.length > 2e3) {
91487
+ if (path7.length === 0 || path7.length > MAX_WORKSPACE_PATH_LENGTH || encoded.length + "path-".length > MAX_DIRECTORY_IDENTIFIER_LENGTH) {
91372
91488
  throw new LocalAuthorizationError("The local directory path is too long to select");
91373
91489
  }
91374
91490
  return `path-${encoded}`;
@@ -91378,12 +91494,12 @@ function expandCurrentUserHome(path7) {
91378
91494
  }
91379
91495
  function decodePath(value, prefix) {
91380
91496
  const encoded = value.slice(prefix.length);
91381
- if (encoded.length === 0 || encoded.length > 2e3 || !/^[a-zA-Z0-9_-]+$/.test(encoded)) {
91497
+ if (encoded.length === 0 || value.length > MAX_DIRECTORY_IDENTIFIER_LENGTH || !/^[a-zA-Z0-9_-]+$/.test(encoded)) {
91382
91498
  throw new LocalAuthorizationError("The directory identifier is invalid");
91383
91499
  }
91384
91500
  const decoded = Buffer.from(encoded, "base64url").toString("utf8");
91385
91501
  const normalized = process.platform === "win32" && decoded.startsWith("~/") ? normalize3(decoded).replaceAll("\\", "/") : normalize3(decoded);
91386
- if (Buffer.from(decoded, "utf8").toString("base64url") !== encoded || decoded.includes("\0") || normalized !== decoded) {
91502
+ if (Buffer.from(decoded, "utf8").toString("base64url") !== encoded || decoded.length > MAX_WORKSPACE_PATH_LENGTH || decoded.includes("\0") || normalized !== decoded) {
91387
91503
  throw new LocalAuthorizationError("The directory identifier is invalid");
91388
91504
  }
91389
91505
  return decoded;
@@ -91575,6 +91691,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
91575
91691
  adapters: harnessAdapters,
91576
91692
  sessionIdentity: "native",
91577
91693
  onSessionStatusChanged: publisher.publishStatus,
91694
+ onSessionClosed: publisher.publishClosed,
91578
91695
  contentExternalizer: new AcpContentExternalizer(externalContent),
91579
91696
  timer,
91580
91697
  maxProcesses: resolveMaxAcpProcesses(config2.localContext.environment)