@moxt-ai/mobius 0.0.108 → 0.0.111

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 (47) hide show
  1. package/dist/acp/process-session.d.ts +0 -1
  2. package/dist/acp/process-session.d.ts.map +1 -1
  3. package/dist/acp/process-session.js +0 -9
  4. package/dist/acp/process-session.js.map +1 -1
  5. package/dist/acp/session-manager.d.ts +1 -3
  6. package/dist/acp/session-manager.d.ts.map +1 -1
  7. package/dist/acp/session-manager.js +4 -37
  8. package/dist/acp/session-manager.js.map +1 -1
  9. package/dist/cli.js +175 -261
  10. package/dist/cli.js.map +4 -4
  11. package/dist/daemon-turn-reconciliation.d.ts.map +1 -1
  12. package/dist/daemon-turn-reconciliation.js +3 -3
  13. package/dist/daemon-turn-reconciliation.js.map +1 -1
  14. package/dist/index.js +175 -262
  15. package/dist/index.js.map +4 -4
  16. package/dist/native-sessions/acp-adapter.d.ts.map +1 -1
  17. package/dist/native-sessions/acp-adapter.js +0 -1
  18. package/dist/native-sessions/acp-adapter.js.map +1 -1
  19. package/dist/native-sessions/agent-adapter.d.ts +0 -1
  20. package/dist/native-sessions/agent-adapter.d.ts.map +1 -1
  21. package/dist/native-sessions/agent-adapter.js +0 -3
  22. package/dist/native-sessions/agent-adapter.js.map +1 -1
  23. package/dist/native-sessions/codex-adapter.d.ts.map +1 -1
  24. package/dist/native-sessions/codex-adapter.js +0 -1
  25. package/dist/native-sessions/codex-adapter.js.map +1 -1
  26. package/dist/native-sessions/handle-native-requests.js +1 -1
  27. package/dist/native-sessions/handle-native-requests.js.map +1 -1
  28. package/dist/native-sessions/service.d.ts +1 -1
  29. package/dist/native-sessions/service.d.ts.map +1 -1
  30. package/dist/native-sessions/service.js +9 -46
  31. package/dist/native-sessions/service.js.map +1 -1
  32. package/dist/pairing/pair-local-machine.d.ts.map +1 -1
  33. package/dist/pairing/pair-local-machine.js +5 -6
  34. package/dist/pairing/pair-local-machine.js.map +1 -1
  35. package/dist/prompt-artifact-resolver.d.ts +1 -1
  36. package/dist/prompt-artifact-resolver.d.ts.map +1 -1
  37. package/dist/prompt-artifact-resolver.js +2 -2
  38. package/dist/prompt-artifact-resolver.js.map +1 -1
  39. package/dist/run-daemon.d.ts.map +1 -1
  40. package/dist/run-daemon.js +17 -1
  41. package/dist/run-daemon.js.map +1 -1
  42. package/dist/runtime.d.ts.map +1 -1
  43. package/dist/runtime.js +8202 -8291
  44. package/dist/runtime.js.map +4 -4
  45. package/dist/storage/runtime-installation-store.js +3 -3
  46. package/dist/storage/runtime-installation-store.js.map +1 -1
  47. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19702,6 +19702,17 @@ function date4(params) {
19702
19702
  return _coercedDate(ZodDate, params);
19703
19703
  }
19704
19704
 
19705
+ // ../protocol/src/identifier.ts
19706
+ var IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
19707
+ var identifierStringSchema = external_exports.string().min(1).max(128).regex(IDENTIFIER_PATTERN);
19708
+ var identifierSchema = identifierStringSchema.brand();
19709
+ function isIdentifier(value) {
19710
+ return identifierSchema.safeParse(value).success;
19711
+ }
19712
+ function decodeIdentifier(value) {
19713
+ return identifierSchema.parse(value);
19714
+ }
19715
+
19705
19716
  // ../protocol/src/prompt-usage.ts
19706
19717
  var TOKEN_COUNT = external_exports.number().int().nonnegative();
19707
19718
  function normalizeQuotaTokenCount(value) {
@@ -19809,9 +19820,7 @@ var FILE_BEGIN_KIND = "file.begin";
19809
19820
  var FILE_CHUNK_KIND = "file.chunk";
19810
19821
  var FILE_END_KIND = "file.end";
19811
19822
  var FILE_FAILED_KIND = "file.failed";
19812
- var IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
19813
19823
  var DIRECTORY_IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
19814
- var IDENTIFIER = external_exports.string().min(1).max(128).regex(IDENTIFIER_PATTERN);
19815
19824
  var DIRECTORY_IDENTIFIER = external_exports.string().min(1).max(2048).regex(DIRECTORY_IDENTIFIER_PATTERN);
19816
19825
  var SHORT_TEXT = external_exports.string().max(500);
19817
19826
  var LONG_TEXT = external_exports.string().max(1e5);
@@ -19821,29 +19830,29 @@ var workspaceEntrySchema = external_exports.strictObject({
19821
19830
  }).readonly();
19822
19831
  var sessionMetadataSchema = external_exports.strictObject({
19823
19832
  additionalDirectories: external_exports.array(workspaceEntrySchema).max(16).readonly(),
19824
- agentId: IDENTIFIER,
19833
+ agentId: identifierStringSchema,
19825
19834
  directoryId: DIRECTORY_IDENTIFIER,
19826
19835
  directoryLabel: external_exports.string().min(1).max(2048),
19827
19836
  prompted: external_exports.boolean(),
19828
- sessionId: IDENTIFIER,
19837
+ sessionId: identifierStringSchema,
19829
19838
  title: external_exports.string().max(500),
19830
19839
  updatedAt: external_exports.iso.datetime({ offset: true })
19831
19840
  }).readonly();
19832
19841
  var sessionQueryCommandSchema = external_exports.strictObject({
19833
19842
  kind: external_exports.literal(SESSION_QUERY_KIND),
19834
- requestId: IDENTIFIER,
19835
- sessionIds: external_exports.array(IDENTIFIER).min(1).max(500).readonly()
19843
+ requestId: identifierStringSchema,
19844
+ sessionIds: external_exports.array(identifierStringSchema).min(1).max(500).readonly()
19836
19845
  }).readonly();
19837
19846
  var sessionsQueriedEventSchema = external_exports.strictObject({
19838
19847
  entries: external_exports.array(sessionMetadataSchema).max(500).readonly(),
19839
19848
  kind: external_exports.literal(SESSION_QUERIED_KIND),
19840
- requestId: IDENTIFIER
19849
+ requestId: identifierStringSchema
19841
19850
  }).readonly();
19842
19851
  var fileReadCommandSchema = external_exports.strictObject({
19843
19852
  kind: external_exports.literal(FILE_READ_KIND),
19844
19853
  maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
19845
- requestId: IDENTIFIER,
19846
- sessionId: IDENTIFIER,
19854
+ requestId: identifierStringSchema,
19855
+ sessionId: identifierStringSchema,
19847
19856
  path: external_exports.string().min(1).max(4096)
19848
19857
  }).readonly();
19849
19858
  var fileBeginEventSchema = external_exports.strictObject({
@@ -19852,27 +19861,27 @@ var fileBeginEventSchema = external_exports.strictObject({
19852
19861
  mediaType: external_exports.string().min(1).max(255),
19853
19862
  modifiedAt: external_exports.iso.datetime({ offset: true }),
19854
19863
  name: external_exports.string().min(1).max(500),
19855
- requestId: IDENTIFIER,
19856
- sessionId: IDENTIFIER
19864
+ requestId: identifierStringSchema,
19865
+ sessionId: identifierStringSchema
19857
19866
  }).readonly();
19858
19867
  var fileChunkEventSchema = external_exports.strictObject({
19859
19868
  data: external_exports.string().min(1).max(4e5),
19860
19869
  kind: external_exports.literal(FILE_CHUNK_KIND),
19861
- requestId: IDENTIFIER,
19870
+ requestId: identifierStringSchema,
19862
19871
  sequence: external_exports.number().int().nonnegative().max(1024),
19863
- sessionId: IDENTIFIER
19872
+ sessionId: identifierStringSchema
19864
19873
  }).readonly();
19865
19874
  var fileEndEventSchema = external_exports.strictObject({
19866
19875
  kind: external_exports.literal(FILE_END_KIND),
19867
- requestId: IDENTIFIER,
19868
- sessionId: IDENTIFIER
19876
+ requestId: identifierStringSchema,
19877
+ sessionId: identifierStringSchema
19869
19878
  }).readonly();
19870
19879
  var fileFailedEventSchema = external_exports.strictObject({
19871
- code: IDENTIFIER,
19880
+ code: identifierStringSchema,
19872
19881
  kind: external_exports.literal(FILE_FAILED_KIND),
19873
19882
  message: external_exports.string().min(1).max(500),
19874
- requestId: IDENTIFIER,
19875
- sessionId: IDENTIFIER
19883
+ requestId: identifierStringSchema,
19884
+ sessionId: identifierStringSchema
19876
19885
  }).readonly();
19877
19886
  var configValueSchema = external_exports.strictObject({
19878
19887
  description: SHORT_TEXT,
@@ -19923,44 +19932,44 @@ var agentModelEffortSchema = external_exports.strictObject({
19923
19932
  valuesByModel: external_exports.record(external_exports.string().min(1).max(500), external_exports.array(configValueSchema).max(500).readonly()).readonly()
19924
19933
  }).readonly();
19925
19934
  var agentSettingsDiscoverCommandSchema = external_exports.strictObject({
19926
- agentId: IDENTIFIER,
19935
+ agentId: identifierStringSchema,
19927
19936
  kind: external_exports.literal(AGENT_SETTINGS_DISCOVER_KIND),
19928
19937
  model: external_exports.string().min(1).max(500).optional(),
19929
- requestId: IDENTIFIER
19938
+ requestId: identifierStringSchema
19930
19939
  }).readonly();
19931
19940
  var agentSettingsDiscoveredEventSchema = external_exports.strictObject({
19932
- agentId: IDENTIFIER,
19941
+ agentId: identifierStringSchema,
19933
19942
  agentName: external_exports.string().max(255),
19934
19943
  agentVersion: external_exports.string().max(128),
19935
19944
  kind: external_exports.literal(AGENT_SETTINGS_DISCOVERED_KIND),
19936
19945
  modelEffort: agentModelEffortSchema,
19937
- requestId: IDENTIFIER,
19946
+ requestId: identifierStringSchema,
19938
19947
  settings: agentSettingsSchema,
19939
19948
  settingsRevision: external_exports.string().regex(/^[a-f0-9]{64}$/)
19940
19949
  }).readonly();
19941
19950
  var agentSettingsDiscoveryFailedEventSchema = external_exports.strictObject({
19942
- code: IDENTIFIER,
19951
+ code: identifierStringSchema,
19943
19952
  kind: external_exports.literal(AGENT_SETTINGS_DISCOVERY_FAILED_KIND),
19944
19953
  message: external_exports.string().min(1).max(500),
19945
- requestId: IDENTIFIER
19954
+ requestId: identifierStringSchema
19946
19955
  }).readonly();
19947
19956
  var agentCatalogRefreshCommandSchema = external_exports.strictObject({
19948
19957
  kind: external_exports.literal(AGENT_CATALOG_REFRESH_KIND),
19949
- requestId: IDENTIFIER
19958
+ requestId: identifierStringSchema
19950
19959
  }).readonly();
19951
19960
  var agentCatalogRefreshedEventSchema = external_exports.strictObject({
19952
19961
  kind: external_exports.literal(AGENT_CATALOG_REFRESHED_KIND),
19953
- requestId: IDENTIFIER
19962
+ requestId: identifierStringSchema
19954
19963
  }).readonly();
19955
19964
  var agentCatalogRefreshFailedEventSchema = external_exports.strictObject({
19956
- code: IDENTIFIER,
19965
+ code: identifierStringSchema,
19957
19966
  kind: external_exports.literal(AGENT_CATALOG_REFRESH_FAILED_KIND),
19958
19967
  message: external_exports.string().min(1).max(500),
19959
- requestId: IDENTIFIER
19968
+ requestId: identifierStringSchema
19960
19969
  }).readonly();
19961
19970
  var sessionConfigurationSelectionSchema = external_exports.strictObject({
19962
19971
  booleanValue: external_exports.boolean(),
19963
- configId: IDENTIFIER,
19972
+ configId: identifierStringSchema,
19964
19973
  value: external_exports.string().max(500),
19965
19974
  valueType: external_exports.enum(["boolean", "select"])
19966
19975
  }).readonly();
@@ -20102,26 +20111,26 @@ var promptResourceSchema = external_exports.strictObject({
20102
20111
  uri: external_exports.string().min(1).max(4096)
20103
20112
  }).readonly();
20104
20113
  var workspaceListCommandSchema = external_exports.strictObject({
20105
- bindingId: IDENTIFIER,
20114
+ bindingId: identifierStringSchema,
20106
20115
  directoryId: DIRECTORY_IDENTIFIER,
20107
20116
  kind: external_exports.literal(WORKSPACE_LIST_KIND),
20108
- requestId: IDENTIFIER
20117
+ requestId: identifierStringSchema
20109
20118
  }).readonly();
20110
20119
  var workspaceEntriesEventSchema = external_exports.strictObject({
20111
- bindingId: IDENTIFIER,
20120
+ bindingId: identifierStringSchema,
20112
20121
  directoryId: DIRECTORY_IDENTIFIER,
20113
20122
  directoryLabel: external_exports.string().min(1).max(2048),
20114
20123
  entries: external_exports.array(workspaceEntrySchema).max(500).readonly(),
20115
20124
  kind: external_exports.literal(WORKSPACE_ENTRIES_KIND),
20116
20125
  parentDirectoryId: external_exports.string().max(2048),
20117
- requestId: IDENTIFIER
20126
+ requestId: identifierStringSchema
20118
20127
  }).readonly();
20119
20128
  var sessionIdentityFields = {
20120
20129
  additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
20121
- agentId: IDENTIFIER,
20122
- bindingId: IDENTIFIER,
20130
+ agentId: identifierStringSchema,
20131
+ bindingId: identifierStringSchema,
20123
20132
  directoryId: DIRECTORY_IDENTIFIER,
20124
- sessionId: IDENTIFIER
20133
+ sessionId: identifierStringSchema
20125
20134
  };
20126
20135
  var sessionPrepareCommandSchema = external_exports.strictObject({
20127
20136
  ...sessionIdentityFields,
@@ -20132,7 +20141,7 @@ var sessionPrepareCommandSchema = external_exports.strictObject({
20132
20141
  valueType: external_exports.enum(["boolean", "select"])
20133
20142
  }).readonly().optional(),
20134
20143
  kind: external_exports.literal(SESSION_PREPARE_KIND),
20135
- requestId: IDENTIFIER,
20144
+ requestId: identifierStringSchema,
20136
20145
  sessionState: external_exports.literal("provisioned").optional(),
20137
20146
  /** Marks an inspection-only Session preparation. */
20138
20147
  transient: external_exports.boolean().optional()
@@ -20153,7 +20162,7 @@ var runtimeTimingsSchema = external_exports.array(
20153
20162
  ).max(16).readonly();
20154
20163
  var sessionReadyEventSchema = external_exports.strictObject({
20155
20164
  additionalDirectories: external_exports.array(workspaceEntrySchema).max(16).readonly(),
20156
- agentId: IDENTIFIER,
20165
+ agentId: identifierStringSchema,
20157
20166
  agentName: external_exports.string().max(255),
20158
20167
  agentVersion: external_exports.string().max(128),
20159
20168
  capabilities: sessionCapabilitiesSchema,
@@ -20162,41 +20171,41 @@ var sessionReadyEventSchema = external_exports.strictObject({
20162
20171
  directoryId: DIRECTORY_IDENTIFIER,
20163
20172
  directoryLabel: external_exports.string().min(1).max(2048),
20164
20173
  kind: external_exports.literal(SESSION_READY_KIND),
20165
- requestId: IDENTIFIER,
20174
+ requestId: identifierStringSchema,
20166
20175
  restored: external_exports.boolean(),
20167
20176
  runtimeTimings: runtimeTimingsSchema.optional(),
20168
- sessionId: IDENTIFIER
20177
+ sessionId: identifierStringSchema
20169
20178
  }).readonly();
20170
20179
  var sessionConfigureCommandSchema = external_exports.strictObject({
20171
20180
  ...sessionIdentityFields,
20172
20181
  booleanValue: external_exports.boolean(),
20173
20182
  configId: external_exports.string().min(1).max(128),
20174
20183
  kind: external_exports.literal(SESSION_CONFIGURE_KIND),
20175
- requestId: IDENTIFIER,
20184
+ requestId: identifierStringSchema,
20176
20185
  value: external_exports.string().max(500),
20177
20186
  valueType: external_exports.enum(["boolean", "select"])
20178
20187
  }).readonly();
20179
20188
  var sessionConfigUpdatedEventSchema = external_exports.strictObject({
20180
20189
  configOptions: sessionConfigOptionsSchema,
20181
20190
  kind: external_exports.literal(SESSION_CONFIG_UPDATED_KIND),
20182
- requestId: IDENTIFIER,
20183
- sessionId: IDENTIFIER
20191
+ requestId: identifierStringSchema,
20192
+ sessionId: identifierStringSchema
20184
20193
  }).readonly();
20185
20194
  var sessionContextUsageUpdatedEventSchema = external_exports.strictObject({
20186
20195
  costAmount: external_exports.number().finite().nonnegative(),
20187
20196
  costCurrency: external_exports.string().max(16),
20188
20197
  hasCost: external_exports.boolean(),
20189
20198
  kind: external_exports.literal(SESSION_USAGE_UPDATED_KIND),
20190
- sessionId: IDENTIFIER,
20199
+ sessionId: identifierStringSchema,
20191
20200
  size: external_exports.number().int().nonnegative(),
20192
20201
  source: external_exports.literal("context").default("context"),
20193
20202
  used: external_exports.number().int().nonnegative()
20194
20203
  }).readonly();
20195
20204
  var sessionPromptUsageUpdatedEventSchema = external_exports.strictObject({
20196
20205
  _meta: promptMetadataSchema.nullable(),
20197
- commandId: IDENTIFIER,
20206
+ commandId: identifierStringSchema,
20198
20207
  kind: external_exports.literal(SESSION_USAGE_UPDATED_KIND),
20199
- sessionId: IDENTIFIER,
20208
+ sessionId: identifierStringSchema,
20200
20209
  source: external_exports.literal("prompt"),
20201
20210
  usage: promptUsageSchema.nullable()
20202
20211
  }).refine((event) => event.usage !== null || event._meta?.quota !== void 0).readonly();
@@ -20207,82 +20216,82 @@ var sessionUsageUpdatedEventSchema = external_exports.union([
20207
20216
  var sessionCommandsUpdatedEventSchema = external_exports.strictObject({
20208
20217
  commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
20209
20218
  kind: external_exports.literal(SESSION_COMMANDS_UPDATED_KIND),
20210
- sessionId: IDENTIFIER
20219
+ sessionId: identifierStringSchema
20211
20220
  }).readonly();
20212
20221
  var sessionInfoUpdatedEventSchema = external_exports.strictObject({
20213
20222
  kind: external_exports.literal(SESSION_INFO_UPDATED_KIND),
20214
- sessionId: IDENTIFIER,
20223
+ sessionId: identifierStringSchema,
20215
20224
  title: external_exports.string().max(500).nullable(),
20216
20225
  updatedAt: external_exports.string().max(128)
20217
20226
  }).readonly();
20218
20227
  var sessionPermissionRequestedEventSchema = external_exports.strictObject({
20219
- commandId: IDENTIFIER,
20220
- interactionId: IDENTIFIER,
20228
+ commandId: identifierStringSchema,
20229
+ interactionId: identifierStringSchema,
20221
20230
  kind: external_exports.literal(SESSION_PERMISSION_REQUESTED_KIND),
20222
20231
  options: external_exports.array(permissionOptionSchema).min(1).max(20).readonly(),
20223
- sessionId: IDENTIFIER,
20232
+ sessionId: identifierStringSchema,
20224
20233
  title: external_exports.string().min(1).max(500),
20225
20234
  toolCallId: external_exports.string().min(1).max(255),
20226
20235
  toolKind: external_exports.string().max(64)
20227
20236
  }).readonly();
20228
20237
  var sessionPermissionRespondCommandSchema = external_exports.strictObject({
20229
- interactionId: IDENTIFIER,
20238
+ interactionId: identifierStringSchema,
20230
20239
  kind: external_exports.literal(SESSION_PERMISSION_RESPOND_KIND),
20231
20240
  optionId: external_exports.string().max(255),
20232
20241
  outcome: external_exports.enum(["cancelled", "selected"]),
20233
- sessionId: IDENTIFIER
20242
+ sessionId: identifierStringSchema
20234
20243
  }).readonly();
20235
20244
  var sessionPermissionResolvedEventSchema = external_exports.strictObject({
20236
- interactionId: IDENTIFIER,
20245
+ interactionId: identifierStringSchema,
20237
20246
  kind: external_exports.literal(SESSION_PERMISSION_RESOLVED_KIND),
20238
20247
  optionId: external_exports.string().max(255),
20239
20248
  outcome: external_exports.enum(["cancelled", "selected"]),
20240
- sessionId: IDENTIFIER
20249
+ sessionId: identifierStringSchema
20241
20250
  }).readonly();
20242
20251
  var sessionElicitationRequestedEventSchema = external_exports.strictObject({
20243
20252
  accepted: external_exports.boolean(),
20244
- commandId: IDENTIFIER,
20253
+ commandId: identifierStringSchema,
20245
20254
  elicitationId: external_exports.string().max(255),
20246
20255
  fields: external_exports.array(elicitationFieldSchema).max(100).readonly(),
20247
- interactionId: IDENTIFIER,
20256
+ interactionId: identifierStringSchema,
20248
20257
  kind: external_exports.literal(SESSION_ELICITATION_REQUESTED_KIND),
20249
20258
  message: external_exports.string().min(1).max(2e3),
20250
20259
  mode: external_exports.enum(["form", "url"]),
20251
- sessionId: IDENTIFIER,
20260
+ sessionId: identifierStringSchema,
20252
20261
  url: external_exports.string().max(4096)
20253
20262
  }).readonly();
20254
20263
  var sessionElicitationRespondCommandSchema = external_exports.strictObject({
20255
20264
  action: external_exports.enum(["accept", "cancel", "decline"]),
20256
20265
  content: external_exports.string().max(1e5),
20257
- interactionId: IDENTIFIER,
20266
+ interactionId: identifierStringSchema,
20258
20267
  kind: external_exports.literal(SESSION_ELICITATION_RESPOND_KIND),
20259
- sessionId: IDENTIFIER
20268
+ sessionId: identifierStringSchema
20260
20269
  }).readonly();
20261
20270
  var sessionElicitationResolvedEventSchema = external_exports.strictObject({
20262
20271
  action: external_exports.enum(["accept", "cancel", "decline", "complete"]),
20263
- interactionId: IDENTIFIER,
20272
+ interactionId: identifierStringSchema,
20264
20273
  kind: external_exports.literal(SESSION_ELICITATION_RESOLVED_KIND),
20265
- sessionId: IDENTIFIER
20274
+ sessionId: identifierStringSchema
20266
20275
  }).readonly();
20267
20276
  var sessionOperationFailedEventSchema = external_exports.strictObject({
20268
- code: IDENTIFIER,
20277
+ code: identifierStringSchema,
20269
20278
  kind: external_exports.literal(SESSION_OPERATION_FAILED_KIND),
20270
20279
  message: external_exports.string().min(1).max(500),
20271
- requestId: IDENTIFIER,
20280
+ requestId: identifierStringSchema,
20272
20281
  runtimeTimings: runtimeTimingsSchema.optional(),
20273
20282
  sessionId: external_exports.string().max(128)
20274
20283
  }).readonly();
20275
20284
  var agentContentEventSchema = external_exports.strictObject({
20276
- commandId: IDENTIFIER,
20285
+ commandId: identifierStringSchema,
20277
20286
  content: displayContentSchema,
20278
- contentId: IDENTIFIER,
20287
+ contentId: identifierStringSchema,
20279
20288
  kind: external_exports.literal(AGENT_CONTENT_KIND),
20280
20289
  messageId: external_exports.string().max(255),
20281
- sessionId: IDENTIFIER
20290
+ sessionId: identifierStringSchema
20282
20291
  }).readonly();
20283
20292
  var agentInstallIdentityFields = {
20284
- agentId: IDENTIFIER,
20285
- requestId: IDENTIFIER
20293
+ agentId: identifierStringSchema,
20294
+ requestId: identifierStringSchema
20286
20295
  };
20287
20296
  var agentInstallRequestCommandSchema = external_exports.strictObject({
20288
20297
  ...agentInstallIdentityFields,
@@ -20290,7 +20299,7 @@ var agentInstallRequestCommandSchema = external_exports.strictObject({
20290
20299
  }).readonly();
20291
20300
  var agentInstallCancelCommandSchema = external_exports.strictObject({
20292
20301
  kind: external_exports.literal(AGENT_INSTALL_CANCEL_KIND),
20293
- requestId: IDENTIFIER
20302
+ requestId: identifierStringSchema
20294
20303
  }).readonly();
20295
20304
  var agentInstallStartedEventSchema = external_exports.strictObject({
20296
20305
  ...agentInstallIdentityFields,
@@ -20315,7 +20324,7 @@ var agentInstallCompletedEventSchema = external_exports.strictObject({
20315
20324
  }).readonly();
20316
20325
  var agentInstallFailedEventSchema = external_exports.strictObject({
20317
20326
  ...agentInstallIdentityFields,
20318
- code: IDENTIFIER,
20327
+ code: identifierStringSchema,
20319
20328
  kind: external_exports.literal(AGENT_INSTALL_FAILED_KIND),
20320
20329
  message: external_exports.string().min(1).max(500)
20321
20330
  }).readonly();
@@ -20447,7 +20456,6 @@ var SessionPromptDisposition = Object.freeze({
20447
20456
  });
20448
20457
 
20449
20458
  // ../protocol/src/codecs/messages.ts
20450
- var IDENTIFIER_PATTERN2 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
20451
20459
  var DIRECTORY_IDENTIFIER_PATTERN2 = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
20452
20460
  var MAX_PROMPT_LENGTH = 1e4;
20453
20461
  var MAX_PROMPT_ATTACHMENT_LENGTH = 6e6;
@@ -20628,11 +20636,11 @@ function readActivityDetail(value) {
20628
20636
  throw new ProtocolMessageError("Invalid activity detail availability");
20629
20637
  }
20630
20638
  function readIdentifier(value, key) {
20631
- const field = readString(value, key, 128);
20632
- if (!IDENTIFIER_PATTERN2.test(field)) {
20633
- throw new ProtocolMessageError(`Invalid identifier field: ${key}`);
20639
+ try {
20640
+ return decodeIdentifier(value[key]);
20641
+ } catch (cause) {
20642
+ throw new ProtocolMessageError(`Invalid identifier field: ${key}`, { cause });
20634
20643
  }
20635
- return field;
20636
20644
  }
20637
20645
  function readDirectoryIdentifier(value, key) {
20638
20646
  const field = readString(value, key, 2048);
@@ -20681,7 +20689,7 @@ function decodeSessionPromptCommand(encoded) {
20681
20689
  const disposition = readPromptDisposition(value);
20682
20690
  const rawTargetCommandId = value["targetCommandId"];
20683
20691
  const targetCommandId = rawTargetCommandId === void 0 ? "" : readText(value, "targetCommandId", 128);
20684
- if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !IDENTIFIER_PATTERN2.test(targetCommandId)) {
20692
+ if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !isIdentifier(targetCommandId)) {
20685
20693
  throw new ProtocolMessageError("Prompt disposition has an invalid target command");
20686
20694
  }
20687
20695
  const sessionConfigurations = hasSessionConfigurations ? decodeSessionConfigurationSelections(value["sessionConfigurations"]) : [];
@@ -20927,8 +20935,13 @@ var availableSessionHistoryObjectSchema = external_exports.strictObject({
20927
20935
  status: external_exports.literal("available"),
20928
20936
  messages: external_exports.array(historyMessage).max(SESSION_HISTORY_MESSAGE_LIMIT).readonly(),
20929
20937
  truncated: external_exports.boolean(),
20930
- coveredCommandIds: external_exports.array(external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/)).max(1e4).readonly(),
20931
- coveredMessageIds: external_exports.array(external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}:(?:user|agent)$/)).max(2e4).readonly().default([])
20938
+ coveredCommandIds: external_exports.array(identifierStringSchema).max(1e4).readonly(),
20939
+ coveredMessageIds: external_exports.array(
20940
+ external_exports.string().refine((value) => {
20941
+ const suffix = value.endsWith(":user") ? ":user" : value.endsWith(":agent") ? ":agent" : null;
20942
+ return suffix !== null && isIdentifier(value.slice(0, -suffix.length));
20943
+ })
20944
+ ).max(2e4).readonly().default([])
20932
20945
  });
20933
20946
  var availableSessionHistorySchema = availableSessionHistoryObjectSchema.readonly();
20934
20947
  var unavailableSessionHistoryObjectSchema = external_exports.strictObject({
@@ -20962,78 +20975,69 @@ var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
20962
20975
  var NATIVE_SESSION_RESULT_KIND = "native.session.result";
20963
20976
  var NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
20964
20977
  var ACTIVE_TURN_TEXT_LIMIT = 1e6;
20965
- var identifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/);
20966
20978
  var directoryId = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
20967
20979
  var envelope = {
20968
- requestId: identifier,
20969
- sessionId: identifier
20980
+ requestId: identifierStringSchema,
20981
+ sessionId: identifierStringSchema
20970
20982
  };
20971
20983
  var identity = {
20972
20984
  ...envelope,
20973
20985
  kind: external_exports.literal(NATIVE_SESSION_REQUEST_KIND),
20974
20986
  additionalDirectoryIds: external_exports.array(directoryId).max(16).readonly(),
20975
- agentId: identifier,
20976
- bindingId: identifier,
20987
+ agentId: identifierStringSchema,
20988
+ bindingId: identifierStringSchema,
20977
20989
  directoryId
20978
20990
  };
20979
20991
  var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
20980
20992
  external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
20981
- external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
20982
- external_exports.strictObject({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifier }).readonly(),
20983
- external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
20984
- external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
20985
- external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
20993
+ external_exports.strictObject({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
20994
+ external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
20995
+ external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
20996
+ external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
20986
20997
  external_exports.strictObject({
20987
20998
  ...identity,
20988
20999
  action: external_exports.literal("list"),
20989
- cursor: identifier.nullable()
21000
+ cursor: identifierStringSchema.nullable()
20990
21001
  }).readonly(),
20991
21002
  external_exports.strictObject({
20992
21003
  ...identity,
20993
21004
  action: external_exports.enum(["import", "fork"]),
20994
- entryId: identifier,
20995
- targetSessionId: identifier
21005
+ entryId: identifierStringSchema,
21006
+ targetSessionId: identifierStringSchema
20996
21007
  }).readonly(),
20997
21008
  external_exports.strictObject({
20998
21009
  ...identity,
20999
21010
  action: external_exports.literal("delete"),
21000
- entryId: identifier
21011
+ entryId: identifierStringSchema
21001
21012
  }).readonly()
21002
21013
  ]);
21003
21014
  var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
21004
21015
  external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
21005
- external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
21006
- external_exports.strictObject({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifier }).readonly(),
21007
- external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
21008
- external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
21009
- external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
21016
+ external_exports.strictObject({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
21017
+ external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
21018
+ external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
21019
+ external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
21010
21020
  external_exports.strictObject({
21011
21021
  ...identity,
21012
21022
  action: external_exports.literal("list"),
21013
- cursor: identifier.nullable()
21023
+ cursor: identifierStringSchema.nullable()
21014
21024
  }).readonly(),
21015
21025
  external_exports.strictObject({
21016
21026
  ...identity,
21017
21027
  action: external_exports.enum(["import", "fork"]),
21018
- entryId: identifier,
21019
- targetSessionId: identifier
21020
- }).readonly(),
21021
- external_exports.strictObject({
21022
- ...identity,
21023
- action: external_exports.enum(["import-only", "fork-only"]),
21024
- entryId: identifier,
21025
- targetSessionId: identifier
21028
+ entryId: identifierStringSchema,
21029
+ targetSessionId: identifierStringSchema
21026
21030
  }).readonly(),
21027
21031
  external_exports.strictObject({
21028
21032
  ...identity,
21029
21033
  action: external_exports.literal("delete"),
21030
- entryId: identifier
21034
+ entryId: identifierStringSchema
21031
21035
  }).readonly()
21032
21036
  ]);
21033
21037
  var nativeSessionEntrySchema = external_exports.strictObject({
21034
- entryId: identifier,
21035
- mobiusSessionIds: external_exports.array(identifier).max(500).readonly(),
21036
- nativeSessionId: identifier,
21038
+ entryId: identifierStringSchema,
21039
+ mobiusSessionIds: external_exports.array(identifierStringSchema).max(500).readonly(),
21040
+ nativeSessionId: identifierStringSchema,
21037
21041
  title: external_exports.string().max(500),
21038
21042
  directoryId,
21039
21043
  directoryLabel: external_exports.string().min(1).max(2048),
@@ -21045,23 +21049,17 @@ var resultEnvelope = {
21045
21049
  kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
21046
21050
  };
21047
21051
  var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21048
- external_exports.strictObject({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifier }).readonly(),
21049
- external_exports.strictObject({
21050
- ...resultEnvelope,
21051
- action: external_exports.literal("linked-history"),
21052
- targetSessionId: identifier,
21053
- history: sessionHistorySchema
21054
- }).readonly(),
21052
+ external_exports.strictObject({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifierStringSchema }).readonly(),
21055
21053
  external_exports.strictObject({
21056
21054
  ...resultEnvelope,
21057
21055
  action: external_exports.literal("active-turn"),
21058
- targetSessionId: identifier,
21056
+ targetSessionId: identifierStringSchema,
21059
21057
  turn: external_exports.strictObject({
21060
- commandId: identifier,
21058
+ commandId: identifierStringSchema,
21061
21059
  prompt: external_exports.string().max(1e5),
21062
21060
  text: external_exports.string().max(ACTIVE_TURN_TEXT_LIMIT),
21063
21061
  truncated: external_exports.boolean(),
21064
- epoch: identifier,
21062
+ epoch: identifierStringSchema,
21065
21063
  interaction: external_exports.discriminatedUnion("kind", [
21066
21064
  sessionPermissionRequestedEventSchema,
21067
21065
  sessionElicitationRequestedEventSchema
@@ -21070,11 +21068,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21070
21068
  state: external_exports.literal("running")
21071
21069
  }).readonly().nullable()
21072
21070
  }).readonly(),
21073
- external_exports.strictObject({
21074
- ...resultEnvelope,
21075
- action: external_exports.literal("unlinked-history"),
21076
- targetSessionId: identifier
21077
- }).readonly(),
21078
21071
  external_exports.strictObject({
21079
21072
  ...resultEnvelope,
21080
21073
  action: external_exports.literal("find"),
@@ -21085,21 +21078,20 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21085
21078
  action: external_exports.literal("list"),
21086
21079
  capabilities: sessionCapabilitiesSchema,
21087
21080
  entries: external_exports.array(nativeSessionEntrySchema).max(500).readonly(),
21088
- nextCursor: identifier.nullable()
21081
+ nextCursor: identifierStringSchema.nullable()
21089
21082
  }).readonly(),
21090
21083
  external_exports.strictObject({
21091
21084
  ...resultEnvelope,
21092
21085
  action: external_exports.enum(["import", "fork"]),
21093
- targetSessionId: identifier,
21086
+ targetSessionId: identifierStringSchema,
21094
21087
  ready: sessionReadyEventSchema,
21095
- history: sessionHistorySchema,
21096
21088
  title: external_exports.string().max(500)
21097
21089
  }).readonly(),
21098
21090
  external_exports.strictObject({
21099
21091
  ...resultEnvelope,
21100
21092
  action: external_exports.literal("preview"),
21101
- entryId: identifier,
21102
- targetSessionId: identifier,
21093
+ entryId: identifierStringSchema,
21094
+ targetSessionId: identifierStringSchema,
21103
21095
  reason: external_exports.enum(["continuation_unavailable", "requested"]),
21104
21096
  history: sessionHistorySchema,
21105
21097
  title: external_exports.string().max(500)
@@ -21107,15 +21099,15 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21107
21099
  external_exports.strictObject({
21108
21100
  ...resultEnvelope,
21109
21101
  action: external_exports.literal("history"),
21110
- entryId: identifier,
21102
+ entryId: identifierStringSchema,
21111
21103
  history: sessionHistorySchema,
21112
21104
  title: external_exports.string().max(500)
21113
21105
  }).readonly(),
21114
21106
  external_exports.strictObject({
21115
21107
  ...resultEnvelope,
21116
21108
  action: external_exports.literal("delete"),
21117
- entryId: identifier,
21118
- deletedSessionIds: external_exports.array(identifier).max(500).readonly()
21109
+ entryId: identifierStringSchema,
21110
+ deletedSessionIds: external_exports.array(identifierStringSchema).max(500).readonly()
21119
21111
  }).readonly()
21120
21112
  ]);
21121
21113
  var nativeSessionCancelSchema = external_exports.strictObject({ ...envelope, kind: external_exports.literal(NATIVE_SESSION_CANCEL_KIND) }).readonly();
@@ -21137,17 +21129,16 @@ var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSch
21137
21129
  // ../protocol/src/session-events.ts
21138
21130
  var SESSION_EVENT_KIND = "session.event";
21139
21131
  var SESSION_EVENT_COMMITTED_KIND = "session.event.committed";
21140
- var IDENTIFIER_PATTERN3 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
21141
21132
  var MAX_RECORDED_EVENT_LENGTH = 8 * 1024 * 1024;
21142
21133
  var eventEnvelopeSchema = external_exports.strictObject({
21143
21134
  kind: external_exports.literal(SESSION_EVENT_KIND),
21144
21135
  payload: external_exports.string().min(2).max(MAX_RECORDED_EVENT_LENGTH),
21145
- sessionId: external_exports.string().min(1).max(128).regex(IDENTIFIER_PATTERN3)
21136
+ sessionId: identifierStringSchema
21146
21137
  }).readonly();
21147
21138
  var committedEventSchema = external_exports.strictObject({
21148
21139
  kind: external_exports.literal(SESSION_EVENT_COMMITTED_KIND),
21149
21140
  payload: external_exports.string().min(2).max(MAX_RECORDED_EVENT_LENGTH),
21150
- sessionId: external_exports.string().min(1).max(128).regex(IDENTIFIER_PATTERN3)
21141
+ sessionId: identifierStringSchema
21151
21142
  }).readonly();
21152
21143
  function decode5(encoded, schema) {
21153
21144
  let value;
@@ -21221,39 +21212,38 @@ var SESSION_LIVE_HISTORY_LOAD_KIND = "session.live-history.load";
21221
21212
  var SESSION_LIVE_HISTORY_LOADED_KIND = "session.live-history.loaded";
21222
21213
  var SESSION_LIVE_HISTORY_PAGE_LOAD_KIND = "session.live-history.page.load";
21223
21214
  var SESSION_LIVE_HISTORY_PAGE_LOADED_KIND = "session.live-history.page.loaded";
21224
- var identifier2 = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/);
21225
21215
  var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
21226
21216
  var sessionLiveHistoryLoadSchema = external_exports.strictObject({
21227
21217
  additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
21228
- agentId: identifier2,
21229
- bindingId: identifier2,
21218
+ agentId: identifierStringSchema,
21219
+ bindingId: identifierStringSchema,
21230
21220
  directoryId: directoryIdentifier,
21231
21221
  kind: external_exports.literal(SESSION_LIVE_HISTORY_LOAD_KIND),
21232
- requestId: identifier2,
21233
- sessionId: identifier2
21222
+ requestId: identifierStringSchema,
21223
+ sessionId: identifierStringSchema
21234
21224
  }).readonly();
21235
21225
  var sessionLiveHistoryLoadedSchema = external_exports.strictObject({
21236
21226
  history: sessionHistorySchema,
21237
21227
  kind: external_exports.literal(SESSION_LIVE_HISTORY_LOADED_KIND),
21238
- requestId: identifier2,
21239
- sessionId: identifier2
21228
+ requestId: identifierStringSchema,
21229
+ sessionId: identifierStringSchema
21240
21230
  }).readonly();
21241
21231
  var sessionLiveHistoryPageLoadSchema = external_exports.strictObject({
21242
21232
  additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
21243
- agentId: identifier2,
21244
- bindingId: identifier2,
21233
+ agentId: identifierStringSchema,
21234
+ bindingId: identifierStringSchema,
21245
21235
  cursor: external_exports.string().min(1).max(512).nullable(),
21246
21236
  directoryId: directoryIdentifier,
21247
21237
  kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOAD_KIND),
21248
21238
  limit: external_exports.number().int().min(1).max(100),
21249
- requestId: identifier2,
21250
- sessionId: identifier2
21239
+ requestId: identifierStringSchema,
21240
+ sessionId: identifierStringSchema
21251
21241
  }).readonly();
21252
21242
  var sessionLiveHistoryPageLoadedSchema = external_exports.strictObject({
21253
21243
  kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOADED_KIND),
21254
21244
  page: nativeMessagePageSchema,
21255
- requestId: identifier2,
21256
- sessionId: identifier2
21245
+ requestId: identifierStringSchema,
21246
+ sessionId: identifierStringSchema
21257
21247
  }).readonly();
21258
21248
  function decode6(schema, encoded) {
21259
21249
  try {
@@ -24179,15 +24169,6 @@ var PendingElicitation = class {
24179
24169
  var PROCESS_STOP_TIMEOUT_MILLISECONDS = 1e3;
24180
24170
  var MAX_PRE_SESSION_UPDATES = 100;
24181
24171
  var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
24182
- function nativeHistoryNotRetained() {
24183
- return {
24184
- cause: {
24185
- code: "native_history_not_retained",
24186
- message: "Native message history is not retained in the cloud for this Session."
24187
- },
24188
- status: "unavailable"
24189
- };
24190
- }
24191
24172
  var NullAcpSessionObserver = class {
24192
24173
  onCommands = () => Promise.resolve();
24193
24174
  onConfig = () => Promise.resolve();
@@ -25934,7 +25915,7 @@ var AcpSessionManager = class {
25934
25915
  return await this.#startRetainedSessionProcess(
25935
25916
  options,
25936
25917
  async () => await AcpProcessSession.start(
25937
- this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
25918
+ options.origin === void 0 && this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
25938
25919
  () => this.#observer,
25939
25920
  this.#store,
25940
25921
  metrics
@@ -26477,26 +26458,7 @@ var AcpSessionManager = class {
26477
26458
  this.#endSessionUse(options.sessionId);
26478
26459
  }
26479
26460
  };
26480
- loadLinkedSessionHistory = async (options) => {
26481
- options.signal.throwIfAborted();
26482
- const stored = this.#store.read(options.sessionId);
26483
- if (!(stored instanceof FoundAcpStoredSession) || !stored.session.prompted) {
26484
- return null;
26485
- }
26486
- const linked = stored.session;
26487
- if (linked.agentId !== options.agent.id || linked.cwd !== options.cwd || linked.additionalDirectories.length !== options.additionalDirectories.length || linked.additionalDirectories.some((directory, index) => directory !== options.additionalDirectories[index])) {
26488
- throw new AcpExecutionError(
26489
- "The session belongs to another Agent or workspace",
26490
- {},
26491
- "session_identity_mismatch"
26492
- );
26493
- }
26494
- if (this.#nativeHistoryReader === null) {
26495
- return await this.loadSessionHistory(options);
26496
- }
26497
- return await this.#nativeHistoryReader.read(options, linked.nativeSessionId) ?? await this.loadSessionHistory(options);
26498
- };
26499
- openNativeSession = async (options, origin, loadHistory) => {
26461
+ openNativeSession = async (options, origin) => {
26500
26462
  const key = `${options.agent.id}:${origin.nativeSessionId}`;
26501
26463
  if (this.#nativeOperations.has(key)) {
26502
26464
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -26526,19 +26488,10 @@ var AcpSessionManager = class {
26526
26488
  }
26527
26489
  this.#nativeOperations.add(key);
26528
26490
  try {
26529
- const history = loadHistory ? await runtime.loadHistory(options.signal) : nativeHistoryNotRetained();
26530
26491
  return {
26531
26492
  prepared: runtime.prepared(),
26532
- sessionId: existing.sessionId,
26533
- history
26493
+ sessionId: existing.sessionId
26534
26494
  };
26535
- } catch (error62) {
26536
- await this.#retireSessionProcess(
26537
- existing.sessionId,
26538
- runtime,
26539
- async () => await runtime.closeProcess()
26540
- );
26541
- throw error62;
26542
26495
  } finally {
26543
26496
  this.#nativeOperations.delete(key);
26544
26497
  this.#notifyProcessCapacityChanged();
@@ -26557,16 +26510,10 @@ var AcpSessionManager = class {
26557
26510
  const openedKey = `${options.agent.id}:${runtime.nativeSessionId()}`;
26558
26511
  this.#nativeOperations.add(openedKey);
26559
26512
  try {
26560
- const history = loadHistory ? await runtime.loadHistory(options.signal) : nativeHistoryNotRetained();
26561
26513
  return {
26562
26514
  sessionId: options.sessionId,
26563
- prepared: runtime.prepared(),
26564
- history
26515
+ prepared: runtime.prepared()
26565
26516
  };
26566
- } catch (error62) {
26567
- this.#store.remove(options.sessionId);
26568
- await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.closeProcess());
26569
- throw error62;
26570
26517
  } finally {
26571
26518
  this.#nativeOperations.delete(openedKey);
26572
26519
  this.#notifyProcessCapacityChanged();
@@ -30537,7 +30484,6 @@ import { dirname as dirname3, join as join15, resolve as resolve4 } from "node:p
30537
30484
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
30538
30485
  var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
30539
30486
  var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
30540
- var IDENTIFIER_PATTERN4 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
30541
30487
  var RUNTIME_CREDENTIAL_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
30542
30488
  var MAX_FILE_LENGTH = 16 * 1024;
30543
30489
  var INSTALLATION_POINTER_KEYS = ["installationId", "version"];
@@ -30615,7 +30561,7 @@ function validateApplicationId(value) {
30615
30561
  return value;
30616
30562
  }
30617
30563
  function validateRemoteAppId(value) {
30618
- if (!IDENTIFIER_PATTERN4.test(value)) {
30564
+ if (!isIdentifier(value)) {
30619
30565
  throw new RuntimeInstallationStoreError("invalid_app_id", "The remote App ID is invalid");
30620
30566
  }
30621
30567
  return value;
@@ -30633,7 +30579,7 @@ function validateInstallationId(value) {
30633
30579
  return value;
30634
30580
  }
30635
30581
  function validateIdentifier(value, code) {
30636
- if (!IDENTIFIER_PATTERN4.test(value)) {
30582
+ if (!isIdentifier(value)) {
30637
30583
  throw new RuntimeInstallationStoreError(code, "The saved Runtime connection is invalid");
30638
30584
  }
30639
30585
  return value;
@@ -31037,7 +30983,6 @@ async function openRuntimeInstallationStore(options, signal) {
31037
30983
  // src/pairing/pair-local-machine.ts
31038
30984
  var PAIRING_TIMEOUT_MILLISECONDS = 2e4;
31039
30985
  var PAIRING_CODE_PATTERN = /^[A-HJ-NP-Z2-9]{4}(?:-[A-HJ-NP-Z2-9]{4}){4}$/;
31040
- var IDENTIFIER_PATTERN5 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
31041
30986
  var TOKEN_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
31042
30987
  var CLAIM_RESPONSE_KEYS = ["appId", "channelId", "daemonToken", "runtimeId"];
31043
30988
  var REDEEM_RESPONSE_KEYS = ["appId", "channelId", "runtimeCredential", "runtimeId"];
@@ -31124,7 +31069,7 @@ function parsePairCommand(arguments_, defaultWorkspace) {
31124
31069
  };
31125
31070
  }
31126
31071
  function validatePairingId(value) {
31127
- if (!IDENTIFIER_PATTERN5.test(value)) {
31072
+ if (!isIdentifier(value)) {
31128
31073
  throw new PairingClientError("invalid_pairing_id", "The Runtime pairing ID is invalid");
31129
31074
  }
31130
31075
  return value;
@@ -31193,7 +31138,7 @@ function decodePairingResponse(value, credentialField, expectedKeys) {
31193
31138
  const channelId = value["channelId"];
31194
31139
  const runtimeCredential2 = value[credentialField];
31195
31140
  const runtimeId = value["runtimeId"];
31196
- if (typeof appId !== "string" || !IDENTIFIER_PATTERN5.test(appId) || typeof channelId !== "string" || !IDENTIFIER_PATTERN5.test(channelId) || typeof runtimeCredential2 !== "string" || !TOKEN_PATTERN.test(runtimeCredential2) || typeof runtimeId !== "string" || !IDENTIFIER_PATTERN5.test(runtimeId)) {
31141
+ if (typeof appId !== "string" || !isIdentifier(appId) || typeof channelId !== "string" || !isIdentifier(channelId) || typeof runtimeCredential2 !== "string" || !TOKEN_PATTERN.test(runtimeCredential2) || typeof runtimeId !== "string" || !isIdentifier(runtimeId)) {
31197
31142
  throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
31198
31143
  }
31199
31144
  return { appId, channelId, runtimeCredential: runtimeCredential2, runtimeId };
@@ -31871,7 +31816,6 @@ var ARTIFACT_SCHEME = "mobius-artifact:";
31871
31816
  var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
31872
31817
  var MAX_AGENT_IMAGE_BASE64_LENGTH = 4e6;
31873
31818
  var MAX_AGENT_RESOURCE_BYTE_LENGTH = 1e6;
31874
- var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
31875
31819
  var PromptArtifactError = class extends Error {
31876
31820
  code;
31877
31821
  constructor(code, message, options = {}) {
@@ -31914,7 +31858,7 @@ function parseReference(resource) {
31914
31858
  const encodedByteLength2 = url2.searchParams.get("byteLength") ?? "";
31915
31859
  const sha256 = url2.searchParams.get("sha256") ?? "";
31916
31860
  const byteLength = Number(encodedByteLength2);
31917
- if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !IDENTIFIER_PATTERN6.test(artifactId) || keys.length !== 2 || keys[0] !== "byteLength" || keys[1] !== "sha256" || !/^[1-9][0-9]*$/.test(encodedByteLength2) || !Number.isSafeInteger(byteLength) || !/^[a-f0-9]{64}$/.test(sha256)) {
31861
+ if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !isIdentifier(artifactId) || keys.length !== 2 || keys[0] !== "byteLength" || keys[1] !== "sha256" || !/^[1-9][0-9]*$/.test(encodedByteLength2) || !Number.isSafeInteger(byteLength) || !/^[a-f0-9]{64}$/.test(sha256)) {
31918
31862
  throw new PromptArtifactError("artifact_reference_invalid", "The prompt artifact reference is invalid");
31919
31863
  }
31920
31864
  return new PromptArtifactReference(artifactId, byteLength, sha256, resource);
@@ -34312,7 +34256,7 @@ var ActiveDaemonTurn = class {
34312
34256
  #truncated = false;
34313
34257
  #sequence = 0;
34314
34258
  #interaction = null;
34315
- #epoch = randomUUID3();
34259
+ #epoch = decodeIdentifier(randomUUID3());
34316
34260
  constructor(command, attemptId) {
34317
34261
  this.attemptId = attemptId;
34318
34262
  this.command = command;
@@ -34348,7 +34292,7 @@ var ActiveDaemonTurn = class {
34348
34292
  }
34349
34293
  };
34350
34294
  snapshot = () => this.#accepted ? {
34351
- commandId: this.command.commandId,
34295
+ commandId: decodeIdentifier(this.command.commandId),
34352
34296
  prompt: this.command.prompt,
34353
34297
  text: this.#text,
34354
34298
  truncated: this.#truncated,
@@ -34899,7 +34843,7 @@ function createNativeSessionRequestHandler(dependencies) {
34899
34843
  };
34900
34844
  const handle = (command) => {
34901
34845
  const previous = [...pending.values()].filter((request) => request.agentId === command.agentId);
34902
- const parallelRead = command.action === "linked-history" || command.action === "active-turn";
34846
+ const parallelRead = command.action === "active-turn";
34903
34847
  if (pending.has(command.requestId) || pending.size >= 4 || !parallelRead && previous.some((request) => !request.controller.signal.aborted)) {
34904
34848
  reportOperationFailure(
34905
34849
  socket,
@@ -35018,7 +34962,6 @@ async function readAcpHistory(sessions, directories, bindingId, options, nativeS
35018
34962
 
35019
34963
  // src/native-sessions/acp-adapter.ts
35020
34964
  var acpSessionAdapter = {
35021
- linkedHistory: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
35022
34965
  history: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
35023
34966
  preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
35024
34967
  };
@@ -35038,7 +34981,6 @@ async function verifiedHistory(context, full) {
35038
34981
  return snapshot.history;
35039
34982
  }
35040
34983
  var codexSessionAdapter = {
35041
- linkedHistory: async (context) => await verifiedHistory(context, true),
35042
34984
  history: async (context) => await verifiedHistory(context, true),
35043
34985
  // Codex enforces an exclusive writer per thread. Its read-only app-server
35044
34986
  // history path keeps externally owned conversations previewable.
@@ -35047,9 +34989,6 @@ var codexSessionAdapter = {
35047
34989
 
35048
34990
  // src/native-sessions/agent-adapter.ts
35049
34991
  var genericSessionAdapter = {
35050
- linkedHistory: async () => {
35051
- throw new AcpExecutionError("This Agent does not support Chat history", {}, "native_session_unsupported");
35052
- },
35053
34992
  history: async () => {
35054
34993
  throw new AcpExecutionError("Native history is unavailable for this Agent", {}, "native_session_unsupported");
35055
34994
  },
@@ -35109,42 +35048,6 @@ var NativeSessionService = class {
35109
35048
  turn: this.#activeTurn(command)
35110
35049
  };
35111
35050
  }
35112
- if (command.action === "linked-history") {
35113
- const nativeSessionId = nativeSessionIdSchema.parse(command.targetSessionId);
35114
- if (this.#sessions.hasPreparedSession(nativeSessionId, options.agent.id, cwd, additionalDirectories) && await this.#sessions.loadLinkedSessionHistory({ ...options, sessionId: nativeSessionId }) === null) {
35115
- this.record(command, "native_session_history_read");
35116
- return {
35117
- action: "linked-history",
35118
- history: {
35119
- status: "available",
35120
- messages: [],
35121
- truncated: false,
35122
- coveredCommandIds: [],
35123
- coveredMessageIds: []
35124
- },
35125
- kind: "native.session.result",
35126
- requestId: command.requestId,
35127
- sessionId: command.sessionId,
35128
- targetSessionId: command.targetSessionId
35129
- };
35130
- }
35131
- const history = await nativeSessionAdapter(options.agent.id).linkedHistory({
35132
- sessions: this.#sessions,
35133
- directories: this.#directories,
35134
- bindingId: command.bindingId,
35135
- options,
35136
- nativeSessionId
35137
- });
35138
- this.record(command, "native_session_history_read");
35139
- return {
35140
- action: "linked-history",
35141
- history,
35142
- kind: "native.session.result",
35143
- requestId: command.requestId,
35144
- sessionId: command.sessionId,
35145
- targetSessionId: command.targetSessionId
35146
- };
35147
- }
35148
35051
  if (command.action === "create") {
35149
35052
  if (!supportsNativeChat(options.agent.id)) {
35150
35053
  throw new AcpExecutionError(
@@ -35159,7 +35062,7 @@ var NativeSessionService = class {
35159
35062
  return {
35160
35063
  action: "create",
35161
35064
  kind: "native.session.result",
35162
- nativeSessionId,
35065
+ nativeSessionId: decodeIdentifier(nativeSessionId),
35163
35066
  requestId: command.requestId,
35164
35067
  sessionId: command.sessionId
35165
35068
  };
@@ -35179,7 +35082,7 @@ var NativeSessionService = class {
35179
35082
  if (authorized === null) {
35180
35083
  return null;
35181
35084
  }
35182
- const entryId = randomUUID4();
35085
+ const entryId = decodeIdentifier(randomUUID4());
35183
35086
  if (this.#entries.size >= 5e3) {
35184
35087
  this.#entries.clear();
35185
35088
  }
@@ -35191,8 +35094,8 @@ var NativeSessionService = class {
35191
35094
  });
35192
35095
  return {
35193
35096
  entryId,
35194
- mobiusSessionIds: this.#sessions.findLinkedSessions(command.agentId, info.sessionId).filter((session) => session.prompted && session.cwd === authorized.cwd).map((session) => session.sessionId),
35195
- nativeSessionId: info.sessionId,
35097
+ mobiusSessionIds: this.#sessions.findLinkedSessions(command.agentId, info.sessionId).filter((session) => session.prompted && session.cwd === authorized.cwd).map((session) => decodeIdentifier(session.sessionId)),
35098
+ nativeSessionId: decodeIdentifier(info.sessionId),
35196
35099
  title: info.title ?? "Untitled session",
35197
35100
  directoryId: authorized.directoryId,
35198
35101
  directoryLabel: authorized.directoryLabel,
@@ -35235,7 +35138,7 @@ var NativeSessionService = class {
35235
35138
  "invalid_native_session_response"
35236
35139
  );
35237
35140
  }
35238
- nextCursor = randomUUID4();
35141
+ nextCursor = decodeIdentifier(randomUUID4());
35239
35142
  if (this.#cursors.size >= 500) {
35240
35143
  this.#cursors.clear();
35241
35144
  }
@@ -35352,10 +35255,10 @@ var NativeSessionService = class {
35352
35255
  ...envelope2,
35353
35256
  action: "delete",
35354
35257
  entryId: command.entryId,
35355
- deletedSessionIds
35258
+ deletedSessionIds: deletedSessionIds.map(decodeIdentifier)
35356
35259
  };
35357
35260
  }
35358
- const action = command.action === "import-only" ? "import" : command.action === "fork-only" ? "fork" : command.action;
35261
+ const action = command.action;
35359
35262
  if (action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
35360
35263
  throw new AcpExecutionError("This Agent cannot import native sessions", {}, "native_session_unsupported");
35361
35264
  }
@@ -35380,8 +35283,7 @@ var NativeSessionService = class {
35380
35283
  sessionId: command.targetSessionId,
35381
35284
  additionalDirectories: target.additionalDirectories
35382
35285
  },
35383
- { kind: action, nativeSessionId: target.info.sessionId },
35384
- command.action !== "import-only" && command.action !== "fork-only"
35286
+ { kind: action, nativeSessionId: target.info.sessionId }
35385
35287
  );
35386
35288
  signal.throwIfAborted();
35387
35289
  const ready = {
@@ -35405,8 +35307,7 @@ var NativeSessionService = class {
35405
35307
  action,
35406
35308
  ready,
35407
35309
  targetSessionId: command.targetSessionId,
35408
- title: target.info.title ?? "Untitled session",
35409
- history: opened.history
35310
+ title: target.info.title ?? "Untitled session"
35410
35311
  };
35411
35312
  };
35412
35313
  querySessions = async (sessionIds, signal) => {
@@ -36393,6 +36294,19 @@ async function runRelayConnection(config2, directories, audit, sessions, install
36393
36294
  );
36394
36295
  return;
36395
36296
  }
36297
+ if (kind === SESSION_QUERY_KIND) {
36298
+ const command2 = message;
36299
+ void nativeSessions.querySessions(command2.sessionIds, connectionController.signal).then((entries) => {
36300
+ send(socket, {
36301
+ entries,
36302
+ kind: SESSION_QUERIED_KIND,
36303
+ requestId: command2.requestId
36304
+ });
36305
+ }).catch((error62) => {
36306
+ reportOperationFailure(socket, command2.requestId, "", error62);
36307
+ });
36308
+ return;
36309
+ }
36396
36310
  if (kind === SESSION_PERMISSION_RESPOND_KIND) {
36397
36311
  const command2 = message;
36398
36312
  void sessions.respondPermission(command2).then(() => {
@@ -36715,7 +36629,6 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
36715
36629
  // src/runtime.ts
36716
36630
  import { mkdir as mkdir6, realpath as realpath10, stat as stat9 } from "node:fs/promises";
36717
36631
  import { resolve as resolve7 } from "node:path";
36718
- var IDENTIFIER_PATTERN7 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
36719
36632
  var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
36720
36633
  var MobiusRuntimeConfigurationError = class extends Error {
36721
36634
  code = "runtime_configuration_invalid";
@@ -36767,7 +36680,7 @@ function relayUrlFromConnection(connection) {
36767
36680
  }
36768
36681
  function loadMobiusRuntimeConnection(environment = process.env) {
36769
36682
  const channelId = requiredEnvironmentValue(environment, "MOBIUS_CHANNEL_ID");
36770
- if (!IDENTIFIER_PATTERN7.test(channelId)) {
36683
+ if (!isIdentifier(channelId)) {
36771
36684
  throw new MobiusRuntimeConfigurationError("MOBIUS_CHANNEL_ID is invalid");
36772
36685
  }
36773
36686
  return Object.freeze({