@chibitek/chibi 0.1.209 → 0.1.211

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/dist/assets/{TerminalPanel-CHGq3udb.js → TerminalPanel-Dro3aeVy.js} +1 -1
  2. package/dist/assets/{abnfDiagram-O67JEVCF-BMaKhJ-b.js → abnfDiagram-O67JEVCF-kzAr7vQ8.js} +1 -1
  3. package/dist/assets/{arc-CYAiNWN8.js → arc-DKMhcYud.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-CxJFFlbO.js → architectureDiagram-NJMV4G6O-_XDnZ7Jz.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-C7AbPjRB.js → blockDiagram-BEXU5L5S-D5MoWro9.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-DfVnCJmT.js → c4Diagram-YGBWAQC7-CGvTMpGE.js} +1 -1
  7. package/dist/assets/channel-YcZdlysP.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-CzAUFkgv.js → chunk-2Q5K7J3B-pjTwr5y0.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-BgeBXphm.js → chunk-3FUC2YCW-BR6zkd-l.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-DPRdTAXc.js → chunk-5VM5RSS4-CfVFFBeH.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-BS-_dIVl.js → chunk-GTNCS2PH-TIoAkccw.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-D6I7xMmd.js → chunk-GWA4HPMP-BNFBgzbt.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-BKSKe7C9.js → chunk-JWPE2WC7-B_3QFchU.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-R48UYTRN.js → chunk-NETBCI7D-Cj9q80P-.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-C8z4mL-2.js → chunk-WEXAMYUT-DFZPGo9K.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-Bml3ZRJ5.js → chunk-XXDRQBXY-CekDrT9T.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-w5wo22FO.js → classDiagram-v2-NBCMYWYE-C3R6Z4Qe.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-Cum9v--4.js → cose-bilkent-JH36ORCC-C1CKyj0L.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-BzN0-KsP.js → cynefin-OW5HDTMX-Deh9QGb0.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-CkOpm32D.js → cynefinDiagram-VND7K2PF-BIlWyG_M.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-BItQkKZD.js → dagre-6A5THRUB-Dx4bWOog.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-BI0zDn7c.js → diagram-22UHCM2B-DPxb-FUO.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-jwcDxsu6.js → diagram-3UASUU5V-BLPCNc4m.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-2RnY9egJ.js → diagram-ATOU4E4O-DOCbp2Dw.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-eVdEZmEF.js → diagram-CDSNMT55-62uSG-tn.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-BCDGCJJ0.js → diagram-MLGK6HIB-De1ZAWVZ.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-DtN5uO5w.js → diagram-MPIPVDR6-CIGX9tku.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-B9GpXSEs.js → ebnfDiagram-ZINNZB2B-CegjStdk.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-Bk_eaK4T.js → elk-276RUBZZ-ClI52Pqm.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-BiGoW6C6.js → erDiagram-OPXOYQCR-BQuzjt2-.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-ZW5w0BaJ.js → flowDiagram-KWPJA3E3-D1xbKgbB.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-yyrKgsx1.js → ganttDiagram-FUAMR5RP-CH1jGSZz.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-CeiDikzD.js → gitGraphDiagram-X574FWY7-BvAUPEmQ.js} +1 -1
  34. package/dist/assets/{index-CZGnshrJ.js → index-BcXDfnlQ.js} +197 -197
  35. package/dist/assets/{index-DUFlRZuA.js → index-DbkR_erP.js} +1 -1
  36. package/dist/assets/index-H8vkXbLq.css +1 -0
  37. package/dist/assets/{infoDiagram-VRGFBTTK-q2B-KJFm.js → infoDiagram-VRGFBTTK-CyMmMbMv.js} +1 -1
  38. package/dist/assets/{ishikawaDiagram-OU5B5YK6-D8gXFuc0.js → ishikawaDiagram-OU5B5YK6-Uw-hE1tO.js} +1 -1
  39. package/dist/assets/{journeyDiagram-ZHPQQLJL-BmHL2mbq.js → journeyDiagram-ZHPQQLJL-ClEDnNRB.js} +1 -1
  40. package/dist/assets/{kanban-definition-PNTS6WVX-B9Ll2WkA.js → kanban-definition-PNTS6WVX-erx0BEal.js} +1 -1
  41. package/dist/assets/{linear-CMVGYrKx.js → linear-CSSxpyL0.js} +1 -1
  42. package/dist/assets/{mermaid.core-qO11n1kV.js → mermaid.core-n13K6vlC.js} +5 -5
  43. package/dist/assets/{mindmap-definition-NLK3R4M7-CxLGFX45.js → mindmap-definition-NLK3R4M7-BcTEIqpD.js} +1 -1
  44. package/dist/assets/{pegDiagram-GJSIUBJH-CxK1MJG4.js → pegDiagram-GJSIUBJH-CJdsm3en.js} +1 -1
  45. package/dist/assets/{pieDiagram-5QR66LMP-H5jiF5Eu.js → pieDiagram-5QR66LMP-C7rk-ash.js} +1 -1
  46. package/dist/assets/{quadrantDiagram-O4NWA36T-CKaqCruv.js → quadrantDiagram-O4NWA36T-BSXOYov0.js} +1 -1
  47. package/dist/assets/{railroadDiagram-XR7U4H2S-BCzKiQOd.js → railroadDiagram-XR7U4H2S-Cmg_FtZY.js} +1 -1
  48. package/dist/assets/{requirementDiagram-PLB6GJNP-Cqtr43DT.js → requirementDiagram-PLB6GJNP-B_9aE6Mg.js} +1 -1
  49. package/dist/assets/{sankeyDiagram-IPEJSGJF-B2tQewX8.js → sankeyDiagram-IPEJSGJF-DyxaQPy3.js} +1 -1
  50. package/dist/assets/{sequenceDiagram-PO4LG4MO-nggwQyrw.js → sequenceDiagram-PO4LG4MO-D5CJeESq.js} +1 -1
  51. package/dist/assets/{sizeCapture-INFHLROL-qSPXJBv2.js → sizeCapture-INFHLROL-9-Q4eosQ.js} +1 -1
  52. package/dist/assets/{stateDiagram-v2-GCMORJYK-DraPbL2T.js → stateDiagram-v2-GCMORJYK-jgsHnEQl.js} +1 -1
  53. package/dist/assets/{swimlanes-2SLR337P-C6HVkIDA.js → swimlanes-2SLR337P-MIVacUbv.js} +1 -1
  54. package/dist/assets/swimlanesDiagram-TC7HE7FX-Dekwo1KL.js +8 -0
  55. package/dist/assets/{timeline-definition-EJHVYXUP-DZmPRTsx.js → timeline-definition-EJHVYXUP-Ch8ins-D.js} +1 -1
  56. package/dist/assets/{usecaseDiagram-POWQR4AR-CsVuROW_.js → usecaseDiagram-POWQR4AR-BDwBIuhZ.js} +1 -1
  57. package/dist/assets/{vennDiagram-UO4OBE2U-B9IRbuhp.js → vennDiagram-UO4OBE2U-BiiDxcHO.js} +1 -1
  58. package/dist/assets/{wardleyDiagram-VNRHLVJA-CGmVK53n.js → wardleyDiagram-VNRHLVJA-D79CK2__.js} +1 -1
  59. package/dist/assets/{xychartDiagram-PMCCYNJV-BAw-x9Y1.js → xychartDiagram-PMCCYNJV-CI7S0o-6.js} +1 -1
  60. package/dist/index.html +4 -2
  61. package/dist-server/accounts-proxy.js +19 -12
  62. package/dist-server/browser-proxy.js +19 -14
  63. package/dist-server/container-mcp.js +165 -93
  64. package/dist-server/drivers/agents-proxy.js +109 -94
  65. package/dist-server/drivers/phone-proxy.js +21 -13
  66. package/dist-server/index.js +6487 -4926
  67. package/dist-server/local-computer-proxy.js +77 -11
  68. package/dist-server/local-computer.js +2 -1
  69. package/dist-server/mcp-gate.js +53 -4
  70. package/dist-server/mcp-server.js +1 -1
  71. package/dist-server/openmausbot.js +1068 -642
  72. package/dist-server/pair-cli.js +1068 -642
  73. package/dist-server/server/accounts-proxy.js +3 -17
  74. package/dist-server/server/atomic-engine-release.js +7 -0
  75. package/dist-server/server/auto-approve.js +12 -0
  76. package/dist-server/server/browser-proxy.js +3 -17
  77. package/dist-server/server/child-env.js +79 -0
  78. package/dist-server/server/config.js +11 -5
  79. package/dist-server/server/container-computer.js +1 -1
  80. package/dist-server/server/container-mcp.js +3 -2
  81. package/dist-server/server/control-client.js +7 -6
  82. package/dist-server/server/delegated-full-access.js +98 -0
  83. package/dist-server/server/desktop-loopback-gate.js +57 -0
  84. package/dist-server/server/drivers/acp/core.js +4 -4
  85. package/dist-server/server/drivers/acp/custom.js +3 -1
  86. package/dist-server/server/drivers/acp/hermes.js +2 -1
  87. package/dist-server/server/drivers/acp/session-key.js +8 -0
  88. package/dist-server/server/drivers/agents-client.js +2 -14
  89. package/dist-server/server/drivers/gcloud-token.js +28 -0
  90. package/dist-server/server/drivers/github-copilot.js +152 -0
  91. package/dist-server/server/drivers/hermes-context-floor.js +68 -0
  92. package/dist-server/server/drivers/openai-chat-protocol.js +8 -0
  93. package/dist-server/server/drivers/openai-chat.js +10 -8
  94. package/dist-server/server/drivers/openai-compat.js +44 -9
  95. package/dist-server/server/drivers/phone-proxy.js +5 -18
  96. package/dist-server/server/engine-tiers.js +9 -9
  97. package/dist-server/server/god-mode-goal.js +78 -0
  98. package/dist-server/server/god-mode-run-host.js +69 -0
  99. package/dist-server/server/harness/http.js +47 -1
  100. package/dist-server/server/index.js +86 -86
  101. package/dist-server/server/ladder-pick.js +18 -0
  102. package/dist-server/server/local-computer-proxy.js +3 -2
  103. package/dist-server/server/local-computer.js +1 -0
  104. package/dist-server/server/mcp-bridge.js +3 -2
  105. package/dist-server/server/mcp-gate.js +2 -1
  106. package/dist-server/server/mcp-registry.js +5 -1
  107. package/dist-server/server/model-fallback-repair.js +20 -0
  108. package/dist-server/server/model-gateway/failover.js +4 -1
  109. package/dist-server/server/model-gateway/route.js +64 -14
  110. package/dist-server/server/model-gateway/usage.js +66 -0
  111. package/dist-server/server/model-levels/aa-scale.js +42 -0
  112. package/dist-server/server/model-levels/aliases.js +16 -3
  113. package/dist-server/server/model-levels/index.js +8 -3
  114. package/dist-server/server/model-levels/rankings-build.js +76 -0
  115. package/dist-server/server/model-prices.js +6 -0
  116. package/dist-server/server/nexus-memory/index.js +5 -13
  117. package/dist-server/server/nexus-memory/policy.js +5 -17
  118. package/dist-server/server/oauth-account-vault.js +7 -2
  119. package/dist-server/server/personal-goal-runtime.js +29 -3
  120. package/dist-server/server/personal-goal-turn.js +2 -1
  121. package/dist-server/server/personal-goals.js +20 -2
  122. package/dist-server/server/provider-accounts.js +20 -1
  123. package/dist-server/server/provider-key-check.js +31 -1
  124. package/dist-server/server/registry-load.js +88 -0
  125. package/dist-server/server/request-auth.js +6 -28
  126. package/dist-server/server/routes/provider-accounts.js +124 -6
  127. package/dist-server/server/routine-daily-schedule.js +20 -0
  128. package/dist-server/server/routine-prompt-escape.js +18 -0
  129. package/dist-server/server/routine-tick-guard.js +16 -0
  130. package/dist-server/server/routine-tool-problems.js +36 -0
  131. package/dist-server/server/routines.js +36 -38
  132. package/dist-server/server/shutdown-triggers.js +18 -0
  133. package/dist-server/server/spend.js +23 -13
  134. package/dist-server/server/store.js +4 -13
  135. package/dist-server/server/terminal.js +2 -1
  136. package/dist-server/server/turn-token-file.js +79 -0
  137. package/dist-server/server/turn-token.js +23 -0
  138. package/dist-server/server/vps-container-mcp.js +3 -2
  139. package/dist-server/server/webhook-ingress.js +11 -1
  140. package/dist-server/server/webhook-prompt.js +82 -0
  141. package/dist-server/server/webhooks.js +8 -65
  142. package/dist-server/server/workspace-backup-policy.js +3 -3
  143. package/dist-server/server/workspace-backup.js +1 -1
  144. package/dist-server/server/workspace-time-zone.js +47 -0
  145. package/dist-server/shared/engine-choices.js +12 -1
  146. package/dist-server/shared/god-mode-run.js +173 -0
  147. package/dist-server/shared/personal-goal.js +42 -0
  148. package/dist-server/shared/provider-accounts.js +114 -2
  149. package/dist-server/shared/zoned-time.js +55 -0
  150. package/dist-server/vps-container-mcp.js +165 -93
  151. package/package.json +1 -1
  152. package/dist/assets/channel-DxL_mLhm.js +0 -1
  153. package/dist/assets/index-Bi3hprmz.css +0 -1
  154. package/dist/assets/swimlanesDiagram-TC7HE7FX-gQUGsELo.js +0 -8
  155. package/dist-server/server/agents-token-file.js +0 -26
@@ -0,0 +1,18 @@
1
+ // Text escaping for the prompt a routine run is started with (routines.ts
2
+ // composeExecutionPrompt).
3
+ /** Keep untrusted local paths inside the same quoted tag shape used by chat. */
4
+ export function escapeAttachmentPath(value) {
5
+ return value
6
+ .replaceAll("&", "&")
7
+ .replaceAll('"', """)
8
+ .replaceAll("<", "&lt;")
9
+ .replaceAll(">", "&gt;")
10
+ .replaceAll("\t", "&#9;")
11
+ .replaceAll("\r", "&#13;")
12
+ .replaceAll("\n", "&#10;");
13
+ }
14
+ /** Preserve prose while preventing the report from introducing markup. This
15
+ * is formatting, not a guarantee that a model cannot follow injected text. */
16
+ export function fenceCarriedReport(output) {
17
+ return output.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
18
+ }
@@ -0,0 +1,16 @@
1
+ // A bound on the scheduler's awaits (routines.ts tick): a start or an
2
+ // interrupt that never settles fails that one run instead of holding the
3
+ // tick, and with it every other routine, forever.
4
+ export const ROUTINE_START_BOUND_MS = 2 * 60_000;
5
+ export const ROUTINE_INTERRUPT_BOUND_MS = 30_000;
6
+ export const ROUTINE_START_TIMED_OUT = "The bot did not start this run in time. Run the routine again, and restart Atomic if it keeps happening.";
7
+ /** `work`, or a rejection with `message` once `ms` has passed. The work is
8
+ * not cancelled; whatever it does later is ignored by the caller. */
9
+ export function bounded(work, ms, message) {
10
+ if (!work)
11
+ return Promise.resolve(undefined);
12
+ return new Promise((resolve, reject) => {
13
+ const timer = setTimeout(() => reject(new Error(message)), ms);
14
+ work.then((value) => { clearTimeout(timer); resolve(value); }, (error) => { clearTimeout(timer); reject(error instanceof Error ? error : new Error(String(error))); });
15
+ });
16
+ }
@@ -0,0 +1,36 @@
1
+ import { redactSecretsInText } from "./redact.js";
2
+ // A routine's model turn can end "ok" while the tools it needed never
3
+ // worked: a server that would not start, or one that stopped mid-turn. The
4
+ // model then writes a polite reply and the run used to be filed as
5
+ // completed (the 2026-10-29 incident in
6
+ // docs/verification/mcp-discovery-recovery.md). What the gates reported
7
+ // against a run is kept here until the run settles, so the receipt can say
8
+ // the work may not have happened.
9
+ const MAX_DETAILS = 5;
10
+ const MAX_RUNS = 200;
11
+ export class RoutineToolProblems {
12
+ byRun = new Map();
13
+ note(runId, detail) {
14
+ const text = redactSecretsInText(detail).trim().slice(0, 200);
15
+ if (!text)
16
+ return;
17
+ const details = this.byRun.get(runId) ?? [];
18
+ if (details.includes(text) || details.length >= MAX_DETAILS)
19
+ return;
20
+ // Re-inserting keeps the map ordered by latest note, so a run that
21
+ // never settles here (stopped, failed elsewhere) ages out first.
22
+ this.byRun.delete(runId);
23
+ this.byRun.set(runId, [...details, text]);
24
+ while (this.byRun.size > MAX_RUNS)
25
+ this.byRun.delete(this.byRun.keys().next().value);
26
+ }
27
+ /** The receipt's failure text when this run's tools failed, else null. The
28
+ * record is consumed: a run settles once. */
29
+ settle(runId) {
30
+ const details = this.byRun.get(runId);
31
+ this.byRun.delete(runId);
32
+ if (!details?.length)
33
+ return null;
34
+ return `Tools failed during this run, so the work may not have been done: ${details.join("; ")}`;
35
+ }
36
+ }
@@ -7,6 +7,10 @@ import { writeFileAtomic } from "./atomic.js";
7
7
  import { redactSecretsInText } from "./redact.js";
8
8
  import { normalizeCronSchedule, nextCronRuns } from "../shared/routine-schedule.js";
9
9
  import { isRoutineProblemRun } from "../shared/routines.js";
10
+ import { nextDailyOccurrence } from "./routine-daily-schedule.js";
11
+ import { escapeAttachmentPath, fenceCarriedReport } from "./routine-prompt-escape.js";
12
+ import { bounded, ROUTINE_INTERRUPT_BOUND_MS, ROUTINE_START_BOUND_MS, ROUTINE_START_TIMED_OUT } from "./routine-tick-guard.js";
13
+ import { RoutineToolProblems } from "./routine-tool-problems.js";
10
14
  const persistedSourceThreadId = z.string().trim().min(1).optional().catch(undefined);
11
15
  const webhookRunReceiptSchema = z.object({
12
16
  webhookId: z.string().min(1).max(200),
@@ -156,24 +160,8 @@ function cloneRun(run) {
156
160
  denials: run.denials ? [...run.denials] : undefined,
157
161
  };
158
162
  }
159
- /** Keep untrusted local paths inside the same quoted tag shape used by chat. */
160
- function escapeAttachmentPath(value) {
161
- return value
162
- .replaceAll("&", "&amp;")
163
- .replaceAll('"', "&quot;")
164
- .replaceAll("<", "&lt;")
165
- .replaceAll(">", "&gt;")
166
- .replaceAll("\t", "&#9;")
167
- .replaceAll("\r", "&#13;")
168
- .replaceAll("\n", "&#10;");
169
- }
170
163
  /** Continuity reuses the bounded stored report, not the full transcript. */
171
164
  const CONTINUITY_CHARS = 2_000;
172
- /** Preserve prose while preventing the report from introducing markup. This
173
- * is formatting, not a guarantee that a model cannot follow injected text. */
174
- function fenceCarriedReport(output) {
175
- return output.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
176
- }
177
165
  function composeExecutionPrompt(prompt, attachments, carry) {
178
166
  const parts = [prompt];
179
167
  if (carry) {
@@ -335,8 +323,8 @@ function nextAlignedInterval(schedule, after) {
335
323
  const candidate = schedule.anchorAt + (intervalsElapsed + 1) * intervalMs;
336
324
  return Number.isSafeInteger(candidate) && candidate <= MAX_DATE_MS ? candidate : null;
337
325
  }
338
- /** Next occurrence strictly after `after`: cron uses its saved zone, daily uses the host zone. */
339
- export function nextOccurrence(schedule, after) {
326
+ /** Next occurrence strictly after `after`: cron uses its saved zone, daily uses `timeZone`, else the host zone. */
327
+ export function nextOccurrence(schedule, after, timeZone) {
340
328
  if (schedule.type === "once")
341
329
  return schedule.at > after ? schedule.at : null;
342
330
  if (schedule.type === "cron")
@@ -357,16 +345,7 @@ export function nextOccurrence(schedule, after) {
357
345
  }
358
346
  return null;
359
347
  }
360
- const [hour, minute] = schedule.time.split(":").map(Number);
361
- const weekdays = new Set(cleanDays(schedule.weekdays));
362
- for (let offset = 0; offset <= 8; offset++) {
363
- const d = new Date(after);
364
- d.setDate(d.getDate() + offset);
365
- d.setHours(hour, minute, 0, 0);
366
- if (d.getTime() > after && weekdays.has(d.getDay()))
367
- return d.getTime();
368
- }
369
- return null;
348
+ return nextDailyOccurrence(schedule.time, cleanDays(schedule.weekdays), after, timeZone);
370
349
  }
371
350
  function latestIntervalOccurrence(schedule, at) {
372
351
  const intervalMs = schedule.everyMinutes * 60_000;
@@ -461,10 +440,12 @@ export class RoutineManager {
461
440
  options;
462
441
  routines = [];
463
442
  runs = [];
443
+ toolProblems = new RoutineToolProblems();
464
444
  routineRequestReceipts = [];
465
445
  webhookRunReceipts = [];
466
446
  timer = null;
467
447
  ticking = false;
448
+ tickAgain = false;
468
449
  constructor(options) {
469
450
  this.options = options;
470
451
  this.file = options.file ?? join(DATA_DIR, "routines.json");
@@ -931,7 +912,7 @@ export class RoutineManager {
931
912
  if (existing)
932
913
  return existing;
933
914
  if (this.options.botState(input.botId) === "missing") {
934
- throw Object.assign(new Error("The assigned MAUS no longer exists"), { status: 410 });
915
+ throw Object.assign(new Error("The assigned bot no longer exists"), { status: 410 });
935
916
  }
936
917
  const run = {
937
918
  id: randomUUID(),
@@ -1100,7 +1081,7 @@ export class RoutineManager {
1100
1081
  }
1101
1082
  async tick() {
1102
1083
  if (this.ticking)
1103
- return;
1084
+ return void (this.tickAgain = true);
1104
1085
  this.ticking = true;
1105
1086
  try {
1106
1087
  const now = this.now();
@@ -1118,13 +1099,13 @@ export class RoutineManager {
1118
1099
  if (!threadId)
1119
1100
  continue;
1120
1101
  if (run.target === "room-goal" && run.groupId) {
1121
- await this.options.interruptGoal?.(run.groupId, threadId, {
1102
+ await bounded(this.options.interruptGoal?.(run.groupId, threadId, {
1122
1103
  status: "limit-reached",
1123
1104
  detail,
1124
- }).catch(() => { });
1105
+ }), ROUTINE_INTERRUPT_BOUND_MS, "interrupt timed out").catch(() => { });
1125
1106
  }
1126
1107
  else {
1127
- await this.options.interruptTurn?.(run.botId, threadId, run.runOn ?? "maus").catch(() => { });
1108
+ await bounded(this.options.interruptTurn?.(run.botId, threadId, run.runOn ?? "maus"), ROUTINE_INTERRUPT_BOUND_MS, "interrupt timed out").catch(() => { });
1128
1109
  }
1129
1110
  }
1130
1111
  const dueRoutines = this.routines.filter((routine) => routine.enabled && routine.nextRunAt != null && routine.nextRunAt <= now);
@@ -1157,7 +1138,7 @@ export class RoutineManager {
1157
1138
  routine.lastSkippedAt = scheduledFor;
1158
1139
  }
1159
1140
  routine.nextRunAt =
1160
- routine.schedule.type === "once" ? null : nextOccurrence(routine.schedule, Math.max(now, scheduledFor));
1141
+ routine.schedule.type === "once" ? null : nextOccurrence(routine.schedule, Math.max(now, scheduledFor), this.options.timeZone);
1161
1142
  // `updatedAt` is the optimistic definition revision carried by
1162
1143
  // routine confirmation cards. Moving the scheduler cursor is runtime
1163
1144
  // progress, not a definition edit, so recurring ticks must not make a
@@ -1212,7 +1193,7 @@ export class RoutineManager {
1212
1193
  const mayDispatch = intervalAllowsOccurrence(definition.schedule, now) &&
1213
1194
  (!requiresCurrentDayOccurrence || (latest !== null && isSameLocalDay(latest, now)));
1214
1195
  if (!mayDispatch) {
1215
- if (nextOccurrence(definition.schedule, now) === null) {
1196
+ if (nextOccurrence(definition.schedule, now, this.options.timeZone) === null) {
1216
1197
  this.missQueuedRun(run, "The routine ended before this scheduled run could start");
1217
1198
  }
1218
1199
  continue;
@@ -1273,10 +1254,10 @@ export class RoutineManager {
1273
1254
  this.failThread(task.threadId, "Room goal routines are unavailable");
1274
1255
  continue;
1275
1256
  }
1276
- await this.options.startGoal(run.groupId, task.threadId, prompt, run.botId, run.id, (message) => this.failThread(task.threadId, message));
1257
+ await bounded(this.options.startGoal(run.groupId, task.threadId, prompt, run.botId, run.id, (message) => this.failThread(task.threadId, message)), this.options.startTimeoutMs ?? ROUTINE_START_BOUND_MS, ROUTINE_START_TIMED_OUT);
1277
1258
  }
1278
1259
  else {
1279
- await this.options.startTurn(run.botId, task.threadId, composeExecutionPrompt(prompt, run.attachments, this.continuityCarry(run)), run.runOn ?? "maus", triggerSource, (message) => this.failThread(task.threadId, message));
1260
+ await bounded(this.options.startTurn(run.botId, task.threadId, composeExecutionPrompt(prompt, run.attachments, this.continuityCarry(run)), run.runOn ?? "maus", triggerSource, (message) => this.failThread(task.threadId, message)), this.options.startTimeoutMs ?? ROUTINE_START_BOUND_MS, ROUTINE_START_TIMED_OUT);
1280
1261
  }
1281
1262
  }
1282
1263
  catch (error) {
@@ -1286,6 +1267,10 @@ export class RoutineManager {
1286
1267
  }
1287
1268
  finally {
1288
1269
  this.ticking = false;
1270
+ if (this.tickAgain) {
1271
+ this.tickAgain = false;
1272
+ queueMicrotask(() => void this.tick());
1273
+ }
1289
1274
  }
1290
1275
  }
1291
1276
  handleRuntimeEvent(event) {
@@ -1338,7 +1323,14 @@ export class RoutineManager {
1338
1323
  queueMicrotask(() => void this.tick());
1339
1324
  return cloneRun(run);
1340
1325
  }
1326
+ this.options.beforeSettle?.(event.threadId);
1341
1327
  const pending = this.options.hasPendingDelegations?.(event.threadId) === true;
1328
+ const toolFailure = pending ? null : this.toolProblems.settle(run.id);
1329
+ if (toolFailure) {
1330
+ this.failRun(run, toolFailure);
1331
+ queueMicrotask(() => void this.tick());
1332
+ return cloneRun(run);
1333
+ }
1342
1334
  run.status = pending ? "waiting" : "completed";
1343
1335
  run.attention = pending ? "Waiting for delegated work to finish" : undefined;
1344
1336
  if (!pending)
@@ -1354,6 +1346,12 @@ export class RoutineManager {
1354
1346
  queueMicrotask(() => void this.tick());
1355
1347
  return cloneRun(run);
1356
1348
  }
1349
+ /** A tool this thread's running routine needed failed (mcp-turn.ts). */
1350
+ noteToolProblem(threadId, detail) {
1351
+ const run = this.runs.find((r) => r.threadId === threadId && ["running", "waiting"].includes(r.status));
1352
+ if (run)
1353
+ this.toolProblems.note(run.id, detail);
1354
+ }
1357
1355
  failThread(threadId, message) {
1358
1356
  const run = this.runs.find((r) => r.threadId === threadId && ["running", "waiting"].includes(r.status));
1359
1357
  if (!run)
@@ -1437,7 +1435,7 @@ export class RoutineManager {
1437
1435
  // threshold from ever triggering for a "once" routine created late.
1438
1436
  if (schedule.type === "once")
1439
1437
  return schedule.at;
1440
- return nextOccurrence(schedule, now);
1438
+ return nextOccurrence(schedule, now, this.options.timeZone);
1441
1439
  }
1442
1440
  newRun(routine, scheduledFor, manual, allocations, sourceThreadId = routine.sourceThreadId) {
1443
1441
  if (routine.target === "bot" && this.options.resolveResultsThread) {
@@ -0,0 +1,18 @@
1
+ /** Must match UTILITY_SERVER_SHUTDOWN_MESSAGE in electron/utility-server-stop.mjs. */
2
+ export const PARENT_SHUTDOWN_MESSAGE = "openmausbot:shutdown";
3
+ export function isParentShutdownMessage(raw) {
4
+ return !!raw && typeof raw === "object" && !Array.isArray(raw) &&
5
+ raw.type === PARENT_SHUTDOWN_MESSAGE;
6
+ }
7
+ /** Every way the server is asked to stop runs the same shutdown. Signals
8
+ * cover POSIX and Ctrl+C. The desktop also asks over its private parent port
9
+ * because Windows ends a child without delivering any signal, which would
10
+ * skip the cleanup that stops engine process trees. */
11
+ export function installShutdownTriggers(signals, port, shutdown) {
12
+ for (const signal of ["SIGINT", "SIGTERM"])
13
+ signals.on(signal, shutdown);
14
+ port?.on("message", (event) => {
15
+ if (isParentShutdownMessage(event?.data))
16
+ shutdown();
17
+ });
18
+ }
@@ -11,6 +11,8 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
  import { entitled } from "./enterprise.js";
13
13
  import { readUsage, usageRowKey } from "./usage-ledger.js";
14
+ import { wallClock, zonedInstant } from "../shared/zoned-time.js";
15
+ import { workspaceTimeZone } from "./workspace-time-zone.js";
14
16
  const DEFAULT_WARN_AT_PERCENT = 80;
15
17
  const CACHE_MS = 15_000;
16
18
  // Every turn start asks; reading the month file each time would be silly.
@@ -21,18 +23,25 @@ const cache = new Map();
21
23
  // cost. The append is asynchronous, and a turn that ran longer than CACHE_MS
22
24
  // would otherwise be re-read out of the month before its own row landed.
23
25
  const unwritten = new Map();
24
- function monthOf(now) {
25
- return now.toISOString().slice(0, 7);
26
+ // The cap's month is the calendar month where the workspace is: this
27
+ // computer's time zone. In UTC it would start over at 7 PM Eastern on the
28
+ // last day. Ledger files stay named by UTC month; only this window moves.
29
+ function monthOf(now, timeZone) {
30
+ const { year, month } = wallClock(now.getTime(), timeZone);
31
+ return `${year}-${String(month).padStart(2, "0")}`;
32
+ }
33
+ function monthStart(now, timeZone) {
34
+ const { year, month } = wallClock(now.getTime(), timeZone);
35
+ return new Date(zonedInstant({ year, month, day: 1, hour: 0, minute: 0, second: 0 }, timeZone));
26
36
  }
27
37
  const costOf = (value) => (typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0);
28
38
  /** Reported and estimated cost this month so far: the ledger file (read at
29
39
  * most every CACHE_MS) plus turns booked since whose rows have not landed. */
30
- export function monthToDateSpend(dataDir, now = new Date()) {
31
- const month = monthOf(now);
40
+ export function monthToDateSpend(dataDir, now = new Date(), timeZone = workspaceTimeZone()) {
41
+ const month = monthOf(now, timeZone);
32
42
  let read = cache.get(dataDir);
33
43
  if (!read || read.month !== month || now.getTime() - read.at >= CACHE_MS) {
34
- const from = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
35
- const rows = readUsage(dataDir, { from, to: now });
44
+ const rows = readUsage(dataDir, { from: monthStart(now, timeZone), to: now });
36
45
  read = { at: now.getTime(), month, fileUsd: rows.reduce((sum, row) => sum + costOf(row.costUsd), 0), keys: new Set(rows.map(usageRowKey)) };
37
46
  cache.set(dataDir, read);
38
47
  }
@@ -48,12 +57,12 @@ export function monthToDateSpend(dataDir, now = new Date()) {
48
57
  * row lands it moves into the cached read, and a re-read that already sees
49
58
  * the row never counts it twice. A write that failed stops counting, as
50
59
  * the ledger has no row for it. */
51
- export function noteSpend(dataDir, row, written) {
60
+ export function noteSpend(dataDir, row, written, timeZone = workspaceTimeZone()) {
52
61
  const costUsd = costOf(row.costUsd);
53
62
  if (!costUsd)
54
63
  return;
55
64
  const key = usageRowKey(row);
56
- const month = row.at.slice(0, 7);
65
+ const month = monthOf(new Date(row.at), timeZone);
57
66
  const entries = unwritten.get(dataDir) ?? new Map();
58
67
  unwritten.set(dataDir, entries);
59
68
  entries.set(key, { month, costUsd });
@@ -68,21 +77,22 @@ export function noteSpend(dataDir, row, written) {
68
77
  }
69
78
  });
70
79
  }
80
+ export { workspaceTimeZone, workspaceTimeZoneStatus } from "./workspace-time-zone.js";
71
81
  export function resetSpendCacheForTests() {
72
82
  cache.clear();
73
83
  unwritten.clear();
74
84
  }
75
85
  /** The cap and where the month stands against it; null when there is no
76
86
  * enforceable cap (no entitlement, or none set). */
77
- export function spendState(cfg, dataDir, now = new Date(), isEntitled = entitled) {
87
+ export function spendState(cfg, dataDir, now = new Date(), isEntitled = entitled, timeZone = workspaceTimeZone()) {
78
88
  const monthlyUsd = cfg.budgets?.monthlyUsd;
79
89
  if (!isEntitled("budgets") || typeof monthlyUsd !== "number" || !Number.isFinite(monthlyUsd) || monthlyUsd <= 0)
80
90
  return null;
81
- const spentUsd = monthToDateSpend(dataDir, now);
91
+ const spentUsd = monthToDateSpend(dataDir, now, timeZone);
82
92
  const warnAtPercent = cfg.budgets?.warnAtPercent ?? DEFAULT_WARN_AT_PERCENT;
83
93
  const percent = Math.min(999, Math.round((spentUsd / monthlyUsd) * 100));
84
94
  return {
85
- month: monthOf(now),
95
+ month: monthOf(now, timeZone),
86
96
  monthlyUsd,
87
97
  spentUsd,
88
98
  percent,
@@ -96,8 +106,8 @@ function usd(value) {
96
106
  return Number.isInteger(Math.round(value * 1000) / 10) ? value.toFixed(2) : value.toFixed(3);
97
107
  }
98
108
  /** Throws the HTTP-shaped refusal a turn start gets once the cap is reached. */
99
- export function assertWithinBudget(cfg, dataDir, now = new Date(), isEntitled = entitled) {
100
- const state = spendState(cfg, dataDir, now, isEntitled);
109
+ export function assertWithinBudget(cfg, dataDir, now = new Date(), isEntitled = entitled, timeZone = workspaceTimeZone()) {
110
+ const state = spendState(cfg, dataDir, now, isEntitled, timeZone);
101
111
  if (!state?.exceeded)
102
112
  return;
103
113
  throw Object.assign(new Error(`this workspace has reached its monthly spend limit of $${usd(state.monthlyUsd)} — an admin can raise it under Settings → Usage`), { status: 409, code: "spend_cap" });
@@ -3,9 +3,10 @@
3
3
  // ProviderSessionDirectory, recipe step 6: persist the binding from day
4
4
  // one). messages-<threadId>.json holds the folded transcript.
5
5
  import { createHash } from "node:crypto";
6
- import { chmodSync, existsSync, readFileSync, mkdirSync, rmSync, statSync, unlinkSync } from "node:fs";
6
+ import { chmodSync, existsSync, mkdirSync, rmSync, statSync, unlinkSync } from "node:fs";
7
7
  import { join } from "node:path";
8
8
  import { writeFileAtomic } from "./atomic.js";
9
+ import { loadRegistry } from "./registry-load.js";
9
10
  import { ensureSections, readSections, changeEmptySection } from "./section-context.js";
10
11
  import { removeBotFolder, soulFile, soulHash, writeSoulMirror } from "./bot-folder.js";
11
12
  import { peerAllowKey } from "./peer-approval-key.js";
@@ -416,18 +417,8 @@ export class Store {
416
417
  mkdirSync(DATA_DIR, { recursive: true });
417
418
  for (const file of [BOTS_FILE, GROUPS_FILE])
418
419
  tightenRegistryFile(file);
419
- try {
420
- this.bots = JSON.parse(readFileSync(BOTS_FILE, "utf8"));
421
- }
422
- catch {
423
- this.bots = [];
424
- }
425
- try {
426
- this.groups = JSON.parse(readFileSync(GROUPS_FILE, "utf8"));
427
- }
428
- catch {
429
- this.groups = [];
430
- }
420
+ this.bots = loadRegistry(BOTS_FILE);
421
+ this.groups = loadRegistry(GROUPS_FILE);
431
422
  this.rememberSections([...this.bots, ...this.groups].map((record) => record.section));
432
423
  // busy never survives a restart — no turn does either. Rooms saved
433
424
  // before default responders existed adopt their first member as lead.
@@ -8,6 +8,7 @@
8
8
  import { spawn } from "node:child_process";
9
9
  import { randomUUID } from "node:crypto";
10
10
  import { StringDecoder } from "node:string_decoder";
11
+ import { withoutHarnessSecrets } from "./child-env.js";
11
12
  const REPLAY_CAP = 64 * 1024;
12
13
  export const MAX_SESSIONS = 8;
13
14
  /** A shell nobody is watching closes after this long. A phone that is put
@@ -60,7 +61,7 @@ export class TerminalRegistry {
60
61
  const wrapped = ptyWrap(spec, this.platform);
61
62
  const child = spawn(wrapped.command, wrapped.args, {
62
63
  cwd: spec.cwd,
63
- env: { ...process.env, TERM: "xterm-256color", COLUMNS: String(spec.cols), LINES: String(spec.rows), ...spec.env },
64
+ env: withoutHarnessSecrets({ ...process.env, TERM: "xterm-256color", COLUMNS: String(spec.cols), LINES: String(spec.rows), ...spec.env }),
64
65
  stdio: ["pipe", "pipe", "pipe"],
65
66
  windowsHide: true,
66
67
  });
@@ -0,0 +1,79 @@
1
+ // The harness side of per-turn proxy tokens on disk (reader: turn-token.ts).
2
+ // Each turn's token is written to DATA_DIR/<kind>-tokens/<digest>.token (0600)
3
+ // and the proxy is given the path, which stays the same across turns. The
4
+ // tokens are revoked when the turn ends, so a leftover file is clutter, not a
5
+ // secret; they are still never exported in a backup.
6
+ import { createHash } from "node:crypto";
7
+ import { mkdirSync, readdirSync, rmSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { writeFileAtomic } from "./atomic.js";
10
+ import { DATA_DIR } from "./config.js";
11
+ export const TURN_TOKEN_KINDS = ["agents", "browser", "phone", "accounts", "computer"];
12
+ const writtenByThread = new Map();
13
+ const swept = new Set();
14
+ /** `scope` separates tokens of one kind that carry different authority inside
15
+ * the same thread (a computer token is bound to one Local VM target). */
16
+ export function turnTokenFile(kind, botId, threadId, scope = "", dataDir = DATA_DIR) {
17
+ const digest = createHash("sha256").update(`${botId}\0${threadId}${scope ? `\0${scope}` : ""}`).digest("hex").slice(0, 24);
18
+ return join(dataDir, `${kind}-tokens`, `${digest}.token`);
19
+ }
20
+ /** Writes this turn's token (0600) and returns the path the proxy reads. */
21
+ export function writeTurnTokenFile(kind, botId, threadId, token, scope = "", dataDir = DATA_DIR) {
22
+ // Capabilities live in this process's memory, so before its first write
23
+ // every file already on disk belongs to a turn that can no longer be live.
24
+ if (!swept.has(dataDir))
25
+ sweepTurnTokenFiles(dataDir);
26
+ const path = turnTokenFile(kind, botId, threadId, scope, dataDir);
27
+ mkdirSync(join(dataDir, `${kind}-tokens`), { recursive: true, mode: 0o700 });
28
+ writeFileAtomic(path, token, { mode: 0o600 });
29
+ const written = writtenByThread.get(threadId) ?? new Set();
30
+ written.add(path);
31
+ writtenByThread.set(threadId, written);
32
+ return path;
33
+ }
34
+ export function writeAgentsTokenFile(botId, threadId, token, dataDir = DATA_DIR) {
35
+ return writeTurnTokenFile("agents", botId, threadId, token, "", dataDir);
36
+ }
37
+ /** The env pair a proxy is spawned with: the token, and the file to prefer. */
38
+ export function turnTokenEnv(kind, tokenVar, botId, threadId, token) {
39
+ return { [tokenVar]: token, [`${tokenVar}_FILE`]: writeTurnTokenFile(kind, botId, threadId, token) };
40
+ }
41
+ /** A computer-control token with its file, keyed by the desktop it is for. */
42
+ export function controlTurnToken(botId, threadId, target, token, dataDir = DATA_DIR) {
43
+ return { token, tokenFile: writeTurnTokenFile("computer", botId, threadId, token, target ? JSON.stringify(target) : "", dataDir) };
44
+ }
45
+ /** Removes the token files written for a thread that no longer exists. */
46
+ export function forgetThreadTurnTokens(threadId) {
47
+ for (const path of writtenByThread.get(threadId) ?? [])
48
+ rmSync(path, { force: true });
49
+ writtenByThread.delete(threadId);
50
+ }
51
+ /** Removes every token file left by an earlier server process and returns how
52
+ * many. Runs once per data directory, before this process writes its first
53
+ * token. Only `*.token` and interrupted temp files are touched. */
54
+ export function sweepTurnTokenFiles(dataDir = DATA_DIR) {
55
+ swept.add(dataDir);
56
+ let removed = 0;
57
+ for (const kind of TURN_TOKEN_KINDS) {
58
+ const dir = join(dataDir, `${kind}-tokens`);
59
+ let names;
60
+ try {
61
+ names = readdirSync(dir);
62
+ }
63
+ catch {
64
+ continue;
65
+ }
66
+ for (const name of names) {
67
+ if (!/\.token(?:\.[^/]*\.tmp)?$/.test(name))
68
+ continue;
69
+ try {
70
+ rmSync(join(dir, name), { force: true });
71
+ removed += 1;
72
+ }
73
+ catch {
74
+ // a file we cannot remove is retried at the next start
75
+ }
76
+ }
77
+ }
78
+ return removed;
79
+ }
@@ -0,0 +1,23 @@
1
+ // How a spawned proxy learns its current turn token. Imported by proxy
2
+ // entries, so it must stay free of server state (node:fs only).
3
+ //
4
+ // An engine may keep a proxy process across turns (pooled ACP sessions, Atomic
5
+ // Engine), while the harness revokes each turn's token when the next begins.
6
+ // The harness therefore rewrites `<VAR>_FILE` every turn and the proxy reads it
7
+ // per request. `<VAR>` itself is the spawn-time token, used where no file
8
+ // exists (cloud boxes, external runtimes, tests, engines that respawn proxies).
9
+ import { readFileSync } from "node:fs";
10
+ export function turnTokenReader(env, tokenVar) {
11
+ const file = env[`${tokenVar}_FILE`];
12
+ const fallback = env[tokenVar]?.trim() ?? "";
13
+ if (!file)
14
+ return () => fallback;
15
+ return () => {
16
+ try {
17
+ return readFileSync(file, "utf8").trim() || fallback;
18
+ }
19
+ catch {
20
+ return fallback;
21
+ }
22
+ };
23
+ }
@@ -4,6 +4,7 @@
4
4
  // The piping, drain-safe exit, and dead-transport watchdog live in
5
5
  // mcp-bridge.ts, shared with the Local VM entry point.
6
6
  import { runMcpBridge } from "./mcp-bridge.js";
7
+ import { turnTokenReader } from "./turn-token.js";
7
8
  import { vpsContainerMcpArgs, vpsDockerArgs } from "./vps-computer.js";
8
9
  const [alias, containerName] = process.argv.slice(2);
9
10
  const sshAlias = alias ?? "";
@@ -18,7 +19,7 @@ catch {
18
19
  // The who-is-driving pair rides in env, not argv — argv is world-readable
19
20
  // through `ps`, and the token guards a loopback endpoint.
20
21
  const controlUrl = process.env.OMB_CONTROL_URL ?? "";
21
- const controlToken = process.env.OMB_CONTROL_TOKEN ?? "";
22
+ const controlToken = turnTokenReader(process.env, "OMB_CONTROL_TOKEN");
22
23
  runMcpBridge({
23
24
  command: "docker",
24
25
  args,
@@ -27,5 +28,5 @@ runMcpBridge({
27
28
  // driver: a busy desktop mid-tool-call must never look dead, while an
28
29
  // unreachable VPS must, and `docker version` distinguishes exactly that.
29
30
  liveness: { command: "docker", args: vpsDockerArgs(sshAlias, ["version", "--format", "{{.Server.Version}}"]) },
30
- ...(controlUrl && controlToken ? { gate: { url: controlUrl, token: controlToken } } : {}),
31
+ ...(controlUrl && controlToken() ? { gate: { url: controlUrl, token: controlToken } } : {}),
31
32
  });
@@ -77,6 +77,16 @@ function fromSlack(req) {
77
77
  }
78
78
  const slackChallengeSchema = z.object({ type: z.literal("url_verification"), challenge: z.string().min(1).max(512) });
79
79
  const slackEventIdSchema = z.object({ event_id: z.string().min(1).max(200) });
80
+ /** A malformed escape cannot be anyone's secret: keep the raw segment so it
81
+ * fails authorization like any other wrong secret instead of throwing. */
82
+ function decodePathSecret(segment) {
83
+ try {
84
+ return decodeURIComponent(segment);
85
+ }
86
+ catch {
87
+ return segment;
88
+ }
89
+ }
80
90
  export function createWebhookIngressHandler(manager, claimRequest) {
81
91
  return async (req, res) => {
82
92
  const url = new URL(req.url ?? "/", "http://localhost");
@@ -91,7 +101,7 @@ export function createWebhookIngressHandler(manager, claimRequest) {
91
101
  let release;
92
102
  try {
93
103
  release = claimRequest?.();
94
- const pathSecret = match[2] ? decodeURIComponent(match[2]) : "";
104
+ const pathSecret = match[2] ? decodePathSecret(match[2]) : "";
95
105
  const secret = pathSecret || bearerSecret(req);
96
106
  // Reject bad capability URLs before buffering or parsing attacker input.
97
107
  if (!manager.authorize(match[1], secret)) {