@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as PROGRESS, Q as LIMITS, R as configDir, T as SANDBOX_ROUTES, Z as OPEN_STATES, b as MOUNT, et as WORKFLOWS_PROFILE, it as inScope, r as duration, rt as channelScope, st as Failure, tt as actorId, w as ROUTES } from "./args-CaFBa2IP.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";
|
|
@@ -898,7 +898,8 @@ function gitRules(repo, token) {
|
|
|
898
898
|
}
|
|
899
899
|
/**
|
|
900
900
|
* Opens a pull request from `head` into `base`, from this machine with the token as it is: the sandbox
|
|
901
|
-
* never reaches GitHub's API. One already open for the branch is answered with its own address
|
|
901
|
+
* never reaches GitHub's API. One already open for the branch is answered with its own address, and
|
|
902
|
+
* `created` false: its body is left as it is.
|
|
902
903
|
*/
|
|
903
904
|
async function openPullRequest(options) {
|
|
904
905
|
const doFetch = options.fetch ?? fetch;
|
|
@@ -921,17 +922,44 @@ async function openPullRequest(options) {
|
|
|
921
922
|
}),
|
|
922
923
|
signal: AbortSignal.timeout(3e4)
|
|
923
924
|
});
|
|
924
|
-
|
|
925
|
+
const answer = (pull, created) => ({
|
|
926
|
+
url: pull.html_url,
|
|
927
|
+
number: Number.isSafeInteger(pull.number) ? pull.number : null,
|
|
928
|
+
created
|
|
929
|
+
});
|
|
930
|
+
if (made.ok) return answer(await made.json(), true);
|
|
925
931
|
if (made.status === 422) {
|
|
926
932
|
const open = await doFetch(`${api}/repos/${options.repo.slug}/pulls?state=open&head=${encodeURIComponent(`${options.repo.owner}:${options.head}`)}`, {
|
|
927
933
|
headers,
|
|
928
934
|
signal: AbortSignal.timeout(3e4)
|
|
929
935
|
});
|
|
930
936
|
const [found] = open.ok ? await open.json() : [];
|
|
931
|
-
if (found) return found
|
|
937
|
+
if (found) return answer(found, false);
|
|
932
938
|
}
|
|
933
939
|
throw new Failure("pull_request_failed", `GitHub didn't open a pull request for ${options.head}: HTTP ${made.status}.`, { hint: "The branch is pushed: open one by hand. A 403 or 404 usually means the token may not write pull requests on this repository." });
|
|
934
940
|
}
|
|
941
|
+
/**
|
|
942
|
+
* Comments on pull request `number`, from this machine: how a later round's description reaches a pull
|
|
943
|
+
* request whose body is never changed. False when GitHub didn't take it, for any reason: a comment is
|
|
944
|
+
* never worth failing a run that pushed.
|
|
945
|
+
*/
|
|
946
|
+
async function commentOnPullRequest(options) {
|
|
947
|
+
const doFetch = options.fetch ?? fetch;
|
|
948
|
+
const api = (options.api ?? "https://api.github.com").replace(/\/$/, "");
|
|
949
|
+
const headers = {
|
|
950
|
+
authorization: `Bearer ${options.token}`,
|
|
951
|
+
accept: "application/vnd.github+json",
|
|
952
|
+
"content-type": "application/json",
|
|
953
|
+
"user-agent": "muster",
|
|
954
|
+
"x-github-api-version": "2022-11-28"
|
|
955
|
+
};
|
|
956
|
+
return (await doFetch(`${api}/repos/${options.repo.slug}/issues/${options.number}/comments`, {
|
|
957
|
+
method: "POST",
|
|
958
|
+
headers,
|
|
959
|
+
body: JSON.stringify({ body: options.body }),
|
|
960
|
+
signal: AbortSignal.timeout(3e4)
|
|
961
|
+
}).catch(() => null))?.ok ?? false;
|
|
962
|
+
}
|
|
935
963
|
const COMMIT = /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/;
|
|
936
964
|
const BRANCH_NAME = /^(?!-)(?!HEAD$)(?!.*\.\.)[A-Za-z0-9._/-]{1,200}$/;
|
|
937
965
|
/**
|
|
@@ -973,6 +1001,79 @@ async function branchState(options) {
|
|
|
973
1001
|
head: head.object.sha
|
|
974
1002
|
};
|
|
975
1003
|
}
|
|
1004
|
+
/** The most pages of pull requests read for one branch. Past them the read fails rather than answer from part of them. */
|
|
1005
|
+
const PULL_PAGES_MAX = 5;
|
|
1006
|
+
/**
|
|
1007
|
+
* The pull requests opened from `head` on a GitHub repository, newest first, and the repository's default branch.
|
|
1008
|
+
* It reads and writes nothing else. With `token`, it reads with that; without, with a token it asks the GitHub
|
|
1009
|
+
* App in `env` (GITHUB_APP_ID, and GITHUB_APP_KEY_FILE or GITHUB_APP_PRIVATE_KEY) for, that may only read pull
|
|
1010
|
+
* requests on this one repository. `repo` is its HTTPS clone address, as a workflow's `workers.repo` gives it.
|
|
1011
|
+
*/
|
|
1012
|
+
async function pullRequests(options) {
|
|
1013
|
+
const doFetch = options.fetch ?? fetch;
|
|
1014
|
+
const api = (options.api ?? "https://api.github.com").replace(/\/$/, "");
|
|
1015
|
+
const repo = githubRepo(options.repo);
|
|
1016
|
+
if (!repo) throw new Failure("github_read_failed", `${options.repo} isn't a github.com repository's HTTPS address.`);
|
|
1017
|
+
if (!BRANCH_NAME.test(options.head)) throw new Failure("github_read_failed", `${options.head} isn't a branch name.`);
|
|
1018
|
+
let token = options.token;
|
|
1019
|
+
if (token === void 0) {
|
|
1020
|
+
const app = githubApp(options.env ?? process.env);
|
|
1021
|
+
if (!app) throw new Failure("github_app_missing", "Reading pull requests needs a GitHub App: GITHUB_APP_ID, and its private key.", { hint: "Set GITHUB_APP_ID and GITHUB_APP_KEY_FILE, as for --push." });
|
|
1022
|
+
token = (await installationToken(app, repo, {
|
|
1023
|
+
pull_requests: "read",
|
|
1024
|
+
metadata: "read"
|
|
1025
|
+
}, {
|
|
1026
|
+
api,
|
|
1027
|
+
fetch: doFetch
|
|
1028
|
+
})).token;
|
|
1029
|
+
}
|
|
1030
|
+
const headers = {
|
|
1031
|
+
authorization: `Bearer ${token}`,
|
|
1032
|
+
accept: "application/vnd.github+json",
|
|
1033
|
+
"user-agent": "muster",
|
|
1034
|
+
"x-github-api-version": "2022-11-28"
|
|
1035
|
+
};
|
|
1036
|
+
const failed = (what, status) => new Failure("github_read_failed", `Reading ${what} of ${repo.slug} on GitHub failed${status ? `: HTTP ${status}` : ""}.`, { hint: "The GitHub App needs Pull requests: read on the repository." });
|
|
1037
|
+
const about = await doFetch(`${api}/repos/${repo.slug}`, {
|
|
1038
|
+
headers,
|
|
1039
|
+
signal: AbortSignal.timeout(3e4)
|
|
1040
|
+
}).catch(() => null);
|
|
1041
|
+
if (!about?.ok) throw failed("the default branch", about?.status);
|
|
1042
|
+
const defaultBranch = (await about.json().catch(() => null))?.default_branch;
|
|
1043
|
+
if (typeof defaultBranch !== "string" || !BRANCH_NAME.test(defaultBranch)) throw failed("the default branch");
|
|
1044
|
+
const pulls = [];
|
|
1045
|
+
for (let page = 1;; page++) {
|
|
1046
|
+
if (page > PULL_PAGES_MAX) throw failed(`the pull requests from ${options.head}`);
|
|
1047
|
+
const query = `state=all&head=${encodeURIComponent(`${repo.owner}:${options.head}`)}&sort=created&direction=desc&per_page=100&page=${page}`;
|
|
1048
|
+
const listed = await doFetch(`${api}/repos/${repo.slug}/pulls?${query}`, {
|
|
1049
|
+
headers,
|
|
1050
|
+
signal: AbortSignal.timeout(3e4)
|
|
1051
|
+
}).catch(() => null);
|
|
1052
|
+
if (!listed?.ok) throw failed(`the pull requests from ${options.head}`, listed?.status);
|
|
1053
|
+
const body = await listed.json().catch(() => null);
|
|
1054
|
+
if (!Array.isArray(body)) throw failed(`the pull requests from ${options.head}`);
|
|
1055
|
+
for (const each of body) {
|
|
1056
|
+
if (each?.head?.ref !== options.head || each.head?.repo?.full_name !== repo.slug) continue;
|
|
1057
|
+
if (typeof each.number !== "number" || each.state !== "open" && each.state !== "closed" || typeof each.base?.ref !== "string" || typeof each.created_at !== "string") throw failed(`the pull requests from ${options.head}`);
|
|
1058
|
+
const mergedAt = typeof each.merged_at === "string" ? each.merged_at : null;
|
|
1059
|
+
pulls.push({
|
|
1060
|
+
number: each.number,
|
|
1061
|
+
state: each.state,
|
|
1062
|
+
merged: mergedAt !== null,
|
|
1063
|
+
mergedAt,
|
|
1064
|
+
base: each.base.ref,
|
|
1065
|
+
createdAt: each.created_at,
|
|
1066
|
+
url: String(each.html_url ?? "")
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
if (body.length < 100) break;
|
|
1070
|
+
}
|
|
1071
|
+
pulls.sort((a, b) => b.createdAt.localeCompare(a.createdAt) || b.number - a.number);
|
|
1072
|
+
return {
|
|
1073
|
+
defaultBranch,
|
|
1074
|
+
pulls
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
976
1077
|
/** The most a sandbox's changes may weigh, as a bundle. */
|
|
977
1078
|
const BUNDLE_MAX = 50 * 1024 * 1024;
|
|
978
1079
|
/**
|
|
@@ -1000,6 +1101,8 @@ const run = promisify(execFile);
|
|
|
1000
1101
|
* The push only moves the branch from where it was when the run started (`expect`, or no branch at all when
|
|
1001
1102
|
* that is null) to a commit that carries on from `base`: a branch someone moved in the meantime, or a change
|
|
1002
1103
|
* that doesn't build on where its checkout started, is refused (`push_conflict`) and nothing is overwritten.
|
|
1104
|
+
*
|
|
1105
|
+
* It answers with the commit pushed, and which of `paths` are files in it.
|
|
1003
1106
|
*/
|
|
1004
1107
|
/** How much of what git and the remote said about a push that failed is passed on: its last lines, up to this many characters. */
|
|
1005
1108
|
const PUSH_SAID_LINES = 12;
|
|
@@ -1038,7 +1141,35 @@ async function pushBundle(options) {
|
|
|
1038
1141
|
if (!await git("bundle", "verify", "-q", join(dir, "mu.bundle")).then(() => true, () => false)) throw notBuilt();
|
|
1039
1142
|
await git("fetch", "-q", "--end-of-options", join(dir, "mu.bundle"), "HEAD:refs/mu/head");
|
|
1040
1143
|
if (!await git("merge-base", "--is-ancestor", options.base, "refs/mu/head").then(() => true, () => false)) throw notBuilt();
|
|
1144
|
+
const head = (await git("rev-parse", "--verify", "refs/mu/head^{commit}")).stdout.trim();
|
|
1041
1145
|
await git("push", "-q", `--force-with-lease=refs/heads/${options.branch}:${options.expect ?? ""}`, "--end-of-options", remote, `refs/mu/head:refs/heads/${options.branch}`);
|
|
1146
|
+
const files = /* @__PURE__ */ new Set();
|
|
1147
|
+
if (options.paths?.length) {
|
|
1148
|
+
const listed = await run("git", [
|
|
1149
|
+
"-C",
|
|
1150
|
+
dir,
|
|
1151
|
+
"ls-tree",
|
|
1152
|
+
"-r",
|
|
1153
|
+
"-z",
|
|
1154
|
+
"--name-only",
|
|
1155
|
+
"refs/mu/head",
|
|
1156
|
+
"--",
|
|
1157
|
+
...options.paths
|
|
1158
|
+
], {
|
|
1159
|
+
env: {
|
|
1160
|
+
...env,
|
|
1161
|
+
GIT_LITERAL_PATHSPECS: "1"
|
|
1162
|
+
},
|
|
1163
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
1164
|
+
timeout: 12e4
|
|
1165
|
+
}).catch(() => null);
|
|
1166
|
+
const wanted = new Set(options.paths);
|
|
1167
|
+
for (const path of listed?.stdout.split("\0") ?? []) if (wanted.has(path)) files.add(path);
|
|
1168
|
+
}
|
|
1169
|
+
return {
|
|
1170
|
+
head,
|
|
1171
|
+
files
|
|
1172
|
+
};
|
|
1042
1173
|
} catch (error) {
|
|
1043
1174
|
if (error instanceof Failure) throw error;
|
|
1044
1175
|
const said$1 = String(error.stderr ?? error.message).replaceAll(options.token, "[REDACTED]").split("\n").map((line) => line.trim()).filter(Boolean).slice(-PUSH_SAID_LINES).join(" ").slice(0, PUSH_SAID_MAX);
|
|
@@ -2060,6 +2191,7 @@ function loadWorkflows(path = workflowsPath()) {
|
|
|
2060
2191
|
if (raw.labels !== void 0 && (!isObject(raw.labels) || !Object.values(raw.labels).every((label) => typeof label === "string"))) fail(`has a step "${key}" whose "labels" aren't k:v strings.`);
|
|
2061
2192
|
if (raw.push !== void 0 && typeof raw.push !== "boolean") fail(`has a step "${key}" whose "push" isn't true or false.`);
|
|
2062
2193
|
if (raw.title !== void 0 && (typeof raw.title !== "string" || !raw.title.trim() || raw.title.length > 200)) fail(`has a step "${key}" whose "title" isn't text of at most 200 characters.`);
|
|
2194
|
+
if (raw.refs !== void 0 && (typeof raw.refs !== "string" || !raw.refs.trim() || raw.refs.length > 200)) fail(`has a step "${key}" whose "refs" isn't text of at most 200 characters.`);
|
|
2063
2195
|
seen.add(key);
|
|
2064
2196
|
return {
|
|
2065
2197
|
key,
|
|
@@ -2068,7 +2200,8 @@ function loadWorkflows(path = workflowsPath()) {
|
|
|
2068
2200
|
...raw.for !== void 0 ? { for: raw.for } : {},
|
|
2069
2201
|
...raw.labels !== void 0 ? { labels: raw.labels } : {},
|
|
2070
2202
|
...raw.push !== void 0 ? { push: raw.push } : {},
|
|
2071
|
-
...raw.title !== void 0 ? { title: raw.title } : {}
|
|
2203
|
+
...raw.title !== void 0 ? { title: raw.title } : {},
|
|
2204
|
+
...raw.refs !== void 0 ? { refs: raw.refs } : {}
|
|
2072
2205
|
};
|
|
2073
2206
|
});
|
|
2074
2207
|
const refused = unreachableResult(steps);
|
|
@@ -2086,7 +2219,11 @@ function loadWorkflows(path = workflowsPath()) {
|
|
|
2086
2219
|
if (w.push !== void 0 && typeof w.push !== "boolean") fail("has a \"workers.push\" that isn't true or false.");
|
|
2087
2220
|
if ((w.push === true || steps.some((step) => step.push === true)) && !(cloud && typeof w.repo === "string" && githubRepo(w.repo))) fail("can only \"push\" with \"runner\": \"vercel\", \"cloudflare\" or \"e2b\" and a github.com https \"repo\".");
|
|
2088
2221
|
if (w.timeout !== void 0) checkDuration(w.timeout, "workers.timeout");
|
|
2222
|
+
if (w.template !== void 0 && (typeof w.template !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,127}$/.test(w.template))) fail("has a \"workers.template\" that isn't an E2B template name.");
|
|
2223
|
+
if (w.template !== void 0 && w.runner !== "e2b") fail("has a \"workers.template\", which is for \"e2b\" workers: no other runner makes a sandbox from a template you name.");
|
|
2224
|
+
if (w.model !== void 0 && (typeof w.model !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,127}$/.test(w.model))) fail("has a \"workers.model\" that isn't a model name.");
|
|
2089
2225
|
if (entryObject.timeout !== void 0) checkDuration(entryObject.timeout, "timeout");
|
|
2226
|
+
if (entryObject.mode !== void 0 && entryObject.mode !== "run" && entryObject.mode !== "suggest") fail("has a \"mode\" that isn't \"run\" or \"suggest\".");
|
|
2090
2227
|
const workers = {
|
|
2091
2228
|
count: w.count,
|
|
2092
2229
|
agent: w.agent,
|
|
@@ -2095,7 +2232,9 @@ function loadWorkflows(path = workflowsPath()) {
|
|
|
2095
2232
|
...w.repo !== void 0 ? { repo: w.repo } : {},
|
|
2096
2233
|
...w.push !== void 0 ? { push: w.push } : {},
|
|
2097
2234
|
...w.cwd !== void 0 ? { cwd: w.cwd } : {},
|
|
2098
|
-
...w.timeout !== void 0 ? { timeout: w.timeout } : {}
|
|
2235
|
+
...w.timeout !== void 0 ? { timeout: w.timeout } : {},
|
|
2236
|
+
...w.template !== void 0 ? { template: w.template } : {},
|
|
2237
|
+
...w.model !== void 0 ? { model: w.model } : {}
|
|
2099
2238
|
};
|
|
2100
2239
|
return {
|
|
2101
2240
|
name,
|
|
@@ -2104,7 +2243,8 @@ function loadWorkflows(path = workflowsPath()) {
|
|
|
2104
2243
|
channels: entryObject.channels,
|
|
2105
2244
|
steps,
|
|
2106
2245
|
workers,
|
|
2107
|
-
...entryObject.timeout !== void 0 ? { timeout: entryObject.timeout } : {}
|
|
2246
|
+
...entryObject.timeout !== void 0 ? { timeout: entryObject.timeout } : {},
|
|
2247
|
+
...entryObject.mode !== void 0 ? { mode: entryObject.mode } : {}
|
|
2108
2248
|
};
|
|
2109
2249
|
});
|
|
2110
2250
|
}
|
|
@@ -2137,7 +2277,7 @@ function missingSettings(workers, env) {
|
|
|
2137
2277
|
for (const name of ["MUSTER_CF_WORKER", "MUSTER_CF_SECRET"]) if (!env[name]) missing.push(name);
|
|
2138
2278
|
}
|
|
2139
2279
|
if (workers.runner === "e2b") {
|
|
2140
|
-
for (const name of ["E2B_API_KEY", "MUSTER_E2B_TEMPLATE"]) if (!env[name]) missing.push(name);
|
|
2280
|
+
for (const name of ["E2B_API_KEY", ...workers.template ? [] : ["MUSTER_E2B_TEMPLATE"]]) if (!env[name]) missing.push(name);
|
|
2141
2281
|
}
|
|
2142
2282
|
if (workers.runner === "vercel") {
|
|
2143
2283
|
const set = [
|
|
@@ -2178,6 +2318,38 @@ const PUSH_LABEL = "workflow.push";
|
|
|
2178
2318
|
const TITLE_LABEL = "workflow.title";
|
|
2179
2319
|
/** The name a run's workers act under (`workers.as`), as the daemon labelled each task when it made it. */
|
|
2180
2320
|
const WORKERS_LABEL = "workflow.workers";
|
|
2321
|
+
/** A step's `refs`, filled and checked as the daemon made its task: the issues its pull request refers to. */
|
|
2322
|
+
const REFS_LABEL = "workflow.refs";
|
|
2323
|
+
/** How many issues one pull request may refer to. */
|
|
2324
|
+
const REFS_MAX = 5;
|
|
2325
|
+
/**
|
|
2326
|
+
* The issue keys a step's filled `refs` names, comma- or space-separated: each `ENG-123`, an upper case letter,
|
|
2327
|
+
* up to nine more letters or digits, a hyphen and up to seven digits, and at most REFS_MAX of them. Anything
|
|
2328
|
+
* else in it, or none, and it names none at all: a key that isn't one is never half taken.
|
|
2329
|
+
*/
|
|
2330
|
+
function issueRefs(value) {
|
|
2331
|
+
const keys = value.split(/[\s,]+/).filter(Boolean);
|
|
2332
|
+
if (keys.length === 0 || keys.length > REFS_MAX || !keys.every((key) => /^[A-Z][A-Z0-9]{0,9}-\d{1,7}$/.test(key))) return null;
|
|
2333
|
+
return [...new Set(keys)];
|
|
2334
|
+
}
|
|
2335
|
+
/**
|
|
2336
|
+
* `{thread.ref}`: the asking thread's `ref` label as sync made the thread, the issue's key for a Linear issue
|
|
2337
|
+
* (`ENG-123`). Read from the board's record of the thread's first message, and only when sync wrote it: a
|
|
2338
|
+
* message posted on the board can't carry where it came from, so a `ref` someone filed by hand, or set since,
|
|
2339
|
+
* counts for nothing. Empty for any other thread.
|
|
2340
|
+
*/
|
|
2341
|
+
async function syncedRef(team, thread) {
|
|
2342
|
+
const made = (await team.events({
|
|
2343
|
+
after: thread - 1,
|
|
2344
|
+
filter: { types: ["message.posted"] },
|
|
2345
|
+
limit: 1
|
|
2346
|
+
})).events[0];
|
|
2347
|
+
if (made === void 0 || made.seq !== thread) return "";
|
|
2348
|
+
const data = made.data;
|
|
2349
|
+
const key = data.origin?.key;
|
|
2350
|
+
if (typeof key !== "string" || made.by.profile !== null || made.by.principal !== key && !made.by.principal.startsWith(`${key}:user:`)) return "";
|
|
2351
|
+
return typeof data.labels?.ref === "string" ? data.labels.ref : "";
|
|
2352
|
+
}
|
|
2181
2353
|
/** Where the daemon keeps its place among the board's workflow requests. */
|
|
2182
2354
|
const REQUESTS_CURSOR = "workflow:requests";
|
|
2183
2355
|
/** Requests one tick handles, so a burst of them never holds up schedules and watchers. */
|
|
@@ -2229,6 +2401,8 @@ function workerArgv(workflow, run$1, seq, i, owner) {
|
|
|
2229
2401
|
...workers.repo ? ["--repo", workers.repo] : [],
|
|
2230
2402
|
...pushes(workflow) ? ["--push"] : [],
|
|
2231
2403
|
...workers.timeout ? ["--timeout", workers.timeout] : [],
|
|
2404
|
+
...workers.template ? ["--template", workers.template] : [],
|
|
2405
|
+
...workers.model ? ["--model", workers.model] : [],
|
|
2232
2406
|
"--by",
|
|
2233
2407
|
`${owner}+${WORKFLOWS_PROFILE}`,
|
|
2234
2408
|
"--label",
|
|
@@ -2336,6 +2510,9 @@ async function runWorkflows(team, workflows, deps) {
|
|
|
2336
2510
|
if (refusal !== null || !workflow) {
|
|
2337
2511
|
await say(event.seq, thread, refusal);
|
|
2338
2512
|
out.refused.push(event.seq);
|
|
2513
|
+
} else if (workflow.mode === "suggest") {
|
|
2514
|
+
await say(event.seq, thread, `would start ${name}: ${workflow.steps.length} ${workflow.steps.length === 1 ? "task" : "tasks"}, ${workflow.workers.count} ${workflow.workers.count === 1 ? "worker" : "workers"}; suggest only, nothing started`);
|
|
2515
|
+
(out.suggested ??= []).push(event.seq);
|
|
2339
2516
|
} else {
|
|
2340
2517
|
const result = await start(team, writer, workflow, {
|
|
2341
2518
|
seq: event.seq,
|
|
@@ -2894,6 +3071,8 @@ async function start(team, writer, workflow, on, owner, deps) {
|
|
|
2894
3071
|
const asked = workflow.steps.some((step) => step.text.includes("{on.text}") || step.title?.includes("{on.title}")) ? await askedMessage(team, on) : void 0;
|
|
2895
3072
|
const onText = asked && workflow.steps.some((step) => step.text.includes("{on.text}")) ? askedQuote(asked) : void 0;
|
|
2896
3073
|
const titleOf = (title) => titleLine(title.replaceAll("{on.title}", asked ? asked.text.split("\n").map((each) => each.trim()).find(Boolean) ?? "" : "").replaceAll("{thread}", String(on.thread)).replaceAll("{channel}", on.channel));
|
|
3074
|
+
const ref = workflow.steps.some((step) => step.refs?.includes("{thread.ref}")) ? await syncedRef(team, on.thread) : "";
|
|
3075
|
+
const refsOf = (refs) => issueRefs(refs.replaceAll("{thread.ref}", ref))?.join(", ");
|
|
2897
3076
|
const perStep = workflow.steps.some((step) => step.push !== void 0);
|
|
2898
3077
|
const tasks = workflow.steps.map((step) => ({
|
|
2899
3078
|
key: step.key,
|
|
@@ -2911,7 +3090,8 @@ async function start(team, writer, workflow, on, owner, deps) {
|
|
|
2911
3090
|
[STEP_LABEL]: step.key,
|
|
2912
3091
|
[WORKERS_LABEL]: workflow.workers.as,
|
|
2913
3092
|
...perStep ? { [PUSH_LABEL]: String(step.push ?? workflow.workers.push === true) } : {},
|
|
2914
|
-
...step.title !== void 0 && titleOf(step.title) ? { [TITLE_LABEL]: titleOf(step.title) } : {}
|
|
3093
|
+
...step.title !== void 0 && titleOf(step.title) ? { [TITLE_LABEL]: titleOf(step.title) } : {},
|
|
3094
|
+
...step.refs !== void 0 && refsOf(step.refs) ? { [REFS_LABEL]: refsOf(step.refs) } : {}
|
|
2915
3095
|
},
|
|
2916
3096
|
...step.needs ? { needs: step.needs } : {},
|
|
2917
3097
|
...step.for !== void 0 ? { for: step.for } : {}
|
|
@@ -3016,8 +3196,115 @@ async function madeLabels(team, id, owner) {
|
|
|
3016
3196
|
*/
|
|
3017
3197
|
async function pullTitle(team, id, owner) {
|
|
3018
3198
|
const made = (await madeLabels(team, id, owner))?.[TITLE_LABEL];
|
|
3019
|
-
if (typeof made === "string" && made.trim()) return made.trim().slice(0, 72);
|
|
3020
|
-
return ((await team.readThread({ id }).catch(() => null))?.message.text.split("\n")[0] ?? "").trim().slice(0, 72) || `Task #${id}`;
|
|
3199
|
+
if (typeof made === "string" && made.trim()) return unkeyed(made.trim().slice(0, 72));
|
|
3200
|
+
return unkeyed(((await team.readThread({ id }).catch(() => null))?.message.text.split("\n")[0] ?? "").trim().slice(0, 72)) || `Task #${id}`;
|
|
3201
|
+
}
|
|
3202
|
+
/**
|
|
3203
|
+
* The issues a worker's pull request for a task refers to: the step's `refs` as the daemon recorded it when it
|
|
3204
|
+
* made the task, checked again, never a label as it is now. None for a task the daemon didn't make.
|
|
3205
|
+
*/
|
|
3206
|
+
async function pullRefs(team, id, owner) {
|
|
3207
|
+
const made = (await madeLabels(team, id, owner))?.[REFS_LABEL];
|
|
3208
|
+
return (typeof made === "string" ? issueRefs(made) : null) ?? [];
|
|
3209
|
+
}
|
|
3210
|
+
/**
|
|
3211
|
+
* An issue key in the shape Linear, Jira and GitHub's `GH-` read (`ENG-123`), up to its hyphen: in any case,
|
|
3212
|
+
* of any length, after anything but a letter or digit (`_ENG-1` too). Text such as `node-22` matches as
|
|
3213
|
+
* well, and gets the lookalike hyphen: a description is read, not copied as code.
|
|
3214
|
+
*/
|
|
3215
|
+
const ISSUE_KEY = /(?<![A-Za-z0-9])([A-Za-z][A-Za-z0-9]*)-(?=\d)/g;
|
|
3216
|
+
/**
|
|
3217
|
+
* Text that names no issue by its key: the hyphen of `ENG-123`, `eng-123` or `GH-123` made a non-breaking
|
|
3218
|
+
* one (U+2011), which looks the same. Linear's GitHub integration would otherwise link the
|
|
3219
|
+
* issue, and close it on merge after a closing word ("Fixes ENG-123"). Only muster names an issue: a
|
|
3220
|
+
* workflow step's `refs` (`pullRefs`).
|
|
3221
|
+
*/
|
|
3222
|
+
const unkeyed = (text) => text.replace(ISSUE_KEY, "$1‑");
|
|
3223
|
+
/**
|
|
3224
|
+
* Where the agent may write task `task`'s pull request description, in its sandbox: outside the checkout, so
|
|
3225
|
+
* it is never committed, and named for the task, so a sandbox that works several never posts one task's on
|
|
3226
|
+
* another's pull request. The run removes it once read, so a later round of the same task starts with none.
|
|
3227
|
+
*/
|
|
3228
|
+
const descriptionFile = (task) => `/tmp/mu-pull-request-${task}.md`;
|
|
3229
|
+
/** How much of that file is read: a bigger one isn't read at all, and the pull request gets muster's line alone. */
|
|
3230
|
+
const DESCRIPTION_READ_MAX = 256 * 1024;
|
|
3231
|
+
/** How long a description may be once made inert, in characters: well under GitHub's 65,536 for a body. */
|
|
3232
|
+
const DESCRIPTION_MAX = 2e4;
|
|
3233
|
+
/** A markdown image written inline, ``: its alt text and its address. */
|
|
3234
|
+
const IMAGE = /!\[([^\]\n]*)\]\(\s*<?([^\s)>]*)>?(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?\s*\)/g;
|
|
3235
|
+
/** An issue, pull request or discussion on GitHub by its address, up to the slash before its number. */
|
|
3236
|
+
const ISSUE_URL = /(github\.com\/[^\s/]+\/[^\s/]+\/(?:issues|pulls?|discussions))\/(?=\d)/gi;
|
|
3237
|
+
/** Whether an image's address is a path, read against the repository: no scheme, no host, not from its root. */
|
|
3238
|
+
const relative = (url) => url !== "" && !/^[a-z][a-z0-9+.-]*:/i.test(url) && !url.startsWith("/") && !url.startsWith("\\");
|
|
3239
|
+
/** How many images one description may show from the pushed commit: each is a longer address than it was written as. */
|
|
3240
|
+
const IMAGES_MAX = 20;
|
|
3241
|
+
/** How long a shown image's alt text, and its path, may be, in characters: twenty of them stay far under GitHub's limit. */
|
|
3242
|
+
const ALT_MAX = 100;
|
|
3243
|
+
const PATH_MAX = 200;
|
|
3244
|
+
/**
|
|
3245
|
+
* An image's relative address as a path in the repository: `./` and `.` segments dropped, percent-escapes read.
|
|
3246
|
+
* Only letters, digits, spaces and `. - _` in each segment, so its address, escaped, holds nothing markdown
|
|
3247
|
+
* reads (no `)`, `'`, `*`). Null for any other, one that climbs out with `..`, or one over PATH_MAX.
|
|
3248
|
+
*/
|
|
3249
|
+
function repoPath(url) {
|
|
3250
|
+
if (!relative(url)) return null;
|
|
3251
|
+
let path;
|
|
3252
|
+
try {
|
|
3253
|
+
path = decodeURIComponent(url.split(/[?#]/)[0]);
|
|
3254
|
+
} catch {
|
|
3255
|
+
return null;
|
|
3256
|
+
}
|
|
3257
|
+
const parts = path.split("/").filter((part) => part !== "" && part !== ".");
|
|
3258
|
+
if (parts.length === 0 || parts.includes("..") || !parts.every((part) => /^[\p{L}\p{N} ._-]+$/u.test(part))) return null;
|
|
3259
|
+
const joined = parts.join("/");
|
|
3260
|
+
return joined.length <= PATH_MAX ? joined : null;
|
|
3261
|
+
}
|
|
3262
|
+
/** The repository paths a description's relative images name, to look up in the pushed commit. */
|
|
3263
|
+
function imagePaths(text) {
|
|
3264
|
+
const paths = /* @__PURE__ */ new Set();
|
|
3265
|
+
for (const match of text.matchAll(IMAGE)) {
|
|
3266
|
+
const path = repoPath(match[2]);
|
|
3267
|
+
if (path) paths.add(path);
|
|
3268
|
+
}
|
|
3269
|
+
return [...paths].slice(0, 1e3);
|
|
3270
|
+
}
|
|
3271
|
+
/**
|
|
3272
|
+
* Text made inert for GitHub's markdown. Rather than find each way markdown links, it takes away what every
|
|
3273
|
+
* one is made of. `&` goes first, so no character reference (`@`) is read back into what follows. `defuse`
|
|
3274
|
+
* takes `@` (mentions) and `<` `>` (HTML, autolinks). Every `[` and `]` is made fullwidth, so no link, image,
|
|
3275
|
+
* reference, definition or footnote forms, wherever it sits. `://`, `www.`, `mailto:` and `xmpp:` lose
|
|
3276
|
+
* the character GitHub's autolinks need. `#<n>`, an issue key (`GH-<n>`, `ENG-<n>`: `unkeyed`) and an
|
|
3277
|
+
* issue's address refer to nothing, so no closing keyword has an issue to close.
|
|
3278
|
+
*/
|
|
3279
|
+
function inert(text) {
|
|
3280
|
+
return unkeyed(defuse(text.replaceAll("&", "&"))).replaceAll("[", "[").replaceAll("]", "]").replaceAll("://", "://").replace(/(www)\./gi, "$1.").replace(/(mailto|xmpp):/gi, "$1:").replace(/#(?=\d)/g, "#").replace(ISSUE_URL, "$1∕");
|
|
3281
|
+
}
|
|
3282
|
+
/**
|
|
3283
|
+
* The description an agent wrote for its pull request, made inert before muster posts it under the App's
|
|
3284
|
+
* name. It lets known good markdown through rather than block known bad: everything is made `inert`, and the
|
|
3285
|
+
* only markup that renders is what muster itself puts back afterwards. At most DESCRIPTION_MAX characters.
|
|
3286
|
+
* Null when nothing is left.
|
|
3287
|
+
*
|
|
3288
|
+
* What it puts back: an image whose relative path is a file in `pushed`, the commit pushed for this run,
|
|
3289
|
+
* as that file's address pinned to the commit (`github.com/<repo>/blob/<sha>/<path>?raw=true`), which
|
|
3290
|
+
* GitHub shows to whoever may read the repository. Any other relative image stays as text; an image at
|
|
3291
|
+
* any other address is replaced by its alt text, so its address isn't in the text at all.
|
|
3292
|
+
*/
|
|
3293
|
+
function pullDescription(text, repo, pushed) {
|
|
3294
|
+
const plain = text.replace(/\r\n?/g, "\n").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, "").trim();
|
|
3295
|
+
if (!plain) return null;
|
|
3296
|
+
const shown = [];
|
|
3297
|
+
const sha = pushed && /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/.test(pushed.sha) ? pushed.sha : null;
|
|
3298
|
+
const safe = inert(plain.replace(IMAGE, (whole, alt, url) => {
|
|
3299
|
+
const path = repoPath(url);
|
|
3300
|
+
if (path && sha && pushed.files.has(path) && shown.length < IMAGES_MAX) {
|
|
3301
|
+
shown.push(`![${unkeyed(Array.from(alt.replace(/[^\p{L}\p{N} ._-]/gu, "")).slice(0, ALT_MAX).join(""))}](https://github.com/${repo.slug}/blob/${sha}/${path.split("/").map((part) => encodeURIComponent(part).replace(ISSUE_KEY, "$1%2D")).join("/")}?raw=true)`);
|
|
3302
|
+
return `\u0000${shown.length - 1}\u0000`;
|
|
3303
|
+
}
|
|
3304
|
+
return relative(url) ? whole : alt;
|
|
3305
|
+
})).trim();
|
|
3306
|
+
if (!safe) return null;
|
|
3307
|
+
return cut(safe, DESCRIPTION_MAX).replace(/\u0000(\d+)\u0000/g, (_, at) => shown[Number(at)]).replace(/\u0000\d*/g, "");
|
|
3021
3308
|
}
|
|
3022
3309
|
/**
|
|
3023
3310
|
* Whether a worker pushes the task it took: never when it wasn't started with `--push`, and otherwise
|
|
@@ -3172,4 +3459,4 @@ function resultQuote(key, step) {
|
|
|
3172
3459
|
}
|
|
3173
3460
|
|
|
3174
3461
|
//#endregion
|
|
3175
|
-
export {
|
|
3462
|
+
export { boardPolicy as A, isSessionId as B, branchState as C, pullRequests as D, openPullRequest as E, runLocal as F, conformance as H, AGENTS as I, claude as L, installationToken as M, KEEP_LOGS_MS as N, pushBundle as O, agentEnv as P, codex as R, BUNDLE_MAX as S, githubRepo as T, http as V, e2b as _, imagePaths as a, vercel as b, pullTitle as c, fenced as d, openRuns as f, workflowsPath as g, loadWorkflows as h, fillResults as i, githubApp as j, applyPolicy as k, pushesTask as l, spawnWorker as m, FillRefused as n, pullDescription as o, runWorkflows as p, descriptionFile as r, pullRefs as s, DESCRIPTION_READ_MAX as t, workflowResult as u, SANDBOX_ENV as v, commentOnPullRequest as w, BUNDLE as x, cloudflare as y, generic as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Watchers and the daemon
|
|
3
|
-
description: A watcher runs your command when a matching event lands on the board, such as a blocked task or a mention. How the daemon hosts watchers, what the command receives, retries
|
|
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 and gates.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## The daemon
|
|
@@ -95,7 +95,9 @@ export default board({
|
|
|
95
95
|
A reminder the profile scheduled for itself wakes it too.
|
|
96
96
|
|
|
97
97
|
Try the filter by hand first: `mu tail work/ --type task.completed --json`.
|
|
98
|
-
The event a watcher gets is what that prints, one at a time.
|
|
98
|
+
The event a watcher gets is what that prints, one at a time. To check the
|
|
99
|
+
whole path, from the filter to an answer, see
|
|
100
|
+
[Check that a watcher wakes something](../03-guides/09-daemon.md#check-that-a-watcher-wakes-something).
|
|
99
101
|
|
|
100
102
|
## What a wake carries
|
|
101
103
|
|
|
@@ -113,36 +115,6 @@ The event a watcher gets is what that prints, one at a time.
|
|
|
113
115
|
agent through `command()`, not through a function that pastes it into a
|
|
114
116
|
prompt.
|
|
115
117
|
|
|
116
|
-
## Check that it wakes something
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
mu daemon check lead
|
|
120
|
-
mu daemon check triage --in work/checks --timeout 10m
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
`check` writes a message the watcher's filter matches, then waits for a reply
|
|
124
|
-
in its thread. A reply proves the whole path: a host runs the watcher, the
|
|
125
|
-
filter matches, the gate lets it through, and the command wakes something
|
|
126
|
-
that answers. It prints who answered and how long it took.
|
|
127
|
-
|
|
128
|
-
- **Its message is built from the filter:** the watcher's channel, its labels,
|
|
129
|
-
a mention or words it asks for. A watcher on a subtree needs `--in` to say
|
|
130
|
-
which channel under it. It stays on the board, never synced.
|
|
131
|
-
- **It fails fast when nothing runs the watcher** (`watcher_not_running`),
|
|
132
|
-
before writing anything: no host holds its lease. If the daemon stopped
|
|
133
|
-
restarting, it says that instead (`daemon_stopped`).
|
|
134
|
-
- **A run that keeps failing is `wake_failed`,** after the five tries an
|
|
135
|
-
event gets, which take a few minutes. A command that runs but wakes nothing
|
|
136
|
-
that replies is `timeout`, with the thread to read.
|
|
137
|
-
- **Some watchers can't be checked with a message:** one that listens only
|
|
138
|
-
for task events, or only to a platform's users. Write what it listens for
|
|
139
|
-
by hand instead.
|
|
140
|
-
|
|
141
|
-
Whatever the command wakes has to reply. The agents in
|
|
142
|
-
[A software factory](../03-guides/03-factory.md) and
|
|
143
|
-
[With your terminal](../03-guides/13-terminals.md) read the thread and answer
|
|
144
|
-
it like any other.
|
|
145
|
-
|
|
146
118
|
## What it promises
|
|
147
119
|
|
|
148
120
|
- **It starts from now.** What was on the board before a watcher first ran
|
|
@@ -3,7 +3,7 @@ title: Schedules
|
|
|
3
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
|
+
## A message for later
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
9
|
mu schedule 12 "is the PR still open?" --in 2h
|
|
@@ -92,9 +92,25 @@ record of is refused, so restoring a board from an old backup stops the
|
|
|
92
92
|
tokens made since.
|
|
93
93
|
|
|
94
94
|
A token made before 0.2.0 may have no ID. Such a token can't be revoked and
|
|
95
|
-
stops when it runs out. To stop one sooner,
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
stops when it runs out. To stop one sooner, rotate the key and drop the old
|
|
96
|
+
one, as below.
|
|
97
|
+
|
|
98
|
+
## Rotate the signing key
|
|
99
|
+
|
|
100
|
+
Rotate the key when you think it was copied: anyone with it can make tokens
|
|
101
|
+
the board accepts. Rotate in three steps, so tokens you still want keep
|
|
102
|
+
working until you replace them:
|
|
103
|
+
|
|
104
|
+
1. `mu token rotate-key` puts a new key in place. Tokens made from now on are
|
|
105
|
+
signed with it. The old key is kept as retired, and tokens it signed still
|
|
106
|
+
work. Restart `mu serve` to use the new key.
|
|
107
|
+
2. Make new tokens for the agents and machines you still trust, with
|
|
108
|
+
`mu token create`.
|
|
109
|
+
3. `mu token drop-old-keys` deletes every retired key, which stops every token
|
|
110
|
+
they signed once `mu serve` restarts.
|
|
111
|
+
|
|
112
|
+
If the key was copied, run both commands at once and make new tokens after:
|
|
113
|
+
waiting leaves whoever has the old key able to make tokens.
|
|
98
114
|
|
|
99
115
|
The signing key is made once and kept in `~/.config/muster/keys/`, so tokens
|
|
100
116
|
survive a restart of `mu serve`.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Budgets
|
|
3
|
-
description: A budget caps what the tasks under a channel may cost in dollars. Once it is spent, the board refuses new claims there with over_budget. Agents that report no cost, such as Codex, need a time limit instead.
|
|
3
|
+
description: A budget caps what the tasks under a channel may cost in dollars. Once it is spent, the board refuses new claims there with over_budget. Agents that report no cost, such as Codex, need a time limit instead. mu report shows how work went and what it cost, by agent and workflow.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## A budget is on a channel
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
9
|
mu budget work 25
|
|
@@ -12,7 +12,9 @@ mu budget work --none
|
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
A budget is on a channel and covers every task under it. `mu budget` with no
|
|
15
|
-
argument lists them with what each has spent.
|
|
15
|
+
argument lists them with what each has spent, and `--none` lifts one. To
|
|
16
|
+
set one before agents work through a queue overnight, see
|
|
17
|
+
[Running unattended](../03-guides/12-unattended.md#set-a-limit-before-you-leave).
|
|
16
18
|
|
|
17
19
|
## What it counts, and what it stops
|
|
18
20
|
|
|
@@ -29,6 +31,67 @@ A looping worker (`mu run --ready work/ --loop`) stops when the board says the
|
|
|
29
31
|
money is spent. `--budget <usd>` on the worker is a limit of its own, on what
|
|
30
32
|
that one worker has spent.
|
|
31
33
|
|
|
34
|
+
## Know the cost before a worker starts
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
mu run --ready work --estimate --agent claude
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
A looping worker (`mu run --ready work --loop`) prints one line before it
|
|
41
|
+
takes its first task, and `--estimate` prints only that line and starts
|
|
42
|
+
nothing:
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
3 ready, about $0.90 at $0.30 a task
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The count is the ready tasks this worker may take, read as `--ready` reads
|
|
49
|
+
the channel (`work` is that channel, `work/` every channel under it): its
|
|
50
|
+
owners, `--from`, `--by`, `--label`, and tasks assigned to it or to nobody.
|
|
51
|
+
The price is what a task in that channel or under it cost that agent on
|
|
52
|
+
average over the last 30 days, from the `cost` labels below. With no cost
|
|
53
|
+
on record, as for Codex, it says `no cost history` and gives no figure.
|
|
54
|
+
An estimate changes nothing about a budget: the board still refuses claims
|
|
55
|
+
once the money is spent.
|
|
56
|
+
|
|
57
|
+
## See how work went
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
mu report work
|
|
61
|
+
mu report --since 7d --json
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`mu report` reads the tasks under a channel (every channel when you name
|
|
65
|
+
none) that changed in the last 30 days, or in `--since`. It groups them by
|
|
66
|
+
the `agent` label `mu run` writes, and again by the `workflow` label a
|
|
67
|
+
[workflow](./16-workflows.md)'s tasks have. It changes nothing.
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
since 2026-10-29 in #work
|
|
71
|
+
agent tasks 1st round rounds failed failing input cost per task
|
|
72
|
+
claude 2 1 50% 1.00 0 0 1 $0.60 $0.30
|
|
73
|
+
codex 1 0 0% 1.00 1 0 0 - -
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
| Column | Meaning |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| `tasks` | Tasks in the group |
|
|
79
|
+
| `1st round` | Completed and never sent back with `tasks reopen --round`, and their share |
|
|
80
|
+
| `rounds` | Rounds on average: 1, and 1 more for each `--round` |
|
|
81
|
+
| `failed` | Tasks in the state `failed` now |
|
|
82
|
+
| `failing` | Tasks the board held as `failing` at least once |
|
|
83
|
+
| `input` | Times a task was held with kind `needs_input` |
|
|
84
|
+
| `cost`, `per task` | The sum of `cost` labels, and that sum over the tasks that have one |
|
|
85
|
+
|
|
86
|
+
What it can't say:
|
|
87
|
+
|
|
88
|
+
- **No model.** `mu run` records the agent, not the model it ran, so the
|
|
89
|
+
report has no model column.
|
|
90
|
+
- **The last run's cost.** Each run of a task writes its `cost` label
|
|
91
|
+
again, so a task sent back shows what its latest round cost.
|
|
92
|
+
- **No agent, no row of its own.** `mu run` writes `agent` only when it
|
|
93
|
+
read a session from the agent. Tasks without it are `(none)`.
|
|
94
|
+
|
|
32
95
|
## What it can't count
|
|
33
96
|
|
|
34
97
|
An agent that reports no cost, as Codex does, adds nothing to the sum. Hold
|