linkedin-relay-mcp 3.0.0 → 3.0.2
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 +44 -97
- package/dist/cli.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp-shim.js +2 -2
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1749,9 +1749,6 @@ async function fetchCommentMenu(ref, trackingId, client) {
|
|
|
1749
1749
|
const stream = result.classification.raw ?? "";
|
|
1750
1750
|
return { ok: true, stream };
|
|
1751
1751
|
}
|
|
1752
|
-
function boxStateId(parent) {
|
|
1753
|
-
return `urn:li:comment:(urn:li:${parent.threadType}:${parent.activityId},${parent.commentId})`;
|
|
1754
|
-
}
|
|
1755
1752
|
function textStates(payload, text2) {
|
|
1756
1753
|
const keyOf = (...names) => {
|
|
1757
1754
|
for (const n of names) {
|
|
@@ -1840,90 +1837,6 @@ function parseCommentUrn(urn) {
|
|
|
1840
1837
|
}
|
|
1841
1838
|
return null;
|
|
1842
1839
|
}
|
|
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
|
-
}
|
|
1927
1840
|
|
|
1928
1841
|
// src/engine/session.ts
|
|
1929
1842
|
var SESSION_FILE = "session.json";
|
|
@@ -2269,7 +2182,8 @@ async function deleteComment(ref, urn, now, deps) {
|
|
|
2269
2182
|
action: "delete your comment",
|
|
2270
2183
|
payload: { urn },
|
|
2271
2184
|
summary: [`comment ${urn}`, `on post urn:li:activity:${ref.activityId}`],
|
|
2272
|
-
|
|
2185
|
+
// Verified live: deleting a parent took its three nested replies with it.
|
|
2186
|
+
reversibility: "NONE. A deleted comment is gone \u2014 AND SO IS EVERY REPLY UNDER IT, including other people's. Verified live.",
|
|
2273
2187
|
transport: "voyager"
|
|
2274
2188
|
};
|
|
2275
2189
|
const gated = await gateWrite("delete", plan, now, deps, { commitSpend: false });
|
|
@@ -3108,11 +3022,11 @@ var COMMANDS = [
|
|
|
3108
3022
|
{
|
|
3109
3023
|
name: "reply",
|
|
3110
3024
|
cost: "1 read + 1 write",
|
|
3111
|
-
summary: "Reply to a comment
|
|
3025
|
+
summary: "Reply to a comment, nested under it. Goes over Voyager \u2014 a different endpoint from commenting, with the parent named in threadUrn.",
|
|
3112
3026
|
usage: 'lnrelay reply <comment-urn> "<text>"',
|
|
3113
3027
|
audience: ["cli"],
|
|
3114
3028
|
risk: "write",
|
|
3115
|
-
implemented:
|
|
3029
|
+
implemented: true
|
|
3116
3030
|
},
|
|
3117
3031
|
{
|
|
3118
3032
|
name: "edit",
|
|
@@ -3591,6 +3505,44 @@ async function react(confirmed, client) {
|
|
|
3591
3505
|
return out;
|
|
3592
3506
|
}
|
|
3593
3507
|
|
|
3508
|
+
// src/engine/voyager-reply.ts
|
|
3509
|
+
var REPLY_DECORATION = "com.linkedin.voyager.dash.deco.social.NormComment-43";
|
|
3510
|
+
var REPLY_URL = `https://www.linkedin.com/voyager/api/voyagerSocialDashNormComments?decorationId=${REPLY_DECORATION}`;
|
|
3511
|
+
function parentThreadUrn(ref) {
|
|
3512
|
+
return `urn:li:comment:(${ref.threadType}:${ref.activityId},${ref.commentId})`;
|
|
3513
|
+
}
|
|
3514
|
+
function replyBody(ref, text2) {
|
|
3515
|
+
return {
|
|
3516
|
+
commentary: {
|
|
3517
|
+
text: text2,
|
|
3518
|
+
// The captured reply carried a profileMention, because LinkedIn's UI
|
|
3519
|
+
// pre-fills "@Author " into the box. We send none: an @mention notifies a
|
|
3520
|
+
// real person, and inventing one would put words — and a notification —
|
|
3521
|
+
// where the user did not ask for them.
|
|
3522
|
+
attributesV2: [],
|
|
3523
|
+
$type: "com.linkedin.voyager.dash.common.text.TextViewModel"
|
|
3524
|
+
},
|
|
3525
|
+
threadUrn: parentThreadUrn(ref)
|
|
3526
|
+
};
|
|
3527
|
+
}
|
|
3528
|
+
async function replyToComment(confirmed, client) {
|
|
3529
|
+
const { ref, text: text2 } = confirmed.payload;
|
|
3530
|
+
const result = await client.request({
|
|
3531
|
+
url: REPLY_URL,
|
|
3532
|
+
method: "POST",
|
|
3533
|
+
body: replyBody(ref, text2),
|
|
3534
|
+
spendClass: "write",
|
|
3535
|
+
operation: "reply"
|
|
3536
|
+
});
|
|
3537
|
+
if (!result.ok) {
|
|
3538
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
3539
|
+
out.hint = /5\d\d|unexpected status/.test(result.message) ? "DO NOT RETRY BLINDLY. This endpoint has been observed returning 5xx after the reply was already created. Check the thread on LinkedIn before sending again." : result.hint ?? "";
|
|
3540
|
+
if (out.hint === "") delete out.hint;
|
|
3541
|
+
return out;
|
|
3542
|
+
}
|
|
3543
|
+
return { ok: true, parent: parentThreadUrn(ref) };
|
|
3544
|
+
}
|
|
3545
|
+
|
|
3594
3546
|
// src/commands/transport.ts
|
|
3595
3547
|
var NO_CREDENTIAL_HINT = [
|
|
3596
3548
|
"Two ways to write, and you need one of them:",
|
|
@@ -3907,11 +3859,9 @@ async function runReply(commentUrn, text2, now = Date.now(), deps = terminalDeps
|
|
|
3907
3859
|
if (ctx.transport.kind !== "voyager") {
|
|
3908
3860
|
return err("reply", "NOT_IMPLEMENTED", "replying is only implemented over the private API");
|
|
3909
3861
|
}
|
|
3910
|
-
const harvested = await harvest(parent.activityId, ctx.transport.session, now);
|
|
3911
|
-
if (!("tokens" in harvested)) return harvested;
|
|
3912
3862
|
const plan = {
|
|
3913
3863
|
action: "reply to a comment",
|
|
3914
|
-
payload: {
|
|
3864
|
+
payload: { ref: parent, text: text2 },
|
|
3915
3865
|
summary: [authorLine(ctx.transport), `replying to ${commentUrn}`, `content "${text2}"`],
|
|
3916
3866
|
reversibility: "deletable with `lnrelay delete <the reply urn>`; the comment author is notified immediately",
|
|
3917
3867
|
transport: "voyager"
|
|
@@ -3919,10 +3869,7 @@ async function runReply(commentUrn, text2, now = Date.now(), deps = terminalDeps
|
|
|
3919
3869
|
const gated = await gate("reply", plan, ctx, deps);
|
|
3920
3870
|
if ("ok" in gated) return gated;
|
|
3921
3871
|
const result = await replyToComment(
|
|
3922
|
-
|
|
3923
|
-
parent,
|
|
3924
|
-
text2,
|
|
3925
|
-
harvested.tokens.trackingId,
|
|
3872
|
+
gated.confirmed,
|
|
3926
3873
|
createLiveClient(ctx.transport.session)
|
|
3927
3874
|
);
|
|
3928
3875
|
return result.ok ? ok("reply", { repliedTo: commentUrn }) : err("reply", result.code, result.message, result.hint);
|