even-keel 0.3.3 → 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 (494) hide show
  1. package/.env.example +10 -0
  2. package/CHANGELOG.md +22 -0
  3. package/README.md +5 -3
  4. package/dist/src/account/globals.js +3 -3
  5. package/dist/src/account/homes.js +41 -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 +78 -18
  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 +97 -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 +5 -4
  17. package/dist/src/badge/render.js +118 -35
  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 +2 -2
  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/codex/version.js +1 -1
  100. package/dist/src/config-form.js +36 -6
  101. package/dist/src/config-store.js +18 -4
  102. package/dist/src/config.js +15 -3
  103. package/dist/src/copilot/adapter.js +1 -1
  104. package/dist/src/copilot/cli.js +11 -5
  105. package/dist/src/diagnostics/missing-package.js +9 -0
  106. package/dist/src/diagnostics/stall-profile.js +99 -0
  107. package/dist/src/diagnostics/start-watch.js +45 -12
  108. package/dist/src/dictation/transcribe.js +124 -0
  109. package/dist/src/event-log/watch.js +28 -3
  110. package/dist/src/events.js +52 -10
  111. package/dist/src/fetch-dispatcher.js +11 -0
  112. package/dist/src/forgejo/api.js +11 -2
  113. package/dist/src/forgejo/editor.js +1 -1
  114. package/dist/src/git/diff.js +52 -0
  115. package/dist/src/git/dirs.js +19 -0
  116. package/dist/src/git/patterns.js +91 -0
  117. package/dist/src/git/push.js +63 -0
  118. package/dist/src/git/remote-head.js +69 -0
  119. package/dist/src/git/remote-urls.js +47 -0
  120. package/dist/src/git/slot-clean.js +144 -0
  121. package/dist/src/git/slot.js +12 -4
  122. package/dist/src/git/sync.js +49 -12
  123. package/dist/src/git/work.js +32 -8
  124. package/dist/src/git/worktree.js +12 -3
  125. package/dist/src/github/adapter.js +1 -0
  126. package/dist/src/github/editor.js +2 -0
  127. package/dist/src/github/import.js +311 -0
  128. package/dist/src/github/profile.js +1 -1
  129. package/dist/src/github/source.js +121 -28
  130. package/dist/src/github/uploads.js +8 -0
  131. package/dist/src/gitlab/api.js +4 -0
  132. package/dist/src/gitlab/editor.js +1 -1
  133. package/dist/src/gitlab/profile.js +1 -1
  134. package/dist/src/huly/adapter.js +2 -1
  135. package/dist/src/huly/colors.js +41 -0
  136. package/dist/src/huly/import-text.js +31 -0
  137. package/dist/src/huly/import.js +317 -0
  138. package/dist/src/huly/model.js +10 -3
  139. package/dist/src/huly/profile.js +1 -1
  140. package/dist/src/huly/source.js +46 -10
  141. package/dist/src/huly/transient.js +32 -0
  142. package/dist/src/intake/intake.js +42 -17
  143. package/dist/src/intake/model.js +2 -0
  144. package/dist/src/jira/api.js +4 -0
  145. package/dist/src/jira/editor.js +1 -1
  146. package/dist/src/jira/model.js +7 -2
  147. package/dist/src/jira/profile.js +1 -1
  148. package/dist/src/jobs/model.js +7 -1
  149. package/dist/src/jobs/runner.js +25 -7
  150. package/dist/src/limits/chatgpt-seat.js +31 -3
  151. package/dist/src/limits/chatgpt.js +16 -4
  152. package/dist/src/limits/identity.js +51 -0
  153. package/dist/src/limits/model.js +17 -3
  154. package/dist/src/limits/polls.js +200 -0
  155. package/dist/src/limits/token-windows.js +30 -0
  156. package/dist/src/limits/watcher.js +93 -9
  157. package/dist/src/linear/adapter.js +1 -0
  158. package/dist/src/linear/answer.js +27 -0
  159. package/dist/src/linear/import.js +282 -0
  160. package/dist/src/linear/profile.js +3 -2
  161. package/dist/src/linear/source.js +62 -8
  162. package/dist/src/link/address.js +28 -0
  163. package/dist/src/link/cert.js +41 -0
  164. package/dist/src/link/colors.js +20 -0
  165. package/dist/src/link/hooks.js +30 -0
  166. package/dist/src/link/hub-server.js +164 -0
  167. package/dist/src/link/hub-store.js +84 -0
  168. package/dist/src/link/hub.js +249 -0
  169. package/dist/src/link/identity.js +20 -0
  170. package/dist/src/link/local.js +75 -0
  171. package/dist/src/link/machine-store.js +177 -0
  172. package/dist/src/link/machine-transport.js +184 -0
  173. package/dist/src/link/machine.js +402 -0
  174. package/dist/src/link/protocol.js +77 -0
  175. package/dist/src/link/view.js +2 -0
  176. package/dist/src/locations.js +3 -0
  177. package/dist/src/machine/about.js +53 -0
  178. package/dist/src/machine/account-here.js +26 -0
  179. package/dist/src/machine/assignments.js +99 -0
  180. package/dist/src/machine/brief.js +99 -0
  181. package/dist/src/machine/chain-machines.js +37 -0
  182. package/dist/src/machine/config.js +48 -0
  183. package/dist/src/machine/facts.js +118 -0
  184. package/dist/src/machine/folder-check.js +103 -0
  185. package/dist/src/{chain → machine}/handover.js +70 -82
  186. package/dist/src/machine/hook-receiver.js +124 -0
  187. package/dist/src/machine/host.js +1 -0
  188. package/dist/src/machine/join-cli.js +59 -0
  189. package/dist/src/machine/join.js +96 -0
  190. package/dist/src/machine/main.js +71 -0
  191. package/dist/src/machine/marks.js +81 -0
  192. package/dist/src/machine/move-call.js +42 -0
  193. package/dist/src/machine/moves.js +210 -0
  194. package/dist/src/{chain → machine}/overage.js +9 -11
  195. package/dist/src/machine/own.js +33 -0
  196. package/dist/src/machine/page.js +74 -0
  197. package/dist/src/machine/pool.js +100 -0
  198. package/dist/src/machine/port.js +1 -0
  199. package/dist/src/machine/reassign.js +30 -0
  200. package/dist/src/machine/records.js +73 -0
  201. package/dist/src/machine/remote.js +300 -0
  202. package/dist/src/machine/runner.js +268 -0
  203. package/dist/src/machine/services.js +52 -0
  204. package/dist/src/machine/state.js +54 -0
  205. package/dist/src/machine/tally.js +65 -0
  206. package/dist/src/machine/task-moves.js +46 -0
  207. package/dist/src/machine/tasks.js +165 -0
  208. package/dist/src/machine-service.js +141 -0
  209. package/dist/src/main.js +12 -104
  210. package/dist/src/memory/mcp.js +206 -0
  211. package/dist/src/memory/mirror.js +142 -0
  212. package/dist/src/memory/record.js +69 -0
  213. package/dist/src/memory/store.js +81 -0
  214. package/dist/src/notice/en-advice.js +7 -0
  215. package/dist/src/notice/en-review.js +3 -0
  216. package/dist/src/notice/en-transfer.js +30 -0
  217. package/dist/src/notice/en-values.js +2 -0
  218. package/dist/src/notice/en.js +120 -11
  219. package/dist/src/npm-access.js +18 -2
  220. package/dist/src/opencode/adapter.js +3 -1
  221. package/dist/src/opencode/cli.js +11 -10
  222. package/dist/src/opencode/home.js +24 -4
  223. package/dist/src/opencode/tail.js +7 -1
  224. package/dist/src/opencode/transcript.js +21 -7
  225. package/dist/src/opencode/window.js +21 -5
  226. package/dist/src/packages/check.js +17 -8
  227. package/dist/src/packages/follow.js +54 -0
  228. package/dist/src/packages/gateway.js +86 -4
  229. package/dist/src/packages/hub.js +64 -0
  230. package/dist/src/packages/installs.js +226 -0
  231. package/dist/src/packages/launch.js +61 -13
  232. package/dist/src/packages/repo-reads.js +41 -0
  233. package/dist/src/packages/service.js +169 -243
  234. package/dist/src/packages/skills-package.js +39 -0
  235. package/dist/src/packages/stdio.js +24 -0
  236. package/dist/src/packages/version.js +2 -1
  237. package/dist/src/pass-memo.js +27 -0
  238. package/dist/src/patch.js +2 -1
  239. package/dist/src/profiles/rules.js +2 -2
  240. package/dist/src/projects/check.js +3 -2
  241. package/dist/src/projects/remotes.js +2 -1
  242. package/dist/src/projects/target-read.js +2 -1
  243. package/dist/src/review/open.js +27 -4
  244. package/dist/src/review/outsider.js +39 -0
  245. package/dist/src/review/wiring.js +2 -1
  246. package/dist/src/secrets/catalog.js +2 -0
  247. package/dist/src/server-request.js +51 -6
  248. package/dist/src/server-response.js +10 -2
  249. package/dist/src/server.js +102 -3
  250. package/dist/src/service/account-packages.js +24 -41
  251. package/dist/src/service/accounts.js +88 -135
  252. package/dist/src/service/badge.js +39 -6
  253. package/dist/src/service/chain-prompts.js +50 -5
  254. package/dist/src/service/chain.js +33 -378
  255. package/dist/src/service/chats.js +41 -0
  256. package/dist/src/service/cleanup.js +22 -7
  257. package/dist/src/service/cli-check.js +4 -4
  258. package/dist/src/service/defaults.js +32 -0
  259. package/dist/src/service/demo.js +3 -2
  260. package/dist/src/service/folders-here.js +21 -0
  261. package/dist/src/service/hosting-state.js +204 -0
  262. package/dist/src/service/hosting.js +153 -209
  263. package/dist/src/service/hub-bootstrap.js +204 -0
  264. package/dist/src/service/hub-brief.js +72 -0
  265. package/dist/src/service/hub-hooks.js +44 -0
  266. package/dist/src/service/hub-mcp.js +140 -0
  267. package/dist/src/service/install-check.js +19 -5
  268. package/dist/src/service/lifecycle.js +4 -2
  269. package/dist/src/service/machine-bootstrap.js +105 -0
  270. package/dist/src/service/machine-cards.js +62 -0
  271. package/dist/src/service/machine-chain.js +499 -0
  272. package/dist/src/service/machine-chats.js +91 -0
  273. package/dist/src/service/machine-context.js +103 -0
  274. package/dist/src/service/machine-host.js +226 -0
  275. package/dist/src/service/machine-link.js +476 -0
  276. package/dist/src/service/machine-network-options.js +12 -0
  277. package/dist/src/service/machine-network.js +741 -0
  278. package/dist/src/service/machine-packages.js +38 -0
  279. package/dist/src/service/machine-page.js +88 -0
  280. package/dist/src/service/machine-pool.js +177 -0
  281. package/dist/src/service/machine-process.js +84 -0
  282. package/dist/src/service/machine-services.js +117 -0
  283. package/dist/src/service/machine-settings.js +84 -0
  284. package/dist/src/service/machine-side.js +220 -0
  285. package/dist/src/service/page-history.js +31 -0
  286. package/dist/src/service/pool-after-green.js +92 -0
  287. package/dist/src/service/reassign.js +79 -0
  288. package/dist/src/service/session-monitor.js +119 -0
  289. package/dist/src/service/stats.js +3 -1
  290. package/dist/src/service/ticks.js +37 -0
  291. package/dist/src/service/trackers.js +1 -0
  292. package/dist/src/service.js +183 -440
  293. package/dist/src/sessions/agents.js +8 -4
  294. package/dist/src/sessions/cache.js +19 -0
  295. package/dist/src/sessions/chat.js +60 -13
  296. package/dist/src/sessions/inbox.js +10 -0
  297. package/dist/src/sessions/inboxes.js +112 -0
  298. package/dist/src/sessions/keepwarm.js +14 -0
  299. package/dist/src/sessions/lingering.js +4 -0
  300. package/dist/src/sessions/mail.js +3 -1
  301. package/dist/src/sessions/mailRelay.js +38 -2
  302. package/dist/src/sessions/mailbox-store.js +25 -0
  303. package/dist/src/sessions/mailbox.js +55 -26
  304. package/dist/src/sessions/monitor.js +17 -1
  305. package/dist/src/sessions/note.js +15 -4
  306. package/dist/src/sessions/orphans.js +131 -0
  307. package/dist/src/sessions/remote.js +5 -1
  308. package/dist/src/sessions/runs.js +39 -21
  309. package/dist/src/sessions/title.js +11 -6
  310. package/dist/src/sessions/transcript.js +41 -16
  311. package/dist/src/sessions/turn-ends.js +23 -0
  312. package/dist/src/sessions/view-index.js +38 -0
  313. package/dist/src/sessions/warm-pings.js +30 -0
  314. package/dist/src/settings/defaults.js +6 -1
  315. package/dist/src/settings/registry.js +49 -13
  316. package/dist/src/start.js +110 -0
  317. package/dist/src/stats/base-sql.js +8 -0
  318. package/dist/src/stats/machine-tally.js +46 -0
  319. package/dist/src/stats/model.js +3 -2
  320. package/dist/src/stats/reader.js +69 -16
  321. package/dist/src/stats/tally-schema.js +1 -1
  322. package/dist/src/stats/tally.js +13 -0
  323. package/dist/src/storage/backup-schedule.js +9 -2
  324. package/dist/src/storage/copy.js +9 -3
  325. package/dist/src/storage/database-steps.js +942 -0
  326. package/dist/src/storage/database.js +2 -630
  327. package/dist/src/storage/json-folder.js +44 -9
  328. package/dist/src/storage/migrations.js +6 -1
  329. package/dist/src/storage/owner.js +1 -1
  330. package/dist/src/storage/schema.js +1 -1
  331. package/dist/src/taskmcp/calls.js +26 -12
  332. package/dist/src/taskmcp/carried.js +69 -0
  333. package/dist/src/taskmcp/downloads.js +68 -32
  334. package/dist/src/taskmcp/files.js +4 -0
  335. package/dist/src/taskmcp/handoff.js +21 -0
  336. package/dist/src/taskmcp/history.js +48 -0
  337. package/dist/src/taskmcp/machine.js +205 -0
  338. package/dist/src/taskmcp/server.js +7 -2
  339. package/dist/src/taskmcp/tools.js +24 -4
  340. package/dist/src/tools/panel.js +5 -3
  341. package/dist/src/tools/sessionSettings.js +4 -1
  342. package/dist/src/tracker/author.js +13 -0
  343. package/dist/src/tracker/brief.js +24 -0
  344. package/dist/src/tracker/comments.js +19 -2
  345. package/dist/src/tracker/control.js +6 -1
  346. package/dist/src/tracker/editor.js +3 -2
  347. package/dist/src/tracker/error-text.js +21 -0
  348. package/dist/src/tracker/export-target.js +2 -1
  349. package/dist/src/tracker/export.js +116 -53
  350. package/dist/src/tracker/file-names.js +34 -0
  351. package/dist/src/tracker/history-export.js +14 -0
  352. package/dist/src/tracker/history.js +55 -0
  353. package/dist/src/tracker/import-plan.js +155 -0
  354. package/dist/src/tracker/import-retry.js +107 -0
  355. package/dist/src/tracker/import-source.js +33 -0
  356. package/dist/src/tracker/import.js +34 -0
  357. package/dist/src/tracker/link.js +4 -8
  358. package/dist/src/tracker/model.js +13 -0
  359. package/dist/src/tracker/pace.js +74 -0
  360. package/dist/src/tracker/parents.js +2 -1
  361. package/dist/src/tracker/rate-limit.js +63 -0
  362. package/dist/src/tracker/source.js +16 -6
  363. package/dist/src/tracker/start.js +72 -9
  364. package/dist/src/tracker/transfer-check.js +278 -0
  365. package/dist/src/tracker/transfer-stop.js +49 -0
  366. package/dist/src/updates/checkout.js +8 -0
  367. package/dist/src/updates/follow.js +108 -0
  368. package/dist/src/updates/model.js +23 -11
  369. package/dist/src/updates/rebuild.js +27 -0
  370. package/dist/src/updates/run.js +32 -16
  371. package/dist/src/updates/runner.js +193 -12
  372. package/dist/src/updates/steps.js +9 -6
  373. package/dist/src/updates/updater.js +18 -12
  374. package/dist/tally/src/activity-result.js +24 -0
  375. package/dist/tally/src/activity.js +52 -0
  376. package/dist/tally/src/chat-sessions.js +14 -0
  377. package/dist/tally/src/classify.js +2 -2
  378. package/dist/tally/src/collect.js +12 -4
  379. package/dist/tally/src/db-activity.js +28 -0
  380. package/dist/tally/src/db-backfills.js +38 -0
  381. package/dist/tally/src/db.js +104 -101
  382. package/dist/tally/src/machine-rows.js +23 -0
  383. package/dist/tally/src/migrations/17-machines.sql +7 -0
  384. package/dist/tally/src/migrations/18-chat-sessions.sql +70 -0
  385. package/dist/tally/src/migrations/19-limit-shares-one-pass.sql +32 -0
  386. package/dist/tally/src/migrations/20-warm-pings.sql +114 -0
  387. package/dist/tally/src/migrations/21-session-activity.sql +80 -0
  388. package/dist/tally/src/migrations/22-line-raws.sql +57 -0
  389. package/dist/tally/src/migrations.js +1 -1
  390. package/dist/tally/src/ship.js +82 -0
  391. package/dist/tally/src/step-runs.js +5 -20
  392. package/dist/tally/src/stream.js +4 -6
  393. package/dist/tally/src/turns.js +2 -2
  394. package/dist/tally/src/warm-pings.js +15 -0
  395. package/dist/web/assets/BadgeDialog-B_puf4gn.js +1 -0
  396. package/dist/web/assets/ButtonWithTip-CKUX2Zj9.css +1 -0
  397. package/dist/web/assets/ButtonWithTip-Dv_lTY2w.js +1 -0
  398. package/dist/web/assets/ChainDivider-BWHmlwAN.css +1 -0
  399. package/dist/web/assets/ChainDivider-CAgORlAt.js +2 -0
  400. package/dist/web/assets/{DescriptionEditor-CPfdoDlm.js → DescriptionEditor-BP9G4eW1.js} +5 -5
  401. package/dist/web/assets/FixButtons-VKGqxhsJ.js +7 -0
  402. package/dist/web/assets/FixButtons-xuzSmDiG.css +1 -0
  403. package/dist/web/assets/Loader-CRa8gNSO.css +1 -0
  404. package/dist/web/assets/Loader-gLtpd-HU.js +1 -0
  405. package/dist/web/assets/NewChatDialog-BNeZwqhQ.css +1 -0
  406. package/dist/web/assets/NewChatDialog-BPhSEUlM.js +1 -0
  407. package/dist/web/assets/OutsideView-CjqU_1_v.js +1 -0
  408. package/dist/web/assets/OutsideView-Hfkm7sQH.css +1 -0
  409. package/dist/web/assets/ProjectChatWindow-DFHqXtJT.js +1 -0
  410. package/dist/web/assets/ProjectPackages-C3WBhYWn.js +1 -0
  411. package/dist/web/assets/Select-ClnxKCav.js +1 -0
  412. package/dist/web/assets/Select-L3DXe4x4.css +1 -0
  413. package/dist/web/assets/TaskCard-DQJ_pizZ.js +2 -0
  414. package/dist/web/assets/TaskCard-MSKfeQSB.css +1 -0
  415. package/dist/web/assets/TranscriptWindow-B_0lkEov.css +1 -0
  416. package/dist/web/assets/TranscriptWindow-D-EQPrlF.js +6 -0
  417. package/dist/web/assets/TranscriptWindow-DTy64neg.js +1 -0
  418. package/dist/web/assets/accountParts-CIVGro5M.css +1 -0
  419. package/dist/web/assets/accountParts-CxNOHLQV.js +3 -0
  420. package/dist/web/assets/blocks-C3-5RdLi.css +1 -0
  421. package/dist/web/assets/blocks-DEe611CF.js +14 -0
  422. package/dist/web/assets/cardDrafts-BIJBcK7y.css +1 -0
  423. package/dist/web/assets/cardDrafts-Cu4oR7jf.js +12 -0
  424. package/dist/web/assets/cardSide-EOcop8Wv.css +1 -0
  425. package/dist/web/assets/cardSide-rO6Ughfv.js +2 -0
  426. package/dist/web/assets/{feedLine-CBjZXWwX.css → feedPin-BXDM-u8h.css} +1 -1
  427. package/dist/web/assets/feedPin-CHY_Owsx.js +3 -0
  428. package/dist/web/assets/format-DecSum6S.js +1 -0
  429. package/dist/web/assets/index-BgmurD3-.js +36 -0
  430. package/dist/web/assets/index-KJhwihX1.css +1 -0
  431. package/dist/web/assets/lib-D5hQoyXI.js +18 -0
  432. package/dist/web/assets/overview-BGjnxKG3.css +1 -0
  433. package/dist/web/assets/packageGroups-B-lwU2vO.js +1 -0
  434. package/dist/web/assets/packages-Cr9yWzy2.css +1 -0
  435. package/dist/web/assets/{react-dom-ntoTaxXv.js → react-dom-CzZfPJAD.js} +1 -1
  436. package/dist/web/assets/settingsRun-Cl3nW7b_.css +1 -0
  437. package/dist/web/assets/settingsRun-D-Dqm7pY.js +3 -0
  438. package/dist/web/assets/useFileDrop-ChaeIqmQ.js +1 -0
  439. package/dist/web/assets/useRowFocus-9aJnL77Z.js +1 -0
  440. package/dist/web/index.html +32 -24
  441. package/even-keel.config.example.json +1 -2
  442. package/package.json +11 -5
  443. package/plugins/agent-bridge/.claude-plugin/plugin.json +2 -2
  444. package/plugins/agent-bridge/.mcp.json +8 -0
  445. package/plugins/agent-bridge/README.md +4 -0
  446. package/plugins/agent-bridge/hooks/checkpoint-mark.mjs +4 -3
  447. package/plugins/agent-bridge/hooks/evenkeel.mjs +40 -3
  448. package/plugins/agent-bridge/hooks/handoff.mjs +12 -2
  449. package/plugins/agent-bridge/hooks/hooks.json +9 -0
  450. package/plugins/agent-bridge/hooks/inbox.mjs +26 -0
  451. package/plugins/agent-bridge/hooks/mailpost.mjs +52 -0
  452. package/plugins/agent-bridge/hooks/merge-check.mjs +2 -1
  453. package/plugins/agent-bridge/hooks/merges.mjs +24 -1
  454. package/plugins/agent-bridge/hooks/nudges.mjs +16 -7
  455. package/plugins/agent-bridge/opencode/agent-bridge.mjs +17 -14
  456. package/plugins/tally/.claude-plugin/plugin.json +1 -1
  457. package/plugins/tally/skills/session-audit/SKILL.md +4 -4
  458. package/plugins/tasks/.claude-plugin/plugin.json +1 -1
  459. package/plugins/tasks/skills/split/SKILL.md +4 -1
  460. package/plugins/tasks/skills/task/SKILL.md +1 -0
  461. package/service/EvenKeelTray.cs +52 -4
  462. package/service/install.ps1 +25 -3
  463. package/service/install.sh +61 -4
  464. package/dist/web/assets/BadgeDialog-B3VcoEuQ.js +0 -1
  465. package/dist/web/assets/ProjectPackages-BO4rIO5w.js +0 -1
  466. package/dist/web/assets/Select-BYWAe5Fn.js +0 -1
  467. package/dist/web/assets/Select-CYemy5Na.css +0 -1
  468. package/dist/web/assets/TaskCard-BV2lQojC.css +0 -1
  469. package/dist/web/assets/TaskCard-DvrNOwWg.js +0 -2
  470. package/dist/web/assets/TranscriptWindow-BNF7AkTM.css +0 -1
  471. package/dist/web/assets/TranscriptWindow-BiO9Wnwu.js +0 -4
  472. package/dist/web/assets/accountParts-DSHr6oHI.js +0 -3
  473. package/dist/web/assets/accountParts-tFRVownp.css +0 -1
  474. package/dist/web/assets/blocks-C9HVGHBz.js +0 -12
  475. package/dist/web/assets/blocks-Dx3DACiG.css +0 -1
  476. package/dist/web/assets/cardDrafts-2oX1SbA7.css +0 -1
  477. package/dist/web/assets/cardDrafts-4S62wAyr.js +0 -12
  478. package/dist/web/assets/cardSide-63fNWHHv.css +0 -1
  479. package/dist/web/assets/cardSide-B4pcPyyP.js +0 -2
  480. package/dist/web/assets/feedLine-Bw0m9J2B.js +0 -1
  481. package/dist/web/assets/hooks-DkC_CVfs.js +0 -1
  482. package/dist/web/assets/index-9wCKwZBT.js +0 -25
  483. package/dist/web/assets/index-CZNlGIGI.css +0 -1
  484. package/dist/web/assets/lib-DqcU8Atw.js +0 -18
  485. package/dist/web/assets/overview-B7iEgjQD.css +0 -1
  486. package/dist/web/assets/overview-CAfIOCOy.js +0 -7
  487. package/dist/web/assets/packageGroups-BQRZ8Kq6.js +0 -1
  488. package/dist/web/assets/packages-Dld4uH9X.css +0 -1
  489. package/dist/web/assets/rules-D-jNBQYg.js +0 -1
  490. package/dist/web/assets/useFileDrop-B3fsWqOP.js +0 -1
  491. package/dist/web/assets/useHeightGlide-75qzC7AC.js +0 -3
  492. package/dist/web/assets/useHeightGlide-B2o4yzDR.css +0 -1
  493. package/dist/web/assets/useRowFocus-DnfnHKTV.js +0 -1
  494. /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
@@ -4,6 +4,24 @@ All notable changes to Even Keel are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.3.4] - 2026-11-20
8
+
9
+ A patch of 0.3: Remote Control for a Claude account added from the page, and fewer "changed directly" plates on the Accounts page.
10
+
11
+ ### Changed
12
+
13
+ - **A claude.ai account you add from the page has Remote Control on.** Its chain sessions show on claude.ai/code and in the Claude app from the first one. Before, the sign-in left Remote Control off, and the page sent you to `/config` without a way to turn it on.
14
+ - **"Turn on Remote Control"** in the account row's menu and in the session panel, where an account has Remote Control off. It applies from the account's next session.
15
+ - Chain sessions run on Claude Code 2.1.330, codex-cli 0.171.0 and Copilot CLI 1.0.114, the versions this release was checked against; OpenCode 1.19.6 stays.
16
+ - A ChatGPT workspace seat with a monthly credit limit reads that limit and its reset straight from the usage answer when the answer carries them, with no second request; before, the reset was assumed to be the start of the next month.
17
+
18
+ ### Fixed
19
+
20
+ - **The "changed directly" plates on the Accounts page show only edits that need your decision.** Keys the CLI writes into an account's `settings.json` itself, such as its notification settings, no longer get a plate.
21
+ - **"Make shared" and "Turn on Remote Control" work on a key the account holds as its own**, also when a plate about a direct edit of that key is still open: the edit is settled. Before, both buttons did nothing until the plate was answered.
22
+ - The README badge's "+N" counts the whole queue, not only the queued tasks the badge has room to draw.
23
+ - In **Move to another tracker**, the project key of a Linear project sits in the same grid as the team and the project, without a blank gap above it; switching the profile to another tracker kind clears the project of the previous one.
24
+
7
25
  ## [0.3.3] - 2026-11-18
8
26
 
9
27
  A patch of 0.3: keep-warm through a long tool call, and a cache clock that knows about keep-warm.
@@ -104,6 +122,10 @@ A patch of 0.3: the CI and limit fixes that cost a chain time, and a clearer car
104
122
  - The ⋯ menu of an account row offers **Replace key** for a working key too.
105
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.
106
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
+
107
129
  ### Changed
108
130
 
109
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
 
@@ -71,7 +71,7 @@ Parallel agents decide on their own what an unfinished task will look like, hand
71
71
 
72
72
  ## Before you run it
73
73
 
74
- - **Even Keel depends on undocumented behaviour of the agents' CLIs**, none of it a public API. Last checked against **Claude Code 2.1.326**, **codex-cli 0.169.0**, **OpenCode 1.19.6** and **Copilot CLI 1.0.113**; the page warns when yours is another version and can run sessions on the checked one instead. A CLI update may break a part of Even Keel until it is adapted — please open an issue when it does. Details: [setup](docs/guide/setup.md#the-clis-it-depends-on).
74
+ - **Even Keel depends on undocumented behaviour of the agents' CLIs**, none of it a public API. Last checked against **Claude Code 2.1.330**, **codex-cli 0.171.0**, **OpenCode 1.19.6** and **Copilot CLI 1.0.114**; the page warns when yours is another version and can run sessions on the checked one instead. A CLI update may break a part of Even Keel until it is adapted — please open an issue when it does. Details: [setup](docs/guide/setup.md#the-clis-it-depends-on).
75
75
  - **Your subscription, the providers' terms.** A project runs on one account per provider, and a spent limit is waited out, never got round by switching accounts. Even Keel does not share, pool or resell access. Each agent's sessions fall under its provider's terms, listed below.
76
76
  - **Sessions don't ask you before each tool call** (Claude in auto mode, Codex with `--approve-for-me` or, if you choose, with no sandbox). Protection refuses destructive commands; set up any other permissions and hooks in your agents' settings before you start a chain. Whoever writes a task's text steers its session: read [whose text a session reads and what it may do](docs/guide/security.md) before a chain runs on a public repository.
77
77
  - **Your sign-in stays with the CLIs.** Even Keel reads only expiry dates, the e-mail and the plan; tokens are never copied or sent anywhere. An API key you add goes only to its own provider.
@@ -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);
@@ -9,10 +9,12 @@ import { fail } from '../notice/notice.js';
9
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 { REMOTE_AT_STARTUP } from '../sessions/remote.js';
12
13
  import { shortLivedProfile } from './aws.js';
13
14
  import { userCredentials } from './gcloud.js';
14
15
  import { cloudEnv, cloudOf } from './cloud.js';
15
16
  import { KeychainCredentials, keychainService } from './keychain.js';
17
+ import { readLongToken, writeLongToken } from './longToken.js';
16
18
  import { CODEX_ACCOUNT, folderName, GLOBAL_ACCOUNT, parseCredentialTimes } from './model.js';
17
19
  import { API_KEY_VARIABLE, shareConfig } from './share.js';
18
20
  const PENDING_PREFIX = '.pending-';
@@ -205,6 +207,21 @@ export class AccountHomes {
205
207
  writeFileSync(join(home.dir, 'settings.json'), JSON.stringify({ env: cloudEnv(connection) }, null, 2));
206
208
  return home;
207
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
+ }
208
225
  /** The cloud a Claude folder's `settings.json` connects to; null for any other folder. */
209
226
  cloudOf(home) {
210
227
  if (home.agent !== CLAUDE)
@@ -282,6 +299,30 @@ export class AccountHomes {
282
299
  return false;
283
300
  return shareConfig({ dir: this.global.dir, config: this.configFile(this.global) }, home.dir, console.warn, this.settings?.planner(home.key));
284
301
  }
302
+ /** Whether the Claude folder's `settings.json` starts Remote Control with its sessions. */
303
+ remoteOn(home) {
304
+ return readObject(join(home.dir, 'settings.json'))[REMOTE_AT_STARTUP] === true;
305
+ }
306
+ /**
307
+ * Remote Control from the folder's next session (EKR-148): an account folder gets it in its own layer, which the
308
+ * global settings never override, and at once by a transfer; the global folder, its own file, merged.
309
+ */
310
+ enableRemote(home) {
311
+ if (home.agent !== CLAUDE)
312
+ throw fail('account.unknown', { key: home.key });
313
+ if (!home.global && this.settings !== null) {
314
+ this.settings.setOwn(home, REMOTE_AT_STARTUP, true);
315
+ this.share(home);
316
+ return;
317
+ }
318
+ const file = join(home.dir, 'settings.json');
319
+ const settings = readObject(file);
320
+ if (Object.keys(settings).length === 0 && existsSync(file) && !/^\s*(\{\s*\})?\s*$/.test(readFileSync(file, 'utf8'))) {
321
+ throw new Error(`claude: ${file} is no JSON object, Remote Control left off rather than overwrite it`);
322
+ }
323
+ mkdirSync(home.dir, { recursive: true });
324
+ writeFileSync(file, JSON.stringify({ ...settings, [REMOTE_AT_STARTUP]: true }, null, 2));
325
+ }
285
326
  /** The `.claude.json` the CLI reads with this folder. */
286
327
  configFile(home) {
287
328
  if (!home.global)
@@ -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);
@@ -86,37 +116,48 @@ export class AccountSettings {
86
116
  return plan.file;
87
117
  };
88
118
  }
89
- /** The keys changed in the folder since the last transfer; none before the first one. */
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 [];
94
128
  const file = join(home.dir, 'settings.json');
95
- let stamp;
96
- try {
97
- const stat = statSync(file);
98
- stamp = `${this.version}:${stat.mtimeMs}:${stat.size}`;
99
- }
100
- catch {
129
+ const folderStamp = fileStamp(file);
130
+ if (folderStamp === undefined)
101
131
  return [];
102
- }
132
+ const globalFile = join(this.globalDir, 'settings.json');
133
+ const stamp = `${this.version}:${folderStamp}:${fileStamp(globalFile)}`;
103
134
  const cached = this.seen.get(home.key);
104
135
  if (cached?.stamp === stamp)
105
- return cached.edits;
106
- const folder = readJson(file);
107
- const discard = this.discards.get(home.key);
108
- const edits = folder === undefined ? [] : editedKeys(folder, record.written).filter((key) => discard?.has(key) !== true);
109
- this.seen.set(home.key, { stamp, edits });
110
- 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;
111
143
  }
112
144
  /** The keys of the account's own layer. */
113
145
  own(account) {
114
146
  return Object.keys(this.records.get(account)?.own ?? {}).sort();
115
147
  }
116
- /** Takes effect at the next transfer into the folder, which the caller starts. */
117
- 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) {
118
159
  const record = this.records.get(home.key);
119
- if (record === undefined || !this.edits(home).includes(key))
160
+ if (record === undefined)
120
161
  throw fail('account.settingsNoEdit', { account: home.key, key });
121
162
  const value = stripSettingsGuard(readJson(join(home.dir, 'settings.json')) ?? {})[key];
122
163
  if (choice === 'discard') {
@@ -132,7 +173,17 @@ export class AccountSettings {
132
173
  const global = readJson(file) ?? {};
133
174
  setOrDelete(global, key, key === 'env' && value !== undefined ? { ...sharedEnv(value), ...ownVariables(global.env) } : value);
134
175
  writeFileSync(file, JSON.stringify(global, null, 2));
135
- this.version++;
176
+ if (Object.hasOwn(record.own, key))
177
+ this.dropOwn(home, key);
178
+ }
179
+ /** A key Even Keel itself gives the account (EKR-148); takes effect at the next transfer, which the caller starts. */
180
+ setOwn(home, key, value) {
181
+ const folder = stripSettingsGuard(readJson(join(home.dir, 'settings.json')) ?? {});
182
+ const record = this.records.get(home.key);
183
+ // A new folder starts at its current file. In a known folder only this key's edit is acknowledged.
184
+ const written = { ...(record?.written ?? folder) };
185
+ setOrDelete(written, key, folder[key]);
186
+ this.keep(home.key, { written, own: { ...record?.own, [key]: value } });
136
187
  }
137
188
  /** Takes effect at the next transfer into the folder, which the caller starts. */
138
189
  dropOwn(home, key) {
@@ -176,6 +227,15 @@ function setOrDelete(target, key, value) {
176
227
  else
177
228
  target[key] = value;
178
229
  }
230
+ function fileStamp(file) {
231
+ try {
232
+ const stat = statSync(file);
233
+ return `${stat.mtimeMs}:${stat.size}`;
234
+ }
235
+ catch {
236
+ return undefined;
237
+ }
238
+ }
179
239
  function readJson(file) {
180
240
  try {
181
241
  const value = JSON.parse(readFileSync(file, 'utf8'));
@@ -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 {};