toolroll 0.9.108 → 0.9.110
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/CHANGELOG.md +69 -0
- package/dist/advanced-view.js +0 -1
- package/dist/agent-detect.js +244 -0
- package/dist/agent-fence.js +47 -5
- package/dist/agent-state.js +5 -2
- package/dist/agentconfig.js +2 -2
- package/dist/approval-summary.js +344 -0
- package/dist/assignment-ui.js +5 -5
- package/dist/assignment.js +5 -2
- package/dist/attest.js +2 -2
- package/dist/browser/terminal.js +1 -1
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +37 -34
- package/dist/browser-crew.js +4 -4
- package/dist/browser-workspace.js +4 -11
- package/dist/builder.js +45 -3
- package/dist/chat-actions.js +24 -17
- package/dist/chat-controls.js +6 -5
- package/dist/chat-core.js +3 -1
- package/dist/chat-decide.js +102 -47
- package/dist/chat-delivery-state.js +2 -0
- package/dist/chat-delivery.js +3 -2
- package/dist/chat-live.js +2 -1
- package/dist/chat-quiet.js +3 -3
- package/dist/chat-task-actions.js +6 -0
- package/dist/chat-voice.js +2 -2
- package/dist/check-report.js +1 -1
- package/dist/cli-help.js +12 -13
- package/dist/cli.js +6 -3
- package/dist/console-chrome.js +10 -3
- package/dist/console-instance.js +10 -1
- package/dist/contracts/console-api.js +14 -8
- package/dist/contracts/engine-api.js +271 -0
- package/dist/contracts/handoff.js +4 -0
- package/dist/coordinator.js +2 -2
- package/dist/decision.js +17 -0
- package/dist/demo-chat.js +1 -1
- package/dist/demo.js +6 -0
- package/dist/design/kit.js +4 -3
- package/dist/discord-api.js +4 -3
- package/dist/discord-chat.js +3 -1
- package/dist/dispatch.js +3 -8
- package/dist/easy-start-args.js +7 -3
- package/dist/easy-start.js +25 -0
- package/dist/egress.js +72 -10
- package/dist/engine-handoff.js +34 -0
- package/dist/engine-reads.js +261 -0
- package/dist/eval-world.js +3 -2
- package/dist/evidence.js +2 -0
- package/dist/fast-start.js +55 -14
- package/dist/fast-terms.js +2 -2
- package/dist/first-run.js +10 -2
- package/dist/flexible-agents.js +234 -0
- package/dist/flexible-answers-schema.js +61 -0
- package/dist/flexible-answers.js +889 -0
- package/dist/flexible-available.js +1 -0
- package/dist/flexible-custody.js +494 -0
- package/dist/flexible-import.js +782 -0
- package/dist/flexible-launch-schema.js +72 -0
- package/dist/flexible-launch.js +331 -0
- package/dist/flexible-launcher.js +88 -0
- package/dist/flexible-levels.js +34 -0
- package/dist/flexible-merge-guard.js +47 -0
- package/dist/flexible-refs.js +47 -0
- package/dist/flexible-relay-cancel.js +19 -0
- package/dist/flexible-relay-schema.js +55 -0
- package/dist/flexible-relay-upstreams.js +36 -0
- package/dist/flexible-relay.js +1032 -0
- package/dist/flexible-schema.js +32 -0
- package/dist/flexible-session.js +732 -0
- package/dist/flexible-ship-schema.js +81 -0
- package/dist/flexible-ship.js +694 -0
- package/dist/flexible-start.js +80 -0
- package/dist/flexible-thread-schema.js +30 -0
- package/dist/flexible-thread.js +676 -0
- package/dist/flexible-turns-schema.js +69 -0
- package/dist/flexible-turns.js +490 -0
- package/dist/flexible-ui.js +44 -0
- package/dist/flexible.js +368 -0
- package/dist/flow-actions.js +6 -4
- package/dist/flow-steps.js +1 -1
- package/dist/flows-cli.js +2 -1
- package/dist/git-views.js +44 -41
- package/dist/guides.js +11 -10
- package/dist/install-mode.js +225 -0
- package/dist/keymap.js +1 -1
- package/dist/lead-context.js +1 -1
- package/dist/lead-doors.js +7 -1
- package/dist/limits-ui.js +8 -1
- package/dist/live-bus.js +70 -13
- package/dist/live-reply.js +6 -0
- package/dist/live-terminal.js +425 -29
- package/dist/local-owner.js +6 -0
- package/dist/model-choices.js +12 -6
- package/dist/needs-you.js +3 -3
- package/dist/nightly-github.js +2 -2
- package/dist/notification-delivery.js +11 -0
- package/dist/operate.js +185 -33
- package/dist/outbound-privacy.js +204 -0
- package/dist/passwordless.js +2 -1
- package/dist/project-delete-ui.js +2 -1
- package/dist/project-delete.js +15 -0
- package/dist/provider-auth.js +1 -1
- package/dist/provider-connection.js +5 -3
- package/dist/publish.js +5 -0
- package/dist/pull-request-flow.js +26 -7
- package/dist/push.js +5 -1
- package/dist/release-card.js +11 -3
- package/dist/release.js +11 -1
- package/dist/result-actions.js +3 -0
- package/dist/result-evidence-readers.js +8 -2
- package/dist/result-review.js +20 -9
- package/dist/route-store.js +2 -2
- package/dist/sandbox-launch.js +32 -8
- package/dist/sandbox-runtime.js +16 -7
- package/dist/sandbox-tools.js +176 -0
- package/dist/scope.js +12 -36
- package/dist/scout-net.js +7 -2
- package/dist/serve.js +90 -40
- package/dist/server/chat.js +9 -9
- package/dist/server/chrome.js +19 -17
- package/dist/server/console.css +33 -6
- package/dist/server/engine-api.js +378 -0
- package/dist/server/flows.js +2 -2
- package/dist/server/guards.js +10 -4
- package/dist/server/home.js +37 -5
- package/dist/server/http.js +11 -2
- package/dist/server/in-place.js +5 -4
- package/dist/server/kit.js +2 -2
- package/dist/server/link-redemption.js +52 -0
- package/dist/server/live.js +100 -10
- package/dist/server/mutation-key.js +21 -7
- package/dist/server/pages.js +129 -74
- package/dist/server/people-tokens.js +17 -41
- package/dist/server/render-chat.js +2 -1
- package/dist/server/render-history.js +18 -4
- package/dist/server/render-new-task.js +4 -4
- package/dist/server/render-pages.js +21 -39
- package/dist/server/render-people.js +2 -2
- package/dist/server/render-projects.js +5 -5
- package/dist/server/render-results.js +30 -14
- package/dist/server/render-tasks.js +155 -155
- package/dist/server/retired-routes.js +37 -4
- package/dist/server/route-policy.js +8 -0
- package/dist/server/route-table.js +43 -5
- package/dist/server/settings-computers.js +140 -0
- package/dist/server/settings-scripts.js +15 -0
- package/dist/server/settings-section-table.js +59 -0
- package/dist/server/settings-sections.js +291 -0
- package/dist/server/settings.js +247 -28
- package/dist/server/task-views.js +55 -15
- package/dist/server/tasks.js +168 -98
- package/dist/server/terminals.js +181 -28
- package/dist/server/welcome.js +40 -14
- package/dist/settings-groups-ui.js +26 -107
- package/dist/settings-proofs.js +18 -11
- package/dist/slack-api.js +4 -3
- package/dist/slack-chat.js +5 -3
- package/dist/spend.js +46 -12
- package/dist/sqlite-telemetry.js +70 -21
- package/dist/status-probe.js +343 -0
- package/dist/store.js +206 -10
- package/dist/task-link.js +64 -0
- package/dist/teams-api.js +4 -3
- package/dist/teams-chat.js +4 -2
- package/dist/telegram-lead.js +2 -1
- package/dist/telegram-live.js +2 -1
- package/dist/telegram-team.js +2 -1
- package/dist/telegram.js +17 -5
- package/dist/trusted-path.js +162 -0
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/tui-launch.js +282 -0
- package/dist/tui-source.js +5 -3
- package/dist/tui.js +2 -2
- package/dist/typed-words-schema.js +18 -0
- package/dist/webhooks.js +8 -4
- package/dist/welcome-facts.js +25 -17
- package/dist/work-index.js +126 -29
- package/dist/work-reads.js +279 -0
- package/dist/workspace-ui.js +5 -0
- package/package.json +4 -2
- package/scripts/crash-canary.mjs +1 -1
- package/scripts/pilot.mjs +1 -1
- package/scripts/provider-canary.mjs +5 -3
package/dist/flexible.js
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { canonicalJson } from "./canonical-json.js";
|
|
3
|
+
import { FLEXIBLE_AVAILABLE } from "./flexible-available.js";
|
|
4
|
+
export const FLEXIBLE_LEVELS = ["supervised", "auto", "full"];
|
|
5
|
+
export const FLEXIBLE_TERMS_VERSION = 1;
|
|
6
|
+
export const FLEXIBLE_DEFAULT_CAPS = Object.freeze({ liveThreads: 3, turnsPerDayProject: 300, turnsPerDayPerson: 150, measuredMicrousdPerDay: null });
|
|
7
|
+
const CAP_LIMITS = { liveThreads: 20, turnsPerDayProject: 10_000, turnsPerDayPerson: 10_000, measuredMicrousdPerDay: 100_000 * 1_000_000 };
|
|
8
|
+
export const FLEXIBLE_LEVEL_WORDS = Object.freeze({ supervised: "Supervised", auto: "Auto", full: "Full access" });
|
|
9
|
+
const rank = (level) => FLEXIBLE_LEVELS.indexOf(level);
|
|
10
|
+
const lowest = (a, b) => (rank(a) <= rank(b) ? a : b);
|
|
11
|
+
export const isFlexibleLevel = (value) => typeof value === "string" && FLEXIBLE_LEVELS.includes(value);
|
|
12
|
+
export function flexibleCeilingAllows(ceiling, level) {
|
|
13
|
+
const top = ceiling === "escalated" ? "full" : ceiling === "standard" ? "auto" : ceiling === "safe" ? "supervised" : null;
|
|
14
|
+
return top !== null && rank(level) <= rank(top);
|
|
15
|
+
}
|
|
16
|
+
export function flexibleTermsJson(terms) {
|
|
17
|
+
return canonicalJson(terms);
|
|
18
|
+
}
|
|
19
|
+
export function flexibleDigestOf(terms) {
|
|
20
|
+
return createHash("sha256").update(`standing-orders:flexible:${flexibleTermsJson(terms)}`, "utf8").digest("hex").slice(0, 32);
|
|
21
|
+
}
|
|
22
|
+
const TERMS_KEYS = ["caps", "default", "max", "network", "passwordFreeUpTo", "repo", "signer", "signerGeneration", "starters", "version"];
|
|
23
|
+
const CAPS_KEYS = ["liveThreads", "measuredMicrousdPerDay", "turnsPerDayPerson", "turnsPerDayProject"];
|
|
24
|
+
const plainObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
25
|
+
const exactKeys = (value, keys) => { const own = Object.keys(value).sort(); return own.length === keys.length && own.every((key, at) => key === keys[at]); };
|
|
26
|
+
const count = (value, max) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1 && value <= max;
|
|
27
|
+
const safeText = (value, max) => typeof value === "string" && value.length > 0 && value.length <= max && !/[\x00-\x1f\x7f]/.test(value);
|
|
28
|
+
function validTerms(value) {
|
|
29
|
+
if (!plainObject(value) || !exactKeys(value, TERMS_KEYS))
|
|
30
|
+
return false;
|
|
31
|
+
const caps = value["caps"];
|
|
32
|
+
if (!plainObject(caps) || !exactKeys(caps, CAPS_KEYS))
|
|
33
|
+
return false;
|
|
34
|
+
if (!count(caps["liveThreads"], CAP_LIMITS.liveThreads) || !count(caps["turnsPerDayProject"], CAP_LIMITS.turnsPerDayProject) || !count(caps["turnsPerDayPerson"], CAP_LIMITS.turnsPerDayPerson))
|
|
35
|
+
return false;
|
|
36
|
+
if (caps["measuredMicrousdPerDay"] !== null && !count(caps["measuredMicrousdPerDay"], CAP_LIMITS.measuredMicrousdPerDay))
|
|
37
|
+
return false;
|
|
38
|
+
const { version, repo, signer, signerGeneration, starters, passwordFreeUpTo, max, network } = value;
|
|
39
|
+
if (version !== FLEXIBLE_TERMS_VERSION || !safeText(repo, 4096) || !repo.startsWith("/") || !safeText(signer, 200))
|
|
40
|
+
return false;
|
|
41
|
+
if (!count(signerGeneration, Number.MAX_SAFE_INTEGER))
|
|
42
|
+
return false;
|
|
43
|
+
if (starters !== "signer" && starters !== "approvers-with-access")
|
|
44
|
+
return false;
|
|
45
|
+
if (network !== "confined" && network !== "open")
|
|
46
|
+
return false;
|
|
47
|
+
if (!isFlexibleLevel(passwordFreeUpTo) || !isFlexibleLevel(max) || !isFlexibleLevel(value["default"]))
|
|
48
|
+
return false;
|
|
49
|
+
return rank(value["default"]) <= rank(passwordFreeUpTo) && rank(passwordFreeUpTo) <= rank(max);
|
|
50
|
+
}
|
|
51
|
+
export function flexibleTermsFromJson(json) {
|
|
52
|
+
if (typeof json !== "string" || json.length > 16_384)
|
|
53
|
+
return null;
|
|
54
|
+
let parsed;
|
|
55
|
+
try {
|
|
56
|
+
parsed = JSON.parse(json);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (!validTerms(parsed))
|
|
62
|
+
return null;
|
|
63
|
+
return canonicalJson(parsed) === json ? parsed : null;
|
|
64
|
+
}
|
|
65
|
+
export function flexibleNarrowerOrEqual(next, signed) {
|
|
66
|
+
if (next.version !== signed.version || next.repo !== signed.repo || next.signer !== signed.signer || next.signerGeneration !== signed.signerGeneration || next.network !== signed.network)
|
|
67
|
+
return false;
|
|
68
|
+
if (next.starters !== signed.starters && next.starters !== "signer")
|
|
69
|
+
return false;
|
|
70
|
+
if (rank(next.max) > rank(signed.max) || rank(next.passwordFreeUpTo) > rank(signed.passwordFreeUpTo) || rank(next.default) > rank(signed.default))
|
|
71
|
+
return false;
|
|
72
|
+
const a = next.caps, b = signed.caps;
|
|
73
|
+
if (a.liveThreads > b.liveThreads || a.turnsPerDayProject > b.turnsPerDayProject || a.turnsPerDayPerson > b.turnsPerDayPerson)
|
|
74
|
+
return false;
|
|
75
|
+
return b.measuredMicrousdPerDay === null || (a.measuredMicrousdPerDay !== null && a.measuredMicrousdPerDay <= b.measuredMicrousdPerDay);
|
|
76
|
+
}
|
|
77
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
78
|
+
export const FULL_ACCESS_WORDS = "Full access removes the agent's permission prompts inside the sandbox only. It never lets the agent leave the sandbox, use your keychain or SSH agent, read or change Toolroll's own data, write to your repository directly, or change how agents are started. It covers the agent's own tools, its MCP servers and plugins, and every program they start. Answering an agent's request never runs anything outside the sandbox, and if the sandbox can't hold, the thread doesn't run.";
|
|
79
|
+
export const OPEN_NETWORK_WORDS = [
|
|
80
|
+
"This project's network is open. The agent can send anything it can read to any website: your code, files the sandbox allows it to read, and the conversation.",
|
|
81
|
+
"If it finds a credential Toolroll missed, such as a token in a project file, it can use it, including to push code anywhere that credential reaches. Branch protection and Toolroll's own push limits don't stop a credential the agent finds itself.",
|
|
82
|
+
"Turn on branch protection for your default branch anyway.",
|
|
83
|
+
];
|
|
84
|
+
export function flexibleTermsWords(terms) {
|
|
85
|
+
const who = terms.starters === "signer" ? `Only ${terms.signer} may` : "People who can approve work in this project may";
|
|
86
|
+
const start = `${who} start Flexible threads at ${FLEXIBLE_LEVEL_WORDS[terms.passwordFreeUpTo]} without a password.`;
|
|
87
|
+
const raise = rank(terms.max) > rank(terms.passwordFreeUpTo) ? ` A thread can be raised to ${FLEXIBLE_LEVEL_WORDS[terms.max]} with that person's password.` : "";
|
|
88
|
+
const levels = [];
|
|
89
|
+
if (rank(terms.max) >= rank("full"))
|
|
90
|
+
levels.push(FULL_ACCESS_WORDS);
|
|
91
|
+
if (rank(terms.max) >= rank("auto"))
|
|
92
|
+
levels.push("Auto lets the agent run routine commands inside the sandbox and asks you before anything outside it.");
|
|
93
|
+
levels.push("Supervised asks you before each command and file change.");
|
|
94
|
+
const caps = terms.caps;
|
|
95
|
+
const spend = caps.measuredMicrousdPerDay === null ? "" : ` New turns stop once today's measured spend reaches $${(caps.measuredMicrousdPerDay / 1_000_000).toFixed(2)}; a turn already running may go past it.`;
|
|
96
|
+
return [
|
|
97
|
+
`${start}${raise} New threads start at ${FLEXIBLE_LEVEL_WORDS[terms.default]}.`,
|
|
98
|
+
...levels,
|
|
99
|
+
"Each thread works in its own copy of the repository, on its own branch, and can read the repository's whole history. Its work reaches your repository only when someone sends it for checks, and nothing merges unless the required check passes on that exact commit.",
|
|
100
|
+
`Limits: ${plural(caps.liveThreads, "thread")} at once, ${plural(caps.turnsPerDayProject, "agent turn")} a day in this project, ${plural(caps.turnsPerDayPerson, "turn")} a day per person. A limit on turns doesn't limit what one turn costs.${spend}`,
|
|
101
|
+
...(terms.network === "open" ? OPEN_NETWORK_WORDS : []),
|
|
102
|
+
"This lasts until someone turns it off or lowers it, or until your account or access changes, the project needs two people to approve, its network setting changes, or the organisation's permission ceiling drops. Turning it off or lowering it stops new threads at once.",
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
export const FLEXIBLE_LAPSE_WORDS = Object.freeze({
|
|
106
|
+
"signer-revoked": "The person who turned it on no longer has an account.",
|
|
107
|
+
"signer-changed": "The account of the person who turned it on changed (password, role or project access).",
|
|
108
|
+
"signer-not-approver": "The person who turned it on can no longer approve work.",
|
|
109
|
+
"signer-lost-access": "The person who turned it on lost access to this project.",
|
|
110
|
+
"two-person": "This project now needs two people to approve work.",
|
|
111
|
+
"network-changed": "This project's network setting changed.",
|
|
112
|
+
"ceiling-lowered": "The organisation's permission ceiling no longer allows these terms.",
|
|
113
|
+
});
|
|
114
|
+
export function flexibleNetworkOf(store, repo) {
|
|
115
|
+
return store.projectNetwork(repo).mode === "open" ? "open" : "confined";
|
|
116
|
+
}
|
|
117
|
+
export function flexibleTwoPerson(store, repo) {
|
|
118
|
+
const rules = store.approvalRules(repo);
|
|
119
|
+
return rules.notRequester || rules.protectProject;
|
|
120
|
+
}
|
|
121
|
+
function approverHere(store, name, repo) {
|
|
122
|
+
const account = store.accountOf(name);
|
|
123
|
+
if (account === null || account.revokedAt !== null || account.role !== "approver")
|
|
124
|
+
return null;
|
|
125
|
+
return store.accountCanAccess(name, repo) ? { generation: account.generation } : null;
|
|
126
|
+
}
|
|
127
|
+
function lapseOf(store, terms) {
|
|
128
|
+
const account = store.accountOf(terms.signer);
|
|
129
|
+
if (account === null || account.revokedAt !== null)
|
|
130
|
+
return "signer-revoked";
|
|
131
|
+
if (account.generation !== terms.signerGeneration)
|
|
132
|
+
return "signer-changed";
|
|
133
|
+
if (account.role !== "approver")
|
|
134
|
+
return "signer-not-approver";
|
|
135
|
+
if (!store.accountCanAccess(terms.signer, terms.repo))
|
|
136
|
+
return "signer-lost-access";
|
|
137
|
+
if (flexibleTwoPerson(store, terms.repo))
|
|
138
|
+
return "two-person";
|
|
139
|
+
if (flexibleNetworkOf(store, terms.repo) !== terms.network)
|
|
140
|
+
return "network-changed";
|
|
141
|
+
if (!flexibleCeilingAllows(store.orgPolicy().ceiling, terms.max))
|
|
142
|
+
return "ceiling-lowered";
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
function readRow(row, repo) {
|
|
146
|
+
const terms = flexibleTermsFromJson(row["terms_json"]);
|
|
147
|
+
const signed = flexibleTermsFromJson(row["signed_terms_json"]);
|
|
148
|
+
if (terms === null || signed === null)
|
|
149
|
+
return null;
|
|
150
|
+
if (flexibleDigestOf(terms) !== row["digest"] || flexibleDigestOf(signed) !== row["signed_digest"])
|
|
151
|
+
return null;
|
|
152
|
+
if (row["repo"] !== repo || terms.repo !== repo || signed.signer !== row["signed_by"] || !flexibleNarrowerOrEqual(terms, signed))
|
|
153
|
+
return null;
|
|
154
|
+
return { id: Number(row["id"]), terms, digest: String(row["digest"]), signedDigest: String(row["signed_digest"]), signedBy: String(row["signed_by"]),
|
|
155
|
+
signedAt: String(row["signed_at"]), changedBy: String(row["changed_by"]), changedAt: String(row["changed_at"]) };
|
|
156
|
+
}
|
|
157
|
+
export function flexibleStanding(store, repo) {
|
|
158
|
+
let row;
|
|
159
|
+
try {
|
|
160
|
+
row = store.handle.prepare("SELECT * FROM flexible_terms WHERE repo = ? AND ended_at IS NULL").get(repo);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return { state: "unreadable", id: null };
|
|
164
|
+
}
|
|
165
|
+
if (row === undefined)
|
|
166
|
+
return { state: "secure" };
|
|
167
|
+
const read = readRow(row, repo);
|
|
168
|
+
if (read === null)
|
|
169
|
+
return { state: "unreadable", id: Number(row["id"]) };
|
|
170
|
+
const lapse = lapseOf(store, read.terms);
|
|
171
|
+
return lapse === null ? { state: "on", ...read } : { state: "lapsed", reason: lapse, ...read };
|
|
172
|
+
}
|
|
173
|
+
export const FLEXIBLE_UNAVAILABLE = "Flexible projects aren't available in this version. Nothing changed.";
|
|
174
|
+
const WORDS = Object.freeze({
|
|
175
|
+
"not-available": FLEXIBLE_UNAVAILABLE,
|
|
176
|
+
"not-an-approver": "Only an approver for this project can do that. Nothing changed.",
|
|
177
|
+
"proof-required": "Turning on Flexible needs your password, typed now. Nothing changed.",
|
|
178
|
+
"two-person": "This project needs two people to approve work, so it can't be Flexible. Nothing changed.",
|
|
179
|
+
"above-ceiling": "The organisation's permission ceiling doesn't allow that level. Nothing changed.",
|
|
180
|
+
"invalid-choice": "Choose Supervised, Auto or Full access, with new threads starting no higher than the highest level. Nothing changed.",
|
|
181
|
+
"terms-changed": "The terms changed since they were shown. Read them again before agreeing. Nothing changed.",
|
|
182
|
+
"not-flexible": "This project isn't Flexible.",
|
|
183
|
+
"terms-unreadable": "This project's Flexible terms can't be read, so they allow nothing. Turn Flexible off, then on again.",
|
|
184
|
+
"not-lower": "Lowering can't raise a level. Turn Flexible on again, with your password, to sign higher terms. Nothing changed.",
|
|
185
|
+
"stale-generation": "Your account changed since this started. Sign in again and retry.",
|
|
186
|
+
"not-a-starter": "These terms let only the person who turned Flexible on start threads.",
|
|
187
|
+
"above-max": "That level is above what this project's Flexible terms allow.",
|
|
188
|
+
});
|
|
189
|
+
const refuse = (reason) => ({ ok: false, reason, message: WORDS[reason] });
|
|
190
|
+
const lapsed = (lapse) => ({ ok: false, reason: "terms-lapsed", message: `This project's Flexible terms no longer count. ${FLEXIBLE_LAPSE_WORDS[lapse]} Turn it on again to sign new terms.` });
|
|
191
|
+
export function proposedFlexibleTerms(store, repo, signer, choice = {}) {
|
|
192
|
+
const standing = approverHere(store, signer, repo);
|
|
193
|
+
if (standing === null)
|
|
194
|
+
return refuse("not-an-approver");
|
|
195
|
+
if (flexibleTwoPerson(store, repo))
|
|
196
|
+
return refuse("two-person");
|
|
197
|
+
const ceiling = store.orgPolicy().ceiling;
|
|
198
|
+
const ceilingTop = [...FLEXIBLE_LEVELS].reverse().find(level => flexibleCeilingAllows(ceiling, level)) ?? null;
|
|
199
|
+
if (ceilingTop === null)
|
|
200
|
+
return refuse("above-ceiling");
|
|
201
|
+
const max = choice.max ?? ceilingTop;
|
|
202
|
+
const level = choice.default ?? max;
|
|
203
|
+
if (!isFlexibleLevel(max) || !isFlexibleLevel(level) || rank(level) > rank(max))
|
|
204
|
+
return refuse("invalid-choice");
|
|
205
|
+
if (!flexibleCeilingAllows(ceiling, max))
|
|
206
|
+
return refuse("above-ceiling");
|
|
207
|
+
const terms = { version: FLEXIBLE_TERMS_VERSION, repo, signer, signerGeneration: standing.generation, starters: "approvers-with-access",
|
|
208
|
+
passwordFreeUpTo: max, max, default: level, network: flexibleNetworkOf(store, repo), caps: { ...FLEXIBLE_DEFAULT_CAPS } };
|
|
209
|
+
if (!validTerms(terms))
|
|
210
|
+
return refuse("invalid-choice");
|
|
211
|
+
return { ok: true, terms, digest: flexibleDigestOf(terms) };
|
|
212
|
+
}
|
|
213
|
+
const levelsWords = (terms) => `max ${terms.max}, password-free ${terms.passwordFreeUpTo}, default ${terms.default}`;
|
|
214
|
+
function endRow(store, id, reason, by, detail, now) {
|
|
215
|
+
const ended = store.handle.prepare("UPDATE flexible_terms SET ended_at = ?, ended_by = ?, end_reason = ?, end_detail = ? WHERE id = ? AND ended_at IS NULL")
|
|
216
|
+
.run(now.toISOString(), by, reason, detail, id);
|
|
217
|
+
if (Number(ended.changes) !== 1)
|
|
218
|
+
return false;
|
|
219
|
+
const ships = store.handle.prepare("SELECT id, repo, task_id FROM flexible_ship WHERE delegation_id = ? AND state IN ('armed', 'completed')").all(id);
|
|
220
|
+
for (const ship of ships) {
|
|
221
|
+
store.handle.prepare("UPDATE flexible_ship SET state = 'cancelled', detail = ?, state_at = ? WHERE id = ? AND state IN ('armed', 'completed')")
|
|
222
|
+
.run(`the project's Flexible terms it was shipped under ended (${reason})`, now.toISOString(), String(ship["id"]));
|
|
223
|
+
store.recordAction({ at: now.toISOString(), actor: by, repo: String(ship["repo"]), taskId: ship["task_id"] === null ? null : String(ship["task_id"]), runId: null, source: "policy",
|
|
224
|
+
action: "flexible merge cancelled", outcome: "cancelled", detail: `ship ${String(ship["id"])} · the Flexible terms ended (${reason})` });
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
function insertRow(store, row, now) {
|
|
229
|
+
const written = store.handle.prepare(`INSERT INTO flexible_terms (repo, terms_json, digest, signed_terms_json, signed_digest, signed_by, signed_at, proof, changed_by, changed_at, derived_from)
|
|
230
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(row.repo, flexibleTermsJson(row.terms), flexibleDigestOf(row.terms), row.signedJson, row.signedDigest, row.signedBy, row.signedAt, row.proof, row.changedBy, now.toISOString(), row.derivedFrom);
|
|
231
|
+
return Number(written.lastInsertRowid);
|
|
232
|
+
}
|
|
233
|
+
export function enableFlexible(store, input) {
|
|
234
|
+
if (!FLEXIBLE_AVAILABLE)
|
|
235
|
+
return refuse("not-available");
|
|
236
|
+
if (input.proof !== "password-now" && input.proof !== "sso-now")
|
|
237
|
+
return refuse("proof-required");
|
|
238
|
+
const proof = input.proof;
|
|
239
|
+
return store.transact(() => {
|
|
240
|
+
const proposed = proposedFlexibleTerms(store, input.repo, input.by, input.choice ?? {});
|
|
241
|
+
if (!proposed.ok)
|
|
242
|
+
return proposed;
|
|
243
|
+
if (proposed.digest !== input.shownDigest)
|
|
244
|
+
return refuse("terms-changed");
|
|
245
|
+
const live = store.handle.prepare("SELECT id FROM flexible_terms WHERE repo = ? AND ended_at IS NULL").get(input.repo);
|
|
246
|
+
const replaced = live !== undefined;
|
|
247
|
+
if (replaced)
|
|
248
|
+
endRow(store, Number(live["id"]), "replaced", input.by, null, input.now);
|
|
249
|
+
const json = flexibleTermsJson(proposed.terms);
|
|
250
|
+
const id = insertRow(store, { repo: input.repo, terms: proposed.terms, signedJson: json, signedDigest: proposed.digest, signedBy: input.by, signedAt: input.now.toISOString(), proof, changedBy: input.by, derivedFrom: null }, input.now);
|
|
251
|
+
store.recordAction({ at: input.now.toISOString(), actor: input.by, repo: input.repo, taskId: null, runId: null, source: "policy", action: "flexible turned on", outcome: "on",
|
|
252
|
+
detail: `terms ${proposed.digest} · ${levelsWords(proposed.terms)} · network ${proposed.terms.network}${replaced ? " · replaced earlier terms" : ""}` });
|
|
253
|
+
store.bumpWake();
|
|
254
|
+
return { ok: true, id, digest: proposed.digest, terms: proposed.terms, replaced };
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
export function lowerFlexible(store, input) {
|
|
258
|
+
if (!FLEXIBLE_AVAILABLE)
|
|
259
|
+
return refuse("not-available");
|
|
260
|
+
if (!isFlexibleLevel(input.max))
|
|
261
|
+
return refuse("invalid-choice");
|
|
262
|
+
return store.transact(() => {
|
|
263
|
+
if (approverHere(store, input.by, input.repo) === null)
|
|
264
|
+
return refuse("not-an-approver");
|
|
265
|
+
const standing = flexibleStanding(store, input.repo);
|
|
266
|
+
if (standing.state === "secure")
|
|
267
|
+
return refuse("not-flexible");
|
|
268
|
+
if (standing.state === "unreadable")
|
|
269
|
+
return refuse("terms-unreadable");
|
|
270
|
+
if (standing.state === "lapsed")
|
|
271
|
+
return lapsed(standing.reason);
|
|
272
|
+
const current = standing.terms;
|
|
273
|
+
if (rank(input.max) > rank(current.max))
|
|
274
|
+
return refuse("not-lower");
|
|
275
|
+
const next = { ...current, max: input.max, passwordFreeUpTo: lowest(current.passwordFreeUpTo, input.max), default: lowest(current.default, input.max) };
|
|
276
|
+
if (flexibleTermsJson(next) === flexibleTermsJson(current))
|
|
277
|
+
return { ok: true, changed: false, digest: standing.digest, terms: current };
|
|
278
|
+
const signed = store.handle.prepare("SELECT signed_terms_json, proof FROM flexible_terms WHERE id = ?").get(standing.id);
|
|
279
|
+
endRow(store, standing.id, "lowered", input.by, null, input.now);
|
|
280
|
+
insertRow(store, { repo: input.repo, terms: next, signedJson: String(signed["signed_terms_json"]), signedDigest: standing.signedDigest, signedBy: standing.signedBy, signedAt: standing.signedAt,
|
|
281
|
+
proof: signed["proof"] === "sso-now" ? "sso-now" : "password-now", changedBy: input.by, derivedFrom: standing.id }, input.now);
|
|
282
|
+
store.recordAction({ at: input.now.toISOString(), actor: input.by, repo: input.repo, taskId: null, runId: null, source: "policy", action: "flexible lowered", outcome: "lowered",
|
|
283
|
+
detail: `${levelsWords(current)} → ${levelsWords(next)} · terms ${flexibleDigestOf(next)}` });
|
|
284
|
+
store.bumpWake();
|
|
285
|
+
return { ok: true, changed: true, digest: flexibleDigestOf(next), terms: next };
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
export function turnFlexibleOff(store, input) {
|
|
289
|
+
if (!FLEXIBLE_AVAILABLE)
|
|
290
|
+
return refuse("not-available");
|
|
291
|
+
return store.transact(() => {
|
|
292
|
+
if (approverHere(store, input.by, input.repo) === null)
|
|
293
|
+
return refuse("not-an-approver");
|
|
294
|
+
const live = store.handle.prepare("SELECT id FROM flexible_terms WHERE repo = ? AND ended_at IS NULL").get(input.repo);
|
|
295
|
+
if (live === undefined)
|
|
296
|
+
return { ok: true, changed: false };
|
|
297
|
+
endRow(store, Number(live["id"]), "off", input.by, null, input.now);
|
|
298
|
+
store.recordAction({ at: input.now.toISOString(), actor: input.by, repo: input.repo, taskId: null, runId: null, source: "policy", action: "flexible turned off", outcome: "off", detail: null });
|
|
299
|
+
store.bumpWake();
|
|
300
|
+
return { ok: true, changed: true };
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
export function endLapsedFlexible(store, which, by, now) {
|
|
304
|
+
const db = store.handle;
|
|
305
|
+
db.exec("SAVEPOINT flexible_lapse");
|
|
306
|
+
try {
|
|
307
|
+
const rows = which === "all" ? db.prepare("SELECT repo, signed_by FROM flexible_terms WHERE ended_at IS NULL").all()
|
|
308
|
+
: "repo" in which ? db.prepare("SELECT repo, signed_by FROM flexible_terms WHERE ended_at IS NULL AND repo = ?").all(which.repo)
|
|
309
|
+
: db.prepare("SELECT repo, signed_by FROM flexible_terms WHERE ended_at IS NULL AND signed_by = ?").all(which.signer);
|
|
310
|
+
let ended = 0;
|
|
311
|
+
for (const row of rows) {
|
|
312
|
+
const repo = String(row["repo"]);
|
|
313
|
+
const standing = flexibleStanding(store, repo);
|
|
314
|
+
if (standing.state !== "lapsed")
|
|
315
|
+
continue;
|
|
316
|
+
if (!endRow(store, standing.id, "lapsed", by, standing.reason, now))
|
|
317
|
+
continue;
|
|
318
|
+
store.recordAction({ at: now.toISOString(), actor: by, repo, taskId: null, runId: null, source: "policy", action: "flexible terms lapsed", outcome: "lapsed", detail: FLEXIBLE_LAPSE_WORDS[standing.reason] });
|
|
319
|
+
ended++;
|
|
320
|
+
}
|
|
321
|
+
db.exec("RELEASE flexible_lapse");
|
|
322
|
+
return ended;
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
db.exec("ROLLBACK TO flexible_lapse");
|
|
326
|
+
db.exec("RELEASE flexible_lapse");
|
|
327
|
+
return 0;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
export function flexibleDelegationAtUse(store, input) {
|
|
331
|
+
if (!FLEXIBLE_AVAILABLE)
|
|
332
|
+
return refuse("not-available");
|
|
333
|
+
return store.transact(() => {
|
|
334
|
+
const standing = flexibleStanding(store, input.repo);
|
|
335
|
+
if (standing.state === "secure")
|
|
336
|
+
return refuse("not-flexible");
|
|
337
|
+
if (standing.state === "unreadable")
|
|
338
|
+
return refuse("terms-unreadable");
|
|
339
|
+
if (standing.state === "lapsed")
|
|
340
|
+
return lapsed(standing.reason);
|
|
341
|
+
if (standing.digest !== input.digest)
|
|
342
|
+
return refuse("terms-changed");
|
|
343
|
+
const account = store.accountOf(input.starter.name);
|
|
344
|
+
if (account === null || account.revokedAt !== null || account.role !== "approver")
|
|
345
|
+
return refuse("not-an-approver");
|
|
346
|
+
if (account.generation !== input.starter.generation)
|
|
347
|
+
return refuse("stale-generation");
|
|
348
|
+
if (!store.accountCanAccess(input.starter.name, input.repo))
|
|
349
|
+
return refuse("not-an-approver");
|
|
350
|
+
const terms = standing.terms;
|
|
351
|
+
if (terms.starters === "signer" && input.starter.name !== terms.signer)
|
|
352
|
+
return refuse("not-a-starter");
|
|
353
|
+
if (!isFlexibleLevel(input.level) || rank(input.level) > rank(terms.max))
|
|
354
|
+
return refuse("above-max");
|
|
355
|
+
if (!flexibleCeilingAllows(store.orgPolicy().ceiling, input.level))
|
|
356
|
+
return refuse("above-ceiling");
|
|
357
|
+
if (rank(input.level) > rank(terms.passwordFreeUpTo) && input.freshProof !== true)
|
|
358
|
+
return { ok: false, reason: "proof-required", message: `Starting at ${FLEXIBLE_LEVEL_WORDS[input.level]} needs your password.` };
|
|
359
|
+
return { ok: true, termsId: standing.id, digest: standing.digest, terms };
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
export function flexibleSettingsView(store, repo, viewer) {
|
|
363
|
+
if (!FLEXIBLE_AVAILABLE)
|
|
364
|
+
return undefined;
|
|
365
|
+
const proposed = viewer.canChange ? proposedFlexibleTerms(store, repo, viewer.name) : refuse("not-an-approver");
|
|
366
|
+
return { repo, standing: flexibleStanding(store, repo), canChange: viewer.canChange,
|
|
367
|
+
proposal: proposed.ok ? { terms: proposed.terms, digest: proposed.digest } : { problem: proposed.message.replace(/ Nothing changed\.$/, "") } };
|
|
368
|
+
}
|
package/dist/flow-actions.js
CHANGED
|
@@ -7,6 +7,7 @@ import { readFlowSecrets, scrubSecrets } from "./flow-secrets.js";
|
|
|
7
7
|
export { readEmailSettings, saveEmailSettings } from "./email-settings.js";
|
|
8
8
|
import { callProjectTool, projectToolsOf, readToolSecrets, toolServerFor } from "./project-tools.js";
|
|
9
9
|
import { ALL_CREDENTIAL_ENV } from "./provider.js";
|
|
10
|
+
import { safeMail } from "./outbound-privacy.js";
|
|
10
11
|
const clip = (text, cap) => text.length <= cap ? text : `${text.slice(0, cap - 1)}…`;
|
|
11
12
|
const blank = (text) => redactSecretAssignments(redactSecretLines(text, scanForSecrets(text)));
|
|
12
13
|
const scrub = scrubSecrets;
|
|
@@ -123,7 +124,7 @@ export const sendThroughServer = async (settings, mail) => {
|
|
|
123
124
|
transport.close();
|
|
124
125
|
}
|
|
125
126
|
};
|
|
126
|
-
export async function sendEmail(stage, card, io, thread = null) {
|
|
127
|
+
export async function sendEmail(stage, card, io, thread = null, repo = null) {
|
|
127
128
|
const account = await sendingAccount(io.dir, io.fetch ?? fetch);
|
|
128
129
|
if (!account.ok)
|
|
129
130
|
return { state: account.permanent ? "failed" : "retry", said: account.said };
|
|
@@ -140,11 +141,12 @@ export async function sendEmail(stage, card, io, thread = null) {
|
|
|
140
141
|
const source = card.source?.mail;
|
|
141
142
|
const known = thread ?? (source?.id ? { inReplyTo: source.id, references: [...source.references, source.id].slice(-20), people: new Set([source.from]) } : null);
|
|
142
143
|
const threaded = known !== null && to.some(one => known.people.has(one.toLowerCase())) ? { inReplyTo: known.inReplyTo, references: known.references } : {};
|
|
143
|
-
const
|
|
144
|
-
const
|
|
144
|
+
const mail = safeMail({ from: settings.from, to, subject, text: body, ...threaded }, { project: repo });
|
|
145
|
+
const sent = await (io.mail ?? sendThroughServer)(settings, mail);
|
|
146
|
+
const log = `From ${settings.from} to ${to.join(", ")}\nSubject: ${mail.subject}\n\n${blank(mail.text)}`;
|
|
145
147
|
if (!sent.ok)
|
|
146
148
|
return { state: sent.permanent ? "failed" : "retry", said: sent.said, log };
|
|
147
|
-
return { state: "passed", said: `Emailed ${to.join(", ")}.`, log, output: `Sent to ${to.join(", ")}: “${subject}”`, mail: { id: sent.id, to } };
|
|
149
|
+
return { state: "passed", said: `Emailed ${to.join(", ")}.`, log, output: `Sent to ${to.join(", ")}: “${mail.subject}”`, mail: { id: sent.id, to } };
|
|
148
150
|
}
|
|
149
151
|
export function toolWaiting(store, stage, repo) {
|
|
150
152
|
const wanted = stage.tool?.server ?? "";
|
package/dist/flow-steps.js
CHANGED
|
@@ -129,7 +129,7 @@ export async function runFlowSteps(store, repo, now, io) {
|
|
|
129
129
|
: stage.kind === "sort" ? await sortCard(known.definition, stage, card, key, io)
|
|
130
130
|
: stage.kind === "draft" ? await draftCard(store, known.definition, stage, card, io, repo, now)
|
|
131
131
|
: stage.kind === "request" ? await runRequest(stage, card, repo, io)
|
|
132
|
-
: stage.kind === "email" ? await sendEmail(stage, card, io, threadOf(store, card))
|
|
132
|
+
: stage.kind === "email" ? await sendEmail(stage, card, io, threadOf(store, card), repo)
|
|
133
133
|
: stage.kind === "tool" ? await useTool(store, stage, card, repo, io)
|
|
134
134
|
: await updateSource(store, stage, card, io, now);
|
|
135
135
|
}
|
package/dist/flows-cli.js
CHANGED
|
@@ -407,7 +407,8 @@ export async function runFlowsCommand(positional, flags, context) {
|
|
|
407
407
|
const given = text('digest');
|
|
408
408
|
if (given === null)
|
|
409
409
|
return fail('usage', `Approve exactly what you read: flows browser ${flow.id} on --yes --digest <the digest the preview showed>.`, EXIT.usage);
|
|
410
|
-
const
|
|
410
|
+
const browserProof = proveCredential(store, acting.name, acting.token, flow.repo);
|
|
411
|
+
const signed = signFlowBrowser(store, { flow: flow.id, signer: who, proof: browserProof.ok ? browserProof.method : null, sawDigest: given }, now);
|
|
411
412
|
if (!signed.ok)
|
|
412
413
|
return refuse(flow.repo, 'refused', `${signed.message} Nothing was changed.`);
|
|
413
414
|
record(flow.repo, 'accepted', `flow #${flow.id} browser on`);
|
package/dist/git-views.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
-
import {
|
|
3
|
+
import { lstatSync, mkdirSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { sqliteRuntime } from "./sqlite-runtime.js";
|
|
5
6
|
export function gitViewsRoot(home) {
|
|
6
7
|
return join(home, ".toolroll", "git-views");
|
|
7
8
|
}
|
|
@@ -35,62 +36,64 @@ export async function lockCheckout(home, checkout, timeoutMs = 10 * 60_000) {
|
|
|
35
36
|
const held = lstatSync(folder);
|
|
36
37
|
if (!held.isDirectory() || held.isSymbolicLink())
|
|
37
38
|
throw new Error(`${folder} isn't a folder of this user's own`);
|
|
38
|
-
const path = join(folder, `${createHash("sha256").update(checkout).digest("hex")}.
|
|
39
|
+
const path = join(folder, `${createHash("sha256").update(checkout).digest("hex")}.lockdb`);
|
|
40
|
+
try {
|
|
41
|
+
if (!lstatSync(path).isFile())
|
|
42
|
+
throw new Error(`${path} isn't a lock file`);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (error.code !== "ENOENT")
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
const { DatabaseSync } = sqliteRuntime();
|
|
49
|
+
const db = new DatabaseSync(path);
|
|
39
50
|
const deadline = Date.now() + timeoutMs;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
try {
|
|
52
|
+
db.exec("PRAGMA busy_timeout = 0");
|
|
53
|
+
for (;;) {
|
|
43
54
|
try {
|
|
44
|
-
|
|
55
|
+
db.exec("BEGIN IMMEDIATE");
|
|
56
|
+
break;
|
|
45
57
|
}
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (!/locked|busy/i.test(error instanceof Error ? error.message : String(error)))
|
|
60
|
+
throw error;
|
|
48
61
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
rmSync(path, { force: true });
|
|
53
|
-
} };
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
if (error.code !== "EEXIST")
|
|
57
|
-
throw error;
|
|
62
|
+
if (Date.now() > deadline)
|
|
63
|
+
throw new Error("another of Toolroll's git commands on this checkout is still running");
|
|
64
|
+
await new Promise(done => setTimeout(done, 25));
|
|
58
65
|
}
|
|
59
|
-
let owner = NaN;
|
|
60
|
-
try {
|
|
61
|
-
owner = Number(readFileSync(path, "utf8").trim());
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
owner = NaN;
|
|
65
|
-
}
|
|
66
|
-
if (Number.isSafeInteger(owner) && owner > 0 && owner !== process.pid && !alive(owner)) {
|
|
67
|
-
rmSync(path, { force: true });
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (Date.now() > deadline)
|
|
71
|
-
throw new Error("another of Toolroll's git commands on this checkout is still running");
|
|
72
|
-
await new Promise(done => setTimeout(done, 25));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function alive(pid) {
|
|
76
|
-
try {
|
|
77
|
-
process.kill(pid, 0);
|
|
78
|
-
return true;
|
|
79
66
|
}
|
|
80
67
|
catch (error) {
|
|
81
|
-
|
|
68
|
+
db.close();
|
|
69
|
+
throw error;
|
|
82
70
|
}
|
|
71
|
+
let released = false;
|
|
72
|
+
return () => {
|
|
73
|
+
if (released)
|
|
74
|
+
return;
|
|
75
|
+
released = true;
|
|
76
|
+
try {
|
|
77
|
+
db.exec("ROLLBACK");
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
db.close();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
83
|
}
|
|
84
84
|
const heldHere = new AsyncLocalStorage();
|
|
85
85
|
export async function withCheckoutLock(home, checkout, work, timeoutMs) {
|
|
86
|
-
const held = heldHere.getStore()
|
|
87
|
-
|
|
86
|
+
const held = heldHere.getStore();
|
|
87
|
+
const hold = held?.get(checkout);
|
|
88
|
+
if (hold !== undefined && !hold.released)
|
|
88
89
|
return work();
|
|
89
90
|
const release = await lockCheckout(home, checkout, timeoutMs);
|
|
91
|
+
const mine = { released: false };
|
|
90
92
|
try {
|
|
91
|
-
return await heldHere.run(new
|
|
93
|
+
return await heldHere.run(new Map([...(held ?? new Map()), [checkout, mine]]), work);
|
|
92
94
|
}
|
|
93
95
|
finally {
|
|
96
|
+
mine.released = true;
|
|
94
97
|
release();
|
|
95
98
|
}
|
|
96
99
|
}
|
package/dist/guides.js
CHANGED
|
@@ -293,20 +293,21 @@ ${AUTHORITY_LINE}
|
|
|
293
293
|
|
|
294
294
|
## The console's screens (what each one is for)
|
|
295
295
|
|
|
296
|
-
- **
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
the dispatch order per builder (drag to reorder,
|
|
302
|
-
keep a task for it). The old pages (\`/
|
|
303
|
-
\`/
|
|
296
|
+
- **Work** (\`/\`): what needs a person first (plans to approve, questions to
|
|
297
|
+
answer, results to accept), then what is running, queued and done, with the
|
|
298
|
+
selected task beside the list (\`/?task=<id>\`). Views: Needs you, All,
|
|
299
|
+
Running, Queued, Done (\`/?view=needs-you\` and so on), the Board
|
|
300
|
+
(\`/?view=board\`), Archived, one project (\`/?project=<path>\`). Its *order*
|
|
301
|
+
view (\`/?view=order\`) is the dispatch order per builder (drag to reorder,
|
|
302
|
+
drag onto a builder to keep a task for it). The old pages (\`/tasks\`,
|
|
303
|
+
\`/inbox\`, \`/next\`, \`/board\`, \`/queue\`, \`/workbench\`, \`/done\`,
|
|
304
|
+
\`/work\`) redirect here for good.
|
|
304
305
|
- **task page** (\`/t/<id>\`): the approval ceremony when a scope waits,
|
|
305
306
|
the acts bar (plan first, hold, retry, build next, cancel), scope,
|
|
306
307
|
attempts, decisions, and — for a scout task — the report with one-tap
|
|
307
308
|
follow-ups.
|
|
308
309
|
- **builds** (\`/runs\`): every attempt, newest first; a result's own page
|
|
309
|
-
is \`/
|
|
310
|
+
is its task page's Result section (\`/t/<task>?tab=result&run=<run>\`), and activity (\`/activity\`) is the ledger. **build
|
|
310
311
|
page** (\`/r/<run>\`): one attempt: stage, live transcript, evidence,
|
|
311
312
|
the diff, comments. **peek** (\`/peek\`): every live run at once,
|
|
312
313
|
transcripts following.
|
|
@@ -321,7 +322,7 @@ ${AUTHORITY_LINE}
|
|
|
321
322
|
which messaging service pages, the Telegram bot token, and the Telegram
|
|
322
323
|
digest cadence (away mode). Notifications → Projects mutes one project's
|
|
323
324
|
pings (\`toolroll notifications mute|unmute --repo <p>\`); it still shows
|
|
324
|
-
in
|
|
325
|
+
in Work and the evening digest.
|
|
325
326
|
- The rail is four rows — inbox · board · builds · projects — and a
|
|
326
327
|
**more** group: portfolio, task list, fleet, system,
|
|
327
328
|
requirements, people, operating mode, settings. On a phone the same
|