@lobu/runtime-device 24.4.0 → 24.6.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 (113) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +77 -64
  3. package/dist/verify.mjs +1 -1
  4. package/npm-shrinkwrap.json +176 -141
  5. package/package.json +3 -2
  6. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +65 -11
  7. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +20 -13
  8. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +48 -100
  9. package/vendor/cli/dist/commands/_lib/apply/client.js +76 -27
  10. package/vendor/cli/dist/commands/_lib/apply/deployment.js +1 -1
  11. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +7 -11
  12. package/vendor/cli/dist/commands/_lib/apply/desired-state.js +9 -40
  13. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +4 -4
  14. package/vendor/cli/dist/commands/_lib/apply/diff.js +37 -33
  15. package/vendor/cli/dist/commands/_lib/apply/map-config.d.ts +1 -1
  16. package/vendor/cli/dist/commands/_lib/apply/map-config.js +79 -92
  17. package/vendor/cli/dist/commands/_lib/apply/shared.d.ts +3 -6
  18. package/vendor/cli/dist/commands/_lib/apply/shared.js +8 -19
  19. package/vendor/cli/dist/commands/_lib/view-bundler.js +9 -1
  20. package/vendor/cli/dist/commands/dev.js +21 -7
  21. package/vendor/cli/dist/commands/doctor.js +1 -8
  22. package/vendor/cli/dist/commands/init.js +4 -5
  23. package/vendor/cli/dist/config/define.d.ts +27 -28
  24. package/vendor/cli/dist/config/define.js +4 -5
  25. package/vendor/cli/dist/connectors/linkedin-identity.ts +43 -0
  26. package/vendor/cli/dist/connectors/linkedin.ts +154 -3
  27. package/vendor/cli/dist/connectors/postgres.ts +77 -48
  28. package/vendor/cli/dist/connectors/x-like-follow.ts +329 -0
  29. package/vendor/cli/dist/connectors/x.ts +709 -80
  30. package/vendor/cli/dist/internal/api-client.d.ts +2 -0
  31. package/vendor/cli/dist/internal/api-client.js +6 -1
  32. package/vendor/cli/dist/internal/connector-compiler.js +3 -1
  33. package/vendor/cli/dist/internal/node-binary.d.ts +22 -0
  34. package/vendor/cli/dist/internal/node-binary.js +73 -0
  35. package/vendor/cli/dist/internal/node-version.d.ts +7 -12
  36. package/vendor/cli/dist/internal/node-version.js +16 -20
  37. package/vendor/cli/dist/runtime-components.json +4 -4
  38. package/vendor/cli/dist/templates/AGENTS.md.tmpl +2 -2
  39. package/vendor/cli/package.json +3 -2
  40. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +8 -2
  41. package/vendor/connector-sdk/dist/reaction-sdk.d.ts +5 -1
  42. package/vendor/connector-sdk/package.json +1 -1
  43. package/vendor/connector-worker/dist/compile/index.d.ts +4 -3
  44. package/vendor/connector-worker/dist/compile/index.js +6 -3
  45. package/vendor/connector-worker/dist/daemon/acp-adapters/claude.js +1 -1
  46. package/vendor/connector-worker/dist/daemon/agent-turn.js +21 -10
  47. package/vendor/connector-worker/dist/daemon/client.d.ts +25 -8
  48. package/vendor/connector-worker/dist/daemon/client.js +25 -3
  49. package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +7 -1
  50. package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +17 -0
  51. package/vendor/connector-worker/dist/daemon/poll-loop.js +75 -6
  52. package/vendor/connector-worker/dist/daemon/resource-admission.d.ts +19 -0
  53. package/vendor/connector-worker/dist/daemon/resource-admission.js +59 -0
  54. package/vendor/connector-worker/dist/daemon/resources.d.ts +20 -0
  55. package/vendor/connector-worker/dist/daemon/resources.js +163 -0
  56. package/vendor/connector-worker/dist/daemon/start.js +29 -4
  57. package/vendor/connector-worker/dist/daemon/worker.d.ts +2 -0
  58. package/vendor/connector-worker/dist/daemon/worker.js +4 -0
  59. package/vendor/connector-worker/dist/executor/select.d.ts +1 -1
  60. package/vendor/connector-worker/dist/executor/select.js +1 -1
  61. package/vendor/connector-worker/dist/isolate/ivm-types.d.ts +1 -2
  62. package/vendor/connector-worker/dist/isolate/ivm-types.js +1 -2
  63. package/vendor/connector-worker/dist/isolate/load.d.ts +10 -12
  64. package/vendor/connector-worker/dist/isolate/load.js +23 -27
  65. package/vendor/connector-worker/dist/self-check/index.d.ts +2 -2
  66. package/vendor/connector-worker/dist/self-check/index.js +2 -2
  67. package/vendor/connector-worker/package.json +3 -4
  68. package/vendor/core/dist/contracts/agent-settings.d.ts +61 -6
  69. package/vendor/core/dist/contracts/agent-settings.js +10 -7
  70. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +473 -98
  71. package/vendor/core/dist/contracts/tools/manage-agents.js +111 -2
  72. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +21 -18
  73. package/vendor/core/dist/contracts/tools/manage-automations.js +15 -15
  74. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
  75. package/vendor/core/dist/contracts/tools/manage-inference-providers.d.ts +445 -0
  76. package/vendor/core/dist/contracts/tools/manage-inference-providers.js +133 -0
  77. package/vendor/core/dist/contracts/tools/manage-views.d.ts +4 -4
  78. package/vendor/core/dist/contracts/tools/manage-views.js +5 -3
  79. package/vendor/core/dist/contracts/tools/view-host.d.ts +7 -0
  80. package/vendor/core/dist/contracts/tools/view-host.js +28 -0
  81. package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -4
  82. package/vendor/core/dist/contracts/tools/view-runtime.js +19 -7
  83. package/vendor/core/dist/contracts/worker/device-automation.js +4 -2
  84. package/vendor/core/dist/error-report.d.ts +73 -0
  85. package/vendor/core/dist/error-report.js +346 -0
  86. package/vendor/core/dist/index.d.ts +3 -1
  87. package/vendor/core/dist/index.js +4 -1
  88. package/vendor/core/dist/logger.js +7 -4
  89. package/vendor/core/dist/otel-fetch.d.ts +19 -0
  90. package/vendor/core/dist/otel-fetch.js +96 -0
  91. package/vendor/core/dist/otel.d.ts +9 -0
  92. package/vendor/core/dist/otel.js +28 -7
  93. package/vendor/core/dist/reserved.d.ts +1 -1
  94. package/vendor/core/dist/reserved.js +6 -4
  95. package/vendor/core/dist/tool-result.d.ts +8 -0
  96. package/vendor/core/dist/tool-result.js +61 -0
  97. package/vendor/core/dist/utils/diagnostic-scrubber.js +1 -1
  98. package/vendor/core/dist/worker/auth.js +4 -0
  99. package/vendor/core/package.json +16 -1
  100. package/vendor/views/dist/api.d.ts +290 -0
  101. package/vendor/views/dist/api.js +714 -0
  102. package/vendor/views/dist/bridge.d.ts +157 -0
  103. package/vendor/views/dist/bridge.js +372 -0
  104. package/vendor/views/dist/components.d.ts +172 -0
  105. package/vendor/views/dist/components.js +376 -0
  106. package/vendor/views/dist/index.d.ts +13 -0
  107. package/vendor/views/dist/index.js +3 -0
  108. package/vendor/views/dist/native.d.ts +327 -0
  109. package/vendor/views/dist/native.js +57 -0
  110. package/vendor/views/package.json +53 -0
  111. /package/vendor/cli/dist/vendor/ora/{.bun-tag-fde20e9a6df212fa → .bun-tag-77bb9b258a474a18} +0 -0
  112. /package/vendor/ora/{.bun-tag-fde20e9a6df212fa → .bun-tag-77bb9b258a474a18} +0 -0
  113. /package/vendor/postgres/{.bun-tag-22d644c2873790db → .bun-tag-c81dacd34e959a7a} +0 -0
@@ -27,6 +27,12 @@ export const LINKEDIN_IDENTITY = {
27
27
  * sender's messages auto-create.
28
28
  */
29
29
  USER_MEMBER_ID: "linkedin_user_member_id",
30
+ /**
31
+ * Canonical `/company/<vanity>` page slug, the identity of a company page
32
+ * that authors a post. Like the member slug it is mutable, so it stays an
33
+ * equal-weight identity.
34
+ */
35
+ COMPANY_SLUG: "linkedin_company_slug",
30
36
  } as const;
31
37
 
32
38
  export type LinkedInIdentityNamespace =
@@ -47,6 +53,41 @@ export function normalizeLinkedInSlug(
47
53
  return slug;
48
54
  }
49
55
 
56
+ /**
57
+ * Extract a canonical LinkedIn company-page slug from a `/company/<slug>` URL
58
+ * or bare slug. An all-digit value is LinkedIn's numeric company id rather than
59
+ * the vanity slug; accepting it would key the same page under two identifiers,
60
+ * so it is rejected.
61
+ */
62
+ export function normalizeLinkedInCompanySlug(
63
+ raw: string | null | undefined,
64
+ ): string | null {
65
+ if (typeof raw !== "string") return null;
66
+ const value = raw.trim();
67
+ if (!value) return null;
68
+ const slug = (
69
+ value.includes("/") ? companyPathSlug(value) : value
70
+ )?.toLowerCase();
71
+ if (!slug || !/^[a-z0-9\-_%]+$/.test(slug) || /^\d+$/.test(slug)) {
72
+ return null;
73
+ }
74
+ return slug;
75
+ }
76
+
77
+ /** The path segment after `company` in an absolute or site-relative URL. */
78
+ function companyPathSlug(url: string): string | null {
79
+ let segments: string[];
80
+ try {
81
+ segments = new URL(url, "https://www.linkedin.com").pathname.split("/");
82
+ } catch {
83
+ return null;
84
+ }
85
+ const index = segments.findIndex(
86
+ (segment) => segment.toLowerCase() === "company",
87
+ );
88
+ return index >= 0 ? (segments[index + 1] ?? null) : null;
89
+ }
90
+
50
91
  /**
51
92
  * Extract the immutable member id from a LinkedIn person URN or bare id.
52
93
  */
@@ -73,6 +114,8 @@ export function normalizeLinkedInIdentityValue(
73
114
  switch (namespace) {
74
115
  case LINKEDIN_IDENTITY.SLUG:
75
116
  return normalizeLinkedInSlug(raw);
117
+ case LINKEDIN_IDENTITY.COMPANY_SLUG:
118
+ return normalizeLinkedInCompanySlug(raw);
76
119
  case LINKEDIN_IDENTITY.MEMBER_ID:
77
120
  case LINKEDIN_IDENTITY.USER_MEMBER_ID:
78
121
  return normalizeLinkedInMemberId(raw);
@@ -52,6 +52,7 @@ import {
52
52
  } from "@lobu/connector-sdk";
53
53
  import {
54
54
  LINKEDIN_IDENTITY,
55
+ normalizeLinkedInCompanySlug,
55
56
  normalizeLinkedInMemberId,
56
57
  normalizeLinkedInSlug,
57
58
  } from "./linkedin-identity.js";
@@ -121,6 +122,7 @@ interface LinkedInConfig extends LocalTakeoutConfig {
121
122
  company_url?: string;
122
123
  max_scrolls?: number;
123
124
  min_scrolls?: number;
125
+ create_engager_people?: boolean;
124
126
  }
125
127
 
126
128
  interface LinkedInPost {
@@ -132,6 +134,8 @@ interface LinkedInPost {
132
134
  authorMemberId?: string;
133
135
  /** Canonical `/in/<slug>` vanity id — soft identity, bridges to takeout. */
134
136
  authorSlug?: string;
137
+ /** Canonical `/company/<slug>` when the actor is a company page. */
138
+ authorCompanySlug?: string;
135
139
  likes: number;
136
140
  comments: number;
137
141
  shares: number;
@@ -228,6 +232,47 @@ const LINKEDIN_MESSAGE_ATTRIBUTIONS: EventAttributionRule[] = [
228
232
  },
229
233
  ];
230
234
 
235
+ /**
236
+ * Link a post written by a company page to a `company` entity keyed on the
237
+ * page's `/company/<slug>`. Like person authors, a company that authors a post
238
+ * is a real source, so it is minted on no match; a workspace without a
239
+ * `company` entity type skips the mint. Companies that are only mentioned or
240
+ * anchored in someone else's post get no rule, matching person mentions.
241
+ */
242
+ const LINKEDIN_COMPANY_AUTHOR_ATTRIBUTION: EventAttributionRule = {
243
+ name: "company_author",
244
+ role: "authored_by",
245
+ autoCreate: true,
246
+ target: {
247
+ entityType: "company",
248
+ titlePath: "author_name",
249
+ identities: [
250
+ {
251
+ namespace: LINKEDIN_IDENTITY.COMPANY_SLUG,
252
+ eventPath: "metadata.author_company_slug",
253
+ },
254
+ ],
255
+ },
256
+ traits: {
257
+ linkedin_url: {
258
+ eventPath: "metadata.author_company_url",
259
+ mergeStrategy: "prefer_non_empty",
260
+ },
261
+ },
262
+ };
263
+
264
+ /**
265
+ * Engager-type people (reactors, commenters, the comment being replied to) are
266
+ * mostly one-off strangers. The home_feed `create_engager_people` setting is
267
+ * stamped on each event; when it is false these roles still link to people who
268
+ * already exist but never create new ones. Events without the stamp keep
269
+ * creating, so the default and older events are unchanged.
270
+ */
271
+ const CREATE_ENGAGER_PEOPLE_GATE = {
272
+ path: "metadata.create_engager_people",
273
+ notEquals: false,
274
+ } as const;
275
+
231
276
  /**
232
277
  * Link a live `post` to its author. The Voyager feed (company_updates) exposes
233
278
  * the actor's immutable `urn:li:fsd_profile:<id>` as `author_member_id` plus the
@@ -273,6 +318,7 @@ const LINKEDIN_POST_AUTHOR_ATTRIBUTIONS: EventAttributionRule[] = [
273
318
  },
274
319
  },
275
320
  },
321
+ LINKEDIN_COMPANY_AUTHOR_ATTRIBUTION,
276
322
  ];
277
323
 
278
324
  /**
@@ -304,12 +350,14 @@ const LINKEDIN_HOME_FEED_ATTRIBUTIONS: EventAttributionRule[] = [
304
350
  },
305
351
  },
306
352
  },
353
+ LINKEDIN_COMPANY_AUTHOR_ATTRIBUTION,
307
354
  {
308
355
  name: "engager",
309
356
  role: "performed_by",
310
357
  autoCreate: true,
311
358
  target: {
312
359
  entityType: "person",
360
+ createWhen: CREATE_ENGAGER_PEOPLE_GATE,
313
361
  titlePath: "metadata.social_actor",
314
362
  identities: [
315
363
  {
@@ -335,6 +383,7 @@ const LINKEDIN_HOME_COMMENT_ATTRIBUTIONS: EventAttributionRule[] = [
335
383
  autoCreate: true,
336
384
  target: {
337
385
  entityType: "person",
386
+ createWhen: CREATE_ENGAGER_PEOPLE_GATE,
338
387
  titlePath: "author_name",
339
388
  identities: [
340
389
  {
@@ -377,6 +426,7 @@ const LINKEDIN_HOME_COMMENT_ATTRIBUTIONS: EventAttributionRule[] = [
377
426
  autoCreate: true,
378
427
  target: {
379
428
  entityType: "person",
429
+ createWhen: CREATE_ENGAGER_PEOPLE_GATE,
380
430
  titlePath: "metadata.parent_comment_author",
381
431
  identities: [
382
432
  {
@@ -1168,6 +1218,10 @@ export function homeFeedObjectAllSupported(rows: HomeFeedRow[]): boolean {
1168
1218
  return withLinks.some((r) => Array.isArray(r.links));
1169
1219
  }
1170
1220
 
1221
+ function companyPageUrl(slug: string): string {
1222
+ return `https://www.linkedin.com/company/${slug}`;
1223
+ }
1224
+
1171
1225
  /** Whether an href points at a `/company/` page rather than a member. */
1172
1226
  function isCompanyHref(href?: string): boolean {
1173
1227
  return /\/company\//i.test(href ?? "");
@@ -1204,6 +1258,32 @@ function resolveMemberSlug(
1204
1258
  return [...memberSlugs][0];
1205
1259
  }
1206
1260
 
1261
+ /**
1262
+ * Resolve a company author's `/company/<slug>` the same way: the target name
1263
+ * must match exactly one company page and no member, so a same-named person
1264
+ * (or two same-named pages) leaves the author unattributed rather than guessed.
1265
+ */
1266
+ function resolveCompanySlug(
1267
+ links: HomeFeedLink[],
1268
+ targetName: string
1269
+ ): string | undefined {
1270
+ const target = nameKey(targetName);
1271
+ if (!target) return undefined;
1272
+ const companySlugs = new Set<string>();
1273
+ let memberMatch = false;
1274
+ for (const link of links) {
1275
+ if (nameKey(linkDisplayName(link)) !== target) continue;
1276
+ if (normalizeLinkedInSlug(link.href)) {
1277
+ memberMatch = true;
1278
+ continue;
1279
+ }
1280
+ const slug = normalizeLinkedInCompanySlug(link.href);
1281
+ if (slug) companySlugs.add(slug);
1282
+ }
1283
+ if (memberMatch || companySlugs.size !== 1) return undefined;
1284
+ return [...companySlugs][0];
1285
+ }
1286
+
1207
1287
  /**
1208
1288
  * The home feed mixes in ads, suggestions, and non-post noise. These never
1209
1289
  * become useful events, so drop them before emitting. Heuristic by necessity —
@@ -1249,6 +1329,8 @@ interface HomeFeedCommentIdentity {
1249
1329
  interface HomeFeedRowContext {
1250
1330
  author: string;
1251
1331
  authorSlug?: string;
1332
+ /** Set when the row's author is a company page rather than a member. */
1333
+ authorCompanySlug?: string;
1252
1334
  postUrl?: string;
1253
1335
  metadata: Record<string, unknown>;
1254
1336
  }
@@ -1508,6 +1590,9 @@ function buildHomeFeedRowContext(row: HomeFeedRow): HomeFeedRowContext {
1508
1590
  const links = normalizeHomeFeedLinks(row.links);
1509
1591
  const engagement = banner?.kind === "actor" ? banner : null;
1510
1592
  const authorSlug = resolveMemberSlug(links, author);
1593
+ const authorCompanySlug = authorSlug
1594
+ ? undefined
1595
+ : resolveCompanySlug(links, author);
1511
1596
  const engagerSlug = engagement
1512
1597
  ? resolveMemberSlug(links, engagement.actor)
1513
1598
  : undefined;
@@ -1544,6 +1629,7 @@ function buildHomeFeedRowContext(row: HomeFeedRow): HomeFeedRowContext {
1544
1629
  return {
1545
1630
  author,
1546
1631
  authorSlug,
1632
+ ...(authorCompanySlug ? { authorCompanySlug } : {}),
1547
1633
  postUrl: postUrl || undefined,
1548
1634
  metadata,
1549
1635
  };
@@ -1712,7 +1798,15 @@ export function buildHomeFeedEvents(
1712
1798
  // source_url is the durable post handle action callers (prepare_comment)
1713
1799
  // resolve directly.
1714
1800
  ...(sourceUrl ? { source_url: sourceUrl } : {}),
1715
- metadata: context.metadata,
1801
+ // A company author belongs to the post only: comment rows share the row
1802
+ // context, but their author is always the commenter.
1803
+ metadata: context.authorCompanySlug
1804
+ ? {
1805
+ ...context.metadata,
1806
+ author_company_slug: context.authorCompanySlug,
1807
+ author_company_url: companyPageUrl(context.authorCompanySlug),
1808
+ }
1809
+ : context.metadata,
1716
1810
  });
1717
1811
  }
1718
1812
  return events;
@@ -2613,6 +2707,12 @@ export function parseCompanyUpdates(
2613
2707
  // normalizeLinkedInSlug pulls the `/in/<slug>` segment from a full URL (and
2614
2708
  // returns null for a company `/company/…` URL or anything slug-invalid).
2615
2709
  const authorSlug = normalizeLinkedInSlug(authorProfileUrl);
2710
+ // A company actor navigates to its `/company/<slug>` page. Require the
2711
+ // `/company/` path: a bare publicIdentifier is a member's vanity slug.
2712
+ const authorCompanySlug =
2713
+ !authorMemberId && !authorSlug && isCompanyHref(authorProfileUrl)
2714
+ ? normalizeLinkedInCompanySlug(authorProfileUrl)
2715
+ : null;
2616
2716
 
2617
2717
  // Get social counts
2618
2718
  const socialRef = el["*socialDetail"] ?? el.socialDetail;
@@ -2640,6 +2740,7 @@ export function parseCompanyUpdates(
2640
2740
  authorHeadline: typeof authorDesc === "string" ? authorDesc : undefined,
2641
2741
  authorMemberId: authorMemberId || undefined,
2642
2742
  authorSlug: authorSlug ?? undefined,
2743
+ authorCompanySlug: authorCompanySlug ?? undefined,
2643
2744
  likes: counts.numLikes ?? 0,
2644
2745
  comments: counts.numComments ?? 0,
2645
2746
  shares: counts.numShares ?? 0,
@@ -2737,6 +2838,12 @@ const homeFeedConfigSchema = {
2737
2838
  description:
2738
2839
  "Optional lower bound. When set below max_scrolls, each sync picks a uniform random scroll count in [min_scrolls, max_scrolls].",
2739
2840
  },
2841
+ create_engager_people: {
2842
+ type: "boolean",
2843
+ default: true,
2844
+ description:
2845
+ "Create a new person for each member who reacted to, commented on, or was replied to on a feed post (default: true). When off, those members are still linked to people that already exist, but no new people are created for them. Post authors are always created.",
2846
+ },
2740
2847
  },
2741
2848
  };
2742
2849
 
@@ -3072,6 +3179,17 @@ export default class LinkedInConnector extends ConnectorRuntime<
3072
3179
  author: { type: "string" },
3073
3180
  author_linkedin_slug: { type: "string" },
3074
3181
  author_profile_url: { type: "string" },
3182
+ author_company_slug: {
3183
+ type: "string",
3184
+ description:
3185
+ "The `/company/<slug>` of the company page that wrote the post, when the author is a company.",
3186
+ },
3187
+ author_company_url: { type: "string" },
3188
+ create_engager_people: {
3189
+ type: "boolean",
3190
+ description:
3191
+ "The connection's create_engager_people setting when the post was read.",
3192
+ },
3075
3193
  social_actor: {
3076
3194
  type: "string",
3077
3195
  description:
@@ -3114,6 +3232,11 @@ export default class LinkedInConnector extends ConnectorRuntime<
3114
3232
  parent_comment_author_linkedin_slug: { type: "string" },
3115
3233
  parent_comment_author_profile_url: { type: "string" },
3116
3234
  is_reply: { type: "boolean" },
3235
+ create_engager_people: {
3236
+ type: "boolean",
3237
+ description:
3238
+ "The connection's create_engager_people setting when the comment was read.",
3239
+ },
3117
3240
  reactions: { type: "number" },
3118
3241
  comments: { type: "number" },
3119
3242
  reposts: { type: "number" },
@@ -3138,6 +3261,12 @@ export default class LinkedInConnector extends ConnectorRuntime<
3138
3261
  author_headline: { type: "string" },
3139
3262
  author_member_id: { type: "string" },
3140
3263
  author_linkedin_slug: { type: "string" },
3264
+ author_company_slug: {
3265
+ type: "string",
3266
+ description:
3267
+ "The `/company/<slug>` of the company page that wrote the post, when the author is a company.",
3268
+ },
3269
+ author_company_url: { type: "string" },
3141
3270
  likes: { type: "number" },
3142
3271
  comments: { type: "number" },
3143
3272
  shares: { type: "number" },
@@ -3747,7 +3876,12 @@ export default class LinkedInConnector extends ConnectorRuntime<
3747
3876
  // company_url — it always reads LINKEDIN_HOME_URL.
3748
3877
  if (feedKey === "home_feed") {
3749
3878
  const homeScrolls = readHomeScrollBudget(config);
3750
- return this.syncHomeFeed(homeScrolls, checkpoint, requireBrowser(ctx));
3879
+ return this.syncHomeFeed(
3880
+ homeScrolls,
3881
+ config.create_engager_people !== false,
3882
+ checkpoint,
3883
+ requireBrowser(ctx)
3884
+ );
3751
3885
  }
3752
3886
 
3753
3887
  if (!config.company_url) {
@@ -3778,6 +3912,7 @@ export default class LinkedInConnector extends ConnectorRuntime<
3778
3912
  */
3779
3913
  private async syncHomeFeed(
3780
3914
  maxScrolls: number,
3915
+ createEngagerPeople: boolean,
3781
3916
  checkpoint: LinkedInCheckpoint,
3782
3917
  dispatcher: ChromeActionDispatcher
3783
3918
  ): Promise<LinkedInSyncPage> {
@@ -3827,7 +3962,17 @@ export default class LinkedInConnector extends ConnectorRuntime<
3827
3962
 
3828
3963
  const commentCoverage = summarizeHomeFeedCommentCoverage(resolvedRows);
3829
3964
 
3830
- const events = buildHomeFeedEvents(resolvedRows, new Date());
3965
+ // Stamp the connection's engager setting on every event so the engager,
3966
+ // commenter, and replied-to rules can gate person creation on it.
3967
+ const events = buildHomeFeedEvents(resolvedRows, new Date()).map(
3968
+ (event) => ({
3969
+ ...event,
3970
+ metadata: {
3971
+ ...event.metadata,
3972
+ create_engager_people: createEngagerPeople,
3973
+ },
3974
+ })
3975
+ );
3831
3976
  if (events.length === 0) {
3832
3977
  throw new Error(
3833
3978
  "LinkedIn is logged in and returned feed rows, but no row combined usable content with a durable identity. Confirm that the paired browser is signed into LinkedIn and retry."
@@ -3908,6 +4053,12 @@ export default class LinkedInConnector extends ConnectorRuntime<
3908
4053
  // Voyager exposed the actor's fsd_profile urn; slug bridges to takeout.
3909
4054
  author_member_id: post.authorMemberId,
3910
4055
  author_linkedin_slug: post.authorSlug,
4056
+ ...(post.authorCompanySlug
4057
+ ? {
4058
+ author_company_slug: post.authorCompanySlug,
4059
+ author_company_url: companyPageUrl(post.authorCompanySlug),
4060
+ }
4061
+ : {}),
3911
4062
  likes: post.likes,
3912
4063
  comments: post.comments,
3913
4064
  shares: post.shares,
@@ -166,63 +166,91 @@ function escapeLike(term: string): string {
166
166
  return term.replace(/[\\%_]/g, (c) => `\\${c}`);
167
167
  }
168
168
 
169
+ /** Opening `$$` / `$tag$` of a dollar-quoted string, matched at `lastIndex`. */
170
+ const DOLLAR_QUOTE_RE = /\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/y;
171
+
169
172
  /**
170
- * True if `sql` has a `LIMIT`/`OFFSET` keyword at paren-depth 0 (a TOP-level
171
- * one), scanning past string literals, quoted identifiers, and comments so a
172
- * `'limit'` literal or a `"limit"` column never false-matches. An inner LIMIT
173
- * inside a subquery sits at depth > 0 and is allowed. Works without the AST, so
174
- * it gates both the parseable and the token-fallback paths identically.
173
+ * Blank out string literals, quoted identifiers, dollar-quoted strings and
174
+ * comments (same length, so positions survive) so the structural checks only
175
+ * see executable tokens — a `';'`, `':name'`, `'$1'` or `"limit"` inside a
176
+ * literal must never trip them. Unterminated literals/comments mask to the end;
177
+ * Postgres reports those itself.
175
178
  */
176
- function hasTopLevelLimitOrOffset(sql: string): boolean {
179
+ function executableSql(sql: string): string {
177
180
  const n = sql.length;
178
- let depth = 0;
181
+ let result = '';
179
182
  let i = 0;
180
183
  while (i < n) {
184
+ const start = i;
181
185
  const c = sql[i];
182
- if (c === "'") {
183
- i++;
184
- while (i < n && sql[i] !== "'") i++;
185
- i++;
186
- continue;
187
- }
188
- if (c === '"') {
189
- i++;
190
- while (i < n && sql[i] !== '"') i++;
186
+ if (c === "'" || c === '"') {
187
+ // E'…' strings escape with backslash; plain ones only double the quote.
188
+ const backslashEscapes =
189
+ c === "'" &&
190
+ /[eE]/.test(sql[i - 1] ?? '') &&
191
+ !/[A-Za-z0-9_$]/.test(sql[i - 2] ?? '');
191
192
  i++;
192
- continue;
193
- }
194
- if (c === '-' && sql[i + 1] === '-') {
195
- i += 2;
193
+ while (i < n) {
194
+ if (backslashEscapes && sql[i] === '\\') {
195
+ i += 2;
196
+ continue;
197
+ }
198
+ if (sql[i++] === c) {
199
+ if (sql[i] !== c) break;
200
+ i++;
201
+ }
202
+ }
203
+ } else if (c === '$' && !/[A-Za-z0-9_$]/.test(sql[i - 1] ?? '')) {
204
+ DOLLAR_QUOTE_RE.lastIndex = i;
205
+ const delimiter = DOLLAR_QUOTE_RE.exec(sql)?.[0];
206
+ if (!delimiter) {
207
+ result += c;
208
+ i++;
209
+ continue;
210
+ }
211
+ const end = sql.indexOf(delimiter, i + delimiter.length);
212
+ i = end < 0 ? n : end + delimiter.length;
213
+ } else if (c === '-' && sql[i + 1] === '-') {
196
214
  while (i < n && sql[i] !== '\n') i++;
197
- continue;
198
- }
199
- if (c === '/' && sql[i + 1] === '*') {
215
+ } else if (c === '/' && sql[i + 1] === '*') {
216
+ let depth = 1;
200
217
  i += 2;
201
- while (i < n && !(sql[i] === '*' && sql[i + 1] === '/')) i++;
202
- i += 2;
203
- continue;
204
- }
205
- if (c === '(') {
206
- depth++;
207
- i++;
208
- continue;
209
- }
210
- if (c === ')') {
211
- if (depth > 0) depth--;
218
+ while (i < n && depth > 0) {
219
+ if (sql[i] === '/' && sql[i + 1] === '*') {
220
+ depth++;
221
+ i += 2;
222
+ } else if (sql[i] === '*' && sql[i + 1] === '/') {
223
+ depth--;
224
+ i += 2;
225
+ } else {
226
+ i++;
227
+ }
228
+ }
229
+ } else {
230
+ result += c;
212
231
  i++;
213
232
  continue;
214
233
  }
215
- if (/[A-Za-z_]/.test(c)) {
216
- let j = i + 1;
217
- while (j < n && /[A-Za-z0-9_$]/.test(sql[j])) j++;
218
- if (depth === 0) {
219
- const word = sql.slice(i, j).toLowerCase();
220
- if (word === 'limit' || word === 'offset') return true;
221
- }
222
- i = j;
223
- continue;
234
+ result += ' '.repeat(Math.min(i, n) - start);
235
+ }
236
+ return result;
237
+ }
238
+
239
+ /**
240
+ * True if `sql` (already masked by executableSql) has a LIMIT/OFFSET keyword
241
+ * at paren-depth 0. An inner LIMIT inside a subquery sits at depth > 0 and is
242
+ * allowed.
243
+ */
244
+ function hasTopLevelLimitOrOffset(sql: string): boolean {
245
+ let depth = 0;
246
+ for (const [token] of sql.matchAll(/[A-Za-z_][A-Za-z0-9_$]*|[()]/g)) {
247
+ if (token === '(') {
248
+ depth++;
249
+ } else if (token === ')') {
250
+ depth = Math.max(0, depth - 1);
251
+ } else if (depth === 0 && /^(limit|offset)$/i.test(token)) {
252
+ return true;
224
253
  }
225
- i++;
226
254
  }
227
255
  return false;
228
256
  }
@@ -253,18 +281,19 @@ function queryValidationError(message: string) {
253
281
  function validateReadOnlySelect(raw: string): string {
254
282
  const stripped = raw.trim().replace(/;\s*$/, '');
255
283
  if (!stripped) throw queryValidationError('query is empty');
256
- if (stripped.includes(';')) {
284
+ const executable = executableSql(stripped);
285
+ if (executable.includes(';')) {
257
286
  throw queryValidationError('query must be a single statement (no embedded ";").');
258
287
  }
259
- if (/\$\d/.test(stripped) || /(^|[^:]):[A-Za-z_]/.test(stripped)) {
288
+ if (/\$\d/.test(executable) || /(^|[^:]):[A-Za-z_]/.test(executable)) {
260
289
  throw queryValidationError('query must not contain bind parameters ($1, :name).');
261
290
  }
262
291
  // Allow a leading "(" for "(SELECT …) UNION …" / parenthesized selects.
263
- const head = stripped.replace(/^\s*\(+\s*/, '');
292
+ const head = executable.replace(/^\s*\(+\s*/, '').trimStart();
264
293
  if (!/^(select|with)\b/i.test(head)) {
265
294
  throw queryValidationError('query must be a single read-only SELECT (or WITH … SELECT).');
266
295
  }
267
- if (hasTopLevelLimitOrOffset(stripped)) {
296
+ if (hasTopLevelLimitOrOffset(executable)) {
268
297
  throw queryValidationError(
269
298
  'query must not include a top-level LIMIT/OFFSET — the connector adds pagination automatically (an inner LIMIT inside a subquery is fine).',
270
299
  );