@lobu/runtime-device 21.2.1 → 23.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.
- package/dist/component.json +1 -1
- package/dist/dependencies.bun.lock +91 -83
- package/npm-shrinkwrap.json +492 -438
- package/package.json +12 -2
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +1 -1
- package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +5 -6
- package/vendor/cli/dist/commands/_lib/apply/client.d.ts +1 -0
- package/vendor/cli/dist/commands/_lib/apply/client.js +26 -7
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +9 -1
- package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +1 -0
- package/vendor/cli/dist/commands/_lib/apply/diff.js +46 -4
- package/vendor/cli/dist/commands/_lib/apply/map-config.js +18 -38
- package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +5 -17
- package/vendor/cli/dist/commands/init.d.ts +0 -2
- package/vendor/cli/dist/commands/init.js +0 -27
- package/vendor/cli/dist/commands/login.d.ts +17 -0
- package/vendor/cli/dist/commands/login.js +43 -17
- package/vendor/cli/dist/commands/memory/_lib/errors.d.ts +0 -8
- package/vendor/cli/dist/commands/memory/_lib/errors.js +0 -12
- package/vendor/cli/dist/commands/memory/_lib/mcp.js +6 -6
- package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +4 -10
- package/vendor/cli/dist/config/define.d.ts +21 -15
- package/vendor/cli/dist/config/define.js +2 -2
- package/vendor/cli/dist/connectors/README.md +21 -6
- package/vendor/cli/dist/connectors/_google/actions.ts +270 -0
- package/vendor/cli/dist/connectors/_google/discovery/calendar_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/chat_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/docs_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/drive_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/gmail_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/people_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/sheets_v4.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/tasks_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/youtube_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery.ts +442 -0
- package/vendor/cli/dist/connectors/_google/errors.ts +91 -0
- package/vendor/cli/dist/connectors/_google/list-feed.ts +223 -0
- package/vendor/cli/dist/connectors/_google/policies.ts +127 -0
- package/vendor/cli/dist/connectors/agentid.ts +43 -0
- package/vendor/cli/dist/connectors/chat-user-identity.ts +2 -1
- package/vendor/cli/dist/connectors/github-automation-events.ts +9 -0
- package/vendor/cli/dist/connectors/github-identity.ts +28 -3
- package/vendor/cli/dist/connectors/github.ts +101 -59
- package/vendor/cli/dist/connectors/google_calendar.ts +207 -719
- package/vendor/cli/dist/connectors/google_drive.ts +16 -2
- package/vendor/cli/dist/connectors/google_gmail.ts +52 -33
- package/vendor/cli/dist/connectors/herdr.ts +406 -0
- package/vendor/cli/dist/connectors/jira-helpers.ts +313 -0
- package/vendor/cli/dist/connectors/jira.ts +35 -227
- package/vendor/cli/dist/connectors/linear.ts +7 -4
- package/vendor/cli/dist/connectors/linkedin-browser-script.ts +13 -0
- package/vendor/cli/dist/connectors/linkedin-draft-page.js +104 -0
- package/vendor/cli/dist/connectors/linkedin-drafts.ts +73 -0
- package/vendor/cli/dist/connectors/linkedin-identity.ts +32 -0
- package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +1185 -0
- package/vendor/cli/dist/connectors/linkedin-inbox.ts +156 -0
- package/vendor/cli/dist/connectors/linkedin-like.ts +114 -0
- package/vendor/cli/dist/connectors/linkedin-takeout.ts +577 -0
- package/vendor/cli/dist/connectors/linkedin.ts +3998 -0
- package/vendor/cli/dist/connectors/postgres.ts +27 -2
- package/vendor/cli/dist/connectors/takeout-utils.ts +240 -0
- package/vendor/cli/dist/connectors/tiktok-inbox-page.js +230 -0
- package/vendor/cli/dist/connectors/tiktok-web-page.js +217 -0
- package/vendor/cli/dist/connectors/tiktok_web.ts +319 -0
- package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +285 -567
- package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +74 -455
- package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +135 -0
- package/vendor/cli/dist/connectors/whatsapp_web.ts +159 -618
- package/vendor/cli/dist/connectors/x-dm-adapter.js +556 -0
- package/vendor/cli/dist/connectors/x-identity.ts +31 -2
- package/vendor/cli/dist/connectors/x.ts +539 -253
- package/vendor/cli/dist/index.js +1 -37
- package/vendor/cli/dist/internal/context.d.ts +10 -0
- package/vendor/cli/dist/internal/context.js +26 -16
- package/vendor/cli/dist/internal/node-version.d.ts +1 -1
- package/vendor/cli/dist/internal/node-version.js +1 -1
- package/vendor/cli/dist/internal/oauth.d.ts +3 -1
- package/vendor/cli/dist/internal/oauth.js +4 -3
- package/vendor/cli/dist/internal/runtime-components.d.ts +9 -0
- package/vendor/cli/dist/internal/runtime-components.js +67 -2
- package/vendor/cli/dist/mac-auth.js +17 -1
- package/vendor/cli/dist/providers.json +1 -1
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +12 -5
- package/vendor/cli/dist/templates/README.md.tmpl +1 -1
- package/vendor/cli/dist/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
- package/vendor/cli/dist/vendor/ora/index.d.ts +332 -0
- package/vendor/cli/dist/vendor/ora/index.js +424 -0
- package/vendor/cli/dist/vendor/ora/license +9 -0
- package/vendor/cli/dist/vendor/ora/package.json +64 -0
- package/vendor/cli/dist/vendor/ora/readme.md +329 -0
- package/vendor/cli/package.json +2 -2
- package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
- package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
- package/vendor/connector-sdk/dist/browser-requirement.d.ts +36 -0
- package/vendor/connector-sdk/dist/browser-requirement.js +60 -0
- package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
- package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
- package/vendor/connector-sdk/dist/connector-runtime.d.ts +3 -1
- package/vendor/connector-sdk/dist/connector-runtime.js +10 -0
- package/vendor/connector-sdk/dist/connector-types.d.ts +169 -45
- package/vendor/connector-sdk/dist/define-connector.d.ts +4 -2
- package/vendor/connector-sdk/dist/define-connector.js +3 -0
- package/vendor/connector-sdk/dist/index.d.ts +8 -2
- package/vendor/connector-sdk/dist/index.js +3 -0
- package/vendor/connector-sdk/dist/reaction-client-types.d.ts +16 -21
- package/vendor/connector-sdk/dist/reaction-client-types.typecheck.d.ts +5 -0
- package/vendor/connector-sdk/package.json +13 -1
- package/vendor/connector-worker/dist/agent-turn/guest-entry.js +43 -30
- package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +416 -330
- package/vendor/connector-worker/dist/agent-turn/memory.d.ts +3 -2
- package/vendor/connector-worker/dist/agent-turn/memory.js +3 -20
- package/vendor/connector-worker/dist/agent-turn/types.d.ts +3 -15
- package/vendor/connector-worker/dist/agent-turn/workspace.d.ts +2 -2
- package/vendor/connector-worker/dist/agent-turn/workspace.js +2 -4
- package/vendor/connector-worker/dist/daemon/action-monitor.d.ts +12 -0
- package/vendor/connector-worker/dist/daemon/action-monitor.js +25 -0
- package/vendor/connector-worker/dist/daemon/agent-turn.js +0 -9
- package/vendor/connector-worker/dist/daemon/automation.d.ts +4 -11
- package/vendor/connector-worker/dist/daemon/automation.js +6 -6
- package/vendor/connector-worker/dist/daemon/builtins/index.d.ts +12 -0
- package/vendor/connector-worker/dist/daemon/builtins/index.js +61 -1
- package/vendor/connector-worker/dist/daemon/builtins/os-shell.d.ts +2 -1
- package/vendor/connector-worker/dist/daemon/builtins/os-shell.js +40 -27
- package/vendor/connector-worker/dist/daemon/client.d.ts +6 -4
- package/vendor/connector-worker/dist/daemon/client.js +3 -3
- package/vendor/connector-worker/dist/daemon/device-concurrency.d.ts +8 -0
- package/vendor/connector-worker/dist/daemon/device-concurrency.js +13 -0
- package/vendor/connector-worker/dist/daemon/executor.d.ts +1 -1
- package/vendor/connector-worker/dist/daemon/executor.js +48 -120
- package/vendor/connector-worker/dist/daemon/log.d.ts +2 -0
- package/vendor/connector-worker/dist/daemon/log.js +23 -2
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.d.ts +23 -6
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +57 -23
- package/vendor/connector-worker/dist/daemon/native-bridge/client.d.ts +6 -0
- package/vendor/connector-worker/dist/daemon/native-bridge/client.js +15 -0
- package/vendor/connector-worker/dist/daemon/native-bridge/executor.js +29 -25
- package/vendor/connector-worker/dist/daemon/native-bridge/protocol.d.ts +1 -1
- package/vendor/connector-worker/dist/daemon/native-bridge/protocol.js +1 -0
- package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +3 -0
- package/vendor/connector-worker/dist/daemon/poll-loop.js +5 -1
- package/vendor/connector-worker/dist/daemon/start.d.ts +1 -0
- package/vendor/connector-worker/dist/daemon/start.js +15 -20
- package/vendor/connector-worker/dist/daemon/terminal-failure.js +0 -11
- package/vendor/connector-worker/dist/daemon/worker-id.d.ts +17 -0
- package/vendor/connector-worker/dist/daemon/worker-id.js +22 -0
- package/vendor/connector-worker/dist/executor/interface.d.ts +34 -2
- package/vendor/connector-worker/dist/executor/isolate.js +66 -15
- package/vendor/connector-worker/dist/executor/redact.d.ts +1 -0
- package/vendor/connector-worker/dist/executor/redact.js +97 -26
- package/vendor/connector-worker/dist/executor/runtime.d.ts +7 -0
- package/vendor/connector-worker/dist/executor/runtime.js +26 -0
- package/vendor/connector-worker/dist/isolate/bridge.js +3 -1
- package/vendor/connector-worker/dist/mac-device-daemon.js +24 -29
- package/vendor/connector-worker/package.json +2 -2
- package/vendor/core/dist/agent-policy.js +1 -1
- package/vendor/core/dist/agent-store.d.ts +2 -0
- package/vendor/core/dist/agent-tooling.d.ts +1 -1
- package/vendor/core/dist/agent-tooling.js +1 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +2 -1
- package/vendor/core/dist/connector-query-errors.d.ts +32 -0
- package/vendor/core/dist/connector-query-errors.js +41 -1
- package/vendor/core/dist/contracts/agent-settings.d.ts +0 -11
- package/vendor/core/dist/contracts/agent-settings.js +1 -7
- package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +93 -0
- package/vendor/core/dist/contracts/tools/collection-presentation.js +88 -0
- package/vendor/core/dist/contracts/tools/collection-selection.d.ts +47 -0
- package/vendor/core/dist/contracts/tools/collection-selection.js +74 -0
- package/vendor/core/dist/contracts/tools/manage-agents.d.ts +10 -4
- package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +1 -1
- package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +5 -1
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +19 -4
- package/vendor/core/dist/contracts/tools/manage-automations.js +25 -8
- package/vendor/core/dist/contracts/tools/manage-connections.d.ts +1 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +3 -0
- package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +11 -0
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +42 -3
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +181 -152
- package/vendor/core/dist/contracts/tools/manage-entity.js +118 -162
- package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +41 -3
- package/vendor/core/dist/contracts/tools/manage-operations.js +40 -2
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +182 -7
- package/vendor/core/dist/contracts/tools/manage-views.js +49 -13
- package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +11 -2
- package/vendor/core/dist/contracts/tools/read-knowledge.js +23 -3
- package/vendor/core/dist/contracts/tools/save-memory.d.ts +3 -6
- package/vendor/core/dist/contracts/tools/save-memory.js +2 -6
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +2 -1
- package/vendor/core/dist/contracts/tools/view-attach.js +7 -2
- package/vendor/core/dist/contracts/worker/protocol.d.ts +130 -159
- package/vendor/core/dist/contracts/worker/protocol.js +88 -76
- package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
- package/vendor/core/dist/device-pin-tombstones.js +57 -0
- package/vendor/core/dist/index.d.ts +5 -5
- package/vendor/core/dist/index.js +4 -6
- package/vendor/core/dist/json-template.d.ts +6 -10
- package/vendor/core/dist/json-template.js +5 -9
- package/vendor/core/dist/logger.js +17 -26
- package/vendor/core/dist/shell-safety.d.ts +9 -0
- package/vendor/core/dist/shell-safety.js +154 -0
- package/vendor/core/dist/suggestions.d.ts +1 -1
- package/vendor/core/dist/suggestions.js +1 -1
- package/vendor/core/dist/tool-trace-summary.d.ts +1 -1
- package/vendor/core/dist/tool-trace-summary.js +1 -1
- package/vendor/core/dist/types.d.ts +1 -3
- package/vendor/core/dist/utils/diagnostic-scrubber.d.ts +7 -0
- package/vendor/core/dist/utils/diagnostic-scrubber.js +437 -0
- package/vendor/core/dist/worker/auth.d.ts +44 -6
- package/vendor/core/dist/worker/auth.js +44 -11
- package/vendor/core/dist/worker/wire.d.ts +0 -10
- package/vendor/core/package.json +20 -11
- package/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
- package/vendor/ora/index.d.ts +332 -0
- package/vendor/ora/index.js +424 -0
- package/vendor/ora/license +9 -0
- package/vendor/ora/package.json +53 -0
- package/vendor/ora/readme.md +329 -0
- package/vendor/cli/dist/commands/telemetry.d.ts +0 -10
- package/vendor/cli/dist/commands/telemetry.js +0 -66
- package/vendor/connector-worker/dist/daemon/device-chat.d.ts +0 -9
- package/vendor/connector-worker/dist/daemon/device-chat.js +0 -61
- package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
- package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
- package/vendor/core/dist/sentry.d.ts +0 -26
- package/vendor/core/dist/sentry.js +0 -133
- package/vendor/core/dist/tool-policy.d.ts +0 -74
- package/vendor/core/dist/tool-policy.js +0 -305
- package/vendor/core/dist/utils/sentry-scrubber.d.ts +0 -29
- package/vendor/core/dist/utils/sentry-scrubber.js +0 -228
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Linear Connector (V1 runtime)
|
|
3
3
|
*
|
|
4
4
|
* Reads Linear issues via GraphQL and can sync them into events.
|
|
5
|
-
* Real-time Issue/Comment deliveries
|
|
6
|
-
*
|
|
5
|
+
* Real-time Issue/Comment deliveries mark the issues feed due, so the poll
|
|
6
|
+
* fetches the changed issues.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { randomBytes } from 'node:crypto';
|
|
@@ -152,7 +152,7 @@ export default class LinearConnector extends ConnectorRuntime<LinearCheckpoint,
|
|
|
152
152
|
name: 'Linear',
|
|
153
153
|
description:
|
|
154
154
|
'Syncs and live-reads Linear issues via GraphQL, and receives real-time issue/comment webhooks.',
|
|
155
|
-
version: '1.
|
|
155
|
+
version: '1.2.0',
|
|
156
156
|
faviconDomain: 'linear.app',
|
|
157
157
|
webhook: {
|
|
158
158
|
signatureHeader: 'linear-signature',
|
|
@@ -160,6 +160,7 @@ export default class LinearConnector extends ConnectorRuntime<LinearCheckpoint,
|
|
|
160
160
|
// Linear signs the raw body with HMAC-SHA256 and sends a bare hex digest
|
|
161
161
|
// (no `sha256=` prefix). It does not send a stable delivery id header, so
|
|
162
162
|
// dedupe falls back to a body hash (no `dedupeHeader`).
|
|
163
|
+
eventType: { path: 'type' },
|
|
163
164
|
// App-installation delivery: one webhook configured ONCE on the Linear app;
|
|
164
165
|
// every delivery carries the workspace `organizationId` — that's the tenant.
|
|
165
166
|
delivery: 'app_installation',
|
|
@@ -193,6 +194,8 @@ export default class LinearConnector extends ConnectorRuntime<LinearCheckpoint,
|
|
|
193
194
|
sync: (ctx) => this.syncFeed(ctx),
|
|
194
195
|
read: (ctx) => this.readFeed(ctx),
|
|
195
196
|
readWindowAxis: 'updated_at',
|
|
197
|
+
// A comment also moves its issue's updatedAt, so both wake the poll.
|
|
198
|
+
webhook: { events: ['Issue', 'Comment'] },
|
|
196
199
|
configSchema: {
|
|
197
200
|
type: 'object',
|
|
198
201
|
properties: {
|
|
@@ -397,7 +400,7 @@ export default class LinearConnector extends ConnectorRuntime<LinearCheckpoint,
|
|
|
397
400
|
}
|
|
398
401
|
|
|
399
402
|
// -------------------------------------------------------------------------
|
|
400
|
-
// Webhooks (subscription lifecycle
|
|
403
|
+
// Webhooks (subscription lifecycle; the platform dispatches deliveries)
|
|
401
404
|
// -------------------------------------------------------------------------
|
|
402
405
|
|
|
403
406
|
async registerWebhook(
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const LINKEDIN_HOME_URL = "https://www.linkedin.com/feed/foryou/";
|
|
2
|
+
|
|
3
|
+
/** Keep data inert in generated browser code, including an HTML script context. */
|
|
4
|
+
export function linkedInScriptArgument(value: unknown): string {
|
|
5
|
+
const json = JSON.stringify(value);
|
|
6
|
+
if (json === undefined) throw new Error("LinkedIn browser input is required");
|
|
7
|
+
const literal = JSON.stringify(json).replace(
|
|
8
|
+
/[<>\u2028\u2029]/g,
|
|
9
|
+
(char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`
|
|
10
|
+
);
|
|
11
|
+
// Parsing also preserves JSON object keys such as __proto__ as plain data.
|
|
12
|
+
return `JSON.parse(${literal})`;
|
|
13
|
+
}
|
|
@@ -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
|
+
};
|