@lobu/runtime-device 24.9.0 → 24.11.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 (65) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +19 -17
  3. package/npm-shrinkwrap.json +81 -64
  4. package/package.json +1 -1
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +3 -0
  6. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +4 -4
  7. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +21 -17
  8. package/vendor/cli/dist/commands/_lib/apply/client.js +32 -34
  9. package/vendor/cli/dist/commands/dev.js +2 -0
  10. package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +13 -3
  11. package/vendor/cli/dist/connectors/postgres.ts +39 -24
  12. package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +54 -22
  13. package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +48 -2
  14. package/vendor/cli/dist/connectors/whatsapp_web.ts +23 -7
  15. package/vendor/cli/dist/connectors/x-dm-adapter.js +17 -3
  16. package/vendor/cli/dist/internal/context.d.ts +5 -0
  17. package/vendor/cli/dist/internal/context.js +23 -9
  18. package/vendor/cli/dist/runtime-components.json +4 -4
  19. package/vendor/cli/package.json +1 -1
  20. package/vendor/connector-sdk/dist/connector-types.d.ts +6 -0
  21. package/vendor/connector-sdk/dist/index.d.ts +1 -0
  22. package/vendor/connector-sdk/dist/index.js +1 -0
  23. package/vendor/connector-sdk/dist/ip-reachability.d.ts +1 -1
  24. package/vendor/connector-sdk/dist/ip-reachability.js +1 -1
  25. package/vendor/connector-sdk/dist/logger.d.ts +1 -1
  26. package/vendor/connector-sdk/dist/logger.js +1 -1
  27. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +3 -1
  28. package/vendor/connector-sdk/dist/retry.d.ts +1 -1
  29. package/vendor/connector-sdk/dist/retry.js +1 -1
  30. package/vendor/connector-sdk/dist/source-withheld-error.d.ts +16 -0
  31. package/vendor/connector-sdk/dist/source-withheld-error.js +19 -0
  32. package/vendor/connector-sdk/package.json +1 -1
  33. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +1 -1
  34. package/vendor/connector-worker/dist/daemon/index.d.ts +1 -0
  35. package/vendor/connector-worker/dist/daemon/index.js +1 -0
  36. package/vendor/connector-worker/dist/daemon/terminal-delivery.d.ts +12 -2
  37. package/vendor/connector-worker/dist/daemon/terminal-delivery.js +19 -12
  38. package/vendor/connector-worker/dist/executor/interface.d.ts +10 -0
  39. package/vendor/connector-worker/dist/executor/interface.js +6 -0
  40. package/vendor/connector-worker/dist/executor/isolate.d.ts +1 -0
  41. package/vendor/connector-worker/dist/executor/isolate.js +85 -24
  42. package/vendor/connector-worker/dist/isolate/prelude.js +5 -0
  43. package/vendor/connector-worker/package.json +1 -1
  44. package/vendor/core/dist/classify-error.d.ts +1 -1
  45. package/vendor/core/dist/classify-error.js +2 -2
  46. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +28 -3
  47. package/vendor/core/dist/contracts/tools/manage-automations.js +27 -8
  48. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +8 -0
  49. package/vendor/core/dist/contracts/tools/manage-entity.js +11 -3
  50. package/vendor/core/dist/contracts/tools/save-memory.d.ts +11 -1
  51. package/vendor/core/dist/contracts/tools/save-memory.js +25 -3
  52. package/vendor/core/dist/contracts/tools/search-memory.js +1 -1
  53. package/vendor/core/dist/credentials.d.ts +12 -0
  54. package/vendor/core/dist/credentials.js +1 -0
  55. package/vendor/core/dist/errors.js +2 -2
  56. package/vendor/core/dist/worker/auth.d.ts +5 -0
  57. package/vendor/core/dist/worker/auth.js +15 -4
  58. package/vendor/core/package.json +1 -1
  59. package/vendor/postgres/cf/src/connection.js +7 -2
  60. package/vendor/postgres/cjs/src/connection.js +7 -2
  61. package/vendor/postgres/src/connection.js +7 -2
  62. package/vendor/views/dist/native.d.ts +33 -1
  63. package/vendor/views/dist/native.js +3 -0
  64. package/vendor/views/package.json +1 -1
  65. /package/vendor/postgres/{.bun-tag-c81dacd34e959a7a → .bun-tag-652f2580b8090d71} +0 -0
@@ -31,10 +31,10 @@ import {
31
31
  messageTitle,
32
32
  normalizeRelayedMessage,
33
33
  type ObservationCheckpoint,
34
+ WHATSAPP_ADAPTER_INSTALL,
34
35
  WHATSAPP_ADAPTER_VERSION,
35
36
  WHATSAPP_ORIGIN,
36
37
  } from "./whatsapp-web-helpers.js";
37
- import { whatsAppWebAdapterProgram } from "./whatsapp-web-adapter.js";
38
38
 
39
39
  /**
40
40
  * How long a run waits for WhatsApp Web to finish hydrating before giving up.
@@ -119,7 +119,7 @@ async function adapterInstalled(
119
119
  tab_id: tabId,
120
120
  expression: `(() => {
121
121
  const a = globalThis.__owlettoWhatsAppAdapterV1;
122
- return !!a && typeof a.invoke === 'function' && a.version === ${WHATSAPP_ADAPTER_VERSION};
122
+ return !!a && typeof a.invoke === 'function' && a.version === ${JSON.stringify(WHATSAPP_ADAPTER_VERSION)};
123
123
  })()`,
124
124
  await_promise: false,
125
125
  });
@@ -144,7 +144,7 @@ async function injectAdapter(
144
144
  exception?: unknown;
145
145
  }>("evaluate", {
146
146
  tab_id: tabId,
147
- expression: `(${whatsAppWebAdapterProgram.toString()})()`,
147
+ expression: WHATSAPP_ADAPTER_INSTALL,
148
148
  await_promise: false,
149
149
  });
150
150
  if (result.exception) {
@@ -338,6 +338,7 @@ function normalizedSearchResults(
338
338
  is_group: message.is_group,
339
339
  quoted_id: message.quoted_id ?? null,
340
340
  mentions_me: message.mentions_me === true,
341
+ own_mention_jids: message.own_mention_jids ?? [],
341
342
  });
342
343
  }
343
344
  return rows;
@@ -363,7 +364,7 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
363
364
  name: "WhatsApp",
364
365
  description:
365
366
  "Personal WhatsApp messages read live from WhatsApp Web in the paired Owletto Chrome without importing message history. Automations react to new-message references and read content on demand. Search, draft, send, edit, react to, and revoke messages.",
366
- version: "2.3.0",
367
+ version: "2.3.1",
367
368
  faviconDomain: "whatsapp.com",
368
369
  authSchema: { methods: [{ type: "browser", mode: "live" }] },
369
370
  browser: {
@@ -371,9 +372,9 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
371
372
  accountProbe: {
372
373
  url: `${WHATSAPP_ORIGIN}/`,
373
374
  expression: `(async () => {
374
- (${whatsAppWebAdapterProgram.toString()})();
375
+ ${WHATSAPP_ADAPTER_INSTALL};
375
376
  for (let i = 0; i < 40; i++) {
376
- const identity = await globalThis.__owlettoWhatsAppAdapterV1.invoke({ op: "account_identity", adapter_version: ${WHATSAPP_ADAPTER_VERSION} });
377
+ const identity = await globalThis.__owlettoWhatsAppAdapterV1.invoke({ op: "account_identity", adapter_version: ${JSON.stringify(WHATSAPP_ADAPTER_VERSION)} });
377
378
  if (identity?.accountId) return identity;
378
379
  await new Promise(resolve => setTimeout(resolve, 250));
379
380
  }
@@ -462,7 +463,21 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
462
463
  type: "string",
463
464
  enum: ["whatsapp_fts", "loaded_model_fallback"],
464
465
  },
465
- results: { type: "array", items: { type: "object" } },
466
+ results: {
467
+ type: "array",
468
+ items: {
469
+ type: "object",
470
+ properties: {
471
+ own_mention_jids: {
472
+ type: "array",
473
+ maxItems: 2,
474
+ uniqueItems: true,
475
+ items: { type: "string", pattern: "^[0-9]{5,32}@(s\\.whatsapp\\.net|lid)$" },
476
+ description: "Verified phone/LID JIDs of the paired account actually @mentioned; empty for quotes alone. Original text is preserved.",
477
+ },
478
+ },
479
+ },
480
+ },
466
481
  hasMore: { type: "boolean" },
467
482
  },
468
483
  },
@@ -710,6 +725,7 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
710
725
  { name: "is_group", type: "boolean" },
711
726
  { name: "quoted_id", type: "string" },
712
727
  { name: "mentions_me", type: "boolean" },
728
+ { name: "own_mention_jids", type: "array" },
713
729
  ],
714
730
  nextCursor: response.nextCursor,
715
731
  hasMore: response.hasMore,
@@ -43,6 +43,16 @@ export function xDirectMessagesProgram() {
43
43
  if (status !== undefined) error.status = status;
44
44
  throw error;
45
45
  }
46
+ // A stop reason is durable evidence: keep the underlying failure instead of
47
+ // reporting only that the listener could not attach.
48
+ function errorDetail(error) {
49
+ const message = error instanceof Error ? error.message : String(error);
50
+ return message
51
+ .replace(/^X direct messages: /, "")
52
+ .replace(/\s+/g, " ")
53
+ .trim()
54
+ .slice(0, 300);
55
+ }
46
56
  function cookie(name) {
47
57
  const raw = document.cookie
48
58
  .split("; ")
@@ -525,6 +535,7 @@ export function xDirectMessagesProgram() {
525
535
  clearTimeout(listener.timer);
526
536
  window.removeEventListener("message", listener.onReply);
527
537
  listeners.delete(listener.id);
538
+ listener.stopReason = reason;
528
539
  if (reason)
529
540
  post(listener, {
530
541
  id: "x:live_messages:source-observation-error",
@@ -552,10 +563,10 @@ export function xDirectMessagesProgram() {
552
563
  }
553
564
  account(listener.account);
554
565
  if (active(listener)) post(listener, listener.batches[0]);
555
- } catch {
566
+ } catch (error) {
556
567
  stop(
557
568
  listener,
558
- "X source observation failed; reconnect to recover without skipping messages",
569
+ `X source observation failed (${errorDetail(error)}); reconnect to recover without skipping messages`,
559
570
  );
560
571
  }
561
572
  if (active(listener))
@@ -618,7 +629,10 @@ export function xDirectMessagesProgram() {
618
629
  window.addEventListener("message", listener.onReply);
619
630
  await poll(listener);
620
631
  if (!listeners.has(listener.id))
621
- fail("Unable to attach source subscription");
632
+ fail(
633
+ "Unable to attach source subscription: " +
634
+ (listener.stopReason ?? "listener stopped"),
635
+ );
622
636
  return { listening: true };
623
637
  }
624
638
  // X serves at most 50 entries per notifications page (`count=50`); the
@@ -35,6 +35,11 @@ export interface ResolvedContext {
35
35
  url: string;
36
36
  source: "default" | "config" | "env";
37
37
  }
38
+ /**
39
+ * Only a missing file means "no contexts yet". An unreadable or corrupt file is
40
+ * an error: reading it as empty would report every context as unknown, and the
41
+ * next save would write that empty config over the user's contexts.
42
+ */
38
43
  export declare function loadContextConfig(): Promise<LobuContextConfig>;
39
44
  export declare function getCurrentContextName(): Promise<string>;
40
45
  export declare function getActiveOrg(contextName?: string): Promise<string | undefined>;
@@ -1,6 +1,7 @@
1
- import { mkdir, readFile, writeFile } from "node:fs/promises";
1
+ import { readFile } from "node:fs/promises";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
+ import { atomicWriteFile } from "@lobu/core";
4
5
  export const LOBU_CONFIG_DIR = join(homedir(), ".config", "lobu");
5
6
  export const DEFAULT_CONTEXT_NAME = "lobu";
6
7
  const DEFAULT_CONTEXT_URL = "https://app.lobu.ai/api/v1";
@@ -23,21 +24,34 @@ export function validateOrgSlug(slug) {
23
24
  }
24
25
  return slug;
25
26
  }
27
+ /**
28
+ * Only a missing file means "no contexts yet". An unreadable or corrupt file is
29
+ * an error: reading it as empty would report every context as unknown, and the
30
+ * next save would write that empty config over the user's contexts.
31
+ */
26
32
  export async function loadContextConfig() {
33
+ let raw;
34
+ try {
35
+ raw = await readFile(CONTEXTS_FILE, "utf-8");
36
+ }
37
+ catch (error) {
38
+ if (error.code === "ENOENT") {
39
+ return normalizeContextConfig({});
40
+ }
41
+ throw error;
42
+ }
43
+ let parsed;
27
44
  try {
28
- const raw = await readFile(CONTEXTS_FILE, "utf-8");
29
- const parsed = JSON.parse(raw);
30
- return normalizeContextConfig(parsed);
45
+ parsed = JSON.parse(raw);
31
46
  }
32
47
  catch {
33
- return normalizeContextConfig({});
48
+ throw new Error(`${CONTEXTS_FILE} is not valid JSON. Fix or delete it, then run \`lobu context list\`.`);
34
49
  }
50
+ return normalizeContextConfig(parsed);
35
51
  }
52
+ /** Atomic, so a concurrent `lobu` process never reads a half-written file. */
36
53
  async function saveContextConfig(config) {
37
- await mkdir(LOBU_CONFIG_DIR, { recursive: true });
38
- await writeFile(CONTEXTS_FILE, JSON.stringify(config, null, 2), {
39
- mode: 0o600,
40
- });
54
+ await atomicWriteFile(CONTEXTS_FILE, JSON.stringify(config, null, 2));
41
55
  }
42
56
  export async function getCurrentContextName() {
43
57
  const envContext = process.env.LOBU_CONTEXT?.trim();
@@ -5,7 +5,7 @@
5
5
  "server": "dist/server.bundle.mjs",
6
6
  "embeddingsServer": "dist/embeddings-server.mjs"
7
7
  },
8
- "version": "24.9.0",
8
+ "version": "24.11.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.9.0",
19
+ "version": "24.11.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.9.0",
27
+ "version": "24.11.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.9.0",
35
+ "version": "24.11.0",
36
36
  "verify": "dist/verify.mjs"
37
37
  }
38
38
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/cli",
3
- "version": "24.9.0",
3
+ "version": "24.11.0",
4
4
  "description": "CLI for deploying and managing AI agents on Lobu",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1087,6 +1087,12 @@ export interface FeedReadResult {
1087
1087
  window?: FeedReadWindowCoverage;
1088
1088
  }
1089
1089
  export type FeedSyncHandler<C = Record<string, unknown>, F = Record<string, unknown>> = (ctx: SyncContext<C, F>) => Promise<SyncResult>;
1090
+ /**
1091
+ * Reads one page from the source. Throw `SourceWithheldError` (or any error
1092
+ * whose own `code` is `'withheld'`) when the source deliberately withholds the
1093
+ * requested record: callers report it as private with the error's message as
1094
+ * the reason, and never retry it. Any other rejection is a read failure.
1095
+ */
1090
1096
  export type FeedReadHandler<F = Record<string, unknown>> = (ctx: FeedReadContext<F>) => Promise<FeedReadResult>;
1091
1097
  /** Executable feed definition held only inside a connector runtime. */
1092
1098
  export interface RuntimeFeedDefinition<C = Record<string, unknown>, F = Record<string, unknown>> extends Omit<FeedDefinition, 'operations' | 'webhook'> {
@@ -58,6 +58,7 @@ export type { FileDelta, FileSystemSource, Snapshot } from './file-source.js';
58
58
  export { connect } from './net.js';
59
59
  export type { ConnectFn, Socket, SocketAddress, SocketOptions, } from './net.js';
60
60
  export { assertFeedReadWindow, validateFeedReadWindow } from './feed-read-window.js';
61
+ export { SourceWithheldError } from './source-withheld-error.js';
61
62
  export { isSecretOutputKey, redactOutput } from './redact.js';
62
63
  export { scrubDiagnosticValue } from '@lobu/core/diagnostic-scrubber';
63
64
  //# sourceMappingURL=index.d.ts.map
@@ -46,6 +46,7 @@ export { extensionNetworkSync } from './extension-network.js';
46
46
  // =============================================================================
47
47
  export { connect } from './net.js';
48
48
  export { assertFeedReadWindow, validateFeedReadWindow } from './feed-read-window.js';
49
+ export { SourceWithheldError } from './source-withheld-error.js';
49
50
  // The worker's output redaction catalog, shared so a connector that returns
50
51
  // third-party text (logs, messages) can scrub it with the same patterns.
51
52
  export { isSecretOutputKey, redactOutput } from './redact.js';
@@ -21,7 +21,7 @@
21
21
  * Keeping the classifier here rather than in each consumer is deliberate:
22
22
  * `@lobu/connector-sdk` is the only package every consumer can import (the
23
23
  * server package is not reachable from a bundled connector, and `@lobu/core`
24
- * pulls OpenTelemetry, Sentry, and winston, which connectors intentionally
24
+ * pulls OpenTelemetry and winston, which connectors intentionally
25
25
  * avoid).
26
26
  *
27
27
  * The matcher collapses the spellings an attacker can use to dress up an
@@ -21,7 +21,7 @@
21
21
  * Keeping the classifier here rather than in each consumer is deliberate:
22
22
  * `@lobu/connector-sdk` is the only package every consumer can import (the
23
23
  * server package is not reachable from a bundled connector, and `@lobu/core`
24
- * pulls OpenTelemetry, Sentry, and winston, which connectors intentionally
24
+ * pulls OpenTelemetry and winston, which connectors intentionally
25
25
  * avoid).
26
26
  *
27
27
  * The matcher collapses the spellings an attacker can use to dress up an
@@ -2,7 +2,7 @@
2
2
  * SDK logger.
3
3
  *
4
4
  * Deliberately self-contained. The package root must stay loadable inside a
5
- * V8 isolate, and `@lobu/core`'s root entry pulls winston, Sentry and
5
+ * V8 isolate, and `@lobu/core`'s root entry pulls winston and
6
6
  * OpenTelemetry into every connector bundle — 6 MB of gateway internals whose
7
7
  * first `require('util')` throws where no Node runtime exists (guarded by
8
8
  * `packages/server/src/__tests__/integration/sandbox/connector-isolate-lane.test.ts`).
@@ -2,7 +2,7 @@
2
2
  * SDK logger.
3
3
  *
4
4
  * Deliberately self-contained. The package root must stay loadable inside a
5
- * V8 isolate, and `@lobu/core`'s root entry pulls winston, Sentry and
5
+ * V8 isolate, and `@lobu/core`'s root entry pulls winston and
6
6
  * OpenTelemetry into every connector bundle — 6 MB of gateway internals whose
7
7
  * first `require('util')` throws where no Node runtime exists (guarded by
8
8
  * `packages/server/src/__tests__/integration/sandbox/connector-isolate-lane.test.ts`).
@@ -17,7 +17,7 @@ import type { ConnectionListInput } from "@lobu/core/contracts/tools/manage-conn
17
17
  import type { EntityCreateInput, EntityCreateResult, EntityDeleteInput, EntityDeleteResult, EntityDiscoverDuplicatesInput, EntityDiscoverDuplicatesResult, EntityGetInput, EntityGetResult, EntityLinkInput, EntityLinkResult, EntityListInput, EntityListResult, EntityListLinksInput, EntityListLinksResult, EntityUnlinkInput, EntityUnlinkResult, EntityUpdateInput, EntityUpdateResult, EntityUpdateLinkInput, EntityUpdateLinkResult } from "@lobu/core/contracts/tools/manage-entity";
18
18
  import type { OperationExecuteInput, OperationListAvailableInput, OperationListRunsInput } from "@lobu/core/contracts/tools/manage-operations";
19
19
  import type { PublicGetContentArgs } from "@lobu/core/contracts/tools/read-knowledge";
20
- import type { SaveContentInput } from "@lobu/core/contracts/tools/save-memory";
20
+ import type { SaveContentInput, UnlinkedEntityName } from "@lobu/core/contracts/tools/save-memory";
21
21
  import type { PublicSearchArgs } from "@lobu/core/contracts/tools/search-memory";
22
22
  /**
23
23
  * A rich card for chat delivery, as a plain serializable object — a `chat`
@@ -58,6 +58,8 @@ export interface KnowledgeSaveResult {
58
58
  id: number;
59
59
  created: boolean;
60
60
  metadata: Record<string, unknown>;
61
+ /** `{ name }` entries from `entity_ids` that did not link. */
62
+ unlinked: UnlinkedEntityName[];
61
63
  }
62
64
  export interface NotificationsSendInput {
63
65
  /** Notification title (≤200 chars). */
@@ -9,7 +9,7 @@
9
9
  * 503.
10
10
  *
11
11
  * The backoff loop lives here rather than being imported from `@lobu/core`:
12
- * core's root entry drags winston, Sentry and OpenTelemetry into every
12
+ * core's root entry drags winston and OpenTelemetry into every
13
13
  * connector bundle, and the package root must stay loadable inside a V8
14
14
  * isolate. It keeps the semantics of core's `retryWithBackoff` for the one
15
15
  * configuration `withHttpRetry` uses: exponential, capped, full jitter.
@@ -9,7 +9,7 @@
9
9
  * 503.
10
10
  *
11
11
  * The backoff loop lives here rather than being imported from `@lobu/core`:
12
- * core's root entry drags winston, Sentry and OpenTelemetry into every
12
+ * core's root entry drags winston and OpenTelemetry into every
13
13
  * connector bundle, and the package root must stay loadable inside a V8
14
14
  * isolate. It keeps the semantics of core's `retryWithBackoff` for the one
15
15
  * configuration `withHttpRetry` uses: exponential, capped, full jitter.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Thrown from a feed `read` when the source deliberately withholds the
3
+ * requested record (for example, a private person's communications). The read
4
+ * is reported as withheld rather than failed: the caller is told the reason,
5
+ * nothing is retried, and pagination continues past it.
6
+ *
7
+ * The platform keys on the error's own `code === 'withheld'`, never on this
8
+ * class, so a connector on an older SDK opts in with
9
+ * `Object.assign(new Error(reason), { code: 'withheld' })`. The message is the
10
+ * human reason shown to the user.
11
+ */
12
+ export declare class SourceWithheldError extends Error {
13
+ readonly code: "withheld";
14
+ constructor(reason: string);
15
+ }
16
+ //# sourceMappingURL=source-withheld-error.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Thrown from a feed `read` when the source deliberately withholds the
3
+ * requested record (for example, a private person's communications). The read
4
+ * is reported as withheld rather than failed: the caller is told the reason,
5
+ * nothing is retried, and pagination continues past it.
6
+ *
7
+ * The platform keys on the error's own `code === 'withheld'`, never on this
8
+ * class, so a connector on an older SDK opts in with
9
+ * `Object.assign(new Error(reason), { code: 'withheld' })`. The message is the
10
+ * human reason shown to the user.
11
+ */
12
+ export class SourceWithheldError extends Error {
13
+ code = 'withheld';
14
+ constructor(reason) {
15
+ super(reason);
16
+ this.name = 'SourceWithheldError';
17
+ }
18
+ }
19
+ //# sourceMappingURL=source-withheld-error.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/connector-sdk",
3
- "version": "24.9.0",
3
+ "version": "24.11.0",
4
4
  "description": "Lobu memory SDK — build pluggable connectors for Lobu memory",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16769,7 +16769,7 @@ var require_dist3 = __commonJS({
16769
16769
  if (error)
16770
16770
  return error;
16771
16771
  hooks?.onPosted?.();
16772
- return (0, plugin_toolkit_1.textResult)("Question posted with buttons. Your turn is now ending \u2014 the user's click will arrive as a new inbound message that resumes this session. Do not call ask_user again.");
16772
+ return (0, plugin_toolkit_1.textResult)("Question posted. Your turn is now ending \u2014 the user's answer will arrive as a new inbound message that resumes this session: a tapped option, or, on chats that cannot show buttons, a typed reply that may be just an option's number from the list (1 = your first option). Do not call ask_user again.");
16773
16773
  });
16774
16774
  }
16775
16775
  async function listConversations(gateway) {
@@ -13,4 +13,5 @@ export type { DaemonConfig } from './worker.js';
13
13
  export { startDaemon, WorkerDaemon } from './worker.js';
14
14
  export { resolveDaemonLaunchContext, resolveDaemonWorkerId, startDaemonCommand, type DaemonStartOptions, } from './start.js';
15
15
  export { executeClaimedAutomationRun, UnexecutableRunError } from './execute-run.js';
16
+ export { completeSyncOnce } from './terminal-delivery.js';
16
17
  //# sourceMappingURL=index.d.ts.map
@@ -10,4 +10,5 @@ export { executeRun } from './executor.js';
10
10
  export { startDaemon, WorkerDaemon } from './worker.js';
11
11
  export { resolveDaemonLaunchContext, resolveDaemonWorkerId, startDaemonCommand, } from './start.js';
12
12
  export { executeClaimedAutomationRun, UnexecutableRunError } from './execute-run.js';
13
+ export { completeSyncOnce } from './terminal-delivery.js';
13
14
  //# sourceMappingURL=index.js.map
@@ -1,10 +1,20 @@
1
1
  import type { CompleteAgentTurnRequest, CompleteAgentTurnResponse, ExecutorClient } from './client.js';
2
+ interface TerminalDeliveryPolicy {
3
+ deadlineMs: number;
4
+ attempts: number;
5
+ /** Pause before retry N (0-based), doubled each time; 0 retries at once. */
6
+ backoffMs: number;
7
+ retriable: (error: unknown) => boolean;
8
+ }
9
+ /** Compresses a sync/action delivery budget; tests pass this to keep backoff fast. */
10
+ type DeliveryTiming = Partial<Pick<TerminalDeliveryPolicy, 'deadlineMs' | 'backoffMs'>>;
2
11
  /**
3
12
  * A delivery failure's retry classification: HTTP 5xx/429 and transport errors
4
13
  * are retriable; an explicit decode failure or any other 4xx is not.
5
14
  */
6
15
  export declare function isRetriableDeliveryFailure(err: unknown): boolean;
7
- export declare function completeSyncOnce(client: ExecutorClient, payload: Parameters<ExecutorClient['complete']>[0]): Promise<void>;
8
- export declare function completeActionOnce(client: ExecutorClient, payload: Parameters<ExecutorClient['completeAction']>[0]): Promise<void>;
16
+ export declare function completeSyncOnce(client: ExecutorClient, payload: Parameters<ExecutorClient['complete']>[0], timing?: DeliveryTiming): Promise<void>;
17
+ export declare function completeActionOnce(client: ExecutorClient, payload: Parameters<ExecutorClient['completeAction']>[0], timing?: DeliveryTiming): Promise<void>;
9
18
  export declare function completeAgentTurnOnce(client: ExecutorClient, payload: CompleteAgentTurnRequest): Promise<CompleteAgentTurnResponse>;
19
+ export {};
10
20
  //# sourceMappingURL=terminal-delivery.d.ts.map
@@ -1,16 +1,23 @@
1
1
  /**
2
2
  * Bounded delivery of an immutable terminal outcome. Execution and failure
3
- * reporting share the retry loop; sync/action and agent-turn budgets differ.
4
- * WorkerDecodeError identifies an unreadable response, not an execution
5
- * failure, and is surfaced without retrying.
3
+ * reporting share the retry loop and its classification; sync/action and
4
+ * agent-turn budgets differ. WorkerDecodeError identifies an unreadable
5
+ * response, not an execution failure, and is surfaced without retrying.
6
6
  */
7
7
  import { WorkerDecodeError, WorkerHttpError } from './client.js';
8
- /** Syncs/actions: two attempts in 15s, anything but an undecodable answer retried. */
8
+ /**
9
+ * Syncs/actions ride out a gateway rollout: a dying replica answers 5xx or
10
+ * drops the connection, and an immediate retry would reach the same one. Six
11
+ * attempts back off 1s, 2s, 4s, 8s, 16s, all inside 90s -- the reaper writes
12
+ * a run off 120s after its last heartbeat, and the executor stops heartbeating
13
+ * up to 30s before delivery starts. A 4xx other than 429 is the gateway's
14
+ * answer and is not re-sent.
15
+ */
9
16
  const ACTION_DELIVERY = {
10
- deadlineMs: 15_000,
11
- attempts: 2,
12
- backoffMs: 0,
13
- retriable: (error) => !(error instanceof WorkerDecodeError),
17
+ deadlineMs: 90_000,
18
+ attempts: 6,
19
+ backoffMs: 1_000,
20
+ retriable: isRetriableDeliveryFailure,
14
21
  };
15
22
  /**
16
23
  * Agent turns retry transient delivery failures across a short gateway outage.
@@ -89,11 +96,11 @@ async function deliverTerminal(send, policy) {
89
96
  }
90
97
  throw lastError instanceof Error ? lastError : new Error(String(lastError));
91
98
  }
92
- export async function completeSyncOnce(client, payload) {
93
- await deliverTerminal(() => client.complete(payload), ACTION_DELIVERY);
99
+ export async function completeSyncOnce(client, payload, timing = {}) {
100
+ await deliverTerminal(() => client.complete(payload), { ...ACTION_DELIVERY, ...timing });
94
101
  }
95
- export async function completeActionOnce(client, payload) {
96
- await deliverTerminal(() => client.completeAction(payload), ACTION_DELIVERY);
102
+ export async function completeActionOnce(client, payload, timing = {}) {
103
+ await deliverTerminal(() => client.completeAction(payload), { ...ACTION_DELIVERY, ...timing });
97
104
  }
98
105
  export function completeAgentTurnOnce(client, payload) {
99
106
  return deliverTerminal(() => client.completeAgentTurn(payload), AGENT_TURN_DELIVERY);
@@ -238,12 +238,20 @@ export interface SyncExecutor {
238
238
  execute(compiledCode: string, job: ExecutorJob, hooks?: ExecutionHooks): Promise<ExecutorResult>;
239
239
  }
240
240
  export type ConnectorExitReason = 'ok' | 'error_message' | 'timeout' | 'oom' | 'crash';
241
+ /**
242
+ * A structured outcome the connector itself declared on the error it threw.
243
+ * `withheld`: the source deliberately withholds the record (SourceWithheldError).
244
+ */
245
+ export type ConnectorErrorCode = 'withheld';
241
246
  export interface ConnectorExecutionDiagnostics {
242
247
  exitCode: number | null;
243
248
  exitSignal: string | null;
244
249
  outputTail: string;
245
250
  exitReason: ConnectorExitReason;
246
251
  httpStatus?: number;
252
+ /** Validated PostgreSQL SQLSTATE; distinct from connector outcome codes. */
253
+ pgCode?: string;
254
+ code?: ConnectorErrorCode;
247
255
  }
248
256
  export declare class ConnectorExecutionError extends Error implements ConnectorExecutionDiagnostics {
249
257
  exitCode: number | null;
@@ -251,6 +259,8 @@ export declare class ConnectorExecutionError extends Error implements ConnectorE
251
259
  outputTail: string;
252
260
  exitReason: ConnectorExitReason;
253
261
  httpStatus?: number;
262
+ pgCode?: string;
263
+ code?: ConnectorErrorCode;
254
264
  constructor(message: string, diagnostics: ConnectorExecutionDiagnostics, options?: {
255
265
  cause?: unknown;
256
266
  });
@@ -4,6 +4,8 @@ export class ConnectorExecutionError extends Error {
4
4
  outputTail;
5
5
  exitReason;
6
6
  httpStatus;
7
+ pgCode;
8
+ code;
7
9
  constructor(message, diagnostics, options) {
8
10
  super(message, options);
9
11
  this.name = 'ConnectorExecutionError';
@@ -12,6 +14,10 @@ export class ConnectorExecutionError extends Error {
12
14
  this.outputTail = diagnostics.outputTail;
13
15
  this.exitReason = diagnostics.exitReason;
14
16
  this.httpStatus = diagnostics.httpStatus;
17
+ if (diagnostics.pgCode)
18
+ this.pgCode = diagnostics.pgCode;
19
+ if (diagnostics.code)
20
+ this.code = diagnostics.code;
15
21
  }
16
22
  }
17
23
  /** Per-stream ring buffer that preserves the most recent bytes. */
@@ -83,6 +83,7 @@ export declare class IsolateExecutor implements SyncExecutor {
83
83
  private assertHostAllowed;
84
84
  private requireIsolatedVm;
85
85
  execute(compiledCode: string, job: ExecutorJob, hooks?: ExecutionHooks): Promise<ExecutorResult>;
86
+ private executeInIsolate;
86
87
  /** Build the `ConnectorExecutionError` the daemon reports for a guest-thrown error. */
87
88
  private guestError;
88
89
  private hostFetch;