@openchamber/web 1.24.2 → 2.0.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 (387) hide show
  1. package/bin/lib/commands-connect-url.js +3 -8
  2. package/bin/lib/commands-tunnel.js +3 -0
  3. package/dist/assets/{CodeMirrorCommentWidgets-B_vBPQYm.js → CodeMirrorCommentWidgets-zm3C1FvM.js} +1 -1
  4. package/dist/assets/DiffView-DNExNi1z.js +4 -0
  5. package/dist/assets/FilesView-DUCLmHBi.js +17 -0
  6. package/dist/assets/{GitView-k0hUF8KB.js → GitView-Bz9z6gZA.js} +4 -4
  7. package/dist/assets/{GuestAttachDialog-DIf2U85Z.js → GuestAttachDialog-UGp4KDlK.js} +1 -1
  8. package/dist/assets/GuestSurfacePane-B3pdB_2u.js +1 -0
  9. package/dist/assets/{JsonTreeView-4AnJ04Pw.js → JsonTreeView-7lVecnZl.js} +1 -1
  10. package/dist/assets/LinearIssuesView-CTGRS9Vq.js +1 -0
  11. package/dist/assets/MarkdownImageGallery-DQk5adUs.js +1 -0
  12. package/dist/assets/MarkdownRendererImpl-DPF8fZpX.js +12 -0
  13. package/dist/assets/OnboardingScreen-CBx6cXPP.js +1 -0
  14. package/dist/assets/{PatchDiff-DpGmHRnV.js → PatchDiff-D7VVpR_l.js} +1 -1
  15. package/dist/assets/{PierreDiffViewer-CgLl_tp7.js → PierreDiffViewer-Gbfks1pk.js} +3 -3
  16. package/dist/assets/PlanView-CPSK0x97.js +5 -0
  17. package/dist/assets/PluginPane-BIGsUx69.js +3 -0
  18. package/dist/assets/SettingsView-Dql7z6Ww.js +30 -0
  19. package/dist/assets/SettingsWindow-D6oi-UmV.js +1 -0
  20. package/dist/assets/SubmoduleDiffSummary-BXA0FAWj.js +1 -0
  21. package/dist/assets/ToolOutputDialog-BQJsSbDm.js +15 -0
  22. package/dist/assets/ToolPartDiffPreview-FY9w0TVT.js +8 -0
  23. package/dist/assets/{VirtualizedFileDiff-BK4aU5qJ.js → VirtualizedFileDiff-B9YhAya5.js} +4 -4
  24. package/dist/assets/{WalkthroughView-Bk6TPNFw.js → WalkthroughView-CmFgOUFN.js} +2 -2
  25. package/dist/assets/appThemeRegistry-BebxalUt.js +1 -0
  26. package/dist/assets/changesTree-CePHbFcj.js +1 -0
  27. package/dist/assets/commitAndPush-Wfxng_IK.js +1 -0
  28. package/dist/assets/{computeVirtualFileMetrics-BVTujWSX.js → computeVirtualFileMetrics-BCOqgixN.js} +2 -2
  29. package/dist/assets/de-CMA45TC-.js +10 -0
  30. package/dist/assets/es-DPL4fBtl.js +16 -0
  31. package/dist/assets/fr-OHBKBseP.js +14 -0
  32. package/dist/assets/index-3TiDNtfN.js +1 -0
  33. package/dist/assets/index-BLUZa5u0.js +41 -0
  34. package/dist/assets/index-Cm2rrq69.css +1 -0
  35. package/dist/assets/{isDiffPlainText-D3yX_vx4.js → isDiffPlainText-DnDYQmWK.js} +1 -1
  36. package/dist/assets/{isFilePlainText-CZR9TcHV.js → isFilePlainText-BA_AHX7d.js} +1 -1
  37. package/dist/assets/ja-DvX4WSRf.js +16 -0
  38. package/dist/assets/ko-BUcLd8YZ.js +16 -0
  39. package/dist/assets/main-B_jri4i-.js +896 -0
  40. package/dist/assets/main-DtUmJp9B.js +2 -0
  41. package/dist/assets/{markdown-shiki.worker-CahLvHIq.js → markdown-shiki.worker-Bg8SoAJJ.js} +8 -5
  42. package/dist/assets/markdownCore-BSnlUXBf.js +7 -0
  43. package/dist/assets/miniChat-BYfLUnDK.js +2 -0
  44. package/dist/assets/mobile-DH3hI6gd.js +2 -0
  45. package/dist/assets/patchFileDiff--L7lt_GZ.js +13 -0
  46. package/dist/assets/pl-BkI_xHqz.js +16 -0
  47. package/dist/assets/pt-BR-7wFtQlV9.js +16 -0
  48. package/dist/assets/renderElectronMiniChatApp-C7kpNW_-.js +2 -0
  49. package/dist/assets/renderMobileApp-i0nq7Dwy.js +25 -0
  50. package/dist/assets/runtimeEndpointReset-CfEYbcCc.js +27 -0
  51. package/dist/assets/scheduledTasksApi-Cy7uZCaI.js +1 -0
  52. package/dist/assets/{shikiHighlight-BfjuB3CD.js → shikiHighlight-D4vxipfr.js} +1 -1
  53. package/dist/assets/{textMateThemeFromAppTheme-BP60t9SX.js → textMateThemeFromAppTheme-BYAHtJwQ.js} +1 -1
  54. package/dist/assets/tr-TsD-AqEH.js +7 -0
  55. package/dist/assets/uk-B-qspCmD.js +16 -0
  56. package/dist/assets/useAppFontEffects-DHZ9-L30.js +7338 -0
  57. package/dist/assets/useInlineCommentController-CvpOMK-R.js +2 -0
  58. package/dist/assets/useRootScrollLock-DzNFi-fn.js +2 -0
  59. package/dist/assets/{vendor-codemirror-language-data-BFm1Ju2w.js → vendor-codemirror-language-data-j3fhlwUM.js} +2 -2
  60. package/dist/assets/vendor-cron-parser-CjvYVigk.js +2 -0
  61. package/dist/assets/vendor-opencode-client-DYdsLbCM.js +12 -0
  62. package/dist/assets/{vendor-remixicon-react-BDmGmFCA.js → vendor-remixicon-react-D6dZ0UwF.js} +1 -1
  63. package/dist/assets/vendor-zod-BSoePkpP.js +39 -0
  64. package/dist/assets/{web-components-2vo9YsZc.js → web-components-BvHNFSEG.js} +2 -2
  65. package/dist/assets/zh-CN-DYuPJV5i.js +16 -0
  66. package/dist/assets/zh-TW-BX_2D_lV.js +16 -0
  67. package/dist/index.html +13 -7
  68. package/dist/mini-chat.html +5 -5
  69. package/dist/mobile.html +5 -5
  70. package/package.json +6 -5
  71. package/server/index.d.ts +1 -0
  72. package/server/index.js +264 -91
  73. package/server/lib/agent-tool/DOCUMENTATION.md +38 -16
  74. package/server/lib/agent-tool/runtime.js +167 -58
  75. package/server/lib/agent-tool/runtime.test.js +170 -87
  76. package/server/lib/browser-control/DOCUMENTATION.md +51 -4
  77. package/server/lib/browser-control/provider.js +217 -0
  78. package/server/lib/browser-control/provider.test.js +251 -0
  79. package/server/lib/context-obligatory/runtime.js +61 -50
  80. package/server/lib/context-obligatory/runtime.test.js +62 -162
  81. package/server/lib/event-stream/DOCUMENTATION.md +12 -1
  82. package/server/lib/event-stream/delta-coalescer.js +0 -0
  83. package/server/lib/event-stream/delta-coalescer.test.js +68 -57
  84. package/server/lib/event-stream/directory-ws-bridge.js +1 -1
  85. package/server/lib/event-stream/global-hub.js +10 -1
  86. package/server/lib/event-stream/global-hub.test.js +27 -26
  87. package/server/lib/event-stream/index.js +6 -0
  88. package/server/lib/event-stream/protocol.js +26 -19
  89. package/server/lib/event-stream/protocol.test.js +18 -7
  90. package/server/lib/event-stream/rebind.test.js +5 -5
  91. package/server/lib/event-stream/runtime.test.js +17 -15
  92. package/server/lib/event-stream/translate-v2.js +313 -0
  93. package/server/lib/event-stream/translate-v2.test.js +209 -0
  94. package/server/lib/event-stream/upstream-reader.test.js +16 -16
  95. package/server/lib/fs/DOCUMENTATION.md +4 -2
  96. package/server/lib/fs/byte-range.js +35 -0
  97. package/server/lib/fs/byte-range.test.js +31 -0
  98. package/server/lib/fs/routes.js +47 -42
  99. package/server/lib/fs/routes.test.js +123 -18
  100. package/server/lib/git/DOCUMENTATION.md +1 -1
  101. package/server/lib/git/service.js +34 -0
  102. package/server/lib/git/service.test.js +8 -0
  103. package/server/lib/github/DOCUMENTATION.md +1 -1
  104. package/server/lib/github/pr-status.js +22 -2
  105. package/server/lib/github/pr-status.test.js +27 -14
  106. package/server/lib/guests/DOCUMENTATION.md +16 -2
  107. package/server/lib/guests/catalog.js +31 -1
  108. package/server/lib/guests/catalog.test.js +55 -0
  109. package/server/lib/guests/html-styles.js +5 -3
  110. package/server/lib/guests/html-styles.test.js +3 -1
  111. package/server/lib/guests/routes.js +21 -4
  112. package/server/lib/guests/service.js +197 -14
  113. package/server/lib/guests/service.test.js +201 -1
  114. package/server/lib/guests/surface.js +676 -0
  115. package/server/lib/guests/surface.test.js +536 -0
  116. package/server/lib/markdown-image-grants/routes.js +18 -5
  117. package/server/lib/markdown-image-grants/routes.test.js +9 -6
  118. package/server/lib/message-queue/DOCUMENTATION.md +33 -22
  119. package/server/lib/message-queue/runtime.js +155 -100
  120. package/server/lib/message-queue/runtime.test.js +168 -82
  121. package/server/lib/notifications/DOCUMENTATION.md +38 -0
  122. package/server/lib/notifications/control-stream.http.test.js +68 -0
  123. package/server/lib/notifications/emit-route.js +118 -0
  124. package/server/lib/notifications/emit-route.test.js +112 -0
  125. package/server/lib/notifications/emitter-runtime.js +15 -0
  126. package/server/lib/notifications/emitter-runtime.test.js +32 -0
  127. package/server/lib/notifications/push-runtime.js +5 -1
  128. package/server/lib/notifications/push-runtime.test.js +2 -2
  129. package/server/lib/notifications/routes.js +1 -1
  130. package/server/lib/notifications/runtime.js +115 -26
  131. package/server/lib/notifications/template-runtime.js +13 -15
  132. package/server/lib/notifications/template-runtime.test.js +16 -9
  133. package/server/lib/notifications/trigger-runtime.test.js +187 -0
  134. package/server/lib/openchamber-control/DOCUMENTATION.md +10 -0
  135. package/server/lib/openchamber-control/actions.js +19 -4
  136. package/server/lib/openchamber-control/error.js +1 -1
  137. package/server/lib/openchamber-control/file-open.js +59 -0
  138. package/server/lib/openchamber-control/file-open.test.js +57 -0
  139. package/server/lib/openchamber-control/routes.test.js +12 -0
  140. package/server/lib/openchamber-control/service.js +125 -49
  141. package/server/lib/openchamber-control/service.test.js +115 -44
  142. package/server/lib/openchamber-sessions/archive-store.js +224 -0
  143. package/server/lib/openchamber-sessions/archive-store.test.js +187 -0
  144. package/server/lib/openchamber-sessions/fork-inheritance.js +103 -0
  145. package/server/lib/openchamber-sessions/fork-inheritance.test.js +69 -0
  146. package/server/lib/openchamber-sessions/opencode-client.js +22 -0
  147. package/server/lib/openchamber-sessions/routes.js +409 -328
  148. package/server/lib/openchamber-sessions/routes.test.js +795 -740
  149. package/server/lib/openchamber-sessions/session-metadata-store.js +285 -0
  150. package/server/lib/openchamber-sessions/session-metadata-store.test.js +259 -0
  151. package/server/lib/opencode/DOCUMENTATION.md +458 -29
  152. package/server/lib/opencode/agents.js +233 -327
  153. package/server/lib/opencode/auth.js +41 -44
  154. package/server/lib/opencode/auth.test.js +92 -0
  155. package/server/lib/opencode/bootstrap-runtime.js +12 -0
  156. package/server/lib/opencode/cli-upgrade.d.ts +4 -0
  157. package/server/lib/opencode/cli-upgrade.js +18 -0
  158. package/server/lib/opencode/cli-upgrade.test.js +36 -0
  159. package/server/lib/opencode/commands.js +164 -145
  160. package/server/lib/opencode/compatibility.d.ts +16 -0
  161. package/server/lib/opencode/compatibility.js +91 -0
  162. package/server/lib/opencode/compatibility.test.js +70 -0
  163. package/server/lib/opencode/config-entity-routes.js +58 -29
  164. package/server/lib/opencode/config-entity-v2.test.js +290 -0
  165. package/server/lib/opencode/config-mutation-response.js +17 -7
  166. package/server/lib/opencode/config-mutation-response.test.js +4 -7
  167. package/server/lib/opencode/config-paths.test.js +2 -2
  168. package/server/lib/opencode/config-v2.d.ts +185 -0
  169. package/server/lib/opencode/config-v2.js +843 -0
  170. package/server/lib/opencode/config-v2.test.js +483 -0
  171. package/server/lib/opencode/core-routes.js +3 -0
  172. package/server/lib/opencode/core-routes.test.js +15 -0
  173. package/server/lib/opencode/credential-db.js +144 -0
  174. package/server/lib/opencode/credential-db.test.js +104 -0
  175. package/server/lib/opencode/env-runtime.js +47 -15
  176. package/server/lib/opencode/env-runtime.test.js +45 -0
  177. package/server/lib/opencode/feature-routes-runtime.js +16 -5
  178. package/server/lib/opencode/lifecycle-process.test.js +7 -4
  179. package/server/lib/opencode/lifecycle.js +113 -30
  180. package/server/lib/opencode/lifecycle.test.js +107 -8
  181. package/server/lib/opencode/login-shell-env.js +27 -0
  182. package/server/lib/opencode/managed-config-file.js +131 -0
  183. package/server/lib/opencode/managed-config-file.test.js +168 -0
  184. package/server/lib/opencode/managed-plugin-config.js +33 -13
  185. package/server/lib/opencode/mcp.js +43 -149
  186. package/server/lib/opencode/network-runtime.js +6 -7
  187. package/server/lib/opencode/openchamber-routes.js +29 -11
  188. package/server/lib/opencode/openchamber-routes.test.js +18 -1
  189. package/server/lib/opencode/plugin-routes.js +3 -3
  190. package/server/lib/opencode/plugin-routes.test.js +6 -24
  191. package/server/lib/opencode/plugins.js +91 -40
  192. package/server/lib/opencode/plugins.test.js +28 -15
  193. package/server/lib/opencode/provider-source-route.test.js +59 -0
  194. package/server/lib/opencode/providers.js +66 -83
  195. package/server/lib/opencode/providers.test.js +190 -59
  196. package/server/lib/opencode/proxy-agent-wiring.test.js +4 -2
  197. package/server/lib/opencode/proxy.js +179 -129
  198. package/server/lib/opencode/pwa-manifest-routes.js +4 -2
  199. package/server/lib/opencode/pwa-manifest-routes.test.js +3 -2
  200. package/server/lib/opencode/response-envelope.js +14 -0
  201. package/server/lib/opencode/response-envelope.test.js +23 -0
  202. package/server/lib/opencode/routes-upgrade.test.js +73 -116
  203. package/server/lib/opencode/routes.js +138 -428
  204. package/server/lib/opencode/server-utils-runtime.js +10 -4
  205. package/server/lib/opencode/session-activity.js +78 -0
  206. package/server/lib/opencode/session-runtime.js +21 -10
  207. package/server/lib/opencode/session-runtime.test.js +9 -9
  208. package/server/lib/opencode/settings-helpers.js +15 -8
  209. package/server/lib/opencode/settings-helpers.test.js +7 -12
  210. package/server/lib/opencode/settings-registry.json +20 -8
  211. package/server/lib/opencode/settings-runtime.js +19 -1
  212. package/server/lib/opencode/settings-runtime.test.js +31 -2
  213. package/server/lib/opencode/shared.js +86 -24
  214. package/server/lib/opencode/shared.test.js +87 -5
  215. package/server/lib/opencode/shutdown-runtime.js +54 -7
  216. package/server/lib/opencode/shutdown-runtime.test.js +224 -30
  217. package/server/lib/opencode/skill-routes.js +51 -36
  218. package/server/lib/opencode/skill-routes.test.js +121 -1
  219. package/server/lib/opencode/skills.js +7 -5
  220. package/server/lib/opencode/tunnel-wiring-runtime.js +2 -1
  221. package/server/lib/opencode/upgrade-capability.js +0 -14
  222. package/server/lib/opencode/upgrade-capability.test.js +1 -1
  223. package/server/lib/opencode/v1-migration-topup.js +294 -0
  224. package/server/lib/opencode/v1-migration-topup.test.js +274 -0
  225. package/server/lib/opencode/v2-install.d.ts +9 -0
  226. package/server/lib/opencode/v2-install.js +159 -0
  227. package/server/lib/opencode/v2-install.test.js +133 -0
  228. package/server/lib/opencode/watcher.js +10 -3
  229. package/server/lib/opencode/watcher.test.js +17 -21
  230. package/server/lib/opencode/websearch-config.js +78 -0
  231. package/server/lib/permission-auto-accept/runtime.js +38 -22
  232. package/server/lib/permission-auto-accept/runtime.test.js +39 -17
  233. package/server/lib/quota/DOCUMENTATION.md +4 -0
  234. package/server/lib/quota/providers/kimi.js +1 -1
  235. package/server/lib/quota/providers/xai.js +4 -4
  236. package/server/lib/relay/tunnel-host.js +4 -1
  237. package/server/lib/relay/tunnel-host.test.js +7 -0
  238. package/server/lib/routing/DOCUMENTATION.md +52 -21
  239. package/server/lib/routing/defaults.js +23 -6
  240. package/server/lib/routing/jev.js +17 -7
  241. package/server/lib/routing/routes.http.test.js +68 -33
  242. package/server/lib/routing/routes.js +65 -22
  243. package/server/lib/routing/runtime.js +145 -48
  244. package/server/lib/routing/runtime.test.js +79 -55
  245. package/server/lib/scheduled-tasks/DOCUMENTATION.md +4 -0
  246. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +51 -46
  247. package/server/lib/scheduled-tasks/runtime.js +81 -74
  248. package/server/lib/scheduled-tasks/runtime.test.js +53 -1
  249. package/server/lib/session-assist/DOCUMENTATION.md +25 -8
  250. package/server/lib/session-assist/context.js +122 -46
  251. package/server/lib/session-assist/context.test.js +117 -49
  252. package/server/lib/session-assist/runtime.js +71 -24
  253. package/server/lib/session-assist/runtime.test.js +153 -173
  254. package/server/lib/session-goal/DOCUMENTATION.md +34 -15
  255. package/server/lib/session-goal/create.js +9 -12
  256. package/server/lib/session-goal/create.test.js +27 -28
  257. package/server/lib/session-goal/runtime.js +164 -77
  258. package/server/lib/session-goal/runtime.test.js +271 -519
  259. package/server/lib/session-knowledge/DOCUMENTATION.md +5 -0
  260. package/server/lib/session-knowledge/runtime.js +59 -41
  261. package/server/lib/session-knowledge/runtime.test.js +90 -20
  262. package/server/lib/small-model/DOCUMENTATION.md +154 -208
  263. package/server/lib/small-model/client.js +113 -0
  264. package/server/lib/small-model/index.js +296 -158
  265. package/server/lib/small-model/index.test.js +423 -256
  266. package/server/lib/small-model/routes.js +1 -1
  267. package/server/lib/spaces/DOCUMENTATION.md +807 -0
  268. package/server/lib/spaces/code-in-bait.js +185 -0
  269. package/server/lib/spaces/code-in.js +641 -0
  270. package/server/lib/spaces/code-in.test.js +1048 -0
  271. package/server/lib/spaces/errors.js +8 -0
  272. package/server/lib/spaces/exec-http.js +94 -0
  273. package/server/lib/spaces/gatekeeper-channel.js +202 -0
  274. package/server/lib/spaces/gatekeeper-channel.test.js +215 -0
  275. package/server/lib/spaces/gatekeeper-program.cjs +914 -0
  276. package/server/lib/spaces/gatekeeper-program.test.js +1391 -0
  277. package/server/lib/spaces/hardening.js +457 -0
  278. package/server/lib/spaces/hardening.test.js +368 -0
  279. package/server/lib/spaces/host-git.js +127 -0
  280. package/server/lib/spaces/host-git.test.js +137 -0
  281. package/server/lib/spaces/labels.js +234 -0
  282. package/server/lib/spaces/labels.test.js +219 -0
  283. package/server/lib/spaces/layout.js +184 -0
  284. package/server/lib/spaces/layout.test.js +30 -0
  285. package/server/lib/spaces/manager.js +82 -0
  286. package/server/lib/spaces/manager.test.js +114 -0
  287. package/server/lib/spaces/places/code-in.docker.live.test.js +216 -0
  288. package/server/lib/spaces/places/contract-suite.js +156 -0
  289. package/server/lib/spaces/places/contract.docker.live.test.js +7 -0
  290. package/server/lib/spaces/places/contract.test.js +6 -0
  291. package/server/lib/spaces/places/docker-engine.js +126 -0
  292. package/server/lib/spaces/places/docker-live-support.js +202 -0
  293. package/server/lib/spaces/places/docker-tools.js +186 -0
  294. package/server/lib/spaces/places/docker.js +587 -0
  295. package/server/lib/spaces/places/docker.test.js +1610 -0
  296. package/server/lib/spaces/places/escape-suite.js +1018 -0
  297. package/server/lib/spaces/places/escape.docker.live.test.js +7 -0
  298. package/server/lib/spaces/places/fake-docker.js +375 -0
  299. package/server/lib/spaces/places/memory-place.js +103 -0
  300. package/server/lib/spaces/places/packed.docker.live.test.js +77 -0
  301. package/server/lib/spaces/places/registry.js +43 -0
  302. package/server/lib/spaces/places/registry.test.js +50 -0
  303. package/server/lib/spaces/places/server.docker.live.test.js +225 -0
  304. package/server/lib/spaces/run-command.js +261 -0
  305. package/server/lib/spaces/run-command.test.js +396 -0
  306. package/server/lib/spaces/space-server.js +190 -0
  307. package/server/lib/spaces/space-server.test.js +335 -0
  308. package/server/lib/spaces/tools-filler.js +82 -0
  309. package/server/lib/spaces/tools-filler.test.js +148 -0
  310. package/server/lib/spaces/tools-pack.js +49 -0
  311. package/server/lib/spaces/tools-pack.test.js +57 -0
  312. package/server/lib/spaces/tools.js +137 -0
  313. package/server/lib/spaces/tools.test.js +153 -0
  314. package/server/lib/tts/openai-sdk.js +11 -0
  315. package/server/lib/tts/service.js +7 -5
  316. package/server/lib/tts/stt.js +3 -2
  317. package/server/lib/tunnels/DOCUMENTATION.md +2 -0
  318. package/server/lib/tunnels/routes.js +7 -0
  319. package/server/lib/tunnels/routes.test.js +55 -0
  320. package/server/lib/ui-auth/ui-auth.js +38 -2
  321. package/server/lib/ui-auth/ui-auth.test.js +42 -0
  322. package/server/lib/ui-auth/ui-passkeys.js +12 -10
  323. package/server/lib/walkthrough/DOCUMENTATION.md +10 -1
  324. package/server/lib/walkthrough/pull-request.js +61 -8
  325. package/server/lib/walkthrough/pull-request.test.js +54 -1
  326. package/server/lib/walkthrough/routes.js +20 -0
  327. package/server/lib/walkthrough/routes.test.js +19 -0
  328. package/server/opencode-proxy.test.js +190 -166
  329. package/server/opencode-worktree-readiness.test.js +5 -4
  330. package/dist/assets/DiffView-Ce0oBXXQ.js +0 -4
  331. package/dist/assets/FilesView-DtXueAWP.js +0 -13
  332. package/dist/assets/LinearIssuesView-z_9p2GuO.js +0 -1
  333. package/dist/assets/MarkdownImageGallery-BC-BNN-s.js +0 -1
  334. package/dist/assets/MarkdownRendererImpl-DyaBTUbH.js +0 -12
  335. package/dist/assets/OnboardingScreen-DKU_yTb6.js +0 -1
  336. package/dist/assets/PlanView-CrfB4qqY.js +0 -5
  337. package/dist/assets/PluginPane-B5cn-jPy.js +0 -3
  338. package/dist/assets/SettingsView-DMKKwezx.js +0 -29
  339. package/dist/assets/SettingsWindow-DwbnVzOC.js +0 -1
  340. package/dist/assets/SubmoduleDiffSummary-hkGcvs0E.js +0 -1
  341. package/dist/assets/ToolOutputDialog-DuoIOc0j.js +0 -15
  342. package/dist/assets/ToolPartDiffPreview-t1Bvq_2Y.js +0 -8
  343. package/dist/assets/appThemeRegistry-DnOVbJjF.js +0 -1
  344. package/dist/assets/commitAndPush-DLWNZkkY.js +0 -1
  345. package/dist/assets/de-zEHaAIi3.js +0 -10
  346. package/dist/assets/es-CBDgEzgk.js +0 -16
  347. package/dist/assets/fr-DjiTptT_.js +0 -14
  348. package/dist/assets/index-AgOdanig.css +0 -1
  349. package/dist/assets/index-B-2_X4DD.js +0 -40
  350. package/dist/assets/index-CkA4p2IK.js +0 -1
  351. package/dist/assets/ja-CerMgj3r.js +0 -16
  352. package/dist/assets/ko-DHYDAze5.js +0 -16
  353. package/dist/assets/main-BDka4W43.js +0 -896
  354. package/dist/assets/main-Dl7Dyge_.js +0 -2
  355. package/dist/assets/markdownCore-DFmr0rUR.js +0 -5
  356. package/dist/assets/miniChat-CLKQPPpO.js +0 -2
  357. package/dist/assets/mobile--giD2Q1L.js +0 -2
  358. package/dist/assets/patchFileDiff-DRh-AQvd.js +0 -13
  359. package/dist/assets/pl-BTB_93bq.js +0 -16
  360. package/dist/assets/pt-BR-BwA3oyCK.js +0 -16
  361. package/dist/assets/renderElectronMiniChatApp-DmB7zpVK.js +0 -2
  362. package/dist/assets/renderMobileApp-pMfOuQfl.js +0 -25
  363. package/dist/assets/runtimeEndpointReset-Gqhmkm3U.js +0 -25
  364. package/dist/assets/scheduledTasksApi-CeRAIUmW.js +0 -1
  365. package/dist/assets/tr-CcPsJoNM.js +0 -7
  366. package/dist/assets/uk-B68WibXi.js +0 -16
  367. package/dist/assets/useAppFontEffects-DcdrFv2Z.js +0 -7333
  368. package/dist/assets/useInlineCommentController-Cq4SUjsA.js +0 -2
  369. package/dist/assets/useRootScrollLock-CSdR6Wnm.js +0 -2
  370. package/dist/assets/vendor-cron-parser-CUcP7OfX.js +0 -2
  371. package/dist/assets/vendor-opencode-sdk-BJ73u-bH.js +0 -7
  372. package/dist/assets/vendor-zod-CgAdXWZO.js +0 -39
  373. package/dist/assets/zh-CN-DbFHYXwP.js +0 -16
  374. package/dist/assets/zh-TW-DmXAwdty.js +0 -16
  375. package/server/lib/opencode/mcp-oauth-callback.test.js +0 -111
  376. package/server/lib/routing/feature-flag.js +0 -11
  377. package/server/lib/small-model/call.js +0 -851
  378. package/server/lib/small-model/call.test.js +0 -1292
  379. package/server/lib/small-model/catalog.js +0 -13
  380. package/server/lib/small-model/resolve.js +0 -131
  381. package/server/lib/small-model/resolve.test.js +0 -197
  382. package/server/lib/small-model/runtime-providers.js +0 -164
  383. package/server/lib/small-model/runtime-providers.test.js +0 -118
  384. package/server/lib/system-prompt/DOCUMENTATION.md +0 -36
  385. package/server/lib/system-prompt/runtime.js +0 -49
  386. package/server/lib/system-prompt/runtime.test.js +0 -76
  387. package/server/lib/walkthrough/reproduce-2607.test.js +0 -148
@@ -14,25 +14,33 @@ import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
14
14
  * before creating a session, so the second instance skips.
15
15
  */
16
16
 
17
- const sdk = vi.hoisted(() => ({
18
- sessionCreates: [],
19
- createOpencodeClient: () => ({
20
- session: {
21
- create: async () => {
22
- sdk.sessionCreates.push(Date.now());
23
- return { data: { id: `sess-${sdk.sessionCreates.length}` } };
24
- },
25
- },
26
- command: { list: async () => ({ data: [] }) },
27
- }),
28
- }));
29
-
30
- vi.mock('@opencode-ai/sdk/v2', () => ({
31
- createOpencodeClient: sdk.createOpencodeClient,
32
- }));
33
-
34
17
  import { createScheduledTasksRuntime } from './runtime.js';
35
18
 
19
+ const opencode = { sessionCreates: [] };
20
+
21
+ const jsonResponse = (body) => new Response(JSON.stringify(body), {
22
+ status: 200,
23
+ headers: { 'content-type': 'application/json' },
24
+ });
25
+
26
+ /**
27
+ * Serves the few v2 routes a scheduled run touches so the test drives the real
28
+ * @opencode/client over its own transport instead of replacing the module.
29
+ * `gate` holds the prompt open the way a long-running dispatch would.
30
+ */
31
+ const installOpenCodeFetch = (gate = null) => {
32
+ globalThis.fetch = vi.fn(async (input) => {
33
+ const { pathname } = new URL(input);
34
+ if (pathname === '/api/session') {
35
+ opencode.sessionCreates.push(Date.now());
36
+ return jsonResponse({ data: { id: `sess-${opencode.sessionCreates.length}` } });
37
+ }
38
+ if (pathname === '/api/command') return jsonResponse({ data: [] });
39
+ if (gate) await gate;
40
+ return jsonResponse({ data: {} });
41
+ });
42
+ };
43
+
36
44
  const UTC = (y, mo, d, h, mi, s = 0) => Date.UTC(y, mo, d, h, mi, s);
37
45
  const MINUTE = 60_000;
38
46
  const HOUR = 3_600_000;
@@ -118,8 +126,8 @@ const startInstances = async (count, task) => {
118
126
  describe('issue 2710: daily scheduled task double execution at the configured time', () => {
119
127
  beforeEach(() => {
120
128
  vi.useFakeTimers();
121
- sdk.sessionCreates.length = 0;
122
- globalThis.fetch = vi.fn(async () => ({ ok: true, text: async () => '' }));
129
+ opencode.sessionCreates.length = 0;
130
+ installOpenCodeFetch();
123
131
  });
124
132
 
125
133
  afterEach(() => {
@@ -132,8 +140,8 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
132
140
  const { runtimes } = await startInstances(1, makeTask({ kind: 'daily', times: ['15:00'] }));
133
141
  await vi.advanceTimersByTimeAsync(HOUR + 3_000);
134
142
 
135
- expect(sdk.sessionCreates.length).toBe(1);
136
- const firedAt = new Date(sdk.sessionCreates[0]);
143
+ expect(opencode.sessionCreates.length).toBe(1);
144
+ const firedAt = new Date(opencode.sessionCreates[0]);
137
145
  expect(firedAt.getUTCHours()).toBe(15);
138
146
 
139
147
  runtimes.forEach((runtime) => runtime.stop());
@@ -144,9 +152,9 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
144
152
  const { runtimes } = await startInstances(1, makeTask({ kind: 'daily', times: ['15:00'] }));
145
153
  await vi.advanceTimersByTimeAsync((4 * 24 * HOUR) + 3_000);
146
154
 
147
- expect(sdk.sessionCreates.length).toBe(4);
155
+ expect(opencode.sessionCreates.length).toBe(4);
148
156
  const byHourBucket = new Map();
149
- for (const timestamp of sdk.sessionCreates) {
157
+ for (const timestamp of opencode.sessionCreates) {
150
158
  const date = new Date(timestamp);
151
159
  expect(date.getUTCHours()).toBe(15);
152
160
  expect(date.getUTCMinutes()).toBe(0);
@@ -168,8 +176,8 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
168
176
  );
169
177
  await vi.advanceTimersByTimeAsync(HOUR + 3_000);
170
178
 
171
- expect(sdk.sessionCreates.length).toBe(1);
172
- const firedAt = new Date(sdk.sessionCreates[0]);
179
+ expect(opencode.sessionCreates.length).toBe(1);
180
+ const firedAt = new Date(opencode.sessionCreates[0]);
173
181
  expect(firedAt.getUTCHours()).toBe(15);
174
182
  expect(firedAt.getUTCMinutes()).toBe(0);
175
183
  expect(projectConfigRuntime.updateScheduledTaskStateIf).toHaveBeenCalled();
@@ -187,7 +195,7 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
187
195
  }));
188
196
  await vi.advanceTimersByTimeAsync((25 * HOUR) + 3_000);
189
197
 
190
- expect(sdk.sessionCreates.length).toBe(1);
198
+ expect(opencode.sessionCreates.length).toBe(1);
191
199
 
192
200
  runtimes.forEach((runtime) => runtime.stop());
193
201
  });
@@ -197,7 +205,7 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
197
205
  const { runtimes } = await startInstances(2, makeTask({ kind: 'cron', cron: '*/5 * * * *' }));
198
206
  await vi.advanceTimersByTimeAsync(3 * MINUTE);
199
207
 
200
- expect(sdk.sessionCreates.length).toBe(1);
208
+ expect(opencode.sessionCreates.length).toBe(1);
201
209
 
202
210
  runtimes.forEach((runtime) => runtime.stop());
203
211
  });
@@ -211,7 +219,7 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
211
219
  }));
212
220
  await vi.advanceTimersByTimeAsync(HOUR + 3_000);
213
221
 
214
- expect(sdk.sessionCreates.length).toBe(1);
222
+ expect(opencode.sessionCreates.length).toBe(1);
215
223
 
216
224
  runtimes.forEach((runtime) => runtime.stop());
217
225
  });
@@ -229,14 +237,14 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
229
237
 
230
238
  await vi.advanceTimersByTimeAsync(HOUR + 3_000);
231
239
 
232
- expect(sdk.sessionCreates.length).toBe(0);
240
+ expect(opencode.sessionCreates.length).toBe(0);
233
241
  expect(runtime.getStatus().runningScheduledTasksCount).toBe(0);
234
242
  expect(runtime.getStatus().hasRunningScheduledTasks).toBe(false);
235
243
 
236
244
  // Manual runNow must not be stuck behind a permanently "running" claim failure.
237
245
  const manual = await runtime.runNow('p1', 'task-1');
238
246
  expect(manual.ok).toBe(true);
239
- expect(sdk.sessionCreates.length).toBe(1);
247
+ expect(opencode.sessionCreates.length).toBe(1);
240
248
 
241
249
  runtime.stop();
242
250
  });
@@ -263,7 +271,7 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
263
271
 
264
272
  // Initial completion write + best-effort retry.
265
273
  expect(completionWrites).toBeGreaterThanOrEqual(2);
266
- expect(sdk.sessionCreates.length).toBe(1);
274
+ expect(opencode.sessionCreates.length).toBe(1);
267
275
  expect(runtime.getStatus().runningScheduledTasksCount).toBe(0);
268
276
 
269
277
  const manual = await runtime.runNow('p1', 'task-1');
@@ -316,7 +324,7 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
316
324
  const manual = await runtime.runNow('p1', 'task-1');
317
325
  expect(manual.ok).toBe(false);
318
326
  expect(manual.reason).toBe('start-state-failed');
319
- expect(sdk.sessionCreates.length).toBe(0);
327
+ expect(opencode.sessionCreates.length).toBe(0);
320
328
  expect(runtime.getStatus().runningScheduledTasksCount).toBe(0);
321
329
 
322
330
  runtime.stop();
@@ -340,7 +348,7 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
340
348
 
341
349
  await vi.advanceTimersByTimeAsync(5_000);
342
350
 
343
- expect(sdk.sessionCreates.length).toBe(1);
351
+ expect(opencode.sessionCreates.length).toBe(1);
344
352
 
345
353
  runtimeA.stop();
346
354
  runtimeB.stop();
@@ -356,7 +364,7 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
356
364
  const runtimeA = createScheduledTasksRuntime(createRuntimeDeps(projectConfigRuntime));
357
365
  await runtimeA.start();
358
366
  await vi.advanceTimersByTimeAsync(HOUR + 3_000);
359
- expect(sdk.sessionCreates.length).toBe(1);
367
+ expect(opencode.sessionCreates.length).toBe(1);
360
368
 
361
369
  // Advance to day-2 afternoon, still outside slack, so A re-arms for 15:00.
362
370
  await vi.advanceTimersByTimeAsync((23 * HOUR) - 3_000);
@@ -367,7 +375,7 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
367
375
 
368
376
  await vi.advanceTimersByTimeAsync(5_000);
369
377
 
370
- expect(sdk.sessionCreates.length).toBe(2);
378
+ expect(opencode.sessionCreates.length).toBe(2);
371
379
 
372
380
  runtimeA.stop();
373
381
  runtimeB.stop();
@@ -380,10 +388,7 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
380
388
  const fetchGate = new Promise((resolve) => {
381
389
  releaseFetch = resolve;
382
390
  });
383
- globalThis.fetch = vi.fn(async () => {
384
- await fetchGate;
385
- return { ok: true, text: async () => '' };
386
- });
391
+ installOpenCodeFetch(fetchGate);
387
392
 
388
393
  const { runtimes, projectConfigRuntime } = await startInstances(2, makeTask({
389
394
  kind: 'once',
@@ -393,21 +398,21 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
393
398
 
394
399
  await vi.advanceTimersByTimeAsync(HOUR + 3_000);
395
400
 
396
- // Winner claimed and is blocked in prompt_async; exactly one session.
397
- expect(sdk.sessionCreates.length).toBe(1);
401
+ // Winner claimed and is blocked in the prompt dispatch; exactly one session.
402
+ expect(opencode.sessionCreates.length).toBe(1);
398
403
  const claimsAfterFire = projectConfigRuntime.updateScheduledTaskStateIf.mock.calls.length;
399
404
  expect(claimsAfterFire).toBeGreaterThanOrEqual(1);
400
405
 
401
406
  // Advance through many jitter windows. Loser must not keep re-entering claim.
402
407
  await vi.advanceTimersByTimeAsync(60_000);
403
408
  expect(projectConfigRuntime.updateScheduledTaskStateIf.mock.calls.length).toBe(claimsAfterFire);
404
- expect(sdk.sessionCreates.length).toBe(1);
409
+ expect(opencode.sessionCreates.length).toBe(1);
405
410
 
406
411
  releaseFetch();
407
412
  await Promise.resolve();
408
413
  await vi.advanceTimersByTimeAsync(5_000);
409
414
 
410
- expect(sdk.sessionCreates.length).toBe(1);
415
+ expect(opencode.sessionCreates.length).toBe(1);
411
416
  expect(runtimes.every((runtime) => runtime.getStatus().runningScheduledTasksCount === 0)).toBe(true);
412
417
 
413
418
  runtimes.forEach((runtime) => runtime.stop());
@@ -467,7 +472,7 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
467
472
  await runtime.start();
468
473
  await vi.advanceTimersByTimeAsync(HOUR + 3_000);
469
474
 
470
- expect(sdk.sessionCreates.length).toBe(0);
475
+ expect(opencode.sessionCreates.length).toBe(0);
471
476
  const tasks = await projectConfigRuntime.listScheduledTasks('p1');
472
477
  expect(tasks[0].state.lastStatus).toBe('error');
473
478
  expect(tasks[0].state.lastError).toMatch(/Scheduled claim failed/);
@@ -496,12 +501,12 @@ describe('issue 2710: daily scheduled task double execution at the configured ti
496
501
 
497
502
  // The scheduler must not fire a disabled task on its own.
498
503
  await vi.advanceTimersByTimeAsync(HOUR + 3_000);
499
- expect(sdk.sessionCreates.length).toBe(0);
504
+ expect(opencode.sessionCreates.length).toBe(0);
500
505
 
501
506
  const manual = await runtime.runNow('p1', 'task-1');
502
507
  expect(manual.ok).toBe(true);
503
508
  expect(manual.sessionID).toBeTruthy();
504
- expect(sdk.sessionCreates.length).toBe(1);
509
+ expect(opencode.sessionCreates.length).toBe(1);
505
510
  expect(runtime.getStatus().runningScheduledTasksCount).toBe(0);
506
511
 
507
512
  // Completion records state but leaves the task paused with no next run.
@@ -1,4 +1,4 @@
1
- import { createOpencodeClient } from '@opencode-ai/sdk/v2';
1
+ import { OpenCode } from '@opencode/client';
2
2
  import { DateTime } from 'luxon';
3
3
  import { CronExpressionParser } from 'cron-parser';
4
4
  import { expandSnippets } from '../opencode/snippets.js';
@@ -255,12 +255,27 @@ export const createScheduledTasksRuntime = (deps) => {
255
255
  emitTaskRunEvent,
256
256
  setSessionAutoAccept,
257
257
  sessionKnowledgeRuntime = null,
258
+ // The goal record lives in OpenChamber's metadata store (OpenCode 2.x takes
259
+ // session metadata only at create time); without it goal mode cannot run.
260
+ persistSessionGoal = null,
258
261
  logger = console,
259
262
  maxGlobalConcurrency = DEFAULT_GLOBAL_CONCURRENCY,
260
263
  maxProjectConcurrency = DEFAULT_PROJECT_CONCURRENCY,
261
264
  maxRunDurationMs = DEFAULT_MAX_RUN_MS,
262
265
  } = deps;
263
266
 
267
+ // Every OpenCode route lives under /api in v2 and the client appends it, so
268
+ // the client only wants the origin. Directory scoping is a request header.
269
+ const openCodeOrigin = () => new URL(buildOpenCodeUrl('/api/info', '')).origin;
270
+ const createScopedClient = (directory) => OpenCode.make({
271
+ baseUrl: openCodeOrigin(),
272
+ headers: {
273
+ ...getOpenCodeAuthHeaders(),
274
+ ...(directory ? { 'x-opencode-directory': encodeURIComponent(directory) } : {}),
275
+ },
276
+ fetch,
277
+ });
278
+
264
279
  let started = false;
265
280
  const tasksByProject = new Map();
266
281
  const projectPathByID = new Map();
@@ -461,61 +476,45 @@ export const createScheduledTasksRuntime = (deps) => {
461
476
  return projectRunning < maxProjectConcurrency;
462
477
  };
463
478
 
464
- const buildPromptAsyncPayload = (task, projectPath, knowledgeText = '') => ({
465
- model: {
466
- providerID: task.execution.providerID,
467
- modelID: task.execution.modelID,
468
- },
469
- ...(task.execution.agent ? { agent: task.execution.agent } : {}),
470
- ...(task.execution.variant ? { variant: task.execution.variant } : {}),
471
- parts: [
472
- // Standing project context first, so the prompt reads against it. A
473
- // scheduled run has no UI to attach this, which is why it is asked for
474
- // here rather than assembled by whoever is sending.
475
- ...(knowledgeText ? [{ type: 'text', text: knowledgeText, synthetic: true }] : []),
476
- {
477
- type: 'text',
478
- text: expandSnippets(task.execution.prompt, projectPath),
479
- },
480
- ...(task.execution.goalEnabled
481
- ? [{ type: 'text', text: buildGoalIntroText(task.execution.goalTokenBudget), synthetic: true }]
482
- : []),
483
- ],
484
- });
485
-
486
- const runPromptAsync = async ({ baseUrl, authHeaders, sessionID, projectPath, task }) => {
487
- // Never allowed to fail the run: a task that executes without its
488
- // background is a lesser loss than a task that does not execute.
489
- const knowledge = sessionKnowledgeRuntime
490
- ? await sessionKnowledgeRuntime.resolvePendingForSession(sessionID, projectPath)
491
- .catch(() => ({ text: '', signature: '' }))
492
- : { text: '', signature: '' };
493
-
494
- const promptUrl = new URL(`${baseUrl}/session/${encodeURIComponent(sessionID)}/prompt_async`);
495
- promptUrl.searchParams.set('directory', projectPath);
496
- const response = await fetch(promptUrl.toString(), {
497
- method: 'POST',
498
- headers: {
499
- ...authHeaders,
500
- 'content-type': 'application/json',
501
- accept: 'application/json',
502
- },
503
- body: JSON.stringify(buildPromptAsyncPayload(task, projectPath, knowledge.text)),
504
- });
505
-
506
- if (!response.ok) {
507
- const body = await response.text().catch(() => '');
508
- throw new Error(`prompt_async failed (${response.status})${body ? `: ${body}` : ''}`);
509
- }
479
+ // Never allowed to fail the run: a task that executes without its
480
+ // background is a lesser loss than a task that does not execute.
481
+ const resolveKnowledge = (sessionID, projectPath) => (sessionKnowledgeRuntime
482
+ ? sessionKnowledgeRuntime.resolvePendingForSession(sessionID, projectPath)
483
+ .catch(() => ({ text: '', signature: '' }))
484
+ : Promise.resolve({ text: '', signature: '' }));
510
485
 
511
- // Recorded only after the prompt is accepted, so a failed dispatch carries
512
- // the context again on the next run.
486
+ // Recorded only after the send is accepted, so a failed dispatch carries
487
+ // the context again on the next run.
488
+ const recordKnowledge = async (sessionID, projectPath, knowledge) => {
513
489
  if (knowledge.text && sessionKnowledgeRuntime) {
514
490
  await sessionKnowledgeRuntime.recordDelivered(sessionID, projectPath, knowledge.signature)
515
491
  .catch(() => undefined);
516
492
  }
517
493
  };
518
494
 
495
+ const runPrompt = async ({ client, sessionID, projectPath, task }) => {
496
+ const knowledge = await resolveKnowledge(sessionID, projectPath);
497
+
498
+ // A v2 prompt carries a single authored text. Standing project context and
499
+ // the goal briefing therefore travel as synthetic messages sent first, so
500
+ // the model still reads the prompt against them exactly as before. A
501
+ // synthetic message schedules execution unless `resume: false`: without
502
+ // it the model would start on the briefing alone, before the task arrived.
503
+ if (knowledge.text) {
504
+ await client.session.synthetic({ sessionID, text: knowledge.text, resume: false });
505
+ }
506
+ if (task.execution.goalEnabled) {
507
+ await client.session.synthetic({ sessionID, text: buildGoalIntroText(task.execution.goalTokenBudget), resume: false });
508
+ }
509
+
510
+ await client.session.prompt({
511
+ sessionID,
512
+ text: expandSnippets(task.execution.prompt, projectPath),
513
+ });
514
+
515
+ await recordKnowledge(sessionID, projectPath, knowledge);
516
+ };
517
+
519
518
  const resolveScheduledCommand = async ({ client, projectPath, task }) => {
520
519
  const parsed = parseScheduledCommandPrompt(task?.execution?.prompt);
521
520
  if (!parsed) {
@@ -524,27 +523,35 @@ export const createScheduledTasksRuntime = (deps) => {
524
523
 
525
524
  let commands = [];
526
525
  try {
527
- const response = await client.command.list({ directory: projectPath });
526
+ const response = await client.command.list({ location: { directory: projectPath } });
528
527
  commands = Array.isArray(response?.data) ? response.data : [];
529
528
  } catch {
530
529
  return null;
531
530
  }
532
531
 
532
+ // v2 CommandInfo carries no template, so a goal objective distilled from
533
+ // the command body is no longer available; the goal falls back to the
534
+ // prompt text, which expandCommandGoalObjective already handles.
533
535
  const command = commands.find((candidate) => candidate?.name === parsed.command);
534
536
  return command ? { ...parsed, template: command.template } : null;
535
537
  };
536
538
 
537
- const runScheduledCommand = async ({ client, projectPath, sessionID, task, command }) => {
539
+ const runScheduledCommand = async ({ client, sessionID, projectPath, command }) => {
540
+ // The command route takes no extra parts, so standing context goes in
541
+ // first as a synthetic message that does not start execution.
542
+ const knowledge = await resolveKnowledge(sessionID, projectPath);
543
+ if (knowledge.text) {
544
+ await client.session.synthetic({ sessionID, text: knowledge.text, resume: false });
545
+ }
546
+ // Agent, model and variant are session properties in v2 and were already
547
+ // set when the run created the session; the command body only carries text.
538
548
  await client.session.command({
539
549
  sessionID,
540
- directory: projectPath,
541
- command: command.command,
542
- arguments: command.arguments,
543
- ...(task.execution.agent ? { agent: task.execution.agent } : {}),
544
- model: `${task.execution.providerID}/${task.execution.modelID}`,
545
- ...(task.execution.variant ? { variant: task.execution.variant } : {}),
550
+ // OpenCode 2.0.8 renamed the command body field `command` to `name`.
551
+ name: command.command,
552
+ text: command.arguments,
546
553
  });
547
-
554
+ await recordKnowledge(sessionID, projectPath, knowledge);
548
555
  };
549
556
 
550
557
  const runTaskWithWatchdog = async (projectID, task, reason) => {
@@ -559,18 +566,23 @@ export const createScheduledTasksRuntime = (deps) => {
559
566
  await waitForOpenCodeReady(10_000, 250);
560
567
  }
561
568
 
562
- const baseUrl = buildOpenCodeUrl('/', '').replace(/\/$/, '');
569
+ const baseUrl = openCodeOrigin();
563
570
  const authHeaders = getOpenCodeAuthHeaders();
564
- const client = createOpencodeClient({
565
- baseUrl,
566
- headers: authHeaders,
567
- });
571
+ const client = createScopedClient(projectPath);
568
572
 
569
- const sessionResponse = await client.session.create({
570
- directory: projectPath,
573
+ // Agent, model and variant belong to the session in v2: a scheduled run
574
+ // fixes them here instead of repeating them on every prompt.
575
+ const session = await client.session.create({
571
576
  title,
577
+ location: { directory: projectPath },
578
+ model: {
579
+ providerID: task.execution.providerID,
580
+ id: task.execution.modelID,
581
+ ...(task.execution.variant ? { variant: task.execution.variant } : {}),
582
+ },
583
+ ...(task.execution.agent ? { agent: task.execution.agent } : {}),
572
584
  });
573
- const sessionID = sessionResponse?.data?.id;
585
+ const sessionID = session?.id;
574
586
  if (!sessionID) {
575
587
  throw new Error('failed to create session');
576
588
  }
@@ -606,6 +618,7 @@ export const createScheduledTasksRuntime = (deps) => {
606
618
  await createSessionGoal({
607
619
  baseUrl,
608
620
  authHeaders,
621
+ persistSessionGoal,
609
622
  sessionID,
610
623
  directory: projectPath,
611
624
  objective: commandObjective ?? expandSnippets(task.execution.prompt, projectPath),
@@ -617,15 +630,9 @@ export const createScheduledTasksRuntime = (deps) => {
617
630
  }
618
631
 
619
632
  if (scheduledCommand) {
620
- await runScheduledCommand({ client, projectPath, sessionID, task, command: scheduledCommand });
633
+ await runScheduledCommand({ client, sessionID, projectPath, command: scheduledCommand });
621
634
  } else {
622
- await runPromptAsync({
623
- baseUrl,
624
- authHeaders,
625
- sessionID,
626
- projectPath,
627
- task,
628
- });
635
+ await runPrompt({ client, sessionID, projectPath, task });
629
636
  }
630
637
 
631
638
  const finishedAt = Date.now();
@@ -1,4 +1,4 @@
1
- import { describe, expect, it, vi } from 'vitest';
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
2
  import os from 'os';
3
3
  import path from 'path';
4
4
  import { mkdtemp, rm, mkdir, writeFile } from 'fs/promises';
@@ -273,3 +273,55 @@ Run daily.
273
273
  }
274
274
  });
275
275
  });
276
+
277
+ describe('scheduled-tasks runtime prompt dispatch', () => {
278
+ afterEach(() => {
279
+ vi.unstubAllGlobals();
280
+ });
281
+
282
+ it('parks the briefing with resume: false so execution starts on the task prompt', async () => {
283
+ const posts = [];
284
+ vi.stubGlobal('fetch', vi.fn(async (input, init = {}) => {
285
+ const { pathname } = new URL(String(input));
286
+ if (init.method === 'POST') posts.push({ pathname, body: JSON.parse(init.body) });
287
+ const data = pathname === '/api/session' ? { id: 'ses_run' } : pathname === '/api/command' ? [] : {};
288
+ return new Response(JSON.stringify({ location: { directory: '/repo' }, data }), { status: 200, headers: { 'content-type': 'application/json' } });
289
+ }));
290
+ const task = {
291
+ id: 'task-1',
292
+ name: 'Nightly',
293
+ enabled: true,
294
+ schedule: { kind: 'daily', times: ['03:00'], timezone: 'UTC' },
295
+ execution: { prompt: 'Review open issues', providerID: 'openai', modelID: 'gpt-5', goalEnabled: true, goalTokenBudget: 50_000 },
296
+ state: { createdAt: 1, updatedAt: 1 },
297
+ };
298
+ const runtime = createScheduledTasksRuntime({
299
+ projectConfigRuntime: {
300
+ listScheduledTasks: async () => [task],
301
+ reconcileLoopTasks: async () => [task],
302
+ updateScheduledTaskState: async () => ({ task, updated: true }),
303
+ updateScheduledTaskStateIf: async () => ({ task, updated: true }),
304
+ },
305
+ listProjects: async () => [{ id: 'proj', path: '/repo' }],
306
+ buildOpenCodeUrl: () => 'http://127.0.0.1:1/',
307
+ getOpenCodeAuthHeaders: () => ({}),
308
+ waitForOpenCodeReady: async () => {},
309
+ persistSessionGoal: async () => undefined,
310
+ sessionKnowledgeRuntime: {
311
+ resolvePendingForSession: async () => ({ text: 'Project background', signature: 'sig' }),
312
+ recordDelivered: async () => undefined,
313
+ },
314
+ logger: { info: () => {}, warn: () => {}, error: () => {} },
315
+ });
316
+ await runtime.start();
317
+ await runtime.runNow('proj', 'task-1');
318
+ runtime.stop();
319
+
320
+ const dispatch = posts.filter((post) => post.pathname.startsWith('/api/session/ses_run/'));
321
+ expect(dispatch.map((post) => post.pathname.split('/').at(-1))).toEqual(['synthetic', 'synthetic', 'prompt']);
322
+ expect(dispatch[0].body).toMatchObject({ text: 'Project background', resume: false });
323
+ expect(dispatch[1].body.resume).toBe(false);
324
+ expect(dispatch[2].body).toMatchObject({ text: 'Review open issues' });
325
+ expect(dispatch[2].body.resume).toBeUndefined();
326
+ });
327
+ });
@@ -28,9 +28,14 @@ bringing an entire old task back into the prompt. This was compared against
28
28
  one, five, ten, and full-history contexts on long maintainer sessions. There
29
29
  is no full-history cache and no assumed provider prefix-cache behavior.
30
30
 
31
- The latest record must be a completed, successful, non-summary assistant answer
32
- with visible text. Child, archived, and reverted sessions are skipped. A new
33
- prompt clears the revert boundary before its next idle event.
31
+ The latest content record must be a completed, successful, non-summary
32
+ assistant answer with visible text. OpenCode closes every turn with an `idle`
33
+ record and appends agent/model/location switches as records of their own;
34
+ `newestContentId` looks past those, both here and in the re-check before the
35
+ write, so an ordinary v2 transcript still ends in its answer. An `idle` whose
36
+ outcome is `failed` or `interrupted` is not skipped: it disqualifies the turn.
37
+ Child, archived, and reverted sessions are skipped. A new prompt clears the
38
+ revert boundary before its next idle event.
34
39
 
35
40
  Human turns follow chronological message intervals. OpenCode can insert
36
41
  synthetic continuation users during compaction, so a final answer's `parentID`
@@ -116,13 +121,25 @@ before work and before writing. With both off there are no reads, model calls,
116
121
  or writes. With one on, the shared recent context is still available, but only
117
122
  that field is requested. An empty suggestion does not erase a valid recap.
118
123
 
119
- Clients render an assist only while its `forMessageID` is the last message and
120
- the session is idle. A new message invalidates it without clearing writes.
121
-
122
- - `packages/ui/src/lib/sessionAssistMetadata.ts` parses the payload.
123
- - `packages/ui/src/hooks/useSessionAssist.ts` owns freshness/settings gating.
124
+ Freshness has one rule, `getCurrentSessionAssist` in
125
+ `packages/ui/src/lib/sessionAssistMetadata.ts`, computed from the session
126
+ record alone so the chat and the sidebar row always agree: the payload is
127
+ current while `generatedAt >= session.time.idle` and the session is not
128
+ reverted. OpenCode moves `time.idle` at every turn end, succeeded or failed.
129
+ Do not compare `forMessageID` with the last loaded message: in v2 the newest
130
+ record is the turn's `idle` marker or a switch record, never the answer.
131
+ When a session turns busy, the runtime also deletes the assist it wrote
132
+ (`persistSessionAssist(id, dir, null)`), so stored state goes stale only for
133
+ payloads written by an earlier process; the `time.idle` rule retires those.
134
+
135
+ - `packages/ui/src/lib/sessionAssistMetadata.ts` parses the payload and owns freshness.
136
+ - `packages/ui/src/hooks/useSessionAssist.ts` adds live-status and settings gating.
124
137
  - `SessionRecapSpacer` shows the reminder in the reserved gap under the reply.
125
138
  - `SessionSuggestionChip` fills the composer; it never sends automatically.
139
+ - Sidebar rows (`SessionNodeItem`, both Projects and Timeline) mark a session
140
+ whose suggestion is still open with a small icon and the suggestion as its
141
+ title, using the same freshness rule (`getOpenSessionSuggestion`). The marker hides while a turn runs, on the open session, and
142
+ when `sessionSuggestionEnabled` is off.
126
143
 
127
144
  Web, Electron, hosted mobile, and Capacitor use the server watcher. VS Code's
128
145
  extension-only runtime does not generate assists; shared UI can render payloads