eve 0.62.0 → 0.64.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 (593) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/src/ai/evaluate.js +1 -1
  3. package/dist/src/channel/channel-address.d.ts +4 -1
  4. package/dist/src/channel/channel-address.js +1 -1
  5. package/dist/src/channel/channel-operations.d.ts +4 -1
  6. package/dist/src/channel/cross-channel-receive.d.ts +4 -1
  7. package/dist/src/channel/cross-channel-receive.js +1 -1
  8. package/dist/src/channel/session.d.ts +3 -1
  9. package/dist/src/channel/session.js +1 -1
  10. package/dist/src/channel/types.d.ts +7 -0
  11. package/dist/src/chunks/{use-eve-agent-C5-yqRuq.js → use-eve-agent-BdKlQF32.js} +8 -8
  12. package/dist/src/chunks/{use-eve-agent-CVWk5KKy.js → use-eve-agent-IIuxkn6y.js} +8 -8
  13. package/dist/src/cli/commands/build.js +1 -1
  14. package/dist/src/cli/commands/init-agent-workspace.d.ts +2 -0
  15. package/dist/src/cli/commands/init.js +1 -1
  16. package/dist/src/cli/dev/tui/line-editor.d.ts +11 -1
  17. package/dist/src/cli/dev/tui/line-editor.js +3 -3
  18. package/dist/src/cli/dev/tui/model-picker.d.ts +50 -0
  19. package/dist/src/cli/dev/tui/model-picker.js +1 -0
  20. package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
  21. package/dist/src/cli/dev/tui/runner.js +2 -2
  22. package/dist/src/cli/dev/tui/setup-commands.d.ts +1 -1
  23. package/dist/src/cli/dev/tui/setup-commands.js +1 -1
  24. package/dist/src/cli/dev/tui/setup-flow.d.ts +2 -2
  25. package/dist/src/cli/dev/tui/setup-panel.d.ts +1 -26
  26. package/dist/src/cli/dev/tui/setup-panel.js +3 -3
  27. package/dist/src/cli/dev/tui/setup-selection-input.js +1 -1
  28. package/dist/src/cli/dev/tui/stream-format.d.ts +6 -7
  29. package/dist/src/cli/dev/tui/stream-format.js +2 -2
  30. package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
  31. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  32. package/dist/src/cli/dev/tui/test/fake-setup-flow-renderer.js +1 -1
  33. package/dist/src/cli/dev/tui/test/mock-terminal.js +1 -1
  34. package/dist/src/cli/dev/tui/theme.d.ts +0 -8
  35. package/dist/src/cli/dev/tui/theme.js +1 -1
  36. package/dist/src/cli/run.js +1 -1
  37. package/dist/src/client/agent-info-schema.d.ts +8 -14
  38. package/dist/src/client/agent-info-schema.js +1 -1
  39. package/dist/src/client/eve-agent-store.js +1 -1
  40. package/dist/src/client/session.js +1 -1
  41. package/dist/src/client/types.d.ts +4 -2
  42. package/dist/src/compiled/.vendor-stamp.json +11 -11
  43. package/dist/src/compiled/@chat-adapter/slack/_chat-adapter-shared.d.ts +1 -0
  44. package/dist/src/compiled/@chat-adapter/slack/api.d.ts +3 -2
  45. package/dist/src/compiled/@chat-adapter/slack/api.js +1 -1
  46. package/dist/src/compiled/@chat-adapter/slack/blocks.js +1 -1
  47. package/dist/src/compiled/@chat-adapter/slack/format.js +1 -1
  48. package/dist/src/compiled/@chat-adapter/slack/index.d.ts +410 -63
  49. package/dist/src/compiled/@chat-adapter/slack/index.js +47 -25
  50. package/dist/src/compiled/@chat-adapter/twilio/api.d.ts +5 -1
  51. package/dist/src/compiled/@chat-adapter/twilio/api.js +1 -1
  52. package/dist/src/compiled/@chat-adapter/twilio/index.d.ts +37 -3
  53. package/dist/src/compiled/@chat-adapter/twilio/index.js +5 -1
  54. package/dist/src/compiled/@chat-adapter/twilio/webhook.d.ts +2 -2
  55. package/dist/src/compiled/@chat-adapter/twilio/webhook.js +1 -1
  56. package/dist/src/compiled/@linqapp/chat-sdk-adapter/index.js +6 -6
  57. package/dist/src/compiled/@photon-ai/chat-adapter-imessage/index.js +50 -50
  58. package/dist/src/compiled/@vercel/sandbox/index.js +4 -4
  59. package/dist/src/compiled/@workflow/core/attribute-changes.d.ts +2 -1
  60. package/dist/src/compiled/@workflow/core/events-consumer.d.ts +6 -3
  61. package/dist/src/compiled/@workflow/core/index.js +2 -2
  62. package/dist/src/compiled/@workflow/core/private.d.ts +37 -5
  63. package/dist/src/compiled/@workflow/core/private.js +1 -1
  64. package/dist/src/compiled/@workflow/core/runtime/deployment-guard.d.ts +2 -1
  65. package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
  66. package/dist/src/compiled/@workflow/core/runtime/invocations.d.ts +35 -0
  67. package/dist/src/compiled/@workflow/core/runtime/lifecycle-hooks.d.ts +90 -0
  68. package/dist/src/compiled/@workflow/core/runtime/quickjs-runtime.d.ts +2 -1
  69. package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +8 -6
  70. package/dist/src/compiled/@workflow/core/runtime/step-single-flight.d.ts +1 -1
  71. package/dist/src/compiled/@workflow/core/runtime.js +4 -4
  72. package/dist/src/compiled/@workflow/core/serialization.d.ts +5 -1
  73. package/dist/src/compiled/@workflow/core/serialization.js +1 -1
  74. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  75. package/dist/src/compiled/@workflow/core/workflow/set-attributes.d.ts +4 -0
  76. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  77. package/dist/src/compiled/@workflow/world/analytics.d.ts +1 -1
  78. package/dist/src/compiled/@workflow/world/attributes-validation.d.ts +5 -0
  79. package/dist/src/compiled/@workflow/world/events.d.ts +2 -2
  80. package/dist/src/compiled/@workflow/world/index.d.ts +2 -1
  81. package/dist/src/compiled/@workflow/world/interfaces.d.ts +12 -1
  82. package/dist/src/compiled/@workflow/world/invocation.d.ts +19 -0
  83. package/dist/src/compiled/@workflow/world/queue.d.ts +24 -3
  84. package/dist/src/compiled/@workflow/world-local/index.js +3 -3
  85. package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
  86. package/dist/src/compiled/_chunks/node/chunk-6QHBXN7B-gl4n6nmi.js +12 -0
  87. package/dist/src/compiled/_chunks/node/chunk-7WDLOIRP-B_IWkVtZ.js +1 -0
  88. package/dist/src/compiled/_chunks/node/chunk-KBOOTKHF-DJqFk2r1.js +1 -0
  89. package/dist/src/compiled/_chunks/node/chunk-TREVQR3E-CLsTAn-O.js +1 -0
  90. package/dist/src/compiled/_chunks/node/dist-DYDVZ-FS.js +98 -0
  91. package/dist/src/compiled/_chunks/node/dist-iEFkK9qw.js +6 -0
  92. package/dist/src/compiled/_chunks/workflow/attribute-changes-DFx4eluc.js +6 -0
  93. package/dist/src/compiled/_chunks/workflow/{dist-D38gP7YF.js → dist-DjECvUyK.js} +1 -1
  94. package/dist/src/compiled/_chunks/workflow/{frames-QcJfYHmh.js → frames-D_Q-7A1N.js} +2 -2
  95. package/dist/src/compiled/_chunks/workflow/{helpers-6kObVbfS.js → helpers-Bw52uyzw.js} +1 -1
  96. package/dist/src/compiled/_chunks/workflow/{logger-NN5YHpYy.js → logger-DFNCa8Nl.js} +1 -1
  97. package/dist/src/compiled/_chunks/workflow/resume-hook-BhA_nDEV.js +1 -0
  98. package/dist/src/compiled/_chunks/workflow/{run-DJevv8zz.js → run-BT6SQv5f.js} +1 -1
  99. package/dist/src/compiled/_chunks/workflow/{serialization-C5KgPESk.js → serialization-Cl0SYU0I.js} +3 -3
  100. package/dist/src/compiled/_chunks/workflow/sleep-DB4AH9-A.js +1 -0
  101. package/dist/src/compiled/_chunks/workflow/{wait-until-BMY_tOr-.js → wait-until-Dzhr6tzf.js} +1 -1
  102. package/dist/src/compiled/_chunks/workflow/{ws-transport-DSDcKH08.js → ws-transport-BpTMh40s.js} +1 -1
  103. package/dist/src/compiled/chat/index.d.ts +1 -725
  104. package/dist/src/compiled/chat/index.js +1 -1
  105. package/dist/src/compiler/artifacts.d.ts +1 -0
  106. package/dist/src/compiler/artifacts.js +1 -1
  107. package/dist/src/compiler/extension-compatibility.d.ts +42 -15
  108. package/dist/src/compiler/extension-compatibility.js +1 -1
  109. package/dist/src/compiler/manifest.d.ts +14 -18
  110. package/dist/src/compiler/manifest.js +1 -1
  111. package/dist/src/compiler/normalize-agent-config.js +1 -1
  112. package/dist/src/compiler/normalize-helpers.js +1 -1
  113. package/dist/src/compiler/normalize-sandbox.d.ts +2 -7
  114. package/dist/src/compiler/normalize-sandbox.js +1 -1
  115. package/dist/src/compiler/normalize-tool.js +1 -1
  116. package/dist/src/compiler/workspace-resources.js +1 -1
  117. package/dist/src/context/build-callback-context.d.ts +2 -0
  118. package/dist/src/context/build-callback-context.js +1 -1
  119. package/dist/src/context/build-dynamic-tools.js +1 -1
  120. package/dist/src/context/container.d.ts +1 -1
  121. package/dist/src/context/container.js +1 -1
  122. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  123. package/dist/src/context/key-names.d.ts +1 -0
  124. package/dist/src/context/key-names.js +1 -1
  125. package/dist/src/context/keys.d.ts +7 -2
  126. package/dist/src/context/keys.js +1 -1
  127. package/dist/src/context/providers/sandbox.js +1 -1
  128. package/dist/src/context/providers/session.d.ts +19 -2
  129. package/dist/src/context/session-context.d.ts +1 -1
  130. package/dist/src/discover/sandbox.js +1 -1
  131. package/dist/src/evals/cli/eval.js +1 -1
  132. package/dist/src/evals/context.d.ts +1 -0
  133. package/dist/src/evals/context.js +1 -1
  134. package/dist/src/evals/define-eval-config.d.ts +7 -7
  135. package/dist/src/evals/define-eval-config.js +1 -1
  136. package/dist/src/evals/define-eval.d.ts +5 -2
  137. package/dist/src/evals/index.d.ts +1 -1
  138. package/dist/src/evals/runner/derive-run-facts.js +1 -1
  139. package/dist/src/evals/runner/execute-eval.d.ts +2 -0
  140. package/dist/src/evals/runner/execute-eval.js +1 -1
  141. package/dist/src/evals/runner/execute-task.d.ts +2 -0
  142. package/dist/src/evals/runner/execute-task.js +1 -1
  143. package/dist/src/evals/runner/run-evals.d.ts +2 -0
  144. package/dist/src/evals/runner/run-evals.js +1 -1
  145. package/dist/src/evals/target.js +1 -1
  146. package/dist/src/evals/types.d.ts +26 -9
  147. package/dist/src/eve-channel/create-request.d.ts +2 -1
  148. package/dist/src/eve-channel/delivery-policy-request.d.ts +4 -0
  149. package/dist/src/eve-channel/delivery-policy-request.js +1 -0
  150. package/dist/src/eve-channel/index.js +1 -1
  151. package/dist/src/eve-channel/request.d.ts +2 -1
  152. package/dist/src/eve-channel/request.js +1 -1
  153. package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
  154. package/dist/src/execution/cancel-indexed-session-tasks-step.d.ts +2 -1
  155. package/dist/src/execution/cancel-indexed-session-tasks-step.js +1 -1
  156. package/dist/src/execution/coordination-dispatch-shared.d.ts +3 -7
  157. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  158. package/dist/src/execution/coordination-dispatch-step.js +1 -1
  159. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  160. package/dist/src/execution/legacy-session/interrupt-step.js +1 -1
  161. package/dist/src/execution/node-step.js +1 -1
  162. package/dist/src/execution/proxied-deliver-step.js +1 -1
  163. package/dist/src/execution/route-child-delivery.js +3 -1
  164. package/dist/src/execution/runtime-context.js +1 -1
  165. package/dist/src/execution/sandbox/active-handles.d.ts +7 -8
  166. package/dist/src/execution/sandbox/active-handles.js +1 -1
  167. package/dist/src/execution/sandbox/bash.js +1 -1
  168. package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +1 -1
  169. package/dist/src/execution/sandbox/bindings/docker-cli.js +1 -1
  170. package/dist/src/execution/sandbox/bindings/docker-container.d.ts +2 -2
  171. package/dist/src/execution/sandbox/bindings/docker-container.js +1 -1
  172. package/dist/src/execution/sandbox/bindings/docker-network.d.ts +1 -1
  173. package/dist/src/execution/sandbox/bindings/docker-network.js +1 -1
  174. package/dist/src/execution/sandbox/bindings/docker-options.d.ts +4 -5
  175. package/dist/src/execution/sandbox/bindings/docker-options.js +1 -1
  176. package/dist/src/execution/sandbox/bindings/docker-session.d.ts +0 -1
  177. package/dist/src/execution/sandbox/bindings/docker-session.js +2 -2
  178. package/dist/src/execution/sandbox/bindings/docker.d.ts +16 -18
  179. package/dist/src/execution/sandbox/bindings/docker.js +1 -1
  180. package/dist/src/execution/sandbox/bindings/immutable-resources.d.ts +21 -0
  181. package/dist/src/execution/sandbox/bindings/immutable-resources.js +2 -0
  182. package/dist/src/execution/sandbox/bindings/just-bash-runtime.d.ts +9 -5
  183. package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
  184. package/dist/src/execution/sandbox/bindings/just-bash.d.ts +13 -26
  185. package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
  186. package/dist/src/execution/sandbox/bindings/{local-backend-utils.d.ts → local-provider-utils.d.ts} +7 -5
  187. package/dist/src/execution/sandbox/bindings/local-provider-utils.js +1 -0
  188. package/dist/src/execution/sandbox/bindings/local.d.ts +3 -3
  189. package/dist/src/execution/sandbox/bindings/local.js +1 -1
  190. package/dist/src/execution/sandbox/bindings/microsandbox-create.js +1 -1
  191. package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.d.ts +30 -8
  192. package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +1 -1
  193. package/dist/src/execution/sandbox/bindings/microsandbox-metadata.d.ts +9 -1
  194. package/dist/src/execution/sandbox/bindings/microsandbox-metadata.js +1 -1
  195. package/dist/src/execution/sandbox/bindings/microsandbox-network.js +1 -1
  196. package/dist/src/execution/sandbox/bindings/microsandbox-options.d.ts +10 -4
  197. package/dist/src/execution/sandbox/bindings/microsandbox-options.js +1 -1
  198. package/dist/src/execution/sandbox/bindings/microsandbox-platform.js +1 -1
  199. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.d.ts +7 -5
  200. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
  201. package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +1 -1
  202. package/dist/src/execution/sandbox/bindings/microsandbox.d.ts +11 -21
  203. package/dist/src/execution/sandbox/bindings/microsandbox.js +1 -1
  204. package/dist/src/execution/sandbox/bindings/vercel-base-runtime.js +2 -2
  205. package/dist/src/execution/sandbox/bindings/vercel-credentials.js +1 -1
  206. package/dist/src/execution/sandbox/bindings/vercel-errors.js +1 -1
  207. package/dist/src/execution/sandbox/bindings/vercel-lifecycle.d.ts +2 -2
  208. package/dist/src/execution/sandbox/bindings/vercel-lifecycle.js +1 -1
  209. package/dist/src/execution/sandbox/bindings/vercel-lookup.js +1 -1
  210. package/dist/src/execution/sandbox/bindings/vercel-options.d.ts +1 -2
  211. package/dist/src/execution/sandbox/bindings/vercel-options.js +1 -1
  212. package/dist/src/execution/sandbox/bindings/vercel.d.ts +20 -12
  213. package/dist/src/execution/sandbox/bindings/vercel.js +2 -2
  214. package/dist/src/execution/sandbox/development-cleanup.js +1 -1
  215. package/dist/src/execution/sandbox/development-prewarm.d.ts +5 -0
  216. package/dist/src/execution/sandbox/development-prewarm.js +1 -1
  217. package/dist/src/execution/sandbox/development-run.d.ts +2 -3
  218. package/dist/src/execution/sandbox/dockerfile.d.ts +25 -0
  219. package/dist/src/execution/sandbox/dockerfile.js +1 -0
  220. package/dist/src/execution/sandbox/ensure.d.ts +0 -17
  221. package/dist/src/execution/sandbox/ensure.js +1 -1
  222. package/dist/src/execution/sandbox/logging-session.js +1 -1
  223. package/dist/src/execution/sandbox/prewarm.d.ts +23 -27
  224. package/dist/src/execution/sandbox/prewarm.js +1 -2
  225. package/dist/src/execution/sandbox/provider-files.d.ts +2 -0
  226. package/dist/src/execution/sandbox/provider-files.js +1 -0
  227. package/dist/src/execution/sandbox/provider-host-development.d.ts +2 -0
  228. package/dist/src/execution/sandbox/provider-host-development.js +1 -0
  229. package/dist/src/execution/sandbox/provider-host.d.ts +2 -0
  230. package/dist/src/execution/sandbox/provider-host.js +1 -0
  231. package/dist/src/execution/sandbox/provider-identity.d.ts +1 -0
  232. package/dist/src/execution/sandbox/provider-identity.js +1 -0
  233. package/dist/src/execution/sandbox/ripgrep-probe.d.ts +0 -7
  234. package/dist/src/execution/sandbox/ripgrep-probe.js +1 -1
  235. package/dist/src/execution/sandbox/session.d.ts +8 -8
  236. package/dist/src/execution/sandbox/session.js +1 -1
  237. package/dist/src/execution/session/admission.js +1 -1
  238. package/dist/src/execution/session/handoff-steps.js +1 -1
  239. package/dist/src/execution/session/handoff.d.ts +2 -1
  240. package/dist/src/execution/session/handoff.js +1 -1
  241. package/dist/src/execution/session/input-queue.d.ts +4 -1
  242. package/dist/src/execution/session/input-queue.js +1 -1
  243. package/dist/src/execution/session/next-input.js +1 -1
  244. package/dist/src/execution/session/program.js +1 -1
  245. package/dist/src/execution/session/turn-step.js +1 -1
  246. package/dist/src/execution/session/turn.js +1 -1
  247. package/dist/src/execution/session-inbox/protocol.js +1 -1
  248. package/dist/src/execution/session-workflow-tool-run.js +1 -1
  249. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  250. package/dist/src/execution/stable-workflow-names.d.ts +0 -1
  251. package/dist/src/execution/stable-workflow-names.js +1 -1
  252. package/dist/src/execution/tasks/child/notify.d.ts +44 -0
  253. package/dist/src/execution/tasks/child/notify.js +1 -0
  254. package/dist/src/execution/tasks/parent/control-shared.d.ts +2 -5
  255. package/dist/src/execution/tasks/parent/control-shared.js +1 -1
  256. package/dist/src/execution/tasks/parent/delegate.d.ts +8 -36
  257. package/dist/src/execution/tasks/parent/delegate.js +1 -1
  258. package/dist/src/execution/tasks/parent/dispatch.d.ts +3 -5
  259. package/dist/src/execution/tasks/parent/dispatch.js +1 -1
  260. package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +4 -1
  261. package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
  262. package/dist/src/execution/tasks/parent/run-parent.d.ts +5 -19
  263. package/dist/src/execution/tasks/parent/run-parent.js +1 -1
  264. package/dist/src/execution/tasks/parent/task-cancel.d.ts +6 -5
  265. package/dist/src/execution/tasks/parent/task-cancel.js +1 -1
  266. package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
  267. package/dist/src/execution/tool-auth.d.ts +3 -9
  268. package/dist/src/execution/tool-auth.js +1 -1
  269. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  270. package/dist/src/execution/tools/sleep-workflow.js +1 -1
  271. package/dist/src/execution/tools/subagent/accept-event-step.js +1 -1
  272. package/dist/src/execution/tools/subagent/emit-event-step.d.ts +11 -0
  273. package/dist/src/execution/tools/subagent/emit-event-step.js +1 -0
  274. package/dist/src/execution/tools/subagent/invoke-agent.d.ts +5 -7
  275. package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
  276. package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -1
  277. package/dist/src/execution/tools/subagent/invoke-step.d.ts +3 -2
  278. package/dist/src/execution/tools/subagent/invoke-step.js +1 -1
  279. package/dist/src/execution/tools/subagent/start.d.ts +1 -0
  280. package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +0 -1
  281. package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -1
  282. package/dist/src/execution/tools/subagent/task-cancel.d.ts +1 -1
  283. package/dist/src/execution/tools/subagent/task-cancel.js +1 -1
  284. package/dist/src/execution/tools/workflow/background.d.ts +1 -1
  285. package/dist/src/execution/tools/workflow/background.js +1 -1
  286. package/dist/src/execution/tools/workflow/body.d.ts +0 -2
  287. package/dist/src/execution/tools/workflow/body.js +1 -1
  288. package/dist/src/execution/tools/workflow/cancel.d.ts +4 -3
  289. package/dist/src/execution/tools/workflow/cancel.js +1 -1
  290. package/dist/src/execution/tools/workflow/cancellation-policy.d.ts +2 -0
  291. package/dist/src/execution/tools/workflow/cancellation-policy.js +1 -0
  292. package/dist/src/execution/tools/workflow/messages.d.ts +0 -1
  293. package/dist/src/execution/tools/workflow/owner-channels.d.ts +6 -6
  294. package/dist/src/execution/tools/workflow/owner-inbox.d.ts +5 -9
  295. package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
  296. package/dist/src/execution/tools/workflow/owner.d.ts +6 -2
  297. package/dist/src/execution/tools/workflow/owner.js +1 -1
  298. package/dist/src/execution/tools/workflow/start.js +1 -1
  299. package/dist/src/execution/tools/workflow/types.d.ts +11 -19
  300. package/dist/src/execution/tools/workflow/types.js +1 -1
  301. package/dist/src/execution/tools/workflow/workflow-owner-background.d.ts +13 -0
  302. package/dist/src/execution/tools/workflow/workflow-owner-background.js +1 -0
  303. package/dist/src/execution/tools/workflow/workflow-owner-blocking.d.ts +12 -0
  304. package/dist/src/execution/tools/workflow/workflow-owner-blocking.js +1 -0
  305. package/dist/src/execution/tools/workflow/workflow.d.ts +3 -3
  306. package/dist/src/execution/tools/workflow/workflow.js +1 -1
  307. package/dist/src/execution/workflow-runtime.d.ts +0 -4
  308. package/dist/src/execution/workflow-runtime.js +1 -1
  309. package/dist/src/framework/sources/modules/sandbox.d.ts +2 -1
  310. package/dist/src/framework/sources/modules/sandbox.js +1 -1
  311. package/dist/src/harness/approval-delivery-coordinator.js +1 -1
  312. package/dist/src/harness/background-tools.d.ts +3 -5
  313. package/dist/src/harness/coordination.js +1 -1
  314. package/dist/src/harness/emission.js +1 -1
  315. package/dist/src/harness/execute-tool.d.ts +2 -29
  316. package/dist/src/harness/hitl/approval-input-requests.d.ts +1 -1
  317. package/dist/src/harness/hitl/approval-input-requests.js +1 -1
  318. package/dist/src/harness/input-requests.d.ts +6 -0
  319. package/dist/src/harness/input-requests.js +1 -1
  320. package/dist/src/harness/messages.d.ts +2 -1
  321. package/dist/src/harness/messages.js +1 -1
  322. package/dist/src/harness/pending-input-batches.d.ts +1 -0
  323. package/dist/src/harness/pending-input-batches.js +1 -1
  324. package/dist/src/harness/tool-loop.js +2 -2
  325. package/dist/src/harness/tool-model-output.js +1 -1
  326. package/dist/src/harness/tools.js +1 -1
  327. package/dist/src/harness/workflow-tool-runs.d.ts +53 -18
  328. package/dist/src/harness/workflow-tool-runs.js +1 -1
  329. package/dist/src/instrumentation/ai-sdk-warnings.d.ts +6 -0
  330. package/dist/src/instrumentation/ai-sdk-warnings.js +1 -0
  331. package/dist/src/instrumentation/runtime.d.ts +1 -0
  332. package/dist/src/instrumentation/runtime.js +1 -1
  333. package/dist/src/internal/application/compiled-artifacts.d.ts +2 -0
  334. package/dist/src/internal/application/compiled-artifacts.js +2 -2
  335. package/dist/src/internal/application/package.js +1 -1
  336. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  337. package/dist/src/internal/nitro/host/artifacts-config.d.ts +6 -1
  338. package/dist/src/internal/nitro/host/artifacts-config.js +1 -1
  339. package/dist/src/internal/nitro/host/build-application.js +1 -1
  340. package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.d.ts +16 -0
  341. package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.js +5 -0
  342. package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
  343. package/dist/src/internal/nitro/host/create-application-nitro.d.ts +3 -3
  344. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  345. package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
  346. package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
  347. package/dist/src/internal/nitro/host/prepare-application-host.d.ts +1 -0
  348. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
  349. package/dist/src/internal/nitro/host/sandbox-shutdown-plugin.js +1 -1
  350. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  351. package/dist/src/internal/nitro/host/start-production-server.js +2 -2
  352. package/dist/src/internal/nitro/host/types.d.ts +1 -1
  353. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  354. package/dist/src/internal/nitro/routes/runtime-artifacts.d.ts +1 -0
  355. package/dist/src/internal/nitro/routes/runtime-artifacts.js +1 -1
  356. package/dist/src/internal/runtime-registry.d.ts +2 -2
  357. package/dist/src/internal/vercel/build-agent-workspace.d.ts +3 -1
  358. package/dist/src/internal/vercel/build-agent-workspace.js +1 -1
  359. package/dist/src/protocol/message.d.ts +4 -4
  360. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +4 -5
  361. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
  362. package/dist/src/public/channels/github/checkout.js +1 -1
  363. package/dist/src/public/channels/index.d.ts +1 -1
  364. package/dist/src/public/channels/slack/slackChannel.d.ts +3 -1
  365. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  366. package/dist/src/public/definitions/channel.d.ts +1 -1
  367. package/dist/src/public/definitions/sandbox.d.ts +5 -43
  368. package/dist/src/public/definitions/sandbox.js +1 -1
  369. package/dist/src/public/local-dev.d.ts +4 -5
  370. package/dist/src/public/sandbox/docker-sandbox.d.ts +16 -40
  371. package/dist/src/public/sandbox/docker.d.ts +2 -2
  372. package/dist/src/public/sandbox/docker.js +1 -1
  373. package/dist/src/public/sandbox/index.d.ts +4 -9
  374. package/dist/src/public/sandbox/index.js +1 -1
  375. package/dist/src/public/sandbox/just-bash-sandbox.d.ts +11 -6
  376. package/dist/src/public/sandbox/just-bash.d.ts +2 -2
  377. package/dist/src/public/sandbox/just-bash.js +1 -1
  378. package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +11 -17
  379. package/dist/src/public/sandbox/microsandbox.d.ts +2 -2
  380. package/dist/src/public/sandbox/microsandbox.js +1 -1
  381. package/dist/src/public/sandbox/provider.d.ts +1 -0
  382. package/dist/src/public/sandbox/provider.js +1 -0
  383. package/dist/src/public/sandbox/vercel-sandbox.d.ts +10 -41
  384. package/dist/src/public/sandbox/vercel.d.ts +2 -2
  385. package/dist/src/public/sandbox/vercel.js +1 -1
  386. package/dist/src/public/tools/index.d.ts +2 -2
  387. package/dist/src/runtime/agent/resolve-model.js +1 -1
  388. package/dist/src/runtime/cache-key.js +1 -1
  389. package/dist/src/runtime/compiled-artifacts-source.d.ts +6 -1
  390. package/dist/src/runtime/compiled-artifacts-source.js +1 -1
  391. package/dist/src/runtime/connections/scoped-authorization.js +1 -1
  392. package/dist/src/runtime/loaders/artifact-paths.d.ts +1 -0
  393. package/dist/src/runtime/loaders/artifact-paths.js +1 -1
  394. package/dist/src/runtime/loaders/bundled-artifacts.d.ts +3 -0
  395. package/dist/src/runtime/loaders/bundled-artifacts.js +1 -1
  396. package/dist/src/runtime/loaders/compile-metadata.js +1 -1
  397. package/dist/src/runtime/loaders/manifest.js +1 -1
  398. package/dist/src/runtime/loaders/module-map.js +1 -1
  399. package/dist/src/runtime/local-dev-capability.d.ts +14 -12
  400. package/dist/src/runtime/local-dev-capability.js +1 -1
  401. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  402. package/dist/src/runtime/resolve-sandbox.d.ts +1 -10
  403. package/dist/src/runtime/resolve-sandbox.js +1 -1
  404. package/dist/src/runtime/sandbox/prepared-artifacts.d.ts +13 -0
  405. package/dist/src/runtime/sandbox/prepared-artifacts.js +1 -0
  406. package/dist/src/runtime/sandbox/registry.d.ts +2 -9
  407. package/dist/src/runtime/sandbox/registry.js +1 -1
  408. package/dist/src/runtime/sessions/runtime-session.js +1 -1
  409. package/dist/src/runtime/sessions/turn.d.ts +10 -8
  410. package/dist/src/runtime/subagents/registry.js +1 -1
  411. package/dist/src/runtime/subagents/workflow.js +1 -1
  412. package/dist/src/runtime/tools/registry.js +1 -1
  413. package/dist/src/runtime/types.d.ts +13 -26
  414. package/dist/src/runtime/workspace/types.d.ts +1 -1
  415. package/dist/src/sandbox/providers/default.d.ts +27 -0
  416. package/dist/src/sandbox/providers/default.js +1 -0
  417. package/dist/src/sandbox/providers/docker.d.ts +11 -0
  418. package/dist/src/sandbox/providers/docker.js +1 -0
  419. package/dist/src/sandbox/providers/just-bash.d.ts +4 -0
  420. package/dist/src/sandbox/providers/just-bash.js +1 -0
  421. package/dist/src/sandbox/providers/microsandbox.d.ts +12 -0
  422. package/dist/src/sandbox/providers/microsandbox.js +1 -0
  423. package/dist/src/sandbox/providers/vercel.d.ts +12 -0
  424. package/dist/src/sandbox/providers/vercel.js +1 -0
  425. package/dist/src/sandbox/providers.d.ts +5 -0
  426. package/dist/src/sandbox/providers.js +1 -0
  427. package/dist/src/sandbox/state.d.ts +6 -25
  428. package/dist/src/self-modification/extension/subagents/agent/agent.d.ts +1 -1
  429. package/dist/src/self-modification/extension/subagents/agent/agent.js +1 -1
  430. package/dist/src/self-modification/extension/subagents/agent/sandbox.d.ts +2 -25
  431. package/dist/src/self-modification/extension/subagents/agent/sandbox.js +1 -1
  432. package/dist/src/self-modification/extension/subagents/agent/tools/publish.js +1 -1
  433. package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.js +1 -1
  434. package/dist/src/self-modification/filesystem.d.ts +3 -1
  435. package/dist/src/self-modification/filesystem.js +1 -1
  436. package/dist/src/self-modification/git-workspace.d.ts +1 -1
  437. package/dist/src/self-modification/git.d.ts +1 -1
  438. package/dist/src/self-modification/sandbox.d.ts +14 -9
  439. package/dist/src/self-modification/sandbox.js +1 -1
  440. package/dist/src/setup/boxes/select-model.js +1 -1
  441. package/dist/src/setup/cli/select-state.d.ts +4 -2
  442. package/dist/src/setup/cli/select-state.js +1 -1
  443. package/dist/src/setup/flows/model-login.js +1 -1
  444. package/dist/src/setup/flows/model.d.ts +5 -5
  445. package/dist/src/setup/primitives/pm/pnpm.js +3 -2
  446. package/dist/src/setup/scaffold/create/project.js +1 -1
  447. package/dist/src/shared/action-types.d.ts +0 -4
  448. package/dist/src/shared/action-types.js +1 -1
  449. package/dist/src/shared/default-agent-model.d.ts +1 -1
  450. package/dist/src/shared/default-agent-model.js +1 -1
  451. package/dist/src/shared/sandbox-environment.d.ts +45 -0
  452. package/dist/src/shared/sandbox-environment.js +1 -0
  453. package/dist/src/shared/sandbox-network-policy.d.ts +8 -3
  454. package/dist/src/shared/sandbox-network-policy.js +1 -1
  455. package/dist/src/shared/sandbox-prepared-artifacts.d.ts +16 -0
  456. package/dist/src/shared/sandbox-prepared-artifacts.js +1 -0
  457. package/dist/src/shared/sandbox-provider.d.ts +110 -0
  458. package/dist/src/shared/sandbox-provider.js +1 -0
  459. package/dist/src/shared/sandbox-session.d.ts +18 -41
  460. package/dist/src/shared/sandbox-template-error.d.ts +9 -0
  461. package/dist/src/shared/sandbox-template-error.js +1 -0
  462. package/dist/src/subagents/tool.d.ts +1 -1
  463. package/dist/src/subagents/tool.js +1 -1
  464. package/dist/src/svelte/index.js +1 -1
  465. package/dist/src/svelte/use-eve-agent.js +1 -1
  466. package/dist/src/tasks/delivery-context.d.ts +6 -4
  467. package/dist/src/tasks/delivery-context.js +2 -2
  468. package/dist/src/tasks/delivery-policy.d.ts +2 -0
  469. package/dist/src/tasks/delivery-policy.js +1 -1
  470. package/dist/src/tasks/notification.d.ts +4 -0
  471. package/dist/src/tasks/notification.js +1 -0
  472. package/dist/src/tasks/session-task-cohorts.d.ts +1 -12
  473. package/dist/src/tasks/session-task-cohorts.js +1 -1
  474. package/dist/src/tasks/transitions.d.ts +5 -2
  475. package/dist/src/tasks/transitions.js +1 -1
  476. package/dist/src/tasks/types.d.ts +2 -52
  477. package/dist/src/tasks/types.js +1 -1
  478. package/dist/src/tools/definition.d.ts +1 -25
  479. package/dist/src/tools/definition.js +1 -1
  480. package/dist/src/tools/dynamic.d.ts +1 -3
  481. package/dist/src/tools/framework/agent-contract.js +1 -1
  482. package/dist/src/tools/framework/agent.d.ts +16 -22
  483. package/dist/src/tools/framework/agent.js +1 -1
  484. package/dist/src/tools/workflow-definition.d.ts +16 -5
  485. package/dist/src/tracing/agent-invocation-coordinator.js +1 -1
  486. package/dist/src/tracing/agent-trace-context-store.js +1 -1
  487. package/dist/src/vue/index.js +1 -1
  488. package/dist/src/vue/use-eve-agent.js +1 -1
  489. package/docs/README.md +40 -45
  490. package/docs/agent-config.md +2 -2
  491. package/docs/channels/eve.mdx +1 -1
  492. package/docs/channels/overview.mdx +48 -0
  493. package/docs/concepts/execution-model-and-durability.mdx +5 -6
  494. package/docs/concepts/sessions-runs-and-streaming.md +5 -5
  495. package/docs/dynamic-configuration/meta.json +5 -0
  496. package/docs/evals/assertions.mdx +5 -1
  497. package/docs/evals/overview.mdx +43 -0
  498. package/docs/getting-started.mdx +1 -1
  499. package/docs/guides/client/overview.mdx +1 -1
  500. package/docs/guides/deployment/overview.md +1 -1
  501. package/docs/guides/deployment/self-hosting.md +5 -5
  502. package/docs/guides/deployment/vercel.mdx +10 -12
  503. package/docs/guides/dev-tui.md +22 -10
  504. package/docs/guides/frontend/overview.mdx +1 -1
  505. package/docs/guides/hooks.md +4 -0
  506. package/docs/memory/meta.json +1 -1
  507. package/docs/memory/overview.mdx +4 -0
  508. package/docs/meta.json +13 -16
  509. package/docs/patterns/meta.json +2 -2
  510. package/docs/protocols/acp.md +1 -1
  511. package/docs/protocols/ucp.mdx +1 -1
  512. package/docs/reference/cli.md +10 -9
  513. package/docs/reference/meta.json +4 -1
  514. package/docs/reference/typescript-api.md +1 -24
  515. package/docs/sandbox/default.mdx +17 -0
  516. package/docs/sandbox/docker.mdx +29 -0
  517. package/docs/sandbox/index.mdx +216 -0
  518. package/docs/sandbox/just-bash.mdx +18 -0
  519. package/docs/sandbox/meta.json +5 -0
  520. package/docs/sandbox/microsandbox.mdx +31 -0
  521. package/docs/sandbox/vercel.mdx +106 -0
  522. package/docs/schedules.mdx +35 -1
  523. package/docs/subagents/index.mdx +27 -6
  524. package/docs/subagents/meta.json +1 -1
  525. package/docs/tools/overview.mdx +37 -37
  526. package/docs/tools/workflows.mdx +31 -24
  527. package/docs/tutorial/run-analysis.mdx +6 -5
  528. package/package.json +20 -11
  529. package/dist/src/cli/dev/tui/model-editor.d.ts +0 -103
  530. package/dist/src/cli/dev/tui/model-editor.js +0 -1
  531. package/dist/src/compiled/_chunks/node/chunk-5OX2R7AJ-CxVV-owP.js +0 -1
  532. package/dist/src/compiled/_chunks/node/chunk-AYN7QRWH-B__hKQV7.js +0 -1
  533. package/dist/src/compiled/_chunks/node/chunk-QZV7YRVM-Dzw4WEBv.js +0 -1
  534. package/dist/src/compiled/_chunks/node/dist-CweJdVFE.js +0 -6
  535. package/dist/src/compiled/_chunks/node/dist-Da54NuK8.js +0 -96
  536. package/dist/src/compiled/_chunks/workflow/attribute-changes-A6HfMNG3.js +0 -6
  537. package/dist/src/compiled/_chunks/workflow/resume-hook-CAqlhwic.js +0 -1
  538. package/dist/src/compiled/_chunks/workflow/sleep-CbUwdv6O.js +0 -1
  539. package/dist/src/compiled/chat/_mdast.d.ts +0 -24
  540. package/dist/src/compiled/chat/_workflow-serde.d.ts +0 -3
  541. package/dist/src/compiled/chat/jsx-runtime-_JEEAotp.d.ts +0 -907
  542. package/dist/src/execution/sandbox/bindings/local-backend-utils.js +0 -1
  543. package/dist/src/execution/sandbox/lazy-backend.d.ts +0 -15
  544. package/dist/src/execution/sandbox/lazy-backend.js +0 -1
  545. package/dist/src/execution/sandbox/template-prewarm-lock.d.ts +0 -8
  546. package/dist/src/execution/sandbox/template-prewarm-lock.js +0 -1
  547. package/dist/src/execution/tasks/child/steps.d.ts +0 -81
  548. package/dist/src/execution/tasks/child/steps.js +0 -1
  549. package/dist/src/execution/tasks/child/workflow.d.ts +0 -28
  550. package/dist/src/execution/tasks/child/workflow.js +0 -1
  551. package/dist/src/execution/tools/subagent/emit-called-step.d.ts +0 -9
  552. package/dist/src/execution/tools/subagent/emit-called-step.js +0 -1
  553. package/dist/src/execution/tools/workflow/run-control.d.ts +0 -14
  554. package/dist/src/execution/tools/workflow/run-control.js +0 -1
  555. package/dist/src/internal/authored-definition/sandbox.d.ts +0 -17
  556. package/dist/src/internal/authored-definition/sandbox.js +0 -1
  557. package/dist/src/internal/nitro/host/compiled-sandbox-backend-prune-plugin.d.ts +0 -16
  558. package/dist/src/internal/nitro/host/compiled-sandbox-backend-prune-plugin.js +0 -2
  559. package/dist/src/public/definitions/sandbox-backend.d.ts +0 -17
  560. package/dist/src/public/definitions/sandbox-backend.js +0 -1
  561. package/dist/src/public/sandbox/backends/default.d.ts +0 -1
  562. package/dist/src/public/sandbox/backends/default.js +0 -1
  563. package/dist/src/public/sandbox/backends/docker.d.ts +0 -1
  564. package/dist/src/public/sandbox/backends/docker.js +0 -1
  565. package/dist/src/public/sandbox/backends/just-bash.d.ts +0 -1
  566. package/dist/src/public/sandbox/backends/just-bash.js +0 -1
  567. package/dist/src/public/sandbox/backends/microsandbox.d.ts +0 -1
  568. package/dist/src/public/sandbox/backends/microsandbox.js +0 -1
  569. package/dist/src/public/sandbox/backends/vercel.d.ts +0 -1
  570. package/dist/src/public/sandbox/backends/vercel.js +0 -1
  571. package/dist/src/runtime/sandbox/keys.d.ts +0 -42
  572. package/dist/src/runtime/sandbox/keys.js +0 -1
  573. package/dist/src/runtime/sandbox/template-plan.d.ts +0 -24
  574. package/dist/src/runtime/sandbox/template-plan.js +0 -1
  575. package/dist/src/sandbox/backends/default.d.ts +0 -42
  576. package/dist/src/sandbox/backends/default.js +0 -1
  577. package/dist/src/sandbox/backends/docker.d.ts +0 -14
  578. package/dist/src/sandbox/backends/docker.js +0 -1
  579. package/dist/src/sandbox/backends/just-bash.d.ts +0 -17
  580. package/dist/src/sandbox/backends/just-bash.js +0 -1
  581. package/dist/src/sandbox/backends/microsandbox.d.ts +0 -17
  582. package/dist/src/sandbox/backends/microsandbox.js +0 -1
  583. package/dist/src/sandbox/backends/vercel.d.ts +0 -30
  584. package/dist/src/sandbox/backends/vercel.js +0 -1
  585. package/dist/src/shared/sandbox-backend.d.ts +0 -176
  586. package/dist/src/shared/sandbox-backend.js +0 -1
  587. package/dist/src/shared/sandbox-definition.d.ts +0 -112
  588. package/dist/src/shared/sandbox-definition.js +0 -1
  589. package/dist/src/tasks/session-index.d.ts +0 -65
  590. package/dist/src/tasks/session-index.js +0 -1
  591. package/dist/src/tools/task.d.ts +0 -55
  592. package/dist/src/tools/task.js +0 -1
  593. package/docs/sandbox.mdx +0 -342
@@ -1,15 +1,15 @@
1
- import{buildAgentHeader}from"./agent-header.js";import{detectMarkdownRendering}from"./markdown.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderAttentionRows,renderBlockLines}from"./blocks.js";import{copyTextToClipboard}from"./clipboard.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{formatStoredDiagnostic,presentDiagnostic}from"./diagnostic-presentation.js";import{interruptedError}from"./errors.js";import{FileContentCache}from"./file-content-cache.js";import{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,layoutPromptInput,lineOf,movePromptLine,visibleLine}from"./line-editor.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{MessageQueue,renderMessageQueueRows}from"./message-queue.js";import{initialModelEditorState,transitionModelEditor}from"./model-editor.js";import{initialProviderPickerState,transitionProviderPicker}from"./provider-picker.js";import{renderQuestionPanel}from"./question-panel.js";import{enterBadge,flowMessageRows,renderAcknowledgeQuestion,renderFlowPanel,renderModelEditorQuestion,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{formatAssistantResponseStats,formatTokenFlow,formatTurnDuration,isIncompleteOsc,isIncompletePaste,nextKey,sanitizePastedText,stripPasteStart,stripPromptControlCharacters,takeUntil,typewriterText}from"./stream-format.js";import{TraceViewerSession}from"./traces/trace-viewer-session.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{isPanelRoutedTool,presentPreparingTool,presentTool,readWriteFileInput,toolBaseName}from"./tool-presentation.js";import{groupToolBlocksForDisplay}from"./tool-block-groups.js";import{TurnClock}from"./turn-clock.js";import{allTodoItemsSettled,readTodoToolItems,renderFinishedTodoRows,renderTodoPanelRows}from"./todo-panel.js";import{reduceSetupSelectInput,setupSelectionIntent}from"./setup-selection-input.js";import{BACKGROUND_COLOR_QUERY,parseBackgroundColorReply}from"./terminal-background.js";import{inspectError}from"#internal/logging.js";import{eveVersionTag}from"#cli/banner.js";import{clipVisible,renderInputText,renderInputWithBlockCursor,stripAnsi,stripTerminalControls}from"#cli/ui/terminal-text.js";import{renderCursorRow}from"#setup/cli/option-row.js";import{initialSelectState,orderedSelection,reduceSelect,searchActionQuery,selectValueAtCursor}from"#setup/cli/select-state.js";import{toErrorMessage}from"#shared/errors.js";import{StringDecoder}from"node:string_decoder";import{summarizeKnownError}from"#harness/semantic-errors/index.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{LiveRegion}from"#cli/ui/live-region.js";import{AltScreen}from"#cli/ui/alt-screen.js";import{PROGRESS_PULSE_ASCII_GLYPH,PROGRESS_PULSE_GLYPH,isProgressPulseVisible}from"#cli/ui/progress-pulse.js";import{readGatewayServiceTier}from"#shared/gateway-service-tier.js";function isMultiSelectRequest(e){return e.kind===`multi`||e.kind===`searchable-multi`}function moveActionCursor(e,t,n){return n===0?void 0:e===void 0?t===`down`?0:n-1:(e+(t===`down`?1:-1)+n)%n}function completedTurnStatus(e){return e.interrupted?`Interrupted`:e.cancelled?`Cancelled`:e.continueSession?`Ready`:`Done`}const incompletePasteFlushMs=1e3,STATUS={processing:`Working…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h=[];#g=new Map;#_=new Set;#v=[];#y=new Set;#b=new Map;#x=0;#S=new Map;#C=new Set;#w=new Set;#T=new FileContentCache;#E=new Set;#D;#O;#k;#A;#j=0;#M;#N=!1;#P;#F=[];#I;#L=0;#R;#z;#B=``;#V=0;#H=new PromptHistory;#U=!1;#W;#G=!1;#K=!1;#q=new TurnClock;#J=EMPTY_LINE;#Y=!1;#X={kind:`idle`};#Z;#Q=STATUS.processing;#$;#ee=`eve`;#te=!1;#ne=!1;#re=!1;#ie=!1;#ae=!1;#oe=!1;#se=!1;#ce;#le=!0;#ue=0;#de=Date.now();#fe;#pe;#me;#he=!1;#ge;#_e=``;#ve=new StringDecoder(`utf8`);#ye;#be;#xe;#Se=!1;#Ce=!1;#we;#Te;#Ee;#De;#Oe;#ke;#Ae;#je=``;#Me=``;#Ne;#Pe;#Fe;#Ie=!1;#Le;#Re=0;#ze;#Be;#Ve;#He;#Ue;#We;#Ge;#Ke;#qe=new MessageQueue;#Je;#Ye;#Xe=!1;#Ze;#Qe;#$e=!1;#et;#tt;#nt;#rt;#it;setupFlow={begin:(e,t)=>this.#dt(e,t),setNavigation:e=>this.#ft(e),end:e=>this.#pt(e?.preserveDiagnostics??!0),readSelect:e=>this.#mt(e),readEditableSelect:e=>this.#gt(e),readProviderPicker:e=>this.#_t(e),readModelEditor:e=>this.#vt(e),readText:e=>this.#yt(e),readAcknowledge:e=>this.#bt(e),readChoice:e=>this.#ht(e),setStatus:e=>this.#Ot(e),renderLine:(e,t)=>this.#kt(e,t),replaceContent:e=>this.#At(e),renderOutput:e=>this.#jt(e),withInheritedStdio:e=>this.#Mt(e),withExclusiveTerminal:e=>this.#Mt(e),waitForInterrupt:e=>this.#Tt(e)};traceViewer={open:e=>this.#Pt(e)};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=new AltScreen(this.#t),this.#i=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#a=e?.renderMarkdown??detectMarkdownRendering(),this.#o=e?.tools??`auto-collapsed`,this.#s=e?.reasoning??`auto-collapsed`,this.#c=e?.subagents??`auto-collapsed`,this.#l=e?.connectionAuth??`full`,this.#u=e?.assistantResponseStats??`tokensPerSecond`,this.#Ee=e?.contextSize,this.#d=e?.captureForeignOutput??this.#t===process.stdout,this.#f=e?.diagnostics,this.#ce=e?.onExitRequest,this.#m=e?.logs??`none`,this.#p=e?.availablePromptCommands??PROMPT_COMMANDS}setStartupPhase(e){this.#O=e,e===void 0?this.#en():this.#Qt(),this.#Dn()}renderAgentHeader(e){this.#M=void 0,this.#ee=e.name,(this.#D?.info?.agent.model.routing.kind!==`dynamic`||e.info?.agent.model.routing.kind!==`dynamic`)&&(this.#Ue=void 0),this.#D=e,this.#Lt();let t=this.#Mn().join(`
2
- `);if(this.#N){t!==this.#P&&(this.#P=t,this.#in({kind:`agent-header`,body:t,live:!1})),this.#Dn();return}this.#N=!0,this.#P=t,this.#n.flush(this.#Mn(),this.#Ln(this.#Kn()))}beginStartupDraft(e){this.#Lt({title:e.title}),this.#U=!0,this.#G=!0,this.#O=`starting`,this.#M={name:e.title},this.#j=Date.now();let t=lineOf(stripPromptControlCharacters(e.initialDraft??``));this.#k=t,this.#ot(t),this.#Yt(),this.#Qt(),this.#Dn();let apply=e=>{t=e,this.#k=e,this.#Zt(),this.#ot(t),this.#Dn()};this.#A=e=>{if(e.type===`escape`&&this.#tt!==void 0){this.#tt(`escape`);return}if(e.type===`ctrl-c`&&this.#tt!==void 0){this.#Nt(),this.#tt(`ctrl-c`);return}let n=applyLineEditorKey(t,e,{multiline:!0});if(n!==void 0){apply(n);return}if(e.type===`enter`&&t.text.trim().length>0){this.#qe.enqueue(t.text)&&apply(EMPTY_LINE);return}e.type===`ctrl-c`&&this.#ce?.()},this.#at()}#at(){this.#k!==void 0&&this.#A!==void 0&&(this.#Kt(),this.#ot(this.#k),this.#U=!0,this.#ge=this.#A,this.#Bt())}finishStartupDraft(){let e={draft:this.#k?.text??this.#B,queuedPrompt:this.#qe.takePrompt()};return this.#k=void 0,this.#A=void 0,this.#Vt(),this.#Xt(),this.#U=!1,this.#G=!1,e}async readPrompt(e){this.#Lt(e),this.#rn(),this.#on(),this.#U=!0,this.#G=!0,this.#X={kind:`idle`},this.#Q=``,this.#oe=this.#se,this.#se=!1;let t=this.#qe.restoreDraft()?.split(`
1
+ import{buildAgentHeader}from"./agent-header.js";import{detectMarkdownRendering}from"./markdown.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderAttentionRows,renderBlockLines}from"./blocks.js";import{copyTextToClipboard}from"./clipboard.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{formatStoredDiagnostic,presentDiagnostic}from"./diagnostic-presentation.js";import{interruptedError}from"./errors.js";import{FileContentCache}from"./file-content-cache.js";import{EMPTY_LINE,KillRing,PromptHistory,applyLineEditorKey,deleteForward,layoutPromptInput,lineOf,movePromptLine,visibleLine}from"./line-editor.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{MessageQueue,renderMessageQueueRows}from"./message-queue.js";import{enterBadge,flowMessageRows,renderAcknowledgeQuestion,renderFlowPanel,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{initialModelPickerState,modelPickerTitle,renderModelPicker,transitionModelPicker}from"./model-picker.js";import{initialProviderPickerState,transitionProviderPicker}from"./provider-picker.js";import{renderQuestionPanel}from"./question-panel.js";import{formatAssistantResponseStats,formatTokenFlow,formatTurnDuration,isIncompleteOsc,isIncompletePaste,nextKey,sanitizePastedText,stripPasteStart,stripPromptControlCharacters,takeUntil}from"./stream-format.js";import{TraceViewerSession}from"./traces/trace-viewer-session.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{isPanelRoutedTool,presentPreparingTool,presentTool,readWriteFileInput,toolBaseName}from"./tool-presentation.js";import{groupToolBlocksForDisplay}from"./tool-block-groups.js";import{TurnClock}from"./turn-clock.js";import{allTodoItemsSettled,readTodoToolItems,renderFinishedTodoRows,renderTodoPanelRows}from"./todo-panel.js";import{reduceSetupSelectInput,setupSelectionIntent}from"./setup-selection-input.js";import{BACKGROUND_COLOR_QUERY,parseBackgroundColorReply}from"./terminal-background.js";import{inspectError}from"#internal/logging.js";import{eveVersionTag}from"#cli/banner.js";import{clipVisible,renderInputText,renderInputWithBlockCursor,stripAnsi,stripTerminalControls}from"#cli/ui/terminal-text.js";import{renderCursorRow}from"#setup/cli/option-row.js";import{initialSelectState,orderedSelection,reduceSelect,searchActionQuery,selectValueAtCursor}from"#setup/cli/select-state.js";import{toErrorMessage}from"#shared/errors.js";import{StringDecoder}from"node:string_decoder";import{summarizeKnownError}from"#harness/semantic-errors/index.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{LiveRegion}from"#cli/ui/live-region.js";import{AltScreen}from"#cli/ui/alt-screen.js";import{PROGRESS_PULSE_ASCII_GLYPH,PROGRESS_PULSE_GLYPH,isProgressPulseVisible}from"#cli/ui/progress-pulse.js";import{readGatewayServiceTier}from"#shared/gateway-service-tier.js";function isMultiSelectRequest(e){return e.kind===`multi`||e.kind===`searchable-multi`}function moveActionCursor(e,t,n){return n===0?void 0:e===void 0?t===`down`?0:n-1:(e+(t===`down`?1:-1)+n)%n}function completedTurnStatus(e){return e.interrupted?`Interrupted`:e.cancelled?`Cancelled`:e.continueSession?`Ready`:`Done`}function turnActivityLabel(e){return e===void 0?`Thinking`:e.runningTools.size>0?`Running`:e.modelActivity}function updateTurnActivity(e,t){switch(t.type){case`turn-start`:case`step-start`:case`reasoning-delta`:e.modelActivity=`Thinking`;break;case`assistant-delta`:case`tool-call-preparing`:e.modelActivity=`Generating`;break;case`assistant-complete`:t.text?.trim()&&(e.modelActivity=`Generating`);break;case`tool-call`:e.runningTools.add(t.toolCallId),e.modelActivity=`Thinking`;break;case`tool-result`:case`tool-error`:case`tool-rejected`:e.runningTools.delete(t.toolCallId)}}const incompletePasteFlushMs=1e3,STATUS={processing:`Thinking`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h=[];#g=new Map;#_=new Set;#v=[];#y=new Set;#b=new Map;#x=0;#S=new Map;#C=new Set;#w=new Set;#T=new FileContentCache;#E=new Set;#D;#O;#k;#A;#j=0;#M;#N=!1;#P;#F=[];#I;#L=0;#R;#z;#B=``;#V=0;#H=new PromptHistory;#U=new KillRing;#W=!1;#G;#K=!1;#q=!1;#J=new TurnClock;#Y;#X=EMPTY_LINE;#Z=!1;#Q={kind:`idle`};#$;#ee=STATUS.processing;#te;#ne=`eve`;#re=!1;#ie=!1;#ae=!1;#oe=!1;#se=!1;#ce=!1;#le=!1;#ue;#de=!0;#fe=0;#pe=Date.now();#me;#he;#ge;#_e=!1;#ve;#ye=``;#be=new StringDecoder(`utf8`);#xe;#Se;#Ce;#we=!1;#Te=!1;#Ee;#De;#Oe;#ke;#Ae;#je;#Me;#Ne=``;#Pe=``;#Fe;#Ie;#Le;#Re=!1;#ze;#Be=0;#Ve;#He;#Ue;#We;#Ge;#Ke;#qe;#Je;#Ye=new MessageQueue;#Xe;#Ze;#Qe=!1;#$e;#et;#tt=!1;#nt;#rt;#it;#at;#ot;setupFlow={begin:(e,t)=>this.#pt(e,t),setNavigation:e=>this.#mt(e),end:e=>this.#ht(e?.preserveDiagnostics??!0),readSelect:e=>this.#gt(e),readEditableSelect:e=>this.#vt(e),readProviderPicker:e=>this.#yt(e),readModelPicker:e=>this.#bt(e),readText:e=>this.#xt(e),readAcknowledge:e=>this.#St(e),readChoice:e=>this.#_t(e),setStatus:e=>this.#At(e),renderLine:(e,t)=>this.#jt(e,t),replaceContent:e=>this.#Mt(e),renderOutput:e=>this.#Nt(e),withInheritedStdio:e=>this.#Pt(e),withExclusiveTerminal:e=>this.#Pt(e),waitForInterrupt:e=>this.#Dt(e)};traceViewer={open:e=>this.#It(e)};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=new AltScreen(this.#t),this.#i=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#a=e?.renderMarkdown??detectMarkdownRendering(),this.#o=e?.tools??`auto-collapsed`,this.#s=e?.reasoning??`auto-collapsed`,this.#c=e?.subagents??`auto-collapsed`,this.#l=e?.connectionAuth??`full`,this.#u=e?.assistantResponseStats??`tokensPerSecond`,this.#Oe=e?.contextSize,this.#d=e?.captureForeignOutput??this.#t===process.stdout,this.#f=e?.diagnostics,this.#ue=e?.onExitRequest,this.#m=e?.logs??`none`,this.#p=e?.availablePromptCommands??PROMPT_COMMANDS}setStartupPhase(e){this.#O=e,e===void 0?this.#rn():this.#tn(),this.#An()}renderAgentHeader(e){this.#M=void 0,this.#ne=e.name,(this.#D?.info?.agent.model.routing.kind!==`dynamic`||e.info?.agent.model.routing.kind!==`dynamic`)&&(this.#Ge=void 0),this.#D=e,this.#zt();let t=this.#Fn().join(`
2
+ `);if(this.#N){t!==this.#P&&(this.#P=t,this.#sn({kind:`agent-header`,body:t,live:!1})),this.#An();return}this.#N=!0,this.#P=t,this.#n.flush(this.#Fn(),this.#Bn(this.#Yn()))}beginStartupDraft(e){this.#zt({title:e.title}),this.#W=!0,this.#K=!0,this.#O=`starting`,this.#M={name:e.title},this.#j=Date.now();let t=lineOf(stripPromptControlCharacters(e.initialDraft??``));this.#k=t,this.#ct(t),this.#Qt(),this.#tn(),this.#An();let apply=e=>{t=e,this.#k=e,this.#en(),this.#ct(t),this.#An()};this.#A=e=>{if(e.type===`escape`&&this.#rt!==void 0){this.#rt(`escape`);return}if(e.type===`ctrl-c`&&this.#rt!==void 0){this.#Ft(),this.#rt(`ctrl-c`);return}let n=this.#U.apply(t,e,{multiline:!0});if(n!==void 0){apply(n);return}if(e.type===`enter`&&t.text.trim().length>0){this.#Ye.enqueue(t.text)&&apply(EMPTY_LINE);return}e.type===`ctrl-c`&&this.#ue?.()},this.#st()}#st(){this.#k!==void 0&&this.#A!==void 0&&(this.#Yt(),this.#ct(this.#k),this.#W=!0,this.#ve=this.#A,this.#Ht())}finishStartupDraft(){let e={draft:this.#k?.text??this.#B,queuedPrompt:this.#Ye.takePrompt()};return this.#k=void 0,this.#A=void 0,this.#Ut(),this.#$t(),this.#W=!1,this.#K=!1,e}async readPrompt(e){this.#zt(e),this.#on(),this.#ln(),this.#W=!0,this.#K=!0,this.#Q={kind:`idle`},this.#ee=``,this.#ce=this.#le,this.#le=!1;let t=this.#Ye.restoreDraft()?.split(`
3
3
  `).map(stripPromptControlCharacters).join(`
4
- `),n=stripPromptControlCharacters(e?.initialDraft??this.#J.text),r=t===void 0?n:n.length===0?t:`${t}\n\n${n}`,i=lineOf(r);return this.#J=EMPTY_LINE,this.#H.begin(i.text),this.#ot(i),this.#W=typeaheadFor(this.#p,i.text),this.#Yt(),this.#Dn(),await new Promise((e,t)=>{this.#Z=t;let apply=e=>{i=e,this.#Zt(),this.#ot(i),this.#W=typeaheadFor(this.#p,e.text,this.#W),this.#Dn()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#W=void 0,this.#Xt(),this.#zt(),t(interruptedError())},suggestions=()=>this.#W!==void 0&&isTypeaheadOpen(this.#W)?this.#W:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#ge=t=>{t.type!==`ctrl-c`&&this.#oe&&(this.#oe=!1,this.#Dn());let n=applyLineEditorKey(i,t,{multiline:!0});if(n!==void 0){apply(n);return}switch(t.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#W=moveTypeaheadSelection(e,-1),this.#Dn();break}let t=movePromptLine(i,`up`);t===void 0?recall(this.#H.previous(i.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#W=moveTypeaheadSelection(e,1),this.#Dn();break}let t=movePromptLine(i,`down`);t===void 0?recall(this.#H.next()):apply(t);break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#W=dismissTypeahead(e),this.#Dn());break}case`enter`:{let t=highlighted(),n=t!==void 0&&parsePromptCommand(i.text)===null?typeaheadCompletion(t).trimEnd():i.text;if(n.trim().length===0)break;this.#W=void 0,this.#H.add(n),this.#U=!1,this.#Xt(),this.#Q=STATUS.processing,isPromptControlCommand(n)?this.#in({kind:`command`,body:stripTerminalControls(n.trim()),live:!1}):(this.#$t(),this.#an(n),this.#ze=n,this.#q.arm()),this.#ot(EMPTY_LINE),this.#Dn(),this.#Vt(),e(n);break}case`ctrl-d`:i.text.length===0?(this.#Nt(),interrupt()):apply(deleteForward(i));break;case`ctrl-l`:this.#An();break;case`ctrl-r`:this.#Dn();break;case`ctrl-c`:if(this.#oe){this.#Nt(),interrupt();break}this.#oe=!0,apply(EMPTY_LINE)}},this.#Bt()})}#ot(e){this.#B=e.text,this.#V=e.cursor}takeQueuedPrompt(){let e=this.#qe.view().steering,t=this.#qe.takePrompt();return t!==void 0&&(this.#Qe=e?`steer`:`queue`),t}async renderStream(e,t){this.#Lt(t),this.#_.clear(),this.#U=!1,this.#X.kind!==`waiting`&&(this.#X={kind:`waiting`,startedAtMs:Date.now()}),this.#Q=this.#L>0?STATUS.connectionAuth:STATUS.processing,this.#sn(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#f?.recordPrompt(),t?.submittedPrompt!==void 0&&!this.#q.armed&&this.#q.arm(),this.#ie=!1,this.#Xe=!1,this.#$e=!1,this.#et=t?.submittedPrompt,this.#qe.beginTurn(),this.#Je=e.cancel,this.#Ye=e.steer,this.#we=void 0,this.#Te=void 0,this.#De=void 0,this.#Oe=void 0,this.#ke=Date.now();let n={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u};this.#Qt(),this.#Y=!0,this.#Dn();let r=new Promise(e=>{this.#xe=e});this.#ge=e=>this.#qt(e),this.#Bt();let i={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!0};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#ie)break;this.#hn(t,n,i)}}catch(e){let t=summarizeKnownError(e);t===null?this.#cn(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#cn(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#xe=void 0,this.#ie&&e.abort?.(),this.#Je=void 0,this.#Ye=void 0,this.#Vt(),this.#Y=!1,this.#X.kind===`waiting`&&(this.#X={kind:`idle`}),this.#rn(),this.#Q=completedTurnStatus({interrupted:this.#ie,cancelled:this.#Xe,continueSession:t?.continueSession===!0}),this.#Sn(i),(this.#ie||i.cancelled)&&this.#xn(i),this.#mn(),this.#rn(),this.#f?.reportStats(),this.#Dn(),t?.continueSession||this.#zt()}}async renderIdleStream(e,t){let n={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u},r={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!1};try{for await(let t of iterateTUIStream(e.events))this.#hn(t,n,r)}catch(e){let t=summarizeKnownError(e);t===null?this.#cn(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#cn(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#Sn(r),r.cancelled&&this.#xn(r),this.#mn(),this.#rn(),this.#f?.reportStats(),this.#Dn()}}async readToolApproval(e,t){return this.#Lt(t),this.#en(),this.#U=!1,this.#X={kind:`idle`},this.#Q=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#ie=!1,this.#Dn(),await new Promise((t,n)=>{this.#Z=n,this.#ge=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#$t(),this.#Q=STATUS.processing,this.#Vt(),this.#Dn(),t({approved:!0})):n===`n`&&(this.#$t(),this.#Q=STATUS.processing,this.#ct(e.toolCallId),this.#Vt(),this.#Dn(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#Dn();break;case`ctrl-c`:this.#ie=!0,this.#zt(),n(interruptedError())}},this.#Bt()})}async readInputQuestion(e,t){this.#Lt(t),this.#en(),this.#U=!1,this.#G=!1,this.#X={kind:`idle`},this.#ie=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`overlay`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,overlayPanel=t=>renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#le},this.#i,t),renderTextSection=()=>{this.#un({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,void 0,this.#i),preformatted:!0,live:!0})},syncFreeformCaret=()=>{isOnFreeformRow()?this.#Yt():(this.#Xt(),this.#Zt())};s===`overlay`?(s=`overlay`,this.#U=!1,this.#fn(o),this.#Be=overlayPanel,this.#Q=``,syncFreeformCaret(),this.#Dn()):(s=`text`,this.#Be=void 0,renderTextSection(),this.#U=!0,this.#ot(l),this.#Q=``,this.#Yt(),this.#Dn());let finalize=t=>{this.#Be=void 0,this.#un({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#U=!1,this.#$t(),this.#Q=STATUS.processing,this.#Xt(),this.#Vt(),this.#Dn();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#Be=void 0,this.#un({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Dismissed.`)}`,preformatted:!0,live:!1}),this.#U=!1,this.#Q=``,this.#Xt(),this.#Vt(),this.#Dn(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#Dn())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,r)=>{this.#Z=r,u=t,this.#ge=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#Zt(),s===`text`&&this.#ot(l),this.#Dn();return}this.#ie=!0,this.#Be=void 0,this.#Xt(),this.#zt(),r(interruptedError());return}if(t.type===`ctrl-r`){this.#Dn();return}if(s===`overlay`){let r=setupSelectionIntent(t,{textNavigation:!isOnFreeformRow()});if(r?.kind===`move`){moveCursor(r.direction===`up`?-1:1);return}switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#Zt(),this.#Dn();break}dismiss();break;default:if(isOnFreeformRow()){let e=applyLineEditorKey(l,t);e!==void 0&&(l=e,this.#Zt(),this.#Dn());break}if(t.type===`text`&&/^[1-9]$/u.test(t.value)){let e=Number(t.value)-1;e<n.length?selectOptionAt(e):e===n.length&&i&&(c=e,syncFreeformCaret(),this.#Dn())}}return}let a=applyLineEditorKey(l,t,{multiline:!0});if(a!==void 0){l=a,this.#Zt(),this.#ot(l),this.#Dn();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#Zt(),this.#ot(l),this.#Dn());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#Zt(),this.#ot(l),this.#Dn();break}dismiss()}},this.#Bt()})}upsertSubagentStep(e){if(this.#f?.recordSubagentDispatch(e.callId),this.#c===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(t.length!==0||n.length!==0){if(this.#ln(e.callId,e.subagentName),this.#c===`collapsed`){this.#Dn();return}this.#dn({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,subagentCallId:e.callId,depth:1,reasoning:t,body:n,collapsed:this.#c!==`full`,live:!e.finalized}),this.#Dn()}}upsertSubagentTool(e){if(this.#f?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#f?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#c===`hidden`)return;if(this.#ln(e.callId,e.subagentName),this.#c===`collapsed`){this.#Dn();return}let t=subagentToolStatus(e.status),n=e.status===`preparing`?presentPreparingTool(e.toolName):presentTool(e.toolName,e.input,this.#yn({input:e.input,output:e.output,toolCallId:e.childCallId,toolName:e.toolName})),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,subagentCallId:e.callId,depth:1,title:stripTerminalControls(n.title),subtitle:stripTerminalControls(n.subtitle),status:t,live:t===`running`||t===`approval`,expanded:this.#c===`full`,toolName:e.toolName,toolGroup:n.group,toolInput:e.input};n.doneTitle!==void 0&&(r.doneTitle=stripTerminalControls(n.doneTitle)),n.detail!==void 0&&(r.detailLines=n.detail,r.keepDetailWhenDone=n.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=n.summarizeResult(e.output),r.toolOutput=e.output),this.#dn(r),this.#st(e.callId),this.#Dn()}#st(e){applyCohortLiveness(this.#h.filter(t=>t.kind===`subagent-tool`&&t.subagentCallId===e).map(e=>({block:e,active:isActiveToolStatus(e.status)})))}removeSubagentTool(e){this.#fn(subagentToolSectionId(e.callId,e.childCallId)),this.#Dn()}subagents={begin:e=>this.beginSubagent(e),background:e=>this.backgroundSubagent(e),upsertStep:e=>this.upsertSubagentStep(e),upsertTool:e=>this.upsertSubagentTool(e),removeTool:e=>this.removeSubagentTool(e),complete:e=>this.completeSubagent(e),markChildToolCallId:e=>this.markChildToolCallId(e)};beginSubagent(e){if(this.#c===`hidden`)return;this.#ln(e.callId,e.name);let t=this.#g.get(subagentHeaderId(e.callId));t!==void 0&&(t.status===`done`&&delete t.status,t.live=!0),this.#w.delete(e.callId),this.#Dn()}backgroundSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t===void 0||this.#_.has(subagentHeaderId(e.callId)))return;t.status=`running`,t.live=!0,t.updateSeq=++this.#x;let n=this.#C.has(e.callId);this.#C.add(e.callId),n||this.#pn(e.callId),this.#rn(),this.#Dn()}completeSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t!==void 0){if(t.status=`done`,e.authoritative){this.#C.delete(e.callId),this.#w.delete(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!1)}else{this.#w.add(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!0)}this.#rn(),this.#Dn()}}markChildToolCallId(e){this.#y.add(e);let t=this.#b.get(e);t!==void 0&&(this.#fn(t),this.#b.delete(e),this.#Dn())}#ct(e){let t=this.#g.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#l===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#un({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e,t),preformatted:!0,live:t===void 0}),this.#Dn()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#L)return;let n=this.#L>0;this.#L=t,t>0?(this.#Q=STATUS.connectionAuth,this.#Dn()):n&&(this.#Q=STATUS.processing,this.#Dn())}setVercelStatus(e){this.#R=e,this.#Dn()}setRemoteConnectionStatus(e){this.#z=e,this.#Dn()}reset(){this.#h=[],this.#g.clear(),this.#_.clear(),this.#I=void 0,this.#F.length=0,this.#v.length=0,this.#N=!1,this.#P=void 0,this.#lt(),this.#K=!1,this.#ze=void 0,this.#Pe=void 0,this.#L=0,this.#we=void 0,this.#Te=void 0,this.#De=void 0,this.#Oe=void 0,this.#ke=void 0,this.#te&&(this.#n.clearAll(),this.#Dn())}renderSessionBoundary(){this.#on(),this.#lt();let e=this.#i.colors,t=this.#i.glyph,n=e.dim(`${t.cornerOpen}${t.dash.repeat(2)} Session restarted, clear context.`);this.#in({kind:`session-boundary`,body:n,live:!1}),this.#Dn()}#lt(){this.#Ue=void 0,this.#We=void 0,this.#y.clear(),this.#b.clear(),this.#E.clear(),this.#C.clear(),this.#w.clear(),this.#S.clear(),this.#Ge=void 0,this.#Ke=void 0,this.#qe.reset(),this.#Qe=void 0,this.#T.clear(),this.#q.reset(),this.#rn()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Lt(),this.#in({kind:`notice`,body:t,live:!1}),this.#Dn())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#f?.append({source:`sandbox`,detail:t}),this.#Lt(),this.#in({kind:`sandbox`,body:t,live:!1}),this.#Dn())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#ut();return}this.#Lt(),this.#He=t,this.#Dn()}clearSetupWarning(){this.#ut()}#ut(){this.#He!==void 0&&(this.#He=void 0,this.#Dn())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#Lt();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#in(r),this.#Dn()}renderCommandResult(e,t){let n=stripAnsi(e);n.trim().length!==0&&(this.#Lt(),this.#in({kind:`result`,body:n,live:!1,status:t===`success`?`done`:void 0}),this.#Dn())}#dt(e,t=`spinner`){this.#Lt(),this.#k===void 0&&(this.#U=!1),this.#X={kind:`idle`},this.#Q=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#Ve={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#Qt(),this.#Dn()}#ft(e){this.#Ve!==void 0&&(this.#Ve.navigation=e,this.#Dn())}#pt(e){this.#tt=void 0,this.#Dt();let t=this.#Ve;if(t!==void 0){if(this.#Ve=void 0,this.#k===void 0?this.#en():this.#at(),e){let e=[];for(let n of t.lines){if(n.evidence===!0){e.push(n.text);continue}(n.tone===`warning`||n.tone===`error`)&&(e.length>0&&this.#in({kind:`flow`,title:`info`,body:e.join(`
5
- `),live:!1}),this.#in({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#Dn()}}async#mt(e){let t=this.#xt(e.message),n=isMultiSelectRequest(e),r=e.kind===`search`?e.searchAction:void 0,i=e.options,a=e.navigation?.kind===`planner`,o={options:i,searchAction:r,submitRow:n&&!a};`initialValue`in e&&e.initialValue!==void 0&&(o.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(o.initialValues=e.initialValues);let s=initialSelectState(o),c,l=!1,u=0,isCurrentSearch=e=>e===u,clearSearch=()=>{u+=1,l=!1,s=reduceSelect(s,{type:`clear`},{options:i,searchAction:r,submitRow:n&&!a}),this.#Dn()},loadSearch=async(e,t)=>{l=!0,c=void 0;let o=++u;this.#Dn();try{let c=await t(e);if(!isCurrentSearch(o))return;let l=s.filter;i=c,s={...initialSelectState({options:c,searchAction:r,submitRow:n&&!a}),filter:l}}catch(e){isCurrentSearch(o)&&(c=toErrorMessage(e))}finally{isCurrentSearch(o)&&(l=!1,this.#Dn())}},d=e.notices;if(e.kind===`task-list`||e.kind===`search`&&e.layout===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));d=e.notices??r,t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,message:``,options:i,select:s};return d!==void 0&&d.length>0&&(t.notices=d),c!==void 0&&(t.error=c),l&&(t.loadingFrame=this.#Pn()),t};return t.question=e=>renderSelectQuestion(panelState(),this.#i,e),this.#Dn(),await this.#wt((t,o)=>{let close=e=>{u+=1,o(e)};if(l){t.type===`ctrl-c`?close(void 0):t.type===`escape`?clearSearch():t.type===`ctrl-r`&&this.#Dn();return}let d=e.navigation?.kind===`planner`?e.navigation:void 0,f=t.type===`left`&&(d?.activeStep??0)>(d?.firstNavigableStep??0)?`back`:t.type===`right`&&d!==void 0&&d.activeStep>=(d.firstNavigableStep??0)&&d.activeStep<d.steps.length-1?`forward`:void 0;if(f!==void 0){close({kind:`navigate`,direction:f,values:n?orderedSelection(i,s.selected):[]});return}let p={key:t,options:i,searchAction:r,select:s},m=reduceSetupSelectInput(n?{...p,kind:e.kind,required:e.required,plannerNavigation:a||void 0}:{...p,kind:e.kind});switch(m.kind){case`cancel`:close(void 0);return;case`repaint`:this.#Dn();return;case`update`:s=m.select,c=void 0,this.#Dn();return;case`submit`:{let e=searchActionQuery(m.values[0]??``),t=r?.load;if(e===void 0||t===void 0){close(m.values);return}loadSearch(e,t);return}case`error`:c=m.message,this.#Dn();return;case`ignore`:return}}).promise}#ht(e){this.#Lt();let t=this.#St();t.status={kind:`progress`,text:stripTerminalControls(e.status),startedAtMs:Date.now()};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#i,t),this.#Dn();let r=this.#wt((t,r)=>{let i=setupSelectionIntent(t,{textNavigation:!0});switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#Dn();return;case`repaint`:this.#Dn();return;case`submit`:n!==void 0&&r(e.actions[n].value);return;case void 0:return}},()=>{t.status=void 0});return{choice:r.promise,close:()=>r.settle(void 0)}}async#gt(e){let t=this.#xt(e.message),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`inline-edit`,layout:`task-list`,message:``,options:e.options,select:r,edit:{optionValue:e.editable.value,caretVisible:this.#le,editor:{kind:`rename`,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint}}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#i,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?this.#Yt():(i=lineOf(``),this.#Xt())};return syncEditableRow(),this.#Dn(),await this.#wt((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#Zt(),this.#Dn()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#Dn()},submit=()=>{let t=selectValueAtCursor([...e.options],r.cursor);if(t===void 0)return;if(t!==e.editable.value){n({kind:`selected`,value:t});return}let o=(i.text||e.editable.defaultValue).trim(),s=e.editable.validate?.(o);if(s!==void 0){a=s,this.#Dn();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t,{textNavigation:!onEditableRow()});switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#Dn();return;case void 0:}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Xt()).promise}async#_t(e){let t=this.#xt(e.message),n=initialProviderPickerState(e.options,e.initialValue),r,cursorBadge=()=>{if(n.phase.kind!==`inactive`)return;let t=selectValueAtCursor([...e.options],n.select.cursor),r=e.options.find(e=>e.value===t);if(r!==void 0)return enterBadge(this.#i,r.checked===!0?`change`:void 0)};t.question=t=>{let r=cursorBadge(),i={kind:`inline-edit`,layout:`stacked`,message:``,options:e.options,select:n.select,edit:{optionValue:`ai-gateway-key`,caretVisible:this.#le,editor:{kind:`key`,phase:n.phase}}};return r!==void 0&&(i.cursorBadge=r),renderSelectQuestion(i,this.#i,t)};let syncCaret=()=>{n.phase.kind===`editing`||n.phase.kind===`invalid`?this.#Yt():this.#Xt()};return syncCaret(),this.#Dn(),await this.#wt((t,i,a)=>{let dispatch=t=>{let o=transitionProviderPicker(n,t,e.options);switch(o.kind){case`ignore`:return;case`clear`:r?.abort(),r=void 0,n=o.state,syncCaret(),this.#Dn();return;case`cancel`:i(void 0);return;case`render`:n=o.state,syncCaret(),this.#Dn();return;case`validate`:{n=o.state,syncCaret(),this.#Dn();let t=new AbortController;r=t;let i;try{i=e.validateInlineKey(o.key,t.signal)}catch(e){a(e);return}i.then(e=>{r!==t||t.signal.aborted||(r=void 0,dispatch({type:`validated`,validation:e}))},e=>{r!==t||t.signal.aborted||(r=void 0,a(e))});return}case`settle`:i(o.result);return}},o=setupSelectionIntent(t,{textNavigation:n.phase.kind===`inactive`});switch(o?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:o.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#Dn();return;case void 0:}if(n.phase.kind!==`editing`&&n.phase.kind!==`invalid`)return;let s=applyLineEditorKey(n.phase.editor,t);s!==void 0&&(this.#Zt(),dispatch({type:`edit`,editor:s}))},()=>{r?.abort(),r=void 0,this.#Xt()}).promise}async#vt(e){let t=this.#xt(`Select the model`),n=initialModelEditorState(e);return t.question=t=>renderModelEditorQuestion({request:e,state:n},this.#i,t,``),this.#Dn(),await this.#wt((t,r)=>{let dispatch=t=>{let i=transitionModelEditor(n,t,e);switch(i.kind){case`ignore`:return;case`render`:n=i.state,this.#Dn();return;case`cancel`:r(void 0);return;case`settle`:r(i.result);return}},i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:i.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#Dn();return;case void 0:}if(t.type===`left`||t.type===`right`){dispatch({type:`adjust`,direction:t.type});return}if(t.type===`tab`){dispatch({type:`adjust`,direction:`right`});return}if(t.type===`backspace`){dispatch({type:`backspace`});return}if(t.type===`text`)for(let e of t.value.replaceAll(`
6
- `,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#yt(e){let t=this.#xt(e.message),n=lineOf(``),r;return t.question=t=>{let i={message:``,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#le)},this.#Yt(),this.#Dn(),await this.#wt((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Zt(),this.#Dn()},a=applyLineEditorKey(n,t);if(a!==void 0){apply(a);return}switch(t.type){case`ctrl-c`:case`escape`:i(void 0);return;case`ctrl-r`:this.#Dn();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#Dn();return}i(t);return}default:return}},()=>this.#Xt()).promise}async#bt(e){let t=this.#xt(e.message);return t.question=t=>renderAcknowledgeQuestion({message:``,lines:e.lines},this.#i,t),this.#Dn(),await this.#wt((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#Dn();return;default:return}}).promise}#xt(e){this.#Lt(),this.#U=!1,this.#X={kind:`idle`},this.#Q=``;let t=this.#St();return t.questionTitle=stripTerminalControls(e),t.status!==void 0&&(t.status=void 0,t.summary=void 0,t.preview=void 0),t}#St(){return this.#Ve===void 0&&(this.#Ve={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#Ve}#Ct(){this.#Ve?.implicit===!0?this.#Ve=void 0:this.#Ve!==void 0&&(this.#Ve.question=void 0,this.#Ve.questionTitle=void 0,this.#Ve.hideLinesWhileQuestion=!1),this.#ge=void 0,this.#Vt(),this.#k===void 0?this.#Ve!==void 0&&this.#Et():this.#at(),this.#Ve===void 0&&this.#Dn()}#wt(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#Ct(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#Ct(),i(e))};return this.#Kt(),this.#ge=t=>{t.type===`ctrl-c`&&this.#Nt(),e(t,settle,reject)},this.#Bt(),{promise:a,settle}}#Tt(e){let t,n=new Promise(e=>{t=e});return this.#tt=t,this.#Et(e?.interruptible??!0),{promise:n,dispose:()=>{this.#tt===t&&(this.#tt=void 0,this.#Dt())}}}#Et(e=!0){if(this.#k!==void 0){this.#at();return}if(this.#tt===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#Nt();let e=this.#tt;this.#tt=void 0,this.#Dt(),e?.(t.type===`ctrl-c`?`ctrl-c`:`escape`);return}t.type===`ctrl-r`&&this.#Dn()};this.#nt=consumer,this.#Kt(),this.#ge=consumer,this.#Bt()}#Dt(){this.#nt!==void 0&&(this.#ge===this.#nt&&this.#Vt(),this.#nt=void 0)}#Ot(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#Ve!==void 0){this.#Ve.status=t,t===void 0&&(this.#Ve.preview=void 0),this.#Dn();return}if(!(this.#U||this.#Y)){if(t===void 0){this.#X={kind:`idle`},this.#$=void 0,this.#en(),this.#Dn();return}this.#Lt(),this.#$t(),this.#$=t.text,this.#Dn()}}#kt(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Ve;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#Dn();return}this.#Lt(),this.#in({kind:`flow`,title:t,body:n,live:!1}),this.#Dn()}#At(e){let t=this.#Ve;t!==void 0&&(t.lines=[],t.outputBuffer=[],t.preview=void 0,t.status=void 0,t.summary=e===void 0?void 0:{headline:stripTerminalControls(e.headline),facts:e.facts.map(e=>({label:stripTerminalControls(e.label),value:stripTerminalControls(e.value)}))},this.#Dn())}#jt(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Ve;if(n===void 0){this.#kt(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#Dn()}async#Mt(e){this.#_e=``,this.#Kt(),this.#tt=void 0,this.#Dt(),this.#Vt(),this.#tn(),this.#n.clear(),this.#Yn(),this.#r.enter({cursor:`visible`,mouse:!1}),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#r.exit(),this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#_e=``,this.#Kt(),this.#n.hideCursor(),this.#Jn(),this.#Ve===void 0?this.#rn():(this.#Qt(),this.#Et()),this.#n.reset(),this.#Dn()}}setSessionId(e){this.#Ze=e}shutdown(){if(this.#zt(),this.#ne&&!this.#re){this.#re=!0;let e=this.#Ze===void 0?``:` ${this.#i.glyph.dot} session ${this.#Ze}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}suspendPromptForInput(){this.#J={cursor:this.#V,text:this.#B},this.#zt()}requestInterrupt(){this.#ie=!0,this.#Ve!==void 0&&this.#ge?.({type:`ctrl-c`}),this.#xe?.(),this.#zt()}exitRequested(){return this.#ae}#Nt(){this.#ae=!0,this.#ce?.()}async#Pt(e){if(this.#rt!==void 0||!this.#te)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Kn(),height:this.#qn()}),paint:e=>this.#r.paint(e,this.#qn()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#it});this.#rt=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#It=e,this.#ge=e=>{t.handleKey(e)===`close`&&this.#Ft()},this.#Bt(),t.start()})}#Ft(){let e=this.#rt;if(e===void 0)return;this.#rt=void 0,e.dispose(),this.#Vt(),this.#r.exit(),this.#n.hideCursor(),this.#Dn(),this.#n.showCursor();let t=this.#It;this.#It=void 0,t?.()}#It;#Lt(e){this.#ee=e?.title??this.#ee,e?.contextSize!==void 0&&(this.#Ee=e.contextSize),!this.#te&&(this.#te=!0,this.#ne=!0,this.#n.reset(),this.#n.hideCursor(),this.#Jn(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#be=()=>this.#Dn(),this.#t.on(`resize`,this.#be),process.on(`exit`,this.#Rt))}#Rt=()=>{this.#te&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#zt(){this.#Ft();let e=this.#Z;if(this.#Z=void 0,e?.(interruptedError()),this.#Vt(),this.#Xt(),this.#tn(),this.#me!==void 0&&(clearTimeout(this.#me),this.#me=void 0),this.#he=!1,this.#rr(),this.#te){this.#ar();for(let e of this.#h)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#Dn(),this.#n.clear(),this.#n.showCursor(),this.#Yn(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#be&&=(this.#t.off(`resize`,this.#be),void 0),process.off(`exit`,this.#Rt),this.#te=!1}}#Bt(){this.#e.off(`data`,this.#Ht),this.#e.on(`data`,this.#Ht),this.#_e.length>0&&queueMicrotask(()=>{this.#ge!==void 0&&this.#_e.length>0&&(this.#Wt(),this.#Ut())})}#Vt(){this.#e.off(`data`,this.#Ht),this.#Kt(),this.#ge=void 0}#Ht=e=>{this.#Kt(),this.#_e+=this.#ve.write(e),this.#Wt(),this.#Ut()};#Ut(){if(this.#_e===`\x1B`){this.#ye=setTimeout(()=>{this.#_e===`\x1B`&&(this.#_e=``,this.#ge?.({type:`escape`}))},30),this.#ye.unref?.();return}if(isIncompletePaste(this.#_e)){let e=this.#_e;this.#ye=setTimeout(()=>{if(this.#_e!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#_e=``,t.length>0&&this.#ge?.({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#ye.unref?.();return}if(isIncompleteOsc(this.#_e)){let e=this.#_e;this.#ye=setTimeout(()=>{this.#_e===e&&(this.#_e=``)},incompletePasteFlushMs),this.#ye.unref?.()}}#Wt(){for(;this.#_e.length>0;){let e=nextKey(this.#_e);if(e.incomplete)return;if(this.#_e=this.#_e.slice(e.consumed),e.key!==void 0&&e.key.type!==`ignore`){if(e.key.type===`osc`){this.#Gt(e.key.value);continue}this.#ge?.(e.key)}}}#Gt(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#it=t,this.#rt?.setTerminalBackground(t))}#Kt(){this.#ye&&=(clearTimeout(this.#ye),void 0)}#qt(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#Dn();break;case`enter`:{let e=this.#J.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#Je!==void 0){this.#J=EMPTY_LINE,this.#qe.requestCancellation(),this.#$e=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#Je(),this.#Dn();break}let t=this.#Ye;t!==void 0&&parsePromptCommand(e)===null?(this.#J=EMPTY_LINE,this.#Jt(e,t)):this.#qe.enqueue(e)&&(this.#J=EMPTY_LINE),this.#Dn();break}case`ctrl-c`:case`escape`:if(e.type===`ctrl-c`&&this.#qe.view().cancelling){this.#ie=!0,this.#se=!0,this.#X={kind:`idle`},this.#Q=`Interrupted`,this.#xe?.(),this.#Dn();break}if(this.#qe.idle&&this.#Je===void 0)break;if(this.#qe.handleEscape()===`steer`){let e=this.#Ye;if(e!==void 0){let t=this.#qe.takeSteering();this.#Jt(t,e)}}else this.#$e=!0,this.#Je?.();this.#Dn();break;default:{let t=applyLineEditorKey(this.#J,e,{multiline:!0});t!==void 0&&(this.#J=t,this.#Dn());break}}}#Jt(e,t){this.#Qe=`steer`,this.#sn(e),t(e).catch(t=>{this.#qe.restoreSteering(e),this.#cn(`Steering failed`,toErrorMessage(t)),this.#Dn()})}#Yt(){this.#Xt(),this.#Zt(),this.#fe=setInterval(()=>{this.#le=!this.#le,this.#Dn()},500),this.#fe.unref?.()}#Xt(){this.#fe&&=(clearInterval(this.#fe),void 0),this.#le=!0}#Zt(){this.#le=!0}#Qt(){this.#tn(),this.#pe=setInterval(()=>{this.#ue+=1,this.#Dn()},90),this.#pe.unref?.()}#$t(){let e=Date.now();this.#de=e,this.#X={kind:`waiting`,startedAtMs:e},this.#Qt()}#en(){this.#nn()||this.#tn()}#tn(){this.#pe&&=(clearInterval(this.#pe),void 0)}#nn(){return this.#h.some(e=>e.live&&e.subagentCallId!==void 0&&(this.#C.has(e.subagentCallId)||this.#w.has(e.subagentCallId)))}#rn(){this.#nn()?this.#Qt():!this.#Y&&this.#X.kind===`idle`&&this.#tn()}#in(e){e.id!==this.#Pe?.id&&this.#ar(),e.updateSeq=++this.#x;let t=e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId)?-1:this.#h.findIndex(e=>e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId));t<0?this.#h.push(e):this.#h.splice(t,0,e),e.id&&this.#g.set(e.id,e)}#an(e){this.#K=!0,this.#in({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#Dn()}#on(){let e=this.#q.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#zn(e.elapsedMs)}`,n=this.#Te??0;if(this.#Ee!==void 0&&this.#Ee>0&&n>0){let e=Math.round(n/this.#Ee*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#in({kind:`turn-stats`,body:t,live:!1})}#sn(e){if(e==null)return;let t=this.#Qe;if(this.#Qe=void 0,this.#ze===e){this.#ze=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#in(n)}#cn(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#f?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#f===void 0?a:`details: ${this.#f.displayPath}`),this.#in(c),this.#Dn()}#ln(e,t){if(this.#E.has(e))return;this.#E.add(e);let n=stripTerminalControls(t),r=this.#S.get(n)??[];if(r.push(e),this.#S.set(n,r),r.length===2){let e=this.#g.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#in(i)}#un(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#x;return}this.#in(e)}#dn(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t!==void 0){Object.assign(t,e),t.updateSeq=++this.#x;return}let n=e.subagentCallId;if(n===void 0){this.#in(e);return}e.id!==this.#Pe?.id&&this.#ar(),e.updateSeq=++this.#x;let r=-1;for(let e=0;e<this.#h.length;e+=1)this.#h[e]?.subagentCallId===n&&(r=e);this.#h.splice(r<0?this.#h.length:r+1,0,e),e.id!==void 0&&this.#g.set(e.id,e)}#fn(e){this.#h=this.#h.filter(t=>t.id!==e),this.#g.delete(e)}#pn(e){let t=this.#h.filter(t=>t.subagentCallId===e);t.length!==0&&(this.#h=this.#h.filter(t=>t.subagentCallId!==e),this.#h.push(...t))}#mn(){for(let e of this.#h)e.subagentCallId!==void 0&&this.#w.has(e.subagentCallId)||e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#hn(e,t,n){switch(e.type){case`turn-start`:e.turnId!==this.#We&&(this.#We=e.turnId,this.#Ue=void 0,this.#Dn());break;case`step-start`:this.#Ue=typeof e.modelId==`string`&&stripTerminalControls(e.modelId.slice(0,256)).replace(/\s+/gu,` `).trim()||void 0,this.#Dn();break;case`step-finish`:this.#f?.recordStepUsage(e.usage),e.usage!==void 0&&this.#q.addUsage(e.usage),this.#Sn(n),this.#En(e.usage),this.#Dn();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#gn(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=typeof e.text==`string`?stripTerminalControls(e.text):t;n.text.set(e.id,r),this.#gn(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#_n(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#_n(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#vn({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#f?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#vn({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.#vn({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#Tn(e.toolCallId,n);if(r===void 0)break;this.#vn({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#Tn(e.toolCallId,n);if(this.#f?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#vn({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#Tn(e.toolCallId,n);if(r===void 0)break;this.#vn({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#cn(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:if(n.cancelled=!0,!n.restoreCancelledPrompt)break;this.#Xe=!0,!this.#$e&&this.#et!==void 0&&this.#J.text.length===0&&(this.#J=lineOf(this.#et),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#En(e.usage),this.#Dn()}}#gn(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#un({id:e,kind:`assistant`,body:r,live:n}),this.#Dn())}#_n(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#un({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#Dn())}#vn(e,t,n){if(n.tools.set(e.toolCallId,e),this.#y.has(e.toolCallId)||this.#Cn(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#b.set(e.toolCallId,r);let i=this.#yn(e);this.#un(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#wn(n),this.#Dn()}#yn(e){e.output!==void 0&&this.#T.observeRead(e.output);let t={};this.#bn(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#T.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#bn(e){let t=this.#D?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#xn(e){for(let t of e.tools.keys()){if(this.#y.has(t))continue;let e=this.#b.get(t)??toolSectionId(t),n=this.#g.get(e);n?.kind===`tool`&&n.status===`running`&&(n.status=`error`,n.result=`interrupted`,n.live=!1)}}#Sn(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#b.get(t)??toolSectionId(t);this.#fn(r),this.#b.delete(t)}}#Cn(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#Ke!==e&&(this.#Ke=e,this.#in({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#Kn(),this.#i).join(`
7
- `),live:!1})),this.#Ge=void 0}else this.#Ge=t.length>0?t:void 0,this.#Ke=void 0;return this.#Dn(),!0}#wn(e){let t=[];for(let n of e.tools.values()){if(this.#y.has(n.toolCallId))continue;let e=this.#b.get(n.toolCallId)??toolSectionId(n.toolCallId),r=this.#g.get(e);r?.kind===`tool`&&t.push({block:r,active:isActiveToolStatus(n.status)})}applyCohortLiveness(t)}#Tn(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#b.get(e)??toolSectionId(e),i=this.#g.get(r);if(i!==void 0&&i.kind===`tool`)return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.toolName??i.title??`tool`}}#En(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#we=(t??0)+(n??0)),this.#Te=t??this.#Te,this.#De=n??this.#De,this.#De!=null&&this.#ke!==void 0){let e=(Date.now()-this.#ke)/1e3;e>0&&(this.#Oe=this.#De/e)}}#Dn(){if(this.#te){if(this.#Se){this.#Ce=!0;return}this.#Se=!0;try{do this.#Ce=!1,this.#On();while(this.#Ce)}finally{this.#Se=!1}}}#On(){if(!this.#te)return;if(this.#rt!==void 0){this.#rt.repaint();return}let e=this.#Kn(),t=this.#Ln(e),n=this.#M===void 0?[]:this.#Mn(),r=Math.max(1,this.#qn()-n.length-t.length),i=[],a=this.#I,o=groupToolBlocksForDisplay(this.#h),s=0;for(;s<o.length&&o[s].display.live===!1;)s+=1;if(s>0){let e=new Set(o.slice(0,s).flatMap(e=>e.members));for(let t=this.#h.length-1;t>=0;--t)e.has(this.#h[t])&&this.#h.splice(t,1)}for(let t of o.slice(0,s)){for(let e of t.members)this.#v.push(e),e.id&&(this.#_.add(e.id),this.#g.delete(e.id));if(this.#sr(t.display))continue;let n=this.#Nn(t.display,e,a);a=previousBlockOf(t.display),this.#I=a,i.push(...n),this.#F.push(...n)}let c=[];for(let{display:t}of o.slice(s)){if(this.#sr(t))continue;let n=this.#Nn(t,e,a);a=previousBlockOf(t);for(let e=0;e<n.length;e+=1)c.push({block:t,row:n[e]})}let l=[...n,...clipLiveRows(c.map(e=>e.row),r,e,this.#i),...t];i.length>0?this.#n.flush(i,l):this.#n.update(l)}#kn(){if(!this.#te)return;let e=this.#Kn(),t=this.#Ln(e),n=Math.max(1,this.#qn()-t.length),r=this.#I,i=[];for(let{display:t}of groupToolBlocksForDisplay(this.#h)){if(this.#sr(t))continue;let n=this.#Nn(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#i),...t];this.#n.clearAll(),this.#n.flush([...this.#Mn(),...this.#F],a)}logDisplayMode(){return this.#m}setLogDisplayMode(e){e!==this.#m&&(this.#m=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#jn(),this.#te&&this.#kn())}flushDelayedDevBuildErrors(){let e=this.#Ne;e!==void 0&&(this.#Ne=void 0,this.#in({kind:`log`,title:`stderr`,body:e,live:!0}),this.#Dn())}#An(){this.#he=!0,this.#me!==void 0&&clearTimeout(this.#me),this.#me=setTimeout(()=>{this.#he=!1,this.#me=void 0,this.#Dn()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#m)),this.#Dn()}#jn(){let e=this.#Kn();this.#F.length=0;let t;for(let{display:n}of groupToolBlocksForDisplay(this.#v,{logCoalescing:`runs`})){if(this.#sr(n))continue;let r=this.#Nn(n,e,t);t=previousBlockOf(n),this.#F.push(...r)}this.#I=t}#Mn(){let e=this.#D,t=this.#M;if(e===void 0&&t===void 0)return[];let n={name:e?.name??t?.name,theme:this.#i,width:this.#Kn()};return e?.info!==void 0&&(n.info=e.info),buildAgentHeader(n)}#Nn(e,t,n){let r={renderMarkdown:this.#a,activityPulse:this.#Fn(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#i,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#Pn(){return this.#i.spinner[this.#ue%this.#i.spinner.length]??``}#Fn(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#In(e,t){return e.indicator.kind===`spinner`?{glyph:this.#Pn(),color:`yellow`}:{glyph:this.#Fn(e.indicator.startedAtMs,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#Ln(e){let t=this.#i.colors,n=[``];if(this.#Be!==void 0)return n.push(...this.#Be(e),``),this.#Un(n,e),n;let r=this.#Ve;if(r!==void 0&&(this.#k===void 0||r.question!==void 0)){let t=this.#In(r,r.status),i;if(r.status!==void 0){let{startedAtMs:e,...n}=r.status,a=Date.now()-e,o=a>=5e3?` ${formatTurnDuration(a)}`:``;i={...n,text:`${n.text}${o}`,indicator:t}}let a;if(r.question!==void 0){let t=r.question(e);a={kind:`question`,title:r.questionTitle,rows:t},i!==void 0&&(a={kind:`question`,title:r.questionTitle,rows:t,status:i})}else i===void 0?a=r.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:r.preview,indicator:t}:(a={kind:`status`,status:i},r.preview!==void 0&&(a={kind:`status`,status:i,preview:r.preview}));let o={title:r.title,navigation:r.navigation,lines:r.summary===void 0?r.hideLinesWhileQuestion===!0?[]:r.lines:[{text:r.summary.headline,tone:`success`},...r.summary.facts.map(e=>({text:`${e.label}: ${e.value}`,tone:`info`}))],content:a};return n.push(...renderFlowPanel(o,this.#i,e)),this.#Wn(n,e),n}r!==void 0&&n.push(...flowMessageRows(r.lines,this.#i).map(t=>t.length===0?``:clip(` ${t}`,e))),this.#O===void 0&&this.#He!==void 0&&n.push(...renderAttentionRows(this.#He,e,this.#i),``),this.#Ge!==void 0&&n.push(...renderTodoPanelRows({items:this.#Ge,width:e,theme:this.#i,working:this.#Y||this.#X.kind===`waiting`,pulse:this.#Fn(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)}),``);let i=renderMessageQueueRows({view:this.#qe.view(),width:e,theme:this.#i,working:this.#Y});if(i.length>0&&n.push(...i,``),this.#U){let r=this.#W===void 0?void 0:inlineCommandHint(this.#W);r===void 0&&this.#W!==void 0&&isTypeaheadOpen(this.#W)&&n.push(...renderCommandSuggestions(this.#W,this.#i,e)),this.#oe&&n.push(clip(t.dim(`Press Ctrl+C again to exit`),e),``);let i=isPromptControlCommand(this.#B),a=r?t.dim(` ${r}`):``,o=[];this.#Un(o,e);let s=Math.max(1,this.#qn()-1-n.length-1-o.length),c={text:this.#B,cursor:this.#V,width:e,theme:this.#i,caretVisible:this.#le,isCommand:i,ghost:a,maxRows:s};return this.#G&&this.#B.length===0&&(c.placeholder=this.#k===void 0?this.#K?``:`Send a message…`:`Message · Enter to queue`),n.push(...promptInputRows(c)),n.push(...o),n}let a=this.#X.kind===`waiting`&&this.#$===void 0;if(this.#Y||a){n.push(this.#Rn(e)),this.#Vn(n,e);let t=[];return this.#Un(t,e),!this.#Y&&t.length>0&&n.push(``),n.push(...t),n}if(this.#J.text.length>0)return this.#Hn(n,e,{inert:!1}),this.#Un(n,e),n;let o=this.#$??(this.#Q.length>0?this.#Q:`Ready`),s=this.#Gn(),c=t.dim(this.#i.glyph.dot),l=s?`${c} ${o} ${t.dim(this.#i.glyph.dot)} ${s}`:`${c} ${o}`;return n.push(clip(l,e)),this.#Un(n,e),n}#Rn(e){let t=this.#i.colors,n=this.#Fn(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),r=this.#X,i=this.#q.startedAtMs??this.#ke??(r.kind===`waiting`?r.startedAtMs:Date.now()),a=Date.now()-i,o=`${typewriterText(`Working for`,a,80)} ${this.#zn(a)}`;return clip(`${t.yellow(n)} ${t.dim(o)}`,e)}#zn(e){return`${formatTurnDuration(e)}${this.#Bn()}`}#Bn(){let{inputTokens:e,outputTokens:t}=this.#q.usage;return e===0&&t===0?``:` ${this.#i.glyph.dash.repeat(2)} ${formatTokenFlow({inputTokens:e,outputTokens:t},this.#i.glyph)}`}#Vn(e,t){this.#Y&&this.#Hn(e,t,{inert:!0})}#Hn(e,t,n){e.push(``);let r={text:this.#J.text,cursor:this.#J.cursor,width:t,theme:this.#i,caretVisible:!0,isCommand:!1,ghost:``,maxRows:4,inert:n.inert};n.inert&&this.#J.text.length===0&&(r.placeholder=``),e.push(...promptInputRows(r))}#Un(e,t){if(this.#O!==void 0){let n=this.#Ve?.status?.text??{starting:`Starting agent…`,connecting:`Reading saved connection…`,updating:`Loading selected model…`}[this.#O],r=this.#Fn(this.#j,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH);e.push(clip(this.#i.colors.dim(`${r} ${n}`),t));return}let n=this.#z===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#i,width:r};this.#Ie&&this.#Fe!==void 0&&(i.devBuild=this.#Fe),this.#he&&(i.logLevel=this.#m);let a=this.#D?.info?.agent.model;a?.routing.kind===`dynamic`?i.model=this.#Ue===void 0?`dynamic model`:`dynamic model · ${this.#Ue}`:a?.id!==void 0&&(i.model=a.id),a?.reasoning!==void 0&&a.reasoning!==`provider-default`&&(i.reasoning=a.reasoning),readGatewayServiceTier(a?.providerOptions).kind===`priority`&&(i.fastMode=!0);let o=a?.endpoint;o!==void 0&&(i.endpoint=o),this.#R!==void 0&&(i.vercel=this.#R),this.#z!==void 0&&(i.remote=this.#z);let s=buildStatusLine(i);s!==void 0&&e.push(clip(`${n}${s}`,t))}#Wn(e,t){if(this.#z===void 0)return;let n=Math.max(1,t-2),r=buildStatusLine({remote:this.#z,theme:this.#i,width:n});r!==void 0&&e.push(``,clip(` ${r}`,t))}#Gn(){let e=this.#i.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#we,outputTokens:this.#De,tokensPerSecond:this.#Oe},this.#u);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#i.glyph.dot} `)):``}#Kn(){return Math.max(20,this.#t.columns||80)}#qn(){return Math.max(8,this.#t.rows||24)}#Jn(){if(this.#Ae!==void 0||!this.#d)return;this.#je=``,this.#Me=``;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.#Zn(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#f?.subscribeLogRecords(e=>this.#Xn(e)),this.#Ae=()=>{this.#f?.unsubscribeLogRecords(),e(),t()}}#Yn(){let e=this.#Ae;e!==void 0&&(this.#Ae=void 0,e(),this.#je.length>0&&(this.#f?.append({source:`stdout`,detail:this.#je}),this.#or(`stdout`)&&process.stdout.write(`${this.#je}\n`),this.#je=``),this.#Me.length>0&&(this.#f?.append({source:`stderr`,detail:this.#Me}),this.#or(`stderr`)&&process.stderr.write(`${this.#Me}\n`),this.#Me=``))}#Xn(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#$n(`[eve:${e.namespace}] ${e.message}${t}`),this.#Dn()}#Zn(e,t){let n=(e===`stdout`?this.#je:this.#Me)+t;if(e===`stdout`&&parseDevRebuildLogLine(n.trimEnd())!==void 0){this.#je=``,this.#f?.append({source:e,detail:n.trimEnd()}),this.#Qn(n.trimEnd()),this.#Dn();return}let r=n.lastIndexOf(`
8
- `),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#je=i:this.#Me=i,r===-1)return;let a=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);a.trim().length!==0&&(this.#f?.append({source:e,detail:a}),e===`stdout`?this.#Qn(a):this.#$n(a),this.#Dn())}#Qn(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
9
- `);t=[],e.trim().length!==0&&this.#in({kind:`log`,title:`stdout`,body:e,live:!0})};for(let n of e.split(`
10
- `)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#in({kind:`sandbox`,body:e,live:!1});continue}let r=parseDevRebuildLogLine(n.trimEnd());if(r===void 0){t.push(n);continue}flushPending(),this.#tr(r,n.trimEnd())}flushPending()}#$n(e){let t=e.split(`
11
- `),n=t.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(n===-1){if(this.#f===void 0){this.#in({kind:`log`,title:`stderr`,body:e,live:!0});return}let t=presentDiagnostic(e,this.#f.displayPath);if(t.kind===`inline`){this.#in({kind:`log`,title:`stderr`,body:t.text,live:!0});return}this.#in({kind:`log`,title:`stderr`,body:formatStoredDiagnostic(t),logVisibility:`stderr-only`,live:!0}),this.#in({kind:`log`,title:`stderr`,body:e,logVisibility:`all-only`,live:!0});return}let r=t.slice(0,n).join(`
12
- `);r.trim().length>0&&this.#in({kind:`log`,title:`stderr`,body:r,live:!0});let i=t.slice(n).join(`
13
- `);this.#er(i)}#er(e){if(this.#rr(),this.#m===`all`){if(e.trim().length===0)return;this.#in({kind:`log`,title:`stderr`,body:e,live:!0});return}this.#Ne=e}#tr(e,t){let n=this.#ir();if(e.kind===`failed`){this.#er(t);return}if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(this.#nr({phase:`building`,summary:t}),n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#Re}`;this.#Re+=1,this.#Pe={id:r,summary:t},this.#in({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}let r=n?.state.summary??this.#Fe?.summary;if(r!==void 0&&this.#nr({phase:`complete`,summary:r}),n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind),e.kind===`rebuilt`&&(this.#Ne=void 0);return}e.kind===`rebuilt`&&(this.#Ne=void 0),this.#in({kind:`log`,title:`stdout`,body:t,live:!0})}#nr(e){this.#Le!==void 0&&clearTimeout(this.#Le),this.#Fe=e,this.#Ie=e.phase===`complete`,this.#Le=setTimeout(()=>{e.phase===`building`?(this.#Ie=!0,this.#Le=void 0):this.#rr(),this.#Dn()},e.phase===`building`?250:4e3)}#rr(){this.#Le!==void 0&&clearTimeout(this.#Le),this.#Fe=void 0,this.#Ie=!1,this.#Le=void 0}#ir(){let e=this.#Pe;if(e===void 0)return;let t=this.#g.get(e.id);if(t!==void 0&&t.live===!0)return{state:e,block:t}}#ar(){let e=this.#Pe;if(e===void 0)return;this.#Pe=void 0;let t=this.#g.get(e.id);t!==void 0&&(t.live=!1)}#or(e){switch(this.#m){case`none`:return!1;case`stderr`:return e===`stderr`;case`sandbox`:return e===`sandbox`;case`all`:return!0}}#sr(e){return e.kind===`sandbox`?!this.#or(`sandbox`):e.kind===`log`?e.logVisibility===`stderr-only`?this.#m!==`stderr`:e.logVisibility===`all-only`?this.#m!==`all`:!this.#or(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 clipVisible(e,t)}function promptInputRows({text:e,cursor:t,width:n,theme:r,caretVisible:i,isCommand:a,ghost:o,maxRows:s,placeholder:c,inert:l}){let u=r.colors;if(e.length===0&&c!==void 0){let e=renderInputWithBlockCursor({...visibleLine({text:c,cursor:0},Math.max(1,n-3),r.glyph.ellipsis),visible:i,inverse:u.inverse,render:e=>u.dim(renderInputText(e))});return[clip(`${r.glyph.prompt} ${e}`,n),``]}let style=e=>{let t=renderInputText(e);return a&&t.length>0?u.blue(t):t},d=layoutPromptInput({text:e,cursor:t}),f=Math.min(Math.max(1,s),d.rows.length),p=Math.max(0,Math.min(d.caretRow-f+1,d.rows.length-f)),m=l===!0?u.dim(r.glyph.prompt):u.cyan(r.glyph.prompt),h=u.dim(r.glyph.ellipsis),g=Math.max(1,n-3),_=[];for(let e=p;e<p+f;e+=1){let t=d.rows[e],a=e===0?m:` `;(e===p&&p>0||e===p+f-1&&p+f<d.rows.length)&&(a=h);let s;if(e===d.caretRow){let{before:e,under:n,after:a}=visibleLine({text:t.text,cursor:d.caretOffset},g,r.glyph.ellipsis);s=renderInputWithBlockCursor({before:e,under:n,after:a,visible:i,inverse:u.inverse,render:style}),o.length>0&&d.rows.length===1&&(s+=o)}else s=style(t.text);_.push(clip(`${a} ${s}`,n))}return _.push(``),_}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function isActiveToolStatus(e){return e===`running`||e===`approval`}function applyCohortLiveness(e){let t=e.some(e=>e.active);for(let n of e)n.block.live=t||n.active}function leadsWithGap(e,t){if(e.kind===`tool`&&(t?.kind===`user`||t?.kind===`assistant`||t?.kind===`question`))return!0;if(e.kind===`sandbox`&&t?.kind===`sandbox`)return!1;if(t?.kind===`sandbox`&&e.kind!==`sandbox`||t?.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`sandbox`:case`log`:case`command`:case`warning`:case`flow`:case`turn-stats`:case`session-boundary`:case`todo-list`:case`agent-header`:return!0;default:return!1}}function parseSandboxLogLine(e){let t=e.trim();if(!t.startsWith(`eve: `))return;let n=t.slice(5);return/\bsandbox\b/i.test(n)&&!isLowValueSandboxLogLine(n)?n:void 0}function isLowValueSandboxLogLine(e){return/^initializing (?:\d+ )?sandbox templates?\b/i.test(e)||/^initialized \d+ sandbox\b/i.test(e)||/^reused cached sandbox template\b/i.test(e)||/^sandbox template "[^"]+" \([^)]+\): (checking|reusing|loading microsandbox runtime|microsandbox runtime ready)\b/i.test(e)}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(e,t,n,r){let i=e.preparing===!0?presentPreparingTool(e.toolName,r):presentTool(e.toolName,e.input,r),a={id:t,kind:`tool`,title:stripTerminalControls(i.title),subtitle:stripTerminalControls(i.subtitle),status:e.status,live:e.status===`running`||e.status===`approval`,expanded:n,toolInput:e.input,toolName:e.toolName,toolGroup:i.group};return i.doneTitle!==void 0&&(a.doneTitle=stripTerminalControls(i.doneTitle)),i.detail!==void 0&&(a.detailLines=i.detail,a.keepDetailWhenDone=i.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(a.result=stripTerminalControls(e.errorText)):(a.result=i.summarizeResult(e.output),a.toolOutput=e.output),a}function writeExistedFlag(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e.existed;return typeof t==`boolean`?t:void 0}function subagentToolStatus(e){switch(e){case`preparing`:return`running`;case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`;case`rejected`:return`denied`}}function formatToolApprovalTitle(e){return stripTerminalControls(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 connectionAuthTerminalMessage(e){switch(e){case`authorized`:return`Authorization complete`;case`declined`:return`Authorization declined`;case`failed`:return`Authorization failed`;case`timed-out`:return`Authorization timed out`;case`required`:case`pending`:return}}function formatConnectionAuthContent(e,t){let n=[];if(t!==void 0)n.push(t);else{let t=stripTerminalControls(e.description);t.length>0&&n.push(t);let r=e.challenge;r?.url&&n.push(`URL: ${stripTerminalControls(r.url)}`),r?.userCode&&n.push(`Code: ${stripTerminalControls(r.userCode)}`),r?.expiresAt&&n.push(`Expires: ${stripTerminalControls(r.expiresAt)}`),r?.instructions&&n.push(stripTerminalControls(r.instructions))}if(e.reason!==void 0){let t=stripTerminalControls(e.reason);t.length>0&&n.push(`Reason: ${t}`)}return n.join(`
4
+ `),n=stripPromptControlCharacters(e?.initialDraft??this.#X.text),r=t===void 0?n:n.length===0?t:`${t}\n\n${n}`,i=lineOf(r);return this.#X=EMPTY_LINE,this.#H.begin(i.text),this.#ct(i),this.#G=typeaheadFor(this.#p,i.text),this.#Qt(),this.#An(),await new Promise((e,t)=>{this.#$=t;let apply=e=>{i=e,this.#en(),this.#ct(i),this.#G=typeaheadFor(this.#p,e.text,this.#G),this.#An()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#G=void 0,this.#$t(),this.#Vt(),t(interruptedError())},suggestions=()=>this.#G!==void 0&&isTypeaheadOpen(this.#G)?this.#G:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#ve=t=>{t.type!==`ctrl-c`&&this.#ce&&(this.#ce=!1,this.#An());let n=this.#U.apply(i,t,{multiline:!0});if(n!==void 0){apply(n);return}switch(t.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#G=moveTypeaheadSelection(e,-1),this.#An();break}let t=movePromptLine(i,`up`);t===void 0?recall(this.#H.previous(i.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#G=moveTypeaheadSelection(e,1),this.#An();break}let t=movePromptLine(i,`down`);t===void 0?recall(this.#H.next()):apply(t);break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#G=dismissTypeahead(e),this.#An());break}case`enter`:{let t=highlighted(),n=t!==void 0&&parsePromptCommand(i.text)===null?typeaheadCompletion(t).trimEnd():i.text;if(n.trim().length===0)break;this.#G=void 0,this.#H.add(n),this.#W=!1,this.#$t(),this.#ee=STATUS.processing,isPromptControlCommand(n)?this.#sn({kind:`command`,body:stripTerminalControls(n.trim()),live:!1}):(this.#nn(),this.#cn(n),this.#Ve=n,this.#J.arm()),this.#ct(EMPTY_LINE),this.#An(),this.#Ut(),e(n);break}case`ctrl-d`:i.text.length===0?(this.#Ft(),interrupt()):apply(deleteForward(i));break;case`ctrl-l`:this.#Nn();break;case`ctrl-r`:this.#An();break;case`ctrl-c`:if(this.#ce){this.#Ft(),interrupt();break}this.#ce=!0,apply(EMPTY_LINE)}},this.#Ht()})}#ct(e){this.#B=e.text,this.#V=e.cursor}takeQueuedPrompt(){let e=this.#Ye.view().steering,t=this.#Ye.takePrompt();return t!==void 0&&(this.#et=e?`steer`:`queue`),t}async renderStream(e,t){this.#zt(t),this.#_.clear(),this.#W=!1,this.#Q.kind!==`waiting`&&(this.#Q={kind:`waiting`,startedAtMs:Date.now()}),this.#ee=this.#L>0?STATUS.connectionAuth:STATUS.processing,this.#un(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#f?.recordPrompt(),t?.submittedPrompt!==void 0&&!this.#J.armed&&this.#J.arm(),this.#oe=!1,this.#Qe=!1,this.#tt=!1,this.#nt=t?.submittedPrompt,this.#Ye.beginTurn(),this.#Xe=e.cancel,this.#Ze=e.steer,this.#Ee=void 0,this.#De=void 0,this.#ke=void 0,this.#Ae=void 0,this.#je=Date.now();let n={text:new Map,reasoning:new Map,tools:new Map,modelActivity:`Thinking`,runningTools:new Set,cancelled:!1,restoreCancelledPrompt:!0};this.#Y=n;let r={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u};this.#tn(),this.#Z=!0,this.#An();let i=new Promise(e=>{this.#Ce=e});this.#ve=e=>this.#Xt(e),this.#Ht();try{for await(let t of takeUntil(iterateTUIStream(e.events),i)){if(this.#oe)break;this.#vn(t,r,n)}}catch(e){let t=summarizeKnownError(e);t===null?this.#dn(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#dn(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#Ce=void 0,this.#oe&&e.abort?.(),this.#Xe=void 0,this.#Ze=void 0,this.#Ut(),this.#Z=!1,this.#Y=void 0,this.#Q.kind===`waiting`&&(this.#Q={kind:`idle`}),this.#on(),this.#ee=completedTurnStatus({interrupted:this.#oe,cancelled:this.#Qe,continueSession:t?.continueSession===!0}),this.#Tn(n),(this.#oe||n.cancelled)&&this.#wn(n),this.#_n(),this.#on(),this.#f?.reportStats(),this.#An(),t?.continueSession||this.#Vt()}}async renderIdleStream(e,t){let n={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u},r={text:new Map,reasoning:new Map,tools:new Map,modelActivity:`Thinking`,runningTools:new Set,cancelled:!1,restoreCancelledPrompt:!1};try{for await(let t of iterateTUIStream(e.events))this.#vn(t,n,r)}catch(e){let t=summarizeKnownError(e);t===null?this.#dn(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#dn(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#Tn(r),r.cancelled&&this.#wn(r),this.#_n(),this.#on(),this.#f?.reportStats(),this.#An()}}async readToolApproval(e,t){return this.#zt(t),this.#rn(),this.#W=!1,this.#Q={kind:`idle`},this.#ee=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#oe=!1,this.#An(),await new Promise((t,n)=>{this.#$=n,this.#ve=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#nn(),this.#ee=STATUS.processing,this.#Ut(),this.#An(),t({approved:!0})):n===`n`&&(this.#nn(),this.#ee=STATUS.processing,this.#ut(e.toolCallId),this.#Ut(),this.#An(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#An();break;case`ctrl-c`:this.#oe=!0,this.#Vt(),n(interruptedError())}},this.#Ht()})}async readInputQuestion(e,t){this.#zt(t),this.#rn(),this.#W=!1,this.#K=!1,this.#Q={kind:`idle`},this.#oe=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`overlay`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,overlayPanel=t=>renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#de},this.#i,t),renderTextSection=()=>{this.#pn({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,void 0,this.#i),preformatted:!0,live:!0})},syncFreeformCaret=()=>{isOnFreeformRow()?this.#Qt():(this.#$t(),this.#en())};s===`overlay`?(s=`overlay`,this.#W=!1,this.#hn(o),this.#He=overlayPanel,this.#ee=``,syncFreeformCaret(),this.#An()):(s=`text`,this.#He=void 0,renderTextSection(),this.#W=!0,this.#ct(l),this.#ee=``,this.#Qt(),this.#An());let finalize=t=>{this.#He=void 0,this.#pn({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#W=!1,this.#nn(),this.#ee=STATUS.processing,this.#$t(),this.#Ut(),this.#An();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#He=void 0,this.#pn({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Dismissed.`)}`,preformatted:!0,live:!1}),this.#W=!1,this.#ee=``,this.#$t(),this.#Ut(),this.#An(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#An())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,r)=>{this.#$=r,u=t,this.#ve=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#en(),s===`text`&&this.#ct(l),this.#An();return}this.#oe=!0,this.#He=void 0,this.#$t(),this.#Vt(),r(interruptedError());return}if(t.type===`ctrl-r`){this.#An();return}if(s===`overlay`){let r=setupSelectionIntent(t,{textNavigation:!isOnFreeformRow()});if(r?.kind===`move`){moveCursor(r.direction===`up`?-1:1);return}switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#en(),this.#An();break}dismiss();break;default:if(isOnFreeformRow()){let e=this.#U.apply(l,t);e!==void 0&&(l=e,this.#en(),this.#An());break}if(t.type===`text`&&/^[1-9]$/u.test(t.value)){let e=Number(t.value)-1;e<n.length?selectOptionAt(e):e===n.length&&i&&(c=e,syncFreeformCaret(),this.#An())}}return}let a=this.#U.apply(l,t,{multiline:!0});if(a!==void 0){l=a,this.#en(),this.#ct(l),this.#An();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#en(),this.#ct(l),this.#An());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#en(),this.#ct(l),this.#An();break}dismiss()}},this.#Ht()})}upsertSubagentStep(e){if(this.#f?.recordSubagentDispatch(e.callId),this.#c===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(t.length!==0||n.length!==0){if(this.#fn(e.callId,e.subagentName),this.#c===`collapsed`){this.#An();return}this.#mn({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,subagentCallId:e.callId,depth:1,reasoning:t,body:n,collapsed:this.#c!==`full`,live:!e.finalized}),this.#An()}}upsertSubagentTool(e){if(this.#f?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#f?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#c===`hidden`)return;if(this.#fn(e.callId,e.subagentName),this.#c===`collapsed`){this.#An();return}let t=subagentToolStatus(e.status),n=e.status===`preparing`?presentPreparingTool(e.toolName):presentTool(e.toolName,e.input,this.#Sn({input:e.input,output:e.output,toolCallId:e.childCallId,toolName:e.toolName})),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,subagentCallId:e.callId,depth:1,title:stripTerminalControls(n.title),subtitle:stripTerminalControls(n.subtitle),status:t,live:t===`running`||t===`approval`,expanded:this.#c===`full`,toolName:e.toolName,toolGroup:n.group,toolInput:e.input};n.doneTitle!==void 0&&(r.doneTitle=stripTerminalControls(n.doneTitle)),n.detail!==void 0&&(r.detailLines=n.detail,r.keepDetailWhenDone=n.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=n.summarizeResult(e.output),r.toolOutput=e.output),this.#mn(r),this.#lt(e.callId),this.#An()}#lt(e){applyCohortLiveness(this.#h.filter(t=>t.kind===`subagent-tool`&&t.subagentCallId===e).map(e=>({block:e,active:isActiveToolStatus(e.status)})))}removeSubagentTool(e){this.#hn(subagentToolSectionId(e.callId,e.childCallId)),this.#An()}subagents={begin:e=>this.beginSubagent(e),background:e=>this.backgroundSubagent(e),upsertStep:e=>this.upsertSubagentStep(e),upsertTool:e=>this.upsertSubagentTool(e),removeTool:e=>this.removeSubagentTool(e),complete:e=>this.completeSubagent(e),markChildToolCallId:e=>this.markChildToolCallId(e)};beginSubagent(e){if(this.#c===`hidden`)return;this.#fn(e.callId,e.name);let t=this.#g.get(subagentHeaderId(e.callId));t!==void 0&&(t.status===`done`&&delete t.status,t.live=!0),this.#w.delete(e.callId),this.#An()}backgroundSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t===void 0||this.#_.has(subagentHeaderId(e.callId)))return;t.status=`running`,t.live=!0,t.updateSeq=++this.#x;let n=this.#C.has(e.callId);this.#C.add(e.callId),n||this.#gn(e.callId),this.#on(),this.#An()}completeSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t!==void 0){if(t.status=`done`,e.authoritative){this.#C.delete(e.callId),this.#w.delete(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!1)}else{this.#w.add(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!0)}this.#on(),this.#An()}}markChildToolCallId(e){this.#y.add(e);let t=this.#b.get(e);t!==void 0&&(this.#hn(t),this.#b.delete(e),this.#An())}#ut(e){let t=this.#g.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#l===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#pn({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e,t),preformatted:!0,live:t===void 0}),this.#An()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#L)return;let n=this.#L>0;this.#L=t,t>0?(this.#ee=STATUS.connectionAuth,this.#An()):n&&(this.#ee=STATUS.processing,this.#An())}setVercelStatus(e){this.#R=e,this.#An()}setRemoteConnectionStatus(e){this.#z=e,this.#An()}reset(){this.#h=[],this.#g.clear(),this.#_.clear(),this.#I=void 0,this.#F.length=0,this.#v.length=0,this.#N=!1,this.#P=void 0,this.#dt(),this.#q=!1,this.#Ve=void 0,this.#Ie=void 0,this.#L=0,this.#Ee=void 0,this.#De=void 0,this.#ke=void 0,this.#Ae=void 0,this.#je=void 0,this.#re&&(this.#n.clearAll(),this.#An())}renderSessionBoundary(){this.#ln(),this.#dt();let e=this.#i.colors,t=this.#i.glyph,n=e.dim(`${t.cornerOpen}${t.dash.repeat(2)} Session restarted, clear context.`);this.#sn({kind:`session-boundary`,body:n,live:!1}),this.#An()}#dt(){this.#Ge=void 0,this.#Ke=void 0,this.#y.clear(),this.#b.clear(),this.#E.clear(),this.#C.clear(),this.#w.clear(),this.#S.clear(),this.#qe=void 0,this.#Je=void 0,this.#Ye.reset(),this.#et=void 0,this.#T.clear(),this.#J.reset(),this.#on()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#zt(),this.#sn({kind:`notice`,body:t,live:!1}),this.#An())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#f?.append({source:`sandbox`,detail:t}),this.#zt(),this.#sn({kind:`sandbox`,body:t,live:!1}),this.#An())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#ft();return}this.#zt(),this.#We=t,this.#An()}clearSetupWarning(){this.#ft()}#ft(){this.#We!==void 0&&(this.#We=void 0,this.#An())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#zt();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#sn(r),this.#An()}renderCommandResult(e,t){let n=stripAnsi(e);n.trim().length!==0&&(this.#zt(),this.#sn({kind:`result`,body:n,live:!1,status:t===`success`?`done`:void 0}),this.#An())}#pt(e,t=`spinner`){this.#zt(),this.#k===void 0&&(this.#W=!1),this.#Q={kind:`idle`},this.#ee=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#Ue={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#tn(),this.#An()}#mt(e){this.#Ue!==void 0&&(this.#Ue.navigation=e,this.#An())}#ht(e){this.#rt=void 0,this.#kt();let t=this.#Ue;if(t!==void 0){if(this.#Ue=void 0,this.#k===void 0?this.#rn():this.#st(),e){let e=[];for(let n of t.lines){if(n.evidence===!0){e.push(n.text);continue}(n.tone===`warning`||n.tone===`error`)&&(e.length>0&&this.#sn({kind:`flow`,title:`info`,body:e.join(`
5
+ `),live:!1}),this.#sn({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#An()}}async#gt(e){let t=this.#Ct(e.message),n=isMultiSelectRequest(e),r=e.kind===`search`?e.searchAction:void 0,i=e.options,a=e.navigation?.kind===`planner`,o={options:i,searchAction:r,submitRow:n&&!a};`initialValue`in e&&e.initialValue!==void 0&&(o.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(o.initialValues=e.initialValues);let s=initialSelectState(o),c,l=!1,u=0,isCurrentSearch=e=>e===u,clearSearch=()=>{u+=1,l=!1,s=reduceSelect(s,{type:`clear`},{options:i,searchAction:r,submitRow:n&&!a}),this.#An()},loadSearch=async(e,t)=>{l=!0,c=void 0;let o=++u;this.#An();try{let c=await t(e);if(!isCurrentSearch(o))return;let l=s.filter;i=c,s={...initialSelectState({options:c,searchAction:r,submitRow:n&&!a}),filter:l}}catch(e){isCurrentSearch(o)&&(c=toErrorMessage(e))}finally{isCurrentSearch(o)&&(l=!1,this.#An())}},d=e.notices;if(e.kind===`task-list`||e.kind===`search`&&e.layout===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));d=e.notices??r,t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,message:``,options:i,select:s};return d!==void 0&&d.length>0&&(t.notices=d),c!==void 0&&(t.error=c),l&&(t.loadingFrame=this.#Ln()),t};return t.question=e=>renderSelectQuestion(panelState(),this.#i,e),this.#An(),await this.#Et((t,o)=>{let close=e=>{u+=1,o(e)};if(l){t.type===`ctrl-c`?close(void 0):t.type===`escape`?clearSearch():t.type===`ctrl-r`&&this.#An();return}let d=e.navigation?.kind===`planner`?e.navigation:void 0,f=t.type===`left`&&(d?.activeStep??0)>(d?.firstNavigableStep??0)?`back`:t.type===`right`&&d!==void 0&&d.activeStep>=(d.firstNavigableStep??0)&&d.activeStep<d.steps.length-1?`forward`:void 0;if(f!==void 0){close({kind:`navigate`,direction:f,values:n?orderedSelection(i,s.selected):[]});return}let p={key:t,options:i,searchAction:r,select:s},m=reduceSetupSelectInput(n?{...p,kind:e.kind,required:e.required,plannerNavigation:a||void 0}:{...p,kind:e.kind});switch(m.kind){case`cancel`:close(void 0);return;case`repaint`:this.#An();return;case`update`:s=m.select,c=void 0,this.#An();return;case`submit`:{let e=searchActionQuery(m.values[0]??``),t=r?.load;if(e===void 0||t===void 0){close(m.values);return}loadSearch(e,t);return}case`error`:c=m.message,this.#An();return;case`ignore`:return}}).promise}#_t(e){this.#zt();let t=this.#wt();t.status={kind:`progress`,text:stripTerminalControls(e.status),startedAtMs:Date.now()};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#i,t),this.#An();let r=this.#Et((t,r)=>{let i=setupSelectionIntent(t,{textNavigation:!0});switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#An();return;case`repaint`:this.#An();return;case`submit`:n!==void 0&&r(e.actions[n].value);return;case void 0:return}},()=>{t.status=void 0});return{choice:r.promise,close:()=>r.settle(void 0)}}async#vt(e){let t=this.#Ct(e.message),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`inline-edit`,layout:`task-list`,message:``,options:e.options,select:r,edit:{optionValue:e.editable.value,caretVisible:this.#de,editor:{kind:`rename`,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint}}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#i,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?this.#Qt():(i=lineOf(``),this.#$t())};return syncEditableRow(),this.#An(),await this.#Et((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#en(),this.#An()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#An()},submit=()=>{let t=selectValueAtCursor([...e.options],r.cursor);if(t===void 0)return;if(t!==e.editable.value){n({kind:`selected`,value:t});return}let o=(i.text||e.editable.defaultValue).trim(),s=e.editable.validate?.(o);if(s!==void 0){a=s,this.#An();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t,{textNavigation:!onEditableRow()});switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#An();return;case void 0:}if(!onEditableRow())return;let s=this.#U.apply(i,t);s!==void 0&&applyEditor(s)},()=>this.#$t()).promise}async#yt(e){this.#U.clear();let t=this.#Ct(e.message),n=initialProviderPickerState(e.options,e.initialValue),r,cursorBadge=()=>{if(n.phase.kind!==`inactive`)return;let t=selectValueAtCursor([...e.options],n.select.cursor),r=e.options.find(e=>e.value===t);if(r!==void 0)return enterBadge(this.#i,r.checked===!0?`change`:void 0)};t.question=t=>{let r=cursorBadge(),i={kind:`inline-edit`,layout:`stacked`,message:``,options:e.options,select:n.select,edit:{optionValue:`ai-gateway-key`,caretVisible:this.#de,editor:{kind:`key`,phase:n.phase}}};return r!==void 0&&(i.cursorBadge=r),renderSelectQuestion(i,this.#i,t)};let syncCaret=()=>{n.phase.kind===`editing`||n.phase.kind===`invalid`?this.#Qt():this.#$t()};return syncCaret(),this.#An(),await this.#Et((t,i,a)=>{let dispatch=t=>{let o=transitionProviderPicker(n,t,e.options);switch(o.kind){case`ignore`:return;case`clear`:r?.abort(),r=void 0,n=o.state,syncCaret(),this.#An();return;case`cancel`:i(void 0);return;case`render`:n=o.state,syncCaret(),this.#An();return;case`validate`:{n=o.state,syncCaret(),this.#An();let t=new AbortController;r=t;let i;try{i=e.validateInlineKey(o.key,t.signal)}catch(e){a(e);return}i.then(e=>{r!==t||t.signal.aborted||(r=void 0,dispatch({type:`validated`,validation:e}))},e=>{r!==t||t.signal.aborted||(r=void 0,a(e))});return}case`settle`:i(o.result);return}},o=setupSelectionIntent(t,{textNavigation:n.phase.kind===`inactive`});switch(o?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:o.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#An();return;case void 0:}if(n.phase.kind!==`editing`&&n.phase.kind!==`invalid`)return;let s=applyLineEditorKey(n.phase.editor,t);s!==void 0&&(this.#en(),dispatch({type:`edit`,editor:s}))},()=>{r?.abort(),r=void 0,this.#$t()}).promise}async#bt(e){let t=initialModelPickerState(e),n=this.#Ct(modelPickerTitle(t));return n.question=n=>renderModelPicker(e,t,this.#i,n),this.#An(),await this.#Et((r,i)=>{let dispatch=r=>{let a=transitionModelPicker(t,r,e);switch(a.kind){case`render`:if(t===a.state)return;t=a.state,n.questionTitle=modelPickerTitle(t),this.#An();return;case`cancel`:i(void 0);return;case`settle`:i(a.result);return}};if(r.type===`ctrl-c`){dispatch({type:`cancel`});return}if(r.type===`escape`||r.type===`left`){dispatch({type:`back`});return}let a=setupSelectionIntent(r);switch(a?.kind){case`move`:dispatch({type:a.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#An();return}if(r.type===`backspace`){dispatch({type:`backspace`});return}if(r.type===`alt-backspace`){dispatch({type:`delete-word-backward`});return}if(r.type===`text`)for(let e of r.value.replaceAll(`
6
+ `,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#xt(e){e.mask===!0&&this.#U.clear();let t=this.#Ct(e.message),n=lineOf(``),r;return t.question=t=>{let i={message:``,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#de)},this.#Qt(),this.#An(),await this.#Et((t,i)=>{let apply=e=>{n=e,r=void 0,this.#en(),this.#An()},a=e.mask?applyLineEditorKey(n,t):this.#U.apply(n,t);if(a!==void 0){apply(a);return}switch(t.type){case`ctrl-c`:case`escape`:i(void 0);return;case`ctrl-r`:this.#An();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#An();return}i(t);return}default:return}},()=>this.#$t()).promise}async#St(e){let t=this.#Ct(e.message);return t.question=t=>renderAcknowledgeQuestion({message:``,lines:e.lines},this.#i,t),this.#An(),await this.#Et((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#An();return;default:return}}).promise}#Ct(e){this.#zt(),this.#W=!1,this.#Q={kind:`idle`},this.#ee=``;let t=this.#wt();return t.questionTitle=stripTerminalControls(e),t.status!==void 0&&(t.status=void 0,t.summary=void 0,t.preview=void 0),t}#wt(){return this.#Ue===void 0&&(this.#Ue={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#Ue}#Tt(){this.#Ue?.implicit===!0?this.#Ue=void 0:this.#Ue!==void 0&&(this.#Ue.question=void 0,this.#Ue.questionTitle=void 0,this.#Ue.hideLinesWhileQuestion=!1),this.#ve=void 0,this.#Ut(),this.#k===void 0?this.#Ue!==void 0&&this.#Ot():this.#st(),this.#Ue===void 0&&this.#An()}#Et(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#Tt(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#Tt(),i(e))};return this.#Yt(),this.#ve=t=>{t.type===`ctrl-c`&&this.#Ft(),e(t,settle,reject)},this.#Ht(),{promise:a,settle}}#Dt(e){let t,n=new Promise(e=>{t=e});return this.#rt=t,this.#Ot(e?.interruptible??!0),{promise:n,dispose:()=>{this.#rt===t&&(this.#rt=void 0,this.#kt())}}}#Ot(e=!0){if(this.#k!==void 0){this.#st();return}if(this.#rt===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#Ft();let e=this.#rt;this.#rt=void 0,this.#kt(),e?.(t.type===`ctrl-c`?`ctrl-c`:`escape`);return}t.type===`ctrl-r`&&this.#An()};this.#it=consumer,this.#Yt(),this.#ve=consumer,this.#Ht()}#kt(){this.#it!==void 0&&(this.#ve===this.#it&&this.#Ut(),this.#it=void 0)}#At(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#Ue!==void 0){this.#Ue.status=t,t===void 0&&(this.#Ue.preview=void 0),this.#An();return}if(!(this.#W||this.#Z)){if(t===void 0){this.#Q={kind:`idle`},this.#te=void 0,this.#rn(),this.#An();return}this.#zt(),this.#nn(),this.#te=t.text,this.#An()}}#jt(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Ue;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#An();return}this.#zt(),this.#sn({kind:`flow`,title:t,body:n,live:!1}),this.#An()}#Mt(e){let t=this.#Ue;t!==void 0&&(t.lines=[],t.outputBuffer=[],t.preview=void 0,t.status=void 0,t.summary=e===void 0?void 0:{headline:stripTerminalControls(e.headline),facts:e.facts.map(e=>({label:stripTerminalControls(e.label),value:stripTerminalControls(e.value)}))},this.#An())}#Nt(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Ue;if(n===void 0){this.#jt(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#An()}async#Pt(e){this.#ye=``,this.#Yt(),this.#rt=void 0,this.#kt(),this.#Ut(),this.#in(),this.#n.clear(),this.#Qn(),this.#r.enter({cursor:`visible`,mouse:!1}),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#r.exit(),this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#ye=``,this.#Yt(),this.#n.hideCursor(),this.#Zn(),this.#Ue===void 0?this.#on():(this.#tn(),this.#Ot()),this.#n.reset(),this.#An()}}setSessionId(e){this.#$e=e}shutdown(){if(this.#Vt(),this.#ie&&!this.#ae){this.#ae=!0;let e=this.#$e===void 0?``:` ${this.#i.glyph.dot} session ${this.#$e}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}suspendPromptForInput(){this.#X={cursor:this.#V,text:this.#B},this.#Vt()}requestInterrupt(){this.#oe=!0,this.#Ue!==void 0&&this.#ve?.({type:`ctrl-c`}),this.#Ce?.(),this.#Vt()}exitRequested(){return this.#se}#Ft(){this.#se=!0,this.#ue?.()}async#It(e){if(this.#at!==void 0||!this.#re)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Yn(),height:this.#Xn()}),paint:e=>this.#r.paint(e,this.#Xn()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#ot});this.#at=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#Rt=e,this.#ve=e=>{t.handleKey(e)===`close`&&this.#Lt()},this.#Ht(),t.start()})}#Lt(){let e=this.#at;if(e===void 0)return;this.#at=void 0,e.dispose(),this.#Ut(),this.#r.exit(),this.#n.hideCursor(),this.#An(),this.#n.showCursor();let t=this.#Rt;this.#Rt=void 0,t?.()}#Rt;#zt(e){this.#ne=e?.title??this.#ne,e?.contextSize!==void 0&&(this.#Oe=e.contextSize),!this.#re&&(this.#re=!0,this.#ie=!0,this.#n.reset(),this.#n.hideCursor(),this.#Zn(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#Se=()=>this.#An(),this.#t.on(`resize`,this.#Se),process.on(`exit`,this.#Bt))}#Bt=()=>{this.#re&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#Vt(){this.#Lt();let e=this.#$;if(this.#$=void 0,e?.(interruptedError()),this.#Ut(),this.#$t(),this.#in(),this.#ge!==void 0&&(clearTimeout(this.#ge),this.#ge=void 0),this.#_e=!1,this.#or(),this.#re){this.#cr();for(let e of this.#h)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#An(),this.#n.clear(),this.#n.showCursor(),this.#Qn(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#Se&&=(this.#t.off(`resize`,this.#Se),void 0),process.off(`exit`,this.#Bt),this.#re=!1}}#Ht(){this.#e.off(`data`,this.#Wt),this.#e.on(`data`,this.#Wt),this.#ye.length>0&&queueMicrotask(()=>{this.#ve!==void 0&&this.#ye.length>0&&(this.#qt(),this.#Gt())})}#Ut(){this.#e.off(`data`,this.#Wt),this.#Yt(),this.#ve=void 0}#Wt=e=>{this.#Yt(),this.#ye+=this.#be.write(e),this.#qt(),this.#Gt()};#Gt(){if(this.#ye===`\x1B`){this.#xe=setTimeout(()=>{this.#ye===`\x1B`&&(this.#ye=``,this.#Kt({type:`escape`}))},30),this.#xe.unref?.();return}if(isIncompletePaste(this.#ye)){let e=this.#ye;this.#xe=setTimeout(()=>{if(this.#ye!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#ye=``,t.length>0&&this.#Kt({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#xe.unref?.();return}if(isIncompleteOsc(this.#ye)){let e=this.#ye;this.#xe=setTimeout(()=>{this.#ye===e&&(this.#ye=``)},incompletePasteFlushMs),this.#xe.unref?.()}}#Kt(e){this.#U.interruptYank(e),this.#ve?.(e)}#qt(){for(;this.#ye.length>0;){let e=nextKey(this.#ye);if(e.incomplete)return;if(this.#ye=this.#ye.slice(e.consumed),e.key!==void 0&&e.key.type!==`ignore`){if(e.key.type===`osc`){this.#Jt(e.key.value);continue}this.#Kt(e.key)}}}#Jt(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#ot=t,this.#at?.setTerminalBackground(t))}#Yt(){this.#xe&&=(clearTimeout(this.#xe),void 0)}#Xt(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#An();break;case`enter`:{let e=this.#X.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#Xe!==void 0){this.#X=EMPTY_LINE,this.#Ye.requestCancellation(),this.#tt=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#Xe(),this.#An();break}let t=this.#Ze;t!==void 0&&parsePromptCommand(e)===null?(this.#X=EMPTY_LINE,this.#Zt(e,t)):this.#Ye.enqueue(e)&&(this.#X=EMPTY_LINE),this.#An();break}case`ctrl-c`:case`escape`:if(e.type===`ctrl-c`&&this.#Ye.view().cancelling){this.#oe=!0,this.#le=!0,this.#Q={kind:`idle`},this.#ee=`Interrupted`,this.#Ce?.(),this.#An();break}if(this.#Ye.idle&&this.#Xe===void 0)break;if(this.#Ye.handleEscape()===`steer`){let e=this.#Ze;if(e!==void 0){let t=this.#Ye.takeSteering();this.#Zt(t,e)}}else this.#tt=!0,this.#Xe?.();this.#An();break;default:{let t=this.#U.apply(this.#X,e,{multiline:!0});t!==void 0&&(this.#X=t,this.#An());break}}}#Zt(e,t){this.#et=`steer`,this.#un(e),t(e).catch(t=>{this.#Ye.restoreSteering(e),this.#dn(`Steering failed`,toErrorMessage(t)),this.#An()})}#Qt(){this.#$t(),this.#en(),this.#me=setInterval(()=>{this.#de=!this.#de,this.#An()},500),this.#me.unref?.()}#$t(){this.#me&&=(clearInterval(this.#me),void 0),this.#de=!0}#en(){this.#de=!0}#tn(){this.#in(),this.#he=setInterval(()=>{this.#fe+=1,this.#An()},90),this.#he.unref?.()}#nn(){let e=Date.now();this.#pe=e,this.#Q={kind:`waiting`,startedAtMs:e},this.#tn()}#rn(){this.#an()||this.#in()}#in(){this.#he&&=(clearInterval(this.#he),void 0)}#an(){return this.#h.some(e=>e.live&&e.subagentCallId!==void 0&&(this.#C.has(e.subagentCallId)||this.#w.has(e.subagentCallId)))}#on(){this.#an()?this.#tn():!this.#Z&&this.#Q.kind===`idle`&&this.#in()}#sn(e){e.id!==this.#Ie?.id&&this.#cr(),e.updateSeq=++this.#x;let t=e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId)?-1:this.#h.findIndex(e=>e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId));t<0?this.#h.push(e):this.#h.splice(t,0,e),e.id&&this.#g.set(e.id,e)}#cn(e){this.#q=!0,this.#sn({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#An()}#ln(){let e=this.#J.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#Hn(e.elapsedMs)}`,n=this.#De??0;if(this.#Oe!==void 0&&this.#Oe>0&&n>0){let e=Math.round(n/this.#Oe*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#sn({kind:`turn-stats`,body:t,live:!1})}#un(e){if(e==null)return;let t=this.#et;if(this.#et=void 0,this.#Ve===e){this.#Ve=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#sn(n)}#dn(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#f?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#f===void 0?a:`details: ${this.#f.displayPath}`),this.#sn(c),this.#An()}#fn(e,t){if(this.#E.has(e))return;this.#E.add(e);let n=stripTerminalControls(t),r=this.#S.get(n)??[];if(r.push(e),this.#S.set(n,r),r.length===2){let e=this.#g.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#sn(i)}#pn(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#x;return}this.#sn(e)}#mn(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t!==void 0){Object.assign(t,e),t.updateSeq=++this.#x;return}let n=e.subagentCallId;if(n===void 0){this.#sn(e);return}e.id!==this.#Ie?.id&&this.#cr(),e.updateSeq=++this.#x;let r=-1;for(let e=0;e<this.#h.length;e+=1)this.#h[e]?.subagentCallId===n&&(r=e);this.#h.splice(r<0?this.#h.length:r+1,0,e),e.id!==void 0&&this.#g.set(e.id,e)}#hn(e){this.#h=this.#h.filter(t=>t.id!==e),this.#g.delete(e)}#gn(e){let t=this.#h.filter(t=>t.subagentCallId===e);t.length!==0&&(this.#h=this.#h.filter(t=>t.subagentCallId!==e),this.#h.push(...t))}#_n(){for(let e of this.#h)e.subagentCallId!==void 0&&this.#w.has(e.subagentCallId)||e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#vn(e,t,n){let r=turnActivityLabel(n);switch(updateTurnActivity(n,e),e.type){case`turn-start`:e.turnId!==this.#Ke&&(this.#Ke=e.turnId,this.#Ge=void 0,this.#An());break;case`step-start`:this.#Ge=typeof e.modelId==`string`&&stripTerminalControls(e.modelId.slice(0,256)).replace(/\s+/gu,` `).trim()||void 0,this.#An();break;case`step-finish`:this.#f?.recordStepUsage(e.usage),e.usage!==void 0&&this.#J.addUsage(e.usage),this.#Tn(n),this.#kn(e.usage),this.#An();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#yn(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=typeof e.text==`string`?stripTerminalControls(e.text):t;n.text.set(e.id,r),this.#yn(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#bn(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#bn(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#xn({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#f?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#xn({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.#xn({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#On(e.toolCallId,n);if(r===void 0)break;this.#xn({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#On(e.toolCallId,n);if(this.#f?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#xn({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#On(e.toolCallId,n);if(r===void 0)break;this.#xn({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#dn(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:if(n.cancelled=!0,!n.restoreCancelledPrompt)break;this.#Qe=!0,!this.#tt&&this.#nt!==void 0&&this.#X.text.length===0&&(this.#X=lineOf(this.#nt),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#kn(e.usage),this.#An()}n===this.#Y&&turnActivityLabel(n)!==r&&this.#An()}#yn(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#pn({id:e,kind:`assistant`,body:r,live:n}),this.#An())}#bn(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#pn({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#An())}#xn(e,t,n){if(n.tools.set(e.toolCallId,e),this.#y.has(e.toolCallId)||this.#En(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#b.set(e.toolCallId,r);let i=this.#Sn(e);this.#pn(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#Dn(n),this.#An()}#Sn(e){e.output!==void 0&&this.#T.observeRead(e.output);let t={};this.#Cn(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#T.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#Cn(e){let t=this.#D?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#wn(e){for(let t of e.tools.keys()){if(this.#y.has(t))continue;let e=this.#b.get(t)??toolSectionId(t),n=this.#g.get(e);n?.kind===`tool`&&n.status===`running`&&(n.status=`error`,n.result=`interrupted`,n.live=!1)}}#Tn(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#b.get(t)??toolSectionId(t);this.#hn(r),this.#b.delete(t)}}#En(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#Je!==e&&(this.#Je=e,this.#sn({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#Yn(),this.#i).join(`
7
+ `),live:!1})),this.#qe=void 0}else this.#qe=t.length>0?t:void 0,this.#Je=void 0;return this.#An(),!0}#Dn(e){let t=[];for(let n of e.tools.values()){if(this.#y.has(n.toolCallId))continue;let e=this.#b.get(n.toolCallId)??toolSectionId(n.toolCallId),r=this.#g.get(e);r?.kind===`tool`&&t.push({block:r,active:isActiveToolStatus(n.status)})}applyCohortLiveness(t)}#On(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#b.get(e)??toolSectionId(e),i=this.#g.get(r);if(i!==void 0&&i.kind===`tool`)return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.toolName??i.title??`tool`}}#kn(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#Ee=(t??0)+(n??0)),this.#De=t??this.#De,this.#ke=n??this.#ke,this.#ke!=null&&this.#je!==void 0){let e=(Date.now()-this.#je)/1e3;e>0&&(this.#Ae=this.#ke/e)}}#An(){if(this.#re){if(this.#we){this.#Te=!0;return}this.#we=!0;try{do this.#Te=!1,this.#jn();while(this.#Te)}finally{this.#we=!1}}}#jn(){if(!this.#re)return;if(this.#at!==void 0){this.#at.repaint();return}let e=this.#Yn(),t=this.#Bn(e),n=this.#M===void 0?[]:this.#Fn(),r=Math.max(1,this.#Xn()-n.length-t.length),i=[],a=this.#I,o=groupToolBlocksForDisplay(this.#h),s=0;for(;s<o.length&&o[s].display.live===!1;)s+=1;if(s>0){let e=new Set(o.slice(0,s).flatMap(e=>e.members));for(let t=this.#h.length-1;t>=0;--t)e.has(this.#h[t])&&this.#h.splice(t,1)}for(let t of o.slice(0,s)){for(let e of t.members)this.#v.push(e),e.id&&(this.#_.add(e.id),this.#g.delete(e.id));if(this.#ur(t.display))continue;let n=this.#In(t.display,e,a);a=previousBlockOf(t.display),this.#I=a,i.push(...n),this.#F.push(...n)}let c=[];for(let{display:t}of o.slice(s)){if(this.#ur(t))continue;let n=this.#In(t,e,a);a=previousBlockOf(t);for(let e=0;e<n.length;e+=1)c.push({block:t,row:n[e]})}let l=[...n,...clipLiveRows(c.map(e=>e.row),r,e,this.#i),...t];i.length>0?this.#n.flush(i,l):this.#n.update(l)}#Mn(){if(!this.#re)return;let e=this.#Yn(),t=this.#Bn(e),n=Math.max(1,this.#Xn()-t.length),r=this.#I,i=[];for(let{display:t}of groupToolBlocksForDisplay(this.#h)){if(this.#ur(t))continue;let n=this.#In(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#i),...t];this.#n.clearAll(),this.#n.flush([...this.#Fn(),...this.#F],a)}logDisplayMode(){return this.#m}setLogDisplayMode(e){e!==this.#m&&(this.#m=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#Pn(),this.#re&&this.#Mn())}flushDelayedDevBuildErrors(){let e=this.#Fe;e!==void 0&&(this.#Fe=void 0,this.#sn({kind:`log`,title:`stderr`,body:e,live:!0}),this.#An())}#Nn(){this.#_e=!0,this.#ge!==void 0&&clearTimeout(this.#ge),this.#ge=setTimeout(()=>{this.#_e=!1,this.#ge=void 0,this.#An()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#m)),this.#An()}#Pn(){let e=this.#Yn();this.#F.length=0;let t;for(let{display:n}of groupToolBlocksForDisplay(this.#v,{logCoalescing:`runs`})){if(this.#ur(n))continue;let r=this.#In(n,e,t);t=previousBlockOf(n),this.#F.push(...r)}this.#I=t}#Fn(){let e=this.#D,t=this.#M;if(e===void 0&&t===void 0)return[];let n={name:e?.name??t?.name,theme:this.#i,width:this.#Yn()};return e?.info!==void 0&&(n.info=e.info),buildAgentHeader(n)}#In(e,t,n){let r={renderMarkdown:this.#a,activityPulse:this.#Rn(this.#pe,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#i,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#Ln(){return this.#i.spinner[this.#fe%this.#i.spinner.length]??``}#Rn(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#zn(e,t){return e.indicator.kind===`spinner`?{glyph:this.#Ln(),color:`yellow`}:{glyph:this.#Rn(e.indicator.startedAtMs,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#Bn(e){let t=this.#i.colors,n=[``];if(this.#He!==void 0)return n.push(...this.#He(e),``),this.#Kn(n,e),n;let r=this.#Ue;if(r!==void 0&&(this.#k===void 0||r.question!==void 0)){let t=this.#zn(r,r.status),i;if(r.status!==void 0){let{startedAtMs:e,...n}=r.status,a=Date.now()-e,o=a>=5e3?` ${formatTurnDuration(a)}`:``;i={...n,text:`${n.text}${o}`,indicator:t}}let a;if(r.question!==void 0){let t=r.question(e);a={kind:`question`,title:r.questionTitle,rows:t},i!==void 0&&(a={kind:`question`,title:r.questionTitle,rows:t,status:i})}else i===void 0?a=r.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:r.preview,indicator:t}:(a={kind:`status`,status:i},r.preview!==void 0&&(a={kind:`status`,status:i,preview:r.preview}));let o={title:r.title,navigation:r.navigation,lines:r.summary===void 0?r.hideLinesWhileQuestion===!0?[]:r.lines:[{text:r.summary.headline,tone:`success`},...r.summary.facts.map(e=>({text:`${e.label}: ${e.value}`,tone:`info`}))],content:a};return n.push(...renderFlowPanel(o,this.#i,e)),this.#qn(n,e),n}r!==void 0&&n.push(...flowMessageRows(r.lines,this.#i).map(t=>t.length===0?``:clip(` ${t}`,e))),this.#O===void 0&&this.#We!==void 0&&n.push(...renderAttentionRows(this.#We,e,this.#i),``),this.#qe!==void 0&&n.push(...renderTodoPanelRows({items:this.#qe,width:e,theme:this.#i,working:this.#Z||this.#Q.kind===`waiting`,pulse:this.#Rn(this.#pe,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)}),``);let i=renderMessageQueueRows({view:this.#Ye.view(),width:e,theme:this.#i,working:this.#Z});if(i.length>0&&n.push(...i,``),this.#W){let r=this.#G===void 0?void 0:inlineCommandHint(this.#G);r===void 0&&this.#G!==void 0&&isTypeaheadOpen(this.#G)&&n.push(...renderCommandSuggestions(this.#G,this.#i,e)),this.#ce&&n.push(clip(t.dim(`Press Ctrl+C again to exit`),e),``);let i=isPromptControlCommand(this.#B),a=r?t.dim(` ${r}`):``,o=[];this.#Kn(o,e);let s=Math.max(1,this.#Xn()-1-n.length-1-o.length),c={text:this.#B,cursor:this.#V,width:e,theme:this.#i,caretVisible:this.#de,isCommand:i,ghost:a,maxRows:s};return this.#K&&this.#B.length===0&&(c.placeholder=this.#k===void 0?this.#q?``:`Send a message…`:`Message · Enter to queue`),n.push(...promptInputRows(c)),n.push(...o),n}let a=this.#Q.kind===`waiting`&&this.#te===void 0;if(this.#Z||a){n.push(this.#Vn(e)),this.#Wn(n,e);let t=[];return this.#Kn(t,e),!this.#Z&&t.length>0&&n.push(``),n.push(...t),n}if(this.#X.text.length>0)return this.#Gn(n,e,{inert:!1}),this.#Kn(n,e),n;let o=this.#te??(this.#ee.length>0?this.#ee:`Ready`),s=this.#Jn(),c=t.dim(this.#i.glyph.dot),l=s?`${c} ${o} ${t.dim(this.#i.glyph.dot)} ${s}`:`${c} ${o}`;return n.push(clip(l,e)),this.#Kn(n,e),n}#Vn(e){let t=this.#i.colors,n=this.#Q,r=this.#J.startedAtMs??this.#je??(n.kind===`waiting`?n.startedAtMs:Date.now()),i=Math.max(0,Date.now()-r),a=i%1e3<500?this.#i.unicode?`•`:`*`:` `,o=i<1e3?`0s`:formatTurnDuration(Math.floor(i/1e3)*1e3),s=`${turnActivityLabel(this.#Y)} (${o})`,{inputTokens:c,outputTokens:l}=this.#J.usage;return clip(`${a} ${s}${c>0||l>0?t.dim(` (${formatTokenFlow({inputTokens:c,outputTokens:l},this.#i.glyph)})`):``}`,e)}#Hn(e){return`${formatTurnDuration(e)}${this.#Un()}`}#Un(){let{inputTokens:e,outputTokens:t}=this.#J.usage;return e===0&&t===0?``:` ${this.#i.glyph.dash.repeat(2)} ${formatTokenFlow({inputTokens:e,outputTokens:t},this.#i.glyph)}`}#Wn(e,t){this.#Z&&this.#Gn(e,t,{inert:!0})}#Gn(e,t,n){e.push(``);let r={text:this.#X.text,cursor:this.#X.cursor,width:t,theme:this.#i,caretVisible:!0,isCommand:!1,ghost:``,maxRows:4,inert:n.inert};n.inert&&this.#X.text.length===0&&(r.placeholder=``),e.push(...promptInputRows(r))}#Kn(e,t){if(this.#O!==void 0){let n=this.#Ue?.status?.text??{starting:`Starting agent…`,connecting:`Reading saved connection…`,updating:`Loading selected model…`}[this.#O],r=this.#Rn(this.#j,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH);e.push(clip(this.#i.colors.dim(`${r} ${n}`),t));return}let n=this.#z===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#i,width:r};this.#Re&&this.#Le!==void 0&&(i.devBuild=this.#Le),this.#_e&&(i.logLevel=this.#m);let a=this.#D?.info?.agent.model;a?.routing.kind===`dynamic`?i.model=this.#Ge===void 0?`dynamic model`:`dynamic model · ${this.#Ge}`:a?.id!==void 0&&(i.model=a.id),a?.reasoning!==void 0&&a.reasoning!==`provider-default`&&(i.reasoning=a.reasoning),readGatewayServiceTier(a?.providerOptions).kind===`priority`&&(i.fastMode=!0);let o=a?.endpoint;o!==void 0&&(i.endpoint=o),this.#R!==void 0&&(i.vercel=this.#R),this.#z!==void 0&&(i.remote=this.#z);let s=buildStatusLine(i);s!==void 0&&e.push(clip(`${n}${s}`,t))}#qn(e,t){if(this.#z===void 0)return;let n=Math.max(1,t-2),r=buildStatusLine({remote:this.#z,theme:this.#i,width:n});r!==void 0&&e.push(``,clip(` ${r}`,t))}#Jn(){let e=this.#i.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#Ee,outputTokens:this.#ke,tokensPerSecond:this.#Ae},this.#u);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#i.glyph.dot} `)):``}#Yn(){return Math.max(20,this.#t.columns||80)}#Xn(){return Math.max(8,this.#t.rows||24)}#Zn(){if(this.#Me!==void 0||!this.#d)return;this.#Ne=``,this.#Pe=``;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.#er(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#f?.subscribeLogRecords(e=>this.#$n(e)),this.#Me=()=>{this.#f?.unsubscribeLogRecords(),e(),t()}}#Qn(){let e=this.#Me;e!==void 0&&(this.#Me=void 0,e(),this.#Ne.length>0&&(this.#f?.append({source:`stdout`,detail:this.#Ne}),this.#lr(`stdout`)&&process.stdout.write(`${this.#Ne}\n`),this.#Ne=``),this.#Pe.length>0&&(this.#f?.append({source:`stderr`,detail:this.#Pe}),this.#lr(`stderr`)&&process.stderr.write(`${this.#Pe}\n`),this.#Pe=``))}#$n(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#nr(`[eve:${e.namespace}] ${e.message}${t}`),this.#An()}#er(e,t){let n=(e===`stdout`?this.#Ne:this.#Pe)+t;if(e===`stdout`&&parseDevRebuildLogLine(n.trimEnd())!==void 0){this.#Ne=``,this.#f?.append({source:e,detail:n.trimEnd()}),this.#tr(n.trimEnd()),this.#An();return}let r=n.lastIndexOf(`
8
+ `),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#Ne=i:this.#Pe=i,r===-1)return;let a=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);a.trim().length!==0&&(this.#f?.append({source:e,detail:a}),e===`stdout`?this.#tr(a):this.#nr(a),this.#An())}#tr(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
9
+ `);t=[],e.trim().length!==0&&this.#sn({kind:`log`,title:`stdout`,body:e,live:!0})};for(let n of e.split(`
10
+ `)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#sn({kind:`sandbox`,body:e,live:!1});continue}let r=parseDevRebuildLogLine(n.trimEnd());if(r===void 0){t.push(n);continue}flushPending(),this.#ir(r,n.trimEnd())}flushPending()}#nr(e){let t=e.split(`
11
+ `),n=t.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(n===-1){if(this.#f===void 0){this.#sn({kind:`log`,title:`stderr`,body:e,live:!0});return}let t=presentDiagnostic(e,this.#f.displayPath);if(t.kind===`inline`){this.#sn({kind:`log`,title:`stderr`,body:t.text,live:!0});return}this.#sn({kind:`log`,title:`stderr`,body:formatStoredDiagnostic(t),logVisibility:`stderr-only`,live:!0}),this.#sn({kind:`log`,title:`stderr`,body:e,logVisibility:`all-only`,live:!0});return}let r=t.slice(0,n).join(`
12
+ `);r.trim().length>0&&this.#sn({kind:`log`,title:`stderr`,body:r,live:!0});let i=t.slice(n).join(`
13
+ `);this.#rr(i)}#rr(e){if(this.#or(),this.#m===`all`){if(e.trim().length===0)return;this.#sn({kind:`log`,title:`stderr`,body:e,live:!0});return}this.#Fe=e}#ir(e,t){let n=this.#sr();if(e.kind===`failed`){this.#rr(t);return}if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(this.#ar({phase:`building`,summary:t}),n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#Be}`;this.#Be+=1,this.#Ie={id:r,summary:t},this.#sn({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}let r=n?.state.summary??this.#Le?.summary;if(r!==void 0&&this.#ar({phase:`complete`,summary:r}),n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind),e.kind===`rebuilt`&&(this.#Fe=void 0);return}e.kind===`rebuilt`&&(this.#Fe=void 0),this.#sn({kind:`log`,title:`stdout`,body:t,live:!0})}#ar(e){this.#ze!==void 0&&clearTimeout(this.#ze),this.#Le=e,this.#Re=e.phase===`complete`,this.#ze=setTimeout(()=>{e.phase===`building`?(this.#Re=!0,this.#ze=void 0):this.#or(),this.#An()},e.phase===`building`?250:4e3)}#or(){this.#ze!==void 0&&clearTimeout(this.#ze),this.#Le=void 0,this.#Re=!1,this.#ze=void 0}#sr(){let e=this.#Ie;if(e===void 0)return;let t=this.#g.get(e.id);if(t!==void 0&&t.live===!0)return{state:e,block:t}}#cr(){let e=this.#Ie;if(e===void 0)return;this.#Ie=void 0;let t=this.#g.get(e.id);t!==void 0&&(t.live=!1)}#lr(e){switch(this.#m){case`none`:return!1;case`stderr`:return e===`stderr`;case`sandbox`:return e===`sandbox`;case`all`:return!0}}#ur(e){return e.kind===`sandbox`?!this.#lr(`sandbox`):e.kind===`log`?e.logVisibility===`stderr-only`?this.#m!==`stderr`:e.logVisibility===`all-only`?this.#m!==`all`:!this.#lr(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 clipVisible(e,t)}function promptInputRows({text:e,cursor:t,width:n,theme:r,caretVisible:i,isCommand:a,ghost:o,maxRows:s,placeholder:c,inert:l}){let u=r.colors;if(e.length===0&&c!==void 0){let e=renderInputWithBlockCursor({...visibleLine({text:c,cursor:0},Math.max(1,n-3),r.glyph.ellipsis),visible:i,inverse:u.inverse,render:e=>u.dim(renderInputText(e))});return[clip(`${r.glyph.prompt} ${e}`,n),``]}let style=e=>{let t=renderInputText(e);return a&&t.length>0?u.blue(t):t},d=layoutPromptInput({text:e,cursor:t}),f=Math.min(Math.max(1,s),d.rows.length),p=Math.max(0,Math.min(d.caretRow-f+1,d.rows.length-f)),m=l===!0?u.dim(r.glyph.prompt):u.cyan(r.glyph.prompt),h=u.dim(r.glyph.ellipsis),g=Math.max(1,n-3),_=[];for(let e=p;e<p+f;e+=1){let t=d.rows[e],a=e===0?m:` `;(e===p&&p>0||e===p+f-1&&p+f<d.rows.length)&&(a=h);let s;if(e===d.caretRow){let{before:e,under:n,after:a}=visibleLine({text:t.text,cursor:d.caretOffset},g,r.glyph.ellipsis);s=renderInputWithBlockCursor({before:e,under:n,after:a,visible:i,inverse:u.inverse,render:style}),o.length>0&&d.rows.length===1&&(s+=o)}else s=style(t.text);_.push(clip(`${a} ${s}`,n))}return _.push(``),_}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function isActiveToolStatus(e){return e===`running`||e===`approval`}function applyCohortLiveness(e){let t=e.some(e=>e.active);for(let n of e)n.block.live=t||n.active}function leadsWithGap(e,t){if(e.kind===`tool`&&(t?.kind===`user`||t?.kind===`assistant`||t?.kind===`question`))return!0;if(e.kind===`sandbox`&&t?.kind===`sandbox`)return!1;if(t?.kind===`sandbox`&&e.kind!==`sandbox`||t?.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`sandbox`:case`log`:case`command`:case`warning`:case`flow`:case`turn-stats`:case`session-boundary`:case`todo-list`:case`agent-header`:return!0;default:return!1}}function parseSandboxLogLine(e){let t=e.trim();if(!t.startsWith(`eve: `))return;let n=t.slice(5);return/\bsandbox\b/i.test(n)&&!isLowValueSandboxLogLine(n)?n:void 0}function isLowValueSandboxLogLine(e){return/^initializing (?:\d+ )?sandbox templates?\b/i.test(e)||/^initialized \d+ sandbox\b/i.test(e)||/^reused cached sandbox template\b/i.test(e)||/^sandbox template "[^"]+" \([^)]+\): (checking|reusing|loading microsandbox runtime|microsandbox runtime ready)\b/i.test(e)}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(e,t,n,r){let i=e.preparing===!0?presentPreparingTool(e.toolName,r):presentTool(e.toolName,e.input,r),a={id:t,kind:`tool`,title:stripTerminalControls(i.title),subtitle:stripTerminalControls(i.subtitle),status:e.status,live:e.status===`running`||e.status===`approval`,expanded:n,toolInput:e.input,toolName:e.toolName,toolGroup:i.group};return i.doneTitle!==void 0&&(a.doneTitle=stripTerminalControls(i.doneTitle)),i.detail!==void 0&&(a.detailLines=i.detail,a.keepDetailWhenDone=i.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(a.result=stripTerminalControls(e.errorText)):(a.result=i.summarizeResult(e.output),a.toolOutput=e.output),a}function writeExistedFlag(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e.existed;return typeof t==`boolean`?t:void 0}function subagentToolStatus(e){switch(e){case`preparing`:return`running`;case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`;case`rejected`:return`denied`}}function formatToolApprovalTitle(e){return stripTerminalControls(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 connectionAuthTerminalMessage(e){switch(e){case`authorized`:return`Authorization complete`;case`declined`:return`Authorization declined`;case`failed`:return`Authorization failed`;case`timed-out`:return`Authorization timed out`;case`required`:case`pending`:return}}function formatConnectionAuthContent(e,t){let n=[];if(t!==void 0)n.push(t);else{let t=stripTerminalControls(e.description);t.length>0&&n.push(t);let r=e.challenge;r?.url&&n.push(`URL: ${stripTerminalControls(r.url)}`),r?.userCode&&n.push(`Code: ${stripTerminalControls(r.userCode)}`),r?.expiresAt&&n.push(`Expires: ${stripTerminalControls(r.expiresAt)}`),r?.instructions&&n.push(stripTerminalControls(r.instructions))}if(e.reason!==void 0){let t=stripTerminalControls(e.reason);t.length>0&&n.push(`Reason: ${t}`)}return n.join(`
14
14
  `)}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=stripTerminalControls(o.label),s=o.description===void 0?``:stripTerminalControls(o.description),c=t===e,l=s.length>0?`${c?` `:` `}${r.dim(`— ${s}`)}`:``,u=c?`${n.glyph.selectedPointer} ${a}`:` ${a}`,d=renderCursorRow(u,c,r);i.push(`${d}${l}`)}if(e.allowFreeform===!0){let e=t===a.length,o=`Type your own answer`,s=e?`${n.glyph.selectedPointer} ${o}`:` ${r.dim(o)}`;i.push(renderCursorRow(s,e,r))}}else i.push(r.dim(` (type your answer)`));return i.join(`
15
15
  `)}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 +1 @@
1
- function createFakeSetupFlowRenderer(e={}){let{readProviderPicker=async()=>void 0,readModelEditor=async()=>void 0,...t}=e;return{begin:()=>{},end:()=>{},readSelect:async()=>void 0,readEditableSelect:async()=>void 0,readProviderPicker,readModelEditor,readText:async()=>void 0,readAcknowledge:async()=>{},readChoice:()=>({choice:Promise.resolve(void 0),close:()=>{}}),setStatus:()=>{},renderLine:()=>{},renderOutput:()=>{},withInheritedStdio:e=>e(),waitForInterrupt:()=>({promise:new Promise(()=>{}),dispose:()=>{}}),...t}}export{createFakeSetupFlowRenderer};
1
+ function createFakeSetupFlowRenderer(e={}){let{readProviderPicker=async()=>void 0,readModelPicker=async()=>void 0,...t}=e;return{begin:()=>{},end:()=>{},readSelect:async()=>void 0,readEditableSelect:async()=>void 0,readProviderPicker,readModelPicker,readText:async()=>void 0,readAcknowledge:async()=>{},readChoice:()=>({choice:Promise.resolve(void 0),close:()=>{}}),setStatus:()=>{},renderLine:()=>{},renderOutput:()=>{},withInheritedStdio:e=>e(),waitForInterrupt:()=>({promise:new Promise(()=>{}),dispose:()=>{}}),...t}}export{createFakeSetupFlowRenderer};
@@ -1,3 +1,3 @@
1
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(``)}ctrlN(){this.send(``)}ctrlP(){this.send(``)}},MockScreen=class extends EventEmitter{isTTY=!0;columns;rows;#e=``;#t=[];#n=0;#r=0;#i;#a=[];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.#s(r),typeof t==`function`&&t(),n?.(),this.#o(),!0}resize(e,t){this.columns=e,this.rows=t,this.emit(`resize`)}snapshot(){return this.#t.join(`
2
- `)}rawOutput(){return this.#e}async waitForIdlePrompt(e=1e3){let t=Array.from({length:11},(e,t)=>`Working for`.slice(0,t+1)),n=RegExp(`^[▪* ] (?:${t.join(`|`)}) \\d`,`mu`),idle=()=>{let e=this.snapshot();return/^[❯]/mu.test(e)&&!n.test(e)},r=Date.now()+e;for(;Date.now()<r;){if(idle())return;await new Promise(e=>setTimeout(e,25))}throw Error(`Timed out waiting for an idle prompt.\n\nScreen:\n${this.snapshot()}`)}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.#a=this.#a.filter(e=>e!==a),i(Error(`Timed out waiting for screen text: ${e}\n\nScreen:\n${n()}`))},t)};this.#a.push(a)})}#o(){let e=this.snapshot();for(let t of this.#a.slice())e.includes(t.text)&&(clearTimeout(t.timeout),this.#a=this.#a.filter(e=>e!==t),t.resolve())}#s(e){let t=0;for(;t<e.length;){if(e[t]===`\x1B`){let n=this.#c(e,t);if(n>t){t=n;continue}}let n=e[t];if(t+=1,n!==void 0){if(n===`
2
+ `)}rawOutput(){return this.#e}async waitForIdlePrompt(e=1e3){let t=/^[•* ] (?:Thinking|Generating|Running) \(\d/mu,idle=()=>{let e=this.snapshot();return/^[❯]/mu.test(e)&&!t.test(e)},n=Date.now()+e;for(;Date.now()<n;){if(idle())return;await new Promise(e=>setTimeout(e,25))}throw Error(`Timed out waiting for an idle prompt.\n\nScreen:\n${this.snapshot()}`)}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.#a=this.#a.filter(e=>e!==a),i(Error(`Timed out waiting for screen text: ${e}\n\nScreen:\n${n()}`))},t)};this.#a.push(a)})}#o(){let e=this.snapshot();for(let t of this.#a.slice())e.includes(t.text)&&(clearTimeout(t.timeout),this.#a=this.#a.filter(e=>e!==t),t.resolve())}#s(e){let t=0;for(;t<e.length;){if(e[t]===`\x1B`){let n=this.#c(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.#d(n)}}}#c(e,t){let n=e.slice(t).match(ansiControlSequencePattern);if(!n)return t;let[r,i=``,,a]=n,o=i.startsWith(`?`),s=i&&!o?i.split(`;`):[],first=e=>s[0]===void 0||s[0]===``?e:Number(s[0]);if(o)return i===`?1049`&&(a===`h`||a===`l`)&&(a===`h`?(this.#i={lines:this.#t,cursorLine:this.#n,cursorColumn:this.#r},this.#t=[],this.#n=0,this.#r=0):this.#i!==void 0&&(this.#t=this.#i.lines,this.#n=this.#i.cursorLine,this.#r=this.#i.cursorColumn,this.#i=void 0)),t+r.length;switch(a){case`H`:case`f`:this.#n=first(1)-1,this.#r=(s[1]?Number(s[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.#l(first(0));break;case`K`:this.#u(first(0))}return t+r.length}#l(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.#u(1);return}this.#u(0),this.#t.length=Math.min(this.#t.length,this.#n+1)}#u(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)}#d(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};
@@ -94,14 +94,6 @@ export interface ThemeGlyphs {
94
94
  arrowDown: string;
95
95
  /** `↯` — Fast mode (Gateway priority tier) marker beside a model id. */
96
96
  fast: string;
97
- /** `●` — a track notch below the current position (already covered). */
98
- trackFilled: string;
99
- /** `◉` — the track notch at the current position. */
100
- trackCurrent: string;
101
- /** `○` — a track notch above the current position. */
102
- trackEmpty: string;
103
- /** `─` — the connector segment between track notches. */
104
- trackLine: string;
105
97
  /** `↵` — the Enter affordance inside a selection badge. */
106
98
  enter: string;
107
99
  /** `▪` — the marker beside an in-flight validation badge. */
@@ -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:`○`,square:`▪`,corner:`└`,cornerOpen:`┌`,external:`⌝`,dotActive:`⏺`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`※`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`›`,selectedPointer:`›`,option:` `,prompt:`❯`,elbow:`⎿`,hrule:`▔`,dash:`─`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown:`↓`,fast:`↯`,trackFilled:`●`,trackCurrent:`◉`,trackEmpty:`○`,trackLine:`─`,enter:`↵`,validating:`▪`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,square:`*`,corner:"`",cornerOpen:`,`,external:`^`,dotActive:`*`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,selectedPointer:`>`,option:`.`,prompt:`>`,elbow:"`-",hrule:`=`,dash:`-`,caret:`_`,dot:`-`,ellipsis:`...`,arrowUp:`^`,arrowDown:`v`,fast:`>>`,trackFilled:`*`,trackCurrent:`O`,trackEmpty:`.`,trackLine:`-`,enter:`<-'`,validating:`o`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(e={}){let t=e.color??!0,n=e.unicode??!0;return{color:t,unicode:n,colors:{reset:ansi(0,0,t),bold:ansi(1,22,t),dim:ansi(2,22,t),inverse:ansi(7,27,t),italic:ansi(3,23,t),white:ansi(97,39,t),gray:ansi(90,39,t),cyan:ansi(36,39,t),green:ansi(32,39,t),red:ansi(31,39,t),yellow:ansi(33,39,t),magenta:ansi(35,39,t),blue:ansi(34,39,t),orange:ansi256(208,t)},glyph:n?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:n?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`)}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:`○`,square:`▪`,corner:`└`,cornerOpen:`┌`,external:`⌝`,dotActive:`⏺`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`※`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`›`,selectedPointer:`›`,option:` `,prompt:`❯`,elbow:`⎿`,hrule:`▔`,dash:`─`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown:`↓`,fast:`↯`,enter:`↵`,validating:`▪`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,square:`*`,corner:"`",cornerOpen:`,`,external:`^`,dotActive:`*`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,selectedPointer:`>`,option:`.`,prompt:`>`,elbow:"`-",hrule:`=`,dash:`-`,caret:`_`,dot:`-`,ellipsis:`...`,arrowUp:`^`,arrowDown:`v`,fast:`>>`,enter:`<-'`,validating:`o`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(e={}){let t=e.color??!0,n=e.unicode??!0;return{color:t,unicode:n,colors:{reset:ansi(0,0,t),bold:ansi(1,22,t),dim:ansi(2,22,t),inverse:ansi(7,27,t),italic:ansi(3,23,t),white:ansi(97,39,t),gray:ansi(90,39,t),cyan:ansi(36,39,t),green:ansi(32,39,t),red:ansi(31,39,t),yellow:ansi(33,39,t),magenta:ansi(35,39,t),blue:ansi(34,39,t),orange:ansi256(208,t)},glyph:n?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:n?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`)}export{createTheme,detectUnicode};
@@ -1,2 +1,2 @@
1
- import{Command,CommanderError}from"#compiled/commander/index.js";import{agentCommand}from"#cli/agent-command.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";import{waitForShutdownSignal}from"#cli/shutdown.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{findEveProjectContext,resolveEveProjectContext}from"#internal/project-context.js";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{eveCliBanner}from"#cli/banner.js";import{registerBuildCommand}from"#cli/commands/build.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{findCliApplicationRoot,resolveCliApplicationProject}from"#cli/application-root.js";import{registerIntegrationCommands}from"#cli/commands/register-integration-commands.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{registerRegistryCommands}from"#cli/commands/register-registry-commands.js";import{registerDevelopmentCommand}from"#cli/dev/command.js";import{resolveDevUiMode,resolveTuiDisplayOptions}from"#cli/dev/ui-options.js";import{registerAcpCommand}from"#cli/acp/command.js";import{registerRuntimeInvokeCommand}from"#cli/invoke/command.js";import{parseAgentNamesOption,parsePortOption,parseReasoningOption}from"#cli/option-parsers.js";import{registerEveTelemetryCommands}from"#cli/telemetry/command.js";import{canonicalCommand,createEveCliTelemetry}from"#cli/telemetry/index.js";async function loadPrintApplicationInfo(){return(await import(`#cli/commands/info.js`)).printApplicationInfo}async function loadRunEvalCommand(){return(await import(`#evals/cli/eval.js`)).runEvalCommand}async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function createCliProgram(e,t,n,r){let i=resolveInstalledPackageInfo().version,a=new Command,o=createCliTheme();a.name(`eve`).description(`Build and run an eve application.`).version(i).showHelpAfterError().exitOverride().hook(`preAction`,(t,n)=>{let{json:r}=n.opts();!r&&(n.name()===`info`||n.name()===`init`&&n.parent!==a)&&e.log(eveCliBanner())}).configureOutput({writeErr:t=>{e.error(t.trimEnd())},writeOut:t=>{e.log(t.trimEnd())}}),agentCommand(a.command(`channels`).description(`Manage user-authored channels in the current project.`).command(`list`),n).description(`List user-authored channels in the current project.`).option(`--json`,`Output as JSON`).action(async t=>{let{runChannelsListCommand:r}=await import(`#cli/commands/channels.js`);await r(e,n.project,t)}),registerEveTelemetryCommands(a,e),registerIntegrationCommands({program:a,logger:e,applicationContext:n});let s=a.command(`extension`).description(`Create and build reusable eve extension packages.`);s.command(`init [target]`).description(`Create a new eve extension package.`).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve extension init.`);let{runExtensionInitCommand:a}=await import(`#cli/commands/extension-init.js`);await a(e,n.root,t,void 0,e=>{r.trackSetupStep({flow:`extension_init`,step:e})})}),s.command(`build`).description(`Build the current package as an eve extension.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);await t(n.root);let{runExtensionBuildCommand:r}=await import(`#cli/commands/extension-build.js`);await r(e,n.root)}),registerRegistryCommands({program:a,logger:e,applicationContext:n}),a.command(`init [target]`).description(`Create a new eve agent, or add one to an existing project directory.`).option(`--channel-web-nextjs`,`Add the Web Chat application (Next.js)`).option(`--agents <names>`,`Create an agents/ workspace with comma-separated agent names`,parseAgentNamesOption).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve init.`);let{runInitCommand:a}=await import(`#cli/commands/init.js`);await a(e,n.root,t,{agents:i.agents,channelWebNextjs:i.channelWebNextjs,model:i.model,reasoning:i.reasoning},void 0,e=>{r.trackSetupStep({flow:`init`,step:e})},(e,t,n)=>{r.trackSetupTerminal({flow:`init`,step:e,result:t,failureCode:n})})}),agentCommand(a.command(`set`),n).description(`Change root agent model settings.`).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).action(async t=>{let{runSetCommand:r}=await import(`#cli/commands/set.js`);await r(e,n.root,t)}),registerProjectCommands({program:a,logger:e,applicationContext:n}),registerBuildCommand({applicationContext:n,buildHost:t.buildHost,logger:e,program:a}),agentCommand(a.command(`start`),n).description(`Start a built eve application.`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).action(async r=>{let{loadDevelopmentEnvironmentFiles:i}=await import(`#cli/dev/environment.js`);await i(n.root);let a=await(t.startProductionHost??await loadStartProductionHost())(n.root,{host:r.host,port:r.port});e.log(renderCliTaggedLine(o,{message:`server listening at ${a.url}`,tag:`start`,tone:`success`})),await waitForShutdownSignal({close:()=>a.close(),wait:()=>a.wait()})}),registerRuntimeInvokeCommand({applicationContext:n,logger:e,program:a,runtime:t}),registerAcpCommand({applicationContext:n,eveVersion:i,program:a,resolveVerifiedRemoteDevelopmentClient:t.resolveVerifiedRemoteDevelopmentClient,runAcpServer:t.runAcpServer,startHost:t.startHost}),registerDevelopmentCommand({applicationContext:n,logger:e,program:a,runtime:t,telemetry:r});let c=a.command(`logs`).description("Inspect local `eve dev` diagnostic logs (.eve/logs).");return agentCommand(c.command(`show [logid]`,{isDefault:!0}),n).description(`Print a diagnostic log (the most recent when logid is omitted).`).option(`--dump`,`Prepend the log's environment dump (.dump sibling)`).option(`--events`,`Interleave session events from the local workflow store`).action(async(t,r)=>{let{runLogsShowCommand:i}=await import(`#cli/commands/logs.js`);await i(e,n.root,t,r)}),agentCommand(c.command(`ls`),n).description(`List diagnostic logs, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runLogsListCommand:r}=await import(`#cli/commands/logs.js`);await r(e,n.root,t)}),agentCommand(a.command(`traces [trace]`),n).usage(`[options] [trace]
1
+ import{Command,CommanderError}from"#compiled/commander/index.js";import{agentCommand}from"#cli/agent-command.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";import{waitForShutdownSignal}from"#cli/shutdown.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{findEveProjectContext,resolveEveProjectContext}from"#internal/project-context.js";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{eveCliBanner}from"#cli/banner.js";import{registerBuildCommand}from"#cli/commands/build.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{findCliApplicationRoot,resolveCliApplicationProject}from"#cli/application-root.js";import{registerIntegrationCommands}from"#cli/commands/register-integration-commands.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{registerRegistryCommands}from"#cli/commands/register-registry-commands.js";import{registerDevelopmentCommand}from"#cli/dev/command.js";import{resolveDevUiMode,resolveTuiDisplayOptions}from"#cli/dev/ui-options.js";import{registerAcpCommand}from"#cli/acp/command.js";import{registerRuntimeInvokeCommand}from"#cli/invoke/command.js";import{parseAgentNamesOption,parsePortOption,parseReasoningOption}from"#cli/option-parsers.js";import{registerEveTelemetryCommands}from"#cli/telemetry/command.js";import{canonicalCommand,createEveCliTelemetry}from"#cli/telemetry/index.js";async function loadPrintApplicationInfo(){return(await import(`#cli/commands/info.js`)).printApplicationInfo}async function loadRunEvalCommand(){return(await import(`#evals/cli/eval.js`)).runEvalCommand}async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function createCliProgram(e,t,n,r){let i=resolveInstalledPackageInfo().version,a=new Command,o=createCliTheme();a.name(`eve`).description(`Build and run an eve application.`).version(i).showHelpAfterError().exitOverride().hook(`preAction`,(t,n)=>{let{json:r}=n.opts();!r&&(n.name()===`info`||n.name()===`init`&&n.parent!==a)&&e.log(eveCliBanner())}).configureOutput({writeErr:t=>{e.error(t.trimEnd())},writeOut:t=>{e.log(t.trimEnd())}}),agentCommand(a.command(`channels`).description(`Manage user-authored channels in the current project.`).command(`list`),n).description(`List user-authored channels in the current project.`).option(`--json`,`Output as JSON`).action(async t=>{let{runChannelsListCommand:r}=await import(`#cli/commands/channels.js`);await r(e,n.project,t)}),registerEveTelemetryCommands(a,e),registerIntegrationCommands({program:a,logger:e,applicationContext:n});let s=a.command(`extension`).description(`Create and build reusable eve extension packages.`);s.command(`init [target]`).description(`Create a new eve extension package.`).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve extension init.`);let{runExtensionInitCommand:a}=await import(`#cli/commands/extension-init.js`);await a(e,n.root,t,void 0,e=>{r.trackSetupStep({flow:`extension_init`,step:e})})}),s.command(`build`).description(`Build the current package as an eve extension.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);await t(n.root);let{runExtensionBuildCommand:r}=await import(`#cli/commands/extension-build.js`);await r(e,n.root)}),registerRegistryCommands({program:a,logger:e,applicationContext:n}),a.command(`init [target]`).description(`Create a new eve agent, or add one to an existing project directory.`).option(`--channel-web-nextjs`,`Add the Web Chat application (Next.js)`).option(`--agents <names>`,`Create an agents/ workspace with comma-separated agent names`,parseAgentNamesOption).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`-n, --non-interactive`,`Scaffold the agent without starting development`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve init.`);let{runInitCommand:a}=await import(`#cli/commands/init.js`);await a(e,n.root,t,{agents:i.agents,channelWebNextjs:i.channelWebNextjs,model:i.model,reasoning:i.reasoning,nonInteractive:i.nonInteractive},void 0,e=>{r.trackSetupStep({flow:`init`,step:e})},(e,t,n)=>{r.trackSetupTerminal({flow:`init`,step:e,result:t,failureCode:n})})}),agentCommand(a.command(`set`),n).description(`Change root agent model settings.`).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).action(async t=>{let{runSetCommand:r}=await import(`#cli/commands/set.js`);await r(e,n.root,t)}),registerProjectCommands({program:a,logger:e,applicationContext:n}),registerBuildCommand({applicationContext:n,buildHost:t.buildHost,logger:e,program:a}),agentCommand(a.command(`start`),n).description(`Start a built eve application.`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).action(async r=>{let{loadDevelopmentEnvironmentFiles:i}=await import(`#cli/dev/environment.js`);await i(n.root);let a=await(t.startProductionHost??await loadStartProductionHost())(n.root,{host:r.host,port:r.port});e.log(renderCliTaggedLine(o,{message:`server listening at ${a.url}`,tag:`start`,tone:`success`})),await waitForShutdownSignal({close:()=>a.close(),wait:()=>a.wait()})}),registerRuntimeInvokeCommand({applicationContext:n,logger:e,program:a,runtime:t}),registerAcpCommand({applicationContext:n,eveVersion:i,program:a,resolveVerifiedRemoteDevelopmentClient:t.resolveVerifiedRemoteDevelopmentClient,runAcpServer:t.runAcpServer,startHost:t.startHost}),registerDevelopmentCommand({applicationContext:n,logger:e,program:a,runtime:t,telemetry:r});let c=a.command(`logs`).description("Inspect local `eve dev` diagnostic logs (.eve/logs).");return agentCommand(c.command(`show [logid]`,{isDefault:!0}),n).description(`Print a diagnostic log (the most recent when logid is omitted).`).option(`--dump`,`Prepend the log's environment dump (.dump sibling)`).option(`--events`,`Interleave session events from the local workflow store`).action(async(t,r)=>{let{runLogsShowCommand:i}=await import(`#cli/commands/logs.js`);await i(e,n.root,t,r)}),agentCommand(c.command(`ls`),n).description(`List diagnostic logs, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runLogsListCommand:r}=await import(`#cli/commands/logs.js`);await r(e,n.root,t)}),agentCommand(a.command(`traces [trace]`),n).usage(`[options] [trace]
2
2
  eve traces ls [options]`).description("Show a local `eve dev` trace (the most recent when trace is omitted).").option(`--verbose`,`Expand every span with all attributes and events`).option(`--json`,`Output as JSON`).action(async(t,r)=>{let{runTraceShowCommand:i}=await import(`#cli/commands/trace.js`);await i(e,n.root,t,r)}).command(`ls`).description(`List local traces, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runTraceListCommand:r}=await import(`#cli/commands/trace.js`);await r(e,n.root,t)}),agentCommand(a.command(`info`),n).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async r=>{await(t.printApplicationInfo??await loadPrintApplicationInfo())(e,n.root,r)}),agentCommand(a.command(`eval`),n,e=>e.opts().url===void 0).description(`Run evals against an eve agent.`).argument(`[evalIds...]`,`Eval ids (or directory prefixes) to run (all discovered evals when omitted)`).option(`--url <url>`,`Remote agent URL (skip local host startup)`,parseDevelopmentServerUrl).option(`--tag <tag...>`,`Run only evals carrying a tag`).option(`--exclude-tag <tag...>`,`Skip evals carrying a tag`).option(`--strict`,`Fail the exit code when any score falls below its threshold`).option(`--list`,`Print discovered evals without running them`).option(`--timeout <ms>`,`Per-eval timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent eval executions`).option(`--json`,`Output results as JSON`).option(`--junit <path>`,`Write JUnit XML results to a file`).option(`--skip-report`,`Skip eval-defined reporters (e.g. Braintrust)`).option(`--verbose`,`Stream per-eval logs and workflow run IDs to stdout`).action(async(r,i)=>{await(t.runEvalCommand??await loadRunEvalCommand())(r,i,e,n.root)}),a}async function runCli(e=process.argv.slice(2),t=console,n={}){let r={root:resolveApplicationRoot(),async resolve(){let e=await(n.resolveApplicationProject??resolveCliApplicationProject)(r.root);r.project=e,r.root=e.appRoot},async resolveAgent(){return resolveEveProjectContext(r.root)}},i=createEveCliTelemetry(resolveInstalledPackageInfo().version),a=createCliProgram(t,n,r,i),o=e;if(o.length===0){let e=await(n.findApplicationRoot??findCliApplicationRoot)(r.root);e===void 0?o=(await findEveProjectContext(r.root))?.kind===`workspace`?[`dev`]:[`init`]:(r.root=e,o=[`dev`])}let s=canonicalCommand(o);i.trackCommand(s),s!==`telemetry`&&await i.notify(t);try{await a.parseAsync(o,{from:`user`}),i.trackOutcome(`success`)}catch(e){if(e instanceof CommanderError&&e.exitCode===0){i.trackOutcome(`success`);return}if(i.trackOutcome(e instanceof CommanderError?`usage_error`:`error`),e instanceof CommanderError){let r=await(n.isCodingAgentLaunch??isCodingAgentLaunch)();if(o[0]===`init`&&r){let{initAgentInstructions:e}=await import(`#cli/commands/agent-instructions.js`);t.log(e())}throw Error(e.message)}throw e}finally{await i.flush()}}export{createCliProgram,resolveDevUiMode,resolveTuiDisplayOptions,runCli};
@@ -654,12 +654,9 @@ declare const sandbox: z.ZodObject<{
654
654
  module: "module";
655
655
  "skill-package": "skill-package";
656
656
  }>;
657
- backendKind: z.ZodOptional<z.ZodString>;
658
- description: z.ZodOptional<z.ZodString>;
659
- hasBootstrap: z.ZodBoolean;
660
- hasOnSession: z.ZodBoolean;
661
- revalidationKey: z.ZodOptional<z.ZodString>;
662
- sourceHash: z.ZodOptional<z.ZodString>;
657
+ provider: z.ZodOptional<z.ZodString>;
658
+ environmentExportName: z.ZodOptional<z.ZodString>;
659
+ revisionHash: z.ZodString;
663
660
  }, z.core.$strict>;
664
661
  declare const subagent: z.ZodObject<{
665
662
  binding: z.ZodOptional<z.ZodObject<{
@@ -834,7 +831,7 @@ declare const remoteAgent: z.ZodObject<{
834
831
  parentNodeId: z.ZodString;
835
832
  url: z.ZodOptional<z.ZodString>;
836
833
  }, z.core.$strict>;
837
- /** Runtime contract for the authoritative `/eve/v1/info` v4 response. */
834
+ /** Runtime contract for the authoritative `/eve/v1/info` v5 response. */
838
835
  export declare const AgentInfoResultSchema: z.ZodObject<{
839
836
  agent: z.ZodObject<{
840
837
  agentRoot: z.ZodString;
@@ -1737,12 +1734,9 @@ export declare const AgentInfoResultSchema: z.ZodObject<{
1737
1734
  module: "module";
1738
1735
  "skill-package": "skill-package";
1739
1736
  }>;
1740
- backendKind: z.ZodOptional<z.ZodString>;
1741
- description: z.ZodOptional<z.ZodString>;
1742
- hasBootstrap: z.ZodBoolean;
1743
- hasOnSession: z.ZodBoolean;
1744
- revalidationKey: z.ZodOptional<z.ZodString>;
1745
- sourceHash: z.ZodOptional<z.ZodString>;
1737
+ provider: z.ZodOptional<z.ZodString>;
1738
+ environmentExportName: z.ZodOptional<z.ZodString>;
1739
+ revisionHash: z.ZodString;
1746
1740
  }, z.core.$strict>;
1747
1741
  schedules: z.ZodArray<z.ZodObject<{
1748
1742
  binding: z.ZodOptional<z.ZodObject<{
@@ -2141,7 +2135,7 @@ export declare const AgentInfoResultSchema: z.ZodObject<{
2141
2135
  requiresApproval: z.ZodBoolean;
2142
2136
  }, z.core.$strict>>;
2143
2137
  }, z.core.$strict>;
2144
- version: z.ZodLiteral<4>;
2138
+ version: z.ZodLiteral<5>;
2145
2139
  workspace: z.ZodObject<{
2146
2140
  resourceRoot: z.ZodUnknown;
2147
2141
  rootEntries: z.ZodArray<z.ZodString>;
@@ -1 +1 @@
1
- import{z}from"#compiled/zod/index.js";const owner=z.discriminatedUnion(`kind`,[z.object({kind:z.literal(`application`)}).strict(),z.object({feature:z.string(),kind:z.literal(`framework`)}).strict(),z.object({kind:z.literal(`extension`),namespace:z.string(),packageName:z.string()}).strict()]),moduleBacking=z.discriminatedUnion(`kind`,[z.object({externalDependencies:z.array(z.string()),extensionScope:z.object({namespace:z.string(),sourceRoot:z.string()}).strict().optional(),kind:z.literal(`filesystem`),sourcePath:z.string()}).strict(),z.object({dependencies:z.record(z.string(),z.string()).optional(),kind:z.literal(`programmatic`),moduleId:z.string(),parameters:z.record(z.string(),z.unknown()).optional(),registryId:z.string(),revision:z.string(),semanticRevision:z.string().optional()}).strict()]),binding=z.object({backing:moduleBacking,logicalPath:z.string(),owner}).strict(),source=z.object({binding:binding.optional(),exportName:z.string().optional(),logicalPath:z.string(),owner,sourceId:z.string(),sourceKind:z.enum([`markdown`,`module`,`skill-package`])}).strict(),entry=source.extend({name:z.string()}).strict(),dynamicResolver=source.extend({eventNames:z.array(z.string()),slug:z.string()}).strict(),modelRouting=z.discriminatedUnion(`kind`,[z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),modelEndpoint=z.union([z.object({kind:z.literal(`external`),provider:z.string()}).strict(),z.object({kind:z.literal(`chatgpt`),state:z.enum([`checking`,`ready`,`signed-out`,`reauth-required`,`unavailable`]),accountLabel:z.string().optional()}).strict(),z.object({kind:z.literal(`gateway`),connected:z.literal(!0),credential:z.enum([`api-key`,`oidc`,`oauth`]),team:z.optional(z.string())}).strict(),z.object({kind:z.literal(`gateway`),connected:z.literal(!1)}).strict()]),modelBaseFields={contextWindowTokens:z.number().optional(),providerOptions:z.unknown().optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional().catch(void 0),source:source.optional()},agentModel=z.union([z.object({...modelBaseFields,endpoint:modelEndpoint.optional(),id:z.string(),routing:modelRouting}).strict(),z.object({...modelBaseFields,endpoint:z.never().optional(),id:z.never().optional(),routing:z.object({kind:z.literal(`dynamic`),resolver:dynamicResolver}).strict()}).strict()]),tool=entry.extend({description:z.string(),hasAuth:z.boolean(),hasExecute:z.boolean(),hasModelOutputProjection:z.boolean(),hasOutputSchema:z.boolean(),inputSchema:z.unknown(),outputSchema:z.unknown().optional(),requiresApproval:z.boolean()}).strict(),skill=entry.extend({description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional()}).strict(),instructions=entry.extend({content:z.string(),role:z.enum([`system`,`user`])}).strict(),schedule=entry.extend({cron:z.string(),hasRun:z.boolean(),markdown:z.string().optional()}).strict(),channelMethod=z.enum([`GET`,`HEAD`,`POST`,`PUT`,`PATCH`,`DELETE`,`OPTIONS`,`WEBSOCKET`]),channelRoute=entry.extend({adapterKind:z.string().optional(),method:channelMethod,urlPath:z.string()}).strict(),sourceDescriptor=z.object({backing:z.union([moduleBacking,z.object({kind:z.literal(`resource`),sourcePath:z.string()}).strict()]),form:z.enum([`derived`,`direct`]),layer:z.enum([`framework-default`,`extension-package`,`extension-override`,`application`]),logicalPath:z.string(),owner,sourceId:z.string()}).strict(),shadowedChannelRoute=z.object({method:channelMethod,source:sourceDescriptor,urlPath:z.string(),winnerSourceId:z.string()}).strict(),connection=source.extend({connectionName:z.string(),description:z.string(),hasApproval:z.boolean(),hasAuthorization:z.boolean(),hasHeaders:z.boolean(),protocol:z.string(),toolFilter:z.unknown().optional(),url:z.string()}).strict(),hook=source.extend({eventNames:z.array(z.string()),slug:z.string()}).strict(),memory=source.extend({description:z.string().optional(),slot:z.string(),visibility:z.enum([`scope`,`session`])}).strict(),sandbox=source.extend({backendKind:z.string().optional(),description:z.string().optional(),hasBootstrap:z.boolean(),hasOnSession:z.boolean(),revalidationKey:z.string().optional(),sourceHash:z.string().optional()}).strict(),subagent=entry.extend({configResolver:dynamicResolver.optional(),description:z.string().optional(),entryPath:z.string(),nodeId:z.string(),parentNodeId:z.string(),rootPath:z.string(),summary:z.object({channels:z.number(),connections:z.number(),hooks:z.number(),instructions:z.number(),memories:z.number(),schedules:z.number(),skills:z.number(),tools:z.number()}).strict()}).strict(),remoteAgent=entry.extend({description:z.string(),nodeId:z.string(),parentNodeId:z.string(),url:z.string().optional()}).strict(),kernelEffect=z.object({action:z.enum([`subagent-call`,`task-cancel`,`workflow-tool-call`]).optional(),audience:z.array(z.enum([`root-session`,`delegated-task-child`,`requires-request-input`])),kind:z.enum([`request-input`,`dispatch`,`provider-tool`]),sourceId:z.string()}).strict(),compositionDiagnostic=z.object({kind:z.enum([`disabled`,`shadowed`]),logicalPath:z.string(),owner,sourceId:z.string(),winnerSourceId:z.string().optional()}).strict(),AgentInfoResultSchema=z.object({agent:z.object({agentRoot:z.string(),appRoot:z.string(),config:source.extend({binding}).strict(),description:z.string().optional(),model:agentModel,name:z.string(),nodeId:z.string(),outputSchema:z.unknown().optional()}).strict(),capabilities:z.object({devRoutes:z.boolean()}).strict(),channels:z.object({routes:z.array(channelRoute),shadowed:z.array(shadowedChannelRoute)}).strict(),composition:z.object({disabled:z.array(compositionDiagnostic),shadowed:z.array(compositionDiagnostic)}).strict(),connections:z.array(connection),diagnostics:z.object({discoveryErrors:z.number(),discoveryWarnings:z.number()}).strict(),hooks:z.array(hook),instructions:z.object({dynamic:z.array(dynamicResolver),static:z.array(instructions)}).strict(),instrumentation:source.optional(),kernelEffects:z.array(kernelEffect),kind:z.literal(`eve-agent-info`),memories:z.array(memory),mode:z.enum([`development`,`production`]),remoteAgents:z.object({entries:z.array(remoteAgent),total:z.number()}).strict(),sandbox,schedules:z.array(schedule),skills:z.object({dynamic:z.array(dynamicResolver),static:z.array(skill)}).strict(),subagents:z.object({local:z.array(subagent),total:z.number()}).strict(),tools:z.object({dynamic:z.array(dynamicResolver),static:z.array(tool)}).strict(),version:z.literal(4),workspace:z.object({resourceRoot:z.unknown(),rootEntries:z.array(z.string())}).strict()}).strict().superRefine((e,t)=>{let assertUnique=(e,n,r)=>{let i=new Set;e.forEach((e,a)=>{let o=n(e);i.has(o)&&t.addIssue({code:`custom`,message:`Duplicate public identity "${o}".`,path:[...r,a]}),i.add(o)})},assertTotal=(e,n,r)=>{(!Number.isSafeInteger(e)||e<0||e!==n.length)&&t.addIssue({code:`custom`,message:`Expected total ${n.length}, received ${e}.`,path:[...r]})};assertUnique(e.tools.static,e=>e.name,[`tools`,`static`]),assertUnique(e.tools.dynamic,e=>e.slug,[`tools`,`dynamic`]),assertUnique(e.skills.static,e=>e.name,[`skills`,`static`]),assertUnique(e.skills.dynamic,e=>e.slug,[`skills`,`dynamic`]),assertUnique(e.instructions.static,e=>e.name,[`instructions`,`static`]),assertUnique(e.instructions.dynamic,e=>e.slug,[`instructions`,`dynamic`]),assertUnique(e.schedules,e=>e.name,[`schedules`]),assertUnique(e.connections,e=>e.connectionName,[`connections`]),assertUnique(e.hooks,e=>e.slug,[`hooks`]),assertUnique(e.memories,e=>e.slot,[`memories`]),assertUnique(e.channels.routes,e=>`${e.method} ${normalizeRoutePattern(e.urlPath)}`,[`channels`,`routes`]),assertUnique(e.subagents.local,e=>e.nodeId,[`subagents`,`local`]),assertUnique(e.remoteAgents.entries,e=>e.nodeId,[`remoteAgents`,`entries`]),assertTotal(e.subagents.total,e.subagents.local,[`subagents`,`total`]),assertTotal(e.remoteAgents.total,e.remoteAgents.entries,[`remoteAgents`,`total`]);let n=[[e.agent.config,[`agent`,`config`]],...e.agent.model.source===void 0?[]:[[e.agent.model.source,[`agent`,`model`,`source`]]],...e.agent.model.routing.kind===`dynamic`?[[e.agent.model.routing.resolver,[`agent`,`model`,`routing`,`resolver`]]]:[],...e.channels.routes.map((e,t)=>[e,[`channels`,`routes`,t]]),...e.connections.map((e,t)=>[e,[`connections`,t]]),...e.hooks.map((e,t)=>[e,[`hooks`,t]]),...e.instructions.dynamic.map((e,t)=>[e,[`instructions`,`dynamic`,t]]),...e.instructions.static.map((e,t)=>[e,[`instructions`,`static`,t]]),...e.memories.map((e,t)=>[e,[`memories`,t]]),...e.instrumentation===void 0?[]:[[e.instrumentation,[`instrumentation`]]],...e.remoteAgents.entries.map((e,t)=>[e,[`remoteAgents`,`entries`,t]]),...e.schedules.map((e,t)=>[e,[`schedules`,t]]),...e.skills.dynamic.map((e,t)=>[e,[`skills`,`dynamic`,t]]),...e.skills.static.map((e,t)=>[e,[`skills`,`static`,t]]),...e.subagents.local.flatMap((e,t)=>e.configResolver===void 0?[]:[[e.configResolver,[`subagents`,`local`,t,`configResolver`]]]),...e.tools.dynamic.map((e,t)=>[e,[`tools`,`dynamic`,t]]),...e.tools.static.map((e,t)=>[e,[`tools`,`static`,t]]),[e.sandbox,[`sandbox`]]];for(let[e,r]of n){if(e.sourceKind===`module`&&e.binding===void 0){t.addIssue({code:`custom`,message:`Module source is missing its compiled binding.`,path:[...r,`binding`]});continue}if(e.sourceKind!==`module`&&e.binding!==void 0){t.addIssue({code:`custom`,message:`${e.sourceKind} source cannot carry a module binding.`,path:[...r,`binding`]});continue}e.binding!==void 0&&(e.binding.logicalPath!==e.logicalPath&&t.addIssue({code:`custom`,message:`Source and binding logical paths do not match.`,path:[...r,`binding`,`logicalPath`]}),JSON.stringify(e.binding.owner)!==JSON.stringify(e.owner)&&t.addIssue({code:`custom`,message:`Source and binding owners do not match.`,path:[...r,`binding`,`owner`]}))}});function normalizeRoutePattern(e){return e.replace(/^\/+|\/+$/g,``).split(`/`).map(e=>e.startsWith(`:`)||/^\[[^\]]+\]$/.test(e)?`:`:e).join(`/`)}export{AgentInfoResultSchema};
1
+ import{z}from"#compiled/zod/index.js";const owner=z.discriminatedUnion(`kind`,[z.object({kind:z.literal(`application`)}).strict(),z.object({feature:z.string(),kind:z.literal(`framework`)}).strict(),z.object({kind:z.literal(`extension`),namespace:z.string(),packageName:z.string()}).strict()]),moduleBacking=z.discriminatedUnion(`kind`,[z.object({externalDependencies:z.array(z.string()),extensionScope:z.object({namespace:z.string(),sourceRoot:z.string()}).strict().optional(),kind:z.literal(`filesystem`),sourcePath:z.string()}).strict(),z.object({dependencies:z.record(z.string(),z.string()).optional(),kind:z.literal(`programmatic`),moduleId:z.string(),parameters:z.record(z.string(),z.unknown()).optional(),registryId:z.string(),revision:z.string(),semanticRevision:z.string().optional()}).strict()]),binding=z.object({backing:moduleBacking,logicalPath:z.string(),owner}).strict(),source=z.object({binding:binding.optional(),exportName:z.string().optional(),logicalPath:z.string(),owner,sourceId:z.string(),sourceKind:z.enum([`markdown`,`module`,`skill-package`])}).strict(),entry=source.extend({name:z.string()}).strict(),dynamicResolver=source.extend({eventNames:z.array(z.string()),slug:z.string()}).strict(),modelRouting=z.discriminatedUnion(`kind`,[z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),modelEndpoint=z.union([z.object({kind:z.literal(`external`),provider:z.string()}).strict(),z.object({kind:z.literal(`chatgpt`),state:z.enum([`checking`,`ready`,`signed-out`,`reauth-required`,`unavailable`]),accountLabel:z.string().optional()}).strict(),z.object({kind:z.literal(`gateway`),connected:z.literal(!0),credential:z.enum([`api-key`,`oidc`,`oauth`]),team:z.optional(z.string())}).strict(),z.object({kind:z.literal(`gateway`),connected:z.literal(!1)}).strict()]),modelBaseFields={contextWindowTokens:z.number().optional(),providerOptions:z.unknown().optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional().catch(void 0),source:source.optional()},agentModel=z.union([z.object({...modelBaseFields,endpoint:modelEndpoint.optional(),id:z.string(),routing:modelRouting}).strict(),z.object({...modelBaseFields,endpoint:z.never().optional(),id:z.never().optional(),routing:z.object({kind:z.literal(`dynamic`),resolver:dynamicResolver}).strict()}).strict()]),tool=entry.extend({description:z.string(),hasAuth:z.boolean(),hasExecute:z.boolean(),hasModelOutputProjection:z.boolean(),hasOutputSchema:z.boolean(),inputSchema:z.unknown(),outputSchema:z.unknown().optional(),requiresApproval:z.boolean()}).strict(),skill=entry.extend({description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional()}).strict(),instructions=entry.extend({content:z.string(),role:z.enum([`system`,`user`])}).strict(),schedule=entry.extend({cron:z.string(),hasRun:z.boolean(),markdown:z.string().optional()}).strict(),channelMethod=z.enum([`GET`,`HEAD`,`POST`,`PUT`,`PATCH`,`DELETE`,`OPTIONS`,`WEBSOCKET`]),channelRoute=entry.extend({adapterKind:z.string().optional(),method:channelMethod,urlPath:z.string()}).strict(),sourceDescriptor=z.object({backing:z.union([moduleBacking,z.object({kind:z.literal(`resource`),sourcePath:z.string()}).strict()]),form:z.enum([`derived`,`direct`]),layer:z.enum([`framework-default`,`extension-package`,`extension-override`,`application`]),logicalPath:z.string(),owner,sourceId:z.string()}).strict(),shadowedChannelRoute=z.object({method:channelMethod,source:sourceDescriptor,urlPath:z.string(),winnerSourceId:z.string()}).strict(),connection=source.extend({connectionName:z.string(),description:z.string(),hasApproval:z.boolean(),hasAuthorization:z.boolean(),hasHeaders:z.boolean(),protocol:z.string(),toolFilter:z.unknown().optional(),url:z.string()}).strict(),hook=source.extend({eventNames:z.array(z.string()),slug:z.string()}).strict(),memory=source.extend({description:z.string().optional(),slot:z.string(),visibility:z.enum([`scope`,`session`])}).strict(),sandbox=source.extend({provider:z.string().optional(),environmentExportName:z.string().optional(),revisionHash:z.string()}).strict(),subagent=entry.extend({configResolver:dynamicResolver.optional(),description:z.string().optional(),entryPath:z.string(),nodeId:z.string(),parentNodeId:z.string(),rootPath:z.string(),summary:z.object({channels:z.number(),connections:z.number(),hooks:z.number(),instructions:z.number(),memories:z.number(),schedules:z.number(),skills:z.number(),tools:z.number()}).strict()}).strict(),remoteAgent=entry.extend({description:z.string(),nodeId:z.string(),parentNodeId:z.string(),url:z.string().optional()}).strict(),kernelEffect=z.object({action:z.enum([`subagent-call`,`task-cancel`,`workflow-tool-call`]).optional(),audience:z.array(z.enum([`root-session`,`delegated-task-child`,`requires-request-input`])),kind:z.enum([`request-input`,`dispatch`,`provider-tool`]),sourceId:z.string()}).strict(),compositionDiagnostic=z.object({kind:z.enum([`disabled`,`shadowed`]),logicalPath:z.string(),owner,sourceId:z.string(),winnerSourceId:z.string().optional()}).strict(),AgentInfoResultSchema=z.object({agent:z.object({agentRoot:z.string(),appRoot:z.string(),config:source.extend({binding}).strict(),description:z.string().optional(),model:agentModel,name:z.string(),nodeId:z.string(),outputSchema:z.unknown().optional()}).strict(),capabilities:z.object({devRoutes:z.boolean()}).strict(),channels:z.object({routes:z.array(channelRoute),shadowed:z.array(shadowedChannelRoute)}).strict(),composition:z.object({disabled:z.array(compositionDiagnostic),shadowed:z.array(compositionDiagnostic)}).strict(),connections:z.array(connection),diagnostics:z.object({discoveryErrors:z.number(),discoveryWarnings:z.number()}).strict(),hooks:z.array(hook),instructions:z.object({dynamic:z.array(dynamicResolver),static:z.array(instructions)}).strict(),instrumentation:source.optional(),kernelEffects:z.array(kernelEffect),kind:z.literal(`eve-agent-info`),memories:z.array(memory),mode:z.enum([`development`,`production`]),remoteAgents:z.object({entries:z.array(remoteAgent),total:z.number()}).strict(),sandbox,schedules:z.array(schedule),skills:z.object({dynamic:z.array(dynamicResolver),static:z.array(skill)}).strict(),subagents:z.object({local:z.array(subagent),total:z.number()}).strict(),tools:z.object({dynamic:z.array(dynamicResolver),static:z.array(tool)}).strict(),version:z.literal(5),workspace:z.object({resourceRoot:z.unknown(),rootEntries:z.array(z.string())}).strict()}).strict().superRefine((e,t)=>{let assertUnique=(e,n,r)=>{let i=new Set;e.forEach((e,a)=>{let o=n(e);i.has(o)&&t.addIssue({code:`custom`,message:`Duplicate public identity "${o}".`,path:[...r,a]}),i.add(o)})},assertTotal=(e,n,r)=>{(!Number.isSafeInteger(e)||e<0||e!==n.length)&&t.addIssue({code:`custom`,message:`Expected total ${n.length}, received ${e}.`,path:[...r]})};assertUnique(e.tools.static,e=>e.name,[`tools`,`static`]),assertUnique(e.tools.dynamic,e=>e.slug,[`tools`,`dynamic`]),assertUnique(e.skills.static,e=>e.name,[`skills`,`static`]),assertUnique(e.skills.dynamic,e=>e.slug,[`skills`,`dynamic`]),assertUnique(e.instructions.static,e=>e.name,[`instructions`,`static`]),assertUnique(e.instructions.dynamic,e=>e.slug,[`instructions`,`dynamic`]),assertUnique(e.schedules,e=>e.name,[`schedules`]),assertUnique(e.connections,e=>e.connectionName,[`connections`]),assertUnique(e.hooks,e=>e.slug,[`hooks`]),assertUnique(e.memories,e=>e.slot,[`memories`]),assertUnique(e.channels.routes,e=>`${e.method} ${normalizeRoutePattern(e.urlPath)}`,[`channels`,`routes`]),assertUnique(e.subagents.local,e=>e.nodeId,[`subagents`,`local`]),assertUnique(e.remoteAgents.entries,e=>e.nodeId,[`remoteAgents`,`entries`]),assertTotal(e.subagents.total,e.subagents.local,[`subagents`,`total`]),assertTotal(e.remoteAgents.total,e.remoteAgents.entries,[`remoteAgents`,`total`]);let n=[[e.agent.config,[`agent`,`config`]],...e.agent.model.source===void 0?[]:[[e.agent.model.source,[`agent`,`model`,`source`]]],...e.agent.model.routing.kind===`dynamic`?[[e.agent.model.routing.resolver,[`agent`,`model`,`routing`,`resolver`]]]:[],...e.channels.routes.map((e,t)=>[e,[`channels`,`routes`,t]]),...e.connections.map((e,t)=>[e,[`connections`,t]]),...e.hooks.map((e,t)=>[e,[`hooks`,t]]),...e.instructions.dynamic.map((e,t)=>[e,[`instructions`,`dynamic`,t]]),...e.instructions.static.map((e,t)=>[e,[`instructions`,`static`,t]]),...e.memories.map((e,t)=>[e,[`memories`,t]]),...e.instrumentation===void 0?[]:[[e.instrumentation,[`instrumentation`]]],...e.remoteAgents.entries.map((e,t)=>[e,[`remoteAgents`,`entries`,t]]),...e.schedules.map((e,t)=>[e,[`schedules`,t]]),...e.skills.dynamic.map((e,t)=>[e,[`skills`,`dynamic`,t]]),...e.skills.static.map((e,t)=>[e,[`skills`,`static`,t]]),...e.subagents.local.flatMap((e,t)=>e.configResolver===void 0?[]:[[e.configResolver,[`subagents`,`local`,t,`configResolver`]]]),...e.tools.dynamic.map((e,t)=>[e,[`tools`,`dynamic`,t]]),...e.tools.static.map((e,t)=>[e,[`tools`,`static`,t]]),[e.sandbox,[`sandbox`]]];for(let[e,r]of n){if(e.sourceKind===`module`&&e.binding===void 0){t.addIssue({code:`custom`,message:`Module source is missing its compiled binding.`,path:[...r,`binding`]});continue}if(e.sourceKind!==`module`&&e.binding!==void 0){t.addIssue({code:`custom`,message:`${e.sourceKind} source cannot carry a module binding.`,path:[...r,`binding`]});continue}e.binding!==void 0&&(e.binding.logicalPath!==e.logicalPath&&t.addIssue({code:`custom`,message:`Source and binding logical paths do not match.`,path:[...r,`binding`,`logicalPath`]}),JSON.stringify(e.binding.owner)!==JSON.stringify(e.owner)&&t.addIssue({code:`custom`,message:`Source and binding owners do not match.`,path:[...r,`binding`,`owner`]}))}});function normalizeRoutePattern(e){return e.replace(/^\/+|\/+$/g,``).split(`/`).map(e=>e.startsWith(`:`)||/^\[[^\]]+\]$/.test(e)?`:`:e).join(`/`)}export{AgentInfoResultSchema};