@lobu/runtime-device 24.3.0 → 24.5.0
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/component.json +1 -1
- package/dist/dependencies.bun.lock +66 -68
- package/dist/verify.mjs +1 -1
- package/npm-shrinkwrap.json +165 -181
- package/package.json +2 -2
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +23 -5
- package/vendor/cli/dist/bundled-skills/lobu-connect/SKILL.md +6 -0
- package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +20 -13
- package/vendor/cli/dist/commands/_lib/apply/client.d.ts +48 -100
- package/vendor/cli/dist/commands/_lib/apply/client.js +76 -27
- package/vendor/cli/dist/commands/_lib/apply/deployment.js +1 -1
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +7 -11
- package/vendor/cli/dist/commands/_lib/apply/desired-state.js +9 -40
- package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +4 -4
- package/vendor/cli/dist/commands/_lib/apply/diff.js +37 -33
- package/vendor/cli/dist/commands/_lib/apply/map-config.d.ts +1 -1
- package/vendor/cli/dist/commands/_lib/apply/map-config.js +79 -92
- package/vendor/cli/dist/commands/_lib/apply/shared.d.ts +3 -6
- package/vendor/cli/dist/commands/_lib/apply/shared.js +8 -19
- package/vendor/cli/dist/commands/dev.js +21 -7
- package/vendor/cli/dist/commands/doctor.js +1 -8
- package/vendor/cli/dist/commands/init.js +4 -5
- package/vendor/cli/dist/config/define.d.ts +27 -28
- package/vendor/cli/dist/config/define.js +4 -5
- package/vendor/cli/dist/connectors/postgres.ts +77 -48
- package/vendor/cli/dist/internal/api-client.d.ts +2 -0
- package/vendor/cli/dist/internal/api-client.js +6 -1
- package/vendor/cli/dist/internal/node-binary.d.ts +22 -0
- package/vendor/cli/dist/internal/node-binary.js +73 -0
- package/vendor/cli/dist/internal/node-version.d.ts +7 -12
- package/vendor/cli/dist/internal/node-version.js +16 -20
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +2 -2
- package/vendor/cli/package.json +2 -2
- package/vendor/connector-sdk/dist/reaction-client-types.d.ts +8 -2
- package/vendor/connector-sdk/dist/reaction-sdk.d.ts +5 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/connector-worker/dist/daemon/acp-adapters/claude.js +1 -1
- package/vendor/connector-worker/dist/daemon/agent-turn.js +69 -3
- package/vendor/connector-worker/dist/daemon/client.d.ts +25 -8
- package/vendor/connector-worker/dist/daemon/client.js +32 -4
- package/vendor/connector-worker/dist/daemon/log.js +2 -1
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +7 -1
- package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +17 -0
- package/vendor/connector-worker/dist/daemon/poll-loop.js +101 -13
- package/vendor/connector-worker/dist/daemon/resource-admission.d.ts +19 -0
- package/vendor/connector-worker/dist/daemon/resource-admission.js +59 -0
- package/vendor/connector-worker/dist/daemon/resources.d.ts +20 -0
- package/vendor/connector-worker/dist/daemon/resources.js +163 -0
- package/vendor/connector-worker/dist/daemon/start.js +29 -4
- package/vendor/connector-worker/dist/daemon/worker.d.ts +2 -0
- package/vendor/connector-worker/dist/daemon/worker.js +4 -0
- package/vendor/connector-worker/dist/executor/select.d.ts +1 -1
- package/vendor/connector-worker/dist/executor/select.js +1 -1
- package/vendor/connector-worker/dist/isolate/ivm-types.d.ts +1 -2
- package/vendor/connector-worker/dist/isolate/ivm-types.js +1 -2
- package/vendor/connector-worker/dist/isolate/load.d.ts +10 -12
- package/vendor/connector-worker/dist/isolate/load.js +23 -27
- package/vendor/connector-worker/dist/self-check/index.d.ts +2 -2
- package/vendor/connector-worker/dist/self-check/index.js +2 -2
- package/vendor/connector-worker/package.json +3 -4
- package/vendor/core/dist/contracts/agent-settings.d.ts +61 -6
- package/vendor/core/dist/contracts/agent-settings.js +10 -7
- package/vendor/core/dist/contracts/tools/manage-agents.d.ts +473 -98
- package/vendor/core/dist/contracts/tools/manage-agents.js +111 -2
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +21 -18
- package/vendor/core/dist/contracts/tools/manage-automations.js +15 -15
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +45 -20
- package/vendor/core/dist/contracts/tools/manage-entity.js +17 -5
- package/vendor/core/dist/contracts/tools/manage-inference-providers.d.ts +445 -0
- package/vendor/core/dist/contracts/tools/manage-inference-providers.js +133 -0
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +4 -4
- package/vendor/core/dist/contracts/tools/manage-views.js +5 -3
- package/vendor/core/dist/contracts/worker/device-automation.js +4 -2
- package/vendor/core/dist/error-report.d.ts +73 -0
- package/vendor/core/dist/error-report.js +346 -0
- package/vendor/core/dist/index.d.ts +4 -1
- package/vendor/core/dist/index.js +7 -1
- package/vendor/core/dist/logger.js +15 -6
- package/vendor/core/dist/otel-fetch.d.ts +19 -0
- package/vendor/core/dist/otel-fetch.js +96 -0
- package/vendor/core/dist/otel.d.ts +22 -2
- package/vendor/core/dist/otel.js +95 -48
- package/vendor/core/dist/reserved.d.ts +1 -1
- package/vendor/core/dist/reserved.js +6 -4
- package/vendor/core/dist/tool-result.d.ts +8 -0
- package/vendor/core/dist/tool-result.js +61 -0
- package/vendor/core/dist/trace-context.d.ts +12 -0
- package/vendor/core/dist/trace-context.js +50 -0
- package/vendor/core/dist/utils/diagnostic-scrubber.js +1 -1
- package/vendor/core/dist/worker/auth.js +4 -0
- package/vendor/core/package.json +6 -1
- /package/vendor/cli/dist/vendor/ora/{.bun-tag-fde20e9a6df212fa → .bun-tag-77bb9b258a474a18} +0 -0
- /package/vendor/ora/{.bun-tag-fde20e9a6df212fa → .bun-tag-77bb9b258a474a18} +0 -0
- /package/vendor/postgres/{.bun-tag-22d644c2873790db → .bun-tag-c81dacd34e959a7a} +0 -0
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* polling, concurrency, and graceful-shutdown lifecycle. Run execution stays
|
|
6
6
|
* injected so the device build does not import fleet connector machinery.
|
|
7
7
|
*/
|
|
8
|
+
import { shutdownTracing } from '@lobu/core';
|
|
8
9
|
import { WORKER_POLL_MAX_WAIT_SECONDS } from '@lobu/core/contracts/worker/protocol';
|
|
9
10
|
import { WorkerHttpError, WorkerUpgradeRequiredError, } from './client.js';
|
|
10
11
|
import { log } from './log.js';
|
|
12
|
+
import { RESOURCE_ADMISSION_INTERVAL_MS } from './resource-admission.js';
|
|
11
13
|
/** Drain budget for a daemon nobody told how long it has (devices, local runs). */
|
|
12
14
|
const DEFAULT_SHUTDOWN_DRAIN_MS = 30_000;
|
|
13
15
|
/**
|
|
@@ -16,17 +18,22 @@ const DEFAULT_SHUTDOWN_DRAIN_MS = 30_000;
|
|
|
16
18
|
*/
|
|
17
19
|
const SHUTDOWN_EXIT_MARGIN_MS = 15_000;
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
21
|
+
* The pod's whole grace period after SIGTERM. A fleet pod is SIGKILLed
|
|
20
22
|
* `terminationGracePeriodSeconds` after SIGTERM; the chart passes that same
|
|
21
|
-
* value as `WORKER_SHUTDOWN_GRACE_SECONDS
|
|
22
|
-
*
|
|
23
|
+
* value as `WORKER_SHUTDOWN_GRACE_SECONDS`. Anything else keeps the fixed
|
|
24
|
+
* default drain plus the exit margin.
|
|
23
25
|
*/
|
|
24
|
-
function
|
|
26
|
+
function resolveWorkerShutdownGraceMs(env = process.env) {
|
|
25
27
|
const raw = env.WORKER_SHUTDOWN_GRACE_SECONDS?.trim();
|
|
26
28
|
const seconds = raw ? Number(raw) : Number.NaN;
|
|
27
|
-
if (!Number.isInteger(seconds) || seconds < 0)
|
|
28
|
-
return DEFAULT_SHUTDOWN_DRAIN_MS;
|
|
29
|
-
|
|
29
|
+
if (!Number.isInteger(seconds) || seconds < 0) {
|
|
30
|
+
return DEFAULT_SHUTDOWN_DRAIN_MS + SHUTDOWN_EXIT_MARGIN_MS;
|
|
31
|
+
}
|
|
32
|
+
return seconds * 1000;
|
|
33
|
+
}
|
|
34
|
+
/** How long SIGTERM waits for in-flight runs: the grace minus the exit margin. */
|
|
35
|
+
function resolveWorkerShutdownDrainMs(env = process.env) {
|
|
36
|
+
return Math.max(0, resolveWorkerShutdownGraceMs(env) - SHUTDOWN_EXIT_MARGIN_MS);
|
|
30
37
|
}
|
|
31
38
|
export function shouldHandleWorkerPollLoopStdinEof(options = {}) {
|
|
32
39
|
return options.stdinEof === true;
|
|
@@ -36,6 +43,8 @@ export class WorkerPollLoop {
|
|
|
36
43
|
pollIntervalMs;
|
|
37
44
|
maxIdleDelayMs;
|
|
38
45
|
maxConcurrentJobs;
|
|
46
|
+
maxConcurrentAgentTurns;
|
|
47
|
+
resourceAdmission;
|
|
39
48
|
execute;
|
|
40
49
|
beforeIdlePoll;
|
|
41
50
|
failClosedOnPollAuthError;
|
|
@@ -43,9 +52,12 @@ export class WorkerPollLoop {
|
|
|
43
52
|
running = false;
|
|
44
53
|
admittingJobs = true;
|
|
45
54
|
activeJobs = 0;
|
|
55
|
+
/** Runs charged to the agent-turn budget; only counted when it is set. */
|
|
56
|
+
activeAgentTurns = 0;
|
|
46
57
|
capacityVersion = 0;
|
|
47
58
|
wakePoll;
|
|
48
59
|
pendingPoll;
|
|
60
|
+
lastPollAt = -Infinity;
|
|
49
61
|
constructor(options) {
|
|
50
62
|
this.client = options.client;
|
|
51
63
|
this.pollIntervalMs = options.pollIntervalMs ?? 10000;
|
|
@@ -53,7 +65,11 @@ export class WorkerPollLoop {
|
|
|
53
65
|
? undefined
|
|
54
66
|
: Math.max(1, options.maxIdleDelayMs);
|
|
55
67
|
this.maxConcurrentJobs = Math.max(1, options.maxConcurrentJobs ?? 1);
|
|
68
|
+
this.maxConcurrentAgentTurns = options.maxConcurrentAgentTurns === undefined
|
|
69
|
+
? undefined
|
|
70
|
+
: Math.max(1, options.maxConcurrentAgentTurns);
|
|
56
71
|
this.execute = options.execute;
|
|
72
|
+
this.resourceAdmission = options.resourceAdmission;
|
|
57
73
|
this.beforeIdlePoll = options.beforeIdlePoll;
|
|
58
74
|
this.failClosedOnPollAuthError = options.failClosedOnPollAuthError === true;
|
|
59
75
|
this.onActiveJobsChange = options.onActiveJobsChange;
|
|
@@ -68,7 +84,9 @@ export class WorkerPollLoop {
|
|
|
68
84
|
}
|
|
69
85
|
if (!this.admittingJobs)
|
|
70
86
|
return;
|
|
71
|
-
log.info(
|
|
87
|
+
log.info(this.maxConcurrentAgentTurns === undefined
|
|
88
|
+
? `[daemon] Starting worker daemon (max concurrent jobs: ${this.maxConcurrentJobs})...`
|
|
89
|
+
: `[daemon] Starting worker daemon (max concurrent connector jobs: ${this.maxConcurrentJobs}, agent turns: ${this.maxConcurrentAgentTurns})...`);
|
|
72
90
|
this.running = true;
|
|
73
91
|
while (this.running) {
|
|
74
92
|
if (this.activeJobs === 0)
|
|
@@ -129,19 +147,55 @@ export class WorkerPollLoop {
|
|
|
129
147
|
log.debug('[daemon] All active jobs completed');
|
|
130
148
|
return true;
|
|
131
149
|
}
|
|
150
|
+
/** Free slots per budget, or undefined while every run shares one budget. */
|
|
151
|
+
laneCapacity() {
|
|
152
|
+
if (this.maxConcurrentAgentTurns === undefined)
|
|
153
|
+
return undefined;
|
|
154
|
+
return {
|
|
155
|
+
agentTurns: Math.max(0, this.maxConcurrentAgentTurns - this.activeAgentTurns),
|
|
156
|
+
connectorJobs: Math.max(0, this.maxConcurrentJobs - (this.activeJobs - this.activeAgentTurns)),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
freeSlots(lanes) {
|
|
160
|
+
return lanes
|
|
161
|
+
? lanes.agentTurns + lanes.connectorJobs
|
|
162
|
+
: Math.max(0, this.maxConcurrentJobs - this.activeJobs);
|
|
163
|
+
}
|
|
132
164
|
async pollAndExecute() {
|
|
133
165
|
if (!this.admittingJobs)
|
|
134
166
|
return undefined;
|
|
135
|
-
const
|
|
167
|
+
const budgetLanes = this.laneCapacity();
|
|
168
|
+
const resourceCapacity = this.resourceAdmission?.capacity();
|
|
169
|
+
// Recheck local pressure frequently without turning that cadence into
|
|
170
|
+
// gateway heartbeats. A recovered worker can claim immediately; a paused
|
|
171
|
+
// one still reports liveness at the normal polling interval.
|
|
172
|
+
if (resourceCapacity === 0 && performance.now() - this.lastPollAt < this.pollIntervalMs) {
|
|
173
|
+
return RESOURCE_ADMISSION_INTERVAL_MS;
|
|
174
|
+
}
|
|
175
|
+
const lanes = resourceCapacity === 0 && budgetLanes
|
|
176
|
+
? { agentTurns: 0, connectorJobs: 0 }
|
|
177
|
+
: budgetLanes;
|
|
178
|
+
const capacityAvailable = Math.min(this.freeSlots(lanes), resourceCapacity ?? Infinity);
|
|
136
179
|
const controller = new AbortController();
|
|
137
180
|
this.pendingPoll = controller;
|
|
138
181
|
let job;
|
|
139
182
|
try {
|
|
183
|
+
this.lastPollAt = performance.now();
|
|
140
184
|
job = await this.client.poll(capacityAvailable, {
|
|
141
185
|
// A worker with no free slot must not hold the request: it cannot take
|
|
142
|
-
// the run the hold would return.
|
|
143
|
-
|
|
186
|
+
// the run the hold would return. Nor may one whose turn budget is full:
|
|
187
|
+
// the hold cannot learn that a turn slot reopened, so a queued chat
|
|
188
|
+
// turn would wait out the whole hold. Polling without one re-polls as
|
|
189
|
+
// soon as any run finishes. A full connector budget still holds: a
|
|
190
|
+
// connector slot freed mid-hold is taken only when the hold returns,
|
|
191
|
+
// at most WORKER_POLL_MAX_WAIT_SECONDS later, which a minutes-long sync
|
|
192
|
+
// can bear; not holding would instead cost every chat turn the idle
|
|
193
|
+
// poll interval for as long as the connector slots stay busy.
|
|
194
|
+
waitSeconds: capacityAvailable > 0 && (lanes === undefined || lanes.agentTurns > 0)
|
|
195
|
+
? WORKER_POLL_MAX_WAIT_SECONDS
|
|
196
|
+
: 0,
|
|
144
197
|
signal: controller.signal,
|
|
198
|
+
...(lanes ? { lanes } : {}),
|
|
145
199
|
});
|
|
146
200
|
}
|
|
147
201
|
finally {
|
|
@@ -152,7 +206,10 @@ export class WorkerPollLoop {
|
|
|
152
206
|
return undefined;
|
|
153
207
|
const nextPoll = job.next_poll_seconds ?? 30;
|
|
154
208
|
log.debug(`[daemon] No runs available, next poll in ${nextPoll}s`);
|
|
155
|
-
|
|
209
|
+
const delay = Number.isFinite(nextPoll) && nextPoll >= 0 ? nextPoll * 1000 : 1000;
|
|
210
|
+
// Resource pressure can recover while every turn is still waiting on a
|
|
211
|
+
// provider. Recheck locally instead of sleeping through the server hint.
|
|
212
|
+
return resourceCapacity === 0 ? Math.min(delay, RESOURCE_ADMISSION_INTERVAL_MS) : delay;
|
|
156
213
|
}
|
|
157
214
|
// A zero-capacity response should be impossible: the server must not enter
|
|
158
215
|
// a claim lane when the worker truthfully reports no free slot. Do not
|
|
@@ -161,7 +218,21 @@ export class WorkerPollLoop {
|
|
|
161
218
|
log.info(`[daemon] Server returned run ${job.run_id} while worker is at capacity; leaving it untouched`);
|
|
162
219
|
return undefined;
|
|
163
220
|
}
|
|
221
|
+
// An agent turn takes a turn slot; everything else is connector work. The
|
|
222
|
+
// gateway gates turns on `agent_turn` and connector runs on compiled
|
|
223
|
+
// capacity, but an embedding backfill has no gate besides free capacity,
|
|
224
|
+
// so it can arrive while only turn slots are free. It then borrows a turn
|
|
225
|
+
// slot: total concurrency stays within both budgets, and backfills are few
|
|
226
|
+
// (one per organization, a handful per scheduler tick).
|
|
227
|
+
const chargedToTurns = lanes !== undefined && (job.run_type === 'agent_turn'
|
|
228
|
+
? lanes.agentTurns > 0
|
|
229
|
+
: lanes.connectorJobs === 0);
|
|
164
230
|
this.activeJobs++;
|
|
231
|
+
// Honour an admitted held claim even if pressure rose during the HTTP
|
|
232
|
+
// request: the server may already own its lease. Only future claims pause.
|
|
233
|
+
this.resourceAdmission?.started();
|
|
234
|
+
if (chargedToTurns)
|
|
235
|
+
this.activeAgentTurns++;
|
|
165
236
|
this.onActiveJobsChange?.(this.activeJobs);
|
|
166
237
|
Promise.resolve()
|
|
167
238
|
.then(() => this.execute(job))
|
|
@@ -170,13 +241,17 @@ export class WorkerPollLoop {
|
|
|
170
241
|
})
|
|
171
242
|
.finally(() => {
|
|
172
243
|
this.activeJobs--;
|
|
244
|
+
if (chargedToTurns)
|
|
245
|
+
this.activeAgentTurns--;
|
|
173
246
|
this.onActiveJobsChange?.(this.activeJobs);
|
|
174
247
|
this.capacityVersion++;
|
|
175
248
|
this.wakePoll?.(true);
|
|
176
249
|
});
|
|
177
250
|
// Fill remaining slots while the queue has work, then wait for capacity
|
|
178
251
|
// or the normal heartbeat instead of delaying every successful claim.
|
|
179
|
-
return this.
|
|
252
|
+
return this.resourceAdmission
|
|
253
|
+
? RESOURCE_ADMISSION_INTERVAL_MS
|
|
254
|
+
: this.freeSlots(this.laneCapacity()) > 0 ? 0 : undefined;
|
|
180
255
|
}
|
|
181
256
|
waitForNextPoll(ms, capacityVersion) {
|
|
182
257
|
if (!this.running ||
|
|
@@ -200,6 +275,7 @@ export class WorkerPollLoop {
|
|
|
200
275
|
}
|
|
201
276
|
export function createWorkerPollLoopShutdownHandler(loop, onShutdown = () => loop.stop(), exit = process.exit) {
|
|
202
277
|
const drainTimeoutMs = resolveWorkerShutdownDrainMs();
|
|
278
|
+
const shutdownGraceMs = resolveWorkerShutdownGraceMs();
|
|
203
279
|
let shuttingDown = false;
|
|
204
280
|
return async (signal) => {
|
|
205
281
|
if (shuttingDown) {
|
|
@@ -208,6 +284,7 @@ export function createWorkerPollLoopShutdownHandler(loop, onShutdown = () => loo
|
|
|
208
284
|
return;
|
|
209
285
|
}
|
|
210
286
|
shuttingDown = true;
|
|
287
|
+
const shutdownDeadline = Date.now() + shutdownGraceMs;
|
|
211
288
|
log.info(`\n[daemon] Received ${signal}, shutting down...`);
|
|
212
289
|
let shutdownHookSucceeded = true;
|
|
213
290
|
try {
|
|
@@ -221,6 +298,17 @@ export function createWorkerPollLoopShutdownHandler(loop, onShutdown = () => loo
|
|
|
221
298
|
const allDone = await loop.waitForActiveJobs(drainTimeoutMs);
|
|
222
299
|
if (!allDone)
|
|
223
300
|
log.info('[daemon] Forcing exit with active jobs still running');
|
|
301
|
+
// Exporters can still be waiting on a collector. Spend only the grace
|
|
302
|
+
// left after hooks/draining, cap telemetry at 5s, and retain 1s to exit.
|
|
303
|
+
const tracingTimeoutMs = Math.min(5_000, Math.max(0, shutdownDeadline - Date.now() - 1_000));
|
|
304
|
+
if (tracingTimeoutMs > 0) {
|
|
305
|
+
try {
|
|
306
|
+
await shutdownTracing(tracingTimeoutMs);
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
log.info('[daemon] Tracing shutdown failed:', error);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
224
312
|
exit(allDone && shutdownHookSucceeded ? 0 : 1);
|
|
225
313
|
};
|
|
226
314
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ResourceSample } from './resources.js';
|
|
2
|
+
/** Give a newly admitted isolate time to expose its startup cost. */
|
|
3
|
+
export declare const RESOURCE_ADMISSION_INTERVAL_MS = 500;
|
|
4
|
+
/**
|
|
5
|
+
* Local resource admission, underneath the configured per-kind ceilings.
|
|
6
|
+
* This owns no run state: the gateway still owns claims, fairness and leases.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ResourceAdmission {
|
|
9
|
+
private readonly sample;
|
|
10
|
+
private readonly now;
|
|
11
|
+
private previous?;
|
|
12
|
+
private nextStartAt;
|
|
13
|
+
private paused?;
|
|
14
|
+
constructor(sample?: () => ResourceSample | null, now?: () => number);
|
|
15
|
+
capacity(): number;
|
|
16
|
+
started(): void;
|
|
17
|
+
private transition;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=resource-admission.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { log } from './log.js';
|
|
2
|
+
import { createResourceSampler } from './resources.js';
|
|
3
|
+
/** Give a newly admitted isolate time to expose its startup cost. */
|
|
4
|
+
export const RESOURCE_ADMISSION_INTERVAL_MS = 500;
|
|
5
|
+
const MIB = 1024 * 1024;
|
|
6
|
+
/**
|
|
7
|
+
* Local resource admission, underneath the configured per-kind ceilings.
|
|
8
|
+
* This owns no run state: the gateway still owns claims, fairness and leases.
|
|
9
|
+
*/
|
|
10
|
+
export class ResourceAdmission {
|
|
11
|
+
sample;
|
|
12
|
+
now;
|
|
13
|
+
previous;
|
|
14
|
+
nextStartAt = 0;
|
|
15
|
+
paused;
|
|
16
|
+
constructor(sample = createResourceSampler(), now = () => performance.now()) {
|
|
17
|
+
this.sample = sample;
|
|
18
|
+
this.now = now;
|
|
19
|
+
}
|
|
20
|
+
capacity() {
|
|
21
|
+
const at = this.now();
|
|
22
|
+
if (at < this.nextStartAt)
|
|
23
|
+
return 0;
|
|
24
|
+
if (this.previous && at - this.previous.at < RESOURCE_ADMISSION_INTERVAL_MS)
|
|
25
|
+
return this.paused ? 0 : 1;
|
|
26
|
+
const current = this.sample();
|
|
27
|
+
if (!current || current.memory.length === 0 || current.memory.some(m => !Number.isFinite(m.usedBytes) || m.usedBytes < 0 || !Number.isFinite(m.limitBytes) || m.limitBytes <= 0)) {
|
|
28
|
+
this.transition('sample');
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
const memoryTarget = this.paused === 'memory' ? 0.7 : 0.8;
|
|
32
|
+
// Keep room for one more large isolate. On small installations reserve
|
|
33
|
+
// 20% instead of requiring half a GiB before admitting the first run.
|
|
34
|
+
const memoryPressure = current.memory.some(m => m.usedBytes + Math.min(512 * MIB, m.limitBytes * 0.2) > m.limitBytes * memoryTarget);
|
|
35
|
+
let cpuLoad = 0;
|
|
36
|
+
if (this.previous && at > this.previous.at) {
|
|
37
|
+
const elapsedMicros = (at - this.previous.at) * 1000;
|
|
38
|
+
for (const c of current.cpu) {
|
|
39
|
+
const before = this.previous.sample.cpu.find(p => p.key === c.key);
|
|
40
|
+
if (before && c.cores > 0)
|
|
41
|
+
cpuLoad = Math.max(cpuLoad, (c.usageMicros - before.usageMicros) / elapsedMicros / c.cores);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
this.previous = { sample: current, at };
|
|
45
|
+
const cpuPressure = cpuLoad > (this.paused === 'cpu' ? 0.6 : 0.8);
|
|
46
|
+
this.transition(memoryPressure ? 'memory' : cpuPressure ? 'cpu' : undefined, { memory: current.memory, cpuLoad });
|
|
47
|
+
return this.paused ? 0 : 1;
|
|
48
|
+
}
|
|
49
|
+
started() {
|
|
50
|
+
this.nextStartAt = this.now() + RESOURCE_ADMISSION_INTERVAL_MS;
|
|
51
|
+
}
|
|
52
|
+
transition(reason, resources) {
|
|
53
|
+
if (reason === this.paused)
|
|
54
|
+
return;
|
|
55
|
+
this.paused = reason;
|
|
56
|
+
log.info(`[daemon] Resource admission ${reason ? `paused (${reason})` : 'resumed'}`, resources);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=resource-admission.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ResourceSample {
|
|
2
|
+
memory: Array<{
|
|
3
|
+
usedBytes: number;
|
|
4
|
+
limitBytes: number;
|
|
5
|
+
}>;
|
|
6
|
+
cpu: Array<{
|
|
7
|
+
key: string;
|
|
8
|
+
usageMicros: number;
|
|
9
|
+
cores: number;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
type Read = (path: string) => string;
|
|
13
|
+
declare function hostMemory(): {
|
|
14
|
+
limitBytes: number;
|
|
15
|
+
availableBytes: number;
|
|
16
|
+
};
|
|
17
|
+
/** Container-wide counters include isolate threads and spawned tool children. */
|
|
18
|
+
export declare function createResourceSampler(read?: Read, platform?: string, readHostMemory?: typeof hostMemory): () => ResourceSample | null;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { availableParallelism, freemem, totalmem } from 'node:os';
|
|
3
|
+
import { dirname, join, relative } from 'node:path';
|
|
4
|
+
function hostMemory() {
|
|
5
|
+
const runtime = process;
|
|
6
|
+
// Available memory includes reclaimable host cache; free memory alone can
|
|
7
|
+
// leave an otherwise healthy bare-metal worker permanently paused.
|
|
8
|
+
return { limitBytes: totalmem(), availableBytes: runtime.availableMemory?.() ?? freemem() };
|
|
9
|
+
}
|
|
10
|
+
function optional(read, path) {
|
|
11
|
+
try {
|
|
12
|
+
return read(path).trim();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function positive(value) {
|
|
19
|
+
const n = value ? Number(value) : Number.NaN;
|
|
20
|
+
return Number.isFinite(n) && n > 0 ? n : undefined;
|
|
21
|
+
}
|
|
22
|
+
function unescapePath(value) {
|
|
23
|
+
return value.replace(/\\([0-7]{3})/g, (_, octal) => String.fromCharCode(Number.parseInt(octal, 8)));
|
|
24
|
+
}
|
|
25
|
+
/** Resolve both host cgroup paths and a container's cgroup-namespace root. */
|
|
26
|
+
function groups(read) {
|
|
27
|
+
const membership = optional(read, '/proc/self/cgroup') ?? '';
|
|
28
|
+
const mounts = optional(read, '/proc/self/mountinfo') ?? '';
|
|
29
|
+
const result = {};
|
|
30
|
+
for (const line of mounts.split('\n')) {
|
|
31
|
+
const [left, right] = line.split(' - ');
|
|
32
|
+
if (!left || !right)
|
|
33
|
+
continue;
|
|
34
|
+
const fields = left.split(' ');
|
|
35
|
+
const [kind, , options = ''] = right.split(' ');
|
|
36
|
+
if (kind !== 'cgroup' && kind !== 'cgroup2')
|
|
37
|
+
continue;
|
|
38
|
+
const root = unescapePath(fields[4] ?? '');
|
|
39
|
+
const mountedFrom = unescapePath(fields[3] ?? '/');
|
|
40
|
+
if (!root.startsWith('/'))
|
|
41
|
+
continue;
|
|
42
|
+
for (const controller of ['memory', 'cpu', 'cpuacct']) {
|
|
43
|
+
if (kind === 'cgroup' && !options.split(',').includes(controller))
|
|
44
|
+
continue;
|
|
45
|
+
// On hybrid hosts a controller belongs to only one hierarchy. A v2
|
|
46
|
+
// mount must not hide its v1 membership, regardless of mount order.
|
|
47
|
+
const v1Entry = membership.split('\n').find(row => row.split(':')[1]?.split(',').includes(controller));
|
|
48
|
+
if (kind === 'cgroup2' && v1Entry)
|
|
49
|
+
continue;
|
|
50
|
+
const entry = membership.split('\n').find(row => {
|
|
51
|
+
const parts = row.split(':');
|
|
52
|
+
return kind === 'cgroup2' ? parts[0] === '0' && parts[1] === '' : parts[1]?.split(',').includes(controller);
|
|
53
|
+
});
|
|
54
|
+
if (!entry)
|
|
55
|
+
continue;
|
|
56
|
+
const member = entry.slice(entry.indexOf(':', entry.indexOf(':') + 1) + 1);
|
|
57
|
+
const suffix = mountedFrom === '/' ? member.slice(1)
|
|
58
|
+
: member === mountedFrom ? ''
|
|
59
|
+
: member.startsWith(`${mountedFrom}/`) ? member.slice(mountedFrom.length + 1)
|
|
60
|
+
: member === '/' ? '' : member.slice(1);
|
|
61
|
+
const candidate = join(root, suffix);
|
|
62
|
+
// A namespace may report a path outside the visible mount. In that
|
|
63
|
+
// case the mounted root is the only scope we can measure faithfully.
|
|
64
|
+
const leaf = relative(root, candidate).startsWith('..') ? root : candidate;
|
|
65
|
+
result[controller] = { root, leaf, v2: kind === 'cgroup2' };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
function ancestors(group) {
|
|
71
|
+
const paths = [group.leaf];
|
|
72
|
+
while (paths[paths.length - 1] !== group.root) {
|
|
73
|
+
const parent = dirname(paths[paths.length - 1]);
|
|
74
|
+
if (parent === paths[paths.length - 1])
|
|
75
|
+
break;
|
|
76
|
+
paths.push(parent);
|
|
77
|
+
}
|
|
78
|
+
return paths;
|
|
79
|
+
}
|
|
80
|
+
/** Container-wide counters include isolate threads and spawned tool children. */
|
|
81
|
+
export function createResourceSampler(read = path => readFileSync(path, 'utf8'), platform = process.platform, readHostMemory = hostMemory) {
|
|
82
|
+
const discovered = platform === 'linux' ? groups(read) : {};
|
|
83
|
+
return () => {
|
|
84
|
+
const memory = [];
|
|
85
|
+
const cpu = [];
|
|
86
|
+
const host = readHostMemory();
|
|
87
|
+
if (!Number.isFinite(host.limitBytes) || host.limitBytes <= 0 || !Number.isFinite(host.availableBytes) || host.availableBytes < 0)
|
|
88
|
+
return null;
|
|
89
|
+
if (discovered.memory) {
|
|
90
|
+
for (const path of ancestors(discovered.memory)) {
|
|
91
|
+
let raw;
|
|
92
|
+
try {
|
|
93
|
+
raw = read(join(path, discovered.memory.v2 ? 'memory.max' : 'memory.limit_in_bytes')).trim();
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (error?.code !== 'ENOENT')
|
|
97
|
+
return null;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const limit = positive(raw);
|
|
101
|
+
if (raw !== 'max' && limit === undefined)
|
|
102
|
+
return null;
|
|
103
|
+
// v2 `max` and v1's huge unlimited sentinel use the host bound.
|
|
104
|
+
if (!limit || limit >= host.limitBytes)
|
|
105
|
+
continue;
|
|
106
|
+
const usage = optional(read, join(path, discovered.memory.v2 ? 'memory.current' : 'memory.usage_in_bytes'));
|
|
107
|
+
const used = usage === undefined ? Number.NaN : Number(usage);
|
|
108
|
+
if (!Number.isFinite(used) || used < 0)
|
|
109
|
+
return null;
|
|
110
|
+
const stats = optional(read, join(path, 'memory.stat')) ?? '';
|
|
111
|
+
const inactiveKey = discovered.memory.v2 ? 'inactive_file' : 'total_inactive_file';
|
|
112
|
+
const inactive = Number(stats.match(new RegExp(`^${inactiveKey} (\\d+)$`, 'm'))?.[1] ?? 0);
|
|
113
|
+
// Match cAdvisor's working set: inactive file cache is reclaimable.
|
|
114
|
+
// Keeping it in usage can permanently pause a worker after a build or
|
|
115
|
+
// large source read, even when resident job memory is small.
|
|
116
|
+
memory.push({ usedBytes: Math.max(0, used - inactive), limitBytes: limit });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// The unified root (or a hierarchy without the memory controller) has
|
|
120
|
+
// no limit file. Only a discovered bound requires a readable usage counter.
|
|
121
|
+
if (memory.length === 0)
|
|
122
|
+
memory.push({ usedBytes: Math.max(0, host.limitBytes - host.availableBytes), limitBytes: host.limitBytes });
|
|
123
|
+
if (discovered.cpu) {
|
|
124
|
+
for (const path of ancestors(discovered.cpu)) {
|
|
125
|
+
let quota;
|
|
126
|
+
let period;
|
|
127
|
+
if (discovered.cpu.v2) {
|
|
128
|
+
const parts = optional(read, join(path, 'cpu.max'))?.split(/\s+/);
|
|
129
|
+
quota = positive(parts?.[0]);
|
|
130
|
+
period = positive(parts?.[1]);
|
|
131
|
+
if (parts && (parts.length !== 2 || !period || (parts[0] !== 'max' && !quota)))
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const raw = optional(read, join(path, 'cpu.cfs_quota_us'));
|
|
136
|
+
quota = positive(raw);
|
|
137
|
+
period = positive(optional(read, join(path, 'cpu.cfs_period_us')));
|
|
138
|
+
if (raw !== undefined && (!period || (raw !== '-1' && !quota)))
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
if (!quota || !period)
|
|
142
|
+
continue;
|
|
143
|
+
const accounting = discovered.cpuacct;
|
|
144
|
+
const usagePath = accounting ? join(accounting.leaf, relative(discovered.cpu.leaf, path)) : path;
|
|
145
|
+
const raw = discovered.cpu.v2
|
|
146
|
+
? optional(read, join(path, 'cpu.stat'))?.match(/^usage_usec (\d+)$/m)?.[1]
|
|
147
|
+
: optional(read, join(usagePath, 'cpuacct.usage'));
|
|
148
|
+
const used = raw === undefined ? Number.NaN : Number(raw);
|
|
149
|
+
if (!Number.isFinite(used) || used < 0)
|
|
150
|
+
return null;
|
|
151
|
+
cpu.push({ key: path, usageMicros: discovered.cpu.v2 ? used : used / 1000, cores: Math.min(availableParallelism(), quota / period) });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// With no quota, process CPU still includes all isolated-vm threads. On
|
|
155
|
+
// devices this sampler is unused; the existing device budget is preserved.
|
|
156
|
+
if (cpu.length === 0) {
|
|
157
|
+
const usage = process.cpuUsage();
|
|
158
|
+
cpu.push({ key: 'process', usageMicros: usage.user + usage.system, cores: availableParallelism() });
|
|
159
|
+
}
|
|
160
|
+
return { memory, cpu };
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -45,14 +45,37 @@ export function resolveDaemonLaunchContext(opts, env = process.env, sessionsDir)
|
|
|
45
45
|
interactiveSession: detected,
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
+
function parseSlotCount(raw) {
|
|
49
|
+
const configured = raw ? Math.max(1, Number.parseInt(raw, 10)) : undefined;
|
|
50
|
+
return configured !== undefined && Number.isFinite(configured) ? configured : undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A device's one shared budget, or a fleet worker's connector-work budget
|
|
54
|
+
* (syncs, actions, auth, embedding backfills).
|
|
55
|
+
*/
|
|
48
56
|
function resolveDaemonMaxConcurrentJobs(platform, env = process.env, hostThreads) {
|
|
49
|
-
const configured = env.WORKER_MAX_CONCURRENT_JOBS
|
|
50
|
-
|
|
51
|
-
: undefined;
|
|
52
|
-
if (configured !== undefined && Number.isFinite(configured))
|
|
57
|
+
const configured = parseSlotCount(env.WORKER_MAX_CONCURRENT_JOBS);
|
|
58
|
+
if (configured !== undefined)
|
|
53
59
|
return configured;
|
|
54
60
|
return platform ? defaultDeviceMaxConcurrentJobs(hostThreads) : undefined;
|
|
55
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Agent-turn slots for an unconfigured fleet worker. A turn mostly waits on
|
|
64
|
+
* the model provider; the worst measured one (4 MB history, the cap) peaked at
|
|
65
|
+
* 133 MB worker RSS, so four stay near half a gigabyte beside the connector
|
|
66
|
+
* slot. The Helm chart sizes its own value from the pod's memory.
|
|
67
|
+
*/
|
|
68
|
+
const DEFAULT_FLEET_MAX_CONCURRENT_AGENT_TURNS = 4;
|
|
69
|
+
/**
|
|
70
|
+
* A fleet worker budgets agent turns apart from connector work.
|
|
71
|
+
* Devices never run agent turns and keep their one shared budget.
|
|
72
|
+
*/
|
|
73
|
+
function resolveDaemonMaxConcurrentAgentTurns(platform, env = process.env) {
|
|
74
|
+
if (platform)
|
|
75
|
+
return undefined;
|
|
76
|
+
return parseSlotCount(env.WORKER_MAX_CONCURRENT_AGENT_TURNS)
|
|
77
|
+
?? DEFAULT_FLEET_MAX_CONCURRENT_AGENT_TURNS;
|
|
78
|
+
}
|
|
56
79
|
/**
|
|
57
80
|
* Validate the options and boot the daemon. Throws a user-facing `Error` on
|
|
58
81
|
* bad input; the caller prints it and exits non-zero.
|
|
@@ -136,6 +159,7 @@ export async function startDaemonCommand(opts) {
|
|
|
136
159
|
log.info(`[cli] Starting worker daemon (ID: ${workerId}, API: ${opts.apiUrl})`);
|
|
137
160
|
const env = buildConnectorWorkerEnv();
|
|
138
161
|
const maxConcurrentJobs = resolveDaemonMaxConcurrentJobs(platform);
|
|
162
|
+
const maxConcurrentAgentTurns = resolveDaemonMaxConcurrentAgentTurns(platform);
|
|
139
163
|
if (platform) {
|
|
140
164
|
log.info(`[cli] device mode: platform=${platform} capabilities=${capabilities.join(',') || '(none)'} max_concurrent_jobs=${maxConcurrentJobs}`);
|
|
141
165
|
if (opts.activeOrg) {
|
|
@@ -156,6 +180,7 @@ export async function startDaemonCommand(opts) {
|
|
|
156
180
|
...(label ? { label } : {}),
|
|
157
181
|
...(platform ? { manifests: DEVICE_MANIFESTS_BY_PLATFORM[platform] ?? [] } : {}),
|
|
158
182
|
...(maxConcurrentJobs ? { maxConcurrentJobs } : {}),
|
|
183
|
+
...(maxConcurrentAgentTurns ? { maxConcurrentAgentTurns } : {}),
|
|
159
184
|
backendCapacity,
|
|
160
185
|
...(opts.workerCredentialMaintenance
|
|
161
186
|
? { workerCredentialMaintenance: opts.workerCredentialMaintenance }
|
|
@@ -14,6 +14,8 @@ export interface DaemonConfig {
|
|
|
14
14
|
capabilities?: WorkerCapabilities;
|
|
15
15
|
pollIntervalMs?: number;
|
|
16
16
|
maxConcurrentJobs?: number;
|
|
17
|
+
/** Separate agent-turn budget; see `WorkerPollLoopOptions`. */
|
|
18
|
+
maxConcurrentAgentTurns?: number;
|
|
17
19
|
executor?: Partial<ExecutorConfig>;
|
|
18
20
|
version?: string;
|
|
19
21
|
/** Set only for a device worker; cloud-fleet daemons leave this undefined. */
|
|
@@ -7,6 +7,7 @@ import { WorkerClient } from './client.js';
|
|
|
7
7
|
import { executeRun } from './executor.js';
|
|
8
8
|
import { attachedInteractiveSession, attachInteractiveSession, } from './interactive-session.js';
|
|
9
9
|
import { installWorkerPollLoopSignals, WorkerPollLoop } from './poll-loop.js';
|
|
10
|
+
import { ResourceAdmission } from './resource-admission.js';
|
|
10
11
|
const DEFAULT_CAPABILITIES = {};
|
|
11
12
|
const DEFAULT_EXECUTOR_TIMEOUT_MS = 600000;
|
|
12
13
|
/**
|
|
@@ -56,6 +57,9 @@ export class WorkerDaemon {
|
|
|
56
57
|
client: this.client,
|
|
57
58
|
pollIntervalMs: daemonConfig.pollIntervalMs,
|
|
58
59
|
maxConcurrentJobs: daemonConfig.maxConcurrentJobs,
|
|
60
|
+
maxConcurrentAgentTurns: daemonConfig.maxConcurrentAgentTurns,
|
|
61
|
+
resourceAdmission: !daemonConfig.platform && daemonConfig.maxConcurrentAgentTurns !== undefined
|
|
62
|
+
? new ResourceAdmission() : undefined,
|
|
59
63
|
execute: (job) => executeRun(this.client, job, this.env, this.config.executor),
|
|
60
64
|
...(credentialMaintenance
|
|
61
65
|
? {
|
|
@@ -26,7 +26,7 @@ export interface ExecutorSelection {
|
|
|
26
26
|
* Build the executor for a job. There is exactly one: connector code runs in a
|
|
27
27
|
* hardened V8 isolate, which IS the security boundary for organization-supplied
|
|
28
28
|
* code. Nothing about the job selects it, so a host that cannot load
|
|
29
|
-
* `isolated-vm` (Bun, Node
|
|
29
|
+
* `isolated-vm` (Bun, a non-26 Node, or a failed native build) rejects with
|
|
30
30
|
* `IsolateRuntimeUnavailableError` rather than falling back to anything.
|
|
31
31
|
*/
|
|
32
32
|
export declare function selectExecutor(selection?: ExecutorSelection): Promise<SyncExecutor>;
|
|
@@ -7,7 +7,7 @@ import { IsolateExecutor, IsolateRuntimeUnavailableError } from './isolate.js';
|
|
|
7
7
|
* Build the executor for a job. There is exactly one: connector code runs in a
|
|
8
8
|
* hardened V8 isolate, which IS the security boundary for organization-supplied
|
|
9
9
|
* code. Nothing about the job selects it, so a host that cannot load
|
|
10
|
-
* `isolated-vm` (Bun, Node
|
|
10
|
+
* `isolated-vm` (Bun, a non-26 Node, or a failed native build) rejects with
|
|
11
11
|
* `IsolateRuntimeUnavailableError` rather than falling back to anything.
|
|
12
12
|
*/
|
|
13
13
|
export async function selectExecutor(selection = {}) {
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Kept separate from the module's own typings so no public worker type
|
|
5
5
|
* depends on `isolated-vm` being installed: `loadIsolatedVm()` narrows the
|
|
6
|
-
* dynamically imported module to this shape at the load boundary
|
|
7
|
-
* `isolated-vm@6` and `isolated-vm@7` satisfy it.
|
|
6
|
+
* dynamically imported module to this shape at the load boundary.
|
|
8
7
|
*/
|
|
9
8
|
export interface IvmReferenceApplyOptions {
|
|
10
9
|
timeout?: number;
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Kept separate from the module's own typings so no public worker type
|
|
5
5
|
* depends on `isolated-vm` being installed: `loadIsolatedVm()` narrows the
|
|
6
|
-
* dynamically imported module to this shape at the load boundary
|
|
7
|
-
* `isolated-vm@6` and `isolated-vm@7` satisfy it.
|
|
6
|
+
* dynamically imported module to this shape at the load boundary.
|
|
8
7
|
*/
|
|
9
8
|
export {};
|
|
10
9
|
//# sourceMappingURL=ivm-types.js.map
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Load `isolated-vm` for the
|
|
2
|
+
* Load `isolated-vm` for the worker's Node runtime.
|
|
3
3
|
*
|
|
4
|
-
* The native addon is ABI-bound
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `packages/server/src/sandbox/run-script.ts`; the gateway adopting this
|
|
11
|
-
* module is a follow-up.
|
|
4
|
+
* The native addon is ABI-bound to the Node major: Lobu ships one
|
|
5
|
+
* `isolated-vm@7` build and runs it on Node 26 only. Bun cannot dlopen a V8
|
|
6
|
+
* addon, and Node majors other than 26 have no matching ABI build, so both
|
|
7
|
+
* return `null` and the executor selector fails an `isolate` run instead of
|
|
8
|
+
* forking a child for it. Mirrors
|
|
9
|
+
* `packages/server/src/sandbox/run-script.ts`.
|
|
12
10
|
*/
|
|
13
11
|
import type { IsolatedVm } from './ivm-types.js';
|
|
14
12
|
/**
|
|
15
|
-
* Why this host cannot run an isolate, or `null` when
|
|
16
|
-
*
|
|
17
|
-
* platform) is reported by `loadIsolatedVm()` returning null; this only
|
|
13
|
+
* Why this host cannot run an isolate, or `null` when it is the supported
|
|
14
|
+
* Node 26 line. A load failure on an eligible host (native build skipped on
|
|
15
|
+
* this platform) is reported by `loadIsolatedVm()` returning null; this only
|
|
18
16
|
* classifies the runtime.
|
|
19
17
|
*/
|
|
20
18
|
export declare function isolatedVmUnavailableReason(): string | null;
|