@openmuster/muster 0.0.0-stage → 0.3.1-alpha.2

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 (75) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +309 -2
  3. package/dist/args-DHgAmYge.js +7043 -0
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +31 -0
  6. package/dist/index.d.ts +2138 -0
  7. package/dist/index.js +1938 -0
  8. package/dist/inspect/app.js +163 -0
  9. package/dist/main-A4nHL5oa.js +3941 -0
  10. package/dist/main-CuIC8iF4.js +6 -0
  11. package/dist/mcp-GkdeWAnr.js +6 -0
  12. package/dist/module-CT_R33MB.js +4 -0
  13. package/dist/module-DOkWwWoU.js +439 -0
  14. package/dist/skills/board/SKILL.md +214 -0
  15. package/dist/skills/board/references/build-a-ui.md +63 -0
  16. package/dist/skills/board/references/claude.md +54 -0
  17. package/dist/skills/board/references/codex.md +61 -0
  18. package/dist/skills/board/references/software-factory.md +89 -0
  19. package/dist/skills/board/references/swarm.md +165 -0
  20. package/dist/skills/configure-factory/SKILL.md +116 -0
  21. package/dist/skills/loop-card/SKILL.md +95 -0
  22. package/dist/steps-ByzmEzLQ.js +3175 -0
  23. package/docs/01-concepts/01-overview.md +73 -0
  24. package/docs/01-concepts/02-boards.md +71 -0
  25. package/docs/01-concepts/03-channels.md +56 -0
  26. package/docs/01-concepts/04-threads.md +75 -0
  27. package/docs/01-concepts/05-labels.md +65 -0
  28. package/docs/01-concepts/06-actors.md +66 -0
  29. package/docs/01-concepts/07-events.md +126 -0
  30. package/docs/01-concepts/08-tasks.md +244 -0
  31. package/docs/01-concepts/09-watchers.md +172 -0
  32. package/docs/01-concepts/10-schedules.md +39 -0
  33. package/docs/01-concepts/11-access.md +182 -0
  34. package/docs/01-concepts/12-files-and-data.md +79 -0
  35. package/docs/01-concepts/13-budgets.md +35 -0
  36. package/docs/01-concepts/14-runners.md +102 -0
  37. package/docs/01-concepts/15-outgoing-webhooks.md +177 -0
  38. package/docs/01-concepts/16-workflows.md +350 -0
  39. package/docs/01-concepts/17-board-module.md +122 -0
  40. package/docs/01-quickstart.md +141 -0
  41. package/docs/02-sync/01-overview.md +239 -0
  42. package/docs/02-sync/02-github.md +158 -0
  43. package/docs/02-sync/03-linear.md +290 -0
  44. package/docs/02-sync/04-slack.md +232 -0
  45. package/docs/02-sync/05-notion.md +92 -0
  46. package/docs/03-guides/01-coding-agents.md +98 -0
  47. package/docs/03-guides/02-swarm.md +85 -0
  48. package/docs/03-guides/03-factory.md +216 -0
  49. package/docs/03-guides/04-inspector.md +53 -0
  50. package/docs/03-guides/05-running-agents.md +73 -0
  51. package/docs/03-guides/06-sandboxed-agents.md +441 -0
  52. package/docs/03-guides/07-build-a-ui.md +61 -0
  53. package/docs/03-guides/08-ci.md +168 -0
  54. package/docs/03-guides/09-daemon.md +103 -0
  55. package/docs/03-guides/10-two-agents.md +76 -0
  56. package/docs/03-guides/11-person-in-the-loop.md +123 -0
  57. package/docs/03-guides/12-unattended.md +110 -0
  58. package/docs/03-guides/13-terminals.md +153 -0
  59. package/docs/03-guides/14-no-cloud.md +82 -0
  60. package/docs/03-guides/15-several-boards.md +71 -0
  61. package/docs/03-guides/16-non-code.md +69 -0
  62. package/docs/03-guides/17-mcp.md +126 -0
  63. package/docs/03-guides/18-a-board-on-a-server.md +162 -0
  64. package/docs/03-guides/19-a-card-queue.md +261 -0
  65. package/docs/03-guides/20-a-feedback-loop.md +225 -0
  66. package/docs/03-guides/21-running-the-loop.md +196 -0
  67. package/docs/04-reference/01-cli.md +166 -0
  68. package/docs/04-reference/02-handle.md +409 -0
  69. package/docs/04-reference/03-http.md +157 -0
  70. package/docs/04-reference/04-events.md +72 -0
  71. package/docs/04-reference/05-errors.md +221 -0
  72. package/docs/04-reference/06-conformance.md +52 -0
  73. package/docs/04-reference/07-porting.md +116 -0
  74. package/docs/index.md +103 -0
  75. package/package.json +52 -3
@@ -0,0 +1,2138 @@
1
+ import { DatabaseSync } from "node:sqlite";
2
+ import { IncomingMessage, Server, ServerResponse } from "node:http";
3
+
4
+ //#region src/store/sqlite.d.ts
5
+
6
+ /** An open board file. */
7
+ type Db = {
8
+ readonly raw: DatabaseSync;
9
+ readonly path: string;
10
+ /** Runs `fn` in one write transaction. Only BEGIN and COMMIT are retried when busy: `fn` runs once. */
11
+ write<T$1>(fn: () => T$1): T$1;
12
+ close(): void;
13
+ };
14
+ //#endregion
15
+ //#region src/model.d.ts
16
+ /** Who a request is from, as the policy verified it. A request body never says. */
17
+ type Caller = {
18
+ /** `local:user:ada`, `token:<subject>`, a platform author under sync. */
19
+ principal: string;
20
+ /** Which of the principal's agents this is, or null for the principal itself. */
21
+ profile: string | null;
22
+ /** What it may do, by channel pattern. Absent means everything (file mode, or a full token). */
23
+ can?: Record<string, readonly Permission[]>;
24
+ /** The ID of the token it came with, where it has one: what a schedule is tied to, so stopping the token stops what it set going. */
25
+ token?: string;
26
+ /** What a narrowed token's allowance is counted against: something the token carries, never a name the request chose. */
27
+ meter?: string;
28
+ /** The private channels, as the board knows them: a narrowed caller reaches one only by its exact name. */
29
+ privates?: readonly string[];
30
+ /** What this caller writes never leaves the board for a synced platform. Set by its token, not by a request. */
31
+ noSync?: true;
32
+ /** Its profile is the one its token is held to, not one the request named. Set by the server, never by a request. */
33
+ profileHeld?: true;
34
+ };
35
+ type Permission = 'read' | 'post' | 'react' | 'label' | 'manage';
36
+ type By = {
37
+ principal: string;
38
+ profile: string | null;
39
+ };
40
+ type Attachment = {
41
+ id: string;
42
+ name: string;
43
+ type: string;
44
+ size: number;
45
+ };
46
+ type Message = {
47
+ id: number;
48
+ channel: string;
49
+ thread: number;
50
+ re: number | null;
51
+ replyTo: number | null;
52
+ by: By;
53
+ text: string;
54
+ labels: Record<string, string>;
55
+ reactions: Record<string, string[]>;
56
+ attachments: Attachment[];
57
+ /** The typed data in its text, parsed. */
58
+ blocks: {
59
+ schema: string;
60
+ data: unknown;
61
+ }[];
62
+ revision: number;
63
+ deleted: boolean;
64
+ noSync: boolean;
65
+ at: string;
66
+ editedAt: string | null;
67
+ };
68
+ type BoardEvent = {
69
+ seq: number;
70
+ at: string;
71
+ type: string;
72
+ by: By;
73
+ channel: string | null;
74
+ thread: number | null;
75
+ data: Record<string, unknown>;
76
+ };
77
+ //#endregion
78
+ //#region src/core/context.d.ts
79
+ /** What every operation gets: the open file, the clock, and a way to check whether a process lives. */
80
+ type Context = {
81
+ db: Db;
82
+ now: () => Date;
83
+ /** Whether the process a claim recorded is still the one running. Injected in tests. */
84
+ alive: (pid: number, start: string) => boolean;
85
+ };
86
+ /**
87
+ * How a repeat with the same idempotency key is compared with the first. `exact` (the default): the
88
+ * whole request, so a key used for something else is refused. `shape`: only what the write is and
89
+ * where it lands (a reply and its thread, a label and its message), so a retry whose text came out
90
+ * differently gets the first answer, and one that writes somewhere else is still refused. A watcher's
91
+ * own writes are keyed this way.
92
+ */
93
+ type IdempotencyMatch = 'exact' | 'shape';
94
+ //#endregion
95
+ //#region src/sync/types.d.ts
96
+ /** What a platform sent, as the parts a provider needs to check and read it. */
97
+ type Received = {
98
+ headers: Record<string, string | undefined>;
99
+ body: string;
100
+ };
101
+ /** One thing that happened on a platform, in board terms. */
102
+ type Inbound = {
103
+ /** The platform's own ID for this event: importing it twice does nothing. */
104
+ id: string;
105
+ /** The platform thing the board thread mirrors: an issue, a Slack thread. */
106
+ thread: string;
107
+ /** This message's own ID on the platform. */
108
+ external: string;
109
+ /** Who wrote it there. Empty when the platform doesn't say: the change is then put down to the sync itself. */
110
+ author: string;
111
+ /** Where on the platform it happened: a repo, a team, a channel. Mapped to a board channel by config. */
112
+ place: string;
113
+ kind: 'root' | 'reply' | 'labels' | 'edit' | 'delete';
114
+ text?: string;
115
+ labels?: Record<string, string>;
116
+ /** Label keys to take off the thread: a property the platform thread no longer has, such as its priority. */
117
+ unset?: string[];
118
+ /**
119
+ * Key prefixes under which the thread says what the platform says (`tag.`, `assignee.`): a key under one
120
+ * that `labels` doesn't carry is taken off. An event names a prefix only when it carries the whole set.
121
+ */
122
+ owns?: string[];
123
+ /**
124
+ * When the platform says it changed, for a `labels` event read on catching up: a label the board has changed
125
+ * since then is newer than it, and is left as it is.
126
+ */
127
+ at?: string;
128
+ /**
129
+ * When the platform says the thing this event is about (an issue, a comment) last changed, as its own clock has
130
+ * it: Linear's `updatedAt`. An update or an edit no newer than the newest one applied to the same thing is late
131
+ * (a retry, or one held up) and is skipped. Without it, an event is applied in the order it arrived.
132
+ */
133
+ updated?: string;
134
+ /**
135
+ * A platform whose webhooks say only what changed, not what it now says (Notion's), marks the event `unread`:
136
+ * its provider's `read` fills it in on the ticker, before it is imported, while the webhook was answered at once.
137
+ */
138
+ unread?: true;
139
+ /** Whether the app itself wrote it: its own echoes are never imported. */
140
+ self?: boolean;
141
+ /**
142
+ * The platform thread itself, when the event is about one the board may never have seen (a comment on
143
+ * an issue opened before sync, or while the board was down). The board starts the thread from it first. An
144
+ * empty `author` is a platform that doesn't say who opened it: the thread is put down to the sync itself.
145
+ */
146
+ parent?: {
147
+ author: string;
148
+ text: string;
149
+ labels: Record<string, string>;
150
+ };
151
+ /** Files the message carries on the platform, still to be fetched. Never holds a credential. */
152
+ files?: Remote[];
153
+ /** What fetching them gave: files on the board, and a line for each one that was not taken. */
154
+ fetched?: {
155
+ attachments: Attachment[];
156
+ notes: string[];
157
+ tries: number;
158
+ withheld?: number;
159
+ };
160
+ };
161
+ /** How many bytes a file may have, and what to say when it has more. */
162
+ type Limit = {
163
+ max: number;
164
+ over: string;
165
+ };
166
+ /** A file on the platform, as an event names it. `id` is the platform's own, when it has one. */
167
+ type Remote = {
168
+ url: string;
169
+ name: string;
170
+ id?: string;
171
+ type?: string;
172
+ size?: number;
173
+ skip?: string;
174
+ };
175
+ /**
176
+ * What a platform made of a board message. A new thread also says what an imported one would carry as
177
+ * labels (which issue it became, its kind, its state), so a thread started on the board reads like one
178
+ * that came in.
179
+ */
180
+ type Delivery$1 = {
181
+ external: string;
182
+ thread?: string;
183
+ labels?: Record<string, string>;
184
+ files?: string[];
185
+ };
186
+ /** A board file's bytes, for a provider sending it out: null when the board no longer has it. */
187
+ type ReadFile = (id: string) => Buffer | null;
188
+ /** A platform: how to check that a webhook is its own, read it, and send a message back. */
189
+ type Provider = ProviderExtras & {
190
+ type: string;
191
+ /** Throws unless the request carries the platform's signature for this body. */
192
+ verify(received: Received): void;
193
+ /** A webhook that is the platform checking the URL, answered at once. */
194
+ challenge?(received: Received): string | null;
195
+ parse(received: Received): Inbound[];
196
+ /** The board channel a place maps to, or null when it isn't synced. */
197
+ channelFor(place: string, kind: string): string | null;
198
+ /** The platform place a board channel mirrors to, for a thread started on the board, or null. */
199
+ placeFor(channel: string): string | null;
200
+ /** Whether board replies in a synced thread go back to the platform. */
201
+ mirrors(place: string): boolean;
202
+ /** Posts a board message on the platform. `threadExternal` is null for a new root. */
203
+ deliver(message: Message, target: {
204
+ place: string;
205
+ threadExternal: string | null;
206
+ }, fetcher: typeof fetch, read: ReadFile): Promise<Delivery$1>;
207
+ };
208
+ /** What a provider may also do. Each is optional: a platform that can't simply doesn't. */
209
+ type ProviderExtras = {
210
+ /** Changes a message the board delivered earlier. Best effort: a failure is skipped. */
211
+ update?(external: string, text: string, place: string, fetcher: typeof fetch): Promise<void>;
212
+ /** Removes a message the board delivered earlier. Best effort. */
213
+ remove?(external: string, place: string, fetcher: typeof fetch): Promise<void>;
214
+ /**
215
+ * What happened on the platform since a time, for when webhooks were missed while the board was down. A read
216
+ * cut short also says where the next one starts (`resume`), so what it didn't reach is read then, not skipped.
217
+ * `resume` must be later than `since`. If getting there meant going past changes it couldn't read, `skipped`
218
+ * says when they were made.
219
+ */
220
+ catchUp?(since: string, fetcher: typeof fetch): Promise<Inbound[] | {
221
+ events: Inbound[];
222
+ resume: string;
223
+ skipped?: string;
224
+ }>;
225
+ /** Bytes of files this sync may bring in a day, from the operator's config. */
226
+ filesPerDay?: number;
227
+ /** Fetches a file an event named, from the platform's own file host only. Throws a Failure: `file_refused` is final. */
228
+ download?(file: Remote, fetcher: typeof fetch, limit: Limit): Promise<{
229
+ bytes: Buffer;
230
+ type?: string;
231
+ }>;
232
+ /**
233
+ * Reads what an `unread` event is about from the platform: the events to import in its place, none to drop it.
234
+ * Runs on the ticker; a throw is tried again on a later tick, a few times.
235
+ */
236
+ read?(event: Inbound, fetcher: typeof fetch): Promise<Inbound[]>;
237
+ /** Runs on text as it comes in: returns what to keep, or null to drop the event. From the operator's config. */
238
+ filter?(text: string): string | null;
239
+ /**
240
+ * Shows on the platform that a synced thread is being worked on, where the platform has a way to show it
241
+ * that isn't a message. Called when the work starts, when what it says changed (`text`), every `workingTtl`
242
+ * while it goes on (`refresh`), and when it ends. `now.text` is the progress message as it reads; `now.state`
243
+ * is whatever the last call for this thread returned (null on the first), kept for it across restarts: what
244
+ * the platform gave to find the same indicator again. A provider with this gets no comment for a progress
245
+ * message: the indicator is how the platform shows it. Best effort: a throw is tried again in a while.
246
+ */
247
+ working?(target: {
248
+ place: string;
249
+ threadExternal: string;
250
+ }, step: WorkingStep, now: {
251
+ text: string;
252
+ state: unknown;
253
+ }, fetcher: typeof fetch): Promise<unknown>;
254
+ /** How long the platform keeps showing it without being told again, in milliseconds. None: until it is told to stop. */
255
+ workingTtl?: number;
256
+ };
257
+ /** Why `working` is called: see there. */
258
+ type WorkingStep = 'start' | 'text' | 'refresh' | 'end';
259
+ //#endregion
260
+ //#region src/sync/engine.d.ts
261
+ type Sync = Record<string, Provider>;
262
+ //#endregion
263
+ //#region src/serve/token.d.ts
264
+ type Claims = {
265
+ /** The principal the token speaks for. */
266
+ sub: string;
267
+ /** The profile it is held to. Null lets the bearer name one per request. */
268
+ profile: string | null;
269
+ /** What it may do, by channel pattern. Absent means everything. */
270
+ can?: Record<string, Permission[]>;
271
+ /** When it stops working, in seconds since the epoch. */
272
+ exp: number;
273
+ /** Its ID in the board's list of tokens, by which it can be stopped. Absent on tokens from before there was one. */
274
+ jti?: string;
275
+ /** It was made over HTTP from another token, so it can't make more. */
276
+ minted?: true;
277
+ /** What its bearer writes stays on the board, whatever the request says. */
278
+ noSync?: true;
279
+ /** It was made for an agent in a sandbox: it calls the routes a sandbox may, and no others. */
280
+ sandbox?: true;
281
+ };
282
+ /**
283
+ * The key a board's tokens are signed with. It is made once and kept, so a restart of `mu serve`
284
+ * doesn't strand every client holding a token.
285
+ */
286
+ declare function boardKey(where: string, dir?: string): Buffer;
287
+ declare function mint(key: Buffer, claims: Claims): string;
288
+ /** The claims of a token this board signed and that hasn't run out. Anything else is refused the same way. */
289
+ declare function verify(key: Buffer, token: string | undefined, now: number): Claims;
290
+ //#endregion
291
+ //#region src/serve/tokens.d.ts
292
+ /** What the board remembers of a token it made: enough to list it and to stop it, never the token itself. */
293
+ type TokenRecord = {
294
+ id: string;
295
+ profile: string | null;
296
+ can: Record<string, Permission[]> | null;
297
+ exp: number;
298
+ at: number;
299
+ revoked: boolean;
300
+ };
301
+ /** The tokens a board has made. */
302
+ type Registry = {
303
+ record(token: TokenRecord): void;
304
+ revoke(id: string): boolean;
305
+ /** Whether a token with this ID is to be refused: it was stopped, or the board has no record of making it. */
306
+ revoked(id: string): boolean;
307
+ /** Whether the board's owner stopped this token. One that only ran out wasn't stopped. */
308
+ stopped(id: string): boolean;
309
+ list(now: number): TokenRecord[];
310
+ };
311
+ type MintRequest = {
312
+ profile?: string | null;
313
+ can?: Record<string, string[]>;
314
+ ttl: number;
315
+ noSync?: boolean;
316
+ sandbox?: boolean;
317
+ };
318
+ //#endregion
319
+ //#region src/core/blocks.d.ts
320
+ /** Data a message carries beside its text: a fenced block that names the schema it follows. */
321
+ type Block = {
322
+ schema: string;
323
+ data: unknown;
324
+ };
325
+ /** Registers a schema under a name and a version. It never changes after: a new shape is a new version. */
326
+ declare function schemaAdd(ctx: Context, caller: Caller, request: {
327
+ name: string;
328
+ schema: unknown;
329
+ }): {
330
+ name: string;
331
+ created: boolean;
332
+ };
333
+ declare function schemaList(ctx: Context): {
334
+ schemas: {
335
+ name: string;
336
+ schema: unknown;
337
+ }[];
338
+ };
339
+ //#endregion
340
+ //#region src/serve/joins.d.ts
341
+ /**
342
+ * Asking to join a served board. An agent with no token asks under the name it wants; the board's owner
343
+ * sees the request and its code, approves it with the channels the agent gets, and the agent picks up a
344
+ * token made for it. Only the agent that asked can pick it up: it holds a secret the board keeps only a
345
+ * hash of. Nothing is decided by the request: the owner names what the token may do.
346
+ */
347
+ /** What the owner sees of a request. */
348
+ type JoinRecord = {
349
+ code: string;
350
+ profile: string;
351
+ note: string | null;
352
+ at: number;
353
+ expires: number;
354
+ state: 'pending' | 'approved' | 'denied';
355
+ };
356
+ type Joins = {
357
+ ask(request: {
358
+ profile: string;
359
+ note?: string;
360
+ }): {
361
+ code: string;
362
+ secret: string;
363
+ expires: number;
364
+ };
365
+ list(): JoinRecord[];
366
+ /** Records the owner's answer: a token for the agent to pick up, or a refusal. */
367
+ answer(code: string, token: string | null): JoinRecord;
368
+ /** What the agent that asked gets: still waiting, its token (once), or a refusal. */
369
+ poll(code: string, secret: string): {
370
+ state: 'pending';
371
+ } | {
372
+ state: 'approved';
373
+ token: string;
374
+ } | {
375
+ state: 'denied';
376
+ };
377
+ /** The request behind a code, for the owner to approve: refused when it is gone or answered. */
378
+ pending(code: string): JoinRecord;
379
+ };
380
+ //#endregion
381
+ //#region src/core/deliveries.d.ts
382
+ /**
383
+ * Where a watcher stands with the events above its cursor: those it has delivered, and those it is
384
+ * trying, with how many tries they have had and when the next is due. Bookkeeping like cursors and
385
+ * leases: not in the log, and pruned as the cursor passes.
386
+ */
387
+ type Delivery = {
388
+ seq: number;
389
+ lane: string;
390
+ attempts: number;
391
+ retryAt: number;
392
+ done: boolean;
393
+ };
394
+ /** The lease a watcher's host holds: each write below checks it, so a host that lost it records nothing. */
395
+ type Fence = {
396
+ name: string;
397
+ holder: string;
398
+ epoch: number;
399
+ };
400
+ /** The rows above `after`, and the board's clock, which every deadline here is measured on. */
401
+ declare function read(c: Context, request: {
402
+ watcher: string;
403
+ after: number;
404
+ }): {
405
+ rows: Delivery[];
406
+ now: number;
407
+ };
408
+ /**
409
+ * Counts a try before it is made, and says when the next may be: so a run that takes its host down with
410
+ * it still counts, and a crash can't retry one event for ever.
411
+ */
412
+ declare function begin(c: Context, request: {
413
+ watcher: string;
414
+ seq: number;
415
+ lane: string;
416
+ fence: Fence;
417
+ }): {
418
+ held: false;
419
+ } | {
420
+ held: true;
421
+ attempts: number;
422
+ };
423
+ /** Marks events delivered, or never to be: one a watcher gave up on, its note about it, events a later one stood for. */
424
+ declare function finish(c: Context, request: {
425
+ watcher: string;
426
+ seqs: number[];
427
+ fence: Fence;
428
+ }): {
429
+ held: boolean;
430
+ };
431
+ /** Moves the watcher's cursor up to `to`, everything at or below it delivered, and forgets the rows it passed. */
432
+ declare function advance(c: Context, caller: Caller, request: {
433
+ watcher: string;
434
+ to: number;
435
+ fence: Fence;
436
+ }): {
437
+ held: boolean;
438
+ };
439
+ //#endregion
440
+ //#region src/core/files.d.ts
441
+ /** Stores a file and returns the record a message carries. The same bytes stored twice are one file. */
442
+ declare function filePut(ctx: Context, caller: Caller, request: {
443
+ name: string;
444
+ type?: string;
445
+ data: string;
446
+ }): Attachment;
447
+ /** A file, for a caller who can read the message that carries it. A file's ID alone opens nothing. */
448
+ declare function fileGet(ctx: Context, caller: Caller, request: {
449
+ message: number;
450
+ id: string;
451
+ }): Attachment & {
452
+ data: string;
453
+ };
454
+ //#endregion
455
+ //#region src/core/leases.d.ts
456
+ /** Taken: the role is yours until `expires` unless renewed. Not taken: who has it, and until when. */
457
+ type Taken = {
458
+ held: true;
459
+ epoch: number;
460
+ expires: number;
461
+ } | {
462
+ held: false;
463
+ holder: string;
464
+ epoch: number;
465
+ expires: number;
466
+ };
467
+ /** Who holds `name` now, if anyone: a lapsed or released lease reads as nobody's. */
468
+ declare function holder(c: Context, name: string): {
469
+ holder: string;
470
+ epoch: number;
471
+ expires: number;
472
+ } | null;
473
+ //#endregion
474
+ //#region src/core/messages.d.ts
475
+ type PostRequest = {
476
+ channel: string;
477
+ text: string;
478
+ labels?: Record<string, string>;
479
+ attachments?: Attachment[];
480
+ noSync?: boolean;
481
+ idempotencyKey?: string;
482
+ idempotencyMatch?: IdempotencyMatch;
483
+ };
484
+ type ReplyRequest = {
485
+ to: number;
486
+ text: string;
487
+ /** Post only if nothing landed in the thread after this message. */
488
+ after?: number;
489
+ labels?: Record<string, string>;
490
+ attachments?: Attachment[];
491
+ noSync?: boolean;
492
+ idempotencyKey?: string;
493
+ idempotencyMatch?: IdempotencyMatch;
494
+ };
495
+ declare function post(ctx: Context, caller: Caller, request: PostRequest): Message;
496
+ declare function reply(ctx: Context, caller: Caller, request: ReplyRequest): Message;
497
+ declare function edit(ctx: Context, caller: Caller, request: {
498
+ id: number;
499
+ text: string;
500
+ ifRevision?: number;
501
+ idempotencyKey?: string;
502
+ idempotencyMatch?: IdempotencyMatch;
503
+ }): Message;
504
+ declare function remove(ctx: Context, caller: Caller, request: {
505
+ id: number;
506
+ ifRevision?: number;
507
+ idempotencyKey?: string;
508
+ idempotencyMatch?: IdempotencyMatch;
509
+ }): Message;
510
+ type LabelRequest = {
511
+ id: number;
512
+ set?: Record<string, string>;
513
+ unset?: string[];
514
+ /** Change only if these labels have these values now. */
515
+ if?: Record<string, string>;
516
+ /** Change only if these keys are unset now. */
517
+ ifUnset?: string[];
518
+ idempotencyKey?: string;
519
+ idempotencyMatch?: IdempotencyMatch;
520
+ };
521
+ declare function label(ctx: Context, caller: Caller, request: LabelRequest): Message;
522
+ declare function react(ctx: Context, caller: Caller, request: {
523
+ id: number;
524
+ emoji: string;
525
+ remove?: boolean;
526
+ idempotencyKey?: string;
527
+ idempotencyMatch?: IdempotencyMatch;
528
+ }): Message;
529
+ declare function createChannel(ctx: Context, caller: Caller, request: {
530
+ path: string;
531
+ private?: boolean;
532
+ }): {
533
+ path: string;
534
+ created: boolean;
535
+ };
536
+ //#endregion
537
+ //#region src/core/tasks.d.ts
538
+ declare const TASK_STATES: readonly ["waiting", "ready", "claimed", "blocked", "completed", "failed", "canceled"];
539
+ type TaskState = (typeof TASK_STATES)[number];
540
+ type Task = {
541
+ id: number;
542
+ channel: string;
543
+ owner: By;
544
+ for: string | null;
545
+ state: TaskState;
546
+ needs: number[];
547
+ hold: {
548
+ kind: string;
549
+ reason: string | null;
550
+ } | null;
551
+ result: string | null;
552
+ reason: string | null;
553
+ claim: {
554
+ by: By;
555
+ until: string;
556
+ epoch: number;
557
+ } | null;
558
+ attempts: number;
559
+ rounds: number;
560
+ };
561
+ /** Sets what the tasks under a channel may cost in all, or lifts the limit with null. Work already claimed carries on; no new claim is given past it. */
562
+ declare function setBudget(ctx: Context, caller: Caller, request: {
563
+ channel: string;
564
+ usd: number | null;
565
+ }): {
566
+ channel: string;
567
+ usd: number | null;
568
+ spent: number;
569
+ };
570
+ declare function budgets(ctx: Context, caller: Caller): {
571
+ budgets: {
572
+ channel: string;
573
+ usd: number;
574
+ spent: number;
575
+ }[];
576
+ };
577
+ type CreateRequest = (PostRequest | {
578
+ thread: number;
579
+ idempotencyKey?: string;
580
+ idempotencyMatch?: IdempotencyMatch;
581
+ }) & {
582
+ needs?: number[];
583
+ for?: string;
584
+ claim?: {
585
+ lease?: number;
586
+ pid?: number;
587
+ pidStart?: string;
588
+ token?: string;
589
+ };
590
+ /** Made held, in the same write: no one can claim it between its making and its block. */
591
+ hold?: {
592
+ kind?: string;
593
+ reason?: string;
594
+ };
595
+ };
596
+ declare function create$1(ctx: Context, caller: Caller, request: CreateRequest): {
597
+ task: Task;
598
+ message: Message;
599
+ token?: string;
600
+ };
601
+ /** What a task in a plan waits for: an earlier task by its key, or a task already on the board by its ID. Either may be written bare. */
602
+ type PlanNeed = {
603
+ key: string;
604
+ } | {
605
+ id: number;
606
+ } | string | number;
607
+ type PlanTask = {
608
+ key: string;
609
+ text: string;
610
+ labels?: Record<string, string>;
611
+ needs?: PlanNeed[];
612
+ for?: string;
613
+ };
614
+ /** Queues a whole plan in one write: each task after the ones it waits for, by its key. */
615
+ declare function plan(ctx: Context, caller: Caller, request: {
616
+ channel: string;
617
+ tasks: PlanTask[];
618
+ idempotencyKey?: string;
619
+ idempotencyMatch?: IdempotencyMatch;
620
+ }): {
621
+ tasks: (Task & {
622
+ key: string;
623
+ })[];
624
+ };
625
+ type ClaimRequest = {
626
+ id?: number;
627
+ /** Take the oldest ready task in this channel or subtree. */
628
+ ready?: string;
629
+ labels?: string[];
630
+ /** Other owners whose tasks to take, by principal. */
631
+ from?: string[];
632
+ /** With `ready`: take only a task this actor created, by its full ID (`local:user:ada+workflows`). */
633
+ by?: string;
634
+ lease?: number;
635
+ pid?: number;
636
+ pidStart?: string;
637
+ /** A token the caller chose, in place of one the board makes. Claiming a task already held under it answers that claim. */
638
+ token?: string;
639
+ };
640
+ declare function claim(ctx: Context, caller: Caller, request: ClaimRequest): {
641
+ task: Task;
642
+ token: string;
643
+ };
644
+ type Held = {
645
+ id: number;
646
+ token?: string | undefined;
647
+ };
648
+ declare function renew(ctx: Context, caller: Caller, request: Held & {
649
+ lease?: number;
650
+ }): {
651
+ task: Task;
652
+ };
653
+ declare function release(ctx: Context, caller: Caller, request: Held): {
654
+ task: Task;
655
+ };
656
+ declare function complete(ctx: Context, caller: Caller, request: Held & {
657
+ result?: string;
658
+ }): {
659
+ task: Task;
660
+ readied: number[];
661
+ };
662
+ declare function fail(ctx: Context, caller: Caller, request: Held & {
663
+ reason?: string;
664
+ counts?: boolean;
665
+ }): {
666
+ task: Task;
667
+ };
668
+ declare function block(ctx: Context, caller: Caller, request: Held & {
669
+ reason?: string;
670
+ kind?: string;
671
+ }): {
672
+ task: Task;
673
+ };
674
+ declare function unblock(ctx: Context, caller: Caller, request: {
675
+ id: number;
676
+ }): {
677
+ task: Task;
678
+ changed: boolean;
679
+ };
680
+ declare function reopen(ctx: Context, caller: Caller, request: {
681
+ id: number;
682
+ round?: boolean;
683
+ }): {
684
+ task: Task;
685
+ changed: boolean;
686
+ };
687
+ declare function cancel$1(ctx: Context, caller: Caller, request: {
688
+ id: number;
689
+ }): {
690
+ task: Task;
691
+ };
692
+ declare function assign(ctx: Context, caller: Caller, request: {
693
+ id: number;
694
+ for: string | null;
695
+ }): {
696
+ task: Task;
697
+ };
698
+ declare function setNeeds(ctx: Context, caller: Caller, request: {
699
+ id: number;
700
+ needs: number[];
701
+ }): {
702
+ task: Task;
703
+ };
704
+ type TaskListing = Task & {
705
+ text: string;
706
+ labels: Record<string, string>;
707
+ by: By;
708
+ at: string;
709
+ };
710
+ /**
711
+ * The tasks a caller may read, the first made first. With `latest` it is the `limit` last active instead,
712
+ * the latest last: a thread is active when something is said in it, so a claim renewed in silence
713
+ * doesn't count. `more` says some that matched were left out.
714
+ */
715
+ declare function list$1(ctx: Context, caller: Caller, request?: {
716
+ channel?: string;
717
+ state?: TaskState | 'open' | 'all';
718
+ labels?: string[];
719
+ limit?: number;
720
+ latest?: boolean;
721
+ }): {
722
+ tasks: TaskListing[];
723
+ more: boolean;
724
+ };
725
+ //#endregion
726
+ //#region src/core/reads.d.ts
727
+ type ThreadSummary = {
728
+ message: Message;
729
+ replies: number;
730
+ last: Message | null;
731
+ task: Task | null;
732
+ };
733
+ type Filter = {
734
+ /** A channel or a subtree (`db/`). */
735
+ channel?: string;
736
+ /** One thread, by its root. */
737
+ re?: number;
738
+ labels?: string[];
739
+ by?: string;
740
+ mentions?: string;
741
+ text?: string;
742
+ types?: string[];
743
+ /**
744
+ * Hold kinds a `task.blocked` event must have. A plain kind (`needs_input`) keeps only blocks of that kind;
745
+ * `!kind` (`!backlog`) drops blocks of that kind and keeps everything else. Other events pass unless a plain
746
+ * kind is given, which keeps only blocks.
747
+ */
748
+ kinds?: string[];
749
+ /**
750
+ * What is for one actor: messages posted that mention it, tasks assigned to it, and replies in threads it
751
+ * wrote in, never its own writes except a message it scheduled. A profile name is one of the caller's own; a
752
+ * value with `:` or `+` is a whole actor ID, with no `+profile` the principal alone.
753
+ */
754
+ for?: string;
755
+ /** Only what is about a thread's first message: a reply, and anything done to one, is left out. */
756
+ root?: boolean;
757
+ };
758
+ declare function readChannel(ctx: Context, caller: Caller, request: {
759
+ channel: string;
760
+ after?: number;
761
+ before?: number;
762
+ limit?: number;
763
+ labels?: string[];
764
+ text?: string;
765
+ mentions?: string;
766
+ }): {
767
+ threads: ThreadSummary[];
768
+ cursor: number;
769
+ older: number | null;
770
+ more: boolean;
771
+ };
772
+ declare function readThread(ctx: Context, caller: Caller, request: {
773
+ id: number;
774
+ after?: number;
775
+ labels?: string[];
776
+ }): {
777
+ message: Message;
778
+ replies: Message[];
779
+ task: Task | null;
780
+ cursor: number;
781
+ };
782
+ type FeedEvent = BoardEvent & {
783
+ message?: Message;
784
+ task?: Task;
785
+ /** Set when the read was `for` someone: why the event is for them. */
786
+ for?: 'mention' | 'assigned' | 'reply';
787
+ };
788
+ /**
789
+ * What `tail` and `wait` read: the events after a cursor that match, oldest first, and where to read on
790
+ * from. `through` reads no further than that seq, so one call looks at a bounded stretch of the log
791
+ * however few events match.
792
+ */
793
+ declare function events(ctx: Context, caller: Caller, request: {
794
+ after?: number;
795
+ filter?: Filter;
796
+ limit?: number;
797
+ through?: number;
798
+ }): {
799
+ events: FeedEvent[];
800
+ cursor: number;
801
+ };
802
+ declare function channels(ctx: Context, caller: Caller, request?: {
803
+ under?: string;
804
+ }): {
805
+ channels: {
806
+ path: string;
807
+ threads: number;
808
+ activity: number | null;
809
+ }[];
810
+ };
811
+ declare function actors(ctx: Context, caller?: Caller): {
812
+ actors: {
813
+ id: string;
814
+ handle: string;
815
+ principal: string;
816
+ profile: string | null;
817
+ }[];
818
+ };
819
+ declare function search(ctx: Context, caller: Caller, request: {
820
+ text: string;
821
+ channel?: string;
822
+ limit?: number;
823
+ }): {
824
+ messages: Message[];
825
+ };
826
+ //#endregion
827
+ //#region src/core/schedules.d.ts
828
+ type Schedule = {
829
+ id: number;
830
+ by: By;
831
+ channel: string;
832
+ thread: number | null;
833
+ text: string;
834
+ every: number | null;
835
+ times: number | null;
836
+ until: string | null;
837
+ fired: number;
838
+ next: string | null;
839
+ canceled: boolean;
840
+ };
841
+ type ScheduleRequest = {
842
+ /** A channel to post in, or a thread to reply in. */
843
+ channel?: string;
844
+ thread?: number;
845
+ text: string;
846
+ /** When the first one goes out. Default: one period from now, or now for a one-off. */
847
+ at?: string;
848
+ /** Seconds between sends. */
849
+ every?: number;
850
+ times?: number;
851
+ until?: string;
852
+ };
853
+ declare function create(ctx: Context, caller: Caller, request: ScheduleRequest): Schedule;
854
+ declare function list(ctx: Context, caller: Caller): {
855
+ schedules: Schedule[];
856
+ };
857
+ declare function cancel(ctx: Context, caller: Caller, request: {
858
+ id: number;
859
+ }): Schedule;
860
+ /**
861
+ * Sends what is due. Each send is one transaction that also records its slot, so a slot is sent once
862
+ * however many processes tick, and a crash between two sends loses neither. After downtime a schedule
863
+ * sends one message for all the slots it missed, if the latest of them is within its grace.
864
+ *
865
+ * A schedule made with a token is that token's doing: once the board's owner stops the token, `stopped`
866
+ * says so, and the schedule is canceled here instead of sent. It writes as the token's profile, and
867
+ * would otherwise go on doing so for as long as it repeats.
868
+ */
869
+ declare function tick(ctx: Context, stopped?: (token: string) => boolean): {
870
+ sent: number[];
871
+ skipped: number[];
872
+ canceled: number[];
873
+ };
874
+ //#endregion
875
+ //#region src/core/workflows.d.ts
876
+ type WorkflowRequest = {
877
+ name: string;
878
+ on: number;
879
+ args?: Record<string, string>;
880
+ };
881
+ /**
882
+ * Asks for a registered workflow to be run on a thread. The board keeps only the request: what the
883
+ * workflow does is its operator's config, read by whoever runs the daemon, never stored here.
884
+ */
885
+ declare function request(ctx: Context, caller: Caller, req: WorkflowRequest): {
886
+ seq: number;
887
+ };
888
+ //#endregion
889
+ //#region src/backend/types.d.ts
890
+ type Op<F> = F extends ((ctx: any, caller: Caller, request: infer R) => infer T) ? (caller: Caller, request: R) => Promise<T> : never;
891
+ type Read<F> = F extends ((ctx: any, caller: Caller, request?: infer R) => infer T) ? (caller: Caller, request?: R) => Promise<T> : never;
892
+ /**
893
+ * What a board answers. `file()` answers from the SQLite file in this process; `http()` asks a
894
+ * `mu serve`. The handle calls nothing else, so a new backend is these methods and the conformance suite.
895
+ */
896
+ type Backend = {
897
+ kind: 'file' | 'http';
898
+ /** Where the board is, for people: a path or a URL. */
899
+ where: string;
900
+ /** Who a request with no token is from, on a backend that decides that itself. */
901
+ self(profile: string | null): Promise<Caller>;
902
+ /** The board's own list of tokens, where it has one: what `mu serve` checks each request's token against. */
903
+ registry?: () => Registry;
904
+ /** The key this board's tokens are signed with, where it keeps one: the one `mu serve` and `team.fetch` check tokens with. */
905
+ signingKey?: () => Buffer;
906
+ /** The board's tokens: making one, listing them, stopping one. For the owner, or a token as wide as the owner's. */
907
+ tokens: {
908
+ create(request: MintRequest): Promise<{
909
+ token: string;
910
+ record: TokenRecord;
911
+ }>;
912
+ list(): Promise<{
913
+ tokens: TokenRecord[];
914
+ }>;
915
+ revoke(request: {
916
+ id: string;
917
+ }): Promise<{
918
+ revoked: string;
919
+ }>;
920
+ /** A workload's own token, signed by its platform, for a board token: on a served board whose owner trusts that workload. */
921
+ exchange(request: {
922
+ token: string;
923
+ }): Promise<{
924
+ token: string;
925
+ record: TokenRecord;
926
+ trust: string;
927
+ }>;
928
+ };
929
+ /**
930
+ * Roles one process at a time holds for this board (the ticker is `tick`), where the board keeps them:
931
+ * only a backend that has the board's file. A board at a URL is ticked by the server it is on.
932
+ */
933
+ leases?: {
934
+ take(request: {
935
+ name: string;
936
+ holder: string;
937
+ ttl: number;
938
+ }): Promise<Taken>;
939
+ renew(request: {
940
+ name: string;
941
+ holder: string;
942
+ epoch: number;
943
+ ttl: number;
944
+ }): Promise<{
945
+ held: boolean;
946
+ expires: number;
947
+ }>;
948
+ release(request: {
949
+ name: string;
950
+ holder: string;
951
+ epoch: number;
952
+ }): Promise<void>;
953
+ holder(name: string): Promise<ReturnType<typeof holder>>;
954
+ };
955
+ /**
956
+ * Where each watcher declared in code stands: what it delivered above its cursor and what it is
957
+ * trying. Only a backend that has the board's file: watchers run where it is.
958
+ */
959
+ deliveries?: {
960
+ read(request: {
961
+ watcher: string;
962
+ after: number;
963
+ }): Promise<ReturnType<typeof read>>;
964
+ begin(request: Parameters<typeof begin>[1]): Promise<ReturnType<typeof begin>>;
965
+ finish(request: Parameters<typeof finish>[1]): Promise<ReturnType<typeof finish>>;
966
+ advance(caller: Caller, request: Parameters<typeof advance>[2]): Promise<ReturnType<typeof advance>>;
967
+ };
968
+ /** The board's own requests to join, where it keeps them: what `mu serve` answers them from. */
969
+ joinStore?: () => Joins;
970
+ /** Asking to join (no token needed), and answering: listing, approving with what the token may do, refusing. */
971
+ joins: {
972
+ ask(request: {
973
+ profile: string;
974
+ note?: string;
975
+ }): Promise<{
976
+ code: string;
977
+ secret: string;
978
+ expires: number;
979
+ }>;
980
+ poll(request: {
981
+ code: string;
982
+ secret: string;
983
+ }): Promise<{
984
+ state: 'pending';
985
+ } | {
986
+ state: 'approved';
987
+ token: string;
988
+ } | {
989
+ state: 'denied';
990
+ }>;
991
+ list(): Promise<{
992
+ joins: JoinRecord[];
993
+ }>;
994
+ approve(request: {
995
+ code: string;
996
+ can: Record<string, string[]>;
997
+ ttl: number;
998
+ noSync?: boolean;
999
+ }): Promise<{
1000
+ join: JoinRecord;
1001
+ record: TokenRecord;
1002
+ }>;
1003
+ deny(request: {
1004
+ code: string;
1005
+ }): Promise<{
1006
+ join: JoinRecord;
1007
+ }>;
1008
+ };
1009
+ post: Op<typeof post>;
1010
+ reply: Op<typeof reply>;
1011
+ edit: Op<typeof edit>;
1012
+ remove: Op<typeof remove>;
1013
+ label: Op<typeof label>;
1014
+ react: Op<typeof react>;
1015
+ createChannel: Op<typeof createChannel>;
1016
+ workflowRequest: Op<typeof request>;
1017
+ readChannel: Op<typeof readChannel>;
1018
+ readThread: Op<typeof readThread>;
1019
+ events: Op<typeof events>;
1020
+ channels: Read<typeof channels>;
1021
+ search: Op<typeof search>;
1022
+ actors(caller: Caller): Promise<ReturnType<typeof actors>>;
1023
+ head(caller: Caller): Promise<number>;
1024
+ cursorGet(caller: Caller, name: string): Promise<number | null>;
1025
+ cursorSet(caller: Caller, name: string, seq: number): Promise<void>;
1026
+ taskCreate: Op<typeof create$1>;
1027
+ taskPlan: Op<typeof plan>;
1028
+ taskClaim: Op<typeof claim>;
1029
+ taskRenew: Op<typeof renew>;
1030
+ taskRelease: Op<typeof release>;
1031
+ taskComplete: Op<typeof complete>;
1032
+ taskFail: Op<typeof fail>;
1033
+ taskBlock: Op<typeof block>;
1034
+ taskUnblock: Op<typeof unblock>;
1035
+ taskReopen: Op<typeof reopen>;
1036
+ taskCancel: Op<typeof cancel$1>;
1037
+ taskAssign: Op<typeof assign>;
1038
+ taskNeeds: Op<typeof setNeeds>;
1039
+ taskList: Read<typeof list$1>;
1040
+ task(caller: Caller, id: number): Promise<Task | null>;
1041
+ budgetSet: Op<typeof setBudget>;
1042
+ budgets(caller: Caller): Promise<ReturnType<typeof budgets>>;
1043
+ filePut: Op<typeof filePut>;
1044
+ fileGet: Op<typeof fileGet>;
1045
+ schemaAdd: Op<typeof schemaAdd>;
1046
+ schemaList(caller: Caller): Promise<ReturnType<typeof schemaList>>;
1047
+ scheduleCreate: Op<typeof create>;
1048
+ scheduleCancel: Op<typeof cancel>;
1049
+ scheduleList(caller: Caller): Promise<ReturnType<typeof list>>;
1050
+ /** Sends what is due now. Whoever holds the board's `tick` lease calls it. */
1051
+ scheduleTick(caller: Caller): Promise<ReturnType<typeof tick>>;
1052
+ /**
1053
+ * Takes a platform's webhook for the sync named `key`. Only the server that owns the board answers this.
1054
+ * `skipped` says what it carried that was late, and not applied.
1055
+ */
1056
+ syncReceive(key: string, received: {
1057
+ headers: Record<string, string | undefined>;
1058
+ body: string;
1059
+ }): Promise<{
1060
+ status: number;
1061
+ body: string;
1062
+ skipped?: string[];
1063
+ }>;
1064
+ /** The names of the platforms this board syncs with, as configured: none means a tick has nothing to do. */
1065
+ readonly syncs?: readonly string[];
1066
+ /** Throws, saying why, when the sync can't run: a secret it names with `env()` isn't set. Said to the owner only. */
1067
+ syncCheck?(): void;
1068
+ /** Imports what is waiting and delivers what is owed. Whoever holds the board's `sync` lease calls it. */
1069
+ syncTick(): Promise<{
1070
+ imported: number;
1071
+ delivered: number;
1072
+ failed: number;
1073
+ skipped?: string[];
1074
+ }>;
1075
+ /** Writes a consistent copy of the board to `path`, while others keep writing. File boards only. */
1076
+ backup(path: string): Promise<{
1077
+ path: string;
1078
+ files?: string;
1079
+ }>;
1080
+ close(): void;
1081
+ };
1082
+ //#endregion
1083
+ //#region src/backend/file.d.ts
1084
+ type FileOptions = {
1085
+ /** The folder the board's file is in. Default: `MUSTER_DIR`, or `~/.muster`. */
1086
+ dir?: string;
1087
+ /** The board's name: `<dir>/<name>.db`. Default `main`. */
1088
+ name?: string;
1089
+ /** The key tokens are signed with, and the list of tokens made. Default: the ones kept for this board in the config folder. */
1090
+ key?: Buffer;
1091
+ tokens?: Registry;
1092
+ /** Keeps the board in memory: nothing is written, and it's gone with the process. For tests. */
1093
+ memory?: boolean;
1094
+ now?: () => Date;
1095
+ alive?: (pid: number, start: string) => boolean;
1096
+ /** Who a caller with no token is. Default: this OS user. */
1097
+ principal?: string;
1098
+ /** The platforms this board syncs with: secrets named with `env()` are read on first use. */
1099
+ sync?: Sync;
1100
+ fetch?: typeof fetch;
1101
+ };
1102
+ declare function boardPath(options?: {
1103
+ dir?: string;
1104
+ name?: string;
1105
+ }): string;
1106
+ /** A board in a SQLite file, answered in this process. Every process that opens it is one trust domain. */
1107
+ declare function file(options?: FileOptions): Backend;
1108
+ //#endregion
1109
+ //#region src/serve/fetch.d.ts
1110
+ type MountOptions = {
1111
+ /** The path the board is mounted at, as a request's URL has it: `/api/board` unless you say otherwise. */
1112
+ base?: string;
1113
+ /**
1114
+ * Host names requests may come for, beside this machine's (`127.0.0.1`, `localhost`, `[::1]`). Default: the
1115
+ * names in `MUSTER_ALLOW_HOSTS`, as for `mu serve`. Any other `Host` is refused.
1116
+ */
1117
+ hosts?: readonly string[];
1118
+ /** Where the board says what only its owner should read, such as why a request failed. Default: standard error. */
1119
+ log?: (line: string) => void;
1120
+ };
1121
+ //#endregion
1122
+ //#region src/config/env.d.ts
1123
+ declare const ENV: unique symbol;
1124
+ /** A secret named, not written: `env('GITHUB_WEBHOOK_SECRET')`. The board reads it when it starts. */
1125
+ type Env = {
1126
+ readonly [ENV]: string;
1127
+ };
1128
+ /**
1129
+ * Names an environment variable for a secret. Nothing is read now: the board reads it when it starts
1130
+ * (`team.start()`, `mu serve`, `mu daemon run`) or takes its first request (`team.fetch`), and refuses,
1131
+ * naming the variable, if it isn't set. It is never text: one turned into a string would be a key anyone
1132
+ * reading the module could guess, so that throws.
1133
+ */
1134
+ declare function env(name: string): Env;
1135
+ //#endregion
1136
+ //#region src/daemon/hooks.d.ts
1137
+ /**
1138
+ * An outgoing webhook, as a board module declares it: what to listen for and where to send it. Like a
1139
+ * watcher it is never read from a board, so nothing written to one can make a host call a URL.
1140
+ */
1141
+ type Hook = {
1142
+ name: string;
1143
+ url: string;
1144
+ /** The name of the environment variable that holds the signing secret. The secret itself is never in the module. */
1145
+ secret: string;
1146
+ tail: Filter;
1147
+ /** What a delivery carries: a pointer to the event, or the event as `mu tail --json` prints it. */
1148
+ body: 'pointer' | 'event';
1149
+ };
1150
+ /** An outgoing webhook as `board({ hooks })` takes it, with its secret named by `env()`. */
1151
+ type HookOptions = {
1152
+ name: string;
1153
+ url: string;
1154
+ /** The environment variable that holds the signing secret: `env('AUDIT_SECRET')`. Read when the host starts. */
1155
+ secret: Env;
1156
+ /** What to send: a filter like `mu tail`'s. Left out, every event. */
1157
+ tail?: Filter;
1158
+ /** What a delivery carries. Default `pointer`. */
1159
+ body?: 'pointer' | 'event';
1160
+ };
1161
+ //#endregion
1162
+ //#region src/failure.d.ts
1163
+ /** What a command exits with: 1 for a failure, 2 for misuse. */
1164
+ type ExitCode = 1 | 2;
1165
+ /**
1166
+ * An error as data: a `reason` to branch on, a headline that says what failed and why, and at most
1167
+ * two ways out. The CLI prints it; a program reads it with --json.
1168
+ */
1169
+ declare class Failure extends Error {
1170
+ readonly reason: string;
1171
+ readonly hint: string | undefined;
1172
+ readonly next: readonly string[];
1173
+ readonly exit: ExitCode;
1174
+ readonly data: Record<string, unknown> | undefined;
1175
+ constructor(reason: string, message: string, options?: {
1176
+ hint?: string;
1177
+ next?: readonly string[];
1178
+ exit?: ExitCode;
1179
+ data?: Record<string, unknown>;
1180
+ });
1181
+ toJSON(): {
1182
+ data?: Record<string, unknown> | undefined;
1183
+ next?: readonly string[] | undefined;
1184
+ hint?: string | undefined;
1185
+ reason: string;
1186
+ message: string;
1187
+ };
1188
+ }
1189
+ //#endregion
1190
+ //#region src/watch/watch.d.ts
1191
+ type MessageType = 'message.posted' | 'message.edited' | 'message.deleted';
1192
+ type TaskType = 'task.created' | 'task.ready' | 'task.claimed' | 'task.renewed' | 'task.released' | 'task.expired' | 'task.blocked' | 'task.completed' | 'task.failed' | 'task.canceled' | 'task.reopened' | 'task.assigned' | 'task.needs_changed' | 'task.waiting' | 'task.extended';
1193
+ type OtherType = 'channel.created' | 'labels.changed' | 'reaction.added' | 'reaction.removed' | 'schedule.created' | 'schedule.canceled' | 'schedule.skipped' | 'schema.registered' | 'budget.set' | 'sync.delivered';
1194
+ /**
1195
+ * An event as a watcher gets it: exactly what `mu tail --json` prints for it, narrowed by `type`. A
1196
+ * message event carries its message as it is now (a tombstone once deleted), a task event its task.
1197
+ */
1198
+ type WatchEvent = (Omit<FeedEvent, 'type' | 'message' | 'task'> & {
1199
+ type: MessageType;
1200
+ message: Message;
1201
+ task?: undefined;
1202
+ }) | (Omit<FeedEvent, 'type' | 'message' | 'task'> & {
1203
+ type: TaskType;
1204
+ task: Task;
1205
+ message?: undefined;
1206
+ }) | (Omit<FeedEvent, 'type' | 'message' | 'task'> & {
1207
+ type: OtherType;
1208
+ message?: undefined;
1209
+ task?: undefined;
1210
+ });
1211
+ /** A length of time: milliseconds, or `500ms`, `30s`, `5m`, `1h`. */
1212
+ type Duration = number | `${number}${'ms' | 's' | 'm' | 'h'}`;
1213
+ /** What a watcher is handed each time it runs. */
1214
+ type WatchContext = {
1215
+ /** The event that woke it. With `coalesce`, the newest of its thread's events since the last run. */
1216
+ event: WatchEvent;
1217
+ /**
1218
+ * The board, writing as the watcher's `as` profile when it has one. Its writes are keyed by the event,
1219
+ * so a retry after a throw doesn't write them twice; once the run is aborted it refuses to write.
1220
+ */
1221
+ board: Board;
1222
+ /** Aborts when the run's `timeout` is up: stop, and write nothing more. */
1223
+ signal: AbortSignal;
1224
+ /** Which watcher this is, and the profile it writes as. */
1225
+ watcher: {
1226
+ name: string;
1227
+ as: string | null;
1228
+ };
1229
+ /** Which try this is for this event: 1, then up to 5. */
1230
+ attempt: number;
1231
+ };
1232
+ /**
1233
+ * A watcher declared in code beside the board: what it listens for, and what it does. It runs where
1234
+ * the board's file is, one host at a time, from the moment it is first started: what was on the board
1235
+ * before wakes nothing.
1236
+ */
1237
+ type Watch = {
1238
+ /** What to listen for: a filter like `mu tail`'s. */
1239
+ tail: Filter;
1240
+ /** Called once for each event that matches. A throw is a failed delivery, tried again. */
1241
+ run: (context: WatchContext) => unknown;
1242
+ /** The profile it writes as. Its own writes never wake it; a message it scheduled does. */
1243
+ as?: string;
1244
+ /** How long one run may take before it is aborted and counted as failed. Default `60s`. */
1245
+ timeout?: Duration;
1246
+ /**
1247
+ * Gathers a thread's events: once its oldest undelivered event is this old, the run gets the newest
1248
+ * of them, once, standing for the rest. For a watcher that wakes an agent who reads the thread itself.
1249
+ */
1250
+ coalesce?: Duration;
1251
+ };
1252
+ //#endregion
1253
+ //#region src/watch/host.d.ts
1254
+ /** A host running a board's watchers: stop it, and `done` settles once each run in flight has been recorded. */
1255
+ type Host = {
1256
+ stop(): void;
1257
+ done: Promise<void>;
1258
+ };
1259
+ type StartOptions = {
1260
+ /** Stops the host when it aborts, like `stop()`. */
1261
+ signal?: AbortSignal;
1262
+ /** Where the host says what it did and what failed. Default: standard error. */
1263
+ log?: (line: string) => void;
1264
+ /** Each watcher's lease, in milliseconds: how long it lasts unrenewed, how often it is renewed, how often a waiting host looks. */
1265
+ lease?: {
1266
+ ttl?: number;
1267
+ every?: number;
1268
+ wait?: number;
1269
+ };
1270
+ /** How long `stop()` waits for a run in flight once it has signalled it, in milliseconds. Default 5 seconds. */
1271
+ grace?: number;
1272
+ };
1273
+ /** What one pass over the watchers did. `held` names those another host runs, so this one left them alone. */
1274
+ type Delivered = {
1275
+ delivered: number;
1276
+ failed: number;
1277
+ held: string[];
1278
+ };
1279
+ //#endregion
1280
+ //#region src/handle.d.ts
1281
+ /** A watcher a handle declares, as anyone may read it: its name, what it listens for, and the profile it writes as. */
1282
+ type DeclaredWatcher = {
1283
+ readonly name: string;
1284
+ readonly tail: Filter;
1285
+ readonly as: string | null;
1286
+ };
1287
+ /** A platform a handle syncs with, as anyone may read it: its name, its type, and the variables it reads when it starts. */
1288
+ type DeclaredSync = {
1289
+ readonly key: string;
1290
+ readonly type: string;
1291
+ readonly env: readonly string[];
1292
+ };
1293
+ /** An outgoing webhook a handle declares: its secret by the name of its variable, never its value. */
1294
+ type DeclaredHook = Readonly<Hook>;
1295
+ type BoardOptions = FileOptions & {
1296
+ /** Where the board lives. Default: `file()` with the options beside it. */
1297
+ backend?: Backend;
1298
+ /** The profile this handle writes as. Default: `MUSTER_PROFILE`, or the principal itself. */
1299
+ as?: string | null;
1300
+ /**
1301
+ * Watchers by name: what to listen for and what to do. Declaring them starts nothing: `start()` does,
1302
+ * in the process you choose.
1303
+ */
1304
+ watch?: Record<string, Watch>;
1305
+ /**
1306
+ * Outgoing webhooks: signed POSTs of what matches each `tail`, with the secret named by `env()`. Declaring them reads nothing: `start()` reads each secret, and sends.
1307
+ */
1308
+ hooks?: HookOptions[];
1309
+ /** How `fetch` serves the board: the path it is mounted at, and the host names it answers for. */
1310
+ serve?: MountOptions;
1311
+ };
1312
+ type Bound<F> = F extends ((caller: Caller, ...rest: infer A) => infer T) ? (...rest: A) => T : never;
1313
+ type Methods = Omit<Backend, 'kind' | 'where' | 'self' | 'close'>;
1314
+ /** A board, as one caller: every read and write the CLI, a UI, or your code makes. */
1315
+ type Board = { [K in keyof Methods]: Bound<Methods[K]> } & {
1316
+ backend: Backend;
1317
+ /** The watchers this handle declares, in the order given. Declared, not running: `start()` runs them. */
1318
+ readonly watchers: readonly DeclaredWatcher[];
1319
+ /** The platforms this handle syncs with, by name. Their secrets are read by `start()`, or `fetch`'s first request. */
1320
+ readonly sync: readonly DeclaredSync[];
1321
+ /** The outgoing webhooks this handle declares, in the order given. `start()` sends them. */
1322
+ readonly hooks: readonly DeclaredHook[];
1323
+ /** The same board, writing as one of your profiles. */
1324
+ as(profile: string | null): Board;
1325
+ whoami(): Promise<{
1326
+ principal: string;
1327
+ profile: string | null;
1328
+ mode: 'file' | 'serve';
1329
+ where: string;
1330
+ }>;
1331
+ /**
1332
+ * Runs the watchers, the sync and the hooks in this process until stopped, and returns at once. Never await
1333
+ * `done` in a server's startup. Throws, naming it, if a variable a sync or a hook names with `env()` isn't set.
1334
+ */
1335
+ start(options?: StartOptions): Host;
1336
+ /** Runs each watcher once on what it has not had yet, and says what happened. For tests. */
1337
+ deliver(): Promise<Delivered>;
1338
+ /**
1339
+ * What `mu serve` serves for this board, as a web `Request → Response` handler: its routes, the live feed,
1340
+ * webhooks for its sync, every request held to a token. `export const GET = team.fetch, POST = team.fetch`.
1341
+ */
1342
+ fetch(request: Request): Promise<Response>;
1343
+ close(): void;
1344
+ };
1345
+ /** A handle on a board: `board()` is the default board in `~/.muster`, as you. */
1346
+ declare function board(options?: BoardOptions): Board;
1347
+ //#endregion
1348
+ //#region src/watch/command.d.ts
1349
+ /** A command as its words, or worked out from the event: never a string a shell splits. */
1350
+ type Argv = string[] | ((context: WatchContext) => string[]);
1351
+ type CommandOptions = {
1352
+ /** Names to pass on from this process's environment, beside PATH, HOME and the board's own. Nothing else is. */
1353
+ env?: string[];
1354
+ /** Run first: when the last line it prints is JSON with `wake: false`, the command isn't run. */
1355
+ gate?: Argv;
1356
+ /** How long a command told to stop (at the watcher's timeout) has before it is killed. Default 5 seconds. */
1357
+ grace?: number;
1358
+ };
1359
+ /**
1360
+ * A watcher's `run` that starts a command, the way to wake an agent: `command(['./wake.sh'])`, or
1361
+ * `command(({ event }) => ['./wake.sh', String(event.thread)])`. It is woken with a pointer in its
1362
+ * environment (`MUSTER_THREAD`, `MUSTER_EVENT`, ...) and nothing else of this process's but what `env`
1363
+ * names. Exit 0 is delivered; anything else is a failed try. At the watcher's timeout its process group
1364
+ * is stopped.
1365
+ */
1366
+ declare function command(argv: Argv, options?: CommandOptions): (context: WatchContext) => Promise<void>;
1367
+ //#endregion
1368
+ //#region src/conformance.d.ts
1369
+ type Check = {
1370
+ name: string;
1371
+ ok: boolean;
1372
+ detail?: string;
1373
+ };
1374
+ /**
1375
+ * What any backend must do, checked through a handle, in a channel of its own. A backend that passes
1376
+ * behaves like a board to everything built on one. It writes real messages: point it at a scratch board.
1377
+ */
1378
+ declare function conformance(team: Board): Promise<Check[]>;
1379
+ //#endregion
1380
+ //#region src/backend/http.d.ts
1381
+ type HttpOptions = {
1382
+ /** The board's URL, as `mu serve` prints it: `http://127.0.0.1:4100/api/board`. */
1383
+ url: string | Promise<string>;
1384
+ token: string;
1385
+ fetch?: typeof fetch;
1386
+ /** What a redirect does. Default `error`: what a request carries is for the board's own URL, and nowhere a redirect points. */
1387
+ redirect?: 'follow' | 'error';
1388
+ /**
1389
+ * Lets a token cross plain http to a host that isn't this machine. Only for a network that is private
1390
+ * some other way, such as a tailnet: anywhere else, whoever is on the path reads the token. `false`
1391
+ * says it never may, whatever the caller's environment says: a job's own token, on its way to be exchanged.
1392
+ */
1393
+ insecure?: boolean;
1394
+ };
1395
+ /** A board at a URL, answered by a `mu serve`. The token says who you are and what you may do. */
1396
+ declare function http(options: HttpOptions): Backend;
1397
+ //#endregion
1398
+ //#region src/serve/oidc.d.ts
1399
+ /**
1400
+ * A workload the board's owner trusts to sign in with a token its platform signed: a CI job, with the
1401
+ * OIDC token its runner gives it. It is the owner's configuration, in a file beside the board's key and
1402
+ * never on a board, and it says everything the board token will be: who it writes as and where.
1403
+ */
1404
+ type Trust = {
1405
+ name: string;
1406
+ /** Who signed the token, exactly as its `iss` says. */
1407
+ issuer: string;
1408
+ /** Who the token must be made out to: this board, by a name the owner chose. Never read from a request. */
1409
+ audience: string;
1410
+ /** Which workload: the token's `sub`, exactly, or a prefix ending in `*` after a `:` or `/`. */
1411
+ sub: string;
1412
+ /** The profile the board token writes as. */
1413
+ as: string;
1414
+ can: Record<string, Permission[]>;
1415
+ /** How long the board token lives, in seconds. */
1416
+ ttl: number;
1417
+ /** Where the issuer's keys are, when it publishes no discovery document. */
1418
+ jwks?: string;
1419
+ /** What the job writes stays on the board, and goes to no platform sync is set up with. */
1420
+ noSync?: true;
1421
+ };
1422
+ //#endregion
1423
+ //#region src/serve/routes.d.ts
1424
+ /**
1425
+ * What a sandbox's agent may call, by name: reading and writing the board, never running it. A route
1426
+ * is here because an agent doing a task needs it. A new route is closed to sandboxes until it is added.
1427
+ */
1428
+ declare const SANDBOX_ROUTES: readonly ["post", "reply", "edit", "remove", "label", "react", "createChannel", "readChannel", "readThread", "events", "channels", "search", "actors", "head", "taskCreate", "taskPlan", "taskClaim", "taskRenew", "taskRelease", "taskComplete", "taskFail", "taskBlock", "taskUnblock", "taskReopen", "taskCancel", "taskAssign", "taskNeeds", "taskList", "task", "schemaList", "filePut", "fileGet", "budgets"];
1429
+ //#endregion
1430
+ //#region src/serve/server.d.ts
1431
+ type ServeOptions = {
1432
+ backend: Backend;
1433
+ key: Buffer;
1434
+ now?: () => number;
1435
+ /** The board's list of tokens it made. Default: the backend's own. */
1436
+ tokens?: Registry;
1437
+ /** Host names requests may come for, beside the address it listens on. */
1438
+ hosts?: readonly string[];
1439
+ /** Milliseconds between looks at the log for an open feed. */
1440
+ feedInterval?: number;
1441
+ /**
1442
+ * MCP over HTTP at `/api/board/mcp`, for agents on other machines. It is handed one JSON-RPC message
1443
+ * and the caller's own token and profile, so the tool can do exactly what that token can, and no more.
1444
+ */
1445
+ mcp?: (message: unknown, as: {
1446
+ token: string;
1447
+ profile: string | null;
1448
+ }) => Promise<object | null>;
1449
+ /** Whether an agent with no token may ask to join. Off unless the owner says so. */
1450
+ allowJoins?: boolean;
1451
+ /** The workloads the owner trusts to sign in with their platform's token. None unless the owner names some. */
1452
+ oidc?: readonly Trust[];
1453
+ /** How the board reaches an issuer for its keys. Default: `fetch`. */
1454
+ fetch?: typeof fetch;
1455
+ /** Where the board says what only its owner should read, such as why an issuer's keys couldn't be fetched. */
1456
+ log?: (line: string) => void;
1457
+ };
1458
+ /**
1459
+ * The board over HTTP. Every request names its caller with a token this board signed: the token fixes
1460
+ * the principal and what it may do, and nothing in a request body can change either.
1461
+ */
1462
+ declare function createHandler(options: ServeOptions): (req: IncomingMessage, res: ServerResponse) => Promise<void | ServerResponse<IncomingMessage>>;
1463
+ declare function listen(options: ServeOptions & {
1464
+ port?: number;
1465
+ host?: string;
1466
+ }): Promise<{
1467
+ server: Server;
1468
+ url: string;
1469
+ close(): Promise<void>;
1470
+ }>;
1471
+ //#endregion
1472
+ //#region src/runner/agents.d.ts
1473
+ /** How a run ended, as far as the board cares. */
1474
+ type ExitKind = 'ok' | 'quota' | 'auth' | 'bad_resume' | 'crash' | 'timeout' | 'stopped';
1475
+ type Usage = {
1476
+ input: number;
1477
+ output: number;
1478
+ };
1479
+ type Parsed = {
1480
+ sessionId?: string;
1481
+ usage?: Usage;
1482
+ costUsd?: number;
1483
+ terminal: boolean;
1484
+ error?: string;
1485
+ };
1486
+ /** `safe` passes no flag that widens what the agent may do. `bypass` is the agent's own skip-permissions flag, and is always asked for by name. */
1487
+ type PermissionMode = 'safe' | 'bypass';
1488
+ /**
1489
+ * How to run one agent CLI headlessly and read what it printed. It is code, not config: every agent
1490
+ * needed its own parsing state and its own error text.
1491
+ */
1492
+ type Agent = {
1493
+ name: string;
1494
+ /** `full` loads everything the person's own setup has: plugins, skills, connected tools. The default is lean. */
1495
+ command(options: {
1496
+ resume?: string;
1497
+ permissionMode: PermissionMode;
1498
+ model?: string;
1499
+ full?: boolean;
1500
+ writable?: string[];
1501
+ }): {
1502
+ bin: string;
1503
+ args: string[];
1504
+ };
1505
+ /** Environment the agent needs beyond PATH and HOME, by name: its own keys and config folders. */
1506
+ envKeys: string[];
1507
+ /**
1508
+ * How the agent reaches its model from a sandbox: the provider's host, the variable its key is read
1509
+ * from on the machine that starts the run, the headers that carry the key, and what the sandbox's
1510
+ * environment holds instead of it. `paths` are the only requests the key is added to, as regular
1511
+ * expressions over the path of a POST: asking the model, and nothing else that key can do. Absent for an agent whose model isn't ours to know.
1512
+ */
1513
+ model?: {
1514
+ host: string;
1515
+ keyEnv: string;
1516
+ paths: string[];
1517
+ headers(key: string): Record<string, string>;
1518
+ env(placeholder: string): Record<string, string>;
1519
+ };
1520
+ parse(stdout: string): Parsed;
1521
+ classify(result: {
1522
+ code: number | null;
1523
+ signal: NodeJS.Signals | null;
1524
+ parsed: Parsed;
1525
+ stderr: string;
1526
+ }): ExitKind;
1527
+ };
1528
+ declare const claude: Agent;
1529
+ declare const codex: Agent;
1530
+ /** Any command: the prompt on stdin, and how it exits is all there is to know. */
1531
+ declare const generic: (bin: string, args?: string[]) => Agent;
1532
+ declare const AGENTS: Record<string, Agent>;
1533
+ //#endregion
1534
+ //#region src/runner/local.d.ts
1535
+ type RunRequest = {
1536
+ agent: Agent;
1537
+ /** What the agent is told. A pointer to the task, never its content. */
1538
+ prompt: string;
1539
+ /** Where it works. */
1540
+ cwd: string;
1541
+ /** Makes `cwd` a git worktree of this repository on a new branch, when it doesn't exist yet. */
1542
+ worktree?: {
1543
+ repo: string;
1544
+ branch: string;
1545
+ from?: string;
1546
+ };
1547
+ /** What the agent's environment carries, beside PATH, HOME and what the agent itself names. */
1548
+ env?: Record<string, string>;
1549
+ /** Names to pass through from this process's environment. Nothing else is inherited. */
1550
+ envAllow?: string[];
1551
+ permissionMode?: PermissionMode;
1552
+ /** Folders beside `cwd` the agent must be able to write: the board's, so its own `mu` commands work in a sandbox. */
1553
+ writable?: string[];
1554
+ /** Load the person's whole agent setup instead of the lean one. */
1555
+ full?: boolean;
1556
+ model?: string;
1557
+ resume?: string;
1558
+ /** Where its output is kept. */
1559
+ logDir: string;
1560
+ /** Stops it after this long. */
1561
+ timeoutMs?: number;
1562
+ signal?: AbortSignal;
1563
+ /** How long it gets between being asked to stop and being killed. */
1564
+ graceMs?: number;
1565
+ /** Removes the logs of earlier runs kept beside this one's (folders named `<task>-<time>`) once they are older than this. Left out, nothing is removed. */
1566
+ keepLogsMs?: number;
1567
+ now?: () => number;
1568
+ };
1569
+ type RunResult = {
1570
+ kind: ExitKind;
1571
+ code: number | null;
1572
+ signal: NodeJS.Signals | null;
1573
+ parsed: Parsed;
1574
+ stdoutPath: string;
1575
+ stderrPath: string;
1576
+ pid: number;
1577
+ notStarted?: boolean;
1578
+ };
1579
+ /**
1580
+ * The environment an agent starts with: built from nothing, then PATH and HOME, what the agent itself
1581
+ * needs, and what the caller allows by name. Secrets in this process's environment don't reach it by
1582
+ * accident, and no marker makes it think it runs inside another agent.
1583
+ */
1584
+ declare function agentEnv(agent: Agent, request: Pick<RunRequest, 'env' | 'envAllow'>, from?: NodeJS.ProcessEnv): Record<string, string>;
1585
+ /** Runs an agent to its end in its own process group, and says how it ended. */
1586
+ declare function runLocal(request: RunRequest): {
1587
+ pid: number;
1588
+ done: Promise<RunResult>;
1589
+ stop(): void;
1590
+ };
1591
+ //#endregion
1592
+ //#region src/sync/declare.d.ts
1593
+ /** A secret as a module gives it: named with `env()`, or written out (which puts it in the module's file). */
1594
+ type Secret = string | Env;
1595
+ /** What every platform's sync takes. */
1596
+ type SyncOptions = {
1597
+ /** The webhook signing secret: `env('NAME')`. */
1598
+ secret: Secret;
1599
+ /** An API token, where the sync sends to the platform or reads from it: `env('NAME')`. */
1600
+ token?: Secret;
1601
+ /**
1602
+ * Runs on text as it comes in, and returns what to keep, or null to drop the event. A command (an array
1603
+ * of words: text in on stdin, what to keep on stdout, a non-zero exit drops it), or a function.
1604
+ */
1605
+ filter?: readonly string[] | ((text: string) => string | null);
1606
+ /** Megabytes of files this sync may bring in a day. */
1607
+ filesPerDayMB?: number;
1608
+ };
1609
+ //#endregion
1610
+ //#region src/sync/providers.d.ts
1611
+ type GitHubOptions = SyncOptions & {
1612
+ /**
1613
+ * A GitHub App's numeric ID, with `appKey`: what the sync sends is then written by the App, not by whoever
1614
+ * owns `token`, and no `token` is needed. `env('NAME')`.
1615
+ */
1616
+ appId?: Secret;
1617
+ /** The App's private key: the PEM itself, or the path to its `.pem` file. `env('NAME')`. */
1618
+ appKey?: Secret;
1619
+ /** The app's own login, so its comments aren't imported back. */
1620
+ bot?: string;
1621
+ /** A repo to a channel, or to a channel for issues and one for pulls. `mirror` sends board replies back. */
1622
+ repos: Record<string, string | {
1623
+ issues?: string;
1624
+ pulls?: string;
1625
+ mirror?: boolean;
1626
+ }>;
1627
+ api?: string;
1628
+ /** The clock an App's tokens are kept by. */
1629
+ now?: () => number;
1630
+ };
1631
+ /**
1632
+ * GitHub: issues, pull requests and their comments come in as threads. Nothing goes back unless a repo mirrors.
1633
+ * `token` is one that may comment, needed only where a repo mirrors; `appId` and `appKey` name a GitHub App
1634
+ * to comment as instead.
1635
+ */
1636
+ declare const github: (options: GitHubOptions) => Provider;
1637
+ type LinearOptions = SyncOptions & {
1638
+ /**
1639
+ * An OAuth application's client ID, with `clientSecret`: the sync then asks Linear for the app's own token
1640
+ * (the client-credentials grant, turned on for the app in Linear), so what it sends is written by the app
1641
+ * and not by whoever owns `token`, and no `token` is needed. `env('NAME')`.
1642
+ */
1643
+ clientId?: Secret;
1644
+ /** The application's client secret. `env('NAME')`. */
1645
+ clientSecret?: Secret;
1646
+ /** What the app's token may do. Changing it ends the app's earlier tokens in the workspace. */
1647
+ scopes?: readonly string[];
1648
+ /** The clock the app's token is kept by. */
1649
+ now?: () => number;
1650
+ /**
1651
+ * With an app (`clientId`): an issue being worked on shows the app's agent session on it, working, in place of
1652
+ * a progress message. Needs webhooks with "Agent session events" turned on for the application in Linear.
1653
+ */
1654
+ agent?: boolean;
1655
+ /**
1656
+ * The signing secret of the application's own webhook, which Linear needs set before it allows agent sessions.
1657
+ * What it sends is checked with this and answered; nothing in it is imported. `env('NAME')`.
1658
+ */
1659
+ appSecret?: Secret;
1660
+ /** The app's own user ID, so its comments aren't imported back. */
1661
+ bot?: string;
1662
+ /** A team key to a channel. Two-way unless `mirror: false`. */
1663
+ teams: Record<string, string | {
1664
+ channel: string;
1665
+ mirror?: boolean;
1666
+ }>;
1667
+ api?: string;
1668
+ };
1669
+ /** Linear: issues and comments come in as threads, and board replies go back as comments. */
1670
+ declare const linear: (options: LinearOptions) => Provider;
1671
+ /**
1672
+ * What an app's token may do unless the module says: read what comes in, and write the comments and issues that go
1673
+ * back. Anything else that asks for a token for the same app asks with these: a token asked for with other scopes ends
1674
+ * the app's earlier ones, the sync's included.
1675
+ */
1676
+ declare const LINEAR_SCOPES: readonly ["read", "write"];
1677
+ type SlackOptions = SyncOptions & {
1678
+ /** The app's own bot ID, so its messages aren't imported back. */
1679
+ bot?: string;
1680
+ /** A Slack channel ID to a board channel. Two-way unless `mirror: false`. */
1681
+ channels: Record<string, string | {
1682
+ channel: string;
1683
+ mirror?: boolean;
1684
+ }>;
1685
+ /**
1686
+ * The Slack app is declared an agent: a thread being worked on shows Slack's own "Working…" under it, in
1687
+ * place of a progress message. Needs the app's agent feature turned on in Slack, which can't be turned off again.
1688
+ */
1689
+ agent?: boolean;
1690
+ api?: string;
1691
+ now?: () => number;
1692
+ };
1693
+ /** Slack: messages in mapped channels come in as threads, and board replies go back into the Slack thread. */
1694
+ declare const slack: (options: SlackOptions) => Provider;
1695
+ type NotionOptions = SyncOptions & {
1696
+ /** The integration's own bot user ID, so what it writes isn't imported back. */
1697
+ bot?: string;
1698
+ /**
1699
+ * A Notion database to a board channel, by its data source ID (or, on an older workspace, the database's own ID),
1700
+ * with or without dashes. Two-way unless `mirror: false`.
1701
+ */
1702
+ databases: Record<string, string | {
1703
+ channel: string;
1704
+ mirror?: boolean;
1705
+ }>;
1706
+ api?: string;
1707
+ /** The `Notion-Version` its API is asked with. */
1708
+ version?: string;
1709
+ };
1710
+ /**
1711
+ * Notion: each page of a mapped database is a thread, its title and text the first message and its Status the
1712
+ * `state` label, and its comments are replies, both ways. Notion's webhooks say only what changed, so each event
1713
+ * is read from Notion's API on the ticker before it is imported. `secret` is the subscription's verification
1714
+ * token, which Notion signs every delivery with.
1715
+ */
1716
+ declare const notion: (options: NotionOptions) => Provider;
1717
+ //#endregion
1718
+ //#region src/runner/policy.d.ts
1719
+ /** One rule of a sandbox's network policy: which requests to a host pass, and what is added to them on the way out. */
1720
+ type Rule = {
1721
+ match: {
1722
+ path: string;
1723
+ method: string[];
1724
+ };
1725
+ transform: {
1726
+ headers: Record<string, string>;
1727
+ }[];
1728
+ };
1729
+ type NetworkPolicy = {
1730
+ allow: Record<string, Rule[]>;
1731
+ };
1732
+ /**
1733
+ * The network policy that hands a sandbox one board. The sandbox reaches the board's host, and on it
1734
+ * only the board's own routes; the credential is added to each request after it leaves the sandbox,
1735
+ * so nothing running inside can read it or send it anywhere else.
1736
+ */
1737
+ declare function boardPolicy(options: {
1738
+ url: string;
1739
+ token: string;
1740
+ }): {
1741
+ networkPolicy: NetworkPolicy;
1742
+ env: Record<string, string>;
1743
+ };
1744
+ /**
1745
+ * What a sandbox's proxy does with one request, for tests and for runners that enforce the policy
1746
+ * themselves: the headers to add, or null when the request doesn't pass.
1747
+ */
1748
+ declare function applyPolicy(policy: NetworkPolicy, request: {
1749
+ url: string;
1750
+ method: string;
1751
+ }): Record<string, string> | null;
1752
+ //#endregion
1753
+ //#region src/runner/cloud.d.ts
1754
+ /** What a cloud runner needs to start an agent on a task somewhere that isn't this machine. */
1755
+ type CloudRequest = {
1756
+ task: number;
1757
+ agent: Agent;
1758
+ prompt: string;
1759
+ /** The board, at a URL the sandbox can reach, and a token held to this agent's profile and channels. */
1760
+ board: {
1761
+ url: string;
1762
+ token: string;
1763
+ };
1764
+ /** The repository to work in, as a clone URL. Its credential is the platform's to add, not ours to pass. */
1765
+ repo?: string;
1766
+ permissionMode?: PermissionMode;
1767
+ /** The key for the agent's model provider. It is added to requests to that provider's host on the way out, and never enters the sandbox. */
1768
+ model?: {
1769
+ key: string;
1770
+ };
1771
+ /** More for the sandbox's environment: settings, never secrets. */
1772
+ env?: Record<string, string>;
1773
+ /** Commands that prepare the sandbox before the agent starts, such as installing the agent's CLI. */
1774
+ setup?: string[][];
1775
+ /** Install the repository's dependencies from its lockfile, with no install scripts, before the agent starts. */
1776
+ install?: boolean;
1777
+ /** A GitHub token for the repository: added to its git routes while it is cloned, before anything of it runs, and never after. */
1778
+ github?: {
1779
+ token: string;
1780
+ };
1781
+ /**
1782
+ * The branch to check out instead of the default one, and the commit it was at when this side looked: a task
1783
+ * worked before carries on from where its last round left it. A checkout that isn't at `sha` is refused.
1784
+ */
1785
+ ref?: {
1786
+ branch: string;
1787
+ sha: string;
1788
+ };
1789
+ timeoutMs?: number;
1790
+ /** Stay with the run until its agent exits and keep the sandbox to be read after (`--push`): a runner that returns at once otherwise does so. */
1791
+ attach?: boolean;
1792
+ };
1793
+ type CloudRun = {
1794
+ id: string;
1795
+ /** Closes the run's way out and removes what is left of it. */
1796
+ stop(): Promise<void>;
1797
+ /**
1798
+ * Resolves when what runs in the sandbox exits, with its exit code. It can reject on a dropped
1799
+ * connection while the run goes on, so it may be asked again. Absent where the platform can't tell.
1800
+ */
1801
+ wait?(): Promise<{
1802
+ exitCode: number | null;
1803
+ }>;
1804
+ /** How the repository's dependencies were installed, when asked: `pnpm`, `npm`, `yarn` or `bun`, `none` without a lockfile, or `failed (exit n)`. */
1805
+ installed?: string;
1806
+ /** Where the repository's checkout started: its commit and branch. */
1807
+ checkout?: {
1808
+ sha: string;
1809
+ branch: string;
1810
+ };
1811
+ /** Runs one command in the sandbox, in the checkout when there is one, and waits for it. */
1812
+ exec?(command: {
1813
+ cmd: string;
1814
+ args: string[];
1815
+ env?: Record<string, string>;
1816
+ }): Promise<{
1817
+ exitCode: number | null;
1818
+ stdout: string;
1819
+ }>;
1820
+ /** A file in the sandbox, read no further than `max` bytes: null when there is none, or it is bigger. */
1821
+ readFile?(path: string, max: number): Promise<Buffer | null>;
1822
+ /** Closes the sandbox's way out: no host is reached from it after. What a runner does besides, to end what was left running, is its own. */
1823
+ close?(): Promise<void>;
1824
+ };
1825
+ /** Starts agents in sandboxes. `local` isn't one of these: it has no network between the agent and the board. */
1826
+ type CloudRunner = {
1827
+ name: string;
1828
+ start(request: CloudRequest): Promise<CloudRun>;
1829
+ };
1830
+ /** Vercel's own network policy, as `@vercel/sandbox` 4 takes it: a path is a matcher object, and a rule can answer a request itself. */
1831
+ type VercelRule = {
1832
+ match?: {
1833
+ path?: {
1834
+ regex: string;
1835
+ };
1836
+ method?: string[];
1837
+ };
1838
+ transform: {
1839
+ headers: Record<string, string>;
1840
+ }[];
1841
+ } | {
1842
+ response: {
1843
+ statusCode: number;
1844
+ };
1845
+ };
1846
+ type VercelPolicy = {
1847
+ allow: Record<string, VercelRule[]>;
1848
+ };
1849
+ /** A Vercel access token with the team and project it is for. The SDK takes these only as arguments, never from the environment. */
1850
+ type VercelCredentials = {
1851
+ token: string;
1852
+ teamId: string;
1853
+ projectId: string;
1854
+ };
1855
+ /** A command as the SDK hands it back: finished, with its output to read, or detached, to wait on. */
1856
+ type Finished = {
1857
+ exitCode?: number | null;
1858
+ stdout?(): Promise<string>;
1859
+ logs?(): AsyncIterable<{
1860
+ stream: string;
1861
+ data: string;
1862
+ }> & {
1863
+ close?(): void;
1864
+ };
1865
+ wait?(): Promise<{
1866
+ exitCode: number | null;
1867
+ }>;
1868
+ };
1869
+ /** A commit's full ID and a branch's name, as git would never read them as an option. */
1870
+
1871
+ /** A sandbox as the SDK hands it back. */
1872
+ type VercelMade = {
1873
+ sandboxId?: string;
1874
+ name?: string;
1875
+ /** A finished command has its `exitCode`; a detached one can be waited on. Older stand-ins return nothing. */
1876
+ runCommand(command: {
1877
+ cmd: string;
1878
+ args: string[];
1879
+ env?: Record<string, string>;
1880
+ detached?: boolean;
1881
+ cwd?: string;
1882
+ }): Promise<Finished | void>;
1883
+ /** A file in the sandbox, as a stream, or null when there is none. */
1884
+ readFile?(file: {
1885
+ path: string;
1886
+ }): Promise<NodeJS.ReadableStream | null>;
1887
+ /** Replaces a running sandbox's policy. Used to close the hosts that only its setup needed. */
1888
+ update?(options: {
1889
+ networkPolicy: VercelPolicy | 'deny-all';
1890
+ }): Promise<unknown>;
1891
+ stop(): Promise<unknown>;
1892
+ /** Removes the sandbox and what it kept. */
1893
+ delete?(): Promise<unknown>;
1894
+ };
1895
+ type Made = VercelMade;
1896
+ /** What a new sandbox is made with. */
1897
+ type CreateOptions = {
1898
+ networkPolicy: VercelPolicy;
1899
+ image?: string;
1900
+ persistent?: boolean;
1901
+ env: Record<string, string>;
1902
+ timeout?: number;
1903
+ name?: string;
1904
+ source?: {
1905
+ type: 'git';
1906
+ url: string;
1907
+ revision?: string;
1908
+ };
1909
+ } & Partial<VercelCredentials>;
1910
+ /** The part of `@vercel/sandbox` this runner uses, so it can be handed the real class or a stand-in. */
1911
+ type VercelSandbox = {
1912
+ create(options: CreateOptions): Promise<Made>;
1913
+ /** A new sandbox from a stopped, kept one: what was saved in it is there. */
1914
+ fork?(options: Omit<CreateOptions, 'source' | 'image' | 'name'> & {
1915
+ sourceSandbox: string;
1916
+ }): Promise<Made>;
1917
+ /** A sandbox by its name. */
1918
+ get?(options: {
1919
+ name: string;
1920
+ } & Partial<VercelCredentials>): Promise<{
1921
+ status?: string;
1922
+ delete?(): Promise<unknown>;
1923
+ }>;
1924
+ };
1925
+ /**
1926
+ * Where the bases this machine made are written down: a name for each kind of base, by key. A base is
1927
+ * forked only when it is in here, so a sandbox someone else made under a name like it is never trusted.
1928
+ */
1929
+ type BaseRecord = {
1930
+ get(key: string): string | undefined;
1931
+ set(key: string, name: string): void;
1932
+ entries(): [string, string][];
1933
+ forget(name: string): void;
1934
+ };
1935
+ /**
1936
+ * `setupHosts` are open while the setup commands run, which are ours, and closed before the agent
1937
+ * starts. `allowHosts` stay open to the agent, so each one is a way out of the sandbox: add few.
1938
+ */
1939
+ declare function vercel(options: {
1940
+ Sandbox: VercelSandbox;
1941
+ allowHosts?: Record<string, never[]>;
1942
+ setupHosts?: string[];
1943
+ image?: string;
1944
+ credentials?: VercelCredentials;
1945
+ base?: boolean;
1946
+ bases?: BaseRecord;
1947
+ }): CloudRunner;
1948
+ /**
1949
+ * Runs an agent in a Cloudflare container, through a Worker you deploy (templates/cloudflare-runner).
1950
+ * The Worker holds the board's token and adds it to the container's outbound requests; this client
1951
+ * only asks the Worker to start and stop runs.
1952
+ */
1953
+ declare function cloudflare(options: {
1954
+ worker: string;
1955
+ secret: string;
1956
+ fetch?: typeof fetch;
1957
+ pollMs?: number;
1958
+ }): CloudRunner;
1959
+ //#endregion
1960
+ //#region src/runner/e2b.d.ts
1961
+ /**
1962
+ * A sandbox's way out, as E2B takes it. A rule is for a host and can only add headers to what goes to
1963
+ * it: there is no matching a path or a method, and no answering a request. So what a credential may be
1964
+ * used for on its host is not decided here, and has to be decided by whoever takes it.
1965
+ */
1966
+ type E2bNetwork = {
1967
+ allowOut?: string[];
1968
+ denyOut?: string[];
1969
+ rules?: Record<string, {
1970
+ transform: {
1971
+ headers: Record<string, string>;
1972
+ };
1973
+ }[]>;
1974
+ };
1975
+ /** A command that ended, or one still running that can be waited on. A command that exits with anything but 0 is thrown, not returned. */
1976
+ type E2bResult = {
1977
+ exitCode?: number;
1978
+ stdout?: string;
1979
+ };
1980
+ type E2bHandle = E2bResult & {
1981
+ pid?: number;
1982
+ wait?(): Promise<E2bResult>;
1983
+ };
1984
+ /** A sandbox as the `e2b` package hands it back. */
1985
+ type E2bMade = {
1986
+ sandboxId: string;
1987
+ commands: {
1988
+ run(cmd: string, options?: {
1989
+ cwd?: string;
1990
+ envs?: Record<string, string>;
1991
+ user?: string;
1992
+ timeoutMs?: number;
1993
+ background?: boolean;
1994
+ }): Promise<E2bHandle>;
1995
+ /** A command that is still running, by its process ID, to wait on again after a connection to it was lost. */
1996
+ connect?(pid: number, options?: {
1997
+ timeoutMs?: number;
1998
+ }): Promise<E2bHandle>;
1999
+ };
2000
+ files: {
2001
+ read(path: string, options: {
2002
+ format: 'stream';
2003
+ }): Promise<AsyncIterable<Uint8Array>>;
2004
+ };
2005
+ /** Replaces the whole of the sandbox's way out: what is left out is cleared. */
2006
+ updateNetwork(network: E2bNetwork): Promise<unknown>;
2007
+ /** Keeps the sandbox as it is now, to start others from. */
2008
+ createSnapshot?(): Promise<{
2009
+ snapshotId: string;
2010
+ }>;
2011
+ kill(): Promise<unknown>;
2012
+ };
2013
+ /** How the SDK is told which account, and which E2B: its own cloud, or one you run. */
2014
+ type E2bConnection = {
2015
+ apiKey: string;
2016
+ domain?: string;
2017
+ };
2018
+ /** The part of the `e2b` package this runner uses, so it can be handed the real one or a stand-in. */
2019
+ type E2bSdk = {
2020
+ Sandbox: {
2021
+ /** A new sandbox from a template, or from a snapshot by its ID: either way with its own environment and way out. */
2022
+ create(template: string, options: E2bConnection & {
2023
+ envs: Record<string, string>;
2024
+ timeoutMs: number;
2025
+ network: E2bNetwork;
2026
+ metadata?: Record<string, string>;
2027
+ }): Promise<E2bMade>;
2028
+ deleteSnapshot?(snapshotId: string, options: E2bConnection): Promise<unknown>;
2029
+ };
2030
+ Secret: {
2031
+ create(name: string, value: string, options: E2bConnection & {
2032
+ metadata?: Record<string, string>;
2033
+ }): Promise<unknown>;
2034
+ destroy(name: string, options: E2bConnection): Promise<unknown>;
2035
+ list(options: E2bConnection): {
2036
+ hasNext: boolean;
2037
+ nextItems(): Promise<{
2038
+ name: string;
2039
+ createdAt: Date | string;
2040
+ metadata?: Record<string, string>;
2041
+ }[]>;
2042
+ };
2043
+ /** What stands for a stored secret in a header: E2B puts the value in its place on the way out. */
2044
+ fill(name: string): string;
2045
+ };
2046
+ };
2047
+ /**
2048
+ * Runs an agent in an E2B sandbox. The board's token and the model's key are stored with E2B as secrets
2049
+ * for the length of the run, and E2B adds them to the sandbox's requests on the way out, so the agent's
2050
+ * environment holds placeholders. E2B adds a credential to every request to its host, whatever the path:
2051
+ * the board therefore has to hold the token to a sandbox's routes itself (a token made with `sandbox`),
2052
+ * and a model key can be used for anything its provider's API offers, which is asked for by name.
2053
+ *
2054
+ * `setupHosts` are open while the setup commands run, which are ours, and closed before the agent
2055
+ * starts. `allowHosts` stay open to the agent, so each one is a way out of the sandbox: add few.
2056
+ *
2057
+ * With `base`, the setup runs once per template and version of it: its result is kept as a snapshot, with no
2058
+ * credential, repository or environment in it, and each run starts from that. A run uses only a snapshot
2059
+ * written down in `bases`, which this machine made.
2060
+ */
2061
+ declare function e2b(options: {
2062
+ sdk: E2bSdk;
2063
+ apiKey: string;
2064
+ domain?: string;
2065
+ template: string;
2066
+ allowHosts?: string[];
2067
+ setupHosts?: string[];
2068
+ keyAnyPath?: boolean;
2069
+ modelSecret?: string;
2070
+ base?: boolean;
2071
+ bases?: BaseRecord;
2072
+ now?: () => number;
2073
+ }): CloudRunner;
2074
+ //#endregion
2075
+ //#region src/daemon/workflows.d.ts
2076
+ type WorkflowStep = {
2077
+ key: string;
2078
+ text: string;
2079
+ needs?: string[];
2080
+ for?: string;
2081
+ labels?: Record<string, string>;
2082
+ push?: boolean;
2083
+ title?: string;
2084
+ };
2085
+ type Workers = {
2086
+ count: number;
2087
+ agent: 'claude' | 'codex';
2088
+ as: string;
2089
+ runner?: 'local' | 'vercel' | 'cloudflare' | 'e2b';
2090
+ repo?: string;
2091
+ push?: boolean;
2092
+ cwd?: string;
2093
+ timeout?: string;
2094
+ };
2095
+ type Workflow = {
2096
+ name: string;
2097
+ description: string;
2098
+ who: string[];
2099
+ channels: string[];
2100
+ steps: WorkflowStep[];
2101
+ workers: Workers;
2102
+ timeout?: string;
2103
+ };
2104
+ declare const workflowsPath: () => string;
2105
+ /**
2106
+ * The operator's registered workflows: named plans of steps for a crew of workers. Like watchers and
2107
+ * hooks they come from this file and never from a board, so nothing written to one can register one.
2108
+ * A file that is missing means none; one that is wrong is a config error.
2109
+ */
2110
+ declare function loadWorkflows(path?: string): Workflow[];
2111
+ //#endregion
2112
+ //#region src/daemon/steps.d.ts
2113
+ /**
2114
+ * A workflow step's result, for code that goes on from it (a board module's watcher, say): only when the
2115
+ * daemon made the task, as `<owner>+workflows`, and the run's own worker completed it, as a step's result is
2116
+ * checked before it is quoted into the next step. With it, the run it belongs to: the workflow and step as
2117
+ * the daemon made them, and the thread and message the run was asked on, from the board's record of the
2118
+ * request. Null for anything else: a task someone else made, one an agent completed with its sandbox's
2119
+ * token, one not completed. Labels count for nothing here, so a relabelled task is read as it was made.
2120
+ */
2121
+ declare function workflowResult(team: Board, id: number, owner: string): Promise<{
2122
+ workflow: string;
2123
+ step: string;
2124
+ request: number;
2125
+ thread: number;
2126
+ on: number;
2127
+ result: string | null;
2128
+ } | null>;
2129
+ //#endregion
2130
+ //#region src/daemon/runs.d.ts
2131
+ /**
2132
+ * Text someone else wrote, set apart in a task under a line that says whose it is: defused, cut at
2133
+ * THREAD_TEXT characters, and in a fence longer than any run of backticks inside, so nothing in it can
2134
+ * close the fence and read as the operator's instructions. `{thread.text}` and `{steps.<key>.result}` both use it.
2135
+ */
2136
+ declare function fenced(whose: string, text: string): string;
2137
+ //#endregion
2138
+ export { AGENTS, type Agent, type Argv, type Attachment, type Backend, type Block, type Board, type BoardEvent, type BoardOptions, type By, type Caller, type Check, type Claims, type CloudRequest, type CloudRunner, type CommandOptions, type DeclaredHook, type DeclaredSync, type DeclaredWatcher, type Delivered, type Duration, type E2bSdk, type Env, type ExitKind, Failure, type FeedEvent, type FileOptions, type Filter, type GitHubOptions, type HookOptions, type Host, type HttpOptions, type Inbound, LINEAR_SCOPES, type LinearOptions, type Message, type NetworkPolicy, type NotionOptions, type Permission, type PlanTask, type Provider, type RunRequest, type RunResult, SANDBOX_ROUTES, type Secret, type SlackOptions, type StartOptions, type SyncOptions, type Task, type TaskListing, type TaskState, type ThreadSummary, type Watch, type WatchContext, type WatchEvent, type Workers, type Workflow, type WorkflowStep, agentEnv, applyPolicy, board, boardKey, boardPath, boardPolicy, claude, cloudflare, codex, command, conformance, createHandler, e2b, env, fenced, file, generic, github, http, linear, listen, loadWorkflows, mint, notion, runLocal, slack, vercel, verify, workflowResult, workflowsPath };