eve 0.25.3 → 0.26.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-Cy73lgA6.js → use-eve-agent-BkztZA0v.js} +76 -55
- package/dist/src/chunks/{use-eve-agent-CQIeqmKc.js → use-eve-agent-CruinZmd.js} +76 -55
- package/dist/src/cli/commands/logs-events.d.ts +36 -0
- package/dist/src/cli/commands/logs-events.js +2 -0
- package/dist/src/cli/commands/logs.d.ts +64 -0
- package/dist/src/cli/commands/logs.js +4 -0
- package/dist/src/cli/dev/diagnostic-dump.d.ts +60 -0
- package/dist/src/cli/dev/diagnostic-dump.js +1 -0
- package/dist/src/cli/dev/diagnostic-sink.d.ts +37 -0
- package/dist/src/cli/dev/diagnostic-sink.js +1 -0
- package/dist/src/cli/dev/diagnostics.d.ts +42 -0
- package/dist/src/cli/dev/diagnostics.js +1 -0
- package/dist/src/cli/dev/tui/blocks.d.ts +4 -0
- package/dist/src/cli/dev/tui/blocks.js +7 -7
- package/dist/src/cli/dev/tui/command-typeahead.js +1 -1
- package/dist/src/cli/dev/tui/diagnostic-presentation.d.ts +14 -0
- package/dist/src/cli/dev/tui/diagnostic-presentation.js +2 -0
- package/dist/src/cli/dev/tui/errors.d.ts +21 -16
- package/dist/src/cli/dev/tui/errors.js +1 -1
- package/dist/src/cli/dev/tui/line-editor.js +1 -1
- package/dist/src/cli/dev/tui/markdown.js +1 -1
- package/dist/src/cli/dev/tui/model-editor.d.ts +103 -0
- package/dist/src/cli/dev/tui/model-editor.js +1 -0
- package/dist/src/cli/dev/tui/prompt-command-handler.d.ts +1 -1
- package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
- package/dist/src/cli/dev/tui/remote-auth-command.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +5 -0
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/setup-commands.d.ts +1 -1
- package/dist/src/cli/dev/tui/setup-commands.js +2 -2
- package/dist/src/cli/dev/tui/setup-flow.d.ts +3 -0
- package/dist/src/cli/dev/tui/setup-panel.d.ts +33 -0
- package/dist/src/cli/dev/tui/setup-panel.js +4 -4
- package/dist/src/cli/dev/tui/status-line.d.ts +8 -6
- package/dist/src/cli/dev/tui/status-line.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +3 -0
- package/dist/src/cli/dev/tui/terminal-renderer.js +11 -10
- package/dist/src/cli/dev/tui/test/fake-setup-flow-renderer.js +1 -1
- package/dist/src/cli/dev/tui/theme.d.ts +14 -0
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/cli/dev/tui/tool-format.js +1 -1
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/run.js +2 -2
- package/dist/src/cli/ui/live-row.js +1 -1
- package/dist/src/client/agent-info-schema.d.ts +9 -0
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/client.js +1 -1
- package/dist/src/client/eve-agent-store.d.ts +1 -2
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/open-stream.d.ts +14 -10
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session-utils.d.ts +2 -1
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.d.ts +3 -5
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +0 -6
- package/dist/src/compiler/extension-compatibility.d.ts +2 -2
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +4 -0
- package/dist/src/execution/sandbox/bindings/docker-cli.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-create.js +1 -1
- package/dist/src/execution/terminal-session-failure-step.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/model-call-error.d.ts +11 -30
- package/dist/src/harness/model-call-error.js +1 -1
- package/dist/src/harness/semantic-errors/index.d.ts +9 -0
- package/dist/src/harness/semantic-errors/index.js +1 -0
- package/dist/src/harness/semantic-errors/rule.d.ts +76 -0
- package/dist/src/harness/semantic-errors/rule.js +1 -0
- package/dist/src/harness/semantic-errors/rules/gateway.d.ts +11 -0
- package/dist/src/harness/semantic-errors/rules/gateway.js +1 -0
- package/dist/src/harness/semantic-errors/rules/model-provider.d.ts +11 -0
- package/dist/src/harness/semantic-errors/rules/model-provider.js +1 -0
- package/dist/src/harness/semantic-errors/rules/sandbox.d.ts +16 -0
- package/dist/src/harness/semantic-errors/rules/sandbox.js +1 -0
- package/dist/src/harness/semantic-errors/rules/system.d.ts +2 -0
- package/dist/src/harness/semantic-errors/rules/system.js +1 -0
- package/dist/src/harness/semantic-errors/rules/workflow.d.ts +9 -0
- package/dist/src/harness/semantic-errors/rules/workflow.js +1 -0
- package/dist/src/harness/semantic-errors/signals.d.ts +28 -0
- package/dist/src/harness/semantic-errors/signals.js +1 -0
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/workflow-sandbox.d.ts +6 -0
- package/dist/src/harness/workflow-sandbox.js +2 -2
- package/dist/src/internal/application/output-publication-lock.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/logging.d.ts +33 -1
- package/dist/src/internal/logging.js +1 -1
- 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 +3 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/internal/workflow/development-world-server.js +1 -1
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/public/models/openai/chatgpt/model.js +3 -1
- package/dist/src/react/use-eve-agent.d.ts +0 -1
- package/dist/src/react/use-eve-agent.js +1 -1
- package/dist/src/setup/boxes/add-channels.js +1 -1
- package/dist/src/setup/boxes/deploy-project.js +1 -1
- package/dist/src/setup/boxes/model-capabilities.d.ts +24 -0
- package/dist/src/setup/boxes/model-capabilities.js +1 -0
- package/dist/src/setup/boxes/resolve-provisioning.js +1 -1
- package/dist/src/setup/boxes/select-model.d.ts +30 -8
- package/dist/src/setup/boxes/select-model.js +1 -1
- package/dist/src/setup/cli/option-row.js +1 -1
- package/dist/src/setup/cli/prompt-ui.d.ts +2 -0
- package/dist/src/setup/cli/prompt-ui.js +2 -2
- package/dist/src/setup/cli/rail-log.d.ts +4 -6
- package/dist/src/setup/cli/rail-log.js +3 -2
- package/dist/src/setup/connection-connector.js +2 -2
- package/dist/src/setup/flows/login.js +1 -1
- package/dist/src/setup/flows/model-source-change.d.ts +38 -0
- package/dist/src/setup/flows/model-source-change.js +1 -0
- package/dist/src/setup/flows/model.d.ts +65 -62
- package/dist/src/setup/flows/model.js +1 -1
- package/dist/src/setup/flows/provider.d.ts +20 -0
- package/dist/src/setup/flows/provider.js +3 -3
- package/dist/src/setup/prompter.d.ts +2 -0
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/slack-connect-lifecycle.js +1 -1
- package/dist/src/setup/slackbot.js +1 -1
- package/dist/src/setup/vercel-project.d.ts +6 -0
- package/dist/src/setup/vercel-project.js +0 -0
- package/dist/src/shared/dynamic-tool-definition.d.ts +1 -8
- package/dist/src/shared/errors.d.ts +5 -0
- package/dist/src/shared/errors.js +1 -1
- package/dist/src/shared/gateway-service-tier.d.ts +19 -0
- package/dist/src/shared/gateway-service-tier.js +1 -0
- package/dist/src/shared/model-summary.d.ts +12 -0
- package/dist/src/shared/model-summary.js +1 -0
- package/dist/src/shared/workflow-sandbox.d.ts +2 -0
- package/dist/src/shared/workflow-sandbox.js +1 -1
- package/dist/src/source-change/agent-config-ast.d.ts +54 -0
- package/dist/src/source-change/agent-config-ast.js +2 -0
- package/dist/src/source-change/agent-config-string-path.d.ts +18 -0
- package/dist/src/source-change/agent-config-string-path.js +2 -0
- package/dist/src/source-change/apply-agent-model-settings.d.ts +26 -0
- package/dist/src/source-change/apply-agent-model-settings.js +1 -0
- package/dist/src/source-change/apply-model-name.js +1 -2
- package/dist/src/source-change/static-source-change.d.ts +14 -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.d.ts +0 -6
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.d.ts +0 -2
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/concepts/execution-model-and-durability.md +1 -1
- package/docs/concepts/sessions-runs-and-streaming.md +1 -1
- package/docs/getting-started.mdx +1 -1
- package/docs/guides/auth-and-route-protection.md +1 -1
- package/docs/guides/client/overview.mdx +1 -1
- package/docs/guides/client/streaming.mdx +1 -10
- package/docs/guides/deployment/meta.json +4 -0
- package/docs/guides/deployment/overview.md +61 -0
- package/docs/guides/deployment/self-hosting.md +88 -0
- package/docs/guides/deployment/vercel.mdx +90 -0
- package/docs/guides/dev-tui.md +8 -4
- package/docs/guides/dynamic-capabilities.md +2 -0
- package/docs/guides/frontend/nextjs.mdx +1 -1
- package/docs/guides/frontend/nuxt.mdx +1 -1
- package/docs/guides/frontend/overview.mdx +2 -5
- package/docs/guides/frontend/sveltekit.mdx +1 -1
- package/docs/guides/frontend/use-eve-agent-svelte.mdx +1 -4
- package/docs/guides/frontend/use-eve-agent-vue.mdx +1 -4
- package/docs/guides/instrumentation.md +1 -1
- package/docs/reference/cli.md +24 -2
- package/docs/tutorial/ship-it.mdx +1 -1
- package/package.json +1 -1
- package/docs/guides/deployment.md +0 -210
- /package/dist/src/cli/{dev/tui → ui}/live-region.d.ts +0 -0
- /package/dist/src/cli/{dev/tui → ui}/live-region.js +0 -0
- /package/dist/src/cli/{dev/tui → ui}/terminal-text.d.ts +0 -0
- /package/dist/src/cli/{dev/tui → ui}/terminal-text.js +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{
|
|
2
|
-
`);if(this.#x){t!==this.#S&&(this.#S=t,this.#
|
|
3
|
-
`),live:!1}),this.#Ze({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#pt()}}async#be(e){let t=this.#Ee(),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.#pt()},loadSearch=async(e,t)=>{c=!0,s=void 0;let a=++l;this.#pt();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.#pt())}},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.#bt()),t};return t.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#pt(),await this.#ke((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.#pt();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.#pt();return;case`update`:o=d.select,s=void 0,this.#pt();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.#pt();return;case`ignore`:return}}).promise}#xe(e){this.#Ie();let t=this.#De();t.status={kind:`progress`,text:stripTerminalControls(e.status)};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#r,t),this.#pt();let r=this.#ke((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.#pt();return;case`repaint`:this.#pt();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#Se(e){let t=this.#Ee(),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.#R,editor:{kind:`rename`,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint}}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#r,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?this.#Ge():(i=lineOf(``),this.#Ke())};return syncEditableRow(),this.#pt(),await this.#ke((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#qe(),this.#pt()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#pt()},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.#pt();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.#pt();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Ke()).promise}async#Ce(e){let t=this.#Ee(),n=initialProviderPickerState(e.options,e.initialValue),r;t.question=t=>renderSelectQuestion({kind:`inline-edit`,layout:`stacked`,message:e.message,options:e.options,select:n.select,edit:{optionValue:`own-key`,caretVisible:this.#R,editor:{kind:`key`,phase:n.phase}}},this.#r,t);let syncCaret=()=>{n.phase.kind===`editing`||n.phase.kind===`invalid`?this.#Ge():this.#Ke()};return syncCaret(),this.#pt(),await this.#ke((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.#pt();return;case`cancel`:i(void 0);return;case`render`:n=o.state,syncCaret(),this.#pt();return;case`validate`:{n=o.state,syncCaret(),this.#pt();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.#pt();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.#qe(),dispatch({type:`edit`,editor:s}))},()=>{r?.abort(),r=void 0,this.#Ke()}).promise}async#we(e){let t=this.#Ee(),n=lineOf(``),r;return t.question=t=>{let i={message:e.message,editor:n,mask:e.mask===!0};return e.placeholder!==void 0&&(i.placeholder=e.placeholder),e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#r,t,this.#R)},this.#Ge(),this.#pt(),await this.#ke((t,i)=>{let apply=e=>{n=e,r=void 0,this.#qe(),this.#pt()},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.#pt();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#pt();return}i(t);return}default:return}},()=>this.#Ke()).promise}async#Te(e){let t=this.#Ee();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#pt(),await this.#ke((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#pt();return;default:return}}).promise}#Ee(){return this.#Ie(),this.#j=!1,this.#N={kind:`idle`},this.#P=``,this.#De()}#De(){return this.#de===void 0&&(this.#de={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[]}),this.#de}#Oe(){this.#de!==void 0&&(this.#de.question=void 0,this.#de.hideLinesWhileQuestion=!1),this.#W=void 0,this.#ze(),this.#je(),this.#pt()}#ke(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#Oe(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#Oe(),i(e))};return this.#W=t=>e(t,settle,reject),this.#Re(),{promise:a,settle}}#Ae(){let e,t=new Promise(t=>{e=t});return this.#pe=e,this.#je(),{promise:t,dispose:()=>{this.#pe===e&&(this.#pe=void 0,this.#Me())}}}#je(){if(this.#pe===void 0)return;let consumer=e=>{if(e.type===`ctrl-c`||e.type===`escape`){let e=this.#pe;this.#pe=void 0,this.#Me(),e?.();return}e.type===`ctrl-r`&&this.#pt()};this.#me=consumer,this.#W=consumer,this.#Re()}#Me(){this.#me!==void 0&&(this.#W===this.#me&&this.#ze(),this.#me=void 0)}#Ne(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e)}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis)};if(this.#de!==void 0){this.#de.status=t,t===void 0&&(this.#de.preview=void 0),this.#pt();return}if(t===void 0){this.#N={kind:`idle`},this.#P=``,this.#Xe(),this.#pt();return}this.#Ie(),this.#Ye(),this.#P=t.text,this.#pt()}#Pe(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#de;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.#pt();return}this.#Ie(),this.#Ze({kind:`flow`,title:t,body:n,live:!1}),this.#pt()}#Fe(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#de;if(n===void 0){this.#Pe(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#pt()}shutdown(){this.#Le()}#Ie(e){this.#F=e?.title??this.#F,this.#ee=e?.contextSize??this.#l,!this.#I&&(this.#I=!0,this.#n.reset(),this.#n.hideCursor(),this.#kt(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#J=()=>this.#pt(),this.#t.on(`resize`,this.#J))}#Le(){this.#ze(),this.#Ke(),this.#Xe(),this.#H!==void 0&&(clearTimeout(this.#H),this.#H=void 0),this.#U=!1,this.#I&&=(this.#Lt(),this.#pt(),this.#n.clear(),this.#n.showCursor(),this.#At(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#J&&=(this.#t.off(`resize`,this.#J),void 0),!1)}#Re(){this.#e.off(`data`,this.#Be),this.#e.on(`data`,this.#Be)}#ze(){this.#e.off(`data`,this.#Be),this.#Ue(),this.#G=``,this.#K=new StringDecoder(`utf8`),this.#W=void 0}#Be=e=>{this.#Ue(),this.#G+=this.#K.write(e),this.#He(),this.#Ve()};#Ve(){if(this.#G===`\x1B`){this.#q=setTimeout(()=>{this.#G===`\x1B`&&(this.#G=``,this.#W?.({type:`escape`}))},30),this.#q.unref?.();return}if(isIncompletePaste(this.#G)){let e=this.#G;this.#q=setTimeout(()=>{if(this.#G!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#G=``,t.length>0&&this.#W?.({type:`text`,value:t,framing:`bracketed-paste`})},1e3),this.#q.unref?.()}}#He(){for(;this.#G.length>0;){let e=nextKey(this.#G);if(e.incomplete)return;this.#G=this.#G.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#W?.(e.key)}}#Ue(){this.#q&&=(clearTimeout(this.#q),void 0)}#We(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#pt();break;case`ctrl-c`:this.#L||(this.#L=!0,this.#N={kind:`idle`},this.#P=`Interrupted`,this.#Y?.(),this.#pt());break;default:break}}#Ge(){this.#Ke(),this.#qe(),this.#B=setInterval(()=>{this.#R=!this.#R,this.#pt()},500),this.#B.unref?.()}#Ke(){this.#B&&=(clearInterval(this.#B),void 0),this.#R=!0}#qe(){this.#R=!0}#Je(){this.#Xe(),this.#V=setInterval(()=>{this.#z+=1,this.#pt()},90),this.#V.unref?.()}#Ye(){this.#N={kind:`waiting`,startedAtMs:Date.now()},this.#Je()}#Xe(){this.#V&&=(clearInterval(this.#V),void 0)}#Ze(e){e.id!==this.#ce?.id&&this.#Lt(),this.#p.push(e),e.id&&this.#m.set(e.id,e)}#Qe(e){this.#Ze({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#pt()}#$e(e){if(e!=null){if(this.#ue===e){this.#ue=void 0;return}this.#Ze({kind:`user`,body:stripTerminalControls(e),live:!1})}}#et(e,t,n){let r={kind:`error`,title:stripTerminalControls(e),body:stripTerminalControls(t),live:!1};n!==void 0&&(r.detail=stripTerminalControls(n)),this.#Ze(r),this.#pt()}#tt(e,t){this.#y.has(e)||(this.#y.add(e),this.#Ze({id:subagentHeaderId(e),kind:`subagent`,title:stripTerminalControls(t),live:!1}))}#nt(e){if(e.id&&this.#h.has(e.id))return;let t=e.id?this.#m.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#Ze(e)}#rt(e){this.#p=this.#p.filter(t=>t.id!==e),this.#m.delete(e)}#it(){for(let e of this.#p)e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#at(e,t,n){switch(e.type){case`step-start`:this.#ot(n.hasPendingToolResults?STATUS.toolResults:STATUS.processing),n.hasPendingToolResults=!1;break;case`step-finish`:this.#ft(e.usage),this.#pt();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);this.#st(t),this.#ot(STATUS.streaming),n.text.set(e.id,t),this.#ct(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;this.#st(r),n.text.set(e.id,r),this.#ct(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);this.#st(r),this.#ot(STATUS.streaming),n.reasoning.set(e.id,r),this.#lt(e.id,r,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;this.#st(r),this.#lt(e.id,r,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#ot(STATUS.executingTools),this.#ut({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.#ut({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#dt(e.toolCallId,n);if(r===void 0)break;n.hasPendingToolResults=!0,this.#ot(STATUS.toolResults),this.#ut({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{if(t.tools===`hidden`)break;let r=this.#dt(e.toolCallId,n);if(r===void 0)break;n.hasPendingToolResults=!0,this.#ot(STATUS.toolResults),this.#ut({...r,errorText:e.errorText,status:`error`},t,n);break}case`error`:this.#et(`Error`,e.errorText,e.detail);break;case`finish`:this.#ft(e.usage),this.#pt();break}}#ot(e){let t=this.#T>0?STATUS.connectionAuth:e;this.#P!==t&&(this.#P=t,this.#pt())}#st(e){e.trim().length>0&&(this.#N={kind:`answering`})}#ct(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#nt({id:e,kind:`assistant`,body:r,live:n}),this.#pt())}#lt(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#nt({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#pt())}#ut(e,t,n){if(n.tools.set(e.toolCallId,e),this.#_.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#v.set(e.toolCallId,r),this.#nt(renderNativeToolBlock(e,r,t.tools===`full`)),this.#pt()}#dt(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#v.get(e)??toolSectionId(e),i=this.#m.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.title??`tool`}}#ft(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#Q=(t??0)+(n??0)),this.#$=t??this.#$,this.#te=n??this.#te,this.#te!=null&&this.#re!==void 0){let e=(Date.now()-this.#re)/1e3;e>0&&(this.#ne=this.#te/e)}}#pt(){if(this.#I){if(this.#X){this.#Z=!0;return}this.#X=!0;try{do this.#Z=!1,this.#mt();while(this.#Z)}finally{this.#X=!1}}}#mt(){if(!this.#I)return;let e=this.#Dt(),t=this.#Ct(e),n=Math.max(1,this.#Ot()-t.length),r=[],i=this.#w;for(;this.#p.length>0&&this.#p[0].live===!1;){let t=this.#p.shift();if(this.#g.push(t),t.id&&(this.#h.add(t.id),this.#m.delete(t.id)),this.#zt(t))continue;let n=this.#yt(t,e,i);i=previousBlockOf(t),this.#w=i,r.push(...n),this.#C.push(...n)}let a=[];for(let t of this.#p){if(this.#zt(t))continue;let n=this.#yt(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)a.push({block:t,row:n[e]})}let o=[...clipLiveRows(a.map(e=>e.row),n,e,this.#r),...t];r.length>0?this.#n.flush(r,o):this.#n.update(o)}#ht(){if(!this.#I)return;let e=this.#Dt(),t=this.#Ct(e),n=Math.max(1,this.#Ot()-t.length),r=this.#w,i=[];for(let t of this.#p){if(this.#zt(t))continue;let n=this.#yt(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#r),...t];this.#n.clearAll(),this.#n.flush([...this.#vt(),...this.#C],a)}logDisplayMode(){return this.#f}setLogDisplayMode(e){e!==this.#f&&(this.#f=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#_t(),this.#I&&this.#ht())}flushDelayedDevBuildErrors(){let e=this.#se;e!==void 0&&(this.#se=void 0,this.#Ze({kind:`log`,title:`stderr`,body:e,live:!1}),this.#pt())}#gt(){this.#U=!0,this.#H!==void 0&&clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#U=!1,this.#H=void 0,this.#pt()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#f)),this.#pt()}#_t(){let e=this.#Dt();this.#C.length=0;let t;for(let n of this.#g){if(this.#zt(n))continue;let r=this.#yt(n,e,t);t=previousBlockOf(n),this.#C.push(...r)}this.#w=t}#vt(){let e=this.#b;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#Dt()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#yt(e,t,n){let r={spinner:this.#bt()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#bt(){return this.#r.spinner[this.#z%this.#r.spinner.length]??``}#xt(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#St(e,t){return e.indicator.kind===`spinner`?{glyph:this.#bt(),color:`yellow`}:{glyph:this.#xt(e.indicator.startedAtMs,this.#r.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#Ct(e){let n=this.#r.colors,r=[``],i=this.#de;if(i!==void 0){let t=this.#St(i,i.status),n=i.status===void 0?void 0:{...i.status,indicator:t},a;if(i.question!==void 0){let t=i.question(e);a={kind:`question`,rows:t},n!==void 0&&(a={kind:`question`,rows:t,status:n})}else n===void 0?a=i.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:i.preview,indicator:t}:(a={kind:`status`,status:n},i.preview!==void 0&&(a={kind:`status`,status:n,preview:i.preview}));let o={title:i.title,lines:i.hideLinesWhileQuestion===!0?[]:i.lines,content:a};return r.push(...renderFlowPanel(o,this.#r,e)),this.#Tt(r,e),r}if(this.#fe!==void 0&&r.push(...renderAttentionRows(this.#fe,e,this.#r),``),this.#j){let i=this.#M===void 0?void 0:inlineCommandHint(this.#M);i===void 0&&this.#M!==void 0&&isTypeaheadOpen(this.#M)&&r.push(...renderCommandSuggestions(this.#M,this.#r,e));let a=isPromptControlCommand(this.#O),o=i?n.dim(` ${i}`):``,s=[];this.#wt(s,e);let c=Math.max(1,this.#Ot()-1-r.length-1-s.length);return r.push(...promptInputRows({text:this.#O,cursor:this.#k,width:e,theme:this.#r,caretVisible:this.#R,isCommand:a,ghost:o,maxRows:c})),r.push(...s),r}let a=this.#N;if(a.kind===`answering`)return this.#wt(r,e),r;let o=a.kind===`waiting`,s=o?n.green(this.#xt(a.startedAtMs,this.#r.unicode?`⊙`:`o`)):n.dim(this.#r.glyph.dot),c=this.#P.length>0?this.#P:`Ready`,l=o?n.dim(c):c,u=this.#Et(),f=o?` `:``,p=u?`${f}${s} ${l} ${n.dim(this.#r.glyph.dot)} ${u}`:`${f}${s} ${l}`;r.push(clip(p,e));let g=[];return this.#wt(g,e),o&&g.length>0&&r.push(``),r.push(...g),r}#wt(e,t){let n=this.#D===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#r,width:r};this.#U&&(i.logLevel=this.#f);let a=this.#b?.serverUrl;if(a!==void 0&&this.#D===void 0){let e=new URL(a).port;e.length>0&&(i.serverPort=e)}let o=this.#b?.info?.agent.model.id;o!==void 0&&(i.model=o);let s=this.#b?.info?.agent.model.endpoint;s!==void 0&&(i.endpoint=s);let c=this.#$??0,l=this.#te??0;if(c>0||l>0){let e={inputTokens:c,outputTokens:l};this.#ee!==void 0&&(e.contextSize=this.#ee),i.tokens=formatTokenFlow(e,this.#r.glyph)}this.#E!==void 0&&(i.vercel=this.#E),this.#D!==void 0&&(i.remote=this.#D);let u=buildStatusLine(i);u!==void 0&&e.push(clip(`${n}${u}`,t))}#Tt(e,t){if(this.#D===void 0)return;let n=Math.max(1,t-2),r=buildStatusLine({remote:this.#D,theme:this.#r,width:n});r!==void 0&&e.push(``,clip(` ${r}`,t))}#Et(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#Q,outputTokens:this.#te,tokensPerSecond:this.#ne},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#Dt(){return Math.max(20,this.#t.columns||80)}#Ot(){return Math.max(8,this.#t.rows||24)}#kt(){if(this.#ie!==void 0||!this.#u)return;this.#ae=``,this.#oe=``;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.#jt(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#ie=()=>{e(),t()}}#At(){let e=this.#ie;e!==void 0&&(this.#ie=void 0,e(),this.#ae.length>0&&(this.#Rt(`stdout`)&&process.stdout.write(`${this.#ae}\n`),this.#ae=``),this.#oe.length>0&&(this.#Rt(`stderr`)&&process.stderr.write(`${this.#oe}\n`),this.#oe=``))}#jt(e,t){let n=(e===`stdout`?this.#ae:this.#oe)+t,r=n.lastIndexOf(`
|
|
4
|
-
`),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#ae=i:this.#oe=i,r===-1)return;let a=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);a.trim().length!==0&&(e===`stdout`?this.#Mt(a):this.#Nt(a),this.#pt())}#Mt(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
|
|
5
|
-
`);
|
|
6
|
-
`)
|
|
7
|
-
`)
|
|
8
|
-
`);
|
|
9
|
-
`);
|
|
10
|
-
`)}
|
|
1
|
+
import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{buildAgentHeader}from"./agent-header.js";import{renderAttentionRows,renderBlockLines}from"./blocks.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{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,layoutPromptInput,lineOf,movePromptLine,visibleLine}from"./line-editor.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{initialModelEditorState,transitionModelEditor}from"./model-editor.js";import{initialProviderPickerState,transitionProviderPicker}from"./provider-picker.js";import{enterBadge,renderAcknowledgeQuestion,renderFlowPanel,renderModelEditorQuestion,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{reduceSetupSelectInput,setupSelectionIntent}from"./setup-selection-input.js";import{formatAssistantResponseStats,isIncompletePaste,nextKey,sanitizePastedText,stripPasteStart,stripPromptControlCharacters,takeUntil}from"./stream-format.js";import{inspectError}from"#internal/logging.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{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,t){return e?`Interrupted`:t?`Ready`:`Done`}const STATUS={processing:`Working…`,toolResults:`Reading results…`,streaming:`Responding…`,executingTools:`Running tools…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=[];#m=new Map;#h=new Set;#g=[];#_=new Set;#v=new Map;#y=new Set;#b;#x=!1;#S;#C=[];#w;#T=0;#E;#D;#O=``;#k=0;#A=new PromptHistory;#j=!1;#M;#N={kind:`idle`};#P=STATUS.processing;#F=`eve`;#I=!1;#L=!1;#R=!0;#z=0;#B;#V;#H;#U=!1;#W;#G=``;#K=new StringDecoder(`utf8`);#q;#J;#Y;#X=!1;#Z=!1;#Q;#$;#ee;#te;#ne;#re=``;#ie=``;#ae;#oe;#se=0;#ce;#le;#ue;#de;#fe;setupFlow={begin:(e,t)=>this.#ge(e,t),end:e=>this.#_e(e?.preserveDiagnostics??!0),readSelect:e=>this.#ve(e),readEditableSelect:e=>this.#be(e),readProviderPicker:e=>this.#xe(e),readModelEditor:e=>this.#Se(e),readText:e=>this.#Ce(e),readAcknowledge:e=>this.#we(e),readChoice:e=>this.#ye(e),setStatus:e=>this.#Me(e),renderLine:(e,t)=>this.#Ne(e,t),renderOutput:e=>this.#Pe(e),waitForInterrupt:()=>this.#ke()};constructor(t){this.#e=t?.input??process.stdin,this.#t=t?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=createTheme({color:t?.color??!0,unicode:t?.unicode??detectUnicode()}),this.#i=t?.tools??`auto-collapsed`,this.#a=t?.reasoning??`full`,this.#o=t?.subagents??`auto-collapsed`,this.#s=t?.connectionAuth??`full`,this.#c=t?.assistantResponseStats??`tokensPerSecond`,this.#l=t?.captureForeignOutput??this.#t===process.stdout,this.#u=t?.diagnostics,this.#f=t?.logs??`none`,this.#d=t?.availablePromptCommands??PROMPT_COMMANDS}renderAgentHeader(e){this.#F=e.name,this.#b=e,this.#Fe();let t=this.#_t().join(`
|
|
2
|
+
`);if(this.#x){t!==this.#S&&(this.#S=t,this.#Xe({kind:`agent-header`,body:t,live:!1})),this.#ft();return}this.#x=!0,this.#S=t,this.#n.flush(this.#_t(),[])}async readPrompt(e){this.#Fe(e),this.#Ye(),this.#j=!0,this.#N={kind:`idle`},this.#P=``;let r=lineOf(stripPromptControlCharacters(e?.initialDraft??``));return this.#A.begin(r.text),this.#pe(r),this.#M=typeaheadFor(this.#d,r.text),this.#We(),this.#ft(),await new Promise((e,i)=>{let apply=e=>{r=e,this.#Ke(),this.#pe(r),this.#M=typeaheadFor(this.#d,e.text,this.#M),this.#ft()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#M=void 0,this.#Ge(),this.#Ie(),i(interruptedError())},suggestions=()=>this.#M!==void 0&&isTypeaheadOpen(this.#M)?this.#M:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#W=i=>{let a=applyLineEditorKey(r,i,{multiline:!0});if(a!==void 0){apply(a);return}switch(i.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#M=moveTypeaheadSelection(e,-1),this.#ft();break}let t=movePromptLine(r,`up`);t===void 0?recall(this.#A.previous(r.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#M=moveTypeaheadSelection(e,1),this.#ft();break}let t=movePromptLine(r,`down`);t===void 0?recall(this.#A.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.#M=dismissTypeahead(e),this.#ft());break}case`enter`:{let i=highlighted(),a=i!==void 0&&parsePromptCommand(r.text)===null?typeaheadCompletion(i).trimEnd():r.text;this.#M=void 0,this.#A.add(a),this.#j=!1,this.#Ge(),this.#Je(),this.#P=STATUS.processing,isPromptControlCommand(a)?this.#Xe({kind:`command`,body:stripTerminalControls(a.trim()),live:!1}):(this.#Ze(a),this.#ce=a),this.#pe(EMPTY_LINE),this.#ft(),this.#Re(),e(a);break}case`ctrl-d`:r.text.length===0?interrupt():apply(deleteForward(r));break;case`ctrl-l`:this.#ht();break;case`ctrl-r`:this.#ft();break;case`ctrl-c`:r.text.length===0?interrupt():apply(EMPTY_LINE);break;default:break}},this.#Le()})}#pe(e){this.#O=e.text,this.#k=e.cursor}async renderStream(e,t){this.#Fe(t),this.#h.clear(),this.#j=!1,this.#N.kind!==`waiting`&&(this.#N={kind:`waiting`,startedAtMs:Date.now()}),this.#P=this.#T>0?STATUS.connectionAuth:STATUS.processing,this.#Qe(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#u?.recordPrompt(),this.#L=!1,this.#Q=void 0,this.#$=void 0,this.#ee=void 0,this.#te=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#qe(),this.#ft();let r=new Promise(e=>{this.#Y=e});this.#W=e=>this.#Ue(e),this.#Le();let i={text:new Map,reasoning:new Map,tools:new Map,hasPendingToolResults:!1};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#L)break;this.#it(t,n,i)}}catch(e){let t=summarizeKnownError(e);t===null?this.#$e(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#$e(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#Y=void 0,this.#L&&e.abort?.(),this.#Re(),this.#Ye(),this.#N.kind===`waiting`&&(this.#N={kind:`idle`}),this.#P=completedTurnStatus(this.#L,t?.continueSession===!0),this.#rt(),this.#u?.reportStats(),this.#ft(),t?.continueSession||this.#Ie()}}async readToolApproval(e,t){return this.#Fe(t),this.#Ye(),this.#j=!1,this.#N={kind:`idle`},this.#P=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#L=!1,this.#ft(),await new Promise((t,n)=>{this.#W=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#Je(),this.#P=STATUS.processing,this.#Re(),this.#ft(),t({approved:!0})):n===`n`&&(this.#Je(),this.#P=STATUS.processing,this.#me(e.toolCallId),this.#Re(),this.#ft(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#ft();break;case`ctrl-c`:this.#L=!0,this.#Ie(),n(interruptedError());break;default:break}},this.#Le()})}async readInputQuestion(e,t){this.#Fe(t),this.#Ye(),this.#j=!1,this.#N={kind:`idle`},this.#L=!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?`select`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,renderSection=()=>{this.#tt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,c,this.#r),preformatted:!0,live:!0})},repaintStatus=()=>{if(s===`select`){let e=isOnFreeformRow()?`type`:`select`;this.#P=`↑/↓ move · enter ${e} · Ctrl+C quit`,this.#j=!1}else this.#j=!0,this.#pe(l),this.#P=``;this.#ft()};renderSection(),s===`text`&&this.#We(),repaintStatus();let finalize=t=>{this.#tt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:` ${this.#r.colors.green(this.#r.glyph.success)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#j=!1,this.#Je(),this.#P=STATUS.processing,this.#Ge(),this.#Re(),this.#ft();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n};return await new Promise((t,i)=>{this.#W=o=>{if(o.type===`ctrl-c`){if(s===`text`&&l.text.length>0){l=EMPTY_LINE,this.#Ke(),repaintStatus();return}this.#L=!0,this.#Ge(),this.#Ie(),i(interruptedError());return}if(o.type===`ctrl-r`){this.#ft();return}if(s===`select`){switch(o.type){case`up`:case`ctrl-p`:a>0&&(c=(c-1+a)%a,renderSection(),repaintStatus());break;case`down`:case`ctrl-n`:a>0&&(c=(c+1)%a,renderSection(),repaintStatus());break;case`enter`:{if(isOnFreeformRow()){s=`text`,l=EMPTY_LINE,this.#We(),repaintStatus();break}let e=n[c];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}let u=applyLineEditorKey(l,o,{multiline:!0});if(u!==void 0){l=u,this.#Ke(),repaintStatus();return}switch(o.type){case`up`:case`down`:{let e=movePromptLine(l,o.type);e!==void 0&&(l=e,this.#Ke(),repaintStatus());break}case`enter`:{let n=resolveQuestionText(l.text,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(r){if(l.text.length>0){l=EMPTY_LINE,this.#Ke(),repaintStatus();break}s=`select`,l=EMPTY_LINE,this.#j=!1,this.#Ge(),repaintStatus();break}l=EMPTY_LINE,this.#Ke(),repaintStatus();break;default:break}},this.#Le()})}upsertSubagentStep(e){if(this.#u?.recordSubagentDispatch(e.callId),this.#o===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&n.length===0)){if(this.#et(e.callId,e.subagentName),this.#o===`collapsed`){this.#ft();return}this.#tt({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:n,live:!e.finalized}),this.#ft()}}upsertSubagentTool(e){if(this.#u?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#u?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#o===`hidden`)return;if(this.#et(e.callId,e.subagentName),this.#o===`collapsed`){this.#ft();return}let t=subagentToolStatus(e.status),n={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,depth:1,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:t,live:t===`running`||t===`approval`,expanded:this.#o===`full`,toolInput:e.input};e.output===void 0?e.errorText!==void 0&&(n.result=stripTerminalControls(e.errorText)):(n.result=summarizeToolResult(e.output),n.toolOutput=e.output),this.#tt(n),this.#ft()}markChildToolCallId(e){this.#_.add(e);let t=this.#v.get(e);t!==void 0&&(this.#nt(t),this.#v.delete(e),this.#ft())}#me(e){let t=this.#m.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#s===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#tt({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.#ft()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#T)return;let n=this.#T>0;this.#T=t,t>0?(this.#P=STATUS.connectionAuth,this.#ft()):n&&(this.#P=STATUS.processing,this.#ft())}setVercelStatus(e){this.#E=e,this.#ft()}setRemoteConnectionStatus(e){this.#D=e,this.#ft()}reset(){this.#p=[],this.#m.clear(),this.#h.clear(),this.#w=void 0,this.#C.length=0,this.#g.length=0,this.#x=!1,this.#S=void 0,this.#_.clear(),this.#v.clear(),this.#y.clear(),this.#ce=void 0,this.#oe=void 0,this.#T=0,this.#Q=void 0,this.#$=void 0,this.#ee=void 0,this.#te=void 0,this.#I&&(this.#n.clearAll(),this.#ft())}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Fe(),this.#Xe({kind:`notice`,body:t,live:!1}),this.#ft())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#u?.append({source:`sandbox`,detail:t}),this.#Fe(),this.#Xe({kind:`sandbox`,body:t,live:!1}),this.#ft())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#he();return}this.#Fe(),this.#ue=t,this.#ft()}clearSetupWarning(){this.#he()}#he(){this.#ue!==void 0&&(this.#ue=void 0,this.#ft())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#Fe();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#Xe(r),this.#ft()}renderCommandResult(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Fe(),this.#Xe({kind:`result`,body:t,live:!1}),this.#ft())}#ge(e,t=`spinner`){this.#Fe(),this.#j=!1,this.#N={kind:`idle`},this.#P=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#le={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#qe(),this.#ft()}#_e(e){this.#de=void 0,this.#je();let t=this.#le;if(t!==void 0){if(this.#le=void 0,this.#Ye(),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.#Xe({kind:`flow`,title:`info`,body:e.join(`
|
|
3
|
+
`),live:!1}),this.#Xe({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#ft()}}async#ve(e){let t=this.#Te(),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.#ft()},loadSearch=async(e,t)=>{c=!0,s=void 0;let a=++l;this.#ft();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.#ft())}},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.#yt()),t};return t.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#ft(),await this.#Oe((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.#ft();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.#ft();return;case`update`:o=d.select,s=void 0,this.#ft();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.#ft();return;case`ignore`:return}}).promise}#ye(e){this.#Fe();let t=this.#Ee();t.status={kind:`progress`,text:stripTerminalControls(e.status)};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#r,t),this.#ft();let r=this.#Oe((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.#ft();return;case`repaint`:this.#ft();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#be(e){let t=this.#Te(),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.#R,editor:{kind:`rename`,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint}}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#r,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?this.#We():(i=lineOf(``),this.#Ge())};return syncEditableRow(),this.#ft(),await this.#Oe((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#Ke(),this.#ft()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#ft()},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.#ft();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.#ft();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Ge()).promise}async#xe(e){let t=this.#Te(),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.#r,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:`own-key`,caretVisible:this.#R,editor:{kind:`key`,phase:n.phase}}};return r!==void 0&&(i.cursorBadge=r),renderSelectQuestion(i,this.#r,t)};let syncCaret=()=>{n.phase.kind===`editing`||n.phase.kind===`invalid`?this.#We():this.#Ge()};return syncCaret(),this.#ft(),await this.#Oe((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.#ft();return;case`cancel`:i(void 0);return;case`render`:n=o.state,syncCaret(),this.#ft();return;case`validate`:{n=o.state,syncCaret(),this.#ft();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.#ft();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.#Ke(),dispatch({type:`edit`,editor:s}))},()=>{r?.abort(),r=void 0,this.#Ge()}).promise}async#Se(e){let t=this.#Te(),n=initialModelEditorState(e);return t.question=t=>renderModelEditorQuestion({request:e,state:n},this.#r,t),this.#ft(),await this.#Oe((t,r)=>{let dispatch=t=>{let i=transitionModelEditor(n,t,e);switch(i.kind){case`ignore`:return;case`render`:n=i.state,this.#ft();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.#ft();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(`
|
|
4
|
+
`,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#Ce(e){let t=this.#Te(),n=lineOf(``),r;return t.question=t=>{let i={message:e.message,editor:n,mask:e.mask===!0};return e.placeholder!==void 0&&(i.placeholder=e.placeholder),e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#r,t,this.#R)},this.#We(),this.#ft(),await this.#Oe((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Ke(),this.#ft()},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.#ft();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#ft();return}i(t);return}default:return}},()=>this.#Ge()).promise}async#we(e){let t=this.#Te();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#ft(),await this.#Oe((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#ft();return;default:return}}).promise}#Te(){return this.#Fe(),this.#j=!1,this.#N={kind:`idle`},this.#P=``,this.#Ee()}#Ee(){return this.#le===void 0&&(this.#le={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[]}),this.#le}#De(){this.#le!==void 0&&(this.#le.question=void 0,this.#le.hideLinesWhileQuestion=!1),this.#W=void 0,this.#Re(),this.#Ae(),this.#ft()}#Oe(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#De(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#De(),i(e))};return this.#W=t=>e(t,settle,reject),this.#Le(),{promise:a,settle}}#ke(){let e,t=new Promise(t=>{e=t});return this.#de=e,this.#Ae(),{promise:t,dispose:()=>{this.#de===e&&(this.#de=void 0,this.#je())}}}#Ae(){if(this.#de===void 0)return;let consumer=e=>{if(e.type===`ctrl-c`||e.type===`escape`){let e=this.#de;this.#de=void 0,this.#je(),e?.();return}e.type===`ctrl-r`&&this.#ft()};this.#fe=consumer,this.#W=consumer,this.#Le()}#je(){this.#fe!==void 0&&(this.#W===this.#fe&&this.#Re(),this.#fe=void 0)}#Me(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e)}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis)};if(this.#le!==void 0){this.#le.status=t,t===void 0&&(this.#le.preview=void 0),this.#ft();return}if(t===void 0){this.#N={kind:`idle`},this.#P=``,this.#Ye(),this.#ft();return}this.#Fe(),this.#Je(),this.#P=t.text,this.#ft()}#Ne(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#le;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.#ft();return}this.#Fe(),this.#Xe({kind:`flow`,title:t,body:n,live:!1}),this.#ft()}#Pe(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#le;if(n===void 0){this.#Ne(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#ft()}shutdown(){this.#Ie()}#Fe(e){this.#F=e?.title??this.#F,!this.#I&&(this.#I=!0,this.#n.reset(),this.#n.hideCursor(),this.#Ot(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#J=()=>this.#ft(),this.#t.on(`resize`,this.#J))}#Ie(){this.#Re(),this.#Ge(),this.#Ye(),this.#H!==void 0&&(clearTimeout(this.#H),this.#H=void 0),this.#U=!1,this.#I&&=(this.#Lt(),this.#ft(),this.#n.clear(),this.#n.showCursor(),this.#kt(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#J&&=(this.#t.off(`resize`,this.#J),void 0),!1)}#Le(){this.#e.off(`data`,this.#ze),this.#e.on(`data`,this.#ze)}#Re(){this.#e.off(`data`,this.#ze),this.#He(),this.#G=``,this.#K=new StringDecoder(`utf8`),this.#W=void 0}#ze=e=>{this.#He(),this.#G+=this.#K.write(e),this.#Ve(),this.#Be()};#Be(){if(this.#G===`\x1B`){this.#q=setTimeout(()=>{this.#G===`\x1B`&&(this.#G=``,this.#W?.({type:`escape`}))},30),this.#q.unref?.();return}if(isIncompletePaste(this.#G)){let e=this.#G;this.#q=setTimeout(()=>{if(this.#G!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#G=``,t.length>0&&this.#W?.({type:`text`,value:t,framing:`bracketed-paste`})},1e3),this.#q.unref?.()}}#Ve(){for(;this.#G.length>0;){let e=nextKey(this.#G);if(e.incomplete)return;this.#G=this.#G.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#W?.(e.key)}}#He(){this.#q&&=(clearTimeout(this.#q),void 0)}#Ue(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#ft();break;case`ctrl-c`:this.#L||(this.#L=!0,this.#N={kind:`idle`},this.#P=`Interrupted`,this.#Y?.(),this.#ft());break;default:break}}#We(){this.#Ge(),this.#Ke(),this.#B=setInterval(()=>{this.#R=!this.#R,this.#ft()},500),this.#B.unref?.()}#Ge(){this.#B&&=(clearInterval(this.#B),void 0),this.#R=!0}#Ke(){this.#R=!0}#qe(){this.#Ye(),this.#V=setInterval(()=>{this.#z+=1,this.#ft()},90),this.#V.unref?.()}#Je(){this.#N={kind:`waiting`,startedAtMs:Date.now()},this.#qe()}#Ye(){this.#V&&=(clearInterval(this.#V),void 0)}#Xe(e){e.id!==this.#oe?.id&&this.#Lt(),this.#p.push(e),e.id&&this.#m.set(e.id,e)}#Ze(e){this.#Xe({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#ft()}#Qe(e){if(e!=null){if(this.#ce===e){this.#ce=void 0;return}this.#Xe({kind:`user`,body:stripTerminalControls(e),live:!1})}}#$e(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.#u?.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.#u===void 0?a:`details: ${this.#u.displayPath}`),this.#Xe(c),this.#ft()}#et(e,t){this.#y.has(e)||(this.#y.add(e),this.#Xe({id:subagentHeaderId(e),kind:`subagent`,title:stripTerminalControls(t),live:!1}))}#tt(e){if(e.id&&this.#h.has(e.id))return;let t=e.id?this.#m.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#Xe(e)}#nt(e){this.#p=this.#p.filter(t=>t.id!==e),this.#m.delete(e)}#rt(){for(let e of this.#p)e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#it(e,t,n){switch(e.type){case`step-start`:this.#at(n.hasPendingToolResults?STATUS.toolResults:STATUS.processing),n.hasPendingToolResults=!1;break;case`step-finish`:this.#u?.recordStepUsage(e.usage),this.#dt(e.usage),this.#ft();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);this.#ot(t),this.#at(STATUS.streaming),n.text.set(e.id,t),this.#st(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;this.#ot(r),n.text.set(e.id,r),this.#st(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);this.#ot(r),this.#at(STATUS.streaming),n.reasoning.set(e.id,r),this.#ct(e.id,r,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;this.#ot(r),this.#ct(e.id,r,!1,t);break}case`tool-call`:if(this.#u?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#at(STATUS.executingTools),this.#lt({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.#lt({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#ut(e.toolCallId,n);if(r===void 0)break;n.hasPendingToolResults=!0,this.#at(STATUS.toolResults),this.#lt({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#ut(e.toolCallId,n);if(this.#u?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;n.hasPendingToolResults=!0,this.#at(STATUS.toolResults),this.#lt({...r,errorText:e.errorText,status:`error`},t,n);break}case`error`:this.#$e(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`finish`:this.#dt(e.usage),this.#ft();break}}#at(e){let t=this.#T>0?STATUS.connectionAuth:e;this.#P!==t&&(this.#P=t,this.#ft())}#ot(e){e.trim().length>0&&(this.#N={kind:`answering`})}#st(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#tt({id:e,kind:`assistant`,body:r,live:n}),this.#ft())}#ct(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#tt({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#ft())}#lt(e,t,n){if(n.tools.set(e.toolCallId,e),this.#_.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#v.set(e.toolCallId,r),this.#tt(renderNativeToolBlock(e,r,t.tools===`full`)),this.#ft()}#ut(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#v.get(e)??toolSectionId(e),i=this.#m.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.title??`tool`}}#dt(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#Q=(t??0)+(n??0)),this.#$=n??this.#$,this.#$!=null&&this.#te!==void 0){let e=(Date.now()-this.#te)/1e3;e>0&&(this.#ee=this.#$/e)}}#ft(){if(this.#I){if(this.#X){this.#Z=!0;return}this.#X=!0;try{do this.#Z=!1,this.#pt();while(this.#Z)}finally{this.#X=!1}}}#pt(){if(!this.#I)return;let e=this.#Et(),t=this.#St(e),n=Math.max(1,this.#Dt()-t.length),r=[],i=this.#w;for(;this.#p.length>0&&this.#p[0].live===!1;){let t=this.#p.shift();if(this.#g.push(t),t.id&&(this.#h.add(t.id),this.#m.delete(t.id)),this.#zt(t))continue;let n=this.#vt(t,e,i);i=previousBlockOf(t),this.#w=i,r.push(...n),this.#C.push(...n)}let a=[];for(let t of this.#p){if(this.#zt(t))continue;let n=this.#vt(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)a.push({block:t,row:n[e]})}let o=[...clipLiveRows(a.map(e=>e.row),n,e,this.#r),...t];r.length>0?this.#n.flush(r,o):this.#n.update(o)}#mt(){if(!this.#I)return;let e=this.#Et(),t=this.#St(e),n=Math.max(1,this.#Dt()-t.length),r=this.#w,i=[];for(let t of this.#p){if(this.#zt(t))continue;let n=this.#vt(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#r),...t];this.#n.clearAll(),this.#n.flush([...this.#_t(),...this.#C],a)}logDisplayMode(){return this.#f}setLogDisplayMode(e){e!==this.#f&&(this.#f=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#gt(),this.#I&&this.#mt())}flushDelayedDevBuildErrors(){let e=this.#ae;e!==void 0&&(this.#ae=void 0,this.#Xe({kind:`log`,title:`stderr`,body:e,live:!1}),this.#ft())}#ht(){this.#U=!0,this.#H!==void 0&&clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#U=!1,this.#H=void 0,this.#ft()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#f)),this.#ft()}#gt(){let e=this.#Et();this.#C.length=0;let t;for(let n of this.#g){if(this.#zt(n))continue;let r=this.#vt(n,e,t);t=previousBlockOf(n),this.#C.push(...r)}this.#w=t}#_t(){let e=this.#b;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#Et()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#vt(e,t,n){let r={spinner:this.#yt()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#yt(){return this.#r.spinner[this.#z%this.#r.spinner.length]??``}#bt(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#xt(e,t){return e.indicator.kind===`spinner`?{glyph:this.#yt(),color:`yellow`}:{glyph:this.#bt(e.indicator.startedAtMs,this.#r.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#St(e){let n=this.#r.colors,r=[``],i=this.#le;if(i!==void 0){let t=this.#xt(i,i.status),n=i.status===void 0?void 0:{...i.status,indicator:t},a;if(i.question!==void 0){let t=i.question(e);a={kind:`question`,rows:t},n!==void 0&&(a={kind:`question`,rows:t,status:n})}else n===void 0?a=i.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:i.preview,indicator:t}:(a={kind:`status`,status:n},i.preview!==void 0&&(a={kind:`status`,status:n,preview:i.preview}));let o={title:i.title,lines:i.hideLinesWhileQuestion===!0?[]:i.lines,content:a};return r.push(...renderFlowPanel(o,this.#r,e)),this.#wt(r,e),r}if(this.#ue!==void 0&&r.push(...renderAttentionRows(this.#ue,e,this.#r),``),this.#j){let i=this.#M===void 0?void 0:inlineCommandHint(this.#M);i===void 0&&this.#M!==void 0&&isTypeaheadOpen(this.#M)&&r.push(...renderCommandSuggestions(this.#M,this.#r,e));let a=isPromptControlCommand(this.#O),o=i?n.dim(` ${i}`):``,s=[];this.#Ct(s,e);let c=Math.max(1,this.#Dt()-1-r.length-1-s.length);return r.push(...promptInputRows({text:this.#O,cursor:this.#k,width:e,theme:this.#r,caretVisible:this.#R,isCommand:a,ghost:o,maxRows:c})),r.push(...s),r}let a=this.#N;if(a.kind===`answering`)return this.#Ct(r,e),r;let s=a.kind===`waiting`,c=s?n.green(this.#bt(a.startedAtMs,this.#r.unicode?`⊙`:`o`)):n.dim(this.#r.glyph.dot),d=this.#P.length>0?this.#P:`Ready`,p=s?n.dim(d):d,m=this.#Tt(),h=s?` `:``,g=m?`${h}${c} ${p} ${n.dim(this.#r.glyph.dot)} ${m}`:`${h}${c} ${p}`;r.push(clip(g,e));let _=[];return this.#Ct(_,e),s&&_.length>0&&r.push(``),r.push(..._),r}#Ct(e,t){let n=this.#D===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#r,width:r};this.#U&&(i.logLevel=this.#f);let a=this.#b?.serverUrl;if(a!==void 0&&this.#D===void 0){let e=new URL(a).port;e.length>0&&(i.serverPort=e)}let o=this.#b?.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.#E!==void 0&&(i.vercel=this.#E),this.#D!==void 0&&(i.remote=this.#D);let c=buildStatusLine(i);c!==void 0&&e.push(clip(`${n}${c}`,t))}#wt(e,t){if(this.#D===void 0)return;let n=Math.max(1,t-2),r=buildStatusLine({remote:this.#D,theme:this.#r,width:n});r!==void 0&&e.push(``,clip(` ${r}`,t))}#Tt(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#Q,outputTokens:this.#$,tokensPerSecond:this.#ee},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#Et(){return Math.max(20,this.#t.columns||80)}#Dt(){return Math.max(8,this.#t.rows||24)}#Ot(){if(this.#ne!==void 0||!this.#l)return;this.#re=``,this.#ie=``;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.#jt(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#u?.subscribeLogRecords(e=>this.#At(e)),this.#ne=()=>{this.#u?.unsubscribeLogRecords(),e(),t()}}#kt(){let e=this.#ne;e!==void 0&&(this.#ne=void 0,e(),this.#re.length>0&&(this.#u?.append({source:`stdout`,detail:this.#re}),this.#Rt(`stdout`)&&process.stdout.write(`${this.#re}\n`),this.#re=``),this.#ie.length>0&&(this.#u?.append({source:`stderr`,detail:this.#ie}),this.#Rt(`stderr`)&&process.stderr.write(`${this.#ie}\n`),this.#ie=``))}#At(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#Nt(`[eve:${e.namespace}] ${e.message}${t}`),this.#ft()}#jt(e,t){let n=(e===`stdout`?this.#re:this.#ie)+t,r=n.lastIndexOf(`
|
|
5
|
+
`),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#re=i:this.#ie=i,r===-1)return;let a=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);a.trim().length!==0&&(this.#u?.append({source:e,detail:a}),e===`stdout`?this.#Mt(a):this.#Nt(a),this.#ft())}#Mt(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
|
|
6
|
+
`);t=[],e.trim().length!==0&&this.#Xe({kind:`log`,title:`stdout`,body:e,live:!1})};for(let n of e.split(`
|
|
7
|
+
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#Xe({kind:`sandbox`,body:e,live:!1});continue}let r=parseDevRebuildLogLine(n.trimEnd());if(r===void 0){t.push(n);continue}flushPending(),this.#Ft(r,n.trimEnd())}flushPending()}#Nt(e){let t=e.split(`
|
|
8
|
+
`),n=t.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(n===-1){if(this.#u===void 0){this.#Xe({kind:`log`,title:`stderr`,body:e,live:!1});return}let t=presentDiagnostic(e,this.#u.displayPath);if(t.kind===`inline`){this.#Xe({kind:`log`,title:`stderr`,body:t.text,live:!1});return}this.#Xe({kind:`log`,title:`stderr`,body:formatStoredDiagnostic(t),logVisibility:`stderr-only`,live:!1}),this.#Xe({kind:`log`,title:`stderr`,body:e,logVisibility:`all-only`,live:!1});return}let r=t.slice(0,n).join(`
|
|
9
|
+
`);r.trim().length>0&&this.#Xe({kind:`log`,title:`stderr`,body:r,live:!1});let i=t.slice(n).join(`
|
|
10
|
+
`);this.#Pt(i)}#Pt(e){if(this.#f===`all`){if(e.trim().length===0)return;this.#Xe({kind:`log`,title:`stderr`,body:e,live:!1});return}this.#ae=e}#Ft(e,t){let n=this.#It();if(e.kind===`failed`){this.#Pt(t);return}if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#se}`;this.#se+=1,this.#oe={id:r,summary:t},this.#Xe({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}if(n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind),e.kind===`rebuilt`&&(this.#ae=void 0);return}e.kind===`rebuilt`&&(this.#ae=void 0),this.#Xe({kind:`log`,title:`stdout`,body:t,live:!1})}#It(){let e=this.#oe;if(e===void 0)return;let t=this.#m.get(e.id);if(!(t===void 0||t.live!==!0))return{state:e,block:t}}#Lt(){let e=this.#oe;if(e===void 0)return;this.#oe=void 0;let t=this.#m.get(e.id);t!==void 0&&(t.live=!1)}#Rt(e){switch(this.#f){case`none`:return!1;case`stderr`:return e===`stderr`;case`sandbox`:return e===`sandbox`;case`all`:return!0}}#zt(e){return e.kind===`sandbox`?!this.#Rt(`sandbox`):e.kind===`log`?e.logVisibility===`stderr-only`?this.#f!==`stderr`:e.logVisibility===`all-only`?this.#f!==`all`:!this.#Rt(e.title===`stderr`?`stderr`:`stdout`):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}async function*iterateTUIStream(e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}return}yield*e}function clip(e,t){return clipVisible(e,t)}function promptInputRows({text:e,cursor:t,width:n,theme:r,caretVisible:i,isCommand:a,ghost:o,maxRows:s}){let c=r.colors,style=e=>{let t=renderInputText(e);return a&&t.length>0?c.blue(t):t},l=layoutPromptInput({text:e,cursor:t}),u=Math.min(Math.max(1,s),l.rows.length),d=Math.max(0,Math.min(l.caretRow-u+1,l.rows.length-u)),f=c.cyan(r.glyph.prompt),p=c.dim(r.glyph.ellipsis),m=Math.max(1,n-4),h=[];for(let e=d;e<d+u;e+=1){let t=l.rows[e],a=e===0?f:` `;(e===d&&d>0||e===d+u-1&&d+u<l.rows.length)&&(a=p);let s;if(e===l.caretRow){let{before:e,under:n,after:a}=visibleLine({text:t.text,cursor:l.caretOffset},m,r.glyph.ellipsis);s=renderInputWithBlockCursor({before:e,under:n,after:a,visible:i,inverse:c.inverse,render:style}),o.length>0&&l.rows.length===1&&(s+=o)}else s=style(t.text);h.push(clip(` ${a} ${s}`,n))}return h.push(``),h}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function leadsWithGap(e,t){if(e.kind===`sandbox`&&t?.kind===`sandbox`)return!1;if(t?.kind===`sandbox`&&e.kind!==`sandbox`)return!0;if(e.kind===`log`&&t?.kind===`log`)return t.title!==e.title;if(t?.kind===`log`&&e.kind!==`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`subagent`:case`error`:case`notice`:case`question`:case`connection-auth`:case`sandbox`:case`log`:case`command`:case`warning`:case`flow`:case`agent-header`:return!0;default:return!1}}function parseSandboxLogLine(e){let t=e.trim();if(!t.startsWith(`eve: `))return;let n=t.slice(5);return/\bsandbox\b/i.test(n)&&!isLowValueSandboxLogLine(n)?n:void 0}function isLowValueSandboxLogLine(e){return/^initializing (?:\d+ )?sandbox templates?\b/i.test(e)||/^initialized \d+ sandbox\b/i.test(e)||/^reused cached sandbox template\b/i.test(e)||/^sandbox template "[^"]+" \([^)]+\): (checking|reusing|loading microsandbox runtime|microsandbox runtime ready)\b/i.test(e)}function clipLiveRows(e,t,n,r){if(e.length<=t)return[...e];if(t<=1)return[clip(hiddenRowsMarker(e.length,r),n)];let i=t-1;return[clip(hiddenRowsMarker(e.length-i,r),n),...e.slice(e.length-i)]}function hiddenRowsMarker(e,t){let n=e.toLocaleString(),r=e===1?`row`:`rows`;return t.colors.dim(`${t.glyph.dot} ${t.glyph.ellipsis} ${n} earlier ${r} hidden while streaming`)}function collapseReasoning(e,t){switch(e){case`collapsed`:return!0;case`auto-collapsed`:return!t;default:return!1}}function renderNativeToolBlock(e,t,n){let a={id:t,kind:`tool`,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:e.status,live:e.status===`running`||e.status===`approval`,expanded:n,toolInput:e.input};return e.output===void 0?e.errorText!==void 0&&(a.result=stripTerminalControls(e.errorText)):(a.result=summarizeToolResult(e.output),a.toolOutput=e.output),a}function subagentToolStatus(e){switch(e){case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`}}function formatToolApprovalTitle(e){return stripTerminalControls(e.title??e.toolName)}function toolSectionId(e){return`tool:${e}`}function questionSectionId(e){return`question:${e}`}function subagentHeaderId(e){return`subagent:${e}:header`}function subagentStepSectionId(e,t){return`subagent:${e}:step:${t}`}function subagentToolSectionId(e,t){return`subagent:${e}:tool:${t}`}function connectionAuthSectionId(e){return`connection-auth:${e}`}function connectionAuthTerminalMessage(e){switch(e){case`authorized`:return`Authorization complete`;case`declined`:return`Authorization declined`;case`failed`:return`Authorization failed`;case`timed-out`:return`Authorization timed out`;case`required`:case`pending`:return}}function formatConnectionAuthContent(e,t){let n=[];if(t!==void 0)n.push(t);else{let t=stripTerminalControls(e.description);t.length>0&&n.push(t);let r=e.challenge;r?.url&&n.push(`URL: ${stripTerminalControls(r.url)}`),r?.userCode&&n.push(`Code: ${stripTerminalControls(r.userCode)}`),r?.expiresAt&&n.push(`Expires: ${stripTerminalControls(r.expiresAt)}`),r?.instructions&&n.push(stripTerminalControls(r.instructions))}if(e.reason!==void 0){let t=stripTerminalControls(e.reason);t.length>0&&n.push(`Reason: ${t}`)}return n.join(`
|
|
11
|
+
`)}function formatQuestionContent(e,t,n){let r=n.colors,i=[],a=e.options??[];if(a.length>0){for(let[e,o]of a.entries()){let a=stripTerminalControls(o.label),s=o.description===void 0?``:stripTerminalControls(o.description),c=t===e,l=s.length>0?`${c?` `:` `}${r.dim(`— ${s}`)}`:``,u=renderCursorRow(c?`${n.glyph.selectedPointer} ${a}`:` ${a}`,c,r);i.push(`${u}${l}`)}if(e.allowFreeform===!0){let e=t===a.length,o=`Type your own answer`,s=e?`${n.glyph.selectedPointer} ${o}`:` ${r.dim(o)}`;i.push(renderCursorRow(s,e,r))}}else i.push(r.dim(` (type your answer)`));return i.join(`
|
|
11
12
|
`)}function resolveQuestionText(e,t){let n=e.trim();if(n.length===0)return;let r=n.toLowerCase(),i=t.options??[];if(i.length>0){let e=matchQuestionOption(r,i);if(e!==void 0)return{optionId:e.id,label:e.label}}if(t.allowFreeform===!0||i.length===0)return{text:n,label:n}}function matchQuestionOption(e,t){let n=t.find(t=>t.id.toLowerCase()===e);if(n!==void 0)return n;let r=t.find(t=>t.label.toLowerCase()===e);if(r!==void 0)return r;let i=Number(e);if(Number.isInteger(i)&&i>0&&i<=t.length)return t[i-1]}export{TerminalRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function createFakeSetupFlowRenderer(e={}){let{readProviderPicker=async()=>void 0,...t}=e;return{begin:()=>{},end:()=>{},readSelect:async()=>void 0,readEditableSelect:async()=>void 0,readProviderPicker,readText:async()=>void 0,readAcknowledge:async()=>{},readChoice:()=>({choice:Promise.resolve(void 0),close:()=>{}}),setStatus:()=>{},renderLine:()=>{},renderOutput:()=>{},waitForInterrupt:()=>({promise:new Promise(()=>{}),dispose:()=>{}}),...t}}export{createFakeSetupFlowRenderer};
|
|
1
|
+
function createFakeSetupFlowRenderer(e={}){let{readProviderPicker=async()=>void 0,readModelEditor=async()=>void 0,...t}=e;return{begin:()=>{},end:()=>{},readSelect:async()=>void 0,readEditableSelect:async()=>void 0,readProviderPicker,readModelEditor,readText:async()=>void 0,readAcknowledge:async()=>{},readChoice:()=>({choice:Promise.resolve(void 0),close:()=>{}}),setStatus:()=>{},renderLine:()=>{},renderOutput:()=>{},waitForInterrupt:()=>({promise:new Promise(()=>{}),dispose:()=>{}}),...t}}export{createFakeSetupFlowRenderer};
|
|
@@ -80,6 +80,20 @@ export interface ThemeGlyphs {
|
|
|
80
80
|
arrowUp: string;
|
|
81
81
|
/** `↓` — output (response) tokens in the token-flow segment. */
|
|
82
82
|
arrowDown: string;
|
|
83
|
+
/** `↯` — Fast mode (Gateway priority tier) marker beside a model id. */
|
|
84
|
+
fast: string;
|
|
85
|
+
/** `●` — a track notch below the current position (already covered). */
|
|
86
|
+
trackFilled: string;
|
|
87
|
+
/** `◉` — the track notch at the current position. */
|
|
88
|
+
trackCurrent: string;
|
|
89
|
+
/** `○` — a track notch above the current position. */
|
|
90
|
+
trackEmpty: string;
|
|
91
|
+
/** `─` — the connector segment between track notches. */
|
|
92
|
+
trackLine: string;
|
|
93
|
+
/** `↵` — the Enter affordance inside a selection badge. */
|
|
94
|
+
enter: string;
|
|
95
|
+
/** `▪` — the marker beside an in-flight validation badge. */
|
|
96
|
+
validating: string;
|
|
83
97
|
}
|
|
84
98
|
export interface Theme {
|
|
85
99
|
readonly color: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}[39m`}const UNICODE_GLYPHS={brand:`▲`,user:`▌`,reasoning:`○`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`◆`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`▷`,selectedPointer:`▶`,option:`◦`,prompt:`❯`,elbow:`⎿`,hrule:`▔`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown
|
|
1
|
+
function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}[39m`}const UNICODE_GLYPHS={brand:`▲`,user:`▌`,reasoning:`○`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`◆`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`▷`,selectedPointer:`▶`,option:`◦`,prompt:`❯`,elbow:`⎿`,hrule:`▔`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown:`↓`,fast:`↯`,trackFilled:`●`,trackCurrent:`◉`,trackEmpty:`○`,trackLine:`─`,enter:`↵`,validating:`▪`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,selectedPointer:`>`,option:`.`,prompt:`>`,elbow:"`-",hrule:`=`,caret:`_`,dot:`-`,ellipsis:`...`,arrowUp:`^`,arrowDown:`v`,fast:`>>`,trackFilled:`*`,trackCurrent:`O`,trackEmpty:`.`,trackLine:`-`,enter:`<-'`,validating:`o`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(i={}){let a=i.color??!0,o=i.unicode??!0;return{color:a,unicode:o,colors:{reset:ansi(0,0,a),bold:ansi(1,22,a),dim:ansi(2,22,a),inverse:ansi(7,27,a),italic:ansi(3,23,a),white:ansi(97,39,a),gray:ansi(90,39,a),cyan:ansi(36,39,a),green:ansi(32,39,a),red:ansi(31,39,a),yellow:ansi(33,39,a),magenta:ansi(35,39,a),blue:ansi(34,39,a),orange:ansi256(208,a)},glyph:o?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:o?UNICODE_SPINNER:ASCII_SPINNER}}function detectUnicode(e=process.env){let t=e.EVE_TUI_UNICODE;return t===`0`||t===`false`?!1:t===`1`||t===`true`?!0:e.TERM===`dumb`?!1:process.platform===`win32`?!!(e.WT_SESSION||e.TERM_PROGRAM===`vscode`):!0}export{createTheme,detectUnicode};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{stripTerminalControls}from"
|
|
1
|
+
import{stripTerminalControls}from"#cli/ui/terminal-text.js";function summarizeToolArgs(t,n=80){if(t==null)return``;if(typeof t!=`object`)return truncate(formatScalar(t),n);if(Array.isArray(t))return truncate(`[${t.length}]`,n);let r=Object.entries(t);if(r.length===0)return``;let i=[];for(let[t,n]of r)i.push(`${stripTerminalControls(t)}=${formatInlineValue(n)}`);return truncate(i.join(` `),n)}function summarizeToolResult(e,t=80){if(e==null)return``;if(typeof e==`string`)return truncate((e.split(`
|
|
2
2
|
`).find(e=>e.trim().length>0)??``).trim(),t);if(typeof e!=`object`)return truncate(formatScalar(e),t);if(Array.isArray(e))return truncate(`${e.length} ${e.length===1?`item`:`items`}`,t);let n=e;for(let e of[`result`,`text`,`message`,`summary`,`value`,`output`]){let r=n[e];if(r!==void 0&&typeof r!=`object`)return truncate(`${formatScalar(r)}`,t)}let r=Object.keys(n);if(r.length===0)return`{}`;let i=r.slice(0,3).map(e=>`${e}=${formatInlineValue(n[e])}`).join(` `);return truncate(r.length>3?`${i} …`:i,t)}function formatValuePretty(t){if(typeof t==`string`)return stripTerminalControls(t);try{return stripTerminalControls(JSON.stringify(t,null,2)??String(t))}catch{return stripTerminalControls(String(t))}}function formatInlineValue(e){return e===void 0?`undefined`:e===null?`null`:typeof e==`string`?`"${truncate(e,32)}"`:typeof e==`object`?Array.isArray(e)?`[${e.length}]`:`{…}`:formatScalar(e)}function formatScalar(t){return stripTerminalControls(typeof t==`string`?t:String(t))}function truncate(t,n){let r=stripTerminalControls(t).replace(/\s+/g,` `).trim();return r.length<=n?r:`${r.slice(0,Math.max(0,n-1)).trimEnd()}…`}export{formatValuePretty,summarizeToolArgs,summarizeToolResult,truncate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{promptCommandsFor}from"./prompt-commands.js";import{probeMcpConnection}from"./mcp-connection-status.js";import{createPromptCommandHandler}from"./prompt-command-handler.js";import{formatRemoteAuthChallengeMessage}from"./remote-auth-result.js";import{remoteHost}from"./target.js";import{EveTUIRunner}from"./runner.js";import{Client}from"#client/index.js";import{toErrorMessage}from"#shared/errors.js";import{resolveDevelopmentOidcToken,resolveLinkedDevelopmentOidcToken}from"#services/dev-client/request-headers.js";import{isVercelAuthChallenge}from"#services/dev-client/vercel-auth-error.js";import{resolveVercelDeployment}from"#setup/vercel-deployment.js";import{resolveLocalDevelopmentClientOptions,resolveRemoteDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{createDevelopmentCredentialGate}from"#services/dev-client/credential-gate.js";function prepareRemoteTarget(e){return{target:e,credentials:createDevelopmentCredentialGate(e.serverUrl),resolveOidcToken:resolveDevelopmentOidcToken,resolveDeployment:t=>resolveVercelDeployment({workspaceRoot:e.workspaceRoot,host:remoteHost(e),signal:t})}}function prepareDevelopmentTarget(e){return e.kind===`local`?{kind:`local`,target:e}:{kind:`remote`,target:e,remote:prepareRemoteTarget(e)}}async function runDevelopmentTui(n){let{target:r,headers:i,initialInput:a,onBootProgress:o,...s}=n,c=prepareDevelopmentTarget(r),{serverUrl:l}=r,u=i===void 0?{}:{headers:i},d=new Client(c.kind===`local`?resolveLocalDevelopmentClientOptions({...u,serverUrl:l,token:()=>resolveLinkedDevelopmentOidcToken(c.target.workspaceRoot)}):resolveRemoteDevelopmentClientOptions({...u,serverUrl:l,credentials:c.remote.credentials})),f={...s,session:d.session(),client:d,serverUrl:l,promptCommandHandler:createPromptCommandHandler({target:r}),availablePromptCommands:promptCommandsFor(r.kind),formatTransportError:e=>isVercelAuthChallenge(e)?formatRemoteAuthChallengeMessage(l):toErrorMessage(e)};c.kind===`local`?(f.appRoot=c.target.workspaceRoot,f.probeMcpConnection=probeMcpConnection):f.remote=c.remote,a!==void 0&&(f.initialInput=a),o!==void 0&&(f.onBootProgress=o)
|
|
1
|
+
import{createDevDiagnostics}from"../diagnostics.js";import{promptCommandsFor}from"./prompt-commands.js";import{probeMcpConnection}from"./mcp-connection-status.js";import{createPromptCommandHandler}from"./prompt-command-handler.js";import{formatRemoteAuthChallengeMessage}from"./remote-auth-result.js";import{remoteHost}from"./target.js";import{EveTUIRunner}from"./runner.js";import{Client}from"#client/index.js";import{toErrorMessage}from"#shared/errors.js";import{resolveDevelopmentOidcToken,resolveLinkedDevelopmentOidcToken}from"#services/dev-client/request-headers.js";import{isVercelAuthChallenge}from"#services/dev-client/vercel-auth-error.js";import{resolveVercelDeployment}from"#setup/vercel-deployment.js";import{resolveLocalDevelopmentClientOptions,resolveRemoteDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{createDevelopmentCredentialGate}from"#services/dev-client/credential-gate.js";function prepareRemoteTarget(e){return{target:e,credentials:createDevelopmentCredentialGate(e.serverUrl),resolveOidcToken:resolveDevelopmentOidcToken,resolveDeployment:t=>resolveVercelDeployment({workspaceRoot:e.workspaceRoot,host:remoteHost(e),signal:t})}}function prepareDevelopmentTarget(e){return e.kind===`local`?{kind:`local`,target:e}:{kind:`remote`,target:e,remote:prepareRemoteTarget(e)}}async function runDevelopmentTui(n){let{target:r,headers:i,initialInput:a,onBootProgress:o,...s}=n,c=prepareDevelopmentTarget(r),{serverUrl:l}=r,u=i===void 0?{}:{headers:i},d=new Client(c.kind===`local`?resolveLocalDevelopmentClientOptions({...u,serverUrl:l,token:()=>resolveLinkedDevelopmentOidcToken(c.target.workspaceRoot)}):resolveRemoteDevelopmentClientOptions({...u,serverUrl:l,credentials:c.remote.credentials})),f={...s,session:d.session(),client:d,serverUrl:l,promptCommandHandler:createPromptCommandHandler({target:r}),availablePromptCommands:promptCommandsFor(r.kind),formatTransportError:e=>isVercelAuthChallenge(e)?formatRemoteAuthChallengeMessage(l):toErrorMessage(e)};c.kind===`local`?(f.appRoot=c.target.workspaceRoot,f.probeMcpConnection=probeMcpConnection):f.remote=c.remote,a!==void 0&&(f.initialInput=a),o!==void 0&&(f.onBootProgress=o);let p=c.kind===`local`?await createDevDiagnostics(c.target.workspaceRoot).catch(()=>void 0):void 0;p!==void 0&&(f.diagnostics=p);try{await new EveTUIRunner(f).run()}finally{await p?.close()}}export{runDevelopmentTui};
|
package/dist/src/cli/run.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.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{Command,CommanderError,InvalidArgumentError}from"#compiled/commander/index.js";import{registerBuildCommand}from"#cli/commands/build.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{resolveDevUiMode,resolveTuiDisplayOptions}from"#cli/dev/ui-options.js";import{parseDevelopmentHeaderOption,resolveDevelopmentUrlTarget}from"#cli/dev/url-target.js";import{LOG_DISPLAY_MODES,parseLogDisplayMode}from"#cli/dev/tui/log-display-mode.js";import{resolveTuiTitle}from"#cli/dev/tui/target.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.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(`#internal/nitro/host.js`)).createDevelopmentServer}const loadIsActiveDevelopmentServerForApp=async()=>(await import(`#internal/nitro/host.js`)).isActiveDevelopmentServerForApp;async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function shouldPrintCliBootBanner(e){return e.name()===`info`||e.name()===`dev`||e.name()===`init`}async function waitForShutdownSignal(e){await new Promise((t,n)=>{let r=!1,cleanup=()=>{process.off(`SIGINT`,handleSignal),process.off(`SIGTERM`,handleSignal)},handleSignal=()=>{r||(r=!0,cleanup(),e.close().then(t,n))};process.once(`SIGINT`,handleSignal),process.once(`SIGTERM`,handleSignal)})}async function waitForProductionServer(e){await Promise.race([e.wait(),waitForShutdownSignal({close:()=>e.close()})])}function parsePortOption(e){if(!/^-?\d+$/.test(e))throw new InvalidArgumentError(`Expected a numeric port, received "${e}".`);let t=Number(e);if(t<0||t>65535)throw new InvalidArgumentError(`Expected a port between 0 and 65535, received "${e}".`);return t}const DISPLAY_MODES=new Set([`full`,`collapsed`,`auto-collapsed`,`hidden`]),STATS_MODES=new Set([`tokens`,`tokensPerSecond`]);function parseDisplayMode(e){if(!DISPLAY_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...DISPLAY_MODES].join(`, `)}, received "${e}".`);return e}function parseStatsMode(e){if(!STATS_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...STATS_MODES].join(`, `)}, received "${e}".`);return e}function parseLogsMode(e){let t=parseLogDisplayMode(e);if(t===void 0)throw new InvalidArgumentError(`Expected one of ${LOG_DISPLAY_MODES.join(`, `)}, received "${e}".`);return t}function parseContextSizeOption(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)throw new InvalidArgumentError(`Expected a positive number, received "${e}".`);return t}function hasInteractiveTerminal(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function createCliProgram(e,i){let c=resolveApplicationRoot(),m=resolveInstalledPackageInfo().version,h=new Command,_=createCliTheme();h.name(`eve`).description(`Build and run an eve application.`).version(m).showHelpAfterError().exitOverride().hook(`preAction`,(t,n)=>{shouldPrintCliBootBanner(n)&&e.log(eveCliBanner())}).configureOutput({writeErr:t=>{e.error(t.trimEnd())},writeOut:t=>{e.log(t.trimEnd())}});let v=h.command(`channels`).description(`Manage user-authored channels in the current project.`);v.command(`add [kind]`).description(`Add channels interactively, or scaffold a channel kind (slack | web).`).option(`-f, --force`,`Overwrite existing channel files`).option(`-y, --yes`,`Assume yes for confirmations; requires an explicit channel kind`).action(async(t,n)=>{let{runChannelsAddCommand:r}=await import(`#cli/commands/channels.js`);await r(e,c,{kind:t,options:n})}),v.command(`list`).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,c,t)});let y=h.command(`extension`).description(`Create and build reusable eve extension packages.`);
|
|
1
|
+
import{createLogger}from"#internal/logging.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{Command,CommanderError,InvalidArgumentError}from"#compiled/commander/index.js";import{registerBuildCommand}from"#cli/commands/build.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{resolveDevUiMode,resolveTuiDisplayOptions}from"#cli/dev/ui-options.js";import{parseDevelopmentHeaderOption,resolveDevelopmentUrlTarget}from"#cli/dev/url-target.js";import{LOG_DISPLAY_MODES,parseLogDisplayMode}from"#cli/dev/tui/log-display-mode.js";import{resolveTuiTitle}from"#cli/dev/tui/target.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.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(`#internal/nitro/host.js`)).createDevelopmentServer}const loadIsActiveDevelopmentServerForApp=async()=>(await import(`#internal/nitro/host.js`)).isActiveDevelopmentServerForApp;async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function shouldPrintCliBootBanner(e){return e.name()===`info`||e.name()===`dev`||e.name()===`init`}async function waitForShutdownSignal(e){await new Promise((t,n)=>{let r=!1,cleanup=()=>{process.off(`SIGINT`,handleSignal),process.off(`SIGTERM`,handleSignal)},handleSignal=()=>{r||(r=!0,cleanup(),e.close().then(t,n))};process.once(`SIGINT`,handleSignal),process.once(`SIGTERM`,handleSignal)})}async function waitForProductionServer(e){await Promise.race([e.wait(),waitForShutdownSignal({close:()=>e.close()})])}function parsePortOption(e){if(!/^-?\d+$/.test(e))throw new InvalidArgumentError(`Expected a numeric port, received "${e}".`);let t=Number(e);if(t<0||t>65535)throw new InvalidArgumentError(`Expected a port between 0 and 65535, received "${e}".`);return t}const DISPLAY_MODES=new Set([`full`,`collapsed`,`auto-collapsed`,`hidden`]),STATS_MODES=new Set([`tokens`,`tokensPerSecond`]);function parseDisplayMode(e){if(!DISPLAY_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...DISPLAY_MODES].join(`, `)}, received "${e}".`);return e}function parseStatsMode(e){if(!STATS_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...STATS_MODES].join(`, `)}, received "${e}".`);return e}function parseLogsMode(e){let t=parseLogDisplayMode(e);if(t===void 0)throw new InvalidArgumentError(`Expected one of ${LOG_DISPLAY_MODES.join(`, `)}, received "${e}".`);return t}function parseContextSizeOption(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)throw new InvalidArgumentError(`Expected a positive number, received "${e}".`);return t}function hasInteractiveTerminal(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function createCliProgram(e,i){let c=resolveApplicationRoot(),m=resolveInstalledPackageInfo().version,h=new Command,_=createCliTheme();h.name(`eve`).description(`Build and run an eve application.`).version(m).showHelpAfterError().exitOverride().hook(`preAction`,(t,n)=>{shouldPrintCliBootBanner(n)&&e.log(eveCliBanner())}).configureOutput({writeErr:t=>{e.error(t.trimEnd())},writeOut:t=>{e.log(t.trimEnd())}});let v=h.command(`channels`).description(`Manage user-authored channels in the current project.`);v.command(`add [kind]`).description(`Add channels interactively, or scaffold a channel kind (slack | web).`).option(`-f, --force`,`Overwrite existing channel files`).option(`-y, --yes`,`Assume yes for confirmations; requires an explicit channel kind`).action(async(t,n)=>{let{runChannelsAddCommand:r}=await import(`#cli/commands/channels.js`);await r(e,c,{kind:t,options:n})}),v.command(`list`).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,c,t)});let y=h.command(`extension`).description(`Create and build reusable eve extension packages.`);y.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,c,t)}),y.command(`build`).description(`Build the current package as an eve extension.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);t(c);let{runExtensionBuildCommand:n}=await import(`#cli/commands/extension-build.js`);await n(e,c)}),h.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(`-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,c,t,{channelWebNextjs:n.channelWebNextjs})}),registerProjectCommands({program:h,logger:e,appRoot:c}),registerBuildCommand({appRoot:c,buildHost:i.buildHost,logger:e,program:h}),h.command(`start`).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:n}=await import(`#cli/dev/environment.js`);n(c);let a=await(i.startProductionHost??await loadStartProductionHost())(c,{host:t.host,port:t.port});e.log(renderCliTaggedLine(_,{message:`server listening at ${a.url}`,tag:`start`,tone:`success`})),await waitForProductionServer(a)}),h.command(`dev`).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
|
-
`).action(async(t,n)=>{let a=resolveDevelopmentUrlTarget(n,t),s=a?.serverUrl,u=hasInteractiveTerminal(),d=resolveDevUiMode({options:n,interactive:u});if(n.input!==void 0&&d===`headless`)throw new InvalidArgumentError(`--input requires the interactive UI.`);let f=!1;s!==void 0&&(f=await(i.isActiveDevelopmentServerForApp??await loadIsActiveDevelopmentServerForApp())({appRoot:c,serverUrl:s}));let runInteractiveUi=async(e,t)=>{let r=await devBootPhase(`loading interactive UI`,async()=>i.runDevelopmentTui??await loadRunDevelopmentTui(),t),o=resolveTuiDisplayOptions(n),l=s===void 0||f?{kind:`local`,serverUrl:e.serverUrl,workspaceRoot:e.appRoot??c}:{kind:`remote`,serverUrl:e.serverUrl,workspaceRoot:c},u=resolveTuiTitle({name:n.name,target:l});u!==void 0&&(o.name=u);let d={target:l,initialInput:n.input,onBootProgress:t,...o};a?.headers===void 0?await r(d):await r({...d,headers:a.headers})};if(s){let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);if(t(c),e.log(`↗ ${f?`local`:`remote`} mode targeting ${_.info(new URL(s).host)}`),d===`headless`){e.log(renderCliTaggedLine(_,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}e.log(``),await runInteractiveUi({serverUrl:s});return}d===`tui`&&e.log(``);let p=d===`tui`?startCliLiveRow(e):void 0,m=createDevBootProgressReporter(p);p?.update(`Building your agent`);let h=!1,g,closeServer=async()=>{h||g===void 0||(h=!0,await g.close())};try{g=(i.startHost??await loadStartHost())(c,{existing:d===`tui`?`attach-if-unconfigured`:`reject`,host:n.host,onBootProgress:m,port:n.port});let t=await g.start();if(d!==`tui`&&e.log(renderCliTaggedLine(_,{message:`server listening at ${t.url}`,tag:`dev`,tone:`success`})),d===`headless`)return n.ui!==!1&&!u&&e.log(renderCliTaggedLine(_,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForShutdownSignal({close:closeServer});await runInteractiveUi({appRoot:t.appRoot,serverUrl:t.url},m)}finally{p?.stop(),await closeServer()}}),h.command(`info`).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async t=>{await(i.printApplicationInfo??await loadPrintApplicationInfo())(e,c,t)}),h.command(`eval`).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(`--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,n)=>{await(i.runEvalCommand??await loadRunEvalCommand())(t,n,e)}),h}async function runCli(e=process.argv.slice(2),t=console,n={}){let r=createCliProgram(t,n),a=e.length===0?[`dev`]:e;try{await r.parseAsync(a,{from:`user`})}catch(e){if(e instanceof CommanderError){if(e.exitCode===0)return;let r=await(n.isCodingAgentLaunch??isCodingAgentLaunch)();if(a[0]===`init`&&r){let{initAgentInstructions:e}=await import(`#cli/commands/agent-instructions.js`);t.log(e())}throw Error(e.message)}throw e}}export{resolveDevUiMode,resolveTuiDisplayOptions,runCli};
|
|
3
|
+
`).action(async(t,n)=>{let a=resolveDevelopmentUrlTarget(n,t),s=a?.serverUrl,u=hasInteractiveTerminal(),d=resolveDevUiMode({options:n,interactive:u});if(n.input!==void 0&&d===`headless`)throw new InvalidArgumentError(`--input requires the interactive UI.`);let f=!1;s!==void 0&&(f=await(i.isActiveDevelopmentServerForApp??await loadIsActiveDevelopmentServerForApp())({appRoot:c,serverUrl:s}));let runInteractiveUi=async(e,t)=>{let r=await devBootPhase(`loading interactive UI`,async()=>i.runDevelopmentTui??await loadRunDevelopmentTui(),t),o=resolveTuiDisplayOptions(n),l=s===void 0||f?{kind:`local`,serverUrl:e.serverUrl,workspaceRoot:e.appRoot??c}:{kind:`remote`,serverUrl:e.serverUrl,workspaceRoot:c},u=resolveTuiTitle({name:n.name,target:l});u!==void 0&&(o.name=u);let d={target:l,initialInput:n.input,onBootProgress:t,...o};a?.headers===void 0?await r(d):await r({...d,headers:a.headers})};if(s){let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);if(t(c),e.log(`↗ ${f?`local`:`remote`} mode targeting ${_.info(new URL(s).host)}`),d===`headless`){e.log(renderCliTaggedLine(_,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}e.log(``),await runInteractiveUi({serverUrl:s});return}d===`tui`&&e.log(``);let p=d===`tui`?startCliLiveRow(e):void 0,m=createDevBootProgressReporter(p);p?.update(`Building your agent`);let h=!1,g,closeServer=async()=>{h||g===void 0||(h=!0,await g.close())};try{g=(i.startHost??await loadStartHost())(c,{existing:d===`tui`?`attach-if-unconfigured`:`reject`,host:n.host,onBootProgress:m,port:n.port});let t=await g.start();if(d!==`tui`&&e.log(renderCliTaggedLine(_,{message:`server listening at ${t.url}`,tag:`dev`,tone:`success`})),d===`headless`)return n.ui!==!1&&!u&&e.log(renderCliTaggedLine(_,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForShutdownSignal({close:closeServer});await runInteractiveUi({appRoot:t.appRoot,serverUrl:t.url},m)}finally{p?.stop(),await closeServer()}});let b=h.command(`logs`).description("Inspect local `eve dev` diagnostic logs (.eve/logs).");return b.command(`show [logid]`,{isDefault:!0}).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,c,t,n)}),b.command(`ls`).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,c,t)}),h.command(`info`).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async t=>{await(i.printApplicationInfo??await loadPrintApplicationInfo())(e,c,t)}),h.command(`eval`).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(`--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,n)=>{await(i.runEvalCommand??await loadRunEvalCommand())(t,n,e)}),h}async function runCli(e=process.argv.slice(2),t=console,n={}){let r=createCliProgram(t,n),a=e.length===0?[`dev`]:e;try{await r.parseAsync(a,{from:`user`})}catch(e){if(e instanceof CommanderError){if(e.exitCode===0)return;let r=await(n.isCodingAgentLaunch??isCodingAgentLaunch)();if(a[0]===`init`&&r){let{initAgentInstructions:e}=await import(`#cli/commands/agent-instructions.js`);t.log(e())}throw Error(e.message)}throw e}}export{resolveDevUiMode,resolveTuiDisplayOptions,runCli};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__toESM}from"../../_virtual/_rolldown/runtime.js";import{require_picocolors}from"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js";import{isLogLevelEnabled}from"#internal/logging.js";import{sanitizeForTerminal}from"#cli/ui/output.js";import{
|
|
1
|
+
import{__toESM}from"../../_virtual/_rolldown/runtime.js";import{require_picocolors}from"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js";import{isLogLevelEnabled}from"#internal/logging.js";import{sanitizeForTerminal}from"#cli/ui/output.js";import{sliceVisible,visibleLength}from"#cli/ui/terminal-text.js";import{LiveRegion}from"#cli/ui/live-region.js";import{PROGRESS_PULSE_DURATION_MS,PROGRESS_PULSE_GLYPH,PROGRESS_PULSE_SEQUENCE}from"#cli/ui/progress-pulse.js";var import_picocolors=__toESM(require_picocolors(),1);function validatePulseSequence(e){if(e.length!==8&&e.length!==16)throw RangeError(`Pulse sequence must contain 8 or 16 steps.`);if(/[^01]/u.test(e))throw RangeError(`Pulse sequence steps must be "0" or "1".`)}function pulseStepDurationMs(e,t){let n=Math.round(e*PROGRESS_PULSE_DURATION_MS/t);return Math.round((e+1)*PROGRESS_PULSE_DURATION_MS/t)-n}function sanitizeProgressText(e){return sanitizeForTerminal(e).replaceAll(/\s+/gu,` `).trim()}function fitProgressText(e,t){return t<=0?``:visibleLength(e)<=t?e:t===1?`…`:`${sliceVisible(e,t-1)}…`}function renderProgressRow(e,t,n,r){let i=n!==``,o=`${e} ${t}${i?``:`...`}`,s=Math.max(0,(r??80)-1),c=visibleLength(o);if(c>=s){let t=fitProgressText(o,s);return t.startsWith(e)?`${import_picocolors.default.green(e)}${t.slice(e.length)}`:t}let l=i?fitProgressText(` ${n}`,s-c):``,d=l===``?``:import_picocolors.default.dim(l);return`${import_picocolors.default.green(e)}${o.slice(e.length)}${d}`}function startCliLiveRow(e,t={}){let r=t.output??process.stdout,i=t.pulseSequence??PROGRESS_PULSE_SEQUENCE;validatePulseSequence(i);let a=r.isTTY===!0&&!isLogLevelEnabled(`debug`),s=a?new LiveRegion({write:e=>(r.write(e),!0)}):void 0,u=0,d=i[0]===`1`,f,p=!1,m=!1,h=!1,g,paint=()=>{if(f===void 0||s===void 0)return;let e=renderProgressRow(d?PROGRESS_PULSE_GLYPH:` `,f.message,f.detail,r.columns);s.update([e]),p=!0},schedulePulseStep=()=>{g=setTimeout(()=>{if(h)return;u=(u+1)%i.length;let e=i[u]===`1`;e!==d&&(d=e,paint()),schedulePulseStep()},pulseStepDurationMs(u,i.length)),g.unref?.()};return{update(t,n=``){if(!h){if(f={detail:sanitizeProgressText(n),message:sanitizeProgressText(t)},!a){m||=(e.log(`${f.message}...`),!0);return}paint(),g===void 0&&schedulePulseStep()}},stop(){h||(h=!0,g!==void 0&&clearTimeout(g),s!==void 0&&p&&s.clear())}}}export{startCliLiveRow};
|
|
@@ -205,6 +205,15 @@ export declare const AgentInfoResultSchema: z.ZodObject<{
|
|
|
205
205
|
contextWindowTokens: z.ZodOptional<z.ZodNumber>;
|
|
206
206
|
id: z.ZodString;
|
|
207
207
|
providerOptions: z.ZodOptional<z.ZodUnknown>;
|
|
208
|
+
reasoning: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
|
|
209
|
+
high: "high";
|
|
210
|
+
low: "low";
|
|
211
|
+
medium: "medium";
|
|
212
|
+
minimal: "minimal";
|
|
213
|
+
none: "none";
|
|
214
|
+
"provider-default": "provider-default";
|
|
215
|
+
xhigh: "xhigh";
|
|
216
|
+
}>>>;
|
|
208
217
|
source: z.ZodOptional<z.ZodObject<{
|
|
209
218
|
exportName: z.ZodOptional<z.ZodString>;
|
|
210
219
|
logicalPath: z.ZodString;
|
|
@@ -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)})]),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({markdown:z.string()}),schedule=entry.extend({cron:z.string(),hasRun:z.boolean(),markdown:z.string().optional()}),subagent=entry.extend({description:z.string(),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:z.object({contextWindowTokens:z.number().optional(),id:z.string(),providerOptions:z.unknown().optional(),source:source.optional(),routing:modelRouting.optional(),endpoint:modelEndpoint.optional()}),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:instructions.nullable()}),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(1),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(`gateway`),connected:z.literal(!0),credential:z.enum([`api-key`,`oidc`])}),z.object({kind:z.literal(`gateway`),connected:z.literal(!1)})]),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({markdown:z.string()}),schedule=entry.extend({cron:z.string(),hasRun:z.boolean(),markdown:z.string().optional()}),subagent=entry.extend({description:z.string(),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:z.object({contextWindowTokens:z.number().optional(),id:z.string(),providerOptions:z.unknown().optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional().catch(void 0),source:source.optional(),routing:modelRouting.optional(),endpoint:modelEndpoint.optional()}),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:instructions.nullable()}),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(1),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{EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{encodeBasicCredentials}from"#internal/http/basic-auth.js";import{AgentInfoResponseError}from"#client/agent-info-error.js";import{AgentInfoResultSchema}from"#client/agent-info-schema.js";import{ClientError}from"#client/client-error.js";import{ClientSession}from"#client/session.js";import{createInitialSessionState}from"#client/session-utils.js";import{createClientUrl}from"#client/url.js";import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";var Client=class{#e;#t;#n;#r;#i
|
|
1
|
+
import{EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{encodeBasicCredentials}from"#internal/http/basic-auth.js";import{AgentInfoResponseError}from"#client/agent-info-error.js";import{AgentInfoResultSchema}from"#client/agent-info-schema.js";import{ClientError}from"#client/client-error.js";import{ClientSession}from"#client/session.js";import{createInitialSessionState}from"#client/session-utils.js";import{createClientUrl}from"#client/url.js";import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";var Client=class{#e;#t;#n;#r;#i;constructor(e){this.#n=e.host,this.#e=e.auth,this.#t=e.headers,this.#r=e.preserveCompletedSessions??!1,this.#i=e.redirect}async health(){let t=createClientUrl(this.#n,EVE_HEALTH_ROUTE_PATH),n=await this.#a(),r=await fetch(t,withRedirectPolicy({headers:n},this.#i));if(!r.ok){let e=await r.text();throw new ClientError(r.status,e,r.headers)}return await r.json()}async info(){let e=await this.fetch(EVE_INFO_ROUTE_PATH);if(!e.ok){let t=await e.text();throw new ClientError(e.status,t,e.headers)}let n;try{n=await e.json()}catch{throw new AgentInfoResponseError}let i=AgentInfoResultSchema.safeParse(n);if(!i.success)throw new AgentInfoResponseError(i.error.issues.slice(0,5).map(e=>{let t=e.path.join(`.`);return t.length===0?e.message:`${t}: ${e.message}`}));return i.data}async fetch(e,t={}){let n=createClientUrl(this.#n,e),r=await this.#a(headersInitToRecord(t.headers));return await fetch(n,withRedirectPolicy({...t,headers:r},this.#i))}session(e){let t;return t=typeof e==`string`?{continuationToken:e,streamIndex:0}:e||createInitialSessionState(),new ClientSession({host:this.#n,preserveCompletedSessions:this.#r,redirect:this.#i,resolveHeaders:e=>this.#a(e)},t)}async#a(e){let t=new Headers,[n,r]=await Promise.all([resolveHeadersValue(this.#t),this.#o()]);for(let[e,r]of Object.entries(n))t.set(e,r);if(e)for(let[n,r]of Object.entries(e))t.set(n,r);for(let[e,n]of Object.entries(r))t.set(e,n);return t}async#o(){let e=this.#e;if(!e)return{};if(`vercelOidc`in e){let t=(await resolveTokenValue(e.vercelOidc.token)).trim();return t.length===0?{}:{authorization:`Bearer ${t}`,[VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER]:t}}if(`bearer`in e){let t=(await resolveTokenValue(e.bearer)).trim();return t.length===0?{}:{authorization:`Bearer ${t}`}}if(`basic`in e){let t=await resolveTokenValue(e.basic.password);return{authorization:`Basic ${encodeBasicCredentials(e.basic.username,t)}`}}return{}}};async function resolveTokenValue(e){return typeof e==`function`?e():e}async function resolveHeadersValue(e){return e===void 0?{}:typeof e==`function`?await e():e}function headersInitToRecord(e){return e===void 0?{}:Object.fromEntries(new Headers(e).entries())}function withRedirectPolicy(e,t){return t===void 0?e:{...e,redirect:t}}export{Client};
|
|
@@ -46,7 +46,7 @@ export interface EveAgentStoreCallbacks<TData> {
|
|
|
46
46
|
* Configuration for constructing an {@link EveAgentStore}.
|
|
47
47
|
*
|
|
48
48
|
* Requires a {@link EveAgentReducer | reducer}, plus either connection options
|
|
49
|
-
* (`host`, `auth`, `headers`, `
|
|
49
|
+
* (`host`, `auth`, `headers`, `initialSession`) for a
|
|
50
50
|
* store-owned session or an existing {@link ClientSession} via `session`.
|
|
51
51
|
*
|
|
52
52
|
* `optimistic` (default `true`) projects submitted user messages before the
|
|
@@ -60,7 +60,6 @@ export interface EveAgentStoreInit<TData> {
|
|
|
60
60
|
readonly host?: string;
|
|
61
61
|
readonly initialEvents?: readonly HandleMessageStreamEvent[];
|
|
62
62
|
readonly initialSession?: SessionState;
|
|
63
|
-
readonly maxReconnectAttempts?: number;
|
|
64
63
|
readonly optimistic?: boolean;
|
|
65
64
|
readonly reducer: EveAgentReducer<TData>;
|
|
66
65
|
readonly session?: ClientSession;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toError}from"#shared/errors.js";import{Client}from"#client/client.js";var EveAgentStore=class{#e;#t;#n;#r=new Set;#i;#a={};#o;#s;#c;#l=0;#u;#d;#f;#p;#m=`ready`;constructor(e){this.#e=e.session?void 0:()=>new Client({auth:e.auth,headers:e.headers,host:e.host
|
|
1
|
+
import{toError}from"#shared/errors.js";import{Client}from"#client/client.js";var EveAgentStore=class{#e;#t;#n;#r=new Set;#i;#a={};#o;#s;#c;#l=0;#u;#d;#f;#p;#m=`ready`;constructor(e){this.#e=e.session?void 0:()=>new Client({auth:e.auth,headers:e.headers,host:e.host??``}).session(e.initialSession),this.#c=[...e.initialEvents??[]],this.#d=[...this.#c],this.#t=e.optimistic??!0,this.#n=e.reducer,this.#f=e.session??this.#h(),this.#o=this.#E(this.#d),this.#p=this.#D()}get snapshot(){return this.#p}setCallbacks(e){this.#a=e}subscribe(e){return this.#r.add(e),()=>{this.#r.delete(e)}}async send(t){if(this.#m===`streaming`||this.#m===`submitted`)throw Error(`eve session is already processing a turn.`);let n=this.#g(),r=new AbortController;this.#i=r,this.#s=void 0,this.#m=`submitted`,this.#O();try{let e=await this.#a.prepareSend?.(t)??t;if(!this.#v(n))return;this.#y(e),this.#b(e),this.#O();let i=await this.#f.send({...e,signal:createAbortSignal(e.signal,r.signal)}),a=!1;for await(let e of i){if(!this.#v(n))return;a||(a=!0,this.#m=`streaming`),this.#c=[...this.#c,e],this.#x(e),this.#a.onEvent?.(e),this.#S(e),this.#O()}if(!this.#v(n))return;this.#m=this.#s===void 0?`ready`:`error`}catch(t){if(!this.#v(n))return;isAbortError(t)?(this.#m=`ready`,this.#C(toError(t))):(this.#s=toError(t),this.#m=`error`,this.#C(this.#s),this.#a.onError?.(this.#s))}finally{this.#v(n)&&(this.#i=void 0,this.#a.onSessionChange?.(this.#f.state),this.#O(),this.#a.onFinish?.(this.#p))}}stop(){this.#i?.abort()}reset(){this.#_(),this.stop(),this.#i=void 0,this.#f=this.#e?.()??this.#f,this.#c=[],this.#u=void 0,this.#d=[],this.#o=this.#n.initial(),this.#s=void 0,this.#m=`ready`,this.#a.onSessionChange?.(this.#f.state),this.#O()}#h(){if(!this.#e)throw Error(`Cannot create an owned eve session from an external session.`);return this.#e()}#g(){return this.#l+=1,this.#l}#_(){this.#l+=1}#v(e){return this.#l===e}#y(e){if(!this.#t||e.message===void 0)return;let t=createSubmissionId(),n={createdAt:Date.now(),id:t,message:summarizeUserContent(e.message)};this.#u=n,this.#w({data:{createdAt:n.createdAt,message:n.message,submissionId:n.id},type:`client.message.submitted`})}#b(e){e.inputResponses===void 0||e.inputResponses.length===0||this.#w({data:{createdAt:Date.now(),responses:e.inputResponses},type:`client.input.responded`})}#x(e){if(e.type===`message.received`&&this.#u!==void 0){let t=this.#u.id;this.#u=void 0,this.#T(e=>e.type===`client.message.submitted`&&e.data.submissionId===t,e);return}this.#w(e)}#S(e){let t=toTerminalStreamFailureError(e);t!==void 0&&(this.#m=`error`,this.#C(t),this.#s===void 0&&(this.#s=t,this.#a.onError?.(t)))}#C(e){let t=this.#u;t!==void 0&&(this.#u=void 0,this.#T(e=>e.type===`client.message.submitted`&&e.data.submissionId===t.id,{data:{createdAt:t.createdAt,error:{message:e.message},message:t.message,submissionId:t.id},type:`client.message.failed`}))}#w(e){this.#d=[...this.#d,e],this.#o=this.#n.reduce(this.#o,e)}#T(e,t){let n=!1;this.#d=this.#d.map(r=>!n&&e(r)?(n=!0,t):r),n||(this.#d=[...this.#d,t]),this.#o=this.#E(this.#d)}#E(e){let t=this.#n.initial();for(let n of e)t=this.#n.reduce(t,n);return t}#D(){return{data:this.#o,error:this.#s,events:this.#c,session:this.#f.state,status:this.#m}}#O(){this.#p=this.#D();for(let e of this.#r)e()}};let submissionSequence=0;function createSubmissionId(){let e=globalThis.crypto?.randomUUID;return e===void 0?(submissionSequence+=1,`submission_${submissionSequence.toString()}`):e.call(globalThis.crypto)}function createAbortSignal(e,t){return e?AbortSignal.any([e,t]):t}function summarizeUserContent(e){if(typeof e==`string`)return e;let t=[];for(let n of e){if(n.type===`text`){t.push(n.text);continue}n.type===`file`&&t.push(n.filename?`[file: ${n.filename}]`:`[file]`)}return t.join(`
|
|
2
2
|
`)}function isAbortError(e){return e instanceof Error&&e.name===`AbortError`}function toTerminalStreamFailureError(e){if(e.type!==`session.failed`)return;let t=Error(e.data.message);return t.name=e.data.code,t}export{EveAgentStore};
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import type { HandleMessageStreamEvent } from "#protocol/message.js";
|
|
2
2
|
import type { ClientRedirectPolicy } from "#client/types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Internal configuration for
|
|
4
|
+
* Internal configuration for following a durable event stream.
|
|
5
5
|
*/
|
|
6
|
-
interface
|
|
6
|
+
interface FollowStreamInput {
|
|
7
7
|
readonly host: string;
|
|
8
|
-
readonly maxReconnectAttempts: number;
|
|
9
8
|
readonly resolveHeaders: () => Promise<Headers>;
|
|
10
9
|
readonly redirect?: ClientRedirectPolicy;
|
|
11
10
|
readonly sessionId: string;
|
|
12
11
|
readonly signal?: AbortSignal;
|
|
13
12
|
readonly startIndex: number;
|
|
14
13
|
}
|
|
15
|
-
type OpenStreamBodyInput = Omit<OpenStreamInput, "maxReconnectAttempts">;
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* Follows a session's durable event stream from an absolute cursor,
|
|
16
|
+
* transparently reconnecting whenever the transport ends.
|
|
17
|
+
*
|
|
18
|
+
* Transport endings reconnect from the advanced cursor. Progress resets the
|
|
19
|
+
* idle budget; repeated empty streams eventually stop the follow. Callers own
|
|
20
|
+
* boundary handling. Negative tail-relative cursors use one connection because
|
|
21
|
+
* they cannot be advanced safely.
|
|
19
22
|
*/
|
|
20
|
-
export declare function
|
|
23
|
+
export declare function followStreamIterable(input: FollowStreamInput): AsyncGenerator<HandleMessageStreamEvent>;
|
|
21
24
|
/**
|
|
22
|
-
* Opens one stream response body, retrying transient
|
|
23
|
-
*
|
|
25
|
+
* Opens one stream response body, retrying transient failures with capped
|
|
26
|
+
* exponential backoff (~35s total): brief network outages and the short
|
|
27
|
+
* propagation window where a just-acknowledged session may not yet be
|
|
24
28
|
* readable from the stream route.
|
|
25
29
|
*/
|
|
26
|
-
export declare function openStreamBody(input:
|
|
30
|
+
export declare function openStreamBody(input: FollowStreamInput): Promise<ReadableStream<Uint8Array>>;
|
|
27
31
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createEveMessageStreamRoutePath}from"#protocol/routes.js";import{ClientError}from"#client/client-error.js";import{createClientUrl}from"#client/url.js";import{isStreamDisconnectError,readNdjsonStream}from"#client/ndjson.js";const STREAM_OPEN_RETRYABLE_STATUS=new Set([404,409,425,500,502,503,504]);async function*
|
|
1
|
+
import{createEveMessageStreamRoutePath}from"#protocol/routes.js";import{ClientError}from"#client/client-error.js";import{createClientUrl}from"#client/url.js";import{isStreamDisconnectError,readNdjsonStream}from"#client/ndjson.js";const STREAM_OPEN_RETRY_MAX_DELAY_MS=5e3,STREAM_OPEN_RETRYABLE_STATUS=new Set([404,409,425,500,502,503,504]);async function*followStreamIterable(e){let t=e.startIndex,n=250,a=0,o=!0;for(;;){let s;try{s=await openStreamBody({...e,startIndex:t})}catch(t){if(e.signal?.aborted)return;throw t}let c=!1;try{for await(let e of readNdjsonStream(s))t+=1,c=!0,n=250,a=0,yield e}catch(e){if(!isStreamDisconnectError(e))throw e}if(e.signal?.aborted||e.startIndex<0||!c&&!o&&(a+=1)>=5||(o=!1,await sleep(n,e.signal),e.signal?.aborted))return;n=Math.min(n*2,4e3)}}async function openStreamBody(i){let s,c,l,u=250;for(let d=0;d<12;d+=1){let f=createClientUrl(i.host,createEveMessageStreamRoutePath(i.sessionId),i.startIndex===0?void 0:{startIndex:String(i.startIndex)}),p=await i.resolveHeaders(),m;try{m=await fetch(f,{headers:p,redirect:i.redirect,signal:i.signal??null})}catch(e){if(i.signal?.aborted||!isStreamDisconnectError(e)||d===11)throw e;await sleep(u,i.signal),u=Math.min(u*2,STREAM_OPEN_RETRY_MAX_DELAY_MS);continue}if(m.ok){if(!m.body)throw new ClientError(m.status,`Response body is null.`,m.headers);return m.body}if(s=m.status,c=await m.text(),l=m.headers,!STREAM_OPEN_RETRYABLE_STATUS.has(m.status))throw new ClientError(m.status,c,m.headers);d<11&&(await sleep(u,i.signal),u=Math.min(u*2,STREAM_OPEN_RETRY_MAX_DELAY_MS))}throw new ClientError(s??0,c??`Failed to open message stream.`,l)}async function sleep(e,t){t?.aborted||await new Promise(n=>{let onAbort=()=>{clearTimeout(r),n()},r=setTimeout(()=>{t?.removeEventListener(`abort`,onAbort),n()},e);t?.addEventListener(`abort`,onAbort,{once:!0})})}export{followStreamIterable,openStreamBody};
|
|
@@ -10,7 +10,8 @@ export declare function createInitialSessionState(): SessionState;
|
|
|
10
10
|
*
|
|
11
11
|
* When the boundary event is `session.waiting`, the session is preserved for
|
|
12
12
|
* the next message. For `session.completed` and `session.failed`, the session
|
|
13
|
-
* resets so the next call starts a new conversation.
|
|
13
|
+
* resets so the next call starts a new conversation. Without a boundary, the
|
|
14
|
+
* session stays resumable from its advanced cursor.
|
|
14
15
|
*/
|
|
15
16
|
export declare function advanceSession(input: {
|
|
16
17
|
readonly continuationToken?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isCurrentTurnBoundaryEvent}from"#protocol/message.js";function createInitialSessionState(){return{streamIndex:0}}function advanceSession(e){let t=findBoundaryEvent(e.events),n=e.session.streamIndex+e.events.length;return t?.type===`session.waiting`||e.preserveCompletedSessions===!0&&t?.type===`session.completed`?{continuationToken:t?.type===`session.waiting`?t.data.continuationToken:e.continuationToken??e.session.continuationToken,sessionId:e.sessionId,streamIndex:n}:createInitialSessionState()}function extractCompletedMessage(e){let t;for(let n of e)isFinalMessageCompleted(n)&&(t=n.data.message??void 0);return t}function deriveResultStatus(e){let t=findBoundaryEvent(e);return t?.type===`session.waiting`?`waiting`:t?.type===`session.failed`?`failed`:`completed`}function extractInputRequests(e){let t=[];for(let n of e)n.type===`input.requested`&&t.push(...n.data.requests);return t}function findBoundaryEvent(t){for(let n=t.length-1;n>=0;n--){let r=t[n];if(r!==void 0&&isCurrentTurnBoundaryEvent(r))return r}}function isFinalMessageCompleted(e){return e.type===`message.completed`&&e.data.finishReason!==`tool-calls`}export{advanceSession,createInitialSessionState,deriveResultStatus,extractCompletedMessage,extractInputRequests};
|
|
1
|
+
import{isCurrentTurnBoundaryEvent}from"#protocol/message.js";function createInitialSessionState(){return{streamIndex:0}}function advanceSession(e){let t=findBoundaryEvent(e.events),n=e.session.streamIndex+e.events.length;return t?.type===`session.waiting`||e.preserveCompletedSessions===!0&&t?.type===`session.completed`?{continuationToken:t?.type===`session.waiting`?t.data.continuationToken:e.continuationToken??e.session.continuationToken,sessionId:e.sessionId,streamIndex:n}:t===void 0?{continuationToken:e.continuationToken??e.session.continuationToken,sessionId:e.sessionId,streamIndex:n}:createInitialSessionState()}function extractCompletedMessage(e){let t;for(let n of e)isFinalMessageCompleted(n)&&(t=n.data.message??void 0);return t}function deriveResultStatus(e){let t=findBoundaryEvent(e);return t?.type===`session.waiting`?`waiting`:t?.type===`session.failed`?`failed`:`completed`}function extractInputRequests(e){let t=[];for(let n of e)n.type===`input.requested`&&t.push(...n.data.requests);return t}function findBoundaryEvent(t){for(let n=t.length-1;n>=0;n--){let r=t[n];if(r!==void 0&&isCurrentTurnBoundaryEvent(r))return r}}function isFinalMessageCompleted(e){return e.type===`message.completed`&&e.data.finishReason!==`tool-calls`}export{advanceSession,createInitialSessionState,deriveResultStatus,extractCompletedMessage,extractInputRequests};
|
|
@@ -7,7 +7,6 @@ import type { CancelSessionResult, ClientRedirectPolicy, SendTurnInput, SessionS
|
|
|
7
7
|
*/
|
|
8
8
|
interface SessionContext {
|
|
9
9
|
readonly host: string;
|
|
10
|
-
readonly maxReconnectAttempts: number;
|
|
11
10
|
readonly preserveCompletedSessions: boolean;
|
|
12
11
|
readonly redirect?: ClientRedirectPolicy;
|
|
13
12
|
resolveHeaders(perRequest?: Readonly<Record<string, string>>): Promise<Headers>;
|
|
@@ -56,10 +55,9 @@ export declare class ClientSession {
|
|
|
56
55
|
* Opens this session's event stream for the current session ID.
|
|
57
56
|
*
|
|
58
57
|
* Resumes from the session's stored stream cursor unless `options.startIndex`
|
|
59
|
-
* overrides it.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* `maxReconnectAttempts`.
|
|
58
|
+
* overrides it. The stream reconnects from its cursor when the connection
|
|
59
|
+
* ends. Negative indices read relative to the current tail on one connection
|
|
60
|
+
* and do not advance the stored absolute cursor.
|
|
63
61
|
*
|
|
64
62
|
* @throws {Error} If the session has no session ID (no message has been sent
|
|
65
63
|
* yet).
|