@vercel/board 0.45.0 → 0.46.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.
Files changed (76) hide show
  1. package/dist/{access-3udXjJAg.mjs → access-Crbvd2Dm.mjs} +2 -2
  2. package/dist/access.d.mts +2 -2
  3. package/dist/access.mjs +5 -5
  4. package/dist/{actors-DasGZnfb.mjs → actors-BBphaJ_G.mjs} +3 -3
  5. package/dist/{auth-aiOVE82-.mjs → auth-C-pFnJBA.mjs} +2 -2
  6. package/dist/{auth-BG_whr9_.d.mts → auth-CkNXnQno.d.mts} +1 -1
  7. package/dist/{backend-D6yTo8Un.d.mts → backend-D3p8gjba.d.mts} +126 -4
  8. package/dist/backend-local.d.mts +1 -1
  9. package/dist/backend-local.mjs +1 -1
  10. package/dist/{chat-provider-BvNqOQFL.mjs → chat-provider-1zpY6Qo_.mjs} +2 -2
  11. package/dist/{chat-provider-V2jnjVLq.d.mts → chat-provider-Bn33acHd.d.mts} +2 -2
  12. package/dist/cli-commands.d.mts +1 -1
  13. package/dist/cli-commands.mjs +1 -1
  14. package/dist/cli-embedded.d.mts +2 -2
  15. package/dist/cli-embedded.mjs +3 -2
  16. package/dist/cli.mjs +6 -6
  17. package/dist/{commands-DewS14_P.d.mts → commands-CSZPQ38I.d.mts} +54 -0
  18. package/dist/{commands-CqdnjUkm.mjs → commands-D0lyo8O8.mjs} +319 -0
  19. package/dist/{conformance-BInS4_6b.mjs → conformance-Blzd4CXG.mjs} +972 -6
  20. package/dist/conformance.d.mts +6 -5
  21. package/dist/conformance.mjs +1 -1
  22. package/dist/{engine-XVBt02Bl.mjs → engine-C_SlBihU.mjs} +15 -7
  23. package/dist/{errors-ZazTZh-s.mjs → errors-DZ1tbwSM.mjs} +151 -3
  24. package/dist/{events-D17RndlV.mjs → events-mGuhF4i5.mjs} +2 -2
  25. package/dist/{exports-DCf75prP.mjs → exports-DQauuHrc.mjs} +1248 -45
  26. package/dist/exports-DUX_Yzo7.d.mts +44 -0
  27. package/dist/{external-DfhN7lKK.mjs → external-BVr1Sq0y.mjs} +1 -1
  28. package/dist/{index-Djmr4GzQ.d.mts → index-BHXg4Xdo.d.mts} +2 -2
  29. package/dist/index.d.mts +6 -6
  30. package/dist/index.mjs +5 -5
  31. package/dist/index.node.d.mts +7 -6
  32. package/dist/index.node.mjs +5 -4
  33. package/dist/inspect/app.js +215 -115
  34. package/dist/inspect/engine.js +5 -5
  35. package/dist/{inspect-B0_aKQM8.mjs → inspect-2OIjv2lW.mjs} +242 -20
  36. package/dist/inspect-F-b4GPXX.mjs +2 -0
  37. package/dist/{local-Bel_oeFa.mjs → local-11FMUJrU.mjs} +1593 -60
  38. package/dist/{main-DmsdcUZ_.mjs → main-BYmbTDgo.mjs} +1167 -24
  39. package/dist/{memory-DyEL0fvN.mjs → memory-CZBdVNn8.mjs} +2 -2
  40. package/dist/{middleware-BHHKHA9q.mjs → middleware-BKsTcMAv.mjs} +2 -2
  41. package/dist/{provider-BC9mPYVh.d.mts → provider-D3bfHRHA.d.mts} +119 -3
  42. package/dist/{routes-CkUetTO2.mjs → routes-B2HHHD_C.mjs} +246 -6
  43. package/dist/{routes-zm4TXKCC.d.mts → routes-NEc6w3QC.d.mts} +540 -6
  44. package/dist/{schemas-BhZaystC.mjs → schemas-7VFdomFB.mjs} +34 -1
  45. package/dist/{serve-bPSEx_8X.mjs → serve-DS2T2iWI.mjs} +4 -4
  46. package/dist/{server-CcvxkXzG.mjs → server-Ch3tuK2k.mjs} +10 -10
  47. package/dist/{serving-BLVRrJ7P.mjs → serving-9riPNrHk.mjs} +1 -1
  48. package/dist/{sql-CyVcjw8x.mjs → sql-Bml29DpM.mjs} +174 -9
  49. package/dist/{sqlite-Con-8duk.mjs → sqlite-4C5u7-ag.mjs} +2 -2
  50. package/dist/{sqlite-db-BdzxtUOV.mjs → sqlite-db-eVb9v3zc.mjs} +1 -1
  51. package/dist/sync-chat-sdk.d.mts +2 -2
  52. package/dist/sync-chat-sdk.mjs +2 -2
  53. package/dist/sync-github.d.mts +2 -2
  54. package/dist/sync-github.mjs +2 -2
  55. package/dist/sync-linear.d.mts +3 -3
  56. package/dist/sync-linear.mjs +2 -2
  57. package/dist/sync-slack.d.mts +3 -3
  58. package/dist/sync-slack.mjs +4 -4
  59. package/dist/sync.d.mts +2 -2
  60. package/dist/sync.mjs +2 -2
  61. package/dist/{origin-BHmEdok7.mjs → task-batch-BJcLiYe1.mjs} +83 -8
  62. package/dist/{tokens-BErYXuHZ.mjs → tokens-DPKF_cb5.mjs} +2 -2
  63. package/docs/01-board/01-mounting.md +3 -3
  64. package/docs/01-board/07-schedules.md +2 -2
  65. package/docs/01-board/08-middleware.md +7 -0
  66. package/docs/01-board/11-tasks.md +348 -0
  67. package/docs/03-guides/02-inspector.md +66 -9
  68. package/docs/03-guides/06-sandboxed-agents.md +5 -3
  69. package/docs/03-guides/07-build-a-ui.md +210 -0
  70. package/docs/04-reference/01-cli.md +216 -8
  71. package/docs/04-reference/02-board.md +277 -2
  72. package/docs/04-reference/03-http.md +185 -11
  73. package/docs/04-reference/05-conformance.md +10 -7
  74. package/package.json +1 -1
  75. package/dist/exports-Gspe1eEq.d.mts +0 -4
  76. package/dist/inspect-CULoD54F.mjs +0 -2
@@ -1,14 +1,15 @@
1
- import { f as Board } from "./backend-D6yTo8Un.mjs";
1
+ import { f as Board } from "./backend-D3p8gjba.mjs";
2
2
  //#region src/conformance/index.d.ts
3
3
  /**
4
4
  * Checks that a board speaks the protocol, through a handle on it (`conformance(board())`), as
5
- * `vb` and agents use it: every board answers all of it. A board may keep no schedules or files,
6
- * and says so with a 501, which the kit reports as not kept here. It writes to one channel
7
- * (`conformance` by default), keeps every post on the board, and deletes what it posted. The one
5
+ * `vb` and agents use it: every board answers all of it. A board may keep no schedules, tasks, or
6
+ * files, and says so with a 501, which the kit reports as not kept here. It writes to one channel
7
+ * (`conformance` by default), and for the tasks checks that need two, to `tasks` under it, keeps
8
+ * every post on the board, and deletes what it posted. The one
8
9
  * schema it registers, `conformance@1`, stays: a schema version is never removed.
9
10
  */
10
11
  /** What a check is about, for the report's headings. */
11
- export type CheckGroup = 'core' | 'schedules' | 'grants' | 'schemas' | 'attachments' | 'watchers' | 'sync';
12
+ export type CheckGroup = 'core' | 'paging' | 'schedules' | 'tasks' | 'grants' | 'schemas' | 'attachments' | 'watchers' | 'sync';
12
13
  export type CheckResult = {
13
14
  group: CheckGroup;
14
15
  name: string;
@@ -1,2 +1,2 @@
1
- import { t as conformance } from "./conformance-BInS4_6b.mjs";
1
+ import { t as conformance } from "./conformance-Blzd4CXG.mjs";
2
2
  export { conformance };
@@ -1,10 +1,10 @@
1
- import { C as typeOf, _ as ATTACHMENT_BYTES_MAX, r as badRequest, s as notFound, t as HttpError, x as fileSize, y as IMPORT_BYTES_MAX } from "./errors-ZazTZh-s.mjs";
2
- import { C as toStorable, p as MESSAGE_TEXT_MAX, s as ChannelPath } from "./schemas-BhZaystC.mjs";
3
- import { l as isThreadTarget, s as channelOf } from "./external-DfhN7lKK.mjs";
1
+ import { C as fileSize, T as typeOf, c as notFound, r as badRequest, t as HttpError, x as IMPORT_BYTES_MAX, y as ATTACHMENT_BYTES_MAX } from "./errors-DZ1tbwSM.mjs";
2
+ import { N as toStorable, m as MESSAGE_TEXT_MAX, s as ChannelPath } from "./schemas-7VFdomFB.mjs";
3
+ import { l as isThreadTarget, s as channelOf } from "./external-BVr1Sq0y.mjs";
4
4
  import { t as canonicalEmoji } from "./emoji-CTLpvH-A.mjs";
5
- import { a as waitUntil, c as platformProfile, f as viaText, i as afterRetry, l as shownName, m as derivedId, o as actorParts, t as DroppedError } from "./middleware-BHHKHA9q.mjs";
5
+ import { a as waitUntil, c as platformProfile, f as viaText, i as afterRetry, l as shownName, m as derivedId, o as actorParts, t as DroppedError } from "./middleware-BKsTcMAv.mjs";
6
6
  import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-DfZGp3B-.mjs";
7
- import { a as immutable, d as opensBlock, f as routesFor, l as UnreadableError, n as SyncOverrides, o as ReceivedEvent, s as ResolvedTarget, u as channelMissing } from "./events-D17RndlV.mjs";
7
+ import { a as immutable, d as opensBlock, f as routesFor, l as UnreadableError, n as SyncOverrides, o as ReceivedEvent, s as ResolvedTarget, u as channelMissing } from "./events-mGuhF4i5.mjs";
8
8
  import { i as vercelDeployments, n as displayText } from "./bots-CLKKMgYf.mjs";
9
9
  //#region src/sync/engine.ts
10
10
  /** `files`: a message with files may have no text. */
@@ -920,7 +920,7 @@ function createSyncEngine(entries) {
920
920
  * A message's text for a platform, through entry `key`, its mentions resolved as it posts and only
921
921
  * against that entry's own users. An `@handle` reads natively when one of them has it, or of
922
922
  * several, the one who wrote in the thread: `@support/malte` names one of support's users, and
923
- * `@malte` is short for whichever of this sync's users that is, under its principal's name. An `@[actor-id]` reads natively when it's one of them,
923
+ * `@malte` is short for whichever of this sync's users that is, under its principal's name. An `@[actor-id]` reads natively when it's one of them (`@[slack:user:U0456]` also naming this sync's own profile of them),
924
924
  * and as the actor's name otherwise; an `@[email]`, as whoever the platform finds with it, or as
925
925
  * the email. The rest go as written.
926
926
  */
@@ -955,11 +955,19 @@ function createSyncEngine(entries) {
955
955
  return one(theirs) ?? (writers ? one(theirs.filter((user) => writers.has(user.id))) : null);
956
956
  }
957
957
  if (found.has(token.actor)) return found.get(token.actor) ?? token.actor;
958
- const actor = actors.byId[token.actor];
958
+ const actor = actorNamed(token.actor, actors);
959
959
  return actor ? nativeMention(key, actor.id, actors) ?? actor.name : null;
960
960
  });
961
961
  }
962
962
  /**
963
+ * The actor an `@[actor-id]` names: that actor, or, when the board has none by that ID, this
964
+ * sync's own profile of it (`@[slack:user:U0456]` for `<principal>+slack:user:U0456`), as plain
965
+ * `@malte` is short for this sync's `<principal>/malte`.
966
+ */
967
+ function actorNamed(id, actors) {
968
+ return actors.byId[id] ?? (actors.principal ? actors.byId[`${actors.principal}+${id}`] : void 0) ?? null;
969
+ }
970
+ /**
963
971
  * Whose ID an actor is on entry `key`'s platform, when it's one of that entry's users: this sync's
964
972
  * own profile of them (`<principal>+<key>:…`), or one named under the key alone, as the board's
965
973
  * own sync names its users and as Vercel's board named imports before profiles. Null for anyone
@@ -1,4 +1,4 @@
1
- import { p as MESSAGE_TEXT_MAX } from "./schemas-BhZaystC.mjs";
1
+ import { m as MESSAGE_TEXT_MAX } from "./schemas-7VFdomFB.mjs";
2
2
  import { r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
3
3
  import { ZodError } from "zod";
4
4
  //#region src/contract/files.ts
@@ -257,6 +257,10 @@ function eventsState(onState) {
257
257
  failed: () => tell("retrying")
258
258
  };
259
259
  }
260
+ /** How long one request for a ready task is held, in seconds, as one for the next event is. */
261
+ const CLAIM_WAIT_S = 25;
262
+ /** How soon a claim that waits asks again, when the board answered without holding the request. */
263
+ const CLAIM_AGAIN_MS = 1e3;
260
264
  const UNITS = {
261
265
  ms: 1,
262
266
  s: 1e3,
@@ -345,6 +349,111 @@ function createBoardClient(options) {
345
349
  async function poll(query = {}, signal) {
346
350
  return call("GET", `/events${queryString(query)}`, signal ? { signal } : {});
347
351
  }
352
+ /** One write to task `id`, which answers its root. */
353
+ const taskWrite = async (id, verb, body = {}) => (await call("POST", `/tasks/${path(id)}/${verb}`, { body })).task;
354
+ /** What a claim on task `id` does, with the `epoch` and `token` the claim answered. */
355
+ const held = (id, proof) => {
356
+ const { epoch, token } = proof;
357
+ return {
358
+ async renew(lease) {
359
+ const { task, until } = await call("POST", `/tasks/${path(id)}/renew`, { body: {
360
+ epoch,
361
+ token,
362
+ ...lease !== void 0 ? { lease } : {}
363
+ } });
364
+ return claimed(task, {
365
+ epoch,
366
+ token,
367
+ until
368
+ });
369
+ },
370
+ release: () => taskWrite(id, "release", {
371
+ epoch,
372
+ token
373
+ }),
374
+ complete: (result) => taskWrite(id, "complete", {
375
+ epoch,
376
+ token,
377
+ ...result !== void 0 ? { result } : {}
378
+ }),
379
+ fail: (reason) => taskWrite(id, "fail", {
380
+ epoch,
381
+ token,
382
+ reason
383
+ }),
384
+ block: (reason, opts = {}) => taskWrite(id, "block", {
385
+ epoch,
386
+ token,
387
+ reason,
388
+ ...opts
389
+ })
390
+ };
391
+ };
392
+ /** A claim as a handle answers it: the task, the claim, and what the claim does. */
393
+ const claimed = (task, claim) => ({
394
+ task,
395
+ ...claim,
396
+ ...held(task.id, claim)
397
+ });
398
+ async function createTask(target, input = {}) {
399
+ const where = typeof target === "string" ? { channel: target } : { re: target.re };
400
+ const made = typeof input === "string" ? { text: input } : "attachments" in input && input.attachments?.length ? {
401
+ ...input,
402
+ attachments: input.attachments.map((file) => typeof file === "string" ? file : file.id)
403
+ } : input;
404
+ const { task, claim } = await call("POST", "/tasks", { body: {
405
+ ...where,
406
+ ...made
407
+ } });
408
+ return {
409
+ task,
410
+ ...claim ? { claim: claimed(task, claim) } : {}
411
+ };
412
+ }
413
+ /**
414
+ * Starts a thread in `channel` for each of `tasks`, as tasks, in one write: all of them or none,
415
+ * and none shows before all have landed. It answers their roots in the order given. A task waits
416
+ * for the ones made with it by their `key`. With `id`, a retry answers the tasks the first call
417
+ * made. A board makes 100 at most, and throws a 400 `batch_too_large` for more, or for more than it
418
+ * holds in one write: `createTasksInChunks` makes a longer plan, in several.
419
+ */
420
+ async function createTasks(channel, tasks, opts = {}) {
421
+ return (await call("POST", "/tasks/batch", { body: {
422
+ channel,
423
+ tasks: tasks.map((task) => task.attachments?.length ? {
424
+ ...task,
425
+ attachments: task.attachments.map((file) => typeof file === "string" ? file : file.id)
426
+ } : task),
427
+ ...opts.id !== void 0 ? { id: opts.id } : {}
428
+ } })).tasks;
429
+ }
430
+ async function claimTask(target, opts = {}) {
431
+ const signal = opts.signal ? { signal: opts.signal } : {};
432
+ if (typeof target === "string") {
433
+ const { task, claim } = await call("POST", `/tasks/${path(target)}/claim`, {
434
+ body: opts.lease !== void 0 ? { lease: opts.lease } : {},
435
+ ...signal
436
+ });
437
+ return claimed(task, claim);
438
+ }
439
+ const { wait, ...ready } = target;
440
+ const deadline = Date.now() + (wait ?? 0) * 1e3;
441
+ for (;;) {
442
+ const asked = Date.now();
443
+ const hold = Math.max(0, Math.min(CLAIM_WAIT_S, (deadline - asked) / 1e3));
444
+ const answer = await call("POST", "/tasks/claim", {
445
+ body: {
446
+ ...ready,
447
+ ...hold > 0 ? { wait: hold } : {}
448
+ },
449
+ ...signal
450
+ });
451
+ if (answer.task) return claimed(answer.task, answer.claim);
452
+ if (Date.now() >= deadline || opts.signal?.aborted) return null;
453
+ const pause = Math.min(CLAIM_AGAIN_MS - (Date.now() - asked), deadline - Date.now());
454
+ if (pause > 0) await new Promise((resolve) => setTimeout(resolve, pause));
455
+ }
456
+ }
348
457
  return {
349
458
  url: base,
350
459
  /**
@@ -429,7 +538,7 @@ function createBoardClient(options) {
429
538
  thread: (id) => call("GET", `/messages/${path(id)}`),
430
539
  /** Your own post with the client ID you gave it, as posting it answered: 404 `post_not_found` when there's none. */
431
540
  posted: async (id) => (await call("GET", `/posts/${path(id)}`)).message,
432
- /** Threads with a matching message, one summary each (root, reply count, latest reply), by latest activity. `limit` counts threads. */
541
+ /** Threads with a matching message, one summary each (root, reply count, latest reply), by latest activity. `limit` counts threads; `before` takes a page's `older`. */
433
542
  threads: (query = {}) => call("GET", `/threads${queryString(query)}`),
434
543
  async post(channel, input) {
435
544
  return (await call("POST", "/messages", { body: {
@@ -459,6 +568,43 @@ function createBoardClient(options) {
459
568
  /** Stops a schedule: yours, or any with manage in its channel. `canceled` is false when it was already done or canceled. */
460
569
  cancelSchedule: (id) => call("POST", `/schedules/${path(id)}/cancel`, { body: {} }),
461
570
  /**
571
+ * Tasks: threads someone's agents are to do, with a state the board keeps. A task's ID is its
572
+ * root's, and its root's `task` says its state, whose it is, what it waits for, and who holds
573
+ * it. A board that keeps no tasks fails each of these with 501 `no_tasks`.
574
+ */
575
+ tasks: {
576
+ /**
577
+ * Tasks, oldest first, each as its thread's summary: open ones (`waiting`, `ready`, `claimed`,
578
+ * `blocked`) unless `state` says `all` or names one. `owner` and `for` take a handle or an ID,
579
+ * `needs` a task's ID, for the tasks that wait for it. `cursor`, as `after`, reads the next page.
580
+ */
581
+ list: (query = {}) => call("GET", `/tasks${queryString(query)}`),
582
+ create: createTask,
583
+ createMany: createTasks,
584
+ claim: claimTask,
585
+ /** What a claim you hold does, from the `epoch` and `token` it answered: for a process that kept them, as `vb` does between commands. */
586
+ held,
587
+ /** Holds a task no one has claimed for a person: yours, or any with manage in its channel. A claimed one's hold is its claim's (`claim.block`). */
588
+ block: (id, reason, opts = {}) => taskWrite(id, "block", {
589
+ reason,
590
+ ...opts
591
+ }),
592
+ /** Lifts a hold: the task is ready again, or waiting while a task it needs hasn't completed. */
593
+ unblock: (id) => taskWrite(id, "unblock"),
594
+ /** Makes a failed task ready again, in place: what waits for it still does. */
595
+ reopen: (id) => taskWrite(id, "reopen"),
596
+ /** Assigns a task to one of its owner's actors (`<owner>+<profile>`), the only one that claims it then, or with null to anyone who may. */
597
+ assign: (id, actor) => taskWrite(id, "assign", { for: actor }),
598
+ /**
599
+ * Replaces what a task waits for, by their IDs: it waits for those now, and is ready once they've all completed, or
600
+ * at once with none. For its owner, while no one holds it and it isn't finished. One that would make it wait for
601
+ * itself, through however many tasks, throws a 400 `invalid_needs`.
602
+ */
603
+ needs: (id, needs) => taskWrite(id, "needs", { needs }),
604
+ /** Cancels a task that hasn't completed, ending any claim. What waits for it keeps waiting. */
605
+ cancel: (id, reason) => taskWrite(id, "cancel", { reason })
606
+ },
607
+ /**
462
608
  * A new grant: `principals` may do what `can` says, a map from channel pattern to permissions
463
609
  * (`[]` for none). The same principals again are another grant. At each channel, the most
464
610
  * specific pattern among the grants that name a caller decides, then the closest principal,
@@ -717,6 +863,8 @@ const forbidden = (message) => new HttpError(403, "forbidden", message);
717
863
  const notFound = (message, code = "not_found") => new HttpError(404, code, message);
718
864
  const textTooLong = () => new HttpError(400, "text_too_long", `A message's text is at most ${MESSAGE_TEXT_MAX.toLocaleString("en-US")} characters.`, { hint: "Put the long part in a file and attach it to a message, with a short summary as the text." });
719
865
  const duplicateId = () => new HttpError(409, "duplicate_id", "that id was already used for a different write");
866
+ /** More tasks than a board makes in one batch: `most` is how many it does. Nothing was made, and its sender splits it. */
867
+ const batchTooLarge = (tasks, most) => new HttpError(400, "batch_too_large", `a batch makes ${most} tasks at most, and this one has ${tasks}: send it in parts`);
720
868
  const json = (body, status = 200, headers) => new Response(JSON.stringify(body), {
721
869
  status,
722
870
  headers: {
@@ -774,4 +922,4 @@ function toErrorResponse(error) {
774
922
  } }, 500);
775
923
  }
776
924
  //#endregion
777
- export { typeOf as C, mediaType as S, ATTACHMENT_BYTES_MAX as _, forbidden as a, fileName as b, textTooLong as c, BoardError as d, createBoardClient as f, parseProfileHeader as g, formatProfileHeader as h, duplicateId as i, toErrorResponse as l, eventsState as m, RejectedError as n, json as o, duration as p, badRequest as r, notFound as s, HttpError as t, unauthorized as u, DIRECT_UPLOAD_BYTES_MAX as v, fileSize as x, IMPORT_BYTES_MAX as y };
925
+ export { fileSize as C, fileName as S, typeOf as T, formatProfileHeader as _, duplicateId as a, DIRECT_UPLOAD_BYTES_MAX as b, notFound as c, unauthorized as d, BoardError as f, InvalidProfileHeader as g, eventsState as h, batchTooLarge as i, textTooLong as l, duration as m, RejectedError as n, forbidden as o, createBoardClient as p, badRequest as r, json as s, HttpError as t, toErrorResponse as u, parseProfileHeader as v, mediaType as w, IMPORT_BYTES_MAX as x, ATTACHMENT_BYTES_MAX as y };
@@ -1,5 +1,5 @@
1
- import { f as Labels, u as LabelKey } from "./schemas-BhZaystC.mjs";
2
- import { n as ExternalEvent, r as ExternalLocation } from "./external-DfhN7lKK.mjs";
1
+ import { d as LabelKey, p as Labels } from "./schemas-7VFdomFB.mjs";
2
+ import { n as ExternalEvent, r as ExternalLocation } from "./external-BVr1Sq0y.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/sync/fn.ts
5
5
  const ROUTES = Symbol.for("board.syncRoutes");