@epoch-ai/cli 2.2.4 → 2.2.5

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 (711) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +18 -179
  3. package/.artifacts/unit/junit.xml +0 -2823
  4. package/.project-map/backups/20260530_223453/.project-map.json +0 -90101
  5. package/.project-map/backups/20260530_223507/.project-map.json +0 -90101
  6. package/.project-map/backups/20260530_223512/.project-map.json +0 -90101
  7. package/.project-map/backups/20260530_223512/map.toon +0 -666
  8. package/.project-map/backups/20260530_223516/.project-map.json +0 -90101
  9. package/.project-map/backups/20260530_223516/map.toon +0 -666
  10. package/.project-map/backups/20260530_223520/.project-map.json +0 -90101
  11. package/.project-map/backups/20260530_223520/map.toon +0 -666
  12. package/AGENTS.md +0 -47
  13. package/BUN_SHELL_MIGRATION_PLAN.md +0 -136
  14. package/Dockerfile +0 -18
  15. package/README.md +0 -15
  16. package/bunfig.toml +0 -7
  17. package/drizzle.config.ts +0 -10
  18. package/git +0 -0
  19. package/migration/20260127222353_familiar_lady_ursula/migration.sql +0 -90
  20. package/migration/20260127222353_familiar_lady_ursula/snapshot.json +0 -796
  21. package/migration/20260211171708_add_project_commands/migration.sql +0 -1
  22. package/migration/20260211171708_add_project_commands/snapshot.json +0 -806
  23. package/migration/20260213144116_wakeful_the_professor/migration.sql +0 -11
  24. package/migration/20260213144116_wakeful_the_professor/snapshot.json +0 -897
  25. package/migration/20260225215848_workspace/migration.sql +0 -7
  26. package/migration/20260225215848_workspace/snapshot.json +0 -959
  27. package/migration/20260227213759_add_session_workspace_id/migration.sql +0 -2
  28. package/migration/20260227213759_add_session_workspace_id/snapshot.json +0 -983
  29. package/migration/20260228203230_blue_harpoon/migration.sql +0 -17
  30. package/migration/20260228203230_blue_harpoon/snapshot.json +0 -1102
  31. package/migration/20260303231226_add_workspace_fields/migration.sql +0 -5
  32. package/migration/20260303231226_add_workspace_fields/snapshot.json +0 -1013
  33. package/migration/20260309230000_move_org_to_state/migration.sql +0 -3
  34. package/migration/20260309230000_move_org_to_state/snapshot.json +0 -1156
  35. package/migration/20260312043431_session_message_cursor/migration.sql +0 -4
  36. package/migration/20260312043431_session_message_cursor/snapshot.json +0 -1168
  37. package/migration/20260323234822_events/migration.sql +0 -13
  38. package/migration/20260323234822_events/snapshot.json +0 -1271
  39. package/migration/20260418092949_add_yolo_to_session/migration.sql +0 -2
  40. package/migration/20260418092949_add_yolo_to_session/snapshot.json +0 -1199
  41. package/migration/20260419120000_add_intervention_to_session/migration.sql +0 -2
  42. package/parsers-config.ts +0 -290
  43. package/script/build-node.ts +0 -71
  44. package/script/build.ts +0 -255
  45. package/script/check-migrations.ts +0 -16
  46. package/script/fix-node-pty.ts +0 -28
  47. package/script/publish.ts +0 -184
  48. package/script/schema.ts +0 -63
  49. package/script/seed-e2e.ts +0 -60
  50. package/script/upgrade-opentui.ts +0 -64
  51. package/specs/effect-migration.md +0 -310
  52. package/specs/tui-plugins.md +0 -436
  53. package/specs/v2.md +0 -14
  54. package/src/account/account.sql.ts +0 -39
  55. package/src/account/index.ts +0 -465
  56. package/src/account/repo.ts +0 -163
  57. package/src/account/schema.ts +0 -91
  58. package/src/acp/README.md +0 -174
  59. package/src/acp/agent.ts +0 -1847
  60. package/src/acp/session.ts +0 -116
  61. package/src/acp/types.ts +0 -24
  62. package/src/agent/agent.ts +0 -445
  63. package/src/agent/generate.txt +0 -75
  64. package/src/agent/prompt/compaction.txt +0 -15
  65. package/src/agent/prompt/explore.txt +0 -9
  66. package/src/agent/prompt/summary.txt +0 -11
  67. package/src/agent/prompt/title.txt +0 -44
  68. package/src/auth/index.ts +0 -110
  69. package/src/bus/bus-event.ts +0 -40
  70. package/src/bus/global.ts +0 -10
  71. package/src/bus/index.ts +0 -232
  72. package/src/cli/bootstrap.ts +0 -17
  73. package/src/cli/cmd/account.ts +0 -257
  74. package/src/cli/cmd/acp.ts +0 -70
  75. package/src/cli/cmd/agent.ts +0 -245
  76. package/src/cli/cmd/cmd.ts +0 -7
  77. package/src/cli/cmd/db.ts +0 -119
  78. package/src/cli/cmd/debug/agent.ts +0 -167
  79. package/src/cli/cmd/debug/config.ts +0 -16
  80. package/src/cli/cmd/debug/file.ts +0 -97
  81. package/src/cli/cmd/debug/index.ts +0 -48
  82. package/src/cli/cmd/debug/lsp.ts +0 -53
  83. package/src/cli/cmd/debug/ripgrep.ts +0 -87
  84. package/src/cli/cmd/debug/scrap.ts +0 -16
  85. package/src/cli/cmd/debug/skill.ts +0 -16
  86. package/src/cli/cmd/debug/snapshot.ts +0 -52
  87. package/src/cli/cmd/export.ts +0 -89
  88. package/src/cli/cmd/generate.ts +0 -38
  89. package/src/cli/cmd/github.ts +0 -1639
  90. package/src/cli/cmd/import.ts +0 -169
  91. package/src/cli/cmd/mcp.ts +0 -754
  92. package/src/cli/cmd/models.ts +0 -78
  93. package/src/cli/cmd/plug.ts +0 -233
  94. package/src/cli/cmd/pr.ts +0 -127
  95. package/src/cli/cmd/providers.ts +0 -478
  96. package/src/cli/cmd/run.ts +0 -681
  97. package/src/cli/cmd/serve.ts +0 -24
  98. package/src/cli/cmd/session.ts +0 -159
  99. package/src/cli/cmd/stats.ts +0 -410
  100. package/src/cli/cmd/tui/app.tsx +0 -945
  101. package/src/cli/cmd/tui/attach.ts +0 -88
  102. package/src/cli/cmd/tui/component/border.tsx +0 -21
  103. package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  104. package/src/cli/cmd/tui/component/dialog-command.tsx +0 -171
  105. package/src/cli/cmd/tui/component/dialog-console-org.tsx +0 -103
  106. package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  107. package/src/cli/cmd/tui/component/dialog-model.tsx +0 -190
  108. package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -364
  109. package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -108
  110. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  111. package/src/cli/cmd/tui/component/dialog-skill.tsx +0 -36
  112. package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -87
  113. package/src/cli/cmd/tui/component/dialog-status.tsx +0 -168
  114. package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  115. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  116. package/src/cli/cmd/tui/component/dialog-variant.tsx +0 -39
  117. package/src/cli/cmd/tui/component/dialog-workspace-list.tsx +0 -320
  118. package/src/cli/cmd/tui/component/error-component.tsx +0 -92
  119. package/src/cli/cmd/tui/component/logo.tsx +0 -85
  120. package/src/cli/cmd/tui/component/plugin-route-missing.tsx +0 -14
  121. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -672
  122. package/src/cli/cmd/tui/component/prompt/frecency.tsx +0 -90
  123. package/src/cli/cmd/tui/component/prompt/history.tsx +0 -109
  124. package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1336
  125. package/src/cli/cmd/tui/component/prompt/part.ts +0 -16
  126. package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
  127. package/src/cli/cmd/tui/component/spinner.tsx +0 -24
  128. package/src/cli/cmd/tui/component/startup-loading.tsx +0 -63
  129. package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
  130. package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
  131. package/src/cli/cmd/tui/component/workspace/dialog-session-list.tsx +0 -151
  132. package/src/cli/cmd/tui/context/args.tsx +0 -15
  133. package/src/cli/cmd/tui/context/directory.ts +0 -13
  134. package/src/cli/cmd/tui/context/exit.tsx +0 -60
  135. package/src/cli/cmd/tui/context/helper.tsx +0 -25
  136. package/src/cli/cmd/tui/context/keybind.tsx +0 -105
  137. package/src/cli/cmd/tui/context/kv.tsx +0 -52
  138. package/src/cli/cmd/tui/context/local.tsx +0 -456
  139. package/src/cli/cmd/tui/context/plugin-keybinds.ts +0 -41
  140. package/src/cli/cmd/tui/context/prompt.tsx +0 -18
  141. package/src/cli/cmd/tui/context/route.tsx +0 -52
  142. package/src/cli/cmd/tui/context/sdk.tsx +0 -115
  143. package/src/cli/cmd/tui/context/sync.tsx +0 -516
  144. package/src/cli/cmd/tui/context/theme/aura.json +0 -69
  145. package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  146. package/src/cli/cmd/tui/context/theme/carbonfox.json +0 -248
  147. package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
  148. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  149. package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  150. package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  151. package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
  152. package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  153. package/src/cli/cmd/tui/context/theme/epochcli.json +0 -245
  154. package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  155. package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  156. package/src/cli/cmd/tui/context/theme/github.json +0 -233
  157. package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -242
  158. package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  159. package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -237
  160. package/src/cli/cmd/tui/context/theme/material.json +0 -235
  161. package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  162. package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  163. package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  164. package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  165. package/src/cli/cmd/tui/context/theme/nord.json +0 -223
  166. package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  167. package/src/cli/cmd/tui/context/theme/orng.json +0 -249
  168. package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
  169. package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  170. package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  171. package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  172. package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  173. package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  174. package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  175. package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  176. package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  177. package/src/cli/cmd/tui/context/theme.tsx +0 -1236
  178. package/src/cli/cmd/tui/context/tui-config.tsx +0 -9
  179. package/src/cli/cmd/tui/event.ts +0 -48
  180. package/src/cli/cmd/tui/feature-plugins/home/footer.tsx +0 -93
  181. package/src/cli/cmd/tui/feature-plugins/home/tips-view.tsx +0 -145
  182. package/src/cli/cmd/tui/feature-plugins/home/tips.tsx +0 -50
  183. package/src/cli/cmd/tui/feature-plugins/sidebar/context.tsx +0 -63
  184. package/src/cli/cmd/tui/feature-plugins/sidebar/files.tsx +0 -62
  185. package/src/cli/cmd/tui/feature-plugins/sidebar/footer.tsx +0 -93
  186. package/src/cli/cmd/tui/feature-plugins/sidebar/lsp.tsx +0 -66
  187. package/src/cli/cmd/tui/feature-plugins/sidebar/mcp.tsx +0 -96
  188. package/src/cli/cmd/tui/feature-plugins/sidebar/todo.tsx +0 -48
  189. package/src/cli/cmd/tui/feature-plugins/system/plugins.tsx +0 -270
  190. package/src/cli/cmd/tui/plugin/api.tsx +0 -397
  191. package/src/cli/cmd/tui/plugin/index.ts +0 -3
  192. package/src/cli/cmd/tui/plugin/internal.ts +0 -27
  193. package/src/cli/cmd/tui/plugin/runtime.ts +0 -1031
  194. package/src/cli/cmd/tui/plugin/slots.tsx +0 -60
  195. package/src/cli/cmd/tui/routes/home.tsx +0 -84
  196. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -65
  197. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -110
  198. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
  199. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
  200. package/src/cli/cmd/tui/routes/session/footer.tsx +0 -91
  201. package/src/cli/cmd/tui/routes/session/index.tsx +0 -2161
  202. package/src/cli/cmd/tui/routes/session/permission.tsx +0 -691
  203. package/src/cli/cmd/tui/routes/session/question.tsx +0 -468
  204. package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -70
  205. package/src/cli/cmd/tui/routes/session/subagent-footer.tsx +0 -131
  206. package/src/cli/cmd/tui/thread.ts +0 -241
  207. package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -59
  208. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -89
  209. package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -211
  210. package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -40
  211. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -115
  212. package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -417
  213. package/src/cli/cmd/tui/ui/dialog.tsx +0 -192
  214. package/src/cli/cmd/tui/ui/link.tsx +0 -28
  215. package/src/cli/cmd/tui/ui/spinner.ts +0 -368
  216. package/src/cli/cmd/tui/ui/toast.tsx +0 -100
  217. package/src/cli/cmd/tui/util/clipboard.ts +0 -192
  218. package/src/cli/cmd/tui/util/editor.ts +0 -37
  219. package/src/cli/cmd/tui/util/model.ts +0 -23
  220. package/src/cli/cmd/tui/util/provider-origin.ts +0 -20
  221. package/src/cli/cmd/tui/util/scroll.ts +0 -23
  222. package/src/cli/cmd/tui/util/selection.ts +0 -25
  223. package/src/cli/cmd/tui/util/signal.ts +0 -7
  224. package/src/cli/cmd/tui/util/terminal.ts +0 -114
  225. package/src/cli/cmd/tui/util/transcript.ts +0 -112
  226. package/src/cli/cmd/tui/win32.ts +0 -129
  227. package/src/cli/cmd/tui/worker.ts +0 -195
  228. package/src/cli/cmd/uninstall.ts +0 -353
  229. package/src/cli/cmd/upgrade.ts +0 -73
  230. package/src/cli/cmd/web.ts +0 -81
  231. package/src/cli/effect/prompt.ts +0 -25
  232. package/src/cli/error.ts +0 -46
  233. package/src/cli/heap.ts +0 -59
  234. package/src/cli/logo.ts +0 -6
  235. package/src/cli/network.ts +0 -60
  236. package/src/cli/ui.ts +0 -133
  237. package/src/cli/upgrade.ts +0 -31
  238. package/src/command/index.ts +0 -197
  239. package/src/command/template/initialize.txt +0 -66
  240. package/src/command/template/review.txt +0 -101
  241. package/src/config/config.ts +0 -1610
  242. package/src/config/console-state.ts +0 -15
  243. package/src/config/markdown.ts +0 -99
  244. package/src/config/paths.ts +0 -167
  245. package/src/config/tui-migrate.ts +0 -155
  246. package/src/config/tui-schema.ts +0 -37
  247. package/src/config/tui.ts +0 -179
  248. package/src/config/validator.ts +0 -52
  249. package/src/control-plane/adaptors/index.ts +0 -20
  250. package/src/control-plane/adaptors/worktree.ts +0 -42
  251. package/src/control-plane/schema.ts +0 -17
  252. package/src/control-plane/sse.ts +0 -66
  253. package/src/control-plane/types.ts +0 -32
  254. package/src/control-plane/workspace.sql.ts +0 -17
  255. package/src/control-plane/workspace.ts +0 -168
  256. package/src/effect/cross-spawn-spawner.ts +0 -502
  257. package/src/effect/instance-ref.ts +0 -6
  258. package/src/effect/instance-registry.ts +0 -12
  259. package/src/effect/instance-state.ts +0 -82
  260. package/src/effect/run-service.ts +0 -33
  261. package/src/effect/runner.ts +0 -216
  262. package/src/env/index.ts +0 -28
  263. package/src/file/ignore.ts +0 -82
  264. package/src/file/index.ts +0 -686
  265. package/src/file/protected.ts +0 -59
  266. package/src/file/ripgrep.ts +0 -376
  267. package/src/file/time.ts +0 -133
  268. package/src/file/watcher.ts +0 -172
  269. package/src/filesystem/index.ts +0 -236
  270. package/src/flag/flag.ts +0 -157
  271. package/src/format/formatter.ts +0 -413
  272. package/src/format/index.ts +0 -203
  273. package/src/git/index.ts +0 -303
  274. package/src/global/index.ts +0 -54
  275. package/src/id/id.ts +0 -85
  276. package/src/ide/index.ts +0 -74
  277. package/src/index.ts +0 -253
  278. package/src/installation/index.ts +0 -355
  279. package/src/installation/meta.ts +0 -7
  280. package/src/lsp/client.ts +0 -256
  281. package/src/lsp/index.ts +0 -558
  282. package/src/lsp/language.ts +0 -120
  283. package/src/lsp/launch.ts +0 -21
  284. package/src/lsp/server.ts +0 -1968
  285. package/src/mcp/auth.ts +0 -173
  286. package/src/mcp/index.ts +0 -1250
  287. package/src/mcp/oauth-callback.ts +0 -216
  288. package/src/mcp/oauth-provider.ts +0 -185
  289. package/src/mcp/schema-loader.ts +0 -82
  290. package/src/node.ts +0 -1
  291. package/src/npm/index.ts +0 -188
  292. package/src/patch/index.ts +0 -680
  293. package/src/permission/arity.ts +0 -163
  294. package/src/permission/evaluate.ts +0 -15
  295. package/src/permission/index.ts +0 -323
  296. package/src/permission/schema.ts +0 -17
  297. package/src/plugin/cloudflare.ts +0 -67
  298. package/src/plugin/codex.ts +0 -608
  299. package/src/plugin/github-copilot/copilot.ts +0 -361
  300. package/src/plugin/github-copilot/models.ts +0 -144
  301. package/src/plugin/index.ts +0 -288
  302. package/src/plugin/install.ts +0 -439
  303. package/src/plugin/loader.ts +0 -174
  304. package/src/plugin/meta.ts +0 -188
  305. package/src/plugin/shared.ts +0 -323
  306. package/src/project/bootstrap.ts +0 -29
  307. package/src/project/instance.ts +0 -175
  308. package/src/project/project.sql.ts +0 -16
  309. package/src/project/project.ts +0 -519
  310. package/src/project/schema.ts +0 -16
  311. package/src/project/state.ts +0 -70
  312. package/src/project/vcs.ts +0 -240
  313. package/src/provider/auth.ts +0 -253
  314. package/src/provider/error.ts +0 -297
  315. package/src/provider/models.ts +0 -162
  316. package/src/provider/provider.ts +0 -1776
  317. package/src/provider/schema.ts +0 -38
  318. package/src/provider/sdk/copilot/README.md +0 -5
  319. package/src/provider/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +0 -170
  320. package/src/provider/sdk/copilot/chat/get-response-metadata.ts +0 -15
  321. package/src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +0 -19
  322. package/src/provider/sdk/copilot/chat/openai-compatible-api-types.ts +0 -64
  323. package/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts +0 -814
  324. package/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts +0 -28
  325. package/src/provider/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +0 -44
  326. package/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts +0 -83
  327. package/src/provider/sdk/copilot/copilot-provider.ts +0 -100
  328. package/src/provider/sdk/copilot/index.ts +0 -2
  329. package/src/provider/sdk/copilot/openai-compatible-error.ts +0 -27
  330. package/src/provider/sdk/copilot/responses/convert-to-openai-responses-input.ts +0 -335
  331. package/src/provider/sdk/copilot/responses/map-openai-responses-finish-reason.ts +0 -22
  332. package/src/provider/sdk/copilot/responses/openai-config.ts +0 -18
  333. package/src/provider/sdk/copilot/responses/openai-error.ts +0 -22
  334. package/src/provider/sdk/copilot/responses/openai-responses-api-types.ts +0 -214
  335. package/src/provider/sdk/copilot/responses/openai-responses-language-model.ts +0 -1769
  336. package/src/provider/sdk/copilot/responses/openai-responses-prepare-tools.ts +0 -173
  337. package/src/provider/sdk/copilot/responses/openai-responses-settings.ts +0 -1
  338. package/src/provider/sdk/copilot/responses/tool/code-interpreter.ts +0 -87
  339. package/src/provider/sdk/copilot/responses/tool/file-search.ts +0 -127
  340. package/src/provider/sdk/copilot/responses/tool/image-generation.ts +0 -114
  341. package/src/provider/sdk/copilot/responses/tool/local-shell.ts +0 -64
  342. package/src/provider/sdk/copilot/responses/tool/web-search-preview.ts +0 -103
  343. package/src/provider/sdk/copilot/responses/tool/web-search.ts +0 -102
  344. package/src/provider/transform.ts +0 -1124
  345. package/src/pty/index.ts +0 -397
  346. package/src/pty/pty.bun.ts +0 -26
  347. package/src/pty/pty.node.ts +0 -27
  348. package/src/pty/pty.ts +0 -25
  349. package/src/pty/schema.ts +0 -17
  350. package/src/question/index.ts +0 -224
  351. package/src/question/schema.ts +0 -17
  352. package/src/server/error.ts +0 -36
  353. package/src/server/event.ts +0 -7
  354. package/src/server/instance.ts +0 -315
  355. package/src/server/mdns.ts +0 -60
  356. package/src/server/middleware.ts +0 -33
  357. package/src/server/projectors.ts +0 -28
  358. package/src/server/proxy.ts +0 -130
  359. package/src/server/router.ts +0 -105
  360. package/src/server/routes/config.ts +0 -92
  361. package/src/server/routes/event.ts +0 -83
  362. package/src/server/routes/experimental.ts +0 -374
  363. package/src/server/routes/file.ts +0 -197
  364. package/src/server/routes/global.ts +0 -312
  365. package/src/server/routes/mcp.ts +0 -225
  366. package/src/server/routes/permission.ts +0 -69
  367. package/src/server/routes/project.ts +0 -118
  368. package/src/server/routes/provider.ts +0 -171
  369. package/src/server/routes/pty.ts +0 -210
  370. package/src/server/routes/question.ts +0 -99
  371. package/src/server/routes/session.ts +0 -984
  372. package/src/server/routes/tui.ts +0 -378
  373. package/src/server/routes/workspace.ts +0 -94
  374. package/src/server/server.ts +0 -353
  375. package/src/session/compaction.ts +0 -86
  376. package/src/session/index.ts +0 -904
  377. package/src/session/instruction.ts +0 -261
  378. package/src/session/llm/monitor.ts +0 -87
  379. package/src/session/llm.ts +0 -1676
  380. package/src/session/message-v2.ts +0 -1082
  381. package/src/session/message.ts +0 -191
  382. package/src/session/overflow.ts +0 -35
  383. package/src/session/processor.ts +0 -635
  384. package/src/session/projectors.ts +0 -136
  385. package/src/session/prompt/build-switch.txt +0 -5
  386. package/src/session/prompt/builder.ts +0 -135
  387. package/src/session/prompt/default.txt +0 -11
  388. package/src/session/prompt/engine.ts +0 -1072
  389. package/src/session/prompt/gemma4.txt +0 -1
  390. package/src/session/prompt/max-steps.txt +0 -16
  391. package/src/session/prompt/orchestrator.ts +0 -426
  392. package/src/session/prompt/plan.txt +0 -28
  393. package/src/session/prompt/qwen.txt +0 -19
  394. package/src/session/prompt/resolver.ts +0 -670
  395. package/src/session/prompt/router.ts +0 -197
  396. package/src/session/prompt/state.ts +0 -96
  397. package/src/session/prompt/types.ts +0 -115
  398. package/src/session/prompt/utils.ts +0 -15
  399. package/src/session/prompt.ts +0 -362
  400. package/src/session/retry.ts +0 -106
  401. package/src/session/revert.ts +0 -176
  402. package/src/session/sanitizer.ts +0 -125
  403. package/src/session/schema.ts +0 -38
  404. package/src/session/session.sql.ts +0 -106
  405. package/src/session/status.ts +0 -102
  406. package/src/session/summary.ts +0 -183
  407. package/src/session/system.ts +0 -79
  408. package/src/session/todo.ts +0 -166
  409. package/src/session/worker.ts +0 -382
  410. package/src/shell/shell.ts +0 -110
  411. package/src/skill/discovery.ts +0 -116
  412. package/src/skill/index.ts +0 -287
  413. package/src/snapshot/index.ts +0 -726
  414. package/src/sql.d.ts +0 -4
  415. package/src/storage/db.bun.ts +0 -8
  416. package/src/storage/db.node.ts +0 -8
  417. package/src/storage/db.ts +0 -174
  418. package/src/storage/json-migration.ts +0 -387
  419. package/src/storage/schema.sql.ts +0 -10
  420. package/src/storage/schema.ts +0 -4
  421. package/src/storage/storage.ts +0 -353
  422. package/src/sync/README.md +0 -179
  423. package/src/sync/event.sql.ts +0 -16
  424. package/src/sync/index.ts +0 -263
  425. package/src/sync/schema.ts +0 -14
  426. package/src/tool/apply_patch.ts +0 -281
  427. package/src/tool/apply_patch.txt +0 -1
  428. package/src/tool/arbitration.txt +0 -5
  429. package/src/tool/bash.ts +0 -494
  430. package/src/tool/bash.txt +0 -2
  431. package/src/tool/batch.ts +0 -183
  432. package/src/tool/batch.txt +0 -1
  433. package/src/tool/codesearch.ts +0 -132
  434. package/src/tool/codesearch.txt +0 -1
  435. package/src/tool/edit.ts +0 -734
  436. package/src/tool/edit.txt +0 -1
  437. package/src/tool/external-directory.ts +0 -46
  438. package/src/tool/glob.ts +0 -73
  439. package/src/tool/glob.txt +0 -2
  440. package/src/tool/grep.ts +0 -156
  441. package/src/tool/grep.txt +0 -2
  442. package/src/tool/invalid.ts +0 -20
  443. package/src/tool/ls.ts +0 -121
  444. package/src/tool/ls.txt +0 -1
  445. package/src/tool/lsp.ts +0 -97
  446. package/src/tool/lsp.txt +0 -1
  447. package/src/tool/multiedit.ts +0 -46
  448. package/src/tool/multiedit.txt +0 -1
  449. package/src/tool/plan-enter.txt +0 -14
  450. package/src/tool/plan-exit.txt +0 -13
  451. package/src/tool/plan.ts +0 -131
  452. package/src/tool/question.ts +0 -46
  453. package/src/tool/question.txt +0 -10
  454. package/src/tool/read.ts +0 -332
  455. package/src/tool/read.txt +0 -1
  456. package/src/tool/registry.ts +0 -288
  457. package/src/tool/revert.ts +0 -37
  458. package/src/tool/schema.ts +0 -17
  459. package/src/tool/skill.ts +0 -105
  460. package/src/tool/task.ts +0 -150
  461. package/src/tool/task.txt +0 -3
  462. package/src/tool/task_complete.ts +0 -21
  463. package/src/tool/tool.ts +0 -112
  464. package/src/tool/truncate.ts +0 -144
  465. package/src/tool/truncation-dir.ts +0 -4
  466. package/src/tool/webfetch.ts +0 -206
  467. package/src/tool/webfetch.txt +0 -1
  468. package/src/tool/websearch.ts +0 -150
  469. package/src/tool/websearch.txt +0 -1
  470. package/src/tool/write.ts +0 -101
  471. package/src/tool/write.txt +0 -1
  472. package/src/util/abort.ts +0 -35
  473. package/src/util/ai-sdk.ts +0 -59
  474. package/src/util/archive.ts +0 -17
  475. package/src/util/color.ts +0 -19
  476. package/src/util/context.ts +0 -25
  477. package/src/util/data-url.ts +0 -9
  478. package/src/util/defer.ts +0 -12
  479. package/src/util/effect-http-client.ts +0 -11
  480. package/src/util/effect-zod.ts +0 -98
  481. package/src/util/error.ts +0 -77
  482. package/src/util/filesystem.ts +0 -245
  483. package/src/util/flock.ts +0 -333
  484. package/src/util/fn.ts +0 -21
  485. package/src/util/format.ts +0 -20
  486. package/src/util/glob.ts +0 -34
  487. package/src/util/hash.ts +0 -7
  488. package/src/util/iife.ts +0 -3
  489. package/src/util/keybind.ts +0 -103
  490. package/src/util/lazy.ts +0 -23
  491. package/src/util/locale.ts +0 -81
  492. package/src/util/lock.ts +0 -98
  493. package/src/util/log-parser.ts +0 -114
  494. package/src/util/log.ts +0 -250
  495. package/src/util/network.ts +0 -23
  496. package/src/util/process.ts +0 -176
  497. package/src/util/queue.ts +0 -32
  498. package/src/util/record.ts +0 -3
  499. package/src/util/rpc.ts +0 -66
  500. package/src/util/schema.ts +0 -53
  501. package/src/util/scrap.ts +0 -10
  502. package/src/util/session-analyzer.ts +0 -331
  503. package/src/util/session-telemetry.ts +0 -91
  504. package/src/util/signal.ts +0 -12
  505. package/src/util/timeout.ts +0 -14
  506. package/src/util/token.ts +0 -7
  507. package/src/util/tokenizer.ts +0 -50
  508. package/src/util/toon.ts +0 -45
  509. package/src/util/update-schema.ts +0 -13
  510. package/src/util/which.ts +0 -14
  511. package/src/util/wildcard.ts +0 -59
  512. package/src/worktree/index.ts +0 -612
  513. package/sst-env.d.ts +0 -10
  514. package/test/AGENTS.md +0 -81
  515. package/test/account/repo.test.ts +0 -326
  516. package/test/account/service.test.ts +0 -393
  517. package/test/acp/agent-interface.test.ts +0 -51
  518. package/test/acp/event-subscription.test.ts +0 -685
  519. package/test/agent/agent.test.ts +0 -716
  520. package/test/auth/auth.test.ts +0 -58
  521. package/test/bus/bus-effect.test.ts +0 -164
  522. package/test/bus/bus-integration.test.ts +0 -87
  523. package/test/bus/bus.test.ts +0 -219
  524. package/test/cli/account.test.ts +0 -26
  525. package/test/cli/cmd/tui/prompt-part.test.ts +0 -47
  526. package/test/cli/github-action.test.ts +0 -198
  527. package/test/cli/github-remote.test.ts +0 -80
  528. package/test/cli/plugin-auth-picker.test.ts +0 -120
  529. package/test/cli/tui/keybind-plugin.test.ts +0 -90
  530. package/test/cli/tui/plugin-add.test.ts +0 -107
  531. package/test/cli/tui/plugin-install.test.ts +0 -89
  532. package/test/cli/tui/plugin-lifecycle.test.ts +0 -225
  533. package/test/cli/tui/plugin-loader-entrypoint.test.ts +0 -492
  534. package/test/cli/tui/plugin-loader-pure.test.ts +0 -72
  535. package/test/cli/tui/plugin-loader.test.ts +0 -752
  536. package/test/cli/tui/plugin-toggle.test.ts +0 -159
  537. package/test/cli/tui/slot-replace.test.tsx +0 -47
  538. package/test/cli/tui/theme-store.test.ts +0 -51
  539. package/test/cli/tui/thread.test.ts +0 -128
  540. package/test/cli/tui/transcript.test.ts +0 -426
  541. package/test/config/agent-color.test.ts +0 -71
  542. package/test/config/config.test.ts +0 -2337
  543. package/test/config/fixtures/empty-frontmatter.md +0 -4
  544. package/test/config/fixtures/frontmatter.md +0 -28
  545. package/test/config/fixtures/markdown-header.md +0 -11
  546. package/test/config/fixtures/no-frontmatter.md +0 -1
  547. package/test/config/fixtures/weird-model-id.md +0 -13
  548. package/test/config/markdown.test.ts +0 -228
  549. package/test/config/tui.test.ts +0 -800
  550. package/test/control-plane/sse.test.ts +0 -56
  551. package/test/effect/cross-spawn-spawner.test.ts +0 -412
  552. package/test/effect/instance-state.test.ts +0 -482
  553. package/test/effect/run-service.test.ts +0 -46
  554. package/test/effect/runner.test.ts +0 -523
  555. package/test/fake/provider.ts +0 -82
  556. package/test/file/fsmonitor.test.ts +0 -62
  557. package/test/file/ignore.test.ts +0 -10
  558. package/test/file/index.test.ts +0 -946
  559. package/test/file/path-traversal.test.ts +0 -198
  560. package/test/file/ripgrep.test.ts +0 -54
  561. package/test/file/time.test.ts +0 -445
  562. package/test/file/watcher.test.ts +0 -247
  563. package/test/filesystem/filesystem.test.ts +0 -319
  564. package/test/fixture/db.ts +0 -11
  565. package/test/fixture/fixture.test.ts +0 -26
  566. package/test/fixture/fixture.ts +0 -172
  567. package/test/fixture/flock-worker.ts +0 -72
  568. package/test/fixture/lsp/fake-lsp-server.js +0 -77
  569. package/test/fixture/plug-worker.ts +0 -93
  570. package/test/fixture/plugin-meta-worker.ts +0 -26
  571. package/test/fixture/skills/agents-sdk/SKILL.md +0 -152
  572. package/test/fixture/skills/agents-sdk/references/callable.md +0 -92
  573. package/test/fixture/skills/cloudflare/SKILL.md +0 -211
  574. package/test/fixture/skills/index.json +0 -6
  575. package/test/fixture/tui-plugin.ts +0 -328
  576. package/test/fixture/tui-runtime.ts +0 -27
  577. package/test/format/format.test.ts +0 -171
  578. package/test/git/git.test.ts +0 -128
  579. package/test/ide/ide.test.ts +0 -82
  580. package/test/installation/installation.test.ts +0 -152
  581. package/test/keybind.test.ts +0 -421
  582. package/test/lib/effect.ts +0 -53
  583. package/test/lib/filesystem.ts +0 -10
  584. package/test/lib/llm-server.ts +0 -794
  585. package/test/lsp/client.test.ts +0 -95
  586. package/test/lsp/index.test.ts +0 -133
  587. package/test/lsp/launch.test.ts +0 -22
  588. package/test/lsp/lifecycle.test.ts +0 -147
  589. package/test/mcp/headers.test.ts +0 -153
  590. package/test/mcp/lifecycle.test.ts +0 -750
  591. package/test/mcp/oauth-auto-connect.test.ts +0 -199
  592. package/test/mcp/oauth-browser.test.ts +0 -249
  593. package/test/mcp/sc-approve-validator.test.ts +0 -431
  594. package/test/memory/abort-leak.test.ts +0 -137
  595. package/test/npm.test.ts +0 -18
  596. package/test/patch/patch.test.ts +0 -348
  597. package/test/permission/arity.test.ts +0 -33
  598. package/test/permission/next.test.ts +0 -1123
  599. package/test/permission-task.test.ts +0 -323
  600. package/test/plugin/auth-override.test.ts +0 -74
  601. package/test/plugin/codex.test.ts +0 -123
  602. package/test/plugin/github-copilot-models.test.ts +0 -117
  603. package/test/plugin/install-concurrency.test.ts +0 -140
  604. package/test/plugin/install.test.ts +0 -570
  605. package/test/plugin/loader-shared.test.ts +0 -1136
  606. package/test/plugin/meta.test.ts +0 -137
  607. package/test/plugin/shared.test.ts +0 -88
  608. package/test/plugin/trigger.test.ts +0 -111
  609. package/test/preload.ts +0 -90
  610. package/test/project/migrate-global.test.ts +0 -140
  611. package/test/project/project.test.ts +0 -459
  612. package/test/project/state.test.ts +0 -115
  613. package/test/project/vcs.test.ts +0 -228
  614. package/test/project/worktree-remove.test.ts +0 -96
  615. package/test/project/worktree.test.ts +0 -173
  616. package/test/provider/amazon-bedrock.test.ts +0 -447
  617. package/test/provider/copilot/convert-to-copilot-messages.test.ts +0 -523
  618. package/test/provider/copilot/copilot-chat-model.test.ts +0 -592
  619. package/test/provider/error.test.ts +0 -49
  620. package/test/provider/gitlab-duo.test.ts +0 -412
  621. package/test/provider/provider.test.ts +0 -2494
  622. package/test/provider/transform.test.ts +0 -2944
  623. package/test/pty/pty-output-isolation.test.ts +0 -141
  624. package/test/pty/pty-session.test.ts +0 -92
  625. package/test/pty/pty-shell.test.ts +0 -59
  626. package/test/question/question.test.ts +0 -453
  627. package/test/server/global-session-list.test.ts +0 -89
  628. package/test/server/project-init-git.test.ts +0 -121
  629. package/test/server/session-actions.test.ts +0 -83
  630. package/test/server/session-list.test.ts +0 -98
  631. package/test/server/session-messages.test.ts +0 -159
  632. package/test/server/session-select.test.ts +0 -84
  633. package/test/session/compaction.test.ts +0 -683
  634. package/test/session/continuity-handover.test.ts +0 -620
  635. package/test/session/deterministic-handover.test.ts +0 -328
  636. package/test/session/doom-protection.test.ts +0 -247
  637. package/test/session/hard-reset.test.ts +0 -179
  638. package/test/session/instruction.test.ts +0 -286
  639. package/test/session/llm/monitor.test.ts +0 -53
  640. package/test/session/llm-sanitizer.test.ts +0 -90
  641. package/test/session/llm-zones-e2e.test.ts +0 -61
  642. package/test/session/llm.test.ts +0 -1308
  643. package/test/session/mcpx-normalization.test.ts +0 -86
  644. package/test/session/mcpx-syntax-recovery.test.ts +0 -28
  645. package/test/session/message-v2.test.ts +0 -957
  646. package/test/session/messages-pagination.test.ts +0 -885
  647. package/test/session/processor-effect.test.ts +0 -805
  648. package/test/session/prompt/builder.test.ts +0 -71
  649. package/test/session/prompt/engine-loop.test.ts +0 -80
  650. package/test/session/prompt/orchestrator.test.ts +0 -108
  651. package/test/session/prompt/resolver.test.ts +0 -211
  652. package/test/session/prompt/router.test.ts +0 -84
  653. package/test/session/prompt/state.test.ts +0 -57
  654. package/test/session/prompt-effect.test.ts +0 -1241
  655. package/test/session/prompt.test.ts +0 -522
  656. package/test/session/refactor-system-zones.test.ts +0 -241
  657. package/test/session/retry.test.ts +0 -232
  658. package/test/session/revert-compact.test.ts +0 -621
  659. package/test/session/sanitizer.test.ts +0 -61
  660. package/test/session/session.test.ts +0 -142
  661. package/test/session/snapshot-tool-race.test.ts +0 -242
  662. package/test/session/structured-output-integration.test.ts +0 -233
  663. package/test/session/structured-output.test.ts +0 -391
  664. package/test/session/system.test.ts +0 -59
  665. package/test/session/telemetry.test.ts +0 -35
  666. package/test/shell/shell.test.ts +0 -73
  667. package/test/skill/discovery.test.ts +0 -116
  668. package/test/skill/skill.test.ts +0 -392
  669. package/test/snapshot/snapshot.test.ts +0 -1404
  670. package/test/storage/db.test.ts +0 -14
  671. package/test/storage/json-migration.test.ts +0 -791
  672. package/test/storage/storage.test.ts +0 -295
  673. package/test/sync/index.test.ts +0 -191
  674. package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
  675. package/test/tool/apply_patch.test.ts +0 -567
  676. package/test/tool/bash.test.ts +0 -1099
  677. package/test/tool/edit.test.ts +0 -681
  678. package/test/tool/external-directory.test.ts +0 -198
  679. package/test/tool/fixtures/large-image.png +0 -0
  680. package/test/tool/fixtures/models-api.json +0 -65179
  681. package/test/tool/grep.test.ts +0 -111
  682. package/test/tool/question.test.ts +0 -126
  683. package/test/tool/read.test.ts +0 -468
  684. package/test/tool/registry.test.ts +0 -126
  685. package/test/tool/skill.test.ts +0 -167
  686. package/test/tool/task.test.ts +0 -49
  687. package/test/tool/tool-define.test.ts +0 -101
  688. package/test/tool/truncation.test.ts +0 -161
  689. package/test/tool/webfetch.test.ts +0 -101
  690. package/test/tool/write.test.ts +0 -354
  691. package/test/util/data-url.test.ts +0 -14
  692. package/test/util/effect-zod.test.ts +0 -61
  693. package/test/util/error.test.ts +0 -38
  694. package/test/util/filesystem.test.ts +0 -656
  695. package/test/util/flock.test.ts +0 -383
  696. package/test/util/format.test.ts +0 -59
  697. package/test/util/glob.test.ts +0 -164
  698. package/test/util/iife.test.ts +0 -36
  699. package/test/util/lazy.test.ts +0 -50
  700. package/test/util/lock.test.ts +0 -72
  701. package/test/util/log-parser.test.ts +0 -61
  702. package/test/util/module.test.ts +0 -59
  703. package/test/util/process.test.ts +0 -128
  704. package/test/util/telemetry-integration.test.ts +0 -104
  705. package/test/util/timeout.test.ts +0 -21
  706. package/test/util/which.test.ts +0 -100
  707. package/test/util/wildcard.test.ts +0 -90
  708. package/test-regex.js +0 -50
  709. package/tsconfig.json +0 -23
  710. /package/bin/{epochcli → epochcli.cjs} +0 -0
  711. /package/{script/postinstall.mjs → postinstall.mjs} +0 -0
@@ -1,1336 +0,0 @@
1
- import { BoxRenderable, TextareaRenderable, MouseEvent, PasteEvent, decodePasteBytes, t, dim, fg } from "@opentui/core"
2
- import { createEffect, createMemo, onMount, createSignal, onCleanup, on, Show, Switch, Match } from "solid-js"
3
- import "opentui-spinner/solid"
4
- import path from "path"
5
- import { fileURLToPath } from "url"
6
- import { Filesystem } from "@/util/filesystem"
7
- import { useLocal } from "@tui/context/local"
8
- import { useTheme } from "@tui/context/theme"
9
- import { EmptyBorder, SplitBorder } from "@tui/component/border"
10
- import { useSDK } from "@tui/context/sdk"
11
- import { useRoute } from "@tui/context/route"
12
- import { useSync } from "@tui/context/sync"
13
- import { MessageID, PartID } from "@/session/schema"
14
- import { createStore, produce } from "solid-js/store"
15
- import { useKeybind } from "@tui/context/keybind"
16
- import { usePromptHistory, type PromptInfo } from "./history"
17
- import { assign } from "./part"
18
- import { usePromptStash } from "./stash"
19
- import { DialogStash } from "../dialog-stash"
20
- import { type AutocompleteRef, Autocomplete } from "./autocomplete"
21
- import { useCommandDialog } from "../dialog-command"
22
- import { useRenderer, type JSX } from "@opentui/solid"
23
- import { Editor } from "@tui/util/editor"
24
- import { useExit } from "../../context/exit"
25
- import { Clipboard } from "../../util/clipboard"
26
- import type { AssistantMessage, FilePart, UserMessage } from "@epoch-ai/sdk/v2"
27
- import { TuiEvent } from "../../event"
28
- import { iife } from "@/util/iife"
29
- import { Locale } from "@/util/locale"
30
- import { formatDuration } from "@/util/format"
31
- import { createColors, createFrames } from "../../ui/spinner.ts"
32
- import { useDialog } from "@tui/ui/dialog"
33
- import { DialogProvider as DialogProviderConnect } from "../dialog-provider"
34
- import { DialogAlert } from "../../ui/dialog-alert"
35
- import { useToast } from "../../ui/toast"
36
- import { useKV } from "../../context/kv"
37
- import { useTextareaKeybindings } from "../textarea-keybindings"
38
- import { DialogSkill } from "../dialog-skill"
39
- import { CONSOLE_MANAGED_ICON, consoleManagedProviderLabel } from "@tui/util/provider-origin"
40
-
41
- export type PromptProps = {
42
- sessionID?: string
43
- workspaceID?: string
44
- visible?: boolean
45
- disabled?: boolean
46
- onSubmit?: () => void
47
- ref?: (ref: PromptRef | undefined) => void
48
- hint?: JSX.Element
49
- right?: JSX.Element
50
- showPlaceholder?: boolean
51
- placeholders?: {
52
- normal?: string[]
53
- shell?: string[]
54
- }
55
- }
56
-
57
- export type PromptRef = {
58
- focused: boolean
59
- current: PromptInfo
60
- set(prompt: PromptInfo): void
61
- reset(): void
62
- blur(): void
63
- focus(): void
64
- submit(): void
65
- }
66
-
67
- const money = new Intl.NumberFormat("en-US", {
68
- style: "currency",
69
- currency: "USD",
70
- })
71
-
72
- function randomIndex(count: number) {
73
- if (count <= 0) return 0
74
- return Math.floor(Math.random() * count)
75
- }
76
-
77
- export function Prompt(props: PromptProps) {
78
- let input: TextareaRenderable
79
- let anchor: BoxRenderable
80
- let autocomplete: AutocompleteRef
81
-
82
- const keybind = useKeybind()
83
- const local = useLocal()
84
- const sdk = useSDK()
85
- const route = useRoute()
86
- const sync = useSync()
87
- const dialog = useDialog()
88
- const toast = useToast()
89
- const status = createMemo(() => sync.data.session_status?.[props.sessionID ?? ""] ?? { type: "idle" })
90
- const history = usePromptHistory()
91
- const stash = usePromptStash()
92
- const command = useCommandDialog()
93
- const renderer = useRenderer()
94
- const { theme, syntax } = useTheme()
95
- const kv = useKV()
96
- const list = createMemo(() => props.placeholders?.normal ?? [])
97
- const shell = createMemo(() => props.placeholders?.shell ?? [])
98
- const [auto, setAuto] = createSignal<AutocompleteRef>()
99
- const activeOrgName = createMemo(() => sync.data.console_state.activeOrgName)
100
- const canSwitchOrgs = createMemo(() => sync.data.console_state.switchableOrgCount > 1)
101
- const currentProviderLabel = createMemo(() => {
102
- const current = local.model.current()
103
- const provider = local.model.parsed().provider
104
- if (!current) return provider
105
- return consoleManagedProviderLabel(sync.data.console_state.consoleManagedProviders, current.providerID, provider)
106
- })
107
- const clerkModelName = createMemo(() => {
108
- const sideProvider = sync.data.provider.find((p) => p.id === "local-side")
109
- if (!sideProvider) return null
110
- const firstModel = Object.values(sideProvider.models)[0]
111
- return firstModel ? firstModel.name : null
112
- })
113
- const hasRightContent = createMemo(() => Boolean(props.right || activeOrgName()))
114
-
115
- function promptModelWarning() {
116
- toast.show({
117
- variant: "warning",
118
- message: "Connect a provider to send prompts",
119
- duration: 3000,
120
- })
121
- if (sync.data.provider.length === 0) {
122
- dialog.replace(() => <DialogProviderConnect />)
123
- }
124
- }
125
-
126
- const textareaKeybindings = useTextareaKeybindings()
127
-
128
- const fileStyleId = syntax().getStyleId("extmark.file")!
129
- const agentStyleId = syntax().getStyleId("extmark.agent")!
130
- const pasteStyleId = syntax().getStyleId("extmark.paste")!
131
- let promptPartTypeId = 0
132
-
133
- sdk.event.on(TuiEvent.PromptAppend.type, (evt) => {
134
- if (!input || input.isDestroyed) return
135
- input.insertText(evt.properties.text)
136
- // @ts-ignore cursorContext is omitted from the generated OpenAPI schema due to z.any()
137
- if (evt.properties.cursorContext) {
138
- // @ts-ignore
139
- setStore("prompt", "cursorContext", evt.properties.cursorContext)
140
- }
141
- setTimeout(() => {
142
- // setTimeout is a workaround and needs to be addressed properly
143
- if (!input || input.isDestroyed) return
144
- input.getLayoutNode().markDirty()
145
- input.gotoBufferEnd()
146
- renderer.requestRender()
147
- }, 0)
148
- })
149
-
150
- createEffect(() => {
151
- if (props.disabled) input.cursorColor = theme.backgroundElement
152
- if (!props.disabled) input.cursorColor = theme.text
153
- })
154
-
155
- const lastUserMessage = createMemo(() => {
156
- if (!props.sessionID) return undefined
157
- const messages = sync.data.message[props.sessionID]
158
- if (!messages) return undefined
159
- return messages.findLast((m): m is UserMessage => m.role === "user")
160
- })
161
-
162
- const usage = createMemo(() => {
163
- if (!props.sessionID) return
164
- const msg = sync.data.message[props.sessionID] ?? []
165
- const last = msg.findLast((item): item is AssistantMessage => item.role === "assistant" && item.tokens.output > 0)
166
- if (!last) return
167
-
168
- const tokens =
169
- last.tokens.input + last.tokens.output + last.tokens.reasoning + last.tokens.cache.read + last.tokens.cache.write
170
- if (tokens <= 0) return
171
-
172
- const model = sync.data.provider.find((item) => item.id === last.providerID)?.models[last.modelID]
173
- const pct = model?.limit.context ? `${Math.round((tokens / model.limit.context) * 100)}%` : undefined
174
- const cost = msg.reduce((sum, item) => sum + (item.role === "assistant" ? item.cost : 0), 0)
175
- return {
176
- context: pct ? `${Locale.number(tokens)} (${pct})` : Locale.number(tokens),
177
- cost: cost > 0 ? money.format(cost) : undefined,
178
- }
179
- })
180
-
181
- const [store, setStore] = createStore<{
182
- prompt: PromptInfo
183
- mode: "normal" | "shell"
184
- extmarkToPartIndex: Map<number, number>
185
- interrupt: number
186
- placeholder: number
187
- }>({
188
- placeholder: randomIndex(list().length),
189
- prompt: {
190
- input: "",
191
- parts: [],
192
- },
193
- mode: "normal",
194
- extmarkToPartIndex: new Map(),
195
- interrupt: 0,
196
- })
197
-
198
- createEffect(
199
- on(
200
- () => props.sessionID,
201
- () => {
202
- setStore("placeholder", randomIndex(list().length))
203
- },
204
- { defer: true },
205
- ),
206
- )
207
-
208
- // Initialize agent/model/variant from last user message when session changes
209
- let syncedSessionID: string | undefined
210
- createEffect(() => {
211
- const sessionID = props.sessionID
212
- const msg = lastUserMessage()
213
-
214
- if (sessionID !== syncedSessionID) {
215
- if (!sessionID || !msg) return
216
-
217
- syncedSessionID = sessionID
218
-
219
- // Only set agent if it's a primary agent (not a subagent)
220
- const isPrimaryAgent = local.agent.list().some((x) => x.name === msg.agent)
221
- if (msg.agent && isPrimaryAgent) {
222
- local.agent.set(msg.agent)
223
- if (msg.model) {
224
- local.model.set(msg.model)
225
- local.model.variant.set(msg.model.variant)
226
- }
227
- }
228
- }
229
- })
230
-
231
- command.register(() => {
232
- return [
233
- {
234
- title: "Clear prompt",
235
- value: "prompt.clear",
236
- category: "Prompt",
237
- hidden: true,
238
- onSelect: (dialog) => {
239
- input.extmarks.clear()
240
- input.clear()
241
- dialog.clear()
242
- },
243
- },
244
- {
245
- title: "Submit prompt",
246
- value: "prompt.submit",
247
- keybind: "input_submit",
248
- category: "Prompt",
249
- hidden: true,
250
- onSelect: (dialog) => {
251
- if (!input.focused) return
252
- submit()
253
- dialog.clear()
254
- },
255
- },
256
- {
257
- title: "Paste",
258
- value: "prompt.paste",
259
- keybind: "input_paste",
260
- category: "Prompt",
261
- hidden: true,
262
- onSelect: async () => {
263
- const content = await Clipboard.read()
264
- if (content?.mime.startsWith("image/")) {
265
- await pasteAttachment({
266
- filename: "clipboard",
267
- mime: content.mime,
268
- content: content.data,
269
- })
270
- }
271
- },
272
- },
273
- {
274
- title: "Interrupt session",
275
- value: "session.interrupt",
276
- keybind: "session_interrupt",
277
- category: "Session",
278
- hidden: true,
279
- enabled: status().type !== "idle",
280
- onSelect: (dialog) => {
281
- if (autocomplete.visible) return
282
- if (!input.focused) return
283
- // TODO: this should be its own command
284
- if (store.mode === "shell") {
285
- setStore("mode", "normal")
286
- return
287
- }
288
- if (!props.sessionID) return
289
-
290
- setStore("interrupt", store.interrupt + 1)
291
-
292
- setTimeout(() => {
293
- setStore("interrupt", 0)
294
- }, 5000)
295
-
296
- if (store.interrupt >= 2) {
297
- sdk.client.session.abort({
298
- sessionID: props.sessionID,
299
- })
300
- setStore("interrupt", 0)
301
- }
302
- dialog.clear()
303
- },
304
- },
305
- {
306
- title: "Open editor",
307
- category: "Session",
308
- keybind: "editor_open",
309
- value: "prompt.editor",
310
- slash: {
311
- name: "editor",
312
- },
313
- onSelect: async (dialog) => {
314
- dialog.clear()
315
-
316
- // replace summarized text parts with the actual text
317
- const text = store.prompt.parts
318
- .filter((p) => p.type === "text")
319
- .reduce((acc, p) => {
320
- if (!p.source) return acc
321
- return acc.replace(p.source.text.value, p.text)
322
- }, store.prompt.input)
323
-
324
- const nonTextParts = store.prompt.parts.filter((p) => p.type !== "text")
325
-
326
- const value = text
327
- const content = await Editor.open({ value, renderer })
328
- if (!content) return
329
-
330
- input.setText(content)
331
-
332
- // Update positions for nonTextParts based on their location in new content
333
- // Filter out parts whose virtual text was deleted
334
- // this handles a case where the user edits the text in the editor
335
- // such that the virtual text moves around or is deleted
336
- const updatedNonTextParts = nonTextParts
337
- .map((part) => {
338
- let virtualText = ""
339
- if (part.type === "file" && part.source?.text) {
340
- virtualText = part.source.text.value
341
- } else if (part.type === "agent" && part.source) {
342
- virtualText = part.source.value
343
- }
344
-
345
- if (!virtualText) return part
346
-
347
- const newStart = content.indexOf(virtualText)
348
- // if the virtual text is deleted, remove the part
349
- if (newStart === -1) return null
350
-
351
- const newEnd = newStart + virtualText.length
352
-
353
- if (part.type === "file" && part.source?.text) {
354
- return {
355
- ...part,
356
- source: {
357
- ...part.source,
358
- text: {
359
- ...part.source.text,
360
- start: newStart,
361
- end: newEnd,
362
- },
363
- },
364
- }
365
- }
366
-
367
- if (part.type === "agent" && part.source) {
368
- return {
369
- ...part,
370
- source: {
371
- ...part.source,
372
- start: newStart,
373
- end: newEnd,
374
- },
375
- }
376
- }
377
-
378
- return part
379
- })
380
- .filter((part) => part !== null)
381
-
382
- setStore("prompt", {
383
- input: content,
384
- // keep only the non-text parts because the text parts were
385
- // already expanded inline
386
- parts: updatedNonTextParts,
387
- })
388
- restoreExtmarksFromParts(updatedNonTextParts)
389
- input.cursorOffset = Bun.stringWidth(content)
390
- },
391
- },
392
- {
393
- title: "Skills",
394
- value: "prompt.skills",
395
- category: "Prompt",
396
- slash: {
397
- name: "skills",
398
- },
399
- onSelect: () => {
400
- dialog.replace(() => (
401
- <DialogSkill
402
- onSelect={(skill) => {
403
- input.setText(`/${skill} `)
404
- setStore("prompt", {
405
- input: `/${skill} `,
406
- parts: [],
407
- })
408
- input.gotoBufferEnd()
409
- }}
410
- />
411
- ))
412
- },
413
- },
414
- ]
415
- })
416
-
417
- const ref: PromptRef = {
418
- get focused() {
419
- return input.focused
420
- },
421
- get current() {
422
- return store.prompt
423
- },
424
- focus() {
425
- input.focus()
426
- },
427
- blur() {
428
- input.blur()
429
- },
430
- set(prompt) {
431
- input.setText(prompt.input)
432
- setStore("prompt", prompt)
433
- restoreExtmarksFromParts(prompt.parts)
434
- input.gotoBufferEnd()
435
- },
436
- reset() {
437
- input.clear()
438
- input.extmarks.clear()
439
- setStore("prompt", {
440
- input: "",
441
- parts: [],
442
- })
443
- setStore("extmarkToPartIndex", new Map())
444
- },
445
- submit() {
446
- submit()
447
- },
448
- }
449
-
450
- onCleanup(() => {
451
- props.ref?.(undefined)
452
- })
453
-
454
- createEffect(() => {
455
- if (!input || input.isDestroyed) return
456
- if (props.visible === false || dialog.stack.length > 0) {
457
- input.blur()
458
- return
459
- }
460
-
461
- // Slot/plugin updates can remount the background prompt while a dialog is open.
462
- // Keep focus with the dialog and let the prompt reclaim it after the dialog closes.
463
- input.focus()
464
- })
465
-
466
- createEffect(() => {
467
- if (!input || input.isDestroyed) return
468
- input.traits = {
469
- capture: auto()?.visible ? ["escape", "navigate", "submit", "tab"] : undefined,
470
- suspend: !!props.disabled || store.mode === "shell",
471
- status: store.mode === "shell" ? "SHELL" : undefined,
472
- }
473
- })
474
-
475
- function restoreExtmarksFromParts(parts: PromptInfo["parts"]) {
476
- input.extmarks.clear()
477
- setStore("extmarkToPartIndex", new Map())
478
-
479
- parts.forEach((part, partIndex) => {
480
- let start = 0
481
- let end = 0
482
- let virtualText = ""
483
- let styleId: number | undefined
484
-
485
- if (part.type === "file" && part.source?.text) {
486
- start = part.source.text.start
487
- end = part.source.text.end
488
- virtualText = part.source.text.value
489
- styleId = fileStyleId
490
- } else if (part.type === "agent" && part.source) {
491
- start = part.source.start
492
- end = part.source.end
493
- virtualText = part.source.value
494
- styleId = agentStyleId
495
- } else if (part.type === "text" && part.source?.text) {
496
- start = part.source.text.start
497
- end = part.source.text.end
498
- virtualText = part.source.text.value
499
- styleId = pasteStyleId
500
- }
501
-
502
- if (virtualText) {
503
- const extmarkId = input.extmarks.create({
504
- start,
505
- end,
506
- virtual: true,
507
- styleId,
508
- typeId: promptPartTypeId,
509
- })
510
- setStore("extmarkToPartIndex", (map: Map<number, number>) => {
511
- const newMap = new Map(map)
512
- newMap.set(extmarkId, partIndex)
513
- return newMap
514
- })
515
- }
516
- })
517
- }
518
-
519
- function syncExtmarksWithPromptParts() {
520
- const allExtmarks = input.extmarks.getAllForTypeId(promptPartTypeId)
521
- setStore(
522
- produce((draft) => {
523
- const newMap = new Map<number, number>()
524
- const newParts: typeof draft.prompt.parts = []
525
-
526
- for (const extmark of allExtmarks) {
527
- const partIndex = draft.extmarkToPartIndex.get(extmark.id)
528
- if (partIndex !== undefined) {
529
- const part = draft.prompt.parts[partIndex]
530
- if (part) {
531
- if (part.type === "agent" && part.source) {
532
- part.source.start = extmark.start
533
- part.source.end = extmark.end
534
- } else if (part.type === "file" && part.source?.text) {
535
- part.source.text.start = extmark.start
536
- part.source.text.end = extmark.end
537
- } else if (part.type === "text" && part.source?.text) {
538
- part.source.text.start = extmark.start
539
- part.source.text.end = extmark.end
540
- }
541
- newMap.set(extmark.id, newParts.length)
542
- newParts.push(part)
543
- }
544
- }
545
- }
546
-
547
- draft.extmarkToPartIndex = newMap
548
- draft.prompt.parts = newParts
549
- }),
550
- )
551
- }
552
-
553
- command.register(() => [
554
- {
555
- title: "Stash prompt",
556
- value: "prompt.stash",
557
- category: "Prompt",
558
- enabled: !!store.prompt.input,
559
- onSelect: (dialog) => {
560
- if (!store.prompt.input) return
561
- stash.push({
562
- input: store.prompt.input,
563
- parts: store.prompt.parts,
564
- })
565
- input.extmarks.clear()
566
- input.clear()
567
- setStore("prompt", { input: "", parts: [] })
568
- setStore("extmarkToPartIndex", new Map())
569
- dialog.clear()
570
- },
571
- },
572
- {
573
- title: "Stash pop",
574
- value: "prompt.stash.pop",
575
- category: "Prompt",
576
- enabled: stash.list().length > 0,
577
- onSelect: (dialog) => {
578
- const entry = stash.pop()
579
- if (entry) {
580
- input.setText(entry.input)
581
- setStore("prompt", { input: entry.input, parts: entry.parts })
582
- restoreExtmarksFromParts(entry.parts)
583
- input.gotoBufferEnd()
584
- }
585
- dialog.clear()
586
- },
587
- },
588
- {
589
- title: "Stash list",
590
- value: "prompt.stash.list",
591
- category: "Prompt",
592
- enabled: stash.list().length > 0,
593
- onSelect: (dialog) => {
594
- dialog.replace(() => (
595
- <DialogStash
596
- onSelect={(entry) => {
597
- input.setText(entry.input)
598
- setStore("prompt", { input: entry.input, parts: entry.parts })
599
- restoreExtmarksFromParts(entry.parts)
600
- input.gotoBufferEnd()
601
- }}
602
- />
603
- ))
604
- },
605
- },
606
- ])
607
-
608
- async function submit() {
609
- if (props.disabled) return
610
- if (autocomplete?.visible) return
611
- if (!store.prompt.input) return
612
- const trimmed = store.prompt.input.trim()
613
- if (trimmed === "exit" || trimmed === "quit" || trimmed === ":q") {
614
- exit()
615
- return
616
- }
617
- const selectedModel = local.model.current()
618
- if (!selectedModel) {
619
- promptModelWarning()
620
- return
621
- }
622
-
623
- let sessionID = props.sessionID
624
- if (sessionID == null) {
625
- const res = await sdk.client.session.create({
626
- workspaceID: props.workspaceID,
627
- })
628
-
629
- if (res.error) {
630
- console.log("Creating a session failed:", res.error)
631
-
632
- toast.show({
633
- message: "Creating a session failed. Open console for more details.",
634
- variant: "error",
635
- })
636
-
637
- return
638
- }
639
-
640
- sessionID = res.data.id
641
- }
642
-
643
- const messageID = MessageID.ascending()
644
- let inputText = store.prompt.input
645
-
646
- // Expand pasted text inline before submitting
647
- const allExtmarks = input.extmarks.getAllForTypeId(promptPartTypeId)
648
- const sortedExtmarks = allExtmarks.sort((a: { start: number }, b: { start: number }) => b.start - a.start)
649
-
650
- for (const extmark of sortedExtmarks) {
651
- const partIndex = store.extmarkToPartIndex.get(extmark.id)
652
- if (partIndex !== undefined) {
653
- const part = store.prompt.parts[partIndex]
654
- if (part?.type === "text" && part.text) {
655
- const before = inputText.slice(0, extmark.start)
656
- const after = inputText.slice(extmark.end)
657
- inputText = before + part.text + after
658
- }
659
- }
660
- }
661
-
662
- // Filter out text parts (pasted content) since they're now expanded inline
663
- const nonTextParts = store.prompt.parts.filter((part) => part.type !== "text")
664
-
665
- // Capture mode before it gets reset
666
- const currentMode = store.mode
667
- const variant = local.model.variant.current()
668
-
669
- if (store.mode === "shell") {
670
- sdk.client.session.shell({
671
- sessionID,
672
- agent: local.agent.current().name,
673
- model: {
674
- providerID: selectedModel.providerID,
675
- modelID: selectedModel.modelID,
676
- },
677
- command: inputText,
678
- })
679
- setStore("mode", "normal")
680
- } else if (
681
- inputText.startsWith("/") &&
682
- iife(() => {
683
- const firstLine = inputText.split("\n")[0]
684
- const command = firstLine.split(" ")[0].slice(1)
685
- return sync.data.command.some((x) => x.name === command)
686
- })
687
- ) {
688
- // Parse command from first line, preserve multi-line content in arguments
689
- const firstLineEnd = inputText.indexOf("\n")
690
- const firstLine = firstLineEnd === -1 ? inputText : inputText.slice(0, firstLineEnd)
691
- const [command, ...firstLineArgs] = firstLine.split(" ")
692
- const restOfInput = firstLineEnd === -1 ? "" : inputText.slice(firstLineEnd + 1)
693
- const args = firstLineArgs.join(" ") + (restOfInput ? "\n" + restOfInput : "")
694
-
695
- sdk.client.session.command({
696
- sessionID,
697
- command: command.slice(1),
698
- arguments: args,
699
- agent: local.agent.current().name,
700
- model: `${selectedModel.providerID}/${selectedModel.modelID}`,
701
- messageID,
702
- variant,
703
- parts: nonTextParts
704
- .filter((x) => x.type === "file")
705
- .map((x) => ({
706
- id: PartID.ascending(),
707
- ...x,
708
- })),
709
- })
710
- } else {
711
- sdk.client.session
712
- .prompt({
713
- sessionID,
714
- ...selectedModel,
715
- messageID,
716
- agent: local.agent.current().name,
717
- model: selectedModel,
718
- variant,
719
- yolo: local.yolo.current(),
720
- // @ts-ignore
721
- cursorContext: store.prompt.cursorContext,
722
- parts: [
723
- {
724
- id: PartID.ascending(),
725
- type: "text",
726
- text: inputText,
727
- },
728
- ...nonTextParts.map(assign),
729
- ],
730
- } as any)
731
- .catch(() => {})
732
- }
733
- history.append({
734
- ...store.prompt,
735
- mode: currentMode,
736
- })
737
- input.extmarks.clear()
738
- setStore("prompt", {
739
- input: "",
740
- parts: [],
741
- })
742
- setStore("extmarkToPartIndex", new Map())
743
- props.onSubmit?.()
744
-
745
- // temporary hack to make sure the message is sent
746
- if (!props.sessionID)
747
- setTimeout(() => {
748
- route.navigate({
749
- type: "session",
750
- sessionID,
751
- })
752
- }, 50)
753
- input.clear()
754
- }
755
- const exit = useExit()
756
-
757
- function pasteText(text: string, virtualText: string) {
758
- const currentOffset = input.visualCursor.offset
759
- const extmarkStart = currentOffset
760
- const extmarkEnd = extmarkStart + virtualText.length
761
-
762
- input.insertText(virtualText + " ")
763
-
764
- const extmarkId = input.extmarks.create({
765
- start: extmarkStart,
766
- end: extmarkEnd,
767
- virtual: true,
768
- styleId: pasteStyleId,
769
- typeId: promptPartTypeId,
770
- })
771
-
772
- setStore(
773
- produce((draft) => {
774
- const partIndex = draft.prompt.parts.length
775
- draft.prompt.parts.push({
776
- type: "text" as const,
777
- text,
778
- source: {
779
- text: {
780
- start: extmarkStart,
781
- end: extmarkEnd,
782
- value: virtualText,
783
- },
784
- },
785
- })
786
- draft.extmarkToPartIndex.set(extmarkId, partIndex)
787
- }),
788
- )
789
- }
790
-
791
- async function pasteAttachment(file: { filename?: string; filepath?: string; content: string; mime: string }) {
792
- const currentOffset = input.visualCursor.offset
793
- const extmarkStart = currentOffset
794
- const pdf = file.mime === "application/pdf"
795
- const count = store.prompt.parts.filter((x) => {
796
- if (x.type !== "file") return false
797
- if (pdf) return x.mime === "application/pdf"
798
- return x.mime.startsWith("image/")
799
- }).length
800
- const virtualText = pdf ? `[PDF ${count + 1}]` : `[Image ${count + 1}]`
801
- const extmarkEnd = extmarkStart + virtualText.length
802
- const textToInsert = virtualText + " "
803
-
804
- input.insertText(textToInsert)
805
-
806
- const extmarkId = input.extmarks.create({
807
- start: extmarkStart,
808
- end: extmarkEnd,
809
- virtual: true,
810
- styleId: pasteStyleId,
811
- typeId: promptPartTypeId,
812
- })
813
-
814
- const part: Omit<FilePart, "id" | "messageID" | "sessionID"> = {
815
- type: "file" as const,
816
- mime: file.mime,
817
- filename: file.filename,
818
- url: `data:${file.mime};base64,${file.content}`,
819
- source: {
820
- type: "file",
821
- path: file.filepath ?? file.filename ?? "",
822
- text: {
823
- start: extmarkStart,
824
- end: extmarkEnd,
825
- value: virtualText,
826
- },
827
- },
828
- }
829
- setStore(
830
- produce((draft) => {
831
- const partIndex = draft.prompt.parts.length
832
- draft.prompt.parts.push(part)
833
- draft.extmarkToPartIndex.set(extmarkId, partIndex)
834
- }),
835
- )
836
- return
837
- }
838
-
839
- const highlight = createMemo(() => {
840
- if (keybind.leader) return theme.border
841
- if (store.mode === "shell") return theme.primary
842
- return local.agent.color(local.agent.current().name)
843
- })
844
-
845
- const showVariant = createMemo(() => {
846
- const variants = local.model.variant.list()
847
- if (variants.length === 0) return false
848
- const current = local.model.variant.current()
849
- return !!current
850
- })
851
-
852
- const placeholderText = createMemo(() => {
853
- if (props.showPlaceholder === false) return undefined
854
- if (store.mode === "shell") {
855
- if (!shell().length) return undefined
856
- const example = shell()[store.placeholder % shell().length]
857
- return `Run a command... "${example}"`
858
- }
859
- if (!list().length) return undefined
860
- return `Ask anything... "${list()[store.placeholder % list().length]}"`
861
- })
862
-
863
- const spinnerDef = createMemo(() => {
864
- const color = local.agent.color(local.agent.current().name)
865
- return {
866
- frames: createFrames({
867
- color,
868
- style: "blocks",
869
- inactiveFactor: 0.6,
870
- // enableFading: false,
871
- minAlpha: 0.3,
872
- }),
873
- color: createColors({
874
- color,
875
- style: "blocks",
876
- inactiveFactor: 0.6,
877
- // enableFading: false,
878
- minAlpha: 0.3,
879
- }),
880
- }
881
- })
882
-
883
- return (
884
- <>
885
- <Autocomplete
886
- sessionID={props.sessionID}
887
- ref={(r) => {
888
- autocomplete = r
889
- setAuto(() => r)
890
- }}
891
- anchor={() => anchor}
892
- input={() => input}
893
- setPrompt={(cb) => {
894
- setStore("prompt", produce(cb))
895
- }}
896
- setExtmark={(partIndex, extmarkId) => {
897
- setStore("extmarkToPartIndex", (map: Map<number, number>) => {
898
- const newMap = new Map(map)
899
- newMap.set(extmarkId, partIndex)
900
- return newMap
901
- })
902
- }}
903
- value={store.prompt.input}
904
- fileStyleId={fileStyleId}
905
- agentStyleId={agentStyleId}
906
- promptPartTypeId={() => promptPartTypeId}
907
- />
908
- <box ref={(r) => (anchor = r)} visible={props.visible !== false}>
909
- <box
910
- border={["left"]}
911
- borderColor={highlight()}
912
- customBorderChars={{
913
- ...SplitBorder.customBorderChars,
914
- bottomLeft: "╹",
915
- }}
916
- >
917
- <box
918
- paddingLeft={2}
919
- paddingRight={2}
920
- paddingTop={1}
921
- flexShrink={0}
922
- backgroundColor={theme.backgroundElement}
923
- flexGrow={1}
924
- >
925
- <textarea
926
- placeholder={placeholderText()}
927
- placeholderColor={theme.textMuted}
928
- textColor={keybind.leader ? theme.textMuted : theme.text}
929
- focusedTextColor={keybind.leader ? theme.textMuted : theme.text}
930
- minHeight={1}
931
- maxHeight={6}
932
- onContentChange={() => {
933
- const value = input.plainText
934
- setStore("prompt", "input", value)
935
- autocomplete.onInput(value)
936
- syncExtmarksWithPromptParts()
937
- }}
938
- keyBindings={textareaKeybindings()}
939
- onKeyDown={async (e) => {
940
- if (props.disabled) {
941
- e.preventDefault()
942
- return
943
- }
944
- // Check clipboard for images before terminal-handled paste runs.
945
- // This helps terminals that forward Ctrl+V to the app; Windows
946
- // Terminal 1.25+ usually handles Ctrl+V before this path.
947
- if (keybind.match("input_paste", e)) {
948
- const content = await Clipboard.read()
949
- if (content?.mime.startsWith("image/")) {
950
- e.preventDefault()
951
- await pasteAttachment({
952
- filename: "clipboard",
953
- mime: content.mime,
954
- content: content.data,
955
- })
956
- return
957
- }
958
- // If no image, let the default paste behavior continue
959
- }
960
- if (keybind.match("input_clear", e) && store.prompt.input !== "") {
961
- input.clear()
962
- input.extmarks.clear()
963
- setStore("prompt", {
964
- input: "",
965
- parts: [],
966
- })
967
- setStore("extmarkToPartIndex", new Map())
968
- return
969
- }
970
- if (keybind.match("app_exit", e)) {
971
- if (store.prompt.input === "") {
972
- await exit()
973
- // Don't preventDefault - let textarea potentially handle the event
974
- e.preventDefault()
975
- return
976
- }
977
- }
978
- if (e.name === "!" && input.visualCursor.offset === 0) {
979
- setStore("placeholder", randomIndex(shell().length))
980
- setStore("mode", "shell")
981
- e.preventDefault()
982
- return
983
- }
984
- if (store.mode === "shell") {
985
- if ((e.name === "backspace" && input.visualCursor.offset === 0) || e.name === "escape") {
986
- setStore("mode", "normal")
987
- e.preventDefault()
988
- return
989
- }
990
- }
991
- if (store.mode === "normal") autocomplete.onKeyDown(e)
992
- if (!autocomplete.visible) {
993
- if (
994
- (keybind.match("history_previous", e) && input.cursorOffset === 0) ||
995
- (keybind.match("history_next", e) && input.cursorOffset === input.plainText.length)
996
- ) {
997
- const direction = keybind.match("history_previous", e) ? -1 : 1
998
- const item = history.move(direction, input.plainText)
999
-
1000
- if (item) {
1001
- input.setText(item.input)
1002
- setStore("prompt", item)
1003
- setStore("mode", item.mode ?? "normal")
1004
- restoreExtmarksFromParts(item.parts)
1005
- e.preventDefault()
1006
- if (direction === -1) input.cursorOffset = 0
1007
- if (direction === 1) input.cursorOffset = input.plainText.length
1008
- }
1009
- return
1010
- }
1011
-
1012
- if (keybind.match("history_previous", e) && input.visualCursor.visualRow === 0) input.cursorOffset = 0
1013
- if (keybind.match("history_next", e) && input.visualCursor.visualRow === input.height - 1)
1014
- input.cursorOffset = input.plainText.length
1015
- }
1016
- }}
1017
- onSubmit={submit}
1018
- onPaste={async (event: PasteEvent) => {
1019
- if (props.disabled) {
1020
- event.preventDefault()
1021
- return
1022
- }
1023
-
1024
- // Normalize line endings at the boundary
1025
- // Windows ConPTY/Terminal often sends CR-only newlines in bracketed paste
1026
- // Replace CRLF first, then any remaining CR
1027
- const normalizedText = decodePasteBytes(event.bytes).replace(/\r\n/g, "\n").replace(/\r/g, "\n")
1028
- const pastedContent = normalizedText.trim()
1029
-
1030
- // Windows Terminal <1.25 can surface image-only clipboard as an
1031
- // empty bracketed paste. Windows Terminal 1.25+ does not.
1032
- if (!pastedContent) {
1033
- command.trigger("prompt.paste")
1034
- return
1035
- }
1036
-
1037
- const filepath = iife(() => {
1038
- const raw = pastedContent.replace(/^['"]+|['"]+$/g, "")
1039
- if (raw.startsWith("file://")) {
1040
- try {
1041
- return fileURLToPath(raw)
1042
- } catch {}
1043
- }
1044
- if (process.platform === "win32") return raw
1045
- return raw.replace(/\\(.)/g, "$1")
1046
- })
1047
- const isUrl = /^(https?):\/\//.test(filepath)
1048
- if (!isUrl) {
1049
- try {
1050
- const mime = Filesystem.mimeType(filepath)
1051
- const filename = path.basename(filepath)
1052
- // Handle SVG as raw text content, not as base64 image
1053
- if (mime === "image/svg+xml") {
1054
- event.preventDefault()
1055
- const content = await Filesystem.readText(filepath).catch(() => {})
1056
- if (content) {
1057
- pasteText(content, `[SVG: ${filename ?? "image"}]`)
1058
- return
1059
- }
1060
- }
1061
- if (mime.startsWith("image/") || mime === "application/pdf") {
1062
- event.preventDefault()
1063
- const content = await Filesystem.readArrayBuffer(filepath)
1064
- .then((buffer) => Buffer.from(buffer).toString("base64"))
1065
- .catch(() => {})
1066
- if (content) {
1067
- await pasteAttachment({
1068
- filename,
1069
- filepath,
1070
- mime,
1071
- content,
1072
- })
1073
- return
1074
- }
1075
- }
1076
- } catch {}
1077
- }
1078
-
1079
- const lineCount = (pastedContent.match(/\n/g)?.length ?? 0) + 1
1080
- if (
1081
- (lineCount >= 3 || pastedContent.length > 150) &&
1082
- !sync.data.config.experimental?.disable_paste_summary
1083
- ) {
1084
- event.preventDefault()
1085
- pasteText(pastedContent, `[Pasted ~${lineCount} lines]`)
1086
- return
1087
- }
1088
-
1089
- // Force layout update and render for the pasted content
1090
- setTimeout(() => {
1091
- // setTimeout is a workaround and needs to be addressed properly
1092
- if (!input || input.isDestroyed) return
1093
- input.getLayoutNode().markDirty()
1094
- renderer.requestRender()
1095
- }, 0)
1096
- }}
1097
- ref={(r: TextareaRenderable) => {
1098
- input = r
1099
- if (promptPartTypeId === 0) {
1100
- promptPartTypeId = input.extmarks.registerType("prompt-part")
1101
- }
1102
- props.ref?.(ref)
1103
- setTimeout(() => {
1104
- // setTimeout is a workaround and needs to be addressed properly
1105
- if (!input || input.isDestroyed) return
1106
- input.cursorColor = theme.text
1107
- }, 0)
1108
- }}
1109
- onMouseDown={(r: MouseEvent) => r.target?.focus()}
1110
- focusedBackgroundColor={theme.backgroundElement}
1111
- cursorColor={theme.text}
1112
- syntaxStyle={syntax()}
1113
- />
1114
- <box flexDirection="row" flexShrink={0} paddingTop={1} gap={1} justifyContent="space-between">
1115
- <box flexDirection="row" gap={4}>
1116
- <box flexDirection="column">
1117
- <Show when={store.mode === "shell"}>
1118
- <text fg={highlight()}>Shell</text>
1119
- </Show>
1120
- <Show when={store.mode === "normal"}>
1121
- <box flexDirection="row" gap={1}>
1122
- <text fg={theme.success}>•</text>
1123
- <text flexShrink={0} fg={keybind.leader ? theme.textMuted : theme.text}>
1124
- Coder: {local.model.parsed().model}
1125
- </text>
1126
- <text fg={theme.textMuted}>{currentProviderLabel()}</text>
1127
- <Show when={showVariant()}>
1128
- <text fg={theme.textMuted}>·</text>
1129
- <text>
1130
- <span style={{ fg: theme.warning, bold: true }}>{local.model.variant.current()}</span>
1131
- </text>
1132
- </Show>
1133
- </box>
1134
- <Show when={clerkModelName()}>
1135
- <box flexDirection="row" gap={1}>
1136
- <text fg={theme.success}>•</text>
1137
- <text flexShrink={0} fg={keybind.leader ? theme.textMuted : theme.text}>
1138
- Clerk: {clerkModelName()}
1139
- </text>
1140
- </box>
1141
- </Show>
1142
- <box flexDirection="row" gap={1}>
1143
- <Show
1144
- when={local.yolo.current()}
1145
- fallback={
1146
- <box flexDirection="row" gap={1}>
1147
- <text fg={theme.textMuted}>•</text>
1148
- <text fg={theme.textMuted}>Interactive</text>
1149
- </box>
1150
- }
1151
- >
1152
- <Show when={status().type === "busy"} fallback={<text fg={theme.warning}>•</text>}>
1153
- <spinner
1154
- frames={createFrames({ color: theme.warning })}
1155
- color={createColors({ color: theme.warning })}
1156
- />
1157
- </Show>
1158
- <text fg={theme.warning}>{status().type === "busy" ? "Autonomous Mode" : "YOLO"}</text>
1159
- </Show>
1160
- </box>
1161
- </Show>
1162
- </box>
1163
- <Show when={store.mode === "normal"}>
1164
- <box flexDirection="column">
1165
- {["spec", "map", "ground"].map((server) => (
1166
- <box flexDirection="row" gap={1}>
1167
- <text fg={sync.data.mcp[server]?.status === "connected" ? theme.success : theme.error}>
1168
- {sync.data.mcp[server]?.status === "connected" ? "●" : "○"}
1169
- </text>
1170
- <text fg={theme.textMuted}>{server}</text>
1171
- </box>
1172
- ))}
1173
- </box>
1174
- </Show>
1175
- </box>
1176
- <Show when={hasRightContent()}>
1177
- <box flexDirection="row" gap={1} alignItems="center">
1178
- {props.right}
1179
- <Show when={activeOrgName()}>
1180
- <text
1181
- fg={theme.textMuted}
1182
- onMouseUp={() => {
1183
- if (!canSwitchOrgs()) return
1184
- command.trigger("console.org.switch")
1185
- }}
1186
- >
1187
- {`${CONSOLE_MANAGED_ICON} ${activeOrgName()}`}
1188
- </text>
1189
- </Show>
1190
- </box>
1191
- </Show>
1192
- </box>
1193
- </box>
1194
- </box>
1195
- <box
1196
- height={1}
1197
- border={["left"]}
1198
- borderColor={highlight()}
1199
- customBorderChars={{
1200
- ...EmptyBorder,
1201
- vertical: theme.backgroundElement.a !== 0 ? "╹" : " ",
1202
- }}
1203
- >
1204
- <box
1205
- height={1}
1206
- border={["bottom"]}
1207
- borderColor={theme.backgroundElement}
1208
- customBorderChars={
1209
- theme.backgroundElement.a !== 0
1210
- ? {
1211
- ...EmptyBorder,
1212
- horizontal: "▀",
1213
- }
1214
- : {
1215
- ...EmptyBorder,
1216
- horizontal: " ",
1217
- }
1218
- }
1219
- />
1220
- </box>
1221
- <box flexDirection="row" justifyContent="space-between">
1222
- <Show when={status().type !== "idle"} fallback={props.hint ?? <text />}>
1223
- <box
1224
- flexDirection="row"
1225
- gap={1}
1226
- flexGrow={1}
1227
- justifyContent={status().type === "retry" ? "space-between" : "flex-start"}
1228
- >
1229
- <box flexShrink={0} flexDirection="row" gap={1}>
1230
- <box marginLeft={1}>
1231
- <Show when={kv.get("animations_enabled", true)} fallback={<text fg={theme.textMuted}>[⋯]</text>}>
1232
- <spinner color={spinnerDef().color} frames={spinnerDef().frames} interval={40} />
1233
- </Show>
1234
- </box>
1235
- <box flexDirection="row" gap={1} flexShrink={0}>
1236
- {(() => {
1237
- const retry = createMemo(() => {
1238
- const s = status()
1239
- if (s.type !== "retry") return
1240
- return s
1241
- })
1242
- const message = createMemo(() => {
1243
- const r = retry()
1244
- if (!r) return
1245
- if (r.message.includes("exceeded your current quota") && r.message.includes("gemini"))
1246
- return "gemini is way too hot right now"
1247
- if (r.message.length > 80) return r.message.slice(0, 80) + "..."
1248
- return r.message
1249
- })
1250
- const isTruncated = createMemo(() => {
1251
- const r = retry()
1252
- if (!r) return false
1253
- return r.message.length > 120
1254
- })
1255
- const [seconds, setSeconds] = createSignal(0)
1256
- onMount(() => {
1257
- const timer = setInterval(() => {
1258
- const next = retry()?.next
1259
- if (next) setSeconds(Math.round((next - Date.now()) / 1000))
1260
- }, 1000)
1261
-
1262
- onCleanup(() => {
1263
- clearInterval(timer)
1264
- })
1265
- })
1266
- const handleMessageClick = () => {
1267
- const r = retry()
1268
- if (!r) return
1269
- if (isTruncated()) {
1270
- DialogAlert.show(dialog, "Retry Error", r.message)
1271
- }
1272
- }
1273
-
1274
- const retryText = () => {
1275
- const r = retry()
1276
- if (!r) return ""
1277
- const baseMessage = message()
1278
- const truncatedHint = isTruncated() ? " (click to expand)" : ""
1279
- const duration = formatDuration(seconds())
1280
- const retryInfo = ` [retrying ${duration ? `in ${duration} ` : ""}attempt #${r.attempt}]`
1281
- return baseMessage + truncatedHint + retryInfo
1282
- }
1283
-
1284
- return (
1285
- <Show when={retry()}>
1286
- <box onMouseUp={handleMessageClick}>
1287
- <text fg={theme.error}>{retryText()}</text>
1288
- </box>
1289
- </Show>
1290
- )
1291
- })()}
1292
- </box>
1293
- </box>
1294
- <text fg={store.interrupt > 0 ? theme.primary : theme.text}>
1295
- esc{" "}
1296
- <span style={{ fg: store.interrupt > 0 ? theme.primary : theme.textMuted }}>
1297
- {store.interrupt > 0 ? "again to interrupt" : "interrupt"}
1298
- </span>
1299
- </text>
1300
- </box>
1301
- </Show>
1302
- <Show when={status().type !== "retry"}>
1303
- <box gap={2} flexDirection="row">
1304
- <Switch>
1305
- <Match when={store.mode === "normal"}>
1306
- <Switch>
1307
- <Match when={usage()}>
1308
- {(item) => (
1309
- <text fg={theme.textMuted} wrapMode="none">
1310
- {[item().context, item().cost].filter(Boolean).join(" · ")}
1311
- </text>
1312
- )}
1313
- </Match>
1314
- <Match when={true}>
1315
- <text fg={theme.text}>
1316
- {keybind.print("agent_cycle")} <span style={{ fg: theme.textMuted }}>agents</span>
1317
- </text>
1318
- </Match>
1319
- </Switch>
1320
- <text fg={theme.text}>
1321
- {keybind.print("command_list")} <span style={{ fg: theme.textMuted }}>commands</span>
1322
- </text>
1323
- </Match>
1324
- <Match when={store.mode === "shell"}>
1325
- <text fg={theme.text}>
1326
- esc <span style={{ fg: theme.textMuted }}>exit shell mode</span>
1327
- </text>
1328
- </Match>
1329
- </Switch>
1330
- </box>
1331
- </Show>
1332
- </box>
1333
- </box>
1334
- </>
1335
- )
1336
- }