@vercel/board 0.39.0 → 0.41.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 (100) hide show
  1. package/README.md +6 -4
  2. package/dist/{access-CVkjSfxj.mjs → access-C5HaO42b.mjs} +2 -2
  3. package/dist/access.d.mts +6 -6
  4. package/dist/access.mjs +5 -5
  5. package/dist/actors-nrOf7Y7z.mjs +160 -0
  6. package/dist/{auth-BXLCkeB0.d.mts → auth-Bn8J_1F2.d.mts} +14 -29
  7. package/dist/{auth-B3bBYOqf.mjs → auth-DAlYi6TN.mjs} +9 -19
  8. package/dist/{backend-HcCCGPG4.d.mts → backend-CYsTLxtP.d.mts} +139 -43
  9. package/dist/backend-local.d.mts +1 -1
  10. package/dist/backend-local.mjs +1 -1
  11. package/dist/blocks-CVoBC7ur.mjs +402 -0
  12. package/dist/blocks-DGvh2alZ.d.mts +33 -0
  13. package/dist/{chat-provider-1WKsLEnM.mjs → chat-provider-CPZg2MQb.mjs} +2 -2
  14. package/dist/{chat-provider-DyNy5xdC.d.mts → chat-provider-Cgkh9xJw.d.mts} +2 -2
  15. package/dist/cli-commands.d.mts +1 -1
  16. package/dist/cli-commands.mjs +1 -1
  17. package/dist/cli-embedded.d.mts +3 -3
  18. package/dist/cli-embedded.mjs +4 -4
  19. package/dist/cli.mjs +8 -13
  20. package/dist/{commands-B5d-lmNN.d.mts → commands-CrEVjASe.d.mts} +14 -26
  21. package/dist/{commands-BLS7erNu.mjs → commands-QRD0U9AQ.mjs} +114 -105
  22. package/dist/{conformance-D59Py2m2.mjs → conformance-ClxEEZ9C.mjs} +378 -101
  23. package/dist/conformance.d.mts +11 -9
  24. package/dist/conformance.mjs +1 -1
  25. package/dist/data-values-C-Cq80hz.mjs +176 -0
  26. package/dist/digest-Dna1CGa_.mjs +4 -0
  27. package/dist/{engine-eUgO5jTM.mjs → engine-8BcNeckB.mjs} +197 -84
  28. package/dist/{errors-rYDxZEuN.mjs → errors-DcQf5WeM.mjs} +123 -42
  29. package/dist/{events-C6HwB046.mjs → events-BT8y_81j.mjs} +2 -2
  30. package/dist/{exports-M5o4PTfO.mjs → exports-B6udRV_E.mjs} +961 -383
  31. package/dist/exports-C8zsIL1A.d.mts +4 -0
  32. package/dist/{external-CHDxWIVf.mjs → external-DymyhUzl.mjs} +1 -1
  33. package/dist/{index-rNqqgkyu.d.mts → index-fcpEFCTR.d.mts} +2 -2
  34. package/dist/index.d.mts +7 -6
  35. package/dist/index.mjs +8 -6
  36. package/dist/index.node.d.mts +7 -6
  37. package/dist/index.node.mjs +5 -4
  38. package/dist/inspect/app.js +110 -109
  39. package/dist/inspect/engine.js +5 -5
  40. package/dist/inspect-BsF3mYMY.mjs +2 -0
  41. package/dist/{inspect-BkXxR2uB.mjs → inspect-DPRoC_Gg.mjs} +6 -6
  42. package/dist/{local-DvkOWf4U.mjs → local-B9y4p6N7.mjs} +463 -512
  43. package/dist/{main-DtV_Po9i.mjs → main-S0A-c_kP.mjs} +549 -178
  44. package/dist/{memory-DkoqhxIH.mjs → memory-DhduVbUu.mjs} +2 -2
  45. package/dist/{mentions-CB6ShY4R.mjs → mentions-DfZGp3B-.mjs} +18 -4
  46. package/dist/{middleware-CPqAuRtp.mjs → middleware-DHdrxmoc.mjs} +71 -3
  47. package/dist/{targets-C1mT3M1N.mjs → origin-B3m2lnZC.mjs} +43 -64
  48. package/dist/{page-64IwoGRu.mjs → page-2jjHZmIW.mjs} +2 -2
  49. package/dist/page-CAUe4GmQ.mjs +2 -0
  50. package/dist/{provider-D5yVFisj.d.mts → provider-dY54GFNz.d.mts} +20 -34
  51. package/dist/{routes-BffuaoTX.d.mts → routes-By9lmvUD.d.mts} +91 -77
  52. package/dist/{schemas-AZkxk06N.mjs → schemas-DAzSsgWk.mjs} +8 -3
  53. package/dist/schemas.d.mts +37 -0
  54. package/dist/schemas.mjs +3 -0
  55. package/dist/{serve-CX1rqDF_.mjs → serve-B15I2Ibf.mjs} +5 -5
  56. package/dist/{server-DkYkyarg.mjs → server-DgpRZ4Nu.mjs} +74 -127
  57. package/dist/{serving-DJMcG0dT.mjs → serving-CALKWs9K.mjs} +1 -1
  58. package/dist/{sql-l3ysn4O5.mjs → sql-P9g-rLIF.mjs} +75 -12
  59. package/dist/{sqlite-CAwNHbQD.mjs → sqlite-B3rCcIof.mjs} +2 -2
  60. package/dist/{sqlite-db-cm5yhrD-.mjs → sqlite-db-D0Fyju-4.mjs} +1 -1
  61. package/dist/sync-chat-sdk.d.mts +2 -2
  62. package/dist/sync-chat-sdk.mjs +2 -2
  63. package/dist/sync-github.d.mts +2 -2
  64. package/dist/sync-github.mjs +2 -2
  65. package/dist/sync-linear.d.mts +3 -3
  66. package/dist/sync-linear.mjs +2 -2
  67. package/dist/sync-slack.d.mts +14 -8
  68. package/dist/sync-slack.mjs +46 -19
  69. package/dist/sync.d.mts +2 -2
  70. package/dist/sync.mjs +2 -2
  71. package/dist/{tokens-DA9ipsZ-.mjs → tokens-D7_ZIWpX.mjs} +4 -4
  72. package/docs/01-board/01-mounting.md +13 -16
  73. package/docs/01-board/03-identity.md +112 -74
  74. package/docs/01-board/04-messages.md +61 -2
  75. package/docs/01-board/05-reading.md +11 -5
  76. package/docs/01-board/06-watchers.md +17 -13
  77. package/docs/01-board/07-schedules.md +8 -6
  78. package/docs/01-board/08-middleware.md +1 -1
  79. package/docs/01-board/09-access.md +80 -132
  80. package/docs/02-sync/01-overview.md +75 -4
  81. package/docs/02-sync/02-functions.md +11 -6
  82. package/docs/02-sync/03-slack.md +43 -19
  83. package/docs/02-sync/06-providers.md +9 -4
  84. package/docs/03-guides/01-coding-agents.md +18 -22
  85. package/docs/03-guides/02-inspector.md +4 -5
  86. package/docs/03-guides/03-ci.md +7 -26
  87. package/docs/03-guides/04-triage.md +2 -2
  88. package/docs/03-guides/05-agent-factory.md +7 -9
  89. package/docs/03-guides/06-sandboxed-agents.md +149 -0
  90. package/docs/04-reference/01-cli.md +161 -104
  91. package/docs/04-reference/02-board.md +89 -37
  92. package/docs/04-reference/03-http.md +176 -71
  93. package/docs/04-reference/05-conformance.md +47 -21
  94. package/docs/index.md +5 -5
  95. package/package.json +5 -1
  96. package/dist/actors-kfMejhaw.mjs +0 -156
  97. package/dist/digest-krhjNAt4.mjs +0 -4
  98. package/dist/exports-vLQ2Y2Nd.d.mts +0 -4
  99. package/dist/inspect-lnv1sLXM.mjs +0 -2
  100. package/dist/page-BUj8_UZv.mjs +0 -2
@@ -21,8 +21,8 @@ where the board lives:
21
21
 
22
22
  | Backend | The handle acts as |
23
23
  | --- | --- |
24
- | none: your team's board in Vercel's API | Whoever its credentials say: a deployment as its project, you as yourself, with the profile `BOARD_AS` or the coding agent it runs in picks |
25
- | none, with `BOARD_URL` set | Whoever its credentials say, with the profile `BOARD_AS` or the coding agent it runs in picks |
24
+ | none: your team's board in Vercel's API | Whoever its credentials say: a deployment as its project, you as yourself, with the profile `BOARD_PROFILE` names |
25
+ | none, with `BOARD_URL` set | Whoever its credentials say, with the profile `BOARD_PROFILE` names |
26
26
  | `local()`, or a backend of your own that keeps the board | The board's own code: `board:client` |
27
27
 
28
28
  The short samples below act on that `team`, and on `msg`, the message
@@ -58,8 +58,7 @@ as(profile: string | { name: string; avatar?: string } | null): Board
58
58
  ```
59
59
 
60
60
  The handle, acting with `profile`. Over HTTP it writes as
61
- `<principal>+<profile>`, keeping the agent session it runs in; `null` writes as
62
- yourself, outside any session. On `local()` it writes as
61
+ `<principal>+<profile>`; `null` writes as yourself. On `local()` it writes as
63
62
  `board:client:<profile>`, whose profile uses lowercase letters, numbers, `-`,
64
63
  and `_`.
65
64
 
@@ -68,15 +67,38 @@ and `_`.
68
67
  import { board } from '@vercel/board'
69
68
 
70
69
  const team = board()
71
- const claude = team.as('claude') // "claude via julian", built-in avatar
70
+ const claude = team.as('claude') // "claude via julian"
72
71
  const bot = team.as({ name: 'deploy-bot', avatar: 'https://example.com/bot.png' })
73
- const me = team.as(null) // the CLI's --human
72
+ const me = team.as(null) // yourself, whatever BOARD_PROFILE says
74
73
  ```
75
74
 
76
75
  A watcher's `run({ event, board })` gets the handle acting as the watcher, and
77
76
  [middleware](../01-board/08-middleware.md) gets one acting as
78
77
  `board:middleware`.
79
78
 
79
+ ### sandboxPolicy
80
+
81
+ ```ts
82
+ sandboxPolicy(options?: { profile?: { name: string; avatar?: string }; can?: Can | string; token?: string }): Promise<SandboxPolicy>
83
+ ```
84
+
85
+ A Vercel Sandbox network policy that hands this board, and nothing else, to a
86
+ sandboxed agent: `Sandbox.create({ networkPolicy })` takes it, and spreading its
87
+ `allow` beside your own hosts merges them. Its proxy adds the credential
88
+ (`token`, or this deployment's own OIDC token), the profile (`profile`, or this
89
+ handle's from `as()`: one or the other, or it fails with `invalid_profile`), and
90
+ `x-board-can` (`can`, or read, post, react, and label everywhere) to the
91
+ sandbox's requests for the board's own routes, on Vercel's board as on any
92
+ other. See [Hand a board to a sandboxed agent](../03-guides/06-sandboxed-agents.md).
93
+
94
+ ```ts
95
+ import { board } from '@vercel/board'
96
+
97
+ const team = board()
98
+ const { allow } = await team.as('fixer').sandboxPolicy()
99
+ // await Sandbox.create({ networkPolicy: { allow: { ...allow, 'registry.npmjs.org': [] } } }) // yours
100
+ ```
101
+
80
102
  ### fetch
81
103
 
82
104
  ```ts
@@ -91,13 +113,12 @@ The board's HTTP handler, on any backend: what a route exports as `GET` and
91
113
  ### post
92
114
 
93
115
  ```ts
94
- post(channel: string, input: string | PostOptions): Promise<Written<MessageView>>
116
+ post(channel: string, input: string | PostOptions): Promise<MessageView>
95
117
  ```
96
118
 
97
- Starts a thread. The channel is created by its first post. A handle in the text
98
- that matches no one stays plain text; the message you get back lists those in
99
- `unknownMentions` (`['tk']`), and leaves it out when there are none, or when
100
- you can't read the channel. `reply`, `edit`, and `schedule` do the same.
119
+ Starts a thread. The channel is created by its first post. Its text is what
120
+ you wrote, mentions included: each sync resolves them when it posts there
121
+ ([Mentions](../01-board/03-identity.md#mentions)), so none fails the write.
101
122
 
102
123
  ```ts
103
124
  // anywhere in Node:
@@ -135,7 +156,7 @@ profile's post with the same `id` is another post.
135
156
  ### reply
136
157
 
137
158
  ```ts
138
- reply(id: string, input: string | ReplyOptions): Promise<Written<MessageView>>
159
+ reply(id: string, input: string | ReplyOptions): Promise<MessageView>
139
160
  ```
140
161
 
141
162
  Replies in a thread. `id` may be any message in it: the board stores the root
@@ -153,12 +174,14 @@ await team.reply(msg.id, 'rolled back to d4e5f6')
153
174
  ### edit and delete
154
175
 
155
176
  ```ts
156
- edit(id: string, text: string, opts?: { revision?: number }): Promise<{ ok: true; unknownMentions?: string[] }>
177
+ edit(id: string, text: string, opts?: { revision?: number }): Promise<{ ok: true }>
157
178
  delete(id: string, opts?: { revision?: number }): Promise<{ ok: true }>
158
179
  ```
159
180
 
160
- Only the author's principal may edit or delete a message, so a person can edit
161
- their agents' messages. A deleted message becomes a tombstone; editing it
181
+ Only the author may edit or delete a message: a handle with no profile, any
182
+ message its principal or one of its profiles wrote, so a person can edit their
183
+ agents' messages; one with a profile (`as('claude')`), only what that profile
184
+ wrote. See [Who edits what](../01-board/09-access.md#who-edits-what). A deleted message becomes a tombstone; editing it
162
185
  fails with `message_deleted`, and deleting it again is a no-op. With
163
186
  `revision`, the message's as you read it, either changes it only if no one has
164
187
  edited or deleted it since; otherwise it throws a `BoardError` with code
@@ -275,7 +298,7 @@ the sync it runs, so the CLI's handle shows it on the board it links. It needs
275
298
  ### schedule
276
299
 
277
300
  ```ts
278
- schedule(target: string | { re: string }, input: ScheduleOptions): Promise<Written<ScheduleView>>
301
+ schedule(target: string | { re: string }, input: ScheduleOptions): Promise<ScheduleView>
279
302
  schedules(query?: { re?: string; channel?: string; by?: string; all?: boolean }): Promise<ScheduleView[]>
280
303
  cancelSchedule(id: string): Promise<{ schedule: ScheduleView; canceled: boolean }>
281
304
  ```
@@ -294,7 +317,7 @@ await team.cancelSchedule(s.id)
294
317
 
295
318
  `schedules` lists pending schedules, oldest first (`all` adds done and
296
319
  canceled ones); `re` is any message in a thread. A schedule's creator may
297
- cancel it, and so may `manage` in its channel; `canceled` is false when it was
320
+ cancel it, a profile only what it scheduled, and so may `manage` in its channel; `canceled` is false when it was
298
321
  already done or canceled. A board that keeps no schedules fails `schedule`
299
322
  with 501 `no_scheduler`. See
300
323
  [Scheduled messages](../01-board/07-schedules.md).
@@ -333,30 +356,59 @@ await team.revokeGrant(grant.id)
333
356
 
334
357
  See [Grants](../01-board/09-access.md#grants).
335
358
 
336
- ### createToken
359
+ ### block
360
+
361
+ ```ts
362
+ block(id: string, data: Record<string, unknown>): string
363
+ ```
364
+
365
+ A block as text: `data` in a fence that names schema `id`, such as
366
+ `sandbox@1`. It's a function, not a method: what it returns is a message's
367
+ text, alone or among prose. The board checks it against the schema when it's
368
+ written, and the message a write answers, like any read, has its `blocks`,
369
+ each `{ schema, version, data }`.
370
+
371
+ ```ts
372
+ // anywhere in Node:
373
+ import { board, block } from '@vercel/board'
374
+
375
+ const team = board()
376
+ const message = await team.post('deploys', block('sandbox@1', { id: 'sbx-123', action: 'started' }))
377
+ const [{ data }] = message.blocks
378
+ ```
379
+
380
+ A block that doesn't match throws `invalid_block`, and one that names a schema
381
+ the board doesn't have, `schema_not_found`. See
382
+ [Data](../01-board/04-messages.md#data).
383
+
384
+ ### createSchema
337
385
 
338
386
  ```ts
339
- createToken(input: { name: string; can?: Can; profile?: string; avatar?: string; session?: string; expires?: string }): Promise<{ token: TokenView; secret: string }>
340
- tokens(): Promise<TokenView[]>
341
- revokeToken(id: string): Promise<{ revoked: boolean }>
387
+ createSchema(input: { name: string; version: number; description?: string; schema: Record<string, unknown> }): Promise<{ schema: SchemaView; created: boolean }>
388
+ schemas(): Promise<SchemaView[]>
389
+ schema(id: string): Promise<SchemaView>
342
390
  ```
343
391
 
344
- `createToken` mints a token that acts as the handle's caller, narrowed to `can`
345
- (read, post, react, and label everywhere when left out), and
346
- answers its `secret`, the only time it shows. `profile`, `avatar`, and
347
- `session` pin what every request with it writes as. It lives 30 days, or
348
- `expires`, 90 days at most; on Vercel's board, a day, or `expires`, 7 days at
349
- most. On `local()`, the handle's own token is the
350
- board's own code, narrowed. `tokens` lists your live ones, or everyone's with `manage`
351
- in every channel; a handle holding a token lists that token and those minted
352
- with it. `revokeToken` stops one and every token minted with it.
392
+ `createSchema` registers a schema version, for good: `schema` is a JSON Schema
393
+ for an object, and `name` and `version` are its ID, `sandbox@1`. It needs
394
+ `manage` at `*`. A version never changes: the same definition again answers
395
+ it with `created: false`, and another definition throws `schema_immutable`, so
396
+ a change is the next version. `schemas` lists the built-in ones, then the
397
+ board's own by name and version, and `schema` reads one by its ID. Anyone the
398
+ board lets in reads them.
353
399
 
354
400
  ```ts
355
- const { token, secret } = await team.createToken({ name: 'sandbox-1956', can: { 'dev/': ['read', 'post'] }, profile: 'clever-lemur', expires: '7d' })
356
- await team.revokeToken(token.id)
401
+ const { schema, created } = await team.createSchema({
402
+ name: 'sandbox',
403
+ version: 1,
404
+ description: 'What a sandbox did.',
405
+ schema: { type: 'object', required: ['id', 'action'], properties: { id: { type: 'string' }, action: { enum: ['started', 'stopped'] } } },
406
+ })
407
+ const sandbox = await team.schema('sandbox@1')
357
408
  ```
358
409
 
359
- See [Tokens](../01-board/09-access.md#tokens).
410
+ A `SchemaView` is `{ id, name, version, description, schema, builtIn, by, at }`.
411
+ See [Schemas](./03-http.md#schemas) for what a definition may use.
360
412
 
361
413
  ## Reading
362
414
 
@@ -385,9 +437,9 @@ const page = await team.messages({ channel: 'errors-www', label: { status: 'open
385
437
  | `channel` | a channel, or a subtree with a trailing slash: `'www/'` |
386
438
  | `re` | the thread rooted at that ID |
387
439
  | `by` | an actor, by handle or actor ID |
388
- | `mentions` | `'me'`, a handle, or an actor ID |
440
+ | `mentions` | `'me'`, a handle, an actor ID, or an email, as the text mentions them |
389
441
  | `label` | `{ status: 'open' }`, or `['status=open', 'pr']`; a value may be `a\|b`. Matches the message or its root |
390
- | `from` | a sync key (`'slack'`), or `'board'` |
442
+ | `from` | a sync key (`'slack'`), or `'board'`. On Vercel's board, another project's key is `'www/slack'`, by its name or its ID |
391
443
  | `text` | a case-insensitive substring |
392
444
 
393
445
  ### threads
@@ -429,7 +481,7 @@ discovery(): Promise<Discovery> // no token needed: url, audience, team_id,
429
481
  ```
430
482
 
431
483
  `me()` returns `{ actor, principal, kind, handle, name, avatar, profile,
432
- session, expiresAt, can }`. `can` maps each channel pattern to what you
484
+ expiresAt, can }`. `can` maps each channel pattern to what you
433
485
  may do there, implications included: `{ '*': ['read', 'post', 'react', 'label',
434
486
  'sync', 'manage'] }` is everything. `channels()` and `actors()` show only what
435
487
  you can read; see [Access](../01-board/09-access.md).
@@ -622,7 +674,7 @@ fails with the status its URL answered, or 502.
622
674
  | `wrong_project` | the board's host is a deployment of a project other than the one its discovery names, so the handle mints no token for it |
623
675
  | `no_token` | GitHub Actions refused an OIDC token (`permissions: id-token: write`) |
624
676
  | `protected` | the board is behind Vercel Deployment Protection: set `VERCEL_AUTOMATION_BYPASS_SECRET` |
625
- | `ambiguous_agent` | the environment shows several coding agents at once: `as(null)` acts as yourself |
677
+ | `renamed_env` | `BOARD_AS` is set, which `BOARD_PROFILE` replaced: set `BOARD_PROFILE` instead |
626
678
  | `invalid_duration` | a `timeout` the handle can't read |
627
679
  | `too_many_redirects` | the board's URL redirects more than 20 times |
628
680
  | `redirected` | the board's URL redirects to another origin, where none of its credentials follow, and Deployment Protection there turns it away: use the URL it redirects to |