linkedin-relay-mcp 1.2.3 → 1.3.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 +157 -38
- 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 +24 -11
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -836,13 +836,16 @@ function classifyRedirect(location) {
|
|
|
836
836
|
}
|
|
837
837
|
return fail("FETCH_FAILED", `unexpected redirect to ${location || "(none)"}`);
|
|
838
838
|
}
|
|
839
|
+
function challengeIn(body) {
|
|
840
|
+
if (!CHALLENGE_MARKERS.test(body.slice(0, 4e3))) return null;
|
|
841
|
+
return fail("CHALLENGE_DETECTED", "a challenge page was returned with status 200", {
|
|
842
|
+
cooldown: "CHALLENGE_DETECTED",
|
|
843
|
+
hint: CHALLENGE_HINT
|
|
844
|
+
});
|
|
845
|
+
}
|
|
839
846
|
function classifyBody(body) {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
cooldown: "CHALLENGE_DETECTED",
|
|
843
|
-
hint: CHALLENGE_HINT
|
|
844
|
-
});
|
|
845
|
-
}
|
|
847
|
+
const challenge = challengeIn(body);
|
|
848
|
+
if (challenge !== null) return challenge;
|
|
846
849
|
let json;
|
|
847
850
|
try {
|
|
848
851
|
json = JSON.parse(body);
|
|
@@ -865,7 +868,7 @@ function classifyBody(body) {
|
|
|
865
868
|
}
|
|
866
869
|
return { outcome: "ok", retry: false, json };
|
|
867
870
|
}
|
|
868
|
-
function classify(res) {
|
|
871
|
+
function classify(res, opts = {}) {
|
|
869
872
|
const headers2 = res.headers ?? {};
|
|
870
873
|
if (res.status >= 300 && res.status < 400) {
|
|
871
874
|
return classifyRedirect(headers2.location ?? "");
|
|
@@ -906,6 +909,15 @@ function classify(res) {
|
|
|
906
909
|
return fail("FETCH_FAILED", `unexpected status ${res.status}`);
|
|
907
910
|
}
|
|
908
911
|
if (res.body.trim() === "") return { outcome: "ok", retry: false, json: null };
|
|
912
|
+
const challenge = challengeIn(res.body);
|
|
913
|
+
if (challenge !== null) return challenge;
|
|
914
|
+
if (opts.expectJson === false) {
|
|
915
|
+
try {
|
|
916
|
+
return { outcome: "ok", retry: false, json: JSON.parse(res.body) };
|
|
917
|
+
} catch {
|
|
918
|
+
return { outcome: "ok", retry: false, json: null };
|
|
919
|
+
}
|
|
920
|
+
}
|
|
909
921
|
return classifyBody(res.body);
|
|
910
922
|
}
|
|
911
923
|
function referencesUrns(data) {
|
|
@@ -967,7 +979,8 @@ function createClient(session, deps) {
|
|
|
967
979
|
if (raw === null) {
|
|
968
980
|
return { ok: false, code: "FETCH_FAILED", message: "the request could not be completed" };
|
|
969
981
|
}
|
|
970
|
-
const
|
|
982
|
+
const isRead = (spec.method ?? "GET") === "GET";
|
|
983
|
+
const classification = classify(raw, { expectJson: isRead });
|
|
971
984
|
if (classification.cooldown !== void 0) {
|
|
972
985
|
deps.saveCooldown(openCooldown(classification.cooldown, deps.now()));
|
|
973
986
|
}
|
|
@@ -2636,7 +2649,7 @@ var COMMANDS = [
|
|
|
2636
2649
|
{
|
|
2637
2650
|
name: "comment",
|
|
2638
2651
|
cost: "1 call \u2014 write",
|
|
2639
|
-
summary: "Comment on a post
|
|
2652
|
+
summary: "Comment on a post. OAuth only \u2014 see the hint; not replayable over the private API.",
|
|
2640
2653
|
usage: 'lnrelay comment <activity-urn> "<text>"',
|
|
2641
2654
|
audience: ["cli"],
|
|
2642
2655
|
risk: "write",
|
|
@@ -2654,8 +2667,8 @@ var COMMANDS = [
|
|
|
2654
2667
|
{
|
|
2655
2668
|
name: "react",
|
|
2656
2669
|
cost: "1 call \u2014 write",
|
|
2657
|
-
summary: "React to a post
|
|
2658
|
-
usage: "lnrelay react <activity-urn> [--type LIKE|PRAISE|EMPATHY|INTEREST|APPRECIATION]",
|
|
2670
|
+
summary: "React to a post or comment, over LinkedIn's SDUI surface. Reversible with --remove.",
|
|
2671
|
+
usage: "lnrelay react <activity-urn | comment-urn> [--type LIKE|PRAISE|EMPATHY|INTEREST|APPRECIATION|ENTERTAINMENT]\n lnrelay react <urn> --remove # take the reaction back",
|
|
2659
2672
|
audience: ["cli"],
|
|
2660
2673
|
risk: "write",
|
|
2661
2674
|
implemented: true
|
|
@@ -2892,14 +2905,112 @@ function comment(confirmed, token, deps) {
|
|
|
2892
2905
|
deps
|
|
2893
2906
|
);
|
|
2894
2907
|
}
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2908
|
+
|
|
2909
|
+
// src/engine/sdui-write.ts
|
|
2910
|
+
var SDUI_ACTION = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
|
|
2911
|
+
var SCREEN_ID = "com.linkedin.sdui.flagshipnav.feed.UpdateDetail";
|
|
2912
|
+
var REACTIONS = [
|
|
2913
|
+
"LIKE",
|
|
2914
|
+
"PRAISE",
|
|
2915
|
+
"EMPATHY",
|
|
2916
|
+
"INTEREST",
|
|
2917
|
+
"APPRECIATION",
|
|
2918
|
+
"ENTERTAINMENT"
|
|
2919
|
+
];
|
|
2920
|
+
var LABELS = {
|
|
2921
|
+
LIKE: "Like",
|
|
2922
|
+
PRAISE: "Celebrate",
|
|
2923
|
+
EMPATHY: "Love",
|
|
2924
|
+
INTEREST: "Insightful",
|
|
2925
|
+
APPRECIATION: "Support",
|
|
2926
|
+
ENTERTAINMENT: "Funny"
|
|
2927
|
+
};
|
|
2928
|
+
function reactionLabel(reaction) {
|
|
2929
|
+
return LABELS[reaction];
|
|
2930
|
+
}
|
|
2931
|
+
function reactionUrl(op) {
|
|
2932
|
+
return `${SDUI_ACTION}?sduiid=com.linkedin.sdui.reactions.${op}`;
|
|
2933
|
+
}
|
|
2934
|
+
function targetFor(urn) {
|
|
2935
|
+
const comment2 = /^urn:li:comment:\((urn:li:activity:\d+),(\d+)\)$/.exec(urn);
|
|
2936
|
+
if (comment2 !== null) {
|
|
2937
|
+
return {
|
|
2938
|
+
threadUrn: {
|
|
2939
|
+
threadUrnCommentThreadUrn: {
|
|
2940
|
+
commentUrn: { commentId: comment2[2], thread: comment2[1] }
|
|
2941
|
+
}
|
|
2942
|
+
},
|
|
2943
|
+
reactionSource: "Comment"
|
|
2944
|
+
};
|
|
2945
|
+
}
|
|
2946
|
+
const activity = /^urn:li:(?:activity|ugcPost|share):(\d+)$/.exec(urn);
|
|
2947
|
+
if (activity !== null) {
|
|
2948
|
+
return {
|
|
2949
|
+
threadUrn: {
|
|
2950
|
+
threadUrnActivityThreadUrn: { activityUrn: { activityId: activity[1] } }
|
|
2951
|
+
},
|
|
2952
|
+
reactionSource: "Update"
|
|
2953
|
+
};
|
|
2954
|
+
}
|
|
2955
|
+
throw new Error(
|
|
2956
|
+
`'${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
2957
|
);
|
|
2902
2958
|
}
|
|
2959
|
+
function reactionPayload(target, reaction) {
|
|
2960
|
+
return {
|
|
2961
|
+
threadUrn: target.threadUrn,
|
|
2962
|
+
reactionType: `ReactionType_${reaction}`,
|
|
2963
|
+
reactionSource: target.reactionSource
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2966
|
+
function sduiBody(op, target, reaction) {
|
|
2967
|
+
const requestId = `com.linkedin.sdui.reactions.${op}`;
|
|
2968
|
+
const payload = reactionPayload(target, reaction);
|
|
2969
|
+
const args = {
|
|
2970
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
2971
|
+
requestedStateKeys: [],
|
|
2972
|
+
payload,
|
|
2973
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
2974
|
+
};
|
|
2975
|
+
return {
|
|
2976
|
+
requestId,
|
|
2977
|
+
serverRequest: {
|
|
2978
|
+
requestId,
|
|
2979
|
+
requestedArguments: args,
|
|
2980
|
+
isApfcEnabled: false,
|
|
2981
|
+
isStreaming: false,
|
|
2982
|
+
rumPageKey: ""
|
|
2983
|
+
},
|
|
2984
|
+
states: [],
|
|
2985
|
+
requestedArguments: {
|
|
2986
|
+
...args,
|
|
2987
|
+
states: [],
|
|
2988
|
+
screenId: SCREEN_ID,
|
|
2989
|
+
knownTemplateIds: []
|
|
2990
|
+
}
|
|
2991
|
+
};
|
|
2992
|
+
}
|
|
2993
|
+
async function react(confirmed, client) {
|
|
2994
|
+
const { urn, type, remove } = confirmed.payload;
|
|
2995
|
+
let target;
|
|
2996
|
+
try {
|
|
2997
|
+
target = targetFor(urn);
|
|
2998
|
+
} catch (e) {
|
|
2999
|
+
return { ok: false, code: "INVALID_INPUT", message: e.message };
|
|
3000
|
+
}
|
|
3001
|
+
const op = remove ? "delete" : "create";
|
|
3002
|
+
const result = await client.request({
|
|
3003
|
+
url: reactionUrl(op),
|
|
3004
|
+
method: "POST",
|
|
3005
|
+
body: sduiBody(op, target, type),
|
|
3006
|
+
spendClass: "write",
|
|
3007
|
+
operation: `reaction.${op}`
|
|
3008
|
+
});
|
|
3009
|
+
if (result.ok) return { ok: true, id: urn };
|
|
3010
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
3011
|
+
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.";
|
|
3012
|
+
return out;
|
|
3013
|
+
}
|
|
2903
3014
|
|
|
2904
3015
|
// src/commands/transport.ts
|
|
2905
3016
|
var NO_CREDENTIAL_HINT = [
|
|
@@ -2986,7 +3097,7 @@ function requireOauth(command, ctx) {
|
|
|
2986
3097
|
command,
|
|
2987
3098
|
"NOT_IMPLEMENTED",
|
|
2988
3099
|
`'${command}' is not implemented over the private API`,
|
|
2989
|
-
|
|
3100
|
+
"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
3101
|
);
|
|
2991
3102
|
}
|
|
2992
3103
|
async function gate(command, plan, ctx, deps) {
|
|
@@ -3050,43 +3161,45 @@ async function runComment(postUrn2, text2, now = Date.now(), deps = terminalDeps
|
|
|
3050
3161
|
});
|
|
3051
3162
|
return result.ok ? ok("comment", { id: result.id }) : err("comment", result.code, result.message, result.hint);
|
|
3052
3163
|
}
|
|
3053
|
-
var
|
|
3054
|
-
async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps()) {
|
|
3164
|
+
var REACTIONS2 = REACTIONS;
|
|
3165
|
+
async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps(), remove = false) {
|
|
3055
3166
|
const reaction = type.toUpperCase();
|
|
3056
3167
|
if (postUrn2 === void 0) {
|
|
3057
3168
|
return err(
|
|
3058
3169
|
"react",
|
|
3059
3170
|
"INVALID_INPUT",
|
|
3060
|
-
"a post urn is required",
|
|
3061
|
-
"lnrelay react <urn> [--type LIKE]"
|
|
3171
|
+
"a post or comment urn is required",
|
|
3172
|
+
"lnrelay react <urn> [--type LIKE] [--remove]"
|
|
3062
3173
|
);
|
|
3063
3174
|
}
|
|
3064
|
-
if (!
|
|
3175
|
+
if (!REACTIONS2.includes(reaction)) {
|
|
3065
3176
|
return err(
|
|
3066
3177
|
"react",
|
|
3067
3178
|
"INVALID_INPUT",
|
|
3068
3179
|
`unknown reaction '${type}'`,
|
|
3069
|
-
`one of: ${
|
|
3180
|
+
`one of: ${REACTIONS2.join(", ")}`
|
|
3070
3181
|
);
|
|
3071
3182
|
}
|
|
3072
|
-
const ctx = prepare("react", now);
|
|
3183
|
+
const ctx = prepare("react", now, "voyager");
|
|
3073
3184
|
if ("ok" in ctx) return ctx;
|
|
3074
|
-
|
|
3075
|
-
|
|
3185
|
+
if (ctx.transport.kind !== "voyager") {
|
|
3186
|
+
return err("react", "NOT_IMPLEMENTED", "reacting is only implemented over the private API");
|
|
3187
|
+
}
|
|
3076
3188
|
const plan = {
|
|
3077
|
-
action: "react to a post",
|
|
3078
|
-
payload: {
|
|
3079
|
-
summary: [
|
|
3080
|
-
|
|
3081
|
-
|
|
3189
|
+
action: remove ? "remove a reaction" : "react to a post",
|
|
3190
|
+
payload: { urn: postUrn2, type: reaction, remove },
|
|
3191
|
+
summary: [
|
|
3192
|
+
authorLine(ctx.transport),
|
|
3193
|
+
`on ${postUrn2}`,
|
|
3194
|
+
`reaction ${reaction} \u2014 shows as "${reactionLabel(reaction)}"${remove ? " (REMOVING)" : ""}`
|
|
3195
|
+
],
|
|
3196
|
+
reversibility: remove ? "you can react again; the author may have been notified the first time" : `removable with \`lnrelay react ${postUrn2} --remove --type ${reaction}\` \u2014 the type is required, LinkedIn deletes a specific reaction; the author is notified immediately`,
|
|
3197
|
+
transport: "voyager"
|
|
3082
3198
|
};
|
|
3083
3199
|
const gated = await gate("react", plan, ctx, deps);
|
|
3084
3200
|
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);
|
|
3201
|
+
const result = await react(gated.confirmed, createLiveClient(ctx.transport.session));
|
|
3202
|
+
return result.ok ? ok("react", { id: result.id, removed: remove }) : err("react", result.code, result.message, result.hint);
|
|
3090
3203
|
}
|
|
3091
3204
|
|
|
3092
3205
|
// src/entry.ts
|
|
@@ -3244,7 +3357,13 @@ async function dispatch(argv, now) {
|
|
|
3244
3357
|
case "comment":
|
|
3245
3358
|
return runComment(args.positionals[0], args.positionals[1], now);
|
|
3246
3359
|
case "react":
|
|
3247
|
-
return runReact(
|
|
3360
|
+
return runReact(
|
|
3361
|
+
args.positionals[0],
|
|
3362
|
+
str(args, "type") ?? "LIKE",
|
|
3363
|
+
now,
|
|
3364
|
+
void 0,
|
|
3365
|
+
bool(args, "remove")
|
|
3366
|
+
);
|
|
3248
3367
|
case "delete":
|
|
3249
3368
|
return runDelete(args.positionals[0], now, void 0, bool(args, "quiet"));
|
|
3250
3369
|
case "whoami":
|