linkedin-relay-mcp 3.6.0 → 3.7.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/.claude/skills/linkedin-relay/SKILL.md +5 -0
- package/dist/cli.js +450 -110
- 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
|
@@ -202,6 +202,7 @@ Writes are **not on the MCP surface**. They exist only as CLI commands:
|
|
|
202
202
|
| `lnrelay comment <activity-urn> "<text>"` | comment on a post |
|
|
203
203
|
| `lnrelay reply <comment-urn> "<text>"` | reply, nested under that comment |
|
|
204
204
|
| `lnrelay edit <comment-urn \| share-urn \| ugcPost-urn> "<text>"` | change the text of their own comment or post |
|
|
205
|
+
| `lnrelay edit headline\|about ("<text>" \| --file <path>)` | change their profile headline (max 220 characters) or About section |
|
|
205
206
|
| `lnrelay react <urn> [--type X] [--remove]` | react to a post or comment |
|
|
206
207
|
| `lnrelay delete <activity-urn \| comment-urn>` | delete their post or comment |
|
|
207
208
|
|
|
@@ -240,6 +241,10 @@ Things worth telling a user who asks:
|
|
|
240
241
|
and not on a post that already carries images, a video, a PDF or a poll). The plan names the card
|
|
241
242
|
(`card "<title>" (<site>)`), or says LinkedIn has none. If the lookup fails nothing is posted; add
|
|
242
243
|
`--no-card` to post the link as plain text.
|
|
244
|
+
- A profile edit's preview shows the current headline or About beside the new one. The approval is
|
|
245
|
+
bound to both, so if the profile changed after the preview, re-plan. Every other profile field
|
|
246
|
+
(name, location, current position) is sent back exactly as LinkedIn holds it, and the result is
|
|
247
|
+
read back from the profile. About edits are refused while the About section has top skills set.
|
|
243
248
|
- Scheduled posts are listed by `scheduled` (MCP and CLI), not by `my-posts`.
|
|
244
249
|
- Editing a post replaces its whole text and LinkedIn marks it edited; pass the urn `share` printed
|
|
245
250
|
(or `shareUrn` from `my-posts`), not the activity urn. An @mention in the old text is not kept.
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
+
// src/cli.ts
|
|
3
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
4
|
+
|
|
2
5
|
// src/args.ts
|
|
3
6
|
function parseArgs(argv) {
|
|
4
7
|
const [command, ...rest] = argv;
|
|
@@ -1998,9 +2001,9 @@ function textStates(payload, text2) {
|
|
|
1998
2001
|
}
|
|
1999
2002
|
return null;
|
|
2000
2003
|
};
|
|
2001
|
-
const
|
|
2004
|
+
const plain2 = keyOf("commentary", "commentFieldBinding");
|
|
2002
2005
|
const rich = keyOf("richTextCommentary", "richCommentFieldBinding");
|
|
2003
|
-
if (
|
|
2006
|
+
if (plain2 === null || rich === null) return [];
|
|
2004
2007
|
const entry2 = (key, value, protoCase) => ({
|
|
2005
2008
|
key,
|
|
2006
2009
|
namespace: "MemoryNamespace",
|
|
@@ -2009,7 +2012,7 @@ function textStates(payload, text2) {
|
|
|
2009
2012
|
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: key } }
|
|
2010
2013
|
});
|
|
2011
2014
|
return [
|
|
2012
|
-
entry2(
|
|
2015
|
+
entry2(plain2, text2, "stringValue"),
|
|
2013
2016
|
entry2(rich, { text: text2, attribute: [], $type: "TextModel", source: "local" }, "textModelForWrite")
|
|
2014
2017
|
];
|
|
2015
2018
|
}
|
|
@@ -2068,17 +2071,107 @@ function parseCommentUrn(urn) {
|
|
|
2068
2071
|
activityId: fsd[3]
|
|
2069
2072
|
};
|
|
2070
2073
|
}
|
|
2071
|
-
const
|
|
2072
|
-
if (
|
|
2074
|
+
const plain2 = /^urn:li:comment:\((?:urn:li:)?(activity|ugcPost):(\d+),(\d+)\)$/.exec(urn);
|
|
2075
|
+
if (plain2 !== null) {
|
|
2073
2076
|
return {
|
|
2074
|
-
threadType:
|
|
2075
|
-
activityId:
|
|
2076
|
-
commentId:
|
|
2077
|
+
threadType: plain2[1],
|
|
2078
|
+
activityId: plain2[2],
|
|
2079
|
+
commentId: plain2[3]
|
|
2077
2080
|
};
|
|
2078
2081
|
}
|
|
2079
2082
|
return null;
|
|
2080
2083
|
}
|
|
2081
2084
|
|
|
2085
|
+
// src/engine/sdui-scheduled.ts
|
|
2086
|
+
var PAGER_ID = "com.linkedin.sdui.pagers.sharing.scheduledPosts";
|
|
2087
|
+
var PAGER_URL = `https://www.linkedin.com/flagship-web/rsc-action/actions/pagination?sduiid=${PAGER_ID}`;
|
|
2088
|
+
var SCREEN_ID2 = "com.linkedin.sdui.flagshipnav.sharing.ShareSchedulePostList";
|
|
2089
|
+
function scheduledPageBody(start, count2) {
|
|
2090
|
+
const args = {
|
|
2091
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
2092
|
+
requestedStateKeys: [],
|
|
2093
|
+
payload: { start, count: count2, shareLifeCycleState: "ShareLifeCycleState_SCHEDULED" },
|
|
2094
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
2095
|
+
};
|
|
2096
|
+
return {
|
|
2097
|
+
pagerId: PAGER_ID,
|
|
2098
|
+
clientArguments: { ...args, states: [], screenId: SCREEN_ID2, knownTemplateIds: [] },
|
|
2099
|
+
paginationRequest: {
|
|
2100
|
+
$type: "proto.sdui.actions.requests.PaginationRequest",
|
|
2101
|
+
pagerId: PAGER_ID,
|
|
2102
|
+
retryCount: 0,
|
|
2103
|
+
requestedArguments: args
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
}
|
|
2107
|
+
var COUNT = /"id":"ShareBoxscheduledPostCount"\}\}\},"value":\{"\$case":"intValue","intValue":(\d+)\}/;
|
|
2108
|
+
var ROW = /"feedUpdateUrn":"(urn:li:(?:share|ugcPost):\d+)","scheduledAtEpochMillis":"(\d+)"/g;
|
|
2109
|
+
var TEXT = /"viewName":"mini-update-container"[\s\S]*?"textProps":\{[^{}]*?"children":\["((?:[^"\\]|\\.)*)"\]/g;
|
|
2110
|
+
function parseScheduledPage(stream) {
|
|
2111
|
+
const count2 = stream.match(COUNT);
|
|
2112
|
+
if (count2?.[1] === void 0) {
|
|
2113
|
+
return drift("the scheduled-posts page carried no post count");
|
|
2114
|
+
}
|
|
2115
|
+
const claimedCount = Number(count2[1]);
|
|
2116
|
+
const posts = [];
|
|
2117
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2118
|
+
for (const [, urn, at] of stream.matchAll(ROW)) {
|
|
2119
|
+
if (urn === void 0 || seen.has(urn)) continue;
|
|
2120
|
+
seen.add(urn);
|
|
2121
|
+
posts.push({ urn, scheduledAt: Number(at), text: null });
|
|
2122
|
+
}
|
|
2123
|
+
if (claimedCount > 0 && posts.length === 0) {
|
|
2124
|
+
return drift(`LinkedIn counts ${claimedCount} scheduled posts but no row could be read`);
|
|
2125
|
+
}
|
|
2126
|
+
const texts = [...stream.matchAll(TEXT)].map((m) => JSON.parse(`"${m[1]}"`));
|
|
2127
|
+
if (texts.length === posts.length) {
|
|
2128
|
+
posts.forEach((p, i) => {
|
|
2129
|
+
p.text = texts[i] ?? null;
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
return { ok: true, claimedCount, posts };
|
|
2133
|
+
}
|
|
2134
|
+
function drift(message) {
|
|
2135
|
+
return {
|
|
2136
|
+
ok: false,
|
|
2137
|
+
code: "SCHEMA_DRIFT",
|
|
2138
|
+
message,
|
|
2139
|
+
hint: 'Re-capture the scheduled list (open "Scheduled" in the composer) with scripts/observe-write.ts.'
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
var PAGE_SIZE = 10;
|
|
2143
|
+
var MAX_PAGES = 10;
|
|
2144
|
+
async function fetchScheduled(client, pageSize = PAGE_SIZE) {
|
|
2145
|
+
const posts = [];
|
|
2146
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2147
|
+
let claimedCount = 0;
|
|
2148
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
2149
|
+
const result = await client.request({
|
|
2150
|
+
url: PAGER_URL,
|
|
2151
|
+
method: "POST",
|
|
2152
|
+
body: scheduledPageBody(posts.length, pageSize),
|
|
2153
|
+
spendClass: "page",
|
|
2154
|
+
operation: "scheduled"
|
|
2155
|
+
});
|
|
2156
|
+
if (!result.ok) {
|
|
2157
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
2158
|
+
if (result.hint !== void 0) out.hint = result.hint;
|
|
2159
|
+
return out;
|
|
2160
|
+
}
|
|
2161
|
+
const parsed = parseScheduledPage(result.classification.raw ?? "");
|
|
2162
|
+
if (!parsed.ok) return parsed;
|
|
2163
|
+
claimedCount = Math.max(claimedCount, parsed.claimedCount);
|
|
2164
|
+
const fresh = parsed.posts.filter((p) => !seen.has(p.urn));
|
|
2165
|
+
for (const p of fresh) {
|
|
2166
|
+
seen.add(p.urn);
|
|
2167
|
+
posts.push(p);
|
|
2168
|
+
}
|
|
2169
|
+
if (posts.length >= claimedCount || fresh.length === 0) break;
|
|
2170
|
+
}
|
|
2171
|
+
const state = posts.length >= claimedCount ? "complete" : "partial";
|
|
2172
|
+
return { ok: true, posts, claimedCount, state };
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2082
2175
|
// src/engine/session.ts
|
|
2083
2176
|
var SESSION_FILE = "session.json";
|
|
2084
2177
|
function loadSession() {
|
|
@@ -2607,6 +2700,15 @@ function findOwnPost(posts, urn) {
|
|
|
2607
2700
|
(p) => typeof p.urn === "string" && postId(p.urn) === id || p.shareUrn === urn
|
|
2608
2701
|
);
|
|
2609
2702
|
}
|
|
2703
|
+
function findScheduled(queue, urn) {
|
|
2704
|
+
const found = queue.find((p) => p.urn === urn);
|
|
2705
|
+
if (found === void 0) return void 0;
|
|
2706
|
+
return {
|
|
2707
|
+
urn: found.urn,
|
|
2708
|
+
...found.text === null ? {} : { text: found.text },
|
|
2709
|
+
scheduledAt: new Date(found.scheduledAt).toISOString()
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2610
2712
|
function previewLines2(post) {
|
|
2611
2713
|
if (post === void 0) {
|
|
2612
2714
|
return [
|
|
@@ -2619,7 +2721,21 @@ function previewLines2(post) {
|
|
|
2619
2721
|
}
|
|
2620
2722
|
const text2 = typeof post.text === "string" ? post.text : "(no text \u2014 media-only post?)";
|
|
2621
2723
|
const shown = text2.length > PREVIEW_CHARS ? `${text2.slice(0, PREVIEW_CHARS)}\u2026` : text2;
|
|
2622
|
-
|
|
2724
|
+
const lines = [`content "${shown.replace(/\n/g, " ")}"`];
|
|
2725
|
+
if (typeof post.scheduledAt === "string") {
|
|
2726
|
+
lines.push(`status scheduled, publishes ${post.scheduledAt} unless cancelled`);
|
|
2727
|
+
}
|
|
2728
|
+
return lines;
|
|
2729
|
+
}
|
|
2730
|
+
function deletePlan(urn, post) {
|
|
2731
|
+
const scheduled = typeof post?.scheduledAt === "string";
|
|
2732
|
+
return {
|
|
2733
|
+
action: scheduled ? "cancel a scheduled post" : "delete a post",
|
|
2734
|
+
payload: { urn },
|
|
2735
|
+
summary: [`post ${urn}`, ...previewLines2(post)],
|
|
2736
|
+
reversibility: scheduled ? "NONE, but it never published: nobody has seen it, and it will not go out." : "NONE. A deleted post is gone, with its comments and reactions.",
|
|
2737
|
+
transport: "voyager"
|
|
2738
|
+
};
|
|
2623
2739
|
}
|
|
2624
2740
|
async function lookup(urn, quiet) {
|
|
2625
2741
|
const session = loadSession();
|
|
@@ -2631,7 +2747,11 @@ async function lookup(urn, quiet) {
|
|
|
2631
2747
|
if (profileUrn === void 0) return void 0;
|
|
2632
2748
|
const posts = await engine.myPosts(profileUrn, LOOKUP_LIMIT);
|
|
2633
2749
|
if (!posts.ok) return void 0;
|
|
2634
|
-
|
|
2750
|
+
const published = findOwnPost(shapeAll(posts.value.parsed.items, posts.value.index), urn);
|
|
2751
|
+
if (published !== void 0) return published;
|
|
2752
|
+
if (!/^urn:li:(share|ugcPost):\d+$/.test(urn)) return void 0;
|
|
2753
|
+
const queue = await fetchScheduled(createLiveClient(session.session, void 0, quiet));
|
|
2754
|
+
return queue.ok ? findScheduled(queue.posts, urn) : void 0;
|
|
2635
2755
|
}
|
|
2636
2756
|
function evictionTarget(result) {
|
|
2637
2757
|
if (!result.ok) return null;
|
|
@@ -2733,13 +2853,7 @@ async function runDelete(urn, now = Date.now(), deps, quiet = false) {
|
|
|
2733
2853
|
const unapprovable = refuseUnapprovable("delete", "deleting", deps ?? terminalDeps());
|
|
2734
2854
|
if (unapprovable !== null) return unapprovable;
|
|
2735
2855
|
const post = await lookup(urn, quiet);
|
|
2736
|
-
const plan =
|
|
2737
|
-
action: "delete a post",
|
|
2738
|
-
payload: { urn },
|
|
2739
|
-
summary: [`post ${urn}`, ...previewLines2(post)],
|
|
2740
|
-
reversibility: "NONE. A deleted post is gone, with its comments and reactions.",
|
|
2741
|
-
transport: "voyager"
|
|
2742
|
-
};
|
|
2856
|
+
const plan = deletePlan(urn, post);
|
|
2743
2857
|
const gated = await gateWrite("delete", plan, now, deps ?? terminalDeps(), {
|
|
2744
2858
|
commitSpend: false
|
|
2745
2859
|
});
|
|
@@ -2752,96 +2866,6 @@ async function runDelete(urn, now = Date.now(), deps, quiet = false) {
|
|
|
2752
2866
|
return ok("delete", { deleted: urn, verified: post !== void 0, evictedFromCache: evicted });
|
|
2753
2867
|
}
|
|
2754
2868
|
|
|
2755
|
-
// src/engine/sdui-scheduled.ts
|
|
2756
|
-
var PAGER_ID = "com.linkedin.sdui.pagers.sharing.scheduledPosts";
|
|
2757
|
-
var PAGER_URL = `https://www.linkedin.com/flagship-web/rsc-action/actions/pagination?sduiid=${PAGER_ID}`;
|
|
2758
|
-
var SCREEN_ID2 = "com.linkedin.sdui.flagshipnav.sharing.ShareSchedulePostList";
|
|
2759
|
-
function scheduledPageBody(start, count2) {
|
|
2760
|
-
const args = {
|
|
2761
|
-
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
2762
|
-
requestedStateKeys: [],
|
|
2763
|
-
payload: { start, count: count2, shareLifeCycleState: "ShareLifeCycleState_SCHEDULED" },
|
|
2764
|
-
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
2765
|
-
};
|
|
2766
|
-
return {
|
|
2767
|
-
pagerId: PAGER_ID,
|
|
2768
|
-
clientArguments: { ...args, states: [], screenId: SCREEN_ID2, knownTemplateIds: [] },
|
|
2769
|
-
paginationRequest: {
|
|
2770
|
-
$type: "proto.sdui.actions.requests.PaginationRequest",
|
|
2771
|
-
pagerId: PAGER_ID,
|
|
2772
|
-
retryCount: 0,
|
|
2773
|
-
requestedArguments: args
|
|
2774
|
-
}
|
|
2775
|
-
};
|
|
2776
|
-
}
|
|
2777
|
-
var COUNT = /"id":"ShareBoxscheduledPostCount"\}\}\},"value":\{"\$case":"intValue","intValue":(\d+)\}/;
|
|
2778
|
-
var ROW = /"feedUpdateUrn":"(urn:li:(?:share|ugcPost):\d+)","scheduledAtEpochMillis":"(\d+)"/g;
|
|
2779
|
-
var TEXT = /"viewName":"mini-update-container"[\s\S]*?"textProps":\{[^{}]*?"children":\["((?:[^"\\]|\\.)*)"\]/g;
|
|
2780
|
-
function parseScheduledPage(stream) {
|
|
2781
|
-
const count2 = stream.match(COUNT);
|
|
2782
|
-
if (count2?.[1] === void 0) {
|
|
2783
|
-
return drift("the scheduled-posts page carried no post count");
|
|
2784
|
-
}
|
|
2785
|
-
const claimedCount = Number(count2[1]);
|
|
2786
|
-
const posts = [];
|
|
2787
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2788
|
-
for (const [, urn, at] of stream.matchAll(ROW)) {
|
|
2789
|
-
if (urn === void 0 || seen.has(urn)) continue;
|
|
2790
|
-
seen.add(urn);
|
|
2791
|
-
posts.push({ urn, scheduledAt: Number(at), text: null });
|
|
2792
|
-
}
|
|
2793
|
-
if (claimedCount > 0 && posts.length === 0) {
|
|
2794
|
-
return drift(`LinkedIn counts ${claimedCount} scheduled posts but no row could be read`);
|
|
2795
|
-
}
|
|
2796
|
-
const texts = [...stream.matchAll(TEXT)].map((m) => JSON.parse(`"${m[1]}"`));
|
|
2797
|
-
if (texts.length === posts.length) {
|
|
2798
|
-
posts.forEach((p, i) => {
|
|
2799
|
-
p.text = texts[i] ?? null;
|
|
2800
|
-
});
|
|
2801
|
-
}
|
|
2802
|
-
return { ok: true, claimedCount, posts };
|
|
2803
|
-
}
|
|
2804
|
-
function drift(message) {
|
|
2805
|
-
return {
|
|
2806
|
-
ok: false,
|
|
2807
|
-
code: "SCHEMA_DRIFT",
|
|
2808
|
-
message,
|
|
2809
|
-
hint: 'Re-capture the scheduled list (open "Scheduled" in the composer) with scripts/observe-write.ts.'
|
|
2810
|
-
};
|
|
2811
|
-
}
|
|
2812
|
-
var PAGE_SIZE = 10;
|
|
2813
|
-
var MAX_PAGES = 10;
|
|
2814
|
-
async function fetchScheduled(client, pageSize = PAGE_SIZE) {
|
|
2815
|
-
const posts = [];
|
|
2816
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2817
|
-
let claimedCount = 0;
|
|
2818
|
-
for (let page = 0; page < MAX_PAGES; page++) {
|
|
2819
|
-
const result = await client.request({
|
|
2820
|
-
url: PAGER_URL,
|
|
2821
|
-
method: "POST",
|
|
2822
|
-
body: scheduledPageBody(posts.length, pageSize),
|
|
2823
|
-
spendClass: "page",
|
|
2824
|
-
operation: "scheduled"
|
|
2825
|
-
});
|
|
2826
|
-
if (!result.ok) {
|
|
2827
|
-
const out = { ok: false, code: result.code, message: result.message };
|
|
2828
|
-
if (result.hint !== void 0) out.hint = result.hint;
|
|
2829
|
-
return out;
|
|
2830
|
-
}
|
|
2831
|
-
const parsed = parseScheduledPage(result.classification.raw ?? "");
|
|
2832
|
-
if (!parsed.ok) return parsed;
|
|
2833
|
-
claimedCount = Math.max(claimedCount, parsed.claimedCount);
|
|
2834
|
-
const fresh = parsed.posts.filter((p) => !seen.has(p.urn));
|
|
2835
|
-
for (const p of fresh) {
|
|
2836
|
-
seen.add(p.urn);
|
|
2837
|
-
posts.push(p);
|
|
2838
|
-
}
|
|
2839
|
-
if (posts.length >= claimedCount || fresh.length === 0) break;
|
|
2840
|
-
}
|
|
2841
|
-
const state = posts.length >= claimedCount ? "complete" : "partial";
|
|
2842
|
-
return { ok: true, posts, claimedCount, state };
|
|
2843
|
-
}
|
|
2844
|
-
|
|
2845
2869
|
// src/commands/live.ts
|
|
2846
2870
|
function withSession(command, quiet = false) {
|
|
2847
2871
|
const loaded = sessionFor(command);
|
|
@@ -3670,8 +3694,8 @@ var COMMANDS = [
|
|
|
3670
3694
|
{
|
|
3671
3695
|
name: "edit",
|
|
3672
3696
|
cost: "1 read + 1 write",
|
|
3673
|
-
summary: "Change the text of a comment or post you wrote. Its own verb, so a comment urn can never be mistaken for something to comment ON.",
|
|
3674
|
-
usage: 'lnrelay edit <comment-urn | share-urn | ugcPost-urn> "<text>"\n A post is edited by the urn it was created as (`share` prints it; `my-posts` lists\n it as shareUrn), not its activity urn. The whole text is replaced.',
|
|
3697
|
+
summary: "Change the text of a comment or post you wrote, or your profile headline or About. Its own verb, so a comment urn can never be mistaken for something to comment ON.",
|
|
3698
|
+
usage: 'lnrelay edit <comment-urn | share-urn | ugcPost-urn> "<text>"\n lnrelay edit headline|about ("<text>" | --file <path>)\n A post is edited by the urn it was created as (`share` prints it; `my-posts` lists\n it as shareUrn), not its activity urn. The whole text is replaced. A profile edit\n shows the current text beside the new one, sends every other profile field back as\n LinkedIn holds it, and reads the profile back to confirm. Headline max 220 characters.',
|
|
3675
3699
|
audience: ["cli"],
|
|
3676
3700
|
risk: "write",
|
|
3677
3701
|
implemented: true
|
|
@@ -4042,6 +4066,218 @@ async function comment(confirmed, client) {
|
|
|
4042
4066
|
return { ok: true, id: activityId };
|
|
4043
4067
|
}
|
|
4044
4068
|
|
|
4069
|
+
// src/engine/sdui-profile.ts
|
|
4070
|
+
var NAV_URL = "https://www.linkedin.com/flagship-web/rsc-action/actions/navigation";
|
|
4071
|
+
var ACTION_URL = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
|
|
4072
|
+
var PROFILE_FIELDS = {
|
|
4073
|
+
headline: {
|
|
4074
|
+
name: "headline",
|
|
4075
|
+
screen: "com.linkedin.sdui.flagshipnav.profile.ProfileEditIntroForm",
|
|
4076
|
+
save: "com.linkedin.sdui.requests.profile.saveProfileIntroForm",
|
|
4077
|
+
binding: "headline",
|
|
4078
|
+
// The web form refuses more ("Exceeded maximum length of 220 characters").
|
|
4079
|
+
maxLength: 220
|
|
4080
|
+
},
|
|
4081
|
+
about: {
|
|
4082
|
+
name: "about",
|
|
4083
|
+
screen: "com.linkedin.sdui.flagshipnav.profile.ProfileAboutForm",
|
|
4084
|
+
save: "com.linkedin.sdui.requests.profile.saveProfileAboutForm",
|
|
4085
|
+
binding: "about",
|
|
4086
|
+
maxLength: 2600
|
|
4087
|
+
}
|
|
4088
|
+
};
|
|
4089
|
+
function formNavBody(screen, vanityName) {
|
|
4090
|
+
return {
|
|
4091
|
+
clientArguments: {
|
|
4092
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
4093
|
+
requestedStateKeys: [],
|
|
4094
|
+
payload: { vanityName, isVanityNameResolved: true },
|
|
4095
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" },
|
|
4096
|
+
states: [],
|
|
4097
|
+
screenId: screen,
|
|
4098
|
+
knownTemplateIds: []
|
|
4099
|
+
},
|
|
4100
|
+
isModal: true
|
|
4101
|
+
};
|
|
4102
|
+
}
|
|
4103
|
+
var drift2 = (message) => ({
|
|
4104
|
+
ok: false,
|
|
4105
|
+
code: "SCHEMA_DRIFT",
|
|
4106
|
+
message,
|
|
4107
|
+
hint: "Re-capture the profile form with scripts/observe-write.ts (edit one character, then revert)."
|
|
4108
|
+
});
|
|
4109
|
+
function balanced(s, start) {
|
|
4110
|
+
const open = s[start];
|
|
4111
|
+
const close = open === "[" ? "]" : "}";
|
|
4112
|
+
let depth = 0;
|
|
4113
|
+
let inString = false;
|
|
4114
|
+
let escaped = false;
|
|
4115
|
+
for (let i = start; i < s.length; i++) {
|
|
4116
|
+
const ch = s[i];
|
|
4117
|
+
if (escaped) escaped = false;
|
|
4118
|
+
else if (ch === "\\") escaped = true;
|
|
4119
|
+
else if (ch === '"') inString = !inString;
|
|
4120
|
+
else if (!inString && ch === open) depth++;
|
|
4121
|
+
else if (!inString && ch === close) {
|
|
4122
|
+
depth--;
|
|
4123
|
+
if (depth === 0) return s.slice(start, i + 1);
|
|
4124
|
+
}
|
|
4125
|
+
}
|
|
4126
|
+
return null;
|
|
4127
|
+
}
|
|
4128
|
+
function parseAt(s, start) {
|
|
4129
|
+
const text2 = start === -1 ? null : balanced(s, start);
|
|
4130
|
+
if (text2 === null) return null;
|
|
4131
|
+
try {
|
|
4132
|
+
return JSON.parse(text2);
|
|
4133
|
+
} catch {
|
|
4134
|
+
return null;
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
function plain(v) {
|
|
4138
|
+
const protoCase = String(v.$case);
|
|
4139
|
+
const raw = v[protoCase];
|
|
4140
|
+
if (protoCase === "stringListValue") {
|
|
4141
|
+
return { protoCase, value: raw?.stringValues ?? [] };
|
|
4142
|
+
}
|
|
4143
|
+
return { protoCase, value: raw };
|
|
4144
|
+
}
|
|
4145
|
+
function readForm(stream, field) {
|
|
4146
|
+
const at = stream.indexOf('"modelStates":[');
|
|
4147
|
+
const model = parseAt(stream, at === -1 ? -1 : stream.indexOf("[", at));
|
|
4148
|
+
if (model === null) return drift2("the profile form carried no initial values");
|
|
4149
|
+
const states2 = /* @__PURE__ */ new Map();
|
|
4150
|
+
for (const entry2 of model) {
|
|
4151
|
+
const id = entry2.key?.key?.value?.id;
|
|
4152
|
+
if (id !== void 0 && entry2.value !== void 0 && !states2.has(id)) {
|
|
4153
|
+
states2.set(id, plain(entry2.value));
|
|
4154
|
+
}
|
|
4155
|
+
}
|
|
4156
|
+
const req = stream.indexOf(`"requestId":"${field.save}","requestedArguments":`);
|
|
4157
|
+
const args = req === -1 ? null : parseAt(
|
|
4158
|
+
stream,
|
|
4159
|
+
stream.indexOf("{", stream.indexOf('"requestedArguments":', req))
|
|
4160
|
+
);
|
|
4161
|
+
if (args === null || !Array.isArray(args.requestedStateKeys) || args.payload === void 0) {
|
|
4162
|
+
return drift2(`the profile form carried no ${field.save.split(".").pop()} action`);
|
|
4163
|
+
}
|
|
4164
|
+
return { ok: true, args, states: states2, screen: field.screen, save: field.save };
|
|
4165
|
+
}
|
|
4166
|
+
function boundKey(form, property) {
|
|
4167
|
+
const ref = form.args.payload[property];
|
|
4168
|
+
return ref?.key;
|
|
4169
|
+
}
|
|
4170
|
+
function currentValue(form, field) {
|
|
4171
|
+
const key = boundKey(form, field.binding);
|
|
4172
|
+
const v = key === void 0 ? void 0 : form.states.get(key)?.value;
|
|
4173
|
+
return typeof v === "string" ? v : void 0;
|
|
4174
|
+
}
|
|
4175
|
+
function computed(form, key) {
|
|
4176
|
+
if (!key.endsWith("ReorderableSkillsFormBindingsskillIdsBinding")) return void 0;
|
|
4177
|
+
const initial = [...form.states.entries()].find(([k]) => k.startsWith("initialSkills"))?.[1];
|
|
4178
|
+
if (initial === void 0) return drift2("the About form carried no initial top skills");
|
|
4179
|
+
if (!Array.isArray(initial.value) || initial.value.length > 0) {
|
|
4180
|
+
return {
|
|
4181
|
+
ok: false,
|
|
4182
|
+
code: "NOT_IMPLEMENTED",
|
|
4183
|
+
message: "your About section has top skills, and saving it with them has not been verified",
|
|
4184
|
+
hint: "Edit About in the browser for now; nothing was changed."
|
|
4185
|
+
};
|
|
4186
|
+
}
|
|
4187
|
+
return { protoCase: "expression", value: [] };
|
|
4188
|
+
}
|
|
4189
|
+
function saveBody(form, field, value) {
|
|
4190
|
+
if (value.length > field.maxLength) {
|
|
4191
|
+
return {
|
|
4192
|
+
ok: false,
|
|
4193
|
+
code: "INVALID_INPUT",
|
|
4194
|
+
message: `the ${field.name} is ${value.length} characters; LinkedIn allows ${field.maxLength}`
|
|
4195
|
+
};
|
|
4196
|
+
}
|
|
4197
|
+
const target = boundKey(form, field.binding);
|
|
4198
|
+
if (target === void 0 || !form.states.has(target)) {
|
|
4199
|
+
return drift2(`the profile form has no ${field.name} field`);
|
|
4200
|
+
}
|
|
4201
|
+
const states2 = [];
|
|
4202
|
+
for (const { key } of form.args.requestedStateKeys) {
|
|
4203
|
+
const id = key.value.id;
|
|
4204
|
+
let state = form.states.get(id);
|
|
4205
|
+
if (state?.protoCase === "expression") state = computed(form, id);
|
|
4206
|
+
if (state === void 0) continue;
|
|
4207
|
+
if ("ok" in state) return state;
|
|
4208
|
+
states2.push({
|
|
4209
|
+
key: id,
|
|
4210
|
+
namespace: "MemoryNamespace",
|
|
4211
|
+
value: id === target ? value : state.value,
|
|
4212
|
+
originalProtoCase: state.protoCase,
|
|
4213
|
+
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id } }
|
|
4214
|
+
});
|
|
4215
|
+
}
|
|
4216
|
+
const requestedArguments = {
|
|
4217
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
4218
|
+
requestedStateKeys: form.args.requestedStateKeys,
|
|
4219
|
+
payload: form.args.payload,
|
|
4220
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
4221
|
+
};
|
|
4222
|
+
const body = {
|
|
4223
|
+
requestId: form.save,
|
|
4224
|
+
serverRequest: {
|
|
4225
|
+
requestId: form.save,
|
|
4226
|
+
requestedArguments,
|
|
4227
|
+
isApfcEnabled: false,
|
|
4228
|
+
isStreaming: false,
|
|
4229
|
+
rumPageKey: ""
|
|
4230
|
+
},
|
|
4231
|
+
states: states2,
|
|
4232
|
+
requestedArguments: {
|
|
4233
|
+
...requestedArguments,
|
|
4234
|
+
states: states2,
|
|
4235
|
+
screenId: form.screen,
|
|
4236
|
+
knownTemplateIds: []
|
|
4237
|
+
}
|
|
4238
|
+
};
|
|
4239
|
+
return { ok: true, body };
|
|
4240
|
+
}
|
|
4241
|
+
async function fetchProfileForm(field, vanityName, client) {
|
|
4242
|
+
const result = await client.request({
|
|
4243
|
+
url: `${NAV_URL}?screenId=${field.screen}&sduiid=${field.screen}`,
|
|
4244
|
+
method: "POST",
|
|
4245
|
+
body: formNavBody(field.screen, vanityName),
|
|
4246
|
+
spendClass: "page",
|
|
4247
|
+
operation: `profile-${field.name}-form`
|
|
4248
|
+
});
|
|
4249
|
+
if (!result.ok) {
|
|
4250
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
4251
|
+
if (result.hint !== void 0) out.hint = result.hint;
|
|
4252
|
+
return out;
|
|
4253
|
+
}
|
|
4254
|
+
return readForm(result.classification.raw ?? "", field);
|
|
4255
|
+
}
|
|
4256
|
+
async function sendProfileSave(form, body, client) {
|
|
4257
|
+
const result = await client.request({
|
|
4258
|
+
url: `${ACTION_URL}?sduiid=${form.save}`,
|
|
4259
|
+
method: "POST",
|
|
4260
|
+
body,
|
|
4261
|
+
spendClass: "write",
|
|
4262
|
+
operation: "profile-save"
|
|
4263
|
+
});
|
|
4264
|
+
if (!result.ok) {
|
|
4265
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
4266
|
+
if (result.hint !== void 0) out.hint = result.hint;
|
|
4267
|
+
return out;
|
|
4268
|
+
}
|
|
4269
|
+
const raw = result.classification.raw ?? "";
|
|
4270
|
+
const errors = raw.match(/"errors":\[([^\]]+)\]/)?.[1];
|
|
4271
|
+
if (errors !== void 0) {
|
|
4272
|
+
return {
|
|
4273
|
+
ok: false,
|
|
4274
|
+
code: "INVALID_INPUT",
|
|
4275
|
+
message: `LinkedIn refused the save: ${errors.slice(0, 300)}`
|
|
4276
|
+
};
|
|
4277
|
+
}
|
|
4278
|
+
return { ok: true };
|
|
4279
|
+
}
|
|
4280
|
+
|
|
4045
4281
|
// src/engine/sdui-write.ts
|
|
4046
4282
|
var SDUI_ACTION3 = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
|
|
4047
4283
|
var SCREEN_ID4 = "com.linkedin.sdui.flagshipnav.feed.UpdateDetail";
|
|
@@ -4613,6 +4849,91 @@ async function runEditPost(urn, text2, now, deps) {
|
|
|
4613
4849
|
const result = await editPost(gated.confirmed, createLiveClient(ctx.transport.session));
|
|
4614
4850
|
return result.ok ? ok("edit", { edited: urn }) : err("edit", result.code, result.message, result.hint);
|
|
4615
4851
|
}
|
|
4852
|
+
function liveProfile(session) {
|
|
4853
|
+
const client = createLiveClient(session);
|
|
4854
|
+
return {
|
|
4855
|
+
vanity: async () => {
|
|
4856
|
+
const me = await createEngine(session).whoami();
|
|
4857
|
+
if (!me.ok) return me;
|
|
4858
|
+
const id = me.value?.publicIdentifier ?? null;
|
|
4859
|
+
return typeof id === "string" && id !== "" ? { ok: true, vanity: id } : { ok: false, code: "SCHEMA_DRIFT", message: "whoami returned no public profile id" };
|
|
4860
|
+
},
|
|
4861
|
+
open: (field, vanity) => fetchProfileForm(field, vanity, client),
|
|
4862
|
+
send: (form, body) => sendProfileSave(form, body, client)
|
|
4863
|
+
};
|
|
4864
|
+
}
|
|
4865
|
+
var PROFILE_HINT = `profile fields: ${Object.keys(PROFILE_FIELDS).join(", ")}`;
|
|
4866
|
+
async function runEditProfile(name, text2, now = Date.now(), deps = terminalDeps(), surface) {
|
|
4867
|
+
const field = PROFILE_FIELDS[name];
|
|
4868
|
+
if (field === void 0) {
|
|
4869
|
+
return err(
|
|
4870
|
+
"edit",
|
|
4871
|
+
"INVALID_INPUT",
|
|
4872
|
+
`'${name}' is not a profile field this edits`,
|
|
4873
|
+
PROFILE_HINT
|
|
4874
|
+
);
|
|
4875
|
+
}
|
|
4876
|
+
if (text2 === void 0 || text2.trim() === "") {
|
|
4877
|
+
return err(
|
|
4878
|
+
"edit",
|
|
4879
|
+
"INVALID_INPUT",
|
|
4880
|
+
`the new ${name} is required`,
|
|
4881
|
+
`lnrelay edit ${name} "<text>"`
|
|
4882
|
+
);
|
|
4883
|
+
}
|
|
4884
|
+
if (text2.length > field.maxLength) {
|
|
4885
|
+
return err(
|
|
4886
|
+
"edit",
|
|
4887
|
+
"INVALID_INPUT",
|
|
4888
|
+
`the ${name} is ${text2.length} characters; LinkedIn allows ${field.maxLength}`
|
|
4889
|
+
);
|
|
4890
|
+
}
|
|
4891
|
+
const unapprovable = refuseUnapprovable("edit", "editing", deps);
|
|
4892
|
+
if (unapprovable !== null) return unapprovable;
|
|
4893
|
+
const ctx = prepare("edit", now, "voyager");
|
|
4894
|
+
if ("ok" in ctx) return ctx;
|
|
4895
|
+
if (ctx.transport.kind !== "voyager") {
|
|
4896
|
+
return err("edit", "NOT_IMPLEMENTED", "profile edits go over the browser session only");
|
|
4897
|
+
}
|
|
4898
|
+
const profile = surface ?? liveProfile(ctx.transport.session);
|
|
4899
|
+
const me = await profile.vanity();
|
|
4900
|
+
if (!me.ok) return err("edit", me.code, me.message, me.hint);
|
|
4901
|
+
const form = await profile.open(field, me.vanity);
|
|
4902
|
+
if (!form.ok) return err("edit", form.code, form.message, form.hint);
|
|
4903
|
+
const was = currentValue(form, field) ?? "";
|
|
4904
|
+
if (was === text2) {
|
|
4905
|
+
return err("edit", "INVALID_INPUT", `your ${name} already reads exactly that; nothing to save`);
|
|
4906
|
+
}
|
|
4907
|
+
const built = saveBody(form, field, text2);
|
|
4908
|
+
if (!built.ok) return err("edit", built.code, built.message, built.hint);
|
|
4909
|
+
const plan = {
|
|
4910
|
+
action: `change your ${name}`,
|
|
4911
|
+
payload: { field: name, was, text: text2 },
|
|
4912
|
+
summary: [
|
|
4913
|
+
authorLine(ctx.transport),
|
|
4914
|
+
`field ${name}`,
|
|
4915
|
+
`was "${was}"`,
|
|
4916
|
+
`new "${text2}"`
|
|
4917
|
+
],
|
|
4918
|
+
reversibility: "editable again, but the old text is kept only in this preview and the audit log (~/.lnrelay/writes.jsonl). Every other profile field is sent back as LinkedIn holds it.",
|
|
4919
|
+
transport: "voyager"
|
|
4920
|
+
};
|
|
4921
|
+
const gated = await gate("edit", plan, ctx, deps);
|
|
4922
|
+
if ("ok" in gated) return gated;
|
|
4923
|
+
const sent = await profile.send(form, built.body);
|
|
4924
|
+
if (!sent.ok) return err("edit", sent.code, sent.message, sent.hint);
|
|
4925
|
+
const after = await profile.open(field, me.vanity);
|
|
4926
|
+
const reads = after.ok ? currentValue(after, field) : void 0;
|
|
4927
|
+
if (reads !== text2) {
|
|
4928
|
+
return err(
|
|
4929
|
+
"edit",
|
|
4930
|
+
"SCHEMA_DRIFT",
|
|
4931
|
+
`LinkedIn accepted the save, but your ${name} does not read back as the new text`,
|
|
4932
|
+
after.ok ? `It reads: "${reads ?? ""}"` : `The read-back failed: ${after.message}`
|
|
4933
|
+
);
|
|
4934
|
+
}
|
|
4935
|
+
return ok("edit", { field: name, verified: true });
|
|
4936
|
+
}
|
|
4616
4937
|
function activityIdOf(urn) {
|
|
4617
4938
|
return /^urn:li:(?:activity|ugcPost|share):(\d+)$/.exec(urn)?.[1] ?? null;
|
|
4618
4939
|
}
|
|
@@ -4706,6 +5027,9 @@ async function runEdit(commentUrn, text2, now = Date.now(), deps = terminalDeps(
|
|
|
4706
5027
|
);
|
|
4707
5028
|
}
|
|
4708
5029
|
const ref = parseCommentUrn(commentUrn);
|
|
5030
|
+
if (ref === null && !commentUrn.startsWith("urn:")) {
|
|
5031
|
+
return runEditProfile(commentUrn, text2, now, deps);
|
|
5032
|
+
}
|
|
4709
5033
|
if (ref === null) {
|
|
4710
5034
|
if (/^urn:li:(share|ugcPost):\d+$/.test(commentUrn)) {
|
|
4711
5035
|
return runEditPost(commentUrn, text2, now, deps);
|
|
@@ -5023,6 +5347,22 @@ async function write(command, args, now) {
|
|
|
5023
5347
|
if (wasApproved()) auditOutcome(command, mode.mode, envelope);
|
|
5024
5348
|
return envelope;
|
|
5025
5349
|
}
|
|
5350
|
+
function edit(args, now, deps) {
|
|
5351
|
+
const [target, inline] = args.positionals;
|
|
5352
|
+
if (args.flags.file === true) return err("edit", "INVALID_INPUT", "--file needs a path");
|
|
5353
|
+
const file = str(args, "file");
|
|
5354
|
+
if (file === void 0) return runEdit(target, inline, now, deps);
|
|
5355
|
+
if (inline !== void 0) {
|
|
5356
|
+
return err("edit", "INVALID_INPUT", "pass the new text inline or with --file, not both");
|
|
5357
|
+
}
|
|
5358
|
+
let text2;
|
|
5359
|
+
try {
|
|
5360
|
+
text2 = readFileSync3(file, "utf-8").replace(/\n$/, "");
|
|
5361
|
+
} catch {
|
|
5362
|
+
return err("edit", "INVALID_INPUT", `cannot read ${file}`);
|
|
5363
|
+
}
|
|
5364
|
+
return runEdit(target, text2, now, deps);
|
|
5365
|
+
}
|
|
5026
5366
|
function runWrite(command, args, now, deps) {
|
|
5027
5367
|
const [first, second] = args.positionals;
|
|
5028
5368
|
switch (command) {
|
|
@@ -5031,7 +5371,7 @@ function runWrite(command, args, now, deps) {
|
|
|
5031
5371
|
case "comment":
|
|
5032
5372
|
return runComment(first, second, now, deps);
|
|
5033
5373
|
case "edit":
|
|
5034
|
-
return
|
|
5374
|
+
return edit(args, now, deps);
|
|
5035
5375
|
case "reply":
|
|
5036
5376
|
return runReply(first, second, now, deps);
|
|
5037
5377
|
case "react":
|