eve 0.11.9 → 0.11.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/src/cli/banner.js +1 -1
- package/dist/src/cli/commands/init-git.d.ts +1 -1
- package/dist/src/cli/commands/init-git.js +1 -1
- package/dist/src/cli/commands/init.d.ts +1 -0
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/tui/line-editor.d.ts +53 -19
- package/dist/src/cli/dev/tui/line-editor.js +6 -1
- package/dist/src/cli/dev/tui/live-region.d.ts +2 -0
- package/dist/src/cli/dev/tui/live-region.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +3 -0
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/setup-panel.js +3 -3
- package/dist/src/cli/dev/tui/setup-selection-input.js +2 -1
- package/dist/src/cli/dev/tui/stream-format.d.ts +21 -2
- package/dist/src/cli/dev/tui/stream-format.js +4 -2
- package/dist/src/cli/dev/tui/terminal-renderer.js +10 -10
- package/dist/src/cli/dev/tui/terminal-text.d.ts +11 -0
- package/dist/src/cli/dev/tui/terminal-text.js +1 -1
- package/dist/src/cli/dev/tui/theme.d.ts +2 -0
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/cli/dev/tui/tui.d.ts +3 -0
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/format-elapsed.d.ts +2 -0
- package/dist/src/cli/format-elapsed.js +1 -0
- package/dist/src/cli/run.d.ts +4 -18
- package/dist/src/cli/run.js +2 -2
- package/dist/src/cli/ui/live-row.d.ts +19 -0
- package/dist/src/cli/ui/live-row.js +1 -0
- package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
- package/dist/src/evals/assertions/run.d.ts +7 -1
- package/dist/src/evals/assertions/run.js +2 -2
- package/dist/src/evals/context.js +1 -1
- package/dist/src/evals/index.d.ts +1 -1
- package/dist/src/evals/match.d.ts +6 -0
- package/dist/src/evals/types.d.ts +3 -1
- package/dist/src/harness/code-mode.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/dev-boot-progress.d.ts +13 -0
- package/dist/src/internal/dev-boot-progress.js +1 -0
- package/dist/src/internal/logging.d.ts +9 -0
- package/dist/src/internal/logging.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.d.ts +2 -5
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/types.d.ts +6 -0
- package/dist/src/internal/nitro/host.d.ts +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +2 -2
- package/dist/src/runtime/framework-tools/skill.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/skills/sandbox-access.d.ts +3 -2
- package/dist/src/runtime/skills/sandbox-access.js +1 -1
- package/dist/src/setup/cli/select-state.js +1 -1
- package/dist/src/setup/primitives/pm/npm.js +1 -1
- package/dist/src/setup/primitives/pm/run.js +1 -1
- package/dist/src/setup/primitives/pm/types.d.ts +2 -0
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/slack-connect-create.js +1 -1
- package/dist/src/setup/slackbot.js +1 -1
- package/dist/src/shared/text-boundaries.d.ts +19 -0
- package/dist/src/shared/text-boundaries.js +1 -0
- package/docs/evals/assertions.mdx +1 -0
- package/docs/guides/dev-tui.md +10 -7
- package/docs/guides/dynamic-capabilities.md +2 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`);if(this.#b){t!==this.#x&&(this.#x=t,this.#
|
|
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
|
-
`),a=i===-1?r:r.slice(i+1);if(e===`stdout`?this.#
|
|
5
|
-
`);t=[],e.trim().length!==0&&this.#
|
|
6
|
-
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#
|
|
7
|
-
`),n=t.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(n===-1){this.#
|
|
8
|
-
`);r.trim().length>0&&this.#
|
|
9
|
-
`);this.#
|
|
10
|
-
`)}function formatQuestionContent(e,t,
|
|
1
|
+
import{clipVisible,renderInputText,stripAnsi,stripTerminalControls}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,layoutPromptInput,lineOf,movePromptLine,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,isIncompletePaste,nextKey,sanitizePastedText,stripPasteStart,stripPromptControlCharacters,takeUntil}from"./stream-format.js";import{toErrorMessage}from"#shared/errors.js";import{StringDecoder}from"node:string_decoder";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=new StringDecoder(`utf8`);#G;#K;#q;#J=!1;#Y=!1;#X;#Z;#Q;#$;#ee;#te;#ne;#re=``;#ie=``;#ae;#oe;#se=0;#ce;#le;#ue;#de;#fe;setupFlow={begin:e=>this.#ge(e),end:e=>this.#_e(e?.preserveDiagnostics??!0),readSelect:e=>this.#ve(e),readEditableSelect:e=>this.#be(e),readText:e=>this.#xe(e),readAcknowledge:e=>this.#Se(e),readChoice:e=>this.#ye(e),setStatus:e=>this.#Ae(e),renderLine:(e,t)=>this.#je(e,t),renderOutput:e=>this.#Me(e),waitForInterrupt:()=>this.#De()};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.#Q=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.#Ne();let t=this.#pt().join(`
|
|
2
|
+
`);if(this.#b){t!==this.#x&&(this.#x=t,this.#qe({kind:`agent-header`,body:t,live:!1})),this.#ct();return}this.#b=!0,this.#x=t,this.#n.flush(this.#pt(),[])}async readPrompt(e){this.#Ne(e),this.#k=!0,this.#j=!1,this.#M=``;let t=lineOf(stripPromptControlCharacters(e?.initialDraft??``));return this.#O.begin(t.text),this.#pe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,t.text),this.#He(),this.#ct(),await new Promise((e,n)=>{let apply=e=>{t=e,this.#We(),this.#pe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,e.text,this.#A),this.#ct()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#A=void 0,this.#Ue(),this.#Pe(),n(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=n=>{let i=applyLineEditorKey(t,n,{multiline:!0});if(i!==void 0){apply(i);return}switch(n.type){case`up`:{let e=suggestions();if(e!==void 0){this.#A=moveTypeaheadSelection(e,-1),this.#ct();break}let n=movePromptLine(t,`up`);n===void 0?recall(this.#O.previous(t.text)):apply(n);break}case`down`:{let e=suggestions();if(e!==void 0){this.#A=moveTypeaheadSelection(e,1),this.#ct();break}let n=movePromptLine(t,`down`);n===void 0?recall(this.#O.next()):apply(n);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.#ct());break}case`enter`:{let n=highlighted(),i=n!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(n).trimEnd():t.text;this.#A=void 0,this.#O.add(i),this.#k=!1,this.#Ue(),this.#M=STATUS.processing,isPromptControlCommand(i)?this.#qe({kind:`command`,body:stripTerminalControls(i.trim()),live:!1}):(this.#Je(i),this.#ce=i),this.#pe(EMPTY_LINE),this.#ct(),this.#Ie(),e(i);break}case`ctrl-d`:t.text.length===0?interrupt():apply(deleteForward(t));break;case`ctrl-l`:this.#dt();break;case`ctrl-r`:this.#ct();break;case`ctrl-c`:t.text.length===0?interrupt():apply(EMPTY_LINE);break;default:break}},this.#Fe()})}#pe(e){this.#E=e.text,this.#D=e.cursor}async renderStream(e,t){this.#Ne(t),this.#m.clear(),this.#k=!1,this.#j=!0,this.#M=STATUS.processing,this.#Ye(t?.submittedPrompt),this.#F=!1,this.#X=void 0,this.#Z=void 0,this.#$=void 0,this.#ee=void 0,this.#te=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#Ge(),this.#ct();let r=new Promise(e=>{this.#q=e});this.#H=e=>this.#Ve(e),this.#Fe();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.#tt(t,n,i)}}catch(e){this.#Xe(`Error`,toErrorMessage(e))}finally{this.#q=void 0,this.#F&&e.abort?.(),this.#Ie(),this.#Ke(),this.#j=!1,this.#M=completedTurnStatus(this.#F,t?.continueSession===!0),this.#et(),this.#ct(),t?.continueSession||this.#Pe()}}async readToolApproval(e,t){return this.#Ne(t),this.#k=!1,this.#j=!1,this.#M=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#F=!1,this.#ct(),await new Promise((t,n)=>{this.#H=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#M=STATUS.processing,this.#Ie(),this.#ct(),t({approved:!0})):n===`n`&&(this.#M=STATUS.processing,this.#me(e.toolCallId),this.#Ie(),this.#ct(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#ct();break;case`ctrl-c`:this.#F=!0,this.#Pe(),n(interruptedError());break;default:break}},this.#Fe()})}async readInputQuestion(e,t){this.#Ne(t),this.#k=!1,this.#j=!1,this.#F=!1;let n=e.options??[],i=n.length>0,a=(e.allowFreeform===!0||!i)&&i,o=n.length+ +!!a,s=questionSectionId(e.requestId),c=i?`select`:`text`,l=0,u=EMPTY_LINE,isOnFreeformRow=()=>a&&l===n.length,renderSection=()=>{this.#Qe({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.#pe(u),this.#M=``;this.#ct()};renderSection(),c===`text`&&this.#He(),repaintStatus();let finalize=t=>{this.#Qe({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.#Ue(),this.#Ie(),this.#ct();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n};return await new Promise((t,r)=>{this.#H=a=>{if(a.type===`ctrl-c`){if(c===`text`&&u.text.length>0){u=EMPTY_LINE,this.#We(),repaintStatus();return}this.#F=!0,this.#Ue(),this.#Pe(),r(interruptedError());return}if(a.type===`ctrl-r`){this.#ct();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=EMPTY_LINE,this.#He(),repaintStatus();break}let e=n[l];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}let s=applyLineEditorKey(u,a,{multiline:!0});if(s!==void 0){u=s,this.#We(),repaintStatus();return}switch(a.type){case`up`:case`down`:{let e=movePromptLine(u,a.type);e!==void 0&&(u=e,this.#We(),repaintStatus());break}case`enter`:{let n=resolveQuestionText(u.text,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(i){if(u.text.length>0){u=EMPTY_LINE,this.#We(),repaintStatus();break}c=`select`,u=EMPTY_LINE,this.#k=!1,this.#Ue(),repaintStatus();break}u=EMPTY_LINE,this.#We(),repaintStatus();break;default:break}},this.#Fe()})}upsertSubagentStep(e){if(this.#o===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&n.length===0)){if(this.#Ze(e.callId,e.subagentName),this.#o===`collapsed`){this.#ct();return}this.#Qe({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:n,live:!e.finalized}),this.#ct()}}upsertSubagentTool(e){if(this.#o===`hidden`)return;if(this.#Ze(e.callId,e.subagentName),this.#o===`collapsed`){this.#ct();return}let t=subagentToolStatus(e.status),n={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,depth:1,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:t,live:t===`running`||t===`approval`,expanded:this.#o===`full`,toolInput:e.input};e.output===void 0?e.errorText!==void 0&&(n.result=stripTerminalControls(e.errorText)):(n.result=summarizeToolResult(e.output),n.toolOutput=e.output),this.#Qe(n),this.#ct()}markChildToolCallId(e){this.#g.add(e);let t=this.#_.get(e);t!==void 0&&(this.#$e(t),this.#_.delete(e),this.#ct())}#me(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.#Qe({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e),preformatted:!0,live:!t}),this.#ct()}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.#ct()):n&&(this.#M=STATUS.processing,this.#ct())}setVercelStatus(e){this.#T=e,this.#ct()}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.#ce=void 0,this.#oe=void 0,this.#w=0,this.#X=void 0,this.#Z=void 0,this.#$=void 0,this.#ee=void 0,this.#te=void 0,this.#P&&(this.#n.clearAll(),this.#ct())}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Ne(),this.#qe({kind:`notice`,body:t,live:!1}),this.#ct())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#Ne(),this.#qe({kind:`sandbox`,body:t,live:!1}),this.#ct())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#he();return}this.#Ne(),this.#ue=t,this.#ct()}clearSetupWarning(){this.#he()}#he(){this.#ue!==void 0&&(this.#ue=void 0,this.#ct())}renderCommandResult(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Ne(),this.#qe({kind:`result`,body:t,live:!1}),this.#ct())}#ge(e){this.#Ne(),this.#k=!1,this.#j=!1,this.#M=``,this.#le={title:stripTerminalControls(e),lines:[],outputBuffer:[]},this.#Ge(),this.#ct()}#_e(e){this.#de=void 0,this.#ke();let t=this.#le;if(t!==void 0){if(this.#le=void 0,this.#Ke(),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.#qe({kind:`flow`,title:`info`,body:e.join(`
|
|
3
|
+
`),live:!1}),this.#qe({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#ct()}}async#ve(e){let t=this.#Ce(),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.#ct(),await this.#Ee((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.#ct();return;case`update`:i=s.select,a=void 0,this.#ct();return;case`submit`:r(s.values);return;case`error`:a=s.message,this.#ct();return;case`ignore`:return}}).promise}#ye(e){this.#Ne();let t=this.#we();t.status=e.status;let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#r,t),this.#ct();let r=this.#Ee((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.#ct();return;case`repaint`:this.#ct();return;case`submit`:n!==void 0&&r(e.actions[n].value);return;case void 0:return}},()=>{t.status=void 0});return{choice:r.promise,close:()=>r.settle(void 0)}}async#be(e){let t=this.#Ce(),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.#He()):(i=lineOf(``),this.#Ue())};return syncEditableRow(),this.#ct(),await this.#Ee((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#We(),this.#ct()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#ct()},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.#ct();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.#ct();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Ue()).promise}async#xe(e){let t=this.#Ce(),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.#He(),this.#ct(),await this.#Ee((t,i)=>{let apply=e=>{n=e,r=void 0,this.#We(),this.#ct()},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.#ct();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#ct();return}i(t);return}default:return}},()=>this.#Ue()).promise}async#Se(e){let t=this.#Ce();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#ct(),await this.#Ee((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#ct();return;default:return}}).promise}#Ce(){return this.#Ne(),this.#k=!1,this.#j=!1,this.#M=``,this.#we()}#we(){return this.#le===void 0&&(this.#le={title:``,lines:[],outputBuffer:[]}),this.#le}#Te(){this.#le!==void 0&&(this.#le.question=void 0,this.#le.hideLinesWhileQuestion=!1),this.#H=void 0,this.#Ie(),this.#Oe(),this.#ct()}#Ee(e,t){let n=!1,r,i=new Promise(e=>{r=e}),settle=e=>{n||(n=!0,t?.(),this.#Te(),r(e))};return this.#H=t=>e(t,settle),this.#Fe(),{promise:i,settle}}#De(){let e,t=new Promise(t=>{e=t});return this.#de=e,this.#Oe(),{promise:t,dispose:()=>{this.#de===e&&(this.#de=void 0,this.#ke())}}}#Oe(){if(this.#de===void 0)return;let consumer=e=>{if(e.type===`ctrl-c`||e.type===`escape`){let e=this.#de;this.#de=void 0,this.#ke(),e?.();return}e.type===`ctrl-r`&&this.#ct()};this.#fe=consumer,this.#H=consumer,this.#Fe()}#ke(){this.#fe!==void 0&&(this.#H===this.#fe&&this.#Ie(),this.#fe=void 0)}#Ae(e){let t=e===void 0?void 0:stripTerminalControls(e);if(this.#le!==void 0){this.#le.status=t,t===void 0&&(this.#le.preview=void 0),this.#ct();return}if(t===void 0){this.#j=!1,this.#M=``,this.#Ke(),this.#ct();return}this.#Ne(),this.#j=!0,this.#M=t,this.#Ge(),this.#ct()}#je(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let i=this.#le;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:n,tone:t}),this.#ct();return}this.#Ne(),this.#qe({kind:`flow`,title:t,body:n,live:!1}),this.#ct()}#Me(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#le;if(n===void 0){this.#je(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#ct()}shutdown(){this.#Pe()}#Ne(e){this.#N=e?.title??this.#N,this.#Q=e?.contextSize??this.#l,!this.#P&&(this.#P=!0,this.#n.reset(),this.#n.hideCursor(),this.#xt(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#K=()=>this.#ct(),this.#t.on(`resize`,this.#K))}#Pe(){this.#Ie(),this.#Ue(),this.#Ke(),this.#B!==void 0&&(clearTimeout(this.#B),this.#B=void 0),this.#V=!1,this.#P&&=(this.#kt(),this.#ct(),this.#n.clear(),this.#n.showCursor(),this.#St(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#K&&=(this.#t.off(`resize`,this.#K),void 0),!1)}#Fe(){this.#e.off(`data`,this.#Le),this.#e.on(`data`,this.#Le)}#Ie(){this.#e.off(`data`,this.#Le),this.#Be(),this.#U=``,this.#W=new StringDecoder(`utf8`),this.#H=void 0}#Le=e=>{this.#Be(),this.#U+=this.#W.write(e),this.#ze(),this.#Re()};#Re(){if(this.#U===`\x1B`){this.#G=setTimeout(()=>{this.#U===`\x1B`&&(this.#U=``,this.#H?.({type:`escape`}))},30),this.#G.unref?.();return}if(isIncompletePaste(this.#U)){let e=this.#U;this.#G=setTimeout(()=>{if(this.#U!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#U=``,t.length>0&&this.#H?.({type:`text`,value:t,framing:`bracketed-paste`})},1e3),this.#G.unref?.()}}#ze(){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)}}#Be(){this.#G&&=(clearTimeout(this.#G),void 0)}#Ve(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#ct();break;case`ctrl-c`:this.#F||(this.#F=!0,this.#M=`Interrupted`,this.#q?.(),this.#ct());break;default:break}}#He(){this.#Ue(),this.#We(),this.#R=setInterval(()=>{this.#I=!this.#I,this.#ct()},500),this.#R.unref?.()}#Ue(){this.#R&&=(clearInterval(this.#R),void 0),this.#I=!0}#We(){this.#I=!0}#Ge(){this.#Ke(),this.#z=setInterval(()=>{this.#L+=1,this.#ct()},90),this.#z.unref?.()}#Ke(){this.#z&&=(clearInterval(this.#z),void 0)}#qe(e){e.id!==this.#oe?.id&&this.#kt(),this.#f.push(e),e.id&&this.#p.set(e.id,e)}#Je(e){this.#qe({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#ct()}#Ye(e){if(e!=null){if(this.#ce===e){this.#ce=void 0;return}this.#qe({kind:`user`,body:stripTerminalControls(e),live:!1})}}#Xe(e,t,n){let i={kind:`error`,title:stripTerminalControls(e),body:stripTerminalControls(t),live:!1};n!==void 0&&(i.detail=stripTerminalControls(n)),this.#qe(i),this.#ct()}#Ze(e,t){this.#v.has(e)||(this.#v.add(e),this.#qe({id:subagentHeaderId(e),kind:`subagent`,title:stripTerminalControls(t),live:!1}))}#Qe(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.#qe(e)}#$e(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#et(){for(let e of this.#f)e.status===`approval`||e.status===`running`||(e.live=!1)}#tt(e,t,n){switch(e.type){case`step-start`:this.#nt(n.hasPendingToolResults?STATUS.toolResults:STATUS.processing),n.hasPendingToolResults=!1;break;case`step-finish`:this.#st(e.usage),this.#ct();break;case`assistant-delta`:{this.#nt(STATUS.streaming);let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#rt(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,i=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;n.text.set(e.id,i),this.#rt(e.id,i,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#nt(STATUS.streaming);let i=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);n.reasoning.set(e.id,i),this.#it(e.id,i,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;this.#it(e.id,r,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#nt(STATUS.executingTools),this.#at({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#at({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#ot(e.toolCallId,n);if(r===void 0)break;n.hasPendingToolResults=!0,this.#nt(STATUS.toolResults),this.#at({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{if(t.tools===`hidden`)break;let r=this.#ot(e.toolCallId,n);if(r===void 0)break;n.hasPendingToolResults=!0,this.#nt(STATUS.toolResults),this.#at({...r,errorText:e.errorText,status:`error`},t,n);break}case`error`:this.#Xe(`Error`,e.errorText,e.detail);break;case`finish`:this.#st(e.usage),this.#ct();break}}#nt(e){let t=this.#w>0?STATUS.connectionAuth:e;this.#M!==t&&(this.#M=t,this.#ct())}#rt(e,t,n){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Qe({id:e,kind:`assistant`,body:i,live:n}),this.#ct())}#it(e,t,n,i){let a=stripTerminalControls(t).trim();a.length!==0&&(this.#Qe({id:e,kind:`reasoning`,body:a,collapsed:collapseReasoning(i.reasoning,n),live:n}),this.#ct())}#at(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.#Qe(renderNativeToolBlock(e,r,t.tools===`full`)),this.#ct()}#ot(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`}}#st(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#X=(t??0)+(n??0)),this.#Z=t??this.#Z,this.#$=n??this.#$,this.#$!=null&&this.#te!==void 0){let e=(Date.now()-this.#te)/1e3;e>0&&(this.#ee=this.#$/e)}}#ct(){if(this.#P){if(this.#J){this.#Y=!0;return}this.#J=!0;try{do this.#Y=!1,this.#lt();while(this.#Y)}finally{this.#J=!1}}}#lt(){if(!this.#P)return;let e=this.#yt(),t=this.#gt(e),n=Math.max(1,this.#bt()-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.#jt(t))continue;let n=this.#mt(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.#jt(t))continue;let n=this.#mt(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)}#ut(){if(!this.#P)return;let e=this.#yt(),t=this.#gt(e),n=Math.max(1,this.#bt()-t.length),r=this.#C,i=[];for(let t of this.#f){if(this.#jt(t))continue;let n=this.#mt(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.#pt(),...this.#S],a)}logDisplayMode(){return this.#d}setLogDisplayMode(e){e!==this.#d&&(this.#d=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#ft(),this.#P&&this.#ut())}flushDelayedDevBuildErrors(){let e=this.#ae;e!==void 0&&(this.#ae=void 0,this.#qe({kind:`log`,title:`stderr`,body:e,live:!1}),this.#ct())}#dt(){this.#V=!0,this.#B!==void 0&&clearTimeout(this.#B),this.#B=setTimeout(()=>{this.#V=!1,this.#B=void 0,this.#ct()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#d)),this.#ct()}#ft(){let e=this.#yt();this.#S.length=0;let t;for(let n of this.#h){if(this.#jt(n))continue;let r=this.#mt(n,e,t);t=previousBlockOf(n),this.#S.push(...r)}this.#C=t}#pt(){let e=this.#y;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#yt()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#mt(e,t,n){let r={spinner:this.#ht()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#ht(){return this.#r.spinner[this.#L%this.#r.spinner.length]??``}#gt(e){let t=this.#r.colors,n=[``],r=this.#le;if(r!==void 0){let t=this.#ht(),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.#ue!==void 0&&n.push(...renderAttentionRows(this.#ue,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=isPromptControlCommand(this.#E),a=r?t.dim(` ${r}`):``,o=[];this.#_t(o,e);let s=Math.max(1,this.#bt()-1-n.length-1-o.length);return n.push(...promptInputRows({text:this.#E,cursor:this.#D,width:e,theme:this.#r,caretVisible:this.#I,isCommand:i,ghost:a,maxRows:s})),n.push(...o),n}let i=this.#j?t.yellow(this.#ht()):t.dim(this.#r.glyph.dot),a=this.#M.length>0?this.#M:`Ready`,o=this.#j?t.dim(a):a,s=this.#vt(),l=s?`${i} ${o} ${t.dim(this.#r.glyph.dot)} ${s}`:`${i} ${o}`;return n.push(clip(l,e)),this.#_t(n,e),n}#_t(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.#Z??0,o=this.#$??0;if(a>0||o>0){let e={inputTokens:a,outputTokens:o};this.#Q!==void 0&&(e.contextSize=this.#Q),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)}#vt(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#X,outputTokens:this.#$,tokensPerSecond:this.#ee},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#yt(){return Math.max(20,this.#t.columns||80)}#bt(){return Math.max(8,this.#t.rows||24)}#xt(){if(this.#ne!==void 0||!this.#u)return;this.#re=``,this.#ie=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#Ct(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#ne=()=>{e(),t()}}#St(){let e=this.#ne;e!==void 0&&(this.#ne=void 0,e(),this.#re.length>0&&(this.#At(`stdout`)&&process.stdout.write(`${this.#re}\n`),this.#re=``),this.#ie.length>0&&(this.#At(`stderr`)&&process.stderr.write(`${this.#ie}\n`),this.#ie=``))}#Ct(e,t){let r=(e===`stdout`?this.#re:this.#ie)+t,i=r.lastIndexOf(`
|
|
4
|
+
`),a=i===-1?r:r.slice(i+1);if(e===`stdout`?this.#re=a:this.#ie=a,i===-1)return;let o=stripAnsi(r.slice(0,i)).replace(/\s+$/u,``);o.trim().length!==0&&(e===`stdout`?this.#wt(o):this.#Tt(o),this.#ct())}#wt(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
|
|
5
|
+
`);t=[],e.trim().length!==0&&this.#qe({kind:`log`,title:`stdout`,body:e,live:!1})};for(let n of e.split(`
|
|
6
|
+
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#qe({kind:`sandbox`,body:e,live:!1});continue}let r=parseDevRebuildLogLine(n.trimEnd());if(r===void 0){t.push(n);continue}flushPending(),this.#Dt(r,n.trimEnd())}flushPending()}#Tt(e){let t=e.split(`
|
|
7
|
+
`),n=t.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(n===-1){this.#qe({kind:`log`,title:`stderr`,body:e,live:!1});return}let r=t.slice(0,n).join(`
|
|
8
|
+
`);r.trim().length>0&&this.#qe({kind:`log`,title:`stderr`,body:r,live:!1});let i=t.slice(n).join(`
|
|
9
|
+
`);this.#Et(i)}#Et(e){if(this.#d===`all`){if(e.trim().length===0)return;this.#qe({kind:`log`,title:`stderr`,body:e,live:!1});return}this.#ae=e}#Dt(e,t){let n=this.#Ot();if(e.kind===`failed`){this.#Et(t);return}if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#se}`;this.#se+=1,this.#oe={id:r,summary:t},this.#qe({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}if(n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind),e.kind===`rebuilt`&&(this.#ae=void 0);return}e.kind===`rebuilt`&&(this.#ae=void 0),this.#qe({kind:`log`,title:`stdout`,body:t,live:!1})}#Ot(){let e=this.#oe;if(e===void 0)return;let t=this.#p.get(e.id);if(!(t===void 0||t.live!==!0))return{state:e,block:t}}#kt(){let e=this.#oe;if(e===void 0)return;this.#oe=void 0;let t=this.#p.get(e.id);t!==void 0&&(t.live=!1)}#At(e){switch(this.#d){case`none`:return!1;case`stderr`:return e===`stderr`;case`sandbox`:return e===`sandbox`;case`all`:return!0}}#jt(e){return e.kind===`sandbox`?!this.#At(`sandbox`):e.kind===`log`?!this.#At(e.title===`stderr`?`stderr`:`stdout`):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}async function*iterateTUIStream(e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}return}yield*e}function clip(t,n){return clipVisible(t,n)}function promptInputRows({text:e,cursor:n,width:r,theme:i,caretVisible:a,isCommand:o,ghost:s,maxRows:c}){let l=i.colors,style=e=>{let n=renderInputText(e);return o&&n.length>0?l.blue(n):n},u=layoutPromptInput({text:e,cursor:n}),d=Math.min(Math.max(1,c),u.rows.length),f=Math.max(0,Math.min(u.caretRow-d+1,u.rows.length-d)),p=l.cyan(i.glyph.prompt),m=l.dim(i.glyph.ellipsis),h=Math.max(1,r-3),g=[];for(let e=f;e<f+d;e+=1){let n=u.rows[e],o=e===0?p:` `;(e===f&&f>0||e===f+d-1&&f+d<u.rows.length)&&(o=m);let c;if(e===u.caretRow){let{before:e,under:r,after:o}=visibleLine({text:n.text,cursor:u.caretOffset},h,i.glyph.ellipsis),d=r||` `,f=a?l.inverse(renderInputText(d)):style(d);c=`${style(e)}${f}${style(o)}`,s.length>0&&u.rows.length===1&&(c+=s)}else c=style(n.text);g.push(clip(`${o} ${c}`,r))}return g.push(``),g}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function leadsWithGap(e,t){if(e.kind===`sandbox`&&t?.kind===`sandbox`)return!1;if(t?.kind===`sandbox`&&e.kind!==`sandbox`)return!0;if(e.kind===`log`&&t?.kind===`log`)return t.title!==e.title;if(t?.kind===`log`&&e.kind!==`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`subagent`:case`error`:case`notice`:case`question`:case`connection-auth`:case`sandbox`:case`log`:case`command`:case`warning`:case`flow`:case`agent-header`:return!0;default:return!1}}function parseSandboxLogLine(e){let t=e.trim();if(!t.startsWith(`eve: `))return;let n=t.slice(5);return/\bsandbox\b/i.test(n)&&!isLowValueSandboxLogLine(n)?n:void 0}function isLowValueSandboxLogLine(e){return/^initializing (?:\d+ )?sandbox templates?\b/i.test(e)||/^initialized \d+ sandbox\b/i.test(e)||/^reused cached sandbox template\b/i.test(e)||/^sandbox template "[^"]+" \([^)]+\): (checking|reusing|loading microsandbox runtime|microsandbox runtime ready)\b/i.test(e)}function clipLiveRows(e,t,n,r){if(e.length<=t)return[...e];if(t<=1)return[clip(hiddenRowsMarker(e.length,r),n)];let i=t-1;return[clip(hiddenRowsMarker(e.length-i,r),n),...e.slice(e.length-i)]}function hiddenRowsMarker(e,t){let n=e.toLocaleString(),r=e===1?`row`:`rows`;return t.colors.dim(`${t.glyph.dot} ${t.glyph.ellipsis} ${n} earlier ${r} hidden while streaming`)}function collapseReasoning(e,t){switch(e){case`collapsed`:return!0;case`auto-collapsed`:return!t;default:return!1}}function renderNativeToolBlock(e,t,n){let o={id:t,kind:`tool`,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:e.status,live:e.status===`running`||e.status===`approval`,expanded:n,toolInput:e.input};return e.output===void 0?e.errorText!==void 0&&(o.result=stripTerminalControls(e.errorText)):(o.result=summarizeToolResult(e.output),o.toolOutput=e.output),o}function subagentToolStatus(e){switch(e){case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`}}function formatToolApprovalTitle(e){return stripTerminalControls(e.title??e.toolName)}function toolSectionId(e){return`tool:${e}`}function questionSectionId(e){return`question:${e}`}function subagentHeaderId(e){return`subagent:${e}:header`}function subagentStepSectionId(e,t){return`subagent:${e}:step:${t}`}function subagentToolSectionId(e,t){return`subagent:${e}:tool:${t}`}function connectionAuthSectionId(e){return`connection-auth:${e}`}function formatConnectionAuthContent(e){let t=[],n=stripTerminalControls(e.description);n.length>0&&t.push(n);let i=e.challenge;if(i?.url&&t.push(`URL: ${stripTerminalControls(i.url)}`),i?.userCode&&t.push(`Code: ${stripTerminalControls(i.userCode)}`),i?.expiresAt&&t.push(`Expires: ${stripTerminalControls(i.expiresAt)}`),i?.instructions&&t.push(stripTerminalControls(i.instructions)),e.reason!==void 0){let n=stripTerminalControls(e.reason);n.length>0&&t.push(`Reason: ${n}`)}return t.join(`
|
|
10
|
+
`)}function formatQuestionContent(e,t,n){let i=n.colors,a=[],o=e.options??[];if(o.length>0){for(let[e,s]of o.entries()){let o=stripTerminalControls(s.label),c=s.description===void 0?``:stripTerminalControls(s.description),l=c.length>0?` ${i.dim(`— ${c}`)}`:``,u=t===e,d=u?`${i.cyan(n.glyph.pointer)} `:` `,f=u?i.cyan(o):o;a.push(`${d}${f}${l}`)}if(e.allowFreeform===!0){let e=t===o.length,r=e?`${i.cyan(n.glyph.pointer)} `:` `,s=`Type your own answer`;a.push(`${r}${e?i.cyan(s):i.dim(s)}`)}}else a.push(i.dim(` (type your answer)`));return a.join(`
|
|
11
11
|
`)}function resolveQuestionText(e,t){let n=e.trim();if(n.length===0)return;let r=n.toLowerCase(),i=t.options??[];if(i.length>0){let e=matchQuestionOption(r,i);if(e!==void 0)return{optionId:e.id,label:e.label}}if(t.allowFreeform===!0||i.length===0)return{text:n,label:n}}function matchQuestionOption(e,t){let n=t.find(t=>t.id.toLowerCase()===e);if(n!==void 0)return n;let r=t.find(t=>t.label.toLowerCase()===e);if(r!==void 0)return r;let i=Number(e);if(Number.isInteger(i)&&i>0&&i<=t.length)return t[i-1]}export{TerminalRenderer};
|
|
@@ -4,6 +4,17 @@ export declare function stripAnsi(input: string): string;
|
|
|
4
4
|
export declare function stripTerminalControls(input: string): string;
|
|
5
5
|
export declare function visibleLength(input: string): number;
|
|
6
6
|
export declare function sliceVisible(input: string, width: number): string;
|
|
7
|
+
/** Clips text styled only at grapheme boundaries, resetting any truncated style. */
|
|
8
|
+
export declare function clipVisible(input: string, width: number): string;
|
|
9
|
+
/** Terminal-cell width of editor text, measured one grapheme cluster at a time. */
|
|
10
|
+
export declare function inputTextWidth(input: string): number;
|
|
11
|
+
/** Expands editor tabs to the same fixed four cells used by {@link inputTextWidth}. */
|
|
12
|
+
export declare function renderInputText(input: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the UTF-16 offset at or immediately before a terminal column.
|
|
15
|
+
* Graphemes stay intact even when the requested column falls inside a wide one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function offsetAtVisibleColumn(input: string, column: number): number;
|
|
7
18
|
/**
|
|
8
19
|
* Word-wraps a single logical line to `width` visible columns, preserving
|
|
9
20
|
* ANSI styling and never splitting inside an escape sequence. Breaks on the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const ansiPattern=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`),ansiPrefixPattern=RegExp(`^\x1B\\[[0-?]*[ -/]*[@-~]`);function stripAnsi(
|
|
1
|
+
import{graphemes}from"#shared/text-boundaries.js";const ansiPattern=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`),ansiPrefixPattern=RegExp(`^\x1B\\[[0-?]*[ -/]*[@-~]`),emojiPresentationPattern=/\p{Emoji_Presentation}/u,extendedPictographicPattern=/\p{Extended_Pictographic}/u,keycapPattern=/^[#*0-9]\u{fe0f}?\u{20e3}$/u;function stripAnsi(e){return stripTerminalControls(e.replaceAll(ansiPattern,``))}function stripTerminalControls(e){let t=``,n=0;for(;n<e.length;){let r=e.codePointAt(n);if(r==null)break;let i=String.fromCodePoint(r);n+=i.length,!isUnsafeTerminalControlCodePoint(r)&&(t+=i)}return t}function visibleLength(e){let t=0;for(let n of terminalTextUnits(e))t+=n.width;return t}function sliceVisible(e,t){if(t<=0)return``;let n=``,r=0,i=terminalTextUnits(e),a=0;for(;a<i.length&&r<t;){let e=i[a];if(e.width>0&&r+e.width>t)break;n+=e.text,r+=e.width,a+=1}for(;i[a]?.ansi===!0;)n+=i[a].text,a+=1;return n}function clipVisible(e,t){if(visibleLength(e)<=t)return e;let n=sliceVisible(e,t);return n.includes(`\x1B`)?`${n}[0m`:n}function inputTextWidth(t){let n=0;for(let r of graphemes(t))n+=terminalGraphemeWidth(r.text);return n}function renderInputText(e){return e.replaceAll(` `,` `)}function offsetAtVisibleColumn(t,n){if(n<=0)return 0;let r=0;for(let i of graphemes(t)){let e=r+terminalGraphemeWidth(i.text);if(e>n)return i.start;if(e===n)return i.end;r=e}return t.length}function terminalGraphemeWidth(e){let t=0;for(let n of e){let e=n.codePointAt(0);e!==void 0&&(t=Math.max(t,codePointWidth(e)))}return emojiPresentationPattern.test(e)||keycapPattern.test(e)||e.includes(`️`)&&extendedPictographicPattern.test(e)?Math.max(2,t):t}function terminalTextUnits(r){let i=[],a=0;for(;a<r.length;){let o=r.slice(a),s=o.match(ansiPrefixPattern);if(s!==null){i.push({text:s[0],width:0,ansi:!0}),a+=s[0].length;continue}let c=o.search(ansiPattern),l=o.slice(0,c===-1?o.length:c);for(let t of graphemes(l))i.push({text:t.text,width:terminalGraphemeWidth(t.text),ansi:!1});a+=l.length}return i}function wrapVisibleLine(e,t){if(t<=0)return[e];if(e.length===0)return[``];let n=[],r=e;for(;visibleLength(r)>t;){let e=findVisibleBreakPoint(r,t);n.push(r.slice(0,e).trimEnd()),r=r.slice(e).trimStart()}return(r.length>0||n.length===0)&&n.push(r),n}function findVisibleBreakPoint(e,t){let n=sliceVisible(e,t+1).lastIndexOf(` `);if(n>0)return n;let r=sliceVisible(e,t);if(visibleLength(r)>0)return r.length;let i=0,a=!1;for(let t of terminalTextUnits(e)){if(a&&t.width>0)return i;i+=t.text.length,t.width>0&&(a=!0)}return i}function codePointWidth(e){return e===9?4:e<32||e>=127&&e<160||isZeroWidthCodePoint(e)?0:isWideCodePoint(e)?2:1}function isUnsafeTerminalControlCodePoint(e){return e>=0&&e<=8||e>=11&&e<=31||e>=127&&e<=159}function isZeroWidthCodePoint(e){return e>=768&&e<=879||e>=1155&&e<=1161||e>=1425&&e<=1469||e===1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e===1479||e>=1552&&e<=1562||e>=1611&&e<=1631||e===1648||e>=1750&&e<=1756||e>=1759&&e<=1764||e>=1767&&e<=1768||e>=1770&&e<=1773||e===1809||e>=1840&&e<=1866||e>=1958&&e<=1968||e>=2027&&e<=2035||e>=2070&&e<=2073||e>=2075&&e<=2083||e>=2085&&e<=2087||e>=2089&&e<=2093||e>=2137&&e<=2139||e>=2259&&e<=2306||e===2362||e===2364||e>=2369&&e<=2376||e===2381||e>=2385&&e<=2391||e===8205||e>=65024&&e<=65039||e>=917760&&e<=917999}function isWideCodePoint(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}export{ansiPattern,ansiPrefixPattern,clipVisible,codePointWidth,inputTextWidth,offsetAtVisibleColumn,renderInputText,sliceVisible,stripAnsi,stripTerminalControls,visibleLength,wrapVisibleLine};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}[39m`}const UNICODE_GLYPHS={brand:`▲`,user:`▌`,reasoning:`○`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`◆`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`▷`,option:`◦`,prompt:`❯`,elbow:`⎿`,hrule:`▔`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown:`↓`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,option:`.`,prompt:`>`,elbow:"`-",hrule:`=`,caret:`_`,dot:`-`,ellipsis:`...`,arrowUp:`^`,arrowDown:`v`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(i={}){let a=i.color??!0,o=i.unicode??!0;return{color:a,unicode:o,colors:{reset:ansi(0,0,a),bold:ansi(1,22,a),dim:ansi(2,22,a),italic:ansi(3,23,a),white:ansi(97,39,a),gray:ansi(90,39,a),cyan:ansi(36,39,a),green:ansi(32,39,a),red:ansi(31,39,a),yellow:ansi(33,39,a),magenta:ansi(35,39,a),blue:ansi(34,39,a),orange:ansi256(208,a)},glyph:o?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:o?UNICODE_SPINNER:ASCII_SPINNER}}function detectUnicode(e=process.env){let t=e.EVE_TUI_UNICODE;return t===`0`||t===`false`?!1:t===`1`||t===`true`?!0:e.TERM===`dumb`?!1:process.platform===`win32`?!!(e.WT_SESSION||e.TERM_PROGRAM===`vscode`):!0}export{createTheme,detectUnicode};
|
|
1
|
+
function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}[39m`}const UNICODE_GLYPHS={brand:`▲`,user:`▌`,reasoning:`○`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`◆`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`▷`,option:`◦`,prompt:`❯`,elbow:`⎿`,hrule:`▔`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown:`↓`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,option:`.`,prompt:`>`,elbow:"`-",hrule:`=`,caret:`_`,dot:`-`,ellipsis:`...`,arrowUp:`^`,arrowDown:`v`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(i={}){let a=i.color??!0,o=i.unicode??!0;return{color:a,unicode:o,colors:{reset:ansi(0,0,a),bold:ansi(1,22,a),dim:ansi(2,22,a),inverse:ansi(7,27,a),italic:ansi(3,23,a),white:ansi(97,39,a),gray:ansi(90,39,a),cyan:ansi(36,39,a),green:ansi(32,39,a),red:ansi(31,39,a),yellow:ansi(33,39,a),magenta:ansi(35,39,a),blue:ansi(34,39,a),orange:ansi256(208,a)},glyph:o?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:o?UNICODE_SPINNER:ASCII_SPINNER}}function detectUnicode(e=process.env){let t=e.EVE_TUI_UNICODE;return t===`0`||t===`false`?!1:t===`1`||t===`true`?!0:e.TERM===`dumb`?!1:process.platform===`win32`?!!(e.WT_SESSION||e.TERM_PROGRAM===`vscode`):!0}export{createTheme,detectUnicode};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DevBootProgressReporter } from "#internal/dev-boot-progress.js";
|
|
1
2
|
import type { TuiDisplayOptions } from "./types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Options for running the `eve dev` terminal UI against a server URL.
|
|
@@ -20,6 +21,8 @@ export interface RunDevelopmentTuiInput extends TuiDisplayOptions {
|
|
|
20
21
|
* Applies to the first prompt only.
|
|
21
22
|
*/
|
|
22
23
|
readonly initialInput?: string;
|
|
24
|
+
/** Reports local CLI boot phases. Omitted for remote and programmatic TUI runs. */
|
|
25
|
+
readonly onBootProgress?: DevBootProgressReporter;
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* Runs the `eve dev` terminal UI against the given server URL until the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createPromptCommandHandler}from"./prompt-command-handler.js";import{EveTUIRunner}from"./runner.js";import{toErrorMessage}from"#shared/errors.js";import{Client}from"#client/index.js";import{resolveDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{formatVercelAuthChallengeMessage,isVercelAuthChallenge}from"#services/dev-client/vercel-auth-error.js";async function runDevelopmentTui(t){let{serverUrl:n,appRoot:r,initialInput:i,...
|
|
1
|
+
import{createPromptCommandHandler}from"./prompt-command-handler.js";import{EveTUIRunner}from"./runner.js";import{toErrorMessage}from"#shared/errors.js";import{Client}from"#client/index.js";import{resolveDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{formatVercelAuthChallengeMessage,isVercelAuthChallenge}from"#services/dev-client/vercel-auth-error.js";async function runDevelopmentTui(t){let{serverUrl:n,appRoot:r,initialInput:i,onBootProgress:a,...o}=t,s=new Client(resolveDevelopmentClientOptions(n)),c={...o,session:s.session(),client:s,serverUrl:n,promptCommandHandler:createPromptCommandHandler({appRoot:r}),formatTransportError:e=>isVercelAuthChallenge(e)?formatVercelAuthChallengeMessage({serverUrl:n}):toErrorMessage(e)};r!==void 0&&(c.appRoot=r),i!==void 0&&(c.initialInput=i),a!==void 0&&(c.onBootProgress=a),await new EveTUIRunner(c).run()}export{runDevelopmentTui};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const SECOND_MS=1e3;function formatElapsed(e){if(!Number.isFinite(e)||e<0)throw RangeError(`Elapsed time must be a finite, non-negative number.`);let t=Math.round(e);if(t<SECOND_MS)return`${t}ms`;if(t<6e4)return`${Math.round(t/100)/10}s`;let n=Math.floor(t/SECOND_MS),r=n%60,i=Math.floor(n/60),a=i%60,o=Math.floor(i/60),s=o%24,c=Math.floor(o/24);return c>0?`${c}d ${s}h ${a}m ${r}s`:o>0?`${o}h ${a}m ${r}s`:`${i}m ${r}s`}export{formatElapsed};
|
package/dist/src/cli/run.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { RunDevelopmentTuiInput } from "#cli/dev/tui/tui.js";
|
|
2
|
+
import type { DevelopmentServerHandle, DevelopmentServerOptions, ProductionServerHandle } from "#internal/nitro/host/types.js";
|
|
1
3
|
import type { AssistantResponseStatsMode, LogDisplayMode, TerminalPartDisplayMode, TuiDisplayOptions } from "#cli/dev/tui/types.js";
|
|
2
4
|
interface CliLogger {
|
|
3
5
|
error(message: string): void;
|
|
@@ -18,30 +20,14 @@ interface DevelopmentCliOptions {
|
|
|
18
20
|
ui?: boolean;
|
|
19
21
|
url?: string;
|
|
20
22
|
}
|
|
21
|
-
interface DevelopmentServerHandle {
|
|
22
|
-
readonly url: string;
|
|
23
|
-
close(): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
interface ProductionServerHandle {
|
|
26
|
-
readonly url: string;
|
|
27
|
-
close(): Promise<void>;
|
|
28
|
-
wait(): Promise<void>;
|
|
29
|
-
}
|
|
30
23
|
interface CliRuntimeDependencies {
|
|
31
24
|
buildHost(appRoot: string): Promise<string>;
|
|
32
25
|
printApplicationInfo(logger: CliLogger, appRoot: string, options?: {
|
|
33
26
|
json?: boolean;
|
|
34
27
|
}): Promise<void>;
|
|
35
|
-
runDevelopmentTui(input:
|
|
36
|
-
serverUrl: string;
|
|
37
|
-
appRoot?: string;
|
|
38
|
-
initialInput?: string;
|
|
39
|
-
} & TuiDisplayOptions): Promise<void>;
|
|
28
|
+
runDevelopmentTui(input: RunDevelopmentTuiInput): Promise<void>;
|
|
40
29
|
runEvalCommand(evalIds: readonly string[], options: EvalCliOptions, logger: CliLogger): Promise<void>;
|
|
41
|
-
startHost(appRoot: string, options?:
|
|
42
|
-
host?: string;
|
|
43
|
-
port?: number;
|
|
44
|
-
}): Promise<DevelopmentServerHandle>;
|
|
30
|
+
startHost(appRoot: string, options?: DevelopmentServerOptions): Promise<DevelopmentServerHandle>;
|
|
45
31
|
startProductionHost(appRoot: string, options?: {
|
|
46
32
|
host?: string;
|
|
47
33
|
port?: number;
|
package/dist/src/cli/run.js
CHANGED
|
@@ -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
|
|
1
|
+
import{createLogger}from"#internal/logging.js";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{startCliLiveRow}from"#cli/ui/live-row.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{Command,CommanderError,InvalidArgumentError}from"#compiled/commander/index.js";import{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";const devBootLog=createLogger(`dev.boot`);function createDevBootProgressReporter(e){return t=>{switch(t.type){case`phase-started`:e?.update(`Building your agent`,t.phase),devBootLog.debug(t.phase);return;case`phase-finished`:devBootLog.debug(`${t.phase} finished`,{ms:t.elapsedMs});return;case`before-first-paint`:e?.stop();return;default:return t}}}async function 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 t=humanizeProjectName(basename(e.appRoot));return t.length>0?t: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(e,n){let c=resolveApplicationRoot(),d=resolveInstalledPackageInfo().version,f=new Command,m=createCliTheme();f.name(`eve`).description(`Build and run an eve application.`).version(d).showHelpAfterError().exitOverride().hook(`preAction`,(t,n)=>{shouldPrintCliBootBanner(n)&&e.log(eveCliBanner())}).configureOutput({writeErr:t=>{e.error(t.trimEnd())},writeOut:t=>{e.log(t.trimEnd())}});let h=f.command(`channels`).description(`Manage user-authored channels in the current project.`);return h.command(`add [kind]`).description(`Add channels interactively, or scaffold a channel kind (slack | web).`).option(`-f, --force`,`Overwrite existing channel files`).option(`-y, --yes`,`Assume yes for confirmations; requires an explicit channel kind`).action(async(t,n)=>{let{runChannelsAddCommand:r}=await import(`#cli/commands/channels.js`);await r(e,c,{kind:t,options:n})}),h.command(`list`).description(`List user-authored channels in the current project.`).option(`--json`,`Output as JSON`).action(async t=>{let{runChannelsListCommand:n}=await import(`#cli/commands/channels.js`);await n(e,c,t)}),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(t,n)=>{let{runInitCommand:r}=await import(`#cli/commands/init.js`);await r(e,c,t,n)}),registerProjectCommands({program:f,logger:e,appRoot:c}),f.command(`build`).description(`Build the current eve application.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);t(c);let r=await(n.buildHost??await loadBuildHost())(c);e.log(renderCliTaggedLine(m,{message:`built output at ${r}`,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 t=>{let{loadDevelopmentEnvironmentFiles:r}=await import(`#cli/dev/environment.js`);r(c);let a=await(n.startProductionHost??await loadStartProductionHost())(c,{host:t.host,port:t.port});e.log(renderCliTaggedLine(m,{message:`server listening at ${a.url}`,tag:`start`,tone:`success`})),await waitForProductionServer(a)}),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
|
-
`).action(async
|
|
3
|
+
`).action(async t=>{let r=resolveRemoteDevelopmentServerUrl(t),a=hasInteractiveTerminal(),s=resolveDevUiMode({options:t,interactive:a});if(t.input!==void 0&&s===`headless`)throw new InvalidArgumentError(`--input requires the interactive UI.`);let{loadDevelopmentEnvironmentFiles:l}=await import(`#cli/dev/environment.js`);l(c);let runInteractiveUi=async(e,i)=>{let a=await devBootPhase(`loading interactive UI`,async()=>n.runDevelopmentTui??await loadRunDevelopmentTui(),i),o=resolveTuiDisplayOptions(t),s=resolveTuiTitle({name:t.name,remoteServerUrl:r,appRoot:c});s!==void 0&&(o.name=s),await a({appRoot:r===void 0?c:void 0,initialInput:t.input,onBootProgress:i,serverUrl:e,...o})};if(r){if(e.log(renderCliTaggedLine(m,{message:`connecting to ${r}`,tag:`dev`,tone:`info`})),s===`headless`){e.log(renderCliTaggedLine(m,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}e.log(``),await runInteractiveUi(r);return}s===`tui`&&e.log(``);let u=s===`tui`?startCliLiveRow(e):void 0,d=createDevBootProgressReporter(u);u?.update(`Building your agent`);let f=!1,p,closeServer=async()=>{f||p===void 0||(f=!0,await p.close())};try{if(p=await(n.startHost??await loadStartHost())(c,{host:t.host,onBootProgress:d,port:t.port}),s!==`tui`&&e.log(renderCliTaggedLine(m,{message:`server listening at ${p.url}`,tag:`dev`,tone:`success`})),s===`headless`)return t.ui!==!1&&!a&&e.log(renderCliTaggedLine(m,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForShutdownSignal({close:closeServer});await runInteractiveUi(p.url,d)}finally{u?.stop(),await closeServer()}}),f.command(`info`).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async t=>{await(n.printApplicationInfo??await loadPrintApplicationInfo())(e,c,t)}),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 t.log lines to stdout`).action(async(t,r)=>{await(n.runEvalCommand??await loadRunEvalCommand())(t,r,e)}),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};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface CliLiveRow {
|
|
2
|
+
update(message: string, detail?: string): void;
|
|
3
|
+
stop(): void;
|
|
4
|
+
}
|
|
5
|
+
interface CliLiveRowLogger {
|
|
6
|
+
log(message: string): void;
|
|
7
|
+
}
|
|
8
|
+
interface CliLiveRowOutput {
|
|
9
|
+
readonly columns?: number;
|
|
10
|
+
readonly isTTY?: boolean;
|
|
11
|
+
write(chunk: string): unknown;
|
|
12
|
+
}
|
|
13
|
+
interface CliLiveRowOptions {
|
|
14
|
+
readonly output?: CliLiveRowOutput;
|
|
15
|
+
readonly pulseSequence?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Starts one transient CLI row, or logs its first message when repainting is unavailable. */
|
|
18
|
+
export declare function startCliLiveRow(logger: CliLiveRowLogger, options?: CliLiveRowOptions): CliLiveRow;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__toESM}from"../../_virtual/_rolldown/runtime.js";import{require_picocolors}from"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js";import{isLogLevelEnabled}from"#internal/logging.js";import{sanitizeForTerminal}from"#cli/ui/output.js";import{sliceVisible,visibleLength}from"#cli/dev/tui/terminal-text.js";var import_picocolors=__toESM(require_picocolors(),1);const REDRAW_PROGRESS_ROW=`\r\x1B[K`,PULSE_SEQUENCE_DURATION_MS=1e3;function validatePulseSequence(e){if(e.length!==8&&e.length!==16)throw RangeError(`Pulse sequence must contain 8 or 16 steps.`);if(/[^01]/u.test(e))throw RangeError(`Pulse sequence steps must be "0" or "1".`)}function pulseStepDurationMs(e,t){let n=Math.round(e*PULSE_SEQUENCE_DURATION_MS/t);return Math.round((e+1)*PULSE_SEQUENCE_DURATION_MS/t)-n}function sanitizeProgressText(e){return sanitizeForTerminal(e).replaceAll(/\s+/gu,` `).trim()}function fitProgressText(e,t){return t<=0?``:visibleLength(e)<=t?e:t===1?`…`:`${sliceVisible(e,t-1)}…`}function renderProgressRow(e,t,n,r){let i=n!==``,s=`${e} ${t}${i?``:`...`}`,c=Math.max(0,(r??80)-1),l=visibleLength(s);if(l>=c){let t=fitProgressText(s,c);return t.startsWith(e)?`${import_picocolors.default.green(e)}${t.slice(e.length)}`:t}let u=i?fitProgressText(` ${n}`,c-l):``,d=u===``?``:import_picocolors.default.dim(u);return`${import_picocolors.default.green(e)}${s.slice(e.length)}${d}`}function startCliLiveRow(e,t={}){let r=t.output??process.stdout,i=t.pulseSequence??`1111110000111111`;validatePulseSequence(i);let a=r.isTTY===!0&&!isLogLevelEnabled(`debug`),o=0,c=i[0]===`1`,l,u=!1,d=!1,f=!1,p,paint=()=>{if(l===void 0)return;let e=renderProgressRow(c?`▪`:` `,l.message,l.detail,r.columns);r.write(`${u?REDRAW_PROGRESS_ROW:``}${e}`),u=!0},schedulePulseStep=()=>{p=setTimeout(()=>{if(f)return;o=(o+1)%i.length;let e=i[o]===`1`;e!==c&&(c=e,paint()),schedulePulseStep()},pulseStepDurationMs(o,i.length)),p.unref?.()};return{update(t,n=``){if(!f){if(l={detail:sanitizeProgressText(n),message:sanitizeProgressText(t)},!a){d||=(e.log(`${l.message}...`),!0);return}paint(),p===void 0&&schedulePulseStep()}},stop(){f||(f=!0,p!==void 0&&clearTimeout(p),a&&u&&r.write(REDRAW_PROGRESS_ROW))}}}export{startCliLiveRow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{DynamicSkillManifestKey,SandboxKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{ALLOWED_DYNAMIC_SKILL_EVENTS,isBrandedSkillEntry}from"#shared/dynamic-tool-definition.js";import{normalizeSkillPackage,writeSkillPackageToSandbox}from"#shared/skill-package.js";import{ContextKey}from"#context/key.js";import{buildResolveContext}from"#context/dynamic-resolve-context.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{formatAvailableSkillsSection}from"#execution/skills/instructions.js";const log=createLogger(`dynamic-skills`);function qualifyDynamicSkillNames(e,t,n){let r=Object.keys(n),i=[];if(r.length===0)return i;if(t
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{DynamicSkillManifestKey,SandboxKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{ALLOWED_DYNAMIC_SKILL_EVENTS,isBrandedSkillEntry}from"#shared/dynamic-tool-definition.js";import{normalizeSkillPackage,writeSkillPackageToSandbox}from"#shared/skill-package.js";import{ContextKey}from"#context/key.js";import{buildResolveContext}from"#context/dynamic-resolve-context.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{formatAvailableSkillsSection}from"#execution/skills/instructions.js";const log=createLogger(`dynamic-skills`);function qualifyDynamicSkillNames(e,t,n){let r=Object.keys(n),i=[];if(r.length===0)return i;if(t)return i.push({name:e,entryKey:r[0],entry:n[r[0]]}),i;for(let t of r)i.push({name:`${e}__${t}`,entryKey:t,entry:n[t]});return i}function formatDynamicSkillAnnouncement(e){return formatAvailableSkillsSection(Object.values(e).flat())??``}const PendingSkillAnnouncementKey=new ContextKey(`eve.pendingSkillAnnouncement`);async function dispatchDynamicSkillEvent(e){let{ctx:a,resolvers:o,event:s,messages:c}=e;if(a.get(PendingSkillAnnouncementKey)===void 0){let e=a.get(DynamicSkillManifestKey);e!==void 0&&Object.keys(e).length>0&&a.setVirtualContext(PendingSkillAnnouncementKey,formatDynamicSkillAnnouncement(e))}if(!ALLOWED_DYNAMIC_SKILL_EVENTS.has(s.type))return;let l=o.filter(e=>e.eventNames.includes(s.type));if(l.length===0)return;let u=buildResolveContext(a,c),d=new Set(a.require(BundleKey).resolvedAgent.skills.map(e=>e.name)),f=a.get(DynamicSkillManifestKey)??{},p=[],m=await Promise.allSettled(l.map(async e=>{let t=e.events[s.type];if(t===void 0)return null;let n=await t(s,u);if(n==null)return{resolver:e,named:[]};let r,i;return isBrandedSkillEntry(n)?(r={_single:n},i=!0):(r=n,i=!1),{resolver:e,named:qualifyDynamicSkillNames(e.slug,i,r)}}));for(let e of m){if(e.status===`rejected`){log.error(`Dynamic skill resolver (${s.type}) threw — skipping.`,{error:toErrorMessage(e.reason)});continue}e.value!==null&&p.push({resolver:e.value.resolver,skills:e.value.named.map(({name:e,entry:t})=>normalizeSkillPackage({...t,name:e}))})}if(p.length===0)return;let h={...f};for(let{resolver:e,skills:t}of p)t.length===0?delete h[e.slug]:h[e.slug]=t.map(e=>({description:e.description,name:e.name}));let g=new Map;for(let[e,t]of Object.entries(h))for(let{name:n}of t){if(d.has(n))throw Error(`Dynamic skill "${n}" from resolver "${e}" conflicts with an authored skill.`);let t=g.get(n);if(t!==void 0)throw Error(`Dynamic skill "${n}" from resolver "${e}" conflicts with dynamic resolver "${t}".`);g.set(n,e)}let _=await a.require(SandboxKey).get();if(_!==null)for(let{skills:e}of p)for(let t of e)await writeSkillPackageToSandbox({sandbox:_,skill:t});a.set(DynamicSkillManifestKey,h),a.setVirtualContext(PendingSkillAnnouncementKey,formatDynamicSkillAnnouncement(h))}export{PendingSkillAnnouncementKey,dispatchDynamicSkillEvent};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from "#compiled/@standard-schema/spec/index.js";
|
|
2
2
|
import type { HandleMessageStreamEvent } from "#protocol/message.js";
|
|
3
|
-
import { type EveEvalSubagentCallMatchOptions, type EveEvalToolCallMatchOptions } from "#evals/match.js";
|
|
3
|
+
import { type EveEvalSkillLoadMatchOptions, type EveEvalSubagentCallMatchOptions, type EveEvalToolCallMatchOptions } from "#evals/match.js";
|
|
4
4
|
import type { RunAssertion } from "#evals/assertions/collector.js";
|
|
5
5
|
/**
|
|
6
6
|
* Asserts the run ran to completion: it did not fail and did not park on an
|
|
@@ -29,6 +29,12 @@ export declare function messageIncludes(token: string | RegExp): RunAssertion;
|
|
|
29
29
|
* `isError` constrains error state, and `times` requires an exact count.
|
|
30
30
|
*/
|
|
31
31
|
export declare function calledTool(name: string, options?: EveEvalToolCallMatchOptions): RunAssertion;
|
|
32
|
+
/**
|
|
33
|
+
* Sugar over {@link calledTool} for the framework `load_skill` tool: asserts a
|
|
34
|
+
* skill with id `skill` was loaded. `output`/`isError`/`times` constrain the
|
|
35
|
+
* matching call exactly as for `calledTool`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function loadedSkill(skill: string, options?: EveEvalSkillLoadMatchOptions): RunAssertion;
|
|
32
38
|
/**
|
|
33
39
|
* Asserts no tool call with `name` happened.
|
|
34
40
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{deepEquals,subagentCallMatches,testRegExp,toolCallMatches}from"#evals/match.js";const PASS={score:1},fail=(e,t)=>({score:0,message:e,metadata:t});function completed(){return{name:`completed`,evaluate(e){return e.status===`failed`?fail(failureDetail(`run failed`,e.derived.failureCode)):e.derived.parked?fail(`run parked on ${e.derived.inputRequests.length} unanswered input request(s)`):PASS}}}function waiting(){return{name:`waiting`,evaluate(e){return e.derived.parked?PASS:fail(`expected the run to park on HITL input; it ended "${e.status}" with no pending requests`)}}}function didNotFail(){return{name:`didNotFail`,evaluate(e){if(e.status===`failed`)return fail(failureDetail(`run failed`,e.derived.failureCode));let t=e.events.find(e=>e.type===`turn.failed`||e.type===`step.failed`);return t===void 0?PASS:fail(`${t.type} (${t.data.code}): ${t.data.message}`)}}}function messageIncludes(e){return{name:`messageIncludes(${String(e)})`,evaluate(t){let r=joinCompletedMessages(t.events);return(typeof e==`string`?r.includes(e):testRegExp(e,r))?PASS:fail(`assistant messages did not include ${String(e)}; got: ${truncate(r)}`)}}}function calledTool(e,t={}){return{name:`calledTool(${e})`,evaluate(n){let i=n.derived.toolCalls.filter(t=>t.name===e),a=i.filter(e=>toolCallMatches(e,t));if(t.times===void 0?a.length>0:a.length===t.times)return{score:1,metadata:{matchingCalls:a.length}};let o=i.length>0?`observed ${e} calls: ${i.map(e=>truncate(JSON.stringify(e.input))).join(`, `)}`:`observed tools: [${n.derived.toolCalls.map(e=>e.name).join(`, `)}]`;return fail(`${t.times===void 0?`expected a matching call to "${e}"`:`expected exactly ${t.times} matching call(s), found ${a.length}`}; ${o}`)}}}function notCalledTool(e){return{name:`notCalledTool(${e})`,evaluate(t){let n=t.derived.toolCalls.filter(t=>t.name===e).length;return n===0?PASS:fail(`"${e}" was called ${n} time(s)`)}}}function toolOrder(e){return{name:`toolOrder(${e.join(` → `)})`,evaluate(t){let n=t.derived.toolCalls.map(e=>e.name),r=0;for(let t of n)if(t===e[r]&&(r+=1),r===e.length)break;return r===e.length?PASS:fail(`missing "${e[r]}" after [${e.slice(0,r).join(`, `)}]; observed order: [${n.join(`, `)}]`)}}}function usedNoTools(){return{name:`usedNoTools`,evaluate(e){let t=e.derived.toolCallCount;return t===0?PASS:fail(`expected no tool calls, got ${t}`,{toolCallCount:t})}}}function maxToolCalls(e){return{name:`maxToolCalls(${e})`,evaluate(t){let n=t.derived.toolCallCount;return n<=e?PASS:fail(`expected at most ${e} tool calls, got ${n}`,{maxAllowed:e,toolCallCount:n})}}}function noFailedActions(){return{name:`noFailedActions`,evaluate(e){let t=e.events.filter(e=>e.type===`action.result`&&(e.data.status===`failed`||e.data.result.isError===!0));if(t.length===0)return PASS;let n=t.map(e=>e.data.result.kind===`tool-result`?e.data.result.toolName:e.data.result.kind);return fail(`${t.length} failed action(s): ${n.join(`, `)}`)}}}function calledSubagent(e,n={}){return{name:`calledSubagent(${e})`,evaluate(r){let
|
|
2
|
-
`)}function failureDetail(e,t){return t===void 0?e:`${e} (code: ${t})`}function truncate(e,t=200){return e===void 0?`undefined`:e.length<=t?e:`${e.slice(0,t)}…`}export{calledSubagent,calledTool,completed,didNotFail,event,maxToolCalls,messageIncludes,noFailedActions,notCalledTool,outputEquals,outputMatches,toolOrder,usedNoTools,waiting};
|
|
1
|
+
import{deepEquals,subagentCallMatches,testRegExp,toolCallMatches}from"#evals/match.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";const PASS={score:1},fail=(e,t)=>({score:0,message:e,metadata:t});function completed(){return{name:`completed`,evaluate(e){return e.status===`failed`?fail(failureDetail(`run failed`,e.derived.failureCode)):e.derived.parked?fail(`run parked on ${e.derived.inputRequests.length} unanswered input request(s)`):PASS}}}function waiting(){return{name:`waiting`,evaluate(e){return e.derived.parked?PASS:fail(`expected the run to park on HITL input; it ended "${e.status}" with no pending requests`)}}}function didNotFail(){return{name:`didNotFail`,evaluate(e){if(e.status===`failed`)return fail(failureDetail(`run failed`,e.derived.failureCode));let t=e.events.find(e=>e.type===`turn.failed`||e.type===`step.failed`);return t===void 0?PASS:fail(`${t.type} (${t.data.code}): ${t.data.message}`)}}}function messageIncludes(e){return{name:`messageIncludes(${String(e)})`,evaluate(t){let r=joinCompletedMessages(t.events);return(typeof e==`string`?r.includes(e):testRegExp(e,r))?PASS:fail(`assistant messages did not include ${String(e)}; got: ${truncate(r)}`)}}}function calledTool(e,t={}){return{name:`calledTool(${e})`,evaluate(n){let i=n.derived.toolCalls.filter(t=>t.name===e),a=i.filter(e=>toolCallMatches(e,t));if(t.times===void 0?a.length>0:a.length===t.times)return{score:1,metadata:{matchingCalls:a.length}};let o=i.length>0?`observed ${e} calls: ${i.map(e=>truncate(JSON.stringify(e.input))).join(`, `)}`:`observed tools: [${n.derived.toolCalls.map(e=>e.name).join(`, `)}]`;return fail(`${t.times===void 0?`expected a matching call to "${e}"`:`expected exactly ${t.times} matching call(s), found ${a.length}`}; ${o}`)}}}function loadedSkill(e,t={}){return{...calledTool(LOAD_SKILL_TOOL_NAME,{...t,input:{skill:e}}),name:`loadedSkill(${e})`}}function notCalledTool(e){return{name:`notCalledTool(${e})`,evaluate(t){let n=t.derived.toolCalls.filter(t=>t.name===e).length;return n===0?PASS:fail(`"${e}" was called ${n} time(s)`)}}}function toolOrder(e){return{name:`toolOrder(${e.join(` → `)})`,evaluate(t){let n=t.derived.toolCalls.map(e=>e.name),r=0;for(let t of n)if(t===e[r]&&(r+=1),r===e.length)break;return r===e.length?PASS:fail(`missing "${e[r]}" after [${e.slice(0,r).join(`, `)}]; observed order: [${n.join(`, `)}]`)}}}function usedNoTools(){return{name:`usedNoTools`,evaluate(e){let t=e.derived.toolCallCount;return t===0?PASS:fail(`expected no tool calls, got ${t}`,{toolCallCount:t})}}}function maxToolCalls(e){return{name:`maxToolCalls(${e})`,evaluate(t){let n=t.derived.toolCallCount;return n<=e?PASS:fail(`expected at most ${e} tool calls, got ${n}`,{maxAllowed:e,toolCallCount:n})}}}function noFailedActions(){return{name:`noFailedActions`,evaluate(e){let t=e.events.filter(e=>e.type===`action.result`&&(e.data.status===`failed`||e.data.result.isError===!0));if(t.length===0)return PASS;let n=t.map(e=>e.data.result.kind===`tool-result`?e.data.result.toolName:e.data.result.kind);return fail(`${t.length} failed action(s): ${n.join(`, `)}`)}}}function calledSubagent(e,n={}){return{name:`calledSubagent(${e})`,evaluate(r){let i=r.derived.subagentCalls.filter(t=>t.name===e);return i.filter(e=>subagentCallMatches(e,n)).length>0?PASS:i.length===0?fail(`subagent "${e}" was never called; observed: [${r.derived.subagentCalls.map(e=>e.name).join(`, `)}]`,{observedSubagentCalls:r.derived.subagentCalls}):fail(`subagent "${e}" was called but no call matched the constraints`,{observedSubagentCalls:i})}}}function event(e,t){return{name:`event(${t})`,evaluate(n){return e(n.events)?PASS:fail(`event predicate "${t}" did not hold`)}}}function outputEquals(t){return{name:`outputEquals`,evaluate(n){return deepEquals(n.output,t)?PASS:fail(`output ${truncate(JSON.stringify(n.output))} does not equal expected ${truncate(JSON.stringify(t))}`)}}}function outputMatches(e){return{name:`outputMatches`,async evaluate(t){let n=await e[`~standard`].validate(t.output);return!(`issues`in n)||n.issues===void 0?PASS:fail(`output failed schema validation: ${n.issues.map(e=>e.message).join(`; `)}`)}}}function joinCompletedMessages(e){let t=[];for(let n of e)n.type===`message.completed`&&n.data.message!==null&&t.push(n.data.message);return t.join(`
|
|
2
|
+
`)}function failureDetail(e,t){return t===void 0?e:`${e} (code: ${t})`}function truncate(e,t=200){return e===void 0?`undefined`:e.length<=t?e:`${e.slice(0,t)}…`}export{calledSubagent,calledTool,completed,didNotFail,event,loadedSkill,maxToolCalls,messageIncludes,noFailedActions,notCalledTool,outputEquals,outputMatches,toolOrder,usedNoTools,waiting};
|
|
@@ -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,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};
|
|
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)),loadedSkill:(e,n)=>i.recordRun(RunAssertions.loadedSkill(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};
|
|
@@ -3,5 +3,5 @@ export { defineEvalConfig } from "#evals/define-eval-config.js";
|
|
|
3
3
|
export { EveEvalTurnFailedError } from "#evals/session.js";
|
|
4
4
|
export type { RuntimeIdentity } from "#protocol/message.js";
|
|
5
5
|
export type { InputRequest } from "#runtime/input/types.js";
|
|
6
|
-
export type { EveEvalValueMatcher, EveEvalToolCallMatchOptions, EveEvalSubagentCallMatchOptions, } from "#evals/match.js";
|
|
6
|
+
export type { EveEvalValueMatcher, EveEvalToolCallMatchOptions, EveEvalSkillLoadMatchOptions, EveEvalSubagentCallMatchOptions, } from "#evals/match.js";
|
|
7
7
|
export type { Assertion, AssertionHandle, AssertionResult, AssertionSeverity, AutoevalsJudges, EveEvalContext, EveEvalDerivedFacts, EveEvalJudgeConfig, EveEvalRunSummary, EveEvalSession, EveEvalSessionResult, EveEvalScheduleDispatchResult, EveEvalSubagentCall, EveEval, EveEvalConfig, EveEvalConfigInput, EveEvalDefinition, EveEvalInput, EveEvalResult, EveEvalTarget, EveEvalTargetCapabilities, EveEvalTargetHandle, EveEvalTaskResult, EveEvalToolCall, EveEvalTurn, EveEvalVerdict, JudgeContext, JudgeOpts, } from "#evals/types.js";
|
|
@@ -30,6 +30,12 @@ export interface EveEvalToolCallMatchOptions {
|
|
|
30
30
|
/** Exact number of matching calls required. Defaults to "at least one". */
|
|
31
31
|
readonly times?: number;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Constraints applied to a `load_skill` call by `t.loadedSkill`. Identical to
|
|
35
|
+
* {@link EveEvalToolCallMatchOptions} without `input`, which the helper fixes to
|
|
36
|
+
* the loaded skill id.
|
|
37
|
+
*/
|
|
38
|
+
export type EveEvalSkillLoadMatchOptions = Omit<EveEvalToolCallMatchOptions, "input">;
|
|
33
39
|
/**
|
|
34
40
|
* Constraints applied to subagent calls by `t.calledSubagent`.
|
|
35
41
|
*/
|
|
@@ -6,7 +6,7 @@ import type { InputRequest, InputResponse } from "#runtime/input/types.js";
|
|
|
6
6
|
import type { JsonObject } from "#shared/json.js";
|
|
7
7
|
import type { AgentModelOptionsDefinition } from "#shared/agent-definition.js";
|
|
8
8
|
import type { EvalReporter } from "#evals/runner/reporters/types.js";
|
|
9
|
-
import type { EveEvalSubagentCallMatchOptions, EveEvalToolCallMatchOptions } from "#evals/match.js";
|
|
9
|
+
import type { EveEvalSkillLoadMatchOptions, EveEvalSubagentCallMatchOptions, EveEvalToolCallMatchOptions } from "#evals/match.js";
|
|
10
10
|
/**
|
|
11
11
|
* One tool call extracted from the captured stream, pairing the
|
|
12
12
|
* `actions.requested` request with its matching `action.result`.
|
|
@@ -258,6 +258,8 @@ export interface EveEvalContext extends EveEvalSession {
|
|
|
258
258
|
waiting(): AssertionHandle;
|
|
259
259
|
messageIncludes(token: string | RegExp): AssertionHandle;
|
|
260
260
|
calledTool(name: string, options?: EveEvalToolCallMatchOptions): AssertionHandle;
|
|
261
|
+
/** Sugar for `calledTool("load_skill", { input: { skill }, ... })`. */
|
|
262
|
+
loadedSkill(skill: string, options?: EveEvalSkillLoadMatchOptions): AssertionHandle;
|
|
261
263
|
notCalledTool(name: string): AssertionHandle;
|
|
262
264
|
toolOrder(names: readonly string[]): AssertionHandle;
|
|
263
265
|
usedNoTools(): AssertionHandle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{contextStorage}from"#context/container.js";import"ai";import{CODE_MODE_RUNTIME_ACTION_INTERRUPT_KIND}from"#harness/code-mode-runtime-action-state.js";import{loadCodeModeModule}from"#shared/code-mode.js";import{isAuthorizationSignal}from"#harness/authorization.js";import{buildDynamicTools}from"#context/build-dynamic-tools.js";import{CODE_MODE_CONNECTION_AUTH_INTERRUPT_KIND,markCodeModeToolExecutionOptions,toCodeModeConnectionAuthArgs}from"#runtime/framework-tools/code-mode-connection-auth.js";import{ALL_SANDBOX_SURFACES}from"#harness/sandbox-surface.js";import{
|
|
1
|
+
import{contextStorage}from"#context/container.js";import"ai";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{CODE_MODE_RUNTIME_ACTION_INTERRUPT_KIND}from"#harness/code-mode-runtime-action-state.js";import{loadCodeModeModule}from"#shared/code-mode.js";import{isAuthorizationSignal}from"#harness/authorization.js";import{buildDynamicTools}from"#context/build-dynamic-tools.js";import{CODE_MODE_CONNECTION_AUTH_INTERRUPT_KIND,markCodeModeToolExecutionOptions,toCodeModeConnectionAuthArgs}from"#runtime/framework-tools/code-mode-connection-auth.js";import{ALL_SANDBOX_SURFACES}from"#harness/sandbox-surface.js";import{buildToolSet,buildToolSetFromDefinitions}from"#harness/tools.js";const NEVER_SANDBOXED_TOOL_NAMES=new Set([LOAD_SKILL_TOOL_NAME]);function createEveCodeModeOptions(e={}){let t={approval:{mode:`interrupt`}};return e.lifecycle!==void 0&&(t.lifecycle=e.lifecycle),t}async function applySandboxToolSet(e){let t={},n=new Map(e.surfaces.map(e=>[e,{}]));for(let[r,i]of Object.entries(e.tools)){if(NEVER_SANDBOXED_TOOL_NAMES.has(r)){t[r]=i;continue}let a=e.harnessTools.get(r),o=a?.runtimeAction!==void 0;o&&(t[r]=i);let s=e.surfaces.filter(e=>e.claims(a,i));if(s.length===0){o||(t[r]=i);continue}let c=o&&a!==void 0?createRuntimeActionHostTool(a):wrapHostToolForCodeMode(i);for(let e of s)n.get(e)[r]=c}let r={};for(let i of e.surfaces){let a=n.get(i);Object.keys(a).length!==0&&(Object.assign(r,a),t[i.toolName]=await createSandboxTool(i,a,e.lifecycle))}return{hostTools:r,modelTools:t}}async function createSandboxTool(e,t,n){let{createCodeModeTool:i}=await loadCodeModeModule(),a=i(t,createEveCodeModeOptions({lifecycle:n}));if(e.describe===void 0)return a;let o=typeof a.description==`string`?a.description:``;return{...a,description:e.describe({generated:o,toolNames:Object.keys(t)})}}async function buildSandboxHostTools(t){let n=buildToolSet({approvedTools:t.approvedTools,capabilities:t.capabilities,tools:t.tools}),r=contextStorage.getStore();if(r!==void 0){let e=buildDynamicTools(r),i=buildToolSetFromDefinitions({approvedTools:t.approvedTools,capabilities:t.capabilities,tools:e});for(let[e,t]of Object.entries(i))n[e]??=t}return(await applySandboxToolSet({harnessTools:t.tools,tools:n,surfaces:ALL_SANDBOX_SURFACES})).hostTools}function createRuntimeActionHostTool(e){return{description:e.description,inputSchema:e.inputSchema,execute:async(t,i)=>{let a=i?.codeModeInterrupt;if(a?.resolution!==void 0)return a.resolution;let{requestCodeModeInterrupt:o}=await loadCodeModeModule();return o({kind:CODE_MODE_RUNTIME_ACTION_INTERRUPT_KIND,runtimeAction:e.runtimeAction,toolInput:t,toolName:e.name})}}}function wrapHostToolForCodeMode(e){let t=e.execute;if(t===void 0)return e;let invoke=async(e,n)=>{let a=await resolveExecuteOutput(t(e,markCodeModeToolExecutionOptions(n)));if(isAuthorizationSignal(a)){let{requestCodeModeInterrupt:t}=await loadCodeModeModule(),n=a.challenges[0]?.name;n&&t({args:toCodeModeConnectionAuthArgs(e),challenges:a.challenges,connectionName:n,kind:CODE_MODE_CONNECTION_AUTH_INTERRUPT_KIND,toolName:``})}return a};return{...e,execute:(e,t)=>invoke(e,t)}}async function resolveExecuteOutput(e){if(isAsyncIterable(e)){let t;for await(let n of e)t=n;return t}return await e}function isAsyncIterable(e){return typeof e==`object`&&!!e&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]==`function`}export{applySandboxToolSet,buildSandboxHostTools,createEveCodeModeOptions};
|
|
@@ -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.11.
|
|
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.11.10`,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};
|