linkedin-relay-mcp 3.5.0 → 3.6.1

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.
@@ -125,6 +125,17 @@ The user's own graph and posts, read from the local cache. **Free — no network
125
125
  back empty, the cache has not been filled: tell the user to run `lnrelay sync connections` (or
126
126
  `sync my-posts`) rather than reporting that they have none.
127
127
 
128
+ ### `scheduled` — live, ~1 call per 10 posts. The queue.
129
+ ```
130
+ scheduled
131
+ ```
132
+ The user's own posts waiting to publish, soonest first: `urn`, `scheduledAt` (ISO), `text`. They are
133
+ **not** in `my-posts` until they go out, so check here before saying nothing is planned. Links in
134
+ `text` show as lnkd.in short links, the way LinkedIn lists them. `text` is null when it could not be
135
+ matched to its post for certain. A scheduled post is cancelled with `lnrelay delete <urn>` and its
136
+ text changed with `lnrelay edit <urn> "<text>"` (both CLI, approved like any write). If `meta.state`
137
+ is not `complete`, the list may be short — say so.
138
+
128
139
  ### `sync` — CLI-only. Fills the cache.
129
140
  ```
130
141
  lnrelay sync my-posts | lnrelay sync connections [--limit N] [--force]
@@ -187,7 +198,7 @@ Writes are **not on the MCP surface**. They exist only as CLI commands:
187
198
 
188
199
  | command | does |
189
200
  |---|---|
190
- | `lnrelay share "<text>" [--image <path> ... [--alt "…" ...] \| --video <path> \| --document <pdf> --title "…"] [--at "YYYY-MM-DD HH:MM"] [--poll "…" --option "…" --option "…" [--duration 1w]]` | post to their own feed — up to 20 images, one video, or one PDF; `--at` schedules it and LinkedIn publishes it then |
201
+ | `lnrelay share "<text>" [--image <path> ... [--alt "…" ...] \| --video <path> \| --document <pdf> --title "…"] [--at "YYYY-MM-DD HH:MM"] [--poll "…" --option "…" --option "…" [--duration 1w]] [--no-card]` | post to their own feed — up to 20 images, one video, or one PDF; `--at` schedules it and LinkedIn publishes it then; a link in the text gets its preview card unless `--no-card` |
191
202
  | `lnrelay comment <activity-urn> "<text>"` | comment on a post |
192
203
  | `lnrelay reply <comment-urn> "<text>"` | reply, nested under that comment |
193
204
  | `lnrelay edit <comment-urn \| share-urn \| ugcPost-urn> "<text>"` | change the text of their own comment or post |
@@ -225,6 +236,11 @@ Things worth telling a user who asks:
225
236
  needed at all: `docs/DECISION-writes.md`.
226
237
  - `--image` / `--video` upload over the private API only; `--via oauth` with media is refused. A
227
238
  video post comes back as a `urn:li:ugcPost:` rather than `urn:li:share:`.
239
+ - A link in a post's text gets the preview card LinkedIn's composer would show (the first link only,
240
+ and not on a post that already carries images, a video, a PDF or a poll). The plan names the card
241
+ (`card "<title>" (<site>)`), or says LinkedIn has none. If the lookup fails nothing is posted; add
242
+ `--no-card` to post the link as plain text.
243
+ - Scheduled posts are listed by `scheduled` (MCP and CLI), not by `my-posts`.
228
244
  - Editing a post replaces its whole text and LinkedIn marks it edited; pass the urn `share` printed
229
245
  (or `shareUrn` from `my-posts`), not the activity urn. An @mention in the old text is not kept.
230
246
  - A poll takes 2–4 options and runs 1d/3d/1w/2w; it cannot be scheduled yet.
package/dist/cli.js CHANGED
@@ -1341,6 +1341,18 @@ var CONTRACTS = {
1341
1341
  provenance: "verified",
1342
1342
  capturedAt: "2026-10-13"
1343
1343
  },
1344
+ // The composer's link lookup: a URL in, the article LinkedIn made of it out
1345
+ // (`urn:li:article:<id>`), which a post then carries as ARTICLE media. queryId
1346
+ // from mguttmann/linkedin-internal-api; same article urn the web composer
1347
+ // attached when captured on the date below.
1348
+ urlPreview: {
1349
+ name: "urlPreview",
1350
+ transport: "voyager-graphql",
1351
+ path: `${VOYAGER}/graphql`,
1352
+ queryId: "voyagerContentcreationDashUpdateUrlPreview.b092c1aea4b6c087ec0d09614b3b3320",
1353
+ provenance: "verified",
1354
+ capturedAt: "2026-10-13"
1355
+ },
1344
1356
  // limit of this projection is UNRESOLVED — do not treat this endpoint as an
1345
1357
  // authoritative "all my posts" until it is settled.
1346
1358
  myPosts: {
@@ -2067,6 +2079,96 @@ function parseCommentUrn(urn) {
2067
2079
  return null;
2068
2080
  }
2069
2081
 
2082
+ // src/engine/sdui-scheduled.ts
2083
+ var PAGER_ID = "com.linkedin.sdui.pagers.sharing.scheduledPosts";
2084
+ var PAGER_URL = `https://www.linkedin.com/flagship-web/rsc-action/actions/pagination?sduiid=${PAGER_ID}`;
2085
+ var SCREEN_ID2 = "com.linkedin.sdui.flagshipnav.sharing.ShareSchedulePostList";
2086
+ function scheduledPageBody(start, count2) {
2087
+ const args = {
2088
+ $type: "proto.sdui.actions.requests.RequestedArguments",
2089
+ requestedStateKeys: [],
2090
+ payload: { start, count: count2, shareLifeCycleState: "ShareLifeCycleState_SCHEDULED" },
2091
+ requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
2092
+ };
2093
+ return {
2094
+ pagerId: PAGER_ID,
2095
+ clientArguments: { ...args, states: [], screenId: SCREEN_ID2, knownTemplateIds: [] },
2096
+ paginationRequest: {
2097
+ $type: "proto.sdui.actions.requests.PaginationRequest",
2098
+ pagerId: PAGER_ID,
2099
+ retryCount: 0,
2100
+ requestedArguments: args
2101
+ }
2102
+ };
2103
+ }
2104
+ var COUNT = /"id":"ShareBoxscheduledPostCount"\}\}\},"value":\{"\$case":"intValue","intValue":(\d+)\}/;
2105
+ var ROW = /"feedUpdateUrn":"(urn:li:(?:share|ugcPost):\d+)","scheduledAtEpochMillis":"(\d+)"/g;
2106
+ var TEXT = /"viewName":"mini-update-container"[\s\S]*?"textProps":\{[^{}]*?"children":\["((?:[^"\\]|\\.)*)"\]/g;
2107
+ function parseScheduledPage(stream) {
2108
+ const count2 = stream.match(COUNT);
2109
+ if (count2?.[1] === void 0) {
2110
+ return drift("the scheduled-posts page carried no post count");
2111
+ }
2112
+ const claimedCount = Number(count2[1]);
2113
+ const posts = [];
2114
+ const seen = /* @__PURE__ */ new Set();
2115
+ for (const [, urn, at] of stream.matchAll(ROW)) {
2116
+ if (urn === void 0 || seen.has(urn)) continue;
2117
+ seen.add(urn);
2118
+ posts.push({ urn, scheduledAt: Number(at), text: null });
2119
+ }
2120
+ if (claimedCount > 0 && posts.length === 0) {
2121
+ return drift(`LinkedIn counts ${claimedCount} scheduled posts but no row could be read`);
2122
+ }
2123
+ const texts = [...stream.matchAll(TEXT)].map((m) => JSON.parse(`"${m[1]}"`));
2124
+ if (texts.length === posts.length) {
2125
+ posts.forEach((p, i) => {
2126
+ p.text = texts[i] ?? null;
2127
+ });
2128
+ }
2129
+ return { ok: true, claimedCount, posts };
2130
+ }
2131
+ function drift(message) {
2132
+ return {
2133
+ ok: false,
2134
+ code: "SCHEMA_DRIFT",
2135
+ message,
2136
+ hint: 'Re-capture the scheduled list (open "Scheduled" in the composer) with scripts/observe-write.ts.'
2137
+ };
2138
+ }
2139
+ var PAGE_SIZE = 10;
2140
+ var MAX_PAGES = 10;
2141
+ async function fetchScheduled(client, pageSize = PAGE_SIZE) {
2142
+ const posts = [];
2143
+ const seen = /* @__PURE__ */ new Set();
2144
+ let claimedCount = 0;
2145
+ for (let page = 0; page < MAX_PAGES; page++) {
2146
+ const result = await client.request({
2147
+ url: PAGER_URL,
2148
+ method: "POST",
2149
+ body: scheduledPageBody(posts.length, pageSize),
2150
+ spendClass: "page",
2151
+ operation: "scheduled"
2152
+ });
2153
+ if (!result.ok) {
2154
+ const out = { ok: false, code: result.code, message: result.message };
2155
+ if (result.hint !== void 0) out.hint = result.hint;
2156
+ return out;
2157
+ }
2158
+ const parsed = parseScheduledPage(result.classification.raw ?? "");
2159
+ if (!parsed.ok) return parsed;
2160
+ claimedCount = Math.max(claimedCount, parsed.claimedCount);
2161
+ const fresh = parsed.posts.filter((p) => !seen.has(p.urn));
2162
+ for (const p of fresh) {
2163
+ seen.add(p.urn);
2164
+ posts.push(p);
2165
+ }
2166
+ if (posts.length >= claimedCount || fresh.length === 0) break;
2167
+ }
2168
+ const state = posts.length >= claimedCount ? "complete" : "partial";
2169
+ return { ok: true, posts, claimedCount, state };
2170
+ }
2171
+
2070
2172
  // src/engine/session.ts
2071
2173
  var SESSION_FILE = "session.json";
2072
2174
  function loadSession() {
@@ -2246,6 +2348,7 @@ var VOYAGER2 = "https://www.linkedin.com/voyager/api";
2246
2348
  var SHARE_URL = `${VOYAGER2}/contentcreation/normShares`;
2247
2349
  var CATEGORY = {
2248
2350
  POLL: "URN_REFERENCE",
2351
+ ARTICLE: "ARTICLE",
2249
2352
  IMAGE: "IMAGE",
2250
2353
  VIDEO: "VIDEO",
2251
2354
  DOCUMENT: "NATIVE_DOCUMENT"
@@ -2318,6 +2421,8 @@ async function share(confirmed, client, bytes) {
2318
2421
  }
2319
2422
  }
2320
2423
  const media = [];
2424
+ const { card } = confirmed.payload;
2425
+ if (card !== void 0) media.push({ category: "ARTICLE", urn: card.urn });
2321
2426
  const { poll } = confirmed.payload;
2322
2427
  if (poll !== void 0) {
2323
2428
  const created = await createPoll(poll, client);
@@ -2446,6 +2551,63 @@ async function createPoll(poll, client) {
2446
2551
  }
2447
2552
  return { ok: true, urn };
2448
2553
  }
2554
+ function firstUrl(text2) {
2555
+ const found = text2.match(/https?:\/\/[^\s<>"]+/)?.[0];
2556
+ if (found === void 0) return null;
2557
+ let url = found.replace(/[.,;:!?'"]+$/, "");
2558
+ if (url.endsWith(")") && !url.includes("(")) url = url.slice(0, -1);
2559
+ return url;
2560
+ }
2561
+ function urlPreviewUrl(url) {
2562
+ const contract = contractFor("urlPreview");
2563
+ return `${contract?.path}?includeWebMetadata=true&variables=(url:${encodeURIComponent(url)})&queryId=${contract?.queryId}`;
2564
+ }
2565
+ function parseUrlPreview(json) {
2566
+ const error = gqlError(json);
2567
+ if (error !== null) {
2568
+ return { ok: false, code: "SCHEMA_DRIFT", message: `the link preview failed: ${error}` };
2569
+ }
2570
+ const j = json;
2571
+ const elements = j?.data?.data?.contentcreationDashUpdateUrlPreviewByUrl?.elements;
2572
+ if (!Array.isArray(elements)) {
2573
+ return {
2574
+ ok: false,
2575
+ code: "SCHEMA_DRIFT",
2576
+ message: "the link preview response had no preview collection",
2577
+ hint: "Re-capture the urlPreview contract: paste a link into the web composer."
2578
+ };
2579
+ }
2580
+ if (elements.length === 0) return { ok: true, card: null };
2581
+ const article = (j.included ?? []).find((e) => e.content?.articleComponent?.articleUrn)?.content?.articleComponent;
2582
+ if (article?.articleUrn === void 0) {
2583
+ return {
2584
+ ok: false,
2585
+ code: "SCHEMA_DRIFT",
2586
+ message: "LinkedIn previewed the link but no article came with it"
2587
+ };
2588
+ }
2589
+ return {
2590
+ ok: true,
2591
+ card: {
2592
+ urn: article.articleUrn,
2593
+ title: article.title?.text ?? "",
2594
+ source: article.subtitle?.text ?? ""
2595
+ }
2596
+ };
2597
+ }
2598
+ async function fetchLinkCard(url, client) {
2599
+ const result = await client.request({
2600
+ url: urlPreviewUrl(url),
2601
+ spendClass: "page",
2602
+ operation: "link-preview"
2603
+ });
2604
+ if (!result.ok) {
2605
+ const out = { ok: false, code: result.code, message: result.message };
2606
+ if (result.hint !== void 0) out.hint = result.hint;
2607
+ return out;
2608
+ }
2609
+ return parseUrlPreview(result.json);
2610
+ }
2449
2611
 
2450
2612
  // src/commands/gate.ts
2451
2613
  import { createInterface } from "readline/promises";
@@ -2535,6 +2697,15 @@ function findOwnPost(posts, urn) {
2535
2697
  (p) => typeof p.urn === "string" && postId(p.urn) === id || p.shareUrn === urn
2536
2698
  );
2537
2699
  }
2700
+ function findScheduled(queue, urn) {
2701
+ const found = queue.find((p) => p.urn === urn);
2702
+ if (found === void 0) return void 0;
2703
+ return {
2704
+ urn: found.urn,
2705
+ ...found.text === null ? {} : { text: found.text },
2706
+ scheduledAt: new Date(found.scheduledAt).toISOString()
2707
+ };
2708
+ }
2538
2709
  function previewLines2(post) {
2539
2710
  if (post === void 0) {
2540
2711
  return [
@@ -2547,7 +2718,21 @@ function previewLines2(post) {
2547
2718
  }
2548
2719
  const text2 = typeof post.text === "string" ? post.text : "(no text \u2014 media-only post?)";
2549
2720
  const shown = text2.length > PREVIEW_CHARS ? `${text2.slice(0, PREVIEW_CHARS)}\u2026` : text2;
2550
- return [`content "${shown.replace(/\n/g, " ")}"`];
2721
+ const lines = [`content "${shown.replace(/\n/g, " ")}"`];
2722
+ if (typeof post.scheduledAt === "string") {
2723
+ lines.push(`status scheduled, publishes ${post.scheduledAt} unless cancelled`);
2724
+ }
2725
+ return lines;
2726
+ }
2727
+ function deletePlan(urn, post) {
2728
+ const scheduled = typeof post?.scheduledAt === "string";
2729
+ return {
2730
+ action: scheduled ? "cancel a scheduled post" : "delete a post",
2731
+ payload: { urn },
2732
+ summary: [`post ${urn}`, ...previewLines2(post)],
2733
+ reversibility: scheduled ? "NONE, but it never published: nobody has seen it, and it will not go out." : "NONE. A deleted post is gone, with its comments and reactions.",
2734
+ transport: "voyager"
2735
+ };
2551
2736
  }
2552
2737
  async function lookup(urn, quiet) {
2553
2738
  const session = loadSession();
@@ -2559,7 +2744,11 @@ async function lookup(urn, quiet) {
2559
2744
  if (profileUrn === void 0) return void 0;
2560
2745
  const posts = await engine.myPosts(profileUrn, LOOKUP_LIMIT);
2561
2746
  if (!posts.ok) return void 0;
2562
- return findOwnPost(shapeAll(posts.value.parsed.items, posts.value.index), urn);
2747
+ const published = findOwnPost(shapeAll(posts.value.parsed.items, posts.value.index), urn);
2748
+ if (published !== void 0) return published;
2749
+ if (!/^urn:li:(share|ugcPost):\d+$/.test(urn)) return void 0;
2750
+ const queue = await fetchScheduled(createLiveClient(session.session, void 0, quiet));
2751
+ return queue.ok ? findScheduled(queue.posts, urn) : void 0;
2563
2752
  }
2564
2753
  function evictionTarget(result) {
2565
2754
  if (!result.ok) return null;
@@ -2661,13 +2850,7 @@ async function runDelete(urn, now = Date.now(), deps, quiet = false) {
2661
2850
  const unapprovable = refuseUnapprovable("delete", "deleting", deps ?? terminalDeps());
2662
2851
  if (unapprovable !== null) return unapprovable;
2663
2852
  const post = await lookup(urn, quiet);
2664
- const plan = {
2665
- action: "delete a post",
2666
- payload: { urn },
2667
- summary: [`post ${urn}`, ...previewLines2(post)],
2668
- reversibility: "NONE. A deleted post is gone, with its comments and reactions.",
2669
- transport: "voyager"
2670
- };
2853
+ const plan = deletePlan(urn, post);
2671
2854
  const gated = await gateWrite("delete", plan, now, deps ?? terminalDeps(), {
2672
2855
  commitSpend: false
2673
2856
  });
@@ -2682,6 +2865,11 @@ async function runDelete(urn, now = Date.now(), deps, quiet = false) {
2682
2865
 
2683
2866
  // src/commands/live.ts
2684
2867
  function withSession(command, quiet = false) {
2868
+ const loaded = sessionFor(command);
2869
+ if ("ok" in loaded) return loaded;
2870
+ return { engine: createEngine(loaded.session, void 0, quiet) };
2871
+ }
2872
+ function sessionFor(command) {
2685
2873
  const loaded = loadSession();
2686
2874
  if (loaded.state === "corrupt") {
2687
2875
  return err(
@@ -2694,7 +2882,7 @@ function withSession(command, quiet = false) {
2694
2882
  if (loaded.state === "missing") {
2695
2883
  return err(command, "AUTH_FAILED", "no session \u2014 run `lnrelay login` first", LAUNCH_HINT);
2696
2884
  }
2697
- return { engine: createEngine(loaded.session, void 0, quiet) };
2885
+ return { session: loaded.session };
2698
2886
  }
2699
2887
  function toEnvelope(command, result) {
2700
2888
  return err(command, result.code, result.message, result.hint, void 0, result.retryAfterMs);
@@ -2800,6 +2988,27 @@ async function runReactions(urn, limit, opts = {}) {
2800
2988
  if (!result.ok) return toEnvelope("reactions", result);
2801
2989
  return ok("reactions", { urn: postUrn2, ...collection(result.value, opts) });
2802
2990
  }
2991
+ async function runScheduled(quiet = false) {
2992
+ const ctx = sessionFor("scheduled");
2993
+ if ("ok" in ctx) return ctx;
2994
+ const result = await fetchScheduled(createLiveClient(ctx.session, void 0, quiet));
2995
+ if (!result.ok) return err("scheduled", result.code, result.message, result.hint);
2996
+ return ok("scheduled", scheduledData(result));
2997
+ }
2998
+ function scheduledData(result) {
2999
+ return {
3000
+ items: result.posts.map((p) => ({
3001
+ urn: p.urn,
3002
+ scheduledAt: new Date(p.scheduledAt).toISOString(),
3003
+ text: p.text
3004
+ })),
3005
+ meta: {
3006
+ state: result.state,
3007
+ returnedCount: result.posts.length,
3008
+ claimedCount: result.claimedCount
3009
+ }
3010
+ };
3011
+ }
2803
3012
  function normalisePostUrn(input) {
2804
3013
  if (input === void 0 || input === "") return void 0;
2805
3014
  const found = input.match(/urn:li:(?:activity|ugcPost|share):\d+/);
@@ -3388,6 +3597,15 @@ var COMMANDS = [
3388
3597
  risk: "read",
3389
3598
  implemented: true
3390
3599
  },
3600
+ {
3601
+ name: "scheduled",
3602
+ cost: "1 call per 10 posts",
3603
+ summary: "Your posts waiting to publish, with when. Not in `my-posts` until they go out.",
3604
+ usage: "lnrelay scheduled\n Each row: urn (cancel with `delete`, change with `edit`), scheduledAt, text. Links in\n the text show as lnkd.in short links, as LinkedIn lists them.",
3605
+ audience: ["cli", "mcp"],
3606
+ risk: "read",
3607
+ implemented: true
3608
+ },
3391
3609
  {
3392
3610
  name: "local",
3393
3611
  cost: "free \u2014 local cache",
@@ -3438,7 +3656,7 @@ var COMMANDS = [
3438
3656
  name: "share",
3439
3657
  cost: "1 call \u2014 write",
3440
3658
  summary: "Post to your own feed. Prefers LinkedIn's official OAuth scope, falls back to the private API when no token exists \u2014 the prompt always names which.",
3441
- usage: 'lnrelay share "<text>" [--image <path> ... [--alt "<text>" ...] | --video <path>\n | --document <pdf> --title "<title>"] [--at "YYYY-MM-DD HH:MM"]\n [--poll "<question>" --option "<a>" --option "<b>" ... [--duration 1d|3d|1w|2w]]\n [--visibility public|connections] [--via oauth|voyager] [--plan | --confirm <token>]\n Approval follows `lnrelay approval`: --plan previews and returns a token without\n sending; --confirm <token> sends it in agent mode. In interactive mode it asks at a\n terminal. --image repeats for up to 20, --alt pairs with it by position (--alt ""\n skips one). --at schedules it (local time, or ISO 8601 with an offset; at least 10\n minutes out); LinkedIn publishes it then, and `lnrelay delete <urn>` cancels it.\n --poll takes 2-4 --option and cannot be scheduled yet. Files, documents, polls and\n scheduling go over the private API only.',
3659
+ usage: 'lnrelay share "<text>" [--image <path> ... [--alt "<text>" ...] | --video <path>\n | --document <pdf> --title "<title>"] [--at "YYYY-MM-DD HH:MM"]\n [--poll "<question>" --option "<a>" --option "<b>" ... [--duration 1d|3d|1w|2w]]\n [--visibility public|connections] [--via oauth|voyager] [--no-card]\n [--plan | --confirm <token>]\n Approval follows `lnrelay approval`: --plan previews and returns a token without\n sending; --confirm <token> sends it in agent mode. In interactive mode it asks at a\n terminal. --image repeats for up to 20, --alt pairs with it by position (--alt ""\n skips one). --at schedules it (local time, or ISO 8601 with an offset; at least 10\n minutes out); LinkedIn publishes it then, and `lnrelay delete <urn>` cancels it.\n --poll takes 2-4 --option and cannot be scheduled yet. The first link in the text\n gets the preview card LinkedIn would show (one extra read, named in the preview);\n --no-card posts it as plain text. Files, documents, polls, cards and scheduling go\n over the private API only.',
3442
3660
  audience: ["cli"],
3443
3661
  risk: "write",
3444
3662
  implemented: true
@@ -3715,7 +3933,7 @@ function share2(confirmed, token, deps) {
3715
3933
  // src/engine/sdui-comment.ts
3716
3934
  var SDUI_ACTION2 = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
3717
3935
  var COMMENT_URL = `${SDUI_ACTION2}?sduiid=com.linkedin.sdui.comments.createComment`;
3718
- var SCREEN_ID2 = "com.linkedin.sdui.flagshipnav.feed.UpdateDetail";
3936
+ var SCREEN_ID3 = "com.linkedin.sdui.flagshipnav.feed.UpdateDetail";
3719
3937
  var STATE_PREFIXES = [
3720
3938
  "commentBoxText",
3721
3939
  "richCommentBoxText",
@@ -3806,7 +4024,7 @@ function commentBody(activityId, text2, tokens, feedType) {
3806
4024
  requestedArguments: {
3807
4025
  ...args,
3808
4026
  states: states(text2, body),
3809
- screenId: SCREEN_ID2,
4027
+ screenId: SCREEN_ID3,
3810
4028
  knownTemplateIds: []
3811
4029
  }
3812
4030
  };
@@ -3847,7 +4065,7 @@ async function comment(confirmed, client) {
3847
4065
 
3848
4066
  // src/engine/sdui-write.ts
3849
4067
  var SDUI_ACTION3 = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
3850
- var SCREEN_ID3 = "com.linkedin.sdui.flagshipnav.feed.UpdateDetail";
4068
+ var SCREEN_ID4 = "com.linkedin.sdui.flagshipnav.feed.UpdateDetail";
3851
4069
  var REACTIONS = [
3852
4070
  "LIKE",
3853
4071
  "PRAISE",
@@ -3924,7 +4142,7 @@ function sduiBody(op, target, reaction) {
3924
4142
  requestedArguments: {
3925
4143
  ...args,
3926
4144
  states: [],
3927
- screenId: SCREEN_ID3,
4145
+ screenId: SCREEN_ID4,
3928
4146
  knownTemplateIds: []
3929
4147
  }
3930
4148
  };
@@ -4216,6 +4434,7 @@ function sharePlan(p) {
4216
4434
  if (p.media !== void 0) payload.media = p.media;
4217
4435
  if (p.scheduledAt !== void 0) payload.scheduledAt = p.scheduledAt;
4218
4436
  if (p.poll !== void 0) payload.poll = p.poll;
4437
+ if (p.card !== void 0 && p.card !== null) payload.card = p.card;
4219
4438
  const scheduled = p.scheduledAt !== void 0;
4220
4439
  return {
4221
4440
  action: scheduled ? "schedule a post" : "post to your feed",
@@ -4226,12 +4445,37 @@ function sharePlan(p) {
4226
4445
  `audience ${p.visibility}`,
4227
4446
  ...p.scheduledAt === void 0 ? [] : [whenLine(p.scheduledAt, p.now)],
4228
4447
  ...p.poll === void 0 ? [] : pollLines(p.poll),
4229
- ...p.media === void 0 ? [] : mediaLines(p.media)
4448
+ ...p.media === void 0 ? [] : mediaLines(p.media),
4449
+ ...cardLines(p.card)
4230
4450
  ],
4231
4451
  reversibility: scheduled ? "cancel any time before it publishes with `lnrelay delete <urn>`; after that it is public under your name like any post" : "deletable with `lnrelay delete <urn>`, but it is public under your name the moment it lands and anyone who saw it cannot un-see it",
4232
4452
  transport: p.transport
4233
4453
  };
4234
4454
  }
4455
+ function cardLines(card) {
4456
+ if (card === void 0) return [];
4457
+ if (card === null) return ["card none \u2014 LinkedIn has no preview for this link"];
4458
+ return [`card "${card.title}" (${card.source})`];
4459
+ }
4460
+ var liveCardLookup = (url, session) => fetchLinkCard(url, createLiveClient(session));
4461
+ function shareNeeds(files, scheduledAt, poll, cardUrl) {
4462
+ const extra = (poll === void 0 ? 0 : 1) + (cardUrl === null ? 0 : 1);
4463
+ return {
4464
+ voyagerOnly: files !== void 0 || scheduledAt !== void 0 || extra > 0,
4465
+ calls: 2 * (files ?? 0) + extra + 1
4466
+ };
4467
+ }
4468
+ async function cardFor(url, transport, link) {
4469
+ if (url === null || transport.kind !== "voyager") return void 0;
4470
+ const found = await (link.lookup ?? liveCardLookup)(url, transport.session);
4471
+ if (found.ok) return found.card;
4472
+ return err(
4473
+ "share",
4474
+ found.code,
4475
+ `could not look up the card for ${url}: ${found.message}; nothing was posted`,
4476
+ "Re-run later, or add --no-card to post the link as plain text."
4477
+ );
4478
+ }
4235
4479
  function pollLines(poll) {
4236
4480
  return [
4237
4481
  `poll "${poll.question}"`,
@@ -4312,7 +4556,7 @@ function whenLine(at, now) {
4312
4556
  const away = hours < 48 ? `in ${hours} h` : `in ${Math.round(hours / 24)} days`;
4313
4557
  return `when ${local} (${zone}) \u2014 ${away}`;
4314
4558
  }
4315
- async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps(), via2, media, at, poll) {
4559
+ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps(), via2, media, at, poll, link = {}) {
4316
4560
  if (text2 === void 0 || text2.trim() === "") {
4317
4561
  return err("share", "INVALID_INPUT", "text is required", 'lnrelay share "<text>"');
4318
4562
  }
@@ -4328,14 +4572,12 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
4328
4572
  via: via2
4329
4573
  });
4330
4574
  if (pollSpec !== void 0 && "ok" in pollSpec) return pollSpec;
4331
- const voyagerOnly = loaded !== void 0 || scheduledAt !== void 0 || pollSpec !== void 0;
4332
- const ctx = prepare(
4333
- "share",
4334
- now,
4335
- voyagerOnly ? "voyager" : via2,
4336
- 2 * (loaded?.approved.length ?? 0) + (pollSpec === void 0 ? 0 : 1) + 1
4337
- );
4575
+ const cardUrl = link.card !== false && loaded === void 0 && pollSpec === void 0 && via2 !== "oauth" ? firstUrl(text2) : null;
4576
+ const needs = shareNeeds(loaded?.approved.length, scheduledAt, pollSpec, cardUrl);
4577
+ const ctx = prepare("share", now, needs.voyagerOnly ? "voyager" : via2, needs.calls);
4338
4578
  if ("ok" in ctx) return ctx;
4579
+ const card = await cardFor(cardUrl, ctx.transport, link);
4580
+ if (card !== void 0 && card !== null && "ok" in card) return card;
4339
4581
  const plan = sharePlan({
4340
4582
  author: authorLine(ctx.transport),
4341
4583
  transport: ctx.transport.kind,
@@ -4344,6 +4586,7 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
4344
4586
  media: loaded?.approved,
4345
4587
  scheduledAt,
4346
4588
  poll: pollSpec,
4589
+ ...card === void 0 ? {} : { card },
4347
4590
  now
4348
4591
  });
4349
4592
  const gated = await gate("share", plan, ctx, deps);
@@ -4734,6 +4977,8 @@ async function dispatch(argv, now) {
4734
4977
  num(args, "limit") ?? 25,
4735
4978
  output(args)
4736
4979
  );
4980
+ case "scheduled":
4981
+ return runScheduled(bool(args, "quiet"));
4737
4982
  case "sync":
4738
4983
  return runSync(args.positionals[0], num(args, "limit") ?? 50, bool(args, "force"), now);
4739
4984
  case "login":
@@ -4843,6 +5088,14 @@ function share3(args, now, deps) {
4843
5088
  return err("share", "INVALID_INPUT", `--${flag} needs a value`);
4844
5089
  }
4845
5090
  }
5091
+ if (typeof args.flags["no-card"] === "string") {
5092
+ return err(
5093
+ "share",
5094
+ "INVALID_INPUT",
5095
+ "--no-card takes no value",
5096
+ 'put the text first: lnrelay share "<text>" --no-card'
5097
+ );
5098
+ }
4846
5099
  const kinds = ["image", "video", "document"].map((flag) => ({ flag, paths: list(args, flag) })).filter((k) => k.paths.length > 0);
4847
5100
  if (kinds.length > 1) {
4848
5101
  return err(
@@ -4885,7 +5138,8 @@ function share3(args, now, deps) {
4885
5138
  surface,
4886
5139
  media,
4887
5140
  str(args, "at"),
4888
- poll
5141
+ poll,
5142
+ { card: !bool(args, "no-card") }
4889
5143
  );
4890
5144
  }
4891
5145
  export {