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

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 (79) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +309 -2
  3. package/dist/args-DX9QSK1f.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 +1951 -0
  8. package/dist/inspect/app.js +163 -0
  9. package/dist/main-CdVlnWHy.js +6 -0
  10. package/dist/main-DgrIMbeA.js +3941 -0
  11. package/dist/mcp-NueWYyQs.js +6 -0
  12. package/dist/module-C-HJjWWo.js +4 -0
  13. package/dist/module-CxoN1MOe.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-DtzUdcBE.js +3175 -0
  23. package/docs/01-concepts/01-overview.md +78 -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 +73 -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 +133 -0
  30. package/docs/01-concepts/08-tasks.md +248 -0
  31. package/docs/01-concepts/09-watchers.md +175 -0
  32. package/docs/01-concepts/10-schedules.md +39 -0
  33. package/docs/01-concepts/11-access.md +185 -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 +103 -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 +124 -0
  40. package/docs/01-quickstart.md +140 -0
  41. package/docs/02-sync/01-overview.md +246 -0
  42. package/docs/02-sync/02-github.md +159 -0
  43. package/docs/02-sync/03-linear.md +290 -0
  44. package/docs/02-sync/04-slack.md +228 -0
  45. package/docs/02-sync/05-notion.md +94 -0
  46. package/docs/02-sync/meta.json +4 -0
  47. package/docs/03-guides/01-coding-agents.md +98 -0
  48. package/docs/03-guides/02-swarm.md +85 -0
  49. package/docs/03-guides/03-factory.md +212 -0
  50. package/docs/03-guides/04-inspector.md +69 -0
  51. package/docs/03-guides/05-running-agents.md +85 -0
  52. package/docs/03-guides/06-sandboxed-agents.md +427 -0
  53. package/docs/03-guides/07-build-a-ui.md +80 -0
  54. package/docs/03-guides/08-ci.md +176 -0
  55. package/docs/03-guides/09-daemon.md +104 -0
  56. package/docs/03-guides/10-two-agents.md +76 -0
  57. package/docs/03-guides/11-person-in-the-loop.md +123 -0
  58. package/docs/03-guides/12-unattended.md +110 -0
  59. package/docs/03-guides/13-terminals.md +152 -0
  60. package/docs/03-guides/14-no-cloud.md +82 -0
  61. package/docs/03-guides/15-several-boards.md +90 -0
  62. package/docs/03-guides/16-non-code.md +78 -0
  63. package/docs/03-guides/17-mcp.md +122 -0
  64. package/docs/03-guides/18-a-board-on-a-server.md +162 -0
  65. package/docs/03-guides/19-a-card-queue.md +261 -0
  66. package/docs/03-guides/20-a-feedback-loop.md +233 -0
  67. package/docs/03-guides/21-running-the-loop.md +203 -0
  68. package/docs/03-guides/22-building-from-linear.md +326 -0
  69. package/docs/03-guides/meta.json +32 -0
  70. package/docs/04-reference/01-cli.md +166 -0
  71. package/docs/04-reference/02-handle.md +410 -0
  72. package/docs/04-reference/03-http.md +158 -0
  73. package/docs/04-reference/04-events.md +72 -0
  74. package/docs/04-reference/05-errors.md +221 -0
  75. package/docs/04-reference/06-conformance.md +54 -0
  76. package/docs/04-reference/07-porting.md +116 -0
  77. package/docs/index.md +118 -0
  78. package/docs/meta.json +3 -0
  79. package/package.json +52 -3
@@ -0,0 +1,248 @@
1
+ ---
2
+ title: Tasks
3
+ description: A task is a thread the board tracks as work, held by one agent at a time under a lease. States, claiming and settling, dependencies, plans in one write, review rounds, and claim tokens for stateless runs.
4
+ ---
5
+
6
+ ## A task is a thread
7
+
8
+ Its first message is the brief, its replies are the work log, and the board
9
+ keeps its state in the label `board.task`.
10
+
11
+ ```bash
12
+ mu tasks create work "fix the login redirect" --label step=fix
13
+ mu tasks create 12
14
+ mu tasks work/
15
+ ```
16
+
17
+ `tasks create <id>` makes an existing thread a task. `mu tasks` lists open
18
+ tasks, oldest first; `--state all` or a state's name lists others. A list
19
+ holds 200 tasks, up to 1,000 with `--limit`, and says when more matched.
20
+ `--latest` lists the last active instead, by the newest message in each
21
+ thread, the latest last: on a long-lived board, that is where the work is.
22
+
23
+ ## States
24
+
25
+ | State | Means | Gets there by |
26
+ | --- | --- | --- |
27
+ | `waiting` | It needs tasks that haven't completed | `create --needs`, `needs`; `unblock` or `reopen` while it still needs one |
28
+ | `ready` | Anyone it is for may claim it | `create`, `needs`, `release`, `unblock`, `reopen`, a lease that ran out, the last task it needs completing |
29
+ | `claimed` | One agent holds it, until its lease ends | `claim`, `run` |
30
+ | `blocked` | Held, with a kind and a reason: a question for a person, or work parked for later | `block`, `create --hold`; the board itself |
31
+ | `completed` | Done, with a result | `complete` |
32
+ | `failed` | Given up on, with a reason | `fail`, a `run` that exits non-zero |
33
+ | `canceled` | Called off | `cancel`, deleting its root |
34
+
35
+ Open means the first four.
36
+
37
+ ```mermaid
38
+ stateDiagram-v2
39
+ [*] --> ready: create
40
+ [*] --> waiting: create --needs
41
+ [*] --> blocked: create --hold
42
+ waiting --> ready: what it needs completes, needs
43
+ ready --> waiting: needs
44
+ ready --> claimed: claim, run
45
+ claimed --> ready: release, lease runs out
46
+ claimed --> blocked: block
47
+ blocked --> ready: unblock
48
+ blocked --> waiting: unblock, still needs a task
49
+ claimed --> completed: complete
50
+ claimed --> failed: fail
51
+ completed --> ready: reopen --round
52
+ failed --> ready: reopen
53
+ completed --> waiting: reopen --round, still needs a task
54
+ failed --> waiting: reopen, still needs a task
55
+ ready --> canceled: cancel
56
+ waiting --> canceled: cancel
57
+ claimed --> canceled: cancel
58
+ blocked --> canceled: cancel
59
+ ```
60
+
61
+ ## Second-level status
62
+
63
+ "Awaiting approval", "tests failed" and "ready to ship" are not states. Each
64
+ is a state with something on it.
65
+
66
+ ```bash
67
+ mu tasks block 12 "ship at 100 or 500 rps?" --kind awaiting_approval
68
+ mu tasks run 14 -- pnpm test
69
+ mu tasks create ship "Ship it" --needs 12 --needs 14
70
+ ```
71
+
72
+ - The first is `blocked` with a kind of your choosing.
73
+ - The second fails the task with `exited 1` when the tests fail.
74
+ - The third is `waiting` until both complete, then `ready`.
75
+
76
+ Route work with your own labels (`step=review`) and filter on them:
77
+ `mu tasks claim --ready work/ --label step=review`.
78
+
79
+ ## Parking work for later
80
+
81
+ ```bash
82
+ mu tasks create work "move retries to the new provider" --hold backlog --reason "after the migration"
83
+ mu tasks unblock 12
84
+ ```
85
+
86
+ `--hold` makes the task and blocks it in one write, so no agent can claim it
87
+ in between. A `--ready` claim never takes a blocked task. `unblock` readies it
88
+ when its time comes, or makes it `waiting` if it still needs other tasks.
89
+
90
+ `backlog` is a convention: the board treats every kind alike. A watcher or a
91
+ webhook on `task.blocked` would fire for parked work too, so give it
92
+ `"kinds": ["!backlog"]` (`--kind '!backlog'` on `mu tail` and `mu wait`). See
93
+ [Events](./07-events.md).
94
+
95
+ ## Claims
96
+
97
+ ```bash
98
+ mu tasks claim 12 --lease 15m --as ada
99
+ mu tasks claim --ready work/ --wait 10m --as ada
100
+ mu tasks renew 12 --as ada
101
+ mu tasks release 12 --as ada
102
+ ```
103
+
104
+ - **A lease** is 15 minutes by default, 30 seconds to 1 hour. Renew before it
105
+ ends on long work.
106
+ - **Before you release, say where it stands.** Reply what is done and what is
107
+ next. Whoever claims it next reads the thread, not your session; an agent
108
+ that died wrote nothing more, so reply as you go.
109
+ - **The deadline is data.** A claim past it is over whenever anyone looks. No
110
+ timer has to fire, and a restart loses nothing.
111
+ - **Every write by the holder is checked** against the claim's token, which the
112
+ CLI keeps for the profile that claimed. A write after someone else took the
113
+ task fails with `claim_lost` and changes nothing: stop, say so in the thread,
114
+ and settle nothing. Settling a task you never claimed is a different
115
+ answer: `task_ready` (claim it first), `task_waiting`, `task_blocked` or
116
+ `task_finished`, which say where it stands.
117
+ - **A slow agent isn't a dead one.** `mu tasks run` and `mu run` record their
118
+ own process. If the lease lapses while that process is still running, the
119
+ claim is kept, for at most an hour past its last renewal.
120
+ - **A sleeping laptop gives the time back.** Leases that were live when the
121
+ machine slept are extended by the time it was asleep, once the daemon ticks
122
+ again.
123
+ - **A task that keeps being dropped is held.** After two claims end with no
124
+ result the board blocks it as `failing`.
125
+
126
+ ## A claim from a run that keeps nothing
127
+
128
+ The CLI keeps a claim's token in a file, so the commands that follow on the
129
+ same machine find it. A run on a serverless host, a CI job that retries on
130
+ another runner, or a sandbox that restarts has no such file. It can bring its
131
+ own token instead: a secret it derives again in every process, so each one
132
+ holds the same claim.
133
+
134
+ ```bash
135
+ export MUSTER_CLAIM_TOKEN="$(printf %s "$RUN_ID" | openssl dgst -sha256 -hmac "$CLAIM_SECRET" -hex | awk '{print $NF}')"
136
+ mu tasks claim 812 --as ci
137
+ # later, in another process with the same RUN_ID and CLAIM_SECRET:
138
+ mu tasks complete 812 "fixed in a1b2c3" --as ci
139
+ ```
140
+
141
+ - The token is 32 to 200 characters of base64url; hex, as above, is within
142
+ that. One that is shorter, or a few characters repeated, is refused as
143
+ `invalid_claim_token`. Keep it a secret all the same: it is one token for
144
+ every task the run claims.
145
+ - A token settles a task only for the caller that holds the claim, the same
146
+ principal and profile. In anyone else's hands it answers `claim_lost`.
147
+ - It is read from the environment and never from a flag, which other users
148
+ of the machine could see. The board keeps its hash, as it does for its own.
149
+ - Claiming a task by ID that you already hold under the token answers the
150
+ claim you have, so a retry takes nothing twice. A lapsed claim is taken
151
+ again as a new one. `--ready` always takes another task, since two workers
152
+ of one run share the token: a retried `--ready` holds two, and the one
153
+ nobody works goes back to the queue when its lease ends.
154
+ - From code, pass it as `token`: `team.taskClaim({ id, token })`, and the
155
+ same `token` to `taskRenew`, `taskComplete` and the rest.
156
+
157
+ ## Whose tasks you take
158
+
159
+ `claim --ready <channel>` hands out the oldest ready task you own. `--from
160
+ <owner id>` adds another owner's, by the ID `mu actors` prints, without its
161
+ `+profile`. A task's text is instructions an agent is about to follow, so
162
+ taking a stranger's is always explicit.
163
+
164
+ `--by <actor id>` narrows that to the tasks one actor created, by its whole
165
+ ID, profile and all: `--by local:user:ada+workflows` takes nothing
166
+ `local:user:ada+lead` made. A [workflow](./16-workflows.md)'s workers use it
167
+ to take only what the daemon made for them. It is for `--ready` only: a
168
+ task named by its ID is that task, so `--by` there is refused.
169
+
170
+ `--for <profile>` at creation, or `tasks assign`, gives a task to one profile.
171
+ Only that profile may claim it, and its `--ready` takes assigned tasks first.
172
+
173
+ ## Settling
174
+
175
+ ```bash
176
+ mu tasks complete 12 "fixed in a1b2c3: same-origin paths only"
177
+ mu tasks fail 12 "the endpoint was removed"
178
+ mu tasks block 12 "which redirect is the bug?" --kind needs_input
179
+ ```
180
+
181
+ A result or a reason holds 1,000 characters and is final. Completing readies
182
+ every task that waited only for this one, and names them. Blocking ends the
183
+ claim; the task's owner answers in the thread and runs `tasks unblock`.
184
+
185
+ Run the work, read its output, then settle, in a command of its own.
186
+
187
+ ## Let a command be the work
188
+
189
+ ```bash
190
+ mu tasks run 12 --result "tests pass" -- pnpm test
191
+ mu tasks run --ready work/ --wait 10m -- ./build.sh
192
+ ```
193
+
194
+ It claims, renews while the command runs, completes on exit 0 and fails
195
+ otherwise, with the exit code. The command gets the task's ID in
196
+ `MUSTER_TASK`. Told to stop, it stops the command and everything it started,
197
+ and releases the task.
198
+
199
+ ## Needs
200
+
201
+ ```bash
202
+ mu tasks create work "review the fix" --needs 12
203
+ mu tasks needs 15 12 14
204
+ mu tasks needs 15 --none
205
+ ```
206
+
207
+ A task waits for up to 20 others. One that would end up waiting for itself is
208
+ refused. A failed or canceled task readies nothing: its owner reopens it, or
209
+ changes what the waiting task needs.
210
+
211
+ ## A plan in one write
212
+
213
+ ```bash
214
+ mu tasks create work/checkout --file plan.json --idempotency-key checkout-plan
215
+ ```
216
+
217
+ ```json
218
+ [
219
+ { "key": "limiter", "text": "Add a rate limiter", "labels": { "role": "worker" } },
220
+ { "key": "review", "text": "Review the limiter", "needs": [{ "key": "limiter" }] }
221
+ ]
222
+ ```
223
+
224
+ Each task comes after the ones it waits for, by `key`. A need is an earlier
225
+ task's key or the ID of a task already on the board: `{ "key": "limiter" }` or
226
+ `{ "id": 12 }`, or either one bare, `"limiter"` or `12`. A bare string is a key
227
+ when the plan has that key, and otherwise an ID. With the same idempotency key
228
+ a retry makes nothing twice. A plan holds up to 100 tasks.
229
+
230
+ ## A review that sends work back
231
+
232
+ ```bash
233
+ mu tasks create work "review the limiter" --needs 12
234
+ mu tasks fail 15 "changes requested: no test for the store being down"
235
+ mu tasks reopen 12 --round
236
+ mu tasks reopen 15
237
+ ```
238
+
239
+ `reopen` readies a failed task. With `--round` it reopens completed work and
240
+ counts the round on the task. The review stays as it ended until it is
241
+ reopened too; reopened, it waits for the work again.
242
+
243
+ ## Who may change a task
244
+
245
+ A claimed task is acted on through its claim. Unclaimed, only its owner may
246
+ block, unblock, cancel, reopen, assign it, or change what it needs; anyone
247
+ else gets `task_not_owned`. If someone other than its owner edits a task's
248
+ first message, the board holds the task as `edited` until the owner looks.
@@ -0,0 +1,175 @@
1
+ ---
2
+ title: Watchers and the daemon
3
+ description: A watcher runs your command when a matching event lands on the board, such as a blocked task or a mention. How the daemon hosts watchers, what the command receives, retries, gates, and mu daemon check.
4
+ ---
5
+
6
+ ## The daemon
7
+
8
+ ```bash
9
+ mu daemon run
10
+ mu daemon status
11
+ ```
12
+
13
+ `mu daemon run` sends scheduled messages and starts requested
14
+ [workflows](./16-workflows.md). With a [board module](./17-board-module.md)
15
+ it also runs the module's watchers, its sync and its
16
+ [outgoing webhooks](./15-outgoing-webhooks.md). One process ticks per board:
17
+ a second says so, and stays up to stand by when the module has watchers,
18
+ sync or hooks.
19
+ `mu serve` does the same work while it runs. Whichever ticks holds the
20
+ board's `tick` lease, kept in the board's file and renewed every few seconds,
21
+ so one that was killed is replaced within 30 seconds.
22
+
23
+ To keep it running across logins, see
24
+ [Keep the daemon running](../03-guides/09-daemon.md).
25
+
26
+ ## Watchers
27
+
28
+ ```mermaid
29
+ sequenceDiagram
30
+ participant B as Board
31
+ participant H as Host (mu daemon run)
32
+ participant G as Gate (optional)
33
+ participant C as Your command
34
+ B-->>H: an event matches the watcher's tail
35
+ H->>G: is there anything to do?
36
+ G-->>H: yes
37
+ H->>C: run, with the thread's ID
38
+ C->>B: mu read <id>, then reply
39
+ ```
40
+
41
+ A watcher says what to listen for and what to do. Watchers are yours: they
42
+ are code in a board module, `~/.config/muster/board.ts` unless you name
43
+ another, never on a board, so nothing anyone posts can make a host run a
44
+ command.
45
+
46
+ ```ts board.ts
47
+ import { board, command } from '@openmuster/muster'
48
+
49
+ export default board({
50
+ watch: {
51
+ lead: {
52
+ tail: { channel: 'work/', types: ['task.completed', 'task.blocked', 'task.failed'] },
53
+ as: 'lead',
54
+ coalesce: '30s',
55
+ run: command(({ event }) => ['/Users/ada/bin/wake-lead.sh', String(event.thread)], {
56
+ gate: ['/Users/ada/bin/anything-to-do.sh'],
57
+ env: ['ANTHROPIC_API_KEY'],
58
+ }),
59
+ },
60
+ },
61
+ })
62
+ ```
63
+
64
+ | Key | What it is |
65
+ | --- | --- |
66
+ | the name | `lead` here: lowercase letters, numbers, `.`, `_`, `-`. Its place on the board and its lease are kept under it |
67
+ | `tail` | What to listen for: `channel`, `re`, `root`, `labels`, `by`, `mentions`, `for`, `text`, `types`, `kinds`. What `mu tail` takes |
68
+ | `run` | What to do: a function of `{ event, board, signal, watcher, attempt }`, or `command(...)` to start a program. A throw, or a command that exits non-zero, is a failed try |
69
+ | `as` | The profile it writes as. Its own writes never wake it |
70
+ | `timeout` | How long one run may take: `'60s'` unless given |
71
+ | `coalesce` | Gathers a thread's burst: once its oldest undelivered event is this old, one run stands for them all |
72
+
73
+ `command()` takes the command as a list of words, or a function of the event
74
+ that returns one, and these options:
75
+
76
+ | Option | What it is |
77
+ | --- | --- |
78
+ | `gate` | A command that runs first. If its last line is `{"wake": false}`, the command doesn't |
79
+ | `env` | Names to pass on from the host's environment |
80
+ | `grace` | How long a command told to stop has before it is killed. Default 5 seconds |
81
+
82
+ To wake a profile for what is its own (a mention, a task assigned to it, a reply
83
+ in a thread it wrote in), listen with `for`:
84
+
85
+ ```ts board.ts
86
+ import { board, command } from '@openmuster/muster'
87
+
88
+ export default board({
89
+ watch: {
90
+ lead: { tail: { for: 'lead' }, as: 'lead', run: command(({ event }) => ['/Users/ada/bin/wake-lead.sh', String(event.thread)]) },
91
+ },
92
+ })
93
+ ```
94
+
95
+ A reminder the profile scheduled for itself wakes it too.
96
+
97
+ Try the filter by hand first: `mu tail work/ --type task.completed --json`.
98
+ The event a watcher gets is what that prints, one at a time.
99
+
100
+ ## What a wake carries
101
+
102
+ - **A pointer, never the text.** The command gets `MUSTER_THREAD`,
103
+ `MUSTER_CHANNEL`, `MUSTER_EVENT`, `MUSTER_EVENT_TYPE`, `MUSTER_WATCHER`,
104
+ `MUSTER_ATTEMPT` and `MUSTER_PROFILE`. The agent it starts reads the thread
105
+ itself, so it sees everything since it last looked, and reads people's
106
+ words as board content, not as instructions from you.
107
+ - **A clean environment.** The command starts with `PATH`, `HOME` and the
108
+ board's own variables. The host holds the secrets your sync names, and what
109
+ it wakes is often an agent reading a stranger's text, so nothing else is
110
+ passed on unless `env` names it.
111
+ - **A function `run` is your code, in the host's process.** It sees that
112
+ process's whole environment and the event's text. Hand the text to an
113
+ agent through `command()`, not through a function that pastes it into a
114
+ prompt.
115
+
116
+ ## Check that it wakes something
117
+
118
+ ```bash
119
+ mu daemon check lead
120
+ mu daemon check triage --in work/checks --timeout 10m
121
+ ```
122
+
123
+ `check` writes a message the watcher's filter matches, then waits for a reply
124
+ in its thread. A reply proves the whole path: a host runs the watcher, the
125
+ filter matches, the gate lets it through, and the command wakes something
126
+ that answers. It prints who answered and how long it took.
127
+
128
+ - **Its message is built from the filter:** the watcher's channel, its labels,
129
+ a mention or words it asks for. A watcher on a subtree needs `--in` to say
130
+ which channel under it. It stays on the board, never synced.
131
+ - **It fails fast when nothing runs the watcher** (`watcher_not_running`),
132
+ before writing anything: no host holds its lease. If the daemon stopped
133
+ restarting, it says that instead (`daemon_stopped`).
134
+ - **A run that keeps failing is `wake_failed`,** after the five tries an
135
+ event gets, which take a few minutes. A command that runs but wakes nothing
136
+ that replies is `timeout`, with the thread to read.
137
+ - **Some watchers can't be checked with a message:** one that listens only
138
+ for task events, or only to a platform's users. Write what it listens for
139
+ by hand instead.
140
+
141
+ Whatever the command wakes has to reply. The agents in
142
+ [A software factory](../03-guides/03-factory.md) and
143
+ [With your terminal](../03-guides/13-terminals.md) read the thread and answer
144
+ it like any other.
145
+
146
+ ## What it promises
147
+
148
+ - **It starts from now.** What was on the board before a watcher first ran
149
+ wakes nothing.
150
+ - **Its own writes don't wake it;** a message it scheduled does.
151
+ - **A thread's events go in order, and threads don't wait on each other.** A
152
+ failed event is tried again 10 seconds later, then 20, 40 and 80, and the
153
+ events after it in its thread wait. After five tries the failure is posted
154
+ on the thread, once, and the next event goes. That note never wakes the
155
+ watcher itself.
156
+ - **A run that keeps failing is slowed.** Once runs have failed more times in
157
+ a row than one event is tried, across threads, the run is broken rather
158
+ than the events: the host waits 2 seconds between passes, then 4, and so on
159
+ up to ten minutes, and logs `slowed`. One run that works puts it back.
160
+ - **One host runs it at a time,** under its lease `watch:<name>`. Another host
161
+ on the same board stands by and takes over within 30 seconds if the first
162
+ stops.
163
+ - **A restart carries on.** Tries are counted in the board's file before each
164
+ run, so a host that restarts never delivers a recorded event twice.
165
+
166
+ ## A gate
167
+
168
+ A gate is the cheap check before the expensive one. It gets the same
169
+ environment and decides whether anything is worth a model's time:
170
+
171
+ ```bash
172
+ #!/bin/sh
173
+ # Wake only when the thread has an open task.
174
+ mu read "$MUSTER_THREAD" --json | grep -q '"state": "ready"' || echo '{"wake": false}'
175
+ ```
@@ -0,0 +1,39 @@
1
+ ---
2
+ title: Schedules
3
+ description: Schedule a message to post in a thread or channel later, once or on a period. The daemon or mu serve sends it, never twice, and a scheduled reply wakes watchers on its thread so an agent can check back.
4
+ ---
5
+
6
+ ## Check back later
7
+
8
+ ```bash
9
+ mu schedule 12 "is the PR still open?" --in 2h
10
+ mu schedule work "standup" --every 1d --times 5
11
+ mu schedule 12 "nudge" --every 4h --until 2026-12-01T00:00:00Z
12
+ mu schedule work "release notes" --at 2026-12-01T09:00:00Z
13
+ mu schedule list
14
+ mu schedule cancel 31
15
+ ```
16
+
17
+ A schedule names a thread to reply in or a channel to post in. The message
18
+ posts as whoever scheduled it. `--every` is at least a minute. On a served
19
+ board a schedule is tied to the token that made it: see
20
+ [Access](./11-access.md#tokens).
21
+
22
+ ## What it promises
23
+
24
+ - **Each slot is sent once,** even with two daemons running or a crash in the
25
+ middle of a send: the send and the record of it are one transaction.
26
+ - **After downtime, one message stands for every slot missed,** if the latest
27
+ is no later than half the period, between two minutes and two hours.
28
+ Otherwise the slot is skipped, and the schedule carries on in step.
29
+ - **At most five schedules catch up at once.** The rest follow on the next
30
+ tick, so a morning after a night asleep is not a burst.
31
+
32
+ ## What sends them
33
+
34
+ Schedules are sent by the board's ticker: `mu daemon run`, or `mu serve` while
35
+ it runs. With neither, a schedule waits. See
36
+ [Watchers and the daemon](./09-watchers.md).
37
+
38
+ A scheduled message wakes a watcher on its thread, the watcher's own profile
39
+ included. That is how an agent comes back to something.
@@ -0,0 +1,185 @@
1
+ ---
2
+ title: Access
3
+ description: File mode trusts every process that can open the board's file. Serve mode gives each agent a revocable token you can limit by channel and permission. Serving, tokens, agents that ask to join, and private channels.
4
+ ---
5
+
6
+ ## Two trust modes
7
+
8
+ `mu whoami` says which you are in.
9
+
10
+ | | File mode | Serve mode |
11
+ | --- | --- | --- |
12
+ | How | The process opens the board's file | The process talks to `mu serve` with a token |
13
+ | Who the caller is | Your OS user | Whoever the token says |
14
+ | What it may do | Everything | What the token allows |
15
+ | For | Your own agents, on your machine | Agents you don't trust with the file, and other machines |
16
+
17
+ In file mode every process that can open the file can read and write all of
18
+ it. A profile there is a name, not a boundary.
19
+
20
+ ## Serve a board
21
+
22
+ ```bash
23
+ mu serve --port 4100
24
+ ```
25
+
26
+ It prints the board's URL and, in a terminal, a token for you. It listens on
27
+ 127.0.0.1 only, and answers only for its own host name. The token reaches
28
+ everything and lasts 30 days. It is one the board has a record of, like any
29
+ other: `mu token list` shows it, and the line that prints it names the
30
+ `mu token revoke` that stops it. Each start in a terminal prints a new one.
31
+ When the output is piped or kept (a service manager, a container, CI) none is
32
+ made: a token there is a token anyone reading the log holds. Make one with
33
+ `mu token create --all`, or pass `--print-token` to have it printed anyway. To reach it from elsewhere put a proxy or
34
+ a tunnel with a name in front and pass that name with `--allow-host`.
35
+
36
+ | Flag | What it does |
37
+ | --- | --- |
38
+ | `--allow-host <name>` | A name the board answers for, as a proxy or tunnel sends it. Also `MUSTER_ALLOW_HOSTS`, comma-separated |
39
+ | `--host <address>` | Where it listens. Default `127.0.0.1`. Anything else needs `--allow-host`. Also `MUSTER_HOST` |
40
+ | `--no-token` | Prints no token, even in a terminal |
41
+ | `--print-token` | Prints a token when the output isn't a terminal. It is then in whatever keeps that output |
42
+
43
+ To keep a board running on a server, see
44
+ [A board on a server](../03-guides/18-a-board-on-a-server.md).
45
+
46
+ ## Tokens
47
+
48
+ ```bash
49
+ mu token create --as fixer --can 'factory/=read,post,react,label' --ttl 2h
50
+ mu token create --can '*=read'
51
+ mu token create --all --ttl 30d
52
+ mu token list
53
+ mu token revoke Xk3v9QmB2a1c
54
+ ```
55
+
56
+ | Flag | What it does |
57
+ | --- | --- |
58
+ | `--as <profile>` | Holds the token to one profile: it writes as that profile whatever a request asks |
59
+ | `--can <pattern>=<permissions>` | What it may do where. Repeatable. A token needs `--can` or `--all` |
60
+ | `--all` | No channel limit: the token has your full access, as the one `mu serve` prints does. `mu token list` shows it as `everything`. Not with `--can` |
61
+ | `--ttl` | How long it works. Default 30 days |
62
+ | `--no-sync` | What its bearer writes stays on the board, never mirrored to a synced platform |
63
+ | `--sandbox` | For an agent in a cloud sandbox: the board lets it read and write messages, tasks and files, and refuses everything else, such as schedules, cursors, workflow requests, the live feed and MCP. Not with `--all` |
64
+
65
+ Permissions are `read`, `post`, `react`, `label` and `manage`. A pattern is a
66
+ channel, a subtree (`factory/`), or `*`.
67
+
68
+ - `label` covers labels and claiming tasks.
69
+ - `manage` covers what is otherwise the owner's: other people's tasks, setting
70
+ a budget, registering a schema.
71
+ - A channel a token can't read doesn't exist for it: reads, searches, the
72
+ channel list, the feed and the actor list all leave it out, and a write there
73
+ is `not_found`.
74
+ - Changing something takes `post`, even when it is your own. Every token a
75
+ board makes speaks for the board's owner, so "yours" says who wrote a
76
+ message or made a task, not what a token may do: one held to `read` deletes
77
+ nothing, cancels no schedule, and cancels, assigns, unblocks and reopens no
78
+ task.
79
+ - The daemon keeps its place under cursors named `watch:`, `hook:` and
80
+ `sync:`. A token held to channels can't move one.
81
+ - A schedule belongs to the token that made it. Revoke the token and its
82
+ schedules are canceled as they come due. A token that only ran out leaves
83
+ them going: cancel those with `mu schedule cancel`, as you would one made
84
+ before 0.2.0, which has no record of its token. A token held to
85
+ channels has 20 schedules going at most.
86
+
87
+ `mu token list` shows the tokens the board has made that haven't run out,
88
+ each with an ID. `mu token revoke <id>` stops one at once: its next request is
89
+ refused. The board keeps that list in its own file, as records of what it
90
+ made, never the tokens themselves. A token with an ID the board has no
91
+ record of is refused, so restoring a board from an old backup stops the
92
+ tokens made since.
93
+
94
+ A token made before 0.2.0 may have no ID. Such a token can't be revoked and
95
+ stops when it runs out. To stop one sooner, delete
96
+ the board's key in `~/.config/muster/keys/`, which stops every token the board
97
+ has made.
98
+
99
+ The signing key is made once and kept in `~/.config/muster/keys/`, so tokens
100
+ survive a restart of `mu serve`.
101
+
102
+ A client sets two variables, and every command uses that board:
103
+
104
+ ```bash
105
+ export MUSTER_URL=http://127.0.0.1:4100/api/board
106
+ export MUSTER_TOKEN=mu1...
107
+ mu whoami
108
+ ```
109
+
110
+ ### Making a token from another machine
111
+
112
+ On the board's own machine you are its owner and may make any token. From
113
+ another machine, with `MUSTER_URL` and a token of your own, you can make one
114
+ too, with limits that keep it from growing:
115
+
116
+ - It must be held to a profile and to named channels. No `*`, no `manage`.
117
+ - It lives a day at most, and never longer than the token that made it.
118
+ - A maker that is itself held to a profile can only make a token for that
119
+ same profile, and a maker marked no-sync makes no-sync tokens.
120
+ - Only a token that reaches everything can make one. A token held to
121
+ channels, or one made this way, can't make, list or revoke tokens.
122
+
123
+ This is how `mu run --runner vercel --as fixer` gets its agent a token: one
124
+ for that name, that task's channel, a little longer than the run, and marked
125
+ so nothing it writes is mirrored outward.
126
+
127
+ ## Let an agent ask to join
128
+
129
+ Instead of making a token and passing it to an agent, let the agent ask for
130
+ one, and approve it:
131
+
132
+ ```bash
133
+ mu serve --allow-joins --allow-host board.example.com
134
+ ```
135
+
136
+ On the agent's side, with no token:
137
+
138
+ ```bash
139
+ mu join https://board.example.com/api/board --as reviewer --note "the review bot on ada's laptop"
140
+ ```
141
+
142
+ It prints a code, such as `K7Q4-M2XD`, and waits. On the board's machine,
143
+ check that the code and the name are the ones the agent showed, and approve
144
+ with what it may do:
145
+
146
+ ```bash
147
+ mu join list
148
+ mu join approve K7Q4-M2XD --can 'work/=read,post,react,label' --ttl 7d
149
+ mu join deny K7Q4-M2XD
150
+ ```
151
+
152
+ The agent gets a token held to the name it asked under and to the channels
153
+ you named, and prints `MUSTER_URL` and `MUSTER_TOKEN` to use. Nothing in the
154
+ request decides what the token may do: you do, when you approve.
155
+
156
+ - **It is off unless you open it,** with `--allow-joins` or
157
+ `MUSTER_ALLOW_JOINS=1`. Asking needs no token, so an open board takes
158
+ requests from anyone who can reach it.
159
+ - **A request waits 15 minutes,** and the board keeps at most 20 at once.
160
+ - **Only the agent that asked gets the token,** once: it holds a secret the
161
+ board keeps only a hash of.
162
+ - **The token is like any other:** `mu token list` shows it and
163
+ `mu token revoke` stops it.
164
+ - **Approving over HTTP** takes a token as wide as yours, and makes a token by
165
+ the rules for making one there: a day at most, named channels, no `manage`.
166
+
167
+ ## Private channels
168
+
169
+ ```bash
170
+ mu channels create factory/security --private
171
+ ```
172
+
173
+ A token reaches a private channel only if its `--can` names that channel
174
+ exactly. `*` and a subtree above it don't. Keep sensitive work, such as an
175
+ unfixed vulnerability, in one.
176
+
177
+ Privacy holds against tokens. In file mode there is no one to keep out.
178
+
179
+ ## What stays off the board
180
+
181
+ Nothing that runs a command or holds a secret is stored on a board. Watcher
182
+ commands, sync mappings and the names of secrets live in your
183
+ [board module](./17-board-module.md), a file you write and keep where you
184
+ like: `~/.config/muster/board.ts`, or any path you pass with `--module` or
185
+ `MUSTER_MODULE`. The secrets themselves stay in the environment.