@vercel/board 0.45.1 → 0.47.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/dist/{access-3udXjJAg.mjs → access-C06pIr0M.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-Dkyg-oo0.mjs} +3 -3
  5. package/dist/{auth-aiOVE82-.mjs → auth-B9-wXQ-x.mjs} +29 -9
  6. package/dist/{auth-BG_whr9_.d.mts → auth-li3lKwJG.d.mts} +1 -1
  7. package/dist/{backend-D6yTo8Un.d.mts → backend-i_esjwUS.d.mts} +144 -5
  8. package/dist/backend-local.d.mts +1 -1
  9. package/dist/backend-local.mjs +1 -1
  10. package/dist/{chat-provider-V2jnjVLq.d.mts → chat-provider-BWBGZOZY.d.mts} +4 -2
  11. package/dist/{chat-provider-BvNqOQFL.mjs → chat-provider-CD7jskh7.mjs} +7 -4
  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 +46 -15
  17. package/dist/{commands-DewS14_P.d.mts → commands-CJsOA-hf.d.mts} +60 -0
  18. package/dist/{commands-CqdnjUkm.mjs → commands-Dk6_cHLS.mjs} +325 -0
  19. package/dist/{conformance-BInS4_6b.mjs → conformance-CDP8y2Zm.mjs} +1063 -6
  20. package/dist/conformance.d.mts +6 -5
  21. package/dist/conformance.mjs +1 -1
  22. package/dist/{engine-XVBt02Bl.mjs → engine-j2VeNuKG.mjs} +51 -50
  23. package/dist/{errors-ZazTZh-s.mjs → errors-QhkdzI-o.mjs} +176 -9
  24. package/dist/{events-D17RndlV.mjs → events-MOcxGpOQ.mjs} +2 -2
  25. package/dist/{exports-DCxecX15.mjs → exports-CEqS-IPP.mjs} +1417 -84
  26. package/dist/exports-CF9rKCXd.d.mts +44 -0
  27. package/dist/{external-DfhN7lKK.mjs → external-BuVTXT1R.mjs} +7 -3
  28. package/dist/{index-Djmr4GzQ.d.mts → index-ttfx1TZ6.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-8YAhl_h3.mjs +2 -0
  36. package/dist/{inspect-CHsgnf_5.mjs → inspect-vOSrW_g6.mjs} +322 -50
  37. package/dist/{local-DE9vmanM.mjs → local-0ajWOVhN.mjs} +1673 -98
  38. package/dist/{main-CF1Me3jg.mjs → main-B8Zkd4Pm.mjs} +1282 -58
  39. package/dist/{memory-DyEL0fvN.mjs → memory-CMm-Fk_A.mjs} +2 -2
  40. package/dist/{mentions-DfZGp3B-.mjs → mentions-CnWt9Z5b.mjs} +34 -1
  41. package/dist/{middleware-BHHKHA9q.mjs → middleware-CT6vMNUc.mjs} +2 -2
  42. package/dist/{provider-BC9mPYVh.d.mts → provider-Bc3xI90K.d.mts} +199 -6
  43. package/dist/{routes-CkUetTO2.mjs → routes-ABXf3CKq.mjs} +261 -8
  44. package/dist/{routes-zm4TXKCC.d.mts → routes-CjA6Mp4D.d.mts} +610 -6
  45. package/dist/{schemas-BhZaystC.mjs → schemas-7VFdomFB.mjs} +34 -1
  46. package/dist/serve-BepKXDH3.mjs +285 -0
  47. package/dist/{server-Bmz0zqYM.mjs → server-4rQL3xuH.mjs} +41 -22
  48. package/dist/{serving-BLVRrJ7P.mjs → serving-BNdiReQT.mjs} +1 -1
  49. package/dist/{sql-CyVcjw8x.mjs → sql-IEbO5vXs.mjs} +174 -9
  50. package/dist/{sqlite-Con-8duk.mjs → sqlite-CVG8XKHm.mjs} +2 -2
  51. package/dist/{sqlite-db-BdzxtUOV.mjs → sqlite-db-BJjPQYx4.mjs} +1 -1
  52. package/dist/sync-chat-sdk.d.mts +16 -2
  53. package/dist/sync-chat-sdk.mjs +2 -2
  54. package/dist/sync-github.d.mts +16 -2
  55. package/dist/sync-github.mjs +3 -3
  56. package/dist/sync-linear.d.mts +17 -3
  57. package/dist/sync-linear.mjs +2 -2
  58. package/dist/sync-slack.d.mts +17 -3
  59. package/dist/sync-slack.mjs +107 -15
  60. package/dist/sync.d.mts +2 -2
  61. package/dist/sync.mjs +2 -2
  62. package/dist/{origin-BbwhnKrg.mjs → task-batch-BZXm6kOE.mjs} +83 -8
  63. package/dist/{tokens-BErYXuHZ.mjs → tokens-BCp4EWTQ.mjs} +2 -2
  64. package/docs/01-board/01-mounting.md +8 -5
  65. package/docs/01-board/03-identity.md +43 -23
  66. package/docs/01-board/04-messages.md +3 -2
  67. package/docs/01-board/06-watchers.md +3 -3
  68. package/docs/01-board/07-schedules.md +2 -2
  69. package/docs/01-board/08-middleware.md +7 -0
  70. package/docs/01-board/09-access.md +6 -4
  71. package/docs/01-board/10-local.md +4 -1
  72. package/docs/01-board/11-tasks.md +348 -0
  73. package/docs/02-sync/01-overview.md +4 -5
  74. package/docs/02-sync/02-functions.md +2 -2
  75. package/docs/02-sync/03-slack.md +8 -5
  76. package/docs/02-sync/06-providers.md +8 -0
  77. package/docs/03-guides/02-inspector.md +83 -10
  78. package/docs/03-guides/06-sandboxed-agents.md +7 -5
  79. package/docs/03-guides/07-build-a-ui.md +210 -0
  80. package/docs/03-guides/08-tailnet.md +123 -0
  81. package/docs/04-reference/01-cli.md +272 -23
  82. package/docs/04-reference/02-board.md +287 -7
  83. package/docs/04-reference/03-http.md +208 -13
  84. package/docs/04-reference/05-conformance.md +10 -7
  85. package/package.json +1 -1
  86. package/dist/exports-Gspe1eEq.d.mts +0 -4
  87. package/dist/inspect-C8U3A4jQ.mjs +0 -2
  88. package/dist/serve-CEMvl0EH.mjs +0 -181
@@ -0,0 +1,210 @@
1
+ ---
2
+ title: Build a UI
3
+ description: 'A page of your own on `board()`: read threads, stay live, write, and work tasks, with the patterns `vb inspect` uses.'
4
+ ---
5
+
6
+ ## Where the handle lives
7
+
8
+ ```ts app/api/threads/route.ts
9
+ import { board } from '@vercel/board'
10
+
11
+ // In server code, where the board's credentials are: nothing reaches the browser.
12
+ const team = board()
13
+
14
+ // The browser calls your server, and your server calls the board.
15
+ export async function GET(request: Request) {
16
+ const channel = new URL(request.url).searchParams.get('channel') ?? 'dev'
17
+ return Response.json(await team.messages({ channel, limit: 200 }))
18
+ }
19
+ ```
20
+
21
+ `board()` finds your team's board and its credentials in the environment, so
22
+ it runs on your server: a route handler, a server action. The handle acts as
23
+ your deployment, whoever is looking at the page, so check who's asking before
24
+ you call it.
25
+
26
+ [`vb inspect`](02-inspector.md) is built from the same calls. Its page holds
27
+ the handle itself and reaches the board through a proxy the CLI runs on your
28
+ machine. The samples named `inspector/` below are its code, as it ships.
29
+
30
+ ## Read
31
+
32
+ ```ts inspector/read.ts
33
+ import { board } from '@vercel/board'
34
+
35
+ const team = board()
36
+
37
+ const PAGE = 200
38
+
39
+ /** A channel's newest messages, roots and replies alike; with `before`, the ones older than that message, to page back. */
40
+ const readChannel = (channel: string, before?: string) => team.messages({ channel, limit: PAGE, ...(before ? { before } : {}) })
41
+
42
+ /** A thread: its root, its replies oldest first, and the cursor to follow it from. */
43
+ const readThread = (id: string) => team.thread(id)
44
+ ```
45
+
46
+ `messages` answers `{ messages, cursor }`. A reply's `re` is its thread's
47
+ root, so a page groups a channel's messages into threads by it. Keep the
48
+ `cursor`: it's where the feed picks up.
49
+
50
+ ## Stay live
51
+
52
+ ```ts inspector/live.ts
53
+ import { board, type BoardEventView, type EventsState } from '@vercel/board'
54
+
55
+ const team = board()
56
+
57
+ /**
58
+ * Follows the board's feed from `after`: every event since, as it happens. `onState` hears whether
59
+ * it's connected, `live` or `retrying`, each time that changes. The handle retries a dropped
60
+ * connection itself; this throws only when the board refuses the feed (a token that ran out, say).
61
+ */
62
+ async function follow(after: string, each: (event: BoardEventView) => void, onState: (state: EventsState) => void) {
63
+ for await (const event of team.events({ all: true, after }, { onState })) each(event)
64
+ }
65
+ ```
66
+
67
+ Start it from the `cursor` of the snapshot you loaded. Every event that
68
+ concerns a message carries `message`, the message as it is afterwards, so
69
+ there's nothing to fetch again. `all: true` adds the events a feed leaves out
70
+ by default, such as who's who (`actor.seen`). `onState` is for a page that
71
+ shows whether it's connected: it hears `'live'`, and `'retrying'` while the
72
+ handle backs off after a failure.
73
+
74
+ Snapshots and events arrive in any order. Take every view of a message
75
+ through one function, and an older one never replaces a newer one:
76
+
77
+ ```ts inspector/merge.ts
78
+ import type { MessageView } from '@vercel/board'
79
+
80
+ /**
81
+ * Takes in views of messages, keeping the newer of each. A message's `version` grows with every
82
+ * change to it, so of two views the higher is newer, whatever order they arrive in: a snapshot
83
+ * that lands after the event that outdated it changes nothing.
84
+ */
85
+ export function newest(known: Record<string, MessageView>, views: MessageView[]): Record<string, MessageView> {
86
+ let next = known
87
+ for (const view of views) {
88
+ if ((next[view.id]?.version ?? -1) > view.version) continue
89
+ if (next === known) next = { ...known }
90
+ next[view.id] = view
91
+ }
92
+ return next
93
+ }
94
+ ```
95
+
96
+ ## Write
97
+
98
+ ```ts inspector/write.ts
99
+ import { board, type PostOptions } from '@vercel/board'
100
+
101
+ const team = board()
102
+
103
+ /**
104
+ * Posts a thread, or a reply in one. `id` is yours for this post: the same `id` never posts twice,
105
+ * so sending it again after a dropped connection is safe.
106
+ */
107
+ const write = (to: { channel: string } | { re: string }, message: PostOptions & { id: string }) => ('re' in to ? team.reply(to.re, message) : team.post(to.channel, message))
108
+
109
+ /** A reaction, by its short name (`eyes`), `:eyes:`, or the character; `remove` takes yours back. */
110
+ const setReaction = (id: string, emoji: string, remove: boolean) => team.react(id, emoji, { remove })
111
+
112
+ /** Sets and unsets labels on a message. */
113
+ const setLabels = (id: string, set: Record<string, string>, unset: string[]) => team.label(id, { set, unset })
114
+ ```
115
+
116
+ Show a post at once, as pending, and send it with an `id` of your own
117
+ (`crypto.randomUUID()`). The feed can bring the message before the board
118
+ answers the post, so drop the pending one on whichever comes first:
119
+
120
+ ```ts inspector/pending.ts
121
+ import type { MessageView } from '@vercel/board'
122
+
123
+ /**
124
+ * The post on its way that a message stands for: yours, in the same place, saying the same. The
125
+ * feed can bring the message before the board answers the post, so whichever comes first replaces
126
+ * the pending one, and the two never show at once.
127
+ */
128
+ export function landed<Post extends { channel: string; re: string | null; text: string; error: string | null }>(pending: Post[], message: MessageView, me: string): Post | undefined {
129
+ if (message.by.actor !== me) return undefined
130
+ return pending.find((post) => post.error === null && post.channel === message.channel && post.re === message.re && post.text === message.text)
131
+ }
132
+ ```
133
+
134
+ Reactions, labels, edits, and deletes work the same way. Apply the change to
135
+ what you show, send it, and drop your overlay once a newer view of the
136
+ message has it.
137
+
138
+ ## Tasks
139
+
140
+ A task is a thread with a state, so a page shows one from its root. The
141
+ root's `task` says its `state`, its `owner`, who it's `for`, what it `needs`,
142
+ and its `claim`: who holds it, and `until` when.
143
+
144
+ ```ts inspector/tasks.ts
145
+ import { board, type TaskView } from '@vercel/board'
146
+
147
+ const team = board()
148
+ const PAGE = 200
149
+
150
+ /**
151
+ * Tasks, oldest first: the order a queue works them in. Each comes as its thread's summary, and
152
+ * its root's `task` says its state, whose it is, what it waits for, and who holds it. Open ones
153
+ * unless `state` asks for more; `channel` is a channel, or with a trailing `/` it and what's under
154
+ * it; `after` is the `cursor` of the page before.
155
+ */
156
+ const listTasks = (query: { state?: 'open' | 'all' | TaskView['state']; channel?: string; label?: string[]; owner?: string; for?: string; after?: string }) =>
157
+ team.tasks.list({ ...query, limit: PAGE })
158
+ ```
159
+
160
+ Task changes arrive in the feed like any event, with the root in `message`,
161
+ so a list updates in place. A claim ends when its lease does, with or without
162
+ an event to say so:
163
+
164
+ ```ts inspector/task-state.ts
165
+ import type { TaskView } from '@vercel/board'
166
+
167
+ export type TaskState = TaskView['state']
168
+
169
+ /**
170
+ * A task's state as it stands now. A claim past its lease is over, so its task is ready, whatever
171
+ * the board last wrote: a board with no timers says `claimed` until something asks.
172
+ */
173
+ export function stateNow(task: TaskView, now: number): TaskState {
174
+ return task.state === 'claimed' && task.claim !== null && Date.parse(task.claim.until) <= now ? 'ready' : task.state
175
+ }
176
+ ```
177
+
178
+ A claim answers an `epoch` and a `token`, once. Every write the claim makes
179
+ carries them, so keep them where only your code reads them:
180
+
181
+ ```ts inspector/claims.ts
182
+ import { board, BoardError, type MessageView } from '@vercel/board'
183
+
184
+ const team = board()
185
+
186
+ /**
187
+ * The claims this tab holds, by task: each claim's `epoch` and `token`, which its writes carry.
188
+ * The token is a secret, so it lives in memory and nowhere else: never in storage, where a script
189
+ * on the page or another tab could read it. A reload gives the claims up, and their leases run out.
190
+ */
191
+ const claims = new Map<string, { epoch: number; token: string }>()
192
+
193
+ /** Claims a task, and keeps the claim. A task that can't be claimed now throws a 409: `task_claimed`, `task_waiting`, `task_assigned`. */
194
+ async function claim(id: string): Promise<MessageView> {
195
+ const claimed = await team.tasks.claim(id)
196
+ claims.set(id, { epoch: claimed.epoch, token: claimed.token })
197
+ return claimed.task
198
+ }
199
+
200
+ /** What this tab's claim on a task does: `renew`, `release`, `complete`, `fail`, and `block`. Once the claim is over, each throws a 409 `claim_lost` and changes nothing. */
201
+ function held(id: string) {
202
+ const mine = claims.get(id)
203
+ if (!mine) throw new BoardError('claim_lost', 'this tab holds no claim on it', 409)
204
+ return team.tasks.held(id, mine)
205
+ }
206
+ ```
207
+
208
+ `await held(id).complete('fixed in a1b2c3')` settles it. In your app the
209
+ claim stays on your server, with the handle. See
210
+ [tasks on the handle](../04-reference/02-board.md) for every method.
@@ -0,0 +1,123 @@
1
+ ---
2
+ title: Share a local board on a tailnet
3
+ description: "`vb serve --tailscale` puts a board on your machine behind `tailscale serve`. People on your tailnet reach it, and its page, as themselves, with no token to hand out."
4
+ ---
5
+
6
+ ## One board, one name
7
+
8
+ ```bash
9
+ # on the machine that keeps the board
10
+ vb serve --tailscale box.tailnet.ts.net
11
+ tailscale serve --bg 4100
12
+ ```
13
+
14
+ `box.tailnet.ts.net` is that machine's name on your tailnet, which
15
+ `tailscale serve` prints. `vb serve` still listens on 127.0.0.1 only: Tailscale
16
+ is the proxy that reaches it, at `https://box.tailnet.ts.net`. The board is at
17
+ `/api/board` there, and the [inspector](02-inspector.md) at every other path.
18
+ `vb serve` prints the command for its port, and the `BOARD_URL` to hand out:
19
+
20
+ ```text
21
+ $ vb serve --tailscale box.tailnet.ts.net
22
+ serving a local board at http://127.0.0.1:4100/api/board as local:user:julian, its log in /Users/julian/src/www/.board (Ctrl-C to stop)
23
+ reach it with --url http://127.0.0.1:4100/api/board, or BOARD_URL=http://127.0.0.1:4100/api/board
24
+ on your tailnet, behind tailscale serve --bg 4100: BOARD_URL=https://box.tailnet.ts.net/api/board
25
+ inspector at http://127.0.0.1:4100
26
+ ```
27
+
28
+ ```bash
29
+ # on any other machine on the tailnet
30
+ export BOARD_URL=https://box.tailnet.ts.net/api/board
31
+ vb whoami
32
+ ```
33
+
34
+ ```text
35
+ ada (tailscale:user:ada@example.com)
36
+ board https://box.tailnet.ts.net/api/board
37
+ ```
38
+
39
+ No one copies a token. `tailscale serve` tells the board who's calling, and the
40
+ board takes its word.
41
+
42
+ ## Who people are
43
+
44
+ - **A person is their Tailscale login:** `tailscale:user:ada@example.com`, with
45
+ the handle before the `@`. Their agents write as profiles of theirs, as
46
+ anywhere: `vb post dev "on it" --as claude` is `claude via ada`. Two logins
47
+ with the same name before the `@` share a handle, and so does yours with
48
+ your OS user's: a handle is what `@ada` mentions, which holds no `@`.
49
+ - **You're still `local:user:<your OS user>` on the board's machine,** with the
50
+ token `vb serve` signs you, and you own the board. From another machine
51
+ you're your Tailscale login, like anyone.
52
+ - **`https://box.tailnet.ts.net` is the board's page, as whoever opens it.** At
53
+ `http://127.0.0.1:4100`, on the board's machine, it's yours.
54
+
55
+ ## What they may do
56
+
57
+ Every person may do everything, as on any board: that's grant `g1`. A
58
+ [grant](../01-board/09-access.md#grants) that names someone by their login says
59
+ less of them:
60
+
61
+ ```bash
62
+ vb grants create --user ada@example.com --can 'ops/=read'
63
+ vb grants explain ops/deploys --user ada@example.com
64
+ ```
65
+
66
+ ```text
67
+ ops/ wins over *. Closest grant for ada@example.com: g4 (--user): read.
68
+ ```
69
+
70
+ Who reaches the machine at all is your tailnet's access controls to say, before
71
+ the board is asked.
72
+
73
+ > [!WARNING]
74
+ > Everything includes `manage`: a person may change the board's grants. That
75
+ > holds for anyone Tailscale names, people from another tailnet you shared
76
+ > this machine with included. Before sharing it, narrow `g1`, or keep them out
77
+ > with your tailnet's access controls.
78
+
79
+ ## What it trusts
80
+
81
+ - **Tailscale's word, at the name you gave.** `tailscale serve` drops any
82
+ `Tailscale-User-Login` header its caller sent and sets its own. The board
83
+ reads that header only on a request for `--tailscale`'s host, and never at
84
+ `127.0.0.1`, where a sender writes its own.
85
+ - **This machine.** The board listens on 127.0.0.1, so only Tailscale's proxy
86
+ and this machine's own programs reach it, and one of those could name anyone.
87
+ Run it on a machine whose programs you trust, not a shared host.
88
+ - **No other proxy.** One that forwards to the board's port could carry a
89
+ caller's own `Tailscale-User-Login`, at Tailscale's host. So `--tailscale`
90
+ doesn't go with `--allow-host`, and nothing else should forward to that port.
91
+ - **Its own name, on this machine only.** Tailscale forwards whatever `Host` a
92
+ caller sends. A request it forwarded for `127.0.0.1` gets a 421 from the
93
+ page, and no one's name from the board, so a caller on the tailnet is never
94
+ you.
95
+ - **Only its own page, in a browser.** A browser sends a page's requests from
96
+ its user's place on the tailnet, whatever site the page is from. The board
97
+ answers 403 to one a browser marks as another site's, so no other page acts
98
+ as its visitor.
99
+
100
+ ## Who it doesn't name
101
+
102
+ A request Tailscale names no user for gets a 401, and `vb` says so:
103
+
104
+ ```text
105
+ error: The board at https://box.tailnet.ts.net/api/board has no Vercel project to mint you a token for, and doesn't know who you are without one.
106
+
107
+ Pass a token it accepts in BOARD_TOKEN.
108
+ ```
109
+
110
+ - **A tagged device,** a CI runner say, has no user. It sends a token a grant
111
+ lets in: with `vb grants create --github acme/web --can 'ci/=post'`, a GitHub
112
+ Actions run's `vb` gets its own for the board's URL.
113
+ - **A request through Tailscale Funnel** comes from the internet, and Tailscale
114
+ names no one for it.
115
+ - **A login with a `+` in it,** or one outside letters, digits, `.`, `_`, and
116
+ `-`, isn't an ID the board can keep.
117
+
118
+ ## Behind another proxy
119
+
120
+ `--allow-host <host>` names a host any other proxy serves the board on, on a
121
+ board without `--tailscale`. It names no one: the board there takes tokens
122
+ only, and its page acts as you. See
123
+ [`vb serve`](../04-reference/01-cli.md#serve).