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
@@ -0,0 +1,335 @@
1
+ import { fail } from '../notice/notice.js';
2
+ /**
3
+ * A Claude account on a cloud (BTN-822): the CLI reaches the models through the cloud's own API, paid by the cloud's
4
+ * bill. Every cloud is one of `CLOUDS`; only the ones of `CLOUDS_READY` can be added.
5
+ * Its whole connection is the `env` of the folder's `settings.json`, the way an API account holds its key.
6
+ */
7
+ export const CLOUDS = ['bedrock', 'vertex', 'foundry'];
8
+ export const CLOUDS_READY = ['bedrock', 'vertex', 'foundry'];
9
+ /** How a Bedrock account finds its AWS credentials. */
10
+ export const BEDROCK_WAYS = ['profile', 'apiKey', 'keys', 'environment'];
11
+ /**
12
+ * How a Vertex account finds its Google Cloud credentials (BTN-823): the ADC file `gcloud auth application-default
13
+ * login` leaves, a key file (a service account's, or a Workload Identity Federation config), or the service's own.
14
+ */
15
+ export const VERTEX_WAYS = ['adc', 'keyFile', 'environment'];
16
+ /**
17
+ * How a Foundry account signs in (BTN-824): an API key of the resource, Microsoft Entra ID through the Azure SDK's
18
+ * chain (`az login` of the service's user, its environment, the machine's identity), or a Bearer token of about an hour.
19
+ */
20
+ export const FOUNDRY_WAYS = ['apiKey', 'entra', 'token'];
21
+ export const CLOUD_WAYS = { bedrock: BEDROCK_WAYS, vertex: VERTEX_WAYS, foundry: FOUNDRY_WAYS };
22
+ /**
23
+ * The models the CLI gives a region variable of their own, by model id prefix, as in 2.1.319. Only the form's choices:
24
+ * the account takes any `VERTEX_REGION_CLAUDE_*`, so a newer model's variable works before this list knows it.
25
+ */
26
+ export const VERTEX_REGION_MODELS = [
27
+ ['claude-fable-5-1', 'VERTEX_REGION_CLAUDE_FABLE_5_1'],
28
+ ['claude-fable-5', 'VERTEX_REGION_CLAUDE_FABLE_5'],
29
+ ['claude-opus-5-5', 'VERTEX_REGION_CLAUDE_5_5_OPUS'],
30
+ ['claude-sonnet-5-5', 'VERTEX_REGION_CLAUDE_5_5_SONNET'],
31
+ ['claude-haiku-5-5', 'VERTEX_REGION_CLAUDE_HAIKU_5_5'],
32
+ ['claude-opus-5', 'VERTEX_REGION_CLAUDE_5_OPUS'],
33
+ ['claude-sonnet-5', 'VERTEX_REGION_CLAUDE_5_SONNET'],
34
+ ['claude-opus-4-8', 'VERTEX_REGION_CLAUDE_4_8_OPUS'],
35
+ ['claude-opus-4-7', 'VERTEX_REGION_CLAUDE_4_7_OPUS'],
36
+ ['claude-opus-4-6', 'VERTEX_REGION_CLAUDE_4_6_OPUS'],
37
+ ['claude-sonnet-4-6', 'VERTEX_REGION_CLAUDE_4_6_SONNET'],
38
+ ['claude-opus-4-5', 'VERTEX_REGION_CLAUDE_4_5_OPUS'],
39
+ ['claude-sonnet-4-5', 'VERTEX_REGION_CLAUDE_4_5_SONNET'],
40
+ ['claude-haiku-4-5', 'VERTEX_REGION_CLAUDE_HAIKU_4_5'],
41
+ ['claude-opus-4-1', 'VERTEX_REGION_CLAUDE_4_1_OPUS'],
42
+ ['claude-opus-4', 'VERTEX_REGION_CLAUDE_4_0_OPUS'],
43
+ ['claude-sonnet-4', 'VERTEX_REGION_CLAUDE_4_0_SONNET'],
44
+ ['claude-3-7-sonnet', 'VERTEX_REGION_CLAUDE_3_7_SONNET'],
45
+ ['claude-3-5-sonnet', 'VERTEX_REGION_CLAUDE_3_5_SONNET'],
46
+ ['claude-3-5-haiku', 'VERTEX_REGION_CLAUDE_3_5_HAIKU'],
47
+ ];
48
+ export const BEDROCK_SWITCH = 'CLAUDE_CODE_USE_BEDROCK';
49
+ export const VERTEX_SWITCH = 'CLAUDE_CODE_USE_VERTEX';
50
+ const MODEL_VARIABLES = { opus: 'ANTHROPIC_DEFAULT_OPUS_MODEL', sonnet: 'ANTHROPIC_DEFAULT_SONNET_MODEL', haiku: 'ANTHROPIC_DEFAULT_HAIKU_MODEL' };
51
+ const FAMILIES = ['opus', 'sonnet', 'haiku'];
52
+ const BEDROCK_VARIABLES = {
53
+ region: 'AWS_REGION',
54
+ profile: 'AWS_PROFILE',
55
+ apiKey: 'AWS_BEARER_TOKEN_BEDROCK',
56
+ accessKeyId: 'AWS_ACCESS_KEY_ID',
57
+ secretAccessKey: 'AWS_SECRET_ACCESS_KEY',
58
+ sessionToken: 'AWS_SESSION_TOKEN',
59
+ regionPrefix: 'ANTHROPIC_BEDROCK_REGION_PREFIX',
60
+ };
61
+ const VERTEX_VARIABLES = { projectId: 'ANTHROPIC_VERTEX_PROJECT_ID', region: 'CLOUD_ML_REGION', keyFile: 'GOOGLE_APPLICATION_CREDENTIALS' };
62
+ const MODEL_REGION = /^VERTEX_REGION_CLAUDE_[A-Z0-9_]+$/;
63
+ export const FOUNDRY_SWITCH = 'CLAUDE_CODE_USE_FOUNDRY';
64
+ const FOUNDRY_VARIABLES = {
65
+ resource: 'ANTHROPIC_FOUNDRY_RESOURCE',
66
+ baseUrl: 'ANTHROPIC_FOUNDRY_BASE_URL',
67
+ apiKey: 'ANTHROPIC_FOUNDRY_API_KEY',
68
+ token: 'ANTHROPIC_FOUNDRY_AUTH_TOKEN',
69
+ };
70
+ const CLOUD_VARIABLES = [
71
+ BEDROCK_SWITCH,
72
+ VERTEX_SWITCH,
73
+ FOUNDRY_SWITCH,
74
+ ...Object.values(BEDROCK_VARIABLES),
75
+ ...Object.values(VERTEX_VARIABLES),
76
+ ...Object.values(FOUNDRY_VARIABLES),
77
+ ...Object.values(MODEL_VARIABLES),
78
+ ];
79
+ /** A resource name as the CLI takes it in 2.1.319: 2–64 letters, digits and hyphens, no hyphen at either end. */
80
+ const FOUNDRY_RESOURCE = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])$/i;
81
+ /** The hosts the CLI counts as Foundry's own in 2.1.319; another one it treats as a gateway and may refuse. */
82
+ const FOUNDRY_HOST = /^[a-z0-9-]{2,64}\.(?:services\.ai|cognitiveservices|openai)\.azure\.(?:com|us|cn)$/;
83
+ /**
84
+ * The Foundry field's value as the CLI takes it: a bare resource name, or a full `https://…/anthropic` address of a
85
+ * Foundry host. One field takes both, since the portal shows the address and the CLI refuses it as a name.
86
+ */
87
+ export function foundryEndpointOf(value) {
88
+ const given = value.trim();
89
+ if (FOUNDRY_RESOURCE.test(given))
90
+ return { resource: given };
91
+ if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(given))
92
+ return { problem: /[./:]/.test(given) ? 'host' : 'name' };
93
+ let url;
94
+ try {
95
+ url = new URL(given);
96
+ }
97
+ catch {
98
+ return { problem: 'name' };
99
+ }
100
+ if (url.protocol !== 'https:')
101
+ return { problem: 'http' };
102
+ if (!FOUNDRY_HOST.test(url.hostname))
103
+ return { problem: 'foreign' };
104
+ if (url.pathname.replace(/\/+$/, '') !== '/anthropic' || url.search !== '' || url.hash !== '')
105
+ return { problem: 'path' };
106
+ return { baseUrl: `${url.origin}/anthropic` };
107
+ }
108
+ /**
109
+ * A variable a cloud folder may hold. The transfer of the shared configuration takes them from the folder only, so
110
+ * a model pinned in `~/.claude` for Anthropic's API does not reach a cloud that names its models otherwise.
111
+ */
112
+ export function isCloudVariable(name) {
113
+ return CLOUD_VARIABLES.includes(name) || MODEL_REGION.test(name);
114
+ }
115
+ /** A short-term Bedrock API key is a presigned URL and lives up to 12 hours; a long-term one starts with `ABSK`. */
116
+ const SHORT_BEDROCK_KEY = /^bedrock-api-key-/;
117
+ export function shortBedrockKey(key) {
118
+ return SHORT_BEDROCK_KEY.test(key.trim());
119
+ }
120
+ /** The `env` the folder's `settings.json` gets: only what is set, so the CLI's own order fills the rest. */
121
+ export function cloudEnv(connection) {
122
+ const env = {};
123
+ const set = (name, value) => {
124
+ if (value !== undefined && value !== '')
125
+ env[name] = value;
126
+ };
127
+ if (connection.cloud === 'foundry') {
128
+ env[FOUNDRY_SWITCH] = '1';
129
+ const { endpoint, auth } = connection;
130
+ if ('resource' in endpoint)
131
+ set(FOUNDRY_VARIABLES.resource, endpoint.resource);
132
+ else
133
+ set(FOUNDRY_VARIABLES.baseUrl, endpoint.baseUrl);
134
+ if (auth.way === 'apiKey')
135
+ set(FOUNDRY_VARIABLES.apiKey, auth.key);
136
+ if (auth.way === 'token')
137
+ set(FOUNDRY_VARIABLES.token, auth.token);
138
+ for (const family of FAMILIES)
139
+ set(MODEL_VARIABLES[family], connection.models[family]);
140
+ return env;
141
+ }
142
+ if (connection.cloud === 'vertex') {
143
+ env[VERTEX_SWITCH] = '1';
144
+ set(VERTEX_VARIABLES.projectId, connection.projectId);
145
+ set(VERTEX_VARIABLES.region, connection.region);
146
+ if (connection.auth.way === 'keyFile')
147
+ set(VERTEX_VARIABLES.keyFile, connection.auth.keyFile);
148
+ for (const family of FAMILIES)
149
+ set(MODEL_VARIABLES[family], connection.models?.[family]);
150
+ for (const [variable, region] of Object.entries(connection.modelRegions ?? {}))
151
+ set(variable, region);
152
+ return env;
153
+ }
154
+ env[BEDROCK_SWITCH] = '1';
155
+ set(BEDROCK_VARIABLES.region, connection.region);
156
+ const { auth } = connection;
157
+ if (auth.way === 'profile')
158
+ set(BEDROCK_VARIABLES.profile, auth.profile);
159
+ if (auth.way === 'apiKey')
160
+ set(BEDROCK_VARIABLES.apiKey, auth.key);
161
+ if (auth.way === 'keys') {
162
+ set(BEDROCK_VARIABLES.accessKeyId, auth.accessKeyId);
163
+ set(BEDROCK_VARIABLES.secretAccessKey, auth.secretAccessKey);
164
+ set(BEDROCK_VARIABLES.sessionToken, auth.sessionToken);
165
+ }
166
+ for (const family of FAMILIES)
167
+ set(MODEL_VARIABLES[family], connection.models?.[family]);
168
+ set(BEDROCK_VARIABLES.regionPrefix, connection.regionPrefix);
169
+ return env;
170
+ }
171
+ /**
172
+ * The cloud a folder's `settings.json` `env` connects to; null for one on a subscription or a key. What is not in the
173
+ * env is asked: `shortLivedProfile` tells an AWS profile's expiry from `~/.aws`, `userCredentials` whether the Google
174
+ * credentials file in effect — the key file, or for null the service's own — holds a user's sign-in.
175
+ */
176
+ export function cloudOf(env, shortLivedProfile = () => false, userCredentials = () => false) {
177
+ const text = (name) => (typeof env[name] === 'string' && env[name] !== '' ? env[name] : undefined);
178
+ const models = {};
179
+ for (const family of FAMILIES) {
180
+ const model = text(MODEL_VARIABLES[family]);
181
+ if (model !== undefined)
182
+ models[family] = model;
183
+ }
184
+ if (truthy(env[BEDROCK_SWITCH])) {
185
+ const profile = text(BEDROCK_VARIABLES.profile);
186
+ const key = text(BEDROCK_VARIABLES.apiKey);
187
+ const way = key !== undefined ? 'apiKey' : text(BEDROCK_VARIABLES.accessKeyId) !== undefined ? 'keys' : profile !== undefined ? 'profile' : 'environment';
188
+ const shortLived = way === 'apiKey' ? SHORT_BEDROCK_KEY.test(key) : way === 'keys' ? text(BEDROCK_VARIABLES.sessionToken) !== undefined : way === 'profile' && shortLivedProfile(profile);
189
+ return { cloud: 'bedrock', region: text(BEDROCK_VARIABLES.region) ?? null, way, ...(way === 'profile' && { profile }), models, shortLived };
190
+ }
191
+ if (truthy(env[VERTEX_SWITCH])) {
192
+ // ADC and the service's environment write the same env, as the CLI's own wizard does: only a key file tells.
193
+ const keyFile = text(VERTEX_VARIABLES.keyFile);
194
+ const project = text(VERTEX_VARIABLES.projectId);
195
+ return {
196
+ cloud: 'vertex',
197
+ region: text(VERTEX_VARIABLES.region) ?? null,
198
+ way: keyFile !== undefined ? 'keyFile' : 'adc',
199
+ ...(project !== undefined && { project }),
200
+ models,
201
+ shortLived: userCredentials(keyFile ?? null),
202
+ };
203
+ }
204
+ if (truthy(env[FOUNDRY_SWITCH])) {
205
+ // The CLI's own order: a token, then a key, then the Azure SDK's chain.
206
+ const way = text(FOUNDRY_VARIABLES.token) !== undefined ? 'token' : text(FOUNDRY_VARIABLES.apiKey) !== undefined ? 'apiKey' : 'entra';
207
+ const baseUrl = text(FOUNDRY_VARIABLES.baseUrl);
208
+ let resource = text(FOUNDRY_VARIABLES.resource);
209
+ if (baseUrl !== undefined) {
210
+ try {
211
+ resource = new URL(baseUrl).hostname;
212
+ }
213
+ catch {
214
+ resource = baseUrl;
215
+ }
216
+ }
217
+ return { cloud: 'foundry', region: null, way, ...(resource !== undefined && { resource }), models, shortLived: way === 'token' };
218
+ }
219
+ return null;
220
+ }
221
+ /** The CLI reads a switch as on for `1` or `true`, in any case. */
222
+ function truthy(value) {
223
+ return typeof value === 'string' && ['1', 'true'].includes(value.trim().toLowerCase());
224
+ }
225
+ const text = (value) => (typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined);
226
+ /** A one-word field the request must hold; one with a space inside is a pasted value with a line break in it. */
227
+ function need(value, field) {
228
+ const given = text(value);
229
+ if (given === undefined)
230
+ throw fail('request.required', { field });
231
+ if (/\s/.test(given))
232
+ throw fail('account.cloudFieldInvalid', { field });
233
+ return given;
234
+ }
235
+ /** A one-word field the request may hold; undefined when blank. */
236
+ function may(value, field) {
237
+ return text(value) === undefined ? undefined : need(value, field);
238
+ }
239
+ function modelsOf(body) {
240
+ const models = {};
241
+ const given = typeof body.models === 'object' && body.models !== null ? body.models : {};
242
+ for (const family of FAMILIES) {
243
+ const model = may(given[family], family);
244
+ if (model !== undefined)
245
+ models[family] = model;
246
+ }
247
+ return Object.keys(models).length > 0 ? models : undefined;
248
+ }
249
+ /** A request's connection, trimmed; a missing field the way needs is refused naming it. */
250
+ export function cloudConnectionOf(body) {
251
+ const cloud = body.cloud;
252
+ if (!CLOUDS.includes(cloud))
253
+ throw fail('request.required', { field: 'cloud' });
254
+ if (!CLOUDS_READY.includes(cloud))
255
+ throw fail('account.cloudNotReady', { cloud: String(cloud) });
256
+ return cloud === 'vertex' ? vertexConnectionOf(body) : cloud === 'foundry' ? foundryConnectionOf(body) : bedrockConnectionOf(body);
257
+ }
258
+ function foundryConnectionOf(body) {
259
+ const way = body.way;
260
+ if (!FOUNDRY_WAYS.includes(way))
261
+ throw fail('request.required', { field: 'way' });
262
+ const given = text(body.resource);
263
+ if (given === undefined)
264
+ throw fail('request.required', { field: 'resource' });
265
+ const endpoint = foundryEndpointOf(given);
266
+ if ('problem' in endpoint)
267
+ throw fail('account.foundryEndpoint', {});
268
+ const auth = way === 'apiKey' ? { way, key: need(body.key, 'key') } : way === 'token' ? { way, token: need(body.token, 'token') } : { way: 'entra' };
269
+ const models = modelsOf(body);
270
+ if (models === undefined)
271
+ throw fail('account.foundryModels', {});
272
+ return { cloud: 'foundry', endpoint, auth, models };
273
+ }
274
+ function bedrockConnectionOf(body) {
275
+ const way = body.way;
276
+ if (!BEDROCK_WAYS.includes(way))
277
+ throw fail('request.required', { field: 'way' });
278
+ const auth = way === 'profile'
279
+ ? { way, profile: need(body.profile, 'profile') }
280
+ : way === 'apiKey'
281
+ ? { way, key: need(body.key, 'key') }
282
+ : way === 'keys'
283
+ ? {
284
+ way,
285
+ accessKeyId: need(body.accessKeyId, 'accessKeyId'),
286
+ secretAccessKey: need(body.secretAccessKey, 'secretAccessKey'),
287
+ ...(text(body.sessionToken) !== undefined && { sessionToken: need(body.sessionToken, 'sessionToken') }),
288
+ }
289
+ : { way: 'environment' };
290
+ const models = modelsOf(body);
291
+ const region = may(body.region, 'region');
292
+ const regionPrefix = may(body.regionPrefix, 'regionPrefix');
293
+ return {
294
+ cloud: 'bedrock',
295
+ ...(region !== undefined && { region }),
296
+ auth,
297
+ ...(models !== undefined && { models }),
298
+ ...(regionPrefix !== undefined && { regionPrefix }),
299
+ };
300
+ }
301
+ function vertexConnectionOf(body) {
302
+ const way = body.way;
303
+ if (!VERTEX_WAYS.includes(way))
304
+ throw fail('request.required', { field: 'way' });
305
+ const projectId = need(body.projectId, 'projectId');
306
+ let auth = { way: way === 'adc' ? 'adc' : 'environment' };
307
+ if (way === 'keyFile') {
308
+ // A path may hold spaces (`C:\Users\John Doe\…`), never a line break.
309
+ const keyFile = text(body.keyFile);
310
+ if (keyFile === undefined)
311
+ throw fail('request.required', { field: 'keyFile' });
312
+ if (/[\r\n]/.test(keyFile))
313
+ throw fail('account.cloudFieldInvalid', { field: 'keyFile' });
314
+ auth = { way, keyFile };
315
+ }
316
+ const regions = {};
317
+ const given = typeof body.modelRegions === 'object' && body.modelRegions !== null ? body.modelRegions : {};
318
+ for (const [variable, value] of Object.entries(given)) {
319
+ if (!MODEL_REGION.test(variable))
320
+ throw fail('account.cloudFieldInvalid', { field: variable });
321
+ const region = may(value, variable);
322
+ if (region !== undefined)
323
+ regions[variable] = region;
324
+ }
325
+ const models = modelsOf(body);
326
+ const region = may(body.region, 'region');
327
+ return {
328
+ cloud: 'vertex',
329
+ projectId,
330
+ ...(region !== undefined && { region }),
331
+ auth,
332
+ ...(models !== undefined && { models }),
333
+ ...(Object.keys(regions).length > 0 && { modelRegions: regions }),
334
+ };
335
+ }
@@ -9,6 +9,8 @@ const OPENAI_RESPONSES_URL = 'https://api.openai.com/v1/responses';
9
9
  const OPENAI_OUT_OF_MONEY = 'insufficient_quota';
10
10
  // Models of the list that take no text input through `/v1/responses`.
11
11
  const NOT_TEXT = /tts|transcribe|audio|realtime|search|image|embedding/;
12
+ const OPENROUTER_MODELS_URL = 'https://openrouter.ai/api/v1/models';
13
+ const OPENROUTER_CHAT_URL = 'https://openrouter.ai/api/v1/chat/completions';
12
14
  /**
13
15
  * Asks Anthropic whether the key can pay again: one output token from the cheapest model the key lists (a Haiku, else
14
16
  * the newest one) — a fraction of a cent. The models list alone costs nothing but answers even with no credit.
@@ -18,7 +20,10 @@ export function checkCredit(key, timeoutMs, fetchImpl = fetch) {
18
20
  modelsUrl: MODELS_URL,
19
21
  url: MESSAGES_URL,
20
22
  headers: { 'x-api-key': key, 'anthropic-version': API_VERSION, 'content-type': 'application/json' },
21
- pick: (ids) => ids.find((id) => id.includes('haiku')) ?? ids[0] ?? null,
23
+ pick: (models) => {
24
+ const ids = models.map((model) => model.id);
25
+ return ids.find((id) => id.includes('haiku')) ?? ids[0] ?? null;
26
+ },
22
27
  body: (model) => ({ model, max_tokens: 1, messages: [{ role: 'user', content: '.' }] }),
23
28
  empty: (status, text) => status === 400 && (text.toLowerCase().includes(OUT_OF_CREDIT) || isSpendingLimit(text)),
24
29
  }, timeoutMs, fetchImpl);
@@ -33,14 +38,51 @@ export function checkOpenAiCredit(key, timeoutMs, fetchImpl = fetch) {
33
38
  modelsUrl: OPENAI_MODELS_URL,
34
39
  url: OPENAI_RESPONSES_URL,
35
40
  headers: { authorization: `Bearer ${key}`, 'content-type': 'application/json' },
36
- pick: (ids) => {
37
- const text = ids.filter((id) => id.startsWith('gpt-') && !NOT_TEXT.test(id));
41
+ pick: (models) => {
42
+ const text = models.map((model) => model.id).filter((id) => id.startsWith('gpt-') && !NOT_TEXT.test(id));
38
43
  return text.find((id) => id.includes('nano')) ?? text.find((id) => id.includes('mini')) ?? null;
39
44
  },
40
45
  body: (model) => ({ model, input: '.', max_output_tokens: 16, store: false }),
41
46
  empty: (status, text) => status === 429 && text.includes(OPENAI_OUT_OF_MONEY),
42
47
  }, timeoutMs, fetchImpl);
43
48
  }
49
+ /**
50
+ * The same question to OpenRouter for an OpenCode key (BTN-843): one output token from the cheapest paid text model it
51
+ * lists — a free one answers even with no money, and `openrouter/auto` has no price (`-1`). A key out of money answers
52
+ * 402; its balance itself only a management key may read.
53
+ */
54
+ export function checkOpenRouterCredit(key, timeoutMs, fetchImpl = fetch) {
55
+ return askCredit({
56
+ modelsUrl: OPENROUTER_MODELS_URL,
57
+ url: OPENROUTER_CHAT_URL,
58
+ headers: { authorization: `Bearer ${key}`, 'content-type': 'application/json' },
59
+ pick: cheapestPaidText,
60
+ body: (model) => ({ model, max_tokens: 1, messages: [{ role: 'user', content: '.' }] }),
61
+ empty: (status) => status === 402,
62
+ }, timeoutMs, fetchImpl);
63
+ }
64
+ function cheapestPaidText(models) {
65
+ let best = null;
66
+ for (const model of models) {
67
+ const architecture = record(model.architecture);
68
+ if (!listHas(architecture.input_modalities, 'text') || !listHas(architecture.output_modalities, 'text'))
69
+ continue;
70
+ const pricing = record(model.pricing);
71
+ const prices = [pricing.prompt, pricing.completion, pricing.request ?? '0'].map(Number);
72
+ if (prices.some((price) => !Number.isFinite(price) || price < 0))
73
+ continue;
74
+ const price = prices.reduce((sum, each) => sum + each, 0);
75
+ if (price > 0 && (best === null || price < best.price))
76
+ best = { id: model.id, price };
77
+ }
78
+ return best?.id ?? null;
79
+ }
80
+ function record(value) {
81
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : {};
82
+ }
83
+ function listHas(value, item) {
84
+ return Array.isArray(value) && value.includes(item);
85
+ }
44
86
  async function askCredit(ask, timeoutMs, fetchImpl) {
45
87
  try {
46
88
  const listed = await fetchImpl(ask.modelsUrl, { headers: ask.headers, signal: AbortSignal.timeout(timeoutMs) });
@@ -48,7 +90,7 @@ async function askCredit(ask, timeoutMs, fetchImpl) {
48
90
  await listed.body?.cancel();
49
91
  return { state: 'unknown', reason: `models HTTP ${listed.status}` };
50
92
  }
51
- const model = ask.pick(modelIds(await listed.json()));
93
+ const model = ask.pick(listedModels(await listed.json()));
52
94
  if (model === null)
53
95
  return { state: 'unknown', reason: 'the key lists no models' };
54
96
  const response = await fetchImpl(ask.url, {
@@ -68,9 +110,9 @@ async function askCredit(ask, timeoutMs, fetchImpl) {
68
110
  return { state: 'unknown', reason: error instanceof Error ? error.message : String(error) };
69
111
  }
70
112
  }
71
- function modelIds(body) {
72
- const data = body?.data;
73
- return Array.isArray(data) ? data.map((model) => model?.id).filter((id) => typeof id === 'string') : [];
113
+ function listedModels(body) {
114
+ const data = record(body).data;
115
+ return Array.isArray(data) ? data.map(record).filter((model) => typeof model.id === 'string') : [];
74
116
  }
75
117
  /**
76
118
  * The credit of the API accounts whose session of a current task stopped on it: checked once per interval while the
@@ -0,0 +1,71 @@
1
+ import { readdirSync, readFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { currentUser } from './aws.js';
5
+ const ADC_FILE = 'application_default_credentials.json';
6
+ /** The gcloud configuration folder where Google's auth library looks for ADC: `CLOUDSDK_CONFIG` moves it. */
7
+ export function gcloudDir(env, platform = process.platform) {
8
+ if (env.CLOUDSDK_CONFIG !== undefined && env.CLOUDSDK_CONFIG !== '')
9
+ return env.CLOUDSDK_CONFIG;
10
+ if (platform === 'win32')
11
+ return join(env.APPDATA ?? join(homedir(), 'AppData', 'Roaming'), 'gcloud');
12
+ return join(homedir(), '.config', 'gcloud');
13
+ }
14
+ /** The Google Cloud credentials of the user Even Keel runs as, for the Vertex form (BTN-823). */
15
+ export function readGcloud(env) {
16
+ const dir = gcloudDir(env);
17
+ const adcFile = join(dir, ADC_FILE);
18
+ const adc = readJson(adcFile);
19
+ const projects = new Set(configProjects(dir));
20
+ if (typeof adc?.quota_project_id === 'string' && adc.quota_project_id !== '')
21
+ projects.add(adc.quota_project_id);
22
+ return {
23
+ user: currentUser(),
24
+ home: homedir(),
25
+ adcFile,
26
+ adcType: typeof adc?.type === 'string' ? adc.type : null,
27
+ environmentFile: env.GOOGLE_APPLICATION_CREDENTIALS || null,
28
+ projects: [...projects],
29
+ };
30
+ }
31
+ /**
32
+ * Whether the credentials file in effect holds a user's sign-in, which an organization's session policy may expire:
33
+ * the account's key file, else the service's `GOOGLE_APPLICATION_CREDENTIALS`, else the ADC file. A service account
34
+ * or a Workload Identity Federation config is not, nor a missing file.
35
+ */
36
+ export function userCredentials(env, keyFile) {
37
+ const file = keyFile ?? (env.GOOGLE_APPLICATION_CREDENTIALS || join(gcloudDir(env), ADC_FILE));
38
+ return readJson(file)?.type === 'authorized_user';
39
+ }
40
+ /** The `project` of every gcloud configuration (`configurations/config_<name>`), as the CLI's own wizard offers them. */
41
+ function configProjects(dir) {
42
+ let names;
43
+ try {
44
+ names = readdirSync(join(dir, 'configurations')).filter((name) => name.startsWith('config_')).sort();
45
+ }
46
+ catch {
47
+ return [];
48
+ }
49
+ const projects = [];
50
+ for (const name of names) {
51
+ let text;
52
+ try {
53
+ text = readFileSync(join(dir, 'configurations', name), 'utf8');
54
+ }
55
+ catch {
56
+ continue;
57
+ }
58
+ for (const match of text.matchAll(/^project\s*=\s*(\S+)/gm))
59
+ projects.push(match[1]);
60
+ }
61
+ return projects;
62
+ }
63
+ function readJson(file) {
64
+ try {
65
+ const value = JSON.parse(readFileSync(file, 'utf8'));
66
+ return typeof value === 'object' && value !== null ? value : null;
67
+ }
68
+ catch {
69
+ return null;
70
+ }
71
+ }
@@ -8,10 +8,11 @@ export function headerLevels(ctx) {
8
8
  const current = ctx.tasks.find((task) => task.id === ctx.current?.task && open(task));
9
9
  const next = nextTask(ctx.tasks, ctx.order.filter((id) => ctx.tasks.some((task) => task.id === id && open(task))), ctx.holding ?? []);
10
10
  const task = current ?? ctx.tasks.find((each) => each.id === next);
11
- const choice = runChoice(task, ctx.project, ctx.hasAccount);
11
+ const run = task === undefined ? undefined : ctx.runOf(task.id);
12
+ const choice = runChoice(run, ctx.project, ctx.hasAccount);
12
13
  const pinned = current && ctx.current?.sessionId ? ctx.sessionAccount(ctx.current.sessionId) : undefined;
13
14
  const account = pinned ?? choice.account;
14
- const labelled = ctx.project.labels && task?.runLabels.length === 1 && choice.fallback === null;
15
+ const labelled = (run?.provider ?? null) !== null && choice.fallback === null;
15
16
  const levels = [];
16
17
  if (task && (labelled || account !== project))
17
18
  levels.push({ account, source: 'task', task: task.id });
@@ -6,9 +6,12 @@ import { CODEX } from '../codex/name.js';
6
6
  import { tokenOf, writeToken } from '../copilot/home.js';
7
7
  import { COPILOT } from '../copilot/name.js';
8
8
  import { fail } from '../notice/notice.js';
9
- import { keyOf, keyVendor, replaceKey, writeKey } from '../opencode/home.js';
9
+ import { consoleKey, readAuth, keyOf, keyVendor, replaceKey, writeKey } from '../opencode/home.js';
10
10
  import { OPENCODE } from '../opencode/name.js';
11
11
  import { samePath } from '../paths.js';
12
+ import { shortLivedProfile } from './aws.js';
13
+ import { userCredentials } from './gcloud.js';
14
+ import { cloudEnv, cloudOf } from './cloud.js';
12
15
  import { KeychainCredentials, keychainService } from './keychain.js';
13
16
  import { CODEX_ACCOUNT, folderName, GLOBAL_ACCOUNT, parseCredentialTimes } from './model.js';
14
17
  import { API_KEY_VARIABLE, shareConfig } from './share.js';
@@ -85,8 +88,18 @@ export class AccountHomes {
85
88
  ...codex.map((name) => this.home(CODEX, name)),
86
89
  ...openCode.map((name) => this.home(OPENCODE, name)),
87
90
  ...copilot.map((name) => this.home(COPILOT, name)),
91
+ ...(this.demo !== null && existsSync(this.demo.dir) ? [this.demo] : []),
88
92
  ];
89
93
  }
94
+ demo = null;
95
+ /**
96
+ * The demo's account folder (BTN-776): listed while it exists, so the chain finds the demo project's account the way
97
+ * it finds any. No project but the demo's names it: an account is always named in a project's settings.
98
+ */
99
+ setDemo(home) {
100
+ this.demo = home;
101
+ this.forget();
102
+ }
90
103
  find(key) {
91
104
  return this.list().find((home) => home.key === key);
92
105
  }
@@ -157,7 +170,9 @@ export class AccountHomes {
157
170
  * `codex login --with-api-key` writes it (BTN-177). OpenCode's: an `auth.json` under the provider the key is of (BTN-214).
158
171
  * Copilot's: the GitHub token in `even-keel.json` (BTN-215).
159
172
  */
160
- addApiKey(name, key, agent = CLAUDE) {
173
+ addApiKey(name, key, agent = CLAUDE, provider) {
174
+ if (provider !== undefined && (agent !== OPENCODE || provider !== 'opencode-go'))
175
+ throw fail('request.required', { field: 'provider' });
161
176
  const value = assertApiKey(key, agent);
162
177
  const home = this.home(agent, folderName(name.trim() === '' ? (agent === COPILOT ? 'github' : 'api') : name, this.taken()));
163
178
  mkdirSync(home.dir, { recursive: true });
@@ -167,7 +182,7 @@ export class AccountHomes {
167
182
  return home;
168
183
  }
169
184
  if (agent === OPENCODE) {
170
- writeKey(home.dir, value);
185
+ writeKey(home.dir, value, provider);
171
186
  return home;
172
187
  }
173
188
  if (agent === CODEX) {
@@ -179,6 +194,24 @@ export class AccountHomes {
179
194
  writeFileSync(join(home.dir, '.claude.json'), JSON.stringify(approved, null, 2));
180
195
  return home;
181
196
  }
197
+ /**
198
+ * A cloud account (BTN-822): a Claude folder whose `settings.json` `env` holds the whole connection, its secrets kept
199
+ * there as an API account's key is. Named like an API account, after the cloud when the name is blank.
200
+ */
201
+ addCloud(name, connection) {
202
+ const home = this.home(CLAUDE, folderName(name.trim() === '' ? connection.cloud : name, this.taken()));
203
+ mkdirSync(home.dir, { recursive: true });
204
+ this.forget();
205
+ writeFileSync(join(home.dir, 'settings.json'), JSON.stringify({ env: cloudEnv(connection) }, null, 2));
206
+ return home;
207
+ }
208
+ /** The cloud a Claude folder's `settings.json` connects to; null for any other folder. */
209
+ cloudOf(home) {
210
+ if (home.agent !== CLAUDE)
211
+ return null;
212
+ const env = objectOf(readObject(join(home.dir, 'settings.json')).env);
213
+ return cloudOf(env, (profile) => shortLivedProfile(this.env, profile), (keyFile) => userCredentials(this.env, keyFile));
214
+ }
182
215
  /**
183
216
  * The trimmed key that may take the place of the folder's own (BTN-418): of the right form, into a folder that holds its
184
217
  * key itself — not the agent's own folder, not one with `apiKeyHelper` — and of the provider of the key it holds.
@@ -188,6 +221,8 @@ export class AccountHomes {
188
221
  const held = home.global ? null : this.apiKeyOf(home);
189
222
  if (held === null)
190
223
  throw fail('account.keyNotHeld', { agent: home.agent });
224
+ if (home.agent === OPENCODE && consoleKey(readAuth(home.dir)) !== null)
225
+ return value;
191
226
  const provider = keyProvider(home.agent, held);
192
227
  if (keyProvider(home.agent, value) !== provider)
193
228
  throw fail('account.keyOtherProvider', { provider });
@@ -236,11 +271,16 @@ export class AccountHomes {
236
271
  return null;
237
272
  }
238
273
  }
274
+ settings = null;
275
+ /** What the transfer wrote into each folder's `settings.json` and each account's own layer (BTN-901). */
276
+ useSettings(settings) {
277
+ this.settings = settings;
278
+ }
239
279
  /** Claude's shared configuration into an account folder; Codex reads its own `config.toml`. */
240
280
  share(home) {
241
281
  if (home.global || home.agent !== CLAUDE)
242
282
  return false;
243
- return shareConfig({ dir: this.global.dir, config: this.configFile(this.global) }, home.dir);
283
+ return shareConfig({ dir: this.global.dir, config: this.configFile(this.global) }, home.dir, console.warn, this.settings?.planner(home.key));
244
284
  }
245
285
  /** The `.claude.json` the CLI reads with this folder. */
246
286
  configFile(home) {
@@ -256,6 +296,7 @@ export class AccountHomes {
256
296
  return;
257
297
  }
258
298
  rmSync(home.dir, { recursive: true, force: true, maxRetries: 3 });
299
+ this.settings?.forget(home.key);
259
300
  this.forget();
260
301
  }
261
302
  home(agent, name) {
@@ -308,7 +349,10 @@ export function assertApiKey(key, agent = CLAUDE) {
308
349
  * a classic `ghp_` is refused by the CLI.
309
350
  */
310
351
  const COPILOT_TOKEN = /^(github_pat_|gho_|ghu_)/;
311
- /** Whose key an API account of the agent holds: Codex's is OpenAI's, OpenCode's either, by its prefix, Copilot's GitHub's. */
352
+ /**
353
+ * Whose key an API account of the agent holds: Codex's is OpenAI's, OpenCode's Anthropic's, OpenAI's or OpenRouter's, by
354
+ * its prefix, Copilot's GitHub's.
355
+ */
312
356
  export function keyProvider(agent, key) {
313
357
  if (agent === COPILOT)
314
358
  return 'github';