@moxt-ai/mobius 0.0.38 → 0.0.39

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
@@ -40727,6 +40727,22 @@ async function publishAgentCatalogUntilAvailable(config2, diagnostics, signal, t
40727
40727
  }
40728
40728
  }
40729
40729
  }
40730
+ async function installDetectedAgentIntegrations(config2, installations, signal) {
40731
+ for (const agent of config2.catalog.read().installableAgents) {
40732
+ if (!(agent instanceof AgentIntegrationDefinition)) {
40733
+ continue;
40734
+ }
40735
+ signal.throwIfAborted();
40736
+ await installations.request(
40737
+ {
40738
+ agentId: agent.id,
40739
+ kind: AGENT_INSTALL_REQUEST_KIND,
40740
+ requestId: `automatic-integration-${randomUUID6()}`
40741
+ },
40742
+ signal
40743
+ );
40744
+ }
40745
+ }
40730
40746
  async function runRelayConnection(config2, directories, audit, sessions, installations, installationObserver, nativeSessions, outbox, publisher, grants, contexts, applicator, ipc, activeTurns, activeAttemptIds, connectionEpoch, diagnostics, onConnected, signal, timer) {
40731
40747
  const relayUrl = new URL(config2.relayUrl);
40732
40748
  relayUrl.searchParams.set("deliveryReceipts", "1");
@@ -40734,11 +40750,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
40734
40750
  const socket = await connectRelay(relayUrl, signal);
40735
40751
  const reconnectingTurns = [...activeTurns.values()];
40736
40752
  diagnostics.connectionOpened(connectionEpoch);
40737
- onConnected();
40738
40753
  const connectionController = new AbortController();
40739
40754
  const nativeRequests = /* @__PURE__ */ new Map();
40740
40755
  const agentSettingsDiscoveries = /* @__PURE__ */ new Map();
40741
40756
  installationObserver.connect(socket);
40757
+ onConnected();
40742
40758
  try {
40743
40759
  await new Promise((resolve6, reject) => {
40744
40760
  let finished = false;
@@ -41694,9 +41710,24 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
41694
41710
  installationAudit
41695
41711
  );
41696
41712
  let connectionEpoch = 0;
41713
+ let automaticIntegrationProvisioningStarted = false;
41714
+ let automaticIntegrationProvisioning = Promise.resolve();
41697
41715
  let connectionAnnounced = false;
41698
41716
  let catalogPublished = false;
41699
41717
  let readinessAnnounced = false;
41718
+ const startAutomaticIntegrationProvisioning = () => {
41719
+ if (!connectionAnnounced || !catalogPublished || automaticIntegrationProvisioningStarted) {
41720
+ return;
41721
+ }
41722
+ automaticIntegrationProvisioningStarted = true;
41723
+ automaticIntegrationProvisioning = installDetectedAgentIntegrations(config2, installations, signal).catch(
41724
+ (error62) => {
41725
+ if (!signal.aborted) {
41726
+ console.error("Mobius daemon could not automatically install detected Agent integrations", error62);
41727
+ }
41728
+ }
41729
+ );
41730
+ };
41700
41731
  const announceReadiness = () => {
41701
41732
  if (!connectionAnnounced || !catalogPublished || readinessAnnounced) {
41702
41733
  return;
@@ -41718,6 +41749,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
41718
41749
  `
41719
41750
  );
41720
41751
  announceReadiness();
41752
+ startAutomaticIntegrationProvisioning();
41721
41753
  };
41722
41754
  const catalogPublication = publishAgentCatalogUntilAvailable(config2, diagnostics, signal, timer);
41723
41755
  void catalogPublication.then(() => {
@@ -41726,6 +41758,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
41726
41758
  }
41727
41759
  catalogPublished = true;
41728
41760
  announceReadiness();
41761
+ startAutomaticIntegrationProvisioning();
41729
41762
  });
41730
41763
  try {
41731
41764
  await ipc.listen(signal);
@@ -41772,24 +41805,28 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
41772
41805
  await catalogPublication;
41773
41806
  } finally {
41774
41807
  try {
41775
- await installations.close();
41808
+ await automaticIntegrationProvisioning;
41776
41809
  } finally {
41777
41810
  try {
41778
- await ipc.close();
41811
+ await installations.close();
41779
41812
  } finally {
41780
41813
  try {
41781
- await sessions.close();
41814
+ await ipc.close();
41782
41815
  } finally {
41783
41816
  try {
41784
- sessionStore.close();
41817
+ await sessions.close();
41785
41818
  } finally {
41786
41819
  try {
41787
- grants.close();
41820
+ sessionStore.close();
41788
41821
  } finally {
41789
41822
  try {
41790
- publisher.close();
41823
+ grants.close();
41791
41824
  } finally {
41792
- outbox.close();
41825
+ try {
41826
+ publisher.close();
41827
+ } finally {
41828
+ outbox.close();
41829
+ }
41793
41830
  }
41794
41831
  }
41795
41832
  }