@lobu/runtime-device 24.4.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 +45 -47
- package/dist/verify.mjs +1 -1
- package/npm-shrinkwrap.json +42 -58
- package/package.json +2 -2
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +8 -2
- 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 +21 -10
- package/vendor/connector-worker/dist/daemon/client.d.ts +25 -8
- package/vendor/connector-worker/dist/daemon/client.js +25 -3
- 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 +75 -6
- 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-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 +3 -1
- package/vendor/core/dist/index.js +4 -1
- package/vendor/core/dist/logger.js +7 -4
- 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 +9 -0
- package/vendor/core/dist/otel.js +28 -7
- 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/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
|
@@ -166,63 +166,91 @@ function escapeLike(term: string): string {
|
|
|
166
166
|
return term.replace(/[\\%_]/g, (c) => `\\${c}`);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
/** Opening `$$` / `$tag$` of a dollar-quoted string, matched at `lastIndex`. */
|
|
170
|
+
const DOLLAR_QUOTE_RE = /\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/y;
|
|
171
|
+
|
|
169
172
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* `'
|
|
173
|
-
*
|
|
174
|
-
*
|
|
173
|
+
* Blank out string literals, quoted identifiers, dollar-quoted strings and
|
|
174
|
+
* comments (same length, so positions survive) so the structural checks only
|
|
175
|
+
* see executable tokens — a `';'`, `':name'`, `'$1'` or `"limit"` inside a
|
|
176
|
+
* literal must never trip them. Unterminated literals/comments mask to the end;
|
|
177
|
+
* Postgres reports those itself.
|
|
175
178
|
*/
|
|
176
|
-
function
|
|
179
|
+
function executableSql(sql: string): string {
|
|
177
180
|
const n = sql.length;
|
|
178
|
-
let
|
|
181
|
+
let result = '';
|
|
179
182
|
let i = 0;
|
|
180
183
|
while (i < n) {
|
|
184
|
+
const start = i;
|
|
181
185
|
const c = sql[i];
|
|
182
|
-
if (c === "'") {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (c === '"') {
|
|
189
|
-
i++;
|
|
190
|
-
while (i < n && sql[i] !== '"') i++;
|
|
186
|
+
if (c === "'" || c === '"') {
|
|
187
|
+
// E'…' strings escape with backslash; plain ones only double the quote.
|
|
188
|
+
const backslashEscapes =
|
|
189
|
+
c === "'" &&
|
|
190
|
+
/[eE]/.test(sql[i - 1] ?? '') &&
|
|
191
|
+
!/[A-Za-z0-9_$]/.test(sql[i - 2] ?? '');
|
|
191
192
|
i++;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
while (i < n) {
|
|
194
|
+
if (backslashEscapes && sql[i] === '\\') {
|
|
195
|
+
i += 2;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (sql[i++] === c) {
|
|
199
|
+
if (sql[i] !== c) break;
|
|
200
|
+
i++;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
} else if (c === '$' && !/[A-Za-z0-9_$]/.test(sql[i - 1] ?? '')) {
|
|
204
|
+
DOLLAR_QUOTE_RE.lastIndex = i;
|
|
205
|
+
const delimiter = DOLLAR_QUOTE_RE.exec(sql)?.[0];
|
|
206
|
+
if (!delimiter) {
|
|
207
|
+
result += c;
|
|
208
|
+
i++;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
const end = sql.indexOf(delimiter, i + delimiter.length);
|
|
212
|
+
i = end < 0 ? n : end + delimiter.length;
|
|
213
|
+
} else if (c === '-' && sql[i + 1] === '-') {
|
|
196
214
|
while (i < n && sql[i] !== '\n') i++;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (c === '/' && sql[i + 1] === '*') {
|
|
215
|
+
} else if (c === '/' && sql[i + 1] === '*') {
|
|
216
|
+
let depth = 1;
|
|
200
217
|
i += 2;
|
|
201
|
-
while (i < n &&
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
218
|
+
while (i < n && depth > 0) {
|
|
219
|
+
if (sql[i] === '/' && sql[i + 1] === '*') {
|
|
220
|
+
depth++;
|
|
221
|
+
i += 2;
|
|
222
|
+
} else if (sql[i] === '*' && sql[i + 1] === '/') {
|
|
223
|
+
depth--;
|
|
224
|
+
i += 2;
|
|
225
|
+
} else {
|
|
226
|
+
i++;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
result += c;
|
|
212
231
|
i++;
|
|
213
232
|
continue;
|
|
214
233
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
234
|
+
result += ' '.repeat(Math.min(i, n) - start);
|
|
235
|
+
}
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* True if `sql` (already masked by executableSql) has a LIMIT/OFFSET keyword
|
|
241
|
+
* at paren-depth 0. An inner LIMIT inside a subquery sits at depth > 0 and is
|
|
242
|
+
* allowed.
|
|
243
|
+
*/
|
|
244
|
+
function hasTopLevelLimitOrOffset(sql: string): boolean {
|
|
245
|
+
let depth = 0;
|
|
246
|
+
for (const [token] of sql.matchAll(/[A-Za-z_][A-Za-z0-9_$]*|[()]/g)) {
|
|
247
|
+
if (token === '(') {
|
|
248
|
+
depth++;
|
|
249
|
+
} else if (token === ')') {
|
|
250
|
+
depth = Math.max(0, depth - 1);
|
|
251
|
+
} else if (depth === 0 && /^(limit|offset)$/i.test(token)) {
|
|
252
|
+
return true;
|
|
224
253
|
}
|
|
225
|
-
i++;
|
|
226
254
|
}
|
|
227
255
|
return false;
|
|
228
256
|
}
|
|
@@ -253,18 +281,19 @@ function queryValidationError(message: string) {
|
|
|
253
281
|
function validateReadOnlySelect(raw: string): string {
|
|
254
282
|
const stripped = raw.trim().replace(/;\s*$/, '');
|
|
255
283
|
if (!stripped) throw queryValidationError('query is empty');
|
|
256
|
-
|
|
284
|
+
const executable = executableSql(stripped);
|
|
285
|
+
if (executable.includes(';')) {
|
|
257
286
|
throw queryValidationError('query must be a single statement (no embedded ";").');
|
|
258
287
|
}
|
|
259
|
-
if (/\$\d/.test(
|
|
288
|
+
if (/\$\d/.test(executable) || /(^|[^:]):[A-Za-z_]/.test(executable)) {
|
|
260
289
|
throw queryValidationError('query must not contain bind parameters ($1, :name).');
|
|
261
290
|
}
|
|
262
291
|
// Allow a leading "(" for "(SELECT …) UNION …" / parenthesized selects.
|
|
263
|
-
const head =
|
|
292
|
+
const head = executable.replace(/^\s*\(+\s*/, '').trimStart();
|
|
264
293
|
if (!/^(select|with)\b/i.test(head)) {
|
|
265
294
|
throw queryValidationError('query must be a single read-only SELECT (or WITH … SELECT).');
|
|
266
295
|
}
|
|
267
|
-
if (hasTopLevelLimitOrOffset(
|
|
296
|
+
if (hasTopLevelLimitOrOffset(executable)) {
|
|
268
297
|
throw queryValidationError(
|
|
269
298
|
'query must not include a top-level LIMIT/OFFSET — the connector adds pagination automatically (an inner LIMIT inside a subquery is fine).',
|
|
270
299
|
);
|
|
@@ -20,6 +20,7 @@ interface OrganizationInfo {
|
|
|
20
20
|
/** HTTP verbs the CLI's REST clients issue. */
|
|
21
21
|
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
22
22
|
export interface RequestWithStatusOptions {
|
|
23
|
+
headers?: Record<string, string>;
|
|
23
24
|
okStatuses?: number[];
|
|
24
25
|
/** Send `Accept: application/json` (default). Off matches the apply client. */
|
|
25
26
|
sendAccept?: boolean;
|
|
@@ -47,6 +48,7 @@ export declare class ApiClient {
|
|
|
47
48
|
requestWithStatus<T>(method: HttpMethod, path: string, body?: unknown, options?: RequestWithStatusOptions): Promise<{
|
|
48
49
|
status: number;
|
|
49
50
|
body: T;
|
|
51
|
+
headers: Headers;
|
|
50
52
|
}>;
|
|
51
53
|
request<T>(method: HttpMethod, path: string, body?: unknown, options?: {
|
|
52
54
|
okStatuses?: number[];
|
|
@@ -25,6 +25,7 @@ export class ApiClient {
|
|
|
25
25
|
const url = path.startsWith("http") ? path : `${this.apiBaseUrl}${path}`;
|
|
26
26
|
const headers = {
|
|
27
27
|
...this.extraHeaders,
|
|
28
|
+
...options.headers,
|
|
28
29
|
Authorization: `Bearer ${this.token}`,
|
|
29
30
|
};
|
|
30
31
|
if (options.sendAccept !== false)
|
|
@@ -48,7 +49,11 @@ export class ApiClient {
|
|
|
48
49
|
const { message, code } = extractApiError(parsed, response.status, response.statusText);
|
|
49
50
|
throw new ApiError(`${method} ${path} failed: ${message}`, response.status, code);
|
|
50
51
|
}
|
|
51
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
status: response.status,
|
|
54
|
+
body: parsed,
|
|
55
|
+
headers: response.headers,
|
|
56
|
+
};
|
|
52
57
|
}
|
|
53
58
|
async request(method, path, body, options = {}) {
|
|
54
59
|
const { body: parsed } = await this.requestWithStatus(method, path, body, options);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface ResolveNode26Deps {
|
|
2
|
+
/** The CLI process's own executable — Bun when the CLI was launched via Bun. */
|
|
3
|
+
execPath: string;
|
|
4
|
+
versions: {
|
|
5
|
+
node?: string;
|
|
6
|
+
bun?: string;
|
|
7
|
+
};
|
|
8
|
+
platform: NodeJS.Platform;
|
|
9
|
+
env: NodeJS.ProcessEnv;
|
|
10
|
+
run: (command: string, args: string[]) => string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the Node 26 binary that must host the backend.
|
|
14
|
+
*
|
|
15
|
+
* `lobu run` may itself be launched through Bun (for example `bunx @lobu/cli`),
|
|
16
|
+
* where `process.execPath` is Bun — a runtime that cannot load the V8
|
|
17
|
+
* isolated-vm addon. Never hand that executable to the server: use the current
|
|
18
|
+
* process only when it is genuinely Node 26, otherwise verify a `node` on PATH
|
|
19
|
+
* and fail fast with an actionable message.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveNode26Binary(deps?: ResolveNode26Deps): string;
|
|
22
|
+
//# sourceMappingURL=node-binary.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { delimiter, join } from "node:path";
|
|
3
|
+
const REQUIRED_NODE_MAJOR = 26;
|
|
4
|
+
const defaultDeps = {
|
|
5
|
+
execPath: process.execPath,
|
|
6
|
+
versions: process.versions,
|
|
7
|
+
platform: process.platform,
|
|
8
|
+
env: process.env,
|
|
9
|
+
run: (command, args) => execFileSync(command, args, {
|
|
10
|
+
encoding: "utf8",
|
|
11
|
+
timeout: 5_000,
|
|
12
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
13
|
+
}).trim(),
|
|
14
|
+
};
|
|
15
|
+
function majorOf(version) {
|
|
16
|
+
return Number.parseInt(version?.split(".")[0] ?? "", 10);
|
|
17
|
+
}
|
|
18
|
+
function probeNode(binary, run) {
|
|
19
|
+
try {
|
|
20
|
+
const raw = run(binary, [
|
|
21
|
+
"-p",
|
|
22
|
+
"JSON.stringify({node:process.versions.node,bun:process.versions.bun??null})",
|
|
23
|
+
]);
|
|
24
|
+
const parsed = JSON.parse(raw);
|
|
25
|
+
if (typeof parsed.node !== "string")
|
|
26
|
+
return null;
|
|
27
|
+
return { node: parsed.node, bun: parsed.bun ?? null };
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function pathCandidates(platform, env) {
|
|
34
|
+
const names = platform === "win32"
|
|
35
|
+
? (env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM")
|
|
36
|
+
.split(";")
|
|
37
|
+
.filter(Boolean)
|
|
38
|
+
.map((ext) => `node${ext.toLowerCase()}`)
|
|
39
|
+
: ["node"];
|
|
40
|
+
const dirs = (env.PATH ?? "")
|
|
41
|
+
.split(platform === "win32" ? ";" : delimiter)
|
|
42
|
+
.filter(Boolean);
|
|
43
|
+
return dirs.flatMap((dir) => names.map((name) => join(dir, name)));
|
|
44
|
+
}
|
|
45
|
+
function isNode26(probe) {
|
|
46
|
+
return (probe !== null &&
|
|
47
|
+
probe.bun === null &&
|
|
48
|
+
majorOf(probe.node) === REQUIRED_NODE_MAJOR);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the Node 26 binary that must host the backend.
|
|
52
|
+
*
|
|
53
|
+
* `lobu run` may itself be launched through Bun (for example `bunx @lobu/cli`),
|
|
54
|
+
* where `process.execPath` is Bun — a runtime that cannot load the V8
|
|
55
|
+
* isolated-vm addon. Never hand that executable to the server: use the current
|
|
56
|
+
* process only when it is genuinely Node 26, otherwise verify a `node` on PATH
|
|
57
|
+
* and fail fast with an actionable message.
|
|
58
|
+
*/
|
|
59
|
+
export function resolveNode26Binary(deps = defaultDeps) {
|
|
60
|
+
if (deps.versions.bun === undefined &&
|
|
61
|
+
majorOf(deps.versions.node) === REQUIRED_NODE_MAJOR) {
|
|
62
|
+
return deps.execPath;
|
|
63
|
+
}
|
|
64
|
+
for (const candidate of pathCandidates(deps.platform, deps.env)) {
|
|
65
|
+
if (isNode26(probeNode(candidate, deps.run)))
|
|
66
|
+
return candidate;
|
|
67
|
+
}
|
|
68
|
+
const current = deps.versions.bun
|
|
69
|
+
? `Bun ${deps.versions.bun}`
|
|
70
|
+
: `Node ${deps.versions.node ?? "unknown"}`;
|
|
71
|
+
throw new Error(`Lobu's gateway must run on Node.js ${REQUIRED_NODE_MAJOR}.x — this CLI is running on ${current} and no Node ${REQUIRED_NODE_MAJOR} binary was found on PATH. Install Node ${REQUIRED_NODE_MAJOR} (nvm install ${REQUIRED_NODE_MAJOR} && nvm use ${REQUIRED_NODE_MAJOR}) and re-run.`);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=node-binary.js.map
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Single source of truth for the CLI's Node-version policy.
|
|
3
3
|
*
|
|
4
|
-
* Lobu's
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* bundled server's deps (undici) reference globals absent on
|
|
9
|
-
* old Node and crash on load.
|
|
4
|
+
* Lobu's gateway and worker load isolated-vm, whose native addon is tied to a
|
|
5
|
+
* single Node major's V8 ABI. This repo ships one isolated-vm 7 build and runs
|
|
6
|
+
* it on Node 26 only; Node 27 and later need a matching addon build before they
|
|
7
|
+
* can be supported.
|
|
10
8
|
*
|
|
11
|
-
* The `bin/lobu.js` entrypoint carries an inline copy of the
|
|
12
|
-
*
|
|
9
|
+
* The `bin/lobu.js` entrypoint carries an inline copy of the same major because
|
|
10
|
+
* it must run with zero imports (before the bundle loads); keep it and
|
|
13
11
|
* packages/server/src/utils/assert-node-version.ts in sync with this file.
|
|
14
12
|
*/
|
|
15
|
-
export declare const MIN_NODE_MAJOR =
|
|
16
|
-
/** True when isolated-vm has a build for this Node major (sandbox works). */
|
|
17
|
-
export declare function sandboxAvailableForNode(major: number): boolean;
|
|
13
|
+
export declare const MIN_NODE_MAJOR = 26;
|
|
18
14
|
type NodeSupport = {
|
|
19
15
|
ok: true;
|
|
20
|
-
sandbox: boolean;
|
|
21
16
|
} | {
|
|
22
17
|
ok: false;
|
|
23
18
|
reason: string;
|
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Single source of truth for the CLI's Node-version policy.
|
|
3
3
|
*
|
|
4
|
-
* Lobu's
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* bundled server's deps (undici) reference globals absent on
|
|
9
|
-
* old Node and crash on load.
|
|
4
|
+
* Lobu's gateway and worker load isolated-vm, whose native addon is tied to a
|
|
5
|
+
* single Node major's V8 ABI. This repo ships one isolated-vm 7 build and runs
|
|
6
|
+
* it on Node 26 only; Node 27 and later need a matching addon build before they
|
|
7
|
+
* can be supported.
|
|
10
8
|
*
|
|
11
|
-
* The `bin/lobu.js` entrypoint carries an inline copy of the
|
|
12
|
-
*
|
|
9
|
+
* The `bin/lobu.js` entrypoint carries an inline copy of the same major because
|
|
10
|
+
* it must run with zero imports (before the bundle loads); keep it and
|
|
13
11
|
* packages/server/src/utils/assert-node-version.ts in sync with this file.
|
|
14
12
|
*/
|
|
15
|
-
export const MIN_NODE_MAJOR =
|
|
16
|
-
const
|
|
13
|
+
export const MIN_NODE_MAJOR = 26;
|
|
14
|
+
const MAX_NODE_MAJOR_EXCLUSIVE = 27;
|
|
17
15
|
function currentNodeMajor() {
|
|
18
16
|
return Number.parseInt(process.versions.node.split(".")[0] ?? "", 10);
|
|
19
17
|
}
|
|
20
|
-
/** True when isolated-vm has a build for this Node major (sandbox works). */
|
|
21
|
-
export function sandboxAvailableForNode(major) {
|
|
22
|
-
return ((major >= MIN_NODE_MAJOR && major < SANDBOX_GAP_NODE_MAJOR) || major >= 26);
|
|
23
|
-
}
|
|
24
18
|
/**
|
|
25
|
-
* One-line explanation of the floor, so user-facing messages say WHY
|
|
19
|
+
* One-line explanation of the floor, so user-facing messages say WHY 26 —
|
|
26
20
|
* not a bare "unsupported" that reads as arbitrary.
|
|
27
21
|
*/
|
|
28
|
-
const NODE_FLOOR_REASON = `Lobu runs agent code in an isolated-vm sandbox whose native
|
|
29
|
-
`
|
|
22
|
+
const NODE_FLOOR_REASON = `Lobu runs agent code in an isolated-vm sandbox whose native build covers ` +
|
|
23
|
+
`Node ${MIN_NODE_MAJOR}.x only.`;
|
|
30
24
|
/** Classify the running Node against Lobu's support policy. */
|
|
31
25
|
export function checkNodeSupport() {
|
|
32
26
|
const current = process.versions.node;
|
|
33
27
|
const major = currentNodeMajor();
|
|
34
|
-
if (!Number.isFinite(major) ||
|
|
28
|
+
if (!Number.isFinite(major) ||
|
|
29
|
+
major < MIN_NODE_MAJOR ||
|
|
30
|
+
major >= MAX_NODE_MAJOR_EXCLUSIVE) {
|
|
35
31
|
return {
|
|
36
32
|
ok: false,
|
|
37
|
-
reason: `Lobu needs Node.js ${MIN_NODE_MAJOR}
|
|
33
|
+
reason: `Lobu needs Node.js ${MIN_NODE_MAJOR}.x — you're on Node ${current}.`,
|
|
38
34
|
why: NODE_FLOOR_REASON,
|
|
39
35
|
};
|
|
40
36
|
}
|
|
41
|
-
return { ok: true
|
|
37
|
+
return { ok: true };
|
|
42
38
|
}
|
|
43
39
|
//# sourceMappingURL=node-version.js.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"server": "dist/server.bundle.mjs",
|
|
6
6
|
"embeddingsServer": "dist/embeddings-server.mjs"
|
|
7
7
|
},
|
|
8
|
-
"version": "24.
|
|
8
|
+
"version": "24.5.0",
|
|
9
9
|
"verify": "dist/verify.mjs"
|
|
10
10
|
},
|
|
11
11
|
"device": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"connector": "node_modules/@lobu/cli/dist/commands/connector.js",
|
|
17
17
|
"worker": "node_modules/@lobu/connector-worker/dist/bin.js"
|
|
18
18
|
},
|
|
19
|
-
"version": "24.
|
|
19
|
+
"version": "24.5.0",
|
|
20
20
|
"verify": "dist/verify.mjs"
|
|
21
21
|
},
|
|
22
22
|
"postgres": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"entries": {
|
|
25
25
|
"postgres": "dist/index.mjs"
|
|
26
26
|
},
|
|
27
|
-
"version": "24.
|
|
27
|
+
"version": "24.5.0",
|
|
28
28
|
"verify": "dist/verify.mjs"
|
|
29
29
|
},
|
|
30
30
|
"embeddings": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"entries": {
|
|
33
33
|
"embeddings": "dist/embeddings.js"
|
|
34
34
|
},
|
|
35
|
-
"version": "24.
|
|
35
|
+
"version": "24.5.0",
|
|
36
36
|
"verify": "dist/verify.mjs"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -44,8 +44,8 @@ or public domain from a personal email address.
|
|
|
44
44
|
|
|
45
45
|
## Prerequisites
|
|
46
46
|
|
|
47
|
-
Before `lobu run`, the host needs Node
|
|
48
|
-
`isolated-vm`
|
|
47
|
+
Before `lobu run`, the host needs Node 26.x — the gateway and worker load the
|
|
48
|
+
Node-26-only `isolated-vm` native build — and one LLM provider credential in
|
|
49
49
|
`.env`.
|
|
50
50
|
Postgres is built in: `lobu run`
|
|
51
51
|
starts an embedded PostgreSQL (with `pgvector`); set `DATABASE_URL` only to use an
|
package/vendor/cli/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobu/cli",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.5.0",
|
|
4
4
|
"description": "CLI for deploying and managing AI agents on Lobu",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
"dist"
|
|
57
57
|
],
|
|
58
58
|
"engines": {
|
|
59
|
-
"node": ">=
|
|
59
|
+
"node": ">=26 <27"
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -195,8 +195,14 @@ export interface ReactionClient {
|
|
|
195
195
|
run_id?: number;
|
|
196
196
|
}>;
|
|
197
197
|
};
|
|
198
|
-
/**
|
|
199
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Run a read-only SQL query against the org's Postgres, or live against a
|
|
200
|
+
* connection's source when `options.connection` names one.
|
|
201
|
+
*/
|
|
202
|
+
query(sql: string, options?: {
|
|
203
|
+
window_token?: string;
|
|
204
|
+
connection?: string;
|
|
205
|
+
}): Promise<unknown[]>;
|
|
200
206
|
/** Structured log — appears in the Automation run output. */
|
|
201
207
|
log(message: string, data?: Record<string, unknown>): void;
|
|
202
208
|
}
|
|
@@ -14,9 +14,13 @@ export interface ReactionEntity {
|
|
|
14
14
|
/**
|
|
15
15
|
* Context passed to reaction scripts containing the analysis results
|
|
16
16
|
* and metadata about the completed Automation run. Reaction scripts have the
|
|
17
|
-
* shape `default async (ctx: ReactionContext, client, params?)`.
|
|
17
|
+
* shape `default async (ctx: ReactionContext, client, params?)`. The same
|
|
18
|
+
* module may export `prepare(ctx: AutomationScriptContext, client)` returning
|
|
19
|
+
* named arrays of records, saved before the run's agent is dispatched.
|
|
18
20
|
*/
|
|
19
21
|
export interface ReactionContext {
|
|
22
|
+
/** Named sources prepared and saved before this run's agent execution. */
|
|
23
|
+
sources?: Record<string, unknown[]>;
|
|
20
24
|
/** The extracted analysis data from the completed run */
|
|
21
25
|
extracted_data: Record<string, unknown>;
|
|
22
26
|
/** All entities the Automation is attached to */
|
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
// ../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
8
|
+
// ../../node_modules/@agentclientprotocol/claude-agent-acp/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
9
9
|
import { createRequire as j5 } from "node:module";
|
|
10
10
|
import * as nr from "node:fs/promises";
|
|
11
11
|
import * as bn from "node:path";
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* What this module adds is only the envelope: the guest bundle, the allowlist,
|
|
8
8
|
* and reporting the result.
|
|
9
9
|
*/
|
|
10
|
-
import { createChildSpan, initTracing, runInSpanContext, SpanStatusCode, traceparentHeader } from '@lobu/core';
|
|
10
|
+
import { classifyErrorMessage, createChildSpan, initTracing, recordError, runInSpanContext, SpanStatusCode, traceparentHeader, } from '@lobu/core';
|
|
11
11
|
import { AGENT_TURN_BRIDGE_BYTES, AGENT_TURN_INPUT_MAX, TURN_DELTA_MAX_CHARS, TURN_TOOL_EVENT_QUEUE_MAX, } from '@lobu/core/contracts/worker/protocol';
|
|
12
12
|
import { agentGuestBundle } from '../agent-turn/bundle.js';
|
|
13
13
|
import { selectExecutor } from '../executor/select.js';
|
|
@@ -25,6 +25,13 @@ import { completeAgentTurnOnce } from './terminal-delivery.js';
|
|
|
25
25
|
* the same request the liveness beat would have made.
|
|
26
26
|
*/
|
|
27
27
|
const TURN_DELTA_FLUSH_MS = 400;
|
|
28
|
+
/**
|
|
29
|
+
* Heap cap for one agent turn's isolate. The fleet runs many turns beside each
|
|
30
|
+
* other, so the connector default (512 MB) would let a few runaway turns take
|
|
31
|
+
* the whole pod. The worst measured turn (history at its 4 MB cap) peaked at a
|
|
32
|
+
* 63 MB heap; a light one at 15 MB. 256 MB is four times that worst case.
|
|
33
|
+
*/
|
|
34
|
+
const AGENT_TURN_ISOLATE_MEMORY_MB = 256;
|
|
28
35
|
/**
|
|
29
36
|
* How many batches the pre-completion drain will push before giving up.
|
|
30
37
|
*
|
|
@@ -69,21 +76,24 @@ export async function executeAgentTurnRun(client, job, env, cfg) {
|
|
|
69
76
|
const { terminalStatus, ...outcome } = result;
|
|
70
77
|
const status = terminalStatus ?? (outcome.error ? 'failed' : 'completed');
|
|
71
78
|
span?.setAttribute('lobu.run_status', status);
|
|
72
|
-
if (status
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
if (status === 'failed') {
|
|
80
|
+
// Classify the failure text once, here, so it groups and routes by its
|
|
81
|
+
// catalog code rather than by prose.
|
|
82
|
+
const message = outcome.error ?? 'Agent turn failed';
|
|
83
|
+
recordError(span, {
|
|
84
|
+
name: 'AgentTurnError',
|
|
85
|
+
message,
|
|
86
|
+
code: classifyErrorMessage(message),
|
|
76
87
|
});
|
|
77
88
|
}
|
|
89
|
+
else if (status !== 'cancelled') {
|
|
90
|
+
span?.setStatus({ code: SpanStatusCode.OK });
|
|
91
|
+
}
|
|
78
92
|
return outcome;
|
|
79
93
|
}
|
|
80
94
|
catch (error) {
|
|
81
95
|
span?.setAttribute('lobu.run_status', 'failed');
|
|
82
|
-
span
|
|
83
|
-
code: SpanStatusCode.ERROR,
|
|
84
|
-
message: error instanceof Error ? error.message : String(error),
|
|
85
|
-
});
|
|
86
|
-
span?.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
96
|
+
recordError(span, error);
|
|
87
97
|
throw error;
|
|
88
98
|
}
|
|
89
99
|
finally {
|
|
@@ -397,6 +407,7 @@ async function runAgentTurn(client, job, env, cfg) {
|
|
|
397
407
|
// attachment payload and stored history separately; the connector
|
|
398
408
|
// default is sized for a connector payload, not for that.
|
|
399
409
|
messageBytes: AGENT_TURN_BRIDGE_BYTES,
|
|
410
|
+
memoryMb: AGENT_TURN_ISOLATE_MEMORY_MB,
|
|
400
411
|
}));
|
|
401
412
|
const result = await executor.execute(guestCode, {
|
|
402
413
|
mode: 'agent_turn',
|
|
@@ -12,10 +12,7 @@ export declare function trimTrailingSlashes(value: string): string;
|
|
|
12
12
|
*/
|
|
13
13
|
export interface ExecutorClient {
|
|
14
14
|
readonly id: string;
|
|
15
|
-
poll(capacityAvailable?: number, options?:
|
|
16
|
-
waitSeconds?: number;
|
|
17
|
-
signal?: AbortSignal;
|
|
18
|
-
}): Promise<PollResponse>;
|
|
15
|
+
poll(capacityAvailable?: number, options?: WorkerPollOptions): Promise<PollResponse>;
|
|
19
16
|
/**
|
|
20
17
|
* Beat, and read what the gateway says back. The response is the only channel
|
|
21
18
|
* into a run this worker already holds: `continue: false` means stop.
|
|
@@ -75,6 +72,22 @@ import type { ConnectorOperationResult } from "@lobu/core/contracts/tools/manage
|
|
|
75
72
|
import type { AgentKind } from "@lobu/core/contracts/worker/device-automation";
|
|
76
73
|
/** Capability strings the worker advertises, keyed by name (e.g. `browser.debugger`). */
|
|
77
74
|
export type WorkerCapabilities = Record<string, boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* Free slots per budget, for a worker that budgets agent turns apart from
|
|
77
|
+
* connector work. The poll body already says this without a new field:
|
|
78
|
+
* `agent_turn` is withdrawn while no turn slot is free, and the free connector
|
|
79
|
+
* slots are the compiled-connector backend capacity, which is what every fleet
|
|
80
|
+
* sync, action and auth claim requires.
|
|
81
|
+
*/
|
|
82
|
+
export interface PollLaneCapacity {
|
|
83
|
+
agentTurns: number;
|
|
84
|
+
connectorJobs: number;
|
|
85
|
+
}
|
|
86
|
+
export interface WorkerPollOptions {
|
|
87
|
+
waitSeconds?: number;
|
|
88
|
+
signal?: AbortSignal;
|
|
89
|
+
lanes?: PollLaneCapacity;
|
|
90
|
+
}
|
|
78
91
|
export interface WorkerAdvertisementSnapshot {
|
|
79
92
|
capabilities: WorkerCapabilities;
|
|
80
93
|
manifests: unknown[];
|
|
@@ -179,13 +192,17 @@ export declare class WorkerClient implements ExecutorClient {
|
|
|
179
192
|
private post;
|
|
180
193
|
private requestJson;
|
|
181
194
|
private requestVoid;
|
|
195
|
+
/**
|
|
196
|
+
* Report free connector slots as compiled-connector capacity, but only for a
|
|
197
|
+
* backend that is ready: a closed backend stays at zero. A worker that sends
|
|
198
|
+
* no map is read by the gateway as `defaultBackendCapacity()`, so start from
|
|
199
|
+
* that.
|
|
200
|
+
*/
|
|
201
|
+
private laneBackendCapacity;
|
|
182
202
|
/**
|
|
183
203
|
* Poll for available runs
|
|
184
204
|
*/
|
|
185
|
-
poll(capacityAvailable?: number, options?:
|
|
186
|
-
waitSeconds?: number;
|
|
187
|
-
signal?: AbortSignal;
|
|
188
|
-
}): Promise<PollResponse>;
|
|
205
|
+
poll(capacityAvailable?: number, options?: WorkerPollOptions): Promise<PollResponse>;
|
|
189
206
|
/**
|
|
190
207
|
* Send heartbeat for active run
|
|
191
208
|
*/
|