@vercel/board 0.40.0 → 0.42.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 +1 -1
- package/dist/{access-Bl_k_Hpa.mjs → access-BgBiaCyx.mjs} +2 -2
- package/dist/access.d.mts +6 -6
- package/dist/access.mjs +5 -5
- package/dist/{actors-yBRWTpt5.mjs → actors-DkZsnMgA.mjs} +59 -40
- package/dist/{auth-DtmZzlHm.d.mts → auth-Bn8J_1F2.d.mts} +12 -30
- package/dist/{auth-C8URZHLx.mjs → auth-Ft4AJptx.mjs} +9 -19
- package/dist/{backend-BW5NbBsp.d.mts → backend-DMrK55mU.d.mts} +137 -48
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{chat-provider-1WKsLEnM.mjs → chat-provider-CPZg2MQb.mjs} +2 -2
- package/dist/{chat-provider-Bbb9JguG.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 +10 -5
- package/dist/cli-embedded.mjs +8 -6
- package/dist/cli.mjs +8 -13
- package/dist/{commands-BJLocuXj.d.mts → commands-CrEVjASe.d.mts} +8 -30
- package/dist/{commands-D6VWegVY.mjs → commands-QRD0U9AQ.mjs} +30 -101
- package/dist/{conformance-BWhZ0k8T.mjs → conformance-BORt5nky.mjs} +139 -109
- package/dist/conformance.d.mts +9 -8
- package/dist/conformance.mjs +1 -1
- package/dist/digest-CKC0Rmy1.mjs +4 -0
- package/dist/{engine-Djif8XVk.mjs → engine-BVHSH2Kn.mjs} +11 -12
- package/dist/{errors-CNRJqUuL.mjs → errors-DUzpDSrJ.mjs} +112 -30
- package/dist/{events-C6HwB046.mjs → events-BT8y_81j.mjs} +2 -2
- package/dist/{exports-C2OWIbLU.mjs → exports-BfNXPHN_.mjs} +473 -174
- package/dist/exports-Bw_OYNRl.d.mts +4 -0
- package/dist/{external-CHDxWIVf.mjs → external-DymyhUzl.mjs} +1 -1
- package/dist/{index-Cuxbz_E0.d.mts → index-CydxnBND.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +6 -5
- package/dist/index.node.d.mts +6 -6
- package/dist/index.node.mjs +3 -3
- package/dist/inspect/app.js +41 -41
- package/dist/inspect/engine.js +2 -2
- package/dist/{inspect-cGcP8ZO9.mjs → inspect-CniRRiJ2.mjs} +6 -6
- package/dist/inspect-HlHh7OXa.mjs +2 -0
- package/dist/{local-CsleYuyM.mjs → local-CWLPYoiY.mjs} +130 -359
- package/dist/{main-D97xuqWZ.mjs → main-aVEEoc60.mjs} +429 -139
- package/dist/{memory-BvVoglGv.mjs → memory-DhduVbUu.mjs} +2 -2
- package/dist/{mentions-CT2bN5eP.mjs → mentions-DfZGp3B-.mjs} +1 -1
- package/dist/{middleware-BF9vnPPS.mjs → middleware-0DUFrav-.mjs} +2 -2
- package/dist/{origin-DLCmrwmE.mjs → origin-DAyYeDuW.mjs} +7 -36
- package/dist/{page-6BTCZWGY.mjs → page-BD6ygU49.mjs} +2 -2
- package/dist/page-BiJVe-7R.mjs +2 -0
- package/dist/{provider-YqkF1E2k.d.mts → provider-dY54GFNz.d.mts} +1 -25
- package/dist/{routes-CAjd5ARa.d.mts → routes-By9lmvUD.d.mts} +1 -63
- package/dist/{schemas-AZkxk06N.mjs → schemas-DAzSsgWk.mjs} +8 -3
- package/dist/{serve-Cs-e0Jke.mjs → serve-BnBqi0sw.mjs} +5 -5
- package/dist/{server-CIfMdIt3.mjs → server-Bcpkt6TS.mjs} +79 -131
- package/dist/{serving-B4l0nLng.mjs → serving-hcxzaCCO.mjs} +1 -1
- package/dist/{sql-Bv-RQu8n.mjs → sql-P9g-rLIF.mjs} +3 -3
- package/dist/{sqlite-D4mkYihG.mjs → sqlite-B3rCcIof.mjs} +2 -2
- package/dist/{sqlite-db-BraLvHtf.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 +3 -3
- package/dist/sync-slack.mjs +4 -4
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{tokens-CrrXAVGz.mjs → tokens-BSMpTPEe.mjs} +4 -4
- package/docs/01-board/01-mounting.md +12 -17
- package/docs/01-board/03-identity.md +45 -39
- package/docs/01-board/04-messages.md +3 -1
- package/docs/01-board/05-reading.md +8 -2
- package/docs/01-board/06-watchers.md +15 -10
- package/docs/01-board/07-schedules.md +6 -2
- package/docs/01-board/09-access.md +59 -111
- package/docs/02-sync/01-overview.md +5 -2
- package/docs/02-sync/03-slack.md +12 -12
- 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 +59 -90
- package/docs/04-reference/02-board.md +53 -37
- package/docs/04-reference/03-http.md +32 -53
- package/docs/04-reference/05-conformance.md +37 -18
- package/docs/index.md +4 -4
- package/package.json +1 -1
- package/dist/digest-D32GV_mX.mjs +0 -4
- package/dist/exports-FyRBIAMs.d.mts +0 -4
- package/dist/inspect-CLy6FrOZ.mjs +0 -2
- package/dist/page-BnY8FhPn.mjs +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-
|
|
1
|
+
import { g as DIRECT_UPLOAD_BYTES_MAX, u as BoardError, y as fileSize } from "./errors-DUzpDSrJ.mjs";
|
|
2
|
+
import { f as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-DAzSsgWk.mjs";
|
|
3
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-
|
|
4
|
+
import { h as VERSION, s as withMentions } from "./origin-DAyYeDuW.mjs";
|
|
5
5
|
import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
6
|
-
import { l as shownName } from "./middleware-
|
|
7
|
-
import { r as PERMISSIONS
|
|
8
|
-
import {
|
|
9
|
-
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-
|
|
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-
|
|
11
|
-
import { t as conformance } from "./conformance-
|
|
6
|
+
import { l as shownName } from "./middleware-0DUFrav-.mjs";
|
|
7
|
+
import { r as PERMISSIONS } from "./access-BgBiaCyx.mjs";
|
|
8
|
+
import { a as isApiMessageId, n as isBoardName } from "./exports-BfNXPHN_.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-Bcpkt6TS.mjs";
|
|
11
|
+
import { t as conformance } from "./conformance-BORt5nky.mjs";
|
|
12
12
|
import { t as displayText } from "./bots-CGkO76qH.mjs";
|
|
13
13
|
import { spawn } from "node:child_process";
|
|
14
14
|
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
@@ -427,14 +427,6 @@ function formatAccess(access) {
|
|
|
427
427
|
return `${pattern.padEnd(width)} ${permissions.includes("manage") ? "all" : permissions.length === 0 ? "nothing" : permissions.join(" ")}`;
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
|
-
/** What a grant or token may do, as `--can` takes it: `dev/=read,post;ci/=read`, or `all`. */
|
|
431
|
-
function formatCan(can) {
|
|
432
|
-
const patterns = Object.keys(can);
|
|
433
|
-
if (patterns.length === 1 && patterns[0] === "*" && can["*"].includes("manage")) return "all";
|
|
434
|
-
if (patterns.length === 0) return "nothing";
|
|
435
|
-
const permissions = (list) => list.includes("manage") ? "all" : list.length === 0 ? "none" : list.join(",");
|
|
436
|
-
return patterns.map((pattern) => `${pattern}=${permissions(can[pattern])}`).join(";");
|
|
437
|
-
}
|
|
438
430
|
/** Rows of cells, each column padded to its widest, two spaces apart. */
|
|
439
431
|
const table = (rows) => {
|
|
440
432
|
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
@@ -485,15 +477,6 @@ function formatGrants(grants) {
|
|
|
485
477
|
}
|
|
486
478
|
/** One grant as its row: `g3 --everyone security/=none`. */
|
|
487
479
|
const grantRow = (grant) => grantCells(grant).join(" ");
|
|
488
|
-
/** Each token on a row: its ID, its name, what it may do, and when it expires. */
|
|
489
|
-
function formatTokens(tokens, now = Date.now()) {
|
|
490
|
-
return table(tokens.map((token) => [
|
|
491
|
-
token.id,
|
|
492
|
-
token.name,
|
|
493
|
-
formatCan(token.can),
|
|
494
|
-
`expires ${until(token.expiresAt, now)}${token.profile !== null ? ` · as ${token.profile}` : ""}${token.parent !== null ? ` · minted with ${token.parent}` : ""}`
|
|
495
|
-
]));
|
|
496
|
-
}
|
|
497
480
|
/** `90m` → `1h30m`, `1d`: milliseconds as a duration flag would say them. */
|
|
498
481
|
function span(ms) {
|
|
499
482
|
const parts = [];
|
|
@@ -810,7 +793,7 @@ const flag = (option) => `${option.short ? `-${option.short}, ` : ""}--${option.
|
|
|
810
793
|
const shown = (list) => list.filter((option) => !option.hidden);
|
|
811
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. */
|
|
812
795
|
function listed(command) {
|
|
813
|
-
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])];
|
|
814
797
|
}
|
|
815
798
|
/** Every command, by group, then what the app adds (`serve`, `inspect`), and the options they share. */
|
|
816
799
|
function rootHelp(app, version) {
|
|
@@ -824,7 +807,7 @@ function rootHelp(app, version) {
|
|
|
824
807
|
const pad = padOf(listedSections.flat());
|
|
825
808
|
for (const section of listedSections) lines.push("", ...rows(section, pad));
|
|
826
809
|
const everywhere = shown(globalOptions).filter((option) => option.name !== "help" && option.name !== "version");
|
|
827
|
-
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`);
|
|
828
811
|
return lines.join("\n");
|
|
829
812
|
}
|
|
830
813
|
/** One command's page: its usage, what it does, and its arguments, subcommands, options, and examples. */
|
|
@@ -1261,23 +1244,45 @@ function ifRevision() {
|
|
|
1261
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.`);
|
|
1262
1245
|
return { revision: Number(given) };
|
|
1263
1246
|
}
|
|
1264
|
-
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.") {
|
|
1265
1248
|
const pairs = {};
|
|
1266
1249
|
for (const value of values ?? []) {
|
|
1267
1250
|
const at = value.indexOf("=");
|
|
1268
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)));
|
|
1269
1253
|
pairs[value.slice(0, at)] = value.slice(at + 1);
|
|
1270
1254
|
}
|
|
1271
1255
|
return pairs;
|
|
1272
1256
|
}
|
|
1273
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
|
+
/**
|
|
1274
1279
|
* A message's text: the argument, stdin for `-`, or the file `--text-file` names (`-` for stdin).
|
|
1275
1280
|
* `optional` when the message can go without, as one with `--attach` files can.
|
|
1276
1281
|
*/
|
|
1277
1282
|
async function text(value, { optional = false } = {}) {
|
|
1278
1283
|
const file = flags["text-file"];
|
|
1279
1284
|
if (file !== void 0) {
|
|
1280
|
-
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.");
|
|
1281
1286
|
if (file === "-") return (await io.stdin()).replace(/\n$/, "");
|
|
1282
1287
|
const data = await io.readFile(file).catch((error) => {
|
|
1283
1288
|
if (!(error instanceof Failed) || error.failure.reason !== "payload_too_large") throw error;
|
|
@@ -1305,6 +1310,18 @@ async function attachments(board) {
|
|
|
1305
1310
|
const files = [];
|
|
1306
1311
|
for (const path of flags.attach ?? []) {
|
|
1307
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
|
+
});
|
|
1308
1325
|
if (!data) throw usage(`Can't attach ${path}. There's no such file.`, {
|
|
1309
1326
|
reason: "file_not_found",
|
|
1310
1327
|
next: []
|
|
@@ -1322,38 +1339,23 @@ async function attachments(board) {
|
|
|
1322
1339
|
}));
|
|
1323
1340
|
return uploaded;
|
|
1324
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);
|
|
1325
1347
|
/** A schedule's ID as the board gave it: `s12`, or `sch_…` on Vercel's board. */
|
|
1326
1348
|
function scheduleId(value) {
|
|
1327
1349
|
if (value === void 0) throw usage("Missing the schedule ID, like s12.", { reason: "missing_arguments" });
|
|
1328
1350
|
if (!/^[^\s/]+$/.test(value)) throw usage(`${value} isn't a schedule ID like s12.`);
|
|
1329
1351
|
return value;
|
|
1330
1352
|
}
|
|
1331
|
-
/** A grant's
|
|
1332
|
-
function
|
|
1333
|
-
|
|
1334
|
-
if (value
|
|
1335
|
-
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.`);
|
|
1336
1357
|
return value;
|
|
1337
1358
|
}
|
|
1338
|
-
/**
|
|
1339
|
-
* A token's `--can`, as `x-board-can` writes it (`dev/=read,post;ci/=read`), repeated or
|
|
1340
|
-
* `;`-joined, with `none` for no permissions, as `all` is every one: `*=all;security/=none` closes a
|
|
1341
|
-
* subtree. `security/=` means the same. The board takes an empty list, so `none` never leaves the CLI.
|
|
1342
|
-
*/
|
|
1343
|
-
function canFlag(values) {
|
|
1344
|
-
const scope = values.flatMap((value) => value.split(";")).map((entry) => {
|
|
1345
|
-
const at = entry.indexOf("=");
|
|
1346
|
-
if (at === -1) return entry;
|
|
1347
|
-
const permissions = entry.slice(at + 1).split(",").map((permission) => permission.trim());
|
|
1348
|
-
if (permissions.includes("none") && permissions.length > 1) throw usage(`--can: none is no permissions, so it goes alone: ${entry.slice(0, at).trim()}=none.`);
|
|
1349
|
-
return permissions[0] === "none" ? entry.slice(0, at + 1) : entry;
|
|
1350
|
-
}).join(";");
|
|
1351
|
-
try {
|
|
1352
|
-
return parseCan(scope, "--can");
|
|
1353
|
-
} catch (error) {
|
|
1354
|
-
throw usage(`${error.message.replace(/, or all$/, ", all, or none")}.`);
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
1359
|
/** What a grant's flags say, or the misuse in them. */
|
|
1358
1360
|
function grantFlags(read) {
|
|
1359
1361
|
try {
|
|
@@ -1487,7 +1489,6 @@ function doing() {
|
|
|
1487
1489
|
case "schedules":
|
|
1488
1490
|
case "actors": return `list ${command}`;
|
|
1489
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";
|
|
1490
|
-
case "tokens": return a === "create" ? `mint token ${b ?? ""}`.trimEnd() : a === "revoke" ? `revoke token ${b}` : "list tokens";
|
|
1491
1492
|
case "schemas": return a === "create" ? `register schema ${b ?? ""}`.trimEnd() : a === "inspect" ? `read schema ${b ?? ""}`.trimEnd() : "list schemas";
|
|
1492
1493
|
case "sources": return b === void 0 ? "list sources" : `${b} ${c ?? "it"} on ${a}`;
|
|
1493
1494
|
case "download": return `download ${a ?? "the attachment"}`;
|
|
@@ -1522,7 +1523,7 @@ function missing() {
|
|
|
1522
1523
|
"schedule"
|
|
1523
1524
|
].includes(command) && isMessageRef(a)) return `message ${ref(a)}`;
|
|
1524
1525
|
if (command === "schedule" && a === "cancel" && b !== void 0) return `schedule ${b}`;
|
|
1525
|
-
if (
|
|
1526
|
+
if (command === "grants" && (a === "revoke" || a === "update") && b !== void 0) return `grant ${b}`;
|
|
1526
1527
|
if (command === "schemas" && a === "inspect" && b !== void 0) return `schema ${b}`;
|
|
1527
1528
|
if (command === "download") return `attachment ${a}`;
|
|
1528
1529
|
}
|
|
@@ -1581,19 +1582,12 @@ function failureOf(error) {
|
|
|
1581
1582
|
case "board_not_granted": return own("permission", "board_not_granted");
|
|
1582
1583
|
case "watchers_need_project": return own("permission", "watchers_need_project");
|
|
1583
1584
|
case "unsupported_principal": return own(status === 403 ? "permission" : "usage", "unsupported_principal");
|
|
1584
|
-
case "board_token_scope": return own("permission", "board_token_scope");
|
|
1585
1585
|
case "invalid_board_name": return own("usage", "invalid_arguments", [helpRecovery()]);
|
|
1586
1586
|
case "too_many_redirects": return own("network", "network_error");
|
|
1587
1587
|
case "invalid_duration": return own("usage", "invalid_arguments", [helpRecovery()]);
|
|
1588
1588
|
case "wrong_audience":
|
|
1589
1589
|
case "redirected": return own("usage", "wrong_url");
|
|
1590
|
-
case "
|
|
1591
|
-
instruction: "Write as one of them",
|
|
1592
|
-
argv: rerun("--as", "<PROFILE>")
|
|
1593
|
-
}, {
|
|
1594
|
-
instruction: "Or as yourself",
|
|
1595
|
-
argv: rerun("--human")
|
|
1596
|
-
}]);
|
|
1590
|
+
case "renamed_env": return own("usage", "renamed_env");
|
|
1597
1591
|
case "too_large": return {
|
|
1598
1592
|
...own("limit", "payload_too_large"),
|
|
1599
1593
|
message: `Can't ${doing()}. ${sentence(message)}`
|
|
@@ -1650,8 +1644,12 @@ function failureOf(error) {
|
|
|
1650
1644
|
instruction: "See the schemas this board has",
|
|
1651
1645
|
argv: [...cli(), "schemas"]
|
|
1652
1646
|
}]);
|
|
1647
|
+
if (status === 400 && code === "text_too_long") return {
|
|
1648
|
+
...theirs("limit", "payload_too_large", `Can't ${doing()}. A message's text is at most ${MESSAGE_TEXT_MAX.toLocaleString("en-US")} characters.`, [{ instruction: current.command === "edit" ? "Keep the edit short, and reply with the long part in a file with --attach" : "Put the long part in a file and --attach it, with a short summary as the text" }]),
|
|
1649
|
+
details: []
|
|
1650
|
+
};
|
|
1653
1651
|
if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
|
|
1654
|
-
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" }] : [{
|
|
1652
|
+
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" }] : [{
|
|
1655
1653
|
instruction: "Log in again",
|
|
1656
1654
|
argv: ["vercel", "login"]
|
|
1657
1655
|
}]);
|
|
@@ -1735,9 +1733,9 @@ function vercelBoard(url) {
|
|
|
1735
1733
|
...team ? { team } : {}
|
|
1736
1734
|
};
|
|
1737
1735
|
}
|
|
1738
|
-
/** Who the handle writes as: `--as`'s profile (with `--avatar`),
|
|
1736
|
+
/** Who the handle writes as: `--as`'s profile (with `--avatar`), or what the environment says (`BOARD_PROFILE`), else yourself. */
|
|
1739
1737
|
function profileFlag() {
|
|
1740
|
-
if (flags.
|
|
1738
|
+
if (flags.avatar !== void 0 && !flags.as) throw usage("--avatar is the avatar of the profile --as names: pass --as too.", { reason: "missing_arguments" });
|
|
1741
1739
|
if (!flags.as) return void 0;
|
|
1742
1740
|
return flags.avatar ? {
|
|
1743
1741
|
name: flags.as,
|
|
@@ -1759,7 +1757,7 @@ function connection(url = flags.url, options = {}) {
|
|
|
1759
1757
|
const board$1 = board({
|
|
1760
1758
|
backend: vercel({
|
|
1761
1759
|
...team !== void 0 ? { team } : {},
|
|
1762
|
-
...sending(options.token, options.can)
|
|
1760
|
+
...sending(options.token, options.can, options.headers)
|
|
1763
1761
|
}),
|
|
1764
1762
|
...name !== void 0 ? {
|
|
1765
1763
|
name,
|
|
@@ -1778,7 +1776,7 @@ function connection(url = flags.url, options = {}) {
|
|
|
1778
1776
|
if (onVercel) {
|
|
1779
1777
|
const board$3 = board({ backend: vercel({
|
|
1780
1778
|
...onVercel,
|
|
1781
|
-
...sending(options.token, options.can)
|
|
1779
|
+
...sending(options.token, options.can, options.headers)
|
|
1782
1780
|
}) });
|
|
1783
1781
|
return {
|
|
1784
1782
|
url: at,
|
|
@@ -1786,11 +1784,13 @@ function connection(url = flags.url, options = {}) {
|
|
|
1786
1784
|
board: profile !== void 0 ? board$3.as(profile) : board$3
|
|
1787
1785
|
};
|
|
1788
1786
|
}
|
|
1789
|
-
const
|
|
1787
|
+
const extra = {
|
|
1788
|
+
...options.headers,
|
|
1789
|
+
...options.can !== void 0 ? { "x-board-can": options.can } : {}
|
|
1790
|
+
};
|
|
1790
1791
|
const transport = connect(at, {
|
|
1791
1792
|
...options.token !== void 0 ? { token: options.token } : {},
|
|
1792
|
-
...
|
|
1793
|
-
...options.can !== void 0 ? { fetch: narrowing(options.can) } : {}
|
|
1793
|
+
...Object.keys(extra).length > 0 ? { fetch: withHeaders(extra) } : {}
|
|
1794
1794
|
});
|
|
1795
1795
|
const board$2 = board({ backend: http(at, { fetch: transport.fetch }) });
|
|
1796
1796
|
return {
|
|
@@ -1830,36 +1830,33 @@ function boardNameFlag(url, team) {
|
|
|
1830
1830
|
if (!isBoardName(given)) throw usage(`${from} ${given} isn't a board's name: one is 1 to 64 characters.`);
|
|
1831
1831
|
return given;
|
|
1832
1832
|
}
|
|
1833
|
-
/** For Vercel's API, `token` in place of your own credentials
|
|
1834
|
-
function sending(token, can) {
|
|
1835
|
-
if (token === void 0 && can === void 0) return {};
|
|
1833
|
+
/** For Vercel's API, `token` in place of your own credentials, `can` narrowing them, and `headers` beside them. */
|
|
1834
|
+
function sending(token, can, extra = {}) {
|
|
1835
|
+
if (token === void 0 && can === void 0 && Object.keys(extra).length === 0) return {};
|
|
1836
1836
|
return { fetch: (input, init = {}) => {
|
|
1837
1837
|
const headers = new Headers(init.headers ?? (input instanceof Request ? input.headers : void 0));
|
|
1838
1838
|
if (token !== void 0) headers.set("authorization", `Bearer ${token}`);
|
|
1839
1839
|
if (can !== void 0) headers.set("x-board-can", can);
|
|
1840
|
+
for (const [name, value] of Object.entries(extra)) headers.set(name, value);
|
|
1840
1841
|
return (token === void 0 ? credentialed() : globalThis.fetch)(input, {
|
|
1841
1842
|
...init,
|
|
1842
1843
|
headers
|
|
1843
1844
|
});
|
|
1844
1845
|
} };
|
|
1845
1846
|
}
|
|
1846
|
-
/** A fetch that
|
|
1847
|
-
function
|
|
1847
|
+
/** A fetch that adds `headers` to each request to a board on HTTP, as a proxy holding its credentials would: `x-board-can`, say. */
|
|
1848
|
+
function withHeaders(headers) {
|
|
1848
1849
|
return (input, init) => {
|
|
1849
1850
|
const request = new Request(input, init);
|
|
1850
|
-
request.headers.set(
|
|
1851
|
+
for (const [name, value] of Object.entries(headers)) request.headers.set(name, value);
|
|
1851
1852
|
return globalThis.fetch(request);
|
|
1852
1853
|
};
|
|
1853
1854
|
}
|
|
1854
1855
|
/** A handle on the board this command talks to: `vb()`'s, as `--as` says, or the one `connection()` finds. */
|
|
1855
1856
|
function client() {
|
|
1856
1857
|
if (!io.board) return connection().board;
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
name: flags.as,
|
|
1860
|
-
avatar: flags.avatar
|
|
1861
|
-
} : flags.as);
|
|
1862
|
-
return io.board;
|
|
1858
|
+
const profile = profileFlag();
|
|
1859
|
+
return profile === void 0 ? io.board : io.board.as(profile);
|
|
1863
1860
|
}
|
|
1864
1861
|
async function readStdin() {
|
|
1865
1862
|
const chunks = [];
|
|
@@ -1944,7 +1941,6 @@ async function run(command, args) {
|
|
|
1944
1941
|
const minutes = Math.max(0, Math.round((Date.parse(me.expiresAt) - Date.now()) / 6e4));
|
|
1945
1942
|
rows.push(["token", `expires in ${Math.floor(minutes / 60)}h ${minutes % 60}m`]);
|
|
1946
1943
|
}
|
|
1947
|
-
if (me.session) rows.push(["session", me.session]);
|
|
1948
1944
|
(me.can === void 0 ? [] : formatAccess(me.can)).forEach((line, index) => rows.push([index === 0 ? "can" : "", line]));
|
|
1949
1945
|
const width = Math.max(...rows.map(([subject]) => subject.length));
|
|
1950
1946
|
for (const [subject, value] of rows) out(`${subject.padEnd(width)} ${value}`);
|
|
@@ -1963,13 +1959,10 @@ async function run(command, args) {
|
|
|
1963
1959
|
argv: rerun("--url", "<URL>")
|
|
1964
1960
|
}]
|
|
1965
1961
|
});
|
|
1966
|
-
const
|
|
1967
|
-
const withToken = io.board ? {} : { withToken: (secret) => connection(tokenUrl, { token: secret }).board };
|
|
1968
|
-
const withCan = io.board ? {} : { withCan: (can) => connection(void 0, { can }).board };
|
|
1962
|
+
const withHeaders = io.board ? {} : { withHeaders: (headers) => connection(void 0, { headers }).board };
|
|
1969
1963
|
const report = await conformance(client(), {
|
|
1970
1964
|
...flags.channel ? { channel: flags.channel } : {},
|
|
1971
|
-
...
|
|
1972
|
-
...withCan
|
|
1965
|
+
...withHeaders
|
|
1973
1966
|
});
|
|
1974
1967
|
if (flags.json) result(report);
|
|
1975
1968
|
else out(formatConformance(report));
|
|
@@ -2059,6 +2052,7 @@ async function run(command, args) {
|
|
|
2059
2052
|
class: "not_found",
|
|
2060
2053
|
reason: "channel_not_found",
|
|
2061
2054
|
message: `Couldn't find channel ${target}.${guess ? ` Did you mean ${guess}?` : ""}`,
|
|
2055
|
+
details: ["A channel appears with its first post: one nobody has posted in yet is not there to read."],
|
|
2062
2056
|
next: [{
|
|
2063
2057
|
instruction: "See its channels",
|
|
2064
2058
|
argv: [...cli(), "channels"]
|
|
@@ -2070,11 +2064,13 @@ async function run(command, args) {
|
|
|
2070
2064
|
const count = `${page.threads.length} ${page.threads.length === 1 ? "thread" : "threads"}`;
|
|
2071
2065
|
out(`${target ?? "all channels"} · ${count} · cursor ${page.cursor}${page.threads.length ? "\n" : ""}`);
|
|
2072
2066
|
if (page.threads.length) out(formatThreadSummaries(page.threads, { channel: !target || target.endsWith("/") }));
|
|
2067
|
+
out(`\nnew since then: ${commandLine(rerunWithout(["--after"], "--after", String(page.cursor)))}`);
|
|
2073
2068
|
return 0;
|
|
2074
2069
|
}
|
|
2075
2070
|
case "post": {
|
|
2076
2071
|
const [target, body] = args;
|
|
2077
2072
|
if (!target) throw usage("Missing the channel or message to post to.", { reason: "missing_arguments" });
|
|
2073
|
+
oneText("post", target, args.slice(2));
|
|
2078
2074
|
const re = isMessageRef(target) ? messageId(target) : void 0;
|
|
2079
2075
|
if (re !== void 0 && flags.sync?.length) throw usage("Can't use --sync on a reply. It syncs whole threads.", { next: [{
|
|
2080
2076
|
instruction: "Sync the thread instead",
|
|
@@ -2108,6 +2104,7 @@ async function run(command, args) {
|
|
|
2108
2104
|
}
|
|
2109
2105
|
case "reply": {
|
|
2110
2106
|
const id = messageId(args[0]);
|
|
2107
|
+
oneText("reply", args[0], args.slice(2));
|
|
2111
2108
|
const board = client();
|
|
2112
2109
|
const said = await content(args[1], { optional: !!flags.attach?.length });
|
|
2113
2110
|
const files = await attachments(board);
|
|
@@ -2188,7 +2185,7 @@ async function run(command, args) {
|
|
|
2188
2185
|
return 0;
|
|
2189
2186
|
}
|
|
2190
2187
|
if (verb === "update") {
|
|
2191
|
-
const id =
|
|
2188
|
+
const id = grantId(rest[0]);
|
|
2192
2189
|
if (rest.length > 1) throw usage(`grants update takes one grant: ${rest[1]} is one too many.`);
|
|
2193
2190
|
onlyPrincipalFlags("update");
|
|
2194
2191
|
const named = grantFlags(() => principalsIn(ordered, ["add-", "remove-"], ({ kind, value }) => {
|
|
@@ -2237,7 +2234,7 @@ async function run(command, args) {
|
|
|
2237
2234
|
return 0;
|
|
2238
2235
|
}
|
|
2239
2236
|
if (verb === "revoke") {
|
|
2240
|
-
const id =
|
|
2237
|
+
const id = grantId(rest[0]);
|
|
2241
2238
|
const { revoked } = await client().revokeGrant(id);
|
|
2242
2239
|
if (flags.json) result({
|
|
2243
2240
|
grant: id,
|
|
@@ -2248,43 +2245,6 @@ async function run(command, args) {
|
|
|
2248
2245
|
}
|
|
2249
2246
|
throw usage(`Unknown command ${verb} for ${named()} grants.`, { reason: "unknown_command" });
|
|
2250
2247
|
}
|
|
2251
|
-
case "tokens": {
|
|
2252
|
-
const [verb, ...rest] = args;
|
|
2253
|
-
if (verb === void 0 || verb === "list") {
|
|
2254
|
-
if (rest.length > 0) throw usage(`tokens list takes no arguments: ${rest[0]} is one too many.`);
|
|
2255
|
-
const list = await client().tokens();
|
|
2256
|
-
if (flags.json) return result({ tokens: list }), 0;
|
|
2257
|
-
out(list.length === 0 ? "no tokens" : formatTokens(list));
|
|
2258
|
-
return 0;
|
|
2259
|
-
}
|
|
2260
|
-
if (verb === "revoke") {
|
|
2261
|
-
const id = trustId("token", rest[0]);
|
|
2262
|
-
const { revoked } = await client().revokeToken(id);
|
|
2263
|
-
if (flags.json) result({
|
|
2264
|
-
token: id,
|
|
2265
|
-
outcome: revoked ? "revoked" : "unchanged"
|
|
2266
|
-
});
|
|
2267
|
-
else out(revoked ? `revoked ${id}` : `${id} isn't a live token of yours`);
|
|
2268
|
-
return 0;
|
|
2269
|
-
}
|
|
2270
|
-
if (verb !== "create") throw usage(`Unknown command ${verb} for ${named()} tokens.`, { reason: "unknown_command" });
|
|
2271
|
-
const [name, extra] = rest;
|
|
2272
|
-
if (!name) throw usage("Missing a name for the token, like feedback-widget.", { reason: "missing_arguments" });
|
|
2273
|
-
if (extra !== void 0) throw usage(`tokens create takes one name: ${extra} is one too many.`);
|
|
2274
|
-
const { token, secret } = await client().createToken({
|
|
2275
|
-
name,
|
|
2276
|
-
...flags.can !== void 0 ? { can: canFlag(flags.can) } : {},
|
|
2277
|
-
...flags.profile !== void 0 ? { profile: flags.profile } : {},
|
|
2278
|
-
...flags.session !== void 0 ? { session: flags.session } : {},
|
|
2279
|
-
...flags.expires !== void 0 ? { expires: flags.expires } : {}
|
|
2280
|
-
});
|
|
2281
|
-
if (flags.json) result({
|
|
2282
|
-
token,
|
|
2283
|
-
secret
|
|
2284
|
-
});
|
|
2285
|
-
else out(secret);
|
|
2286
|
-
return 0;
|
|
2287
|
-
}
|
|
2288
2248
|
case "schemas": {
|
|
2289
2249
|
const [verb, ...rest] = args;
|
|
2290
2250
|
if (verb === void 0 || verb === "list") {
|
|
@@ -2319,6 +2279,24 @@ async function run(command, args) {
|
|
|
2319
2279
|
return 0;
|
|
2320
2280
|
}
|
|
2321
2281
|
case "schedules": {
|
|
2282
|
+
if (args[0] !== void 0 && isScheduleId(args[0])) {
|
|
2283
|
+
const one = (await client().schedules({ all: true })).find((schedule) => schedule.id.toLowerCase() === args[0].toLowerCase());
|
|
2284
|
+
if (!one) throw new Failed({
|
|
2285
|
+
class: "not_found",
|
|
2286
|
+
reason: "schedule_not_found",
|
|
2287
|
+
message: `Couldn't find schedule ${args[0]}.`,
|
|
2288
|
+
next: [{
|
|
2289
|
+
instruction: "See every schedule, done and canceled ones too",
|
|
2290
|
+
argv: [
|
|
2291
|
+
...cli(),
|
|
2292
|
+
"schedules",
|
|
2293
|
+
"--all"
|
|
2294
|
+
]
|
|
2295
|
+
}]
|
|
2296
|
+
});
|
|
2297
|
+
if (flags.json) return result({ schedules: [one] }), 0;
|
|
2298
|
+
return out(formatSchedule(one)), 0;
|
|
2299
|
+
}
|
|
2322
2300
|
const list = await client().schedules({
|
|
2323
2301
|
...args[0] ? { re: messageId(args[0]) } : {},
|
|
2324
2302
|
...flags.by ? { by: flags.by.replace(/^@/, "") } : {},
|
|
@@ -2394,10 +2372,10 @@ async function run(command, args) {
|
|
|
2394
2372
|
}
|
|
2395
2373
|
case "label": {
|
|
2396
2374
|
const id = messageId(args[0]);
|
|
2397
|
-
const set = labelPairs(args.slice(1));
|
|
2375
|
+
const set = labelPairs(args.slice(1), void 0, "{value} has no value. To remove the label, --unset {key}.");
|
|
2398
2376
|
const unset = flags.unset ?? [];
|
|
2399
2377
|
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" });
|
|
2400
|
-
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.");
|
|
2378
|
+
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);
|
|
2401
2379
|
for (const key of flags["if-unset"] ?? []) {
|
|
2402
2380
|
if (Object.hasOwn(expected, key)) throw usage(`Can't use --if ${key}=… with --if-unset ${key}.`);
|
|
2403
2381
|
expected[key] = null;
|
|
@@ -2436,6 +2414,14 @@ async function run(command, args) {
|
|
|
2436
2414
|
case "download": {
|
|
2437
2415
|
const id = args[0];
|
|
2438
2416
|
if (!id) throw usage(`Missing the attachment to download: the ID \`${named()} read\` shows on a file line.`, { reason: "missing_arguments" });
|
|
2417
|
+
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: [{
|
|
2418
|
+
instruction: "Read the thread to see the ID",
|
|
2419
|
+
argv: [
|
|
2420
|
+
...cli(),
|
|
2421
|
+
"read",
|
|
2422
|
+
"<ID>"
|
|
2423
|
+
]
|
|
2424
|
+
}] });
|
|
2439
2425
|
const response = await client().download(id);
|
|
2440
2426
|
const data = new Uint8Array(await response.arrayBuffer());
|
|
2441
2427
|
if (args[1] === "-") return io.write(data), 0;
|
|
@@ -2511,8 +2497,15 @@ async function run(command, args) {
|
|
|
2511
2497
|
case "wait": {
|
|
2512
2498
|
const controller = new AbortController();
|
|
2513
2499
|
const stop = stopOn(controller);
|
|
2514
|
-
const timeout = flags.timeout ?? "30m";
|
|
2515
|
-
const
|
|
2500
|
+
const timeout = /^\d+$/.test(flags.timeout ?? "") ? `${flags.timeout}s` : flags.timeout ?? "30m";
|
|
2501
|
+
const thread = args[0] !== void 0 && isMessageRef(args[0]) && flags.re === void 0 ? args[0] : void 0;
|
|
2502
|
+
const root = thread === void 0 ? void 0 : (await client().thread(messageId(thread))).message.id;
|
|
2503
|
+
const waitsOn = root === void 0 ? filters(args[0]) : {
|
|
2504
|
+
...filters(),
|
|
2505
|
+
re: root,
|
|
2506
|
+
...flags.after === void 0 ? { after: messageId(thread) } : {}
|
|
2507
|
+
};
|
|
2508
|
+
const event = await client().wait(waitsOn, {
|
|
2516
2509
|
timeout,
|
|
2517
2510
|
signal: controller.signal
|
|
2518
2511
|
}).finally(stop.release);
|
|
@@ -2521,21 +2514,37 @@ async function run(command, args) {
|
|
|
2521
2514
|
throw new Failed({
|
|
2522
2515
|
class: "timeout",
|
|
2523
2516
|
reason: "timeout",
|
|
2524
|
-
message: `Nothing matched within ${timeout}
|
|
2517
|
+
message: `Nothing matched within ${timeout}.`,
|
|
2518
|
+
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}.`],
|
|
2519
|
+
next: [{
|
|
2520
|
+
instruction: "See what is there now",
|
|
2521
|
+
argv: [
|
|
2522
|
+
...cli(),
|
|
2523
|
+
"read",
|
|
2524
|
+
...thread ?? flags.re ?? args[0] ? [thread ?? flags.re ?? args[0]] : []
|
|
2525
|
+
]
|
|
2526
|
+
}]
|
|
2525
2527
|
});
|
|
2526
2528
|
}
|
|
2527
2529
|
if (flags.json) result({ event });
|
|
2528
|
-
else
|
|
2530
|
+
else {
|
|
2531
|
+
out(formatEvent(event));
|
|
2532
|
+
out(`next: ${commandLine(rerunWithout(["--after"], "--after", String(event.cursor)))}`);
|
|
2533
|
+
}
|
|
2529
2534
|
return 0;
|
|
2530
2535
|
}
|
|
2531
|
-
case "inspect": return (await import("./inspect-
|
|
2536
|
+
case "inspect": return (await import("./inspect-HlHh7OXa.mjs")).inspect(context());
|
|
2532
2537
|
default: {
|
|
2533
2538
|
const own = app.commands[command];
|
|
2534
2539
|
if (own) return own.run(args, context());
|
|
2535
2540
|
const guess = closest(command, [...commands.flatMap((known) => [known.name, ...known.aliases ?? []]), ...Object.keys(app.commands)]);
|
|
2536
|
-
|
|
2541
|
+
const said = Object.hasOwn(OTHER_NAMES, command.toLowerCase()) ? OTHER_NAMES[command.toLowerCase()] : void 0;
|
|
2542
|
+
throw usage(`Unknown command ${command} for ${named()}.${said ? "" : guess ? ` Did you mean ${guess}?` : ""}`, {
|
|
2537
2543
|
reason: "unknown_command",
|
|
2538
|
-
next: [{
|
|
2544
|
+
next: [...said ? [{
|
|
2545
|
+
instruction: said.instruction,
|
|
2546
|
+
argv: [...cli(), ...said.argv]
|
|
2547
|
+
}] : [], {
|
|
2539
2548
|
instruction: "See all commands",
|
|
2540
2549
|
argv: [...cli(), "--help"]
|
|
2541
2550
|
}]
|
|
@@ -2543,6 +2552,254 @@ async function run(command, args) {
|
|
|
2543
2552
|
}
|
|
2544
2553
|
}
|
|
2545
2554
|
}
|
|
2555
|
+
/** Words for a command this CLI names otherwise, and the command they mean. */
|
|
2556
|
+
const OTHER_NAMES = {
|
|
2557
|
+
search: {
|
|
2558
|
+
instruction: "Search is a filter on read",
|
|
2559
|
+
argv: [
|
|
2560
|
+
"read",
|
|
2561
|
+
"<CHANNEL>",
|
|
2562
|
+
"--text",
|
|
2563
|
+
"<PHRASE>"
|
|
2564
|
+
]
|
|
2565
|
+
},
|
|
2566
|
+
find: {
|
|
2567
|
+
instruction: "Search is a filter on read",
|
|
2568
|
+
argv: [
|
|
2569
|
+
"read",
|
|
2570
|
+
"<CHANNEL>",
|
|
2571
|
+
"--text",
|
|
2572
|
+
"<PHRASE>"
|
|
2573
|
+
]
|
|
2574
|
+
},
|
|
2575
|
+
grep: {
|
|
2576
|
+
instruction: "Search is a filter on read",
|
|
2577
|
+
argv: [
|
|
2578
|
+
"read",
|
|
2579
|
+
"<CHANNEL>",
|
|
2580
|
+
"--text",
|
|
2581
|
+
"<PHRASE>"
|
|
2582
|
+
]
|
|
2583
|
+
},
|
|
2584
|
+
list: {
|
|
2585
|
+
instruction: "List a channel's threads with read",
|
|
2586
|
+
argv: ["read", "<CHANNEL>"]
|
|
2587
|
+
},
|
|
2588
|
+
ls: {
|
|
2589
|
+
instruction: "List a channel's threads with read",
|
|
2590
|
+
argv: ["read", "<CHANNEL>"]
|
|
2591
|
+
},
|
|
2592
|
+
threads: {
|
|
2593
|
+
instruction: "List a channel's threads with read",
|
|
2594
|
+
argv: ["read", "<CHANNEL>"]
|
|
2595
|
+
},
|
|
2596
|
+
messages: {
|
|
2597
|
+
instruction: "Read one thread, every message",
|
|
2598
|
+
argv: ["read", "<ID>"]
|
|
2599
|
+
},
|
|
2600
|
+
thread: {
|
|
2601
|
+
instruction: "Read one thread, every message",
|
|
2602
|
+
argv: ["read", "<ID>"]
|
|
2603
|
+
},
|
|
2604
|
+
show: {
|
|
2605
|
+
instruction: "Read one thread, every message",
|
|
2606
|
+
argv: ["read", "<ID>"]
|
|
2607
|
+
},
|
|
2608
|
+
get: {
|
|
2609
|
+
instruction: "Read one thread, every message",
|
|
2610
|
+
argv: ["read", "<ID>"]
|
|
2611
|
+
},
|
|
2612
|
+
view: {
|
|
2613
|
+
instruction: "Read one thread, every message",
|
|
2614
|
+
argv: ["read", "<ID>"]
|
|
2615
|
+
},
|
|
2616
|
+
history: {
|
|
2617
|
+
instruction: "Read one thread, every message",
|
|
2618
|
+
argv: ["read", "<ID>"]
|
|
2619
|
+
},
|
|
2620
|
+
send: {
|
|
2621
|
+
instruction: "Start a thread with post",
|
|
2622
|
+
argv: [
|
|
2623
|
+
"post",
|
|
2624
|
+
"<CHANNEL>",
|
|
2625
|
+
"<TEXT>"
|
|
2626
|
+
]
|
|
2627
|
+
},
|
|
2628
|
+
create: {
|
|
2629
|
+
instruction: "Start a thread with post",
|
|
2630
|
+
argv: [
|
|
2631
|
+
"post",
|
|
2632
|
+
"<CHANNEL>",
|
|
2633
|
+
"<TEXT>"
|
|
2634
|
+
]
|
|
2635
|
+
},
|
|
2636
|
+
comment: {
|
|
2637
|
+
instruction: "Reply in a thread",
|
|
2638
|
+
argv: [
|
|
2639
|
+
"reply",
|
|
2640
|
+
"<ID>",
|
|
2641
|
+
"<TEXT>"
|
|
2642
|
+
]
|
|
2643
|
+
},
|
|
2644
|
+
answer: {
|
|
2645
|
+
instruction: "Reply in a thread",
|
|
2646
|
+
argv: [
|
|
2647
|
+
"reply",
|
|
2648
|
+
"<ID>",
|
|
2649
|
+
"<TEXT>"
|
|
2650
|
+
]
|
|
2651
|
+
},
|
|
2652
|
+
update: {
|
|
2653
|
+
instruction: "Change a message's text with edit",
|
|
2654
|
+
argv: [
|
|
2655
|
+
"edit",
|
|
2656
|
+
"<ID>",
|
|
2657
|
+
"<TEXT>"
|
|
2658
|
+
]
|
|
2659
|
+
},
|
|
2660
|
+
remove: {
|
|
2661
|
+
instruction: "Delete a message",
|
|
2662
|
+
argv: ["delete", "<ID>"]
|
|
2663
|
+
},
|
|
2664
|
+
rm: {
|
|
2665
|
+
instruction: "Delete a message",
|
|
2666
|
+
argv: ["delete", "<ID>"]
|
|
2667
|
+
},
|
|
2668
|
+
cancel: {
|
|
2669
|
+
instruction: "Cancel a schedule",
|
|
2670
|
+
argv: [
|
|
2671
|
+
"schedule",
|
|
2672
|
+
"cancel",
|
|
2673
|
+
"<SCHEDULE>"
|
|
2674
|
+
]
|
|
2675
|
+
},
|
|
2676
|
+
unschedule: {
|
|
2677
|
+
instruction: "Cancel a schedule",
|
|
2678
|
+
argv: [
|
|
2679
|
+
"schedule",
|
|
2680
|
+
"cancel",
|
|
2681
|
+
"<SCHEDULE>"
|
|
2682
|
+
]
|
|
2683
|
+
},
|
|
2684
|
+
remind: {
|
|
2685
|
+
instruction: "Post later with schedule",
|
|
2686
|
+
argv: [
|
|
2687
|
+
"schedule",
|
|
2688
|
+
"<TARGET>",
|
|
2689
|
+
"<TEXT>",
|
|
2690
|
+
"--in",
|
|
2691
|
+
"<DURATION>"
|
|
2692
|
+
]
|
|
2693
|
+
},
|
|
2694
|
+
attach: {
|
|
2695
|
+
instruction: "Attach a file to a post",
|
|
2696
|
+
argv: [
|
|
2697
|
+
"post",
|
|
2698
|
+
"<TARGET>",
|
|
2699
|
+
"<TEXT>",
|
|
2700
|
+
"--attach",
|
|
2701
|
+
"<FILE>"
|
|
2702
|
+
]
|
|
2703
|
+
},
|
|
2704
|
+
upload: {
|
|
2705
|
+
instruction: "Attach a file to a post",
|
|
2706
|
+
argv: [
|
|
2707
|
+
"post",
|
|
2708
|
+
"<TARGET>",
|
|
2709
|
+
"<TEXT>",
|
|
2710
|
+
"--attach",
|
|
2711
|
+
"<FILE>"
|
|
2712
|
+
]
|
|
2713
|
+
},
|
|
2714
|
+
claim: {
|
|
2715
|
+
instruction: "Claim a thread with a label, unless someone has",
|
|
2716
|
+
argv: [
|
|
2717
|
+
"label",
|
|
2718
|
+
"<ID>",
|
|
2719
|
+
"owner=<YOU>",
|
|
2720
|
+
"--if-unset",
|
|
2721
|
+
"owner"
|
|
2722
|
+
]
|
|
2723
|
+
},
|
|
2724
|
+
assign: {
|
|
2725
|
+
instruction: "Claim a thread with a label, unless someone has",
|
|
2726
|
+
argv: [
|
|
2727
|
+
"label",
|
|
2728
|
+
"<ID>",
|
|
2729
|
+
"owner=<YOU>",
|
|
2730
|
+
"--if-unset",
|
|
2731
|
+
"owner"
|
|
2732
|
+
]
|
|
2733
|
+
},
|
|
2734
|
+
tag: {
|
|
2735
|
+
instruction: "Set labels on a message",
|
|
2736
|
+
argv: [
|
|
2737
|
+
"label",
|
|
2738
|
+
"<ID>",
|
|
2739
|
+
"<KEY=VALUE>"
|
|
2740
|
+
]
|
|
2741
|
+
},
|
|
2742
|
+
labels: {
|
|
2743
|
+
instruction: "Set labels on a message",
|
|
2744
|
+
argv: [
|
|
2745
|
+
"label",
|
|
2746
|
+
"<ID>",
|
|
2747
|
+
"<KEY=VALUE>"
|
|
2748
|
+
]
|
|
2749
|
+
},
|
|
2750
|
+
mentions: {
|
|
2751
|
+
instruction: "Mentions are a filter on read and wait",
|
|
2752
|
+
argv: ["read", "--mentions"]
|
|
2753
|
+
},
|
|
2754
|
+
watch: {
|
|
2755
|
+
instruction: "Block for the next match with wait, or follow live with tail",
|
|
2756
|
+
argv: [
|
|
2757
|
+
"wait",
|
|
2758
|
+
"<CHANNEL>",
|
|
2759
|
+
"--after",
|
|
2760
|
+
"<CURSOR>"
|
|
2761
|
+
]
|
|
2762
|
+
},
|
|
2763
|
+
follow: {
|
|
2764
|
+
instruction: "Block for the next match with wait, or follow live with tail",
|
|
2765
|
+
argv: [
|
|
2766
|
+
"wait",
|
|
2767
|
+
"<CHANNEL>",
|
|
2768
|
+
"--after",
|
|
2769
|
+
"<CURSOR>"
|
|
2770
|
+
]
|
|
2771
|
+
},
|
|
2772
|
+
subscribe: {
|
|
2773
|
+
instruction: "Block for the next match with wait, or follow live with tail",
|
|
2774
|
+
argv: [
|
|
2775
|
+
"wait",
|
|
2776
|
+
"<CHANNEL>",
|
|
2777
|
+
"--after",
|
|
2778
|
+
"<CURSOR>"
|
|
2779
|
+
]
|
|
2780
|
+
},
|
|
2781
|
+
listen: {
|
|
2782
|
+
instruction: "Block for the next match with wait, or follow live with tail",
|
|
2783
|
+
argv: [
|
|
2784
|
+
"wait",
|
|
2785
|
+
"<CHANNEL>",
|
|
2786
|
+
"--after",
|
|
2787
|
+
"<CURSOR>"
|
|
2788
|
+
]
|
|
2789
|
+
},
|
|
2790
|
+
users: {
|
|
2791
|
+
instruction: "See who is on the board",
|
|
2792
|
+
argv: ["actors"]
|
|
2793
|
+
},
|
|
2794
|
+
members: {
|
|
2795
|
+
instruction: "See who is on the board",
|
|
2796
|
+
argv: ["actors"]
|
|
2797
|
+
},
|
|
2798
|
+
me: {
|
|
2799
|
+
instruction: "See who you are",
|
|
2800
|
+
argv: ["whoami"]
|
|
2801
|
+
}
|
|
2802
|
+
};
|
|
2546
2803
|
/**
|
|
2547
2804
|
* Aborts `controller` on the run's signal, or Ctrl-C without one. `release` stops listening, and
|
|
2548
2805
|
* `interrupted` says whether Ctrl-C stopped it.
|
|
@@ -2619,7 +2876,7 @@ async function runOnce(argv, options) {
|
|
|
2619
2876
|
args
|
|
2620
2877
|
};
|
|
2621
2878
|
if (io.board) {
|
|
2622
|
-
const given = flags.url ? "url" : flags.name !== void 0 ? "name" : flags.ensure ? "ensure" :
|
|
2879
|
+
const given = flags.url ? "url" : flags.name !== void 0 ? "name" : flags.ensure ? "ensure" : null;
|
|
2623
2880
|
if (given) throw usage(`--${given} doesn't apply in-process: the board handle you pass says which board and who.`, { next: [] });
|
|
2624
2881
|
if (command !== void 0 && MACHINE.has(command)) throw usage(`${command} isn't available in-process: it's about the machine ${named()} runs on.`, {
|
|
2625
2882
|
reason: "not_available",
|
|
@@ -2628,10 +2885,43 @@ async function runOnce(argv, options) {
|
|
|
2628
2885
|
}
|
|
2629
2886
|
return await run(command, args);
|
|
2630
2887
|
} catch (error) {
|
|
2888
|
+
if (io.signal?.aborted) {
|
|
2889
|
+
if (current.command === "tail" || current.command === "wait") return 0;
|
|
2890
|
+
error = stopped(io.signal.reason);
|
|
2891
|
+
}
|
|
2631
2892
|
const json = flags.json ?? argv.slice(0, argv.includes("--") ? argv.indexOf("--") : void 0).includes("--json");
|
|
2632
2893
|
return report(failureOf(error), json);
|
|
2633
2894
|
}
|
|
2634
2895
|
}
|
|
2896
|
+
/** The commands that change the board, whatever their arguments. */
|
|
2897
|
+
const WRITES = /* @__PURE__ */ new Set([
|
|
2898
|
+
"post",
|
|
2899
|
+
"reply",
|
|
2900
|
+
"edit",
|
|
2901
|
+
"delete",
|
|
2902
|
+
"label",
|
|
2903
|
+
"react",
|
|
2904
|
+
"schedule",
|
|
2905
|
+
"sync"
|
|
2906
|
+
]);
|
|
2907
|
+
/** What a run its caller's signal stopped says: a write it was making may have landed. */
|
|
2908
|
+
function stopped(reason) {
|
|
2909
|
+
const timedOut = reason instanceof Error && reason.name === "TimeoutError";
|
|
2910
|
+
const sub = current.command === "sources" ? current.args[1] : current.args[0];
|
|
2911
|
+
const writes = WRITES.has(current.command ?? "") || [
|
|
2912
|
+
"create",
|
|
2913
|
+
"update",
|
|
2914
|
+
"revoke",
|
|
2915
|
+
"cancel",
|
|
2916
|
+
"join"
|
|
2917
|
+
].includes(sub ?? "");
|
|
2918
|
+
return new Failed({
|
|
2919
|
+
class: timedOut ? "timeout" : "canceled",
|
|
2920
|
+
reason: timedOut ? "timeout" : "canceled",
|
|
2921
|
+
message: `${timedOut ? "Timed out" : "Stopped"} before it could ${doing()}.`,
|
|
2922
|
+
...writes ? { next: [{ instruction: "It may have happened anyway: read before you run it again." }] } : {}
|
|
2923
|
+
});
|
|
2924
|
+
}
|
|
2635
2925
|
/** The commands about the machine the CLI runs on, not the board: none of them run in-process. */
|
|
2636
2926
|
const MACHINE = /* @__PURE__ */ new Set([
|
|
2637
2927
|
"whoami",
|