eve 0.28.0 → 0.29.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 (221) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/src/channel/types.d.ts +6 -0
  3. package/dist/src/chunks/{use-eve-agent-hdPX68_i.js → use-eve-agent-CyDt3Lny.js} +2 -0
  4. package/dist/src/chunks/{use-eve-agent-CZkX_ZTT.js → use-eve-agent-DaH3cf8K.js} +2 -0
  5. package/dist/src/cli/commands/agent-prompt/collect-intent.md +1 -1
  6. package/dist/src/cli/commands/channels.d.ts +0 -17
  7. package/dist/src/cli/commands/channels.js +1 -1
  8. package/dist/src/cli/commands/deploy.js +1 -1
  9. package/dist/src/cli/commands/extension-init.js +1 -1
  10. package/dist/src/cli/commands/init.js +1 -1
  11. package/dist/src/cli/commands/integration-connect.d.ts +29 -0
  12. package/dist/src/cli/commands/integration-connect.js +1 -0
  13. package/dist/src/cli/commands/integration-setup.d.ts +2 -3
  14. package/dist/src/cli/commands/integration-setup.js +1 -1
  15. package/dist/src/cli/commands/register-integration-commands.js +1 -1
  16. package/dist/src/cli/commands/registry-setup-command.d.ts +13 -3
  17. package/dist/src/cli/commands/registry-setup-command.js +2 -1
  18. package/dist/src/cli/commands/registry.d.ts +35 -1
  19. package/dist/src/cli/commands/registry.js +1 -1
  20. package/dist/src/cli/commands/trace.js +1 -1
  21. package/dist/src/cli/dev/tui/agent-header.js +1 -1
  22. package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
  23. package/dist/src/cli/dev/tui/prompt-commands.d.ts +1 -1
  24. package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
  25. package/dist/src/cli/dev/tui/remote-auth-command.js +1 -1
  26. package/dist/src/cli/dev/tui/runner.d.ts +8 -7
  27. package/dist/src/cli/dev/tui/runner.js +1 -1
  28. package/dist/src/cli/dev/tui/setup-commands.d.ts +8 -13
  29. package/dist/src/cli/dev/tui/setup-commands.js +3 -2
  30. package/dist/src/cli/dev/tui/setup-flow.d.ts +14 -5
  31. package/dist/src/cli/dev/tui/setup-panel.d.ts +5 -1
  32. package/dist/src/cli/dev/tui/setup-panel.js +2 -2
  33. package/dist/src/cli/dev/tui/status-line.d.ts +1 -1
  34. package/dist/src/cli/dev/tui/status-line.js +1 -1
  35. package/dist/src/cli/dev/tui/terminal-renderer.d.ts +2 -5
  36. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  37. package/dist/src/cli/dev/tui/test/fake-setup-flow-renderer.js +1 -1
  38. package/dist/src/cli/dev/tui/tui-prompter.js +1 -1
  39. package/dist/src/cli/dev/tui/tui.d.ts +2 -0
  40. package/dist/src/cli/dev/tui/tui.js +1 -1
  41. package/dist/src/cli/dev/tui/vercel-status.d.ts +1 -6
  42. package/dist/src/cli/dev/tui/vercel-status.js +1 -1
  43. package/dist/src/cli/option-parsers.d.ts +11 -0
  44. package/dist/src/cli/option-parsers.js +1 -0
  45. package/dist/src/cli/run.d.ts +1 -12
  46. package/dist/src/cli/run.js +3 -3
  47. package/dist/src/cli/shutdown.d.ts +2 -0
  48. package/dist/src/cli/shutdown.js +1 -1
  49. package/dist/src/compiled/.vendor-stamp.json +5 -5
  50. package/dist/src/compiled/@workflow/core/index.js +1 -1
  51. package/dist/src/compiled/@workflow/core/private.d.ts +21 -5
  52. package/dist/src/compiled/@workflow/core/private.js +1 -1
  53. package/dist/src/compiled/@workflow/core/runtime/world.d.ts +10 -5
  54. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  55. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +2 -2
  56. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  57. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  58. package/dist/src/compiled/@workflow/world-local/index.js +3 -3
  59. package/dist/src/compiled/@workflow/world-vercel/index.js +13 -13
  60. package/dist/src/compiled/_chunks/workflow/{attribute-changes-DeZc2RZz.js → attribute-changes-1LmTKuTT.js} +1 -1
  61. package/dist/src/compiled/_chunks/workflow/{private-Cre8uYkA.js → private-BcwCGTV5.js} +1 -1
  62. package/dist/src/compiled/_chunks/workflow/{resume-hook-ip1hbn1b.js → resume-hook-D1_5NCZ6.js} +1 -1
  63. package/dist/src/compiled/_chunks/workflow/{run-CWytxfIp.js → run-C240Ctf4.js} +1 -1
  64. package/dist/src/compiled/_chunks/workflow/sleep-De802yfX.js +1 -0
  65. package/dist/src/compiled/_chunks/workflow/{wait-until-De9yESQN.js → wait-until-z48sPUjU.js} +2 -2
  66. package/dist/src/compiled/shadcn-registry/index.d.ts +1 -0
  67. package/dist/src/evals/assertions/collector.d.ts +2 -10
  68. package/dist/src/evals/assertions/collector.js +1 -1
  69. package/dist/src/evals/cli/eval.d.ts +6 -2
  70. package/dist/src/evals/cli/eval.js +2 -2
  71. package/dist/src/evals/cli/filter.d.ts +14 -0
  72. package/dist/src/evals/cli/filter.js +1 -0
  73. package/dist/src/evals/context.js +1 -1
  74. package/dist/src/evals/diagnostics.d.ts +8 -0
  75. package/dist/src/evals/diagnostics.js +1 -0
  76. package/dist/src/evals/expect/index.d.ts +1 -1
  77. package/dist/src/evals/expect/index.js +1 -1
  78. package/dist/src/evals/index.d.ts +1 -1
  79. package/dist/src/evals/judge.js +2 -1
  80. package/dist/src/evals/runner/artifacts.js +1 -1
  81. package/dist/src/evals/runner/reporters/assertion-diagnostics.d.ts +3 -0
  82. package/dist/src/evals/runner/reporters/assertion-diagnostics.js +3 -0
  83. package/dist/src/evals/runner/reporters/braintrust.js +1 -1
  84. package/dist/src/evals/runner/reporters/console.js +1 -1
  85. package/dist/src/evals/runner/reporters/junit.js +2 -2
  86. package/dist/src/evals/types.d.ts +21 -5
  87. package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
  88. package/dist/src/execution/turn-cancellation-control.js +1 -1
  89. package/dist/src/execution/turn-workflow.js +1 -1
  90. package/dist/src/execution/workflow-runtime.js +1 -1
  91. package/dist/src/execution/workflow-steps.d.ts +7 -0
  92. package/dist/src/execution/workflow-steps.js +1 -1
  93. package/dist/src/harness/turn-sleep.d.ts +12 -0
  94. package/dist/src/harness/turn-sleep.js +1 -0
  95. package/dist/src/internal/application/compiled-artifacts.js +7 -7
  96. package/dist/src/internal/application/package.js +1 -1
  97. package/dist/src/internal/nitro/host/dev-authored-source-watcher.d.ts +4 -0
  98. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  99. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  100. package/dist/src/internal/workflow/development-world-protocol.js +1 -1
  101. package/dist/src/internal/workflow/world-target.d.ts +7 -0
  102. package/dist/src/internal/workflow/world-target.js +1 -0
  103. package/dist/src/protocol/routes.d.ts +4 -0
  104. package/dist/src/protocol/routes.js +1 -1
  105. package/dist/src/public/tools/sleep/index.d.ts +18 -0
  106. package/dist/src/public/tools/sleep/index.js +1 -0
  107. package/dist/src/runtime/framework-tools/sleep.d.ts +15 -0
  108. package/dist/src/runtime/framework-tools/sleep.js +1 -0
  109. package/dist/src/services/dev-client/runtime-artifacts.d.ts +7 -0
  110. package/dist/src/services/dev-client/runtime-artifacts.js +1 -1
  111. package/dist/src/setup/boxes/apply-ai-gateway-credential.js +1 -1
  112. package/dist/src/setup/boxes/deploy-project.d.ts +3 -3
  113. package/dist/src/setup/flows/deploy.js +1 -1
  114. package/dist/src/setup/flows/ensure-vercel-project.d.ts +17 -0
  115. package/dist/src/setup/flows/ensure-vercel-project.js +1 -0
  116. package/dist/src/setup/flows/in-project.d.ts +1 -1
  117. package/dist/src/setup/flows/link.js +1 -1
  118. package/dist/src/setup/flows/model.js +1 -1
  119. package/dist/src/setup/flows/provider.js +1 -1
  120. package/dist/src/setup/flows/registry.d.ts +20 -0
  121. package/dist/src/setup/flows/registry.js +1 -0
  122. package/dist/src/setup/index.d.ts +0 -1
  123. package/dist/src/setup/index.js +1 -1
  124. package/dist/src/setup/{channel-setup-environment.d.ts → integrations/channels/environment.d.ts} +2 -2
  125. package/dist/src/setup/integrations/channels/environment.js +1 -0
  126. package/dist/src/setup/{channel-setup-integrations.d.ts → integrations/channels/index.d.ts} +3 -3
  127. package/dist/src/setup/integrations/channels/index.js +1 -0
  128. package/dist/src/setup/{channel-setup-runner.d.ts → integrations/channels/runner.d.ts} +1 -1
  129. package/dist/src/setup/integrations/channels/runner.js +1 -0
  130. package/dist/src/setup/{boxes/add-channels.d.ts → integrations/channels/setup.d.ts} +32 -22
  131. package/dist/src/setup/integrations/channels/setup.js +2 -0
  132. package/dist/src/setup/{channel-setup-slack.d.ts → integrations/channels/slack.d.ts} +1 -1
  133. package/dist/src/setup/integrations/channels/slack.js +1 -0
  134. package/dist/src/setup/{channel-setup-integration.d.ts → integrations/channels/types.d.ts} +23 -7
  135. package/dist/src/setup/{channel-setup-ui.d.ts → integrations/channels/ui.d.ts} +2 -2
  136. package/dist/src/setup/integrations/channels/ui.js +2 -0
  137. package/dist/src/setup/{channel-setup-web.d.ts → integrations/channels/web.d.ts} +1 -1
  138. package/dist/src/setup/integrations/channels/web.js +1 -0
  139. package/dist/src/setup/primitives/run-vercel.d.ts +1 -0
  140. package/dist/src/setup/primitives/run-vercel.js +1 -1
  141. package/dist/src/setup/prompter.d.ts +16 -3
  142. package/dist/src/setup/prompter.js +1 -1
  143. package/dist/src/setup/registry-setup-client.d.ts +18 -0
  144. package/dist/src/setup/registry-setup-client.js +2 -0
  145. package/dist/src/setup/registry-setup-protocol.d.ts +93 -0
  146. package/dist/src/setup/registry-setup-protocol.js +1 -0
  147. package/dist/src/setup/scaffold/channels-catalog.d.ts +1 -1
  148. package/dist/src/setup/scaffold/create/extension.js +2 -2
  149. package/dist/src/setup/scaffold/create/project.js +2 -2
  150. package/dist/src/setup/scaffold/create-in-place.d.ts +1 -0
  151. package/dist/src/setup/scaffold/create-in-place.js +1 -0
  152. package/dist/src/setup/scaffold/index.js +1 -1
  153. package/dist/src/setup/scaffold/update/connections.js +3 -3
  154. package/dist/src/setup/scaffold/update/update-connection-connector.js +1 -1
  155. package/dist/src/setup/vercel-project-framework.d.ts +1 -1
  156. package/dist/src/setup/vercel-project-framework.js +1 -1
  157. package/dist/src/setup/vercel-project.d.ts +17 -2
  158. package/dist/src/setup/vercel-project.js +0 -0
  159. package/dist/src/svelte/index.js +1 -1
  160. package/dist/src/svelte/use-eve-agent.js +1 -1
  161. package/dist/src/vue/index.js +1 -1
  162. package/dist/src/vue/use-eve-agent.js +1 -1
  163. package/docs/channels/overview.mdx +1 -1
  164. package/docs/channels/slack.mdx +2 -2
  165. package/docs/concepts/default-harness.md +12 -0
  166. package/docs/evals/assertions.mdx +8 -1
  167. package/docs/evals/judge.mdx +11 -1
  168. package/docs/evals/reporters.mdx +1 -1
  169. package/docs/evals/running.mdx +3 -0
  170. package/docs/guides/dev-tui.md +9 -14
  171. package/docs/guides/instrumentation.md +1 -1
  172. package/docs/reference/cli.md +25 -38
  173. package/docs/reference/typescript-api.md +2 -1
  174. package/docs/tutorial/ship-it.mdx +2 -2
  175. package/package.json +11 -6
  176. package/dist/src/compiled/@workflow/core/runtime/world-target.d.ts +0 -11
  177. package/dist/src/compiled/_chunks/workflow/sleep-BjrUxUcs.js +0 -1
  178. package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/index.js +0 -1
  179. package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/parse-name.js +0 -1
  180. package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/promise.js +0 -1
  181. package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/time.js +0 -1
  182. package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/workflow-routes.js +0 -1
  183. package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/world-target.js +0 -1
  184. package/dist/src/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +0 -1
  185. package/dist/src/setup/boxes/add-channels.js +0 -2
  186. package/dist/src/setup/boxes/add-connections.d.ts +0 -26
  187. package/dist/src/setup/boxes/add-connections.js +0 -1
  188. package/dist/src/setup/boxes/install-channel-registry-items.d.ts +0 -8
  189. package/dist/src/setup/boxes/install-channel-registry-items.js +0 -1
  190. package/dist/src/setup/boxes/one-shot-next-steps.d.ts +0 -18
  191. package/dist/src/setup/boxes/one-shot-next-steps.js +0 -2
  192. package/dist/src/setup/boxes/preflight.d.ts +0 -37
  193. package/dist/src/setup/boxes/preflight.js +0 -1
  194. package/dist/src/setup/boxes/resolve-target.d.ts +0 -58
  195. package/dist/src/setup/boxes/resolve-target.js +0 -1
  196. package/dist/src/setup/boxes/scaffold.d.ts +0 -40
  197. package/dist/src/setup/boxes/scaffold.js +0 -1
  198. package/dist/src/setup/boxes/select-channels.d.ts +0 -49
  199. package/dist/src/setup/boxes/select-channels.js +0 -1
  200. package/dist/src/setup/boxes/select-chat.d.ts +0 -38
  201. package/dist/src/setup/boxes/select-chat.js +0 -1
  202. package/dist/src/setup/boxes/select-connections.d.ts +0 -30
  203. package/dist/src/setup/boxes/select-connections.js +0 -1
  204. package/dist/src/setup/boxes/select-setup-mode.d.ts +0 -32
  205. package/dist/src/setup/boxes/select-setup-mode.js +0 -1
  206. package/dist/src/setup/channel-setup-deployment.d.ts +0 -11
  207. package/dist/src/setup/channel-setup-deployment.js +0 -1
  208. package/dist/src/setup/channel-setup-environment.js +0 -1
  209. package/dist/src/setup/channel-setup-integration.js +0 -1
  210. package/dist/src/setup/channel-setup-integrations.js +0 -1
  211. package/dist/src/setup/channel-setup-runner.js +0 -1
  212. package/dist/src/setup/channel-setup-slack.js +0 -1
  213. package/dist/src/setup/channel-setup-ui.js +0 -2
  214. package/dist/src/setup/channel-setup-web.js +0 -1
  215. package/dist/src/setup/flows/channels.d.ts +0 -57
  216. package/dist/src/setup/flows/channels.js +0 -1
  217. package/dist/src/setup/flows/connections.d.ts +0 -37
  218. package/dist/src/setup/flows/connections.js +0 -3
  219. package/dist/src/setup/onboarding.d.ts +0 -60
  220. package/dist/src/setup/onboarding.js +0 -1
  221. /package/dist/src/{node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/pluralize.js → setup/integrations/channels/types.js} +0 -0
@@ -1 +1 @@
1
- import{PROMPT_COMMANDS,formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{pickAgentHeaderTip}from"./agent-header.js";import{failureKey,formatFailureDetail,formatFailureHint,formatFailureMessage,isInterruptedError,localFailureHint}from"./errors.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{createMcpConnectionStatusTracker}from"./mcp-connection-status.js";import{createRemoteConnectionController}from"./remote-connection.js";import{SubagentPump}from"./subagent-pump.js";import{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,orderedSetupIssues,resolveModelProviderState}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{toErrorMessage}from"#shared/errors.js";import"#client/index.js";import{probeAgentInfo}from"#services/dev-client/agent-info-probe.js";import{subscribeDevelopmentSandboxPrewarmLogs}from"#execution/sandbox/development-prewarm.js";import{createEventDeduper}from"#protocol/event-dedupe.js";import{createDevelopmentRuntimeArtifactRefresher}from"#services/dev-client.js";import{devBootPhase}from"#internal/dev-boot-progress.js";async function delayMs(e){await new Promise(t=>{setTimeout(t,e).unref?.()})}function authIssueForStatus(e){if(e===`logged-out`)return LOGIN_SETUP_ISSUE;if(e===`cli-missing`)return CLI_MISSING_SETUP_ISSUE}var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x=!1;#S=new AbortController;#C=!1;#w=[];#T;#E;#D;#O=pickAgentHeaderTip();#k;#A=new Map;#j;#M=new Map;#N=new Set;#P=!1;#F;#I;constructor(t){this.#e=t.session,t.client!==void 0&&(this.#t=t.client),t.lifecycle!==void 0&&(this.#I=t.lifecycle),this.#n=createRenderer(t);let n={formatActionResultError};if(this.#t!==void 0&&(n.client=this.#t),this.#n.subagents!==void 0&&(n.view=this.#n.subagents),this.#j=new SubagentPump(n),this.#r=t.name??`eve`,this.#i=t.tools??`full`,this.#a=t.reasoning??`full`,this.#o=t.subagents??`full`,this.#s=t.connectionAuth??`full`,this.#c=t.assistantResponseStats??`tokensPerSecond`,this.#l=t.contextSize,this.#u=t.formatTransportError??toErrorMessage,t.initialInput!==void 0&&(this.#m=t.initialInput),t.appRoot!==void 0){this.#p=t.appRoot;let e={appRoot:t.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};t.detectProjectIdentity!==void 0&&(e.detectIdentity=t.detectProjectIdentity),this.#E=createVercelStatusTracker(e),t.probeMcpConnection!==void 0&&(this.#D=createMcpConnectionStatusTracker({onChange:()=>{},probe:t.probeMcpConnection}))}if(t.promptCommandHandler!==void 0&&(this.#h=t.promptCommandHandler),this.#g=t.availablePromptCommands??PROMPT_COMMANDS,t.remote!==void 0){if(this.#t===void 0)throw Error(`A remote TUI requires a configured development client.`);this.#_=createRemoteConnectionController({client:this.#t,credentials:t.remote.credentials,target:t.remote.target,onChange:e=>this.#n.setRemoteConnectionStatus?.(e),resolveOidcToken:t.remote.resolveOidcToken,resolveDeployment:t.remote.resolveDeployment})}this.#v=t.bootDetections??BOOT_DETECTIONS,this.#y=t.getVercelAuthStatus??getVercelAuthStatus,t.onBootProgress!==void 0&&(this.#b=t.onBootProgress),t.serverUrl!==void 0&&(this.#f=t.serverUrl),t.serverUrl!==void 0&&t.remote===void 0&&(this.#d=createDevelopmentRuntimeArtifactRefresher({serverUrl:t.serverUrl}))}async#L(){if(this.#f===void 0){this.#z(),await this.#J(void 0);return}let e;if(this.#_!==void 0){let t=await this.#_.check();t.state===`ready`&&(e=t.info)}else{let t=this.#t;if(t!==void 0)try{let n=await devBootPhase(`connecting to agent`,()=>probeAgentInfo({client:t}),this.#b);n.kind===`ready`&&(e=n.info)}catch{e=void 0}}this.#z();let t=this.#R(e);await this.#J(t)}#R(e){let t=this.#p===void 0?e:resolveModelProviderState(e,process.env);this.#k=t;let n=this.#f;if(n===void 0)return t;let r={name:this.#r,serverUrl:n};return t!==void 0&&(r.info=t),this.#p!==void 0&&(r.tip=this.#O),this.#n.renderAgentHeader?.(r),t}#z(){let e=this.#b;this.#b=void 0,e?.({type:`before-first-paint`})}async run(){let onStop=()=>this.#n.requestInterrupt?.();this.#I?.signal.aborted===!0?onStop():this.#I?.signal.addEventListener(`abort`,onStop,{once:!0});try{await this.#B()}finally{this.#I?.signal.removeEventListener(`abort`,onStop),this.#x=!0,this.#S.abort(),this.#j.abortAll(),this.#F?.(),this.#F=void 0,this.#n.shutdown?.(),this.#E?.dispose(),this.#D?.dispose(),this.#_?.dispose()}}async#B(){let e=this.#r,r,i,a=!1,o=!1,s=this.#m;await this.#L(),this.#_?.current().connection.state===`auth-required`&&await this.#ie({type:`extension`,name:`vc:login`,argument:``},e,{trigger:`startup`}),this.#Q(),this.#E?.refreshIdentity(),this.#D?.refresh();let l=this.#m===void 0?void 0:parsePromptCommand(this.#m);for(l?.type===`extension`&&l.name===`model`&&l.argument===``&&this.#p!==void 0&&this.#h!==void 0&&this.#n.setupFlow!==void 0&&(s=void 0,await this.#ae(e));;){if(this.#I?.signal.aborted===!0||this.#n.exitRequested?.()===!0)return;if(!o){if(r==null){if(!this.#n.readPrompt){if(a)return;throw Error(`No prompt was provided and the renderer does not support prompt input.`)}let t={title:e};s!==void 0&&(t.initialDraft=s,s=void 0);try{r=await this.#U(t)}catch(e){if(isInterruptedError(e))return;throw e}if(r==null)return}let l=parsePromptCommand(r);if(l?.type===`exit`)return;if(l?.type===`new`){if(!await this.#H()){i=void 0,o=!1,r=void 0;continue}i=void 0,o=!1,r=void 0;continue}if(l?.type===`help`){this.#$(formatPromptCommandHelp(this.#g)),i=void 0,o=!1,r=void 0;continue}if(l?.type===`loglevel`){this.#$(this.#se(l.argument)),i=void 0,o=!1,r=void 0;continue}if(l?.type===`extension`){try{await this.#ie(l,e,{trigger:`command`})}catch(e){if(isInterruptedError(e))return;throw e}i=void 0,r=void 0,o=!1;continue}a=!0}let l=await this.#W({prompt:o?void 0:r,inputResponses:i}),u=this.#e.state.sessionId;u!==void 0&&this.#n.setSessionId?.(u);let d=r,f=!1;try{for(;;){await this.#n.renderStream(l,{title:e,submittedPrompt:d,continueSession:!!this.#n.readPrompt,tools:this.#i,reasoning:this.#a,subagents:this.#o,connectionAuth:this.#s,assistantResponseStats:this.#c,contextSize:this.#l});let t=l.turnState?.pendingApprovals??[],n=l.turnState?.pendingQuestions??[];if(t.length>0||n.length>0){let a=[];if(t.length>0){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);for(let n of t){let t=await this.#n.readToolApproval(n,{title:e});a.push({requestId:n.approvalId,optionId:t.approved?`approve`:`deny`}),this.#A.delete(n.approvalId)}}if(n.length>0){if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);for(let t of n){let n=toAgentTUIInputQuestion(t),r=await this.#n.readInputQuestion(n,{title:e});if(r===void 0)continue;let i={requestId:t.requestId};r.optionId!==void 0&&(i.optionId=r.optionId),r.text!==void 0&&(i.text=r.text),a.push(i),this.#A.delete(t.requestId)}}if(a.length===0)break;o=!0,i=a,r=void 0,f=!0;break}if(this.#fe(l)){l=this.#K(),d=void 0;continue}if(l.turnState&&l.turnState.boundaryEvent===void 0)if(l.turnState.aborted)this.#P=!0;else{let e=this.#e.state.sessionId;this.#n.renderNotice?.(e?`Lost the event stream — the turn may still be running on the server (session ${e}). Your next message resumes this session; use /cancel to stop the turn.`:`Lost the connection to the running turn.`)}break}}catch(e){if(isInterruptedError(e))return;throw e}if(f)continue;o=!1,i=void 0,r=void 0;let p=l.turnState?.boundaryEvent;!this.#P&&(p===`session.waiting`||p===`session.completed`)&&(r=this.#n.takeQueuedPrompt?.()),this.#P&&(this.#P=!1,this.#V(),l.turnState?.aborted?this.#n.renderNotice?.(`Stopped following the turn and started a new session. Earlier context was cleared; the interrupted turn may still be running on the server.`):this.#n.renderSessionBoundary===void 0?this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`):this.#n.renderSessionBoundary())}}#V(){this.#j.abortAll(),this.#A.clear(),this.#M.clear(),this.#N.clear(),this.#n.setConnectionAuthPendingCount?.(0),this.#t&&(this.#e=this.#t.session()),this.#d?.clear()}async#H(){try{await this.#e.reset()}catch(e){return this.#n.renderNotice?.(`Couldn't reset the session: ${toErrorMessage(e)}`),!1}return this.#V(),this.#n.reset?.(),!0}async#U(e){if(!this.#n.readPrompt)return;let t=this.#n.readPrompt(e),n=this.#d;if(n===void 0)return await t;let r=!1,i=!1,a,refresh=async()=>{if(!(r||i)){i=!0;try{await n.refreshIdle({onRuntimeArtifactsChanged:()=>this.#ue()})}finally{i=!1}}},startRefresh=()=>{if(r||i)return;let e=refresh().finally(()=>{a===e&&(a=void 0)});a=e};startRefresh();let o=setInterval(()=>{startRefresh()},500);o.unref?.();try{return await t}finally{r=!0,clearInterval(o),await a}}async#W(e){let t=new AbortController,n={signal:t.signal};e.prompt!==void 0&&(n.message=e.prompt),e.inputResponses!==void 0&&e.inputResponses.length>0&&(n.inputResponses=e.inputResponses);let r;try{this.#d!==void 0&&await this.#d.refresh({inputResponses:n.inputResponses,message:n.message,onRuntimeArtifactsChanged:()=>this.#ue()}),n.message!==void 0&&(n.inputResponses?.length??0)===0&&this.#n.flushDelayedDevBuildErrors?.(),r=await this.#e.send(n)}catch(e){if(isInterruptedError(e))throw e;return this.#_?.reportFailure(e),this.#P=!0,{events:errorOnlyTUIStream({errorText:this.#u(e)}),turnState:createTurnState()}}return this.#q(r,()=>t.abort())}async#G(e){if(e.cancelInFlight!==!0){e.cancelInFlight=!0;try{for(let t=0;t<8;t+=1){if(e.boundaryEvent!==void 0||e.aborted===!0)return;let t=e.turnId;try{if((await this.#e.cancel(t===void 0?void 0:{turnId:t})).status===`accepted`)return}catch{}await delayMs(250)}}finally{e.cancelInFlight=!1}}}#K(){let e=new AbortController;return this.#q(this.#e.stream({signal:e.signal}),()=>e.abort())}#q(e,t){let n=createTurnState();return{abort:()=>{n.aborted=!0,t()},cancel:()=>{this.#G(n)},events:eveEventsToTUIStream({events:e,pendingInputRequests:this.#A,turnState:n,onSubagentCalled:e=>this.#j.begin(e),onSubagentCompleted:e=>this.#j.settle(e),onTurnCancelled:()=>this.#j.settleAll(),onConnectionAuthRequired:e=>this.#de(e),onConnectionAuthCompleted:e=>this.#pe(e),onTerminalFailure:()=>{this.#P=!0},failureHintOverride:this.#p===void 0?void 0:localFailureHint}),turnState:n}}async#J(e){if(this.#p===void 0)return;let t={appRoot:this.#p,env:process.env};e!==void 0&&(t.info=e),this.#w=await detectSetupIssues(t,this.#v),this.#n.renderSetupWarning!==void 0&&(this.#Y(),this.#X())}#Y(){let e=orderedSetupIssues(this.#w,this.#T);e.length>0?this.#n.renderSetupWarning?.(formatSetupIssuesLine(e)):this.#n.clearSetupWarning?.()}async#X(){let e=this.#p;if(e===void 0)return;let t;try{t=await this.#y(e,{signal:this.#S.signal})}catch{return}this.#x||this.#C||(this.#T=authIssueForStatus(t),this.#Y())}async#Z(e){let t=this.#p;if(t===void 0||this.#n.renderSetupWarning===void 0)return;let n={appRoot:t,env:process.env};e!==void 0&&(n.info=e);try{this.#w=await detectSetupIssues(n,this.#v);let e=await this.#y(t,{signal:this.#S.signal});this.#T=authIssueForStatus(e)}catch{return}this.#x||this.#Y()}#Q(){this.#p===void 0||this.#n.renderSandboxLog===void 0||this.#F===void 0&&(this.#F=subscribeDevelopmentSandboxPrewarmLogs({appRoot:this.#p,log:e=>this.#n.renderSandboxLog?.(e)}))}#$(e){if(e!==void 0){if(this.#n.renderCommandResult!==void 0){this.#n.renderCommandResult(e);return}this.#n.renderNotice?.(e)}}async#ee(e,t){let n=this.#h;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r={renderer:this.#n,title:t.title,initialModelStep:t.initialModelStep,remoteConnection:this.#_},i=this.#D?.current(),a=i!==void 0&&Object.keys(i).length>0?{...r,disabledConnectionReasons:i}:r;return t.keepSetupFlowOpen===!0?await n.handle(e,{...a,keepSetupFlowOpen:!0}):await n.handle(e,a)}#te(e,t){if(t!==`startup`)return;let n=this.#_?.current().connection.state,r=n===`auth-failed`||n===`unavailable`?`failed`:void 0,i=e.argument.length===0?``:` ${e.argument}`;this.#n.renderCommandInvocation?.(`/${e.name}${i}`,r)}async#ne(e){if(e?.kind===`connection-added`){this.#E?.applyEffect({kind:`refresh-identity`}),this.#C=!0,await this.#re(),await this.#ce();return}if(e?.kind===`model-access-changed`){this.#E?.applyEffect({kind:`refresh-identity`}),this.#C=!0,await this.#ce();return}e!==void 0&&(this.#E?.applyEffect(e),this.#C=!0,this.#Z(this.#k))}async#re(){let e=this.#d;e!==void 0&&await e.refreshAfterSourceChange({onRuntimeArtifactsChanged:()=>this.#ue()})}async#ie(e,t,n){let r=await this.#ee(e,{initialModelStep:n.initialModelStep,keepSetupFlowOpen:n.keepSetupFlowOpen,title:t});this.#te(e,n.trigger),this.#$(r?.message),await this.#ne(r?.effect),this.#oe()}async#ae(e){let t=this.#p;if(t===void 0)return;let authStatus=async()=>{try{return await this.#y(t,{signal:this.#S.signal})}catch{return}},n=await authStatus();if(n===`cli-missing`&&(await this.#ie({type:`extension`,name:`vc:install`,argument:``},e,{trigger:`startup`,keepSetupFlowOpen:!0}),n=await authStatus(),n===`cli-missing`)){this.#n.setupFlow?.end();return}if(n===`logged-out`&&(await this.#ie({type:`extension`,name:`vc:login`,argument:``},e,{trigger:`startup`,keepSetupFlowOpen:!0}),n=await authStatus(),n===`cli-missing`||n===`logged-out`)){this.#n.setupFlow?.end();return}await this.#ie({type:`extension`,name:`model`,argument:``},e,{trigger:`startup`,initialModelStep:`provider`})}#oe(){let e=this.#_?.current().connection;e?.state!==`ready`||e.info===this.#k||(this.#k=e.info,this.#f!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#r,serverUrl:this.#f}))}#se(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel all|stderr|sandbox|none — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use all, stderr, sandbox, or none.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`stderr`:return`Showing stderr logs only.`;case`sandbox`:return`Showing sandbox logs only.`;case`all`:return`Showing all logs.`}}async#ce(){let e=this.#p;if(e===void 0)return;loadDevelopmentEnvironmentFiles(e);let t=this.#R(await this.#le());this.#Z(t)}async#le(){let e=this.#t;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}async#ue(){let e=this.#k,t=await this.#le();t!==void 0&&this.#R(t),(!this.#n.renderAgentHeader||t===void 0)&&this.#n.renderNotice?.(formatAgentUpdateNotice(e,t))}#de(e){let t={name:e.data.name,description:e.data.description,state:`required`};e.data.authorization!==void 0&&(t.challenge=e.data.authorization),e.data.webhookUrl!==void 0&&(t.webhookUrl=e.data.webhookUrl),this.#M.set(e.data.name,t),this.#me(t)}#fe(e){if(e.turnState?.boundaryEvent!==`session.waiting`)return!1;let t=!1;for(let e of this.#M.values())e.state!==`required`||e.webhookUrl===void 0||(e.state=`pending`,this.#N.add(e.name),this.#me(e),t=!0);return t&&this.#n.setConnectionAuthPendingCount?.(this.#N.size),this.#N.size>0}#pe(e){let t=this.#M.get(e.data.name)??{name:e.data.name,description:``,state:e.data.outcome};t.state=e.data.outcome,e.data.reason!==void 0&&(t.reason=e.data.reason),this.#M.set(e.data.name,t),this.#N.delete(e.data.name),this.#me(t),this.#n.setConnectionAuthPendingCount?.(this.#N.size)}#me(e){let t={name:e.name,description:e.description,state:e.state};e.challenge!==void 0&&(t.challenge=e.challenge),e.reason!==void 0&&(t.reason=e.reason),this.#n.upsertConnectionAuth?.(t)}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,availablePromptCommands:e.availablePromptCommands,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}async function*eveEventsToTUIStream(e){let{events:t,pendingInputRequests:n,turnState:r,onSubagentCalled:i,onSubagentCompleted:a,onTurnCancelled:o,onConnectionAuthRequired:s,onConnectionAuthCompleted:c,onTerminalFailure:l,failureHintOverride:u}=e,d=new Map,f=new Map,p=createEventDeduper(),m=0,h=new Set,g=new Set,_=new Set,v=!1,y=!1,b;for await(let e of t)if(p.admit(e)&&!(y&&isPostTurnVisibleEvent(e)))switch(e.type){case`session.started`:case`message.received`:break;case`turn.started`:r.turnId=e.data.turnId;break;case`step.started`:m+=1,yield{type:`step-start`};break;case`step.completed`:{let t=e;b=t.data.usage,yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m),yield{type:`step-finish`,usage:t.data.usage};break}case`message.appended`:{let t=e,n=textPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(d,n),i=t.data.messageSoFar;if(r.completed){if(m<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}if(!i.startsWith(r.text)||i.length<=r.text.length)break;let a=i.slice(r.text.length);r.text=i,yield{type:`assistant-delta`,id:partGenerationId(n,r.generation),delta:a};break}case`message.completed`:{let t=textPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(d,t),r=e.data.message;if(n.completed){if(r===null||m<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=m,yield{type:`assistant-complete`,id:partGenerationId(t,n.generation),text:r};break}let i=partGenerationId(t,n.generation);if(r!==null){if(n.text.length===0)n.text=r,n.completed=!0,n.completedEpoch=m,yield{type:`assistant-complete`,id:i,text:r};else if(r.startsWith(n.text)){let e=r.slice(n.text.length);e.length>0&&(yield{type:`assistant-delta`,id:i,delta:e}),n.text=r,n.completed=!0,n.completedEpoch=m,yield{type:`assistant-complete`,id:i}}}else n.text.length>0&&(n.completed=!0,n.completedEpoch=m,yield{type:`assistant-complete`,id:i});break}case`reasoning.appended`:{let t=e,n=reasoningPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(f,n),i=t.data.reasoningSoFar;if(r.completed){if(m<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}if(!i.startsWith(r.text)||i.length<=r.text.length)break;let a=i.slice(r.text.length);r.text=i,yield{type:`reasoning-delta`,id:partGenerationId(n,r.generation),delta:a};break}case`reasoning.completed`:{let t=reasoningPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(f,t),r=e.data.reasoning;if(n.completed){if(r.length===0||m<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=m;let e=partGenerationId(t,n.generation);yield{type:`reasoning-delta`,id:e,delta:r},yield{type:`reasoning-complete`,id:e};break}let i=partGenerationId(t,n.generation);if(n.text.length===0&&r.length>0)n.text=r,yield{type:`reasoning-delta`,id:i,delta:r};else if(r.length>0&&!r.startsWith(n.text))break;n.completed=!0,n.completedEpoch=m,yield{type:`reasoning-complete`,id:i};break}case`actions.requested`:{let t=e.data.actions.filter(e=>e.kind===`tool-call`);if(t.length===0)break;for(let e of t)h.has(e.callId)||(h.add(e.callId),yield{type:`tool-call`,toolCallId:e.callId,toolName:e.toolName,input:e.input});break}case`input.requested`:{let t=e.data.requests.filter(e=>e.action.kind===`tool-call`);if(t.length===0)break;for(let e of t){let t=e.action.callId;if(e.kind!==`session-limit`&&!h.has(t)&&(h.add(t),yield{type:`tool-call`,toolCallId:t,toolName:e.action.toolName,input:e.action.input}),!g.has(e.requestId)){if(g.add(e.requestId),n.set(e.requestId,e),e.kind!==`tool-approval`){upsertPendingQuestion(r,e);continue}upsertPendingApproval(r,e),yield{type:`tool-approval-request`,approvalId:e.requestId,toolCallId:t}}}break}case`action.result`:{let t=e;if(t.data.result.kind!==`tool-result`)break;let n=t.data.result.callId;if(!h.has(n))break;switch(t.data.status){case`completed`:yield{type:`tool-result`,toolCallId:n,output:t.data.result.output};break;case`failed`:yield{type:`tool-error`,toolCallId:n,errorText:formatActionResultError(t)};break;case`rejected`:yield{type:`tool-rejected`,toolCallId:n,reason:formatActionResultError(t)};break}break}case`step.failed`:case`turn.failed`:{let t=toFailureEvent(e,_,u);t&&(yield t);break}case`session.failed`:{r.sawSessionFailure=!0,l?.(e);let t=toFailureEvent(e,_,u);t&&(yield t),r.boundaryEvent=e.type,yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m),yield{type:`finish`,usage:b},v=!0;return}case`session.waiting`:case`session.completed`:r.boundaryEvent=e.type,yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m),yield{type:`finish`,usage:b},v=!0;return;case`turn.completed`:y=!0,yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m);break;case`turn.cancelled`:o?.(),yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m),yield{type:`turn-cancelled`};break;case`subagent.called`:i?.(e);break;case`subagent.started`:case`subagent.event`:break;case`subagent.completed`:a?.(e.data.callId);break;case`authorization.required`:s?.(e);break;case`authorization.completed`:c?.(e);break;default:break}v||(yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m),yield{type:`finish`,usage:b})}async function*errorOnlyTUIStream(e){yield{type:`error`,errorText:e.errorText},yield{type:`finish`}}function createTurnState(){return{aborted:!1,pendingApprovals:[],pendingQuestions:[],sawSessionFailure:!1}}function upsertPendingApproval(e,t){let n=toAgentTUIToolApprovalRequest(t),r=e.pendingApprovals.findIndex(e=>e.approvalId===n.approvalId);r===-1?e.pendingApprovals.push(n):e.pendingApprovals[r]=n}function toAgentTUIToolApprovalRequest(e){return{approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,input:e.action.input}}function upsertPendingQuestion(e,t){let n=e.pendingQuestions.findIndex(e=>e.requestId===t.requestId);n===-1?e.pendingQuestions.push(t):e.pendingQuestions[n]=t}function textPartId(e,t){return`text:${e}:${t}`}function reasoningPartId(e,t){return`reasoning:${e}:${t}`}function partStateFor(e,t){let n=e.get(t);return n===void 0&&(n={generation:0,text:``,completed:!1,completedEpoch:0},e.set(t,n)),n}function partGenerationId(e,t){return t===0?e:`${e}#${t}`}function*closeOpenParts(e,t,n){for(let[r,i]of e)i.completed||i.text.length===0||(i.completed=!0,i.completedEpoch=n,yield{type:t,id:partGenerationId(r,i.generation)})}function isPostTurnVisibleEvent(e){switch(e.type){case`actions.requested`:case`authorization.completed`:case`authorization.required`:case`input.requested`:case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:case`result.completed`:case`step.completed`:case`step.failed`:case`step.started`:case`subagent.called`:case`subagent.completed`:case`subagent.event`:case`subagent.started`:case`turn.completed`:case`turn.failed`:return!0;default:return!1}}function formatActionResultError(e){if(e.data.error?.message)return e.data.error.message;let t=e.data.result.output;if(typeof t==`string`)return t;try{return JSON.stringify(t)}catch{return`Tool execution failed.`}}function toFailureEvent(e,t,n){let r=failureKey(e);if(t.has(r))return;t.add(r);let c={type:`error`,errorText:formatFailureMessage(e)},l=n?.(e)??formatFailureHint(e);l!==void 0&&(c.hint=l);let u=formatFailureDetail(e);return u!==void 0&&(c.detail=u),c}function toAgentTUIInputQuestion(e){let t=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,n={requestId:e.requestId,prompt:e.prompt,display:t};return e.options!==void 0&&(n.options=e.options.map(e=>{let t={id:e.id,label:e.label};return e.description!==void 0&&(t.description=e.description),e.style!==void 0&&(t.style=e.style),t})),e.allowFreeform!==void 0&&(n.allowFreeform=e.allowFreeform),n}export{EveTUIRunner,parsePromptCommand};
1
+ import{PROMPT_COMMANDS,formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{pickAgentHeaderTip}from"./agent-header.js";import{failureKey,formatFailureDetail,formatFailureHint,formatFailureMessage,isInterruptedError,localFailureHint}from"./errors.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{createMcpConnectionStatusTracker}from"./mcp-connection-status.js";import{createRemoteConnectionController}from"./remote-connection.js";import{SubagentPump}from"./subagent-pump.js";import{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,orderedSetupIssues,resolveModelProviderState}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{toErrorMessage}from"#shared/errors.js";import"#client/index.js";import{probeAgentInfo}from"#services/dev-client/agent-info-probe.js";import{subscribeDevelopmentSandboxPrewarmLogs}from"#execution/sandbox/development-prewarm.js";import{createEventDeduper}from"#protocol/event-dedupe.js";import{createDevelopmentRuntimeArtifactRefresher}from"#services/dev-client.js";import{devBootPhase}from"#internal/dev-boot-progress.js";async function delayMs(e){await new Promise(t=>{setTimeout(t,e).unref?.()})}function authIssueForStatus(e){if(e===`logged-out`)return LOGIN_SETUP_ISSUE;if(e===`cli-missing`)return CLI_MISSING_SETUP_ISSUE}var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S=!1;#C=new AbortController;#w=!1;#T=[];#E;#D;#O;#k=pickAgentHeaderTip();#A;#j=new Map;#M;#N=new Map;#P=new Set;#F=!1;#I;#L;constructor(t){this.#e=t.session,t.client!==void 0&&(this.#t=t.client),t.lifecycle!==void 0&&(this.#L=t.lifecycle),this.#n=createRenderer(t);let n={formatActionResultError};if(this.#t!==void 0&&(n.client=this.#t),this.#n.subagents!==void 0&&(n.view=this.#n.subagents),this.#M=new SubagentPump(n),this.#r=t.name??`eve`,this.#_=t.withExclusiveTerminal,this.#i=t.tools??`full`,this.#a=t.reasoning??`full`,this.#o=t.subagents??`full`,this.#s=t.connectionAuth??`full`,this.#c=t.assistantResponseStats??`tokensPerSecond`,this.#l=t.contextSize,this.#u=t.formatTransportError??toErrorMessage,t.initialInput!==void 0&&(this.#m=t.initialInput),t.appRoot!==void 0){this.#p=t.appRoot;let e={appRoot:t.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};t.detectProjectIdentity!==void 0&&(e.detectIdentity=t.detectProjectIdentity),this.#D=createVercelStatusTracker(e),t.probeMcpConnection!==void 0&&(this.#O=createMcpConnectionStatusTracker({onChange:()=>{},probe:t.probeMcpConnection}))}if(t.promptCommandHandler!==void 0&&(this.#h=t.promptCommandHandler),this.#g=t.availablePromptCommands??PROMPT_COMMANDS,t.remote!==void 0){if(this.#t===void 0)throw Error(`A remote TUI requires a configured development client.`);this.#v=createRemoteConnectionController({client:this.#t,credentials:t.remote.credentials,target:t.remote.target,onChange:e=>this.#n.setRemoteConnectionStatus?.(e),resolveOidcToken:t.remote.resolveOidcToken,resolveDeployment:t.remote.resolveDeployment})}this.#y=t.bootDetections??BOOT_DETECTIONS,this.#b=t.getVercelAuthStatus??getVercelAuthStatus,t.onBootProgress!==void 0&&(this.#x=t.onBootProgress),t.serverUrl!==void 0&&(this.#f=t.serverUrl),t.serverUrl!==void 0&&t.remote===void 0&&(this.#d=createDevelopmentRuntimeArtifactRefresher({serverUrl:t.serverUrl}))}async#R(){if(this.#f===void 0){this.#B(),await this.#Y(void 0);return}let e;if(this.#v!==void 0){let t=await this.#v.check();t.state===`ready`&&(e=t.info)}else{let t=this.#t;if(t!==void 0)try{let n=await devBootPhase(`connecting to agent`,()=>probeAgentInfo({client:t}),this.#x);n.kind===`ready`&&(e=n.info)}catch{e=void 0}}this.#B();let t=this.#z(e);await this.#Y(t)}#z(e){let t=this.#p===void 0?e:resolveModelProviderState(e,process.env);this.#A=t;let n=this.#f;if(n===void 0)return t;let r={name:this.#r,serverUrl:n};return t!==void 0&&(r.info=t),this.#p!==void 0&&(r.tip=this.#k),this.#n.renderAgentHeader?.(r),t}#B(){let e=this.#x;this.#x=void 0,e?.({type:`before-first-paint`})}async run(){let onStop=()=>this.#n.requestInterrupt?.();this.#L?.signal.aborted===!0?onStop():this.#L?.signal.addEventListener(`abort`,onStop,{once:!0});try{await this.#V()}finally{this.#L?.signal.removeEventListener(`abort`,onStop),this.#S=!0,this.#C.abort(),this.#M.abortAll(),this.#I?.(),this.#I=void 0,this.#n.shutdown?.(),this.#D?.dispose(),this.#O?.dispose(),this.#v?.dispose()}}async#V(){let e=this.#r,r,i,a=!1,o=!1,s=this.#m;await this.#R(),this.#v?.current().connection.state===`auth-required`&&await this.#ie({type:`extension`,name:`vc:login`,argument:``},e,{trigger:`startup`}),this.#$(),this.#D?.refreshIdentity(),this.#O?.refresh();let l=this.#m===void 0?void 0:parsePromptCommand(this.#m);for(l?.type===`extension`&&l.name===`model`&&l.argument===``&&this.#p!==void 0&&this.#h!==void 0&&this.#n.setupFlow!==void 0&&(s=void 0,await this.#ae(e));;){if(this.#L?.signal.aborted===!0||this.#n.exitRequested?.()===!0)return;if(!o){if(r==null){if(!this.#n.readPrompt){if(a)return;throw Error(`No prompt was provided and the renderer does not support prompt input.`)}let t={title:e};s!==void 0&&(t.initialDraft=s,s=void 0);try{r=await this.#W(t)}catch(e){if(isInterruptedError(e))return;throw e}if(r==null)return}let l=parsePromptCommand(r);if(l?.type===`exit`)return;if(l?.type===`new`){if(!await this.#U()){i=void 0,o=!1,r=void 0;continue}i=void 0,o=!1,r=void 0;continue}if(l?.type===`help`){this.#ee(formatPromptCommandHelp(this.#g)),i=void 0,o=!1,r=void 0;continue}if(l?.type===`loglevel`){this.#ee(this.#se(l.argument)),i=void 0,o=!1,r=void 0;continue}if(l?.type===`extension`){try{await this.#ie(l,e,{trigger:`command`})}catch(e){if(isInterruptedError(e))return;throw e}i=void 0,r=void 0,o=!1;continue}a=!0}let l=await this.#G({prompt:o?void 0:r,inputResponses:i}),u=this.#e.state.sessionId;u!==void 0&&this.#n.setSessionId?.(u);let d=r,f=!1;try{for(;;){await this.#n.renderStream(l,{title:e,submittedPrompt:d,continueSession:!!this.#n.readPrompt,tools:this.#i,reasoning:this.#a,subagents:this.#o,connectionAuth:this.#s,assistantResponseStats:this.#c,contextSize:this.#l});let t=l.turnState?.pendingApprovals??[],n=l.turnState?.pendingQuestions??[];if(t.length>0||n.length>0){let a=[];if(t.length>0){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);for(let n of t){let t=await this.#n.readToolApproval(n,{title:e});a.push({requestId:n.approvalId,optionId:t.approved?`approve`:`deny`}),this.#j.delete(n.approvalId)}}if(n.length>0){if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);for(let t of n){let n=toAgentTUIInputQuestion(t),r=await this.#n.readInputQuestion(n,{title:e});if(r===void 0)continue;let i={requestId:t.requestId};r.optionId!==void 0&&(i.optionId=r.optionId),r.text!==void 0&&(i.text=r.text),a.push(i),this.#j.delete(t.requestId)}}if(a.length===0)break;o=!0,i=a,r=void 0,f=!0;break}if(this.#fe(l)){l=this.#q(),d=void 0;continue}if(l.turnState&&l.turnState.boundaryEvent===void 0)if(l.turnState.aborted)this.#F=!0;else{let e=this.#e.state.sessionId;this.#n.renderNotice?.(e?`Lost the event stream — the turn may still be running on the server (session ${e}). Your next message resumes this session; use /cancel to stop the turn.`:`Lost the connection to the running turn.`)}break}}catch(e){if(isInterruptedError(e))return;throw e}if(f)continue;o=!1,i=void 0,r=void 0;let p=l.turnState?.boundaryEvent;!this.#F&&(p===`session.waiting`||p===`session.completed`)&&(r=this.#n.takeQueuedPrompt?.()),this.#F&&(this.#F=!1,this.#H(),l.turnState?.aborted?this.#n.renderNotice?.(`Stopped following the turn and started a new session. Earlier context was cleared; the interrupted turn may still be running on the server.`):this.#n.renderSessionBoundary===void 0?this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`):this.#n.renderSessionBoundary())}}#H(){this.#M.abortAll(),this.#j.clear(),this.#N.clear(),this.#P.clear(),this.#n.setConnectionAuthPendingCount?.(0),this.#t&&(this.#e=this.#t.session()),this.#d?.clear()}async#U(){try{await this.#e.reset()}catch(e){return this.#n.renderNotice?.(`Couldn't reset the session: ${toErrorMessage(e)}`),!1}return this.#H(),this.#n.reset?.(),!0}async#W(e){if(!this.#n.readPrompt)return;let t=this.#n.readPrompt(e),n=this.#d;if(n===void 0)return await t;let r=!1,i=!1,a,refresh=async()=>{if(!(r||i)){i=!0;try{await n.refreshIdle({onRuntimeArtifactsChanged:()=>this.#ue()})}finally{i=!1}}},startRefresh=()=>{if(r||i)return;let e=refresh().finally(()=>{a===e&&(a=void 0)});a=e};startRefresh();let o=setInterval(()=>{startRefresh()},500);o.unref?.();try{return await t}finally{r=!0,clearInterval(o),await a}}async#G(e){let t=new AbortController,n={signal:t.signal};e.prompt!==void 0&&(n.message=e.prompt),e.inputResponses!==void 0&&e.inputResponses.length>0&&(n.inputResponses=e.inputResponses);let r;try{this.#d!==void 0&&await this.#d.refresh({inputResponses:n.inputResponses,message:n.message,onRuntimeArtifactsChanged:()=>this.#ue()}),n.message!==void 0&&(n.inputResponses?.length??0)===0&&this.#n.flushDelayedDevBuildErrors?.(),r=await this.#e.send(n)}catch(e){if(isInterruptedError(e))throw e;return this.#v?.reportFailure(e),this.#F=!0,{events:errorOnlyTUIStream({errorText:this.#u(e)}),turnState:createTurnState()}}return this.#J(r,()=>t.abort())}async#K(e){if(e.cancelInFlight!==!0){e.cancelInFlight=!0;try{for(let t=0;t<8;t+=1){if(e.boundaryEvent!==void 0||e.aborted===!0)return;let t=e.turnId;try{if((await this.#e.cancel(t===void 0?void 0:{turnId:t})).status===`accepted`)return}catch{}await delayMs(250)}}finally{e.cancelInFlight=!1}}}#q(){let e=new AbortController;return this.#J(this.#e.stream({signal:e.signal}),()=>e.abort())}#J(e,t){let n=createTurnState();return{abort:()=>{n.aborted=!0,t()},cancel:()=>{this.#K(n)},events:eveEventsToTUIStream({events:e,pendingInputRequests:this.#j,turnState:n,onSubagentCalled:e=>this.#M.begin(e),onSubagentCompleted:e=>this.#M.settle(e),onTurnCancelled:()=>this.#M.settleAll(),onConnectionAuthRequired:e=>this.#de(e),onConnectionAuthCompleted:e=>this.#pe(e),onTerminalFailure:()=>{this.#F=!0},failureHintOverride:this.#p===void 0?void 0:localFailureHint}),turnState:n}}async#Y(e){if(this.#p===void 0)return;let t={appRoot:this.#p,env:process.env};e!==void 0&&(t.info=e),this.#T=await detectSetupIssues(t,this.#y),this.#n.renderSetupWarning!==void 0&&(this.#X(),this.#Z())}#X(){let e=orderedSetupIssues(this.#T,this.#E);e.length>0?this.#n.renderSetupWarning?.(formatSetupIssuesLine(e)):this.#n.clearSetupWarning?.()}async#Z(){let e=this.#p;if(e===void 0)return;let t;try{t=await this.#b(e,{signal:this.#C.signal})}catch{return}this.#S||this.#w||(this.#E=authIssueForStatus(t),this.#X())}async#Q(e){let t=this.#p;if(t===void 0||this.#n.renderSetupWarning===void 0)return;let n={appRoot:t,env:process.env};e!==void 0&&(n.info=e);try{this.#T=await detectSetupIssues(n,this.#y);let e=await this.#b(t,{signal:this.#C.signal});this.#E=authIssueForStatus(e)}catch{return}this.#S||this.#X()}#$(){this.#p===void 0||this.#n.renderSandboxLog===void 0||this.#I===void 0&&(this.#I=subscribeDevelopmentSandboxPrewarmLogs({appRoot:this.#p,log:e=>this.#n.renderSandboxLog?.(e)}))}#ee(e,t){if(e!==void 0){if(this.#n.renderCommandResult!==void 0){this.#n.renderCommandResult(e,t);return}this.#n.renderNotice?.(e)}}async#te(e,t){let n=this.#h;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r={renderer:this.#n,title:t.title,initialModelStep:t.initialModelStep,remoteConnection:this.#v,withExclusiveTerminal:this.#_},i=this.#O?.current(),a=i!==void 0&&Object.keys(i).length>0?{...r,disabledConnectionReasons:i}:r;return t.keepSetupFlowOpen===!0?await n.handle(e,{...a,keepSetupFlowOpen:!0}):await n.handle(e,a)}#ne(e,t){if(t!==`startup`)return;let n=this.#v?.current().connection.state,r=n===`auth-failed`||n===`unavailable`?`failed`:void 0,i=e.argument.length===0?``:` ${e.argument}`;this.#n.renderCommandInvocation?.(`/${e.name}${i}`,r)}async#re(e){if(e?.kind===`model-access-changed`){this.#D?.applyEffect({kind:`refresh-identity`}),this.#w=!0,await this.#ce();return}e!==void 0&&(this.#D?.applyEffect(e),this.#w=!0,this.#Q(this.#A))}async#ie(e,t,n){let r=await this.#te(e,{initialModelStep:n.initialModelStep,keepSetupFlowOpen:n.keepSetupFlowOpen,title:t});this.#ne(e,n.trigger),this.#ee(r?.message,r?.tone),await this.#re(r?.effect),this.#oe()}async#ae(e){let t=this.#p;if(t===void 0)return;let authStatus=async()=>{try{return await this.#b(t,{signal:this.#C.signal})}catch{return}},n=await authStatus();if(n===`cli-missing`&&(await this.#ie({type:`extension`,name:`vc:install`,argument:``},e,{trigger:`startup`,keepSetupFlowOpen:!0}),n=await authStatus(),n===`cli-missing`)){this.#n.setupFlow?.end();return}if(n===`logged-out`&&(await this.#ie({type:`extension`,name:`vc:login`,argument:``},e,{trigger:`startup`,keepSetupFlowOpen:!0}),n=await authStatus(),n===`cli-missing`||n===`logged-out`)){this.#n.setupFlow?.end();return}await this.#ie({type:`extension`,name:`model`,argument:``},e,{trigger:`startup`,initialModelStep:`provider`}),await this.#ie({type:`extension`,name:`add`,argument:``},e,{trigger:`startup`})}#oe(){let e=this.#v?.current().connection;e?.state!==`ready`||e.info===this.#A||(this.#A=e.info,this.#f!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#r,serverUrl:this.#f}))}#se(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel all|stderr|sandbox|none — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use all, stderr, sandbox, or none.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`stderr`:return`Showing stderr logs only.`;case`sandbox`:return`Showing sandbox logs only.`;case`all`:return`Showing all logs.`}}async#ce(){let e=this.#p;if(e===void 0)return;loadDevelopmentEnvironmentFiles(e);let t=this.#z(await this.#le());this.#Q(t)}async#le(){let e=this.#t;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}async#ue(){let e=this.#A,t=await this.#le();t!==void 0&&this.#z(t),(!this.#n.renderAgentHeader||t===void 0)&&this.#n.renderNotice?.(formatAgentUpdateNotice(e,t))}#de(e){let t={name:e.data.name,description:e.data.description,state:`required`};e.data.authorization!==void 0&&(t.challenge=e.data.authorization),e.data.webhookUrl!==void 0&&(t.webhookUrl=e.data.webhookUrl),this.#N.set(e.data.name,t),this.#me(t)}#fe(e){if(e.turnState?.boundaryEvent!==`session.waiting`)return!1;let t=!1;for(let e of this.#N.values())e.state!==`required`||e.webhookUrl===void 0||(e.state=`pending`,this.#P.add(e.name),this.#me(e),t=!0);return t&&this.#n.setConnectionAuthPendingCount?.(this.#P.size),this.#P.size>0}#pe(e){let t=this.#N.get(e.data.name)??{name:e.data.name,description:``,state:e.data.outcome};t.state=e.data.outcome,e.data.reason!==void 0&&(t.reason=e.data.reason),this.#N.set(e.data.name,t),this.#P.delete(e.data.name),this.#me(t),this.#n.setConnectionAuthPendingCount?.(this.#P.size)}#me(e){let t={name:e.name,description:e.description,state:e.state};e.challenge!==void 0&&(t.challenge=e.challenge),e.reason!==void 0&&(t.reason=e.reason),this.#n.upsertConnectionAuth?.(t)}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,availablePromptCommands:e.availablePromptCommands,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}async function*eveEventsToTUIStream(e){let{events:t,pendingInputRequests:n,turnState:r,onSubagentCalled:i,onSubagentCompleted:a,onTurnCancelled:o,onConnectionAuthRequired:s,onConnectionAuthCompleted:c,onTerminalFailure:l,failureHintOverride:u}=e,d=new Map,f=new Map,p=createEventDeduper(),m=0,h=new Set,g=new Set,_=new Set,v=!1,y=!1,b;for await(let e of t)if(p.admit(e)&&!(y&&isPostTurnVisibleEvent(e)))switch(e.type){case`session.started`:case`message.received`:break;case`turn.started`:r.turnId=e.data.turnId;break;case`step.started`:m+=1,yield{type:`step-start`};break;case`step.completed`:{let t=e;b=t.data.usage,yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m),yield{type:`step-finish`,usage:t.data.usage};break}case`message.appended`:{let t=e,n=textPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(d,n),i=t.data.messageSoFar;if(r.completed){if(m<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}if(!i.startsWith(r.text)||i.length<=r.text.length)break;let a=i.slice(r.text.length);r.text=i,yield{type:`assistant-delta`,id:partGenerationId(n,r.generation),delta:a};break}case`message.completed`:{let t=textPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(d,t),r=e.data.message;if(n.completed){if(r===null||m<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=m,yield{type:`assistant-complete`,id:partGenerationId(t,n.generation),text:r};break}let i=partGenerationId(t,n.generation);if(r!==null){if(n.text.length===0)n.text=r,n.completed=!0,n.completedEpoch=m,yield{type:`assistant-complete`,id:i,text:r};else if(r.startsWith(n.text)){let e=r.slice(n.text.length);e.length>0&&(yield{type:`assistant-delta`,id:i,delta:e}),n.text=r,n.completed=!0,n.completedEpoch=m,yield{type:`assistant-complete`,id:i}}}else n.text.length>0&&(n.completed=!0,n.completedEpoch=m,yield{type:`assistant-complete`,id:i});break}case`reasoning.appended`:{let t=e,n=reasoningPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(f,n),i=t.data.reasoningSoFar;if(r.completed){if(m<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}if(!i.startsWith(r.text)||i.length<=r.text.length)break;let a=i.slice(r.text.length);r.text=i,yield{type:`reasoning-delta`,id:partGenerationId(n,r.generation),delta:a};break}case`reasoning.completed`:{let t=reasoningPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(f,t),r=e.data.reasoning;if(n.completed){if(r.length===0||m<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=m;let e=partGenerationId(t,n.generation);yield{type:`reasoning-delta`,id:e,delta:r},yield{type:`reasoning-complete`,id:e};break}let i=partGenerationId(t,n.generation);if(n.text.length===0&&r.length>0)n.text=r,yield{type:`reasoning-delta`,id:i,delta:r};else if(r.length>0&&!r.startsWith(n.text))break;n.completed=!0,n.completedEpoch=m,yield{type:`reasoning-complete`,id:i};break}case`actions.requested`:{let t=e.data.actions.filter(e=>e.kind===`tool-call`);if(t.length===0)break;for(let e of t)h.has(e.callId)||(h.add(e.callId),yield{type:`tool-call`,toolCallId:e.callId,toolName:e.toolName,input:e.input});break}case`input.requested`:{let t=e.data.requests.filter(e=>e.action.kind===`tool-call`);if(t.length===0)break;for(let e of t){let t=e.action.callId;if(e.kind!==`session-limit`&&!h.has(t)&&(h.add(t),yield{type:`tool-call`,toolCallId:t,toolName:e.action.toolName,input:e.action.input}),!g.has(e.requestId)){if(g.add(e.requestId),n.set(e.requestId,e),e.kind!==`tool-approval`){upsertPendingQuestion(r,e);continue}upsertPendingApproval(r,e),yield{type:`tool-approval-request`,approvalId:e.requestId,toolCallId:t}}}break}case`action.result`:{let t=e;if(t.data.result.kind!==`tool-result`)break;let n=t.data.result.callId;if(!h.has(n))break;switch(t.data.status){case`completed`:yield{type:`tool-result`,toolCallId:n,output:t.data.result.output};break;case`failed`:yield{type:`tool-error`,toolCallId:n,errorText:formatActionResultError(t)};break;case`rejected`:yield{type:`tool-rejected`,toolCallId:n,reason:formatActionResultError(t)};break}break}case`step.failed`:case`turn.failed`:{let t=toFailureEvent(e,_,u);t&&(yield t);break}case`session.failed`:{r.sawSessionFailure=!0,l?.(e);let t=toFailureEvent(e,_,u);t&&(yield t),r.boundaryEvent=e.type,yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m),yield{type:`finish`,usage:b},v=!0;return}case`session.waiting`:case`session.completed`:r.boundaryEvent=e.type,yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m),yield{type:`finish`,usage:b},v=!0;return;case`turn.completed`:y=!0,yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m);break;case`turn.cancelled`:o?.(),yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m),yield{type:`turn-cancelled`};break;case`subagent.called`:i?.(e);break;case`subagent.started`:case`subagent.event`:break;case`subagent.completed`:a?.(e.data.callId);break;case`authorization.required`:s?.(e);break;case`authorization.completed`:c?.(e);break;default:break}v||(yield*closeOpenParts(d,`assistant-complete`,m),yield*closeOpenParts(f,`reasoning-complete`,m),yield{type:`finish`,usage:b})}async function*errorOnlyTUIStream(e){yield{type:`error`,errorText:e.errorText},yield{type:`finish`}}function createTurnState(){return{aborted:!1,pendingApprovals:[],pendingQuestions:[],sawSessionFailure:!1}}function upsertPendingApproval(e,t){let n=toAgentTUIToolApprovalRequest(t),r=e.pendingApprovals.findIndex(e=>e.approvalId===n.approvalId);r===-1?e.pendingApprovals.push(n):e.pendingApprovals[r]=n}function toAgentTUIToolApprovalRequest(e){return{approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,input:e.action.input}}function upsertPendingQuestion(e,t){let n=e.pendingQuestions.findIndex(e=>e.requestId===t.requestId);n===-1?e.pendingQuestions.push(t):e.pendingQuestions[n]=t}function textPartId(e,t){return`text:${e}:${t}`}function reasoningPartId(e,t){return`reasoning:${e}:${t}`}function partStateFor(e,t){let n=e.get(t);return n===void 0&&(n={generation:0,text:``,completed:!1,completedEpoch:0},e.set(t,n)),n}function partGenerationId(e,t){return t===0?e:`${e}#${t}`}function*closeOpenParts(e,t,n){for(let[r,i]of e)i.completed||i.text.length===0||(i.completed=!0,i.completedEpoch=n,yield{type:t,id:partGenerationId(r,i.generation)})}function isPostTurnVisibleEvent(e){switch(e.type){case`actions.requested`:case`authorization.completed`:case`authorization.required`:case`input.requested`:case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:case`result.completed`:case`step.completed`:case`step.failed`:case`step.started`:case`subagent.called`:case`subagent.completed`:case`subagent.event`:case`subagent.started`:case`turn.completed`:case`turn.failed`:return!0;default:return!1}}function formatActionResultError(e){if(e.data.error?.message)return e.data.error.message;let t=e.data.result.output;if(typeof t==`string`)return t;try{return JSON.stringify(t)}catch{return`Tool execution failed.`}}function toFailureEvent(e,t,n){let r=failureKey(e);if(t.has(r))return;t.add(r);let c={type:`error`,errorText:formatFailureMessage(e)},l=n?.(e)??formatFailureHint(e);l!==void 0&&(c.hint=l);let u=formatFailureDetail(e);return u!==void 0&&(c.detail=u),c}function toAgentTUIInputQuestion(e){let t=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,n={requestId:e.requestId,prompt:e.prompt,display:t};return e.options!==void 0&&(n.options=e.options.map(e=>{let t={id:e.id,label:e.label};return e.description!==void 0&&(t.description=e.description),e.style!==void 0&&(t.style=e.style),t})),e.allowFreeform!==void 0&&(n.allowFreeform=e.allowFreeform),n}export{EveTUIRunner,parsePromptCommand};
@@ -1,9 +1,8 @@
1
- import { runChannelsFlow } from "#setup/flows/channels.js";
2
- import { runConnectionsFlow } from "#setup/flows/connections.js";
3
1
  import { runDeployFlow } from "#setup/flows/deploy.js";
4
2
  import { runInstallVercelCliFlow } from "#setup/flows/install-vercel-cli.js";
5
3
  import { runLoginFlow } from "#setup/flows/login.js";
6
4
  import { runModelFlow } from "#setup/flows/model.js";
5
+ import { runRegistryFlow } from "#setup/flows/registry.js";
7
6
  import type { Prompter } from "#setup/prompter.js";
8
7
  import { type TuiPrompterRenderer } from "./tui-prompter.js";
9
8
  import type { PromptCommandExtensionName } from "./prompt-commands.js";
@@ -28,11 +27,7 @@ export declare const SETUP_FLOW_CONFIG: {
28
27
  title: string;
29
28
  indicator: "pulse";
30
29
  };
31
- channels: {
32
- title: string;
33
- indicator: "pulse";
34
- };
35
- connect: {
30
+ add: {
36
31
  title: string;
37
32
  indicator: "pulse";
38
33
  };
@@ -51,7 +46,8 @@ export interface TuiSetupCommandInput {
51
46
  renderer: TuiSetupCommandRenderer;
52
47
  /** Initial model-flow step authorized by the runner's boot evidence. */
53
48
  initialModelStep?: "provider";
54
- disabledConnectionReasons?: Readonly<Record<string, string>>;
49
+ /** Suspends development runtime artifacts while registry installation and setup mutate them. */
50
+ withExclusiveTerminal?<T>(task: () => Promise<T>): Promise<T>;
55
51
  /** Test seam; defaults to the real TUI-native prompter over `renderer`. */
56
52
  createPrompter?: (renderer: TuiPrompterRenderer) => Prompter;
57
53
  /** Test seam; defaults to the real setup flows. */
@@ -62,23 +58,22 @@ export interface TuiSetupFlows {
62
58
  runInstallVercelCliFlow: typeof runInstallVercelCliFlow;
63
59
  runLoginFlow: typeof runLoginFlow;
64
60
  runModelFlow: typeof runModelFlow;
65
- runChannelsFlow: typeof runChannelsFlow;
66
- runConnectionsFlow: typeof runConnectionsFlow;
61
+ runRegistryFlow: typeof runRegistryFlow;
67
62
  runDeployFlow: typeof runDeployFlow;
68
63
  }
69
64
  export interface TuiSetupCommandResult {
70
65
  message: string;
66
+ /** Promotes an outcome to a top-level status. */
67
+ tone?: "success" | "error";
71
68
  /** Keep warning/error lines after the bordered panel closes. */
72
69
  preserveFlowDiagnostics: boolean;
73
70
  /** Status refresh required after the command settles. */
74
71
  effect?: VercelStatusEffect | {
75
- kind: "connection-added";
76
- } | {
77
72
  kind: "model-access-changed";
78
73
  };
79
74
  }
80
75
  /**
81
- * Runs one TUI setup command (/model, /channels, /connect, /deploy) over the
76
+ * Runs one TUI setup command (/model, /add, /deploy) over the
82
77
  * shared setup flows, asking through the TUI's own bordered panel. Never throws:
83
78
  * every outcome — done, cancelled, failed — folds into the returned command
84
79
  * result. Ctrl-C or Esc on the working indicator (no question open) aborts the
@@ -1,2 +1,3 @@
1
- import{createTuiPrompter}from"./tui-prompter.js";import{runDeployFlow}from"#setup/flows/deploy.js";import{WizardCancelledError}from"#setup/step.js";import{runLoginFlow}from"#setup/flows/login.js";import{HumanActionRequiredError}from"#setup/human-action.js";import{runChannelsFlow}from"#setup/flows/channels.js";import{runConnectionsFlow}from"#setup/flows/connections.js";import{runInstallVercelCliFlow}from"#setup/flows/install-vercel-cli.js";import{runModelFlow}from"#setup/flows/model.js";import{runProviderFlow}from"#setup/flows/provider.js";import{openUrl}from"#setup/primitives/open-url.js";import{slackMessageDeepLink}from"#setup/slack-connect.js";const SETUP_FLOW_CONFIG={"vc:install":{title:`Install the Vercel CLI`,indicator:`pulse`},"vc:login":{title:`Log in to Vercel`,indicator:`pulse`},model:{title:`Configure the agent model`,indicator:`pulse`},channels:{title:`Agent channels`,indicator:`pulse`},connect:{title:`Agent connections`,indicator:`pulse`},deploy:{title:`Deploy to Vercel`,indicator:`spinner`}};function muteableRenderer(e,t){return{readSelect:n=>t()?Promise.resolve(void 0):e.readSelect(n),readEditableSelect:n=>t()?Promise.resolve(void 0):e.readEditableSelect(n),readProviderPicker:n=>t()?Promise.resolve(void 0):e.readProviderPicker(n),readModelEditor:n=>t()?Promise.resolve(void 0):e.readModelEditor(n),readText:n=>t()?Promise.resolve(void 0):e.readText(n),readAcknowledge:n=>t()?Promise.resolve():e.readAcknowledge(n),readChoice:n=>t()?{choice:Promise.resolve(void 0),close:()=>{}}:e.readChoice(n),setStatus:n=>{t()||e.setStatus(n)},renderLine:(n,r)=>{(!t()||r===`warning`||r===`error`)&&e.renderLine(n,r)},renderOutput:n=>{t()||e.renderOutput(n)}}}async function runTuiSetupCommand(t){let{command:r}=t,i=!1,a=new AbortController,o=muteableRenderer(t.renderer,()=>i),s=(t.createPrompter??createTuiPrompter)(o),c=t.renderer.waitForInterrupt(),l=Symbol(`interrupted`),u=executeSetupCommand(t,s,o,a.signal);try{let e=await Promise.race([u,c.promise.then(()=>l)]);return e===l?(i=!0,a.abort(new WizardCancelledError),{...await u,message:`/${r} interrupted.`,preserveFlowDiagnostics:!0}):e}finally{c.dispose(),t.renderer.setStatus(void 0)}}async function executeSetupCommand(e,i,u,d){let{command:f,appRoot:p}=e,m={runInstallVercelCliFlow,runLoginFlow,runModelFlow,runChannelsFlow,runConnectionsFlow,runDeployFlow,...e.flows};try{switch(f){case`vc:install`:return installVercelCliResultMessage(await m.runInstallVercelCliFlow({appRoot:p,prompter:i,signal:d}));case`vc:login`:return loginResultMessage(await m.runLoginFlow({appRoot:p,prompter:i,signal:d}));case`model`:{let pickProvider=e=>u.readProviderPicker(e),t={appRoot:p,prompter:i,signal:d,deps:{pickModelSettings:e=>u.readModelEditor(e),runProviderFlow:e=>runProviderFlow({...e,picker:pickProvider})}};e.initialModelStep!==void 0&&(t.initialStep=e.initialModelStep);let n=await m.runModelFlow(t);if(n.kind===`cancelled`)return{message:n.discardedDraft===!0?`/model dismissed. Drafted changes were discarded; Done commits them.`:`/model dismissed.`,preserveFlowDiagnostics:!1};let r=[];n.modelMessage!==void 0&&r.push(n.modelMessage),n.providerOutcome!==void 0&&r.push(providerOutcomeMessage(n.providerOutcome));let a={message:r.join(`
2
- `),preserveFlowDiagnostics:!1};return n.providerOutcome!==void 0&&(a.effect={kind:`model-access-changed`}),a}case`channels`:{let e=await m.runChannelsFlow({appRoot:p,prompter:i,signal:d});switch(e.kind){case`failed`:return pendingChannelsResult(`Channel files changed, but /channels failed: ${e.message}`);case`cancelled`:return{message:`/channels dismissed.`,preserveFlowDiagnostics:!0};case`deploy-and-chat`:return await runDeployAndChat(m,{appRoot:p,prompter:i,signal:d},e.chat);case`done`:return e.addedChannels.length===0?{message:`No channels added.`,preserveFlowDiagnostics:!0}:{message:`Channels added: ${e.addedChannels.join(`, `)} — run /deploy to ship them.`,preserveFlowDiagnostics:!0,effect:{kind:`channels-added`}}}}case`connect`:{let t=await m.runConnectionsFlow({appRoot:p,prompter:i,signal:d,disabledConnectionReasons:e.disabledConnectionReasons});switch(t.kind){case`cancelled`:return{message:`/connect dismissed.`,preserveFlowDiagnostics:!0,effect:{kind:`model-access-changed`}};case`failed`:return{message:t.addedConnections.length===0?`/connect failed: ${t.message}`:`Connection files changed, but /connect failed: ${t.message}`,preserveFlowDiagnostics:!0,effect:t.addedConnections.length===0?{kind:`model-access-changed`}:{kind:`connection-added`}};case`done`:return{message:t.addedConnections.length===0?`No connections added.`:`Connections added: ${t.addedConnections.join(`, `)}.`,preserveFlowDiagnostics:!0,effect:t.addedConnections.length===0?{kind:`model-access-changed`}:{kind:`connection-added`}}}}case`deploy`:{let e=await m.runDeployFlow({appRoot:p,prompter:i,interactive:!0,signal:d});return e.kind===`cancelled`?{message:`/deploy dismissed.`,preserveFlowDiagnostics:!0}:e.kind===`needs-link`?{message:`Not linked to a Vercel project — run /model to connect one first.`,preserveFlowDiagnostics:!0}:{message:e.productionUrl===void 0?`Deployed.`:`Deployed: ${e.productionUrl}`,preserveFlowDiagnostics:!0,effect:{kind:`deployed`}}}}}catch(e){if(e instanceof WizardCancelledError)return{message:`/${f} dismissed.`,preserveFlowDiagnostics:f!==`model`};let t=await vercelCliUpgradeOutcome(e,f,m,{appRoot:p,prompter:i,signal:d});if(t!==void 0)return t;let r=vercelActionOutcome(e,f);return r===void 0?{message:`/${f} failed: ${e instanceof Error?e.message:String(e)}`,preserveFlowDiagnostics:!0}:r}}async function vercelCliUpgradeOutcome(e,t,n,r){if(!(e instanceof HumanActionRequiredError)||e.action.kind!==`vercel-cli-upgrade`)return;let a;try{a=await r.prompter.select({message:`Your Vercel CLI needs an update to list your teams. Upgrade now?`,options:[{value:`upgrade`,label:`Upgrade Vercel CLI`,description:`Run the Vercel CLI's native upgrader`},{value:`later`,label:`Not now`}],initialValue:`upgrade`})}catch{a=`later`}if(a===`later`)return{message:`The Vercel CLI needs an update — run \`vercel upgrade\`, then retry /${t}.`,preserveFlowDiagnostics:!0};let o;try{o=await n.runInstallVercelCliFlow({appRoot:r.appRoot,prompter:r.prompter,signal:r.signal,upgrade:!0})}catch(e){return{message:vercelCliUpgradeFailureMessage(t,errorMessage(e)),preserveFlowDiagnostics:!0}}switch(o.kind){case`installed`:return{message:`Upgraded the Vercel CLI. Retry /${t}.`,preserveFlowDiagnostics:!1};case`failed`:return{message:vercelCliUpgradeFailureMessage(t,o.reason),preserveFlowDiagnostics:!0};case`cancelled`:return{message:`Vercel CLI upgrade cancelled — run \`vercel upgrade\`, then retry /${t}.`,preserveFlowDiagnostics:!0};case`already`:return{message:`The Vercel CLI is already up to date. Retry /${t}.`,preserveFlowDiagnostics:!1}}}function errorMessage(e){let t=(e instanceof Error?e.message:String(e)).replace(/\s+/gu,` `).trim();return t.length<=240?t:`${t.slice(0,239)}…`}function vercelCliUpgradeFailureMessage(e,t){return`Couldn't upgrade the Vercel CLI${t===void 0||t===``?``:` (${t})`} — run \`vercel upgrade\`, then retry /${e}.`}function vercelActionOutcome(e,t){if(!(e instanceof HumanActionRequiredError))return;let n=vercelActionMessage(e.action.kind,t);return n===void 0?void 0:{message:n,preserveFlowDiagnostics:!0}}function vercelActionMessage(e,t){switch(e){case`vercel-login`:return`You're not logged in to Vercel — run /vc:login, then retry /${t}.`;case`vercel-forbidden`:return`Vercel denied access to that team — run /vc:login to re-authenticate (for example to complete SSO), or pick a team you can access, then retry /${t}.`;case`vercel-cli-missing`:return`The Vercel CLI isn't installed — run /vc:install to install it, then retry /${t}.`;case`vercel-cli-upgrade`:return`The Vercel CLI needs an update — run \`vercel upgrade\`, then retry /${t}.`;default:return}}async function runDeployAndChat(e,t,r){let i;try{i=await e.runDeployFlow({...t,interactive:!0})}catch(e){if(e instanceof WizardCancelledError)return pendingChannelsResult(`Channels added, but /deploy was dismissed. Run /deploy to ship them.`);let t=vercelActionOutcome(e,`deploy`);return pendingChannelsResult(t===void 0?`Channels added, but /deploy failed: ${e instanceof Error?e.message:String(e)}`:`Channels added. ${t.message}`)}if(i.kind===`cancelled`)return pendingChannelsResult(`Channels added, but /deploy was dismissed. Run /deploy to ship them.`);if(i.kind===`needs-link`)return pendingChannelsResult(`Channels added, but this directory is not linked to Vercel. Run /model, then /deploy.`);let a=i.productionUrl===void 0?`Deployed.`:`Deployed: ${i.productionUrl}`,o;if(r.chatUrl===void 0)o=`Message your agent in Slack to see it live.`;else{let e=slackMessageDeepLink(r.chatUrl);openUrl(e),o=`Chat with your agent in Slack: ${e}`}return{message:`${a}\n${o}`,preserveFlowDiagnostics:!0,effect:{kind:`deployed`}}}function installVercelCliResultMessage(e){switch(e.kind){case`cancelled`:return{message:`/vc:install dismissed.`,preserveFlowDiagnostics:!1};case`already`:return{message:`The Vercel CLI is already installed.`,preserveFlowDiagnostics:!1};case`failed`:return{message:"Couldn't install the Vercel CLI — install it manually with `npm i -g vercel@latest`.",preserveFlowDiagnostics:!0};case`installed`:return{message:`Installed the Vercel CLI. Run /vc:login next.`,preserveFlowDiagnostics:!1,effect:{kind:`refresh-identity`}}}}function loginResultMessage(e){switch(e.kind){case`cancelled`:return{message:`/vc:login dismissed.`,preserveFlowDiagnostics:!1};case`already`:return{message:`You're already logged in to Vercel.`,preserveFlowDiagnostics:!1};case`cli-missing`:return{message:`The Vercel CLI isn't installed — run /vc:install to install it, then retry /vc:login.`,preserveFlowDiagnostics:!0};case`failed`:return{message:`Vercel login didn't complete — run /vc:login to try again.`,preserveFlowDiagnostics:!0};case`logged-in`:return{message:`Logged in to Vercel.`,preserveFlowDiagnostics:!1,effect:{kind:`refresh-identity`}};case`unavailable`:return{message:`Couldn't reach Vercel — check your connection, then retry /vc:login.`,preserveFlowDiagnostics:!0}}}function pendingChannelsResult(e){return{message:e,preserveFlowDiagnostics:!0,effect:{kind:`channels-added`}}}function providerOutcomeMessage(e){let{resolution:t,status:n}=e;if(n.kind===`gateway-project`)return t===void 0?`Project linked. No model credential found; set AI_GATEWAY_API_KEY in .env.local.`:t.credential===`oidc`?`Project linked. Connected to AI Gateway via VERCEL_OIDC_TOKEN.`:t.shadowedOidc===void 0?`Project linked. Connected to AI Gateway via AI_GATEWAY_API_KEY.`:`Project linked. AI_GATEWAY_API_KEY (${t.source.kind===`shell`?`shell`:t.source.path}) outranks the project's VERCEL_OIDC_TOKEN and stays the active credential — ${t.source.kind===`shell`?`unset it in your shell`:`remove it from ${t.source.path}`} to run on the project.`;if(n.kind===`gateway-key`){let e=n.source.kind===`shell`?`your shell`:n.source.path;return`Connected to AI Gateway via ${n.envKey} in ${e}.`}return`Provider updated — no gateway credential detected; set AI_GATEWAY_API_KEY in .env.local.`}export{SETUP_FLOW_CONFIG,runTuiSetupCommand};
1
+ import{createTuiPrompter}from"./tui-prompter.js";import{runDeployFlow}from"#setup/flows/deploy.js";import{WizardCancelledError}from"#setup/step.js";import{runLoginFlow}from"#setup/flows/login.js";import{HumanActionRequiredError}from"#setup/human-action.js";import{runInstallVercelCliFlow}from"#setup/flows/install-vercel-cli.js";import{runModelFlow}from"#setup/flows/model.js";import{runProviderFlow}from"#setup/flows/provider.js";import{runRegistryFlow}from"#setup/flows/registry.js";const SETUP_FLOW_CONFIG={"vc:install":{title:`Install the Vercel CLI`,indicator:`pulse`},"vc:login":{title:`Log in to Vercel`,indicator:`pulse`},model:{title:`Configure the agent model`,indicator:`pulse`},add:{title:`Add to your agent`,indicator:`pulse`},deploy:{title:`Deploy to Vercel`,indicator:`spinner`}};function muteableRenderer(e,t,n){return{readSelect:n=>t()?Promise.resolve(void 0):e.readSelect(n),readEditableSelect:n=>t()?Promise.resolve(void 0):e.readEditableSelect(n),readProviderPicker:n=>t()?Promise.resolve(void 0):e.readProviderPicker(n),readModelEditor:n=>t()?Promise.resolve(void 0):e.readModelEditor(n),readText:n=>t()?Promise.resolve(void 0):e.readText(n),readAcknowledge:n=>t()?Promise.resolve():e.readAcknowledge(n),readChoice:n=>t()?{choice:Promise.resolve(void 0),close:()=>{}}:e.readChoice(n),setStatus:n=>{t()||e.setStatus(n)},renderLine:(n,r)=>{(!t()||r===`warning`||r===`error`)&&e.renderLine(n,r)},renderOutput:n=>{t()||e.renderOutput(n)},withInheritedStdio:t=>e.withInheritedStdio(t),withExclusiveTerminal:e=>n?.(e)??e()}}async function runTuiSetupCommand(t){let{command:r}=t,i=!1,a=new AbortController,o=muteableRenderer(t.renderer,()=>i,t.withExclusiveTerminal),s=(t.createPrompter??createTuiPrompter)(o),c=t.renderer.waitForInterrupt(),l=Symbol(`interrupted`),u=executeSetupCommand(t,s,o,a.signal);try{let e=await Promise.race([u,c.promise.then(()=>l)]);return e===l?(i=!0,a.abort(new WizardCancelledError),{...await u,message:`/${r} interrupted.`,preserveFlowDiagnostics:!0}):e}finally{c.dispose(),t.renderer.setStatus(void 0)}}async function executeSetupCommand(e,i,l,u){let{command:d,appRoot:f}=e,p={runInstallVercelCliFlow,runLoginFlow,runModelFlow,runRegistryFlow,runDeployFlow,...e.flows};try{switch(d){case`vc:install`:return installVercelCliResultMessage(await p.runInstallVercelCliFlow({appRoot:f,prompter:i,signal:u}));case`vc:login`:return loginResultMessage(await p.runLoginFlow({appRoot:f,prompter:i,signal:u}));case`model`:{let pickProvider=e=>l.readProviderPicker(e),t={appRoot:f,prompter:i,signal:u,deps:{pickModelSettings:e=>l.readModelEditor(e),runProviderFlow:e=>runProviderFlow({...e,picker:pickProvider})}};e.initialModelStep!==void 0&&(t.initialStep=e.initialModelStep);let n=await p.runModelFlow(t);if(n.kind===`cancelled`)return{message:n.discardedDraft===!0?`/model dismissed. Drafted changes were discarded; Done commits them.`:`/model dismissed.`,preserveFlowDiagnostics:!1};let r=[];n.modelMessage!==void 0&&r.push(n.modelMessage),n.providerOutcome!==void 0&&r.push(providerOutcomeMessage(n.providerOutcome));let a={message:r.join(`
2
+ `),preserveFlowDiagnostics:!1};return n.providerOutcome!==void 0&&(a.effect={kind:`model-access-changed`}),a}case`add`:{let e=await p.runRegistryFlow({appRoot:f,prompter:i,signal:u});return e.kind===`cancelled`?{message:`/add dismissed.`,preserveFlowDiagnostics:!0}:e.addedItems.length>0?{message:[`Registry items added: ${e.addedItems.join(`, `)}.`,...e.output??[]].join(`
3
+ `),tone:`success`,preserveFlowDiagnostics:!0}:{message:`No registry items added.`,preserveFlowDiagnostics:!0}}case`deploy`:{let e=await p.runDeployFlow({appRoot:f,prompter:i,interactive:!0,signal:u});return e.kind===`cancelled`?{message:`/deploy dismissed.`,preserveFlowDiagnostics:!0}:e.kind===`needs-link`?{message:`Not linked to a Vercel project — run /model to connect one first.`,preserveFlowDiagnostics:!0}:{message:e.productionUrl===void 0?`Deployed.`:`Deployed: ${e.productionUrl}`,preserveFlowDiagnostics:!0,effect:{kind:`deployed`}}}}}catch(e){if(e instanceof WizardCancelledError)return{message:`/${d} dismissed.`,preserveFlowDiagnostics:d!==`model`};let t=await vercelCliUpgradeOutcome(e,d,p,{appRoot:f,prompter:i,signal:u});if(t!==void 0)return t;let r=vercelActionOutcome(e,d);return r===void 0?{message:`/${d} failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`,preserveFlowDiagnostics:!0}:r}}async function vercelCliUpgradeOutcome(e,t,n,r){if(!(e instanceof HumanActionRequiredError)||e.action.kind!==`vercel-cli-upgrade`)return;let a;try{a=await r.prompter.select({message:`Your Vercel CLI needs an update to list your teams. Upgrade now?`,options:[{value:`upgrade`,label:`Upgrade Vercel CLI`,description:`Run the Vercel CLI's native upgrader`},{value:`later`,label:`Not now`}],initialValue:`upgrade`})}catch{a=`later`}if(a===`later`)return{message:`The Vercel CLI needs an update — run \`vercel upgrade\`, then retry /${t}.`,preserveFlowDiagnostics:!0};let o;try{o=await n.runInstallVercelCliFlow({appRoot:r.appRoot,prompter:r.prompter,signal:r.signal,upgrade:!0})}catch(e){return{message:vercelCliUpgradeFailureMessage(t,errorMessage(e)),preserveFlowDiagnostics:!0}}switch(o.kind){case`installed`:return{message:`Upgraded the Vercel CLI. Retry /${t}.`,preserveFlowDiagnostics:!1};case`failed`:return{message:vercelCliUpgradeFailureMessage(t,o.reason),preserveFlowDiagnostics:!0};case`cancelled`:return{message:`Vercel CLI upgrade cancelled — run \`vercel upgrade\`, then retry /${t}.`,preserveFlowDiagnostics:!0};case`already`:return{message:`The Vercel CLI is already up to date. Retry /${t}.`,preserveFlowDiagnostics:!1}}}function errorMessage(e){let t=(e instanceof Error?e.message:String(e)).replace(/\s+/gu,` `).trim();return t.length<=240?t:`${t.slice(0,239)}…`}function vercelCliUpgradeFailureMessage(e,t){return`Couldn't upgrade the Vercel CLI${t===void 0||t===``?``:` (${t})`} — run \`vercel upgrade\`, then retry /${e}.`}function vercelActionOutcome(e,t){if(!(e instanceof HumanActionRequiredError))return;let n=vercelActionMessage(e.action.kind,t);return n===void 0?void 0:{message:n,preserveFlowDiagnostics:!0}}function vercelActionMessage(e,t){switch(e){case`vercel-login`:return`You're not logged in to Vercel — run /vc:login, then retry /${t}.`;case`vercel-forbidden`:return`Vercel denied access to that team — run /vc:login to re-authenticate (for example to complete SSO), or pick a team you can access, then retry /${t}.`;case`vercel-cli-missing`:return`The Vercel CLI isn't installed — run /vc:install to install it, then retry /${t}.`;case`vercel-cli-upgrade`:return`The Vercel CLI needs an update — run \`vercel upgrade\`, then retry /${t}.`;default:return}}function installVercelCliResultMessage(e){switch(e.kind){case`cancelled`:return{message:`/vc:install dismissed.`,preserveFlowDiagnostics:!1};case`already`:return{message:`The Vercel CLI is already installed.`,preserveFlowDiagnostics:!1};case`failed`:return{message:"Couldn't install the Vercel CLI — install it manually with `npm i -g vercel@latest`.",preserveFlowDiagnostics:!0};case`installed`:return{message:`Installed the Vercel CLI. Run /vc:login next.`,preserveFlowDiagnostics:!1,effect:{kind:`refresh-identity`}}}}function loginResultMessage(e){switch(e.kind){case`cancelled`:return{message:`/vc:login dismissed.`,preserveFlowDiagnostics:!1};case`already`:return{message:`You're already logged in to Vercel.`,preserveFlowDiagnostics:!1};case`cli-missing`:return{message:`The Vercel CLI isn't installed — run /vc:install to install it, then retry /vc:login.`,preserveFlowDiagnostics:!0};case`failed`:return{message:`Vercel login didn't complete — run /vc:login to try again.`,preserveFlowDiagnostics:!0};case`logged-in`:return{message:`Logged in to Vercel.`,preserveFlowDiagnostics:!1,effect:{kind:`refresh-identity`}};case`unavailable`:return{message:`Couldn't reach Vercel — check your connection, then retry /vc:login.`,preserveFlowDiagnostics:!0}}}function providerOutcomeMessage(e){let{resolution:t,status:n}=e;if(n.kind===`gateway-project`)return t===void 0?`Project linked. No model credential found; set AI_GATEWAY_API_KEY in .env.local.`:t.credential===`oidc`?`Project linked. Connected to AI Gateway via VERCEL_OIDC_TOKEN.`:t.shadowedOidc===void 0?`Project linked. Connected to AI Gateway via AI_GATEWAY_API_KEY.`:`Project linked. AI_GATEWAY_API_KEY (${t.source.kind===`shell`?`shell`:t.source.path}) outranks the project's VERCEL_OIDC_TOKEN and stays the active credential — ${t.source.kind===`shell`?`unset it in your shell`:`remove it from ${t.source.path}`} to run on the project.`;if(n.kind===`gateway-key`){let e=n.source.kind===`shell`?`your shell`:n.source.path;return`Connected to AI Gateway via ${n.envKey} in ${e}.`}return`Provider updated — no gateway credential detected; set AI_GATEWAY_API_KEY in .env.local.`}export{SETUP_FLOW_CONFIG,runTuiSetupCommand};
@@ -2,7 +2,7 @@ import type { ChannelSetupChoice, ChannelSetupChoiceOptions } from "#setup/cli/i
2
2
  import type { SearchActionOption } from "#setup/cli/select-state.js";
3
3
  import type { ModelSettingsRequest, ModelSettingsResult } from "#setup/flows/model.js";
4
4
  import type { ProviderPickerChoice, ProviderPickerRequest } from "#setup/flows/provider.js";
5
- import type { SelectNotice } from "#setup/prompter.js";
5
+ import type { SelectMetadata, SelectNotice } from "#setup/prompter.js";
6
6
  import type { SetupPanelOption } from "./setup-panel.js";
7
7
  export type SetupEditableSelectResult = {
8
8
  kind: "selected";
@@ -22,6 +22,8 @@ export type SetupFlowStatus = string | {
22
22
  };
23
23
  interface SetupSelectRequestBase {
24
24
  message: string;
25
+ description?: string;
26
+ metadata?: readonly SelectMetadata[];
25
27
  options: readonly SetupPanelOption[];
26
28
  notices?: readonly SelectNotice[];
27
29
  }
@@ -100,18 +102,25 @@ export interface SetupFlowRenderer {
100
102
  setStatus(status: SetupFlowStatus | undefined): void;
101
103
  renderLine(text: string, tone: "info" | "success" | "warning" | "error"): void;
102
104
  renderOutput(text: string): void;
105
+ /** Temporarily restores the terminal while a child process inherits stdio. */
106
+ withInheritedStdio<T>(task: () => Promise<T>): Promise<T>;
107
+ /** Gives a setup subprocess exclusive terminal and development-host ownership. */
108
+ withExclusiveTerminal?<T>(task: () => Promise<T>): Promise<T>;
103
109
  /**
104
110
  * Arms a key trap for the flow's working state — the status indicator between
105
111
  * questions, where no prompt is consuming keys. Ctrl-C or Esc resolves the
106
112
  * promise so the command can abandon an in-flight flow (e.g. a parked
107
113
  * `vercel connect create` browser OAuth). Open questions own their keys; the
108
- * trap covers only the gaps. `dispose` releases the trap; the promise then
109
- * never resolves.
114
+ * trap covers only the gaps. `interruptible: false` still consumes and
115
+ * discards input but does not cancel non-abortable work. `dispose` releases
116
+ * the trap; the promise then never resolves.
110
117
  */
111
- waitForInterrupt(): {
118
+ waitForInterrupt(options?: {
119
+ interruptible?: boolean;
120
+ }): {
112
121
  promise: Promise<void>;
113
122
  dispose(): void;
114
123
  };
115
124
  }
116
- export type SetupFlowPrompterRenderer = Pick<SetupFlowRenderer, "readSelect" | "readEditableSelect" | "readText" | "readAcknowledge" | "readChoice" | "setStatus" | "renderLine" | "renderOutput">;
125
+ export type SetupFlowPrompterRenderer = Pick<SetupFlowRenderer, "readSelect" | "readEditableSelect" | "readText" | "readAcknowledge" | "readChoice" | "setStatus" | "renderLine" | "renderOutput" | "withInheritedStdio" | "withExclusiveTerminal">;
117
126
  export {};
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import type { ChannelSetupAction, PromptOption } from "#setup/cli/index.js";
17
17
  import { type SearchActionOption, type SelectState } from "#setup/cli/select-state.js";
18
- import type { SelectNotice } from "#setup/prompter.js";
18
+ import type { SelectMetadata, SelectNotice } from "#setup/prompter.js";
19
19
  import type { ModelSettingsRequest } from "#setup/flows/model.js";
20
20
  import { type ModelEditorState } from "./model-editor.js";
21
21
  import type { ProviderPickerPhase } from "./provider-picker.js";
@@ -25,6 +25,10 @@ import type { Theme } from "./theme.js";
25
25
  export type SetupPanelOption = PromptOption<string>;
26
26
  interface SetupQuestionPanelBase {
27
27
  message: string;
28
+ /** Inert context rendered beneath the heading and above the controls. */
29
+ description?: string;
30
+ /** Labeled facts rendered beneath the description and above the controls. */
31
+ metadata?: readonly SelectMetadata[];
28
32
  error?: string;
29
33
  /** Outcome lines from earlier menu laps, shown beneath the options. */
30
34
  notices?: readonly SelectNotice[];
@@ -1,4 +1,4 @@
1
- import{maskLine,visibleLine}from"./line-editor.js";import{modelEditorMenuRows,reasoningPositions}from"./model-editor.js";import{clipVisible,renderInputText,renderInputWithBlockCursor,visibleLength,wrapVisibleLine}from"#cli/ui/terminal-text.js";import{renderCursorRow,renderOptionRow,renderOptionRowContinuation,resolveOptionRowState}from"#setup/cli/option-row.js";import{filterOptions,submitRowIndex}from"#setup/cli/select-state.js";function clip(e,t){return clipVisible(e,t)}function questionFooter(e,t){let n=t.colors;return[``,` ${n.dim(n.italic(e.join(` ${t.glyph.dot} `)))}`]}const BOLD_OR_DIM_CLOSE=`\x1B[22m`,DIM_OPEN=`\x1B[2m`,ANSI_FOREGROUND_COLOR=RegExp(`\x1B\\[(?:3[0-9]|9[0-7])m`,`g`);function dimWithEmphasis(e,t){return t.colors.dim(e.replaceAll(BOLD_OR_DIM_CLOSE,`${BOLD_OR_DIM_CLOSE}${DIM_OPEN}`))}function solidWithinDim(e,t){return t.color?`${BOLD_OR_DIM_CLOSE}${e}${DIM_OPEN}`:e}function foregroundWithEmphasis(e){let t=!1;return e.replaceAll(DIM_OPEN,``).replace(ANSI_FOREGROUND_COLOR,e=>e===`\x1B[34m`?(t=!0,e):e===`\x1B[39m`&&t?(t=!1,e):``)}function toneGlyph(e,t){let n=t.colors;switch(e){case`success`:return n.green(t.glyph.success);case`warning`:return n.yellow(t.glyph.warning);case`error`:return n.red(t.glyph.error);case`info`:return n.dim(t.glyph.dot)}}function renderIndicator(e,t){return e.color===`green`?t.colors.green(e.glyph):t.colors.yellow(e.glyph)}function renderStatusText(e,t){if(e.kind===`progress`)return t.colors.dim(e.text);let n=e.text.indexOf(e.emphasis);if(n===-1)return t.colors.dim(e.text);let r=n+e.emphasis.length;return`${t.colors.dim(e.text.slice(0,n))}${t.colors.yellow(e.text.slice(n,r))}${t.colors.dim(e.text.slice(r))}`}function renderFlowPanelStatus(e,t){return`${renderIndicator(e.indicator,t)} ${renderStatusText(e,t)}`}function renderFlowPanel(e,t,n){let r=t.colors,i=[r.dim(t.glyph.hrule.repeat(Math.max(1,n)))];e.title.length>0&&i.push(` ${r.bold(e.title)}`),i.push(``);let a=e.lines.slice(-6);for(let e of a){let n=e.tone===`info`?r.dim(e.text):e.text;i.push(` ${toneGlyph(e.tone,t)} ${n}`)}switch(a.length>0&&i.push(``),e.content.kind){case`question`:e.content.status!==void 0&&i.push(` ${renderFlowPanelStatus(e.content.status,t)}`,``),i.push(...e.content.rows);break;case`status`:i.push(` ${renderFlowPanelStatus(e.content.status,t)}`),e.content.preview!==void 0&&i.push(` ${r.dim(e.content.preview)}`);break;case`preview`:i.push(` ${renderIndicator(e.content.indicator,t)} ${r.dim(e.content.text)}`);break;case`idle`:i.push(` ${renderIndicator(e.content.indicator,t)} ${r.dim(`Working…`)}`);break}return i.map((e,t)=>t===0||e.length===0?clip(e,n):clip(` ${e}`,n))}function optionRow(e){let{option:t,theme:n}=e,r=e.railed===!0;return renderOptionRow({colors:n.colors,glyphs:{pointer:n.glyph.pointer,selectedPointer:n.glyph.selectedPointer,success:n.glyph.success,placeholder:r?n.glyph.caret:n.glyph.option,dot:r?``:n.glyph.dot,warning:n.glyph.warning},label:t.label,hint:t.hint,focusHint:t.focusHint,accent:t.accent,isCursor:e.isCursor,state:resolveOptionRowState(t,e.isChecked),placeholder:e.placeholder,hintPadding:e.hintPadding})}function selectPresentation(e){switch(e.kind){case`single`:return{selection:`single`,filter:void 0,layout:`plain`,edit:void 0};case`search`:return{selection:`single`,filter:{placeholder:e.placeholder},layout:e.layout??`plain`,edit:void 0};case`multi`:return{selection:`multiple`,filter:void 0,layout:`plain`,edit:void 0};case`searchable-multi`:return{selection:`multiple`,filter:{placeholder:e.placeholder},layout:`plain`,edit:void 0};case`stacked`:return{selection:`single`,filter:void 0,layout:`stacked`,edit:void 0};case`task-list`:return{selection:`single`,filter:void 0,layout:`task-list`,edit:void 0};case`inline-edit`:return{selection:`single`,filter:void 0,layout:e.layout,edit:e.edit}}}function selectMessageRows(e,t,n){if(e===``)return[];let r=e.split(`
1
+ import{maskLine,visibleLine}from"./line-editor.js";import{modelEditorMenuRows,reasoningPositions}from"./model-editor.js";import{clipVisible,renderInputText,renderInputWithBlockCursor,visibleLength,wrapVisibleLine}from"#cli/ui/terminal-text.js";import{renderCursorRow,renderOptionRow,renderOptionRowContinuation,resolveOptionRowState}from"#setup/cli/option-row.js";import{filterOptions,submitRowIndex}from"#setup/cli/select-state.js";function clip(e,t){return clipVisible(e,t)}function questionFooter(e,t){let n=t.colors;return[``,` ${n.dim(n.italic(e.join(` ${t.glyph.dot} `)))}`]}const BOLD_OR_DIM_CLOSE=`\x1B[22m`,DIM_OPEN=`\x1B[2m`,ANSI_FOREGROUND_COLOR=RegExp(`\x1B\\[(?:3[0-9]|9[0-7])m`,`g`);function dimWithEmphasis(e,t){return t.colors.dim(e.replaceAll(BOLD_OR_DIM_CLOSE,`${BOLD_OR_DIM_CLOSE}${DIM_OPEN}`))}function solidWithinDim(e,t){return t.color?`${BOLD_OR_DIM_CLOSE}${e}${DIM_OPEN}`:e}function foregroundWithEmphasis(e){let t=!1;return e.replaceAll(DIM_OPEN,``).replace(ANSI_FOREGROUND_COLOR,e=>e===`\x1B[34m`?(t=!0,e):e===`\x1B[39m`&&t?(t=!1,e):``)}function toneGlyph(e,t){let n=t.colors;switch(e){case`success`:return n.green(t.glyph.success);case`warning`:return n.yellow(t.glyph.warning);case`error`:return n.red(t.glyph.error);case`info`:return n.dim(t.glyph.dot)}}function renderIndicator(e,t){return e.color===`green`?t.colors.green(e.glyph):t.colors.yellow(e.glyph)}function renderStatusText(e,t){if(e.kind===`progress`)return t.colors.dim(e.text);let n=e.text.indexOf(e.emphasis);if(n===-1)return t.colors.dim(e.text);let r=n+e.emphasis.length;return`${t.colors.dim(e.text.slice(0,n))}${t.colors.yellow(e.text.slice(n,r))}${t.colors.dim(e.text.slice(r))}`}function renderFlowPanelStatus(e,t){return`${renderIndicator(e.indicator,t)} ${renderStatusText(e,t)}`}function renderFlowPanel(e,t,n){let r=t.colors,i=[r.dim(t.glyph.hrule.repeat(Math.max(1,n-1)))];e.title.length>0&&i.push(` ${r.bold(e.title)}`),i.push(``);let a=e.lines.slice(-6);for(let e of a){let n=e.tone===`info`?r.dim(e.text):e.text;i.push(` ${toneGlyph(e.tone,t)} ${n}`)}switch(a.length>0&&i.push(``),e.content.kind){case`question`:e.content.status!==void 0&&i.push(` ${renderFlowPanelStatus(e.content.status,t)}`,``),i.push(...e.content.rows);break;case`status`:i.push(` ${renderFlowPanelStatus(e.content.status,t)}`),e.content.preview!==void 0&&i.push(` ${r.dim(e.content.preview)}`);break;case`preview`:i.push(` ${renderIndicator(e.content.indicator,t)} ${r.dim(e.content.text)}`);break;case`idle`:i.push(` ${renderIndicator(e.content.indicator,t)} ${r.dim(`Working…`)}`);break}return i.map((e,t)=>t===0||e.length===0?clip(e,n):clip(` ${e}`,n))}function optionRow(e){let{option:t,theme:n}=e,r=e.railed===!0;return renderOptionRow({colors:n.colors,glyphs:{pointer:n.glyph.pointer,selectedPointer:n.glyph.selectedPointer,success:n.glyph.success,placeholder:r?n.glyph.caret:n.glyph.option,dot:r?``:n.glyph.dot,warning:n.glyph.warning},label:t.label,hint:t.hint,focusHint:t.focusHint,accent:t.accent,isCursor:e.isCursor,state:resolveOptionRowState(t,e.isChecked),placeholder:e.placeholder,hintPadding:e.hintPadding})}function selectPresentation(e){switch(e.kind){case`single`:return{selection:`single`,filter:void 0,layout:`plain`,edit:void 0};case`search`:return{selection:`single`,filter:{placeholder:e.placeholder},layout:e.layout??`plain`,edit:void 0};case`multi`:return{selection:`multiple`,filter:void 0,layout:`plain`,edit:void 0};case`searchable-multi`:return{selection:`multiple`,filter:{placeholder:e.placeholder},layout:`plain`,edit:void 0};case`stacked`:return{selection:`single`,filter:void 0,layout:`stacked`,edit:void 0};case`task-list`:return{selection:`single`,filter:void 0,layout:`task-list`,edit:void 0};case`inline-edit`:return{selection:`single`,filter:void 0,layout:e.layout,edit:e.edit}}}function selectMessageRows(e,t,n){if(e===``)return[];let r=e.split(`
2
2
  `).map((e,r)=>` ${t===`stacked`||r>0?n.colors.bold(e):e}`);return r.push(``),r}function searchFilter(e,t,n,r,i){let a=r.colors.dim(r.glyph.caret),o=a;return i?o=`${a} ${e.length>0?e+a:r.colors.dim(t??`type to search`)}`:e.length>0?o=e+a:t!==void 0&&(o=r.colors.dim(`> ${t}`)),n===void 0?o:`${o} ${r.colors.yellow(n)}`}function isRailedSearch(e){return e.filter!==void 0&&e.layout===`plain`&&e.selection===`single`&&e.edit===void 0}function selectViewSize(e){return e.search?e.railed?5:e.filter===``&&e.featuredLead>0?Math.min(e.featuredLead,8):8:e.optionCount}function noticeBody(e,t,n){return e.tone===`info`?n.colors.dim(e.text):e.tone===`success`&&t===`task-list`?n.colors.bold(e.text):e.text}function renameHint(e,n,r,i){let a=renderInputWithBlockCursor({...visibleLine({text:r.editor.text||r.defaultValue,cursor:r.editor.cursor},1/0),visible:n,inverse:i.colors.inverse});return r.editor.text.length>0&&(a=solidWithinDim(a,i)),{...e,hint:r.formatHint(a)}}function keyHint(n,r,i,c,l){let u=i.phase;if(u.kind===`inactive`)return n;let d=c.colors,f=maskLine(u.editor),p=u.kind!==`validating`&&u.kind!==`invalid`,m=``;u.kind===`editing`?m=` ${enterBadge(c,`validate`)}`:u.kind===`validating`?m=` ${d.yellow(c.glyph.validating)} ${d.dim(`validating`)}`:u.kind===`invalid`&&(m=` ${d.red(`${c.glyph.error} API key is not valid`)}`);let h=`${c.glyph.elbow} `,g=u.editor.text.length===0?`type your key`:void 0,_=visibleLine(g===void 0?f:{text:g,cursor:0},Math.max(1,l-visibleLength(`${h}${m}`)),c.glyph.ellipsis),v=p?renderInputWithBlockCursor({..._,visible:r,inverse:c.colors.inverse}):renderInputText(`${_.before}${_.under}${_.after}`);return{...n,hint:`${h}${v}${m}`}}function inlineEditOption(e,t,n,r,i){if(!t||n===void 0||e.value!==n.optionValue)return e;switch(n.editor.kind){case`rename`:return renameHint(e,n.caretVisible,n.editor,r);case`key`:return keyHint(e,n.caretVisible,n.editor,r,i)}}function optionWithoutStackedHint(e,t){if(t!==`stacked`||e.hint===void 0)return{option:e,stackedHint:void 0};let{hint:n,...r}=e;return{option:r,stackedHint:n}}function optionUsesPlaceholder(e,t){let n=e.filter!==void 0&&e.layout!==`task-list`,r=e.selection===`multiple`,i=e.layout!==`plain`;return!n&&!t&&(r||i)}function appendSelectOptionRows(e){let{rows:t,state:n,presentation:r,visible:i,start:a,end:o,cursor:s,visibleLabelWidth:c,width:l,theme:u}=e,f=u.colors,p=!1;for(let e=a;e<o;e+=1){let m=i[e],h=e===s,g=r.layout===`task-list`&&m.trailingAction===!0;g&&(appendSelectNotices(t,n.notices,r.layout,u,l),p=!0),g&&(e>a||(n.notices?.length??0)>0)&&t.push(``);let _=r.layout===`stacked`?Math.max(1,l-6):Math.max(1,l-Math.max(c,m.label.length)-9),{option:v,stackedHint:y}=optionWithoutStackedHint(inlineEditOption(m,h,r.edit,u,_),r.layout),b=isRailedSearch(r),x=n.cursorBadge??(b&&!g?enterBadge(u):void 0),S=h&&x!==void 0?` ${x}`:``;if(t.push(` ${optionRow({option:v,isCursor:h,isChecked:r.selection===`multiple`?n.select.selected.has(m.value):m.checked===!0,placeholder:b||optionUsesPlaceholder(r,g),railed:b,hintPadding:Math.max(0,c-v.label.length),theme:u})}${S}`),y!==void 0){let e=r.edit,n=h&&e!==void 0&&e.optionValue===m.value&&e.editor.kind===`key`&&e.editor.phase.kind!==`inactive`;for(let e of y.split(`
3
- `)){let r=h?n?e:foregroundWithEmphasis(e):dimWithEmphasis(e,u);t.push(` ${renderOptionRowContinuation(r)}`)}}m.description!==void 0&&(m.disabled===!0||h)&&t.push(` ${renderOptionRowContinuation(f.dim(m.description))}`),r.layout===`stacked`&&e<o-1&&t.push(``)}return p}function appendSubmitRow(e,t,n,r){if(n<0)return;let i=t===n,a=i?`${r.glyph.selectedPointer} ${r.colors.bold(`Submit`)}`:` Submit`;e.push(``,` ${renderCursorRow(a,i,r.colors)}`)}function appendSelectNotices(e,t,n,r,i){if(!(t===void 0||t.length===0)){e.push(``);for(let a of t){let t=toneGlyph(a.tone,r),o=` `.repeat(visibleLength(t)+1),l=Math.max(1,i-2-visibleLength(t)-1),u=wrapVisibleLine(a.text,l);for(let[i,s]of u.entries()){let c=noticeBody({...a,text:s},n,r);e.push(i===0?` ${t} ${c}`:` ${o}${c}`)}}}}function selectFooterHints(e,t,n){let r=[],i=`esc to cancel`,a=e.edit;if(a!==void 0&&t[n]?.value===a.optionValue)if(a.editor.kind===`key`){let e=a.editor.phase;if(e.kind!==`inactive`&&e.editor.text.length>0&&(i=`esc to clear`),e.kind===`validating`)return[i];r.push(`type your key`)}else r.push(`type to rename`);return e.filter!==void 0&&r.push(`type to filter`),r.push(`↑/↓ move`),r.push(e.selection===`multiple`?`space to toggle`:`enter to select`),e.selection===`multiple`&&r.push(`enter on Submit to confirm`),r.push(i),r}function renderActionQuestion(e,t,n){let r=[` ${t.colors.dim(`${t.glyph.dot} ${e.context}`)}`,``];for(let[n,i]of e.actions.entries())r.push(` ${optionRow({option:i,isCursor:n===e.cursor,isChecked:!1,placeholder:!0,hintPadding:0,theme:t})}`);return r.push(...questionFooter([`↑/↓ move`,`enter to select`,`esc to cancel`],t)),r.map(e=>clip(e,n))}function renderSelectQuestion(e,t,n){if(e.kind===`actions`)return renderActionQuestion(e,t,n);let r=t.colors,i=selectPresentation(e),a=i.filter?filterOptions(e.options,e.select.filter,e.searchAction):e.options,o=i.selection===`multiple`?submitRowIndex(a):-1,s=e.select.cursor,c=isRailedSearch(i),l=selectMessageRows(e.message,i.layout,t);i.filter!==void 0&&l.push(` ${c?` `:``}${searchFilter(e.select.filter,i.filter.placeholder,e.loadingFrame,t,c)}`);let u=0;for(;a[u]?.featured;)u+=1;let d=selectViewSize({search:i.filter!==void 0,filter:e.select.filter,featuredLead:u,optionCount:a.length,railed:c}),f=Math.max(0,Math.min(s-Math.floor(d/2),Math.max(0,a.length-d))),h=Math.min(f+d,a.length),g=a.slice(f,h).filter(e=>e.hint!==void 0||e.focusHint!==void 0).reduce((e,t)=>Math.max(e,t.label.length),0);a.length===0&&l.push(` ${r.dim(`(no matches)`)}`);let _=appendSelectOptionRows({rows:l,state:e,presentation:i,visible:a,start:f,end:h,cursor:s,visibleLabelWidth:g,width:n,theme:t});return appendSubmitRow(l,s,o,t),!c&&a.length>h-f&&l.push(` ${r.dim(`↑↓ ${a.length} options, showing ${f+1}–${h}`)}`),_||appendSelectNotices(l,e.notices,i.layout,t,n),e.error!==void 0&&l.push(``,` ${r.red(e.error)}`),l.push(...questionFooter(c?[`esc to cancel`]:selectFooterHints(i,a,s),t)),l.map(e=>clip(e,n))}function enterBadge(e,t){return e.colors.dim(t===void 0?e.glyph.enter:`${e.glyph.enter} ${t}`)}function reasoningTrack(e){let{count:t,index:n,theme:r}=e,i=r.glyph,a=i.trackLine.repeat(e.connectorWidth),o=[];for(let e=0;e<t;e+=1)e>0&&o.push(a),o.push(e<n?i.trackFilled:e===n?i.trackCurrent:i.trackEmpty);if(!e.accent||n<0)return o.join(``);let s=o.slice(0,2*n+1).join(``);return`${r.colors.blue(s)}${o.slice(2*n+1).join(``)}`}function renderModelEditorQuestion(e,t,n){let{request:r,state:i}=e;switch(i.screen.kind){case`menu`:return renderModelEditorMenu(e,i.screen.cursor,t,n);case`model`:return renderModelEditorModelScreen(r,i.screen.select,t,n)}}function renderModelEditorMenu(e,t,i,a){let{request:o,state:s}=e,{draft:c}=s,l=modelEditorMenuRows(o,c,s.capabilities).map(e=>{if(e.disabled===!0&&e.value===`model`)return c.modelId===null?{...e}:{...e,hint:c.modelId};if(e.disabled===!0||e.value===`done`)return{...e};switch(e.value){case`model`:return{...e,hint:c.modelId??void 0};case`reasoning`:{let n=reasoningPositions(s.capabilities,c.reasoning),a=c.reasoning==="default"?-1:n.indexOf(c.reasoning),o=reasoningTrack({count:n.length,index:a,connectorWidth:1,accent:e.value===t,theme:i}),l=c.reasoning==="default"?`provider default`:c.reasoning;return{...e,hint:`${o} ${l}`}}case`tier`:return{...e,hint:c.tier===`priority`?`fast ${i.glyph.fast}`:`normal`};default:return{...e}}});return renderSelectQuestion({kind:`stacked`,message:``,options:l,select:{filter:``,cursor:Math.max(0,l.findIndex(e=>e.value===t)),selected:new Set}},i,a)}function renderModelEditorModelScreen(e,t,n,r){return renderSelectQuestion({kind:`search`,message:`Select the model`,options:e.model.kind===`pick`?e.model.options:[],placeholder:`type to search`,select:t},n,r)}function renderTextQuestion(n,r,i,s){let c=r.colors,l=[];for(let e of n.notices??[]){let t=e.tone===`info`?c.dim(e.text):e.text;l.push(`${toneGlyph(e.tone,r)} ${t}`)}l.push(...n.message.split(`
3
+ `)){let r=h?n?e:foregroundWithEmphasis(e):dimWithEmphasis(e,u);t.push(` ${renderOptionRowContinuation(r)}`)}}m.description!==void 0&&(m.disabled===!0||h)&&t.push(` ${renderOptionRowContinuation(f.dim(m.description))}`),r.layout===`stacked`&&e<o-1&&t.push(``)}return p}function appendSubmitRow(e,t,n,r){if(n<0)return;let i=t===n,a=i?`${r.glyph.selectedPointer} ${r.colors.bold(`Submit`)}`:` Submit`;e.push(``,` ${renderCursorRow(a,i,r.colors)}`)}function appendSelectNotices(e,t,n,r,i){if(!(t===void 0||t.length===0)){e.push(``);for(let a of t){let t=toneGlyph(a.tone,r),o=` `.repeat(visibleLength(t)+1),l=Math.max(1,i-2-visibleLength(t)-1),u=wrapVisibleLine(a.text,l);for(let[i,s]of u.entries()){let c=noticeBody({...a,text:s},n,r);e.push(i===0?` ${t} ${c}`:` ${o}${c}`)}}}}function selectFooterHints(e,t,n){let r=[],i=`esc to cancel`,a=e.edit;if(a!==void 0&&t[n]?.value===a.optionValue)if(a.editor.kind===`key`){let e=a.editor.phase;if(e.kind!==`inactive`&&e.editor.text.length>0&&(i=`esc to clear`),e.kind===`validating`)return[i];r.push(`type your key`)}else r.push(`type to rename`);return e.filter!==void 0&&r.push(`type to filter`),r.push(`↑/↓ move`),r.push(e.selection===`multiple`?`space to toggle`:`enter to select`),e.selection===`multiple`&&r.push(`enter on Submit to confirm`),r.push(i),r}function renderActionQuestion(e,t,n){let r=[` ${t.colors.dim(`${t.glyph.dot} ${e.context}`)}`,``];for(let[n,i]of e.actions.entries())r.push(` ${optionRow({option:i,isCursor:n===e.cursor,isChecked:!1,placeholder:!0,hintPadding:0,theme:t})}`);return r.push(...questionFooter([`↑/↓ move`,`enter to select`,`esc to cancel`],t)),r.map(e=>clip(e,n))}function renderSelectQuestion(e,t,n){if(e.kind===`actions`)return renderActionQuestion(e,t,n);let r=t.colors,i=selectPresentation(e),a=i.filter?filterOptions(e.options,e.select.filter,e.searchAction):e.options,o=i.selection===`multiple`?submitRowIndex(a):-1,s=e.select.cursor,l=isRailedSearch(i),u=selectMessageRows(e.message,i.layout,t);if(e.description!==void 0||e.metadata!==void 0){if(u.at(-1)===``&&u.pop(),e.description!==void 0)for(let t of wrapVisibleLine(e.description,Math.max(1,n-4)))u.push(` ${r.dim(t)}`);for(let{label:t,value:i}of e.metadata??[]){let e=`${t}: `,a=wrapVisibleLine(i,Math.max(1,n-4-e.length));u.push(` ${r.dim(`${e}${a[0]??``}`)}`);for(let t of a.slice(1))u.push(` ${r.dim(`${` `.repeat(e.length)}${t}`)}`)}u.push(``)}i.filter!==void 0&&u.push(` ${l?` `:``}${searchFilter(e.select.filter,i.filter.placeholder,e.loadingFrame,t,l)}`);let d=0;for(;a[d]?.featured;)d+=1;let f=selectViewSize({search:i.filter!==void 0,filter:e.select.filter,featuredLead:d,optionCount:a.length,railed:l}),h=Math.max(0,Math.min(s-Math.floor(f/2),Math.max(0,a.length-f))),g=Math.min(h+f,a.length),_=a.slice(h,g).filter(e=>e.hint!==void 0||e.focusHint!==void 0).reduce((e,t)=>Math.max(e,t.label.length),0);a.length===0&&u.push(` ${r.dim(`(no matches)`)}`);let v=appendSelectOptionRows({rows:u,state:e,presentation:i,visible:a,start:h,end:g,cursor:s,visibleLabelWidth:_,width:n,theme:t});return appendSubmitRow(u,s,o,t),!l&&a.length>g-h&&u.push(` ${r.dim(`↑↓ ${a.length} options, showing ${h+1}–${g}`)}`),v||appendSelectNotices(u,e.notices,i.layout,t,n),e.error!==void 0&&u.push(``,` ${r.red(e.error)}`),u.push(...questionFooter(l?[`esc to cancel`]:selectFooterHints(i,a,s),t)),u.map(e=>clip(e,n))}function enterBadge(e,t){return e.colors.dim(t===void 0?e.glyph.enter:`${e.glyph.enter} ${t}`)}function reasoningTrack(e){let{count:t,index:n,theme:r}=e,i=r.glyph,a=i.trackLine.repeat(e.connectorWidth),o=[];for(let e=0;e<t;e+=1)e>0&&o.push(a),o.push(e<n?i.trackFilled:e===n?i.trackCurrent:i.trackEmpty);if(!e.accent||n<0)return o.join(``);let s=o.slice(0,2*n+1).join(``);return`${r.colors.blue(s)}${o.slice(2*n+1).join(``)}`}function renderModelEditorQuestion(e,t,n){let{request:r,state:i}=e;switch(i.screen.kind){case`menu`:return renderModelEditorMenu(e,i.screen.cursor,t,n);case`model`:return renderModelEditorModelScreen(r,i.screen.select,t,n)}}function renderModelEditorMenu(e,t,i,a){let{request:o,state:s}=e,{draft:c}=s,l=modelEditorMenuRows(o,c,s.capabilities).map(e=>{if(e.disabled===!0&&e.value===`model`)return c.modelId===null?{...e}:{...e,hint:c.modelId};if(e.disabled===!0||e.value===`done`)return{...e};switch(e.value){case`model`:return{...e,hint:c.modelId??void 0};case`reasoning`:{let n=reasoningPositions(s.capabilities,c.reasoning),a=c.reasoning==="default"?-1:n.indexOf(c.reasoning),o=reasoningTrack({count:n.length,index:a,connectorWidth:1,accent:e.value===t,theme:i}),l=c.reasoning==="default"?`provider default`:c.reasoning;return{...e,hint:`${o} ${l}`}}case`tier`:return{...e,hint:c.tier===`priority`?`fast ${i.glyph.fast}`:`normal`};default:return{...e}}});return renderSelectQuestion({kind:`stacked`,message:``,options:l,select:{filter:``,cursor:Math.max(0,l.findIndex(e=>e.value===t)),selected:new Set}},i,a)}function renderModelEditorModelScreen(e,t,n,r){return renderSelectQuestion({kind:`search`,message:`Select the model`,options:e.model.kind===`pick`?e.model.options:[],placeholder:`type to search`,select:t},n,r)}function renderTextQuestion(n,r,i,s){let c=r.colors,l=[];for(let e of n.notices??[]){let t=e.tone===`info`?c.dim(e.text):e.text;l.push(`${toneGlyph(e.tone,r)} ${t}`)}l.push(...n.message.split(`
4
4
  `).map(e=>` ${c.bold(e)}`));let u=Math.max(4,i-4),d=n.mask?maskLine(n.editor):n.editor,f=n.editor.text.length===0?n.placeholder:void 0,p=renderInputWithBlockCursor({...visibleLine(f===void 0?d:{text:f,cursor:0},u,r.glyph.ellipsis),visible:s,inverse:c.inverse,render:f===void 0?renderInputText:e=>c.dim(renderInputText(e))});return l.push(` ${p}`),n.error!==void 0&&l.push(``,` ${c.red(n.error)}`),l.push(...questionFooter([`enter to submit`,`esc to cancel`],r)),l.map(e=>clip(e,i))}function renderAcknowledgeQuestion(e,t,n){let r=t.colors,i=[` ${r.bold(e.message)}`];if(e.lines.length>0){i.push(``);for(let t of e.lines)i.push(` ${r.dim(t)}`)}return i.push(...questionFooter([`enter to continue`],t)),i.map(e=>clip(e,n))}export{enterBadge,reasoningTrack,renderAcknowledgeQuestion,renderFlowPanel,renderModelEditorQuestion,renderSelectQuestion,renderTextQuestion};
@@ -30,7 +30,7 @@ export interface StatusLineInput {
30
30
  }
31
31
  /**
32
32
  * Builds a leading local `:port` or remote badge followed by the model (with
33
- * its reasoning level and Fast mode marker), endpoint, and deploy status
33
+ * its reasoning level and Fast mode marker), and endpoint
34
34
  * segments. Both badges are the final narrow-width fallback. Remote sessions
35
35
  * omit endpoint state. Returns undefined when every segment is empty.
36
36
  */
@@ -1 +1 @@
1
- import{remoteHost}from"./target.js";import{clipVisible,stripAnsi,visibleLength}from"#cli/ui/terminal-text.js";import{formatModelSummary}from"#shared/model-summary.js";function renderModel(e){if(e.model===void 0)return;let t=e.theme.colors,r={model:e.model};if(e.reasoning!==void 0&&(r.reasoning=e.reasoning),e.fastMode===!0&&(r.fastGlyph=e.theme.glyph.fast),e.remote!==void 0){r.model=stripAnsi(e.model).replace(/\s+/gu,` `).trim();let a=stripAnsi(formatModelSummary(r)).replace(/\s+/gu,` `).trim();return t.dim(a)}return t.dim(formatModelSummary(r))}function renderServerPort(e){if(e.remote!==void 0||e.serverPort===void 0)return;let t=e.theme.colors;return t.inverse(t.gray(` :${e.serverPort} `))}const EXTERNAL_PROVIDER_DISPLAY_NAMES={codex:`chatgpt-sub`};function renderEndpoint(e){if(e.remote!==void 0||e.endpoint===void 0)return;let t=e.theme.colors,n=e.theme.glyph,clause=(e,n)=>`${t.dim(`via `)}${e}${t.dim(n)}`;if(e.endpoint.kind===`external`){let r=EXTERNAL_PROVIDER_DISPLAY_NAMES[e.endpoint.provider]??e.endpoint.provider;return{text:`${t.dim(`via ${r}`)}${n.external}`,standalone:!1}}if(!e.endpoint.connected)return{text:t.yellow(`${n.warning} ai-gateway`),standalone:!0};if(e.endpoint.credential===`api-key`)return{text:clause(`ai-gateway`,`(api-key)`),standalone:!1};let r=e.vercel?.identity?.projectName;return{text:clause(`ai-gateway`,`(${r===void 0?`oidc`:`oidc:${r}`})`),standalone:!1}}function buildStatusLine(e){let{theme:n,width:i}=e,a=n.colors,o=e.logLevel===void 0?void 0:a.cyan(`logs: ${e.logLevel}`),s=renderServerPort(e),c=renderModel(e),l=e.vercel?.pendingDeploy?a.yellow(`/deploy pending`):void 0,u=e.remote===void 0?void 0:formatRemoteStatus(e.remote,n),d=renderEndpoint(e),f=u?.full??s,p=u?.badge??s,m=d!==void 0&&!d.standalone&&c!==void 0,h=m?`${c} ${d.text}`:c,g=d===void 0||m?void 0:d.text,compose=(e,t)=>{let n=t.filter(e=>e!==void 0).join(` `);return e===void 0||n.length===0?e??n:`${e} ${n}`},_=[compose(f,[o,h,g,l]),compose(f,[o,c,l]),compose(f,[o,l]),compose(f,[o]),compose(p,[o]),compose(p,[])];if(_[0].length!==0){for(let e of _)if(e.length>0&&visibleLength(e)<=i)return e;return clipVisible(_.findLast(e=>e.length>0),i)}}function formatRemoteStatus(t,n){let r=n.colors,i=t.deployment===void 0?remoteHost(t.target):`${t.deployment.projectName} (${t.deployment.environment})`,a=formatRemoteBadge(` ${n.unicode?`↗`:`->`} ${i} `,t.connection.state,n),o;switch(t.connection.state){case`checking`:o=r.dim(`Checking access…`);break;case`ready`:break;case`auth-required`:o=r.yellow(`Authenticate via OIDC`);break;case`authenticating`:o=r.dim(`Authenticating via OIDC…`);break;case`auth-failed`:o=r.yellow(`Authentication failed`);break;case`unavailable`:o=r.yellow(`Remote unavailable`);break}return{badge:a,full:o===void 0?a:`${a} ${o}`}}function formatRemoteBadge(e,t,n){let r=n.colors;switch(t){case`checking`:return r.inverse(r.gray(e));case`ready`:return r.inverse(r.blue(e));case`unavailable`:case`auth-required`:case`authenticating`:case`auth-failed`:return r.inverse(r.yellow(e))}}export{buildStatusLine};
1
+ import{remoteHost}from"./target.js";import{clipVisible,stripAnsi,visibleLength}from"#cli/ui/terminal-text.js";import{formatModelSummary}from"#shared/model-summary.js";function renderModel(e){if(e.model===void 0)return;let t=e.theme.colors,r={model:e.model};if(e.reasoning!==void 0&&(r.reasoning=e.reasoning),e.fastMode===!0&&(r.fastGlyph=e.theme.glyph.fast),e.remote!==void 0){r.model=stripAnsi(e.model).replace(/\s+/gu,` `).trim();let a=stripAnsi(formatModelSummary(r)).replace(/\s+/gu,` `).trim();return t.dim(a)}return t.dim(formatModelSummary(r))}function renderServerPort(e){if(e.remote!==void 0||e.serverPort===void 0)return;let t=e.theme.colors;return t.inverse(t.gray(` :${e.serverPort} `))}const EXTERNAL_PROVIDER_DISPLAY_NAMES={codex:`chatgpt-sub`};function renderEndpoint(e){if(e.remote!==void 0||e.endpoint===void 0)return;let t=e.theme.colors,n=e.theme.glyph,clause=(e,n)=>`${t.dim(`via `)}${e}${t.dim(n)}`;if(e.endpoint.kind===`external`){let r=EXTERNAL_PROVIDER_DISPLAY_NAMES[e.endpoint.provider]??e.endpoint.provider;return{text:`${t.dim(`via ${r}`)}${n.external}`,standalone:!1}}if(!e.endpoint.connected)return{text:t.yellow(`${n.warning} ai-gateway`),standalone:!0};if(e.endpoint.credential===`api-key`)return{text:clause(`ai-gateway`,`(api-key)`),standalone:!1};let r=e.vercel?.identity?.projectName;return{text:clause(`ai-gateway`,`(${r===void 0?`oidc`:`oidc:${r}`})`),standalone:!1}}function buildStatusLine(e){let{theme:n,width:i}=e,a=n.colors,o=e.logLevel===void 0?void 0:a.cyan(`logs: ${e.logLevel}`),s=renderServerPort(e),c=renderModel(e),l=e.remote===void 0?void 0:formatRemoteStatus(e.remote,n),u=renderEndpoint(e),d=l?.full??s,f=l?.badge??s,p=u!==void 0&&!u.standalone&&c!==void 0,m=p?`${c} ${u.text}`:c,h=u===void 0||p?void 0:u.text,compose=(e,t)=>{let n=t.filter(e=>e!==void 0).join(` `);return e===void 0||n.length===0?e??n:`${e} ${n}`},g=[compose(d,[o,m,h]),compose(d,[o,c]),compose(d,[o]),compose(d,[o]),compose(f,[o]),compose(f,[])];if(g[0].length!==0){for(let e of g)if(e.length>0&&visibleLength(e)<=i)return e;return clipVisible(g.findLast(e=>e.length>0),i)}}function formatRemoteStatus(t,n){let r=n.colors,i=t.deployment===void 0?remoteHost(t.target):`${t.deployment.projectName} (${t.deployment.environment})`,a=formatRemoteBadge(` ${n.unicode?`↗`:`->`} ${i} `,t.connection.state,n),o;switch(t.connection.state){case`checking`:o=r.dim(`Checking access…`);break;case`ready`:break;case`auth-required`:o=r.yellow(`Authenticate via OIDC`);break;case`authenticating`:o=r.dim(`Authenticating via OIDC…`);break;case`auth-failed`:o=r.yellow(`Authentication failed`);break;case`unavailable`:o=r.yellow(`Remote unavailable`);break}return{badge:a,full:o===void 0?a:`${a} ${o}`}}function formatRemoteBadge(e,t,n){let r=n.colors;switch(t){case`checking`:return r.inverse(r.gray(e));case`ready`:return r.inverse(r.blue(e));case`unavailable`:case`auth-required`:case`authenticating`:case`auth-failed`:return r.inverse(r.yellow(e))}}export{buildStatusLine};
@@ -132,11 +132,8 @@ export declare class TerminalRenderer implements AgentTUIRenderer {
132
132
  clearSetupWarning(): void;
133
133
  /** Commits a slash-command invocation that was started without prompt input. */
134
134
  renderCommandInvocation(text: string, status?: "failed"): void;
135
- /**
136
- * Commits one command's outcome under its invocation with the elbow
137
- * connector (` ⎿ /model cancelled.`), Claude Code's sub-result grammar.
138
- */
139
- renderCommandResult(text: string): void;
135
+ /** Commits one command outcome, promoting explicit status to a top-level result. */
136
+ renderCommandResult(text: string, tone?: "success" | "error"): void;
140
137
  /** Last server session id the runner reported; named in the parting line. */
141
138
  setSessionId(sessionId: string): void;
142
139
  shutdown(): void;