linkedin-relay-mcp 3.2.0 → 3.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/.claude/skills/linkedin-relay/SKILL.md +1 -1
- package/dist/cli.js +91 -29
- package/dist/cli.js.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp-shim.js +1 -1
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
|
@@ -187,7 +187,7 @@ Writes are **not on the MCP surface**. They exist only as CLI commands:
|
|
|
187
187
|
|
|
188
188
|
| command | does |
|
|
189
189
|
|---|---|
|
|
190
|
-
| `lnrelay share "<text>" [--image <path> \| --video <path>]` | post to their own feed,
|
|
190
|
+
| `lnrelay share "<text>" [--image <path> ... [--alt "<text>" ...] \| --video <path>]` | post to their own feed, with up to 20 images (alt text paired by position) or one video |
|
|
191
191
|
| `lnrelay comment <activity-urn> "<text>"` | comment on a post |
|
|
192
192
|
| `lnrelay reply <comment-urn> "<text>"` | reply, nested under that comment |
|
|
193
193
|
| `lnrelay edit <comment-urn> "<text>"` | change the text of their own comment |
|
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,13 @@ function parseArgs(argv) {
|
|
|
4
4
|
const [command, ...rest] = argv;
|
|
5
5
|
const positionals = [];
|
|
6
6
|
const flags = {};
|
|
7
|
+
const repeated = {};
|
|
8
|
+
const keep = (key, value) => {
|
|
9
|
+
flags[key] = value;
|
|
10
|
+
const seen = repeated[key] ?? [];
|
|
11
|
+
seen.push(value);
|
|
12
|
+
repeated[key] = seen;
|
|
13
|
+
};
|
|
7
14
|
for (let i = 0; i < rest.length; i++) {
|
|
8
15
|
const token = rest[i];
|
|
9
16
|
if (token === void 0) continue;
|
|
@@ -11,7 +18,7 @@ function parseArgs(argv) {
|
|
|
11
18
|
const key = token.slice(2);
|
|
12
19
|
const next = rest[i + 1];
|
|
13
20
|
if (next !== void 0 && !next.startsWith("--")) {
|
|
14
|
-
|
|
21
|
+
keep(key, next);
|
|
15
22
|
i++;
|
|
16
23
|
} else {
|
|
17
24
|
flags[key] = true;
|
|
@@ -20,7 +27,7 @@ function parseArgs(argv) {
|
|
|
20
27
|
const key = token.slice(1);
|
|
21
28
|
const next = rest[i + 1];
|
|
22
29
|
if (next !== void 0 && !next.startsWith("-")) {
|
|
23
|
-
|
|
30
|
+
keep(key, next);
|
|
24
31
|
i++;
|
|
25
32
|
} else {
|
|
26
33
|
flags[key] = true;
|
|
@@ -29,7 +36,7 @@ function parseArgs(argv) {
|
|
|
29
36
|
positionals.push(token);
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
|
-
return { command, positionals, flags };
|
|
39
|
+
return { command, positionals, flags, repeated };
|
|
33
40
|
}
|
|
34
41
|
function bool(args, name) {
|
|
35
42
|
return args.flags[name] === true || args.flags[name] === "true";
|
|
@@ -44,6 +51,9 @@ function num(args, name) {
|
|
|
44
51
|
const n = Number(v);
|
|
45
52
|
return Number.isFinite(n) ? n : void 0;
|
|
46
53
|
}
|
|
54
|
+
function list(args, name) {
|
|
55
|
+
return args.repeated[name] ?? [];
|
|
56
|
+
}
|
|
47
57
|
|
|
48
58
|
// src/commands/approval.ts
|
|
49
59
|
import { appendFileSync, mkdirSync as mkdirSync2 } from "fs";
|
|
@@ -2229,7 +2239,13 @@ function sharePayload(text2, visibility, media = []) {
|
|
|
2229
2239
|
origin: "FEED",
|
|
2230
2240
|
allowedCommentersScope: "ALL",
|
|
2231
2241
|
postState: "PUBLISHED",
|
|
2232
|
-
|
|
2242
|
+
// altText only when given, so a post without it keeps the body verified in 2026-08.
|
|
2243
|
+
media: media.map((m) => ({
|
|
2244
|
+
category: m.category,
|
|
2245
|
+
mediaUrn: m.urn,
|
|
2246
|
+
tapTargets: [],
|
|
2247
|
+
...m.alt === void 0 ? {} : { altText: m.alt }
|
|
2248
|
+
}))
|
|
2233
2249
|
};
|
|
2234
2250
|
}
|
|
2235
2251
|
function mediaDigest(bytes) {
|
|
@@ -2268,27 +2284,35 @@ function extractShareUrn(json) {
|
|
|
2268
2284
|
return JSON.stringify(json ?? null).match(POST_URN)?.[0] ?? null;
|
|
2269
2285
|
}
|
|
2270
2286
|
async function share(confirmed, client, bytes) {
|
|
2271
|
-
const
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2274
|
-
|
|
2287
|
+
const approved = confirmed.payload.media ?? [];
|
|
2288
|
+
const files = bytes ?? [];
|
|
2289
|
+
for (const [i, a] of approved.entries()) {
|
|
2290
|
+
const b = files[i];
|
|
2291
|
+
if (b === void 0 || mediaDigest(b) !== a.sha256) {
|
|
2275
2292
|
return {
|
|
2276
2293
|
ok: false,
|
|
2277
2294
|
code: "INVALID_INPUT",
|
|
2278
|
-
message: `${
|
|
2295
|
+
message: `${a.filename} changed after it was approved; nothing was sent`
|
|
2279
2296
|
};
|
|
2280
2297
|
}
|
|
2298
|
+
}
|
|
2299
|
+
const media = [];
|
|
2300
|
+
for (const [i, a] of approved.entries()) {
|
|
2281
2301
|
const uploaded = await uploadMedia(
|
|
2282
2302
|
{
|
|
2283
|
-
bytes,
|
|
2284
|
-
filename:
|
|
2285
|
-
kind:
|
|
2286
|
-
contentType:
|
|
2303
|
+
bytes: files[i],
|
|
2304
|
+
filename: a.filename,
|
|
2305
|
+
kind: a.kind,
|
|
2306
|
+
contentType: a.contentType
|
|
2287
2307
|
},
|
|
2288
2308
|
client
|
|
2289
2309
|
);
|
|
2290
2310
|
if (!uploaded.ok) return uploaded;
|
|
2291
|
-
media.push({
|
|
2311
|
+
media.push({
|
|
2312
|
+
category: a.kind,
|
|
2313
|
+
urn: uploaded.urn,
|
|
2314
|
+
...a.alt === void 0 ? {} : { alt: a.alt }
|
|
2315
|
+
});
|
|
2292
2316
|
}
|
|
2293
2317
|
const body = sharePayload(confirmed.payload.text, confirmed.payload.visibility, media);
|
|
2294
2318
|
const result = await client.request({
|
|
@@ -3301,7 +3325,7 @@ var COMMANDS = [
|
|
|
3301
3325
|
name: "share",
|
|
3302
3326
|
cost: "1 call \u2014 write",
|
|
3303
3327
|
summary: "Post to your own feed. Prefers LinkedIn's official OAuth scope, falls back to the private API when no token exists \u2014 the prompt always names which.",
|
|
3304
|
-
usage: 'lnrelay share "<text>" [--image <path> | --video <path>] [--visibility public|connections]
|
|
3328
|
+
usage: 'lnrelay share "<text>" [--image <path> ... | --video <path>] [--alt "<text>" ...]\n [--visibility public|connections] [--via oauth|voyager] [--plan | --confirm <token>]\n Approval follows `lnrelay approval`: --plan previews and returns a token without\n sending; --confirm <token> sends it in agent mode. In interactive mode it asks at a\n terminal. --image (png/jpg/gif/webp, repeat for up to 20) or one --video (mp4/mov)\n uploads first, over the private API only; the preview shows each size and sha256.\n --alt pairs with --image by position; --alt "" skips one.',
|
|
3305
3329
|
audience: ["cli"],
|
|
3306
3330
|
risk: "write",
|
|
3307
3331
|
implemented: true
|
|
@@ -3932,6 +3956,43 @@ async function gate(command, plan, ctx, deps) {
|
|
|
3932
3956
|
if ("ok" in gated) return gated;
|
|
3933
3957
|
return { confirmed: gated.confirmed };
|
|
3934
3958
|
}
|
|
3959
|
+
function mediaLines(media) {
|
|
3960
|
+
return media.flatMap(({ filename, kind, size, sha256, alt }) => [
|
|
3961
|
+
`${kind === "IMAGE" ? "image" : "video"} ${filename} (${Math.ceil(size / 1024)} KB, sha256 ${sha256.slice(0, 12)})`,
|
|
3962
|
+
...alt === void 0 ? [] : [` alt "${alt}"`]
|
|
3963
|
+
]);
|
|
3964
|
+
}
|
|
3965
|
+
var MAX_IMAGES = 20;
|
|
3966
|
+
function loadAllMedia(media) {
|
|
3967
|
+
const alts = media.alts ?? [];
|
|
3968
|
+
if (media.flag === "video" && media.paths.length > 1) {
|
|
3969
|
+
return err("share", "INVALID_INPUT", "a post carries one video", "pass a single --video");
|
|
3970
|
+
}
|
|
3971
|
+
if (media.flag === "video" && alts.length > 0) {
|
|
3972
|
+
return err("share", "INVALID_INPUT", "--alt applies to images, not video");
|
|
3973
|
+
}
|
|
3974
|
+
if (media.paths.length > MAX_IMAGES) {
|
|
3975
|
+
return err("share", "INVALID_INPUT", `a post carries at most ${MAX_IMAGES} images`);
|
|
3976
|
+
}
|
|
3977
|
+
if (alts.length > 0 && alts.length !== media.paths.length) {
|
|
3978
|
+
return err(
|
|
3979
|
+
"share",
|
|
3980
|
+
"INVALID_INPUT",
|
|
3981
|
+
`${alts.length} --alt for ${media.paths.length} images; they pair up by position`,
|
|
3982
|
+
'give one --alt per --image, in the same order; pass --alt "" for an image without one'
|
|
3983
|
+
);
|
|
3984
|
+
}
|
|
3985
|
+
const approved = [];
|
|
3986
|
+
const bytes = [];
|
|
3987
|
+
for (const [i, path] of media.paths.entries()) {
|
|
3988
|
+
const one = loadMedia({ flag: media.flag, path });
|
|
3989
|
+
if ("ok" in one) return one;
|
|
3990
|
+
const alt = alts[i];
|
|
3991
|
+
approved.push(alt === void 0 || alt === "" ? one.approved : { ...one.approved, alt });
|
|
3992
|
+
bytes.push(one.bytes);
|
|
3993
|
+
}
|
|
3994
|
+
return { approved, bytes };
|
|
3995
|
+
}
|
|
3935
3996
|
function loadMedia(media) {
|
|
3936
3997
|
const kind = mediaKindOf(media.path);
|
|
3937
3998
|
if (kind === null) {
|
|
@@ -3975,7 +4036,7 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
|
|
|
3975
4036
|
return err("share", "INVALID_INPUT", "text is required", 'lnrelay share "<text>"');
|
|
3976
4037
|
}
|
|
3977
4038
|
const vis = visibility === "connections" ? "CONNECTIONS" : "PUBLIC";
|
|
3978
|
-
const loaded = media === void 0 ? void 0 :
|
|
4039
|
+
const loaded = media === void 0 || media.paths.length === 0 ? void 0 : loadAllMedia(media);
|
|
3979
4040
|
if (loaded !== void 0 && "ok" in loaded) return loaded;
|
|
3980
4041
|
if (loaded !== void 0 && via2 === "oauth") {
|
|
3981
4042
|
return err(
|
|
@@ -3985,7 +4046,7 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
|
|
|
3985
4046
|
"drop --via oauth, or pass --via voyager"
|
|
3986
4047
|
);
|
|
3987
4048
|
}
|
|
3988
|
-
const ctx = loaded === void 0 ? prepare("share", now, via2) : prepare("share", now, "voyager",
|
|
4049
|
+
const ctx = loaded === void 0 ? prepare("share", now, via2) : prepare("share", now, "voyager", 2 * loaded.approved.length + 1);
|
|
3989
4050
|
if ("ok" in ctx) return ctx;
|
|
3990
4051
|
const payload = {
|
|
3991
4052
|
text: text2,
|
|
@@ -3994,10 +4055,7 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
|
|
|
3994
4055
|
const summary = [authorLine(ctx.transport), `content "${text2}"`, `audience ${vis}`];
|
|
3995
4056
|
if (loaded !== void 0) {
|
|
3996
4057
|
payload.media = loaded.approved;
|
|
3997
|
-
|
|
3998
|
-
summary.push(
|
|
3999
|
-
`${kind === "IMAGE" ? "image" : "video"} ${filename} (${Math.ceil(size / 1024)} KB, sha256 ${sha256.slice(0, 12)})`
|
|
4000
|
-
);
|
|
4058
|
+
summary.push(...mediaLines(loaded.approved));
|
|
4001
4059
|
}
|
|
4002
4060
|
const plan = {
|
|
4003
4061
|
action: "post to your feed",
|
|
@@ -4454,24 +4512,28 @@ function share3(args, now, deps) {
|
|
|
4454
4512
|
"one of: oauth, voyager. Omit it to prefer OAuth and fall back to Voyager."
|
|
4455
4513
|
);
|
|
4456
4514
|
}
|
|
4457
|
-
for (const flag of ["image", "video"]) {
|
|
4515
|
+
for (const flag of ["image", "video", "alt"]) {
|
|
4458
4516
|
if (args.flags[flag] === true) {
|
|
4459
4517
|
return err("share", "INVALID_INPUT", `--${flag} needs a file path`);
|
|
4460
4518
|
}
|
|
4461
4519
|
}
|
|
4462
|
-
const
|
|
4463
|
-
const
|
|
4464
|
-
if (
|
|
4520
|
+
const images = list(args, "image");
|
|
4521
|
+
const videos = list(args, "video");
|
|
4522
|
+
if (images.length > 0 && videos.length > 0) {
|
|
4465
4523
|
return err(
|
|
4466
4524
|
"share",
|
|
4467
4525
|
"INVALID_INPUT",
|
|
4468
|
-
"a post carries
|
|
4469
|
-
"pass
|
|
4526
|
+
"a post carries images or a video, not both",
|
|
4527
|
+
"pass --image <path> (repeatable) or a single --video <path>"
|
|
4470
4528
|
);
|
|
4471
4529
|
}
|
|
4530
|
+
const alts = list(args, "alt");
|
|
4472
4531
|
let media;
|
|
4473
|
-
if (
|
|
4474
|
-
else if (
|
|
4532
|
+
if (images.length > 0) media = { flag: "image", paths: images, alts };
|
|
4533
|
+
else if (videos.length > 0) media = { flag: "video", paths: videos, alts };
|
|
4534
|
+
else if (alts.length > 0) {
|
|
4535
|
+
return err("share", "INVALID_INPUT", "--alt describes an --image, and none was given");
|
|
4536
|
+
}
|
|
4475
4537
|
return runShare(
|
|
4476
4538
|
args.positionals[0],
|
|
4477
4539
|
str(args, "visibility") ?? "public",
|