linkedin-relay-mcp 2.1.0 → 3.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/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,6 +1749,9 @@ async function fetchCommentMenu(ref, trackingId, client) {
1739
1749
  const stream = result.classification.raw ?? "";
1740
1750
  return { ok: true, stream };
1741
1751
  }
1752
+ function boxStateId(parent) {
1753
+ return `urn:li:comment:(urn:li:${parent.threadType}:${parent.activityId},${parent.commentId})`;
1754
+ }
1742
1755
  function textStates(payload, text2) {
1743
1756
  const keyOf = (...names) => {
1744
1757
  for (const n of names) {
@@ -1827,6 +1840,90 @@ function parseCommentUrn(urn) {
1827
1840
  }
1828
1841
  return null;
1829
1842
  }
1843
+ var SUBMIT_COMPONENT = "com.linkedin.sdui.generated.comments.dsl.impl.submitCommentButton";
1844
+ var CREATE_OP = "com.linkedin.sdui.comments.createComment";
1845
+ var COMPONENT_URL = "https://www.linkedin.com/flagship-web/rsc-action/actions/component";
1846
+ async function fetchReplyAction(postActivityId, parent, trackingId, client) {
1847
+ const activityUrn = { activityUrn: { activityId: postActivityId } };
1848
+ const body = {
1849
+ clientArguments: {
1850
+ payload: {
1851
+ collection: {
1852
+ updateKey: {
1853
+ feedType: 3,
1854
+ items: [{ feedUpdateUrn: { updateUrnActivityUrn: activityUrn }, trackingId }],
1855
+ aggregationType: 0,
1856
+ isVideoCarousel: false
1857
+ },
1858
+ threadUrn: { threadUrnActivityThreadUrn: activityUrn }
1859
+ },
1860
+ // Keying the box to the PARENT COMMENT is what makes this a reply.
1861
+ commentBoxStateId: boxStateId(parent)
1862
+ },
1863
+ states: [],
1864
+ requestMetadata: { $type: "proto.sdui.common.RequestMetadata" },
1865
+ screenId: SCREEN_ID,
1866
+ knownTemplateIds: []
1867
+ }
1868
+ };
1869
+ const result = await client.request({
1870
+ url: `${COMPONENT_URL}?componentId=${SUBMIT_COMPONENT}&sduiid=${SUBMIT_COMPONENT}`,
1871
+ method: "POST",
1872
+ body,
1873
+ spendClass: "page",
1874
+ operation: "replyBox"
1875
+ });
1876
+ if (!result.ok) return { ok: false, code: result.code, message: result.message };
1877
+ const stream = result.classification.raw ?? "";
1878
+ const payload = extractActionPayload(stream, CREATE_OP);
1879
+ if (payload === null) {
1880
+ return {
1881
+ ok: false,
1882
+ code: "NOT_IMPLEMENTED",
1883
+ message: "the reply box did not declare a createComment action",
1884
+ hint: "Replies may be closed on this post, or the component shape changed. Nothing was sent."
1885
+ };
1886
+ }
1887
+ const bound = payload.commentFieldBinding?.key;
1888
+ if (typeof bound !== "string" || !bound.includes(boxStateId(parent))) {
1889
+ return {
1890
+ ok: false,
1891
+ code: "SCHEMA_DRIFT",
1892
+ message: "the reply box came back bound to something other than the parent comment",
1893
+ hint: "Refusing to send \u2014 this is how a reply becomes a top-level comment."
1894
+ };
1895
+ }
1896
+ return { ok: true, payload };
1897
+ }
1898
+ async function replyToComment(postActivityId, parent, text2, trackingId, client) {
1899
+ const action = await fetchReplyAction(postActivityId, parent, trackingId, client);
1900
+ if (!action.ok) {
1901
+ const out = { ok: false, code: action.code, message: action.message };
1902
+ if (action.hint !== void 0) out.hint = action.hint;
1903
+ return out;
1904
+ }
1905
+ const states2 = textStates(action.payload, text2);
1906
+ if (states2.length === 0) {
1907
+ return {
1908
+ ok: false,
1909
+ code: "SCHEMA_DRIFT",
1910
+ message: "the reply box did not name its text bindings, so a reply cannot be built"
1911
+ };
1912
+ }
1913
+ const result = await client.request({
1914
+ url: actionUrl(CREATE_OP),
1915
+ method: "POST",
1916
+ body: sduiEnvelope(CREATE_OP, action.payload, states2),
1917
+ spendClass: "write",
1918
+ operation: "reply"
1919
+ });
1920
+ if (!result.ok) {
1921
+ const out = { ok: false, code: result.code, message: result.message };
1922
+ if (result.hint !== void 0) out.hint = result.hint;
1923
+ return out;
1924
+ }
1925
+ return { ok: true, operation: CREATE_OP };
1926
+ }
1830
1927
 
1831
1928
  // src/engine/session.ts
1832
1929
  var SESSION_FILE = "session.json";
@@ -3008,6 +3105,15 @@ var COMMANDS = [
3008
3105
  risk: "write",
3009
3106
  implemented: true
3010
3107
  },
3108
+ {
3109
+ name: "reply",
3110
+ cost: "1 read + 1 write",
3111
+ summary: "Reply to a comment. WITHDRAWN \u2014 the implementation posted a top-level comment instead of a nested reply. Refuses until that is actually solved.",
3112
+ usage: 'lnrelay reply <comment-urn> "<text>"',
3113
+ audience: ["cli"],
3114
+ risk: "write",
3115
+ implemented: false
3116
+ },
3011
3117
  {
3012
3118
  name: "edit",
3013
3119
  cost: "1 read + 1 write",
@@ -3636,7 +3742,7 @@ async function runComment(postUrn2, text2, now = Date.now(), deps = terminalDeps
3636
3742
  "comment",
3637
3743
  "INVALID_INPUT",
3638
3744
  "that is a comment urn, not a post urn",
3639
- `To change its text: lnrelay edit ${postUrn2} "<text>". Replying to a comment is not implemented \u2014 pass the POST urn to add a top-level comment.`
3745
+ `To change its text: lnrelay edit ${postUrn2} "<text>". To answer it: lnrelay reply ${postUrn2} "<text>". Pass the POST urn to add a top-level comment.`
3640
3746
  );
3641
3747
  }
3642
3748
  const activityId = activityIdOf(postUrn2);
@@ -3770,6 +3876,57 @@ async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps(),
3770
3876
  const result = await react(gated.confirmed, createLiveClient(ctx.transport.session));
3771
3877
  return result.ok ? ok("react", { id: result.id, removed: remove }) : err("react", result.code, result.message, result.hint);
3772
3878
  }
3879
+ async function runReply(commentUrn, text2, now = Date.now(), deps = terminalDeps()) {
3880
+ if (commentUrn === void 0 || text2 === void 0 || text2.trim() === "") {
3881
+ return err(
3882
+ "reply",
3883
+ "INVALID_INPUT",
3884
+ "a comment urn and the reply text are required",
3885
+ 'lnrelay reply <comment-urn> "<text>"'
3886
+ );
3887
+ }
3888
+ const parent = parseCommentUrn(commentUrn);
3889
+ if (parent === null) {
3890
+ return err(
3891
+ "reply",
3892
+ "INVALID_INPUT",
3893
+ `'${commentUrn}' is not a comment urn`,
3894
+ "To comment on a POST, use `lnrelay comment <activity-urn>`. Comment urns come from `lnrelay post <activity-urn>`."
3895
+ );
3896
+ }
3897
+ if (!deps.isTty) {
3898
+ return err(
3899
+ "reply",
3900
+ "CONFIRMATION_REQUIRED",
3901
+ "replying needs a human to confirm it at an interactive terminal",
3902
+ "No terminal is attached, so nothing was sent and no network call was made."
3903
+ );
3904
+ }
3905
+ const ctx = prepare("reply", now, "voyager");
3906
+ if ("ok" in ctx) return ctx;
3907
+ if (ctx.transport.kind !== "voyager") {
3908
+ return err("reply", "NOT_IMPLEMENTED", "replying is only implemented over the private API");
3909
+ }
3910
+ const harvested = await harvest(parent.activityId, ctx.transport.session, now);
3911
+ if (!("tokens" in harvested)) return harvested;
3912
+ const plan = {
3913
+ action: "reply to a comment",
3914
+ payload: { parent: commentUrn, text: text2 },
3915
+ summary: [authorLine(ctx.transport), `replying to ${commentUrn}`, `content "${text2}"`],
3916
+ reversibility: "deletable with `lnrelay delete <the reply urn>`; the comment author is notified immediately",
3917
+ transport: "voyager"
3918
+ };
3919
+ const gated = await gate("reply", plan, ctx, deps);
3920
+ if ("ok" in gated) return gated;
3921
+ const result = await replyToComment(
3922
+ parent.activityId,
3923
+ parent,
3924
+ text2,
3925
+ harvested.tokens.trackingId,
3926
+ createLiveClient(ctx.transport.session)
3927
+ );
3928
+ return result.ok ? ok("reply", { repliedTo: commentUrn }) : err("reply", result.code, result.message, result.hint);
3929
+ }
3773
3930
 
3774
3931
  // src/entry.ts
3775
3932
  import { realpathSync } from "fs";
@@ -3927,6 +4084,8 @@ async function dispatch(argv, now) {
3927
4084
  return runComment(args.positionals[0], args.positionals[1], now);
3928
4085
  case "edit":
3929
4086
  return runEdit(args.positionals[0], args.positionals[1], now);
4087
+ case "reply":
4088
+ return runReply(args.positionals[0], args.positionals[1], now);
3930
4089
  case "react":
3931
4090
  return runReact(
3932
4091
  args.positionals[0],