@openmuster/muster 0.3.1-alpha.4 → 0.3.1-alpha.6
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/README.md +11 -7
- package/dist/{args-9ZZDcPxa.js → args-CaFBa2IP.js} +305 -23
- package/dist/cli.js +3 -3
- package/dist/index.d.ts +98 -19
- package/dist/index.js +107 -42
- package/dist/inspect/app.js +49 -26
- package/dist/{main-Doit2DDY.js → main-3kE64MlN.js} +195 -12
- package/dist/main-o4m_lGDG.js +6 -0
- package/dist/mcp-D6Xt2ixk.js +6 -0
- package/dist/{module-DjDMSEKu.js → module-BX2IjSiv.js} +2 -2
- package/dist/{module-D8qcE3e7.js → module-D9KdbEpS.js} +1 -1
- package/dist/skills/board/SKILL.md +5 -0
- package/dist/skills/loop-card/SKILL.md +22 -3
- package/dist/{steps-BUPRIOe3.js → steps-cnWo2Wvx.js} +299 -12
- package/docs/01-concepts/09-watchers.md +4 -32
- package/docs/01-concepts/10-schedules.md +1 -1
- package/docs/01-concepts/11-access.md +19 -3
- package/docs/01-concepts/13-budgets.md +66 -3
- package/docs/01-concepts/15-outgoing-webhooks.md +6 -19
- package/docs/01-concepts/16-workflows.md +42 -2
- package/docs/01-quickstart.md +74 -45
- package/docs/02-sync/01-overview.md +34 -2
- package/docs/02-sync/02-github.md +40 -19
- package/docs/02-sync/03-linear.md +103 -85
- package/docs/02-sync/04-slack.md +116 -111
- package/docs/02-sync/05-notion.md +46 -25
- package/docs/03-guides/01-coding-agents.md +51 -33
- package/docs/03-guides/02-swarm.md +30 -15
- package/docs/03-guides/03-factory.md +193 -80
- package/docs/03-guides/04-inspector.md +73 -42
- package/docs/03-guides/05-running-agents.md +62 -35
- package/docs/03-guides/06-sandboxed-agents.md +535 -305
- package/docs/03-guides/07-build-a-ui.md +86 -31
- package/docs/03-guides/08-ci.md +59 -36
- package/docs/03-guides/09-daemon.md +121 -53
- package/docs/03-guides/10-two-agents.md +31 -22
- package/docs/03-guides/11-person-in-the-loop.md +47 -34
- package/docs/03-guides/12-unattended.md +46 -27
- package/docs/03-guides/13-terminals.md +51 -39
- package/docs/03-guides/14-no-cloud.md +31 -19
- package/docs/03-guides/15-several-boards.md +61 -27
- package/docs/03-guides/16-non-code.md +29 -18
- package/docs/03-guides/17-mcp.md +37 -30
- package/docs/03-guides/18-a-board-on-a-server.md +66 -43
- package/docs/03-guides/19-a-card-queue.md +210 -121
- package/docs/03-guides/20-a-feedback-loop.md +412 -135
- package/docs/03-guides/21-running-the-loop.md +94 -64
- package/docs/03-guides/22-building-from-linear.md +100 -63
- package/docs/04-reference/01-cli.md +7 -0
- package/docs/04-reference/02-handle.md +11 -15
- package/docs/04-reference/03-http.md +1 -1
- package/docs/04-reference/04-events.md +2 -1
- package/docs/04-reference/05-errors.md +6 -0
- package/docs/04-reference/08-files.md +49 -0
- package/docs/index.md +1 -0
- package/package.json +1 -1
- package/dist/main-D5aX7Jaj.js +0 -6
- package/dist/mcp-Cm96TIb3.js +0 -6
|
@@ -11,7 +11,25 @@ For the whole workflow, from a project and its spec to a pull request per
|
|
|
11
11
|
issue, with rounds started from a comment, see
|
|
12
12
|
[Building from Linear](../03-guides/22-building-from-linear.md).
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Set it up
|
|
15
|
+
|
|
16
|
+
### 1. Create a key
|
|
17
|
+
|
|
18
|
+
Create a key: Settings, Security & access, Personal API keys, with read
|
|
19
|
+
and write access. Or an OAuth app with permission to create issues and
|
|
20
|
+
comments: see [Who the comments are by](#who-the-comments-are-by).
|
|
21
|
+
|
|
22
|
+
### 2. Add the webhook
|
|
23
|
+
|
|
24
|
+
Settings, API, Webhooks: add one pointing at
|
|
25
|
+
`https://<host>/api/board/webhooks/lin`, for **Issues** and **Comments**.
|
|
26
|
+
Limit it to the teams you map: one for all public teams also sends what
|
|
27
|
+
happens in the others, which the board then drops.
|
|
28
|
+
|
|
29
|
+
### 3. Map the teams
|
|
30
|
+
|
|
31
|
+
Put the key and the webhook's signing secret in the server's environment,
|
|
32
|
+
and name them in the board module with `env()`:
|
|
15
33
|
|
|
16
34
|
```ts board.ts
|
|
17
35
|
import { board, env, linear } from '@openmuster/muster'
|
|
@@ -33,45 +51,16 @@ A team, by its key, maps to a channel. Sync is two-way unless a team sets
|
|
|
33
51
|
`token` is a personal API key (`lin_api_…`) or an OAuth access token; muster
|
|
34
52
|
sends each the way Linear expects.
|
|
35
53
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```ts board.ts
|
|
43
|
-
import { board, env, linear } from '@openmuster/muster'
|
|
44
|
-
|
|
45
|
-
export default board({
|
|
46
|
-
sync: {
|
|
47
|
-
lin: linear({
|
|
48
|
-
secret: env('LINEAR_WEBHOOK_SECRET'),
|
|
49
|
-
clientId: env('LINEAR_CLIENT_ID'),
|
|
50
|
-
clientSecret: env('LINEAR_CLIENT_SECRET'),
|
|
51
|
-
teams: { ENG: 'eng' },
|
|
52
|
-
}),
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
- In Linear, create an OAuth application (Settings, API, OAuth applications)
|
|
58
|
-
and turn on **client credentials tokens** for it. Its name and icon are how
|
|
59
|
-
it shows on comments.
|
|
60
|
-
- The board asks Linear for the app's token when it first needs one, keeps it
|
|
61
|
-
for the thirty days it lasts, and asks again before it runs out or when
|
|
62
|
-
Linear ends it early. Nothing is stored: a board that starts again asks
|
|
63
|
-
again.
|
|
64
|
-
- `scopes` is what the token may do, `['read', 'write']` unless you say.
|
|
65
|
-
Changing it ends the app's earlier tokens in the workspace.
|
|
66
|
-
- A client credentials token replaces an installation of the same app made
|
|
67
|
-
through the authorization page. Use an application of its own for the board.
|
|
68
|
-
- Catch-up and files use the app as well, so no `token` is needed. With both
|
|
69
|
-
set, the app is used.
|
|
54
|
+
`bot` is optional: the user ID whose comments are never imported. Set it only
|
|
55
|
+
when the token acts as a user of its own, such as an OAuth app that posts as
|
|
56
|
+
itself rather than as the person who installed it. With a personal API key, that user is you, and naming it would
|
|
57
|
+
drop everything you write in Linear. Without `bot`, the board still knows its
|
|
58
|
+
own comments and issues by the IDs Linear gave them, so they don't come back.
|
|
70
59
|
|
|
71
|
-
|
|
72
|
-
or one Linear ends early.
|
|
60
|
+
### Show an issue being worked on
|
|
73
61
|
|
|
74
|
-
|
|
62
|
+
This step is optional, and needs the OAuth application from
|
|
63
|
+
[Who the comments are by](#who-the-comments-are-by).
|
|
75
64
|
|
|
76
65
|
An application can have an agent session on an issue, which Linear shows as
|
|
77
66
|
working. With `agent: true`, the board uses that for an issue a workflow run
|
|
@@ -118,13 +107,40 @@ nothing in it is imported. The token needs no more than `read` and `write`.
|
|
|
118
107
|
A person writing in the session's thread is not imported: it reaches the
|
|
119
108
|
application's webhook, which the board answers and drops.
|
|
120
109
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
110
|
+
### 4. Restart `mu serve`
|
|
111
|
+
|
|
112
|
+
Restart `mu serve`: it reads the module and the secrets only when it starts.
|
|
113
|
+
|
|
114
|
+
### 5. Check it
|
|
115
|
+
|
|
116
|
+
To check the key, ask Linear who it is and what teams it sees:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
curl -s https://api.linear.app/graphql -H "authorization: $LINEAR_API_KEY" \
|
|
120
|
+
-H 'content-type: application/json' -d '{"query":"{ viewer { id } teams { nodes { key } } }"}'
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
A new issue in a mapped team shows up on the board within seconds. If it
|
|
124
|
+
doesn't, a webhook answered `404` means `mu serve` was started before the
|
|
125
|
+
`lin` entry was added; `401` means the signing secret is not the webhook's.
|
|
126
|
+
|
|
127
|
+
## Turn tickets into tasks
|
|
128
|
+
|
|
129
|
+
A synced issue is a thread. Make it claimable when it should be worked:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
mu tasks create 41
|
|
133
|
+
mu tasks claim --ready eng --as fixer
|
|
134
|
+
```
|
|
126
135
|
|
|
127
|
-
|
|
136
|
+
An agent or a watcher can do that for every new thread in the channel; which
|
|
137
|
+
ones deserve it is a judgment, so leave it to the agent.
|
|
138
|
+
|
|
139
|
+
## Reference
|
|
140
|
+
|
|
141
|
+
What the sync brings in, sends back and catches up on.
|
|
142
|
+
|
|
143
|
+
### What comes in
|
|
128
144
|
|
|
129
145
|
| In Linear | On the board |
|
|
130
146
|
| --- | --- |
|
|
@@ -154,7 +170,7 @@ opened its issue.
|
|
|
154
170
|
|
|
155
171
|
Not imported: an assignee's email.
|
|
156
172
|
|
|
157
|
-
|
|
173
|
+
#### An issue from before sync
|
|
158
174
|
|
|
159
175
|
An issue made before sync was set up has no thread until something happens
|
|
160
176
|
to it in a mapped team:
|
|
@@ -173,7 +189,7 @@ to it in a mapped team:
|
|
|
173
189
|
|
|
174
190
|
An issue in a team that isn't mapped starts nothing.
|
|
175
191
|
|
|
176
|
-
|
|
192
|
+
#### In the order Linear made them
|
|
177
193
|
|
|
178
194
|
Linear resends a webhook the board didn't answer, such as one sent while it
|
|
179
195
|
was restarting, and a webhook can be held up on the way. So a change can
|
|
@@ -196,7 +212,7 @@ changed (its `updatedAt`), not by when the webhook came:
|
|
|
196
212
|
|
|
197
213
|
A change from a webhook with no `updatedAt` is applied as it arrives.
|
|
198
214
|
|
|
199
|
-
|
|
215
|
+
### What goes back
|
|
200
216
|
|
|
201
217
|
- A reply in a synced thread is posted as a comment on the issue.
|
|
202
218
|
- A thread posted in a team's channel creates an issue in that team. Its first
|
|
@@ -206,7 +222,7 @@ A change from a webhook with no `updatedAt` is applied as it arrives.
|
|
|
206
222
|
What the board sent is not imported back, and neither are comments by the
|
|
207
223
|
user named in `bot`.
|
|
208
224
|
|
|
209
|
-
|
|
225
|
+
### Files
|
|
210
226
|
|
|
211
227
|
- **In:** a file uploaded to Linear is a markdown link to
|
|
212
228
|
`uploads.linear.app` in an issue's description or a comment. The board
|
|
@@ -232,7 +248,45 @@ live workspace.
|
|
|
232
248
|
The board follows no redirect from `uploads.linear.app`: a file Linear
|
|
233
249
|
redirects is named in the text instead of attached. See [Files](./01-overview.md#files) for the limits.
|
|
234
250
|
|
|
235
|
-
|
|
251
|
+
### Who the comments are by
|
|
252
|
+
|
|
253
|
+
What the sync sends is written by whoever its credential belongs to. A
|
|
254
|
+
personal API key in `token` makes every comment and issue yours. To have them
|
|
255
|
+
written by an app of its own, name an OAuth application in place of the token:
|
|
256
|
+
|
|
257
|
+
```ts board.ts
|
|
258
|
+
import { board, env, linear } from '@openmuster/muster'
|
|
259
|
+
|
|
260
|
+
export default board({
|
|
261
|
+
sync: {
|
|
262
|
+
lin: linear({
|
|
263
|
+
secret: env('LINEAR_WEBHOOK_SECRET'),
|
|
264
|
+
clientId: env('LINEAR_CLIENT_ID'),
|
|
265
|
+
clientSecret: env('LINEAR_CLIENT_SECRET'),
|
|
266
|
+
teams: { ENG: 'eng' },
|
|
267
|
+
}),
|
|
268
|
+
},
|
|
269
|
+
})
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
- In Linear, create an OAuth application (Settings, API, OAuth applications)
|
|
273
|
+
and turn on **client credentials tokens** for it. Its name and icon are how
|
|
274
|
+
it shows on comments.
|
|
275
|
+
- The board asks Linear for the app's token when it first needs one, keeps it
|
|
276
|
+
for the thirty days it lasts, and asks again before it runs out or when
|
|
277
|
+
Linear ends it early. Nothing is stored: a board that starts again asks
|
|
278
|
+
again.
|
|
279
|
+
- `scopes` is what the token may do, `['read', 'write']` unless you say.
|
|
280
|
+
Changing it ends the app's earlier tokens in the workspace.
|
|
281
|
+
- A client credentials token replaces an installation of the same app made
|
|
282
|
+
through the authorization page. Use an application of its own for the board.
|
|
283
|
+
- Catch-up and files use the app as well, so no `token` is needed. With both
|
|
284
|
+
set, the app is used.
|
|
285
|
+
|
|
286
|
+
Not yet seen against a live workspace: a token renewed after thirty days,
|
|
287
|
+
or one Linear ends early.
|
|
288
|
+
|
|
289
|
+
### Catching up
|
|
236
290
|
|
|
237
291
|
After downtime, and when a token or an OAuth app is set, the ticker asks Linear for the issues in
|
|
238
292
|
the mapped teams updated since the last event it received, then the comments
|
|
@@ -252,39 +306,3 @@ the reasons, it is asked again from the same point five minutes later. See
|
|
|
252
306
|
[After downtime](./01-overview.md#after-downtime) for the rest.
|
|
253
307
|
A file linked from an issue or comment read this way is fetched as one from a
|
|
254
308
|
webhook would be, with the same limits.
|
|
255
|
-
|
|
256
|
-
## Set it up
|
|
257
|
-
|
|
258
|
-
1. Create a key: Settings, Security & access, Personal API keys, with read
|
|
259
|
-
and write access. Or an OAuth app with permission to create issues and
|
|
260
|
-
comments.
|
|
261
|
-
2. Settings, API, Webhooks: add one pointing at
|
|
262
|
-
`https://<host>/api/board/webhooks/lin`, for **Issues** and **Comments**.
|
|
263
|
-
Limit it to the teams you map: one for all public teams also sends what
|
|
264
|
-
happens in the others, which the board then drops.
|
|
265
|
-
3. Put the key and the webhook's signing secret in the server's environment,
|
|
266
|
-
and name them in the board module with `env()`, as above.
|
|
267
|
-
4. Restart `mu serve`: it reads the module and the secrets only when it starts.
|
|
268
|
-
|
|
269
|
-
To check the key, ask Linear who it is and what teams it sees:
|
|
270
|
-
|
|
271
|
-
```bash
|
|
272
|
-
curl -s https://api.linear.app/graphql -H "authorization: $LINEAR_API_KEY" \
|
|
273
|
-
-H 'content-type: application/json' -d '{"query":"{ viewer { id } teams { nodes { key } } }"}'
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
A new issue in a mapped team shows up on the board within seconds. If it
|
|
277
|
-
doesn't, a webhook answered `404` means `mu serve` was started before the
|
|
278
|
-
`lin` entry was added; `401` means the signing secret is not the webhook's.
|
|
279
|
-
|
|
280
|
-
## Turn tickets into tasks
|
|
281
|
-
|
|
282
|
-
A synced issue is a thread. Make it claimable when it should be worked:
|
|
283
|
-
|
|
284
|
-
```bash
|
|
285
|
-
mu tasks create 41
|
|
286
|
-
mu tasks claim --ready eng --as fixer
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
An agent or a watcher can do that for every new thread in the channel; which
|
|
290
|
-
ones deserve it is a judgment, so leave it to the agent.
|
package/docs/02-sync/04-slack.md
CHANGED
|
@@ -5,7 +5,64 @@ description: Map Slack channels to board channels, so a message people post beco
|
|
|
5
5
|
|
|
6
6
|
Guides that use it: [A software factory](../03-guides/03-factory.md) answers questions in a channel as they arrive, and [A feedback loop](../03-guides/20-a-feedback-loop.md) turns a thread into a pull request, with Slack showing the run as working.
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## Set it up
|
|
9
|
+
|
|
10
|
+
The board has to be served at an HTTPS address Slack can reach: see
|
|
11
|
+
[A board on a server](../03-guides/18-a-board-on-a-server.md). A tunnel to your
|
|
12
|
+
machine is enough to try it.
|
|
13
|
+
|
|
14
|
+
### 1. Create the app
|
|
15
|
+
|
|
16
|
+
At [api.slack.com/apps](https://api.slack.com/apps), choose **Create New App**,
|
|
17
|
+
then **From a manifest**, pick the workspace and paste:
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
display_information:
|
|
21
|
+
name: muster
|
|
22
|
+
features:
|
|
23
|
+
bot_user:
|
|
24
|
+
display_name: muster
|
|
25
|
+
always_online: true
|
|
26
|
+
oauth_config:
|
|
27
|
+
scopes:
|
|
28
|
+
bot:
|
|
29
|
+
- channels:history
|
|
30
|
+
- groups:history
|
|
31
|
+
- chat:write
|
|
32
|
+
- files:read
|
|
33
|
+
- files:write
|
|
34
|
+
settings:
|
|
35
|
+
org_deploy_enabled: false
|
|
36
|
+
socket_mode_enabled: false
|
|
37
|
+
token_rotation_enabled: false
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Events come later: Slack checks their request URL as soon as it is saved, so
|
|
41
|
+
the board must be running first.
|
|
42
|
+
|
|
43
|
+
### 2. Install it and keep its two secrets
|
|
44
|
+
|
|
45
|
+
Install the app to the workspace from **Install App**. Then put two values
|
|
46
|
+
where `mu serve` reads its environment, never in the board module itself:
|
|
47
|
+
|
|
48
|
+
| Variable | Where it is |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `SLACK_BOT_TOKEN` | **OAuth & Permissions**, Bot User OAuth Token, `xoxb-...` |
|
|
51
|
+
| `SLACK_SIGNING_SECRET` | **Basic Information**, App Credentials, Signing Secret |
|
|
52
|
+
|
|
53
|
+
### 3. Find the IDs
|
|
54
|
+
|
|
55
|
+
- **The channel:** invite the app with `/invite @muster`, then open the
|
|
56
|
+
channel's details: its ID, `C...`, is at the bottom of the About tab.
|
|
57
|
+
- **The bot:** `auth.test` returns it as `bot_id`, `B...`.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
curl -s -H "Authorization: Bearer $SLACK_BOT_TOKEN" https://slack.com/api/auth.test
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 4. Map the channel and start the board
|
|
64
|
+
|
|
65
|
+
Write the `chat` sync in the board module, with the channel and `bot`:
|
|
9
66
|
|
|
10
67
|
```ts board.ts
|
|
11
68
|
import { board, env, slack } from '@openmuster/muster'
|
|
@@ -25,27 +82,22 @@ export default board({
|
|
|
25
82
|
A Slack channel, by its ID, maps to a board channel. Sync is two-way unless a
|
|
26
83
|
channel sets `mirror: false`.
|
|
27
84
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
| In Slack | On the board |
|
|
31
|
-
| --- | --- |
|
|
32
|
-
| A message in the channel | A thread, by `chat:user:<id>` |
|
|
33
|
-
| A message in a Slack thread | A reply in that thread |
|
|
34
|
-
| A message is edited or deleted | The message is edited or deleted |
|
|
85
|
+
`mu serve` reads the module when it starts: restart it after a change.
|
|
35
86
|
|
|
36
|
-
|
|
37
|
-
|
|
87
|
+
Without `bot`, messages from every bot in a mapped channel are skipped, not
|
|
88
|
+
only the app's own.
|
|
38
89
|
|
|
39
|
-
|
|
90
|
+
### 5. Turn on events
|
|
40
91
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
92
|
+
In **Event Subscriptions**, turn events on and set the request URL to
|
|
93
|
+
`https://<host>/api/board/webhooks/chat`. The board answers Slack's check
|
|
94
|
+
itself, and the URL shows as verified. Subscribe to the bot events
|
|
95
|
+
`message.channels` and `message.groups`, save, and reinstall the app if Slack
|
|
96
|
+
asks.
|
|
45
97
|
|
|
46
|
-
|
|
98
|
+
### Show a thread being worked on
|
|
47
99
|
|
|
48
|
-
|
|
100
|
+
This step is optional.
|
|
49
101
|
|
|
50
102
|
A Slack app declared an agent can show Slack's own "Working…" under a thread.
|
|
51
103
|
With `agent: true`, the board uses that for a thread a workflow run is working
|
|
@@ -87,7 +139,47 @@ In the app's settings, turn on the agent feature (the manifest's
|
|
|
87
139
|
Not yet seen against a live workspace: a private channel, a run longer than
|
|
88
140
|
Slack's hour, and one run handing over to the next on the same thread.
|
|
89
141
|
|
|
90
|
-
|
|
142
|
+
### 6. Check it
|
|
143
|
+
|
|
144
|
+
Post a message in the channel: it arrives as a thread in the mapped board
|
|
145
|
+
channel, labelled `source=chat`. Reply to it on the board, and the reply
|
|
146
|
+
appears in the Slack thread from the app.
|
|
147
|
+
|
|
148
|
+
## Keep the noise down
|
|
149
|
+
|
|
150
|
+
Report milestones and skip the "still working" updates: every reply in a mirrored thread reaches
|
|
151
|
+
people in Slack. Use `--no-sync` for a work log that only the board needs.
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
mu reply 12 "ran the suite: 40 of 40" --no-sync
|
|
155
|
+
mu reply 12 "fixed in a1b2c3"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Reference
|
|
159
|
+
|
|
160
|
+
What the sync brings in, sends back and catches up on.
|
|
161
|
+
|
|
162
|
+
### What comes in
|
|
163
|
+
|
|
164
|
+
| In Slack | On the board |
|
|
165
|
+
| --- | --- |
|
|
166
|
+
| A message in the channel | A thread, by `chat:user:<id>` |
|
|
167
|
+
| A message in a Slack thread | A reply in that thread |
|
|
168
|
+
| A message is edited or deleted | The message is edited or deleted |
|
|
169
|
+
|
|
170
|
+
Joins, topic changes and other system messages are ignored. A request older
|
|
171
|
+
than five minutes is refused however well it is signed.
|
|
172
|
+
|
|
173
|
+
### What goes back
|
|
174
|
+
|
|
175
|
+
- A reply in a synced thread is posted into the Slack thread.
|
|
176
|
+
- A thread posted in a mapped board channel is posted to the Slack channel,
|
|
177
|
+
and later replies go into its thread.
|
|
178
|
+
- An edit or a delete of a delivered message updates or removes it.
|
|
179
|
+
|
|
180
|
+
Messages from the app's own bot, named by `bot`, are not imported back.
|
|
181
|
+
|
|
182
|
+
### Files
|
|
91
183
|
|
|
92
184
|
- **In:** a file on a Slack message is fetched from `files.slack.com` with
|
|
93
185
|
the bot token and attached to the message. It needs `files:read`. A web
|
|
@@ -109,7 +201,7 @@ files synced needs the two scopes added under **OAuth & Permissions**, and
|
|
|
109
201
|
reinstalling. See
|
|
110
202
|
[Files](./01-overview.md#files) for the limits.
|
|
111
203
|
|
|
112
|
-
|
|
204
|
+
### After downtime
|
|
113
205
|
|
|
114
206
|
Slack retries an event that wasn't answered three times, within minutes.
|
|
115
207
|
Beyond that, the ticker reads each mapped channel's history, oldest first,
|
|
@@ -134,95 +226,8 @@ and deletes made meanwhile are not read.
|
|
|
134
226
|
point five minutes later.
|
|
135
227
|
|
|
136
228
|
Catch-up uses `conversations.history` and `conversations.replies`, which the
|
|
137
|
-
`channels:history` and `groups:history` scopes
|
|
138
|
-
gives an app made for your own workspace, as
|
|
139
|
-
|
|
140
|
-
and with many channels mapped,
|
|
141
|
-
|
|
142
|
-
## Set it up
|
|
143
|
-
|
|
144
|
-
The board has to be served at an HTTPS address Slack can reach: see
|
|
145
|
-
[A board on a server](../03-guides/18-a-board-on-a-server.md). A tunnel to your
|
|
146
|
-
machine is enough to try it.
|
|
147
|
-
|
|
148
|
-
### 1. Create the app
|
|
149
|
-
|
|
150
|
-
At [api.slack.com/apps](https://api.slack.com/apps), choose **Create New App**,
|
|
151
|
-
then **From a manifest**, pick the workspace and paste:
|
|
152
|
-
|
|
153
|
-
```yaml
|
|
154
|
-
display_information:
|
|
155
|
-
name: muster
|
|
156
|
-
features:
|
|
157
|
-
bot_user:
|
|
158
|
-
display_name: muster
|
|
159
|
-
always_online: true
|
|
160
|
-
oauth_config:
|
|
161
|
-
scopes:
|
|
162
|
-
bot:
|
|
163
|
-
- channels:history
|
|
164
|
-
- groups:history
|
|
165
|
-
- chat:write
|
|
166
|
-
- files:read
|
|
167
|
-
- files:write
|
|
168
|
-
settings:
|
|
169
|
-
org_deploy_enabled: false
|
|
170
|
-
socket_mode_enabled: false
|
|
171
|
-
token_rotation_enabled: false
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
Events come later: Slack checks their request URL as soon as it is saved, so
|
|
175
|
-
the board must be running first.
|
|
176
|
-
|
|
177
|
-
### 2. Install it and keep its two secrets
|
|
178
|
-
|
|
179
|
-
Install the app to the workspace from **Install App**. Then put two values
|
|
180
|
-
where `mu serve` reads its environment, never in the board module itself:
|
|
181
|
-
|
|
182
|
-
| Variable | Where it is |
|
|
183
|
-
| --- | --- |
|
|
184
|
-
| `SLACK_BOT_TOKEN` | **OAuth & Permissions**, Bot User OAuth Token, `xoxb-...` |
|
|
185
|
-
| `SLACK_SIGNING_SECRET` | **Basic Information**, App Credentials, Signing Secret |
|
|
186
|
-
|
|
187
|
-
### 3. Find the IDs
|
|
188
|
-
|
|
189
|
-
- **The channel:** invite the app with `/invite @muster`, then open the
|
|
190
|
-
channel's details: its ID, `C...`, is at the bottom of the About tab.
|
|
191
|
-
- **The bot:** `auth.test` returns it as `bot_id`, `B...`.
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
curl -s -H "Authorization: Bearer $SLACK_BOT_TOKEN" https://slack.com/api/auth.test
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
### 4. Map the channel and start the board
|
|
198
|
-
|
|
199
|
-
Write the `chat` sync in the board module as shown at the top of this page,
|
|
200
|
-
with the channel and `bot`. `mu serve` reads the module when it starts:
|
|
201
|
-
restart it after a change.
|
|
202
|
-
|
|
203
|
-
Without `bot`, messages from every bot in a mapped channel are skipped, not
|
|
204
|
-
only the app's own.
|
|
205
|
-
|
|
206
|
-
### 5. Turn on events
|
|
207
|
-
|
|
208
|
-
In **Event Subscriptions**, turn events on and set the request URL to
|
|
209
|
-
`https://<host>/api/board/webhooks/chat`. The board answers Slack's check
|
|
210
|
-
itself, and the URL shows as verified. Subscribe to the bot events
|
|
211
|
-
`message.channels` and `message.groups`, save, and reinstall the app if Slack
|
|
212
|
-
asks.
|
|
213
|
-
|
|
214
|
-
### 6. Check it
|
|
215
|
-
|
|
216
|
-
Post a message in the channel: it arrives as a thread in the mapped board
|
|
217
|
-
channel, labelled `source=chat`. Reply to it on the board, and the reply
|
|
218
|
-
appears in the Slack thread from the app.
|
|
219
|
-
|
|
220
|
-
## Keep the noise down
|
|
221
|
-
|
|
222
|
-
Report milestones and skip the "still working" updates: every reply in a mirrored thread reaches
|
|
223
|
-
people in Slack. Use `--no-sync` for a work log that only the board needs.
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
mu reply 12 "ran the suite: 40 of 40" --no-sync
|
|
227
|
-
mu reply 12 "fixed in a1b2c3"
|
|
228
|
-
```
|
|
229
|
+
`channels:history` and `groups:history` scopes in the manifest already
|
|
230
|
+
allow. Slack gives an app made for your own workspace, as in
|
|
231
|
+
[Set it up](#set-it-up), 50 or more of each a minute; an app installed from
|
|
232
|
+
outside the Slack Marketplace gets far fewer, and with many channels mapped,
|
|
233
|
+
catch-up then mostly waits.
|
|
@@ -5,7 +5,15 @@ description: Map a Notion database to a channel, so each page becomes a thread w
|
|
|
5
5
|
|
|
6
6
|
Guides that use it: [A feedback loop](../03-guides/20-a-feedback-loop.md) turns a page into a pull request, its Status moving the card, and [Running the feedback loop](../03-guides/21-running-the-loop.md) covers the day-to-day.
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## Set it up
|
|
9
|
+
|
|
10
|
+
### 1. Create the integration
|
|
11
|
+
|
|
12
|
+
Create a Notion integration. `token` is the integration's secret
|
|
13
|
+
(`ntn_…`). Share each mapped database with the integration, and give it the
|
|
14
|
+
capabilities to read content, read comments and insert comments.
|
|
15
|
+
|
|
16
|
+
### 2. Map the databases
|
|
9
17
|
|
|
10
18
|
```ts board.ts
|
|
11
19
|
import { board, env, notion } from '@openmuster/muster'
|
|
@@ -25,38 +33,50 @@ A database maps to a channel, by its data source ID: on a workspace that
|
|
|
25
33
|
predates data sources, by the database's own ID. Either is taken with or
|
|
26
34
|
without dashes. Sync is two-way unless a database sets `mirror: false`.
|
|
27
35
|
|
|
28
|
-
`token` is the integration's secret (`ntn_…`). Share each mapped database
|
|
29
|
-
with the integration, and give it the capabilities to read content, read
|
|
30
|
-
comments and insert comments.
|
|
31
|
-
|
|
32
36
|
`secret` is the webhook subscription's verification token, which Notion
|
|
33
37
|
signs every delivery with. `bot` is optional: the integration's own user ID,
|
|
34
38
|
whose pages and comments are never imported.
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
### 3. Start the board with a pending secret
|
|
37
41
|
|
|
38
42
|
Notion sends its verification token once, to the webhook's URL, signed with
|
|
39
43
|
that same token, and it has to be pasted back into Notion before anything
|
|
40
|
-
else is sent
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
else is sent.
|
|
45
|
+
|
|
46
|
+
Start the board with the sync in its module and `NOTION_WEBHOOK_SECRET`
|
|
47
|
+
set to `pending`. Only then does the board take Notion's one unsigned
|
|
48
|
+
request.
|
|
49
|
+
|
|
50
|
+
### 4. Subscribe the webhook
|
|
51
|
+
|
|
52
|
+
In the integration's settings, under Webhooks, subscribe
|
|
53
|
+
`https://<your host>/api/board/webhooks/nt` to page and comment events.
|
|
54
|
+
|
|
55
|
+
### 5. Verify the token
|
|
56
|
+
|
|
57
|
+
The board writes the token Notion sent to `notion-verification-token`
|
|
58
|
+
in muster's config folder (`~/.config/muster`, or `MUSTER_CONFIG`),
|
|
59
|
+
readable by you alone. It is never logged or answered, and never
|
|
60
|
+
written over: the first one stays.
|
|
61
|
+
|
|
62
|
+
Paste it into Notion's Verify. Anyone can send the board a token, so
|
|
63
|
+
this is the check: one Notion didn't send fails there. If it fails,
|
|
64
|
+
delete the file and have Notion send its token again. Then set
|
|
65
|
+
`NOTION_WEBHOOK_SECRET` to it and start the board again.
|
|
55
66
|
|
|
56
67
|
From then on a delivery without Notion's signature for that token is
|
|
57
68
|
refused.
|
|
58
69
|
|
|
59
|
-
|
|
70
|
+
### 6. Check it
|
|
71
|
+
|
|
72
|
+
Make a page in the mapped database: on the board's next tick it arrives as a
|
|
73
|
+
thread in the mapped channel, labelled `kind=page` and `source=nt`.
|
|
74
|
+
|
|
75
|
+
## Reference
|
|
76
|
+
|
|
77
|
+
What the sync brings in, sends back and catches up on.
|
|
78
|
+
|
|
79
|
+
### What comes in
|
|
60
80
|
|
|
61
81
|
| In Notion | On the board |
|
|
62
82
|
| --- | --- |
|
|
@@ -71,12 +91,13 @@ Notion's webhooks say only what changed, not what it says now. The board
|
|
|
71
91
|
answers each at once and reads the page or comment from Notion's API on its
|
|
72
92
|
next tick, so what it imports is always what Notion says then, and a late
|
|
73
93
|
delivery brings nothing older. A read that fails is tried again on later
|
|
74
|
-
ticks, rather than import less than the page says.
|
|
94
|
+
ticks, rather than import less than the page says. One Notion won't answer for
|
|
95
|
+
24 hours is given up with a `sync.dropped` event. A page's text is cut at 9,000 characters,
|
|
75
96
|
with a link to the rest.
|
|
76
97
|
|
|
77
98
|
A page in a database the sync doesn't map is not brought in.
|
|
78
99
|
|
|
79
|
-
|
|
100
|
+
### What goes back
|
|
80
101
|
|
|
81
102
|
- **A reply** in a synced thread is a comment on the page, in pieces of
|
|
82
103
|
2,000 characters, as Notion takes them. Editing or deleting it does the
|
|
@@ -86,7 +107,7 @@ A page in a database the sync doesn't map is not brought in.
|
|
|
86
107
|
- **Files** aren't sent yet: each is named in the comment, and stays on the
|
|
87
108
|
board.
|
|
88
109
|
|
|
89
|
-
|
|
110
|
+
### Catching up
|
|
90
111
|
|
|
91
112
|
A board that was down asks Notion, when it starts, for the pages changed in
|
|
92
113
|
each mapped database since it last heard, oldest first, up to 1,000 a
|