agent-transport-system 0.7.54 → 0.7.56

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.7.54";
30
+ var version = "0.7.56";
31
31
  var package_default = {
32
32
  $schema: "https://www.schemastore.org/package.json",
33
33
  name: "agent-transport-system",
@@ -19738,8 +19738,8 @@ function isPidAlive$4(pid) {
19738
19738
  }
19739
19739
  }
19740
19740
  function isRuntimeLeaseHeartbeatStale(runtimeLease) {
19741
- if (!runtimeLease.heartbeatAt) return false;
19742
- const heartbeatMs = Date.parse(runtimeLease.heartbeatAt);
19741
+ const freshnessTimestamp = runtimeLease.heartbeatAt ?? runtimeLease.updatedAt;
19742
+ const heartbeatMs = Date.parse(freshnessTimestamp);
19743
19743
  if (Number.isNaN(heartbeatMs)) return true;
19744
19744
  return Date.now() - heartbeatMs > DAEMON_HEARTBEAT_STALE_MS;
19745
19745
  }
@@ -26425,9 +26425,13 @@ async function resolveAgentReplyReadinessStatus(input) {
26425
26425
  });
26426
26426
  const { executionTarget, targetState, transportMode } = await resolveAgentPrimaryRuntimeContext(input.profile);
26427
26427
  const localAgentId = executionTarget?.localAgentId ?? null;
26428
+ const deviceReasonCodes = resolveAgentDeviceReasonCodes({
26429
+ coreWakeRouteOnline: input.coreWakeRouteOnline === true,
26430
+ deviceReasonCodes: deviceReplyReadiness.reasonCodes
26431
+ });
26428
26432
  const reasonCodes = collectAgentReplyReadinessReasonCodes({
26429
26433
  bindingReady: executionTarget?.bindingState === "enabled_primary" && executionTarget.routable,
26430
- deviceReasonCodes: deviceReplyReadiness.reasonCodes,
26434
+ deviceReasonCodes,
26431
26435
  profile: input.profile,
26432
26436
  targetState
26433
26437
  });
@@ -26476,6 +26480,10 @@ async function resolveAgentReplyReadinessStatus(input) {
26476
26480
  replyReadiness: resolveReplyReadinessLevel(reasonCodes, deviceReplyReadiness)
26477
26481
  });
26478
26482
  }
26483
+ function resolveAgentDeviceReasonCodes(input) {
26484
+ if (!input.coreWakeRouteOnline) return [...input.deviceReasonCodes];
26485
+ return input.deviceReasonCodes.filter((reasonCode) => reasonCode !== "service.not_running" && reasonCode !== "route.offline" && reasonCode !== "route.not_registered");
26486
+ }
26479
26487
  async function resolveAgentPrimaryRuntimeContext(profile) {
26480
26488
  const executionTarget = await resolveAgentProfilePrimaryAgentControllerReport({ profile }).catch(() => null);
26481
26489
  const localAgentId = executionTarget?.localAgentId;
@@ -26870,18 +26878,20 @@ async function resolveCurrentReplyReadinessSnapshot(input = {}) {
26870
26878
  profile: input.profile ?? null,
26871
26879
  profileWorkspaceRuntimeResolution
26872
26880
  });
26881
+ const daemonRouteObservation = await resolveDaemonRouteObservation({
26882
+ baseUrl: input.baseUrl,
26883
+ includeDaemonRouteObservation: input.includeDaemonRouteObservation === true,
26884
+ profile: input.profile ?? null
26885
+ });
26873
26886
  const agentReplyReadiness = input.profile?.profileKind === "agent" ? await resolveAgentReplyReadinessStatus({
26887
+ coreWakeRouteOnline: daemonRouteObservation.status === "online",
26874
26888
  deviceReplyReadiness,
26875
26889
  openClawLocalDiagnostics,
26876
26890
  profile: input.profile,
26877
26891
  profileWorkspaceRuntimeResolution
26878
26892
  }).catch(() => null) : null;
26879
26893
  return {
26880
- daemonRouteObservation: await resolveDaemonRouteObservation({
26881
- baseUrl: input.baseUrl,
26882
- includeDaemonRouteObservation: input.includeDaemonRouteObservation === true,
26883
- profile: input.profile ?? null
26884
- }),
26894
+ daemonRouteObservation,
26885
26895
  observedAt: (/* @__PURE__ */ new Date()).toISOString(),
26886
26896
  daemonStatus,
26887
26897
  inventory,
@@ -40710,13 +40720,15 @@ function createDaemonRuntimeStateTracker(input) {
40710
40720
  let lastRuntimeStatePersistAtMs = Date.now();
40711
40721
  const touchRuntimeState = async (updates, options) => {
40712
40722
  const nowAt = nowIsoString();
40723
+ const previousHeartbeatAt = runtimeState.heartbeatAt;
40713
40724
  runtimeState = {
40714
40725
  ...runtimeState,
40715
40726
  ...updates,
40716
40727
  updatedAt: updates.updatedAt ?? nowAt
40717
40728
  };
40729
+ const receivedFirstHeartbeat = previousHeartbeatAt === null && typeof updates.heartbeatAt === "string" && updates.heartbeatAt.length > 0;
40718
40730
  if (!shouldPersistDaemonRuntimeState({
40719
- forcePersist: options?.forcePersist === true,
40731
+ forcePersist: options?.forcePersist === true || receivedFirstHeartbeat,
40720
40732
  nowMs: Date.now(),
40721
40733
  lastPersistedAtMs: lastRuntimeStatePersistAtMs,
40722
40734
  updates