@moxt-ai/mobius 0.0.302 → 0.0.303

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/agent/catalog.d.ts +2 -1
  2. package/dist/agent/catalog.d.ts.map +1 -1
  3. package/dist/agent/catalog.js +18 -4
  4. package/dist/agent/catalog.js.map +1 -1
  5. package/dist/agent/discovery/agent-discovery.d.ts +9 -0
  6. package/dist/agent/discovery/agent-discovery.d.ts.map +1 -1
  7. package/dist/agent/discovery/agent-discovery.js +10 -0
  8. package/dist/agent/discovery/agent-discovery.js.map +1 -1
  9. package/dist/agent/discovery/discover-local-agents.d.ts +1 -0
  10. package/dist/agent/discovery/discover-local-agents.d.ts.map +1 -1
  11. package/dist/agent/discovery/discover-local-agents.js +1 -0
  12. package/dist/agent/discovery/discover-local-agents.js.map +1 -1
  13. package/dist/cli.js +303 -75
  14. package/dist/cli.js.map +4 -4
  15. package/dist/daemon/pairing/pair-local-machine.d.ts.map +1 -1
  16. package/dist/daemon/pairing/pair-local-machine.js +5 -1
  17. package/dist/daemon/pairing/pair-local-machine.js.map +1 -1
  18. package/dist/runtime/catalog/handle-agent-catalog-discovery.d.ts +29 -0
  19. package/dist/runtime/catalog/handle-agent-catalog-discovery.d.ts.map +1 -0
  20. package/dist/runtime/catalog/handle-agent-catalog-discovery.js +88 -0
  21. package/dist/runtime/catalog/handle-agent-catalog-discovery.js.map +1 -0
  22. package/dist/runtime/catalog/resolve-catalog-agent.d.ts +2 -1
  23. package/dist/runtime/catalog/resolve-catalog-agent.d.ts.map +1 -1
  24. package/dist/runtime/catalog/resolve-catalog-agent.js +12 -20
  25. package/dist/runtime/catalog/resolve-catalog-agent.js.map +1 -1
  26. package/dist/runtime/command/registry/agent-catalog.d.ts +4 -0
  27. package/dist/runtime/command/registry/agent-catalog.d.ts.map +1 -0
  28. package/dist/runtime/command/registry/agent-catalog.js +29 -0
  29. package/dist/runtime/command/registry/agent-catalog.js.map +1 -0
  30. package/dist/runtime/command/registry/index.d.ts.map +1 -1
  31. package/dist/runtime/command/registry/index.js +2 -0
  32. package/dist/runtime/command/registry/index.js.map +1 -1
  33. package/dist/runtime/config.d.ts +6 -1
  34. package/dist/runtime/config.d.ts.map +1 -1
  35. package/dist/runtime/config.js +2 -1
  36. package/dist/runtime/config.js.map +1 -1
  37. package/dist/runtime/engine.d.ts.map +1 -1
  38. package/dist/runtime/engine.js +1 -1
  39. package/dist/runtime/engine.js.map +1 -1
  40. package/dist/runtime.js +260 -67
  41. package/dist/runtime.js.map +4 -4
  42. package/dist/util/serial-task-queue.d.ts +6 -0
  43. package/dist/util/serial-task-queue.d.ts.map +1 -0
  44. package/dist/util/serial-task-queue.js +14 -0
  45. package/dist/util/serial-task-queue.js.map +1 -0
  46. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -2086,7 +2086,7 @@ var init_package = __esm({
2086
2086
  "package.json"() {
2087
2087
  package_default = {
2088
2088
  name: "@moxt-ai/mobius",
2089
- version: "0.0.302",
2089
+ version: "0.0.303",
2090
2090
  description: "Mobius CLI for pairing and running local AI agent services.",
2091
2091
  type: "module",
2092
2092
  bin: {
@@ -72906,6 +72906,46 @@ var init_access = __esm({
72906
72906
  }
72907
72907
  });
72908
72908
 
72909
+ // ../mobius-sdk/src/protocol/session/agent/catalog.ts
72910
+ var AGENT_CATALOG_DISCOVER_KIND, AGENT_CATALOG_DISCOVERED_KIND, AGENT_CATALOG_DISCOVERY_FAILED_KIND, catalogedAgentSchema, agentCatalogDiscoverCommandSchema, agentCatalogDiscoveredEventSchema, agentCatalogDiscoveryFailedEventSchema, decodeAgentCatalogDiscoverCommand, encodeAgentCatalogDiscoverCommand, decodeAgentCatalogDiscoveredEvent, encodeAgentCatalogDiscoveredEvent, decodeAgentCatalogDiscoveryFailedEvent, encodeAgentCatalogDiscoveryFailedEvent;
72911
+ var init_catalog = __esm({
72912
+ "../mobius-sdk/src/protocol/session/agent/catalog.ts"() {
72913
+ "use strict";
72914
+ init_zod();
72915
+ init_identifier();
72916
+ init_message_codec();
72917
+ AGENT_CATALOG_DISCOVER_KIND = "agent.catalog.discover";
72918
+ AGENT_CATALOG_DISCOVERED_KIND = "agent.catalog.discovered";
72919
+ AGENT_CATALOG_DISCOVERY_FAILED_KIND = "agent.catalog.discovery.failed";
72920
+ catalogedAgentSchema = external_exports.object({
72921
+ agentVersion: external_exports.string().min(1).max(128),
72922
+ id: identifierStringSchema,
72923
+ label: external_exports.string().min(1).max(255)
72924
+ }).readonly();
72925
+ agentCatalogDiscoverCommandSchema = external_exports.object({
72926
+ kind: external_exports.literal(AGENT_CATALOG_DISCOVER_KIND),
72927
+ requestId: identifierStringSchema
72928
+ }).readonly();
72929
+ agentCatalogDiscoveredEventSchema = external_exports.object({
72930
+ agents: external_exports.array(catalogedAgentSchema).max(64).readonly(),
72931
+ kind: external_exports.literal(AGENT_CATALOG_DISCOVERED_KIND),
72932
+ requestId: identifierStringSchema
72933
+ }).readonly();
72934
+ agentCatalogDiscoveryFailedEventSchema = external_exports.object({
72935
+ code: identifierStringSchema,
72936
+ kind: external_exports.literal(AGENT_CATALOG_DISCOVERY_FAILED_KIND),
72937
+ message: external_exports.string().min(1).max(500),
72938
+ requestId: identifierStringSchema
72939
+ }).readonly();
72940
+ decodeAgentCatalogDiscoverCommand = (encoded) => decodeZodMessage(encoded, agentCatalogDiscoverCommandSchema);
72941
+ encodeAgentCatalogDiscoverCommand = (message) => encodeZodMessage(message, agentCatalogDiscoverCommandSchema);
72942
+ decodeAgentCatalogDiscoveredEvent = (encoded) => decodeZodMessage(encoded, agentCatalogDiscoveredEventSchema);
72943
+ encodeAgentCatalogDiscoveredEvent = (message) => encodeZodMessage(message, agentCatalogDiscoveredEventSchema);
72944
+ decodeAgentCatalogDiscoveryFailedEvent = (encoded) => decodeZodMessage(encoded, agentCatalogDiscoveryFailedEventSchema);
72945
+ encodeAgentCatalogDiscoveryFailedEvent = (message) => encodeZodMessage(message, agentCatalogDiscoveryFailedEventSchema);
72946
+ }
72947
+ });
72948
+
72909
72949
  // ../mobius-sdk/src/protocol/session/shared/index.ts
72910
72950
  var SHORT_TEXT, workspaceEntrySchema, sessionStatusSchema, sessionCapabilitiesSchema, sessionCommandSchema, configValueSchema, sessionIdentityFields;
72911
72951
  var init_shared2 = __esm({
@@ -74859,6 +74899,7 @@ var init_daemon_transport = __esm({
74859
74899
  init_diagnostics();
74860
74900
  init_liveness();
74861
74901
  init_upgrade();
74902
+ init_catalog();
74862
74903
  init_settings2();
74863
74904
  init_configuration();
74864
74905
  init_title();
@@ -74882,6 +74923,11 @@ var init_daemon_transport = __esm({
74882
74923
  encodeAgentSettingsDiscoverCommand,
74883
74924
  decodeAgentSettingsDiscoverCommand
74884
74925
  ),
74926
+ [AGENT_CATALOG_DISCOVER_KIND]: defineMessageSignature(
74927
+ AGENT_CATALOG_DISCOVER_KIND,
74928
+ encodeAgentCatalogDiscoverCommand,
74929
+ decodeAgentCatalogDiscoverCommand
74930
+ ),
74885
74931
  [FILE_READ_KIND]: defineMessageSignature(FILE_READ_KIND, encodeFileReadCommand, decodeFileReadCommand),
74886
74932
  [SESSION_LIST_KIND]: defineMessageSignature(SESSION_LIST_KIND, encodeSessionListCommand, decodeSessionListCommand),
74887
74933
  [SESSION_QUERY_KIND]: defineMessageSignature(
@@ -75023,6 +75069,16 @@ var init_daemon_transport = __esm({
75023
75069
  encodeAgentSettingsDiscoveryFailedEvent,
75024
75070
  decodeAgentSettingsDiscoveryFailedEvent
75025
75071
  ),
75072
+ [AGENT_CATALOG_DISCOVERED_KIND]: defineMessageSignature(
75073
+ AGENT_CATALOG_DISCOVERED_KIND,
75074
+ encodeAgentCatalogDiscoveredEvent,
75075
+ decodeAgentCatalogDiscoveredEvent
75076
+ ),
75077
+ [AGENT_CATALOG_DISCOVERY_FAILED_KIND]: defineMessageSignature(
75078
+ AGENT_CATALOG_DISCOVERY_FAILED_KIND,
75079
+ encodeAgentCatalogDiscoveryFailedEvent,
75080
+ decodeAgentCatalogDiscoveryFailedEvent
75081
+ ),
75026
75082
  [FILE_BEGIN_KIND]: defineMessageSignature(FILE_BEGIN_KIND, encodeFileBeginEvent, decodeFileBeginEvent),
75027
75083
  [FILE_CHUNK_KIND]: defineMessageSignature(FILE_CHUNK_KIND, encodeFileChunkEvent, decodeFileChunkEvent),
75028
75084
  [FILE_END_KIND]: defineMessageSignature(FILE_END_KIND, encodeFileEndEvent, decodeFileEndEvent),
@@ -75108,6 +75164,7 @@ var init_protocol = __esm({
75108
75164
  init_liveness();
75109
75165
  init_upgrade();
75110
75166
  init_access();
75167
+ init_catalog();
75111
75168
  init_settings2();
75112
75169
  init_configuration();
75113
75170
  init_title();
@@ -81010,6 +81067,7 @@ var init_discover_local_agents = __esm({
81010
81067
  init_supported_agent_specifications();
81011
81068
  init_agent_discovery();
81012
81069
  init_executable_discovery();
81070
+ init_agent_discovery();
81013
81071
  }
81014
81072
  });
81015
81073
 
@@ -81190,12 +81248,33 @@ var init_publish_agent_catalog = __esm({
81190
81248
  }
81191
81249
  });
81192
81250
 
81251
+ // src/util/serial-task-queue.ts
81252
+ var SerialTaskQueue;
81253
+ var init_serial_task_queue = __esm({
81254
+ "src/util/serial-task-queue.ts"() {
81255
+ "use strict";
81256
+ SerialTaskQueue = class {
81257
+ #tail = Promise.resolve();
81258
+ run = async (task, signal) => {
81259
+ signal.throwIfAborted();
81260
+ const result = this.#tail.then(() => {
81261
+ signal.throwIfAborted();
81262
+ return task(signal);
81263
+ });
81264
+ this.#tail = result.catch(() => void 0);
81265
+ return await result;
81266
+ };
81267
+ };
81268
+ }
81269
+ });
81270
+
81193
81271
  // src/agent/catalog.ts
81194
81272
  var LocalAgentCatalogSnapshot, LocalAgentCatalogError, LocalAgentCatalog;
81195
- var init_catalog = __esm({
81273
+ var init_catalog2 = __esm({
81196
81274
  "src/agent/catalog.ts"() {
81197
81275
  "use strict";
81198
81276
  init_operation_error();
81277
+ init_serial_task_queue();
81199
81278
  LocalAgentCatalogSnapshot = class {
81200
81279
  agents;
81201
81280
  constructor(agents) {
@@ -81210,6 +81289,7 @@ var init_catalog = __esm({
81210
81289
  };
81211
81290
  LocalAgentCatalog = class {
81212
81291
  #snapshot;
81292
+ #updates = new SerialTaskQueue();
81213
81293
  constructor(agents) {
81214
81294
  this.#snapshot = this.validate(agents);
81215
81295
  }
@@ -81222,10 +81302,20 @@ var init_catalog = __esm({
81222
81302
  throw new LocalAgentCatalogError();
81223
81303
  };
81224
81304
  read = () => this.#snapshot;
81225
- transition = (agents) => {
81226
- const next = this.validate(agents);
81227
- this.#snapshot = next;
81228
- return next;
81305
+ /** Serializes replacements and publication; a failed publication restores only its own prior snapshot. */
81306
+ replaceAndPublish = async (build, publish, signal) => {
81307
+ return await this.#updates.run(async (updateSignal) => {
81308
+ const previous = this.#snapshot;
81309
+ const next = this.validate(build(previous.agents));
81310
+ this.#snapshot = next;
81311
+ try {
81312
+ await publish(updateSignal);
81313
+ } catch (error62) {
81314
+ this.#snapshot = previous;
81315
+ throw error62;
81316
+ }
81317
+ return next;
81318
+ }, signal);
81229
81319
  };
81230
81320
  validate = (agents) => {
81231
81321
  const identifiers = /* @__PURE__ */ new Set();
@@ -81256,7 +81346,7 @@ function withRuntimeEnvironment(agent, environment) {
81256
81346
  }
81257
81347
  return agent.withEnvironment({ ...launchEnvironment, ...agent.environment });
81258
81348
  }
81259
- function createRuntimeConfig(connection, agents = [], localContext = new RuntimeLocalContext(readStateDirectory(), process.env), reconnectTarget = null, resolveAgent) {
81349
+ function createRuntimeConfig(connection, agents = [], localContext = new RuntimeLocalContext(readStateDirectory(), process.env), reconnectTarget = null, resolveAgent, rediscoverAgents) {
81260
81350
  const runtimeAgents = agents.map((agent) => withRuntimeEnvironment(agent, localContext.environment));
81261
81351
  return {
81262
81352
  agents: runtimeAgents,
@@ -81267,7 +81357,8 @@ function createRuntimeConfig(connection, agents = [], localContext = new Runtime
81267
81357
  localContext,
81268
81358
  reconnectTarget,
81269
81359
  relayUrl: connection.relayUrl,
81270
- ...resolveAgent === void 0 ? {} : { resolveAgent }
81360
+ ...resolveAgent === void 0 ? {} : { resolveAgent },
81361
+ ...rediscoverAgents === void 0 ? {} : { rediscoverAgents }
81271
81362
  };
81272
81363
  }
81273
81364
  var RuntimeLocalContext, RuntimeReconnectTarget, OpaqueRuntimeReconnectTarget;
@@ -81275,7 +81366,7 @@ var init_config = __esm({
81275
81366
  "src/runtime/config.ts"() {
81276
81367
  "use strict";
81277
81368
  init_protocol();
81278
- init_catalog();
81369
+ init_catalog2();
81279
81370
  init_state_directory();
81280
81371
  RuntimeLocalContext = class {
81281
81372
  environment;
@@ -81325,21 +81416,17 @@ function createCatalogAgentResolver(discover, readConfig, publish) {
81325
81416
  signal.throwIfAborted();
81326
81417
  const inventory = await discover(signal);
81327
81418
  signal.throwIfAborted();
81328
- const previous = config2.catalog.read();
81329
- const previousAgent = previous.agents.find((entry) => entry.id === agent.id);
81330
- if (previousAgent === void 0) {
81331
- throw new Error(`The local Agent ${agent.id} left the catalog before its refresh completed`);
81332
- }
81333
- config2.catalog.transition([
81334
- ...previous.agents.filter((entry) => entry.id !== agent.id),
81335
- ...inventory.readyAgents().filter((ready) => ready.id === agent.id).map((ready) => withRuntimeEnvironment(ready, config2.localContext.environment))
81336
- ]);
81337
- try {
81338
- await publish(config2, signal);
81339
- } catch (error62) {
81340
- config2.catalog.transition(previous.agents);
81341
- throw error62;
81342
- }
81419
+ const rediscovered = inventory.readyAgents().filter((ready) => ready.id === agent.id).map((ready) => withRuntimeEnvironment(ready, config2.localContext.environment));
81420
+ await config2.catalog.replaceAndPublish(
81421
+ (current) => {
81422
+ if (!current.some((entry) => entry.id === agent.id)) {
81423
+ throw new Error(`The local Agent ${agent.id} left the catalog before its refresh completed`);
81424
+ }
81425
+ return [...current.filter((entry) => entry.id !== agent.id), ...rediscovered];
81426
+ },
81427
+ (publishSignal) => publish(config2, publishSignal),
81428
+ signal
81429
+ );
81343
81430
  return config2.catalog.find(agent.id);
81344
81431
  } finally {
81345
81432
  swaps.delete(agent.id);
@@ -82530,7 +82617,12 @@ function buildPairedRuntime(installation, connection, defaultWorkspace, inventor
82530
82617
  }),
82531
82618
  () => config2,
82532
82619
  publishAgentCatalog
82533
- )
82620
+ ),
82621
+ (refreshSignal) => discoverLocalAgentInventory({
82622
+ defaultWorkspace,
82623
+ environment: localContext.environment,
82624
+ signal: refreshSignal
82625
+ }).then((inventory2) => inventory2.readyAgents())
82534
82626
  );
82535
82627
  return {
82536
82628
  channelUrl: new URL(`/channels/${encodeURIComponent(connection.channelId)}`, connection.relayOrigin).toString(),
@@ -97754,6 +97846,169 @@ var init_diagnostics2 = __esm({
97754
97846
  }
97755
97847
  });
97756
97848
 
97849
+ // src/runtime/command/transport.ts
97850
+ import { WebSocket as WebSocket2 } from "undici";
97851
+ function send(socket, message) {
97852
+ if (socket.readyState !== WebSocket2.OPEN) {
97853
+ throw new Error("Relay connection is not open");
97854
+ }
97855
+ socket.send(encodeDaemonToServiceMessage(message));
97856
+ }
97857
+ function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTimings = []) {
97858
+ if (socket.readyState !== WebSocket2.OPEN) {
97859
+ return;
97860
+ }
97861
+ send(socket, {
97862
+ code: operationErrorCode(error62),
97863
+ kind: "session.operation.failed",
97864
+ message: operationErrorMessage(error62),
97865
+ requestId,
97866
+ ...runtimeTimings.length === 0 ? {} : { runtimeTimings },
97867
+ sessionId
97868
+ });
97869
+ }
97870
+ var init_transport = __esm({
97871
+ "src/runtime/command/transport.ts"() {
97872
+ "use strict";
97873
+ init_protocol();
97874
+ init_operation_error();
97875
+ }
97876
+ });
97877
+
97878
+ // src/runtime/catalog/handle-agent-catalog-discovery.ts
97879
+ import { WebSocket as WebSocket3 } from "undici";
97880
+ function discoveredEvent(command, agents) {
97881
+ return {
97882
+ agents: agents.map((agent) => ({
97883
+ agentVersion: agent.agentVersion,
97884
+ id: agent.id,
97885
+ label: agent.label
97886
+ })),
97887
+ kind: "agent.catalog.discovered",
97888
+ requestId: command.requestId
97889
+ };
97890
+ }
97891
+ function createAgentCatalogDiscoveryHandler(dependencies) {
97892
+ const { config: config2, discover, diagnostics, socket, signal, timer } = dependencies;
97893
+ const requestIds = /* @__PURE__ */ new Set();
97894
+ let controller = null;
97895
+ let completion = null;
97896
+ const handle = (command) => {
97897
+ if (requestIds.has(command.requestId) || controller !== null) {
97898
+ if (socket.readyState === WebSocket3.OPEN) {
97899
+ send(socket, {
97900
+ code: "agent_catalog_discovery_busy",
97901
+ kind: AGENT_CATALOG_DISCOVERY_FAILED_KIND,
97902
+ message: "An Agent catalog discovery is already running",
97903
+ requestId: command.requestId
97904
+ });
97905
+ }
97906
+ return;
97907
+ }
97908
+ controller = new AbortController();
97909
+ requestIds.add(command.requestId);
97910
+ const operationSignal = AbortSignal.any([signal, controller.signal]);
97911
+ const timeout = timer.schedule(
97912
+ () => controller?.abort(new Error("Agent catalog discovery timed out")),
97913
+ CATALOG_DISCOVERY_TIMEOUT_MILLISECONDS
97914
+ );
97915
+ completion = (async () => {
97916
+ try {
97917
+ const readyAgents = await discover(operationSignal);
97918
+ operationSignal.throwIfAborted();
97919
+ const published = await config2.catalog.replaceAndPublish(
97920
+ () => readyAgents.map((agent) => withRuntimeEnvironment(agent, config2.localContext.environment)),
97921
+ (publishSignal) => publishAgentCatalog(config2, publishSignal),
97922
+ operationSignal
97923
+ );
97924
+ operationSignal.throwIfAborted();
97925
+ if (socket.readyState === WebSocket3.OPEN) {
97926
+ send(
97927
+ socket,
97928
+ discoveredEvent(
97929
+ command,
97930
+ published.agents.map((agent) => ({
97931
+ agentVersion: agent.agentVersion,
97932
+ id: agent.id,
97933
+ label: agent.label
97934
+ }))
97935
+ )
97936
+ );
97937
+ }
97938
+ } catch (error62) {
97939
+ diagnostics.daemonDiagnostic(
97940
+ "agent_catalog_discovery_failed",
97941
+ command.requestId,
97942
+ { code: operationErrorCode(error62) },
97943
+ error62
97944
+ );
97945
+ if (socket.readyState === WebSocket3.OPEN) {
97946
+ send(socket, {
97947
+ code: operationErrorCode(error62),
97948
+ kind: AGENT_CATALOG_DISCOVERY_FAILED_KIND,
97949
+ message: operationErrorMessage(error62),
97950
+ requestId: command.requestId
97951
+ });
97952
+ }
97953
+ } finally {
97954
+ timeout.cancel();
97955
+ requestIds.delete(command.requestId);
97956
+ controller = null;
97957
+ completion = null;
97958
+ }
97959
+ })();
97960
+ };
97961
+ const settle2 = async () => {
97962
+ await (completion ?? Promise.resolve());
97963
+ };
97964
+ return { handle, settle: settle2 };
97965
+ }
97966
+ var CATALOG_DISCOVERY_TIMEOUT_MILLISECONDS;
97967
+ var init_handle_agent_catalog_discovery = __esm({
97968
+ "src/runtime/catalog/handle-agent-catalog-discovery.ts"() {
97969
+ "use strict";
97970
+ init_protocol();
97971
+ init_operation_error();
97972
+ init_transport();
97973
+ init_config();
97974
+ init_publish_agent_catalog();
97975
+ CATALOG_DISCOVERY_TIMEOUT_MILLISECONDS = 9e4;
97976
+ }
97977
+ });
97978
+
97979
+ // src/runtime/command/registry/agent-catalog.ts
97980
+ function createAgentCatalogCommands(context) {
97981
+ const handler = createAgentCatalogDiscoveryHandler({
97982
+ config: context.config,
97983
+ discover: context.config.rediscoverAgents === void 0 ? () => {
97984
+ throw new Error("Agent catalog discovery is not available for this Runtime");
97985
+ } : context.config.rediscoverAgents,
97986
+ diagnostics: context.diagnostics,
97987
+ socket: context.socket,
97988
+ signal: context.signal,
97989
+ timer: context.timer
97990
+ });
97991
+ return [
97992
+ {
97993
+ kind: AGENT_CATALOG_DISCOVER_KIND,
97994
+ handle: (_context, message) => {
97995
+ if (message.kind !== AGENT_CATALOG_DISCOVER_KIND) {
97996
+ throw new Error("Command kind mismatch");
97997
+ }
97998
+ handler.handle(message);
97999
+ },
98000
+ settle: handler.settle
98001
+ }
98002
+ ];
98003
+ }
98004
+ var init_agent_catalog = __esm({
98005
+ "src/runtime/command/registry/agent-catalog.ts"() {
98006
+ "use strict";
98007
+ init_protocol();
98008
+ init_handle_agent_catalog_discovery();
98009
+ }
98010
+ });
98011
+
97757
98012
  // src/session/api/session-error.ts
97758
98013
  var SessionError;
97759
98014
  var init_session_error = __esm({
@@ -98127,37 +98382,8 @@ var init_discover_agent_settings = __esm({
98127
98382
  }
98128
98383
  });
98129
98384
 
98130
- // src/runtime/command/transport.ts
98131
- import { WebSocket as WebSocket2 } from "undici";
98132
- function send(socket, message) {
98133
- if (socket.readyState !== WebSocket2.OPEN) {
98134
- throw new Error("Relay connection is not open");
98135
- }
98136
- socket.send(encodeDaemonToServiceMessage(message));
98137
- }
98138
- function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTimings = []) {
98139
- if (socket.readyState !== WebSocket2.OPEN) {
98140
- return;
98141
- }
98142
- send(socket, {
98143
- code: operationErrorCode(error62),
98144
- kind: "session.operation.failed",
98145
- message: operationErrorMessage(error62),
98146
- requestId,
98147
- ...runtimeTimings.length === 0 ? {} : { runtimeTimings },
98148
- sessionId
98149
- });
98150
- }
98151
- var init_transport = __esm({
98152
- "src/runtime/command/transport.ts"() {
98153
- "use strict";
98154
- init_protocol();
98155
- init_operation_error();
98156
- }
98157
- });
98158
-
98159
98385
  // src/runtime/command/agent-settings-discovery.ts
98160
- import { WebSocket as WebSocket3 } from "undici";
98386
+ import { WebSocket as WebSocket4 } from "undici";
98161
98387
  function createAgentSettingsDiscoveryHandler(dependencies) {
98162
98388
  const { config: config2, directories, sessions, diagnostics, socket, signal, timer } = dependencies;
98163
98389
  const agentSettingsDiscoveries = /* @__PURE__ */ new Map();
@@ -98166,7 +98392,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
98166
98392
  (request) => request.agentId === command.agentId && !request.controller.signal.aborted
98167
98393
  );
98168
98394
  if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
98169
- if (socket.readyState === WebSocket3.OPEN) {
98395
+ if (socket.readyState === WebSocket4.OPEN) {
98170
98396
  send(socket, {
98171
98397
  code: "agent_settings_discovery_busy",
98172
98398
  kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
@@ -98181,7 +98407,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
98181
98407
  return;
98182
98408
  }
98183
98409
  if (existing !== void 0) {
98184
- if (socket.readyState === WebSocket3.OPEN) {
98410
+ if (socket.readyState === WebSocket4.OPEN) {
98185
98411
  send(socket, {
98186
98412
  code: "agent_settings_discovery_busy",
98187
98413
  kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
@@ -98192,7 +98418,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
98192
98418
  return;
98193
98419
  }
98194
98420
  if (agentSettingsDiscoveries.size >= 4) {
98195
- if (socket.readyState === WebSocket3.OPEN) {
98421
+ if (socket.readyState === WebSocket4.OPEN) {
98196
98422
  send(socket, {
98197
98423
  code: "agent_settings_discovery_busy",
98198
98424
  kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
@@ -98230,7 +98456,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
98230
98456
  );
98231
98457
  }
98232
98458
  for (const requestId of requestIds) {
98233
- if (socket.readyState === WebSocket3.OPEN) {
98459
+ if (socket.readyState === WebSocket4.OPEN) {
98234
98460
  send(socket, { ...result.event, requestId });
98235
98461
  }
98236
98462
  }
@@ -98244,7 +98470,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
98244
98470
  `
98245
98471
  );
98246
98472
  }
98247
- if (socket.readyState === WebSocket3.OPEN) {
98473
+ if (socket.readyState === WebSocket4.OPEN) {
98248
98474
  for (const requestId of requestIds) {
98249
98475
  send(socket, {
98250
98476
  code: operationErrorCode(failure2),
@@ -98414,7 +98640,7 @@ var init_session_files = __esm({
98414
98640
  });
98415
98641
 
98416
98642
  // src/runtime/command/registry/file-read/index.ts
98417
- import { WebSocket as WebSocket4 } from "undici";
98643
+ import { WebSocket as WebSocket5 } from "undici";
98418
98644
  var fileReadCommand;
98419
98645
  var init_file_read = __esm({
98420
98646
  "src/runtime/command/registry/file-read/index.ts"() {
@@ -98435,7 +98661,7 @@ var init_file_read = __esm({
98435
98661
  sessions.findSessions([message.sessionId])[0]?.cwd ?? null,
98436
98662
  externalContent
98437
98663
  ).catch((error62) => {
98438
- if (socket.readyState !== WebSocket4.OPEN || signal.aborted) {
98664
+ if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
98439
98665
  return;
98440
98666
  }
98441
98667
  send(socket, {
@@ -98808,7 +99034,7 @@ var init_interactions2 = __esm({
98808
99034
  });
98809
99035
 
98810
99036
  // src/runtime/command/native-session-requests.ts
98811
- import { WebSocket as WebSocket5 } from "undici";
99037
+ import { WebSocket as WebSocket6 } from "undici";
98812
99038
  function createNativeSessionRequestHandler(dependencies) {
98813
99039
  const { diagnostics, nativeSessions, signal, socket, timer } = dependencies;
98814
99040
  const pending = /* @__PURE__ */ new Map();
@@ -98860,7 +99086,7 @@ function createNativeSessionRequestHandler(dependencies) {
98860
99086
  }
98861
99087
  operationSignal.throwIfAborted();
98862
99088
  const result = await nativeSessions.execute(command, operationSignal);
98863
- if (socket.readyState === WebSocket5.OPEN) {
99089
+ if (socket.readyState === WebSocket6.OPEN) {
98864
99090
  send(socket, result);
98865
99091
  }
98866
99092
  } catch (error62) {
@@ -100045,6 +100271,7 @@ function createCommandRegistry(context) {
100045
100271
  sessionHistoryPageLoadCommand,
100046
100272
  previewHistoryPageLoadCommand,
100047
100273
  ...createNativeSessionCommands(context),
100274
+ ...createAgentCatalogCommands(context),
100048
100275
  ...createAgentSettingsCommands(context),
100049
100276
  fileReadCommand,
100050
100277
  sessionCancelCommand,
@@ -100076,6 +100303,7 @@ function createCommandRegistry(context) {
100076
100303
  var init_registry2 = __esm({
100077
100304
  "src/runtime/command/registry/index.ts"() {
100078
100305
  "use strict";
100306
+ init_agent_catalog();
100079
100307
  init_agent_settings();
100080
100308
  init_file_read();
100081
100309
  init_history2();
@@ -100123,14 +100351,14 @@ var init_runtime_revocation = __esm({
100123
100351
  });
100124
100352
 
100125
100353
  // src/runtime/relay/connect.ts
100126
- import { WebSocket as WebSocket6 } from "undici";
100354
+ import { WebSocket as WebSocket7 } from "undici";
100127
100355
  function connectRelay(url2, signal) {
100128
100356
  signal.throwIfAborted();
100129
100357
  return new Promise((resolve20, reject2) => {
100130
100358
  const endpoint = new URL(url2);
100131
100359
  const headers = relayAuthorization(endpoint);
100132
100360
  endpoint.searchParams.delete("token");
100133
- const socket = new WebSocket6(endpoint, {
100361
+ const socket = new WebSocket7(endpoint, {
100134
100362
  dispatcher: environmentProxyDispatcher,
100135
100363
  headers
100136
100364
  });
@@ -100335,7 +100563,7 @@ var init_liveness2 = __esm({
100335
100563
  });
100336
100564
 
100337
100565
  // src/runtime/relay/run-relay-connection.ts
100338
- import { WebSocket as WebSocket7 } from "undici";
100566
+ import { WebSocket as WebSocket8 } from "undici";
100339
100567
  function closeRelaySocket(socket, code, reason) {
100340
100568
  try {
100341
100569
  socket.close(code, reason);
@@ -100366,7 +100594,7 @@ function readCommandCorrelation(encoded) {
100366
100594
  };
100367
100595
  }
100368
100596
  function rejectUnsupportedCommand(socket, correlation, rejection) {
100369
- if (socket.readyState !== WebSocket7.OPEN) {
100597
+ if (socket.readyState !== WebSocket8.OPEN) {
100370
100598
  return;
100371
100599
  }
100372
100600
  send(socket, {
@@ -100414,7 +100642,7 @@ async function runRelayConnection({
100414
100642
  timer
100415
100643
  });
100416
100644
  void reportUpgradeAvailability((result) => {
100417
- if (socket.readyState === WebSocket7.OPEN) {
100645
+ if (socket.readyState === WebSocket8.OPEN) {
100418
100646
  send(socket, result);
100419
100647
  }
100420
100648
  }, signal).catch((cause) => {
@@ -100465,14 +100693,14 @@ async function runRelayConnection({
100465
100693
  };
100466
100694
  const connectionLiveness = new RelayConnectionLiveness(timer, {
100467
100695
  send: (message) => {
100468
- if (socket.readyState !== WebSocket7.OPEN) {
100696
+ if (socket.readyState !== WebSocket8.OPEN) {
100469
100697
  return false;
100470
100698
  }
100471
100699
  try {
100472
100700
  send(socket, message);
100473
100701
  return true;
100474
100702
  } catch (error62) {
100475
- if (socket.readyState !== WebSocket7.OPEN) {
100703
+ if (socket.readyState !== WebSocket8.OPEN) {
100476
100704
  return false;
100477
100705
  }
100478
100706
  throw error62;
@@ -100589,7 +100817,7 @@ var init_run_relay_connection = __esm({
100589
100817
  });
100590
100818
 
100591
100819
  // src/runtime/relay/session-event-publisher.ts
100592
- import { WebSocket as WebSocket8 } from "undici";
100820
+ import { WebSocket as WebSocket9 } from "undici";
100593
100821
  var MAX_BUFFERED_BYTES, MAX_PENDING_BYTES2, MAX_EVENT_BATCH_BYTES, MAX_FRAME_BYTES, LOCAL_BACKPRESSURE_CLOSE_CODE, EMPTY_ENVELOPE_BYTES, SESSION_EVENT_BATCH_WINDOW_MILLISECONDS, RuntimeSessionEventPublisher;
100594
100822
  var init_session_event_publisher = __esm({
100595
100823
  "src/runtime/relay/session-event-publisher.ts"() {
@@ -100644,7 +100872,7 @@ var init_session_event_publisher = __esm({
100644
100872
  publishClosed = (event) => this.#send(event);
100645
100873
  #send = (message) => {
100646
100874
  const connection = this.#connection;
100647
- if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket8.OPEN) {
100875
+ if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket9.OPEN) {
100648
100876
  return;
100649
100877
  }
100650
100878
  const socket = connection.socket;
@@ -100695,7 +100923,7 @@ var init_session_event_publisher = __esm({
100695
100923
  batch.bytes += bytes;
100696
100924
  this.#pendingBytes += additionalBytes;
100697
100925
  const connection = this.#connection;
100698
- if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket8.OPEN) {
100926
+ if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket9.OPEN) {
100699
100927
  return;
100700
100928
  }
100701
100929
  const socket = connection.socket;
@@ -100715,7 +100943,7 @@ var init_session_event_publisher = __esm({
100715
100943
  flushEvents = (socket) => {
100716
100944
  this.cancelFlush();
100717
100945
  const connection = this.#connection;
100718
- if (connection.kind !== "connected" || connection.socket !== socket || socket.readyState !== WebSocket8.OPEN) {
100946
+ if (connection.kind !== "connected" || connection.socket !== socket || socket.readyState !== WebSocket9.OPEN) {
100719
100947
  return;
100720
100948
  }
100721
100949
  let attempted = 0;