@vercel/board 0.52.0 → 0.54.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 +4 -3
- package/dist/{access-DdojoPZm.mjs → access-HzqFpgL_.mjs} +1 -1
- package/dist/access.d.mts +3 -3
- package/dist/access.mjs +5 -5
- package/dist/{actors-CDkNgWUL.mjs → actors-D-u6bitG.mjs} +2 -2
- package/dist/{auth-zPqFJocD.mjs → auth-D9ycDQK0.mjs} +34 -12
- package/dist/{auth-C4VxPLYz.d.mts → auth-ULldUvir.d.mts} +8 -2
- package/dist/{backend-Da_YEltI.d.mts → backend-BHN6GTjB.d.mts} +8 -7
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{chat-provider-BHyX6H8H.d.mts → chat-provider-F7UqWVZK.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 +32 -3
- package/dist/cli-embedded.mjs +4 -2
- package/dist/cli.mjs +6 -6
- package/dist/{client-C4-r10SA.d.mts → client-CFHunEFn.d.mts} +16 -4
- package/dist/{commands-B_gbi2sU.mjs → commands-B5SXeo4W.mjs} +14 -9
- package/dist/{commands-B6pgzwTI.d.mts → commands-DLPIX7Jw.d.mts} +3 -1
- package/dist/{conformance-DW4-9Dwf.mjs → conformance-CyQG0jky.mjs} +56 -4
- package/dist/conformance.d.mts +3 -4
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-D8YAsQS_.mjs → engine-C8wCzkw-.mjs} +2 -2
- package/dist/errors-DDfXnZ2b.mjs +1958 -0
- package/dist/{exports-BUtR_AHa.d.mts → exports-BBmjHyCB.d.mts} +4 -4
- package/dist/{exports-DI-MtN01.mjs → exports-JUhj5Bl3.mjs} +127 -77
- package/dist/{index-BTuTaBaK.d.mts → index-Ce3SDZ3Y.d.mts} +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/index.node.d.mts +7 -7
- package/dist/index.node.mjs +4 -4
- package/dist/inspect/app.js +69 -69
- package/dist/inspect/engine.js +3 -3
- package/dist/inspect-BN7V9e-M.mjs +2 -0
- package/dist/{inspect-BJR-BsUv.mjs → inspect-CrVs-iEi.mjs} +2 -2
- package/dist/inspect.d.mts +1 -1
- package/dist/inspect.mjs +1 -1
- package/dist/{local-B376y9u3.mjs → local-RoMUU6QX.mjs} +39 -23
- package/dist/{main-DfJNxck4.mjs → main-B_gzTjBR.mjs} +370 -102
- package/dist/{middleware-iVTNf5Su.mjs → middleware-BY4qqIh3.mjs} +1 -1
- package/dist/{provider-CGicSMdu.d.mts → provider-DgGp4Zej.d.mts} +2 -2
- package/dist/{routes-ChGBn0K3.d.mts → routes-DNmQSOvQ.d.mts} +36 -3
- package/dist/{serve-D8j7O2Tc.mjs → serve-Cz1NynhG.mjs} +6 -6
- package/dist/{server--BLSj6fd.mjs → server-CdBXNUxf.mjs} +68 -11
- package/dist/{serving-aOQsBok0.mjs → serving-C1mhZQqH.mjs} +1 -1
- package/dist/{shell-qrJL3Z_R.mjs → shell-Cqn38XUs.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync.d.mts +2 -2
- package/dist/{task-batch-6UHphYfl.mjs → task-batch-CVamHB-W.mjs} +4 -5
- package/dist/{tokens-C-T0B1uF.mjs → tokens-B3gXkQCs.mjs} +2 -2
- package/dist/{version-NfsFHDfg.mjs → version-DBaKHEZS.mjs} +1 -1
- package/docs/01-board/01-mounting.md +8 -6
- package/docs/01-board/03-identity.md +1 -1
- package/docs/01-board/05-reading.md +34 -7
- package/docs/01-board/06-watchers.md +2 -1
- package/docs/01-board/09-access.md +11 -2
- package/docs/01-board/11-tasks.md +28 -5
- package/docs/01-quickstart.md +19 -5
- package/docs/03-guides/03-ci.md +71 -43
- package/docs/03-guides/04-triage.md +4 -4
- package/docs/04-reference/01-cli.md +84 -22
- package/docs/04-reference/02-board.md +19 -10
- package/docs/04-reference/03-http.md +14 -5
- package/docs/04-reference/05-conformance.md +1 -1
- package/docs/index.md +7 -5
- package/package.json +2 -2
- package/dist/errors-DbCKqGXp.mjs +0 -851
- package/dist/inspect-CYfZ0vva.mjs +0 -2
- package/dist/routes-C85Sbhtm.mjs +0 -1067
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { a as DIRECT_UPLOAD_BYTES_MAX, l as fileSize } from "./profile-header-O8wC8yk8.mjs";
|
|
2
2
|
import { m as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-CUSTEFIy.mjs";
|
|
3
|
-
import "./
|
|
3
|
+
import { f as BoardError } from "./errors-DDfXnZ2b.mjs";
|
|
4
4
|
import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { l as shownName } from "./middleware-iVTNf5Su.mjs";
|
|
5
|
+
import { l as shownName } from "./middleware-BY4qqIh3.mjs";
|
|
7
6
|
import { d as parseSchemaId, r as findBlocks, t as block } from "./blocks-CVoBC7ur.mjs";
|
|
8
7
|
import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
|
|
9
|
-
import { t as VERSION } from "./version-
|
|
10
|
-
import { r as PERMISSIONS } from "./access-
|
|
11
|
-
import { c as withMentions } from "./task-batch-
|
|
12
|
-
import { a as isBoardName, c as isApiMessageId, n as createTasksInChunks, t as TasksInChunksError } from "./exports-
|
|
13
|
-
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-
|
|
14
|
-
import { _ as vercelProjectFile, a as vercel, c as boardUrl, d as environmentProfile, f as handFetch, i as handTeam, l as configDir, m as handToken, n as credentialSource, o as http, p as handLogin, r as credentialed, t as board, u as connect } from "./server
|
|
15
|
-
import { n as everyChannel, t as conformance } from "./conformance-
|
|
8
|
+
import { t as VERSION } from "./version-DBaKHEZS.mjs";
|
|
9
|
+
import { r as PERMISSIONS } from "./access-HzqFpgL_.mjs";
|
|
10
|
+
import { c as withMentions } from "./task-batch-CVamHB-W.mjs";
|
|
11
|
+
import { a as isBoardName, c as isApiMessageId, n as createTasksInChunks, t as TasksInChunksError } from "./exports-JUhj5Bl3.mjs";
|
|
12
|
+
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-B5SXeo4W.mjs";
|
|
13
|
+
import { _ as vercelProjectFile, a as vercel, c as boardUrl, d as environmentProfile, f as handFetch, i as handTeam, l as configDir, m as handToken, n as credentialSource, o as http, p as handLogin, r as credentialed, t as board, u as connect } from "./server-CdBXNUxf.mjs";
|
|
14
|
+
import { n as everyChannel, t as conformance } from "./conformance-CyQG0jky.mjs";
|
|
16
15
|
import { n as displayText, t as byVercelBot } from "./bots-CqPYxkqK.mjs";
|
|
17
16
|
import { spawn } from "node:child_process";
|
|
18
17
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -839,6 +838,26 @@ function memoryClaims(board, profile) {
|
|
|
839
838
|
drop: async (task) => void claims.delete(at(task))
|
|
840
839
|
};
|
|
841
840
|
}
|
|
841
|
+
/**
|
|
842
|
+
* Claims by a token the caller chose, kept nowhere: a task's claim is this token's while the task
|
|
843
|
+
* is claimed, at the epoch the board shows, and the board says whether the token holds it. So any
|
|
844
|
+
* call with the token renews and settles the claim, on any handle, process, or instance.
|
|
845
|
+
*/
|
|
846
|
+
function tokenClaims(board, token) {
|
|
847
|
+
return {
|
|
848
|
+
async get(task) {
|
|
849
|
+
const held = (await board.thread(task, { limit: 1 })).message.task;
|
|
850
|
+
if (held?.state !== "claimed" || !held.claim) return null;
|
|
851
|
+
return {
|
|
852
|
+
epoch: held.epoch,
|
|
853
|
+
token,
|
|
854
|
+
until: held.claim.until
|
|
855
|
+
};
|
|
856
|
+
},
|
|
857
|
+
put: async () => {},
|
|
858
|
+
drop: async () => {}
|
|
859
|
+
};
|
|
860
|
+
}
|
|
842
861
|
//#endregion
|
|
843
862
|
//#region src/cli/run.ts
|
|
844
863
|
/** A claim is never renewed more often than this, however short its lease. */
|
|
@@ -1085,7 +1104,7 @@ function listed(command) {
|
|
|
1085
1104
|
function rootHelp(app, version) {
|
|
1086
1105
|
const sections = [...groups.map((group) => commands.filter((command) => command.group === group)), app.commands].map((list) => list.filter((command) => !command.hidden));
|
|
1087
1106
|
const lines = [
|
|
1088
|
-
`${app.name} ${version}:
|
|
1107
|
+
`${app.name} ${version}: your Vercel team's message board, for people and agents`,
|
|
1089
1108
|
"",
|
|
1090
1109
|
`usage: ${app.name} <command> [options]${app.name === "board" ? " (also installed as `vb`)" : ""}`
|
|
1091
1110
|
];
|
|
@@ -1116,15 +1135,23 @@ function commandHelp(name, path) {
|
|
|
1116
1135
|
if (command.filters) {
|
|
1117
1136
|
section("filters", shown(filters$1).map((option) => [flag(option), option.description]));
|
|
1118
1137
|
lines.push(" labels match a message or its thread's root; repeated flags all must match");
|
|
1138
|
+
if (command.filtersNote) lines.push(...wrap(command.filtersNote, 78).map((line) => ` ${line}`));
|
|
1119
1139
|
}
|
|
1120
1140
|
if (command.examples.length) lines.push("", "examples:", ...command.examples.flatMap((example, index) => [
|
|
1121
1141
|
...index ? [""] : [],
|
|
1122
1142
|
` ${example.name}`,
|
|
1123
1143
|
` ${name} ${example.value}`
|
|
1124
1144
|
]));
|
|
1125
|
-
lines.push("", `
|
|
1145
|
+
lines.push("", ...labeled("global:", COMMON.map((option) => flag(globalOptions.find((known) => known.name === option))).join(" "), " "), ...labeled("", `and the rest every command takes: ${name} help`));
|
|
1126
1146
|
return lines.join("\n");
|
|
1127
1147
|
}
|
|
1148
|
+
/** The global options a command's page shows: a program's output, who it writes as, and which board. */
|
|
1149
|
+
const COMMON = [
|
|
1150
|
+
"json",
|
|
1151
|
+
"as",
|
|
1152
|
+
"scope",
|
|
1153
|
+
"url"
|
|
1154
|
+
];
|
|
1128
1155
|
/**
|
|
1129
1156
|
* The command `words` name, and its subcommand when they name one (`schedule cancel`, `sources slack
|
|
1130
1157
|
* read`): what `--help` shows the page of. Null when the first word names no command.
|
|
@@ -1250,8 +1277,8 @@ function rerun(...extra) {
|
|
|
1250
1277
|
...typed.slice(at)
|
|
1251
1278
|
]];
|
|
1252
1279
|
}
|
|
1253
|
-
/** A command line without `options` and their values. */
|
|
1254
|
-
const without = (argv, ...options) => argv.filter((arg, at) => !options.some((option) => arg === option || argv[at - 1] === option
|
|
1280
|
+
/** A command line without `options` and their values: a bare `--mentions` has none, so what follows it stays. */
|
|
1281
|
+
const without = (argv, ...options) => argv.filter((arg, at) => !options.some((option) => arg === option || arg.startsWith(`${option}=`) || argv[at - 1] === option && !(OPTIONS[option.slice(2)]?.optionalValue && arg.startsWith("-"))));
|
|
1255
1282
|
/**
|
|
1256
1283
|
* This run's command line without `options`, with `extra` in their place: both before any `--`,
|
|
1257
1284
|
* since what follows it is text, which a way out mustn't change or add options to.
|
|
@@ -1399,11 +1426,16 @@ let reached = null;
|
|
|
1399
1426
|
let sent = () => null;
|
|
1400
1427
|
/** How long the message text this run sends is, for a backend's refusal of it to say what to do instead. */
|
|
1401
1428
|
let sentLength = 0;
|
|
1402
|
-
/**
|
|
1429
|
+
/**
|
|
1430
|
+
* The help `words` ask for: a command's page when they name one (`read`, `sources read`), or with
|
|
1431
|
+
* none, every command. A word that names no command is unknown, as it is without `--help`.
|
|
1432
|
+
*/
|
|
1403
1433
|
function help(words = []) {
|
|
1404
1434
|
const own = Object.values(app.commands).map((command) => command.spec);
|
|
1405
1435
|
const path = commandPath(words, [...commands, ...own]);
|
|
1406
|
-
|
|
1436
|
+
if (path) return commandHelp(app.name, path);
|
|
1437
|
+
if (words[0] !== void 0 && words[0] !== "help") throw unknownCommand(words[0]);
|
|
1438
|
+
return rootHelp({
|
|
1407
1439
|
name: app.name,
|
|
1408
1440
|
commands: own
|
|
1409
1441
|
}, VERSION);
|
|
@@ -2131,7 +2163,10 @@ function failureOf(error) {
|
|
|
2131
2163
|
case "board_name_taken": return own("conflict", "board_name_taken");
|
|
2132
2164
|
case "board_not_granted": return own("permission", "board_not_granted");
|
|
2133
2165
|
case "watchers_need_project": return own("permission", "watchers_need_project");
|
|
2134
|
-
case "
|
|
2166
|
+
case "missing_team": return {
|
|
2167
|
+
...own("missing_input", "missing_scope", [{ instruction: "Use a team's board: add --scope <TEAM_ID>" }, { instruction: "Or set VERCEL_ORG_ID to its ID" }]),
|
|
2168
|
+
actionRequired: true
|
|
2169
|
+
};
|
|
2135
2170
|
case "invalid_board_name": return own("usage", "invalid_arguments", [helpRecovery()]);
|
|
2136
2171
|
case "too_many_redirects": return own("network", "network_error");
|
|
2137
2172
|
case "invalid_duration": return own("usage", "invalid_arguments", [helpRecovery()]);
|
|
@@ -2202,7 +2237,21 @@ function failureOf(error) {
|
|
|
2202
2237
|
...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" : current.command === "tasks" ? "Keep it short, and reply to the task 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" }]),
|
|
2203
2238
|
details: []
|
|
2204
2239
|
};
|
|
2205
|
-
if (code === "too_many_boards") return theirs("limit", code, `Can't ${doing()}. The team has all the boards it can.`,
|
|
2240
|
+
if (code === "too_many_boards") return theirs("limit", code, `Can't ${doing()}. The team has all the boards it can.`, current.command === "conformance" ? [{
|
|
2241
|
+
instruction: "Check a board by its URL, such as one from vb serve",
|
|
2242
|
+
argv: [
|
|
2243
|
+
...rerunWithout(["--name", "--scope"]).filter((arg) => arg !== "--ensure"),
|
|
2244
|
+
"--url",
|
|
2245
|
+
"<URL>"
|
|
2246
|
+
]
|
|
2247
|
+
}, {
|
|
2248
|
+
instruction: "Or the team's own board, which it posts to and changes the grants of",
|
|
2249
|
+
argv: [
|
|
2250
|
+
...rerunWithout(["--name"]).filter((arg) => arg !== "--ensure"),
|
|
2251
|
+
"--name",
|
|
2252
|
+
"General"
|
|
2253
|
+
]
|
|
2254
|
+
}] : flags.name !== void 0 ? [{
|
|
2206
2255
|
instruction: "Use the team's board instead",
|
|
2207
2256
|
argv: rerunWithout(["--name"]).filter((arg) => arg !== "--ensure")
|
|
2208
2257
|
}] : process.env.BOARD_NAME ? [{
|
|
@@ -2211,11 +2260,11 @@ function failureOf(error) {
|
|
|
2211
2260
|
}] : []);
|
|
2212
2261
|
if (code === "private_boards_unavailable") return theirs("limit", code, `Can't ${doing()}. This team's plan has no private boards.`, [{ instruction: "Keep the board open to the whole team, or move the team to a plan with private boards" }]);
|
|
2213
2262
|
if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
|
|
2214
|
-
if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", sent() === "the token you passed" ? [{ instruction: "Pass a token it accepts" }] : sent() === "BOARD_TOKEN" ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : [{
|
|
2263
|
+
if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", sent() === "the token you passed" ? [{ instruction: "Pass a token it accepts" }] : sent() === "BOARD_TOKEN" ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : sent() === "GitHub Actions OIDC" ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN" }] : [{
|
|
2215
2264
|
instruction: "Log in again",
|
|
2216
2265
|
argv: ["vercel", "login"]
|
|
2217
2266
|
}]);
|
|
2218
|
-
if (status === 403) return theirs("permission", "permission_denied", `You can't ${doing()}
|
|
2267
|
+
if (status === 403) return theirs("permission", "permission_denied", `You can't ${doing()}.`, refusedRecoveries());
|
|
2219
2268
|
if (status === 404) {
|
|
2220
2269
|
const thing = missing();
|
|
2221
2270
|
return thing ? {
|
|
@@ -2267,10 +2316,74 @@ function failureOf(error) {
|
|
|
2267
2316
|
if (status === 413) return theirs("limit", "payload_too_large", `Can't ${doing()}. It's too large for the board.`);
|
|
2268
2317
|
if (status === 501 && code === "no_direct_uploads") return theirs("limit", "payload_too_large", `Can't ${doing()}. The file is too large for this board.`, [{ instruction: "Compress it, or split it into smaller files" }]);
|
|
2269
2318
|
if (status === 429) return theirs("rate_limit", "rate_limited", `Can't ${doing()}. Too many requests to the board.`, [{ instruction: wait !== void 0 ? `Wait ${waitFor(wait)}, then run it again` : "Wait a minute, then run it again" }]);
|
|
2270
|
-
if (status === 501) return theirs("platform", specific("not_supported"), `Can't ${doing()}. This board doesn't support it
|
|
2319
|
+
if (status === 501) return theirs("platform", specific("not_supported"), `Can't ${doing()}. This board doesn't support it.`, unsupportedRecoveries());
|
|
2271
2320
|
if (code === "unreachable") return theirs("network", "network_error", "Couldn't reach the board.");
|
|
2272
2321
|
return theirs("platform", "api_error", `Failed to ${doing()}.`);
|
|
2273
2322
|
}
|
|
2323
|
+
/** The options that say which board this run is on, and as whom, as typed: what a way out to another command keeps. */
|
|
2324
|
+
const onThisBoard = () => [
|
|
2325
|
+
...flags.url !== void 0 ? ["--url", flags.url] : [],
|
|
2326
|
+
...(flags.scope ?? flags.team) !== void 0 ? ["--scope", flags.scope ?? flags.team] : [],
|
|
2327
|
+
...flags.name !== void 0 ? ["--name", flags.name] : [],
|
|
2328
|
+
...flags.as ? ["--as", flags.as] : []
|
|
2329
|
+
];
|
|
2330
|
+
/** Where to go from a 403: what you may do on this board, and who can let you do more. */
|
|
2331
|
+
const refusedRecoveries = () => [{
|
|
2332
|
+
instruction: "See what you can do on this board",
|
|
2333
|
+
argv: [
|
|
2334
|
+
...cli(),
|
|
2335
|
+
"whoami",
|
|
2336
|
+
...onThisBoard()
|
|
2337
|
+
]
|
|
2338
|
+
}, { instruction: "Or ask someone who manages the board's grants to give you access" }];
|
|
2339
|
+
/** The filters a board answers 501 to on a read when it keeps no index of them, as Vercel's does. */
|
|
2340
|
+
const UNINDEXED = [
|
|
2341
|
+
"--by",
|
|
2342
|
+
"--mentions",
|
|
2343
|
+
"--source",
|
|
2344
|
+
"--text"
|
|
2345
|
+
];
|
|
2346
|
+
/**
|
|
2347
|
+
* What to run instead of what a board answered 501 to, by what this run asked for: the same without
|
|
2348
|
+
* the part a board may not do (a read's search filters or its every channel, a post's `--sync`, a
|
|
2349
|
+
* schedule's files). Nothing when it asked for none of them.
|
|
2350
|
+
*/
|
|
2351
|
+
function unsupportedRecoveries() {
|
|
2352
|
+
const { command, args } = current;
|
|
2353
|
+
const given = (option) => flags[option.slice(2)] !== void 0;
|
|
2354
|
+
if (command === "read") {
|
|
2355
|
+
const filtered = UNINDEXED.filter(given);
|
|
2356
|
+
const target = args[0];
|
|
2357
|
+
const whole = target === void 0 || target.endsWith("/") && !isMessageRef(target);
|
|
2358
|
+
if (!filtered.length && !whole) return [];
|
|
2359
|
+
const argv = rerunWithout(filtered);
|
|
2360
|
+
if (whole) {
|
|
2361
|
+
const at = argv.indexOf(positionals[0], cli().length);
|
|
2362
|
+
argv.splice(at + 1, target === void 0 ? 0 : 1, "<CHANNEL>");
|
|
2363
|
+
}
|
|
2364
|
+
return [...whole ? [{
|
|
2365
|
+
instruction: "See the channels",
|
|
2366
|
+
argv: [
|
|
2367
|
+
...cli(),
|
|
2368
|
+
"channels",
|
|
2369
|
+
...target !== void 0 ? [target] : [],
|
|
2370
|
+
...onThisBoard()
|
|
2371
|
+
]
|
|
2372
|
+
}] : [], {
|
|
2373
|
+
instruction: whole ? `Read one channel at a time${filtered.length ? `, without ${filtered.join(" or ")}` : ""}` : `Read it without ${filtered.join(" or ")}, and look through it`,
|
|
2374
|
+
argv
|
|
2375
|
+
}];
|
|
2376
|
+
}
|
|
2377
|
+
if ((command === "post" || command === "reply") && given("--sync")) return [{
|
|
2378
|
+
instruction: "Post it without --sync",
|
|
2379
|
+
argv: rerunWithout(["--sync"])
|
|
2380
|
+
}];
|
|
2381
|
+
if (command === "schedule" && given("--attach")) return [{
|
|
2382
|
+
instruction: "Schedule the text without its files",
|
|
2383
|
+
argv: rerunWithout(["--attach"])
|
|
2384
|
+
}];
|
|
2385
|
+
return [];
|
|
2386
|
+
}
|
|
2274
2387
|
/** `42s`, `2m`: a wait the way people say it. */
|
|
2275
2388
|
const waitFor = (seconds) => seconds < 120 ? `${Math.max(1, seconds)}s` : `${Math.ceil(seconds / 60)}m`;
|
|
2276
2389
|
/** How this run ends with `failure`: shown on stderr, or by the app, and its exit code. */
|
|
@@ -2299,6 +2412,21 @@ function vercelBoard(url) {
|
|
|
2299
2412
|
...team ? { team } : {}
|
|
2300
2413
|
};
|
|
2301
2414
|
}
|
|
2415
|
+
/**
|
|
2416
|
+
* Whether this run's board is a team's board in Vercel's API, as its flags and environment say,
|
|
2417
|
+
* without a request: undefined when they don't say (an in-process handle, or no board to use).
|
|
2418
|
+
*/
|
|
2419
|
+
function onTeamBoard() {
|
|
2420
|
+
if (io.board) return void 0;
|
|
2421
|
+
try {
|
|
2422
|
+
if (flags.url !== void 0) return vercelBoard(flags.url) !== null;
|
|
2423
|
+
if (flags.scope !== void 0 || flags.team !== void 0 || flags.name !== void 0) return true;
|
|
2424
|
+
const url = configuredUrl();
|
|
2425
|
+
return url === null || vercelBoard(url) !== null;
|
|
2426
|
+
} catch {
|
|
2427
|
+
return;
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2302
2430
|
/** Who the handle writes as: `--as`'s profile (with `--avatar`), or what the environment says (`BOARD_PROFILE`), else yourself. */
|
|
2303
2431
|
function profileFlag() {
|
|
2304
2432
|
if (flags.avatar !== void 0 && !flags.as) throw usage("--avatar is the avatar of the profile --as names: pass --as too.", { reason: "missing_arguments" });
|
|
@@ -2568,6 +2696,7 @@ async function run(command, args) {
|
|
|
2568
2696
|
}]
|
|
2569
2697
|
});
|
|
2570
2698
|
const withHeaders = io.board ? {} : { withHeaders: (headers) => connection(void 0, { headers }).board };
|
|
2699
|
+
await client().me();
|
|
2571
2700
|
const report = await conformance(client(), {
|
|
2572
2701
|
...flags.channel ? { channel: flags.channel } : {},
|
|
2573
2702
|
...withHeaders
|
|
@@ -2664,7 +2793,7 @@ async function run(command, args) {
|
|
|
2664
2793
|
...working,
|
|
2665
2794
|
...mentionedIn([thread.message, ...replies])
|
|
2666
2795
|
])].filter((id) => !authors.has(id));
|
|
2667
|
-
const listed = unnamed.length ?
|
|
2796
|
+
const listed = unnamed.length ? await board.actors({ id: unnamed }).catch(() => []) : [];
|
|
2668
2797
|
const known = new Map(listed.map((a) => [a.id, actorName(a)]));
|
|
2669
2798
|
out(formatThreads([thread.message, ...replies], known, new Map(listed.map((a) => [a.id, a.handle]))));
|
|
2670
2799
|
if (!narrowed) for (const schedule of thread.schedules ?? []) out(formatSchedule(schedule, { pad: " " }));
|
|
@@ -2672,7 +2801,7 @@ async function run(command, args) {
|
|
|
2672
2801
|
}
|
|
2673
2802
|
const limit = flags.limit ? Number(flags.limit) : 50;
|
|
2674
2803
|
if (flags.before !== void 0 && flags.after !== void 0) throw usage("Can't use --before with --after. One pages back, the other reads forward.");
|
|
2675
|
-
const peek = !(target !== void 0 && !target.endsWith("/") && Object.keys(filters()).
|
|
2804
|
+
const peek = !(target !== void 0 && !target.endsWith("/") && Object.keys(filters()).every((key) => key === "mentions" || key === "text")) && !flags.json && flags.before === void 0 && Number.isInteger(limit) && limit >= 1 && limit < 500;
|
|
2676
2805
|
const query = {
|
|
2677
2806
|
...filters(target),
|
|
2678
2807
|
...flags.before !== void 0 ? { before: flags.before } : {},
|
|
@@ -2689,7 +2818,8 @@ async function run(command, args) {
|
|
|
2689
2818
|
...listed,
|
|
2690
2819
|
threads: flags.after !== void 0 ? listed.threads.slice(0, limit) : listed.threads.slice(-limit)
|
|
2691
2820
|
} : listed;
|
|
2692
|
-
|
|
2821
|
+
const scanned = typeof listed.scanned === "number" ? listed.scanned : void 0;
|
|
2822
|
+
if (!page.threads.length && target && !scanned) {
|
|
2693
2823
|
const channels = (await everyChannel(board)).map((c) => c.path);
|
|
2694
2824
|
if (!channels.some((path) => path === target || path.startsWith(target.replace(/\/?$/, "/")))) {
|
|
2695
2825
|
const guess = closest(target, channels);
|
|
@@ -2712,12 +2842,13 @@ async function run(command, args) {
|
|
|
2712
2842
|
const roots = page.threads.map(({ message }) => message);
|
|
2713
2843
|
const wrote = new Set(page.threads.flatMap(({ message, last }) => last ? [message.by.actor, last.by.actor] : [message.by.actor]));
|
|
2714
2844
|
const unnamed = mentionedIn(roots).filter((id) => !wrote.has(id));
|
|
2715
|
-
const handles = new Map(unnamed.length ? (await
|
|
2845
|
+
const handles = new Map(unnamed.length ? (await board.actors({ id: unnamed }).catch(() => [])).map((a) => [a.id, a.handle]) : []);
|
|
2716
2846
|
out(formatThreadSummaries(page.threads, {
|
|
2717
2847
|
channel: !target || target.endsWith("/"),
|
|
2718
2848
|
handles
|
|
2719
2849
|
}));
|
|
2720
2850
|
}
|
|
2851
|
+
if (scanned !== void 0) out(`\n(looked through ${scanned} ${scanned === 1 ? "thread" : "threads"}, at the first and latest message of each: a match under a newer reply is not found)`);
|
|
2721
2852
|
const latest = page.threads.at(-1);
|
|
2722
2853
|
if (more && flags.after !== void 0 && latest) {
|
|
2723
2854
|
if (![
|
|
@@ -2733,6 +2864,16 @@ async function run(command, args) {
|
|
|
2733
2864
|
}
|
|
2734
2865
|
if (more) out(older !== void 0 ? `\n(older not shown: ${commandLine(rerunWithout(["--before"], "--before", older))})` : limit < 500 ? `\n(older not shown: ${commandLine(rerunWithout(["--limit", "-n"], "--limit", String(Math.min(500, limit * 2))))})` : `\n(older not shown: 500 is the most a read lists, so read one channel and page back with --before, or narrow it with --label)`);
|
|
2735
2866
|
if (flags.before !== void 0) return 0;
|
|
2867
|
+
if (scanned !== void 0) {
|
|
2868
|
+
const argv = rerunWithout([
|
|
2869
|
+
"--after",
|
|
2870
|
+
"--limit",
|
|
2871
|
+
"-n"
|
|
2872
|
+
], "--after", String(page.cursor));
|
|
2873
|
+
argv[argv.indexOf("read", cli().length)] = "wait";
|
|
2874
|
+
out(`\nnew since then: ${commandLine(argv)}`);
|
|
2875
|
+
return 0;
|
|
2876
|
+
}
|
|
2736
2877
|
out(`\nnew since then: ${commandLine(rerunWithout(["--after"], "--after", String(page.cursor)))}`);
|
|
2737
2878
|
return 0;
|
|
2738
2879
|
}
|
|
@@ -3228,21 +3369,28 @@ async function run(command, args) {
|
|
|
3228
3369
|
default: {
|
|
3229
3370
|
const own = app.commands[command];
|
|
3230
3371
|
if (own) return own.run(args, context());
|
|
3231
|
-
|
|
3232
|
-
const said = Object.hasOwn(OTHER_NAMES, command.toLowerCase()) ? OTHER_NAMES[command.toLowerCase()] : void 0;
|
|
3233
|
-
throw usage(`Unknown command ${command} for ${named()}.${said ? "" : guess ? ` Did you mean ${guess}?` : ""}`, {
|
|
3234
|
-
reason: "unknown_command",
|
|
3235
|
-
next: [...said ? [{
|
|
3236
|
-
instruction: said.instruction,
|
|
3237
|
-
argv: [...cli(), ...said.argv]
|
|
3238
|
-
}] : [], {
|
|
3239
|
-
instruction: "See all commands",
|
|
3240
|
-
argv: [...cli(), "--help"]
|
|
3241
|
-
}]
|
|
3242
|
-
});
|
|
3372
|
+
throw unknownCommand(command);
|
|
3243
3373
|
}
|
|
3244
3374
|
}
|
|
3245
3375
|
}
|
|
3376
|
+
/** Every name a command runs by here: board's, their aliases, and the app's own. */
|
|
3377
|
+
const commandNames = () => [...commands.flatMap((known) => [known.name, ...known.aliases ?? []]), ...Object.keys(app.commands)];
|
|
3378
|
+
/** `command` names nothing here: the closest that does, or what it goes by here. */
|
|
3379
|
+
function unknownCommand(command) {
|
|
3380
|
+
const guess = closest(command, commandNames());
|
|
3381
|
+
const other = Object.hasOwn(OTHER_NAMES, command.toLowerCase()) ? OTHER_NAMES[command.toLowerCase()] : void 0;
|
|
3382
|
+
const said = other?.teams && onTeamBoard() !== false ? other.teams : other;
|
|
3383
|
+
return usage(`Unknown command ${command} for ${named()}.${said ? "" : guess ? ` Did you mean ${guess}?` : ""}`, {
|
|
3384
|
+
reason: "unknown_command",
|
|
3385
|
+
next: [...said ? [{
|
|
3386
|
+
instruction: said.instruction,
|
|
3387
|
+
argv: [...cli(), ...said.argv]
|
|
3388
|
+
}] : [], {
|
|
3389
|
+
instruction: "See all commands",
|
|
3390
|
+
argv: [...cli(), "--help"]
|
|
3391
|
+
}]
|
|
3392
|
+
});
|
|
3393
|
+
}
|
|
3246
3394
|
/** What `tasks` does to a task, by the word after it: any other word is a channel to list. */
|
|
3247
3395
|
const TASK_VERBS = /* @__PURE__ */ new Set([
|
|
3248
3396
|
"create",
|
|
@@ -3293,7 +3441,9 @@ function seconds(flag) {
|
|
|
3293
3441
|
*/
|
|
3294
3442
|
async function createPlan(target, text, path) {
|
|
3295
3443
|
if (isMessageRef(target)) throw usage(`--file holds a plan, which starts threads in a channel, and ${ref(target)} is a thread.`);
|
|
3296
|
-
|
|
3444
|
+
if (text !== void 0) throw usage("Text is one task's: with --file, each task in the file has its own.");
|
|
3445
|
+
const parsed = await planSource(path);
|
|
3446
|
+
const own = [
|
|
3297
3447
|
"label",
|
|
3298
3448
|
"needs",
|
|
3299
3449
|
"for",
|
|
@@ -3301,9 +3451,9 @@ async function createPlan(target, text, path) {
|
|
|
3301
3451
|
"lease",
|
|
3302
3452
|
"no-sync"
|
|
3303
3453
|
].find((name) => flags[name] !== void 0 && flags[name] !== false);
|
|
3304
|
-
if (own !== void 0) throw usage(
|
|
3454
|
+
if (own !== void 0) throw usage(`--${own} is one task's: with --file, each task in the file has its own.`);
|
|
3305
3455
|
const board = client();
|
|
3306
|
-
const tasks = await planFrom(path, board);
|
|
3456
|
+
const tasks = await planFrom(parsed, path, board);
|
|
3307
3457
|
sentLength = Math.max(0, ...tasks.map((task) => typeof task.text === "string" ? task.text.length : 0));
|
|
3308
3458
|
const key = flags["idempotency-key"] ?? crypto.randomUUID();
|
|
3309
3459
|
let made;
|
|
@@ -3361,13 +3511,27 @@ const planHelp = () => ({
|
|
|
3361
3511
|
"--help"
|
|
3362
3512
|
]
|
|
3363
3513
|
});
|
|
3364
|
-
/** One of a plan task's `needs`: a task that's there, by its ID as text
|
|
3514
|
+
/** One of a plan task's `needs`: a task that's there, by its ID as text, as a number, or as `{ "id": … }`, or `{ "key": … }` for one of the plan's own. */
|
|
3365
3515
|
function isNeed(need) {
|
|
3366
3516
|
if (typeof need === "string") return need.replace(/^#/, "").length > 0;
|
|
3367
3517
|
if (typeof need === "number") return Number.isSafeInteger(need) && need >= 0;
|
|
3368
3518
|
if (typeof need !== "object" || need === null) return false;
|
|
3369
3519
|
const keys = Object.keys(need);
|
|
3370
|
-
|
|
3520
|
+
if (keys.length !== 1) return false;
|
|
3521
|
+
const value = need[keys[0]];
|
|
3522
|
+
if (keys[0] === "id") return typeof value === "string" && isNeed(value);
|
|
3523
|
+
return keys[0] === "key" && typeof value === "string";
|
|
3524
|
+
}
|
|
3525
|
+
/** A need as the board takes it: an ID as it is, or `{ "key": … }`, which a bare string is when it's a key of the plan's own. */
|
|
3526
|
+
function boardNeed(need, keys) {
|
|
3527
|
+
if (typeof need === "string" && keys.has(need)) return { key: need };
|
|
3528
|
+
return idNeed(need);
|
|
3529
|
+
}
|
|
3530
|
+
function idNeed(need) {
|
|
3531
|
+
if (typeof need === "string") return need.replace(/^#/, "");
|
|
3532
|
+
if (typeof need === "number") return String(need);
|
|
3533
|
+
if (typeof need === "object" && need !== null && "id" in need) return idNeed(need.id);
|
|
3534
|
+
return need;
|
|
3371
3535
|
}
|
|
3372
3536
|
/**
|
|
3373
3537
|
* Refuses a plan that says something a task doesn't take, before anything is sent. The board
|
|
@@ -3393,12 +3557,16 @@ function checkPlan(plan, where) {
|
|
|
3393
3557
|
const odd = task.needs.find((need) => !isNeed(need));
|
|
3394
3558
|
if (odd !== void 0) {
|
|
3395
3559
|
const said = JSON.stringify(odd);
|
|
3396
|
-
throw usage(`Task ${at + 1} of ${where} needs ${said.length > 60 ? `${said.slice(0, 59)}…` : said}
|
|
3560
|
+
throw usage(`Task ${at + 1} of ${where} needs ${said.length > 60 ? `${said.slice(0, 59)}…` : said}. A need is a key of the plan's own, like "fix" or {"key": "fix"}, or a task's ID as vb prints it or as {"id": "…"}.`, { next: [planHelp()] });
|
|
3397
3561
|
}
|
|
3398
3562
|
}
|
|
3399
3563
|
}
|
|
3400
|
-
/**
|
|
3401
|
-
|
|
3564
|
+
/**
|
|
3565
|
+
* What a plan's `--file` holds, as JSON: the file, or stdin for `-`. Prose is the likeliest slip,
|
|
3566
|
+
* --file carried over from post, where it's the text: it says the same command with the file on
|
|
3567
|
+
* stdin, `-` as the text, and the options it was given.
|
|
3568
|
+
*/
|
|
3569
|
+
async function planSource(path) {
|
|
3402
3570
|
const where = path === "-" ? "stdin" : path;
|
|
3403
3571
|
let source;
|
|
3404
3572
|
if (path === "-") source = await io.stdin();
|
|
@@ -3410,20 +3578,25 @@ async function planFrom(path, board) {
|
|
|
3410
3578
|
});
|
|
3411
3579
|
source = new TextDecoder().decode(data);
|
|
3412
3580
|
}
|
|
3413
|
-
let parsed;
|
|
3414
3581
|
try {
|
|
3415
|
-
|
|
3582
|
+
return JSON.parse(source);
|
|
3416
3583
|
} catch {
|
|
3417
|
-
|
|
3584
|
+
const piped = `${commandLine(rerunWithout(["--file"], "-"))}${path === "-" ? "" : ` < ${commandLine([path])}`}`;
|
|
3585
|
+
throw usage(`${where} isn't JSON: --file on tasks create is a plan of tasks.`, { next: [{ instruction: `One task's text goes on stdin, as -: ${piped}` }, planHelp()] });
|
|
3418
3586
|
}
|
|
3587
|
+
}
|
|
3588
|
+
/** The tasks a plan's `--file` holds: a JSON array. An ID may be written `#812`, and `for` as a profile's name. */
|
|
3589
|
+
async function planFrom(parsed, path, board) {
|
|
3590
|
+
const where = path === "-" ? "stdin" : path;
|
|
3419
3591
|
const shape = "A plan is a JSON array of tasks: [{\"key\": \"fix\", \"text\": \"…\"}, {\"text\": \"…\", \"needs\": [{\"key\": \"fix\"}]}].";
|
|
3420
3592
|
if (!Array.isArray(parsed) || parsed.length === 0 || parsed.some((task) => typeof task !== "object" || task === null || Array.isArray(task))) throw usage(`${where} holds no tasks. ${shape}`, { next: [planHelp()] });
|
|
3421
3593
|
const plan = parsed;
|
|
3422
3594
|
checkPlan(plan, where);
|
|
3423
3595
|
const principal = plan.some((task) => typeof task.for === "string" && !task.for.includes(":")) ? (await board.me()).principal : "";
|
|
3596
|
+
const keys = new Set(plan.flatMap((task) => typeof task.key === "string" ? [task.key] : []));
|
|
3424
3597
|
return plan.map((task) => ({
|
|
3425
3598
|
...task,
|
|
3426
|
-
...Array.isArray(task.needs) ? { needs: task.needs.map((need) =>
|
|
3599
|
+
...Array.isArray(task.needs) ? { needs: task.needs.map((need) => boardNeed(need, keys)) } : {},
|
|
3427
3600
|
...typeof task.for === "string" && !task.for.includes(":") ? { for: profileActor(principal, task.for) } : {}
|
|
3428
3601
|
}));
|
|
3429
3602
|
}
|
|
@@ -3444,14 +3617,18 @@ const asTyped = () => flags.as ? ["--as", flags.as] : [];
|
|
|
3444
3617
|
/**
|
|
3445
3618
|
* This run's board, and the claims it holds there as whoever it writes as. A claim's token is the
|
|
3446
3619
|
* CLI's to keep: in a file under its config directory, by the board's URL, the task, and the
|
|
3447
|
-
* profile this run writes as; or for `vb()`, whose board is a handle, in
|
|
3448
|
-
* handle lasts.
|
|
3620
|
+
* profile this run writes as; or for `vb()`, whose board is a handle, in the store its caller
|
|
3621
|
+
* passes, or else in memory for as long as the handle lasts.
|
|
3449
3622
|
*/
|
|
3450
3623
|
function tasksOn() {
|
|
3451
3624
|
const profile = writesAs();
|
|
3625
|
+
if (io.board && io.claimToken !== void 0) return {
|
|
3626
|
+
board: client(),
|
|
3627
|
+
claims: tokenClaims(client(), io.claimToken)
|
|
3628
|
+
};
|
|
3452
3629
|
if (io.board) return {
|
|
3453
3630
|
board: client(),
|
|
3454
|
-
claims: memoryClaims(io.claimsOf ?? io.board, profile)
|
|
3631
|
+
claims: io.claims?.(profile) ?? memoryClaims(io.claimsOf ?? io.board, profile)
|
|
3455
3632
|
};
|
|
3456
3633
|
const { board, url } = connection();
|
|
3457
3634
|
return {
|
|
@@ -3488,22 +3665,69 @@ function printClaim(task, claim, more = {}) {
|
|
|
3488
3665
|
*/
|
|
3489
3666
|
async function heldBy(board, claims, id) {
|
|
3490
3667
|
const stored = await claims.get(id);
|
|
3491
|
-
if (
|
|
3668
|
+
if (stored) return board.tasks.held(id, stored);
|
|
3669
|
+
const none = `You hold no claim on task ${ref(id)} as ${writesAs() ?? "yourself"}.`;
|
|
3670
|
+
const claim = {
|
|
3671
|
+
instruction: "Claim it",
|
|
3672
|
+
argv: [
|
|
3673
|
+
...cli(),
|
|
3674
|
+
"tasks",
|
|
3675
|
+
"claim",
|
|
3676
|
+
id,
|
|
3677
|
+
...asTyped()
|
|
3678
|
+
]
|
|
3679
|
+
};
|
|
3680
|
+
const task = await board.thread(id).then(({ message }) => message.task, () => void 0);
|
|
3681
|
+
const see = {
|
|
3682
|
+
instruction: "See where it stands",
|
|
3683
|
+
argv: [
|
|
3684
|
+
...cli(),
|
|
3685
|
+
"read",
|
|
3686
|
+
id
|
|
3687
|
+
]
|
|
3688
|
+
};
|
|
3689
|
+
if (task?.state === "blocked") throw new Failed({
|
|
3492
3690
|
class: "conflict",
|
|
3493
3691
|
reason: "claim_not_held",
|
|
3494
|
-
message:
|
|
3692
|
+
message: `${none} It's held for a person: claim it once the hold lifts.`,
|
|
3495
3693
|
next: [{
|
|
3496
|
-
instruction: "
|
|
3694
|
+
instruction: "As its owner, lift the hold, then claim it",
|
|
3497
3695
|
argv: [
|
|
3498
3696
|
...cli(),
|
|
3499
3697
|
"tasks",
|
|
3500
|
-
"
|
|
3501
|
-
id
|
|
3502
|
-
...asTyped()
|
|
3698
|
+
"unblock",
|
|
3699
|
+
id
|
|
3503
3700
|
]
|
|
3504
|
-
}]
|
|
3701
|
+
}, see]
|
|
3702
|
+
});
|
|
3703
|
+
if (task?.state === "waiting") {
|
|
3704
|
+
const needs = task.needs.map(ref);
|
|
3705
|
+
throw new Failed({
|
|
3706
|
+
class: "conflict",
|
|
3707
|
+
reason: "claim_not_held",
|
|
3708
|
+
message: `${none} It waits for what it needs${needs.length ? ` (${needs.join(", ")})` : ""}: claim it once those complete.`,
|
|
3709
|
+
next: [{
|
|
3710
|
+
instruction: "See what it waits for",
|
|
3711
|
+
argv: [
|
|
3712
|
+
...cli(),
|
|
3713
|
+
"read",
|
|
3714
|
+
id
|
|
3715
|
+
]
|
|
3716
|
+
}]
|
|
3717
|
+
});
|
|
3718
|
+
}
|
|
3719
|
+
if (task?.state === "completed" || task?.state === "failed" || task?.state === "canceled") throw new Failed({
|
|
3720
|
+
class: "conflict",
|
|
3721
|
+
reason: "claim_not_held",
|
|
3722
|
+
message: `${none} It's ${task.state} already.`,
|
|
3723
|
+
next: [see]
|
|
3724
|
+
});
|
|
3725
|
+
throw new Failed({
|
|
3726
|
+
class: "conflict",
|
|
3727
|
+
reason: "claim_not_held",
|
|
3728
|
+
message: none,
|
|
3729
|
+
next: [claim]
|
|
3505
3730
|
});
|
|
3506
|
-
return board.tasks.held(id, stored);
|
|
3507
3731
|
}
|
|
3508
3732
|
/** A write a claim makes. One the board answers `claim_lost` is over: the CLI forgets it, and the failure says how to claim again. */
|
|
3509
3733
|
async function withClaim(claims, id, write) {
|
|
@@ -3515,11 +3739,47 @@ async function withClaim(claims, id, write) {
|
|
|
3515
3739
|
}
|
|
3516
3740
|
}
|
|
3517
3741
|
/**
|
|
3742
|
+
* `--label` on `claim --ready` and `run --ready`: each an exact `key=value`, the one thing a claim
|
|
3743
|
+
* matches. The list's `key=a|b` and bare `key` would match nothing, or the value `a|b`, and wait
|
|
3744
|
+
* out its `--wait` without a word: they're refused, with the claim of one value and the list.
|
|
3745
|
+
*/
|
|
3746
|
+
function readyLabels(values, target, verb) {
|
|
3747
|
+
for (const value of values) {
|
|
3748
|
+
const at = value.indexOf("=");
|
|
3749
|
+
const options = at > 0 ? value.slice(at + 1).split("|") : [];
|
|
3750
|
+
if (at > 0 && options.length < 2) continue;
|
|
3751
|
+
const key = at > 0 ? value.slice(0, at) : value;
|
|
3752
|
+
if (at === 0) throw usage(`--label on ${verb} --ready takes key=value, and ${value} has no key before its =.`);
|
|
3753
|
+
const listed = {
|
|
3754
|
+
instruction: "See what's ready, and their labels",
|
|
3755
|
+
argv: [
|
|
3756
|
+
...cli(),
|
|
3757
|
+
"tasks",
|
|
3758
|
+
target,
|
|
3759
|
+
"--state",
|
|
3760
|
+
"ready",
|
|
3761
|
+
"--label",
|
|
3762
|
+
value
|
|
3763
|
+
]
|
|
3764
|
+
};
|
|
3765
|
+
if (at === -1) throw usage(`--label on ${verb} --ready takes key=value: ${value} has no value, and a claim matches one exactly.`, { next: [listed] });
|
|
3766
|
+
const one = `${key}=${options[0]}`;
|
|
3767
|
+
const dash = typed.indexOf("--");
|
|
3768
|
+
const ours = (index) => dash === -1 || index < dash;
|
|
3769
|
+
const again = [...cli(), ...typed.map((arg, index) => !ours(index) ? arg : arg === value && typed[index - 1] === "--label" ? one : arg === `--label=${value}` ? `--label=${one}` : arg)];
|
|
3770
|
+
throw usage(`--label on ${verb} --ready takes one value: ${value} has ${options.length}, and a claim matches one exactly.`, { next: [{
|
|
3771
|
+
instruction: `Claim one with ${one}`,
|
|
3772
|
+
argv: again
|
|
3773
|
+
}, listed] });
|
|
3774
|
+
}
|
|
3775
|
+
return labelPairs(values);
|
|
3776
|
+
}
|
|
3777
|
+
/**
|
|
3518
3778
|
* Claims a task for this run, by its ID or with `--ready` the oldest ready one in `target`, and
|
|
3519
3779
|
* keeps the claim. With nothing ready it fails: `nothing_ready`, or `timeout` once `--wait` ran
|
|
3520
3780
|
* out, as `wait` does. Stopped while it waits, it answers the exit code instead.
|
|
3521
3781
|
*/
|
|
3522
|
-
async function claimFor(board, claims, target) {
|
|
3782
|
+
async function claimFor(board, claims, target, verb) {
|
|
3523
3783
|
const lease = seconds("lease");
|
|
3524
3784
|
if (!flags.ready) {
|
|
3525
3785
|
for (const given of [
|
|
@@ -3527,7 +3787,10 @@ async function claimFor(board, claims, target) {
|
|
|
3527
3787
|
"from",
|
|
3528
3788
|
"wait"
|
|
3529
3789
|
]) if (flags[given] !== void 0) throw usage(`--${given} goes with --ready, which claims the next ready task in a channel.`);
|
|
3530
|
-
const claim = await board.tasks.claim(taskId(target),
|
|
3790
|
+
const claim = await board.tasks.claim(taskId(target), {
|
|
3791
|
+
...lease !== void 0 ? { lease } : {},
|
|
3792
|
+
...io.claimToken !== void 0 ? { token: io.claimToken } : {}
|
|
3793
|
+
});
|
|
3531
3794
|
await claims.put(claim.task.id, {
|
|
3532
3795
|
epoch: claim.epoch,
|
|
3533
3796
|
token: claim.token,
|
|
@@ -3547,10 +3810,11 @@ async function claimFor(board, claims, target) {
|
|
|
3547
3810
|
try {
|
|
3548
3811
|
claim = await board.tasks.claim({
|
|
3549
3812
|
channel: target,
|
|
3550
|
-
...flags.label?.length ? { label:
|
|
3813
|
+
...flags.label?.length ? { label: readyLabels(flags.label, target, verb) } : {},
|
|
3551
3814
|
...flags.from?.length ? { from: flags.from } : {},
|
|
3552
3815
|
...wait !== void 0 ? { wait } : {},
|
|
3553
|
-
...lease !== void 0 ? { lease } : {}
|
|
3816
|
+
...lease !== void 0 ? { lease } : {},
|
|
3817
|
+
...io.claimToken !== void 0 ? { token: io.claimToken } : {}
|
|
3554
3818
|
}, { signal: controller.signal });
|
|
3555
3819
|
} catch (error) {
|
|
3556
3820
|
if (controller.signal.aborted) return stop.interrupted() ? 130 : 0;
|
|
@@ -3649,7 +3913,8 @@ async function tasks(args) {
|
|
|
3649
3913
|
...flags.needs?.length ? { needs: flags.needs.map((id) => taskId(id)) } : {},
|
|
3650
3914
|
...flags.for ? { for: profileActor((await board.me()).principal, flags.for) } : {},
|
|
3651
3915
|
...claimFlag() ? { claim: true } : {},
|
|
3652
|
-
...lease !== void 0 ? { lease } : {}
|
|
3916
|
+
...lease !== void 0 ? { lease } : {},
|
|
3917
|
+
...claimFlag() && io.claimToken !== void 0 ? { token: io.claimToken } : {}
|
|
3653
3918
|
};
|
|
3654
3919
|
let made;
|
|
3655
3920
|
if (isMessageRef(target)) {
|
|
@@ -3704,7 +3969,7 @@ async function tasks(args) {
|
|
|
3704
3969
|
if (rest.length > 1) throw usage(`tasks claim takes one ${flags.ready ? "channel" : "task"}: ${rest[1]} is one too many.`);
|
|
3705
3970
|
if (!flags.ready && rest[0] === void 0) throw usage("Missing the task to claim: its ID, or --ready and a channel.", { reason: "missing_arguments" });
|
|
3706
3971
|
const { board, claims } = tasksOn();
|
|
3707
|
-
const claim = await claimFor(board, claims, rest[0]);
|
|
3972
|
+
const claim = await claimFor(board, claims, rest[0], "claim");
|
|
3708
3973
|
if (typeof claim === "number") return claim;
|
|
3709
3974
|
printClaim(claim.task, claim);
|
|
3710
3975
|
return 0;
|
|
@@ -3734,7 +3999,7 @@ async function tasks(args) {
|
|
|
3734
3999
|
next: []
|
|
3735
4000
|
});
|
|
3736
4001
|
const { board, claims } = tasksOn();
|
|
3737
|
-
const claim = await claimFor(board, claims, before[0]);
|
|
4002
|
+
const claim = await claimFor(board, claims, before[0], "run");
|
|
3738
4003
|
if (typeof claim === "number") return claim;
|
|
3739
4004
|
const id = claim.task.id;
|
|
3740
4005
|
const lease = seconds("lease");
|
|
@@ -4084,35 +4349,33 @@ function stateCommand() {
|
|
|
4084
4349
|
if (flags.label?.some((pair) => pair === "board.task" || pair.startsWith("board.task=")) && command === "post" && args[0] !== void 0 && !isMessageRef(args[0])) return [tasksDo("Start it as a task", "create", args[0], "<TEXT>")];
|
|
4085
4350
|
return [];
|
|
4086
4351
|
}
|
|
4087
|
-
/**
|
|
4088
|
-
const
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
find: {
|
|
4099
|
-
instruction: "Search is a filter on read",
|
|
4100
|
-
argv: [
|
|
4101
|
-
"read",
|
|
4102
|
-
"<CHANNEL>",
|
|
4103
|
-
"--text",
|
|
4104
|
-
"<PHRASE>"
|
|
4105
|
-
]
|
|
4106
|
-
},
|
|
4107
|
-
grep: {
|
|
4108
|
-
instruction: "Search is a filter on read",
|
|
4352
|
+
/** Search: a filter on read. Vercel's board keeps no index of text, so there it looks through a page of a channel's threads. */
|
|
4353
|
+
const SEARCH = {
|
|
4354
|
+
instruction: "Search is a filter on read",
|
|
4355
|
+
argv: [
|
|
4356
|
+
"read",
|
|
4357
|
+
"<CHANNEL>",
|
|
4358
|
+
"--text",
|
|
4359
|
+
"<PHRASE>"
|
|
4360
|
+
],
|
|
4361
|
+
teams: {
|
|
4362
|
+
instruction: "Search a channel's latest threads, a page at a time, since this board keeps no text search",
|
|
4109
4363
|
argv: [
|
|
4110
4364
|
"read",
|
|
4111
4365
|
"<CHANNEL>",
|
|
4112
4366
|
"--text",
|
|
4113
4367
|
"<PHRASE>"
|
|
4114
4368
|
]
|
|
4115
|
-
}
|
|
4369
|
+
}
|
|
4370
|
+
};
|
|
4371
|
+
/**
|
|
4372
|
+
* Words for a command this CLI names otherwise, and the command they mean: on a team's board in
|
|
4373
|
+
* Vercel's API, `teams`, where it reads one channel's page (or when nothing says which board).
|
|
4374
|
+
*/
|
|
4375
|
+
const OTHER_NAMES = {
|
|
4376
|
+
search: SEARCH,
|
|
4377
|
+
find: SEARCH,
|
|
4378
|
+
grep: SEARCH,
|
|
4116
4379
|
list: {
|
|
4117
4380
|
instruction: "List a channel's threads with read",
|
|
4118
4381
|
argv: ["read", "<CHANNEL>"]
|
|
@@ -4244,23 +4507,20 @@ const OTHER_NAMES = {
|
|
|
4244
4507
|
]
|
|
4245
4508
|
},
|
|
4246
4509
|
claim: {
|
|
4247
|
-
instruction: "
|
|
4510
|
+
instruction: "Hold a task with tasks claim",
|
|
4248
4511
|
argv: [
|
|
4249
|
-
"
|
|
4250
|
-
"
|
|
4251
|
-
"
|
|
4252
|
-
"--if-unset",
|
|
4253
|
-
"owner"
|
|
4512
|
+
"tasks",
|
|
4513
|
+
"claim",
|
|
4514
|
+
"<ID>"
|
|
4254
4515
|
]
|
|
4255
4516
|
},
|
|
4256
4517
|
assign: {
|
|
4257
|
-
instruction: "
|
|
4518
|
+
instruction: "Keep a task for one of its owner's profiles",
|
|
4258
4519
|
argv: [
|
|
4259
|
-
"
|
|
4520
|
+
"tasks",
|
|
4521
|
+
"assign",
|
|
4260
4522
|
"<ID>",
|
|
4261
|
-
"
|
|
4262
|
-
"--if-unset",
|
|
4263
|
-
"owner"
|
|
4523
|
+
"<PROFILE>"
|
|
4264
4524
|
]
|
|
4265
4525
|
},
|
|
4266
4526
|
tag: {
|
|
@@ -4281,7 +4541,15 @@ const OTHER_NAMES = {
|
|
|
4281
4541
|
},
|
|
4282
4542
|
mentions: {
|
|
4283
4543
|
instruction: "Mentions are a filter on read and wait",
|
|
4284
|
-
argv: ["read", "--mentions"]
|
|
4544
|
+
argv: ["read", "--mentions"],
|
|
4545
|
+
teams: {
|
|
4546
|
+
instruction: "Read what mentions you in a channel's latest threads, then wait from where it stops",
|
|
4547
|
+
argv: [
|
|
4548
|
+
"read",
|
|
4549
|
+
"<CHANNEL>",
|
|
4550
|
+
"--mentions"
|
|
4551
|
+
]
|
|
4552
|
+
}
|
|
4285
4553
|
},
|
|
4286
4554
|
watch: {
|
|
4287
4555
|
instruction: "Block for the next match with wait, or follow live with tail",
|