agent-transport-system 0.7.49 → 0.7.50

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.49";
30
+ var version = "0.7.50";
31
31
  var package_default = {
32
32
  $schema: "https://www.schemastore.org/package.json",
33
33
  name: "agent-transport-system",
@@ -45364,6 +45364,7 @@ async function runDaemonSocketSession(input) {
45364
45364
  let closeCode = 1e3;
45365
45365
  let closeReason = "closed";
45366
45366
  let heartbeatInFlight = false;
45367
+ let routeCatalogSyncInFlight = false;
45367
45368
  let heartbeatTimer = null;
45368
45369
  let heartbeatTimerDueAtMs = null;
45369
45370
  let lastDispatchActivityAtMs = null;
@@ -45533,7 +45534,7 @@ async function runDaemonSocketSession(input) {
45533
45534
  nextCatalogSyncAtMs = 0;
45534
45535
  nextProviderConversationProofSyncAtMs = 0;
45535
45536
  nextRuntimeAgentControllerReportSyncAtMs = 0;
45536
- if (heartbeatInFlight) pendingLocalExecutionEvidenceRefreshReason = inputRequest.reason;
45537
+ if (heartbeatInFlight || routeCatalogSyncInFlight) pendingLocalExecutionEvidenceRefreshReason = inputRequest.reason;
45537
45538
  scheduleHeartbeat({
45538
45539
  delayMs: 0,
45539
45540
  reason: inputRequest.scheduleReason
@@ -45574,7 +45575,6 @@ async function runDaemonSocketSession(input) {
45574
45575
  if (closed || heartbeatInFlight) return;
45575
45576
  heartbeatInFlight = true;
45576
45577
  try {
45577
- await syncRouteCatalogIfDue();
45578
45578
  const leases = Array.from(leasesByProfileId.entries()).map(([profileId, leaseEpoch]) => ({
45579
45579
  profileId,
45580
45580
  leaseEpoch
@@ -45610,7 +45610,6 @@ async function runDaemonSocketSession(input) {
45610
45610
  if (heartbeatResponse.staleLeases.length > 0) {
45611
45611
  forceCatalogSyncReason = "stale_leases";
45612
45612
  nextCatalogSyncAtMs = 0;
45613
- await syncRouteCatalogIfDue();
45614
45613
  }
45615
45614
  await input.touchRuntimeState({
45616
45615
  heartbeatAt: nowIsoString(),
@@ -45644,6 +45643,7 @@ async function runDaemonSocketSession(input) {
45644
45643
  code: "daemon.run.heartbeat",
45645
45644
  text: `heartbeat ok; active leases=${leasesByProfileId.size}, stale leases=${heartbeatResponse.staleLeases.length}, next=${String(currentHeartbeatIntervalMs)}ms`
45646
45645
  });
45646
+ startRouteCatalogSyncIfDue();
45647
45647
  startSupplementalEvidenceSyncs();
45648
45648
  } catch (error) {
45649
45649
  consecutiveHeartbeatFailures += 1;
@@ -45925,7 +45925,23 @@ async function runDaemonSocketSession(input) {
45925
45925
  handleFailedCatalogSync(syncResult);
45926
45926
  resolvePendingRouteCatalogSyncRequests(syncResult);
45927
45927
  };
45928
- const syncRouteCatalogIfDue = async () => {
45928
+ const shouldStartRouteCatalogSync = () => Boolean(forceCatalogSyncReason) || Date.now() >= nextCatalogSyncAtMs;
45929
+ function startRouteCatalogSyncIfDue() {
45930
+ if (closed || routeCatalogSyncInFlight || !shouldStartRouteCatalogSync()) return;
45931
+ routeCatalogSyncInFlight = true;
45932
+ syncRouteCatalogIfDue().catch((error) => {
45933
+ failPendingRouteCatalogSyncRequests(error instanceof Error ? error : new Error(toErrorMessage$29(error)));
45934
+ emitRunLine({
45935
+ presenter: input.presenter,
45936
+ code: "daemon.run.catalog_sync_failed",
45937
+ text: `catalog sync failed: ${toErrorMessage$29(error)}`
45938
+ });
45939
+ }).finally(() => {
45940
+ routeCatalogSyncInFlight = false;
45941
+ schedulePendingLocalExecutionEvidenceRefreshIfNeeded();
45942
+ });
45943
+ }
45944
+ async function syncRouteCatalogIfDue() {
45929
45945
  const forceReason = forceCatalogSyncReason;
45930
45946
  const nowMs = Date.now();
45931
45947
  if (!forceReason && nowMs < nextCatalogSyncAtMs) {
@@ -45939,7 +45955,7 @@ async function runDaemonSocketSession(input) {
45939
45955
  }
45940
45956
  forceCatalogSyncReason = null;
45941
45957
  await runCatalogSync(forceReason ? { forceReason } : void 0);
45942
- };
45958
+ }
45943
45959
  const syncRuntimeAgentControllerReportsIfDue = async () => {
45944
45960
  if (runtimeAgentControllerReportSyncInFlight || Date.now() < nextRuntimeAgentControllerReportSyncAtMs) return;
45945
45961
  runtimeAgentControllerReportSyncInFlight = true;