@vercel/board 0.39.0 → 0.41.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/README.md +6 -4
- package/dist/{access-CVkjSfxj.mjs → access-C5HaO42b.mjs} +2 -2
- package/dist/access.d.mts +6 -6
- package/dist/access.mjs +5 -5
- package/dist/actors-nrOf7Y7z.mjs +160 -0
- package/dist/{auth-BXLCkeB0.d.mts → auth-Bn8J_1F2.d.mts} +14 -29
- package/dist/{auth-B3bBYOqf.mjs → auth-DAlYi6TN.mjs} +9 -19
- package/dist/{backend-HcCCGPG4.d.mts → backend-CYsTLxtP.d.mts} +139 -43
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/blocks-CVoBC7ur.mjs +402 -0
- package/dist/blocks-DGvh2alZ.d.mts +33 -0
- package/dist/{chat-provider-1WKsLEnM.mjs → chat-provider-CPZg2MQb.mjs} +2 -2
- package/dist/{chat-provider-DyNy5xdC.d.mts → chat-provider-Cgkh9xJw.d.mts} +2 -2
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +3 -3
- package/dist/cli-embedded.mjs +4 -4
- package/dist/cli.mjs +8 -13
- package/dist/{commands-B5d-lmNN.d.mts → commands-CrEVjASe.d.mts} +14 -26
- package/dist/{commands-BLS7erNu.mjs → commands-QRD0U9AQ.mjs} +114 -105
- package/dist/{conformance-D59Py2m2.mjs → conformance-ClxEEZ9C.mjs} +378 -101
- package/dist/conformance.d.mts +11 -9
- package/dist/conformance.mjs +1 -1
- package/dist/data-values-C-Cq80hz.mjs +176 -0
- package/dist/digest-Dna1CGa_.mjs +4 -0
- package/dist/{engine-eUgO5jTM.mjs → engine-8BcNeckB.mjs} +197 -84
- package/dist/{errors-rYDxZEuN.mjs → errors-DcQf5WeM.mjs} +123 -42
- package/dist/{events-C6HwB046.mjs → events-BT8y_81j.mjs} +2 -2
- package/dist/{exports-M5o4PTfO.mjs → exports-B6udRV_E.mjs} +961 -383
- package/dist/exports-C8zsIL1A.d.mts +4 -0
- package/dist/{external-CHDxWIVf.mjs → external-DymyhUzl.mjs} +1 -1
- package/dist/{index-rNqqgkyu.d.mts → index-fcpEFCTR.d.mts} +2 -2
- package/dist/index.d.mts +7 -6
- package/dist/index.mjs +8 -6
- package/dist/index.node.d.mts +7 -6
- package/dist/index.node.mjs +5 -4
- package/dist/inspect/app.js +110 -109
- package/dist/inspect/engine.js +5 -5
- package/dist/inspect-BsF3mYMY.mjs +2 -0
- package/dist/{inspect-BkXxR2uB.mjs → inspect-DPRoC_Gg.mjs} +6 -6
- package/dist/{local-DvkOWf4U.mjs → local-B9y4p6N7.mjs} +463 -512
- package/dist/{main-DtV_Po9i.mjs → main-S0A-c_kP.mjs} +549 -178
- package/dist/{memory-DkoqhxIH.mjs → memory-DhduVbUu.mjs} +2 -2
- package/dist/{mentions-CB6ShY4R.mjs → mentions-DfZGp3B-.mjs} +18 -4
- package/dist/{middleware-CPqAuRtp.mjs → middleware-DHdrxmoc.mjs} +71 -3
- package/dist/{targets-C1mT3M1N.mjs → origin-B3m2lnZC.mjs} +43 -64
- package/dist/{page-64IwoGRu.mjs → page-2jjHZmIW.mjs} +2 -2
- package/dist/page-CAUe4GmQ.mjs +2 -0
- package/dist/{provider-D5yVFisj.d.mts → provider-dY54GFNz.d.mts} +20 -34
- package/dist/{routes-BffuaoTX.d.mts → routes-By9lmvUD.d.mts} +91 -77
- package/dist/{schemas-AZkxk06N.mjs → schemas-DAzSsgWk.mjs} +8 -3
- package/dist/schemas.d.mts +37 -0
- package/dist/schemas.mjs +3 -0
- package/dist/{serve-CX1rqDF_.mjs → serve-B15I2Ibf.mjs} +5 -5
- package/dist/{server-DkYkyarg.mjs → server-DgpRZ4Nu.mjs} +74 -127
- package/dist/{serving-DJMcG0dT.mjs → serving-CALKWs9K.mjs} +1 -1
- package/dist/{sql-l3ysn4O5.mjs → sql-P9g-rLIF.mjs} +75 -12
- package/dist/{sqlite-CAwNHbQD.mjs → sqlite-B3rCcIof.mjs} +2 -2
- package/dist/{sqlite-db-cm5yhrD-.mjs → sqlite-db-D0Fyju-4.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-chat-sdk.mjs +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-github.mjs +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +2 -2
- package/dist/sync-slack.d.mts +14 -8
- package/dist/sync-slack.mjs +46 -19
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{tokens-DA9ipsZ-.mjs → tokens-D7_ZIWpX.mjs} +4 -4
- package/docs/01-board/01-mounting.md +13 -16
- package/docs/01-board/03-identity.md +112 -74
- package/docs/01-board/04-messages.md +61 -2
- package/docs/01-board/05-reading.md +11 -5
- package/docs/01-board/06-watchers.md +17 -13
- package/docs/01-board/07-schedules.md +8 -6
- package/docs/01-board/08-middleware.md +1 -1
- package/docs/01-board/09-access.md +80 -132
- package/docs/02-sync/01-overview.md +75 -4
- package/docs/02-sync/02-functions.md +11 -6
- package/docs/02-sync/03-slack.md +43 -19
- package/docs/02-sync/06-providers.md +9 -4
- package/docs/03-guides/01-coding-agents.md +18 -22
- package/docs/03-guides/02-inspector.md +4 -5
- package/docs/03-guides/03-ci.md +7 -26
- package/docs/03-guides/04-triage.md +2 -2
- package/docs/03-guides/05-agent-factory.md +7 -9
- package/docs/03-guides/06-sandboxed-agents.md +149 -0
- package/docs/04-reference/01-cli.md +161 -104
- package/docs/04-reference/02-board.md +89 -37
- package/docs/04-reference/03-http.md +176 -71
- package/docs/04-reference/05-conformance.md +47 -21
- package/docs/index.md +5 -5
- package/package.json +5 -1
- package/dist/actors-kfMejhaw.mjs +0 -156
- package/dist/digest-krhjNAt4.mjs +0 -4
- package/dist/exports-vLQ2Y2Nd.d.mts +0 -4
- package/dist/inspect-lnv1sLXM.mjs +0 -2
- package/dist/page-BUj8_UZv.mjs +0 -2
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-
|
|
3
|
-
import {
|
|
1
|
+
import { g as DIRECT_UPLOAD_BYTES_MAX, u as BoardError, y as fileSize } from "./errors-DcQf5WeM.mjs";
|
|
2
|
+
import { f as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-DAzSsgWk.mjs";
|
|
3
|
+
import { d as parseSchemaId, r as findBlocks, t as block } from "./blocks-CVoBC7ur.mjs";
|
|
4
|
+
import { h as VERSION, s as withMentions } from "./origin-B3m2lnZC.mjs";
|
|
4
5
|
import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { i as
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
6
|
+
import { l as shownName } from "./middleware-DHdrxmoc.mjs";
|
|
7
|
+
import { r as PERMISSIONS } from "./access-C5HaO42b.mjs";
|
|
8
|
+
import { i as isApiMessageId, n as isBoardName } from "./exports-B6udRV_E.mjs";
|
|
9
|
+
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-QRD0U9AQ.mjs";
|
|
10
|
+
import { a as vercel, c as connect, i as handTeam, l as handFetch, n as credentialSource, o as http, p as vercelProjectFile, r as credentialed, s as boardUrl, t as board, u as handLogin } from "./server-DgpRZ4Nu.mjs";
|
|
11
|
+
import { t as conformance } from "./conformance-ClxEEZ9C.mjs";
|
|
10
12
|
import { t as displayText } from "./bots-CGkO76qH.mjs";
|
|
11
13
|
import { spawn } from "node:child_process";
|
|
12
14
|
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
@@ -268,7 +270,6 @@ function explanationLine(answer, subject, kind) {
|
|
|
268
270
|
}
|
|
269
271
|
//#endregion
|
|
270
272
|
//#region src/cli/format.ts
|
|
271
|
-
/** "claude via julian" for a profile, the name otherwise. */
|
|
272
273
|
/**
|
|
273
274
|
* Text for a terminal. What boards and platforms say can carry control characters, ESC among them,
|
|
274
275
|
* which starts the sequences that clear the screen, move the cursor, or retitle the window: each
|
|
@@ -279,13 +280,15 @@ const terminalText = (text) => text.replace(/\r\n/g, "\n").replace(/[\u0000-\u00
|
|
|
279
280
|
const code = char.charCodeAt(0);
|
|
280
281
|
return code < 32 ? String.fromCharCode(9216 + code) : code === 127 ? "␡" : "�";
|
|
281
282
|
});
|
|
282
|
-
|
|
283
|
+
/** Who you are, as your messages show you: `claude via julian` with a profile, your name otherwise. */
|
|
284
|
+
const who = (me) => shownName(me);
|
|
285
|
+
/**
|
|
286
|
+
* A message's author as people see them: their name, and who they act through when they have a
|
|
287
|
+
* profile, an agent's person (`claude via julian`) or the principal whose sync imported a
|
|
288
|
+
* platform user (`Malte via www (preview)`).
|
|
289
|
+
*/
|
|
283
290
|
function authorName(message) {
|
|
284
|
-
|
|
285
|
-
if (!author) return message.by.actor;
|
|
286
|
-
const slash = author.handle.indexOf("/");
|
|
287
|
-
if (message.by.profile !== null && slash !== -1) return `${author.name} via ${author.handle.slice(0, slash)}`;
|
|
288
|
-
return author.name;
|
|
291
|
+
return message.author ? shownName(message.author) : message.by.actor;
|
|
289
292
|
}
|
|
290
293
|
function ago(iso, now = Date.now()) {
|
|
291
294
|
const seconds = Math.max(0, Math.round((now - Date.parse(iso)) / 1e3));
|
|
@@ -312,9 +315,22 @@ function reactionNames(messages) {
|
|
|
312
315
|
return [...new Set(messages.flatMap((m) => Object.values(m.reactions).flatMap((actors) => actors.slice(0, 3))))];
|
|
313
316
|
}
|
|
314
317
|
/** An actor's display name from `/actors`, the way a message's author shows: `claude via julian`. */
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
+
const actorName = (actor) => shownName(actor);
|
|
319
|
+
/**
|
|
320
|
+
* A message's text as a terminal shows it: a bot's in its readable form, and each block as one
|
|
321
|
+
* line, its schema and its data, where its fence was. A message that is only a block is that line.
|
|
322
|
+
*/
|
|
323
|
+
function shownText(message) {
|
|
324
|
+
const text = displayText(message.text, message.by.actor);
|
|
325
|
+
if (!message.blocks?.length || text !== message.text) return text;
|
|
326
|
+
let out = "";
|
|
327
|
+
let at = 0;
|
|
328
|
+
for (const found of findBlocks(text)) {
|
|
329
|
+
if (found.data === void 0) continue;
|
|
330
|
+
out += `${text.slice(at, found.start)}data ${found.id} · ${JSON.stringify(found.data)}`;
|
|
331
|
+
at = found.end;
|
|
332
|
+
}
|
|
333
|
+
return out + text.slice(at);
|
|
318
334
|
}
|
|
319
335
|
/** Lines of a linked message an embed shows before it trails off. */
|
|
320
336
|
const EMBED_LINES = 12;
|
|
@@ -334,7 +350,7 @@ function embed(link, pad) {
|
|
|
334
350
|
function formatMessage(message, options = {}) {
|
|
335
351
|
const pad = options.reply ? " " : " ";
|
|
336
352
|
const head = `${options.reply ? " ↳ " : ""}#${message.id} ${authorName(message)} · ${ago(message.createdAt)}${message.editedAt ? " (edited)" : ""}${message.schedule ? ` · scheduled ${message.schedule.id}` : ""}${labels(message)}`;
|
|
337
|
-
const body = message.deleted ? `${pad}(message removed)` : indent(
|
|
353
|
+
const body = message.deleted ? `${pad}(message removed)` : indent(shownText(message), pad);
|
|
338
354
|
const files = (message.attachments ?? []).map((a) => `${pad}file ${a.name} · ${a.type} · ${fileSize(a.size)} · ${a.id}`);
|
|
339
355
|
const links = message.deleted ? [] : (message.links ?? []).flatMap((link) => embed(link, pad));
|
|
340
356
|
const reacted = reactions(message, options.names ?? /* @__PURE__ */ new Map());
|
|
@@ -371,7 +387,7 @@ function formatThreads(messages, known = /* @__PURE__ */ new Map()) {
|
|
|
371
387
|
/** A root's first line, cut to fit 80 columns under its header. */
|
|
372
388
|
function firstLine(message) {
|
|
373
389
|
if (message.deleted) return "(message removed)";
|
|
374
|
-
const text =
|
|
390
|
+
const text = shownText(message).trim();
|
|
375
391
|
const files = message.attachments?.length ?? 0;
|
|
376
392
|
if (!text) return files ? `(${files} ${files === 1 ? "file" : "files"})` : "(no text)";
|
|
377
393
|
const [line = "", ...rest] = text.split(/\r?\n/);
|
|
@@ -411,14 +427,6 @@ function formatAccess(access) {
|
|
|
411
427
|
return `${pattern.padEnd(width)} ${permissions.includes("manage") ? "all" : permissions.length === 0 ? "nothing" : permissions.join(" ")}`;
|
|
412
428
|
});
|
|
413
429
|
}
|
|
414
|
-
/** What a grant or token may do, as `--can` takes it: `dev/=read,post;ci/=read`, or `all`. */
|
|
415
|
-
function formatCan(can) {
|
|
416
|
-
const patterns = Object.keys(can);
|
|
417
|
-
if (patterns.length === 1 && patterns[0] === "*" && can["*"].includes("manage")) return "all";
|
|
418
|
-
if (patterns.length === 0) return "nothing";
|
|
419
|
-
const permissions = (list) => list.includes("manage") ? "all" : list.length === 0 ? "none" : list.join(",");
|
|
420
|
-
return patterns.map((pattern) => `${pattern}=${permissions(can[pattern])}`).join(";");
|
|
421
|
-
}
|
|
422
430
|
/** Rows of cells, each column padded to its widest, two spaces apart. */
|
|
423
431
|
const table = (rows) => {
|
|
424
432
|
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
@@ -469,15 +477,6 @@ function formatGrants(grants) {
|
|
|
469
477
|
}
|
|
470
478
|
/** One grant as its row: `g3 --everyone security/=none`. */
|
|
471
479
|
const grantRow = (grant) => grantCells(grant).join(" ");
|
|
472
|
-
/** Each token on a row: its ID, its name, what it may do, and when it expires. */
|
|
473
|
-
function formatTokens(tokens, now = Date.now()) {
|
|
474
|
-
return table(tokens.map((token) => [
|
|
475
|
-
token.id,
|
|
476
|
-
token.name,
|
|
477
|
-
formatCan(token.can),
|
|
478
|
-
`expires ${until(token.expiresAt, now)}${token.profile !== null ? ` · as ${token.profile}` : ""}${token.parent !== null ? ` · minted with ${token.parent}` : ""}`
|
|
479
|
-
]));
|
|
480
|
-
}
|
|
481
480
|
/** `90m` → `1h30m`, `1d`: milliseconds as a duration flag would say them. */
|
|
482
481
|
function span(ms) {
|
|
483
482
|
const parts = [];
|
|
@@ -521,9 +520,9 @@ function formatEvent(event) {
|
|
|
521
520
|
switch (event.type) {
|
|
522
521
|
case "message.posted": {
|
|
523
522
|
const files = (message.attachments ?? []).map((a) => ` · file ${a.name}`).join("");
|
|
524
|
-
return `#${message.id} ${where} ${who}: ${
|
|
523
|
+
return `#${message.id} ${where} ${who}: ${shownText(message)}${files}`;
|
|
525
524
|
}
|
|
526
|
-
case "message.edited": return `#${message.id} ${where} ${who} (edited): ${
|
|
525
|
+
case "message.edited": return `#${message.id} ${where} ${who} (edited): ${shownText(message)}`;
|
|
527
526
|
case "message.deleted": return `#${message.id} ${where} (message removed)`;
|
|
528
527
|
case "message.linked": return `#${message.id} ${where} ↪ links ${(message.links ?? []).map((link) => link.message !== null ? `#${link.message}` : link.url).join(", ") || "nothing"}`;
|
|
529
528
|
case "reaction.added":
|
|
@@ -598,6 +597,33 @@ function formatConformance(report) {
|
|
|
598
597
|
return `${blocks.join("\n\n")}\n\n${counts.join(", ")}`;
|
|
599
598
|
}
|
|
600
599
|
//#endregion
|
|
600
|
+
//#region src/cli/schemas.ts
|
|
601
|
+
/** How wide a schemas row gets before its description is cut: 80 columns. */
|
|
602
|
+
const WIDTH = 80;
|
|
603
|
+
/** `text` on one line, cut to `width` with an ellipsis. */
|
|
604
|
+
const fitted = (text, width) => {
|
|
605
|
+
const line = text.replace(/\s+/g, " ").trim();
|
|
606
|
+
return line.length <= width ? line : `${line.slice(0, Math.max(0, width - 1)).trimEnd()}…`;
|
|
607
|
+
};
|
|
608
|
+
/** Each schema on a row: its ID, when it was registered (`built in` for the board's own), and what it holds. */
|
|
609
|
+
function formatSchemas(schemas, now = Date.now()) {
|
|
610
|
+
const rows = schemas.map((schema) => [
|
|
611
|
+
schema.id,
|
|
612
|
+
schema.at === null ? "built in" : ago(schema.at, now),
|
|
613
|
+
schema.description ?? ""
|
|
614
|
+
]);
|
|
615
|
+
const widths = [0, 1].map((column) => Math.max(...rows.map((row) => row[column].length)));
|
|
616
|
+
return rows.map(([id, registered, description]) => {
|
|
617
|
+
const head = `${id.padEnd(widths[0])} ${registered.padEnd(widths[1])}`;
|
|
618
|
+
return description ? `${head} ${fitted(description, WIDTH - head.length - 2)}` : head.trimEnd();
|
|
619
|
+
}).join("\n");
|
|
620
|
+
}
|
|
621
|
+
/** One schema: its ID and what it holds, then its JSON Schema, to paste. */
|
|
622
|
+
function formatSchema(schema) {
|
|
623
|
+
const definition = JSON.stringify(schema.schema, null, 2).replace(/^/gm, " ");
|
|
624
|
+
return `${[schema.id, schema.description].filter(Boolean).join(" ")}\n\n${definition}`;
|
|
625
|
+
}
|
|
626
|
+
//#endregion
|
|
601
627
|
//#region src/cli/hooks.ts
|
|
602
628
|
/**
|
|
603
629
|
* Where each agent keeps hooks, and which of its events run ours. Claude Code
|
|
@@ -767,7 +793,7 @@ const flag = (option) => `${option.short ? `-${option.short}, ` : ""}--${option.
|
|
|
767
793
|
const shown = (list) => list.filter((option) => !option.hidden);
|
|
768
794
|
/** A command's rows in the list: itself, when it runs alone and no subcommand is what it runs, and each of its subcommands. */
|
|
769
795
|
function listed(command) {
|
|
770
|
-
return [...!command.subcommands || command.runsWithoutSubcommand && !command.subcommands.some((sub) => sub.default) ? [[usage$1([command])
|
|
796
|
+
return [...!command.subcommands || command.runsWithoutSubcommand && !command.subcommands.some((sub) => sub.default) ? [[`${usage$1([command])}${command.brief ? ` ${command.brief}` : ""}`, command.description]] : [], ...(command.subcommands ?? []).filter((sub) => !sub.hidden).map((sub) => [usage$1([command, sub]), sub.description])];
|
|
771
797
|
}
|
|
772
798
|
/** Every command, by group, then what the app adds (`serve`, `inspect`), and the options they share. */
|
|
773
799
|
function rootHelp(app, version) {
|
|
@@ -781,7 +807,7 @@ function rootHelp(app, version) {
|
|
|
781
807
|
const pad = padOf(listedSections.flat());
|
|
782
808
|
for (const section of listedSections) lines.push("", ...rows(section, pad));
|
|
783
809
|
const everywhere = shown(globalOptions).filter((option) => option.name !== "help" && option.name !== "version");
|
|
784
|
-
lines.push("", ...labeled("filters:", shown(filters$1).map(flag).join(" "), " "), ...labeled("", "labels match a message or its thread's root; repeated flags all must match"), ...labeled("global:", everywhere.map(flag).join(" "), " "), ...labeled("json:", "one object
|
|
810
|
+
lines.push("", ...labeled("filters:", shown(filters$1).map(flag).join(" "), " "), ...labeled("", "labels match a message or its thread's root; repeated flags all must match"), ...labeled("global:", everywhere.map(flag).join(" "), " "), ...labeled("json:", "one object: { threads, cursor } for read <channel>, { message, replies, cursor } for read <id> (message is the thread root)"), ...labeled("text:", "pass \"-\" to read it from stdin; it may be left out when you --attach"), ...labeled("env:", "BOARD_URL BOARD_NAME BOARD_TOKEN BOARD_PROFILE BOARD_AVATAR", " "), "", `a command's own help: ${app.name} <command> --help`);
|
|
785
811
|
return lines.join("\n");
|
|
786
812
|
}
|
|
787
813
|
/** One command's page: its usage, what it does, and its arguments, subcommands, options, and examples. */
|
|
@@ -1218,23 +1244,45 @@ function ifRevision() {
|
|
|
1218
1244
|
if (!/^[1-9]\d{0,15}$/.test(given)) throw usage(`--if-revision takes the message's revision, a number, and ${given} isn't one.`);
|
|
1219
1245
|
return { revision: Number(given) };
|
|
1220
1246
|
}
|
|
1221
|
-
function labelPairs(values, wrong = "Labels look like key=value, and {value} isn't one.") {
|
|
1247
|
+
function labelPairs(values, wrong = "Labels look like key=value, and {value} isn't one.", empty = "{value} has no value: a label needs one.") {
|
|
1222
1248
|
const pairs = {};
|
|
1223
1249
|
for (const value of values ?? []) {
|
|
1224
1250
|
const at = value.indexOf("=");
|
|
1225
1251
|
if (at <= 0) throw usage(wrong.replace("{value}", value));
|
|
1252
|
+
if (at === value.length - 1 && empty !== null) throw usage(empty.replace("{value}", value).replace("{key}", value.slice(0, at)));
|
|
1226
1253
|
pairs[value.slice(0, at)] = value.slice(at + 1);
|
|
1227
1254
|
}
|
|
1228
1255
|
return pairs;
|
|
1229
1256
|
}
|
|
1230
1257
|
/**
|
|
1258
|
+
* A post or reply takes one text. What follows it was meant to be part of the message, or a label,
|
|
1259
|
+
* and would be dropped without a word: say so, and how each is written.
|
|
1260
|
+
*/
|
|
1261
|
+
function oneText(command, target, extra) {
|
|
1262
|
+
if (flags.text !== void 0) throw usage(`--text is a filter for read, tail, and wait. ${command} takes its text as an argument, in quotes.`);
|
|
1263
|
+
const [first] = extra;
|
|
1264
|
+
if (first === void 0) return;
|
|
1265
|
+
if (/^[\w.-]+=/.test(first)) throw usage(`${first} looks like a label, and ${command} takes labels with --label.`, { next: [{
|
|
1266
|
+
instruction: "Label it as you post it",
|
|
1267
|
+
argv: [
|
|
1268
|
+
...cli(),
|
|
1269
|
+
command,
|
|
1270
|
+
target,
|
|
1271
|
+
"<TEXT>",
|
|
1272
|
+
"--label",
|
|
1273
|
+
first
|
|
1274
|
+
]
|
|
1275
|
+
}] });
|
|
1276
|
+
throw usage(first === "-" ? `${command} takes one text, and - (stdin) is a second. For a long message, pass - alone as the text: it has no title.` : `${command} takes one text, and ${first.length > 40 ? `${first.slice(0, 40)}…` : first} is one too many. Quote the whole message as one argument: it has no title.`);
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1231
1279
|
* A message's text: the argument, stdin for `-`, or the file `--text-file` names (`-` for stdin).
|
|
1232
1280
|
* `optional` when the message can go without, as one with `--attach` files can.
|
|
1233
1281
|
*/
|
|
1234
1282
|
async function text(value, { optional = false } = {}) {
|
|
1235
1283
|
const file = flags["text-file"];
|
|
1236
1284
|
if (file !== void 0) {
|
|
1237
|
-
if (value !== void 0) throw usage("Can't use --text-file with text:
|
|
1285
|
+
if (value !== void 0) throw usage("Can't use --text-file with text: a message has no title, so its whole text comes from one or the other.");
|
|
1238
1286
|
if (file === "-") return (await io.stdin()).replace(/\n$/, "");
|
|
1239
1287
|
const data = await io.readFile(file).catch((error) => {
|
|
1240
1288
|
if (!(error instanceof Failed) || error.failure.reason !== "payload_too_large") throw error;
|
|
@@ -1262,6 +1310,18 @@ async function attachments(board) {
|
|
|
1262
1310
|
const files = [];
|
|
1263
1311
|
for (const path of flags.attach ?? []) {
|
|
1264
1312
|
const data = await io.readFile(path);
|
|
1313
|
+
if (!data && path === "-") throw usage("Can't attach -: stdin is for the message's text. Pass - as the text to read it from stdin.", {
|
|
1314
|
+
reason: "file_not_found",
|
|
1315
|
+
next: [{
|
|
1316
|
+
instruction: "Post text from stdin",
|
|
1317
|
+
argv: [
|
|
1318
|
+
...cli(),
|
|
1319
|
+
current.command ?? "post",
|
|
1320
|
+
"<channel|id>",
|
|
1321
|
+
"-"
|
|
1322
|
+
]
|
|
1323
|
+
}]
|
|
1324
|
+
});
|
|
1265
1325
|
if (!data) throw usage(`Can't attach ${path}. There's no such file.`, {
|
|
1266
1326
|
reason: "file_not_found",
|
|
1267
1327
|
next: []
|
|
@@ -1279,38 +1339,23 @@ async function attachments(board) {
|
|
|
1279
1339
|
}));
|
|
1280
1340
|
return uploaded;
|
|
1281
1341
|
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Whether `value` is a schedule's own ID and not a message's: `s12` on a local board, `sch_…` on
|
|
1344
|
+
* Vercel's. A message's is a number or `msg_…`, so neither is ever one.
|
|
1345
|
+
*/
|
|
1346
|
+
const isScheduleId = (value) => /^(?:s\d+|sch_\S+)$/i.test(value);
|
|
1282
1347
|
/** A schedule's ID as the board gave it: `s12`, or `sch_…` on Vercel's board. */
|
|
1283
1348
|
function scheduleId(value) {
|
|
1284
1349
|
if (value === void 0) throw usage("Missing the schedule ID, like s12.", { reason: "missing_arguments" });
|
|
1285
1350
|
if (!/^[^\s/]+$/.test(value)) throw usage(`${value} isn't a schedule ID like s12.`);
|
|
1286
1351
|
return value;
|
|
1287
1352
|
}
|
|
1288
|
-
/** A grant's
|
|
1289
|
-
function
|
|
1290
|
-
|
|
1291
|
-
if (value
|
|
1292
|
-
if (!/^[^\s/]+$/.test(value)) throw usage(`${value} isn't a ${what} ID like ${like}.`);
|
|
1353
|
+
/** A grant's ID as the board gave it: `g3`, or another board's own. */
|
|
1354
|
+
function grantId(value) {
|
|
1355
|
+
if (value === void 0) throw usage("Missing the grant ID, like g3.", { reason: "missing_arguments" });
|
|
1356
|
+
if (!/^[^\s/]+$/.test(value)) throw usage(`${value} isn't a grant ID like g3.`);
|
|
1293
1357
|
return value;
|
|
1294
1358
|
}
|
|
1295
|
-
/**
|
|
1296
|
-
* A token's `--can`, as `x-board-can` writes it (`dev/=read,post;ci/=read`), repeated or
|
|
1297
|
-
* `;`-joined, with `none` for no permissions, as `all` is every one: `*=all;security/=none` closes a
|
|
1298
|
-
* subtree. `security/=` means the same. The board takes an empty list, so `none` never leaves the CLI.
|
|
1299
|
-
*/
|
|
1300
|
-
function canFlag(values) {
|
|
1301
|
-
const scope = values.flatMap((value) => value.split(";")).map((entry) => {
|
|
1302
|
-
const at = entry.indexOf("=");
|
|
1303
|
-
if (at === -1) return entry;
|
|
1304
|
-
const permissions = entry.slice(at + 1).split(",").map((permission) => permission.trim());
|
|
1305
|
-
if (permissions.includes("none") && permissions.length > 1) throw usage(`--can: none is no permissions, so it goes alone: ${entry.slice(0, at).trim()}=none.`);
|
|
1306
|
-
return permissions[0] === "none" ? entry.slice(0, at + 1) : entry;
|
|
1307
|
-
}).join(";");
|
|
1308
|
-
try {
|
|
1309
|
-
return parseCan(scope, "--can");
|
|
1310
|
-
} catch (error) {
|
|
1311
|
-
throw usage(`${error.message.replace(/, or all$/, ", all, or none")}.`);
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
1359
|
/** What a grant's flags say, or the misuse in them. */
|
|
1315
1360
|
function grantFlags(read) {
|
|
1316
1361
|
try {
|
|
@@ -1373,6 +1418,48 @@ function configuredUrl() {
|
|
|
1373
1418
|
});
|
|
1374
1419
|
}
|
|
1375
1420
|
}
|
|
1421
|
+
/**
|
|
1422
|
+
* What a message says: its text, or with `--schema`, a block of that schema and nothing else, whose
|
|
1423
|
+
* JSON the text is, from wherever text comes (the argument, stdin, `--text-file`).
|
|
1424
|
+
*/
|
|
1425
|
+
async function content(value, options = {}) {
|
|
1426
|
+
const schema = flags.schema;
|
|
1427
|
+
if (schema === void 0) return text(value, options);
|
|
1428
|
+
if (!parseSchemaId(schema)) throw usage(`${schema} doesn't name a schema. One is name@version, like sandbox@1.`);
|
|
1429
|
+
let data;
|
|
1430
|
+
try {
|
|
1431
|
+
data = JSON.parse(await text(value));
|
|
1432
|
+
} catch (error) {
|
|
1433
|
+
if (error instanceof Failed) throw error;
|
|
1434
|
+
throw usage(`With --schema, the text is ${schema}'s JSON, and this isn't JSON.`);
|
|
1435
|
+
}
|
|
1436
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) throw usage(`With --schema, the text is a JSON object, like {"id":"sbx-123"}.`);
|
|
1437
|
+
return block(schema, data);
|
|
1438
|
+
}
|
|
1439
|
+
/** A schema's JSON Schema, as `--schema` gives it: inline JSON, the file `@<path>` names, or stdin for `-`. */
|
|
1440
|
+
async function definition() {
|
|
1441
|
+
const given = flags.schema;
|
|
1442
|
+
if (given === void 0) throw usage("Missing --schema: its JSON Schema, inline, @<file>, or - for stdin.", { reason: "missing_arguments" });
|
|
1443
|
+
let source = given;
|
|
1444
|
+
if (given === "-") source = await io.stdin();
|
|
1445
|
+
else if (given.startsWith("@")) {
|
|
1446
|
+
const file = given.slice(1);
|
|
1447
|
+
const data = await io.readFile(file);
|
|
1448
|
+
if (!data) throw usage(`Can't read ${file}. There's no such file.`, {
|
|
1449
|
+
reason: "file_not_found",
|
|
1450
|
+
next: []
|
|
1451
|
+
});
|
|
1452
|
+
source = new TextDecoder().decode(data);
|
|
1453
|
+
}
|
|
1454
|
+
let parsed;
|
|
1455
|
+
try {
|
|
1456
|
+
parsed = JSON.parse(source);
|
|
1457
|
+
} catch {
|
|
1458
|
+
throw usage(given === "-" || given.startsWith("@") ? `${given === "-" ? "stdin" : given.slice(1)} isn't JSON.` : `--schema takes JSON, or a file as @<path>: ${given.length > 40 ? `${given.slice(0, 40)}…` : given} isn't JSON.`);
|
|
1459
|
+
}
|
|
1460
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw usage("A schema is a JSON object: {\"type\":\"object\", …}.");
|
|
1461
|
+
return parsed;
|
|
1462
|
+
}
|
|
1376
1463
|
/** A board that predates what this run asked of it. */
|
|
1377
1464
|
const outdated = (message) => new Failed({
|
|
1378
1465
|
class: "platform",
|
|
@@ -1402,7 +1489,7 @@ function doing() {
|
|
|
1402
1489
|
case "schedules":
|
|
1403
1490
|
case "actors": return `list ${command}`;
|
|
1404
1491
|
case "grants": return a === "create" ? "create the grant" : a === "update" ? `update grant ${b}` : a === "explain" ? `explain ${b ?? "the channel"}` : a === "revoke" ? `revoke grant ${b}` : "list grants";
|
|
1405
|
-
case "
|
|
1492
|
+
case "schemas": return a === "create" ? `register schema ${b ?? ""}`.trimEnd() : a === "inspect" ? `read schema ${b ?? ""}`.trimEnd() : "list schemas";
|
|
1406
1493
|
case "sources": return b === void 0 ? "list sources" : `${b} ${c ?? "it"} on ${a}`;
|
|
1407
1494
|
case "download": return `download ${a ?? "the attachment"}`;
|
|
1408
1495
|
case "inbox": return `read ${a}'s inbox`;
|
|
@@ -1436,7 +1523,8 @@ function missing() {
|
|
|
1436
1523
|
"schedule"
|
|
1437
1524
|
].includes(command) && isMessageRef(a)) return `message ${ref(a)}`;
|
|
1438
1525
|
if (command === "schedule" && a === "cancel" && b !== void 0) return `schedule ${b}`;
|
|
1439
|
-
if (
|
|
1526
|
+
if (command === "grants" && (a === "revoke" || a === "update") && b !== void 0) return `grant ${b}`;
|
|
1527
|
+
if (command === "schemas" && a === "inspect" && b !== void 0) return `schema ${b}`;
|
|
1440
1528
|
if (command === "download") return `attachment ${a}`;
|
|
1441
1529
|
}
|
|
1442
1530
|
/**
|
|
@@ -1494,19 +1582,12 @@ function failureOf(error) {
|
|
|
1494
1582
|
case "board_not_granted": return own("permission", "board_not_granted");
|
|
1495
1583
|
case "watchers_need_project": return own("permission", "watchers_need_project");
|
|
1496
1584
|
case "unsupported_principal": return own(status === 403 ? "permission" : "usage", "unsupported_principal");
|
|
1497
|
-
case "board_token_scope": return own("permission", "board_token_scope");
|
|
1498
1585
|
case "invalid_board_name": return own("usage", "invalid_arguments", [helpRecovery()]);
|
|
1499
1586
|
case "too_many_redirects": return own("network", "network_error");
|
|
1500
1587
|
case "invalid_duration": return own("usage", "invalid_arguments", [helpRecovery()]);
|
|
1501
1588
|
case "wrong_audience":
|
|
1502
1589
|
case "redirected": return own("usage", "wrong_url");
|
|
1503
|
-
case "
|
|
1504
|
-
instruction: "Write as one of them",
|
|
1505
|
-
argv: rerun("--as", "<PROFILE>")
|
|
1506
|
-
}, {
|
|
1507
|
-
instruction: "Or as yourself",
|
|
1508
|
-
argv: rerun("--human")
|
|
1509
|
-
}]);
|
|
1590
|
+
case "renamed_env": return own("usage", "renamed_env");
|
|
1510
1591
|
case "too_large": return {
|
|
1511
1592
|
...own("limit", "payload_too_large"),
|
|
1512
1593
|
message: `Can't ${doing()}. ${sentence(message)}`
|
|
@@ -1550,8 +1631,21 @@ function failureOf(error) {
|
|
|
1550
1631
|
data: said
|
|
1551
1632
|
});
|
|
1552
1633
|
const specific = (fallback) => /^[a-z]+(_[a-z]+)+$/.test(code) && code !== "invalid_request" && code !== "remote_error" ? code : fallback;
|
|
1634
|
+
if (status === 400 && code === "invalid_block" && flags.schema !== void 0 && parseSchemaId(flags.schema)) return theirs("usage", code, `Can't ${doing()}.`, [{
|
|
1635
|
+
instruction: `See what ${flags.schema} holds`,
|
|
1636
|
+
argv: [
|
|
1637
|
+
...cli(),
|
|
1638
|
+
"schemas",
|
|
1639
|
+
"inspect",
|
|
1640
|
+
flags.schema
|
|
1641
|
+
]
|
|
1642
|
+
}]);
|
|
1643
|
+
if (status === 400 && code === "schema_not_found" && current.command !== "schemas") return theirs("usage", code, `Can't ${doing()}.`, [{
|
|
1644
|
+
instruction: "See the schemas this board has",
|
|
1645
|
+
argv: [...cli(), "schemas"]
|
|
1646
|
+
}]);
|
|
1553
1647
|
if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
|
|
1554
|
-
if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", process.env.BOARD_TOKEN ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : [{
|
|
1648
|
+
if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", process.env.BOARD_TOKEN && reached && !vercelBoard(reached) ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : [{
|
|
1555
1649
|
instruction: "Log in again",
|
|
1556
1650
|
argv: ["vercel", "login"]
|
|
1557
1651
|
}]);
|
|
@@ -1568,6 +1662,15 @@ function failureOf(error) {
|
|
|
1568
1662
|
const newer = code === "newer_message" && flags.after !== void 0 && args[0] !== void 0;
|
|
1569
1663
|
const labeled = code === "label_conflict" && (flags.if !== void 0 || flags["if-unset"] !== void 0) && args[0] !== void 0;
|
|
1570
1664
|
const changed = code === "revision_conflict" && flags["if-revision"] !== void 0 && args[0] !== void 0;
|
|
1665
|
+
if (code === "schema_immutable" && current.command === "schemas" && args[1] !== void 0) return theirs("conflict", code, `Can't ${doing()}.`, [{
|
|
1666
|
+
instruction: "See what it's registered as",
|
|
1667
|
+
argv: [
|
|
1668
|
+
...cli(),
|
|
1669
|
+
"schemas",
|
|
1670
|
+
"inspect",
|
|
1671
|
+
args[1]
|
|
1672
|
+
]
|
|
1673
|
+
}]);
|
|
1571
1674
|
return theirs("conflict", specific("conflict"), `Can't ${doing()}.`, newer ? [{
|
|
1572
1675
|
instruction: `Read what came after ${ref(flags.after)}`,
|
|
1573
1676
|
argv: [
|
|
@@ -1626,9 +1729,9 @@ function vercelBoard(url) {
|
|
|
1626
1729
|
...team ? { team } : {}
|
|
1627
1730
|
};
|
|
1628
1731
|
}
|
|
1629
|
-
/** Who the handle writes as: `--as`'s profile (with `--avatar`),
|
|
1732
|
+
/** Who the handle writes as: `--as`'s profile (with `--avatar`), or what the environment says (`BOARD_PROFILE`), else yourself. */
|
|
1630
1733
|
function profileFlag() {
|
|
1631
|
-
if (flags.
|
|
1734
|
+
if (flags.avatar !== void 0 && !flags.as) throw usage("--avatar is the avatar of the profile --as names: pass --as too.", { reason: "missing_arguments" });
|
|
1632
1735
|
if (!flags.as) return void 0;
|
|
1633
1736
|
return flags.avatar ? {
|
|
1634
1737
|
name: flags.as,
|
|
@@ -1650,7 +1753,7 @@ function connection(url = flags.url, options = {}) {
|
|
|
1650
1753
|
const board$1 = board({
|
|
1651
1754
|
backend: vercel({
|
|
1652
1755
|
...team !== void 0 ? { team } : {},
|
|
1653
|
-
...sending(options.token, options.can)
|
|
1756
|
+
...sending(options.token, options.can, options.headers)
|
|
1654
1757
|
}),
|
|
1655
1758
|
...name !== void 0 ? {
|
|
1656
1759
|
name,
|
|
@@ -1669,7 +1772,7 @@ function connection(url = flags.url, options = {}) {
|
|
|
1669
1772
|
if (onVercel) {
|
|
1670
1773
|
const board$3 = board({ backend: vercel({
|
|
1671
1774
|
...onVercel,
|
|
1672
|
-
...sending(options.token, options.can)
|
|
1775
|
+
...sending(options.token, options.can, options.headers)
|
|
1673
1776
|
}) });
|
|
1674
1777
|
return {
|
|
1675
1778
|
url: at,
|
|
@@ -1677,11 +1780,13 @@ function connection(url = flags.url, options = {}) {
|
|
|
1677
1780
|
board: profile !== void 0 ? board$3.as(profile) : board$3
|
|
1678
1781
|
};
|
|
1679
1782
|
}
|
|
1680
|
-
const
|
|
1783
|
+
const extra = {
|
|
1784
|
+
...options.headers,
|
|
1785
|
+
...options.can !== void 0 ? { "x-board-can": options.can } : {}
|
|
1786
|
+
};
|
|
1681
1787
|
const transport = connect(at, {
|
|
1682
1788
|
...options.token !== void 0 ? { token: options.token } : {},
|
|
1683
|
-
...
|
|
1684
|
-
...options.can !== void 0 ? { fetch: narrowing(options.can) } : {}
|
|
1789
|
+
...Object.keys(extra).length > 0 ? { fetch: withHeaders(extra) } : {}
|
|
1685
1790
|
});
|
|
1686
1791
|
const board$2 = board({ backend: http(at, { fetch: transport.fetch }) });
|
|
1687
1792
|
return {
|
|
@@ -1721,36 +1826,33 @@ function boardNameFlag(url, team) {
|
|
|
1721
1826
|
if (!isBoardName(given)) throw usage(`${from} ${given} isn't a board's name: one is 1 to 64 characters.`);
|
|
1722
1827
|
return given;
|
|
1723
1828
|
}
|
|
1724
|
-
/** For Vercel's API, `token` in place of your own credentials
|
|
1725
|
-
function sending(token, can) {
|
|
1726
|
-
if (token === void 0 && can === void 0) return {};
|
|
1829
|
+
/** For Vercel's API, `token` in place of your own credentials, `can` narrowing them, and `headers` beside them. */
|
|
1830
|
+
function sending(token, can, extra = {}) {
|
|
1831
|
+
if (token === void 0 && can === void 0 && Object.keys(extra).length === 0) return {};
|
|
1727
1832
|
return { fetch: (input, init = {}) => {
|
|
1728
1833
|
const headers = new Headers(init.headers ?? (input instanceof Request ? input.headers : void 0));
|
|
1729
1834
|
if (token !== void 0) headers.set("authorization", `Bearer ${token}`);
|
|
1730
1835
|
if (can !== void 0) headers.set("x-board-can", can);
|
|
1836
|
+
for (const [name, value] of Object.entries(extra)) headers.set(name, value);
|
|
1731
1837
|
return (token === void 0 ? credentialed() : globalThis.fetch)(input, {
|
|
1732
1838
|
...init,
|
|
1733
1839
|
headers
|
|
1734
1840
|
});
|
|
1735
1841
|
} };
|
|
1736
1842
|
}
|
|
1737
|
-
/** A fetch that
|
|
1738
|
-
function
|
|
1843
|
+
/** A fetch that adds `headers` to each request to a board on HTTP, as a proxy holding its credentials would: `x-board-can`, say. */
|
|
1844
|
+
function withHeaders(headers) {
|
|
1739
1845
|
return (input, init) => {
|
|
1740
1846
|
const request = new Request(input, init);
|
|
1741
|
-
request.headers.set(
|
|
1847
|
+
for (const [name, value] of Object.entries(headers)) request.headers.set(name, value);
|
|
1742
1848
|
return globalThis.fetch(request);
|
|
1743
1849
|
};
|
|
1744
1850
|
}
|
|
1745
1851
|
/** A handle on the board this command talks to: `vb()`'s, as `--as` says, or the one `connection()` finds. */
|
|
1746
1852
|
function client() {
|
|
1747
1853
|
if (!io.board) return connection().board;
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
name: flags.as,
|
|
1751
|
-
avatar: flags.avatar
|
|
1752
|
-
} : flags.as);
|
|
1753
|
-
return io.board;
|
|
1854
|
+
const profile = profileFlag();
|
|
1855
|
+
return profile === void 0 ? io.board : io.board.as(profile);
|
|
1754
1856
|
}
|
|
1755
1857
|
async function readStdin() {
|
|
1756
1858
|
const chunks = [];
|
|
@@ -1762,23 +1864,6 @@ function hookAgents(names) {
|
|
|
1762
1864
|
for (const name of names) if (!known.includes(name)) throw usage(`Unknown agent ${name}. The agents are ${known.join(", ")}.`);
|
|
1763
1865
|
return names.length ? names : known;
|
|
1764
1866
|
}
|
|
1765
|
-
/** Says what a write that went through had to say: in its JSON result with `--json`, on stderr otherwise. */
|
|
1766
|
-
function warn(warning) {
|
|
1767
|
-
if (flags.json) warnings.push(warning);
|
|
1768
|
-
else if (app.onWarning) app.onWarning(warning);
|
|
1769
|
-
else io.error(`${terminalText(`warning: ${warning.message}`)}\n`);
|
|
1770
|
-
}
|
|
1771
|
-
/** A write went through, but some handles in it matched no one: they stayed plain text. */
|
|
1772
|
-
function warnUnknownMentions(handles) {
|
|
1773
|
-
if (!handles?.length) return;
|
|
1774
|
-
const names = handles.map((handle) => `@${handle}`);
|
|
1775
|
-
const list = names.length === 1 ? names[0] : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
|
|
1776
|
-
const one = names.length === 1;
|
|
1777
|
-
warn({
|
|
1778
|
-
reason: "unknown_mention",
|
|
1779
|
-
message: `${list} ${one ? "matches" : "match"} no one on the board, so ${one ? "it stays" : "they stay"} plain text and ${one ? "notifies" : "notify"} no one.`
|
|
1780
|
-
});
|
|
1781
|
-
}
|
|
1782
1867
|
/** A post or reply: its ID, or with `--json`, the message. */
|
|
1783
1868
|
function printMessage(message) {
|
|
1784
1869
|
if (flags.json) result({
|
|
@@ -1845,15 +1930,13 @@ async function run(command, args) {
|
|
|
1845
1930
|
});
|
|
1846
1931
|
return 0;
|
|
1847
1932
|
}
|
|
1848
|
-
|
|
1849
|
-
out(`${name} (${me.actor})`);
|
|
1933
|
+
out(`${who(me)} (${me.actor})`);
|
|
1850
1934
|
const rows = [["board", url]];
|
|
1851
1935
|
if (source) rows.push(["source", source]);
|
|
1852
1936
|
if (me.expiresAt) {
|
|
1853
1937
|
const minutes = Math.max(0, Math.round((Date.parse(me.expiresAt) - Date.now()) / 6e4));
|
|
1854
1938
|
rows.push(["token", `expires in ${Math.floor(minutes / 60)}h ${minutes % 60}m`]);
|
|
1855
1939
|
}
|
|
1856
|
-
if (me.session) rows.push(["session", me.session]);
|
|
1857
1940
|
(me.can === void 0 ? [] : formatAccess(me.can)).forEach((line, index) => rows.push([index === 0 ? "can" : "", line]));
|
|
1858
1941
|
const width = Math.max(...rows.map(([subject]) => subject.length));
|
|
1859
1942
|
for (const [subject, value] of rows) out(`${subject.padEnd(width)} ${value}`);
|
|
@@ -1872,13 +1955,10 @@ async function run(command, args) {
|
|
|
1872
1955
|
argv: rerun("--url", "<URL>")
|
|
1873
1956
|
}]
|
|
1874
1957
|
});
|
|
1875
|
-
const
|
|
1876
|
-
const withToken = io.board ? {} : { withToken: (secret) => connection(tokenUrl, { token: secret }).board };
|
|
1877
|
-
const withCan = io.board ? {} : { withCan: (can) => connection(void 0, { can }).board };
|
|
1958
|
+
const withHeaders = io.board ? {} : { withHeaders: (headers) => connection(void 0, { headers }).board };
|
|
1878
1959
|
const report = await conformance(client(), {
|
|
1879
1960
|
...flags.channel ? { channel: flags.channel } : {},
|
|
1880
|
-
...
|
|
1881
|
-
...withCan
|
|
1961
|
+
...withHeaders
|
|
1882
1962
|
});
|
|
1883
1963
|
if (flags.json) result(report);
|
|
1884
1964
|
else out(formatConformance(report));
|
|
@@ -1924,7 +2004,7 @@ async function run(command, args) {
|
|
|
1924
2004
|
case "actors": {
|
|
1925
2005
|
const actors = await client().actors();
|
|
1926
2006
|
if (flags.json) return result({ actors }), 0;
|
|
1927
|
-
for (const actor of actors) out(`@${actor.handle} ${actor
|
|
2007
|
+
for (const actor of actors) out(`@${actor.handle} ${actorName(actor)} ${actor.id}`);
|
|
1928
2008
|
return 0;
|
|
1929
2009
|
}
|
|
1930
2010
|
case "read": {
|
|
@@ -1968,6 +2048,7 @@ async function run(command, args) {
|
|
|
1968
2048
|
class: "not_found",
|
|
1969
2049
|
reason: "channel_not_found",
|
|
1970
2050
|
message: `Couldn't find channel ${target}.${guess ? ` Did you mean ${guess}?` : ""}`,
|
|
2051
|
+
details: ["A channel appears with its first post: one nobody has posted in yet is not there to read."],
|
|
1971
2052
|
next: [{
|
|
1972
2053
|
instruction: "See its channels",
|
|
1973
2054
|
argv: [...cli(), "channels"]
|
|
@@ -1979,11 +2060,13 @@ async function run(command, args) {
|
|
|
1979
2060
|
const count = `${page.threads.length} ${page.threads.length === 1 ? "thread" : "threads"}`;
|
|
1980
2061
|
out(`${target ?? "all channels"} · ${count} · cursor ${page.cursor}${page.threads.length ? "\n" : ""}`);
|
|
1981
2062
|
if (page.threads.length) out(formatThreadSummaries(page.threads, { channel: !target || target.endsWith("/") }));
|
|
2063
|
+
out(`\nnew since then: ${commandLine(rerunWithout(["--after"], "--after", String(page.cursor)))}`);
|
|
1982
2064
|
return 0;
|
|
1983
2065
|
}
|
|
1984
2066
|
case "post": {
|
|
1985
2067
|
const [target, body] = args;
|
|
1986
2068
|
if (!target) throw usage("Missing the channel or message to post to.", { reason: "missing_arguments" });
|
|
2069
|
+
oneText("post", target, args.slice(2));
|
|
1987
2070
|
const re = isMessageRef(target) ? messageId(target) : void 0;
|
|
1988
2071
|
if (re !== void 0 && flags.sync?.length) throw usage("Can't use --sync on a reply. It syncs whole threads.", { next: [{
|
|
1989
2072
|
instruction: "Sync the thread instead",
|
|
@@ -1997,41 +2080,38 @@ async function run(command, args) {
|
|
|
1997
2080
|
if (flags.sync?.length && flags["no-sync"]) throw usage("Can't use --sync with --no-sync.");
|
|
1998
2081
|
if (re === void 0 && flags.after !== void 0) throw usage("Can't use --after on a new thread. It's for replies: the thread's newest message.");
|
|
1999
2082
|
const board = client();
|
|
2000
|
-
const
|
|
2083
|
+
const said = await content(body, { optional: !!flags.attach?.length });
|
|
2001
2084
|
const files = await attachments(board);
|
|
2002
2085
|
const options = {
|
|
2003
|
-
text:
|
|
2086
|
+
text: said,
|
|
2004
2087
|
...files.length ? { attachments: files } : {},
|
|
2005
2088
|
...flags.label?.length ? { labels: labelPairs(flags.label) } : {},
|
|
2006
2089
|
...flags["idempotency-key"] ? { id: flags["idempotency-key"] } : {},
|
|
2007
2090
|
...flags["no-sync"] ? { noSync: true } : {}
|
|
2008
2091
|
};
|
|
2009
|
-
|
|
2092
|
+
printMessage(re === void 0 ? await board.post(target, {
|
|
2010
2093
|
...options,
|
|
2011
2094
|
...flags.sync?.length ? { sync: flags.sync } : {}
|
|
2012
2095
|
}) : await board.reply(re, {
|
|
2013
2096
|
...options,
|
|
2014
2097
|
...flags.after !== void 0 ? { after: messageId(flags.after) } : {}
|
|
2015
|
-
});
|
|
2016
|
-
warnUnknownMentions(message.unknownMentions);
|
|
2017
|
-
printMessage(message);
|
|
2098
|
+
}));
|
|
2018
2099
|
return 0;
|
|
2019
2100
|
}
|
|
2020
2101
|
case "reply": {
|
|
2021
2102
|
const id = messageId(args[0]);
|
|
2103
|
+
oneText("reply", args[0], args.slice(2));
|
|
2022
2104
|
const board = client();
|
|
2023
|
-
const
|
|
2105
|
+
const said = await content(args[1], { optional: !!flags.attach?.length });
|
|
2024
2106
|
const files = await attachments(board);
|
|
2025
|
-
|
|
2026
|
-
text:
|
|
2107
|
+
printMessage(await board.reply(id, {
|
|
2108
|
+
text: said,
|
|
2027
2109
|
...files.length ? { attachments: files } : {},
|
|
2028
2110
|
...flags.label?.length ? { labels: labelPairs(flags.label) } : {},
|
|
2029
2111
|
...flags["idempotency-key"] ? { id: flags["idempotency-key"] } : {},
|
|
2030
2112
|
...flags["no-sync"] ? { noSync: true } : {},
|
|
2031
2113
|
...flags.after !== void 0 ? { after: messageId(flags.after) } : {}
|
|
2032
|
-
});
|
|
2033
|
-
warnUnknownMentions(message.unknownMentions);
|
|
2034
|
-
printMessage(message);
|
|
2114
|
+
}));
|
|
2035
2115
|
return 0;
|
|
2036
2116
|
}
|
|
2037
2117
|
case "schedule": {
|
|
@@ -2051,11 +2131,11 @@ async function run(command, args) {
|
|
|
2051
2131
|
const times = flags.times === void 0 ? void 0 : Number(flags.times);
|
|
2052
2132
|
if (times !== void 0 && !(Number.isInteger(times) && times > 0)) throw usage(`--times takes a count, and ${flags.times} isn't one.`);
|
|
2053
2133
|
const board = client();
|
|
2054
|
-
const
|
|
2134
|
+
const said = await content(body, { optional: !!flags.attach?.length });
|
|
2055
2135
|
const files = await attachments(board);
|
|
2056
2136
|
const where = isMessageRef(target) ? { re: messageId(target) } : target;
|
|
2057
2137
|
const schedule = await board.schedule(where, {
|
|
2058
|
-
text:
|
|
2138
|
+
text: said,
|
|
2059
2139
|
...files.length ? { attachments: files } : {},
|
|
2060
2140
|
...flags.label?.length ? { labels: labelPairs(flags.label) } : {},
|
|
2061
2141
|
...flags["no-sync"] ? { noSync: true } : {},
|
|
@@ -2066,7 +2146,6 @@ async function run(command, args) {
|
|
|
2066
2146
|
...flags.for ? { for: flags.for } : {},
|
|
2067
2147
|
...times !== void 0 ? { times } : {}
|
|
2068
2148
|
});
|
|
2069
|
-
warnUnknownMentions(schedule.unknownMentions);
|
|
2070
2149
|
if (flags.json) result({
|
|
2071
2150
|
schedule,
|
|
2072
2151
|
outcome: "scheduled"
|
|
@@ -2102,7 +2181,7 @@ async function run(command, args) {
|
|
|
2102
2181
|
return 0;
|
|
2103
2182
|
}
|
|
2104
2183
|
if (verb === "update") {
|
|
2105
|
-
const id =
|
|
2184
|
+
const id = grantId(rest[0]);
|
|
2106
2185
|
if (rest.length > 1) throw usage(`grants update takes one grant: ${rest[1]} is one too many.`);
|
|
2107
2186
|
onlyPrincipalFlags("update");
|
|
2108
2187
|
const named = grantFlags(() => principalsIn(ordered, ["add-", "remove-"], ({ kind, value }) => {
|
|
@@ -2151,7 +2230,7 @@ async function run(command, args) {
|
|
|
2151
2230
|
return 0;
|
|
2152
2231
|
}
|
|
2153
2232
|
if (verb === "revoke") {
|
|
2154
|
-
const id =
|
|
2233
|
+
const id = grantId(rest[0]);
|
|
2155
2234
|
const { revoked } = await client().revokeGrant(id);
|
|
2156
2235
|
if (flags.json) result({
|
|
2157
2236
|
grant: id,
|
|
@@ -2162,44 +2241,58 @@ async function run(command, args) {
|
|
|
2162
2241
|
}
|
|
2163
2242
|
throw usage(`Unknown command ${verb} for ${named()} grants.`, { reason: "unknown_command" });
|
|
2164
2243
|
}
|
|
2165
|
-
case "
|
|
2244
|
+
case "schemas": {
|
|
2166
2245
|
const [verb, ...rest] = args;
|
|
2167
2246
|
if (verb === void 0 || verb === "list") {
|
|
2168
|
-
if (rest.length > 0) throw usage(`
|
|
2169
|
-
const list = await client().
|
|
2170
|
-
if (flags.json) return result({
|
|
2171
|
-
out(
|
|
2247
|
+
if (rest.length > 0) throw usage(`schemas list takes no arguments: ${rest[0]} is one too many.`);
|
|
2248
|
+
const list = await client().schemas();
|
|
2249
|
+
if (flags.json) return result({ schemas: list }), 0;
|
|
2250
|
+
out(formatSchemas(list));
|
|
2172
2251
|
return 0;
|
|
2173
2252
|
}
|
|
2174
|
-
if (verb
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2253
|
+
if (verb !== "inspect" && verb !== "create") throw usage(`Unknown command ${verb} for ${named()} schemas.`, { reason: "unknown_command" });
|
|
2254
|
+
const [id, extra] = rest;
|
|
2255
|
+
if (id === void 0) throw usage(`Missing the schema to ${verb}: its name and version, like sandbox@1.`, { reason: "missing_arguments" });
|
|
2256
|
+
if (extra !== void 0) throw usage(`schemas ${verb} takes one schema: ${extra} is one too many.`);
|
|
2257
|
+
const wanted = parseSchemaId(id);
|
|
2258
|
+
if (!wanted) throw usage(`${id} doesn't name a schema. One is name@version, like sandbox@1.`);
|
|
2259
|
+
if (verb === "inspect") {
|
|
2260
|
+
const schema = await client().schema(id);
|
|
2261
|
+
if (flags.json) result({ schema });
|
|
2262
|
+
else out(formatSchema(schema));
|
|
2182
2263
|
return 0;
|
|
2183
2264
|
}
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
const { token, secret } = await client().createToken({
|
|
2189
|
-
name,
|
|
2190
|
-
...flags.can !== void 0 ? { can: canFlag(flags.can) } : {},
|
|
2191
|
-
...flags.profile !== void 0 ? { profile: flags.profile } : {},
|
|
2192
|
-
...flags.session !== void 0 ? { session: flags.session } : {},
|
|
2193
|
-
...flags.expires !== void 0 ? { expires: flags.expires } : {}
|
|
2265
|
+
const { schema, created } = await client().createSchema({
|
|
2266
|
+
...wanted,
|
|
2267
|
+
schema: await definition(),
|
|
2268
|
+
...flags.description !== void 0 ? { description: flags.description } : {}
|
|
2194
2269
|
});
|
|
2195
2270
|
if (flags.json) result({
|
|
2196
|
-
|
|
2197
|
-
|
|
2271
|
+
schema,
|
|
2272
|
+
outcome: created ? "created" : "unchanged"
|
|
2198
2273
|
});
|
|
2199
|
-
else out(
|
|
2274
|
+
else out(created ? `created ${schema.id}` : `${schema.id} is already registered`);
|
|
2200
2275
|
return 0;
|
|
2201
2276
|
}
|
|
2202
2277
|
case "schedules": {
|
|
2278
|
+
if (args[0] !== void 0 && isScheduleId(args[0])) {
|
|
2279
|
+
const one = (await client().schedules({ all: true })).find((schedule) => schedule.id.toLowerCase() === args[0].toLowerCase());
|
|
2280
|
+
if (!one) throw new Failed({
|
|
2281
|
+
class: "not_found",
|
|
2282
|
+
reason: "schedule_not_found",
|
|
2283
|
+
message: `Couldn't find schedule ${args[0]}.`,
|
|
2284
|
+
next: [{
|
|
2285
|
+
instruction: "See every schedule, done and canceled ones too",
|
|
2286
|
+
argv: [
|
|
2287
|
+
...cli(),
|
|
2288
|
+
"schedules",
|
|
2289
|
+
"--all"
|
|
2290
|
+
]
|
|
2291
|
+
}]
|
|
2292
|
+
});
|
|
2293
|
+
if (flags.json) return result({ schedules: [one] }), 0;
|
|
2294
|
+
return out(formatSchedule(one)), 0;
|
|
2295
|
+
}
|
|
2203
2296
|
const list = await client().schedules({
|
|
2204
2297
|
...args[0] ? { re: messageId(args[0]) } : {},
|
|
2205
2298
|
...flags.by ? { by: flags.by.replace(/^@/, "") } : {},
|
|
@@ -2250,8 +2343,7 @@ async function run(command, args) {
|
|
|
2250
2343
|
case "hook": return 0;
|
|
2251
2344
|
case "edit": {
|
|
2252
2345
|
const id = messageId(args[0]);
|
|
2253
|
-
|
|
2254
|
-
warnUnknownMentions(unknownMentions);
|
|
2346
|
+
await client().edit(id, await content(args[1]), ifRevision());
|
|
2255
2347
|
printDone(id, "edited");
|
|
2256
2348
|
return 0;
|
|
2257
2349
|
}
|
|
@@ -2276,10 +2368,10 @@ async function run(command, args) {
|
|
|
2276
2368
|
}
|
|
2277
2369
|
case "label": {
|
|
2278
2370
|
const id = messageId(args[0]);
|
|
2279
|
-
const set = labelPairs(args.slice(1));
|
|
2371
|
+
const set = labelPairs(args.slice(1), void 0, "{value} has no value. To remove the label, --unset {key}.");
|
|
2280
2372
|
const unset = flags.unset ?? [];
|
|
2281
2373
|
if (Object.keys(set).length === 0 && unset.length === 0) throw usage("Missing the labels: k=v to set one, --unset k to remove one.", { reason: "missing_arguments" });
|
|
2282
|
-
const expected = labelPairs(flags.if, "--if takes key=value, and {value} isn't one. For a label that mustn't be set, --if-unset key.");
|
|
2374
|
+
const expected = labelPairs(flags.if, "--if takes key=value, and {value} isn't one. For a label that mustn't be set, --if-unset key.", null);
|
|
2283
2375
|
for (const key of flags["if-unset"] ?? []) {
|
|
2284
2376
|
if (Object.hasOwn(expected, key)) throw usage(`Can't use --if ${key}=… with --if-unset ${key}.`);
|
|
2285
2377
|
expected[key] = null;
|
|
@@ -2318,6 +2410,14 @@ async function run(command, args) {
|
|
|
2318
2410
|
case "download": {
|
|
2319
2411
|
const id = args[0];
|
|
2320
2412
|
if (!id) throw usage(`Missing the attachment to download: the ID \`${named()} read\` shows on a file line.`, { reason: "missing_arguments" });
|
|
2413
|
+
if (/[./]/.test(id)) throw usage(`${id} is a file's name, and download takes the attachment's ID: the last thing on its file line when you read its thread.`, { next: [{
|
|
2414
|
+
instruction: "Read the thread to see the ID",
|
|
2415
|
+
argv: [
|
|
2416
|
+
...cli(),
|
|
2417
|
+
"read",
|
|
2418
|
+
"<ID>"
|
|
2419
|
+
]
|
|
2420
|
+
}] });
|
|
2321
2421
|
const response = await client().download(id);
|
|
2322
2422
|
const data = new Uint8Array(await response.arrayBuffer());
|
|
2323
2423
|
if (args[1] === "-") return io.write(data), 0;
|
|
@@ -2393,8 +2493,15 @@ async function run(command, args) {
|
|
|
2393
2493
|
case "wait": {
|
|
2394
2494
|
const controller = new AbortController();
|
|
2395
2495
|
const stop = stopOn(controller);
|
|
2396
|
-
const timeout = flags.timeout ?? "30m";
|
|
2397
|
-
const
|
|
2496
|
+
const timeout = /^\d+$/.test(flags.timeout ?? "") ? `${flags.timeout}s` : flags.timeout ?? "30m";
|
|
2497
|
+
const thread = args[0] !== void 0 && isMessageRef(args[0]) && flags.re === void 0 ? args[0] : void 0;
|
|
2498
|
+
const root = thread === void 0 ? void 0 : (await client().thread(messageId(thread))).message.id;
|
|
2499
|
+
const waitsOn = root === void 0 ? filters(args[0]) : {
|
|
2500
|
+
...filters(),
|
|
2501
|
+
re: root,
|
|
2502
|
+
...flags.after === void 0 ? { after: messageId(thread) } : {}
|
|
2503
|
+
};
|
|
2504
|
+
const event = await client().wait(waitsOn, {
|
|
2398
2505
|
timeout,
|
|
2399
2506
|
signal: controller.signal
|
|
2400
2507
|
}).finally(stop.release);
|
|
@@ -2403,21 +2510,37 @@ async function run(command, args) {
|
|
|
2403
2510
|
throw new Failed({
|
|
2404
2511
|
class: "timeout",
|
|
2405
2512
|
reason: "timeout",
|
|
2406
|
-
message: `Nothing matched within ${timeout}
|
|
2513
|
+
message: `Nothing matched within ${timeout}.`,
|
|
2514
|
+
details: [waitsOn.after === void 0 ? "wait sees only what arrives after it starts. For what is already there, read, or pass --after <id>." : `Nothing came after ${waitsOn.after}.`],
|
|
2515
|
+
next: [{
|
|
2516
|
+
instruction: "See what is there now",
|
|
2517
|
+
argv: [
|
|
2518
|
+
...cli(),
|
|
2519
|
+
"read",
|
|
2520
|
+
...thread ?? flags.re ?? args[0] ? [thread ?? flags.re ?? args[0]] : []
|
|
2521
|
+
]
|
|
2522
|
+
}]
|
|
2407
2523
|
});
|
|
2408
2524
|
}
|
|
2409
2525
|
if (flags.json) result({ event });
|
|
2410
|
-
else
|
|
2526
|
+
else {
|
|
2527
|
+
out(formatEvent(event));
|
|
2528
|
+
out(`next: ${commandLine(rerunWithout(["--after"], "--after", String(event.cursor)))}`);
|
|
2529
|
+
}
|
|
2411
2530
|
return 0;
|
|
2412
2531
|
}
|
|
2413
|
-
case "inspect": return (await import("./inspect-
|
|
2532
|
+
case "inspect": return (await import("./inspect-BsF3mYMY.mjs")).inspect(context());
|
|
2414
2533
|
default: {
|
|
2415
2534
|
const own = app.commands[command];
|
|
2416
2535
|
if (own) return own.run(args, context());
|
|
2417
2536
|
const guess = closest(command, [...commands.flatMap((known) => [known.name, ...known.aliases ?? []]), ...Object.keys(app.commands)]);
|
|
2418
|
-
|
|
2537
|
+
const said = Object.hasOwn(OTHER_NAMES, command.toLowerCase()) ? OTHER_NAMES[command.toLowerCase()] : void 0;
|
|
2538
|
+
throw usage(`Unknown command ${command} for ${named()}.${said ? "" : guess ? ` Did you mean ${guess}?` : ""}`, {
|
|
2419
2539
|
reason: "unknown_command",
|
|
2420
|
-
next: [{
|
|
2540
|
+
next: [...said ? [{
|
|
2541
|
+
instruction: said.instruction,
|
|
2542
|
+
argv: [...cli(), ...said.argv]
|
|
2543
|
+
}] : [], {
|
|
2421
2544
|
instruction: "See all commands",
|
|
2422
2545
|
argv: [...cli(), "--help"]
|
|
2423
2546
|
}]
|
|
@@ -2425,6 +2548,254 @@ async function run(command, args) {
|
|
|
2425
2548
|
}
|
|
2426
2549
|
}
|
|
2427
2550
|
}
|
|
2551
|
+
/** Words for a command this CLI names otherwise, and the command they mean. */
|
|
2552
|
+
const OTHER_NAMES = {
|
|
2553
|
+
search: {
|
|
2554
|
+
instruction: "Search is a filter on read",
|
|
2555
|
+
argv: [
|
|
2556
|
+
"read",
|
|
2557
|
+
"<CHANNEL>",
|
|
2558
|
+
"--text",
|
|
2559
|
+
"<PHRASE>"
|
|
2560
|
+
]
|
|
2561
|
+
},
|
|
2562
|
+
find: {
|
|
2563
|
+
instruction: "Search is a filter on read",
|
|
2564
|
+
argv: [
|
|
2565
|
+
"read",
|
|
2566
|
+
"<CHANNEL>",
|
|
2567
|
+
"--text",
|
|
2568
|
+
"<PHRASE>"
|
|
2569
|
+
]
|
|
2570
|
+
},
|
|
2571
|
+
grep: {
|
|
2572
|
+
instruction: "Search is a filter on read",
|
|
2573
|
+
argv: [
|
|
2574
|
+
"read",
|
|
2575
|
+
"<CHANNEL>",
|
|
2576
|
+
"--text",
|
|
2577
|
+
"<PHRASE>"
|
|
2578
|
+
]
|
|
2579
|
+
},
|
|
2580
|
+
list: {
|
|
2581
|
+
instruction: "List a channel's threads with read",
|
|
2582
|
+
argv: ["read", "<CHANNEL>"]
|
|
2583
|
+
},
|
|
2584
|
+
ls: {
|
|
2585
|
+
instruction: "List a channel's threads with read",
|
|
2586
|
+
argv: ["read", "<CHANNEL>"]
|
|
2587
|
+
},
|
|
2588
|
+
threads: {
|
|
2589
|
+
instruction: "List a channel's threads with read",
|
|
2590
|
+
argv: ["read", "<CHANNEL>"]
|
|
2591
|
+
},
|
|
2592
|
+
messages: {
|
|
2593
|
+
instruction: "Read one thread, every message",
|
|
2594
|
+
argv: ["read", "<ID>"]
|
|
2595
|
+
},
|
|
2596
|
+
thread: {
|
|
2597
|
+
instruction: "Read one thread, every message",
|
|
2598
|
+
argv: ["read", "<ID>"]
|
|
2599
|
+
},
|
|
2600
|
+
show: {
|
|
2601
|
+
instruction: "Read one thread, every message",
|
|
2602
|
+
argv: ["read", "<ID>"]
|
|
2603
|
+
},
|
|
2604
|
+
get: {
|
|
2605
|
+
instruction: "Read one thread, every message",
|
|
2606
|
+
argv: ["read", "<ID>"]
|
|
2607
|
+
},
|
|
2608
|
+
view: {
|
|
2609
|
+
instruction: "Read one thread, every message",
|
|
2610
|
+
argv: ["read", "<ID>"]
|
|
2611
|
+
},
|
|
2612
|
+
history: {
|
|
2613
|
+
instruction: "Read one thread, every message",
|
|
2614
|
+
argv: ["read", "<ID>"]
|
|
2615
|
+
},
|
|
2616
|
+
send: {
|
|
2617
|
+
instruction: "Start a thread with post",
|
|
2618
|
+
argv: [
|
|
2619
|
+
"post",
|
|
2620
|
+
"<CHANNEL>",
|
|
2621
|
+
"<TEXT>"
|
|
2622
|
+
]
|
|
2623
|
+
},
|
|
2624
|
+
create: {
|
|
2625
|
+
instruction: "Start a thread with post",
|
|
2626
|
+
argv: [
|
|
2627
|
+
"post",
|
|
2628
|
+
"<CHANNEL>",
|
|
2629
|
+
"<TEXT>"
|
|
2630
|
+
]
|
|
2631
|
+
},
|
|
2632
|
+
comment: {
|
|
2633
|
+
instruction: "Reply in a thread",
|
|
2634
|
+
argv: [
|
|
2635
|
+
"reply",
|
|
2636
|
+
"<ID>",
|
|
2637
|
+
"<TEXT>"
|
|
2638
|
+
]
|
|
2639
|
+
},
|
|
2640
|
+
answer: {
|
|
2641
|
+
instruction: "Reply in a thread",
|
|
2642
|
+
argv: [
|
|
2643
|
+
"reply",
|
|
2644
|
+
"<ID>",
|
|
2645
|
+
"<TEXT>"
|
|
2646
|
+
]
|
|
2647
|
+
},
|
|
2648
|
+
update: {
|
|
2649
|
+
instruction: "Change a message's text with edit",
|
|
2650
|
+
argv: [
|
|
2651
|
+
"edit",
|
|
2652
|
+
"<ID>",
|
|
2653
|
+
"<TEXT>"
|
|
2654
|
+
]
|
|
2655
|
+
},
|
|
2656
|
+
remove: {
|
|
2657
|
+
instruction: "Delete a message",
|
|
2658
|
+
argv: ["delete", "<ID>"]
|
|
2659
|
+
},
|
|
2660
|
+
rm: {
|
|
2661
|
+
instruction: "Delete a message",
|
|
2662
|
+
argv: ["delete", "<ID>"]
|
|
2663
|
+
},
|
|
2664
|
+
cancel: {
|
|
2665
|
+
instruction: "Cancel a schedule",
|
|
2666
|
+
argv: [
|
|
2667
|
+
"schedule",
|
|
2668
|
+
"cancel",
|
|
2669
|
+
"<SCHEDULE>"
|
|
2670
|
+
]
|
|
2671
|
+
},
|
|
2672
|
+
unschedule: {
|
|
2673
|
+
instruction: "Cancel a schedule",
|
|
2674
|
+
argv: [
|
|
2675
|
+
"schedule",
|
|
2676
|
+
"cancel",
|
|
2677
|
+
"<SCHEDULE>"
|
|
2678
|
+
]
|
|
2679
|
+
},
|
|
2680
|
+
remind: {
|
|
2681
|
+
instruction: "Post later with schedule",
|
|
2682
|
+
argv: [
|
|
2683
|
+
"schedule",
|
|
2684
|
+
"<TARGET>",
|
|
2685
|
+
"<TEXT>",
|
|
2686
|
+
"--in",
|
|
2687
|
+
"<DURATION>"
|
|
2688
|
+
]
|
|
2689
|
+
},
|
|
2690
|
+
attach: {
|
|
2691
|
+
instruction: "Attach a file to a post",
|
|
2692
|
+
argv: [
|
|
2693
|
+
"post",
|
|
2694
|
+
"<TARGET>",
|
|
2695
|
+
"<TEXT>",
|
|
2696
|
+
"--attach",
|
|
2697
|
+
"<FILE>"
|
|
2698
|
+
]
|
|
2699
|
+
},
|
|
2700
|
+
upload: {
|
|
2701
|
+
instruction: "Attach a file to a post",
|
|
2702
|
+
argv: [
|
|
2703
|
+
"post",
|
|
2704
|
+
"<TARGET>",
|
|
2705
|
+
"<TEXT>",
|
|
2706
|
+
"--attach",
|
|
2707
|
+
"<FILE>"
|
|
2708
|
+
]
|
|
2709
|
+
},
|
|
2710
|
+
claim: {
|
|
2711
|
+
instruction: "Claim a thread with a label, unless someone has",
|
|
2712
|
+
argv: [
|
|
2713
|
+
"label",
|
|
2714
|
+
"<ID>",
|
|
2715
|
+
"owner=<YOU>",
|
|
2716
|
+
"--if-unset",
|
|
2717
|
+
"owner"
|
|
2718
|
+
]
|
|
2719
|
+
},
|
|
2720
|
+
assign: {
|
|
2721
|
+
instruction: "Claim a thread with a label, unless someone has",
|
|
2722
|
+
argv: [
|
|
2723
|
+
"label",
|
|
2724
|
+
"<ID>",
|
|
2725
|
+
"owner=<YOU>",
|
|
2726
|
+
"--if-unset",
|
|
2727
|
+
"owner"
|
|
2728
|
+
]
|
|
2729
|
+
},
|
|
2730
|
+
tag: {
|
|
2731
|
+
instruction: "Set labels on a message",
|
|
2732
|
+
argv: [
|
|
2733
|
+
"label",
|
|
2734
|
+
"<ID>",
|
|
2735
|
+
"<KEY=VALUE>"
|
|
2736
|
+
]
|
|
2737
|
+
},
|
|
2738
|
+
labels: {
|
|
2739
|
+
instruction: "Set labels on a message",
|
|
2740
|
+
argv: [
|
|
2741
|
+
"label",
|
|
2742
|
+
"<ID>",
|
|
2743
|
+
"<KEY=VALUE>"
|
|
2744
|
+
]
|
|
2745
|
+
},
|
|
2746
|
+
mentions: {
|
|
2747
|
+
instruction: "Mentions are a filter on read and wait",
|
|
2748
|
+
argv: ["read", "--mentions"]
|
|
2749
|
+
},
|
|
2750
|
+
watch: {
|
|
2751
|
+
instruction: "Block for the next match with wait, or follow live with tail",
|
|
2752
|
+
argv: [
|
|
2753
|
+
"wait",
|
|
2754
|
+
"<CHANNEL>",
|
|
2755
|
+
"--after",
|
|
2756
|
+
"<CURSOR>"
|
|
2757
|
+
]
|
|
2758
|
+
},
|
|
2759
|
+
follow: {
|
|
2760
|
+
instruction: "Block for the next match with wait, or follow live with tail",
|
|
2761
|
+
argv: [
|
|
2762
|
+
"wait",
|
|
2763
|
+
"<CHANNEL>",
|
|
2764
|
+
"--after",
|
|
2765
|
+
"<CURSOR>"
|
|
2766
|
+
]
|
|
2767
|
+
},
|
|
2768
|
+
subscribe: {
|
|
2769
|
+
instruction: "Block for the next match with wait, or follow live with tail",
|
|
2770
|
+
argv: [
|
|
2771
|
+
"wait",
|
|
2772
|
+
"<CHANNEL>",
|
|
2773
|
+
"--after",
|
|
2774
|
+
"<CURSOR>"
|
|
2775
|
+
]
|
|
2776
|
+
},
|
|
2777
|
+
listen: {
|
|
2778
|
+
instruction: "Block for the next match with wait, or follow live with tail",
|
|
2779
|
+
argv: [
|
|
2780
|
+
"wait",
|
|
2781
|
+
"<CHANNEL>",
|
|
2782
|
+
"--after",
|
|
2783
|
+
"<CURSOR>"
|
|
2784
|
+
]
|
|
2785
|
+
},
|
|
2786
|
+
users: {
|
|
2787
|
+
instruction: "See who is on the board",
|
|
2788
|
+
argv: ["actors"]
|
|
2789
|
+
},
|
|
2790
|
+
members: {
|
|
2791
|
+
instruction: "See who is on the board",
|
|
2792
|
+
argv: ["actors"]
|
|
2793
|
+
},
|
|
2794
|
+
me: {
|
|
2795
|
+
instruction: "See who you are",
|
|
2796
|
+
argv: ["whoami"]
|
|
2797
|
+
}
|
|
2798
|
+
};
|
|
2428
2799
|
/**
|
|
2429
2800
|
* Aborts `controller` on the run's signal, or Ctrl-C without one. `release` stops listening, and
|
|
2430
2801
|
* `interrupted` says whether Ctrl-C stopped it.
|
|
@@ -2501,7 +2872,7 @@ async function runOnce(argv, options) {
|
|
|
2501
2872
|
args
|
|
2502
2873
|
};
|
|
2503
2874
|
if (io.board) {
|
|
2504
|
-
const given = flags.url ? "url" : flags.name !== void 0 ? "name" : flags.ensure ? "ensure" :
|
|
2875
|
+
const given = flags.url ? "url" : flags.name !== void 0 ? "name" : flags.ensure ? "ensure" : null;
|
|
2505
2876
|
if (given) throw usage(`--${given} doesn't apply in-process: the board handle you pass says which board and who.`, { next: [] });
|
|
2506
2877
|
if (command !== void 0 && MACHINE.has(command)) throw usage(`${command} isn't available in-process: it's about the machine ${named()} runs on.`, {
|
|
2507
2878
|
reason: "not_available",
|