@vercel/board 0.48.1 → 0.50.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 (87) hide show
  1. package/dist/{access-C06pIr0M.mjs → access-BbgmsAFF.mjs} +29 -17
  2. package/dist/access.d.mts +2 -2
  3. package/dist/access.mjs +5 -5
  4. package/dist/{actors-Dkyg-oo0.mjs → actors-CX2D22hL.mjs} +4 -3
  5. package/dist/{auth-B9-wXQ-x.mjs → auth-DJDTfgAL.mjs} +2 -2
  6. package/dist/{auth-li3lKwJG.d.mts → auth-Z9-Khvvw.d.mts} +1 -1
  7. package/dist/{backend-UBP6HimX.d.mts → backend-CcaaS9Xl.d.mts} +31 -8
  8. package/dist/backend-local.d.mts +1 -1
  9. package/dist/backend-local.mjs +1 -1
  10. package/dist/{chat-provider-iN0DFsSE.d.mts → chat-provider-DQ1GHm4o.d.mts} +2 -2
  11. package/dist/{chat-provider-kNWd6MQC.mjs → chat-provider-HJ7y_ipp.mjs} +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 +8 -2
  15. package/dist/cli-embedded.mjs +10 -4
  16. package/dist/cli.mjs +6 -6
  17. package/dist/client-C2T4eaXd.d.mts +544 -0
  18. package/dist/{commands-CJsOA-hf.d.mts → commands-Cm4sODIu.d.mts} +12 -8
  19. package/dist/{commands-Dk6_cHLS.mjs → commands-nN8WpvCe.mjs} +75 -58
  20. package/dist/{conformance-CDP8y2Zm.mjs → conformance-Cr-umDl0.mjs} +102 -20
  21. package/dist/conformance.d.mts +1 -1
  22. package/dist/conformance.mjs +1 -1
  23. package/dist/{engine-BQ0hJw2w.mjs → engine-DJZ8Xy_g.mjs} +10 -7
  24. package/dist/{errors-QhkdzI-o.mjs → errors-DYF4hhIc.mjs} +53 -174
  25. package/dist/{events-B-qyxNsJ.mjs → events-BdOCmnZh.mjs} +3 -3
  26. package/dist/{exports-BzSG0_wL.mjs → exports-CuD-Mxkw.mjs} +389 -118
  27. package/dist/{exports-inhbjAWi.d.mts → exports-lmr6UHHc.d.mts} +4 -4
  28. package/dist/{external-BuVTXT1R.mjs → external-D2jq_DEQ.mjs} +1 -1
  29. package/dist/{index-B0Fnhvk7.d.mts → index-_KxJu15n.d.mts} +2 -2
  30. package/dist/index.d.mts +6 -6
  31. package/dist/index.mjs +4 -4
  32. package/dist/index.node.d.mts +7 -7
  33. package/dist/index.node.mjs +4 -4
  34. package/dist/inspect/app.js +39 -39
  35. package/dist/inspect/engine.js +3 -3
  36. package/dist/inspect-CZeoSm7E.mjs +272 -0
  37. package/dist/inspect-UCcPViyA.mjs +2 -0
  38. package/dist/inspect.d.mts +17 -0
  39. package/dist/inspect.mjs +196 -0
  40. package/dist/{local-BdKxz-Dn.mjs → local-BVSFSSYf.mjs} +165 -61
  41. package/dist/{main-BgiViRZ8.mjs → main-B016auoG.mjs} +227 -49
  42. package/dist/{memory-CMm-Fk_A.mjs → memory-C2lzMV_t.mjs} +2 -2
  43. package/dist/{middleware-CT6vMNUc.mjs → middleware-DUKIITFZ.mjs} +3 -3
  44. package/dist/{page-D-OzDOAX.mjs → page-7KWSGxyC.mjs} +12 -2
  45. package/dist/page-CN77B014.mjs +2 -0
  46. package/dist/profile-header-Cj0Cb1cf.mjs +163 -0
  47. package/dist/{provider-DC3WHUXo.d.mts → provider-Dwb_9mnu.d.mts} +3 -529
  48. package/dist/{routes-CjA6Mp4D.d.mts → routes-B6SEA9yw.d.mts} +130 -4
  49. package/dist/{routes-ABXf3CKq.mjs → routes-BE0y6wCk.mjs} +40 -14
  50. package/dist/{schemas-7VFdomFB.mjs → schemas-CUSTEFIy.mjs} +11 -3
  51. package/dist/{serve-C2Jbr7pR.mjs → serve-B10e7QaY.mjs} +5 -5
  52. package/dist/{server-EOQC5Gtq.mjs → server-ViWNvg5q.mjs} +61 -29
  53. package/dist/{serving-BNdiReQT.mjs → serving-SbqeWqlA.mjs} +1 -1
  54. package/dist/{inspect-n9brh-TT.mjs → shell-DmpmgOPC.mjs} +25 -274
  55. package/dist/{sql-IEbO5vXs.mjs → sql-iABdyCiz.mjs} +18 -5
  56. package/dist/{sqlite-CVG8XKHm.mjs → sqlite-28EMrmk7.mjs} +2 -2
  57. package/dist/{sqlite-db-BJjPQYx4.mjs → sqlite-db-Ckd-ceNe.mjs} +1 -1
  58. package/dist/sync-chat-sdk.d.mts +2 -2
  59. package/dist/sync-chat-sdk.mjs +2 -2
  60. package/dist/sync-github.d.mts +2 -2
  61. package/dist/sync-github.mjs +3 -3
  62. package/dist/sync-linear.d.mts +3 -3
  63. package/dist/sync-linear.mjs +3 -3
  64. package/dist/sync-slack.d.mts +3 -3
  65. package/dist/sync-slack.mjs +11 -7
  66. package/dist/sync.d.mts +2 -2
  67. package/dist/sync.mjs +2 -2
  68. package/dist/{tags-BpFo6q0_.mjs → tags-D0qra0Qy.mjs} +1 -1
  69. package/dist/{task-batch-D4p9N8lN.mjs → task-batch-9lVDG3d-.mjs} +10 -11
  70. package/dist/{tokens-BCp4EWTQ.mjs → tokens-C-iK0Cku.mjs} +2 -2
  71. package/dist/version-C70RLVEK.mjs +5 -0
  72. package/docs/01-board/01-mounting.md +8 -0
  73. package/docs/01-board/03-identity.md +3 -2
  74. package/docs/01-board/04-messages.md +6 -2
  75. package/docs/01-board/05-reading.md +17 -2
  76. package/docs/01-board/09-access.md +40 -6
  77. package/docs/01-board/11-tasks.md +3 -3
  78. package/docs/02-sync/01-overview.md +2 -1
  79. package/docs/03-guides/02-inspector.md +31 -0
  80. package/docs/03-guides/06-sandboxed-agents.md +22 -21
  81. package/docs/04-reference/01-cli.md +91 -33
  82. package/docs/04-reference/02-board.md +20 -7
  83. package/docs/04-reference/03-http.md +9 -6
  84. package/docs/04-reference/05-conformance.md +7 -0
  85. package/package.json +5 -1
  86. package/dist/inspect-BB-XUPuz.mjs +0 -2
  87. package/dist/page-Dr9Aqlej.mjs +0 -2
@@ -75,7 +75,7 @@ echo "$EVENT" | vb reply "$id" --schema sandbox@1 - # the
75
75
  ```
76
76
 
77
77
  `--schema` takes the text as that schema's JSON, from wherever text comes: the
78
- argument, `-` for stdin, or `--text-file`. To say something beside the data,
78
+ argument, `-` for stdin, or `--file`. To say something beside the data,
79
79
  write the fence yourself. The text is still the message:
80
80
 
81
81
  ````text
@@ -186,7 +186,11 @@ agents can filter on and [watchers](./06-watchers.md) can wake on.
186
186
 
187
187
  - **Keys** are lowercase letters, numbers, `_`, `.`, and `-`, starting with a
188
188
  letter or number, up to 64 characters. **Values** are strings up to 256
189
- characters. Each key holds one value.
189
+ characters. Each key holds one value. A refused label says which and why:
190
+ `set: "Verdict" isn't a label key: one is 1 to 64 lowercase letters, …`.
191
+ - **Vercel's board is stricter about values:** it counts 256 bytes, not
192
+ characters, and refuses control characters, a newline among them. A short
193
+ line of text fits; keep a report's detail in its thread, not in a label.
190
194
  - **A label filter matches a message or its thread's root,** so labeling a root
191
195
  puts its whole thread in view. See [filters](./05-reading.md#filters).
192
196
  - **Labels stay on the board.** They never sync out to platforms. Sync does set
@@ -25,7 +25,8 @@ new since then: vb read errors-www --after 815
25
25
  channel: the root's header and first line, its reply count, and the latest
26
26
  reply. The latest activity comes last. It shows the newest 50 threads;
27
27
  `--limit` counts threads and takes up to 500. A thread is in when any of its
28
- messages matches the filters.
28
+ messages matches the filters. When there are older ones, it says so, and
29
+ the command that shows more: `(older not shown: vb read errors-www --limit 100)`.
29
30
  - **`vb read <id>`** shows one whole thread, from any message in it, plus its
30
31
  pending [scheduled messages](./07-schedules.md).
31
32
  - **`vb read`** with no channel reads across every channel, and each summary
@@ -166,7 +167,21 @@ last=$(jq -r .cursor <<<"$next")
166
167
  ```
167
168
 
168
169
  `read` reports a `cursor` too: `vb read firehose-www --after 815` lists only
169
- the threads with activity since.
170
+ the threads with activity since, the oldest first, up to `--limit`. When more
171
+ than that changed, its last line reads on from the page's newest message
172
+ instead of the cursor, which is past the threads the page left out:
173
+
174
+ ```text
175
+ more since then: vb read firehose-www --after 840
176
+ ```
177
+
178
+ With a filter on messages (`--by`, `--text`, `--mentions`, `--re`,
179
+ `--source`), a thread may be placed by its newest match, which the page
180
+ doesn't show, so the line reads the same cursor again with a bigger `--limit`.
181
+
182
+ With `--json`, a page of `--limit` threads may not be all of them: read again
183
+ after the same cursor with a bigger `--limit` before you move on to its
184
+ `cursor`.
170
185
 
171
186
  ## In code
172
187
 
@@ -65,9 +65,12 @@ import { board } from '@vercel/board'
65
65
  // The board at BOARD_URL, one that keeps grants: vb serve's, say.
66
66
  const team = board()
67
67
 
68
- // Close security/ to everyone, then open it to two people.
69
- await team.createGrant({ principals: [{ kind: 'everyone' }], can: { 'security/': [] } })
70
- const { grant } = await team.createGrant({ principals: [{ kind: 'user', email: 'alice@acme.com' }, { kind: 'user', email: 'bob@acme.com' }], can: { 'security/': 'all' } })
68
+ // Close security/ to everyone but two people, in one write.
69
+ const { grants } = await team.createGrants([
70
+ { principals: [{ kind: 'everyone' }], can: { 'security/': [] } },
71
+ { principals: [{ kind: 'user', email: 'alice@acme.com' }, { kind: 'user', email: 'bob@acme.com' }], can: { 'security/': 'all' } },
72
+ ])
73
+ const grant = grants[1]
71
74
  // acme/web's CI posts in ci/ from its main branch.
72
75
  await team.createGrant({ principals: [{ kind: 'github', repository: 'acme/web', workflow: 'ci.yml', branch: 'main' }], can: { 'ci/': ['post'] } })
73
76
  await team.updateGrant(grant.id, { add: [{ kind: 'user', email: 'carol@acme.com' }] })
@@ -84,8 +87,9 @@ deployments.
84
87
  | CLI | Handle |
85
88
  | --- | --- |
86
89
  | `vb grants` | `team.grants()` |
87
- | `vb grants create --everyone --can 'security/=none'` | `team.createGrant({ principals: [{ kind: 'everyone' }], can: { 'security/': 'none' } })` |
88
90
  | `vb grants create --user alice@acme.com --user bob@acme.com --can 'security/=all'` | `team.createGrant({ principals: [{ kind: 'user', email: 'alice@acme.com' }, { kind: 'user', email: 'bob@acme.com' }], can: { 'security/': 'all' } })` |
91
+ | `vb grants create --file grants.json` | `team.createGrants([{ principals: [{ kind: 'everyone' }], can: { 'security/': 'none' } }, { principals: [{ kind: 'user', email: 'alice@acme.com' }], can: { 'security/': 'all' } }])` |
92
+ | `vb grants create --everyone --can 'attic/=none' --lock-me-out` | `team.createGrant({ principals: [{ kind: 'everyone' }], can: { 'attic/': 'none' } }, { lockMeOut: true })` |
89
93
  | `vb grants create --project sec --environment production,preview --can 'security/=read,post'` | `team.createGrant({ principals: [{ kind: 'project', project: 'sec', environments: ['production', 'preview'] }], can: { 'security/': ['read', 'post'] } })` |
90
94
  | `vb grants create --github acme/web --workflow ci.yml --git-branch main --can 'ci/=post'` | `team.createGrant({ principals: [{ kind: 'github', repository: 'acme/web', workflow: 'ci.yml', branch: 'main' }], can: { 'ci/': ['post'] } })` |
91
95
  | `vb grants create --oidc https://gitlab.com --claim project_id=42 --can 'ci/=post'` | `team.createGrant({ principals: [{ kind: 'oidc', issuer: 'https://gitlab.com', claims: { project_id: '42' } }], can: { 'ci/': ['post'] } })` |
@@ -193,12 +197,26 @@ more specific pattern decides first.
193
197
  so what `everyone` gets doesn't count. Unless you may list the grants,
194
198
  revoking or changing one you can't reach answers the same 403 as one that
195
199
  isn't there, so trying g1, g2, and on finds out nothing.
200
+ - **A change you couldn't take back takes saying so.** Closing `security/` to
201
+ `everyone` closes it to whoever closes it, and lifting it takes `manage`
202
+ there. So a grant write that takes its caller's own `manage` at a pattern it
203
+ names is 409 `grant_lockout`, and nothing is written. Keep yourself in with
204
+ a grant that names you at each pattern the lock names, made before it or in
205
+ the same write, or pass `lockMeOut` (`--lock-me-out`) to go ahead. Revoking
206
+ or narrowing the grant that keeps you in is the same lockout.
207
+ - **Several grants go in one write.** `createGrants([…])`
208
+ (`POST /grants/batch`, 16 at most) makes all of them or none, in the order
209
+ given. Each needs what it would alone, on the grants as they are, and what
210
+ they leave you with is judged with all of them made. So a lock and the
211
+ grant that keeps you in pass together, whichever comes first.
212
+ `vb grants create --file` makes the ones a JSON file holds.
196
213
  - **Naming an `oidc` principal takes `manage` everywhere,** since the board
197
214
  then fetches its issuer's keys. Listing grants takes `manage` at `*`.
198
215
  - **Owners always may.** On Vercel's API, the team's owners. On a local board,
199
216
  its local user, the one `vb serve` mints a token for: a person on the team
200
- is a principal like any other. Reading a closed channel still takes a
201
- grant, an owner's too.
217
+ is a principal like any other. Nothing locks an owner out, so no write of
218
+ theirs is a lockout. Reading a closed channel still takes a grant, an
219
+ owner's too.
202
220
  - **A private channel is two grants and the channel.**
203
221
  `createChannel(path, { private: true })` makes a grant letting you in at
204
222
  `<path>/`, then one closing it to `everyone`, then the channel. Before it
@@ -445,6 +463,22 @@ and opens to them only as it opens to you, so grants on `*` stay yours to
445
463
  make. A grant on `security/` itself doesn't: it would meet the lock there and
446
464
  win, being closer. The board's owners always may.
447
465
 
466
+ ### Why won't the board let me close a channel to everyone?
467
+
468
+ Because that closes it to you too, and then you couldn't open it again:
469
+ lifting a lock takes `manage` where it applies. Make the grant that keeps you
470
+ in first, and it stays yours to change:
471
+
472
+ ```bash
473
+ vb grants create --user you@acme.com --can 'security/=all'
474
+ vb grants create --everyone --can 'security/=none'
475
+ ```
476
+
477
+ `vb grants create --file` makes both in one write.
478
+
479
+ `--lock-me-out` makes it anyway. Then only an owner, or someone a grant names
480
+ there with `manage`, can change it.
481
+
448
482
  ### How do I keep a channel from the project's own people?
449
483
 
450
484
  You can't, on one board: people who can access the board's Vercel project can
@@ -21,8 +21,8 @@ replies are the work log, and the board keeps its state. It's still a thread:
21
21
  on it as on any other.
22
22
 
23
23
  - **`vb tasks create <channel> "<text>"`** starts a thread as a task. It takes
24
- `--label`, `--text-file`, `--no-sync`, and `--idempotency-key` as `post`
25
- does.
24
+ `--label`, `--no-sync`, and `--idempotency-key` as `post` does, and `-` as
25
+ the text reads it from stdin. Its `--file` is a plan of several.
26
26
  - **`vb tasks create <id>`** makes a task of a thread that's there, as it is:
27
27
  an issue someone filed, a question from Slack. Its text stays its author's.
28
28
  - **You own the tasks you make.** A task's owner, or anyone with `manage` in
@@ -219,7 +219,7 @@ $ vb tasks needs 814 --none
219
219
  ```
220
220
 
221
221
  ```bash
222
- vb tasks create work --tasks-file plan.json --idempotency-key cve-123
222
+ vb tasks create work --file plan.json --idempotency-key cve-123
223
223
  ```
224
224
 
225
225
  ```text
@@ -171,7 +171,8 @@ like any message on the board, but never goes back through the key it came by.
171
171
 
172
172
  Within a project, one deployment holds each key, so a message never goes out
173
173
  twice. Production takes a key over from the project's previews and development;
174
- otherwise the first deployment to register a key keeps it. A deployment that
174
+ otherwise the first deployment to register a key keeps it, though a preview
175
+ never takes a key the project's production held. A deployment that
175
176
  doesn't hold a key runs nothing through it: its webhook for that key answers 200
176
177
  before its adapter reads anything, and it pulls, imports, starts, and delivers
177
178
  nothing there.
@@ -178,6 +178,37 @@ board under it at `/api/board`. Behind `tailscale serve`, use
178
178
  whoever Tailscale says opened it, not as you. See
179
179
  [Share a local board on a tailnet](08-tailnet.md).
180
180
 
181
+ ## In your app
182
+
183
+ `@vercel/board/inspect` serves the same page from a route in your app, so
184
+ people open the board at your deployment's URL, from any browser, phone
185
+ included, with nothing to run:
186
+
187
+ ```ts
188
+ // app/board/[[...path]]/route.ts
189
+ import { inspector } from '@vercel/board/inspect'
190
+ import { team } from '@/lib/board'
191
+
192
+ const inspect = inspector({ board: team, basePath: '/board' })
193
+
194
+ export const GET = inspect, POST = inspect, PATCH = inspect, PUT = inspect, DELETE = inspect
195
+ ```
196
+
197
+ The page is at `/board`, its bundle at `/board/app.js`, and its proxy at
198
+ `/board/board/*`. Each request acts as the handle you pass, under the
199
+ profile the page picks, so a person who names themselves `ada` posts as
200
+ `ada via <your app>`. The handle is your app, not whoever's visiting, so the
201
+ page asks who's posting before it loads, and the proxy refuses a write that
202
+ names no profile (401 `profile_required`). Reads need none.
203
+
204
+ Whoever reaches the route reads and writes as that handle, so put it behind
205
+ something that turns strangers away, like Vercel's Deployment Protection,
206
+ and refuse requests in front of it that the handle shouldn't take. The proxy
207
+ answers only its own page: every request carries a header the page sends,
208
+ a browser's must say it's from the same origin (`Sec-Fetch-Site`), and a write
209
+ needs the page's `Origin`. Next.js's Turbopack build copies the bundle into
210
+ its output on its own.
211
+
181
212
  ## Try writes safely
182
213
 
183
214
  The inspector writes to whichever board it points at, and a board's writes
@@ -7,10 +7,11 @@ description: A Vercel Sandbox network policy that gives an agent in a sandbox th
7
7
 
8
8
  An agent in a [Vercel Sandbox](https://vercel.com/docs/vercel-sandbox) runs code
9
9
  you don't trust with credentials. `sandboxPolicy()` returns a network policy for
10
- it: the sandbox reaches the board's host, and on it only the board's own routes,
11
- and the sandbox's proxy adds what they need on the way out. The credential, who
12
- the agent is, and what it may do never enter the sandbox, so nothing in it can
13
- read them, change them, or take them anywhere else.
10
+ it, and the environment `vb` in the sandbox runs with: the sandbox reaches the
11
+ board's host, and on it only the board's own routes, and the sandbox's proxy
12
+ adds what they need on the way out. The credential, who the agent is, and what
13
+ it may do never enter the sandbox, so nothing in it can read them, change them,
14
+ or take them anywhere else.
14
15
 
15
16
  ```ts lib/fixer.ts
16
17
  import { board } from '@vercel/board'
@@ -21,18 +22,13 @@ const team = board()
21
22
  const fixer = team.as({ name: 'fixer', avatar: 'https://example.com/fixer.png' })
22
23
 
23
24
  /** The board, as the fixer, and npm to install vb with. Every other host is blocked. */
24
- async function networkPolicy() {
25
- const { allow } = await fixer.sandboxPolicy()
26
- return { allow: { ...allow, 'registry.npmjs.org': [] } }
25
+ async function policy() {
26
+ const { allow, env } = await fixer.sandboxPolicy()
27
+ return { networkPolicy: { allow: { ...allow, 'registry.npmjs.org': [] } }, env }
27
28
  }
28
29
 
29
30
  export async function startFixer(thread: string) {
30
- const { url } = await team.discovery()
31
- const sandbox = await Sandbox.create({
32
- networkPolicy: await networkPolicy(),
33
- // vb needs a credential to send in BOARD_TOKEN; the policy replaces it on the way out.
34
- env: { BOARD_URL: url, BOARD_TOKEN: 'set-by-the-network-policy' },
35
- })
31
+ const sandbox = await Sandbox.create(await policy())
36
32
  await sandbox.runCommand('npm', ['install', '-g', '@vercel/board'])
37
33
  await sandbox.runCommand('vb', ['reply', thread, 'looking into it'])
38
34
  // const agent = await startYourAgent(sandbox) // yours
@@ -41,11 +37,16 @@ export async function startFixer(thread: string) {
41
37
 
42
38
  /** A new policy, before the deployment's OIDC token in the last one dies. */
43
39
  export async function refresh(sandbox: Sandbox) {
44
- await sandbox.update({ networkPolicy: await networkPolicy() })
40
+ const { networkPolicy } = await policy()
41
+ await sandbox.update({ networkPolicy })
45
42
  }
46
43
  ```
47
44
 
48
- `sandboxPolicy()` is async and takes:
45
+ `sandboxPolicy()` is async, and returns `{ allow, env }`: `allow` is the
46
+ network policy's hosts, which `networkPolicy: { allow }` takes, and `env` is
47
+ `BOARD_URL`, the board's, and `BOARD_TOKEN`, a placeholder for `vb` to send,
48
+ which the policy replaces with the credential on the way out. Pass `allow` in
49
+ `networkPolicy`, not the whole result. It takes:
49
50
 
50
51
  | Option | Does |
51
52
  | --- | --- |
@@ -121,7 +122,7 @@ Vercel Sandbox sends it as it is. Nothing in the sandbox can renew it.
121
122
  (`decodeJwt(token).exp` from `jose`, in seconds), or make a new policy on a
122
123
  schedule, and `sandbox.update({ networkPolicy })` before it expires: 15
123
124
  minutes ahead leaves room. Every update replaces the whole policy, so merge
124
- your own hosts in again, as `networkPolicy()` above does.
125
+ your own hosts in again, as `policy()` above does.
125
126
  - **A sandbox that stopped** resumes with the policy it saved, its token
126
127
  included: update it each time you resume one.
127
128
  - **A credential you pass** as `token` lasts as long as it does: refresh the
@@ -136,8 +137,8 @@ Vercel Sandbox sends it as it is. Nothing in the sandbox can renew it.
136
137
  From the handle: `sandboxPolicy()` on the team's board in Vercel's API uses the
137
138
  board's ID and team; on a board at `BOARD_URL`, that URL; on a board you mount
138
139
  with [`local()`](../01-board/10-local.md), its own, which `board({ url })` names
139
- off Vercel. `team.discovery()` answers the same URL, for the sandbox's
140
- `BOARD_URL`.
140
+ off Vercel. Its `env` has it as the sandbox's `BOARD_URL`, the same URL
141
+ `team.discovery()` answers.
141
142
 
142
143
  ### Can the agent upload files?
143
144
 
@@ -146,6 +147,6 @@ store, on a URL the board signs: add that store's host beside `allow`.
146
147
 
147
148
  ### Does it work without `@vercel/sandbox`?
148
149
 
149
- It returns a plain object that `Sandbox.create({ networkPolicy })` and
150
- `sandbox.update({ networkPolicy })` take, and depends on nothing of the SDK's.
151
- Any proxy that reads the same shape can run it.
150
+ It returns plain objects, an `allow` that `Sandbox.create({ networkPolicy })`
151
+ and `sandbox.update({ networkPolicy })` take and an `env` of strings, and
152
+ depends on nothing of the SDK's. Any proxy that reads the same shape can run it.
@@ -57,9 +57,18 @@ const code = await createApp({
57
57
  // How requests to Vercel's API go with that login: the app's own fetch, which adds the login's
58
58
  // credentials. Without it, the login goes as a Bearer token, which a DPoP login can't use.
59
59
  // fetch: (input, init) => yourSignedFetch(input, init), // a DPoP proof for each request
60
+ // A Vercel token someone passed for this run, as `vercel board --token` takes one: the login to
61
+ // use in place of `login`, ahead of everything the environment holds, a deployment's own token
62
+ // and BOARD_TOKEN included. Board sends it itself, as a Bearer token, never through `fetch`. A
63
+ // board at a URL gets a token minted with it, never the token itself.
64
+ // token: yourFlags.token,
60
65
  }).run(process.argv.slice(3))
61
66
  ```
62
67
 
68
+ A variable never goes ahead of a deployment's own token, so a token in the
69
+ environment is not one to pass here: pass only what the person typed for this
70
+ run. [`whoami`](#whoami) names it as its source, `the token you passed`.
71
+
63
72
  `class` fixes the exit code: `usage` and `missing_input` answer 2,
64
73
  `canceled` 130, and the rest 1, `timeout` included. Without `onError`, board
65
74
  prints its own on stderr: `error: ` and the lines, or with `--json`, its
@@ -237,9 +246,14 @@ for one to pass.
237
246
  `completed 812`, `blocked 813`, `unassigned 815`.
238
247
  - **IDs go in as they come out.** Output shows `#812`; pass `812`, or quote
239
248
  it as `'#812'`, since in a shell an unquoted `#` starts a comment.
240
- - **Text can come from a file or stdin.** `--text-file note.md` reads a file,
241
- and `--text-file -`, or `-` as the text, reads stdin. Text may be left out
249
+ - **Text can come from a file or stdin.** `--file note.md` reads a file,
250
+ and `--file -`, or `-` as the text, reads stdin. Text may be left out
242
251
  when the message has `--attach` files.
252
+ - **`--file` is what a command takes from a file,** and `-` there reads
253
+ stdin: a message's text on `post`, `reply`, `edit`, and `schedule`, a plan
254
+ of tasks on `tasks create`, several grants on `grants create`, and a JSON
255
+ Schema on `schemas create`, which also takes one written inline, as
256
+ `--data`.
243
257
  - **Errors go to stderr**: `error:` and what failed, then how to fix it, the
244
258
  command to run indented under it. With `--json`, one JSON document instead.
245
259
  See [Errors](#errors).
@@ -499,10 +513,11 @@ options every command takes: board help
499
513
 
500
514
  ```text
501
515
  vb grants [list]
502
- vb grants create <principal>... --can <pattern=permissions>...
503
- vb grants update <grant> [--add-<kind> <name>]... [--remove-<kind> <name>]... [--can <pattern=permissions>]...
516
+ vb grants create <principal>... --can <pattern=permissions>... [--lock-me-out]
517
+ vb grants create --file <path> [--lock-me-out]
518
+ vb grants update <grant> [--add-<kind> <name>]... [--remove-<kind> <name>]... [--can <pattern=permissions>]... [--lock-me-out]
504
519
  vb grants explain [<principal>] <channel>
505
- vb grants revoke <grant>
520
+ vb grants revoke <grant> [--lock-me-out]
506
521
  ```
507
522
 
508
523
  `vb grants` lists each grant's ID, the principals it names as the flags that
@@ -534,7 +549,13 @@ comma-separated list, `all`, or `none`. A board that verifies tokens itself,
534
549
  as `vb serve` does, takes IDs: `--user u_123`, `--project prj_123`, and an
535
550
  app's client ID.
536
551
 
537
- `create` prints the grant it made as its row. `update` takes `--add-<kind>` and
552
+ `create --file <path>` makes several grants in one write, or none of them:
553
+ the file is a JSON array of grants, each `{ principals, can }` as
554
+ [`createGrants`](./02-board.md#creategrant) takes them, and `-` reads it from
555
+ stdin. A lock and the grant that keeps you in go together that way, in either
556
+ order.
557
+
558
+ `create` prints each grant it made as its row. `update` takes `--add-<kind>` and
538
559
  `--remove-<kind>` for each kind (`--add-user`, `--remove-project`,
539
560
  `--add-github … --workflow …`), and `--can`, which replaces the grant's.
540
561
  Adding a project it names already adds the environments; to narrow one,
@@ -542,18 +563,53 @@ remove it and add it back in the same update. Each needs `manage` at the
542
563
  patterns the grant names, before and after. `revoke` stops one.
543
564
 
544
565
  ```text
545
- $ vb grants create --everyone --can 'security/=none'
546
- created g4 --everyone security/=none
547
566
  $ vb grants create --user alice@acme.com --user bob@acme.com --can 'security/=all'
548
- created g5 --user alice@acme.com --user bob@acme.com security/=all
567
+ created g4 --user alice@acme.com --user bob@acme.com security/=all
568
+ $ vb grants create --everyone --can 'security/=none'
569
+ created g5 --everyone security/=none
549
570
  $ vb grants create --project sec --environment production,preview --can 'security/=read,post'
550
571
  created g6 --project sec --environment production,preview security/=read,post
551
- $ vb grants update g5 --add-user carol@acme.com
552
- updated g5 --user alice@acme.com --user bob@acme.com --user carol@acme.com security/=all
572
+ $ vb grants update g4 --add-user carol@acme.com
573
+ updated g4 --user alice@acme.com --user bob@acme.com --user carol@acme.com security/=all
553
574
  $ vb grants update g6 --remove-project sec --add-project sec --environment production --can 'security/=read'
554
575
  updated g6 --project sec --environment production security/=read
555
- $ vb grants revoke g4
556
- revoked g4
576
+ $ vb grants revoke g5
577
+ revoked g5
578
+ ```
579
+
580
+ ```json grants.json
581
+ [
582
+ { "principals": [{ "kind": "everyone" }], "can": { "security/": "none" } },
583
+ { "principals": [{ "kind": "user", "userId": "u_julian" }], "can": { "security/": "all" } }
584
+ ]
585
+ ```
586
+
587
+ ```text
588
+ $ vb grants create --file grants.json
589
+ created g6 --everyone security/=none
590
+ created g7 --user u_julian security/=all
591
+ ```
592
+
593
+ A change you couldn't take back is refused, with reason `grant_lockout`:
594
+ closing a channel to everyone closes it to you, and lifting that takes
595
+ `manage` there. It says which grant to make first to keep yourself in, naming
596
+ you as a grant would (`--user`, `--project` and `--environment`, `--app`, or
597
+ `--github`), and `--lock-me-out` goes ahead. Revoking or narrowing the grant
598
+ that keeps you in is refused the same way. An owner is never locked out.
599
+
600
+ ```text
601
+ $ vb grants create --everyone --can factory/=read
602
+ error: Can't create the grant: it would lock you out.
603
+ this grant would leave you unable to manage grants in factory/
604
+
605
+ Keep manage there yourself first:
606
+ vb grants create --user u_julian --can factory/=all
607
+ Make it anyway:
608
+ vb grants create --everyone --can factory/=read --lock-me-out
609
+ $ vb grants create --user u_julian --can factory/=all
610
+ created g4 --user u_julian factory/=all
611
+ $ vb grants create --everyone --can factory/=read
612
+ created g5 --everyone factory/=read
557
613
  ```
558
614
 
559
615
  Vercel's board takes no `--github` or `--oidc` principal: a workflow gets in
@@ -644,7 +700,7 @@ one with a profile: `Malte via support (preview)`), and actor ID.
644
700
  ```text
645
701
  vb schemas [list]
646
702
  vb schemas inspect <schema>
647
- vb schemas create <schema> --schema <json|@file|-> [--description <text>]
703
+ vb schemas create <schema> (--file <path> | --data <json>) [--description <text>]
648
704
  ```
649
705
 
650
706
  A schema says what a piece of structured data holds: a JSON Schema for an
@@ -659,17 +715,18 @@ vercel-deployment@1 built in A Vercel deployment, by its URL and optionally t
659
715
  sandbox@1 2d What a sandbox did.
660
716
  ```
661
717
 
662
- `create` registers a version, for good. `--schema` takes the JSON Schema
663
- inline, from a file as `@<path>`, or from stdin as `-`. A version never
718
+ `create` registers a version, for good. `--file` takes the JSON Schema
719
+ from a file, or from stdin as `-`, and `--data` takes it written inline. A
720
+ version never
664
721
  changes: the same definition again registers nothing, and another one is
665
722
  refused, so a change is the next version. It needs `manage` at `*`.
666
723
 
667
724
  ```text
668
- $ vb schemas create sandbox@1 --schema @sandbox.schema.json --description 'What a sandbox did.'
725
+ $ vb schemas create sandbox@1 --file sandbox.schema.json --description 'What a sandbox did.'
669
726
  created sandbox@1
670
- $ vb schemas create sandbox@1 --schema @sandbox.schema.json --description 'What a sandbox did.'
727
+ $ vb schemas create sandbox@1 --file sandbox.schema.json --description 'What a sandbox did.'
671
728
  sandbox@1 is already registered
672
- $ vb schemas create sandbox@1 --schema '{"type":"object","required":["id"]}'
729
+ $ vb schemas create sandbox@1 --data '{"type":"object","required":["id"]}'
673
730
  error: Can't register schema sandbox@1.
674
731
  sandbox@1 is registered with another definition, and a version never changes: register a new version
675
732
 
@@ -679,7 +736,8 @@ error: Can't register schema sandbox@1.
679
736
 
680
737
  | Flag | Effect |
681
738
  | --- | --- |
682
- | `--schema <json\|@file\|->` | its JSON Schema: inline, the file `@<path>` names, or stdin for `-` |
739
+ | `--file <path>` | its JSON Schema, from a file, or stdin for `-` |
740
+ | `--data <json>` | its JSON Schema, written inline |
683
741
  | `--description <text>` | what it holds, in a sentence. Part of the version: it never changes either |
684
742
 
685
743
  `inspect` prints one version with its JSON Schema, to read before writing data
@@ -783,7 +841,7 @@ and canceled ones.
783
841
  ### post
784
842
 
785
843
  ```text
786
- vb post <channel|id> ["<text>" | --text-file <path>] [--schema <schema>] [--label k=v]... [--attach <file>]... [--sync <target>]... [--no-sync] [--idempotency-key <key>] [--after <id>]
844
+ vb post <channel|id> ["<text>" | --file <path>] [--schema <schema>] [--label k=v]... [--attach <file>]... [--sync <target>]... [--no-sync] [--idempotency-key <key>] [--after <id>]
787
845
  ```
788
846
 
789
847
  Starts a thread. The channel is created by its first post. Given a message ID
@@ -831,7 +889,7 @@ See [Data](../01-board/04-messages.md#data).
831
889
  ### reply
832
890
 
833
891
  ```text
834
- vb reply <id> ["<text>" | --text-file <path>] [--label k=v]... [--attach <file>]... [--no-sync] [--idempotency-key <key>] [--after <id>]
892
+ vb reply <id> ["<text>" | --file <path>] [--label k=v]... [--attach <file>]... [--no-sync] [--idempotency-key <key>] [--after <id>]
835
893
  ```
836
894
 
837
895
  Replies in a thread. `<id>` may be any message in it: the board stores the
@@ -843,7 +901,7 @@ you read, is still the thread's newest: see
843
901
  ### edit
844
902
 
845
903
  ```text
846
- vb edit <id> ("<text>" | --text-file <path>) [--if-revision N]
904
+ vb edit <id> ("<text>" | --file <path>) [--if-revision N]
847
905
  ```
848
906
 
849
907
  Replaces a message's text. Only its author may edit it: as yourself, any
@@ -880,7 +938,7 @@ vb label <id> k=v... [--unset k]... [--if k=v]... [--if-unset k]...
880
938
 
881
939
  Sets and unsets labels. Each key holds one value. Keys match
882
940
  `[a-z0-9][a-z0-9_.-]*` (up to 64 characters), other than `constructor` and
883
- `prototype`; values are up to 256 characters. `vb label` refuses `k=`, a label
941
+ `prototype`; values are up to 256 characters, with no control characters. `vb label` refuses `k=`, a label
884
942
  with no value, which would still count as set: `--unset k` removes a label.
885
943
  `--if k=v` changes them only
886
944
  while the message has that label, and `--if-unset k` only while it has none
@@ -894,7 +952,7 @@ Keys under `board.` are the board's own: writing one fails with
894
952
  ### schedule
895
953
 
896
954
  ```text
897
- vb schedule <channel|id> ["<text>" | --text-file <path>] (--in 1d | --at <time> | --every 30m)
955
+ vb schedule <channel|id> ["<text>" | --file <path>] (--in 1d | --at <time> | --every 30m)
898
956
  [--until <time> | --for 24h | --times N] [--label k=v]... [--attach <file>]... [--no-sync]
899
957
  vb schedule cancel <schedule>
900
958
  ```
@@ -922,9 +980,9 @@ with `manage` in its channel, and prints
922
980
 
923
981
  ```text
924
982
  vb tasks [channel] [--state <state>|open|all] [--label k=v]... [--by <handle>] [--for <profile>] [--after <cursor>] [--limit N]
925
- vb tasks create (<channel> ["<text>" | --text-file <path>] | <id>) [--label k=v]... [--needs <id>]... [--for <profile>]
983
+ vb tasks create (<channel> "<text>" | <id>) [--label k=v]... [--needs <id>]... [--for <profile>]
926
984
  [--claim [--lease <duration>]] [--no-sync] [--idempotency-key <key>]
927
- vb tasks create <channel> --tasks-file <path> [--idempotency-key <key>]
985
+ vb tasks create <channel> --file <path> [--idempotency-key <key>]
928
986
  vb tasks claim (<id> | --ready <channel> [--label k=v]... [--from <id>]... [--wait <duration>]) [--lease <duration>]
929
987
  vb tasks run (<id> | --ready <channel> [--label k=v]... [--from <id>]... [--wait <duration>])
930
988
  [--result "<text>"] [--lease <duration>] -- <cmd>...
@@ -947,7 +1005,7 @@ Threads agents are to do, each with a state the board keeps. See
947
1005
  | --- | --- | --- |
948
1006
  | `tasks [channel]` | lists open tasks, oldest first: `waiting`, `ready`, `claimed`, and `blocked` | a row per task: its ID, state, first line, and labels |
949
1007
  | `tasks create` | starts a thread as a task, or with an ID makes that thread one. You own it | its ID, or with `--claim` the claim |
950
- | `tasks create --tasks-file` | starts a thread for each task a JSON file holds, in as many writes as the board needs | a row per task, as the list shows it |
1008
+ | `tasks create --file` | starts a thread for each task a JSON file holds, in as many writes as the board needs | a row per task, as the list shows it |
951
1009
  | `tasks claim` | holds a task for a lease: by its ID, or with `--ready` the oldest ready one in a channel | the claim: `#812 yours for 15m fix CVE-123 in acme/web` |
952
1010
  | `tasks run` | claims a task, runs a command on it, and settles it by how the command exits | what the command prints, then `completed 812` or `failed 812`. With `--json`, what the command prints goes to stderr, and stdout is the one document |
953
1011
  | `tasks renew` | extends your lease, from now | the claim |
@@ -990,7 +1048,7 @@ $ vb tasks work/ --state all --limit 2
990
1048
  - **`--ready`** takes a task assigned to you first, then the oldest unassigned
991
1049
  one you own, or whose owner `--from <id>` names. `--wait` holds until one is
992
1050
  ready.
993
- - **`--tasks-file <path>`** makes a plan: a JSON array of tasks, each `{ key?,
1051
+ - **`--file <path>`** makes a plan: a JSON array of tasks, each `{ key?,
994
1052
  text, labels?, needs?, for?, noSync?, attachments? }`, from a file, or from
995
1053
  stdin for `-`. A task's `key` names it for the others of the file, and
996
1054
  `needs` takes `{ "key": "fix" }` for one of them or a task's ID for one
@@ -1047,7 +1105,7 @@ What can go wrong, by `reason`:
1047
1105
  | `task_not_owned` | the change is its owner's to make, or `manage`'s in its channel. A profile owns only the tasks it made | 1 |
1048
1106
  | `not_a_task`, `already_a_task` | the thread isn't a task, or `create <id>` named one that is | 1 |
1049
1107
  | `invalid_needs` | `--needs` or `tasks needs` named something that isn't a task you can read, or `tasks needs` a task that waits for this one. In a plan, a `key` two tasks have or none has, or tasks that wait for each other | 2 |
1050
- | `duplicate_id` | `--idempotency-key` was used for another task, or with `--tasks-file`, for another plan: other tasks where it made some, or more once it finished | 1 |
1108
+ | `duplicate_id` | `--idempotency-key` was used for another task, or with `--file`, for another plan: other tasks where it made some, or more once it finished | 1 |
1051
1109
  | `invalid_from` | `--from` named an owner by handle: several can share one, so it takes IDs | 2 |
1052
1110
  | `command_not_found` | `run`'s command couldn't start. The task is released | 1 |
1053
1111
  | `claim_too_wide` | on Vercel's board, `--ready` with `--from` would look in more than 200 places, its channels times the owners it takes from: name fewer owners, or a smaller subtree | 1 |
@@ -1086,17 +1144,17 @@ error: Can't change what task #814 needs. It waits for tasks you can read, and n
1086
1144
  ```
1087
1145
 
1088
1146
  ```text
1089
- $ vb tasks create work --tasks-file plan.json --idempotency-key cve-123
1147
+ $ vb tasks create work --file plan.json --idempotency-key cve-123
1090
1148
  #2 ready fix CVE-123 in acme/web step=fix
1091
1149
  #4 waiting review the fix for CVE-123 step=review needs #2
1092
1150
  #6 waiting ship it needs #4 #2
1093
- $ vb tasks create migration --tasks-file shards.json
1151
+ $ vb tasks create migration --file shards.json
1094
1152
  error: Can't create tasks in migration. A task's needs are tasks you can read, or keys of the plan's own.
1095
1153
  needs: #999999 isn't a task
1096
1154
  made 100 of 250: #214 to #412
1097
1155
 
1098
1156
  Make the rest, under the same key: what was made stays as it is:
1099
- vb tasks create migration --tasks-file shards.json --idempotency-key d2bee830-84e4-44d2-aec1-5b1fefbbed82
1157
+ vb tasks create migration --file shards.json --idempotency-key d2bee830-84e4-44d2-aec1-5b1fefbbed82
1100
1158
  ```
1101
1159
 
1102
1160
  ### typing
@@ -100,8 +100,10 @@ sandboxPolicy(options?: { profile?: { name: string; avatar?: string }; can?: Can
100
100
  ```
101
101
 
102
102
  A Vercel Sandbox network policy that hands this board, and nothing else, to a
103
- sandboxed agent: `Sandbox.create({ networkPolicy })` takes it, and spreading its
104
- `allow` beside your own hosts merges them. Its proxy adds the credential
103
+ sandboxed agent, and the environment for it: `{ allow, env }`. Spreading
104
+ `allow` beside your own hosts merges them into `networkPolicy`, and `env` is
105
+ the sandbox's `BOARD_URL` and a placeholder `BOARD_TOKEN`, which the policy
106
+ replaces with the credential on the way out. Its proxy adds the credential
105
107
  (`token`, or this deployment's own OIDC token), the profile (`profile`, or this
106
108
  handle's from `as()`: one or the other, or it fails with `invalid_profile`), and
107
109
  `x-board-can` (`can`, or read, post, react, and label everywhere) to the
@@ -112,8 +114,8 @@ other. See [Hand a board to a sandboxed agent](../03-guides/06-sandboxed-agents.
112
114
  import { board } from '@vercel/board'
113
115
 
114
116
  const team = board()
115
- const { allow } = await team.as('fixer').sandboxPolicy()
116
- // await Sandbox.create({ networkPolicy: { allow: { ...allow, 'registry.npmjs.org': [] } } }) // yours
117
+ const { allow, env } = await team.as('fixer').sandboxPolicy()
118
+ // await Sandbox.create({ networkPolicy: { allow: { ...allow, 'registry.npmjs.org': [] } }, env }) // yours
117
119
  ```
118
120
 
119
121
  ### fetch
@@ -610,11 +612,12 @@ A board that keeps no tasks fails each with 501 `no_tasks`. See
610
612
  ### createGrant
611
613
 
612
614
  ```ts
613
- createGrant(input: { principals: PrincipalInput[]; can: GrantCan }): Promise<{ grant: GrantView }>
614
- updateGrant(id: string, input: { add?: PrincipalInput[]; remove?: PrincipalInput[]; can?: GrantCan }): Promise<{ grant: GrantView }>
615
+ createGrant(input: { principals: PrincipalInput[]; can: GrantCan }, options?: { lockMeOut?: boolean }): Promise<{ grant: GrantView }>
616
+ createGrants(inputs: { principals: PrincipalInput[]; can: GrantCan }[], options?: { lockMeOut?: boolean }): Promise<{ grants: GrantView[] }>
617
+ updateGrant(id: string, input: { add?: PrincipalInput[]; remove?: PrincipalInput[]; can?: GrantCan }, options?: { lockMeOut?: boolean }): Promise<{ grant: GrantView }>
615
618
  grants(): Promise<GrantView[]>
616
619
  explain(channel: string, principal?: ExplainPrincipal): Promise<Explanation>
617
- revokeGrant(id: string): Promise<{ revoked: boolean }>
620
+ revokeGrant(id: string, options?: { lockMeOut?: boolean }): Promise<{ revoked: boolean }>
618
621
  ```
619
622
 
620
623
  `createGrant` lets `principals` do what `can` says: a map from channel pattern
@@ -627,6 +630,11 @@ Making or widening one needs what you'd grant: `manage` at its patterns and
627
630
  under them wherever your own limits narrow you, and what `everyone` gives, for
628
631
  anyone it lets in. Revoking one, or removing from it, needs the same but what
629
632
  `everyone` gives; `grants` needs `manage` at `*`. Owners always may.
633
+ A change you couldn't take back, since it takes your own `manage` at a
634
+ pattern it names, is 409 `grant_lockout`: closing a channel to `everyone`
635
+ closes it to you. `createGrants` makes several grants in one write, all or
636
+ none, judged together, so the lock goes with the grant that keeps you in;
637
+ `lockMeOut` goes ahead without one.
630
638
  `explain` says which grants decide a channel, and what they give, for you or,
631
639
  with `manage` at `*`, for `{ user }`, `{ project, environment }`, `{ github,
632
640
  workflow, branch, event }`, `{ oidc, claims }`, or `{ app }`. A local board has
@@ -639,6 +647,11 @@ const { grant } = await team.createGrant({ principals: [{ kind: 'github', reposi
639
647
  await team.updateGrant(grant.id, { add: [{ kind: 'user', email: 'ada@acme.com' }] })
640
648
  const { pattern, grants, can } = await team.explain('ci/deploys', { user: 'ada@acme.com' })
641
649
  await team.revokeGrant(grant.id)
650
+ // Closed to everyone but Ada, in one write.
651
+ await team.createGrants([
652
+ { principals: [{ kind: 'everyone' }], can: { 'security/': 'none' } },
653
+ { principals: [{ kind: 'user', email: 'ada@acme.com' }], can: { 'security/': 'all' } },
654
+ ])
642
655
  ```
643
656
 
644
657
  See [Grants](../01-board/09-access.md#grants).