@moxt-ai/mobius 0.0.37 → 0.0.38

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.
package/dist/runtime.js CHANGED
@@ -1233,6 +1233,7 @@ var ClaudeCodeAgentSpecification = class extends BridgedAcpAgentDefinition {
1233
1233
 
1234
1234
  // src/agent-catalog/agents/codex-agent.ts
1235
1235
  var CodexAgentSpecification = class extends BridgedAcpAgentDefinition {
1236
+ versionProbeTimeoutMilliseconds = 1e4;
1236
1237
  adapterEnvironmentVariable = "CODEX_PATH";
1237
1238
  adapterOverrideVariable = "MOBIUS_CODEX_ACP_PATH";
1238
1239
  adapterPackageDefinition = new ManagedNpmPackageDefinition(
@@ -22545,6 +22546,9 @@ var AGENT_INSTALL_PROGRESS_KIND = "agent.integration.install.progress";
22545
22546
  var AGENT_INSTALL_COMPLETED_KIND = "agent.integration.install.completed";
22546
22547
  var AGENT_INSTALL_FAILED_KIND = "agent.integration.install.failed";
22547
22548
  var AGENT_INSTALL_CANCELLED_KIND = "agent.integration.install.cancelled";
22549
+ var AGENT_SETTINGS_DISCOVER_KIND = "agent.settings.discover";
22550
+ var AGENT_SETTINGS_DISCOVERED_KIND = "agent.settings.discovered";
22551
+ var AGENT_SETTINGS_DISCOVERY_FAILED_KIND = "agent.settings.discovery.failed";
22548
22552
  var IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
22549
22553
  var DIRECTORY_IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
22550
22554
  var IDENTIFIER = external_exports.string().min(1).max(128).regex(IDENTIFIER_PATTERN);
@@ -22573,6 +22577,28 @@ var sessionConfigOptionSchema = external_exports.strictObject({
22573
22577
  values: external_exports.array(configValueSchema).max(500).readonly()
22574
22578
  }).readonly();
22575
22579
  var sessionConfigOptionsSchema = external_exports.array(sessionConfigOptionSchema).max(100).readonly();
22580
+ var agentSettingsDiscoverCommandSchema = external_exports.strictObject({
22581
+ additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
22582
+ agentId: IDENTIFIER,
22583
+ directoryId: DIRECTORY_IDENTIFIER,
22584
+ kind: external_exports.literal(AGENT_SETTINGS_DISCOVER_KIND),
22585
+ requestId: IDENTIFIER
22586
+ }).readonly();
22587
+ var agentSettingsDiscoveredEventSchema = external_exports.strictObject({
22588
+ agentId: IDENTIFIER,
22589
+ agentName: external_exports.string().max(255),
22590
+ agentVersion: external_exports.string().max(128),
22591
+ configOptions: sessionConfigOptionsSchema,
22592
+ directoryId: DIRECTORY_IDENTIFIER,
22593
+ kind: external_exports.literal(AGENT_SETTINGS_DISCOVERED_KIND),
22594
+ requestId: IDENTIFIER
22595
+ }).readonly();
22596
+ var agentSettingsDiscoveryFailedEventSchema = external_exports.strictObject({
22597
+ code: IDENTIFIER,
22598
+ kind: external_exports.literal(AGENT_SETTINGS_DISCOVERY_FAILED_KIND),
22599
+ message: external_exports.string().min(1).max(500),
22600
+ requestId: IDENTIFIER
22601
+ }).readonly();
22576
22602
  var sessionConfigurationSelectionSchema = external_exports.strictObject({
22577
22603
  booleanValue: external_exports.boolean(),
22578
22604
  configId: IDENTIFIER,
@@ -22709,6 +22735,7 @@ var sessionPrepareCommandSchema = external_exports.strictObject({
22709
22735
  }).readonly().optional(),
22710
22736
  kind: external_exports.literal(SESSION_PREPARE_KIND),
22711
22737
  requestId: IDENTIFIER,
22738
+ /** @deprecated Reserved for the legacy Bot Agent-configuration endpoint. */
22712
22739
  transient: external_exports.boolean().optional()
22713
22740
  }).readonly();
22714
22741
  var runtimeTimingsSchema = external_exports.array(
@@ -22922,6 +22949,9 @@ var decodePromptImagesValue = (value) => decodeValue(value, external_exports.arr
22922
22949
  var decodePromptResourcesValue = (value) => decodeValue(value, external_exports.array(promptResourceSchema).max(16).readonly());
22923
22950
  var decodeSessionConfigurationSelections = (value) => decodeValue(value, sessionConfigurationSelectionsSchema);
22924
22951
  var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
22952
+ var decodeAgentSettingsDiscoverCommand = (encoded) => decode3(encoded, agentSettingsDiscoverCommandSchema);
22953
+ var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
22954
+ var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
22925
22955
  var decodeWorkspaceListCommand = (encoded) => decode3(encoded, workspaceListCommandSchema);
22926
22956
  var encodeWorkspaceEntriesEvent = (message) => encode3(message, workspaceEntriesEventSchema);
22927
22957
  var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
@@ -32915,6 +32945,16 @@ var AcpPreparedSession = class {
32915
32945
  this.restored = restored;
32916
32946
  }
32917
32947
  };
32948
+ var AcpAgentSettingsSnapshot = class {
32949
+ agentName;
32950
+ agentVersion;
32951
+ configOptions;
32952
+ constructor(agentName, agentVersion, configOptions) {
32953
+ this.agentName = agentName;
32954
+ this.agentVersion = agentVersion;
32955
+ this.configOptions = configOptions;
32956
+ }
32957
+ };
32918
32958
  var AcpExecutionError = class extends Error {
32919
32959
  code;
32920
32960
  constructor(message, options = {}, code = "acp_execution_failed") {
@@ -34538,6 +34578,7 @@ var AcpProcessSession = class _AcpProcessSession {
34538
34578
  };
34539
34579
  var AcpSessionManager = class {
34540
34580
  #activeCommandIds = /* @__PURE__ */ new Map();
34581
+ #agentSettingsObserver = new NullAcpSessionObserver();
34541
34582
  #nativeOperations = /* @__PURE__ */ new Set();
34542
34583
  #nativeBrowserObserver = new NullAcpSessionObserver();
34543
34584
  #nativeBrowserPreparing = /* @__PURE__ */ new Map();
@@ -34732,9 +34773,29 @@ var AcpSessionManager = class {
34732
34773
  return runtime.prepared();
34733
34774
  };
34734
34775
  /**
34735
- * Opens a short-lived ACP session only to read the Agent's authoritative
34736
- * configuration options. The runtime and any persisted native-session
34737
- * record are released before this method resolves.
34776
+ * Opens a short-lived native ACP session only to read the local Agent's
34777
+ * authoritative settings. Its identity and store are private to this
34778
+ * operation and never become a Mobius Session.
34779
+ */
34780
+ inspectAgentSettings = async (options) => {
34781
+ const runtime = await AcpProcessSession.start(
34782
+ {
34783
+ ...options,
34784
+ sessionId: `agent-settings-${crypto.randomUUID()}`
34785
+ },
34786
+ () => this.#agentSettingsObserver,
34787
+ new MemoryAcpSessionStore()
34788
+ );
34789
+ try {
34790
+ const prepared = runtime.prepared();
34791
+ return new AcpAgentSettingsSnapshot(prepared.agentName, prepared.agentVersion, prepared.configOptions);
34792
+ } finally {
34793
+ await runtime.close();
34794
+ }
34795
+ };
34796
+ /**
34797
+ * @deprecated Retained for the Bot-scoped legacy Agent-configuration API.
34798
+ * Use inspectAgentSettings for Agent-scoped settings discovery.
34738
34799
  */
34739
34800
  inspectSession = async (options, metrics = unmeasuredOperationMetrics) => {
34740
34801
  if (this.#preparing.has(options.sessionId) || this.#sessions.has(options.sessionId)) {
@@ -35267,6 +35328,7 @@ async function publishAgentCatalog(config2, signal) {
35267
35328
  agents: catalog.agents.map((agent) => ({
35268
35329
  agentPath: agent.agentIdentity.requestedPath,
35269
35330
  agentVersion: agent.agentVersion,
35331
+ agentSettingsDiscovery: true,
35270
35332
  botSessionConfiguration: true,
35271
35333
  capabilities: agent.capabilities,
35272
35334
  id: agent.id,
@@ -35656,23 +35718,19 @@ var FixedInstallationExecutor = class {
35656
35718
  this.#catalog.transition(previous2.agents, previous2.installableAgents);
35657
35719
  throw error62;
35658
35720
  }
35659
- const alreadyReady = initialInventory.available.find((candidate2) => candidate2.specification.id === agentId);
35721
+ const alreadyReady = initialInventory.available.find((candidate) => candidate.specification.id === agentId);
35660
35722
  if (alreadyReady instanceof AvailableAgent) {
35661
35723
  return;
35662
35724
  }
35663
- const candidate = initialInventory.installable.find((agent2) => agent2.id === agentId);
35664
- if (candidate instanceof MissingAgentDefinition) {
35725
+ const initialDiscovery = initialInventory.unavailable.find(
35726
+ (candidate) => candidate.specification.id === agentId
35727
+ );
35728
+ if (initialDiscovery instanceof MissingAgent) {
35665
35729
  throw new InstallationManagerError(
35666
35730
  "agent_not_installed",
35667
35731
  `Install ${specification.label} on this machine, then try installing the integration again.`
35668
35732
  );
35669
35733
  }
35670
- if (!(candidate instanceof AgentIntegrationDefinition)) {
35671
- throw new InstallationManagerError(
35672
- "agent_verification_failed",
35673
- "The local Agent discovery result is unavailable"
35674
- );
35675
- }
35676
35734
  const verifiedAgent = await findVerifiedAgentExecutable(specification, discoveryOptions);
35677
35735
  if (verifiedAgent === null) {
35678
35736
  throw new InstallationManagerError(
@@ -35714,7 +35772,7 @@ var FixedInstallationExecutor = class {
35714
35772
  signal,
35715
35773
  specifications: this.#specifications
35716
35774
  });
35717
- const verified = inventory.available.find((candidate2) => candidate2.specification.id === agentId);
35775
+ const verified = inventory.available.find((candidate) => candidate.specification.id === agentId);
35718
35776
  if (verified instanceof AvailableAgent) {
35719
35777
  this.#audit.record("agent_installation_acp_verified", requestId, agentId, {
35720
35778
  adapterVersion: verified.agent.adapterVersion,
@@ -35730,7 +35788,7 @@ var FixedInstallationExecutor = class {
35730
35788
  }
35731
35789
  return;
35732
35790
  }
35733
- const unavailable = inventory.unavailable.find((candidate2) => candidate2.specification.id === agentId);
35791
+ const unavailable = inventory.unavailable.find((candidate) => candidate.specification.id === agentId);
35734
35792
  if (unavailable === void 0) {
35735
35793
  throw new InstallationManagerError(
35736
35794
  "agent_verification_failed",
@@ -39571,6 +39629,31 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
39571
39629
  }
39572
39630
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
39573
39631
  }
39632
+ async function discoverAgentSettings(command, config2, directories, sessions, signal) {
39633
+ const resolved = await resolveSessionDirectories(
39634
+ directories,
39635
+ config2.bindingId,
39636
+ command.directoryId,
39637
+ command.additionalDirectoryIds,
39638
+ signal
39639
+ );
39640
+ const agent = config2.catalog.find(command.agentId);
39641
+ const snapshot = await sessions.inspectAgentSettings({
39642
+ additionalDirectories: resolved.additionalDirectories,
39643
+ agent,
39644
+ cwd: resolved.cwd,
39645
+ signal
39646
+ });
39647
+ return {
39648
+ agentId: command.agentId,
39649
+ agentName: snapshot.agentName,
39650
+ agentVersion: snapshot.agentVersion,
39651
+ configOptions: snapshot.configOptions,
39652
+ directoryId: command.directoryId,
39653
+ kind: AGENT_SETTINGS_DISCOVERED_KIND,
39654
+ requestId: command.requestId
39655
+ };
39656
+ }
39574
39657
  async function executeWorkspaceList(socket, command, directories, audit, signal) {
39575
39658
  try {
39576
39659
  const listing = await directories.list(command.bindingId, command.directoryId, signal);
@@ -40098,6 +40181,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
40098
40181
  onConnected();
40099
40182
  const connectionController = new AbortController();
40100
40183
  const nativeRequests = /* @__PURE__ */ new Map();
40184
+ const agentSettingsDiscoveries = /* @__PURE__ */ new Map();
40101
40185
  installationObserver.connect(socket);
40102
40186
  try {
40103
40187
  await new Promise((resolve6, reject) => {
@@ -40525,6 +40609,104 @@ async function runRelayConnection(config2, directories, audit, sessions, install
40525
40609
  }
40526
40610
  return;
40527
40611
  }
40612
+ if (kind === AGENT_SETTINGS_DISCOVER_KIND) {
40613
+ const command2 = decodeAgentSettingsDiscoverCommand(encoded);
40614
+ const existing = [...agentSettingsDiscoveries.values()].find(
40615
+ (request) => request.agentId === command2.agentId && !request.controller.signal.aborted
40616
+ );
40617
+ if (agentSettingsDiscoveries.has(command2.requestId) || existing !== void 0) {
40618
+ if (socket.readyState === WebSocket2.OPEN) {
40619
+ send(
40620
+ socket,
40621
+ encodeAgentSettingsDiscoveryFailedEvent({
40622
+ code: "agent_settings_discovery_busy",
40623
+ kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
40624
+ message: "Another settings discovery is already running for this Agent",
40625
+ requestId: command2.requestId
40626
+ })
40627
+ );
40628
+ }
40629
+ return;
40630
+ }
40631
+ if (agentSettingsDiscoveries.size >= 4) {
40632
+ if (socket.readyState === WebSocket2.OPEN) {
40633
+ send(
40634
+ socket,
40635
+ encodeAgentSettingsDiscoveryFailedEvent({
40636
+ code: "agent_settings_discovery_busy",
40637
+ kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
40638
+ message: "Too many Agent settings discoveries are running",
40639
+ requestId: command2.requestId
40640
+ })
40641
+ );
40642
+ }
40643
+ return;
40644
+ }
40645
+ const controller = new AbortController();
40646
+ const operationSignal = AbortSignal.any([connectionController.signal, controller.signal]);
40647
+ const timeout = timer.schedule(
40648
+ () => controller.abort(
40649
+ new AcpExecutionError(
40650
+ "Agent settings discovery timed out",
40651
+ {},
40652
+ "agent_settings_discovery_timeout"
40653
+ )
40654
+ ),
40655
+ 9e4
40656
+ );
40657
+ const completion = (async () => {
40658
+ try {
40659
+ const result = await discoverAgentSettings(
40660
+ command2,
40661
+ config2,
40662
+ directories,
40663
+ sessions,
40664
+ operationSignal
40665
+ );
40666
+ audit.record({
40667
+ commandId: command2.requestId,
40668
+ details: { agentId: command2.agentId, directoryId: command2.directoryId },
40669
+ event: "agent_settings_discovered",
40670
+ sessionId: `agent-settings:${command2.agentId}`
40671
+ });
40672
+ if (socket.readyState === WebSocket2.OPEN) {
40673
+ send(socket, encodeAgentSettingsDiscoveredEvent(result));
40674
+ }
40675
+ } catch (error62) {
40676
+ const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
40677
+ "Agent settings discovery cancelled",
40678
+ {},
40679
+ "agent_settings_discovery_cancelled"
40680
+ ) : error62;
40681
+ audit.record({
40682
+ commandId: command2.requestId,
40683
+ details: { agentId: command2.agentId, code: operationErrorCode(failure2) },
40684
+ event: "agent_settings_discovery_failed",
40685
+ sessionId: `agent-settings:${command2.agentId}`
40686
+ });
40687
+ if (socket.readyState === WebSocket2.OPEN) {
40688
+ send(
40689
+ socket,
40690
+ encodeAgentSettingsDiscoveryFailedEvent({
40691
+ code: operationErrorCode(failure2),
40692
+ kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
40693
+ message: operationErrorMessage(failure2),
40694
+ requestId: command2.requestId
40695
+ })
40696
+ );
40697
+ }
40698
+ } finally {
40699
+ timeout.cancel();
40700
+ agentSettingsDiscoveries.delete(command2.requestId);
40701
+ }
40702
+ })();
40703
+ agentSettingsDiscoveries.set(command2.requestId, {
40704
+ agentId: command2.agentId,
40705
+ completion,
40706
+ controller
40707
+ });
40708
+ return;
40709
+ }
40528
40710
  if (kind === NATIVE_SESSION_REQUEST_KIND) {
40529
40711
  const command2 = decodeNativeSessionCommand(encoded);
40530
40712
  const previous2 = [...nativeRequests.values()].filter(
@@ -40909,7 +41091,10 @@ async function runRelayConnection(config2, directories, audit, sessions, install
40909
41091
  });
40910
41092
  } finally {
40911
41093
  connectionController.abort();
40912
- await Promise.all([...nativeRequests.values()].map((request) => request.completion));
41094
+ await Promise.all([
41095
+ ...[...nativeRequests.values()].map((request) => request.completion),
41096
+ ...[...agentSettingsDiscoveries.values()].map((request) => request.completion)
41097
+ ]);
40913
41098
  }
40914
41099
  }
40915
41100
  async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
@@ -40954,6 +41139,15 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
40954
41139
  );
40955
41140
  let connectionEpoch = 0;
40956
41141
  let connectionAnnounced = false;
41142
+ let catalogPublished = false;
41143
+ let readinessAnnounced = false;
41144
+ const announceReadiness = () => {
41145
+ if (!connectionAnnounced || !catalogPublished || readinessAnnounced) {
41146
+ return;
41147
+ }
41148
+ readinessAnnounced = true;
41149
+ process.stdout.write("Mobius daemon is ready for Agent requests.\n");
41150
+ };
40957
41151
  const announceConnection = () => {
40958
41152
  if (connectionAnnounced) {
40959
41153
  return;
@@ -40967,8 +41161,16 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
40967
41161
 
40968
41162
  `
40969
41163
  );
41164
+ announceReadiness();
40970
41165
  };
40971
41166
  const catalogPublication = publishAgentCatalogUntilAvailable(config2, diagnostics, signal, timer);
41167
+ void catalogPublication.then(() => {
41168
+ if (signal.aborted) {
41169
+ return;
41170
+ }
41171
+ catalogPublished = true;
41172
+ announceReadiness();
41173
+ });
40972
41174
  try {
40973
41175
  await ipc.listen(signal);
40974
41176
  while (!signal.aborted) {
@@ -41171,6 +41373,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
41171
41373
  const agents = localAgents.map((agent) => ({
41172
41374
  agentPath: agent.agentIdentity.requestedPath,
41173
41375
  agentVersion: agent.agentVersion,
41376
+ agentSettingsDiscovery: true,
41174
41377
  botSessionConfiguration: true,
41175
41378
  capabilities: agent.capabilities,
41176
41379
  id: agent.id,