@moxt-ai/mobius 0.0.36 → 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.
Files changed (47) hide show
  1. package/dist/acp/markdown-images.d.ts +9 -0
  2. package/dist/acp/markdown-images.d.ts.map +1 -0
  3. package/dist/acp/markdown-images.js +47 -0
  4. package/dist/acp/markdown-images.js.map +1 -0
  5. package/dist/acp/session-manager.d.ts +21 -4
  6. package/dist/acp/session-manager.d.ts.map +1 -1
  7. package/dist/acp/session-manager.js +53 -39
  8. package/dist/acp/session-manager.js.map +1 -1
  9. package/dist/agent-catalog/agents/codex-agent.d.ts +1 -0
  10. package/dist/agent-catalog/agents/codex-agent.d.ts.map +1 -1
  11. package/dist/agent-catalog/agents/codex-agent.js +1 -0
  12. package/dist/agent-catalog/agents/codex-agent.js.map +1 -1
  13. package/dist/agent-catalog/discover-local-agents.d.ts +0 -1
  14. package/dist/agent-catalog/discover-local-agents.d.ts.map +1 -1
  15. package/dist/agent-catalog/discover-local-agents.js +0 -1
  16. package/dist/agent-catalog/discover-local-agents.js.map +1 -1
  17. package/dist/agent-catalog/publish-agent-catalog.d.ts.map +1 -1
  18. package/dist/agent-catalog/publish-agent-catalog.js +1 -0
  19. package/dist/agent-catalog/publish-agent-catalog.js.map +1 -1
  20. package/dist/agent-installation/fixed-installation-executor.d.ts +1 -1
  21. package/dist/agent-installation/fixed-installation-executor.d.ts.map +1 -1
  22. package/dist/agent-installation/fixed-installation-executor.js +3 -7
  23. package/dist/agent-installation/fixed-installation-executor.js.map +1 -1
  24. package/dist/cli.js +8482 -782
  25. package/dist/cli.js.map +4 -4
  26. package/dist/index.js +8441 -744
  27. package/dist/index.js.map +4 -4
  28. package/dist/infra/operation-metrics.d.ts.map +1 -1
  29. package/dist/infra/operation-metrics.js +1 -1
  30. package/dist/infra/operation-metrics.js.map +1 -1
  31. package/dist/native-sessions/codex-history.d.ts +11 -0
  32. package/dist/native-sessions/codex-history.d.ts.map +1 -0
  33. package/dist/native-sessions/codex-history.js +233 -0
  34. package/dist/native-sessions/codex-history.js.map +1 -0
  35. package/dist/native-sessions/service.d.ts +1 -0
  36. package/dist/native-sessions/service.d.ts.map +1 -1
  37. package/dist/native-sessions/service.js +68 -22
  38. package/dist/native-sessions/service.js.map +1 -1
  39. package/dist/pairing/pair-local-machine.d.ts.map +1 -1
  40. package/dist/pairing/pair-local-machine.js +1 -0
  41. package/dist/pairing/pair-local-machine.js.map +1 -1
  42. package/dist/run-daemon.d.ts.map +1 -1
  43. package/dist/run-daemon.js +175 -58
  44. package/dist/run-daemon.js.map +1 -1
  45. package/dist/runtime.js +8466 -769
  46. package/dist/runtime.js.map +4 -4
  47. package/package.json +4 -1
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { basename, join } from "node:path";
3
3
  import { styleText } from "node:util";
4
- import { AGENT_ACTIVITY_KIND, AGENT_INSTALL_CANCEL_KIND, AGENT_INSTALL_CANCELLED_KIND, AGENT_INSTALL_COMPLETED_KIND, AGENT_INSTALL_FAILED_KIND, AGENT_INSTALL_PROGRESS_KIND, AGENT_INSTALL_REQUEST_KIND, AGENT_INSTALL_STARTED_KIND, AGENT_MESSAGE_DELTA_KIND, BOT_BINDING_APPROVAL_REQUEST_KIND, BOT_BINDING_APPROVED_KIND, BOT_BINDING_UNAVAILABLE_KIND, BOT_SESSION_PROMPT_KIND, BotExecutionBindingUnavailableEvent, decodeAgentInstallCancelCommand, decodeAgentInstallRequestCommand, decodeBotExecutionBindingApprovalRequest, decodeBotExecutionBindingApprovedEvent, decodeBotExecutionBindingUnavailableEvent, decodeBotSessionPromptCommand, decodeMessageKind, decodeNativeSessionCancel, decodeNativeSessionCommand, decodeNativeSessionTurnForkCommand, decodeRuntimeDelivery, decodeRuntimeDeliveryCommitted, decodeRuntimeHeartbeatAckEvent, decodeRuntimeLivenessReadyEvent, decodeSessionCancelCommand, decodeSessionConfigureCommand, decodeSessionElicitationRespondCommand, decodeSessionEventAcknowledgement, decodeSessionEventDeferred, decodeSessionEventEnvelope, decodeSessionEventRejection, decodeSessionPermissionRespondCommand, decodeSessionPrepareCommand, decodeSessionPromptCommand, decodeWorkspaceListCommand, encodeAgentActivityEvent, encodeAgentContentEvent, encodeAgentInstallCancelledEvent, encodeAgentInstallCompletedEvent, encodeAgentInstallFailedEvent, encodeAgentInstallProgressEvent, encodeAgentInstallStartedEvent, encodeAgentMessageDeltaEvent, encodeBotExecutionBindingApprovedEvent, encodeBotExecutionBindingUnavailableEvent, encodeNativeSessionResult, encodeRuntimeDeliveryReceived, encodeSessionCommandsUpdatedEvent, encodeSessionCompletedEvent, encodeSessionConfigUpdatedEvent, encodeSessionElicitationRequestedEvent, encodeSessionElicitationResolvedEvent, encodeSessionFailedEvent, encodeSessionInfoUpdatedEvent, encodeSessionOperationFailedEvent, encodeSessionPermissionRequestedEvent, encodeSessionPermissionResolvedEvent, encodeSessionReadyEvent, encodeSessionStartedEvent, encodeSessionUsageUpdatedEvent, encodeWorkspaceEntriesEvent, NATIVE_SESSION_CANCEL_KIND, NATIVE_SESSION_REQUEST_KIND, NATIVE_SESSION_TURN_FORK_KIND, OwnerBotReplyRoute, RUNTIME_DELIVERY_COMMITTED_KIND, RUNTIME_DELIVERY_KIND, RUNTIME_DELIVERY_RECEIVED_KIND, RUNTIME_HEARTBEAT_ACK_KIND, RUNTIME_LIVENESS_READY_KIND, SESSION_CANCEL_KIND, SESSION_COMPLETED_KIND, SESSION_CONFIGURE_KIND, SESSION_ELICITATION_RESPOND_KIND, SESSION_EVENT_ACK_KIND, SESSION_EVENT_DEFERRED_KIND, SESSION_EVENT_REJECTED_KIND, SESSION_FAILED_KIND, SESSION_PERMISSION_RESPOND_KIND, SESSION_PREPARE_KIND, SESSION_PROMPT_KIND, SESSION_STARTED_KIND, SessionPromptDisposition, WORKSPACE_LIST_KIND, } from "@moxt-ai/mobius-protocol";
4
+ import { AGENT_ACTIVITY_KIND, AGENT_INSTALL_CANCEL_KIND, AGENT_INSTALL_CANCELLED_KIND, AGENT_INSTALL_COMPLETED_KIND, AGENT_INSTALL_FAILED_KIND, AGENT_INSTALL_PROGRESS_KIND, AGENT_INSTALL_REQUEST_KIND, AGENT_INSTALL_STARTED_KIND, AGENT_MESSAGE_DELTA_KIND, AGENT_SETTINGS_DISCOVER_KIND, AGENT_SETTINGS_DISCOVERED_KIND, AGENT_SETTINGS_DISCOVERY_FAILED_KIND, BOT_BINDING_APPROVAL_REQUEST_KIND, BOT_BINDING_APPROVED_KIND, BOT_BINDING_UNAVAILABLE_KIND, BOT_SESSION_PROMPT_KIND, BotExecutionBindingUnavailableEvent, decodeAgentInstallCancelCommand, decodeAgentInstallRequestCommand, decodeAgentSettingsDiscoverCommand, decodeBotExecutionBindingApprovalRequest, decodeBotExecutionBindingApprovedEvent, decodeBotExecutionBindingUnavailableEvent, decodeBotSessionPromptCommand, decodeMessageKind, decodeNativeSessionCancel, decodeNativeSessionCommand, decodeNativeSessionTurnForkCommand, decodeRuntimeDelivery, decodeRuntimeDeliveryCommitted, decodeRuntimeHeartbeatAckEvent, decodeRuntimeLivenessReadyEvent, decodeSessionCancelCommand, decodeSessionConfigureCommand, decodeSessionElicitationRespondCommand, decodeSessionEventAcknowledgement, decodeSessionEventDeferred, decodeSessionEventEnvelope, decodeSessionEventRejection, decodeSessionPermissionRespondCommand, decodeSessionPrepareCommand, decodeSessionPromptCommand, decodeWorkspaceListCommand, encodeAgentActivityEvent, encodeAgentContentEvent, encodeAgentInstallCancelledEvent, encodeAgentInstallCompletedEvent, encodeAgentInstallFailedEvent, encodeAgentInstallProgressEvent, encodeAgentInstallStartedEvent, encodeAgentMessageDeltaEvent, encodeAgentSettingsDiscoveredEvent, encodeAgentSettingsDiscoveryFailedEvent, encodeBotExecutionBindingApprovedEvent, encodeBotExecutionBindingUnavailableEvent, encodeNativeSessionResult, encodeRuntimeDeliveryReceived, encodeSessionCommandsUpdatedEvent, encodeSessionCompletedEvent, encodeSessionConfigUpdatedEvent, encodeSessionElicitationRequestedEvent, encodeSessionElicitationResolvedEvent, encodeSessionFailedEvent, encodeSessionInfoUpdatedEvent, encodeSessionOperationFailedEvent, encodeSessionPermissionRequestedEvent, encodeSessionPermissionResolvedEvent, encodeSessionReadyEvent, encodeSessionStartedEvent, encodeSessionUsageUpdatedEvent, encodeWorkspaceEntriesEvent, NATIVE_SESSION_CANCEL_KIND, NATIVE_SESSION_REQUEST_KIND, NATIVE_SESSION_TURN_FORK_KIND, OwnerBotReplyRoute, RUNTIME_DELIVERY_COMMITTED_KIND, RUNTIME_DELIVERY_KIND, RUNTIME_DELIVERY_RECEIVED_KIND, RUNTIME_HEARTBEAT_ACK_KIND, RUNTIME_LIVENESS_READY_KIND, SESSION_CANCEL_KIND, SESSION_COMPLETED_KIND, SESSION_CONFIGURE_KIND, SESSION_ELICITATION_RESPOND_KIND, SESSION_EVENT_ACK_KIND, SESSION_EVENT_DEFERRED_KIND, SESSION_EVENT_REJECTED_KIND, SESSION_FAILED_KIND, SESSION_PERMISSION_RESPOND_KIND, SESSION_PREPARE_KIND, SESSION_PROMPT_KIND, SESSION_STARTED_KIND, SessionPromptDisposition, WORKSPACE_LIST_KIND, } from "@moxt-ai/mobius-protocol";
5
5
  import { fetch, WebSocket } from "undici";
6
6
  import { AcpExecutionError, AcpSessionManager } from "./acp/session-manager.js";
7
7
  import { SqliteAcpSessionStore } from "./acp/session-store.js";
@@ -574,7 +574,7 @@ function operationErrorMessage(error) {
574
574
  }
575
575
  return "The local agent operation could not be completed";
576
576
  }
577
- function reportOperationFailure(socket, requestId, sessionId, error) {
577
+ function reportOperationFailure(socket, requestId, sessionId, error, runtimeTimings = []) {
578
578
  if (socket.readyState !== WebSocket.OPEN) {
579
579
  return;
580
580
  }
@@ -583,6 +583,7 @@ function reportOperationFailure(socket, requestId, sessionId, error) {
583
583
  kind: "session.operation.failed",
584
584
  message: operationErrorMessage(error),
585
585
  requestId,
586
+ ...(runtimeTimings.length === 0 ? {} : { runtimeTimings }),
586
587
  sessionId,
587
588
  }));
588
589
  }
@@ -605,6 +606,25 @@ async function resolveSessionDirectories(directories, bindingId, directoryId, ad
605
606
  }
606
607
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
607
608
  }
609
+ async function discoverAgentSettings(command, config, directories, sessions, signal) {
610
+ const resolved = await resolveSessionDirectories(directories, config.bindingId, command.directoryId, command.additionalDirectoryIds, signal);
611
+ const agent = config.catalog.find(command.agentId);
612
+ const snapshot = await sessions.inspectAgentSettings({
613
+ additionalDirectories: resolved.additionalDirectories,
614
+ agent,
615
+ cwd: resolved.cwd,
616
+ signal,
617
+ });
618
+ return {
619
+ agentId: command.agentId,
620
+ agentName: snapshot.agentName,
621
+ agentVersion: snapshot.agentVersion,
622
+ configOptions: snapshot.configOptions,
623
+ directoryId: command.directoryId,
624
+ kind: AGENT_SETTINGS_DISCOVERED_KIND,
625
+ requestId: command.requestId,
626
+ };
627
+ }
608
628
  async function executeWorkspaceList(socket, command, directories, audit, signal) {
609
629
  try {
610
630
  const listing = await directories.list(command.bindingId, command.directoryId, signal);
@@ -628,68 +648,71 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
628
648
  }
629
649
  }
630
650
  async function executeSessionPrepare(publisher, socket, command, config, directories, audit, sessions, signal) {
651
+ const metrics = new AccumulatingOperationMetrics();
631
652
  try {
632
- const resolved = await resolveSessionDirectories(directories, config.bindingId, command.directoryId, command.additionalDirectoryIds, signal);
633
- const agent = config.catalog.find(command.agentId);
634
- const metrics = new AccumulatingOperationMetrics();
635
- const preparation = {
636
- additionalDirectories: resolved.additionalDirectories,
637
- agent,
638
- cwd: resolved.cwd,
639
- sessionId: command.sessionId,
640
- signal,
641
- };
642
- const prepared = command.transient === true
643
- ? await sessions.inspectSession(preparation)
644
- : await sessions.prepareSession(preparation, metrics);
645
- const configuration = command.configuration;
646
- const configOptions = configuration === undefined
647
- ? prepared.configOptions
648
- : await metrics.measure("configuration", async () => await sessions.configureSession({
649
- ...preparation,
650
- booleanValue: configuration.booleanValue,
651
- configId: configuration.configId,
652
- requestId: command.requestId,
653
- value: configuration.value,
654
- valueType: configuration.valueType,
655
- }));
656
- const listing = await directories.list(config.bindingId, command.directoryId, signal);
657
- audit.record({
658
- commandId: command.requestId,
659
- event: "session_prepared",
660
- sessionId: command.sessionId,
661
- });
662
- if (command.configuration !== undefined) {
653
+ const readyEvent = await metrics.measure("prepare-total", async () => {
654
+ const resolved = await metrics.measure("workspace-resolve", async () => await resolveSessionDirectories(directories, config.bindingId, command.directoryId, command.additionalDirectoryIds, signal));
655
+ const agent = config.catalog.find(command.agentId);
656
+ const preparation = {
657
+ additionalDirectories: resolved.additionalDirectories,
658
+ agent,
659
+ cwd: resolved.cwd,
660
+ sessionId: command.sessionId,
661
+ signal,
662
+ };
663
+ const prepared = command.transient === true
664
+ ? await sessions.inspectSession(preparation, metrics)
665
+ : await sessions.prepareSession(preparation, metrics);
666
+ const configuration = command.configuration;
667
+ const configOptions = configuration === undefined
668
+ ? prepared.configOptions
669
+ : await metrics.measure("configuration", async () => await sessions.configureSession({
670
+ ...preparation,
671
+ booleanValue: configuration.booleanValue,
672
+ configId: configuration.configId,
673
+ requestId: command.requestId,
674
+ value: configuration.value,
675
+ valueType: configuration.valueType,
676
+ }));
677
+ const listing = await metrics.measure("workspace-list", async () => await directories.list(config.bindingId, command.directoryId, signal));
663
678
  audit.record({
664
679
  commandId: command.requestId,
665
- event: "session_configured",
680
+ event: "session_prepared",
666
681
  sessionId: command.sessionId,
667
682
  });
668
- publisher.recordRuntime(command.sessionId, encodeSessionConfigUpdatedEvent({
683
+ if (command.configuration !== undefined) {
684
+ audit.record({
685
+ commandId: command.requestId,
686
+ event: "session_configured",
687
+ sessionId: command.sessionId,
688
+ });
689
+ publisher.recordRuntime(command.sessionId, encodeSessionConfigUpdatedEvent({
690
+ configOptions,
691
+ kind: "session.config.updated",
692
+ requestId: command.requestId,
693
+ sessionId: command.sessionId,
694
+ }));
695
+ }
696
+ const event = {
697
+ additionalDirectories: resolved.additionalDirectoryEntries,
698
+ agentId: command.agentId,
699
+ agentName: prepared.agentName,
700
+ agentVersion: prepared.agentVersion,
701
+ capabilities: prepared.capabilities,
702
+ commands: prepared.commands,
669
703
  configOptions,
670
- kind: "session.config.updated",
704
+ directoryId: command.directoryId,
705
+ directoryLabel: listing.directoryLabel,
706
+ kind: "session.ready",
671
707
  requestId: command.requestId,
708
+ restored: prepared.restored,
672
709
  sessionId: command.sessionId,
673
- }));
674
- }
675
- const readyEvent = {
676
- additionalDirectories: resolved.additionalDirectoryEntries,
677
- agentId: command.agentId,
678
- agentName: prepared.agentName,
679
- agentVersion: prepared.agentVersion,
680
- capabilities: prepared.capabilities,
681
- commands: prepared.commands,
682
- configOptions,
683
- directoryId: command.directoryId,
684
- directoryLabel: listing.directoryLabel,
685
- kind: "session.ready",
686
- requestId: command.requestId,
687
- restored: prepared.restored,
688
- sessionId: command.sessionId,
689
- runtimeTimings: metrics.snapshot(),
690
- };
691
- metrics.measureSync("readiness-commit", () => {
692
- publisher.recordRuntime(command.sessionId, encodeSessionReadyEvent(readyEvent));
710
+ runtimeTimings: metrics.snapshot(),
711
+ };
712
+ metrics.measureSync("readiness-commit", () => {
713
+ publisher.recordRuntime(command.sessionId, encodeSessionReadyEvent(event));
714
+ });
715
+ return event;
693
716
  });
694
717
  send(socket, encodeSessionReadyEvent({
695
718
  ...readyEvent,
@@ -706,7 +729,7 @@ async function executeSessionPrepare(publisher, socket, command, config, directo
706
729
  event: "session_prepare_failed",
707
730
  sessionId: command.sessionId,
708
731
  });
709
- reportOperationFailure(socket, command.requestId, command.sessionId, error);
732
+ reportOperationFailure(socket, command.requestId, command.sessionId, error, metrics.snapshot());
710
733
  }
711
734
  }
712
735
  async function executeSessionConfigure(publisher, socket, command, config, directories, audit, sessions, signal) {
@@ -1032,6 +1055,7 @@ async function runRelayConnection(config, directories, audit, sessions, installa
1032
1055
  onConnected();
1033
1056
  const connectionController = new AbortController();
1034
1057
  const nativeRequests = new Map();
1058
+ const agentSettingsDiscoveries = new Map();
1035
1059
  installationObserver.connect(socket);
1036
1060
  try {
1037
1061
  await new Promise((resolve, reject) => {
@@ -1384,6 +1408,79 @@ async function runRelayConnection(config, directories, audit, sessions, installa
1384
1408
  }
1385
1409
  return;
1386
1410
  }
1411
+ if (kind === AGENT_SETTINGS_DISCOVER_KIND) {
1412
+ const command = decodeAgentSettingsDiscoverCommand(encoded);
1413
+ const existing = [...agentSettingsDiscoveries.values()].find((request) => request.agentId === command.agentId && !request.controller.signal.aborted);
1414
+ if (agentSettingsDiscoveries.has(command.requestId) || existing !== undefined) {
1415
+ if (socket.readyState === WebSocket.OPEN) {
1416
+ send(socket, encodeAgentSettingsDiscoveryFailedEvent({
1417
+ code: "agent_settings_discovery_busy",
1418
+ kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
1419
+ message: "Another settings discovery is already running for this Agent",
1420
+ requestId: command.requestId,
1421
+ }));
1422
+ }
1423
+ return;
1424
+ }
1425
+ if (agentSettingsDiscoveries.size >= 4) {
1426
+ if (socket.readyState === WebSocket.OPEN) {
1427
+ send(socket, encodeAgentSettingsDiscoveryFailedEvent({
1428
+ code: "agent_settings_discovery_busy",
1429
+ kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
1430
+ message: "Too many Agent settings discoveries are running",
1431
+ requestId: command.requestId,
1432
+ }));
1433
+ }
1434
+ return;
1435
+ }
1436
+ const controller = new AbortController();
1437
+ const operationSignal = AbortSignal.any([connectionController.signal, controller.signal]);
1438
+ const timeout = timer.schedule(() => controller.abort(new AcpExecutionError("Agent settings discovery timed out", {}, "agent_settings_discovery_timeout")), 90_000);
1439
+ const completion = (async () => {
1440
+ try {
1441
+ const result = await discoverAgentSettings(command, config, directories, sessions, operationSignal);
1442
+ audit.record({
1443
+ commandId: command.requestId,
1444
+ details: { agentId: command.agentId, directoryId: command.directoryId },
1445
+ event: "agent_settings_discovered",
1446
+ sessionId: `agent-settings:${command.agentId}`,
1447
+ });
1448
+ if (socket.readyState === WebSocket.OPEN) {
1449
+ send(socket, encodeAgentSettingsDiscoveredEvent(result));
1450
+ }
1451
+ }
1452
+ catch (error) {
1453
+ const failure = operationSignal.aborted
1454
+ ? (controller.signal.reason ??
1455
+ new AcpExecutionError("Agent settings discovery cancelled", {}, "agent_settings_discovery_cancelled"))
1456
+ : error;
1457
+ audit.record({
1458
+ commandId: command.requestId,
1459
+ details: { agentId: command.agentId, code: operationErrorCode(failure) },
1460
+ event: "agent_settings_discovery_failed",
1461
+ sessionId: `agent-settings:${command.agentId}`,
1462
+ });
1463
+ if (socket.readyState === WebSocket.OPEN) {
1464
+ send(socket, encodeAgentSettingsDiscoveryFailedEvent({
1465
+ code: operationErrorCode(failure),
1466
+ kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
1467
+ message: operationErrorMessage(failure),
1468
+ requestId: command.requestId,
1469
+ }));
1470
+ }
1471
+ }
1472
+ finally {
1473
+ timeout.cancel();
1474
+ agentSettingsDiscoveries.delete(command.requestId);
1475
+ }
1476
+ })();
1477
+ agentSettingsDiscoveries.set(command.requestId, {
1478
+ agentId: command.agentId,
1479
+ completion,
1480
+ controller,
1481
+ });
1482
+ return;
1483
+ }
1387
1484
  if (kind === NATIVE_SESSION_REQUEST_KIND) {
1388
1485
  const command = decodeNativeSessionCommand(encoded);
1389
1486
  const previous = [...nativeRequests.values()].filter((request) => request.agentId === command.agentId);
@@ -1681,7 +1778,10 @@ async function runRelayConnection(config, directories, audit, sessions, installa
1681
1778
  }
1682
1779
  finally {
1683
1780
  connectionController.abort();
1684
- await Promise.all([...nativeRequests.values()].map((request) => request.completion));
1781
+ await Promise.all([
1782
+ ...[...nativeRequests.values()].map((request) => request.completion),
1783
+ ...[...agentSettingsDiscoveries.values()].map((request) => request.completion),
1784
+ ]);
1685
1785
  }
1686
1786
  }
1687
1787
  export async function runDaemon(config, audit, signal, timer = systemDaemonTimer) {
@@ -1721,6 +1821,15 @@ export async function runDaemon(config, audit, signal, timer = systemDaemonTimer
1721
1821
  const installations = new AgentInstallationManager(specifications, installationExecutor, installationObserver, installationAudit);
1722
1822
  let connectionEpoch = 0;
1723
1823
  let connectionAnnounced = false;
1824
+ let catalogPublished = false;
1825
+ let readinessAnnounced = false;
1826
+ const announceReadiness = () => {
1827
+ if (!connectionAnnounced || !catalogPublished || readinessAnnounced) {
1828
+ return;
1829
+ }
1830
+ readinessAnnounced = true;
1831
+ process.stdout.write("Mobius daemon is ready for Agent requests.\n");
1832
+ };
1724
1833
  const announceConnection = () => {
1725
1834
  if (connectionAnnounced) {
1726
1835
  return;
@@ -1729,8 +1838,16 @@ export async function runDaemon(config, audit, signal, timer = systemDaemonTimer
1729
1838
  const reconnectCommand = `npx --yes @moxt-ai/mobius start --channel ${config.channelId}`;
1730
1839
  process.stdout.write("Mobius daemon connected to the relay.\n\n");
1731
1840
  process.stdout.write(`${styleText(["bold", "yellow"], `Reconnect this channel later:\n ${reconnectCommand}`)}\n\n`);
1841
+ announceReadiness();
1732
1842
  };
1733
1843
  const catalogPublication = publishAgentCatalogUntilAvailable(config, diagnostics, signal, timer);
1844
+ void catalogPublication.then(() => {
1845
+ if (signal.aborted) {
1846
+ return;
1847
+ }
1848
+ catalogPublished = true;
1849
+ announceReadiness();
1850
+ });
1734
1851
  try {
1735
1852
  await ipc.listen(signal);
1736
1853
  while (!signal.aborted) {