@moxt-ai/mobius 0.0.173 → 0.0.175

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 (86) hide show
  1. package/dist/acp/agent-runtime-manager.d.ts +0 -1
  2. package/dist/acp/agent-runtime-manager.d.ts.map +1 -1
  3. package/dist/acp/agent-runtime-manager.js +2 -37
  4. package/dist/acp/agent-runtime-manager.js.map +1 -1
  5. package/dist/acp/agent-session.d.ts +0 -1
  6. package/dist/acp/agent-session.d.ts.map +1 -1
  7. package/dist/acp/agent-session.js +5 -17
  8. package/dist/acp/agent-session.js.map +1 -1
  9. package/dist/acp/session-store.d.ts +1 -8
  10. package/dist/acp/session-store.d.ts.map +1 -1
  11. package/dist/acp/session-store.js +8 -73
  12. package/dist/acp/session-store.js.map +1 -1
  13. package/dist/agent-catalog/agent-specification.js +1 -1
  14. package/dist/cli.js +66 -981
  15. package/dist/cli.js.map +4 -4
  16. package/dist/daemon-command-handler.d.ts +1 -2
  17. package/dist/daemon-command-handler.d.ts.map +1 -1
  18. package/dist/daemon-command-handler.js +6 -27
  19. package/dist/daemon-command-handler.js.map +1 -1
  20. package/dist/daemon-history-commands.d.ts +1 -3
  21. package/dist/daemon-history-commands.d.ts.map +1 -1
  22. package/dist/daemon-history-commands.js +1 -48
  23. package/dist/daemon-history-commands.js.map +1 -1
  24. package/dist/daemon-turn-registry.d.ts +13 -13
  25. package/dist/generated/acp-session-store-migrations.d.ts +3 -0
  26. package/dist/generated/acp-session-store-migrations.d.ts.map +1 -1
  27. package/dist/generated/acp-session-store-migrations.js +5 -1
  28. package/dist/generated/acp-session-store-migrations.js.map +1 -1
  29. package/dist/index.js +65 -980
  30. package/dist/index.js.map +4 -4
  31. package/dist/native-sessions/handle-native-requests.d.ts +0 -2
  32. package/dist/native-sessions/handle-native-requests.d.ts.map +1 -1
  33. package/dist/native-sessions/handle-native-requests.js +1 -12
  34. package/dist/native-sessions/handle-native-requests.js.map +1 -1
  35. package/dist/native-sessions/service.d.ts.map +1 -1
  36. package/dist/native-sessions/service.js +0 -117
  37. package/dist/native-sessions/service.js.map +1 -1
  38. package/dist/relay-connection/run-relay-connection.d.ts +1 -2
  39. package/dist/relay-connection/run-relay-connection.d.ts.map +1 -1
  40. package/dist/relay-connection/run-relay-connection.js +1 -2
  41. package/dist/relay-connection/run-relay-connection.js.map +1 -1
  42. package/dist/run-daemon.d.ts +0 -1
  43. package/dist/run-daemon.d.ts.map +1 -1
  44. package/dist/run-daemon.js +0 -6
  45. package/dist/run-daemon.js.map +1 -1
  46. package/dist/runtime.d.ts +0 -1
  47. package/dist/runtime.d.ts.map +1 -1
  48. package/dist/runtime.js +67 -982
  49. package/dist/runtime.js.map +4 -4
  50. package/dist/schema/acp-session-store/acp-session.d.ts +0 -16
  51. package/dist/schema/acp-session-store/acp-session.d.ts.map +1 -1
  52. package/dist/schema/acp-session-store/acp-session.js +0 -1
  53. package/dist/schema/acp-session-store/acp-session.js.map +1 -1
  54. package/dist/schema/acp-session-store/index.d.ts +0 -1
  55. package/dist/schema/acp-session-store/index.d.ts.map +1 -1
  56. package/dist/schema/acp-session-store/index.js +0 -1
  57. package/dist/schema/acp-session-store/index.js.map +1 -1
  58. package/package.json +1 -1
  59. package/dist/agent-catalog/handle-agent-catalog-refresh.d.ts +0 -21
  60. package/dist/agent-catalog/handle-agent-catalog-refresh.d.ts.map +0 -1
  61. package/dist/agent-catalog/handle-agent-catalog-refresh.js +0 -119
  62. package/dist/agent-catalog/handle-agent-catalog-refresh.js.map +0 -1
  63. package/dist/native-sessions/acp-adapter.d.ts +0 -3
  64. package/dist/native-sessions/acp-adapter.d.ts.map +0 -1
  65. package/dist/native-sessions/acp-adapter.js +0 -6
  66. package/dist/native-sessions/acp-adapter.js.map +0 -1
  67. package/dist/native-sessions/acp-history.d.ts +0 -6
  68. package/dist/native-sessions/acp-history.d.ts.map +0 -1
  69. package/dist/native-sessions/acp-history.js +0 -27
  70. package/dist/native-sessions/acp-history.js.map +0 -1
  71. package/dist/native-sessions/agent-adapter.d.ts +0 -16
  72. package/dist/native-sessions/agent-adapter.d.ts.map +0 -1
  73. package/dist/native-sessions/agent-adapter.js +0 -19
  74. package/dist/native-sessions/agent-adapter.js.map +0 -1
  75. package/dist/native-sessions/codex-adapter.d.ts +0 -3
  76. package/dist/native-sessions/codex-adapter.d.ts.map +0 -1
  77. package/dist/native-sessions/codex-adapter.js +0 -20
  78. package/dist/native-sessions/codex-adapter.js.map +0 -1
  79. package/dist/native-sessions/live-history-page.d.ts +0 -4
  80. package/dist/native-sessions/live-history-page.d.ts.map +0 -1
  81. package/dist/native-sessions/live-history-page.js +0 -258
  82. package/dist/native-sessions/live-history-page.js.map +0 -1
  83. package/dist/schema/acp-session-store/deleted-acp-session.d.ts +0 -24
  84. package/dist/schema/acp-session-store/deleted-acp-session.d.ts.map +0 -1
  85. package/dist/schema/acp-session-store/deleted-acp-session.js +0 -5
  86. package/dist/schema/acp-session-store/deleted-acp-session.js.map +0 -1
package/dist/runtime.js CHANGED
@@ -19789,9 +19789,6 @@ var AGENT_INSTALL_CANCELLED_KIND = "agent.integration.install.cancelled";
19789
19789
  var AGENT_SETTINGS_DISCOVER_KIND = "agent.settings.discover";
19790
19790
  var AGENT_SETTINGS_DISCOVERED_KIND = "agent.settings.discovered";
19791
19791
  var AGENT_SETTINGS_DISCOVERY_FAILED_KIND = "agent.settings.discovery.failed";
19792
- var AGENT_CATALOG_REFRESH_KIND = "agent.catalog.refresh";
19793
- var AGENT_CATALOG_REFRESHED_KIND = "agent.catalog.refreshed";
19794
- var AGENT_CATALOG_REFRESH_FAILED_KIND = "agent.catalog.refresh.failed";
19795
19792
  var FILE_READ_KIND = "file.read";
19796
19793
  var FILE_BEGIN_KIND = "file.begin";
19797
19794
  var FILE_CHUNK_KIND = "file.chunk";
@@ -19953,20 +19950,6 @@ var agentSettingsDiscoveryFailedEventSchema = external_exports.object({
19953
19950
  message: external_exports.string().min(1).max(500),
19954
19951
  requestId: identifierStringSchema
19955
19952
  }).readonly();
19956
- var agentCatalogRefreshCommandSchema = external_exports.object({
19957
- kind: external_exports.literal(AGENT_CATALOG_REFRESH_KIND),
19958
- requestId: identifierStringSchema
19959
- }).readonly();
19960
- var agentCatalogRefreshedEventSchema = external_exports.object({
19961
- kind: external_exports.literal(AGENT_CATALOG_REFRESHED_KIND),
19962
- requestId: identifierStringSchema
19963
- }).readonly();
19964
- var agentCatalogRefreshFailedEventSchema = external_exports.object({
19965
- code: identifierStringSchema,
19966
- kind: external_exports.literal(AGENT_CATALOG_REFRESH_FAILED_KIND),
19967
- message: external_exports.string().min(1).max(500),
19968
- requestId: identifierStringSchema
19969
- }).readonly();
19970
19953
  var sessionConfigurationSelectionSchema = external_exports.object({
19971
19954
  booleanValue: external_exports.boolean(),
19972
19955
  configId: identifierStringSchema,
@@ -20371,12 +20354,6 @@ var decodeAgentSettingsDiscoveredEvent = (encoded) => decode3(encoded, agentSett
20371
20354
  var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
20372
20355
  var decodeAgentSettingsDiscoveryFailedEvent = (encoded) => decode3(encoded, agentSettingsDiscoveryFailedEventSchema);
20373
20356
  var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
20374
- var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
20375
- var encodeAgentCatalogRefreshCommand = (message) => encode3(message, agentCatalogRefreshCommandSchema);
20376
- var decodeAgentCatalogRefreshedEvent = (encoded) => decode3(encoded, agentCatalogRefreshedEventSchema);
20377
- var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
20378
- var decodeAgentCatalogRefreshFailedEvent = (encoded) => decode3(encoded, agentCatalogRefreshFailedEventSchema);
20379
- var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
20380
20357
  var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
20381
20358
  var encodeFileReadCommand = (message) => encode3(message, fileReadCommandSchema);
20382
20359
  var decodeFileBeginEvent = (encoded) => decode3(encoded, fileBeginEventSchema);
@@ -20445,6 +20422,8 @@ var SESSION_CANCEL_KIND = "session.cancel";
20445
20422
  var RUNTIME_LIVENESS_READY_KIND = "runtime.liveness.ready";
20446
20423
  var RUNTIME_HEARTBEAT_KIND = "runtime.heartbeat";
20447
20424
  var RUNTIME_HEARTBEAT_ACK_KIND = "runtime.heartbeat.ack";
20425
+ var RUNTIME_PING_KIND = "runtime.ping";
20426
+ var RUNTIME_PONG_KIND = "runtime.pong";
20448
20427
  var SESSION_STARTED_KIND = "session.started";
20449
20428
  var SESSION_QUEUED_KIND = "session.queued";
20450
20429
  var AGENT_MESSAGE_DELTA_KIND = "agent.message.delta";
@@ -20757,6 +20736,16 @@ function decodeRuntimeHeartbeatAckEvent(encoded) {
20757
20736
  kind: RUNTIME_HEARTBEAT_ACK_KIND
20758
20737
  };
20759
20738
  }
20739
+ function decodeRuntimePingCommand(encoded) {
20740
+ const value = parseJson2(encoded);
20741
+ assertKind(value, RUNTIME_PING_KIND);
20742
+ return { kind: RUNTIME_PING_KIND, requestId: readIdentifier(value, "requestId") };
20743
+ }
20744
+ function decodeRuntimePongEvent(encoded) {
20745
+ const value = parseJson2(encoded);
20746
+ assertKind(value, RUNTIME_PONG_KIND);
20747
+ return { kind: RUNTIME_PONG_KIND, requestId: readIdentifier(value, "requestId") };
20748
+ }
20760
20749
  function decodeSessionStartedEvent(encoded) {
20761
20750
  const value = parseJson2(encoded);
20762
20751
  assertKind(value, SESSION_STARTED_KIND);
@@ -20854,6 +20843,12 @@ function encodeRuntimeHeartbeatEvent(message) {
20854
20843
  function encodeRuntimeHeartbeatAckEvent(message) {
20855
20844
  return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
20856
20845
  }
20846
+ function encodeRuntimePingCommand(message) {
20847
+ return JSON.stringify(decodeRuntimePingCommand(JSON.stringify(message)));
20848
+ }
20849
+ function encodeRuntimePongEvent(message) {
20850
+ return JSON.stringify(decodeRuntimePongEvent(JSON.stringify(message)));
20851
+ }
20857
20852
  function decodeAgentActivityNarrationEvent(encoded) {
20858
20853
  const value = parseJson2(encoded);
20859
20854
  assertKind(value, AGENT_ACTIVITY_NARRATION_KIND);
@@ -20967,10 +20962,6 @@ function withinHistoryContentLimits(history) {
20967
20962
  ) <= SESSION_HISTORY_IMAGE_CHARACTER_LIMIT;
20968
20963
  }
20969
20964
  var sessionHistorySchema = external_exports.discriminatedUnion("status", [availableSessionHistorySchema, unavailableSessionHistorySchema]).refine(withinHistoryContentLimits);
20970
- var nativeMessagePageSchema = external_exports.discriminatedUnion("status", [
20971
- availableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.string().max(512).nullable() }).readonly(),
20972
- unavailableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.null() }).readonly()
20973
- ]).refine(withinHistoryContentLimits);
20974
20965
 
20975
20966
  // ../protocol/src/native-sessions.ts
20976
20967
  var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
@@ -21036,10 +21027,7 @@ var identity = {
21036
21027
  directoryId
21037
21028
  };
21038
21029
  var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
21039
- external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
21040
21030
  external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
21041
- external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
21042
- external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
21043
21031
  external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
21044
21032
  external_exports.object({
21045
21033
  ...identity,
@@ -21051,24 +21039,10 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
21051
21039
  action: external_exports.enum(["import", "fork"]),
21052
21040
  entryId: identifierStringSchema,
21053
21041
  targetSessionId: identifierStringSchema
21054
- }).readonly(),
21055
- external_exports.object({
21056
- ...identity,
21057
- action: external_exports.literal("fork-recorded"),
21058
- targetSessionId: identifierStringSchema,
21059
- throughCommandId: identifierStringSchema
21060
- }).readonly(),
21061
- external_exports.object({
21062
- ...identity,
21063
- action: external_exports.literal("delete"),
21064
- entryId: identifierStringSchema
21065
21042
  }).readonly()
21066
21043
  ]);
21067
21044
  var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
21068
- external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
21069
21045
  external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
21070
- external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
21071
- external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
21072
21046
  external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
21073
21047
  external_exports.object({
21074
21048
  ...identity,
@@ -21080,17 +21054,6 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
21080
21054
  action: external_exports.enum(["import", "fork"]),
21081
21055
  entryId: identifierStringSchema,
21082
21056
  targetSessionId: identifierStringSchema
21083
- }).readonly(),
21084
- external_exports.object({
21085
- ...identity,
21086
- action: external_exports.literal("fork-recorded"),
21087
- targetSessionId: identifierStringSchema,
21088
- throughCommandId: identifierStringSchema
21089
- }).readonly(),
21090
- external_exports.object({
21091
- ...identity,
21092
- action: external_exports.literal("delete"),
21093
- entryId: identifierStringSchema
21094
21057
  }).readonly()
21095
21058
  ]);
21096
21059
  var nativeSessionEntrySchema = external_exports.object({
@@ -21108,7 +21071,6 @@ var resultEnvelope = {
21108
21071
  kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
21109
21072
  };
21110
21073
  var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21111
- external_exports.object({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifierStringSchema }).readonly(),
21112
21074
  external_exports.object({
21113
21075
  ...resultEnvelope,
21114
21076
  action: external_exports.literal("active-turn"),
@@ -21136,32 +21098,10 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21136
21098
  }).readonly(),
21137
21099
  external_exports.object({
21138
21100
  ...resultEnvelope,
21139
- action: external_exports.enum(["import", "fork", "fork-recorded"]),
21101
+ action: external_exports.enum(["import", "fork"]),
21140
21102
  targetSessionId: identifierStringSchema,
21141
21103
  ready: sessionReadyEventSchema,
21142
21104
  title: external_exports.string().max(500)
21143
- }).readonly(),
21144
- external_exports.object({
21145
- ...resultEnvelope,
21146
- action: external_exports.literal("preview"),
21147
- entryId: identifierStringSchema,
21148
- targetSessionId: identifierStringSchema,
21149
- reason: external_exports.enum(["continuation_unavailable", "requested"]),
21150
- history: sessionHistorySchema,
21151
- title: external_exports.string().max(500)
21152
- }).readonly(),
21153
- external_exports.object({
21154
- ...resultEnvelope,
21155
- action: external_exports.literal("history"),
21156
- entryId: identifierStringSchema,
21157
- history: sessionHistorySchema,
21158
- title: external_exports.string().max(500)
21159
- }).readonly(),
21160
- external_exports.object({
21161
- ...resultEnvelope,
21162
- action: external_exports.literal("delete"),
21163
- entryId: identifierStringSchema,
21164
- deletedSessionIds: external_exports.array(identifierStringSchema).max(500).readonly()
21165
21105
  }).readonly()
21166
21106
  ]);
21167
21107
  var nativeSessionCancelSchema = external_exports.object({ ...envelope, kind: external_exports.literal(NATIVE_SESSION_CANCEL_KIND) }).readonly();
@@ -21727,28 +21667,9 @@ function decodeRecordedSessionEvent(encoded) {
21727
21667
  var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
21728
21668
 
21729
21669
  // ../protocol/src/session-live-history.ts
21730
- var SESSION_LIVE_HISTORY_PAGE_LOAD_KIND = "session.live-history.page.load";
21731
- var SESSION_LIVE_HISTORY_PAGE_LOADED_KIND = "session.live-history.page.loaded";
21732
21670
  var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
21733
21671
  var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
21734
21672
  var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
21735
- var sessionLiveHistoryPageLoadSchema = external_exports.object({
21736
- additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
21737
- agentId: identifierStringSchema,
21738
- bindingId: identifierStringSchema,
21739
- cursor: external_exports.string().min(1).max(512).nullable(),
21740
- directoryId: directoryIdentifier,
21741
- kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOAD_KIND),
21742
- limit: external_exports.number().int().min(1).max(100),
21743
- requestId: identifierStringSchema,
21744
- sessionId: identifierStringSchema
21745
- }).readonly();
21746
- var sessionLiveHistoryPageLoadedSchema = external_exports.object({
21747
- kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOADED_KIND),
21748
- page: nativeMessagePageSchema,
21749
- requestId: identifierStringSchema,
21750
- sessionId: identifierStringSchema
21751
- }).readonly();
21752
21673
  var sessionLiveHistoryV2PageLoadSchema = external_exports.object({
21753
21674
  additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
21754
21675
  agentId: identifierStringSchema,
@@ -21774,10 +21695,6 @@ function decode7(schema, encoded) {
21774
21695
  throw new ProtocolMessageError("Invalid live Session history message", { cause });
21775
21696
  }
21776
21697
  }
21777
- var decodeSessionLiveHistoryPageLoad = (encoded) => decode7(sessionLiveHistoryPageLoadSchema, encoded);
21778
- var decodeSessionLiveHistoryPageLoaded = (encoded) => decode7(sessionLiveHistoryPageLoadedSchema, encoded);
21779
- var encodeSessionLiveHistoryPageLoad = (value) => JSON.stringify(sessionLiveHistoryPageLoadSchema.parse(value));
21780
- var encodeSessionLiveHistoryPageLoaded = (value) => JSON.stringify(sessionLiveHistoryPageLoadedSchema.parse(value));
21781
21698
  var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode7(sessionLiveHistoryV2PageLoadSchema, encoded);
21782
21699
  var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode7(sessionLiveHistoryV2PageLoadedSchema, encoded);
21783
21700
  var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
@@ -21794,11 +21711,6 @@ function defineMessageSignature(kind, encoder, decoder) {
21794
21711
  };
21795
21712
  }
21796
21713
  var serviceToDaemonSignatures = {
21797
- [AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
21798
- AGENT_CATALOG_REFRESH_KIND,
21799
- encodeAgentCatalogRefreshCommand,
21800
- decodeAgentCatalogRefreshCommand
21801
- ),
21802
21714
  [AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
21803
21715
  AGENT_INSTALL_CANCEL_KIND,
21804
21716
  encodeAgentInstallCancelCommand,
@@ -21841,6 +21753,7 @@ var serviceToDaemonSignatures = {
21841
21753
  encodeRuntimeLivenessReadyEvent,
21842
21754
  decodeRuntimeLivenessReadyEvent
21843
21755
  ),
21756
+ [RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
21844
21757
  [SESSION_CANCEL_KIND]: defineMessageSignature(
21845
21758
  SESSION_CANCEL_KIND,
21846
21759
  encodeSessionCancelCommand,
@@ -21856,11 +21769,6 @@ var serviceToDaemonSignatures = {
21856
21769
  encodeSessionElicitationRespondCommand,
21857
21770
  decodeSessionElicitationRespondCommand
21858
21771
  ),
21859
- [SESSION_LIVE_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
21860
- SESSION_LIVE_HISTORY_PAGE_LOAD_KIND,
21861
- encodeSessionLiveHistoryPageLoad,
21862
- decodeSessionLiveHistoryPageLoad
21863
- ),
21864
21772
  [SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND]: defineMessageSignature(
21865
21773
  SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND,
21866
21774
  encodeSessionLiveHistoryV2PageLoad,
@@ -21902,16 +21810,6 @@ function decodeServiceToDaemonMessage(encoded) {
21902
21810
  return signature.decoder(encoded);
21903
21811
  }
21904
21812
  var daemonToServiceSignatures = {
21905
- [AGENT_CATALOG_REFRESHED_KIND]: defineMessageSignature(
21906
- AGENT_CATALOG_REFRESHED_KIND,
21907
- encodeAgentCatalogRefreshedEvent,
21908
- decodeAgentCatalogRefreshedEvent
21909
- ),
21910
- [AGENT_CATALOG_REFRESH_FAILED_KIND]: defineMessageSignature(
21911
- AGENT_CATALOG_REFRESH_FAILED_KIND,
21912
- encodeAgentCatalogRefreshFailedEvent,
21913
- decodeAgentCatalogRefreshFailedEvent
21914
- ),
21915
21813
  [AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
21916
21814
  AGENT_INSTALL_CANCELLED_KIND,
21917
21815
  encodeAgentInstallCancelledEvent,
@@ -21981,6 +21879,7 @@ var daemonToServiceSignatures = {
21981
21879
  encodeRuntimeHeartbeatEvent,
21982
21880
  decodeRuntimeHeartbeatEvent
21983
21881
  ),
21882
+ [RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
21984
21883
  [SESSION_EVENT_KIND]: defineMessageSignature(
21985
21884
  SESSION_EVENT_KIND,
21986
21885
  encodeSessionEventEnvelope,
@@ -21996,11 +21895,6 @@ var daemonToServiceSignatures = {
21996
21895
  encodeSessionOperationFailedEvent,
21997
21896
  decodeSessionOperationFailedEvent
21998
21897
  ),
21999
- [SESSION_LIVE_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
22000
- SESSION_LIVE_HISTORY_PAGE_LOADED_KIND,
22001
- encodeSessionLiveHistoryPageLoaded,
22002
- decodeSessionLiveHistoryPageLoaded
22003
- ),
22004
21898
  [SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND]: defineMessageSignature(
22005
21899
  SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
22006
21900
  encodeSessionLiveHistoryV2PageLoaded,
@@ -34372,6 +34266,10 @@ var acpSessionStoreMigrations = [
34372
34266
  {
34373
34267
  "name": "0003_silky_ravenous.sql",
34374
34268
  "sql": "DROP TABLE `session_event_v2`;"
34269
+ },
34270
+ {
34271
+ "name": "0004_special_mathemanic.sql",
34272
+ "sql": "DROP TABLE `deleted_acp_session`;--> statement-breakpoint\nALTER TABLE `acp_session` DROP COLUMN `last_terminal_command_id`;"
34375
34273
  }
34376
34274
  ];
34377
34275
 
@@ -34382,33 +34280,25 @@ var acpSession = sqliteTable("acp_session", {
34382
34280
  nativeSessionId: text("native_session_id").notNull(),
34383
34281
  cwd: text("cwd").notNull(),
34384
34282
  additionalDirectories: text("additional_directories").notNull(),
34385
- lastTerminalCommandId: text("last_terminal_command_id"),
34386
34283
  prompted: integer2("prompted", { mode: "boolean" }).notNull(),
34387
34284
  title: text("title").notNull(),
34388
34285
  updatedAt: text("updated_at").notNull()
34389
34286
  });
34390
34287
 
34391
- // src/schema/acp-session-store/deleted-acp-session.ts
34392
- var deletedAcpSession = sqliteTable("deleted_acp_session", {
34393
- sessionId: text("session_id").primaryKey()
34394
- });
34395
-
34396
34288
  // src/acp/session-store.ts
34397
34289
  var AcpStoredSession = class {
34398
34290
  additionalDirectories;
34399
34291
  agentId;
34400
34292
  cwd;
34401
- lastTerminalCommandId;
34402
34293
  nativeSessionId;
34403
34294
  prompted;
34404
34295
  sessionId;
34405
34296
  title;
34406
34297
  updatedAt;
34407
- constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString(), lastTerminalCommandId = null) {
34298
+ constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString()) {
34408
34299
  this.additionalDirectories = [...additionalDirectories];
34409
34300
  this.agentId = agentId;
34410
34301
  this.cwd = cwd;
34411
- this.lastTerminalCommandId = lastTerminalCommandId;
34412
34302
  this.nativeSessionId = nativeSessionId;
34413
34303
  this.prompted = prompted;
34414
34304
  this.sessionId = sessionId;
@@ -34429,32 +34319,16 @@ var FoundAcpStoredSession = class extends AcpStoredSessionLookup {
34429
34319
  this.session = session;
34430
34320
  }
34431
34321
  };
34432
- var DeletedAcpStoredSession = class extends AcpStoredSessionLookup {
34433
- found = false;
34434
- };
34435
34322
  var MemoryAcpSessionStore = class {
34436
34323
  #sessions = /* @__PURE__ */ new Map();
34437
- #deleted = /* @__PURE__ */ new Set();
34438
34324
  close = () => {
34439
34325
  this.#sessions.clear();
34440
- this.#deleted.clear();
34441
34326
  };
34442
34327
  findNative = (agentId, nativeSessionId) => [...this.#sessions.values()].filter(
34443
34328
  (session) => session.agentId === agentId && session.nativeSessionId === nativeSessionId
34444
34329
  );
34445
34330
  list = () => [...this.#sessions.values()].toSorted((left, right) => right.updatedAt.localeCompare(left.updatedAt));
34446
- markDeleted = (agentId, nativeSessionId) => {
34447
- const ids = this.findNative(agentId, nativeSessionId).map((session) => session.sessionId);
34448
- for (const id of ids) {
34449
- this.#sessions.delete(id);
34450
- this.#deleted.add(id);
34451
- }
34452
- return ids;
34453
- };
34454
34331
  read = (sessionId) => {
34455
- if (this.#deleted.has(sessionId)) {
34456
- return new DeletedAcpStoredSession();
34457
- }
34458
34332
  const session = this.#sessions.get(sessionId);
34459
34333
  return session === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(session);
34460
34334
  };
@@ -34469,14 +34343,12 @@ var storedSessionRowSchema = external_exports.object({
34469
34343
  additionalDirectories: external_exports.string(),
34470
34344
  agentId: external_exports.string(),
34471
34345
  cwd: external_exports.string(),
34472
- lastTerminalCommandId: external_exports.string().nullable(),
34473
34346
  nativeSessionId: external_exports.string(),
34474
34347
  prompted: external_exports.boolean(),
34475
34348
  sessionId: external_exports.string(),
34476
34349
  title: external_exports.string(),
34477
34350
  updatedAt: external_exports.string()
34478
34351
  });
34479
- var sessionIdRowSchema = external_exports.object({ sessionId: external_exports.string() });
34480
34352
  function decodeStoredSession(value) {
34481
34353
  const row = storedSessionRowSchema.parse(value);
34482
34354
  const decodedAdditionalDirectories = JSON.parse(row.additionalDirectories);
@@ -34489,8 +34361,7 @@ function decodeStoredSession(value) {
34489
34361
  additionalDirectories,
34490
34362
  row.prompted,
34491
34363
  row.title,
34492
- row.updatedAt,
34493
- row.lastTerminalCommandId
34364
+ row.updatedAt
34494
34365
  );
34495
34366
  }
34496
34367
  var SqliteAcpSessionStore = class {
@@ -34525,37 +34396,12 @@ var SqliteAcpSessionStore = class {
34525
34396
  }
34526
34397
  }
34527
34398
  };
34528
- #transaction = (operation) => {
34529
- this.#sqliteDatabase.exec("BEGIN IMMEDIATE");
34530
- try {
34531
- operation();
34532
- this.#sqliteDatabase.exec("COMMIT");
34533
- } catch (error62) {
34534
- this.#sqliteDatabase.exec("ROLLBACK");
34535
- throw error62;
34536
- }
34537
- };
34538
34399
  close = () => {
34539
34400
  this.#sqliteDatabase.close();
34540
34401
  };
34541
34402
  findNative = (agentId, nativeSessionId) => this.#database.select().from(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).all().map(decodeStoredSession);
34542
34403
  list = () => this.#database.select().from(acpSession).orderBy(desc(acpSession.updatedAt)).all().map(decodeStoredSession);
34543
- markDeleted = (agentId, nativeSessionId) => {
34544
- const ids = this.#database.select({ sessionId: acpSession.sessionId }).from(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).all().map((row) => sessionIdRowSchema.parse(row).sessionId);
34545
- this.#transaction(() => {
34546
- this.#database.delete(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).run();
34547
- for (const id of ids) {
34548
- this.#database.insert(deletedAcpSession).values({ sessionId: id }).onConflictDoNothing().run();
34549
- }
34550
- });
34551
- return ids;
34552
- };
34553
34404
  read = (sessionId) => {
34554
- const deleted = this.#database.select({ sessionId: deletedAcpSession.sessionId }).from(deletedAcpSession).where(eq(deletedAcpSession.sessionId, sessionId)).get();
34555
- if (deleted !== void 0) {
34556
- sessionIdRowSchema.parse(deleted);
34557
- return new DeletedAcpStoredSession();
34558
- }
34559
34405
  const row = this.#database.select().from(acpSession).where(eq(acpSession.sessionId, sessionId)).get();
34560
34406
  return row === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(decodeStoredSession(row));
34561
34407
  };
@@ -34567,20 +34413,13 @@ var SqliteAcpSessionStore = class {
34567
34413
  additionalDirectories: JSON.stringify(session.additionalDirectories),
34568
34414
  agentId: session.agentId,
34569
34415
  cwd: session.cwd,
34570
- lastTerminalCommandId: session.lastTerminalCommandId,
34571
34416
  nativeSessionId: session.nativeSessionId,
34572
34417
  prompted: session.prompted,
34573
34418
  sessionId: session.sessionId,
34574
34419
  title: session.title,
34575
34420
  updatedAt: session.updatedAt
34576
34421
  };
34577
- this.#transaction(() => {
34578
- this.#database.delete(deletedAcpSession).where(eq(deletedAcpSession.sessionId, session.sessionId)).run();
34579
- this.#database.insert(acpSession).values(value).onConflictDoUpdate({
34580
- target: acpSession.sessionId,
34581
- set: value
34582
- }).run();
34583
- });
34422
+ this.#database.insert(acpSession).values(value).onConflictDoUpdate({ target: acpSession.sessionId, set: value }).run();
34584
34423
  };
34585
34424
  };
34586
34425
 
@@ -34621,7 +34460,6 @@ var AgentSession = class _AgentSession {
34621
34460
  #commands = [];
34622
34461
  #configRevision = 0;
34623
34462
  #configOptions = [];
34624
- #lastTerminalCommandId = null;
34625
34463
  #nativeHistoryOwnership = { kind: "unbound" };
34626
34464
  #prompted = false;
34627
34465
  #nativePrompt = null;
@@ -34934,13 +34772,6 @@ var AgentSession = class _AgentSession {
34934
34772
  this.#store.remove(this.#mobiusSessionId);
34935
34773
  stored = this.#metrics.measureSync("session-state-read", () => this.#store.read(this.#mobiusSessionId));
34936
34774
  }
34937
- if (stored instanceof DeletedAcpStoredSession) {
34938
- throw new AcpExecutionError(
34939
- "The native Agent session was deleted. Start a new chat.",
34940
- {},
34941
- "native_session_deleted"
34942
- );
34943
- }
34944
34775
  let lifecycleResponse;
34945
34776
  if (origin?.kind === "fork") {
34946
34777
  if (!this.#capabilities.unstableForkSession) {
@@ -34988,7 +34819,6 @@ var AgentSession = class _AgentSession {
34988
34819
  } else if (stored instanceof FoundAcpStoredSession && stored.session.agentId === this.#agentId && stored.session.cwd === this.#cwd && arraysEqual(stored.session.additionalDirectories, this.#additionalDirectories)) {
34989
34820
  this.selectNativeSession(stored.session.nativeSessionId);
34990
34821
  this.#prompted = stored.session.prompted;
34991
- this.#lastTerminalCommandId = stored.session.lastTerminalCommandId;
34992
34822
  this.#sessionTitle = stored.session.title;
34993
34823
  this.#restored = true;
34994
34824
  if (this.#capabilities.resumeSession) {
@@ -35064,8 +34894,7 @@ var AgentSession = class _AgentSession {
35064
34894
  this.#additionalDirectories,
35065
34895
  this.#prompted,
35066
34896
  this.#sessionTitle ?? "",
35067
- (/* @__PURE__ */ new Date()).toISOString(),
35068
- this.#lastTerminalCommandId
34897
+ (/* @__PURE__ */ new Date()).toISOString()
35069
34898
  )
35070
34899
  );
35071
34900
  };
@@ -35094,24 +34923,6 @@ var AgentSession = class _AgentSession {
35094
34923
  }
35095
34924
  return decoded.data;
35096
34925
  };
35097
- deleteNativeSession = async (nativeSessionId, signal) => {
35098
- if (!this.#capabilities.deleteSession || !this.#capabilities.listSessions) {
35099
- throw new AcpExecutionError(
35100
- "This Agent does not support native session deletion",
35101
- {},
35102
- "native_session_unsupported"
35103
- );
35104
- }
35105
- await this.race(
35106
- this.#connection.connection.agent.request(
35107
- methods8.agent.session.delete,
35108
- { sessionId: nativeSessionIdSchema.parse(nativeSessionId) },
35109
- { cancellationSignal: signal }
35110
- ),
35111
- "ACP agent exited while deleting a session",
35112
- signal
35113
- );
35114
- };
35115
34926
  nativeSessionId = () => this.#updates.sessionId();
35116
34927
  adoptNativeSessionId = (sessionId) => {
35117
34928
  if (this.#prompted || this.#updates.sessionId() !== sessionId) {
@@ -35267,8 +35078,7 @@ var AgentSession = class _AgentSession {
35267
35078
  this.#additionalDirectories,
35268
35079
  true,
35269
35080
  this.#sessionTitle,
35270
- (/* @__PURE__ */ new Date()).toISOString(),
35271
- this.#lastTerminalCommandId
35081
+ (/* @__PURE__ */ new Date()).toISOString()
35272
35082
  )
35273
35083
  );
35274
35084
  this.#prompted = true;
@@ -35337,7 +35147,6 @@ var AgentSession = class _AgentSession {
35337
35147
  usage: result.usage ?? null
35338
35148
  });
35339
35149
  }
35340
- this.#lastTerminalCommandId = options.commandId;
35341
35150
  this.#store.write(
35342
35151
  new AcpStoredSession(
35343
35152
  this.#mobiusSessionId,
@@ -35347,8 +35156,7 @@ var AgentSession = class _AgentSession {
35347
35156
  this.#additionalDirectories,
35348
35157
  true,
35349
35158
  this.#sessionTitle ?? "",
35350
- (/* @__PURE__ */ new Date()).toISOString(),
35351
- this.#lastTerminalCommandId
35159
+ (/* @__PURE__ */ new Date()).toISOString()
35352
35160
  )
35353
35161
  );
35354
35162
  if (lifecycleV2 !== void 0) {
@@ -35636,8 +35444,7 @@ var AgentSession = class _AgentSession {
35636
35444
  this.#additionalDirectories,
35637
35445
  this.#prompted,
35638
35446
  this.#sessionTitle ?? "",
35639
- (/* @__PURE__ */ new Date()).toISOString(),
35640
- this.#lastTerminalCommandId
35447
+ (/* @__PURE__ */ new Date()).toISOString()
35641
35448
  )
35642
35449
  );
35643
35450
  }
@@ -36329,9 +36136,6 @@ var LocalExternalContentStore = class {
36329
36136
  };
36330
36137
 
36331
36138
  // src/native-sessions/chat-agent.ts
36332
- function supportsNativeChat(agentId) {
36333
- return agentId === "codex" || agentId === "claude" || agentId === "opencode" || agentId === "pi";
36334
- }
36335
36139
  function isNativeChatSessionId(agentId, sessionId) {
36336
36140
  if (!nativeSessionIdSchema.safeParse(sessionId).success) {
36337
36141
  return false;
@@ -36681,13 +36485,6 @@ var AgentRuntimeManager = class {
36681
36485
  }
36682
36486
  prepareSession = async (options, metrics = unmeasuredOperationMetrics) => this.#operations.run(options, async (options2) => {
36683
36487
  const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
36684
- if (stored instanceof DeletedAcpStoredSession) {
36685
- throw new AcpExecutionError(
36686
- "The native Agent session was deleted. Start a new chat.",
36687
- {},
36688
- "native_session_deleted"
36689
- );
36690
- }
36691
36488
  if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
36692
36489
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
36693
36490
  }
@@ -37136,7 +36933,7 @@ var AgentRuntimeManager = class {
37136
36933
  }
37137
36934
  });
37138
36935
  }
37139
- if (this.#executionProcesses.get(options2.sessionId) !== void 0 || this.#executionProcesses.pending(options2.sessionId) !== void 0 || this.#store.read(options2.sessionId) instanceof FoundAcpStoredSession || this.#store.read(options2.sessionId) instanceof DeletedAcpStoredSession) {
36936
+ if (this.#executionProcesses.get(options2.sessionId) !== void 0 || this.#executionProcesses.pending(options2.sessionId) !== void 0 || this.#store.read(options2.sessionId) instanceof FoundAcpStoredSession) {
37140
36937
  throw new AcpExecutionError(
37141
36938
  "The destination conversation already exists",
37142
36939
  {},
@@ -37182,40 +36979,6 @@ var AgentRuntimeManager = class {
37182
36979
  }
37183
36980
  });
37184
36981
  });
37185
- deleteNativeSession = async (options, nativeSessionId) => this.#operations.run(options, async (options2) => {
37186
- return await this.#queryProcesses.use(options2, async (runtime) => {
37187
- const key = `${options2.agent.id}:${nativeSessionId}`;
37188
- const linked = this.#store.findNative(options2.agent.id, nativeSessionId);
37189
- if (this.#nativeOperations.has(key) || linked.some(
37190
- (entry) => this.#executions.command(entry.sessionId) !== void 0 || this.#executionProcesses.pending(entry.sessionId) !== void 0
37191
- )) {
37192
- throw new AcpExecutionError(
37193
- "Wait for the native session's running operation to finish",
37194
- {},
37195
- "session_busy"
37196
- );
37197
- }
37198
- this.#nativeOperations.add(key);
37199
- try {
37200
- for (const entry of linked) {
37201
- const active = this.#executionProcesses.get(entry.sessionId);
37202
- if (active !== void 0 && active !== runtime) {
37203
- await this.#retireSessionProcess(entry.sessionId, active, async () => await active.close());
37204
- }
37205
- }
37206
- options2.signal.throwIfAborted();
37207
- await runtime.deleteNativeSession(nativeSessionId, options2.signal);
37208
- const deleted = this.#store.markDeleted(options2.agent.id, nativeSessionId);
37209
- if (runtime.nativeSessionId() === nativeSessionId) {
37210
- await this.#queryProcesses.retire(options2.sessionId, runtime);
37211
- }
37212
- return deleted;
37213
- } finally {
37214
- this.#nativeOperations.delete(key);
37215
- this.#processes.notifyChanged();
37216
- }
37217
- });
37218
- });
37219
36982
  };
37220
36983
 
37221
36984
  // src/agent-catalog/publish-agent-catalog.ts
@@ -39589,7 +39352,6 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
39589
39352
  child2.removeListener("exit", onExit);
39590
39353
  }
39591
39354
  }
39592
- var readCodexHistory = async (agent, cwd, nativeSessionId, signal) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, { detail: "messages" });
39593
39355
  var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTurn) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, {
39594
39356
  detail: "rich",
39595
39357
  ...nativeTurn === void 0 ? {} : { nativeTurn }
@@ -39597,85 +39359,6 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
39597
39359
 
39598
39360
  // src/native-sessions/service.ts
39599
39361
  import { randomUUID as randomUUID3 } from "node:crypto";
39600
- import { basename as basename4 } from "node:path";
39601
-
39602
- // src/native-sessions/acp-history.ts
39603
- async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
39604
- let cursor = null;
39605
- let inspected = 0;
39606
- for (let pageNumber = 0; pageNumber < 500 && inspected < 500; pageNumber += 1) {
39607
- const page = await sessions.listNativeSessions(options, cursor);
39608
- inspected += page.sessions.length;
39609
- const found = page.sessions.find((entry) => entry.sessionId === nativeSessionId);
39610
- if (found !== void 0) {
39611
- const primary = await directories.identify(bindingId, found.cwd, options.signal);
39612
- const additional = await Promise.all(
39613
- found.additionalDirectories.map(
39614
- async (directory) => await directories.identify(bindingId, directory, options.signal)
39615
- )
39616
- );
39617
- if (primary.path !== options.cwd || additional.length !== options.additionalDirectories.length || additional.some((directory, index) => directory.path !== options.additionalDirectories[index])) {
39618
- throw new AcpExecutionError(
39619
- "The native Session belongs to another workspace.",
39620
- {},
39621
- "session_identity_mismatch"
39622
- );
39623
- }
39624
- return await sessions.previewNativeSession(options, nativeSessionId);
39625
- }
39626
- if (page.nextCursor === null || page.nextCursor === cursor) {
39627
- break;
39628
- }
39629
- cursor = page.nextCursor ?? null;
39630
- }
39631
- throw new AcpExecutionError("The native Session was not found.", {}, "native_session_not_found");
39632
- }
39633
-
39634
- // src/native-sessions/acp-adapter.ts
39635
- var acpSessionAdapter = {
39636
- history: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
39637
- preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
39638
- };
39639
-
39640
- // src/native-sessions/codex-adapter.ts
39641
- async function verifiedHistory(context, full) {
39642
- const { options, nativeSessionId, directories, bindingId } = context;
39643
- const snapshot = full ? await readCodexFullHistory(options.agent, options.cwd, nativeSessionId, options.signal) : await readCodexHistory(options.agent, options.cwd, nativeSessionId, options.signal);
39644
- const resolved = await directories.identify(bindingId, snapshot.cwd, options.signal);
39645
- if (snapshot.nativeSessionId !== nativeSessionId || resolved.path !== options.cwd) {
39646
- throw new AcpExecutionError(
39647
- "Codex returned history for a different session or workspace.",
39648
- {},
39649
- "invalid_native_session_response"
39650
- );
39651
- }
39652
- return snapshot.history;
39653
- }
39654
- var codexSessionAdapter = {
39655
- history: async (context) => await verifiedHistory(context, true),
39656
- // Codex enforces an exclusive writer per thread. Its read-only app-server
39657
- // history path keeps externally owned conversations previewable.
39658
- preview: async (context) => await verifiedHistory(context, false)
39659
- };
39660
-
39661
- // src/native-sessions/agent-adapter.ts
39662
- var genericSessionAdapter = {
39663
- history: async () => {
39664
- throw new AcpExecutionError("Native history is unavailable for this Agent", {}, "native_session_unsupported");
39665
- },
39666
- preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
39667
- };
39668
- function nativeSessionAdapter(agentId) {
39669
- if (agentId === "codex") {
39670
- return codexSessionAdapter;
39671
- }
39672
- if (agentId === "claude" || agentId === "opencode" || agentId === "pi") {
39673
- return acpSessionAdapter;
39674
- }
39675
- return genericSessionAdapter;
39676
- }
39677
-
39678
- // src/native-sessions/service.ts
39679
39362
  var NativeSessionService = class {
39680
39363
  #entries = /* @__PURE__ */ new Map();
39681
39364
  #cursors = /* @__PURE__ */ new Map();
@@ -39719,83 +39402,6 @@ var NativeSessionService = class {
39719
39402
  ...await this.#activeTurn(command, options)
39720
39403
  };
39721
39404
  }
39722
- if (command.action === "create") {
39723
- if (!supportsNativeChat(options.agent.id)) {
39724
- throw new AcpExecutionError(
39725
- "Native session creation is unavailable for this Agent",
39726
- {},
39727
- "native_session_unsupported"
39728
- );
39729
- }
39730
- const nativeSessionId = await this.#sessions.createNativeSession(options);
39731
- signal.throwIfAborted();
39732
- this.record(command, "native_session_created");
39733
- return {
39734
- action: "create",
39735
- kind: "native.session.result",
39736
- nativeSessionId: decodeIdentifier(nativeSessionId),
39737
- requestId: command.requestId,
39738
- sessionId: command.sessionId
39739
- };
39740
- }
39741
- if (command.action === "fork-recorded") {
39742
- const source = this.#sessions.findSessions([command.sessionId])[0];
39743
- if (source === void 0 || !source.prompted) {
39744
- throw new AcpExecutionError(
39745
- "The source conversation has no resumable native Agent session",
39746
- {},
39747
- "native_session_not_found"
39748
- );
39749
- }
39750
- if (source.agentId !== command.agentId || source.cwd !== cwd || source.additionalDirectories.length !== additionalDirectories.length || source.additionalDirectories.some((path2, index) => path2 !== additionalDirectories[index])) {
39751
- throw new AcpExecutionError(
39752
- "The source conversation execution target does not match the fork request",
39753
- {},
39754
- "native_session_target_changed"
39755
- );
39756
- }
39757
- if (source.lastTerminalCommandId !== command.throughCommandId) {
39758
- throw new AcpExecutionError(
39759
- "The selected Turn is no longer the source conversation head",
39760
- {},
39761
- "fork_point_stale"
39762
- );
39763
- }
39764
- const opened2 = await this.#sessions.openNativeSession(
39765
- { ...options, sessionId: command.targetSessionId },
39766
- { kind: "fork", nativeSessionId: source.nativeSessionId }
39767
- );
39768
- signal.throwIfAborted();
39769
- const directory = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
39770
- const ready2 = {
39771
- additionalDirectories: additionalDirectories.map((path2, index) => ({
39772
- directoryId: command.additionalDirectoryIds[index] ?? command.directoryId,
39773
- name: basename4(path2) || path2
39774
- })),
39775
- agentId: command.agentId,
39776
- agentName: opened2.prepared.agentName,
39777
- agentVersion: opened2.prepared.agentVersion,
39778
- capabilities: opened2.prepared.capabilities,
39779
- commands: opened2.prepared.commands,
39780
- configOptions: opened2.prepared.configOptions,
39781
- directoryId: command.directoryId,
39782
- directoryLabel: directory.directoryLabel,
39783
- kind: "session.ready",
39784
- requestId: command.requestId,
39785
- restored: true,
39786
- sessionId: opened2.sessionId
39787
- };
39788
- this.record(command, "native_recorded_session_forked");
39789
- return {
39790
- action: "fork-recorded",
39791
- kind: "native.session.result",
39792
- ready: ready2,
39793
- requestId: command.requestId,
39794
- sessionId: command.sessionId,
39795
- targetSessionId: command.targetSessionId,
39796
- title: source.title || "Untitled session"
39797
- };
39798
- }
39799
39405
  const prepared = await this.#sessions.prepareNativeSessionBrowser(options);
39800
39406
  if (!prepared.capabilities.listSessions) {
39801
39407
  throw new AcpExecutionError(
@@ -39930,63 +39536,6 @@ var NativeSessionService = class {
39930
39536
  );
39931
39537
  }
39932
39538
  const target = await this.resolveTarget(command, options, selected);
39933
- if (command.action === "history") {
39934
- const history = await nativeSessionAdapter(options.agent.id).history({
39935
- sessions: this.#sessions,
39936
- directories: this.#directories,
39937
- bindingId: command.bindingId,
39938
- options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
39939
- nativeSessionId: target.info.sessionId
39940
- });
39941
- signal.throwIfAborted();
39942
- this.record(command, "native_session_history_read");
39943
- return {
39944
- ...envelope2,
39945
- action: "history",
39946
- entryId: command.entryId,
39947
- history,
39948
- title: target.info.title ?? "Untitled session"
39949
- };
39950
- }
39951
- if (command.action === "preview") {
39952
- const history = await nativeSessionAdapter(options.agent.id).preview({
39953
- sessions: this.#sessions,
39954
- directories: this.#directories,
39955
- bindingId: command.bindingId,
39956
- options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
39957
- nativeSessionId: target.info.sessionId
39958
- });
39959
- signal.throwIfAborted();
39960
- this.record(command, "native_session_previewed");
39961
- return {
39962
- ...envelope2,
39963
- action: "preview",
39964
- entryId: command.entryId,
39965
- targetSessionId: command.sessionId,
39966
- reason: "requested",
39967
- title: target.info.title ?? "Untitled session",
39968
- history
39969
- };
39970
- }
39971
- if (command.action === "delete") {
39972
- if (!prepared.capabilities.deleteSession) {
39973
- throw new AcpExecutionError(
39974
- "This Agent does not support native session deletion",
39975
- {},
39976
- "native_session_unsupported"
39977
- );
39978
- }
39979
- signal.throwIfAborted();
39980
- this.record(command, "native_session_delete_authorized");
39981
- const deletedSessionIds = await this.#sessions.deleteNativeSession(options, target.info.sessionId);
39982
- this.record(command, "native_session_deleted");
39983
- return {
39984
- ...envelope2,
39985
- action: "delete",
39986
- entryId: command.entryId,
39987
- deletedSessionIds: deletedSessionIds.map(decodeIdentifier)
39988
- };
39989
- }
39990
39539
  const action = command.action;
39991
39540
  if (action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
39992
39541
  throw new AcpExecutionError("This Agent cannot import native sessions", {}, "native_session_unsupported");
@@ -40371,135 +39920,13 @@ var RelayConnectionDiagnostics = class {
40371
39920
  };
40372
39921
 
40373
39922
  // src/relay-connection/run-relay-connection.ts
40374
- import { WebSocket as WebSocket8 } from "undici";
39923
+ import { WebSocket as WebSocket7 } from "undici";
40375
39924
 
40376
39925
  // src/daemon-command-handler.ts
40377
- import { WebSocket as WebSocket6 } from "undici";
40378
-
40379
- // src/agent-catalog/handle-agent-catalog-refresh.ts
40380
- import { WebSocket as WebSocket3 } from "undici";
40381
- async function retainStillInstalledAgents(previous, refreshed, signal) {
40382
- const refreshedIdentifiers = new Set(refreshed.map((agent) => agent.id));
40383
- const retained = [];
40384
- for (const agent of previous) {
40385
- if (refreshedIdentifiers.has(agent.id)) {
40386
- continue;
40387
- }
40388
- signal.throwIfAborted();
40389
- if (await revalidateExecutable(agent.agentIdentity)) {
40390
- retained.push(agent);
40391
- }
40392
- }
40393
- return Object.freeze([...refreshed, ...retained]);
40394
- }
40395
- async function refreshAgentCatalog(config2, resolveEnvironment, signal) {
40396
- signal.throwIfAborted();
40397
- const shellEnvironment = await resolveEnvironment(signal);
40398
- const environment = new DaemonLocalContext(config2.localContext.stateDirectory, shellEnvironment).environment;
40399
- signal.throwIfAborted();
40400
- const inventory = await discoverLocalAgentInventory({
40401
- defaultWorkspace: config2.defaultWorkspace,
40402
- environment,
40403
- signal
40404
- });
40405
- const previousCatalog = config2.catalog.read();
40406
- const refreshedAgents = inventory.readyAgents().map((agent) => withDaemonEnvironment(agent, environment));
40407
- const agents = await retainStillInstalledAgents(previousCatalog.agents, refreshedAgents, signal);
40408
- const verifiedIdentifiers = new Set(agents.map((agent) => agent.id));
40409
- config2.catalog.transition(
40410
- agents,
40411
- inventory.installable.filter((agent) => !verifiedIdentifiers.has(agent.id))
40412
- );
40413
- try {
40414
- await publishAgentCatalog(config2, signal);
40415
- } catch (error62) {
40416
- config2.catalog.transition(previousCatalog.agents, previousCatalog.installableAgents);
40417
- throw error62;
40418
- }
40419
- }
40420
- function createAgentCatalogRefreshHandler(dependencies) {
40421
- const { config: config2, audit, diagnostics, socket, signal, timer, resolveEnvironment } = dependencies;
40422
- const agentCatalogRefreshes = /* @__PURE__ */ new Map();
40423
- const handle = (command) => {
40424
- if (agentCatalogRefreshes.has(command.requestId) || agentCatalogRefreshes.size > 0) {
40425
- if (socket.readyState === WebSocket3.OPEN) {
40426
- send(socket, {
40427
- code: "agent_catalog_refresh_busy",
40428
- kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
40429
- message: "Another local Agent catalog refresh is already running",
40430
- requestId: command.requestId
40431
- });
40432
- }
40433
- return;
40434
- }
40435
- const controller = new AbortController();
40436
- const operationSignal = AbortSignal.any([signal, controller.signal]);
40437
- const timeout = timer.schedule(
40438
- () => controller.abort(
40439
- new AcpExecutionError(
40440
- "The local Agent catalog refresh timed out",
40441
- {},
40442
- "agent_catalog_refresh_timeout"
40443
- )
40444
- ),
40445
- 9e4
40446
- );
40447
- const completion = (async () => {
40448
- try {
40449
- await refreshAgentCatalog(config2, resolveEnvironment, operationSignal);
40450
- audit.record({
40451
- commandId: command.requestId,
40452
- event: "agent_catalog_refreshed",
40453
- sessionId: "agent-catalog"
40454
- });
40455
- if (socket.readyState === WebSocket3.OPEN) {
40456
- send(socket, {
40457
- kind: AGENT_CATALOG_REFRESHED_KIND,
40458
- requestId: command.requestId
40459
- });
40460
- }
40461
- } catch (error62) {
40462
- const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
40463
- "The local Agent catalog refresh was cancelled",
40464
- {},
40465
- "agent_catalog_refresh_cancelled"
40466
- ) : error62;
40467
- audit.record({
40468
- commandId: command.requestId,
40469
- details: { code: operationErrorCode(failure2) },
40470
- event: "agent_catalog_refresh_failed",
40471
- sessionId: "agent-catalog"
40472
- });
40473
- diagnostics.daemonDiagnostic(
40474
- "agent_catalog_refresh_failed",
40475
- command.requestId,
40476
- { code: operationErrorCode(failure2) },
40477
- failure2
40478
- );
40479
- if (socket.readyState === WebSocket3.OPEN) {
40480
- send(socket, {
40481
- code: operationErrorCode(failure2),
40482
- kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
40483
- message: operationErrorMessage(failure2),
40484
- requestId: command.requestId
40485
- });
40486
- }
40487
- } finally {
40488
- timeout.cancel();
40489
- agentCatalogRefreshes.delete(command.requestId);
40490
- }
40491
- })();
40492
- agentCatalogRefreshes.set(command.requestId, { completion, controller });
40493
- return;
40494
- };
40495
- const settle2 = async () => {
40496
- await Promise.all([...agentCatalogRefreshes.values()].map((request) => request.completion));
40497
- };
40498
- return { handle, settle: settle2 };
40499
- }
39926
+ import { WebSocket as WebSocket5 } from "undici";
40500
39927
 
40501
39928
  // src/agent-catalog/handle-agent-settings-discovery.ts
40502
- import { WebSocket as WebSocket4 } from "undici";
39929
+ import { WebSocket as WebSocket3 } from "undici";
40503
39930
 
40504
39931
  // src/agent-catalog/discover-agent-settings.ts
40505
39932
  import { createHash as createHash5 } from "node:crypto";
@@ -40987,7 +40414,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
40987
40414
  (request) => request.agentId === command.agentId && !request.controller.signal.aborted
40988
40415
  );
40989
40416
  if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
40990
- if (socket.readyState === WebSocket4.OPEN) {
40417
+ if (socket.readyState === WebSocket3.OPEN) {
40991
40418
  send(socket, {
40992
40419
  code: "agent_settings_discovery_busy",
40993
40420
  kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
@@ -41002,7 +40429,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
41002
40429
  return;
41003
40430
  }
41004
40431
  if (existing !== void 0) {
41005
- if (socket.readyState === WebSocket4.OPEN) {
40432
+ if (socket.readyState === WebSocket3.OPEN) {
41006
40433
  send(socket, {
41007
40434
  code: "agent_settings_discovery_busy",
41008
40435
  kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
@@ -41013,7 +40440,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
41013
40440
  return;
41014
40441
  }
41015
40442
  if (agentSettingsDiscoveries.size >= 4) {
41016
- if (socket.readyState === WebSocket4.OPEN) {
40443
+ if (socket.readyState === WebSocket3.OPEN) {
41017
40444
  send(socket, {
41018
40445
  code: "agent_settings_discovery_busy",
41019
40446
  kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
@@ -41059,7 +40486,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
41059
40486
  event: "agent_settings_discovered",
41060
40487
  sessionId: `agent-settings:${command.agentId}`
41061
40488
  });
41062
- if (socket.readyState === WebSocket4.OPEN) {
40489
+ if (socket.readyState === WebSocket3.OPEN) {
41063
40490
  send(socket, { ...result.event, requestId });
41064
40491
  }
41065
40492
  }
@@ -41085,7 +40512,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
41085
40512
  `
41086
40513
  );
41087
40514
  }
41088
- if (socket.readyState === WebSocket4.OPEN) {
40515
+ if (socket.readyState === WebSocket3.OPEN) {
41089
40516
  for (const requestId of requestIds) {
41090
40517
  send(socket, {
41091
40518
  code: operationErrorCode(failure2),
@@ -41118,7 +40545,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
41118
40545
  // src/artifacts/local-file-streamer.ts
41119
40546
  import { createReadStream as createReadStream2 } from "node:fs";
41120
40547
  import { realpath as realpath9, stat as stat8 } from "node:fs/promises";
41121
- import { basename as basename5, isAbsolute as isAbsolute10, normalize as normalize4, resolve as resolve5 } from "node:path";
40548
+ import { basename as basename4, isAbsolute as isAbsolute10, normalize as normalize4, resolve as resolve5 } from "node:path";
41122
40549
  import { fileURLToPath as fileURLToPath2 } from "node:url";
41123
40550
  var CHUNK_BYTES = 192 * 1024;
41124
40551
  function requestedPath(value) {
@@ -41170,7 +40597,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
41170
40597
  kind: FILE_BEGIN_KIND,
41171
40598
  mediaType: external?.mediaType ?? raster?.mimeType ?? "application/octet-stream",
41172
40599
  modifiedAt: before.mtime.toISOString(),
41173
- name: external?.name ?? (basename5(target) || "file"),
40600
+ name: external?.name ?? (basename4(target) || "file"),
41174
40601
  requestId: command.requestId,
41175
40602
  sessionId: command.sessionId
41176
40603
  });
@@ -41200,7 +40627,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
41200
40627
  }
41201
40628
 
41202
40629
  // src/authorization/resolve-session-directories.ts
41203
- import { basename as basename6 } from "node:path";
40630
+ import { basename as basename5 } from "node:path";
41204
40631
  var ResolvedSessionDirectories = class {
41205
40632
  additionalDirectories;
41206
40633
  additionalDirectoryEntries;
@@ -41225,306 +40652,13 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
41225
40652
  additionalDirectories.push(directory);
41226
40653
  additionalDirectoryEntries.push({
41227
40654
  directoryId: additionalDirectoryId,
41228
- name: basename6(directory)
40655
+ name: basename5(directory)
41229
40656
  });
41230
40657
  }
41231
40658
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
41232
40659
  }
41233
40660
 
41234
- // src/native-sessions/live-history-page.ts
41235
- function encodeLiveHistoryCursor(cursor) {
41236
- return Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url");
41237
- }
41238
- function decodeLiveHistoryCursor(cursor, sessionId) {
41239
- try {
41240
- if (!/^[A-Za-z0-9_-]{1,512}$/u.test(cursor)) {
41241
- throw new Error("Invalid cursor alphabet");
41242
- }
41243
- const value = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
41244
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
41245
- throw new Error("Invalid cursor shape");
41246
- }
41247
- const record2 = Object.fromEntries(Object.entries(value));
41248
- const keys = Object.keys(record2).sort().join(",");
41249
- const legacyNative = keys === "endIndex,sessionId";
41250
- const kind = legacyNative ? "native" : record2["kind"];
41251
- if (keys !== "endIndex,kind,sessionId" && keys !== "endIndex,epoch,kind,sessionId" && !legacyNative || record2["sessionId"] !== sessionId || kind !== "active" && kind !== "native" || typeof record2["endIndex"] !== "number" || !Number.isSafeInteger(record2["endIndex"]) || record2["endIndex"] < 0) {
41252
- throw new Error("Invalid cursor target");
41253
- }
41254
- if (kind === "active") {
41255
- if (keys !== "endIndex,epoch,kind,sessionId" || typeof record2["epoch"] !== "string") {
41256
- throw new Error("Invalid active cursor target");
41257
- }
41258
- return { endIndex: record2["endIndex"], epoch: record2["epoch"], kind, sessionId };
41259
- }
41260
- if (keys !== "endIndex,kind,sessionId" && !legacyNative) {
41261
- throw new Error("Invalid native cursor target");
41262
- }
41263
- return { endIndex: record2["endIndex"], kind, sessionId };
41264
- } catch (cause) {
41265
- throw new AcpExecutionError("The native Session history cursor is invalid", { cause }, "invalid_cursor");
41266
- }
41267
- }
41268
- function activeHistoryCursor(sessionId, epoch, endIndex) {
41269
- return encodeLiveHistoryCursor({ endIndex, epoch, kind: "active", sessionId });
41270
- }
41271
- function nativeHistoryCursor(sessionId, endIndex) {
41272
- return encodeLiveHistoryCursor({ endIndex, kind: "native", sessionId });
41273
- }
41274
- function liveHistoryCoveredTurnRanges(history) {
41275
- const ranges = [];
41276
- let historyIndex = history.messages.length;
41277
- for (const commandId of history.coveredCommandIds) {
41278
- let assistantStartIndex = historyIndex;
41279
- while (assistantStartIndex > 0 && history.messages[assistantStartIndex - 1]?.role === "assistant") {
41280
- assistantStartIndex -= 1;
41281
- }
41282
- const userIndex = assistantStartIndex - 1;
41283
- if (assistantStartIndex === historyIndex || history.messages[userIndex]?.role !== "user") {
41284
- break;
41285
- }
41286
- ranges.push({ assistantEndIndex: historyIndex, assistantStartIndex, commandId, userIndex });
41287
- historyIndex = userIndex;
41288
- }
41289
- return ranges;
41290
- }
41291
- function historyMessageCharacters(message) {
41292
- return message.text.length + (message.role === "assistant" ? JSON.stringify(message.activities).length + JSON.stringify(message.content).length : 0);
41293
- }
41294
- function isNativeHistoryImageMimeType(mimeType) {
41295
- return mimeType === "image/png" || mimeType === "image/jpeg" || mimeType === "image/gif" || mimeType === "image/webp";
41296
- }
41297
- function selectMessagesBefore(messages, endIndex, messageLimit, characterLimit) {
41298
- const selected = [];
41299
- let remainingCharacters = characterLimit;
41300
- let startIndex = endIndex;
41301
- for (let index = endIndex - 1; index >= 0 && selected.length < messageLimit; index -= 1) {
41302
- const message = messages[index];
41303
- if (message === void 0) {
41304
- break;
41305
- }
41306
- const characters = historyMessageCharacters(message);
41307
- if (characters > remainingCharacters) {
41308
- break;
41309
- }
41310
- selected.unshift(message);
41311
- remainingCharacters -= characters;
41312
- startIndex = index;
41313
- }
41314
- if (selected.length === 0 && endIndex > 0) {
41315
- throw new AcpExecutionError(
41316
- "A native Session history item exceeds the page budget",
41317
- {},
41318
- "history_item_too_large"
41319
- );
41320
- }
41321
- return { characters: characterLimit - remainingCharacters, messages: selected, startIndex };
41322
- }
41323
- function nativeActiveMessage(message) {
41324
- if (message.role === "assistant") {
41325
- return {
41326
- activities: message.activities,
41327
- content: message.content,
41328
- role: "assistant",
41329
- text: message.text
41330
- };
41331
- }
41332
- const images = (message.images ?? []).flatMap((image) => {
41333
- if (image.data.length < 4 || image.data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(image.data) || !isNativeHistoryImageMimeType(image.mimeType)) {
41334
- return [];
41335
- }
41336
- return [{ data: image.data, mimeType: image.mimeType, name: image.name }];
41337
- });
41338
- return { ...images.length === 0 ? {} : { images }, role: "user", text: message.text };
41339
- }
41340
- function nativeHistoryCoversCompletedRecovery(history, recovery) {
41341
- const root = recovery.messages.find((message) => message.role === "user" && message.id === recovery.commandId);
41342
- if (root === void 0) {
41343
- return false;
41344
- }
41345
- const rootIndex = history.messages.findLastIndex(
41346
- (message) => message.role === "user" && message.text === root.text
41347
- );
41348
- if (rootIndex < 0) {
41349
- return false;
41350
- }
41351
- const nativeAssistant = history.messages.slice(rootIndex + 1).filter((message) => message.role === "assistant");
41352
- if (nativeAssistant.length === 0) {
41353
- return false;
41354
- }
41355
- const recoveryAssistant = recovery.messages.filter((message) => message.role === "assistant");
41356
- const recoveryText = recoveryAssistant.map((message) => message.text).join("");
41357
- const nativeText = nativeAssistant.map((message) => message.text).join("");
41358
- if (recoveryText.length > 0 && !nativeText.includes(recoveryText)) {
41359
- return false;
41360
- }
41361
- const nativeContent = new Set(
41362
- nativeAssistant.flatMap((message) => message.content).map((content) => JSON.stringify(content))
41363
- );
41364
- return recoveryAssistant.flatMap((message) => message.content).every((content) => nativeContent.has(JSON.stringify(content)));
41365
- }
41366
- function historyBeforeActiveTurn(history, activeTurn) {
41367
- if (history.status === "unavailable") {
41368
- return history;
41369
- }
41370
- const activeRoot = activeTurn.messages.find(
41371
- (message) => message.role === "user" && message.id === activeTurn.commandId
41372
- );
41373
- const matchingActiveUserIndex = activeRoot === void 0 ? -1 : activeTurn.state === "completed" || history.messages.at(-1)?.role === "user" && history.messages.at(-1)?.text === activeRoot.text || history.coveredCommandIds.includes(activeTurn.commandId) ? history.messages.findLastIndex((message) => message.role === "user" && message.text === activeRoot.text) : -1;
41374
- const activeUserIndex = matchingActiveUserIndex >= 0 ? matchingActiveUserIndex : liveHistoryCoveredTurnRanges(history).find((range) => range.commandId === activeTurn.commandId)?.userIndex ?? -1;
41375
- if (activeUserIndex < 0) {
41376
- return history;
41377
- }
41378
- return {
41379
- ...history,
41380
- coveredCommandIds: history.coveredCommandIds.filter((id) => id !== activeTurn.commandId),
41381
- coveredMessageIds: history.coveredMessageIds.filter(
41382
- (id) => id !== `${activeTurn.commandId}:user` && id !== `${activeTurn.commandId}:agent`
41383
- ),
41384
- messages: history.messages.slice(0, activeUserIndex)
41385
- };
41386
- }
41387
- function paginateAvailableNativeHistory(history, sessionId, endIndex, limit, characterLimit) {
41388
- if (endIndex > history.messages.length) {
41389
- throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
41390
- }
41391
- const selected = selectMessagesBefore(history.messages, endIndex, limit, characterLimit);
41392
- const coveredMessageIds = new Set(history.coveredMessageIds);
41393
- const ranges = liveHistoryCoveredTurnRanges(history);
41394
- return {
41395
- coveredCommandIds: ranges.filter((range) => range.userIndex >= selected.startIndex && range.assistantEndIndex <= endIndex).map((range) => range.commandId),
41396
- coveredMessageIds: ranges.flatMap((range) => [
41397
- ...range.userIndex >= selected.startIndex && range.userIndex < endIndex && coveredMessageIds.has(`${range.commandId}:user`) ? [`${range.commandId}:user`] : [],
41398
- ...range.assistantStartIndex >= selected.startIndex && range.assistantEndIndex <= endIndex && coveredMessageIds.has(`${range.commandId}:agent`) ? [`${range.commandId}:agent`] : []
41399
- ]),
41400
- messages: selected.messages,
41401
- nextCursor: selected.startIndex > 0 ? nativeHistoryCursor(sessionId, selected.startIndex) : null,
41402
- status: "available",
41403
- truncated: history.truncated
41404
- };
41405
- }
41406
- function paginateNativeHistory(history, sessionId, cursor, limit) {
41407
- if (cursor?.kind === "active") {
41408
- throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
41409
- }
41410
- if (history.status === "unavailable") {
41411
- if (cursor !== null) {
41412
- throw new AcpExecutionError("Unavailable native Session history has no cursor", {}, "invalid_cursor");
41413
- }
41414
- return { cause: history.cause, nextCursor: null, status: "unavailable" };
41415
- }
41416
- return paginateAvailableNativeHistory(
41417
- history,
41418
- sessionId,
41419
- cursor?.endIndex ?? history.messages.length,
41420
- limit,
41421
- SESSION_HISTORY_CHARACTER_LIMIT
41422
- );
41423
- }
41424
- function paginateActiveTurn(history, activeTurn, sessionId, endIndex, limit) {
41425
- if (endIndex > activeTurn.messages.length) {
41426
- throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
41427
- }
41428
- const activeMessages = activeTurn.messages.map(nativeActiveMessage);
41429
- const active = selectMessagesBefore(activeMessages, endIndex, limit, SESSION_HISTORY_CHARACTER_LIMIT);
41430
- const historicalLimit = limit - active.messages.length;
41431
- const historicalCharacterLimit = SESSION_HISTORY_CHARACTER_LIMIT - active.characters;
41432
- const pendingHistoricalCursor = history.status === "available" && history.messages.length > 0 ? nativeHistoryCursor(sessionId, history.messages.length) : null;
41433
- const latestHistoricalMessage = history.status === "available" ? history.messages.at(-1) : void 0;
41434
- const historicalPageFits = latestHistoricalMessage === void 0 || historyMessageCharacters(latestHistoricalMessage) <= historicalCharacterLimit;
41435
- const historical = active.startIndex === 0 && history.status === "available" && historicalLimit > 0 && historicalPageFits ? paginateAvailableNativeHistory(
41436
- history,
41437
- sessionId,
41438
- history.messages.length,
41439
- historicalLimit,
41440
- historicalCharacterLimit
41441
- ) : null;
41442
- return {
41443
- streamPosition: { commandId: activeTurn.commandId, epoch: activeTurn.epoch, sequence: activeTurn.sequence },
41444
- coveredCommandIds: historical?.coveredCommandIds ?? [],
41445
- coveredMessageIds: [
41446
- ...historical?.coveredMessageIds ?? [],
41447
- ...active.startIndex === 0 ? [`${activeTurn.commandId}:user`, `${activeTurn.commandId}:agent`] : []
41448
- ],
41449
- messages: [...historical?.messages ?? [], ...active.messages],
41450
- nextCursor: active.startIndex > 0 ? activeHistoryCursor(sessionId, activeTurn.epoch, active.startIndex) : historical === null ? pendingHistoricalCursor : historical.nextCursor,
41451
- status: "available",
41452
- truncated: activeTurn.truncated || (historical?.truncated ?? false)
41453
- };
41454
- }
41455
- function paginateLiveSessionHistory(history, activeTurn, sessionId, encodedCursor, limit) {
41456
- const cursor = encodedCursor === null ? null : decodeLiveHistoryCursor(encodedCursor, sessionId);
41457
- if (activeTurn === null || activeTurn.state === "completed" && history.status === "available" && nativeHistoryCoversCompletedRecovery(history, activeTurn)) {
41458
- return paginateNativeHistory(history, sessionId, cursor, limit);
41459
- }
41460
- const historical = historyBeforeActiveTurn(history, activeTurn);
41461
- if (cursor?.kind === "native") {
41462
- return paginateNativeHistory(historical, sessionId, cursor, limit);
41463
- }
41464
- if (cursor !== null && cursor.epoch !== activeTurn.epoch) {
41465
- throw new AcpExecutionError("The active Turn history cursor is stale", {}, "stale_cursor");
41466
- }
41467
- return paginateActiveTurn(historical, activeTurn, sessionId, cursor?.endIndex ?? activeTurn.messages.length, limit);
41468
- }
41469
-
41470
40661
  // src/daemon-history-commands.ts
41471
- async function executeSessionLiveHistoryPageLoad(socket, command, config2, directories, audit, sessions, activeTurn, signal) {
41472
- try {
41473
- const resolved = await resolveSessionDirectories(
41474
- directories,
41475
- config2.bindingId,
41476
- command.directoryId,
41477
- command.additionalDirectoryIds,
41478
- signal
41479
- );
41480
- const history = await sessions.loadSessionHistory({
41481
- additionalDirectories: resolved.additionalDirectories,
41482
- agent: config2.catalog.find(command.agentId),
41483
- cwd: resolved.cwd,
41484
- sessionId: command.sessionId,
41485
- signal
41486
- });
41487
- signal.throwIfAborted();
41488
- const page = paginateLiveSessionHistory(
41489
- history,
41490
- activeTurn(command.sessionId),
41491
- command.sessionId,
41492
- command.cursor,
41493
- command.limit
41494
- );
41495
- audit.record({
41496
- commandId: command.requestId,
41497
- event: "session_history_loaded",
41498
- sessionId: command.sessionId
41499
- });
41500
- send(socket, {
41501
- kind: "session.live-history.page.loaded",
41502
- page,
41503
- requestId: command.requestId,
41504
- sessionId: command.sessionId
41505
- });
41506
- } catch (error62) {
41507
- if (signal.aborted) {
41508
- return;
41509
- }
41510
- audit.record({
41511
- commandId: command.requestId,
41512
- details: { code: operationErrorCode(error62) },
41513
- event: "session_history_unavailable",
41514
- sessionId: command.sessionId
41515
- });
41516
- send(socket, {
41517
- kind: "session.live-history.page.loaded",
41518
- page: {
41519
- status: "unavailable",
41520
- cause: { code: operationErrorCode(error62), message: operationErrorMessage(error62) },
41521
- nextCursor: null
41522
- },
41523
- requestId: command.requestId,
41524
- sessionId: command.sessionId
41525
- });
41526
- }
41527
- }
41528
40662
  async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
41529
40663
  try {
41530
40664
  const resolved = await resolveSessionDirectories(
@@ -42295,9 +41429,9 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
42295
41429
  }
42296
41430
 
42297
41431
  // src/native-sessions/handle-native-requests.ts
42298
- import { WebSocket as WebSocket5 } from "undici";
41432
+ import { WebSocket as WebSocket4 } from "undici";
42299
41433
  function createNativeSessionRequestHandler(dependencies) {
42300
- const { audit, diagnostics, nativeSessions, publisher, signal, socket, timer } = dependencies;
41434
+ const { audit, diagnostics, nativeSessions, signal, socket, timer } = dependencies;
42301
41435
  const pending = /* @__PURE__ */ new Map();
42302
41436
  const cancel = (command) => {
42303
41437
  const request = pending.get(command.requestId);
@@ -42349,18 +41483,7 @@ function createNativeSessionRequestHandler(dependencies) {
42349
41483
  }
42350
41484
  operationSignal.throwIfAborted();
42351
41485
  const result = await nativeSessions.execute(command, operationSignal);
42352
- if (command.action === "fork-recorded" && result.action === "fork-recorded") {
42353
- publisher.publishBatch(result.ready.sessionId, [
42354
- result.ready,
42355
- {
42356
- kind: "session.forked",
42357
- sessionId: result.ready.sessionId,
42358
- sourceSessionId: command.sessionId,
42359
- throughCommandId: command.throughCommandId
42360
- }
42361
- ]);
42362
- }
42363
- if (socket.readyState === WebSocket5.OPEN) {
41486
+ if (socket.readyState === WebSocket4.OPEN) {
42364
41487
  send(socket, result);
42365
41488
  }
42366
41489
  } catch (error62) {
@@ -42419,8 +41542,7 @@ function createDaemonCommandHandler({
42419
41542
  socket,
42420
41543
  signal,
42421
41544
  runtimeSignal,
42422
- timer,
42423
- resolveAgentCatalogEnvironment
41545
+ timer
42424
41546
  }) {
42425
41547
  const handleSettingsDiscovery = createAgentSettingsDiscoveryHandler({
42426
41548
  config: config2,
@@ -42432,25 +41554,14 @@ function createDaemonCommandHandler({
42432
41554
  signal,
42433
41555
  timer
42434
41556
  });
42435
- const handleCatalogRefresh = createAgentCatalogRefreshHandler({
42436
- config: config2,
42437
- audit,
42438
- diagnostics,
42439
- socket,
42440
- signal,
42441
- timer,
42442
- resolveEnvironment: resolveAgentCatalogEnvironment
42443
- });
42444
41557
  const queueChanged = (sessionId) => {
42445
41558
  publisher.publish(sessionId, { kind: "session.queue.changed", sessionId });
42446
41559
  eventLogV2.queueChanged(sessionId);
42447
41560
  };
42448
- const activeTurnRecovery = (sessionId) => activeTurns.recovery((command) => command.sessionId === sessionId);
42449
41561
  const nativeRequestHandler = createNativeSessionRequestHandler({
42450
41562
  audit,
42451
41563
  diagnostics,
42452
41564
  nativeSessions,
42453
- publisher,
42454
41565
  signal,
42455
41566
  socket,
42456
41567
  timer
@@ -42458,18 +41569,8 @@ function createDaemonCommandHandler({
42458
41569
  return {
42459
41570
  handle: (message) => {
42460
41571
  const kind = message.kind;
42461
- if (kind === SESSION_LIVE_HISTORY_PAGE_LOAD_KIND) {
42462
- const command2 = message;
42463
- void executeSessionLiveHistoryPageLoad(
42464
- socket,
42465
- command2,
42466
- config2,
42467
- directories,
42468
- audit,
42469
- sessions,
42470
- activeTurnRecovery,
42471
- signal
42472
- );
41572
+ if (kind === RUNTIME_PING_KIND) {
41573
+ send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
42473
41574
  return;
42474
41575
  }
42475
41576
  if (kind === SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) {
@@ -42494,10 +41595,6 @@ function createDaemonCommandHandler({
42494
41595
  handleSettingsDiscovery.handle(message);
42495
41596
  return;
42496
41597
  }
42497
- if (kind === AGENT_CATALOG_REFRESH_KIND) {
42498
- handleCatalogRefresh.handle(message);
42499
- return;
42500
- }
42501
41598
  if (kind === NATIVE_SESSION_REQUEST_KIND) {
42502
41599
  nativeRequestHandler.handle(message);
42503
41600
  return;
@@ -42511,7 +41608,7 @@ function createDaemonCommandHandler({
42511
41608
  sessions.findSessions([command2.sessionId])[0]?.cwd ?? null,
42512
41609
  externalContent
42513
41610
  ).catch((error62) => {
42514
- if (socket.readyState !== WebSocket6.OPEN || signal.aborted) {
41611
+ if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
42515
41612
  return;
42516
41613
  }
42517
41614
  send(socket, {
@@ -42717,17 +41814,13 @@ function createDaemonCommandHandler({
42717
41814
  });
42718
41815
  },
42719
41816
  settle: async () => {
42720
- await Promise.all([
42721
- nativeRequestHandler.settle(),
42722
- handleSettingsDiscovery.settle(),
42723
- handleCatalogRefresh.settle()
42724
- ]);
41817
+ await Promise.all([nativeRequestHandler.settle(), handleSettingsDiscovery.settle()]);
42725
41818
  }
42726
41819
  };
42727
41820
  }
42728
41821
 
42729
41822
  // src/relay-connection/connect.ts
42730
- import { WebSocket as WebSocket7 } from "undici";
41823
+ import { WebSocket as WebSocket6 } from "undici";
42731
41824
 
42732
41825
  // src/relay-connection/runtime-revocation.ts
42733
41826
  var runtimeRevocationCloseCode = 1008;
@@ -42765,7 +41858,7 @@ function connectRelay(url2, signal) {
42765
41858
  const endpoint = new URL(url2);
42766
41859
  const headers = runtimeAuthorization(endpoint);
42767
41860
  endpoint.searchParams.delete("token");
42768
- const socket = new WebSocket7(endpoint, {
41861
+ const socket = new WebSocket6(endpoint, {
42769
41862
  dispatcher: environmentProxyDispatcher,
42770
41863
  headers
42771
41864
  });
@@ -42983,8 +42076,7 @@ async function runRelayConnection({
42983
42076
  diagnostics,
42984
42077
  onConnected,
42985
42078
  signal,
42986
- timer,
42987
- resolveAgentCatalogEnvironment
42079
+ timer
42988
42080
  }) {
42989
42081
  const relayUrl = new URL(config2.relayUrl);
42990
42082
  relayUrl.searchParams.set("liveness", "1");
@@ -43007,8 +42099,7 @@ async function runRelayConnection({
43007
42099
  socket,
43008
42100
  signal: connectionController.signal,
43009
42101
  runtimeSignal: signal,
43010
- timer,
43011
- resolveAgentCatalogEnvironment
42102
+ timer
43012
42103
  });
43013
42104
  installationObserver.connect(socket);
43014
42105
  onConnected();
@@ -43054,14 +42145,14 @@ async function runRelayConnection({
43054
42145
  };
43055
42146
  const connectionLiveness = new RelayConnectionLiveness(timer, {
43056
42147
  send: (message) => {
43057
- if (socket.readyState !== WebSocket8.OPEN) {
42148
+ if (socket.readyState !== WebSocket7.OPEN) {
43058
42149
  return false;
43059
42150
  }
43060
42151
  try {
43061
42152
  send(socket, message);
43062
42153
  return true;
43063
42154
  } catch (error62) {
43064
- if (socket.readyState !== WebSocket8.OPEN) {
42155
+ if (socket.readyState !== WebSocket7.OPEN) {
43065
42156
  return false;
43066
42157
  }
43067
42158
  throw error62;
@@ -43150,7 +42241,7 @@ async function runRelayConnection({
43150
42241
  }
43151
42242
 
43152
42243
  // src/relay-connection/session-event-publisher.ts
43153
- import { WebSocket as WebSocket9 } from "undici";
42244
+ import { WebSocket as WebSocket8 } from "undici";
43154
42245
  var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
43155
42246
  var DaemonSessionEventPublisher = class {
43156
42247
  #socket = null;
@@ -43167,7 +42258,7 @@ var DaemonSessionEventPublisher = class {
43167
42258
  };
43168
42259
  publish = (sessionId, event) => {
43169
42260
  const socket = this.#socket;
43170
- if (socket === null || socket.readyState !== WebSocket9.OPEN) {
42261
+ if (socket === null || socket.readyState !== WebSocket8.OPEN) {
43171
42262
  return;
43172
42263
  }
43173
42264
  const encoded = encodeDaemonToServiceMessage({
@@ -43191,7 +42282,7 @@ var DaemonSessionEventPublisher = class {
43191
42282
  };
43192
42283
  publishStatus = (event) => {
43193
42284
  const socket = this.#socket;
43194
- if (socket === null || socket.readyState !== WebSocket9.OPEN) {
42285
+ if (socket === null || socket.readyState !== WebSocket8.OPEN) {
43195
42286
  return;
43196
42287
  }
43197
42288
  const encoded = encodeDaemonToServiceMessage(event);
@@ -43206,7 +42297,7 @@ var DaemonSessionEventPublisher = class {
43206
42297
  };
43207
42298
  publishV2 = (event) => {
43208
42299
  const socket = this.#socket;
43209
- if (socket === null || socket.readyState !== WebSocket9.OPEN) {
42300
+ if (socket === null || socket.readyState !== WebSocket8.OPEN) {
43210
42301
  return;
43211
42302
  }
43212
42303
  const encoded = encodeDaemonToServiceMessage({ event, kind: SESSION_EVENT_V2_KIND });
@@ -43445,10 +42536,6 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
43445
42536
  let connectionAnnounced = false;
43446
42537
  let catalogPublished = false;
43447
42538
  let readinessAnnounced = false;
43448
- const resolveAgentCatalogEnvironment = options.resolveAgentCatalogEnvironment ?? (async (catalogSignal) => {
43449
- catalogSignal.throwIfAborted();
43450
- return config2.localContext.environment;
43451
- });
43452
42539
  const startAutomaticIntegrationProvisioning = () => {
43453
42540
  if (!connectionAnnounced || !catalogPublished || automaticIntegrationProvisioningStarted) {
43454
42541
  return;
@@ -43526,8 +42613,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
43526
42613
  announceConnection();
43527
42614
  },
43528
42615
  signal,
43529
- timer,
43530
- resolveAgentCatalogEnvironment
42616
+ timer
43531
42617
  });
43532
42618
  } catch (error62) {
43533
42619
  if (signal.aborted) {
@@ -43574,7 +42660,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
43574
42660
  // src/pairing/pair-local-machine.ts
43575
42661
  import { mkdir as mkdir6, realpath as realpath10, stat as stat9 } from "node:fs/promises";
43576
42662
  import { hostname as hostname3 } from "node:os";
43577
- import { basename as basename7, resolve as resolve7 } from "node:path";
42663
+ import { basename as basename6, resolve as resolve7 } from "node:path";
43578
42664
  import { fetch as fetch4 } from "undici";
43579
42665
 
43580
42666
  // src/storage/runtime-installation-store.ts
@@ -44216,7 +43302,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
44216
43302
  installableAgents,
44217
43303
  machineName: hostname3(),
44218
43304
  pairingCode: options.code,
44219
- workspaceName: basename7(defaultWorkspace) || "Local workspace"
43305
+ workspaceName: basename6(defaultWorkspace) || "Local workspace"
44220
43306
  }),
44221
43307
  dispatcher: environmentProxyDispatcher,
44222
43308
  headers: { "content-type": "application/json" },
@@ -44435,8 +43521,7 @@ var MobiusRuntimeEngine = class {
44435
43521
  const audit = new AuditStore();
44436
43522
  try {
44437
43523
  await runDaemon(this.#config, audit, signal, void 0, {
44438
- ...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus },
44439
- ...this.#options.resolveAgentCatalogEnvironment === void 0 ? {} : { resolveAgentCatalogEnvironment: this.#options.resolveAgentCatalogEnvironment }
43524
+ ...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
44440
43525
  });
44441
43526
  } finally {
44442
43527
  audit.close();