agent-transport-system 0.7.55 → 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.55";
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
  }
@@ -40720,13 +40720,15 @@ function createDaemonRuntimeStateTracker(input) {
40720
40720
  let lastRuntimeStatePersistAtMs = Date.now();
40721
40721
  const touchRuntimeState = async (updates, options) => {
40722
40722
  const nowAt = nowIsoString();
40723
+ const previousHeartbeatAt = runtimeState.heartbeatAt;
40723
40724
  runtimeState = {
40724
40725
  ...runtimeState,
40725
40726
  ...updates,
40726
40727
  updatedAt: updates.updatedAt ?? nowAt
40727
40728
  };
40729
+ const receivedFirstHeartbeat = previousHeartbeatAt === null && typeof updates.heartbeatAt === "string" && updates.heartbeatAt.length > 0;
40728
40730
  if (!shouldPersistDaemonRuntimeState({
40729
- forcePersist: options?.forcePersist === true,
40731
+ forcePersist: options?.forcePersist === true || receivedFirstHeartbeat,
40730
40732
  nowMs: Date.now(),
40731
40733
  lastPersistedAtMs: lastRuntimeStatePersistAtMs,
40732
40734
  updates