@lobu/runtime-device 24.7.0 → 24.8.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 (30) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +25 -41
  3. package/npm-shrinkwrap.json +116 -240
  4. package/package.json +4 -2
  5. package/vendor/cli/dist/chrome-extension/manifest.json +5 -4
  6. package/vendor/cli/dist/chrome-extension/tools.js +2 -3
  7. package/vendor/cli/dist/commands/dev.js +28 -4
  8. package/vendor/cli/dist/connectors/imessage.ts +953 -0
  9. package/vendor/cli/dist/connectors/linkedin.ts +20 -377
  10. package/vendor/cli/dist/runtime-components.json +4 -4
  11. package/vendor/cli/dist/templates/AGENTS.md.tmpl +1 -1
  12. package/vendor/cli/package.json +1 -1
  13. package/vendor/connector-sdk/package.json +1 -1
  14. package/vendor/connector-worker/dist/env.d.ts +15 -0
  15. package/vendor/connector-worker/dist/env.js +17 -0
  16. package/vendor/connector-worker/dist/executor/isolate.d.ts +3 -1
  17. package/vendor/connector-worker/dist/executor/isolate.js +29 -8
  18. package/vendor/connector-worker/package.json +1 -1
  19. package/vendor/core/dist/connector-query-errors.d.ts +6 -0
  20. package/vendor/core/dist/connector-query-errors.js +4 -0
  21. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +2 -0
  22. package/vendor/core/dist/contracts/tools/manage-entity.js +7 -0
  23. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +2 -0
  24. package/vendor/core/dist/contracts/tools/manage-feeds.js +3 -0
  25. package/vendor/core/dist/contracts/tools/view-host.js +2 -0
  26. package/vendor/core/dist/error-report.js +1 -0
  27. package/vendor/core/package.json +1 -1
  28. package/vendor/views/package.json +1 -1
  29. package/vendor/cli/dist/connectors/linkedin-takeout.ts +0 -577
  30. package/vendor/cli/dist/connectors/takeout-utils.ts +0 -240
@@ -395,6 +395,25 @@ function refusedAddress(error) {
395
395
  return '';
396
396
  return null;
397
397
  }
398
+ /**
399
+ * The operator's `fetch` exemptions for one run: `LOBU_HTTP_EGRESS_ALLOW_HOSTS`
400
+ * (see `httpEgressAllowHostsEnv` in `env.ts`), the exact hosts a self-hosted
401
+ * install lets connector code reach in private space -- another container on
402
+ * its Docker network. Read from `job.env`, the run producer's deployment
403
+ * config, never from tenant `job.config`; and only for a run whose env says
404
+ * `allow-private`: under block-private (Cloud, which the gateway forces onto
405
+ * any worker it dispatches to) or a job that names no policy (offline webhook
406
+ * normalization) the list is inert, and an agent turn never gets one. Parsed
407
+ * by the DB list's parser, so a wildcard, CIDR, port or bracketed entry refuses
408
+ * the run rather than widening it. Address axis only: the run's allowlist
409
+ * still decides which hosts it may name, and metadata stays refused at the
410
+ * `allow-private` floor these hosts are lowered to.
411
+ */
412
+ function operatorHttpExemptHosts(job) {
413
+ if (job.mode === 'agent_turn' || job.env?.LOBU_DB_EGRESS_POLICY !== 'allow-private')
414
+ return [];
415
+ return parseExemptHosts(job.env.LOBU_HTTP_EGRESS_ALLOW_HOSTS, 'LOBU_HTTP_EGRESS_ALLOW_HOSTS').map((host) => stripIpv6Brackets(normalizeDomainPattern(host)));
416
+ }
398
417
  /** Request headers that must not follow a redirect to another origin. */
399
418
  const CROSS_ORIGIN_SENSITIVE_HEADERS = new Set(['authorization', 'cookie', 'proxy-authorization']);
400
419
  /** Same text the guest `fetch` uses, so both rejections read alike. */
@@ -459,6 +478,7 @@ export class IsolateExecutor {
459
478
  throw new Error('HTTP authentication requires a gateway fetch hook');
460
479
  }
461
480
  assertIsolateEligible(compiledCode);
481
+ const exemptHosts = [...this.exactAllowedHosts, ...operatorHttpExemptHosts(job)];
462
482
  const ivm = await this.requireIsolatedVm();
463
483
  const tail = new RingBuffer(STREAM_TAIL_CAP_BYTES);
464
484
  let logBytesUsed = 0;
@@ -482,10 +502,10 @@ export class IsolateExecutor {
482
502
  activeFetches.clear();
483
503
  };
484
504
  // The run's `fetch` transport: block-private, with the exact allowlist
485
- // entries lowered to the allow-private floor. One per run and destroyed
486
- // with it, so a worker that builds an executor per job never accumulates
487
- // idle keep-alive sockets.
488
- const egress = new EgressDispatcher({ exemptHosts: this.exactAllowedHosts, lookup: this.options.lookup });
505
+ // entries and the operator's HTTP exemptions lowered to the allow-private
506
+ // floor. One per run and destroyed with it, so a worker that builds an
507
+ // executor per job never accumulates idle keep-alive sockets.
508
+ const egress = new EgressDispatcher({ exemptHosts, lookup: this.options.lookup });
489
509
  // The run's credential vault: the guest gets placeholders, the host keeps
490
510
  // the values and resolves them into request headers at `fetch`. Cleared
491
511
  // with the run, so a placeholder that leaks into a checkpoint or a log is
@@ -598,7 +618,7 @@ export class IsolateExecutor {
598
618
  return undefined;
599
619
  };
600
620
  const network = {
601
- egress, vault, spends: new Set(), log,
621
+ egress, exemptHosts, vault, spends: new Set(), log,
602
622
  onHttpFetch: job.httpAuth ? hooks?.onHttpFetch : undefined,
603
623
  ...(job.mode === 'agent_turn' && job.credentials?.accessToken ? {
604
624
  agentGateway: {
@@ -1175,8 +1195,9 @@ export class IsolateExecutor {
1175
1195
  // Placeholders resolve only now, with the destination admitted, and only
1176
1196
  // into a destination that may carry a credential: HTTPS, or the run's
1177
1197
  // own machine -- a loopback or reserved literal (or `localhost`) that the
1178
- // allowlist names exactly, the same exemption that lets a self-hosted
1179
- // install or a fixture reach a local service. A public name stays HTTPS
1198
+ // allowlist or the operator's HTTP exemptions name exactly, the same
1199
+ // exemption that lets a self-hosted install or a fixture reach a local
1200
+ // service. A public name, or a private service NAME, stays HTTPS
1180
1201
  // only even when named exactly. Real values exist in `headers` from here
1181
1202
  // on and nowhere the guest can read. A refusal is the lane's egress
1182
1203
  // refusal: logged once host-side and named so the guest can tell it
@@ -1185,7 +1206,7 @@ export class IsolateExecutor {
1185
1206
  let spent;
1186
1207
  try {
1187
1208
  spent = net.vault.swapHeaders(headers, url, {
1188
- plaintextAllowed: this.exactAllowedHosts.includes(bareHost) && (bareHost === 'localhost' || isReservedIp(bareHost)),
1209
+ plaintextAllowed: net.exemptHosts.includes(bareHost) && (bareHost === 'localhost' || isReservedIp(bareHost)),
1189
1210
  });
1190
1211
  }
1191
1212
  catch (error) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/connector-worker",
3
- "version": "24.7.0",
3
+ "version": "24.8.0",
4
4
  "description": "Self-hosted worker for Lobu memory — connectors and embedding generation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -36,6 +36,12 @@ export type ToolErrorCode =
36
36
  * agent, MCP session or Automation is behind the call (HTTP 403).
37
37
  */
38
38
  | "MANUAL_EDIT_NOT_ALLOWED"
39
+ /**
40
+ * `manage_entity update` sent `expected`, and at least one field's live value
41
+ * no longer matches it, so nothing was written (HTTP 409). Re-read and retry
42
+ * with the current values.
43
+ */
44
+ | "PRECONDITION_FAILED"
39
45
  /** Upstream throttled the request (HTTP 429 / too many requests). */
40
46
  | "RATE_LIMITED"
41
47
  /** Upstream request or DB statement timed out (e.g. PG 57014). */
@@ -54,6 +54,10 @@ exports.TOOL_ERRORS = {
54
54
  retryable: false,
55
55
  message: "This caller may not assert a manual edit; it needs the entities:manual_edit scope and no agent, MCP session or Automation behind it.",
56
56
  },
57
+ PRECONDITION_FAILED: {
58
+ retryable: false,
59
+ message: "A field changed since it was read, so nothing was written; re-read it and retry with the current values.",
60
+ },
57
61
  RATE_LIMITED: {
58
62
  retryable: true,
59
63
  message: "The upstream rate limit was hit; retry shortly.",
@@ -25,6 +25,7 @@ export declare const UpdateEntityAction: import("@sinclair/typebox").TObject<{
25
25
  field_note: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
26
26
  affirm_fields: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
27
27
  manual_edit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
28
+ expected: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
28
29
  automation_source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
29
30
  automation_id: import("@sinclair/typebox").TNumber;
30
31
  run_id: import("@sinclair/typebox").TNumber;
@@ -169,6 +170,7 @@ export declare const ManageEntitySchema: import("@sinclair/typebox").TUnion<[imp
169
170
  field_note: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
170
171
  affirm_fields: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
171
172
  manual_edit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
173
+ expected: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
172
174
  automation_source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
173
175
  automation_id: import("@sinclair/typebox").TNumber;
174
176
  run_id: import("@sinclair/typebox").TNumber;
@@ -113,6 +113,8 @@ exports.CreateEntityAction = typebox_1.Type.Object({
113
113
  metadata: typebox_1.Type.Optional(Metadata),
114
114
  automation_source: typebox_1.Type.Optional(AutomationSource),
115
115
  });
116
+ /** Upper bound on `update`'s `expected` precondition keys. */
117
+ const MAX_EXPECTED_FIELDS = 50;
116
118
  exports.UpdateEntityAction = typebox_1.Type.Object({
117
119
  action: typebox_1.Type.Literal("update", {
118
120
  description: "Patch entity fields (human-owned fields queued for approval).",
@@ -136,6 +138,11 @@ exports.UpdateEntityAction = typebox_1.Type.Object({
136
138
  manual_edit: typebox_1.Type.Optional(typebox_1.Type.Boolean({
137
139
  description: "[update] Assert that the signed-in person made this change themselves, so it is recorded as their manual edit: the fields it sets (and affirm_fields) become theirs, and Automations then queue an approval instead of updating them. A wrong assertion takes the field away from Automations. Honoured for a person's own web-session edit, or for a token minted with the entities:manual_edit scope by a person in the web app, with no agent, MCP session or Automation behind the call; otherwise the update fails with 403 MANUAL_EDIT_NOT_ALLOWED and nothing is written. Defaults to false.",
138
140
  })),
141
+ // Optimistic concurrency: the values the caller read before writing
142
+ expected: typebox_1.Type.Optional(typebox_1.Type.Record(typebox_1.Type.String(), typebox_1.Type.Unknown(), {
143
+ maxProperties: MAX_EXPECTED_FIELDS,
144
+ description: `[update] Metadata field name -> the value the caller last read. Checked against the live row under the update's row lock: if any field differs, nothing is written (no field changes, ownership markers, events or approvals) and the update fails with 409 PRECONDITION_FAILED listing the field names in mismatched_fields. Values compare structurally (object key order is ignored); null matches a field that was never set. Metadata fields only (not name, content, slug or parent_id); at most ${MAX_EXPECTED_FIELDS} keys.`,
145
+ })),
139
146
  automation_source: typebox_1.Type.Optional(AutomationSource),
140
147
  });
141
148
  exports.ListEntitiesAction = typebox_1.Type.Object({
@@ -9,6 +9,7 @@ export declare const ListFeedsAction: import("@sinclair/typebox").TObject<{
9
9
  entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
10
10
  status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"active">, import("@sinclair/typebox").TLiteral<"paused">]>>;
11
11
  health: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"healthy">, import("@sinclair/typebox").TLiteral<"failing">]>>;
12
+ include_event_count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
12
13
  }>;
13
14
  export declare const ReadFeedAction: import("@sinclair/typebox").TObject<{
14
15
  action: import("@sinclair/typebox").TLiteral<"read_feed">;
@@ -155,6 +156,7 @@ export declare const ManageFeedsSchema: import("@sinclair/typebox").TUnion<[impo
155
156
  entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
156
157
  status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"active">, import("@sinclair/typebox").TLiteral<"paused">]>>;
157
158
  health: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"healthy">, import("@sinclair/typebox").TLiteral<"failing">]>>;
159
+ include_event_count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
158
160
  }>, import("@sinclair/typebox").TObject<{
159
161
  action: import("@sinclair/typebox").TLiteral<"read_feed">;
160
162
  feed_id: import("@sinclair/typebox").TNumber;
@@ -21,6 +21,9 @@ exports.ListFeedsAction = typebox_1.Type.Object({
21
21
  health: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.Literal("healthy"), typebox_1.Type.Literal("failing")], {
22
22
  description: "Filter by runtime health for active feeds on non-paused connections; paused feeds and feeds on paused connections are excluded. 'failing' = last sync failed or the feed has one or more consecutive failures; 'healthy' = otherwise. Surfaces active-but-failing feeds the `status` filter cannot.",
23
23
  })),
24
+ include_event_count: typebox_1.Type.Optional(typebox_1.Type.Boolean({
25
+ description: "Add `event_count`, each feed's stored events. Counting takes seconds on a busy connection, so it is off by default; ask for it only when you show the number.",
26
+ })),
24
27
  ...(0, pagination_1.paginationFields)(50),
25
28
  });
26
29
  // Metadata inspection is deliberately separate from source access. Reading one
@@ -8,6 +8,8 @@ exports.VIEW_OPEN_RECORD_METHOD = "lobu/open-record";
8
8
  /** A mixed read/write tool is admitted only for these fixed read actions.
9
9
  * The server still applies the visiting user's authorization and org scope. */
10
10
  function isViewRead(tool, args) {
11
+ if (tool === "read_knowledge")
12
+ return true;
11
13
  if (tool === "manage_entity") {
12
14
  return (args?.action === "list" ||
13
15
  args?.action === "get" ||
@@ -183,6 +183,7 @@ const USER_TOOL_CODES = new Set([
183
183
  "VALIDATION",
184
184
  "PERMISSION",
185
185
  "MANUAL_EDIT_NOT_ALLOWED",
186
+ "PRECONDITION_FAILED",
186
187
  ]);
187
188
  const DEPENDENCY_TOOL_CODES = new Set([
188
189
  "AUTH_INVALID",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/core",
3
- "version": "24.7.0",
3
+ "version": "24.8.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Core types and utilities for Lobu agent platform",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/views",
3
- "version": "24.7.0",
3
+ "version": "24.8.0",
4
4
  "description": "Authoring runtime for Lobu views — React modules rendered in the sandboxed MCP Apps frame",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",