eve 0.6.0-beta.8 → 0.7.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 (588) hide show
  1. package/CHANGELOG.md +278 -0
  2. package/README.md +9 -6
  3. package/dist/docs/public/README.md +1 -1
  4. package/dist/docs/public/advanced/auth-and-route-protection.md +3 -1
  5. package/dist/docs/public/advanced/default-harness.md +2 -2
  6. package/dist/docs/public/advanced/dev-tui.md +9 -11
  7. package/dist/docs/public/advanced/instrumentation.md +1 -1
  8. package/dist/docs/public/advanced/meta.json +0 -1
  9. package/dist/docs/public/advanced/security-model.md +1 -1
  10. package/dist/docs/public/advanced/session-context.md +1 -1
  11. package/dist/docs/public/agent-config.md +6 -3
  12. package/dist/docs/public/channels/eve.mdx +1 -1
  13. package/dist/docs/public/channels/slack.mdx +14 -2
  14. package/dist/docs/public/connections.mdx +3 -1
  15. package/dist/docs/public/evals/assertions.mdx +108 -0
  16. package/dist/docs/public/evals/cases.mdx +143 -0
  17. package/dist/docs/public/evals/judge.mdx +94 -0
  18. package/dist/docs/public/evals/meta.json +4 -0
  19. package/dist/docs/public/evals/overview.mdx +118 -0
  20. package/dist/docs/public/evals/reporters.mdx +62 -0
  21. package/dist/docs/public/evals/running.mdx +63 -0
  22. package/dist/docs/public/evals/targets.mdx +54 -0
  23. package/dist/docs/public/frontend/nextjs.mdx +13 -4
  24. package/dist/docs/public/frontend/nuxt.mdx +4 -4
  25. package/dist/docs/public/frontend/sveltekit.mdx +2 -2
  26. package/dist/docs/public/getting-started.mdx +25 -13
  27. package/dist/docs/public/meta.json +1 -0
  28. package/dist/docs/public/reference/cli.md +31 -9
  29. package/dist/docs/public/reference/typescript-api.md +6 -2
  30. package/dist/docs/public/sandbox.mdx +3 -1
  31. package/dist/docs/public/tools.mdx +0 -4
  32. package/dist/docs/public/tutorial/connect-a-warehouse.mdx +1 -1
  33. package/dist/docs/public/tutorial/first-agent.mdx +5 -2
  34. package/dist/src/chunks/{use-eve-agent-DCZbkLG7.js → use-eve-agent-DErQj5hs.js} +125 -37
  35. package/dist/src/chunks/{use-eve-agent-DoheC4_o.js → use-eve-agent-DoR8C4i6.js} +125 -37
  36. package/dist/src/cli/banner.d.ts +7 -0
  37. package/dist/src/cli/banner.js +1 -0
  38. package/dist/src/cli/commands/channel-add-conflicts.d.ts +1 -1
  39. package/dist/src/cli/commands/channels.d.ts +9 -6
  40. package/dist/src/cli/commands/channels.js +1 -1
  41. package/dist/src/cli/commands/deploy.d.ts +21 -0
  42. package/dist/src/cli/commands/deploy.js +1 -0
  43. package/dist/src/cli/commands/init-git.d.ts +15 -0
  44. package/dist/src/cli/commands/init-git.js +1 -0
  45. package/dist/src/cli/commands/init.d.ts +29 -0
  46. package/dist/src/cli/commands/init.js +1 -0
  47. package/dist/src/cli/commands/link.d.ts +21 -0
  48. package/dist/src/cli/commands/link.js +1 -0
  49. package/dist/src/cli/commands/preconditions.d.ts +7 -0
  50. package/dist/src/cli/commands/preconditions.js +1 -0
  51. package/dist/src/cli/commands/register-project-commands.d.ts +12 -0
  52. package/dist/src/cli/commands/register-project-commands.js +1 -0
  53. package/dist/src/cli/dev/tui/agent-header.d.ts +15 -9
  54. package/dist/src/cli/dev/tui/agent-header.js +1 -1
  55. package/dist/src/cli/dev/tui/blocks.d.ts +1 -1
  56. package/dist/src/cli/dev/tui/blocks.js +3 -2
  57. package/dist/src/cli/dev/tui/command-typeahead.d.ts +47 -0
  58. package/dist/src/cli/dev/tui/command-typeahead.js +1 -0
  59. package/dist/src/cli/dev/tui/dev-rebuild-status.d.ts +21 -0
  60. package/dist/src/cli/dev/tui/dev-rebuild-status.js +1 -0
  61. package/dist/src/cli/dev/tui/errors.d.ts +18 -0
  62. package/dist/src/cli/dev/tui/errors.js +1 -1
  63. package/dist/src/cli/dev/tui/prompt-command-handler.d.ts +14 -0
  64. package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -0
  65. package/dist/src/cli/dev/tui/prompt-commands.d.ts +54 -0
  66. package/dist/src/cli/dev/tui/prompt-commands.js +2 -0
  67. package/dist/src/cli/dev/tui/runner.d.ts +62 -5
  68. package/dist/src/cli/dev/tui/runner.js +1 -1
  69. package/dist/src/cli/dev/tui/setup-commands.d.ts +48 -0
  70. package/dist/src/cli/dev/tui/setup-commands.js +2 -0
  71. package/dist/src/cli/dev/tui/setup-flow.d.ts +35 -0
  72. package/dist/src/cli/dev/tui/setup-issues.d.ts +40 -0
  73. package/dist/src/cli/dev/tui/setup-issues.js +1 -0
  74. package/dist/src/cli/dev/tui/setup-panel.d.ts +103 -0
  75. package/dist/src/cli/dev/tui/setup-panel.js +1 -0
  76. package/dist/src/cli/dev/tui/status-line.d.ts +25 -0
  77. package/dist/src/cli/dev/tui/status-line.js +1 -0
  78. package/dist/src/cli/dev/tui/stream-format.d.ts +16 -1
  79. package/dist/src/cli/dev/tui/stream-format.js +1 -1
  80. package/dist/src/cli/dev/tui/terminal-renderer.d.ts +32 -3
  81. package/dist/src/cli/dev/tui/terminal-renderer.js +5 -2
  82. package/dist/src/cli/dev/tui/test/index.d.ts +3 -1
  83. package/dist/src/cli/dev/tui/test/index.js +1 -1
  84. package/dist/src/cli/dev/tui/test/mock-terminal.d.ts +1 -0
  85. package/dist/src/cli/dev/tui/test/mock-terminal.js +1 -1
  86. package/dist/src/cli/dev/tui/theme.d.ts +10 -0
  87. package/dist/src/cli/dev/tui/theme.js +1 -1
  88. package/dist/src/cli/dev/tui/tui-prompter.d.ts +20 -0
  89. package/dist/src/cli/dev/tui/tui-prompter.js +1 -0
  90. package/dist/src/cli/dev/tui/tui.d.ts +6 -8
  91. package/dist/src/cli/dev/tui/tui.js +1 -1
  92. package/dist/src/cli/dev/tui/types.d.ts +4 -3
  93. package/dist/src/cli/dev/tui/vercel-status.d.ts +47 -0
  94. package/dist/src/cli/dev/tui/vercel-status.js +1 -0
  95. package/dist/src/cli/run.d.ts +12 -19
  96. package/dist/src/cli/run.js +2 -2
  97. package/dist/src/client/client.d.ts +8 -0
  98. package/dist/src/client/client.js +1 -1
  99. package/dist/src/client/file-parts.d.ts +18 -0
  100. package/dist/src/client/file-parts.js +1 -0
  101. package/dist/src/client/index.d.ts +3 -2
  102. package/dist/src/client/index.js +1 -1
  103. package/dist/src/client/message-response.js +1 -1
  104. package/dist/src/client/open-stream.d.ts +6 -0
  105. package/dist/src/client/open-stream.js +1 -1
  106. package/dist/src/client/session-utils.d.ts +5 -0
  107. package/dist/src/client/session-utils.js +1 -1
  108. package/dist/src/client/session.js +1 -1
  109. package/dist/src/client/types.d.ts +9 -2
  110. package/dist/src/compiled/.vendor-stamp.json +8 -8
  111. package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +56 -31
  112. package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -2
  113. package/dist/src/compiled/@ai-sdk/google/index.js +1 -1
  114. package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
  115. package/dist/src/compiled/@ai-sdk/openai/index.d.ts +16 -9
  116. package/dist/src/compiled/@ai-sdk/openai/index.js +2 -2
  117. package/dist/src/compiled/@ai-sdk/otel/index.js +2 -2
  118. package/dist/src/compiled/@vercel/sandbox/index.js +1 -1
  119. package/dist/src/compiled/@workflow/core/index.js +2 -2
  120. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +4 -2
  121. package/dist/src/compiled/@workflow/core/runtime/wait-until.d.ts +18 -0
  122. package/dist/src/compiled/@workflow/core/runtime.d.ts +3 -1
  123. package/dist/src/compiled/@workflow/core/runtime.js +28 -28
  124. package/dist/src/compiled/@workflow/core/serialization.d.ts +41 -0
  125. package/dist/src/compiled/@workflow/core/util.d.ts +0 -5
  126. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  127. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  128. package/dist/src/compiled/@workflow/world/index.d.ts +2 -2
  129. package/dist/src/compiled/@workflow/world/queue.d.ts +28 -2
  130. package/dist/src/compiled/_chunks/workflow/{dist-gEXVSMPU.js → dist-CkMRLaRV.js} +1 -1
  131. package/dist/src/compiled/_chunks/workflow/functions-DuPjIvMH.js +1 -0
  132. package/dist/src/compiled/_chunks/workflow/resume-hook-CEAS3opc.js +12 -0
  133. package/dist/src/compiled/_chunks/workflow/sleep-Cup6vPoA.js +1 -0
  134. package/dist/src/compiled/_chunks/workflow/{symbols-BWCAoPHE.js → symbols-BUTtwS7j.js} +1 -1
  135. package/dist/src/compiled/just-bash/index.d.ts +27 -4
  136. package/dist/src/compiler/artifacts.js +1 -1
  137. package/dist/src/compiler/manifest.d.ts +8 -8
  138. package/dist/src/compiler/normalize-agent-config.d.ts +0 -10
  139. package/dist/src/compiler/normalize-agent-config.js +1 -1
  140. package/dist/src/compiler/normalize-channel.d.ts +2 -1
  141. package/dist/src/compiler/normalize-channel.js +1 -1
  142. package/dist/src/compiler/normalize-connection.d.ts +2 -1
  143. package/dist/src/compiler/normalize-connection.js +1 -1
  144. package/dist/src/compiler/normalize-helpers.d.ts +5 -0
  145. package/dist/src/compiler/normalize-helpers.js +1 -1
  146. package/dist/src/compiler/normalize-instructions.d.ts +3 -2
  147. package/dist/src/compiler/normalize-instructions.js +1 -1
  148. package/dist/src/compiler/normalize-manifest.js +2 -2
  149. package/dist/src/compiler/normalize-sandbox.d.ts +2 -1
  150. package/dist/src/compiler/normalize-sandbox.js +1 -1
  151. package/dist/src/compiler/normalize-schedule.d.ts +2 -1
  152. package/dist/src/compiler/normalize-schedule.js +1 -1
  153. package/dist/src/compiler/normalize-skill.d.ts +2 -1
  154. package/dist/src/compiler/normalize-skill.js +1 -1
  155. package/dist/src/compiler/normalize-subagent.d.ts +4 -1
  156. package/dist/src/compiler/normalize-subagent.js +1 -1
  157. package/dist/src/compiler/normalize-tool.d.ts +2 -1
  158. package/dist/src/compiler/normalize-tool.js +1 -1
  159. package/dist/src/compiler/workspace-resources.js +1 -1
  160. package/dist/src/context/node.d.ts +1 -1
  161. package/dist/src/evals/assertions/collector.d.ts +43 -0
  162. package/dist/src/evals/assertions/collector.js +1 -0
  163. package/dist/src/evals/assertions/run.d.ts +72 -0
  164. package/dist/src/evals/assertions/run.js +2 -0
  165. package/dist/src/evals/autoevals-client.js +2 -0
  166. package/dist/src/evals/cli/eval-client.d.ts +22 -0
  167. package/dist/src/evals/cli/eval-client.js +1 -0
  168. package/dist/src/evals/cli/eval.d.ts +12 -3
  169. package/dist/src/evals/cli/eval.js +1 -1
  170. package/dist/src/evals/context.d.ts +19 -0
  171. package/dist/src/evals/context.js +1 -0
  172. package/dist/src/evals/define-eval-config.d.ts +16 -0
  173. package/dist/src/evals/define-eval-config.js +1 -0
  174. package/dist/src/evals/define-eval.d.ts +20 -0
  175. package/dist/src/evals/define-eval.js +1 -0
  176. package/dist/src/evals/expect/index.d.ts +25 -0
  177. package/dist/src/evals/expect/index.js +1 -0
  178. package/dist/src/evals/index.d.ts +7 -2
  179. package/dist/src/evals/index.js +1 -1
  180. package/dist/src/evals/judge.d.ts +20 -0
  181. package/dist/src/evals/judge.js +1 -0
  182. package/dist/src/evals/match.d.ts +67 -0
  183. package/dist/src/evals/match.js +1 -0
  184. package/dist/src/evals/reporters/index.d.ts +1 -0
  185. package/dist/src/evals/reporters/index.js +1 -1
  186. package/dist/src/evals/requirements.d.ts +3 -0
  187. package/dist/src/evals/requirements.js +1 -0
  188. package/dist/src/evals/runner/artifacts.d.ts +7 -6
  189. package/dist/src/evals/runner/artifacts.js +3 -3
  190. package/dist/src/evals/runner/derive-run-facts.d.ts +17 -3
  191. package/dist/src/evals/runner/derive-run-facts.js +1 -1
  192. package/dist/src/evals/runner/discover.d.ts +31 -10
  193. package/dist/src/evals/runner/discover.js +1 -1
  194. package/dist/src/evals/runner/execute-eval.d.ts +25 -0
  195. package/dist/src/evals/runner/execute-eval.js +1 -0
  196. package/dist/src/evals/runner/execute-task.d.ts +31 -0
  197. package/dist/src/evals/runner/execute-task.js +1 -0
  198. package/dist/src/evals/runner/reporters/braintrust.d.ts +7 -5
  199. package/dist/src/evals/runner/reporters/braintrust.js +2 -2
  200. package/dist/src/evals/runner/reporters/console.d.ts +4 -4
  201. package/dist/src/evals/runner/reporters/console.js +1 -1
  202. package/dist/src/evals/runner/reporters/junit.d.ts +10 -0
  203. package/dist/src/evals/runner/reporters/junit.js +4 -0
  204. package/dist/src/evals/runner/reporters/types.d.ts +14 -8
  205. package/dist/src/evals/runner/run-evals.d.ts +38 -0
  206. package/dist/src/evals/runner/run-evals.js +1 -0
  207. package/dist/src/evals/runner/verdict.d.ts +13 -0
  208. package/dist/src/evals/runner/verdict.js +1 -0
  209. package/dist/src/evals/session.d.ts +52 -0
  210. package/dist/src/evals/session.js +1 -0
  211. package/dist/src/evals/target.d.ts +23 -0
  212. package/dist/src/evals/target.js +1 -0
  213. package/dist/src/evals/types.d.ts +353 -165
  214. package/dist/src/execution/compaction.d.ts +14 -0
  215. package/dist/src/execution/compaction.js +1 -0
  216. package/dist/src/execution/delegated-parent-notification.js +1 -1
  217. package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
  218. package/dist/src/execution/node-step.js +1 -1
  219. package/dist/src/execution/sandbox/bash-tool.d.ts +6 -6
  220. package/dist/src/execution/sandbox/bash-tool.js +1 -1
  221. package/dist/src/execution/sandbox/bindings/local.d.ts +11 -0
  222. package/dist/src/execution/sandbox/bindings/local.js +1 -1
  223. package/dist/src/execution/sandbox/glob-tool.js +3 -3
  224. package/dist/src/execution/sandbox/grep-tool.js +3 -3
  225. package/dist/src/execution/sandbox/read-file-tool.js +1 -1
  226. package/dist/src/execution/subagent-adapter.js +1 -1
  227. package/dist/src/execution/tool-auth.js +1 -1
  228. package/dist/src/execution/turn-workflow.js +1 -1
  229. package/dist/src/execution/workflow-runtime.d.ts +2 -2
  230. package/dist/src/execution/workflow-runtime.js +1 -1
  231. package/dist/src/execution/workflow-steps.js +1 -1
  232. package/dist/src/harness/action-result-helpers.js +1 -1
  233. package/dist/src/harness/authorization.d.ts +26 -0
  234. package/dist/src/harness/authorization.js +1 -1
  235. package/dist/src/harness/code-mode-lifecycle.js +1 -1
  236. package/dist/src/harness/emission.d.ts +12 -5
  237. package/dist/src/harness/emission.js +1 -1
  238. package/dist/src/harness/model-call-error.d.ts +35 -6
  239. package/dist/src/harness/model-call-error.js +1 -1
  240. package/dist/src/harness/step-hooks.d.ts +10 -4
  241. package/dist/src/harness/step-hooks.js +1 -1
  242. package/dist/src/harness/tool-loop.js +1 -1
  243. package/dist/src/harness/tools.d.ts +4 -6
  244. package/dist/src/harness/tools.js +1 -1
  245. package/dist/src/harness/turn-tag-state.d.ts +4 -0
  246. package/dist/src/harness/turn-tag-state.js +1 -1
  247. package/dist/src/harness/types.d.ts +4 -15
  248. package/dist/src/internal/application/cache-metadata.js +1 -1
  249. package/dist/src/internal/application/compiled-artifacts.js +1 -1
  250. package/dist/src/internal/application/package.js +1 -1
  251. package/dist/src/internal/application/paths.js +1 -1
  252. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  253. package/dist/src/internal/authored-module-loader.d.ts +4 -1
  254. package/dist/src/internal/authored-module-loader.js +2 -2
  255. package/dist/src/internal/authored-module-map-loader.js +1 -1
  256. package/dist/src/internal/nitro/dev-runtime-artifacts.d.ts +11 -0
  257. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  258. package/dist/src/internal/nitro/host/build-application.js +1 -1
  259. package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
  260. package/dist/src/internal/nitro/host/configure-nitro-routes.js +3 -3
  261. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  262. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  263. package/dist/src/internal/nitro/host/dev-watcher-log.d.ts +37 -0
  264. package/dist/src/internal/nitro/host/dev-watcher-log.js +1 -0
  265. package/dist/src/internal/nitro/host/ports.d.ts +8 -0
  266. package/dist/src/internal/nitro/host/ports.js +1 -0
  267. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
  268. package/dist/src/internal/nitro/host/server-external-packages.d.ts +1 -1
  269. package/dist/src/internal/nitro/host/server-external-packages.js +1 -1
  270. package/dist/src/internal/nitro/host/start-development-server.js +1 -1
  271. package/dist/src/internal/nitro/host/start-production-server.js +1 -1
  272. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.d.ts +5 -0
  273. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -0
  274. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +31 -2
  275. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  276. package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.d.ts +13 -0
  277. package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.js +1 -1
  278. package/dist/src/internal/nitro/routes/info.d.ts +2 -2
  279. package/dist/src/internal/nitro/routes/info.js +1 -1
  280. package/dist/src/internal/workflow/queue-namespace.d.ts +5 -0
  281. package/dist/src/internal/workflow/queue-namespace.js +1 -0
  282. package/dist/src/internal/workflow-bundle/builder-support.js +2 -2
  283. package/dist/src/internal/workflow-bundle/builder.js +3 -5
  284. package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
  285. package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +1 -1
  286. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
  287. package/dist/src/node_modules/.pnpm/@clack_core@1.3.1/node_modules/@clack/core/dist/index.js +4 -4
  288. package/dist/src/protocol/message.d.ts +15 -0
  289. package/dist/src/protocol/message.js +2 -2
  290. package/dist/src/public/channels/slack/api.d.ts +8 -0
  291. package/dist/src/public/channels/slack/api.js +1 -1
  292. package/dist/src/public/channels/slack/connections.d.ts +26 -18
  293. package/dist/src/public/channels/slack/connections.js +1 -1
  294. package/dist/src/public/channels/slack/defaults.d.ts +5 -2
  295. package/dist/src/public/channels/slack/defaults.js +1 -1
  296. package/dist/src/public/channels/slack/index.d.ts +1 -1
  297. package/dist/src/public/channels/slack/slackChannel.d.ts +65 -5
  298. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  299. package/dist/src/public/channels/teams/defaults.js +1 -1
  300. package/dist/src/public/connections/errors.d.ts +8 -0
  301. package/dist/src/public/definitions/tool.d.ts +0 -33
  302. package/dist/src/public/next/index.d.ts +7 -1
  303. package/dist/src/public/next/index.js +1 -1
  304. package/dist/src/public/next/server.d.ts +1 -0
  305. package/dist/src/public/next/server.js +1 -1
  306. package/dist/src/public/nuxt/dev-server.js +1 -1
  307. package/dist/src/public/sandbox/backends/local.d.ts +2 -3
  308. package/dist/src/public/sveltekit/dev-server.js +1 -1
  309. package/dist/src/public/sveltekit/index.d.ts +1 -1
  310. package/dist/src/public/tools/defaults.d.ts +2 -4
  311. package/dist/src/public/tools/defaults.js +1 -1
  312. package/dist/src/public/tools/define-bash-tool.d.ts +3 -3
  313. package/dist/src/public/tools/define-bash-tool.js +1 -1
  314. package/dist/src/public/tools/define-read-file-tool.d.ts +0 -6
  315. package/dist/src/public/tools/define-read-file-tool.js +1 -1
  316. package/dist/src/public/tools/index.d.ts +2 -2
  317. package/dist/src/public/tools/index.js +1 -1
  318. package/dist/src/public/tools/internal.js +1 -1
  319. package/dist/src/runtime/actions/types.d.ts +11 -11
  320. package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
  321. package/dist/src/runtime/agent/mock-model-fixtures.js +3 -2
  322. package/dist/src/runtime/agent/mock-model-skill-selection.js +3 -4
  323. package/dist/src/runtime/connections/callback-route.js +1 -1
  324. package/dist/src/runtime/connections/mcp-client.js +1 -1
  325. package/dist/src/runtime/connections/scoped-authorization.d.ts +21 -5
  326. package/dist/src/runtime/connections/scoped-authorization.js +1 -1
  327. package/dist/src/runtime/connections/types.d.ts +33 -0
  328. package/dist/src/runtime/connections/validate-authorization.js +1 -1
  329. package/dist/src/runtime/framework-tools/bash.d.ts +3 -3
  330. package/dist/src/runtime/framework-tools/bash.js +1 -1
  331. package/dist/src/runtime/framework-tools/connection-search-dynamic.d.ts +1 -1
  332. package/dist/src/runtime/framework-tools/connection-search-dynamic.js +1 -1
  333. package/dist/src/runtime/framework-tools/file-state.d.ts +3 -3
  334. package/dist/src/runtime/framework-tools/index.js +1 -1
  335. package/dist/src/runtime/framework-tools/read-file.js +2 -2
  336. package/dist/src/runtime/framework-tools/todo.d.ts +7 -0
  337. package/dist/src/runtime/framework-tools/todo.js +2 -2
  338. package/dist/src/runtime/governance/auth/http-basic.js +1 -1
  339. package/dist/src/runtime/input/types.d.ts +1 -1
  340. package/dist/src/runtime/resolve-tool.d.ts +2 -2
  341. package/dist/src/runtime/resolve-tool.js +1 -1
  342. package/dist/src/runtime/sandbox/keys.js +1 -1
  343. package/dist/src/runtime/session-callback-route.js +1 -1
  344. package/dist/src/runtime/types.d.ts +1 -7
  345. package/dist/src/services/dev-client/client-options.d.ts +8 -0
  346. package/dist/src/services/dev-client/client-options.js +1 -0
  347. package/dist/src/services/dev-client/runtime-artifacts.d.ts +13 -0
  348. package/dist/src/services/dev-client/runtime-artifacts.js +1 -0
  349. package/dist/src/services/dev-client.d.ts +13 -46
  350. package/dist/src/services/dev-client.js +1 -1
  351. package/dist/src/services/inspect-application.js +1 -1
  352. package/dist/src/setup/ask.d.ts +205 -0
  353. package/dist/src/setup/ask.js +1 -0
  354. package/dist/src/setup/boxes/add-channels.d.ts +100 -16
  355. package/dist/src/setup/boxes/add-channels.js +2 -1
  356. package/dist/src/setup/boxes/add-connections.d.ts +13 -23
  357. package/dist/src/setup/boxes/add-connections.js +1 -1
  358. package/dist/src/setup/boxes/apply-ai-gateway-credential.d.ts +2 -2
  359. package/dist/src/setup/boxes/apply-ai-gateway-credential.js +1 -1
  360. package/dist/src/setup/boxes/deploy-project.d.ts +46 -14
  361. package/dist/src/setup/boxes/deploy-project.js +1 -1
  362. package/dist/src/setup/boxes/detect-ai-gateway.d.ts +10 -3
  363. package/dist/src/setup/boxes/detect-ai-gateway.js +1 -1
  364. package/dist/src/setup/boxes/link-project.d.ts +3 -3
  365. package/dist/src/setup/boxes/link-project.js +1 -1
  366. package/dist/src/setup/boxes/one-shot-next-steps.d.ts +18 -0
  367. package/dist/src/setup/boxes/one-shot-next-steps.js +2 -0
  368. package/dist/src/setup/boxes/preflight.d.ts +14 -6
  369. package/dist/src/setup/boxes/preflight.js +1 -1
  370. package/dist/src/setup/boxes/resolve-provisioning.d.ts +36 -8
  371. package/dist/src/setup/boxes/resolve-provisioning.js +1 -1
  372. package/dist/src/setup/boxes/resolve-target.d.ts +25 -8
  373. package/dist/src/setup/boxes/resolve-target.js +1 -1
  374. package/dist/src/setup/boxes/scaffold.d.ts +12 -6
  375. package/dist/src/setup/boxes/scaffold.js +1 -1
  376. package/dist/src/setup/boxes/select-channels.d.ts +38 -9
  377. package/dist/src/setup/boxes/select-channels.js +1 -1
  378. package/dist/src/setup/boxes/select-chat.d.ts +15 -11
  379. package/dist/src/setup/boxes/select-chat.js +1 -1
  380. package/dist/src/setup/boxes/select-connections.d.ts +30 -0
  381. package/dist/src/setup/boxes/select-connections.js +1 -0
  382. package/dist/src/setup/boxes/select-model.d.ts +18 -14
  383. package/dist/src/setup/boxes/select-model.js +1 -1
  384. package/dist/src/setup/boxes/select-setup-mode.d.ts +32 -0
  385. package/dist/src/setup/boxes/select-setup-mode.js +1 -0
  386. package/dist/src/setup/channel-add-conflicts.d.ts +28 -0
  387. package/dist/src/setup/channel-add-conflicts.js +1 -0
  388. package/dist/src/setup/cli/channel-setup-prompter.d.ts +23 -0
  389. package/dist/src/setup/cli/channel-setup-prompter.js +1 -0
  390. package/dist/src/setup/cli/connection-add-prompter.d.ts +8 -0
  391. package/dist/src/setup/cli/connection-add-prompter.js +1 -0
  392. package/dist/src/setup/{scaffold/cli → cli}/index.d.ts +4 -3
  393. package/dist/src/setup/cli/index.js +1 -0
  394. package/dist/src/setup/{scaffold/cli → cli}/prompt-ui.d.ts +39 -15
  395. package/dist/src/setup/cli/prompt-ui.js +5 -0
  396. package/dist/src/setup/{scaffold/cli → cli}/rail-log.d.ts +2 -0
  397. package/dist/src/setup/{scaffold/cli → cli}/rail-log.js +2 -2
  398. package/dist/src/setup/{scaffold/cli → cli}/select-component.d.ts +18 -3
  399. package/dist/src/setup/cli/select-component.js +1 -0
  400. package/dist/src/setup/cli/select-option-codec.d.ts +12 -0
  401. package/dist/src/setup/cli/select-option-codec.js +1 -0
  402. package/dist/src/setup/{scaffold/cli → cli}/select-state.d.ts +13 -1
  403. package/dist/src/setup/cli/select-state.js +1 -0
  404. package/dist/src/setup/cli/whimsy.d.ts +16 -0
  405. package/dist/src/setup/cli/whimsy.js +1 -0
  406. package/dist/src/setup/{scaffold/steps/setup-connection.d.ts → connection-connector.d.ts} +3 -2
  407. package/dist/src/setup/connection-connector.js +1 -0
  408. package/dist/src/setup/flows/channels.d.ts +43 -0
  409. package/dist/src/setup/flows/channels.js +1 -0
  410. package/dist/src/setup/flows/deploy.d.ts +40 -0
  411. package/dist/src/setup/flows/deploy.js +1 -0
  412. package/dist/src/setup/flows/in-project.d.ts +16 -0
  413. package/dist/src/setup/flows/in-project.js +1 -0
  414. package/dist/src/setup/flows/link.d.ts +43 -0
  415. package/dist/src/setup/flows/link.js +1 -0
  416. package/dist/src/setup/flows/model.d.ts +112 -0
  417. package/dist/src/setup/flows/model.js +1 -0
  418. package/dist/src/setup/flows/vercel.d.ts +31 -0
  419. package/dist/src/setup/flows/vercel.js +2 -0
  420. package/dist/src/setup/gateway-models.js +1 -1
  421. package/dist/src/setup/headless.d.ts +1 -1
  422. package/dist/src/setup/index.d.ts +10 -4
  423. package/dist/src/setup/index.js +1 -1
  424. package/dist/src/setup/onboarding.d.ts +7 -4
  425. package/dist/src/setup/onboarding.js +1 -1
  426. package/dist/src/setup/package-manager.d.ts +27 -0
  427. package/dist/src/setup/package-manager.js +1 -0
  428. package/dist/src/setup/primitives/index.d.ts +3 -0
  429. package/dist/src/setup/primitives/index.js +1 -0
  430. package/dist/src/setup/primitives/pm/bun.d.ts +10 -0
  431. package/dist/src/setup/primitives/pm/bun.js +1 -0
  432. package/dist/src/setup/primitives/pm/index.d.ts +11 -0
  433. package/dist/src/setup/primitives/pm/index.js +1 -0
  434. package/dist/src/setup/primitives/pm/npm.d.ts +10 -0
  435. package/dist/src/setup/primitives/pm/npm.js +1 -0
  436. package/dist/src/setup/primitives/pm/pnpm.d.ts +27 -0
  437. package/dist/src/setup/primitives/pm/pnpm.js +8 -0
  438. package/dist/src/setup/primitives/pm/run.d.ts +23 -0
  439. package/dist/src/setup/primitives/pm/run.js +1 -0
  440. package/dist/src/setup/primitives/pm/shared.d.ts +8 -0
  441. package/dist/src/setup/primitives/pm/shared.js +1 -0
  442. package/dist/src/setup/primitives/pm/types.d.ts +37 -0
  443. package/dist/src/setup/primitives/pm/types.js +1 -0
  444. package/dist/src/setup/primitives/pm/yarn.d.ts +10 -0
  445. package/dist/src/setup/primitives/pm/yarn.js +1 -0
  446. package/dist/src/setup/primitives/run-pnpm.d.ts +1 -0
  447. package/dist/src/setup/primitives/run-pnpm.js +1 -0
  448. package/dist/src/setup/{scaffold/primitives → primitives}/run-vercel.d.ts +7 -0
  449. package/dist/src/setup/primitives/run-vercel.js +1 -0
  450. package/dist/src/setup/project-name.d.ts +4 -0
  451. package/dist/src/setup/project-name.js +1 -0
  452. package/dist/src/setup/project-resolution.d.ts +54 -0
  453. package/dist/src/setup/project-resolution.js +1 -0
  454. package/dist/src/setup/prompter.d.ts +52 -4
  455. package/dist/src/setup/prompter.js +1 -1
  456. package/dist/src/setup/quit-guard.d.ts +1 -1
  457. package/dist/src/setup/run-vercel-link.d.ts +1 -1
  458. package/dist/src/setup/run-vercel-link.js +1 -1
  459. package/dist/src/setup/runner.d.ts +5 -4
  460. package/dist/src/setup/runner.js +1 -1
  461. package/dist/src/setup/scaffold/channels-catalog.d.ts +3 -3
  462. package/dist/src/setup/scaffold/channels-catalog.js +1 -1
  463. package/dist/src/setup/scaffold/create/add-to-project.d.ts +26 -0
  464. package/dist/src/setup/scaffold/create/add-to-project.js +1 -0
  465. package/dist/src/setup/scaffold/create/project.d.ts +54 -0
  466. package/dist/src/setup/scaffold/create/project.js +80 -0
  467. package/dist/src/setup/scaffold/index.d.ts +4 -4
  468. package/dist/src/setup/scaffold/index.js +1 -1
  469. package/dist/src/setup/scaffold/{channels.d.ts → update/channels.d.ts} +11 -0
  470. package/dist/src/setup/scaffold/update/channels.js +7 -0
  471. package/dist/src/setup/scaffold/{connections.d.ts → update/connections.d.ts} +1 -1
  472. package/dist/src/setup/scaffold/update/connections.js +21 -0
  473. package/dist/src/setup/scaffold/version-tokens.d.ts +11 -0
  474. package/dist/src/setup/scaffold/version-tokens.js +1 -0
  475. package/dist/src/setup/{scaffold/steps/setup-slackbot.d.ts → slackbot.d.ts} +24 -20
  476. package/dist/src/setup/slackbot.js +1 -0
  477. package/dist/src/setup/state.d.ts +62 -15
  478. package/dist/src/setup/state.js +1 -1
  479. package/dist/src/setup/step.d.ts +9 -18
  480. package/dist/src/setup/vercel-project.d.ts +15 -8
  481. package/dist/src/setup/vercel-project.js +1 -1
  482. package/dist/src/shared/agent-definition.d.ts +9 -3
  483. package/dist/src/shared/default-agent-model.d.ts +5 -0
  484. package/dist/src/shared/default-agent-model.js +1 -0
  485. package/dist/src/shared/sandbox-backend.d.ts +11 -11
  486. package/dist/src/source-change/apply-model-name.d.ts +25 -0
  487. package/dist/src/source-change/apply-model-name.js +2 -0
  488. package/dist/src/source-change/static-source-change.d.ts +36 -0
  489. package/dist/src/source-change/static-source-change.js +1 -0
  490. package/dist/src/svelte/index.js +1 -1
  491. package/dist/src/svelte/use-eve-agent.js +1 -1
  492. package/dist/src/vue/index.js +1 -1
  493. package/dist/src/vue/use-eve-agent.js +1 -1
  494. package/package.json +23 -38
  495. package/dist/docs/public/advanced/evals.md +0 -121
  496. package/dist/src/cli/commands/setup.d.ts +0 -55
  497. package/dist/src/cli/commands/setup.js +0 -1
  498. package/dist/src/cli/dev/repl/input-requests.d.ts +0 -38
  499. package/dist/src/cli/dev/repl/input-requests.js +0 -1
  500. package/dist/src/cli/dev/repl/input.d.ts +0 -19
  501. package/dist/src/cli/dev/repl/input.js +0 -1
  502. package/dist/src/cli/dev/repl/repl.d.ts +0 -62
  503. package/dist/src/cli/dev/repl/repl.js +0 -2
  504. package/dist/src/cli/dev/repl/terminal.d.ts +0 -21
  505. package/dist/src/cli/dev/repl/terminal.js +0 -5
  506. package/dist/src/compiled/_chunks/workflow/resume-hook-0Zk0zSvq.js +0 -12
  507. package/dist/src/compiled/_chunks/workflow/sleep-DXZr2BgM.js +0 -1
  508. package/dist/src/evals/define-eval-suite.d.ts +0 -16
  509. package/dist/src/evals/define-eval-suite.js +0 -1
  510. package/dist/src/evals/runner/execute-case.d.ts +0 -23
  511. package/dist/src/evals/runner/execute-case.js +0 -1
  512. package/dist/src/evals/runner/execute-suite.d.ts +0 -24
  513. package/dist/src/evals/runner/execute-suite.js +0 -1
  514. package/dist/src/evals/scorers/autoevals-client.js +0 -2
  515. package/dist/src/evals/scorers/autoevals.d.ts +0 -58
  516. package/dist/src/evals/scorers/autoevals.js +0 -1
  517. package/dist/src/evals/scorers/json.d.ts +0 -10
  518. package/dist/src/evals/scorers/json.js +0 -1
  519. package/dist/src/evals/scorers/run.d.ts +0 -18
  520. package/dist/src/evals/scorers/run.js +0 -1
  521. package/dist/src/evals/scorers/sql.d.ts +0 -9
  522. package/dist/src/evals/scorers/sql.js +0 -1
  523. package/dist/src/evals/scorers/text.d.ts +0 -18
  524. package/dist/src/evals/scorers/text.js +0 -1
  525. package/dist/src/evals/scores/index.d.ts +0 -72
  526. package/dist/src/evals/scores/index.js +0 -1
  527. package/dist/src/execution/tool-compaction.d.ts +0 -9
  528. package/dist/src/execution/tool-compaction.js +0 -1
  529. package/dist/src/services/dev-client/stream.d.ts +0 -5
  530. package/dist/src/services/dev-client/stream.js +0 -1
  531. package/dist/src/services/dev-client/url.d.ts +0 -11
  532. package/dist/src/services/dev-client/url.js +0 -1
  533. package/dist/src/setup/channel-setup-prompter.d.ts +0 -8
  534. package/dist/src/setup/channel-setup-prompter.js +0 -1
  535. package/dist/src/setup/scaffold/channels.js +0 -7
  536. package/dist/src/setup/scaffold/cli/channel-add-prompter.d.ts +0 -12
  537. package/dist/src/setup/scaffold/cli/channel-add-prompter.js +0 -1
  538. package/dist/src/setup/scaffold/cli/channel-setup-prompter.d.ts +0 -56
  539. package/dist/src/setup/scaffold/cli/connection-add-prompter.d.ts +0 -44
  540. package/dist/src/setup/scaffold/cli/connection-add-prompter.js +0 -1
  541. package/dist/src/setup/scaffold/cli/index.js +0 -1
  542. package/dist/src/setup/scaffold/cli/prompt-ui.js +0 -5
  543. package/dist/src/setup/scaffold/cli/select-component.js +0 -1
  544. package/dist/src/setup/scaffold/cli/select-state.js +0 -1
  545. package/dist/src/setup/scaffold/connections.js +0 -21
  546. package/dist/src/setup/scaffold/pnpm-workspace.d.ts +0 -3
  547. package/dist/src/setup/scaffold/pnpm-workspace.js +0 -11
  548. package/dist/src/setup/scaffold/primitives/detect-deployment.d.ts +0 -13
  549. package/dist/src/setup/scaffold/primitives/detect-deployment.js +0 -1
  550. package/dist/src/setup/scaffold/primitives/index.d.ts +0 -3
  551. package/dist/src/setup/scaffold/primitives/index.js +0 -1
  552. package/dist/src/setup/scaffold/primitives/pnpm-invocation.d.ts +0 -12
  553. package/dist/src/setup/scaffold/primitives/pnpm-invocation.js +0 -1
  554. package/dist/src/setup/scaffold/primitives/run-pnpm.d.ts +0 -17
  555. package/dist/src/setup/scaffold/primitives/run-pnpm.js +0 -1
  556. package/dist/src/setup/scaffold/primitives/run-vercel.js +0 -1
  557. package/dist/src/setup/scaffold/project.d.ts +0 -21
  558. package/dist/src/setup/scaffold/project.js +0 -80
  559. package/dist/src/setup/scaffold/steps/deploy-to-vercel.d.ts +0 -17
  560. package/dist/src/setup/scaffold/steps/deploy-to-vercel.js +0 -1
  561. package/dist/src/setup/scaffold/steps/index.d.ts +0 -4
  562. package/dist/src/setup/scaffold/steps/index.js +0 -1
  563. package/dist/src/setup/scaffold/steps/project-resolution.d.ts +0 -19
  564. package/dist/src/setup/scaffold/steps/project-resolution.js +0 -1
  565. package/dist/src/setup/scaffold/steps/run-add-connection.d.ts +0 -40
  566. package/dist/src/setup/scaffold/steps/run-add-connection.js +0 -1
  567. package/dist/src/setup/scaffold/steps/run-add-to-agent.d.ts +0 -81
  568. package/dist/src/setup/scaffold/steps/run-add-to-agent.js +0 -2
  569. package/dist/src/setup/scaffold/steps/setup-connection.js +0 -1
  570. package/dist/src/setup/scaffold/steps/setup-slackbot.js +0 -1
  571. /package/dist/src/{setup/scaffold/cli/channel-setup-prompter.js → cli/dev/tui/setup-flow.js} +0 -0
  572. /package/dist/src/evals/{scorers/autoevals-client.d.ts → autoevals-client.d.ts} +0 -0
  573. /package/dist/src/setup/{scaffold/cli → cli}/command-output.d.ts +0 -0
  574. /package/dist/src/setup/{scaffold/cli → cli}/command-output.js +0 -0
  575. /package/dist/src/setup/{scaffold/human-action.d.ts → human-action.d.ts} +0 -0
  576. /package/dist/src/setup/{scaffold/human-action.js → human-action.js} +0 -0
  577. /package/dist/src/setup/{scaffold/primitives → primitives}/process-output.d.ts +0 -0
  578. /package/dist/src/setup/{scaffold/primitives → primitives}/process-output.js +0 -0
  579. /package/dist/src/setup/scaffold/{web-template.d.ts → create/web-template.d.ts} +0 -0
  580. /package/dist/src/setup/scaffold/{web-template.js → create/web-template.js} +0 -0
  581. /package/dist/src/setup/scaffold/{module-files.d.ts → update/module-files.d.ts} +0 -0
  582. /package/dist/src/setup/scaffold/{module-files.js → update/module-files.js} +0 -0
  583. /package/dist/src/setup/scaffold/{package-json.d.ts → update/package-json.d.ts} +0 -0
  584. /package/dist/src/setup/scaffold/{package-json.js → update/package-json.js} +0 -0
  585. /package/dist/src/setup/scaffold/{primitives → update}/update-connection-connector.d.ts +0 -0
  586. /package/dist/src/setup/scaffold/{primitives → update}/update-connection-connector.js +0 -0
  587. /package/dist/src/setup/scaffold/{primitives → update}/update-slack-channel.d.ts +0 -0
  588. /package/dist/src/setup/scaffold/{primitives → update}/update-slack-channel.js +0 -0
@@ -0,0 +1,35 @@
1
+ import type { SelectNotice } from "#setup/prompter.js";
2
+ import type { SetupPanelOption } from "./setup-panel.js";
3
+ export interface SetupFlowRenderer {
4
+ begin(title: string): void;
5
+ end(options?: {
6
+ preserveDiagnostics?: boolean;
7
+ }): void;
8
+ readSelect(options: {
9
+ message: string;
10
+ options: readonly SetupPanelOption[];
11
+ multiple: boolean;
12
+ search: boolean;
13
+ required: boolean;
14
+ initialValue?: string;
15
+ initialValues?: readonly string[];
16
+ placeholder?: string;
17
+ layout?: "stacked";
18
+ notices?: readonly SelectNotice[];
19
+ }): Promise<readonly string[] | undefined>;
20
+ readText(options: {
21
+ message: string;
22
+ placeholder?: string;
23
+ defaultValue?: string;
24
+ mask?: boolean;
25
+ validate?: (value: string) => string | undefined;
26
+ }): Promise<string | undefined>;
27
+ readAcknowledge(options: {
28
+ message: string;
29
+ lines: readonly string[];
30
+ }): Promise<void>;
31
+ setStatus(text: string | undefined): void;
32
+ renderLine(text: string, tone: "info" | "success" | "warning" | "error"): void;
33
+ renderOutput(text: string): void;
34
+ }
35
+ export type SetupFlowPrompterRenderer = Pick<SetupFlowRenderer, "readSelect" | "readText" | "readAcknowledge" | "setStatus" | "renderLine" | "renderOutput">;
@@ -0,0 +1,40 @@
1
+ import type { AgentInfoResult } from "#client/index.js";
2
+ /** One boot-time setup problem the TUI can point at a fixing command. */
3
+ export interface SetupIssue {
4
+ /** Short category label, e.g. "AI Gateway credentials". */
5
+ label: string;
6
+ /** The slash command that fixes it, e.g. "/model". */
7
+ command: string;
8
+ }
9
+ /** What a boot detection may inspect. */
10
+ export interface BootDetectionContext {
11
+ /** The local project the in-process dev server is running. */
12
+ appRoot: string;
13
+ /** `eve dev` loads the project env files before the TUI boots. */
14
+ env: Record<string, string | undefined>;
15
+ /** Best-effort agent truth from the header fetch; undefined when unavailable. */
16
+ info?: AgentInfoResult;
17
+ }
18
+ /**
19
+ * One installation-state check run at TUI boot, before the user hits the
20
+ * failure mid-conversation. Detections must stay cheap and local (env reads,
21
+ * a single fs stat) — they run between the header and the first prompt.
22
+ */
23
+ export interface BootDetection {
24
+ id: string;
25
+ detect(context: BootDetectionContext): SetupIssue[] | Promise<SetupIssue[]>;
26
+ }
27
+ /** The built-in boot detections, run in order. */
28
+ export declare const BOOT_DETECTIONS: readonly BootDetection[];
29
+ /**
30
+ * Runs the boot detections and aggregates their issues. Each detection is
31
+ * individually guarded: one that throws contributes nothing and never blocks
32
+ * the prompt.
33
+ */
34
+ export declare function detectSetupIssues(context: BootDetectionContext, detections?: readonly BootDetection[]): Promise<SetupIssue[]>;
35
+ /**
36
+ * The attention line's body, mirroring Claude Code's
37
+ * `1 setup issue: MCP · /doctor` shape; the renderer prefixes the warning
38
+ * glyph and paints the command blue.
39
+ */
40
+ export declare function formatSetupIssuesLine(issues: readonly SetupIssue[]): string;
@@ -0,0 +1 @@
1
+ import{join}from"node:path";import{pathExists}from"#setup/path-exists.js";const BOOT_DETECTIONS=[{id:`model-provider`,async detect({appRoot:n,env:r}){return r.AI_GATEWAY_API_KEY||r.VERCEL_OIDC_TOKEN?[]:await pathExists(join(n,`.vercel`,`project.json`))?[{label:`AI Gateway credentials missing`,command:`/model`}]:[{label:`model provider not linked`,command:`/model`}]}}];async function detectSetupIssues(e,t=BOOT_DETECTIONS){return(await Promise.all(t.map(async t=>{try{return await t.detect(e)}catch{return[]}}))).flat()}function formatSetupIssuesLine(e){let t=e.length===1?`setup issue`:`setup issues`,n=e.map(e=>`${e.label} · ${e.command}`).join(`, `);return`${e.length} ${t}: ${n}`}export{BOOT_DETECTIONS,detectSetupIssues,formatSetupIssuesLine};
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Pure rendering for the bordered setup flow panel — the input-region variant
3
+ * a setup command runs inside for its whole duration (the Claude Code
4
+ * `/model`-panel grammar): a full-width rule, the command as a blue title,
5
+ * the flow's recent progress lines, and the active question (numbered option
6
+ * rows or a text field) or the ephemeral status spinner. Behavior state comes
7
+ * from the shared select reducer (`#setup/cli/select-state.js`); this module
8
+ * only paints rows, so the renderer hosts lifecycle and keys while tests
9
+ * assert on strings.
10
+ *
11
+ * Column grammar: the panel adds a one-space left margin to every row under
12
+ * the rule, so gutter glyphs (cursor, spinner, tone marks) sit at column 1
13
+ * and written text always starts at column 3. The question renderers stay
14
+ * margin-free (glyphs 0, text 2) — the margin is applied once, in
15
+ * {@link renderFlowPanel}, so every question variant lines up by
16
+ * construction.
17
+ */
18
+ import type { PromptOption } from "#setup/cli/index.js";
19
+ import { type SelectState } from "#setup/cli/select-state.js";
20
+ import type { SelectNotice } from "#setup/prompter.js";
21
+ import { type LineState } from "./line-editor.js";
22
+ import type { Theme } from "./theme.js";
23
+ /** One row of a setup select panel; the shared prompt-option shape. */
24
+ export type SetupPanelOption = PromptOption<string>;
25
+ export interface SetupSelectPanelState {
26
+ message: string;
27
+ options: readonly SetupPanelOption[];
28
+ multiple: boolean;
29
+ search: boolean;
30
+ placeholder?: string;
31
+ select: SelectState;
32
+ error?: string;
33
+ /** "stacked" puts each hint on its own line with blank rows between options. */
34
+ layout?: "stacked";
35
+ /** Outcome lines from earlier menu laps, shown beneath the options. */
36
+ notices?: readonly SelectNotice[];
37
+ }
38
+ export interface SetupTextPanelState {
39
+ message: string;
40
+ editor: LineState;
41
+ placeholder?: string;
42
+ mask: boolean;
43
+ error?: string;
44
+ }
45
+ export interface SetupAcknowledgePanelState {
46
+ message: string;
47
+ lines: readonly string[];
48
+ }
49
+ /** One progress line shown inside the flow panel while it runs. */
50
+ export interface FlowPanelLine {
51
+ text: string;
52
+ tone: "info" | "success" | "warning" | "error";
53
+ }
54
+ /** The whole bordered section: title, recent progress, question or status. */
55
+ export interface FlowPanelState {
56
+ /** The invoked command, e.g. "/deploy". Empty renders no title row. */
57
+ title: string;
58
+ lines: readonly FlowPanelLine[];
59
+ /** Ephemeral status shown when no question is active. */
60
+ status?: {
61
+ text: string;
62
+ frame: string;
63
+ };
64
+ /**
65
+ * The latest subprocess output line — a transient preview replaced on every
66
+ * write, mirroring the rail-log's command preview. Shown dim under the
67
+ * status (or alone behind the spinner) and never persisted.
68
+ */
69
+ preview?: string;
70
+ /** The current spinner frame, for the preview/idle pulse rows. */
71
+ frame?: string;
72
+ /** The active question's rows (a select or text section). */
73
+ question?: readonly string[];
74
+ }
75
+ /**
76
+ * Paints the bordered flow panel. Everything a running command produces lives
77
+ * here — progress, questions, the status spinner — and the panel vanishes
78
+ * wholesale when the command resolves; only the command echo and the elbow
79
+ * outcome persist in the transcript.
80
+ */
81
+ export declare function renderFlowPanel(state: FlowPanelState, theme: Theme, width: number): string[];
82
+ /**
83
+ * Paints a select question section (for the flow panel). The cursor row's
84
+ * `description` rides on a dim line beneath it; a searchable question windows
85
+ * the option list around the cursor (a leading run of `featured` options
86
+ * sizes the unfiltered viewport) and advertises the rest with a count footer.
87
+ */
88
+ export declare function renderSelectQuestion(state: SetupSelectPanelState, theme: Theme, width: number): string[];
89
+ /** True when a select question numbers its rows (and accepts digit jumps). */
90
+ export declare function numbersSelectRows(state: {
91
+ multiple: boolean;
92
+ search: boolean;
93
+ options: readonly SetupPanelOption[];
94
+ }): boolean;
95
+ /** Paints a text question section: message, a caret-bearing input line, hints. */
96
+ export declare function renderTextQuestion(state: SetupTextPanelState, theme: Theme, width: number, caretVisible: boolean): string[];
97
+ /**
98
+ * Paints a static acknowledgement section (for the flow panel): a heading and
99
+ * dim body lines where option rows normally sit, held until the user
100
+ * dismisses it. There is nothing to cancel — the text is the point — so the
101
+ * footer advertises only enter.
102
+ */
103
+ export declare function renderAcknowledgeQuestion(state: SetupAcknowledgePanelState, theme: Theme, width: number): string[];
@@ -0,0 +1 @@
1
+ import{sliceVisible,visibleLength}from"./terminal-text.js";import{visibleLine}from"./line-editor.js";import{filterOptions,submitRowIndex}from"#setup/cli/select-state.js";function clip(n,r){return visibleLength(n)>r?sliceVisible(n,r):n}function questionFooter(e,t){let n=t.colors;return[``,` ${n.dim(n.italic(e.join(` ${t.glyph.dot} `)))}`]}const BOLD_OR_DIM_CLOSE=`\x1B[22m`;function dimWithEmphasis(e,t){return t.colors.dim(e.replaceAll(BOLD_OR_DIM_CLOSE,`${BOLD_OR_DIM_CLOSE}`))}function toneGlyph(e,t){let n=t.colors;switch(e){case`success`:return n.green(t.glyph.success);case`warning`:return n.yellow(t.glyph.warning);case`error`:return n.red(t.glyph.error);case`info`:return n.dim(t.glyph.dot)}}function renderFlowPanel(e,t,n){let r=t.colors,i=[r.dim(t.glyph.hrule.repeat(Math.max(1,n)))];e.title.length>0&&i.push(` ${r.blue(r.bold(e.title))}`),i.push(``);let a=e.lines.slice(-6);for(let e of a){let n=e.tone===`info`?r.dim(e.text):e.text;i.push(`${toneGlyph(e.tone,t)} ${n}`)}return a.length>0&&i.push(``),e.question===void 0?e.status===void 0?e.preview===void 0?i.push(`${r.yellow(e.frame??``)} ${r.dim(`Working…`)}`):i.push(`${r.yellow(e.frame??``)} ${r.dim(e.preview)}`):(i.push(`${r.yellow(e.status.frame)} ${r.dim(e.status.text)}`),e.preview!==void 0&&i.push(` ${r.dim(e.preview)}`)):i.push(...e.question),i.map((e,t)=>t===0||e.length===0?clip(e,n):clip(` ${e}`,n))}function optionRow(e){let{option:t,theme:n}=e,r=n.colors,i=e.isCursor?r.cyan(n.glyph.prompt):` `,a=e.number===void 0?``:`${e.number}. `,o=e.checkbox?`${t.locked?r.dim(`◼`):e.isChecked?r.green(`◼`):r.dim(`◻`)} `:``,s=t.label;t.disabled?s=r.dim(`${s}${t.disabledReason?` (${t.disabledReason})`:``}`):t.locked?s=r.dim(`${s}${t.lockedReason?` (${t.lockedReason})`:``}`):e.isCursor&&(s=r.blue(s));let c=t.hint?r.dim(` ${n.glyph.dot} ${t.hint}`):``;return`${i} ${a}${o}${s}${c}`}function renderSelectQuestion(e,t,n){let a=t.colors,o=e.search?filterOptions(e.options,e.select.filter):e.options,s=e.multiple?submitRowIndex(o):-1,c=e.select.cursor,l=[` ${a.bold(e.message)}`,``],u=numbersSelectRows(e);if(e.search){let n=e.select.filter.length>0?e.select.filter+a.dim(t.glyph.caret):e.placeholder===void 0?a.dim(t.glyph.caret):a.dim(e.placeholder);l.push(` ${n}`,``)}let d=0;for(;o[d]?.featured;)d+=1;let f=e.search&&e.select.filter===``&&d>0?Math.min(d,8):e.search?8:o.length,p=Math.max(0,Math.min(c-Math.floor(f/2),Math.max(0,o.length-f))),m=Math.min(p+f,o.length);o.length===0&&l.push(` ${a.dim(`(no matches)`)}`);for(let n=p;n<m;n+=1){let r=o[n],i=n===c,s=e.layout===`stacked`,d=r;if(s&&r.hint!==void 0){let{hint:e,...t}=r;d=t}let f={option:d,isCursor:i,isChecked:e.multiple&&e.select.selected.has(r.value),checkbox:e.multiple,theme:t};if(u&&(f.number=n+1),l.push(optionRow(f)),s&&r.hint!==void 0){let e=` `.repeat(2+(u?`${n+1}. `.length:0));l.push(`${e}${dimWithEmphasis(r.hint,t)}`)}i&&r.description&&!r.disabled&&l.push(` ${a.dim(r.description)}`),s&&n<m-1&&l.push(``)}if(e.multiple&&s>=0){let e=c===s,n=e?a.cyan(t.glyph.prompt):` `,r=e?a.blue(a.bold(`Submit`)):`Submit`;l.push(``,`${n} ${r}`)}if(o.length>m-p&&l.push(` ${a.dim(`↑↓ ${o.length} options, showing ${p+1}–${m}`)}`),e.notices!==void 0&&e.notices.length>0){l.push(``);for(let n of e.notices){let e=n.tone===`info`?a.dim(n.text):n.text;l.push(` ${toneGlyph(n.tone,t)} ${e}`)}}e.error!==void 0&&l.push(``,` ${a.red(e.error)}`);let h=[];return e.search&&h.push(`type to filter`),h.push(`↑/↓ move`),h.push(e.multiple?`space to toggle`:`enter to select`),e.multiple&&h.push(`enter on Submit to confirm`),h.push(`esc to cancel`),l.push(...questionFooter(h,t)),l.map(e=>clip(e,n))}function numbersSelectRows(e){return!e.multiple&&!e.search&&e.options.length>1}function renderTextQuestion(e,t,r,i){let a=t.colors,o=[` ${a.bold(e.message)}`,``],s=Math.max(4,r-4),{before:c,after:l}=visibleLine(e.mask?{text:`•`.repeat(e.editor.text.length),cursor:e.editor.cursor}:{text:e.editor.text,cursor:e.editor.cursor},s,t.glyph.ellipsis),u=i?a.cyan(t.glyph.caret):` `,d=e.editor.text.length===0&&e.placeholder!==void 0?`${u}${a.dim(e.placeholder)}`:`${c}${u}${l}`;return o.push(` ${d}`),e.error!==void 0&&o.push(``,` ${a.red(e.error)}`),o.push(...questionFooter([`enter to submit`,`esc to cancel`],t)),o.map(e=>clip(e,r))}function renderAcknowledgeQuestion(e,t,n){let r=t.colors,i=[` ${r.bold(e.message)}`];if(e.lines.length>0){i.push(``);for(let t of e.lines)i.push(` ${r.dim(t)}`)}return i.push(...questionFooter([`enter to continue`],t)),i.map(e=>clip(e,n))}export{numbersSelectRows,renderAcknowledgeQuestion,renderFlowPanel,renderSelectQuestion,renderTextQuestion};
@@ -0,0 +1,25 @@
1
+ import type { Theme } from "./theme.js";
2
+ import type { VercelStatusSnapshot } from "./vercel-status.js";
3
+ export interface StatusLineInput {
4
+ /** Resolved model slug, e.g. "anthropic/claude-sonnet-4-6"; absent when `/eve/v1/info` failed. */
5
+ model?: string;
6
+ /** Preformatted token-flow segment (formatTokenFlow output), e.g. `⁕ ↑ 394.4K ↓ 4.3K`. */
7
+ tokens?: string;
8
+ /** Workspace-scoped Vercel state; identity absent while unlinked or still resolving. */
9
+ vercel?: VercelStatusSnapshot;
10
+ theme: Theme;
11
+ width: number;
12
+ }
13
+ /**
14
+ * Builds the dev TUI's persistent one-row status line:
15
+ *
16
+ * `model · tokens · ▲ project (team) · deploy pending`
17
+ *
18
+ * Everything renders dim except the yellow pending-deploy marker — the one
19
+ * segment that asks for action. On narrow widths segments degrade in a fixed
20
+ * order — team suffix, then the project segment, then the model — keeping the
21
+ * live, actionable signals (tokens, pending deploy) longest; the model and
22
+ * project identity remain recoverable from the agent header in scrollback.
23
+ * Returns undefined when no segment has content so callers skip the row.
24
+ */
25
+ export declare function buildStatusLine(input: StatusLineInput): string | undefined;
@@ -0,0 +1 @@
1
+ import{sliceVisible,visibleLength}from"./terminal-text.js";function buildStatusLine(t){let{theme:n,width:r}=t,i=n.colors,a=t.model===void 0?void 0:i.dim(t.model),o=t.tokens===void 0?void 0:i.dim(t.tokens),s=t.vercel?.pendingDeploy?i.yellow(`deploy pending`):void 0,c=t.vercel?.identity,l=c===void 0?void 0:i.dim(`${n.glyph.brand} ${c.projectName}`),u=c?.teamName===void 0?l:i.dim(`${n.glyph.brand} ${c.projectName} (${c.teamName})`),d=` ${i.dim(n.glyph.dot)} `,compose=e=>e.filter(e=>e!==void 0).join(d),f=[compose([a,o,u,s]),compose([a,o,l,s]),compose([a,o,s]),compose([o,s])];if(f[0].length!==0){for(let e of f)if(e.length>0&&visibleLength(e)<=r)return e;return sliceVisible(f.findLast(e=>e.length>0),r)}}export{buildStatusLine};
@@ -72,5 +72,20 @@ export interface AssistantResponseStats {
72
72
  tokensPerSecond: number | undefined;
73
73
  }
74
74
  export declare function takeUntil<T>(source: AsyncIterable<T>, stop: Promise<void>): AsyncIterable<T>;
75
- export declare function formatTokenCount(tokens: number | undefined, contextSize?: number): string | undefined;
75
+ /** `394.4K`-style compact count: plain below 1000, then K/M with one trimmed decimal. */
76
+ export declare function formatCompactTokenCount(count: number): string;
77
+ /**
78
+ * The status line's token-flow segment: `⁕ ↑ 394.4K ↓ 4.3K`, input (prompt)
79
+ * tokens up, output tokens down, both from the latest usage report. A known
80
+ * `--context-size` appends the context-fill percentage of the input side.
81
+ */
82
+ export declare function formatTokenFlow(flow: {
83
+ inputTokens: number;
84
+ outputTokens: number;
85
+ contextSize?: number;
86
+ }, glyph: {
87
+ tokens: string;
88
+ arrowUp: string;
89
+ arrowDown: string;
90
+ }): string;
76
91
  export declare function formatAssistantResponseStats(stats: AssistantResponseStats, mode: AssistantResponseStatsMode): string | undefined;
@@ -1,2 +1,2 @@
1
1
  const CSI_FINAL=/[\u0040-\u007e]/u;function nextKey(t){let n=t[0];if(n===void 0)return{consumed:0,incomplete:!0};if(n===`\x1B`){if(t.length===1)return{consumed:0,incomplete:!0};let n=t[1];if(n===`O`)return t.length<3?{consumed:0,incomplete:!0}:{key:parseKey(Buffer.from(t.slice(0,3))),consumed:3};if(n===`[`){for(let n=2;n<t.length;n+=1)if(CSI_FINAL.test(t[n]))return{key:parseKey(Buffer.from(t.slice(0,n+1))),consumed:n+1};return{consumed:0,incomplete:!0}}return{key:{type:`escape`},consumed:1}}if(n<` `||n===``)return{key:parseKey(Buffer.from(n)),consumed:1};let r=1;for(;r<t.length;){let e=t[r];if(e===`\x1B`||e<` `||e===``)break;r+=1}return{key:parseKey(Buffer.from(t.slice(0,r))),consumed:r}}function parseKey(e){let t=e.toString(`utf8`);switch(t){case``:return{type:`ctrl-a`};case``:return{type:`ctrl-e`};case``:return{type:`ctrl-d`};case`\v`:return{type:`ctrl-k`};case`\f`:return{type:`ctrl-l`};case``:return{type:`ctrl-r`};case``:return{type:`ctrl-u`};case``:return{type:`ctrl-w`};case``:return{type:`ctrl-c`};case`\r`:case`
2
- `:return{type:`enter`};case``:case`\b`:return{type:`backspace`};case`\x1B[A`:case`\x1BOA`:return{type:`up`};case`\x1B[B`:case`\x1BOB`:return{type:`down`};case`\x1B[C`:case`\x1BOC`:return{type:`right`};case`\x1B[D`:case`\x1BOD`:return{type:`left`};case`\x1B[H`:case`\x1BOH`:case`\x1B[1~`:return{type:`home`};case`\x1B[F`:case`\x1BOF`:case`\x1B[4~`:return{type:`end`};case`\x1B[3~`:return{type:`delete`};case` `:return{type:`tab`};case`\x1B`:return{type:`escape`};default:{let e=``;for(let n of t)n>=` `&&n!==``&&(e+=n);return e.length>0?{type:`character`,value:e}:{type:`ignore`}}}}async function*takeUntil(e,t){let n=e[Symbol.asyncIterator](),r=t.then(()=>({done:!0,value:void 0}));for(;;){let e=await Promise.race([n.next(),r]);if(e.done)break;yield e.value}}function formatTokenCount(e,t){if(e==null)return;let n=`${e.toLocaleString()} ${e===1?`token`:`tokens`}`,r=formatContextPercentage(e,t);return r==null?n:`${n} ${r}`}function formatContextPercentage(e,t){if(!(t==null||t<=0||!Number.isFinite(t)))return`${Math.round(e/t*100).toLocaleString()}%`}function formatAssistantResponseStats(e,t){if(t===`tokensPerSecond`)return formatTokensPerSecond(e.tokensPerSecond);if(e.outputTokens!=null)return`${e.outputTokens.toLocaleString()} output tokens`}function formatTokensPerSecond(e){if(e!=null)return`${formatNumber(e)} tok/s`}function formatNumber(e){return Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:1})}export{formatAssistantResponseStats,formatTokenCount,nextKey,parseKey,takeUntil};
2
+ `:return{type:`enter`};case``:case`\b`:return{type:`backspace`};case`\x1B[A`:case`\x1BOA`:return{type:`up`};case`\x1B[B`:case`\x1BOB`:return{type:`down`};case`\x1B[C`:case`\x1BOC`:return{type:`right`};case`\x1B[D`:case`\x1BOD`:return{type:`left`};case`\x1B[H`:case`\x1BOH`:case`\x1B[1~`:return{type:`home`};case`\x1B[F`:case`\x1BOF`:case`\x1B[4~`:return{type:`end`};case`\x1B[3~`:return{type:`delete`};case` `:return{type:`tab`};case`\x1B`:return{type:`escape`};default:{let e=``;for(let n of t)n>=` `&&n!==``&&(e+=n);return e.length>0?{type:`character`,value:e}:{type:`ignore`}}}}async function*takeUntil(e,t){let n=e[Symbol.asyncIterator](),r=t.then(()=>({done:!0,value:void 0}));try{for(;;){let e=n.next();e.catch(()=>{});let t=await Promise.race([e,r]);if(t.done)break;yield t.value}}finally{n.return?.()?.catch(()=>{})}}function formatCompactTokenCount(e){if(e<1e3)return`${e}`;let t=e<1e6?e/1e3:e/1e6,n=e<1e6?`K`:`M`;return`${t.toFixed(1).replace(/\.0$/,``)}${n}`}function formatTokenFlow(e,t){let n=formatCompactTokenCount(e.inputTokens),r=formatCompactTokenCount(e.outputTokens),i=`${t.tokens} ${t.arrowUp} ${n} ${t.arrowDown} ${r}`,a=formatContextPercentage(e.inputTokens,e.contextSize);return a==null?i:`${i} ${a}`}function formatContextPercentage(e,t){if(!(t==null||t<=0||!Number.isFinite(t)))return`${Math.round(e/t*100).toLocaleString()}%`}function formatAssistantResponseStats(e,t){if(t===`tokensPerSecond`)return formatTokensPerSecond(e.tokensPerSecond);if(e.outputTokens!=null)return`${e.outputTokens.toLocaleString()} output tokens`}function formatTokensPerSecond(e){if(e!=null)return`${formatNumber(e)} tok/s`}function formatNumber(e){return Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:1})}export{formatAssistantResponseStats,formatCompactTokenCount,formatTokenFlow,nextKey,parseKey,takeUntil};
@@ -1,6 +1,8 @@
1
- import type { AgentTUIInputQuestion, AgentTUIInputQuestionResponse, AgentTUISessionOptions, AgentTUIStreamResult, AgentTUIToolApprovalRequest, AgentTUIToolApprovalResponse, ConnectionAuthUpdate, SubagentStepUpdate, SubagentToolUpdate } from "./runner.js";
1
+ import type { AgentTUIInputQuestion, AgentTUIInputQuestionResponse, AgentTUIRenderer, AgentTUISessionOptions, AgentTUIStreamResult, AgentTUIToolApprovalRequest, AgentTUIToolApprovalResponse, ConnectionAuthUpdate, SubagentStepUpdate, SubagentToolUpdate } from "./runner.js";
2
+ import type { SetupFlowRenderer } from "./setup-flow.js";
2
3
  import type { AssistantResponseStatsMode, LogDisplayMode, TerminalPartDisplayMode } from "./types.js";
3
4
  import type { AgentInfoResult } from "#client/index.js";
5
+ import type { VercelStatusSnapshot } from "./vercel-status.js";
4
6
  export type TerminalInput = {
5
7
  isTTY?: boolean;
6
8
  on(event: "data", listener: (chunk: Buffer) => void): TerminalInput;
@@ -10,6 +12,7 @@ export type TerminalInput = {
10
12
  setRawMode?: (mode: boolean) => TerminalInput;
11
13
  };
12
14
  export type TerminalOutput = {
15
+ isTTY?: boolean;
13
16
  columns?: number;
14
17
  rows?: number;
15
18
  write(chunk: string | Uint8Array, encodingOrCallback?: BufferEncoding | ((error?: Error | null) => void), callback?: (error?: Error | null) => void): boolean;
@@ -34,13 +37,18 @@ export type AgentHeaderOptions = {
34
37
  name: string;
35
38
  serverUrl: string;
36
39
  info?: AgentInfoResult;
40
+ /** Message-of-the-day line under the brand line (local sessions only). */
41
+ tip?: string;
37
42
  };
38
- export declare class TerminalRenderer {
43
+ export declare class TerminalRenderer implements AgentTUIRenderer {
39
44
  #private;
45
+ readonly setupFlow: SetupFlowRenderer;
40
46
  constructor(options?: TerminalRendererOptions);
41
47
  /**
42
48
  * Commits the startup agent header (brand mark + resolved configuration) to
43
- * scrollback before the first prompt. Safe to call once at startup.
49
+ * scrollback before the first prompt. Later calls (dev HMR refreshing fields
50
+ * such as the resolved model) commit a fresh header beneath the existing
51
+ * transcript; committed scrollback is never cleared or replayed.
44
52
  */
45
53
  renderAgentHeader(options: AgentHeaderOptions): void;
46
54
  readPrompt(options?: AgentTUISessionOptions): Promise<string>;
@@ -52,6 +60,7 @@ export declare class TerminalRenderer {
52
60
  markChildToolCallId(callId: string): void;
53
61
  upsertConnectionAuth(update: ConnectionAuthUpdate): void;
54
62
  setConnectionAuthPendingCount(count: number): void;
63
+ setVercelStatus(status: VercelStatusSnapshot): void;
55
64
  reset(): void;
56
65
  /**
57
66
  * Commits a single dim informational line to the transcript (e.g. the
@@ -59,5 +68,25 @@ export declare class TerminalRenderer {
59
68
  * text is blank.
60
69
  */
61
70
  renderNotice(text: string): void;
71
+ /**
72
+ * Commits the boot-time setup attention line (yellow `⚠`, commands blue),
73
+ * shown once after the agent header when boot detection finds issues.
74
+ */
75
+ renderSetupWarning(text: string): void;
76
+ /**
77
+ * Commits one command's outcome under its invocation with the elbow
78
+ * connector (` ⎿ /model cancelled.`), Claude Code's sub-result grammar.
79
+ */
80
+ renderCommandResult(text: string): void;
62
81
  shutdown(): void;
82
+ /** The log sources the transcript currently renders. */
83
+ logDisplayMode(): LogDisplayMode;
84
+ /**
85
+ * Switches which captured log sources the transcript shows. Captured
86
+ * output is buffered in the block history regardless of mode, so the
87
+ * committed transcript is re-rendered under the new filter and replayed:
88
+ * hiding removes past log lines, showing restores them at their original
89
+ * positions.
90
+ */
91
+ setLogDisplayMode(mode: LogDisplayMode): void;
63
92
  }
@@ -1,4 +1,7 @@
1
- import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{buildAgentHeader}from"./agent-header.js";import{sliceVisible,stripAnsi,visibleLength}from"./terminal-text.js";import{renderBlockLines}from"./blocks.js";import{interruptedError}from"./errors.js";import{EMPTY_LINE,PromptHistory,backspace,deleteForward,deleteWord,insert,killToEnd,killToStart,lineOf,moveEnd,moveHome,moveLeft,moveRight,visibleLine}from"./line-editor.js";import{LiveRegion}from"./live-region.js";import{createTheme,detectUnicode}from"./theme.js";import{formatAssistantResponseStats,formatTokenCount,nextKey,takeUntil}from"./stream-format.js";import{toErrorMessage}from"#shared/errors.js";const STATUS={processing:`Working…`,toolResults:`Reading results…`,streaming:`Responding…`,executingTools:`Running tools…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f=[];#p=new Map;#m=new Set;#h=new Set;#g=new Map;#_=new Set;#v;#y=0;#b=``;#x=0;#S=new PromptHistory;#C=!1;#w=!1;#T=STATUS.processing;#E=`Eve`;#D=!1;#O=!1;#k=!0;#A=0;#j;#M;#N;#P=``;#F;#I;#L;#R=!1;#z=!1;#B;#V;#H;#U;#W;#G;#K=``;#q=``;#J;constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#i=e?.tools??`auto-collapsed`,this.#a=e?.reasoning??`full`,this.#o=e?.subagents??`auto-collapsed`,this.#s=e?.connectionAuth??`full`,this.#c=e?.assistantResponseStats??`tokensPerSecond`,this.#l=e?.contextSize,this.#V=e?.contextSize,this.#u=e?.captureForeignOutput??this.#t===process.stdout,this.#d=e?.logs??`all`}renderAgentHeader(e){this.#E=e.name,this.#Z(),this.#n.clearAll();let t=buildAgentHeader({name:e.name,serverUrl:e.serverUrl,info:e.info,theme:this.#r,width:this.#Ae()});this.#n.flush(t,[])}async readPrompt(e){this.#Z(e),this.#C=!0,this.#w=!1,this.#T=``;let t=lineOf(``);return this.#S.begin(t.text),this.#Y(t),this.#ae(),this.#we(),await new Promise((e,n)=>{let apply=e=>{t=e,this.#se(),this.#Y(t),this.#we()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#oe(),this.#Q(),n(interruptedError())};this.#N=n=>{switch(n.type){case`character`:apply(insert(t,n.value));break;case`backspace`:apply(backspace(t));break;case`delete`:apply(deleteForward(t));break;case`left`:apply(moveLeft(t));break;case`right`:apply(moveRight(t));break;case`home`:case`ctrl-a`:apply(moveHome(t));break;case`end`:case`ctrl-e`:apply(moveEnd(t));break;case`ctrl-k`:apply(killToEnd(t));break;case`ctrl-u`:apply(killToStart(t));break;case`ctrl-w`:apply(deleteWord(t));break;case`up`:recall(this.#S.previous(t.text));break;case`down`:recall(this.#S.next());break;case`enter`:{let n=t.text;this.#S.add(n),this.#C=!1,this.#oe(),this.#T=STATUS.processing,isPromptControlCommand(n)||(this.#de(n),this.#J=n),this.#Y(EMPTY_LINE),this.#we(),this.#ee(),e(n);break}case`ctrl-d`:t.text.length===0?interrupt():apply(deleteForward(t));break;case`ctrl-l`:case`ctrl-r`:this.#we();break;case`ctrl-c`:interrupt();break;default:break}},this.#$()})}#Y(e){this.#b=e.text,this.#x=e.cursor}async renderStream(e,t){this.#Z(t),this.#m.clear(),this.#C=!1,this.#w=!0,this.#T=STATUS.processing,this.#fe(t?.submittedPrompt),this.#O=!1,this.#B=void 0,this.#H=void 0,this.#U=void 0,this.#W=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#ce(),this.#we();let r=new Promise(e=>{this.#L=e});this.#N=e=>this.#ie(e),this.#$();let i={text:new Map,reasoning:new Map,tools:new Map,hasPendingToolResults:!1};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#O)break;this.#ve(t,n,i)}}catch(e){this.#pe(`Error`,toErrorMessage(e))}finally{this.#L=void 0,this.#O&&e.abort?.(),this.#ee(),this.#le(),this.#w=!1,this.#T=this.#O?`Interrupted`:t?.continueSession?`Ready`:`Done`,this.#_e(),this.#we(),(this.#O||!t?.continueSession)&&this.#Q()}if(this.#O)throw interruptedError()}async readToolApproval(e,t){return this.#Z(t),this.#C=!1,this.#w=!1,this.#T=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#O=!1,this.#we(),await new Promise((t,n)=>{this.#N=r=>{switch(r.type){case`character`:{let n=r.value.toLowerCase();n===`y`?(this.#T=STATUS.processing,this.#ee(),this.#we(),t({approved:!0})):n===`n`&&(this.#T=STATUS.processing,this.#X(e.toolCallId),this.#ee(),this.#we(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#we();break;case`ctrl-c`:this.#O=!0,this.#Q(),n(interruptedError());break;default:break}},this.#$()})}async readInputQuestion(e,t){this.#Z(t),this.#C=!1,this.#w=!1,this.#O=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),c=r?`select`:`text`,l=0,u=``,isOnFreeformRow=()=>i&&l===n.length,renderSection=()=>{this.#he({id:o,kind:`question`,title:e.prompt,body:formatQuestionContent(e,l,this.#r),preformatted:!0,live:!0})},repaintStatus=()=>{if(c===`select`){let e=isOnFreeformRow()?`type`:`select`;this.#T=`↑/↓ move · enter ${e} · Ctrl+C quit`,this.#C=!1}else this.#C=!0,this.#Y(lineOf(u)),this.#T=``;this.#we()};renderSection(),c===`text`&&this.#ae(),repaintStatus();let finalize=t=>{this.#he({id:o,kind:`question`,title:e.prompt,body:` ${this.#r.colors.green(this.#r.glyph.success)} ${t.label}`,preformatted:!0,live:!1}),this.#C=!1,this.#T=STATUS.processing,this.#oe(),this.#ee(),this.#we();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n};return await new Promise((t,i)=>{this.#N=o=>{if(o.type===`ctrl-c`){this.#O=!0,this.#oe(),this.#Q(),i(interruptedError());return}if(o.type===`ctrl-r`){this.#we();return}if(c===`select`){switch(o.type){case`up`:a>0&&(l=(l-1+a)%a,renderSection(),repaintStatus());break;case`down`:a>0&&(l=(l+1)%a,renderSection(),repaintStatus());break;case`enter`:{if(isOnFreeformRow()){c=`text`,u=``,this.#ae(),repaintStatus();break}let e=n[l];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}switch(o.type){case`character`:u+=o.value,this.#se(),repaintStatus();break;case`backspace`:u=u.slice(0,-1),this.#se(),repaintStatus();break;case`enter`:{let n=resolveQuestionText(u,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(r){if(u.length>0){u=``,this.#se(),repaintStatus();break}c=`select`,u=``,this.#C=!1,this.#oe(),repaintStatus();break}u=``,this.#se(),repaintStatus();break;default:break}},this.#$()})}upsertSubagentStep(e){if(this.#o===`hidden`)return;let t=e.reasoning?.trim()??``,n=e.message?.trim()??``;if(!(t.length===0&&n.length===0)){if(this.#me(e.callId,e.subagentName),this.#o===`collapsed`){this.#we();return}this.#he({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:n,live:!e.finalized}),this.#we()}}upsertSubagentTool(n){if(this.#o===`hidden`)return;if(this.#me(n.callId,n.subagentName),this.#o===`collapsed`){this.#we();return}let r=subagentToolStatus(n.status),i={id:subagentToolSectionId(n.callId,n.childCallId),kind:`subagent-tool`,depth:1,title:n.toolName,subtitle:summarizeToolArgs(n.input),status:r,live:r===`running`||r===`approval`,expanded:this.#o===`full`,toolInput:n.input};n.output===void 0?n.errorText!==void 0&&(i.result=n.errorText):(i.result=summarizeToolResult(n.output),i.toolOutput=n.output),this.#he(i),this.#we()}markChildToolCallId(e){this.#h.add(e);let t=this.#g.get(e);t!==void 0&&(this.#ge(t),this.#g.delete(e),this.#we())}#X(e){let t=this.#p.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#s===`hidden`)return;let t=e.state===`authorized`||e.state===`declined`||e.state===`failed`||e.state===`timed-out`;this.#he({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${e.name} · authorization · ${e.state}`,body:formatConnectionAuthContent(e),preformatted:!0,live:!t}),this.#we()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#y)return;let n=this.#y>0;this.#y=t,t>0?(this.#T=STATUS.connectionAuth,this.#we()):n&&(this.#T=STATUS.processing,this.#we())}reset(){this.#f=[],this.#p.clear(),this.#m.clear(),this.#v=void 0,this.#h.clear(),this.#g.clear(),this.#_.clear(),this.#J=void 0,this.#y=0,this.#B=void 0,this.#H=void 0,this.#U=void 0,this.#W=void 0,this.#D&&(this.#n.clearAll(),this.#we())}renderNotice(e){e.trim().length!==0&&(this.#Z(),this.#ue({kind:`notice`,body:e,live:!1}),this.#we())}shutdown(){this.#Q()}#Z(e){this.#E=e?.title??this.#E,this.#V=e?.contextSize??this.#l,!this.#D&&(this.#D=!0,this.#n.reset(),this.#n.hideCursor(),this.#Me(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume()),this.#I=()=>this.#we(),this.#t.on(`resize`,this.#I))}#Q(){this.#ee(),this.#oe(),this.#le(),this.#D&&=(this.#we(),this.#n.clear(),this.#n.showCursor(),this.#Ne(),this.#n.newline(),this.#e.isTTY&&(this.#e.setRawMode?.(!1),this.#e.pause()),this.#I&&=(this.#t.off(`resize`,this.#I),void 0),!1)}#$(){this.#e.on(`data`,this.#te)}#ee(){this.#e.off(`data`,this.#te),this.#re(),this.#P=``,this.#N=void 0}#te=e=>{this.#re(),this.#P+=e.toString(`utf8`),this.#ne(),this.#P===`\x1B`&&(this.#F=setTimeout(()=>{this.#P===`\x1B`&&(this.#P=``,this.#N?.({type:`escape`}))},30),this.#F.unref?.())};#ne(){for(;this.#P.length>0;){let e=nextKey(this.#P);if(e.incomplete)return;this.#P=this.#P.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#N?.(e.key)}}#re(){this.#F&&=(clearTimeout(this.#F),void 0)}#ie(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#we();break;case`ctrl-c`:this.#O=!0,this.#L?.();break;default:break}}#ae(){this.#oe(),this.#se(),this.#j=setInterval(()=>{this.#k=!this.#k,this.#we()},500),this.#j.unref?.()}#oe(){this.#j&&=(clearInterval(this.#j),void 0),this.#k=!0}#se(){this.#k=!0}#ce(){this.#le(),this.#M=setInterval(()=>{this.#A+=1,this.#we()},90),this.#M.unref?.()}#le(){this.#M&&=(clearInterval(this.#M),void 0)}#ue(e){this.#f.push(e),e.id&&this.#p.set(e.id,e)}#de(e){this.#ue({kind:`user`,body:e,live:!1}),this.#we()}#fe(e){if(e!=null){if(this.#J===e){this.#J=void 0;return}this.#ue({kind:`user`,body:e,live:!1})}}#pe(e,t,n){let r={kind:`error`,title:e,body:t,live:!1};n!==void 0&&(r.detail=n),this.#ue(r),this.#we()}#me(e,t){this.#_.has(e)||(this.#_.add(e),this.#ue({id:subagentHeaderId(e),kind:`subagent`,title:t,live:!1}))}#he(e){if(e.id&&this.#m.has(e.id))return;let t=e.id?this.#p.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#ue(e)}#ge(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#_e(){for(let e of this.#f)e.status!==`approval`&&(e.live=!1)}#ve(e,t,n){switch(e.type){case`step-start`:this.#ye(n.hasPendingToolResults?STATUS.toolResults:STATUS.processing),n.hasPendingToolResults=!1;break;case`step-finish`:this.#Ce(e.usage),this.#we();break;case`assistant-delta`:{this.#ye(STATUS.streaming);let t=(n.text.get(e.id)??``)+e.delta;n.text.set(e.id,t),this.#be(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=e.text!==void 0&&t.length===0?e.text??``:t;n.text.set(e.id,r),this.#be(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#ye(STATUS.streaming);let r=(n.reasoning.get(e.id)??``)+e.delta;n.reasoning.set(e.id,r),this.#xe(e.id,r,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;this.#xe(e.id,r,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#ye(STATUS.executingTools),this.#Se({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#Se({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;n.hasPendingToolResults=!0,this.#ye(STATUS.toolResults),this.#Se({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;n.hasPendingToolResults=!0,this.#ye(STATUS.toolResults),this.#Se({...r,errorText:e.errorText,status:`error`},t,n);break}case`error`:this.#pe(`Error`,e.errorText,e.detail);break;case`finish`:this.#Ce(e.usage),this.#we();break}}#ye(e){let t=this.#y>0?STATUS.connectionAuth:e;this.#T!==t&&(this.#T=t,this.#we())}#be(e,t,n){let r=t.trim();r.length!==0&&(this.#he({id:e,kind:`assistant`,body:r,live:n}),this.#we())}#xe(e,t,n,r){let i=t.trim();i.length!==0&&(this.#he({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#we())}#Se(e,t,n){if(n.tools.set(e.toolCallId,e),this.#h.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#g.set(e.toolCallId,r),this.#he(renderNativeToolBlock(e,r,t.tools===`full`)),this.#we()}#Ce(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#B=(t??0)+(n??0)),this.#H=n??this.#H,this.#H!=null&&this.#W!==void 0){let e=(Date.now()-this.#W)/1e3;e>0&&(this.#U=this.#H/e)}}#we(){if(this.#D){if(this.#R){this.#z=!0;return}this.#R=!0;try{do this.#z=!1,this.#Te();while(this.#z)}finally{this.#R=!1}}}#Te(){if(!this.#D)return;let e=this.#Ae(),t=this.#Oe(e),n=Math.max(1,this.#je()-t.length),r=[],i=this.#v;for(;this.#f.length>0&&this.#f[0].live===!1;){let t=this.#f.shift(),n=this.#Ee(t,e,i);i=previousBlockOf(t),this.#v=i,r.push(...n),t.id&&(this.#m.add(t.id),this.#p.delete(t.id))}let a=[];for(let t of this.#f){let n=this.#Ee(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)a.push({block:t,row:n[e]})}let o=[...clipLiveRows(a.map(e=>e.row),n,e,this.#r),...t];r.length>0?this.#n.flush(r,o):this.#n.update(o)}#Ee(e,t,n){let r={spinner:this.#De()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#De(){return this.#r.spinner[this.#A%this.#r.spinner.length]??``}#Oe(e){let t=this.#r.colors,n=[``];if(this.#C){let r=Math.max(4,e-3),{before:i,after:a}=visibleLine({text:this.#b,cursor:this.#x},r,this.#r.glyph.ellipsis),o=this.#k?t.cyan(this.#r.glyph.caret):` `;return n.push(`${t.cyan(this.#r.glyph.prompt)} ${i}${o}${a}`),n}let r=this.#w?t.yellow(this.#De()):t.dim(this.#r.glyph.dot),i=this.#T.length>0?this.#T:`Ready`,a=this.#w?t.dim(i):i,o=this.#ke(),s=o?`${r} ${a} ${t.dim(this.#r.glyph.dot)} ${o}`:`${r} ${a}`;return n.push(clip(s,e)),n}#ke(){let e=this.#r.colors,t=[],n=formatTokenCount(this.#B,this.#V);n&&t.push(n);let r=formatAssistantResponseStats({totalTokens:this.#B,outputTokens:this.#H,tokensPerSecond:this.#U},this.#c);return r&&t.push(r),this.#w&&t.push(`Ctrl+C to interrupt`),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#Ae(){return Math.max(20,this.#t.columns||80)}#je(){return Math.max(8,this.#t.rows||24)}#Me(){if(this.#G!==void 0||!this.#u)return;this.#K=``,this.#q=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#Pe(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#G=()=>{e(),t()}}#Ne(){let e=this.#G;e!==void 0&&(this.#G=void 0,e(),this.#K.length>0&&(this.#Fe(`stdout`)&&process.stdout.write(`${this.#K}\n`),this.#K=``),this.#q.length>0&&(this.#Fe(`stderr`)&&process.stderr.write(`${this.#q}\n`),this.#q=``))}#Pe(e,t){let n=(e===`stdout`?this.#K:this.#q)+t,r=n.lastIndexOf(`
2
- `),a=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#K=a:this.#q=a,r===-1||!this.#Fe(e))return;let o=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);o.trim().length!==0&&(this.#ue({kind:`log`,title:e,body:o,live:!1}),this.#we())}#Fe(e){switch(this.#d){case`none`:return!1;case`stderr`:return e===`stderr`;case`all`:return!0}}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}async function*iterateTUIStream(e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}return}yield*e}function clip(e,t){return visibleLength(e)>t?sliceVisible(e,t):e}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function leadsWithGap(e,t){if(e.kind===`log`&&t?.kind===`log`)return t.title!==e.title;if(t?.kind===`log`&&e.kind!==`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`subagent`:case`error`:case`notice`:case`question`:case`connection-auth`:case`log`:return!0;default:return!1}}function clipLiveRows(e,t,n,r){if(e.length<=t)return[...e];if(t<=1)return[clip(hiddenRowsMarker(e.length,r),n)];let i=t-1;return[clip(hiddenRowsMarker(e.length-i,r),n),...e.slice(e.length-i)]}function hiddenRowsMarker(e,t){let n=e.toLocaleString(),r=e===1?`row`:`rows`;return t.colors.dim(`${t.glyph.dot} ${t.glyph.ellipsis} ${n} earlier ${r} hidden while streaming`)}function isPromptControlCommand(e){let t=e.trim();return t===`/new`||t===`/exit`||t===`/quit`}function collapseReasoning(e,t){switch(e){case`collapsed`:return!0;case`auto-collapsed`:return!t;default:return!1}}function renderNativeToolBlock(n,r,i){let a={id:r,kind:`tool`,title:n.toolName,subtitle:summarizeToolArgs(n.input),status:n.status,live:n.status===`running`||n.status===`approval`,expanded:i,toolInput:n.input};return n.output===void 0?n.errorText!==void 0&&(a.result=n.errorText):(a.result=summarizeToolResult(n.output),a.toolOutput=n.output),a}function subagentToolStatus(e){switch(e){case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`}}function formatToolApprovalTitle(e){return e.title??e.toolName}function toolSectionId(e){return`tool:${e}`}function questionSectionId(e){return`question:${e}`}function subagentHeaderId(e){return`subagent:${e}:header`}function subagentStepSectionId(e,t){return`subagent:${e}:step:${t}`}function subagentToolSectionId(e,t){return`subagent:${e}:tool:${t}`}function connectionAuthSectionId(e){return`connection-auth:${e}`}function formatConnectionAuthContent(e){let t=[];e.description.length>0&&t.push(e.description);let n=e.challenge;return n?.url&&t.push(`URL: ${n.url}`),n?.userCode&&t.push(`Code: ${n.userCode}`),n?.expiresAt&&t.push(`Expires: ${n.expiresAt}`),n?.instructions&&t.push(n.instructions),e.reason!==void 0&&e.reason.length>0&&t.push(`Reason: ${e.reason}`),t.join(`
1
+ import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{buildAgentHeader}from"./agent-header.js";import{sliceVisible,stripAnsi,visibleLength}from"./terminal-text.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderBlockLines}from"./blocks.js";import{dismissTypeahead,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{interruptedError}from"./errors.js";import{EMPTY_LINE,PromptHistory,backspace,deleteForward,deleteWord,insert,killToEnd,killToStart,lineOf,moveEnd,moveHome,moveLeft,moveRight,visibleLine}from"./line-editor.js";import{LiveRegion}from"./live-region.js";import{numbersSelectRows,renderAcknowledgeQuestion,renderFlowPanel,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{formatAssistantResponseStats,formatTokenFlow,nextKey,takeUntil}from"./stream-format.js";import{toErrorMessage}from"#shared/errors.js";import{filterOptions,initialSelectState,orderedSelection,reduceSelect,selectValueAtCursor,submitRowIndex}from"#setup/cli/select-state.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";const STATUS={processing:`Working…`,toolResults:`Reading results…`,streaming:`Responding…`,executingTools:`Running tools…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f=[];#p=new Map;#m=new Set;#h=[];#g=new Set;#_=new Map;#v=new Set;#y;#b=!1;#x=[];#S;#C=0;#w;#T=``;#E=0;#D;#O=new PromptHistory;#k=!1;#A;#j=!1;#M=STATUS.processing;#N=`Eve`;#P=!1;#F=!1;#I=!0;#L=0;#R;#z;#B;#V=``;#H;#U;#W;#G=!1;#K=!1;#q;#J;#Y;#X;#Z;#Q;#$;#ee=``;#te=``;#ne;#re=0;#ie;#ae;setupFlow={begin:e=>this.#ce(e),end:e=>this.#le(e?.preserveDiagnostics??!0),readSelect:e=>this.#ue(e),readText:e=>this.#de(e),readAcknowledge:e=>this.#fe(e),setStatus:e=>this.#he(e),renderLine:(e,t)=>this.#ge(e,t),renderOutput:e=>this.#_e(e)};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#i=e?.tools??`auto-collapsed`,this.#a=e?.reasoning??`full`,this.#o=e?.subagents??`auto-collapsed`,this.#s=e?.connectionAuth??`full`,this.#c=e?.assistantResponseStats??`tokensPerSecond`,this.#l=e?.contextSize,this.#Y=e?.contextSize,this.#u=e?.captureForeignOutput??this.#t===process.stdout,this.#d=e?.logs??`none`}renderAgentHeader(e){if(this.#N=e.name,this.#y=e,this.#ve(),this.#b){this.#je({kind:`agent-header`,body:this.#Ye().join(`
2
+ `),live:!1}),this.#Ge();return}this.#b=!0,this.#n.flush(this.#Ye(),[])}async readPrompt(e){this.#ve(e),this.#k=!0,this.#j=!1,this.#M=``,this.#D=`Type to chat ${this.#r.glyph.dot} / for commands`;let t=lineOf(``);return this.#O.begin(t.text),this.#oe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,t.text),this.#Ee(),this.#Ge(),await new Promise((e,n)=>{let apply=e=>{t=e,this.#Oe(),this.#oe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,e.text,this.#A),this.#Ge()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#A=void 0,this.#De(),this.#ye(),n(interruptedError())},suggestions=()=>this.#A!==void 0&&isTypeaheadOpen(this.#A)?this.#A:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#B=n=>{switch(n.type){case`character`:apply(insert(t,n.value));break;case`backspace`:apply(backspace(t));break;case`delete`:apply(deleteForward(t));break;case`left`:apply(moveLeft(t));break;case`right`:apply(moveRight(t));break;case`home`:case`ctrl-a`:apply(moveHome(t));break;case`end`:case`ctrl-e`:apply(moveEnd(t));break;case`ctrl-k`:apply(killToEnd(t));break;case`ctrl-u`:apply(killToStart(t));break;case`ctrl-w`:apply(deleteWord(t));break;case`up`:{let e=suggestions();e===void 0?recall(this.#O.previous(t.text)):(this.#A=moveTypeaheadSelection(e,-1),this.#Ge());break}case`down`:{let e=suggestions();e===void 0?recall(this.#O.next()):(this.#A=moveTypeaheadSelection(e,1),this.#Ge());break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#A=dismissTypeahead(e),this.#Ge());break}case`enter`:{let n=highlighted(),r=n!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(n).trimEnd():t.text;this.#A=void 0,this.#O.add(r),this.#k=!1,this.#De(),this.#M=STATUS.processing,isPromptControlCommand(r)?this.#je({kind:`command`,body:r.trim(),live:!1}):(this.#Me(r),this.#ie=r),this.#oe(EMPTY_LINE),this.#Ge(),this.#xe(),e(r);break}case`ctrl-d`:t.text.length===0?interrupt():apply(deleteForward(t));break;case`ctrl-l`:case`ctrl-r`:this.#Ge();break;case`ctrl-c`:interrupt();break;default:break}},this.#be()})}#oe(e){this.#T=e.text,this.#E=e.cursor}async renderStream(e,t){this.#ve(t),this.#m.clear(),this.#k=!1,this.#j=!0,this.#M=STATUS.processing,this.#Ne(t?.submittedPrompt),this.#F=!1,this.#q=void 0,this.#J=void 0,this.#X=void 0,this.#Z=void 0,this.#Q=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#ke(),this.#Ge();let r=new Promise(e=>{this.#W=e});this.#B=e=>this.#Te(e),this.#be();let i={text:new Map,reasoning:new Map,tools:new Map,hasPendingToolResults:!1};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#F)break;this.#ze(t,n,i)}}catch(e){this.#Pe(`Error`,toErrorMessage(e))}finally{this.#W=void 0,this.#F&&e.abort?.(),this.#xe(),this.#Ae(),this.#j=!1,this.#M=this.#F?`Interrupted`:t?.continueSession?`Ready`:`Done`,this.#Re(),this.#Ge(),(this.#F||!t?.continueSession)&&this.#ye()}if(this.#F)throw interruptedError()}async readToolApproval(e,t){return this.#ve(t),this.#k=!1,this.#j=!1,this.#M=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#F=!1,this.#Ge(),await new Promise((t,n)=>{this.#B=r=>{switch(r.type){case`character`:{let n=r.value.toLowerCase();n===`y`?(this.#M=STATUS.processing,this.#xe(),this.#Ge(),t({approved:!0})):n===`n`&&(this.#M=STATUS.processing,this.#se(e.toolCallId),this.#xe(),this.#Ge(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#Ge();break;case`ctrl-c`:this.#F=!0,this.#ye(),n(interruptedError());break;default:break}},this.#be()})}async readInputQuestion(e,t){this.#ve(t),this.#k=!1,this.#j=!1,this.#F=!1,this.#D=void 0;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`select`:`text`,c=0,l=``,isOnFreeformRow=()=>i&&c===n.length,renderSection=()=>{this.#Ie({id:o,kind:`question`,title:e.prompt,body:formatQuestionContent(e,c,this.#r),preformatted:!0,live:!0})},repaintStatus=()=>{if(s===`select`){let e=isOnFreeformRow()?`type`:`select`;this.#M=`↑/↓ move · enter ${e} · Ctrl+C quit`,this.#k=!1}else this.#k=!0,this.#oe(lineOf(l)),this.#M=``;this.#Ge()};renderSection(),s===`text`&&this.#Ee(),repaintStatus();let finalize=t=>{this.#Ie({id:o,kind:`question`,title:e.prompt,body:` ${this.#r.colors.green(this.#r.glyph.success)} ${t.label}`,preformatted:!0,live:!1}),this.#k=!1,this.#M=STATUS.processing,this.#De(),this.#xe(),this.#Ge();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n};return await new Promise((t,i)=>{this.#B=o=>{if(o.type===`ctrl-c`){this.#F=!0,this.#De(),this.#ye(),i(interruptedError());return}if(o.type===`ctrl-r`){this.#Ge();return}if(s===`select`){switch(o.type){case`up`:a>0&&(c=(c-1+a)%a,renderSection(),repaintStatus());break;case`down`:a>0&&(c=(c+1)%a,renderSection(),repaintStatus());break;case`enter`:{if(isOnFreeformRow()){s=`text`,l=``,this.#Ee(),repaintStatus();break}let e=n[c];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}switch(o.type){case`character`:l+=o.value,this.#Oe(),repaintStatus();break;case`backspace`:l=l.slice(0,-1),this.#Oe(),repaintStatus();break;case`enter`:{let n=resolveQuestionText(l,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(r){if(l.length>0){l=``,this.#Oe(),repaintStatus();break}s=`select`,l=``,this.#k=!1,this.#De(),repaintStatus();break}l=``,this.#Oe(),repaintStatus();break;default:break}},this.#be()})}upsertSubagentStep(e){if(this.#o===`hidden`)return;let t=e.reasoning?.trim()??``,n=e.message?.trim()??``;if(!(t.length===0&&n.length===0)){if(this.#Fe(e.callId,e.subagentName),this.#o===`collapsed`){this.#Ge();return}this.#Ie({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:n,live:!e.finalized}),this.#Ge()}}upsertSubagentTool(n){if(this.#o===`hidden`)return;if(this.#Fe(n.callId,n.subagentName),this.#o===`collapsed`){this.#Ge();return}let r=subagentToolStatus(n.status),i={id:subagentToolSectionId(n.callId,n.childCallId),kind:`subagent-tool`,depth:1,title:n.toolName,subtitle:summarizeToolArgs(n.input),status:r,live:r===`running`||r===`approval`,expanded:this.#o===`full`,toolInput:n.input};n.output===void 0?n.errorText!==void 0&&(i.result=n.errorText):(i.result=summarizeToolResult(n.output),i.toolOutput=n.output),this.#Ie(i),this.#Ge()}markChildToolCallId(e){this.#g.add(e);let t=this.#_.get(e);t!==void 0&&(this.#Le(t),this.#_.delete(e),this.#Ge())}#se(e){let t=this.#p.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#s===`hidden`)return;let t=e.state===`authorized`||e.state===`declined`||e.state===`failed`||e.state===`timed-out`;this.#Ie({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${e.name} · authorization · ${e.state}`,body:formatConnectionAuthContent(e),preformatted:!0,live:!t}),this.#Ge()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#C)return;let n=this.#C>0;this.#C=t,t>0?(this.#M=STATUS.connectionAuth,this.#Ge()):n&&(this.#M=STATUS.processing,this.#Ge())}setVercelStatus(e){this.#w=e,this.#Ge()}reset(){this.#f=[],this.#p.clear(),this.#m.clear(),this.#S=void 0,this.#x.length=0,this.#h.length=0,this.#b=!1,this.#g.clear(),this.#_.clear(),this.#v.clear(),this.#ie=void 0,this.#ne=void 0,this.#C=0,this.#q=void 0,this.#J=void 0,this.#X=void 0,this.#Z=void 0,this.#Q=void 0,this.#P&&(this.#n.clearAll(),this.#Ge())}renderNotice(e){e.trim().length!==0&&(this.#ve(),this.#je({kind:`notice`,body:e,live:!1}),this.#Ge())}renderSetupWarning(e){e.trim().length!==0&&(this.#ve(),this.#je({kind:`warning`,body:e,live:!1}),this.#Ge())}renderCommandResult(e){e.trim().length!==0&&(this.#ve(),this.#je({kind:`result`,body:e,live:!1}),this.#Ge())}#ce(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``,this.#ae={title:e,lines:[],outputBuffer:[]},this.#ke(),this.#Ge()}#le(e){let t=this.#ae;if(t!==void 0){if(this.#ae=void 0,this.#Ae(),e)for(let e of t.lines)(e.tone===`warning`||e.tone===`error`)&&this.#je({kind:`flow`,title:e.tone,body:e.text,live:!1});this.#Ge()}}async#ue(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t={options:e.options,submitRow:e.multiple},n={options:e.options,submitRow:e.multiple};e.initialValue!==void 0&&(n.defaultValue=e.initialValue),e.initialValues!==void 0&&(n.initialValues=e.initialValues);let r=initialSelectState(n),i,a=this.#pe(),panelState=()=>{let t={message:e.message,options:e.options,multiple:e.multiple,search:e.search,select:r};return e.placeholder!==void 0&&(t.placeholder=e.placeholder),e.layout!==void 0&&(t.layout=e.layout),e.notices!==void 0&&(t.notices=e.notices),i!==void 0&&(t.error=i),t};return a.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#Ge(),await new Promise(n=>{let settle=e=>{this.#me(),n(e)},apply=e=>{r=reduceSelect(r,e,t),i=void 0,this.#Ge()};this.#B=n=>{switch(n.type){case`ctrl-c`:case`escape`:settle(void 0);return;case`ctrl-r`:this.#Ge();return;case`up`:apply({type:`up`});return;case`down`:apply({type:`down`});return;case`backspace`:e.search&&apply({type:`backspace`});return;case`character`:if(e.multiple&&n.value===` `){apply({type:`toggle`});return}if(numbersSelectRows(e)&&/^[1-9]$/.test(n.value)){let t=Number(n.value)-1,a=e.options[t];a!==void 0&&!a.disabled&&!a.locked&&(r={...r,cursor:t},i=void 0,this.#Ge());return}if(e.search){for(let e of n.value)e>=` `&&e!==``&&(r=reduceSelect(r,{type:`char`,char:e},t));i=void 0,this.#Ge()}return;case`enter`:{let t=e.search?filterOptions(e.options,r.filter):[...e.options];if(e.multiple){if(r.cursor===submitRowIndex(t)){if(e.required&&r.selected.size===0){i=`Select at least one option, then submit.`,this.#Ge();return}settle(orderedSelection(e.options,r.selected));return}apply({type:`toggle`});return}let n=selectValueAtCursor(t,r.cursor);if(n===void 0){i=`Type to match an option, then press enter.`,this.#Ge();return}settle([n]);return}default:return}},this.#be()})}async#de(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t=lineOf(``),n,r=this.#pe();return r.question=r=>{let i={message:e.message,editor:t,mask:e.mask===!0};return e.placeholder!==void 0&&(i.placeholder=e.placeholder),n!==void 0&&(i.error=n),renderTextQuestion(i,this.#r,r,this.#I)},this.#Ee(),this.#Ge(),await new Promise(r=>{let settle=e=>{this.#De(),this.#me(),r(e)},apply=e=>{t=e,n=void 0,this.#Oe(),this.#Ge()};this.#B=r=>{switch(r.type){case`ctrl-c`:case`escape`:settle(void 0);return;case`ctrl-r`:this.#Ge();return;case`character`:apply(insert(t,r.value));return;case`backspace`:apply(backspace(t));return;case`delete`:apply(deleteForward(t));return;case`left`:apply(moveLeft(t));return;case`right`:apply(moveRight(t));return;case`home`:case`ctrl-a`:apply(moveHome(t));return;case`end`:case`ctrl-e`:apply(moveEnd(t));return;case`ctrl-k`:apply(killToEnd(t));return;case`ctrl-u`:apply(killToStart(t));return;case`ctrl-w`:apply(deleteWord(t));return;case`enter`:{let r=t.text.length>0?t.text:e.defaultValue??``,i=e.validate?.(r);if(i!==void 0){n=i,this.#Ge();return}settle(r);return}default:return}},this.#be()})}async#fe(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t=this.#pe();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#Ge(),await new Promise(e=>{this.#B=t=>{switch(t.type){case`enter`:case`escape`:case`ctrl-c`:this.#me(),e();return;case`ctrl-r`:this.#Ge();return;default:return}},this.#be()})}#pe(){return this.#ae===void 0&&(this.#ae={title:``,lines:[],outputBuffer:[]}),this.#ae}#me(){this.#ae!==void 0&&(this.#ae.question=void 0),this.#B=void 0,this.#xe(),this.#Ge()}#he(e){if(this.#ae!==void 0){this.#ae.status=e,e===void 0&&(this.#ae.preview=void 0),this.#Ge();return}if(e===void 0){this.#j=!1,this.#M=``,this.#Ae(),this.#Ge();return}this.#ve(),this.#j=!0,this.#M=e,this.#ke(),this.#Ge()}#ge(e,t){if(e.trim().length===0)return;let n=this.#ae;if(n!==void 0){if(n.preview=void 0,t===`warning`||t===`error`)for(let e of n.outputBuffer)n.lines.push({text:e,tone:`info`});n.outputBuffer=[],n.lines.push({text:e,tone:t}),this.#Ge();return}this.#ve(),this.#je({kind:`flow`,title:t,body:e,live:!1}),this.#Ge()}#_e(e){if(e.trim().length===0)return;let t=this.#ae;if(t===void 0){this.#ge(e,`info`);return}t.preview=e,t.outputBuffer.push(e),t.outputBuffer.length>8&&t.outputBuffer.shift(),this.#Ge()}shutdown(){this.#ye()}#ve(e){this.#N=e?.title??this.#N,this.#Y=e?.contextSize??this.#l,!this.#P&&(this.#P=!0,this.#n.reset(),this.#n.hideCursor(),this.#rt(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume()),this.#U=()=>this.#Ge(),this.#t.on(`resize`,this.#U))}#ye(){this.#xe(),this.#De(),this.#Ae(),this.#P&&=(this.#lt(),this.#Ge(),this.#n.clear(),this.#n.showCursor(),this.#it(),this.#n.newline(),this.#e.isTTY&&(this.#e.setRawMode?.(!1),this.#e.pause()),this.#U&&=(this.#t.off(`resize`,this.#U),void 0),!1)}#be(){this.#e.on(`data`,this.#Se)}#xe(){this.#e.off(`data`,this.#Se),this.#we(),this.#V=``,this.#B=void 0}#Se=e=>{this.#we(),this.#V+=e.toString(`utf8`),this.#Ce(),this.#V===`\x1B`&&(this.#H=setTimeout(()=>{this.#V===`\x1B`&&(this.#V=``,this.#B?.({type:`escape`}))},30),this.#H.unref?.())};#Ce(){for(;this.#V.length>0;){let e=nextKey(this.#V);if(e.incomplete)return;this.#V=this.#V.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#B?.(e.key)}}#we(){this.#H&&=(clearTimeout(this.#H),void 0)}#Te(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#Ge();break;case`ctrl-c`:this.#F=!0,this.#W?.();break;default:break}}#Ee(){this.#De(),this.#Oe(),this.#R=setInterval(()=>{this.#I=!this.#I,this.#Ge()},500),this.#R.unref?.()}#De(){this.#R&&=(clearInterval(this.#R),void 0),this.#I=!0}#Oe(){this.#I=!0}#ke(){this.#Ae(),this.#z=setInterval(()=>{this.#L+=1,this.#Ge()},90),this.#z.unref?.()}#Ae(){this.#z&&=(clearInterval(this.#z),void 0)}#je(e){e.id!==this.#ne?.id&&this.#lt(),this.#f.push(e),e.id&&this.#p.set(e.id,e)}#Me(e){this.#je({kind:`user`,body:e,live:!1}),this.#Ge()}#Ne(e){if(e!=null){if(this.#ie===e){this.#ie=void 0;return}this.#je({kind:`user`,body:e,live:!1})}}#Pe(e,t,n){let r={kind:`error`,title:e,body:t,live:!1};n!==void 0&&(r.detail=n),this.#je(r),this.#Ge()}#Fe(e,t){this.#v.has(e)||(this.#v.add(e),this.#je({id:subagentHeaderId(e),kind:`subagent`,title:t,live:!1}))}#Ie(e){if(e.id&&this.#m.has(e.id))return;let t=e.id?this.#p.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#je(e)}#Le(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#Re(){for(let e of this.#f)e.status!==`approval`&&(e.live=!1)}#ze(e,t,n){switch(e.type){case`step-start`:this.#Be(n.hasPendingToolResults?STATUS.toolResults:STATUS.processing),n.hasPendingToolResults=!1;break;case`step-finish`:this.#We(e.usage),this.#Ge();break;case`assistant-delta`:{this.#Be(STATUS.streaming);let t=(n.text.get(e.id)??``)+e.delta;n.text.set(e.id,t),this.#Ve(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=e.text!==void 0&&t.length===0?e.text??``:t;n.text.set(e.id,r),this.#Ve(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#Be(STATUS.streaming);let r=(n.reasoning.get(e.id)??``)+e.delta;n.reasoning.set(e.id,r),this.#He(e.id,r,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;this.#He(e.id,r,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#Be(STATUS.executingTools),this.#Ue({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#Ue({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;n.hasPendingToolResults=!0,this.#Be(STATUS.toolResults),this.#Ue({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;n.hasPendingToolResults=!0,this.#Be(STATUS.toolResults),this.#Ue({...r,errorText:e.errorText,status:`error`},t,n);break}case`error`:this.#Pe(`Error`,e.errorText,e.detail);break;case`finish`:this.#We(e.usage),this.#Ge();break}}#Be(e){let t=this.#C>0?STATUS.connectionAuth:e;this.#M!==t&&(this.#M=t,this.#Ge())}#Ve(e,t,n){let r=t.trim();r.length!==0&&(this.#Ie({id:e,kind:`assistant`,body:r,live:n}),this.#Ge())}#He(e,t,n,r){let i=t.trim();i.length!==0&&(this.#Ie({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#Ge())}#Ue(e,t,n){if(n.tools.set(e.toolCallId,e),this.#g.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#_.set(e.toolCallId,r),this.#Ie(renderNativeToolBlock(e,r,t.tools===`full`)),this.#Ge()}#We(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#q=(t??0)+(n??0)),this.#J=t??this.#J,this.#X=n??this.#X,this.#X!=null&&this.#Q!==void 0){let e=(Date.now()-this.#Q)/1e3;e>0&&(this.#Z=this.#X/e)}}#Ge(){if(this.#P){if(this.#G){this.#K=!0;return}this.#G=!0;try{do this.#K=!1,this.#Ke();while(this.#K)}finally{this.#G=!1}}}#Ke(){if(!this.#P)return;let e=this.#tt(),t=this.#Qe(e),n=Math.max(1,this.#nt()-t.length),r=[],i=this.#S;for(;this.#f.length>0&&this.#f[0].live===!1;){let t=this.#f.shift();if(this.#h.push(t),t.id&&(this.#m.add(t.id),this.#p.delete(t.id)),this.#dt(t))continue;let n=this.#Xe(t,e,i);i=previousBlockOf(t),this.#S=i,r.push(...n),this.#x.push(...n)}let a=[];for(let t of this.#f){if(this.#dt(t))continue;let n=this.#Xe(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)a.push({block:t,row:n[e]})}let o=[...clipLiveRows(a.map(e=>e.row),n,e,this.#r),...t];r.length>0?this.#n.flush(r,o):this.#n.update(o)}#qe(){if(!this.#P)return;let e=this.#tt(),t=this.#Qe(e),n=Math.max(1,this.#nt()-t.length),r=this.#S,i=[];for(let t of this.#f){if(this.#dt(t))continue;let n=this.#Xe(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#r),...t];this.#n.clearAll(),this.#n.flush([...this.#Ye(),...this.#x],a)}logDisplayMode(){return this.#d}setLogDisplayMode(e){e!==this.#d&&(this.#d=e,this.#Je(),this.#P&&this.#qe())}#Je(){let e=this.#tt();this.#x.length=0;let t;for(let n of this.#h){if(this.#dt(n))continue;let r=this.#Xe(n,e,t);t=previousBlockOf(n),this.#x.push(...r)}this.#S=t}#Ye(){let e=this.#y;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#tt()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#Xe(e,t,n){let r={spinner:this.#Ze()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#Ze(){return this.#r.spinner[this.#L%this.#r.spinner.length]??``}#Qe(e){let t=this.#r.colors,n=[``],r=this.#ae;if(r!==void 0){let t={title:r.title,lines:r.lines,frame:this.#Ze()};return r.question===void 0?(r.status!==void 0&&(t.status={text:r.status,frame:this.#Ze()}),r.preview!==void 0&&(t.preview=r.preview)):t.question=r.question(e),n.push(...renderFlowPanel(t,this.#r,e)),n}if(this.#k){this.#A!==void 0&&isTypeaheadOpen(this.#A)&&n.push(...renderCommandSuggestions(this.#A,this.#r,e));let r=Math.max(4,e-3),{before:i,after:a}=visibleLine({text:this.#T,cursor:this.#E},r,this.#r.glyph.ellipsis),o=isPromptControlCommand(this.#T),style=e=>o&&e.length>0?t.blue(e):e,c=this.#I?t.cyan(this.#r.glyph.caret):` `,l=this.#T.length===0&&this.#D!==void 0?`${c}${t.dim(this.#D)}`:`${style(i)}${c}${style(a)}`;return n.push(clip(`${t.cyan(this.#r.glyph.prompt)} ${l}`,e)),this.#$e(n,e),n}let i=this.#j?t.yellow(this.#Ze()):t.dim(this.#r.glyph.dot),a=this.#M.length>0?this.#M:`Ready`,o=this.#j?t.dim(a):a,c=this.#et(),l=c?`${i} ${o} ${t.dim(this.#r.glyph.dot)} ${c}`:`${i} ${o}`;return n.push(clip(l,e)),this.#$e(n,e),n}#$e(e,t){let n={theme:this.#r,width:t},r=this.#y?.info?.agent.model.id;r!==void 0&&(n.model=r);let i={inputTokens:this.#J??0,outputTokens:this.#X??0};this.#Y!==void 0&&(i.contextSize=this.#Y),n.tokens=formatTokenFlow(i,this.#r.glyph),this.#w!==void 0&&(n.vercel=this.#w);let a=buildStatusLine(n);a!==void 0&&e.push(a)}#et(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#q,outputTokens:this.#X,tokensPerSecond:this.#Z},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#tt(){return Math.max(20,this.#t.columns||80)}#nt(){return Math.max(8,this.#t.rows||24)}#rt(){if(this.#$!==void 0||!this.#u)return;this.#ee=``,this.#te=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#at(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#$=()=>{e(),t()}}#it(){let e=this.#$;e!==void 0&&(this.#$=void 0,e(),this.#ee.length>0&&(this.#ut(`stdout`)&&process.stdout.write(`${this.#ee}\n`),this.#ee=``),this.#te.length>0&&(this.#ut(`stderr`)&&process.stderr.write(`${this.#te}\n`),this.#te=``))}#at(e,t){let n=(e===`stdout`?this.#ee:this.#te)+t,r=n.lastIndexOf(`
3
+ `),a=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#ee=a:this.#te=a,r===-1)return;let o=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);o.trim().length!==0&&(e===`stdout`?this.#ot(o):this.#je({kind:`log`,title:e,body:o,live:!1}),this.#Ge())}#ot(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
4
+ `);t=[],e.trim().length!==0&&this.#je({kind:`log`,title:`stdout`,body:e,live:!1})};for(let n of e.split(`
5
+ `)){let e=parseDevRebuildLogLine(n.trimEnd());if(e===void 0){t.push(n);continue}flushPending(),this.#st(e,n.trimEnd())}flushPending()}#st(e,t){let n=this.#ct();if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#re}`;this.#re+=1,this.#ne={id:r,summary:t},this.#je({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}if(n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind);return}this.#je({kind:`log`,title:`stdout`,body:t,live:!1})}#ct(){let e=this.#ne;if(e===void 0)return;let t=this.#p.get(e.id);if(!(t===void 0||t.live!==!0))return{state:e,block:t}}#lt(){let e=this.#ne;if(e===void 0)return;this.#ne=void 0;let t=this.#p.get(e.id);t!==void 0&&(t.live=!1)}#ut(e){switch(this.#d){case`none`:return!1;case`stderr`:return e===`stderr`;case`all`:return!0}}#dt(e){return e.kind===`log`?!this.#ut(e.title===`stderr`?`stderr`:`stdout`):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}async function*iterateTUIStream(e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}return}yield*e}function clip(e,t){return visibleLength(e)>t?sliceVisible(e,t):e}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function leadsWithGap(e,t){if(e.kind===`log`&&t?.kind===`log`)return t.title!==e.title;if(t?.kind===`log`&&e.kind!==`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`subagent`:case`error`:case`notice`:case`question`:case`connection-auth`:case`log`:case`command`:case`warning`:case`flow`:case`agent-header`:return!0;default:return!1}}function clipLiveRows(e,t,n,r){if(e.length<=t)return[...e];if(t<=1)return[clip(hiddenRowsMarker(e.length,r),n)];let i=t-1;return[clip(hiddenRowsMarker(e.length-i,r),n),...e.slice(e.length-i)]}function hiddenRowsMarker(e,t){let n=e.toLocaleString(),r=e===1?`row`:`rows`;return t.colors.dim(`${t.glyph.dot} ${t.glyph.ellipsis} ${n} earlier ${r} hidden while streaming`)}function collapseReasoning(e,t){switch(e){case`collapsed`:return!0;case`auto-collapsed`:return!t;default:return!1}}function renderNativeToolBlock(n,r,i){let a={id:r,kind:`tool`,title:n.toolName,subtitle:summarizeToolArgs(n.input),status:n.status,live:n.status===`running`||n.status===`approval`,expanded:i,toolInput:n.input};return n.output===void 0?n.errorText!==void 0&&(a.result=n.errorText):(a.result=summarizeToolResult(n.output),a.toolOutput=n.output),a}function subagentToolStatus(e){switch(e){case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`}}function formatToolApprovalTitle(e){return e.title??e.toolName}function toolSectionId(e){return`tool:${e}`}function questionSectionId(e){return`question:${e}`}function subagentHeaderId(e){return`subagent:${e}:header`}function subagentStepSectionId(e,t){return`subagent:${e}:step:${t}`}function subagentToolSectionId(e,t){return`subagent:${e}:tool:${t}`}function connectionAuthSectionId(e){return`connection-auth:${e}`}function formatConnectionAuthContent(e){let t=[];e.description.length>0&&t.push(e.description);let n=e.challenge;return n?.url&&t.push(`URL: ${n.url}`),n?.userCode&&t.push(`Code: ${n.userCode}`),n?.expiresAt&&t.push(`Expires: ${n.expiresAt}`),n?.instructions&&t.push(n.instructions),e.reason!==void 0&&e.reason.length>0&&t.push(`Reason: ${e.reason}`),t.join(`
3
6
  `)}function formatQuestionContent(e,t,n){let r=n.colors,i=[],a=e.options??[];if(a.length>0){for(let[e,o]of a.entries()){let a=o.description?` ${r.dim(`— ${o.description}`)}`:``,s=t===e,c=s?`${r.cyan(n.glyph.pointer)} `:` `,l=s?r.cyan(o.label):o.label;i.push(`${c}${l}${a}`)}if(e.allowFreeform===!0){let e=t===a.length,o=e?`${r.cyan(n.glyph.pointer)} `:` `,s=`Type your own answer`;i.push(`${o}${e?r.cyan(s):r.dim(s)}`)}}else i.push(r.dim(` (type your answer)`));return i.join(`
4
7
  `)}function resolveQuestionText(e,t){let n=e.trim();if(n.length===0)return;let r=n.toLowerCase(),i=t.options??[];if(i.length>0){let e=matchQuestionOption(r,i);if(e!==void 0)return{optionId:e.id,label:e.label}}if(t.allowFreeform===!0||i.length===0)return{text:n,label:n}}function matchQuestionOption(e,t){let n=t.find(t=>t.id.toLowerCase()===e);if(n!==void 0)return n;let r=t.find(t=>t.label.toLowerCase()===e);if(r!==void 0)return r;let i=Number(e);if(Number.isInteger(i)&&i>0&&i<=t.length)return t[i-1]}export{TerminalRenderer};
@@ -1,11 +1,13 @@
1
1
  /**
2
2
  * Test-only entrypoint for driving the `eve dev` terminal UI from
3
- * end-to-end smoke tests. Consumed via `e2e/lib/tui.ts`, which
3
+ * TUI smoke tests. Consumed via `packages/eve/test/tui-client/lib/tui.ts`, which
4
4
  * imports the built output directly by path. Not part of the supported
5
5
  * public API — production code reaches the TUI through the internal
6
6
  * `#cli/dev/tui/*` modules instead.
7
7
  */
8
8
  export { EveTUIRunner } from "../runner.js";
9
9
  export type { EveTUIRunnerOptions } from "../runner.js";
10
+ export { createPromptCommandHandler } from "../prompt-command-handler.js";
10
11
  export { TerminalRenderer } from "../terminal-renderer.js";
11
12
  export { MockScreen, MockUserInput } from "./mock-terminal.js";
13
+ export { AUTHORED_ARTIFACTS_UPDATED_LOG_LINE, formatChangeDetectedLogLine, } from "#internal/nitro/host/dev-watcher-log.js";
@@ -1 +1 @@
1
- import{TerminalRenderer}from"../terminal-renderer.js";import{EveTUIRunner}from"../runner.js";import{MockScreen,MockUserInput}from"./mock-terminal.js";export{EveTUIRunner,MockScreen,MockUserInput,TerminalRenderer};
1
+ import{createPromptCommandHandler}from"../prompt-command-handler.js";import{TerminalRenderer}from"../terminal-renderer.js";import{EveTUIRunner}from"../runner.js";import{MockScreen,MockUserInput}from"./mock-terminal.js";import{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,formatChangeDetectedLogLine}from"#internal/nitro/host/dev-watcher-log.js";export{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,EveTUIRunner,MockScreen,MockUserInput,TerminalRenderer,createPromptCommandHandler,formatChangeDetectedLogLine};
@@ -21,6 +21,7 @@ export declare class MockUserInput extends EventEmitter implements TerminalInput
21
21
  }
22
22
  export declare class MockScreen extends EventEmitter implements TerminalOutput {
23
23
  #private;
24
+ isTTY: boolean;
24
25
  columns: number;
25
26
  rows: number;
26
27
  constructor({ columns, rows }: {
@@ -1,3 +1,3 @@
1
- import{EventEmitter}from"node:events";const ansiControlSequencePattern=RegExp(`^\x1B\\[([0-9?;]*)([ -/]*)([@-~])`);var MockUserInput=class extends EventEmitter{isTTY=!0;rawModes=[];resumeCalls=0;pauseCalls=0;setRawMode(e){return this.rawModes.push(e),this}resume(){return this.resumeCalls+=1,this}pause(){return this.pauseCalls+=1,this}type(e){this.emit(`data`,Buffer.from(e))}send(e){this.emit(`data`,Buffer.from(e))}enter(){this.send(`\r`)}backspace(){this.send(``)}up(){this.send(`\x1B[A`)}down(){this.send(`\x1B[B`)}left(){this.send(`\x1B[D`)}right(){this.send(`\x1B[C`)}ctrlC(){this.send(``)}},MockScreen=class extends EventEmitter{columns;rows;#e=``;#t=[];#n=0;#r=0;#i=[];constructor({columns:e,rows:t}){super(),this.columns=e,this.rows=t}write(e,t,n){let r=String(e);return this.#e+=r,this.#o(r),typeof t==`function`&&t(),n?.(),this.#a(),!0}resize(e,t){this.columns=e,this.rows=t,this.emit(`resize`)}snapshot(){return this.#t.join(`
1
+ import{EventEmitter}from"node:events";const ansiControlSequencePattern=RegExp(`^\x1B\\[([0-9?;]*)([ -/]*)([@-~])`);var MockUserInput=class extends EventEmitter{isTTY=!0;rawModes=[];resumeCalls=0;pauseCalls=0;setRawMode(e){return this.rawModes.push(e),this}resume(){return this.resumeCalls+=1,this}pause(){return this.pauseCalls+=1,this}type(e){this.emit(`data`,Buffer.from(e))}send(e){this.emit(`data`,Buffer.from(e))}enter(){this.send(`\r`)}backspace(){this.send(``)}up(){this.send(`\x1B[A`)}down(){this.send(`\x1B[B`)}left(){this.send(`\x1B[D`)}right(){this.send(`\x1B[C`)}ctrlC(){this.send(``)}},MockScreen=class extends EventEmitter{isTTY=!0;columns;rows;#e=``;#t=[];#n=0;#r=0;#i=[];constructor({columns:e,rows:t}){super(),this.columns=e,this.rows=t}write(e,t,n){let r=String(e);return this.#e+=r,this.#o(r),typeof t==`function`&&t(),n?.(),this.#a(),!0}resize(e,t){this.columns=e,this.rows=t,this.emit(`resize`)}snapshot(){return this.#t.join(`
2
2
  `)}rawOutput(){return this.#e}async waitForText(e,t=1e3,n=()=>this.snapshot()){this.snapshot().includes(e)||await new Promise((r,i)=>{let a={text:e,resolve:r,reject:i,timeout:setTimeout(()=>{this.#i=this.#i.filter(e=>e!==a),i(Error(`Timed out waiting for screen text: ${e}\n\nScreen:\n${n()}`))},t)};this.#i.push(a)})}#a(){let e=this.snapshot();for(let t of this.#i.slice())e.includes(t.text)&&(clearTimeout(t.timeout),this.#i=this.#i.filter(e=>e!==t),t.resolve())}#o(e){let t=0;for(;t<e.length;){if(e[t]===`\x1B`){let n=this.#s(e,t);if(n>t){t=n;continue}}let n=e[t];if(t+=1,n!==void 0){if(n===`
3
3
  `){this.#n+=1,this.#r=0;continue}if(n===`\r`){this.#r=0;continue}this.#u(n)}}}#s(e,n){let r=e.slice(n).match(ansiControlSequencePattern);if(!r)return n;let[i,a=``,,o]=r,s=a.startsWith(`?`),c=a&&!s?a.split(`;`):[],first=e=>c[0]===void 0||c[0]===``?e:Number(c[0]);if(s)return n+i.length;switch(o){case`H`:case`f`:this.#n=first(1)-1,this.#r=(c[1]?Number(c[1]):1)-1;break;case`A`:this.#n=Math.max(0,this.#n-first(1));break;case`B`:this.#n+=first(1);break;case`C`:this.#r+=first(1);break;case`D`:this.#r=Math.max(0,this.#r-first(1));break;case`E`:this.#n+=first(1),this.#r=0;break;case`F`:this.#n=Math.max(0,this.#n-first(1)),this.#r=0;break;case`G`:this.#r=first(1)-1;break;case`J`:this.#c(first(0));break;case`K`:this.#l(first(0));break;default:break}return n+i.length}#c(e){if(e===2||e===3){this.#t=[],this.#n=0,this.#r=0;return}if(e===1){for(let e=0;e<this.#n;e+=1)this.#t[e]=``;this.#l(1);return}this.#l(0),this.#t.length=Math.min(this.#t.length,this.#n+1)}#l(e){let t=this.#t[this.#n]??``;if(e===2){this.#t[this.#n]=``;return}if(e===1){this.#t[this.#n]=` `.repeat(this.#r)+t.slice(this.#r);return}this.#t[this.#n]=t.slice(0,this.#r)}#u(e){let t=(this.#t[this.#n]??``).padEnd(this.#r,` `),n=t.slice(0,this.#r)+e+t.slice(this.#r+e.length);this.#t[this.#n]=n,this.#r+=e.length}};export{MockScreen,MockUserInput};
@@ -60,12 +60,22 @@ export interface ThemeGlyphs {
60
60
  pointer: string;
61
61
  /** `❯` — the input prompt mark. */
62
62
  prompt: string;
63
+ /** `⎿` — hangs a command's result under its invocation. */
64
+ elbow: string;
65
+ /** `▔` — strong full-width rule opening the bottom question panel. */
66
+ hrule: string;
63
67
  /** `▏` — the synthetic input caret. */
64
68
  caret: string;
65
69
  /** `·` — inline separator for header / status segments. */
66
70
  dot: string;
67
71
  /** `…` — truncation marker. */
68
72
  ellipsis: string;
73
+ /** `⁕` — marks the token-flow segment of the status line. */
74
+ tokens: string;
75
+ /** `↑` — input (prompt) tokens in the token-flow segment. */
76
+ arrowUp: string;
77
+ /** `↓` — output (response) tokens in the token-flow segment. */
78
+ arrowDown: string;
69
79
  }
70
80
  export interface Theme {
71
81
  readonly color: boolean;
@@ -1 +1 @@
1
- function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}`}const UNICODE_GLYPHS={brand:`▲`,user:`▌`,reasoning:`○`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`◆`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`›`,prompt:`❯`,caret:`▏`,dot:`·`,ellipsis:`…`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,prompt:`>`,caret:`_`,dot:`-`,ellipsis:`...`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(i={}){let a=i.color??!0,o=i.unicode??!0;return{color:a,unicode:o,colors:{reset:ansi(0,0,a),bold:ansi(1,22,a),dim:ansi(2,22,a),italic:ansi(3,23,a),white:ansi(97,39,a),gray:ansi(90,39,a),cyan:ansi(36,39,a),green:ansi(32,39,a),red:ansi(31,39,a),yellow:ansi(33,39,a),magenta:ansi(35,39,a),blue:ansi(34,39,a),orange:ansi256(208,a)},glyph:o?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:o?UNICODE_SPINNER:ASCII_SPINNER}}function detectUnicode(e=process.env){let t=e.EVE_TUI_UNICODE;return t===`0`||t===`false`?!1:t===`1`||t===`true`?!0:e.TERM===`dumb`?!1:process.platform===`win32`?!!(e.WT_SESSION||e.TERM_PROGRAM===`vscode`):!0}export{createTheme,detectUnicode};
1
+ function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}`}const UNICODE_GLYPHS={brand:`▲`,user:`▌`,reasoning:`○`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`◆`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`›`,prompt:`❯`,elbow:`⎿`,hrule:`▔`,caret:`▏`,dot:`·`,ellipsis:`…`,tokens:`⁕`,arrowUp:`↑`,arrowDown:`↓`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,prompt:`>`,elbow:"`-",hrule:`=`,caret:`_`,dot:`-`,ellipsis:`...`,tokens:`*`,arrowUp:`^`,arrowDown:`v`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(i={}){let a=i.color??!0,o=i.unicode??!0;return{color:a,unicode:o,colors:{reset:ansi(0,0,a),bold:ansi(1,22,a),dim:ansi(2,22,a),italic:ansi(3,23,a),white:ansi(97,39,a),gray:ansi(90,39,a),cyan:ansi(36,39,a),green:ansi(32,39,a),red:ansi(31,39,a),yellow:ansi(33,39,a),magenta:ansi(35,39,a),blue:ansi(34,39,a),orange:ansi256(208,a)},glyph:o?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:o?UNICODE_SPINNER:ASCII_SPINNER}}function detectUnicode(e=process.env){let t=e.EVE_TUI_UNICODE;return t===`0`||t===`false`?!1:t===`1`||t===`true`?!0:e.TERM===`dumb`?!1:process.platform===`win32`?!!(e.WT_SESSION||e.TERM_PROGRAM===`vscode`):!0}export{createTheme,detectUnicode};
@@ -0,0 +1,20 @@
1
+ import type { Prompter } from "#setup/prompter.js";
2
+ import type { SetupFlowPrompterRenderer } from "./setup-flow.js";
3
+ /**
4
+ * The renderer slice the TUI-native prompter drives: the bordered setup
5
+ * panel for questions, the footer status for ephemeral loading, and toned
6
+ * transcript lines for persistent output. Same members as the optional
7
+ * methods on {@link AgentTUIRenderer}, required here.
8
+ */
9
+ export type TuiPrompterRenderer = SetupFlowPrompterRenderer;
10
+ /**
11
+ * A {@link Prompter} implemented by the TUI itself: questions render as the
12
+ * bordered setup panel (an input-region variant, clearly not chat content),
13
+ * spinners become the footer's ephemeral status line, and log output lands
14
+ * as toned transcript lines. A cancelled panel throws
15
+ * {@link WizardCancelledError}, which the setup flows already fold.
16
+ *
17
+ * `intro`/`outro` are no-ops — the command's elbow-connected outcome line is
18
+ * the opening and closing of a TUI flow.
19
+ */
20
+ export declare function createTuiPrompter(renderer: TuiPrompterRenderer): Prompter;
@@ -0,0 +1 @@
1
+ import{WizardCancelledError}from"#setup/step.js";import{createSelectOptionCodec}from"#setup/cli/select-option-codec.js";function createTuiPrompter(n){function guardCancel(t){if(t===void 0)throw new WizardCancelledError;return t}async function select(e){let r=createSelectOptionCodec(e.options),i=e.multiple===!0,a={message:e.message,options:r.options,multiple:i,search:e.search??!1,required:e.required??!1};e.placeholder!==void 0&&(a.placeholder=e.placeholder),e.layout!==void 0&&(a.layout=e.layout),e.notices!==void 0&&(a.notices=e.notices),!i&&e.initialValue!==void 0&&(a.initialValue=r.encode(e.initialValue)),i&&e.initialValues!==void 0&&(a.initialValues=e.initialValues.map(e=>r.encode(e)));let o=guardCancel(await n.readSelect(a)).map(e=>r.decode(e));if(i)return o;let s=o[0];if(s===void 0)throw Error(`Single-select returned no option.`);return s}function line(e){return t=>n.renderLine(t,e)}return{async text(e){let t={message:e.message};return e.placeholder!==void 0&&(t.placeholder=e.placeholder),e.defaultValue!==void 0&&(t.defaultValue=e.defaultValue),e.validate!==void 0&&(t.validate=e.validate),guardCancel(await n.readText(t))},async password(e){let t={message:e.message,mask:!0};return e.validate!==void 0&&(t.validate=e.validate),guardCancel(await n.readText(t))},select,async acknowledge(e){await n.readAcknowledge({message:e.message,lines:e.lines??[]})},note(e,t,r){let i=r?.tone===`success`?`success`:`warning`;t&&n.renderLine(t,i),n.renderLine(e,i)},intro(){},outro(){},log:{message:line(`info`),info:line(`info`),success:line(`success`),warning:line(`warning`),error:line(`error`),commandOutput:e=>n.renderOutput(e),section(e,t){n.renderLine(e,`info`);for(let e of t)n.renderLine(` ${e}`,`info`)},spinner(e){n.setStatus(e);let t=!1;return{stop(){t||(t=!0,n.setStatus(void 0))}}}}}}export{createTuiPrompter};
@@ -1,4 +1,3 @@
1
- import type { ClientOptions } from "#client/index.js";
2
1
  import type { TuiDisplayOptions } from "./types.js";
3
2
  /**
4
3
  * Options for running the `eve dev` terminal UI against a server URL.
@@ -9,14 +8,13 @@ export interface RunDevelopmentTuiInput extends TuiDisplayOptions {
9
8
  * server started by `eve dev`, or a remote `--url` target.
10
9
  */
11
10
  readonly serverUrl: string;
11
+ /**
12
+ * Absolute application root. When present and the server is a local dev
13
+ * server, enables the TUI's `/model` command to edit local agent source.
14
+ * Omitted for remote (`--url`) targets.
15
+ */
16
+ readonly appRoot?: string;
12
17
  }
13
- /**
14
- * Builds the client options the `eve dev` TUI connects with, matching the
15
- * REPL's dev client: local hosts skip the Vercel OIDC bearer (the framework's
16
- * `localDev()` channel auth accepts unauthenticated calls); remote hosts
17
- * attach it alongside any protection-bypass headers resolved per request.
18
- */
19
- export declare function resolveDevTuiClientOptions(serverUrl: string): ClientOptions;
20
18
  /**
21
19
  * Runs the `eve dev` terminal UI against the given server URL until the
22
20
  * user exits.
@@ -1 +1 @@
1
- import{EveTUIRunner}from"./runner.js";import{toErrorMessage}from"#shared/errors.js";import{isLocalDevelopmentServerUrl,resolveDevelopmentClientHeaders,resolveDevelopmentOidcToken}from"#services/dev-client/request-headers.js";import{formatVercelAuthChallengeMessage,isVercelAuthChallenge}from"#services/dev-client/vercel-auth-error.js";import{Client}from"#client/index.js";function resolveDevTuiClientOptions(e){let t={headers:()=>resolveDevelopmentClientHeaders({serverUrl:e}),host:e};return isLocalDevelopmentServerUrl(e)?t:{...t,auth:{bearer:resolveDevelopmentOidcToken}}}async function runDevelopmentTui(n){let{serverUrl:r,...i}=n,a=new Client(resolveDevTuiClientOptions(r));await new EveTUIRunner({...i,session:a.session(),client:a,serverUrl:r,formatTransportError:e=>isVercelAuthChallenge(e)?formatVercelAuthChallengeMessage({serverUrl:r}):toErrorMessage(e)}).run()}export{resolveDevTuiClientOptions,runDevelopmentTui};
1
+ import{createPromptCommandHandler}from"./prompt-command-handler.js";import{EveTUIRunner}from"./runner.js";import{Client}from"#client/index.js";import{toErrorMessage}from"#shared/errors.js";import{resolveDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{formatVercelAuthChallengeMessage,isVercelAuthChallenge}from"#services/dev-client/vercel-auth-error.js";async function runDevelopmentTui(t){let{serverUrl:n,appRoot:r,...i}=t,a=new Client(resolveDevelopmentClientOptions(n)),o={...i,session:a.session(),client:a,serverUrl:n,promptCommandHandler:createPromptCommandHandler({appRoot:r}),formatTransportError:e=>isVercelAuthChallenge(e)?formatVercelAuthChallengeMessage({serverUrl:n}):toErrorMessage(e)};r!==void 0&&(o.appRoot=r),await new EveTUIRunner(o).run()}export{runDevelopmentTui};
@@ -60,9 +60,10 @@ export type TuiDisplayOptions = {
60
60
  contextSize?: number;
61
61
  /**
62
62
  * Which in-process server/agent logs to surface as inline regions.
63
- * Output is always captured so it cannot corrupt the frame; this only
64
- * controls what is rendered. Defaults to `all` the TUI is primarily a
65
- * development tool.
63
+ * Output is always captured and buffered so it cannot corrupt the frame;
64
+ * this only controls what is rendered. The `/loglevel` command switches
65
+ * the mode at runtime, retroactively hiding or restoring buffered log
66
+ * lines. Defaults to `none`.
66
67
  */
67
68
  logs?: LogDisplayMode;
68
69
  };