@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,156 @@
1
+ import {
2
+ assertInboxSourceRead,
3
+ assertNoCursor,
4
+ assertNoMatch,
5
+ assertNoOffsetPaging,
6
+ assertNoSort,
7
+ assertNoWindow,
8
+ requireBrowser,
9
+ type ActionContext,
10
+ type ActionResult,
11
+ type FeedObserveContext,
12
+ type FeedReadContext,
13
+ type FeedReadResult,
14
+ type ChromeActionDispatcher,
15
+ } from "@lobu/connector-sdk";
16
+ import { linkedInInboxProgram } from "./linkedin-inbox-adapter.js";
17
+ import {
18
+ LINKEDIN_HOME_URL,
19
+ linkedInScriptArgument,
20
+ } from "./linkedin-browser-script.js";
21
+
22
+ export interface LinkedInInboxCheckpoint {
23
+ linkedin_inbox?: Record<string, unknown>;
24
+ }
25
+
26
+ /**
27
+ * The live messages feed's `inbox` setting: absent or "me" reads the signed-in
28
+ * member's inbox; a page mailbox URN reads that company page's inbox, which the
29
+ * member must administer. Other feeds read the member's own sources.
30
+ */
31
+ function inboxOf(feedKey: string, config: unknown): unknown {
32
+ return feedKey === "live_messages"
33
+ ? (config as { inbox?: unknown } | null | undefined)?.inbox
34
+ : undefined;
35
+ }
36
+
37
+ async function readyTab(browser: ChromeActionDispatcher): Promise<number> {
38
+ // Opening the inbox itself marks conversations seen. A scrape-owned neutral
39
+ // tab supplies authentication without changing notification/message state.
40
+ // Use LinkedIn's settled route: /feed/ redirects and reloads the warm tab,
41
+ // destroying the other feed's listener on every read or observation setup.
42
+ const tab = await browser.dispatch<{ tab_id?: number }>("navigate", {
43
+ url: LINKEDIN_HOME_URL,
44
+ persistent: true,
45
+ wait_for_load: true,
46
+ });
47
+ if (typeof tab.tab_id !== "number")
48
+ throw new Error("LinkedIn source tab is unavailable");
49
+ return tab.tab_id;
50
+ }
51
+
52
+ async function invoke<T>(
53
+ browser: ChromeActionDispatcher,
54
+ tabId: number,
55
+ op: "read" | "listen" | "send",
56
+ input: Record<string, unknown>
57
+ ): Promise<T> {
58
+ const result = await browser.dispatch<{ value?: T; exception?: unknown }>(
59
+ "evaluate",
60
+ {
61
+ tab_id: tabId,
62
+ expression: `(() => { (${linkedInInboxProgram.toString()})(); return globalThis.__lobuLinkedInInboxV1.${op}(${linkedInScriptArgument(input)}); })()`,
63
+ await_promise: true,
64
+ }
65
+ );
66
+ if (result.exception || !result.value)
67
+ throw new Error(
68
+ `LinkedIn source ${op} failed: ${JSON.stringify(result.exception ?? "empty response")}`
69
+ );
70
+ return result.value;
71
+ }
72
+
73
+ /**
74
+ * Send one text reply into an existing direct-message conversation from the
75
+ * scrape-owned tab, without opening the inbox. A full conversation URN sends
76
+ * from the inbox it names (a company page's, for a page feed's row). The page program refuses group
77
+ * or unknown conversations, dedupes on `idempotency_key`, and returns only once
78
+ * the message shows in the conversation.
79
+ */
80
+ export async function sendLinkedInMessage(
81
+ ctx: ActionContext
82
+ ): Promise<ActionResult> {
83
+ try {
84
+ const browser = requireBrowser(ctx);
85
+ const output = await invoke<Record<string, unknown>>(
86
+ browser,
87
+ await readyTab(browser),
88
+ "send",
89
+ {
90
+ conversation_id: ctx.input.conversation_id,
91
+ text: ctx.input.text,
92
+ idempotency_key: ctx.input.idempotency_key,
93
+ }
94
+ );
95
+ return { success: true, output };
96
+ } catch (error) {
97
+ return {
98
+ success: false,
99
+ error: error instanceof Error ? error.message : String(error),
100
+ };
101
+ }
102
+ }
103
+
104
+ export async function readLinkedInInbox<F>(
105
+ ctx: FeedReadContext<F>
106
+ ): Promise<FeedReadResult> {
107
+ if (ctx.feedKey === "live_messages" && ctx.query?.startsWith("id:")) {
108
+ // A message reference read back by id (chat ingress, Automations).
109
+ const message =
110
+ "LinkedIn message lookup by id:<message URN> takes no cursor, offset, sorting, matching, or time window";
111
+ assertNoCursor(ctx, message);
112
+ assertNoOffsetPaging(ctx, message);
113
+ assertNoSort(ctx, message);
114
+ assertNoWindow(ctx, message);
115
+ assertNoMatch(ctx, message);
116
+ } else {
117
+ assertInboxSourceRead(ctx, "LinkedIn");
118
+ }
119
+ const browser = requireBrowser(ctx);
120
+ return invoke(browser, await readyTab(browser), "read", {
121
+ feed: ctx.feedKey,
122
+ inbox: inboxOf(ctx.feedKey, ctx.config),
123
+ query: ctx.query,
124
+ cursor: ctx.cursor,
125
+ limit: ctx.limit,
126
+ });
127
+ }
128
+
129
+ export async function observeLinkedInInbox<
130
+ C extends LinkedInInboxCheckpoint,
131
+ F,
132
+ >(ctx: FeedObserveContext<C, F>): Promise<void> {
133
+ const browser = requireBrowser(ctx);
134
+ const tabId = await readyTab(browser);
135
+ const binding = await browser.dispatch<{
136
+ bridge_id?: string;
137
+ token?: string;
138
+ listening?: boolean;
139
+ subscription?: { scope_key: string };
140
+ }>("feed_listen", { tab_id: tabId });
141
+ if (
142
+ !binding.bridge_id ||
143
+ !binding.token ||
144
+ !binding.subscription ||
145
+ binding.listening === false
146
+ ) {
147
+ throw new Error("The paired browser must support source subscriptions");
148
+ }
149
+ await invoke(browser, tabId, "listen", {
150
+ feed: ctx.feedKey,
151
+ inbox: inboxOf(ctx.feedKey, ctx.config),
152
+ checkpoint: ctx.checkpoint,
153
+ bridge_id: binding.bridge_id,
154
+ token: binding.token,
155
+ });
156
+ }
@@ -0,0 +1,114 @@
1
+ import type { ChromeActionDispatcher } from "@lobu/connector-sdk";
2
+
3
+ const origins = ["linkedin.com", "*.linkedin.com"];
4
+
5
+ /** The selector is deliberately limited to the observed top-level post button;
6
+ * reaction buttons inside comment containers are excluded.
7
+ */
8
+ export function buildLinkedInLikeExpression(
9
+ postUrl: string,
10
+ desired: boolean | null
11
+ ): string {
12
+ return String.raw`(async () => {
13
+ const expected = new URL(${JSON.stringify(postUrl)});
14
+ const desired = ${JSON.stringify(desired)};
15
+ const assertPage = () => {
16
+ if (location.origin !== expected.origin || location.pathname.replace(/\/$/, '') !== expected.pathname.replace(/\/$/, ''))
17
+ throw new Error('LinkedIn post changed; refusing to react');
18
+ };
19
+ const read = () => {
20
+ assertPage();
21
+ const buttons = [...document.querySelectorAll('main button[aria-label^="Reaction button state:"], [role="main"] button[aria-label^="Reaction button state:"]')]
22
+ .filter(b => b.getClientRects().length && !b.closest('[id^="replaceableComment_"], [componentkey^="commentsSectionContainer"], .comments-comment-item'));
23
+ if (buttons.length > 1) throw new Error('LinkedIn post reaction control is ambiguous');
24
+ if (!buttons.length) return null;
25
+ const button = buttons[0];
26
+ const label = button.getAttribute('aria-label').slice('Reaction button state:'.length).trim().toLowerCase();
27
+ if (label !== 'no reaction' && label !== 'like') throw new Error('Preserving an existing or unknown LinkedIn reaction: ' + label);
28
+ if (button.disabled || button.getAttribute('aria-disabled') === 'true') throw new Error('LinkedIn reaction control is disabled');
29
+ return { button, liked: label === 'like' };
30
+ };
31
+ const wait = async (test) => {
32
+ for (let i = 0; i < 40; i++) {
33
+ const result = read();
34
+ if (result && test(result)) return result;
35
+ await new Promise(resolve => setTimeout(resolve, 200));
36
+ }
37
+ throw new Error('LinkedIn reaction state could not be verified');
38
+ };
39
+ const before = await wait(() => true);
40
+ const changed = desired !== null && before.liked !== desired;
41
+ if (changed) {
42
+ assertPage();
43
+ before.button.click();
44
+ await wait(state => state.liked === desired);
45
+ }
46
+ const after = read();
47
+ if (!after) throw new Error('LinkedIn reaction control disappeared');
48
+ return { liked: after.liked, changed, post_url: expected.href };
49
+ })()`;
50
+ }
51
+
52
+ export async function setLinkedInLike(
53
+ browser: ChromeActionDispatcher,
54
+ postUrl: string,
55
+ liked: boolean
56
+ ): Promise<{
57
+ post_url: string;
58
+ liked: boolean;
59
+ changed: boolean;
60
+ verified: true;
61
+ }> {
62
+ let tabId: number | undefined;
63
+ try {
64
+ const nav = await browser.dispatch<{ tab_id?: number }>("navigate", {
65
+ url: postUrl,
66
+ new_tab: true,
67
+ wait_for_load: true,
68
+ allowed_origins: origins,
69
+ });
70
+ tabId = nav.tab_id;
71
+ if (typeof tabId !== "number")
72
+ throw new Error("LinkedIn scratch tab was not created");
73
+ const read = async (desired: boolean | null) => {
74
+ const result = await browser.dispatch<{
75
+ value?: { liked: boolean; changed: boolean; post_url: string };
76
+ }>("evaluate", {
77
+ tab_id: tabId,
78
+ expression: buildLinkedInLikeExpression(postUrl, desired),
79
+ allowed_origins: origins,
80
+ });
81
+ if (
82
+ !result.value ||
83
+ result.value.post_url !== postUrl ||
84
+ typeof result.value.liked !== "boolean"
85
+ )
86
+ throw new Error("LinkedIn returned no verified reaction state");
87
+ return result.value;
88
+ };
89
+ const effect = await read(liked);
90
+ // A second navigation reads server-backed state, including on a retry that
91
+ // already matches. Never toggle again after an uncertain write result.
92
+ await browser.dispatch("navigate", {
93
+ url: postUrl,
94
+ tab_id: tabId,
95
+ wait_for_load: true,
96
+ allowed_origins: origins,
97
+ });
98
+ const persisted = await read(null);
99
+ if (persisted.liked !== liked)
100
+ throw new Error("LinkedIn like state did not persist after reload");
101
+ return {
102
+ post_url: postUrl,
103
+ liked,
104
+ changed: effect.changed,
105
+ verified: true,
106
+ };
107
+ } finally {
108
+ if (typeof tabId === "number")
109
+ await browser.dispatch("close_tab", {
110
+ tab_id: tabId,
111
+ allowed_origins: origins,
112
+ });
113
+ }
114
+ }