toolroll 0.9.109 → 0.9.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +5 -1
  3. package/THIRD_PARTY_NOTICES.md +30 -0
  4. package/dist/agent-detect.js +244 -0
  5. package/dist/agent-fence.js +12 -1
  6. package/dist/agent-said-schema.js +4 -0
  7. package/dist/agent-said.js +23 -0
  8. package/dist/agentconfig.js +2 -2
  9. package/dist/approval-summary.js +375 -0
  10. package/dist/attest.js +2 -2
  11. package/dist/browser/THIRD_PARTY_NOTICES.txt +30 -0
  12. package/dist/browser/workspace.css +2 -2
  13. package/dist/browser/workspace.js +27 -27
  14. package/dist/builder.js +42 -3
  15. package/dist/chat-actions.js +24 -17
  16. package/dist/chat-core.js +3 -1
  17. package/dist/chat-decide.js +101 -46
  18. package/dist/chat-delivery-state.js +2 -0
  19. package/dist/chat-delivery.js +3 -2
  20. package/dist/chat-live.js +2 -1
  21. package/dist/chat-task-actions.js +6 -0
  22. package/dist/check-report.js +1 -1
  23. package/dist/claim.js +28 -13
  24. package/dist/cli-help.js +1 -1
  25. package/dist/cli.js +2 -0
  26. package/dist/codex-limits.js +21 -8
  27. package/dist/console-instance.js +11 -1
  28. package/dist/contracts/console-api.js +13 -7
  29. package/dist/contracts/engine-api.js +283 -0
  30. package/dist/contracts/route.js +1 -0
  31. package/dist/coordinator.js +2 -2
  32. package/dist/discord-api.js +4 -3
  33. package/dist/discord-chat.js +3 -1
  34. package/dist/dispatch.js +1 -1
  35. package/dist/dispose.js +15 -9
  36. package/dist/easy-start-args.js +7 -3
  37. package/dist/easy-start.js +40 -1
  38. package/dist/egress.js +72 -10
  39. package/dist/engine-handoff.js +34 -0
  40. package/dist/engine-reads.js +338 -0
  41. package/dist/eval-world.js +3 -2
  42. package/dist/evidence.js +2 -0
  43. package/dist/fast-start.js +68 -18
  44. package/dist/fast-terms.js +2 -2
  45. package/dist/first-run.js +10 -2
  46. package/dist/flexible-agents.js +234 -0
  47. package/dist/flexible-answers-schema.js +61 -0
  48. package/dist/flexible-answers.js +889 -0
  49. package/dist/flexible-custody.js +494 -0
  50. package/dist/flexible-import.js +782 -0
  51. package/dist/flexible-launch-schema.js +72 -0
  52. package/dist/flexible-launch.js +331 -0
  53. package/dist/flexible-launcher.js +88 -0
  54. package/dist/flexible-levels.js +34 -0
  55. package/dist/flexible-merge-guard.js +47 -0
  56. package/dist/flexible-refs.js +47 -0
  57. package/dist/flexible-relay-cancel.js +19 -0
  58. package/dist/flexible-relay-schema.js +55 -0
  59. package/dist/flexible-relay-upstreams.js +36 -0
  60. package/dist/flexible-relay.js +1032 -0
  61. package/dist/flexible-session.js +732 -0
  62. package/dist/flexible-ship-schema.js +81 -0
  63. package/dist/flexible-ship.js +694 -0
  64. package/dist/flexible-start.js +80 -0
  65. package/dist/flexible-thread.js +175 -25
  66. package/dist/flexible-turns-schema.js +69 -0
  67. package/dist/flexible-turns.js +490 -0
  68. package/dist/flexible.js +10 -1
  69. package/dist/flow-actions.js +6 -4
  70. package/dist/flow-steps.js +1 -1
  71. package/dist/flows-cli.js +2 -1
  72. package/dist/git-views.js +6 -3
  73. package/dist/install-mode.js +225 -0
  74. package/dist/integrations.js +6 -1
  75. package/dist/lead-doors.js +7 -1
  76. package/dist/limits-ui.js +7 -0
  77. package/dist/live-reply.js +6 -0
  78. package/dist/live-terminal.js +425 -29
  79. package/dist/local-owner.js +7 -0
  80. package/dist/model-choices.js +12 -6
  81. package/dist/needs-you.js +2 -0
  82. package/dist/notification-delivery.js +11 -0
  83. package/dist/operate.js +128 -37
  84. package/dist/outbound-privacy.js +204 -0
  85. package/dist/passwordless.js +2 -1
  86. package/dist/phase-routing.js +3 -1
  87. package/dist/plane-review.js +1 -1
  88. package/dist/project-delete.js +14 -0
  89. package/dist/proposal.js +2 -2
  90. package/dist/provider-connection.js +19 -5
  91. package/dist/publish.js +5 -0
  92. package/dist/pull-request-flow.js +26 -7
  93. package/dist/push.js +5 -1
  94. package/dist/release-card.js +11 -3
  95. package/dist/release.js +10 -1
  96. package/dist/route-store.js +3 -3
  97. package/dist/sandbox-launch.js +32 -8
  98. package/dist/sandbox-runtime.js +16 -7
  99. package/dist/sandbox-tools.js +176 -0
  100. package/dist/scope.js +12 -36
  101. package/dist/scout-net.js +7 -2
  102. package/dist/serve.js +62 -13
  103. package/dist/server/chrome.js +3 -1
  104. package/dist/server/console.css +33 -6
  105. package/dist/server/engine-api.js +378 -0
  106. package/dist/server/flows.js +2 -2
  107. package/dist/server/http.js +7 -0
  108. package/dist/server/link-redemption.js +52 -0
  109. package/dist/server/mutation-key.js +21 -7
  110. package/dist/server/pages.js +72 -40
  111. package/dist/server/people-tokens.js +17 -41
  112. package/dist/server/render-chat.js +1 -0
  113. package/dist/server/render-new-task.js +3 -3
  114. package/dist/server/render-results.js +4 -4
  115. package/dist/server/render-tasks.js +133 -139
  116. package/dist/server/route-table.js +32 -1
  117. package/dist/server/settings-section-table.js +6 -0
  118. package/dist/server/settings-sections.js +69 -0
  119. package/dist/server/settings.js +120 -10
  120. package/dist/server/task-views.js +8 -2
  121. package/dist/server/tasks.js +56 -12
  122. package/dist/server/terminals.js +181 -28
  123. package/dist/server/welcome.js +35 -10
  124. package/dist/settings-groups-ui.js +2 -2
  125. package/dist/settings-proofs.js +14 -9
  126. package/dist/slack-api.js +4 -3
  127. package/dist/slack-chat.js +5 -3
  128. package/dist/spend.js +46 -12
  129. package/dist/status-probe.js +343 -0
  130. package/dist/store.js +181 -12
  131. package/dist/task-sizing-schema.js +14 -0
  132. package/dist/task-sizing.js +76 -10
  133. package/dist/teams-api.js +4 -3
  134. package/dist/teams-chat.js +4 -2
  135. package/dist/telegram-lead.js +2 -1
  136. package/dist/telegram-live.js +2 -1
  137. package/dist/telegram-team.js +2 -1
  138. package/dist/telegram.js +17 -5
  139. package/dist/toolroll-update.js +3 -1
  140. package/dist/trusted-path.js +162 -0
  141. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  142. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  143. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  144. package/dist/tui/linux-x64/toolroll-tui +0 -0
  145. package/dist/tui-launch.js +282 -0
  146. package/dist/tui-source.js +5 -3
  147. package/dist/tui.js +1 -1
  148. package/dist/webhooks.js +14 -4
  149. package/dist/welcome-facts.js +22 -15
  150. package/dist/work-index.js +2 -2
  151. package/dist/workspace-ui.js +5 -0
  152. package/package.json +1 -1
  153. package/scripts/crash-canary.mjs +1 -1
  154. package/scripts/pilot.mjs +1 -1
  155. package/scripts/provider-canary.mjs +5 -3
@@ -0,0 +1,204 @@
1
+ import { scanForSecrets } from "./evidence.js";
2
+ const HOME_FOLDER = /(?:^|[\s"'`(<[=:,])(?:\/Users\/|\/home\/|\/root\/|~\/)/;
3
+ const DRIVE_OR_SHARE = /(?<![A-Za-z0-9+.-])[A-Za-z]:[\\/]|\\\\|\bfile:\/\//i;
4
+ export function privateWords(text) {
5
+ return scanForSecrets(text).length > 0 || /\b\d{5,}:[A-Za-z0-9_-]{20,}\b/.test(text) || HOME_FOLDER.test(text) || DRIVE_OR_SHARE.test(text);
6
+ }
7
+ export const outboundPrivate = (fields) => fields.some(privateWords);
8
+ export function textsOf(value, depth = 0) {
9
+ if (typeof value === "string")
10
+ return [value];
11
+ if (depth > 12 || value === null || typeof value !== "object")
12
+ return [];
13
+ return (Array.isArray(value) ? value : Object.values(value)).flatMap(one => textsOf(one, depth + 1));
14
+ }
15
+ const unescaped = (text) => text.replace(/\\([\\`*_{}[\]()#+\-.!|~>])/g, "$1");
16
+ export const privateValue = (value) => textsOf(value).some(text => privateWords(text) || privateWords(unescaped(text)));
17
+ export function projectName(repo) {
18
+ if (repo === null || repo === undefined)
19
+ return null;
20
+ const name = (repo.split(/[\\/]/).filter(Boolean).pop() ?? "").replace(/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2060-\u206f]/g, "").trim().slice(0, 48);
21
+ return name === "" || privateWords(name) || privateWords(` ${name}`) ? null : name;
22
+ }
23
+ export function taskSubject(store, task) {
24
+ if (task === null || task === undefined || task === "")
25
+ return { project: null };
26
+ return { project: store.lookupRef(task)?.repo ?? null, withheld: privateWords(store.getTask(task)?.title ?? "") };
27
+ }
28
+ export function safeWords(subject) {
29
+ const name = projectName(subject?.project);
30
+ return name === null ? "An update is ready. Open it in Toolroll." : `An update is ready in ${name}. Open it in Toolroll.`;
31
+ }
32
+ export function checkedChunks(whole, chunks, subject) {
33
+ return privateValue(whole) ? [safeWords(subject)] : [...chunks];
34
+ }
35
+ export const OPEN_IN_TOOLROLL = "Open in Toolroll";
36
+ export const WITHHELD = "Its words name a key or a folder on this computer, so it stays in Toolroll.";
37
+ export function safeLink(value) {
38
+ if (typeof value !== "string" || value.length > 2_000)
39
+ return null;
40
+ let url;
41
+ try {
42
+ url = new URL(value);
43
+ }
44
+ catch {
45
+ return null;
46
+ }
47
+ if ((url.protocol !== "https:" && url.protocol !== "http:") || url.username !== "" || url.password !== "")
48
+ return null;
49
+ let decoded;
50
+ try {
51
+ decoded = decodeURIComponent(`${url.pathname}${url.search}${url.hash}`);
52
+ }
53
+ catch {
54
+ return null;
55
+ }
56
+ if (privateWords(value) || privateWords(` ${decoded}`))
57
+ return null;
58
+ return /[|<>\s]/.test(url.href) ? null : url.href;
59
+ }
60
+ export function firstLink(value, depth = 0) {
61
+ if (depth > 12 || value === null || typeof value !== "object")
62
+ return null;
63
+ for (const [key, one] of Object.entries(value)) {
64
+ if (key === "url" && safeLink(one) !== null)
65
+ return safeLink(one);
66
+ const found = firstLink(one, depth + 1);
67
+ if (found !== null)
68
+ return found;
69
+ }
70
+ return null;
71
+ }
72
+ const pick = (from, keys) => Object.fromEntries(keys.filter(key => from[key] !== undefined).map(key => [key, from[key]]));
73
+ const goesSafe = (subject, message, ...values) => (message && subject?.withheld === true) || values.some(privateValue);
74
+ const checked = (made) => made === null || privateValue(made) ? null : made;
75
+ export function guardTelegram(transport, subject) {
76
+ return async (method, params, signal, upload, more) => {
77
+ const files = [upload, ...(more ?? [])].filter((one) => one !== undefined);
78
+ const privateFile = files.some(one => one.contentType === "text/plain" && privateWords(one.bytes.toString("utf8")));
79
+ if (!privateFile && !goesSafe(subject, TELEGRAM_MESSAGES.has(method), params))
80
+ return transport(method, params, signal, upload, more);
81
+ const safe = privateFile ? null : checked(safeTelegramCall(method, params, safeWords(subject)));
82
+ if (safe === null)
83
+ return { ok: false, description: WITHHELD };
84
+ return transport(method, safe, signal, upload, more);
85
+ };
86
+ }
87
+ const TELEGRAM_MESSAGES = new Set(["sendMessage", "editMessageText", "sendMessageDraft", "sendPhoto", "sendDocument", "editMessageCaption", "sendMediaGroup"]);
88
+ function safeTelegramCall(method, params, words) {
89
+ const link = firstLink(params["reply_markup"]);
90
+ const keyboard = link === null ? {} : { reply_markup: { inline_keyboard: [[{ text: OPEN_IN_TOOLROLL, url: link }]] } };
91
+ const where = pick(params, ["chat_id", "message_id", "inline_message_id", "message_thread_id", "reply_parameters", "draft_id", "disable_notification"]);
92
+ switch (method) {
93
+ case "sendMessage":
94
+ case "editMessageText":
95
+ case "sendMessageDraft":
96
+ return { ...where, text: words, link_preview_options: { is_disabled: true }, ...(method === "sendMessageDraft" ? {} : keyboard) };
97
+ case "sendPhoto":
98
+ case "sendDocument":
99
+ case "editMessageCaption":
100
+ return { ...pick(params, ["photo", "document"]), ...where, caption: words, ...keyboard };
101
+ case "sendMediaGroup": {
102
+ const media = Array.isArray(params["media"]) ? params["media"] : [];
103
+ return { ...where, media: media.map((one, index) => {
104
+ const item = one !== null && typeof one === "object" ? one : {};
105
+ return { ...pick(item, ["type", "media"]), ...(index === 0 ? { caption: words } : {}) };
106
+ }) };
107
+ }
108
+ case "answerCallbackQuery":
109
+ return { ...pick(params, ["callback_query_id"]), text: "Open it in Toolroll." };
110
+ default:
111
+ return null;
112
+ }
113
+ }
114
+ export function guardSlack(api, refuse, subject) {
115
+ return (async (method, args) => {
116
+ if (args === undefined || !goesSafe(subject, SLACK_MESSAGES.has(method), args))
117
+ return api(method, args);
118
+ const safe = checked(safeSlackCall(method, args, safeWords(subject)));
119
+ if (safe === null)
120
+ throw refuse();
121
+ return api(method, safe);
122
+ });
123
+ }
124
+ const SLACK_MESSAGES = new Set(["chat.postMessage", "chat.update", "chat.postEphemeral", "files.completeUploadExternal"]);
125
+ function safeSlackCall(method, args, words) {
126
+ const escaped = words.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
127
+ switch (method) {
128
+ case "chat.postMessage":
129
+ case "chat.update":
130
+ case "chat.postEphemeral": {
131
+ const link = firstLink(args["blocks"]) ?? firstLink(args["attachments"]);
132
+ const text = link === null ? escaped : `${escaped} <${link}|${OPEN_IN_TOOLROLL}>`;
133
+ return { ...pick(args, ["channel", "ts", "thread_ts", "user"]), text, blocks: [{ type: "section", text: { type: "mrkdwn", text, verbatim: true } }],
134
+ mrkdwn: true, parse: "none", link_names: false, unfurl_links: false, unfurl_media: false };
135
+ }
136
+ case "files.completeUploadExternal": {
137
+ const files = Array.isArray(args["files"]) ? args["files"] : [];
138
+ return { ...pick(args, ["channel_id", "thread_ts"]), initial_comment: words,
139
+ files: files.map(one => ({ id: one !== null && typeof one === "object" ? one["id"] : undefined, title: words })) };
140
+ }
141
+ default:
142
+ return null;
143
+ }
144
+ }
145
+ export function guardDiscord(api, refuse, subject) {
146
+ return (async (method, path, body, file) => {
147
+ if (!goesSafe(subject, body !== undefined && discordMessagePath(method, path) !== null, body, file?.name ?? ""))
148
+ return api(method, path, body, file);
149
+ const safe = file !== undefined && privateWords(file.name) ? null : checked(safeDiscordCall(method, path, body ?? {}, safeWords(subject)));
150
+ if (safe === null)
151
+ throw refuse();
152
+ return api(method, path, safe, file);
153
+ });
154
+ }
155
+ function discordMessage(body, words) {
156
+ const link = firstLink(body["components"]) ?? firstLink(body["embeds"]);
157
+ const attachments = Array.isArray(body["attachments"]) ? body["attachments"].map(one => one !== null && typeof one === "object" ? pick(one, ["id", "filename"]) : {}) : undefined;
158
+ return { content: words.replace(/[\\*_~`|>#[\]()-]/g, "\\$&"), embeds: [],
159
+ components: link === null ? [] : [{ type: 1, components: [{ type: 2, style: 5, label: OPEN_IN_TOOLROLL, url: link }] }],
160
+ allowed_mentions: { parse: [], replied_user: false }, ...pick(body, ["message_reference", "flags"]), ...(attachments === undefined ? {} : { attachments }) };
161
+ }
162
+ function discordMessagePath(method, path) {
163
+ if ((method === "POST" || method === "PATCH") && /^\/channels\/[0-9]+\/messages(?:\/[0-9]+)?$/.test(path))
164
+ return "message";
165
+ if (method === "POST" && /^\/interactions\/[0-9]+\/[A-Za-z0-9._-]+\/callback$/.test(path))
166
+ return "interaction";
167
+ return null;
168
+ }
169
+ function safeDiscordCall(method, path, body, words) {
170
+ const kind = discordMessagePath(method, path);
171
+ if (kind === "message")
172
+ return discordMessage(body, words);
173
+ if (kind === "interaction") {
174
+ const data = body["data"] !== null && typeof body["data"] === "object" ? body["data"] : {};
175
+ return { type: body["type"], data: discordMessage(data, words) };
176
+ }
177
+ return null;
178
+ }
179
+ export function guardTeams(api, refuse, subject) {
180
+ return (async (method, serviceUrl, path, body) => {
181
+ if (!goesSafe(subject, teamsMessage(method, path, body), body))
182
+ return api(method, serviceUrl, path, body);
183
+ const safe = checked(teamsMessage(method, path, body) ? safeTeamsActivity(body, safeWords(subject)) : null);
184
+ if (safe === null)
185
+ throw refuse();
186
+ return api(method, serviceUrl, path, safe);
187
+ });
188
+ }
189
+ const teamsMessage = (method, path, body) => method !== "GET" && /\/activities(?:\/[^/]+)?$/.test(path) && body?.["type"] === "message";
190
+ function safeTeamsActivity(body, words) {
191
+ const link = firstLink(body["attachments"]);
192
+ const where = pick(body, ["replyToId"]);
193
+ if (link === null)
194
+ return { type: "message", ...where, text: words, textFormat: "plain" };
195
+ return { type: "message", ...where, attachments: [{ contentType: "application/vnd.microsoft.card.adaptive",
196
+ content: { type: "AdaptiveCard", version: "1.4", $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
197
+ body: [{ type: "TextBlock", text: words, wrap: true }], actions: [{ type: "Action.OpenUrl", title: OPEN_IN_TOOLROLL, url: link }] } }] };
198
+ }
199
+ export function safeMail(mail, subject) {
200
+ if (!outboundPrivate([mail.subject, mail.text]))
201
+ return mail;
202
+ const name = projectName(subject?.project);
203
+ return { ...mail, subject: name === null ? "An update from Toolroll" : `An update from Toolroll in ${name}`, text: safeWords(subject) };
204
+ }
@@ -13,7 +13,8 @@ export function passwordlessSetting(store) {
13
13
  }
14
14
  export const passwordlessOn = (store) => passwordlessSetting(store).on;
15
15
  export function setPasswordless(store, on, by, now) {
16
- if (passwordlessOn(store) === on)
16
+ const setting = passwordlessSetting(store);
17
+ if (setting.on === on && (on || setting.at !== null))
17
18
  return { changed: false };
18
19
  store.recordAction({ at: now.toISOString(), actor: by, repo: null, taskId: null, runId: null, action: PASSWORDLESS_ACTION, outcome: on ? "on" : "off", source: "policy",
19
20
  detail: on ? "Passwordless on: signing in is the only password" : "Passwordless off: step-ups ask for the password again" });
@@ -23,6 +23,8 @@ export const TASK_SIZES = TASK_SIZE_WORDS;
23
23
  export function isTaskSize(value) {
24
24
  return value === "small" || value === "medium" || value === "large";
25
25
  }
26
+ export const SIZING_OFF_REASON = "task sizing is off";
27
+ export const PLANNED_FIRST_REASON = `${SIZING_OFF_REASON}; planned first`;
26
28
  export function makesNoPlan(size, risk) {
27
29
  return size != null && size.size === "small" && !size.risky && risk === "routine";
28
30
  }
@@ -468,7 +470,7 @@ export function canonicalRouteJson(route) {
468
470
  ...(route.version === 3 && leg.selection !== undefined ? { selection: leg.selection } : {}),
469
471
  })),
470
472
  overrides: route.overrides.map(one => ({ phase: one.phase, provider: one.provider, model: one.model, by: one.by, at: one.at })),
471
- ...(route.version === 1 ? {} : { size: route.size === null ? null : { size: route.size.size, risky: route.size.risky, source: route.size.source, reason: route.size.reason } }),
473
+ ...(route.version === 1 ? {} : { size: route.size === null ? null : { size: route.size.size, risky: route.size.risky, source: route.size.source, reason: route.size.reason, ...(route.size.by === undefined ? {} : { by: route.size.by }) } }),
472
474
  });
473
475
  }
474
476
  export function routeDigestOf(route) {
@@ -27,7 +27,7 @@ export function excerpt(text, cap = 160) {
27
27
  return "[hidden: it looked like it held a key or password]";
28
28
  return clean.length > cap ? `${clean.slice(0, cap - 1).trimEnd()}…` : clean;
29
29
  }
30
- const PROVIDER_REASONS = new Set(["retryable-infra", "provider-init", "provider-protocol", "provider-unattested", "setup"]);
30
+ const PROVIDER_REASONS = new Set(["retryable-infra", "agent-error", "provider-init", "provider-protocol", "provider-unattested", "setup"]);
31
31
  const TIMEOUT_WORDS = /made no observable progress|ran past \d+ minutes|timed out/i;
32
32
  export function runCause(run) {
33
33
  const reason = run.reason ?? "";
@@ -71,6 +71,9 @@ export function projectRunning(store, repo, now) {
71
71
  const merges = count(`SELECT COUNT(*) AS n FROM merge_intent WHERE state IN ('claimed','firing') AND publication IN (SELECT id FROM publication WHERE task_ref IN (SELECT value FROM json_each(?)))`, json(d.refs))
72
72
  + count("SELECT COUNT(*) AS n FROM merge_in_flight WHERE at > ? AND task_ref IN (SELECT value FROM json_each(?))", new Date(now.getTime() - 15 * 60_000).toISOString(), json(d.refs));
73
73
  const checkouts = count("SELECT COUNT(*) AS n FROM worktree WHERE repo = ? AND runner IS NOT NULL AND released_at IS NULL", repo);
74
+ const threads = tableExists(db, "flexible_thread") ? count("SELECT COUNT(*) AS n FROM flexible_thread WHERE repo = ? AND state IN ('preparing', 'ready', 'removing')", repo) : 0;
75
+ const agents = tableExists(db, "flexible_thread_launch")
76
+ ? count("SELECT COUNT(*) AS n FROM flexible_thread_launch WHERE state <> 'exited' AND thread IN (SELECT id FROM flexible_thread WHERE repo = ?)", repo) : 0;
74
77
  return [
75
78
  ...(building > 0 ? [`${plural(building, "task")} ${building === 1 ? "is" : "are"} being built`] : []),
76
79
  ...(slots > 0 ? ["an agent is working"] : []),
@@ -79,6 +82,8 @@ export function projectRunning(store, repo, now) {
79
82
  ...(calls > 0 ? ["a subagent is working"] : []),
80
83
  ...(merges > 0 ? ["a merge is in progress"] : []),
81
84
  ...(checkouts > 0 && building === 0 ? [`${plural(checkouts, "checkout")} ${checkouts === 1 ? "is" : "are"} in use`] : []),
85
+ ...(agents > 0 ? ["a Flexible thread's agent is still running"] : []),
86
+ ...(threads > 0 ? [`${plural(threads, "Flexible thread")} ${threads === 1 ? "is" : "are"} still open (remove ${threads === 1 ? "it" : "them"} first)`] : []),
82
87
  ];
83
88
  }
84
89
  const inside = (root, path) => { const rel = relative(resolve(root), resolve(path)); return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel); };
@@ -294,6 +299,15 @@ function deleteRows(store, repo, d, now) {
294
299
  for (const table of ["knowledge_change", "project_identity_carry", "project_skill_change", "memory_gap", "memory_proposal", "memory_rejection", "memory_session", "memory_search", "mode_rail", "side_spend", "watch_episode", "worktree", "coordinator_proposal", "lead_commitment"])
295
300
  del(table, "repo = ?", repo);
296
301
  del("watch_lease", "repo = ? AND expires_at <= ?", repo, now.toISOString());
302
+ const flexibleThreads = `thread IN (SELECT id FROM flexible_thread WHERE repo = ? AND state IN ('removed', 'failed'))`;
303
+ del("thread_decision", flexibleThreads, repo);
304
+ del("thread_relay_call", flexibleThreads, repo);
305
+ del("thread_relay_pending", flexibleThreads, repo);
306
+ del("flexible_relay_grant", flexibleThreads, repo);
307
+ del("thread_turn", flexibleThreads, repo);
308
+ del("flexible_thread_launch", flexibleThreads, repo);
309
+ del("flexible_thread_level", flexibleThreads, repo);
310
+ del("flexible_thread", "repo = ? AND state IN ('removed', 'failed')", repo);
297
311
  del("project", "path = ?", repo);
298
312
  return rows;
299
313
  }
package/dist/proposal.js CHANGED
@@ -2,7 +2,7 @@ import { validateTaskText } from "./task-text.js";
2
2
  export { validateTaskText } from "./task-text.js";
3
3
  import { resolve } from "node:path";
4
4
  import { canonicalProject } from "./project.js";
5
- import { heuristicSizing, planningSignals, refineFiledSizing } from "./task-sizing.js";
5
+ import { filingSizing, planningSignals, refineFiledSizing } from "./task-sizing.js";
6
6
  import { FolderUnavailable } from "./folder-gate.js";
7
7
  const FILED_VIA = /^[a-z][a-z0-9:-]{0,63}$/;
8
8
  export function shouldPlanTask(input, sizing) {
@@ -53,7 +53,7 @@ export function fileTaskProposal(store, input, now) {
53
53
  const badText = validateTaskText(input);
54
54
  if (badText !== null)
55
55
  return badText;
56
- const sizing = input.sizing ?? heuristicSizing(input);
56
+ const sizing = input.sizing ?? filingSizing(store, input);
57
57
  const outOfScope = input.outOfScope ?? null;
58
58
  const touches = input.touches ?? [];
59
59
  const repo = checkRepo(input.repo, input.admittedRepos);
@@ -1,8 +1,11 @@
1
1
  import { homedir } from "node:os";
2
- import { run } from "./exec.js";
2
+ import {} from "./exec.js";
3
+ import { statusProbe } from "./status-probe.js";
3
4
  import { ALL_CREDENTIAL_ENV, inspectionOf } from "./provider.js";
4
5
  import { isAcpProvider } from "./acp-agents.js";
5
6
  import { keyStatus, PROVIDER_KEY_ENV, readAuthMode, readProviderKey, verifyProviderKey } from "./keys.js";
7
+ export const SIGNED_OUT_RECHECK_MS = 10 * 60_000;
8
+ const ANSWER_MS = 30_000;
6
9
  export function signInFacts(provider, result, now = new Date()) {
7
10
  const base = { mode: "subscription", checkedAt: now.toISOString() };
8
11
  if (result.notFound)
@@ -39,11 +42,13 @@ export function signInFacts(provider, result, now = new Date()) {
39
42
  return { ...base, state: "unverified" };
40
43
  }
41
44
  export function createConnectionChecker(options = {}) {
42
- const probe = options.probe ?? run;
43
- const verify = options.verify ?? ((provider, key) => verifyProviderKey(provider, key));
44
45
  const home = options.home ?? homedir();
46
+ const probe = options.probe ?? statusProbe({ ...(options.env === undefined ? {} : { env: options.env }), ...(options.store === undefined ? {} : { store: options.store }),
47
+ ...(options.databaseFile === undefined ? {} : { databaseFile: options.databaseFile }) });
48
+ const verify = options.verify ?? ((provider, key) => verifyProviderKey(provider, key));
45
49
  const clock = options.clock ?? (() => new Date());
46
50
  const cache = new Map();
51
+ const absentStreak = new Map();
47
52
  const pending = new Map();
48
53
  return async (provider, fresh = false) => {
49
54
  if (isAcpProvider(provider))
@@ -84,8 +89,16 @@ export function createConnectionChecker(options = {}) {
84
89
  const value = await check;
85
90
  const currentKeyFacts = keyStatus(provider, home);
86
91
  const currentKey = JSON.stringify([provider, readAuthMode(provider, home), currentKeyFacts.set, currentKeyFacts.updatedAt, !!(options.env ?? process.env)[PROVIDER_KEY_ENV[provider]]]);
87
- if (currentKey === key)
88
- cache.set(provider, { key, until: value.verdict !== undefined ? Number.POSITIVE_INFINITY : clock().getTime() + 30_000, value });
92
+ if (currentKey === key) {
93
+ const before = absentStreak.get(provider);
94
+ const absent = value.state === "signed-out" || value.state === "not-installed";
95
+ const count = absent ? (before?.state === value.state ? before.count + 1 : 1) : 0;
96
+ if (absent)
97
+ absentStreak.set(provider, { state: value.state, count });
98
+ else
99
+ absentStreak.delete(provider);
100
+ cache.set(provider, { key, until: value.verdict !== undefined ? Number.POSITIVE_INFINITY : clock().getTime() + answerStandsMs(value.state, count), value });
101
+ }
89
102
  return value;
90
103
  }
91
104
  finally {
@@ -93,3 +106,4 @@ export function createConnectionChecker(options = {}) {
93
106
  }
94
107
  };
95
108
  }
109
+ export const answerStandsMs = (state, inARow) => state === "signed-out" || state === "not-installed" ? Math.min(ANSWER_MS * 4 ** Math.max(0, inARow - 1), SIGNED_OUT_RECHECK_MS) : ANSWER_MS;
package/dist/publish.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { flexibleMergeRefusal } from "./flexible-merge-guard.js";
1
2
  import { createHash } from "node:crypto";
2
3
  import { protectedPublicationHold } from "./result-completion.js";
3
4
  import { fastPublishProblem } from "./fast-start.js";
@@ -427,6 +428,10 @@ export async function sweepMerges(store, options) {
427
428
  continue;
428
429
  if (publication.githubRepo !== grant.githubRepo)
429
430
  continue;
431
+ if (flexibleMergeRefusal(store, ref.externalId, "publish-sweep") !== null) {
432
+ report.skipped++;
433
+ continue;
434
+ }
430
435
  const blocker = store.mergeBlockerFor(publication.id);
431
436
  if (blocker !== null) {
432
437
  report.skipped++;
@@ -1,6 +1,7 @@
1
1
  import { fastPublishProblem } from "./fast-start.js";
2
2
  import { createHash, randomUUID } from "node:crypto";
3
3
  import { run as execRun } from "./exec.js";
4
+ import { flexibleMergeRefusal } from "./flexible-merge-guard.js";
4
5
  import { bodyHashOf, publicationBody, publicationGrantOf } from "./publish.js";
5
6
  import { failingChecks, summarizeChecks } from "./pulls.js";
6
7
  import { assignmentOf, checkAssignmentAsOperator } from "./assignment.js";
@@ -254,6 +255,8 @@ export async function followPullRequests(store, seen, options) {
254
255
  const taskId = taskIdOf(store, publication);
255
256
  if (refArchived(store, publication.taskRef))
256
257
  continue;
258
+ if (flexibleMergeRefusal(store, taskId, "merge-when-green") !== null)
259
+ continue;
257
260
  if (one.remoteState === "MERGED") {
258
261
  updateFollow(store, publication.id, { merge_commit: one.mergeCommit ?? "", merged_by: "GitHub", merged_at: clock().toISOString() }, clock());
259
262
  continue;
@@ -363,6 +366,10 @@ export async function mergePullRequest(store, input) {
363
366
  return refuse("release", "This result belongs to a release; it merges only through `toolroll release`.");
364
367
  if (mergedTask !== null && autoReleaseSealed(store, mergedTask))
365
368
  return refuse("release", "This result was approved automatically for a release; it merges only through `toolroll release`.");
369
+ const flexibleAuthority = { ...(input.flexibleShip === undefined ? {} : { ship: input.flexibleShip }), ...(input.flexibleToken === undefined ? {} : { token: input.flexibleToken }), ...(input.anyway === true ? { anyway: true } : {}) };
370
+ const flexibleHold = flexibleMergeRefusal(store, mergedTask, "pull-request", flexibleAuthority);
371
+ if (flexibleHold !== null)
372
+ return refuse("flexible", flexibleHold);
366
373
  const fastHold = mergedTask === null ? null : fastPublishProblem(store, mergedTask, input.runId);
367
374
  if (fastHold !== null)
368
375
  return refuse("fast-start", fastHold);
@@ -370,7 +377,9 @@ export async function mergePullRequest(store, input) {
370
377
  const follow = publication === null ? null : followOf(store, publication.id);
371
378
  if (publication === null || follow === null || publication.prNumber === null)
372
379
  return refuse("no-pr", "This result has no open pull request to merge.");
373
- if (follow.mergeCommit !== null)
380
+ if (input.flexibleShip !== undefined && input.destination === undefined)
381
+ return refuse("flexible", "A Flexible merge must say where it may land.");
382
+ if (follow.mergeCommit !== null && input.destination === undefined)
374
383
  return { ok: true, commit: follow.mergeCommit || null };
375
384
  const ref = store.refById(publication.taskRef);
376
385
  const grant = ref?.repo == null ? null : store.publicationGrantFor(ref.repo);
@@ -379,13 +388,14 @@ export async function mergePullRequest(store, input) {
379
388
  const method = input.method ?? grant.mergeMethod ?? "squash";
380
389
  const pr = String(publication.prNumber);
381
390
  const view = async () => {
382
- const viewed = await exec("gh", ["pr", "view", pr, "--repo", publication.githubRepo, "--json", "state,isDraft,headRefOid,statusCheckRollup,mergeCommit"], { timeoutMs: EXEC_TIMEOUT_MS });
391
+ const viewed = await exec("gh", ["pr", "view", pr, "--repo", publication.githubRepo, "--json", "state,isDraft,headRefOid,statusCheckRollup,mergeCommit,baseRefName,url"], { timeoutMs: EXEC_TIMEOUT_MS });
383
392
  if (viewed.code !== 0)
384
393
  return null;
385
394
  try {
386
395
  const payload = JSON.parse(viewed.stdout);
387
396
  return { state: String(payload.state ?? "").toUpperCase(), draft: payload.isDraft === true, head: typeof payload.headRefOid === "string" ? payload.headRefOid : null,
388
- checks: summarizeChecks(payload.statusCheckRollup), commit: typeof payload.mergeCommit?.oid === "string" ? payload.mergeCommit.oid : null };
397
+ checks: summarizeChecks(payload.statusCheckRollup), commit: typeof payload.mergeCommit?.oid === "string" ? payload.mergeCommit.oid : null,
398
+ base: typeof payload.baseRefName === "string" ? payload.baseRefName : null, url: typeof payload.url === "string" ? payload.url : null };
389
399
  }
390
400
  catch {
391
401
  return null;
@@ -418,8 +428,12 @@ export async function mergePullRequest(store, input) {
418
428
  if (before === null)
419
429
  return fail("unread", "GitHub couldn't be read just now. Try again.");
420
430
  if (before.state === "MERGED") {
421
- record(before.commit, input.by);
422
- return { ok: true, commit: before.commit };
431
+ const landed = input.destination?.({ base: before.base, url: before.url, head: before.head }) ?? null;
432
+ if (landed !== null)
433
+ return refuse("elsewhere", landed);
434
+ if (follow.mergeCommit === null)
435
+ record(before.commit, input.by);
436
+ return { ok: true, commit: before.commit, ...(input.destination === undefined ? {} : { seen: { base: before.base, url: before.url, head: before.head } }) };
423
437
  }
424
438
  if (before.state !== "OPEN")
425
439
  return fail("closed", "This pull request is closed on GitHub.");
@@ -431,7 +445,9 @@ export async function mergePullRequest(store, input) {
431
445
  return fail("checks", before.checks === "failing" ? "Checks are failing, so it can't merge." : before.checks === "running" ? "Checks are still running. Merge once they pass." : "No checks have reported yet. Merge once they pass.");
432
446
  const token = randomUUID();
433
447
  const reserved = store.transact(() => {
434
- if (input.proceed?.() === false)
448
+ if (input.proceed?.({ base: before.base, url: before.url, head: before.head }) === false)
449
+ return "halted";
450
+ if (flexibleMergeRefusal(store, mergedTask, "pull-request", flexibleAuthority, "reserve") !== null)
435
451
  return "halted";
436
452
  if (refArchived(store, publication.taskRef))
437
453
  return "archived";
@@ -459,8 +475,11 @@ export async function mergePullRequest(store, input) {
459
475
  store.handle.prepare("DELETE FROM merge_in_flight WHERE publication = ? AND token = ?").run(publication.id, token);
460
476
  }
461
477
  if (after?.state === "MERGED") {
478
+ const landed = input.destination?.({ base: after.base, url: after.url, head: after.head }) ?? null;
479
+ if (landed !== null)
480
+ return refuse("elsewhere", landed);
462
481
  record(after.commit, input.by);
463
- return { ok: true, commit: after.commit };
482
+ return { ok: true, commit: after.commit, ...(input.destination === undefined ? {} : { seen: { base: after.base, url: after.url, head: after.head } }) };
464
483
  }
465
484
  if (merged.code === 4)
466
485
  return fail("gh-signed-out", "The GitHub CLI isn't signed in on this computer. Run gh auth login, then merge again.");
package/dist/push.js CHANGED
@@ -3,6 +3,7 @@ import { join } from "node:path";
3
3
  import { createCipheriv, createECDH, createPrivateKey, hkdfSync, randomBytes, createHash, sign as cryptoSign } from "node:crypto";
4
4
  import { isCheckProgressLine } from "./check-progress.js";
5
5
  import { RELEASE_PUSH_WORDS, releasePushOf, releaseReadyObsolete } from "./release-approval.js";
6
+ import { privateValue } from "./outbound-privacy.js";
6
7
  export const VAPID_FILE = "vapid-keys.json";
7
8
  const RECORD_SIZE = 4096;
8
9
  export const PLAINTEXT_CEILING = 3993;
@@ -190,8 +191,11 @@ export function pushLineOf(notification) {
190
191
  }
191
192
  return { body: PUSH_WORDS[pushClass].body, url: safePushLink(pushClass, notification.link) };
192
193
  }
194
+ export function privacySafeLine(line, pushClass) {
195
+ return privateValue(line) ? { body: PUSH_WORDS[pushClass].body, url: CLASS_FALLBACK[pushClass] } : line;
196
+ }
193
197
  export function buildPushPayload(notification, waiting = null, release = null) {
194
- const line = release !== null ? { body: PUSH_WORDS.release.body, url: safePushLink("release", release.link) } : pushLineOf(notification);
198
+ const line = privacySafeLine(release !== null ? { body: PUSH_WORDS.release.body, url: safePushLink("release", release.link) } : pushLineOf(notification), release !== null ? "release" : notification.pushClass ?? "attention");
195
199
  return JSON.stringify({
196
200
  title: "Toolroll",
197
201
  body: line.body,
@@ -93,11 +93,18 @@ const valueAt = (terms, path) => path.split(".").reduce((at, key) => at !== null
93
93
  export function approvalTermsOf(store, scope, words) {
94
94
  const ref = store.lookupRef(scope.taskId);
95
95
  const repo = ref?.repo ?? null;
96
+ const where = (path) => {
97
+ if (words.chat !== true)
98
+ return text(path);
99
+ const remote = store.projectRemote(path);
100
+ const slug = remote === null ? null : releaseRemote(remote)?.slug ?? null;
101
+ return slug ?? text(projectName(path));
102
+ };
96
103
  const filer = store.taskFiler(scope.taskId);
97
104
  const profile = scope.profile ?? null;
98
105
  const scopeValues = {
99
106
  title: said(store.getTask(scope.taskId)?.title),
100
- project: repo === null ? NONE : `${text(projectName(repo))} (${text(repo)})`,
107
+ project: repo === null ? NONE : `${text(projectName(repo))} (${where(repo)})`,
101
108
  filedBy: filer === null ? NONE : filer.name === null ? filer.kind : `${text(filer.name)}${filer.kind === "person" ? "" : ` (${filer.kind})`}`,
102
109
  goal: said(scope.goal),
103
110
  outOfScope: said(scope.outOfScope),
@@ -127,7 +134,7 @@ export function approvalTermsOf(store, scope, words) {
127
134
  if (terms === null && scope.releaseCheck != null) {
128
135
  const purpose = scope.releaseCheck;
129
136
  for (const path of schemaLeaves(releaseCheckPurposeSchema)) {
130
- const value = path === "pr" ? `#${purpose.pr}` : path === "purpose" ? "a release check: every later commit asks again" : said(valueAt(purpose, path));
137
+ const value = path === "pr" ? `#${purpose.pr}` : path === "purpose" ? "a release check: every later commit asks again" : path === "repo" ? where(purpose.repo) : said(valueAt(purpose, path));
131
138
  lines.push({ key: `releaseCheck.${path}`, label: RELEASE_CHECK_LABELS[path] ?? path, value });
132
139
  }
133
140
  return lines;
@@ -136,7 +143,8 @@ export function approvalTermsOf(store, scope, words) {
136
143
  const label = RELEASE_TERM_LABELS[path] ?? path;
137
144
  const value = terms === null ? NONE : path === "pr" ? `#${terms.pr}`
138
145
  : path === "policy.protectedPaths" && terms.policy.protectProject ? `the whole project (listed: ${said(terms.policy.protectedPaths)})`
139
- : path === "policy.unsandboxedCarry" && terms.policy.unsandboxedCarry === undefined ? "no (not set when sealed)" : said(valueAt(terms, path));
146
+ : path === "policy.unsandboxedCarry" && terms.policy.unsandboxedCarry === undefined ? "no (not set when sealed)"
147
+ : path === "repo" ? where(terms.repo) : said(valueAt(terms, path));
140
148
  lines.push({ key: `release.${path}`, label, value });
141
149
  }
142
150
  return lines;
package/dist/release.js CHANGED
@@ -37,8 +37,17 @@ export const ADVISORY_PR_CHECKS = {
37
37
  "install smoke · ubuntu-24.04": ".github/workflows/install-smoke.yml",
38
38
  "install smoke · macos-latest": ".github/workflows/install-smoke.yml",
39
39
  "wire budgets": ".github/workflows/wire-budgets.yml",
40
+ "rust · ubuntu-latest": ".github/workflows/rust.yml",
41
+ "rust · macos-latest": ".github/workflows/rust.yml",
42
+ "workbench bundle · ubuntu-24.04": ".github/workflows/tui-bundle.yml",
43
+ "workbench bundle · macos-latest": ".github/workflows/tui-bundle.yml",
44
+ "workbench bundle / binary · darwin-arm64": ".github/workflows/tui-bundle.yml",
45
+ "workbench bundle / binary · darwin-x64": ".github/workflows/tui-bundle.yml",
46
+ "workbench bundle / binary · linux-x64": ".github/workflows/tui-bundle.yml",
47
+ "workbench bundle / binary · linux-arm64": ".github/workflows/tui-bundle.yml",
48
+ "workbench bundle / assemble": ".github/workflows/tui-bundle.yml",
40
49
  };
41
- export const RELEASE_TAG_CHECKS = ["release proof", "publish"];
50
+ export const RELEASE_TAG_CHECKS = ["release proof", "package / binary · darwin-arm64", "package / binary · darwin-x64", "package / binary · linux-x64", "package / binary · linux-arm64", "package / assemble", "publish"];
42
51
  export const RELEASE_TAG_WORKFLOW = ".github/workflows/publish.yml";
43
52
  export const RELEASE_STEPS = ["gate", "approval", "check", "complete", "quiet", "deploy", "link", "ci", "merge", "tree", "tag", "publish", "homebrew", "done"];
44
53
  export const RELEASE_LIMITS = { gate: 60, approval: 24 * 60, check: 360, quiet: 60, deploy: 30, ci: 60, publish: 45, homebrew: 45 };
@@ -1,14 +1,14 @@
1
1
  import { isProtectedWork } from "./approval-policy.js";
2
2
  import { trialSealStandsSql } from "./approval-authority.js";
3
3
  import { currentLocalOwner, localOwnerInFlight, localOwnerStandsNow } from "./local-owner.js";
4
- import { passwordlessOn } from "./passwordless.js";
4
+ import { sessionStandsIn } from "./install-mode.js";
5
5
  import { machineActing } from "./scope.js";
6
6
  import { NOT_COUNTED_REASONS, RECORD_STATES, REJECT_REASONS, REVISION_ORIGINS } from "./contracts/route-results.js";
7
7
  import { BUILT_IN, nightlyTaskRef, releaseTaskRef } from "./store.js";
8
8
  export const EXEC_CLASS_OF_REASON = Object.freeze({
9
9
  timeout: "model", agent: "model", "agent-reported": "model", "no-op": "model", "no-handoff": "model",
10
10
  "moved-head": "model", "moved-branch": "model", "commit-failure": "model",
11
- git: "infrastructure", setup: "infrastructure", "provider-init": "infrastructure", "provider-unattested": "infrastructure",
11
+ git: "infrastructure", setup: "infrastructure", "provider-init": "infrastructure", "agent-error": "model", "provider-unattested": "infrastructure",
12
12
  "provider-protocol": "infrastructure", stopped: "infrastructure",
13
13
  });
14
14
  export const INFRASTRUCTURE_TERMINALS = new Set(["auth-expired", "usage-exhausted", "credits-depleted", "transient-throttle"]);
@@ -209,7 +209,7 @@ export function proveRuleDoor(store, door, act, repo) {
209
209
  return { ok: false, reason: "lead-refused" };
210
210
  const account = store.accountOf(person.actor);
211
211
  const proof = spec.raising
212
- ? RAISING_PROOFS.has(person.method) && ((person.method !== "session" && person.method !== "cli-login") || passwordlessOn(store))
212
+ ? RAISING_PROOFS.has(person.method) && ((person.method !== "session" && person.method !== "cli-login") || sessionStandsIn(store))
213
213
  : RAISING_PROOFS.has(person.method) || person.method === "local-owner";
214
214
  if (account === null || account.revokedAt !== null || account.generation !== person.generation || !store.isInstanceOperator(person.actor)
215
215
  || !store.accountCanAccess(person.actor, repo) || !person.live() || !proof)