agent-transport-system 0.3.45 → 0.3.46

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/ats.js CHANGED
@@ -27,7 +27,7 @@ import wrapAnsi from "wrap-ansi";
27
27
  import { Box, Container, Editor, Key, ProcessTerminal, TUI, Text, getEditorKeybindings, matchesKey } from "@mariozechner/pi-tui";
28
28
 
29
29
  //#region package.json
30
- var version = "0.3.45";
30
+ var version = "0.3.46";
31
31
  var package_default = {
32
32
  name: "agent-transport-system",
33
33
  version,
@@ -18192,7 +18192,7 @@ function toErrorMessage$20(error) {
18192
18192
 
18193
18193
  //#endregion
18194
18194
  //#region src/system/gateway-chain-readiness.ts
18195
- const DEFAULT_GATEWAY_CHAIN_TIMEOUT_MS = 5e3;
18195
+ const DEFAULT_GATEWAY_CHAIN_TIMEOUT_MS = 3e4;
18196
18196
  async function resolveGatewayChainReadiness(input = {}) {
18197
18197
  const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
18198
18198
  const authSession = input.authSession === void 0 ? await resolveGatewayChainAuthSession() : input.authSession;
@@ -50726,7 +50726,7 @@ async function prepareSingleAgentProfile(input) {
50726
50726
  let profile = input.profile;
50727
50727
  let prepared = false;
50728
50728
  let snapshot = await resolveProfileReadinessSnapshot(profile);
50729
- const initialReasonCodes = snapshot.deviceReplyReadiness.reasonCodes;
50729
+ const initialReasonCodes = collectPreparationReasonCodes(snapshot);
50730
50730
  if (needsControllerSetup({
50731
50731
  profile,
50732
50732
  reasonCodes: initialReasonCodes
@@ -50763,7 +50763,7 @@ async function prepareSingleAgentProfile(input) {
50763
50763
  snapshot = await resolveProfileReadinessSnapshot(profile);
50764
50764
  }
50765
50765
  }
50766
- const reasonCodes = snapshot.deviceReplyReadiness.reasonCodes;
50766
+ const reasonCodes = collectPreparationReasonCodes(snapshot);
50767
50767
  if (reasonCodes.includes("projection.missing")) {
50768
50768
  await syncDeviceRuntimeStateProjection({ mode: "repair" });
50769
50769
  prepared = true;
@@ -50814,6 +50814,12 @@ async function resolveProfileReadinessSnapshot(profile) {
50814
50814
  profile
50815
50815
  });
50816
50816
  }
50817
+ function collectPreparationReasonCodes(snapshot) {
50818
+ const reasonCodes = [];
50819
+ for (const reasonCode of snapshot.deviceReplyReadiness.reasonCodes) if (!reasonCodes.includes(reasonCode)) reasonCodes.push(reasonCode);
50820
+ for (const reasonCode of snapshot.agentReplyReadiness?.reasonCodes ?? []) if (!reasonCodes.includes(reasonCode)) reasonCodes.push(reasonCode);
50821
+ return reasonCodes;
50822
+ }
50817
50823
  function didWorkspaceRepairPrepareProfile(input) {
50818
50824
  if (input.workspaceSync.status === "skipped") return false;
50819
50825
  if (!input.workspaceSync.projectedProfileIds.includes(input.profileId)) return false;
@@ -54484,6 +54490,12 @@ async function runAgentsPrepare(input) {
54484
54490
  profile: preparedProfile,
54485
54491
  runtime
54486
54492
  });
54493
+ await maybeCompleteServiceReadinessAfterPreparation({
54494
+ interactive,
54495
+ profile: preparedProfile,
54496
+ runtime,
54497
+ view: input.view
54498
+ });
54487
54499
  await emitAgentsPrepareReadinessResult({
54488
54500
  presenter,
54489
54501
  profile: preparedProfile,
@@ -54590,6 +54602,59 @@ async function stopServiceForResetThisComputer(input) {
54590
54602
  throw error;
54591
54603
  }
54592
54604
  }
54605
+ async function maybeCompleteServiceReadinessAfterPreparation(input) {
54606
+ if (!input.interactive || input.runtime.resolvedView !== "human") return;
54607
+ const reasonCodes = collectReadinessReasonCodes(await resolveCurrentReplyReadinessSnapshot({
54608
+ checkGatewayChain: true,
54609
+ includeDaemonRouteObservation: true,
54610
+ openClawDiagnosticsMode: "repair",
54611
+ ownerUserId: input.profile.ownerUserId,
54612
+ profile: input.profile
54613
+ }));
54614
+ if (reasonCodes.length === 0) return;
54615
+ if ((await inspectDaemonServiceInventory({
54616
+ expectedVersion: resolveCurrentDaemonExpectedVersion(),
54617
+ intent: "status_cleanup"
54618
+ })).anomalies.some((anomaly) => DAEMON_SERVICE_ARTIFACT_DRIFT_ANOMALIES.has(anomaly.code)) || reasonCodes.includes("service.drifted")) {
54619
+ await runDaemonReinstall({
54620
+ agentOverviewHandled: true,
54621
+ profile: input.profile.atsProfileId,
54622
+ view: input.view
54623
+ }, {
54624
+ startAfterInstallMode: "always",
54625
+ suppressAgentOverview: true
54626
+ });
54627
+ return;
54628
+ }
54629
+ if (reasonCodes.includes("service.not_installed")) {
54630
+ await runDaemonInstall({
54631
+ agentOverviewHandled: true,
54632
+ profile: input.profile.atsProfileId,
54633
+ view: input.view
54634
+ }, { suppressAgentOverview: true });
54635
+ await runDaemonRun({
54636
+ agentOverviewHandled: true,
54637
+ gatewayUrl: await resolveBaseUrl(),
54638
+ mode: "background",
54639
+ profile: input.profile.atsProfileId,
54640
+ view: input.view
54641
+ });
54642
+ return;
54643
+ }
54644
+ if (reasonCodes.includes("service.not_running")) await runDaemonRun({
54645
+ agentOverviewHandled: true,
54646
+ gatewayUrl: await resolveBaseUrl(),
54647
+ mode: "background",
54648
+ profile: input.profile.atsProfileId,
54649
+ view: input.view
54650
+ });
54651
+ }
54652
+ function collectReadinessReasonCodes(input) {
54653
+ const reasonCodes = [];
54654
+ for (const reasonCode of input.deviceReplyReadiness.reasonCodes) if (!reasonCodes.includes(reasonCode)) reasonCodes.push(reasonCode);
54655
+ for (const reasonCode of input.agentReplyReadiness?.reasonCodes ?? []) if (!reasonCodes.includes(reasonCode)) reasonCodes.push(reasonCode);
54656
+ return reasonCodes;
54657
+ }
54593
54658
  function normalizeOptionalString$7(value) {
54594
54659
  const normalized = String(value ?? "").trim();
54595
54660
  return normalized.length > 0 ? normalized : null;