eve 0.62.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/src/cli/dev/tui/model-picker.d.ts +48 -0
- package/dist/src/cli/dev/tui/model-picker.js +1 -0
- package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +2 -2
- package/dist/src/cli/dev/tui/setup-commands.d.ts +1 -1
- package/dist/src/cli/dev/tui/setup-commands.js +1 -1
- package/dist/src/cli/dev/tui/setup-flow.d.ts +2 -2
- package/dist/src/cli/dev/tui/setup-panel.d.ts +1 -26
- package/dist/src/cli/dev/tui/setup-panel.js +3 -3
- package/dist/src/cli/dev/tui/stream-format.d.ts +0 -7
- package/dist/src/cli/dev/tui/stream-format.js +1 -1
- package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
- package/dist/src/cli/dev/tui/test/fake-setup-flow-renderer.js +1 -1
- package/dist/src/cli/dev/tui/test/mock-terminal.js +1 -1
- package/dist/src/cli/dev/tui/theme.d.ts +0 -8
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +25 -6
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/evals/runner/derive-run-facts.js +1 -1
- package/dist/src/evals/types.d.ts +4 -3
- package/dist/src/eve-channel/request.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/cancel-indexed-session-tasks-step.d.ts +2 -1
- package/dist/src/execution/cancel-indexed-session-tasks-step.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +1 -6
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/legacy-session/interrupt-step.js +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/route-child-delivery.js +3 -1
- package/dist/src/execution/session/admission.js +1 -1
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +2 -1
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +2 -0
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/next-input.js +1 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-workflow-tool-run.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +0 -1
- package/dist/src/execution/stable-workflow-names.js +1 -1
- package/dist/src/execution/tasks/child/notify.d.ts +44 -0
- package/dist/src/execution/tasks/child/notify.js +1 -0
- package/dist/src/execution/tasks/parent/control-shared.d.ts +2 -5
- package/dist/src/execution/tasks/parent/control-shared.js +1 -1
- package/dist/src/execution/tasks/parent/delegate.d.ts +8 -36
- package/dist/src/execution/tasks/parent/delegate.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch.d.ts +3 -5
- package/dist/src/execution/tasks/parent/dispatch.js +1 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +4 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
- package/dist/src/execution/tasks/parent/run-parent.d.ts +5 -19
- package/dist/src/execution/tasks/parent/run-parent.js +1 -1
- package/dist/src/execution/tasks/parent/task-cancel.d.ts +6 -5
- package/dist/src/execution/tasks/parent/task-cancel.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/tool-auth.d.ts +3 -9
- package/dist/src/execution/tool-auth.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/sleep-workflow.js +1 -1
- package/dist/src/execution/tools/subagent/accept-event-step.js +1 -1
- package/dist/src/execution/tools/subagent/emit-event-step.d.ts +11 -0
- package/dist/src/execution/tools/subagent/emit-event-step.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-agent.d.ts +5 -7
- package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-step.d.ts +3 -2
- package/dist/src/execution/tools/subagent/invoke-step.js +1 -1
- package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +0 -1
- package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -1
- package/dist/src/execution/tools/subagent/task-cancel.d.ts +1 -1
- package/dist/src/execution/tools/subagent/task-cancel.js +1 -1
- package/dist/src/execution/tools/workflow/background.d.ts +1 -1
- package/dist/src/execution/tools/workflow/background.js +1 -1
- package/dist/src/execution/tools/workflow/body.d.ts +0 -2
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/cancel.d.ts +4 -3
- package/dist/src/execution/tools/workflow/cancel.js +1 -1
- package/dist/src/execution/tools/workflow/cancellation-policy.d.ts +2 -0
- package/dist/src/execution/tools/workflow/cancellation-policy.js +1 -0
- package/dist/src/execution/tools/workflow/messages.d.ts +0 -1
- package/dist/src/execution/tools/workflow/owner-channels.d.ts +6 -6
- package/dist/src/execution/tools/workflow/owner-inbox.d.ts +5 -9
- package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
- package/dist/src/execution/tools/workflow/owner.d.ts +6 -2
- package/dist/src/execution/tools/workflow/owner.js +1 -1
- package/dist/src/execution/tools/workflow/start.js +1 -1
- package/dist/src/execution/tools/workflow/types.d.ts +11 -19
- package/dist/src/execution/tools/workflow/types.js +1 -1
- package/dist/src/execution/tools/workflow/workflow-owner-background.d.ts +13 -0
- package/dist/src/execution/tools/workflow/workflow-owner-background.js +1 -0
- package/dist/src/execution/tools/workflow/workflow-owner-blocking.d.ts +12 -0
- package/dist/src/execution/tools/workflow/workflow-owner-blocking.js +1 -0
- package/dist/src/execution/tools/workflow/workflow.d.ts +3 -3
- package/dist/src/execution/tools/workflow/workflow.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +0 -4
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/background-tools.d.ts +3 -5
- package/dist/src/harness/coordination.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +2 -29
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/tool-model-output.js +1 -1
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/workflow-tool-runs.d.ts +53 -18
- package/dist/src/harness/workflow-tool-runs.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/protocol/message.d.ts +4 -4
- package/dist/src/public/tools/index.d.ts +2 -2
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/connections/scoped-authorization.js +1 -1
- package/dist/src/runtime/sessions/turn.d.ts +10 -8
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/subagents/workflow.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/setup/flows/model.d.ts +5 -5
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/action-types.d.ts +0 -4
- package/dist/src/shared/action-types.js +1 -1
- package/dist/src/tasks/delivery-context.js +2 -2
- package/dist/src/tasks/notification.d.ts +4 -0
- package/dist/src/tasks/notification.js +1 -0
- package/dist/src/tasks/session-task-cohorts.d.ts +1 -12
- package/dist/src/tasks/session-task-cohorts.js +1 -1
- package/dist/src/tasks/transitions.d.ts +5 -2
- package/dist/src/tasks/transitions.js +1 -1
- package/dist/src/tasks/types.d.ts +2 -52
- package/dist/src/tasks/types.js +1 -1
- package/dist/src/tools/definition.d.ts +1 -25
- package/dist/src/tools/definition.js +1 -1
- package/dist/src/tools/dynamic.d.ts +1 -3
- package/dist/src/tools/framework/agent.d.ts +16 -22
- package/dist/src/tools/framework/agent.js +1 -1
- package/dist/src/tools/workflow-definition.d.ts +16 -5
- package/dist/src/tracing/agent-invocation-coordinator.js +1 -1
- package/dist/src/tracing/agent-trace-context-store.js +1 -1
- package/docs/concepts/execution-model-and-durability.mdx +4 -5
- package/docs/concepts/sessions-runs-and-streaming.md +2 -2
- package/docs/evals/assertions.mdx +5 -1
- package/docs/guides/dev-tui.md +21 -9
- package/docs/guides/frontend/overview.mdx +1 -1
- package/docs/subagents/index.mdx +12 -9
- package/docs/tools/overview.mdx +26 -34
- package/docs/tools/workflows.mdx +31 -24
- package/package.json +1 -1
- package/dist/src/cli/dev/tui/model-editor.d.ts +0 -103
- package/dist/src/cli/dev/tui/model-editor.js +0 -1
- package/dist/src/execution/tasks/child/steps.d.ts +0 -81
- package/dist/src/execution/tasks/child/steps.js +0 -1
- package/dist/src/execution/tasks/child/workflow.d.ts +0 -28
- package/dist/src/execution/tasks/child/workflow.js +0 -1
- package/dist/src/execution/tools/subagent/emit-called-step.d.ts +0 -9
- package/dist/src/execution/tools/subagent/emit-called-step.js +0 -1
- package/dist/src/execution/tools/workflow/run-control.d.ts +0 -14
- package/dist/src/execution/tools/workflow/run-control.js +0 -1
- package/dist/src/tasks/session-index.d.ts +0 -65
- package/dist/src/tasks/session-index.js +0 -1
- package/dist/src/tools/task.d.ts +0 -55
- package/dist/src/tools/task.js +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{buildAgentHeader}from"./agent-header.js";import{detectMarkdownRendering}from"./markdown.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderAttentionRows,renderBlockLines}from"./blocks.js";import{copyTextToClipboard}from"./clipboard.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{formatStoredDiagnostic,presentDiagnostic}from"./diagnostic-presentation.js";import{interruptedError}from"./errors.js";import{FileContentCache}from"./file-content-cache.js";import{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,layoutPromptInput,lineOf,movePromptLine,visibleLine}from"./line-editor.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{MessageQueue,renderMessageQueueRows}from"./message-queue.js";import{
|
|
2
|
-
`);if(this.#N){t!==this.#P&&(this.#P=t,this.#
|
|
1
|
+
import{buildAgentHeader}from"./agent-header.js";import{detectMarkdownRendering}from"./markdown.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderAttentionRows,renderBlockLines}from"./blocks.js";import{copyTextToClipboard}from"./clipboard.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{formatStoredDiagnostic,presentDiagnostic}from"./diagnostic-presentation.js";import{interruptedError}from"./errors.js";import{FileContentCache}from"./file-content-cache.js";import{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,layoutPromptInput,lineOf,movePromptLine,visibleLine}from"./line-editor.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{MessageQueue,renderMessageQueueRows}from"./message-queue.js";import{enterBadge,flowMessageRows,renderAcknowledgeQuestion,renderFlowPanel,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{initialModelPickerState,modelPickerTitle,renderModelPicker,transitionModelPicker}from"./model-picker.js";import{initialProviderPickerState,transitionProviderPicker}from"./provider-picker.js";import{renderQuestionPanel}from"./question-panel.js";import{formatAssistantResponseStats,formatTokenFlow,formatTurnDuration,isIncompleteOsc,isIncompletePaste,nextKey,sanitizePastedText,stripPasteStart,stripPromptControlCharacters,takeUntil}from"./stream-format.js";import{TraceViewerSession}from"./traces/trace-viewer-session.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{isPanelRoutedTool,presentPreparingTool,presentTool,readWriteFileInput,toolBaseName}from"./tool-presentation.js";import{groupToolBlocksForDisplay}from"./tool-block-groups.js";import{TurnClock}from"./turn-clock.js";import{allTodoItemsSettled,readTodoToolItems,renderFinishedTodoRows,renderTodoPanelRows}from"./todo-panel.js";import{reduceSetupSelectInput,setupSelectionIntent}from"./setup-selection-input.js";import{BACKGROUND_COLOR_QUERY,parseBackgroundColorReply}from"./terminal-background.js";import{inspectError}from"#internal/logging.js";import{eveVersionTag}from"#cli/banner.js";import{clipVisible,renderInputText,renderInputWithBlockCursor,stripAnsi,stripTerminalControls}from"#cli/ui/terminal-text.js";import{renderCursorRow}from"#setup/cli/option-row.js";import{initialSelectState,orderedSelection,reduceSelect,searchActionQuery,selectValueAtCursor}from"#setup/cli/select-state.js";import{toErrorMessage}from"#shared/errors.js";import{StringDecoder}from"node:string_decoder";import{summarizeKnownError}from"#harness/semantic-errors/index.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{LiveRegion}from"#cli/ui/live-region.js";import{AltScreen}from"#cli/ui/alt-screen.js";import{PROGRESS_PULSE_ASCII_GLYPH,PROGRESS_PULSE_GLYPH,isProgressPulseVisible}from"#cli/ui/progress-pulse.js";import{readGatewayServiceTier}from"#shared/gateway-service-tier.js";function isMultiSelectRequest(e){return e.kind===`multi`||e.kind===`searchable-multi`}function moveActionCursor(e,t,n){return n===0?void 0:e===void 0?t===`down`?0:n-1:(e+(t===`down`?1:-1)+n)%n}function completedTurnStatus(e){return e.interrupted?`Interrupted`:e.cancelled?`Cancelled`:e.continueSession?`Ready`:`Done`}function turnActivityLabel(e){return e===void 0?`Thinking`:e.runningTools.size>0?`Running`:e.modelActivity}function updateTurnActivity(e,t){switch(t.type){case`turn-start`:case`step-start`:case`reasoning-delta`:e.modelActivity=`Thinking`;break;case`assistant-delta`:case`tool-call-preparing`:e.modelActivity=`Generating`;break;case`assistant-complete`:t.text?.trim()&&(e.modelActivity=`Generating`);break;case`tool-call`:e.runningTools.add(t.toolCallId),e.modelActivity=`Thinking`;break;case`tool-result`:case`tool-error`:case`tool-rejected`:e.runningTools.delete(t.toolCallId)}}const incompletePasteFlushMs=1e3,STATUS={processing:`Thinking`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h=[];#g=new Map;#_=new Set;#v=[];#y=new Set;#b=new Map;#x=0;#S=new Map;#C=new Set;#w=new Set;#T=new FileContentCache;#E=new Set;#D;#O;#k;#A;#j=0;#M;#N=!1;#P;#F=[];#I;#L=0;#R;#z;#B=``;#V=0;#H=new PromptHistory;#U=!1;#W;#G=!1;#K=!1;#q=new TurnClock;#J;#Y=EMPTY_LINE;#X=!1;#Z={kind:`idle`};#Q;#$=STATUS.processing;#ee;#te=`eve`;#ne=!1;#re=!1;#ie=!1;#ae=!1;#oe=!1;#se=!1;#ce=!1;#le;#ue=!0;#de=0;#fe=Date.now();#pe;#me;#he;#ge=!1;#_e;#ve=``;#ye=new StringDecoder(`utf8`);#be;#xe;#Se;#Ce=!1;#we=!1;#Te;#Ee;#De;#Oe;#ke;#Ae;#je;#Me=``;#Ne=``;#Pe;#Fe;#Ie;#Le=!1;#Re;#ze=0;#Be;#Ve;#He;#Ue;#We;#Ge;#Ke;#qe;#Je=new MessageQueue;#Ye;#Xe;#Ze=!1;#Qe;#$e;#et=!1;#tt;#nt;#rt;#it;#at;setupFlow={begin:(e,t)=>this.#ft(e,t),setNavigation:e=>this.#pt(e),end:e=>this.#mt(e?.preserveDiagnostics??!0),readSelect:e=>this.#ht(e),readEditableSelect:e=>this.#_t(e),readProviderPicker:e=>this.#vt(e),readModelPicker:e=>this.#yt(e),readText:e=>this.#bt(e),readAcknowledge:e=>this.#xt(e),readChoice:e=>this.#gt(e),setStatus:e=>this.#kt(e),renderLine:(e,t)=>this.#At(e,t),replaceContent:e=>this.#jt(e),renderOutput:e=>this.#Mt(e),withInheritedStdio:e=>this.#Nt(e),withExclusiveTerminal:e=>this.#Nt(e),waitForInterrupt:e=>this.#Et(e)};traceViewer={open:e=>this.#Ft(e)};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=new AltScreen(this.#t),this.#i=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#a=e?.renderMarkdown??detectMarkdownRendering(),this.#o=e?.tools??`auto-collapsed`,this.#s=e?.reasoning??`auto-collapsed`,this.#c=e?.subagents??`auto-collapsed`,this.#l=e?.connectionAuth??`full`,this.#u=e?.assistantResponseStats??`tokensPerSecond`,this.#De=e?.contextSize,this.#d=e?.captureForeignOutput??this.#t===process.stdout,this.#f=e?.diagnostics,this.#le=e?.onExitRequest,this.#m=e?.logs??`none`,this.#p=e?.availablePromptCommands??PROMPT_COMMANDS}setStartupPhase(e){this.#O=e,e===void 0?this.#tn():this.#$t(),this.#On()}renderAgentHeader(e){this.#M=void 0,this.#te=e.name,(this.#D?.info?.agent.model.routing.kind!==`dynamic`||e.info?.agent.model.routing.kind!==`dynamic`)&&(this.#We=void 0),this.#D=e,this.#Rt();let t=this.#Nn().join(`
|
|
2
|
+
`);if(this.#N){t!==this.#P&&(this.#P=t,this.#an({kind:`agent-header`,body:t,live:!1})),this.#On();return}this.#N=!0,this.#P=t,this.#n.flush(this.#Nn(),this.#Rn(this.#qn()))}beginStartupDraft(e){this.#Rt({title:e.title}),this.#U=!0,this.#G=!0,this.#O=`starting`,this.#M={name:e.title},this.#j=Date.now();let t=lineOf(stripPromptControlCharacters(e.initialDraft??``));this.#k=t,this.#st(t),this.#Xt(),this.#$t(),this.#On();let apply=e=>{t=e,this.#k=e,this.#Qt(),this.#st(t),this.#On()};this.#A=e=>{if(e.type===`escape`&&this.#nt!==void 0){this.#nt(`escape`);return}if(e.type===`ctrl-c`&&this.#nt!==void 0){this.#Pt(),this.#nt(`ctrl-c`);return}let n=applyLineEditorKey(t,e,{multiline:!0});if(n!==void 0){apply(n);return}if(e.type===`enter`&&t.text.trim().length>0){this.#Je.enqueue(t.text)&&apply(EMPTY_LINE);return}e.type===`ctrl-c`&&this.#le?.()},this.#ot()}#ot(){this.#k!==void 0&&this.#A!==void 0&&(this.#qt(),this.#st(this.#k),this.#U=!0,this.#_e=this.#A,this.#Vt())}finishStartupDraft(){let e={draft:this.#k?.text??this.#B,queuedPrompt:this.#Je.takePrompt()};return this.#k=void 0,this.#A=void 0,this.#Ht(),this.#Zt(),this.#U=!1,this.#G=!1,e}async readPrompt(e){this.#Rt(e),this.#in(),this.#sn(),this.#U=!0,this.#G=!0,this.#Z={kind:`idle`},this.#$=``,this.#se=this.#ce,this.#ce=!1;let t=this.#Je.restoreDraft()?.split(`
|
|
3
3
|
`).map(stripPromptControlCharacters).join(`
|
|
4
|
-
`),n=stripPromptControlCharacters(e?.initialDraft??this.#J.text),r=t===void 0?n:n.length===0?t:`${t}\n\n${n}`,i=lineOf(r);return this.#J=EMPTY_LINE,this.#H.begin(i.text),this.#ot(i),this.#W=typeaheadFor(this.#p,i.text),this.#Yt(),this.#Dn(),await new Promise((e,t)=>{this.#Z=t;let apply=e=>{i=e,this.#Zt(),this.#ot(i),this.#W=typeaheadFor(this.#p,e.text,this.#W),this.#Dn()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#W=void 0,this.#Xt(),this.#zt(),t(interruptedError())},suggestions=()=>this.#W!==void 0&&isTypeaheadOpen(this.#W)?this.#W:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#ge=t=>{t.type!==`ctrl-c`&&this.#oe&&(this.#oe=!1,this.#Dn());let n=applyLineEditorKey(i,t,{multiline:!0});if(n!==void 0){apply(n);return}switch(t.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#W=moveTypeaheadSelection(e,-1),this.#Dn();break}let t=movePromptLine(i,`up`);t===void 0?recall(this.#H.previous(i.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#W=moveTypeaheadSelection(e,1),this.#Dn();break}let t=movePromptLine(i,`down`);t===void 0?recall(this.#H.next()):apply(t);break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#W=dismissTypeahead(e),this.#Dn());break}case`enter`:{let t=highlighted(),n=t!==void 0&&parsePromptCommand(i.text)===null?typeaheadCompletion(t).trimEnd():i.text;if(n.trim().length===0)break;this.#W=void 0,this.#H.add(n),this.#U=!1,this.#Xt(),this.#Q=STATUS.processing,isPromptControlCommand(n)?this.#in({kind:`command`,body:stripTerminalControls(n.trim()),live:!1}):(this.#$t(),this.#an(n),this.#ze=n,this.#q.arm()),this.#ot(EMPTY_LINE),this.#Dn(),this.#Vt(),e(n);break}case`ctrl-d`:i.text.length===0?(this.#Nt(),interrupt()):apply(deleteForward(i));break;case`ctrl-l`:this.#An();break;case`ctrl-r`:this.#Dn();break;case`ctrl-c`:if(this.#oe){this.#Nt(),interrupt();break}this.#oe=!0,apply(EMPTY_LINE)}},this.#Bt()})}#ot(e){this.#B=e.text,this.#V=e.cursor}takeQueuedPrompt(){let e=this.#qe.view().steering,t=this.#qe.takePrompt();return t!==void 0&&(this.#Qe=e?`steer`:`queue`),t}async renderStream(e,t){this.#Lt(t),this.#_.clear(),this.#U=!1,this.#X.kind!==`waiting`&&(this.#X={kind:`waiting`,startedAtMs:Date.now()}),this.#Q=this.#L>0?STATUS.connectionAuth:STATUS.processing,this.#sn(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#f?.recordPrompt(),t?.submittedPrompt!==void 0&&!this.#q.armed&&this.#q.arm(),this.#ie=!1,this.#Xe=!1,this.#$e=!1,this.#et=t?.submittedPrompt,this.#qe.beginTurn(),this.#Je=e.cancel,this.#Ye=e.steer,this.#we=void 0,this.#Te=void 0,this.#De=void 0,this.#Oe=void 0,this.#ke=Date.now();let n={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u};this.#Qt(),this.#Y=!0,this.#Dn();let r=new Promise(e=>{this.#xe=e});this.#ge=e=>this.#qt(e),this.#Bt();let i={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!0};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#ie)break;this.#hn(t,n,i)}}catch(e){let t=summarizeKnownError(e);t===null?this.#cn(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#cn(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#xe=void 0,this.#ie&&e.abort?.(),this.#Je=void 0,this.#Ye=void 0,this.#Vt(),this.#Y=!1,this.#X.kind===`waiting`&&(this.#X={kind:`idle`}),this.#rn(),this.#Q=completedTurnStatus({interrupted:this.#ie,cancelled:this.#Xe,continueSession:t?.continueSession===!0}),this.#Sn(i),(this.#ie||i.cancelled)&&this.#xn(i),this.#mn(),this.#rn(),this.#f?.reportStats(),this.#Dn(),t?.continueSession||this.#zt()}}async renderIdleStream(e,t){let n={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u},r={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!1};try{for await(let t of iterateTUIStream(e.events))this.#hn(t,n,r)}catch(e){let t=summarizeKnownError(e);t===null?this.#cn(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#cn(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#Sn(r),r.cancelled&&this.#xn(r),this.#mn(),this.#rn(),this.#f?.reportStats(),this.#Dn()}}async readToolApproval(e,t){return this.#Lt(t),this.#en(),this.#U=!1,this.#X={kind:`idle`},this.#Q=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#ie=!1,this.#Dn(),await new Promise((t,n)=>{this.#Z=n,this.#ge=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#$t(),this.#Q=STATUS.processing,this.#Vt(),this.#Dn(),t({approved:!0})):n===`n`&&(this.#$t(),this.#Q=STATUS.processing,this.#ct(e.toolCallId),this.#Vt(),this.#Dn(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#Dn();break;case`ctrl-c`:this.#ie=!0,this.#zt(),n(interruptedError())}},this.#Bt()})}async readInputQuestion(e,t){this.#Lt(t),this.#en(),this.#U=!1,this.#G=!1,this.#X={kind:`idle`},this.#ie=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`overlay`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,overlayPanel=t=>renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#le},this.#i,t),renderTextSection=()=>{this.#un({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,void 0,this.#i),preformatted:!0,live:!0})},syncFreeformCaret=()=>{isOnFreeformRow()?this.#Yt():(this.#Xt(),this.#Zt())};s===`overlay`?(s=`overlay`,this.#U=!1,this.#fn(o),this.#Be=overlayPanel,this.#Q=``,syncFreeformCaret(),this.#Dn()):(s=`text`,this.#Be=void 0,renderTextSection(),this.#U=!0,this.#ot(l),this.#Q=``,this.#Yt(),this.#Dn());let finalize=t=>{this.#Be=void 0,this.#un({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#U=!1,this.#$t(),this.#Q=STATUS.processing,this.#Xt(),this.#Vt(),this.#Dn();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#Be=void 0,this.#un({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Dismissed.`)}`,preformatted:!0,live:!1}),this.#U=!1,this.#Q=``,this.#Xt(),this.#Vt(),this.#Dn(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#Dn())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,r)=>{this.#Z=r,u=t,this.#ge=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#Zt(),s===`text`&&this.#ot(l),this.#Dn();return}this.#ie=!0,this.#Be=void 0,this.#Xt(),this.#zt(),r(interruptedError());return}if(t.type===`ctrl-r`){this.#Dn();return}if(s===`overlay`){let r=setupSelectionIntent(t,{textNavigation:!isOnFreeformRow()});if(r?.kind===`move`){moveCursor(r.direction===`up`?-1:1);return}switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#Zt(),this.#Dn();break}dismiss();break;default:if(isOnFreeformRow()){let e=applyLineEditorKey(l,t);e!==void 0&&(l=e,this.#Zt(),this.#Dn());break}if(t.type===`text`&&/^[1-9]$/u.test(t.value)){let e=Number(t.value)-1;e<n.length?selectOptionAt(e):e===n.length&&i&&(c=e,syncFreeformCaret(),this.#Dn())}}return}let a=applyLineEditorKey(l,t,{multiline:!0});if(a!==void 0){l=a,this.#Zt(),this.#ot(l),this.#Dn();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#Zt(),this.#ot(l),this.#Dn());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#Zt(),this.#ot(l),this.#Dn();break}dismiss()}},this.#Bt()})}upsertSubagentStep(e){if(this.#f?.recordSubagentDispatch(e.callId),this.#c===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(t.length!==0||n.length!==0){if(this.#ln(e.callId,e.subagentName),this.#c===`collapsed`){this.#Dn();return}this.#dn({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,subagentCallId:e.callId,depth:1,reasoning:t,body:n,collapsed:this.#c!==`full`,live:!e.finalized}),this.#Dn()}}upsertSubagentTool(e){if(this.#f?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#f?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#c===`hidden`)return;if(this.#ln(e.callId,e.subagentName),this.#c===`collapsed`){this.#Dn();return}let t=subagentToolStatus(e.status),n=e.status===`preparing`?presentPreparingTool(e.toolName):presentTool(e.toolName,e.input,this.#yn({input:e.input,output:e.output,toolCallId:e.childCallId,toolName:e.toolName})),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,subagentCallId:e.callId,depth:1,title:stripTerminalControls(n.title),subtitle:stripTerminalControls(n.subtitle),status:t,live:t===`running`||t===`approval`,expanded:this.#c===`full`,toolName:e.toolName,toolGroup:n.group,toolInput:e.input};n.doneTitle!==void 0&&(r.doneTitle=stripTerminalControls(n.doneTitle)),n.detail!==void 0&&(r.detailLines=n.detail,r.keepDetailWhenDone=n.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=n.summarizeResult(e.output),r.toolOutput=e.output),this.#dn(r),this.#st(e.callId),this.#Dn()}#st(e){applyCohortLiveness(this.#h.filter(t=>t.kind===`subagent-tool`&&t.subagentCallId===e).map(e=>({block:e,active:isActiveToolStatus(e.status)})))}removeSubagentTool(e){this.#fn(subagentToolSectionId(e.callId,e.childCallId)),this.#Dn()}subagents={begin:e=>this.beginSubagent(e),background:e=>this.backgroundSubagent(e),upsertStep:e=>this.upsertSubagentStep(e),upsertTool:e=>this.upsertSubagentTool(e),removeTool:e=>this.removeSubagentTool(e),complete:e=>this.completeSubagent(e),markChildToolCallId:e=>this.markChildToolCallId(e)};beginSubagent(e){if(this.#c===`hidden`)return;this.#ln(e.callId,e.name);let t=this.#g.get(subagentHeaderId(e.callId));t!==void 0&&(t.status===`done`&&delete t.status,t.live=!0),this.#w.delete(e.callId),this.#Dn()}backgroundSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t===void 0||this.#_.has(subagentHeaderId(e.callId)))return;t.status=`running`,t.live=!0,t.updateSeq=++this.#x;let n=this.#C.has(e.callId);this.#C.add(e.callId),n||this.#pn(e.callId),this.#rn(),this.#Dn()}completeSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t!==void 0){if(t.status=`done`,e.authoritative){this.#C.delete(e.callId),this.#w.delete(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!1)}else{this.#w.add(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!0)}this.#rn(),this.#Dn()}}markChildToolCallId(e){this.#y.add(e);let t=this.#b.get(e);t!==void 0&&(this.#fn(t),this.#b.delete(e),this.#Dn())}#ct(e){let t=this.#g.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#l===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#un({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e,t),preformatted:!0,live:t===void 0}),this.#Dn()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#L)return;let n=this.#L>0;this.#L=t,t>0?(this.#Q=STATUS.connectionAuth,this.#Dn()):n&&(this.#Q=STATUS.processing,this.#Dn())}setVercelStatus(e){this.#R=e,this.#Dn()}setRemoteConnectionStatus(e){this.#z=e,this.#Dn()}reset(){this.#h=[],this.#g.clear(),this.#_.clear(),this.#I=void 0,this.#F.length=0,this.#v.length=0,this.#N=!1,this.#P=void 0,this.#lt(),this.#K=!1,this.#ze=void 0,this.#Pe=void 0,this.#L=0,this.#we=void 0,this.#Te=void 0,this.#De=void 0,this.#Oe=void 0,this.#ke=void 0,this.#te&&(this.#n.clearAll(),this.#Dn())}renderSessionBoundary(){this.#on(),this.#lt();let e=this.#i.colors,t=this.#i.glyph,n=e.dim(`${t.cornerOpen}${t.dash.repeat(2)} Session restarted, clear context.`);this.#in({kind:`session-boundary`,body:n,live:!1}),this.#Dn()}#lt(){this.#Ue=void 0,this.#We=void 0,this.#y.clear(),this.#b.clear(),this.#E.clear(),this.#C.clear(),this.#w.clear(),this.#S.clear(),this.#Ge=void 0,this.#Ke=void 0,this.#qe.reset(),this.#Qe=void 0,this.#T.clear(),this.#q.reset(),this.#rn()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Lt(),this.#in({kind:`notice`,body:t,live:!1}),this.#Dn())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#f?.append({source:`sandbox`,detail:t}),this.#Lt(),this.#in({kind:`sandbox`,body:t,live:!1}),this.#Dn())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#ut();return}this.#Lt(),this.#He=t,this.#Dn()}clearSetupWarning(){this.#ut()}#ut(){this.#He!==void 0&&(this.#He=void 0,this.#Dn())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#Lt();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#in(r),this.#Dn()}renderCommandResult(e,t){let n=stripAnsi(e);n.trim().length!==0&&(this.#Lt(),this.#in({kind:`result`,body:n,live:!1,status:t===`success`?`done`:void 0}),this.#Dn())}#dt(e,t=`spinner`){this.#Lt(),this.#k===void 0&&(this.#U=!1),this.#X={kind:`idle`},this.#Q=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#Ve={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#Qt(),this.#Dn()}#ft(e){this.#Ve!==void 0&&(this.#Ve.navigation=e,this.#Dn())}#pt(e){this.#tt=void 0,this.#Dt();let t=this.#Ve;if(t!==void 0){if(this.#Ve=void 0,this.#k===void 0?this.#en():this.#at(),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.#in({kind:`flow`,title:`info`,body:e.join(`
|
|
5
|
-
`),live:!1}),this.#
|
|
6
|
-
`,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#yt(e){let t=this.#xt(e.message),n=lineOf(``),r;return t.question=t=>{let i={message:``,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#le)},this.#Yt(),this.#Dn(),await this.#wt((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Zt(),this.#Dn()},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.#Dn();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#Dn();return}i(t);return}default:return}},()=>this.#Xt()).promise}async#bt(e){let t=this.#xt(e.message);return t.question=t=>renderAcknowledgeQuestion({message:``,lines:e.lines},this.#i,t),this.#Dn(),await this.#wt((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#Dn();return;default:return}}).promise}#xt(e){this.#Lt(),this.#U=!1,this.#X={kind:`idle`},this.#Q=``;let t=this.#St();return t.questionTitle=stripTerminalControls(e),t.status!==void 0&&(t.status=void 0,t.summary=void 0,t.preview=void 0),t}#St(){return this.#Ve===void 0&&(this.#Ve={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#Ve}#Ct(){this.#Ve?.implicit===!0?this.#Ve=void 0:this.#Ve!==void 0&&(this.#Ve.question=void 0,this.#Ve.questionTitle=void 0,this.#Ve.hideLinesWhileQuestion=!1),this.#ge=void 0,this.#Vt(),this.#k===void 0?this.#Ve!==void 0&&this.#Et():this.#at(),this.#Ve===void 0&&this.#Dn()}#wt(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#Ct(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#Ct(),i(e))};return this.#Kt(),this.#ge=t=>{t.type===`ctrl-c`&&this.#Nt(),e(t,settle,reject)},this.#Bt(),{promise:a,settle}}#Tt(e){let t,n=new Promise(e=>{t=e});return this.#tt=t,this.#Et(e?.interruptible??!0),{promise:n,dispose:()=>{this.#tt===t&&(this.#tt=void 0,this.#Dt())}}}#Et(e=!0){if(this.#k!==void 0){this.#at();return}if(this.#tt===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#Nt();let e=this.#tt;this.#tt=void 0,this.#Dt(),e?.(t.type===`ctrl-c`?`ctrl-c`:`escape`);return}t.type===`ctrl-r`&&this.#Dn()};this.#nt=consumer,this.#Kt(),this.#ge=consumer,this.#Bt()}#Dt(){this.#nt!==void 0&&(this.#ge===this.#nt&&this.#Vt(),this.#nt=void 0)}#Ot(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#Ve!==void 0){this.#Ve.status=t,t===void 0&&(this.#Ve.preview=void 0),this.#Dn();return}if(!(this.#U||this.#Y)){if(t===void 0){this.#X={kind:`idle`},this.#$=void 0,this.#en(),this.#Dn();return}this.#Lt(),this.#$t(),this.#$=t.text,this.#Dn()}}#kt(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Ve;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#Dn();return}this.#Lt(),this.#in({kind:`flow`,title:t,body:n,live:!1}),this.#Dn()}#At(e){let t=this.#Ve;t!==void 0&&(t.lines=[],t.outputBuffer=[],t.preview=void 0,t.status=void 0,t.summary=e===void 0?void 0:{headline:stripTerminalControls(e.headline),facts:e.facts.map(e=>({label:stripTerminalControls(e.label),value:stripTerminalControls(e.value)}))},this.#Dn())}#jt(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Ve;if(n===void 0){this.#kt(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#Dn()}async#Mt(e){this.#_e=``,this.#Kt(),this.#tt=void 0,this.#Dt(),this.#Vt(),this.#tn(),this.#n.clear(),this.#Yn(),this.#r.enter({cursor:`visible`,mouse:!1}),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#r.exit(),this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#_e=``,this.#Kt(),this.#n.hideCursor(),this.#Jn(),this.#Ve===void 0?this.#rn():(this.#Qt(),this.#Et()),this.#n.reset(),this.#Dn()}}setSessionId(e){this.#Ze=e}shutdown(){if(this.#zt(),this.#ne&&!this.#re){this.#re=!0;let e=this.#Ze===void 0?``:` ${this.#i.glyph.dot} session ${this.#Ze}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}suspendPromptForInput(){this.#J={cursor:this.#V,text:this.#B},this.#zt()}requestInterrupt(){this.#ie=!0,this.#Ve!==void 0&&this.#ge?.({type:`ctrl-c`}),this.#xe?.(),this.#zt()}exitRequested(){return this.#ae}#Nt(){this.#ae=!0,this.#ce?.()}async#Pt(e){if(this.#rt!==void 0||!this.#te)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Kn(),height:this.#qn()}),paint:e=>this.#r.paint(e,this.#qn()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#it});this.#rt=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#It=e,this.#ge=e=>{t.handleKey(e)===`close`&&this.#Ft()},this.#Bt(),t.start()})}#Ft(){let e=this.#rt;if(e===void 0)return;this.#rt=void 0,e.dispose(),this.#Vt(),this.#r.exit(),this.#n.hideCursor(),this.#Dn(),this.#n.showCursor();let t=this.#It;this.#It=void 0,t?.()}#It;#Lt(e){this.#ee=e?.title??this.#ee,e?.contextSize!==void 0&&(this.#Ee=e.contextSize),!this.#te&&(this.#te=!0,this.#ne=!0,this.#n.reset(),this.#n.hideCursor(),this.#Jn(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#be=()=>this.#Dn(),this.#t.on(`resize`,this.#be),process.on(`exit`,this.#Rt))}#Rt=()=>{this.#te&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#zt(){this.#Ft();let e=this.#Z;if(this.#Z=void 0,e?.(interruptedError()),this.#Vt(),this.#Xt(),this.#tn(),this.#me!==void 0&&(clearTimeout(this.#me),this.#me=void 0),this.#he=!1,this.#rr(),this.#te){this.#ar();for(let e of this.#h)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#Dn(),this.#n.clear(),this.#n.showCursor(),this.#Yn(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#be&&=(this.#t.off(`resize`,this.#be),void 0),process.off(`exit`,this.#Rt),this.#te=!1}}#Bt(){this.#e.off(`data`,this.#Ht),this.#e.on(`data`,this.#Ht),this.#_e.length>0&&queueMicrotask(()=>{this.#ge!==void 0&&this.#_e.length>0&&(this.#Wt(),this.#Ut())})}#Vt(){this.#e.off(`data`,this.#Ht),this.#Kt(),this.#ge=void 0}#Ht=e=>{this.#Kt(),this.#_e+=this.#ve.write(e),this.#Wt(),this.#Ut()};#Ut(){if(this.#_e===`\x1B`){this.#ye=setTimeout(()=>{this.#_e===`\x1B`&&(this.#_e=``,this.#ge?.({type:`escape`}))},30),this.#ye.unref?.();return}if(isIncompletePaste(this.#_e)){let e=this.#_e;this.#ye=setTimeout(()=>{if(this.#_e!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#_e=``,t.length>0&&this.#ge?.({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#ye.unref?.();return}if(isIncompleteOsc(this.#_e)){let e=this.#_e;this.#ye=setTimeout(()=>{this.#_e===e&&(this.#_e=``)},incompletePasteFlushMs),this.#ye.unref?.()}}#Wt(){for(;this.#_e.length>0;){let e=nextKey(this.#_e);if(e.incomplete)return;if(this.#_e=this.#_e.slice(e.consumed),e.key!==void 0&&e.key.type!==`ignore`){if(e.key.type===`osc`){this.#Gt(e.key.value);continue}this.#ge?.(e.key)}}}#Gt(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#it=t,this.#rt?.setTerminalBackground(t))}#Kt(){this.#ye&&=(clearTimeout(this.#ye),void 0)}#qt(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#Dn();break;case`enter`:{let e=this.#J.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#Je!==void 0){this.#J=EMPTY_LINE,this.#qe.requestCancellation(),this.#$e=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#Je(),this.#Dn();break}let t=this.#Ye;t!==void 0&&parsePromptCommand(e)===null?(this.#J=EMPTY_LINE,this.#Jt(e,t)):this.#qe.enqueue(e)&&(this.#J=EMPTY_LINE),this.#Dn();break}case`ctrl-c`:case`escape`:if(e.type===`ctrl-c`&&this.#qe.view().cancelling){this.#ie=!0,this.#se=!0,this.#X={kind:`idle`},this.#Q=`Interrupted`,this.#xe?.(),this.#Dn();break}if(this.#qe.idle&&this.#Je===void 0)break;if(this.#qe.handleEscape()===`steer`){let e=this.#Ye;if(e!==void 0){let t=this.#qe.takeSteering();this.#Jt(t,e)}}else this.#$e=!0,this.#Je?.();this.#Dn();break;default:{let t=applyLineEditorKey(this.#J,e,{multiline:!0});t!==void 0&&(this.#J=t,this.#Dn());break}}}#Jt(e,t){this.#Qe=`steer`,this.#sn(e),t(e).catch(t=>{this.#qe.restoreSteering(e),this.#cn(`Steering failed`,toErrorMessage(t)),this.#Dn()})}#Yt(){this.#Xt(),this.#Zt(),this.#fe=setInterval(()=>{this.#le=!this.#le,this.#Dn()},500),this.#fe.unref?.()}#Xt(){this.#fe&&=(clearInterval(this.#fe),void 0),this.#le=!0}#Zt(){this.#le=!0}#Qt(){this.#tn(),this.#pe=setInterval(()=>{this.#ue+=1,this.#Dn()},90),this.#pe.unref?.()}#$t(){let e=Date.now();this.#de=e,this.#X={kind:`waiting`,startedAtMs:e},this.#Qt()}#en(){this.#nn()||this.#tn()}#tn(){this.#pe&&=(clearInterval(this.#pe),void 0)}#nn(){return this.#h.some(e=>e.live&&e.subagentCallId!==void 0&&(this.#C.has(e.subagentCallId)||this.#w.has(e.subagentCallId)))}#rn(){this.#nn()?this.#Qt():!this.#Y&&this.#X.kind===`idle`&&this.#tn()}#in(e){e.id!==this.#Pe?.id&&this.#ar(),e.updateSeq=++this.#x;let t=e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId)?-1:this.#h.findIndex(e=>e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId));t<0?this.#h.push(e):this.#h.splice(t,0,e),e.id&&this.#g.set(e.id,e)}#an(e){this.#K=!0,this.#in({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#Dn()}#on(){let e=this.#q.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#zn(e.elapsedMs)}`,n=this.#Te??0;if(this.#Ee!==void 0&&this.#Ee>0&&n>0){let e=Math.round(n/this.#Ee*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#in({kind:`turn-stats`,body:t,live:!1})}#sn(e){if(e==null)return;let t=this.#Qe;if(this.#Qe=void 0,this.#ze===e){this.#ze=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#in(n)}#cn(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#f?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#f===void 0?a:`details: ${this.#f.displayPath}`),this.#in(c),this.#Dn()}#ln(e,t){if(this.#E.has(e))return;this.#E.add(e);let n=stripTerminalControls(t),r=this.#S.get(n)??[];if(r.push(e),this.#S.set(n,r),r.length===2){let e=this.#g.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#in(i)}#un(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#x;return}this.#in(e)}#dn(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t!==void 0){Object.assign(t,e),t.updateSeq=++this.#x;return}let n=e.subagentCallId;if(n===void 0){this.#in(e);return}e.id!==this.#Pe?.id&&this.#ar(),e.updateSeq=++this.#x;let r=-1;for(let e=0;e<this.#h.length;e+=1)this.#h[e]?.subagentCallId===n&&(r=e);this.#h.splice(r<0?this.#h.length:r+1,0,e),e.id!==void 0&&this.#g.set(e.id,e)}#fn(e){this.#h=this.#h.filter(t=>t.id!==e),this.#g.delete(e)}#pn(e){let t=this.#h.filter(t=>t.subagentCallId===e);t.length!==0&&(this.#h=this.#h.filter(t=>t.subagentCallId!==e),this.#h.push(...t))}#mn(){for(let e of this.#h)e.subagentCallId!==void 0&&this.#w.has(e.subagentCallId)||e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#hn(e,t,n){switch(e.type){case`turn-start`:e.turnId!==this.#We&&(this.#We=e.turnId,this.#Ue=void 0,this.#Dn());break;case`step-start`:this.#Ue=typeof e.modelId==`string`&&stripTerminalControls(e.modelId.slice(0,256)).replace(/\s+/gu,` `).trim()||void 0,this.#Dn();break;case`step-finish`:this.#f?.recordStepUsage(e.usage),e.usage!==void 0&&this.#q.addUsage(e.usage),this.#Sn(n),this.#En(e.usage),this.#Dn();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#gn(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=typeof e.text==`string`?stripTerminalControls(e.text):t;n.text.set(e.id,r),this.#gn(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#_n(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#_n(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#vn({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#f?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#vn({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.#vn({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#Tn(e.toolCallId,n);if(r===void 0)break;this.#vn({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#Tn(e.toolCallId,n);if(this.#f?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#vn({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#Tn(e.toolCallId,n);if(r===void 0)break;this.#vn({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#cn(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:if(n.cancelled=!0,!n.restoreCancelledPrompt)break;this.#Xe=!0,!this.#$e&&this.#et!==void 0&&this.#J.text.length===0&&(this.#J=lineOf(this.#et),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#En(e.usage),this.#Dn()}}#gn(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#un({id:e,kind:`assistant`,body:r,live:n}),this.#Dn())}#_n(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#un({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#Dn())}#vn(e,t,n){if(n.tools.set(e.toolCallId,e),this.#y.has(e.toolCallId)||this.#Cn(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#b.set(e.toolCallId,r);let i=this.#yn(e);this.#un(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#wn(n),this.#Dn()}#yn(e){e.output!==void 0&&this.#T.observeRead(e.output);let t={};this.#bn(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#T.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#bn(e){let t=this.#D?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#xn(e){for(let t of e.tools.keys()){if(this.#y.has(t))continue;let e=this.#b.get(t)??toolSectionId(t),n=this.#g.get(e);n?.kind===`tool`&&n.status===`running`&&(n.status=`error`,n.result=`interrupted`,n.live=!1)}}#Sn(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#b.get(t)??toolSectionId(t);this.#fn(r),this.#b.delete(t)}}#Cn(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#Ke!==e&&(this.#Ke=e,this.#in({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#Kn(),this.#i).join(`
|
|
7
|
-
`),live:!1})),this.#Ge=void 0}else this.#Ge=t.length>0?t:void 0,this.#Ke=void 0;return this.#Dn(),!0}#wn(e){let t=[];for(let n of e.tools.values()){if(this.#y.has(n.toolCallId))continue;let e=this.#b.get(n.toolCallId)??toolSectionId(n.toolCallId),r=this.#g.get(e);r?.kind===`tool`&&t.push({block:r,active:isActiveToolStatus(n.status)})}applyCohortLiveness(t)}#Tn(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#b.get(e)??toolSectionId(e),i=this.#g.get(r);if(i!==void 0&&i.kind===`tool`)return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.toolName??i.title??`tool`}}#En(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#we=(t??0)+(n??0)),this.#Te=t??this.#Te,this.#De=n??this.#De,this.#De!=null&&this.#ke!==void 0){let e=(Date.now()-this.#ke)/1e3;e>0&&(this.#Oe=this.#De/e)}}#Dn(){if(this.#te){if(this.#Se){this.#Ce=!0;return}this.#Se=!0;try{do this.#Ce=!1,this.#On();while(this.#Ce)}finally{this.#Se=!1}}}#On(){if(!this.#te)return;if(this.#rt!==void 0){this.#rt.repaint();return}let e=this.#Kn(),t=this.#Ln(e),n=this.#M===void 0?[]:this.#Mn(),r=Math.max(1,this.#qn()-n.length-t.length),i=[],a=this.#I,o=groupToolBlocksForDisplay(this.#h),s=0;for(;s<o.length&&o[s].display.live===!1;)s+=1;if(s>0){let e=new Set(o.slice(0,s).flatMap(e=>e.members));for(let t=this.#h.length-1;t>=0;--t)e.has(this.#h[t])&&this.#h.splice(t,1)}for(let t of o.slice(0,s)){for(let e of t.members)this.#v.push(e),e.id&&(this.#_.add(e.id),this.#g.delete(e.id));if(this.#sr(t.display))continue;let n=this.#Nn(t.display,e,a);a=previousBlockOf(t.display),this.#I=a,i.push(...n),this.#F.push(...n)}let c=[];for(let{display:t}of o.slice(s)){if(this.#sr(t))continue;let n=this.#Nn(t,e,a);a=previousBlockOf(t);for(let e=0;e<n.length;e+=1)c.push({block:t,row:n[e]})}let l=[...n,...clipLiveRows(c.map(e=>e.row),r,e,this.#i),...t];i.length>0?this.#n.flush(i,l):this.#n.update(l)}#kn(){if(!this.#te)return;let e=this.#Kn(),t=this.#Ln(e),n=Math.max(1,this.#qn()-t.length),r=this.#I,i=[];for(let{display:t}of groupToolBlocksForDisplay(this.#h)){if(this.#sr(t))continue;let n=this.#Nn(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#i),...t];this.#n.clearAll(),this.#n.flush([...this.#Mn(),...this.#F],a)}logDisplayMode(){return this.#m}setLogDisplayMode(e){e!==this.#m&&(this.#m=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#jn(),this.#te&&this.#kn())}flushDelayedDevBuildErrors(){let e=this.#Ne;e!==void 0&&(this.#Ne=void 0,this.#in({kind:`log`,title:`stderr`,body:e,live:!0}),this.#Dn())}#An(){this.#he=!0,this.#me!==void 0&&clearTimeout(this.#me),this.#me=setTimeout(()=>{this.#he=!1,this.#me=void 0,this.#Dn()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#m)),this.#Dn()}#jn(){let e=this.#Kn();this.#F.length=0;let t;for(let{display:n}of groupToolBlocksForDisplay(this.#v,{logCoalescing:`runs`})){if(this.#sr(n))continue;let r=this.#Nn(n,e,t);t=previousBlockOf(n),this.#F.push(...r)}this.#I=t}#Mn(){let e=this.#D,t=this.#M;if(e===void 0&&t===void 0)return[];let n={name:e?.name??t?.name,theme:this.#i,width:this.#Kn()};return e?.info!==void 0&&(n.info=e.info),buildAgentHeader(n)}#Nn(e,t,n){let r={renderMarkdown:this.#a,activityPulse:this.#Fn(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#i,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#Pn(){return this.#i.spinner[this.#ue%this.#i.spinner.length]??``}#Fn(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#In(e,t){return e.indicator.kind===`spinner`?{glyph:this.#Pn(),color:`yellow`}:{glyph:this.#Fn(e.indicator.startedAtMs,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#Ln(e){let t=this.#i.colors,n=[``];if(this.#Be!==void 0)return n.push(...this.#Be(e),``),this.#Un(n,e),n;let r=this.#Ve;if(r!==void 0&&(this.#k===void 0||r.question!==void 0)){let t=this.#In(r,r.status),i;if(r.status!==void 0){let{startedAtMs:e,...n}=r.status,a=Date.now()-e,o=a>=5e3?` ${formatTurnDuration(a)}`:``;i={...n,text:`${n.text}${o}`,indicator:t}}let a;if(r.question!==void 0){let t=r.question(e);a={kind:`question`,title:r.questionTitle,rows:t},i!==void 0&&(a={kind:`question`,title:r.questionTitle,rows:t,status:i})}else i===void 0?a=r.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:r.preview,indicator:t}:(a={kind:`status`,status:i},r.preview!==void 0&&(a={kind:`status`,status:i,preview:r.preview}));let o={title:r.title,navigation:r.navigation,lines:r.summary===void 0?r.hideLinesWhileQuestion===!0?[]:r.lines:[{text:r.summary.headline,tone:`success`},...r.summary.facts.map(e=>({text:`${e.label}: ${e.value}`,tone:`info`}))],content:a};return n.push(...renderFlowPanel(o,this.#i,e)),this.#Wn(n,e),n}r!==void 0&&n.push(...flowMessageRows(r.lines,this.#i).map(t=>t.length===0?``:clip(` ${t}`,e))),this.#O===void 0&&this.#He!==void 0&&n.push(...renderAttentionRows(this.#He,e,this.#i),``),this.#Ge!==void 0&&n.push(...renderTodoPanelRows({items:this.#Ge,width:e,theme:this.#i,working:this.#Y||this.#X.kind===`waiting`,pulse:this.#Fn(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)}),``);let i=renderMessageQueueRows({view:this.#qe.view(),width:e,theme:this.#i,working:this.#Y});if(i.length>0&&n.push(...i,``),this.#U){let r=this.#W===void 0?void 0:inlineCommandHint(this.#W);r===void 0&&this.#W!==void 0&&isTypeaheadOpen(this.#W)&&n.push(...renderCommandSuggestions(this.#W,this.#i,e)),this.#oe&&n.push(clip(t.dim(`Press Ctrl+C again to exit`),e),``);let i=isPromptControlCommand(this.#B),a=r?t.dim(` ${r}`):``,o=[];this.#Un(o,e);let s=Math.max(1,this.#qn()-1-n.length-1-o.length),c={text:this.#B,cursor:this.#V,width:e,theme:this.#i,caretVisible:this.#le,isCommand:i,ghost:a,maxRows:s};return this.#G&&this.#B.length===0&&(c.placeholder=this.#k===void 0?this.#K?``:`Send a message…`:`Message · Enter to queue`),n.push(...promptInputRows(c)),n.push(...o),n}let a=this.#X.kind===`waiting`&&this.#$===void 0;if(this.#Y||a){n.push(this.#Rn(e)),this.#Vn(n,e);let t=[];return this.#Un(t,e),!this.#Y&&t.length>0&&n.push(``),n.push(...t),n}if(this.#J.text.length>0)return this.#Hn(n,e,{inert:!1}),this.#Un(n,e),n;let o=this.#$??(this.#Q.length>0?this.#Q:`Ready`),s=this.#Gn(),c=t.dim(this.#i.glyph.dot),l=s?`${c} ${o} ${t.dim(this.#i.glyph.dot)} ${s}`:`${c} ${o}`;return n.push(clip(l,e)),this.#Un(n,e),n}#Rn(e){let t=this.#i.colors,n=this.#Fn(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),r=this.#X,i=this.#q.startedAtMs??this.#ke??(r.kind===`waiting`?r.startedAtMs:Date.now()),a=Date.now()-i,o=`${typewriterText(`Working for`,a,80)} ${this.#zn(a)}`;return clip(`${t.yellow(n)} ${t.dim(o)}`,e)}#zn(e){return`${formatTurnDuration(e)}${this.#Bn()}`}#Bn(){let{inputTokens:e,outputTokens:t}=this.#q.usage;return e===0&&t===0?``:` ${this.#i.glyph.dash.repeat(2)} ${formatTokenFlow({inputTokens:e,outputTokens:t},this.#i.glyph)}`}#Vn(e,t){this.#Y&&this.#Hn(e,t,{inert:!0})}#Hn(e,t,n){e.push(``);let r={text:this.#J.text,cursor:this.#J.cursor,width:t,theme:this.#i,caretVisible:!0,isCommand:!1,ghost:``,maxRows:4,inert:n.inert};n.inert&&this.#J.text.length===0&&(r.placeholder=``),e.push(...promptInputRows(r))}#Un(e,t){if(this.#O!==void 0){let n=this.#Ve?.status?.text??{starting:`Starting agent…`,connecting:`Reading saved connection…`,updating:`Loading selected model…`}[this.#O],r=this.#Fn(this.#j,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH);e.push(clip(this.#i.colors.dim(`${r} ${n}`),t));return}let n=this.#z===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#i,width:r};this.#Ie&&this.#Fe!==void 0&&(i.devBuild=this.#Fe),this.#he&&(i.logLevel=this.#m);let a=this.#D?.info?.agent.model;a?.routing.kind===`dynamic`?i.model=this.#Ue===void 0?`dynamic model`:`dynamic model · ${this.#Ue}`:a?.id!==void 0&&(i.model=a.id),a?.reasoning!==void 0&&a.reasoning!==`provider-default`&&(i.reasoning=a.reasoning),readGatewayServiceTier(a?.providerOptions).kind===`priority`&&(i.fastMode=!0);let o=a?.endpoint;o!==void 0&&(i.endpoint=o),this.#R!==void 0&&(i.vercel=this.#R),this.#z!==void 0&&(i.remote=this.#z);let s=buildStatusLine(i);s!==void 0&&e.push(clip(`${n}${s}`,t))}#Wn(e,t){if(this.#z===void 0)return;let n=Math.max(1,t-2),r=buildStatusLine({remote:this.#z,theme:this.#i,width:n});r!==void 0&&e.push(``,clip(` ${r}`,t))}#Gn(){let e=this.#i.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#we,outputTokens:this.#De,tokensPerSecond:this.#Oe},this.#u);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#i.glyph.dot} `)):``}#Kn(){return Math.max(20,this.#t.columns||80)}#qn(){return Math.max(8,this.#t.rows||24)}#Jn(){if(this.#Ae!==void 0||!this.#d)return;this.#je=``,this.#Me=``;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.#Zn(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#f?.subscribeLogRecords(e=>this.#Xn(e)),this.#Ae=()=>{this.#f?.unsubscribeLogRecords(),e(),t()}}#Yn(){let e=this.#Ae;e!==void 0&&(this.#Ae=void 0,e(),this.#je.length>0&&(this.#f?.append({source:`stdout`,detail:this.#je}),this.#or(`stdout`)&&process.stdout.write(`${this.#je}\n`),this.#je=``),this.#Me.length>0&&(this.#f?.append({source:`stderr`,detail:this.#Me}),this.#or(`stderr`)&&process.stderr.write(`${this.#Me}\n`),this.#Me=``))}#Xn(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#$n(`[eve:${e.namespace}] ${e.message}${t}`),this.#Dn()}#Zn(e,t){let n=(e===`stdout`?this.#je:this.#Me)+t;if(e===`stdout`&&parseDevRebuildLogLine(n.trimEnd())!==void 0){this.#je=``,this.#f?.append({source:e,detail:n.trimEnd()}),this.#Qn(n.trimEnd()),this.#Dn();return}let r=n.lastIndexOf(`
|
|
8
|
-
`),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#
|
|
9
|
-
`);t=[],e.trim().length!==0&&this.#
|
|
10
|
-
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#
|
|
11
|
-
`),n=t.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(n===-1){if(this.#f===void 0){this.#
|
|
12
|
-
`);r.trim().length>0&&this.#
|
|
13
|
-
`);this.#
|
|
4
|
+
`),n=stripPromptControlCharacters(e?.initialDraft??this.#Y.text),r=t===void 0?n:n.length===0?t:`${t}\n\n${n}`,i=lineOf(r);return this.#Y=EMPTY_LINE,this.#H.begin(i.text),this.#st(i),this.#W=typeaheadFor(this.#p,i.text),this.#Xt(),this.#On(),await new Promise((e,t)=>{this.#Q=t;let apply=e=>{i=e,this.#Qt(),this.#st(i),this.#W=typeaheadFor(this.#p,e.text,this.#W),this.#On()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#W=void 0,this.#Zt(),this.#Bt(),t(interruptedError())},suggestions=()=>this.#W!==void 0&&isTypeaheadOpen(this.#W)?this.#W:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#_e=t=>{t.type!==`ctrl-c`&&this.#se&&(this.#se=!1,this.#On());let n=applyLineEditorKey(i,t,{multiline:!0});if(n!==void 0){apply(n);return}switch(t.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#W=moveTypeaheadSelection(e,-1),this.#On();break}let t=movePromptLine(i,`up`);t===void 0?recall(this.#H.previous(i.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#W=moveTypeaheadSelection(e,1),this.#On();break}let t=movePromptLine(i,`down`);t===void 0?recall(this.#H.next()):apply(t);break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#W=dismissTypeahead(e),this.#On());break}case`enter`:{let t=highlighted(),n=t!==void 0&&parsePromptCommand(i.text)===null?typeaheadCompletion(t).trimEnd():i.text;if(n.trim().length===0)break;this.#W=void 0,this.#H.add(n),this.#U=!1,this.#Zt(),this.#$=STATUS.processing,isPromptControlCommand(n)?this.#an({kind:`command`,body:stripTerminalControls(n.trim()),live:!1}):(this.#en(),this.#on(n),this.#Be=n,this.#q.arm()),this.#st(EMPTY_LINE),this.#On(),this.#Ht(),e(n);break}case`ctrl-d`:i.text.length===0?(this.#Pt(),interrupt()):apply(deleteForward(i));break;case`ctrl-l`:this.#jn();break;case`ctrl-r`:this.#On();break;case`ctrl-c`:if(this.#se){this.#Pt(),interrupt();break}this.#se=!0,apply(EMPTY_LINE)}},this.#Vt()})}#st(e){this.#B=e.text,this.#V=e.cursor}takeQueuedPrompt(){let e=this.#Je.view().steering,t=this.#Je.takePrompt();return t!==void 0&&(this.#$e=e?`steer`:`queue`),t}async renderStream(e,t){this.#Rt(t),this.#_.clear(),this.#U=!1,this.#Z.kind!==`waiting`&&(this.#Z={kind:`waiting`,startedAtMs:Date.now()}),this.#$=this.#L>0?STATUS.connectionAuth:STATUS.processing,this.#cn(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#f?.recordPrompt(),t?.submittedPrompt!==void 0&&!this.#q.armed&&this.#q.arm(),this.#ae=!1,this.#Ze=!1,this.#et=!1,this.#tt=t?.submittedPrompt,this.#Je.beginTurn(),this.#Ye=e.cancel,this.#Xe=e.steer,this.#Te=void 0,this.#Ee=void 0,this.#Oe=void 0,this.#ke=void 0,this.#Ae=Date.now();let n={text:new Map,reasoning:new Map,tools:new Map,modelActivity:`Thinking`,runningTools:new Set,cancelled:!1,restoreCancelledPrompt:!0};this.#J=n;let r={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u};this.#$t(),this.#X=!0,this.#On();let i=new Promise(e=>{this.#Se=e});this.#_e=e=>this.#Jt(e),this.#Vt();try{for await(let t of takeUntil(iterateTUIStream(e.events),i)){if(this.#ae)break;this.#gn(t,r,n)}}catch(e){let t=summarizeKnownError(e);t===null?this.#ln(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#ln(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#Se=void 0,this.#ae&&e.abort?.(),this.#Ye=void 0,this.#Xe=void 0,this.#Ht(),this.#X=!1,this.#J=void 0,this.#Z.kind===`waiting`&&(this.#Z={kind:`idle`}),this.#in(),this.#$=completedTurnStatus({interrupted:this.#ae,cancelled:this.#Ze,continueSession:t?.continueSession===!0}),this.#Cn(n),(this.#ae||n.cancelled)&&this.#Sn(n),this.#hn(),this.#in(),this.#f?.reportStats(),this.#On(),t?.continueSession||this.#Bt()}}async renderIdleStream(e,t){let n={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u},r={text:new Map,reasoning:new Map,tools:new Map,modelActivity:`Thinking`,runningTools:new Set,cancelled:!1,restoreCancelledPrompt:!1};try{for await(let t of iterateTUIStream(e.events))this.#gn(t,n,r)}catch(e){let t=summarizeKnownError(e);t===null?this.#ln(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#ln(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#Cn(r),r.cancelled&&this.#Sn(r),this.#hn(),this.#in(),this.#f?.reportStats(),this.#On()}}async readToolApproval(e,t){return this.#Rt(t),this.#tn(),this.#U=!1,this.#Z={kind:`idle`},this.#$=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#ae=!1,this.#On(),await new Promise((t,n)=>{this.#Q=n,this.#_e=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#en(),this.#$=STATUS.processing,this.#Ht(),this.#On(),t({approved:!0})):n===`n`&&(this.#en(),this.#$=STATUS.processing,this.#lt(e.toolCallId),this.#Ht(),this.#On(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#On();break;case`ctrl-c`:this.#ae=!0,this.#Bt(),n(interruptedError())}},this.#Vt()})}async readInputQuestion(e,t){this.#Rt(t),this.#tn(),this.#U=!1,this.#G=!1,this.#Z={kind:`idle`},this.#ae=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`overlay`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,overlayPanel=t=>renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#ue},this.#i,t),renderTextSection=()=>{this.#dn({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,void 0,this.#i),preformatted:!0,live:!0})},syncFreeformCaret=()=>{isOnFreeformRow()?this.#Xt():(this.#Zt(),this.#Qt())};s===`overlay`?(s=`overlay`,this.#U=!1,this.#pn(o),this.#Ve=overlayPanel,this.#$=``,syncFreeformCaret(),this.#On()):(s=`text`,this.#Ve=void 0,renderTextSection(),this.#U=!0,this.#st(l),this.#$=``,this.#Xt(),this.#On());let finalize=t=>{this.#Ve=void 0,this.#dn({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#U=!1,this.#en(),this.#$=STATUS.processing,this.#Zt(),this.#Ht(),this.#On();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#Ve=void 0,this.#dn({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Dismissed.`)}`,preformatted:!0,live:!1}),this.#U=!1,this.#$=``,this.#Zt(),this.#Ht(),this.#On(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#On())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,r)=>{this.#Q=r,u=t,this.#_e=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#Qt(),s===`text`&&this.#st(l),this.#On();return}this.#ae=!0,this.#Ve=void 0,this.#Zt(),this.#Bt(),r(interruptedError());return}if(t.type===`ctrl-r`){this.#On();return}if(s===`overlay`){let r=setupSelectionIntent(t,{textNavigation:!isOnFreeformRow()});if(r?.kind===`move`){moveCursor(r.direction===`up`?-1:1);return}switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#Qt(),this.#On();break}dismiss();break;default:if(isOnFreeformRow()){let e=applyLineEditorKey(l,t);e!==void 0&&(l=e,this.#Qt(),this.#On());break}if(t.type===`text`&&/^[1-9]$/u.test(t.value)){let e=Number(t.value)-1;e<n.length?selectOptionAt(e):e===n.length&&i&&(c=e,syncFreeformCaret(),this.#On())}}return}let a=applyLineEditorKey(l,t,{multiline:!0});if(a!==void 0){l=a,this.#Qt(),this.#st(l),this.#On();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#Qt(),this.#st(l),this.#On());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#Qt(),this.#st(l),this.#On();break}dismiss()}},this.#Vt()})}upsertSubagentStep(e){if(this.#f?.recordSubagentDispatch(e.callId),this.#c===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(t.length!==0||n.length!==0){if(this.#un(e.callId,e.subagentName),this.#c===`collapsed`){this.#On();return}this.#fn({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,subagentCallId:e.callId,depth:1,reasoning:t,body:n,collapsed:this.#c!==`full`,live:!e.finalized}),this.#On()}}upsertSubagentTool(e){if(this.#f?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#f?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#c===`hidden`)return;if(this.#un(e.callId,e.subagentName),this.#c===`collapsed`){this.#On();return}let t=subagentToolStatus(e.status),n=e.status===`preparing`?presentPreparingTool(e.toolName):presentTool(e.toolName,e.input,this.#bn({input:e.input,output:e.output,toolCallId:e.childCallId,toolName:e.toolName})),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,subagentCallId:e.callId,depth:1,title:stripTerminalControls(n.title),subtitle:stripTerminalControls(n.subtitle),status:t,live:t===`running`||t===`approval`,expanded:this.#c===`full`,toolName:e.toolName,toolGroup:n.group,toolInput:e.input};n.doneTitle!==void 0&&(r.doneTitle=stripTerminalControls(n.doneTitle)),n.detail!==void 0&&(r.detailLines=n.detail,r.keepDetailWhenDone=n.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=n.summarizeResult(e.output),r.toolOutput=e.output),this.#fn(r),this.#ct(e.callId),this.#On()}#ct(e){applyCohortLiveness(this.#h.filter(t=>t.kind===`subagent-tool`&&t.subagentCallId===e).map(e=>({block:e,active:isActiveToolStatus(e.status)})))}removeSubagentTool(e){this.#pn(subagentToolSectionId(e.callId,e.childCallId)),this.#On()}subagents={begin:e=>this.beginSubagent(e),background:e=>this.backgroundSubagent(e),upsertStep:e=>this.upsertSubagentStep(e),upsertTool:e=>this.upsertSubagentTool(e),removeTool:e=>this.removeSubagentTool(e),complete:e=>this.completeSubagent(e),markChildToolCallId:e=>this.markChildToolCallId(e)};beginSubagent(e){if(this.#c===`hidden`)return;this.#un(e.callId,e.name);let t=this.#g.get(subagentHeaderId(e.callId));t!==void 0&&(t.status===`done`&&delete t.status,t.live=!0),this.#w.delete(e.callId),this.#On()}backgroundSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t===void 0||this.#_.has(subagentHeaderId(e.callId)))return;t.status=`running`,t.live=!0,t.updateSeq=++this.#x;let n=this.#C.has(e.callId);this.#C.add(e.callId),n||this.#mn(e.callId),this.#in(),this.#On()}completeSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t!==void 0){if(t.status=`done`,e.authoritative){this.#C.delete(e.callId),this.#w.delete(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!1)}else{this.#w.add(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!0)}this.#in(),this.#On()}}markChildToolCallId(e){this.#y.add(e);let t=this.#b.get(e);t!==void 0&&(this.#pn(t),this.#b.delete(e),this.#On())}#lt(e){let t=this.#g.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#l===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#dn({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e,t),preformatted:!0,live:t===void 0}),this.#On()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#L)return;let n=this.#L>0;this.#L=t,t>0?(this.#$=STATUS.connectionAuth,this.#On()):n&&(this.#$=STATUS.processing,this.#On())}setVercelStatus(e){this.#R=e,this.#On()}setRemoteConnectionStatus(e){this.#z=e,this.#On()}reset(){this.#h=[],this.#g.clear(),this.#_.clear(),this.#I=void 0,this.#F.length=0,this.#v.length=0,this.#N=!1,this.#P=void 0,this.#ut(),this.#K=!1,this.#Be=void 0,this.#Fe=void 0,this.#L=0,this.#Te=void 0,this.#Ee=void 0,this.#Oe=void 0,this.#ke=void 0,this.#Ae=void 0,this.#ne&&(this.#n.clearAll(),this.#On())}renderSessionBoundary(){this.#sn(),this.#ut();let e=this.#i.colors,t=this.#i.glyph,n=e.dim(`${t.cornerOpen}${t.dash.repeat(2)} Session restarted, clear context.`);this.#an({kind:`session-boundary`,body:n,live:!1}),this.#On()}#ut(){this.#We=void 0,this.#Ge=void 0,this.#y.clear(),this.#b.clear(),this.#E.clear(),this.#C.clear(),this.#w.clear(),this.#S.clear(),this.#Ke=void 0,this.#qe=void 0,this.#Je.reset(),this.#$e=void 0,this.#T.clear(),this.#q.reset(),this.#in()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Rt(),this.#an({kind:`notice`,body:t,live:!1}),this.#On())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#f?.append({source:`sandbox`,detail:t}),this.#Rt(),this.#an({kind:`sandbox`,body:t,live:!1}),this.#On())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#dt();return}this.#Rt(),this.#Ue=t,this.#On()}clearSetupWarning(){this.#dt()}#dt(){this.#Ue!==void 0&&(this.#Ue=void 0,this.#On())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#Rt();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#an(r),this.#On()}renderCommandResult(e,t){let n=stripAnsi(e);n.trim().length!==0&&(this.#Rt(),this.#an({kind:`result`,body:n,live:!1,status:t===`success`?`done`:void 0}),this.#On())}#ft(e,t=`spinner`){this.#Rt(),this.#k===void 0&&(this.#U=!1),this.#Z={kind:`idle`},this.#$=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#He={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#$t(),this.#On()}#pt(e){this.#He!==void 0&&(this.#He.navigation=e,this.#On())}#mt(e){this.#nt=void 0,this.#Ot();let t=this.#He;if(t!==void 0){if(this.#He=void 0,this.#k===void 0?this.#tn():this.#ot(),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.#an({kind:`flow`,title:`info`,body:e.join(`
|
|
5
|
+
`),live:!1}),this.#an({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#On()}}async#ht(e){let t=this.#St(e.message),n=isMultiSelectRequest(e),r=e.kind===`search`?e.searchAction:void 0,i=e.options,a=e.navigation?.kind===`planner`,o={options:i,searchAction:r,submitRow:n&&!a};`initialValue`in e&&e.initialValue!==void 0&&(o.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(o.initialValues=e.initialValues);let s=initialSelectState(o),c,l=!1,u=0,isCurrentSearch=e=>e===u,clearSearch=()=>{u+=1,l=!1,s=reduceSelect(s,{type:`clear`},{options:i,searchAction:r,submitRow:n&&!a}),this.#On()},loadSearch=async(e,t)=>{l=!0,c=void 0;let o=++u;this.#On();try{let c=await t(e);if(!isCurrentSearch(o))return;let l=s.filter;i=c,s={...initialSelectState({options:c,searchAction:r,submitRow:n&&!a}),filter:l}}catch(e){isCurrentSearch(o)&&(c=toErrorMessage(e))}finally{isCurrentSearch(o)&&(l=!1,this.#On())}},d=e.notices;if(e.kind===`task-list`||e.kind===`search`&&e.layout===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));d=e.notices??r,t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,message:``,options:i,select:s};return d!==void 0&&d.length>0&&(t.notices=d),c!==void 0&&(t.error=c),l&&(t.loadingFrame=this.#Fn()),t};return t.question=e=>renderSelectQuestion(panelState(),this.#i,e),this.#On(),await this.#Tt((t,o)=>{let close=e=>{u+=1,o(e)};if(l){t.type===`ctrl-c`?close(void 0):t.type===`escape`?clearSearch():t.type===`ctrl-r`&&this.#On();return}let d=e.navigation?.kind===`planner`?e.navigation:void 0,f=t.type===`left`&&(d?.activeStep??0)>(d?.firstNavigableStep??0)?`back`:t.type===`right`&&d!==void 0&&d.activeStep>=(d.firstNavigableStep??0)&&d.activeStep<d.steps.length-1?`forward`:void 0;if(f!==void 0){close({kind:`navigate`,direction:f,values:n?orderedSelection(i,s.selected):[]});return}let p={key:t,options:i,searchAction:r,select:s},m=reduceSetupSelectInput(n?{...p,kind:e.kind,required:e.required,plannerNavigation:a||void 0}:{...p,kind:e.kind});switch(m.kind){case`cancel`:close(void 0);return;case`repaint`:this.#On();return;case`update`:s=m.select,c=void 0,this.#On();return;case`submit`:{let e=searchActionQuery(m.values[0]??``),t=r?.load;if(e===void 0||t===void 0){close(m.values);return}loadSearch(e,t);return}case`error`:c=m.message,this.#On();return;case`ignore`:return}}).promise}#gt(e){this.#Rt();let t=this.#Ct();t.status={kind:`progress`,text:stripTerminalControls(e.status),startedAtMs:Date.now()};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#i,t),this.#On();let r=this.#Tt((t,r)=>{let i=setupSelectionIntent(t,{textNavigation:!0});switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#On();return;case`repaint`:this.#On();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#_t(e){let t=this.#St(e.message),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`inline-edit`,layout:`task-list`,message:``,options:e.options,select:r,edit:{optionValue:e.editable.value,caretVisible:this.#ue,editor:{kind:`rename`,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint}}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#i,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?this.#Xt():(i=lineOf(``),this.#Zt())};return syncEditableRow(),this.#On(),await this.#Tt((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#Qt(),this.#On()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#On()},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.#On();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t,{textNavigation:!onEditableRow()});switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#On();return;case void 0:}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Zt()).promise}async#vt(e){let t=this.#St(e.message),n=initialProviderPickerState(e.options,e.initialValue),r,cursorBadge=()=>{if(n.phase.kind!==`inactive`)return;let t=selectValueAtCursor([...e.options],n.select.cursor),r=e.options.find(e=>e.value===t);if(r!==void 0)return enterBadge(this.#i,r.checked===!0?`change`:void 0)};t.question=t=>{let r=cursorBadge(),i={kind:`inline-edit`,layout:`stacked`,message:``,options:e.options,select:n.select,edit:{optionValue:`ai-gateway-key`,caretVisible:this.#ue,editor:{kind:`key`,phase:n.phase}}};return r!==void 0&&(i.cursorBadge=r),renderSelectQuestion(i,this.#i,t)};let syncCaret=()=>{n.phase.kind===`editing`||n.phase.kind===`invalid`?this.#Xt():this.#Zt()};return syncCaret(),this.#On(),await this.#Tt((t,i,a)=>{let dispatch=t=>{let o=transitionProviderPicker(n,t,e.options);switch(o.kind){case`ignore`:return;case`clear`:r?.abort(),r=void 0,n=o.state,syncCaret(),this.#On();return;case`cancel`:i(void 0);return;case`render`:n=o.state,syncCaret(),this.#On();return;case`validate`:{n=o.state,syncCaret(),this.#On();let t=new AbortController;r=t;let i;try{i=e.validateInlineKey(o.key,t.signal)}catch(e){a(e);return}i.then(e=>{r!==t||t.signal.aborted||(r=void 0,dispatch({type:`validated`,validation:e}))},e=>{r!==t||t.signal.aborted||(r=void 0,a(e))});return}case`settle`:i(o.result);return}},o=setupSelectionIntent(t,{textNavigation:n.phase.kind===`inactive`});switch(o?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:o.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#On();return;case void 0:}if(n.phase.kind!==`editing`&&n.phase.kind!==`invalid`)return;let s=applyLineEditorKey(n.phase.editor,t);s!==void 0&&(this.#Qt(),dispatch({type:`edit`,editor:s}))},()=>{r?.abort(),r=void 0,this.#Zt()}).promise}async#yt(e){let t=initialModelPickerState(e),n=this.#St(modelPickerTitle(t));return n.question=n=>renderModelPicker(e,t,this.#i,n),this.#On(),await this.#Tt((r,i)=>{let dispatch=r=>{let a=transitionModelPicker(t,r,e);switch(a.kind){case`render`:if(t===a.state)return;t=a.state,n.questionTitle=modelPickerTitle(t),this.#On();return;case`cancel`:i(void 0);return;case`settle`:i(a.result);return}};if(r.type===`ctrl-c`){dispatch({type:`cancel`});return}if(r.type===`escape`||r.type===`left`){dispatch({type:`back`});return}let a=setupSelectionIntent(r);switch(a?.kind){case`move`:dispatch({type:a.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#On();return}if(r.type===`backspace`){dispatch({type:`backspace`});return}if(r.type===`text`)for(let e of r.value.replaceAll(`
|
|
6
|
+
`,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#bt(e){let t=this.#St(e.message),n=lineOf(``),r;return t.question=t=>{let i={message:``,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#ue)},this.#Xt(),this.#On(),await this.#Tt((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Qt(),this.#On()},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.#On();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#On();return}i(t);return}default:return}},()=>this.#Zt()).promise}async#xt(e){let t=this.#St(e.message);return t.question=t=>renderAcknowledgeQuestion({message:``,lines:e.lines},this.#i,t),this.#On(),await this.#Tt((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#On();return;default:return}}).promise}#St(e){this.#Rt(),this.#U=!1,this.#Z={kind:`idle`},this.#$=``;let t=this.#Ct();return t.questionTitle=stripTerminalControls(e),t.status!==void 0&&(t.status=void 0,t.summary=void 0,t.preview=void 0),t}#Ct(){return this.#He===void 0&&(this.#He={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#He}#wt(){this.#He?.implicit===!0?this.#He=void 0:this.#He!==void 0&&(this.#He.question=void 0,this.#He.questionTitle=void 0,this.#He.hideLinesWhileQuestion=!1),this.#_e=void 0,this.#Ht(),this.#k===void 0?this.#He!==void 0&&this.#Dt():this.#ot(),this.#He===void 0&&this.#On()}#Tt(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#wt(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#wt(),i(e))};return this.#qt(),this.#_e=t=>{t.type===`ctrl-c`&&this.#Pt(),e(t,settle,reject)},this.#Vt(),{promise:a,settle}}#Et(e){let t,n=new Promise(e=>{t=e});return this.#nt=t,this.#Dt(e?.interruptible??!0),{promise:n,dispose:()=>{this.#nt===t&&(this.#nt=void 0,this.#Ot())}}}#Dt(e=!0){if(this.#k!==void 0){this.#ot();return}if(this.#nt===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#Pt();let e=this.#nt;this.#nt=void 0,this.#Ot(),e?.(t.type===`ctrl-c`?`ctrl-c`:`escape`);return}t.type===`ctrl-r`&&this.#On()};this.#rt=consumer,this.#qt(),this.#_e=consumer,this.#Vt()}#Ot(){this.#rt!==void 0&&(this.#_e===this.#rt&&this.#Ht(),this.#rt=void 0)}#kt(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#He!==void 0){this.#He.status=t,t===void 0&&(this.#He.preview=void 0),this.#On();return}if(!(this.#U||this.#X)){if(t===void 0){this.#Z={kind:`idle`},this.#ee=void 0,this.#tn(),this.#On();return}this.#Rt(),this.#en(),this.#ee=t.text,this.#On()}}#At(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#He;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#On();return}this.#Rt(),this.#an({kind:`flow`,title:t,body:n,live:!1}),this.#On()}#jt(e){let t=this.#He;t!==void 0&&(t.lines=[],t.outputBuffer=[],t.preview=void 0,t.status=void 0,t.summary=e===void 0?void 0:{headline:stripTerminalControls(e.headline),facts:e.facts.map(e=>({label:stripTerminalControls(e.label),value:stripTerminalControls(e.value)}))},this.#On())}#Mt(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#He;if(n===void 0){this.#At(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#On()}async#Nt(e){this.#ve=``,this.#qt(),this.#nt=void 0,this.#Ot(),this.#Ht(),this.#nn(),this.#n.clear(),this.#Xn(),this.#r.enter({cursor:`visible`,mouse:!1}),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#r.exit(),this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#ve=``,this.#qt(),this.#n.hideCursor(),this.#Yn(),this.#He===void 0?this.#in():(this.#$t(),this.#Dt()),this.#n.reset(),this.#On()}}setSessionId(e){this.#Qe=e}shutdown(){if(this.#Bt(),this.#re&&!this.#ie){this.#ie=!0;let e=this.#Qe===void 0?``:` ${this.#i.glyph.dot} session ${this.#Qe}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}suspendPromptForInput(){this.#Y={cursor:this.#V,text:this.#B},this.#Bt()}requestInterrupt(){this.#ae=!0,this.#He!==void 0&&this.#_e?.({type:`ctrl-c`}),this.#Se?.(),this.#Bt()}exitRequested(){return this.#oe}#Pt(){this.#oe=!0,this.#le?.()}async#Ft(e){if(this.#it!==void 0||!this.#ne)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#qn(),height:this.#Jn()}),paint:e=>this.#r.paint(e,this.#Jn()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#at});this.#it=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#Lt=e,this.#_e=e=>{t.handleKey(e)===`close`&&this.#It()},this.#Vt(),t.start()})}#It(){let e=this.#it;if(e===void 0)return;this.#it=void 0,e.dispose(),this.#Ht(),this.#r.exit(),this.#n.hideCursor(),this.#On(),this.#n.showCursor();let t=this.#Lt;this.#Lt=void 0,t?.()}#Lt;#Rt(e){this.#te=e?.title??this.#te,e?.contextSize!==void 0&&(this.#De=e.contextSize),!this.#ne&&(this.#ne=!0,this.#re=!0,this.#n.reset(),this.#n.hideCursor(),this.#Yn(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#xe=()=>this.#On(),this.#t.on(`resize`,this.#xe),process.on(`exit`,this.#zt))}#zt=()=>{this.#ne&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#Bt(){this.#It();let e=this.#Q;if(this.#Q=void 0,e?.(interruptedError()),this.#Ht(),this.#Zt(),this.#nn(),this.#he!==void 0&&(clearTimeout(this.#he),this.#he=void 0),this.#ge=!1,this.#ir(),this.#ne){this.#or();for(let e of this.#h)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#On(),this.#n.clear(),this.#n.showCursor(),this.#Xn(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#xe&&=(this.#t.off(`resize`,this.#xe),void 0),process.off(`exit`,this.#zt),this.#ne=!1}}#Vt(){this.#e.off(`data`,this.#Ut),this.#e.on(`data`,this.#Ut),this.#ve.length>0&&queueMicrotask(()=>{this.#_e!==void 0&&this.#ve.length>0&&(this.#Gt(),this.#Wt())})}#Ht(){this.#e.off(`data`,this.#Ut),this.#qt(),this.#_e=void 0}#Ut=e=>{this.#qt(),this.#ve+=this.#ye.write(e),this.#Gt(),this.#Wt()};#Wt(){if(this.#ve===`\x1B`){this.#be=setTimeout(()=>{this.#ve===`\x1B`&&(this.#ve=``,this.#_e?.({type:`escape`}))},30),this.#be.unref?.();return}if(isIncompletePaste(this.#ve)){let e=this.#ve;this.#be=setTimeout(()=>{if(this.#ve!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#ve=``,t.length>0&&this.#_e?.({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#be.unref?.();return}if(isIncompleteOsc(this.#ve)){let e=this.#ve;this.#be=setTimeout(()=>{this.#ve===e&&(this.#ve=``)},incompletePasteFlushMs),this.#be.unref?.()}}#Gt(){for(;this.#ve.length>0;){let e=nextKey(this.#ve);if(e.incomplete)return;if(this.#ve=this.#ve.slice(e.consumed),e.key!==void 0&&e.key.type!==`ignore`){if(e.key.type===`osc`){this.#Kt(e.key.value);continue}this.#_e?.(e.key)}}}#Kt(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#at=t,this.#it?.setTerminalBackground(t))}#qt(){this.#be&&=(clearTimeout(this.#be),void 0)}#Jt(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#On();break;case`enter`:{let e=this.#Y.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#Ye!==void 0){this.#Y=EMPTY_LINE,this.#Je.requestCancellation(),this.#et=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#Ye(),this.#On();break}let t=this.#Xe;t!==void 0&&parsePromptCommand(e)===null?(this.#Y=EMPTY_LINE,this.#Yt(e,t)):this.#Je.enqueue(e)&&(this.#Y=EMPTY_LINE),this.#On();break}case`ctrl-c`:case`escape`:if(e.type===`ctrl-c`&&this.#Je.view().cancelling){this.#ae=!0,this.#ce=!0,this.#Z={kind:`idle`},this.#$=`Interrupted`,this.#Se?.(),this.#On();break}if(this.#Je.idle&&this.#Ye===void 0)break;if(this.#Je.handleEscape()===`steer`){let e=this.#Xe;if(e!==void 0){let t=this.#Je.takeSteering();this.#Yt(t,e)}}else this.#et=!0,this.#Ye?.();this.#On();break;default:{let t=applyLineEditorKey(this.#Y,e,{multiline:!0});t!==void 0&&(this.#Y=t,this.#On());break}}}#Yt(e,t){this.#$e=`steer`,this.#cn(e),t(e).catch(t=>{this.#Je.restoreSteering(e),this.#ln(`Steering failed`,toErrorMessage(t)),this.#On()})}#Xt(){this.#Zt(),this.#Qt(),this.#pe=setInterval(()=>{this.#ue=!this.#ue,this.#On()},500),this.#pe.unref?.()}#Zt(){this.#pe&&=(clearInterval(this.#pe),void 0),this.#ue=!0}#Qt(){this.#ue=!0}#$t(){this.#nn(),this.#me=setInterval(()=>{this.#de+=1,this.#On()},90),this.#me.unref?.()}#en(){let e=Date.now();this.#fe=e,this.#Z={kind:`waiting`,startedAtMs:e},this.#$t()}#tn(){this.#rn()||this.#nn()}#nn(){this.#me&&=(clearInterval(this.#me),void 0)}#rn(){return this.#h.some(e=>e.live&&e.subagentCallId!==void 0&&(this.#C.has(e.subagentCallId)||this.#w.has(e.subagentCallId)))}#in(){this.#rn()?this.#$t():!this.#X&&this.#Z.kind===`idle`&&this.#nn()}#an(e){e.id!==this.#Fe?.id&&this.#or(),e.updateSeq=++this.#x;let t=e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId)?-1:this.#h.findIndex(e=>e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId));t<0?this.#h.push(e):this.#h.splice(t,0,e),e.id&&this.#g.set(e.id,e)}#on(e){this.#K=!0,this.#an({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#On()}#sn(){let e=this.#q.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#Bn(e.elapsedMs)}`,n=this.#Ee??0;if(this.#De!==void 0&&this.#De>0&&n>0){let e=Math.round(n/this.#De*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#an({kind:`turn-stats`,body:t,live:!1})}#cn(e){if(e==null)return;let t=this.#$e;if(this.#$e=void 0,this.#Be===e){this.#Be=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#an(n)}#ln(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#f?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#f===void 0?a:`details: ${this.#f.displayPath}`),this.#an(c),this.#On()}#un(e,t){if(this.#E.has(e))return;this.#E.add(e);let n=stripTerminalControls(t),r=this.#S.get(n)??[];if(r.push(e),this.#S.set(n,r),r.length===2){let e=this.#g.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#an(i)}#dn(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#x;return}this.#an(e)}#fn(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t!==void 0){Object.assign(t,e),t.updateSeq=++this.#x;return}let n=e.subagentCallId;if(n===void 0){this.#an(e);return}e.id!==this.#Fe?.id&&this.#or(),e.updateSeq=++this.#x;let r=-1;for(let e=0;e<this.#h.length;e+=1)this.#h[e]?.subagentCallId===n&&(r=e);this.#h.splice(r<0?this.#h.length:r+1,0,e),e.id!==void 0&&this.#g.set(e.id,e)}#pn(e){this.#h=this.#h.filter(t=>t.id!==e),this.#g.delete(e)}#mn(e){let t=this.#h.filter(t=>t.subagentCallId===e);t.length!==0&&(this.#h=this.#h.filter(t=>t.subagentCallId!==e),this.#h.push(...t))}#hn(){for(let e of this.#h)e.subagentCallId!==void 0&&this.#w.has(e.subagentCallId)||e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#gn(e,t,n){let r=turnActivityLabel(n);switch(updateTurnActivity(n,e),e.type){case`turn-start`:e.turnId!==this.#Ge&&(this.#Ge=e.turnId,this.#We=void 0,this.#On());break;case`step-start`:this.#We=typeof e.modelId==`string`&&stripTerminalControls(e.modelId.slice(0,256)).replace(/\s+/gu,` `).trim()||void 0,this.#On();break;case`step-finish`:this.#f?.recordStepUsage(e.usage),e.usage!==void 0&&this.#q.addUsage(e.usage),this.#Cn(n),this.#Dn(e.usage),this.#On();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#_n(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=typeof e.text==`string`?stripTerminalControls(e.text):t;n.text.set(e.id,r),this.#_n(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#vn(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#vn(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#yn({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#f?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#yn({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.#yn({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#En(e.toolCallId,n);if(r===void 0)break;this.#yn({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#En(e.toolCallId,n);if(this.#f?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#yn({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#En(e.toolCallId,n);if(r===void 0)break;this.#yn({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#ln(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:if(n.cancelled=!0,!n.restoreCancelledPrompt)break;this.#Ze=!0,!this.#et&&this.#tt!==void 0&&this.#Y.text.length===0&&(this.#Y=lineOf(this.#tt),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#Dn(e.usage),this.#On()}n===this.#J&&turnActivityLabel(n)!==r&&this.#On()}#_n(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#dn({id:e,kind:`assistant`,body:r,live:n}),this.#On())}#vn(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#dn({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#On())}#yn(e,t,n){if(n.tools.set(e.toolCallId,e),this.#y.has(e.toolCallId)||this.#wn(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#b.set(e.toolCallId,r);let i=this.#bn(e);this.#dn(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#Tn(n),this.#On()}#bn(e){e.output!==void 0&&this.#T.observeRead(e.output);let t={};this.#xn(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#T.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#xn(e){let t=this.#D?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#Sn(e){for(let t of e.tools.keys()){if(this.#y.has(t))continue;let e=this.#b.get(t)??toolSectionId(t),n=this.#g.get(e);n?.kind===`tool`&&n.status===`running`&&(n.status=`error`,n.result=`interrupted`,n.live=!1)}}#Cn(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#b.get(t)??toolSectionId(t);this.#pn(r),this.#b.delete(t)}}#wn(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#qe!==e&&(this.#qe=e,this.#an({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#qn(),this.#i).join(`
|
|
7
|
+
`),live:!1})),this.#Ke=void 0}else this.#Ke=t.length>0?t:void 0,this.#qe=void 0;return this.#On(),!0}#Tn(e){let t=[];for(let n of e.tools.values()){if(this.#y.has(n.toolCallId))continue;let e=this.#b.get(n.toolCallId)??toolSectionId(n.toolCallId),r=this.#g.get(e);r?.kind===`tool`&&t.push({block:r,active:isActiveToolStatus(n.status)})}applyCohortLiveness(t)}#En(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#b.get(e)??toolSectionId(e),i=this.#g.get(r);if(i!==void 0&&i.kind===`tool`)return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.toolName??i.title??`tool`}}#Dn(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#Te=(t??0)+(n??0)),this.#Ee=t??this.#Ee,this.#Oe=n??this.#Oe,this.#Oe!=null&&this.#Ae!==void 0){let e=(Date.now()-this.#Ae)/1e3;e>0&&(this.#ke=this.#Oe/e)}}#On(){if(this.#ne){if(this.#Ce){this.#we=!0;return}this.#Ce=!0;try{do this.#we=!1,this.#kn();while(this.#we)}finally{this.#Ce=!1}}}#kn(){if(!this.#ne)return;if(this.#it!==void 0){this.#it.repaint();return}let e=this.#qn(),t=this.#Rn(e),n=this.#M===void 0?[]:this.#Nn(),r=Math.max(1,this.#Jn()-n.length-t.length),i=[],a=this.#I,o=groupToolBlocksForDisplay(this.#h),s=0;for(;s<o.length&&o[s].display.live===!1;)s+=1;if(s>0){let e=new Set(o.slice(0,s).flatMap(e=>e.members));for(let t=this.#h.length-1;t>=0;--t)e.has(this.#h[t])&&this.#h.splice(t,1)}for(let t of o.slice(0,s)){for(let e of t.members)this.#v.push(e),e.id&&(this.#_.add(e.id),this.#g.delete(e.id));if(this.#cr(t.display))continue;let n=this.#Pn(t.display,e,a);a=previousBlockOf(t.display),this.#I=a,i.push(...n),this.#F.push(...n)}let c=[];for(let{display:t}of o.slice(s)){if(this.#cr(t))continue;let n=this.#Pn(t,e,a);a=previousBlockOf(t);for(let e=0;e<n.length;e+=1)c.push({block:t,row:n[e]})}let l=[...n,...clipLiveRows(c.map(e=>e.row),r,e,this.#i),...t];i.length>0?this.#n.flush(i,l):this.#n.update(l)}#An(){if(!this.#ne)return;let e=this.#qn(),t=this.#Rn(e),n=Math.max(1,this.#Jn()-t.length),r=this.#I,i=[];for(let{display:t}of groupToolBlocksForDisplay(this.#h)){if(this.#cr(t))continue;let n=this.#Pn(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#i),...t];this.#n.clearAll(),this.#n.flush([...this.#Nn(),...this.#F],a)}logDisplayMode(){return this.#m}setLogDisplayMode(e){e!==this.#m&&(this.#m=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#Mn(),this.#ne&&this.#An())}flushDelayedDevBuildErrors(){let e=this.#Pe;e!==void 0&&(this.#Pe=void 0,this.#an({kind:`log`,title:`stderr`,body:e,live:!0}),this.#On())}#jn(){this.#ge=!0,this.#he!==void 0&&clearTimeout(this.#he),this.#he=setTimeout(()=>{this.#ge=!1,this.#he=void 0,this.#On()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#m)),this.#On()}#Mn(){let e=this.#qn();this.#F.length=0;let t;for(let{display:n}of groupToolBlocksForDisplay(this.#v,{logCoalescing:`runs`})){if(this.#cr(n))continue;let r=this.#Pn(n,e,t);t=previousBlockOf(n),this.#F.push(...r)}this.#I=t}#Nn(){let e=this.#D,t=this.#M;if(e===void 0&&t===void 0)return[];let n={name:e?.name??t?.name,theme:this.#i,width:this.#qn()};return e?.info!==void 0&&(n.info=e.info),buildAgentHeader(n)}#Pn(e,t,n){let r={renderMarkdown:this.#a,activityPulse:this.#In(this.#fe,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#i,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#Fn(){return this.#i.spinner[this.#de%this.#i.spinner.length]??``}#In(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#Ln(e,t){return e.indicator.kind===`spinner`?{glyph:this.#Fn(),color:`yellow`}:{glyph:this.#In(e.indicator.startedAtMs,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#Rn(e){let t=this.#i.colors,n=[``];if(this.#Ve!==void 0)return n.push(...this.#Ve(e),``),this.#Wn(n,e),n;let r=this.#He;if(r!==void 0&&(this.#k===void 0||r.question!==void 0)){let t=this.#Ln(r,r.status),i;if(r.status!==void 0){let{startedAtMs:e,...n}=r.status,a=Date.now()-e,o=a>=5e3?` ${formatTurnDuration(a)}`:``;i={...n,text:`${n.text}${o}`,indicator:t}}let a;if(r.question!==void 0){let t=r.question(e);a={kind:`question`,title:r.questionTitle,rows:t},i!==void 0&&(a={kind:`question`,title:r.questionTitle,rows:t,status:i})}else i===void 0?a=r.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:r.preview,indicator:t}:(a={kind:`status`,status:i},r.preview!==void 0&&(a={kind:`status`,status:i,preview:r.preview}));let o={title:r.title,navigation:r.navigation,lines:r.summary===void 0?r.hideLinesWhileQuestion===!0?[]:r.lines:[{text:r.summary.headline,tone:`success`},...r.summary.facts.map(e=>({text:`${e.label}: ${e.value}`,tone:`info`}))],content:a};return n.push(...renderFlowPanel(o,this.#i,e)),this.#Gn(n,e),n}r!==void 0&&n.push(...flowMessageRows(r.lines,this.#i).map(t=>t.length===0?``:clip(` ${t}`,e))),this.#O===void 0&&this.#Ue!==void 0&&n.push(...renderAttentionRows(this.#Ue,e,this.#i),``),this.#Ke!==void 0&&n.push(...renderTodoPanelRows({items:this.#Ke,width:e,theme:this.#i,working:this.#X||this.#Z.kind===`waiting`,pulse:this.#In(this.#fe,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)}),``);let i=renderMessageQueueRows({view:this.#Je.view(),width:e,theme:this.#i,working:this.#X});if(i.length>0&&n.push(...i,``),this.#U){let r=this.#W===void 0?void 0:inlineCommandHint(this.#W);r===void 0&&this.#W!==void 0&&isTypeaheadOpen(this.#W)&&n.push(...renderCommandSuggestions(this.#W,this.#i,e)),this.#se&&n.push(clip(t.dim(`Press Ctrl+C again to exit`),e),``);let i=isPromptControlCommand(this.#B),a=r?t.dim(` ${r}`):``,o=[];this.#Wn(o,e);let s=Math.max(1,this.#Jn()-1-n.length-1-o.length),c={text:this.#B,cursor:this.#V,width:e,theme:this.#i,caretVisible:this.#ue,isCommand:i,ghost:a,maxRows:s};return this.#G&&this.#B.length===0&&(c.placeholder=this.#k===void 0?this.#K?``:`Send a message…`:`Message · Enter to queue`),n.push(...promptInputRows(c)),n.push(...o),n}let a=this.#Z.kind===`waiting`&&this.#ee===void 0;if(this.#X||a){n.push(this.#zn(e)),this.#Hn(n,e);let t=[];return this.#Wn(t,e),!this.#X&&t.length>0&&n.push(``),n.push(...t),n}if(this.#Y.text.length>0)return this.#Un(n,e,{inert:!1}),this.#Wn(n,e),n;let o=this.#ee??(this.#$.length>0?this.#$:`Ready`),s=this.#Kn(),c=t.dim(this.#i.glyph.dot),l=s?`${c} ${o} ${t.dim(this.#i.glyph.dot)} ${s}`:`${c} ${o}`;return n.push(clip(l,e)),this.#Wn(n,e),n}#zn(e){let t=this.#i.colors,n=this.#Z,r=this.#q.startedAtMs??this.#Ae??(n.kind===`waiting`?n.startedAtMs:Date.now()),i=Math.max(0,Date.now()-r),a=i%1e3<500?this.#i.unicode?`•`:`*`:` `,o=i<1e3?`0s`:formatTurnDuration(Math.floor(i/1e3)*1e3),s=`${turnActivityLabel(this.#J)} (${o})`,{inputTokens:c,outputTokens:l}=this.#q.usage;return clip(`${a} ${s}${c>0||l>0?t.dim(` (${formatTokenFlow({inputTokens:c,outputTokens:l},this.#i.glyph)})`):``}`,e)}#Bn(e){return`${formatTurnDuration(e)}${this.#Vn()}`}#Vn(){let{inputTokens:e,outputTokens:t}=this.#q.usage;return e===0&&t===0?``:` ${this.#i.glyph.dash.repeat(2)} ${formatTokenFlow({inputTokens:e,outputTokens:t},this.#i.glyph)}`}#Hn(e,t){this.#X&&this.#Un(e,t,{inert:!0})}#Un(e,t,n){e.push(``);let r={text:this.#Y.text,cursor:this.#Y.cursor,width:t,theme:this.#i,caretVisible:!0,isCommand:!1,ghost:``,maxRows:4,inert:n.inert};n.inert&&this.#Y.text.length===0&&(r.placeholder=``),e.push(...promptInputRows(r))}#Wn(e,t){if(this.#O!==void 0){let n=this.#He?.status?.text??{starting:`Starting agent…`,connecting:`Reading saved connection…`,updating:`Loading selected model…`}[this.#O],r=this.#In(this.#j,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH);e.push(clip(this.#i.colors.dim(`${r} ${n}`),t));return}let n=this.#z===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#i,width:r};this.#Le&&this.#Ie!==void 0&&(i.devBuild=this.#Ie),this.#ge&&(i.logLevel=this.#m);let a=this.#D?.info?.agent.model;a?.routing.kind===`dynamic`?i.model=this.#We===void 0?`dynamic model`:`dynamic model · ${this.#We}`:a?.id!==void 0&&(i.model=a.id),a?.reasoning!==void 0&&a.reasoning!==`provider-default`&&(i.reasoning=a.reasoning),readGatewayServiceTier(a?.providerOptions).kind===`priority`&&(i.fastMode=!0);let o=a?.endpoint;o!==void 0&&(i.endpoint=o),this.#R!==void 0&&(i.vercel=this.#R),this.#z!==void 0&&(i.remote=this.#z);let s=buildStatusLine(i);s!==void 0&&e.push(clip(`${n}${s}`,t))}#Gn(e,t){if(this.#z===void 0)return;let n=Math.max(1,t-2),r=buildStatusLine({remote:this.#z,theme:this.#i,width:n});r!==void 0&&e.push(``,clip(` ${r}`,t))}#Kn(){let e=this.#i.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#Te,outputTokens:this.#Oe,tokensPerSecond:this.#ke},this.#u);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#i.glyph.dot} `)):``}#qn(){return Math.max(20,this.#t.columns||80)}#Jn(){return Math.max(8,this.#t.rows||24)}#Yn(){if(this.#je!==void 0||!this.#d)return;this.#Me=``,this.#Ne=``;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.#Qn(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#f?.subscribeLogRecords(e=>this.#Zn(e)),this.#je=()=>{this.#f?.unsubscribeLogRecords(),e(),t()}}#Xn(){let e=this.#je;e!==void 0&&(this.#je=void 0,e(),this.#Me.length>0&&(this.#f?.append({source:`stdout`,detail:this.#Me}),this.#sr(`stdout`)&&process.stdout.write(`${this.#Me}\n`),this.#Me=``),this.#Ne.length>0&&(this.#f?.append({source:`stderr`,detail:this.#Ne}),this.#sr(`stderr`)&&process.stderr.write(`${this.#Ne}\n`),this.#Ne=``))}#Zn(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#er(`[eve:${e.namespace}] ${e.message}${t}`),this.#On()}#Qn(e,t){let n=(e===`stdout`?this.#Me:this.#Ne)+t;if(e===`stdout`&&parseDevRebuildLogLine(n.trimEnd())!==void 0){this.#Me=``,this.#f?.append({source:e,detail:n.trimEnd()}),this.#$n(n.trimEnd()),this.#On();return}let r=n.lastIndexOf(`
|
|
8
|
+
`),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#Me=i:this.#Ne=i,r===-1)return;let a=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);a.trim().length!==0&&(this.#f?.append({source:e,detail:a}),e===`stdout`?this.#$n(a):this.#er(a),this.#On())}#$n(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
|
|
9
|
+
`);t=[],e.trim().length!==0&&this.#an({kind:`log`,title:`stdout`,body:e,live:!0})};for(let n of e.split(`
|
|
10
|
+
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#an({kind:`sandbox`,body:e,live:!1});continue}let r=parseDevRebuildLogLine(n.trimEnd());if(r===void 0){t.push(n);continue}flushPending(),this.#nr(r,n.trimEnd())}flushPending()}#er(e){let t=e.split(`
|
|
11
|
+
`),n=t.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(n===-1){if(this.#f===void 0){this.#an({kind:`log`,title:`stderr`,body:e,live:!0});return}let t=presentDiagnostic(e,this.#f.displayPath);if(t.kind===`inline`){this.#an({kind:`log`,title:`stderr`,body:t.text,live:!0});return}this.#an({kind:`log`,title:`stderr`,body:formatStoredDiagnostic(t),logVisibility:`stderr-only`,live:!0}),this.#an({kind:`log`,title:`stderr`,body:e,logVisibility:`all-only`,live:!0});return}let r=t.slice(0,n).join(`
|
|
12
|
+
`);r.trim().length>0&&this.#an({kind:`log`,title:`stderr`,body:r,live:!0});let i=t.slice(n).join(`
|
|
13
|
+
`);this.#tr(i)}#tr(e){if(this.#ir(),this.#m===`all`){if(e.trim().length===0)return;this.#an({kind:`log`,title:`stderr`,body:e,live:!0});return}this.#Pe=e}#nr(e,t){let n=this.#ar();if(e.kind===`failed`){this.#tr(t);return}if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(this.#rr({phase:`building`,summary:t}),n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#ze}`;this.#ze+=1,this.#Fe={id:r,summary:t},this.#an({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}let r=n?.state.summary??this.#Ie?.summary;if(r!==void 0&&this.#rr({phase:`complete`,summary:r}),n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind),e.kind===`rebuilt`&&(this.#Pe=void 0);return}e.kind===`rebuilt`&&(this.#Pe=void 0),this.#an({kind:`log`,title:`stdout`,body:t,live:!0})}#rr(e){this.#Re!==void 0&&clearTimeout(this.#Re),this.#Ie=e,this.#Le=e.phase===`complete`,this.#Re=setTimeout(()=>{e.phase===`building`?(this.#Le=!0,this.#Re=void 0):this.#ir(),this.#On()},e.phase===`building`?250:4e3)}#ir(){this.#Re!==void 0&&clearTimeout(this.#Re),this.#Ie=void 0,this.#Le=!1,this.#Re=void 0}#ar(){let e=this.#Fe;if(e===void 0)return;let t=this.#g.get(e.id);if(t!==void 0&&t.live===!0)return{state:e,block:t}}#or(){let e=this.#Fe;if(e===void 0)return;this.#Fe=void 0;let t=this.#g.get(e.id);t!==void 0&&(t.live=!1)}#sr(e){switch(this.#m){case`none`:return!1;case`stderr`:return e===`stderr`;case`sandbox`:return e===`sandbox`;case`all`:return!0}}#cr(e){return e.kind===`sandbox`?!this.#sr(`sandbox`):e.kind===`log`?e.logVisibility===`stderr-only`?this.#m!==`stderr`:e.logVisibility===`all-only`?this.#m!==`all`:!this.#sr(e.title===`stderr`?`stderr`:`stdout`):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}async function*iterateTUIStream(e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}return}yield*e}function clip(e,t){return clipVisible(e,t)}function promptInputRows({text:e,cursor:t,width:n,theme:r,caretVisible:i,isCommand:a,ghost:o,maxRows:s,placeholder:c,inert:l}){let u=r.colors;if(e.length===0&&c!==void 0){let e=renderInputWithBlockCursor({...visibleLine({text:c,cursor:0},Math.max(1,n-3),r.glyph.ellipsis),visible:i,inverse:u.inverse,render:e=>u.dim(renderInputText(e))});return[clip(`${r.glyph.prompt} ${e}`,n),``]}let style=e=>{let t=renderInputText(e);return a&&t.length>0?u.blue(t):t},d=layoutPromptInput({text:e,cursor:t}),f=Math.min(Math.max(1,s),d.rows.length),p=Math.max(0,Math.min(d.caretRow-f+1,d.rows.length-f)),m=l===!0?u.dim(r.glyph.prompt):u.cyan(r.glyph.prompt),h=u.dim(r.glyph.ellipsis),g=Math.max(1,n-3),_=[];for(let e=p;e<p+f;e+=1){let t=d.rows[e],a=e===0?m:` `;(e===p&&p>0||e===p+f-1&&p+f<d.rows.length)&&(a=h);let s;if(e===d.caretRow){let{before:e,under:n,after:a}=visibleLine({text:t.text,cursor:d.caretOffset},g,r.glyph.ellipsis);s=renderInputWithBlockCursor({before:e,under:n,after:a,visible:i,inverse:u.inverse,render:style}),o.length>0&&d.rows.length===1&&(s+=o)}else s=style(t.text);_.push(clip(`${a} ${s}`,n))}return _.push(``),_}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function isActiveToolStatus(e){return e===`running`||e===`approval`}function applyCohortLiveness(e){let t=e.some(e=>e.active);for(let n of e)n.block.live=t||n.active}function leadsWithGap(e,t){if(e.kind===`tool`&&(t?.kind===`user`||t?.kind===`assistant`||t?.kind===`question`))return!0;if(e.kind===`sandbox`&&t?.kind===`sandbox`)return!1;if(t?.kind===`sandbox`&&e.kind!==`sandbox`||t?.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`turn-stats`:case`session-boundary`:case`todo-list`: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,r){let i=e.preparing===!0?presentPreparingTool(e.toolName,r):presentTool(e.toolName,e.input,r),a={id:t,kind:`tool`,title:stripTerminalControls(i.title),subtitle:stripTerminalControls(i.subtitle),status:e.status,live:e.status===`running`||e.status===`approval`,expanded:n,toolInput:e.input,toolName:e.toolName,toolGroup:i.group};return i.doneTitle!==void 0&&(a.doneTitle=stripTerminalControls(i.doneTitle)),i.detail!==void 0&&(a.detailLines=i.detail,a.keepDetailWhenDone=i.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(a.result=stripTerminalControls(e.errorText)):(a.result=i.summarizeResult(e.output),a.toolOutput=e.output),a}function writeExistedFlag(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e.existed;return typeof t==`boolean`?t:void 0}function subagentToolStatus(e){switch(e){case`preparing`:return`running`;case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`;case`rejected`:return`denied`}}function formatToolApprovalTitle(e){return stripTerminalControls(e.title??e.toolName)}function toolSectionId(e){return`tool:${e}`}function questionSectionId(e){return`question:${e}`}function subagentHeaderId(e){return`subagent:${e}:header`}function subagentStepSectionId(e,t){return`subagent:${e}:step:${t}`}function subagentToolSectionId(e,t){return`subagent:${e}:tool:${t}`}function connectionAuthSectionId(e){return`connection-auth:${e}`}function connectionAuthTerminalMessage(e){switch(e){case`authorized`:return`Authorization complete`;case`declined`:return`Authorization declined`;case`failed`:return`Authorization failed`;case`timed-out`:return`Authorization timed out`;case`required`:case`pending`:return}}function formatConnectionAuthContent(e,t){let n=[];if(t!==void 0)n.push(t);else{let t=stripTerminalControls(e.description);t.length>0&&n.push(t);let r=e.challenge;r?.url&&n.push(`URL: ${stripTerminalControls(r.url)}`),r?.userCode&&n.push(`Code: ${stripTerminalControls(r.userCode)}`),r?.expiresAt&&n.push(`Expires: ${stripTerminalControls(r.expiresAt)}`),r?.instructions&&n.push(stripTerminalControls(r.instructions))}if(e.reason!==void 0){let t=stripTerminalControls(e.reason);t.length>0&&n.push(`Reason: ${t}`)}return n.join(`
|
|
14
14
|
`)}function formatQuestionContent(e,t,n){let r=n.colors,i=[],a=e.options??[];if(a.length>0){for(let[e,o]of a.entries()){let a=stripTerminalControls(o.label),s=o.description===void 0?``:stripTerminalControls(o.description),c=t===e,l=s.length>0?`${c?` `:` `}${r.dim(`— ${s}`)}`:``,u=c?`${n.glyph.selectedPointer} ${a}`:` ${a}`,d=renderCursorRow(u,c,r);i.push(`${d}${l}`)}if(e.allowFreeform===!0){let e=t===a.length,o=`Type your own answer`,s=e?`${n.glyph.selectedPointer} ${o}`:` ${r.dim(o)}`;i.push(renderCursorRow(s,e,r))}}else i.push(r.dim(` (type your answer)`));return i.join(`
|
|
15
15
|
`)}function resolveQuestionText(e,t){let n=e.trim();if(n.length===0)return;let r=n.toLowerCase(),i=t.options??[];if(i.length>0){let e=matchQuestionOption(r,i);if(e!==void 0)return{optionId:e.id,label:e.label}}if(t.allowFreeform===!0||i.length===0)return{text:n,label:n}}function matchQuestionOption(e,t){let n=t.find(t=>t.id.toLowerCase()===e);if(n!==void 0)return n;let r=t.find(t=>t.label.toLowerCase()===e);if(r!==void 0)return r;let i=Number(e);if(Number.isInteger(i)&&i>0&&i<=t.length)return t[i-1]}export{TerminalRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function createFakeSetupFlowRenderer(e={}){let{readProviderPicker=async()=>void 0,
|
|
1
|
+
function createFakeSetupFlowRenderer(e={}){let{readProviderPicker=async()=>void 0,readModelPicker=async()=>void 0,...t}=e;return{begin:()=>{},end:()=>{},readSelect:async()=>void 0,readEditableSelect:async()=>void 0,readProviderPicker,readModelPicker,readText:async()=>void 0,readAcknowledge:async()=>{},readChoice:()=>({choice:Promise.resolve(void 0),close:()=>{}}),setStatus:()=>{},renderLine:()=>{},renderOutput:()=>{},withInheritedStdio:e=>e(),waitForInterrupt:()=>({promise:new Promise(()=>{}),dispose:()=>{}}),...t}}export{createFakeSetupFlowRenderer};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{EventEmitter}from"node:events";const ansiControlSequencePattern=RegExp(`^\x1B\\[([0-9?;]*)([ -/]*)([@-~])`);var MockUserInput=class extends EventEmitter{isTTY=!0;rawModes=[];resumeCalls=0;pauseCalls=0;setRawMode(e){return this.rawModes.push(e),this}resume(){return this.resumeCalls+=1,this}pause(){return this.pauseCalls+=1,this}type(e){this.emit(`data`,Buffer.from(e))}send(e){this.emit(`data`,Buffer.from(e))}enter(){this.send(`\r`)}backspace(){this.send(``)}up(){this.send(`\x1B[A`)}down(){this.send(`\x1B[B`)}left(){this.send(`\x1B[D`)}right(){this.send(`\x1B[C`)}ctrlC(){this.send(``)}ctrlN(){this.send(``)}ctrlP(){this.send(``)}},MockScreen=class extends EventEmitter{isTTY=!0;columns;rows;#e=``;#t=[];#n=0;#r=0;#i;#a=[];constructor({columns:e,rows:t}){super(),this.columns=e,this.rows=t}write(e,t,n){let r=String(e);return this.#e+=r,this.#s(r),typeof t==`function`&&t(),n?.(),this.#o(),!0}resize(e,t){this.columns=e,this.rows=t,this.emit(`resize`)}snapshot(){return this.#t.join(`
|
|
2
|
-
`)}rawOutput(){return this.#e}async waitForIdlePrompt(e=1e3){let t
|
|
2
|
+
`)}rawOutput(){return this.#e}async waitForIdlePrompt(e=1e3){let t=/^[•* ] (?:Thinking|Generating|Running) \(\d/mu,idle=()=>{let e=this.snapshot();return/^[❯]/mu.test(e)&&!t.test(e)},n=Date.now()+e;for(;Date.now()<n;){if(idle())return;await new Promise(e=>setTimeout(e,25))}throw Error(`Timed out waiting for an idle prompt.\n\nScreen:\n${this.snapshot()}`)}async waitForText(e,t=1e3,n=()=>this.snapshot()){this.snapshot().includes(e)||await new Promise((r,i)=>{let a={text:e,resolve:r,reject:i,timeout:setTimeout(()=>{this.#a=this.#a.filter(e=>e!==a),i(Error(`Timed out waiting for screen text: ${e}\n\nScreen:\n${n()}`))},t)};this.#a.push(a)})}#o(){let e=this.snapshot();for(let t of this.#a.slice())e.includes(t.text)&&(clearTimeout(t.timeout),this.#a=this.#a.filter(e=>e!==t),t.resolve())}#s(e){let t=0;for(;t<e.length;){if(e[t]===`\x1B`){let n=this.#c(e,t);if(n>t){t=n;continue}}let n=e[t];if(t+=1,n!==void 0){if(n===`
|
|
3
3
|
`){this.#n+=1,this.#r=0;continue}if(n===`\r`){this.#r=0;continue}this.#d(n)}}}#c(e,t){let n=e.slice(t).match(ansiControlSequencePattern);if(!n)return t;let[r,i=``,,a]=n,o=i.startsWith(`?`),s=i&&!o?i.split(`;`):[],first=e=>s[0]===void 0||s[0]===``?e:Number(s[0]);if(o)return i===`?1049`&&(a===`h`||a===`l`)&&(a===`h`?(this.#i={lines:this.#t,cursorLine:this.#n,cursorColumn:this.#r},this.#t=[],this.#n=0,this.#r=0):this.#i!==void 0&&(this.#t=this.#i.lines,this.#n=this.#i.cursorLine,this.#r=this.#i.cursorColumn,this.#i=void 0)),t+r.length;switch(a){case`H`:case`f`:this.#n=first(1)-1,this.#r=(s[1]?Number(s[1]):1)-1;break;case`A`:this.#n=Math.max(0,this.#n-first(1));break;case`B`:this.#n+=first(1);break;case`C`:this.#r+=first(1);break;case`D`:this.#r=Math.max(0,this.#r-first(1));break;case`E`:this.#n+=first(1),this.#r=0;break;case`F`:this.#n=Math.max(0,this.#n-first(1)),this.#r=0;break;case`G`:this.#r=first(1)-1;break;case`J`:this.#l(first(0));break;case`K`:this.#u(first(0))}return t+r.length}#l(e){if(e===2||e===3){this.#t=[],this.#n=0,this.#r=0;return}if(e===1){for(let e=0;e<this.#n;e+=1)this.#t[e]=``;this.#u(1);return}this.#u(0),this.#t.length=Math.min(this.#t.length,this.#n+1)}#u(e){let t=this.#t[this.#n]??``;if(e===2){this.#t[this.#n]=``;return}if(e===1){this.#t[this.#n]=` `.repeat(this.#r)+t.slice(this.#r);return}this.#t[this.#n]=t.slice(0,this.#r)}#d(e){let t=(this.#t[this.#n]??``).padEnd(this.#r,` `),n=t.slice(0,this.#r)+e+t.slice(this.#r+e.length);this.#t[this.#n]=n,this.#r+=e.length}};export{MockScreen,MockUserInput};
|
|
@@ -94,14 +94,6 @@ export interface ThemeGlyphs {
|
|
|
94
94
|
arrowDown: string;
|
|
95
95
|
/** `↯` — Fast mode (Gateway priority tier) marker beside a model id. */
|
|
96
96
|
fast: string;
|
|
97
|
-
/** `●` — a track notch below the current position (already covered). */
|
|
98
|
-
trackFilled: string;
|
|
99
|
-
/** `◉` — the track notch at the current position. */
|
|
100
|
-
trackCurrent: string;
|
|
101
|
-
/** `○` — a track notch above the current position. */
|
|
102
|
-
trackEmpty: string;
|
|
103
|
-
/** `─` — the connector segment between track notches. */
|
|
104
|
-
trackLine: string;
|
|
105
97
|
/** `↵` — the Enter affordance inside a selection badge. */
|
|
106
98
|
enter: string;
|
|
107
99
|
/** `▪` — the marker beside an in-flight validation badge. */
|
|
@@ -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:`○`,square:`▪`,corner:`└`,cornerOpen:`┌`,external:`⌝`,dotActive:`⏺`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`※`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`›`,selectedPointer:`›`,option:` `,prompt:`❯`,elbow:`⎿`,hrule:`▔`,dash:`─`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown:`↓`,fast:`↯`,
|
|
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:`○`,square:`▪`,corner:`└`,cornerOpen:`┌`,external:`⌝`,dotActive:`⏺`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`※`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`›`,selectedPointer:`›`,option:` `,prompt:`❯`,elbow:`⎿`,hrule:`▔`,dash:`─`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown:`↓`,fast:`↯`,enter:`↵`,validating:`▪`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,square:`*`,corner:"`",cornerOpen:`,`,external:`^`,dotActive:`*`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,selectedPointer:`>`,option:`.`,prompt:`>`,elbow:"`-",hrule:`=`,dash:`-`,caret:`_`,dot:`-`,ellipsis:`...`,arrowUp:`^`,arrowDown:`v`,fast:`>>`,enter:`<-'`,validating:`o`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(e={}){let t=e.color??!0,n=e.unicode??!0;return{color:t,unicode:n,colors:{reset:ansi(0,0,t),bold:ansi(1,22,t),dim:ansi(2,22,t),inverse:ansi(7,27,t),italic:ansi(3,23,t),white:ansi(97,39,t),gray:ansi(90,39,t),cyan:ansi(36,39,t),green:ansi(32,39,t),red:ansi(31,39,t),yellow:ansi(33,39,t),magenta:ansi(35,39,t),blue:ansi(34,39,t),orange:ansi256(208,t)},glyph:n?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:n?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`)}export{createTheme,detectUnicode};
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"zod": "4.5.4",
|
|
56
56
|
"zod-validation-error": "5.0.0"
|
|
57
57
|
},
|
|
58
|
-
"scriptHash": "
|
|
58
|
+
"scriptHash": "e816dd3417a2a7f84d93a29096962d66df2120bf91b4b5bd82364d92c986f02b",
|
|
59
59
|
"toolVersions": {
|
|
60
60
|
"rolldown": "1.2.8",
|
|
61
61
|
"typescript": "7.0.2"
|
|
@@ -11,8 +11,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
|
|
|
11
11
|
readonly dropped: {};
|
|
12
12
|
};
|
|
13
13
|
readonly tool: {
|
|
14
|
-
readonly current:
|
|
15
|
-
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
|
14
|
+
readonly current: 53;
|
|
15
|
+
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 29, 30, 31, 32, 34, 35, 53];
|
|
16
16
|
readonly dropped: {
|
|
17
17
|
readonly 14: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
|
|
18
18
|
readonly 15: "TaskExec replaces stageEffect with send";
|
|
@@ -28,6 +28,7 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
|
|
|
28
28
|
readonly 25: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
|
|
29
29
|
readonly 26: "Background tools now use task yield descriptors";
|
|
30
30
|
readonly 27: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
|
|
31
|
+
readonly 28: "Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.";
|
|
31
32
|
readonly 33: "ctx.agent now accepts the subagent name as its first argument, derives invocation identity internally, and infers structured output types";
|
|
32
33
|
readonly 36: "experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow";
|
|
33
34
|
readonly 37: "experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow";
|
|
@@ -37,13 +38,20 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
|
|
|
37
38
|
readonly 41: "workflow no longer accepts agents and its options argument is optional; use workflow() or workflow({ maxSubagents })";
|
|
38
39
|
readonly 42: "Legacy session history migration was removed; user-role messages require current provenance kinds.";
|
|
39
40
|
readonly 43: "Legacy session history migration was removed; user-role messages require current provenance kinds.";
|
|
41
|
+
readonly 44: "Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.";
|
|
42
|
+
readonly 45: "Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.";
|
|
43
|
+
readonly 46: "Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.";
|
|
40
44
|
readonly 47: "eve/experimental/evaluate was removed; import evaluate from eve/ai";
|
|
41
45
|
readonly 48: "eve/experimental/evaluate was removed; import evaluate from eve/ai";
|
|
46
|
+
readonly 49: "Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.";
|
|
47
|
+
readonly 50: "Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.";
|
|
48
|
+
readonly 51: "Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.";
|
|
49
|
+
readonly 52: "Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.";
|
|
42
50
|
};
|
|
43
51
|
};
|
|
44
52
|
readonly dynamicTool: {
|
|
45
|
-
readonly current:
|
|
46
|
-
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22,
|
|
53
|
+
readonly current: 51;
|
|
54
|
+
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 31, 32, 33, 51];
|
|
47
55
|
readonly dropped: {
|
|
48
56
|
readonly 21: "Message and reasoning append events now expose deltas instead of cumulative snapshots.";
|
|
49
57
|
readonly 23: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
|
|
@@ -51,6 +59,9 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
|
|
|
51
59
|
readonly 25: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
|
|
52
60
|
readonly 26: "Background tools now use task yield descriptors";
|
|
53
61
|
readonly 27: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
|
|
62
|
+
readonly 28: "Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.";
|
|
63
|
+
readonly 29: "Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.";
|
|
64
|
+
readonly 30: "Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.";
|
|
54
65
|
readonly 34: "Legacy session history migration was removed; user-role messages require current provenance kinds.";
|
|
55
66
|
readonly 35: "workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory";
|
|
56
67
|
readonly 36: "workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory";
|
|
@@ -58,23 +69,31 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
|
|
|
58
69
|
readonly 38: "workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory";
|
|
59
70
|
readonly 39: "Legacy session history migration was removed; user-role messages require current provenance kinds.";
|
|
60
71
|
readonly 40: "Legacy session history migration was removed; user-role messages require current provenance kinds.";
|
|
72
|
+
readonly 41: "Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.";
|
|
61
73
|
readonly 42: "autoModel and eve/experimental/evaluate were removed; import auto from eve/models";
|
|
62
74
|
readonly 43: "autoModel and eve/experimental/evaluate were removed; import auto from eve/models";
|
|
63
75
|
readonly 44: "autoModel and eve/experimental/evaluate were removed; import auto from eve/models";
|
|
64
76
|
readonly 45: "autoModel and eve/experimental/evaluate were removed; import auto from eve/models";
|
|
65
77
|
readonly 46: "autoModel and eve/experimental/evaluate were removed; import auto from eve/models";
|
|
66
78
|
readonly 47: "autoModel and eve/experimental/evaluate were removed; import auto from eve/models";
|
|
79
|
+
readonly 48: "Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.";
|
|
80
|
+
readonly 49: "Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.";
|
|
81
|
+
readonly 50: "Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.";
|
|
67
82
|
};
|
|
68
83
|
};
|
|
69
84
|
readonly channel: {
|
|
70
|
-
readonly current:
|
|
71
|
-
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18,
|
|
85
|
+
readonly current: 27;
|
|
86
|
+
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 27];
|
|
72
87
|
readonly dropped: {
|
|
73
88
|
readonly 12: "Message and reasoning append events now expose deltas instead of cumulative snapshots.";
|
|
74
89
|
readonly 19: "Continuation rekey was removed; channel extensions must use additive continuation.alias instead.";
|
|
75
90
|
readonly 20: "Continuation rekey was removed; channel extensions must use additive continuation.alias instead.";
|
|
76
91
|
readonly 21: "Continuation rekey was removed; channel extensions must use additive continuation.alias instead.";
|
|
77
92
|
readonly 22: "Continuation rekey was removed; channel extensions must use additive continuation.alias instead.";
|
|
93
|
+
readonly 23: "Task views no longer expose executor bindings; background work is owned by workflow runs.";
|
|
94
|
+
readonly 24: "Task views no longer expose executor bindings; background work is owned by workflow runs.";
|
|
95
|
+
readonly 25: "Task views no longer expose executor bindings; background work is owned by workflow runs.";
|
|
96
|
+
readonly 26: "Task views no longer expose executor bindings; background work is owned by workflow runs.";
|
|
78
97
|
};
|
|
79
98
|
};
|
|
80
99
|
readonly schedule: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=2,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_CONTRACTS={extension:{current:1,supported:[1],dropped:{}},tool:{current:52,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,28,29,30,31,32,34,35,44,45,46,49,50,51,52],dropped:{14:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,15:`TaskExec replaces stageEffect with send`,16:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,17:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,18:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,19:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,20:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,21:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,22:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,33:`ctx.agent now accepts the subagent name as its first argument, derives invocation identity internally, and infers structured output types`,36:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,37:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,38:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,39:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,40:`runWorkflowProgram was made internal; use the workflow factory from eve/tools/workflow`,41:`workflow no longer accepts agents and its options argument is optional; use workflow() or workflow({ maxSubagents })`,42:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,43:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,47:`eve/experimental/evaluate was removed; import evaluate from eve/ai`,48:`eve/experimental/evaluate was removed; import evaluate from eve/ai`}},dynamicTool:{current:50,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,28,29,30,31,32,33,41,48,49,50],dropped:{21:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,34:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,35:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,36:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,37:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,38:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,39:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,40:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,42:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,43:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,44:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,45:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,46:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,47:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`}},channel:{current:26,supported:[1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,23,24,25,26],dropped:{12:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,19:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,20:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,21:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,22:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`}},schedule:{current:14,supported:[1,2,3,4,6,7,8,9,10,11,12,13,14],dropped:{5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},subagent:{current:19,supported:[3,4,6,7,8,9,10,11,12,13,14,15,16,19],dropped:{1:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,2:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,17:`Removed experimental.instrumentationProviders; instrumentation is now always enabled for root agents.`,18:`Removed experimental.instrumentationProviders; instrumentation is now always enabled for root agents.`}},connection:{current:23,supported:[1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18,19,20,21,22,23],dropped:{9:`Dynamic connection resolvers no longer receive conversation or channel continuation data`,10:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},hook:{current:24,supported:[10,11,12,13,14,15,17,18,19,20,21,22,23,24],dropped:{1:`Model identity moved from session.started runtime metadata to step.started call attribution.`,2:`Model identity moved from session.started runtime metadata to step.started call attribution.`,3:`Model identity moved from session.started runtime metadata to step.started call attribution.`,4:`Model identity moved from session.started runtime metadata to step.started call attribution.`,5:`Model identity moved from session.started runtime metadata to step.started call attribution.`,6:`Model identity moved from session.started runtime metadata to step.started call attribution.`,7:`Model identity moved from session.started runtime metadata to step.started call attribution.`,8:`Model identity moved from session.started runtime metadata to step.started call attribution.`,9:`Model identity moved from session.started runtime metadata to step.started call attribution.`,16:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},skill:{current:1,supported:[1],dropped:{}},dynamicSkill:{current:21,supported:[1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21],dropped:{13:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},instructions:{current:2,supported:[1,2],dropped:{}},dynamicInstructions:{current:22,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22],dropped:{14:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},config:{current:1,supported:[1],dropped:{}},state:{current:6,supported:[1,2,3,4,5,6],dropped:{}}},EXTENSION_CAPABILITY_VERSIONS=Object.fromEntries(Object.entries(EXTENSION_CAPABILITY_CONTRACTS).map(([e,t])=>[e,t.current])),EXTENSION_CAPABILITY_SUPPORT=Object.keys(EXTENSION_CAPABILITY_CONTRACTS).reduce((e,t)=>(e[t]=EXTENSION_CAPABILITY_CONTRACTS[t].supported,e),{}),extensionCompatibilityManifestV1Schema=z.object({kind:z.literal(EXTENSION_COMPATIBILITY_MANIFEST_KIND),formatVersion:z.literal(1),builtWithEve:z.string().min(1),requires:z.record(z.string(),z.number().int().positive())}).strict(),extensionCompatibilityManifestV2Schema=extensionCompatibilityManifestV1Schema.extend({formatVersion:z.literal(2),build:z.object({externalDependencies:z.array(z.string().min(1)).readonly()}).strict().optional()}),extensionCompatibilityManifestSchema=z.union([extensionCompatibilityManifestV1Schema,extensionCompatibilityManifestV2Schema]);function serializeExtensionCompatibilityManifest(e){return`${JSON.stringify(e,null,2)}\n`}function parseExtensionCompatibilityManifest(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`Extension compatibility manifest "${t}" is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}let r=extensionCompatibilityManifestSchema.safeParse(n);if(!r.success)throw Error(`Extension compatibility manifest "${t}" is invalid. ${formatValidationError(r.error)}`);return r.data}async function readExtensionCompatibilityManifest(e){return parseExtensionCompatibilityManifest(await readFile(e,`utf8`),e)}async function writeExtensionCompatibilityManifest(e,t){await writeFile(join(e,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),serializeExtensionCompatibilityManifest(t),`utf8`)}function findUnsupportedExtensionCapabilities(e,t=EXTENSION_CAPABILITY_SUPPORT){return Object.entries(e.requires).flatMap(([e,n])=>{let r=Object.hasOwn(t,e)?t[e]??[]:[];return r.includes(n)?[]:[{capability:e,requiredVersion:n,supportedVersions:r}]}).sort((e,t)=>e.capability.localeCompare(t.capability))}export{EXTENSION_CAPABILITY_SUPPORT,EXTENSION_CAPABILITY_VERSIONS,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest,readExtensionCompatibilityManifest,serializeExtensionCompatibilityManifest,writeExtensionCompatibilityManifest};
|
|
1
|
+
import{readFile,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=2,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_CONTRACTS={extension:{current:1,supported:[1],dropped:{}},tool:{current:53,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,29,30,31,32,34,35,53],dropped:{14:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,15:`TaskExec replaces stageEffect with send`,16:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,17:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,18:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,19:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,20:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,21:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,22:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,28:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,33:`ctx.agent now accepts the subagent name as its first argument, derives invocation identity internally, and infers structured output types`,36:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,37:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,38:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,39:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,40:`runWorkflowProgram was made internal; use the workflow factory from eve/tools/workflow`,41:`workflow no longer accepts agents and its options argument is optional; use workflow() or workflow({ maxSubagents })`,42:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,43:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,44:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,45:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,46:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,47:`eve/experimental/evaluate was removed; import evaluate from eve/ai`,48:`eve/experimental/evaluate was removed; import evaluate from eve/ai`,49:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,50:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,51:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,52:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`}},dynamicTool:{current:51,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,31,32,33,51],dropped:{21:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,28:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,29:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,30:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,34:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,35:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,36:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,37:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,38:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,39:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,40:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,41:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,42:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,43:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,44:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,45:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,46:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,47:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,48:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,49:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,50:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`}},channel:{current:27,supported:[1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,27],dropped:{12:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,19:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,20:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,21:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,22:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,23:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,24:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,25:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,26:`Task views no longer expose executor bindings; background work is owned by workflow runs.`}},schedule:{current:14,supported:[1,2,3,4,6,7,8,9,10,11,12,13,14],dropped:{5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},subagent:{current:19,supported:[3,4,6,7,8,9,10,11,12,13,14,15,16,19],dropped:{1:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,2:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,17:`Removed experimental.instrumentationProviders; instrumentation is now always enabled for root agents.`,18:`Removed experimental.instrumentationProviders; instrumentation is now always enabled for root agents.`}},connection:{current:23,supported:[1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18,19,20,21,22,23],dropped:{9:`Dynamic connection resolvers no longer receive conversation or channel continuation data`,10:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},hook:{current:24,supported:[10,11,12,13,14,15,17,18,19,20,21,22,23,24],dropped:{1:`Model identity moved from session.started runtime metadata to step.started call attribution.`,2:`Model identity moved from session.started runtime metadata to step.started call attribution.`,3:`Model identity moved from session.started runtime metadata to step.started call attribution.`,4:`Model identity moved from session.started runtime metadata to step.started call attribution.`,5:`Model identity moved from session.started runtime metadata to step.started call attribution.`,6:`Model identity moved from session.started runtime metadata to step.started call attribution.`,7:`Model identity moved from session.started runtime metadata to step.started call attribution.`,8:`Model identity moved from session.started runtime metadata to step.started call attribution.`,9:`Model identity moved from session.started runtime metadata to step.started call attribution.`,16:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},skill:{current:1,supported:[1],dropped:{}},dynamicSkill:{current:21,supported:[1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21],dropped:{13:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},instructions:{current:2,supported:[1,2],dropped:{}},dynamicInstructions:{current:22,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22],dropped:{14:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},config:{current:1,supported:[1],dropped:{}},state:{current:6,supported:[1,2,3,4,5,6],dropped:{}}},EXTENSION_CAPABILITY_VERSIONS=Object.fromEntries(Object.entries(EXTENSION_CAPABILITY_CONTRACTS).map(([e,t])=>[e,t.current])),EXTENSION_CAPABILITY_SUPPORT=Object.keys(EXTENSION_CAPABILITY_CONTRACTS).reduce((e,t)=>(e[t]=EXTENSION_CAPABILITY_CONTRACTS[t].supported,e),{}),extensionCompatibilityManifestV1Schema=z.object({kind:z.literal(EXTENSION_COMPATIBILITY_MANIFEST_KIND),formatVersion:z.literal(1),builtWithEve:z.string().min(1),requires:z.record(z.string(),z.number().int().positive())}).strict(),extensionCompatibilityManifestV2Schema=extensionCompatibilityManifestV1Schema.extend({formatVersion:z.literal(2),build:z.object({externalDependencies:z.array(z.string().min(1)).readonly()}).strict().optional()}),extensionCompatibilityManifestSchema=z.union([extensionCompatibilityManifestV1Schema,extensionCompatibilityManifestV2Schema]);function serializeExtensionCompatibilityManifest(e){return`${JSON.stringify(e,null,2)}\n`}function parseExtensionCompatibilityManifest(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`Extension compatibility manifest "${t}" is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}let r=extensionCompatibilityManifestSchema.safeParse(n);if(!r.success)throw Error(`Extension compatibility manifest "${t}" is invalid. ${formatValidationError(r.error)}`);return r.data}async function readExtensionCompatibilityManifest(e){return parseExtensionCompatibilityManifest(await readFile(e,`utf8`),e)}async function writeExtensionCompatibilityManifest(e,t){await writeFile(join(e,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),serializeExtensionCompatibilityManifest(t),`utf8`)}function findUnsupportedExtensionCapabilities(e,t=EXTENSION_CAPABILITY_SUPPORT){return Object.entries(e.requires).flatMap(([e,n])=>{let r=Object.hasOwn(t,e)?t[e]??[]:[];return r.includes(n)?[]:[{capability:e,requiredVersion:n,supportedVersions:r}]}).sort((e,t)=>e.capability.localeCompare(t.capability))}export{EXTENSION_CAPABILITY_SUPPORT,EXTENSION_CAPABILITY_VERSIONS,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest,readExtensionCompatibilityManifest,serializeExtensionCompatibilityManifest,writeExtensionCompatibilityManifest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isAbsolute,relative,resolve}from"node:path";import{createCompiledBindingNamespaceLoader}from"#compiler/load-binding-namespace.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{toErrorMessage}from"#shared/errors.js";import{serializeOutputSchema}from"#tools/schema.js";import{isDynamicModelDefinition}from"#shared/agent-definition.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{isChatGptModelRouting}from"#shared/chatgpt-model.js";import{
|
|
1
|
+
import{isAbsolute,relative,resolve}from"node:path";import{createCompiledBindingNamespaceLoader}from"#compiler/load-binding-namespace.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{toErrorMessage}from"#shared/errors.js";import{parseJsonObject}from"#shared/json.js";import{serializeOutputSchema}from"#tools/schema.js";import{isDynamicModelDefinition}from"#shared/agent-definition.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{isChatGptModelRouting}from"#shared/chatgpt-model.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";async function compileAgentConfig(e,t,n){let r=n.source,i=formatAgentConfigModulePath(e,r,n.binding),a=normalizeAgentDefinition(Object.hasOwn(n,`definition`)?n.definition:await loadModuleBackedDefinition({binding:n.binding,displayPath:i,kind:`agent config`,loadNamespace:createCompiledBindingNamespaceLoader({bindings:{[r.sourceId]:n.binding},registries:t.registries}),source:r}),`Expected the agent config export "${r.exportName??`default`}" from "${i}" to match the public eve shape.`),o=isDynamicModelDefinition(a.model)?a.model:void 0,s=o===void 0?await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:a.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:r,sourcePath:i,value:a.model}):void 0,c={},l={compaction:c,name:e.agentId,source:{...r}};a.defaultTools!==void 0&&(l.defaultTools=a.defaultTools),a.description!==void 0&&(l.description=a.description);let u;o!==void 0&&(u={eventNames:Object.keys(o.events),exportName:r.exportName,sourceKind:`module`,logicalPath:r.logicalPath,sourceId:r.sourceId});let d=normalizeExperimentalDefinition(a.experimental);if(d!==void 0&&(l.experimental=d),a.build!==void 0&&(l.build={externalDependencies:a.build.externalDependencies===void 0?void 0:[...a.build.externalDependencies]}),a.outputSchema!==void 0&&(l.outputSchema=serializeOutputSchema(a.outputSchema)),a.reasoning!==void 0&&(l.reasoning=a.reasoning),a.tool!==void 0&&(l.tool=a.tool),a.limits!==void 0&&(l.limits={maxInputTokensPerSession:a.limits.maxInputTokensPerSession,maxOutputTokensPerSession:a.limits.maxOutputTokensPerSession,maxTokenCostUsdPerSession:a.limits.maxTokenCostUsdPerSession,sessionTimeoutMs:a.limits.sessionTimeoutMs}),a.compaction?.model!==void 0&&(c.model=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:a.compaction.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:r,sourcePath:i,value:a.compaction.model})),a.compaction?.thresholdPercent!==void 0&&(c.thresholdPercent=a.compaction.thresholdPercent),u!==void 0)return{...l,dynamicModel:u};if(s===void 0)throw Error(`Expected a static agent model to compile to a concrete model reference.`);return{...l,model:s}}function normalizeExperimentalDefinition(e){if(e===void 0)return;let t={};return e.workflow!==void 0&&(t.workflow={modelCallsPerStep:e.workflow.modelCallsPerStep,retention:e.workflow.retention,world:e.workflow.world}),t}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(e.value,e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${e.sourcePath??t.logicalPath}" to provide a valid AI SDK language model.`);let i={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(n,e.providerOptions)};if(e.contextWindowTokens===void 0){if(isChatGptModelRouting(i.routing))return{...i,contextWindowTokens:2e5};try{let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...i,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens,maxOutputTokens:t.limits.maxOutputTokens}}catch{}}return await withCompiledRuntimeModelLimits(i,e)}function formatAgentConfigModulePath(e,t,n){return n.backing.kind===`programmatic`?t.logicalPath:normalizeLogicalPath(relative(resolveTopLevelAgentRoot(e),n.backing.sourcePath))}function resolveTopLevelAgentRoot(e){let t=resolve(e.appRoot),n=resolve(t,`agent`);return isPathInsideOrEqual(n,resolve(e.agentRoot))?n:t}function isPathInsideOrEqual(e,t){let n=relative(e,t);return n===``||!n.startsWith(`..`)&&!isAbsolute(n)}async function withCompiledRuntimeModelLimits(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n;try{n=await t.modelCatalog.getModelLimits(e.id)}catch(n){throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${toErrorMessage(n)}`)}if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens,maxOutputTokens:n.maxOutputTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{compileAgentConfig};
|