eve 0.38.2 → 0.39.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.
- package/CHANGELOG.md +23 -0
- package/dist/src/chunks/{use-eve-agent-BbSsu99c.js → use-eve-agent-Bh-oE6hp.js} +12 -0
- package/dist/src/chunks/{use-eve-agent-Dt8Y5QtW.js → use-eve-agent-pDXW_bLy.js} +12 -0
- package/dist/src/cli/application-command.d.ts +2 -0
- package/dist/src/cli/application-root.d.ts +3 -1
- package/dist/src/cli/application-root.js +1 -1
- package/dist/src/cli/commands/channels.d.ts +2 -1
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/deploy.d.ts +0 -1
- package/dist/src/cli/commands/deploy.js +1 -1
- package/dist/src/cli/commands/init-git.d.ts +5 -3
- package/dist/src/cli/commands/init-git.js +1 -1
- package/dist/src/cli/commands/init-target.d.ts +2 -3
- package/dist/src/cli/commands/init-target.js +2 -1
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/integration-connect.js +1 -1
- package/dist/src/cli/commands/integration-setup.js +1 -1
- package/dist/src/cli/commands/link.d.ts +0 -1
- package/dist/src/cli/commands/link.js +1 -1
- package/dist/src/cli/commands/registry-recovery.d.ts +1 -1
- package/dist/src/cli/commands/registry-recovery.js +1 -1
- package/dist/src/cli/commands/set.d.ts +0 -2
- package/dist/src/cli/commands/set.js +1 -1
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
- package/dist/src/cli/dev/tui/provider-picker.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +2 -0
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/setup-commands.d.ts +2 -0
- package/dist/src/cli/dev/tui/setup-commands.js +2 -2
- package/dist/src/cli/dev/tui/setup-issues.d.ts +1 -1
- package/dist/src/cli/dev/tui/setup-issues.js +1 -1
- package/dist/src/cli/dev/tui/status-line.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +3 -3
- package/dist/src/cli/run.d.ts +3 -4
- package/dist/src/cli/run.js +2 -2
- package/dist/src/cli/ui/alt-screen.d.ts +9 -3
- package/dist/src/cli/ui/alt-screen.js +1 -1
- package/dist/src/client/agent-info-schema.d.ts +12 -0
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/compiler/artifacts.js +1 -1
- package/dist/src/compiler/manifest.d.ts +4 -0
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-helpers.js +1 -1
- package/dist/src/compiler/normalize-sandbox.d.ts +1 -0
- package/dist/src/compiler/normalize-sandbox.js +1 -1
- package/dist/src/context/providers/sandbox.js +1 -1
- package/dist/src/discover/connections.js +1 -1
- package/dist/src/discover/discover-agent.js +1 -1
- package/dist/src/discover/discover-subagent.js +1 -1
- package/dist/src/discover/extensions.js +1 -1
- package/dist/src/discover/grammar.js +1 -1
- package/dist/src/discover/manifest.js +1 -1
- package/dist/src/discover/named-source-directory.js +1 -1
- package/dist/src/discover/project.js +1 -1
- package/dist/src/discover/sandbox.js +1 -1
- package/dist/src/discover/skills.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +2 -0
- package/dist/src/execution/dispatch-runtime-actions-shared.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +7 -5
- package/dist/src/execution/sandbox/bindings/docker-cli.js +2 -2
- package/dist/src/execution/sandbox/bindings/local.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/local.js +1 -1
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/sandbox/prewarm.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/subagent-event-proxy-step.js +1 -1
- package/dist/src/execution/subagent-start-local.d.ts +1 -0
- package/dist/src/execution/subagent-start-local.js +1 -1
- package/dist/src/execution/subagent-tool.d.ts +22 -0
- package/dist/src/execution/subagent-tool.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/ai-sdk-hook-bridge.d.ts +1 -1
- package/dist/src/harness/ai-sdk-hook-bridge.js +1 -1
- package/dist/src/harness/instrumentation/lifecycle.d.ts +2 -0
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/host/compiled-sandbox-backend-prune-plugin.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.d.ts +2 -0
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/nitro/routes/info.js +1 -1
- package/dist/src/internal/resolve-model-endpoint-status.d.ts +6 -14
- package/dist/src/internal/resolve-model-endpoint-status.js +1 -1
- package/dist/src/node_modules/.pnpm/@clack_core@1.3.1/node_modules/@clack/core/dist/index.js +4 -4
- package/dist/src/public/channels/slack/index.d.ts +1 -1
- package/dist/src/public/channels/slack/input-response.d.ts +11 -0
- package/dist/src/public/channels/slack/input-response.js +1 -0
- package/dist/src/public/channels/slack/interactions.d.ts +10 -14
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +35 -0
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/definitions/sandbox.d.ts +23 -4
- package/dist/src/public/definitions/sandbox.js +1 -1
- package/dist/src/public/models/openai/chatgpt/auth.d.ts +2 -67
- package/dist/src/public/models/openai/chatgpt/auth.js +1 -1
- package/dist/src/public/models/openai/chatgpt/codex-app-server.d.ts +40 -0
- package/dist/src/public/models/openai/chatgpt/codex-app-server.js +1 -0
- package/dist/src/public/models/openai/chatgpt/token-broker.d.ts +33 -0
- package/dist/src/public/models/openai/chatgpt/token-broker.js +1 -0
- package/dist/src/public/models/openai/chatgpt/transport.d.ts +5 -14
- package/dist/src/public/models/openai/chatgpt/transport.js +1 -1
- package/dist/src/public/models/openai/index.d.ts +5 -8
- package/dist/src/public/models/openai/index.js +1 -1
- package/dist/src/public/sandbox/backends/default.d.ts +1 -1
- package/dist/src/public/sandbox/backends/default.js +1 -1
- package/dist/src/public/sandbox/index.d.ts +1 -1
- package/dist/src/runtime/framework-tools/glob.js +1 -1
- package/dist/src/runtime/framework-tools/grep.js +1 -1
- package/dist/src/runtime/framework-tools/index.d.ts +2 -0
- package/dist/src/runtime/framework-tools/index.js +1 -1
- package/dist/src/runtime/framework-tools/read-file.js +1 -1
- package/dist/src/runtime/framework-tools/skill.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-sandbox.js +1 -1
- package/dist/src/runtime/sandbox/registry.d.ts +6 -0
- package/dist/src/runtime/sandbox/registry.js +1 -1
- package/dist/src/runtime/types.d.ts +1 -0
- package/dist/src/setup/flows/chatgpt-auth.d.ts +2 -0
- package/dist/src/setup/flows/chatgpt-auth.js +1 -0
- package/dist/src/setup/flows/deploy.d.ts +4 -0
- package/dist/src/setup/flows/deploy.js +1 -1
- package/dist/src/setup/flows/model-source-change.js +1 -1
- package/dist/src/setup/flows/model.d.ts +18 -28
- package/dist/src/setup/flows/model.js +1 -1
- package/dist/src/setup/flows/provider.d.ts +18 -32
- package/dist/src/setup/flows/provider.js +4 -4
- package/dist/src/setup/provider-settings.d.ts +12 -0
- package/dist/src/setup/provider-settings.js +1 -0
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +45 -14
- package/dist/src/setup/scaffold/update/channels.d.ts +1 -1
- package/dist/src/setup/scaffold/update/channels.js +1 -1
- package/dist/src/shared/chatgpt-model.d.ts +9 -0
- package/dist/src/shared/chatgpt-model.js +1 -0
- package/dist/src/shared/model-endpoint-status.d.ts +5 -0
- package/dist/src/source-change/apply-agent-model-settings.js +1 -1
- package/dist/src/source-change/apply-model-selection.d.ts +12 -0
- package/dist/src/source-change/apply-model-selection.js +2 -0
- package/dist/src/source-change/static-source-change.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +1 -1
- package/docs/channels/slack.mdx +19 -9
- package/docs/concepts/built-in-tools.md +215 -0
- package/docs/concepts/default-harness.md +6 -113
- package/docs/concepts/execution-model-and-durability.mdx +1 -1
- package/docs/concepts/meta.json +1 -0
- package/docs/concepts/security-model.md +1 -1
- package/docs/guides/dynamic-capabilities.md +1 -1
- package/docs/guides/remote-agents.md +1 -1
- package/docs/reference/typescript-api.md +47 -33
- package/docs/sandbox.mdx +21 -4
- package/docs/subagents/index.mdx +2 -2
- package/docs/subagents/meta.json +1 -1
- package/docs/tools/human-in-the-loop.md +2 -2
- package/docs/tools/overview.mdx +1 -1
- package/docs/tutorial/query-sample-data.mdx +25 -1
- package/package.json +1 -1
- package/dist/src/source-change/apply-model-name.d.ts +0 -25
- package/dist/src/source-change/apply-model-name.js +0 -1
- package/docs/subagents/workflow-tool.md +0 -88
|
@@ -1,3 +1,3 @@
|
|
|
1
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{RegistryFlowFailedError,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 joinedTitles(e){return e.length===0?``:e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function registryResultMessage(e){let t=[`Added ${joinedTitles(e.items.map(e=>e.title))}`];for(let n of e.items){if(n.facts.length===0&&n.output.length===0)continue;t.push(``,n.title);let e=Math.max(0,...n.facts.map(e=>e.label.length));for(let r of n.facts)t.push(` ${r.label.padEnd(e)} ${r.value}`);for(let e of n.output)t.push(` ${e}`)}return t.join(`
|
|
2
|
-
`)}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)},replaceContent:n=>{t()||e.replaceContent?.(n)},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.`,tone:`error`,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,runRegistryFlow,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.
|
|
3
|
-
`),preserveFlowDiagnostics:!1};return n.
|
|
2
|
+
`)}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)},replaceContent:n=>{t()||e.replaceContent?.(n)},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.`,tone:`error`,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,runRegistryFlow,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,chatGptAccountLabel:e.chatGptAccountLabel,deps:{pickModelSettings:e=>u.readModelEditor(e),runProviderFlow:e=>runProviderFlow({...e,picker:pickProvider})}};e.initialModelStep!==void 0&&(t.initialStep=e.initialModelStep),t.withExclusiveTerminal=t=>u.withInheritedStdio(()=>e.withExclusiveTerminal?.(t)??t());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.providerSelection!==void 0&&r.push(providerSelectionMessage(n.providerSelection));let a={message:r.join(`
|
|
3
|
+
`),preserveFlowDiagnostics:!1};return n.accessChanged&&(a.effect={kind:`model-access-changed`}),a}case`add`:{let e=await m.runRegistryFlow({appRoot:p,prompter:i,signal:d});if(e.kind===`cancelled`)return{message:`/add dismissed.`,preserveFlowDiagnostics:!0};let t={message:e.addedItems.length>0?registryResultMessage(e):`No registry items added.`,preserveFlowDiagnostics:!0};return e.addedItems.length>0&&(t.tone=`success`),e.deployed===`production`&&(t.effect={kind:`deployed`}),t}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}:e.kind===`local-model`?{message:`ChatGPT subscription models are local-only. Switch to an AI Gateway or server-authenticated model before deploying.`,preserveFlowDiagnostics:!0}:{message:e.productionUrl===void 0?`Deployed.`:`Deployed: ${e.productionUrl}`,preserveFlowDiagnostics:!0,effect:{kind:`deployed`}}}}}catch(e){if(e instanceof RegistryFlowFailedError){let t=e.completed;return{message:`${registryResultMessage(t)}\n\n${e.message}`,tone:`error`,preserveFlowDiagnostics:!0}}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)}`,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 providerSelectionMessage(e){return e===`chatgpt`?`ChatGPT subscription selected.`:e===`ai-gateway-project`?`AI Gateway via Project selected.`:`AI Gateway via API key selected.`}export{SETUP_FLOW_CONFIG,runTuiSetupCommand};
|
|
@@ -32,7 +32,7 @@ export interface BootDetection {
|
|
|
32
32
|
* loaded credential is usable even when an earlier `/info` response says
|
|
33
33
|
* disconnected.
|
|
34
34
|
*/
|
|
35
|
-
export declare function
|
|
35
|
+
export declare function normalizeLocalModelEndpoint(info: AgentInfoResult | undefined, env: Record<string, string | undefined>): AgentInfoResult | undefined;
|
|
36
36
|
/** The built-in boot detections, run in order. */
|
|
37
37
|
export declare const BOOT_DETECTIONS: readonly BootDetection[];
|
|
38
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join}from"node:path";import{pathExists}from"#setup/path-exists.js";import{hasEnvValue,resolveGatewayCredential}from"#internal/resolve-model-endpoint-status.js";function
|
|
1
|
+
import{join}from"node:path";import{pathExists}from"#setup/path-exists.js";import{hasEnvValue,resolveGatewayCredential}from"#internal/resolve-model-endpoint-status.js";function normalizeLocalModelEndpoint(e,t){let n=modelProviderAccess({env:t,info:e});if(e===void 0||n.kind!==`gateway`||n.runtime.status!==`connected`)return e;let{credential:r}=n.runtime,i=e.agent.model;if(i.id===void 0||i.routing.kind!==`gateway`)return e;let a=i.endpoint;if(a?.kind===`gateway`&&a.connected&&a.credential===r)return e;let o={connected:!0,credential:r,kind:`gateway`};return{...e,agent:{...e.agent,model:{contextWindowTokens:i.contextWindowTokens,endpoint:o,id:i.id,providerOptions:i.providerOptions,reasoning:i.reasoning,routing:i.routing,source:i.source}}}}function modelProviderAccess(e){let t=e.info?.agent.model;if(t?.routing?.kind===`external`)return{kind:`external`};if(t?.routing?.kind!==`gateway`)return{kind:`unknown`};let i=resolveGatewayCredential({apiKeyInEnv:hasEnvValue(e.env.AI_GATEWAY_API_KEY),oidcAvailable:hasEnvValue(e.env.VERCEL_OIDC_TOKEN)});if(i?.credential===`api-key`)return{kind:`gateway`,runtime:{status:`connected`,credential:`api-key`}};let a=t.endpoint;return a?.kind===`gateway`&&a.connected?{kind:`gateway`,runtime:{status:`connected`,credential:a.credential}}:i===void 0?a?.kind===`gateway`?{kind:`gateway`,runtime:{status:`disconnected`}}:{kind:`gateway`,runtime:{status:`unknown`}}:{kind:`gateway`,runtime:{status:`connected`,credential:i.credential}}}const BOOT_DETECTIONS=[{id:`model-provider`,async detect({appRoot:n,env:r,info:i}){let a=modelProviderAccess({env:r,info:i});if(a.kind===`external`)return[];if(a.kind===`gateway`){if(a.runtime.status===`connected`)return[];if(a.runtime.status===`disconnected`)return[{kind:`attention`,label:await pathExists(join(n,`.vercel`,`project.json`))?`AI Gateway credentials missing`:`model provider not linked`,command:`/model`}]}return await pathExists(join(n,`.vercel`,`project.json`))?[{kind:`attention`,label:`AI Gateway credentials missing`,command:`/model`}]:[{kind:`attention`,label:`model provider not linked`,command:`/model`}]}}],LOGIN_SETUP_ISSUE={kind:`attention`,label:`not logged in`,command:`/vc:login`},CLI_MISSING_SETUP_ISSUE={kind:`attention`,label:`Vercel CLI not found`,command:`/vc:install`};async function detectSetupIssues(e,t=BOOT_DETECTIONS){return(await Promise.all(t.map(async t=>{try{return await t.detect(e)}catch{return[]}}))).flat()}function orderedSetupIssues(e,t){return t===void 0?[...e]:[t,...e]}function formatSetupIssuesLine(e){let t=e.length===1?`setup issue`:`setup issues`,n=e.map(e=>`${e.label} · ${e.command}`).join(`, `);return`${e.length} ${t}: ${n}`}export{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,normalizeLocalModelEndpoint,orderedSetupIssues};
|
|
@@ -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.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};
|
|
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.kind===`chatgpt`)switch(e.endpoint.state){case`ready`:return{text:`${t.dim(`via chatgpt-sub`)}${n.external}`,standalone:!1};case`checking`:return{text:t.dim(`chatgpt-sub checking…`),standalone:!0};case`signed-out`:case`reauth-required`:return{text:t.yellow(`${n.warning} chatgpt-sub login · codex login`),standalone:!0};case`unavailable`:return{text:t.yellow(`${n.warning} chatgpt-sub unavailable`),standalone:!0}}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};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{buildAgentHeader}from"./agent-header.js";import{renderAttentionRows,renderBlockLines}from"./blocks.js";import{copyTextToClipboard}from"./clipboard.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{formatStoredDiagnostic,presentDiagnostic}from"./diagnostic-presentation.js";import{interruptedError}from"./errors.js";import{FileContentCache}from"./file-content-cache.js";import{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,layoutPromptInput,lineOf,movePromptLine,visibleLine}from"./line-editor.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{MessageQueue,renderMessageQueueRows}from"./message-queue.js";import{initialModelEditorState,transitionModelEditor}from"./model-editor.js";import{promptPlaceholder}from"./prompt-placeholder.js";import{initialProviderPickerState,transitionProviderPicker}from"./provider-picker.js";import{renderQuestionPanel}from"./question-panel.js";import{enterBadge,renderAcknowledgeQuestion,renderFlowPanel,renderModelEditorQuestion,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{formatAssistantResponseStats,formatTokenFlow,formatTurnDuration,isIncompleteOsc,isIncompletePaste,nextKey,sanitizePastedText,stripPasteStart,stripPromptControlCharacters,takeUntil,typewriterText}from"./stream-format.js";import{TraceViewerSession}from"./traces/trace-viewer-session.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{isPanelRoutedTool,presentPreparingTool,presentTool,readWriteFileInput,toolBaseName}from"./tool-presentation.js";import{groupToolBlocksForDisplay}from"./tool-block-groups.js";import{TurnClock}from"./turn-clock.js";import{allTodoItemsSettled,readTodoToolItems,renderFinishedTodoRows,renderTodoPanelRows}from"./todo-panel.js";import{reduceSetupSelectInput,setupSelectionIntent}from"./setup-selection-input.js";import{BACKGROUND_COLOR_QUERY,parseBackgroundColorReply}from"./terminal-background.js";import{inspectError}from"#internal/logging.js";import{eveVersionTag}from"#cli/banner.js";import{clipVisible,renderInputText,renderInputWithBlockCursor,stripAnsi,stripTerminalControls}from"#cli/ui/terminal-text.js";import{renderCursorRow}from"#setup/cli/option-row.js";import{initialSelectState,reduceSelect,searchActionQuery,selectValueAtCursor}from"#setup/cli/select-state.js";import{toErrorMessage}from"#shared/errors.js";import{StringDecoder}from"node:string_decoder";import{summarizeKnownError}from"#harness/semantic-errors/index.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{LiveRegion}from"#cli/ui/live-region.js";import{AltScreen}from"#cli/ui/alt-screen.js";import{PROGRESS_PULSE_ASCII_GLYPH,PROGRESS_PULSE_GLYPH,isProgressPulseVisible}from"#cli/ui/progress-pulse.js";import{readGatewayServiceTier}from"#shared/gateway-service-tier.js";function isMultiSelectRequest(e){return e.kind===`multi`||e.kind===`searchable-multi`}function moveActionCursor(e,t,n){return n===0?void 0:e===void 0?t===`down`?0:n-1:(e+(t===`down`?1:-1)+n)%n}function completedTurnStatus(e){return e.interrupted?`Interrupted`:e.cancelled?`Cancelled`:e.continueSession?`Ready`:`Done`}const incompletePasteFlushMs=1e3,STATUS={processing:`Working…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=[];#h=new Map;#g=new Set;#_=[];#v=new Set;#y=new Map;#b=0;#x=new Map;#S=new Set;#C=new Set;#w=new FileContentCache;#T=new Set;#E;#D=!1;#O;#k=[];#A;#j=0;#M;#N;#P=``;#F=0;#I=new PromptHistory;#L=!1;#R;#z=!1;#B=Date.now();#V=!1;#H=new TurnClock;#U=EMPTY_LINE;#W=!1;#G={kind:`idle`};#K;#q=STATUS.processing;#J;#Y=`eve`;#X=!1;#Z=!1;#Q=!1;#$=!1;#ee=!1;#te=!1;#ne;#re=!0;#ie=0;#ae=Date.now();#oe;#se;#ce;#le=!1;#ue;#de=``;#fe=new StringDecoder(`utf8`);#pe;#me;#he;#ge=!1;#_e=!1;#ve;#ye;#be;#xe;#Se;#Ce;#we;#Te=``;#Ee=``;#De;#Oe;#ke=0;#Ae;#je;#Me;#Ne;#Pe;#Fe;#Ie=new MessageQueue;#Le;#Re=!1;#ze;#Be;#Ve=!1;#He;#Ue;#We;#Ge;#Ke;setupFlow={begin:(e,t)=>this.#Qe(e,t),end:e=>this.#$e(e?.preserveDiagnostics??!0),readSelect:e=>this.#et(e),readEditableSelect:e=>this.#nt(e),readProviderPicker:e=>this.#rt(e),readModelEditor:e=>this.#it(e),readText:e=>this.#at(e),readAcknowledge:e=>this.#ot(e),readChoice:e=>this.#tt(e),setStatus:e=>this.#mt(e),renderLine:(e,t)=>this.#ht(e,t),replaceContent:e=>this.#gt(e),renderOutput:e=>this.#_t(e),withInheritedStdio:e=>this.#vt(e),withExclusiveTerminal:e=>this.#vt(e),waitForInterrupt:e=>this.#dt(e)};traceViewer={open:e=>this.#bt(e)};constructor(t){this.#e=t?.input??process.stdin,this.#t=t?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=new AltScreen(this.#t),this.#i=createTheme({color:t?.color??!0,unicode:t?.unicode??detectUnicode()}),this.#a=t?.tools??`auto-collapsed`,this.#o=t?.reasoning??`auto-collapsed`,this.#s=t?.subagents??`auto-collapsed`,this.#c=t?.connectionAuth??`full`,this.#l=t?.assistantResponseStats??`tokensPerSecond`,this.#be=t?.contextSize,this.#u=t?.captureForeignOutput??this.#t===process.stdout,this.#d=t?.diagnostics,this.#ne=t?.onExitRequest,this.#p=t?.logs??`none`,this.#f=t?.availablePromptCommands??PROMPT_COMMANDS}renderAgentHeader(e){this.#Y=e.name,this.#E=e,this.#Ct();let t=this.#pn().join(`
|
|
2
2
|
`);if(this.#D){t!==this.#O&&(this.#O=t,this.#Bt({kind:`agent-header`,body:t,live:!1})),this.#cn();return}this.#D=!0,this.#O=t,this.#n.flush(this.#pn(),[])}async readPrompt(e){this.#Ct(e),this.#zt(),this.#Ht(),this.#L=!0,this.#z=!0,this.#G={kind:`idle`},this.#q=``,this.#te=!1;let r=this.#Ie.restoreDraft()?.split(`
|
|
3
3
|
`).map(stripPromptControlCharacters).join(`
|
|
4
|
-
`),i=stripPromptControlCharacters(e?.initialDraft??this.#U.text),a=lineOf(r===void 0?i:i.length===0?r:`${r}\n\n${i}`);return this.#U=EMPTY_LINE,this.#I.begin(a.text),this.#qe(a),this.#R=typeaheadFor(this.#f,a.text),this.#Pt(),this.#cn(),await new Promise((e,r)=>{this.#K=r;let apply=e=>{a=e,this.#It(),this.#qe(a),this.#R=typeaheadFor(this.#f,e.text,this.#R),this.#cn()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#R=void 0,this.#Ft(),this.#Tt(),r(interruptedError())},suggestions=()=>this.#R!==void 0&&isTypeaheadOpen(this.#R)?this.#R:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#ue=r=>{r.type!==`ctrl-c`&&this.#te&&(this.#te=!1,this.#cn());let i=applyLineEditorKey(a,r,{multiline:!0});if(i!==void 0){apply(i);return}switch(r.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#R=moveTypeaheadSelection(e,-1),this.#cn();break}let t=movePromptLine(a,`up`);t===void 0?recall(this.#I.previous(a.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#R=moveTypeaheadSelection(e,1),this.#cn();break}let t=movePromptLine(a,`down`);t===void 0?recall(this.#I.next()):apply(t);break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#R=dismissTypeahead(e),this.#cn());break}case`enter`:{let r=highlighted(),i=r!==void 0&&parsePromptCommand(a.text)===null?typeaheadCompletion(r).trimEnd():a.text;if(i.trim().length===0)break;this.#R=void 0,this.#I.add(i),this.#L=!1,this.#Ft(),this.#q=STATUS.processing,isPromptControlCommand(i)?this.#Bt({kind:`command`,body:stripTerminalControls(i.trim()),live:!1}):(this.#Rt(),this.#Vt(i),this.#Ae=i,this.#H.arm()),this.#qe(EMPTY_LINE),this.#cn(),this.#Dt(),e(i);break}case`ctrl-d`:a.text.length===0?(this.#yt(),interrupt()):apply(deleteForward(a));break;case`ctrl-l`:this.#dn();break;case`ctrl-r`:this.#cn();break;case`ctrl-c`:if(this.#te){this.#yt(),interrupt();break}this.#te=!0,apply(EMPTY_LINE);break;default:break}},this.#Et()})}#qe(e){this.#P=e.text,this.#F=e.cursor}takeQueuedPrompt(){let e=this.#Ie.view().steering,t=this.#Ie.takePrompt();return t!==void 0&&(this.#Be=e?`steer`:`queue`),t}async renderStream(e,t){this.#Ct(t),this.#g.clear(),this.#L=!1,this.#G.kind!==`waiting`&&(this.#G={kind:`waiting`,startedAtMs:Date.now()}),this.#q=this.#j>0?STATUS.connectionAuth:STATUS.processing,this.#Ut(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#d?.recordPrompt(),t?.submittedPrompt!==void 0&&!this.#H.armed&&this.#H.arm(),this.#$=!1,this.#Re=!1,this.#Ve=!1,this.#He=t?.submittedPrompt,this.#Ie.beginTurn(),this.#Le=e.cancel,this.#ve=void 0,this.#ye=void 0,this.#xe=void 0,this.#Se=void 0,this.#Ce=Date.now();let n={tools:t?.tools??this.#a,reasoning:t?.reasoning??this.#o,assistantResponseStats:t?.assistantResponseStats??this.#l};this.#Lt(),this.#W=!0,this.#cn();let r=new Promise(e=>{this.#he=e});this.#ue=e=>this.#Nt(e),this.#Et();let i={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!0};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#$)break;this.#Xt(t,n,i)}}catch(e){let t=summarizeKnownError(e);t===null?this.#Wt(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#Wt(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#he=void 0,this.#$&&e.abort?.(),this.#Le=void 0,this.#Dt(),this.#zt(),this.#W=!1,this.#G.kind===`waiting`&&(this.#G={kind:`idle`}),this.#q=completedTurnStatus({interrupted:this.#$,cancelled:this.#Re,continueSession:t?.continueSession===!0}),this.#rn(i),(this.#$||i.cancelled)&&this.#nn(i),this.#Yt(),this.#d?.reportStats(),this.#cn(),t?.continueSession||this.#Tt()}}async renderIdleStream(e,t){let n={tools:t?.tools??this.#a,reasoning:t?.reasoning??this.#o,assistantResponseStats:t?.assistantResponseStats??this.#l},r={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!1};try{for await(let t of iterateTUIStream(e.events))this.#Xt(t,n,r)}catch(e){let t=summarizeKnownError(e);t===null?this.#Wt(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#Wt(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#rn(r),r.cancelled&&this.#nn(r),this.#Yt(),this.#d?.reportStats(),this.#cn()}}async readToolApproval(e,t){return this.#Ct(t),this.#zt(),this.#L=!1,this.#G={kind:`idle`},this.#q=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#$=!1,this.#cn(),await new Promise((t,n)=>{this.#K=n,this.#ue=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#Rt(),this.#q=STATUS.processing,this.#Dt(),this.#cn(),t({approved:!0})):n===`n`&&(this.#Rt(),this.#q=STATUS.processing,this.#Ye(e.toolCallId),this.#Dt(),this.#cn(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#cn();break;case`ctrl-c`:this.#$=!0,this.#Tt(),n(interruptedError());break;default:break}},this.#Et()})}async readInputQuestion(e,t){this.#Ct(t),this.#zt(),this.#L=!1,this.#z=!1,this.#G={kind:`idle`},this.#$=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`overlay`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,overlayPanel=t=>renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#re},this.#i,t),renderTextSection=()=>{this.#Kt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,void 0,this.#i),preformatted:!0,live:!0})},syncFreeformCaret=()=>{isOnFreeformRow()?this.#Pt():(this.#Ft(),this.#It())};s===`overlay`?(s=`overlay`,this.#L=!1,this.#Jt(o),this.#je=overlayPanel,this.#q=``,syncFreeformCaret(),this.#cn()):(s=`text`,this.#je=void 0,renderTextSection(),this.#L=!0,this.#qe(l),this.#q=``,this.#Pt(),this.#cn());let finalize=t=>{this.#je=void 0,this.#Kt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#L=!1,this.#Rt(),this.#q=STATUS.processing,this.#Ft(),this.#Dt(),this.#cn();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#je=void 0,this.#Kt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Dismissed.`)}`,preformatted:!0,live:!1}),this.#L=!1,this.#q=``,this.#Ft(),this.#Dt(),this.#cn(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#cn())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,r)=>{this.#K=r,u=t,this.#ue=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#It(),s===`text`&&this.#qe(l),this.#cn();return}this.#$=!0,this.#je=void 0,this.#Ft(),this.#Tt(),r(interruptedError());return}if(t.type===`ctrl-r`){this.#cn();return}if(s===`overlay`){switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#It(),this.#cn();break}dismiss();break;default:if(isOnFreeformRow()){let e=applyLineEditorKey(l,t);e!==void 0&&(l=e,this.#It(),this.#cn());break}if(t.type===`text`&&/^[1-9]$/u.test(t.value)){let e=Number(t.value)-1;e<n.length?selectOptionAt(e):e===n.length&&i&&(c=e,syncFreeformCaret(),this.#cn())}break}return}let a=applyLineEditorKey(l,t,{multiline:!0});if(a!==void 0){l=a,this.#It(),this.#qe(l),this.#cn();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#It(),this.#qe(l),this.#cn());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#It(),this.#qe(l),this.#cn();break}dismiss();break;default:break}},this.#Et()})}upsertSubagentStep(e){if(this.#d?.recordSubagentDispatch(e.callId),this.#s===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&n.length===0)){if(this.#Gt(e.callId,e.subagentName),this.#s===`collapsed`){this.#cn();return}this.#qt({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,subagentCallId:e.callId,depth:1,reasoning:t,body:n,collapsed:this.#s!==`full`,live:!e.finalized}),this.#cn()}}upsertSubagentTool(e){if(this.#d?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#d?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#s===`hidden`)return;if(this.#Gt(e.callId,e.subagentName),this.#s===`collapsed`){this.#cn();return}let t=subagentToolStatus(e.status),n=e.status===`preparing`?presentPreparingTool(e.toolName):presentTool(e.toolName,e.input,this.#en({input:e.input,output:e.output,toolCallId:e.childCallId,toolName:e.toolName})),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,subagentCallId:e.callId,depth:1,title:stripTerminalControls(n.title),subtitle:stripTerminalControls(n.subtitle),status:t,live:t===`running`||t===`approval`,expanded:this.#s===`full`,toolName:e.toolName,toolGroup:n.group,toolInput:e.input};n.doneTitle!==void 0&&(r.doneTitle=stripTerminalControls(n.doneTitle)),n.detail!==void 0&&(r.detailLines=n.detail,r.keepDetailWhenDone=n.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=n.summarizeResult(e.output),r.toolOutput=e.output),this.#qt(r),this.#Je(e.callId),this.#cn()}#Je(e){applyCohortLiveness(this.#m.filter(t=>t.kind===`subagent-tool`&&t.subagentCallId===e).map(e=>({block:e,active:isActiveToolStatus(e.status)})))}removeSubagentTool(e){this.#Jt(subagentToolSectionId(e.callId,e.childCallId)),this.#cn()}subagents={begin:e=>this.beginSubagent(e),background:e=>this.backgroundSubagent(e),upsertStep:e=>this.upsertSubagentStep(e),upsertTool:e=>this.upsertSubagentTool(e),removeTool:e=>this.removeSubagentTool(e),complete:e=>this.completeSubagent(e),markChildToolCallId:e=>this.markChildToolCallId(e)};beginSubagent(e){if(this.#s===`hidden`)return;this.#Gt(e.callId,e.name);let t=this.#h.get(subagentHeaderId(e.callId));t!==void 0&&(t.status===`done`&&delete t.status,t.live=!0),this.#C.delete(e.callId),this.#cn()}backgroundSubagent(e){let t=this.#h.get(subagentHeaderId(e.callId));t===void 0||this.#g.has(subagentHeaderId(e.callId))||(t.status=`running`,t.live=!0,t.updateSeq=++this.#b,this.#S.add(e.callId),this.#cn())}completeSubagent(e){let t=this.#h.get(subagentHeaderId(e.callId));if(t!==void 0){if(t.status=`done`,e.authoritative){this.#S.delete(e.callId),this.#C.delete(e.callId);for(let t of this.#m)t.subagentCallId===e.callId&&(t.live=!1)}else{this.#C.add(e.callId);for(let t of this.#m)t.subagentCallId===e.callId&&(t.live=!0)}this.#cn()}}markChildToolCallId(e){this.#v.add(e);let t=this.#y.get(e);t!==void 0&&(this.#Jt(t),this.#y.delete(e),this.#cn())}#Ye(e){let t=this.#h.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#c===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#Kt({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e,t),preformatted:!0,live:t===void 0}),this.#cn()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#j)return;let n=this.#j>0;this.#j=t,t>0?(this.#q=STATUS.connectionAuth,this.#cn()):n&&(this.#q=STATUS.processing,this.#cn())}setVercelStatus(e){this.#M=e,this.#cn()}setRemoteConnectionStatus(e){this.#N=e,this.#cn()}reset(){this.#m=[],this.#h.clear(),this.#g.clear(),this.#A=void 0,this.#k.length=0,this.#_.length=0,this.#D=!1,this.#O=void 0,this.#Xe(),this.#V=!1,this.#Ae=void 0,this.#Oe=void 0,this.#j=0,this.#ve=void 0,this.#ye=void 0,this.#xe=void 0,this.#Se=void 0,this.#Ce=void 0,this.#X&&(this.#n.clearAll(),this.#cn())}renderSessionBoundary(){this.#Ht(),this.#Xe();let e=this.#i.colors,t=this.#i.glyph,n=e.dim(`${t.cornerOpen}${t.dash.repeat(2)} Session restarted, clear context.`);this.#Bt({kind:`session-boundary`,body:n,live:!1}),this.#cn()}#Xe(){this.#v.clear(),this.#y.clear(),this.#T.clear(),this.#S.clear(),this.#C.clear(),this.#x.clear(),this.#Pe=void 0,this.#Fe=void 0,this.#Ie.reset(),this.#Be=void 0,this.#w.clear(),this.#H.reset()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Ct(),this.#Bt({kind:`notice`,body:t,live:!1}),this.#cn())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#d?.append({source:`sandbox`,detail:t}),this.#Ct(),this.#Bt({kind:`sandbox`,body:t,live:!1}),this.#cn())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#Ze();return}this.#Ct(),this.#Ne=t,this.#cn()}clearSetupWarning(){this.#Ze()}#Ze(){this.#Ne!==void 0&&(this.#Ne=void 0,this.#cn())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#Ct();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#Bt(r),this.#cn()}renderCommandResult(e,t){let n=stripTerminalControls(e);n.trim().length!==0&&(this.#Ct(),this.#Bt(t===`success`?{kind:`result`,body:n,live:!1,status:`done`}:t===`error`?{kind:`flow`,title:t,body:n,live:!1}:{kind:`result`,body:n,live:!1}),this.#cn())}#Qe(e,t=`spinner`){this.#Ct(),this.#L=!1,this.#G={kind:`idle`},this.#q=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#Me={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#Lt(),this.#cn()}#$e(e){this.#Ue=void 0,this.#pt();let t=this.#Me;if(t!==void 0){if(this.#Me=void 0,this.#zt(),e){let e=[];for(let n of t.lines){if(n.evidence===!0){e.push(n.text);continue}(n.tone===`warning`||n.tone===`error`)&&(e.length>0&&this.#Bt({kind:`flow`,title:`info`,body:e.join(`
|
|
5
|
-
`),live:!1}),this.#Bt({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#cn()}}async#et(e){let t=this.#st(),n=isMultiSelectRequest(e),r=e.kind===`search`?e.searchAction:void 0,i=e.options,a={options:i,searchAction:r,submitRow:n};`initialValue`in e&&e.initialValue!==void 0&&(a.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(a.initialValues=e.initialValues);let o=initialSelectState(a),s,c=!1,l=0,isCurrentSearch=e=>e===l,clearSearch=()=>{l+=1,c=!1,o=reduceSelect(o,{type:`clear`},{options:i,searchAction:r,submitRow:n}),this.#cn()},loadSearch=async(e,t)=>{c=!0,s=void 0;let a=++l;this.#cn();try{let s=await t(e);if(!isCurrentSearch(a))return;let c=o.filter;i=s,o={...initialSelectState({options:s,searchAction:r,submitRow:n}),filter:c}}catch(e){isCurrentSearch(a)&&(s=toErrorMessage(e))}finally{isCurrentSearch(a)&&(c=!1,this.#cn())}},u=e.notices;if(e.kind===`task-list`||e.kind===`search`&&e.layout===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));u=e.notices??r,t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,options:i,select:o};return u!==void 0&&u.length>0&&(t.notices=u),s!==void 0&&(t.error=s),c&&(t.loadingFrame=this.#hn()),t};return t.question=e=>renderSelectQuestion(panelState(),this.#i,e),this.#cn(),await this.#ut((t,a)=>{let close=e=>{l+=1,a(e)};if(c){t.type===`ctrl-c`?close(void 0):t.type===`escape`?clearSearch():t.type===`ctrl-r`&&this.#cn();return}let u={key:t,options:i,searchAction:r,select:o},d=reduceSetupSelectInput(n?{...u,kind:e.kind,required:e.required}:{...u,kind:e.kind});switch(d.kind){case`cancel`:close(void 0);return;case`repaint`:this.#cn();return;case`update`:o=d.select,s=void 0,this.#cn();return;case`submit`:{let e=searchActionQuery(d.values[0]??``),t=r?.load;if(e===void 0||t===void 0){close(d.values);return}loadSearch(e,t);return}case`error`:s=d.message,this.#cn();return;case`ignore`:return}}).promise}#tt(e){this.#Ct();let t=this.#ct();t.status={kind:`progress`,text:stripTerminalControls(e.status),startedAtMs:Date.now()};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#i,t),this.#cn();let r=this.#ut((t,r)=>{let i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#cn();return;case`repaint`:this.#cn();return;case`submit`:n!==void 0&&r(e.actions[n].value);return;case void 0:return}},()=>{t.status=void 0});return{choice:r.promise,close:()=>r.settle(void 0)}}async#nt(e){let t=this.#st(),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`inline-edit`,layout:`task-list`,message:e.message,options:e.options,select:r,edit:{optionValue:e.editable.value,caretVisible:this.#re,editor:{kind:`rename`,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint}}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#i,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?this.#Pt():(i=lineOf(``),this.#Ft())};return syncEditableRow(),this.#cn(),await this.#ut((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#It(),this.#cn()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#cn()},submit=()=>{let t=selectValueAtCursor([...e.options],r.cursor);if(t===void 0)return;if(t!==e.editable.value){n({kind:`selected`,value:t});return}let o=(i.text||e.editable.defaultValue).trim(),s=e.editable.validate?.(o);if(s!==void 0){a=s,this.#cn();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t);switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#cn();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Ft()).promise}async#rt(e){let t=this.#st(),n=initialProviderPickerState(e.options,e.initialValue),r,cursorBadge=()=>{if(n.phase.kind!==`inactive`)return;let t=selectValueAtCursor([...e.options],n.select.cursor),r=e.options.find(e=>e.value===t);if(r!==void 0)return enterBadge(this.#i,r.checked===!0?`change`:void 0)};t.question=t=>{let r=cursorBadge(),i={kind:`inline-edit`,layout:`stacked`,message:e.message,options:e.options,select:n.select,edit:{optionValue:`
|
|
6
|
-
`,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#at(e){let t=this.#st(),n=lineOf(``),r;return t.question=t=>{let i={message:e.message,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#re)},this.#Pt(),this.#cn(),await this.#ut((t,i)=>{let apply=e=>{n=e,r=void 0,this.#It(),this.#cn()},a=applyLineEditorKey(n,t);if(a!==void 0){apply(a);return}switch(t.type){case`ctrl-c`:case`escape`:i(void 0);return;case`ctrl-r`:this.#cn();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#cn();return}i(t);return}default:return}},()=>this.#Ft()).promise}async#ot(e){let t=this.#st();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#i,t),this.#cn(),await this.#ut((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#cn();return;default:return}}).promise}#st(){return this.#Ct(),this.#L=!1,this.#G={kind:`idle`},this.#q=``,this.#ct()}#ct(){return this.#Me===void 0&&(this.#Me={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#Me}#lt(){this.#Me?.implicit===!0?this.#Me=void 0:this.#Me!==void 0&&(this.#Me.question=void 0,this.#Me.hideLinesWhileQuestion=!1),this.#ue=void 0,this.#Dt(),this.#Me!==void 0&&this.#ft(),this.#cn()}#ut(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#lt(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#lt(),i(e))};return this.#Mt(),this.#ue=t=>{t.type===`ctrl-c`&&this.#yt(),e(t,settle,reject)},this.#Et(),{promise:a,settle}}#dt(e){let t,n=new Promise(e=>{t=e});return this.#Ue=t,this.#ft(e?.interruptible??!0),{promise:n,dispose:()=>{this.#Ue===t&&(this.#Ue=void 0,this.#pt())}}}#ft(e=!0){if(this.#Ue===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#yt();let e=this.#Ue;this.#Ue=void 0,this.#pt(),e?.();return}t.type===`ctrl-r`&&this.#cn()};this.#We=consumer,this.#Mt(),this.#ue=consumer,this.#Et()}#pt(){this.#We!==void 0&&(this.#ue===this.#We&&this.#Dt(),this.#We=void 0)}#mt(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#Me!==void 0){this.#Me.status=t,t===void 0&&(this.#Me.preview=void 0),this.#cn();return}if(!(this.#L||this.#W)){if(t===void 0){this.#G={kind:`idle`},this.#J=void 0,this.#zt(),this.#cn();return}this.#Ct(),this.#Rt(),this.#J=t.text,this.#cn()}}#ht(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Me;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#cn();return}this.#Ct(),this.#Bt({kind:`flow`,title:t,body:n,live:!1}),this.#cn()}#gt(e){let t=this.#Me;t!==void 0&&(t.lines=[],t.outputBuffer=[],t.preview=void 0,t.summary=e===void 0?void 0:{headline:stripTerminalControls(e.headline),facts:e.facts.map(e=>({label:stripTerminalControls(e.label),value:stripTerminalControls(e.value)}))},this.#cn())}#_t(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Me;if(n===void 0){this.#ht(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#cn()}async#vt(e){this.#de=``,this.#Mt(),this.#Ue=void 0,this.#pt(),this.#Dt(),this.#zt(),this.#n.clear(),this.#n.showCursor(),this.#An(),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#de=``,this.#Mt(),this.#n.hideCursor(),this.#kn(),this.#Me!==void 0&&(this.#Lt(),this.#ft()),this.#n.reset(),this.#cn()}}setSessionId(e){this.#ze=e}shutdown(){if(this.#Tt(),this.#Z&&!this.#Q){this.#Q=!0;let e=this.#ze===void 0?``:` ${this.#i.glyph.dot} session ${this.#ze}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}suspendPromptForInput(){this.#U={cursor:this.#F,text:this.#P},this.#Tt()}requestInterrupt(){this.#$=!0,this.#Me!==void 0&&this.#ue?.({type:`ctrl-c`}),this.#he?.(),this.#Tt()}exitRequested(){return this.#ee}#yt(){this.#ee=!0,this.#ne?.()}async#bt(e){if(this.#Ge!==void 0||!this.#X)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Dn(),height:this.#On()}),paint:e=>this.#r.paint(e,this.#On()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#Ke});this.#Ge=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#St=e,this.#ue=e=>{t.handleKey(e)===`close`&&this.#xt()},this.#Et(),t.start()})}#xt(){let e=this.#Ge;if(e===void 0)return;this.#Ge=void 0,e.dispose(),this.#Dt(),this.#r.exit(),this.#n.hideCursor(),this.#cn(),this.#n.showCursor();let t=this.#St;this.#St=void 0,t?.()}#St;#Ct(e){this.#Y=e?.title??this.#Y,e?.contextSize!==void 0&&(this.#be=e.contextSize),!this.#X&&(this.#X=!0,this.#Z=!0,this.#n.reset(),this.#n.hideCursor(),this.#kn(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#me=()=>this.#cn(),this.#t.on(`resize`,this.#me),process.on(`exit`,this.#wt))}#wt=()=>{this.#X&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#Tt(){this.#xt();let e=this.#K;if(this.#K=void 0,e?.(interruptedError()),this.#Dt(),this.#Ft(),this.#zt(),this.#ce!==void 0&&(clearTimeout(this.#ce),this.#ce=void 0),this.#le=!1,this.#X){this.#Rn();for(let e of this.#m)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#cn(),this.#n.clear(),this.#n.showCursor(),this.#An(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#me&&=(this.#t.off(`resize`,this.#me),void 0),process.off(`exit`,this.#wt),this.#X=!1}}#Et(){this.#e.off(`data`,this.#Ot),this.#e.on(`data`,this.#Ot),this.#de.length>0&&queueMicrotask(()=>{this.#ue!==void 0&&this.#de.length>0&&(this.#At(),this.#kt())})}#Dt(){this.#e.off(`data`,this.#Ot),this.#Mt(),this.#ue=void 0}#Ot=e=>{this.#Mt(),this.#de+=this.#fe.write(e),this.#At(),this.#kt()};#kt(){if(this.#de===`\x1B`){this.#pe=setTimeout(()=>{this.#de===`\x1B`&&(this.#de=``,this.#ue?.({type:`escape`}))},30),this.#pe.unref?.();return}if(isIncompletePaste(this.#de)){let e=this.#de;this.#pe=setTimeout(()=>{if(this.#de!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#de=``,t.length>0&&this.#ue?.({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#pe.unref?.();return}if(isIncompleteOsc(this.#de)){let e=this.#de;this.#pe=setTimeout(()=>{this.#de===e&&(this.#de=``)},incompletePasteFlushMs),this.#pe.unref?.()}}#At(){for(;this.#de.length>0;){let e=nextKey(this.#de);if(e.incomplete)return;if(this.#de=this.#de.slice(e.consumed),!(e.key===void 0||e.key.type===`ignore`)){if(e.key.type===`osc`){this.#jt(e.key.value);continue}this.#ue?.(e.key)}}}#jt(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#Ke=t,this.#Ge?.setTerminalBackground(t))}#Mt(){this.#pe&&=(clearTimeout(this.#pe),void 0)}#Nt(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#cn();break;case`enter`:{let e=this.#U.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#Le!==void 0){this.#U=EMPTY_LINE,this.#Ie.requestCancellation(),this.#Ve=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#Le(),this.#cn();break}this.#Ie.enqueue(e)&&(this.#U=EMPTY_LINE),this.#cn();break}case`ctrl-c`:case`escape`:if(this.#Ie.idle&&this.#Le===void 0)break;this.#Ie.handleEscape(),this.#Ve=!0,this.#Le?.(),this.#cn();break;default:{let t=applyLineEditorKey(this.#U,e,{multiline:!0});t!==void 0&&(this.#U=t,this.#cn());break}}}#Pt(){this.#Ft(),this.#It(),this.#oe=setInterval(()=>{this.#re=!this.#re,this.#cn()},500),this.#oe.unref?.()}#Ft(){this.#oe&&=(clearInterval(this.#oe),void 0),this.#re=!0}#It(){this.#re=!0}#Lt(){this.#zt(),this.#se=setInterval(()=>{this.#ie+=1,this.#cn()},90),this.#se.unref?.()}#Rt(){let e=Date.now();this.#ae=e,this.#G={kind:`waiting`,startedAtMs:e},this.#Lt()}#zt(){this.#se&&=(clearInterval(this.#se),void 0)}#Bt(e){e.id!==this.#Oe?.id&&this.#Rn(),e.updateSeq=++this.#b;let t=e.subagentCallId!==void 0&&this.#S.has(e.subagentCallId)?-1:this.#m.findIndex(e=>e.subagentCallId!==void 0&&this.#S.has(e.subagentCallId));t<0?this.#m.push(e):this.#m.splice(t,0,e),e.id&&this.#h.set(e.id,e)}#Vt(e){this.#V=!0,this.#Bt({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#cn()}#Ht(){let e=this.#H.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#bn(e.elapsedMs)}`,n=this.#ye??0;if(this.#be!==void 0&&this.#be>0&&n>0){let e=Math.round(n/this.#be*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#Bt({kind:`turn-stats`,body:t,live:!1})}#Ut(e){if(e==null)return;let t=this.#Be;if(this.#Be=void 0,this.#Ae===e){this.#Ae=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#Bt(n)}#Wt(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#d?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#d===void 0?a:`details: ${this.#d.displayPath}`),this.#Bt(c),this.#cn()}#Gt(e,t){if(this.#T.has(e))return;this.#T.add(e);let n=stripTerminalControls(t),r=this.#x.get(n)??[];if(r.push(e),this.#x.set(n,r),r.length===2){let e=this.#h.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#Bt(i)}#Kt(e){if(e.id&&this.#g.has(e.id))return;let t=e.id?this.#h.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#b;return}this.#Bt(e)}#qt(e){if(e.id&&this.#g.has(e.id))return;let t=e.id?this.#h.get(e.id):void 0;if(t!==void 0){Object.assign(t,e),t.updateSeq=++this.#b;return}let n=e.subagentCallId;if(n===void 0){this.#Bt(e);return}e.id!==this.#Oe?.id&&this.#Rn(),e.updateSeq=++this.#b;let r=-1;for(let e=0;e<this.#m.length;e+=1)this.#m[e]?.subagentCallId===n&&(r=e);this.#m.splice(r<0?this.#m.length:r+1,0,e),e.id!==void 0&&this.#h.set(e.id,e)}#Jt(e){this.#m=this.#m.filter(t=>t.id!==e),this.#h.delete(e)}#Yt(){for(let e of this.#m)e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId)||e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#Xt(e,t,n){switch(e.type){case`step-finish`:this.#d?.recordStepUsage(e.usage),e.usage!==void 0&&this.#H.addUsage(e.usage),this.#rn(n),this.#sn(e.usage),this.#cn();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#Zt(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;n.text.set(e.id,r),this.#Zt(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#Qt(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#Qt(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#$t({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#d?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#$t({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#$t({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#on(e.toolCallId,n);if(r===void 0)break;this.#$t({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#on(e.toolCallId,n);if(this.#d?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#$t({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#on(e.toolCallId,n);if(r===void 0)break;this.#$t({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#Wt(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:if(n.cancelled=!0,!n.restoreCancelledPrompt)break;this.#Re=!0,!this.#Ve&&this.#He!==void 0&&this.#U.text.length===0&&(this.#U=lineOf(this.#He),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#sn(e.usage),this.#cn();break}}#Zt(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#Kt({id:e,kind:`assistant`,body:r,live:n}),this.#cn())}#Qt(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Kt({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#cn())}#$t(e,t,n){if(n.tools.set(e.toolCallId,e),this.#v.has(e.toolCallId)||this.#in(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#y.set(e.toolCallId,r);let i=this.#en(e);this.#Kt(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#an(n),this.#cn()}#en(e){e.output!==void 0&&this.#w.observeRead(e.output);let t={};this.#tn(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#w.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#tn(e){let t=this.#E?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#nn(e){for(let t of e.tools.keys()){if(this.#v.has(t))continue;let e=this.#y.get(t)??toolSectionId(t),n=this.#h.get(e);n?.kind===`tool`&&n.status===`running`&&(n.status=`error`,n.result=`interrupted`,n.live=!1)}}#rn(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#y.get(t)??toolSectionId(t);this.#Jt(r),this.#y.delete(t)}}#in(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#Fe!==e&&(this.#Fe=e,this.#Bt({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#Dn(),this.#i).join(`
|
|
4
|
+
`),i=stripPromptControlCharacters(e?.initialDraft??this.#U.text),a=lineOf(r===void 0?i:i.length===0?r:`${r}\n\n${i}`);return this.#U=EMPTY_LINE,this.#I.begin(a.text),this.#qe(a),this.#R=typeaheadFor(this.#f,a.text),this.#Pt(),this.#cn(),await new Promise((e,r)=>{this.#K=r;let apply=e=>{a=e,this.#It(),this.#qe(a),this.#R=typeaheadFor(this.#f,e.text,this.#R),this.#cn()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#R=void 0,this.#Ft(),this.#Tt(),r(interruptedError())},suggestions=()=>this.#R!==void 0&&isTypeaheadOpen(this.#R)?this.#R:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#ue=r=>{r.type!==`ctrl-c`&&this.#te&&(this.#te=!1,this.#cn());let i=applyLineEditorKey(a,r,{multiline:!0});if(i!==void 0){apply(i);return}switch(r.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#R=moveTypeaheadSelection(e,-1),this.#cn();break}let t=movePromptLine(a,`up`);t===void 0?recall(this.#I.previous(a.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#R=moveTypeaheadSelection(e,1),this.#cn();break}let t=movePromptLine(a,`down`);t===void 0?recall(this.#I.next()):apply(t);break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#R=dismissTypeahead(e),this.#cn());break}case`enter`:{let r=highlighted(),i=r!==void 0&&parsePromptCommand(a.text)===null?typeaheadCompletion(r).trimEnd():a.text;if(i.trim().length===0)break;this.#R=void 0,this.#I.add(i),this.#L=!1,this.#Ft(),this.#q=STATUS.processing,isPromptControlCommand(i)?this.#Bt({kind:`command`,body:stripTerminalControls(i.trim()),live:!1}):(this.#Rt(),this.#Vt(i),this.#Ae=i,this.#H.arm()),this.#qe(EMPTY_LINE),this.#cn(),this.#Dt(),e(i);break}case`ctrl-d`:a.text.length===0?(this.#yt(),interrupt()):apply(deleteForward(a));break;case`ctrl-l`:this.#dn();break;case`ctrl-r`:this.#cn();break;case`ctrl-c`:if(this.#te){this.#yt(),interrupt();break}this.#te=!0,apply(EMPTY_LINE);break;default:break}},this.#Et()})}#qe(e){this.#P=e.text,this.#F=e.cursor}takeQueuedPrompt(){let e=this.#Ie.view().steering,t=this.#Ie.takePrompt();return t!==void 0&&(this.#Be=e?`steer`:`queue`),t}async renderStream(e,t){this.#Ct(t),this.#g.clear(),this.#L=!1,this.#G.kind!==`waiting`&&(this.#G={kind:`waiting`,startedAtMs:Date.now()}),this.#q=this.#j>0?STATUS.connectionAuth:STATUS.processing,this.#Ut(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#d?.recordPrompt(),t?.submittedPrompt!==void 0&&!this.#H.armed&&this.#H.arm(),this.#$=!1,this.#Re=!1,this.#Ve=!1,this.#He=t?.submittedPrompt,this.#Ie.beginTurn(),this.#Le=e.cancel,this.#ve=void 0,this.#ye=void 0,this.#xe=void 0,this.#Se=void 0,this.#Ce=Date.now();let n={tools:t?.tools??this.#a,reasoning:t?.reasoning??this.#o,assistantResponseStats:t?.assistantResponseStats??this.#l};this.#Lt(),this.#W=!0,this.#cn();let r=new Promise(e=>{this.#he=e});this.#ue=e=>this.#Nt(e),this.#Et();let i={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!0};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#$)break;this.#Xt(t,n,i)}}catch(e){let t=summarizeKnownError(e);t===null?this.#Wt(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#Wt(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#he=void 0,this.#$&&e.abort?.(),this.#Le=void 0,this.#Dt(),this.#zt(),this.#W=!1,this.#G.kind===`waiting`&&(this.#G={kind:`idle`}),this.#q=completedTurnStatus({interrupted:this.#$,cancelled:this.#Re,continueSession:t?.continueSession===!0}),this.#rn(i),(this.#$||i.cancelled)&&this.#nn(i),this.#Yt(),this.#d?.reportStats(),this.#cn(),t?.continueSession||this.#Tt()}}async renderIdleStream(e,t){let n={tools:t?.tools??this.#a,reasoning:t?.reasoning??this.#o,assistantResponseStats:t?.assistantResponseStats??this.#l},r={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!1};try{for await(let t of iterateTUIStream(e.events))this.#Xt(t,n,r)}catch(e){let t=summarizeKnownError(e);t===null?this.#Wt(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#Wt(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#rn(r),r.cancelled&&this.#nn(r),this.#Yt(),this.#d?.reportStats(),this.#cn()}}async readToolApproval(e,t){return this.#Ct(t),this.#zt(),this.#L=!1,this.#G={kind:`idle`},this.#q=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#$=!1,this.#cn(),await new Promise((t,n)=>{this.#K=n,this.#ue=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#Rt(),this.#q=STATUS.processing,this.#Dt(),this.#cn(),t({approved:!0})):n===`n`&&(this.#Rt(),this.#q=STATUS.processing,this.#Ye(e.toolCallId),this.#Dt(),this.#cn(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#cn();break;case`ctrl-c`:this.#$=!0,this.#Tt(),n(interruptedError());break;default:break}},this.#Et()})}async readInputQuestion(e,t){this.#Ct(t),this.#zt(),this.#L=!1,this.#z=!1,this.#G={kind:`idle`},this.#$=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`overlay`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,overlayPanel=t=>renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#re},this.#i,t),renderTextSection=()=>{this.#Kt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,void 0,this.#i),preformatted:!0,live:!0})},syncFreeformCaret=()=>{isOnFreeformRow()?this.#Pt():(this.#Ft(),this.#It())};s===`overlay`?(s=`overlay`,this.#L=!1,this.#Jt(o),this.#je=overlayPanel,this.#q=``,syncFreeformCaret(),this.#cn()):(s=`text`,this.#je=void 0,renderTextSection(),this.#L=!0,this.#qe(l),this.#q=``,this.#Pt(),this.#cn());let finalize=t=>{this.#je=void 0,this.#Kt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#L=!1,this.#Rt(),this.#q=STATUS.processing,this.#Ft(),this.#Dt(),this.#cn();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#je=void 0,this.#Kt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Dismissed.`)}`,preformatted:!0,live:!1}),this.#L=!1,this.#q=``,this.#Ft(),this.#Dt(),this.#cn(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#cn())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,r)=>{this.#K=r,u=t,this.#ue=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#It(),s===`text`&&this.#qe(l),this.#cn();return}this.#$=!0,this.#je=void 0,this.#Ft(),this.#Tt(),r(interruptedError());return}if(t.type===`ctrl-r`){this.#cn();return}if(s===`overlay`){switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#It(),this.#cn();break}dismiss();break;default:if(isOnFreeformRow()){let e=applyLineEditorKey(l,t);e!==void 0&&(l=e,this.#It(),this.#cn());break}if(t.type===`text`&&/^[1-9]$/u.test(t.value)){let e=Number(t.value)-1;e<n.length?selectOptionAt(e):e===n.length&&i&&(c=e,syncFreeformCaret(),this.#cn())}break}return}let a=applyLineEditorKey(l,t,{multiline:!0});if(a!==void 0){l=a,this.#It(),this.#qe(l),this.#cn();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#It(),this.#qe(l),this.#cn());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#It(),this.#qe(l),this.#cn();break}dismiss();break;default:break}},this.#Et()})}upsertSubagentStep(e){if(this.#d?.recordSubagentDispatch(e.callId),this.#s===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&n.length===0)){if(this.#Gt(e.callId,e.subagentName),this.#s===`collapsed`){this.#cn();return}this.#qt({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,subagentCallId:e.callId,depth:1,reasoning:t,body:n,collapsed:this.#s!==`full`,live:!e.finalized}),this.#cn()}}upsertSubagentTool(e){if(this.#d?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#d?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#s===`hidden`)return;if(this.#Gt(e.callId,e.subagentName),this.#s===`collapsed`){this.#cn();return}let t=subagentToolStatus(e.status),n=e.status===`preparing`?presentPreparingTool(e.toolName):presentTool(e.toolName,e.input,this.#en({input:e.input,output:e.output,toolCallId:e.childCallId,toolName:e.toolName})),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,subagentCallId:e.callId,depth:1,title:stripTerminalControls(n.title),subtitle:stripTerminalControls(n.subtitle),status:t,live:t===`running`||t===`approval`,expanded:this.#s===`full`,toolName:e.toolName,toolGroup:n.group,toolInput:e.input};n.doneTitle!==void 0&&(r.doneTitle=stripTerminalControls(n.doneTitle)),n.detail!==void 0&&(r.detailLines=n.detail,r.keepDetailWhenDone=n.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=n.summarizeResult(e.output),r.toolOutput=e.output),this.#qt(r),this.#Je(e.callId),this.#cn()}#Je(e){applyCohortLiveness(this.#m.filter(t=>t.kind===`subagent-tool`&&t.subagentCallId===e).map(e=>({block:e,active:isActiveToolStatus(e.status)})))}removeSubagentTool(e){this.#Jt(subagentToolSectionId(e.callId,e.childCallId)),this.#cn()}subagents={begin:e=>this.beginSubagent(e),background:e=>this.backgroundSubagent(e),upsertStep:e=>this.upsertSubagentStep(e),upsertTool:e=>this.upsertSubagentTool(e),removeTool:e=>this.removeSubagentTool(e),complete:e=>this.completeSubagent(e),markChildToolCallId:e=>this.markChildToolCallId(e)};beginSubagent(e){if(this.#s===`hidden`)return;this.#Gt(e.callId,e.name);let t=this.#h.get(subagentHeaderId(e.callId));t!==void 0&&(t.status===`done`&&delete t.status,t.live=!0),this.#C.delete(e.callId),this.#cn()}backgroundSubagent(e){let t=this.#h.get(subagentHeaderId(e.callId));t===void 0||this.#g.has(subagentHeaderId(e.callId))||(t.status=`running`,t.live=!0,t.updateSeq=++this.#b,this.#S.add(e.callId),this.#cn())}completeSubagent(e){let t=this.#h.get(subagentHeaderId(e.callId));if(t!==void 0){if(t.status=`done`,e.authoritative){this.#S.delete(e.callId),this.#C.delete(e.callId);for(let t of this.#m)t.subagentCallId===e.callId&&(t.live=!1)}else{this.#C.add(e.callId);for(let t of this.#m)t.subagentCallId===e.callId&&(t.live=!0)}this.#cn()}}markChildToolCallId(e){this.#v.add(e);let t=this.#y.get(e);t!==void 0&&(this.#Jt(t),this.#y.delete(e),this.#cn())}#Ye(e){let t=this.#h.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#c===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#Kt({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e,t),preformatted:!0,live:t===void 0}),this.#cn()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#j)return;let n=this.#j>0;this.#j=t,t>0?(this.#q=STATUS.connectionAuth,this.#cn()):n&&(this.#q=STATUS.processing,this.#cn())}setVercelStatus(e){this.#M=e,this.#cn()}setRemoteConnectionStatus(e){this.#N=e,this.#cn()}reset(){this.#m=[],this.#h.clear(),this.#g.clear(),this.#A=void 0,this.#k.length=0,this.#_.length=0,this.#D=!1,this.#O=void 0,this.#Xe(),this.#V=!1,this.#Ae=void 0,this.#Oe=void 0,this.#j=0,this.#ve=void 0,this.#ye=void 0,this.#xe=void 0,this.#Se=void 0,this.#Ce=void 0,this.#X&&(this.#n.clearAll(),this.#cn())}renderSessionBoundary(){this.#Ht(),this.#Xe();let e=this.#i.colors,t=this.#i.glyph,n=e.dim(`${t.cornerOpen}${t.dash.repeat(2)} Session restarted, clear context.`);this.#Bt({kind:`session-boundary`,body:n,live:!1}),this.#cn()}#Xe(){this.#v.clear(),this.#y.clear(),this.#T.clear(),this.#S.clear(),this.#C.clear(),this.#x.clear(),this.#Pe=void 0,this.#Fe=void 0,this.#Ie.reset(),this.#Be=void 0,this.#w.clear(),this.#H.reset()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Ct(),this.#Bt({kind:`notice`,body:t,live:!1}),this.#cn())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#d?.append({source:`sandbox`,detail:t}),this.#Ct(),this.#Bt({kind:`sandbox`,body:t,live:!1}),this.#cn())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#Ze();return}this.#Ct(),this.#Ne=t,this.#cn()}clearSetupWarning(){this.#Ze()}#Ze(){this.#Ne!==void 0&&(this.#Ne=void 0,this.#cn())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#Ct();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#Bt(r),this.#cn()}renderCommandResult(e,t){let n=stripAnsi(e);n.trim().length!==0&&(this.#Ct(),this.#Bt(t===`success`?{kind:`result`,body:n,live:!1,status:`done`}:t===`error`?{kind:`flow`,title:t,body:n,live:!1}:{kind:`result`,body:n,live:!1}),this.#cn())}#Qe(e,t=`spinner`){this.#Ct(),this.#L=!1,this.#G={kind:`idle`},this.#q=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#Me={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#Lt(),this.#cn()}#$e(e){this.#Ue=void 0,this.#pt();let t=this.#Me;if(t!==void 0){if(this.#Me=void 0,this.#zt(),e){let e=[];for(let n of t.lines){if(n.evidence===!0){e.push(n.text);continue}(n.tone===`warning`||n.tone===`error`)&&(e.length>0&&this.#Bt({kind:`flow`,title:`info`,body:e.join(`
|
|
5
|
+
`),live:!1}),this.#Bt({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#cn()}}async#et(e){let t=this.#st(),n=isMultiSelectRequest(e),r=e.kind===`search`?e.searchAction:void 0,i=e.options,a={options:i,searchAction:r,submitRow:n};`initialValue`in e&&e.initialValue!==void 0&&(a.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(a.initialValues=e.initialValues);let o=initialSelectState(a),s,c=!1,l=0,isCurrentSearch=e=>e===l,clearSearch=()=>{l+=1,c=!1,o=reduceSelect(o,{type:`clear`},{options:i,searchAction:r,submitRow:n}),this.#cn()},loadSearch=async(e,t)=>{c=!0,s=void 0;let a=++l;this.#cn();try{let s=await t(e);if(!isCurrentSearch(a))return;let c=o.filter;i=s,o={...initialSelectState({options:s,searchAction:r,submitRow:n}),filter:c}}catch(e){isCurrentSearch(a)&&(s=toErrorMessage(e))}finally{isCurrentSearch(a)&&(c=!1,this.#cn())}},u=e.notices;if(e.kind===`task-list`||e.kind===`search`&&e.layout===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));u=e.notices??r,t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,options:i,select:o};return u!==void 0&&u.length>0&&(t.notices=u),s!==void 0&&(t.error=s),c&&(t.loadingFrame=this.#hn()),t};return t.question=e=>renderSelectQuestion(panelState(),this.#i,e),this.#cn(),await this.#ut((t,a)=>{let close=e=>{l+=1,a(e)};if(c){t.type===`ctrl-c`?close(void 0):t.type===`escape`?clearSearch():t.type===`ctrl-r`&&this.#cn();return}let u={key:t,options:i,searchAction:r,select:o},d=reduceSetupSelectInput(n?{...u,kind:e.kind,required:e.required}:{...u,kind:e.kind});switch(d.kind){case`cancel`:close(void 0);return;case`repaint`:this.#cn();return;case`update`:o=d.select,s=void 0,this.#cn();return;case`submit`:{let e=searchActionQuery(d.values[0]??``),t=r?.load;if(e===void 0||t===void 0){close(d.values);return}loadSearch(e,t);return}case`error`:s=d.message,this.#cn();return;case`ignore`:return}}).promise}#tt(e){this.#Ct();let t=this.#ct();t.status={kind:`progress`,text:stripTerminalControls(e.status),startedAtMs:Date.now()};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#i,t),this.#cn();let r=this.#ut((t,r)=>{let i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#cn();return;case`repaint`:this.#cn();return;case`submit`:n!==void 0&&r(e.actions[n].value);return;case void 0:return}},()=>{t.status=void 0});return{choice:r.promise,close:()=>r.settle(void 0)}}async#nt(e){let t=this.#st(),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`inline-edit`,layout:`task-list`,message:e.message,options:e.options,select:r,edit:{optionValue:e.editable.value,caretVisible:this.#re,editor:{kind:`rename`,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint}}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#i,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?this.#Pt():(i=lineOf(``),this.#Ft())};return syncEditableRow(),this.#cn(),await this.#ut((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#It(),this.#cn()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#cn()},submit=()=>{let t=selectValueAtCursor([...e.options],r.cursor);if(t===void 0)return;if(t!==e.editable.value){n({kind:`selected`,value:t});return}let o=(i.text||e.editable.defaultValue).trim(),s=e.editable.validate?.(o);if(s!==void 0){a=s,this.#cn();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t);switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#cn();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Ft()).promise}async#rt(e){let t=this.#st(),n=initialProviderPickerState(e.options,e.initialValue),r,cursorBadge=()=>{if(n.phase.kind!==`inactive`)return;let t=selectValueAtCursor([...e.options],n.select.cursor),r=e.options.find(e=>e.value===t);if(r!==void 0)return enterBadge(this.#i,r.checked===!0?`change`:void 0)};t.question=t=>{let r=cursorBadge(),i={kind:`inline-edit`,layout:`stacked`,message:e.message,options:e.options,select:n.select,edit:{optionValue:`ai-gateway-key`,caretVisible:this.#re,editor:{kind:`key`,phase:n.phase}}};return r!==void 0&&(i.cursorBadge=r),renderSelectQuestion(i,this.#i,t)};let syncCaret=()=>{n.phase.kind===`editing`||n.phase.kind===`invalid`?this.#Pt():this.#Ft()};return syncCaret(),this.#cn(),await this.#ut((t,i,a)=>{let dispatch=t=>{let o=transitionProviderPicker(n,t,e.options);switch(o.kind){case`ignore`:return;case`clear`:r?.abort(),r=void 0,n=o.state,syncCaret(),this.#cn();return;case`cancel`:i(void 0);return;case`render`:n=o.state,syncCaret(),this.#cn();return;case`validate`:{n=o.state,syncCaret(),this.#cn();let t=new AbortController;r=t;let i;try{i=e.validateInlineKey(o.key,t.signal)}catch(e){a(e);return}i.then(e=>{r!==t||t.signal.aborted||(r=void 0,dispatch({type:`validated`,validation:e}))},e=>{r!==t||t.signal.aborted||(r=void 0,a(e))});return}case`settle`:i(o.result);return}},o=setupSelectionIntent(t);switch(o?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:o.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#cn();return;case void 0:break}if(n.phase.kind!==`editing`&&n.phase.kind!==`invalid`)return;let s=applyLineEditorKey(n.phase.editor,t);s!==void 0&&(this.#It(),dispatch({type:`edit`,editor:s}))},()=>{r?.abort(),r=void 0,this.#Ft()}).promise}async#it(e){let t=this.#st(),n=initialModelEditorState(e);return t.question=t=>renderModelEditorQuestion({request:e,state:n},this.#i,t),this.#cn(),await this.#ut((t,r)=>{let dispatch=t=>{let i=transitionModelEditor(n,t,e);switch(i.kind){case`ignore`:return;case`render`:n=i.state,this.#cn();return;case`cancel`:r(void 0);return;case`settle`:r(i.result);return}},i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:i.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#cn();return;case void 0:break}if(t.type===`left`||t.type===`right`){dispatch({type:`adjust`,direction:t.type});return}if(t.type===`tab`){dispatch({type:`adjust`,direction:`right`});return}if(t.type===`backspace`){dispatch({type:`backspace`});return}if(t.type===`text`)for(let e of t.value.replaceAll(`
|
|
6
|
+
`,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#at(e){let t=this.#st(),n=lineOf(``),r;return t.question=t=>{let i={message:e.message,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#re)},this.#Pt(),this.#cn(),await this.#ut((t,i)=>{let apply=e=>{n=e,r=void 0,this.#It(),this.#cn()},a=applyLineEditorKey(n,t);if(a!==void 0){apply(a);return}switch(t.type){case`ctrl-c`:case`escape`:i(void 0);return;case`ctrl-r`:this.#cn();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#cn();return}i(t);return}default:return}},()=>this.#Ft()).promise}async#ot(e){let t=this.#st();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#i,t),this.#cn(),await this.#ut((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#cn();return;default:return}}).promise}#st(){return this.#Ct(),this.#L=!1,this.#G={kind:`idle`},this.#q=``,this.#ct()}#ct(){return this.#Me===void 0&&(this.#Me={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#Me}#lt(){this.#Me?.implicit===!0?this.#Me=void 0:this.#Me!==void 0&&(this.#Me.question=void 0,this.#Me.hideLinesWhileQuestion=!1),this.#ue=void 0,this.#Dt(),this.#Me!==void 0&&this.#ft(),this.#cn()}#ut(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#lt(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#lt(),i(e))};return this.#Mt(),this.#ue=t=>{t.type===`ctrl-c`&&this.#yt(),e(t,settle,reject)},this.#Et(),{promise:a,settle}}#dt(e){let t,n=new Promise(e=>{t=e});return this.#Ue=t,this.#ft(e?.interruptible??!0),{promise:n,dispose:()=>{this.#Ue===t&&(this.#Ue=void 0,this.#pt())}}}#ft(e=!0){if(this.#Ue===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#yt();let e=this.#Ue;this.#Ue=void 0,this.#pt(),e?.();return}t.type===`ctrl-r`&&this.#cn()};this.#We=consumer,this.#Mt(),this.#ue=consumer,this.#Et()}#pt(){this.#We!==void 0&&(this.#ue===this.#We&&this.#Dt(),this.#We=void 0)}#mt(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#Me!==void 0){this.#Me.status=t,t===void 0&&(this.#Me.preview=void 0),this.#cn();return}if(!(this.#L||this.#W)){if(t===void 0){this.#G={kind:`idle`},this.#J=void 0,this.#zt(),this.#cn();return}this.#Ct(),this.#Rt(),this.#J=t.text,this.#cn()}}#ht(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Me;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#cn();return}this.#Ct(),this.#Bt({kind:`flow`,title:t,body:n,live:!1}),this.#cn()}#gt(e){let t=this.#Me;t!==void 0&&(t.lines=[],t.outputBuffer=[],t.preview=void 0,t.summary=e===void 0?void 0:{headline:stripTerminalControls(e.headline),facts:e.facts.map(e=>({label:stripTerminalControls(e.label),value:stripTerminalControls(e.value)}))},this.#cn())}#_t(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Me;if(n===void 0){this.#ht(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#cn()}async#vt(e){this.#de=``,this.#Mt(),this.#Ue=void 0,this.#pt(),this.#Dt(),this.#zt(),this.#n.clear(),this.#An(),this.#r.enter({cursor:`visible`,mouse:!1}),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#r.exit(),this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#de=``,this.#Mt(),this.#n.hideCursor(),this.#kn(),this.#Me!==void 0&&(this.#Lt(),this.#ft()),this.#n.reset(),this.#cn()}}setSessionId(e){this.#ze=e}shutdown(){if(this.#Tt(),this.#Z&&!this.#Q){this.#Q=!0;let e=this.#ze===void 0?``:` ${this.#i.glyph.dot} session ${this.#ze}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}suspendPromptForInput(){this.#U={cursor:this.#F,text:this.#P},this.#Tt()}requestInterrupt(){this.#$=!0,this.#Me!==void 0&&this.#ue?.({type:`ctrl-c`}),this.#he?.(),this.#Tt()}exitRequested(){return this.#ee}#yt(){this.#ee=!0,this.#ne?.()}async#bt(e){if(this.#Ge!==void 0||!this.#X)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Dn(),height:this.#On()}),paint:e=>this.#r.paint(e,this.#On()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#Ke});this.#Ge=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#St=e,this.#ue=e=>{t.handleKey(e)===`close`&&this.#xt()},this.#Et(),t.start()})}#xt(){let e=this.#Ge;if(e===void 0)return;this.#Ge=void 0,e.dispose(),this.#Dt(),this.#r.exit(),this.#n.hideCursor(),this.#cn(),this.#n.showCursor();let t=this.#St;this.#St=void 0,t?.()}#St;#Ct(e){this.#Y=e?.title??this.#Y,e?.contextSize!==void 0&&(this.#be=e.contextSize),!this.#X&&(this.#X=!0,this.#Z=!0,this.#n.reset(),this.#n.hideCursor(),this.#kn(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#me=()=>this.#cn(),this.#t.on(`resize`,this.#me),process.on(`exit`,this.#wt))}#wt=()=>{this.#X&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#Tt(){this.#xt();let e=this.#K;if(this.#K=void 0,e?.(interruptedError()),this.#Dt(),this.#Ft(),this.#zt(),this.#ce!==void 0&&(clearTimeout(this.#ce),this.#ce=void 0),this.#le=!1,this.#X){this.#Rn();for(let e of this.#m)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#cn(),this.#n.clear(),this.#n.showCursor(),this.#An(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#me&&=(this.#t.off(`resize`,this.#me),void 0),process.off(`exit`,this.#wt),this.#X=!1}}#Et(){this.#e.off(`data`,this.#Ot),this.#e.on(`data`,this.#Ot),this.#de.length>0&&queueMicrotask(()=>{this.#ue!==void 0&&this.#de.length>0&&(this.#At(),this.#kt())})}#Dt(){this.#e.off(`data`,this.#Ot),this.#Mt(),this.#ue=void 0}#Ot=e=>{this.#Mt(),this.#de+=this.#fe.write(e),this.#At(),this.#kt()};#kt(){if(this.#de===`\x1B`){this.#pe=setTimeout(()=>{this.#de===`\x1B`&&(this.#de=``,this.#ue?.({type:`escape`}))},30),this.#pe.unref?.();return}if(isIncompletePaste(this.#de)){let e=this.#de;this.#pe=setTimeout(()=>{if(this.#de!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#de=``,t.length>0&&this.#ue?.({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#pe.unref?.();return}if(isIncompleteOsc(this.#de)){let e=this.#de;this.#pe=setTimeout(()=>{this.#de===e&&(this.#de=``)},incompletePasteFlushMs),this.#pe.unref?.()}}#At(){for(;this.#de.length>0;){let e=nextKey(this.#de);if(e.incomplete)return;if(this.#de=this.#de.slice(e.consumed),!(e.key===void 0||e.key.type===`ignore`)){if(e.key.type===`osc`){this.#jt(e.key.value);continue}this.#ue?.(e.key)}}}#jt(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#Ke=t,this.#Ge?.setTerminalBackground(t))}#Mt(){this.#pe&&=(clearTimeout(this.#pe),void 0)}#Nt(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#cn();break;case`enter`:{let e=this.#U.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#Le!==void 0){this.#U=EMPTY_LINE,this.#Ie.requestCancellation(),this.#Ve=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#Le(),this.#cn();break}this.#Ie.enqueue(e)&&(this.#U=EMPTY_LINE),this.#cn();break}case`ctrl-c`:case`escape`:if(this.#Ie.idle&&this.#Le===void 0)break;this.#Ie.handleEscape(),this.#Ve=!0,this.#Le?.(),this.#cn();break;default:{let t=applyLineEditorKey(this.#U,e,{multiline:!0});t!==void 0&&(this.#U=t,this.#cn());break}}}#Pt(){this.#Ft(),this.#It(),this.#oe=setInterval(()=>{this.#re=!this.#re,this.#cn()},500),this.#oe.unref?.()}#Ft(){this.#oe&&=(clearInterval(this.#oe),void 0),this.#re=!0}#It(){this.#re=!0}#Lt(){this.#zt(),this.#se=setInterval(()=>{this.#ie+=1,this.#cn()},90),this.#se.unref?.()}#Rt(){let e=Date.now();this.#ae=e,this.#G={kind:`waiting`,startedAtMs:e},this.#Lt()}#zt(){this.#se&&=(clearInterval(this.#se),void 0)}#Bt(e){e.id!==this.#Oe?.id&&this.#Rn(),e.updateSeq=++this.#b;let t=e.subagentCallId!==void 0&&this.#S.has(e.subagentCallId)?-1:this.#m.findIndex(e=>e.subagentCallId!==void 0&&this.#S.has(e.subagentCallId));t<0?this.#m.push(e):this.#m.splice(t,0,e),e.id&&this.#h.set(e.id,e)}#Vt(e){this.#V=!0,this.#Bt({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#cn()}#Ht(){let e=this.#H.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#bn(e.elapsedMs)}`,n=this.#ye??0;if(this.#be!==void 0&&this.#be>0&&n>0){let e=Math.round(n/this.#be*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#Bt({kind:`turn-stats`,body:t,live:!1})}#Ut(e){if(e==null)return;let t=this.#Be;if(this.#Be=void 0,this.#Ae===e){this.#Ae=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#Bt(n)}#Wt(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#d?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#d===void 0?a:`details: ${this.#d.displayPath}`),this.#Bt(c),this.#cn()}#Gt(e,t){if(this.#T.has(e))return;this.#T.add(e);let n=stripTerminalControls(t),r=this.#x.get(n)??[];if(r.push(e),this.#x.set(n,r),r.length===2){let e=this.#h.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#Bt(i)}#Kt(e){if(e.id&&this.#g.has(e.id))return;let t=e.id?this.#h.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#b;return}this.#Bt(e)}#qt(e){if(e.id&&this.#g.has(e.id))return;let t=e.id?this.#h.get(e.id):void 0;if(t!==void 0){Object.assign(t,e),t.updateSeq=++this.#b;return}let n=e.subagentCallId;if(n===void 0){this.#Bt(e);return}e.id!==this.#Oe?.id&&this.#Rn(),e.updateSeq=++this.#b;let r=-1;for(let e=0;e<this.#m.length;e+=1)this.#m[e]?.subagentCallId===n&&(r=e);this.#m.splice(r<0?this.#m.length:r+1,0,e),e.id!==void 0&&this.#h.set(e.id,e)}#Jt(e){this.#m=this.#m.filter(t=>t.id!==e),this.#h.delete(e)}#Yt(){for(let e of this.#m)e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId)||e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#Xt(e,t,n){switch(e.type){case`step-finish`:this.#d?.recordStepUsage(e.usage),e.usage!==void 0&&this.#H.addUsage(e.usage),this.#rn(n),this.#sn(e.usage),this.#cn();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#Zt(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;n.text.set(e.id,r),this.#Zt(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#Qt(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#Qt(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#$t({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#d?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#$t({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#$t({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#on(e.toolCallId,n);if(r===void 0)break;this.#$t({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#on(e.toolCallId,n);if(this.#d?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#$t({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#on(e.toolCallId,n);if(r===void 0)break;this.#$t({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#Wt(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:if(n.cancelled=!0,!n.restoreCancelledPrompt)break;this.#Re=!0,!this.#Ve&&this.#He!==void 0&&this.#U.text.length===0&&(this.#U=lineOf(this.#He),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#sn(e.usage),this.#cn();break}}#Zt(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#Kt({id:e,kind:`assistant`,body:r,live:n}),this.#cn())}#Qt(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Kt({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#cn())}#$t(e,t,n){if(n.tools.set(e.toolCallId,e),this.#v.has(e.toolCallId)||this.#in(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#y.set(e.toolCallId,r);let i=this.#en(e);this.#Kt(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#an(n),this.#cn()}#en(e){e.output!==void 0&&this.#w.observeRead(e.output);let t={};this.#tn(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#w.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#tn(e){let t=this.#E?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#nn(e){for(let t of e.tools.keys()){if(this.#v.has(t))continue;let e=this.#y.get(t)??toolSectionId(t),n=this.#h.get(e);n?.kind===`tool`&&n.status===`running`&&(n.status=`error`,n.result=`interrupted`,n.live=!1)}}#rn(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#y.get(t)??toolSectionId(t);this.#Jt(r),this.#y.delete(t)}}#in(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#Fe!==e&&(this.#Fe=e,this.#Bt({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#Dn(),this.#i).join(`
|
|
7
7
|
`),live:!1})),this.#Pe=void 0}else this.#Pe=t.length>0?t:void 0,this.#Fe=void 0;return this.#cn(),!0}#an(e){let t=[];for(let n of e.tools.values()){if(this.#v.has(n.toolCallId))continue;let e=this.#y.get(n.toolCallId)??toolSectionId(n.toolCallId),r=this.#h.get(e);r?.kind===`tool`&&t.push({block:r,active:isActiveToolStatus(n.status)})}applyCohortLiveness(t)}#on(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#y.get(e)??toolSectionId(e),i=this.#h.get(r);if(!(i===void 0||i.kind!==`tool`))return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.toolName??i.title??`tool`}}#sn(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#ve=(t??0)+(n??0)),this.#ye=t??this.#ye,this.#xe=n??this.#xe,this.#xe!=null&&this.#Ce!==void 0){let e=(Date.now()-this.#Ce)/1e3;e>0&&(this.#Se=this.#xe/e)}}#cn(){if(this.#X){if(this.#ge){this.#_e=!0;return}this.#ge=!0;try{do this.#_e=!1,this.#ln();while(this.#_e)}finally{this.#ge=!1}}}#ln(){if(!this.#X)return;if(this.#Ge!==void 0){this.#Ge.repaint();return}let e=this.#Dn(),t=this.#vn(e),n=Math.max(1,this.#On()-t.length),r=[],i=this.#A,a=groupToolBlocksForDisplay(this.#m),o=0;for(;o<a.length&&a[o].display.live===!1;)o+=1;if(o>0){let e=new Set(a.slice(0,o).flatMap(e=>e.members));for(let t=this.#m.length-1;t>=0;--t)e.has(this.#m[t])&&this.#m.splice(t,1)}for(let t of a.slice(0,o)){for(let e of t.members)this.#_.push(e),e.id&&(this.#g.add(e.id),this.#h.delete(e.id));if(this.#Bn(t.display))continue;let n=this.#mn(t.display,e,i);i=previousBlockOf(t.display),this.#A=i,r.push(...n),this.#k.push(...n)}let s=[];for(let{display:t}of a.slice(o)){if(this.#Bn(t))continue;let n=this.#mn(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)s.push({block:t,row:n[e]})}let c=[...clipLiveRows(s.map(e=>e.row),n,e,this.#i),...t];r.length>0?this.#n.flush(r,c):this.#n.update(c)}#un(){if(!this.#X)return;let e=this.#Dn(),t=this.#vn(e),n=Math.max(1,this.#On()-t.length),r=this.#A,i=[];for(let{display:t}of groupToolBlocksForDisplay(this.#m)){if(this.#Bn(t))continue;let n=this.#mn(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#i),...t];this.#n.clearAll(),this.#n.flush([...this.#pn(),...this.#k],a)}logDisplayMode(){return this.#p}setLogDisplayMode(e){e!==this.#p&&(this.#p=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#fn(),this.#X&&this.#un())}flushDelayedDevBuildErrors(){let e=this.#De;e!==void 0&&(this.#De=void 0,this.#Bt({kind:`log`,title:`stderr`,body:e,live:!0}),this.#cn())}#dn(){this.#le=!0,this.#ce!==void 0&&clearTimeout(this.#ce),this.#ce=setTimeout(()=>{this.#le=!1,this.#ce=void 0,this.#cn()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#p)),this.#cn()}#fn(){let e=this.#Dn();this.#k.length=0;let t;for(let{display:n}of groupToolBlocksForDisplay(this.#_,{logCoalescing:`runs`})){if(this.#Bn(n))continue;let r=this.#mn(n,e,t);t=previousBlockOf(n),this.#k.push(...r)}this.#A=t}#pn(){let e=this.#E;if(e===void 0)return[];let t={name:e.name,theme:this.#i,width:this.#Dn()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#mn(e,t,n){let r={activityPulse:this.#gn(this.#ae,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#i,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#hn(){return this.#i.spinner[this.#ie%this.#i.spinner.length]??``}#gn(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#_n(e,t){return e.indicator.kind===`spinner`?{glyph:this.#hn(),color:`yellow`}:{glyph:this.#gn(e.indicator.startedAtMs,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#vn(e){let n=this.#i.colors,r=[``];if(this.#je!==void 0)return r.push(...this.#je(e),``),this.#wn(r,e),r;let a=this.#Me;if(a!==void 0){let t=this.#_n(a,a.status),n;if(a.status!==void 0){let{startedAtMs:e,...r}=a.status,i=Date.now()-e,o=i>=5e3?` ${formatTurnDuration(i)}`:``;n={...r,text:`${r.text}${o}`,indicator:t}}let i;if(a.question!==void 0){let t=a.question(e);i={kind:`question`,rows:t},n!==void 0&&(i={kind:`question`,rows:t,status:n})}else n===void 0?i=a.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:a.preview,indicator:t}:(i={kind:`status`,status:n},a.preview!==void 0&&(i={kind:`status`,status:n,preview:a.preview}));let o={title:a.title,lines:a.summary===void 0?a.hideLinesWhileQuestion===!0?[]:a.lines:[{text:a.summary.headline,tone:`success`},...a.summary.facts.map(e=>({text:`${e.label}: ${e.value}`,tone:`info`}))],content:i};return r.push(...renderFlowPanel(o,this.#i,e)),this.#Tn(r,e),r}this.#Ne!==void 0&&r.push(...renderAttentionRows(this.#Ne,e,this.#i),``),this.#Pe!==void 0&&r.push(...renderTodoPanelRows({items:this.#Pe,width:e,theme:this.#i,working:this.#W||this.#G.kind===`waiting`,pulse:this.#gn(this.#ae,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)}),``);let o=renderMessageQueueRows({view:this.#Ie.view(),width:e,theme:this.#i,working:this.#W});if(o.length>0&&r.push(...o,``),this.#L){let i=this.#R===void 0?void 0:inlineCommandHint(this.#R);i===void 0&&this.#R!==void 0&&isTypeaheadOpen(this.#R)&&r.push(...renderCommandSuggestions(this.#R,this.#i,e)),this.#te&&r.push(clip(n.dim(`Press Ctrl+C again to exit`),e),``);let a=isPromptControlCommand(this.#P),o=i?n.dim(` ${i}`):``,s=[];this.#wn(s,e);let u=Math.max(1,this.#On()-1-r.length-1-s.length),f={text:this.#P,cursor:this.#F,width:e,theme:this.#i,caretVisible:this.#re,isCommand:a,ghost:o,maxRows:u};return this.#z&&this.#P.length===0&&(f.placeholder=this.#V?``:promptPlaceholder(Date.now()-this.#B)),r.push(...promptInputRows(f)),r.push(...s),r}let s=this.#G.kind===`waiting`&&this.#J===void 0;if(this.#W||s){r.push(this.#yn(e)),this.#Sn(r,e);let t=[];return this.#wn(t,e),!this.#W&&t.length>0&&r.push(``),r.push(...t),r}if(this.#U.text.length>0)return this.#Cn(r,e,{inert:!1}),this.#wn(r,e),r;let u=this.#J??(this.#q.length>0?this.#q:`Ready`),f=this.#En(),p=n.dim(this.#i.glyph.dot),m=f?`${p} ${u} ${n.dim(this.#i.glyph.dot)} ${f}`:`${p} ${u}`;return r.push(clip(m,e)),this.#wn(r,e),r}#yn(e){let t=this.#i.colors,n=this.#gn(this.#ae,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),r=this.#G,i=this.#H.startedAtMs??this.#Ce??(r.kind===`waiting`?r.startedAtMs:Date.now()),a=Date.now()-i,o=`${typewriterText(`Working for`,a,80)} ${this.#bn(a)}`;return clip(`${t.yellow(n)} ${t.dim(o)}`,e)}#bn(e){return`${formatTurnDuration(e)}${this.#xn()}`}#xn(){let{inputTokens:e,outputTokens:t}=this.#H.usage;return e===0&&t===0?``:` ${this.#i.glyph.dash.repeat(2)} ${formatTokenFlow({inputTokens:e,outputTokens:t},this.#i.glyph)}`}#Sn(e,t){this.#W&&this.#Cn(e,t,{inert:!0})}#Cn(e,t,n){e.push(``);let r={text:this.#U.text,cursor:this.#U.cursor,width:t,theme:this.#i,caretVisible:!0,isCommand:!1,ghost:``,maxRows:4,inert:n.inert};n.inert&&this.#U.text.length===0&&(r.placeholder=``),e.push(...promptInputRows(r))}#wn(e,t){let n=this.#N===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#i,width:r};this.#le&&(i.logLevel=this.#p);let a=this.#E?.serverUrl;if(a!==void 0&&this.#N===void 0){let e=new URL(a).port;e.length>0&&(i.serverPort=e)}let o=this.#E?.info?.agent.model;o?.id!==void 0&&(i.model=o.id),o?.reasoning!==void 0&&o.reasoning!==`provider-default`&&(i.reasoning=o.reasoning),readGatewayServiceTier(o?.providerOptions).kind===`priority`&&(i.fastMode=!0);let s=o?.endpoint;s!==void 0&&(i.endpoint=s),this.#M!==void 0&&(i.vercel=this.#M),this.#N!==void 0&&(i.remote=this.#N);let c=buildStatusLine(i);c!==void 0&&e.push(clip(`${n}${c}`,t))}#Tn(e,t){if(this.#N===void 0)return;let n=Math.max(1,t-2),r=buildStatusLine({remote:this.#N,theme:this.#i,width:n});r!==void 0&&e.push(``,clip(` ${r}`,t))}#En(){let e=this.#i.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#ve,outputTokens:this.#xe,tokensPerSecond:this.#Se},this.#l);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#i.glyph.dot} `)):``}#Dn(){return Math.max(20,this.#t.columns||80)}#On(){return Math.max(8,this.#t.rows||24)}#kn(){if(this.#we!==void 0||!this.#u)return;this.#Te=``,this.#Ee=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#Mn(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#d?.subscribeLogRecords(e=>this.#jn(e)),this.#we=()=>{this.#d?.unsubscribeLogRecords(),e(),t()}}#An(){let e=this.#we;e!==void 0&&(this.#we=void 0,e(),this.#Te.length>0&&(this.#d?.append({source:`stdout`,detail:this.#Te}),this.#zn(`stdout`)&&process.stdout.write(`${this.#Te}\n`),this.#Te=``),this.#Ee.length>0&&(this.#d?.append({source:`stderr`,detail:this.#Ee}),this.#zn(`stderr`)&&process.stderr.write(`${this.#Ee}\n`),this.#Ee=``))}#jn(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#Pn(`[eve:${e.namespace}] ${e.message}${t}`),this.#cn()}#Mn(e,t){let n=(e===`stdout`?this.#Te:this.#Ee)+t;if(e===`stdout`&&parseDevRebuildLogLine(n.trimEnd())!==void 0){this.#Te=``,this.#d?.append({source:e,detail:n.trimEnd()}),this.#Nn(n.trimEnd()),this.#cn();return}let r=n.lastIndexOf(`
|
|
8
8
|
`),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#Te=i:this.#Ee=i,r===-1)return;let a=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);a.trim().length!==0&&(this.#d?.append({source:e,detail:a}),e===`stdout`?this.#Nn(a):this.#Pn(a),this.#cn())}#Nn(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
|
|
9
9
|
`);t=[],e.trim().length!==0&&this.#Bt({kind:`log`,title:`stdout`,body:e,live:!0})};for(let n of e.split(`
|
package/dist/src/cli/run.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BuildHost } from "#cli/commands/build.js";
|
|
2
|
+
import { resolveCliApplicationProject } from "#cli/application-root.js";
|
|
2
3
|
import { resolveDevUiMode, resolveTuiDisplayOptions } from "#cli/dev/ui-options.js";
|
|
3
4
|
import { type ResolveVerifiedRemoteDevelopmentClient, type RunAcpServer } from "#cli/acp/command.js";
|
|
4
5
|
import type { RunDevelopmentTuiInput } from "#cli/dev/tui/tui.js";
|
|
@@ -27,14 +28,12 @@ interface CliRuntimeDependencies {
|
|
|
27
28
|
runInvoke: InvokeCliRuntimeDependencies["runInvoke"];
|
|
28
29
|
runEvalCommand(evalIds: readonly string[], options: EvalCliOptions, logger: CliLogger, appRoot: string): Promise<void>;
|
|
29
30
|
startHost(appRoot: string, options?: DevelopmentServerOptions): DevelopmentServer;
|
|
30
|
-
|
|
31
|
+
resolveApplicationProject: typeof resolveCliApplicationProject;
|
|
31
32
|
startProductionHost(appRoot: string, options?: {
|
|
32
33
|
host?: string;
|
|
33
34
|
port?: number;
|
|
34
35
|
}): Promise<ProductionServerHandle>;
|
|
35
36
|
}
|
|
36
37
|
type CliRuntimeOverrides = Partial<CliRuntimeDependencies>;
|
|
37
|
-
/**
|
|
38
|
-
* Runs the eve CLI entrypoint.
|
|
39
|
-
*/
|
|
38
|
+
/** Runs the eve CLI entrypoint. */
|
|
40
39
|
export declare function runCli(argv?: string[], logger?: CliLogger, runtime?: CliRuntimeOverrides): Promise<void>;
|
package/dist/src/cli/run.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{Command,CommanderError,InvalidArgumentError}from"#compiled/commander/index.js";import{applicationCommand}from"#cli/application-command.js";import{parseDevelopmentHeaderOption,resolveDevelopmentUrlTarget}from"#cli/dev/url-target.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";import{FORCED_EXIT_BACKSTOP_MS,installShutdownSignal,waitForShutdownSignal}from"#cli/shutdown.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{eveCliBanner}from"#cli/banner.js";import{startCliLiveRow}from"#cli/ui/live-row.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{registerBuildCommand}from"#cli/commands/build.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{findCliApplicationRoot,
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{Command,CommanderError,InvalidArgumentError}from"#compiled/commander/index.js";import{applicationCommand}from"#cli/application-command.js";import{parseDevelopmentHeaderOption,resolveDevelopmentUrlTarget}from"#cli/dev/url-target.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";import{FORCED_EXIT_BACKSTOP_MS,installShutdownSignal,waitForShutdownSignal}from"#cli/shutdown.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{eveCliBanner}from"#cli/banner.js";import{startCliLiveRow}from"#cli/ui/live-row.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{registerBuildCommand}from"#cli/commands/build.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{findCliApplicationRoot,resolveCliApplicationProject}from"#cli/application-root.js";import{registerIntegrationCommands}from"#cli/commands/register-integration-commands.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{registerRegistryCommands}from"#cli/commands/register-registry-commands.js";import{resolveDevUiMode,resolveTuiDisplayOptions}from"#cli/dev/ui-options.js";import{registerAcpCommand}from"#cli/acp/command.js";import{waitForServerOrStop,waitForUiOrServer}from"#cli/dev/wait-for-ui.js";import{registerRuntimeInvokeCommand}from"#cli/invoke/command.js";import{parseContextSizeOption,parseDisplayMode,parseLogsMode,parsePortOption,parseReasoningOption,parseStatsMode}from"#cli/option-parsers.js";import{resolveTuiTitle}from"#cli/dev/tui/target.js";import{resumeDevelopmentRuntimeArtifacts,suspendDevelopmentRuntimeArtifacts}from"#services/dev-client/runtime-artifacts.js";const devBootLog=createLogger(`dev.boot`);function createDevBootProgressReporter(e){return t=>{switch(t.type){case`phase-started`:e?.update(`Building your agent`,t.phase),devBootLog.debug(t.phase);return;case`phase-finished`:devBootLog.debug(`${t.phase} finished`,{ms:t.elapsedMs});return;case`before-first-paint`:e?.stop();return;default:return t}}}async function loadPrintApplicationInfo(){return(await import(`#cli/commands/info.js`)).printApplicationInfo}async function loadRunDevelopmentTui(){return(await import(`#cli/dev/tui/tui.js`)).runDevelopmentTui}async function loadRunEvalCommand(){return(await import(`#evals/cli/eval.js`)).runEvalCommand}async function loadStartHost(){return(await import(`#cli/dev/local-server-process.js`)).createDevelopmentServer}const loadIsActiveDevelopmentServerForApp=async()=>(await import(`#internal/nitro/host.js`)).isActiveDevelopmentServerForApp;async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function hasInteractiveTerminal(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function createCliProgram(e,n,p){let g=resolveInstalledPackageInfo().version,_=new Command,v=createCliTheme();_.name(`eve`).description(`Build and run an eve application.`).version(g).showHelpAfterError().exitOverride().hook(`preAction`,(t,n)=>{[`info`,`dev`,`init`].includes(n.name())&&e.log(eveCliBanner())}).configureOutput({writeErr:t=>{e.error(t.trimEnd())},writeOut:t=>{e.log(t.trimEnd())}}),applicationCommand(_.command(`channels`).description(`Manage user-authored channels in the current project.`).command(`list`),p).description(`List user-authored channels in the current project.`).option(`--json`,`Output as JSON`).action(async t=>{let{runChannelsListCommand:n}=await import(`#cli/commands/channels.js`);await n(e,p.project,t)}),registerIntegrationCommands({program:_,logger:e,applicationContext:p});let b=_.command(`extension`).description(`Create and build reusable eve extension packages.`);b.command(`init [target]`).description(`Create a new eve extension package.`).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,n)=>{n.yes&&e.error(`warning: --yes has no effect for eve extension init.`);let{runExtensionInitCommand:r}=await import(`#cli/commands/extension-init.js`);await r(e,p.root,t)}),b.command(`build`).description(`Build the current package as an eve extension.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);t(p.root);let{runExtensionBuildCommand:n}=await import(`#cli/commands/extension-build.js`);await n(e,p.root)}),registerRegistryCommands({program:_,logger:e,applicationContext:p}),_.command(`init [target]`).description(`Create a new eve agent, or add one to an existing project directory.`).option(`--channel-web-nextjs`,`Add the Web Chat application (Next.js)`).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,n)=>{n.yes&&e.error(`warning: --yes has no effect for eve init.`);let{runInitCommand:r}=await import(`#cli/commands/init.js`);await r(e,p.root,t,{channelWebNextjs:n.channelWebNextjs,model:n.model,reasoning:n.reasoning})}),applicationCommand(_.command(`set`),p).description(`Change root agent model settings.`).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).action(async t=>{let{runSetCommand:n}=await import(`#cli/commands/set.js`);await n(e,p.root,t)}),registerProjectCommands({program:_,logger:e,applicationContext:p}),registerBuildCommand({applicationContext:p,buildHost:n.buildHost,logger:e,program:_}),applicationCommand(_.command(`start`),p).description(`Start a built eve application.`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).action(async t=>{let{loadDevelopmentEnvironmentFiles:r}=await import(`#cli/dev/environment.js`);r(p.root);let i=await(n.startProductionHost??await loadStartProductionHost())(p.root,{host:t.host,port:t.port});e.log(renderCliTaggedLine(v,{message:`server listening at ${i.url}`,tag:`start`,tone:`success`})),await waitForShutdownSignal({close:()=>i.close(),wait:()=>i.wait()})}),registerRuntimeInvokeCommand({applicationContext:p,logger:e,program:_,runtime:n}),registerAcpCommand({applicationContext:p,eveVersion:g,program:_,resolveVerifiedRemoteDevelopmentClient:n.resolveVerifiedRemoteDevelopmentClient,runAcpServer:n.runAcpServer,startHost:n.startHost}),applicationCommand(_.command(`dev`),p,e=>resolveDevelopmentUrlTarget(e.opts(),e.processedArgs[0])===void 0).description(`Start the eve development server or connect to an existing URL.`).argument(`[url]`,`Connect to an existing server URL`,parseDevelopmentServerUrl).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 2000)`,parsePortOption).option(`-u, --url <url>`,`Connect to an existing server URL`,parseDevelopmentServerUrl).option(`-H, --header <header>`,`Request header for a URL target, in "Name: value" form (repeatable)`,parseDevelopmentHeaderOption).option(`--no-ui`,`Start the server without an interactive UI`).option(`--name <name>`,`Title shown in the terminal UI (defaults to the app folder name)`).option(`--input <text>`,`Pre-fill the prompt input, or start onboarding with /model`).option(`--tools <mode>`,`How tool calls render: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--reasoning <mode>`,`How reasoning renders: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--subagents <mode>`,`How subagent sections render: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--connection-auth <mode>`,`How connection authorization renders: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--assistant-response-stats <mode>`,`Assistant header statistic: tokens | tokensPerSecond`,parseStatsMode).option(`--context-size <tokens>`,`Model context window size, shown as a usage percentage`,parseContextSizeOption).option(`--logs <mode>`,`Which server/agent logs to show: all | stderr | sandbox | none`,parseLogsMode).addHelpText(`after`,`
|
|
2
2
|
You can also pass a bare URL, for example: eve dev https://example.com
|
|
3
3
|
`).action(async(t,i)=>{let a=resolveDevelopmentUrlTarget(i,t),s=a?.serverUrl,u=hasInteractiveTerminal(),d=resolveDevUiMode({options:i,interactive:u});if(i.input!==void 0&&d===`headless`)throw new InvalidArgumentError(`--input requires the interactive UI.`);let f=!1;s!==void 0&&(f=await(n.isActiveDevelopmentServerForApp??await loadIsActiveDevelopmentServerForApp())({appRoot:p.root,serverUrl:s}));let runInteractiveUi=async(e,t,r)=>{let o=await devBootPhase(`loading interactive UI`,async()=>n.runDevelopmentTui??await loadRunDevelopmentTui(),t),c=resolveTuiDisplayOptions(i),l=s===void 0||f?{kind:`local`,serverUrl:e.serverUrl,workspaceRoot:e.appRoot??p.root}:{kind:`remote`,serverUrl:e.serverUrl,workspaceRoot:p.root},u=resolveTuiTitle({name:i.name,target:l});u!==void 0&&(c.name=u);let d={target:l,initialInput:i.input,onBootProgress:t,lifecycle:r,...c};l.kind===`local`&&(d.withExclusiveTerminal=async t=>await(async()=>{if(!await suspendDevelopmentRuntimeArtifacts({serverUrl:e.serverUrl}))throw Error(`Could not pause the development server for integration setup.`);try{return await t()}finally{await resumeDevelopmentRuntimeArtifacts({serverUrl:e.serverUrl,silent:!0})}})()),a?.headers===void 0?await o(d):await o({...d,headers:a.headers})};if(s){let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);if(t(p.root),e.log(`↗ ${f?`local`:`remote`} mode targeting ${v.info(new URL(s).host)}`),d===`headless`){e.log(renderCliTaggedLine(v,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}e.log(``);let n=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS});try{await runInteractiveUi({serverUrl:s},void 0,n)}finally{n.dispose()}return}d===`tui`&&e.log(``);let m=d===`tui`?startCliLiveRow(e):void 0,h=createDevBootProgressReporter(m);m?.update(`Building your agent`);let g,_,closeServer=()=>g===void 0?Promise.resolve():(_??=g.close(),_.catch(()=>void 0),_),y=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS,onStop:()=>{closeServer()}});try{g=(n.startHost??await loadStartHost())(p.root,{existing:d===`tui`?`attach-if-unconfigured`:`reject`,host:i.host,onBootProgress:h,port:i.port});let t=(await Promise.race([g.start().then(e=>({handle:e})),y.stopped.then(()=>({handle:void 0}))])).handle;if(t===void 0)return;if(d!==`tui`&&e.log(renderCliTaggedLine(v,{message:`server listening at ${t.url}`,tag:`dev`,tone:`success`})),d===`headless`){i.ui!==!1&&!u&&e.log(renderCliTaggedLine(v,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForServerOrStop(g,y);return}await waitForUiOrServer({handle:t,lifecycle:y,server:g,runUi:async()=>await runInteractiveUi({appRoot:t.appRoot,serverUrl:t.url},h,y)})}finally{m?.stop(),await closeServer(),y.dispose()}});let x=_.command(`logs`).description("Inspect local `eve dev` diagnostic logs (.eve/logs).");return applicationCommand(x.command(`show [logid]`,{isDefault:!0}),p).description(`Print a diagnostic log (the most recent when logid is omitted).`).option(`--dump`,`Prepend the log's environment dump (.dump sibling)`).option(`--events`,`Interleave session events from the local workflow store`).action(async(t,n)=>{let{runLogsShowCommand:r}=await import(`#cli/commands/logs.js`);await r(e,p.root,t,n)}),applicationCommand(x.command(`ls`),p).description(`List diagnostic logs, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runLogsListCommand:n}=await import(`#cli/commands/logs.js`);await n(e,p.root,t)}),applicationCommand(_.command(`traces [trace]`),p).usage(`[options] [trace]
|
|
4
|
-
eve traces ls [options]`).description("Show a local `eve dev` trace (the most recent when trace is omitted).").option(`--verbose`,`Expand every span with all attributes and events`).option(`--json`,`Output as JSON`).action(async(t,n)=>{let{runTraceShowCommand:r}=await import(`#cli/commands/trace.js`);await r(e,p.root,t,n)}).command(`ls`).description(`List local traces, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runTraceListCommand:n}=await import(`#cli/commands/trace.js`);await n(e,p.root,t)}),applicationCommand(_.command(`info`),p).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async t=>{await(n.printApplicationInfo??await loadPrintApplicationInfo())(e,p.root,t)}),applicationCommand(_.command(`eval`),p).description(`Run evals against an eve agent.`).argument(`[evalIds...]`,`Eval ids (or directory prefixes) to run (all discovered evals when omitted)`).option(`--url <url>`,`Remote agent URL (skip local host startup)`,parseDevelopmentServerUrl).option(`--tag <tag...>`,`Run only evals carrying a tag`).option(`--exclude-tag <tag...>`,`Skip evals carrying a tag`).option(`--strict`,`Fail the exit code when any score falls below its threshold`).option(`--list`,`Print discovered evals without running them`).option(`--timeout <ms>`,`Per-eval timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent eval executions`).option(`--json`,`Output results as JSON`).option(`--junit <path>`,`Write JUnit XML results to a file`).option(`--skip-report`,`Skip eval-defined reporters (e.g. Braintrust)`).option(`--verbose`,`Stream per-eval t.log lines to stdout`).action(async(t,r)=>{await(n.runEvalCommand??await loadRunEvalCommand())(t,r,e,p.root)}),_}async function runCli(e=process.argv.slice(2),t=console,r={}){let i={root:resolveApplicationRoot(),async resolve(){
|
|
4
|
+
eve traces ls [options]`).description("Show a local `eve dev` trace (the most recent when trace is omitted).").option(`--verbose`,`Expand every span with all attributes and events`).option(`--json`,`Output as JSON`).action(async(t,n)=>{let{runTraceShowCommand:r}=await import(`#cli/commands/trace.js`);await r(e,p.root,t,n)}).command(`ls`).description(`List local traces, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runTraceListCommand:n}=await import(`#cli/commands/trace.js`);await n(e,p.root,t)}),applicationCommand(_.command(`info`),p).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async t=>{await(n.printApplicationInfo??await loadPrintApplicationInfo())(e,p.root,t)}),applicationCommand(_.command(`eval`),p).description(`Run evals against an eve agent.`).argument(`[evalIds...]`,`Eval ids (or directory prefixes) to run (all discovered evals when omitted)`).option(`--url <url>`,`Remote agent URL (skip local host startup)`,parseDevelopmentServerUrl).option(`--tag <tag...>`,`Run only evals carrying a tag`).option(`--exclude-tag <tag...>`,`Skip evals carrying a tag`).option(`--strict`,`Fail the exit code when any score falls below its threshold`).option(`--list`,`Print discovered evals without running them`).option(`--timeout <ms>`,`Per-eval timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent eval executions`).option(`--json`,`Output results as JSON`).option(`--junit <path>`,`Write JUnit XML results to a file`).option(`--skip-report`,`Skip eval-defined reporters (e.g. Braintrust)`).option(`--verbose`,`Stream per-eval t.log lines to stdout`).action(async(t,r)=>{await(n.runEvalCommand??await loadRunEvalCommand())(t,r,e,p.root)}),_}async function runCli(e=process.argv.slice(2),t=console,r={}){let i={root:resolveApplicationRoot(),async resolve(){let e=await(r.resolveApplicationProject??resolveCliApplicationProject)(i.root);i.project=e,i.root=e.appRoot}},a=createCliProgram(t,r,i),o=e;if(o.length===0){let e=await(r.findApplicationRoot??findCliApplicationRoot)(i.root);e===void 0?o=[`init`]:(i.root=e,o=[`dev`])}try{await a.parseAsync(o,{from:`user`})}catch(e){if(e instanceof CommanderError){if(e.exitCode===0)return;let n=await(r.isCodingAgentLaunch??isCodingAgentLaunch)();if(o[0]===`init`&&n){let{initAgentInstructions:e}=await import(`#cli/commands/agent-instructions.js`);t.log(e())}throw Error(e.message)}throw e}}export{resolveDevUiMode,resolveTuiDisplayOptions,runCli};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Alternate-screen mode for full-screen
|
|
2
|
+
* Alternate-screen mode for temporary full-screen terminal ownership.
|
|
3
3
|
*
|
|
4
4
|
* The dev TUI's transcript deliberately streams into native scrollback (see
|
|
5
5
|
* `live-region.ts`), but a modal viewer wants the whole terminal without
|
|
@@ -13,12 +13,18 @@
|
|
|
13
13
|
export interface AltScreenOutput {
|
|
14
14
|
write(chunk: string): boolean;
|
|
15
15
|
}
|
|
16
|
+
export interface AltScreenEnterOptions {
|
|
17
|
+
/** Interactive subprocesses need the terminal cursor; rendered views do not. */
|
|
18
|
+
cursor?: "hidden" | "visible";
|
|
19
|
+
/** Rendered views use mouse events; inherited subprocesses retain native selection. */
|
|
20
|
+
mouse?: boolean;
|
|
21
|
+
}
|
|
16
22
|
export declare class AltScreen {
|
|
17
23
|
#private;
|
|
18
24
|
constructor(output: AltScreenOutput);
|
|
19
25
|
get active(): boolean;
|
|
20
|
-
/** Switches to the alternate buffer
|
|
21
|
-
enter(): void;
|
|
26
|
+
/** Switches to the alternate buffer with view-friendly defaults. */
|
|
27
|
+
enter(options?: AltScreenEnterOptions): void;
|
|
22
28
|
/**
|
|
23
29
|
* Paints a full-screen frame. Each row must already be styled and fit
|
|
24
30
|
* within the terminal width (one row == one screen line); rows beyond the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var AltScreen=class{#e;#t=!1;constructor(e){this.#e=e.write.bind(e)}get active(){return this.#t}enter(){this.#t
|
|
1
|
+
const SHOW_CURSOR=`\x1B[?25h`;var AltScreen=class{#e;#t=!1;#n=!1;constructor(e){this.#e=e.write.bind(e)}get active(){return this.#t}enter(t={}){if(this.#t)return;let n=t.mouse??!0,r=t.cursor??`hidden`;this.#e(`[?1049h${r===`hidden`?`\x1B[?25l`:SHOW_CURSOR}${n?`\x1B[?1002h\x1B[?1006h`:``}`),this.#n=n,this.#t=!0}paint(e,t){if(!this.#t)return;let n=e.slice(0,Math.max(0,t)).map((e,t)=>`[${t+1}H${e}`).join(``);this.#e(`[?2026h[H[0J${n}[?2026l`)}writeRaw(e){this.#t&&this.#e(e)}exit(){this.#t&&=(this.#e(`${this.#n?`\x1B[?1006l\x1B[?1002l`:``}${SHOW_CURSOR}[?1049l`),this.#n=!1,!1)}};export{AltScreen};
|
|
@@ -56,6 +56,7 @@ declare const frameworkTool: z.ZodObject<{
|
|
|
56
56
|
status: z.ZodEnum<{
|
|
57
57
|
active: "active";
|
|
58
58
|
disabled: "disabled";
|
|
59
|
+
"opt-in": "opt-in";
|
|
59
60
|
replaced: "replaced";
|
|
60
61
|
}>;
|
|
61
62
|
}, z.core.$strip>;
|
|
@@ -235,6 +236,16 @@ export declare const AgentInfoResultSchema: z.ZodObject<{
|
|
|
235
236
|
endpoint: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
236
237
|
kind: z.ZodLiteral<"external">;
|
|
237
238
|
provider: z.ZodString;
|
|
239
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
240
|
+
kind: z.ZodLiteral<"chatgpt">;
|
|
241
|
+
state: z.ZodEnum<{
|
|
242
|
+
checking: "checking";
|
|
243
|
+
ready: "ready";
|
|
244
|
+
"reauth-required": "reauth-required";
|
|
245
|
+
"signed-out": "signed-out";
|
|
246
|
+
unavailable: "unavailable";
|
|
247
|
+
}>;
|
|
248
|
+
accountLabel: z.ZodOptional<z.ZodString>;
|
|
238
249
|
}, z.core.$strip>, z.ZodObject<{
|
|
239
250
|
kind: z.ZodLiteral<"gateway">;
|
|
240
251
|
connected: z.ZodLiteral<true>;
|
|
@@ -533,6 +544,7 @@ export declare const AgentInfoResultSchema: z.ZodObject<{
|
|
|
533
544
|
status: z.ZodEnum<{
|
|
534
545
|
active: "active";
|
|
535
546
|
disabled: "disabled";
|
|
547
|
+
"opt-in": "opt-in";
|
|
536
548
|
replaced: "replaced";
|
|
537
549
|
}>;
|
|
538
550
|
}, z.core.$strip>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";const source=z.object({exportName:z.string().optional(),logicalPath:z.string(),sourceId:z.string().optional(),sourceKind:z.string()}),entry=source.extend({name:z.string()}),modelRouting=z.discriminatedUnion(`kind`,[z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}),z.object({kind:z.literal(`external`),provider:z.string()})]),modelEndpoint=z.union([z.object({kind:z.literal(`external`),provider:z.string()}),z.object({kind:z.literal(`gateway`),connected:z.literal(!0),credential:z.enum([`api-key`,`oidc`])}),z.object({kind:z.literal(`gateway`),connected:z.literal(!1)})]),agentModelBaseFields={contextWindowTokens:z.number().optional(),providerOptions:z.unknown().optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional().catch(void 0),source:source.optional()},agentModel=z.union([z.object({...agentModelBaseFields,id:z.string(),routing:modelRouting,endpoint:modelEndpoint.optional()}).strict(),z.object({...agentModelBaseFields,endpoint:z.never().optional(),id:z.never().optional(),routing:z.object({kind:z.literal(`dynamic`)}).strict()}).strict()]),tool=entry.extend({description:z.string(),hasAuth:z.boolean(),hasExecute:z.boolean(),hasModelOutputProjection:z.boolean(),hasOutputSchema:z.boolean(),inputSchema:z.unknown(),origin:z.enum([`authored`,`framework`]),outputSchema:z.unknown().optional(),replacesFrameworkTool:z.boolean(),requiresApproval:z.boolean()}),frameworkTool=tool.extend({disabledByAuthor:z.boolean(),replacedByAuthoredTool:z.boolean(),status:z.enum([`active`,`disabled`,`replaced`])}),dynamicResolver=source.extend({eventNames:z.array(z.string()),origin:z.enum([`authored`,`framework`]),slug:z.string()}),skill=entry.extend({description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional()}),instructions=entry.extend({content:z.string(),role:z.enum([`system`,`user`])}),schedule=entry.extend({cron:z.string(),hasRun:z.boolean(),markdown:z.string().optional()}),subagent=entry.extend({description:z.string().optional(),entryPath:z.string(),nodeId:z.string(),rootPath:z.string(),summary:z.object({channels:z.number(),connections:z.number(),hooks:z.number(),instructions:z.boolean(),schedules:z.number(),skills:z.number(),tools:z.number()})}),channel=entry.extend({adapterKind:z.string().optional(),method:z.string(),origin:z.enum([`authored`,`framework`]),urlPath:z.string()}),frameworkChannel=channel.extend({disabledByAuthor:z.boolean(),replacedByAuthoredChannel:z.boolean(),status:z.enum([`active`,`disabled`,`replaced`])}),connection=source.extend({connectionName:z.string(),description:z.string(),hasApproval:z.boolean(),hasAuthorization:z.boolean(),hasHeaders:z.boolean(),protocol:z.string(),toolFilter:z.unknown().optional(),url:z.string()}),hook=source.extend({eventNames:z.array(z.string()),slug:z.string()}),sandbox=source.extend({backendKind:z.string().optional(),description:z.string().optional(),hasBootstrap:z.boolean(),hasOnSession:z.boolean(),revalidationKey:z.string().optional(),sourceHash:z.string().optional()}),AgentInfoResultSchema=z.object({agent:z.object({agentRoot:z.string(),appRoot:z.string(),configSource:source.optional(),description:z.string().optional(),model:agentModel,name:z.string(),outputSchema:z.unknown().optional()}),capabilities:z.object({devRoutes:z.boolean()}),channels:z.object({authored:z.array(channel),available:z.array(channel),disabledFramework:z.array(z.string()),framework:z.array(frameworkChannel)}),connections:z.array(connection),diagnostics:z.object({discoveryErrors:z.number(),discoveryWarnings:z.number()}),hooks:z.array(hook),instructions:z.object({dynamic:z.array(dynamicResolver),static:z.array(instructions)}),kind:z.literal(`eve-agent-info`),mode:z.enum([`development`,`production`]),sandbox:sandbox.nullable(),schedules:z.array(schedule),skills:z.object({dynamic:z.array(dynamicResolver),static:z.array(skill)}),subagents:z.object({local:z.array(subagent),total:z.number()}),tools:z.object({authored:z.array(tool),available:z.array(tool),disabledFramework:z.array(z.string()),dynamic:z.array(dynamicResolver),framework:z.array(frameworkTool),reserved:z.array(z.string())}),version:z.literal(2),workflow:z.object({enabled:z.boolean(),toolName:z.string()}),workspace:z.object({resourceRoot:z.unknown(),rootEntries:z.array(z.string())})});export{AgentInfoResultSchema};
|
|
1
|
+
import{z}from"#compiled/zod/index.js";const source=z.object({exportName:z.string().optional(),logicalPath:z.string(),sourceId:z.string().optional(),sourceKind:z.string()}),entry=source.extend({name:z.string()}),modelRouting=z.discriminatedUnion(`kind`,[z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}),z.object({kind:z.literal(`external`),provider:z.string()})]),modelEndpoint=z.union([z.object({kind:z.literal(`external`),provider:z.string()}),z.object({kind:z.literal(`chatgpt`),state:z.enum([`checking`,`ready`,`signed-out`,`reauth-required`,`unavailable`]),accountLabel:z.string().optional()}),z.object({kind:z.literal(`gateway`),connected:z.literal(!0),credential:z.enum([`api-key`,`oidc`])}),z.object({kind:z.literal(`gateway`),connected:z.literal(!1)})]),agentModelBaseFields={contextWindowTokens:z.number().optional(),providerOptions:z.unknown().optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional().catch(void 0),source:source.optional()},agentModel=z.union([z.object({...agentModelBaseFields,id:z.string(),routing:modelRouting,endpoint:modelEndpoint.optional()}).strict(),z.object({...agentModelBaseFields,endpoint:z.never().optional(),id:z.never().optional(),routing:z.object({kind:z.literal(`dynamic`)}).strict()}).strict()]),tool=entry.extend({description:z.string(),hasAuth:z.boolean(),hasExecute:z.boolean(),hasModelOutputProjection:z.boolean(),hasOutputSchema:z.boolean(),inputSchema:z.unknown(),origin:z.enum([`authored`,`framework`]),outputSchema:z.unknown().optional(),replacesFrameworkTool:z.boolean(),requiresApproval:z.boolean()}),frameworkTool=tool.extend({disabledByAuthor:z.boolean(),replacedByAuthoredTool:z.boolean(),status:z.enum([`active`,`disabled`,`opt-in`,`replaced`])}),dynamicResolver=source.extend({eventNames:z.array(z.string()),origin:z.enum([`authored`,`framework`]),slug:z.string()}),skill=entry.extend({description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional()}),instructions=entry.extend({content:z.string(),role:z.enum([`system`,`user`])}),schedule=entry.extend({cron:z.string(),hasRun:z.boolean(),markdown:z.string().optional()}),subagent=entry.extend({description:z.string().optional(),entryPath:z.string(),nodeId:z.string(),rootPath:z.string(),summary:z.object({channels:z.number(),connections:z.number(),hooks:z.number(),instructions:z.boolean(),schedules:z.number(),skills:z.number(),tools:z.number()})}),channel=entry.extend({adapterKind:z.string().optional(),method:z.string(),origin:z.enum([`authored`,`framework`]),urlPath:z.string()}),frameworkChannel=channel.extend({disabledByAuthor:z.boolean(),replacedByAuthoredChannel:z.boolean(),status:z.enum([`active`,`disabled`,`replaced`])}),connection=source.extend({connectionName:z.string(),description:z.string(),hasApproval:z.boolean(),hasAuthorization:z.boolean(),hasHeaders:z.boolean(),protocol:z.string(),toolFilter:z.unknown().optional(),url:z.string()}),hook=source.extend({eventNames:z.array(z.string()),slug:z.string()}),sandbox=source.extend({backendKind:z.string().optional(),description:z.string().optional(),hasBootstrap:z.boolean(),hasOnSession:z.boolean(),revalidationKey:z.string().optional(),sourceHash:z.string().optional()}),AgentInfoResultSchema=z.object({agent:z.object({agentRoot:z.string(),appRoot:z.string(),configSource:source.optional(),description:z.string().optional(),model:agentModel,name:z.string(),outputSchema:z.unknown().optional()}),capabilities:z.object({devRoutes:z.boolean()}),channels:z.object({authored:z.array(channel),available:z.array(channel),disabledFramework:z.array(z.string()),framework:z.array(frameworkChannel)}),connections:z.array(connection),diagnostics:z.object({discoveryErrors:z.number(),discoveryWarnings:z.number()}),hooks:z.array(hook),instructions:z.object({dynamic:z.array(dynamicResolver),static:z.array(instructions)}),kind:z.literal(`eve-agent-info`),mode:z.enum([`development`,`production`]),sandbox:sandbox.nullable(),schedules:z.array(schedule),skills:z.object({dynamic:z.array(dynamicResolver),static:z.array(skill)}),subagents:z.object({local:z.array(subagent),total:z.number()}),tools:z.object({authored:z.array(tool),available:z.array(tool),disabledFramework:z.array(z.string()),dynamic:z.array(dynamicResolver),framework:z.array(frameworkTool),reserved:z.array(z.string())}),version:z.literal(2),workflow:z.object({enabled:z.boolean(),toolName:z.string()}),workspace:z.object({resourceRoot:z.unknown(),rootEntries:z.array(z.string())})});export{AgentInfoResultSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash}from"node:crypto";import{mkdir,writeFile}from"node:fs/promises";import{join,relative,resolve}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{
|
|
1
|
+
import{createHash}from"node:crypto";import{mkdir,writeFile}from"node:fs/promises";import{join,relative,resolve}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{summarizeDiscoverDiagnostics}from"#discover/diagnostics.js";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{compileAgentManifest}from"#compiler/normalize-manifest.js";import{materializeWorkspaceResources}from"#compiler/workspace-resources.js";const COMPILE_METADATA_KIND=`eve-compile-metadata`,COMPILE_METADATA_VERSION=5;function resolveCompilerArtifactPaths(e){return resolveCompilerArtifactPathsAt(e,join(resolve(e),`.eve`))}function resolveCompilerArtifactPathsAt(e,t){let n=resolve(e),i=resolve(t),o=join(i,`discovery`),s=join(i,`compile`);return{appRoot:n,compiledManifestPath:join(s,`compiled-agent-manifest.json`),compileDirectoryPath:s,compileMetadataPath:join(s,`compile-metadata.json`),diagnosticsPath:join(o,`diagnostics.json`),discoveryManifestPath:join(o,`agent-discovery-manifest.json`),discoveryDirectoryPath:o,moduleMapPath:join(s,`module-map.mjs`)}}function createDiscoveryDiagnosticsArtifact(e){return{diagnostics:[...e],kind:`eve-discovery-diagnostics`,summary:summarizeDiscoverDiagnostics(e),version:1}}function createCompileMetadata(e){let t=resolveInstalledPackageInfo(),n=createContentHash(e.discoveryManifestJson),r=createContentHash(e.diagnosticsArtifactJson),i=createContentHash(e.moduleMapSource);return{compile:{moduleMap:{path:toArtifactRelativePath(e.appRoot,e.paths.moduleMapPath),sha256:i}},discovery:{diagnostics:{path:toArtifactRelativePath(e.appRoot,e.paths.diagnosticsPath),sha256:r},manifest:{path:toArtifactRelativePath(e.appRoot,e.paths.discoveryManifestPath),sha256:n},sourceGraphHash:createContentHash(`${n}:${r}:${i}`),summary:e.diagnosticsSummary},generator:{name:t.name,version:t.version},kind:COMPILE_METADATA_KIND,status:e.diagnosticsSummary.errors>0?`failed`:`ready`,version:5}}async function writeCompilerArtifacts(e){let r=resolveCompilerArtifactPathsAt(e.appRoot,e.artifactLocations.writeRoot),i=resolveCompilerArtifactPathsAt(e.appRoot,e.artifactLocations.publishedRoot),a=createDiscoveryDiagnosticsArtifact(e.diagnostics),o=await materializeWorkspaceResources({compileDirectoryPath:r.compileDirectoryPath,manifest:await compileAgentManifest(e.manifest)}),s=serializeArtifactJson(o),c=serializeArtifactJson(e.manifest),l=serializeArtifactJson(a),u=createCompiledModuleMapSource({manifest:o,moduleMapPath:i.moduleMapPath}),d=createCompileMetadata({appRoot:e.appRoot,diagnosticsArtifactJson:l,diagnosticsSummary:a.summary,discoveryManifestJson:c,moduleMapSource:u,paths:i}),f=serializeArtifactJson(d);return await mkdir(r.discoveryDirectoryPath,{recursive:!0}),await mkdir(r.compileDirectoryPath,{recursive:!0}),await Promise.all([writeFile(r.compiledManifestPath,s),writeFile(r.diagnosticsPath,l),writeFile(r.discoveryManifestPath,c),writeFile(r.moduleMapPath,u),writeFile(r.compileMetadataPath,f)]),{compiledManifest:o,diagnosticsArtifact:a,metadata:d,moduleMapSource:u,paths:r}}function createContentHash(t){return createHash(`sha256`).update(t).digest(`hex`)}function serializeArtifactJson(e){return`${JSON.stringify(e,null,2)}\n`}function toArtifactRelativePath(e,t){return normalizeLogicalPath(relative(resolve(e),t))}export{COMPILE_METADATA_KIND,COMPILE_METADATA_VERSION,createCompileMetadata,resolveCompilerArtifactPaths,writeCompilerArtifacts};
|
|
@@ -240,6 +240,7 @@ declare const compiledScheduleDefinitionSchema: z.ZodObject<{
|
|
|
240
240
|
declare const compiledSandboxDefinitionSchema: z.ZodObject<{
|
|
241
241
|
backendName: z.ZodOptional<z.ZodString>;
|
|
242
242
|
description: z.ZodOptional<z.ZodString>;
|
|
243
|
+
inheritsParent: z.ZodOptional<z.ZodBoolean>;
|
|
243
244
|
exportName: z.ZodOptional<z.ZodString>;
|
|
244
245
|
logicalPath: z.ZodString;
|
|
245
246
|
revalidationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -312,6 +313,7 @@ declare const compiledAgentResourcesSchema: z.ZodObject<{
|
|
|
312
313
|
sandbox: z.ZodNullable<z.ZodObject<{
|
|
313
314
|
backendName: z.ZodOptional<z.ZodString>;
|
|
314
315
|
description: z.ZodOptional<z.ZodString>;
|
|
316
|
+
inheritsParent: z.ZodOptional<z.ZodBoolean>;
|
|
315
317
|
exportName: z.ZodOptional<z.ZodString>;
|
|
316
318
|
logicalPath: z.ZodString;
|
|
317
319
|
revalidationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -407,6 +409,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
|
|
|
407
409
|
sandbox: z.ZodNullable<z.ZodObject<{
|
|
408
410
|
backendName: z.ZodOptional<z.ZodString>;
|
|
409
411
|
description: z.ZodOptional<z.ZodString>;
|
|
412
|
+
inheritsParent: z.ZodOptional<z.ZodBoolean>;
|
|
410
413
|
exportName: z.ZodOptional<z.ZodString>;
|
|
411
414
|
logicalPath: z.ZodString;
|
|
412
415
|
revalidationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -549,6 +552,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
|
|
|
549
552
|
sandbox: z.ZodNullable<z.ZodObject<{
|
|
550
553
|
backendName: z.ZodOptional<z.ZodString>;
|
|
551
554
|
description: z.ZodOptional<z.ZodString>;
|
|
555
|
+
inheritsParent: z.ZodOptional<z.ZodBoolean>;
|
|
552
556
|
exportName: z.ZodOptional<z.ZodString>;
|
|
553
557
|
logicalPath: z.ZodString;
|
|
554
558
|
revalidationKey: z.ZodOptional<z.ZodString>;
|