@lobu/runtime-device 24.7.0 → 24.9.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 (88) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +35 -51
  3. package/npm-shrinkwrap.json +214 -334
  4. package/package.json +4 -2
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +14 -3
  6. package/vendor/cli/dist/chrome-extension/manifest.json +5 -4
  7. package/vendor/cli/dist/chrome-extension/tools.js +2 -3
  8. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +27 -0
  9. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +16 -5
  10. package/vendor/cli/dist/commands/_lib/apply/client.js +31 -9
  11. package/vendor/cli/dist/commands/_lib/apply/deployment.d.ts +8 -12
  12. package/vendor/cli/dist/commands/_lib/apply/deployment.js +14 -1
  13. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +8 -4
  14. package/vendor/cli/dist/commands/_lib/apply/desired-state.js +2 -1
  15. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +26 -7
  16. package/vendor/cli/dist/commands/_lib/apply/diff.js +101 -30
  17. package/vendor/cli/dist/commands/_lib/apply/map-config.js +29 -2
  18. package/vendor/cli/dist/commands/_lib/apply/render.js +2 -0
  19. package/vendor/cli/dist/commands/_lib/apply/shared.d.ts +20 -0
  20. package/vendor/cli/dist/commands/_lib/apply/shared.js +22 -0
  21. package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +14 -0
  22. package/vendor/cli/dist/commands/dev.js +28 -4
  23. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +6 -2
  24. package/vendor/cli/dist/config/define.d.ts +21 -3
  25. package/vendor/cli/dist/connectors/README.md +6 -2
  26. package/vendor/cli/dist/connectors/github.ts +16 -3
  27. package/vendor/cli/dist/connectors/imessage.ts +953 -0
  28. package/vendor/cli/dist/connectors/linkedin.ts +20 -377
  29. package/vendor/cli/dist/connectors/market_quotes.ts +388 -91
  30. package/vendor/cli/dist/connectors/postgres.ts +21 -14
  31. package/vendor/cli/dist/connectors/x-dm-adapter.js +55 -21
  32. package/vendor/cli/dist/connectors/x.ts +1 -1
  33. package/vendor/cli/dist/runtime-components.json +4 -4
  34. package/vendor/cli/dist/templates/AGENTS.md.tmpl +1 -1
  35. package/vendor/cli/package.json +1 -1
  36. package/vendor/connector-sdk/dist/connector-types.d.ts +23 -2
  37. package/vendor/connector-sdk/package.json +1 -1
  38. package/vendor/connector-worker/dist/daemon/automation.js +7 -4
  39. package/vendor/connector-worker/dist/env.d.ts +15 -0
  40. package/vendor/connector-worker/dist/env.js +17 -0
  41. package/vendor/connector-worker/dist/executor/isolate.d.ts +3 -1
  42. package/vendor/connector-worker/dist/executor/isolate.js +32 -8
  43. package/vendor/connector-worker/package.json +1 -1
  44. package/vendor/core/dist/classify-error.d.ts +3 -4
  45. package/vendor/core/dist/classify-error.js +8 -8
  46. package/vendor/core/dist/connector-query-errors.d.ts +6 -0
  47. package/vendor/core/dist/connector-query-errors.js +4 -0
  48. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +17 -1
  49. package/vendor/core/dist/contracts/tools/collection-presentation.js +27 -3
  50. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +39 -0
  51. package/vendor/core/dist/contracts/tools/manage-automations.js +11 -1
  52. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
  53. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +2 -0
  54. package/vendor/core/dist/contracts/tools/manage-entity.js +7 -0
  55. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +2 -0
  56. package/vendor/core/dist/contracts/tools/manage-feeds.js +3 -0
  57. package/vendor/core/dist/contracts/tools/manage-views.d.ts +249 -7
  58. package/vendor/core/dist/contracts/tools/manage-views.js +83 -21
  59. package/vendor/core/dist/contracts/tools/navigation.d.ts +248 -0
  60. package/vendor/core/dist/contracts/tools/navigation.js +284 -0
  61. package/vendor/core/dist/contracts/tools/view-attach.d.ts +7 -0
  62. package/vendor/core/dist/contracts/tools/view-attach.js +15 -0
  63. package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +4 -1
  64. package/vendor/core/dist/contracts/tools/view-content-hash.js +4 -2
  65. package/vendor/core/dist/contracts/tools/view-definition.d.ts +2 -0
  66. package/vendor/core/dist/contracts/tools/view-definition.js +52 -0
  67. package/vendor/core/dist/contracts/tools/view-host.d.ts +68 -0
  68. package/vendor/core/dist/contracts/tools/view-host.js +30 -1
  69. package/vendor/core/dist/contracts/tools/view-scope.d.ts +31 -0
  70. package/vendor/core/dist/contracts/tools/view-scope.js +45 -0
  71. package/vendor/core/dist/error-report.js +1 -0
  72. package/vendor/core/dist/errors.d.ts +17 -24
  73. package/vendor/core/dist/errors.js +17 -24
  74. package/vendor/core/dist/types.d.ts +0 -6
  75. package/vendor/core/package.json +11 -1
  76. package/vendor/views/dist/api.d.ts +30 -5
  77. package/vendor/views/dist/api.js +22 -8
  78. package/vendor/views/dist/bridge.d.ts +17 -0
  79. package/vendor/views/dist/bridge.js +49 -1
  80. package/vendor/views/dist/components.d.ts +27 -5
  81. package/vendor/views/dist/components.js +57 -7
  82. package/vendor/views/dist/embed.d.ts +98 -0
  83. package/vendor/views/dist/embed.js +418 -0
  84. package/vendor/views/dist/index.d.ts +3 -1
  85. package/vendor/views/dist/index.js +1 -0
  86. package/vendor/views/package.json +1 -1
  87. package/vendor/cli/dist/connectors/linkedin-takeout.ts +0 -577
  88. package/vendor/cli/dist/connectors/takeout-utils.ts +0 -240
@@ -621,6 +621,20 @@ export function xDirectMessagesProgram() {
621
621
  fail("Unable to attach source subscription");
622
622
  return { listening: true };
623
623
  }
624
+ // X serves at most 50 entries per notifications page (`count=50`); the
625
+ // cap leaves room for a page grown by a replacement instruction.
626
+ const PAGE_ROWS_MAX = 200;
627
+ // A short row-identity hash for the in-page cursor: a page's returned set
628
+ // stays well under the 10,000-character cursor bound.
629
+ async function rowKey(id) {
630
+ const hash = await crypto.subtle.digest(
631
+ "SHA-256",
632
+ new TextEncoder().encode(id),
633
+ );
634
+ return Array.from(new Uint8Array(hash).slice(0, 6), (x) =>
635
+ x.toString(16).padStart(2, "0"),
636
+ ).join("");
637
+ }
624
638
  // The notification API is read from this same neutral page. In particular,
625
639
  // never render /notifications or call its seen/read-state endpoints here.
626
640
  async function readNotifications(input) {
@@ -635,13 +649,32 @@ export function xDirectMessagesProgram() {
635
649
  fail("Invalid notification cursor");
636
650
  cursor = JSON.parse(input.cursor);
637
651
  if (
638
- cursor.v !== 1 ||
652
+ ![1, 2].includes(cursor.v) ||
639
653
  cursor.kind !== "notifications" ||
640
654
  cursor.account !== self ||
641
- !(cursor.source === null || typeof cursor.source === "string") ||
642
- !(cursor.after === null || typeof cursor.after === "string")
655
+ !(cursor.source === null || typeof cursor.source === "string")
643
656
  )
644
657
  fail("Notification cursor belongs to another account or source");
658
+ // v1 boundary cursors persist in sync checkpoints and equal a v2
659
+ // cursor with nothing returned yet. A v1 cursor inside a source page
660
+ // anchored on one row, which X can re-key; that read must restart.
661
+ if (cursor.v === 1) {
662
+ if (cursor.after !== null) {
663
+ account(self);
664
+ if (input.restartExpired)
665
+ return { rows: [], account_id: self, expired: true };
666
+ fail(
667
+ "Notification cursor format changed; restart the read (coverage incomplete)",
668
+ );
669
+ }
670
+ cursor = { ...cursor, returned: [] };
671
+ }
672
+ if (
673
+ !Array.isArray(cursor.returned) ||
674
+ cursor.returned.length > PAGE_ROWS_MAX ||
675
+ !cursor.returned.every((x) => typeof x === "string" && x.length === 12)
676
+ )
677
+ fail("Invalid notification cursor");
645
678
  }
646
679
  const path =
647
680
  "/i/api/2/notifications/all.json?count=50" +
@@ -760,39 +793,40 @@ export function xDirectMessagesProgram() {
760
793
  if (input.metadataOnly) delete row.text;
761
794
  all.push(row);
762
795
  }
763
- let start = 0;
764
- if (cursor?.after) {
765
- start = all.findIndex((row) => row.id === cursor.after) + 1;
766
- if (!start) {
767
- account(self);
768
- if (input.restartExpired)
769
- return { rows: [], account_id: self, expired: true };
770
- fail(
771
- "Notification page changed; restart the read (coverage incomplete)",
772
- );
773
- }
774
- }
775
- const rows = all.slice(start, start + limit);
776
- const moreInPage = start + rows.length < all.length;
796
+ // Resume by excluding rows already returned from this source page, not
797
+ // by anchoring on one row: X regroups its newest page between reads
798
+ // (re-keying, dropping, or reordering grouped reactions). A re-keyed
799
+ // row may come back as a duplicate reference, deduped by origin_id;
800
+ // no row is ever skipped.
801
+ const returned = new Set(cursor?.returned ?? []);
802
+ const keys = [];
803
+ for (const row of all) keys.push(await rowKey(row.id));
804
+ const remaining = all.filter((_, index) => !returned.has(keys[index]));
805
+ const rows = remaining.slice(0, limit);
806
+ const moreInPage = rows.length < remaining.length;
777
807
  if (!moreInPage && cursor && next === cursor.source) {
778
808
  if (all.length) fail("Notification cursor did not advance");
779
809
  next = undefined;
780
810
  }
811
+ // Keep only keys still on the page, so the set stays page-bounded.
812
+ const sent = new Set(rows.map((row) => row.id));
781
813
  const nextCursor = moreInPage
782
814
  ? JSON.stringify({
783
- v: 1,
815
+ v: 2,
784
816
  kind: "notifications",
785
817
  account: self,
786
818
  source: cursor?.source ?? null,
787
- after: rows.at(-1).id,
819
+ returned: keys.filter(
820
+ (key, index) => returned.has(key) || sent.has(all[index].id),
821
+ ),
788
822
  })
789
823
  : next
790
824
  ? JSON.stringify({
791
- v: 1,
825
+ v: 2,
792
826
  kind: "notifications",
793
827
  account: self,
794
828
  source: next,
795
- after: null,
829
+ returned: [],
796
830
  })
797
831
  : undefined;
798
832
  if (account() !== self)
@@ -3876,7 +3876,7 @@ export default class XConnector extends ConnectorRuntime {
3876
3876
  name: "X (Twitter)",
3877
3877
  description:
3878
3878
  "Fetches tweets, browser-visible like history, bookmarks, and DMs through the X API v2 or the paired Owletto Chrome extension, reads the chronological Following timeline live through the X API, captures notification references and the accounts you follow, reads and answers DMs live in the paired browser, and likes posts or follows accounts there. Links social actors into the person and company graph.",
3879
- version: "3.17.1",
3879
+ version: "3.17.2",
3880
3880
  faviconDomain: "x.com",
3881
3881
  browser: {
3882
3882
  origins: ["https://x.com", "https://twitter.com"],
@@ -5,7 +5,7 @@
5
5
  "server": "dist/server.bundle.mjs",
6
6
  "embeddingsServer": "dist/embeddings-server.mjs"
7
7
  },
8
- "version": "24.7.0",
8
+ "version": "24.9.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.7.0",
19
+ "version": "24.9.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.7.0",
27
+ "version": "24.9.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.7.0",
35
+ "version": "24.9.0",
36
36
  "verify": "dist/verify.mjs"
37
37
  }
38
38
  }
@@ -227,7 +227,7 @@ const gh = defineConnection({
227
227
  `google.gmail`, not `gmail` or `google_gmail`): `github`, `slack`, `linear`, `jira`, `google.gmail`,
228
228
  `google.calendar`, `google.drive`, `microsoft.outlook`, `discord`, `teams`, `telegram`, `tiktok.web`, `webhook`,
229
229
  `whatsapp`, `whatsapp.web`, `gchat`, `rss`, `postgres`,
230
- `hackernews`, `herdr`, `linkedin`, `market.quotes`, `reddit`, `x`, `youtube`, `producthunt`, `agentid`.
230
+ `hackernews`, `herdr`, `imessage`, `linkedin`, `market.quotes`, `reddit`, `x`, `youtube`, `producthunt`, `agentid`.
231
231
 
232
232
  Device connectors are not in that list: they are advertised by the device at
233
233
  poll time and appear after it grants permission. `os.shell` is one of them —
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/cli",
3
- "version": "24.7.0",
3
+ "version": "24.9.0",
4
4
  "description": "CLI for deploying and managing AI agents on Lobu",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -42,6 +42,7 @@ export interface ConnectorDefinition {
42
42
  queryCapabilities?: {
43
43
  exactMatch?: boolean;
44
44
  verbatimExactMatch?: boolean;
45
+ exactMatchAny?: boolean;
45
46
  selection?: boolean;
46
47
  };
47
48
  /** Connector-normalized events that can activate Automations. */
@@ -74,6 +75,8 @@ export interface ConnectorDefinition {
74
75
  includeOperations?: string[];
75
76
  excludeOperations?: string[];
76
77
  includeTags?: string[];
78
+ /** HTTP methods to expose (e.g. `['get']` for a read-only surface). */
79
+ includeMethods?: string[];
77
80
  serverUrl?: string;
78
81
  };
79
82
  /**
@@ -338,6 +341,16 @@ export interface ConnectorAuthEnvField {
338
341
  example?: string;
339
342
  secret?: boolean;
340
343
  required?: boolean;
344
+ /**
345
+ * Send this field as the HTTP credential for generated `openapiConfig`
346
+ * operations (and MCP upstreams) when the connection authenticates with this
347
+ * env method: `<header>: <scheme> <value>`. Defaults: header `Authorization`,
348
+ * scheme `Bearer`. At most one env field per connector may set it.
349
+ */
350
+ httpCredential?: {
351
+ header?: string;
352
+ scheme?: string;
353
+ };
341
354
  }
342
355
  export interface ConnectorAuthEnvKeys {
343
356
  type: 'env_keys';
@@ -1118,12 +1131,20 @@ export interface QueryContext<F = Record<string, unknown>> {
1118
1131
  * connector, which owns its source dialect. Requires queryCapabilities.exactMatch.
1119
1132
  * `verbatim: true` preserves the scalar string without trimming and additionally
1120
1133
  * requires queryCapabilities.verbatimExactMatch. The default stays trimmed.
1134
+ * Exactly one of `value` / `values` is set. `values` (1-500 strings) keeps a
1135
+ * row whose key equals ANY of them, under the same per-column semantics as
1136
+ * `value`, and additionally requires queryCapabilities.exactMatchAny.
1121
1137
  */
1122
1138
  exactMatch?: {
1123
1139
  columns: string[];
1124
- value: string;
1125
1140
  verbatim?: boolean;
1126
- };
1141
+ } & ({
1142
+ value: string;
1143
+ values?: never;
1144
+ } | {
1145
+ values: string[];
1146
+ value?: never;
1147
+ });
1127
1148
  /**
1128
1149
  * Shared collection predicates, applied before sorting and pagination.
1129
1150
  * Search is a literal case-insensitive substring of the projected name.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/connector-sdk",
3
- "version": "24.7.0",
3
+ "version": "24.9.0",
4
4
  "description": "Lobu memory SDK — build pluggable connectors for Lobu memory",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -153,10 +153,13 @@ function drain(stream, capBytes) {
153
153
  * for deterministic account limits. Generic stream errors remain owned by the
154
154
  * CLI and its own retry loop.
155
155
  *
156
- * The wording accepted here must stay a subset of what the server's
157
- * `deviceProviderQuotaResetNotBefore` recognizes as quota evidence. Killing a
158
- * run the server will not park just moves the same failure to the next cron
159
- * tick, which is the waste this path exists to stop.
156
+ * OpenCode keeps retrying an account limit for the provider's whole reset
157
+ * window, so the run would otherwise burn its wall clock before failing.
158
+ * Accept only wording no in-run retry can clear: an empty balance, or a
159
+ * daily/weekly/monthly usage window that resets hours or more away. A short
160
+ * rate limit stays with the CLI, whose own retry may still finish the run.
161
+ * The relayed reason must still classify as provider quota in core's
162
+ * `classifyErrorMessage`, so the failed run is not blamed on the agent.
160
163
  */
161
164
  function openCodeTerminalRetryDiagnostic(output) {
162
165
  const lines = output.split(/\r?\n/);
@@ -37,5 +37,20 @@ export declare function connectorRunEnv(opts: {
37
37
  organizationSupplied: boolean;
38
38
  cloud: boolean;
39
39
  }): Record<string, string | undefined>;
40
+ /**
41
+ * The operator's `LOBU_HTTP_EGRESS_ALLOW_HOSTS`: comma-separated EXACT hosts a
42
+ * connector's `fetch` may reach even though they resolve into private space
43
+ * (another container on a self-hosted Docker network). Read here, from this
44
+ * process's env, by every producer of a connector run's `job.env` -- this
45
+ * whitelist (worker daemon, in-gateway runs) and the gateway's source-read,
46
+ * pushdown and listener paths. The isolate host is the one place that honours
47
+ * it, and only for a run whose `LOBU_DB_EGRESS_POLICY` is `allow-private`, so
48
+ * under Cloud (block-private, which the gateway's poll response forces onto any
49
+ * worker) it is inert. Never the DB socket list: that is
50
+ * `LOBU_DB_EGRESS_ALLOW_HOSTS`, a separate boundary.
51
+ */
52
+ export declare function httpEgressAllowHostsEnv(): {
53
+ LOBU_HTTP_EGRESS_ALLOW_HOSTS?: string;
54
+ };
40
55
  export declare function buildConnectorWorkerEnv(): Env;
41
56
  //# sourceMappingURL=env.d.ts.map
@@ -53,6 +53,22 @@ export function connectorRunEnv(opts) {
53
53
  const env = buildConnectorWorkerEnv();
54
54
  return { ...(opts.cloud && opts.organizationSupplied ? withoutDeploymentProviderKeys(env) : env) };
55
55
  }
56
+ /**
57
+ * The operator's `LOBU_HTTP_EGRESS_ALLOW_HOSTS`: comma-separated EXACT hosts a
58
+ * connector's `fetch` may reach even though they resolve into private space
59
+ * (another container on a self-hosted Docker network). Read here, from this
60
+ * process's env, by every producer of a connector run's `job.env` -- this
61
+ * whitelist (worker daemon, in-gateway runs) and the gateway's source-read,
62
+ * pushdown and listener paths. The isolate host is the one place that honours
63
+ * it, and only for a run whose `LOBU_DB_EGRESS_POLICY` is `allow-private`, so
64
+ * under Cloud (block-private, which the gateway's poll response forces onto any
65
+ * worker) it is inert. Never the DB socket list: that is
66
+ * `LOBU_DB_EGRESS_ALLOW_HOSTS`, a separate boundary.
67
+ */
68
+ export function httpEgressAllowHostsEnv() {
69
+ const hosts = process.env.LOBU_HTTP_EGRESS_ALLOW_HOSTS;
70
+ return hosts ? { LOBU_HTTP_EGRESS_ALLOW_HOSTS: hosts } : {};
71
+ }
56
72
  export function buildConnectorWorkerEnv() {
57
73
  return {
58
74
  ENVIRONMENT: process.env.ENVIRONMENT || 'production',
@@ -77,6 +93,7 @@ export function buildConnectorWorkerEnv() {
77
93
  // for a DB socket under block-private (`socketOpen` in `executor/isolate.ts`);
78
94
  // self-hosted (allow-private) reaches its own private DB.
79
95
  LOBU_DB_EGRESS_POLICY: cloudModeOn() ? 'block-private' : 'allow-private',
96
+ ...httpEgressAllowHostsEnv(),
80
97
  };
81
98
  }
82
99
  //# sourceMappingURL=env.js.map
@@ -53,7 +53,9 @@ export interface IsolateExecutorOptions {
53
53
  * internal addresses are refused under every list except where an EXACT
54
54
  * entry names one: `localhost` or `127.0.0.1` is how a self-hosted install
55
55
  * reaches its own services and how the fixture suites reach a loopback
56
- * server; even that exemption keeps cloud metadata refused. Raw sockets do
56
+ * server; even that exemption keeps cloud metadata refused. Off cloud the
57
+ * operator's `LOBU_HTTP_EGRESS_ALLOW_HOSTS` adds exemptions of the same kind
58
+ * for `fetch` (`operatorHttpExemptHosts`), never entries. Raw sockets do
57
59
  * NOT inherit it: a DB socket's address policy is `LOBU_DB_EGRESS_POLICY`
58
60
  * plus the operator's `LOBU_DB_EGRESS_ALLOW_HOSTS`, so this list can only
59
61
  * ever narrow what a run reaches, never widen the DB boundary.
@@ -223,6 +223,9 @@ const GUEST_RUNNER = String.raw `
223
223
  if (job.exactMatch && job.exactMatch.verbatim === true && !(queryCapabilities && queryCapabilities.verbatimExactMatch === true)) {
224
224
  throw Object.assign(new Error('Connector does not support verbatim exact-match queries'), { status: 400 });
225
225
  }
226
+ if (job.exactMatch && job.exactMatch.values !== undefined && !(queryCapabilities && queryCapabilities.exactMatchAny === true)) {
227
+ throw Object.assign(new Error('Connector does not support multi-value exact-match queries'), { status: 400 });
228
+ }
226
229
  var queryResult = await instance.query({
227
230
  query: job.query, config: mergedConfig, credentials: job.credentials, sessionState: job.sessionState,
228
231
  limit: job.limit, offset: job.offset, sort: job.sort, exactMatch: job.exactMatch, selection: supportsSelection ? job.selection : undefined
@@ -395,6 +398,25 @@ function refusedAddress(error) {
395
398
  return '';
396
399
  return null;
397
400
  }
401
+ /**
402
+ * The operator's `fetch` exemptions for one run: `LOBU_HTTP_EGRESS_ALLOW_HOSTS`
403
+ * (see `httpEgressAllowHostsEnv` in `env.ts`), the exact hosts a self-hosted
404
+ * install lets connector code reach in private space -- another container on
405
+ * its Docker network. Read from `job.env`, the run producer's deployment
406
+ * config, never from tenant `job.config`; and only for a run whose env says
407
+ * `allow-private`: under block-private (Cloud, which the gateway forces onto
408
+ * any worker it dispatches to) or a job that names no policy (offline webhook
409
+ * normalization) the list is inert, and an agent turn never gets one. Parsed
410
+ * by the DB list's parser, so a wildcard, CIDR, port or bracketed entry refuses
411
+ * the run rather than widening it. Address axis only: the run's allowlist
412
+ * still decides which hosts it may name, and metadata stays refused at the
413
+ * `allow-private` floor these hosts are lowered to.
414
+ */
415
+ function operatorHttpExemptHosts(job) {
416
+ if (job.mode === 'agent_turn' || job.env?.LOBU_DB_EGRESS_POLICY !== 'allow-private')
417
+ return [];
418
+ return parseExemptHosts(job.env.LOBU_HTTP_EGRESS_ALLOW_HOSTS, 'LOBU_HTTP_EGRESS_ALLOW_HOSTS').map((host) => stripIpv6Brackets(normalizeDomainPattern(host)));
419
+ }
398
420
  /** Request headers that must not follow a redirect to another origin. */
399
421
  const CROSS_ORIGIN_SENSITIVE_HEADERS = new Set(['authorization', 'cookie', 'proxy-authorization']);
400
422
  /** Same text the guest `fetch` uses, so both rejections read alike. */
@@ -459,6 +481,7 @@ export class IsolateExecutor {
459
481
  throw new Error('HTTP authentication requires a gateway fetch hook');
460
482
  }
461
483
  assertIsolateEligible(compiledCode);
484
+ const exemptHosts = [...this.exactAllowedHosts, ...operatorHttpExemptHosts(job)];
462
485
  const ivm = await this.requireIsolatedVm();
463
486
  const tail = new RingBuffer(STREAM_TAIL_CAP_BYTES);
464
487
  let logBytesUsed = 0;
@@ -482,10 +505,10 @@ export class IsolateExecutor {
482
505
  activeFetches.clear();
483
506
  };
484
507
  // 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 });
508
+ // entries and the operator's HTTP exemptions lowered to the allow-private
509
+ // floor. One per run and destroyed with it, so a worker that builds an
510
+ // executor per job never accumulates idle keep-alive sockets.
511
+ const egress = new EgressDispatcher({ exemptHosts, lookup: this.options.lookup });
489
512
  // The run's credential vault: the guest gets placeholders, the host keeps
490
513
  // the values and resolves them into request headers at `fetch`. Cleared
491
514
  // with the run, so a placeholder that leaks into a checkpoint or a log is
@@ -598,7 +621,7 @@ export class IsolateExecutor {
598
621
  return undefined;
599
622
  };
600
623
  const network = {
601
- egress, vault, spends: new Set(), log,
624
+ egress, exemptHosts, vault, spends: new Set(), log,
602
625
  onHttpFetch: job.httpAuth ? hooks?.onHttpFetch : undefined,
603
626
  ...(job.mode === 'agent_turn' && job.credentials?.accessToken ? {
604
627
  agentGateway: {
@@ -1175,8 +1198,9 @@ export class IsolateExecutor {
1175
1198
  // Placeholders resolve only now, with the destination admitted, and only
1176
1199
  // into a destination that may carry a credential: HTTPS, or the run's
1177
1200
  // 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
1201
+ // allowlist or the operator's HTTP exemptions name exactly, the same
1202
+ // exemption that lets a self-hosted install or a fixture reach a local
1203
+ // service. A public name, or a private service NAME, stays HTTPS
1180
1204
  // only even when named exactly. Real values exist in `headers` from here
1181
1205
  // on and nowhere the guest can read. A refusal is the lane's egress
1182
1206
  // refusal: logged once host-side and named so the guest can tell it
@@ -1185,7 +1209,7 @@ export class IsolateExecutor {
1185
1209
  let spent;
1186
1210
  try {
1187
1211
  spent = net.vault.swapHeaders(headers, url, {
1188
- plaintextAllowed: this.exactAllowedHosts.includes(bareHost) && (bareHost === 'localhost' || isReservedIp(bareHost)),
1212
+ plaintextAllowed: net.exemptHosts.includes(bareHost) && (bareHost === 'localhost' || isReservedIp(bareHost)),
1189
1213
  });
1190
1214
  }
1191
1215
  catch (error) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/connector-worker",
3
- "version": "24.7.0",
3
+ "version": "24.9.0",
4
4
  "description": "Self-hosted worker for Lobu memory — connectors and embedding generation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -5,10 +5,9 @@
5
5
  * `AgentErrorCode`. Every other layer consumes this rather than growing its
6
6
  * own regex, and three of them act on the result:
7
7
  *
8
- * - `providerQuotaResetNotBefore` (automations/schedule-cursor.ts) returns
9
- * `null` unless the code is `PROVIDER_QUOTA_EXHAUSTED`, so an unclassified
10
- * quota trip never parks the Automation until the provider's reset — it
11
- * keeps firing on schedule against an exhausted quota.
8
+ * - `classifyRunOutcome` (server runs/run-outcome.ts) stamps a classified
9
+ * failure `infra_error`; an unclassified provider refusal is blamed on the
10
+ * agent as `agent_error`.
12
11
  * - `response-renderer.ts` and `chat-response-bridge.ts` resolve the code to
13
12
  * a remediation CTA; with none, the user gets the provider's raw prose.
14
13
  * - An unclassified failure also misses the `PROVIDER_*` Sentry alerting.
@@ -6,10 +6,9 @@
6
6
  * `AgentErrorCode`. Every other layer consumes this rather than growing its
7
7
  * own regex, and three of them act on the result:
8
8
  *
9
- * - `providerQuotaResetNotBefore` (automations/schedule-cursor.ts) returns
10
- * `null` unless the code is `PROVIDER_QUOTA_EXHAUSTED`, so an unclassified
11
- * quota trip never parks the Automation until the provider's reset — it
12
- * keeps firing on schedule against an exhausted quota.
9
+ * - `classifyRunOutcome` (server runs/run-outcome.ts) stamps a classified
10
+ * failure `infra_error`; an unclassified provider refusal is blamed on the
11
+ * agent as `agent_error`.
13
12
  * - `response-renderer.ts` and `chat-response-bridge.ts` resolve the code to
14
13
  * a remediation CTA; with none, the user gets the provider's raw prose.
15
14
  * - An unclassified failure also misses the `PROVIDER_*` Sentry alerting.
@@ -86,10 +85,11 @@ function classifyErrorMessage(message) {
86
85
  // dodged the PROVIDER_* alert.
87
86
  //
88
87
  // It belongs HERE and not in `PROVIDER_BALANCE_EXHAUSTED` above: a
89
- // subscription usage limit is WINDOWED — the provider names its own reset,
90
- // hours or days out — while that union parks an Automation for a flat day
91
- // regardless. Parking a windowed limit on a balance schedule would be a
92
- // worse bug than the one this fixes.
88
+ // subscription usage limit is WINDOWED — it clears on the provider's own
89
+ // reset — while that union means the account cannot spend until someone tops
90
+ // it up. The device daemon stops a retrying OpenCode run on balance wording
91
+ // alone, so a windowed limit in that union would cut short a run the CLI's
92
+ // own retry could still finish.
93
93
  if (errors_js_1.PROVIDER_WINDOWED_QUOTA.test(message))
94
94
  return errors_js_1.AgentErrorCode.PROVIDER_QUOTA_EXHAUSTED;
95
95
  // Gemini can end a turn with this provider-side tool-call rejection instead
@@ -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.",
@@ -40,6 +40,11 @@ declare const PresetSchema: import("@sinclair/typebox").TObject<{
40
40
  toDays: import("@sinclair/typebox").TInteger;
41
41
  timeZone: import("@sinclair/typebox").TString;
42
42
  }>>;
43
+ /** Adds `{ field, op: "eq", value: <signed-in user's email> }`. Only a
44
+ * filter: read access is still enforced server-side. */
45
+ viewer: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
46
+ field: import("@sinclair/typebox").TString;
47
+ }>>;
43
48
  }>;
44
49
  export declare const CollectionPresentationSchema: import("@sinclair/typebox").TObject<{
45
50
  presets: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
@@ -71,6 +76,11 @@ export declare const CollectionPresentationSchema: import("@sinclair/typebox").T
71
76
  toDays: import("@sinclair/typebox").TInteger;
72
77
  timeZone: import("@sinclair/typebox").TString;
73
78
  }>>;
79
+ /** Adds `{ field, op: "eq", value: <signed-in user's email> }`. Only a
80
+ * filter: read access is still enforced server-side. */
81
+ viewer: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
82
+ field: import("@sinclair/typebox").TString;
83
+ }>>;
74
84
  }>>>;
75
85
  table: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
76
86
  columns: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
@@ -88,6 +98,12 @@ export type CollectionPresentation = Static<typeof CollectionPresentationSchema>
88
98
  export type CollectionPreset = Static<typeof PresetSchema>;
89
99
  export type CollectionTable = Static<typeof TableSchema>;
90
100
  export declare function parseCollectionPresentation(raw: unknown): CollectionPresentation;
91
- export declare function resolveCollectionPreset(preset: CollectionPreset, now?: Date): CollectionSelection;
101
+ /**
102
+ * The preset as a concrete selection. A viewer preset needs the signed-in
103
+ * viewer and throws without one, so it never widens to every row.
104
+ */
105
+ export declare function resolveCollectionPreset(preset: CollectionPreset, now?: Date, viewer?: {
106
+ email: string;
107
+ }): CollectionSelection;
92
108
  export {};
93
109
  //# sourceMappingURL=collection-presentation.d.ts.map
@@ -32,6 +32,9 @@ const PresetSchema = typebox_1.Type.Object({
32
32
  toDays: typebox_1.Type.Integer({ minimum: -3660, maximum: 3660 }),
33
33
  timeZone: typebox_1.Type.String({ minLength: 1, maxLength: 100 }),
34
34
  }, { additionalProperties: false })),
35
+ /** Adds `{ field, op: "eq", value: <signed-in user's email> }`. Only a
36
+ * filter: read access is still enforced server-side. */
37
+ viewer: typebox_1.Type.Optional(typebox_1.Type.Object({ field: Field }, { additionalProperties: false })),
35
38
  }, { additionalProperties: false });
36
39
  exports.CollectionPresentationSchema = typebox_1.Type.Object({
37
40
  presets: typebox_1.Type.Optional(typebox_1.Type.Array(PresetSchema, { maxItems: 32 })),
@@ -41,6 +44,7 @@ exports.CollectionPresentationSchema = typebox_1.Type.Object({
41
44
  * Both calls run as the viewer; this binding grants no source access. */
42
45
  facetQuery: typebox_1.Type.Optional(typebox_1.Type.String({ minLength: 1, maxLength: 64000 })),
43
46
  }, { additionalProperties: false });
47
+ const MAX_FILTERS = collection_selection_1.AttributeFiltersSchema.maxItems ?? 32;
44
48
  function parseCollectionPresentation(raw) {
45
49
  if (!value_1.Value.Check(exports.CollectionPresentationSchema, raw))
46
50
  throw new Error("Invalid collection presentation configuration");
@@ -49,9 +53,13 @@ function parseCollectionPresentation(raw) {
49
53
  if (keys.has(preset.key))
50
54
  throw new Error(`Duplicate collection preset: ${preset.key}`);
51
55
  keys.add(preset.key);
56
+ // The resolved selection must still fit the selection contract.
57
+ if ((preset.selection.filters?.length ?? 0) +
58
+ (preset.viewer ? 1 : 0) +
59
+ (preset.relativeDate ? 2 : 0) >
60
+ MAX_FILTERS)
61
+ throw new Error(`Collection preset ${preset.key} resolves to more than ${MAX_FILTERS} filters`);
52
62
  if (preset.relativeDate) {
53
- if ((preset.selection.filters?.length ?? 0) > 30)
54
- throw new Error("Relative date presets support at most 30 other filters");
55
63
  if (preset.relativeDate.fromDays > preset.relativeDate.toDays)
56
64
  throw new Error("Relative date range is reversed");
57
65
  // Intl validates IANA timezone names, including UTC.
@@ -62,8 +70,24 @@ function parseCollectionPresentation(raw) {
62
70
  }
63
71
  return raw;
64
72
  }
65
- function resolveCollectionPreset(preset, now = new Date()) {
73
+ /**
74
+ * The preset as a concrete selection. A viewer preset needs the signed-in
75
+ * viewer and throws without one, so it never widens to every row.
76
+ */
77
+ function resolveCollectionPreset(preset, now = new Date(), viewer) {
66
78
  const selection = structuredClone(preset.selection);
79
+ if (preset.viewer) {
80
+ if (!viewer?.email)
81
+ throw new Error(`Collection preset ${preset.key} needs a signed-in viewer`);
82
+ selection.filters = [
83
+ ...(selection.filters ?? []),
84
+ {
85
+ field: preset.viewer.field,
86
+ op: "eq",
87
+ value: viewer.email.toLowerCase(),
88
+ },
89
+ ];
90
+ }
67
91
  if (!preset.relativeDate)
68
92
  return selection;
69
93
  const { field, fromDays, toDays, timeZone } = preset.relativeDate;