linkedin-relay-mcp 3.6.0 → 3.6.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 +120 -99
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2079,6 +2079,96 @@ function parseCommentUrn(urn) {
|
|
|
2079
2079
|
return null;
|
|
2080
2080
|
}
|
|
2081
2081
|
|
|
2082
|
+
// src/engine/sdui-scheduled.ts
|
|
2083
|
+
var PAGER_ID = "com.linkedin.sdui.pagers.sharing.scheduledPosts";
|
|
2084
|
+
var PAGER_URL = `https://www.linkedin.com/flagship-web/rsc-action/actions/pagination?sduiid=${PAGER_ID}`;
|
|
2085
|
+
var SCREEN_ID2 = "com.linkedin.sdui.flagshipnav.sharing.ShareSchedulePostList";
|
|
2086
|
+
function scheduledPageBody(start, count2) {
|
|
2087
|
+
const args = {
|
|
2088
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
2089
|
+
requestedStateKeys: [],
|
|
2090
|
+
payload: { start, count: count2, shareLifeCycleState: "ShareLifeCycleState_SCHEDULED" },
|
|
2091
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
2092
|
+
};
|
|
2093
|
+
return {
|
|
2094
|
+
pagerId: PAGER_ID,
|
|
2095
|
+
clientArguments: { ...args, states: [], screenId: SCREEN_ID2, knownTemplateIds: [] },
|
|
2096
|
+
paginationRequest: {
|
|
2097
|
+
$type: "proto.sdui.actions.requests.PaginationRequest",
|
|
2098
|
+
pagerId: PAGER_ID,
|
|
2099
|
+
retryCount: 0,
|
|
2100
|
+
requestedArguments: args
|
|
2101
|
+
}
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
var COUNT = /"id":"ShareBoxscheduledPostCount"\}\}\},"value":\{"\$case":"intValue","intValue":(\d+)\}/;
|
|
2105
|
+
var ROW = /"feedUpdateUrn":"(urn:li:(?:share|ugcPost):\d+)","scheduledAtEpochMillis":"(\d+)"/g;
|
|
2106
|
+
var TEXT = /"viewName":"mini-update-container"[\s\S]*?"textProps":\{[^{}]*?"children":\["((?:[^"\\]|\\.)*)"\]/g;
|
|
2107
|
+
function parseScheduledPage(stream) {
|
|
2108
|
+
const count2 = stream.match(COUNT);
|
|
2109
|
+
if (count2?.[1] === void 0) {
|
|
2110
|
+
return drift("the scheduled-posts page carried no post count");
|
|
2111
|
+
}
|
|
2112
|
+
const claimedCount = Number(count2[1]);
|
|
2113
|
+
const posts = [];
|
|
2114
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2115
|
+
for (const [, urn, at] of stream.matchAll(ROW)) {
|
|
2116
|
+
if (urn === void 0 || seen.has(urn)) continue;
|
|
2117
|
+
seen.add(urn);
|
|
2118
|
+
posts.push({ urn, scheduledAt: Number(at), text: null });
|
|
2119
|
+
}
|
|
2120
|
+
if (claimedCount > 0 && posts.length === 0) {
|
|
2121
|
+
return drift(`LinkedIn counts ${claimedCount} scheduled posts but no row could be read`);
|
|
2122
|
+
}
|
|
2123
|
+
const texts = [...stream.matchAll(TEXT)].map((m) => JSON.parse(`"${m[1]}"`));
|
|
2124
|
+
if (texts.length === posts.length) {
|
|
2125
|
+
posts.forEach((p, i) => {
|
|
2126
|
+
p.text = texts[i] ?? null;
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
return { ok: true, claimedCount, posts };
|
|
2130
|
+
}
|
|
2131
|
+
function drift(message) {
|
|
2132
|
+
return {
|
|
2133
|
+
ok: false,
|
|
2134
|
+
code: "SCHEMA_DRIFT",
|
|
2135
|
+
message,
|
|
2136
|
+
hint: 'Re-capture the scheduled list (open "Scheduled" in the composer) with scripts/observe-write.ts.'
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
var PAGE_SIZE = 10;
|
|
2140
|
+
var MAX_PAGES = 10;
|
|
2141
|
+
async function fetchScheduled(client, pageSize = PAGE_SIZE) {
|
|
2142
|
+
const posts = [];
|
|
2143
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2144
|
+
let claimedCount = 0;
|
|
2145
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
2146
|
+
const result = await client.request({
|
|
2147
|
+
url: PAGER_URL,
|
|
2148
|
+
method: "POST",
|
|
2149
|
+
body: scheduledPageBody(posts.length, pageSize),
|
|
2150
|
+
spendClass: "page",
|
|
2151
|
+
operation: "scheduled"
|
|
2152
|
+
});
|
|
2153
|
+
if (!result.ok) {
|
|
2154
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
2155
|
+
if (result.hint !== void 0) out.hint = result.hint;
|
|
2156
|
+
return out;
|
|
2157
|
+
}
|
|
2158
|
+
const parsed = parseScheduledPage(result.classification.raw ?? "");
|
|
2159
|
+
if (!parsed.ok) return parsed;
|
|
2160
|
+
claimedCount = Math.max(claimedCount, parsed.claimedCount);
|
|
2161
|
+
const fresh = parsed.posts.filter((p) => !seen.has(p.urn));
|
|
2162
|
+
for (const p of fresh) {
|
|
2163
|
+
seen.add(p.urn);
|
|
2164
|
+
posts.push(p);
|
|
2165
|
+
}
|
|
2166
|
+
if (posts.length >= claimedCount || fresh.length === 0) break;
|
|
2167
|
+
}
|
|
2168
|
+
const state = posts.length >= claimedCount ? "complete" : "partial";
|
|
2169
|
+
return { ok: true, posts, claimedCount, state };
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2082
2172
|
// src/engine/session.ts
|
|
2083
2173
|
var SESSION_FILE = "session.json";
|
|
2084
2174
|
function loadSession() {
|
|
@@ -2607,6 +2697,15 @@ function findOwnPost(posts, urn) {
|
|
|
2607
2697
|
(p) => typeof p.urn === "string" && postId(p.urn) === id || p.shareUrn === urn
|
|
2608
2698
|
);
|
|
2609
2699
|
}
|
|
2700
|
+
function findScheduled(queue, urn) {
|
|
2701
|
+
const found = queue.find((p) => p.urn === urn);
|
|
2702
|
+
if (found === void 0) return void 0;
|
|
2703
|
+
return {
|
|
2704
|
+
urn: found.urn,
|
|
2705
|
+
...found.text === null ? {} : { text: found.text },
|
|
2706
|
+
scheduledAt: new Date(found.scheduledAt).toISOString()
|
|
2707
|
+
};
|
|
2708
|
+
}
|
|
2610
2709
|
function previewLines2(post) {
|
|
2611
2710
|
if (post === void 0) {
|
|
2612
2711
|
return [
|
|
@@ -2619,7 +2718,21 @@ function previewLines2(post) {
|
|
|
2619
2718
|
}
|
|
2620
2719
|
const text2 = typeof post.text === "string" ? post.text : "(no text \u2014 media-only post?)";
|
|
2621
2720
|
const shown = text2.length > PREVIEW_CHARS ? `${text2.slice(0, PREVIEW_CHARS)}\u2026` : text2;
|
|
2622
|
-
|
|
2721
|
+
const lines = [`content "${shown.replace(/\n/g, " ")}"`];
|
|
2722
|
+
if (typeof post.scheduledAt === "string") {
|
|
2723
|
+
lines.push(`status scheduled, publishes ${post.scheduledAt} unless cancelled`);
|
|
2724
|
+
}
|
|
2725
|
+
return lines;
|
|
2726
|
+
}
|
|
2727
|
+
function deletePlan(urn, post) {
|
|
2728
|
+
const scheduled = typeof post?.scheduledAt === "string";
|
|
2729
|
+
return {
|
|
2730
|
+
action: scheduled ? "cancel a scheduled post" : "delete a post",
|
|
2731
|
+
payload: { urn },
|
|
2732
|
+
summary: [`post ${urn}`, ...previewLines2(post)],
|
|
2733
|
+
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.",
|
|
2734
|
+
transport: "voyager"
|
|
2735
|
+
};
|
|
2623
2736
|
}
|
|
2624
2737
|
async function lookup(urn, quiet) {
|
|
2625
2738
|
const session = loadSession();
|
|
@@ -2631,7 +2744,11 @@ async function lookup(urn, quiet) {
|
|
|
2631
2744
|
if (profileUrn === void 0) return void 0;
|
|
2632
2745
|
const posts = await engine.myPosts(profileUrn, LOOKUP_LIMIT);
|
|
2633
2746
|
if (!posts.ok) return void 0;
|
|
2634
|
-
|
|
2747
|
+
const published = findOwnPost(shapeAll(posts.value.parsed.items, posts.value.index), urn);
|
|
2748
|
+
if (published !== void 0) return published;
|
|
2749
|
+
if (!/^urn:li:(share|ugcPost):\d+$/.test(urn)) return void 0;
|
|
2750
|
+
const queue = await fetchScheduled(createLiveClient(session.session, void 0, quiet));
|
|
2751
|
+
return queue.ok ? findScheduled(queue.posts, urn) : void 0;
|
|
2635
2752
|
}
|
|
2636
2753
|
function evictionTarget(result) {
|
|
2637
2754
|
if (!result.ok) return null;
|
|
@@ -2733,13 +2850,7 @@ async function runDelete(urn, now = Date.now(), deps, quiet = false) {
|
|
|
2733
2850
|
const unapprovable = refuseUnapprovable("delete", "deleting", deps ?? terminalDeps());
|
|
2734
2851
|
if (unapprovable !== null) return unapprovable;
|
|
2735
2852
|
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
|
-
};
|
|
2853
|
+
const plan = deletePlan(urn, post);
|
|
2743
2854
|
const gated = await gateWrite("delete", plan, now, deps ?? terminalDeps(), {
|
|
2744
2855
|
commitSpend: false
|
|
2745
2856
|
});
|
|
@@ -2752,96 +2863,6 @@ async function runDelete(urn, now = Date.now(), deps, quiet = false) {
|
|
|
2752
2863
|
return ok("delete", { deleted: urn, verified: post !== void 0, evictedFromCache: evicted });
|
|
2753
2864
|
}
|
|
2754
2865
|
|
|
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
2866
|
// src/commands/live.ts
|
|
2846
2867
|
function withSession(command, quiet = false) {
|
|
2847
2868
|
const loaded = sessionFor(command);
|