@vercel/board 0.50.0 → 0.51.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 (88) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +128 -118
  3. package/dist/{access-BbgmsAFF.mjs → access-DdojoPZm.mjs} +1 -1
  4. package/dist/access.d.mts +2 -2
  5. package/dist/access.mjs +4 -4
  6. package/dist/{actors-CX2D22hL.mjs → actors-CDkNgWUL.mjs} +3 -3
  7. package/dist/{auth-Z9-Khvvw.d.mts → auth-C4VxPLYz.d.mts} +1 -1
  8. package/dist/{auth-DJDTfgAL.mjs → auth-zPqFJocD.mjs} +10 -3
  9. package/dist/{backend-CcaaS9Xl.d.mts → backend-Da_YEltI.d.mts} +16 -13
  10. package/dist/backend-local.d.mts +1 -1
  11. package/dist/backend-local.mjs +1 -1
  12. package/dist/{chat-provider-DQ1GHm4o.d.mts → chat-provider-BHyX6H8H.d.mts} +2 -2
  13. package/dist/{chat-provider-HJ7y_ipp.mjs → chat-provider-Br2RXgLV.mjs} +4 -3
  14. package/dist/cli-commands.d.mts +1 -1
  15. package/dist/cli-commands.mjs +1 -1
  16. package/dist/cli-embedded.d.mts +15 -7
  17. package/dist/cli-embedded.mjs +9 -6
  18. package/dist/cli.mjs +6 -6
  19. package/dist/{client-C2T4eaXd.d.mts → client-C4-r10SA.d.mts} +25 -4
  20. package/dist/{commands-Cm4sODIu.d.mts → commands-B6pgzwTI.d.mts} +10 -0
  21. package/dist/{commands-nN8WpvCe.mjs → commands-DB1T8vT9.mjs} +37 -10
  22. package/dist/{conformance-Cr-umDl0.mjs → conformance-DW4-9Dwf.mjs} +176 -64
  23. package/dist/conformance.d.mts +4 -3
  24. package/dist/conformance.mjs +1 -1
  25. package/dist/{engine-DJZ8Xy_g.mjs → engine-D8YAsQS_.mjs} +17 -9
  26. package/dist/{errors-DYF4hhIc.mjs → errors-DbCKqGXp.mjs} +35 -7
  27. package/dist/{events-BdOCmnZh.mjs → events-mWKc1uvZ.mjs} +1 -1
  28. package/dist/{exports-CuD-Mxkw.mjs → exports-BDE3eV7B.mjs} +593 -261
  29. package/dist/{exports-lmr6UHHc.d.mts → exports-BUtR_AHa.d.mts} +4 -4
  30. package/dist/{external-D2jq_DEQ.mjs → external-DkWafjn-.mjs} +5 -1
  31. package/dist/{index-_KxJu15n.d.mts → index-BTuTaBaK.d.mts} +2 -2
  32. package/dist/index.d.mts +6 -6
  33. package/dist/index.mjs +4 -4
  34. package/dist/index.node.d.mts +7 -7
  35. package/dist/index.node.mjs +4 -4
  36. package/dist/inspect/app.js +41 -41
  37. package/dist/inspect/engine.js +4 -4
  38. package/dist/inspect-BXvdLMET.mjs +2 -0
  39. package/dist/{inspect-CZeoSm7E.mjs → inspect-Nd_TlU1s.mjs} +3 -3
  40. package/dist/inspect.d.mts +1 -1
  41. package/dist/inspect.mjs +2 -2
  42. package/dist/{local-BVSFSSYf.mjs → local-BsYjQrl_.mjs} +113 -35
  43. package/dist/{main-B016auoG.mjs → main-CSIXhZ_b.mjs} +117 -36
  44. package/dist/{memory-C2lzMV_t.mjs → memory-wmUDblhm.mjs} +2 -2
  45. package/dist/{middleware-DUKIITFZ.mjs → middleware-iVTNf5Su.mjs} +1 -1
  46. package/dist/{profile-header-Cj0Cb1cf.mjs → profile-header-O8wC8yk8.mjs} +12 -1
  47. package/dist/{provider-Dwb_9mnu.d.mts → provider-CGicSMdu.d.mts} +4 -2
  48. package/dist/{routes-BE0y6wCk.mjs → routes-C85Sbhtm.mjs} +44 -11
  49. package/dist/{routes-B6SEA9yw.d.mts → routes-ChGBn0K3.d.mts} +60 -23
  50. package/dist/{serve-B10e7QaY.mjs → serve-Cp0qM4jk.mjs} +9 -8
  51. package/dist/{server-ViWNvg5q.mjs → server-HPq6MO3_.mjs} +50 -33
  52. package/dist/{serving-SbqeWqlA.mjs → serving-aOQsBok0.mjs} +1 -1
  53. package/dist/{shell-DmpmgOPC.mjs → shell-CUR5woOP.mjs} +1 -1
  54. package/dist/{sql-iABdyCiz.mjs → sql-D0MqINA6.mjs} +1 -1
  55. package/dist/{sqlite-28EMrmk7.mjs → sqlite-Dj2ZEtgy.mjs} +2 -2
  56. package/dist/{sqlite-db-Ckd-ceNe.mjs → sqlite-db-DjbTlUwN.mjs} +1 -1
  57. package/dist/sync-chat-sdk.d.mts +2 -2
  58. package/dist/sync-chat-sdk.mjs +2 -2
  59. package/dist/sync-github.d.mts +2 -2
  60. package/dist/sync-github.mjs +3 -3
  61. package/dist/sync-linear.d.mts +3 -3
  62. package/dist/sync-linear.mjs +3 -3
  63. package/dist/sync-slack.d.mts +21 -4
  64. package/dist/sync-slack.mjs +35 -11
  65. package/dist/sync.d.mts +2 -2
  66. package/dist/sync.mjs +2 -2
  67. package/dist/{tags-D0qra0Qy.mjs → tags-CxDCF_tt.mjs} +1 -1
  68. package/dist/{task-batch-9lVDG3d-.mjs → task-batch-D3ASL5_-.mjs} +53 -9
  69. package/dist/{tokens-C-iK0Cku.mjs → tokens-C-T0B1uF.mjs} +31 -7
  70. package/dist/{version-C70RLVEK.mjs → version-BJH1vWR0.mjs} +1 -1
  71. package/docs/01-board/01-mounting.md +20 -7
  72. package/docs/01-board/03-identity.md +1 -1
  73. package/docs/01-board/04-messages.md +5 -0
  74. package/docs/01-board/05-reading.md +71 -16
  75. package/docs/01-board/07-schedules.md +1 -1
  76. package/docs/01-board/10-local.md +1 -1
  77. package/docs/02-sync/01-overview.md +3 -3
  78. package/docs/02-sync/03-slack.md +4 -3
  79. package/docs/03-guides/01-coding-agents.md +1 -1
  80. package/docs/03-guides/02-inspector.md +13 -5
  81. package/docs/03-guides/07-build-a-ui.md +15 -11
  82. package/docs/04-reference/01-cli.md +64 -25
  83. package/docs/04-reference/02-board.md +48 -23
  84. package/docs/04-reference/03-http.md +33 -14
  85. package/docs/04-reference/05-conformance.md +11 -10
  86. package/docs/index.md +1 -1
  87. package/package.json +14 -2
  88. package/dist/inspect-UCcPViyA.mjs +0 -2
@@ -1,7 +1,24 @@
1
- import "./routes-BE0y6wCk.mjs";
2
- import { f as BoardError } from "./errors-DYF4hhIc.mjs";
1
+ import "./routes-C85Sbhtm.mjs";
2
+ import { f as BoardError } from "./errors-DbCKqGXp.mjs";
3
3
  import { c as canonical, t as block } from "./blocks-CVoBC7ur.mjs";
4
- import { a as canText, c as compileAccess } from "./access-BbgmsAFF.mjs";
4
+ import { a as canText, c as compileAccess } from "./access-DdojoPZm.mjs";
5
+ //#region src/client/channels.ts
6
+ /** Every channel of a board, or every one whose path starts with `prefix`, a page at a time: for what needs them all. */
7
+ async function everyChannel(board, prefix) {
8
+ const channels = [];
9
+ let after;
10
+ do {
11
+ const page = await board.channels({
12
+ limit: 500,
13
+ ...prefix !== void 0 ? { prefix } : {},
14
+ ...after !== void 0 ? { after } : {}
15
+ });
16
+ channels.push(...page.channels);
17
+ after = page.next ?? void 0;
18
+ } while (after !== void 0);
19
+ return channels;
20
+ }
21
+ //#endregion
5
22
  //#region src/conformance/index.ts
6
23
  var Mismatch = class extends Error {};
7
24
  const show = (value) => JSON.stringify(value) ?? String(value);
@@ -82,9 +99,12 @@ function isRef(value, what) {
82
99
  * The groups a board may keep none of, saying so with a 501: a board without a scheduler answers
83
100
  * `no_scheduler`, and without a blob store `no_files`; one that keeps no tasks answers `no_tasks`,
84
101
  * a backend of one's own that keeps no grants `no_grants`, and one that keeps no schemas
85
- * `no_schemas`. A board that's meant to keep something and doesn't yet answers otherwise, and fails.
102
+ * `no_schemas`. `search` is finding threads by what their messages say, and reading every channel
103
+ * under a pattern at once: a board with no index for either, as Vercel's has none, answers
104
+ * `not_supported`. A board that's meant to keep something and doesn't yet answers otherwise, and fails.
86
105
  */
87
106
  const OPTIONAL = /* @__PURE__ */ new Set([
107
+ "search",
88
108
  "schedules",
89
109
  "tasks",
90
110
  "grants",
@@ -550,36 +570,86 @@ const CHECKS = [
550
570
  },
551
571
  {
552
572
  group: "core",
553
- name: "matches a label on the message or its thread's root",
573
+ name: "reads one channel's messages after a cursor of its own, oldest first, and on from where it stopped",
554
574
  run: async (ctx) => {
555
- const { reply } = needRoot(ctx);
556
- const { messages } = await ctx.board.messages({
557
- channel: ctx.channel,
558
- label: ctx.labels
575
+ const { root, reply } = needRoot(ctx);
576
+ const channel = ctx.board.channel(ctx.channel);
577
+ const page = await channel.messages({
578
+ after: ctx.start,
579
+ limit: 500
559
580
  });
560
- check(messages.some((m) => m.id === reply.id), "a reply should match its root's label");
581
+ isRef(page.cursor, "a read's cursor");
582
+ const ids = page.messages.map((m) => m.id);
583
+ check(ids.indexOf(root.id) !== -1 && ids.indexOf(root.id) < ids.indexOf(reply.id), `the root should come before its reply, got ${show(ids)}`);
584
+ check(page.messages.every((m) => m.channel === ctx.channel), `a channel's messages should all be in it, got ${show([...new Set(page.messages.map((m) => m.channel))])}`);
585
+ const one = await channel.messages({
586
+ after: ctx.start,
587
+ limit: 1
588
+ });
589
+ same(one.messages.length, 1, "how many messages a read with a limit of 1 lists");
590
+ const rest = await channel.messages({
591
+ after: one.cursor,
592
+ limit: 500
593
+ });
594
+ const twice = rest.messages.filter((m) => one.messages.some((first) => first.id === m.id));
595
+ check(twice.length === 0, `reading on from a page's cursor should repeat none of it, got ${show(twice.map((m) => m.id))} again`);
596
+ const all = [...one.messages, ...rest.messages].map((m) => m.id);
597
+ check(all.includes(root.id) && all.includes(reply.id), `reading on from a page's cursor should reach what came after it, got ${show(all)}`);
598
+ }
599
+ },
600
+ {
601
+ group: "core",
602
+ name: "lists channels a page at a time, and the ones under a prefix",
603
+ run: async (ctx) => {
604
+ const paths = (channels) => channels.map((channel) => channel.path);
605
+ const under = paths(await everyChannel(ctx.board, ctx.channel));
606
+ check(under.includes(ctx.channel) && under.every((path) => path.startsWith(ctx.channel)), `the channels under ${ctx.channel} should be it and the ones that start with it, got ${show(under)}`);
607
+ const seen = [];
608
+ let after;
609
+ do {
610
+ const page = await ctx.board.channels({
611
+ prefix: ctx.channel,
612
+ limit: 1,
613
+ ...after !== void 0 ? { after } : {}
614
+ });
615
+ check(page.channels.length <= 1, `a list with a limit of 1 should answer 1 channel at most, got ${show(paths(page.channels))}`);
616
+ seen.push(...paths(page.channels));
617
+ after = page.next ?? void 0;
618
+ } while (after !== void 0 && seen.length <= under.length);
619
+ same(show([...seen].sort()), show([...under].sort()), "the channels under a prefix, read a page of 1 at a time");
561
620
  }
562
621
  },
563
622
  {
564
623
  group: "core",
565
- name: "reads a channel after a cursor or a message ID, oldest first",
624
+ name: "reads a thread's replies after one of its messages, and as many of its newest as it's asked for",
566
625
  run: async (ctx) => {
567
626
  const { root, reply } = needRoot(ctx);
568
- const page = await ctx.board.messages({
569
- channel: ctx.channel,
570
- label: ctx.labels,
571
- after: ctx.start
572
- });
573
- isRef(page.cursor, "a read's cursor");
574
- const ids = page.messages.map((m) => m.id);
575
- check(ids.indexOf(root.id) !== -1 && ids.indexOf(root.id) < ids.indexOf(reply.id), `the root should come before its reply, got ${show(ids)}`);
576
- const later = await ctx.board.messages({
577
- channel: ctx.channel,
578
- label: ctx.labels,
579
- after: root.id
627
+ const ids = (read) => [read.message.id, ...read.replies.map((m) => m.id)];
628
+ const whole = ids(await ctx.board.thread(root.id));
629
+ const after = ids(await ctx.board.thread(root.id, { after: reply.id }));
630
+ same(show(after), show([root.id, ...whole.slice(whole.indexOf(reply.id) + 1)]), "a thread read after one of its replies: its root, and the replies after that one");
631
+ const first = ids(await ctx.board.thread(reply.id, {
632
+ after: root.id,
633
+ limit: 1
634
+ }));
635
+ same(show(first), show(whole.slice(0, 2)), "a thread read for the first reply after its root");
636
+ const newest = ids(await ctx.board.thread(root.id, { limit: 1 }));
637
+ same(show(newest), show([root.id, whole.at(-1)]), "a thread read for its newest reply");
638
+ }
639
+ },
640
+ {
641
+ group: "core",
642
+ name: "reads one channel's newest messages, as many as it's asked for",
643
+ run: async (ctx) => {
644
+ needRoot(ctx);
645
+ const latest = await post(ctx, "conformance: the newest message of the channel, for now");
646
+ const page = await ctx.board.channel(ctx.channel).messages({ limit: 2 });
647
+ check(page.messages.length <= 2, `a read with a limit of 2 should list 2 at most, got ${page.messages.length}`);
648
+ const after = await ctx.board.channel(ctx.channel).messages({
649
+ after: page.cursor,
650
+ limit: 500
580
651
  });
581
- check(!later.messages.some((m) => m.id === root.id), "reading after a message should leave it out");
582
- check(later.messages.some((m) => m.id === reply.id), "reading after a message should include what came after it");
652
+ check([...page.messages, ...after.messages].some((m) => m.id === latest.id), `the newest messages, and what came after them, should include ${latest.id}`);
583
653
  }
584
654
  },
585
655
  {
@@ -665,31 +735,36 @@ const CHECKS = [
665
735
  }
666
736
  },
667
737
  {
668
- group: "core",
669
- name: "matches text anywhere in a message's own, in any case, as it reads now",
738
+ group: "search",
739
+ name: "finds threads by text anywhere in a message of theirs, in any case, as it reads now",
670
740
  run: async (ctx) => {
671
741
  const literal = await post(ctx, "conformance: Deploy FAILED at 100% on a_b");
672
742
  const lookalike = await post(ctx, "conformance: deploy failed at 1000 on axb");
673
- const under = await reply(ctx, lookalike.id, "conformance: a reply that says Crème Brûlée");
674
- const found = async (text) => (await ctx.board.messages({
743
+ await reply(ctx, lookalike.id, "conformance: a reply that says Crème Brûlée");
744
+ const found = async (text) => (await ctx.board.threads({
675
745
  channel: ctx.channel,
676
746
  label: ctx.labels,
677
- after: ctx.start,
678
747
  text
679
- })).messages.map((m) => m.id);
680
- alike(await found("DEPLOY failed"), [literal.id, lookalike.id], "the messages \"DEPLOY failed\" finds");
681
- alike(await found("100%"), [literal.id], "the messages \"100%\" finds, % being a character");
682
- alike(await found("a_b"), [literal.id], "the messages \"a_b\" finds, _ being a character");
683
- alike(await found("BRÛLÉE"), [under.id], "the messages \"BRÛLÉE\" finds");
748
+ })).threads.map((t) => t.message.id);
749
+ alike(await found("DEPLOY failed"), [literal.id, lookalike.id], "the threads \"DEPLOY failed\" finds");
750
+ alike(await found("100%"), [literal.id], "the threads \"100%\" finds, % being a character");
751
+ alike(await found("a_b"), [literal.id], "the threads \"a_b\" finds, _ being a character");
752
+ alike(await found("crème BRÛLÉE"), [lookalike.id], "the threads \"crème BRÛLÉE\" finds");
753
+ await ctx.board.edit(lookalike.id, "conformance: deploy fixed");
754
+ alike(await found("1000"), [], "the threads \"1000\" finds, once the message that said it is edited");
755
+ alike(await found("deploy fixed"), [lookalike.id], "the threads \"deploy fixed\" finds, once a message is edited to say it");
756
+ }
757
+ },
758
+ {
759
+ group: "search",
760
+ name: "lists the threads of every channel under a pattern at once",
761
+ run: async (ctx) => {
762
+ const { root } = needRoot(ctx);
684
763
  const { threads } = await ctx.board.threads({
685
- channel: ctx.channel,
686
- label: ctx.labels,
687
- text: "crème brûlée"
764
+ channel: `${ctx.channel}/`,
765
+ label: ctx.labels
688
766
  });
689
- alike(threads.map((t) => t.message.id), [lookalike.id], "the threads \"crème brûlée\" finds");
690
- await ctx.board.edit(lookalike.id, "conformance: deploy fixed");
691
- alike(await found("1000"), [], "the messages \"1000\" finds, once the one that said it is edited");
692
- alike(await found("deploy fixed"), [lookalike.id], "the messages \"deploy fixed\" finds, once one is edited to say it");
767
+ check(threads.some((t) => t.message.id === root.id), `the threads under ${ctx.channel}/ should include ${root.id}, in ${ctx.channel} itself`);
693
768
  }
694
769
  },
695
770
  {
@@ -711,6 +786,34 @@ const CHECKS = [
711
786
  })).events.some((event) => event.message?.id === root.id), "reading on from the cursor should not repeat what it read");
712
787
  }
713
788
  },
789
+ {
790
+ group: "core",
791
+ name: "reads a channel's newest events, oldest first, and goes on from their cursor",
792
+ run: async (ctx) => {
793
+ const { root, reply } = needRoot(ctx);
794
+ const page = await ctx.board.poll({
795
+ channel: ctx.channel,
796
+ last: 100
797
+ }).catch((error) => {
798
+ if (error instanceof BoardError && error.status === 501 && error.code === "not_supported") return `not kept here: ${error.message}`;
799
+ throw error;
800
+ });
801
+ if (typeof page === "string") return page;
802
+ isRef(page.cursor, "the newest events' cursor");
803
+ const posted = page.events.filter((event) => event.type === "message.posted").map((event) => event.message?.id);
804
+ check(posted.includes(root.id) && posted.includes(reply.id), `the channel's newest events should include ${root.id} and ${reply.id} being posted`);
805
+ check(posted.indexOf(root.id) < posted.indexOf(reply.id), `${root.id} was posted before ${reply.id}, so it should come first`);
806
+ const one = await ctx.board.poll({
807
+ channel: ctx.channel,
808
+ last: 1
809
+ });
810
+ check(one.events.length <= 1, `\`last=1\` on one channel should answer one event at most, not ${one.events.length}`);
811
+ check(!(await ctx.board.poll({
812
+ channel: ctx.channel,
813
+ after: page.cursor
814
+ })).events.some((event) => page.events.some((read) => read.cursor === event.cursor)), "reading on from the cursor should not repeat what it read");
815
+ }
816
+ },
714
817
  {
715
818
  group: "core",
716
819
  name: "holds a long-poll open until the next event",
@@ -757,32 +860,25 @@ const CHECKS = [
757
860
  noSync: true
758
861
  });
759
862
  ctx.posted.push(root.id);
760
- const kept = await reply(ctx, root.id, "conformance: a reply under it");
761
- const found = async () => ({
762
- threads: (await ctx.board.threads({
763
- channel: ctx.channel,
764
- label
765
- })).threads.map((t) => t.message.id),
766
- messages: (await ctx.board.messages({
767
- channel: ctx.channel,
768
- label
769
- })).messages.map((m) => m.id)
770
- });
863
+ await reply(ctx, root.id, "conformance: a reply under it");
864
+ const found = async () => (await ctx.board.threads({
865
+ channel: ctx.channel,
866
+ label
867
+ })).threads.map((t) => t.message.id);
771
868
  const before = await found();
772
- check(before.threads.includes(root.id) && before.messages.includes(kept.id), `its labels should find the root and its reply before the delete, got ${show(before)}`);
869
+ check(before.includes(root.id), `its labels should find the root's thread before the delete, got ${show(before)}`);
773
870
  await ctx.board.delete(root.id);
774
871
  const { labels } = (await ctx.board.thread(root.id)).message;
775
872
  check(Object.keys(labels).length === 0, `a deleted message should keep no labels, got ${show(labels)}`);
776
873
  const after = await found();
777
- check(!after.threads.includes(root.id), `a label read should leave out a deleted root's thread, got ${show(after.threads)}`);
778
- check(!after.messages.includes(root.id) && !after.messages.includes(kept.id), `a deleted root's labels should find neither it nor its replies, got ${show(after.messages)}`);
874
+ check(!after.includes(root.id), `a label read should leave out a deleted root's thread, got ${show(after)}`);
779
875
  }
780
876
  },
781
877
  {
782
878
  group: "core",
783
879
  name: "lists the channel and you in it",
784
880
  run: async (ctx) => {
785
- const found = (await ctx.board.channels()).find((c) => c.path === ctx.channel);
881
+ const found = (await everyChannel(ctx.board)).find((c) => c.path === ctx.channel);
786
882
  check(found, `the channels should include ${ctx.channel}`);
787
883
  for (const field of [
788
884
  "lastIndex",
@@ -990,14 +1086,14 @@ const CHECKS = [
990
1086
  const thread = await ctx.board.thread(root.id);
991
1087
  same(thread.message.task?.state, "ready", "the task, read as its thread");
992
1088
  check(thread.replies.some((m) => m.id === answer.id), "a reply should land in the task's thread");
993
- const { messages } = await ctx.board.messages({
1089
+ const { threads } = await ctx.board.threads({
994
1090
  channel: ctx.channel,
995
1091
  label: {
996
1092
  ...ctx.labels,
997
1093
  "board.task": "ready"
998
1094
  }
999
1095
  });
1000
- check(messages.some((m) => m.id === root.id), "board.task=ready should find the task");
1096
+ check(threads.some((t) => t.message.id === root.id), "board.task=ready should find the task");
1001
1097
  const listed = (await ctx.board.tasks.list({
1002
1098
  channel: ctx.channel,
1003
1099
  label: ctx.labels
@@ -2363,6 +2459,25 @@ const CHECKS = [
2363
2459
  same(new TextDecoder().decode(await response.arrayBuffer()), new TextDecoder().decode(bytes), "the file's bytes");
2364
2460
  }
2365
2461
  },
2462
+ {
2463
+ group: "attachments",
2464
+ name: "refuses a name that would download as a dotfile",
2465
+ run: async (ctx) => {
2466
+ const bytes = new TextEncoder().encode(`conformance ${ctx.labels.conformance}\n`);
2467
+ try {
2468
+ await ctx.board.upload({
2469
+ data: bytes,
2470
+ name: ".conformance",
2471
+ type: "text/plain"
2472
+ });
2473
+ } catch (error) {
2474
+ if (error instanceof BoardError && error.status === 501) throw error;
2475
+ if (error instanceof BoardError && error.status === 400 && error.code === "invalid_attachment") return;
2476
+ throw new Mismatch(`a dotfile name: expected 400 invalid_attachment, got ${error instanceof BoardError ? `${error.status} ${error.code}` : String(error)}`);
2477
+ }
2478
+ throw new Mismatch("a dotfile name: expected 400 invalid_attachment, and it succeeded");
2479
+ }
2480
+ },
2366
2481
  {
2367
2482
  group: "attachments",
2368
2483
  name: "starts a task with a file, which its root carries",
@@ -2972,10 +3087,7 @@ async function conformance(board, options = {}) {
2972
3087
  board,
2973
3088
  channel,
2974
3089
  labels: { conformance: label },
2975
- start: (await board.messages({
2976
- channel,
2977
- limit: 1
2978
- })).cursor,
3090
+ start: (await board.channel(channel).messages({ limit: 1 })).cursor,
2979
3091
  me,
2980
3092
  posted: [],
2981
3093
  ...options.withCan ? { withCan: options.withCan } : options.withHeaders ? { withCan: (can) => options.withHeaders({ "x-board-can": can }) } : {},
@@ -3037,4 +3149,4 @@ async function conformance(board, options = {}) {
3037
3149
  };
3038
3150
  }
3039
3151
  //#endregion
3040
- export { conformance as t };
3152
+ export { everyChannel as n, conformance as t };
@@ -1,15 +1,16 @@
1
- import { f as Board } from "./backend-CcaaS9Xl.mjs";
1
+ import { f as Board } from "./backend-Da_YEltI.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
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
6
+ * files, or no index to find threads by what their messages say or who wrote them, and says so with a
7
+ * 501, which the kit reports as not kept here. It writes to one channel
7
8
  * (`conformance` by default), and for the tasks checks that need two, to `tasks` under it, keeps
8
9
  * every post on the board, and deletes what it posted. The one
9
10
  * schema it registers, `conformance@1`, stays: a schema version is never removed.
10
11
  */
11
12
  /** What a check is about, for the report's headings. */
12
- export type CheckGroup = 'core' | 'paging' | 'schedules' | 'tasks' | 'grants' | 'schemas' | 'attachments' | 'watchers' | 'sync';
13
+ export type CheckGroup = 'core' | 'paging' | 'search' | 'schedules' | 'tasks' | 'grants' | 'schemas' | 'attachments' | 'watchers' | 'sync';
13
14
  export type CheckResult = {
14
15
  group: CheckGroup;
15
16
  name: string;
@@ -1,2 +1,2 @@
1
- import { t as conformance } from "./conformance-Cr-umDl0.mjs";
1
+ import { t as conformance } from "./conformance-DW4-9Dwf.mjs";
2
2
  export { conformance };
@@ -1,11 +1,11 @@
1
- import { c as fileSize, i as ATTACHMENT_BYTES_MAX, o as IMPORT_BYTES_MAX, u as typeOf } from "./profile-header-Cj0Cb1cf.mjs";
1
+ import { f as typeOf, i as ATTACHMENT_BYTES_MAX, l as fileSize, o as IMPORT_BYTES_MAX, u as importedFileName } from "./profile-header-O8wC8yk8.mjs";
2
2
  import { P as toStorable, m as MESSAGE_TEXT_MAX, s as ChannelPath } from "./schemas-CUSTEFIy.mjs";
3
- import { l as isThreadTarget, s as channelOf } from "./external-D2jq_DEQ.mjs";
3
+ import { l as isThreadTarget, s as channelOf } from "./external-DkWafjn-.mjs";
4
4
  import { t as canonicalEmoji } from "./emoji-CTLpvH-A.mjs";
5
- import { c as notFound, r as badRequest, t as HttpError } from "./errors-DYF4hhIc.mjs";
6
- 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-DUKIITFZ.mjs";
5
+ import { c as notFound, r as badRequest, t as HttpError } from "./errors-DbCKqGXp.mjs";
6
+ 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-iVTNf5Su.mjs";
7
7
  import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
8
- 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-BdOCmnZh.mjs";
8
+ 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-mWKc1uvZ.mjs";
9
9
  import { i as vercelDeployments, n as displayText, t as byVercelBot } from "./bots-CqPYxkqK.mjs";
10
10
  //#region src/sync/engine.ts
11
11
  /** `files`: a message with files may have no text. */
@@ -45,6 +45,8 @@ const sameLinks = (a, b) => a.length === b.length && a.every((link, i) => linkKe
45
45
  const FILE_ATTEMPTS = 3;
46
46
  /** How long a platform's answer to who has an email holds, for `@[ada@vercel.com]`: a busy thread asks once. */
47
47
  const EMAIL_TTL_MS = 3e5;
48
+ /** How many `@[email]`s one message has looked up on a platform: each is a call to it, and a message holds thousands. */
49
+ const EMAIL_LOOKUPS_PER_MESSAGE_MAX = 10;
48
50
  /** How long a webhook waits for the board's tables before it lets an event into the inbox anyway: platforms resend after about 3 seconds. */
49
51
  const GATE_WAIT_MS = 2e3;
50
52
  /**
@@ -494,7 +496,7 @@ function createSyncEngine(entries) {
494
496
  notes.push(fileNote(file, "it was empty"));
495
497
  continue;
496
498
  }
497
- const name = file.name ?? `${file.type}`;
499
+ const name = importedFileName(file.name ?? `${file.type}`);
498
500
  try {
499
501
  attachments.push((await call("upload", {
500
502
  data,
@@ -946,14 +948,19 @@ function createSyncEngine(entries) {
946
948
  * A message's text for a platform, through entry `key`. A mention is `@[actor-id]`, settled when
947
949
  * the message was written: it reads natively when the actor is one of this entry's own users
948
950
  * (`@[slack:user:U0456]` also naming this sync's own profile of them), and as the actor's name
949
- * otherwise. An `@[email]` is whoever the platform finds with it, or the email. Everything else
951
+ * otherwise. An `@[email]` is whoever the platform finds with it, or the email, for the first 10
952
+ * a message names. Everything else
950
953
  * is text and goes as written, an `@handle` included: no sync reads one as a mention.
951
954
  */
952
955
  async function textFor(key, actors, text) {
953
956
  const exact = extractMentions(text).flatMap((token) => token.kind === "actor" ? [token.actor] : []);
954
957
  if (exact.length === 0) return text;
955
958
  const found = /* @__PURE__ */ new Map();
956
- for (const named of exact) if (!actors.byId[named] && isEmail(named)) found.set(named, await emailMention(key, named));
959
+ let asked = 0;
960
+ for (const named of exact) {
961
+ if (actors.byId[named] || !isEmail(named) || found.has(named)) continue;
962
+ found.set(named, asked++ < EMAIL_LOOKUPS_PER_MESSAGE_MAX ? await emailMention(key, named) : null);
963
+ }
957
964
  return replaceMentions(text, (token) => {
958
965
  if (token.kind === "handle") return null;
959
966
  if (found.has(token.actor)) return found.get(token.actor) ?? token.actor;
@@ -1057,7 +1064,8 @@ function createSyncEngine(entries) {
1057
1064
  const { markdown, ...rest } = await render(key, target, message, actors, renderer);
1058
1065
  return {
1059
1066
  markdown: message.attachments.length > 0 && (noted || !platformOf(key).uploadsFiles) ? `${markdown}\n${attachmentNotes(message)}` : markdown,
1060
- ...rest
1067
+ ...rest,
1068
+ external: message.from !== null && message.from !== "board"
1061
1069
  };
1062
1070
  };
1063
1071
  async function postReply(message, target, externalThread, actors, renderer) {
@@ -1,4 +1,4 @@
1
- import { a as DIRECT_UPLOAD_BYTES_MAX, i as ATTACHMENT_BYTES_MAX, n as formatProfileHeader, u as typeOf } from "./profile-header-Cj0Cb1cf.mjs";
1
+ import { a as DIRECT_UPLOAD_BYTES_MAX, f as typeOf, i as ATTACHMENT_BYTES_MAX, n as formatProfileHeader } from "./profile-header-O8wC8yk8.mjs";
2
2
  import { m as MESSAGE_TEXT_MAX } from "./schemas-CUSTEFIy.mjs";
3
3
  import { r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
4
4
  import { ZodError } from "zod";
@@ -321,7 +321,17 @@ function createBoardClient(options) {
321
321
  }),
322
322
  discovery: () => call("GET", "/", { auth: false }),
323
323
  me: () => call("GET", "/me"),
324
- channels: async () => (await call("GET", "/channels")).channels,
324
+ /**
325
+ * A page of the board's channels: `prefix` keeps the ones whose path starts with it (`dev/`), `limit` is how many
326
+ * (100 unless it says, 500 at most), and `after` takes a page's `next`, which is null on the last.
327
+ */
328
+ channels: async (query = {}) => {
329
+ const page = await call("GET", `/channels${queryString(query)}`);
330
+ return {
331
+ ...page,
332
+ next: page.next ?? null
333
+ };
334
+ },
325
335
  /**
326
336
  * Makes a channel before anything posts to it, as a first post would. Needs `read` and `post`
327
337
  * there. `created` is false when it was there already; it's left as it is.
@@ -354,7 +364,11 @@ function createBoardClient(options) {
354
364
  };
355
365
  const before = await reaching();
356
366
  if (before.length > 0) throw granted(before);
357
- const there = (await call("GET", "/channels")).channels.find((channel) => channel.path === path || channel.path.startsWith(pattern));
367
+ const first = async (prefix) => (await call("GET", `/channels${queryString({
368
+ prefix,
369
+ limit: 1
370
+ })}`)).channels.find((channel) => channel.path === path || channel.path.startsWith(pattern));
371
+ const there = await first(path) ?? await first(pattern);
358
372
  if (there) throw new BoardError("channel_exists", there.path === path ? `${path} is a channel already, so it stays as it is.` : `${there.path} is a channel already, and a private ${path} would close it too, so nothing was made.`, 409, { hint: `Close it with a grant: everyone at ${pattern} with 'none'.` });
359
373
  const own = await call("POST", "/grants", { body: {
360
374
  principals: [creator],
@@ -391,8 +405,20 @@ function createBoardClient(options) {
391
405
  };
392
406
  },
393
407
  actors: async () => (await call("GET", "/actors")).actors,
394
- messages: (query = {}) => call("GET", `/messages${queryString(query)}`),
395
- thread: (id) => call("GET", `/messages/${path(id)}`),
408
+ /**
409
+ * One channel, by its whole name: a board lists messages a channel at a time, never across channels. Its
410
+ * `messages()` are the channel's across its threads, oldest first: the newest `limit` (50 without one), or with
411
+ * `after`, a cursor a read of this channel answered, the ones posted since.
412
+ */
413
+ channel: (name) => ({ messages: (query = {}) => call("GET", `/messages${queryString({
414
+ channel: name,
415
+ ...query
416
+ })}`) }),
417
+ /**
418
+ * A thread: its root and its replies. `after`, one of its messages, answers the replies after it, and `limit` that
419
+ * many of them: with `after` the first after it, to read on from, and without, the newest.
420
+ */
421
+ thread: (id, range = {}) => call("GET", `/messages/${path(id)}${queryString(range)}`),
396
422
  /** Your own post with the client ID you gave it, as posting it answered: 404 `post_not_found` when there's none. */
397
423
  posted: async (id) => (await call("GET", `/posts/${path(id)}`)).message,
398
424
  /** 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`. */
@@ -655,6 +681,7 @@ function createBoardClient(options) {
655
681
  inboxAck: (key, id, body) => call("POST", `/inbox/${path(key)}/${path(id)}/ack`, { body }),
656
682
  /** Live events. Reconnects from the last seen index whenever the stream closes, and tells `onState` whether it's live or retrying. */
657
683
  async *events(query = {}, opts = {}) {
684
+ const { last, ...rest } = query;
658
685
  let after = query.after;
659
686
  let failures = 0;
660
687
  const state = eventsState(opts.onState);
@@ -662,7 +689,8 @@ function createBoardClient(options) {
662
689
  let response;
663
690
  try {
664
691
  response = await raw("GET", `/events${queryString({
665
- ...filtersQuery(query),
692
+ ...filtersQuery(rest),
693
+ ...after === void 0 && last !== void 0 ? { last } : {},
666
694
  after
667
695
  })}`, {
668
696
  headers: { accept: "text/event-stream" },
@@ -670,7 +698,7 @@ function createBoardClient(options) {
670
698
  });
671
699
  } catch (error) {
672
700
  if (opts.signal?.aborted) return;
673
- if (error instanceof BoardError && error.status >= 400 && error.status < 500) throw error;
701
+ if (error instanceof BoardError && (error.status === 501 || error.status >= 400 && error.status < 500)) throw error;
674
702
  state.failed();
675
703
  await new Promise((r) => setTimeout(r, Math.min(3e4, 500 * 2 ** failures++)));
676
704
  continue;
@@ -1,5 +1,5 @@
1
1
  import { _ as NewLabels, d as LabelKey } from "./schemas-CUSTEFIy.mjs";
2
- import { n as ExternalEvent, r as ExternalLocation } from "./external-D2jq_DEQ.mjs";
2
+ import { n as ExternalEvent, r as ExternalLocation } from "./external-DkWafjn-.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/sync/fn.ts
5
5
  const ROUTES = Symbol.for("board.syncRoutes");