@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/index.js CHANGED
@@ -19804,6 +19804,9 @@ var AGENT_INSTALL_PROGRESS_KIND = "agent.integration.install.progress";
19804
19804
  var AGENT_INSTALL_COMPLETED_KIND = "agent.integration.install.completed";
19805
19805
  var AGENT_INSTALL_FAILED_KIND = "agent.integration.install.failed";
19806
19806
  var AGENT_INSTALL_CANCELLED_KIND = "agent.integration.install.cancelled";
19807
+ var AGENT_SETTINGS_DISCOVER_KIND = "agent.settings.discover";
19808
+ var AGENT_SETTINGS_DISCOVERED_KIND = "agent.settings.discovered";
19809
+ var AGENT_SETTINGS_DISCOVERY_FAILED_KIND = "agent.settings.discovery.failed";
19807
19810
  var IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
19808
19811
  var DIRECTORY_IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
19809
19812
  var IDENTIFIER = external_exports.string().min(1).max(128).regex(IDENTIFIER_PATTERN);
@@ -19832,6 +19835,28 @@ var sessionConfigOptionSchema = external_exports.strictObject({
19832
19835
  values: external_exports.array(configValueSchema).max(500).readonly()
19833
19836
  }).readonly();
19834
19837
  var sessionConfigOptionsSchema = external_exports.array(sessionConfigOptionSchema).max(100).readonly();
19838
+ var agentSettingsDiscoverCommandSchema = external_exports.strictObject({
19839
+ additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
19840
+ agentId: IDENTIFIER,
19841
+ directoryId: DIRECTORY_IDENTIFIER,
19842
+ kind: external_exports.literal(AGENT_SETTINGS_DISCOVER_KIND),
19843
+ requestId: IDENTIFIER
19844
+ }).readonly();
19845
+ var agentSettingsDiscoveredEventSchema = external_exports.strictObject({
19846
+ agentId: IDENTIFIER,
19847
+ agentName: external_exports.string().max(255),
19848
+ agentVersion: external_exports.string().max(128),
19849
+ configOptions: sessionConfigOptionsSchema,
19850
+ directoryId: DIRECTORY_IDENTIFIER,
19851
+ kind: external_exports.literal(AGENT_SETTINGS_DISCOVERED_KIND),
19852
+ requestId: IDENTIFIER
19853
+ }).readonly();
19854
+ var agentSettingsDiscoveryFailedEventSchema = external_exports.strictObject({
19855
+ code: IDENTIFIER,
19856
+ kind: external_exports.literal(AGENT_SETTINGS_DISCOVERY_FAILED_KIND),
19857
+ message: external_exports.string().min(1).max(500),
19858
+ requestId: IDENTIFIER
19859
+ }).readonly();
19835
19860
  var sessionConfigurationSelectionSchema = external_exports.strictObject({
19836
19861
  booleanValue: external_exports.boolean(),
19837
19862
  configId: IDENTIFIER,
@@ -19968,6 +19993,7 @@ var sessionPrepareCommandSchema = external_exports.strictObject({
19968
19993
  }).readonly().optional(),
19969
19994
  kind: external_exports.literal(SESSION_PREPARE_KIND),
19970
19995
  requestId: IDENTIFIER,
19996
+ /** @deprecated Reserved for the legacy Bot Agent-configuration endpoint. */
19971
19997
  transient: external_exports.boolean().optional()
19972
19998
  }).readonly();
19973
19999
  var runtimeTimingsSchema = external_exports.array(
@@ -20181,6 +20207,9 @@ var decodePromptImagesValue = (value) => decodeValue(value, external_exports.arr
20181
20207
  var decodePromptResourcesValue = (value) => decodeValue(value, external_exports.array(promptResourceSchema).max(16).readonly());
20182
20208
  var decodeSessionConfigurationSelections = (value) => decodeValue(value, sessionConfigurationSelectionsSchema);
20183
20209
  var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
20210
+ var decodeAgentSettingsDiscoverCommand = (encoded) => decode3(encoded, agentSettingsDiscoverCommandSchema);
20211
+ var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
20212
+ var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
20184
20213
  var decodeWorkspaceListCommand = (encoded) => decode3(encoded, workspaceListCommandSchema);
20185
20214
  var encodeWorkspaceEntriesEvent = (message) => encode3(message, workspaceEntriesEventSchema);
20186
20215
  var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
@@ -30902,6 +30931,16 @@ var AcpPreparedSession = class {
30902
30931
  this.restored = restored;
30903
30932
  }
30904
30933
  };
30934
+ var AcpAgentSettingsSnapshot = class {
30935
+ agentName;
30936
+ agentVersion;
30937
+ configOptions;
30938
+ constructor(agentName, agentVersion, configOptions) {
30939
+ this.agentName = agentName;
30940
+ this.agentVersion = agentVersion;
30941
+ this.configOptions = configOptions;
30942
+ }
30943
+ };
30905
30944
  var AcpExecutionError = class extends Error {
30906
30945
  code;
30907
30946
  constructor(message, options = {}, code = "acp_execution_failed") {
@@ -32525,6 +32564,7 @@ var AcpProcessSession = class _AcpProcessSession {
32525
32564
  };
32526
32565
  var AcpSessionManager = class {
32527
32566
  #activeCommandIds = /* @__PURE__ */ new Map();
32567
+ #agentSettingsObserver = new NullAcpSessionObserver();
32528
32568
  #nativeOperations = /* @__PURE__ */ new Set();
32529
32569
  #nativeBrowserObserver = new NullAcpSessionObserver();
32530
32570
  #nativeBrowserPreparing = /* @__PURE__ */ new Map();
@@ -32719,9 +32759,29 @@ var AcpSessionManager = class {
32719
32759
  return runtime.prepared();
32720
32760
  };
32721
32761
  /**
32722
- * Opens a short-lived ACP session only to read the Agent's authoritative
32723
- * configuration options. The runtime and any persisted native-session
32724
- * record are released before this method resolves.
32762
+ * Opens a short-lived native ACP session only to read the local Agent's
32763
+ * authoritative settings. Its identity and store are private to this
32764
+ * operation and never become a Mobius Session.
32765
+ */
32766
+ inspectAgentSettings = async (options) => {
32767
+ const runtime = await AcpProcessSession.start(
32768
+ {
32769
+ ...options,
32770
+ sessionId: `agent-settings-${crypto.randomUUID()}`
32771
+ },
32772
+ () => this.#agentSettingsObserver,
32773
+ new MemoryAcpSessionStore()
32774
+ );
32775
+ try {
32776
+ const prepared = runtime.prepared();
32777
+ return new AcpAgentSettingsSnapshot(prepared.agentName, prepared.agentVersion, prepared.configOptions);
32778
+ } finally {
32779
+ await runtime.close();
32780
+ }
32781
+ };
32782
+ /**
32783
+ * @deprecated Retained for the Bot-scoped legacy Agent-configuration API.
32784
+ * Use inspectAgentSettings for Agent-scoped settings discovery.
32725
32785
  */
32726
32786
  inspectSession = async (options, metrics = unmeasuredOperationMetrics) => {
32727
32787
  if (this.#preparing.has(options.sessionId) || this.#sessions.has(options.sessionId)) {
@@ -34780,6 +34840,7 @@ var ClaudeCodeAgentSpecification = class extends BridgedAcpAgentDefinition {
34780
34840
 
34781
34841
  // src/agent-catalog/agents/codex-agent.ts
34782
34842
  var CodexAgentSpecification = class extends BridgedAcpAgentDefinition {
34843
+ versionProbeTimeoutMilliseconds = 1e4;
34783
34844
  adapterEnvironmentVariable = "CODEX_PATH";
34784
34845
  adapterOverrideVariable = "MOBIUS_CODEX_ACP_PATH";
34785
34846
  adapterPackageDefinition = new ManagedNpmPackageDefinition(
@@ -36401,6 +36462,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
36401
36462
  const agents = localAgents.map((agent) => ({
36402
36463
  agentPath: agent.agentIdentity.requestedPath,
36403
36464
  agentVersion: agent.agentVersion,
36465
+ agentSettingsDiscovery: true,
36404
36466
  botSessionConfiguration: true,
36405
36467
  capabilities: agent.capabilities,
36406
36468
  id: agent.id,
@@ -36642,6 +36704,7 @@ async function publishAgentCatalog(config2, signal) {
36642
36704
  agents: catalog.agents.map((agent) => ({
36643
36705
  agentPath: agent.agentIdentity.requestedPath,
36644
36706
  agentVersion: agent.agentVersion,
36707
+ agentSettingsDiscovery: true,
36645
36708
  botSessionConfiguration: true,
36646
36709
  capabilities: agent.capabilities,
36647
36710
  id: agent.id,
@@ -37031,23 +37094,19 @@ var FixedInstallationExecutor = class {
37031
37094
  this.#catalog.transition(previous2.agents, previous2.installableAgents);
37032
37095
  throw error62;
37033
37096
  }
37034
- const alreadyReady = initialInventory.available.find((candidate2) => candidate2.specification.id === agentId);
37097
+ const alreadyReady = initialInventory.available.find((candidate) => candidate.specification.id === agentId);
37035
37098
  if (alreadyReady instanceof AvailableAgent) {
37036
37099
  return;
37037
37100
  }
37038
- const candidate = initialInventory.installable.find((agent2) => agent2.id === agentId);
37039
- if (candidate instanceof MissingAgentDefinition) {
37101
+ const initialDiscovery = initialInventory.unavailable.find(
37102
+ (candidate) => candidate.specification.id === agentId
37103
+ );
37104
+ if (initialDiscovery instanceof MissingAgent) {
37040
37105
  throw new InstallationManagerError(
37041
37106
  "agent_not_installed",
37042
37107
  `Install ${specification.label} on this machine, then try installing the integration again.`
37043
37108
  );
37044
37109
  }
37045
- if (!(candidate instanceof AgentIntegrationDefinition)) {
37046
- throw new InstallationManagerError(
37047
- "agent_verification_failed",
37048
- "The local Agent discovery result is unavailable"
37049
- );
37050
- }
37051
37110
  const verifiedAgent = await findVerifiedAgentExecutable(specification, discoveryOptions);
37052
37111
  if (verifiedAgent === null) {
37053
37112
  throw new InstallationManagerError(
@@ -37089,7 +37148,7 @@ var FixedInstallationExecutor = class {
37089
37148
  signal,
37090
37149
  specifications: this.#specifications
37091
37150
  });
37092
- const verified = inventory.available.find((candidate2) => candidate2.specification.id === agentId);
37151
+ const verified = inventory.available.find((candidate) => candidate.specification.id === agentId);
37093
37152
  if (verified instanceof AvailableAgent) {
37094
37153
  this.#audit.record("agent_installation_acp_verified", requestId, agentId, {
37095
37154
  adapterVersion: verified.agent.adapterVersion,
@@ -37105,7 +37164,7 @@ var FixedInstallationExecutor = class {
37105
37164
  }
37106
37165
  return;
37107
37166
  }
37108
- const unavailable = inventory.unavailable.find((candidate2) => candidate2.specification.id === agentId);
37167
+ const unavailable = inventory.unavailable.find((candidate) => candidate.specification.id === agentId);
37109
37168
  if (unavailable === void 0) {
37110
37169
  throw new InstallationManagerError(
37111
37170
  "agent_verification_failed",
@@ -40126,6 +40185,31 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
40126
40185
  }
40127
40186
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
40128
40187
  }
40188
+ async function discoverAgentSettings(command, config2, directories, sessions, signal) {
40189
+ const resolved = await resolveSessionDirectories(
40190
+ directories,
40191
+ config2.bindingId,
40192
+ command.directoryId,
40193
+ command.additionalDirectoryIds,
40194
+ signal
40195
+ );
40196
+ const agent = config2.catalog.find(command.agentId);
40197
+ const snapshot = await sessions.inspectAgentSettings({
40198
+ additionalDirectories: resolved.additionalDirectories,
40199
+ agent,
40200
+ cwd: resolved.cwd,
40201
+ signal
40202
+ });
40203
+ return {
40204
+ agentId: command.agentId,
40205
+ agentName: snapshot.agentName,
40206
+ agentVersion: snapshot.agentVersion,
40207
+ configOptions: snapshot.configOptions,
40208
+ directoryId: command.directoryId,
40209
+ kind: AGENT_SETTINGS_DISCOVERED_KIND,
40210
+ requestId: command.requestId
40211
+ };
40212
+ }
40129
40213
  async function executeWorkspaceList(socket, command, directories, audit, signal) {
40130
40214
  try {
40131
40215
  const listing = await directories.list(command.bindingId, command.directoryId, signal);
@@ -40653,6 +40737,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
40653
40737
  onConnected();
40654
40738
  const connectionController = new AbortController();
40655
40739
  const nativeRequests = /* @__PURE__ */ new Map();
40740
+ const agentSettingsDiscoveries = /* @__PURE__ */ new Map();
40656
40741
  installationObserver.connect(socket);
40657
40742
  try {
40658
40743
  await new Promise((resolve6, reject) => {
@@ -41080,6 +41165,104 @@ async function runRelayConnection(config2, directories, audit, sessions, install
41080
41165
  }
41081
41166
  return;
41082
41167
  }
41168
+ if (kind === AGENT_SETTINGS_DISCOVER_KIND) {
41169
+ const command2 = decodeAgentSettingsDiscoverCommand(encoded);
41170
+ const existing = [...agentSettingsDiscoveries.values()].find(
41171
+ (request) => request.agentId === command2.agentId && !request.controller.signal.aborted
41172
+ );
41173
+ if (agentSettingsDiscoveries.has(command2.requestId) || existing !== void 0) {
41174
+ if (socket.readyState === WebSocket2.OPEN) {
41175
+ send(
41176
+ socket,
41177
+ encodeAgentSettingsDiscoveryFailedEvent({
41178
+ code: "agent_settings_discovery_busy",
41179
+ kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
41180
+ message: "Another settings discovery is already running for this Agent",
41181
+ requestId: command2.requestId
41182
+ })
41183
+ );
41184
+ }
41185
+ return;
41186
+ }
41187
+ if (agentSettingsDiscoveries.size >= 4) {
41188
+ if (socket.readyState === WebSocket2.OPEN) {
41189
+ send(
41190
+ socket,
41191
+ encodeAgentSettingsDiscoveryFailedEvent({
41192
+ code: "agent_settings_discovery_busy",
41193
+ kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
41194
+ message: "Too many Agent settings discoveries are running",
41195
+ requestId: command2.requestId
41196
+ })
41197
+ );
41198
+ }
41199
+ return;
41200
+ }
41201
+ const controller = new AbortController();
41202
+ const operationSignal = AbortSignal.any([connectionController.signal, controller.signal]);
41203
+ const timeout = timer.schedule(
41204
+ () => controller.abort(
41205
+ new AcpExecutionError(
41206
+ "Agent settings discovery timed out",
41207
+ {},
41208
+ "agent_settings_discovery_timeout"
41209
+ )
41210
+ ),
41211
+ 9e4
41212
+ );
41213
+ const completion = (async () => {
41214
+ try {
41215
+ const result = await discoverAgentSettings(
41216
+ command2,
41217
+ config2,
41218
+ directories,
41219
+ sessions,
41220
+ operationSignal
41221
+ );
41222
+ audit.record({
41223
+ commandId: command2.requestId,
41224
+ details: { agentId: command2.agentId, directoryId: command2.directoryId },
41225
+ event: "agent_settings_discovered",
41226
+ sessionId: `agent-settings:${command2.agentId}`
41227
+ });
41228
+ if (socket.readyState === WebSocket2.OPEN) {
41229
+ send(socket, encodeAgentSettingsDiscoveredEvent(result));
41230
+ }
41231
+ } catch (error62) {
41232
+ const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
41233
+ "Agent settings discovery cancelled",
41234
+ {},
41235
+ "agent_settings_discovery_cancelled"
41236
+ ) : error62;
41237
+ audit.record({
41238
+ commandId: command2.requestId,
41239
+ details: { agentId: command2.agentId, code: operationErrorCode(failure2) },
41240
+ event: "agent_settings_discovery_failed",
41241
+ sessionId: `agent-settings:${command2.agentId}`
41242
+ });
41243
+ if (socket.readyState === WebSocket2.OPEN) {
41244
+ send(
41245
+ socket,
41246
+ encodeAgentSettingsDiscoveryFailedEvent({
41247
+ code: operationErrorCode(failure2),
41248
+ kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
41249
+ message: operationErrorMessage(failure2),
41250
+ requestId: command2.requestId
41251
+ })
41252
+ );
41253
+ }
41254
+ } finally {
41255
+ timeout.cancel();
41256
+ agentSettingsDiscoveries.delete(command2.requestId);
41257
+ }
41258
+ })();
41259
+ agentSettingsDiscoveries.set(command2.requestId, {
41260
+ agentId: command2.agentId,
41261
+ completion,
41262
+ controller
41263
+ });
41264
+ return;
41265
+ }
41083
41266
  if (kind === NATIVE_SESSION_REQUEST_KIND) {
41084
41267
  const command2 = decodeNativeSessionCommand(encoded);
41085
41268
  const previous2 = [...nativeRequests.values()].filter(
@@ -41464,7 +41647,10 @@ async function runRelayConnection(config2, directories, audit, sessions, install
41464
41647
  });
41465
41648
  } finally {
41466
41649
  connectionController.abort();
41467
- await Promise.all([...nativeRequests.values()].map((request) => request.completion));
41650
+ await Promise.all([
41651
+ ...[...nativeRequests.values()].map((request) => request.completion),
41652
+ ...[...agentSettingsDiscoveries.values()].map((request) => request.completion)
41653
+ ]);
41468
41654
  }
41469
41655
  }
41470
41656
  async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
@@ -41509,6 +41695,15 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
41509
41695
  );
41510
41696
  let connectionEpoch = 0;
41511
41697
  let connectionAnnounced = false;
41698
+ let catalogPublished = false;
41699
+ let readinessAnnounced = false;
41700
+ const announceReadiness = () => {
41701
+ if (!connectionAnnounced || !catalogPublished || readinessAnnounced) {
41702
+ return;
41703
+ }
41704
+ readinessAnnounced = true;
41705
+ process.stdout.write("Mobius daemon is ready for Agent requests.\n");
41706
+ };
41512
41707
  const announceConnection = () => {
41513
41708
  if (connectionAnnounced) {
41514
41709
  return;
@@ -41522,8 +41717,16 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
41522
41717
 
41523
41718
  `
41524
41719
  );
41720
+ announceReadiness();
41525
41721
  };
41526
41722
  const catalogPublication = publishAgentCatalogUntilAvailable(config2, diagnostics, signal, timer);
41723
+ void catalogPublication.then(() => {
41724
+ if (signal.aborted) {
41725
+ return;
41726
+ }
41727
+ catalogPublished = true;
41728
+ announceReadiness();
41729
+ });
41527
41730
  try {
41528
41731
  await ipc.listen(signal);
41529
41732
  while (!signal.aborted) {