agent-transport-system 0.4.9 → 0.4.92
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 +43 -16
- 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.4.
|
|
30
|
+
var version = "0.4.92";
|
|
31
31
|
var package_default = {
|
|
32
32
|
$schema: "https://www.schemastore.org/package.json",
|
|
33
33
|
name: "agent-transport-system",
|
|
@@ -7514,7 +7514,7 @@ async function resolveDaemonDeviceId(input) {
|
|
|
7514
7514
|
return explicit;
|
|
7515
7515
|
}
|
|
7516
7516
|
const persisted = normalizeOptionalText$43(await readFile(input.deviceIdPath, "utf8").catch(() => ""));
|
|
7517
|
-
if (persisted) return persisted;
|
|
7517
|
+
if (persisted && !(input.shouldDiscardPersistedDeviceId?.(persisted) ?? false)) return persisted;
|
|
7518
7518
|
const generated = randomUUID();
|
|
7519
7519
|
await writeDaemonDeviceId({
|
|
7520
7520
|
deviceId: generated,
|
|
@@ -7663,6 +7663,11 @@ const DAEMON_SERVICE_ARTIFACT_DRIFT_ANOMALIES = new Set([
|
|
|
7663
7663
|
"service_manager_path_drift",
|
|
7664
7664
|
"version_outdated"
|
|
7665
7665
|
]);
|
|
7666
|
+
const DAEMON_SERVICE_RUN_BLOCKING_ANOMALIES = new Set([
|
|
7667
|
+
...[...DAEMON_SERVICE_ARTIFACT_DRIFT_ANOMALIES].filter((code) => code !== "runtime_stale" && code !== "version_outdated"),
|
|
7668
|
+
"duplicate_owned_processes",
|
|
7669
|
+
"foreground_background_conflict"
|
|
7670
|
+
]);
|
|
7666
7671
|
const DAEMON_SERVICE_WAKEABILITY_HARD_BLOCKER_ANOMALIES = new Set([
|
|
7667
7672
|
"duplicate_owned_processes",
|
|
7668
7673
|
"manager_running_without_runtime",
|
|
@@ -7716,6 +7721,13 @@ function classifyDaemonServiceWakeability(input) {
|
|
|
7716
7721
|
executionEvidenceSafe
|
|
7717
7722
|
};
|
|
7718
7723
|
}
|
|
7724
|
+
function classifyDaemonServiceRunStartability(input) {
|
|
7725
|
+
const blockingCodes = collectUniqueAnomalyCodes(input.inventory).filter((code) => DAEMON_SERVICE_RUN_BLOCKING_ANOMALIES.has(code));
|
|
7726
|
+
return {
|
|
7727
|
+
blockingCodes,
|
|
7728
|
+
blocksStart: blockingCodes.length > 0
|
|
7729
|
+
};
|
|
7730
|
+
}
|
|
7719
7731
|
function shouldBlockConditionalWakeabilityAnomaly(input) {
|
|
7720
7732
|
return !input.executionEvidenceSafe;
|
|
7721
7733
|
}
|
|
@@ -23160,10 +23172,11 @@ function resolveRuntimeHeadlineFromStatus(status) {
|
|
|
23160
23172
|
}
|
|
23161
23173
|
function createServiceUpdateAvailableProjection(input) {
|
|
23162
23174
|
const nextSteps = [formatAtsCliCommand("ats service reinstall")];
|
|
23175
|
+
const serviceIsRunning = input.runtimeHeadline === "running";
|
|
23163
23176
|
return createServiceStatusProjection({
|
|
23164
23177
|
anomalyCodes: input.anomalyCodes,
|
|
23165
|
-
detailText: "ATS Service update available. Local agents can keep replying if this service is still execution-compatible.",
|
|
23166
|
-
nextStepSummary: "Update ATS Service when convenient with `ats service reinstall`.",
|
|
23178
|
+
detailText: serviceIsRunning ? "ATS Service update available. Local agents can keep replying if this service is still execution-compatible." : "ATS Service update available, and ATS Service is not ready. Update and start ATS Service before local agents can reply from this computer.",
|
|
23179
|
+
nextStepSummary: serviceIsRunning ? "Update ATS Service when convenient with `ats service reinstall`." : "Update and start ATS Service with `ats service reinstall`.",
|
|
23167
23180
|
nextSteps,
|
|
23168
23181
|
runtimeHeadline: input.runtimeHeadline,
|
|
23169
23182
|
state: "update_available",
|
|
@@ -23245,12 +23258,13 @@ function resolveDaemonStatusAttention(input) {
|
|
|
23245
23258
|
};
|
|
23246
23259
|
if (repairCodes.length === 0) {
|
|
23247
23260
|
if (updateAvailableCodes.length === 0) return null;
|
|
23261
|
+
const serviceIsRunning = isRuntimeActive(input.runtimeState);
|
|
23248
23262
|
return {
|
|
23249
23263
|
level: "info",
|
|
23250
23264
|
code: "service_update_available",
|
|
23251
23265
|
title: "ATS Service Update Available",
|
|
23252
|
-
message: "An ATS Service update is available. Local agents can keep replying if this service is still execution-compatible.",
|
|
23253
|
-
nextStep: "Update ATS Service when convenient with `ats service reinstall`.",
|
|
23266
|
+
message: serviceIsRunning ? "An ATS Service update is available. Local agents can keep replying if this service is still execution-compatible." : "An ATS Service update is available, and ATS Service is not ready. Update and start ATS Service before local agents can reply from this computer.",
|
|
23267
|
+
nextStep: serviceIsRunning ? "Update ATS Service when convenient with `ats service reinstall`." : "Update and start ATS Service with `ats service reinstall`.",
|
|
23254
23268
|
anomalyCodes: updateAvailableCodes
|
|
23255
23269
|
};
|
|
23256
23270
|
}
|
|
@@ -23276,6 +23290,9 @@ function collectAnomalyCodes(inventory, allowedCodes) {
|
|
|
23276
23290
|
function isForegroundRuntimeActive(runtimeState) {
|
|
23277
23291
|
return runtimeState?.status === "running" && runtimeState.mode === "foreground";
|
|
23278
23292
|
}
|
|
23293
|
+
function isRuntimeActive(runtimeState) {
|
|
23294
|
+
return runtimeState?.status === "running";
|
|
23295
|
+
}
|
|
23279
23296
|
function createStatusAttentionReplyReadiness() {
|
|
23280
23297
|
return {
|
|
23281
23298
|
reasonCodes: [],
|
|
@@ -24250,12 +24267,14 @@ async function resolveLifecycleCommandOptions(input) {
|
|
|
24250
24267
|
const preferCommandGateway = shouldPreferCommandResolvedGatewayForLifecycle();
|
|
24251
24268
|
const gatewayUrl = explicitGatewayUrl ?? (preferCommandGateway ? commandGatewayUrl : null) ?? normalizeGatewayBaseUrlOrNull(currentContract?.gatewayUrl) ?? normalizeGatewayBaseUrlOrNull(runtimeSnapshot?.gatewayUrl) ?? commandGatewayUrl;
|
|
24252
24269
|
const atsProfileId = normalizeOptionalText$43(input.profile) ?? normalizeOptionalText$43(runtimeSnapshot?.atsProfileId) ?? fallbackProfile?.atsProfileId ?? reusableCurrentContract?.profileId;
|
|
24270
|
+
const shouldDiscardPersistedDeviceId = resolveAtsEnvPreset() === "prod" ? isUnsafeProductionDeviceId : void 0;
|
|
24253
24271
|
const deviceId = runtimePaths ? await resolveDaemonDeviceId({
|
|
24254
24272
|
deviceId: resolvePreferredDaemonDeviceId({
|
|
24255
24273
|
explicitDeviceId: input.deviceId,
|
|
24256
24274
|
contractDeviceId: reusableCurrentContract?.deviceId
|
|
24257
24275
|
}),
|
|
24258
|
-
deviceIdPath: runtimePaths.deviceIdPath
|
|
24276
|
+
deviceIdPath: runtimePaths.deviceIdPath,
|
|
24277
|
+
...shouldDiscardPersistedDeviceId ? { shouldDiscardPersistedDeviceId } : {}
|
|
24259
24278
|
}).catch(() => reusableCurrentContract?.deviceId ?? null) : normalizeOptionalText$43(input.deviceId) ?? reusableCurrentContract?.deviceId ?? null;
|
|
24260
24279
|
const heartbeatMs = normalizeHeartbeatIntervalMs(input.heartbeatMs ?? currentContract?.heartbeatMs);
|
|
24261
24280
|
return {
|
|
@@ -49579,11 +49598,7 @@ async function syncCurrentDeviceBootstrapObservationAfterLocalStateChange(input)
|
|
|
49579
49598
|
//#endregion
|
|
49580
49599
|
//#region src/commands/daemon.ts
|
|
49581
49600
|
const STATUS_CLEANUP_SIGNIFICANT_ANOMALIES = DAEMON_SERVICE_REPAIR_ANOMALIES;
|
|
49582
|
-
const DAEMON_RUN_BLOCKING_ANOMALIES =
|
|
49583
|
-
...[...DAEMON_SERVICE_ARTIFACT_DRIFT_ANOMALIES].filter((code) => code !== "runtime_stale" && code !== "version_outdated"),
|
|
49584
|
-
"duplicate_owned_processes",
|
|
49585
|
-
"foreground_background_conflict"
|
|
49586
|
-
]);
|
|
49601
|
+
const DAEMON_RUN_BLOCKING_ANOMALIES = DAEMON_SERVICE_RUN_BLOCKING_ANOMALIES;
|
|
49587
49602
|
const DAEMON_STARTUP_BLOCKING_ANOMALIES = new Set([
|
|
49588
49603
|
"duplicate_owned_processes",
|
|
49589
49604
|
"multiple_active_owners",
|
|
@@ -49830,7 +49845,14 @@ async function attachDaemonReinstallEvidence(input) {
|
|
|
49830
49845
|
};
|
|
49831
49846
|
}
|
|
49832
49847
|
function buildDaemonReinstallFailureMessage(input) {
|
|
49833
|
-
if (input.resolvedView === "human")
|
|
49848
|
+
if (input.resolvedView === "human") {
|
|
49849
|
+
if (input.errorMessage.includes("test fixture identity")) return [
|
|
49850
|
+
"ATS service reinstall failed because this production lane contains old test setup identity that cannot be reused.",
|
|
49851
|
+
"Rerun the setup command from ATS Web so ATS can write a fresh production service contract.",
|
|
49852
|
+
"For diagnostics, run `ats service status --view agent`."
|
|
49853
|
+
].join(" ");
|
|
49854
|
+
return `ATS service reinstall failed. ${buildDaemonServiceRefreshNextStep()} For diagnostics, run \`ats service status --view agent\`.`;
|
|
49855
|
+
}
|
|
49834
49856
|
const failureContext = formatDaemonFailureContextText({
|
|
49835
49857
|
backupDataPath: input.backupDataPath,
|
|
49836
49858
|
evidencePath: input.evidencePath,
|
|
@@ -54081,7 +54103,8 @@ async function resolveDaemonServiceParticipationStatus(input) {
|
|
|
54081
54103
|
};
|
|
54082
54104
|
const installedVersion = inventory.installStatus.state.daemonVersion;
|
|
54083
54105
|
const blockingServiceDriftCodes = classifyDaemonServiceWakeability({ inventory }).blockingCodes;
|
|
54084
|
-
const
|
|
54106
|
+
const runBlockingServiceDriftCodes = classifyDaemonServiceRunStartability({ inventory }).blockingCodes;
|
|
54107
|
+
const repairAnomalies = inventory.anomalies.filter((anomaly) => [...blockingServiceDriftCodes, ...runBlockingServiceDriftCodes].includes(anomaly.code));
|
|
54085
54108
|
if (repairAnomalies.length > 0) return {
|
|
54086
54109
|
kind: "needs_repair",
|
|
54087
54110
|
expectedVersion,
|
|
@@ -59849,16 +59872,20 @@ async function maybeCompleteServiceReadinessAfterPreparation(input) {
|
|
|
59849
59872
|
profile: input.profile
|
|
59850
59873
|
}));
|
|
59851
59874
|
if (reasonCodes.length === 0) return;
|
|
59852
|
-
|
|
59875
|
+
const inventory = await inspectDaemonServiceInventory({
|
|
59853
59876
|
expectedVersion: resolveCurrentDaemonExpectedVersion(),
|
|
59854
59877
|
intent: "status_cleanup"
|
|
59855
|
-
})
|
|
59878
|
+
});
|
|
59879
|
+
const hasBlockingServiceDrift = classifyDaemonServiceWakeability({ inventory }).blocksWake;
|
|
59880
|
+
const serviceRunWouldBeBlocked = classifyDaemonServiceRunStartability({ inventory }).blocksStart;
|
|
59881
|
+
if (hasBlockingServiceDrift || serviceRunWouldBeBlocked || reasonCodes.includes("service.drifted")) {
|
|
59856
59882
|
const refreshOutcome = await runDaemonReinstall({
|
|
59857
59883
|
agentOverviewHandled: true,
|
|
59858
59884
|
gatewayUrl: await resolveBaseUrl(),
|
|
59859
59885
|
profile: input.profile.atsProfileId,
|
|
59860
59886
|
view: input.view
|
|
59861
59887
|
}, {
|
|
59888
|
+
skipConfirm: true,
|
|
59862
59889
|
startAfterInstallMode: "always",
|
|
59863
59890
|
suppressAgentOverview: true
|
|
59864
59891
|
});
|