linkedin-relay-mcp 3.2.0 → 3.4.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.
@@ -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, optionally with one image or video |
190
+ | `lnrelay share "<text>" [--image <path> ... [--alt "…" ...] \| --video <path> \| --document <pdf> --title "…"] [--at "YYYY-MM-DD HH:MM"]` | post to their own feed — up to 20 images, one video, or one PDF; `--at` schedules it and LinkedIn publishes it then |
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 |
@@ -225,6 +225,9 @@ Things worth telling a user who asks:
225
225
  needed at all: `docs/DECISION-writes.md`.
226
226
  - `--image` / `--video` upload over the private API only; `--via oauth` with media is refused. A
227
227
  video post comes back as a `urn:li:ugcPost:` rather than `urn:li:share:`.
228
+ - A scheduled post gets its urn immediately; `lnrelay delete <urn>` cancels it before it publishes.
229
+ `--at` without an offset is the machine's local time — say the time back to the user in the
230
+ preview's own words, which name the timezone.
228
231
  - **Deleting a comment also deletes every reply under it**, including other people's. Verified live.
229
232
 
230
233
  Connecting and messaging do not exist at all, in any surface. They are the actions where the
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
- flags[key] = next;
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
- flags[key] = next;
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";
@@ -2144,7 +2154,9 @@ var TYPES = {
2144
2154
  gif: { kind: "IMAGE", contentType: "image/gif" },
2145
2155
  webp: { kind: "IMAGE", contentType: "image/webp" },
2146
2156
  mp4: { kind: "VIDEO", contentType: "video/mp4" },
2147
- mov: { kind: "VIDEO", contentType: "video/quicktime" }
2157
+ mov: { kind: "VIDEO", contentType: "video/quicktime" },
2158
+ // LinkedIn also takes ppt/pptx/doc/docx; only pdf has been verified here.
2159
+ pdf: { kind: "DOCUMENT", contentType: "application/pdf" }
2148
2160
  };
2149
2161
  function mediaKindOf(filename) {
2150
2162
  const ext = /\.([a-z0-9]+)$/i.exec(filename)?.[1]?.toLowerCase();
@@ -2152,7 +2164,7 @@ function mediaKindOf(filename) {
2152
2164
  }
2153
2165
  function registerPayload(kind, fileSize, filename) {
2154
2166
  return {
2155
- mediaUploadType: kind === "IMAGE" ? "IMAGE_SHARING" : "VIDEO_SHARING",
2167
+ mediaUploadType: `${kind}_SHARING`,
2156
2168
  fileSize,
2157
2169
  filename
2158
2170
  };
@@ -2221,15 +2233,28 @@ async function uploadMedia(file, client) {
2221
2233
  // src/engine/voyager-write.ts
2222
2234
  var VOYAGER2 = "https://www.linkedin.com/voyager/api";
2223
2235
  var SHARE_URL = `${VOYAGER2}/contentcreation/normShares`;
2224
- function sharePayload(text2, visibility, media = []) {
2236
+ var CATEGORY = {
2237
+ IMAGE: "IMAGE",
2238
+ VIDEO: "VIDEO",
2239
+ DOCUMENT: "NATIVE_DOCUMENT"
2240
+ };
2241
+ function sharePayload(text2, visibility, media = [], scheduledAt) {
2242
+ const schedule = scheduledAt === void 0 ? { postState: "PUBLISHED" } : { postState: "SCHEDULED", scheduledAt };
2225
2243
  return {
2226
2244
  visibleToConnectionsOnly: visibility === "CONNECTIONS",
2227
2245
  externalAudienceProviders: [],
2228
2246
  commentaryV2: { text: text2, attributes: [] },
2229
2247
  origin: "FEED",
2230
2248
  allowedCommentersScope: "ALL",
2231
- postState: "PUBLISHED",
2232
- media: media.map((m) => ({ category: m.category, mediaUrn: m.urn, tapTargets: [] }))
2249
+ ...schedule,
2250
+ // altText only when given, so a post without it keeps the body verified in 2026-08.
2251
+ media: media.map((m) => ({
2252
+ category: CATEGORY[m.category],
2253
+ mediaUrn: m.urn,
2254
+ tapTargets: [],
2255
+ ...m.alt === void 0 ? {} : { altText: m.alt },
2256
+ ...m.title === void 0 ? {} : { title: { text: m.title } }
2257
+ }))
2233
2258
  };
2234
2259
  }
2235
2260
  function mediaDigest(bytes) {
@@ -2268,29 +2293,43 @@ function extractShareUrn(json) {
2268
2293
  return JSON.stringify(json ?? null).match(POST_URN)?.[0] ?? null;
2269
2294
  }
2270
2295
  async function share(confirmed, client, bytes) {
2271
- const { media: approved } = confirmed.payload;
2272
- const media = [];
2273
- if (approved !== void 0) {
2274
- if (bytes === void 0 || mediaDigest(bytes) !== approved.sha256) {
2296
+ const approved = confirmed.payload.media ?? [];
2297
+ const files = bytes ?? [];
2298
+ for (const [i, a] of approved.entries()) {
2299
+ const b = files[i];
2300
+ if (b === void 0 || mediaDigest(b) !== a.sha256) {
2275
2301
  return {
2276
2302
  ok: false,
2277
2303
  code: "INVALID_INPUT",
2278
- message: `${approved.filename} changed after it was approved; nothing was sent`
2304
+ message: `${a.filename} changed after it was approved; nothing was sent`
2279
2305
  };
2280
2306
  }
2307
+ }
2308
+ const media = [];
2309
+ for (const [i, a] of approved.entries()) {
2281
2310
  const uploaded = await uploadMedia(
2282
2311
  {
2283
- bytes,
2284
- filename: approved.filename,
2285
- kind: approved.kind,
2286
- contentType: approved.contentType
2312
+ bytes: files[i],
2313
+ filename: a.filename,
2314
+ kind: a.kind,
2315
+ contentType: a.contentType
2287
2316
  },
2288
2317
  client
2289
2318
  );
2290
2319
  if (!uploaded.ok) return uploaded;
2291
- media.push({ category: approved.kind, urn: uploaded.urn });
2320
+ media.push({
2321
+ category: a.kind,
2322
+ urn: uploaded.urn,
2323
+ ...a.alt === void 0 ? {} : { alt: a.alt },
2324
+ ...a.title === void 0 ? {} : { title: a.title }
2325
+ });
2292
2326
  }
2293
- const body = sharePayload(confirmed.payload.text, confirmed.payload.visibility, media);
2327
+ const body = sharePayload(
2328
+ confirmed.payload.text,
2329
+ confirmed.payload.visibility,
2330
+ media,
2331
+ confirmed.payload.scheduledAt
2332
+ );
2294
2333
  const result = await client.request({
2295
2334
  url: SHARE_URL,
2296
2335
  method: "POST",
@@ -2403,7 +2442,8 @@ function previewLines2(post) {
2403
2442
  if (post === void 0) {
2404
2443
  return [
2405
2444
  "content COULD NOT READ THIS POST.",
2406
- " It is not among your recent posts. That may only mean it is older",
2445
+ " It is not among your recent published posts. That is expected for a",
2446
+ " scheduled post (deleting one cancels it), and may also mean it is older",
2407
2447
  " than the page fetched \u2014 but nothing here has verified what you are",
2408
2448
  " about to delete, or that it is yours."
2409
2449
  ];
@@ -3301,7 +3341,7 @@ var COMMANDS = [
3301
3341
  name: "share",
3302
3342
  cost: "1 call \u2014 write",
3303
3343
  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]\n [--via oauth|voyager]\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) or --video (mp4/mov) uploads the file first, over the\n private API only; the prompt shows its size and sha256.',
3344
+ usage: 'lnrelay share "<text>" [--image <path> ... [--alt "<text>" ...] | --video <path>\n | --document <pdf> --title "<title>"] [--at "YYYY-MM-DD HH:MM"]\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 repeats for up to 20, --alt pairs with it by position (--alt ""\n skips one). --at schedules it (local time, or ISO 8601 with an offset; at least 10\n minutes out); LinkedIn publishes it then, and `lnrelay delete <urn>` cancels it.\n Files, documents and scheduling go over the private API only.',
3305
3345
  audience: ["cli"],
3306
3346
  risk: "write",
3307
3347
  implemented: true
@@ -3932,37 +3972,113 @@ async function gate(command, plan, ctx, deps) {
3932
3972
  if ("ok" in gated) return gated;
3933
3973
  return { confirmed: gated.confirmed };
3934
3974
  }
3935
- function loadMedia(media) {
3936
- const kind = mediaKindOf(media.path);
3975
+ var FLAG_KIND = {
3976
+ image: "IMAGE",
3977
+ video: "VIDEO",
3978
+ document: "DOCUMENT"
3979
+ };
3980
+ var KIND_FLAG = {
3981
+ IMAGE: "--image",
3982
+ VIDEO: "--video",
3983
+ DOCUMENT: "--document"
3984
+ };
3985
+ var KIND_WORD = {
3986
+ IMAGE: "image ",
3987
+ VIDEO: "video ",
3988
+ DOCUMENT: "document"
3989
+ };
3990
+ function mediaLines(media) {
3991
+ return media.flatMap(({ filename, kind, size, sha256, alt, title }) => [
3992
+ `${KIND_WORD[kind]} ${filename} (${Math.ceil(size / 1024)} KB, sha256 ${sha256.slice(0, 12)})`,
3993
+ ...alt === void 0 ? [] : [` alt "${alt}"`],
3994
+ ...title === void 0 ? [] : [` title "${title}"`]
3995
+ ]);
3996
+ }
3997
+ var MAX_IMAGES = 20;
3998
+ function mediaRequestError(media) {
3999
+ const alts = media.alts ?? [];
4000
+ const single = media.flag !== "image";
4001
+ if (single && media.paths.length > 1) {
4002
+ return err(
4003
+ "share",
4004
+ "INVALID_INPUT",
4005
+ `a post carries one ${media.flag}`,
4006
+ `pass a single --${media.flag}`
4007
+ );
4008
+ }
4009
+ if (media.flag !== "image" && alts.length > 0) {
4010
+ return err("share", "INVALID_INPUT", `--alt applies to images, not a ${media.flag}`);
4011
+ }
4012
+ if (media.flag === "document" && (media.title ?? "").trim() === "") {
4013
+ return err(
4014
+ "share",
4015
+ "INVALID_INPUT",
4016
+ "a document needs a title",
4017
+ 'pass --title "<what readers see above the document>"'
4018
+ );
4019
+ }
4020
+ if (media.flag !== "document" && media.title !== void 0) {
4021
+ return err("share", "INVALID_INPUT", "--title applies to a --document");
4022
+ }
4023
+ if (media.paths.length > MAX_IMAGES) {
4024
+ return err("share", "INVALID_INPUT", `a post carries at most ${MAX_IMAGES} images`);
4025
+ }
4026
+ if (alts.length > 0 && alts.length !== media.paths.length) {
4027
+ return err(
4028
+ "share",
4029
+ "INVALID_INPUT",
4030
+ `${alts.length} --alt for ${media.paths.length} images; they pair up by position`,
4031
+ 'give one --alt per --image, in the same order; pass --alt "" for an image without one'
4032
+ );
4033
+ }
4034
+ return null;
4035
+ }
4036
+ function loadAllMedia(media) {
4037
+ const refused = mediaRequestError(media);
4038
+ if (refused !== null) return refused;
4039
+ const alts = media.alts ?? [];
4040
+ const approved = [];
4041
+ const bytes = [];
4042
+ for (const [i, path] of media.paths.entries()) {
4043
+ const one = loadMedia(media.flag, path);
4044
+ if ("ok" in one) return one;
4045
+ const alt = alts[i];
4046
+ let a = alt === void 0 || alt === "" ? one.approved : { ...one.approved, alt };
4047
+ if (media.flag === "document") a = { ...a, title: (media.title ?? "").trim() };
4048
+ approved.push(a);
4049
+ bytes.push(one.bytes);
4050
+ }
4051
+ return { approved, bytes };
4052
+ }
4053
+ function loadMedia(flag, path) {
4054
+ const kind = mediaKindOf(path);
3937
4055
  if (kind === null) {
3938
4056
  return err(
3939
4057
  "share",
3940
4058
  "INVALID_INPUT",
3941
- `unsupported file type: ${basename(media.path)}`,
3942
- "images: png, jpg, jpeg, gif, webp. videos: mp4, mov."
4059
+ `unsupported file type: ${basename(path)}`,
4060
+ "images: png, jpg, jpeg, gif, webp. videos: mp4, mov. documents: pdf."
3943
4061
  );
3944
4062
  }
3945
- const expected = media.flag === "image" ? "IMAGE" : "VIDEO";
3946
- if (kind.kind !== expected) {
3947
- const right = kind.kind === "IMAGE" ? "--image" : "--video";
4063
+ if (kind.kind !== FLAG_KIND[flag]) {
3948
4064
  return err(
3949
4065
  "share",
3950
4066
  "INVALID_INPUT",
3951
- `${basename(media.path)} is not a${media.flag === "image" ? "n image" : " video"}`,
3952
- `pass it with ${right}`
4067
+ `${basename(path)} is not ${flag === "image" ? "an image" : `a ${flag}`}`,
4068
+ `pass it with ${KIND_FLAG[kind.kind]}`
3953
4069
  );
3954
4070
  }
3955
4071
  let bytes;
3956
4072
  try {
3957
- if (!statSync(media.path).isFile()) throw new Error("not a file");
3958
- bytes = new Uint8Array(readFileSync2(media.path));
4073
+ if (!statSync(path).isFile()) throw new Error("not a file");
4074
+ bytes = new Uint8Array(readFileSync2(path));
3959
4075
  } catch {
3960
- return err("share", "INVALID_INPUT", `cannot read ${media.path}`);
4076
+ return err("share", "INVALID_INPUT", `cannot read ${path}`);
3961
4077
  }
3962
4078
  return {
3963
4079
  bytes,
3964
4080
  approved: {
3965
- filename: basename(media.path),
4081
+ filename: basename(path),
3966
4082
  kind: kind.kind,
3967
4083
  contentType: kind.contentType,
3968
4084
  size: bytes.byteLength,
@@ -3970,14 +4086,25 @@ function loadMedia(media) {
3970
4086
  }
3971
4087
  };
3972
4088
  }
3973
- async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps(), via2, media) {
3974
- if (text2 === void 0 || text2.trim() === "") {
3975
- return err("share", "INVALID_INPUT", "text is required", 'lnrelay share "<text>"');
3976
- }
3977
- const vis = visibility === "connections" ? "CONNECTIONS" : "PUBLIC";
3978
- const loaded = media === void 0 ? void 0 : loadMedia(media);
3979
- if (loaded !== void 0 && "ok" in loaded) return loaded;
3980
- if (loaded !== void 0 && via2 === "oauth") {
4089
+ function parseScheduleTime(input) {
4090
+ const iso = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/;
4091
+ if (iso.test(input)) {
4092
+ const t = Date.parse(input);
4093
+ return Number.isNaN(t) ? null : t;
4094
+ }
4095
+ const local = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})$/.exec(input);
4096
+ if (local === null) return null;
4097
+ const [y, mo, d, h, mi] = local.slice(1).map(Number);
4098
+ const date = new Date(y, mo - 1, d, h, mi);
4099
+ const same = date.getFullYear() === y && date.getMonth() === mo - 1 && date.getDate() === d && date.getHours() === h && date.getMinutes() === mi;
4100
+ return same ? date.getTime() : null;
4101
+ }
4102
+ var MIN_LEAD_MS = 10 * 6e4;
4103
+ function mediaFrom(media, via2) {
4104
+ if (media === void 0 || media.paths.length === 0) return void 0;
4105
+ const loaded = loadAllMedia(media);
4106
+ if ("ok" in loaded) return loaded;
4107
+ if (via2 === "oauth") {
3981
4108
  return err(
3982
4109
  "share",
3983
4110
  "NOT_IMPLEMENTED",
@@ -3985,25 +4112,83 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
3985
4112
  "drop --via oauth, or pass --via voyager"
3986
4113
  );
3987
4114
  }
3988
- const ctx = loaded === void 0 ? prepare("share", now, via2) : prepare("share", now, "voyager", 3);
4115
+ return loaded;
4116
+ }
4117
+ function scheduleFrom(at, now, via2) {
4118
+ if (at === void 0) return void 0;
4119
+ const t = parseScheduleTime(at);
4120
+ if (t === null) {
4121
+ return err(
4122
+ "share",
4123
+ "INVALID_INPUT",
4124
+ `cannot read --at '${at}'`,
4125
+ 'use "YYYY-MM-DD HH:MM" (local time) or ISO 8601 with an offset, e.g. 2026-10-20T14:00+02:00'
4126
+ );
4127
+ }
4128
+ if (t < now + MIN_LEAD_MS) {
4129
+ return err(
4130
+ "share",
4131
+ "INVALID_INPUT",
4132
+ "--at must be at least 10 minutes from now",
4133
+ "to post right away, leave --at out"
4134
+ );
4135
+ }
4136
+ if (via2 === "oauth") {
4137
+ return err(
4138
+ "share",
4139
+ "NOT_IMPLEMENTED",
4140
+ "scheduling is only implemented over the private API",
4141
+ "drop --via oauth, or pass --via voyager"
4142
+ );
4143
+ }
4144
+ return t;
4145
+ }
4146
+ function whenLine(at, now) {
4147
+ const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
4148
+ const local = new Date(at).toLocaleString("en-US", {
4149
+ weekday: "short",
4150
+ month: "short",
4151
+ day: "numeric",
4152
+ year: "numeric",
4153
+ hour: "2-digit",
4154
+ minute: "2-digit",
4155
+ hour12: false
4156
+ });
4157
+ const hours = Math.round((at - now) / 36e5);
4158
+ const away = hours < 48 ? `in ${hours} h` : `in ${Math.round(hours / 24)} days`;
4159
+ return `when ${local} (${zone}) \u2014 ${away}`;
4160
+ }
4161
+ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps(), via2, media, at) {
4162
+ if (text2 === void 0 || text2.trim() === "") {
4163
+ return err("share", "INVALID_INPUT", "text is required", 'lnrelay share "<text>"');
4164
+ }
4165
+ const vis = visibility === "connections" ? "CONNECTIONS" : "PUBLIC";
4166
+ const scheduled = scheduleFrom(at, now, via2);
4167
+ if (typeof scheduled === "object") return scheduled;
4168
+ const scheduledAt = scheduled;
4169
+ const loaded = mediaFrom(media, via2);
4170
+ if (loaded !== void 0 && "ok" in loaded) return loaded;
4171
+ const voyagerOnly = loaded !== void 0 || scheduledAt !== void 0;
4172
+ const ctx = prepare(
4173
+ "share",
4174
+ now,
4175
+ voyagerOnly ? "voyager" : via2,
4176
+ 2 * (loaded?.approved.length ?? 0) + 1
4177
+ );
3989
4178
  if ("ok" in ctx) return ctx;
3990
- const payload = {
3991
- text: text2,
3992
- visibility: vis
3993
- };
4179
+ const payload = { text: text2, visibility: vis };
4180
+ if (scheduledAt !== void 0) payload.scheduledAt = scheduledAt;
3994
4181
  const summary = [authorLine(ctx.transport), `content "${text2}"`, `audience ${vis}`];
4182
+ if (scheduledAt !== void 0) summary.push(whenLine(scheduledAt, now));
3995
4183
  if (loaded !== void 0) {
3996
4184
  payload.media = loaded.approved;
3997
- const { filename, kind, size, sha256 } = loaded.approved;
3998
- summary.push(
3999
- `${kind === "IMAGE" ? "image" : "video"} ${filename} (${Math.ceil(size / 1024)} KB, sha256 ${sha256.slice(0, 12)})`
4000
- );
4185
+ summary.push(...mediaLines(loaded.approved));
4001
4186
  }
4002
4187
  const plan = {
4003
- action: "post to your feed",
4188
+ action: scheduledAt === void 0 ? "post to your feed" : "schedule a post",
4004
4189
  payload,
4005
4190
  summary,
4006
- reversibility: "deletable with `lnrelay delete <urn>`, but it is public under your name the moment it lands and anyone who saw it cannot un-see it",
4191
+ reversibility: scheduledAt === void 0 ? "deletable with `lnrelay delete <urn>`, but it is public under your name the moment it lands and anyone who saw it cannot un-see it" : "cancel any time before it publishes with `lnrelay delete <urn>`; after that it is public under your name like any post",
4007
4192
  transport: ctx.transport.kind
4008
4193
  };
4009
4194
  const gated = await gate("share", plan, ctx, deps);
@@ -4016,6 +4201,7 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
4016
4201
  return ok("share", {
4017
4202
  id: result.id ?? null,
4018
4203
  transport: ctx.transport.kind,
4204
+ scheduledFor: scheduledAt === void 0 ? void 0 : new Date(scheduledAt).toISOString(),
4019
4205
  url: "url" in result ? result.url : void 0,
4020
4206
  note: "note" in result ? result.note : ctx.note
4021
4207
  });
@@ -4454,31 +4640,42 @@ function share3(args, now, deps) {
4454
4640
  "one of: oauth, voyager. Omit it to prefer OAuth and fall back to Voyager."
4455
4641
  );
4456
4642
  }
4457
- for (const flag of ["image", "video"]) {
4643
+ for (const flag of ["image", "video", "document", "alt", "title", "at"]) {
4458
4644
  if (args.flags[flag] === true) {
4459
- return err("share", "INVALID_INPUT", `--${flag} needs a file path`);
4645
+ return err("share", "INVALID_INPUT", `--${flag} needs a value`);
4460
4646
  }
4461
4647
  }
4462
- const image = str(args, "image");
4463
- const video = str(args, "video");
4464
- if (image !== void 0 && video !== void 0) {
4648
+ const kinds = ["image", "video", "document"].map((flag) => ({ flag, paths: list(args, flag) })).filter((k) => k.paths.length > 0);
4649
+ if (kinds.length > 1) {
4465
4650
  return err(
4466
4651
  "share",
4467
4652
  "INVALID_INPUT",
4468
- "a post carries an image or a video, not both",
4469
- "pass one of --image <path> or --video <path>"
4653
+ `a post carries ${kinds.map((k) => `${k.flag}s`).join(" or ")}, not both`,
4654
+ "pass --image <path> (repeatable), or a single --video <path>, or a single --document <path>"
4470
4655
  );
4471
4656
  }
4657
+ const alts = list(args, "alt");
4658
+ const title = str(args, "title");
4659
+ const chosen = kinds[0];
4472
4660
  let media;
4473
- if (image !== void 0) media = { flag: "image", path: image };
4474
- else if (video !== void 0) media = { flag: "video", path: video };
4661
+ if (chosen !== void 0) {
4662
+ media = { flag: chosen.flag, paths: chosen.paths, alts };
4663
+ if (title !== void 0) media.title = title;
4664
+ } else if (alts.length > 0 || title !== void 0) {
4665
+ return err(
4666
+ "share",
4667
+ "INVALID_INPUT",
4668
+ "--alt and --title describe an attached file, and none was given"
4669
+ );
4670
+ }
4475
4671
  return runShare(
4476
4672
  args.positionals[0],
4477
4673
  str(args, "visibility") ?? "public",
4478
4674
  now,
4479
4675
  deps,
4480
4676
  surface,
4481
- media
4677
+ media,
4678
+ str(args, "at")
4482
4679
  );
4483
4680
  }
4484
4681
  export {