toolroll 0.9.109 → 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.
Files changed (135) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/agent-detect.js +244 -0
  3. package/dist/agent-fence.js +12 -1
  4. package/dist/agentconfig.js +2 -2
  5. package/dist/approval-summary.js +344 -0
  6. package/dist/attest.js +2 -2
  7. package/dist/browser/workspace.css +2 -2
  8. package/dist/browser/workspace.js +27 -27
  9. package/dist/builder.js +36 -2
  10. package/dist/chat-actions.js +24 -17
  11. package/dist/chat-core.js +3 -1
  12. package/dist/chat-decide.js +101 -46
  13. package/dist/chat-delivery-state.js +2 -0
  14. package/dist/chat-delivery.js +3 -2
  15. package/dist/chat-live.js +2 -1
  16. package/dist/chat-task-actions.js +6 -0
  17. package/dist/check-report.js +1 -1
  18. package/dist/cli.js +2 -0
  19. package/dist/console-instance.js +10 -1
  20. package/dist/contracts/console-api.js +10 -5
  21. package/dist/contracts/engine-api.js +271 -0
  22. package/dist/coordinator.js +2 -2
  23. package/dist/discord-api.js +4 -3
  24. package/dist/discord-chat.js +3 -1
  25. package/dist/easy-start-args.js +7 -3
  26. package/dist/easy-start.js +25 -0
  27. package/dist/egress.js +72 -10
  28. package/dist/engine-handoff.js +34 -0
  29. package/dist/engine-reads.js +261 -0
  30. package/dist/eval-world.js +3 -2
  31. package/dist/evidence.js +2 -0
  32. package/dist/fast-start.js +55 -14
  33. package/dist/fast-terms.js +2 -2
  34. package/dist/first-run.js +10 -2
  35. package/dist/flexible-agents.js +234 -0
  36. package/dist/flexible-answers-schema.js +61 -0
  37. package/dist/flexible-answers.js +889 -0
  38. package/dist/flexible-custody.js +494 -0
  39. package/dist/flexible-import.js +782 -0
  40. package/dist/flexible-launch-schema.js +72 -0
  41. package/dist/flexible-launch.js +331 -0
  42. package/dist/flexible-launcher.js +88 -0
  43. package/dist/flexible-levels.js +34 -0
  44. package/dist/flexible-merge-guard.js +47 -0
  45. package/dist/flexible-refs.js +47 -0
  46. package/dist/flexible-relay-cancel.js +19 -0
  47. package/dist/flexible-relay-schema.js +55 -0
  48. package/dist/flexible-relay-upstreams.js +36 -0
  49. package/dist/flexible-relay.js +1032 -0
  50. package/dist/flexible-session.js +732 -0
  51. package/dist/flexible-ship-schema.js +81 -0
  52. package/dist/flexible-ship.js +694 -0
  53. package/dist/flexible-start.js +80 -0
  54. package/dist/flexible-thread.js +175 -25
  55. package/dist/flexible-turns-schema.js +69 -0
  56. package/dist/flexible-turns.js +490 -0
  57. package/dist/flexible.js +10 -1
  58. package/dist/flow-actions.js +6 -4
  59. package/dist/flow-steps.js +1 -1
  60. package/dist/flows-cli.js +2 -1
  61. package/dist/git-views.js +6 -3
  62. package/dist/install-mode.js +225 -0
  63. package/dist/lead-doors.js +7 -1
  64. package/dist/limits-ui.js +7 -0
  65. package/dist/live-reply.js +6 -0
  66. package/dist/live-terminal.js +425 -29
  67. package/dist/local-owner.js +6 -0
  68. package/dist/model-choices.js +12 -6
  69. package/dist/notification-delivery.js +11 -0
  70. package/dist/operate.js +74 -30
  71. package/dist/outbound-privacy.js +204 -0
  72. package/dist/passwordless.js +2 -1
  73. package/dist/project-delete.js +14 -0
  74. package/dist/provider-connection.js +5 -3
  75. package/dist/publish.js +5 -0
  76. package/dist/pull-request-flow.js +26 -7
  77. package/dist/push.js +5 -1
  78. package/dist/release-card.js +11 -3
  79. package/dist/release.js +10 -1
  80. package/dist/route-store.js +2 -2
  81. package/dist/sandbox-launch.js +32 -8
  82. package/dist/sandbox-runtime.js +16 -7
  83. package/dist/sandbox-tools.js +176 -0
  84. package/dist/scope.js +12 -36
  85. package/dist/scout-net.js +7 -2
  86. package/dist/serve.js +58 -11
  87. package/dist/server/chrome.js +3 -1
  88. package/dist/server/console.css +33 -6
  89. package/dist/server/engine-api.js +378 -0
  90. package/dist/server/flows.js +2 -2
  91. package/dist/server/http.js +7 -0
  92. package/dist/server/link-redemption.js +52 -0
  93. package/dist/server/mutation-key.js +21 -7
  94. package/dist/server/pages.js +69 -40
  95. package/dist/server/people-tokens.js +17 -41
  96. package/dist/server/render-chat.js +1 -0
  97. package/dist/server/render-new-task.js +3 -3
  98. package/dist/server/render-results.js +4 -4
  99. package/dist/server/render-tasks.js +129 -138
  100. package/dist/server/route-table.js +30 -1
  101. package/dist/server/settings-section-table.js +3 -0
  102. package/dist/server/settings-sections.js +33 -0
  103. package/dist/server/settings.js +84 -10
  104. package/dist/server/task-views.js +8 -2
  105. package/dist/server/tasks.js +25 -8
  106. package/dist/server/terminals.js +181 -28
  107. package/dist/server/welcome.js +35 -10
  108. package/dist/settings-groups-ui.js +2 -2
  109. package/dist/settings-proofs.js +13 -9
  110. package/dist/slack-api.js +4 -3
  111. package/dist/slack-chat.js +5 -3
  112. package/dist/spend.js +46 -12
  113. package/dist/status-probe.js +343 -0
  114. package/dist/store.js +102 -5
  115. package/dist/teams-api.js +4 -3
  116. package/dist/teams-chat.js +4 -2
  117. package/dist/telegram-lead.js +2 -1
  118. package/dist/telegram-live.js +2 -1
  119. package/dist/telegram-team.js +2 -1
  120. package/dist/telegram.js +17 -5
  121. package/dist/trusted-path.js +162 -0
  122. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  123. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  124. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  125. package/dist/tui/linux-x64/toolroll-tui +0 -0
  126. package/dist/tui-launch.js +282 -0
  127. package/dist/tui-source.js +5 -3
  128. package/dist/tui.js +1 -1
  129. package/dist/webhooks.js +8 -4
  130. package/dist/welcome-facts.js +22 -15
  131. package/dist/workspace-ui.js +5 -0
  132. package/package.json +1 -1
  133. package/scripts/crash-canary.mjs +1 -1
  134. package/scripts/pilot.mjs +1 -1
  135. package/scripts/provider-canary.mjs +5 -3
@@ -0,0 +1,225 @@
1
+ import { PASSWORDLESS_ACTION } from "./passwordless.js";
2
+ const LIVE_FACTS = new Set(["unreadable", "invite-open", "second-person", "token-for-someone-else", "chat-person", "chat-group"]);
3
+ const WHYS = new Set(["new-install", "just-me", "upgrade"]);
4
+ export const INSTALL_MODE_ACTION = "install mode";
5
+ const COUNT_KEYS = ["people", "tokens", "chat", "groups", "invites"];
6
+ const CHAT_IDENTITIES = "SELECT DISTINCT provider, installation, team, member FROM chat_binding";
7
+ const ACTIVE_PEOPLE = "SELECT name FROM approver WHERE revoked_at IS NULL";
8
+ const TOKEN_FOR_OTHER = `access = 'act' AND (account <> created_by OR account NOT IN (${ACTIVE_PEOPLE}))`;
9
+ function count(store, sql) {
10
+ const n = Number(store.handle.prepare(sql).get()?.["n"]);
11
+ if (!Number.isSafeInteger(n) || n < 0)
12
+ throw new Error("install mode: an unreadable count");
13
+ return n;
14
+ }
15
+ function countsNow(store) {
16
+ return {
17
+ v: 2,
18
+ people: count(store, "SELECT count(*) AS n FROM approver"),
19
+ tokens: count(store, "SELECT count(*) AS n FROM credential WHERE access = 'act' AND account <> created_by"),
20
+ chat: count(store, `SELECT max(0, (SELECT count(*) FROM (${CHAT_IDENTITIES})) - 1) AS n`),
21
+ groups: count(store, "SELECT count(*) AS n FROM chat_room WHERE kind = 'group'"),
22
+ invites: count(store, "SELECT count(*) AS n FROM invite"),
23
+ };
24
+ }
25
+ function liveFacts(store) {
26
+ const facts = [];
27
+ if (Number(store.handle.prepare("SELECT count(*) AS n FROM invite WHERE consumed_at IS NULL AND revoked_at IS NULL AND expires_at > ?").get(new Date().toISOString())?.["n"] ?? 1) > 0)
28
+ facts.push("invite-open");
29
+ if (count(store, "SELECT count(*) AS n FROM approver WHERE revoked_at IS NULL") > 1)
30
+ facts.push("second-person");
31
+ if (count(store, `SELECT count(*) AS n FROM credential WHERE revoked_at IS NULL AND ${TOKEN_FOR_OTHER}`) > 0)
32
+ facts.push("token-for-someone-else");
33
+ if (count(store, `SELECT count(*) AS n FROM (${CHAT_IDENTITIES} WHERE revoked IS NULL)`) > 1
34
+ || count(store, `SELECT count(*) AS n FROM chat_binding WHERE revoked IS NULL AND approver NOT IN (${ACTIVE_PEOPLE})`) > 0)
35
+ facts.push("chat-person");
36
+ if (count(store, "SELECT count(*) AS n FROM chat_room WHERE revoked IS NULL AND kind = 'group'") > 0)
37
+ facts.push("chat-group");
38
+ return facts;
39
+ }
40
+ function countsOf(detail) {
41
+ if (typeof detail !== "string")
42
+ return null;
43
+ let parsed;
44
+ try {
45
+ parsed = JSON.parse(detail);
46
+ }
47
+ catch {
48
+ return null;
49
+ }
50
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
51
+ return null;
52
+ const record = parsed;
53
+ const counted = record["v"] === 2 ? COUNT_KEYS : record["v"] === 1 ? COUNT_KEYS.filter(key => key !== "invites") : null;
54
+ if (counted === null)
55
+ return null;
56
+ const keys = ["v", ...counted, "why"];
57
+ if (Object.keys(record).length !== keys.length || !keys.every(key => Object.hasOwn(record, key)) || !WHYS.has(record["why"]))
58
+ return null;
59
+ for (const key of counted) {
60
+ const value = record[key];
61
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
62
+ return null;
63
+ }
64
+ if (record["v"] === 1)
65
+ return "outdated";
66
+ return { v: 2, people: record["people"], tokens: record["tokens"], chat: record["chat"], groups: record["groups"], invites: record["invites"] };
67
+ }
68
+ export function installModeNow(store) {
69
+ try {
70
+ const facts = liveFacts(store);
71
+ const row = store.handle.prepare(`SELECT actor, at, outcome, detail FROM action_ledger
72
+ WHERE action = ? AND source = 'access' AND repo IS NULL AND task_id IS NULL AND run_id IS NULL ORDER BY id DESC LIMIT 1`).get(INSTALL_MODE_ACTION);
73
+ const kept = row === undefined || row["outcome"] !== "solo" ? null : countsOf(row["detail"]);
74
+ if (kept === null)
75
+ return { mode: "team", facts: ["existing-install", ...facts], declared: null };
76
+ if (kept === "outdated")
77
+ return { mode: "team", facts: ["outdated-declaration", ...facts], declared: null };
78
+ const now = countsNow(store);
79
+ if (now.invites > kept.invites)
80
+ facts.push("invite-added");
81
+ if (now.people > kept.people)
82
+ facts.push("person-added");
83
+ if (now.tokens > kept.tokens)
84
+ facts.push("token-added");
85
+ if (now.chat > kept.chat)
86
+ facts.push("chat-person-added");
87
+ if (now.groups > kept.groups)
88
+ facts.push("chat-group-added");
89
+ const why = JSON.parse(String(row["detail"])).why;
90
+ return { mode: facts.length === 0 ? "solo" : "team", facts, declared: { by: String(row["actor"]), at: String(row["at"]), why } };
91
+ }
92
+ catch {
93
+ return { mode: "team", facts: ["unreadable"], declared: null };
94
+ }
95
+ }
96
+ export function soloNow(store) {
97
+ return installModeNow(store).mode === "solo";
98
+ }
99
+ export function sessionStandsIn(store) {
100
+ let rows;
101
+ try {
102
+ rows = store.handle.prepare(`SELECT 'passwordless' AS kind, outcome FROM (SELECT outcome FROM action_ledger WHERE repo IS NULL AND task_id IS NULL AND action = ? ORDER BY id DESC LIMIT 1)
103
+ UNION ALL SELECT 'mode' AS kind, outcome FROM (SELECT outcome FROM action_ledger WHERE action = ? AND source = 'access' AND repo IS NULL AND task_id IS NULL AND run_id IS NULL ORDER BY id DESC LIMIT 1)`)
104
+ .all(PASSWORDLESS_ACTION, INSTALL_MODE_ACTION);
105
+ }
106
+ catch {
107
+ return false;
108
+ }
109
+ const passwordless = rows.find(row => row["kind"] === "passwordless")?.["outcome"];
110
+ if (passwordless === "on")
111
+ return true;
112
+ if (passwordless !== undefined)
113
+ return false;
114
+ if (rows.find(row => row["kind"] === "mode")?.["outcome"] !== "solo")
115
+ return false;
116
+ return soloNow(store);
117
+ }
118
+ export const defaultChainOf = (mode) => mode === "solo" ? "just-code" : "plan-first";
119
+ function declare(store, by, why, now) {
120
+ const counts = countsNow(store);
121
+ store.recordAction({ at: now.toISOString(), actor: by, repo: null, taskId: null, runId: null, action: INSTALL_MODE_ACTION, outcome: "solo", source: "access",
122
+ detail: JSON.stringify({ ...counts, why }) });
123
+ }
124
+ export function declareNewInstallSolo(store, owner, now) {
125
+ if (count(store, "SELECT count(*) AS n FROM approver") !== 1 || store.accountOf(owner) === null)
126
+ return;
127
+ if (liveFacts(store).length > 0)
128
+ return;
129
+ declare(store, owner, "new-install", now);
130
+ }
131
+ export function declareJustMe(store, by, now) {
132
+ return store.transact(() => {
133
+ const read = installModeNow(store);
134
+ if (read.mode === "solo")
135
+ return { ok: false, reason: "already-solo", facts: [] };
136
+ const blocking = read.facts.filter(fact => LIVE_FACTS.has(fact));
137
+ if (blocking.length > 0)
138
+ return { ok: false, reason: "team", facts: blocking };
139
+ const account = store.accountOf(by);
140
+ if (account === null || account.revokedAt !== null || account.role !== "approver" || !store.isInstanceOperator(by))
141
+ return { ok: false, reason: "not-owner", facts: [] };
142
+ declare(store, by, "just-me", now);
143
+ return { ok: true };
144
+ });
145
+ }
146
+ export function justMeAllowed(read) {
147
+ return read.mode === "team" && read.facts.every(fact => !LIVE_FACTS.has(fact));
148
+ }
149
+ export const TEAM_FACT_WORDS = Object.freeze({
150
+ "existing-install": "This install was set up before solo mode.",
151
+ "outdated-declaration": "This install was marked solo by an earlier version. Say it's just you again.",
152
+ "invite-open": "An invitation is open. Cancel it first.",
153
+ "invite-added": "Someone was invited since this install became solo.",
154
+ unreadable: "Toolroll couldn't read who uses this install.",
155
+ "second-person": "Another person has an account here. Remove them first.",
156
+ "person-added": "Another person joined since this install became solo.",
157
+ "token-for-someone-else": "A token acts for someone else. Revoke it first.",
158
+ "token-added": "A token for someone else was made since this install became solo.",
159
+ "chat-person": "Someone else can act through a chat app. Unpair them first.",
160
+ "chat-person-added": "Someone else paired a chat app since this install became solo.",
161
+ "chat-group": "A chat group follows this install. Remove it first.",
162
+ "chat-group-added": "A chat group was added since this install became solo.",
163
+ });
164
+ export function installModeLine(mode) {
165
+ return mode === "solo"
166
+ ? { label: "Solo", words: "Just you. Approvals need no password; sign-in, tokens and connections still do." }
167
+ : { label: "Team", words: "More than one person can use this install." };
168
+ }
169
+ export const SOLO_ON_UPGRADE_WORDS = "declared solo on upgrade: one person, nothing else ever";
170
+ export function declareSoloOnUpgrade(store, now) {
171
+ try {
172
+ return store.transact(() => {
173
+ if (store.handle.prepare("SELECT 1 AS hit FROM action_ledger WHERE action = ? LIMIT 1").get(INSTALL_MODE_ACTION) !== undefined)
174
+ return false;
175
+ const mode = store.handle.prepare("SELECT owner, enabled FROM local_mode WHERE id = 1").get();
176
+ if (mode === undefined || Number(mode["enabled"]) !== 1)
177
+ return false;
178
+ const owner = String(mode["owner"]);
179
+ const people = store.handle.prepare("SELECT name, revoked_at, role FROM approver").all();
180
+ if (people.length !== 1 || people[0]["name"] !== owner || people[0]["revoked_at"] !== null || people[0]["role"] !== "approver")
181
+ return false;
182
+ const none = (sql, ...args) => {
183
+ const n = Number(store.handle.prepare(sql).get(...args)?.["n"]);
184
+ if (!Number.isSafeInteger(n) || n < 0)
185
+ throw new Error("install mode: an unreadable count");
186
+ return n === 0;
187
+ };
188
+ const clean = none("SELECT count(*) AS n FROM credential WHERE account <> ? OR created_by <> ?", owner, owner)
189
+ && none("SELECT count(*) AS n FROM chat_binding WHERE approver <> ?", owner)
190
+ && count(store, `SELECT count(*) AS n FROM (${CHAT_IDENTITIES})`) <= 1
191
+ && none("SELECT count(*) AS n FROM chat_pair WHERE approver <> ?", owner)
192
+ && none("SELECT count(*) AS n FROM chat_room WHERE kind = 'group'")
193
+ && none("SELECT count(*) AS n FROM invite")
194
+ && none("SELECT count(*) AS n FROM sso_identity WHERE account <> ?", owner)
195
+ && none("SELECT count(*) AS n FROM action_ledger WHERE source = 'access' AND (actor NOT IN (?, ?, 'system') OR action IN ('joined', 'invitation created'))", owner, `operator:${owner}`)
196
+ && liveFacts(store).length === 0;
197
+ if (!clean)
198
+ return false;
199
+ declare(store, "system", "upgrade", now);
200
+ store.recordAction({ at: now.toISOString(), actor: "system", repo: null, taskId: null, runId: null, action: "install mode (automatic)", outcome: "solo", source: "access", detail: SOLO_ON_UPGRADE_WORDS });
201
+ return true;
202
+ });
203
+ }
204
+ catch {
205
+ return false;
206
+ }
207
+ }
208
+ export function soloChatSeatRefusal(store, seat) {
209
+ const refusal = "On this install, chat acts come only from the chat account its owner paired. Nothing was done.";
210
+ try {
211
+ if (!soloNow(store))
212
+ return null;
213
+ if (seat.binding === undefined)
214
+ return refusal;
215
+ const people = store.handle.prepare("SELECT name FROM approver WHERE revoked_at IS NULL").all();
216
+ const live = store.handle.prepare("SELECT provider, id, approver FROM chat_binding WHERE revoked IS NULL").all();
217
+ const mine = live.find(row => row["provider"] === seat.provider && Number(row["id"]) === seat.binding);
218
+ if (people.length !== 1 || people[0]["name"] !== seat.approver || mine === undefined || mine["approver"] !== seat.approver)
219
+ return refusal;
220
+ return count(store, `SELECT count(*) AS n FROM (${CHAT_IDENTITIES} WHERE revoked IS NULL)`) === 1 ? null : refusal;
221
+ }
222
+ catch {
223
+ return refusal;
224
+ }
225
+ }
@@ -18,6 +18,7 @@ import { applyChatReview } from "./chat-review.js";
18
18
  import { applyChatTaskAction } from "./chat-task-actions.js";
19
19
  import { currentLocalOwner, localOwnerRefusal, proposalLocalAct, withLocalAct } from "./local-owner.js";
20
20
  import { chatStartPreview, consumeChatStartPreview } from "./fast-start.js";
21
+ import { soloChatSeatRefusal } from "./install-mode.js";
21
22
  function localDoor(options) {
22
23
  return options.authority !== "full" || currentLocalOwner() !== null;
23
24
  }
@@ -237,6 +238,11 @@ export function dismissCoordinatorProposal(store, who, proposalId, now) {
237
238
  function executeProposal(store, actor, kind, payload, now, options) {
238
239
  if (!isVerifiedApprover(actor) || !reproveApprover(store, actor).ok)
239
240
  return { ok: false, kind, reason: "standing", said: "Your sign-in changed. Sign in again." };
241
+ if (options.via !== "web" && options.via !== "cli") {
242
+ const solo = soloChatSeatRefusal(store, { provider: options.via, binding: options.binding, approver: actor.name });
243
+ if (solo !== null)
244
+ return { ok: false, kind, reason: "standing", said: solo };
245
+ }
240
246
  const taskId = payloadString(payload, "task");
241
247
  const admitted = (repo) => repo !== null && actor.repos.includes(repo);
242
248
  const refuse = (reason, said) => ({ ok: false, kind, reason, said });
@@ -312,7 +318,7 @@ function executeProposal(store, actor, kind, payload, now, options) {
312
318
  if (ref === null || !admitted(ref.repo))
313
319
  return refuse("unknown-task", "no such task in your projects");
314
320
  if (kind === "task_action") {
315
- const result = applyChatTaskAction(store, actor, payload, now, options.via !== "cli", { deferSignal: options.deferSignal, via: options.via, person: options.via === "web" ? options.person === true : options.via !== "cli", ...(options.evidenceRoot === undefined ? {} : { evidenceRoot: options.evidenceRoot }) });
321
+ const result = applyChatTaskAction(store, actor, payload, now, options.via !== "cli", { deferSignal: options.deferSignal, via: options.via, person: options.via === "web" ? options.person === true : options.via !== "cli", ...(options.evidenceRoot === undefined ? {} : { evidenceRoot: options.evidenceRoot }), ...(options.binding === undefined ? {} : { binding: options.binding }) });
316
322
  return result.ok ? { ok: true, kind, taskId: result.taskId, said: result.said } : refuse("stale", result.message);
317
323
  }
318
324
  if (kind === "review") {
package/dist/limits-ui.js CHANGED
@@ -61,6 +61,13 @@ export function usageChipOf(windows, now) {
61
61
  const text = `${PROVIDER_NAMES[top.provider] ?? top.provider} ${windowLabel(top.window, top.windowMinutes)} · ${Math.round(top.usedPercent)}% · ${reset}${stale ? ` · as of ${ago(top.observedAt, now)}` : ""}`;
62
62
  return { text, tone: old ? "neutral" : toneOf(top.usedPercent, top.reached), stale, href: "/", title: `What the providers last reported: ${text}` };
63
63
  }
64
+ export function spendLineOf(items, windows, now) {
65
+ const dayStart = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
66
+ const micro = items.reduce((sum, one) => { const at = Date.parse(one.at); return Number.isFinite(at) && at >= dayStart && at <= now.getTime() ? sum + (one.microusd ?? 0) : sum; }, 0);
67
+ const current = windows.filter(one => one.resetsAt === null || Date.parse(one.resetsAt) > now.getTime());
68
+ const top = current.reduce((max, one) => Math.max(max ?? 0, one.reached ? 100 : one.usedPercent), null);
69
+ return { todayUsd: Math.round(micro / 10_000) / 100, planPercent: top === null ? null : Math.round(Math.min(100, Math.max(0, top))) };
70
+ }
64
71
  export function limitsHtml(limits) {
65
72
  if (limits === null)
66
73
  return html ``;
@@ -18,6 +18,10 @@ function opening(leads, body) {
18
18
  }
19
19
  return `(?:${[...alternatives].join("|")})`;
20
20
  }
21
+ function namePrefixes(names) {
22
+ const escape = (text) => text.replace(/[.*+?^${}()|[\]\\/-]/g, "\\$&");
23
+ return [...new Set(names.flatMap(name => Array.from({ length: name.length - 1 }, (_, n) => escape(name.slice(0, n + 1)))))].join("|");
24
+ }
21
25
  const SECRET_STARTS = [
22
26
  /-{1,5}(?:B(?:E(?:G(?:I(?:N(?:[ \t][A-Z \t]*-{0,5})?)?)?)?)?)?$/,
23
27
  new RegExp(String.raw `(?:^|[^A-Za-z0-9])${opening(["_authToken"], String.raw `[\s=]`)}\S*$`),
@@ -30,6 +34,8 @@ const SECRET_STARTS = [
30
34
  new RegExp(String.raw `(?:^|[^A-Za-z0-9_])${opening(["glpat-"], "[A-Za-z0-9_-]")}$`),
31
35
  /(?:^|[^A-Za-z0-9_])\d+(?::(?:A(?:A[A-Za-z0-9_-]*)?)?)?$/,
32
36
  /(?:^|[^A-Za-z0-9_])[MN][A-Za-z\d]*(?:\.[\w-]*(?:\.[\w-]*)?)?$/,
37
+ new RegExp(String.raw `(?:^|[^A-Za-z0-9_])${opening(["PuTTY-User-Key-File-"], "[0-9:]")}$`),
38
+ new RegExp(String.raw `(?:^|[^A-Za-z0-9_])(?:${namePrefixes(["aws_secret_access_key", "SecretAccessKey"])}|(?:aws_secret_access_key|SecretAccessKey)["']?\s*(?:[=:]\s*["']?[A-Za-z0-9/+]*)?)$`, "i"),
33
39
  /(?:^|[^A-Za-z0-9+.-])[a-z][a-z0-9+.-]*:\S*$/i,
34
40
  ];
35
41
  export function secretMayStart(text) {