even-keel 0.2.4 → 0.3.0-rc.2

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 (477) hide show
  1. package/.claude-plugin/marketplace.json +16 -4
  2. package/.env.example +2 -2
  3. package/CHANGELOG.md +23 -0
  4. package/README.md +10 -8
  5. package/dist/src/account/aws.js +76 -0
  6. package/dist/src/account/azure.js +36 -0
  7. package/dist/src/account/cloud-errors.js +72 -0
  8. package/dist/src/account/cloud.js +335 -0
  9. package/dist/src/account/credit.js +49 -7
  10. package/dist/src/account/gcloud.js +71 -0
  11. package/dist/src/account/header-levels.js +3 -2
  12. package/dist/src/account/homes.js +49 -5
  13. package/dist/src/account/keycheck.js +57 -4
  14. package/dist/src/account/management.js +41 -0
  15. package/dist/src/account/model.js +41 -18
  16. package/dist/src/account/network.js +8 -3
  17. package/dist/src/account/service-defaults.js +12 -3
  18. package/dist/src/account/settingsGuard.js +92 -0
  19. package/dist/src/account/settingsGuardStrip.js +36 -0
  20. package/dist/src/account/settingsHook.js +15 -0
  21. package/dist/src/account/settingsLayer.js +190 -0
  22. package/dist/src/account/settingsUninstall.js +7 -0
  23. package/dist/src/account/share.js +23 -6
  24. package/dist/src/account/spend.js +155 -0
  25. package/dist/src/account/watcher.js +189 -24
  26. package/dist/src/agent/adapters.js +13 -2
  27. package/dist/src/agent/env.js +22 -7
  28. package/dist/src/agent/model-slots.js +32 -0
  29. package/dist/src/agent/process.js +32 -6
  30. package/dist/src/agent/projectRules.js +3 -2
  31. package/dist/src/agent/providers.js +18 -1
  32. package/dist/src/agent/scripted.js +319 -0
  33. package/dist/src/agent/windows.js +35 -3
  34. package/dist/src/badge/action.js +41 -0
  35. package/dist/src/badge/check.js +60 -0
  36. package/dist/src/badge/collect.js +174 -0
  37. package/dist/src/badge/dates.js +29 -0
  38. package/dist/src/badge/drawing.js +3 -0
  39. package/dist/src/badge/fonts.generated.js +11 -0
  40. package/dist/src/badge/model.js +9 -0
  41. package/dist/src/badge/privacy.js +151 -0
  42. package/dist/src/badge/push.js +117 -0
  43. package/dist/src/badge/render.js +490 -0
  44. package/dist/src/badge/settings.js +43 -0
  45. package/dist/src/badge/stats.js +31 -0
  46. package/dist/src/badge/status.js +57 -0
  47. package/dist/src/badge/text.js +52 -0
  48. package/dist/src/badge/theme.js +54 -0
  49. package/dist/src/badge/translate.js +162 -0
  50. package/dist/src/builtin/adapter.js +40 -0
  51. package/dist/src/builtin/control.js +179 -0
  52. package/dist/src/builtin/editor.js +117 -0
  53. package/dist/src/builtin/export-store.js +67 -0
  54. package/dist/src/builtin/export.js +202 -0
  55. package/dist/src/builtin/exporting.js +25 -0
  56. package/dist/src/builtin/files.js +155 -0
  57. package/dist/src/builtin/links.js +25 -0
  58. package/dist/src/builtin/model.js +59 -0
  59. package/dist/src/builtin/routes.js +108 -0
  60. package/dist/src/builtin/source.js +240 -0
  61. package/dist/src/builtin/store.js +520 -0
  62. package/dist/src/builtin/switch.js +77 -0
  63. package/dist/src/chain/answers.js +27 -0
  64. package/dist/src/chain/archive.js +0 -1
  65. package/dist/src/chain/dispatcher.js +105 -12
  66. package/dist/src/chain/fence.js +30 -0
  67. package/dist/src/chain/handover.js +27 -9
  68. package/dist/src/chain/launches.js +4 -4
  69. package/dist/src/chain/limitNotice.js +1 -1
  70. package/dist/src/chain/lists.js +42 -6
  71. package/dist/src/chain/log.js +3 -1
  72. package/dist/src/chain/maincheck.js +116 -10
  73. package/dist/src/chain/mainci.js +26 -7
  74. package/dist/src/chain/mainfix.js +12 -1
  75. package/dist/src/chain/milestone-sequence.js +40 -0
  76. package/dist/src/chain/milestones.js +3 -2
  77. package/dist/src/chain/order.js +20 -5
  78. package/dist/src/chain/overage.js +7 -2
  79. package/dist/src/chain/places.js +1 -1
  80. package/dist/src/chain/prompts.js +64 -6
  81. package/dist/src/chain/relay.js +35 -14
  82. package/dist/src/chain/reviews.js +8 -4
  83. package/dist/src/chain/rules.js +40 -11
  84. package/dist/src/chain/snapshots.js +2 -0
  85. package/dist/src/chain/start.js +21 -1
  86. package/dist/src/chain/store.js +16 -6
  87. package/dist/src/chain/unchanged.js +68 -5
  88. package/dist/src/ci/adapters.js +3 -1
  89. package/dist/src/ci/forgejo-profile.js +3 -24
  90. package/dist/src/ci/forgejo.js +2 -1
  91. package/dist/src/ci/github.js +10 -2
  92. package/dist/src/ci/gitlab.js +10 -3
  93. package/dist/src/ci/http.js +4 -0
  94. package/dist/src/ci/model.js +79 -6
  95. package/dist/src/ci/report.js +6 -3
  96. package/dist/src/ci/shared.js +9 -0
  97. package/dist/src/ci/verdict.js +18 -7
  98. package/dist/src/ci/watcher.js +95 -23
  99. package/dist/src/ci/wiring.js +15 -0
  100. package/dist/src/claude/adapter.js +34 -8
  101. package/dist/src/claude/cli.js +32 -8
  102. package/dist/src/claude/instructions.js +42 -7
  103. package/dist/src/claude/oauth.js +67 -0
  104. package/dist/src/claude/sdk/host.js +9 -4
  105. package/dist/src/claude/tree.js +45 -14
  106. package/dist/src/cli-check/run.js +3 -3
  107. package/dist/src/cli-check/support.js +4 -4
  108. package/dist/src/cli.js +54 -17
  109. package/dist/src/codex/adapter.js +2 -0
  110. package/dist/src/codex/cli.js +34 -18
  111. package/dist/src/codex/protection.js +17 -11
  112. package/dist/src/codex/rollout.js +9 -2
  113. package/dist/src/codex/turns.js +6 -3
  114. package/dist/src/codex/window.js +14 -0
  115. package/dist/src/config-form.js +63 -7
  116. package/dist/src/config-store.js +29 -7
  117. package/dist/src/config.js +45 -15
  118. package/dist/src/copilot/adapter.js +2 -0
  119. package/dist/src/copilot/cli.js +8 -11
  120. package/dist/src/copilot/home.js +1 -1
  121. package/dist/src/copilot/transcript.js +1 -2
  122. package/dist/src/demo/agent.js +97 -0
  123. package/dist/src/demo/model.js +6 -0
  124. package/dist/src/demo/scenario.js +139 -0
  125. package/dist/src/demo/service.js +161 -0
  126. package/dist/src/diagnostics/stop.js +16 -0
  127. package/dist/src/env-file.js +4 -0
  128. package/dist/src/error-reason.js +10 -0
  129. package/dist/src/event-log/log.js +97 -0
  130. package/dist/src/event-log/model.js +1 -0
  131. package/dist/src/event-log/page-events.js +71 -0
  132. package/dist/src/event-log/watch.js +236 -0
  133. package/dist/src/events.js +57 -1
  134. package/dist/src/forgejo/adapter.js +49 -0
  135. package/dist/src/forgejo/api.js +95 -0
  136. package/dist/src/forgejo/editor.js +196 -0
  137. package/dist/src/forgejo/model.js +90 -0
  138. package/dist/src/forgejo/profile.js +24 -0
  139. package/dist/src/forgejo/source.js +292 -0
  140. package/dist/src/forgejo/trust.js +45 -0
  141. package/dist/src/git/branches.js +88 -0
  142. package/dist/src/git/clone-progress.js +168 -0
  143. package/dist/src/git/remote-run.js +162 -0
  144. package/dist/src/git/run.js +6 -2
  145. package/dist/src/git/setup.js +4 -5
  146. package/dist/src/git/slot.js +9 -7
  147. package/dist/src/git/worktree.js +13 -10
  148. package/dist/src/github/adapter.js +1 -0
  149. package/dist/src/github/editor.js +214 -0
  150. package/dist/src/github/edits.js +31 -0
  151. package/dist/src/github/model.js +10 -4
  152. package/dist/src/github/source.js +66 -15
  153. package/dist/src/gitlab/adapter.js +1 -0
  154. package/dist/src/gitlab/api.js +4 -2
  155. package/dist/src/gitlab/editor.js +248 -0
  156. package/dist/src/gitlab/model.js +43 -4
  157. package/dist/src/gitlab/source.js +113 -22
  158. package/dist/src/guard.js +26 -10
  159. package/dist/src/hotkeys.js +51 -0
  160. package/dist/src/huly/adapter.js +1 -0
  161. package/dist/src/huly/collab.js +15 -0
  162. package/dist/src/huly/editor.js +241 -0
  163. package/dist/src/huly/marks.js +48 -0
  164. package/dist/src/huly/model.js +22 -5
  165. package/dist/src/huly/source.js +111 -48
  166. package/dist/src/intake/github.js +10 -0
  167. package/dist/src/intake/intake.js +41 -1
  168. package/dist/src/intake/model.js +8 -3
  169. package/dist/src/jira/adapter.js +1 -0
  170. package/dist/src/jira/api.js +28 -7
  171. package/dist/src/jira/editor.js +243 -0
  172. package/dist/src/jira/model.js +19 -5
  173. package/dist/src/jira/source.js +41 -9
  174. package/dist/src/jobs/model.js +1 -0
  175. package/dist/src/jobs/runner.js +236 -0
  176. package/dist/src/limits/chatgpt.js +11 -0
  177. package/dist/src/limits/copilot.js +51 -18
  178. package/dist/src/limits/model.js +62 -8
  179. package/dist/src/limits/overage-session.js +2 -2
  180. package/dist/src/limits/overage.js +8 -5
  181. package/dist/src/limits/reset.js +7 -0
  182. package/dist/src/limits/usage.js +60 -5
  183. package/dist/src/linear/adapter.js +1 -0
  184. package/dist/src/linear/editor.js +220 -0
  185. package/dist/src/linear/estimate.js +32 -0
  186. package/dist/src/linear/model.js +24 -3
  187. package/dist/src/linear/source.js +74 -21
  188. package/dist/src/main.js +53 -23
  189. package/dist/src/notice/en-advice.js +28 -0
  190. package/dist/src/notice/en-review.js +29 -0
  191. package/dist/src/notice/en-startup.js +21 -0
  192. package/dist/src/notice/en-values.js +47 -0
  193. package/dist/src/notice/en.js +265 -96
  194. package/dist/src/notice/kinds.js +26 -0
  195. package/dist/src/notice/notice.js +49 -6
  196. package/dist/src/npm-access.js +58 -0
  197. package/dist/src/opencode/adapter.js +4 -2
  198. package/dist/src/opencode/cli.js +34 -25
  199. package/dist/src/opencode/go.js +51 -0
  200. package/dist/src/opencode/home.js +41 -8
  201. package/dist/src/opencode/transcript.js +5 -5
  202. package/dist/src/opencode/usage.js +10 -4
  203. package/dist/src/opencode/window.js +54 -0
  204. package/dist/src/packages/check.js +11 -5
  205. package/dist/src/packages/gateway.js +76 -6
  206. package/dist/src/packages/launch.js +6 -3
  207. package/dist/src/packages/model.js +61 -2
  208. package/dist/src/packages/npm.js +55 -6
  209. package/dist/src/packages/plugins.js +23 -2
  210. package/dist/src/packages/service.js +104 -17
  211. package/dist/src/packages/settings.js +13 -0
  212. package/dist/src/packages/store.js +1 -1
  213. package/dist/src/paths.js +32 -0
  214. package/dist/src/profiles/control.js +1 -0
  215. package/dist/src/profiles/model.js +2 -2
  216. package/dist/src/profiles/oauth-error.js +1 -9
  217. package/dist/src/profiles/oauth-response.js +2 -0
  218. package/dist/src/profiles/service.js +46 -4
  219. package/dist/src/profiles/store.js +10 -5
  220. package/dist/src/projects/add.js +25 -2
  221. package/dist/src/projects/branch-control.js +86 -0
  222. package/dist/src/projects/branch-move.js +39 -0
  223. package/dist/src/projects/branch.js +13 -0
  224. package/dist/src/projects/check.js +80 -36
  225. package/dist/src/projects/creation.js +166 -0
  226. package/dist/src/projects/git-found.js +62 -0
  227. package/dist/src/projects/git-mode.js +116 -0
  228. package/dist/src/projects/own-folder.js +8 -0
  229. package/dist/src/projects/place.js +235 -0
  230. package/dist/src/projects/remote-branches.js +24 -0
  231. package/dist/src/projects/target-read.js +95 -0
  232. package/dist/src/projects/target.js +56 -0
  233. package/dist/src/review/events.js +1 -1
  234. package/dist/src/review/note.js +58 -0
  235. package/dist/src/review/open.js +3 -3
  236. package/dist/src/review/wiring.js +25 -3
  237. package/dist/src/secrets/catalog.js +4 -1
  238. package/dist/src/server-control.js +1 -0
  239. package/dist/src/server-guard.js +4 -0
  240. package/dist/src/server-request.js +88 -10
  241. package/dist/src/server-response.js +143 -0
  242. package/dist/src/server-security.js +16 -0
  243. package/dist/src/server.js +105 -117
  244. package/dist/src/service/account-packages.js +116 -0
  245. package/dist/src/service/accounts.js +109 -81
  246. package/dist/src/service/badge-private.js +62 -0
  247. package/dist/src/service/badge.js +203 -0
  248. package/dist/src/service/chain-prompts.js +87 -0
  249. package/dist/src/service/chain.js +120 -190
  250. package/dist/src/service/cleanup.js +114 -0
  251. package/dist/src/service/cli-check.js +1 -1
  252. package/dist/src/service/closing.js +57 -0
  253. package/dist/src/service/demo.js +46 -0
  254. package/dist/src/service/hosting.js +239 -18
  255. package/dist/src/service/install-check.js +78 -0
  256. package/dist/src/service/lifecycle.js +4 -7
  257. package/dist/src/service/stats.js +3 -3
  258. package/dist/src/service/trackers.js +27 -1
  259. package/dist/src/service/vocabulary.js +17 -0
  260. package/dist/src/service.js +215 -19
  261. package/dist/src/sessions/agents.js +10 -2
  262. package/dist/src/sessions/approvals.js +1 -1
  263. package/dist/src/sessions/ask.js +32 -6
  264. package/dist/src/sessions/boot.js +7 -0
  265. package/dist/src/sessions/chat.js +16 -4
  266. package/dist/src/sessions/commandPrompt.js +13 -6
  267. package/dist/src/sessions/history.js +2 -0
  268. package/dist/src/sessions/keepwarm.js +1 -1
  269. package/dist/src/sessions/launch.js +21 -25
  270. package/dist/src/sessions/lingering.js +30 -7
  271. package/dist/src/sessions/mail.js +7 -6
  272. package/dist/src/sessions/mailRelay.js +2 -2
  273. package/dist/src/sessions/mailbox.js +1 -1
  274. package/dist/src/sessions/monitor.js +47 -3
  275. package/dist/src/sessions/note.js +44 -19
  276. package/dist/src/sessions/permission.js +32 -10
  277. package/dist/src/sessions/protection.js +38 -14
  278. package/dist/src/sessions/rare.js +130 -0
  279. package/dist/src/sessions/runs-store.js +20 -0
  280. package/dist/src/sessions/runs.js +140 -0
  281. package/dist/src/sessions/tail.js +4 -0
  282. package/dist/src/sessions/transcript.js +64 -8
  283. package/dist/src/settings/defaults.js +1 -0
  284. package/dist/src/settings/registry.js +86 -24
  285. package/dist/src/settings/store.js +14 -5
  286. package/dist/src/setup.js +5 -0
  287. package/dist/src/shown-work.js +22 -0
  288. package/dist/src/state/settings.js +1 -0
  289. package/dist/src/stats/base-sql.js +7 -1
  290. package/dist/src/stats/checkpoint.js +8 -5
  291. package/dist/src/stats/model.js +1 -1
  292. package/dist/src/stats/reader.js +50 -25
  293. package/dist/src/stats/rules-reader.js +6 -2
  294. package/dist/src/stats/steps-reader.js +5 -0
  295. package/dist/src/stats/tally-schema.js +1 -1
  296. package/dist/src/storage/backup-model.js +3 -0
  297. package/dist/src/storage/backup-schedule.js +197 -0
  298. package/dist/src/storage/backup-worker.js +9 -0
  299. package/dist/src/storage/backup.js +141 -0
  300. package/dist/src/storage/browser-hotkeys.js +25 -0
  301. package/dist/src/storage/context-windows.js +39 -0
  302. package/dist/src/storage/copy.js +44 -13
  303. package/dist/src/storage/database.js +343 -4
  304. package/dist/src/storage/left-folders.js +16 -0
  305. package/dist/src/storage/migrations.js +98 -1
  306. package/dist/src/storage/owner.js +12 -7
  307. package/dist/src/storage/schema.js +1 -1
  308. package/dist/src/storage/startup.js +25 -0
  309. package/dist/src/storage/state-files.js +1 -1
  310. package/dist/src/storage/vacuum.js +29 -0
  311. package/dist/src/taskmcp/args.js +146 -0
  312. package/dist/src/taskmcp/calls.js +741 -0
  313. package/dist/src/taskmcp/downloads.js +87 -0
  314. package/dist/src/taskmcp/files.js +58 -0
  315. package/dist/src/taskmcp/retries.js +57 -0
  316. package/dist/src/taskmcp/server.js +81 -0
  317. package/dist/src/taskmcp/tools.js +128 -0
  318. package/dist/src/taskmcp/vocabulary.js +75 -0
  319. package/dist/src/tools/panel.js +41 -8
  320. package/dist/src/tools/sessionSettings.js +2 -1
  321. package/dist/src/tools/settings.js +16 -3
  322. package/dist/src/tracker/adapters.js +3 -1
  323. package/dist/src/tracker/card.js +16 -12
  324. package/dist/src/tracker/close.js +57 -0
  325. package/dist/src/tracker/closer.js +18 -15
  326. package/dist/src/tracker/closes.js +6 -0
  327. package/dist/src/tracker/control.js +32 -13
  328. package/dist/src/tracker/diagnostics.js +5 -2
  329. package/dist/src/tracker/editor.js +108 -0
  330. package/dist/src/tracker/export-target.js +30 -0
  331. package/dist/src/tracker/export.js +168 -0
  332. package/dist/src/tracker/health.js +5 -0
  333. package/dist/src/tracker/link.js +127 -24
  334. package/dist/src/tracker/markers.js +7 -0
  335. package/dist/src/tracker/model.js +0 -12
  336. package/dist/src/tracker/parents.js +8 -0
  337. package/dist/src/tracker/questions.js +24 -3
  338. package/dist/src/tracker/readers.js +19 -3
  339. package/dist/src/tracker/source.js +5 -0
  340. package/dist/src/tracker/start.js +61 -6
  341. package/dist/src/tracker/templates.js +102 -0
  342. package/dist/src/tracker/trackers.js +20 -10
  343. package/dist/src/updates/runner.js +1 -1
  344. package/dist/src/updates/settle.js +11 -3
  345. package/dist/src/updates/updater.js +4 -4
  346. package/dist/tally/src/builtin-tasks.js +45 -0
  347. package/dist/tally/src/catalogue.js +70 -0
  348. package/dist/tally/src/classify.js +1 -0
  349. package/dist/tally/src/collect.js +33 -10
  350. package/dist/tally/src/copilot.js +1 -0
  351. package/dist/tally/src/db-classify.js +46 -0
  352. package/dist/tally/src/db.js +66 -60
  353. package/dist/tally/src/migrations/10-rework-label.sql +73 -0
  354. package/dist/tally/src/migrations/11-catalogue-prices.sql +53 -0
  355. package/dist/tally/src/migrations/12-key-spends.sql +30 -0
  356. package/dist/tally/src/migrations/13-normal-spans.sql +110 -0
  357. package/dist/tally/src/migrations/14-model-families.sql +25 -0
  358. package/dist/tally/src/migrations/15-task-moves.sql +32 -0
  359. package/dist/tally/src/migrations.js +1 -1
  360. package/dist/tally/src/opencode.js +1 -0
  361. package/dist/tally/src/parse.js +3 -0
  362. package/dist/tally/src/rollout.js +2 -1
  363. package/dist/tally/src/rule-hook-size.js +2 -1
  364. package/dist/tally/src/rule-hook.js +3 -0
  365. package/dist/tally/src/task-moves.js +32 -0
  366. package/dist/web/assets/BadgeDialog-Dx2EERWr.js +1 -0
  367. package/dist/web/assets/BadgeDialog-W0giN4k2.css +1 -0
  368. package/dist/web/assets/DescriptionEditor-BL_6314d.js +216 -0
  369. package/dist/web/assets/ProjectPackages-D-Hqs0sG.js +1 -0
  370. package/dist/web/assets/Select-B5xZpiCG.js +1 -0
  371. package/dist/web/assets/Select-CYemy5Na.css +1 -0
  372. package/dist/web/assets/TaskCard-B9EJ_Qa2.js +2 -0
  373. package/dist/web/assets/TaskCard-BV2lQojC.css +1 -0
  374. package/dist/web/assets/TranscriptWindow-BN6jSpev.css +1 -0
  375. package/dist/web/assets/TranscriptWindow-E8DxggYC.js +4 -0
  376. package/dist/web/assets/accountParts-c2gPSGKK.js +3 -0
  377. package/dist/web/assets/accountParts-tFRVownp.css +1 -0
  378. package/dist/web/assets/blocks-B03KxlgQ.js +12 -0
  379. package/dist/web/assets/blocks-Dx3DACiG.css +1 -0
  380. package/dist/web/assets/cardDrafts-Cb5dNpJ3.js +12 -0
  381. package/dist/web/assets/cardDrafts-izWnctoh.css +1 -0
  382. package/dist/web/assets/cardSide-63fNWHHv.css +1 -0
  383. package/dist/web/assets/cardSide-CIGvmTwG.js +2 -0
  384. package/dist/web/assets/description-C-o9LBbp.css +1 -0
  385. package/dist/web/assets/feedLine-Buzox_AA.js +1 -0
  386. package/dist/web/assets/feedLine-CBjZXWwX.css +1 -0
  387. package/dist/web/assets/hooks-DdmIE6gF.js +1 -0
  388. package/dist/web/assets/index-CkYiatZt.css +1 -0
  389. package/dist/web/assets/index-DELgEMlH.js +25 -0
  390. package/dist/web/assets/lib-B8qNeB0X.css +1 -0
  391. package/dist/web/assets/lib-C1i2rKJZ.js +18 -0
  392. package/dist/web/assets/overview-B7iEgjQD.css +1 -0
  393. package/dist/web/assets/overview-D9PUjFeR.js +7 -0
  394. package/dist/web/assets/packageGroups-B34vA6-0.js +1 -0
  395. package/dist/web/assets/packages-Dld4uH9X.css +1 -0
  396. package/dist/web/assets/react-dom-vGPErQYp.js +1 -0
  397. package/dist/web/assets/rules-BVB-I2tg.js +1 -0
  398. package/dist/web/assets/rules-Bgil4ZBp.css +1 -0
  399. package/dist/web/assets/secret-CmK85pY6.js +1 -0
  400. package/dist/web/assets/secret-DldsC74x.css +1 -0
  401. package/dist/web/assets/useFileDrop-eZtIxL1H.js +1 -0
  402. package/dist/web/assets/useHeightGlide-BmtdsmN0.css +1 -0
  403. package/dist/web/assets/useHeightGlide-DQvvOoIL.js +3 -0
  404. package/dist/web/assets/useRowFocus-CwOoEmzD.js +1 -0
  405. package/dist/web/index.html +30 -9
  406. package/dist/web/theme.js +6 -0
  407. package/even-keel.config.example.json +5 -4
  408. package/package.json +21 -5
  409. package/plugins/agent-bridge/.claude-plugin/plugin.json +16 -0
  410. package/plugins/{checkpoint → agent-bridge}/README.md +20 -6
  411. package/plugins/agent-bridge/hooks/addressban.mjs +64 -0
  412. package/plugins/{checkpoint → agent-bridge}/hooks/checkpoint-mark.mjs +4 -3
  413. package/plugins/{checkpoint → agent-bridge}/hooks/evenkeel.mjs +28 -11
  414. package/plugins/agent-bridge/hooks/git-ban.mjs +31 -0
  415. package/plugins/agent-bridge/hooks/gitban.mjs +83 -0
  416. package/plugins/agent-bridge/hooks/handoff.mjs +20 -0
  417. package/plugins/{checkpoint → agent-bridge}/hooks/hooks.json +10 -0
  418. package/plugins/{checkpoint → agent-bridge}/hooks/mailbox.mjs +6 -3
  419. package/plugins/{checkpoint → agent-bridge}/hooks/nudges.mjs +11 -7
  420. package/plugins/{checkpoint/opencode/checkpoint.mjs → agent-bridge/opencode/agent-bridge.mjs} +15 -9
  421. package/plugins/forgejo/.claude-plugin/plugin.json +7 -0
  422. package/plugins/forgejo/.mcp.json +13 -0
  423. package/plugins/forgejo/README.md +23 -0
  424. package/plugins/forgejo/skills/task/SKILL.md +55 -0
  425. package/plugins/github/.claude-plugin/plugin.json +1 -1
  426. package/plugins/github/README.md +1 -1
  427. package/plugins/github/skills/task/SKILL.md +2 -2
  428. package/plugins/gitlab/.claude-plugin/plugin.json +1 -1
  429. package/plugins/gitlab/skills/task/SKILL.md +2 -2
  430. package/plugins/huly/.claude-plugin/plugin.json +1 -1
  431. package/plugins/huly/skills/task/SKILL.md +4 -4
  432. package/plugins/jira/.claude-plugin/plugin.json +1 -1
  433. package/plugins/jira/skills/task/SKILL.md +3 -3
  434. package/plugins/linear/.claude-plugin/plugin.json +1 -1
  435. package/plugins/linear/README.md +1 -1
  436. package/plugins/linear/skills/task/SKILL.md +3 -3
  437. package/plugins/tally/.claude-plugin/plugin.json +1 -1
  438. package/plugins/tally/skills/session-audit/SKILL.md +5 -5
  439. package/plugins/tasks/.claude-plugin/plugin.json +9 -0
  440. package/plugins/tasks/.mcp.json +8 -0
  441. package/plugins/tasks/README.md +42 -0
  442. package/plugins/tasks/hooks/calibration-context.mjs +45 -0
  443. package/plugins/tasks/hooks/calibration.mjs +92 -0
  444. package/plugins/tasks/hooks/check-service.mjs +15 -0
  445. package/plugins/tasks/hooks/hooks.json +28 -0
  446. package/plugins/tasks/hooks/service-check.mjs +34 -0
  447. package/plugins/tasks/hooks/show-calibration.mjs +19 -0
  448. package/plugins/tasks/opencode/tasks.mjs +28 -0
  449. package/plugins/tasks/skills/split/SKILL.md +29 -0
  450. package/plugins/tasks/skills/task/SKILL.md +61 -0
  451. package/service/EvenKeelTray.cs +4 -20
  452. package/service/install.sh +25 -2
  453. package/service/uninstall.ps1 +16 -0
  454. package/service/uninstall.sh +10 -0
  455. package/tally/tally.config.json +2 -0
  456. package/dist/web/assets/Loader-CRe-GCoI.js +0 -31
  457. package/dist/web/assets/Loader-DJJTBsaF.css +0 -1
  458. package/dist/web/assets/TaskCard-Br2QIllc.css +0 -1
  459. package/dist/web/assets/TaskCard-C2xeaHWD.js +0 -2
  460. package/dist/web/assets/TranscriptWindow-B9zsSmIg.css +0 -1
  461. package/dist/web/assets/TranscriptWindow-COL_WTrF.js +0 -4
  462. package/dist/web/assets/feedLine-D0lnFyBZ.js +0 -1
  463. package/dist/web/assets/index-DQje9Nfo.js +0 -25
  464. package/dist/web/assets/index-mDBlgk2Y.css +0 -1
  465. package/dist/web/assets/media-BlW-XXN0.js +0 -1
  466. package/dist/web/assets/media-DR8nAbPy.css +0 -1
  467. package/dist/web/assets/useModels-1oIk0mDX.css +0 -1
  468. package/dist/web/assets/useModels-DRW63oka.js +0 -15
  469. package/plugins/checkpoint/.claude-plugin/plugin.json +0 -9
  470. package/plugins/checkpoint/hooks/handoff.mjs +0 -9
  471. /package/plugins/{checkpoint → agent-bridge}/hooks/context-checkpoint.mjs +0 -0
  472. /package/plugins/{checkpoint → agent-bridge}/hooks/merge-check.mjs +0 -0
  473. /package/plugins/{checkpoint → agent-bridge}/hooks/merges.mjs +0 -0
  474. /package/plugins/{checkpoint → agent-bridge}/hooks/permission.mjs +0 -0
  475. /package/plugins/{checkpoint → agent-bridge}/hooks/schema-hint.mjs +0 -0
  476. /package/plugins/{checkpoint → agent-bridge}/hooks/standard-gate.mjs +0 -0
  477. /package/plugins/{checkpoint → agent-bridge}/hooks/standards.mjs +0 -0
@@ -1,7 +1,10 @@
1
1
  import { copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, readlinkSync, renameSync, rmdirSync, symlinkSync, unlinkSync, writeFileSync, } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
- import { pathKey, sameSpelling } from '../paths.js';
3
+ import { cloudOf, isCloudVariable } from './cloud.js';
4
+ import { pathKey, samePath, sameSpelling } from '../paths.js';
4
5
  import { projectDirName } from '../sessions/paths.js';
6
+ import { listenOf, localUrlOf } from '../config.js';
7
+ import { stripSettingsGuard, withSettingsGuard } from './settingsGuard.js';
5
8
  const PROJECT_KEYS = [
6
9
  'hasTrustDialogAccepted',
7
10
  'mcpServers',
@@ -18,12 +21,21 @@ const LINKED_DIRS = ['agents', 'commands', 'hooks', 'output-styles'];
18
21
  const OWN_SKILLS = new Set(['synced', '.trash']);
19
22
  export const API_KEY_VARIABLE = 'ANTHROPIC_API_KEY';
20
23
  const COPIED_FILES = ['CLAUDE.md', join('plugins', 'installed_plugins.json'), join('plugins', 'known_marketplaces.json')];
21
- /** The global settings win, except the folder's own API key: it is what makes an API account (`docs/accounts.md`). */
24
+ /**
25
+ * The global settings win, except the folder's own API key and cloud connection: they are what makes an API or a cloud
26
+ * account (`docs/accounts.md`). A cloud folder takes none of the cloud's variables from the global settings.
27
+ */
22
28
  export function mergeSettings(global, folder) {
23
29
  const merged = { ...folder, ...global };
24
- const key = objectOf(folder?.env)[API_KEY_VARIABLE];
30
+ const own = objectOf(folder?.env);
31
+ const key = own[API_KEY_VARIABLE];
25
32
  if (typeof key === 'string')
26
33
  merged.env = { ...objectOf(global.env), [API_KEY_VARIABLE]: key };
34
+ if (cloudOf(own) !== null) {
35
+ const shared = Object.fromEntries(Object.entries(objectOf(merged.env ?? global.env)).filter(([name]) => !isCloudVariable(name)));
36
+ const cloud = Object.fromEntries(Object.entries(own).filter(([name]) => isCloudVariable(name)));
37
+ merged.env = { ...shared, ...cloud };
38
+ }
27
39
  if (folder?.apiKeyHelper !== undefined)
28
40
  merged.apiKeyHelper = folder.apiKeyHelper;
29
41
  return merged;
@@ -70,12 +82,17 @@ export function shareProjects(global, folder, platform = process.platform) {
70
82
  shared[key] = global[key];
71
83
  return JSON.stringify(shared) === JSON.stringify(folder) ? undefined : shared;
72
84
  }
73
- export function shareConfig(global, dir, warn = console.warn) {
85
+ export function shareConfig(global, dir, warn = console.warn, planner = mergeSettings) {
74
86
  mkdirSync(dir, { recursive: true });
75
87
  let changed = false;
76
88
  const settings = readJson(join(global.dir, 'settings.json'));
77
- if (settings !== undefined)
78
- changed = writeIfChanged(join(dir, 'settings.json'), mergeSettings(settings, readJson(join(dir, 'settings.json')))) || changed;
89
+ const folderFile = join(dir, 'settings.json');
90
+ const folder = readJson(folderFile);
91
+ if (!samePath(dir, global.dir) && (folder !== undefined || !existsSync(folderFile))) {
92
+ const merged = planner(stripSettingsGuard(settings ?? {}), folder === undefined ? undefined : stripSettingsGuard(folder));
93
+ const guarded = withSettingsGuard(merged, { accountsDir: dirname(dir), globalDir: global.dir, url: localUrlOf(listenOf(process.env)) });
94
+ changed = writeIfChanged(folderFile, guarded) || changed;
95
+ }
79
96
  const config = readJson(global.config);
80
97
  if (config !== undefined) {
81
98
  const shared = shareProjects(config, readJson(join(dir, '.claude.json')) ?? {});
@@ -0,0 +1,155 @@
1
+ import { OPENROUTER_KEY_URL, openRouterLimit } from './keycheck.js';
2
+ /**
3
+ * Reads an OpenRouter key's description of itself, which any key may read (BTN-860, BTN-847); `null` — no answer, an
4
+ * error or a body that is no description.
5
+ */
6
+ export async function readOpenRouterKey(key, timeoutMs, fetchImpl = fetch) {
7
+ try {
8
+ const response = await fetchImpl(OPENROUTER_KEY_URL, { headers: { authorization: `Bearer ${key}` }, signal: AbortSignal.timeout(timeoutMs) });
9
+ if (!response.ok) {
10
+ await response.body?.cancel();
11
+ return null;
12
+ }
13
+ const body = await response.json();
14
+ const data = typeof body === 'object' && body !== null ? body.data : undefined;
15
+ if (typeof data !== 'object' || data === null)
16
+ return null;
17
+ const usage = data.usage;
18
+ return { usage: typeof usage === 'number' && Number.isFinite(usage) ? usage : null, limit: openRouterLimit(data) };
19
+ }
20
+ catch {
21
+ return null;
22
+ }
23
+ }
24
+ /**
25
+ * The real spend of the sessions on a key that tells it (BTN-860, `docs/tally.md`, "Cost"): the key is read before each
26
+ * turn, at each turn's end and during a tail after the last turn, and the growth between two reads goes to the session
27
+ * that ran in between, or to the last one while its tail lasts. Two sessions in one interval, or busy at once, cannot
28
+ * be told apart: both are marked shared and keep only the estimate by price.
29
+ */
30
+ export class KeySpend {
31
+ options;
32
+ meters = new Map();
33
+ shared = new Set();
34
+ constructor(options) {
35
+ this.options = options;
36
+ }
37
+ /** Reads the key before a turn starts, so what was spent before goes to whoever spent it. */
38
+ async beforeTurn(account) {
39
+ if (!this.options.metered(account))
40
+ return;
41
+ await this.read(account, this.meter(account));
42
+ }
43
+ /** One tick of the session monitor: every session it sees, of every account. */
44
+ observe(entries) {
45
+ const now = this.options.now();
46
+ const busyOf = new Map();
47
+ for (const entry of entries) {
48
+ if (!this.options.metered(entry.account))
49
+ continue;
50
+ const busy = busyOf.get(entry.account) ?? new Set();
51
+ if (entry.busy)
52
+ busy.add(entry.sessionId);
53
+ busyOf.set(entry.account, busy);
54
+ }
55
+ for (const account of this.meters.keys())
56
+ if (!busyOf.has(account) && this.options.metered(account))
57
+ busyOf.set(account, new Set());
58
+ for (const [account, busy] of busyOf) {
59
+ if (busy.size === 0 && !this.meters.has(account))
60
+ continue;
61
+ const meter = this.meter(account);
62
+ // Busy before any read of the key: the turn began before the service started or with its read failed, and
63
+ // the spend up to the first read is lost, so the session keeps the estimate (BTN-871).
64
+ if (busy.size > 1 || (busy.size > 0 && meter.usage === null))
65
+ this.markShared(account, busy);
66
+ for (const sessionId of busy)
67
+ meter.ran.add(sessionId);
68
+ const ended = [...meter.busy].some((sessionId) => !busy.has(sessionId));
69
+ meter.busy = busy;
70
+ if (ended) {
71
+ meter.endedAt = now;
72
+ void this.read(account, meter);
73
+ }
74
+ else if (busy.size === 0 && meter.endedAt !== null) {
75
+ if (now - meter.endedAt > this.options.tailMs) {
76
+ meter.endedAt = null;
77
+ meter.last = null;
78
+ }
79
+ else if (now - meter.triedAt >= this.options.pollMs)
80
+ void this.read(account, meter);
81
+ }
82
+ }
83
+ }
84
+ /** Every read asked for so far has been made. */
85
+ async settled() {
86
+ await Promise.all([...this.meters.values()].map((meter) => meter.reads));
87
+ }
88
+ meter(account) {
89
+ let meter = this.meters.get(account);
90
+ if (meter === undefined) {
91
+ meter = { usage: null, ran: new Set(), busy: new Set(), last: null, endedAt: null, triedAt: 0, reads: Promise.resolve(), queued: null };
92
+ this.meters.set(account, meter);
93
+ }
94
+ return meter;
95
+ }
96
+ read(account, meter) {
97
+ if (meter.queued !== null)
98
+ return meter.queued;
99
+ const queued = meter.reads.then(async () => {
100
+ meter.queued = null;
101
+ const owners = meter.ran;
102
+ meter.ran = new Set(meter.busy);
103
+ meter.triedAt = this.options.now();
104
+ const usage = await this.options.read(account).catch(() => null);
105
+ if (usage === null) {
106
+ for (const sessionId of owners)
107
+ meter.ran.add(sessionId);
108
+ return;
109
+ }
110
+ this.settle(account, meter, owners, usage);
111
+ });
112
+ meter.queued = queued;
113
+ meter.reads = queued;
114
+ return queued;
115
+ }
116
+ settle(account, meter, ran, usage) {
117
+ const owners = ran.size > 0 ? ran : meter.last === null ? new Set() : new Set([meter.last]);
118
+ const growth = meter.usage === null ? 0 : usage - meter.usage;
119
+ meter.usage = usage;
120
+ if (owners.size > 1) {
121
+ this.markShared(account, owners);
122
+ meter.last = null;
123
+ return;
124
+ }
125
+ const [owner] = owners;
126
+ if (owner === undefined)
127
+ return;
128
+ meter.last = owner;
129
+ if (growth > 0 && !this.shared.has(owner)) {
130
+ this.options.onSpend({ sessionId: owner, account, usd: growth, shared: false, at: new Date(this.options.now()).toISOString() });
131
+ }
132
+ }
133
+ markShared(account, sessions) {
134
+ for (const sessionId of sessions) {
135
+ if (this.shared.has(sessionId))
136
+ continue;
137
+ this.shared.add(sessionId);
138
+ this.options.onSpend({ sessionId, account, usd: 0, shared: true, at: new Date(this.options.now()).toISOString() });
139
+ }
140
+ }
141
+ }
142
+ /**
143
+ * Adds a growth to the session's row of `key_spends` (step 35, `docs/storage.md`): the sum grows in SQL, so a write
144
+ * behind never loses another. Starts its write at the call: see `Writes`.
145
+ */
146
+ export async function saveKeySpend(db, growth) {
147
+ await db.query(`insert into key_spends (session_id, account, usd, shared, reads, first_at, last_at) values ($1, $2, $3, $4, 1, $5, $5)
148
+ on conflict (session_id) do update set usd = key_spends.usd + excluded.usd, shared = key_spends.shared or excluded.shared,
149
+ reads = key_spends.reads + 1, last_at = excluded.last_at`, [growth.sessionId, growth.account, growth.usd, growth.shared, growth.at]);
150
+ }
151
+ export async function readKeySpends(db) {
152
+ const { rows } = await db.query('select session_id, account, usd, shared, first_at, last_at from key_spends order by first_at, session_id');
153
+ const iso = (value) => new Date(value).toISOString();
154
+ return rows.map((row) => ({ sessionId: row.session_id, account: row.account, usd: Number(row.usd), shared: row.shared, firstAt: iso(row.first_at), lastAt: iso(row.last_at) }));
155
+ }
@@ -2,14 +2,28 @@ import { NO_SIGN_IN, SIGN_INS } from '../agent/providers.js';
2
2
  import { fail, notice, NoticeError, noticeOf, sameNotice } from '../notice/notice.js';
3
3
  import { appSwitchProblem } from './apps.js';
4
4
  import { assertApiKey, keyProvider } from './homes.js';
5
+ import { consoleKey, readAuth } from '../opencode/home.js';
6
+ import { checkGoKey } from '../opencode/go.js';
5
7
  import { CreditChecks } from './credit.js';
6
8
  import { KeyChecks } from './keycheck.js';
7
- import { cleanOutput, isApiKey, loginBlockNotice, loginCode, loginUrls, missingNotice, needsLogin, removeProblem, secondFreeProblem, switchProblem, takesShared, withIdentity, } from './model.js';
9
+ import { CLAUDE } from '../claude/name.js';
10
+ import { cloudErrorNotice } from './cloud-errors.js';
11
+ import { cleanOutput, isApiKey, loginBlockNotice, loginCode, loginUrls, missingNotice, needsLogin, paysPerToken, removeProblem, secondFreeProblem, switchProblem, takesShared, withIdentity, } from './model.js';
8
12
  const MAX_OUTPUT_CHARS = 16 * 1024;
9
13
  const SHOWN_OUTPUT_CHARS = 2 * 1024;
10
14
  /** What a key refused or not checked says, by whose key it is (`keyProvider`). */
11
- const REJECTED = { anthropic: 'account.apiKeyRejected', openai: 'account.codexKeyRejected', github: 'account.copilotTokenRejected' };
12
- const UNCHECKED = { anthropic: 'account.apiKeyUnchecked', openai: 'account.codexKeyUnchecked', github: 'account.copilotTokenUnchecked' };
15
+ const REJECTED = {
16
+ anthropic: 'account.apiKeyRejected',
17
+ openai: 'account.codexKeyRejected',
18
+ openrouter: 'account.openRouterKeyRejected',
19
+ github: 'account.copilotTokenRejected',
20
+ };
21
+ const UNCHECKED = {
22
+ anthropic: 'account.apiKeyUnchecked',
23
+ openai: 'account.codexKeyUnchecked',
24
+ openrouter: 'account.openRouterKeyUnchecked',
25
+ github: 'account.copilotTokenUnchecked',
26
+ };
13
27
  export class AccountWatcher {
14
28
  options;
15
29
  known = [];
@@ -21,7 +35,14 @@ export class AccountWatcher {
21
35
  output = '';
22
36
  timer;
23
37
  keys;
38
+ aws;
39
+ gcloud;
40
+ azure;
41
+ /** The model each cloud account's check turn answered with, by folder key (BTN-822). */
42
+ checkedModels = new Map();
24
43
  credit;
44
+ /** Each OpenRouter account's balance as its management key last read it, by folder key (BTN-868). */
45
+ balances = new Map();
25
46
  constructor(options) {
26
47
  this.options = options;
27
48
  this.keys = new KeyChecks(options.keyCheckMs);
@@ -36,12 +57,12 @@ export class AccountWatcher {
36
57
  }
37
58
  get view() {
38
59
  const now = this.options.now();
39
- const accounts = this.known.map(({ home, status, error, keyHeld }) => {
60
+ const accounts = this.known.map(({ home, status, error, keyHeld, openRouter, cloud }) => {
40
61
  const times = this.options.homes.times(home);
41
- const transport = this.options.transportOf(home, isApiKey(status));
62
+ const transport = this.options.transportOf(home, paysPerToken(status));
42
63
  const seen = this.options.signedInAs?.(home.key);
43
64
  const signedOut = this.needsLogin(home.key);
44
- const terminalLogin = signedOut && !isApiKey(status) ? this.options.agentOf(home).terminalLogin?.(home) : undefined;
65
+ const terminalLogin = signedOut && !paysPerToken(status) ? this.options.agentOf(home).terminalLogin?.(home) : undefined;
45
66
  return {
46
67
  key: home.key,
47
68
  name: this.options.nameOf(home.key),
@@ -59,14 +80,20 @@ export class AccountWatcher {
59
80
  projects: this.options.projectsOn(home.key),
60
81
  removing: this.options.removing(home.key),
61
82
  configPending: this.options.configPending(home.key),
83
+ ...this.settingsOf(home),
62
84
  apiKey: isApiKey(status),
63
- keyReplaceable: isApiKey(status) && keyHeld,
85
+ keyReplaceable: keyHeld && (isApiKey(status) || status?.authMethod === 'subscription_key'),
86
+ ...(cloud !== null && { cloud }),
87
+ ...(this.checkedModels.has(home.key) && { checkedModel: this.checkedModels.get(home.key) ?? null }),
64
88
  ...(transport !== null && { transport }),
65
89
  limits: this.options.limits(home.key),
66
90
  usage: this.options.usage(home.key),
67
91
  ...(this.options.limitsOutdated?.(home.key) === true && { limitsOutdated: true }),
68
92
  lastLimitAt: this.options.lastLimit?.(home.key) ?? null,
69
93
  spendingLimit: this.credit.spendingLimit(home.key, now),
94
+ ...(this.keys.limit(home.key) !== null && { keyLimit: this.keys.limit(home.key) }),
95
+ ...(openRouter && { managementKey: this.options.managementKeys.of(home.key) !== undefined }),
96
+ ...(openRouter && this.balances.has(home.key) && { balance: this.balances.get(home.key) }),
70
97
  };
71
98
  });
72
99
  return {
@@ -74,6 +101,9 @@ export class AccountWatcher {
74
101
  accounts,
75
102
  login: this.current,
76
103
  ...(this.globalCheck !== undefined && { globalCheck: this.globalCheck }),
104
+ ...(this.aws !== undefined && { aws: this.aws }),
105
+ ...(this.gcloud !== undefined && { gcloud: this.gcloud }),
106
+ ...(this.azure !== undefined && { azure: this.azure }),
77
107
  loginBlock: this.options.loginBlock(),
78
108
  apps: this.options.apps.list(),
79
109
  pool: this.options.pool().filter((entry) => accounts.some((account) => account.key === entry.account && account.agent === entry.provider)),
@@ -90,8 +120,61 @@ export class AccountWatcher {
90
120
  emailOf(key) {
91
121
  return this.known.find((known) => known.home.key === key)?.status?.email ?? null;
92
122
  }
123
+ /** The account pays per token, with a key or on a cloud: no plan limits to poll or wait out. */
93
124
  apiKey(key) {
94
- return isApiKey(this.known.find((known) => known.home.key === key)?.status ?? null);
125
+ return paysPerToken(this.known.find((known) => known.home.key === key)?.status ?? null);
126
+ }
127
+ /**
128
+ * The key's own limit, read between the hourly checks by a read of its spend (`readOpenRouterKey`, BTN-847); null — the
129
+ * key has none. The page hears of a change at once.
130
+ */
131
+ noteKeyLimit(key, limit) {
132
+ if (this.keys.noteLimit(key, limit, this.options.now()))
133
+ this.options.onChange();
134
+ }
135
+ /**
136
+ * Keeps an OpenRouter account's management key once it reads the balance (BTN-868), or removes it on an empty value;
137
+ * a refused key or no answer is thrown and nothing is written. The page hears only that the account has one.
138
+ */
139
+ async setManagementKey(key, value) {
140
+ if (this.options.homes.find(key) === undefined)
141
+ throw fail('account.unknown', { key });
142
+ if (this.known.find((known) => known.home.key === key)?.openRouter !== true)
143
+ throw fail('account.managementKeyNotOpenRouter', {});
144
+ const next = value?.trim() ?? '';
145
+ if (next === '') {
146
+ this.options.managementKeys.forget(key);
147
+ this.balances.delete(key);
148
+ this.options.onChange();
149
+ return;
150
+ }
151
+ const verdict = await this.options.readBalance(next);
152
+ if (verdict.state === 'rejected')
153
+ throw fail('account.managementKeyRejected', {});
154
+ if (verdict.state === 'unknown')
155
+ throw fail('account.managementKeyUnchecked', { reason: verdict.reason });
156
+ this.options.managementKeys.save(key, next);
157
+ this.balances.set(key, { usd: verdict.usd, at: this.options.now().toISOString() });
158
+ this.options.onChange();
159
+ }
160
+ /** Reads the balance of an account that has a management key, between the hourly checks; the page hears of a change. */
161
+ async readBalance(key) {
162
+ if (await this.noteBalance(key))
163
+ this.options.onChange();
164
+ }
165
+ /** True when the balance changed; an answer that tells nothing, or a key replaced meanwhile, keeps the last one. */
166
+ async noteBalance(key) {
167
+ const managementKey = this.options.managementKeys.of(key);
168
+ if (managementKey === undefined)
169
+ return false;
170
+ const verdict = await this.options.readBalance(managementKey);
171
+ if (verdict.state === 'unknown' || this.options.managementKeys.of(key) !== managementKey)
172
+ return false;
173
+ const at = this.options.now().toISOString();
174
+ const before = this.balances.get(key);
175
+ const next = verdict.state === 'ok' ? { usd: verdict.usd, at } : { rejected: true, at };
176
+ this.balances.set(key, next);
177
+ return before === undefined || ('usd' in before ? !('usd' in next) || before.usd !== next.usd : 'usd' in next);
95
178
  }
96
179
  /** When an API key can pay again after a credit or spending refusal at `at`; asking keeps it checked. */
97
180
  creditBackAfter(key, at, text) {
@@ -172,15 +255,53 @@ export class AccountWatcher {
172
255
  this.globalCheck = undefined;
173
256
  await this.refresh();
174
257
  }
175
- async addApiKey(name, key, agent) {
258
+ async addApiKey(name, key, agent, provider) {
259
+ if (provider !== undefined && (agent !== 'opencode' || provider !== 'opencode-go'))
260
+ throw fail('request.required', { field: 'provider' });
176
261
  const value = assertApiKey(key, agent);
177
- const verdict = await this.accepted(agent, value);
178
- const home = this.options.homes.addApiKey(name, value, agent);
262
+ const verdict = await this.accepted(agent, value, provider === 'opencode-go');
263
+ const home = this.options.homes.addApiKey(name, value, agent, provider);
179
264
  this.noteKey(home.key, verdict);
180
265
  this.options.name(home.key, name);
181
266
  this.claimShared(home);
182
267
  await this.refresh();
183
268
  }
269
+ /** Reads the AWS profiles of the service's user for the cloud form; the page gets them in `view.aws`. */
270
+ readAws() {
271
+ this.aws = this.options.awsProfiles();
272
+ this.options.onChange();
273
+ }
274
+ /** Reads the Google Cloud credentials of the service's user for the Vertex form, into `view.gcloud` (BTN-823). */
275
+ readGcloud() {
276
+ this.gcloud = this.options.gcloud();
277
+ this.options.onChange();
278
+ }
279
+ /** Reads the Azure sign-in of the service's user for the Foundry form's Entra ID way, into `view.azure` (BTN-824). */
280
+ readAzure() {
281
+ this.azure = this.options.azure();
282
+ this.options.onChange();
283
+ }
284
+ /**
285
+ * A cloud account (BTN-822): the folder is made, one short turn runs on it, and a refusal removes it again with the
286
+ * cloud's own reason (`cloudErrorNotice`), so no account is added that cannot run a session.
287
+ */
288
+ async addCloud(name, connection) {
289
+ const home = this.options.homes.addCloud(name, connection);
290
+ let model;
291
+ try {
292
+ model = (await this.options.checkCloud(home)).model;
293
+ }
294
+ catch (reason) {
295
+ await this.options.homes.remove(home);
296
+ const text = reason instanceof Error ? reason.message : String(reason);
297
+ const known = cloudErrorNotice(text, this.options.whose(), connection.cloud);
298
+ throw known === undefined ? fail('account.cloudCheckFailed', { reason: text.slice(0, 500) }) : new NoticeError(known);
299
+ }
300
+ this.checkedModels.set(home.key, model);
301
+ this.options.name(home.key, name);
302
+ this.claimShared(home);
303
+ await this.refresh();
304
+ }
184
305
  /**
185
306
  * A new key in the folder of an API account (BTN-418): its name, roles and pools stay. Checked as a new account's key
186
307
  * is, and refused when the account's organization is known and the key's is another one. Running sessions go on with
@@ -191,7 +312,7 @@ export class AccountWatcher {
191
312
  if (home === undefined)
192
313
  throw fail('account.unknown', { key });
193
314
  const next = this.options.homes.replacement(home, value);
194
- const verdict = await this.accepted(home.agent, next);
315
+ const verdict = await this.accepted(home.agent, next, home.agent === 'opencode' && consoleKey(readAuth(home.dir)) !== null);
195
316
  const known = this.options.organizations.of(key);
196
317
  if (known !== undefined && verdict.organization !== undefined && verdict.organization !== known) {
197
318
  throw fail('account.keyOtherOrganization', { agent: home.agent });
@@ -201,7 +322,15 @@ export class AccountWatcher {
201
322
  await this.refresh();
202
323
  }
203
324
  /** The provider's verdict on a key it takes; a refusal or no answer is thrown. */
204
- async accepted(agent, key) {
325
+ async accepted(agent, key, go = false) {
326
+ if (go) {
327
+ const verdict = await checkGoKey(key, 15_000);
328
+ if (verdict.state === 'rejected')
329
+ throw fail('account.goKeyRejected', {});
330
+ if (verdict.state === 'unknown')
331
+ throw fail('account.goKeyUnchecked', { reason: verdict.reason });
332
+ return verdict;
333
+ }
205
334
  const verdict = await this.options.checkKey(agent, key);
206
335
  const provider = keyProvider(agent, key);
207
336
  if (verdict.state === 'rejected')
@@ -210,11 +339,13 @@ export class AccountWatcher {
210
339
  throw fail(UNCHECKED[provider], { reason: verdict.reason });
211
340
  return verdict;
212
341
  }
342
+ /** True when the verdict or the key's limit changed. */
213
343
  noteKey(key, verdict) {
214
- this.keys.note(key, verdict, this.options.now());
344
+ const changed = this.keys.note(key, verdict, this.options.now());
215
345
  if (verdict.state === 'ok' && verdict.organization !== undefined && verdict.organization !== this.options.organizations.of(key)) {
216
346
  this.options.organizations.note(key, verdict.organization);
217
347
  }
348
+ return changed;
218
349
  }
219
350
  renew(key) {
220
351
  this.requireIdle();
@@ -260,6 +391,34 @@ export class AccountWatcher {
260
391
  this.options.markRemoving(key, false);
261
392
  this.options.onChange();
262
393
  }
394
+ settingsOf(home) {
395
+ const settings = this.options.settings;
396
+ if (settings === undefined || home.global || home.agent !== CLAUDE)
397
+ return {};
398
+ const edits = settings.edits(home);
399
+ const own = settings.own(home.key);
400
+ return { ...(edits.length > 0 && { settingsEdits: edits }), ...(own.length > 0 && { ownSettings: own }) };
401
+ }
402
+ /** An edit right in the folder's `settings.json`: made shared, kept as the account's own or dropped, then transferred. */
403
+ async resolveSettingsEdit(key, setting, choice) {
404
+ const home = this.claudeHome(key);
405
+ this.options.settings?.resolve(home, setting, choice);
406
+ await this.options.prepare(home);
407
+ this.options.onChange();
408
+ }
409
+ /** A key of the account's own layer goes, and the global value comes back at once. */
410
+ async dropOwnSetting(key, setting) {
411
+ const home = this.claudeHome(key);
412
+ this.options.settings?.dropOwn(home, setting);
413
+ await this.options.prepare(home);
414
+ this.options.onChange();
415
+ }
416
+ claudeHome(key) {
417
+ const home = this.options.homes.find(key);
418
+ if (home === undefined || home.global || home.agent !== CLAUDE)
419
+ throw fail('account.unknown', { key });
420
+ return home;
421
+ }
263
422
  /** Only the name the page shows: the folder and its key stay as they are; a blank name goes back to the default. */
264
423
  rename(key, name) {
265
424
  if (this.options.homes.find(key) === undefined)
@@ -282,17 +441,17 @@ export class AccountWatcher {
282
441
  }
283
442
  }
284
443
  }
285
- /** Asks Anthropic or OpenAI about each API account's key once per `keyCheckMs`; true when a verdict changed. */
444
+ /** Asks each API account's provider about its key once per `keyCheckMs`; true when a verdict or a key's limit changed. */
286
445
  async checkKeys(known) {
287
446
  const now = this.options.now();
288
447
  const due = known.filter(({ home, status }) => isApiKey(status) && this.keys.due(home.key, now));
289
- const changes = await Promise.all(due.map(async ({ home }) => {
448
+ const changes = await Promise.all(due.map(async ({ home, openRouter }) => {
290
449
  const key = this.options.homes.apiKeyOf(home);
291
450
  if (key === null)
292
451
  return false;
293
- const before = this.keys.rejected(home.key);
294
- this.noteKey(home.key, await this.options.checkKey(home.agent, key));
295
- return this.keys.rejected(home.key) !== before;
452
+ const checked = this.options.checkKey(home.agent, key).then((verdict) => this.noteKey(home.key, verdict));
453
+ const [noted, balance] = await Promise.all([checked, openRouter ? this.noteBalance(home.key) : false]);
454
+ return noted || balance;
296
455
  }));
297
456
  return changes.includes(true);
298
457
  }
@@ -312,13 +471,16 @@ export class AccountWatcher {
312
471
  async drop(key) {
313
472
  const home = this.options.homes.find(key);
314
473
  const status = this.known.find((known) => known.home.key === key)?.status;
315
- if (!home.global && status?.loggedIn === true && !isApiKey(status))
474
+ if (!home.global && status?.loggedIn === true && !paysPerToken(status))
316
475
  await this.options.agentOf(home).logout(home);
317
476
  await this.options.homes.remove(home);
318
477
  this.options.forget(key);
319
478
  this.keys.forget(key);
320
479
  this.credit.forget(key);
480
+ this.checkedModels.delete(key);
321
481
  this.options.organizations.forget(key);
482
+ this.options.managementKeys.forget(key);
483
+ this.balances.delete(key);
322
484
  }
323
485
  code(code) {
324
486
  if (this.running === undefined || this.current === null)
@@ -338,17 +500,20 @@ export class AccountWatcher {
338
500
  }
339
501
  async check(home) {
340
502
  const before = this.known.find((known) => known.home.key === home.key);
341
- const keyHeld = !home.global && this.options.homes.apiKeyOf(home) !== null;
503
+ const apiKey = home.global ? null : this.options.homes.apiKeyOf(home);
504
+ const keyHeld = apiKey !== null;
505
+ const openRouter = apiKey !== null && keyProvider(home.agent, apiKey) === 'openrouter';
506
+ const cloud = this.options.homes.cloudOf(home);
342
507
  if (!(await this.options.online(home)))
343
- return { home, status: before?.status ?? null, error: before?.error ?? null, keyHeld };
508
+ return { home, status: before?.status ?? null, error: before?.error ?? null, keyHeld, openRouter, cloud };
344
509
  try {
345
- return { home, status: withIdentity(await this.options.agentOf(home).authStatus(home), home.key), error: null, keyHeld };
510
+ return { home, status: withIdentity(await this.options.agentOf(home).authStatus(home), home.key), error: null, keyHeld, openRouter, cloud };
346
511
  }
347
512
  catch (reason) {
348
513
  const error = noticeOf(reason);
349
514
  if (!sameNotice(error, before?.error ?? null))
350
515
  this.options.onError(reason);
351
- return { home, status: before?.status ?? null, error, keyHeld };
516
+ return { home, status: before?.status ?? null, error, keyHeld, openRouter, cloud };
352
517
  }
353
518
  }
354
519
  requireIdle() {
@@ -4,7 +4,18 @@ import { codex } from '../codex/adapter.js';
4
4
  import { CODEX } from '../codex/name.js';
5
5
  import { copilot } from '../copilot/adapter.js';
6
6
  import { COPILOT } from '../copilot/name.js';
7
+ import { demoAgent } from '../demo/agent.js';
8
+ import { DEMO_AGENT } from '../demo/model.js';
7
9
  import { opencode } from '../opencode/adapter.js';
8
10
  import { OPENCODE } from '../opencode/name.js';
9
- /** The agents by the name accounts and sessions carry (`AccountHome.agent`, `SessionView.agent`). */
10
- export const AGENTS = { [CLAUDE]: claude, [CODEX]: codex, [OPENCODE]: opencode, [COPILOT]: copilot };
11
+ /**
12
+ * The agents by the name accounts and sessions carry (`AccountHome.agent`, `SessionView.agent`). The demo's runs only
13
+ * the demo project (BTN-776): it is no provider a config or a task's run names (`PROVIDERS`).
14
+ */
15
+ export const AGENTS = {
16
+ [CLAUDE]: claude,
17
+ [CODEX]: codex,
18
+ [OPENCODE]: opencode,
19
+ [COPILOT]: copilot,
20
+ [DEMO_AGENT]: demoAgent.adapter(),
21
+ };
@@ -1,19 +1,34 @@
1
1
  import { ciVariables } from '../ci/adapters.js';
2
- import { trackerVariables } from '../tracker/adapters.js';
3
- /** The trackers' and CIs' credentials and the keys of the packages (`keys`): no session gets them. */
2
+ import { secretCatalog } from '../secrets/catalog.js';
3
+ import { trackerKeyRules, trackerVariables } from '../tracker/adapters.js';
4
+ /**
5
+ * The names no session gets: the trackers' and CIs' credentials, the placeholders the MCP gateway also reads a tracker's
6
+ * key under (`GITHUB_PERSONAL_ACCESS_TOKEN`, `JIRA_BASIC_AUTH`), Even Keel's own secrets (the page token, Tally's, the
7
+ * badge's) and the keys of the packages (`keys`).
8
+ */
4
9
  export function sessionSecrets(keys = []) {
5
- return [...new Set([...trackerVariables(), ...ciVariables(), ...keys])];
10
+ const rules = trackerKeyRules();
11
+ const own = secretCatalog().filter((spec) => spec.secret).map((spec) => spec.name);
12
+ return [...new Set([...trackerVariables(), ...ciVariables(), ...Object.keys(rules.aliases), ...Object.keys(rules.derived ?? {}), ...own, ...keys])];
6
13
  }
7
14
  /**
8
- * The service's environment without the trackers' and CIs' credentials and the keys of the packages (`keys`): an agent
9
- * adds its own variables on top (`Agent.env`).
15
+ * The service's environment without `sessionSecrets(keys)` and without the variables Even Keel's `.env` put there
16
+ * (`file`, `EnvFile.own`): a session and a package's server need nothing of that file (BTN-1115). An agent adds its own
17
+ * variables on top (`Agent.env`).
10
18
  */
11
- export function sessionBase(env, keys = []) {
19
+ export function sessionBase(env, keys = [], file = []) {
12
20
  const base = { ...env };
13
- for (const name of sessionSecrets(keys))
21
+ for (const name of [...sessionSecrets(keys), ...file])
14
22
  delete base[name];
15
23
  return base;
16
24
  }
25
+ /**
26
+ * An agent's environment for its sessions: `sessionBase` and the service's own address `url` as `EVEN_KEEL_URL`,
27
+ * the only way the packages' hooks find the service off its default port (BTN-817).
28
+ */
29
+ export function sessionEnv(env, keys, url, file = []) {
30
+ return { ...sessionBase(env, keys, file), EVEN_KEEL_URL: url };
31
+ }
17
32
  /** Which of `names` the `env` of a parsed `settings.json` sets: the CLI puts it on top of a session's environment. */
18
33
  export function settingsSecrets(settings, names) {
19
34
  const env = typeof settings === 'object' && settings !== null ? settings.env : undefined;