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