even-keel 0.3.4 → 0.4.0-rc.1

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 (491) hide show
  1. package/.env.example +10 -0
  2. package/CHANGELOG.md +4 -0
  3. package/README.md +4 -2
  4. package/dist/src/account/globals.js +3 -3
  5. package/dist/src/account/homes.js +16 -0
  6. package/dist/src/account/longToken.js +99 -0
  7. package/dist/src/account/settingsGuard.js +1 -1
  8. package/dist/src/account/settingsLayer.js +53 -8
  9. package/dist/src/account/share.js +12 -3
  10. package/dist/src/account/tokenAccount.js +53 -0
  11. package/dist/src/account/watcher-options.js +1 -0
  12. package/dist/src/account/watcher.js +80 -12
  13. package/dist/src/agent/copies.js +2 -2
  14. package/dist/src/agent/copy.js +6 -3
  15. package/dist/src/agent/npm-global.js +21 -2
  16. package/dist/src/badge/collect.js +2 -3
  17. package/dist/src/badge/render.js +115 -34
  18. package/dist/src/badge/theme.js +17 -0
  19. package/dist/src/builtin/components.js +86 -0
  20. package/dist/src/builtin/control.js +70 -2
  21. package/dist/src/builtin/diff.js +73 -0
  22. package/dist/src/builtin/editor.js +6 -3
  23. package/dist/src/builtin/export-store.js +36 -5
  24. package/dist/src/builtin/export.js +244 -37
  25. package/dist/src/builtin/files.js +13 -4
  26. package/dist/src/builtin/history-log.js +40 -0
  27. package/dist/src/builtin/import-reading.js +125 -0
  28. package/dist/src/builtin/import-run.js +294 -0
  29. package/dist/src/builtin/import-store.js +75 -0
  30. package/dist/src/builtin/import.js +373 -0
  31. package/dist/src/builtin/milestones.js +116 -0
  32. package/dist/src/builtin/routes.js +84 -4
  33. package/dist/src/builtin/source.js +38 -11
  34. package/dist/src/builtin/store.js +204 -128
  35. package/dist/src/builtin/switch.js +18 -10
  36. package/dist/src/builtin/task-rows.js +157 -0
  37. package/dist/src/builtin/transfer-store.js +62 -0
  38. package/dist/src/chain/answers.js +14 -11
  39. package/dist/src/chain/archive-pages.js +44 -0
  40. package/dist/src/chain/arrange.js +109 -0
  41. package/dist/src/chain/carry.js +3 -3
  42. package/dist/src/chain/checkreports.js +9 -0
  43. package/dist/src/chain/cleanup.js +90 -20
  44. package/dist/src/chain/dispatcher.js +189 -482
  45. package/dist/src/chain/handoff-note.js +5 -0
  46. package/dist/src/chain/handoff-notes.js +44 -0
  47. package/dist/src/chain/lanes.js +55 -0
  48. package/dist/src/chain/launches.js +17 -2
  49. package/dist/src/chain/limit-moves.js +32 -0
  50. package/dist/src/chain/limitNotice.js +19 -8
  51. package/dist/src/chain/lists.js +26 -2
  52. package/dist/src/chain/maincheck.js +49 -10
  53. package/dist/src/chain/mainci.js +11 -62
  54. package/dist/src/chain/mainfix.js +114 -25
  55. package/dist/src/chain/order.js +48 -6
  56. package/dist/src/chain/outside.js +28 -0
  57. package/dist/src/chain/pauses.js +33 -3
  58. package/dist/src/chain/placement.js +113 -0
  59. package/dist/src/chain/prompts.js +32 -4
  60. package/dist/src/chain/quiet.js +25 -0
  61. package/dist/src/chain/relay.js +46 -11
  62. package/dist/src/chain/restartGuard.js +2 -2
  63. package/dist/src/chain/reviews.js +12 -7
  64. package/dist/src/chain/rules.js +14 -0
  65. package/dist/src/chain/shelved.js +3 -3
  66. package/dist/src/chain/start.js +7 -7
  67. package/dist/src/chain/step.js +246 -0
  68. package/dist/src/chain/store.js +2 -2
  69. package/dist/src/chain/talk.js +122 -0
  70. package/dist/src/chain/unchanged.js +8 -8
  71. package/dist/src/chain/user-message.js +38 -0
  72. package/dist/src/chats/chats.js +345 -0
  73. package/dist/src/chats/model.js +115 -0
  74. package/dist/src/chats/prompt.js +51 -0
  75. package/dist/src/chats/routes.js +60 -0
  76. package/dist/src/chats/store.js +101 -0
  77. package/dist/src/ci/adapters.js +2 -1
  78. package/dist/src/ci/forgejo-profile.js +2 -2
  79. package/dist/src/ci/protection-audit.js +2 -1
  80. package/dist/src/ci/watcher.js +2 -2
  81. package/dist/src/claude/adapter.js +1 -1
  82. package/dist/src/claude/cli.js +22 -4
  83. package/dist/src/claude/listing.js +128 -0
  84. package/dist/src/claude/login-browser.js +42 -0
  85. package/dist/src/claude/sdk/registry.js +1 -1
  86. package/dist/src/cli-args.js +62 -5
  87. package/dist/src/cli-check/lease.js +2 -1
  88. package/dist/src/cli-check/run.js +1 -1
  89. package/dist/src/cli-install.js +44 -0
  90. package/dist/src/cli.js +111 -36
  91. package/dist/src/codex/adapter.js +11 -4
  92. package/dist/src/codex/cli.js +13 -6
  93. package/dist/src/codex/plugins.js +6 -3
  94. package/dist/src/codex/rollout.js +51 -43
  95. package/dist/src/codex/rolloutFiles.js +62 -0
  96. package/dist/src/codex/tail.js +16 -3
  97. package/dist/src/codex/turns.js +1 -1
  98. package/dist/src/codex/usage.js +7 -2
  99. package/dist/src/config-form.js +36 -6
  100. package/dist/src/config-store.js +18 -4
  101. package/dist/src/config.js +15 -3
  102. package/dist/src/copilot/cli.js +11 -5
  103. package/dist/src/diagnostics/missing-package.js +9 -0
  104. package/dist/src/diagnostics/stall-profile.js +99 -0
  105. package/dist/src/diagnostics/start-watch.js +45 -12
  106. package/dist/src/dictation/transcribe.js +124 -0
  107. package/dist/src/event-log/watch.js +28 -3
  108. package/dist/src/events.js +52 -10
  109. package/dist/src/fetch-dispatcher.js +11 -0
  110. package/dist/src/forgejo/api.js +11 -2
  111. package/dist/src/forgejo/editor.js +1 -1
  112. package/dist/src/git/diff.js +52 -0
  113. package/dist/src/git/dirs.js +19 -0
  114. package/dist/src/git/patterns.js +91 -0
  115. package/dist/src/git/push.js +63 -0
  116. package/dist/src/git/remote-head.js +69 -0
  117. package/dist/src/git/remote-urls.js +47 -0
  118. package/dist/src/git/slot-clean.js +144 -0
  119. package/dist/src/git/slot.js +12 -4
  120. package/dist/src/git/sync.js +49 -12
  121. package/dist/src/git/work.js +32 -8
  122. package/dist/src/git/worktree.js +12 -3
  123. package/dist/src/github/adapter.js +1 -0
  124. package/dist/src/github/editor.js +2 -0
  125. package/dist/src/github/import.js +311 -0
  126. package/dist/src/github/profile.js +1 -1
  127. package/dist/src/github/source.js +121 -28
  128. package/dist/src/github/uploads.js +8 -0
  129. package/dist/src/gitlab/api.js +4 -0
  130. package/dist/src/gitlab/editor.js +1 -1
  131. package/dist/src/gitlab/profile.js +1 -1
  132. package/dist/src/huly/adapter.js +2 -1
  133. package/dist/src/huly/colors.js +41 -0
  134. package/dist/src/huly/import-text.js +31 -0
  135. package/dist/src/huly/import.js +317 -0
  136. package/dist/src/huly/model.js +10 -3
  137. package/dist/src/huly/profile.js +1 -1
  138. package/dist/src/huly/source.js +46 -10
  139. package/dist/src/huly/transient.js +32 -0
  140. package/dist/src/intake/intake.js +42 -17
  141. package/dist/src/intake/model.js +2 -0
  142. package/dist/src/jira/api.js +4 -0
  143. package/dist/src/jira/editor.js +1 -1
  144. package/dist/src/jira/model.js +7 -2
  145. package/dist/src/jira/profile.js +1 -1
  146. package/dist/src/jobs/model.js +7 -1
  147. package/dist/src/jobs/runner.js +25 -7
  148. package/dist/src/limits/chatgpt.js +9 -0
  149. package/dist/src/limits/identity.js +51 -0
  150. package/dist/src/limits/model.js +17 -3
  151. package/dist/src/limits/polls.js +200 -0
  152. package/dist/src/limits/token-windows.js +30 -0
  153. package/dist/src/limits/watcher.js +93 -9
  154. package/dist/src/linear/adapter.js +1 -0
  155. package/dist/src/linear/answer.js +27 -0
  156. package/dist/src/linear/import.js +282 -0
  157. package/dist/src/linear/profile.js +3 -2
  158. package/dist/src/linear/source.js +62 -8
  159. package/dist/src/link/address.js +28 -0
  160. package/dist/src/link/cert.js +41 -0
  161. package/dist/src/link/colors.js +20 -0
  162. package/dist/src/link/hooks.js +30 -0
  163. package/dist/src/link/hub-server.js +164 -0
  164. package/dist/src/link/hub-store.js +84 -0
  165. package/dist/src/link/hub.js +249 -0
  166. package/dist/src/link/identity.js +20 -0
  167. package/dist/src/link/local.js +75 -0
  168. package/dist/src/link/machine-store.js +177 -0
  169. package/dist/src/link/machine-transport.js +184 -0
  170. package/dist/src/link/machine.js +402 -0
  171. package/dist/src/link/protocol.js +77 -0
  172. package/dist/src/link/view.js +2 -0
  173. package/dist/src/locations.js +3 -0
  174. package/dist/src/machine/about.js +53 -0
  175. package/dist/src/machine/account-here.js +26 -0
  176. package/dist/src/machine/assignments.js +99 -0
  177. package/dist/src/machine/brief.js +99 -0
  178. package/dist/src/machine/chain-machines.js +37 -0
  179. package/dist/src/machine/config.js +48 -0
  180. package/dist/src/machine/facts.js +118 -0
  181. package/dist/src/machine/folder-check.js +103 -0
  182. package/dist/src/{chain → machine}/handover.js +70 -82
  183. package/dist/src/machine/hook-receiver.js +124 -0
  184. package/dist/src/machine/host.js +1 -0
  185. package/dist/src/machine/join-cli.js +59 -0
  186. package/dist/src/machine/join.js +96 -0
  187. package/dist/src/machine/main.js +71 -0
  188. package/dist/src/machine/marks.js +81 -0
  189. package/dist/src/machine/move-call.js +42 -0
  190. package/dist/src/machine/moves.js +210 -0
  191. package/dist/src/{chain → machine}/overage.js +9 -11
  192. package/dist/src/machine/own.js +33 -0
  193. package/dist/src/machine/page.js +74 -0
  194. package/dist/src/machine/pool.js +100 -0
  195. package/dist/src/machine/port.js +1 -0
  196. package/dist/src/machine/reassign.js +30 -0
  197. package/dist/src/machine/records.js +73 -0
  198. package/dist/src/machine/remote.js +300 -0
  199. package/dist/src/machine/runner.js +268 -0
  200. package/dist/src/machine/services.js +52 -0
  201. package/dist/src/machine/state.js +54 -0
  202. package/dist/src/machine/tally.js +65 -0
  203. package/dist/src/machine/task-moves.js +46 -0
  204. package/dist/src/machine/tasks.js +165 -0
  205. package/dist/src/machine-service.js +141 -0
  206. package/dist/src/main.js +12 -104
  207. package/dist/src/memory/mcp.js +206 -0
  208. package/dist/src/memory/mirror.js +142 -0
  209. package/dist/src/memory/record.js +69 -0
  210. package/dist/src/memory/store.js +81 -0
  211. package/dist/src/notice/en-advice.js +7 -0
  212. package/dist/src/notice/en-review.js +3 -0
  213. package/dist/src/notice/en-transfer.js +30 -0
  214. package/dist/src/notice/en-values.js +2 -0
  215. package/dist/src/notice/en.js +119 -11
  216. package/dist/src/npm-access.js +18 -2
  217. package/dist/src/opencode/adapter.js +3 -1
  218. package/dist/src/opencode/cli.js +11 -10
  219. package/dist/src/opencode/home.js +24 -4
  220. package/dist/src/opencode/tail.js +7 -1
  221. package/dist/src/opencode/transcript.js +21 -7
  222. package/dist/src/opencode/window.js +21 -5
  223. package/dist/src/packages/check.js +17 -8
  224. package/dist/src/packages/follow.js +54 -0
  225. package/dist/src/packages/gateway.js +86 -4
  226. package/dist/src/packages/hub.js +64 -0
  227. package/dist/src/packages/installs.js +226 -0
  228. package/dist/src/packages/launch.js +61 -13
  229. package/dist/src/packages/repo-reads.js +41 -0
  230. package/dist/src/packages/service.js +169 -243
  231. package/dist/src/packages/skills-package.js +39 -0
  232. package/dist/src/packages/stdio.js +24 -0
  233. package/dist/src/packages/version.js +2 -1
  234. package/dist/src/pass-memo.js +27 -0
  235. package/dist/src/patch.js +2 -1
  236. package/dist/src/profiles/rules.js +2 -2
  237. package/dist/src/projects/check.js +3 -2
  238. package/dist/src/projects/remotes.js +2 -1
  239. package/dist/src/projects/target-read.js +2 -1
  240. package/dist/src/review/open.js +27 -4
  241. package/dist/src/review/outsider.js +39 -0
  242. package/dist/src/review/wiring.js +2 -1
  243. package/dist/src/secrets/catalog.js +2 -0
  244. package/dist/src/server-request.js +51 -6
  245. package/dist/src/server-response.js +10 -2
  246. package/dist/src/server.js +101 -3
  247. package/dist/src/service/account-packages.js +24 -41
  248. package/dist/src/service/accounts.js +88 -135
  249. package/dist/src/service/badge.js +39 -6
  250. package/dist/src/service/chain-prompts.js +50 -5
  251. package/dist/src/service/chain.js +33 -378
  252. package/dist/src/service/chats.js +41 -0
  253. package/dist/src/service/cleanup.js +22 -7
  254. package/dist/src/service/cli-check.js +4 -4
  255. package/dist/src/service/defaults.js +32 -0
  256. package/dist/src/service/demo.js +3 -2
  257. package/dist/src/service/folders-here.js +21 -0
  258. package/dist/src/service/hosting-state.js +204 -0
  259. package/dist/src/service/hosting.js +153 -209
  260. package/dist/src/service/hub-bootstrap.js +204 -0
  261. package/dist/src/service/hub-brief.js +72 -0
  262. package/dist/src/service/hub-hooks.js +44 -0
  263. package/dist/src/service/hub-mcp.js +140 -0
  264. package/dist/src/service/install-check.js +19 -5
  265. package/dist/src/service/lifecycle.js +4 -2
  266. package/dist/src/service/machine-bootstrap.js +105 -0
  267. package/dist/src/service/machine-cards.js +62 -0
  268. package/dist/src/service/machine-chain.js +499 -0
  269. package/dist/src/service/machine-chats.js +91 -0
  270. package/dist/src/service/machine-context.js +103 -0
  271. package/dist/src/service/machine-host.js +226 -0
  272. package/dist/src/service/machine-link.js +476 -0
  273. package/dist/src/service/machine-network-options.js +12 -0
  274. package/dist/src/service/machine-network.js +741 -0
  275. package/dist/src/service/machine-packages.js +38 -0
  276. package/dist/src/service/machine-page.js +88 -0
  277. package/dist/src/service/machine-pool.js +177 -0
  278. package/dist/src/service/machine-process.js +84 -0
  279. package/dist/src/service/machine-services.js +117 -0
  280. package/dist/src/service/machine-settings.js +84 -0
  281. package/dist/src/service/machine-side.js +220 -0
  282. package/dist/src/service/page-history.js +31 -0
  283. package/dist/src/service/pool-after-green.js +92 -0
  284. package/dist/src/service/reassign.js +79 -0
  285. package/dist/src/service/session-monitor.js +119 -0
  286. package/dist/src/service/stats.js +3 -1
  287. package/dist/src/service/ticks.js +37 -0
  288. package/dist/src/service/trackers.js +1 -0
  289. package/dist/src/service.js +183 -440
  290. package/dist/src/sessions/agents.js +8 -4
  291. package/dist/src/sessions/cache.js +19 -0
  292. package/dist/src/sessions/chat.js +60 -13
  293. package/dist/src/sessions/inbox.js +10 -0
  294. package/dist/src/sessions/inboxes.js +112 -0
  295. package/dist/src/sessions/keepwarm.js +14 -0
  296. package/dist/src/sessions/lingering.js +4 -0
  297. package/dist/src/sessions/mail.js +3 -1
  298. package/dist/src/sessions/mailRelay.js +38 -2
  299. package/dist/src/sessions/mailbox-store.js +25 -0
  300. package/dist/src/sessions/mailbox.js +55 -26
  301. package/dist/src/sessions/monitor.js +17 -1
  302. package/dist/src/sessions/note.js +15 -4
  303. package/dist/src/sessions/orphans.js +131 -0
  304. package/dist/src/sessions/remote.js +2 -0
  305. package/dist/src/sessions/runs.js +39 -21
  306. package/dist/src/sessions/title.js +11 -6
  307. package/dist/src/sessions/transcript.js +41 -16
  308. package/dist/src/sessions/turn-ends.js +23 -0
  309. package/dist/src/sessions/view-index.js +38 -0
  310. package/dist/src/sessions/warm-pings.js +30 -0
  311. package/dist/src/settings/defaults.js +6 -1
  312. package/dist/src/settings/registry.js +49 -13
  313. package/dist/src/start.js +110 -0
  314. package/dist/src/stats/base-sql.js +8 -0
  315. package/dist/src/stats/machine-tally.js +46 -0
  316. package/dist/src/stats/model.js +3 -2
  317. package/dist/src/stats/reader.js +69 -16
  318. package/dist/src/stats/tally-schema.js +1 -1
  319. package/dist/src/stats/tally.js +13 -0
  320. package/dist/src/storage/backup-schedule.js +9 -2
  321. package/dist/src/storage/copy.js +9 -3
  322. package/dist/src/storage/database-steps.js +942 -0
  323. package/dist/src/storage/database.js +2 -630
  324. package/dist/src/storage/json-folder.js +44 -9
  325. package/dist/src/storage/migrations.js +6 -1
  326. package/dist/src/storage/owner.js +1 -1
  327. package/dist/src/storage/schema.js +1 -1
  328. package/dist/src/taskmcp/calls.js +26 -12
  329. package/dist/src/taskmcp/carried.js +69 -0
  330. package/dist/src/taskmcp/downloads.js +68 -32
  331. package/dist/src/taskmcp/files.js +4 -0
  332. package/dist/src/taskmcp/handoff.js +21 -0
  333. package/dist/src/taskmcp/history.js +48 -0
  334. package/dist/src/taskmcp/machine.js +205 -0
  335. package/dist/src/taskmcp/server.js +7 -2
  336. package/dist/src/taskmcp/tools.js +24 -4
  337. package/dist/src/tools/panel.js +5 -3
  338. package/dist/src/tools/sessionSettings.js +4 -1
  339. package/dist/src/tracker/author.js +13 -0
  340. package/dist/src/tracker/brief.js +24 -0
  341. package/dist/src/tracker/comments.js +19 -2
  342. package/dist/src/tracker/control.js +6 -1
  343. package/dist/src/tracker/editor.js +3 -2
  344. package/dist/src/tracker/error-text.js +21 -0
  345. package/dist/src/tracker/export-target.js +2 -1
  346. package/dist/src/tracker/export.js +116 -53
  347. package/dist/src/tracker/file-names.js +34 -0
  348. package/dist/src/tracker/history-export.js +14 -0
  349. package/dist/src/tracker/history.js +55 -0
  350. package/dist/src/tracker/import-plan.js +155 -0
  351. package/dist/src/tracker/import-retry.js +107 -0
  352. package/dist/src/tracker/import-source.js +33 -0
  353. package/dist/src/tracker/import.js +34 -0
  354. package/dist/src/tracker/link.js +4 -8
  355. package/dist/src/tracker/model.js +13 -0
  356. package/dist/src/tracker/pace.js +74 -0
  357. package/dist/src/tracker/parents.js +2 -1
  358. package/dist/src/tracker/rate-limit.js +63 -0
  359. package/dist/src/tracker/source.js +16 -6
  360. package/dist/src/tracker/start.js +72 -9
  361. package/dist/src/tracker/transfer-check.js +278 -0
  362. package/dist/src/tracker/transfer-stop.js +49 -0
  363. package/dist/src/updates/checkout.js +8 -0
  364. package/dist/src/updates/follow.js +108 -0
  365. package/dist/src/updates/model.js +23 -11
  366. package/dist/src/updates/rebuild.js +27 -0
  367. package/dist/src/updates/run.js +32 -16
  368. package/dist/src/updates/runner.js +193 -12
  369. package/dist/src/updates/steps.js +9 -6
  370. package/dist/src/updates/updater.js +18 -12
  371. package/dist/tally/src/activity-result.js +24 -0
  372. package/dist/tally/src/activity.js +52 -0
  373. package/dist/tally/src/chat-sessions.js +14 -0
  374. package/dist/tally/src/classify.js +2 -2
  375. package/dist/tally/src/collect.js +12 -4
  376. package/dist/tally/src/db-activity.js +28 -0
  377. package/dist/tally/src/db-backfills.js +38 -0
  378. package/dist/tally/src/db.js +104 -101
  379. package/dist/tally/src/machine-rows.js +23 -0
  380. package/dist/tally/src/migrations/17-machines.sql +7 -0
  381. package/dist/tally/src/migrations/18-chat-sessions.sql +70 -0
  382. package/dist/tally/src/migrations/19-limit-shares-one-pass.sql +32 -0
  383. package/dist/tally/src/migrations/20-warm-pings.sql +114 -0
  384. package/dist/tally/src/migrations/21-session-activity.sql +80 -0
  385. package/dist/tally/src/migrations/22-line-raws.sql +57 -0
  386. package/dist/tally/src/migrations.js +1 -1
  387. package/dist/tally/src/ship.js +82 -0
  388. package/dist/tally/src/step-runs.js +5 -20
  389. package/dist/tally/src/stream.js +4 -6
  390. package/dist/tally/src/turns.js +2 -2
  391. package/dist/tally/src/warm-pings.js +15 -0
  392. package/dist/web/assets/BadgeDialog-B_puf4gn.js +1 -0
  393. package/dist/web/assets/ButtonWithTip-CKUX2Zj9.css +1 -0
  394. package/dist/web/assets/ButtonWithTip-Dv_lTY2w.js +1 -0
  395. package/dist/web/assets/ChainDivider-BWHmlwAN.css +1 -0
  396. package/dist/web/assets/ChainDivider-CAgORlAt.js +2 -0
  397. package/dist/web/assets/{DescriptionEditor-BGZ9A6x7.js → DescriptionEditor-BP9G4eW1.js} +5 -5
  398. package/dist/web/assets/FixButtons-VKGqxhsJ.js +7 -0
  399. package/dist/web/assets/FixButtons-xuzSmDiG.css +1 -0
  400. package/dist/web/assets/Loader-CRa8gNSO.css +1 -0
  401. package/dist/web/assets/Loader-gLtpd-HU.js +1 -0
  402. package/dist/web/assets/NewChatDialog-BNeZwqhQ.css +1 -0
  403. package/dist/web/assets/NewChatDialog-BPhSEUlM.js +1 -0
  404. package/dist/web/assets/OutsideView-CjqU_1_v.js +1 -0
  405. package/dist/web/assets/OutsideView-Hfkm7sQH.css +1 -0
  406. package/dist/web/assets/ProjectChatWindow-DFHqXtJT.js +1 -0
  407. package/dist/web/assets/ProjectPackages-C3WBhYWn.js +1 -0
  408. package/dist/web/assets/Select-ClnxKCav.js +1 -0
  409. package/dist/web/assets/Select-L3DXe4x4.css +1 -0
  410. package/dist/web/assets/TaskCard-DQJ_pizZ.js +2 -0
  411. package/dist/web/assets/TaskCard-MSKfeQSB.css +1 -0
  412. package/dist/web/assets/TranscriptWindow-B_0lkEov.css +1 -0
  413. package/dist/web/assets/TranscriptWindow-D-EQPrlF.js +6 -0
  414. package/dist/web/assets/TranscriptWindow-DTy64neg.js +1 -0
  415. package/dist/web/assets/accountParts-CIVGro5M.css +1 -0
  416. package/dist/web/assets/accountParts-CxNOHLQV.js +3 -0
  417. package/dist/web/assets/blocks-C3-5RdLi.css +1 -0
  418. package/dist/web/assets/blocks-DEe611CF.js +14 -0
  419. package/dist/web/assets/cardDrafts-BIJBcK7y.css +1 -0
  420. package/dist/web/assets/cardDrafts-Cu4oR7jf.js +12 -0
  421. package/dist/web/assets/cardSide-EOcop8Wv.css +1 -0
  422. package/dist/web/assets/cardSide-rO6Ughfv.js +2 -0
  423. package/dist/web/assets/{feedLine-CBjZXWwX.css → feedPin-BXDM-u8h.css} +1 -1
  424. package/dist/web/assets/feedPin-CHY_Owsx.js +3 -0
  425. package/dist/web/assets/format-DecSum6S.js +1 -0
  426. package/dist/web/assets/index-BgmurD3-.js +36 -0
  427. package/dist/web/assets/index-KJhwihX1.css +1 -0
  428. package/dist/web/assets/lib-D5hQoyXI.js +18 -0
  429. package/dist/web/assets/overview-BGjnxKG3.css +1 -0
  430. package/dist/web/assets/packageGroups-B-lwU2vO.js +1 -0
  431. package/dist/web/assets/packages-Cr9yWzy2.css +1 -0
  432. package/dist/web/assets/{react-dom-m8C9mC5F.js → react-dom-CzZfPJAD.js} +1 -1
  433. package/dist/web/assets/settingsRun-Cl3nW7b_.css +1 -0
  434. package/dist/web/assets/settingsRun-D-Dqm7pY.js +3 -0
  435. package/dist/web/assets/useFileDrop-ChaeIqmQ.js +1 -0
  436. package/dist/web/assets/useRowFocus-9aJnL77Z.js +1 -0
  437. package/dist/web/index.html +32 -24
  438. package/even-keel.config.example.json +1 -2
  439. package/package.json +11 -5
  440. package/plugins/agent-bridge/.claude-plugin/plugin.json +2 -2
  441. package/plugins/agent-bridge/.mcp.json +8 -0
  442. package/plugins/agent-bridge/README.md +4 -0
  443. package/plugins/agent-bridge/hooks/checkpoint-mark.mjs +4 -3
  444. package/plugins/agent-bridge/hooks/evenkeel.mjs +40 -3
  445. package/plugins/agent-bridge/hooks/handoff.mjs +12 -2
  446. package/plugins/agent-bridge/hooks/hooks.json +9 -0
  447. package/plugins/agent-bridge/hooks/inbox.mjs +26 -0
  448. package/plugins/agent-bridge/hooks/mailpost.mjs +52 -0
  449. package/plugins/agent-bridge/hooks/merge-check.mjs +2 -1
  450. package/plugins/agent-bridge/hooks/merges.mjs +24 -1
  451. package/plugins/agent-bridge/hooks/nudges.mjs +16 -7
  452. package/plugins/agent-bridge/opencode/agent-bridge.mjs +17 -14
  453. package/plugins/tally/.claude-plugin/plugin.json +1 -1
  454. package/plugins/tally/skills/session-audit/SKILL.md +4 -4
  455. package/plugins/tasks/.claude-plugin/plugin.json +1 -1
  456. package/plugins/tasks/skills/split/SKILL.md +4 -1
  457. package/plugins/tasks/skills/task/SKILL.md +1 -0
  458. package/service/EvenKeelTray.cs +52 -4
  459. package/service/install.ps1 +25 -3
  460. package/service/install.sh +61 -4
  461. package/dist/web/assets/BadgeDialog-Dytdlslk.js +0 -1
  462. package/dist/web/assets/ProjectPackages-XDRyVrDZ.js +0 -1
  463. package/dist/web/assets/Select-C1zxlcfk.js +0 -1
  464. package/dist/web/assets/Select-CYemy5Na.css +0 -1
  465. package/dist/web/assets/TaskCard-BV2lQojC.css +0 -1
  466. package/dist/web/assets/TaskCard-ixAKvQuF.js +0 -2
  467. package/dist/web/assets/TranscriptWindow-BNF7AkTM.css +0 -1
  468. package/dist/web/assets/TranscriptWindow-DJUwXoAb.js +0 -4
  469. package/dist/web/assets/accountParts-BRDCFhw7.js +0 -3
  470. package/dist/web/assets/accountParts-tFRVownp.css +0 -1
  471. package/dist/web/assets/blocks-CRzT04_P.js +0 -12
  472. package/dist/web/assets/blocks-Dx3DACiG.css +0 -1
  473. package/dist/web/assets/cardDrafts-2oX1SbA7.css +0 -1
  474. package/dist/web/assets/cardDrafts-D7iH-zNK.js +0 -12
  475. package/dist/web/assets/cardSide-63fNWHHv.css +0 -1
  476. package/dist/web/assets/cardSide-DT3aKjf9.js +0 -2
  477. package/dist/web/assets/feedLine-C60ODRrO.js +0 -1
  478. package/dist/web/assets/hooks-UYkBK54l.js +0 -1
  479. package/dist/web/assets/index-BUZWji2e.css +0 -1
  480. package/dist/web/assets/index-DrV6L65j.js +0 -25
  481. package/dist/web/assets/lib-CzxqvNiV.js +0 -18
  482. package/dist/web/assets/overview-B7iEgjQD.css +0 -1
  483. package/dist/web/assets/overview-DVOx9Lzw.js +0 -7
  484. package/dist/web/assets/packageGroups-py7H8wzR.js +0 -1
  485. package/dist/web/assets/packages-Dld4uH9X.css +0 -1
  486. package/dist/web/assets/rules-Bm27YbzZ.js +0 -1
  487. package/dist/web/assets/useFileDrop-DiTOLKSY.js +0 -1
  488. package/dist/web/assets/useHeightGlide-B2o4yzDR.css +0 -1
  489. package/dist/web/assets/useHeightGlide-Cx8nEUXF.js +0 -3
  490. package/dist/web/assets/useRowFocus-DKQshgF0.js +0 -1
  491. /package/dist/web/assets/{rules-Bgil4ZBp.css → lib-Bgil4ZBp.css} +0 -0
package/.env.example CHANGED
@@ -23,11 +23,19 @@
23
23
  # EVEN_KEEL_HOST=127.0.0.1
24
24
  # EVEN_KEEL_PORT=4747
25
25
 
26
+ # Sample the service CPU and save profiles of event-loop stalls in logs/. Off by default.
27
+ # EVEN_KEEL_STALL_PROFILE=1
28
+
26
29
  # The local MCP gateway chain sessions reach their packages' servers through (docs/packages.md); always on 127.0.0.1.
27
30
  # EVEN_KEEL_MCP_PORT=4748
28
31
 
32
+ # The port the hub listens for other machines on, on all interfaces, while "Hub address for machines" is set (docs/machines.md). Read at startup.
33
+ # EVEN_KEEL_MACHINES_PORT=4749
34
+
29
35
  # The page's token for requests from other machines; required when EVEN_KEEL_HOST is not loopback (docs/guide/setup.md).
30
36
  # EVEN_KEEL_TOKEN=change-me-0123456789abcdef
37
+ # For Docker Compose, set a fresh token above. Image tag: latest, next, or an exact version.
38
+ # EVEN_KEEL_IMAGE_TAG=latest
31
39
 
32
40
  # Folder with one Claude config folder per extra account; defaults to ~/.claude-accounts.
33
41
  # EVEN_KEEL_ACCOUNTS_DIR=C:\Users\john.doe\.claude-accounts
@@ -64,3 +72,5 @@
64
72
  # TALLY_LLM_URL=http://100.64.0.1:4000
65
73
  # TALLY_LLM_KEY=sk-change-me
66
74
  # TALLY_LLM_MODEL=google-gemini-3.1-flash-lite
75
+ # The chat microphone's model on the same LiteLLM (it must take audio); empty — the one below.
76
+ # TALLY_LLM_DICTATION_MODEL=google-gemini-3.5-flash-lite
package/CHANGELOG.md CHANGED
@@ -122,6 +122,10 @@ A patch of 0.3: the CI and limit fixes that cost a chain time, and a clearer car
122
122
  - The ⋯ menu of an account row offers **Replace key** for a working key too.
123
123
  - **`even-keel install`, `even-keel update` and the first install from `npx` print the page's address** once the page answers, taken from `EVEN_KEEL_HOST`/`EVEN_KEEL_PORT` of the environment and the data folder's `.env`. If the page has not answered after 30 s, they say where the log is instead. The first install from `npx` then opens the page in the browser. On Linux it does that only on a desktop with a display, never over SSH.
124
124
 
125
+ ### Added
126
+
127
+ - **A Claude subscription can be added on a long token.** "Subscription" in the new Claude Code account dialog now offers two cards: the full sign-in, with what it gives, and the long token of `claude setup-token`, with what it lacks — no Remote Control, limits only while a session runs, no e-mail, a new token in a year. Paste the token and one short turn checks it before the account is added; say which full sign-in it is the same account as, and it shows that account's limits. The account's row shows "long token" and its last day, warns a month before it, and "Issue a new token" replaces a refused or outdated one in the same folder.
128
+
125
129
  ### Changed
126
130
 
127
131
  - **What a task runs on is set on its card, not by a tracker label.** A task's run — provider, model and effort — is kept by Even Keel: the card's **Runs on** picks it, and a session can set it through the tasks server's `run` field of `tasks_create` and `task_update`. The effort is new: Claude Code's `low` to `max`, Codex's `minimal` to `xhigh`, OpenCode's variant and Copilot's reasoning effort; empty passes none. Labels `<Provider> | <model>` are no longer read. The update moves the run label of each open task into its run once, in the projects that had run labels on; the labels stay in the tracker. The setting `modelLabels` is removed.
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  **You write the tickets. It takes the night shift.** Even Keel is a service on your own machine that you drive from one web page. It takes a project's open tasks, in the order of their `blocks` links, and works through them one at a time with [Claude Code](https://docs.claude.com/en/docs/claude-code/overview), [Codex](https://github.com/openai/codex), [OpenCode](https://opencode.ai) or [GitHub Copilot](https://github.com/github/copilot-cli) while you do something else. It waits out a spent usage limit, hands a long session over to a fresh one and keeps going while you are away; only a question or a decision waits for you — on that page, in the tracker or on your phone.
11
11
 
12
- **Who it's for:** you have a bunch of ideas and an agent subscription, and you'd rather have the agent work through them one task at a time than watch a terminal. No tracker? It has one built in. No git? A plain folder works.
12
+ **Who it's for:** you have a bunch of ideas and an agent subscription, and you'd rather have the agent work through them one task at a time than watch a terminal. No tracker? It has one built in. No git? A plain folder works. No subscription? OpenCode's free models, Codex and Copilot free tiers work too.
13
13
 
14
14
  **Not for:** ten agents at once — it runs one task per folder, on purpose. And it won't write your tasks for you: a clear task makes a good night.
15
15
 
@@ -89,6 +89,8 @@ Parallel agents decide on their own what an unfinished task will look like, hand
89
89
 
90
90
  ## As a service
91
91
 
92
+ On a server or NAS, [install with Docker Compose](docs/guide/docker.md) and update by pulling the image.
93
+
92
94
  `npx even-keel` sets it up as your own user, no administrator needed: a start at sign-in with a tray icon on Windows, a systemd user unit on Linux, a launchd agent on macOS. It restarts Even Keel if it fails; stopping it leaves running sessions alone. `even-keel install` sets it up again (in PowerShell `even-keel.cmd`, [why](docs/guide/setup.md#windows-powershell)). Logs, the data folder, running it in a terminal or from a clone: [setup](docs/guide/setup.md#as-a-service).
93
95
 
94
96
  ## Updating
@@ -105,7 +107,7 @@ The settings live in Even Keel's database and are edited on the page, applied at
105
107
 
106
108
  ## What comes next
107
109
 
108
- Looked at, not promised: several machines taking the tasks of one project, running in Docker, a cap on how much of the usage limit one task may spend.
110
+ Looked at, not promised: several machines taking the tasks of one project, a cap on how much of the usage limit one task may spend.
109
111
 
110
112
  ## Extending
111
113
 
@@ -1,7 +1,7 @@
1
1
  import { AccountHomes, accountsRoot, codexAccountsRoot, copilotAccountsRoot, openCodeAccountsRoot } from './homes.js';
2
2
  import { inTransaction } from '../storage/database.js';
3
3
  /** Registration belongs to this installation; a CLI's own folder and credentials remain the CLI's. */
4
- export async function openAccountHomes(db, env) {
4
+ export async function openAccountHomes(db, env, stateTable = 'service_state') {
5
5
  const { rows } = await db.query('select account from global_accounts');
6
6
  const registration = {
7
7
  keys: new Set(rows.map((row) => row.account)),
@@ -10,13 +10,13 @@ export async function openAccountHomes(db, env) {
10
10
  },
11
11
  };
12
12
  const homes = new AccountHomes(env, accountsRoot(env), codexAccountsRoot(env), openCodeAccountsRoot(env), copilotAccountsRoot(env), registration);
13
- const legacy = await db.query("select 1 from service_state where name = 'accounts.adoptLegacy'");
13
+ const legacy = await db.query(`select 1 from ${stateTable} where name = 'accounts.adoptLegacy'`);
14
14
  if (legacy.rows.length > 0) {
15
15
  const visible = homes.availableGlobals();
16
16
  await inTransaction(db, async (tx) => {
17
17
  for (const home of visible)
18
18
  await tx.query('insert into global_accounts (account) values ($1) on conflict do nothing', [home.key]);
19
- await tx.query("delete from service_state where name = 'accounts.adoptLegacy'");
19
+ await tx.query(`delete from ${stateTable} where name = 'accounts.adoptLegacy'`);
20
20
  });
21
21
  for (const home of visible)
22
22
  registration.keys.add(home.key);
@@ -14,6 +14,7 @@ import { shortLivedProfile } from './aws.js';
14
14
  import { userCredentials } from './gcloud.js';
15
15
  import { cloudEnv, cloudOf } from './cloud.js';
16
16
  import { KeychainCredentials, keychainService } from './keychain.js';
17
+ import { readLongToken, writeLongToken } from './longToken.js';
17
18
  import { CODEX_ACCOUNT, folderName, GLOBAL_ACCOUNT, parseCredentialTimes } from './model.js';
18
19
  import { API_KEY_VARIABLE, shareConfig } from './share.js';
19
20
  const PENDING_PREFIX = '.pending-';
@@ -206,6 +207,21 @@ export class AccountHomes {
206
207
  writeFileSync(join(home.dir, 'settings.json'), JSON.stringify({ env: cloudEnv(connection) }, null, 2));
207
208
  return home;
208
209
  }
210
+ /**
211
+ * A subscription account on a long token of `claude setup-token` (BTN-1005): a Claude folder whose `settings.json`
212
+ * carries the token, as an API account's carries its key; named `token` when the name is blank.
213
+ */
214
+ addLongToken(name, token, now, tie = {}) {
215
+ const home = this.home(CLAUDE, folderName(name.trim() === '' ? 'token' : name, this.taken()));
216
+ mkdirSync(home.dir, { recursive: true });
217
+ this.forget();
218
+ writeLongToken(home.dir, token, now, tie);
219
+ return home;
220
+ }
221
+ /** The long token a Claude folder runs on; null for a folder signed in any other way. */
222
+ longTokenOf(home) {
223
+ return home.agent === CLAUDE ? readLongToken(home.dir) : null;
224
+ }
209
225
  /** The cloud a Claude folder's `settings.json` connects to; null for any other folder. */
210
226
  cloudOf(home) {
211
227
  if (home.agent !== CLAUDE)
@@ -0,0 +1,99 @@
1
+ import { readFileSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { fail } from '../notice/notice.js';
4
+ import { OAUTH_TOKEN_VARIABLE } from './share.js';
5
+ /** What Even Keel knows of a folder's long token beside the token itself; kept in the account folder, never in git. */
6
+ export const LONG_TOKEN_FILE = 'even-keel-token.json';
7
+ /** `claude setup-token` issues a token for a year and the token carries no readable date: counted from the day it was added. */
8
+ const VALID_MS = 365 * 24 * 3600_000;
9
+ const TOKEN = /^sk-ant-oat\d\d-\S{20,}$/;
10
+ /** The trimmed token of the form `claude setup-token` prints; an API key or anything else is refused. */
11
+ export function assertLongToken(token) {
12
+ const value = token.trim();
13
+ if (!TOKEN.test(value))
14
+ throw fail('account.tokenInvalid', {});
15
+ return value;
16
+ }
17
+ function readObject(file) {
18
+ try {
19
+ const parsed = JSON.parse(readFileSync(file, 'utf8'));
20
+ return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? parsed : {};
21
+ }
22
+ catch {
23
+ return {};
24
+ }
25
+ }
26
+ function tokenIn(dir) {
27
+ const env = readObject(join(dir, 'settings.json')).env;
28
+ const token = typeof env === 'object' && env !== null ? env[OAUTH_TOKEN_VARIABLE] : undefined;
29
+ return typeof token === 'string' && token !== '' ? token : null;
30
+ }
31
+ /** The folder's long token as Even Keel knows it; null — its `settings.json` holds none. */
32
+ export function readLongToken(dir) {
33
+ if (tokenIn(dir) === null)
34
+ return null;
35
+ const kept = readObject(join(dir, LONG_TOKEN_FILE));
36
+ const account = accountOf(kept.account);
37
+ return {
38
+ until: typeof kept.until === 'string' ? kept.until : null,
39
+ ...(typeof kept.sameAs === 'string' && kept.sameAs !== '' && { sameAs: kept.sameAs }),
40
+ ...(account !== undefined && { account }),
41
+ ...(typeof kept.refusedAt === 'string' && { refusedAt: kept.refusedAt }),
42
+ };
43
+ }
44
+ function accountOf(value) {
45
+ if (typeof value !== 'object' || value === null)
46
+ return undefined;
47
+ const { account, email } = value;
48
+ if (typeof account !== 'string' || account === '')
49
+ return undefined;
50
+ return { account, email: typeof email === 'string' && email !== '' ? email : null };
51
+ }
52
+ /** The token into the folder's `settings.json`, the rest of the file as it was, and a year from `now` as its last day. */
53
+ export function writeLongToken(dir, token, now, tie = {}) {
54
+ const file = join(dir, 'settings.json');
55
+ const settings = readObject(file);
56
+ const env = typeof settings.env === 'object' && settings.env !== null ? settings.env : {};
57
+ writeFileSync(file, JSON.stringify({ ...settings, env: { ...env, [OAUTH_TOKEN_VARIABLE]: token } }, null, 2));
58
+ const kept = {
59
+ until: new Date(now.getTime() + VALID_MS).toISOString(),
60
+ ...(tie.sameAs !== undefined && { sameAs: tie.sameAs }),
61
+ ...(tie.account !== undefined && { account: tie.account }),
62
+ };
63
+ writeFileSync(join(dir, LONG_TOKEN_FILE), JSON.stringify(kept, null, 2));
64
+ }
65
+ /** Puts back what `takeLongToken` returned, after a new token failed its check. */
66
+ export function restoreLongToken(dir, held) {
67
+ const file = join(dir, 'settings.json');
68
+ const settings = readObject(file);
69
+ const env = typeof settings.env === 'object' && settings.env !== null ? settings.env : {};
70
+ writeFileSync(file, JSON.stringify({ ...settings, env: { ...env, [OAUTH_TOKEN_VARIABLE]: held.token } }, null, 2));
71
+ if (held.kept === null)
72
+ rmSync(join(dir, LONG_TOKEN_FILE), { force: true });
73
+ else
74
+ writeFileSync(join(dir, LONG_TOKEN_FILE), held.kept);
75
+ }
76
+ /** The folder's token and its file as they are, to put back; null — the folder holds no token. */
77
+ export function takeLongToken(dir) {
78
+ const token = tokenIn(dir);
79
+ if (token === null)
80
+ return null;
81
+ try {
82
+ return { token, kept: readFileSync(join(dir, LONG_TOKEN_FILE), 'utf8') };
83
+ }
84
+ catch {
85
+ return { token, kept: null };
86
+ }
87
+ }
88
+ /** Notes that the provider refused the folder's token; false — already noted or no token there. */
89
+ export function noteTokenRefused(dir, at) {
90
+ const known = readLongToken(dir);
91
+ if (known === null || known.refusedAt !== undefined)
92
+ return false;
93
+ writeFileSync(join(dir, LONG_TOKEN_FILE), JSON.stringify({ ...known, refusedAt: at }, null, 2));
94
+ return true;
95
+ }
96
+ /** The token no longer signs the folder in: refused by the provider, or past its last day. */
97
+ export function tokenOver(token, now) {
98
+ return token.refusedAt !== undefined || (token.until !== null && Date.parse(token.until) <= now.getTime());
99
+ }
@@ -84,7 +84,7 @@ export async function guardSettingsEdit(input, config, ask = async () => {
84
84
  && paths.basename(account.key) === account.key
85
85
  && targets.some((path) => samePath(path, paths.join(config.accountsDir, account.key, 'settings.json'), platform));
86
86
  });
87
- return managed ? 'Even Keel manages this account folder’s settings.json. Edit shared settings in ~/.claude/settings.json; Even Keel transfers them to all Claude accounts before launch. For account-only settings, use Accounts in Even Keel: resolve a settings change with “Keep for this account only”.' : null;
87
+ return managed ? 'Even Keel manages this account folder’s settings.json. Edit shared settings in ~/.claude/settings.json; Even Keel transfers them to all Claude accounts before launch. For account-only settings, use Accounts in Even Keel: resolve a settings change with “This account only”.' : null;
88
88
  }
89
89
  catch {
90
90
  return null;
@@ -38,6 +38,36 @@ export function editedKeys(folder, written) {
38
38
  const keys = new Set([...Object.keys(folder), ...Object.keys(written)]);
39
39
  return [...keys].filter((key) => !SILENT_KEYS.has(key) && !FOLDER_KEYS.has(key) && comparable(key, folder[key]) !== comparable(key, written[key])).sort();
40
40
  }
41
+ /** Longer values are cut: the page shows them in a tip, and a whole `hooks` block would weigh on every state. */
42
+ const SHOWN_VALUE = 2000;
43
+ function shown(value) {
44
+ if (value === undefined)
45
+ return undefined;
46
+ const text = JSON.stringify(value);
47
+ return text.length <= SHOWN_VALUE ? text : `${text.slice(0, SHOWN_VALUE - 1)}…`;
48
+ }
49
+ /** What the page shows of an edited key: its value before and after, or for `env` only the names of what moved. */
50
+ export function settingsEdit(key, was, now) {
51
+ if (key === 'env') {
52
+ const before = sharedEnv(was);
53
+ const after = sharedEnv(now);
54
+ const names = [...new Set([...Object.keys(before), ...Object.keys(after)])].sort();
55
+ const differs = (name) => JSON.stringify(before[name]) !== JSON.stringify(after[name]);
56
+ return { key, variables: {
57
+ added: names.filter((name) => !(name in before)),
58
+ removed: names.filter((name) => !(name in after)),
59
+ changed: names.filter((name) => name in before && name in after && differs(name)),
60
+ } };
61
+ }
62
+ const edit = { key };
63
+ const before = shown(was);
64
+ const after = shown(now);
65
+ if (before !== undefined)
66
+ edit.was = before;
67
+ if (after !== undefined)
68
+ edit.now = after;
69
+ return edit;
70
+ }
41
71
  /** The transfer of `settings.json` with the account's layer on top and the folder's own edits kept (`docs/accounts.md`). */
42
72
  export function planSettings(global, folder, record, discard = new Set()) {
43
73
  const file = mergeSettings(global, folder);
@@ -88,6 +118,10 @@ export class AccountSettings {
88
118
  }
89
119
  /** The folder edits that would still need a decision at the next transfer. */
90
120
  edits(home) {
121
+ return this.changes(home).map((change) => change.key);
122
+ }
123
+ /** `edits` with what each key was and is now. */
124
+ changes(home) {
91
125
  const record = this.records.get(home.key);
92
126
  if (record === undefined)
93
127
  return [];
@@ -99,20 +133,31 @@ export class AccountSettings {
99
133
  const stamp = `${this.version}:${folderStamp}:${fileStamp(globalFile)}`;
100
134
  const cached = this.seen.get(home.key);
101
135
  if (cached?.stamp === stamp)
102
- return cached.edits;
103
- const folder = readJson(file);
104
- const edits = folder === undefined ? [] : planSettings(stripSettingsGuard(readJson(globalFile) ?? {}), stripSettingsGuard(folder), record, this.discards.get(home.key)).edits;
105
- this.seen.set(home.key, { stamp, edits });
106
- return edits;
136
+ return cached.changes;
137
+ const read = readJson(file);
138
+ const folder = stripSettingsGuard(read ?? {});
139
+ const written = stripSettingsGuard(record.written);
140
+ const changes = read === undefined ? [] : planSettings(stripSettingsGuard(readJson(globalFile) ?? {}), folder, record, this.discards.get(home.key)).edits.map((key) => settingsEdit(key, written[key], folder[key]));
141
+ this.seen.set(home.key, { stamp, changes });
142
+ return changes;
107
143
  }
108
144
  /** The keys of the account's own layer. */
109
145
  own(account) {
110
146
  return Object.keys(this.records.get(account)?.own ?? {}).sort();
111
147
  }
112
- /** Takes effect at the next transfer into the folder, which the caller starts. */
113
- resolve(home, key, choice) {
148
+ /** Every key or none: a key that is no edit any more refuses them all. Takes effect at the next transfer, which the caller starts. */
149
+ resolve(home, keys, choice) {
150
+ const list = typeof keys === 'string' ? [keys] : keys;
151
+ const edits = this.edits(home);
152
+ const missing = list.find((key) => !edits.includes(key));
153
+ if (missing !== undefined)
154
+ throw fail('account.settingsNoEdit', { account: home.key, key: missing });
155
+ for (const key of new Set(list))
156
+ this.resolveOne(home, key, choice);
157
+ }
158
+ resolveOne(home, key, choice) {
114
159
  const record = this.records.get(home.key);
115
- if (record === undefined || !this.edits(home).includes(key))
160
+ if (record === undefined)
116
161
  throw fail('account.settingsNoEdit', { account: home.key, key });
117
162
  const value = stripSettingsGuard(readJson(join(home.dir, 'settings.json')) ?? {})[key];
118
163
  if (choice === 'discard') {
@@ -20,17 +20,26 @@ const ONBOARDING_KEYS = ['hasCompletedOnboarding', 'lastOnboardingVersion'];
20
20
  const LINKED_DIRS = ['agents', 'commands', 'hooks', 'output-styles'];
21
21
  const OWN_SKILLS = new Set(['synced', '.trash']);
22
22
  export const API_KEY_VARIABLE = 'ANTHROPIC_API_KEY';
23
+ /** The long-lived token of `claude setup-token` (BTN-1005): it makes a long-token account, never shared between folders. */
24
+ export const OAUTH_TOKEN_VARIABLE = 'CLAUDE_CODE_OAUTH_TOKEN';
23
25
  const COPIED_FILES = ['CLAUDE.md', join('plugins', 'installed_plugins.json'), join('plugins', 'known_marketplaces.json')];
24
26
  /**
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
+ * The global settings win, except the folder's own API key, long token and cloud connection: they are what makes an API,
28
+ * a long-token or a cloud account (`docs/accounts.md`). A cloud folder takes none of the cloud's variables from the global
29
+ * settings, and no folder takes the global long token.
27
30
  */
28
31
  export function mergeSettings(global, folder) {
29
32
  const merged = { ...folder, ...global };
30
33
  const own = objectOf(folder?.env);
34
+ const globalEnv = Object.fromEntries(Object.entries(objectOf(global.env)).filter(([name]) => name !== OAUTH_TOKEN_VARIABLE));
35
+ if (OAUTH_TOKEN_VARIABLE in objectOf(global.env))
36
+ merged.env = globalEnv;
31
37
  const key = own[API_KEY_VARIABLE];
32
38
  if (typeof key === 'string')
33
- merged.env = { ...objectOf(global.env), [API_KEY_VARIABLE]: key };
39
+ merged.env = { ...globalEnv, [API_KEY_VARIABLE]: key };
40
+ const token = own[OAUTH_TOKEN_VARIABLE];
41
+ if (typeof token === 'string')
42
+ merged.env = { ...globalEnv, [OAUTH_TOKEN_VARIABLE]: token };
34
43
  if (cloudOf(own) !== null) {
35
44
  const shared = Object.fromEntries(Object.entries(objectOf(merged.env ?? global.env)).filter(([name]) => !isCloudVariable(name)));
36
45
  const cloud = Object.fromEntries(Object.entries(own).filter(([name]) => isCloudVariable(name)));
@@ -0,0 +1,53 @@
1
+ import { CLAUDE } from '../claude/name.js';
2
+ import { fail } from '../notice/notice.js';
3
+ import { assertLongToken, restoreLongToken, takeLongToken, writeLongToken } from './longToken.js';
4
+ const reasonOf = (reason) => (reason instanceof Error ? reason.message : String(reason)).slice(0, 500);
5
+ /** The folder with a full sign-in the token is said to be of: a Claude folder that is on no token itself. */
6
+ function sameAccount(homes, key) {
7
+ if (key === undefined || key === null || key === '')
8
+ return undefined;
9
+ const home = homes.find(key);
10
+ if (home === undefined || home.agent !== CLAUDE || homes.longTokenOf(home) !== null)
11
+ throw fail('account.unknown', { key });
12
+ return key;
13
+ }
14
+ /**
15
+ * A subscription account on a long token (BTN-1005): the folder is made, one short turn runs on it, and a refusal
16
+ * removes it again, so no account is added that cannot run a session. `account` — the hub's account a machine's token
17
+ * is of (BTN-1002); `sameAs` may come as null through the link.
18
+ */
19
+ export async function addTokenAccount(accounts, name, token, sameAs, account) {
20
+ const value = assertLongToken(token);
21
+ const same = sameAccount(accounts.homes, sameAs);
22
+ const home = accounts.homes.addLongToken(name, value, accounts.now(), { ...(same !== undefined && { sameAs: same }), ...(account != null && { account }) });
23
+ try {
24
+ await accounts.check(home);
25
+ }
26
+ catch (reason) {
27
+ await accounts.homes.remove(home);
28
+ throw fail('account.tokenRejected', { reason: reasonOf(reason) });
29
+ }
30
+ return home;
31
+ }
32
+ /**
33
+ * A new token in the folder of a long-token account, its name, roles and pools kept: checked by one short turn, and the
34
+ * old one is put back when the new one is refused. Running sessions go on with the token they started with.
35
+ */
36
+ export async function replaceToken(accounts, home, token) {
37
+ const value = assertLongToken(token);
38
+ const held = home.global ? null : takeLongToken(home.dir);
39
+ if (held === null)
40
+ throw fail('account.keyNotHeld', { agent: home.agent });
41
+ const known = accounts.homes.longTokenOf(home);
42
+ writeLongToken(home.dir, value, accounts.now(), {
43
+ ...(known?.sameAs !== undefined && { sameAs: known.sameAs }),
44
+ ...(known?.account !== undefined && { account: known.account }),
45
+ });
46
+ try {
47
+ await accounts.check(home);
48
+ }
49
+ catch (reason) {
50
+ restoreLongToken(home.dir, held);
51
+ throw fail('account.tokenRejected', { reason: reasonOf(reason) });
52
+ }
53
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -8,6 +8,8 @@ import { CreditChecks } from './credit.js';
8
8
  import { KeyChecks } from './keycheck.js';
9
9
  import { CLAUDE } from '../claude/name.js';
10
10
  import { cloudErrorNotice } from './cloud-errors.js';
11
+ import { noteTokenRefused, tokenOver } from './longToken.js';
12
+ import { addTokenAccount, replaceToken } from './tokenAccount.js';
11
13
  import { cleanOutput, isApiKey, loginBlockNotice, loginCode, loginUrls, missingNotice, needsLogin, paysPerToken, removeProblem, secondFreeProblem, switchProblem, takesShared, withIdentity, } from './model.js';
12
14
  const MAX_OUTPUT_CHARS = 16 * 1024;
13
15
  const SHOWN_OUTPUT_CHARS = 2 * 1024;
@@ -45,6 +47,11 @@ export class AccountWatcher {
45
47
  balances = new Map();
46
48
  /** The account's own key `/credits` refused, by folder key: the balance is asked of the management key until it changes. */
47
49
  ownKeyRefused = new Map();
50
+ batching = false;
51
+ batched;
52
+ get tokens() {
53
+ return { homes: this.options.homes, check: this.options.checkCloud, now: this.options.now };
54
+ }
48
55
  constructor(options) {
49
56
  this.options = options;
50
57
  this.keys = new KeyChecks(options.keyCheckMs);
@@ -55,11 +62,54 @@ export class AccountWatcher {
55
62
  const known = this.known.find((entry) => entry.home.key === key);
56
63
  if (known === undefined)
57
64
  return true;
65
+ if (known.longToken !== null && tokenOver(known.longToken, this.options.now()))
66
+ return true;
58
67
  return needsLogin(known.status, this.options.homes.times(known.home), this.options.now()) || (isApiKey(known.status) && this.keys.rejected(key));
59
68
  }
69
+ /** The long token the account runs on, as of the last poll (BTN-1005). */
70
+ longToken(key) {
71
+ return this.known.find((entry) => entry.home.key === key)?.longToken ?? undefined;
72
+ }
73
+ /**
74
+ * The folder's e-mail as `view` shows it, its status's or the one its sign-in last showed, read without building the
75
+ * view (BTN-1317): a view reads every folder's files.
76
+ */
77
+ shownEmailOf(key) {
78
+ const known = this.known.find((entry) => entry.home.key === key);
79
+ if (known === undefined)
80
+ return null;
81
+ return known.status?.email ?? this.options.signedInAs?.(key)?.last ?? null;
82
+ }
83
+ /** A session's request was refused as not signed in: on a long token the account needs a new one, as after a sign-out. */
84
+ tokenRefused(key, at) {
85
+ const home = this.options.homes.find(key);
86
+ if (home !== undefined && this.longToken(key) !== undefined && noteTokenRefused(home.dir, at))
87
+ void this.refresh();
88
+ }
89
+ /**
90
+ * Runs `body` with one view for all its reads: a view reads every folder's files, and the machine's facts ask for it
91
+ * per project and per task. `body` must not change the accounts.
92
+ */
93
+ batch(body) {
94
+ if (this.batching)
95
+ return body();
96
+ this.batching = true;
97
+ try {
98
+ return body();
99
+ }
100
+ finally {
101
+ this.batching = false;
102
+ this.batched = undefined;
103
+ }
104
+ }
60
105
  get view() {
106
+ if (!this.batching)
107
+ return this.build();
108
+ return (this.batched ??= this.build());
109
+ }
110
+ build() {
61
111
  const now = this.options.now();
62
- const accounts = this.known.map(({ home, status, error, keyHeld, openRouter, cloud, remote }) => {
112
+ const accounts = this.known.map(({ home, status, error, keyHeld, openRouter, cloud, longToken, remote }) => {
63
113
  const times = this.options.homes.times(home);
64
114
  const transport = this.options.transportOf(home, paysPerToken(status));
65
115
  const seen = this.options.signedInAs?.(home.key);
@@ -84,9 +134,10 @@ export class AccountWatcher {
84
134
  configPending: this.options.configPending(home.key),
85
135
  ...this.settingsOf(home),
86
136
  apiKey: isApiKey(status),
87
- keyReplaceable: keyHeld && (isApiKey(status) || status?.authMethod === 'subscription_key'),
137
+ keyReplaceable: (keyHeld && (isApiKey(status) || status?.authMethod === 'subscription_key')) || (longToken !== null && !home.global),
138
+ ...(longToken !== null && { longToken }),
88
139
  ...(cloud !== null && { cloud }),
89
- ...(remote === false && fullSignIn(home, status) && { remoteOff: true }),
140
+ ...(remote === false && longToken === null && fullSignIn(home, status) && { remoteOff: true }),
90
141
  ...(this.checkedModels.has(home.key) && { checkedModel: this.checkedModels.get(home.key) ?? null }),
91
142
  ...(transport !== null && { transport }),
92
143
  limits: this.options.limits(home.key),
@@ -329,6 +380,13 @@ export class AccountWatcher {
329
380
  this.claimShared(home);
330
381
  await this.refresh();
331
382
  }
383
+ /** A subscription account on a long token of `claude setup-token`, checked by one short turn (`addTokenAccount`). */
384
+ async addLongToken(name, token, sameAs, account) {
385
+ const home = await addTokenAccount(this.tokens, name, token, sameAs, account);
386
+ this.options.name(home.key, name);
387
+ this.claimShared(home);
388
+ await this.refresh();
389
+ }
332
390
  /**
333
391
  * 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
334
392
  * is, and refused when the account's organization is known and the key's is another one. Running sessions go on with
@@ -338,6 +396,10 @@ export class AccountWatcher {
338
396
  const home = this.options.homes.find(key);
339
397
  if (home === undefined)
340
398
  throw fail('account.unknown', { key });
399
+ if (this.options.homes.longTokenOf(home) !== null) {
400
+ await replaceToken(this.tokens, home, value);
401
+ return this.refresh();
402
+ }
341
403
  const next = this.options.homes.replacement(home, value);
342
404
  const verdict = await this.accepted(home.agent, next, home.agent === 'opencode' && consoleKey(readAuth(home.dir)) !== null);
343
405
  const known = this.options.organizations.of(key);
@@ -424,14 +486,14 @@ export class AccountWatcher {
424
486
  const settings = this.options.settings;
425
487
  if (settings === undefined || home.global || home.agent !== CLAUDE)
426
488
  return {};
427
- const edits = settings.edits(home);
489
+ const edits = settings.changes(home);
428
490
  const own = settings.own(home.key);
429
491
  return { ...(edits.length > 0 && { settingsEdits: edits }), ...(own.length > 0 && { ownSettings: own }) };
430
492
  }
431
493
  /** An edit right in the folder's `settings.json`: made shared, kept as the account's own or dropped, then transferred. */
432
- async resolveSettingsEdit(key, setting, choice) {
494
+ async resolveSettingsEdit(key, settings, choice) {
433
495
  const home = this.claudeHome(key);
434
- this.options.settings?.resolve(home, setting, choice);
496
+ this.options.settings?.resolve(home, settings, choice);
435
497
  await this.options.prepare(home);
436
498
  this.options.onChange();
437
499
  }
@@ -508,7 +570,7 @@ export class AccountWatcher {
508
570
  async drop(key) {
509
571
  const home = this.options.homes.find(key);
510
572
  const status = this.known.find((known) => known.home.key === key)?.status;
511
- if (!home.global && status?.loggedIn === true && !paysPerToken(status))
573
+ if (!home.global && status?.loggedIn === true && !paysPerToken(status) && this.longToken(home.key) === undefined)
512
574
  await this.options.agentOf(home).logout(home);
513
575
  await this.options.homes.remove(home);
514
576
  this.options.forget(key);
@@ -541,18 +603,18 @@ export class AccountWatcher {
541
603
  const apiKey = home.global ? null : this.options.homes.apiKeyOf(home);
542
604
  const keyHeld = apiKey !== null;
543
605
  const openRouter = apiKey !== null && keyProvider(home.agent, apiKey) === 'openrouter';
544
- const cloud = this.options.homes.cloudOf(home);
545
606
  const remote = home.agent === CLAUDE ? this.options.homes.remoteOn(home) : null;
607
+ const facts = { home, keyHeld, openRouter, cloud: this.options.homes.cloudOf(home), longToken: this.options.homes.longTokenOf(home), remote };
546
608
  if (!(await this.options.online(home)))
547
- return { home, status: before?.status ?? null, error: before?.error ?? null, keyHeld, openRouter, cloud, remote };
609
+ return { ...facts, status: before?.status ?? null, error: before?.error ?? null };
548
610
  try {
549
- return { home, status: withIdentity(await this.options.agentOf(home).authStatus(home), home.key), error: null, keyHeld, openRouter, cloud, remote };
611
+ return { ...facts, status: withIdentity(await this.options.agentOf(home).authStatus(home), home.key), error: null };
550
612
  }
551
613
  catch (reason) {
552
614
  const error = noticeOf(reason);
553
615
  if (!sameNotice(error, before?.error ?? null))
554
616
  this.options.onError(reason);
555
- return { home, status: before?.status ?? null, error, keyHeld, openRouter, cloud, remote };
617
+ return { ...facts, status: before?.status ?? null, error };
556
618
  }
557
619
  }
558
620
  requireIdle() {
@@ -560,7 +622,13 @@ export class AccountWatcher {
560
622
  throw fail('login.running', {});
561
623
  }
562
624
  begin(home, adding, method) {
563
- const child = this.options.agentOf(home).login(home, method);
625
+ const onLocalLink = (localUrl) => {
626
+ if (this.running !== running || this.current === null)
627
+ return;
628
+ this.current = { ...this.current, localUrl };
629
+ this.options.onChange();
630
+ };
631
+ const child = this.options.agentOf(home).login(home, method, onLocalLink);
564
632
  const running = { child, home, adding };
565
633
  this.running = running;
566
634
  this.output = '';
@@ -36,7 +36,7 @@ export function copies(runtimes, save, fallBack, changed, check, consent) {
36
36
  };
37
37
  /** Missing, not failed: a failed download waits for the explicit retry. */
38
38
  const fetchesItself = (name) => {
39
- const view = runtimes.get(name)?.cli?.view();
39
+ const view = runtimes.get(name)?.cli?.state();
40
40
  return consented.has(name) && view?.source === 'checked' && view.status === 'missing';
41
41
  };
42
42
  const auto = (name) => {
@@ -46,7 +46,7 @@ export function copies(runtimes, save, fallBack, changed, check, consent) {
46
46
  return {
47
47
  view: () => Object.fromEntries([...runtimes].flatMap(([name, agent]) => agent.cli ? [[name, agent.cli.view()]] : [])),
48
48
  blocked(name) {
49
- const view = runtimes.get(name)?.cli?.view();
49
+ const view = runtimes.get(name)?.cli?.state();
50
50
  if (view?.source !== 'checked' || view.status === 'ready')
51
51
  return undefined;
52
52
  if (fetchesItself(name))
@@ -15,13 +15,16 @@ export function cliCopy(copy, options, version, system, overridden, approximate,
15
15
  return { received: whole, total: whole };
16
16
  }
17
17
  return {
18
- view() {
18
+ /** The view without `system`, which searches the disk: what a launch asks before each start. */
19
+ state() {
19
20
  return {
20
- version, source: options.checkedCli() && !overridden() ? 'checked' : 'system',
21
+ source: options.checkedCli() && !overridden() ? 'checked' : 'system',
21
22
  status: downloading || copy?.downloading || extra?.downloading ? 'downloading' : copy?.error || extra?.error ? 'failed' : copy?.path() !== undefined && (extra === undefined || extra.path() !== undefined) ? 'ready' : 'missing',
22
- system: system(), ...bytes(), approximate,
23
23
  };
24
24
  },
25
+ view() {
26
+ return { version, ...this.state(), system: system(), ...bytes(), approximate };
27
+ },
25
28
  async download() {
26
29
  if (!copy)
27
30
  throw new Error('No checked CLI for this platform');