linkedin-relay-mcp 2.2.0 → 3.0.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.
package/dist/cli.js CHANGED
@@ -732,9 +732,19 @@ var CAPS = {
732
732
  search: { perDay: 25, provenance: "guessed", note: "no corroborated figure exists" },
733
733
  page: { perDay: 60, provenance: "guessed", note: "thread/feed pagination" },
734
734
  write: {
735
- perDay: 10,
735
+ // Raised from 10 on 2026-08-14 by the owner's explicit decision, after 10
736
+ // blocked ordinary development on a tool whose writes are the point — a
737
+ // single test round of comment, reply and two deletes exceeded a whole day.
738
+ //
739
+ // Still a GUESS, and still below the weakly-reported ~20/day connection
740
+ // lore. Nothing here has ever been measured against LinkedIn, and the
741
+ // research's strongest finding stands: cadence triggers restrictions more
742
+ // reliably than volume, and this cap does not pace anything — the client's
743
+ // jittered 3-15s gap does. Treat a raised ceiling as more room to be
744
+ // careful in, not permission to burst.
745
+ perDay: 25,
736
746
  provenance: "guessed",
737
- note: "deliberately below the weakly-reported ~20/day connection lore"
747
+ note: "raised from 10 for development; still below the ~20/day connection lore per action type"
738
748
  },
739
749
  global: { perDay: 250, provenance: "guessed", note: "all classes combined" }
740
750
  };
@@ -1739,9 +1749,6 @@ async function fetchCommentMenu(ref, trackingId, client) {
1739
1749
  const stream = result.classification.raw ?? "";
1740
1750
  return { ok: true, stream };
1741
1751
  }
1742
- function boxStateId(parent) {
1743
- return `urn:li:comment:(urn:li:${parent.threadType}:${parent.activityId},${parent.commentId})`;
1744
- }
1745
1752
  function textStates(payload, text2) {
1746
1753
  const keyOf = (...names) => {
1747
1754
  for (const n of names) {
@@ -1830,90 +1837,6 @@ function parseCommentUrn(urn) {
1830
1837
  }
1831
1838
  return null;
1832
1839
  }
1833
- var SUBMIT_COMPONENT = "com.linkedin.sdui.generated.comments.dsl.impl.submitCommentButton";
1834
- var CREATE_OP = "com.linkedin.sdui.comments.createComment";
1835
- var COMPONENT_URL = "https://www.linkedin.com/flagship-web/rsc-action/actions/component";
1836
- async function fetchReplyAction(postActivityId, parent, trackingId, client) {
1837
- const activityUrn = { activityUrn: { activityId: postActivityId } };
1838
- const body = {
1839
- clientArguments: {
1840
- payload: {
1841
- collection: {
1842
- updateKey: {
1843
- feedType: 3,
1844
- items: [{ feedUpdateUrn: { updateUrnActivityUrn: activityUrn }, trackingId }],
1845
- aggregationType: 0,
1846
- isVideoCarousel: false
1847
- },
1848
- threadUrn: { threadUrnActivityThreadUrn: activityUrn }
1849
- },
1850
- // Keying the box to the PARENT COMMENT is what makes this a reply.
1851
- commentBoxStateId: boxStateId(parent)
1852
- },
1853
- states: [],
1854
- requestMetadata: { $type: "proto.sdui.common.RequestMetadata" },
1855
- screenId: SCREEN_ID,
1856
- knownTemplateIds: []
1857
- }
1858
- };
1859
- const result = await client.request({
1860
- url: `${COMPONENT_URL}?componentId=${SUBMIT_COMPONENT}&sduiid=${SUBMIT_COMPONENT}`,
1861
- method: "POST",
1862
- body,
1863
- spendClass: "page",
1864
- operation: "replyBox"
1865
- });
1866
- if (!result.ok) return { ok: false, code: result.code, message: result.message };
1867
- const stream = result.classification.raw ?? "";
1868
- const payload = extractActionPayload(stream, CREATE_OP);
1869
- if (payload === null) {
1870
- return {
1871
- ok: false,
1872
- code: "NOT_IMPLEMENTED",
1873
- message: "the reply box did not declare a createComment action",
1874
- hint: "Replies may be closed on this post, or the component shape changed. Nothing was sent."
1875
- };
1876
- }
1877
- const bound = payload.commentFieldBinding?.key;
1878
- if (typeof bound !== "string" || !bound.includes(boxStateId(parent))) {
1879
- return {
1880
- ok: false,
1881
- code: "SCHEMA_DRIFT",
1882
- message: "the reply box came back bound to something other than the parent comment",
1883
- hint: "Refusing to send \u2014 this is how a reply becomes a top-level comment."
1884
- };
1885
- }
1886
- return { ok: true, payload };
1887
- }
1888
- async function replyToComment(postActivityId, parent, text2, trackingId, client) {
1889
- const action = await fetchReplyAction(postActivityId, parent, trackingId, client);
1890
- if (!action.ok) {
1891
- const out = { ok: false, code: action.code, message: action.message };
1892
- if (action.hint !== void 0) out.hint = action.hint;
1893
- return out;
1894
- }
1895
- const states2 = textStates(action.payload, text2);
1896
- if (states2.length === 0) {
1897
- return {
1898
- ok: false,
1899
- code: "SCHEMA_DRIFT",
1900
- message: "the reply box did not name its text bindings, so a reply cannot be built"
1901
- };
1902
- }
1903
- const result = await client.request({
1904
- url: actionUrl(CREATE_OP),
1905
- method: "POST",
1906
- body: sduiEnvelope(CREATE_OP, action.payload, states2),
1907
- spendClass: "write",
1908
- operation: "reply"
1909
- });
1910
- if (!result.ok) {
1911
- const out = { ok: false, code: result.code, message: result.message };
1912
- if (result.hint !== void 0) out.hint = result.hint;
1913
- return out;
1914
- }
1915
- return { ok: true, operation: CREATE_OP };
1916
- }
1917
1840
 
1918
1841
  // src/engine/session.ts
1919
1842
  var SESSION_FILE = "session.json";
@@ -3098,7 +3021,7 @@ var COMMANDS = [
3098
3021
  {
3099
3022
  name: "reply",
3100
3023
  cost: "1 read + 1 write",
3101
- summary: "Reply to a comment. Its own verb \u2014 a reply and a top-level comment differ only by which binding the server hands back, so guessing is not survivable.",
3024
+ summary: "Reply to a comment, nested under it. Goes over Voyager \u2014 a different endpoint from commenting, with the parent named in threadUrn.",
3102
3025
  usage: 'lnrelay reply <comment-urn> "<text>"',
3103
3026
  audience: ["cli"],
3104
3027
  risk: "write",
@@ -3581,6 +3504,43 @@ async function react(confirmed, client) {
3581
3504
  return out;
3582
3505
  }
3583
3506
 
3507
+ // src/engine/voyager-reply.ts
3508
+ var REPLY_DECORATION = "com.linkedin.voyager.dash.deco.social.NormComment-43";
3509
+ var REPLY_URL = `https://www.linkedin.com/voyager/api/voyagerSocialDashNormComments?decorationId=${REPLY_DECORATION}`;
3510
+ function parentThreadUrn(ref) {
3511
+ return `urn:li:comment:(${ref.threadType}:${ref.activityId},${ref.commentId})`;
3512
+ }
3513
+ function replyBody(ref, text2) {
3514
+ return {
3515
+ commentary: {
3516
+ text: text2,
3517
+ // The captured reply carried a profileMention, because LinkedIn's UI
3518
+ // pre-fills "@Author " into the box. We send none: an @mention notifies a
3519
+ // real person, and inventing one would put words — and a notification —
3520
+ // where the user did not ask for them.
3521
+ attributesV2: [],
3522
+ $type: "com.linkedin.voyager.dash.common.text.TextViewModel"
3523
+ },
3524
+ threadUrn: parentThreadUrn(ref)
3525
+ };
3526
+ }
3527
+ async function replyToComment(confirmed, client) {
3528
+ const { ref, text: text2 } = confirmed.payload;
3529
+ const result = await client.request({
3530
+ url: REPLY_URL,
3531
+ method: "POST",
3532
+ body: replyBody(ref, text2),
3533
+ spendClass: "write",
3534
+ operation: "reply"
3535
+ });
3536
+ if (!result.ok) {
3537
+ const out = { ok: false, code: result.code, message: result.message };
3538
+ if (result.hint !== void 0) out.hint = result.hint;
3539
+ return out;
3540
+ }
3541
+ return { ok: true, parent: parentThreadUrn(ref) };
3542
+ }
3543
+
3584
3544
  // src/commands/transport.ts
3585
3545
  var NO_CREDENTIAL_HINT = [
3586
3546
  "Two ways to write, and you need one of them:",
@@ -3897,11 +3857,9 @@ async function runReply(commentUrn, text2, now = Date.now(), deps = terminalDeps
3897
3857
  if (ctx.transport.kind !== "voyager") {
3898
3858
  return err("reply", "NOT_IMPLEMENTED", "replying is only implemented over the private API");
3899
3859
  }
3900
- const harvested = await harvest(parent.activityId, ctx.transport.session, now);
3901
- if (!("tokens" in harvested)) return harvested;
3902
3860
  const plan = {
3903
3861
  action: "reply to a comment",
3904
- payload: { parent: commentUrn, text: text2 },
3862
+ payload: { ref: parent, text: text2 },
3905
3863
  summary: [authorLine(ctx.transport), `replying to ${commentUrn}`, `content "${text2}"`],
3906
3864
  reversibility: "deletable with `lnrelay delete <the reply urn>`; the comment author is notified immediately",
3907
3865
  transport: "voyager"
@@ -3909,10 +3867,7 @@ async function runReply(commentUrn, text2, now = Date.now(), deps = terminalDeps
3909
3867
  const gated = await gate("reply", plan, ctx, deps);
3910
3868
  if ("ok" in gated) return gated;
3911
3869
  const result = await replyToComment(
3912
- parent.activityId,
3913
- parent,
3914
- text2,
3915
- harvested.tokens.trackingId,
3870
+ gated.confirmed,
3916
3871
  createLiveClient(ctx.transport.session)
3917
3872
  );
3918
3873
  return result.ok ? ok("reply", { repliedTo: commentUrn }) : err("reply", result.code, result.message, result.hint);