eve 0.9.5 → 0.9.8

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.
@@ -1,6 +1,6 @@
1
1
  import{sliceVisible,stripAnsi,stripTerminalControls,visibleLength}from"./terminal-text.js";import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{buildAgentHeader}from"./agent-header.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.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{interruptedError}from"./errors.js";import{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,lineOf,visibleLine}from"./line-editor.js";import{LiveRegion}from"./live-region.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{renderAcknowledgeQuestion,renderFlowPanel,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,formatTokenFlow,nextKey,stripPromptControlCharacters,takeUntil}from"./stream-format.js";import{toErrorMessage}from"#shared/errors.js";import{initialSelectState,reduceSelect,selectValueAtCursor}from"#setup/cli/select-state.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.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=new Map;#m=new Set;#h=[];#g=new Set;#_=new Map;#v=new Set;#y;#b=!1;#x;#S=[];#C;#w=0;#T;#E=``;#D=0;#O=new PromptHistory;#k=!1;#A;#j=!1;#M=STATUS.processing;#N=`Eve`;#P=!1;#F=!1;#I=!0;#L=0;#R;#z;#B;#V=!1;#H;#U=``;#W;#G;#K;#q=!1;#J=!1;#Y;#X;#Z;#Q;#$;#ee;#te;#ne=``;#re=``;#ie;#ae;#oe=0;#se;#ce;#le;#ue;#de;setupFlow={begin:e=>this.#he(e),end:e=>this.#ge(e?.preserveDiagnostics??!0),readSelect:e=>this.#_e(e),readEditableSelect:e=>this.#ye(e),readText:e=>this.#be(e),readAcknowledge:e=>this.#xe(e),readChoice:e=>this.#ve(e),setStatus:e=>this.#ke(e),renderLine:(e,t)=>this.#Ae(e,t),renderOutput:e=>this.#je(e),waitForInterrupt:()=>this.#Ee()};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#i=e?.tools??`auto-collapsed`,this.#a=e?.reasoning??`full`,this.#o=e?.subagents??`auto-collapsed`,this.#s=e?.connectionAuth??`full`,this.#c=e?.assistantResponseStats??`tokensPerSecond`,this.#l=e?.contextSize,this.#Z=e?.contextSize,this.#u=e?.captureForeignOutput??this.#t===process.stdout,this.#d=e?.logs??`none`}renderAgentHeader(e){this.#N=e.name,this.#y=e,this.#Me();let t=this.#dt().join(`
2
- `);if(this.#b){t!==this.#x&&(this.#x=t,this.#Ge({kind:`agent-header`,body:t,live:!1})),this.#ot();return}this.#b=!0,this.#x=t,this.#n.flush(this.#dt(),[])}async readPrompt(e){this.#Me(e),this.#k=!0,this.#j=!1,this.#M=``;let t=lineOf(stripPromptControlCharacters(e?.initialDraft??``));return this.#O.begin(t.text),this.#fe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,t.text),this.#Be(),this.#ot(),await new Promise((e,r)=>{let apply=e=>{t=e,this.#He(),this.#fe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,e.text,this.#A),this.#ot()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#A=void 0,this.#Ve(),this.#Ne(),r(interruptedError())},suggestions=()=>this.#A!==void 0&&isTypeaheadOpen(this.#A)?this.#A:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#H=r=>{let i=applyLineEditorKey(t,r);if(i!==void 0){apply(i);return}switch(r.type){case`up`:{let e=suggestions();e===void 0?recall(this.#O.previous(t.text)):(this.#A=moveTypeaheadSelection(e,-1),this.#ot());break}case`down`:{let e=suggestions();e===void 0?recall(this.#O.next()):(this.#A=moveTypeaheadSelection(e,1),this.#ot());break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#A=dismissTypeahead(e),this.#ot());break}case`enter`:{let r=highlighted(),i=r!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(r).trimEnd():t.text;this.#A=void 0,this.#O.add(i),this.#k=!1,this.#Ve(),this.#M=STATUS.processing,isPromptControlCommand(i)?this.#Ge({kind:`command`,body:stripTerminalControls(i.trim()),live:!1}):(this.#Ke(i),this.#se=i),this.#fe(EMPTY_LINE),this.#ot(),this.#Fe(),e(i);break}case`ctrl-d`:t.text.length===0?interrupt():apply(deleteForward(t));break;case`ctrl-l`:this.#lt();break;case`ctrl-r`:this.#ot();break;case`ctrl-c`:interrupt();break;default:break}},this.#Pe()})}#fe(e){this.#E=e.text,this.#D=e.cursor}async renderStream(e,t){this.#Me(t),this.#m.clear(),this.#k=!1,this.#j=!0,this.#M=STATUS.processing,this.#qe(t?.submittedPrompt),this.#F=!1,this.#Y=void 0,this.#X=void 0,this.#Q=void 0,this.#$=void 0,this.#ee=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#Ue(),this.#ot();let r=new Promise(e=>{this.#K=e});this.#H=e=>this.#ze(e),this.#Pe();let i={text:new Map,reasoning:new Map,tools:new Map,hasPendingToolResults:!1};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#F)break;this.#$e(t,n,i)}}catch(e){this.#Je(`Error`,toErrorMessage(e))}finally{this.#K=void 0,this.#F&&e.abort?.(),this.#Fe(),this.#We(),this.#j=!1,this.#M=completedTurnStatus(this.#F,t?.continueSession===!0),this.#Qe(),this.#ot(),(this.#F||!t?.continueSession)&&this.#Ne()}if(this.#F)throw interruptedError()}async readToolApproval(e,t){return this.#Me(t),this.#k=!1,this.#j=!1,this.#M=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#F=!1,this.#ot(),await new Promise((t,n)=>{this.#H=r=>{switch(r.type){case`character`:{let n=r.value.toLowerCase();n===`y`?(this.#M=STATUS.processing,this.#Fe(),this.#ot(),t({approved:!0})):n===`n`&&(this.#M=STATUS.processing,this.#pe(e.toolCallId),this.#Fe(),this.#ot(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#ot();break;case`ctrl-c`:this.#F=!0,this.#Ne(),n(interruptedError());break;default:break}},this.#Pe()})}async readInputQuestion(e,t){this.#Me(t),this.#k=!1,this.#j=!1,this.#F=!1;let r=e.options??[],i=r.length>0,a=(e.allowFreeform===!0||!i)&&i,o=r.length+ +!!a,s=questionSectionId(e.requestId),c=i?`select`:`text`,l=0,u=``,isOnFreeformRow=()=>a&&l===r.length,renderSection=()=>{this.#Xe({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,l,this.#r),preformatted:!0,live:!0})},repaintStatus=()=>{if(c===`select`){let e=isOnFreeformRow()?`type`:`select`;this.#M=`↑/↓ move · enter ${e} · Ctrl+C quit`,this.#k=!1}else this.#k=!0,this.#fe(lineOf(u)),this.#M=``;this.#ot()};renderSection(),c===`text`&&this.#Be(),repaintStatus();let finalize=t=>{this.#Xe({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:` ${this.#r.colors.green(this.#r.glyph.success)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#k=!1,this.#M=STATUS.processing,this.#Ve(),this.#Fe(),this.#ot();let r={};return t.optionId!==void 0&&(r.optionId=t.optionId),t.text!==void 0&&(r.text=t.text),r};return await new Promise((t,n)=>{this.#H=a=>{if(a.type===`ctrl-c`){this.#F=!0,this.#Ve(),this.#Ne(),n(interruptedError());return}if(a.type===`ctrl-r`){this.#ot();return}if(c===`select`){switch(a.type){case`up`:o>0&&(l=(l-1+o)%o,renderSection(),repaintStatus());break;case`down`:o>0&&(l=(l+1)%o,renderSection(),repaintStatus());break;case`enter`:{if(isOnFreeformRow()){c=`text`,u=``,this.#Be(),repaintStatus();break}let e=r[l];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}switch(a.type){case`character`:u+=a.value,this.#He(),repaintStatus();break;case`backspace`:u=u.slice(0,-1),this.#He(),repaintStatus();break;case`enter`:{let n=resolveQuestionText(u,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(i){if(u.length>0){u=``,this.#He(),repaintStatus();break}c=`select`,u=``,this.#k=!1,this.#Ve(),repaintStatus();break}u=``,this.#He(),repaintStatus();break;default:break}},this.#Pe()})}upsertSubagentStep(e){if(this.#o===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),r=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&r.length===0)){if(this.#Ye(e.callId,e.subagentName),this.#o===`collapsed`){this.#ot();return}this.#Xe({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:r,live:!e.finalized}),this.#ot()}}upsertSubagentTool(e){if(this.#o===`hidden`)return;if(this.#Ye(e.callId,e.subagentName),this.#o===`collapsed`){this.#ot();return}let t=subagentToolStatus(e.status),r={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&&(r.result=stripTerminalControls(e.errorText)):(r.result=summarizeToolResult(e.output),r.toolOutput=e.output),this.#Xe(r),this.#ot()}markChildToolCallId(e){this.#g.add(e);let t=this.#_.get(e);t!==void 0&&(this.#Ze(t),this.#_.delete(e),this.#ot())}#pe(e){let t=this.#p.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#s===`hidden`)return;let t=e.state===`authorized`||e.state===`declined`||e.state===`failed`||e.state===`timed-out`;this.#Xe({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e),preformatted:!0,live:!t}),this.#ot()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#w)return;let n=this.#w>0;this.#w=t,t>0?(this.#M=STATUS.connectionAuth,this.#ot()):n&&(this.#M=STATUS.processing,this.#ot())}setVercelStatus(e){this.#T=e,this.#ot()}reset(){this.#f=[],this.#p.clear(),this.#m.clear(),this.#C=void 0,this.#S.length=0,this.#h.length=0,this.#b=!1,this.#x=void 0,this.#g.clear(),this.#_.clear(),this.#v.clear(),this.#se=void 0,this.#ae=void 0,this.#w=0,this.#Y=void 0,this.#X=void 0,this.#Q=void 0,this.#$=void 0,this.#ee=void 0,this.#P&&(this.#n.clearAll(),this.#ot())}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Me(),this.#Ge({kind:`notice`,body:t,live:!1}),this.#ot())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#Me(),this.#Ge({kind:`sandbox`,body:t,live:!1}),this.#ot())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#me();return}this.#Me(),this.#le=t,this.#ot()}clearSetupWarning(){this.#me()}#me(){this.#le!==void 0&&(this.#le=void 0,this.#ot())}renderCommandResult(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Me(),this.#Ge({kind:`result`,body:t,live:!1}),this.#ot())}#he(e){this.#Me(),this.#k=!1,this.#j=!1,this.#M=``,this.#ce={title:stripTerminalControls(e),lines:[],outputBuffer:[]},this.#Ue(),this.#ot()}#ge(e){this.#ue=void 0,this.#Oe();let t=this.#ce;if(t!==void 0){if(this.#ce=void 0,this.#We(),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.#Ge({kind:`flow`,title:`info`,body:e.join(`
3
- `),live:!1}),this.#Ge({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#ot()}}async#_e(e){let t=this.#Se(),n=isMultiSelectRequest(e),r={options:e.options,submitRow:n};`initialValue`in e&&e.initialValue!==void 0&&(r.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(r.initialValues=e.initialValues);let i=initialSelectState(r),a,o=e.notices;if(e.kind===`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}));o=[...e.notices??[],...r],t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,select:i};return o!==void 0&&o.length>0&&(t.notices=o),a!==void 0&&(t.error=a),t};return t.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#ot(),await this.#Te((t,r)=>{let o={key:t,options:e.options,select:i},s=reduceSetupSelectInput(n?{...o,kind:e.kind,required:e.required}:{...o,kind:e.kind});switch(s.kind){case`cancel`:r(void 0);return;case`repaint`:this.#ot();return;case`update`:i=s.select,a=void 0,this.#ot();return;case`submit`:r(s.values);return;case`error`:a=s.message,this.#ot();return;case`ignore`:return}}).promise}#ve(e){this.#Me();let t=this.#Ce();t.status=e.status;let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#r,t),this.#ot();let r=this.#Te((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.#ot();return;case`repaint`:this.#ot();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#ye(e){let t=this.#Se(),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:`editable`,message:e.message,options:e.options,select:r,edit:{optionValue:e.editable.value,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint,caretVisible:this.#I}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#r,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?(i.text.length===0&&(i=lineOf(e.editable.defaultValue)),this.#Be()):(i=lineOf(``),this.#Ve())};return syncEditableRow(),this.#ot(),await this.#Te((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#He(),this.#ot()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#ot()},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.#ot();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.#ot();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Ve()).promise}async#be(e){let t=this.#Se(),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.#I)},this.#Be(),this.#ot(),await this.#Te((t,i)=>{let apply=e=>{n=e,r=void 0,this.#He(),this.#ot()},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.#ot();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#ot();return}i(t);return}default:return}},()=>this.#Ve()).promise}async#xe(e){let t=this.#Se();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#ot(),await this.#Te((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#ot();return;default:return}}).promise}#Se(){return this.#Me(),this.#k=!1,this.#j=!1,this.#M=``,this.#Ce()}#Ce(){return this.#ce===void 0&&(this.#ce={title:``,lines:[],outputBuffer:[]}),this.#ce}#we(){this.#ce!==void 0&&(this.#ce.question=void 0,this.#ce.hideLinesWhileQuestion=!1),this.#H=void 0,this.#Fe(),this.#De(),this.#ot()}#Te(e,t){let n=!1,r,i=new Promise(e=>{r=e}),settle=e=>{n||(n=!0,t?.(),this.#we(),r(e))};return this.#H=t=>e(t,settle),this.#Pe(),{promise:i,settle}}#Ee(){let e,t=new Promise(t=>{e=t});return this.#ue=e,this.#De(),{promise:t,dispose:()=>{this.#ue===e&&(this.#ue=void 0,this.#Oe())}}}#De(){if(this.#ue===void 0)return;let consumer=e=>{if(e.type===`ctrl-c`||e.type===`escape`){let e=this.#ue;this.#ue=void 0,this.#Oe(),e?.();return}e.type===`ctrl-r`&&this.#ot()};this.#de=consumer,this.#H=consumer,this.#Pe()}#Oe(){this.#de!==void 0&&(this.#H===this.#de&&this.#Fe(),this.#de=void 0)}#ke(e){let t=e===void 0?void 0:stripTerminalControls(e);if(this.#ce!==void 0){this.#ce.status=t,t===void 0&&(this.#ce.preview=void 0),this.#ot();return}if(t===void 0){this.#j=!1,this.#M=``,this.#We(),this.#ot();return}this.#Me(),this.#j=!0,this.#M=t,this.#Ue(),this.#ot()}#Ae(e,t){let r=stripTerminalControls(e);if(r.trim().length===0)return;let i=this.#ce;if(i!==void 0){if(i.preview=void 0,t===`warning`||t===`error`)for(let e of i.outputBuffer)i.lines.push({text:e,tone:`info`,evidence:!0});i.outputBuffer=[],i.lines.push({text:r,tone:t}),this.#ot();return}this.#Me(),this.#Ge({kind:`flow`,title:t,body:r,live:!1}),this.#ot()}#je(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let r=this.#ce;if(r===void 0){this.#Ae(t,`info`);return}r.preview=t,r.outputBuffer.push(t),r.outputBuffer.length>40&&r.outputBuffer.shift(),this.#ot()}shutdown(){this.#Ne()}#Me(e){this.#N=e?.title??this.#N,this.#Z=e?.contextSize??this.#l,!this.#P&&(this.#P=!0,this.#n.reset(),this.#n.hideCursor(),this.#yt(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume()),this.#G=()=>this.#ot(),this.#t.on(`resize`,this.#G))}#Ne(){this.#Fe(),this.#Ve(),this.#We(),this.#B!==void 0&&(clearTimeout(this.#B),this.#B=void 0),this.#V=!1,this.#P&&=(this.#Dt(),this.#ot(),this.#n.clear(),this.#n.showCursor(),this.#bt(),this.#n.newline(),this.#e.isTTY&&(this.#e.setRawMode?.(!1),this.#e.pause()),this.#G&&=(this.#t.off(`resize`,this.#G),void 0),!1)}#Pe(){this.#e.off(`data`,this.#Ie),this.#e.on(`data`,this.#Ie)}#Fe(){this.#e.off(`data`,this.#Ie),this.#Re(),this.#U=``,this.#H=void 0}#Ie=e=>{this.#Re(),this.#U+=e.toString(`utf8`),this.#Le(),this.#U===`\x1B`&&(this.#W=setTimeout(()=>{this.#U===`\x1B`&&(this.#U=``,this.#H?.({type:`escape`}))},30),this.#W.unref?.())};#Le(){for(;this.#U.length>0;){let e=nextKey(this.#U);if(e.incomplete)return;this.#U=this.#U.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#H?.(e.key)}}#Re(){this.#W&&=(clearTimeout(this.#W),void 0)}#ze(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#ot();break;case`ctrl-c`:this.#F=!0,this.#K?.();break;default:break}}#Be(){this.#Ve(),this.#He(),this.#R=setInterval(()=>{this.#I=!this.#I,this.#ot()},500),this.#R.unref?.()}#Ve(){this.#R&&=(clearInterval(this.#R),void 0),this.#I=!0}#He(){this.#I=!0}#Ue(){this.#We(),this.#z=setInterval(()=>{this.#L+=1,this.#ot()},90),this.#z.unref?.()}#We(){this.#z&&=(clearInterval(this.#z),void 0)}#Ge(e){e.id!==this.#ae?.id&&this.#Dt(),this.#f.push(e),e.id&&this.#p.set(e.id,e)}#Ke(e){this.#Ge({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#ot()}#qe(e){if(e!=null){if(this.#se===e){this.#se=void 0;return}this.#Ge({kind:`user`,body:stripTerminalControls(e),live:!1})}}#Je(e,t,r){let i={kind:`error`,title:stripTerminalControls(e),body:stripTerminalControls(t),live:!1};r!==void 0&&(i.detail=stripTerminalControls(r)),this.#Ge(i),this.#ot()}#Ye(e,t){this.#v.has(e)||(this.#v.add(e),this.#Ge({id:subagentHeaderId(e),kind:`subagent`,title:stripTerminalControls(t),live:!1}))}#Xe(e){if(e.id&&this.#m.has(e.id))return;let t=e.id?this.#p.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#Ge(e)}#Ze(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#Qe(){for(let e of this.#f)e.status===`approval`||e.status===`running`||(e.live=!1)}#$e(e,t,r){switch(e.type){case`step-start`:this.#et(r.hasPendingToolResults?STATUS.toolResults:STATUS.processing),r.hasPendingToolResults=!1;break;case`step-finish`:this.#at(e.usage),this.#ot();break;case`assistant-delta`:{this.#et(STATUS.streaming);let t=(r.text.get(e.id)??``)+stripTerminalControls(e.delta);r.text.set(e.id,t),this.#tt(e.id,t,!0);break}case`assistant-complete`:{let t=r.text.get(e.id)??``,i=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;r.text.set(e.id,i),this.#tt(e.id,i,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#et(STATUS.streaming);let i=(r.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);r.reasoning.set(e.id,i),this.#nt(e.id,i,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let n=r.reasoning.get(e.id)??``;this.#nt(e.id,n,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#et(STATUS.executingTools),this.#rt({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,r);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;this.#rt({...n,status:`approval`},t,r);break}case`tool-result`:{if(t.tools===`hidden`)break;let n=this.#it(e.toolCallId,r);if(n===void 0)break;r.hasPendingToolResults=!0,this.#et(STATUS.toolResults),this.#rt({...n,output:e.output,status:`done`},t,r);break}case`tool-error`:{if(t.tools===`hidden`)break;let n=this.#it(e.toolCallId,r);if(n===void 0)break;r.hasPendingToolResults=!0,this.#et(STATUS.toolResults),this.#rt({...n,errorText:e.errorText,status:`error`},t,r);break}case`error`:this.#Je(`Error`,e.errorText,e.detail);break;case`finish`:this.#at(e.usage),this.#ot();break}}#et(e){let t=this.#w>0?STATUS.connectionAuth:e;this.#M!==t&&(this.#M=t,this.#ot())}#tt(e,t,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Xe({id:e,kind:`assistant`,body:i,live:r}),this.#ot())}#nt(e,t,r,i){let a=stripTerminalControls(t).trim();a.length!==0&&(this.#Xe({id:e,kind:`reasoning`,body:a,collapsed:collapseReasoning(i.reasoning,r),live:r}),this.#ot())}#rt(e,t,n){if(n.tools.set(e.toolCallId,e),this.#g.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#_.set(e.toolCallId,r),this.#Xe(renderNativeToolBlock(e,r,t.tools===`full`)),this.#ot()}#it(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#_.get(e)??toolSectionId(e),i=this.#p.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`}}#at(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#Y=(t??0)+(n??0)),this.#X=t??this.#X,this.#Q=n??this.#Q,this.#Q!=null&&this.#ee!==void 0){let e=(Date.now()-this.#ee)/1e3;e>0&&(this.#$=this.#Q/e)}}#ot(){if(this.#P){if(this.#q){this.#J=!0;return}this.#q=!0;try{do this.#J=!1,this.#st();while(this.#J)}finally{this.#q=!1}}}#st(){if(!this.#P)return;let e=this.#_t(),t=this.#mt(e),n=Math.max(1,this.#vt()-t.length),r=[],i=this.#C;for(;this.#f.length>0&&this.#f[0].live===!1;){let t=this.#f.shift();if(this.#h.push(t),t.id&&(this.#m.add(t.id),this.#p.delete(t.id)),this.#kt(t))continue;let n=this.#ft(t,e,i);i=previousBlockOf(t),this.#C=i,r.push(...n),this.#S.push(...n)}let a=[];for(let t of this.#f){if(this.#kt(t))continue;let n=this.#ft(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)}#ct(){if(!this.#P)return;let e=this.#_t(),t=this.#mt(e),n=Math.max(1,this.#vt()-t.length),r=this.#C,i=[];for(let t of this.#f){if(this.#kt(t))continue;let n=this.#ft(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.#dt(),...this.#S],a)}logDisplayMode(){return this.#d}setLogDisplayMode(e){e!==this.#d&&(this.#d=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#ut(),this.#P&&this.#ct())}flushDelayedDevBuildErrors(){let e=this.#ie;e!==void 0&&(this.#ie=void 0,this.#Ge({kind:`log`,title:`stderr`,body:e,live:!1}),this.#ot())}#lt(){this.#V=!0,this.#B!==void 0&&clearTimeout(this.#B),this.#B=setTimeout(()=>{this.#V=!1,this.#B=void 0,this.#ot()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#d)),this.#ot()}#ut(){let e=this.#_t();this.#S.length=0;let t;for(let n of this.#h){if(this.#kt(n))continue;let r=this.#ft(n,e,t);t=previousBlockOf(n),this.#S.push(...r)}this.#C=t}#dt(){let e=this.#y;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#_t()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#ft(e,t,n){let r={spinner:this.#pt()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#pt(){return this.#r.spinner[this.#L%this.#r.spinner.length]??``}#mt(e){let t=this.#r.colors,n=[``],r=this.#ce;if(r!==void 0){let t=this.#pt(),i;if(r.question!==void 0){let n=r.question(e);i={kind:`question`,rows:n},r.status!==void 0&&(i={kind:`question`,rows:n,status:{text:r.status,frame:t}})}else r.status===void 0?i=r.preview===void 0?{kind:`idle`,frame:t}:{kind:`preview`,text:r.preview,frame:t}:(i={kind:`status`,status:{text:r.status,frame:t}},r.preview!==void 0&&(i={kind:`status`,status:{text:r.status,frame:t},preview:r.preview}));let a={title:r.title,lines:r.hideLinesWhileQuestion===!0?[]:r.lines,content:i};return n.push(...renderFlowPanel(a,this.#r,e)),n}if(this.#le!==void 0&&n.push(...renderAttentionRows(this.#le,e,this.#r),``),this.#k){let r=this.#A===void 0?void 0:inlineCommandHint(this.#A);r===void 0&&this.#A!==void 0&&isTypeaheadOpen(this.#A)&&n.push(...renderCommandSuggestions(this.#A,this.#r,e));let i=Math.max(4,e-3),{before:a,after:o}=visibleLine({text:this.#E,cursor:this.#D},i,this.#r.glyph.ellipsis),s=isPromptControlCommand(this.#E),style=e=>s&&e.length>0?t.blue(e):e,l=this.#I?t.cyan(this.#r.glyph.caret):` `,u=r?t.dim(` ${r}`):``,d=`${style(a)}${l}${style(o)}${u}`;return n.push(...promptInputRows(d,e,this.#r,!0)),this.#ht(n,e),n}let i=this.#j?t.yellow(this.#pt()):t.dim(this.#r.glyph.dot),a=this.#M.length>0?this.#M:`Ready`,o=this.#j?t.dim(a):a,s=this.#gt(),l=s?`${i} ${o} ${t.dim(this.#r.glyph.dot)} ${s}`:`${i} ${o}`;return n.push(clip(l,e)),this.#ht(n,e),n}#ht(e,t){let n={theme:this.#r,width:t};this.#V&&(n.logLevel=this.#d);let r=this.#y?.info?.agent.model.id;r!==void 0&&(n.model=r);let i=this.#y?.info?.agent.model.endpoint;i!==void 0&&(n.endpoint=i);let a=this.#X??0,o=this.#Q??0;if(a>0||o>0){let e={inputTokens:a,outputTokens:o};this.#Z!==void 0&&(e.contextSize=this.#Z),n.tokens=formatTokenFlow(e,this.#r.glyph)}this.#T!==void 0&&(n.vercel=this.#T);let s=buildStatusLine(n);s!==void 0&&e.push(s)}#gt(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#Y,outputTokens:this.#Q,tokensPerSecond:this.#$},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#_t(){return Math.max(20,this.#t.columns||80)}#vt(){return Math.max(8,this.#t.rows||24)}#yt(){if(this.#te!==void 0||!this.#u)return;this.#ne=``,this.#re=``;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.#xt(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#te=()=>{e(),t()}}#bt(){let e=this.#te;e!==void 0&&(this.#te=void 0,e(),this.#ne.length>0&&(this.#Ot(`stdout`)&&process.stdout.write(`${this.#ne}\n`),this.#ne=``),this.#re.length>0&&(this.#Ot(`stderr`)&&process.stderr.write(`${this.#re}\n`),this.#re=``))}#xt(e,n){let r=(e===`stdout`?this.#ne:this.#re)+n,i=r.lastIndexOf(`
2
+ `);if(this.#b){t!==this.#x&&(this.#x=t,this.#Ge({kind:`agent-header`,body:t,live:!1})),this.#ot();return}this.#b=!0,this.#x=t,this.#n.flush(this.#dt(),[])}async readPrompt(e){this.#Me(e),this.#k=!0,this.#j=!1,this.#M=``;let t=lineOf(stripPromptControlCharacters(e?.initialDraft??``));return this.#O.begin(t.text),this.#fe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,t.text),this.#Be(),this.#ot(),await new Promise((e,r)=>{let apply=e=>{t=e,this.#He(),this.#fe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,e.text,this.#A),this.#ot()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#A=void 0,this.#Ve(),this.#Ne(),r(interruptedError())},suggestions=()=>this.#A!==void 0&&isTypeaheadOpen(this.#A)?this.#A:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#H=r=>{let i=applyLineEditorKey(t,r);if(i!==void 0){apply(i);return}switch(r.type){case`up`:{let e=suggestions();e===void 0?recall(this.#O.previous(t.text)):(this.#A=moveTypeaheadSelection(e,-1),this.#ot());break}case`down`:{let e=suggestions();e===void 0?recall(this.#O.next()):(this.#A=moveTypeaheadSelection(e,1),this.#ot());break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#A=dismissTypeahead(e),this.#ot());break}case`enter`:{let r=highlighted(),i=r!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(r).trimEnd():t.text;this.#A=void 0,this.#O.add(i),this.#k=!1,this.#Ve(),this.#M=STATUS.processing,isPromptControlCommand(i)?this.#Ge({kind:`command`,body:stripTerminalControls(i.trim()),live:!1}):(this.#Ke(i),this.#se=i),this.#fe(EMPTY_LINE),this.#ot(),this.#Fe(),e(i);break}case`ctrl-d`:t.text.length===0?interrupt():apply(deleteForward(t));break;case`ctrl-l`:this.#lt();break;case`ctrl-r`:this.#ot();break;case`ctrl-c`:interrupt();break;default:break}},this.#Pe()})}#fe(e){this.#E=e.text,this.#D=e.cursor}async renderStream(e,t){this.#Me(t),this.#m.clear(),this.#k=!1,this.#j=!0,this.#M=STATUS.processing,this.#qe(t?.submittedPrompt),this.#F=!1,this.#Y=void 0,this.#X=void 0,this.#Q=void 0,this.#$=void 0,this.#ee=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#Ue(),this.#ot();let r=new Promise(e=>{this.#K=e});this.#H=e=>this.#ze(e),this.#Pe();let i={text:new Map,reasoning:new Map,tools:new Map,hasPendingToolResults:!1};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#F)break;this.#$e(t,n,i)}}catch(e){this.#Je(`Error`,toErrorMessage(e))}finally{this.#K=void 0,this.#F&&e.abort?.(),this.#Fe(),this.#We(),this.#j=!1,this.#M=completedTurnStatus(this.#F,t?.continueSession===!0),this.#Qe(),this.#ot(),t?.continueSession||this.#Ne()}}async readToolApproval(e,t){return this.#Me(t),this.#k=!1,this.#j=!1,this.#M=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#F=!1,this.#ot(),await new Promise((t,n)=>{this.#H=r=>{switch(r.type){case`character`:{let n=r.value.toLowerCase();n===`y`?(this.#M=STATUS.processing,this.#Fe(),this.#ot(),t({approved:!0})):n===`n`&&(this.#M=STATUS.processing,this.#pe(e.toolCallId),this.#Fe(),this.#ot(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#ot();break;case`ctrl-c`:this.#F=!0,this.#Ne(),n(interruptedError());break;default:break}},this.#Pe()})}async readInputQuestion(e,t){this.#Me(t),this.#k=!1,this.#j=!1,this.#F=!1;let r=e.options??[],i=r.length>0,a=(e.allowFreeform===!0||!i)&&i,o=r.length+ +!!a,s=questionSectionId(e.requestId),c=i?`select`:`text`,l=0,u=``,isOnFreeformRow=()=>a&&l===r.length,renderSection=()=>{this.#Xe({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,l,this.#r),preformatted:!0,live:!0})},repaintStatus=()=>{if(c===`select`){let e=isOnFreeformRow()?`type`:`select`;this.#M=`↑/↓ move · enter ${e} · Ctrl+C quit`,this.#k=!1}else this.#k=!0,this.#fe(lineOf(u)),this.#M=``;this.#ot()};renderSection(),c===`text`&&this.#Be(),repaintStatus();let finalize=t=>{this.#Xe({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:` ${this.#r.colors.green(this.#r.glyph.success)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#k=!1,this.#M=STATUS.processing,this.#Ve(),this.#Fe(),this.#ot();let r={};return t.optionId!==void 0&&(r.optionId=t.optionId),t.text!==void 0&&(r.text=t.text),r};return await new Promise((t,n)=>{this.#H=a=>{if(a.type===`ctrl-c`){this.#F=!0,this.#Ve(),this.#Ne(),n(interruptedError());return}if(a.type===`ctrl-r`){this.#ot();return}if(c===`select`){switch(a.type){case`up`:o>0&&(l=(l-1+o)%o,renderSection(),repaintStatus());break;case`down`:o>0&&(l=(l+1)%o,renderSection(),repaintStatus());break;case`enter`:{if(isOnFreeformRow()){c=`text`,u=``,this.#Be(),repaintStatus();break}let e=r[l];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}switch(a.type){case`character`:u+=a.value,this.#He(),repaintStatus();break;case`backspace`:u=u.slice(0,-1),this.#He(),repaintStatus();break;case`enter`:{let n=resolveQuestionText(u,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(i){if(u.length>0){u=``,this.#He(),repaintStatus();break}c=`select`,u=``,this.#k=!1,this.#Ve(),repaintStatus();break}u=``,this.#He(),repaintStatus();break;default:break}},this.#Pe()})}upsertSubagentStep(e){if(this.#o===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),r=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&r.length===0)){if(this.#Ye(e.callId,e.subagentName),this.#o===`collapsed`){this.#ot();return}this.#Xe({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:r,live:!e.finalized}),this.#ot()}}upsertSubagentTool(e){if(this.#o===`hidden`)return;if(this.#Ye(e.callId,e.subagentName),this.#o===`collapsed`){this.#ot();return}let t=subagentToolStatus(e.status),r={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&&(r.result=stripTerminalControls(e.errorText)):(r.result=summarizeToolResult(e.output),r.toolOutput=e.output),this.#Xe(r),this.#ot()}markChildToolCallId(e){this.#g.add(e);let t=this.#_.get(e);t!==void 0&&(this.#Ze(t),this.#_.delete(e),this.#ot())}#pe(e){let t=this.#p.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#s===`hidden`)return;let t=e.state===`authorized`||e.state===`declined`||e.state===`failed`||e.state===`timed-out`;this.#Xe({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e),preformatted:!0,live:!t}),this.#ot()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#w)return;let n=this.#w>0;this.#w=t,t>0?(this.#M=STATUS.connectionAuth,this.#ot()):n&&(this.#M=STATUS.processing,this.#ot())}setVercelStatus(e){this.#T=e,this.#ot()}reset(){this.#f=[],this.#p.clear(),this.#m.clear(),this.#C=void 0,this.#S.length=0,this.#h.length=0,this.#b=!1,this.#x=void 0,this.#g.clear(),this.#_.clear(),this.#v.clear(),this.#se=void 0,this.#ae=void 0,this.#w=0,this.#Y=void 0,this.#X=void 0,this.#Q=void 0,this.#$=void 0,this.#ee=void 0,this.#P&&(this.#n.clearAll(),this.#ot())}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Me(),this.#Ge({kind:`notice`,body:t,live:!1}),this.#ot())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#Me(),this.#Ge({kind:`sandbox`,body:t,live:!1}),this.#ot())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#me();return}this.#Me(),this.#le=t,this.#ot()}clearSetupWarning(){this.#me()}#me(){this.#le!==void 0&&(this.#le=void 0,this.#ot())}renderCommandResult(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Me(),this.#Ge({kind:`result`,body:t,live:!1}),this.#ot())}#he(e){this.#Me(),this.#k=!1,this.#j=!1,this.#M=``,this.#ce={title:stripTerminalControls(e),lines:[],outputBuffer:[]},this.#Ue(),this.#ot()}#ge(e){this.#ue=void 0,this.#Oe();let t=this.#ce;if(t!==void 0){if(this.#ce=void 0,this.#We(),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.#Ge({kind:`flow`,title:`info`,body:e.join(`
3
+ `),live:!1}),this.#Ge({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#ot()}}async#_e(e){let t=this.#Se(),n=isMultiSelectRequest(e),r={options:e.options,submitRow:n};`initialValue`in e&&e.initialValue!==void 0&&(r.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(r.initialValues=e.initialValues);let i=initialSelectState(r),a,o=e.notices;if(e.kind===`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}));o=[...e.notices??[],...r],t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,select:i};return o!==void 0&&o.length>0&&(t.notices=o),a!==void 0&&(t.error=a),t};return t.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#ot(),await this.#Te((t,r)=>{let o={key:t,options:e.options,select:i},s=reduceSetupSelectInput(n?{...o,kind:e.kind,required:e.required}:{...o,kind:e.kind});switch(s.kind){case`cancel`:r(void 0);return;case`repaint`:this.#ot();return;case`update`:i=s.select,a=void 0,this.#ot();return;case`submit`:r(s.values);return;case`error`:a=s.message,this.#ot();return;case`ignore`:return}}).promise}#ve(e){this.#Me();let t=this.#Ce();t.status=e.status;let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#r,t),this.#ot();let r=this.#Te((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.#ot();return;case`repaint`:this.#ot();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#ye(e){let t=this.#Se(),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:`editable`,message:e.message,options:e.options,select:r,edit:{optionValue:e.editable.value,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint,caretVisible:this.#I}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#r,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?(i.text.length===0&&(i=lineOf(e.editable.defaultValue)),this.#Be()):(i=lineOf(``),this.#Ve())};return syncEditableRow(),this.#ot(),await this.#Te((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#He(),this.#ot()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#ot()},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.#ot();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.#ot();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Ve()).promise}async#be(e){let t=this.#Se(),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.#I)},this.#Be(),this.#ot(),await this.#Te((t,i)=>{let apply=e=>{n=e,r=void 0,this.#He(),this.#ot()},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.#ot();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#ot();return}i(t);return}default:return}},()=>this.#Ve()).promise}async#xe(e){let t=this.#Se();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#ot(),await this.#Te((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#ot();return;default:return}}).promise}#Se(){return this.#Me(),this.#k=!1,this.#j=!1,this.#M=``,this.#Ce()}#Ce(){return this.#ce===void 0&&(this.#ce={title:``,lines:[],outputBuffer:[]}),this.#ce}#we(){this.#ce!==void 0&&(this.#ce.question=void 0,this.#ce.hideLinesWhileQuestion=!1),this.#H=void 0,this.#Fe(),this.#De(),this.#ot()}#Te(e,t){let n=!1,r,i=new Promise(e=>{r=e}),settle=e=>{n||(n=!0,t?.(),this.#we(),r(e))};return this.#H=t=>e(t,settle),this.#Pe(),{promise:i,settle}}#Ee(){let e,t=new Promise(t=>{e=t});return this.#ue=e,this.#De(),{promise:t,dispose:()=>{this.#ue===e&&(this.#ue=void 0,this.#Oe())}}}#De(){if(this.#ue===void 0)return;let consumer=e=>{if(e.type===`ctrl-c`||e.type===`escape`){let e=this.#ue;this.#ue=void 0,this.#Oe(),e?.();return}e.type===`ctrl-r`&&this.#ot()};this.#de=consumer,this.#H=consumer,this.#Pe()}#Oe(){this.#de!==void 0&&(this.#H===this.#de&&this.#Fe(),this.#de=void 0)}#ke(e){let t=e===void 0?void 0:stripTerminalControls(e);if(this.#ce!==void 0){this.#ce.status=t,t===void 0&&(this.#ce.preview=void 0),this.#ot();return}if(t===void 0){this.#j=!1,this.#M=``,this.#We(),this.#ot();return}this.#Me(),this.#j=!0,this.#M=t,this.#Ue(),this.#ot()}#Ae(e,t){let r=stripTerminalControls(e);if(r.trim().length===0)return;let i=this.#ce;if(i!==void 0){if(i.preview=void 0,t===`warning`||t===`error`)for(let e of i.outputBuffer)i.lines.push({text:e,tone:`info`,evidence:!0});i.outputBuffer=[],i.lines.push({text:r,tone:t}),this.#ot();return}this.#Me(),this.#Ge({kind:`flow`,title:t,body:r,live:!1}),this.#ot()}#je(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let r=this.#ce;if(r===void 0){this.#Ae(t,`info`);return}r.preview=t,r.outputBuffer.push(t),r.outputBuffer.length>40&&r.outputBuffer.shift(),this.#ot()}shutdown(){this.#Ne()}#Me(e){this.#N=e?.title??this.#N,this.#Z=e?.contextSize??this.#l,!this.#P&&(this.#P=!0,this.#n.reset(),this.#n.hideCursor(),this.#yt(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume()),this.#G=()=>this.#ot(),this.#t.on(`resize`,this.#G))}#Ne(){this.#Fe(),this.#Ve(),this.#We(),this.#B!==void 0&&(clearTimeout(this.#B),this.#B=void 0),this.#V=!1,this.#P&&=(this.#Dt(),this.#ot(),this.#n.clear(),this.#n.showCursor(),this.#bt(),this.#n.newline(),this.#e.isTTY&&(this.#e.setRawMode?.(!1),this.#e.pause()),this.#G&&=(this.#t.off(`resize`,this.#G),void 0),!1)}#Pe(){this.#e.off(`data`,this.#Ie),this.#e.on(`data`,this.#Ie)}#Fe(){this.#e.off(`data`,this.#Ie),this.#Re(),this.#U=``,this.#H=void 0}#Ie=e=>{this.#Re(),this.#U+=e.toString(`utf8`),this.#Le(),this.#U===`\x1B`&&(this.#W=setTimeout(()=>{this.#U===`\x1B`&&(this.#U=``,this.#H?.({type:`escape`}))},30),this.#W.unref?.())};#Le(){for(;this.#U.length>0;){let e=nextKey(this.#U);if(e.incomplete)return;this.#U=this.#U.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#H?.(e.key)}}#Re(){this.#W&&=(clearTimeout(this.#W),void 0)}#ze(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#ot();break;case`ctrl-c`:this.#F||(this.#F=!0,this.#M=`Interrupted`,this.#K?.(),this.#ot());break;default:break}}#Be(){this.#Ve(),this.#He(),this.#R=setInterval(()=>{this.#I=!this.#I,this.#ot()},500),this.#R.unref?.()}#Ve(){this.#R&&=(clearInterval(this.#R),void 0),this.#I=!0}#He(){this.#I=!0}#Ue(){this.#We(),this.#z=setInterval(()=>{this.#L+=1,this.#ot()},90),this.#z.unref?.()}#We(){this.#z&&=(clearInterval(this.#z),void 0)}#Ge(e){e.id!==this.#ae?.id&&this.#Dt(),this.#f.push(e),e.id&&this.#p.set(e.id,e)}#Ke(e){this.#Ge({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#ot()}#qe(e){if(e!=null){if(this.#se===e){this.#se=void 0;return}this.#Ge({kind:`user`,body:stripTerminalControls(e),live:!1})}}#Je(e,t,r){let i={kind:`error`,title:stripTerminalControls(e),body:stripTerminalControls(t),live:!1};r!==void 0&&(i.detail=stripTerminalControls(r)),this.#Ge(i),this.#ot()}#Ye(e,t){this.#v.has(e)||(this.#v.add(e),this.#Ge({id:subagentHeaderId(e),kind:`subagent`,title:stripTerminalControls(t),live:!1}))}#Xe(e){if(e.id&&this.#m.has(e.id))return;let t=e.id?this.#p.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#Ge(e)}#Ze(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#Qe(){for(let e of this.#f)e.status===`approval`||e.status===`running`||(e.live=!1)}#$e(e,t,r){switch(e.type){case`step-start`:this.#et(r.hasPendingToolResults?STATUS.toolResults:STATUS.processing),r.hasPendingToolResults=!1;break;case`step-finish`:this.#at(e.usage),this.#ot();break;case`assistant-delta`:{this.#et(STATUS.streaming);let t=(r.text.get(e.id)??``)+stripTerminalControls(e.delta);r.text.set(e.id,t),this.#tt(e.id,t,!0);break}case`assistant-complete`:{let t=r.text.get(e.id)??``,i=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;r.text.set(e.id,i),this.#tt(e.id,i,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#et(STATUS.streaming);let i=(r.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);r.reasoning.set(e.id,i),this.#nt(e.id,i,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let n=r.reasoning.get(e.id)??``;this.#nt(e.id,n,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#et(STATUS.executingTools),this.#rt({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,r);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;this.#rt({...n,status:`approval`},t,r);break}case`tool-result`:{if(t.tools===`hidden`)break;let n=this.#it(e.toolCallId,r);if(n===void 0)break;r.hasPendingToolResults=!0,this.#et(STATUS.toolResults),this.#rt({...n,output:e.output,status:`done`},t,r);break}case`tool-error`:{if(t.tools===`hidden`)break;let n=this.#it(e.toolCallId,r);if(n===void 0)break;r.hasPendingToolResults=!0,this.#et(STATUS.toolResults),this.#rt({...n,errorText:e.errorText,status:`error`},t,r);break}case`error`:this.#Je(`Error`,e.errorText,e.detail);break;case`finish`:this.#at(e.usage),this.#ot();break}}#et(e){let t=this.#w>0?STATUS.connectionAuth:e;this.#M!==t&&(this.#M=t,this.#ot())}#tt(e,t,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Xe({id:e,kind:`assistant`,body:i,live:r}),this.#ot())}#nt(e,t,r,i){let a=stripTerminalControls(t).trim();a.length!==0&&(this.#Xe({id:e,kind:`reasoning`,body:a,collapsed:collapseReasoning(i.reasoning,r),live:r}),this.#ot())}#rt(e,t,n){if(n.tools.set(e.toolCallId,e),this.#g.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#_.set(e.toolCallId,r),this.#Xe(renderNativeToolBlock(e,r,t.tools===`full`)),this.#ot()}#it(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#_.get(e)??toolSectionId(e),i=this.#p.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`}}#at(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#Y=(t??0)+(n??0)),this.#X=t??this.#X,this.#Q=n??this.#Q,this.#Q!=null&&this.#ee!==void 0){let e=(Date.now()-this.#ee)/1e3;e>0&&(this.#$=this.#Q/e)}}#ot(){if(this.#P){if(this.#q){this.#J=!0;return}this.#q=!0;try{do this.#J=!1,this.#st();while(this.#J)}finally{this.#q=!1}}}#st(){if(!this.#P)return;let e=this.#_t(),t=this.#mt(e),n=Math.max(1,this.#vt()-t.length),r=[],i=this.#C;for(;this.#f.length>0&&this.#f[0].live===!1;){let t=this.#f.shift();if(this.#h.push(t),t.id&&(this.#m.add(t.id),this.#p.delete(t.id)),this.#kt(t))continue;let n=this.#ft(t,e,i);i=previousBlockOf(t),this.#C=i,r.push(...n),this.#S.push(...n)}let a=[];for(let t of this.#f){if(this.#kt(t))continue;let n=this.#ft(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)}#ct(){if(!this.#P)return;let e=this.#_t(),t=this.#mt(e),n=Math.max(1,this.#vt()-t.length),r=this.#C,i=[];for(let t of this.#f){if(this.#kt(t))continue;let n=this.#ft(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.#dt(),...this.#S],a)}logDisplayMode(){return this.#d}setLogDisplayMode(e){e!==this.#d&&(this.#d=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#ut(),this.#P&&this.#ct())}flushDelayedDevBuildErrors(){let e=this.#ie;e!==void 0&&(this.#ie=void 0,this.#Ge({kind:`log`,title:`stderr`,body:e,live:!1}),this.#ot())}#lt(){this.#V=!0,this.#B!==void 0&&clearTimeout(this.#B),this.#B=setTimeout(()=>{this.#V=!1,this.#B=void 0,this.#ot()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#d)),this.#ot()}#ut(){let e=this.#_t();this.#S.length=0;let t;for(let n of this.#h){if(this.#kt(n))continue;let r=this.#ft(n,e,t);t=previousBlockOf(n),this.#S.push(...r)}this.#C=t}#dt(){let e=this.#y;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#_t()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#ft(e,t,n){let r={spinner:this.#pt()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#pt(){return this.#r.spinner[this.#L%this.#r.spinner.length]??``}#mt(e){let t=this.#r.colors,n=[``],r=this.#ce;if(r!==void 0){let t=this.#pt(),i;if(r.question!==void 0){let n=r.question(e);i={kind:`question`,rows:n},r.status!==void 0&&(i={kind:`question`,rows:n,status:{text:r.status,frame:t}})}else r.status===void 0?i=r.preview===void 0?{kind:`idle`,frame:t}:{kind:`preview`,text:r.preview,frame:t}:(i={kind:`status`,status:{text:r.status,frame:t}},r.preview!==void 0&&(i={kind:`status`,status:{text:r.status,frame:t},preview:r.preview}));let a={title:r.title,lines:r.hideLinesWhileQuestion===!0?[]:r.lines,content:i};return n.push(...renderFlowPanel(a,this.#r,e)),n}if(this.#le!==void 0&&n.push(...renderAttentionRows(this.#le,e,this.#r),``),this.#k){let r=this.#A===void 0?void 0:inlineCommandHint(this.#A);r===void 0&&this.#A!==void 0&&isTypeaheadOpen(this.#A)&&n.push(...renderCommandSuggestions(this.#A,this.#r,e));let i=Math.max(4,e-3),{before:a,after:o}=visibleLine({text:this.#E,cursor:this.#D},i,this.#r.glyph.ellipsis),s=isPromptControlCommand(this.#E),style=e=>s&&e.length>0?t.blue(e):e,l=this.#I?t.cyan(this.#r.glyph.caret):` `,u=r?t.dim(` ${r}`):``,d=`${style(a)}${l}${style(o)}${u}`;return n.push(...promptInputRows(d,e,this.#r,!0)),this.#ht(n,e),n}let i=this.#j?t.yellow(this.#pt()):t.dim(this.#r.glyph.dot),a=this.#M.length>0?this.#M:`Ready`,o=this.#j?t.dim(a):a,s=this.#gt(),l=s?`${i} ${o} ${t.dim(this.#r.glyph.dot)} ${s}`:`${i} ${o}`;return n.push(clip(l,e)),this.#ht(n,e),n}#ht(e,t){let n={theme:this.#r,width:t};this.#V&&(n.logLevel=this.#d);let r=this.#y?.info?.agent.model.id;r!==void 0&&(n.model=r);let i=this.#y?.info?.agent.model.endpoint;i!==void 0&&(n.endpoint=i);let a=this.#X??0,o=this.#Q??0;if(a>0||o>0){let e={inputTokens:a,outputTokens:o};this.#Z!==void 0&&(e.contextSize=this.#Z),n.tokens=formatTokenFlow(e,this.#r.glyph)}this.#T!==void 0&&(n.vercel=this.#T);let s=buildStatusLine(n);s!==void 0&&e.push(s)}#gt(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#Y,outputTokens:this.#Q,tokensPerSecond:this.#$},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#_t(){return Math.max(20,this.#t.columns||80)}#vt(){return Math.max(8,this.#t.rows||24)}#yt(){if(this.#te!==void 0||!this.#u)return;this.#ne=``,this.#re=``;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.#xt(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#te=()=>{e(),t()}}#bt(){let e=this.#te;e!==void 0&&(this.#te=void 0,e(),this.#ne.length>0&&(this.#Ot(`stdout`)&&process.stdout.write(`${this.#ne}\n`),this.#ne=``),this.#re.length>0&&(this.#Ot(`stderr`)&&process.stderr.write(`${this.#re}\n`),this.#re=``))}#xt(e,n){let r=(e===`stdout`?this.#ne:this.#re)+n,i=r.lastIndexOf(`
4
4
  `),a=i===-1?r:r.slice(i+1);if(e===`stdout`?this.#ne=a:this.#re=a,i===-1)return;let o=stripAnsi(r.slice(0,i)).replace(/\s+$/u,``);o.trim().length!==0&&(e===`stdout`?this.#St(o):this.#Ct(o),this.#ot())}#St(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
5
5
  `);t=[],e.trim().length!==0&&this.#Ge({kind:`log`,title:`stdout`,body:e,live:!1})};for(let n of e.split(`
6
6
  `)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#Ge({kind:`sandbox`,body:e,live:!1});continue}let r=parseDevRebuildLogLine(n.trimEnd());if(r===void 0){t.push(n);continue}flushPending(),this.#Tt(r,n.trimEnd())}flushPending()}#Ct(e){let t=e.split(`
@@ -82,7 +82,7 @@ export declare function resolveDevUiMode(input: {
82
82
  /**
83
83
  * Resolves the terminal UI's header title: an explicit `--name`, else the
84
84
  * remote server's host (for `--url`), else the humanized app-folder name
85
- * (e.g. `apps/fixtures/weather-fixture` → "Weather Fixture"). Returns `undefined` when
85
+ * (e.g. `apps/fixtures/weather-agent` → "Weather Agent"). Returns `undefined` when
86
86
  * nothing meaningful can be derived, so the runner falls back to its own
87
87
  * default.
88
88
  */
@@ -1,3 +1,3 @@
1
- import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{basename}from"node:path";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{eveCliBanner}from"#cli/banner.js";import{Command,CommanderError,InvalidArgumentError}from"#compiled/commander/index.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{LOG_DISPLAY_MODES,parseLogDisplayMode}from"#cli/dev/tui/log-display-mode.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";async function loadBuildHost(){return(await import(`#internal/nitro/host.js`)).buildApplication}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`)).startDevelopmentServer}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 resolveDevUiMode(e){return e.options.ui===!1||!e.interactive?`headless`:`tui`}function resolveTuiTitle(e){if(e.name!==void 0&&e.name.length>0)return e.name;if(e.remoteServerUrl!==void 0)try{return new URL(e.remoteServerUrl).host}catch{return}let n=humanizeProjectName(basename(e.appRoot));return n.length>0?n:void 0}function humanizeProjectName(e){return e.replace(/[-_.]+/gu,` `).trim().split(/\s+/u).filter(e=>e.length>0).map(e=>e[0].toUpperCase()+e.slice(1)).join(` `)}function resolveTuiDisplayOptions(e){let t={logs:e.logs??`stderr`,reasoning:e.reasoning??`full`,tools:e.tools??`auto-collapsed`};return e.subagents!==void 0&&(t.subagents=e.subagents),e.connectionAuth!==void 0&&(t.connectionAuth=e.connectionAuth),e.assistantResponseStats!==void 0&&(t.assistantResponseStats=e.assistantResponseStats),e.contextSize!==void 0&&(t.contextSize=e.contextSize),t}function hasInteractiveTerminal(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function rewriteDevelopmentUrlShorthand(e){let t=e[1];return e[0]!==`dev`||e.length!==2||t===void 0||t.startsWith(`-`)?[...e]:[`dev`,`--url`,t]}function resolveRemoteDevelopmentServerUrl(e){if(e.url){if(e.host!==void 0)throw new InvalidArgumentError(`The --host option cannot be used with --url.`);if(e.port!==void 0)throw new InvalidArgumentError(`The --port option cannot be used with --url.`);if(e.ui===!1)throw new InvalidArgumentError(`The --no-ui option cannot be used with --url.`);return e.url}}function createCliProgram(t,o){let u=resolveApplicationRoot(),d=resolveInstalledPackageInfo().version,f=new Command,p=createCliTheme();f.name(`eve`).description(`Build and run an Eve application.`).version(d).showHelpAfterError().exitOverride().hook(`preAction`,(e,n)=>{shouldPrintCliBootBanner(n)&&t.log(eveCliBanner())}).configureOutput({writeErr:e=>{t.error(e.trimEnd())},writeOut:e=>{t.log(e.trimEnd())}});let m=f.command(`channels`).description(`Manage user-authored channels in the current project.`);return m.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(e,n)=>{let{runChannelsAddCommand:r}=await import(`#cli/commands/channels.js`);await r(t,u,{kind:e,options:n})}),m.command(`list`).description(`List user-authored channels in the current project.`).option(`--json`,`Output as JSON`).action(async e=>{let{runChannelsListCommand:n}=await import(`#cli/commands/channels.js`);await n(t,u,e)}),f.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)`).action(async(e,n)=>{let{runInitCommand:r}=await import(`#cli/commands/init.js`);await r(t,u,e,n)}),registerProjectCommands({program:f,logger:t,appRoot:u}),f.command(`build`).description(`Build the current Eve application.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:e}=await import(`#cli/dev/environment.js`);e(u);let n=await(o.buildHost??await loadBuildHost())(u);t.log(renderCliTaggedLine(p,{message:`built output at ${n}`,tag:`build`,tone:`success`}))}),f.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 e=>{let{loadDevelopmentEnvironmentFiles:n}=await import(`#cli/dev/environment.js`);n(u);let i=await(o.startProductionHost??await loadStartProductionHost())(u,{host:e.host,port:e.port});t.log(renderCliTaggedLine(p,{message:`server listening at ${i.url}`,tag:`start`,tone:`success`})),await waitForProductionServer(i)}),f.command(`dev`).description(`Start the Eve development server or connect to an existing URL.`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).option(`-u, --url <url>`,`Connect to an existing server URL`,parseDevelopmentServerUrl).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 after launching the UI`).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`,`
1
+ import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{basename}from"node:path";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{eveCliBanner}from"#cli/banner.js";import{Command,CommanderError,InvalidArgumentError}from"#compiled/commander/index.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{LOG_DISPLAY_MODES,parseLogDisplayMode}from"#cli/dev/tui/log-display-mode.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";async function loadBuildHost(){return(await import(`#internal/nitro/host.js`)).buildApplication}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`)).startDevelopmentServer}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 resolveDevUiMode(e){return e.options.ui===!1||!e.interactive?`headless`:`tui`}function resolveTuiTitle(e){if(e.name!==void 0&&e.name.length>0)return e.name;if(e.remoteServerUrl!==void 0)try{return new URL(e.remoteServerUrl).host}catch{return}let n=humanizeProjectName(basename(e.appRoot));return n.length>0?n:void 0}function humanizeProjectName(e){return e.replace(/[-_.]+/gu,` `).trim().split(/\s+/u).filter(e=>e.length>0).map(e=>e[0].toUpperCase()+e.slice(1)).join(` `)}function resolveTuiDisplayOptions(e){let t={logs:e.logs??`stderr`,reasoning:e.reasoning??`full`,tools:e.tools??`auto-collapsed`};return e.subagents!==void 0&&(t.subagents=e.subagents),e.connectionAuth!==void 0&&(t.connectionAuth=e.connectionAuth),e.assistantResponseStats!==void 0&&(t.assistantResponseStats=e.assistantResponseStats),e.contextSize!==void 0&&(t.contextSize=e.contextSize),t}function hasInteractiveTerminal(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function rewriteDevelopmentUrlShorthand(e){let t=e[1];return e[0]!==`dev`||e.length!==2||t===void 0||t.startsWith(`-`)?[...e]:[`dev`,`--url`,t]}function resolveRemoteDevelopmentServerUrl(e){if(e.url){if(e.host!==void 0)throw new InvalidArgumentError(`The --host option cannot be used with --url.`);if(e.port!==void 0)throw new InvalidArgumentError(`The --port option cannot be used with --url.`);if(e.ui===!1)throw new InvalidArgumentError(`The --no-ui option cannot be used with --url.`);return e.url}}function createCliProgram(t,o){let u=resolveApplicationRoot(),d=resolveInstalledPackageInfo().version,f=new Command,p=createCliTheme();f.name(`eve`).description(`Build and run an Eve application.`).version(d).showHelpAfterError().exitOverride().hook(`preAction`,(e,n)=>{shouldPrintCliBootBanner(n)&&t.log(eveCliBanner())}).configureOutput({writeErr:e=>{t.error(e.trimEnd())},writeOut:e=>{t.log(e.trimEnd())}});let m=f.command(`channels`).description(`Manage user-authored channels in the current project.`);return m.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(e,n)=>{let{runChannelsAddCommand:r}=await import(`#cli/commands/channels.js`);await r(t,u,{kind:e,options:n})}),m.command(`list`).description(`List user-authored channels in the current project.`).option(`--json`,`Output as JSON`).action(async e=>{let{runChannelsListCommand:n}=await import(`#cli/commands/channels.js`);await n(t,u,e)}),f.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)`).action(async(e,n)=>{let{runInitCommand:r}=await import(`#cli/commands/init.js`);await r(t,u,e,n)}),registerProjectCommands({program:f,logger:t,appRoot:u}),f.command(`build`).description(`Build the current Eve application.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:e}=await import(`#cli/dev/environment.js`);e(u);let n=await(o.buildHost??await loadBuildHost())(u);t.log(renderCliTaggedLine(p,{message:`built output at ${n}`,tag:`build`,tone:`success`}))}),f.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 e=>{let{loadDevelopmentEnvironmentFiles:n}=await import(`#cli/dev/environment.js`);n(u);let i=await(o.startProductionHost??await loadStartProductionHost())(u,{host:e.host,port:e.port});t.log(renderCliTaggedLine(p,{message:`server listening at ${i.url}`,tag:`start`,tone:`success`})),await waitForProductionServer(i)}),f.command(`dev`).description(`Start the Eve development server or connect to an existing URL.`).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(`--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 after launching the UI`).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 as the only argument, for example: eve dev https://example.com
3
3
  `).action(async e=>{let n=resolveRemoteDevelopmentServerUrl(e),i=hasInteractiveTerminal(),a=resolveDevUiMode({options:e,interactive:i});if(e.input!==void 0&&a===`headless`)throw new InvalidArgumentError(`--input requires the interactive UI.`);let{loadDevelopmentEnvironmentFiles:c}=await import(`#cli/dev/environment.js`);c(u);let runInteractiveUi=async r=>{t.log(``);let i=o.runDevelopmentTui??await loadRunDevelopmentTui(),a=resolveTuiDisplayOptions(e),s=resolveTuiTitle({name:e.name,remoteServerUrl:n,appRoot:u});s!==void 0&&(a.name=s);let c={serverUrl:r,...a};n===void 0&&(c.appRoot=u),e.input!==void 0&&(c.initialInput=e.input),await i(c)};if(n){if(t.log(renderCliTaggedLine(p,{message:`connecting to ${n}`,tag:`dev`,tone:`info`})),a===`headless`){t.log(renderCliTaggedLine(p,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}await runInteractiveUi(n);return}let l=await(o.startHost??await loadStartHost())(u,{host:e.host,port:e.port}),d=!1,closeServer=async()=>{d||(d=!0,await l.close())};try{if(a!==`tui`&&t.log(renderCliTaggedLine(p,{message:`server listening at ${l.url}`,tag:`dev`,tone:`success`})),a===`headless`)return e.ui!==!1&&!i&&t.log(renderCliTaggedLine(p,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForShutdownSignal({close:closeServer});await runInteractiveUi(l.url)}finally{await closeServer()}}),f.command(`info`).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async e=>{await(o.printApplicationInfo??await loadPrintApplicationInfo())(t,u,e)}),f.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)`).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 ctx.log lines to stdout`).action(async(e,n)=>{await(o.runEvalCommand??await loadRunEvalCommand())(e,n,t)}),f}async function runCli(e=process.argv.slice(2),t=console,n={}){let r=createCliProgram(t,n),i=e.length===0?[`dev`]:rewriteDevelopmentUrlShorthand(e);try{await r.parseAsync(i,{from:`user`})}catch(e){if(e instanceof CommanderError){if(e.exitCode===0)return;throw Error(e.message)}throw e}}export{resolveDevUiMode,resolveTuiDisplayOptions,resolveTuiTitle,runCli};
@@ -29,5 +29,5 @@
29
29
  "zod": "4.4.3",
30
30
  "zod-validation-error": "5.0.0"
31
31
  },
32
- "scriptHash": "a6001eeee1872ee43456043e6c0b8ca745ad8766a75b148eb3d638e4cccce565"
32
+ "scriptHash": "36b9994f5b5180a27cb27601163c60a4d715a7b275632926014b5bbbbe44e99a"
33
33
  }
@@ -1 +1 @@
1
- import"#evals/session.js";import{AssertionCollector}from"#evals/assertions/collector.js";import*as RunAssertions from"#evals/assertions/run.js";import{buildJudgeContext}from"#evals/judge.js";function createEvalContext(r){let i=new AssertionCollector,a=``,primary=()=>r.manager.primary,replyMessage=()=>r.manager.lastTurnSession()?.lastTurn?.message??null,o=buildJudgeContext({collector:i,getReply:replyMessage,getInput:()=>a,judge:r.judge});return{context:{get events(){return primary().events},get pendingInputRequests(){return primary().pendingInputRequests},get state(){return primary().state},get sessionId(){return primary().sessionId},expectInputRequests:e=>primary().expectInputRequests(e),respond:(...e)=>primary().respond(...e),respondAll:e=>primary().respondAll(e),send:e=>(a=promptText(e),primary().send(e)),sendFile:(e,t,n)=>(a=e,primary().sendFile(e,t,n)),signal:r.signal,target:r.target,get reply(){return replyMessage()},log:r.log,newSession:()=>r.manager.newSession(),completed:()=>i.recordRun(RunAssertions.completed()),didNotFail:()=>i.recordRun(RunAssertions.didNotFail()),waiting:()=>i.recordRun(RunAssertions.waiting()),messageIncludes:e=>i.recordRun(RunAssertions.messageIncludes(e)),calledTool:(e,n)=>i.recordRun(RunAssertions.calledTool(e,n)),notCalledTool:e=>i.recordRun(RunAssertions.notCalledTool(e)),toolOrder:e=>i.recordRun(RunAssertions.toolOrder(e)),usedNoTools:()=>i.recordRun(RunAssertions.usedNoTools()),maxToolCalls:e=>i.recordRun(RunAssertions.maxToolCalls(e)),calledSubagent:(e,n)=>i.recordRun(RunAssertions.calledSubagent(e,n)),noFailedActions:()=>i.recordRun(RunAssertions.noFailedActions()),event:(e,n)=>i.recordRun(RunAssertions.event(e,n)),outputEquals:e=>i.recordRun(RunAssertions.outputEquals(e)),outputMatches:e=>i.recordRun(RunAssertions.outputMatches(e)),check:(e,t)=>recordCheck(i,e,t),judge:o},collector:i}}function recordCheck(e,t,n){return e.recordValue({name:n.name,severity:n.severity,threshold:n.threshold,score:async()=>({score:await n.score(t)})})}function promptText(e){if(typeof e==`string`)return e;let t=e.message;return typeof t==`string`?t:``}export{createEvalContext};
1
+ import"#evals/session.js";import{AssertionCollector}from"#evals/assertions/collector.js";import*as RunAssertions from"#evals/assertions/run.js";import{buildJudgeContext}from"#evals/judge.js";function createEvalContext(r){let i=new AssertionCollector,a=``,primary=()=>r.manager.primary,replyMessage=()=>r.manager.lastTurnSession()?.lastTurn?.message??null,o=buildJudgeContext({collector:i,getReply:replyMessage,getInput:()=>a,judge:r.judge});return{context:{get events(){return primary().events},get pendingInputRequests(){return primary().pendingInputRequests},get state(){return primary().state},get sessionId(){return primary().sessionId},expectInputRequests:e=>primary().expectInputRequests(e),respond:(...e)=>primary().respond(...e),respondAll:e=>primary().respondAll(e),send:e=>(a=promptText(e),primary().send(e)),sendFile:(e,t,n)=>(a=e,primary().sendFile(e,t,n)),signal:r.signal,target:r.target,get reply(){return replyMessage()},log:r.log,sleep:e=>sleep(e,r.signal),newSession:()=>r.manager.newSession(),completed:()=>i.recordRun(RunAssertions.completed()),didNotFail:()=>i.recordRun(RunAssertions.didNotFail()),waiting:()=>i.recordRun(RunAssertions.waiting()),messageIncludes:e=>i.recordRun(RunAssertions.messageIncludes(e)),calledTool:(e,n)=>i.recordRun(RunAssertions.calledTool(e,n)),notCalledTool:e=>i.recordRun(RunAssertions.notCalledTool(e)),toolOrder:e=>i.recordRun(RunAssertions.toolOrder(e)),usedNoTools:()=>i.recordRun(RunAssertions.usedNoTools()),maxToolCalls:e=>i.recordRun(RunAssertions.maxToolCalls(e)),calledSubagent:(e,n)=>i.recordRun(RunAssertions.calledSubagent(e,n)),noFailedActions:()=>i.recordRun(RunAssertions.noFailedActions()),event:(e,n)=>i.recordRun(RunAssertions.event(e,n)),outputEquals:e=>i.recordRun(RunAssertions.outputEquals(e)),outputMatches:e=>i.recordRun(RunAssertions.outputMatches(e)),check:(e,t)=>recordCheck(i,e,t),judge:o},collector:i}}function recordCheck(e,t,n){return e.recordValue({name:n.name,severity:n.severity,threshold:n.threshold,score:async()=>({score:await n.score(t)})})}function promptText(e){if(typeof e==`string`)return e;let t=e.message;return typeof t==`string`?t:``}function sleep(e=1e3,t){if(!Number.isFinite(e)||e<0)throw Error(`sleep() duration must be a non-negative finite number.`);return t?.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(t.reason)},{once:!0})})}export{createEvalContext};
@@ -249,6 +249,8 @@ export interface EveEvalContext extends EveEvalSession {
249
249
  readonly reply: string | null;
250
250
  /** Structured eval log hook. */
251
251
  log(message: string): void;
252
+ /** Pause the eval task, defaulting to 1 second, while respecting the eval timeout signal. */
253
+ sleep(ms?: number): Promise<void>;
252
254
  /** Create an additional independent session against the same target. */
253
255
  newSession(): EveEvalSession;
254
256
  completed(): AssertionHandle;
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.9.5`,WORKFLOW_MODULE_ALIASES={"workflow/api":`src/compiled/@workflow/core/runtime.js`,"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`,"workflow/runtime":`src/compiled/@workflow/core/runtime.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let n=e;for(;;){if(existsSync(join(n,`package.json`))&&!isBuildOutputPackageRoot(n))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve package root from "${e}".`);n=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let r=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(r?.name===t)return r}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveInstalledPackageInfo,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
1
+ import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.9.8`,WORKFLOW_MODULE_ALIASES={"workflow/api":`src/compiled/@workflow/core/runtime.js`,"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`,"workflow/runtime":`src/compiled/@workflow/core/runtime.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let n=e;for(;;){if(existsSync(join(n,`package.json`))&&!isBuildOutputPackageRoot(n))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve package root from "${e}".`);n=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let r=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(r?.name===t)return r}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveInstalledPackageInfo,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
@@ -3,6 +3,6 @@
3
3
  * `start-development-server.ts` derives its bind-retry walk from these values.
4
4
  */
5
5
  /** The port `eve dev` binds when none is requested. */
6
- export declare const DEFAULT_DEVELOPMENT_SERVER_PORT = 3000;
6
+ export declare const DEFAULT_DEVELOPMENT_SERVER_PORT = 2000;
7
7
  /** How many consecutive ports the dev server tries past the default before giving up. */
8
8
  export declare const MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS = 10;
@@ -1 +1 @@
1
- const DEFAULT_DEVELOPMENT_SERVER_PORT=3e3,MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS=10;export{DEFAULT_DEVELOPMENT_SERVER_PORT,MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS};
1
+ const DEFAULT_DEVELOPMENT_SERVER_PORT=2e3,MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS=10;export{DEFAULT_DEVELOPMENT_SERVER_PORT,MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS};
@@ -1,2 +1,2 @@
1
1
  import{join}from"node:path";import{mkdir,readFile,rm,writeFile}from"node:fs/promises";import{startDevelopmentSandboxPrewarmInBackground}from"#execution/sandbox/development-prewarm.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{EVE_DEV_ENV_FLAG}from"#internal/application/optional-package-install.js";import{EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV,clearInitializedDevelopmentSandboxBackendNames,createDevelopmentSandboxRunId,getInitializedDevelopmentSandboxBackendNames}from"#execution/sandbox/development-run.js";import{pruneDevelopmentRuntimeArtifactsSnapshotsInBackground}from"#internal/nitro/dev-runtime-artifacts.js";import{build,createDevServer,prepare}from"nitro/builder";import{createApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{prepareApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{createNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{resolveNitroCompiledArtifactsSource}from"#internal/nitro/routes/runtime-artifacts.js";import{pruneLocalSandboxTemplatesInBackground,stopDevelopmentSandboxResources}from"#execution/sandbox/bindings/local.js";import{DEFAULT_DEVELOPMENT_SERVER_PORT,MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS}from"#internal/nitro/host/ports.js";const MAX_ALLOWED_DEVELOPMENT_SERVER_PORT=65535,WORKFLOW_LOCAL_BASE_URL_ENV=`WORKFLOW_LOCAL_BASE_URL`,PORT_ENV=`PORT`,DEFAULT_DEVELOPMENT_SERVER_HOST=`127.0.0.1`,IPV6_WILDCARD_LISTEN_HOSTNAMES=new Set([`[::]`,`::`]);function normalizeDevelopmentServerClientUrl(e){let t=new URL(e);return IPV6_WILDCARD_LISTEN_HOSTNAMES.has(t.hostname)?(t.hostname=`[::1]`,t.toString()):t.hostname===`0.0.0.0`?(t.hostname=DEFAULT_DEVELOPMENT_SERVER_HOST,t.toString()):e}function isAddressInUseError(e){return e instanceof Error&&`code`in e&&e.code===`EADDRINUSE`}function resolveDevelopmentServerPort(e){let t=typeof e==`string`?Number(e):e??DEFAULT_DEVELOPMENT_SERVER_PORT;if(!Number.isInteger(t)||t<0||t>MAX_ALLOWED_DEVELOPMENT_SERVER_PORT)throw Error(`Invalid development server port "${String(e)}". Expected an integer between 0 and ${MAX_ALLOWED_DEVELOPMENT_SERVER_PORT}.`);return t}function readEnvironmentPort(){let e=process.env[PORT_ENV];if(e===void 0||e.trim()===``)return;let t=Number(e);if(!Number.isInteger(t)||t<0||t>MAX_ALLOWED_DEVELOPMENT_SERVER_PORT)throw Error(`Invalid ${PORT_ENV} environment variable "${e}". Expected an integer between 0 and ${MAX_ALLOWED_DEVELOPMENT_SERVER_PORT}.`);return t}function resolveDevelopmentProcessIdPath(t){return join(t,`.eve`,`dev-process.pid`)}function parseProcessId(e){let t=e.trim();if(!/^\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)&&n>0?n:void 0}function isProcessRunning(e){try{return process.kill(e,0),!0}catch(e){return e instanceof Error&&`code`in e&&e.code===`EPERM`}}function formatKillCommand(e){return process.platform===`win32`?`taskkill /PID ${e}`:`kill ${e}`}async function readActiveDevelopmentProcessId(e){let t;try{t=parseProcessId(await readFile(resolveDevelopmentProcessIdPath(e),`utf8`))}catch{return}if(!(t===void 0||!isProcessRunning(t)))return t}async function writeDevelopmentProcessId(a){let o=resolveDevelopmentProcessIdPath(a),s=await readActiveDevelopmentProcessId(a);if(s!==void 0)throw Error([`A dev server is already running for this Eve agent (pid ${s}).`,`To stop it, run: ${formatKillCommand(s)}`].join(`
2
- `));return await mkdir(join(a,`.eve`),{recursive:!0}),await writeFile(o,`${process.pid}\n`,`utf8`),async()=>{let e;try{e=parseProcessId(await readFile(o,`utf8`))}catch{return}e===process.pid&&await rm(o,{force:!0})}}function resolveDevelopmentServerPorts(e){let t=resolveDevelopmentServerPort(e.port);if(t===0||!e.retryOnAddressInUse)return[t];let n=[];for(let e=0;e<MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS;e+=1){let r=t+e;if(r>65535)break;n.push(r)}return n}function installWorkflowLocalQueueEnvironment(e){let t=process.env[WORKFLOW_LOCAL_BASE_URL_ENV],n=process.env[PORT_ENV],r=new URL(normalizeDevelopmentServerClientUrl(e));return process.env[WORKFLOW_LOCAL_BASE_URL_ENV]=r.origin,r.port&&(process.env[PORT_ENV]=r.port),()=>{t===void 0?delete process.env[WORKFLOW_LOCAL_BASE_URL_ENV]:process.env[WORKFLOW_LOCAL_BASE_URL_ENV]=t,n===void 0?delete process.env[PORT_ENV]:process.env[PORT_ENV]=n}}function attachTemporarySocketErrorHandler(e){let onSocketError=()=>{};return e.once(`error`,onSocketError),()=>{e.off(`error`,onSocketError)}}function shouldProxyDevelopmentServerWebSocketUpgrades(e){return e.options.features.websocket===!0||e.options.experimental.websocket===!0}function guardDevelopmentServerWebSocketUpgrades(e,t){let n=t.upgrade.bind(t),r=shouldProxyDevelopmentServerWebSocketUpgrades(e);t.upgrade=async(e,t,i)=>{if(!r){t.destroyed||t.destroy();return}let a=attachTemporarySocketErrorHandler(t);try{await n(e,t,i)}catch{t.destroyed||t.destroy()}finally{a()}}}async function listenForDevelopmentServer(e){let t=resolveDevelopmentServerPorts({port:e.port,retryOnAddressInUse:e.retryOnAddressInUse}),n;for(let r of t){let t=e.devServer.listen({hostname:e.host,port:r,silent:!0});try{return await t.ready(),t}catch(r){if(n=r,await t.close().catch(()=>{}),!isAddressInUseError(r)||!e.retryOnAddressInUse)throw r}}throw Error(`Failed to start Nitro dev server after ${t.length} attempts. Tried ports ${t.join(`, `)}.`,{cause:n})}async function startDevelopmentServer(e,t={}){process.env[EVE_DEV_ENV_FLAG]??=`1`,loadDevelopmentEnvironmentFiles(e);let n=process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV],r=createDevelopmentSandboxRunId();process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV]=r;let i,u,d,f,p;try{let o=await prepareApplicationHost(e,{dev:!0});p=await writeDevelopmentProcessId(o.appRoot),pruneDevelopmentRuntimeArtifactsSnapshotsInBackground(o.appRoot);let s=resolveNitroCompiledArtifactsSource(createNitroArtifactsConfig({appRoot:o.appRoot,dev:!0}));startDevelopmentSandboxPrewarmInBackground({appRoot:o.appRoot,compiledArtifactsSource:s}),pruneLocalSandboxTemplatesInBackground(o.appRoot),i=await createApplicationNitro(o,!0),u=createDevServer(i),guardDevelopmentServerWebSocketUpgrades(i,u);let c=t.host??i.options.devServer.hostname??DEFAULT_DEVELOPMENT_SERVER_HOST,l=t.port??readEnvironmentPort(),m=l??i.options.devServer.port,h=await listenForDevelopmentServer({devServer:u,host:c,port:m,retryOnAddressInUse:l===void 0});if(!h.url)throw Error(`Nitro dev server did not expose a URL.`);d=installWorkflowLocalQueueEnvironment(h.url),await prepare(i),await build(i);let{startAuthoredSourceWatcher:g}=await import(`#internal/nitro/host/dev-authored-source-watcher.js`);f=await g({nitro:i,preparedHost:o});let _=d;if(_===void 0)throw Error(`Workflow local queue environment was not initialized.`);let v=f,y=u,b=i;return{async close(){try{await v.close(),await y.close(),await b.close(),await stopDevelopmentSandboxResources({backendNames:getInitializedDevelopmentSandboxBackendNames(r),devRunId:r,log:e=>console.warn(`[eve:dev] ${e}`)})}finally{clearInitializedDevelopmentSandboxBackendNames(r),await p?.(),_(),restoreDevelopmentSandboxRunId(n)}},url:normalizeDevelopmentServerClientUrl(h.url)}}catch(e){throw await f?.close().catch(()=>{}),d?.(),await u?.close().catch(()=>{}),await i?.close().catch(()=>{}),await stopDevelopmentSandboxResources({backendNames:getInitializedDevelopmentSandboxBackendNames(r),devRunId:r,log:e=>console.warn(`[eve:dev] ${e}`)}).catch(()=>{}),clearInitializedDevelopmentSandboxBackendNames(r),await p?.().catch(()=>{}),restoreDevelopmentSandboxRunId(n),e}}function restoreDevelopmentSandboxRunId(e){if(e===void 0){delete process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV];return}process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV]=e}export{normalizeDevelopmentServerClientUrl,startDevelopmentServer};
2
+ `));return await mkdir(join(a,`.eve`),{recursive:!0}),await writeFile(o,`${process.pid}\n`,`utf8`),async()=>{let e;try{e=parseProcessId(await readFile(o,`utf8`))}catch{return}e===process.pid&&await rm(o,{force:!0})}}function resolveDevelopmentServerPorts(e){let t=resolveDevelopmentServerPort(e.port);if(t===0||!e.retryOnAddressInUse)return[t];let n=[];for(let e=0;e<MAX_DEVELOPMENT_SERVER_PORT_ATTEMPTS;e+=1){let r=t+e;if(r>65535)break;n.push(r)}return n}function installWorkflowLocalQueueEnvironment(e){let t=process.env[WORKFLOW_LOCAL_BASE_URL_ENV],n=process.env[PORT_ENV],r=new URL(normalizeDevelopmentServerClientUrl(e));return process.env[WORKFLOW_LOCAL_BASE_URL_ENV]=r.origin,r.port&&(process.env[PORT_ENV]=r.port),()=>{t===void 0?delete process.env[WORKFLOW_LOCAL_BASE_URL_ENV]:process.env[WORKFLOW_LOCAL_BASE_URL_ENV]=t,n===void 0?delete process.env[PORT_ENV]:process.env[PORT_ENV]=n}}function attachTemporarySocketErrorHandler(e){let onSocketError=()=>{};return e.once(`error`,onSocketError),()=>{e.off(`error`,onSocketError)}}function shouldProxyDevelopmentServerWebSocketUpgrades(e){return e.options.features.websocket===!0||e.options.experimental.websocket===!0}function guardDevelopmentServerWebSocketUpgrades(e,t){let n=t.upgrade.bind(t),r=shouldProxyDevelopmentServerWebSocketUpgrades(e);t.upgrade=async(e,t,i)=>{if(!r){t.destroyed||t.destroy();return}let a=attachTemporarySocketErrorHandler(t);try{await n(e,t,i)}catch{t.destroyed||t.destroy()}finally{a()}}}async function listenForDevelopmentServer(e){let t=resolveDevelopmentServerPorts({port:e.port,retryOnAddressInUse:e.retryOnAddressInUse}),n;for(let r of t){let t=e.devServer.listen({hostname:e.host,port:r,silent:!0});try{return await t.ready(),t}catch(r){if(n=r,await t.close().catch(()=>{}),!isAddressInUseError(r)||!e.retryOnAddressInUse)throw r}}throw Error(`Failed to start Nitro dev server after ${t.length} attempts. Tried ports ${t.join(`, `)}.`,{cause:n})}async function startDevelopmentServer(e,t={}){process.env[EVE_DEV_ENV_FLAG]??=`1`,loadDevelopmentEnvironmentFiles(e);let n=process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV],r=createDevelopmentSandboxRunId();process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV]=r;let i,u,d,f,p;try{let o=await prepareApplicationHost(e,{dev:!0});p=await writeDevelopmentProcessId(o.appRoot),pruneDevelopmentRuntimeArtifactsSnapshotsInBackground(o.appRoot);let s=resolveNitroCompiledArtifactsSource(createNitroArtifactsConfig({appRoot:o.appRoot,dev:!0}));startDevelopmentSandboxPrewarmInBackground({appRoot:o.appRoot,compiledArtifactsSource:s}),pruneLocalSandboxTemplatesInBackground(o.appRoot),i=await createApplicationNitro(o,!0),u=createDevServer(i),guardDevelopmentServerWebSocketUpgrades(i,u);let c=t.host??i.options.devServer.hostname??DEFAULT_DEVELOPMENT_SERVER_HOST,l=t.port??readEnvironmentPort(),m=await listenForDevelopmentServer({devServer:u,host:c,port:l,retryOnAddressInUse:l===void 0});if(!m.url)throw Error(`Nitro dev server did not expose a URL.`);d=installWorkflowLocalQueueEnvironment(m.url),await prepare(i),await build(i);let{startAuthoredSourceWatcher:h}=await import(`#internal/nitro/host/dev-authored-source-watcher.js`);f=await h({nitro:i,preparedHost:o});let g=d;if(g===void 0)throw Error(`Workflow local queue environment was not initialized.`);let _=f,v=u,y=i;return{async close(){try{await _.close(),await v.close(),await y.close(),await stopDevelopmentSandboxResources({backendNames:getInitializedDevelopmentSandboxBackendNames(r),devRunId:r,log:e=>console.warn(`[eve:dev] ${e}`)})}finally{clearInitializedDevelopmentSandboxBackendNames(r),await p?.(),g(),restoreDevelopmentSandboxRunId(n)}},url:normalizeDevelopmentServerClientUrl(m.url)}}catch(e){throw await f?.close().catch(()=>{}),d?.(),await u?.close().catch(()=>{}),await i?.close().catch(()=>{}),await stopDevelopmentSandboxResources({backendNames:getInitializedDevelopmentSandboxBackendNames(r),devRunId:r,log:e=>console.warn(`[eve:dev] ${e}`)}).catch(()=>{}),clearInitializedDevelopmentSandboxBackendNames(r),await p?.().catch(()=>{}),restoreDevelopmentSandboxRunId(n),e}}function restoreDevelopmentSandboxRunId(e){if(e===void 0){delete process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV];return}process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV]=e}export{normalizeDevelopmentServerClientUrl,startDevelopmentServer};
@@ -2,7 +2,8 @@ import type { ConnectionAuthDefinition, HeadersDefinition, ToolFilterDefinition
2
2
  import type { NeedsApprovalContext } from "#public/definitions/tool.js";
3
3
  /**
4
4
  * The OpenAPI document backing the connection: either an HTTPS URL the
5
- * runtime fetches on first use, or an already-parsed OpenAPI 3.x object.
5
+ * runtime fetches on first use, or an already-parsed OpenAPI 3.x /
6
+ * Swagger 2.0 object.
6
7
  */
7
8
  export type OpenAPISpecSource = string | Record<string, unknown>;
8
9
  /**
@@ -25,8 +26,8 @@ export type OpenAPISpecSource = string | Record<string, unknown>;
25
26
  */
26
27
  export interface OpenAPIConnectionDefinition {
27
28
  /**
28
- * The OpenAPI 3.x document. Pass an HTTPS URL to fetch and parse at
29
- * runtime, or an inline parsed object.
29
+ * The OpenAPI 3.x or Swagger 2.0 document. Pass an HTTPS URL to fetch
30
+ * and parse at runtime, or an inline parsed object.
30
31
  */
31
32
  readonly spec: OpenAPISpecSource;
32
33
  /**
@@ -34,10 +35,11 @@ export interface OpenAPIConnectionDefinition {
34
35
  * `https://api.example.com`).
35
36
  *
36
37
  * Optional: when omitted, the runtime uses the document's first usable
37
- * `servers` entry. It fills server-variable `{var}` placeholders from
38
+ * `servers` entry (OpenAPI 3.x) or `schemes`/`host`/`basePath`
39
+ * (Swagger 2.0). It fills server-variable `{var}` placeholders from
38
40
  * each variable's `default`, and resolves a relative server URL
39
41
  * against the spec's URL. Provide `baseUrl` when the document has no
40
- * absolute `servers` entry, or to override it.
42
+ * derivable base URL, or to override it.
41
43
  */
42
44
  readonly baseUrl?: string;
43
45
  /**
@@ -19,8 +19,8 @@ export interface OpenApiToolResult {
19
19
  readonly body: unknown;
20
20
  }
21
21
  /**
22
- * A {@link ConnectionClient} that turns an OpenAPI 3.x document into
23
- * connection tools.
22
+ * A {@link ConnectionClient} that turns an OpenAPI 3.x or Swagger 2.0
23
+ * document into connection tools.
24
24
  *
25
25
  * Created lazily per-connection per-session. On first use it loads the
26
26
  * document (fetching it when `spec` is a URL), dereferences local
@@ -1 +1 @@
1
- import{isObject}from"#shared/guards.js";import{jsonSchema,tool}from"ai";import{passesToolFilter,resolveHeaders}from"#runtime/connections/mcp-client.js";import{HTTP_METHODS,operationDescription,operationName,uniqueName}from"#runtime/connections/openapi-operations.js";import{buildInputSchema,deref,derefSchema,isArray}from"#runtime/connections/openapi-schema.js";import{applySecurity,resolveSecurity}from"#runtime/connections/openapi-security.js";import{extractServerUrl,parseSpecDocument}from"#runtime/connections/openapi-spec.js";var OpenApiConnectionClient=class{#e;#t;#n;constructor(e){this.#n=e}async connect(){return this.#r()}async getToolMetadata(){return(await this.#r()).metadata}async getTools(){return(await this.#r()).tools}async executeTool(t,n){let r=await this.#r(),i=r.operations.get(t);if(i===void 0)throw Error(`Tool "${t}" not found in connection "${this.#n.connectionName}".`);return this.#u(i,r.baseUrl,isObject(n)?n:{})}async close(){this.#e=void 0,this.#t=void 0}async#r(){if(this.#t!==void 0)return this.#t;if(this.#e!==void 0)return this.#e;this.#e=this.#i();try{return this.#t=await this.#e,this.#t}catch(e){throw this.#e=void 0,e}}async#i(){let i=await this.#o(),a=this.#a(i),o=this.#s(i),s=this.#n.tools,c=s===void 0?o:o.filter(e=>passesToolFilter(e.toolName,s)),l=[],u=new Map,d={};for(let r of c)u.set(r.toolName,r),l.push({description:r.description,inputSchema:r.inputSchema,name:r.toolName}),d[r.toolName]=tool({description:r.description,inputSchema:jsonSchema(r.inputSchema),execute:async t=>this.#u(r,a,isObject(t)?t:{})});return{metadata:l,operations:u,tools:d,baseUrl:a}}#a(e){let t=this.#n.url;if(typeof t==`string`&&t.trim().length>0)return t;let n=extractServerUrl(e,this.#n.spec);if(n!==void 0)return n;throw Error(`OpenAPI connection "${this.#n.connectionName}" has no base URL: set "baseUrl" or ensure the document declares an absolute "servers" entry.`)}async#o(){let t=this.#n.spec;if(t===void 0)throw Error(`OpenAPI connection "${this.#n.connectionName}" is missing its "spec" source.`);if(typeof t!=`string`)return t;let n;try{n=await fetch(t,{headers:{accept:`application/json, application/yaml, text/yaml, */*`}})}catch(e){throw Error(`OpenAPI connection "${this.#n.connectionName}" failed to fetch its spec from "${t}": ${String(e)}`)}if(!n.ok)throw Error(`OpenAPI connection "${this.#n.connectionName}" failed to fetch its spec from "${t}": HTTP ${n.status}.`);let r=await n.text(),i;try{i=parseSpecDocument(r)}catch(e){throw Error(`OpenAPI connection "${this.#n.connectionName}" spec at "${t}" could not be parsed as JSON or YAML: ${String(e)}`)}if(!isObject(i))throw Error(`OpenAPI connection "${this.#n.connectionName}" spec at "${t}" is not an OpenAPI document object.`);return i}#s(t){let n=t.paths;if(!isObject(n))return[];let r=[],i=new Set;for(let[u,d]of Object.entries(n)){if(!isObject(d))continue;let n=isArray(d.parameters)?d.parameters:[];for(let f of HTTP_METHODS){let a=d[f];if(!isObject(a))continue;let p=uniqueName(operationName(a,f,u),i),m=isArray(a.parameters)?a.parameters:[],h=this.#c(t,[...n,...m]),g=this.#l(t,a.requestBody);r.push({toolName:p,method:f,pathTemplate:u,description:operationDescription(a),parameters:h,requestBody:g,inputSchema:buildInputSchema(h,g),security:resolveSecurity(t,a)})}}return r}#c(t,n){let r=[];for(let i of n){let n=isObject(i)?deref(t,i):i;if(!isObject(n))continue;let a=n.in;if(a!==`path`&&a!==`query`&&a!==`header`&&a!==`cookie`||typeof n.name!=`string`)continue;let o=isObject(n.schema)?derefSchema(t,n.schema):{};r.push({name:n.name,location:a,required:n.required===!0||a===`path`,schema:o,description:typeof n.description==`string`?n.description:void 0})}return r}#l(t,n){if(!isObject(n))return;let r=deref(t,n);if(!isObject(r)||!isObject(r.content))return;let i=r.content,a=`application/json`in i?`application/json`:Object.keys(i)[0];if(a===void 0)return;let o=i[a],s=isObject(o)&&isObject(o.schema)?derefSchema(t,o.schema):{};return{required:r.required===!0,contentType:a,schema:s}}async#u(e,t,n){let r=await resolveHeaders(this.#n),a=e.pathTemplate,o=new URLSearchParams,s=[];for(let t of e.parameters){let e=n[t.name];e!=null&&(t.location===`path`?a=a.replace(`{${t.name}}`,encodeURIComponent(String(e))):t.location===`query`?appendQuery(o,t.name,e):t.location===`cookie`?s.push(`${t.name}=${encodeURIComponent(String(e))}`):r[t.name]=String(e))}if(applySecurity(e.security,this.#n,r,o,s),s.length>0){let e=r.cookie??r.Cookie;delete r.Cookie,r.cookie=[e,...s].filter(e=>!!e).join(`; `)}let c=new URL(joinPath(t,a));c.search=o.toString();let l;e.requestBody!==void 0&&n.body!==void 0&&(l=JSON.stringify(n.body),r[`content-type`]=e.requestBody.contentType);let u=await fetch(c,{method:e.method.toUpperCase(),headers:r,body:l});return{status:u.status,statusText:u.statusText,body:await readResponseBody(u)}}};function appendQuery(e,t,n){if(isArray(n)){for(let r of n)e.append(t,String(r));return}e.append(t,String(n))}function joinPath(e,t){return`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`}async function readResponseBody(e){let t=await e.text();if(t.length===0)return null;if((e.headers.get(`content-type`)??``).includes(`application/json`))try{return JSON.parse(t)}catch{return t}return t}export{OpenApiConnectionClient};
1
+ import{isObject}from"#shared/guards.js";import{jsonSchema,tool}from"ai";import{passesToolFilter,resolveHeaders}from"#runtime/connections/mcp-client.js";import{HTTP_METHODS,operationDescription,operationName,uniqueName}from"#runtime/connections/openapi-operations.js";import{buildInputSchema,deref,derefSchema,isArray}from"#runtime/connections/openapi-schema.js";import{applySecurity,resolveSecurity}from"#runtime/connections/openapi-security.js";import{extractServerUrl,parseSpecDocument}from"#runtime/connections/openapi-spec.js";const SWAGGER_PARAMETER_SCHEMA_KEYS=[`default`,`enum`,`exclusiveMaximum`,`exclusiveMinimum`,`format`,`items`,`maximum`,`maxItems`,`maxLength`,`minimum`,`minItems`,`minLength`,`multipleOf`,`pattern`,`type`,`uniqueItems`];var OpenApiConnectionClient=class{#e;#t;#n;constructor(e){this.#n=e}async connect(){return this.#r()}async getToolMetadata(){return(await this.#r()).metadata}async getTools(){return(await this.#r()).tools}async executeTool(t,n){let r=await this.#r(),i=r.operations.get(t);if(i===void 0)throw Error(`Tool "${t}" not found in connection "${this.#n.connectionName}".`);return this.#f(i,r.baseUrl,isObject(n)?n:{})}async close(){this.#e=void 0,this.#t=void 0}async#r(){if(this.#t!==void 0)return this.#t;if(this.#e!==void 0)return this.#e;this.#e=this.#i();try{return this.#t=await this.#e,this.#t}catch(e){throw this.#e=void 0,e}}async#i(){let i=await this.#o(),a=this.#a(i),o=this.#s(i),s=this.#n.tools,c=s===void 0?o:o.filter(e=>passesToolFilter(e.toolName,s)),l=[],u=new Map,d={};for(let r of c)u.set(r.toolName,r),l.push({description:r.description,inputSchema:r.inputSchema,name:r.toolName}),d[r.toolName]=tool({description:r.description,inputSchema:jsonSchema(r.inputSchema),execute:async t=>this.#f(r,a,isObject(t)?t:{})});return{metadata:l,operations:u,tools:d,baseUrl:a}}#a(e){let t=this.#n.url;if(typeof t==`string`&&t.trim().length>0)return t;let n=extractServerUrl(e,this.#n.spec);if(n!==void 0)return n;throw Error(`OpenAPI connection "${this.#n.connectionName}" has no base URL: set "baseUrl" or ensure the document declares an absolute "servers" entry or Swagger "host".`)}async#o(){let t=this.#n.spec;if(t===void 0)throw Error(`OpenAPI connection "${this.#n.connectionName}" is missing its "spec" source.`);if(typeof t!=`string`)return t;let n;try{n=await fetch(t,{headers:{accept:`application/json, application/yaml, text/yaml, */*`}})}catch(e){throw Error(`OpenAPI connection "${this.#n.connectionName}" failed to fetch its spec from "${t}": ${String(e)}`)}if(!n.ok)throw Error(`OpenAPI connection "${this.#n.connectionName}" failed to fetch its spec from "${t}": HTTP ${n.status}.`);let r=await n.text(),i;try{i=parseSpecDocument(r)}catch(e){throw Error(`OpenAPI connection "${this.#n.connectionName}" spec at "${t}" could not be parsed as JSON or YAML: ${String(e)}`)}if(!isObject(i))throw Error(`OpenAPI connection "${this.#n.connectionName}" spec at "${t}" is not an OpenAPI document object.`);return i}#s(t){let n=t.paths;if(!isObject(n))return[];let r=[],i=new Set;for(let[u,d]of Object.entries(n)){if(!isObject(d))continue;let n=isArray(d.parameters)?d.parameters:[];for(let f of HTTP_METHODS){let a=d[f];if(!isObject(a))continue;let p=uniqueName(operationName(a,f,u),i),m=isArray(a.parameters)?a.parameters:[],h=[...n,...m],g=this.#c(t,h),_=this.#l(t,a.requestBody,h);r.push({toolName:p,method:f,pathTemplate:u,description:operationDescription(a),parameters:g,requestBody:_,inputSchema:buildInputSchema(g,_),security:resolveSecurity(t,a)})}}return r}#c(t,n){let r=[];for(let i of n){let n=isObject(i)?deref(t,i):i;if(!isObject(n))continue;let a=n.in;if(a!==`path`&&a!==`query`&&a!==`header`&&a!==`cookie`||typeof n.name!=`string`)continue;let o=this.#u(t,n);r.push({name:n.name,location:a,required:n.required===!0||a===`path`,schema:o,description:typeof n.description==`string`?n.description:void 0})}return r}#l(t,n,r=[]){if(isObject(n)){let r=deref(t,n);if(isObject(r)&&isObject(r.content)){let n=r.content,i=`application/json`in n?`application/json`:Object.keys(n)[0];if(i!==void 0){let a=n[i],o=isObject(a)&&isObject(a.schema)?derefSchema(t,a.schema):{};return{required:r.required===!0,contentType:i,schema:o}}}}return this.#d(t,r)}#u(t,n){if(isObject(n.schema))return derefSchema(t,n.schema);let r={};for(let e of SWAGGER_PARAMETER_SCHEMA_KEYS)n[e]!==void 0&&(r[e]=n[e]);return derefSchema(t,r)}#d(t,n){for(let r of n){let n=isObject(r)?deref(t,r):r;if(!isObject(n)||n.in!==`body`)continue;let i=isObject(n.schema)?derefSchema(t,n.schema):{};return{required:n.required===!0,contentType:`application/json`,schema:i}}}async#f(e,t,n){let r=await resolveHeaders(this.#n),a=e.pathTemplate,o=new URLSearchParams,s=[];for(let t of e.parameters){let e=n[t.name];e!=null&&(t.location===`path`?a=a.replace(`{${t.name}}`,encodeURIComponent(String(e))):t.location===`query`?appendQuery(o,t.name,e):t.location===`cookie`?s.push(`${t.name}=${encodeURIComponent(String(e))}`):r[t.name]=String(e))}if(applySecurity(e.security,this.#n,r,o,s),s.length>0){let e=r.cookie??r.Cookie;delete r.Cookie,r.cookie=[e,...s].filter(e=>!!e).join(`; `)}let c=new URL(joinPath(t,a));c.search=o.toString();let l;e.requestBody!==void 0&&n.body!==void 0&&(l=JSON.stringify(n.body),r[`content-type`]=e.requestBody.contentType);let u=await fetch(c,{method:e.method.toUpperCase(),headers:r,body:l});return{status:u.status,statusText:u.statusText,body:await readResponseBody(u)}}};function appendQuery(e,t,n){if(isArray(n)){for(let r of n)e.append(t,String(r));return}e.append(t,String(n))}function joinPath(e,t){return`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`}async function readResponseBody(e){let t=await e.text();if(t.length===0)return null;if((e.headers.get(`content-type`)??``).includes(`application/json`))try{return JSON.parse(t)}catch{return t}return t}export{OpenApiConnectionClient};
@@ -2,7 +2,8 @@ import type { ResolvedConnectionDefinition } from "#runtime/types.js";
2
2
  /**
3
3
  * How the connection's resolved credential is placed on a request,
4
4
  * derived from the operation's effective `security` requirement and the
5
- * document's `securitySchemes`.
5
+ * document's `securitySchemes` (OpenAPI 3.x) or `securityDefinitions`
6
+ * (Swagger 2.0).
6
7
  *
7
8
  * - `bearer` — `Authorization: Bearer <token>` (the default; also covers
8
9
  * `oauth2` / `openIdConnect`, whose access tokens are bearer tokens).
@@ -1 +1 @@
1
- import{isObject}from"#shared/guards.js";import{deref,isArray}from"#runtime/connections/openapi-schema.js";function resolveSecurity(r,i){let a=isArray(i.security)?i.security:isArray(r.security)?r.security:void 0;if(a===void 0||a.length===0)return;let o=isObject(r.components)?r.components:void 0,s=o!==void 0&&isObject(o.securitySchemes)?o.securitySchemes:void 0;if(s!==void 0)for(let n of a){if(!isObject(n))continue;let i=Object.keys(n)[0];if(i===void 0)continue;let a=s[i],o=isObject(a)?deref(r,a):void 0;if(!isObject(o))continue;let c=mapSecurityScheme(o);if(c!==void 0)return c}}function mapSecurityScheme(e){if(e.type===`apiKey`){let t=e.in;return(t===`header`||t===`query`||t===`cookie`)&&typeof e.name==`string`&&e.name.length>0?{kind:`apiKey`,in:t,name:e.name}:void 0}if(e.type===`http`)return(typeof e.scheme==`string`?e.scheme.toLowerCase():``)===`basic`?{kind:`basic`}:{kind:`bearer`};if(e.type===`oauth2`||e.type===`openIdConnect`)return{kind:`bearer`}}function applySecurity(e,t,n,r,i){if(e===void 0||t.authorization===void 0)return;let a=extractBearerToken(n);if(a!==void 0&&e.kind!==`bearer`){if(e.kind===`basic`){n.Authorization=`Basic ${a}`;return}delete n.Authorization,e.in===`header`?n[e.name]=a:e.in===`query`?r.set(e.name,a):i.push(`${e.name}=${a}`)}}function extractBearerToken(e){let t=e.Authorization??e.authorization;return typeof t==`string`?/^Bearer\s+(.+)$/i.exec(t)?.[1]:void 0}export{applySecurity,resolveSecurity};
1
+ import{isObject}from"#shared/guards.js";import{deref,isArray}from"#runtime/connections/openapi-schema.js";function resolveSecurity(r,i){let a=isArray(i.security)?i.security:isArray(r.security)?r.security:void 0;if(a===void 0||a.length===0)return;let o=getSecuritySchemes(r);if(o!==void 0)for(let n of a){if(!isObject(n))continue;let i=Object.keys(n)[0];if(i===void 0)continue;let a=o[i],s=isObject(a)?deref(r,a):void 0;if(!isObject(s))continue;let c=mapSecurityScheme(s);if(c!==void 0)return c}}function getSecuritySchemes(t){let n=isObject(t.components)?t.components:void 0;return n!==void 0&&isObject(n.securitySchemes)?n.securitySchemes:isObject(t.securityDefinitions)?t.securityDefinitions:void 0}function mapSecurityScheme(e){if(e.type===`apiKey`){let t=e.in;return(t===`header`||t===`query`||t===`cookie`)&&typeof e.name==`string`&&e.name.length>0?{kind:`apiKey`,in:t,name:e.name}:void 0}if(e.type===`http`)return(typeof e.scheme==`string`?e.scheme.toLowerCase():``)===`basic`?{kind:`basic`}:{kind:`bearer`};if(e.type===`basic`)return{kind:`basic`};if(e.type===`oauth2`||e.type===`openIdConnect`)return{kind:`bearer`}}function applySecurity(e,t,n,r,i){if(e===void 0||t.authorization===void 0)return;let a=extractBearerToken(n);if(a!==void 0&&e.kind!==`bearer`){if(e.kind===`basic`){n.Authorization=`Basic ${a}`;return}delete n.Authorization,e.in===`header`?n[e.name]=a:e.in===`query`?r.set(e.name,a):i.push(`${e.name}=${a}`)}}function extractBearerToken(e){let t=e.Authorization??e.authorization;return typeof t==`string`?/^Bearer\s+(.+)$/i.exec(t)?.[1]:void 0}export{applySecurity,resolveSecurity};
@@ -9,12 +9,10 @@
9
9
  */
10
10
  export declare function parseSpecDocument(text: string): unknown;
11
11
  /**
12
- * Picks a base URL from an OpenAPI document's `servers` array.
12
+ * Picks a base URL from an OpenAPI document.
13
13
  *
14
- * Returns the first server whose URL resolves to an absolute `http(s)`
15
- * origin: `{var}` placeholders are substituted with each variable's
16
- * `default`, and a relative URL (e.g. `/api/v3`) is resolved against
17
- * `specSource` when the spec was supplied as a URL. Returns `undefined`
18
- * when no entry yields an absolute URL.
14
+ * OpenAPI 3.x documents use `servers`; Swagger 2.0 documents use
15
+ * `schemes`/`host`/`basePath`. Returns `undefined` when neither shape
16
+ * yields an absolute HTTP(S) URL.
19
17
  */
20
18
  export declare function extractServerUrl(document: Record<string, unknown>, specSource: string | Record<string, unknown> | undefined): string | undefined;
@@ -1 +1 @@
1
- import{isObject}from"#shared/guards.js";import matter from"#compiled/gray-matter/index.js";import{isArray}from"#runtime/connections/openapi-schema.js";function parseSpecDocument(e){try{return JSON.parse(e)}catch{}let n=e.replace(/^\uFEFF/,``);return matter(n.trimStart().startsWith(`---`)?n:`---\n${n}\n---`).data??{}}function extractServerUrl(t,r){let i=t.servers;if(isArray(i))for(let t of i){if(!isObject(t)||typeof t.url!=`string`||t.url.length===0)continue;let n=isObject(t.variables)?substituteServerVariables(t.url,t.variables):t.url;if(n.startsWith(`http://`)||n.startsWith(`https://`))return n;if(typeof r==`string`&&URL.canParse(r))try{return new URL(n,r).toString()}catch{}}}function substituteServerVariables(t,n){return t.replace(/\{([^}]+)\}/g,(t,r)=>{let i=n[r];return isObject(i)&&typeof i.default==`string`?i.default:t})}export{extractServerUrl,parseSpecDocument};
1
+ import{isObject}from"#shared/guards.js";import matter from"#compiled/gray-matter/index.js";import{isArray}from"#runtime/connections/openapi-schema.js";function parseSpecDocument(e){try{return JSON.parse(e)}catch{}let n=e.replace(/^\uFEFF/,``);return matter(n.trimStart().startsWith(`---`)?n:`---\n${n}\n---`).data??{}}function extractServerUrl(e,t){let n=extractOpenApiServerUrl(e,t);return n===void 0?extractSwaggerBaseUrl(e,t):n}function extractOpenApiServerUrl(t,r){let i=t.servers;if(isArray(i))for(let t of i){if(!isObject(t)||typeof t.url!=`string`||t.url.length===0)continue;let n=isObject(t.variables)?substituteServerVariables(t.url,t.variables):t.url;if(n.startsWith(`http://`)||n.startsWith(`https://`))return n;if(typeof r==`string`&&URL.canParse(r))try{return new URL(n,r).toString()}catch{}}}function extractSwaggerBaseUrl(e,t){let n=typeof e.basePath==`string`?e.basePath:``,r=typeof e.host==`string`&&e.host.length>0?e.host:``,i=typeof t==`string`&&URL.canParse(t)?new URL(t):void 0,a=extractSwaggerScheme(e)??i?.protocol.replace(/:$/,``)??`https`;if(r.length>0)return`${a}://${r}${normalizeBasePath(n)}`;if(i!==void 0){let e=new URL(normalizeBasePath(n)||`/`,i.origin).toString();return e.endsWith(`/`)&&normalizeBasePath(n).length===0?e.slice(0,-1):e}}function extractSwaggerScheme(e){let t=e.schemes;if(isArray(t)){for(let e of t)if(e===`https`||e===`http`)return e}}function normalizeBasePath(e){let t=e.trim();return t.length===0||t===`/`?``:t.startsWith(`/`)?t:`/${t}`}function substituteServerVariables(t,n){return t.replace(/\{([^}]+)\}/g,(t,r)=>{let i=n[r];return isObject(i)&&typeof i.default==`string`?i.default:t})}export{extractServerUrl,parseSpecDocument};
@@ -1,2 +1,2 @@
1
- function formatConnectionsSection(e){return[`## Connections`,``,`You have direct access to the following external services through connected MCP servers.`,`When the user's request relates to any of these services, use them instead of web search or general knowledge.`,``,`Available connections:`,...e.map(e=>`- ${e.connectionName}: ${e.description}`),``,`Use connection__search to discover specific tools within a connection. Discovered tools become directly callable by their qualified name (e.g. connection__linear__list_issues) in your next response.`].join(`
1
+ function formatConnectionsSection(e){return[`## Connections`,``,`You have direct access to the following external services through connected MCP servers and OpenAPI HTTP APIs.`,`When the user's request relates to any of these services, use them instead of web search or general knowledge.`,``,`Available connections:`,...e.map(e=>`- ${e.connectionName}: ${e.description}`),``,`Use connection__search to discover specific tools within a connection. Discovered tools become directly callable by their qualified name (e.g. connection__linear__list_issues) in your next response.`].join(`
2
2
  `)}export{formatConnectionsSection};
@@ -1,4 +1,4 @@
1
- import{getPackageManagerStrategy}from"../../primitives/pm/index.js";import{pinnedNodeEngineMajor}from"../../node-engine.js";import{pathExists,writeTextFile}from"../files.js";import{resolveVersionToken}from"../version-tokens.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{basename,join,resolve}from"node:path";import{mkdir,readdir,stat}from"node:fs/promises";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,ALLOWED_CREATE_IN_PLACE_ENTRIES=new Set([`.DS_Store`,`.git`,`.gitkeep`,`.hg`]),DEFAULT_AI_PACKAGE_VERSION=`7.0.0-beta.178`,DEFAULT_CONNECT_PACKAGE_VERSION=`0.2.2`,DEFAULT_ZOD_PACKAGE_VERSION=`4.4.3`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.9.5`,nodeEngine:`>=24`};function resolveEvePackageContract(e=DEFAULT_EVE_PACKAGE_CONTRACT){return{version:resolveVersionToken(`evePackage.version`,e.version),nodeEngine:resolveVersionToken(`evePackage.nodeEngine`,e.nodeEngine)}}function modelProviderSlug(e){let t=(e.split(`/`)[0]??``).replaceAll(/[^A-Za-z0-9._-]/gu,``);return t.length>0?t:`anthropic`}function byokProviderEnvVar(e){let t=modelProviderSlug(e).toUpperCase().replaceAll(/[^A-Z0-9]/gu,`_`);return`${/^[0-9]/.test(t)?`_`:``}${t}_API_KEY`}function agentTemplateFiles(e){return{"agent/agent.ts":BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e),"agent/channels/eve.ts":WEB_APP_TEMPLATE_FILES[`agent/channels/eve.ts`],"agent/instructions.md":AGENT_INSTRUCTIONS_TEMPLATE}}function renderTemplate(e,t){return e.replaceAll(`__EVE_INIT_APP_NAME__`,t.appName).replaceAll(`__EVE_INIT_MODEL__`,t.model).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(t.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(t.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(t.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,t.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,t.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,t.zodPackageVersion).replaceAll(`__EVE_INIT_TSGO_VERSION__`,t.tsgoPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,t.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,t.nodeEngine)}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}const BASE_AGENT_TEMPLATE=`import { defineAgent } from "eve";
1
+ import{getPackageManagerStrategy}from"../../primitives/pm/index.js";import{pinnedNodeEngineMajor}from"../../node-engine.js";import{pathExists,writeTextFile}from"../files.js";import{resolveVersionToken}from"../version-tokens.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{basename,join,resolve}from"node:path";import{mkdir,readdir,stat}from"node:fs/promises";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,ALLOWED_CREATE_IN_PLACE_ENTRIES=new Set([`.DS_Store`,`.git`,`.gitkeep`,`.hg`]),DEFAULT_AI_PACKAGE_VERSION=`7.0.0-beta.178`,DEFAULT_CONNECT_PACKAGE_VERSION=`0.2.2`,DEFAULT_ZOD_PACKAGE_VERSION=`4.4.3`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.9.8`,nodeEngine:`>=24`};function resolveEvePackageContract(e=DEFAULT_EVE_PACKAGE_CONTRACT){return{version:resolveVersionToken(`evePackage.version`,e.version),nodeEngine:resolveVersionToken(`evePackage.nodeEngine`,e.nodeEngine)}}function modelProviderSlug(e){let t=(e.split(`/`)[0]??``).replaceAll(/[^A-Za-z0-9._-]/gu,``);return t.length>0?t:`anthropic`}function byokProviderEnvVar(e){let t=modelProviderSlug(e).toUpperCase().replaceAll(/[^A-Z0-9]/gu,`_`);return`${/^[0-9]/.test(t)?`_`:``}${t}_API_KEY`}function agentTemplateFiles(e){return{"agent/agent.ts":BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e),"agent/channels/eve.ts":WEB_APP_TEMPLATE_FILES[`agent/channels/eve.ts`],"agent/instructions.md":AGENT_INSTRUCTIONS_TEMPLATE}}function renderTemplate(e,t){return e.replaceAll(`__EVE_INIT_APP_NAME__`,t.appName).replaceAll(`__EVE_INIT_MODEL__`,t.model).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(t.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(t.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(t.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,t.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,t.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,t.zodPackageVersion).replaceAll(`__EVE_INIT_TSGO_VERSION__`,t.tsgoPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,t.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,t.nodeEngine)}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}const BASE_AGENT_TEMPLATE=`import { defineAgent } from "eve";
2
2
 
3
3
  export default defineAgent({
4
4
  model: "__EVE_INIT_MODEL__",
package/docs/README.md CHANGED
@@ -90,5 +90,5 @@ That is why Eve exposes two identifiers:
90
90
 
91
91
  ## Good companions in this repo
92
92
 
93
- - Weather-focused smoke/dev fixture: [`../../apps/fixtures/weather-fixture`](../../apps/fixtures/weather-fixture)
93
+ - Weather-focused smoke/dev fixture: [`../../apps/fixtures/weather-agent`](../../apps/fixtures/weather-agent)
94
94
  - Public API source of truth: [`../../packages/eve/src/public/index.ts`](../../packages/eve/src/public/index.ts)
@@ -19,7 +19,7 @@ React, Vue, and Svelte apps reach for [`useEveAgent()`](../guides/frontend/overv
19
19
  ## Start a session
20
20
 
21
21
  ```bash
22
- curl -X POST http://127.0.0.1:3000/eve/v1/session \
22
+ curl -X POST http://127.0.0.1:2000/eve/v1/session \
23
23
  -H 'content-type: application/json' \
24
24
  -d '{"message":"Summarize the latest forecast."}'
25
25
  ```
@@ -29,7 +29,7 @@ Eve responds right away. The JSON body carries a `sessionId` and a `continuation
29
29
  ## Stream a session
30
30
 
31
31
  ```bash
32
- curl http://127.0.0.1:3000/eve/v1/session/<sessionId>/stream
32
+ curl http://127.0.0.1:2000/eve/v1/session/<sessionId>/stream
33
33
  ```
34
34
 
35
35
  The stream is newline-delimited JSON (NDJSON), one event per line:
@@ -75,7 +75,7 @@ A delegated subagent publishes progress on its own child-session stream. The par
75
75
  Once the session is waiting (you'll see `session.waiting`), POST your follow-up to the session endpoint with the stored continuation token:
76
76
 
77
77
  ```bash
78
- curl -X POST http://127.0.0.1:3000/eve/v1/session/<sessionId> \
78
+ curl -X POST http://127.0.0.1:2000/eve/v1/session/<sessionId> \
79
79
  -H 'content-type: application/json' \
80
80
  -d '{"continuationToken":"<token>","message":"Now send the short version."}'
81
81
  ```
@@ -89,7 +89,7 @@ For deterministic ordering, send one follow-up at a time and wait for the next `
89
89
  The stream is durable. Every event is recorded before a step completes, so it's all replayable. Pass `startIndex` to reconnect by event count and pick up where you dropped off, or rewind to the start:
90
90
 
91
91
  ```bash
92
- curl "http://127.0.0.1:3000/eve/v1/session/<sessionId>/stream?startIndex=<count>"
92
+ curl "http://127.0.0.1:2000/eve/v1/session/<sessionId>/stream?startIndex=<count>"
93
93
  ```
94
94
 
95
95
  ## Use the client from TypeScript
@@ -103,7 +103,7 @@ Start with the [TypeScript SDK](../guides/client/overview) guide. It covers basi
103
103
  `GET /eve/v1/info` returns a JSON inspection snapshot for the running agent: model, instructions, authored and framework tools, skills, channels, schedules, subagents, sandbox, connections, hooks, workflow, and workspace metadata. Local development accepts loopback requests; deployed Vercel targets require the route's OIDC auth.
104
104
 
105
105
  ```bash
106
- curl http://127.0.0.1:3000/eve/v1/info
106
+ curl http://127.0.0.1:2000/eve/v1/info
107
107
  ```
108
108
 
109
109
  The route uses the same default auth chain as the eve channel (`[localDev(), vercelOidc()]`). Locally it answers anonymously; a deployed Vercel target requires a valid OIDC bearer, with a same-project bypass for in-deployment callers. See [auth & route protection](../guides/auth-and-route-protection).
@@ -88,7 +88,7 @@ export default defineMcpClientConnection({
88
88
 
89
89
  ## OpenAPI connections
90
90
 
91
- `defineOpenAPIConnection` turns any OpenAPI 3.x document into connection tools, one per operation. Pass an HTTPS URL Eve fetches at runtime, or an inline parsed object:
91
+ `defineOpenAPIConnection` turns any OpenAPI 3.x or Swagger 2.0 document into connection tools, one per operation. Pass an HTTPS URL Eve fetches at runtime, or an inline parsed object:
92
92
 
93
93
  ```ts title="agent/connections/petstore.ts"
94
94
  import { defineOpenAPIConnection } from "eve/connections";
@@ -104,10 +104,10 @@ Each operation becomes `connection__<connection>__<operationId>` (e.g. `connecti
104
104
 
105
105
  `auth`, `headers`, and `approval` work exactly as they do for MCP. There are two fields specific to OpenAPI:
106
106
 
107
- | Field | Purpose |
108
- | ------------ | ----------------------------------------------------------------------------------------------------------------------- |
109
- | `baseUrl` | Base URL operation paths resolve against. Optional; defaults to the document's first usable `servers` entry. |
110
- | `operations` | Filter keyed on `operationId` (`allow` or `block`). Mirrors `tools` on MCP connections, but names operations not tools. |
107
+ | Field | Purpose |
108
+ | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
109
+ | `baseUrl` | Base URL operation paths resolve against. Optional; defaults to the document's first usable `servers` entry or Swagger `schemes`/`host`/`basePath`. |
110
+ | `operations` | Filter keyed on `operationId` (`allow` or `block`). Mirrors `tools` on MCP connections, but names operations not tools. |
111
111
 
112
112
  ## Interactive OAuth via Vercel Connect
113
113
 
@@ -109,7 +109,7 @@ The same CLI can point at a deployment. `eve dev https://your-app.vercel.app` dr
109
109
  Every Eve app exposes the same stable HTTP API. Start a durable session:
110
110
 
111
111
  ```bash
112
- curl -X POST http://127.0.0.1:3000/eve/v1/session \
112
+ curl -X POST http://127.0.0.1:2000/eve/v1/session \
113
113
  -H 'content-type: application/json' \
114
114
  -d '{"message":"What is the weather in Brooklyn?"}'
115
115
  ```
@@ -124,7 +124,7 @@ The response comes back with two things you'll reuse:
124
124
  Attach to the session stream:
125
125
 
126
126
  ```bash
127
- curl http://127.0.0.1:3000/eve/v1/session/<sessionId>/stream
127
+ curl http://127.0.0.1:2000/eve/v1/session/<sessionId>/stream
128
128
  ```
129
129
 
130
130
  The stream is NDJSON, one lifecycle event per line. See [Sessions, runs & streaming](./concepts/sessions-runs-and-streaming) for the full list of events and what each one carries.
@@ -134,7 +134,7 @@ The stream is NDJSON, one lifecycle event per line. See [Sessions, runs & stream
134
134
  When the session is waiting for the next user message, post a follow-up with the token:
135
135
 
136
136
  ```bash
137
- curl -X POST http://127.0.0.1:3000/eve/v1/session/<sessionId> \
137
+ curl -X POST http://127.0.0.1:2000/eve/v1/session/<sessionId> \
138
138
  -H 'content-type: application/json' \
139
139
  -d '{"continuationToken":"<token>","message":"Now do Queens."}'
140
140
  ```
@@ -152,12 +152,7 @@ If a coding agent (Claude Code, Cursor, and the like) is doing the setup, hand i
152
152
  the user the dev command instead of starting the interactive server.
153
153
  </CopyPrompt>
154
154
 
155
- Once `eve` is a dependency, the full docs are bundled in the package, so the agent can read them locally without fetching anything:
156
-
157
- - Docs: `node_modules/eve/docs/`
158
-
159
- `eve init [name]` creates the base agent; `eve init`, `eve init .`, and `eve init ./` do the same in the current empty directory; `eve init .` adds one to a non-empty existing app. Add `--channel-web-nextjs` for Web Chat, or run
160
- `eve channels add slack` later from an interactive terminal.
155
+ Once `eve` is installed, the complete docs ship at `node_modules/eve/docs/`, so the agent can read them locally instead of fetching anything.
161
156
 
162
157
  ## What to read next
163
158
 
@@ -12,7 +12,7 @@ Pass a string to `send()` for plain text:
12
12
  ```ts
13
13
  import { Client } from "eve/client";
14
14
 
15
- const client = new Client({ host: "http://127.0.0.1:3000" });
15
+ const client = new Client({ host: "http://127.0.0.1:2000" });
16
16
  const session = client.session();
17
17
 
18
18
  const response = await session.send("What is the weather in Brooklyn?");
@@ -26,7 +26,7 @@ const outputSchema = {
26
26
  required: ["title", "count"],
27
27
  } as const;
28
28
 
29
- const client = new Client({ host: "http://127.0.0.1:3000" });
29
+ const client = new Client({ host: "http://127.0.0.1:2000" });
30
30
  const session = client.session();
31
31
 
32
32
  const response = await session.send<Summary>({