eve 0.9.0 → 0.9.1
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 +11 -0
- package/bin/eve.d.ts +5 -0
- package/bin/eve.js +15 -13
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +5 -0
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +1 -0
- package/dist/src/cli/dev/tui/terminal-renderer.js +9 -6
- package/dist/src/compiled/.vendor-stamp.json +2 -1
- package/dist/src/compiled/semver/LICENSE +15 -0
- package/dist/src/compiled/semver/index.d.ts +23 -0
- package/dist/src/compiled/semver/index.js +1 -0
- package/dist/src/execution/sandbox/logging-session.js +2 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/host/dev-watcher-log.d.ts +3 -0
- package/dist/src/internal/nitro/host/dev-watcher-log.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -1
- package/dist/src/setup/boxes/add-channels.d.ts +4 -6
- package/dist/src/setup/boxes/add-channels.js +1 -1
- package/dist/src/setup/boxes/scaffold.d.ts +2 -2
- package/dist/src/setup/boxes/scaffold.js +1 -1
- package/dist/src/setup/node-engine.d.ts +31 -0
- package/dist/src/setup/node-engine.js +1 -0
- package/dist/src/setup/onboarding.d.ts +3 -2
- package/dist/src/setup/onboarding.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.d.ts +10 -5
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.d.ts +17 -4
- package/dist/src/setup/scaffold/create/project.js +9 -5
- package/dist/src/setup/scaffold/index.d.ts +1 -1
- package/dist/src/setup/scaffold/update/channels.d.ts +4 -2
- package/dist/src/setup/scaffold/update/channels.js +2 -2
- package/dist/src/setup/scaffold/update/package-json.d.ts +12 -1
- package/dist/src/setup/scaffold/update/package-json.js +1 -1
- package/dist/src/setup/scaffold/version-tokens.js +1 -1
- package/docs/getting-started.mdx +2 -2
- package/docs/reference/cli.md +2 -0
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 79dcb7b: Update the AI SDK peer dependency range to accept `ai` versions starting at `7.0.0-beta.177`, and use that beta for workspace development installs.
|
|
8
|
+
- bd96d9c: Delay local dev rebuild errors in `eve dev` until the next user prompt unless all logs are enabled. A successful rebuild clears the delayed error so stale HMR failures are not shown after the agent builds cleanly.
|
|
9
|
+
- 9009664: `eve dev` now records its active process in `.eve/dev-process.pid` and refuses to start a second local server for the same agent while that process is still running. The duplicate-start message includes the command to stop the existing server.
|
|
10
|
+
- 9936fc8: Fail sandbox bootstrap immediately when a `sandbox.run` command exits with code 1, including the command plus full stdout and stderr in the error.
|
|
11
|
+
- 6d7a4e5: Scaffolded projects now select the lowest complete Node.js major supported by Eve's own `package.json` `engines.node` contract and pin that major (e.g. `24.x`). The CLI bootstrap validates the exact authored range and ships its runtime semver dependency, while `eve init` and Web Chat use the invoking Eve release's matching dependency version and engine contract.
|
|
12
|
+
- 6d7a4e5: Scaffolded agent projects now declare `@types/node` at the same major selected for `engines.node` and set `compilerOptions.types: ["node"]` in `tsconfig.json`. Agent code that touches `process` or Node built-ins now typechecks without exposing APIs from a newer Node major than the generated app declares.
|
|
13
|
+
|
|
3
14
|
## 0.9.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/bin/eve.d.ts
CHANGED
|
@@ -46,6 +46,11 @@ export interface BootstrapDependencies extends BootstrapBuildDependencies {
|
|
|
46
46
|
* Node.js version string used by tests to exercise the bin version guard.
|
|
47
47
|
*/
|
|
48
48
|
nodeVersion?: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Node.js engine range used by tests to exercise non-default package contracts.
|
|
52
|
+
*/
|
|
53
|
+
nodeEngineRequirement?: string;
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
/**
|
package/bin/eve.js
CHANGED
|
@@ -5,9 +5,15 @@ import { access, readdir, realpath, stat } from "node:fs/promises";
|
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { dirname, resolve } from "node:path";
|
|
7
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
+
import semver from "semver";
|
|
8
9
|
|
|
9
10
|
const require = createRequire(import.meta.url);
|
|
10
|
-
const
|
|
11
|
+
const packageJson = require("../package.json");
|
|
12
|
+
const packageNodeEngine = packageJson.engines?.node;
|
|
13
|
+
|
|
14
|
+
if (typeof packageNodeEngine !== "string" || semver.validRange(packageNodeEngine) === null) {
|
|
15
|
+
throw new Error("eve package.json must declare a valid engines.node range.");
|
|
16
|
+
}
|
|
11
17
|
|
|
12
18
|
function createBootstrapOptions(overrides = {}) {
|
|
13
19
|
const packageRoot =
|
|
@@ -109,23 +115,19 @@ function inputTsconfigPath({ packageRoot }) {
|
|
|
109
115
|
return resolve(packageRoot, "tsconfig.json");
|
|
110
116
|
}
|
|
111
117
|
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function assertSupportedNodeVersion(version = process.version) {
|
|
118
|
-
const majorVersion = parseNodeMajorVersion(version);
|
|
119
|
-
|
|
120
|
-
if (majorVersion !== undefined && majorVersion >= minimumNodeMajorVersion) {
|
|
118
|
+
function assertSupportedNodeVersion(version = process.version, requiredRange = packageNodeEngine) {
|
|
119
|
+
if (semver.validRange(requiredRange) === null) {
|
|
120
|
+
throw new Error(`Eve declares an invalid Node.js engine range: "${requiredRange}".`);
|
|
121
|
+
}
|
|
122
|
+
if (semver.satisfies(version, requiredRange)) {
|
|
121
123
|
return;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
throw new Error(
|
|
125
127
|
[
|
|
126
|
-
`Eve requires Node.js ${
|
|
128
|
+
`Eve requires Node.js ${requiredRange}.`,
|
|
127
129
|
`You are running ${version}.`,
|
|
128
|
-
"Please
|
|
130
|
+
"Please install a compatible Node.js version and try again.",
|
|
129
131
|
].join(" "),
|
|
130
132
|
);
|
|
131
133
|
}
|
|
@@ -230,7 +232,7 @@ export async function ensureBuiltCli(overrides = {}, dependencies = {}) {
|
|
|
230
232
|
* Runs the compiled Eve CLI, building the workspace package on demand when needed.
|
|
231
233
|
*/
|
|
232
234
|
export async function runEveCli(argv = process.argv.slice(2), overrides = {}, dependencies = {}) {
|
|
233
|
-
assertSupportedNodeVersion(dependencies.nodeVersion);
|
|
235
|
+
assertSupportedNodeVersion(dependencies.nodeVersion, dependencies.nodeEngineRequirement);
|
|
234
236
|
|
|
235
237
|
const cliEntrypointPath = await ensureBuiltCli(overrides, dependencies);
|
|
236
238
|
const importModule = dependencies.importModule ?? ((specifier) => import(specifier));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__toESM}from"../../_virtual/_rolldown/runtime.js";import{require_picocolors}from"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js";import{tryInitializeGit}from"./init-git.js";import{join,resolve}from"node:path";import{ensureChannel,scaffoldBaseProject}from"#setup/scaffold/index.js";import{mkdtemp,rename,rm,stat}from"node:fs/promises";import{EVE_WORDMARK}from"#cli/banner.js";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{SPINNER_FRAMES,SPINNER_FRAME_MS}from"#setup/cli/rail-log.js";import{detectInvokingPackageManager,detectPackageManager}from"#setup/package-manager.js";import{pathExists}from"#setup/path-exists.js";import{parseProjectName}from"#setup/project-name.js";import{eveDevArguments,runPackageManagerInstall,spawnPackageManager}from"#setup/primitives/index.js";import{addAgentToProject}from"#setup/scaffold/create/add-to-project.js";var import_picocolors=__toESM(require_picocolors(),1);const defaultDependencies={addAgentToProject,detectInvokingPackageManager,detectPackageManager,ensureChannel,runPackageManagerInstall,scaffoldBaseProject,spawnPackageManager,tryInitializeGit};async function resolveTargetDirectory(e,t){let n=resolve(e,t);return(await stat(n).catch(()=>void 0))?.isDirectory()?n:void 0}async function addToExistingProject(e,t,n){if(t.channelWebNextjs===!0)throw Error("`--channel-web-nextjs` is not supported when adding an agent to an existing project. Run `eve channels add web` from the project afterwards instead.");let r=await n.detectPackageManager(e)
|
|
1
|
+
import{__toESM}from"../../_virtual/_rolldown/runtime.js";import{require_picocolors}from"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js";import{tryInitializeGit}from"./init-git.js";import{join,resolve}from"node:path";import{ensureChannel,scaffoldBaseProject}from"#setup/scaffold/index.js";import{mkdtemp,rename,rm,stat}from"node:fs/promises";import{EVE_WORDMARK}from"#cli/banner.js";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{SPINNER_FRAMES,SPINNER_FRAME_MS}from"#setup/cli/rail-log.js";import{formatNodeEngineOverrideWarning}from"#setup/node-engine.js";import{detectInvokingPackageManager,detectPackageManager}from"#setup/package-manager.js";import{pathExists}from"#setup/path-exists.js";import{parseProjectName}from"#setup/project-name.js";import{eveDevArguments,runPackageManagerInstall,spawnPackageManager}from"#setup/primitives/index.js";import{addAgentToProject}from"#setup/scaffold/create/add-to-project.js";var import_picocolors=__toESM(require_picocolors(),1);const defaultDependencies={addAgentToProject,detectInvokingPackageManager,detectPackageManager,ensureChannel,runPackageManagerInstall,scaffoldBaseProject,spawnPackageManager,tryInitializeGit};async function resolveTargetDirectory(e,t){let n=resolve(e,t);return(await stat(n).catch(()=>void 0))?.isDirectory()?n:void 0}async function addToExistingProject(e,t,n){if(t.channelWebNextjs===!0)throw Error("`--channel-web-nextjs` is not supported when adding an agent to an existing project. Run `eve channels add web` from the project afterwards instead.");let r=await n.detectPackageManager(e),i=await n.addAgentToProject({projectRoot:e,model:DEFAULT_AGENT_MODEL_ID,packageManager:r.kind});return{packageManager:r.kind,nodeEngineOverride:i.nodeEngineOverride}}function resolveScaffoldPackageManager(e){return e.detectInvokingPackageManager()??`pnpm`}async function scaffoldProject(e,t,n,a,o){let u=resolve(e),d=join(u,t);if(await pathExists(d))throw Error(`Cannot create project because "${d}" already exists.`);let p=await mkdtemp(join(u,`.eve-init-`));try{let e=await o.scaffoldBaseProject({projectName:t,model:DEFAULT_AGENT_MODEL_ID,packageManager:n,targetDirectory:p});return a.channelWebNextjs===!0&&await o.ensureChannel({projectRoot:e,kind:`web`,packageManager:n,configureVercelServices:!1}),await rename(e,d),d}finally{await rm(p,{recursive:!0,force:!0})}}function startSpinner(e,t){if(process.stdout.isTTY!==!0)return e.log(t),{stop(){}};let row=e=>`${import_picocolors.default.green(e)} ${t}`;process.stdout.write(row(SPINNER_FRAMES[0]));let n=0,r=setInterval(()=>{n+=1;let e=SPINNER_FRAMES[n%SPINNER_FRAMES.length]??SPINNER_FRAMES[0];process.stdout.write(`\r\u001B[K${row(e)}`)},SPINNER_FRAME_MS);r.unref?.();let i=!1;return{stop(){i||(i=!0,clearInterval(r),process.stdout.write(`\r\x1B[K`))}}}async function runInitCommand(e,t,n,r,i=defaultDependencies){let a=await resolveTargetDirectory(t,n),o,s;if(a===void 0)o=resolveScaffoldPackageManager(i),s=await scaffoldProject(t,parseProjectName(n),o,r,i),e.log(`${import_picocolors.default.green(`✓`)} Created an ${EVE_WORDMARK} agent in ${import_picocolors.default.bold(s)}`);else{let t=await addToExistingProject(a,r,i);o=t.packageManager,s=a,e.log(`${import_picocolors.default.green(`✓`)} Added an ${EVE_WORDMARK} agent to ${import_picocolors.default.bold(s)}`),t.nodeEngineOverride!==void 0&&e.log(import_picocolors.default.yellow(`⚠ ${formatNodeEngineOverrideWarning(t.nodeEngineOverride)}`))}let c=[],l=startSpinner(e,`Installing dependencies...`),u;try{u=await i.runPackageManagerInstall(o,s,{bypassMinimumReleaseAge:!0,onOutput:e=>c.push(e.text)})}finally{l.stop()}if(!u){for(let t of c)e.error(t);throw Error(`Failed to install dependencies in "${s}".`)}if(e.log(`${import_picocolors.default.green(`✓`)} Installed dependencies`),a===void 0){let t=i.tryInitializeGit(s);t.kind===`failed`&&e.error(import_picocolors.default.yellow(`Git initialization failed: ${t.reason}`))}let f=a===void 0,p=f?[...eveDevArguments(o),`--input`,`/model`]:eveDevArguments(o);if(e.log(import_picocolors.default.dim(f?`$ eve dev --input /model`:`$ eve dev`)),!await i.spawnPackageManager(o,s,p))throw Error(`Development server exited unsuccessfully in "${s}".`)}export{runInitCommand};
|
|
@@ -189,6 +189,11 @@ export type AgentTUIRenderer = {
|
|
|
189
189
|
* positions. Used by the `/loglevel` command.
|
|
190
190
|
*/
|
|
191
191
|
setLogDisplayMode?(mode: LogDisplayMode): void;
|
|
192
|
+
/**
|
|
193
|
+
* Commits any delayed local dev build errors immediately before dispatching
|
|
194
|
+
* a user prompt. Renderers without process-log capture ignore it.
|
|
195
|
+
*/
|
|
196
|
+
flushDelayedDevBuildErrors?(): void;
|
|
192
197
|
/**
|
|
193
198
|
* Sets the workspace-scoped Vercel segment of the persistent bottom
|
|
194
199
|
* status line: linked project identity and the session's pending-deploy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pickAgentHeaderTip}from"./agent-header.js";import{formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{failureKey,formatFailureDetail,formatFailureMessage,formatGatewayAuthFailureNotice,isAbortLikeError,isGatewayAuthFailure,isInterruptedError}from"./errors.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{BOOT_DETECTIONS,detectSetupIssues,formatSetupIssuesLine}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import{toErrorMessage}from"#shared/errors.js";import{isCurrentTurnBoundaryEvent}from"#client/index.js";import{subscribeDevelopmentSandboxPrewarmLogs}from"#execution/sandbox/development-prewarm.js";import{createDevelopmentRuntimeArtifactSessionRefresher}from"#services/dev-client.js";var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v=pickAgentHeaderTip();#y;#b=new Map;#x=new Map;#S=new Map;#C=new Map;#w=new Set;#T=!1;#E;constructor(e){if(this.#e=e.session,e.client!==void 0&&(this.#t=e.client),this.#n=createRenderer(e),this.#r=e.name??`Eve`,this.#i=e.tools??`full`,this.#a=e.reasoning??`full`,this.#o=e.subagents??`full`,this.#s=e.connectionAuth??`full`,this.#c=e.assistantResponseStats??`tokensPerSecond`,this.#l=e.contextSize,this.#u=e.formatTransportError??toErrorMessage,e.initialInput!==void 0&&(this.#m=e.initialInput),e.appRoot!==void 0){this.#p=e.appRoot;let t={appRoot:e.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};e.detectProjectIdentity!==void 0&&(t.detectIdentity=e.detectProjectIdentity),this.#_=createVercelStatusTracker(t)}e.promptCommandHandler!==void 0&&(this.#h=e.promptCommandHandler),this.#g=e.bootDetections??BOOT_DETECTIONS,e.serverUrl!==void 0&&(this.#f=e.serverUrl,this.#d=createDevelopmentRuntimeArtifactSessionRefresher({serverUrl:e.serverUrl}))}async#D(){let e=this.#f;if(e===void 0){await this.#M(void 0);return}let t;try{t=await this.#t?.info()}catch{t=void 0}this.#y=t;let n={name:this.#r,serverUrl:e};t!==void 0&&(n.info=t),this.#p!==void 0&&(n.tip=this.#v),this.#n.renderAgentHeader?.(n),await this.#M(t)}async run(){try{await this.#O()}finally{this.#E?.(),this.#E=void 0,this.#n.shutdown?.(),this.#_?.dispose()}}async#O(){let e=this.#r,r,i,a=!1,o=!1,s=this.#m;for(await this.#D(),this.#N(),this.#_?.refreshIdentity();;){if(!o){if(r==null){if(!this.#n.readPrompt){if(a)return;throw Error(`No prompt was provided and the renderer does not support prompt input.`)}let t={title:e};s!==void 0&&(t.initialDraft=s,s=void 0);try{r=await this.#A(t)}catch(e){if(isInterruptedError(e))return;throw e}if(r==null)return}let c=parsePromptCommand(r);if(c?.type===`exit`)return;if(c?.type===`new`){this.#k(),i=void 0,o=!1,r=void 0,this.#n.reset?.();continue}if(c?.type===`help`){this.#P(formatPromptCommandHelp()),i=void 0,o=!1,r=void 0;continue}if(c?.type===`loglevel`){this.#P(this.#F(c.argument)),i=void 0,o=!1,r=void 0;continue}if(c?.type===`extension`){try{let t=this.#h===void 0?{message:`/${c.name} is not available in this session.`}:await this.#h.handle(c,{renderer:this.#n,title:e});t?.message!==void 0&&this.#P(t.message),t?.vercelEffect!==void 0&&this.#_?.applyEffect(t.vercelEffect)}catch(e){if(isInterruptedError(e))return;throw e}i=void 0,r=void 0,o=!1;continue}a=!0}let c=await this.#j({prompt:o?void 0:r,inputResponses:i});try{await this.#n.renderStream(c,{title:e,submittedPrompt:r,continueSession:!!this.#n.readPrompt,tools:this.#i,reasoning:this.#a,subagents:this.#o,connectionAuth:this.#s,assistantResponseStats:this.#c,contextSize:this.#l});let t=c.turnState?.pendingApprovals??[],n=c.turnState?.pendingQuestions??[];if(t.length>0||n.length>0){let a=[];if(t.length>0){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);for(let n of t){let t=await this.#n.readToolApproval(n,{title:e});a.push({requestId:n.approvalId,optionId:t.approved?`approve`:`deny`}),this.#b.delete(n.approvalId)}}if(n.length>0){if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);for(let t of n){let n=toAgentTUIInputQuestion(t),r=await this.#n.readInputQuestion(n,{title:e});if(r===void 0)continue;let i={requestId:t.requestId};r.optionId!==void 0&&(i.optionId=r.optionId),r.text!==void 0&&(i.text=r.text),a.push(i),this.#b.delete(t.requestId)}}o=!0,i=a,r=void 0;continue}c.turnState&&c.turnState.boundaryEvent===void 0&&(this.#T=!0)}catch(e){if(isInterruptedError(e))return;throw e}o=!1,i=void 0,r=void 0,this.#T&&(this.#T=!1,this.#k(),this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`))}}#k(){for(let e of this.#S.values())e.abort();this.#S.clear(),this.#x.clear(),this.#b.clear(),this.#C.clear(),this.#w.clear(),this.#t&&(this.#e=this.#t.session()),this.#d?.clear()}async#A(e){if(!this.#n.readPrompt)return;let t=this.#n.readPrompt(e),n=this.#t,r=this.#d;if(n===void 0||r===void 0)return await t;let i=!1,a=!1,o,refresh=async()=>{if(!(i||a)){a=!0;try{this.#e=await r.refreshIdle({createSession:()=>n.session(),onRuntimeArtifactsChanged:()=>this.#I(),session:this.#e})}finally{a=!1}}},startRefresh=()=>{if(i||a)return;let e=refresh().finally(()=>{o===e&&(o=void 0)});o=e};startRefresh();let s=setInterval(()=>{startRefresh()},500);s.unref?.();try{return await t}finally{i=!0,clearInterval(s),await o}}async#j(e){let t=new AbortController,n={signal:t.signal};e.prompt!==void 0&&(n.message=e.prompt),e.inputResponses!==void 0&&e.inputResponses.length>0&&(n.inputResponses=e.inputResponses);let r;try{let e=this.#t;e!==void 0&&this.#d!==void 0&&(this.#e=await this.#d.refresh({createSession:()=>e.session(),inputResponses:n.inputResponses,message:n.message,onRuntimeArtifactsChanged:()=>this.#I(),session:this.#e})),r=await this.#e.send(n)}catch(e){if(isInterruptedError(e))throw e;return this.#T=!0,{events:errorOnlyTUIStream({errorText:this.#u(e)}),turnState:createTurnState()}}let i=createTurnState();return{abort:()=>t.abort(),events:eveEventsToTUIStream({events:r,pendingInputRequests:this.#b,subagentRuns:this.#x,turnState:i,onSubagentCalled:e=>this.#B(e),onSubagentCompleted:e=>this.#H(e),onConnectionAuthRequired:e=>this.#L(e),onConnectionAuthCompleted:e=>this.#R(e),onTerminalFailure:()=>{this.#T=!0},failureOverride:this.#p===void 0?void 0:e=>isGatewayAuthFailure(e)?formatGatewayAuthFailureNotice(e):void 0}),turnState:i}}async#M(e){if(this.#p===void 0||this.#n.renderSetupWarning===void 0)return;let t={appRoot:this.#p,env:process.env};e!==void 0&&(t.info=e);let n=await detectSetupIssues(t,this.#g);n.length!==0&&this.#n.renderSetupWarning(formatSetupIssuesLine(n))}#N(){this.#p===void 0||this.#n.renderSandboxLog===void 0||this.#E===void 0&&(this.#E=subscribeDevelopmentSandboxPrewarmLogs({appRoot:this.#p,log:e=>this.#n.renderSandboxLog?.(e)}))}#P(e){if(this.#n.renderCommandResult!==void 0){this.#n.renderCommandResult(e);return}this.#n.renderNotice?.(e)}#F(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel all|stderr|sandbox|none — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use all, stderr, sandbox, or none.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`stderr`:return`Showing stderr logs only.`;case`sandbox`:return`Showing sandbox logs only.`;case`all`:return`Showing all logs.`}}async#I(){let e=this.#y,t;try{t=await this.#t?.info()}catch{t=void 0}if(t!==void 0&&(this.#y=t,this.#f!==void 0)){let e={info:t,name:this.#r,serverUrl:this.#f};this.#p!==void 0&&(e.tip=this.#v),this.#n.renderAgentHeader?.(e)}(!this.#n.renderAgentHeader||t===void 0)&&this.#n.renderNotice?.(formatAgentUpdateNotice(e,t))}#L(e){let t={name:e.data.name,description:e.data.description,state:`required`};e.data.authorization!==void 0&&(t.challenge=e.data.authorization),e.data.webhookUrl!==void 0&&(t.webhookUrl=e.data.webhookUrl),this.#C.set(e.data.name,t),this.#z(t)}#R(e){let t=this.#C.get(e.data.name)??{name:e.data.name,description:``,state:e.data.outcome};t.state=e.data.outcome,e.data.reason!==void 0&&(t.reason=e.data.reason),this.#C.set(e.data.name,t),this.#w.delete(e.data.name),this.#z(t),this.#n.setConnectionAuthPendingCount?.(this.#w.size)}#z(e){let t={name:e.name,description:e.description,state:e.state};e.challenge!==void 0&&(t.challenge=e.challenge),e.reason!==void 0&&(t.reason=e.reason),this.#n.upsertConnectionAuth?.(t)}#B(e){let t=e.data.callId;if(this.#S.has(t))return;let n=this.#t;if(!n)return;let r=new AbortController;this.#S.set(t,r),(async()=>{try{let i=n.session({sessionId:e.data.childSessionId,streamIndex:0}).stream({signal:r.signal});for await(let e of i)if(r.signal.aborted||(this.#U(t,e),isCurrentTurnBoundaryEvent(e)))break}catch(e){if(!isAbortLikeError(e)){let n=toErrorMessage(e),r=this.#x.get(t);if(r){let{key:e,step:i}=openCurrentSubagentSection(r);i.message=i.message?`${i.message}\n\nstream error: ${n}`:`stream error: ${n}`,i.finalized=!0,r.currentSectionKey=null,this.#n.upsertSubagentStep?.({callId:t,subagentName:r.name,sectionKey:e,reasoning:i.reasoning,message:i.message,finalized:!0})}}}finally{this.#S.delete(t)}})()}#V(e,t,n){let r=t.tools.get(n.childCallId),i=r??{toolName:n.toolName,input:n.input,status:n.status};if(r){let e={"approval-requested":0,executing:1,done:2,failed:2};e[n.status]>e[r.status]&&(r.status=n.status),r.input=n.input}else t.tools.set(n.childCallId,i);this.#n.markChildToolCallId?.(n.childCallId),this.#n.upsertSubagentTool?.({callId:e,subagentName:t.name,childCallId:n.childCallId,toolName:i.toolName,input:i.input,status:i.status})}#H(e){let t=this.#x.get(e);if(t){for(let[n,r]of t.steps)r.finalized||(r.finalized=!0,this.#n.upsertSubagentStep?.({callId:e,subagentName:t.name,sectionKey:n,reasoning:r.reasoning,message:r.message,finalized:!0}));t.currentSectionKey=null}}#U(e,t){let n=this.#x.get(e);if(!n)return;let r=this.#n,emit=(t,i)=>{r.upsertSubagentStep?.({callId:e,subagentName:n.name,sectionKey:t,reasoning:i.reasoning,message:i.message,finalized:i.finalized})},finalizeCurrent=()=>{if(n.currentSectionKey===null)return;let e=n.steps.get(n.currentSectionKey);e&&(e.finalized=!0,emit(n.currentSectionKey,e)),n.currentSectionKey=null};switch(t.type){case`reasoning.appended`:{let{key:e,step:r}=openCurrentSubagentSection(n);r.reasoning+=t.data.reasoningDelta,emit(e,r);break}case`reasoning.completed`:break;case`message.appended`:{let{key:e,step:r}=openCurrentSubagentSection(n);r.message+=t.data.messageDelta,emit(e,r);break}case`message.completed`:{let{key:e,step:r}=openCurrentSubagentSection(n);t.data.message!==null&&r.message.length===0&&(r.message=t.data.message),r.finalized=!0,emit(e,r),n.currentSectionKey=null;break}case`step.completed`:finalizeCurrent();break;case`actions.requested`:finalizeCurrent();for(let r of t.data.actions)r.kind===`tool-call`&&this.#V(e,n,{childCallId:r.callId,toolName:r.toolName,input:r.input,status:`executing`});break;case`input.requested`:finalizeCurrent();for(let r of t.data.requests)r.action.kind===`tool-call`&&this.#V(e,n,{childCallId:r.action.callId,toolName:r.action.toolName,input:r.action.input,status:`approval-requested`});break;case`action.result`:{let i=t.data.result;if(i.kind!==`tool-result`)break;let a=n.tools.get(i.callId);if(!a)break;t.data.status===`failed`?(a.status=`failed`,a.errorText=formatActionResultError(t)):(a.status=`done`,a.output=i.output);let o={callId:e,subagentName:n.name,childCallId:i.callId,toolName:a.toolName,input:a.input,status:a.status};a.output!==void 0&&(o.output=a.output),a.errorText!==void 0&&(o.errorText=a.errorText),r.upsertSubagentTool?.(o);break}default:break}}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,input:e.userInput,output:e.screen})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}async function*eveEventsToTUIStream(e){let{events:t,pendingInputRequests:n,subagentRuns:r,turnState:i,onSubagentCalled:a,onSubagentCompleted:o,onConnectionAuthRequired:s,onConnectionAuthCompleted:c,onTerminalFailure:l,failureOverride:u}=e,d=new Map,f=new Map,p=0,m=new Set,h=new Set,g=new Set,_=new Set,v=!1,y=!1,b;for await(let e of t)if(!(y&&isPostTurnVisibleEvent(e)))switch(e.type){case`session.started`:case`turn.started`:case`message.received`:break;case`step.started`:p+=1,yield{type:`step-start`};break;case`step.completed`:{let t=e;b=t.data.usage,yield*closeOpenParts(d,`assistant-complete`,p),yield*closeOpenParts(f,`reasoning-complete`,p),yield{type:`step-finish`,usage:t.data.usage};break}case`message.appended`:{let t=e,n=textPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(d,n),i=t.data.messageSoFar;if(r.completed){if(r.text.startsWith(i)||p<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}if(!i.startsWith(r.text)||i.length<=r.text.length)break;let a=i.slice(r.text.length);r.text=i,yield{type:`assistant-delta`,id:partGenerationId(n,r.generation),delta:a};break}case`message.completed`:{let t=textPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(d,t),r=e.data.message;if(n.completed){if(r===null||r===n.text||p<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=p,yield{type:`assistant-complete`,id:partGenerationId(t,n.generation),text:r};break}let i=partGenerationId(t,n.generation);if(r!==null){if(n.text.length===0)n.text=r,n.completed=!0,n.completedEpoch=p,yield{type:`assistant-complete`,id:i,text:r};else if(r.startsWith(n.text)){let e=r.slice(n.text.length);e.length>0&&(yield{type:`assistant-delta`,id:i,delta:e}),n.text=r,n.completed=!0,n.completedEpoch=p,yield{type:`assistant-complete`,id:i}}}else n.text.length>0&&(n.completed=!0,n.completedEpoch=p,yield{type:`assistant-complete`,id:i});break}case`reasoning.appended`:{let t=e,n=reasoningPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(f,n),i=t.data.reasoningSoFar;if(r.completed){if(r.text.startsWith(i)||p<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}if(!i.startsWith(r.text)||i.length<=r.text.length)break;let a=i.slice(r.text.length);r.text=i,yield{type:`reasoning-delta`,id:partGenerationId(n,r.generation),delta:a};break}case`reasoning.completed`:{let t=reasoningPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(f,t),r=e.data.reasoning;if(n.completed){if(r.length===0||r===n.text||n.text.startsWith(r)||p<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=p;let e=partGenerationId(t,n.generation);yield{type:`reasoning-delta`,id:e,delta:r},yield{type:`reasoning-complete`,id:e};break}let i=partGenerationId(t,n.generation);if(n.text.length===0&&r.length>0)n.text=r,yield{type:`reasoning-delta`,id:i,delta:r};else if(r.length>0&&!r.startsWith(n.text))break;n.completed=!0,n.completedEpoch=p,yield{type:`reasoning-complete`,id:i};break}case`actions.requested`:{let t=e.data,n=t.actions.filter(e=>e.kind===`tool-call`);if(n.length===0)break;let r=toolBatchKey(`actions.requested`,t.turnId,t.stepIndex,n);if(g.has(r)){for(let e of n)m.has(e.callId)||h.add(e.callId);break}g.add(r);for(let e of n)m.has(e.callId)||(m.add(e.callId),yield{type:`tool-call`,toolCallId:e.callId,toolName:e.toolName,input:e.input});break}case`input.requested`:{let t=e.data,r=t.requests.filter(e=>e.action.kind===`tool-call`);if(r.length===0)break;let a=inputRequestBatchKey(t.turnId,t.stepIndex,r);if(g.has(a)){for(let e of r)m.has(e.action.callId)||h.add(e.action.callId);break}g.add(a);for(let e of r){let t=e.action.callId;if(m.has(t)||(m.add(t),yield{type:`tool-call`,toolCallId:t,toolName:e.action.toolName,input:e.action.input}),n.set(e.requestId,e),isQuestionRequest(e)){upsertPendingQuestion(i,e);continue}upsertPendingApproval(i,e),yield{type:`tool-approval-request`,approvalId:e.requestId,toolCallId:t}}break}case`action.result`:{let t=e;if(t.data.result.kind!==`tool-result`)break;let n=t.data.result.callId;if(h.has(n)||!m.has(n))break;t.data.status===`failed`?yield{type:`tool-error`,toolCallId:n,errorText:formatActionResultError(t)}:yield{type:`tool-result`,toolCallId:n,output:t.data.result.output};break}case`step.failed`:case`turn.failed`:{let t=toFailureEvent(e,_,u);t&&(yield t);break}case`session.failed`:{i.sawSessionFailure=!0,l?.(e);let t=toFailureEvent(e,_,u);t&&(yield t),i.boundaryEvent=e.type,yield*closeOpenParts(d,`assistant-complete`,p),yield*closeOpenParts(f,`reasoning-complete`,p),yield{type:`finish`,usage:b},v=!0;return}case`session.waiting`:case`session.completed`:i.boundaryEvent=e.type,yield*closeOpenParts(d,`assistant-complete`,p),yield*closeOpenParts(f,`reasoning-complete`,p),yield{type:`finish`,usage:b},v=!0;return;case`turn.completed`:y=!0,yield*closeOpenParts(d,`assistant-complete`,p),yield*closeOpenParts(f,`reasoning-complete`,p);break;case`subagent.called`:{let t=e;if(!r.has(t.data.callId))r.set(t.data.callId,{name:t.data.name,steps:new Map,currentSectionKey:null,nextSectionKey:0,tools:new Map});else{let e=r.get(t.data.callId);e&&(e.name=t.data.name)}a?.(t);break}case`subagent.started`:case`subagent.event`:break;case`subagent.completed`:o?.(e.data.callId);break;case`authorization.required`:s?.(e);break;case`authorization.completed`:c?.(e);break;default:break}v||(yield*closeOpenParts(d,`assistant-complete`,p),yield*closeOpenParts(f,`reasoning-complete`,p),yield{type:`finish`,usage:b})}async function*errorOnlyTUIStream(e){yield{type:`error`,errorText:e.errorText},yield{type:`finish`}}function createTurnState(){return{pendingApprovals:[],pendingQuestions:[],sawSessionFailure:!1}}function upsertPendingApproval(e,t){let n=toAgentTUIToolApprovalRequest(t),r=e.pendingApprovals.findIndex(e=>e.approvalId===n.approvalId);r===-1?e.pendingApprovals.push(n):e.pendingApprovals[r]=n}function toAgentTUIToolApprovalRequest(e){return{approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,input:e.action.input}}function upsertPendingQuestion(e,t){let n=e.pendingQuestions.findIndex(e=>e.requestId===t.requestId);n===-1?e.pendingQuestions.push(t):e.pendingQuestions[n]=t}function textPartId(e,t){return`text:${e}:${t}`}function reasoningPartId(e,t){return`reasoning:${e}:${t}`}function partStateFor(e,t){let n=e.get(t);return n===void 0&&(n={generation:0,text:``,completed:!1,completedEpoch:0},e.set(t,n)),n}function partGenerationId(e,t){return t===0?e:`${e}#${t}`}function*closeOpenParts(e,t,n){for(let[r,i]of e)i.completed||i.text.length===0||(i.completed=!0,i.completedEpoch=n,yield{type:t,id:partGenerationId(r,i.generation)})}function isPostTurnVisibleEvent(e){switch(e.type){case`actions.requested`:case`authorization.completed`:case`authorization.required`:case`input.requested`:case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:case`result.completed`:case`step.completed`:case`step.failed`:case`step.started`:case`subagent.called`:case`subagent.completed`:case`subagent.event`:case`subagent.started`:case`turn.completed`:case`turn.failed`:return!0;default:return!1}}function toolBatchKey(e,t,n,r){return`${e}:${t}:${String(n)}:${stableStringify(r.map(e=>({input:e.input,toolName:e.toolName})))}`}function inputRequestBatchKey(e,t,n){return toolBatchKey(`input.requested`,e,t,n.map(e=>({input:e.action.input,toolName:e.action.toolName})))}function stableStringify(e){return JSON.stringify(toStableJson(e))??`undefined`}function toStableJson(e,t=new WeakSet){if(typeof e!=`object`||!e)return e;if(t.has(e))return`[Circular]`;if(t.add(e),Array.isArray(e))return e.map(e=>toStableJson(e,t));let n=e,r={};for(let e of Object.keys(n).sort())r[e]=toStableJson(n[e],t);return r}function formatActionResultError(e){if(e.data.error?.message)return e.data.error.message;let t=e.data.result.output;if(typeof t==`string`)return t;try{return JSON.stringify(t)}catch{return`Tool execution failed.`}}function toFailureEvent(e,t,n){let o=failureKey(e);if(t.has(o))return;t.add(o);let s=n?.(e),c={type:`error`,errorText:s??formatFailureMessage(e)};if(s!==void 0)return c;let l=formatFailureDetail(e);return l!==void 0&&(c.detail=l),c}function isQuestionRequest(e){return e.display===`select`||e.display===`text`?!0:e.display===`confirmation`?!1:e.options!==void 0&&e.options.length>0}function toAgentTUIInputQuestion(e){let t=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,n={requestId:e.requestId,prompt:e.prompt,display:t};return e.options!==void 0&&(n.options=e.options.map(e=>{let t={id:e.id,label:e.label};return e.description!==void 0&&(t.description=e.description),e.style!==void 0&&(t.style=e.style),t})),e.allowFreeform!==void 0&&(n.allowFreeform=e.allowFreeform),n}function openCurrentSubagentSection(e){e.currentSectionKey===null&&(e.currentSectionKey=e.nextSectionKey++,e.steps.set(e.currentSectionKey,{reasoning:``,message:``,finalized:!1}));let t=e.steps.get(e.currentSectionKey);if(!t)throw Error(`invariant: subagent section state missing for current key`);return{key:e.currentSectionKey,step:t}}export{EveTUIRunner,parsePromptCommand};
|
|
1
|
+
import{pickAgentHeaderTip}from"./agent-header.js";import{formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{failureKey,formatFailureDetail,formatFailureMessage,formatGatewayAuthFailureNotice,isAbortLikeError,isGatewayAuthFailure,isInterruptedError}from"./errors.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{BOOT_DETECTIONS,detectSetupIssues,formatSetupIssuesLine}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import{toErrorMessage}from"#shared/errors.js";import{isCurrentTurnBoundaryEvent}from"#client/index.js";import{subscribeDevelopmentSandboxPrewarmLogs}from"#execution/sandbox/development-prewarm.js";import{createDevelopmentRuntimeArtifactSessionRefresher}from"#services/dev-client.js";var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v=pickAgentHeaderTip();#y;#b=new Map;#x=new Map;#S=new Map;#C=new Map;#w=new Set;#T=!1;#E;constructor(e){if(this.#e=e.session,e.client!==void 0&&(this.#t=e.client),this.#n=createRenderer(e),this.#r=e.name??`Eve`,this.#i=e.tools??`full`,this.#a=e.reasoning??`full`,this.#o=e.subagents??`full`,this.#s=e.connectionAuth??`full`,this.#c=e.assistantResponseStats??`tokensPerSecond`,this.#l=e.contextSize,this.#u=e.formatTransportError??toErrorMessage,e.initialInput!==void 0&&(this.#m=e.initialInput),e.appRoot!==void 0){this.#p=e.appRoot;let t={appRoot:e.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};e.detectProjectIdentity!==void 0&&(t.detectIdentity=e.detectProjectIdentity),this.#_=createVercelStatusTracker(t)}e.promptCommandHandler!==void 0&&(this.#h=e.promptCommandHandler),this.#g=e.bootDetections??BOOT_DETECTIONS,e.serverUrl!==void 0&&(this.#f=e.serverUrl,this.#d=createDevelopmentRuntimeArtifactSessionRefresher({serverUrl:e.serverUrl}))}async#D(){let e=this.#f;if(e===void 0){await this.#M(void 0);return}let t;try{t=await this.#t?.info()}catch{t=void 0}this.#y=t;let n={name:this.#r,serverUrl:e};t!==void 0&&(n.info=t),this.#p!==void 0&&(n.tip=this.#v),this.#n.renderAgentHeader?.(n),await this.#M(t)}async run(){try{await this.#O()}finally{this.#E?.(),this.#E=void 0,this.#n.shutdown?.(),this.#_?.dispose()}}async#O(){let e=this.#r,r,i,a=!1,o=!1,s=this.#m;for(await this.#D(),this.#N(),this.#_?.refreshIdentity();;){if(!o){if(r==null){if(!this.#n.readPrompt){if(a)return;throw Error(`No prompt was provided and the renderer does not support prompt input.`)}let t={title:e};s!==void 0&&(t.initialDraft=s,s=void 0);try{r=await this.#A(t)}catch(e){if(isInterruptedError(e))return;throw e}if(r==null)return}let c=parsePromptCommand(r);if(c?.type===`exit`)return;if(c?.type===`new`){this.#k(),i=void 0,o=!1,r=void 0,this.#n.reset?.();continue}if(c?.type===`help`){this.#P(formatPromptCommandHelp()),i=void 0,o=!1,r=void 0;continue}if(c?.type===`loglevel`){this.#P(this.#F(c.argument)),i=void 0,o=!1,r=void 0;continue}if(c?.type===`extension`){try{let t=this.#h===void 0?{message:`/${c.name} is not available in this session.`}:await this.#h.handle(c,{renderer:this.#n,title:e});t?.message!==void 0&&this.#P(t.message),t?.vercelEffect!==void 0&&this.#_?.applyEffect(t.vercelEffect)}catch(e){if(isInterruptedError(e))return;throw e}i=void 0,r=void 0,o=!1;continue}a=!0}let c=await this.#j({prompt:o?void 0:r,inputResponses:i});try{await this.#n.renderStream(c,{title:e,submittedPrompt:r,continueSession:!!this.#n.readPrompt,tools:this.#i,reasoning:this.#a,subagents:this.#o,connectionAuth:this.#s,assistantResponseStats:this.#c,contextSize:this.#l});let t=c.turnState?.pendingApprovals??[],n=c.turnState?.pendingQuestions??[];if(t.length>0||n.length>0){let a=[];if(t.length>0){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);for(let n of t){let t=await this.#n.readToolApproval(n,{title:e});a.push({requestId:n.approvalId,optionId:t.approved?`approve`:`deny`}),this.#b.delete(n.approvalId)}}if(n.length>0){if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);for(let t of n){let n=toAgentTUIInputQuestion(t),r=await this.#n.readInputQuestion(n,{title:e});if(r===void 0)continue;let i={requestId:t.requestId};r.optionId!==void 0&&(i.optionId=r.optionId),r.text!==void 0&&(i.text=r.text),a.push(i),this.#b.delete(t.requestId)}}o=!0,i=a,r=void 0;continue}c.turnState&&c.turnState.boundaryEvent===void 0&&(this.#T=!0)}catch(e){if(isInterruptedError(e))return;throw e}o=!1,i=void 0,r=void 0,this.#T&&(this.#T=!1,this.#k(),this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`))}}#k(){for(let e of this.#S.values())e.abort();this.#S.clear(),this.#x.clear(),this.#b.clear(),this.#C.clear(),this.#w.clear(),this.#t&&(this.#e=this.#t.session()),this.#d?.clear()}async#A(e){if(!this.#n.readPrompt)return;let t=this.#n.readPrompt(e),n=this.#t,r=this.#d;if(n===void 0||r===void 0)return await t;let i=!1,a=!1,o,refresh=async()=>{if(!(i||a)){a=!0;try{this.#e=await r.refreshIdle({createSession:()=>n.session(),onRuntimeArtifactsChanged:()=>this.#I(),session:this.#e})}finally{a=!1}}},startRefresh=()=>{if(i||a)return;let e=refresh().finally(()=>{o===e&&(o=void 0)});o=e};startRefresh();let s=setInterval(()=>{startRefresh()},500);s.unref?.();try{return await t}finally{i=!0,clearInterval(s),await o}}async#j(e){let t=new AbortController,n={signal:t.signal};e.prompt!==void 0&&(n.message=e.prompt),e.inputResponses!==void 0&&e.inputResponses.length>0&&(n.inputResponses=e.inputResponses);let r;try{let e=this.#t;e!==void 0&&this.#d!==void 0&&(this.#e=await this.#d.refresh({createSession:()=>e.session(),inputResponses:n.inputResponses,message:n.message,onRuntimeArtifactsChanged:()=>this.#I(),session:this.#e})),n.message!==void 0&&(n.inputResponses?.length??0)===0&&this.#n.flushDelayedDevBuildErrors?.(),r=await this.#e.send(n)}catch(e){if(isInterruptedError(e))throw e;return this.#T=!0,{events:errorOnlyTUIStream({errorText:this.#u(e)}),turnState:createTurnState()}}let i=createTurnState();return{abort:()=>t.abort(),events:eveEventsToTUIStream({events:r,pendingInputRequests:this.#b,subagentRuns:this.#x,turnState:i,onSubagentCalled:e=>this.#B(e),onSubagentCompleted:e=>this.#H(e),onConnectionAuthRequired:e=>this.#L(e),onConnectionAuthCompleted:e=>this.#R(e),onTerminalFailure:()=>{this.#T=!0},failureOverride:this.#p===void 0?void 0:e=>isGatewayAuthFailure(e)?formatGatewayAuthFailureNotice(e):void 0}),turnState:i}}async#M(e){if(this.#p===void 0||this.#n.renderSetupWarning===void 0)return;let t={appRoot:this.#p,env:process.env};e!==void 0&&(t.info=e);let n=await detectSetupIssues(t,this.#g);n.length!==0&&this.#n.renderSetupWarning(formatSetupIssuesLine(n))}#N(){this.#p===void 0||this.#n.renderSandboxLog===void 0||this.#E===void 0&&(this.#E=subscribeDevelopmentSandboxPrewarmLogs({appRoot:this.#p,log:e=>this.#n.renderSandboxLog?.(e)}))}#P(e){if(this.#n.renderCommandResult!==void 0){this.#n.renderCommandResult(e);return}this.#n.renderNotice?.(e)}#F(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel all|stderr|sandbox|none — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use all, stderr, sandbox, or none.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`stderr`:return`Showing stderr logs only.`;case`sandbox`:return`Showing sandbox logs only.`;case`all`:return`Showing all logs.`}}async#I(){let e=this.#y,t;try{t=await this.#t?.info()}catch{t=void 0}if(t!==void 0&&(this.#y=t,this.#f!==void 0)){let e={info:t,name:this.#r,serverUrl:this.#f};this.#p!==void 0&&(e.tip=this.#v),this.#n.renderAgentHeader?.(e)}(!this.#n.renderAgentHeader||t===void 0)&&this.#n.renderNotice?.(formatAgentUpdateNotice(e,t))}#L(e){let t={name:e.data.name,description:e.data.description,state:`required`};e.data.authorization!==void 0&&(t.challenge=e.data.authorization),e.data.webhookUrl!==void 0&&(t.webhookUrl=e.data.webhookUrl),this.#C.set(e.data.name,t),this.#z(t)}#R(e){let t=this.#C.get(e.data.name)??{name:e.data.name,description:``,state:e.data.outcome};t.state=e.data.outcome,e.data.reason!==void 0&&(t.reason=e.data.reason),this.#C.set(e.data.name,t),this.#w.delete(e.data.name),this.#z(t),this.#n.setConnectionAuthPendingCount?.(this.#w.size)}#z(e){let t={name:e.name,description:e.description,state:e.state};e.challenge!==void 0&&(t.challenge=e.challenge),e.reason!==void 0&&(t.reason=e.reason),this.#n.upsertConnectionAuth?.(t)}#B(e){let t=e.data.callId;if(this.#S.has(t))return;let n=this.#t;if(!n)return;let r=new AbortController;this.#S.set(t,r),(async()=>{try{let i=n.session({sessionId:e.data.childSessionId,streamIndex:0}).stream({signal:r.signal});for await(let e of i)if(r.signal.aborted||(this.#U(t,e),isCurrentTurnBoundaryEvent(e)))break}catch(e){if(!isAbortLikeError(e)){let n=toErrorMessage(e),r=this.#x.get(t);if(r){let{key:e,step:i}=openCurrentSubagentSection(r);i.message=i.message?`${i.message}\n\nstream error: ${n}`:`stream error: ${n}`,i.finalized=!0,r.currentSectionKey=null,this.#n.upsertSubagentStep?.({callId:t,subagentName:r.name,sectionKey:e,reasoning:i.reasoning,message:i.message,finalized:!0})}}}finally{this.#S.delete(t)}})()}#V(e,t,n){let r=t.tools.get(n.childCallId),i=r??{toolName:n.toolName,input:n.input,status:n.status};if(r){let e={"approval-requested":0,executing:1,done:2,failed:2};e[n.status]>e[r.status]&&(r.status=n.status),r.input=n.input}else t.tools.set(n.childCallId,i);this.#n.markChildToolCallId?.(n.childCallId),this.#n.upsertSubagentTool?.({callId:e,subagentName:t.name,childCallId:n.childCallId,toolName:i.toolName,input:i.input,status:i.status})}#H(e){let t=this.#x.get(e);if(t){for(let[n,r]of t.steps)r.finalized||(r.finalized=!0,this.#n.upsertSubagentStep?.({callId:e,subagentName:t.name,sectionKey:n,reasoning:r.reasoning,message:r.message,finalized:!0}));t.currentSectionKey=null}}#U(e,t){let n=this.#x.get(e);if(!n)return;let r=this.#n,emit=(t,i)=>{r.upsertSubagentStep?.({callId:e,subagentName:n.name,sectionKey:t,reasoning:i.reasoning,message:i.message,finalized:i.finalized})},finalizeCurrent=()=>{if(n.currentSectionKey===null)return;let e=n.steps.get(n.currentSectionKey);e&&(e.finalized=!0,emit(n.currentSectionKey,e)),n.currentSectionKey=null};switch(t.type){case`reasoning.appended`:{let{key:e,step:r}=openCurrentSubagentSection(n);r.reasoning+=t.data.reasoningDelta,emit(e,r);break}case`reasoning.completed`:break;case`message.appended`:{let{key:e,step:r}=openCurrentSubagentSection(n);r.message+=t.data.messageDelta,emit(e,r);break}case`message.completed`:{let{key:e,step:r}=openCurrentSubagentSection(n);t.data.message!==null&&r.message.length===0&&(r.message=t.data.message),r.finalized=!0,emit(e,r),n.currentSectionKey=null;break}case`step.completed`:finalizeCurrent();break;case`actions.requested`:finalizeCurrent();for(let r of t.data.actions)r.kind===`tool-call`&&this.#V(e,n,{childCallId:r.callId,toolName:r.toolName,input:r.input,status:`executing`});break;case`input.requested`:finalizeCurrent();for(let r of t.data.requests)r.action.kind===`tool-call`&&this.#V(e,n,{childCallId:r.action.callId,toolName:r.action.toolName,input:r.action.input,status:`approval-requested`});break;case`action.result`:{let i=t.data.result;if(i.kind!==`tool-result`)break;let a=n.tools.get(i.callId);if(!a)break;t.data.status===`failed`?(a.status=`failed`,a.errorText=formatActionResultError(t)):(a.status=`done`,a.output=i.output);let o={callId:e,subagentName:n.name,childCallId:i.callId,toolName:a.toolName,input:a.input,status:a.status};a.output!==void 0&&(o.output=a.output),a.errorText!==void 0&&(o.errorText=a.errorText),r.upsertSubagentTool?.(o);break}default:break}}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,input:e.userInput,output:e.screen})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}async function*eveEventsToTUIStream(e){let{events:t,pendingInputRequests:n,subagentRuns:r,turnState:i,onSubagentCalled:a,onSubagentCompleted:o,onConnectionAuthRequired:s,onConnectionAuthCompleted:c,onTerminalFailure:l,failureOverride:u}=e,d=new Map,f=new Map,p=0,m=new Set,h=new Set,g=new Set,_=new Set,v=!1,y=!1,b;for await(let e of t)if(!(y&&isPostTurnVisibleEvent(e)))switch(e.type){case`session.started`:case`turn.started`:case`message.received`:break;case`step.started`:p+=1,yield{type:`step-start`};break;case`step.completed`:{let t=e;b=t.data.usage,yield*closeOpenParts(d,`assistant-complete`,p),yield*closeOpenParts(f,`reasoning-complete`,p),yield{type:`step-finish`,usage:t.data.usage};break}case`message.appended`:{let t=e,n=textPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(d,n),i=t.data.messageSoFar;if(r.completed){if(r.text.startsWith(i)||p<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}if(!i.startsWith(r.text)||i.length<=r.text.length)break;let a=i.slice(r.text.length);r.text=i,yield{type:`assistant-delta`,id:partGenerationId(n,r.generation),delta:a};break}case`message.completed`:{let t=textPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(d,t),r=e.data.message;if(n.completed){if(r===null||r===n.text||p<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=p,yield{type:`assistant-complete`,id:partGenerationId(t,n.generation),text:r};break}let i=partGenerationId(t,n.generation);if(r!==null){if(n.text.length===0)n.text=r,n.completed=!0,n.completedEpoch=p,yield{type:`assistant-complete`,id:i,text:r};else if(r.startsWith(n.text)){let e=r.slice(n.text.length);e.length>0&&(yield{type:`assistant-delta`,id:i,delta:e}),n.text=r,n.completed=!0,n.completedEpoch=p,yield{type:`assistant-complete`,id:i}}}else n.text.length>0&&(n.completed=!0,n.completedEpoch=p,yield{type:`assistant-complete`,id:i});break}case`reasoning.appended`:{let t=e,n=reasoningPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(f,n),i=t.data.reasoningSoFar;if(r.completed){if(r.text.startsWith(i)||p<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}if(!i.startsWith(r.text)||i.length<=r.text.length)break;let a=i.slice(r.text.length);r.text=i,yield{type:`reasoning-delta`,id:partGenerationId(n,r.generation),delta:a};break}case`reasoning.completed`:{let t=reasoningPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(f,t),r=e.data.reasoning;if(n.completed){if(r.length===0||r===n.text||n.text.startsWith(r)||p<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=p;let e=partGenerationId(t,n.generation);yield{type:`reasoning-delta`,id:e,delta:r},yield{type:`reasoning-complete`,id:e};break}let i=partGenerationId(t,n.generation);if(n.text.length===0&&r.length>0)n.text=r,yield{type:`reasoning-delta`,id:i,delta:r};else if(r.length>0&&!r.startsWith(n.text))break;n.completed=!0,n.completedEpoch=p,yield{type:`reasoning-complete`,id:i};break}case`actions.requested`:{let t=e.data,n=t.actions.filter(e=>e.kind===`tool-call`);if(n.length===0)break;let r=toolBatchKey(`actions.requested`,t.turnId,t.stepIndex,n);if(g.has(r)){for(let e of n)m.has(e.callId)||h.add(e.callId);break}g.add(r);for(let e of n)m.has(e.callId)||(m.add(e.callId),yield{type:`tool-call`,toolCallId:e.callId,toolName:e.toolName,input:e.input});break}case`input.requested`:{let t=e.data,r=t.requests.filter(e=>e.action.kind===`tool-call`);if(r.length===0)break;let a=inputRequestBatchKey(t.turnId,t.stepIndex,r);if(g.has(a)){for(let e of r)m.has(e.action.callId)||h.add(e.action.callId);break}g.add(a);for(let e of r){let t=e.action.callId;if(m.has(t)||(m.add(t),yield{type:`tool-call`,toolCallId:t,toolName:e.action.toolName,input:e.action.input}),n.set(e.requestId,e),isQuestionRequest(e)){upsertPendingQuestion(i,e);continue}upsertPendingApproval(i,e),yield{type:`tool-approval-request`,approvalId:e.requestId,toolCallId:t}}break}case`action.result`:{let t=e;if(t.data.result.kind!==`tool-result`)break;let n=t.data.result.callId;if(h.has(n)||!m.has(n))break;t.data.status===`failed`?yield{type:`tool-error`,toolCallId:n,errorText:formatActionResultError(t)}:yield{type:`tool-result`,toolCallId:n,output:t.data.result.output};break}case`step.failed`:case`turn.failed`:{let t=toFailureEvent(e,_,u);t&&(yield t);break}case`session.failed`:{i.sawSessionFailure=!0,l?.(e);let t=toFailureEvent(e,_,u);t&&(yield t),i.boundaryEvent=e.type,yield*closeOpenParts(d,`assistant-complete`,p),yield*closeOpenParts(f,`reasoning-complete`,p),yield{type:`finish`,usage:b},v=!0;return}case`session.waiting`:case`session.completed`:i.boundaryEvent=e.type,yield*closeOpenParts(d,`assistant-complete`,p),yield*closeOpenParts(f,`reasoning-complete`,p),yield{type:`finish`,usage:b},v=!0;return;case`turn.completed`:y=!0,yield*closeOpenParts(d,`assistant-complete`,p),yield*closeOpenParts(f,`reasoning-complete`,p);break;case`subagent.called`:{let t=e;if(!r.has(t.data.callId))r.set(t.data.callId,{name:t.data.name,steps:new Map,currentSectionKey:null,nextSectionKey:0,tools:new Map});else{let e=r.get(t.data.callId);e&&(e.name=t.data.name)}a?.(t);break}case`subagent.started`:case`subagent.event`:break;case`subagent.completed`:o?.(e.data.callId);break;case`authorization.required`:s?.(e);break;case`authorization.completed`:c?.(e);break;default:break}v||(yield*closeOpenParts(d,`assistant-complete`,p),yield*closeOpenParts(f,`reasoning-complete`,p),yield{type:`finish`,usage:b})}async function*errorOnlyTUIStream(e){yield{type:`error`,errorText:e.errorText},yield{type:`finish`}}function createTurnState(){return{pendingApprovals:[],pendingQuestions:[],sawSessionFailure:!1}}function upsertPendingApproval(e,t){let n=toAgentTUIToolApprovalRequest(t),r=e.pendingApprovals.findIndex(e=>e.approvalId===n.approvalId);r===-1?e.pendingApprovals.push(n):e.pendingApprovals[r]=n}function toAgentTUIToolApprovalRequest(e){return{approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,input:e.action.input}}function upsertPendingQuestion(e,t){let n=e.pendingQuestions.findIndex(e=>e.requestId===t.requestId);n===-1?e.pendingQuestions.push(t):e.pendingQuestions[n]=t}function textPartId(e,t){return`text:${e}:${t}`}function reasoningPartId(e,t){return`reasoning:${e}:${t}`}function partStateFor(e,t){let n=e.get(t);return n===void 0&&(n={generation:0,text:``,completed:!1,completedEpoch:0},e.set(t,n)),n}function partGenerationId(e,t){return t===0?e:`${e}#${t}`}function*closeOpenParts(e,t,n){for(let[r,i]of e)i.completed||i.text.length===0||(i.completed=!0,i.completedEpoch=n,yield{type:t,id:partGenerationId(r,i.generation)})}function isPostTurnVisibleEvent(e){switch(e.type){case`actions.requested`:case`authorization.completed`:case`authorization.required`:case`input.requested`:case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:case`result.completed`:case`step.completed`:case`step.failed`:case`step.started`:case`subagent.called`:case`subagent.completed`:case`subagent.event`:case`subagent.started`:case`turn.completed`:case`turn.failed`:return!0;default:return!1}}function toolBatchKey(e,t,n,r){return`${e}:${t}:${String(n)}:${stableStringify(r.map(e=>({input:e.input,toolName:e.toolName})))}`}function inputRequestBatchKey(e,t,n){return toolBatchKey(`input.requested`,e,t,n.map(e=>({input:e.action.input,toolName:e.action.toolName})))}function stableStringify(e){return JSON.stringify(toStableJson(e))??`undefined`}function toStableJson(e,t=new WeakSet){if(typeof e!=`object`||!e)return e;if(t.has(e))return`[Circular]`;if(t.add(e),Array.isArray(e))return e.map(e=>toStableJson(e,t));let n=e,r={};for(let e of Object.keys(n).sort())r[e]=toStableJson(n[e],t);return r}function formatActionResultError(e){if(e.data.error?.message)return e.data.error.message;let t=e.data.result.output;if(typeof t==`string`)return t;try{return JSON.stringify(t)}catch{return`Tool execution failed.`}}function toFailureEvent(e,t,n){let o=failureKey(e);if(t.has(o))return;t.add(o);let s=n?.(e),c={type:`error`,errorText:s??formatFailureMessage(e)};if(s!==void 0)return c;let l=formatFailureDetail(e);return l!==void 0&&(c.detail=l),c}function isQuestionRequest(e){return e.display===`select`||e.display===`text`?!0:e.display===`confirmation`?!1:e.options!==void 0&&e.options.length>0}function toAgentTUIInputQuestion(e){let t=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,n={requestId:e.requestId,prompt:e.prompt,display:t};return e.options!==void 0&&(n.options=e.options.map(e=>{let t={id:e.id,label:e.label};return e.description!==void 0&&(t.description=e.description),e.style!==void 0&&(t.style=e.style),t})),e.allowFreeform!==void 0&&(n.allowFreeform=e.allowFreeform),n}function openCurrentSubagentSection(e){e.currentSectionKey===null&&(e.currentSectionKey=e.nextSectionKey++,e.steps.set(e.currentSectionKey,{reasoning:``,message:``,finalized:!1}));let t=e.steps.get(e.currentSectionKey);if(!t)throw Error(`invariant: subagent section state missing for current key`);return{key:e.currentSectionKey,step:t}}export{EveTUIRunner,parsePromptCommand};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import{sliceVisible,stripAnsi,stripTerminalControls,visibleLength}from"./terminal-text.js";import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{buildAgentHeader}from"./agent-header.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderBlockLines}from"./blocks.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{interruptedError}from"./errors.js";import{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,lineOf,visibleLine}from"./line-editor.js";import{LiveRegion}from"./live-region.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{renderAcknowledgeQuestion,renderFlowPanel,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{reduceSetupSelectInput,setupSelectionIntent}from"./setup-selection-input.js";import{formatAssistantResponseStats,formatTokenFlow,nextKey,stripPromptControlCharacters,takeUntil}from"./stream-format.js";import{toErrorMessage}from"#shared/errors.js";import{initialSelectState,reduceSelect,selectValueAtCursor}from"#setup/cli/select-state.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";function isMultiSelectRequest(e){return e.kind===`multi`||e.kind===`searchable-multi`}function moveActionCursor(e,t,n){return n===0?void 0:e===void 0?t===`down`?0:n-1:(e+(t===`down`?1:-1)+n)%n}function completedTurnStatus(e,t){return e?`Interrupted`:t?`Ready`:`Done`}const STATUS={processing:`Working…`,toolResults:`Reading results…`,streaming:`Responding…`,executingTools:`Running tools…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f=[];#p=new Map;#m=new Set;#h=[];#g=new Set;#_=new Map;#v=new Set;#y;#b=!1;#x;#S=[];#C;#w=0;#T;#E=``;#D=0;#O=new PromptHistory;#k=!1;#A;#j=!1;#M=STATUS.processing;#N=`Eve`;#P=!1;#F=!1;#I=!0;#L=0;#R;#z;#B;#V=!1;#H;#U=``;#W;#G;#K;#q=!1;#J=!1;#Y;#X;#Z;#Q;#$;#ee;#te;#ne=``;#re=``;#ie;#ae=0;#
|
|
2
|
-
`);if(this.#b){t!==this.#x&&(this.#x=t,this.#
|
|
3
|
-
`),live:!1}),this.#He({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#rt()}}async#me(e){let t=this.#ye(),n=isMultiSelectRequest(e),r={options:e.options,submitRow:n};`initialValue`in e&&e.initialValue!==void 0&&(r.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(r.initialValues=e.initialValues);let i=initialSelectState(r),a,o=e.notices;if(e.kind===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));o=[...e.notices??[],...r],t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,select:i};return o!==void 0&&o.length>0&&(t.notices=o),a!==void 0&&(t.error=a),t};return t.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#rt(),await this.#Se((t,r)=>{let o={key:t,options:e.options,select:i},s=reduceSetupSelectInput(n?{...o,kind:e.kind,required:e.required}:{...o,kind:e.kind});switch(s.kind){case`cancel`:r(void 0);return;case`repaint`:this.#rt();return;case`update`:i=s.select,a=void 0,this.#rt();return;case`submit`:r(s.values);return;case`error`:a=s.message,this.#rt();return;case`ignore`:return}}).promise}#he(e){this.#ke();let t=this.#be();t.status=e.status;let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#r,t),this.#rt();let r=this.#Se((t,r)=>{let i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#rt();return;case`repaint`:this.#rt();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#ge(e){let t=this.#ye(),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`editable`,message:e.message,options:e.options,select:r,edit:{optionValue:e.editable.value,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint,caretVisible:this.#I}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#r,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?(i.text.length===0&&(i=lineOf(e.editable.defaultValue)),this.#Le()):(i=lineOf(``),this.#Re())};return syncEditableRow(),this.#rt(),await this.#Se((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#ze(),this.#rt()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#rt()},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.#rt();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t);switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#rt();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Re()).promise}async#_e(e){let t=this.#ye(),n=lineOf(``),r;return t.question=t=>{let i={message:e.message,editor:n,mask:e.mask===!0};return e.placeholder!==void 0&&(i.placeholder=e.placeholder),e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#r,t,this.#I)},this.#Le(),this.#rt(),await this.#Se((t,i)=>{let apply=e=>{n=e,r=void 0,this.#ze(),this.#rt()},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.#rt();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#rt();return}i(t);return}default:return}},()=>this.#Re()).promise}async#ve(e){let t=this.#ye();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#rt(),await this.#Se((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#rt();return;default:return}}).promise}#ye(){return this.#ke(),this.#k=!1,this.#j=!1,this.#M=``,this.#be()}#be(){return this.#se===void 0&&(this.#se={title:``,lines:[],outputBuffer:[]}),this.#se}#xe(){this.#se!==void 0&&(this.#se.question=void 0,this.#se.hideLinesWhileQuestion=!1),this.#H=void 0,this.#Me(),this.#we(),this.#rt()}#Se(e,t){let n=!1,r,i=new Promise(e=>{r=e}),settle=e=>{n||(n=!0,t?.(),this.#xe(),r(e))};return this.#H=t=>e(t,settle),this.#je(),{promise:i,settle}}#Ce(){let e,t=new Promise(t=>{e=t});return this.#ce=e,this.#we(),{promise:t,dispose:()=>{this.#ce===e&&(this.#ce=void 0,this.#Te())}}}#we(){if(this.#ce===void 0)return;let consumer=e=>{if(e.type===`ctrl-c`||e.type===`escape`){let e=this.#ce;this.#ce=void 0,this.#Te(),e?.();return}e.type===`ctrl-r`&&this.#rt()};this.#le=consumer,this.#H=consumer,this.#je()}#Te(){this.#le!==void 0&&(this.#H===this.#le&&this.#Me(),this.#le=void 0)}#Ee(e){let t=e===void 0?void 0:stripTerminalControls(e);if(this.#se!==void 0){this.#se.status=t,t===void 0&&(this.#se.preview=void 0),this.#rt();return}if(t===void 0){this.#j=!1,this.#M=``,this.#Ve(),this.#rt();return}this.#ke(),this.#j=!0,this.#M=t,this.#Be(),this.#rt()}#De(e,t){let r=stripTerminalControls(e);if(r.trim().length===0)return;let i=this.#se;if(i!==void 0){if(i.preview=void 0,t===`warning`||t===`error`)for(let e of i.outputBuffer)i.lines.push({text:e,tone:`info`,evidence:!0});i.outputBuffer=[],i.lines.push({text:r,tone:t}),this.#rt();return}this.#ke(),this.#He({kind:`flow`,title:t,body:r,live:!1}),this.#rt()}#Oe(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let r=this.#se;if(r===void 0){this.#De(t,`info`);return}r.preview=t,r.outputBuffer.push(t),r.outputBuffer.length>40&&r.outputBuffer.shift(),this.#rt()}shutdown(){this.#Ae()}#ke(e){this.#N=e?.title??this.#N,this.#Z=e?.contextSize??this.#l,!this.#P&&(this.#P=!0,this.#n.reset(),this.#n.hideCursor(),this.#gt(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume()),this.#G=()=>this.#rt(),this.#t.on(`resize`,this.#G))}#Ae(){this.#Me(),this.#Re(),this.#Ve(),this.#B!==void 0&&(clearTimeout(this.#B),this.#B=void 0),this.#V=!1,this.#P&&=(this.#St(),this.#rt(),this.#n.clear(),this.#n.showCursor(),this.#_t(),this.#n.newline(),this.#e.isTTY&&(this.#e.setRawMode?.(!1),this.#e.pause()),this.#G&&=(this.#t.off(`resize`,this.#G),void 0),!1)}#je(){this.#e.off(`data`,this.#Ne),this.#e.on(`data`,this.#Ne)}#Me(){this.#e.off(`data`,this.#Ne),this.#Fe(),this.#U=``,this.#H=void 0}#Ne=e=>{this.#Fe(),this.#U+=e.toString(`utf8`),this.#Pe(),this.#U===`\x1B`&&(this.#W=setTimeout(()=>{this.#U===`\x1B`&&(this.#U=``,this.#H?.({type:`escape`}))},30),this.#W.unref?.())};#Pe(){for(;this.#U.length>0;){let e=nextKey(this.#U);if(e.incomplete)return;this.#U=this.#U.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#H?.(e.key)}}#Fe(){this.#W&&=(clearTimeout(this.#W),void 0)}#Ie(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#rt();break;case`ctrl-c`:this.#F=!0,this.#K?.();break;default:break}}#Le(){this.#Re(),this.#ze(),this.#R=setInterval(()=>{this.#I=!this.#I,this.#rt()},500),this.#R.unref?.()}#Re(){this.#R&&=(clearInterval(this.#R),void 0),this.#I=!0}#ze(){this.#I=!0}#Be(){this.#Ve(),this.#z=setInterval(()=>{this.#L+=1,this.#rt()},90),this.#z.unref?.()}#Ve(){this.#z&&=(clearInterval(this.#z),void 0)}#He(e){e.id!==this.#ie?.id&&this.#St(),this.#f.push(e),e.id&&this.#p.set(e.id,e)}#Ue(e){this.#He({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#rt()}#We(e){if(e!=null){if(this.#oe===e){this.#oe=void 0;return}this.#He({kind:`user`,body:stripTerminalControls(e),live:!1})}}#Ge(e,t,r){let i={kind:`error`,title:stripTerminalControls(e),body:stripTerminalControls(t),live:!1};r!==void 0&&(i.detail=stripTerminalControls(r)),this.#He(i),this.#rt()}#Ke(e,t){this.#v.has(e)||(this.#v.add(e),this.#He({id:subagentHeaderId(e),kind:`subagent`,title:stripTerminalControls(t),live:!1}))}#qe(e){if(e.id&&this.#m.has(e.id))return;let t=e.id?this.#p.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#He(e)}#Je(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#Ye(){for(let e of this.#f)e.status===`approval`||e.status===`running`||(e.live=!1)}#Xe(e,t,r){switch(e.type){case`step-start`:this.#Ze(r.hasPendingToolResults?STATUS.toolResults:STATUS.processing),r.hasPendingToolResults=!1;break;case`step-finish`:this.#nt(e.usage),this.#rt();break;case`assistant-delta`:{this.#Ze(STATUS.streaming);let t=(r.text.get(e.id)??``)+stripTerminalControls(e.delta);r.text.set(e.id,t),this.#Qe(e.id,t,!0);break}case`assistant-complete`:{let t=r.text.get(e.id)??``,i=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;r.text.set(e.id,i),this.#Qe(e.id,i,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#Ze(STATUS.streaming);let i=(r.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);r.reasoning.set(e.id,i),this.#$e(e.id,i,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let n=r.reasoning.get(e.id)??``;this.#$e(e.id,n,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#Ze(STATUS.executingTools),this.#et({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,r);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;this.#et({...n,status:`approval`},t,r);break}case`tool-result`:{if(t.tools===`hidden`)break;let n=this.#tt(e.toolCallId,r);if(n===void 0)break;r.hasPendingToolResults=!0,this.#Ze(STATUS.toolResults),this.#et({...n,output:e.output,status:`done`},t,r);break}case`tool-error`:{if(t.tools===`hidden`)break;let n=this.#tt(e.toolCallId,r);if(n===void 0)break;r.hasPendingToolResults=!0,this.#Ze(STATUS.toolResults),this.#et({...n,errorText:e.errorText,status:`error`},t,r);break}case`error`:this.#Ge(`Error`,e.errorText,e.detail);break;case`finish`:this.#nt(e.usage),this.#rt();break}}#Ze(e){let t=this.#w>0?STATUS.connectionAuth:e;this.#M!==t&&(this.#M=t,this.#rt())}#Qe(e,t,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#qe({id:e,kind:`assistant`,body:i,live:r}),this.#rt())}#$e(e,t,r,i){let a=stripTerminalControls(t).trim();a.length!==0&&(this.#qe({id:e,kind:`reasoning`,body:a,collapsed:collapseReasoning(i.reasoning,r),live:r}),this.#rt())}#et(e,t,n){if(n.tools.set(e.toolCallId,e),this.#g.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#_.set(e.toolCallId,r),this.#qe(renderNativeToolBlock(e,r,t.tools===`full`)),this.#rt()}#tt(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#_.get(e)??toolSectionId(e),i=this.#p.get(r);if(!(i===void 0||i.kind!==`tool`))return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.title??`tool`}}#nt(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#Y=(t??0)+(n??0)),this.#X=t??this.#X,this.#Q=n??this.#Q,this.#Q!=null&&this.#ee!==void 0){let e=(Date.now()-this.#ee)/1e3;e>0&&(this.#$=this.#Q/e)}}#rt(){if(this.#P){if(this.#q){this.#J=!0;return}this.#q=!0;try{do this.#J=!1,this.#it();while(this.#J)}finally{this.#q=!1}}}#it(){if(!this.#P)return;let e=this.#mt(),t=this.#dt(e),n=Math.max(1,this.#ht()-t.length),r=[],i=this.#C;for(;this.#f.length>0&&this.#f[0].live===!1;){let t=this.#f.shift();if(this.#h.push(t),t.id&&(this.#m.add(t.id),this.#p.delete(t.id)),this.#wt(t))continue;let n=this.#lt(t,e,i);i=previousBlockOf(t),this.#C=i,r.push(...n),this.#S.push(...n)}let a=[];for(let t of this.#f){if(this.#wt(t))continue;let n=this.#lt(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)a.push({block:t,row:n[e]})}let o=[...clipLiveRows(a.map(e=>e.row),n,e,this.#r),...t];r.length>0?this.#n.flush(r,o):this.#n.update(o)}#at(){if(!this.#P)return;let e=this.#mt(),t=this.#dt(e),n=Math.max(1,this.#ht()-t.length),r=this.#C,i=[];for(let t of this.#f){if(this.#wt(t))continue;let n=this.#lt(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#r),...t];this.#n.clearAll(),this.#n.flush([...this.#ct(),...this.#S],a)}logDisplayMode(){return this.#d}setLogDisplayMode(e){e!==this.#d&&(this.#d=e,this.#st(),this.#P&&this.#at())}#ot(){this.#V=!0,this.#B!==void 0&&clearTimeout(this.#B),this.#B=setTimeout(()=>{this.#V=!1,this.#B=void 0,this.#rt()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#d)),this.#rt()}#st(){let e=this.#mt();this.#S.length=0;let t;for(let n of this.#h){if(this.#wt(n))continue;let r=this.#lt(n,e,t);t=previousBlockOf(n),this.#S.push(...r)}this.#C=t}#ct(){let e=this.#y;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#mt()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#lt(e,t,n){let r={spinner:this.#ut()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#ut(){return this.#r.spinner[this.#L%this.#r.spinner.length]??``}#dt(e){let t=this.#r.colors,n=[``],r=this.#se;if(r!==void 0){let t=this.#ut(),i;if(r.question!==void 0){let n=r.question(e);i={kind:`question`,rows:n},r.status!==void 0&&(i={kind:`question`,rows:n,status:{text:r.status,frame:t}})}else r.status===void 0?i=r.preview===void 0?{kind:`idle`,frame:t}:{kind:`preview`,text:r.preview,frame:t}:(i={kind:`status`,status:{text:r.status,frame:t}},r.preview!==void 0&&(i={kind:`status`,status:{text:r.status,frame:t},preview:r.preview}));let a={title:r.title,lines:r.hideLinesWhileQuestion===!0?[]:r.lines,content:i};return n.push(...renderFlowPanel(a,this.#r,e)),n}if(this.#k){let r=this.#A===void 0?void 0:inlineCommandHint(this.#A);r===void 0&&this.#A!==void 0&&isTypeaheadOpen(this.#A)&&n.push(...renderCommandSuggestions(this.#A,this.#r,e));let i=Math.max(4,e-3),{before:a,after:o}=visibleLine({text:this.#E,cursor:this.#D},i,this.#r.glyph.ellipsis),s=isPromptControlCommand(this.#E),style=e=>s&&e.length>0?t.blue(e):e,l=this.#I?t.cyan(this.#r.glyph.caret):` `,u=r?t.dim(` ${r}`):``,d=`${style(a)}${l}${style(o)}${u}`;return n.push(...promptInputRows(d,e,this.#r,!0)),this.#ft(n,e),n}let i=this.#j?t.yellow(this.#ut()):t.dim(this.#r.glyph.dot),a=this.#M.length>0?this.#M:`Ready`,o=this.#j?t.dim(a):a,s=this.#pt(),l=s?`${i} ${o} ${t.dim(this.#r.glyph.dot)} ${s}`:`${i} ${o}`;return n.push(clip(l,e)),this.#ft(n,e),n}#ft(e,t){let n={theme:this.#r,width:t};this.#V&&(n.logLevel=this.#d);let r=this.#y?.info?.agent.model.id;r!==void 0&&(n.model=r);let i=this.#y?.info?.agent.model.endpoint;i!==void 0&&(n.endpoint=i);let a=this.#X??0,o=this.#Q??0;if(a>0||o>0){let e={inputTokens:a,outputTokens:o};this.#Z!==void 0&&(e.contextSize=this.#Z),n.tokens=formatTokenFlow(e,this.#r.glyph)}this.#T!==void 0&&(n.vercel=this.#T);let s=buildStatusLine(n);s!==void 0&&e.push(s)}#pt(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#Y,outputTokens:this.#Q,tokensPerSecond:this.#$},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#mt(){return Math.max(20,this.#t.columns||80)}#ht(){return Math.max(8,this.#t.rows||24)}#gt(){if(this.#te!==void 0||!this.#u)return;this.#ne=``,this.#re=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#vt(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#te=()=>{e(),t()}}#_t(){let e=this.#te;e!==void 0&&(this.#te=void 0,e(),this.#ne.length>0&&(this.#Ct(`stdout`)&&process.stdout.write(`${this.#ne}\n`),this.#ne=``),this.#re.length>0&&(this.#Ct(`stderr`)&&process.stderr.write(`${this.#re}\n`),this.#re=``))}#vt(e,n){let r=(e===`stdout`?this.#ne:this.#re)+n,i=r.lastIndexOf(`
|
|
4
|
-
`),a=i===-1?r:r.slice(i+1);if(e===`stdout`?this.#ne=a:this.#re=a,i===-1)return;let o=stripAnsi(r.slice(0,i)).replace(/\s+$/u,``);o.trim().length!==0&&(e===`stdout`?this.#
|
|
5
|
-
`);t=[],e.trim().length!==0&&this.#
|
|
6
|
-
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#
|
|
1
|
+
import{sliceVisible,stripAnsi,stripTerminalControls,visibleLength}from"./terminal-text.js";import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{buildAgentHeader}from"./agent-header.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderBlockLines}from"./blocks.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{interruptedError}from"./errors.js";import{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,lineOf,visibleLine}from"./line-editor.js";import{LiveRegion}from"./live-region.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{renderAcknowledgeQuestion,renderFlowPanel,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{reduceSetupSelectInput,setupSelectionIntent}from"./setup-selection-input.js";import{formatAssistantResponseStats,formatTokenFlow,nextKey,stripPromptControlCharacters,takeUntil}from"./stream-format.js";import{toErrorMessage}from"#shared/errors.js";import{initialSelectState,reduceSelect,selectValueAtCursor}from"#setup/cli/select-state.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";function isMultiSelectRequest(e){return e.kind===`multi`||e.kind===`searchable-multi`}function moveActionCursor(e,t,n){return n===0?void 0:e===void 0?t===`down`?0:n-1:(e+(t===`down`?1:-1)+n)%n}function completedTurnStatus(e,t){return e?`Interrupted`:t?`Ready`:`Done`}const STATUS={processing:`Working…`,toolResults:`Reading results…`,streaming:`Responding…`,executingTools:`Running tools…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f=[];#p=new Map;#m=new Set;#h=[];#g=new Set;#_=new Map;#v=new Set;#y;#b=!1;#x;#S=[];#C;#w=0;#T;#E=``;#D=0;#O=new PromptHistory;#k=!1;#A;#j=!1;#M=STATUS.processing;#N=`Eve`;#P=!1;#F=!1;#I=!0;#L=0;#R;#z;#B;#V=!1;#H;#U=``;#W;#G;#K;#q=!1;#J=!1;#Y;#X;#Z;#Q;#$;#ee;#te;#ne=``;#re=``;#ie;#ae;#oe=0;#se;#ce;#le;#ue;setupFlow={begin:e=>this.#pe(e),end:e=>this.#me(e?.preserveDiagnostics??!0),readSelect:e=>this.#he(e),readEditableSelect:e=>this.#_e(e),readText:e=>this.#ve(e),readAcknowledge:e=>this.#ye(e),readChoice:e=>this.#ge(e),setStatus:e=>this.#De(e),renderLine:(e,t)=>this.#Oe(e,t),renderOutput:e=>this.#ke(e),waitForInterrupt:()=>this.#we()};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#i=e?.tools??`auto-collapsed`,this.#a=e?.reasoning??`full`,this.#o=e?.subagents??`auto-collapsed`,this.#s=e?.connectionAuth??`full`,this.#c=e?.assistantResponseStats??`tokensPerSecond`,this.#l=e?.contextSize,this.#Z=e?.contextSize,this.#u=e?.captureForeignOutput??this.#t===process.stdout,this.#d=e?.logs??`none`}renderAgentHeader(e){this.#N=e.name,this.#y=e,this.#Ae();let t=this.#lt().join(`
|
|
2
|
+
`);if(this.#b){t!==this.#x&&(this.#x=t,this.#Ue({kind:`agent-header`,body:t,live:!1})),this.#it();return}this.#b=!0,this.#x=t,this.#n.flush(this.#lt(),[])}async readPrompt(e){this.#Ae(e),this.#k=!0,this.#j=!1,this.#M=``;let t=lineOf(stripPromptControlCharacters(e?.initialDraft??``));return this.#O.begin(t.text),this.#de(t),this.#A=typeaheadFor(PROMPT_COMMANDS,t.text),this.#Re(),this.#it(),await new Promise((e,r)=>{let apply=e=>{t=e,this.#Be(),this.#de(t),this.#A=typeaheadFor(PROMPT_COMMANDS,e.text,this.#A),this.#it()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#A=void 0,this.#ze(),this.#je(),r(interruptedError())},suggestions=()=>this.#A!==void 0&&isTypeaheadOpen(this.#A)?this.#A:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#H=r=>{let i=applyLineEditorKey(t,r);if(i!==void 0){apply(i);return}switch(r.type){case`up`:{let e=suggestions();e===void 0?recall(this.#O.previous(t.text)):(this.#A=moveTypeaheadSelection(e,-1),this.#it());break}case`down`:{let e=suggestions();e===void 0?recall(this.#O.next()):(this.#A=moveTypeaheadSelection(e,1),this.#it());break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#A=dismissTypeahead(e),this.#it());break}case`enter`:{let r=highlighted(),i=r!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(r).trimEnd():t.text;this.#A=void 0,this.#O.add(i),this.#k=!1,this.#ze(),this.#M=STATUS.processing,isPromptControlCommand(i)?this.#Ue({kind:`command`,body:stripTerminalControls(i.trim()),live:!1}):(this.#We(i),this.#se=i),this.#de(EMPTY_LINE),this.#it(),this.#Ne(),e(i);break}case`ctrl-d`:t.text.length===0?interrupt():apply(deleteForward(t));break;case`ctrl-l`:this.#st();break;case`ctrl-r`:this.#it();break;case`ctrl-c`:interrupt();break;default:break}},this.#Me()})}#de(e){this.#E=e.text,this.#D=e.cursor}async renderStream(e,t){this.#Ae(t),this.#m.clear(),this.#k=!1,this.#j=!0,this.#M=STATUS.processing,this.#Ge(t?.submittedPrompt),this.#F=!1,this.#Y=void 0,this.#X=void 0,this.#Q=void 0,this.#$=void 0,this.#ee=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#Ve(),this.#it();let r=new Promise(e=>{this.#K=e});this.#H=e=>this.#Le(e),this.#Me();let i={text:new Map,reasoning:new Map,tools:new Map,hasPendingToolResults:!1};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#F)break;this.#Ze(t,n,i)}}catch(e){this.#Ke(`Error`,toErrorMessage(e))}finally{this.#K=void 0,this.#F&&e.abort?.(),this.#Ne(),this.#He(),this.#j=!1,this.#M=completedTurnStatus(this.#F,t?.continueSession===!0),this.#Xe(),this.#it(),(this.#F||!t?.continueSession)&&this.#je()}if(this.#F)throw interruptedError()}async readToolApproval(e,t){return this.#Ae(t),this.#k=!1,this.#j=!1,this.#M=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#F=!1,this.#it(),await new Promise((t,n)=>{this.#H=r=>{switch(r.type){case`character`:{let n=r.value.toLowerCase();n===`y`?(this.#M=STATUS.processing,this.#Ne(),this.#it(),t({approved:!0})):n===`n`&&(this.#M=STATUS.processing,this.#fe(e.toolCallId),this.#Ne(),this.#it(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#it();break;case`ctrl-c`:this.#F=!0,this.#je(),n(interruptedError());break;default:break}},this.#Me()})}async readInputQuestion(e,t){this.#Ae(t),this.#k=!1,this.#j=!1,this.#F=!1;let r=e.options??[],i=r.length>0,a=(e.allowFreeform===!0||!i)&&i,o=r.length+ +!!a,s=questionSectionId(e.requestId),c=i?`select`:`text`,l=0,u=``,isOnFreeformRow=()=>a&&l===r.length,renderSection=()=>{this.#Je({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,l,this.#r),preformatted:!0,live:!0})},repaintStatus=()=>{if(c===`select`){let e=isOnFreeformRow()?`type`:`select`;this.#M=`↑/↓ move · enter ${e} · Ctrl+C quit`,this.#k=!1}else this.#k=!0,this.#de(lineOf(u)),this.#M=``;this.#it()};renderSection(),c===`text`&&this.#Re(),repaintStatus();let finalize=t=>{this.#Je({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:` ${this.#r.colors.green(this.#r.glyph.success)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#k=!1,this.#M=STATUS.processing,this.#ze(),this.#Ne(),this.#it();let r={};return t.optionId!==void 0&&(r.optionId=t.optionId),t.text!==void 0&&(r.text=t.text),r};return await new Promise((t,n)=>{this.#H=a=>{if(a.type===`ctrl-c`){this.#F=!0,this.#ze(),this.#je(),n(interruptedError());return}if(a.type===`ctrl-r`){this.#it();return}if(c===`select`){switch(a.type){case`up`:o>0&&(l=(l-1+o)%o,renderSection(),repaintStatus());break;case`down`:o>0&&(l=(l+1)%o,renderSection(),repaintStatus());break;case`enter`:{if(isOnFreeformRow()){c=`text`,u=``,this.#Re(),repaintStatus();break}let e=r[l];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}switch(a.type){case`character`:u+=a.value,this.#Be(),repaintStatus();break;case`backspace`:u=u.slice(0,-1),this.#Be(),repaintStatus();break;case`enter`:{let n=resolveQuestionText(u,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(i){if(u.length>0){u=``,this.#Be(),repaintStatus();break}c=`select`,u=``,this.#k=!1,this.#ze(),repaintStatus();break}u=``,this.#Be(),repaintStatus();break;default:break}},this.#Me()})}upsertSubagentStep(e){if(this.#o===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),r=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&r.length===0)){if(this.#qe(e.callId,e.subagentName),this.#o===`collapsed`){this.#it();return}this.#Je({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:r,live:!e.finalized}),this.#it()}}upsertSubagentTool(e){if(this.#o===`hidden`)return;if(this.#qe(e.callId,e.subagentName),this.#o===`collapsed`){this.#it();return}let t=subagentToolStatus(e.status),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,depth:1,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:t,live:t===`running`||t===`approval`,expanded:this.#o===`full`,toolInput:e.input};e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=summarizeToolResult(e.output),r.toolOutput=e.output),this.#Je(r),this.#it()}markChildToolCallId(e){this.#g.add(e);let t=this.#_.get(e);t!==void 0&&(this.#Ye(t),this.#_.delete(e),this.#it())}#fe(e){let t=this.#p.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#s===`hidden`)return;let t=e.state===`authorized`||e.state===`declined`||e.state===`failed`||e.state===`timed-out`;this.#Je({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e),preformatted:!0,live:!t}),this.#it()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#w)return;let n=this.#w>0;this.#w=t,t>0?(this.#M=STATUS.connectionAuth,this.#it()):n&&(this.#M=STATUS.processing,this.#it())}setVercelStatus(e){this.#T=e,this.#it()}reset(){this.#f=[],this.#p.clear(),this.#m.clear(),this.#C=void 0,this.#S.length=0,this.#h.length=0,this.#b=!1,this.#x=void 0,this.#g.clear(),this.#_.clear(),this.#v.clear(),this.#se=void 0,this.#ae=void 0,this.#w=0,this.#Y=void 0,this.#X=void 0,this.#Q=void 0,this.#$=void 0,this.#ee=void 0,this.#P&&(this.#n.clearAll(),this.#it())}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Ae(),this.#Ue({kind:`notice`,body:t,live:!1}),this.#it())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#Ae(),this.#Ue({kind:`sandbox`,body:t,live:!1}),this.#it())}renderSetupWarning(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Ae(),this.#Ue({kind:`warning`,body:t,live:!1}),this.#it())}renderCommandResult(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Ae(),this.#Ue({kind:`result`,body:t,live:!1}),this.#it())}#pe(e){this.#Ae(),this.#k=!1,this.#j=!1,this.#M=``,this.#ce={title:stripTerminalControls(e),lines:[],outputBuffer:[]},this.#Ve(),this.#it()}#me(e){this.#le=void 0,this.#Ee();let t=this.#ce;if(t!==void 0){if(this.#ce=void 0,this.#He(),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.#Ue({kind:`flow`,title:`info`,body:e.join(`
|
|
3
|
+
`),live:!1}),this.#Ue({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#it()}}async#he(e){let t=this.#be(),n=isMultiSelectRequest(e),r={options:e.options,submitRow:n};`initialValue`in e&&e.initialValue!==void 0&&(r.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(r.initialValues=e.initialValues);let i=initialSelectState(r),a,o=e.notices;if(e.kind===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));o=[...e.notices??[],...r],t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,select:i};return o!==void 0&&o.length>0&&(t.notices=o),a!==void 0&&(t.error=a),t};return t.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#it(),await this.#Ce((t,r)=>{let o={key:t,options:e.options,select:i},s=reduceSetupSelectInput(n?{...o,kind:e.kind,required:e.required}:{...o,kind:e.kind});switch(s.kind){case`cancel`:r(void 0);return;case`repaint`:this.#it();return;case`update`:i=s.select,a=void 0,this.#it();return;case`submit`:r(s.values);return;case`error`:a=s.message,this.#it();return;case`ignore`:return}}).promise}#ge(e){this.#Ae();let t=this.#xe();t.status=e.status;let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#r,t),this.#it();let r=this.#Ce((t,r)=>{let i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#it();return;case`repaint`:this.#it();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#_e(e){let t=this.#be(),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`editable`,message:e.message,options:e.options,select:r,edit:{optionValue:e.editable.value,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint,caretVisible:this.#I}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#r,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?(i.text.length===0&&(i=lineOf(e.editable.defaultValue)),this.#Re()):(i=lineOf(``),this.#ze())};return syncEditableRow(),this.#it(),await this.#Ce((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#Be(),this.#it()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#it()},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.#it();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t);switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#it();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#ze()).promise}async#ve(e){let t=this.#be(),n=lineOf(``),r;return t.question=t=>{let i={message:e.message,editor:n,mask:e.mask===!0};return e.placeholder!==void 0&&(i.placeholder=e.placeholder),e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#r,t,this.#I)},this.#Re(),this.#it(),await this.#Ce((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Be(),this.#it()},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.#it();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#it();return}i(t);return}default:return}},()=>this.#ze()).promise}async#ye(e){let t=this.#be();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#it(),await this.#Ce((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#it();return;default:return}}).promise}#be(){return this.#Ae(),this.#k=!1,this.#j=!1,this.#M=``,this.#xe()}#xe(){return this.#ce===void 0&&(this.#ce={title:``,lines:[],outputBuffer:[]}),this.#ce}#Se(){this.#ce!==void 0&&(this.#ce.question=void 0,this.#ce.hideLinesWhileQuestion=!1),this.#H=void 0,this.#Ne(),this.#Te(),this.#it()}#Ce(e,t){let n=!1,r,i=new Promise(e=>{r=e}),settle=e=>{n||(n=!0,t?.(),this.#Se(),r(e))};return this.#H=t=>e(t,settle),this.#Me(),{promise:i,settle}}#we(){let e,t=new Promise(t=>{e=t});return this.#le=e,this.#Te(),{promise:t,dispose:()=>{this.#le===e&&(this.#le=void 0,this.#Ee())}}}#Te(){if(this.#le===void 0)return;let consumer=e=>{if(e.type===`ctrl-c`||e.type===`escape`){let e=this.#le;this.#le=void 0,this.#Ee(),e?.();return}e.type===`ctrl-r`&&this.#it()};this.#ue=consumer,this.#H=consumer,this.#Me()}#Ee(){this.#ue!==void 0&&(this.#H===this.#ue&&this.#Ne(),this.#ue=void 0)}#De(e){let t=e===void 0?void 0:stripTerminalControls(e);if(this.#ce!==void 0){this.#ce.status=t,t===void 0&&(this.#ce.preview=void 0),this.#it();return}if(t===void 0){this.#j=!1,this.#M=``,this.#He(),this.#it();return}this.#Ae(),this.#j=!0,this.#M=t,this.#Ve(),this.#it()}#Oe(e,t){let r=stripTerminalControls(e);if(r.trim().length===0)return;let i=this.#ce;if(i!==void 0){if(i.preview=void 0,t===`warning`||t===`error`)for(let e of i.outputBuffer)i.lines.push({text:e,tone:`info`,evidence:!0});i.outputBuffer=[],i.lines.push({text:r,tone:t}),this.#it();return}this.#Ae(),this.#Ue({kind:`flow`,title:t,body:r,live:!1}),this.#it()}#ke(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let r=this.#ce;if(r===void 0){this.#Oe(t,`info`);return}r.preview=t,r.outputBuffer.push(t),r.outputBuffer.length>40&&r.outputBuffer.shift(),this.#it()}shutdown(){this.#je()}#Ae(e){this.#N=e?.title??this.#N,this.#Z=e?.contextSize??this.#l,!this.#P&&(this.#P=!0,this.#n.reset(),this.#n.hideCursor(),this.#_t(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume()),this.#G=()=>this.#it(),this.#t.on(`resize`,this.#G))}#je(){this.#Ne(),this.#ze(),this.#He(),this.#B!==void 0&&(clearTimeout(this.#B),this.#B=void 0),this.#V=!1,this.#P&&=(this.#Tt(),this.#it(),this.#n.clear(),this.#n.showCursor(),this.#vt(),this.#n.newline(),this.#e.isTTY&&(this.#e.setRawMode?.(!1),this.#e.pause()),this.#G&&=(this.#t.off(`resize`,this.#G),void 0),!1)}#Me(){this.#e.off(`data`,this.#Pe),this.#e.on(`data`,this.#Pe)}#Ne(){this.#e.off(`data`,this.#Pe),this.#Ie(),this.#U=``,this.#H=void 0}#Pe=e=>{this.#Ie(),this.#U+=e.toString(`utf8`),this.#Fe(),this.#U===`\x1B`&&(this.#W=setTimeout(()=>{this.#U===`\x1B`&&(this.#U=``,this.#H?.({type:`escape`}))},30),this.#W.unref?.())};#Fe(){for(;this.#U.length>0;){let e=nextKey(this.#U);if(e.incomplete)return;this.#U=this.#U.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#H?.(e.key)}}#Ie(){this.#W&&=(clearTimeout(this.#W),void 0)}#Le(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#it();break;case`ctrl-c`:this.#F=!0,this.#K?.();break;default:break}}#Re(){this.#ze(),this.#Be(),this.#R=setInterval(()=>{this.#I=!this.#I,this.#it()},500),this.#R.unref?.()}#ze(){this.#R&&=(clearInterval(this.#R),void 0),this.#I=!0}#Be(){this.#I=!0}#Ve(){this.#He(),this.#z=setInterval(()=>{this.#L+=1,this.#it()},90),this.#z.unref?.()}#He(){this.#z&&=(clearInterval(this.#z),void 0)}#Ue(e){e.id!==this.#ae?.id&&this.#Tt(),this.#f.push(e),e.id&&this.#p.set(e.id,e)}#We(e){this.#Ue({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#it()}#Ge(e){if(e!=null){if(this.#se===e){this.#se=void 0;return}this.#Ue({kind:`user`,body:stripTerminalControls(e),live:!1})}}#Ke(e,t,r){let i={kind:`error`,title:stripTerminalControls(e),body:stripTerminalControls(t),live:!1};r!==void 0&&(i.detail=stripTerminalControls(r)),this.#Ue(i),this.#it()}#qe(e,t){this.#v.has(e)||(this.#v.add(e),this.#Ue({id:subagentHeaderId(e),kind:`subagent`,title:stripTerminalControls(t),live:!1}))}#Je(e){if(e.id&&this.#m.has(e.id))return;let t=e.id?this.#p.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#Ue(e)}#Ye(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#Xe(){for(let e of this.#f)e.status===`approval`||e.status===`running`||(e.live=!1)}#Ze(e,t,r){switch(e.type){case`step-start`:this.#Qe(r.hasPendingToolResults?STATUS.toolResults:STATUS.processing),r.hasPendingToolResults=!1;break;case`step-finish`:this.#rt(e.usage),this.#it();break;case`assistant-delta`:{this.#Qe(STATUS.streaming);let t=(r.text.get(e.id)??``)+stripTerminalControls(e.delta);r.text.set(e.id,t),this.#$e(e.id,t,!0);break}case`assistant-complete`:{let t=r.text.get(e.id)??``,i=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;r.text.set(e.id,i),this.#$e(e.id,i,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#Qe(STATUS.streaming);let i=(r.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);r.reasoning.set(e.id,i),this.#et(e.id,i,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let n=r.reasoning.get(e.id)??``;this.#et(e.id,n,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#Qe(STATUS.executingTools),this.#tt({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,r);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;this.#tt({...n,status:`approval`},t,r);break}case`tool-result`:{if(t.tools===`hidden`)break;let n=this.#nt(e.toolCallId,r);if(n===void 0)break;r.hasPendingToolResults=!0,this.#Qe(STATUS.toolResults),this.#tt({...n,output:e.output,status:`done`},t,r);break}case`tool-error`:{if(t.tools===`hidden`)break;let n=this.#nt(e.toolCallId,r);if(n===void 0)break;r.hasPendingToolResults=!0,this.#Qe(STATUS.toolResults),this.#tt({...n,errorText:e.errorText,status:`error`},t,r);break}case`error`:this.#Ke(`Error`,e.errorText,e.detail);break;case`finish`:this.#rt(e.usage),this.#it();break}}#Qe(e){let t=this.#w>0?STATUS.connectionAuth:e;this.#M!==t&&(this.#M=t,this.#it())}#$e(e,t,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Je({id:e,kind:`assistant`,body:i,live:r}),this.#it())}#et(e,t,r,i){let a=stripTerminalControls(t).trim();a.length!==0&&(this.#Je({id:e,kind:`reasoning`,body:a,collapsed:collapseReasoning(i.reasoning,r),live:r}),this.#it())}#tt(e,t,n){if(n.tools.set(e.toolCallId,e),this.#g.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#_.set(e.toolCallId,r),this.#Je(renderNativeToolBlock(e,r,t.tools===`full`)),this.#it()}#nt(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#_.get(e)??toolSectionId(e),i=this.#p.get(r);if(!(i===void 0||i.kind!==`tool`))return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.title??`tool`}}#rt(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#Y=(t??0)+(n??0)),this.#X=t??this.#X,this.#Q=n??this.#Q,this.#Q!=null&&this.#ee!==void 0){let e=(Date.now()-this.#ee)/1e3;e>0&&(this.#$=this.#Q/e)}}#it(){if(this.#P){if(this.#q){this.#J=!0;return}this.#q=!0;try{do this.#J=!1,this.#at();while(this.#J)}finally{this.#q=!1}}}#at(){if(!this.#P)return;let e=this.#ht(),t=this.#ft(e),n=Math.max(1,this.#gt()-t.length),r=[],i=this.#C;for(;this.#f.length>0&&this.#f[0].live===!1;){let t=this.#f.shift();if(this.#h.push(t),t.id&&(this.#m.add(t.id),this.#p.delete(t.id)),this.#Dt(t))continue;let n=this.#ut(t,e,i);i=previousBlockOf(t),this.#C=i,r.push(...n),this.#S.push(...n)}let a=[];for(let t of this.#f){if(this.#Dt(t))continue;let n=this.#ut(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)a.push({block:t,row:n[e]})}let o=[...clipLiveRows(a.map(e=>e.row),n,e,this.#r),...t];r.length>0?this.#n.flush(r,o):this.#n.update(o)}#ot(){if(!this.#P)return;let e=this.#ht(),t=this.#ft(e),n=Math.max(1,this.#gt()-t.length),r=this.#C,i=[];for(let t of this.#f){if(this.#Dt(t))continue;let n=this.#ut(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#r),...t];this.#n.clearAll(),this.#n.flush([...this.#lt(),...this.#S],a)}logDisplayMode(){return this.#d}setLogDisplayMode(e){e!==this.#d&&(this.#d=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#ct(),this.#P&&this.#ot())}flushDelayedDevBuildErrors(){let e=this.#ie;e!==void 0&&(this.#ie=void 0,this.#Ue({kind:`log`,title:`stderr`,body:e,live:!1}),this.#it())}#st(){this.#V=!0,this.#B!==void 0&&clearTimeout(this.#B),this.#B=setTimeout(()=>{this.#V=!1,this.#B=void 0,this.#it()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#d)),this.#it()}#ct(){let e=this.#ht();this.#S.length=0;let t;for(let n of this.#h){if(this.#Dt(n))continue;let r=this.#ut(n,e,t);t=previousBlockOf(n),this.#S.push(...r)}this.#C=t}#lt(){let e=this.#y;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#ht()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#ut(e,t,n){let r={spinner:this.#dt()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#dt(){return this.#r.spinner[this.#L%this.#r.spinner.length]??``}#ft(e){let t=this.#r.colors,n=[``],r=this.#ce;if(r!==void 0){let t=this.#dt(),i;if(r.question!==void 0){let n=r.question(e);i={kind:`question`,rows:n},r.status!==void 0&&(i={kind:`question`,rows:n,status:{text:r.status,frame:t}})}else r.status===void 0?i=r.preview===void 0?{kind:`idle`,frame:t}:{kind:`preview`,text:r.preview,frame:t}:(i={kind:`status`,status:{text:r.status,frame:t}},r.preview!==void 0&&(i={kind:`status`,status:{text:r.status,frame:t},preview:r.preview}));let a={title:r.title,lines:r.hideLinesWhileQuestion===!0?[]:r.lines,content:i};return n.push(...renderFlowPanel(a,this.#r,e)),n}if(this.#k){let r=this.#A===void 0?void 0:inlineCommandHint(this.#A);r===void 0&&this.#A!==void 0&&isTypeaheadOpen(this.#A)&&n.push(...renderCommandSuggestions(this.#A,this.#r,e));let i=Math.max(4,e-3),{before:a,after:o}=visibleLine({text:this.#E,cursor:this.#D},i,this.#r.glyph.ellipsis),s=isPromptControlCommand(this.#E),style=e=>s&&e.length>0?t.blue(e):e,l=this.#I?t.cyan(this.#r.glyph.caret):` `,u=r?t.dim(` ${r}`):``,d=`${style(a)}${l}${style(o)}${u}`;return n.push(...promptInputRows(d,e,this.#r,!0)),this.#pt(n,e),n}let i=this.#j?t.yellow(this.#dt()):t.dim(this.#r.glyph.dot),a=this.#M.length>0?this.#M:`Ready`,o=this.#j?t.dim(a):a,s=this.#mt(),l=s?`${i} ${o} ${t.dim(this.#r.glyph.dot)} ${s}`:`${i} ${o}`;return n.push(clip(l,e)),this.#pt(n,e),n}#pt(e,t){let n={theme:this.#r,width:t};this.#V&&(n.logLevel=this.#d);let r=this.#y?.info?.agent.model.id;r!==void 0&&(n.model=r);let i=this.#y?.info?.agent.model.endpoint;i!==void 0&&(n.endpoint=i);let a=this.#X??0,o=this.#Q??0;if(a>0||o>0){let e={inputTokens:a,outputTokens:o};this.#Z!==void 0&&(e.contextSize=this.#Z),n.tokens=formatTokenFlow(e,this.#r.glyph)}this.#T!==void 0&&(n.vercel=this.#T);let s=buildStatusLine(n);s!==void 0&&e.push(s)}#mt(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#Y,outputTokens:this.#Q,tokensPerSecond:this.#$},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#ht(){return Math.max(20,this.#t.columns||80)}#gt(){return Math.max(8,this.#t.rows||24)}#_t(){if(this.#te!==void 0||!this.#u)return;this.#ne=``,this.#re=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#yt(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#te=()=>{e(),t()}}#vt(){let e=this.#te;e!==void 0&&(this.#te=void 0,e(),this.#ne.length>0&&(this.#Et(`stdout`)&&process.stdout.write(`${this.#ne}\n`),this.#ne=``),this.#re.length>0&&(this.#Et(`stderr`)&&process.stderr.write(`${this.#re}\n`),this.#re=``))}#yt(e,n){let r=(e===`stdout`?this.#ne:this.#re)+n,i=r.lastIndexOf(`
|
|
4
|
+
`),a=i===-1?r:r.slice(i+1);if(e===`stdout`?this.#ne=a:this.#re=a,i===-1)return;let o=stripAnsi(r.slice(0,i)).replace(/\s+$/u,``);o.trim().length!==0&&(e===`stdout`?this.#bt(o):this.#xt(o),this.#it())}#bt(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
|
|
5
|
+
`);t=[],e.trim().length!==0&&this.#Ue({kind:`log`,title:`stdout`,body:e,live:!1})};for(let n of e.split(`
|
|
6
|
+
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#Ue({kind:`sandbox`,body:e,live:!1});continue}let r=parseDevRebuildLogLine(n.trimEnd());if(r===void 0){t.push(n);continue}flushPending(),this.#Ct(r,n.trimEnd())}flushPending()}#xt(e){let t=e.split(`
|
|
7
|
+
`),n=t.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(n===-1){this.#Ue({kind:`log`,title:`stderr`,body:e,live:!1});return}let r=t.slice(0,n).join(`
|
|
8
|
+
`);r.trim().length>0&&this.#Ue({kind:`log`,title:`stderr`,body:r,live:!1});let i=t.slice(n).join(`
|
|
9
|
+
`);this.#St(i)}#St(e){if(this.#d===`all`){if(e.trim().length===0)return;this.#Ue({kind:`log`,title:`stderr`,body:e,live:!1});return}this.#ie=e}#Ct(e,t){let n=this.#wt();if(e.kind===`failed`){this.#St(t);return}if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#oe}`;this.#oe+=1,this.#ae={id:r,summary:t},this.#Ue({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}if(n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind),e.kind===`rebuilt`&&(this.#ie=void 0);return}e.kind===`rebuilt`&&(this.#ie=void 0),this.#Ue({kind:`log`,title:`stdout`,body:t,live:!1})}#wt(){let e=this.#ae;if(e===void 0)return;let t=this.#p.get(e.id);if(!(t===void 0||t.live!==!0))return{state:e,block:t}}#Tt(){let e=this.#ae;if(e===void 0)return;this.#ae=void 0;let t=this.#p.get(e.id);t!==void 0&&(t.live=!1)}#Et(e){switch(this.#d){case`none`:return!1;case`stderr`:return e===`stderr`;case`sandbox`:return e===`sandbox`;case`all`:return!0}}#Dt(e){return e.kind===`sandbox`?!this.#Et(`sandbox`):e.kind===`log`?!this.#Et(e.title===`stderr`?`stderr`:`stdout`):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}async function*iterateTUIStream(e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}return}yield*e}function clip(t,n){return visibleLength(t)>n?sliceVisible(t,n):t}function promptInputRows(e,t,n,r){let i=n.colors;return[clip(`${r?i.cyan(n.glyph.prompt):i.dim(n.glyph.prompt)} ${r?e:i.dim(e)}`,t),``]}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function leadsWithGap(e,t){if(e.kind===`sandbox`&&t?.kind===`sandbox`)return!1;if(t?.kind===`sandbox`&&e.kind!==`sandbox`)return!0;if(e.kind===`log`&&t?.kind===`log`)return t.title!==e.title;if(t?.kind===`log`&&e.kind!==`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`subagent`:case`error`:case`notice`:case`question`:case`connection-auth`:case`sandbox`:case`log`:case`command`:case`warning`:case`flow`:case`agent-header`:return!0;default:return!1}}function parseSandboxLogLine(e){let t=e.trim();if(!t.startsWith(`Eve: `))return;let n=t.slice(5);return/\bsandbox\b/i.test(n)&&!isLowValueSandboxLogLine(n)?n:void 0}function isLowValueSandboxLogLine(e){return/^initializing (?:\d+ )?sandbox templates?\b/i.test(e)||/^initialized \d+ sandbox\b/i.test(e)||/^reused cached sandbox template\b/i.test(e)||/^sandbox template "[^"]+" \([^)]+\): (checking|reusing|loading microsandbox runtime|microsandbox runtime ready)\b/i.test(e)}function clipLiveRows(e,t,n,r){if(e.length<=t)return[...e];if(t<=1)return[clip(hiddenRowsMarker(e.length,r),n)];let i=t-1;return[clip(hiddenRowsMarker(e.length-i,r),n),...e.slice(e.length-i)]}function hiddenRowsMarker(e,t){let n=e.toLocaleString(),r=e===1?`row`:`rows`;return t.colors.dim(`${t.glyph.dot} ${t.glyph.ellipsis} ${n} earlier ${r} hidden while streaming`)}function collapseReasoning(e,t){switch(e){case`collapsed`:return!0;case`auto-collapsed`:return!t;default:return!1}}function renderNativeToolBlock(e,t,r){let o={id:t,kind:`tool`,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:e.status,live:e.status===`running`||e.status===`approval`,expanded:r,toolInput:e.input};return e.output===void 0?e.errorText!==void 0&&(o.result=stripTerminalControls(e.errorText)):(o.result=summarizeToolResult(e.output),o.toolOutput=e.output),o}function subagentToolStatus(e){switch(e){case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`}}function formatToolApprovalTitle(e){return stripTerminalControls(e.title??e.toolName)}function toolSectionId(e){return`tool:${e}`}function questionSectionId(e){return`question:${e}`}function subagentHeaderId(e){return`subagent:${e}:header`}function subagentStepSectionId(e,t){return`subagent:${e}:step:${t}`}function subagentToolSectionId(e,t){return`subagent:${e}:tool:${t}`}function connectionAuthSectionId(e){return`connection-auth:${e}`}function formatConnectionAuthContent(e){let t=[],r=stripTerminalControls(e.description);r.length>0&&t.push(r);let i=e.challenge;if(i?.url&&t.push(`URL: ${stripTerminalControls(i.url)}`),i?.userCode&&t.push(`Code: ${stripTerminalControls(i.userCode)}`),i?.expiresAt&&t.push(`Expires: ${stripTerminalControls(i.expiresAt)}`),i?.instructions&&t.push(stripTerminalControls(i.instructions)),e.reason!==void 0){let r=stripTerminalControls(e.reason);r.length>0&&t.push(`Reason: ${r}`)}return t.join(`
|
|
7
10
|
`)}function formatQuestionContent(e,t,r){let i=r.colors,a=[],o=e.options??[];if(o.length>0){for(let[e,s]of o.entries()){let o=stripTerminalControls(s.label),c=s.description===void 0?``:stripTerminalControls(s.description),l=c.length>0?` ${i.dim(`— ${c}`)}`:``,u=t===e,d=u?`${i.cyan(r.glyph.pointer)} `:` `,f=u?i.cyan(o):o;a.push(`${d}${f}${l}`)}if(e.allowFreeform===!0){let e=t===o.length,n=e?`${i.cyan(r.glyph.pointer)} `:` `,s=`Type your own answer`;a.push(`${n}${e?i.cyan(s):i.dim(s)}`)}}else a.push(i.dim(` (type your answer)`));return a.join(`
|
|
8
11
|
`)}function resolveQuestionText(e,t){let n=e.trim();if(n.length===0)return;let r=n.toLowerCase(),i=t.options??[];if(i.length>0){let e=matchQuestionOption(r,i);if(e!==void 0)return{optionId:e.id,label:e.label}}if(t.allowFreeform===!0||i.length===0)return{text:n,label:n}}function matchQuestionOption(e,t){let n=t.find(t=>t.id.toLowerCase()===e);if(n!==void 0)return n;let r=t.find(t=>t.label.toLowerCase()===e);if(r!==void 0)return r;let i=Number(e);if(Number.isInteger(i)&&i>0&&i<=t.length)return t[i-1]}export{TerminalRenderer};
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"@ai-sdk/otel": "1.0.0-canary.117",
|
|
18
18
|
"picocolors": "1.1.1",
|
|
19
19
|
"@ai-sdk/provider": "4.0.0-canary.18",
|
|
20
|
+
"semver": "7.8.4",
|
|
20
21
|
"@standard-schema/spec": "1.1.0",
|
|
21
22
|
"turndown": "7.2.4",
|
|
22
23
|
"@vercel/oidc": "3.5.0",
|
|
@@ -27,5 +28,5 @@
|
|
|
27
28
|
"zod": "4.4.3",
|
|
28
29
|
"zod-validation-error": "5.0.0"
|
|
29
30
|
},
|
|
30
|
-
"scriptHash": "
|
|
31
|
+
"scriptHash": "8747039183f8d37273f8ede1c4f82e37763b9103421d434baddd3298a4a83c38"
|
|
31
32
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
The ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Isaac Z. Schlueter and Contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
15
|
+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface SemVer {
|
|
2
|
+
major: number;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface Comparator {
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Range {
|
|
10
|
+
set: Comparator[][];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SemVerApi {
|
|
14
|
+
Range: new (range: string) => Range;
|
|
15
|
+
intersects(rangeA: string, rangeB: string): boolean;
|
|
16
|
+
minVersion(range: string): SemVer | null;
|
|
17
|
+
subset(candidateRange: string, requiredRange: string): boolean;
|
|
18
|
+
validRange(range: string): string | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare const semver: SemVerApi;
|
|
22
|
+
|
|
23
|
+
export default semver;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),t=e(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),n=e(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),r=e(((e,r)=>{let{MAX_SAFE_COMPONENT_LENGTH:i,MAX_SAFE_BUILD_LENGTH:a,MAX_LENGTH:o}=t(),s=n();e=r.exports={};let c=e.re=[],l=e.safeRe=[],u=e.src=[],d=e.safeSrc=[],f=e.t={},p=0,m=`[a-zA-Z0-9-]`,h=[[`\\s`,1],[`\\d`,o],[m,a]],g=e=>{for(let[t,n]of h)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},_=(e,t,n)=>{let r=g(t),i=p++;s(e,i,t),f[e]=i,u[i]=t,d[i]=r,c[i]=new RegExp(t,n?`g`:void 0),l[i]=new RegExp(r,n?`g`:void 0)};_(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),_(`NUMERICIDENTIFIERLOOSE`,`\\d+`),_(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${m}*`),_(`MAINVERSION`,`(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})`),_(`MAINVERSIONLOOSE`,`(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})`),_(`PRERELEASEIDENTIFIER`,`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIER]})`),_(`PRERELEASEIDENTIFIERLOOSE`,`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIERLOOSE]})`),_(`PRERELEASE`,`(?:-(${u[f.PRERELEASEIDENTIFIER]}(?:\\.${u[f.PRERELEASEIDENTIFIER]})*))`),_(`PRERELEASELOOSE`,`(?:-?(${u[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[f.PRERELEASEIDENTIFIERLOOSE]})*))`),_(`BUILDIDENTIFIER`,`${m}+`),_(`BUILD`,`(?:\\+(${u[f.BUILDIDENTIFIER]}(?:\\.${u[f.BUILDIDENTIFIER]})*))`),_(`FULLPLAIN`,`v?${u[f.MAINVERSION]}${u[f.PRERELEASE]}?${u[f.BUILD]}?`),_(`FULL`,`^${u[f.FULLPLAIN]}$`),_(`LOOSEPLAIN`,`[v=\\s]*${u[f.MAINVERSIONLOOSE]}${u[f.PRERELEASELOOSE]}?${u[f.BUILD]}?`),_(`LOOSE`,`^${u[f.LOOSEPLAIN]}$`),_(`GTLT`,`((?:<|>)?=?)`),_(`XRANGEIDENTIFIERLOOSE`,`${u[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),_(`XRANGEIDENTIFIER`,`${u[f.NUMERICIDENTIFIER]}|x|X|\\*`),_(`XRANGEPLAIN`,`[v=\\s]*(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:${u[f.PRERELEASE]})?${u[f.BUILD]}?)?)?`),_(`XRANGEPLAINLOOSE`,`[v=\\s]*(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:${u[f.PRERELEASELOOSE]})?${u[f.BUILD]}?)?)?`),_(`XRANGE`,`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAIN]}$`),_(`XRANGELOOSE`,`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAINLOOSE]}$`),_(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${i}})(?:\\.(\\d{1,${i}}))?(?:\\.(\\d{1,${i}}))?`),_(`COERCE`,`${u[f.COERCEPLAIN]}(?:$|[^\\d])`),_(`COERCEFULL`,u[f.COERCEPLAIN]+`(?:${u[f.PRERELEASE]})?(?:${u[f.BUILD]})?(?:$|[^\\d])`),_(`COERCERTL`,u[f.COERCE],!0),_(`COERCERTLFULL`,u[f.COERCEFULL],!0),_(`LONETILDE`,`(?:~>?)`),_(`TILDETRIM`,`(\\s*)${u[f.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,_(`TILDE`,`^${u[f.LONETILDE]}${u[f.XRANGEPLAIN]}$`),_(`TILDELOOSE`,`^${u[f.LONETILDE]}${u[f.XRANGEPLAINLOOSE]}$`),_(`LONECARET`,`(?:\\^)`),_(`CARETTRIM`,`(\\s*)${u[f.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,_(`CARET`,`^${u[f.LONECARET]}${u[f.XRANGEPLAIN]}$`),_(`CARETLOOSE`,`^${u[f.LONECARET]}${u[f.XRANGEPLAINLOOSE]}$`),_(`COMPARATORLOOSE`,`^${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]})$|^$`),_(`COMPARATOR`,`^${u[f.GTLT]}\\s*(${u[f.FULLPLAIN]})$|^$`),_(`COMPARATORTRIM`,`(\\s*)${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]}|${u[f.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,_(`HYPHENRANGE`,`^\\s*(${u[f.XRANGEPLAIN]})\\s+-\\s+(${u[f.XRANGEPLAIN]})\\s*$`),_(`HYPHENRANGELOOSE`,`^\\s*(${u[f.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[f.XRANGEPLAINLOOSE]})\\s*$`),_(`STAR`,`(<|>)?=?\\s*\\*`),_(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),_(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),i=e(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),a=e(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),o=e(((e,o)=>{let s=n(),{MAX_LENGTH:c,MAX_SAFE_INTEGER:l}=t(),{safeRe:u,t:d}=r(),f=i(),{compareIdentifiers:p}=a(),m=(e,t)=>{let n=t.split(`.`);if(n.length>e.length)return!1;for(let t=0;t<n.length;t++)if(p(e[t],n[t])!==0)return!1;return!0};o.exports=class e{constructor(t,n){if(n=f(n),t instanceof e){if(t.loose===!!n.loose&&t.includePrerelease===!!n.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>c)throw TypeError(`version is longer than ${c} characters`);s(`SemVer`,t,n),this.options=n,this.loose=!!n.loose,this.includePrerelease=!!n.includePrerelease;let r=t.trim().match(n.loose?u[d.LOOSE]:u[d.FULL]);if(!r)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>l||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>l||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>l||this.patch<0)throw TypeError(`Invalid patch version`);r[4]?this.prerelease=r[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<l)return t}return e}):this.prerelease=[],this.build=r[5]?r[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(s(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let n=0;do{let e=this.prerelease[n],r=t.prerelease[n];if(s(`prerelease compare`,n,e,r),e===void 0&&r===void 0)return 0;if(r===void 0)return 1;if(e===void 0)return-1;if(e===r)continue;return p(e,r)}while(++n)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let n=0;do{let e=this.build[n],r=t.build[n];if(s(`build compare`,n,e,r),e===void 0&&r===void 0)return 0;if(r===void 0)return 1;if(e===void 0)return-1;if(e===r)continue;return p(e,r)}while(++n)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?u[d.PRERELEASELOOSE]:u[d.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];if(n===!1&&(r=[t]),m(this.prerelease,t)){let e=this.prerelease[t.split(`.`).length];isNaN(e)&&(this.prerelease=r)}else this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),s=e(((e,t)=>{let n=o();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),c=e(((e,t)=>{let n=s();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),l=e(((e,t)=>{let n=s();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),u=e(((e,t)=>{let n=o();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),d=e(((e,t)=>{let n=s();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),f=e(((e,t)=>{let n=o();t.exports=(e,t)=>new n(e,t).major})),p=e(((e,t)=>{let n=o();t.exports=(e,t)=>new n(e,t).minor})),m=e(((e,t)=>{let n=o();t.exports=(e,t)=>new n(e,t).patch})),h=e(((e,t)=>{let n=s();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),g=e(((e,t)=>{let n=o();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),_=e(((e,t)=>{let n=g();t.exports=(e,t,r)=>n(t,e,r)})),v=e(((e,t)=>{let n=g();t.exports=(e,t)=>n(e,t,!0)})),y=e(((e,t)=>{let n=o();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),b=e(((e,t)=>{let n=y();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),x=e(((e,t)=>{let n=y();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),S=e(((e,t)=>{let n=g();t.exports=(e,t,r)=>n(e,t,r)>0})),C=e(((e,t)=>{let n=g();t.exports=(e,t,r)=>n(e,t,r)<0})),w=e(((e,t)=>{let n=g();t.exports=(e,t,r)=>n(e,t,r)===0})),T=e(((e,t)=>{let n=g();t.exports=(e,t,r)=>n(e,t,r)!==0})),E=e(((e,t)=>{let n=g();t.exports=(e,t,r)=>n(e,t,r)>=0})),D=e(((e,t)=>{let n=g();t.exports=(e,t,r)=>n(e,t,r)<=0})),O=e(((e,t)=>{let n=w(),r=T(),i=S(),a=E(),o=C(),s=D();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),k=e(((e,t)=>{let n=o(),i=s(),{safeRe:a,t:c}=r();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?a[c.COERCEFULL]:a[c.COERCE]);else{let n=t.includePrerelease?a[c.COERCERTLFULL]:a[c.COERCERTL],i;for(;(i=n.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||i.index+i[0].length!==r.index+r[0].length)&&(r=i),n.lastIndex=i.index+i[1].length+i[2].length;n.lastIndex=-1}if(r===null)return null;let o=r[2];return i(`${o}.${r[3]||`0`}.${r[4]||`0`}${t.includePrerelease&&r[5]?`-${r[5]}`:``}${t.includePrerelease&&r[6]?`+${r[6]}`:``}`,t)}})),A=e(((e,n)=>{let r=s(),i=t(),a=o(),c=(e,t,n)=>{if(!i.RELEASE_TYPES.includes(t))return null;let r=l(e,n);return r&&u(r,t)},l=(e,t)=>r(e instanceof a?e.version:e,t),u=(e,t)=>{if(d(t))return e.version;switch(e.prerelease=[],t){case`major`:e.minor=0,e.patch=0;break;case`minor`:e.patch=0;break}return e.format()},d=e=>e.startsWith(`pre`);n.exports=c})),j=e(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),M=e(((e,a)=>{let s=/\s+/g;a.exports=class e{constructor(t,n){if(n=l(n),t instanceof e)return t.loose===!!n.loose&&t.includePrerelease===!!n.includePrerelease?t:new e(t.raw,n);if(t instanceof u)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=n,this.loose=!!n.loose,this.includePrerelease=!!n.includePrerelease,this.raw=t.trim().replace(s,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!S(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&C(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){e=e.replace(x,``);let t=((this.options.includePrerelease&&y)|(this.options.loose&&b))+`:`+e,n=c.get(t);if(n)return n;let r=this.options.loose,i=r?p[h.HYPHENRANGELOOSE]:p[h.HYPHENRANGE];e=e.replace(i,R(this.options.includePrerelease)),d(`hyphen replace`,e),e=e.replace(p[h.COMPARATORTRIM],g),d(`comparator trim`,e),e=e.replace(p[h.TILDETRIM],_),d(`tilde trim`,e),e=e.replace(p[h.CARETTRIM],v),d(`caret trim`,e);let a=e.split(` `).map(e=>T(e,this.options)).join(` `).split(/\s+/).map(e=>L(e,this.options));r&&(a=a.filter(e=>(d(`loose invalid filter`,e,this.options),!!e.match(p[h.COMPARATORLOOSE])))),d(`range list`,a);let o=new Map,s=a.map(e=>new u(e,this.options));for(let e of s){if(S(e))return[e];o.set(e.value,e)}o.size>1&&o.has(``)&&o.delete(``);let l=[...o.values()];return c.set(t,l),l}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>w(e,n)&&t.set.some(t=>w(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new f(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(z(this.set[t],e,this.options))return!0;return!1}};let c=new(j()),l=i(),u=N(),d=n(),f=o(),{safeRe:p,src:m,t:h,comparatorTrimReplace:g,tildeTrimReplace:_,caretTrimReplace:v}=r(),{FLAG_INCLUDE_PRERELEASE:y,FLAG_LOOSE:b}=t(),x=new RegExp(m[h.BUILD],`g`),S=e=>e.value===`<0.0.0-0`,C=e=>e.value===``,w=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},T=(e,t)=>(e=e.replace(p[h.BUILD],``),d(`comp`,e,t),e=A(e,t),d(`caret`,e),e=O(e,t),d(`tildes`,e),e=P(e,t),d(`xrange`,e),e=I(e,t),d(`stars`,e),e),E=e=>!e||e.toLowerCase()===`x`||e===`*`,D=(e,t,n)=>E(e)&&!E(t)||E(t)&&n&&!E(n),O=(e,t)=>e.trim().split(/\s+/).map(e=>k(e,t)).join(` `),k=(e,t)=>{let n=t.loose?p[h.TILDELOOSE]:p[h.TILDE];return e.replace(n,(t,n,r,i,a)=>{d(`tilde`,e,t,n,r,i,a);let o;return E(n)?o=``:E(r)?o=`>=${n}.0.0 <${+n+1}.0.0-0`:E(i)?o=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(d(`replaceTilde pr`,a),o=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):o=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,d(`tilde return`,o),o})},A=(e,t)=>e.trim().split(/\s+/).map(e=>M(e,t)).join(` `),M=(e,t)=>{d(`caret`,e,t);let n=t.loose?p[h.CARETLOOSE]:p[h.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,o)=>{d(`caret`,e,t,n,i,a,o);let s;return E(n)?s=``:E(i)?s=`>=${n}.0.0${r} <${+n+1}.0.0-0`:E(a)?s=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:o?(d(`replaceCaret pr`,o),s=n===`0`?i===`0`?`>=${n}.${i}.${a}-${o} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${o} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${o} <${+n+1}.0.0-0`):(d(`no pr`),s=n===`0`?i===`0`?`>=${n}.${i}.${a} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),d(`caret return`,s),s})},P=(e,t)=>(d(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>F(e,t)).join(` `)),F=(e,t)=>{e=e.trim();let n=t.loose?p[h.XRANGELOOSE]:p[h.XRANGE];return e.replace(n,(n,r,i,a,o,s)=>{if(d(`xRange`,e,n,r,i,a,o,s),D(i,a,o))return e;let c=E(i),l=c||E(a),u=l||E(o),f=u;return r===`=`&&f&&(r=``),s=t.includePrerelease?`-0`:``,c?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(l&&(a=0),o=0,r===`>`?(r=`>=`,l?(i=+i+1,a=0,o=0):(a=+a+1,o=0)):r===`<=`&&(r=`<`,l?i=+i+1:a=+a+1),r===`<`&&(s=`-0`),n=`${r+i}.${a}.${o}${s}`):l?n=`>=${i}.0.0${s} <${+i+1}.0.0-0`:u&&(n=`>=${i}.${a}.0${s} <${i}.${+a+1}.0-0`),d(`xRange return`,n),n})},I=(e,t)=>(d(`replaceStars`,e,t),e.trim().replace(p[h.STAR],``)),L=(e,t)=>(d(`replaceGTE0`,e,t),e.trim().replace(p[t.includePrerelease?h.GTE0PRE:h.GTE0],``)),R=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=E(r)?``:E(i)?`>=${r}.0.0${e?`-0`:``}`:E(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=E(l)?``:E(u)?`<${+l+1}.0.0-0`:E(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),z=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(d(e[n].semver),e[n].semver!==u.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),N=e(((e,t)=>{let a=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return a}constructor(t,n){if(n=s(n),t instanceof e){if(t.loose===!!n.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),d(`comparator`,t,n),this.options=n,this.loose=!!n.loose,this.parse(t),this.semver===a?this.value=``:this.value=this.operator+this.semver.version,d(`comp`,this)}parse(e){let t=this.options.loose?c[l.COMPARATORLOOSE]:c[l.COMPARATOR],n=e.match(t);if(!n)throw TypeError(`Invalid comparator: ${e}`);this.operator=n[1]===void 0?``:n[1],this.operator===`=`&&(this.operator=``),n[2]?this.semver=new f(n[2],this.options.loose):this.semver=a}toString(){return this.value}test(e){if(d(`Comparator.test`,e,this.options.loose),this.semver===a||e===a)return!0;if(typeof e==`string`)try{e=new f(e,this.options)}catch{return!1}return u(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``?!0:new p(t.value,n).test(this.value):t.operator===``?t.value===``?!0:new p(this.value,n).test(t.semver):(n=s(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||u(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||u(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let s=i(),{safeRe:c,t:l}=r(),u=O(),d=n(),f=o(),p=M()})),P=e(((e,t)=>{let n=M();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),F=e(((e,t)=>{let n=M();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),I=e(((e,t)=>{let n=o(),r=M();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),L=e(((e,t)=>{let n=o(),r=M();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),R=e(((e,t)=>{let n=o(),r=M(),i=S();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),z=e(((e,t)=>{let n=M();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),B=e(((e,t)=>{let n=o(),r=N(),{ANY:i}=r,a=M(),s=P(),c=S(),l=C(),u=D(),d=E();t.exports=(e,t,o,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(o){case`>`:p=c,m=u,h=l,g=`>`,_=`>=`;break;case`<`:p=l,m=d,h=c,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(s(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),V=e(((e,t)=>{let n=B();t.exports=(e,t,r)=>n(e,t,`>`,r)})),H=e(((e,t)=>{let n=B();t.exports=(e,t,r)=>n(e,t,`<`,r)})),U=e(((e,t)=>{let n=M();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),W=e(((e,t)=>{let n=P(),r=g();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),G=e(((e,t)=>{let n=M(),r=N(),{ANY:i}=r,a=P(),o=g(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!e.test(s.semver))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!e.test(u.semver))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),K=e(((e,n)=>{let i=r(),j=t(),K=o(),q=a();n.exports={parse:s(),valid:c(),clean:l(),inc:u(),diff:d(),major:f(),minor:p(),patch:m(),prerelease:h(),compare:g(),rcompare:_(),compareLoose:v(),compareBuild:y(),sort:b(),rsort:x(),gt:S(),lt:C(),eq:w(),neq:T(),gte:E(),lte:D(),cmp:O(),coerce:k(),truncate:A(),Comparator:N(),Range:M(),satisfies:P(),toComparators:F(),maxSatisfying:I(),minSatisfying:L(),minVersion:R(),validRange:z(),outside:B(),gtr:V(),ltr:H(),intersects:U(),simplifyRange:W(),subset:G(),SemVer:K,re:i.re,src:i.src,tokens:i.t,SEMVER_SPEC_VERSION:j.SEMVER_SPEC_VERSION,RELEASE_TYPES:j.RELEASE_TYPES,compareIdentifiers:q.compareIdentifiers,rcompareIdentifiers:q.rcompareIdentifiers}}));export default K();export{};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
function createLoggingSandboxSession(e){let{log:t,session:n}=e;return
|
|
1
|
+
function createLoggingSandboxSession(e){let{log:t,session:n}=e;return{...n,async run(e){t?.(`bootstrap run: ${formatCommand(e.command)}`);let r=await n.run(e);if(r.exitCode===1)throw Error(formatBootstrapRunFailure(e.command,r));return r},async spawn(e){return t?.(`bootstrap spawn: ${formatCommand(e.command)}`),await n.spawn(e)},async setNetworkPolicy(e){return t?.(`bootstrap set network policy: ${formatNetworkPolicy(e)}`),await n.setNetworkPolicy(e)},async writeFile(e){return t?.(`bootstrap write file: ${e.path}`),await n.writeFile(e)},async writeBinaryFile(e){return t?.(`bootstrap write binary file: ${e.path} (${e.content.byteLength} bytes)`),await n.writeBinaryFile(e)},async writeTextFile(e){return t?.(`bootstrap write text file: ${e.path} (${e.content.length} chars)`),await n.writeTextFile(e)},async removePath(e){return t?.(`bootstrap remove path: ${e.path}`),await n.removePath(e)}}}function formatBootstrapRunFailure(e,t){return[`Sandbox bootstrap failed because sandbox.run command exited with code 1:`,e,``,`stdout:`,t.stdout,``,`stderr:`,t.stderr].join(`
|
|
2
|
+
`)}function formatCommand(e){return truncateOneLine(e)}function formatNetworkPolicy(e){return truncateOneLine(typeof e==`string`?e:JSON.stringify(e))}function truncateOneLine(e){let t=e.replaceAll(/\s+/g,` `).trim();return t.length<=240?t:`${t.slice(0,239)}…`}export{createLoggingSandboxSession};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.9.
|
|
1
|
+
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.9.1`,WORKFLOW_MODULE_ALIASES={"workflow/api":`src/compiled/@workflow/core/runtime.js`,"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`,"workflow/runtime":`src/compiled/@workflow/core/runtime.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let t=e;for(;;){if(existsSync(join(t,`package.json`))&&!isBuildOutputPackageRoot(t))return t;let r=dirname(t);if(r===t)throw Error(`Failed to resolve package root from "${e}".`);t=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveInstalledPackageInfo,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isAbsolute,relative,sep}from"node:path";const AUTHORED_ARTIFACTS_UPDATED_LOG_LINE=`[eve:dev] authored artifacts updated.`,STRUCTURAL_RELOAD_LOG_LINE=`[eve:dev] structural change detected, reloading Nitro worker...`;function formatChangeDetectedLogLine(e,t){return`[eve:dev] change detected (${formatChangeEventList(e,t)}), rebuilding authored artifacts...`}const CHANGE_DETECTED_PATTERN=/^\[eve:dev\] change detected \(\d+ events?: (.+)\), rebuilding authored artifacts\.\.\.$/u,MORE_EVENTS_PATTERN=/^\+(\d+) more$/u;function parseDevRebuildLogLine(e){if(e===`[eve:dev] authored artifacts updated.`)return{kind:`rebuilt`};if(e===`[eve:dev] structural change detected, reloading Nitro worker...`)return{kind:`reloading`};let t=
|
|
1
|
+
import{isAbsolute,relative,sep}from"node:path";const AUTHORED_ARTIFACTS_UPDATED_LOG_LINE=`[eve:dev] authored artifacts updated.`,STRUCTURAL_RELOAD_LOG_LINE=`[eve:dev] structural change detected, reloading Nitro worker...`;function formatChangeDetectedLogLine(e,t){return`[eve:dev] change detected (${formatChangeEventList(e,t)}), rebuilding authored artifacts...`}const CHANGE_DETECTED_PATTERN=/^\[eve:dev\] change detected \(\d+ events?: (.+)\), rebuilding authored artifacts\.\.\.$/u,MORE_EVENTS_PATTERN=/^\+(\d+) more$/u,REBUILD_FAILED_PATTERN=/^\[eve:dev\] rebuild (?:failed|queue error): (.+)$/u;function parseDevRebuildLogLine(e){if(e===`[eve:dev] authored artifacts updated.`)return{kind:`rebuilt`};if(e===`[eve:dev] structural change detected, reloading Nitro worker...`)return{kind:`reloading`};let t=REBUILD_FAILED_PATTERN.exec(e);if(t!==null)return{kind:`failed`,message:t[1]};let n=CHANGE_DETECTED_PATTERN.exec(e);if(n===null)return;let r=[],i=0;for(let e of n[1].split(`, `)){let t=MORE_EVENTS_PATTERN.exec(e);if(t!==null){i+=Number(t[1]);continue}let n=e.indexOf(` `);if(n===-1)return;r.push({event:e.slice(0,n),path:e.slice(n+1)})}if(r.length!==0)return{kind:`rebuilding`,events:r,more:i}}function formatChangeEventList(e,t){let n=`${t.length} event${t.length===1?``:`s`}`,r=t.slice(0,6).map(t=>`${t.event} ${formatChangeEventPath(e,t.path)}`),i=t.length-r.length;return i>0&&r.push(`+${i} more`),`${n}: ${r.join(`, `)}`}function formatChangeEventPath(r,i){let a=relative(r,i),o=a===`..`||a.startsWith(`..${sep}`)||isAbsolute(a);return(a.length>0&&!o?a:i).replaceAll(`\\`,`/`)}export{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine,parseDevRebuildLogLine};
|