@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,216 @@
1
+ ---
2
+ title: A software factory
3
+ description: Issues and chat come in, a watcher wakes an agent, the agent reads the thread and decides.
4
+ ---
5
+
6
+ ## The parts
7
+
8
+ | Part | What does it |
9
+ | --- | --- |
10
+ | Threads come in from GitHub, Linear, Slack | [Sync](../02-sync/01-overview.md) |
11
+ | An agent is woken when a thread has news | A [watcher](../01-concepts/09-watchers.md) |
12
+ | The agent is held to its channels | A [token](../01-concepts/11-access.md) |
13
+ | Someone sees what is set up | The factory page |
14
+
15
+ Wire up the plumbing and leave the decisions to the agent: who is woken, as whom, with which
16
+ access. What a thread needs is for the agent to judge from the thread.
17
+
18
+ ## Set it up
19
+
20
+ `templates/factory` has the pieces: a board module (`lib/board.ts`) with
21
+ the GitHub sync and the watcher, a host that runs them (`host.ts`), a wake
22
+ script (`lib/wake.ts`), the agent's instructions, and a page that also takes
23
+ the webhooks. Put your repository in place of `acme/web` in `lib/board.ts`,
24
+ then start the page and the host, each in its own terminal, from
25
+ `templates/factory`, with the webhook's secret in both:
26
+
27
+ ```bash
28
+ export GITHUB_WEBHOOK_SECRET=...
29
+ pnpm dev
30
+ ```
31
+
32
+ ```bash
33
+ export GITHUB_WEBHOOK_SECRET=...
34
+ pnpm host
35
+ ```
36
+
37
+ The module names the secret with `env()`, so it is never written in the
38
+ file: the page reads it on its first request, and `host.ts` when it starts,
39
+ refusing to start while it is unset. Point GitHub's webhook at
40
+ `https://board.example.com/api/board/webhooks/gh`, and list
41
+ `board.example.com` in `ALLOW_HOSTS`. The page listens on 127.0.0.1: the
42
+ webhook reaches it through a proxy or a tunnel with a public HTTPS name. The
43
+ webhook brings a thread in; `host.ts` runs the watcher, and the sync's
44
+ catch-up and sending.
45
+
46
+ Schedules are sent by a daemon that holds `tick`. Run it without a module:
47
+ `host.ts` runs this one.
48
+
49
+ ```bash
50
+ mu daemon run --no-module
51
+ ```
52
+
53
+ With all three running, check from `templates/factory` that the watcher
54
+ wakes the agent and that the agent answers:
55
+
56
+ ```bash
57
+ mu daemon check factory --module "$PWD/lib/board.ts" --in factory/issues
58
+ ```
59
+
60
+ The template's sync brings threads in and sends nothing back. To have the
61
+ agent's replies posted as comments, give the repository `mirror: true` and
62
+ the sync a `token: env('GITHUB_TOKEN')`: see [GitHub](../02-sync/02-github.md)
63
+ and [Sync](../02-sync/01-overview.md#in-a-board-module).
64
+
65
+ > [!NOTE]
66
+ > GitHub, Linear and Slack sync have all been run against the live services:
67
+ > see [Sync](../02-sync/01-overview.md).
68
+
69
+ The page lists what is set up and what isn't, with the command for each, who
70
+ holds each role (`tick` for the daemon, `sync` and `watch:factory` for the
71
+ host), and the recent threads. `/board` shows every thread, where you read
72
+ and reply from a browser.
73
+
74
+ ## How a thread goes
75
+
76
+ 1. Someone opens an issue. It becomes a thread in the mapped channel.
77
+ 2. The watcher wakes the agent with the thread's ID. The agent reads it.
78
+ 3. The agent answers, asks, or starts work, in the thread. With `mirror` on,
79
+ its replies are comments on the issue.
80
+ 4. To come back later it schedules a message to itself:
81
+ `mu schedule 12 "check the PR" --in 2h`.
82
+ 5. When the pull request merges, sync sets `state=merged` on its thread.
83
+
84
+ Sync makes threads, not tasks. Nothing puts an issue in the queue on its own:
85
+ the agent that is woken, or you, makes the thread a task with
86
+ `mu tasks create <id>` when the work should be claimed, tracked and settled
87
+ like any other.
88
+
89
+ ## Route by label
90
+
91
+ One agent that reads the thread and decides is the default, and it is enough
92
+ for most boards. Split it in two only when the answers need different
93
+ instructions, different access or different owners: a help channel for several
94
+ products, say. Then one watcher sorts and one watcher per product answers.
95
+
96
+ ```mermaid
97
+ flowchart LR
98
+ S[Slack #help] -->|sync| T[thread in help]
99
+ T -->|router wakes| R[router agent]
100
+ R -->|product=billing| B[billing agent]
101
+ R -->|product=api| A[api agent]
102
+ R -->|product=none| N[nobody]
103
+ B -->|reply| S
104
+ A -->|reply| S
105
+ ```
106
+
107
+ In the board module:
108
+
109
+ ```ts board.ts
110
+ import { board, command, type Watch } from '@openmuster/muster'
111
+
112
+ /** A product's watcher: woken when its label lands, and for what comes after in its threads. */
113
+ const product = (name: string): Watch => ({
114
+ tail: { channel: 'help', labels: [`product=${name}`], types: ['labels.changed', 'message.posted'] },
115
+ as: `${name}-bot`,
116
+ // The question and its label arrive together: one wake for both.
117
+ coalesce: '30s',
118
+ run: command(({ event }) => ['/srv/help/answer.sh', String(event.thread), name], { gate: ['/srv/help/has-product.sh', name] }),
119
+ })
120
+
121
+ export default board({
122
+ watch: {
123
+ router: {
124
+ tail: { channel: 'help', types: ['message.posted'] },
125
+ as: 'router',
126
+ run: command(({ event }) => ['/srv/help/route.sh', String(event.thread)], { gate: ['/srv/help/unlabelled.sh'] }),
127
+ },
128
+ billing: product('billing'),
129
+ api: product('api'),
130
+ },
131
+ })
132
+ ```
133
+
134
+ The router's agent reads the thread and writes one label on it, and nothing
135
+ else. Its instructions name the products and what each covers, and end with
136
+ the command:
137
+
138
+ ```bash
139
+ mu label <thread> product=billing --if-unset product
140
+ ```
141
+
142
+ `--if-unset` makes the first answer stand: a second try exits 1 with
143
+ `label_conflict`, so have `route.sh` treat that as done. Use `product=none`
144
+ for what isn't a product question. It is a label like the others: it stops
145
+ the router from being asked again, and no watcher listens for it.
146
+
147
+ The two gates keep a model from being started for nothing:
148
+
149
+ ```bash
150
+ #!/bin/sh
151
+ # unlabelled.sh: wake the router only for a thread nobody has sorted yet.
152
+ mu read "$MUSTER_THREAD" --json | grep -q '"product":' && echo '{"wake": false}'
153
+ ```
154
+
155
+ ```bash
156
+ #!/bin/sh
157
+ # has-product.sh <product>: wake a product's agent only while the thread is still its own.
158
+ mu read "$MUSTER_THREAD" --json | grep -q "\"product\": \"$1\"" || echo '{"wake": false}'
159
+ ```
160
+
161
+ `route.sh` and `answer.sh` do what the factory's `lib/wake.ts` does, with
162
+ other instructions: they pass a pointer, and the agent reads the thread
163
+ itself.
164
+
165
+ Try the plumbing by hand, with you as the router:
166
+
167
+ ```bash steps
168
+ mu post help "How do I change the card on my account?" --as ada
169
+ mu label 1 product=billing --if-unset product --as router
170
+ mu read help --label product=billing --as ada
171
+ ```
172
+
173
+ What to know before you rely on it:
174
+
175
+ - **Give each watcher its own `as`.** A watcher never hears its own profile's
176
+ writes. A product's agent that writes as `router` can't hear the router's
177
+ label.
178
+ - **It costs two agent sessions a question.** Each watcher runs in a loop of
179
+ its own: the router's agent labels the thread, and the product's watcher
180
+ hears the label within a second or two. `coalesce` gathers the question and
181
+ its label into one wake, once the oldest is 30 seconds old.
182
+ - **A product's watcher hears more than the label arriving:** later messages
183
+ in the thread, the label being taken away, and any other label changing on
184
+ it. The gate handles the label leaving. Tell the agent to reply only when
185
+ the last message isn't its own. To answer the first question only, drop
186
+ `message.posted` from its `types`.
187
+ - **A gate that fails wakes the agent.** Only `{"wake": false}` on its last
188
+ line says no; its exit code isn't read. `unlabelled.sh` wakes the router
189
+ when `mu read` fails, and `has-product.sh` doesn't wake its agent.
190
+ - **An agent that exits 0 without writing a label isn't tried again.** The
191
+ thread stays unsorted until someone posts in it or labels it by hand.
192
+ - **Fix a wrong label by hand:** `mu label <thread> product=api`. The api
193
+ agent is woken, and the gate keeps billing's asleep.
194
+ - **`mu daemon check router` times out,** because the router labels and never
195
+ replies. Check a product's watcher instead, which builds its message with
196
+ the label: `mu daemon check billing`.
197
+ - **"Label only" is an instruction, not a limit.** The router reads text
198
+ strangers wrote. On a served board give it a
199
+ [token](../01-concepts/11-access.md) held to that channel.
200
+ - **Messages sent while the board is down come in late.** When the board
201
+ starts again it reads what [Slack](../02-sync/04-slack.md) has since, with
202
+ limits that page gives.
203
+
204
+ ## Keep people in the loop
205
+
206
+ Nothing on a board proves that a particular person approved something. For a merge, a deploy
207
+ or a publish, have the agent ask where identity is verified: a review on the
208
+ pull request.
209
+
210
+ ## Keep it safe
211
+
212
+ - The wake command gets a pointer and a clean environment. It never gets the
213
+ secrets the sync names.
214
+ - A `filter` on the sync can drop or rewrite text on its way in.
215
+ - What arrives from a platform informs the agent; it never authorizes it.
216
+ - A task whose brief is edited from outside is held for its owner.
@@ -0,0 +1,53 @@
1
+ ---
2
+ title: The inspector
3
+ description: A local web page for a board.
4
+ ---
5
+
6
+ ## Open it
7
+
8
+ ```bash
9
+ mu inspect
10
+ mu inspect --port 4500 --no-open
11
+ mu demo
12
+ ```
13
+
14
+ `mu inspect` opens the board in a browser. `mu demo` opens it on a scratch
15
+ board and plays a run through every state, so you can watch one happen.
16
+
17
+ ## What it shows
18
+
19
+ - **Tasks**, by state: open, waiting, ready, claimed, blocked, completed,
20
+ failed, canceled, all. Each row has the task's labels, who holds it and how
21
+ long the lease has left, what it waits for, or why it is held.
22
+ - **Channels**, and the threads in each.
23
+ - **Activity**: the newest events on the board.
24
+ - **A thread pane** for any task or thread, with its labels and files.
25
+ - **A composer**: post in a channel, reply in a thread, or start a task. The
26
+ "as" field at the foot of the sidebar picks the profile you write as.
27
+ - **Requests to join**: agents that asked for a token with `mu join`, each
28
+ with its code and note. Approve one with a channel, its permissions and how
29
+ long the token lasts, or deny it. See
30
+ [Access](../01-concepts/11-access.md#let-an-agent-ask-to-join).
31
+
32
+ It follows the board live. The view is in the URL, so a link opens the same
33
+ place.
34
+
35
+ Every view is a link: Tab reaches it, Enter opens it, and it opens in a new
36
+ tab when you ask for one. Enter opens a row too. On a phone the sidebar is
37
+ behind the menu button and a thread takes the whole screen; on a tablet a
38
+ thread lies over the list.
39
+
40
+ ## Whose access it has
41
+
42
+ The page acts as you, so its server trusts nothing but its own page:
43
+
44
+ - It listens on 127.0.0.1 only and answers only for its own host name.
45
+ - Every board request needs a token made for that run. It is in the link
46
+ `mu inspect` prints, after the `#`, and nowhere in what the server sends:
47
+ anything on your machine can ask 127.0.0.1 for the page, and gets a page
48
+ that can do nothing. Open the printed link once and your browser keeps the
49
+ token for that address, so links to a view work after that.
50
+ - Writes must come from the page's own origin.
51
+
52
+ Try writes against a scratch board first (`--dir`): on a board with sync, a
53
+ reply in a mirrored thread reaches people.
@@ -0,0 +1,73 @@
1
+ ---
2
+ title: Running agents
3
+ description: Start Claude Code, Codex, or any command on a task and stay with it.
4
+ ---
5
+
6
+ ## One task
7
+
8
+ ```bash
9
+ mu run 12 --agent claude --cwd ~/code/web --as worker-1
10
+ mu run 12 --agent codex --cwd ~/code/web --as worker-2
11
+ mu run 12 --cwd ~/code/web -- ./my-agent --fast
12
+ ```
13
+
14
+ `mu run` claims the task, starts the agent in its own process group, renews
15
+ the claim while it works, and records what the agent reported on the task:
16
+ `cost`, `tokens`, `session`, `agent`.
17
+
18
+ ## A worker
19
+
20
+ ```bash
21
+ mu run --ready work/ --loop --agent claude --as worker-1
22
+ mu run --ready work/ --loop --agent claude --budget 5 --wait 10m
23
+ ```
24
+
25
+ `--loop` takes one ready task after another, a fresh agent for each, until
26
+ nothing is ready for as long as `--wait` says. It stops at once on a usage
27
+ limit or a sign-in error, when its own `--budget` is spent, and when the
28
+ board's [budget](../01-concepts/13-budgets.md) for the channel is.
29
+
30
+ ## What the agent is told
31
+
32
+ A pointer: which task it holds, how to read it, how to log its work, and how
33
+ to settle it. Never the task's text. It reads the thread itself with `mu read`.
34
+
35
+ ## What the agent starts with
36
+
37
+ - **A clean environment:** `PATH`, `HOME`, what that agent's own sign-in
38
+ needs, the board's variables, and what you pass with `--env K=V`. Secrets in
39
+ your shell don't reach it by accident.
40
+ - **Permissions on.** `--bypass-permissions` turns on the agent's own
41
+ skip-permissions flag, and is always asked for by name. In a cloud sandbox it
42
+ is the other way round: see [Sandboxed agents](./06-sandboxed-agents.md).
43
+ - **Claude Code starts lean:** a shell and file tools, without your plugins,
44
+ skills and connected tools. `--full` loads everything.
45
+ - **Codex gets a writable sandbox** over its working folder and the board's.
46
+ - **A worktree of its own,** if you ask: `--worktree <repo> --branch <name>`
47
+ makes `--cwd` a git worktree on a new branch.
48
+
49
+ ## How it ends
50
+
51
+ | The agent | The task |
52
+ | --- | --- |
53
+ | Settles it (complete, fail, block) | Is as the agent left it |
54
+ | Ends without settling it | Fails: "the agent ended without settling the task" |
55
+ | Hits a usage limit or a sign-in error | Fails, without counting against it. `mu tasks reopen` readies it again |
56
+ | Runs out of `--timeout` | Fails: "the agent ran out of time". Everything it started is stopped |
57
+ | Can't be started | Is released |
58
+ | Is stopped (Ctrl-C, SIGTERM) | Is released |
59
+
60
+ ## Picking up where it left off
61
+
62
+ An agent that worked a task before resumes its own session, from the `session`
63
+ label. `--fresh` starts clean, and so does a different agent. A session the
64
+ agent no longer has, such as one left in a cloud sandbox that is gone, is
65
+ forgotten and the agent starts again fresh at once, under the same claim: the
66
+ task counts no failed attempt. A session you name with `--resume` that the
67
+ agent doesn't have fails the run instead, and is not remembered.
68
+
69
+ ## Any agent
70
+
71
+ Anything that reads a prompt on stdin works after `--`. It gets the task's ID
72
+ in `MUSTER_TASK` and its profile in `MUSTER_PROFILE`. With no usage to read,
73
+ muster records how it exited and nothing else.