@lobu/runtime-device 24.4.0 → 24.6.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.
Files changed (113) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +77 -64
  3. package/dist/verify.mjs +1 -1
  4. package/npm-shrinkwrap.json +176 -141
  5. package/package.json +3 -2
  6. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +65 -11
  7. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +20 -13
  8. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +48 -100
  9. package/vendor/cli/dist/commands/_lib/apply/client.js +76 -27
  10. package/vendor/cli/dist/commands/_lib/apply/deployment.js +1 -1
  11. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +7 -11
  12. package/vendor/cli/dist/commands/_lib/apply/desired-state.js +9 -40
  13. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +4 -4
  14. package/vendor/cli/dist/commands/_lib/apply/diff.js +37 -33
  15. package/vendor/cli/dist/commands/_lib/apply/map-config.d.ts +1 -1
  16. package/vendor/cli/dist/commands/_lib/apply/map-config.js +79 -92
  17. package/vendor/cli/dist/commands/_lib/apply/shared.d.ts +3 -6
  18. package/vendor/cli/dist/commands/_lib/apply/shared.js +8 -19
  19. package/vendor/cli/dist/commands/_lib/view-bundler.js +9 -1
  20. package/vendor/cli/dist/commands/dev.js +21 -7
  21. package/vendor/cli/dist/commands/doctor.js +1 -8
  22. package/vendor/cli/dist/commands/init.js +4 -5
  23. package/vendor/cli/dist/config/define.d.ts +27 -28
  24. package/vendor/cli/dist/config/define.js +4 -5
  25. package/vendor/cli/dist/connectors/linkedin-identity.ts +43 -0
  26. package/vendor/cli/dist/connectors/linkedin.ts +154 -3
  27. package/vendor/cli/dist/connectors/postgres.ts +77 -48
  28. package/vendor/cli/dist/connectors/x-like-follow.ts +329 -0
  29. package/vendor/cli/dist/connectors/x.ts +709 -80
  30. package/vendor/cli/dist/internal/api-client.d.ts +2 -0
  31. package/vendor/cli/dist/internal/api-client.js +6 -1
  32. package/vendor/cli/dist/internal/connector-compiler.js +3 -1
  33. package/vendor/cli/dist/internal/node-binary.d.ts +22 -0
  34. package/vendor/cli/dist/internal/node-binary.js +73 -0
  35. package/vendor/cli/dist/internal/node-version.d.ts +7 -12
  36. package/vendor/cli/dist/internal/node-version.js +16 -20
  37. package/vendor/cli/dist/runtime-components.json +4 -4
  38. package/vendor/cli/dist/templates/AGENTS.md.tmpl +2 -2
  39. package/vendor/cli/package.json +3 -2
  40. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +8 -2
  41. package/vendor/connector-sdk/dist/reaction-sdk.d.ts +5 -1
  42. package/vendor/connector-sdk/package.json +1 -1
  43. package/vendor/connector-worker/dist/compile/index.d.ts +4 -3
  44. package/vendor/connector-worker/dist/compile/index.js +6 -3
  45. package/vendor/connector-worker/dist/daemon/acp-adapters/claude.js +1 -1
  46. package/vendor/connector-worker/dist/daemon/agent-turn.js +21 -10
  47. package/vendor/connector-worker/dist/daemon/client.d.ts +25 -8
  48. package/vendor/connector-worker/dist/daemon/client.js +25 -3
  49. package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +7 -1
  50. package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +17 -0
  51. package/vendor/connector-worker/dist/daemon/poll-loop.js +75 -6
  52. package/vendor/connector-worker/dist/daemon/resource-admission.d.ts +19 -0
  53. package/vendor/connector-worker/dist/daemon/resource-admission.js +59 -0
  54. package/vendor/connector-worker/dist/daemon/resources.d.ts +20 -0
  55. package/vendor/connector-worker/dist/daemon/resources.js +163 -0
  56. package/vendor/connector-worker/dist/daemon/start.js +29 -4
  57. package/vendor/connector-worker/dist/daemon/worker.d.ts +2 -0
  58. package/vendor/connector-worker/dist/daemon/worker.js +4 -0
  59. package/vendor/connector-worker/dist/executor/select.d.ts +1 -1
  60. package/vendor/connector-worker/dist/executor/select.js +1 -1
  61. package/vendor/connector-worker/dist/isolate/ivm-types.d.ts +1 -2
  62. package/vendor/connector-worker/dist/isolate/ivm-types.js +1 -2
  63. package/vendor/connector-worker/dist/isolate/load.d.ts +10 -12
  64. package/vendor/connector-worker/dist/isolate/load.js +23 -27
  65. package/vendor/connector-worker/dist/self-check/index.d.ts +2 -2
  66. package/vendor/connector-worker/dist/self-check/index.js +2 -2
  67. package/vendor/connector-worker/package.json +3 -4
  68. package/vendor/core/dist/contracts/agent-settings.d.ts +61 -6
  69. package/vendor/core/dist/contracts/agent-settings.js +10 -7
  70. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +473 -98
  71. package/vendor/core/dist/contracts/tools/manage-agents.js +111 -2
  72. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +21 -18
  73. package/vendor/core/dist/contracts/tools/manage-automations.js +15 -15
  74. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
  75. package/vendor/core/dist/contracts/tools/manage-inference-providers.d.ts +445 -0
  76. package/vendor/core/dist/contracts/tools/manage-inference-providers.js +133 -0
  77. package/vendor/core/dist/contracts/tools/manage-views.d.ts +4 -4
  78. package/vendor/core/dist/contracts/tools/manage-views.js +5 -3
  79. package/vendor/core/dist/contracts/tools/view-host.d.ts +7 -0
  80. package/vendor/core/dist/contracts/tools/view-host.js +28 -0
  81. package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -4
  82. package/vendor/core/dist/contracts/tools/view-runtime.js +19 -7
  83. package/vendor/core/dist/contracts/worker/device-automation.js +4 -2
  84. package/vendor/core/dist/error-report.d.ts +73 -0
  85. package/vendor/core/dist/error-report.js +346 -0
  86. package/vendor/core/dist/index.d.ts +3 -1
  87. package/vendor/core/dist/index.js +4 -1
  88. package/vendor/core/dist/logger.js +7 -4
  89. package/vendor/core/dist/otel-fetch.d.ts +19 -0
  90. package/vendor/core/dist/otel-fetch.js +96 -0
  91. package/vendor/core/dist/otel.d.ts +9 -0
  92. package/vendor/core/dist/otel.js +28 -7
  93. package/vendor/core/dist/reserved.d.ts +1 -1
  94. package/vendor/core/dist/reserved.js +6 -4
  95. package/vendor/core/dist/tool-result.d.ts +8 -0
  96. package/vendor/core/dist/tool-result.js +61 -0
  97. package/vendor/core/dist/utils/diagnostic-scrubber.js +1 -1
  98. package/vendor/core/dist/worker/auth.js +4 -0
  99. package/vendor/core/package.json +16 -1
  100. package/vendor/views/dist/api.d.ts +290 -0
  101. package/vendor/views/dist/api.js +714 -0
  102. package/vendor/views/dist/bridge.d.ts +157 -0
  103. package/vendor/views/dist/bridge.js +372 -0
  104. package/vendor/views/dist/components.d.ts +172 -0
  105. package/vendor/views/dist/components.js +376 -0
  106. package/vendor/views/dist/index.d.ts +13 -0
  107. package/vendor/views/dist/index.js +3 -0
  108. package/vendor/views/dist/native.d.ts +327 -0
  109. package/vendor/views/dist/native.js +57 -0
  110. package/vendor/views/package.json +53 -0
  111. /package/vendor/cli/dist/vendor/ora/{.bun-tag-fde20e9a6df212fa → .bun-tag-77bb9b258a474a18} +0 -0
  112. /package/vendor/ora/{.bun-tag-fde20e9a6df212fa → .bun-tag-77bb9b258a474a18} +0 -0
  113. /package/vendor/postgres/{.bun-tag-22d644c2873790db → .bun-tag-c81dacd34e959a7a} +0 -0
@@ -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 { status: response.status, body: parsed };
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);
@@ -246,7 +246,9 @@ var ISOLATE_LANE_BUILD_OPTIONS = {
246
246
  platform: "node",
247
247
  conditions: ["workerd"],
248
248
  supported: { "dynamic-import": false },
249
- external: []
249
+ // This non-Node specifier is supplied by the isolate's host-backed prelude;
250
+ // unlike Node builtins, esbuild otherwise tries to resolve it as a package.
251
+ external: ["cloudflare:sockets"]
250
252
  };
251
253
  var RETAINED_SOURCE_BUILD_OPTIONS = {
252
254
  minify: true,
@@ -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 SDK sandbox (query_sdk / run_sdk) uses isolated-vm, whose native addon
5
- * is tied to each Node line's V8 ABI: isolated-vm@6 covers Node 22–24, the
6
- * aliased isolated-vm@7 covers Node 26+. Node 25 is an EOL non-LTS line upstream
7
- * skipped, so it boots but has no sandbox build. Below 22 nothing works — the
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 MIN threshold
12
- * because it must run with zero imports (before the bundle loads); keep it and
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 = 22;
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 SDK sandbox (query_sdk / run_sdk) uses isolated-vm, whose native addon
5
- * is tied to each Node line's V8 ABI: isolated-vm@6 covers Node 22–24, the
6
- * aliased isolated-vm@7 covers Node 26+. Node 25 is an EOL non-LTS line upstream
7
- * skipped, so it boots but has no sandbox build. Below 22 nothing works — the
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 MIN threshold
12
- * because it must run with zero imports (before the bundle loads); keep it and
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 = 22;
16
- const SANDBOX_GAP_NODE_MAJOR = 25;
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 22 —
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 builds only ` +
29
- `cover Node ${MIN_NODE_MAJOR}–24 and 26+, so ${MIN_NODE_MAJOR} is the minimum.`;
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) || major < MIN_NODE_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} or newer — you're on Node ${current}.`,
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, sandbox: sandboxAvailableForNode(major) };
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.4.0",
8
+ "version": "24.6.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.4.0",
19
+ "version": "24.6.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.4.0",
27
+ "version": "24.6.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.4.0",
35
+ "version": "24.6.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 22-24 or 26+ (only Node 25 is unsupported —
48
- `isolated-vm` skips that EOL non-LTS line) and one LLM provider credential in
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/cli",
3
- "version": "24.4.0",
3
+ "version": "24.6.0",
4
4
  "description": "CLI for deploying and managing AI agents on Lobu",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,6 +34,7 @@
34
34
  "@inquirer/prompts": "^7.10.1",
35
35
  "@lobu/connector-sdk": "file:../connector-sdk",
36
36
  "@lobu/core": "file:../core",
37
+ "@lobu/views": "file:../views",
37
38
  "@sinclair/typebox": "^0.34.41",
38
39
  "chalk": "^5.3.0",
39
40
  "commander": "^14.0.1",
@@ -56,6 +57,6 @@
56
57
  "dist"
57
58
  ],
58
59
  "engines": {
59
- "node": ">=22 <25 || >=26"
60
+ "node": ">=26 <27"
60
61
  }
61
62
  }
@@ -195,8 +195,14 @@ export interface ReactionClient {
195
195
  run_id?: number;
196
196
  }>;
197
197
  };
198
- /** Run a read-only SQL query against the org's Postgres. */
199
- query(sql: string): Promise<unknown[]>;
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 */
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/connector-sdk",
3
- "version": "24.4.0",
3
+ "version": "24.6.0",
4
4
  "description": "Lobu memory SDK — build pluggable connectors for Lobu memory",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -54,8 +54,9 @@ export declare function normalizeSdkSpecifier(specifier: string): string;
54
54
  /**
55
55
  * esbuild options for code that runs inside a V8 isolate: the gateway's script
56
56
  * sandbox (`packages/server/src/sandbox/run-script.ts`, via the server's
57
- * `compiler-core`) and the connector isolate lane. `external: []` inlines every
58
- * import because an isolate has no module resolver, and `platform: 'node'`
57
+ * `compiler-core`) and the connector isolate lane. Packages are inlined because
58
+ * an isolate has no module resolver; only the provided socket shim is external.
59
+ * `platform: 'node'`
59
60
  * leaves Node builtins as bare `require()` calls that throw at load — the
60
61
  * fail-closed signal `findIsolateIneligibleBuiltins` and the lane tests key
61
62
  * on. One constant so the runtime and the tests that classify bundles can
@@ -69,7 +70,7 @@ export declare const ISOLATE_LANE_BUILD_OPTIONS: {
69
70
  readonly supported: {
70
71
  readonly 'dynamic-import': false;
71
72
  };
72
- readonly external: [];
73
+ readonly external: ["cloudflare:sockets"];
73
74
  };
74
75
  export interface NpmSpecifierPluginOptions {
75
76
  /**
@@ -88,8 +88,9 @@ export function normalizeSdkSpecifier(specifier) {
88
88
  /**
89
89
  * esbuild options for code that runs inside a V8 isolate: the gateway's script
90
90
  * sandbox (`packages/server/src/sandbox/run-script.ts`, via the server's
91
- * `compiler-core`) and the connector isolate lane. `external: []` inlines every
92
- * import because an isolate has no module resolver, and `platform: 'node'`
91
+ * `compiler-core`) and the connector isolate lane. Packages are inlined because
92
+ * an isolate has no module resolver; only the provided socket shim is external.
93
+ * `platform: 'node'`
93
94
  * leaves Node builtins as bare `require()` calls that throw at load — the
94
95
  * fail-closed signal `findIsolateIneligibleBuiltins` and the lane tests key
95
96
  * on. One constant so the runtime and the tests that classify bundles can
@@ -101,7 +102,9 @@ export const ISOLATE_LANE_BUILD_OPTIONS = {
101
102
  platform: 'node',
102
103
  conditions: ['workerd'],
103
104
  supported: { 'dynamic-import': false },
104
- external: [],
105
+ // This non-Node specifier is supplied by the isolate's host-backed prelude;
106
+ // unlike Node builtins, esbuild otherwise tries to resolve it as a package.
107
+ external: ['cloudflare:sockets'],
105
108
  };
106
109
  /**
107
110
  * Retained artifacts travel with their source, so they must be portable:
@@ -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 !== 'cancelled') {
73
- span?.setStatus({
74
- code: status === 'failed' ? SpanStatusCode.ERROR : SpanStatusCode.OK,
75
- ...(outcome.error ? { message: outcome.error } : {}),
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?.setStatus({
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
  */
@@ -11,6 +11,7 @@ export function trimTrailingSlashes(value) {
11
11
  return end === value.length ? value : value.slice(0, end);
12
12
  }
13
13
  import { traceparentHeader } from "@lobu/core";
14
+ import { defaultBackendCapacity, EXECUTION_BACKENDS, } from "@lobu/core/contracts/worker/protocol";
14
15
  import { resolveRunnableAgentKinds } from "./agent-binaries.js";
15
16
  export class MutableWorkerAdvertisementProvider {
16
17
  current;
@@ -205,14 +206,35 @@ export class WorkerClient {
205
206
  async requestVoid(path, body) {
206
207
  await this.post(path, body);
207
208
  }
209
+ /**
210
+ * Report free connector slots as compiled-connector capacity, but only for a
211
+ * backend that is ready: a closed backend stays at zero. A worker that sends
212
+ * no map is read by the gateway as `defaultBackendCapacity()`, so start from
213
+ * that.
214
+ */
215
+ laneBackendCapacity(connectorJobs) {
216
+ const compiled = EXECUTION_BACKENDS.compiledConnector;
217
+ const base = Object.keys(this.backendCapacity).length > 0
218
+ ? this.backendCapacity
219
+ : defaultBackendCapacity();
220
+ return { ...base, [compiled]: (base[compiled] ?? 0) > 0 ? connectorJobs : 0 };
221
+ }
208
222
  /**
209
223
  * Poll for available runs
210
224
  */
211
225
  async poll(capacityAvailable, options) {
212
226
  const advertisement = this.advertisementProvider?.snapshot();
213
- const capabilities = advertisement
227
+ const advertised = advertisement
214
228
  ? { ...this.advertisedCapabilities(), ...advertisement.capabilities }
215
229
  : this.advertisedCapabilities();
230
+ const lanes = options?.lanes;
231
+ // Budgets only ever withdraw what was advertised; they never open a lane.
232
+ const capabilities = lanes && advertised.agent_turn === true && lanes.agentTurns === 0
233
+ ? { ...advertised, agent_turn: false }
234
+ : advertised;
235
+ const backendCapacity = lanes
236
+ ? this.laneBackendCapacity(lanes.connectorJobs)
237
+ : this.backendCapacity;
216
238
  const manifests = advertisement?.manifests ?? this.manifests;
217
239
  const body = {
218
240
  worker_id: this.workerId,
@@ -222,8 +244,8 @@ export class WorkerClient {
222
244
  ...(capacityAvailable === undefined
223
245
  ? {}
224
246
  : { capacity_available: capacityAvailable }),
225
- ...(Object.keys(this.backendCapacity).length > 0
226
- ? { backend_capacity: this.backendCapacity }
247
+ ...(Object.keys(backendCapacity).length > 0
248
+ ? { backend_capacity: backendCapacity }
227
249
  : {}),
228
250
  // app_version belongs to the device registration fields, so omit both for
229
251
  // fleet workers rather than sending empty values. A device worker also
@@ -268,7 +268,13 @@ export function createMacDeviceDaemon(options, dependencies = {}) {
268
268
  sessionMeta: {
269
269
  claudeCode: {
270
270
  options: {
271
- allowedTools: ['mcp__lobu__query_sdk', 'mcp__lobu__run_sdk'],
271
+ // Discovery is read-only and must work before a run can use the SDK.
272
+ // Keep in sync with the headless `--allowedTools` list in core's DEVICE_AGENT_SPECS.
273
+ allowedTools: [
274
+ 'mcp__lobu__search_sdk',
275
+ 'mcp__lobu__query_sdk',
276
+ 'mcp__lobu__run_sdk',
277
+ ],
272
278
  settingSources: [],
273
279
  },
274
280
  },