@lobu/runtime-device 21.1.0 → 21.2.1

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 (57) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +12 -12
  3. package/npm-shrinkwrap.json +51 -51
  4. package/package.json +1 -1
  5. package/vendor/cli/dist/commands/_lib/apply/client.js +4 -1
  6. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +1 -1
  7. package/vendor/cli/dist/commands/_lib/apply/diff.js +0 -1
  8. package/vendor/cli/dist/commands/_lib/apply/map-config.js +0 -5
  9. package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +2 -7
  10. package/vendor/cli/dist/commands/chat.d.ts +0 -1
  11. package/vendor/cli/dist/commands/chat.js +3 -65
  12. package/vendor/cli/dist/commands/memory/_lib/errors.d.ts +8 -0
  13. package/vendor/cli/dist/commands/memory/_lib/errors.js +12 -0
  14. package/vendor/cli/dist/commands/memory/_lib/mcp.js +3 -3
  15. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.d.ts +8 -0
  16. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +11 -3
  17. package/vendor/cli/dist/config/define.d.ts +0 -5
  18. package/vendor/cli/dist/config/define.js +27 -0
  19. package/vendor/cli/dist/connectors/README.md +6 -3
  20. package/vendor/cli/dist/connectors/github.ts +0 -6
  21. package/vendor/cli/dist/connectors/google_calendar.ts +0 -4
  22. package/vendor/cli/dist/connectors/google_drive.ts +0 -2
  23. package/vendor/cli/dist/connectors/google_gmail.ts +0 -6
  24. package/vendor/cli/dist/connectors/market_quotes.ts +0 -1
  25. package/vendor/cli/dist/connectors/microsoft_outlook.ts +0 -2
  26. package/vendor/cli/dist/connectors/postgres.ts +68 -3
  27. package/vendor/cli/dist/connectors/whatsapp_web.ts +2 -8
  28. package/vendor/cli/dist/connectors/x.ts +3 -9
  29. package/vendor/cli/dist/connectors/youtube.ts +0 -5
  30. package/vendor/cli/dist/index.js +0 -1
  31. package/vendor/cli/dist/runtime-components.json +4 -4
  32. package/vendor/cli/dist/templates/README.md.tmpl +1 -1
  33. package/vendor/cli/package.json +1 -1
  34. package/vendor/connector-sdk/dist/connector-runtime.d.ts +1 -1
  35. package/vendor/connector-sdk/dist/connector-runtime.js +1 -1
  36. package/vendor/connector-sdk/dist/connector-types.d.ts +14 -2
  37. package/vendor/connector-sdk/dist/define-connector.d.ts +3 -5
  38. package/vendor/connector-sdk/dist/define-connector.js +1 -1
  39. package/vendor/connector-sdk/dist/device-manifest.d.ts +0 -1
  40. package/vendor/connector-sdk/dist/extension-network.js +1 -2
  41. package/vendor/connector-sdk/package.json +1 -1
  42. package/vendor/connector-worker/dist/daemon/generated/headless-device-connector-manifests.json +1 -1
  43. package/vendor/connector-worker/dist/executor/interface.d.ts +2 -1
  44. package/vendor/connector-worker/dist/executor/isolate.js +4 -1
  45. package/vendor/connector-worker/package.json +1 -1
  46. package/vendor/core/dist/contracts/agent-settings.d.ts +0 -1
  47. package/vendor/core/dist/contracts/agent-settings.js +0 -1
  48. package/vendor/core/dist/contracts/tools/manage-classifiers.d.ts +6 -6
  49. package/vendor/core/dist/contracts/tools/manage-classifiers.js +4 -6
  50. package/vendor/core/dist/contracts/tools/manage-connections.d.ts +0 -1
  51. package/vendor/core/dist/contracts/tools/manage-connections.js +3 -4
  52. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +2 -2
  53. package/vendor/core/dist/contracts/tools/manage-entity.js +4 -2
  54. package/vendor/core/dist/logger.js +13 -2
  55. package/vendor/core/dist/worker/wire.d.ts +1 -6
  56. package/vendor/core/dist/worker/wire.js +1 -1
  57. package/vendor/core/package.json +1 -1
@@ -3,7 +3,7 @@ import { basename, dirname, join, resolve } from "node:path";
3
3
  import { parse as parseYaml } from "yaml";
4
4
  import { loadDesiredStateFromConfig } from "../../_lib/apply/desired-state.js";
5
5
  import { isPlatformOwnedRelationshipSlug } from "../../_lib/platform-owned-types.js";
6
- import { ApiError, ValidationError } from "./errors.js";
6
+ import { ApiError, ValidationError, wrongHostHint } from "./errors.js";
7
7
  import { getSessionForOrg, getUsableToken, mcpUrlForOrg, orgFromMcpUrl, resolveOrg, resolveServerUrl, } from "./memory-auth.js";
8
8
  import { printError, printText } from "../../../internal/output.js";
9
9
  import { validateDataRecord, } from "./schema.js";
@@ -82,7 +82,7 @@ function deriveApiBaseUrl(mcpUrl) {
82
82
  url.hash = "";
83
83
  return url.toString().replace(/\/+$/, "");
84
84
  }
85
- async function callTool(ctx, toolName, args) {
85
+ export async function callTool(ctx, toolName, args) {
86
86
  const url = `${ctx.apiBaseUrl}/api/${ctx.orgSlug}/${toolName}`;
87
87
  const res = await fetch(url, {
88
88
  method: "POST",
@@ -98,7 +98,15 @@ async function callTool(ctx, toolName, args) {
98
98
  parsed = JSON.parse(body);
99
99
  }
100
100
  catch {
101
- throw new ApiError(`Invalid JSON from ${toolName}: ${body}`, res.status);
101
+ // An empty or non-JSON body is most often a wrong-host answer (405/404 from
102
+ // a host that does not serve the tool API). Name the URL and status so the
103
+ // failure is diagnosable instead of a bare "Invalid JSON".
104
+ const detail = body.trim()
105
+ ? body.slice(0, 500)
106
+ : `HTTP ${res.status} ${res.statusText}`.trim();
107
+ throw new ApiError(res.ok
108
+ ? `Invalid JSON from ${toolName} via ${url}: ${detail}`
109
+ : `${toolName} failed via ${url}: ${detail}${wrongHostHint(res.status)}`, res.status);
102
110
  }
103
111
  if (!res.ok) {
104
112
  const msg = typeof parsed.error === "string" ? parsed.error : `HTTP ${res.status}`;
@@ -702,11 +702,6 @@ export interface NetworkConfig {
702
702
  }
703
703
  /** Worker-side tool permissions. */
704
704
  export interface ToolsConfig {
705
- /**
706
- * MCP tool grant patterns pre-approved by the operator (e.g.
707
- * `/mcp/gmail/tools/send_email`), bypassing the in-chat approval card.
708
- */
709
- preApproved?: string[];
710
705
  allowed?: string[];
711
706
  denied?: string[];
712
707
  /** Reject tool calls that aren't in `allowed`. */
@@ -70,7 +70,31 @@ function deriveRequired(required, properties) {
70
70
  .map(([key]) => key);
71
71
  return derived.length > 0 ? derived : undefined;
72
72
  }
73
+ /**
74
+ * Config files are evaluated without typechecking, so a wrongly-typed or empty
75
+ * field would flow through `lobu validate` as valid and only surface (or not)
76
+ * at apply time. Refuse it where the declaration is built, with the field name.
77
+ */
78
+ function assertEntityTypeShape(config) {
79
+ const c = config;
80
+ const key = c?.key;
81
+ if (typeof key !== "string" || key.trim() === "") {
82
+ throw new Error(`defineEntityType: 'key' must be a non-empty string (got ${JSON.stringify(key)}).`);
83
+ }
84
+ for (const field of ["name", "description"]) {
85
+ const value = c?.[field];
86
+ if (value !== undefined && typeof value !== "string") {
87
+ throw new Error(`Entity type '${key}': '${field}' must be a string (got ${typeof value}).`);
88
+ }
89
+ }
90
+ const required = c?.required;
91
+ if (required !== undefined &&
92
+ (!Array.isArray(required) || required.some((r) => typeof r !== "string"))) {
93
+ throw new Error(`Entity type '${key}': 'required' must be an array of property names (got ${Array.isArray(required) ? "a non-string entry" : typeof required}).`);
94
+ }
95
+ }
73
96
  export function defineEntityType(config) {
97
+ assertEntityTypeShape(config);
74
98
  const { required, properties, ...rest } = config;
75
99
  // View templates were retired with the server tool: a stale config must fail
76
100
  // loudly here, not silently drop the declaration or die later on a removed
@@ -239,6 +263,9 @@ export function context(query) {
239
263
  */
240
264
  export const UNRESOLVED_MODEL_SUFFIX = "__unresolved__";
241
265
  export function defineAgent(config) {
266
+ if (config.tools && "preApproved" in config.tools) {
267
+ throw new Error(`Agent '${config.id}' declares removed 'tools.preApproved'. Delete it from your config; connector approvals are managed in Settings → Policies.`);
268
+ }
242
269
  return { ...config, kind: "agent" };
243
270
  }
244
271
  /** Declare a skill inline — `content` is the body, the rest is JSON frontmatter. */
@@ -360,13 +360,16 @@ ad-hoc SQL and warehouse pushdown; configured feed reads belong on
360
360
 
361
361
  Actions let connectors write back to external services (e.g. create a GitHub
362
362
  issue). Define them in the `actions` record passed to `defineConnector`. The
363
- record key becomes the action key and `requiresApproval` defaults to `false`:
363
+ record key becomes the action key. Declare what the operation does; the
364
+ organization controls approval through Auto, Ask, or Block policies. An action
365
+ with no matching policy requires approval. A non-destructive hint does not grant
366
+ automatic execution:
364
367
 
365
368
  ```typescript
366
369
  interface ConnectorActionSpec {
367
370
  name: string; // Display name
368
371
  description?: string; // What this action does
369
- requiresApproval?: boolean; // Whether user must approve before execution
372
+ kind?: "read" | "write"; // Defaults to write
370
373
  inputSchema?: object; // JSON Schema for action input
371
374
  outputSchema?: object; // JSON Schema for action output
372
375
  annotations?: { // MCP tool annotations for client-side UX
@@ -385,7 +388,7 @@ actions: {
385
388
  create_issue: {
386
389
  name: 'Create Issue',
387
390
  description: 'Create a new issue in the repository.',
388
- requiresApproval: true,
391
+ kind: "write",
389
392
  annotations: {
390
393
  openWorldHint: true,
391
394
  idempotentHint: false,
@@ -789,7 +789,6 @@ export default class GitHubConnector extends ConnectorRuntime {
789
789
  key: 'create_issue',
790
790
  name: 'Create Issue',
791
791
  description: 'Create a new issue in the configured repository.',
792
- requiresApproval: true,
793
792
  inputSchema: {
794
793
  type: 'object',
795
794
  required: ['title'],
@@ -807,7 +806,6 @@ export default class GitHubConnector extends ConnectorRuntime {
807
806
  key: 'add_issue_comment',
808
807
  name: 'Add Issue Comment',
809
808
  description: 'Add a comment to an issue or pull request.',
810
- requiresApproval: true,
811
809
  inputSchema: {
812
810
  type: 'object',
813
811
  required: ['issue_number', 'body'],
@@ -823,7 +821,6 @@ export default class GitHubConnector extends ConnectorRuntime {
823
821
  key: 'close_issue',
824
822
  name: 'Close Issue',
825
823
  description: 'Close an issue by number.',
826
- requiresApproval: true,
827
824
  inputSchema: {
828
825
  type: 'object',
829
826
  required: ['issue_number'],
@@ -838,7 +835,6 @@ export default class GitHubConnector extends ConnectorRuntime {
838
835
  key: 'reopen_issue',
839
836
  name: 'Reopen Issue',
840
837
  description: 'Reopen an issue by number.',
841
- requiresApproval: true,
842
838
  inputSchema: {
843
839
  type: 'object',
844
840
  required: ['issue_number'],
@@ -853,7 +849,6 @@ export default class GitHubConnector extends ConnectorRuntime {
853
849
  key: 'create_pull_request',
854
850
  name: 'Create Pull Request',
855
851
  description: 'Create a pull request from head to base branch.',
856
- requiresApproval: true,
857
852
  inputSchema: {
858
853
  type: 'object',
859
854
  required: ['title', 'head', 'base'],
@@ -891,7 +886,6 @@ export default class GitHubConnector extends ConnectorRuntime {
891
886
  key: 'merge_pull_request',
892
887
  name: 'Merge Pull Request',
893
888
  description: 'Merge a pull request by number.',
894
- requiresApproval: true,
895
889
  annotations: {
896
890
  destructiveHint: true,
897
891
  },
@@ -277,7 +277,6 @@ export default class GoogleCalendarConnector extends ConnectorRuntime<Record<str
277
277
  key: 'create_event',
278
278
  name: 'Create Event',
279
279
  description: 'Create a new event on Google Calendar.',
280
- requiresApproval: true,
281
280
  requiredScopes: ['https://www.googleapis.com/auth/calendar.events'],
282
281
  inputSchema: {
283
282
  type: 'object',
@@ -303,7 +302,6 @@ export default class GoogleCalendarConnector extends ConnectorRuntime<Record<str
303
302
  key: 'update_event',
304
303
  name: 'Update Event',
305
304
  description: 'Update an existing calendar event.',
306
- requiresApproval: true,
307
305
  requiredScopes: ['https://www.googleapis.com/auth/calendar.events'],
308
306
  inputSchema: {
309
307
  type: 'object',
@@ -326,7 +324,6 @@ export default class GoogleCalendarConnector extends ConnectorRuntime<Record<str
326
324
  key: 'delete_event',
327
325
  name: 'Delete Event',
328
326
  description: 'Delete/cancel an event.',
329
- requiresApproval: true,
330
327
  annotations: {
331
328
  destructiveHint: true,
332
329
  },
@@ -346,7 +343,6 @@ export default class GoogleCalendarConnector extends ConnectorRuntime<Record<str
346
343
  get_event: {
347
344
  key: 'get_event',
348
345
  kind: 'read',
349
- requiresApproval: false,
350
346
  name: 'Get Event',
351
347
  description: 'Get full event details.',
352
348
  inputSchema: {
@@ -408,7 +408,6 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
408
408
  download_file: {
409
409
  key: 'download_file',
410
410
  kind: 'read',
411
- requiresApproval: false,
412
411
  name: 'Download File',
413
412
  description:
414
413
  'Download one Drive file. Google Docs/Sheets/Slides are exported (text/plain, CSV); everything else is downloaded as-is, binary included. The bytes are published as an attachment with a `download_url` a device can fetch, and small text files are ALSO returned inline as `content` so they can be read without a second call.',
@@ -428,7 +427,6 @@ export default class GoogleDriveConnector extends ConnectorRuntime<
428
427
  get_file: {
429
428
  key: 'get_file',
430
429
  kind: 'read',
431
- requiresApproval: false,
432
430
  name: 'Get File Metadata',
433
431
  description: 'Get one Drive file\'s metadata without fetching its content.',
434
432
  requiredScopes: ['https://www.googleapis.com/auth/drive.readonly'],
@@ -327,7 +327,6 @@ export default class GmailConnector extends ConnectorRuntime<GmailCheckpoint, Gm
327
327
  key: 'send_email',
328
328
  name: 'Send Email',
329
329
  description: 'Send an email via Gmail.',
330
- requiresApproval: true,
331
330
  inputSchema: {
332
331
  type: 'object',
333
332
  required: ['to', 'subject', 'body'],
@@ -344,7 +343,6 @@ export default class GmailConnector extends ConnectorRuntime<GmailCheckpoint, Gm
344
343
  key: 'create_draft',
345
344
  name: 'Create Draft',
346
345
  description: 'Create a draft email in Gmail.',
347
- requiresApproval: false,
348
346
  inputSchema: {
349
347
  type: 'object',
350
348
  required: ['to', 'subject', 'body'],
@@ -365,7 +363,6 @@ export default class GmailConnector extends ConnectorRuntime<GmailCheckpoint, Gm
365
363
  key: 'reply',
366
364
  name: 'Reply to Thread',
367
365
  description: 'Send a reply to an existing email thread.',
368
- requiresApproval: true,
369
366
  inputSchema: {
370
367
  type: 'object',
371
368
  required: ['thread_id', 'body'],
@@ -385,7 +382,6 @@ export default class GmailConnector extends ConnectorRuntime<GmailCheckpoint, Gm
385
382
  kind: 'read',
386
383
  name: 'Search Emails',
387
384
  description: 'Search emails by query.',
388
- requiresApproval: false,
389
385
  inputSchema: {
390
386
  type: 'object',
391
387
  required: ['query'],
@@ -406,7 +402,6 @@ export default class GmailConnector extends ConnectorRuntime<GmailCheckpoint, Gm
406
402
  kind: 'read',
407
403
  name: 'Get Thread',
408
404
  description: 'Read full thread content.',
409
- requiresApproval: false,
410
405
  inputSchema: {
411
406
  type: 'object',
412
407
  required: ['thread_id'],
@@ -421,7 +416,6 @@ export default class GmailConnector extends ConnectorRuntime<GmailCheckpoint, Gm
421
416
  name: 'Download Attachment',
422
417
  description:
423
418
  'Download one attachment from a Gmail message. The bytes are published as an attachment with a `download_url` a device can fetch, and small text files are ALSO returned inline as `content`. Get `attachment_id` from `get_thread`, which lists each message\'s attachments.',
424
- requiresApproval: false,
425
419
  requiredScopes: ['https://www.googleapis.com/auth/gmail.readonly'],
426
420
  inputSchema: {
427
421
  type: 'object',
@@ -307,7 +307,6 @@ export default class MarketQuotesConnector extends ConnectorRuntime {
307
307
  name: "Quote symbols",
308
308
  description:
309
309
  "Return a quoted or quote_unavailable result for every requested symbol.",
310
- requiresApproval: false,
311
310
  annotations: {
312
311
  readOnlyHint: true,
313
312
  idempotentHint: true,
@@ -263,7 +263,6 @@ export default class MicrosoftOutlookConnector extends ConnectorRuntime {
263
263
  name: 'List Attachments',
264
264
  description:
265
265
  "List a message's attachments with their IDs, names, types and sizes. The feed only reports `has_attachments`, so this is how an agent learns what to download.",
266
- requiresApproval: false,
267
266
  requiredScopes: ['Mail.Read'],
268
267
  inputSchema: {
269
268
  type: 'object',
@@ -282,7 +281,6 @@ export default class MicrosoftOutlookConnector extends ConnectorRuntime {
282
281
  name: 'Download Attachment',
283
282
  description:
284
283
  'Download one attachment from an Outlook message. The bytes are published as an attachment with a `download_url` a device can fetch, and small text files are ALSO returned inline as `content`. Get `attachment_id` from `list_attachments`.',
285
- requiresApproval: false,
286
284
  requiredScopes: ['Mail.Read'],
287
285
  inputSchema: {
288
286
  type: 'object',
@@ -353,7 +353,8 @@ export default class PostgresConnector extends ConnectorRuntime {
353
353
  name: 'PostgreSQL',
354
354
  description:
355
355
  'Bring your own PostgreSQL database as memory, read a configured feed directly, or run governed connection-level SQL.',
356
- version: '1.0.1',
356
+ version: '1.1.0',
357
+ queryCapabilities: { exactMatch: true },
357
358
  faviconDomain: 'postgresql.org',
358
359
  authSchema: {
359
360
  methods: [
@@ -516,7 +517,6 @@ export default class PostgresConnector extends ConnectorRuntime {
516
517
  const col = assertIdentifier(ctx.sort.column, 'sort.column');
517
518
  orderBy = `ORDER BY q."${col}" ${ctx.sort.order === 'desc' ? 'DESC' : 'ASC'}`;
518
519
  }
519
- const wrapped = `SELECT * FROM (\n${baseSql}\n) q\n${orderBy}\nLIMIT ${limit} OFFSET ${offset}`;
520
520
  // Real total over the whole (un-paginated) result, so the aggregator reports
521
521
  // an accurate total_count / has_more — parity with the internal query_sql
522
522
  // path. baseSql has no top-level LIMIT (rejected above), so this is exact.
@@ -526,7 +526,72 @@ export default class PostgresConnector extends ConnectorRuntime {
526
526
  try {
527
527
  const { data, total } = (await sql.begin(async (tx) => {
528
528
  await setReadOnly(tx, 30000);
529
- const rows = await tx.unsafe(wrapped);
529
+ const params: string[] = [];
530
+ const bind = (value: string) => { params.push(value); return `$${params.length}::text`; };
531
+ let where = '';
532
+ if (ctx.exactMatch) {
533
+ const { columns, value } = ctx.exactMatch;
534
+ if (!columns.length) throw new Error('exactMatch.columns must not be empty');
535
+ for (const column of columns) assertIdentifier(column, 'exactMatch.column');
536
+ const projection = await tx.unsafe(`SELECT * FROM (\n${baseSql}\n) q LIMIT 0`);
537
+ const projected = projection.columns as Array<{ name: string; type: number; parser?: { array?: boolean } }>;
538
+ const candidates = columns.flatMap((name) => projected.filter((column) => column.name === name));
539
+ if (!candidates.length) return { data: projection, total: 0 };
540
+ const isScalar = (column: (typeof projected)[number]) => !column.parser?.array && column.type !== 17;
541
+ if (!candidates.some(isScalar)) {
542
+ throw Object.assign(new Error('Exact-match identity must be a scalar; project a text key in the source query'), { status: 400 });
543
+ }
544
+ const textMatch = (ref: string) => `btrim(${ref}, ${bind('\t\n\v\f\r \u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff')}) = ${bind(value)}`;
545
+ const numberMatch = (ref: string, cast: string) => Number.isFinite(Number(value)) && String(Number(value)) === value
546
+ ? `${ref} = ${bind(value)}::${cast}` : 'FALSE';
547
+ const cases = candidates.map((column) => {
548
+ const ref = `q.${quoteIdent(column.name)}`;
549
+ const jsonType = [114, 3802].includes(column.type) ? `${column.type === 114 ? 'json' : 'jsonb'}_typeof(${ref})` : undefined;
550
+ let present = `${ref} IS NOT NULL`;
551
+ let match: string;
552
+ if (!isScalar(column)) {
553
+ // Null falls through; a non-null complex key cannot use a later scalar.
554
+ match = 'FALSE';
555
+ } else if (jsonType) {
556
+ // JSON decoding yields JS scalars; objects/arrays are not routing keys.
557
+ const decoded = `(${ref} #>> '{}')`;
558
+ // PG12+ soft conversion guards the raw cast without losing precision.
559
+ // JS underflow is zero; overflow becomes null in isolate serialization.
560
+ const number = `(CASE WHEN jsonb_path_query_first(to_jsonb(${decoded}), '$.double()', '{}', true) IS NOT NULL THEN ${decoded} WHEN abs(${decoded}::numeric) < 1 THEN '0' ELSE NULL END)::float8`;
561
+ match = `CASE WHEN ${jsonType} IN ('string', 'boolean') THEN (${textMatch(decoded)}) WHEN ${jsonType} = 'number' THEN (${numberMatch(`(${number})`, 'float8')}) ELSE FALSE END`;
562
+ present = `CASE WHEN ${jsonType} = 'number' THEN (${number}) IS NOT NULL ELSE ${jsonType} <> 'null' END`;
563
+ } else if ([700, 701].includes(column.type)) {
564
+ // The driver parses floats as JS numbers: 0.0000001 routes as 1e-7.
565
+ match = numberMatch(ref, PG_OID[column.type].cast);
566
+ present = `abs(${ref}) < 'Infinity'::float8`;
567
+ } else if ([1082, 1114, 1184].includes(column.type)) {
568
+ // The driver returns Date values; the isolate serializes them as ISO.
569
+ present = `isfinite(${ref})`;
570
+ const date = new Date(value);
571
+ if (!Number.isFinite(date.getTime()) || date.toISOString() !== value) {
572
+ match = 'FALSE';
573
+ } else if (column.type === 1082) {
574
+ match = value.endsWith('T00:00:00.000Z') ? `${ref} = ${bind(value.slice(0, 10))}::date` : 'FALSE';
575
+ } else {
576
+ // Timestamp without zone is parsed in the worker's local zone.
577
+ const key = column.type === 1114
578
+ ? new Date(date.getTime() - date.getTimezoneOffset() * 60_000).toISOString().slice(0, -1)
579
+ : value;
580
+ const bound = `${bind(key)}::${PG_OID[column.type].cast}`;
581
+ // Date drops source microseconds, so retain its full millisecond.
582
+ match = `${ref} >= ${bound} AND ${ref} < ${bound} + INTERVAL '1 millisecond'`;
583
+ }
584
+ } else {
585
+ match = textMatch(`${ref}::text`);
586
+ }
587
+ return `WHEN ${present} THEN (${match})`;
588
+ });
589
+ where = `WHERE CASE ${cases.join(' ')} ELSE FALSE END`;
590
+ }
591
+ const wrapped = `SELECT * FROM (\n${baseSql}\n) q\n${where}\n${orderBy}\nLIMIT ${limit} OFFSET ${offset}`;
592
+ const rows = await tx.unsafe(wrapped, params);
593
+ // Record lookup needs only its bounded result, never a full-source count.
594
+ if (ctx.exactMatch) return { data: rows, total: undefined };
530
595
  const counted = (await tx.unsafe(countSql)) as unknown as Array<{ n: number }>;
531
596
  return { data: rows, total: counted[0]?.n };
532
597
  })) as unknown as {
@@ -5,8 +5,8 @@
5
5
  * Successful sync checkpoints acknowledge exact buffered revisions. Ordinary
6
6
  * collection still supplies history and reconciles the page's current state.
7
7
  *
8
- * Auth stays in the user's signed-in WhatsApp Web tab. Message writes retain
9
- * their existing approval requirements and have no connector-side action ledger.
8
+ * Auth stays in the user's signed-in WhatsApp Web tab. Org policy governs
9
+ * message writes; there is no connector-side action ledger.
10
10
  */
11
11
 
12
12
  import {
@@ -754,7 +754,6 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
754
754
  description:
755
755
  "Search WhatsApp's local full-text index globally or within one exact chat. Results are bounded; loaded-model matching is used only when the private search capability is unavailable.",
756
756
  kind: "read",
757
- requiresApproval: false,
758
757
  annotations: { readOnlyHint: true, openWorldHint: true },
759
758
  inputSchema: {
760
759
  type: "object",
@@ -801,7 +800,6 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
801
800
  kind: "write",
802
801
  // A draft is the handoff surface, not the send: it fills the chat's
803
802
  // composer and stops. The human presses send.
804
- requiresApproval: false,
805
803
  annotations: { destructiveHint: false, idempotentHint: true },
806
804
  inputSchema: {
807
805
  type: "object",
@@ -833,7 +831,6 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
833
831
  name: "Send message",
834
832
  description: "Send a text message to an exact WhatsApp chat.",
835
833
  kind: "write",
836
- requiresApproval: true,
837
834
  annotations: { destructiveHint: false, idempotentHint: false },
838
835
  inputSchema: {
839
836
  type: "object",
@@ -864,7 +861,6 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
864
861
  name: "Edit message",
865
862
  description: "Edit a loaded outgoing WhatsApp message.",
866
863
  kind: "write",
867
- requiresApproval: true,
868
864
  annotations: { destructiveHint: false, idempotentHint: false },
869
865
  inputSchema: {
870
866
  type: "object",
@@ -890,7 +886,6 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
890
886
  name: "React to message",
891
887
  description: "Add or remove a reaction on a loaded WhatsApp message.",
892
888
  kind: "write",
893
- requiresApproval: true,
894
889
  annotations: { destructiveHint: false, idempotentHint: true },
895
890
  inputSchema: {
896
891
  type: "object",
@@ -917,7 +912,6 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
917
912
  description:
918
913
  "Delete a loaded outgoing WhatsApp message for everyone where WhatsApp permits it.",
919
914
  kind: "write",
920
- requiresApproval: true,
921
915
  annotations: { destructiveHint: true, idempotentHint: true },
922
916
  inputSchema: {
923
917
  type: "object",
@@ -3301,15 +3301,9 @@ export default class XConnector extends ConnectorRuntime {
3301
3301
  reason_preview: { type: "string" },
3302
3302
  },
3303
3303
  },
3304
- // NOT gated on Lobu approval, deliberately. The irreversible step is
3305
- // publishing, and X's own Reply button already guards it — a human
3306
- // must click it, and this action structurally cannot (safeDispatch
3307
- // rejects every click_ref except focusing the composer). A Lobu gate
3308
- // here would only guard "fills an already-open X page", while forcing
3309
- // the user to approve a draft BEFORE they can see it in context. The
3310
- // user-opened page is the approval. `linkedin.prepare_comment` is ungated for
3311
- // the same reason.
3312
- requiresApproval: false,
3304
+ // Org policy governs staging. Publishing still requires the human
3305
+ // to click X's Reply button: safeDispatch rejects every click_ref
3306
+ // except focusing the composer.
3313
3307
  },
3314
3308
  },
3315
3309
  };
@@ -485,7 +485,6 @@ export default class YouTubeConnector extends ConnectorRuntime {
485
485
  kind: 'read',
486
486
  name: 'Search Videos',
487
487
  description: 'Search public YouTube by keyword and return matching videos.',
488
- requiresApproval: false,
489
488
  inputSchema: {
490
489
  type: 'object',
491
490
  required: ['query'],
@@ -513,7 +512,6 @@ export default class YouTubeConnector extends ConnectorRuntime {
513
512
  kind: 'read',
514
513
  name: 'Get Video',
515
514
  description: 'Fetch metadata for one YouTube video by id or URL.',
516
- requiresApproval: false,
517
515
  inputSchema: {
518
516
  type: 'object',
519
517
  required: ['video_id'],
@@ -539,7 +537,6 @@ export default class YouTubeConnector extends ConnectorRuntime {
539
537
  name: 'Search Liked Videos',
540
538
  description:
541
539
  "Filter the authenticated user's liked videos by title or channel name (substring match).",
542
- requiresApproval: false,
543
540
  inputSchema: {
544
541
  type: 'object',
545
542
  required: ['query'],
@@ -563,7 +560,6 @@ export default class YouTubeConnector extends ConnectorRuntime {
563
560
  kind: 'read',
564
561
  name: 'List Playlists',
565
562
  description: "List the authenticated user's YouTube playlists.",
566
- requiresApproval: false,
567
563
  inputSchema: {
568
564
  type: 'object',
569
565
  properties: {
@@ -581,7 +577,6 @@ export default class YouTubeConnector extends ConnectorRuntime {
581
577
  kind: 'read',
582
578
  name: 'Get Playlist',
583
579
  description: 'List videos in one of your playlists, with an optional title filter.',
584
- requiresApproval: false,
585
580
  inputSchema: {
586
581
  type: 'object',
587
582
  required: ['playlist_id'],
@@ -161,7 +161,6 @@ Memory:
161
161
  .option("--dry-run", "Skip side-effecting tool calls (sandbox writes, sdk_run mutations). The turn still runs and history is still persisted.")
162
162
  .option("--new", "Force new session (ignore existing)")
163
163
  .option("-C, --continue", "Resume the last thread for this (context, agent)")
164
- .option("--auto-approve", "Auto-approve every tool call (use only in trusted environments)")
165
164
  .option("--json", "Emit raw SSE events as JSON lines instead of text")
166
165
  .option("-c, --context <name>", "Use a named context")
167
166
  .option("--org <slug>", "Org slug override for this run (defaults to active context org; no config write)")
@@ -5,7 +5,7 @@
5
5
  "server": "dist/server.bundle.mjs",
6
6
  "embeddingsServer": "dist/embeddings-server.mjs"
7
7
  },
8
- "version": "21.1.0",
8
+ "version": "21.2.1",
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": "21.1.0",
19
+ "version": "21.2.1",
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": "21.1.0",
27
+ "version": "21.2.1",
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": "21.1.0",
35
+ "version": "21.2.1",
36
36
  "verify": "dist/verify.mjs"
37
37
  }
38
38
  }
@@ -46,7 +46,7 @@ Declare chat integrations as project-level `defineConnection(...)` entries in `l
46
46
  Worker execution is controlled by:
47
47
 
48
48
  - Install MCP-backed services as connectors so they inherit connection auth, approval, and audit semantics.
49
- - `defineAgent({ tools: { allowed, denied, preApproved, strict } })` — configure tool visibility and approval bypasses.
49
+ - `defineAgent({ tools: { allowed, denied, strict } })` — configure tool visibility. Connector approvals are managed in Settings → Policies.
50
50
  - `defineAgent({ nixPackages })` — pulls binaries onto the `PATH` of the sandbox your agent's `bash` runs in. Shell commands execute in a remote sandbox provisioned per turn, not on the gateway host, so they are isolated from the machine running Lobu.
51
51
 
52
52
  ## Learn More
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/cli",
3
- "version": "21.1.0",
3
+ "version": "21.2.1",
4
4
  "description": "CLI for deploying and managing AI agents on Lobu",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -54,7 +54,7 @@ export declare abstract class ConnectorRuntime<C = Record<string, unknown>, F =
54
54
  /**
55
55
  * Execute an action on the connected service.
56
56
  *
57
- * Called either inline (low-risk) or by the worker (high-risk with approval).
57
+ * Called by the host after org policy authorizes execution.
58
58
  * Default implementation rejects with "Actions not supported" — connectors
59
59
  * that don't declare any `actions` in their definition need not override.
60
60
  * The `ctx` parameter is part of the public contract (subclasses overriding
@@ -69,7 +69,7 @@ export class ConnectorRuntime {
69
69
  /**
70
70
  * Execute an action on the connected service.
71
71
  *
72
- * Called either inline (low-risk) or by the worker (high-risk with approval).
72
+ * Called by the host after org policy authorizes execution.
73
73
  * Default implementation rejects with "Actions not supported" — connectors
74
74
  * that don't declare any `actions` in their definition need not override.
75
75
  * The `ctx` parameter is part of the public contract (subclasses overriding
@@ -32,6 +32,10 @@ export interface ConnectorDefinition {
32
32
  feeds?: Record<string, FeedDefinition>;
33
33
  /** Available action definitions (keyed by action_key) */
34
34
  actions?: Record<string, ActionDefinition>;
35
+ /** Query filters implemented by this connector. Unsupported filters fail before query(). */
36
+ queryCapabilities?: {
37
+ exactMatch?: boolean;
38
+ };
35
39
  /** Connector-normalized events that can activate Automations. */
36
40
  automationEvents?: ConnectorAutomationEvent[];
37
41
  /**
@@ -654,8 +658,6 @@ export interface ActionDefinition {
654
658
  name: string;
655
659
  /** Description */
656
660
  description?: string;
657
- /** Whether this action requires human approval before execution */
658
- requiresApproval: boolean;
659
661
  /** Semantic effect used by operation discovery and policy. Defaults to write. */
660
662
  kind?: 'read' | 'write';
661
663
  /**
@@ -975,6 +977,16 @@ export interface QueryContext<F = Record<string, unknown>> {
975
977
  column: string;
976
978
  order: 'asc' | 'desc';
977
979
  };
980
+ /**
981
+ * Filter before pagination by the trimmed string of the first non-null
982
+ * projected column, in order. Missing columns count as null; an empty string
983
+ * does not fall through. Values must be bound or safely encoded by the
984
+ * connector, which owns its source dialect. Requires queryCapabilities.exactMatch.
985
+ */
986
+ exactMatch?: {
987
+ columns: string[];
988
+ value: string;
989
+ };
978
990
  }
979
991
  /** Result from ConnectorRuntime.query(). Rows are returned to the caller, never persisted. */
980
992
  export interface QueryResult {
@@ -42,11 +42,9 @@ export type ConnectorFeedSpec<C = Record<string, unknown>, F = Record<string, un
42
42
  sync?: FeedSyncHandler<C, F>;
43
43
  read: FeedReadHandler<F>;
44
44
  });
45
- /** An action's metadata (minus `key`; `requiresApproval` defaults false) plus its `execute` handler. */
46
- export interface ConnectorActionSpec extends Omit<ActionDefinition, "key" | "requiresApproval"> {
47
- /** Whether the action needs human approval before execution. Defaults to `false`. */
48
- requiresApproval?: boolean;
49
- /** Effect handler for this action. Called inline (low-risk) or by the worker. */
45
+ /** An action's metadata (minus `key`) plus its `execute` handler. */
46
+ export interface ConnectorActionSpec extends Omit<ActionDefinition, "key"> {
47
+ /** Effect handler for this action. The host authorizes execution through org policy. */
50
48
  execute(ctx: ActionContext): Promise<ActionResult>;
51
49
  }
52
50
  /** Functional connector spec: connector metadata plus handler-bearing feeds/actions. */