@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,104 @@
1
+ // Serialized into the activated LinkedIn page with Function.prototype.toString(),
2
+ // so it stays plain JS: no syntax a transform would rewrite, no outer bindings.
3
+ /** Serialized as one closed function; never clicks Send/Post or presses Enter. */
4
+ export async function fillLinkedInDraft(input) {
5
+ function fail(message) {
6
+ throw new Error(`LinkedIn draft: ${message}`);
7
+ }
8
+ if (location.href !== input.url)
9
+ fail("The activated page is not the requested draft target");
10
+ const visible = (element) =>
11
+ element.getClientRects().length > 0 &&
12
+ getComputedStyle(element).visibility !== "hidden";
13
+ let editor;
14
+ if (input.kind === "prepare_message") {
15
+ const selected = [
16
+ ...document.querySelectorAll(
17
+ '.msg-conversation-listitem--active a[href*="/messaging/thread/"], a[aria-current="page"][href*="/messaging/thread/"]'
18
+ ),
19
+ ].filter(
20
+ (link) =>
21
+ visible(link) &&
22
+ new URL(link.href).pathname === new URL(input.url).pathname
23
+ );
24
+ if (selected.length !== 1)
25
+ fail("The selected conversation does not match the requested recipient");
26
+ const threads = [...document.querySelectorAll(".msg-thread")].filter(
27
+ visible
28
+ );
29
+ if (threads.length !== 1) fail("Exactly one conversation must be open");
30
+ const editors = [
31
+ ...threads[0].querySelectorAll(
32
+ '.msg-form [contenteditable="true"][role="textbox"]'
33
+ ),
34
+ ].filter(visible);
35
+ if (editors.length !== 1)
36
+ fail("The conversation message composer is unavailable");
37
+ editor = editors[0];
38
+ if (
39
+ threads[0].querySelector(
40
+ '.msg-form__attachment, .msg-form__attachments [data-attachment-id], input[type="file"]:disabled'
41
+ )
42
+ ) {
43
+ fail("The conversation already has an attachment draft");
44
+ }
45
+ } else if (input.kind === "prepare_post") {
46
+ if (document.querySelector('[role="dialog"] [contenteditable="true"]'))
47
+ fail("A composer is already open; finish or close it first");
48
+ const buttons = [
49
+ ...document.querySelectorAll(
50
+ 'button, a[href="https://www.linkedin.com/preload/sharebox/?"]'
51
+ ),
52
+ ].filter(
53
+ (button) =>
54
+ visible(button) && button.textContent?.trim() === "Start a post"
55
+ );
56
+ if (buttons.length !== 1)
57
+ fail("The personal post composer entry point is unavailable");
58
+ buttons[0].click();
59
+ for (let attempt = 0; attempt < 40; attempt++) {
60
+ const editors = [
61
+ ...document.querySelectorAll(
62
+ '[role="dialog"] [contenteditable="true"][role="textbox"], [role="dialog"] .ql-editor[contenteditable="true"]'
63
+ ),
64
+ ].filter(visible);
65
+ if (editors.length === 1) {
66
+ editor = editors[0];
67
+ break;
68
+ }
69
+ await new Promise((resolve) => setTimeout(resolve, 100));
70
+ }
71
+ if (!editor) fail("The personal post composer did not open");
72
+ const dialog = editor.closest('[role="dialog"]');
73
+ if (
74
+ !dialog ||
75
+ dialog.querySelector('input[type="file"]:disabled, [data-attachment-id]')
76
+ )
77
+ fail("The post composer is not an empty text draft");
78
+ } else fail("Unsupported draft action");
79
+ if (!editor || location.href !== input.url)
80
+ fail("The activated target changed");
81
+ if (
82
+ (editor.textContent ?? "").trim() ||
83
+ editor.querySelector("img,video,audio,[contenteditable=false]")
84
+ )
85
+ fail("The composer already contains a draft");
86
+ editor.focus();
87
+ if (!document.execCommand("insertText", false, input.body))
88
+ fail("The browser could not fill the draft");
89
+ const normalized = (value) => value.replace(/\r\n/g, "\n").trim();
90
+ if (
91
+ normalized(editor.innerText ?? editor.textContent ?? "") !==
92
+ normalized(input.body)
93
+ )
94
+ fail("The draft text could not be verified; review the composer");
95
+ return {
96
+ prepared: true,
97
+ submitted: false,
98
+ url: input.url,
99
+ message:
100
+ input.kind === "prepare_message"
101
+ ? "Draft ready. Review it and click Send in LinkedIn."
102
+ : "Draft ready. Review it and click Post in LinkedIn.",
103
+ };
104
+ }
@@ -0,0 +1,73 @@
1
+ import {
2
+ requireBrowser,
3
+ type ActionContext,
4
+ type ActionResult,
5
+ } from "@lobu/connector-sdk";
6
+ import {
7
+ LINKEDIN_HOME_URL,
8
+ linkedInScriptArgument,
9
+ } from "./linkedin-browser-script.js";
10
+ import { fillLinkedInDraft } from "./linkedin-draft-page.js";
11
+
12
+ export function linkedInDraftUrl(
13
+ kind: string,
14
+ input: Record<string, unknown>
15
+ ): string {
16
+ if (kind === "prepare_post") return LINKEDIN_HOME_URL;
17
+ const url = new URL(String(input.conversation_url ?? ""));
18
+ if (
19
+ url.origin !== "https://www.linkedin.com" ||
20
+ url.username ||
21
+ url.password ||
22
+ url.search ||
23
+ url.hash ||
24
+ !/^\/messaging\/thread\/[A-Za-z0-9_=%-]+\/$/.test(url.pathname)
25
+ ) {
26
+ throw new Error(
27
+ "conversation_url must be the exact LinkedIn conversation URL ending in a slash"
28
+ );
29
+ }
30
+ return url.href;
31
+ }
32
+
33
+ export async function prepareLinkedInDraft(
34
+ ctx: ActionContext
35
+ ): Promise<ActionResult> {
36
+ try {
37
+ const body =
38
+ typeof ctx.input.body === "string" ? ctx.input.body.trim() : "";
39
+ if (!body || body.length > 3000)
40
+ throw new Error("body must contain 1–3000 characters");
41
+ const url = linkedInDraftUrl(ctx.actionKey, ctx.input);
42
+ const browser = requireBrowser(ctx);
43
+ const nav = await browser.dispatch<{ tab_id?: number }>("navigate", {
44
+ url,
45
+ require_page_activation: true,
46
+ });
47
+ if (typeof nav.tab_id !== "number")
48
+ throw new Error("The activated LinkedIn page is unavailable");
49
+ const result = await browser.dispatch<{
50
+ value?: Record<string, unknown>;
51
+ exception?: unknown;
52
+ }>("evaluate", {
53
+ tab_id: nav.tab_id,
54
+ await_promise: true,
55
+ expression: `(${fillLinkedInDraft.toString()})(${linkedInScriptArgument({ kind: ctx.actionKey, url, body })})`,
56
+ });
57
+ if (
58
+ result.exception ||
59
+ result.value?.prepared !== true ||
60
+ result.value?.submitted !== false
61
+ ) {
62
+ throw new Error(
63
+ `Draft could not be verified: ${JSON.stringify(result.exception ?? result.value)}`
64
+ );
65
+ }
66
+ return { success: true, output: { ...result.value, tab_id: nav.tab_id } };
67
+ } catch (error) {
68
+ return {
69
+ success: false,
70
+ error: error instanceof Error ? error.message : String(error),
71
+ };
72
+ }
73
+ }
@@ -7,6 +7,7 @@
7
7
  * connector that extracted them.
8
8
  */
9
9
 
10
+ import type { ChatUserIdentity } from "./chat-user-identity.js";
10
11
  import type { ConnectorIdentityModule } from "./connector-identity-module.js";
11
12
 
12
13
  /** Connector-owned identity namespaces (not SDK-global). */
@@ -19,6 +20,13 @@ export const LINKEDIN_IDENTITY = {
19
20
  SLUG: "linkedin_slug",
20
21
  /** Immutable member id from `urn:li:fsd_profile:<id>`. */
21
22
  MEMBER_ID: "linkedin_member_id",
23
+ /**
24
+ * A direct-message sender's member id, linking the sender to a Lobu member.
25
+ * Distinct from `linkedin_member_id`, the person-entity attribution key, so
26
+ * a chat link on a `$member` never collides with the contact entity the same
27
+ * sender's messages auto-create.
28
+ */
29
+ USER_MEMBER_ID: "linkedin_user_member_id",
22
30
  } as const;
23
31
 
24
32
  export type LinkedInIdentityNamespace =
@@ -66,6 +74,7 @@ export function normalizeLinkedInIdentityValue(
66
74
  case LINKEDIN_IDENTITY.SLUG:
67
75
  return normalizeLinkedInSlug(raw);
68
76
  case LINKEDIN_IDENTITY.MEMBER_ID:
77
+ case LINKEDIN_IDENTITY.USER_MEMBER_ID:
69
78
  return normalizeLinkedInMemberId(raw);
70
79
  default:
71
80
  return undefined;
@@ -78,3 +87,26 @@ export const linkedInIdentityModule: ConnectorIdentityModule = {
78
87
  recallNamespaces: [LINKEDIN_IDENTITY.SLUG, LINKEDIN_IDENTITY.MEMBER_ID],
79
88
  normalize: normalizeLinkedInIdentityValue,
80
89
  };
90
+
91
+ /**
92
+ * LinkedIn's direct-message sender model. Member ids are unique across
93
+ * LinkedIn, so there is no tenant axis: `teamId` is ignored and the scope is
94
+ * global.
95
+ *
96
+ * LinkedIn's OpenID sign-in returns an opaque `sub`, not the messaging member
97
+ * id, so no sign-in extractor writes this namespace; a link comes only from the
98
+ * explicit, sender-proven chat link offered in the direct message.
99
+ */
100
+ export const linkedInChatUserIdentity: ChatUserIdentity = {
101
+ platform: "linkedin",
102
+ providerId: "linkedin",
103
+ namespace: LINKEDIN_IDENTITY.USER_MEMBER_ID,
104
+ buildUserKey(_teamId, platformUserId) {
105
+ return normalizeLinkedInMemberId(platformUserId);
106
+ },
107
+ userKeyScope: () => ({ kind: "global" }),
108
+ // The stored key is the member id the adapter puts on a message author.
109
+ platformUserIdFromKey(key) {
110
+ return normalizeLinkedInMemberId(key);
111
+ },
112
+ };