linkedin-relay-mcp 1.2.2 → 1.3.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 +125 -30
- package/dist/cli.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp-shim.js +3 -3
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2636,7 +2636,7 @@ var COMMANDS = [
|
|
|
2636
2636
|
{
|
|
2637
2637
|
name: "comment",
|
|
2638
2638
|
cost: "1 call \u2014 write",
|
|
2639
|
-
summary: "Comment on a post
|
|
2639
|
+
summary: "Comment on a post. OAuth only \u2014 see the hint; not replayable over the private API.",
|
|
2640
2640
|
usage: 'lnrelay comment <activity-urn> "<text>"',
|
|
2641
2641
|
audience: ["cli"],
|
|
2642
2642
|
risk: "write",
|
|
@@ -2654,8 +2654,8 @@ var COMMANDS = [
|
|
|
2654
2654
|
{
|
|
2655
2655
|
name: "react",
|
|
2656
2656
|
cost: "1 call \u2014 write",
|
|
2657
|
-
summary: "React to a post
|
|
2658
|
-
usage: "lnrelay react <activity-urn> [--type LIKE|PRAISE|EMPATHY|INTEREST|APPRECIATION]",
|
|
2657
|
+
summary: "React to a post or comment, over LinkedIn's SDUI surface. Reversible with --remove.",
|
|
2658
|
+
usage: "lnrelay react <activity-urn | comment-urn> [--type LIKE|PRAISE|EMPATHY|INTEREST|APPRECIATION|ENTERTAINMENT]\n lnrelay react <urn> --remove # take the reaction back",
|
|
2659
2659
|
audience: ["cli"],
|
|
2660
2660
|
risk: "write",
|
|
2661
2661
|
implemented: true
|
|
@@ -2892,14 +2892,101 @@ function comment(confirmed, token, deps) {
|
|
|
2892
2892
|
deps
|
|
2893
2893
|
);
|
|
2894
2894
|
}
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2895
|
+
|
|
2896
|
+
// src/engine/sdui-write.ts
|
|
2897
|
+
var SDUI_ACTION = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
|
|
2898
|
+
var SCREEN_ID = "com.linkedin.sdui.flagshipnav.feed.UpdateDetail";
|
|
2899
|
+
var REACTIONS = [
|
|
2900
|
+
"LIKE",
|
|
2901
|
+
"PRAISE",
|
|
2902
|
+
"EMPATHY",
|
|
2903
|
+
"INTEREST",
|
|
2904
|
+
"APPRECIATION",
|
|
2905
|
+
"ENTERTAINMENT"
|
|
2906
|
+
];
|
|
2907
|
+
function reactionUrl(op) {
|
|
2908
|
+
return `${SDUI_ACTION}?sduiid=com.linkedin.sdui.reactions.${op}`;
|
|
2909
|
+
}
|
|
2910
|
+
function targetFor(urn) {
|
|
2911
|
+
const comment2 = /^urn:li:comment:\((urn:li:activity:\d+),(\d+)\)$/.exec(urn);
|
|
2912
|
+
if (comment2 !== null) {
|
|
2913
|
+
return {
|
|
2914
|
+
threadUrn: {
|
|
2915
|
+
threadUrnCommentThreadUrn: {
|
|
2916
|
+
commentUrn: { commentId: comment2[2], thread: comment2[1] }
|
|
2917
|
+
}
|
|
2918
|
+
},
|
|
2919
|
+
reactionSource: "Comment"
|
|
2920
|
+
};
|
|
2921
|
+
}
|
|
2922
|
+
const activity = /^urn:li:(?:activity|ugcPost|share):(\d+)$/.exec(urn);
|
|
2923
|
+
if (activity !== null) {
|
|
2924
|
+
return {
|
|
2925
|
+
threadUrn: {
|
|
2926
|
+
threadUrnActivityThreadUrn: { activityUrn: { activityId: activity[1] } }
|
|
2927
|
+
},
|
|
2928
|
+
reactionSource: "Update"
|
|
2929
|
+
};
|
|
2930
|
+
}
|
|
2931
|
+
throw new Error(
|
|
2932
|
+
`'${urn}' does not identify a post or a comment \u2014 expected urn:li:activity:<id> or urn:li:comment:(urn:li:activity:<id>,<id>)`
|
|
2901
2933
|
);
|
|
2902
2934
|
}
|
|
2935
|
+
function reactionPayload(target, reaction) {
|
|
2936
|
+
return {
|
|
2937
|
+
threadUrn: target.threadUrn,
|
|
2938
|
+
reactionType: `ReactionType_${reaction}`,
|
|
2939
|
+
reactionSource: target.reactionSource
|
|
2940
|
+
};
|
|
2941
|
+
}
|
|
2942
|
+
function sduiBody(op, target, reaction) {
|
|
2943
|
+
const requestId = `com.linkedin.sdui.reactions.${op}`;
|
|
2944
|
+
const payload = reactionPayload(target, reaction);
|
|
2945
|
+
const args = {
|
|
2946
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
2947
|
+
requestedStateKeys: [],
|
|
2948
|
+
payload,
|
|
2949
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
2950
|
+
};
|
|
2951
|
+
return {
|
|
2952
|
+
requestId,
|
|
2953
|
+
serverRequest: {
|
|
2954
|
+
requestId,
|
|
2955
|
+
requestedArguments: args,
|
|
2956
|
+
isApfcEnabled: false,
|
|
2957
|
+
isStreaming: false,
|
|
2958
|
+
rumPageKey: ""
|
|
2959
|
+
},
|
|
2960
|
+
states: [],
|
|
2961
|
+
requestedArguments: {
|
|
2962
|
+
...args,
|
|
2963
|
+
states: [],
|
|
2964
|
+
screenId: SCREEN_ID,
|
|
2965
|
+
knownTemplateIds: []
|
|
2966
|
+
}
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2969
|
+
async function react(confirmed, client) {
|
|
2970
|
+
const { urn, type, remove } = confirmed.payload;
|
|
2971
|
+
let target;
|
|
2972
|
+
try {
|
|
2973
|
+
target = targetFor(urn);
|
|
2974
|
+
} catch (e) {
|
|
2975
|
+
return { ok: false, code: "INVALID_INPUT", message: e.message };
|
|
2976
|
+
}
|
|
2977
|
+
const op = remove ? "delete" : "create";
|
|
2978
|
+
const result = await client.request({
|
|
2979
|
+
url: reactionUrl(op),
|
|
2980
|
+
method: "POST",
|
|
2981
|
+
body: sduiBody(op, target, type),
|
|
2982
|
+
spendClass: "write",
|
|
2983
|
+
operation: `reaction.${op}`
|
|
2984
|
+
});
|
|
2985
|
+
if (result.ok) return { ok: true, id: urn };
|
|
2986
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
2987
|
+
out.hint = result.hint ?? "This surface was captured from the live client but has never been replayed by this tool. If it refuses, the first thing to try is sending `x-li-page-instance` and `x-li-track`, which the browser sends here and which our verified read header set deliberately omits.";
|
|
2988
|
+
return out;
|
|
2989
|
+
}
|
|
2903
2990
|
|
|
2904
2991
|
// src/commands/transport.ts
|
|
2905
2992
|
var NO_CREDENTIAL_HINT = [
|
|
@@ -2986,7 +3073,7 @@ function requireOauth(command, ctx) {
|
|
|
2986
3073
|
command,
|
|
2987
3074
|
"NOT_IMPLEMENTED",
|
|
2988
3075
|
`'${command}' is not implemented over the private API`,
|
|
2989
|
-
|
|
3076
|
+
"Commenting was captured from the live client on 2026-08-13 and is NOT replayable as a single request: com.linkedin.sdui.comments.createComment carries a trackingId from the feed render and an opaque binding key that only exists once a page has been rendered. Reaching it means fetching the SDUI screen first to harvest both. `share`, `delete` and `react` work over the private API. See docs/research/W5-sdui-writes.md."
|
|
2990
3077
|
);
|
|
2991
3078
|
}
|
|
2992
3079
|
async function gate(command, plan, ctx, deps) {
|
|
@@ -3050,43 +3137,45 @@ async function runComment(postUrn2, text2, now = Date.now(), deps = terminalDeps
|
|
|
3050
3137
|
});
|
|
3051
3138
|
return result.ok ? ok("comment", { id: result.id }) : err("comment", result.code, result.message, result.hint);
|
|
3052
3139
|
}
|
|
3053
|
-
var
|
|
3054
|
-
async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps()) {
|
|
3140
|
+
var REACTIONS2 = REACTIONS;
|
|
3141
|
+
async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps(), remove = false) {
|
|
3055
3142
|
const reaction = type.toUpperCase();
|
|
3056
3143
|
if (postUrn2 === void 0) {
|
|
3057
3144
|
return err(
|
|
3058
3145
|
"react",
|
|
3059
3146
|
"INVALID_INPUT",
|
|
3060
|
-
"a post urn is required",
|
|
3061
|
-
"lnrelay react <urn> [--type LIKE]"
|
|
3147
|
+
"a post or comment urn is required",
|
|
3148
|
+
"lnrelay react <urn> [--type LIKE] [--remove]"
|
|
3062
3149
|
);
|
|
3063
3150
|
}
|
|
3064
|
-
if (!
|
|
3151
|
+
if (!REACTIONS2.includes(reaction)) {
|
|
3065
3152
|
return err(
|
|
3066
3153
|
"react",
|
|
3067
3154
|
"INVALID_INPUT",
|
|
3068
3155
|
`unknown reaction '${type}'`,
|
|
3069
|
-
`one of: ${
|
|
3156
|
+
`one of: ${REACTIONS2.join(", ")}`
|
|
3070
3157
|
);
|
|
3071
3158
|
}
|
|
3072
|
-
const ctx = prepare("react", now);
|
|
3159
|
+
const ctx = prepare("react", now, "voyager");
|
|
3073
3160
|
if ("ok" in ctx) return ctx;
|
|
3074
|
-
|
|
3075
|
-
|
|
3161
|
+
if (ctx.transport.kind !== "voyager") {
|
|
3162
|
+
return err("react", "NOT_IMPLEMENTED", "reacting is only implemented over the private API");
|
|
3163
|
+
}
|
|
3076
3164
|
const plan = {
|
|
3077
|
-
action: "react to a post",
|
|
3078
|
-
payload: {
|
|
3079
|
-
summary: [
|
|
3080
|
-
|
|
3081
|
-
|
|
3165
|
+
action: remove ? "remove a reaction" : "react to a post",
|
|
3166
|
+
payload: { urn: postUrn2, type: reaction, remove },
|
|
3167
|
+
summary: [
|
|
3168
|
+
authorLine(ctx.transport),
|
|
3169
|
+
`on ${postUrn2}`,
|
|
3170
|
+
`reaction ${remove ? `${reaction} (REMOVING)` : reaction}`
|
|
3171
|
+
],
|
|
3172
|
+
reversibility: remove ? "you can react again; the author may have been notified the first time" : "removable with `lnrelay react <urn> --remove`; the author is notified immediately",
|
|
3173
|
+
transport: "voyager"
|
|
3082
3174
|
};
|
|
3083
3175
|
const gated = await gate("react", plan, ctx, deps);
|
|
3084
3176
|
if ("ok" in gated) return gated;
|
|
3085
|
-
const result = await react(gated.confirmed,
|
|
3086
|
-
|
|
3087
|
-
now: () => now
|
|
3088
|
-
});
|
|
3089
|
-
return result.ok ? ok("react", { id: result.id }) : err("react", result.code, result.message, result.hint);
|
|
3177
|
+
const result = await react(gated.confirmed, createLiveClient(ctx.transport.session));
|
|
3178
|
+
return result.ok ? ok("react", { id: result.id, removed: remove }) : err("react", result.code, result.message, result.hint);
|
|
3090
3179
|
}
|
|
3091
3180
|
|
|
3092
3181
|
// src/entry.ts
|
|
@@ -3244,7 +3333,13 @@ async function dispatch(argv, now) {
|
|
|
3244
3333
|
case "comment":
|
|
3245
3334
|
return runComment(args.positionals[0], args.positionals[1], now);
|
|
3246
3335
|
case "react":
|
|
3247
|
-
return runReact(
|
|
3336
|
+
return runReact(
|
|
3337
|
+
args.positionals[0],
|
|
3338
|
+
str(args, "type") ?? "LIKE",
|
|
3339
|
+
now,
|
|
3340
|
+
void 0,
|
|
3341
|
+
bool(args, "remove")
|
|
3342
|
+
);
|
|
3248
3343
|
case "delete":
|
|
3249
3344
|
return runDelete(args.positionals[0], now, void 0, bool(args, "quiet"));
|
|
3250
3345
|
case "whoami":
|