rovecode 0.4.0-beta.3 → 0.4.0

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 (432) hide show
  1. package/README.md +57 -72
  2. package/THIRD_PARTY_NOTICES.md +0 -44
  3. package/bin/rovecode.ts +21 -0
  4. package/package.json +16 -38
  5. package/src/account/keys.ts +97 -0
  6. package/src/account/login.ts +158 -0
  7. package/src/account/provision.ts +47 -0
  8. package/src/account/store.ts +63 -0
  9. package/src/acp/server.ts +373 -0
  10. package/src/cli/account-cmd.ts +116 -0
  11. package/src/cli/connect.ts +244 -0
  12. package/src/cli/context-cmd.ts +199 -0
  13. package/src/cli/dispatch.ts +109 -0
  14. package/src/cli/doctor.ts +324 -0
  15. package/src/cli/export.ts +278 -0
  16. package/src/cli/help.ts +240 -0
  17. package/src/cli/is-tui-invocation.ts +8 -0
  18. package/src/cli/main.ts +599 -0
  19. package/src/cli/market-cmd.ts +658 -0
  20. package/src/cli/mcp-market-cmd.ts +299 -0
  21. package/src/cli/output.ts +382 -0
  22. package/src/cli/repl.ts +172 -0
  23. package/src/cli/resume.ts +32 -0
  24. package/src/cli/run-limits.ts +78 -0
  25. package/src/cli/runtime.ts +792 -0
  26. package/src/cli/setup.ts +187 -0
  27. package/src/cli/update-cmd.ts +78 -0
  28. package/src/cli/workflow-cmd.ts +100 -0
  29. package/src/coding/checkpoints.ts +270 -0
  30. package/src/coding/diff.ts +136 -0
  31. package/src/coding/files.ts +339 -0
  32. package/src/coding/hashline.ts +319 -0
  33. package/src/coding/lsp.ts +406 -0
  34. package/src/coding/repomap-cache.ts +99 -0
  35. package/src/coding/repomap-files.ts +110 -0
  36. package/src/coding/repomap.ts +392 -0
  37. package/src/core/compaction.ts +399 -0
  38. package/src/core/config.ts +289 -0
  39. package/src/core/context-report.ts +228 -0
  40. package/src/core/context.ts +60 -0
  41. package/src/core/count-remote.ts +107 -0
  42. package/src/core/execpolicy-rules.ts +196 -0
  43. package/src/core/execpolicy.ts +385 -0
  44. package/src/core/executor.ts +397 -0
  45. package/src/core/guardrails.ts +400 -0
  46. package/src/core/hooks.ts +398 -0
  47. package/src/core/images.ts +230 -0
  48. package/src/core/intro.ts +236 -0
  49. package/src/core/loop.ts +621 -0
  50. package/src/core/modes.ts +372 -0
  51. package/src/core/orchestrator.ts +207 -0
  52. package/src/core/reflection.ts +165 -0
  53. package/src/core/sandbox-config.ts +167 -0
  54. package/src/core/session-images.ts +73 -0
  55. package/src/core/session.ts +398 -0
  56. package/src/core/settings.ts +98 -0
  57. package/src/core/stuck-detector.ts +273 -0
  58. package/src/core/tasks.ts +374 -0
  59. package/src/core/token-scale.ts +108 -0
  60. package/src/core/tool-output-budget.ts +166 -0
  61. package/src/core/tools.ts +288 -0
  62. package/src/core/types.ts +330 -0
  63. package/src/core/update-check.ts +171 -0
  64. package/src/core/update.ts +158 -0
  65. package/src/core/usage.ts +204 -0
  66. package/src/core/validate.ts +121 -0
  67. package/src/core/verify-gate.ts +159 -0
  68. package/src/core/verify.ts +237 -0
  69. package/src/core/voice.ts +158 -0
  70. package/src/core/win-job.ts +183 -0
  71. package/src/design/audit.ts +797 -0
  72. package/src/design/direction.ts +190 -0
  73. package/src/design/rules.ts +157 -0
  74. package/src/eval/bench.ts +150 -0
  75. package/src/eval/gauntlet-runner.ts +218 -0
  76. package/src/eval/gauntlet.ts +226 -0
  77. package/src/eval/grader.ts +186 -0
  78. package/src/eval/record.ts +202 -0
  79. package/src/eval/redact.ts +141 -0
  80. package/src/eval/replay.ts +147 -0
  81. package/src/eval/trajectory.ts +373 -0
  82. package/src/index.ts +17 -0
  83. package/src/market/catalogs/mcp-docs.json +111 -0
  84. package/src/market/catalogs/plugins.json +111 -0
  85. package/src/market/catalogs/skills.json +478 -0
  86. package/src/market/clone.ts +72 -0
  87. package/src/market/context-cost.ts +121 -0
  88. package/src/market/digest.ts +106 -0
  89. package/src/market/index.ts +22 -0
  90. package/src/market/install.ts +578 -0
  91. package/src/market/manifest.ts +187 -0
  92. package/src/market/prereq.ts +145 -0
  93. package/src/market/registry.ts +363 -0
  94. package/src/market/resolve.ts +111 -0
  95. package/src/market/types.ts +236 -0
  96. package/src/market/validate.ts +227 -0
  97. package/src/mcp/client.ts +431 -0
  98. package/src/mcp/config.ts +239 -0
  99. package/src/mcp/local-package.ts +211 -0
  100. package/src/mcp/market-catalog.ts +84 -0
  101. package/src/mcp/market-install.ts +289 -0
  102. package/src/mcp/market.ts +0 -0
  103. package/src/mcp/tools.ts +131 -0
  104. package/src/mcp/trust.ts +49 -0
  105. package/src/memory/blocks.ts +175 -0
  106. package/src/memory/recall.ts +355 -0
  107. package/src/memory/store.ts +105 -0
  108. package/src/memory/tools.ts +99 -0
  109. package/src/plugins/cli.ts +123 -0
  110. package/src/plugins/discover.ts +108 -0
  111. package/src/plugins/index.ts +50 -0
  112. package/src/plugins/init.ts +140 -0
  113. package/src/plugins/install.ts +184 -0
  114. package/src/plugins/load.ts +149 -0
  115. package/src/plugins/manifest.ts +106 -0
  116. package/src/plugins/state.ts +83 -0
  117. package/src/providers/auth.ts +293 -0
  118. package/src/providers/cache.ts +223 -0
  119. package/src/providers/catalog-local.ts +160 -0
  120. package/src/providers/catalog.ts +408 -0
  121. package/src/providers/middleware-context.ts +86 -0
  122. package/src/providers/middleware.ts +373 -0
  123. package/src/providers/profile-glm53.ts +111 -0
  124. package/src/providers/profile-sonnet5-persona.ts +65 -0
  125. package/src/providers/profile-sonnet5-voice.ts +23 -0
  126. package/src/providers/profiles.ts +156 -0
  127. package/src/providers/provider-config.ts +311 -0
  128. package/src/providers/registry.ts +302 -0
  129. package/src/providers/response-validation.ts +80 -0
  130. package/src/providers/retry.ts +234 -0
  131. package/src/providers/router.ts +294 -0
  132. package/src/providers/sse.ts +26 -0
  133. package/src/providers/stream-errors.ts +117 -0
  134. package/src/providers/stream.ts +569 -0
  135. package/src/providers/thinking.ts +189 -0
  136. package/src/providers/wire-messages.ts +129 -0
  137. package/src/sdk/client.ts +225 -0
  138. package/src/sdk/index.ts +3 -0
  139. package/src/server/dashboard.ts +144 -0
  140. package/src/server/http.ts +343 -0
  141. package/src/server/openapi.ts +246 -0
  142. package/src/sextant/card-hits.ts +102 -0
  143. package/src/sextant/card-keys.ts +55 -0
  144. package/src/sextant/context-source.ts +157 -0
  145. package/src/sextant/draw-agents.ts +273 -0
  146. package/src/sextant/draw-code.ts +388 -0
  147. package/src/sextant/draw-context.ts +222 -0
  148. package/src/sextant/draw-frame.ts +164 -0
  149. package/src/sextant/draw-market.ts +573 -0
  150. package/src/sextant/draw-messages.ts +386 -0
  151. package/src/sextant/draw-pet.ts +230 -0
  152. package/src/sextant/draw-plan.ts +159 -0
  153. package/src/sextant/draw-tabs.ts +85 -0
  154. package/src/sextant/draw-util.ts +65 -0
  155. package/src/sextant/engine.ts +230 -0
  156. package/src/sextant/frame-hits.ts +25 -0
  157. package/src/sextant/frame.ts +101 -0
  158. package/src/sextant/git-status.ts +197 -0
  159. package/src/sextant/grid.ts +59 -0
  160. package/src/sextant/input.ts +119 -0
  161. package/src/sextant/keys.ts +488 -0
  162. package/src/sextant/layout.ts +86 -0
  163. package/src/sextant/local-commands.ts +156 -0
  164. package/src/sextant/market-source.ts +287 -0
  165. package/src/sextant/mentions.ts +141 -0
  166. package/src/sextant/message-hits.ts +26 -0
  167. package/src/sextant/model.ts +387 -0
  168. package/src/sextant/overlays.ts +451 -0
  169. package/src/sextant/panel-hits.ts +38 -0
  170. package/src/sextant/pet.ts +399 -0
  171. package/src/sextant/screen.ts +324 -0
  172. package/src/sextant/scroll-hits.ts +66 -0
  173. package/src/sextant/scrollbar.ts +82 -0
  174. package/src/sextant/selection.ts +123 -0
  175. package/src/sextant/sextant-bridge.ts +174 -0
  176. package/src/sextant/sextant-cards.ts +142 -0
  177. package/src/sextant/sextant-diff-base.ts +63 -0
  178. package/src/sextant/sextant-files.ts +154 -0
  179. package/src/sextant/sextant-frame-loop.ts +314 -0
  180. package/src/sextant/sextant-renderer.ts +478 -0
  181. package/src/sextant/sextant-repo.ts +131 -0
  182. package/src/sextant/theme.ts +66 -0
  183. package/src/sextant/tool-rows.ts +189 -0
  184. package/src/sextant/types.ts +473 -0
  185. package/src/skills/index.ts +306 -0
  186. package/src/skills/tools.ts +69 -0
  187. package/src/skills/versioned.ts +227 -0
  188. package/src/telemetry/otel.ts +353 -0
  189. package/src/telemetry/otlp.ts +68 -0
  190. package/src/tools/ask-user.ts +156 -0
  191. package/src/tools/design.ts +151 -0
  192. package/src/tools/evalcell.ts +338 -0
  193. package/src/tools/html-text.ts +139 -0
  194. package/src/tools/provider.ts +149 -0
  195. package/src/tools/task.ts +216 -0
  196. package/src/tools/todo.ts +320 -0
  197. package/src/tools/webfetch.ts +331 -0
  198. package/src/tui/app.ts +608 -0
  199. package/src/tui/attach.ts +127 -0
  200. package/src/tui/checkpoints-cmd.ts +70 -0
  201. package/src/tui/clipboard-image.ts +81 -0
  202. package/src/tui/commands.ts +277 -0
  203. package/src/tui/cost.ts +108 -0
  204. package/src/tui/info-cmd.ts +144 -0
  205. package/src/tui/mcp-cmd.ts +128 -0
  206. package/src/tui/modes-cmd.ts +45 -0
  207. package/src/tui/overlays.ts +97 -0
  208. package/src/tui/pi-renderer.ts +424 -0
  209. package/src/tui/providers-cmd.ts +366 -0
  210. package/src/tui/renderer.ts +101 -0
  211. package/src/tui/replay-marker.ts +29 -0
  212. package/src/tui/session-cmd.ts +146 -0
  213. package/src/tui/sextant-attach.ts +68 -0
  214. package/src/tui/sextant-io.ts +184 -0
  215. package/src/tui/sextant-smoke.ts +110 -0
  216. package/src/tui/smoke.ts +72 -0
  217. package/src/tui/theme.ts +59 -0
  218. package/src/tui/todo-label.ts +7 -0
  219. package/src/workflow/engine.ts +266 -0
  220. package/tsconfig.json +30 -0
  221. package/vendor/pi-tui/LICENSE +21 -0
  222. package/vendor/pi-tui/PATCHES.md +12 -0
  223. package/vendor/pi-tui/PROVENANCE.md +12 -0
  224. package/vendor/pi-tui/README.upstream.md +854 -0
  225. package/vendor/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  226. package/vendor/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  227. package/vendor/pi-tui/src/alt-screen-search.ts +158 -0
  228. package/vendor/pi-tui/src/autocomplete.ts +827 -0
  229. package/vendor/pi-tui/src/components/alt-screen-flash.ts +52 -0
  230. package/vendor/pi-tui/src/components/box.ts +138 -0
  231. package/vendor/pi-tui/src/components/cancellable-loader.ts +41 -0
  232. package/vendor/pi-tui/src/components/editor.ts +2364 -0
  233. package/vendor/pi-tui/src/components/h-stack.ts +45 -0
  234. package/vendor/pi-tui/src/components/image.ts +128 -0
  235. package/vendor/pi-tui/src/components/input.ts +448 -0
  236. package/vendor/pi-tui/src/components/loader.ts +93 -0
  237. package/vendor/pi-tui/src/components/markdown.ts +1016 -0
  238. package/vendor/pi-tui/src/components/scroll-view.ts +217 -0
  239. package/vendor/pi-tui/src/components/select-list.ts +230 -0
  240. package/vendor/pi-tui/src/components/settings-list.ts +277 -0
  241. package/vendor/pi-tui/src/components/spacer.ts +29 -0
  242. package/vendor/pi-tui/src/components/stack.ts +155 -0
  243. package/vendor/pi-tui/src/components/text.ts +108 -0
  244. package/vendor/pi-tui/src/components/truncated-text.ts +66 -0
  245. package/vendor/pi-tui/src/components/v-stack.ts +34 -0
  246. package/vendor/pi-tui/src/editor-component.ts +75 -0
  247. package/vendor/pi-tui/src/fuzzy.ts +138 -0
  248. package/vendor/pi-tui/src/index.ts +149 -0
  249. package/vendor/pi-tui/src/keybindings.ts +321 -0
  250. package/vendor/pi-tui/src/keys.ts +1402 -0
  251. package/vendor/pi-tui/src/kill-ring.ts +47 -0
  252. package/vendor/pi-tui/src/latex.ts +1381 -0
  253. package/vendor/pi-tui/src/layout-node.ts +52 -0
  254. package/vendor/pi-tui/src/layout.ts +411 -0
  255. package/vendor/pi-tui/src/native-modifiers.ts +60 -0
  256. package/vendor/pi-tui/src/native-module-path.ts +32 -0
  257. package/vendor/pi-tui/src/stdin-buffer.ts +445 -0
  258. package/vendor/pi-tui/src/terminal-colors.ts +74 -0
  259. package/vendor/pi-tui/src/terminal-image.ts +701 -0
  260. package/vendor/pi-tui/src/terminal.ts +554 -0
  261. package/vendor/pi-tui/src/tui-alt-screen.ts +1379 -0
  262. package/vendor/pi-tui/src/tui-main-screen.ts +655 -0
  263. package/vendor/pi-tui/src/tui.ts +1264 -0
  264. package/vendor/pi-tui/src/undo-stack.ts +29 -0
  265. package/vendor/pi-tui/src/utils.ts +1327 -0
  266. package/vendor/pi-tui/src/word-navigation.ts +118 -0
  267. package/vendor/pi-tui/test/test-themes.ts +39 -0
  268. package/vendor/pi-tui/test/virtual-terminal.ts +219 -0
  269. package/CHANGELOG.md +0 -527
  270. package/bin/rovecode.js +0 -24
  271. package/dist/cli/app-j6gn14w3.js +0 -2
  272. package/dist/cli/ask-user-cwstt8fz.js +0 -2
  273. package/dist/cli/auth-login-9bbp9915.js +0 -2
  274. package/dist/cli/auth-m8p9grty.js +0 -2
  275. package/dist/cli/bench-16zqdms5.js +0 -9
  276. package/dist/cli/catalog-1xchffa4.js +0 -2
  277. package/dist/cli/cli-1n1zb64f.js +0 -2
  278. package/dist/cli/client-2t9gjkck.js +0 -2
  279. package/dist/cli/commands-exafvm2b.js +0 -2
  280. package/dist/cli/connect-6zde0kn3.js +0 -2
  281. package/dist/cli/context-cmd-5t43wgqt.js +0 -2
  282. package/dist/cli/context-report-kt01pw8y.js +0 -2
  283. package/dist/cli/count-remote-ap7x3vh6.js +0 -2
  284. package/dist/cli/design-ne5zszyh.js +0 -2
  285. package/dist/cli/dispatch-2r5myxye.js +0 -2
  286. package/dist/cli/doctor-ws4fh4tn.js +0 -3
  287. package/dist/cli/executor-bdrjn634.js +0 -2
  288. package/dist/cli/export-1mxb9g5p.js +0 -2
  289. package/dist/cli/files-g104xghh.js +0 -2
  290. package/dist/cli/gauntlet-07xrjpj7.js +0 -2
  291. package/dist/cli/gauntlet-runner-xvy64436.js +0 -10
  292. package/dist/cli/gauntlet-wave3-jm91yt5w.js +0 -5
  293. package/dist/cli/gauntlet-wave4-r13py7p1.js +0 -14
  294. package/dist/cli/hashline-znvrat11.js +0 -2
  295. package/dist/cli/http-xafw6fsh.js +0 -143
  296. package/dist/cli/index-1sgjm25y.js +0 -2
  297. package/dist/cli/init-g2m0tn4m.js +0 -51
  298. package/dist/cli/install-avaqjjqq.js +0 -2
  299. package/dist/cli/loop-mmpfft01.js +0 -2
  300. package/dist/cli/main-0904f6ps.js +0 -5
  301. package/dist/cli/main-0ab9fc26.js +0 -9
  302. package/dist/cli/main-0jys2ccn.js +0 -3
  303. package/dist/cli/main-0mtcdbs7.js +0 -3
  304. package/dist/cli/main-0z1w2zsg.js +0 -3
  305. package/dist/cli/main-1dchs7xv.js +0 -18
  306. package/dist/cli/main-1ereejm1.js +0 -3
  307. package/dist/cli/main-1k1kw6b5.js +0 -3
  308. package/dist/cli/main-27y4sm2k.js +0 -38
  309. package/dist/cli/main-2wwjex5j.js +0 -58
  310. package/dist/cli/main-2yeveeve.js +0 -6
  311. package/dist/cli/main-2yfck9b5.js +0 -3
  312. package/dist/cli/main-2zmzgkwh.js +0 -3
  313. package/dist/cli/main-351pz3z7.js +0 -7
  314. package/dist/cli/main-3gjqfh7a.js +0 -6
  315. package/dist/cli/main-3nf3kgve.js +0 -3
  316. package/dist/cli/main-3pjrb2hd.js +0 -3
  317. package/dist/cli/main-3rxcvgna.js +0 -19
  318. package/dist/cli/main-4b3jgy66.js +0 -19
  319. package/dist/cli/main-4wndhjdc.js +0 -7
  320. package/dist/cli/main-4xcmvxnk.js +0 -3
  321. package/dist/cli/main-5tbz0wbz.js +0 -4
  322. package/dist/cli/main-5ywnwthm.js +0 -3
  323. package/dist/cli/main-6b62vkz0.js +0 -14
  324. package/dist/cli/main-6dnk69vp.js +0 -3
  325. package/dist/cli/main-6genrmhs.js +0 -136
  326. package/dist/cli/main-73g7eff4.js +0 -15
  327. package/dist/cli/main-7c5thhjd.js +0 -5
  328. package/dist/cli/main-7rn6bqje.js +0 -3
  329. package/dist/cli/main-80haw7qk.js +0 -4
  330. package/dist/cli/main-875s60s2.js +0 -4
  331. package/dist/cli/main-8kjxbpw4.js +0 -8
  332. package/dist/cli/main-90ds1z4e.js +0 -10
  333. package/dist/cli/main-9etavkew.js +0 -3
  334. package/dist/cli/main-a9njrkk1.js +0 -3
  335. package/dist/cli/main-aecrjq2d.js +0 -12
  336. package/dist/cli/main-ck9asesq.js +0 -9
  337. package/dist/cli/main-cta9racd.js +0 -4
  338. package/dist/cli/main-ddv7j2ag.js +0 -3
  339. package/dist/cli/main-dfreez27.js +0 -10
  340. package/dist/cli/main-f7rw7des.js +0 -3
  341. package/dist/cli/main-ggcn7rd7.js +0 -5
  342. package/dist/cli/main-gzkmycnv.js +0 -3
  343. package/dist/cli/main-hq51jg8v.js +0 -18
  344. package/dist/cli/main-jft389w9.js +0 -8
  345. package/dist/cli/main-k1eqkg83.js +0 -3
  346. package/dist/cli/main-k2y8a2aw.js +0 -9
  347. package/dist/cli/main-kcpbykxz.js +0 -4
  348. package/dist/cli/main-kd488vje.js +0 -22
  349. package/dist/cli/main-kh32yvgk.js +0 -5
  350. package/dist/cli/main-kqxnqjnv.js +0 -25
  351. package/dist/cli/main-kyn0xnsg.js +0 -3
  352. package/dist/cli/main-m1kk6fp5.js +0 -21
  353. package/dist/cli/main-mv40pcr2.js +0 -4
  354. package/dist/cli/main-n0t3973w.js +0 -3
  355. package/dist/cli/main-nqveez48.js +0 -4
  356. package/dist/cli/main-pknhvrmj.js +0 -3
  357. package/dist/cli/main-pn1w7a7j.js +0 -3
  358. package/dist/cli/main-prxxs70n.js +0 -4
  359. package/dist/cli/main-q3vsesf9.js +0 -3
  360. package/dist/cli/main-qsevpgsv.js +0 -3
  361. package/dist/cli/main-rdgdw24b.js +0 -25
  362. package/dist/cli/main-rfth4tbm.js +0 -16
  363. package/dist/cli/main-rg0wn0xf.js +0 -5
  364. package/dist/cli/main-sdmxhtv8.js +0 -4
  365. package/dist/cli/main-skbp13js.js +0 -18
  366. package/dist/cli/main-t4xnd213.js +0 -7
  367. package/dist/cli/main-vqak588n.js +0 -4
  368. package/dist/cli/main-w2n1303f.js +0 -9
  369. package/dist/cli/main-wbrdspr2.js +0 -5
  370. package/dist/cli/main-wsrg79c1.js +0 -7
  371. package/dist/cli/main-x4r0fne4.js +0 -5
  372. package/dist/cli/main-xea2f3tn.js +0 -6
  373. package/dist/cli/main-xg704a3c.js +0 -3
  374. package/dist/cli/main-xvnrabfp.js +0 -16
  375. package/dist/cli/main-xy53xf0r.js +0 -4
  376. package/dist/cli/main-y1fqy60y.js +0 -3
  377. package/dist/cli/main-yn8cd281.js +0 -34
  378. package/dist/cli/main-yr0ksc0h.js +0 -4
  379. package/dist/cli/main-z2ex2vyf.js +0 -4
  380. package/dist/cli/main-z3aayzvq.js +0 -3
  381. package/dist/cli/main-zaqh35jg.js +0 -3
  382. package/dist/cli/main-zc2e8e46.js +0 -4
  383. package/dist/cli/main-zzrfw6cf.js +0 -13
  384. package/dist/cli/main.js +0 -280
  385. package/dist/cli/market-cmd-e14kmx9n.js +0 -5
  386. package/dist/cli/mcp-login-wq7ktdek.js +0 -2
  387. package/dist/cli/mcp-market-cmd-9mg3jecy.js +0 -2
  388. package/dist/cli/notify-b7qc0cjb.js +0 -2
  389. package/dist/cli/oauth-z8whcgfx.js +0 -2
  390. package/dist/cli/output-b3ewj3ps.js +0 -16
  391. package/dist/cli/profiles-6mr5he5e.js +0 -2
  392. package/dist/cli/provider-config-g7j42q8x.js +0 -2
  393. package/dist/cli/provider-jr1y8vvm.js +0 -2
  394. package/dist/cli/registry-s8yk86g0.js +0 -2
  395. package/dist/cli/registry-t6p8d4mn.js +0 -2
  396. package/dist/cli/repl-bajwe1mh.js +0 -11
  397. package/dist/cli/resume-rwn9nz7y.js +0 -2
  398. package/dist/cli/run-flags-nah7ndpt.js +0 -2
  399. package/dist/cli/runtime-n7gafzhb.js +0 -2
  400. package/dist/cli/sandbox-config-emdy18x4.js +0 -2
  401. package/dist/cli/server-b0nvs2bn.js +0 -5
  402. package/dist/cli/session-arg-y75wd4kj.js +0 -2
  403. package/dist/cli/session-j62evmjq.js +0 -2
  404. package/dist/cli/sessions-cmd-tsnwz0ns.js +0 -7
  405. package/dist/cli/settings-df10wfez.js +0 -2
  406. package/dist/cli/setup-jzvv72fg.js +0 -2
  407. package/dist/cli/sextant-smoke-37m81ke6.js +0 -5
  408. package/dist/cli/skills-cmd-gjxnxnhx.js +0 -2
  409. package/dist/cli/smoke-p7748apt.js +0 -8
  410. package/dist/cli/start-chat-s4st3mm0.js +0 -12
  411. package/dist/cli/stream-gmeyewds.js +0 -2
  412. package/dist/cli/task-gh0kkp3n.js +0 -2
  413. package/dist/cli/tasks-z1kfpe8e.js +0 -2
  414. package/dist/cli/thinking-0eqkrz6t.js +0 -2
  415. package/dist/cli/todo-5brcrt9m.js +0 -2
  416. package/dist/cli/tools-7pzm0vj9.js +0 -2
  417. package/dist/cli/tools-s635p6s8.js +0 -2
  418. package/dist/cli/trust-cmd-cjav8zgm.js +0 -2
  419. package/dist/cli/update-check-pt31bm2f.js +0 -2
  420. package/dist/cli/update-cmd-tk131s9t.js +0 -2
  421. package/dist/cli/voice-56nabd8d.js +0 -2
  422. package/dist/cli/webfetch-xd8q596m.js +0 -2
  423. package/dist/cli/websearch-5hkf98k1.js +0 -2
  424. package/dist/cli/workflow-cmd-cy3cvzjp.js +0 -4
  425. package/dist/cli/workspace-q10g5z3e.js +0 -2
  426. package/dist/lib/index.js +0 -62
  427. package/dist/lib/models-index.json +0 -1
  428. package/dist/lib/plugins.js +0 -55
  429. package/dist/lib/providers.js +0 -17
  430. package/dist/lib/public-api.js +0 -20
  431. package/dist/lib/sdk.js +0 -360
  432. /package/{dist/cli → src/providers}/models-index.json +0 -0
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{dh as b,eh as U,hh as M,ih as N,jh as C,kh as w,lh as m,mh as R}from"./main-rg0wn0xf.js";import{Am as V,Em as P,Fm as z,xm as S,zm as x}from"./main-7rn6bqje.js";import{vn as p,wn as _,xn as j}from"./main-qsevpgsv.js";function Y(){return L??=Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/stdio.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js"),import("@modelcontextprotocol/sdk/client/sse.js"),import("@modelcontextprotocol/sdk/client/auth.js"),import("@modelcontextprotocol/sdk/types.js")]).then(([q,D,F,H,I,J])=>{return K={Client:q.Client,StdioClientTransport:D.StdioClientTransport,getDefaultEnvironment:D.getDefaultEnvironment,StreamableHTTPClientTransport:F.StreamableHTTPClientTransport,StreamableHTTPError:F.StreamableHTTPError,SSEClientTransport:H.SSEClientTransport,SseError:H.SseError,UnauthorizedError:I.UnauthorizedError,ToolListChangedNotificationSchema:J.ToolListChangedNotificationSchema,PromptListChangedNotificationSchema:J.PromptListChangedNotificationSchema,ResourceListChangedNotificationSchema:J.ResourceListChangedNotificationSchema},K}),L}function E(q){let D=K;return D!==null&&q instanceof D.StreamableHTTPError&&(q.code===404||q.code===405)}function y(q){let D=K;if(D!==null&&(q instanceof D.StreamableHTTPError||q instanceof D.SseError))return q.code===401;return q instanceof Error&&/\(HTTP 401\)/.test(q.message)}function B(q,D){if(q instanceof N)return q.message;let F=K;if(F!==null&&q instanceof F.UnauthorizedError||y(q))return C(D)?"HTTP 401 \u2014 the configured Authorization header was rejected":M(D.name);let H=V(q);return F!==null&&q instanceof F.StreamableHTTPError&&typeof q.code==="number"&&q.code>0&&!H.includes(String(q.code))?`${H} (HTTP ${q.code})`:H}async function O(q,D,F){let H=await Y();if(D==="http"||D==="sse"){if(q.url===void 0)throw Error(`${D} server "${q.name}" has no url`);let I={...q.headers?{requestInit:{headers:q.headers}}:{},...F?{authProvider:F}:{}},J=new URL(q.url);return D==="http"?new H.StreamableHTTPClientTransport(J,I):new H.SSEClientTransport(J,I)}if(q.command===void 0)throw Error(`stdio server "${q.name}" has no command`);return new H.StdioClientTransport({command:q.command,args:q.args??[],env:{...H.getDefaultEnvironment(),...q.env??{}},stderr:"ignore"})}var L=null,K=null;var T=_(()=>{z();R()});var l={};p(l,{runnerTimeoutMessage:()=>k,mcpConfigPath:()=>S,loadMcpConfig:()=>P,isPackageRunner:()=>A,RUNNER_CONNECT_MS:()=>h,McpManager:()=>u});function A(q){if(q.transport!=="stdio"||q.command===void 0)return!1;let D=q.command.split(/[\\/]/).pop()??q.command;return f.has(D.toLowerCase())}function k(q,D){let F=`connect to MCP server "${q.name}" timed out after ${Math.round(D/1000)}s`;if(!A(q))return F;let H=(q.command??"the runner").split(/[\\/]/).pop();return`${F} \u2014 ${H} downloads the server's package on first use. Try again (the download is cached), or install it once so it starts without the network: rovecode mcp add ${q.name} --local --force`}class u{servers=new Map;toolCache=new Map;toolGen=new Map;listeners=new Set;ttl;connectTimeout;callTimeout;transportFactory;authProvider;constructor(q,D={}){this.ttl=D.toolTtlMs??60000,this.connectTimeout=D.connectTimeoutMs??1e4,this.callTimeout=D.callTimeoutMs??120000,this.transportFactory=D.transportFactory,this.authProvider=D.authProvider??d;for(let F of q)if(!this.servers.has(F.name))this.servers.set(F.name,{config:F,client:null,attempted:!1})}serverNames(){return[...this.servers.keys()]}connectedNames(){return[...this.servers.values()].filter((q)=>q.client!==null).map((q)=>q.config.name)}get ttlMs(){return this.ttl}get requestTimeoutMs(){return this.connectTimeout}clientOf(q){let D=this.servers.get(q);if(!D)throw Error(`unknown MCP server "${q}"`);if(!D.client)throw Error(`MCP server "${q}" is not connected${D.lastError?` (${D.lastError})`:""}`);return D.client}connection(q){let D=this.clientOf(q);return{client:D,caps:D.getServerCapabilities()??{}}}onListChanged(q){return this.listeners.add(q),()=>{this.listeners.delete(q)}}invalidate(q,D){if(D==="tools")this.toolCache.delete(q),this.toolGen.set(q,(this.toolGen.get(q)??0)+1);for(let F of this.listeners)try{F(q,D)}catch{}}async connect(){let q=[],D=[...this.servers.values()].filter((H)=>H.config.enabled!==!1&&H.client===null),F=[];for(let H of D){if(F.length>0&&H.connecting===void 0)await v();H.connecting??=this.open(H).finally(()=>{H.connecting=void 0}),F.push(H.connecting.catch((I)=>{q.push({name:H.config.name,error:B(I,H.config)})}))}return await Promise.all(F),{connected:this.connectedNames(),failed:q}}async open(q){let{config:D}=q;q.attempted=!0;try{let F=this.transportFactory?await this.transportFactory(D):void 0,H=F?"custom":D.transport,I=!1,J;try{J=await this.handshake(D,F??await O(D,D.transport,await this.authProvider(D)))}catch(X){if(F!==void 0||D.transport!=="http"||!E(X))throw X;J=await this.handshake(D,await O(D,"sse",await this.authProvider(D))),H="sse",I=!0}await this.armNotifications(D.name,J),q.client=J,q.wire=H,q.fellBack=I,delete q.lastError}catch(F){throw q.lastError=B(F,D),F}}async handshake(q,D){let F=new(await Y()).Client({name:"rovecode",version:"0.1.0"}),H=A(q)?Math.max(this.connectTimeout,h):this.connectTimeout;try{await w(F.connect(D,{timeout:H}),H+2000,k(q,H))}catch(I){throw await F.close().catch(()=>{}),I}return F}async armNotifications(q,D){let F=await Y();D.setNotificationHandler(F.ToolListChangedNotificationSchema,()=>this.invalidate(q,"tools")),D.setNotificationHandler(F.PromptListChangedNotificationSchema,()=>this.invalidate(q,"prompts")),D.setNotificationHandler(F.ResourceListChangedNotificationSchema,()=>this.invalidate(q,"resources"))}async fetchTools(q,D=!1,F){let H=this.clientOf(q),I=this.toolCache.get(q),J=Date.now();if(!D&&I&&J-I.at<this.ttl)return I.tools;let X=this.toolGen.get(q)??0,$=await m("tool",q,async(G)=>{let Q=U(F),Z;try{Z=await H.listTools(G===void 0?void 0:{cursor:G},{timeout:this.connectTimeout,signal:Q.signal})}finally{Q.dispose()}return{items:Z.tools.map((W)=>({name:W.name,description:typeof W.description==="string"?W.description:"",inputSchema:W.inputSchema})),nextCursor:Z.nextCursor}},F);if((this.toolGen.get(q)??0)===X)this.toolCache.set(q,{at:J,tools:$});return $}async listTools(q=!1,D){let F=[];for(let[H,I]of this.servers){if(I.client===null)continue;try{for(let J of await this.fetchTools(H,q,D))F.push({server:H,name:J.name,description:J.description})}catch{}}return F}async toolSchema(q,D,F){try{let H=(await this.fetchTools(q,!1,F)).find((I)=>I.name===D);if(!H)H=(await this.fetchTools(q,!0,F)).find((I)=>I.name===D);return H?.inputSchema}catch{return}}async callTool(q,D,F,H,I){let J=this.servers.get(q);if(!J){let Q=this.serverNames();return{ok:!1,output:`unknown MCP server "${q}". Known servers: ${Q.length>0?Q.join(", "):"(none configured)"}`}}let X=J.client;if(!X)return{ok:!1,output:`MCP server "${q}" is not connected${J.lastError?`: ${J.lastError}`:""}`};if(F!==void 0&&F!==null&&!x(F))return{ok:!1,output:`args for ${q}/${D} must be a JSON object (got ${Array.isArray(F)?"array":typeof F})`};let $;try{$=await this.fetchTools(q,!1,H)}catch(Q){return{ok:!1,output:`failed to list tools on "${q}": ${V(Q)}`}}if(!$.some((Q)=>Q.name===D)){try{$=await this.fetchTools(q,!0,H)}catch{}if(!$.some((Q)=>Q.name===D)){let Q=$.map((Z)=>Z.name).join(", ");return{ok:!1,output:`unknown tool "${D}" on server "${q}". Available: ${Q.length>0?Q:"(none)"}`}}}let G=U(H);try{let Q=await X.callTool({name:D,arguments:F??void 0},void 0,{signal:G.signal,timeout:this.callTimeout,resetTimeoutOnProgress:!0,onprogress:(W)=>I?.(typeof W.message==="string"&&W.message.length>0?W.message:`progress ${W.progress}${typeof W.total==="number"?`/${W.total}`:""}`)}),Z=b(Q.content,Q.structuredContent);if(Q.isError===!0)return{ok:!1,output:Z.length>0?Z:`tool "${D}" reported an error`};return{ok:!0,output:Z}}catch(Q){return{ok:!1,output:`mcp call ${q}/${D} failed: ${V(Q)}`}}finally{G.dispose()}}status(){return[...this.servers.values()].map((q)=>{let D={name:q.config.name,transport:q.config.transport,state:q.config.enabled===!1?"disabled":q.client?"connected":q.attempted&&!q.connecting?"failed":"pending"};if(q.wire!==void 0)D.wire=q.wire;if(q.fellBack)D.fellBack=!0;if(q.lastError!==void 0)D.error=q.lastError;let F=this.toolCache.get(q.config.name);if(F)D.tools=F.tools.length;return D})}async sync(q){let D=new Map(q.map((I)=>[I.name,I])),F=[],H=[];for(let[I,J]of[...this.servers]){if(D.has(I))continue;H.push(I),this.servers.delete(I);for(let X of["tools","prompts","resources"])this.invalidate(I,X);if(J.client)await J.client.close().catch(()=>{})}for(let[I,J]of D){if(this.servers.has(I))continue;this.servers.set(I,{config:J,client:null,attempted:!1}),F.push(I)}return{added:F,removed:H}}async close(){let q=[];for(let D of this.servers.values()){if(D.client)q.push(D.client.close().catch(()=>{})),D.client=null;D.attempted=!1,delete D.wire,delete D.fellBack;for(let F of["tools","prompts","resources"])this.invalidate(D.config.name,F)}await Promise.all(q)}}var v=()=>new Promise((q)=>setTimeout(q,0)),f,h=90000,d=async(q)=>(await import("./oauth-z8whcgfx.js")).runtimeAuthProvider(q);var a=_(()=>{z();R();T();z();f=new Set(["npx","npx.cmd","uvx","uvx.exe","pipx","pipx.exe","bunx","bunx.exe"])});
3
- export{h as Md,A as Nd,k as Od,u as Pd,l as Qd,a as Rd};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{wn as e}from"./main-qsevpgsv.js";var t;var s=e(()=>{t={name:"rovecode",version:"0.4.0-beta.3",license:"AGPL-3.0-only",author:"9Code Labs",repository:{type:"git",url:"git+https://github.com/9Code-Labs/rovecode-community.git"},homepage:"https://github.com/9Code-Labs/rovecode-community#readme",description:"Rovecode: a coding agent for the terminal. Research-derived harness on Bun/TypeScript with evidence-based ports from open-source harnesses (sextant TUI, MCP, ACP, headless server, repo-map, shadow-git checkpoints, execpolicy, model routers). The npm tarball ships the minified bundle; this public repository is its AGPL source.",type:"module",module:"./dist/lib/index.js",exports:{".":"./dist/lib/index.js","./extensions":"./dist/lib/public-api.js","./plugins":"./dist/lib/plugins.js","./providers":"./dist/lib/providers.js","./sdk":"./dist/lib/sdk.js","./package.json":"./package.json"},bin:{rovecode:"bin/rovecode.js"},files:["bin","dist","README.md","CHANGELOG.md","LICENSE","THIRD_PARTY_NOTICES.md"],engines:{bun:">=1.3.14"},scripts:{build:"bun run scripts/build.ts","build:cli":`bun -e "require('node:fs').rmSync('dist/cli', { recursive: true, force: true })" && bun build --target=bun --splitting --sourcemap=external src/cli/main.ts --outdir dist/cli && bun -e "require('node:fs').copyFileSync('src/providers/models-index.json', 'dist/cli/models-index.json')" && bun run smoke:cli && bun run smoke:dist`,"build:npm":"bun run build:npm:cli && bun run build:npm:lib && bun run smoke:npm","build:npm:cli":`bun -e "require('node:fs').rmSync('dist/cli', { recursive: true, force: true })" && bun build --target=bun --minify --splitting --packages=external src/cli/main.ts --outdir dist/cli && bun -e "require('node:fs').copyFileSync('src/providers/models-index.json', 'dist/cli/models-index.json')"`,"build:npm:lib":`bun -e "require('node:fs').rmSync('dist/lib', { recursive: true, force: true })" && bun build --target=bun --minify --packages=external src/index.ts --outfile dist/lib/index.js && bun build --target=bun --minify --packages=external src/public-api.ts --outfile dist/lib/public-api.js && bun build --target=bun --minify --packages=external src/plugins/index.ts --outfile dist/lib/plugins.js && bun build --target=bun --minify --packages=external src/providers/stream.ts --outfile dist/lib/providers.js && bun build --target=bun --minify --packages=external src/sdk/index.ts --outfile dist/lib/sdk.js && bun -e "require('node:fs').copyFileSync('src/providers/models-index.json', 'dist/lib/models-index.json')"`,"smoke:npm":"bun dist/cli/main.js --version && bun dist/cli/main.js smoke-tui --sextant",prepack:"bun run build:npm","smoke:cli":"bun dist/cli/main.js --version","smoke:dist":"bun dist/cli/main.js smoke-tui --sextant",test:"bun test",gauntlet:"bun src/cli/main.ts gauntlet",typecheck:"tsc --noEmit",check:"node scripts/build-model-index.mjs --check && tsc --noEmit && bun test",smoke:"bun src/cli/main.ts smoke-tui --sextant","build:model-index":"node scripts/build-model-index.mjs","check:boundary":"node scripts/check-public-boundary.mjs","check:product-boundary":"node scripts/check-product-boundary.mjs","check:links":"node scripts/check-doc-links.mjs",ci:"bun run check:boundary && bun run check:product-boundary && bun run check:links && bun run typecheck && bun test && bun run build:cli","release:check":"bun run ci && bun run build:npm && npm pack --dry-run","release:stage":"bun run scripts/stage-release.ts","quality:offline":"bun run scripts/harness-quality.ts"},dependencies:{"@ast-grep/napi":"^0.45.3","@modelcontextprotocol/sdk":"^1.30.0","@zed-industries/agent-client-protocol":"^0.4.5",diff:"^9.0.0","get-east-asian-width":"1.6.0","gpt-tokenizer":"^4.0.0",marked:"18.0.11",tokenlens:"^1.3.1"},devDependencies:{"@opencode-ai/models":"^0.0.64","@types/bun":"latest","@xterm/headless":"6.0.0",typescript:"^5.9.3"},bugs:{url:"https://github.com/9Code-Labs/rovecode-community/issues"},publishConfig:{access:"public",provenance:!0,tag:"beta"}}});
3
- export{s as Th,t as Uh};
@@ -1,18 +0,0 @@
1
- // @bun
2
- import{ri as v,ti as u}from"./main-3gjqfh7a.js";import{Ul as p,bm as o}from"./main-0904f6ps.js";import{wn as F}from"./main-qsevpgsv.js";class h{opts;jobs=new Map;listeners=new Set;seq=0;unbind;constructor(z={}){this.opts=z;let Q=z.owner;if(Q){let V=()=>{this.killAll()};Q.addEventListener("abort",V,{once:!0}),this.unbind=()=>Q.removeEventListener("abort",V)}}subscribe(z){return this.listeners.add(z),()=>this.listeners.delete(z)}list(){return[...this.jobs.values()].map((z)=>({...z.info}))}status(z){let Q=this.jobs.get(z);return Q?{...Q.info}:void 0}get running(){let z=0;for(let Q of this.jobs.values())if(Q.info.status==="running")z++;return z}start(z,Q){if(this.running>=y)return{ok:!1,reason:`${y} background jobs already running (bash_list shows them; bash_kill frees a slot) \u2014 run this one in the foreground or wait`};let V=`b${++this.seq}`,Z=new AbortController,$={info:{id:V,command:z,status:"running",startedAt:Date.now(),dropped:0,drained:!1},buf:"",cursor:0,ac:Z,done:Promise.resolve()},q=new TextDecoder,J={onSpawn:(K)=>{$.info.pid=K},onChunk:(K,W)=>{this.append($,q.decode(W,{stream:!0}))}};return this.jobs.set(V,$),$.done=v().run(z,Q,Z.signal,J).then((K)=>{if($.info.status==="killed"){this.finish($);return}if($.info.status=K.code===0?"exited":"failed",$.info.exitCode=K.code,$.buf===""&&K.text!=="")this.append($,K.text);this.finish($)},(K)=>{$.info.status="failed",this.append($,`
3
- [job runner threw: ${K instanceof Error?K.message:String(K)}]`),this.finish($)}),{ok:!0,info:{...$.info}}}append(z,Q){if(Q==="")return;if(z.buf+=Q,z.buf.length>g){let V=z.buf.length-g;z.buf=z.buf.slice(V),z.info.dropped+=V,z.cursor=Math.max(0,z.cursor-V)}}finish(z){z.info.finishedAt=Date.now();let Q={...z.info};for(let Z of this.listeners)Z(Q);let V=z.info.status==="killed"?"killed":`exit=${z.info.exitCode}`;this.opts.notify?.push(`background job ${z.info.id} finished (${V}): ${m(z.info.command,60)} \u2014 bash_output ${z.info.id} reads what it printed`),this.reap()}read(z){let Q=this.jobs.get(z);if(!Q)return{ok:!1,reason:`no background job "${z}" in this session (bash_list shows them; a finished job is dropped after its output has been read)`};let V=Q.info.dropped,$=Q.buf.slice(Q.cursor).slice(0,x);Q.cursor+=$.length;let q=Q.cursor<Q.buf.length;if(!q&&Q.info.status!=="running")Q.info.drained=!0,this.reap();return{ok:!0,info:{...Q.info},text:$,more:q,lost:V}}kill(z){let Q=this.jobs.get(z);if(!Q)return{ok:!1,reason:`no background job "${z}" in this session`};if(Q.info.status!=="running")return{ok:!0,info:{...Q.info}};return Q.info.status="killed",Q.ac.abort(),{ok:!0,info:{...Q.info}}}killAll(){let z=0;for(let Q of this.jobs.values())if(Q.info.status==="running")this.kill(Q.info.id),z++;return z}async drain(){await Promise.allSettled([...this.jobs.values()].map((z)=>z.done))}dispose(){this.killAll(),this.unbind?.(),this.listeners.clear()}reap(){let z=[...this.jobs.values()].filter((Q)=>Q.info.status!=="running"&&Q.info.drained);if(z.length<=M)return;z.sort((Q,V)=>(Q.info.finishedAt??0)-(V.info.finishedAt??0));for(let Q of z.slice(0,z.length-M))this.jobs.delete(Q.info.id)}}function $z(z){k=z}function A(){return k!==null}function Wz(){return k}function _(z,Q){if(!k)return{ok:!1,reason:"background jobs are not available on this surface \u2014 run the command in the foreground (drop run_in_background)"};return k.start(z,Q)}var y=4,g=200000,x=1e4,M=8,m=(z,Q)=>z.length>Q?z.slice(0,Q-1)+"\u2026":z,k=null;var S=F(()=>{u()});function f(z){if(z===void 0||z===null)return;let Q=typeof z==="number"?z:Number(z);if(!Number.isFinite(Q)||Q<=0)return Error(`timeout_ms must be a positive number of milliseconds (got ${JSON.stringify(z)})`);if(Q>L)return Error(`timeout_ms ${Q} is longer than the ${L}ms cap \u2014 use run_in_background for work that takes longer`);return Math.floor(Q)}function E(z){let Q=d.find((V)=>V.test(z));return Q?`command refused by safety blocklist (matched ${Q.source}): this tool is not a sandbox; rephrase without destructive system commands`:null}var L=600000,l,d;var b=F(()=>{u();S();l={schema:{name:"bash",description:"Run a shell command in the workspace (cwd locked to the session cwd). One automatic retry on non-zero exit. "+"Destructive system commands are refused by a best-effort blocklist \u2014 this is NOT a sandbox. Output truncated to 10k chars. "+`\`timeout_ms\` gives up after that long and RETURNS what the command printed (max ${L}ms); the process tree is killed. `+"`run_in_background: true` returns a job id at once instead of waiting \u2014 for a dev server, a long build, a slow test run. "+"Read it later with bash_output (only NEW output per read), see them with bash_list, stop one with bash_kill; a finished job also posts one note here by itself.",args:{type:"object",properties:{command:{type:"string"},timeout_ms:{type:"number",description:`give up after this many ms and return the partial output (1..${L}); a timeout is never retried`},run_in_background:{type:"boolean",description:"start it as a background job and return its id immediately (bash_output reads it)"}},required:["command"]}},kind:"execute",sequential:!0,async execute(z,Q){let V=z,Z=String(V.command),$=E(Z);if($)return{ok:!1,output:$};if(V.run_in_background===!0){if(!A())return{ok:!1,output:"background jobs are not available on this surface \u2014 drop run_in_background to run it in the foreground"};let W=_(Z,Q.cwd);if(!W.ok)return{ok:!1,output:W.reason};return{ok:!0,output:`started background job ${W.info.id}: ${Z}
4
- It runs while you continue \u2014 do NOT poll in a loop. \`bash_output ${W.info.id}\` reads what is new; a note lands here when it finishes.`,data:W.info}}let q=f(V.timeout_ms);if(q instanceof Error)return{ok:!1,output:q.message};let J=async()=>{if(q===void 0){let G=await v().run(Z,Q.cwd,Q.signal);return{code:G.code,text:G.text,timedOut:!1}}let W=new AbortController,Y=()=>W.abort();Q.signal.addEventListener("abort",Y,{once:!0});let U,B=!1;try{U=setTimeout(()=>{B=!0,W.abort()},q);let G=await v().run(Z,Q.cwd,W.signal);return{code:G.code,text:G.text,timedOut:B}}finally{clearTimeout(U),Q.signal.removeEventListener("abort",Y)}},K=await J();if(K.code!==0&&!K.timedOut&&!Q.signal.aborted)K=await J();if(K.timedOut)return{ok:!1,output:`timed out after ${q}ms (process tree killed; what it printed follows)
5
- ${K.text}`};return{ok:K.code===0,output:`exit=${K.code}
6
- ${K.text}`}}};d=[/rm\s+(-[a-z]*\s+)*\/(\s|$)/,/rm\s+(-[a-z]*\s+)*\/\*/,/rm\s+(-[a-z]*\s+)*(--no-preserve-root\s+)?\*(\s|$)/,/:\(\)\s*\{/,/\bmkfs(\.\w+)?\b/,/\b(shutdown|reboot|poweroff|halt)\b/,/(^|[;&|\s])(sudo\s+)?format\s+(\/|[c-z]:)/i,/(^|[;&|\s])(sudo\s+)?del\s+\/[fqs]/i,/(^|[;&|\s])(sudo\s+)?rd\s+\/[sq]/i,/(^|[;&|\s])(sudo\s+)?remove-item\s+-(rec|r|f|force)/i,/\bdd\s+[^|]*of=\/dev\/(sd|nvme|hd|disk)/,/>\s*\/dev\/(sd|nvme|hd|disk)/,/\bsudo\b.*\b(rm|mkfs|dd|shutdown|reboot|halt|format)\b/]});import{createHash as i}from"crypto";import{readFileSync as D,writeFileSync as j,existsSync as R}from"fs";import{dirname as n}from"path";function X(z){let Q=z.replace(/\s/g,""),V=2166136261;for(let Z=0;Z<Q.length;Z++)V^=Q.charCodeAt(Z),V=Math.imul(V,16777619)>>>0;return V.toString(36).padStart(3,"0").slice(-3)}function N(z){return i("sha1").update(z).digest("hex").slice(0,4)}function s(z){let Q=D(z,"utf8"),V=Q.split(`
7
- `).map((Z,$)=>({n:$+1,hash:X(Z),text:Z}));return{path:z,tag:N(Q),lines:V}}function c(z){let Q=`${z.path}#${z.tag}`,V=z.lines.map((Z)=>`${Z.n}#${Z.hash}|${Z.text}`).join(`
8
- `);return`${Q}
9
- ${V}`}function r(z,Q,V){let Z=N(z),$=Q.find((W)=>W.tag!==Z);if($)return{ok:!1,failure:{kind:"tag-mismatch",path:V,expected:$.tag,actual:Z}};let q=z.split(`
10
- `),J=[...Q].sort((W,Y)=>Y.anchorLine-W.anchorLine);for(let W of J){if(W.anchorLine<1||W.anchorLine>q.length)return{ok:!1,failure:{kind:"out-of-range",path:V,line:W.anchorLine,lineCount:q.length}};let Y=q[W.anchorLine-1],U=X(Y);if(U!==W.anchorHash){let B=[];for(let C=0;C<q.length&&B.length<a;C++)if(X(q[C])===W.anchorHash)B.push(C+1);let G=B.length>0?`line ${B[0]} currently holds that hash: ${q[B[0]-1].slice(0,80)}`:`no line matches; line ${W.anchorLine} is now: ${Y.slice(0,80)}`;return{ok:!1,failure:{kind:"hash-mismatch",path:V,line:W.anchorLine,expected:W.anchorHash,actual:U,nearest:G,text:Y.slice(0,80),matches:B}}}q.splice(W.anchorLine-1,1,...W.newLines)}let K=q.join(`
11
- `);return{ok:!0,content:K,newTag:N(K)}}function t(z,Q){if(!R(z))return{ok:!1,failure:{kind:"out-of-range",path:z,line:0,lineCount:0}};let V=r(D(z,"utf8"),Q,z);if(!V.ok)return V;return j(z,V.content),{ok:!0,newTag:V.newTag}}function e(z){let V=I-15-w.length-1;return`Edit rejected: ${P(zz(z),V)} ${w}`}function zz(z){switch(z.kind){case"tag-mismatch":return`stale read \u2014 ${z.path} changed since you read it (file TAG is now ${z.actual}, your edit carries ${z.expected}).`;case"hash-mismatch":{let Q=z.matches.length>0?`Lines whose hash matches your anchor: ${z.matches.join(", ")} \u2014 did you mean one of those?`:"No line in the file has that hash now \u2014 the content changed since your read.";return`anchor mismatch at ${z.path}:${z.line} \u2014 line ${z.line} now reads ${JSON.stringify(z.text)} (hash ${z.actual}), your anchor expected hash ${z.expected}. ${Q}`}case"out-of-range":return`line ${z.line} is out of range \u2014 ${z.path} has ${z.lineCount} lines (valid anchors: 1-${z.lineCount}).`}}function P(z,Q){return z.length<=Q?z:z.slice(0,Math.max(0,Q-1))+"\u2026"}function T(z,Q){return p(z,Q)}function Qz(z,Q,V){let Z=z.lines.length,$=Math.max(1,Math.floor(Q));if($>Z)return`${z.path}#${z.tag}
12
- (showing lines 0-0 of ${Z}; offset ${$} is past EOF)`;let q=Math.min(Z,$+Math.floor(V)-1),J=z.lines.slice($-1,q);return c({...z,lines:J}).replace(/\n$/,"")+`
13
- (showing lines ${$}-${q} of ${Z})`}function Cz(z){O=z}var a=3,I=600,w="Remedy: re-read the file with `read` to get fresh line hashes, then retry the edit.",H=8,vz,O,Lz,Oz;var Vz=F(()=>{o();b();vz={schema:{name:"read",description:"Read a file window. Output is `path#TAG` header plus `N#hash|content` lines; use hashes for edit anchors. Defaults: offset 1, limit 2000 lines. Footer notes `showing lines X-Y of Z`; if Y < Z pass a larger offset to see more.",args:{type:"object",properties:{path:{type:"string"},offset:{type:"integer",description:"first line to show (1-based, default 1)"},limit:{type:"integer",description:"max lines to show (default 2000)"}},required:["path"]}},kind:"read",sequential:!1,execute(z,Q){let V=z,Z=T(Q.cwd,V.path);if(!R(Z))return Promise.resolve({ok:!1,output:`file not found: ${Z}`});let $=Number.isFinite(V.offset)&&V.offset>0?Math.floor(V.offset):1,q=Number.isFinite(V.limit)&&V.limit>0?Math.floor(V.limit):2000;return Promise.resolve({ok:!0,output:Qz(s(Z),$,q)})}};Lz={schema:{name:"edit",description:"Anchored edit. Each op replaces the line at anchorLine (whose hash must equal anchorHash) with newLines. tag must match the TAG from your last read.",args:{type:"object",properties:{path:{type:"string"},edits:{type:"array",items:{type:"object",properties:{tag:{type:"string"},anchorLine:{type:"integer"},anchorHash:{type:"string"},newLines:{type:"array",items:{type:"string"}}},required:["tag","anchorLine","anchorHash","newLines"]}}},required:["path","edits"]}},kind:"write",sequential:!0,execute(z,Q){let V=z,Z=T(Q.cwd,V.path);if(!R(Z))return Promise.resolve({ok:!1,output:P(`Edit rejected: file not found: ${Z} \u2014 check the path (relative paths resolve against ${Q.cwd}) or create the file with \`write\`.`,I)});let $=D(Z,"utf8"),q=t(Z,V.edits.map((J)=>({...J,path:Z})));if(!q.ok)return Promise.resolve({ok:!1,output:e(q.failure)});if(O){let J=O($,Z),K=O(D(Z,"utf8"),Z),W=new Set(J),Y=K.filter((U)=>!W.has(U));if(Y.length>0){j(Z,$);let U=Y.slice(0,H).join(`
14
- `)+(Y.length>H?`
15
- \u2026 and ${Y.length-H} more`:"");return Promise.resolve({ok:!1,output:`Edit applied but lint failed \u2014 file reverted to original. New lint errors:
16
- ${U}
17
- Fix these and retry the edit.`})}}return Promise.resolve({ok:!0,output:`applied ${V.edits.length} edit(s); new TAG ${q.newTag}`})}},Oz={schema:{name:"write",description:"Create or overwrite a file with content.",args:{type:"object",properties:{path:{type:"string"},content:{type:"string"}},required:["path","content"]}},kind:"write",sequential:!0,execute(z,Q){let V=z,Z=T(Q.cwd,V.path),$=n(Z);if(!R($))return Promise.resolve({ok:!1,output:P(`Write rejected: directory ${$} does not exist \u2014 create it first (bash: mkdir -p ${JSON.stringify($)}) or write into an existing directory.`,I)});return j(Z,V.content),Promise.resolve({ok:!0,output:`wrote ${Z} (${V.content.length} bytes, TAG ${N(V.content)})`})}}});
18
- export{h as Lg,$z as Mg,Wz as Ng,S as Og,l as Pg,E as Qg,X as Rg,N as Sg,s as Tg,c as Ug,r as Vg,t as Wg,I as Xg,e as Yg,vz as Zg,Cz as _g,Lz as $g,Oz as ah,Vz as bh};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{$d as I,Zd as v,ae as E,ce as j}from"./main-m1kk6fp5.js";import{Cl as O,Dl as q,Fl as A,Jl as U,Ll as C,Ml as g}from"./main-4wndhjdc.js";import{wn as H}from"./main-qsevpgsv.js";import{basename as R}from"path";function _(G){return G.trim().length>0&&G!=="."&&G!==".."&&!/[\\/]/.test(G)&&R(G)===G}function B(G){if(_(G))return;if(G.trim().length===0)return"session id is empty";return`session id ${JSON.stringify(G)} is not a plain directory name (no / or \\, not . or ..)`}var D=()=>{};import{randomUUID as k}from"crypto";import{copyFileSync as b,cpSync as x,existsSync as z,mkdirSync as T,readdirSync as f,rmSync as p,statSync as w}from"fs";import{join as Z}from"path";function JG(G){return Z(G,".rovecode","sessions")}function S(G,J){let L=G.find((V)=>V.id===J);return L?[L]:G.filter((V)=>V.id.startsWith(J))}function u(G,J){let L=J.slice(0,4).map((V)=>V.id.slice(0,8)).join(", ");return`"${G}" matches ${J.length} sessions: ${L}${J.length>4?", \u2026":""} \u2014 be more specific`}function LG(G,J){let L=J.trim();if(L==="")return{ok:!1,error:"a session id or prefix is required"};let V=B(L);if(V!==void 0)return{ok:!1,error:V};let W=S(U(G,{includeHollow:!0}),L);if(W.length===1)return{ok:!0,id:W[0].id,summary:W[0]};if(W.length>1)return{ok:!1,error:u(L,W)};return{ok:!1,error:`no session matching "${L}"`}}function y(G){let J=/^(.+) \(fork #(\d+)\)$/.exec(G);return J?`${J[1]} (fork #${Number(J[2])+1})`:`${G} (fork #1)`}function QG(G,J,L){new C(G,J).patchMeta({title:L})}function M(G){let J=0,L;try{L=f(G)}catch{return 0}for(let V of L){let W=Z(G,V);try{let $=w(W);J+=$.isDirectory()?M(W):$.size}catch{}}return J}function VG(G,J,L={}){let V=Z(G,J.id),W=Z(V,O),$=L.maxBytes??h,Y=z(W)?M(W):0;if(Y>$)throw Error(`session ${J.id.slice(0,8)} carries ${N(Y)} of attachments, over the fork limit of ${N($)} \u2014 nothing copied; \`rovecode export ${J.id.slice(0,8)}\` writes the transcript without them`);let P=k(),X=Z(G,P);T(X,{recursive:!0});for(let F of["entries.jsonl","meta.json"])if(z(Z(V,F)))b(Z(V,F),Z(X,F));if(z(W))x(W,Z(X,O),{recursive:!0});let Q=J.title??J.preview,K=y(Q===""?"(empty session)":Q);return new C(G,P).patchMeta({createdAt:Date.now(),title:K,forkedFrom:J.id}),{id:P,from:J.id,title:K}}function WG(G,J,L){let V=[];for(let W of[Z(J,L),v(G,L)]){if(!z(W))continue;p(W,{recursive:!0,force:!0}),V.push(W)}return{removed:V}}function ZG(G,J,L=10){let V=J.trim();if(V==="")return[];let W=U(G),$=new Map;for(let Q of W)if(Q.title!==void 0)$.set(Q.id,Q.title);let Y=V.toLowerCase(),P=[];for(let Q of W)if(Q.title!==void 0&&Q.title.toLowerCase().includes(Y))P.push({sessionId:Q.id,title:Q.title,entryId:"",timestamp:Q.updatedAt,preview:Q.preview});for(let Q of new E(G).search(V,L)){let K=$.get(Q.sessionId);P.push({sessionId:Q.sessionId,...K!==void 0?{title:K}:{},entryId:Q.entryId,timestamp:Q.timestamp,preview:Q.preview})}let X=new Set;return P.filter((Q)=>{let K=`${Q.sessionId.length}:${Q.sessionId}:${Q.entryId}`;if(X.has(K))return!1;return X.add(K),!0}).slice(0,L)}var h=268435456,N=(G)=>`${(G/1048576).toFixed(1)} MB`;var l=H(()=>{I();j();D();q();g();A()});
3
- export{B as cc,D as dc,JG as ec,S as fc,u as gc,LG as hc,QG as ic,VG as jc,WG as kc,ZG as lc,l as mc};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{Bj as B,wj as x}from"./main-90ds1z4e.js";var C=(j)=>j??"auto",F="nothing \u2014 auto: the endpoint's own default stands";function H(j){switch(j){case"low":return 2048;case"medium":return 8192;case"high":return 24576;default:return null}}function U(j,z){if(j===void 0||j==="auto")return{};if(j==="off")return{thinking:{type:"disabled"}};if(z==="effort")return{output_config:{effort:j}};let J=H(j);return J===null?{}:{thinking:{type:"enabled",budget_tokens:J}}}function q(j,z){let J=U(j,z),W=j==="auto"?F:j==="off"?'thinking: { type: "disabled" } \u2014 an explicit off; Claude 5 reasons by default':`${JSON.stringify(J).slice(1,-1).replace(/"(\w+)":/g,"$1: ").replace(/,/g,", ")} (the ${z} shape \u2014 learned from the endpoint, kept per model)`;return{dialect:`anthropic/${z}`,fields:J,says:W}}var R=(j)=>JSON.stringify(j),K=(j)=>({fields:{},says:`nothing \u2014 ${j}`}),Q=(j,z="")=>({fields:{reasoning_effort:j},says:`reasoning_effort: ${R(j)}${z?` (${z})`:""}`}),$=(j,z)=>({fields:{thinking:{type:j?"enabled":"disabled"}},says:`thinking: { type: ${R(j?"enabled":"disabled")} } (${z} has an on/off switch, no levels)`}),V=(j)=>(z)=>j.test(z.model),M=[{id:"catalog: no reasoning mode",matches:(j)=>j.reasoning===!1,plan:(j,z)=>K(`the catalog lists ${z.model} without a reasoning mode, so no dial is sent`)},{id:"openrouter",matches:(j)=>j.provider==="openrouter",plan:(j)=>j==="off"?{fields:{reasoning:{enabled:!1}},says:"reasoning: { enabled: false } (OpenRouter's unified field; a model that always reasons ignores it)"}:{fields:{reasoning:{effort:j}},says:`reasoning: { effort: ${R(j)} } (OpenRouter's unified field, translated per upstream)`}},{id:"glm-5.3",matches:V(x),plan:(j,z)=>{if(j==="off")return K("GLM-5.3 cannot switch thinking off (Z.ai: thinking.type accepts enabled only); the endpoint default is max");let J=B(z);if(J===null)return Q(j,"ROVECODE_PROFILE=off: the plain word, not GLM's low | high | max");return Q(J.reasoningEffort(j),"GLM's words are low | high | max; medium rounds up")}},{id:"glm-5.x",matches:V(/(^|[/:])glm-5(\.\d+)?(?=[-:]|$)/i),plan:(j)=>j==="off"?{fields:{thinking:{type:"disabled"}},says:'thinking: { type: "disabled" } (best effort \u2014 GLM gen-5 endpoints may ignore it; measured ignored on kaesra dash)'}:Q(j==="low"?"low":j==="medium"?"high":"max","GLM gen-5 words are low | high | max; medium rounds up")},{id:"glm",matches:V(/(^|[/:])glm-(4\.[5-9]|4\.\d{2,})(?=[-:]|$)/i),plan:(j)=>$(j!=="off","GLM")},{id:"deepseek",matches:V(/deepseek/i),plan:(j,z)=>/reasoner|r1/i.test(z.model)?K(`${z.model} always thinks \u2014 no dial`):$(j!=="off","DeepSeek")},{id:"qwen",matches:V(/(^|[/:])(qwen|qwq)/i),plan:(j,z)=>{if(z.provider==="groq")return j==="off"?Q("none","Groq's Qwen words are none | default"):Q("default","Groq's Qwen words are none | default");if(j==="off")return{fields:{enable_thinking:!1},says:"enable_thinking: false (DashScope / most Qwen hosts; a vLLM host wants chat_template_kwargs instead and ignores this)"};let J=H(j);return{fields:{enable_thinking:!0,thinking_budget:J},says:`enable_thinking: true, thinking_budget: ${J} (DashScope's fields; a host without them ignores both)`}}},{id:"kimi",matches:V(/kimi|moonshot/i),plan:(j,z)=>/thinking/i.test(z.model)?K(`${z.model} always thinks \u2014 no dial`):/k2[.-]5|k2\.5/i.test(z.model)?$(j!=="off","Moonshot K2.5"):K(`${z.model} has no thinking mode (the -thinking variant does)`)},{id:"gemini",matches:V(/gemini/i),plan:(j,z)=>j!=="off"?Q(j,"Google's OpenAI-compatible layer maps low | medium | high to a thinking budget"):/flash/i.test(z.model)?{fields:{extra_body:{google:{thinking_config:{thinking_budget:0}}}},says:"extra_body.google.thinking_config.thinking_budget: 0 (Flash can switch thinking off; Pro cannot)"}:K(`${z.model} cannot switch thinking off (Gemini Pro keeps a minimum budget)`)},{id:"grok",matches:V(/grok/i),plan:(j,z)=>/non-reasoning/i.test(z.model)?K(`${z.model} has no reasoning mode`):/grok-3-mini/i.test(z.model)?j==="off"?K("grok-3-mini cannot switch reasoning off"):Q(j==="low"?"low":"high","xAI's words for grok-3-mini are low | high; medium rounds up"):j==="off"?Q("none","xAI's explicit off (grok-4.3 and later; retired grok-4 slugs are served by grok-4.3)"):Q(j,"xAI's words are none | low | medium | high")},{id:"gpt-oss",matches:V(/gpt-oss/i),plan:(j)=>j==="off"?K("gpt-oss cannot switch reasoning off (low is the floor)"):Q(j)},{id:"openai o-series",matches:V(/(^|[/:])o[134](-|$)/i),plan:(j,z)=>j==="off"?K(`${z.model} cannot switch reasoning off`):Q(j)},{id:"openai gpt-5",matches:V(/(^|[/:])gpt-5/i),plan:(j,z)=>j!=="off"?Q(j):/gpt-5\.[1-9]/i.test(z.model)?Q("none","gpt-5.1 and later: the explicit off"):Q("minimal","gpt-5 has no off; minimal is its floor")},{id:"openai gpt-4 class",matches:V(/(^|[/:])(gpt-4|gpt-3\.5|chatgpt)/i),plan:(j,z)=>K(`${z.model} has no reasoning mode and OpenAI rejects reasoning_effort for it`)},{id:"mistral",matches:V(/magistral|mistral|codestral|ministral|pixtral/i),plan:(j,z)=>/magistral/i.test(z.model)?K("Magistral always reasons \u2014 no dial"):K(`${z.model} has no reasoning mode`)},{id:"minimax",matches:V(/minimax/i),plan:(j,z)=>K(`${z.model} always reasons \u2014 no dial`)},{id:"openai-compatible default",matches:()=>!0,plan:(j)=>j==="off"?K("off sends nothing here: no common explicit disable on OpenAI-compatible endpoints; a model without a reasoning mode ignores the word anyway"):Q(j,"the OpenAI word; a model without a reasoning mode ignores it")}];function y(j){return M.find((z)=>z.matches(j)).id}function S(j,z,J={}){let W=C(j.effort);if(z==="anthropic")return q(W,J.shape??"effort");let X=M.find((Y)=>Y.matches(j));if(W==="auto")return{dialect:X.id,fields:{},says:F};return{dialect:X.id,...X.plan(W,j)}}function D(j,z,J={}){return["auto","off","low","medium","high"].map((W)=>({level:W,says:S({...j,effort:W},z,J).says}))}function A(j,z,J={}){return`${j.provider}/${j.model} receives: ${S(j,z,J).says}`}function E(j,z,J={}){let W=C(j.effort),X=z==="anthropic"?`anthropic (${J.shape??"effort"} shape)`:y(j),Y=[`${j.provider}/${j.model}${J.source?` (${J.source})`:""}`,` protocol ${z}`,` dialect ${X}${j.reasoning===!1?" \u2014 the catalog lists no reasoning mode":j.reasoning===!0?" \u2014 the catalog lists a reasoning mode":""}`,...J.catalog?[` prices ${J.catalog}`]:[],` effort ${W} (ROVECODE_EFFORT / --effort / /effort)`];for(let Z of D(j,z,J))Y.push(` ${Z.level===W?"*":" "} ${Z.level.padEnd(7)} ${Z.says}`);return Y}
3
- export{H as mj,U as nj,y as oj,S as pj,D as qj,A as rj,E as sj};
@@ -1,38 +0,0 @@
1
- // @bun
2
- import{Pb as g,bc as Rz}from"./main-73g7eff4.js";import{ad as U,bd as jz,cd as az}from"./main-rfth4tbm.js";import{jf as Zz,lf as $z,nf as nz}from"./main-dfreez27.js";import{ji as d,ti as Tz}from"./main-3gjqfh7a.js";import{ak as v,ck as YJ}from"./main-xg704a3c.js";import{Rk as t,Sk as xz,Tk as e,Vk as zz,Wk as Jz,Xk as dz,ml as M,nl as Vz,ol as n}from"./main-3rxcvgna.js";import{Bl as FJ,Cl as r,Dl as pz,pl as I,rl as Hz,sl as Fz,ul as w,wl as _,yl as Yz}from"./main-4wndhjdc.js";import{wn as R}from"./main-qsevpgsv.js";function Pz(z){if(/[\r\n]/.test(z))return null;let J=z.trim();if(!Gz.test(J))return null;return J.slice(1).trim()}function h(z,J,V){let Z=z.add(J,V);if(!Z.ok)return{ok:!1,tone:"warn",text:`memory: not saved to ${A[J]} \u2014 ${Z.reason??"edit failed"}`};return{ok:!0,tone:"info",text:`memory: noted in ${A[J]} (${Z.current}/${Z.limit} chars, ${z.path(J)}) \u2014 in the prompt from the next run`}}function PJ(z,J){let V=Pz(J);if(V===null)return!1;z.renderer.addUser(J.trim());let Z=h(z.blocks(),"memory",V);return z.renderer.addSystemNote(Z.text,Z.tone),!0}function Dz(z,J){let V=z.overCap(J);return(z.edited(J)?`
3
- (edited this run \u2014 in the prompt from the next run)`:"")+(z.isWithheld(J)?`
4
- (not in the prompt and not writable \u2014 it came with this repository; rovecode trust show)`:"")+(V?`
5
- (over the ${V.cap}-char cap \u2014 the prompt shows the first ${V.cap}; trim the file)`:"")}function DJ(z,J){let V=J.trim(),Z=V==="--user"||V.startsWith("--user "),$=Z?V.slice(6).trim():V;if($){let K=h(z,Z?"user":"memory",$);return{text:K.text,tone:K.tone}}return{text:(Z?["user"]:["memory","user"]).map((K)=>`# ${A[K]} \u2014 ${z.path(K)}
6
- ${z.liveText(K)||"(empty)"}${Dz(z,K)}`).join(`
7
-
8
- `),tone:"info"}}var Gz,A;var Lz=R(()=>{Gz=/^#[\p{L}\p{N}]/u;A={memory:"MEMORY",user:"USER"}});import{randomUUID as l}from"crypto";function Iz(z){let J=g(z);return J.kind==="shell"&&J.cmd?J.cmd:null}function _z(z,J){return!J&&z.detail==="user denied"?{...z,detail:b}:z}async function OJ(z,J){let V=Iz(J);if(V===null)return;let{renderer:Z}=z;if(z.busy()){Z.addSystemNote("finish or interrupt the run first (Esc) \u2014 `!cmd` runs only while the agent is idle","warn");return}Z.addUser(J.trim());let $=new AbortController;z.setBusy(!0),z.bindAbort($),Z.setBusy(!0,`running ${u(V)}\u2026`);let Q={kind:"tool_call",id:`shell-${l().slice(0,8)}`,tool:"bash",args:{command:V}},j=!1,K=!1,W=z.approve(),q=z.rt.buildCfg(z.level(),W===void 0?void 0:async(H)=>{return j=!0,W(H)}),B={sessionId:z.store().id,cwd:z.rt.cwd,signal:$.signal,permissions:{effect:"allow"}},Y=(H)=>{let X=H.type==="tool_call_failed"?_z(H,j):H;if(Z.onEvent?.(X),X.type==="tool_execution_start")Z.toolStart(X.callId,X.tool,JSON.stringify(X.args).slice(0,120));else if(X.type==="tool_execution_update")Z.toolUpdate(X.callId,X.note);else if(X.type==="tool_execution_end")K=!0,Z.toolEnd(X.callId,X.ok,X.output.slice(0,160).replace(/\n/g," \u23CE "),X.durationMs);else if(X.type==="tool_call_failed")Z.toolEnd(X.callId,!1,`${X.reason}: ${X.detail}`.slice(0,160),0)},P={ok:!1,output:""};try{if(P=await z.rt.registry.dispatch(Q,B,z.rt.hooks,q.permissionRules,q.approval,Y,void 0),K){let H=z.store(),X=H.stagedAttachments;if(H.stageAttachments([]),H.append(Az(V,P,H.messages().at(-1)?.id??null)),H.stageAttachments(X),!Z.onEvent)Z.addSystemNote(yz(P.output),P.ok?"info":"warn")}else{let H=$.signal.aborted?"was interrupted before it ran":j?"was denied at the approval card":"was refused before any approval prompt (a permission rule, exec policy or a hook)";Z.addSystemNote(`\`${u(V)}\` ${H} \u2014 nothing ran, nothing recorded`,"warn")}}finally{z.bindAbort(null),Z.setBusy(!1,K&&P.ok?"done":"error"),z.setBusy(!1)}}function Az(z,J,V){let Z=/^exit=(-?\d+)\r?\n?/.exec(J.output),$=Z?Z[1]:"?",Q=(Z?J.output.slice(Z[0].length):J.output).replace(/\r?\n$/,""),j=[Oz,`$ ${z}`,Mz,`${Uz} exit="${$}">`,...Q?[Q]:[],Cz].join(`
9
- `);return{id:l(),role:"user",parts:[{kind:"text",text:j}],parentId:V,createdAt:Date.now()}}function kz(z){let J=bz.exec(z);return J?{cmd:J[1],exit:J[2],output:J[3]??""}:null}function yz(z){let J=z.replace(/\r\n/g,`
10
- `).replace(/\n$/,"").split(`
11
- `),V=J.slice(0,Nz),Z=J.length-V.length;return V.join(`
12
- `)+(Z>0?`
13
- \u2026 ${Z} more line${Z===1?"":"s"} (the session record keeps the full output)`:"")}function MJ(z,J){let V=kz(J);if(!V)return!1;let Z=`shell-replay-${++Sz}`;return z.addUser(`!${V.cmd}`),z.toolStart(Z,"bash",JSON.stringify({command:V.cmd}).slice(0,120)),z.toolEnd(Z,V.exit==="0",[`exit=${V.exit}`,...V.output?[V.output]:[]].join(`
14
- `).slice(0,160).replace(/\n/g," \u23CE "),0),!0}var Nz=40,Oz="<user_shell_command>",Mz="</user_shell_command>",Uz="<user_shell_output",Cz="</user_shell_output>",u=(z)=>{let J=z.replace(/\s+/g," ").trim();return J.length>40?J.slice(0,39)+"\u2026":J},b="refused by a permission rule, exec policy or an approval hook (no approval prompt)",bz,Sz=0;var m=R(()=>{Rz();bz=/^<user_shell_command>\n\$ ([\s\S]*?)\n<\/user_shell_command>\n<user_shell_output exit="(-?\d+|\?)">\n(?:([\s\S]*?)\n)?<\/user_shell_output>$/});function E(z){return`compacted (${z.strategy}): ${z.tokensBefore} \u2192 ${z.tokensAfter} tokens`}function SJ(z){let J=z.event;if(!J||typeof J!=="object")return null;return J.type==="compaction"?E(J):null}var o=()=>{};import{spawnSync as jJ}from"child_process";function qJ(z){let J=z?.trim()??"";if(J.length<16||!/^[A-Za-z0-9+/=\r\n]+$/.test(J))return null;try{return new Uint8Array(Buffer.from(J.replace(/\s+/g,""),"base64"))}catch{return null}}function HJ(z){let J=/\u00ABdata PNGf([0-9A-Fa-f]+)\u00BB/.exec(z??"");if(!J||J[1].length<32||J[1].length%2!==0)return null;return new Uint8Array(Buffer.from(J[1],"hex"))}function Xz(z=XJ,J=process.platform){if(J==="win32")return qJ(z("powershell",["-NoProfile","-NonInteractive","-STA","-Command",WJ]));if(J==="darwin")return HJ(z("osascript",["-e","the clipboard as \xABclass PNGf\xBB"]));for(let[V,Z]of[["wl-paste",["-t","image/png"]],["xclip",["-selection","clipboard","-t","image/png","-o"]]]){let $=z(V,Z,"latin1");if($!==null&&$.length>8)return new Uint8Array(Buffer.from($,"latin1"))}return null}function Wz(z=new Date){let J=(V)=>String(V).padStart(2,"0");return`clipboard-${J(z.getHours())}${J(z.getMinutes())}${J(z.getSeconds())}.png`}var KJ=5000,QJ=67108864,XJ=(z,J,V="utf8")=>{try{let Z=jJ(z,J,{encoding:V,timeout:KJ,maxBuffer:QJ,windowsHide:!0,stdio:["ignore","pipe","ignore"]});if(Z.error||Z.status!==0||Z.signal)return null;return Z.stdout}catch{return null}},WJ;var qz=R(()=>{WJ=["Add-Type -AssemblyName System.Windows.Forms,System.Drawing","$i = [System.Windows.Forms.Clipboard]::GetImage()","if ($i -eq $null) { exit 3 }","$ms = New-Object System.IO.MemoryStream","$i.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)","[Console]::Out.Write([Convert]::ToBase64String($ms.ToArray()))"].join("; ")});import{resolve as BJ}from"path";function VV(z,J){let{renderer:V}=z,Z=z.store(),$=Z.stagedAttachments;if(J===""){V.addSystemNote($.length===0?"no images attached \u2014 /attach <path>":`attached (${$.length}/${I}):
15
- ${$.map((B,Y)=>`${Y+1}. ${_(B)}`).join(`
16
- `)}`);return}if(J==="clear"){Z.stageAttachments([]),V.addSystemNote($.length===0?"no images attached":`attachments cleared (${f($.length)} removed)`);return}let Q=J.replace(/^(["'])(.*)\1$/,"$2"),j=Fz(BJ(z.cwd,Q));if("error"in j){V.addSystemNote(j.error,"error");return}let K=w($.length+1);if(K!==void 0){V.addSystemNote(K,"error");return}Z.stageAttachments([...$,j]),V.addSystemNote(`attached ${_(j)} (${$.length+1}/${I}) \u2014 type your message and press Enter to send it`);let W=z.modelRef(),q=v(W);if(q===!1)V.addSystemNote(`model ${W.provider}/${W.model} has no image input \u2014 it will be sent as a text placeholder`,"warn");else if(q===void 0)V.addSystemNote(`unknown model ${W.provider}/${W.model}; image sent as-is (provider may reject)`)}function $V(z,J=()=>Xz(),V=Wz()){let{renderer:Z}=z,$=J();if($===null){Z.addSystemNote("no image on the clipboard \u2014 copy a screenshot or picture first, or /attach <path>");return}let Q=Hz($,{name:V});if("error"in Q){Z.addSystemNote(Q.error,"error");return}let j=z.store(),K=j.stagedAttachments,W=w(K.length+1);if(W!==void 0){Z.addSystemNote(W,"error");return}j.stageAttachments([...K,Q]),Z.addSystemNote(`attached ${_(Q)} from the clipboard (${K.length+1}/${I}) \u2014 type your message and press Enter to send it`);let q=z.modelRef();if(v(q)===!1)Z.addSystemNote(`model ${q.provider}/${q.model} has no image input \u2014 it will be sent as a text placeholder`,"warn")}function jV(z,J){let V=J.filter((Z)=>Z.kind==="image").map(Yz).join(" ");return z&&V?`${z}
17
- ${V}`:z||V}function KV(z){let J=z.stagedAttachments.length;return J===0?"":` \u2014 ${f(J)} attached to your queued message`}function QV(z,J){if(J.length===0)return;z.store().stageAttachments(J),z.renderer.addSystemNote(`${f(J.length)} still attached \u2014 carried over to this session, rides on your next message`)}var JV,f=(z)=>`${z} image${z===1?"":"s"}`,ZV;var GJ=R(()=>{FJ();qz();YJ();JV={name:"attach",description:"Attach an image to your next message (text required): /attach <path> \xB7 /attach = list \xB7 /attach clear \xB7 or drag an image file onto the terminal"};ZV={name:"paste",description:"attach the image on the clipboard (\u2303v)"}});Tz();n();m();import{randomUUID as T}from"crypto";var a="finish or interrupt the run first (Esc) \u2014 /commit and /undo run only while the agent is idle",i="(diff truncated at the 10k output cap for the model)",p="a commit message cannot start with -; quote it or begin with a word \u2014 git would read a dash-led message as a flag, so nothing was committed",Ez="You write git commit messages. Reply with the commit message only: a first line `type(scope): summary` in the imperative mood, at most 72 characters, type one of feat, fix, refactor, docs, test, chore, perf, build, ci, style; then, only when the change needs it, one blank line and a short body. No quotes, no code fences, no commentary.";function wz(z){return/^[A-Za-z0-9_./:=@%+,-]+$/.test(z)?z:`'${z.replace(/'/g,"'\\''")}'`}function vz(z){return["git",...z.map(wz)].join(" ")}async function O(z,J,V,Z){let $=vz(J),Q={kind:"tool_call",id:`git-${T().slice(0,8)}`,tool:"bash",args:{command:$}},j=!1,K=!1,W=z.approve(),q=z.rt.buildCfg(z.yolo(),W===void 0?void 0:async(D)=>{return j=!0,await z.renderer.askApproval(D.tool,JSON.stringify(D.revisedArgs).slice(0,140),Z)==="deny"?"deny":"once"}),B={sessionId:z.store().id,cwd:z.rt.cwd,signal:V,permissions:{effect:"allow"}},{renderer:Y}=z,P=(D)=>{let G=D.type==="tool_call_failed"&&!j&&D.detail==="user denied"?{...D,detail:b}:D;if(Y.onEvent?.(G),G.type==="tool_execution_start")Y.toolStart(G.callId,G.tool,JSON.stringify(G.args).slice(0,120));else if(G.type==="tool_execution_update")Y.toolUpdate(G.callId,G.note);else if(G.type==="tool_execution_end")K=!0,Y.toolEnd(G.callId,G.ok,G.output.slice(0,160).replace(/\n/g," \u23CE "),G.durationMs);else if(G.type==="tool_call_failed")Y.toolEnd(G.callId,!1,`${G.reason}: ${G.detail}`.slice(0,160),0)},H=await z.rt.registry.dispatch(Q,B,z.rt.hooks,q.permissionRules,q.approval,P,void 0),X=/^exit=(-?\d+)\r?\n?/.exec(H.output),F=X?H.output.slice(X[0].length):H.output;return{executed:K,asked:j,exit:X?Number(X[1]):-1,body:F.replace(/\r\n/g,`
18
- `),capped:F.length>=d,command:$}}var k=(z)=>z.trim().split(`
19
- `)[0]??"",y=(z,J)=>J.aborted?"was interrupted before it ran":z.asked?"was denied at the approval card":"was refused before any approval prompt (exec policy, a permission rule or a hook)";function S(z,J){let V=z.body.split(`
20
- `).map(($)=>$.trim()).find(($)=>$!==""&&$!=="stderr:")??"no output",Z=/not a git repository|--no-index/.test(z.body);return`${z.command.split(" ").slice(0,2).join(" ")} failed (exit ${z.exit}): ${V}${Z?` \u2014 ${J} is not inside a git repository`:""}`}function fz(z){let J=z.replace(/\r\n/g,`
21
- `).trim(),V=/^```[^\n]*\n([\s\S]*?)\n?```$/.exec(J);if(V)J=V[1].trim();if(J=J.replace(/^commit message:\s*/i,""),J.startsWith('"')&&J.endsWith('"')||J.startsWith("'")&&J.endsWith("'"))J=J.slice(1,-1).trim();return J.split(`
22
- `).map((Z)=>Z.trimEnd()).join(`
23
- `).replace(/\n{3,}/g,`
24
-
25
- `).trim()}async function hz(z,J,V,Z){let $=z.rt.stream;if(!$)return{error:"no provider configured \u2014 nothing can draft a message"};let Q=Date.now(),j={id:T(),role:"system",parts:[{kind:"text",text:Ez}],parentId:null,createdAt:Q},K={id:T(),role:"user",parts:[{kind:"text",text:`Write the commit message for this diff:
26
-
27
- ${J}`}],parentId:j.id,createdAt:Q},W=null;try{for await(let B of $(V,[j,K],{signal:Z}))if(B.type==="turn")W=B.turn}catch(B){return{error:`commit model failed: ${B instanceof Error?B.message:String(B)}`}}if(Z.aborted)return{error:"interrupted while drafting the message"};if(!W)return{error:"commit model returned no turn"};if(W.stopReason==="error")return{error:`commit model failed: ${W.error??"error"}`};let q=fz(M(W.parts));return q?{text:q}:{error:"the commit model returned an empty message"}}function uz(z){let J=[];for(let V of z.matchAll(/^diff --git a\/(.+?) b\/(.+)$/gm))J.push(V[2]);return J}async function bJ(z,J=""){let{renderer:V}=z;if(z.busy()){V.addSystemNote(a,"warn");return}let Z=J.replace(/\r\n/g,`
28
- `).trim();if(Z.startsWith("-")){V.addSystemNote(p,"warn");return}let $=new AbortController;z.setBusy(!0),z.bindAbort($),V.setBusy(!0,"collecting the diff\u2026");let Q="error";try{let j=await O(z,["diff","--cached"],$.signal);if(!j.executed){V.addSystemNote(`\`${j.command}\` ${y(j,$.signal)} \u2014 nothing committed`,"warn");return}if(j.exit!==0){V.addSystemNote(S(j,z.rt.cwd),"error");return}let K="staged",W=j.body,q=j.capped;if(!W.trim()){let F=await O(z,["diff"],$.signal);if(!F.executed){V.addSystemNote(`\`${F.command}\` ${y(F,$.signal)} \u2014 nothing committed`,"warn");return}if(F.exit!==0){V.addSystemNote(S(F,z.rt.cwd),"error");return}if(!F.body.trim()){V.addSystemNote("nothing to commit \u2014 the index and the tracked working tree are clean (untracked files need `git add` first)"),Q="done";return}K="working",W=F.body,q=F.capped,V.addSystemNote("nothing staged \u2014 committing the working-tree changes to tracked files instead (`git commit -a`)")}let B=uz(W);if(q){let F=await O(z,K==="working"?["diff","--name-only"]:["diff","--cached","--name-only"],$.signal);if(F.executed&&F.exit===0)B=F.body.split(`
29
- `).map((D)=>D.trim()).filter((D)=>D!=="")}let Y=Z,P="";if(!Y){let F=z.rt.router.resolve("commit");V.setBusy(!0,`drafting the commit message (${F.model})\u2026`);let D=await hz(z,q?`${W}
30
- \u2026 ${i}`:W,F,$.signal);if("error"in D){V.addSystemNote(`${D.error} \u2014 pass the message yourself: /commit <message>`,"error");return}if(Y=D.text,P=`${F.provider}/${F.model}`,Y.startsWith("-")){V.addSystemNote(`the drafted message starts with - (${k(Y)}); ${p}`,"error");return}}V.setBusy(!0,"committing\u2026");let H=[`commit message${P?` (drafted by ${P}${Z?"":" \u2014 deny to edit it in the prompt"})`:""}:`,...Y.split(`
31
- `).map((F)=>` ${F}`),"",K==="working"?"scope: working-tree changes to tracked files (git commit -a)":"scope: the staged changes",`files (${B.length}): ${B.slice(0,12).join(", ")}${B.length>12?", \u2026":""}`,...q?[i]:[]].join(`
32
- `),X=await O(z,K==="working"?["commit","-a","-m",Y]:["commit","-m",Y],$.signal,H);if(!X.executed){if(V.addSystemNote(`commit ${y(X,$.signal)} \u2014 nothing committed`,"warn"),X.asked&&!$.signal.aborted)V.prefillEditor(`/commit ${Y}`),V.addSystemNote("the message is in the prompt \u2014 edit it and press Enter to commit");return}if(X.exit!==0){V.addSystemNote(`${S(X,z.rt.cwd)}
33
- ${X.body.trim().split(`
34
- `).slice(-8).join(`
35
- `)}`,"error");return}Q="done",V.addSystemNote(`committed ${k(X.body)||k(Y)}${P?` \xB7 message by ${P}`:""}`)}finally{z.bindAbort(null),V.setBusy(!1,Q),z.setBusy(!1)}}var gz=(z)=>new Date(z.createdAt).toLocaleTimeString(),x=(z)=>`${z.hash.slice(0,8)} (${z.label}, ${gz(z)})`,lz={M:"rewritten",D:"recreated",A:"removed (added since that checkpoint)","?":"removed (created after the checkpoint)"};async function kJ(z){let{renderer:J}=z;if(z.busy()){J.addSystemNote(a,"warn");return}let V=await z.rt.checkpointsFor(z.store().id);if(!V){J.addSystemNote("checkpoints unavailable (git missing or ROVECODE_NO_CHECKPOINTS=1) \u2014 nothing to undo","warn");return}let Z=V.list().at(-1);if(!Z){J.addSystemNote("no checkpoint to undo to \u2014 snapshots land after each mutating tool call (edit, write, bash)");return}let $=await V.position(),Q=$.at?$.previous:Z;if(!Q){J.addSystemNote(`nothing to undo \u2014 the workspace matches checkpoint ${x($.at)} and no older snapshot differs from it (/checkpoints lists them; /restore <ref> reaches any)`);return}let j=x(Q),K=await V.changedSince(Q.hash);if(K!==null&&K.length===0){J.addSystemNote(`nothing to undo \u2014 the workspace already matches the last checkpoint ${j}`);return}let W=$.at?`undo the agent's last change (checkpoint ${$.at.hash.slice(0,8)}, ${$.at.label}): restore ${j}`:`restore the workspace to checkpoint ${j}`,q=K===null?`${W}: every file goes back to that snapshot (the change list could not be computed)`:[`${W} \u2014 ${K.length} path${K.length===1?"":"s"}:`,...K.slice(0,40).map((H)=>` ${H.status} ${H.path} \u2014 ${lz[H.status]??H.status}`),...K.length>40?[` \u2026 ${K.length-40} more`]:[],"","the conversation is untouched; /restore <ref> conversation branches it too"].join(`
36
- `);if(await J.askApproval("undo",`restore checkpoint ${Q.hash.slice(0,8)} \xB7 files only`,q)==="deny"){J.addSystemNote("undo cancelled \u2014 nothing changed","warn");return}let Y=await V.restore(Q.hash,"files");if(!Y.ok){J.addSystemNote(`undo failed: ${Y.error}`,"error");return}let P=K===null?"the workspace":`${K.length} path${K.length===1?"":"s"}: ${K.slice(0,8).map((H)=>H.path).join(", ")}${K.length>8?", \u2026":""}`;J.addSystemNote(`undo: restored ${P} to checkpoint ${j} \u2014 files only; the conversation is untouched (snapshots keep history: /checkpoints)`)}dz();xz();n();nz();pz();az();import{randomUUID as Kz}from"crypto";import{existsSync as oz}from"fs";import{basename as sz,isAbsolute as cz,join as rz}from"path";function mz(z){if(z==="win32")return[["powershell","-NoProfile","-NonInteractive","-Command","[Console]::InputEncoding=[Text.Encoding]::UTF8; $t=[Console]::In.ReadToEnd(); Set-Clipboard -Value $t"]];return[["pbcopy"],["wl-copy"],["xclip","-selection","clipboard"],["xsel","--clipboard","--input"]]}var iz=async(z,J)=>{try{let V=Bun.spawn([...z],{stdin:"pipe",stdout:"ignore",stderr:"pipe"});V.stdin.write(J),await V.stdin.end();let Z=await V.exited;if(Z===0)return{ok:!0};let $=(await new Response(V.stderr).text()).trim().split(`
37
- `)[0]??"";return{ok:!1,detail:`exit ${Z}${$?`: ${$.slice(0,120)}`:""}`}}catch(V){return{ok:!1,detail:V instanceof Error?V.message:String(V)}}};async function s(z,J={}){let V=J.spawn??iz,Z=[];if(z.length===0)return{ok:!1,tried:Z,detail:"nothing to copy (empty text)"};let $;for(let Q of mz(J.platform??process.platform)){let j=Q[0];Z.push(j);let K;try{K=await V(Q,z)}catch(W){K={ok:!1,detail:W instanceof Error?W.message:String(W)}}if(K.ok)return{ok:!0,tool:j};$=K.detail}return{ok:!1,tried:Z,...$!==void 0?{detail:$}:{}}}o();var dJ=[{name:"compact",description:"Compact the context now: /compact [focus] \u2014 the automatic strategy set, marker persisted",group:"session"},{name:"clear",description:"Fresh session in place (transcript emptied; the previous session is kept \u2014 /resume <id>)",group:"session"},{name:"init",description:"Analyse the repo and write AGENTS.md (an existing one gets targeted improvements)",group:"files & history"},{name:"copy",description:"Copy the last assistant message to the clipboard: /copy [n] (n-th from the end)",group:"session"}],c=6,C="finish or interrupt the run first (Esc)";function tz(z){return z.map((J)=>J.kind==="image"&&J.path!==void 0&&cz(J.path)?{...J,path:`${r}/${sz(J.path)}`}:J)}async function ez(z,J,V={}){let Z=z.messages(),$=Z.length;if($<c)return{kind:"nothing",reason:`nothing to compact \u2014 ${$} message${$===1?"":"s"} on the active path (compaction needs at least ${c})`};let Q=(L)=>Vz(L.parts),j=(L)=>L.reduce((N,Bz)=>N+t(Q(Bz)),0),K={trigger:"speculative",tokenText:Q,summarize:V.summarize,native:V.native,model:V.model,signal:V.signal},W=zz(Z,J,K),q=W?await Jz(Z,W,J,K):null;if(!q)return{kind:"nothing",reason:`nothing to compact \u2014 ${J.compactionStrategy??e} found nothing droppable (${j(Z)} tokens)`};let B=j(Z),Y=j(q.history),P=z.stagedAttachments;z.stageAttachments([]);let H=Z.at(-1)?.id,X=null;try{for(let L of q.history){let N={...L,id:Kz(),parentId:X,parts:tz(L.parts)};z.append(N),X=N.id}if(X!==null)z.branch(X)}catch(L){if(H!==void 0)z.branch(H);throw L}finally{z.stageAttachments(P)}let F={type:"compaction",strategy:q.strategy,tokensBefore:B,tokensAfter:Y};z.appendEvent(F);let D=new Set(Z.map((L)=>L.id)),G=q.history.filter((L)=>D.has(L.id)).length;return{kind:"compacted",event:F,dropped:$-G,kept:G,...q.fallbackFrom?{fallbackFrom:q.fallbackFrom}:{}}}function Qz(z,J){let V=(Z)=>Z===1?"":"s";return`${z.dropped} message${V(z.dropped)} dropped, ${z.kept} kept \u2014 the earlier turns stay in the session file on the previous branch`+(z.fallbackFrom?` \xB7 ${z.fallbackFrom} could not run on this surface (no summarizer wired) \u2014 ${z.event.strategy} ran instead`:"")+(J?` \xB7 focus "${J}" not applied \u2014 the compaction strategies take no instructions`:"")}function nJ(z,J){return z.kind==="nothing"?[z.reason]:[E(z.event),Qz(z,J)]}async function zJ(z,J){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let V=z.store();z.state.busy=!0;let Z=new AbortController;z.bindAbort?.(Z);let $;try{$=await ez(V,z.buildCfg(),{model:z.modes.modelFor(),summarize:z.summarize,signal:Z.signal})}catch(j){$={kind:"nothing",reason:`compaction failed: ${j instanceof Error?j.message:String(j)} \u2014 the session is unchanged`}}finally{z.bindAbort?.(null),z.state.busy=!1}if($.kind==="nothing"){z.renderer.addSystemNote($.reason,$.reason.startsWith("compaction failed")?"error":"info"),z.pushStatus();return}let Q=$z(V.messages())??z.defaultMode;if(Q!==z.modes.mode)V.append(Zz({from:Q,to:z.modes.mode},V.messages().at(-1)?.id??null));z.replayHistory(),z.refreshUsage(),z.pushStatus(),z.renderer.addSystemNote(Qz($,J))}function JJ(z){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let J=z.store().id,V=z.modes.mode,Z=Kz();if(z.switchSession(Z,!1),z.modes.mode!==V){z.modes.toggle(V);let $=z.modes.modelFor();z.state.mode=V,z.state.model=$.model,z.state.provider=$.provider,z.pushStatus()}z.renderer.addSystemNote(`cleared \u2014 fresh session ${Z.slice(0,8)} in the same directory; session ${J.slice(0,8)} kept (/resume ${J.slice(0,8)})`)}async function VJ(z){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let J=jz("/init",z.cwd);if(J===void 0)return;z.renderer.addSystemNote(oz(rz(z.cwd,U))?`${U} exists \u2014 asking the agent for targeted improvements (edits go through the usual approval)`:`analysing the repository to write ${U} (the write goes through the usual approval)`),await z.submit(J)}async function ZJ(z,J,V={}){let Z=z.filter((j)=>j.role==="assistant").map((j)=>M(j.parts)).filter((j)=>j.trim()!=="");if(Z.length===0)return{text:"nothing to copy \u2014 no assistant message with text yet",tone:"warn"};let $=Z[Z.length-J];if($===void 0)return{text:`nothing to copy \u2014 only ${Z.length} assistant message${Z.length===1?"":"s"} with text (asked for number ${J} from the end)`,tone:"warn"};let Q=await s($,V);if(Q.ok)return{text:`copied ${J===1?"the last assistant message":`assistant message ${J} from the end`} (${$.length} chars) to the clipboard via ${Q.tool}`,tone:"info"};return{text:`clipboard unavailable \u2014 tried ${Q.tried.join(", ")||"nothing"}${Q.detail?` (${Q.detail})`:""}; the text stays in the transcript`,tone:"warn"}}async function $J(z,J){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let V=J===""?1:/^[1-9]\d*$/.test(J)?Number(J):NaN;if(Number.isNaN(V)){z.renderer.addSystemNote("usage: /copy [n] \u2014 copies the last assistant message; n counts back from the latest (2 = the one before)","warn");return}let Z=await ZJ(z.store().messages(),V,z.clipboard??{});z.renderer.addSystemNote(Z.text,Z.tone)}async function aJ(z,J,V){switch(J){case"compact":return zJ(z,V);case"clear":return JJ(z);case"init":return VJ(z);case"copy":return $J(z,V);default:return}}
38
- export{Pz as Ea,h as Fa,PJ as Ga,DJ as Ha,Lz as Ia,Iz as Ja,OJ as Ka,MJ as La,m as Ma,bJ as Na,kJ as Oa,E as Pa,SJ as Qa,o as Ra,dJ as Sa,ez as Ta,nJ as Ua,ZJ as Va,aJ as Wa,JV as Xa,VV as Ya,ZV as Za,$V as _a,jV as $a,KV as ab,QV as bb,GJ as cb};