linkedin-relay-mcp 3.0.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 +41 -96
- 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";
|
|
@@ -3108,11 +3021,11 @@ var COMMANDS = [
|
|
|
3108
3021
|
{
|
|
3109
3022
|
name: "reply",
|
|
3110
3023
|
cost: "1 read + 1 write",
|
|
3111
|
-
summary: "Reply to a comment
|
|
3024
|
+
summary: "Reply to a comment, nested under it. Goes over Voyager \u2014 a different endpoint from commenting, with the parent named in threadUrn.",
|
|
3112
3025
|
usage: 'lnrelay reply <comment-urn> "<text>"',
|
|
3113
3026
|
audience: ["cli"],
|
|
3114
3027
|
risk: "write",
|
|
3115
|
-
implemented:
|
|
3028
|
+
implemented: true
|
|
3116
3029
|
},
|
|
3117
3030
|
{
|
|
3118
3031
|
name: "edit",
|
|
@@ -3591,6 +3504,43 @@ async function react(confirmed, client) {
|
|
|
3591
3504
|
return out;
|
|
3592
3505
|
}
|
|
3593
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
|
+
|
|
3594
3544
|
// src/commands/transport.ts
|
|
3595
3545
|
var NO_CREDENTIAL_HINT = [
|
|
3596
3546
|
"Two ways to write, and you need one of them:",
|
|
@@ -3907,11 +3857,9 @@ async function runReply(commentUrn, text2, now = Date.now(), deps = terminalDeps
|
|
|
3907
3857
|
if (ctx.transport.kind !== "voyager") {
|
|
3908
3858
|
return err("reply", "NOT_IMPLEMENTED", "replying is only implemented over the private API");
|
|
3909
3859
|
}
|
|
3910
|
-
const harvested = await harvest(parent.activityId, ctx.transport.session, now);
|
|
3911
|
-
if (!("tokens" in harvested)) return harvested;
|
|
3912
3860
|
const plan = {
|
|
3913
3861
|
action: "reply to a comment",
|
|
3914
|
-
payload: {
|
|
3862
|
+
payload: { ref: parent, text: text2 },
|
|
3915
3863
|
summary: [authorLine(ctx.transport), `replying to ${commentUrn}`, `content "${text2}"`],
|
|
3916
3864
|
reversibility: "deletable with `lnrelay delete <the reply urn>`; the comment author is notified immediately",
|
|
3917
3865
|
transport: "voyager"
|
|
@@ -3919,10 +3867,7 @@ async function runReply(commentUrn, text2, now = Date.now(), deps = terminalDeps
|
|
|
3919
3867
|
const gated = await gate("reply", plan, ctx, deps);
|
|
3920
3868
|
if ("ok" in gated) return gated;
|
|
3921
3869
|
const result = await replyToComment(
|
|
3922
|
-
|
|
3923
|
-
parent,
|
|
3924
|
-
text2,
|
|
3925
|
-
harvested.tokens.trackingId,
|
|
3870
|
+
gated.confirmed,
|
|
3926
3871
|
createLiveClient(ctx.transport.session)
|
|
3927
3872
|
);
|
|
3928
3873
|
return result.ok ? ok("reply", { repliedTo: commentUrn }) : err("reply", result.code, result.message, result.hint);
|