@openmuster/muster 0.3.1-alpha.2 → 0.3.1-alpha.4
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 +19 -17
- package/dist/{args-DHgAmYge.js → args-9ZZDcPxa.js} +2 -2
- package/dist/cli.js +5 -5
- package/dist/index.js +16 -3
- package/dist/inspect/app.js +45 -40
- package/dist/main-D5aX7Jaj.js +6 -0
- package/dist/{main-A4nHL5oa.js → main-Doit2DDY.js} +242 -21
- package/dist/mcp-Cm96TIb3.js +6 -0
- package/dist/{module-DOkWwWoU.js → module-D8qcE3e7.js} +1 -1
- package/dist/{module-CT_R33MB.js → module-DjDMSEKu.js} +2 -2
- package/dist/{steps-ByzmEzLQ.js → steps-BUPRIOe3.js} +1 -1
- package/docs/01-concepts/01-overview.md +7 -2
- package/docs/01-concepts/02-boards.md +4 -4
- package/docs/01-concepts/03-channels.md +1 -1
- package/docs/01-concepts/04-threads.md +1 -3
- package/docs/01-concepts/05-labels.md +1 -1
- package/docs/01-concepts/06-actors.md +1 -1
- package/docs/01-concepts/07-events.md +11 -4
- package/docs/01-concepts/08-tasks.md +8 -4
- package/docs/01-concepts/09-watchers.md +7 -4
- package/docs/01-concepts/10-schedules.md +1 -1
- package/docs/01-concepts/11-access.md +46 -43
- package/docs/01-concepts/12-files-and-data.md +1 -1
- package/docs/01-concepts/13-budgets.md +1 -1
- package/docs/01-concepts/14-runners.md +9 -8
- package/docs/01-concepts/15-outgoing-webhooks.md +2 -2
- package/docs/01-concepts/16-workflows.md +6 -6
- package/docs/01-concepts/17-board-module.md +8 -6
- package/docs/01-quickstart.md +8 -6
- package/docs/02-sync/01-overview.md +33 -26
- package/docs/02-sync/02-github.md +5 -4
- package/docs/02-sync/03-linear.md +21 -21
- package/docs/02-sync/04-slack.md +7 -11
- package/docs/02-sync/05-notion.md +3 -1
- package/docs/02-sync/meta.json +4 -0
- package/docs/03-guides/01-coding-agents.md +2 -2
- package/docs/03-guides/02-swarm.md +4 -4
- package/docs/03-guides/03-factory.md +1 -5
- package/docs/03-guides/04-inspector.md +36 -1
- package/docs/03-guides/05-running-agents.md +13 -1
- package/docs/03-guides/06-sandboxed-agents.md +15 -29
- package/docs/03-guides/07-build-a-ui.md +21 -2
- package/docs/03-guides/08-ci.md +13 -5
- package/docs/03-guides/09-daemon.md +6 -5
- package/docs/03-guides/10-two-agents.md +1 -1
- package/docs/03-guides/11-person-in-the-loop.md +1 -1
- package/docs/03-guides/12-unattended.md +1 -1
- package/docs/03-guides/13-terminals.md +4 -5
- package/docs/03-guides/14-no-cloud.md +1 -1
- package/docs/03-guides/15-several-boards.md +21 -2
- package/docs/03-guides/16-non-code.md +12 -3
- package/docs/03-guides/17-mcp.md +2 -6
- package/docs/03-guides/18-a-board-on-a-server.md +1 -1
- package/docs/03-guides/19-a-card-queue.md +22 -22
- package/docs/03-guides/20-a-feedback-loop.md +14 -6
- package/docs/03-guides/21-running-the-loop.md +16 -9
- package/docs/03-guides/22-building-from-linear.md +326 -0
- package/docs/03-guides/meta.json +32 -0
- package/docs/04-reference/01-cli.md +2 -1
- package/docs/04-reference/02-handle.md +4 -3
- package/docs/04-reference/03-http.md +3 -2
- package/docs/04-reference/04-events.md +1 -1
- package/docs/04-reference/05-errors.md +3 -3
- package/docs/04-reference/06-conformance.md +4 -2
- package/docs/04-reference/07-porting.md +1 -1
- package/docs/index.md +60 -24
- package/docs/meta.json +3 -0
- package/package.json +1 -1
- package/dist/main-CuIC8iF4.js +0 -6
- package/dist/mcp-GkdeWAnr.js +0 -6
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { D as VERSION } from "./args-9ZZDcPxa.js";
|
|
2
|
+
import "./steps-BUPRIOe3.js";
|
|
3
|
+
import { a as main, i as attend, n as agentPrompt, o as meantCommand, r as agentToken, s as repoUrl, t as SPECS } from "./main-Doit2DDY.js";
|
|
4
|
+
import "./module-D8qcE3e7.js";
|
|
5
|
+
|
|
6
|
+
export { SPECS, VERSION, agentPrompt, agentToken, attend, main, meantCommand, repoUrl };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { E as KEEP_LOGS_MS, F as conformance, M as generic, N as isSessionId, O as runLocal, P as http, T as installationToken, _ as BUNDLE_MAX, b as openPullRequest, c as runWorkflows, d as workflowsPath, f as e2b, g as BUNDLE, h as vercel, i as pushesTask, k as AGENTS, l as spawnWorker, m as cloudflare, n as fillResults, p as SANDBOX_ENV, r as pullTitle, s as openRuns, t as FillRefused, u as loadWorkflows, v as branchState, w as githubApp, x as pushBundle, y as githubRepo } from "./steps-
|
|
3
|
-
import { C as begin, D as reset, E as readGuard, O as retryAt, S as STEADY_AFTER, T as guardPath, b as RESTART_LIMIT, c as chooseModule, d as invokedAs, f as launchGuard, k as steady, l as defaultModule, m as loadsModule, p as loadBoard, s as SERVE_SPEC, t as DAEMON_SPEC, u as endLaunch, v as refusal, w as ended, x as RESTART_WINDOW, y as self } from "./module-
|
|
1
|
+
import { A as boardPath, C as listen, D as VERSION, E as RELEASE_HOSTS, F as configDir, I as dropClaim, L as heldClaim, M as boardKey, O as releaseTarball, Q as actorId, R as keepClaim, S as isLoopback, _ as ping, a as list, at as misuse, c as parse, d as ROOT, f as board, g as armHooks, h as HOOKS_LEASE, i as id, it as Failure, j as file, k as loadOidc, l as str, m as DROPPED, n as cursor, nt as labelFilter, o as on, p as syncLoop, q as processStart, r as duration, rt as profileName, s as pairs, t as GLOBAL, v as why, w as ROUTES, y as holdLease } from "./args-9ZZDcPxa.js";
|
|
2
|
+
import { E as KEEP_LOGS_MS, F as conformance, M as generic, N as isSessionId, O as runLocal, P as http, T as installationToken, _ as BUNDLE_MAX, b as openPullRequest, c as runWorkflows, d as workflowsPath, f as e2b, g as BUNDLE, h as vercel, i as pushesTask, k as AGENTS, l as spawnWorker, m as cloudflare, n as fillResults, p as SANDBOX_ENV, r as pullTitle, s as openRuns, t as FillRefused, u as loadWorkflows, v as branchState, w as githubApp, x as pushBundle, y as githubRepo } from "./steps-BUPRIOe3.js";
|
|
3
|
+
import { C as begin, D as reset, E as readGuard, O as retryAt, S as STEADY_AFTER, T as guardPath, b as RESTART_LIMIT, c as chooseModule, d as invokedAs, f as launchGuard, k as steady, l as defaultModule, m as loadsModule, p as loadBoard, s as SERVE_SPEC, t as DAEMON_SPEC, u as endLaunch, v as refusal, w as ended, x as RESTART_WINDOW, y as self } from "./module-D8qcE3e7.js";
|
|
4
4
|
import { chmodSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { homedir, tmpdir } from "node:os";
|
|
6
6
|
import { basename, dirname, join, resolve } from "node:path";
|
|
@@ -10,6 +10,90 @@ import { createServer } from "node:http";
|
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
11
|
import { createInterface } from "node:readline";
|
|
12
12
|
|
|
13
|
+
//#region src/cli/update.ts
|
|
14
|
+
/**
|
|
15
|
+
* Says when a newer muster is out, for whoever asked to be told: off unless `MUSTER_UPDATE_CHECK=1`.
|
|
16
|
+
* muster makes no request of its own otherwise. Asked for, it asks npm's registry (or the one
|
|
17
|
+
* `npm_config_registry` names) for the version tagged latest, at most once a day, from a process of
|
|
18
|
+
* its own that no command waits for, and sends nothing but that request. What it learned is kept in
|
|
19
|
+
* the config folder, and the next command in a terminal says so in one line on stderr.
|
|
20
|
+
*/
|
|
21
|
+
const PACKAGE = "@openmuster/muster";
|
|
22
|
+
/** A release number and nothing else: what the registry or the kept file says is printed only if it is one. */
|
|
23
|
+
const RELEASE = /^\d{1,6}\.\d{1,6}\.\d{1,6}(-[0-9A-Za-z]{1,20}(\.[0-9A-Za-z]{1,20}){0,3})?$/;
|
|
24
|
+
const DAY = 1440 * 60 * 1e3;
|
|
25
|
+
/** Release numbers in order: 0.3.1-alpha.2 < 0.3.1-alpha.10 < 0.3.1-beta.1 < 0.3.1. Negative when a is older. */
|
|
26
|
+
function compareVersions(a, b) {
|
|
27
|
+
const split = (version) => {
|
|
28
|
+
const [core, pre] = version.split(/-(.*)/s, 2);
|
|
29
|
+
return {
|
|
30
|
+
core: core.split(".").map(Number),
|
|
31
|
+
pre: pre === void 0 ? null : pre.split(".")
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const x = split(a);
|
|
35
|
+
const y = split(b);
|
|
36
|
+
for (let i = 0; i < 3; i++) if ((x.core[i] ?? 0) !== (y.core[i] ?? 0)) return (x.core[i] ?? 0) - (y.core[i] ?? 0);
|
|
37
|
+
if (x.pre === null || y.pre === null) return x.pre === y.pre ? 0 : x.pre === null ? 1 : -1;
|
|
38
|
+
for (let i = 0; i < Math.max(x.pre.length, y.pre.length); i++) {
|
|
39
|
+
const p = x.pre[i];
|
|
40
|
+
const q = y.pre[i];
|
|
41
|
+
if (p === void 0 || q === void 0) return p === void 0 ? -1 : 1;
|
|
42
|
+
if (p === q) continue;
|
|
43
|
+
return /^\d+$/.test(p) && /^\d+$/.test(q) ? Number(p) - Number(q) : p < q ? -1 : 1;
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
const checkPath = (env) => join(env.MUSTER_CONFIG ?? join(env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "muster"), "update-check.json");
|
|
48
|
+
const registryOf = (env) => (env.npm_config_registry || "https://registry.npmjs.org").replace(/\/+$/, "");
|
|
49
|
+
/** Whether to say anything, and whether to ask again: only for someone who opted in, at a terminal. */
|
|
50
|
+
function updateNotice(input) {
|
|
51
|
+
const { version, env, tty, json, now, checked } = input;
|
|
52
|
+
if (env.MUSTER_UPDATE_CHECK !== "1" || !tty || json || env.CI || version === "0.0.0") return {
|
|
53
|
+
notice: null,
|
|
54
|
+
ask: false
|
|
55
|
+
};
|
|
56
|
+
const newer = typeof checked?.latest === "string" && RELEASE.test(checked.latest) && compareVersions(checked.latest, version) > 0 ? checked.latest : null;
|
|
57
|
+
return {
|
|
58
|
+
notice: newer ? `muster ${newer} is out; this is ${version}. npm install -g ${PACKAGE}` : null,
|
|
59
|
+
ask: checked === null || !(now - checked.checked < DAY)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function readChecked(path) {
|
|
63
|
+
try {
|
|
64
|
+
const found = JSON.parse(readFileSync(path, "utf8"));
|
|
65
|
+
return typeof found.checked === "number" ? found : null;
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const ASK = `
|
|
71
|
+
const [path, url, before] = process.argv.slice(1)
|
|
72
|
+
const fs = require('node:fs')
|
|
73
|
+
const write = (latest) => { try { fs.mkdirSync(require('node:path').dirname(path), { recursive: true }); fs.writeFileSync(path, JSON.stringify({ checked: Date.now(), latest })) } catch {} }
|
|
74
|
+
fetch(url, { signal: AbortSignal.timeout(5000), headers: { accept: 'application/json' } })
|
|
75
|
+
.then((response) => (response.ok ? response.json() : null))
|
|
76
|
+
.then((tags) => write(tags && typeof tags.latest === 'string' ? tags.latest : before || null), () => write(before || null))
|
|
77
|
+
`;
|
|
78
|
+
/** Starts the check and leaves it: the command that started it ends when it would have. */
|
|
79
|
+
function ask(env, checked) {
|
|
80
|
+
const url = `${registryOf(env)}/-/package/${PACKAGE.replace("/", "%2f")}/dist-tags`;
|
|
81
|
+
try {
|
|
82
|
+
spawn(process.execPath, [
|
|
83
|
+
"-e",
|
|
84
|
+
ASK,
|
|
85
|
+
checkPath(env),
|
|
86
|
+
url,
|
|
87
|
+
checked?.latest ?? ""
|
|
88
|
+
], {
|
|
89
|
+
detached: true,
|
|
90
|
+
stdio: "ignore",
|
|
91
|
+
env
|
|
92
|
+
}).unref();
|
|
93
|
+
} catch {}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
13
97
|
//#region src/cli/format.ts
|
|
14
98
|
/** How long ago, or how long until, in a word: `11s`, `5m`, `3h`, `2d`. */
|
|
15
99
|
function span(ms) {
|
|
@@ -734,7 +818,8 @@ serve
|
|
|
734
818
|
MUSTER_INSECURE_HTTP=1: for a network that is private some other way.
|
|
735
819
|
|
|
736
820
|
states: waiting, ready, claimed, blocked, completed, failed, canceled
|
|
737
|
-
exit: 0 ok, 1 failed or timed out, 2 misuse, 130 interrupted, 143 terminated
|
|
821
|
+
exit: 0 ok, 1 failed or timed out, 2 misuse, 130 interrupted, 143 terminated
|
|
822
|
+
update: MUSTER_UPDATE_CHECK=1 says, once a day, when a newer muster is out`;
|
|
738
823
|
const GLOBAL_LINE = "global: [--as <profile>] [--board <name>] [--dir <path>] [--url <board url>] [--json]";
|
|
739
824
|
/**
|
|
740
825
|
* One command's part of the help: its lines as the whole help has them, under the section they are in,
|
|
@@ -860,6 +945,7 @@ function inspect(options) {
|
|
|
860
945
|
if (req.method !== "POST") throw new Failure("not_found", "No such route.");
|
|
861
946
|
if (req.headers.origin !== origin) throw new Failure("forbidden", "Writes come from the inspector page.");
|
|
862
947
|
const route = url.pathname.slice(7);
|
|
948
|
+
if (route === "whoami") return send(res, 200, { ok: actorId(await options.backend.self(null)) });
|
|
863
949
|
const answering = route === "joinList" || route === "joinApprove" || route === "joinDeny";
|
|
864
950
|
if (!ALLOWED.has(route) && !answering) throw new Failure("not_found", "No such route.");
|
|
865
951
|
const chunks = [];
|
|
@@ -1100,6 +1186,33 @@ async function checkWatcher(run, parsed, mode, guardAt) {
|
|
|
1100
1186
|
}
|
|
1101
1187
|
}
|
|
1102
1188
|
const stopCode = (signal) => signal.reason === "SIGTERM" ? 143 : 130;
|
|
1189
|
+
/**
|
|
1190
|
+
* Rides out a board that is out of reach for now, for a command that waits: a gateway's 502 or a dropped
|
|
1191
|
+
* connection isn't an answer, so the poll goes again after a pause that doubles, as the daemon's does.
|
|
1192
|
+
* Only once the command has reached the board (`ok`): a board out of reach from the start is said at
|
|
1193
|
+
* once, as any command says it. `failed` rethrows what isn't an outage, and an outage whose next try
|
|
1194
|
+
* would come after the deadline, so the command says what went wrong rather than that nothing came.
|
|
1195
|
+
* With no deadline it waits for as long as the command runs. A stop ends the pause at once, and
|
|
1196
|
+
* `failed` returns: the caller checks the stop and exits as stopped.
|
|
1197
|
+
*/
|
|
1198
|
+
function outages(run, deadline) {
|
|
1199
|
+
let failing = 0;
|
|
1200
|
+
let reached = false;
|
|
1201
|
+
return {
|
|
1202
|
+
ok() {
|
|
1203
|
+
reached = true;
|
|
1204
|
+
failing = 0;
|
|
1205
|
+
},
|
|
1206
|
+
async failed(error$1) {
|
|
1207
|
+
if (run.io.stop.aborted) return;
|
|
1208
|
+
if (!reached || !(error$1 instanceof Failure) || !UNREACHABLE.has(error$1.reason)) throw error$1;
|
|
1209
|
+
const pause = Math.min(FAILING_PAUSE, 500 * 2 ** failing++);
|
|
1210
|
+
if (deadline !== void 0 && Date.now() + pause >= deadline) throw error$1;
|
|
1211
|
+
if (!run.json && (failing & failing - 1) === 0) run.io.err(`error ${error$1.message} Trying again.${failing > 1 ? ` (${failing} tries in a row)` : ""}`);
|
|
1212
|
+
await sleep(pause, run.io.stop);
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1103
1216
|
/** An argument as a shell takes it, quoted only when it has to be. */
|
|
1104
1217
|
const shell = (arg) => /^[\w@%+=:,./-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", `'\\''`)}'`;
|
|
1105
1218
|
function textOf(parsed, at, io) {
|
|
@@ -1337,13 +1450,24 @@ const commands = {
|
|
|
1337
1450
|
if (limit !== void 0 && !/^[1-9][0-9]*$/.test(limit)) throw misuse("invalid_limit", "--limit takes a whole number of at least 1.");
|
|
1338
1451
|
const deadline = wait === void 0 ? 0 : Date.now() + duration(wait, "wait") * 1e3;
|
|
1339
1452
|
let after = await run.team.cursorGet("inbox") ?? 0;
|
|
1453
|
+
const outage = wait === void 0 ? null : outages(run, deadline);
|
|
1454
|
+
outage?.ok();
|
|
1340
1455
|
let pause = 100;
|
|
1341
1456
|
for (;;) {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1457
|
+
let page;
|
|
1458
|
+
try {
|
|
1459
|
+
page = await run.team.events({
|
|
1460
|
+
after,
|
|
1461
|
+
filter: { for: mine },
|
|
1462
|
+
limit: limit === void 0 ? 50 : Number(limit)
|
|
1463
|
+
});
|
|
1464
|
+
outage?.ok();
|
|
1465
|
+
} catch (error$1) {
|
|
1466
|
+
if (outage === null) throw error$1;
|
|
1467
|
+
await outage.failed(error$1);
|
|
1468
|
+
if (run.io.stop.aborted) return stopCode(run.io.stop);
|
|
1469
|
+
continue;
|
|
1470
|
+
}
|
|
1347
1471
|
after = page.cursor;
|
|
1348
1472
|
if (page.events.length > 0 || Date.now() >= deadline || run.io.stop.aborted) {
|
|
1349
1473
|
if (!peek) await run.team.cursorSet("inbox", page.cursor);
|
|
@@ -1636,16 +1760,26 @@ const commands = {
|
|
|
1636
1760
|
async run(run, parsed) {
|
|
1637
1761
|
const filter = filterOf(parsed, 0);
|
|
1638
1762
|
const given = str(parsed.flags, "after");
|
|
1639
|
-
let after = given !== void 0 ? cursor(given, "after") : await run.team.head();
|
|
1640
1763
|
const timeout = duration(str(parsed.flags, "timeout") ?? "30m", "timeout") * 1e3;
|
|
1641
1764
|
const deadline = Date.now() + timeout;
|
|
1765
|
+
const outage = outages(run, deadline);
|
|
1766
|
+
let after = given !== void 0 ? cursor(given, "after") : await run.team.head();
|
|
1767
|
+
if (given === void 0) outage.ok();
|
|
1642
1768
|
let pause = 100;
|
|
1643
1769
|
for (;;) {
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1770
|
+
let page;
|
|
1771
|
+
try {
|
|
1772
|
+
page = await run.team.events({
|
|
1773
|
+
after,
|
|
1774
|
+
filter,
|
|
1775
|
+
limit: 1
|
|
1776
|
+
});
|
|
1777
|
+
outage.ok();
|
|
1778
|
+
} catch (error$1) {
|
|
1779
|
+
await outage.failed(error$1);
|
|
1780
|
+
if (run.io.stop.aborted) return stopCode(run.io.stop);
|
|
1781
|
+
continue;
|
|
1782
|
+
}
|
|
1649
1783
|
after = page.cursor;
|
|
1650
1784
|
const event = page.events[0];
|
|
1651
1785
|
if (event) {
|
|
@@ -1684,12 +1818,21 @@ const commands = {
|
|
|
1684
1818
|
});
|
|
1685
1819
|
for (const event of all.events.slice(-count)) run.io.out(run.json ? JSON.stringify(event) : eventLine(event, run.now()));
|
|
1686
1820
|
}
|
|
1821
|
+
const outage = outages(run);
|
|
1822
|
+
if (given === void 0) outage.ok();
|
|
1687
1823
|
let pause = 100;
|
|
1688
1824
|
while (!run.io.stop.aborted) {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1825
|
+
let page;
|
|
1826
|
+
try {
|
|
1827
|
+
page = await run.team.events({
|
|
1828
|
+
after,
|
|
1829
|
+
filter
|
|
1830
|
+
});
|
|
1831
|
+
outage.ok();
|
|
1832
|
+
} catch (error$1) {
|
|
1833
|
+
await outage.failed(error$1);
|
|
1834
|
+
continue;
|
|
1835
|
+
}
|
|
1693
1836
|
after = page.cursor;
|
|
1694
1837
|
for (const event of page.events) run.io.out(run.json ? JSON.stringify(event) : eventLine(event, run.now()));
|
|
1695
1838
|
pause = page.events.length ? 100 : Math.min(pause * 2, 1e3);
|
|
@@ -2426,6 +2569,60 @@ const TASK_VERBS = [
|
|
|
2426
2569
|
"needs",
|
|
2427
2570
|
"run"
|
|
2428
2571
|
];
|
|
2572
|
+
/**
|
|
2573
|
+
* The flags each verb takes. `tasks` parses the flags of all of them, so without this a flag only another
|
|
2574
|
+
* verb reads was taken and dropped: `tasks complete 5 --file report.md` completed with no result.
|
|
2575
|
+
*/
|
|
2576
|
+
const CLAIM_FLAGS = [
|
|
2577
|
+
"ready",
|
|
2578
|
+
"label",
|
|
2579
|
+
"from",
|
|
2580
|
+
"by",
|
|
2581
|
+
"lease",
|
|
2582
|
+
"wait"
|
|
2583
|
+
];
|
|
2584
|
+
const TASK_FLAGS = {
|
|
2585
|
+
list: [
|
|
2586
|
+
"state",
|
|
2587
|
+
"limit",
|
|
2588
|
+
"label",
|
|
2589
|
+
"latest"
|
|
2590
|
+
],
|
|
2591
|
+
create: [
|
|
2592
|
+
"label",
|
|
2593
|
+
"needs",
|
|
2594
|
+
"for",
|
|
2595
|
+
"claim",
|
|
2596
|
+
"lease",
|
|
2597
|
+
"hold",
|
|
2598
|
+
"reason",
|
|
2599
|
+
"file",
|
|
2600
|
+
"idempotency-key",
|
|
2601
|
+
"no-sync"
|
|
2602
|
+
],
|
|
2603
|
+
claim: CLAIM_FLAGS,
|
|
2604
|
+
renew: ["lease"],
|
|
2605
|
+
release: [],
|
|
2606
|
+
complete: ["result"],
|
|
2607
|
+
fail: ["reason", "no-count"],
|
|
2608
|
+
block: ["reason", "kind"],
|
|
2609
|
+
unblock: [],
|
|
2610
|
+
reopen: ["round"],
|
|
2611
|
+
cancel: [],
|
|
2612
|
+
assign: ["for", "pool"],
|
|
2613
|
+
needs: ["none"],
|
|
2614
|
+
run: [...CLAIM_FLAGS, "result"]
|
|
2615
|
+
};
|
|
2616
|
+
function refuseOtherVerbsFlags(verb, flags) {
|
|
2617
|
+
const takes = TASK_FLAGS[verb];
|
|
2618
|
+
const global = new Set([...GLOBAL.value, ...GLOBAL.bool]);
|
|
2619
|
+
const other = Object.keys(flags).find((name) => !global.has(name) && !takes.includes(name));
|
|
2620
|
+
if (other === void 0) return;
|
|
2621
|
+
const command = verb === "list" ? "mu tasks" : `mu tasks ${verb}`;
|
|
2622
|
+
const what = takes.length ? `${command} takes ${takes.map((name) => `--${name}`).join(", ")}.` : `${command} takes no flags of its own.`;
|
|
2623
|
+
const report = (verb === "complete" || verb === "fail" || verb === "block") && other === "file" ? " A long report goes in a reply: mu reply <thread> --file <path>." : "";
|
|
2624
|
+
throw misuse("unknown_flag", `--${other} isn't a flag of ${command}.`, what + report);
|
|
2625
|
+
}
|
|
2429
2626
|
const lease = (flags) => {
|
|
2430
2627
|
const value = str(flags, "lease");
|
|
2431
2628
|
return value === void 0 ? {} : { lease: duration(value, "lease") };
|
|
@@ -2469,6 +2666,8 @@ async function claimWith(run, parsed, target, me, pid) {
|
|
|
2469
2666
|
};
|
|
2470
2667
|
const wait = str(parsed.flags, "wait");
|
|
2471
2668
|
const deadline = wait === void 0 ? 0 : Date.now() + duration(wait, "wait") * 1e3;
|
|
2669
|
+
const outage = ready !== void 0 && wait !== void 0 ? outages(run, deadline) : null;
|
|
2670
|
+
outage?.ok();
|
|
2472
2671
|
let pause = 100;
|
|
2473
2672
|
for (;;) try {
|
|
2474
2673
|
const claimed = await run.team.taskClaim(request);
|
|
@@ -2478,6 +2677,11 @@ async function claimWith(run, parsed, target, me, pid) {
|
|
|
2478
2677
|
});
|
|
2479
2678
|
return claimed;
|
|
2480
2679
|
} catch (error$1) {
|
|
2680
|
+
if (outage !== null && error$1 instanceof Failure && UNREACHABLE.has(error$1.reason)) {
|
|
2681
|
+
await outage.failed(error$1);
|
|
2682
|
+
if (run.io.stop.aborted) throw error$1;
|
|
2683
|
+
continue;
|
|
2684
|
+
}
|
|
2481
2685
|
if (!(error$1 instanceof Failure) || error$1.reason !== "nothing_ready" || ready === void 0 || wait === void 0) throw error$1;
|
|
2482
2686
|
if (run.io.stop.aborted) throw error$1;
|
|
2483
2687
|
if (Date.now() >= deadline) throw new Failure("timeout", `Nothing was ready in ${ready} within ${wait}.`, { hint: "That isn't a failure of the work: there is nothing to take." });
|
|
@@ -2488,6 +2692,7 @@ async function claimWith(run, parsed, target, me, pid) {
|
|
|
2488
2692
|
async function tasks(run, parsed) {
|
|
2489
2693
|
const verb = parsed.positionals[0];
|
|
2490
2694
|
const now = () => run.now();
|
|
2695
|
+
refuseOtherVerbsFlags(verb !== void 0 && TASK_VERBS.includes(verb) ? verb : "list", parsed.flags);
|
|
2491
2696
|
if (verb === void 0 || !TASK_VERBS.includes(verb)) {
|
|
2492
2697
|
const state = str(parsed.flags, "state");
|
|
2493
2698
|
const labels = list(parsed.flags, "label");
|
|
@@ -3731,12 +3936,28 @@ async function main(argv, io) {
|
|
|
3731
3936
|
const command = commands[name];
|
|
3732
3937
|
try {
|
|
3733
3938
|
const parsed = parse(argv.slice(1), command.spec);
|
|
3734
|
-
|
|
3735
|
-
|
|
3939
|
+
const code = name === "daemon" && parsed.positionals[0] === "run" && !runsModule(parsed.flags, io.env) ? await counted(guardOf(parsed.flags, io.env).path, io, () => dispatch(name, command, parsed, io, json)) : await dispatch(name, command, parsed, io, json);
|
|
3940
|
+
newerRelease(io, json);
|
|
3941
|
+
return code;
|
|
3736
3942
|
} catch (error$1) {
|
|
3737
3943
|
return fail(io, json, error$1);
|
|
3738
3944
|
}
|
|
3739
3945
|
}
|
|
3946
|
+
/** For whoever opted in with MUSTER_UPDATE_CHECK=1: one line when a newer release is out (update.ts). */
|
|
3947
|
+
function newerRelease(io, json) {
|
|
3948
|
+
if (io.env.MUSTER_UPDATE_CHECK !== "1") return;
|
|
3949
|
+
const checked = readChecked(checkPath(io.env));
|
|
3950
|
+
const { notice, ask: again } = updateNotice({
|
|
3951
|
+
version: VERSION,
|
|
3952
|
+
env: io.env,
|
|
3953
|
+
tty: io.tty === true,
|
|
3954
|
+
json,
|
|
3955
|
+
now: Date.now(),
|
|
3956
|
+
checked
|
|
3957
|
+
});
|
|
3958
|
+
if (notice) io.err(notice);
|
|
3959
|
+
if (again) ask(io.env, checked);
|
|
3960
|
+
}
|
|
3740
3961
|
/** How often a stopped daemon reads its record again, to see whether it may start. */
|
|
3741
3962
|
const GUARD_POLL = 2e3;
|
|
3742
3963
|
/** Whether this command line runs a board module. A choice that is misuse is dispatch's to say. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as VERSION, F as configDir, at as misuse, c as parse, it as Failure, u as COPY } from "./args-9ZZDcPxa.js";
|
|
2
2
|
import { registerHooks } from "node:module";
|
|
3
3
|
import { chmodSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { constants } from "node:os";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./args-
|
|
2
|
-
import { _ as prepare, a as REEXEC_DEPTH, c as chooseModule, d as invokedAs, f as launchGuard, g as plan, h as musterFor, i as REEXEC, l as defaultModule, m as loadsModule, n as LAUNCH, o as REEXEC_FROM, p as loadBoard, r as MODULE_PROTOCOL, s as SERVE_SPEC, t as DAEMON_SPEC, u as endLaunch, v as refusal, y as self } from "./module-
|
|
1
|
+
import "./args-9ZZDcPxa.js";
|
|
2
|
+
import { _ as prepare, a as REEXEC_DEPTH, c as chooseModule, d as invokedAs, f as launchGuard, g as plan, h as musterFor, i as REEXEC, l as defaultModule, m as loadsModule, n as LAUNCH, o as REEXEC_FROM, p as loadBoard, r as MODULE_PROTOCOL, s as SERVE_SPEC, t as DAEMON_SPEC, u as endLaunch, v as refusal, y as self } from "./module-D8qcE3e7.js";
|
|
3
3
|
|
|
4
4
|
export { DAEMON_SPEC, LAUNCH, MODULE_PROTOCOL, REEXEC, REEXEC_DEPTH, REEXEC_FROM, SERVE_SPEC, chooseModule, defaultModule, endLaunch, invokedAs, launchGuard, loadBoard, loadsModule, musterFor, plan, prepare, refusal, self };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as configDir, J as OPEN_STATES, Q as actorId, T as SANDBOX_ROUTES, X as PROGRESS, Y as LIMITS, Z as WORKFLOWS_PROFILE, b as MOUNT, et as channelScope, it as Failure, r as duration, tt as inScope, w as ROUTES } from "./args-9ZZDcPxa.js";
|
|
2
2
|
import { chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Concepts
|
|
3
|
-
description:
|
|
3
|
+
description: A board holds channels, threads, tasks, events and actors. How they fit together, how work moves between a person and an agent, and when to use one agent, two, or a swarm.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## The shape of a board
|
|
@@ -30,8 +30,13 @@ it waits for something, or it moves a task.
|
|
|
30
30
|
| Watcher | A rule that runs your command when something happens | [Watchers](./09-watchers.md) |
|
|
31
31
|
| Schedule | A message sent later, or on repeat | [Schedules](./10-schedules.md) |
|
|
32
32
|
| Access | Who may read and write: trust modes, tokens, private channels | [Access](./11-access.md) |
|
|
33
|
+
| Files and typed data | Files on a message, and JSON blocks the board checks | [Files and typed data](./12-files-and-data.md) |
|
|
34
|
+
| Budget | A cap on what the tasks under a channel may cost | [Budgets](./13-budgets.md) |
|
|
33
35
|
| Runner | What starts an agent on a task: here, or in a cloud sandbox | [Runners](./14-runners.md) |
|
|
34
|
-
|
|
|
36
|
+
| Outgoing webhook | Board events POSTed to a URL of yours, signed | [Outgoing webhooks](./15-outgoing-webhooks.md) |
|
|
37
|
+
| Workflow | A plan of tasks and a crew of workers you start on a thread | [Workflows](./16-workflows.md) |
|
|
38
|
+
| Board module | One file that declares a board's watchers, sync and webhooks | [The board module and hosts](./17-board-module.md) |
|
|
39
|
+
| Sync | Threads mirrored with GitHub, Linear, Slack or Notion | [Sync](../02-sync/01-overview.md) |
|
|
35
40
|
|
|
36
41
|
## How work moves
|
|
37
42
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Boards and backends
|
|
3
|
-
description:
|
|
3
|
+
description: A board is one SQLite file, or a board behind mu serve reached over HTTP. Choose which board a command uses, see how writes are kept safe, and pick between the file() and http() backends.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## A board is a file
|
|
@@ -29,10 +29,10 @@ mu read general --dir ./.muster
|
|
|
29
29
|
is the cursor everything reads by. Events are never changed or removed.
|
|
30
30
|
- **Tables follow the log.** Messages, tasks and the rest are tables updated in
|
|
31
31
|
the same transaction as the event. Rebuilding them from the log alone gives
|
|
32
|
-
the same tables
|
|
32
|
+
the same tables.
|
|
33
33
|
- **One writer at a time, and nothing lost.** Every command is one transaction.
|
|
34
|
-
Of several processes racing for one claim, exactly one wins
|
|
35
|
-
writing at once
|
|
34
|
+
Of several processes racing for one claim, exactly one wins, and many
|
|
35
|
+
processes writing at once lose no write.
|
|
36
36
|
- **A file it can't read is set aside.** A corrupt board is copied next to
|
|
37
37
|
itself and refused, never recreated or written over.
|
|
38
38
|
- **Local disks only.** A filesystem that can't keep a write-ahead log, as some
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Channels
|
|
3
|
-
description:
|
|
3
|
+
description: Channels are slash-separated paths like work/login that hold threads. One exists once something is posted in it, a trailing slash selects a whole subtree, and a private channel is reachable only by a token that names it.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## What a channel is
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Threads and messages
|
|
3
|
-
description:
|
|
3
|
+
description: A post starts a thread, and every reply sits one level under it. Message size, reactions, edits checked by revision, what a delete removes, writes that are safe to retry, and keeping a message off synced platforms.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## A thread
|
|
@@ -22,8 +22,6 @@ them as printed.
|
|
|
22
22
|
```bash
|
|
23
23
|
mu post dev "deploy is red" --label kind=bug --as lead
|
|
24
24
|
mu reply 12 "looking" --as claude
|
|
25
|
-
mu channels
|
|
26
|
-
mu channels create factory/security --private
|
|
27
25
|
```
|
|
28
26
|
|
|
29
27
|
A message holds up to 10,000 characters. Longer text goes in a file:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Labels
|
|
3
|
-
description:
|
|
3
|
+
description: Labels are key=value pairs that hold a thread's shared state, such as its owner or step. Filter reads, waits and claims by them, and use conditional writes so exactly one of several agents wins.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## What labels are for
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Actors
|
|
3
|
-
description:
|
|
3
|
+
description: Every message records its author as a principal, such as your OS user or a token's subject, plus an optional profile naming the agent. What a profile does not prove, who may change a message, and how mentions work.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Principals and profiles
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Events and waiting
|
|
3
|
-
description:
|
|
3
|
+
description: Every change on a board is an event in one log. Read a channel or thread, page with cursors, filter and search, block until something matches with mu wait, or follow the log with mu tail.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
Every change on a board is an event in one log, which you read, wait on or
|
|
7
|
+
follow.
|
|
8
|
+
|
|
6
9
|
## A channel, or a thread
|
|
7
10
|
|
|
8
11
|
```bash
|
|
@@ -59,13 +62,17 @@ and exits 0.
|
|
|
59
62
|
- A timeout exits 1 with the reason `timeout`, and the cursor it reached. That
|
|
60
63
|
isn't an answer.
|
|
61
64
|
- Filters: a channel or subtree, `--re <root>`, `--label`, `--by <who>`,
|
|
62
|
-
`--mentions <who>`, `--for <profile>`, `--text`, `--type`, `--kind
|
|
63
|
-
event under it: `task.`.
|
|
65
|
+
`--mentions <who>`, `--for <profile>`, `--text`, `--type`, `--kind`,
|
|
66
|
+
`--root`. A type ending in `.` takes every event under it: `task.`.
|
|
67
|
+
- `--root` leaves out events about replies: a reply posted, edited, deleted,
|
|
68
|
+
labelled or reacted to. Events about first messages and tasks still match.
|
|
64
69
|
- `--kind` is about blocks. `--kind needs_input` keeps only `task.blocked`
|
|
65
70
|
events of that kind; `--kind '!backlog'` drops blocks of that kind and keeps
|
|
66
71
|
everything else.
|
|
67
72
|
- An event matches a label filter if its thread matched before it or after it,
|
|
68
|
-
so a task leaving a state is news for a filter on that state.
|
|
73
|
+
so a task leaving a state is news for a filter on that state. A label that
|
|
74
|
+
leaves the filter wakes a wait on it too: `mu wait --label kind=bug` returns
|
|
75
|
+
when a thread's `kind=bug` is changed or removed.
|
|
69
76
|
|
|
70
77
|
## tail
|
|
71
78
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Tasks
|
|
3
|
-
description:
|
|
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
4
|
---
|
|
5
5
|
|
|
6
6
|
## A task is a thread
|
|
@@ -24,8 +24,8 @@ thread, the latest last: on a long-lived board, that is where the work is.
|
|
|
24
24
|
|
|
25
25
|
| State | Means | Gets there by |
|
|
26
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 |
|
|
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
29
|
| `claimed` | One agent holds it, until its lease ends | `claim`, `run` |
|
|
30
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
31
|
| `completed` | Done, with a result | `complete` |
|
|
@@ -39,15 +39,19 @@ stateDiagram-v2
|
|
|
39
39
|
[*] --> ready: create
|
|
40
40
|
[*] --> waiting: create --needs
|
|
41
41
|
[*] --> blocked: create --hold
|
|
42
|
-
waiting --> ready: what it needs completes
|
|
42
|
+
waiting --> ready: what it needs completes, needs
|
|
43
|
+
ready --> waiting: needs
|
|
43
44
|
ready --> claimed: claim, run
|
|
44
45
|
claimed --> ready: release, lease runs out
|
|
45
46
|
claimed --> blocked: block
|
|
46
47
|
blocked --> ready: unblock
|
|
48
|
+
blocked --> waiting: unblock, still needs a task
|
|
47
49
|
claimed --> completed: complete
|
|
48
50
|
claimed --> failed: fail
|
|
49
51
|
completed --> ready: reopen --round
|
|
50
52
|
failed --> ready: reopen
|
|
53
|
+
completed --> waiting: reopen --round, still needs a task
|
|
54
|
+
failed --> waiting: reopen, still needs a task
|
|
51
55
|
ready --> canceled: cancel
|
|
52
56
|
waiting --> canceled: cancel
|
|
53
57
|
claimed --> canceled: cancel
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Watchers and the daemon
|
|
3
|
-
description:
|
|
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
4
|
---
|
|
5
5
|
|
|
6
6
|
## The daemon
|
|
@@ -14,7 +14,8 @@ mu daemon status
|
|
|
14
14
|
[workflows](./16-workflows.md). With a [board module](./17-board-module.md)
|
|
15
15
|
it also runs the module's watchers, its sync and its
|
|
16
16
|
[outgoing webhooks](./15-outgoing-webhooks.md). One process ticks per board:
|
|
17
|
-
a second says so, and stays up
|
|
17
|
+
a second says so, and stays up to stand by when the module has watchers,
|
|
18
|
+
sync or hooks.
|
|
18
19
|
`mu serve` does the same work while it runs. Whichever ticks holds the
|
|
19
20
|
board's `tick` lease, kept in the board's file and renewed every few seconds,
|
|
20
21
|
so one that was killed is replaced within 30 seconds.
|
|
@@ -137,8 +138,10 @@ that answers. It prints who answered and how long it took.
|
|
|
137
138
|
for task events, or only to a platform's users. Write what it listens for
|
|
138
139
|
by hand instead.
|
|
139
140
|
|
|
140
|
-
Whatever the command wakes has to reply. The
|
|
141
|
-
|
|
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.
|
|
142
145
|
|
|
143
146
|
## What it promises
|
|
144
147
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Schedules
|
|
3
|
-
description:
|
|
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
4
|
---
|
|
5
5
|
|
|
6
6
|
## Check back later
|