agent-transport-system 0.7.48 → 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 +49 -10
- package/dist/ats.js.map +1 -1
- package/package.json +1 -1
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.
|
|
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;
|
|
@@ -45375,6 +45376,8 @@ async function runDaemonSocketSession(input) {
|
|
|
45375
45376
|
let nextCatalogSyncAtMs = 0;
|
|
45376
45377
|
let nextProviderConversationProofSyncAtMs = 0;
|
|
45377
45378
|
let nextRuntimeAgentControllerReportSyncAtMs = 0;
|
|
45379
|
+
let providerConversationProofSyncInFlight = false;
|
|
45380
|
+
let runtimeAgentControllerReportSyncInFlight = false;
|
|
45378
45381
|
let latestCatalogSyncStatus = null;
|
|
45379
45382
|
let latestSkippedProfilesFingerprint = null;
|
|
45380
45383
|
let latestCatalogSyncSignalUpdatedAtMs = 0;
|
|
@@ -45531,7 +45534,7 @@ async function runDaemonSocketSession(input) {
|
|
|
45531
45534
|
nextCatalogSyncAtMs = 0;
|
|
45532
45535
|
nextProviderConversationProofSyncAtMs = 0;
|
|
45533
45536
|
nextRuntimeAgentControllerReportSyncAtMs = 0;
|
|
45534
|
-
if (heartbeatInFlight) pendingLocalExecutionEvidenceRefreshReason = inputRequest.reason;
|
|
45537
|
+
if (heartbeatInFlight || routeCatalogSyncInFlight) pendingLocalExecutionEvidenceRefreshReason = inputRequest.reason;
|
|
45535
45538
|
scheduleHeartbeat({
|
|
45536
45539
|
delayMs: 0,
|
|
45537
45540
|
reason: inputRequest.scheduleReason
|
|
@@ -45572,7 +45575,6 @@ async function runDaemonSocketSession(input) {
|
|
|
45572
45575
|
if (closed || heartbeatInFlight) return;
|
|
45573
45576
|
heartbeatInFlight = true;
|
|
45574
45577
|
try {
|
|
45575
|
-
await syncRouteCatalogIfDue();
|
|
45576
45578
|
const leases = Array.from(leasesByProfileId.entries()).map(([profileId, leaseEpoch]) => ({
|
|
45577
45579
|
profileId,
|
|
45578
45580
|
leaseEpoch
|
|
@@ -45608,14 +45610,11 @@ async function runDaemonSocketSession(input) {
|
|
|
45608
45610
|
if (heartbeatResponse.staleLeases.length > 0) {
|
|
45609
45611
|
forceCatalogSyncReason = "stale_leases";
|
|
45610
45612
|
nextCatalogSyncAtMs = 0;
|
|
45611
|
-
await syncRouteCatalogIfDue();
|
|
45612
45613
|
}
|
|
45613
45614
|
await input.touchRuntimeState({
|
|
45614
45615
|
heartbeatAt: nowIsoString(),
|
|
45615
45616
|
updatedAt: nowIsoString()
|
|
45616
45617
|
});
|
|
45617
|
-
await syncRuntimeAgentControllerReportsIfDue();
|
|
45618
|
-
await syncProviderConversationProofsIfDue();
|
|
45619
45618
|
flushDispatchResultOutbox({
|
|
45620
45619
|
currentSocketRef,
|
|
45621
45620
|
ledgerPaths: input.ledgerPaths,
|
|
@@ -45644,6 +45643,8 @@ 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
|
+
startSupplementalEvidenceSyncs();
|
|
45647
45648
|
} catch (error) {
|
|
45648
45649
|
consecutiveHeartbeatFailures += 1;
|
|
45649
45650
|
const shouldCloseSocket = consecutiveHeartbeatFailures >= HEARTBEAT_CONSECUTIVE_FAILURES_BEFORE_CLOSE;
|
|
@@ -45924,7 +45925,23 @@ async function runDaemonSocketSession(input) {
|
|
|
45924
45925
|
handleFailedCatalogSync(syncResult);
|
|
45925
45926
|
resolvePendingRouteCatalogSyncRequests(syncResult);
|
|
45926
45927
|
};
|
|
45927
|
-
const
|
|
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() {
|
|
45928
45945
|
const forceReason = forceCatalogSyncReason;
|
|
45929
45946
|
const nowMs = Date.now();
|
|
45930
45947
|
if (!forceReason && nowMs < nextCatalogSyncAtMs) {
|
|
@@ -45938,9 +45955,10 @@ async function runDaemonSocketSession(input) {
|
|
|
45938
45955
|
}
|
|
45939
45956
|
forceCatalogSyncReason = null;
|
|
45940
45957
|
await runCatalogSync(forceReason ? { forceReason } : void 0);
|
|
45941
|
-
}
|
|
45958
|
+
}
|
|
45942
45959
|
const syncRuntimeAgentControllerReportsIfDue = async () => {
|
|
45943
|
-
if (Date.now() < nextRuntimeAgentControllerReportSyncAtMs) return;
|
|
45960
|
+
if (runtimeAgentControllerReportSyncInFlight || Date.now() < nextRuntimeAgentControllerReportSyncAtMs) return;
|
|
45961
|
+
runtimeAgentControllerReportSyncInFlight = true;
|
|
45944
45962
|
try {
|
|
45945
45963
|
const result = await syncLocalServiceRuntimeAgentControllerReports({ localAdapterContainer: input.localAdapterContainer });
|
|
45946
45964
|
const retryInMs = result.failedCount > 0 ? RUNTIME_AGENT_CONTROLLER_REPORT_SYNC_RETRY_INTERVAL_MS : RUNTIME_AGENT_CONTROLLER_REPORT_SYNC_INTERVAL_MS;
|
|
@@ -45969,10 +45987,13 @@ async function runDaemonSocketSession(input) {
|
|
|
45969
45987
|
code: "daemon.run.runtime_agent_controller_report_sync_failed",
|
|
45970
45988
|
text: `runtime agent controller report sync failed: ${toErrorMessage$29(error)}`
|
|
45971
45989
|
});
|
|
45990
|
+
} finally {
|
|
45991
|
+
runtimeAgentControllerReportSyncInFlight = false;
|
|
45972
45992
|
}
|
|
45973
45993
|
};
|
|
45974
45994
|
const syncProviderConversationProofsIfDue = async () => {
|
|
45975
|
-
if (Date.now() < nextProviderConversationProofSyncAtMs) return;
|
|
45995
|
+
if (providerConversationProofSyncInFlight || Date.now() < nextProviderConversationProofSyncAtMs) return;
|
|
45996
|
+
providerConversationProofSyncInFlight = true;
|
|
45976
45997
|
try {
|
|
45977
45998
|
const result = await syncLocalServiceProviderConversationProofs({ routeCatalog: createRouteCatalogFromMutableState(input.routeCatalogState) });
|
|
45978
45999
|
const retryInMs = result.failedCount > 0 ? PROVIDER_CONVERSATION_PROOF_SYNC_RETRY_INTERVAL_MS : PROVIDER_CONVERSATION_PROOF_SYNC_INTERVAL_MS;
|
|
@@ -46001,8 +46022,26 @@ async function runDaemonSocketSession(input) {
|
|
|
46001
46022
|
code: "daemon.run.provider_conversation_proof_sync_failed",
|
|
46002
46023
|
text: `provider conversation proof sync failed: ${toErrorMessage$29(error)}`
|
|
46003
46024
|
});
|
|
46025
|
+
} finally {
|
|
46026
|
+
providerConversationProofSyncInFlight = false;
|
|
46004
46027
|
}
|
|
46005
46028
|
};
|
|
46029
|
+
const startSupplementalEvidenceSyncs = () => {
|
|
46030
|
+
syncRuntimeAgentControllerReportsIfDue().catch((error) => {
|
|
46031
|
+
emitRunLine({
|
|
46032
|
+
presenter: input.presenter,
|
|
46033
|
+
code: "daemon.run.runtime_agent_controller_report_sync_failed",
|
|
46034
|
+
text: `runtime agent controller report sync failed: ${toErrorMessage$29(error)}`
|
|
46035
|
+
});
|
|
46036
|
+
});
|
|
46037
|
+
syncProviderConversationProofsIfDue().catch((error) => {
|
|
46038
|
+
emitRunLine({
|
|
46039
|
+
presenter: input.presenter,
|
|
46040
|
+
code: "daemon.run.provider_conversation_proof_sync_failed",
|
|
46041
|
+
text: `provider conversation proof sync failed: ${toErrorMessage$29(error)}`
|
|
46042
|
+
});
|
|
46043
|
+
});
|
|
46044
|
+
};
|
|
46006
46045
|
input.socket.onError((error) => {
|
|
46007
46046
|
emitRunLine({
|
|
46008
46047
|
presenter: input.presenter,
|