@lobu/runtime-device 23.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.
- package/dist/component.json +1 -1
- package/dist/dependencies.bun.lock +30 -27
- package/npm-shrinkwrap.json +131 -115
- package/package.json +2 -1
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +73 -0
- package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +9 -11
- package/vendor/cli/dist/commands/_lib/apply/client.d.ts +3 -11
- package/vendor/cli/dist/commands/_lib/apply/client.js +3 -3
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +0 -6
- package/vendor/cli/dist/commands/_lib/apply/desired-state.js +6 -15
- package/vendor/cli/dist/commands/_lib/apply/diff.js +1 -0
- package/vendor/cli/dist/commands/_lib/apply/map-config.js +8 -0
- package/vendor/cli/dist/commands/_lib/view-bundler.d.ts +2 -9
- package/vendor/cli/dist/commands/_lib/view-bundler.js +25 -97
- package/vendor/cli/dist/config/define.d.ts +8 -0
- package/vendor/cli/dist/connectors/README.md +1 -1
- package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +4 -7
- package/vendor/cli/dist/connectors/linkedin.ts +53 -34
- package/vendor/cli/dist/connectors/reddit.ts +92 -20
- package/vendor/cli/dist/connectors/slack.ts +1 -0
- package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +41 -11
- package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +1 -1
- package/vendor/cli/dist/connectors/whatsapp_web.ts +2 -2
- package/vendor/cli/dist/connectors/x-identity.ts +5 -3
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +10 -3
- package/vendor/cli/package.json +1 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/connector-worker/dist/agent-turn/gateway-tools.d.ts +2 -2
- package/vendor/connector-worker/dist/agent-turn/gateway-tools.js +2 -2
- package/vendor/connector-worker/dist/agent-turn/guest-entry.js +34 -2
- package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +362 -300
- package/vendor/connector-worker/dist/agent-turn/native-session.d.ts +12 -0
- package/vendor/connector-worker/dist/agent-turn/native-session.js +32 -6
- package/vendor/connector-worker/dist/agent-turn/types.d.ts +24 -3
- package/vendor/connector-worker/dist/daemon/agent-turn.js +5 -1
- package/vendor/connector-worker/dist/daemon/automation.js +20 -15
- package/vendor/connector-worker/dist/isolate/prelude.js +93 -44
- package/vendor/connector-worker/package.json +1 -1
- package/vendor/core/dist/agent-policy.js +0 -3
- package/vendor/core/dist/agent-tooling.d.ts +1 -1
- package/vendor/core/dist/agent-tooling.js +3 -1
- package/vendor/core/dist/contracts/agent-settings.d.ts +6 -2
- package/vendor/core/dist/contracts/agent-settings.js +12 -1
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +53 -234
- package/vendor/core/dist/contracts/tools/manage-views.js +50 -76
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +5 -8
- package/vendor/core/dist/contracts/tools/view-attach.js +14 -31
- package/vendor/core/dist/contracts/tools/view-definition.d.ts +21 -0
- package/vendor/core/dist/contracts/tools/view-definition.js +165 -0
- package/vendor/core/dist/contracts/worker/protocol.d.ts +39 -2
- package/vendor/core/dist/contracts/worker/protocol.js +24 -1
- package/vendor/core/dist/index.d.ts +1 -1
- package/vendor/core/dist/index.js +2 -1
- package/vendor/core/dist/suggestions.d.ts +15 -2
- package/vendor/core/dist/suggestions.js +48 -3
- package/vendor/core/dist/types.d.ts +26 -0
- package/vendor/core/dist/types.js +5 -0
- package/vendor/core/package.json +11 -5
- package/vendor/postgres/cf/src/connection.js +18 -0
- package/vendor/postgres/cjs/src/connection.js +18 -0
- package/vendor/postgres/src/connection.js +18 -0
- /package/vendor/postgres/{.bun-tag-f39dafdb2305d504 → .bun-tag-2f292c6554a8475e} +0 -0
|
@@ -556,25 +556,20 @@ export async function executePlan(ctx, pendingAuth) {
|
|
|
556
556
|
printText(chalk.yellow(`Warning: ${warning}`));
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
|
-
// 2b) Views — shipped from the load-time bundle (source + browser bundle
|
|
560
|
-
//
|
|
561
|
-
//
|
|
562
|
-
// hash the server will compute.
|
|
559
|
+
// 2b) Views — shipped from the load-time bundle (source + browser bundle,
|
|
560
|
+
// hashed with the server's function; the server reads the declaration
|
|
561
|
+
// from the source). No re-bundling here: the diff already compared the
|
|
562
|
+
// exact hash the server will compute.
|
|
563
563
|
for (const row of rowsByKind("view")) {
|
|
564
564
|
if (row.kind !== "view")
|
|
565
565
|
continue;
|
|
566
566
|
if (!row.desired)
|
|
567
567
|
continue;
|
|
568
568
|
const result = await ctx.client.setView({
|
|
569
|
-
key: row.id,
|
|
570
|
-
name: row.desired.key,
|
|
571
569
|
source_code: row.desired.sourceCode,
|
|
572
570
|
compiled_code: row.desired.compiledCode,
|
|
573
571
|
source_files: row.desired.sourceFiles,
|
|
574
572
|
dependencies: row.desired.dependencies,
|
|
575
|
-
attach: row.desired.attach,
|
|
576
|
-
params: row.desired.params,
|
|
577
|
-
actions: row.desired.actions,
|
|
578
573
|
});
|
|
579
574
|
const kb = (Buffer.byteLength(row.desired.compiledCode, "utf8") / 1024).toFixed(0);
|
|
580
575
|
printText(renderProgress(row.verb, "view", row.id, `${result.written ? "(pushed" : "(unchanged"}, ${kb} KB)`));
|
|
@@ -1285,8 +1280,11 @@ async function applyProject(opts, prepared) {
|
|
|
1285
1280
|
// Provider API keys live outside the resource diff (the secret value isn't
|
|
1286
1281
|
// serialized into any plan row), so a key-only `.env` change produces an
|
|
1287
1282
|
// all-noop plan. Detect declared keys so the apply isn't short-circuited and
|
|
1288
|
-
// the keys aren't silently dropped.
|
|
1289
|
-
|
|
1283
|
+
// the keys aren't silently dropped. Keys are declared on agents, so they
|
|
1284
|
+
// belong to the agents family: `--only memory` must never push one (a push
|
|
1285
|
+
// can create the org provider row).
|
|
1286
|
+
const hasProviderKeys = opts.only !== "memory" &&
|
|
1287
|
+
state.agents.some((a) => a.providerKeys.length > 0);
|
|
1290
1288
|
if (plan.counts.create === 0 &&
|
|
1291
1289
|
plan.counts.update === 0 &&
|
|
1292
1290
|
plan.counts.delete === 0 &&
|
|
@@ -125,18 +125,10 @@ export interface RemoteView {
|
|
|
125
125
|
updated_at: string;
|
|
126
126
|
}
|
|
127
127
|
export interface SetViewPayload {
|
|
128
|
-
key: string;
|
|
129
|
-
name?: string;
|
|
130
|
-
description?: string;
|
|
131
128
|
source_code: string;
|
|
132
129
|
compiled_code?: string;
|
|
133
130
|
source_files?: SourceFiles;
|
|
134
131
|
dependencies?: SourceDependencies;
|
|
135
|
-
attach: Array<Record<string, unknown>>;
|
|
136
|
-
params: Record<string, unknown>;
|
|
137
|
-
actions: Record<string, {
|
|
138
|
-
emits: string;
|
|
139
|
-
}>;
|
|
140
132
|
}
|
|
141
133
|
export interface RemoteAutomation {
|
|
142
134
|
slug: string;
|
|
@@ -372,9 +364,9 @@ export declare class ApplyClient {
|
|
|
372
364
|
/** Applied views (metadata only — the list never returns bundles). */
|
|
373
365
|
listViews(): Promise<RemoteView[]>;
|
|
374
366
|
/**
|
|
375
|
-
* Store a view: source + CLI-bundled browser bundle
|
|
376
|
-
* from the
|
|
377
|
-
* executable artifact is a server-side no-op).
|
|
367
|
+
* Store a view: source + CLI-bundled browser bundle. The server reads the
|
|
368
|
+
* view's key, attach, params and actions from the source. Returns whether a
|
|
369
|
+
* write happened (same executable artifact is a server-side no-op).
|
|
378
370
|
*/
|
|
379
371
|
setView(payload: SetViewPayload): Promise<{
|
|
380
372
|
written: boolean;
|
|
@@ -293,9 +293,9 @@ export class ApplyClient {
|
|
|
293
293
|
return body.views ?? [];
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
|
-
* Store a view: source + CLI-bundled browser bundle
|
|
297
|
-
* from the
|
|
298
|
-
* executable artifact is a server-side no-op).
|
|
296
|
+
* Store a view: source + CLI-bundled browser bundle. The server reads the
|
|
297
|
+
* view's key, attach, params and actions from the source. Returns whether a
|
|
298
|
+
* write happened (same executable artifact is a server-side no-op).
|
|
299
299
|
*/
|
|
300
300
|
async setView(payload) {
|
|
301
301
|
const { body } = await this.request("POST", `/api/${this.orgSlug}/manage_views`, {
|
|
@@ -248,12 +248,6 @@ export interface DesiredView extends RetainedSource {
|
|
|
248
248
|
sourceFile: string;
|
|
249
249
|
/** Browser IIFE bundle (react, bridge, relative files, view npm deps). */
|
|
250
250
|
compiledCode: string;
|
|
251
|
-
/** Metadata extracted from the module itself. */
|
|
252
|
-
attach: Array<Record<string, unknown>>;
|
|
253
|
-
params: Record<string, unknown>;
|
|
254
|
-
actions: Record<string, {
|
|
255
|
-
emits: string;
|
|
256
|
-
}>;
|
|
257
251
|
}
|
|
258
252
|
export interface DesiredAgent {
|
|
259
253
|
metadata: DesiredAgentMetadata;
|
|
@@ -496,22 +496,16 @@ async function resolveViewSources(sources, cwd) {
|
|
|
496
496
|
}
|
|
497
497
|
const bundled = await bundleViewFromFile(abs, baseDir);
|
|
498
498
|
sourceCode = bundled.sourceFiles.files[bundled.sourceFiles.entrypoint];
|
|
499
|
-
const key = bundled.
|
|
499
|
+
const { key, name, description, attach, params, actions } = bundled.definition;
|
|
500
500
|
if (seen.has(key)) {
|
|
501
501
|
throw new ValidationError(`duplicate view key "${key}" in lobu.config.ts — each viewFromFile must resolve to a unique key`);
|
|
502
502
|
}
|
|
503
503
|
seen.add(key);
|
|
504
|
-
// Hash EXACTLY what the server will store:
|
|
505
|
-
//
|
|
506
|
-
//
|
|
507
|
-
//
|
|
508
|
-
//
|
|
509
|
-
// Same function, same inputs: same hash.
|
|
510
|
-
const name = key;
|
|
511
|
-
const description = "";
|
|
512
|
-
const attach = JSON.parse(JSON.stringify(bundled.metadata.attach));
|
|
513
|
-
const params = JSON.parse(JSON.stringify(bundled.metadata.params));
|
|
514
|
-
const actions = JSON.parse(JSON.stringify(bundled.metadata.actions));
|
|
504
|
+
// Hash EXACTLY what the server will store: the declaration comes from
|
|
505
|
+
// the same reader the server runs on save (defaults applied there), plus
|
|
506
|
+
// the digest of the bundle produced above (which carries the relative
|
|
507
|
+
// imports the entry source alone omits). Same function, same inputs:
|
|
508
|
+
// same hash.
|
|
515
509
|
views.push({
|
|
516
510
|
key,
|
|
517
511
|
sourcePath: abs,
|
|
@@ -530,9 +524,6 @@ async function resolveViewSources(sources, cwd) {
|
|
|
530
524
|
compiledCode: bundled.compiledCode,
|
|
531
525
|
sourceFiles: bundled.sourceFiles,
|
|
532
526
|
dependencies: bundled.dependencies,
|
|
533
|
-
attach,
|
|
534
|
-
params,
|
|
535
|
-
actions,
|
|
536
527
|
});
|
|
537
528
|
}
|
|
538
529
|
return views.sort((a, b) => a.sourceFile.localeCompare(b.sourceFile));
|
|
@@ -32,6 +32,7 @@ const AGENT_SETTINGS_FIELD_POLICY = {
|
|
|
32
32
|
sandboxId: "unsupported",
|
|
33
33
|
verboseLogging: "unsupported",
|
|
34
34
|
showToolCalls: "unsupported",
|
|
35
|
+
starters: "mapped",
|
|
35
36
|
};
|
|
36
37
|
void AGENT_SETTINGS_FIELD_POLICY;
|
|
37
38
|
import { CronExpressionParser } from "cron-parser";
|
|
@@ -231,6 +232,12 @@ function mapAgent(agent, env, required) {
|
|
|
231
232
|
if (agent.nixPackages?.length) {
|
|
232
233
|
settings.nixConfig = { packages: [...new Set(agent.nixPackages)] };
|
|
233
234
|
}
|
|
235
|
+
if (agent.starters !== undefined) {
|
|
236
|
+
settings.starters = agent.starters.map(({ title, message }) => ({
|
|
237
|
+
title,
|
|
238
|
+
message,
|
|
239
|
+
}));
|
|
240
|
+
}
|
|
234
241
|
const providerKeys = [];
|
|
235
242
|
for (const provider of agent.providers ?? []) {
|
|
236
243
|
if (provider.key === undefined)
|
|
@@ -282,6 +289,7 @@ function mapAgent(agent, env, required) {
|
|
|
282
289
|
sandboxId: settings.sandboxId,
|
|
283
290
|
verboseLogging: settings.verboseLogging,
|
|
284
291
|
showToolCalls: settings.showToolCalls,
|
|
292
|
+
starters: settings.starters,
|
|
285
293
|
};
|
|
286
294
|
void _exhaustive;
|
|
287
295
|
return { metadata, settings, providerKeys };
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import type { RetainedSource } from "@lobu/core/contracts/tools/source-files";
|
|
2
|
-
|
|
3
|
-
key: string;
|
|
4
|
-
attach: Array<Record<string, unknown>>;
|
|
5
|
-
params: Record<string, unknown>;
|
|
6
|
-
actions: Record<string, {
|
|
7
|
-
emits: string;
|
|
8
|
-
}>;
|
|
9
|
-
}
|
|
2
|
+
import { type ViewDefinitionRecord } from "@lobu/core/contracts/tools/view-definition";
|
|
10
3
|
export interface BundledView extends RetainedSource {
|
|
11
4
|
compiledCode: string;
|
|
12
|
-
|
|
5
|
+
definition: ViewDefinitionRecord;
|
|
13
6
|
}
|
|
14
7
|
/**
|
|
15
8
|
* Bundle the view at `entry` (absolute path) for the browser. Throws when the
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The module shape is exactly one: `export const view = defineView({ key,
|
|
5
5
|
* attach, … })` plus a default-export component (hooks inside, no document
|
|
6
|
-
* access).
|
|
6
|
+
* access). One esbuild pass, plus a read of the declaration:
|
|
7
7
|
* 1. browser IIFE bundle of a SYNTHETIC entry that mounts the two exports
|
|
8
8
|
* (`mountView(view, Default)`) — what the server stores as
|
|
9
9
|
* `compiled_code` and inlines into the view shell. Bundled here, where
|
|
@@ -11,65 +11,18 @@
|
|
|
11
11
|
* use), because the server has no file context for relative imports or
|
|
12
12
|
* view npm deps. The server compiles plain sources itself through the
|
|
13
13
|
* same mount on its own bootstrap.
|
|
14
|
-
* 2.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* 2. the entry's `defineView({...})` literal, read without running the module
|
|
15
|
+
* by the same `readViewDefinition` the server uses on save, so the CLI's
|
|
16
|
+
* plan hashes exactly what the server stores. The declaration lives in the
|
|
17
|
+
* file, never in the config.
|
|
18
18
|
*
|
|
19
|
-
* Anything else (no `view` export, no default component,
|
|
20
|
-
* here rather than rendering a blank frame in prod.
|
|
19
|
+
* Anything else (no `view` export, no default component, a non-literal
|
|
20
|
+
* declaration) fails loud here rather than rendering a blank frame in prod.
|
|
21
21
|
*/
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { pathToFileURL } from "node:url";
|
|
26
|
-
import { build } from "esbuild";
|
|
22
|
+
import { basename, dirname, resolve } from "node:path";
|
|
23
|
+
import { readViewDefinition, } from "@lobu/core/contracts/tools/view-definition";
|
|
24
|
+
import { build, transform } from "esbuild";
|
|
27
25
|
import { createSourceCapture } from "../../internal/connector-compiler.js";
|
|
28
|
-
const VIEW_KEY_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
29
|
-
const RUNTIME_MODULE_RE = /(^|\/)lobu-views(\.tsx?)?$|^@lobu\/views$/;
|
|
30
|
-
const metadataStub = {
|
|
31
|
-
name: "lobu-views-metadata-stub",
|
|
32
|
-
setup(b) {
|
|
33
|
-
b.onResolve({ filter: RUNTIME_MODULE_RE }, () => ({
|
|
34
|
-
path: "lobu-views-stub",
|
|
35
|
-
namespace: "lobu-views-stub",
|
|
36
|
-
}));
|
|
37
|
-
b.onLoad({ filter: /.*/, namespace: "lobu-views-stub" }, () => ({
|
|
38
|
-
loader: "js",
|
|
39
|
-
contents: `
|
|
40
|
-
export function defineView(def) {
|
|
41
|
-
if (!def || typeof def.key !== "string" || !def.key) {
|
|
42
|
-
throw new Error("defineView({ key, attach, ... }) requires a non-empty key");
|
|
43
|
-
}
|
|
44
|
-
return def;
|
|
45
|
-
}
|
|
46
|
-
export function mountView() { throw new Error("mountView is not called by view modules: export const view = defineView({ ... }) plus a default-export component"); }
|
|
47
|
-
const noHook = () => { throw new Error("hooks are not available at metadata-extraction time"); };
|
|
48
|
-
export const useParams = noHook, useScope = noHook, useHost = noHook,
|
|
49
|
-
useQuery = noHook, useAction = noHook;
|
|
50
|
-
export function Provider() { throw new Error("not available at metadata-extraction time"); }
|
|
51
|
-
export function sql(strings, ...values) { return { kind: "sql", text: String(strings[0] ?? "") }; }
|
|
52
|
-
export function tool(name, args = {}) { return { kind: "tool", name, args }; }
|
|
53
|
-
export function escapeLiteral(value) { return String(value); }
|
|
54
|
-
export const defaultsFor = () => ({}), coerceParams = (_def, raw) => raw ?? {};
|
|
55
|
-
`,
|
|
56
|
-
}));
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
function readViewExport(ns, entry) {
|
|
60
|
-
const view = ns?.view;
|
|
61
|
-
if (!view || typeof view !== "object") {
|
|
62
|
-
throw new Error(`${entry}: the module must export const view = defineView({ key, attach, ... })`);
|
|
63
|
-
}
|
|
64
|
-
const { key } = view;
|
|
65
|
-
if (typeof key !== "string" || !key) {
|
|
66
|
-
throw new Error(`${entry}: defineView({ key, attach, ... }) requires a non-empty key`);
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
view: { ...view, key },
|
|
70
|
-
hasDefault: typeof ns?.default === "function",
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
26
|
/**
|
|
74
27
|
* Bundle the view at `entry` (absolute path) for the browser. Throws when the
|
|
75
28
|
* module has no `view` export, no default-export component, or an invalid
|
|
@@ -103,49 +56,24 @@ export async function bundleViewFromFile(entry, projectRoot) {
|
|
|
103
56
|
throw new Error(`${entry}: view bundle compiled to empty output`);
|
|
104
57
|
}
|
|
105
58
|
assertBundlePortable(compiledCode, entry);
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
target: ["node22"],
|
|
113
|
-
jsx: "automatic",
|
|
114
|
-
plugins: [capture.plugin, metadataStub],
|
|
115
|
-
define: { "process.env.NODE_ENV": '"production"' },
|
|
116
|
-
logLevel: "silent",
|
|
117
|
-
});
|
|
118
|
-
const tmp = await mkdtemp(join(tmpdir(), "lobu-view-meta-"));
|
|
59
|
+
const source = capture.source();
|
|
60
|
+
const entrySource = source.sourceFiles.files[source.sourceFiles.entrypoint];
|
|
61
|
+
if (entrySource === undefined) {
|
|
62
|
+
throw new Error(`${entry}: the view entry was not captured`);
|
|
63
|
+
}
|
|
64
|
+
let definition;
|
|
119
65
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
throw new Error(`${entry}: the module must have a default-export component`);
|
|
127
|
-
}
|
|
128
|
-
if (!VIEW_KEY_RE.test(def.key)) {
|
|
129
|
-
throw new Error(`${entry}: defineView key ${JSON.stringify(def.key)} must match /^[a-z0-9][a-z0-9-]{0,63}$/`);
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
compiledCode,
|
|
133
|
-
...capture.source(),
|
|
134
|
-
metadata: {
|
|
135
|
-
key: def.key,
|
|
136
|
-
attach: Array.isArray(def.attach) ? def.attach : [],
|
|
137
|
-
params: def.params && typeof def.params === "object"
|
|
138
|
-
? def.params
|
|
139
|
-
: {},
|
|
140
|
-
actions: def.actions && typeof def.actions === "object"
|
|
141
|
-
? def.actions
|
|
142
|
-
: {},
|
|
143
|
-
},
|
|
144
|
-
};
|
|
66
|
+
const { code } = await transform(entrySource, {
|
|
67
|
+
loader: "tsx",
|
|
68
|
+
jsx: "automatic",
|
|
69
|
+
logLevel: "silent",
|
|
70
|
+
});
|
|
71
|
+
definition = readViewDefinition(code);
|
|
145
72
|
}
|
|
146
|
-
|
|
147
|
-
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw new Error(`${entry}: ${error.message}`);
|
|
148
75
|
}
|
|
76
|
+
return { compiledCode, ...source, definition };
|
|
149
77
|
}
|
|
150
78
|
/**
|
|
151
79
|
* The `lobu run` watch set for one view: the entry plus every file esbuild
|
|
@@ -737,6 +737,14 @@ export interface Agent {
|
|
|
737
737
|
guardrails?: string[];
|
|
738
738
|
/** Nix packages provisioned into the worker environment. */
|
|
739
739
|
nixPackages?: string[];
|
|
740
|
+
/**
|
|
741
|
+
* Up to three conversation starters, shown on an empty web chat and as
|
|
742
|
+
* Slack assistant thread-start prompts. `message` is sent as the user.
|
|
743
|
+
*/
|
|
744
|
+
starters?: Array<{
|
|
745
|
+
title: string;
|
|
746
|
+
message: string;
|
|
747
|
+
}>;
|
|
740
748
|
}
|
|
741
749
|
export declare function defineAgent(config: Omit<Agent, "kind">): Agent;
|
|
742
750
|
/**
|
|
@@ -559,7 +559,7 @@ For source-backed bundled connectors, the worker recompiles a `.ts` file after i
|
|
|
559
559
|
| `linkedin` | browser/none | notifications, inbox messages, home feed, company updates, jobs; Data Export requires an injected CSV reader | send direct-message replies; like; prepare message/post/comment drafts |
|
|
560
560
|
| `market.quotes` | none | - | quote (read-only, quotes returned to the caller, never persisted) |
|
|
561
561
|
| `producthunt` | env_keys | posts & comments | - |
|
|
562
|
-
| `reddit` | oauth/none | posts, comments, user activity | - |
|
|
562
|
+
| `reddit` | oauth/none | posts, comments, user activity, home feed | - |
|
|
563
563
|
| `rss` | none | articles | - |
|
|
564
564
|
| `x` | browser/oauth | tweets, own posts, likes, bookmarks, DMs, home timeline | prepare reply |
|
|
565
565
|
| `youtube` | oauth (Google) | liked videos, playlists, subscriptions, videos | search, get_video, search_liked_videos, list_playlists, get_playlist |
|
|
@@ -96,17 +96,14 @@ export function linkedInInboxProgram() {
|
|
|
96
96
|
}
|
|
97
97
|
// Whether a message was sent from this inbox. A member inbox's own messages
|
|
98
98
|
// carry the member's identity. A page inbox holds conversations between the
|
|
99
|
-
// page and members
|
|
100
|
-
// participant,
|
|
99
|
+
// page and members: a page reply's sender is the page's mailbox or the page
|
|
100
|
+
// as an organization participant, with the admin who sent it only as its
|
|
101
|
+
// actor. The signed-in admin writing as themselves is a member like any other.
|
|
101
102
|
function fromMe(sender, inbox) {
|
|
102
103
|
const host = sender?.hostIdentityUrn;
|
|
103
104
|
if (typeof host !== "string") return null;
|
|
104
105
|
if (!inbox.page) return host === inbox.mailbox;
|
|
105
|
-
return
|
|
106
|
-
host === inbox.mailbox ||
|
|
107
|
-
host === inbox.member ||
|
|
108
|
-
!!sender.participantType?.organization
|
|
109
|
-
);
|
|
106
|
+
return host === inbox.mailbox || !!sender.participantType?.organization;
|
|
110
107
|
}
|
|
111
108
|
// A page conversation's visitor-chosen topic, when LinkedIn shows one.
|
|
112
109
|
function topicOf(conversation, inbox) {
|
|
@@ -487,9 +487,10 @@ const HOME_FEED_POST_IDENTITY_SELECTOR =
|
|
|
487
487
|
':is([id*="shareId="], [id*="ugcPostId="], [id*="urn:li:activity:"], [id*="-replaceableCommentTools"]):not([id^="replaceableComment_"]):not([id^="replaceableComment_"] *)';
|
|
488
488
|
|
|
489
489
|
/** Current comment-tool ids encode a typed post URN, followed by the recycled
|
|
490
|
-
* card key. Decode only the typed prefix: field 1 is activity, field 2 ugcPost
|
|
491
|
-
*
|
|
492
|
-
* the
|
|
490
|
+
* card key. Decode only the typed prefix: field 1 is activity, field 2 ugcPost,
|
|
491
|
+
* and field 3 groupPost. Each contains field 1 as a protobuf sint64 (ZigZag);
|
|
492
|
+
* groupPost contains the group id in field 1 and the post id in field 2.
|
|
493
|
+
* Native comment URNs and live post URLs confirm those namespaces. */
|
|
493
494
|
function decodeHomeFeedPostIdentity(
|
|
494
495
|
raw: string | undefined
|
|
495
496
|
): string | undefined {
|
|
@@ -509,25 +510,38 @@ function decodeHomeFeedPostIdentity(
|
|
|
509
510
|
}
|
|
510
511
|
const tag = bytes.charCodeAt(0);
|
|
511
512
|
if (
|
|
512
|
-
(tag !== 10 && tag !== 18) ||
|
|
513
|
+
(tag !== 10 && tag !== 18 && tag !== 26) ||
|
|
513
514
|
bytes.length < 4 ||
|
|
514
|
-
bytes.length > 13 ||
|
|
515
|
+
bytes.length > (tag === 26 ? 24 : 13) ||
|
|
515
516
|
bytes.charCodeAt(1) !== bytes.length - 2 ||
|
|
516
517
|
bytes.charCodeAt(2) !== 8
|
|
517
518
|
) {
|
|
518
519
|
throw invalid();
|
|
519
520
|
}
|
|
520
|
-
let
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
521
|
+
let offset = 3;
|
|
522
|
+
const readId = (minimum: bigint) => {
|
|
523
|
+
let encoded = 0n;
|
|
524
|
+
for (let shift = 0; shift < 70 && offset < bytes.length; shift += 7) {
|
|
525
|
+
const byte = bytes.charCodeAt(offset++);
|
|
526
|
+
encoded |= BigInt(byte & 127) << BigInt(shift);
|
|
527
|
+
if (byte & 128) continue;
|
|
528
|
+
if ((encoded & 1n) !== 0n || encoded >= 1n << 64n || encoded < minimum) {
|
|
529
|
+
throw invalid();
|
|
530
|
+
}
|
|
531
|
+
return encoded >> 1n;
|
|
532
|
+
}
|
|
528
533
|
throw invalid();
|
|
534
|
+
};
|
|
535
|
+
// Group ids can be smaller than post ids, but must still be positive.
|
|
536
|
+
const firstId = readId(tag === 26 ? 2n : 200_000n);
|
|
537
|
+
if (tag === 26) {
|
|
538
|
+
if (bytes.charCodeAt(offset++) !== 16) throw invalid();
|
|
539
|
+
const postId = readId(200_000n);
|
|
540
|
+
if (offset !== bytes.length) throw invalid();
|
|
541
|
+
return `urn:li:groupPost:${firstId}-${postId}`;
|
|
529
542
|
}
|
|
530
|
-
|
|
543
|
+
if (offset !== bytes.length) throw invalid();
|
|
544
|
+
return `urn:li:${tag === 10 ? "activity" : "ugcPost"}:${firstId}`;
|
|
531
545
|
}
|
|
532
546
|
|
|
533
547
|
// A fenced dispatch discards every row it collected, so an oversized scrape
|
|
@@ -1227,7 +1241,7 @@ interface HomeFeedEngagement {
|
|
|
1227
1241
|
|
|
1228
1242
|
interface HomeFeedCommentIdentity {
|
|
1229
1243
|
urn: string;
|
|
1230
|
-
parentNamespace:
|
|
1244
|
+
parentNamespace: ReturnType<typeof linkedInUrnNamespace>;
|
|
1231
1245
|
parentId: string;
|
|
1232
1246
|
commentId: string;
|
|
1233
1247
|
}
|
|
@@ -1246,10 +1260,10 @@ function homeFeedPostIdentityKey(
|
|
|
1246
1260
|
for (const raw of [context.postUrl, row.post_identity]) {
|
|
1247
1261
|
if (!raw) continue;
|
|
1248
1262
|
const match = raw.match(
|
|
1249
|
-
/(?:(shareId|ugcPostId)=|urn:li:(activity|share|ugcPost):)(\d{6,})/i
|
|
1263
|
+
/(?:(shareId|ugcPostId)=|urn:li:(activity|share|ugcPost):)(\d{6,})|urn:li:(groupPost):(\d+-\d{6,})/i
|
|
1250
1264
|
);
|
|
1251
1265
|
if (!match) continue;
|
|
1252
|
-
return `${linkedInUrnNamespace(match[1] ?? match[2] ?? "")}:${match[3]}`;
|
|
1266
|
+
return `${linkedInUrnNamespace(match[1] ?? match[2] ?? match[4] ?? "")}:${match[3] ?? match[5]}`;
|
|
1253
1267
|
}
|
|
1254
1268
|
return undefined;
|
|
1255
1269
|
}
|
|
@@ -1517,11 +1531,11 @@ function buildHomeFeedRowContext(row: HomeFeedRow): HomeFeedRowContext {
|
|
|
1517
1531
|
}
|
|
1518
1532
|
|
|
1519
1533
|
const embeddedUrn = row.post_identity?.match(
|
|
1520
|
-
/(?:(shareId|ugcPostId)=|urn:li:(activity|share|ugcPost):)(\d{6,})/i
|
|
1534
|
+
/(?:(shareId|ugcPostId)=|urn:li:(activity|share|ugcPost):)(\d{6,})|urn:li:(groupPost):(\d+-\d{6,})/i
|
|
1521
1535
|
);
|
|
1522
|
-
const embeddedId = embeddedUrn?.[3];
|
|
1536
|
+
const embeddedId = embeddedUrn?.[3] ?? embeddedUrn?.[5];
|
|
1523
1537
|
const embeddedNamespace = linkedInUrnNamespace(
|
|
1524
|
-
embeddedUrn?.[1] ?? embeddedUrn?.[2] ?? ""
|
|
1538
|
+
embeddedUrn?.[1] ?? embeddedUrn?.[2] ?? embeddedUrn?.[4] ?? ""
|
|
1525
1539
|
);
|
|
1526
1540
|
const postUrl = normalizeLinkedInPostUrl(
|
|
1527
1541
|
row.post_url ??
|
|
@@ -1548,7 +1562,7 @@ function isHomeFeedRowNoise(
|
|
|
1548
1562
|
/**
|
|
1549
1563
|
* Map cs_scrape home-feed rows to event envelopes. A scraped permalink still
|
|
1550
1564
|
* wins when a row carries one, but current cards expose none, so the canonical
|
|
1551
|
-
* post identity is normally the activity/share/ugcPost id embedded in
|
|
1565
|
+
* post identity is normally the activity/share/ugcPost/groupPost id embedded in
|
|
1552
1566
|
* `post_identity`. The scrape-only componentkey never becomes an event origin,
|
|
1553
1567
|
* and a post without either durable identity is not emitted. Native comments
|
|
1554
1568
|
* carry their own durable id and point at the stable parent-post origin.
|
|
@@ -1721,20 +1735,24 @@ type PrepareCommentResult = {
|
|
|
1721
1735
|
|
|
1722
1736
|
/**
|
|
1723
1737
|
* Canonical casing for the LinkedIn URN namespace an id came from. share and
|
|
1724
|
-
* ugcPost ids live in different id spaces than activity ids, so
|
|
1725
|
-
* has to survive normalization; /feed/update/ resolves all
|
|
1738
|
+
* ugcPost and groupPost ids live in different id spaces than activity ids, so
|
|
1739
|
+
* the namespace has to survive normalization; /feed/update/ resolves them all.
|
|
1726
1740
|
*/
|
|
1727
|
-
function linkedInUrnNamespace(
|
|
1741
|
+
function linkedInUrnNamespace(
|
|
1742
|
+
token: string
|
|
1743
|
+
): "activity" | "share" | "ugcPost" | "groupPost" {
|
|
1728
1744
|
const normalized = token.toLowerCase();
|
|
1729
1745
|
if (normalized === "shareid" || normalized === "share") return "share";
|
|
1730
1746
|
if (normalized === "ugcpostid" || normalized === "ugcpost") return "ugcPost";
|
|
1747
|
+
if (normalized === "grouppost") return "groupPost";
|
|
1731
1748
|
return "activity";
|
|
1732
1749
|
}
|
|
1733
1750
|
|
|
1734
1751
|
/**
|
|
1735
1752
|
* Normalize a post URL or activity id into a linkedin.com update URL.
|
|
1736
1753
|
* Accepts full URLs, `urn:li:activity:…` / `urn:li:share:…` /
|
|
1737
|
-
* `urn:li:ugcPost
|
|
1754
|
+
* `urn:li:ugcPost:…` / `urn:li:groupPost:<group>-<post>`, bare activity digits,
|
|
1755
|
+
* or `/feed/update/…` paths.
|
|
1738
1756
|
*/
|
|
1739
1757
|
export function normalizeLinkedInPostUrl(input: string): string | null {
|
|
1740
1758
|
const raw = input.trim();
|
|
@@ -1746,12 +1764,13 @@ export function normalizeLinkedInPostUrl(input: string): string | null {
|
|
|
1746
1764
|
return `https://www.linkedin.com/feed/update/urn:li:activity:${bareId}`;
|
|
1747
1765
|
}
|
|
1748
1766
|
|
|
1749
|
-
//
|
|
1750
|
-
|
|
1751
|
-
|
|
1767
|
+
// Post URNs or shorthand, with a compound id only for groupPost.
|
|
1768
|
+
const urnMatch = raw.match(
|
|
1769
|
+
/(?:urn:li:)?(?:(activity|share|ugcPost):(\d{6,})|(groupPost):(\d+-\d{6,}))/i
|
|
1770
|
+
);
|
|
1752
1771
|
if (urnMatch && !raw.includes("://") && !raw.startsWith("/")) {
|
|
1753
|
-
const ns = linkedInUrnNamespace(urnMatch[1] ?? "");
|
|
1754
|
-
return `https://www.linkedin.com/feed/update/urn:li:${ns}:${urnMatch[2] ?? ""}`;
|
|
1772
|
+
const ns = linkedInUrnNamespace(urnMatch[1] ?? urnMatch[3] ?? "");
|
|
1773
|
+
return `https://www.linkedin.com/feed/update/urn:li:${ns}:${urnMatch[2] ?? urnMatch[4] ?? ""}`;
|
|
1755
1774
|
}
|
|
1756
1775
|
|
|
1757
1776
|
try {
|
|
@@ -1772,11 +1791,11 @@ export function normalizeLinkedInPostUrl(input: string): string | null {
|
|
|
1772
1791
|
// Prefer canonical feed/update URLs when we can extract a post id, keeping
|
|
1773
1792
|
// whichever URN namespace the source URL used.
|
|
1774
1793
|
const urnInUrl = `${u.pathname}${u.search}`.match(
|
|
1775
|
-
/(?:urn(?::|%3A)li(?::|%3A))?(activity|share|ugcPost)(?::|%3A|-)(\d{6,})/i
|
|
1794
|
+
/(?:urn(?::|%3A)li(?::|%3A))?(?:(activity|share|ugcPost)(?::|%3A|-)(\d{6,})|(groupPost)(?::|%3A|-)(\d+-\d{6,}))/i
|
|
1776
1795
|
);
|
|
1777
1796
|
if (urnInUrl) {
|
|
1778
|
-
const ns = linkedInUrnNamespace(urnInUrl[1] ?? "");
|
|
1779
|
-
return `https://www.linkedin.com/feed/update/urn:li:${ns}:${urnInUrl[2] ?? ""}`;
|
|
1797
|
+
const ns = linkedInUrnNamespace(urnInUrl[1] ?? urnInUrl[3] ?? "");
|
|
1798
|
+
return `https://www.linkedin.com/feed/update/urn:li:${ns}:${urnInUrl[2] ?? urnInUrl[4] ?? ""}`;
|
|
1780
1799
|
}
|
|
1781
1800
|
return null;
|
|
1782
1801
|
} catch {
|
|
@@ -2914,7 +2933,7 @@ export default class LinkedInConnector extends ConnectorRuntime<
|
|
|
2914
2933
|
name: "LinkedIn",
|
|
2915
2934
|
description:
|
|
2916
2935
|
"Read LinkedIn feeds, notifications, and recent inbox messages through paired Chrome. Subscribe to source changes, answer direct messages, and prepare message, post, or comment drafts for human submission. Also supports local LinkedIn Data Export CSV files.",
|
|
2917
|
-
version: "3.20.
|
|
2936
|
+
version: "3.20.1",
|
|
2918
2937
|
faviconDomain: "linkedin.com",
|
|
2919
2938
|
// Live feeds bind a signed-in Chrome account. Local takeout imports need no browser.
|
|
2920
2939
|
browser: {
|