@openchamber/web 2.3.0 → 2.3.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 (250) hide show
  1. package/dist/assets/AboutDialog-C1ulAXh5.js +1 -0
  2. package/dist/assets/ArchiveView-DJo1Bpw_.js +1 -0
  3. package/dist/assets/{CommandPalette-1VlA7PbL.js → CommandPalette-B6r6DPF9.js} +2 -2
  4. package/dist/assets/{DiffView-SHdJJ6tl.js → DiffView-mJuVm7Z4.js} +2 -2
  5. package/dist/assets/{FilePreviewCommentMenu-DlVgwRsr.js → FilePreviewCommentMenu-Ca4ziuof.js} +1 -1
  6. package/dist/assets/{FilesView-BeMtsSlV.js → FilesView-BBFbfDp9.js} +3 -3
  7. package/dist/assets/{GitView-npRGKKx8.js → GitView-WL1wkRFF.js} +3 -3
  8. package/dist/assets/GuestSurfacePane-peVDY5gW.js +1 -0
  9. package/dist/assets/HelpDialog-Dxc2yneu.js +1 -0
  10. package/dist/assets/{InProgressOperationBanner-B6iO22_7.js → InProgressOperationBanner-Dy0RiPsD.js} +1 -1
  11. package/dist/assets/JsonTreeView-BKUmh7Iw.js +1 -0
  12. package/dist/assets/MarkdownImageGallery-Cd6hLNmi.js +1 -0
  13. package/dist/assets/MarkdownRendererImpl-C-3B3mBt.js +1 -0
  14. package/dist/assets/MemoryDebugPanel-b116r1SF.js +1 -0
  15. package/dist/assets/OnboardingScreen-vBEhpU3q.js +1 -0
  16. package/dist/assets/OpenCodeStatusDialog-DH7dJ6MH.js +1 -0
  17. package/dist/assets/{PatchDiff-Du2s7T3U.js → PatchDiff-yM7vgQgi.js} +1 -1
  18. package/dist/assets/{PierreDiffViewer-B9K0gBvV.js → PierreDiffViewer-DnHKbYGl.js} +1 -1
  19. package/dist/assets/{PlanView-IkTcPrbw.js → PlanView-j0hLJmto.js} +2 -2
  20. package/dist/assets/RunOverview-ZuFZvDcu.js +2 -0
  21. package/dist/assets/ScheduledTasksDialog-UKXFFI91.js +5 -0
  22. package/dist/assets/{SettingsView-DIy5ZL4-.js → SettingsView-gB_NvyX4.js} +8 -8
  23. package/dist/assets/SettingsWindow-Dfb_RFpD.js +1 -0
  24. package/dist/assets/SourceBoardView-BjaL0nKs.js +1 -0
  25. package/dist/assets/SpaceAccessDialog-XzHRmIdT.js +1 -0
  26. package/dist/assets/SpaceApplyDialog-CxX9mrzT.js +1 -0
  27. package/dist/assets/{SpaceRow-YPmKQKeD.js → SpaceRow-vCpOCANO.js} +1 -1
  28. package/dist/assets/SpaceSetupOutput-CDZvJCf_.js +1 -0
  29. package/dist/assets/SpacesView-D3a9bCzn.js +1 -0
  30. package/dist/assets/{SubmoduleDiffSummary-RDY5md3p.js → SubmoduleDiffSummary-CQyRcvDZ.js} +1 -1
  31. package/dist/assets/{ToolOutputDialog-Dx85XZJs.js → ToolOutputDialog-judR_5mS.js} +2 -2
  32. package/dist/assets/{ToolPartDiffPreview-Dtv0xF9O.js → ToolPartDiffPreview-Ca9ISxfg.js} +1 -1
  33. package/dist/assets/UsageStatsView-C63Emjfj.js +1 -0
  34. package/dist/assets/{Virtualizer-DL535kyR.js → Virtualizer-DNgIEKcx.js} +1 -1
  35. package/dist/assets/{WalkthroughView-DcxbT5tc.js → WalkthroughView-D74b_7sC.js} +2 -2
  36. package/dist/assets/WorktreesView-hcm8Eb_C.js +1 -0
  37. package/dist/assets/appThemeRegistry-COeayQaQ.js +1 -0
  38. package/dist/assets/{ar-lP51qqz9.js → ar-1_zdYVV5.js} +2 -2
  39. package/dist/assets/computeVirtualFileMetrics-MZqvCQy0.js +3 -0
  40. package/dist/assets/{de-CpROAvTV.js → de-Ci7SGEQP.js} +3 -3
  41. package/dist/assets/{decorate-BNB7jeKg.js → decorate-CZeRRVC7.js} +1 -1
  42. package/dist/assets/{es-Bb8LKRhE.js → es-ZJii-6Tt.js} +2 -2
  43. package/dist/assets/{fr-BlNN9FC2.js → fr-C-hK8mvI.js} +2 -2
  44. package/dist/assets/{he-r546pCuc.js → he-t07CylP8.js} +2 -2
  45. package/dist/assets/index-D2tPUss-.js +1 -0
  46. package/dist/assets/{initializeSharedPreferences-dCHO04bl.js → initializeSharedPreferences-FxFkTjgn.js} +1 -1
  47. package/dist/assets/{isDiffPlainText-BwicHPpI.js → isDiffPlainText-C1F9opE5.js} +1 -1
  48. package/dist/assets/{isFilePlainText-Dk2R7BJo.js → isFilePlainText-B4SyJ-ni.js} +1 -1
  49. package/dist/assets/{ja-evNvJAHz.js → ja-iJr8aONy.js} +2 -2
  50. package/dist/assets/{katex-CMY-1eWf.css → katex-BEX7X_K8.css} +1 -1
  51. package/dist/assets/{katex.min-Iw9WSgM9.js → katex.min-C-51hS9A.js} +18 -18
  52. package/dist/assets/{ko-BPQP7lXe.js → ko-D5ow_yz-.js} +2 -2
  53. package/dist/assets/main-BtGnuno4.js +1048 -0
  54. package/dist/assets/main-uj5954n5.js +2 -0
  55. package/dist/assets/markdownCore-rBXCnAJp.js +9 -0
  56. package/dist/assets/miniChat-yWQmT2OS.js +2 -0
  57. package/dist/assets/mobile-NDAeGtzL.js +2 -0
  58. package/dist/assets/{moveWorkspacePath-B31RGdgu.js → moveWorkspacePath-BINgpJ9S.js} +1 -1
  59. package/dist/assets/{nl-CkQXd1nU.js → nl-CfqYrSVe.js} +2 -2
  60. package/dist/assets/{parseDiffFromFile-DcsKSY0J.js → parseDiffFromFile--DE4eHIp.js} +2 -2
  61. package/dist/assets/{patchFileDiff-Cx-HpjyI.js → patchFileDiff-BfFUmWgS.js} +1 -1
  62. package/dist/assets/pierreDiffTint-D9K6_CVD.js +29 -0
  63. package/dist/assets/{pl-C4i9Aizi.js → pl-Bn2_jAhL.js} +4 -4
  64. package/dist/assets/{pt-BR-CoYnG1CH.js → pt-BR-ZSDgn6cI.js} +2 -2
  65. package/dist/assets/relocateRestoredSession-C85Tk2y9.js +1 -0
  66. package/dist/assets/renderElectronMiniChatApp-BvAEmWhZ.js +2 -0
  67. package/dist/assets/{renderMobileApp-gDKxRJQi.js → renderMobileApp-T20l8ise.js} +7 -7
  68. package/dist/assets/{restartOpenCode-dq-SGun3.js → restartOpenCode-VEmIrLer.js} +1 -1
  69. package/dist/assets/runtimeEndpointReset-ExJsaWzA.js +55 -0
  70. package/dist/assets/scheduledTasksApi-NSyxVfHu.js +1 -0
  71. package/dist/assets/{selectionMarkdown-sDTBbKLh.js → selectionMarkdown-BJ2RhTXc.js} +2 -2
  72. package/dist/assets/{sessionOwnership-kZAtwMQd.js → sessionOwnership-BAX1xEJC.js} +1 -1
  73. package/dist/assets/{shikiHighlight-BRNXPlF-.js → shikiHighlight-DOzrE7BE.js} +1 -1
  74. package/dist/assets/{space-apply-CCOKLfrX.js → space-apply-DB_ZfJBW.js} +1 -1
  75. package/dist/assets/space-close-1kNlTkW1.js +1 -0
  76. package/dist/assets/{spaceNetwork-DUxJClu3.js → spaceNetwork-DA16ov_y.js} +1 -1
  77. package/dist/assets/{textMateThemeFromAppTheme-B6UJwdZz.js → textMateThemeFromAppTheme-BfIrjFAU.js} +1 -1
  78. package/dist/assets/{tr-D-_lz-lC.js → tr-C89uz1hs.js} +2 -2
  79. package/dist/assets/{uk-B49PGMYB.js → uk-uTYVPFrO.js} +2 -2
  80. package/dist/assets/{useAppFontEffects-3EN8Ava3.js → useAppFontEffects-C1ceAD51.js} +185 -185
  81. package/dist/assets/useCallableModelProviders-BkLsgs6y.js +1 -0
  82. package/dist/assets/{useInlineCommentController-l9cWyfuR.js → useInlineCommentController-ynkUsoVA.js} +1 -1
  83. package/dist/assets/{useRootScrollLock-UAQn24Y8.js → useRootScrollLock-DnoKH1HE.js} +2 -2
  84. package/dist/assets/{vendor-codemirror-autocomplete-C8FBSI9t.js → vendor-codemirror-autocomplete-BRKmCSiY.js} +1 -1
  85. package/dist/assets/{vendor-codemirror-commands-BhRb6jns.js → vendor-codemirror-commands-MmBpgSOc.js} +1 -1
  86. package/dist/assets/vendor-codemirror-lang-angular-Bj5Pk8sp.js +1 -0
  87. package/dist/assets/vendor-codemirror-lang-cpp-tZt-BOgi.js +1 -0
  88. package/dist/assets/vendor-codemirror-lang-css-DfdrZ848.js +1 -0
  89. package/dist/assets/{vendor-codemirror-lang-go-BHJEONih.js → vendor-codemirror-lang-go-C9OcoXdP.js} +2 -2
  90. package/dist/assets/vendor-codemirror-lang-html-C5kFuJzc.js +1 -0
  91. package/dist/assets/vendor-codemirror-lang-java-Divn2dnj.js +1 -0
  92. package/dist/assets/{vendor-codemirror-lang-javascript-CUmSxayT.js → vendor-codemirror-lang-javascript-DmPuKUEa.js} +2 -2
  93. package/dist/assets/vendor-codemirror-lang-jinja-B-8miA-Q.js +1 -0
  94. package/dist/assets/vendor-codemirror-lang-json-L0wsFFxi.js +1 -0
  95. package/dist/assets/vendor-codemirror-lang-less-CWlCIxCI.js +1 -0
  96. package/dist/assets/vendor-codemirror-lang-liquid-Dm8xthAW.js +1 -0
  97. package/dist/assets/vendor-codemirror-lang-markdown-CPn-qinN.js +1 -0
  98. package/dist/assets/vendor-codemirror-lang-php-DKIOifjN.js +1 -0
  99. package/dist/assets/vendor-codemirror-lang-python-BAVa3Hg5.js +3 -0
  100. package/dist/assets/vendor-codemirror-lang-rust-Dab90hdg.js +1 -0
  101. package/dist/assets/vendor-codemirror-lang-sass-eezaHFBZ.js +1 -0
  102. package/dist/assets/{vendor-codemirror-lang-sql-C1Jj9uuJ.js → vendor-codemirror-lang-sql-Vu-PR7cv.js} +2 -2
  103. package/dist/assets/vendor-codemirror-lang-vue-BthRGZHy.js +1 -0
  104. package/dist/assets/vendor-codemirror-lang-wast-Db6KSic0.js +1 -0
  105. package/dist/assets/vendor-codemirror-lang-xml-DQkh4sc1.js +1 -0
  106. package/dist/assets/vendor-codemirror-lang-yaml-Bt2N__AW.js +1 -0
  107. package/dist/assets/vendor-codemirror-language-DkBxRck3.js +3 -0
  108. package/dist/assets/vendor-codemirror-language-data-CTYHXywt.js +2 -0
  109. package/dist/assets/{vendor-codemirror-search-CvXM_pZg.js → vendor-codemirror-search-BKAwkhkm.js} +1 -1
  110. package/dist/assets/vendor-codemirror-streamparser-CmlTsbN2.js +1 -0
  111. package/dist/assets/vendor-codemirror-view-B66jUSmE.js +4 -0
  112. package/dist/assets/{vendor-replit-codemirror-vim-Ck2X_WZC.js → vendor-replit-codemirror-vim-D0bqFa1D.js} +5 -5
  113. package/dist/assets/{worker-DdhrXE7g.js → worker-BbEdJ2Oi.js} +18 -18
  114. package/dist/assets/workerFactory-Bw5qLmrM.js +1 -0
  115. package/dist/assets/{zh-CN-CS-9Os9n.js → zh-CN-DdTNG52a.js} +2 -2
  116. package/dist/assets/{zh-TW-D0XYVdcl.js → zh-TW-DPm_33Fi.js} +2 -2
  117. package/dist/index.html +3 -3
  118. package/dist/mini-chat.html +3 -3
  119. package/dist/mobile.html +3 -3
  120. package/package.json +2 -2
  121. package/server/index.js +4 -0
  122. package/server/lib/environment/store.js +3 -4
  123. package/server/lib/environment/store.test.js +17 -0
  124. package/server/lib/fs/DOCUMENTATION.md +4 -2
  125. package/server/lib/fs/routes.js +48 -13
  126. package/server/lib/fs/routes.test.js +118 -5
  127. package/server/lib/git/DOCUMENTATION.md +3 -1
  128. package/server/lib/git/contributor-remote.js +4 -0
  129. package/server/lib/git/contributor-remote.test.js +21 -0
  130. package/server/lib/git/service.js +20 -25
  131. package/server/lib/git/service.test.js +99 -0
  132. package/server/lib/git/worktree-creation.js +4 -5
  133. package/server/lib/github/DOCUMENTATION.md +1 -1
  134. package/server/lib/github/routes.auth.test.js +14 -0
  135. package/server/lib/github/routes.js +13 -5
  136. package/server/lib/github/routes.mutations.test.js +18 -2
  137. package/server/lib/message-queue/DOCUMENTATION.md +8 -2
  138. package/server/lib/message-queue/runtime.js +3 -2
  139. package/server/lib/message-queue/runtime.test.js +64 -2
  140. package/server/lib/openchamber-control/service.js +48 -13
  141. package/server/lib/openchamber-control/service.test.js +42 -0
  142. package/server/lib/opencode/DOCUMENTATION.md +3 -1
  143. package/server/lib/opencode/project-start-command.d.ts +11 -0
  144. package/server/lib/opencode/project-start-command.js +56 -0
  145. package/server/lib/opencode/project-start-command.test.js +80 -0
  146. package/server/lib/opencode/session-activity.js +43 -3
  147. package/server/lib/opencode/session-activity.test.js +97 -0
  148. package/server/lib/opencode/settings-runtime.js +19 -1
  149. package/server/lib/opencode/settings-runtime.test.js +23 -0
  150. package/server/lib/opencode/skill-routes.js +34 -1
  151. package/server/lib/opencode/skill-routes.test.js +99 -0
  152. package/server/lib/quota/DOCUMENTATION.md +13 -1
  153. package/server/lib/quota/providers/antigravity/api.js +104 -0
  154. package/server/lib/quota/providers/antigravity/auth.js +45 -0
  155. package/server/lib/quota/providers/antigravity/index.js +76 -0
  156. package/server/lib/quota/providers/antigravity/transforms.js +168 -0
  157. package/server/lib/quota/providers/antigravity/transforms.test.js +162 -0
  158. package/server/lib/quota/providers/codex.js +28 -4
  159. package/server/lib/quota/providers/codex.test.js +29 -0
  160. package/server/lib/quota/providers/google/auth.js +4 -49
  161. package/server/lib/quota/providers/google/transforms.js +3 -22
  162. package/server/lib/quota/providers/index.js +8 -0
  163. package/server/lib/quota/providers/opencode-go.js +3 -1
  164. package/server/lib/quota/providers/opencode-go.test.js +12 -0
  165. package/server/lib/routing/DOCUMENTATION.md +3 -1
  166. package/server/lib/routing/runtime.js +34 -1
  167. package/server/lib/routing/runtime.test.js +43 -1
  168. package/server/lib/scheduled-tasks/DOCUMENTATION.md +11 -0
  169. package/server/lib/scheduled-tasks/existing-session.js +52 -8
  170. package/server/lib/scheduled-tasks/existing-session.test.js +121 -0
  171. package/server/lib/scheduled-tasks/routes.js +26 -0
  172. package/server/lib/scheduled-tasks/runtime.js +1 -0
  173. package/server/lib/session-assist/runtime.js +3 -0
  174. package/server/lib/session-assist/runtime.test.js +47 -0
  175. package/server/lib/skills-catalog/DOCUMENTATION.md +10 -1
  176. package/server/lib/skills-catalog/install.js +1 -1
  177. package/server/lib/skills-catalog/installed-sources.d.ts +17 -0
  178. package/server/lib/skills-catalog/installed-sources.js +112 -0
  179. package/server/lib/skills-catalog/installed-sources.test.js +94 -0
  180. package/server/lib/small-model/DOCUMENTATION.md +12 -5
  181. package/server/lib/small-model/index.js +6 -4
  182. package/server/lib/small-model/index.test.js +40 -0
  183. package/server/lib/small-model/routes.js +3 -2
  184. package/server/lib/source-control/change-request-worktree.js +2 -6
  185. package/server/lib/source-control/mutation-storage.js +4 -1
  186. package/server/lib/source-control/mutation-storage.test.js +21 -0
  187. package/server/lib/spaces/DOCUMENTATION.md +1 -1
  188. package/server/lib/spaces/journey.js +10 -3
  189. package/server/lib/spaces/journey.test.js +13 -1
  190. package/server/lib/terminal/history.js +22 -2
  191. package/server/lib/terminal/history.test.js +23 -0
  192. package/server/lib/terminal/theme-response.js +14 -0
  193. package/server/lib/terminal/theme-response.test.js +10 -0
  194. package/dist/assets/AboutDialog-e8ek_kPI.js +0 -1
  195. package/dist/assets/ArchiveView-CjF4_TFg.js +0 -1
  196. package/dist/assets/GuestSurfacePane-4kmEXPLD.js +0 -1
  197. package/dist/assets/HelpDialog-CITMqPDK.js +0 -1
  198. package/dist/assets/JsonTreeView-xGikhCtL.js +0 -1
  199. package/dist/assets/MarkdownImageGallery-D0FJyr7C.js +0 -1
  200. package/dist/assets/MarkdownRendererImpl-BIM7Pjwk.js +0 -1
  201. package/dist/assets/MemoryDebugPanel-CBk8QW-M.js +0 -1
  202. package/dist/assets/OnboardingScreen-Cy6ARiMS.js +0 -1
  203. package/dist/assets/OpenCodeStatusDialog-YMHuJzwt.js +0 -1
  204. package/dist/assets/RunOverview-CHkGSW1x.js +0 -2
  205. package/dist/assets/ScheduledTasksDialog-77SO8zdJ.js +0 -4
  206. package/dist/assets/SettingsWindow-X74FIkdo.js +0 -1
  207. package/dist/assets/SourceBoardView-Cff2ejOW.js +0 -1
  208. package/dist/assets/SpaceAccessDialog-BXMZNRei.js +0 -1
  209. package/dist/assets/SpaceApplyDialog-BEJd2ryu.js +0 -1
  210. package/dist/assets/SpaceSetupOutput-Cb3XcIII.js +0 -1
  211. package/dist/assets/SpacesView-I3HaRKtW.js +0 -1
  212. package/dist/assets/UsageStatsView-DwTt9zIz.js +0 -1
  213. package/dist/assets/WorktreesView-Bh7GLvrR.js +0 -1
  214. package/dist/assets/appThemeRegistry-Bzb67M9O.js +0 -1
  215. package/dist/assets/computeVirtualFileMetrics-WAp98Bb7.js +0 -3
  216. package/dist/assets/index-BsupKM40.js +0 -1
  217. package/dist/assets/main-C_QGhDBL.js +0 -1048
  218. package/dist/assets/main-pWZ7F_hy.js +0 -2
  219. package/dist/assets/markdownCore-6gz4uJDQ.js +0 -9
  220. package/dist/assets/miniChat-DnaTfdYh.js +0 -2
  221. package/dist/assets/mobile-C7DIJqP8.js +0 -2
  222. package/dist/assets/pierreDiffTint-B297eqF0.js +0 -28
  223. package/dist/assets/relocateRestoredSession-D3lujODj.js +0 -1
  224. package/dist/assets/renderElectronMiniChatApp-BF4hNe69.js +0 -2
  225. package/dist/assets/runtimeEndpointReset-D6Lxhk0S.js +0 -55
  226. package/dist/assets/scheduledTasksApi-DUbAMrjW.js +0 -1
  227. package/dist/assets/space-close-CWcWwH4_.js +0 -1
  228. package/dist/assets/useCallableModelProviders-BB9xkUzM.js +0 -1
  229. package/dist/assets/vendor-codemirror-lang-angular-BpYCRJSk.js +0 -1
  230. package/dist/assets/vendor-codemirror-lang-cpp-BI3uPyjT.js +0 -1
  231. package/dist/assets/vendor-codemirror-lang-css-B2_PZTBl.js +0 -1
  232. package/dist/assets/vendor-codemirror-lang-html-BpvvTxbZ.js +0 -1
  233. package/dist/assets/vendor-codemirror-lang-java-BM5LQZ4u.js +0 -1
  234. package/dist/assets/vendor-codemirror-lang-jinja-D8nLZQPK.js +0 -1
  235. package/dist/assets/vendor-codemirror-lang-json-VDxF27mO.js +0 -1
  236. package/dist/assets/vendor-codemirror-lang-less-BecU2BJP.js +0 -1
  237. package/dist/assets/vendor-codemirror-lang-liquid-DCw83Anh.js +0 -1
  238. package/dist/assets/vendor-codemirror-lang-markdown-CimQAQbQ.js +0 -1
  239. package/dist/assets/vendor-codemirror-lang-php-C5Kpnpyb.js +0 -1
  240. package/dist/assets/vendor-codemirror-lang-python-BFE1OJNx.js +0 -3
  241. package/dist/assets/vendor-codemirror-lang-rust-hqZDyGIJ.js +0 -1
  242. package/dist/assets/vendor-codemirror-lang-sass-CAZML-Jl.js +0 -1
  243. package/dist/assets/vendor-codemirror-lang-vue-BHOTXcKp.js +0 -1
  244. package/dist/assets/vendor-codemirror-lang-wast-DcCHfPUI.js +0 -1
  245. package/dist/assets/vendor-codemirror-lang-xml-BO_V-1wZ.js +0 -1
  246. package/dist/assets/vendor-codemirror-lang-yaml-CPimap_N.js +0 -1
  247. package/dist/assets/vendor-codemirror-language-BBADuAkg.js +0 -3
  248. package/dist/assets/vendor-codemirror-language-data-Cu5ZbrPm.js +0 -2
  249. package/dist/assets/vendor-codemirror-view-1e0FQ6Wn.js +0 -4
  250. package/dist/assets/workerFactory-De9YXIdE.js +0 -1
@@ -6,8 +6,6 @@
6
6
  */
7
7
 
8
8
  import {
9
- ANTIGRAVITY_ACCOUNTS_PATHS,
10
- readJsonFile,
11
9
  getAuthEntry,
12
10
  normalizeAuthEntry,
13
11
  asObject,
@@ -16,27 +14,15 @@ import {
16
14
  } from '../../utils/index.js';
17
15
  import { parseGoogleRefreshToken } from './transforms.js';
18
16
 
19
- const ANTIGRAVITY_GOOGLE_CLIENT_ID =
20
- '1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com';
21
- const ANTIGRAVITY_GOOGLE_CLIENT_SECRET = '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';
22
17
  const GEMINI_GOOGLE_CLIENT_ID =
23
18
  '681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com';
24
19
  const GEMINI_GOOGLE_CLIENT_SECRET = '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';
25
20
  export const DEFAULT_PROJECT_ID = 'rising-fact-p41fc';
26
21
 
27
- export const resolveGoogleOAuthClient = (sourceId) => {
28
- if (sourceId === 'gemini') {
29
- return {
30
- clientId: GEMINI_GOOGLE_CLIENT_ID,
31
- clientSecret: GEMINI_GOOGLE_CLIENT_SECRET
32
- };
33
- }
34
-
35
- return {
36
- clientId: ANTIGRAVITY_GOOGLE_CLIENT_ID,
37
- clientSecret: ANTIGRAVITY_GOOGLE_CLIENT_SECRET
38
- };
39
- };
22
+ export const resolveGoogleOAuthClient = () => ({
23
+ clientId: GEMINI_GOOGLE_CLIENT_ID,
24
+ clientSecret: GEMINI_GOOGLE_CLIENT_SECRET
25
+ });
40
26
 
41
27
  const resolveGeminiCliAuth = (auth) => {
42
28
  const entry = normalizeAuthEntry(getAuthEntry(auth, ['google', 'google.oauth']));
@@ -63,32 +49,6 @@ const resolveGeminiCliAuth = (auth) => {
63
49
  };
64
50
  };
65
51
 
66
- const resolveAntigravityAuth = () => {
67
- for (const filePath of ANTIGRAVITY_ACCOUNTS_PATHS) {
68
- const data = readJsonFile(filePath);
69
- const accounts = data?.accounts;
70
- if (Array.isArray(accounts) && accounts.length > 0) {
71
- const index = typeof data.activeIndex === 'number' ? data.activeIndex : 0;
72
- const account = accounts[index] ?? accounts[0];
73
- if (account?.refreshToken) {
74
- const refreshParts = parseGoogleRefreshToken(account.refreshToken);
75
- return {
76
- sourceId: 'antigravity',
77
- sourceLabel: 'Antigravity',
78
- refreshToken: refreshParts.refreshToken,
79
- projectId: asNonEmptyString(account.projectId)
80
- ?? asNonEmptyString(account.managedProjectId)
81
- ?? refreshParts.projectId
82
- ?? refreshParts.managedProjectId,
83
- email: account.email
84
- };
85
- }
86
- }
87
- }
88
-
89
- return null;
90
- };
91
-
92
52
  export const resolveGoogleAuthSources = (auth) => {
93
53
  const sources = [];
94
54
 
@@ -97,10 +57,5 @@ export const resolveGoogleAuthSources = (auth) => {
97
57
  sources.push(geminiAuth);
98
58
  }
99
59
 
100
- const antigravityAuth = resolveAntigravityAuth();
101
- if (antigravityAuth) {
102
- sources.push(antigravityAuth);
103
- }
104
-
105
60
  return sources;
106
61
  };
@@ -12,7 +12,6 @@ import {
12
12
  toUsageWindow
13
13
  } from '../../utils/index.js';
14
14
 
15
- const GOOGLE_FIVE_HOUR_WINDOW_SECONDS = 5 * 60 * 60;
16
15
  const GOOGLE_DAILY_WINDOW_SECONDS = 24 * 60 * 60;
17
16
 
18
17
  export const parseGoogleRefreshToken = (rawRefreshToken) => {
@@ -29,25 +28,7 @@ export const parseGoogleRefreshToken = (rawRefreshToken) => {
29
28
  };
30
29
  };
31
30
 
32
- const resolveGoogleWindow = (sourceId, resetAt) => {
33
- if (sourceId === 'gemini') {
34
- return { label: 'daily', seconds: GOOGLE_DAILY_WINDOW_SECONDS };
35
- }
36
-
37
- if (sourceId === 'antigravity') {
38
- const remainingSeconds = typeof resetAt === 'number'
39
- ? Math.max(0, Math.round((resetAt - Date.now()) / 1000))
40
- : null;
41
-
42
- if (remainingSeconds !== null && remainingSeconds > 10 * 60 * 60) {
43
- return { label: 'daily', seconds: GOOGLE_DAILY_WINDOW_SECONDS };
44
- }
45
-
46
- return { label: '5h', seconds: GOOGLE_FIVE_HOUR_WINDOW_SECONDS };
47
- }
48
-
49
- return { label: 'daily', seconds: GOOGLE_DAILY_WINDOW_SECONDS };
50
- };
31
+ const resolveGoogleWindow = () => ({ label: 'daily', seconds: GOOGLE_DAILY_WINDOW_SECONDS });
51
32
 
52
33
  export const transformQuotaBucket = (bucket, sourceId) => {
53
34
  const modelId = asNonEmptyString(bucket?.modelId);
@@ -65,7 +46,7 @@ export const transformQuotaBucket = (bucket, sourceId) => {
65
46
  : null;
66
47
  const usedPercent = remainingPercent !== null ? Math.max(0, 100 - remainingPercent) : null;
67
48
  const resetAt = toTimestamp(bucket?.resetTime);
68
- const window = resolveGoogleWindow(sourceId, resetAt);
49
+ const window = resolveGoogleWindow();
69
50
 
70
51
  return {
71
52
  [scopedName]: {
@@ -93,7 +74,7 @@ export const transformModelData = (modelName, modelData, sourceId) => {
93
74
  const resetAt = modelData?.quotaInfo?.resetTime
94
75
  ? new Date(modelData.quotaInfo.resetTime).getTime()
95
76
  : null;
96
- const window = resolveGoogleWindow(sourceId, resetAt);
77
+ const window = resolveGoogleWindow();
97
78
 
98
79
  return {
99
80
  [scopedName]: {
@@ -17,6 +17,7 @@ import * as deepinfra from './deepinfra.js';
17
17
  import * as deepseek from './deepseek.js';
18
18
  import * as exeDev from './exe-dev.js';
19
19
  import * as google from './google/index.js';
20
+ import * as antigravity from './antigravity/index.js';
20
21
  import * as hyper from './hyper.js';
21
22
  import * as kimi from './kimi.js';
22
23
  import * as nanogpt from './nanogpt.js';
@@ -83,6 +84,12 @@ const registry = {
83
84
  isConfigured: google.isConfigured,
84
85
  fetchQuota: google.fetchGoogleQuota
85
86
  },
87
+ antigravity: {
88
+ providerId: antigravity.providerId,
89
+ providerName: antigravity.providerName,
90
+ isConfigured: antigravity.isConfigured,
91
+ fetchQuota: antigravity.fetchQuota
92
+ },
86
93
  hyper: {
87
94
  providerId: hyper.providerId,
88
95
  providerName: hyper.providerName,
@@ -252,6 +259,7 @@ export const fetchQuotaForProvider = (providerId) => {
252
259
  export const fetchClaudeQuota = claude.fetchQuota;
253
260
  export const fetchOpenaiQuota = openai.fetchQuota;
254
261
  export const fetchGoogleQuota = google.fetchGoogleQuota;
262
+ export const fetchAntigravityQuota = antigravity.fetchQuota;
255
263
  export const fetchCodexQuota = codex.fetchQuota;
256
264
  export const fetchCursorQuota = cursor.fetchQuota;
257
265
  export const fetchDeepinfraQuota = deepinfra.fetchQuota;
@@ -30,7 +30,9 @@ const CONSOLE_BILLING_STATUS_URL = 'https://opencode.ai/console/api/billing/stat
30
30
  const MICRO_CENTS_PER_DOLLAR = 1_000_000;
31
31
  const CONSOLE_SERVER = 'https://opencode.ai/console';
32
32
  const CONSOLE_INTEGRATION_ID = 'opencode';
33
- const ORGANIZATION_ID_PATTERN = /^org_[A-Za-z0-9]+$/;
33
+ // Console workspaces carry a `wrk_` id on current sign-ins; older stored
34
+ // credentials still carry `org_`, so both prefixes count and nothing else.
35
+ const ORGANIZATION_ID_PATTERN = /^(?:org|wrk)_[A-Za-z0-9]+$/;
34
36
  const CONSOLE_PRODUCTS = new Set(['go', 'go-plus']);
35
37
  const NO_CONSOLE_SUBSCRIPTION = 'No active OpenCode Go subscription on the selected Console account';
36
38
  const REQUEST_TIMEOUT_MS = 15_000;
@@ -300,6 +300,18 @@ describe('OpenCode Go quota provider — Console OAuth', () => {
300
300
  expect(isConfigured({ 'opencode-go': { key: 'test-key' } })).toBe(true);
301
301
  });
302
302
 
303
+ it('accepts a wrk_ workspace id from a Console sign-in', async () => {
304
+ const orgID = 'wrk_01JBW7QK3E8V2Y5M9R4T6A8C0D';
305
+ expect(isConfigured(consoleAuth({ orgID }))).toBe(true);
306
+
307
+ const fetchImpl = vi.fn(async () => new Response(JSON.stringify(consolePayload())));
308
+ const result = await fetchQuota({ readAuth: async () => consoleAuth({ orgID }), fetchImpl });
309
+
310
+ expect(result.ok).toBe(true);
311
+ const statusCall = fetchImpl.mock.calls.find((call) => call[0] === CONSOLE_STATUS_URL);
312
+ expect(statusCall[1].headers['x-org-id']).toBe(orgID);
313
+ });
314
+
303
315
  it('distinguishes an expired sign-in without sending the stale token', async () => {
304
316
  const fetchImpl = vi.fn();
305
317
  const result = await fetchQuota({
@@ -52,7 +52,9 @@ Auto. There is no env gate — the feature shipped dark behind
52
52
  custom endpoint writes, event broadcasts, and `testClassifier` (one probe
53
53
  request from Settings' Test button, through the provider answering now or
54
54
  through custom endpoint fields as typed; stores nothing, and typed fields are
55
- refused in enterprise mode like a save).
55
+ refused in enterprise mode like a save). The classifier judges the user's
56
+ text plus one attachment fact for sends with images (`attachmentHint`,
57
+ `routingRequestTextOf`); that fact never reaches OpenCode.
56
58
  - `routes.js` — `/api/routing` (GET, PUT), `/api/routing/token` (PUT, DELETE),
57
59
  `/api/routing/classifier` (PUT), `/api/routing/classifier/custom` (PUT,
58
60
  DELETE), `/api/routing/classifier/test` (POST) and
@@ -54,6 +54,39 @@ export const requestTextOf = (body) => {
54
54
  return (prompt.success ? prompt.data.text ?? '' : '').trim();
55
55
  };
56
56
 
57
+ // The prompt body carries the attachments as `{ uri, name }` (`toPromptFile`
58
+ // drops the mime), so an image is recognized from its data URL or its name.
59
+ const attachmentFileSchema = z.object({ uri: z.string().nullish(), name: z.string().nullish() });
60
+ const attachmentListSchema = z.array(attachmentFileSchema);
61
+ const IMAGE_EXTENSIONS = new Set(['avif', 'bmp', 'gif', 'heic', 'heif', 'ico', 'jpeg', 'jpg', 'png', 'svg', 'webp']);
62
+
63
+ const isImageFile = (file) => {
64
+ const uri = file.uri ?? '';
65
+ if (uri.startsWith('data:')) return uri.startsWith('data:image/');
66
+ const name = (file.name ?? '').toLowerCase();
67
+ const dot = name.lastIndexOf('.');
68
+ return dot > 0 && IMAGE_EXTENSIONS.has(name.slice(dot + 1));
69
+ };
70
+
71
+ /**
72
+ * The attachment fact for the classifier. Jev reads text only, so a pasted
73
+ * image has to be stated in the request it judges; without this the router
74
+ * discards the one cue that distinguishes "look at this screenshot" from
75
+ * "fix the image-upload endpoint". Kept beside `requestTextOf` rather than
76
+ * inside it, whose tests pin that the raw words stay untouched.
77
+ */
78
+ export const attachmentHint = (body) => {
79
+ const files = attachmentListSchema.safeParse(body?.files).data ?? [];
80
+ const images = files.filter((file) => isImageFile(file));
81
+ if (images.length === 0) return '';
82
+ const names = images.map((file) => file.name).filter(Boolean).slice(0, 3);
83
+ const count = images.length === 1 ? 'an image' : `${images.length} images`;
84
+ return `\n\n[The user attached ${count}${names.length > 0 ? `: ${names.join(', ')}` : ''}]`;
85
+ };
86
+
87
+ /** What the classifier sees for this send: the user's words plus the attachment fact. */
88
+ export const routingRequestTextOf = (body) => `${requestTextOf(body)}${attachmentHint(body)}`.trim();
89
+
57
90
  const agentBodySchema = z.object({ agent: z.string().trim().min(1) });
58
91
 
59
92
  // v2 serves one flat model catalogue; a model's thinking levels are `{ id }[]`.
@@ -401,7 +434,7 @@ export function createRoutingRuntime({
401
434
  directory,
402
435
  model: AUTO_MODEL_REF,
403
436
  agent: agentBodySchema.safeParse(body).data?.agent ?? null,
404
- requestText: requestTextOf(body),
437
+ requestText: routingRequestTextOf(body),
405
438
  });
406
439
  if (!resolved) return null;
407
440
  // v2 prompt and command bodies carry neither model nor agent: switching
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it, vi } from 'vitest';
2
- import { createRoutingRuntime, readOpenCodeKeys, requestTextOf } from './runtime.js';
2
+ import { attachmentHint, createRoutingRuntime, readOpenCodeKeys, requestTextOf, routingRequestTextOf } from './runtime.js';
3
3
  import { resolveEffectiveConfig } from './store.js';
4
4
  import { excerptHead, excerptHeadTail, turnsToHistory } from './history.js';
5
5
  import { createJevClient, decidePermission, decideRouting } from './jev.js';
@@ -76,6 +76,48 @@ describe('requestTextOf', () => {
76
76
  });
77
77
  });
78
78
 
79
+ describe('attachmentHint', () => {
80
+ it('describes a pasted image from its data URL and names it', () => {
81
+ expect(attachmentHint({ text: "what's wrong?", files: [{ uri: 'data:image/png;base64,iVBORw0KGgo=', name: 'screenshot.png' }] }))
82
+ .toBe('\n\n[The user attached an image: screenshot.png]');
83
+ });
84
+ it('counts several images and lists at most three names', () => {
85
+ const files = ['a.png', 'b.jpg', 'c.webp', 'd.gif'].map((name) => ({ uri: 'data:image/png;base64,AAAA', name }));
86
+ expect(attachmentHint({ text: 'compare these', files })).toBe(
87
+ '\n\n[The user attached 4 images: a.png, b.jpg, c.webp]',
88
+ );
89
+ });
90
+ it('recognizes a non-data URI by its image extension', () => {
91
+ expect(attachmentHint({ text: 'look', files: [{ uri: 'file:///repo/shots/FIGURE-1.PNG', name: 'FIGURE-1.PNG' }] }))
92
+ .toBe('\n\n[The user attached an image: FIGURE-1.PNG]');
93
+ });
94
+ it('stays silent without images, without files, or for non-image attachments', () => {
95
+ expect(attachmentHint({ text: 'read the log', files: [{ uri: 'file:///repo/notes.txt', name: 'notes.txt' }] })).toBe('');
96
+ expect(attachmentHint({ text: 'sign this', files: [{ uri: 'data:application/pdf;base64,JVBERi0=', name: 'contract.pdf' }] })).toBe('');
97
+ expect(attachmentHint({ text: 'no files here' })).toBe('');
98
+ expect(attachmentHint({ text: '' })).toBe('');
99
+ });
100
+ it('survives a malformed files value', () => {
101
+ expect(attachmentHint({ text: 'hi', files: 'nope' })).toBe('');
102
+ expect(attachmentHint({ text: 'hi', files: [{ uri: 42, name: null }] })).toBe('');
103
+ });
104
+ });
105
+
106
+ describe('routingRequestTextOf', () => {
107
+ it('appends the attachment fact to the words being classified', () => {
108
+ const body = { text: "what's wrong?", files: [{ uri: 'data:image/png;base64,iVBORw0KGgo=', name: 'screenshot.png' }] };
109
+ expect(routingRequestTextOf(body)).toBe("what's wrong?\n\n[The user attached an image: screenshot.png]");
110
+ });
111
+ it('is byte-identical to requestTextOf when nothing image-shaped is attached', () => {
112
+ const body = { text: 'fix the typo in README', files: [{ uri: 'file:///repo/notes.txt', name: 'notes.txt' }] };
113
+ expect(routingRequestTextOf(body)).toBe(requestTextOf(body));
114
+ });
115
+ it('keeps the slash-command form for a command body with an image', () => {
116
+ const body = { name: 'review', text: ' src ', files: [{ uri: 'data:image/jpeg;base64,/9j/', name: 'shot.jpg' }] };
117
+ expect(routingRequestTextOf(body)).toBe('/review src\n\n[The user attached an image: shot.jpg]');
118
+ });
119
+ });
120
+
79
121
  describe('history excerpts', () => {
80
122
  it('keeps the head of a user message and head plus tail of an answer', () => {
81
123
  const long = 'a'.repeat(1000);
@@ -110,6 +110,16 @@ Another registered project owns its exact checkout. Chats targets must remain
110
110
  inside the chats scope. Missing targets return 404; archived or foreign targets
111
111
  return 409, including through Run now.
112
112
 
113
+ Target discovery asks the same rule rather than reproducing it:
114
+ `POST /api/projects/:projectId/scheduled-tasks/targets/eligible` takes the
115
+ candidate sessions the editor already holds (at most 500 per request; the
116
+ editor sends larger lists in batches), each with its directory, and returns the
117
+ ones whose directory belongs to the task project by `validateTarget`'s rule,
118
+ resolving worktree ownership through Git once per directory. Discovery does not
119
+ check that a session still exists; that stays with `validateTarget`. The picker filters on that answer, so the renderer's current
120
+ worktree topology never decides eligibility, and `validateTarget` stays the
121
+ final authority on save, admission and send.
122
+
113
123
  The prompt enters the ordinary server message queue with `scheduledTask`
114
124
  provenance. One project and task can have at most one waiting prompt. Run now
115
125
  on an already queued prompt records `skipped` and returns 409 with
@@ -275,6 +285,7 @@ project write lock on every `syncProject` when the project path is known:
275
285
  - Registers:
276
286
  - `GET /api/projects/:projectId/scheduled-tasks`
277
287
  - `PUT /api/projects/:projectId/scheduled-tasks`
288
+ - `POST /api/projects/:projectId/scheduled-tasks/targets/eligible`
278
289
  - `DELETE /api/projects/:projectId/scheduled-tasks/:taskId`
279
290
  - `PATCH /api/projects/:projectId/scheduled-tasks/:taskId/loop-file`
280
291
  - `DELETE /api/projects/:projectId/scheduled-tasks/:taskId/loop-file`
@@ -1,10 +1,24 @@
1
1
  import path from 'node:path';
2
2
  import { z } from 'zod';
3
3
  import { OpenChamberControlError } from '../openchamber-control/error.js';
4
+ import { asNonEmptyString } from '../shared/guards.js';
4
5
  import { expandSnippets } from '../opencode/snippets.js';
5
6
 
6
7
  export const createExistingSessionTasks = ({ projectConfigRuntime, messageQueueRuntime, createClient, listProjects, chatsScope, resolvePrimaryWorktreeRoot, isSessionArchived, emitTaskRunEvent }) => {
7
8
  const admissions = new Set();
9
+
10
+ // The membership rule, in one place: a save or run and the picker's
11
+ // discovery both ask this, so the two can never disagree about whether a
12
+ // directory belongs to a project. Ownership comes from Git through
13
+ // `resolvePrimaryWorktreeRoot`, never from the renderer's worktree topology.
14
+ const ownsDirectory = async (project, directory) => {
15
+ if (!project || !directory) return false;
16
+ if (path.resolve(directory) === path.resolve(project.path)) return true;
17
+ if (!resolvePrimaryWorktreeRoot) return false;
18
+ const owner = await resolvePrimaryWorktreeRoot(directory);
19
+ return Boolean(owner?.root) && path.resolve(owner.root) === path.resolve(project.path);
20
+ };
21
+
8
22
  const validateTarget = async (projectId, targetSessionId) => {
9
23
  if (!z.string().regex(/^[A-Za-z0-9_-]{4,128}$/).safeParse(targetSessionId).success) {
10
24
  throw new OpenChamberControlError('targetSessionId is invalid', 400);
@@ -29,17 +43,47 @@ export const createExistingSessionTasks = ({ projectConfigRuntime, messageQueueR
29
43
  }
30
44
  let belongs = false;
31
45
  if (chatsScope && projectId === chatsScope.id) belongs = chatsScope.contains(directory);
32
- else if (project && directory) {
33
- belongs = path.resolve(directory) === path.resolve(project.path);
34
- if (!belongs && resolvePrimaryWorktreeRoot) {
35
- const owner = await resolvePrimaryWorktreeRoot(directory);
36
- belongs = Boolean(owner?.root) && path.resolve(owner.root) === path.resolve(project.path);
37
- }
38
- }
46
+ else if (project && directory) belongs = await ownsDirectory(project, directory);
39
47
  if (!belongs) throw new OpenChamberControlError('Scheduled target is outside the task project', 409);
40
48
  return { session, directory };
41
49
  };
42
50
 
51
+ /**
52
+ * The discovery half of the same rule: which candidates a save or run would
53
+ * accept by their directory. Candidates arrive with the directory the client
54
+ * already knows; ownership is resolved here, and a session offered without a
55
+ * directory, or one that is archived or foreign, is never eligible. Whether
56
+ * the session still exists is left to `validateTarget` on save.
57
+ */
58
+ const listEligibleTargets = async (projectId, candidates) => {
59
+ const projects = await listProjects();
60
+ const scopeId = chatsScope ? chatsScope.toStorageID(projectId) : projectId;
61
+ const project = projects.find((entry) => entry.id === scopeId);
62
+ // Many sessions share a few directories, so membership is resolved once
63
+ // per directory: a Git lookup per session would run hundreds of processes.
64
+ const membership = new Map();
65
+ const belongsToTask = (directory) => {
66
+ const key = path.resolve(directory);
67
+ if (!membership.has(key)) {
68
+ membership.set(key, (async () => {
69
+ if (projects.some((entry) => entry.id !== scopeId && path.resolve(entry.path) === key)) return false;
70
+ if (chatsScope && scopeId === chatsScope.id) return chatsScope.contains(directory);
71
+ return project ? ownsDirectory(project, directory) : false;
72
+ })());
73
+ }
74
+ return membership.get(key);
75
+ };
76
+ const eligible = [];
77
+ for (const candidate of Array.isArray(candidates) ? candidates : []) {
78
+ const sessionId = asNonEmptyString(candidate?.sessionId);
79
+ const directory = asNonEmptyString(candidate?.directory);
80
+ if (!sessionId || !directory) continue;
81
+ if (await isSessionArchived?.(sessionId)) continue;
82
+ if (await belongsToTask(directory)) eligible.push({ sessionId, directory });
83
+ }
84
+ return eligible;
85
+ };
86
+
43
87
  const record = async (projectId, taskId, status, error, lastRunAt) => {
44
88
  const patch = {
45
89
  lastStatus: status, lastError: error || undefined, updatedAt: Date.now(),
@@ -112,7 +156,7 @@ export const createExistingSessionTasks = ({ projectConfigRuntime, messageQueueR
112
156
  };
113
157
 
114
158
  return {
115
- validateTarget, run, beforeSend,
159
+ validateTarget, listEligibleTargets, run, beforeSend,
116
160
  result: ({ projectId, taskId }, status, error) => record(projectId, taskId, status, error),
117
161
  cancel: (projectId, taskId) => messageQueueRuntime.cancelScheduledTask(projectId, taskId),
118
162
  };
@@ -348,3 +348,124 @@ describe('existing session scheduling', () => {
348
348
  }
349
349
  });
350
350
  });
351
+
352
+ describe('eligible target discovery', () => {
353
+ it('accepts a linked-worktree session the renderer topology need not know', async () => {
354
+ const { runtime } = setup({
355
+ resolvePrimaryWorktreeRoot: async (directory) => (directory.startsWith('/repo/worktrees/') ? { root: '/repo' } : null),
356
+ });
357
+
358
+ const eligible = await runtime.listEligibleTargets('project-1', [
359
+ { sessionId: 'ses_root', directory: '/repo' },
360
+ { sessionId: 'ses_wt', directory: '/repo/worktrees/feature' },
361
+ ]);
362
+
363
+ expect(eligible.map((entry) => entry.sessionId)).toEqual(['ses_root', 'ses_wt']);
364
+ });
365
+
366
+ it('rejects a plain subdirectory the old picker offered by prefix match', async () => {
367
+ const { runtime } = setup({
368
+ resolvePrimaryWorktreeRoot: async () => null,
369
+ });
370
+
371
+ const eligible = await runtime.listEligibleTargets('project-1', [
372
+ { sessionId: 'ses_sub', directory: '/repo/docs/notes' },
373
+ ]);
374
+
375
+ expect(eligible).toEqual([]);
376
+ });
377
+
378
+ it('rejects foreign projects, archived sessions and candidates without a directory', async () => {
379
+ const { runtime } = setup({
380
+ listProjects: async () => [
381
+ { id: 'project-1', path: '/repo' },
382
+ { id: 'project-2', path: '/other' },
383
+ ],
384
+ isSessionArchived: async (sessionId) => sessionId === 'ses_archived',
385
+ resolvePrimaryWorktreeRoot: async () => null,
386
+ });
387
+
388
+ const eligible = await runtime.listEligibleTargets('project-1', [
389
+ { sessionId: 'ses_other', directory: '/other' },
390
+ { sessionId: 'ses_archived', directory: '/repo' },
391
+ { sessionId: 'ses_nodir', directory: '' },
392
+ { sessionId: 'ses_ok', directory: '/repo' },
393
+ ]);
394
+
395
+ expect(eligible.map((entry) => entry.sessionId)).toEqual(['ses_ok']);
396
+ });
397
+
398
+ it('resolves ownership once per directory', async () => {
399
+ const resolvePrimaryWorktreeRoot = vi.fn(async () => ({ root: '/repo' }));
400
+ const { runtime } = setup({ resolvePrimaryWorktreeRoot });
401
+ const candidates = Array.from({ length: 300 }, (_, index) => ({
402
+ sessionId: `ses_${index}`,
403
+ directory: `/repo/worktrees/tree-${index % 10}`,
404
+ }));
405
+
406
+ const eligible = await runtime.listEligibleTargets('project-1', candidates);
407
+
408
+ expect(eligible).toHaveLength(300);
409
+ expect(resolvePrimaryWorktreeRoot).toHaveBeenCalledTimes(10);
410
+ });
411
+
412
+ it('resolves the chats scope through its public id', async () => {
413
+ const { runtime } = setup({
414
+ chatsScope: {
415
+ id: 'chats-path-id',
416
+ root: '/chats',
417
+ toStorageID: (projectId) => (projectId === 'openchamber:chats' ? 'chats-path-id' : projectId),
418
+ contains: (directory) => directory.startsWith('/chats/'),
419
+ },
420
+ });
421
+
422
+ const eligible = await runtime.listEligibleTargets('openchamber:chats', [
423
+ { sessionId: 'ses_chat', directory: '/chats/2026-10-11/session-1' },
424
+ { sessionId: 'ses_repo', directory: '/repo' },
425
+ ]);
426
+
427
+ expect(eligible.map((entry) => entry.sessionId)).toEqual(['ses_chat']);
428
+ });
429
+ });
430
+
431
+ describe('eligible targets route', () => {
432
+ const makeResponse = () => ({
433
+ statusCode: 200,
434
+ body: null,
435
+ status(code) { this.statusCode = code; return this; },
436
+ json(body) { this.body = body; return this; },
437
+ });
438
+
439
+ it('answers the scheduler resolution for the posted candidates', async () => {
440
+ const listEligibleTargets = vi.fn(async () => [{ sessionId: 'ses_ok', directory: '/repo' }]);
441
+ const handlers = new Map();
442
+ const app = Object.fromEntries(['get', 'put', 'delete', 'patch', 'post'].map((method) => [method, (route, handler) => handlers.set(`${method}:${route}`, handler)]));
443
+ registerScheduledTaskRoutes(app, { scheduledTasksRuntime: { listEligibleTargets } });
444
+ const handler = handlers.get('post:/api/projects/:projectId/scheduled-tasks/targets/eligible');
445
+ expect(handler).toBeTypeOf('function');
446
+
447
+ const candidates = [{ sessionId: 'ses_ok', directory: '/repo' }];
448
+ const response = makeResponse();
449
+ await handler({ params: { projectId: 'project-1' }, body: { candidates } }, response);
450
+
451
+ expect(listEligibleTargets).toHaveBeenCalledWith('project-1', candidates);
452
+ expect(response.body).toEqual({ eligible: [{ sessionId: 'ses_ok', directory: '/repo' }] });
453
+ });
454
+
455
+ it('rejects a missing or oversized candidate list', async () => {
456
+ const listEligibleTargets = vi.fn(async () => []);
457
+ const handlers = new Map();
458
+ const app = Object.fromEntries(['get', 'put', 'delete', 'patch', 'post'].map((method) => [method, (route, handler) => handlers.set(`${method}:${route}`, handler)]));
459
+ registerScheduledTaskRoutes(app, { scheduledTasksRuntime: { listEligibleTargets } });
460
+ const handler = handlers.get('post:/api/projects/:projectId/scheduled-tasks/targets/eligible');
461
+
462
+ const missing = makeResponse();
463
+ await handler({ params: { projectId: 'project-1' }, body: {} }, missing);
464
+ expect(missing.statusCode).toBe(400);
465
+
466
+ const oversized = makeResponse();
467
+ await handler({ params: { projectId: 'project-1' }, body: { candidates: Array.from({ length: 501 }, (_, index) => ({ sessionId: `ses_${index}`, directory: '/repo' })) } }, oversized);
468
+ expect(oversized.statusCode).toBe(400);
469
+ expect(listEligibleTargets).not.toHaveBeenCalled();
470
+ });
471
+ });
@@ -57,6 +57,32 @@ export const registerScheduledTaskRoutes = (app, dependencies) => {
57
57
  }
58
58
  });
59
59
 
60
+ // The picker asks the scheduler which of the candidates it already holds a
61
+ // save would accept. Eligibility shares validateTarget's membership rule on
62
+ // purpose: the client never decides it from its own worktree topology (#4757).
63
+ app.post('/api/projects/:projectId/scheduled-tasks/targets/eligible', async (req, res) => {
64
+ const projectID = parseProjectID(req);
65
+ if (!projectID) {
66
+ return res.status(400).json({ error: 'projectId is required' });
67
+ }
68
+ const candidates = req.body && Array.isArray(req.body.candidates) ? req.body.candidates : null;
69
+ if (!candidates || candidates.length > 500) {
70
+ return res.status(400).json({ error: 'candidates must be an array of at most 500 entries' });
71
+ }
72
+ if (!scheduledTasksRuntime?.listEligibleTargets) {
73
+ return res.status(503).json({ error: 'Eligible target resolution is unavailable' });
74
+ }
75
+
76
+ try {
77
+ const eligible = await scheduledTasksRuntime.listEligibleTargets(projectID, candidates);
78
+ return res.json({ eligible });
79
+ } catch (error) {
80
+ if (error?.statusCode) return res.status(error.statusCode).json({ error: error.message });
81
+ console.error('[ScheduledTasks] failed to resolve eligible targets:', error);
82
+ return res.status(500).json({ error: 'Failed to resolve eligible targets' });
83
+ }
84
+ });
85
+
60
86
  app.delete('/api/projects/:projectId/scheduled-tasks/:taskId', async (req, res) => {
61
87
  const projectID = parseProjectID(req);
62
88
  const taskID = parseTaskID(req);
@@ -1264,6 +1264,7 @@ export const createScheduledTasksRuntime = (deps) => {
1264
1264
  runNow,
1265
1265
  getStatus,
1266
1266
  validateTarget: (projectID, sessionID) => existingSessionTasks.validateTarget(projectID, sessionID),
1267
+ listEligibleTargets: (projectID, candidates) => existingSessionTasks.listEligibleTargets(projectID, candidates),
1267
1268
  beforeScheduledTaskSend: (sessionID, directory, item) => existingSessionTasks.beforeSend(sessionID, directory, item),
1268
1269
  onScheduledTaskResult: (provenance, status, error) => existingSessionTasks.result(provenance, status, error),
1269
1270
  cancelWaitingPrompt: (projectID, taskID) => existingSessionTasks?.cancel(projectID, taskID),
@@ -231,6 +231,9 @@ export const createSessionAssistRuntime = ({
231
231
  checkCurrent();
232
232
  if (freshSession?.id !== sessionId || freshSession.revert?.messageID || freshSession.location?.directory !== session.location?.directory) return;
233
233
  if (await isSessionArchived(sessionId)) return;
234
+ // The archive check is a wait of its own: a turn that started meanwhile
235
+ // has aborted this run, and the write below must not land.
236
+ checkCurrent();
234
237
  const enabled = getTargets();
235
238
  if (!enabled.recap || !allowed.recap) recap = '';
236
239
  if (!enabled.suggestion || !allowed.suggestion) suggestion = '';