@agent-link/agent 0.1.325 → 0.1.328
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/action.d.ts +1 -0
- package/dist/action.js +15 -1
- package/dist/action.js.map +1 -1
- package/dist/backends/types.d.ts +8 -0
- package/dist/backends/types.js +15 -0
- package/dist/backends/types.js.map +1 -1
- package/dist/braincore-cli.d.ts +3 -1
- package/dist/braincore-cli.js +14 -1
- package/dist/braincore-cli.js.map +1 -1
- package/dist/connection.js +94 -23
- package/dist/connection.js.map +1 -1
- package/dist/pi.d.ts +4 -0
- package/dist/pi.js +234 -4
- package/dist/pi.js.map +1 -1
- package/dist/process-identity.js +13 -0
- package/dist/process-identity.js.map +1 -1
- package/dist/provider-command-discovery.d.ts +25 -0
- package/dist/provider-command-discovery.js +42 -0
- package/dist/provider-command-discovery.js.map +1 -0
- package/dist/provider-command-types.d.ts +23 -0
- package/dist/provider-command-types.js +13 -0
- package/dist/provider-command-types.js.map +1 -0
- package/dist/recap.d.ts +1 -0
- package/dist/recap.js +9 -0
- package/dist/recap.js.map +1 -1
- package/launcher/launcher.cjs +11 -0
- package/package.json +1 -1
- package/worker/worker.cjs +37 -2
package/worker/worker.cjs
CHANGED
|
@@ -121,6 +121,19 @@ function identityError(error) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
function processIdentity(pid) {
|
|
124
|
+
if (
|
|
125
|
+
process.env.NODE_ENV === 'test'
|
|
126
|
+
&& process.env.AGENTLINK_TEST_FAST_PROCESS_IDENTITY === '1'
|
|
127
|
+
) {
|
|
128
|
+
try {
|
|
129
|
+
process.kill(pid, 0);
|
|
130
|
+
return { status: 'found', identity: `test:${pid}` };
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return error.code === 'ESRCH'
|
|
133
|
+
? { status: 'absent' }
|
|
134
|
+
: { status: 'error', error: identityError(error) };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
124
137
|
if (process.platform === 'linux') {
|
|
125
138
|
let stat;
|
|
126
139
|
try {
|
|
@@ -803,6 +816,14 @@ function sessionIdentityMatches(job, runtime, status) {
|
|
|
803
816
|
|
|
804
817
|
async function waitForLocalHealth(job, expectedSelection, expectedIdentity, timeoutMs = Number(process.env.AGENTLINK_UPGRADE_HEALTH_TIMEOUT_MS) || 15000) {
|
|
805
818
|
validateSelection(job, expectedSelection);
|
|
819
|
+
const testTimeoutMs = Number(process.env.AGENTLINK_WORKER_TEST_LOCAL_HEALTH_TIMEOUT_MS);
|
|
820
|
+
if (
|
|
821
|
+
process.env.NODE_ENV === 'test'
|
|
822
|
+
&& Number.isFinite(testTimeoutMs)
|
|
823
|
+
&& testTimeoutMs > 0
|
|
824
|
+
) {
|
|
825
|
+
timeoutMs = Math.min(timeoutMs, testTimeoutMs);
|
|
826
|
+
}
|
|
806
827
|
if (
|
|
807
828
|
process.env.AGENTLINK_WORKER_TEST_FAIL_LOCAL_HEALTH_VERSION
|
|
808
829
|
=== expectedSelection.version
|
|
@@ -868,9 +889,23 @@ function relayHealthy(health) {
|
|
|
868
889
|
async function waitForRelay(job, health) {
|
|
869
890
|
let current = health;
|
|
870
891
|
const configuredTimeout = Number(process.env.AGENTLINK_UPGRADE_RELAY_TIMEOUT_MS);
|
|
871
|
-
|
|
892
|
+
let rollbackTimeout = Number.isFinite(configuredTimeout)
|
|
872
893
|
? Math.min(Math.max(configuredTimeout, 1000), 120000)
|
|
873
894
|
: 30000;
|
|
895
|
+
const testTimeoutMs = Number(process.env.AGENTLINK_WORKER_TEST_RELAY_TIMEOUT_MS);
|
|
896
|
+
if (
|
|
897
|
+
process.env.NODE_ENV === 'test'
|
|
898
|
+
&& Number.isFinite(testTimeoutMs)
|
|
899
|
+
&& testTimeoutMs > 0
|
|
900
|
+
) {
|
|
901
|
+
rollbackTimeout = Math.min(rollbackTimeout, testTimeoutMs);
|
|
902
|
+
}
|
|
903
|
+
const testPollIntervalMs = Number(process.env.AGENTLINK_WORKER_TEST_RELAY_POLL_INTERVAL_MS);
|
|
904
|
+
const pollIntervalMs = process.env.NODE_ENV === 'test'
|
|
905
|
+
&& Number.isFinite(testPollIntervalMs)
|
|
906
|
+
&& testPollIntervalMs > 0
|
|
907
|
+
? testPollIntervalMs
|
|
908
|
+
: 1000;
|
|
874
909
|
const deadline = job.operation === 'rollback'
|
|
875
910
|
? Date.now() + rollbackTimeout
|
|
876
911
|
: Number.POSITIVE_INFINITY;
|
|
@@ -879,7 +914,7 @@ async function waitForRelay(job, health) {
|
|
|
879
914
|
if (Date.now() >= deadline) {
|
|
880
915
|
throw new Error('mandatory relay health failed before the rollback deadline');
|
|
881
916
|
}
|
|
882
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
917
|
+
await new Promise(resolve => setTimeout(resolve, pollIntervalMs));
|
|
883
918
|
current = await waitForLocalHealth(job, job.targetSelection, current.identity, 2000);
|
|
884
919
|
}
|
|
885
920
|
}
|