@lobu/runtime-device 22.0.0 → 24.0.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 (115) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +33 -30
  3. package/npm-shrinkwrap.json +140 -124
  4. package/package.json +2 -1
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +74 -1
  6. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +9 -11
  7. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +3 -11
  8. package/vendor/cli/dist/commands/_lib/apply/client.js +3 -3
  9. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +0 -6
  10. package/vendor/cli/dist/commands/_lib/apply/desired-state.js +6 -15
  11. package/vendor/cli/dist/commands/_lib/apply/diff.js +1 -0
  12. package/vendor/cli/dist/commands/_lib/apply/map-config.js +8 -0
  13. package/vendor/cli/dist/commands/_lib/view-bundler.d.ts +2 -9
  14. package/vendor/cli/dist/commands/_lib/view-bundler.js +25 -97
  15. package/vendor/cli/dist/config/define.d.ts +8 -0
  16. package/vendor/cli/dist/connectors/README.md +15 -2
  17. package/vendor/cli/dist/connectors/google_gmail.ts +1 -0
  18. package/vendor/cli/dist/connectors/jira-helpers.ts +313 -0
  19. package/vendor/cli/dist/connectors/jira.ts +29 -221
  20. package/vendor/cli/dist/connectors/linkedin-browser-script.ts +13 -0
  21. package/vendor/cli/dist/connectors/linkedin-draft-page.js +104 -0
  22. package/vendor/cli/dist/connectors/linkedin-drafts.ts +73 -0
  23. package/vendor/cli/dist/connectors/linkedin-identity.ts +32 -0
  24. package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +1182 -0
  25. package/vendor/cli/dist/connectors/linkedin-inbox.ts +156 -0
  26. package/vendor/cli/dist/connectors/linkedin-like.ts +114 -0
  27. package/vendor/cli/dist/connectors/linkedin-takeout.ts +577 -0
  28. package/vendor/cli/dist/connectors/linkedin.ts +4017 -0
  29. package/vendor/cli/dist/connectors/reddit.ts +92 -20
  30. package/vendor/cli/dist/connectors/slack.ts +1 -0
  31. package/vendor/cli/dist/connectors/takeout-utils.ts +240 -0
  32. package/vendor/cli/dist/connectors/tiktok-inbox-page.js +9 -9
  33. package/vendor/cli/dist/connectors/tiktok-web-page.js +21 -15
  34. package/vendor/cli/dist/connectors/tiktok_web.ts +63 -30
  35. package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +104 -574
  36. package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +30 -444
  37. package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +20 -6
  38. package/vendor/cli/dist/connectors/whatsapp_web.ts +46 -646
  39. package/vendor/cli/dist/connectors/x-dm-adapter.js +556 -0
  40. package/vendor/cli/dist/connectors/x-identity.ts +33 -2
  41. package/vendor/cli/dist/connectors/x.ts +266 -120
  42. package/vendor/cli/dist/runtime-components.json +4 -4
  43. package/vendor/cli/dist/templates/AGENTS.md.tmpl +12 -5
  44. package/vendor/cli/package.json +1 -1
  45. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  46. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  47. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  48. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  49. package/vendor/connector-sdk/dist/connector-types.d.ts +10 -0
  50. package/vendor/connector-sdk/dist/index.d.ts +3 -0
  51. package/vendor/connector-sdk/dist/index.js +2 -0
  52. package/vendor/connector-sdk/package.json +9 -1
  53. package/vendor/connector-worker/dist/agent-turn/gateway-tools.d.ts +2 -2
  54. package/vendor/connector-worker/dist/agent-turn/gateway-tools.js +2 -2
  55. package/vendor/connector-worker/dist/agent-turn/guest-entry.js +49 -8
  56. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +650 -448
  57. package/vendor/connector-worker/dist/agent-turn/native-session.d.ts +12 -0
  58. package/vendor/connector-worker/dist/agent-turn/native-session.js +32 -6
  59. package/vendor/connector-worker/dist/agent-turn/types.d.ts +24 -3
  60. package/vendor/connector-worker/dist/daemon/agent-turn.js +5 -1
  61. package/vendor/connector-worker/dist/daemon/automation.d.ts +4 -11
  62. package/vendor/connector-worker/dist/daemon/automation.js +26 -21
  63. package/vendor/connector-worker/dist/daemon/client.d.ts +2 -4
  64. package/vendor/connector-worker/dist/daemon/client.js +0 -3
  65. package/vendor/connector-worker/dist/daemon/executor.js +0 -3
  66. package/vendor/connector-worker/dist/daemon/mac-device-daemon.d.ts +4 -3
  67. package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +4 -10
  68. package/vendor/connector-worker/dist/daemon/native-bridge/executor.js +27 -25
  69. package/vendor/connector-worker/dist/daemon/start.js +3 -15
  70. package/vendor/connector-worker/dist/daemon/terminal-failure.js +0 -11
  71. package/vendor/connector-worker/dist/daemon/worker-id.d.ts +17 -0
  72. package/vendor/connector-worker/dist/daemon/worker-id.js +22 -0
  73. package/vendor/connector-worker/dist/isolate/prelude.js +93 -44
  74. package/vendor/connector-worker/dist/mac-device-daemon.js +14 -26
  75. package/vendor/connector-worker/package.json +1 -1
  76. package/vendor/core/dist/agent-policy.js +0 -3
  77. package/vendor/core/dist/agent-tooling.d.ts +1 -1
  78. package/vendor/core/dist/agent-tooling.js +3 -1
  79. package/vendor/core/dist/capabilities.d.ts +1 -1
  80. package/vendor/core/dist/capabilities.js +0 -1
  81. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  82. package/vendor/core/dist/connector-query-errors.js +41 -1
  83. package/vendor/core/dist/contracts/agent-settings.d.ts +6 -2
  84. package/vendor/core/dist/contracts/agent-settings.js +12 -1
  85. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  86. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  87. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  88. package/vendor/core/dist/contracts/tools/manage-views.d.ts +53 -234
  89. package/vendor/core/dist/contracts/tools/manage-views.js +50 -76
  90. package/vendor/core/dist/contracts/tools/view-attach.d.ts +5 -8
  91. package/vendor/core/dist/contracts/tools/view-attach.js +14 -31
  92. package/vendor/core/dist/contracts/tools/view-definition.d.ts +21 -0
  93. package/vendor/core/dist/contracts/tools/view-definition.js +165 -0
  94. package/vendor/core/dist/contracts/worker/protocol.d.ts +47 -133
  95. package/vendor/core/dist/contracts/worker/protocol.js +33 -62
  96. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  97. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  98. package/vendor/core/dist/index.d.ts +3 -2
  99. package/vendor/core/dist/index.js +3 -1
  100. package/vendor/core/dist/logger.js +10 -25
  101. package/vendor/core/dist/suggestions.d.ts +15 -2
  102. package/vendor/core/dist/suggestions.js +48 -3
  103. package/vendor/core/dist/types.d.ts +26 -0
  104. package/vendor/core/dist/types.js +5 -0
  105. package/vendor/core/dist/utils/diagnostic-scrubber.js +258 -21
  106. package/vendor/core/dist/worker/wire.d.ts +0 -10
  107. package/vendor/core/package.json +16 -10
  108. package/vendor/postgres/cf/src/connection.js +18 -0
  109. package/vendor/postgres/cjs/src/connection.js +18 -0
  110. package/vendor/postgres/src/connection.js +18 -0
  111. package/vendor/connector-worker/dist/daemon/device-chat.d.ts +0 -9
  112. package/vendor/connector-worker/dist/daemon/device-chat.js +0 -61
  113. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  114. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
  115. /package/vendor/postgres/{.bun-tag-f39dafdb2305d504 → .bun-tag-2f292c6554a8475e} +0 -0
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Shared in-page handoff banner for browser-staged drafts.
3
+ *
4
+ * Two connectors stage text in the user's own signed-in page and stop before
5
+ * submit (`x.prepare_reply`, `linkedin.prepare_comment`). Without a banner the
6
+ * staged page is context-free — a draft in a box with no record of why the
7
+ * agent thought the post mattered. Both banners are the same DOM shape (a
8
+ * fixed `#lobu-handoff-banner` status node, anchored above the composer when
9
+ * one is found, dismissible, never auto-submitted); only the title,
10
+ * instruction line, optional footer, and composer/host selectors differ per
11
+ * site. Callers pass those; this module owns the injection script.
12
+ *
13
+ * Pure (no `node:`, no `@lobu/core`): the root must stay loadable inside a V8
14
+ * isolate.
15
+ */
16
+ export function truncateHandoffReason(reason, maxLen = 120) {
17
+ if (reason == null)
18
+ return undefined;
19
+ const t = reason.replace(/\s+/g, " ").trim();
20
+ if (!t)
21
+ return undefined;
22
+ if (t.length <= maxLen)
23
+ return t;
24
+ return `${t.slice(0, Math.max(0, maxLen - 1)).trimEnd()}…`;
25
+ }
26
+ /**
27
+ * JS expression: inject the Lobu handoff banner on the page.
28
+ *
29
+ * Best-effort; the host page re-renders aggressively and may drop the node.
30
+ * Never fatal — the draft is already staged by the time this runs. No
31
+ * auto-dismiss: the draft lives in the user's page, so its context should
32
+ * still be present when the user returns later.
33
+ */
34
+ export function buildInjectHandoffBannerExpression(opts) {
35
+ const reason = truncateHandoffReason(opts.reason);
36
+ const title = opts.title ?? "Lobu staged this draft";
37
+ const instruction = opts.instruction ?? "Review the draft yourself — Lobu did not submit.";
38
+ const titleLit = JSON.stringify(title);
39
+ const instructionLit = JSON.stringify(instruction);
40
+ const reasonLit = JSON.stringify(reason ?? null);
41
+ const footerLit = JSON.stringify(opts.footer ?? null);
42
+ const composerSelectorsLit = JSON.stringify(opts.composerSelectors ?? ['div[role="textbox"][contenteditable="true"]']);
43
+ const hostSelectorsLit = JSON.stringify(opts.hostSelectors ?? ["form"]);
44
+ return `(async()=>{
45
+ const TITLE = ${titleLit};
46
+ const INSTRUCTION = ${instructionLit};
47
+ const REASON = ${reasonLit};
48
+ const FOOTER = ${footerLit};
49
+ const COMPOSER_SELECTORS = ${composerSelectorsLit};
50
+ const HOST_SELECTORS = ${hostSelectorsLit};
51
+ const ID = 'lobu-handoff-banner';
52
+ try {
53
+ const prev = document.getElementById(ID);
54
+ if (prev) prev.remove();
55
+ } catch (_) {}
56
+
57
+ const root = document.createElement('div');
58
+ root.id = ID;
59
+ root.setAttribute('role', 'status');
60
+ root.setAttribute('data-lobu', 'handoff-banner');
61
+ root.style.cssText = [
62
+ 'position:fixed',
63
+ 'top:12px',
64
+ 'left:50%',
65
+ 'transform:translateX(-50%)',
66
+ 'z-index:2147483646',
67
+ 'max-width:min(520px,calc(100vw - 24px))',
68
+ 'font:13px/1.4 -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif',
69
+ 'color:#0f172a',
70
+ 'background:#fff',
71
+ 'border:1px solid #cbd5e1',
72
+ 'border-left:4px solid #0ea5e9',
73
+ 'border-radius:10px',
74
+ 'box-shadow:0 8px 28px rgba(15,23,42,.18)',
75
+ 'padding:10px 12px',
76
+ 'display:flex',
77
+ 'gap:10px',
78
+ 'align-items:flex-start',
79
+ 'pointer-events:auto',
80
+ ].join(';');
81
+
82
+ const body = document.createElement('div');
83
+ body.style.cssText = 'flex:1;min-width:0';
84
+
85
+ const head = document.createElement('div');
86
+ head.style.cssText = 'font-weight:600;margin:0 0 2px;color:#0c4a6e';
87
+ head.textContent = TITLE;
88
+
89
+ const line = document.createElement('div');
90
+ line.style.cssText = 'color:#334155;margin:0 0 2px';
91
+ line.textContent = INSTRUCTION;
92
+
93
+ body.appendChild(head);
94
+ body.appendChild(line);
95
+
96
+ if (REASON) {
97
+ const why = document.createElement('div');
98
+ why.style.cssText = 'color:#64748b;margin:4px 0 0;font-size:12px';
99
+ why.textContent = 'Why: ' + REASON;
100
+ body.appendChild(why);
101
+ }
102
+
103
+ if (FOOTER) {
104
+ const foot = document.createElement('div');
105
+ foot.style.cssText = 'color:#64748b;margin:4px 0 0;font-size:12px';
106
+ foot.textContent = FOOTER;
107
+ body.appendChild(foot);
108
+ }
109
+
110
+ const close = document.createElement('button');
111
+ close.type = 'button';
112
+ close.setAttribute('aria-label', 'Dismiss');
113
+ close.textContent = '\\u00d7';
114
+ close.style.cssText = [
115
+ 'flex:none',
116
+ 'border:0',
117
+ 'background:transparent',
118
+ 'color:#64748b',
119
+ 'font:20px/1 sans-serif',
120
+ 'cursor:pointer',
121
+ 'padding:0 2px',
122
+ ].join(';');
123
+ close.onclick = function () { try { root.remove(); } catch (_) {} };
124
+
125
+ root.appendChild(body);
126
+ root.appendChild(close);
127
+
128
+ // Anchor above the composer when we can find it, so the reason sits
129
+ // next to the draft instead of floating over unrelated content.
130
+ let anchored = false;
131
+ try {
132
+ let composer = null;
133
+ for (const selector of COMPOSER_SELECTORS) {
134
+ try {
135
+ composer = document.querySelector(selector);
136
+ } catch (_) {
137
+ composer = null;
138
+ }
139
+ if (composer) break;
140
+ }
141
+ if (composer) {
142
+ let host = null;
143
+ for (const selector of HOST_SELECTORS) {
144
+ try {
145
+ host = composer.closest(selector);
146
+ } catch (_) {
147
+ host = null;
148
+ }
149
+ if (host) break;
150
+ }
151
+ host = host || composer.parentElement;
152
+ if (host && host.parentElement) {
153
+ root.style.position = 'relative';
154
+ root.style.top = '0';
155
+ root.style.left = '0';
156
+ root.style.transform = 'none';
157
+ root.style.margin = '8px 0 12px';
158
+ root.style.maxWidth = '100%';
159
+ host.parentElement.insertBefore(root, host);
160
+ anchored = true;
161
+ }
162
+ }
163
+ } catch (_) {}
164
+
165
+ if (!anchored) {
166
+ (document.body || document.documentElement).appendChild(root);
167
+ }
168
+
169
+ // No auto-dismiss: the draft lives in the user's page, so its context should
170
+ // still be present when the user returns later. The dismiss button remains.
171
+
172
+ return { ok: true, anchored: anchored, has_reason: !!REASON };
173
+ })()`;
174
+ }
175
+ //# sourceMappingURL=browser-handoff-banner.js.map
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Shared guards and reference-batch splitting for browser-source reads.
3
+ *
4
+ * Browser connectors observe references only (WhatsApp, TikTok inbox,
5
+ * LinkedIn inbox) or take bounded snapshots (TikTok timeline/search): the
6
+ * source owns order and pagination, so offsets, sorts, time windows, and
7
+ * exact-match filters are rejected before touching the page. Each durable
8
+ * browser record is limited to 128 KiB including its checkpoint, so reference
9
+ * batches are capped at 500 events and halved until they fit; only the final
10
+ * batch carries the checkpoint, so an interruption replays instead of
11
+ * skipping.
12
+ *
13
+ * Pure (no `node:`, no `@lobu/core`): the root must stay loadable inside a V8
14
+ * isolate.
15
+ */
16
+ import type { FeedReadContext } from "./connector-types.js";
17
+ /** Max references per durable browser record. */
18
+ export declare const SOURCE_REFERENCE_BATCH_MAX_EVENTS = 500;
19
+ /** Max serialized bytes per durable browser record, checkpoint included. */
20
+ export declare const SOURCE_RECORD_MAX_BYTES: number;
21
+ export declare function jsonByteLength(value: unknown): number;
22
+ /**
23
+ * Split references into ordered batches of at most `maxEvents` references and
24
+ * `maxBytes` serialized bytes. `buildBatch` shapes each record (id,
25
+ * checkpoint on the final batch, `more`); it receives the slice, whether it
26
+ * is the last batch, and the running offset. Throws when a single reference
27
+ * cannot fit even alone.
28
+ */
29
+ export declare function splitReferenceBatches<E>(events: E[], buildBatch: (slice: E[], isLast: boolean, offset: number) => Record<string, unknown>, opts?: {
30
+ maxEvents?: number;
31
+ maxBytes?: number;
32
+ }): Record<string, unknown>[];
33
+ type ReadShape = Pick<FeedReadContext, "offset" | "sort" | "window" | "match" | "query" | "cursor" | "limit">;
34
+ export declare function assertNoOffsetPaging(ctx: Pick<ReadShape, "offset">, message: string): void;
35
+ export declare function assertNoSort(ctx: Pick<ReadShape, "sort">, message: string): void;
36
+ export declare function assertNoWindow(ctx: Pick<ReadShape, "window">, message: string): void;
37
+ export declare function assertNoMatch(ctx: Pick<ReadShape, "match">, message: string): void;
38
+ export declare function assertNoQuery(ctx: Pick<ReadShape, "query">, message: string): void;
39
+ export declare function assertNoCursor(ctx: Pick<ReadShape, "cursor">, message: string): void;
40
+ export declare function assertPositiveReadLimit(ctx: Pick<ReadShape, "limit">, message?: string): void;
41
+ /**
42
+ * Inbox reads follow source order and the returned cursor; search, offsets,
43
+ * sorting, matching, and time windows are unsupported.
44
+ */
45
+ export declare function assertInboxSourceRead(ctx: ReadShape, sourceLabel: string): void;
46
+ /**
47
+ * Bounded snapshot reads support no pagination, sorting, time windows, or
48
+ * exact-match filters.
49
+ */
50
+ export declare function assertSnapshotSourceRead(ctx: ReadShape, sourceLabel: string): void;
51
+ export {};
52
+ //# sourceMappingURL=browser-source-read.d.ts.map
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Shared guards and reference-batch splitting for browser-source reads.
3
+ *
4
+ * Browser connectors observe references only (WhatsApp, TikTok inbox,
5
+ * LinkedIn inbox) or take bounded snapshots (TikTok timeline/search): the
6
+ * source owns order and pagination, so offsets, sorts, time windows, and
7
+ * exact-match filters are rejected before touching the page. Each durable
8
+ * browser record is limited to 128 KiB including its checkpoint, so reference
9
+ * batches are capped at 500 events and halved until they fit; only the final
10
+ * batch carries the checkpoint, so an interruption replays instead of
11
+ * skipping.
12
+ *
13
+ * Pure (no `node:`, no `@lobu/core`): the root must stay loadable inside a V8
14
+ * isolate.
15
+ */
16
+ /** Max references per durable browser record. */
17
+ export const SOURCE_REFERENCE_BATCH_MAX_EVENTS = 500;
18
+ /** Max serialized bytes per durable browser record, checkpoint included. */
19
+ export const SOURCE_RECORD_MAX_BYTES = 128 * 1024;
20
+ export function jsonByteLength(value) {
21
+ return new TextEncoder().encode(JSON.stringify(value)).length;
22
+ }
23
+ /**
24
+ * Split references into ordered batches of at most `maxEvents` references and
25
+ * `maxBytes` serialized bytes. `buildBatch` shapes each record (id,
26
+ * checkpoint on the final batch, `more`); it receives the slice, whether it
27
+ * is the last batch, and the running offset. Throws when a single reference
28
+ * cannot fit even alone.
29
+ */
30
+ export function splitReferenceBatches(events, buildBatch, opts) {
31
+ const maxEvents = opts?.maxEvents ?? SOURCE_REFERENCE_BATCH_MAX_EVENTS;
32
+ const maxBytes = opts?.maxBytes ?? SOURCE_RECORD_MAX_BYTES;
33
+ const batches = [];
34
+ for (let offset = 0;;) {
35
+ const through = (end) => buildBatch(events.slice(offset, end), end === events.length, offset);
36
+ let end = Math.min(offset + maxEvents, events.length);
37
+ let batch = through(end);
38
+ while (jsonByteLength(batch) > maxBytes && end - offset > 1) {
39
+ end = offset + Math.floor((end - offset) / 2);
40
+ batch = through(end);
41
+ }
42
+ if (jsonByteLength(batch) > maxBytes) {
43
+ throw new Error("Source reference or checkpoint exceeds the browser record limit");
44
+ }
45
+ batches.push(batch);
46
+ if (end === events.length)
47
+ return batches;
48
+ offset = end;
49
+ }
50
+ }
51
+ export function assertNoOffsetPaging(ctx, message) {
52
+ if (ctx.offset)
53
+ throw new Error(message);
54
+ }
55
+ export function assertNoSort(ctx, message) {
56
+ if (ctx.sort)
57
+ throw new Error(message);
58
+ }
59
+ export function assertNoWindow(ctx, message) {
60
+ if (ctx.window)
61
+ throw new Error(message);
62
+ }
63
+ export function assertNoMatch(ctx, message) {
64
+ if (ctx.match)
65
+ throw new Error(message);
66
+ }
67
+ export function assertNoQuery(ctx, message) {
68
+ if (ctx.query)
69
+ throw new Error(message);
70
+ }
71
+ export function assertNoCursor(ctx, message) {
72
+ if (ctx.cursor)
73
+ throw new Error(message);
74
+ }
75
+ export function assertPositiveReadLimit(ctx, message = "limit must be a positive integer") {
76
+ if (ctx.limit !== undefined &&
77
+ (!Number.isInteger(ctx.limit) || ctx.limit < 1)) {
78
+ throw new Error(message);
79
+ }
80
+ }
81
+ /**
82
+ * Inbox reads follow source order and the returned cursor; search, offsets,
83
+ * sorting, matching, and time windows are unsupported.
84
+ */
85
+ export function assertInboxSourceRead(ctx, sourceLabel) {
86
+ const message = `${sourceLabel} inbox reads use source order and the returned cursor; ` +
87
+ `search, offsets, sorting, matching, and time windows are unsupported`;
88
+ assertNoOffsetPaging(ctx, message);
89
+ assertNoSort(ctx, message);
90
+ assertNoWindow(ctx, message);
91
+ assertNoMatch(ctx, message);
92
+ assertNoQuery(ctx, message);
93
+ }
94
+ /**
95
+ * Bounded snapshot reads support no pagination, sorting, time windows, or
96
+ * exact-match filters.
97
+ */
98
+ export function assertSnapshotSourceRead(ctx, sourceLabel) {
99
+ const message = `${sourceLabel} snapshot feeds do not support pagination, sorting, ` +
100
+ `time windows, or exact-match filters`;
101
+ assertNoCursor(ctx, message);
102
+ assertNoOffsetPaging(ctx, message);
103
+ assertNoSort(ctx, message);
104
+ assertNoWindow(ctx, message);
105
+ assertNoMatch(ctx, message);
106
+ }
107
+ //# sourceMappingURL=browser-source-read.js.map
@@ -569,6 +569,16 @@ export interface FeedDefinition {
569
569
  eventKinds?: Record<string, {
570
570
  description?: string;
571
571
  metadataSchema?: Record<string, unknown>;
572
+ /**
573
+ * Opt in to a separate `<kind>.updated` Automation trigger when a sync
574
+ * supersedes this source item with changed durable content and strictly
575
+ * newer `occurred_at` activity. The original kind remains insert-only.
576
+ * Unchanged rows, volatile-only updates and cold-start backfills stay
577
+ * quiet. Use activity time for `occurred_at`, not a scheduled start time.
578
+ * A declared literal kind wins a collision; composite keys over 100
579
+ * characters are not derived. Persisted unchanged in feeds_schema.
580
+ */
581
+ updatedEvent?: boolean;
572
582
  /**
573
583
  * Generic event attribution declarations. New connector work should model
574
584
  * "who authored / what resource this event belongs to / what it is about"
@@ -34,6 +34,9 @@ export { calculateEngagementScore } from './scoring.js';
34
34
  export { ConnectorAutomationEventSchema, ConnectorAutomationSignalDraftSchema, SubscriptionCandidateSchema, } from './automation-triggers.js';
35
35
  export type { AutomationEventTrigger, AutomationScheduleTrigger, AutomationTrigger, AutomationWorkspaceEventTrigger, ConnectorAutomationEvent, ConnectorAutomationSignalDraft, ConnectorTriggerSignal, SubscriptionCandidate, } from './automation-triggers.js';
36
36
  export { applyLookbackCutoff } from './checkpoint/lookback.js';
37
+ export { buildInjectHandoffBannerExpression, truncateHandoffReason, } from './browser-handoff-banner.js';
38
+ export type { HandoffBannerOptions } from './browser-handoff-banner.js';
39
+ export { assertInboxSourceRead, assertNoCursor, assertNoMatch, assertNoOffsetPaging, assertNoQuery, assertNoSort, assertNoWindow, assertPositiveReadLimit, assertSnapshotSourceRead, jsonByteLength, SOURCE_RECORD_MAX_BYTES, SOURCE_REFERENCE_BATCH_MAX_EVENTS, splitReferenceBatches, } from './browser-source-read.js';
37
40
  export { buildTimestampCheckpoint, filterByCheckpoint, finalizeTimestampSync, } from './checkpoint/timestamp-watermark.js';
38
41
  export { validatePublicUrl, validateUrlDomain } from './url-guards.js';
39
42
  export { sleep } from './sleep.js';
@@ -33,6 +33,8 @@ export { ConnectorAutomationEventSchema, ConnectorAutomationSignalDraftSchema, S
33
33
  // The root must stay loadable inside a V8 isolate.
34
34
  // =============================================================================
35
35
  export { applyLookbackCutoff } from './checkpoint/lookback.js';
36
+ export { buildInjectHandoffBannerExpression, truncateHandoffReason, } from './browser-handoff-banner.js';
37
+ export { assertInboxSourceRead, assertNoCursor, assertNoMatch, assertNoOffsetPaging, assertNoQuery, assertNoSort, assertNoWindow, assertPositiveReadLimit, assertSnapshotSourceRead, jsonByteLength, SOURCE_RECORD_MAX_BYTES, SOURCE_REFERENCE_BATCH_MAX_EVENTS, splitReferenceBatches, } from './browser-source-read.js';
36
38
  export { buildTimestampCheckpoint, filterByCheckpoint, finalizeTimestampSync, } from './checkpoint/timestamp-watermark.js';
37
39
  export { validatePublicUrl, validateUrlDomain } from './url-guards.js';
38
40
  export { sleep } from './sleep.js';
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/connector-sdk",
3
- "version": "22.0.0",
3
+ "version": "24.0.0",
4
4
  "description": "Lobu memory SDK — build pluggable connectors for Lobu memory",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,6 +20,14 @@
20
20
  "types": "./dist/browser-requirement.d.ts",
21
21
  "import": "./dist/browser-requirement.js"
22
22
  },
23
+ "./browser-handoff-banner": {
24
+ "types": "./dist/browser-handoff-banner.d.ts",
25
+ "import": "./dist/browser-handoff-banner.js"
26
+ },
27
+ "./browser-source-read": {
28
+ "types": "./dist/browser-source-read.d.ts",
29
+ "import": "./dist/browser-source-read.js"
30
+ },
23
31
  "./define-connector": {
24
32
  "import": {
25
33
  "types": "./dist/define-connector.d.ts",
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The turn's gateway tools: `ask_user`, `send_message`, `suggest_actions` and
3
- * the rest of `@lobu/plugin-conversations`.
2
+ * The turn's gateway tools: `ask_user`, `send_message` and the rest of
3
+ * `@lobu/plugin-conversations`.
4
4
  *
5
5
  * GUEST code, bundled with the agent entry, so the same portability rules as
6
6
  * `workspace.ts` apply: no `node:` import, no host module, no root
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The turn's gateway tools: `ask_user`, `send_message`, `suggest_actions` and
3
- * the rest of `@lobu/plugin-conversations`.
2
+ * The turn's gateway tools: `ask_user`, `send_message` and the rest of
3
+ * `@lobu/plugin-conversations`.
4
4
  *
5
5
  * GUEST code, bundled with the agent entry, so the same portability rules as
6
6
  * `workspace.ts` apply: no `node:` import, no host module, no root
@@ -18,16 +18,26 @@
18
18
  * swaps it into the outbound header, the secret proxy accepts it as the
19
19
  * provider credential and the MCP route accepts it as the bearer.
20
20
  */
21
+ import { mcpToolResult, toolImageBudget } from '@lobu/plugin-toolkit';
22
+ import { FOLLOW_UP_SUGGESTIONS_PROMPT, parseFollowUpSuggestions } from '@lobu/core/agent-tooling';
21
23
  import { createGatewayTools } from './gateway-tools.js';
22
24
  import { createTurnMediaTools } from './media-tools.js';
23
25
  import { createTurnMemoryHooks } from './memory.js';
24
26
  import { estimatePromptTokenCost, memoryFlushDue, MEMORY_FLUSH_STATE_CUSTOM_TYPE } from '@lobu/core/memory-flush';
25
27
  import { isRetrievalTool, summarizeToolTrace } from '@lobu/core/tool-trace-summary';
26
- import { createNativeSession, nativeSessionJsonl, promptNativeSession } from './native-session.js';
28
+ import { askAside, createNativeSession, nativeSessionJsonl, promptNativeSession } from './native-session.js';
27
29
  import { MAX_TOOL_CALLS_PER_TURN } from './types.js';
28
30
  import { createWorkspace, INPUT_DIR, SKILLS_DIR, } from './workspace.js';
29
31
  /** Third-party MCP server on the other side of the gateway: generous, never forever. */
30
32
  const TOOL_CALL_TIMEOUT_MS = 120_000;
33
+ /**
34
+ * The follow-up chips request. It runs after the answer has streamed and
35
+ * before the turn completes, so this bounds how much later the reply is
36
+ * marked done; a slower model simply yields no chips.
37
+ */
38
+ const FOLLOW_UPS_TIMEOUT_MS = 10_000;
39
+ /** A chips reply is a few short JSON objects. */
40
+ const FOLLOW_UPS_MAX_TOKENS = 400;
31
41
  /**
32
42
  * What of a tool's output the host sees in the event stream.
33
43
  *
@@ -52,7 +62,7 @@ function joinText(content) {
52
62
  * result, so a blocked or approval-gated call reaches the model as text and the
53
63
  * turn goes on.
54
64
  */
55
- async function callMcpTool(gatewayUrl, credential, tool, args, timeoutMs = TOOL_CALL_TIMEOUT_MS) {
65
+ async function callMcpTool(gatewayUrl, credential, tool, args, timeoutMs = TOOL_CALL_TIMEOUT_MS, supportsImages = true, imageBudget) {
56
66
  const url = `${gatewayUrl}/mcp/${encodeURIComponent(tool.mcpId)}/tools/${encodeURIComponent(tool.name)}`;
57
67
  let response;
58
68
  try {
@@ -91,7 +101,7 @@ async function callMcpTool(gatewayUrl, credential, tool, args, timeoutMs = TOOL_
91
101
  // Ordinary agent tools render this same result below; no second transport.
92
102
  return {
93
103
  ...reply,
94
- content: [{ type: 'text', text: text || reply.error || '' }],
104
+ ...mcpToolResult(reply.isError === true ? reply.content?.filter(part => part?.type === 'text') : reply.content, reply.error || '', supportsImages, imageBudget),
95
105
  };
96
106
  }
97
107
  /**
@@ -102,9 +112,10 @@ async function callMcpTool(gatewayUrl, credential, tool, args, timeoutMs = TOOL_
102
112
  * `createGatewayTools`.
103
113
  */
104
114
  function buildTools(input, credential, onAskUserPosted, onInBandReplyDelivered, emit, runtimeExec) {
115
+ const imageBudget = toolImageBudget((input.images ?? []).map(image => ({ type: 'image', data: image.data })));
105
116
  const tools = input.tools;
106
117
  if (!tools)
107
- return { tools: [], workspace: null, canReadFiles: false };
118
+ return { tools: [], workspace: null, canReadFiles: false, imageBudget };
108
119
  // ONE workspace for the whole turn: the file tools act on it and
109
120
  // `upload_file` reads it, so the file the model just wrote is the file it can
110
121
  // show. Built even when no file tool was admitted but a media tool was, since
@@ -140,12 +151,14 @@ function buildTools(input, credential, onAskUserPosted, onInBandReplyDelivered,
140
151
  // A plain JSON schema: pi-ai validates arguments against it as-is.
141
152
  parameters: tool.inputSchema,
142
153
  execute: async (_toolCallId, args) => {
143
- const result = await callMcpTool(tools.gatewayUrl, credential, tool, args);
154
+ const result = await callMcpTool(tools.gatewayUrl, credential, tool, args, TOOL_CALL_TIMEOUT_MS, input.provider.input?.includes('image') === true, imageBudget);
144
155
  const text = joinText(result.content);
145
156
  if (result.isError === true)
146
157
  throw new Error(String(result.error || text || `${tool.name} failed`));
147
158
  return {
148
- content: [{ type: 'text', text: text || `${tool.name} completed.` }],
159
+ content: text || result.content.some((part) => part.type === 'image')
160
+ ? result.content
161
+ : [{ type: 'text', text: `${tool.name} completed.` }],
149
162
  details: {},
150
163
  };
151
164
  },
@@ -157,6 +170,7 @@ function buildTools(input, credential, onAskUserPosted, onInBandReplyDelivered,
157
170
  tools: [...mcp, ...gateway, ...media, ...(workspace?.tools ?? [])],
158
171
  workspace,
159
172
  canReadFiles,
173
+ imageBudget,
160
174
  };
161
175
  }
162
176
  /**
@@ -333,7 +347,7 @@ export async function runAgentTurn(input, emit, takeSteering = () => [], runtime
333
347
  agentId: input.memory.agentId,
334
348
  conversationId: input.tools.conversation?.conversationId ?? '',
335
349
  mcpId: input.memory.mcpId,
336
- callTool: (mcpId, toolName, args, options) => callMcpTool(input.tools.gatewayUrl, credential, { mcpId, name: toolName, description: '', inputSchema: {} }, args, options?.timeoutMs),
350
+ callTool: (mcpId, toolName, args, options) => callMcpTool(input.tools.gatewayUrl, credential, { mcpId, name: toolName, description: '', inputSchema: {} }, args, options?.timeoutMs).then((result) => ({ ...result, content: [{ type: 'text', text: joinText(result.content) }] })),
337
351
  logger: guestLogger,
338
352
  })
339
353
  : null;
@@ -434,6 +448,10 @@ export async function runAgentTurn(input, emit, takeSteering = () => [], runtime
434
448
  const text = messageText(message);
435
449
  return text === undefined ? undefined : messageContext.get(text);
436
450
  });
451
+ // Only the isolate must fit the full checkpoint through a bounded bridge.
452
+ // buildTools charged this prompt's images; add the already-hydrated history.
453
+ built.imageBudget.bytes += toolImageBudget(session.sessionManager.getEntries().flatMap(entry => entry.type === 'message' && 'content' in entry.message && Array.isArray(entry.message.content)
454
+ ? entry.message.content : [])).bytes;
437
455
  session.subscribe((event) => {
438
456
  if (event.type === 'compaction_end' && event.errorMessage)
439
457
  console.warn(event.errorMessage);
@@ -445,7 +463,7 @@ export async function runAgentTurn(input, emit, takeSteering = () => [], runtime
445
463
  // another request every time and an answer could still follow `ask_user`.
446
464
  //
447
465
  // `block` keeps its job — a sibling scheduled in the same batch must not
448
- // RUN, since `suggest_actions`/`send_message` post to the user — and
466
+ // RUN, since `send_message` posts to the user — and
449
467
  // `agent.abort()` is what ends generation. Pi's own `terminate` hint cannot
450
468
  // do it here: `shouldTerminateToolBatch` needs every result in the batch to
451
469
  // set it, and a blocked call is short-circuited as `kind:'immediate'`, which
@@ -734,6 +752,28 @@ export async function runAgentTurn(input, emit, takeSteering = () => [], runtime
734
752
  }
735
753
  if (ended)
736
754
  throw new Error(ended);
755
+ // Follow-up chips, asked of the model that just answered. They ride the
756
+ // result, so the gateway delivers them with the reply: embedded on web's
757
+ // `complete`, posted after the reply on chat, and dropped if a guardrail
758
+ // blocks it. Skipped when the turn already handed control back
759
+ // (`ask_user`), posted its answer in-band, or answered steered follow-ups
760
+ // as well — each of those inputs completes on its own.
761
+ let suggestions = [];
762
+ if (input.tools?.followUps && !askedUser && !repliedInBand && steeredMessages.size === 0 && finalText.trim()) {
763
+ try {
764
+ const reply = await askAside(session, credential, FOLLOW_UP_SUGGESTIONS_PROMPT, {
765
+ maxTokens: FOLLOW_UPS_MAX_TOKENS,
766
+ signal: AbortSignal.timeout(FOLLOW_UPS_TIMEOUT_MS),
767
+ });
768
+ suggestions = parseFollowUpSuggestions(reply);
769
+ }
770
+ catch (error) {
771
+ // Chips are optional: a slow or failed request leaves the answer as is.
772
+ console.warn('follow-up suggestions failed; the turn completes without them', {
773
+ error: error instanceof Error ? error.message : String(error),
774
+ });
775
+ }
776
+ }
737
777
  return {
738
778
  // The answer is the last assistant message WITH TEXT after each user
739
779
  // message, not the accumulated stream: a model that narrates before a
@@ -783,6 +823,7 @@ export async function runAgentTurn(input, emit, takeSteering = () => [], runtime
783
823
  }];
784
824
  }),
785
825
  ...(repliedInBand ? { repliedInBand: true } : {}),
826
+ ...(suggestions.length > 0 ? { suggestions } : {}),
786
827
  };
787
828
  }
788
829
  finally {