eve 0.70.1 → 0.70.2
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 +24 -0
- package/dist/src/channel/adapter.js +1 -1
- package/dist/src/channel/channel-operations.js +1 -1
- package/dist/src/channel/resolve-text.d.ts +8 -0
- package/dist/src/channel/resolve-text.js +2 -1
- package/dist/src/cli/banner.d.ts +2 -2
- package/dist/src/cli/banner.js +1 -1
- package/dist/src/cli/commands/init-agent-workspace.js +1 -1
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +2 -1
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +2 -2
- package/dist/src/cli/dev/tui/test/mock-terminal.d.ts +7 -1
- package/dist/src/cli/dev/tui/test/mock-terminal.js +4 -3
- package/dist/src/cli/dev/tui/theme.d.ts +1 -1
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/cli/dev/tui/tool-presentation.d.ts +15 -2
- package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
- package/dist/src/cli/dev/tui/transcript-parts.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +7 -7
- package/dist/src/compiled/@photon-ai/chat-adapter-imessage/index.js +1 -1
- package/dist/src/compiled/@vercel/sandbox/index.js +1 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +15 -0
- package/dist/src/compiled/@workflow/core/runtime/dynamic-workflow.d.ts +182 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +7 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/quickjs-assets.generated.d.ts +7 -0
- package/dist/src/compiled/@workflow/core/runtime/quickjs-entrypoint.d.ts +2 -30
- package/dist/src/compiled/@workflow/core/runtime/quickjs-log-view.d.ts +27 -4
- package/dist/src/compiled/@workflow/core/runtime/quickjs-runtime.d.ts +55 -3
- package/dist/src/compiled/@workflow/core/runtime/quickjs-snapshot-codec.d.ts +74 -0
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +44 -0
- package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +4 -4
- package/dist/src/compiled/@workflow/core/schemas.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +27 -2
- package/dist/src/compiled/@workflow/core/serialization/hardened.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/serialization/types.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/serialization.d.ts +48 -0
- package/dist/src/compiled/@workflow/core/serialization.js +1 -1
- package/dist/src/compiled/@workflow/core/set-error-stack.d.ts +12 -0
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +47 -0
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world/events.d.ts +10 -0
- package/dist/src/compiled/@workflow/world/index.d.ts +2 -0
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +127 -0
- package/dist/src/compiled/@workflow/world/queue.d.ts +6 -0
- package/dist/src/compiled/@workflow/world/runs.d.ts +9 -2
- package/dist/src/compiled/@workflow/world/snapshots.d.ts +60 -0
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +19 -17
- package/dist/src/compiled/_chunks/node/undici-B61sz6UT.js +95 -0
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-D721NpZv.js → attribute-changes-VaTKT4K8.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/dist-B7NC1c9-.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{functions-DpZiBxgQ.js → functions-CKkqf9V6.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/helpers-CP9TjeO8.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{logger-D4GJNTk4.js → logger-oqfblE3p.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/resume-hook-yq-NAdBu.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-DYKeqbob.js +32 -0
- package/dist/src/compiled/_chunks/workflow/serialization-APSKphN5.js +3 -0
- package/dist/src/compiled/_chunks/workflow/signal-exit-iIdjQcCK.js +95 -0
- package/dist/src/compiled/_chunks/workflow/sleep-Ba8SExMt.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{token-BhlnqoHM.js → token-BKeK6DmC.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/token-Cv2GYj9A.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{token-util-DaeRTzDa.js → token-util-CddTZ_ef.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{wait-until-3_1djUuL.js → wait-until-Dc9s3yyP.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{wrapper-CzrF_dmI.js → wrapper-Dq4OeGmJ.js} +4 -4
- package/dist/src/compiled/shadcn-registry/index.js +4 -4
- package/dist/src/context/serialize.js +1 -1
- package/dist/src/discover/discover-agent.js +1 -1
- package/dist/src/discover/extension-specifier.d.ts +1 -0
- package/dist/src/discover/extension-specifier.js +1 -1
- package/dist/src/discover/extensions.d.ts +1 -1
- package/dist/src/discover/extensions.js +1 -1
- package/dist/src/discover/project-source.d.ts +5 -0
- package/dist/src/discover/project-source.js +1 -1
- package/dist/src/evals/session.d.ts +1 -0
- package/dist/src/evals/session.js +1 -1
- package/dist/src/evals/types.d.ts +6 -0
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
- package/dist/src/execution/proxied-deliver-step.d.ts +11 -0
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/sandbox/read-file.d.ts +8 -1
- package/dist/src/execution/sandbox/read-file.js +3 -3
- package/dist/src/execution/session/active-turn.d.ts +4 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/entry-input.d.ts +23 -5
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +35 -13
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/program.d.ts +16 -3
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/turn-step-types.d.ts +6 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +4 -4
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/attachment-staging.d.ts +27 -7
- package/dist/src/harness/attachment-staging.js +1 -1
- package/dist/src/harness/compaction-prompt.js +2 -2
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/token-estimate.d.ts +5 -3
- package/dist/src/harness/token-estimate.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/attachments/media-metadata.d.ts +25 -0
- package/dist/src/internal/attachments/media-metadata.js +1 -0
- package/dist/src/internal/attachments/sandbox-refs.d.ts +12 -7
- package/dist/src/internal/attachments/sandbox-refs.js +1 -1
- package/dist/src/internal/authored-module-loader.js +1 -1
- package/dist/src/internal/bundler/extension-mount-plugin.d.ts +4 -0
- package/dist/src/internal/bundler/extension-mount-plugin.js +1 -1
- package/dist/src/internal/bundler/extension-scope-plugin.js +2 -2
- package/dist/src/internal/input-text.d.ts +12 -0
- package/dist/src/internal/input-text.js +1 -0
- package/dist/src/internal/workflow/vercel-world-defaults.d.ts +1 -1
- package/dist/src/internal/workflow/vercel-world-defaults.js +1 -1
- package/dist/src/public/channels/chat-sdk/input-actions.d.ts +8 -2
- package/dist/src/public/channels/chat-sdk/input-actions.js +4 -1
- package/dist/src/public/channels/github/defaults.js +2 -3
- package/dist/src/public/channels/linear/hitl.js +2 -3
- package/dist/src/public/channels/slack/action-status.d.ts +10 -5
- package/dist/src/public/channels/slack/action-status.js +1 -1
- package/dist/src/public/channels/slack/defaults.js +3 -3
- package/dist/src/public/channels/slack/limits.d.ts +1 -1
- package/dist/src/public/channels/slack/limits.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +11 -9
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/slack/task-card.js +1 -1
- package/dist/src/public/channels/slack/thread-status.d.ts +33 -0
- package/dist/src/public/channels/slack/thread-status.js +1 -0
- package/dist/src/public/channels/twilio/defaults.js +4 -2
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/subagents/hitl-proxy.d.ts +2 -2
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/read-file.d.ts +7 -0
- package/dist/src/tools/provided/read-file.js +2 -2
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/docs/agent-config.md +2 -2
- package/docs/channels/chat-sdk.mdx +1 -1
- package/docs/channels/slack.mdx +21 -15
- package/docs/channels/twilio.mdx +1 -1
- package/docs/concepts/built-in-tools.md +1 -1
- package/docs/concepts/default-harness.md +4 -0
- package/docs/concepts/execution-model-and-durability.mdx +7 -1
- package/docs/concepts/sessions-runs-and-streaming.md +3 -3
- package/docs/evals/cases.mdx +1 -0
- package/docs/extensions.md +5 -3
- package/docs/guides/dev-tui.md +3 -1
- package/docs/guides/dynamic-capabilities.md +1 -1
- package/docs/sandbox/index.mdx +11 -0
- package/docs/tools/overview.mdx +4 -2
- package/package.json +7 -7
- package/dist/src/compiled/_chunks/node/undici-h5GH4RBM.js +0 -95
- package/dist/src/compiled/_chunks/workflow/debug-log-CVPstO1D.js +0 -1
- package/dist/src/compiled/_chunks/workflow/dist-BUFGAKRb.js +0 -1
- package/dist/src/compiled/_chunks/workflow/frames-Dr9fHWdo.js +0 -3
- package/dist/src/compiled/_chunks/workflow/helpers-DkKxg_yn.js +0 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-uTW-jBYz.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-5DmiMN9b.js +0 -1
- package/dist/src/compiled/_chunks/workflow/serialization-CNIYl1D3.js +0 -3
- package/dist/src/compiled/_chunks/workflow/signal-exit-DZKTacNU.js +0 -95
- package/dist/src/compiled/_chunks/workflow/sleep-DFKgN7UG.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-1wSBbi5N.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-util-Cm4Ec1Bg.js +0 -1
- package/dist/src/compiled/_chunks/workflow/ws-transport--rYOVIaf.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.70.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 43f585c: A model step that ends early, for example at the output token limit, no longer leaves its tool calls unanswered. The AI SDK does not run tools from such a step, so the next model call failed with "Tool results are missing". eve now answers each skipped call with an error, and the model can call the tool again.
|
|
8
|
+
- 1360a1f: Chat SDK adapters without card support, such as Photon iMessage and Linq, now show `ask_question` prompts and tool approvals with numbered options, so a person can answer by replying with an option's number or label (for example `approve` or `cancel`). Freeform questions now ask for a typed reply on every adapter instead of pointing to the eve session UI.
|
|
9
|
+
- 1062c92: After compaction, eve now moves an idle session to a fresh workflow run on the same deployment, so long-running sessions no longer accumulate an ever-growing workflow event log. The session keeps its ID, event stream, continuation addresses, and deadline.
|
|
10
|
+
- 285cbe6: A plain-text reply that answers a pending `ask_question` or `ctx.ask()` question no longer leaves its channel context behind. Before, channels that attach per-message context, such as Telegram, Discord, Teams, and Twilio, added that block to history as a separate message after the answer, and the model replied to it instead of continuing from the answer.
|
|
11
|
+
- f9d2071: Fix discovery of packaged extension mounts whose default exports are rewritten during compilation, and of built-in extensions mounted from inside the eve package itself.
|
|
12
|
+
- 1062c92: Eval sessions now have `session.compact()`, which compacts the session between turns and resolves to the compaction events through `session.waiting`, so evals no longer need raw `fetch` calls to cover compaction.
|
|
13
|
+
- 11e7cad: An installed extension mounted in both the root agent and a subagent now builds when its distribution has shared chunks in `dist/_chunks`. Each mount owns those chunks, so they read that mount's configuration and state instead of failing with `refers to multiple extension mounts`.
|
|
14
|
+
- f8ef817: Sessions from eve 0.68 and earlier now hand off to a newer deployment even when the agent or one of its extensions has since removed a `defineState` key. The removed state is dropped with a warning instead of keeping the session on its old deployment.
|
|
15
|
+
- bdba125: Avoid repeating the eve header when interactive `eve init` opens onboarding. Standalone init runs still print their header, and all CLI banners now use a single space between the eve wordmark and version.
|
|
16
|
+
- 0bf95b0: The default Slack thread status now keeps naming the latest work across model steps, including tool progress, reasoning, and long replies, instead of resetting to `Thinking...`. eve clears it while a turn waits on an approval, answer, or sign-in.
|
|
17
|
+
- ef1a6b9: Slack thread replies now answer pending tool approvals and `ctx.ask()` questions by what the person typed, such as `approve` or an option label. Before, eve matched the attributed `<slack_message>` envelope instead, so typed answers never resolved a choice and free-text answers included the envelope.
|
|
18
|
+
- 1f81fcd: Update eve's bundled Workflow SDK packages from prerelease builds to the stable 5.0.1 release family.
|
|
19
|
+
- 79c4379: Telegram's Approve and Cancel buttons answer a tool approval again. Since approvals started holding the turn, a button press never resumed it and the turn waited until the person typed a reply.
|
|
20
|
+
- 0df9bbf: Files that tools return to the model now live in the session sandbox, with only a reference in session history, so workflow state no longer re-stores image bytes on every step; each model call sends the same file, keeping it visible on later turns and the provider's prompt cache valid. Compaction now counts images at roughly what providers bill for them instead of their base64 length, and `read_file` shows PNG, JPEG, GIF, and WebP files to the model as images. Message attachments and tool files now stage under `/workspace/.eve/attachments` instead of `/workspace/attachments`, so they no longer collide with an agent's own files.
|
|
21
|
+
- f7b07c1: The `eve dev` TUI's approval drawer now asks the approval's own prompt, such as `Approve Deploy release?`, instead of `Approve deploy_release?` built from the raw tool name. It now matches what channels and the web client show.
|
|
22
|
+
- d18970c: Fix blank lines accumulating after model selection in the dev TUI under tmux. The speed marker now uses a single-column glyph so rebuild status lines do not wrap or leave a stray character below the status bar.
|
|
23
|
+
- 0bf95b0: The dev TUI now shows readable names for subagents and unlabeled tools, such as `subagent(worker)` for `code__worker` and `List issues` for `linear__list_issues`, using the same naming as the Slack status and task cards.
|
|
24
|
+
- 46f8a6e: The Twilio channel now sends `ask_question` prompts and tool approvals by SMS with numbered options, so a person can answer by replying with an option's number or label (for example `approve` or `cancel`). Previously the request was never sent and the session stayed parked.
|
|
25
|
+
- beb0dd1: Agents on the Vercel workflow world now write workflow events over WebSocket by default (`WORKFLOW_EVENTS_TRANSPORT=ws`). Set `WORKFLOW_EVENTS_TRANSPORT=http` to keep the HTTP transport.
|
|
26
|
+
|
|
3
27
|
## 0.70.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{createLogger}from"#internal/logging.js";const log=createLogger(`channel.adapter`);function defaultDeliverResult(e){if(e.message!==void 0)return attachClientContext({inputResponses:e.inputResponses,message:e.message,context:e.context,outputSchema:e.outputSchema},readClientContext(e));if(e.inputResponses!==void 0&&e.inputResponses.length>0)return attachClientContext({inputResponses:e.inputResponses,context:e.context,outputSchema:e.outputSchema},readClientContext(e));if(e.context!==void 0&&e.context.length>0||(readClientContext(e)?.length??0)>0)return attachClientContext({context:e.context,outputSchema:e.outputSchema},readClientContext(e));if(e.outputSchema!==void 0)return{outputSchema:e.outputSchema}}function getAdapterKind(e){return e.kind}async function callAdapterEventHandler(e,t,n){let r=withWaitingContinuationToken(t,n),i=e[t.type];if(i!==void 0)try{await i(`data`in r?r.data:void 0,n)}catch(n){log.error(`adapter event handler threw — event swallowed`,{adapterKind:getAdapterKind(e),eventType:t.type,error:n})}return withWaitingContinuationToken(r,n)}function withWaitingContinuationToken(e,t){return e.type===`session.waiting`?{...e,data:{...e.data,continuationToken:t.session.continuation?.token??t.session.id}}:e}export{callAdapterEventHandler,defaultDeliverResult,getAdapterKind};
|
|
1
|
+
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{attachInputText,readInputText}from"#internal/input-text.js";import{createLogger}from"#internal/logging.js";const log=createLogger(`channel.adapter`);function defaultDeliverResult(e){if(e.message!==void 0)return attachClientContext(attachInputText({inputResponses:e.inputResponses,message:e.message,context:e.context,outputSchema:e.outputSchema},readInputText(e)),readClientContext(e));if(e.inputResponses!==void 0&&e.inputResponses.length>0)return attachClientContext({inputResponses:e.inputResponses,context:e.context,outputSchema:e.outputSchema},readClientContext(e));if(e.context!==void 0&&e.context.length>0||(readClientContext(e)?.length??0)>0)return attachClientContext({context:e.context,outputSchema:e.outputSchema},readClientContext(e));if(e.outputSchema!==void 0)return{outputSchema:e.outputSchema}}function getAdapterKind(e){return e.kind}async function callAdapterEventHandler(e,t,n){let r=withWaitingContinuationToken(t,n),i=e[t.type];if(i!==void 0)try{await i(`data`in r?r.data:void 0,n)}catch(n){log.error(`adapter event handler threw — event swallowed`,{adapterKind:getAdapterKind(e),eventType:t.type,error:n})}return withWaitingContinuationToken(r,n)}function withWaitingContinuationToken(e,t){return e.type===`session.waiting`?{...e,data:{...e.data,continuationToken:t.session.continuation?.token??t.session.id}}:e}export{callAdapterEventHandler,defaultDeliverResult,getAdapterKind};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createChannelAddressFn}from"#channel/channel-address.js";import{parseInputResponses}from"#shared/input.js";function createChannelOperations(e){let t=createChannelAddressFn(e);return{from(e){let n=t(e);return{async send(e,t){return await n.deliver({context:t.context,message:e,outputSchema:t.outputSchema,state:t.state},t)},async respond(e,t){if(e.length===0)throw Error(`respond() requires at least one input response.`);let r=parseInputResponses(e);return await n.deliver({context:t.context,inputResponses:r,state:t.state},t)},async cancel(e){return await n.cancel(e)},async compact(){return await n.compact()},async clear(){return await n.clear()},async reset(e){return await n.reset(e)}}},async resolveSession(e){return await t(e).resolveSession()}}}export{createChannelOperations};
|
|
1
|
+
import{attachInputText,readInputText}from"#internal/input-text.js";import{createChannelAddressFn}from"#channel/channel-address.js";import{parseInputResponses}from"#shared/input.js";function createChannelOperations(e){let t=createChannelAddressFn(e);return{from(e){let n=t(e);return{async send(e,t){return await n.deliver(attachInputText({context:t.context,message:e,outputSchema:t.outputSchema,state:t.state},readInputText(t)),t)},async respond(e,t){if(e.length===0)throw Error(`respond() requires at least one input response.`);let r=parseInputResponses(e);return await n.deliver({context:t.context,inputResponses:r,state:t.state},t)},async cancel(e){return await n.cancel(e)},async compact(){return await n.compact()},async clear(){return await n.clear()},async reset(e){return await n.reset(e)}}},async resolveSession(e){return await t(e).resolveSession()}}}export{createChannelOperations};
|
|
@@ -5,6 +5,14 @@ interface TextResolvableRequest {
|
|
|
5
5
|
readonly options?: readonly InputOption[];
|
|
6
6
|
readonly requestId: string;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Renders a request's prompt and numbered options as the plain text that
|
|
10
|
+
* {@link resolveTextToResponse} parses, so a reply with the number, label, or
|
|
11
|
+
* id answers it. Channels append their own reply instructions.
|
|
12
|
+
*/
|
|
13
|
+
export declare function renderTextInputRequest(request: TextResolvableRequest & {
|
|
14
|
+
readonly prompt: string;
|
|
15
|
+
}): string;
|
|
8
16
|
/**
|
|
9
17
|
* Maps freeform text to an {@link InputResponse} for a single request.
|
|
10
18
|
*
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function renderTextInputRequest(e){let t=[e.prompt];return e.options!==void 0&&e.options.length>0&&t.push(``,...e.options.map((e,t)=>{let n=e.description?` - ${e.description}`:``;return`${t+1}. ${e.label}${n}`})),t.join(`
|
|
2
|
+
`)}function resolveTextToResponse(e,t){let n=e.trim();if(n.length===0)return;let r=n.toLowerCase();if(t.options!==void 0&&t.options.length>0){let e=matchOption(r,t.options);if(e!==void 0)return{requestId:t.requestId,optionId:e.id}}if(t.allowFreeform===!0||t.options===void 0||t.options.length===0)return{requestId:t.requestId,text:n}}function resolveTextToResponses(e,t){let n=[];for(let r of t){let t=resolveTextToResponse(e,r);t!==void 0&&n.push(t)}return n}function matchOption(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{renderTextInputRequest,resolveTextToResponse,resolveTextToResponses};
|
package/dist/src/cli/banner.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare const EVE_WORDMARK = "eve";
|
|
2
2
|
/**
|
|
3
3
|
* The boot banner shared by every CLI command that announces itself: the eve
|
|
4
|
-
* badge plus the installed version.
|
|
4
|
+
* badge plus the installed version.
|
|
5
5
|
*/
|
|
6
6
|
export declare function eveCliBanner(): string;
|
|
7
7
|
/**
|
|
8
|
-
* The unstyled wordmark-and-version tag (`☰eve
|
|
8
|
+
* The unstyled wordmark-and-version tag (`☰eve v0.24.5`) — the boot banner's
|
|
9
9
|
* plain-text form. The dev TUI dims it as its parting line on teardown.
|
|
10
10
|
*/
|
|
11
11
|
export declare function eveVersionTag(): string;
|
package/dist/src/cli/banner.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import pc from"#compiled/picocolors/index.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";const EVE_WORDMARK=`eve`;function eveCliBanner(){let{version:e}=resolveInstalledPackageInfo();return`${pc.bgBlack(pc.white(`☰eve
|
|
1
|
+
import pc from"#compiled/picocolors/index.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";const EVE_WORDMARK=`eve`;function eveCliBanner(){let{version:e}=resolveInstalledPackageInfo();return`${pc.bgBlack(pc.white(`☰eve`))} ${pc.dim(`v${e}`)}`}function eveVersionTag(){let{version:e}=resolveInstalledPackageInfo();return`☰eve v${e}`}export{EVE_WORDMARK,eveCliBanner,eveVersionTag};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{InitTargetError}from"./init-telemetry.js";import{mkdir,readFile,rename}from"node:fs/promises";import pc from"#compiled/picocolors/index.js";import{join}from"node:path";import{resolveInitAgentSettings}from"#shared/default-agent-model.js";import{createPrompter}from"#setup/prompter.js";import{findEveProjectContext}from"#internal/project-context.js";import{formatNodeEngineOverrideWarning}from"#setup/node-engine.js";import{pathExists}from"#setup/path-exists.js";import{agentTemplateFiles}from"#setup/scaffold/create/project.js";import{assertValidPublicAgentName}from"#internal/agent-name.js";import{validateModelSlug}from"#setup/flows/model-source-change.js";import{writeTextFile}from"#setup/scaffold/files.js";function formatWorkspaceRootMutationWarning(e){let t=e.kind===`package-json`?`package.json`:`configuration`,n=e.nodeEngineOverride===void 0?``:` (${formatNodeEngineOverrideWarning(e.nodeEngineOverride)})`;return`Updated workspace root ${t} at ${e.path}${n}`}function validateAgentNames(e){if(e.length===0)throw Error(`--agents requires at least one agent name.`);let t=new Set;for(let n of e){if(assertValidPublicAgentName(n,`Agent`),t.has(n))throw Error(`Agent name ${JSON.stringify(n)} is repeated.`);t.add(n)}}async function writeWorkspaceAgent(e,t,n){let r=join(e,`agents`,t);if(await pathExists(r))throw Error(`Cannot create agent ${JSON.stringify(t)} because ${r} already exists.`);let{model:i,reasoning:a}=resolveInitAgentSettings(n),o=agentTemplateFiles(i,a);await Promise.all(Object.entries(o).map(([e,t])=>writeTextFile(join(r,e),t)))}async function convertScaffoldToAgentWorkspace(e,t,n){if(validateAgentNames(t),n.channelWebNextjs===!0)throw Error(`--channel-web-nextjs cannot be combined with --agents.`);let[r,...i]=t;await mkdir(join(e,`agents`,r),{recursive:!0}),await rename(join(e,`agent`),join(e,`agents`,r,`agent`));let a=join(e,`tsconfig.json`),o=await readFile(a,`utf8`);await writeTextFile(a,o.replace(`"agent/**/*.ts"`,`"agents/**/*.ts"`),{force:!0});for(let t of i)await writeWorkspaceAgent(e,t,n)}async function addAgentsToWorkspace(e,t,n,r,i=validateModelSlug){if((await findEveProjectContext(t))?.kind!==`workspace`)return!1;if(r.channelWebNextjs===!0)throw new InitTargetError(`workspace_input`,`--channel-web-nextjs is not supported when adding a workspace agent.`);let a=r.agents;if(n!==void 0&&a!==void 0)throw new InitTargetError(`workspace_input`,`Pass either an agent name or --agents, not both.`);if(a===void 0&&n!==void 0&&(a=[n]),a===void 0){if(!(process.stdin.isTTY&&process.stdout.isTTY))throw new InitTargetError(`workspace_input`,`This directory is an eve agent workspace. Pass an agent name, for example: eve init billing.`);a=[await createPrompter().text({message:`Name the new agent`})]}try{if(validateAgentNames(a),r.model!==void 0){let e=await i(t,r.model);if(e!==null)throw Error(e)}}catch(e){throw new InitTargetError(`workspace_input`,e instanceof Error?e.message:String(e))}for(let e of a){let n=join(t,`agents`,e);if(await pathExists(n))throw new InitTargetError(`target_conflict`,`Cannot create agent ${JSON.stringify(e)} because ${n} already exists.`)}for(let e of a)await writeWorkspaceAgent(t,e,r);return e.log(`${pc.green(`✓`)} Added ${a.length===1?`agent`:`agents`} ${a.map(e=>pc.bold(e)).join(`, `)}`),e.log(pc.dim(`$ eve dev --agent <name>`)),!0}export{addAgentsToWorkspace,convertScaffoldToAgentWorkspace,formatWorkspaceRootMutationWarning};
|
|
1
|
+
import{InitTargetError}from"./init-telemetry.js";import{mkdir,readFile,rename}from"node:fs/promises";import pc from"#compiled/picocolors/index.js";import{join}from"node:path";import{resolveInitAgentSettings}from"#shared/default-agent-model.js";import{createPrompter}from"#setup/prompter.js";import{findEveProjectContext}from"#internal/project-context.js";import{eveCliBanner}from"#cli/banner.js";import{formatNodeEngineOverrideWarning}from"#setup/node-engine.js";import{pathExists}from"#setup/path-exists.js";import{agentTemplateFiles}from"#setup/scaffold/create/project.js";import{assertValidPublicAgentName}from"#internal/agent-name.js";import{validateModelSlug}from"#setup/flows/model-source-change.js";import{writeTextFile}from"#setup/scaffold/files.js";function formatWorkspaceRootMutationWarning(e){let t=e.kind===`package-json`?`package.json`:`configuration`,n=e.nodeEngineOverride===void 0?``:` (${formatNodeEngineOverrideWarning(e.nodeEngineOverride)})`;return`Updated workspace root ${t} at ${e.path}${n}`}function validateAgentNames(e){if(e.length===0)throw Error(`--agents requires at least one agent name.`);let t=new Set;for(let n of e){if(assertValidPublicAgentName(n,`Agent`),t.has(n))throw Error(`Agent name ${JSON.stringify(n)} is repeated.`);t.add(n)}}async function writeWorkspaceAgent(e,t,n){let r=join(e,`agents`,t);if(await pathExists(r))throw Error(`Cannot create agent ${JSON.stringify(t)} because ${r} already exists.`);let{model:i,reasoning:a}=resolveInitAgentSettings(n),o=agentTemplateFiles(i,a);await Promise.all(Object.entries(o).map(([e,t])=>writeTextFile(join(r,e),t)))}async function convertScaffoldToAgentWorkspace(e,t,n){if(validateAgentNames(t),n.channelWebNextjs===!0)throw Error(`--channel-web-nextjs cannot be combined with --agents.`);let[r,...i]=t;await mkdir(join(e,`agents`,r),{recursive:!0}),await rename(join(e,`agent`),join(e,`agents`,r,`agent`));let a=join(e,`tsconfig.json`),o=await readFile(a,`utf8`);await writeTextFile(a,o.replace(`"agent/**/*.ts"`,`"agents/**/*.ts"`),{force:!0});for(let t of i)await writeWorkspaceAgent(e,t,n)}async function addAgentsToWorkspace(e,t,n,r,i=validateModelSlug){if((await findEveProjectContext(t))?.kind!==`workspace`)return!1;if(e.log(eveCliBanner()),r.channelWebNextjs===!0)throw new InitTargetError(`workspace_input`,`--channel-web-nextjs is not supported when adding a workspace agent.`);let a=r.agents;if(n!==void 0&&a!==void 0)throw new InitTargetError(`workspace_input`,`Pass either an agent name or --agents, not both.`);if(a===void 0&&n!==void 0&&(a=[n]),a===void 0){if(!(process.stdin.isTTY&&process.stdout.isTTY))throw new InitTargetError(`workspace_input`,`This directory is an eve agent workspace. Pass an agent name, for example: eve init billing.`);a=[await createPrompter().text({message:`Name the new agent`})]}try{if(validateAgentNames(a),r.model!==void 0){let e=await i(t,r.model);if(e!==null)throw Error(e)}}catch(e){throw new InitTargetError(`workspace_input`,e instanceof Error?e.message:String(e))}for(let e of a){let n=join(t,`agents`,e);if(await pathExists(n))throw new InitTargetError(`target_conflict`,`Cannot create agent ${JSON.stringify(e)} because ${n} already exists.`)}for(let e of a)await writeWorkspaceAgent(t,e,r);return e.log(`${pc.green(`✓`)} Added ${a.length===1?`agent`:`agents`} ${a.map(e=>pc.bold(e)).join(`, `)}`),e.log(pc.dim(`$ eve dev --agent <name>`)),!0}export{addAgentsToWorkspace,convertScaffoldToAgentWorkspace,formatWorkspaceRootMutationWarning};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initAgentDevHandoff,initAgentReadySummary}from"./agent-instructions.js";import{hasInteractiveTerminal}from"./preconditions.js";import{tryInitializeGit}from"./init-git.js";import{InitTargetError}from"./init-telemetry.js";import{addAgentsToWorkspace,convertScaffoldToAgentWorkspace,formatWorkspaceRootMutationWarning}from"./init-agent-workspace.js";import{createInstallDiagnostics,packageManagerInstallFailureCode}from"./init-install.js";import{reportExistingProjectChanges}from"./init-project.js";import{cleanupFreshInitTarget,workspaceFailureNote}from"./init-recovery.js";import{resolveInitTarget}from"./init-target.js";import{mkdtemp,readdir,rename,rm}from"node:fs/promises";import{createLogger,isLogLevelEnabled}from"#internal/logging.js";import pc from"#compiled/picocolors/index.js";import{basename,join,resolve}from"node:path";import{resolveInitAgentSettings}from"#shared/default-agent-model.js";import{ensureChannel,scaffoldBaseProject}from"#setup/scaffold/index.js";import{eveDevArguments,packageManagerInstallFailureMessage,packageManagerInstallSucceeded,resultSucceeded,runPackageManagerInstall,spawnPackageManager}from"#setup/primitives/index.js";import{performance}from"node:perf_hooks";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{EVE_WORDMARK,eveCliBanner}from"#cli/banner.js";import{formatElapsed}from"#cli/format-elapsed.js";import{startCliLiveRow}from"#cli/ui/live-row.js";import{detectInvokingPackageManager,detectPackageManager}from"#setup/package-manager.js";import{pathExists}from"#setup/path-exists.js";import{DEFAULT_EVE_PACKAGE_CONTRACT}from"#setup/scaffold/create/project.js";import{validateModelSlug}from"#setup/flows/model-source-change.js";import{addAgentToProject}from"#setup/scaffold/create/add-to-project.js";import{WizardCancelledError}from"#setup/step.js";import{isPackageManagerWorkspaceMember}from"#setup/scaffold/workspace-root.js";const defaultDependencies={addAgentToProject,detectInvokingPackageManager,detectPackageManager,ensureChannel,isCodingAgentLaunch,now:()=>performance.now(),runPackageManagerInstall,scaffoldBaseProject,hasInteractiveTerminal,spawnPackageManager,tryInitializeGit,validateModelSlug},EVE_INIT_PACKAGE_SPEC_ENV=`EVE_INIT_PACKAGE_SPEC`,initLog=createLogger(`init`);async function moveDirectoryContents(e,t){for(let n of await readdir(e))await rename(join(e,n),join(t,n))}function uniqueWorkspaceRootMutations(e){let t=new Map;for(let n of e){let e=`${n.kind}:${n.path}`,r=t.get(e);t.set(e,{...n,nodeEngineOverride:n.nodeEngineOverride??r?.nodeEngineOverride})}return[...t.values()]}async function addToExistingProject(e,t,n,r){if(t.channelWebNextjs===!0)throw Error("`--channel-web-nextjs` is not supported when adding an agent to an existing project. Run `eve add channel/web` from the project afterwards instead.");if(t.model!==void 0){let r=await n.validateModelSlug(e,t.model);if(r!==null)throw Error(r)}let i=await n.detectPackageManager(e),a=await n.addAgentToProject({projectRoot:e,...resolveInitAgentSettings(t),packageManager:i.kind,evePackage:r});return{configurationFilesChanged:a.configurationFilesChanged,dependenciesAdded:a.dependenciesAdded,filesWritten:a.filesWritten,packageManager:i.kind,nodeEngineOverride:a.nodeEngineOverride}}async function resolveScaffoldPackageManager(e,t){let n=await t.detectPackageManager(e);return n.source==="default"?t.detectInvokingPackageManager()??`pnpm`:n.kind}async function scaffoldProject(e,t,n,r,i,a,o,s){let c=resolve(e,`..`),l=!n&&await pathExists(e)&&(await readdir(e)).length===0;if(!n&&await pathExists(e)&&!l)throw Error(`Cannot create project because "${e}" already exists.`);let u=n&&s?void 0:await mkdtemp(join(c,`.eve-init-`)),d=[];try{let c=u??e;if(i.model!==void 0){let e=await a.validateModelSlug(c,i.model);if(e!==null)throw Error(e)}let f={projectName:u===void 0?`.`:n?basename(e):t,...resolveInitAgentSettings(i),evePackage:o,targetDirectory:c,overwriteExisting:s,workspaceProbeDirectory:e,packageManager:r,onWorkspaceRootMutation:e=>{d.push(e)}},p=await a.scaffoldBaseProject(f);return i.agents!==void 0&&await convertScaffoldToAgentWorkspace(p,i.agents,i),i.channelWebNextjs===!0&&await a.ensureChannel({projectRoot:p,kind:`web`,packageManager:r,force:s,workspaceProbeDirectory:e,configureVercelServices:!1,onWorkspaceRootMutation:e=>{d.push(e)}}),u!==void 0&&(n||l?await moveDirectoryContents(p,e):await rename(p,e)),{projectPath:e,workspaceRootMutations:uniqueWorkspaceRootMutations(d)}}finally{u!==void 0&&await rm(u,{recursive:!0,force:!0})}}async function runInitSteps(e){let{agentLaunched:t,dependencies:n,interactive:r,logger:i,options:a,parentDirectory:o,target:s,trackStep:c,trackTerminal:l}=e,u=isLogLevelEnabled(`debug`),d=await resolveInitTarget({parentDirectory:o,target:s}),f=resolveInitEvePackageOverride(),p=n.now(),m={animate:r&&!t&&!process.env.CI&&process.env.TERM!==`dumb`,elapsed:!0,logPhases:!0},h=startCliLiveRow(i,m),g=`scaffold`,_;try{let e=d.kind===`fresh`?`creating agent`:`adding agent`;c?.(g),h.update(d.kind===`fresh`?`Creating agent`:`Adding agent`),initLog.debug(e);let r=n.now(),o;if(d.kind===`fresh`){let e=await resolveScaffoldPackageManager(d.projectPath,n),t=isPackageManagerWorkspaceMember(e,d.projectPath),r;try{r=await scaffoldProject(d.projectPath,d.projectName,d.createInPlace,e,a,n,f,d.overwriteExisting)}catch(e){if(d.failurePolicy===`clear`){let n=await cleanupFreshInitTarget(d.projectPath,d.failurePolicy,d.preservedEntries),r=e instanceof Error?e.message:String(e),i=n?`eve restored "${d.projectPath}" to its original state.`:`eve could not completely clean "${d.projectPath}".`;throw Error(`${r}\n\n${i}${workspaceFailureNote(t)}`)}if(d.failurePolicy===`remove`&&t){let t=e instanceof Error?e.message:String(e);throw Error(`${t}${workspaceFailureNote(!0)}`)}throw e}o={failurePolicy:d.failurePolicy,kind:`created`,packageManager:e,preservedTargetEntries:d.preservedEntries,projectPath:r.projectPath,retryCommand:`eve init ${d.projectPath}`,workspaceMember:t,workspaceRootMutations:r.workspaceRootMutations}}else{let e=await addToExistingProject(d.projectPath,a,n,f);o=e.nodeEngineOverride===void 0?{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,packageManager:e.packageManager,projectPath:d.projectPath}:{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,nodeEngineOverride:e.nodeEngineOverride,packageManager:e.packageManager,projectPath:d.projectPath}}let s=n.now()-r;initLog.debug(`${e} done`,{ms:s}),o.kind===`added`&&(h.stop(),reportExistingProjectChanges(i,o),h=startCliLiveRow(i,m)),g=`install_dependencies`,c?.(g),h.update(`Installing dependencies`,o.packageManager),initLog.debug(`installing dependencies with ${o.packageManager}`);let l=n.now(),v=createInstallDiagnostics(),y=await n.runPackageManagerInstall(o.packageManager,o.projectPath,{autoApprove:!0,bypassMinimumReleaseAge:!0,progressDetails:!1,onOutput:e=>{v.append(e.text),u&&initLog.debug(e.text)}}),b=n.now()-l;if(!packageManagerInstallSucceeded(y)){_=packageManagerInstallFailureCode(y),initLog.debug(`dependency installation failed`,{ms:b}),h.stop();let{lines:e,truncated:t}=v.result();t&&i.error(`Earlier install output omitted; showing the final diagnostics.`);for(let t of e)i.error(t);if(e.length===0){let e=packageManagerInstallFailureMessage(y);e!==void 0&&i.error(e)}if(o.failurePolicy!==`preserve`){if(await cleanupFreshInitTarget(o.projectPath,o.failurePolicy,o.preservedTargetEntries)){let e=o.failurePolicy===`remove`?`eve removed the incomplete project at "${o.projectPath}".`:`eve restored "${o.projectPath}" to its original state.`,t=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies.\n\n${e}\n\nResolve the package-manager error above, then retry:\n ${o.retryCommand}${workspaceFailureNote(t)}`)}let e=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies, and eve could not completely clean "${o.projectPath}".\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in that directory. Or clean the target manually before rerunning eve init.${workspaceFailureNote(e)}`)}throw Error(`The eve agent was added, but dependency installation failed.\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in "${o.projectPath}".\n\nDo not rerun eve init; the agent is already configured.`)}if(initLog.debug(`dependencies installed`,{ms:b}),o.kind===`created`){g=`initialize_git`,c?.(g),h.update(`Initializing Git`),initLog.debug(`initializing git repository`);let e=await n.tryInitializeGit(o.projectPath);return{...o,elapsedMs:n.now()-p,agentLaunched:t,gitResult:e}}return{...o,elapsedMs:n.now()-p,agentLaunched:t}}catch(e){throw l?.(g,`error`,g===`install_dependencies`?_:void 0),e}finally{h.stop()}}async function runInitCommand(e,t,n,r,i=defaultDependencies,a,o){let s=await i.isCodingAgentLaunch(),c=i.hasInteractiveTerminal();c&&!s&&e.log(``),e.log(eveCliBanner()),a?.(`resolve_target`);let l;try{if(await addAgentsToWorkspace(e,t,n,r,i.validateModelSlug)){a?.(`handoff`),o?.(`handoff`,`completed`);return}l=await runInitSteps({agentLaunched:s,interactive:c,dependencies:i,logger:e,options:r,parentDirectory:t,target:n,trackStep:a,trackTerminal:o})}catch(e){if(e instanceof WizardCancelledError){o?.(`resolve_target`,`cancelled`);return}throw e instanceof InitTargetError&&o?.(`resolve_target`,`error`,e.failureCode),e}if(a?.(`handoff`),l.kind===`created`){e.log(`${pc.green(`✓`)} Created an ${EVE_WORDMARK} agent in ${pc.bold(l.projectPath)} ${pc.dim(`in ${formatElapsed(l.elapsedMs)}`)}`);for(let t of l.workspaceRootMutations)e.log(pc.yellow(`⚠ ${formatWorkspaceRootMutationWarning(t)}`))}else e.log(`${pc.green(`✓`)} Added an ${EVE_WORDMARK} agent to ${pc.bold(l.projectPath)} ${pc.dim(`in ${formatElapsed(l.elapsedMs)}`)}`);l.kind===`created`&&l.gitResult.kind===`failed`&&(e.error(pc.yellow(`Git initialization failed during ${l.gitResult.stage}: ${l.gitResult.reason}`)),l.gitResult.stage===`commit`&&e.error(pc.yellow(`The eve agent was created successfully. Git repository metadata and staged files were preserved at "${l.projectPath}"; the initial commit is optional.\n\nTo create it later, configure Git identity and run:\n git -C ${JSON.stringify(l.projectPath)} commit -m "Initial commit from eve"`)));let u=eveDevArguments(l.packageManager),d=[l.packageManager,...u].join(` `),f=initAgentDevHandoff({projectPath:l.projectPath,devCommand:d});if(l.agentLaunched){e.log(initAgentReadySummary(r.model,l.projectPath,{workspace:r.agents!==void 0})),e.log(f);return}if(r.nonInteractive||!c){e.log(f);return}let p=l.kind===`created`,m=[...l.packageManager===`pnpm`?[`--reporter=silent`]:[],...u,...p?[`--onboard`]:[]];if(e.log(``),!resultSucceeded(await i.spawnPackageManager(l.packageManager,l.projectPath,m)))throw Error(`Development server exited unsuccessfully in "${l.projectPath}".`)}function resolveInitEvePackageOverride(){let e=process.env[EVE_INIT_PACKAGE_SPEC_ENV]?.trim();if(e!==void 0&&e.length!==0)return{nodeEngine:DEFAULT_EVE_PACKAGE_CONTRACT.nodeEngine,version:e}}export{EVE_INIT_PACKAGE_SPEC_ENV,runInitCommand};
|
|
1
|
+
import{initAgentDevHandoff,initAgentReadySummary}from"./agent-instructions.js";import{hasInteractiveTerminal}from"./preconditions.js";import{tryInitializeGit}from"./init-git.js";import{InitTargetError}from"./init-telemetry.js";import{addAgentsToWorkspace,convertScaffoldToAgentWorkspace,formatWorkspaceRootMutationWarning}from"./init-agent-workspace.js";import{createInstallDiagnostics,packageManagerInstallFailureCode}from"./init-install.js";import{reportExistingProjectChanges}from"./init-project.js";import{cleanupFreshInitTarget,workspaceFailureNote}from"./init-recovery.js";import{resolveInitTarget}from"./init-target.js";import{mkdtemp,readdir,rename,rm}from"node:fs/promises";import{createLogger,isLogLevelEnabled}from"#internal/logging.js";import pc from"#compiled/picocolors/index.js";import{basename,join,resolve}from"node:path";import{resolveInitAgentSettings}from"#shared/default-agent-model.js";import{ensureChannel,scaffoldBaseProject}from"#setup/scaffold/index.js";import{eveDevArguments,packageManagerInstallFailureMessage,packageManagerInstallSucceeded,resultSucceeded,runPackageManagerInstall,spawnPackageManager}from"#setup/primitives/index.js";import{performance}from"node:perf_hooks";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{EVE_WORDMARK,eveCliBanner}from"#cli/banner.js";import{formatElapsed}from"#cli/format-elapsed.js";import{startCliLiveRow}from"#cli/ui/live-row.js";import{detectInvokingPackageManager,detectPackageManager}from"#setup/package-manager.js";import{pathExists}from"#setup/path-exists.js";import{DEFAULT_EVE_PACKAGE_CONTRACT}from"#setup/scaffold/create/project.js";import{validateModelSlug}from"#setup/flows/model-source-change.js";import{addAgentToProject}from"#setup/scaffold/create/add-to-project.js";import{WizardCancelledError}from"#setup/step.js";import{isPackageManagerWorkspaceMember}from"#setup/scaffold/workspace-root.js";const defaultDependencies={addAgentToProject,detectInvokingPackageManager,detectPackageManager,ensureChannel,isCodingAgentLaunch,now:()=>performance.now(),runPackageManagerInstall,scaffoldBaseProject,hasInteractiveTerminal,spawnPackageManager,tryInitializeGit,validateModelSlug},EVE_INIT_PACKAGE_SPEC_ENV=`EVE_INIT_PACKAGE_SPEC`,initLog=createLogger(`init`);async function moveDirectoryContents(e,t){for(let n of await readdir(e))await rename(join(e,n),join(t,n))}function uniqueWorkspaceRootMutations(e){let t=new Map;for(let n of e){let e=`${n.kind}:${n.path}`,r=t.get(e);t.set(e,{...n,nodeEngineOverride:n.nodeEngineOverride??r?.nodeEngineOverride})}return[...t.values()]}async function addToExistingProject(e,t,n,r){if(t.channelWebNextjs===!0)throw Error("`--channel-web-nextjs` is not supported when adding an agent to an existing project. Run `eve add channel/web` from the project afterwards instead.");if(t.model!==void 0){let r=await n.validateModelSlug(e,t.model);if(r!==null)throw Error(r)}let i=await n.detectPackageManager(e),a=await n.addAgentToProject({projectRoot:e,...resolveInitAgentSettings(t),packageManager:i.kind,evePackage:r});return{configurationFilesChanged:a.configurationFilesChanged,dependenciesAdded:a.dependenciesAdded,filesWritten:a.filesWritten,packageManager:i.kind,nodeEngineOverride:a.nodeEngineOverride}}async function resolveScaffoldPackageManager(e,t){let n=await t.detectPackageManager(e);return n.source==="default"?t.detectInvokingPackageManager()??`pnpm`:n.kind}async function scaffoldProject(e,t,n,r,i,a,o,s){let c=resolve(e,`..`),l=!n&&await pathExists(e)&&(await readdir(e)).length===0;if(!n&&await pathExists(e)&&!l)throw Error(`Cannot create project because "${e}" already exists.`);let u=n&&s?void 0:await mkdtemp(join(c,`.eve-init-`)),d=[];try{let c=u??e;if(i.model!==void 0){let e=await a.validateModelSlug(c,i.model);if(e!==null)throw Error(e)}let f={projectName:u===void 0?`.`:n?basename(e):t,...resolveInitAgentSettings(i),evePackage:o,targetDirectory:c,overwriteExisting:s,workspaceProbeDirectory:e,packageManager:r,onWorkspaceRootMutation:e=>{d.push(e)}},p=await a.scaffoldBaseProject(f);return i.agents!==void 0&&await convertScaffoldToAgentWorkspace(p,i.agents,i),i.channelWebNextjs===!0&&await a.ensureChannel({projectRoot:p,kind:`web`,packageManager:r,force:s,workspaceProbeDirectory:e,configureVercelServices:!1,onWorkspaceRootMutation:e=>{d.push(e)}}),u!==void 0&&(n||l?await moveDirectoryContents(p,e):await rename(p,e)),{projectPath:e,workspaceRootMutations:uniqueWorkspaceRootMutations(d)}}finally{u!==void 0&&await rm(u,{recursive:!0,force:!0})}}async function runInitSteps(e){let{agentLaunched:t,dependencies:n,interactive:r,logger:i,options:a,parentDirectory:o,target:s,trackStep:c,trackTerminal:l}=e,u=isLogLevelEnabled(`debug`),d=await resolveInitTarget({parentDirectory:o,target:s}),f=resolveInitEvePackageOverride(),p=n.now(),m={animate:r&&!t&&!process.env.CI&&process.env.TERM!==`dumb`,elapsed:!0,logPhases:!0},h=startCliLiveRow(i,m),g=`scaffold`,_;try{let e=d.kind===`fresh`?`creating agent`:`adding agent`;c?.(g),h.update(d.kind===`fresh`?`Creating agent`:`Adding agent`),initLog.debug(e);let r=n.now(),o;if(d.kind===`fresh`){let e=await resolveScaffoldPackageManager(d.projectPath,n),t=isPackageManagerWorkspaceMember(e,d.projectPath),r;try{r=await scaffoldProject(d.projectPath,d.projectName,d.createInPlace,e,a,n,f,d.overwriteExisting)}catch(e){if(d.failurePolicy===`clear`){let n=await cleanupFreshInitTarget(d.projectPath,d.failurePolicy,d.preservedEntries),r=e instanceof Error?e.message:String(e),i=n?`eve restored "${d.projectPath}" to its original state.`:`eve could not completely clean "${d.projectPath}".`;throw Error(`${r}\n\n${i}${workspaceFailureNote(t)}`)}if(d.failurePolicy===`remove`&&t){let t=e instanceof Error?e.message:String(e);throw Error(`${t}${workspaceFailureNote(!0)}`)}throw e}o={failurePolicy:d.failurePolicy,kind:`created`,packageManager:e,preservedTargetEntries:d.preservedEntries,projectPath:r.projectPath,retryCommand:`eve init ${d.projectPath}`,workspaceMember:t,workspaceRootMutations:r.workspaceRootMutations}}else{let e=await addToExistingProject(d.projectPath,a,n,f);o=e.nodeEngineOverride===void 0?{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,packageManager:e.packageManager,projectPath:d.projectPath}:{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,nodeEngineOverride:e.nodeEngineOverride,packageManager:e.packageManager,projectPath:d.projectPath}}let s=n.now()-r;initLog.debug(`${e} done`,{ms:s}),o.kind===`added`&&(h.stop(),reportExistingProjectChanges(i,o),h=startCliLiveRow(i,m)),g=`install_dependencies`,c?.(g),h.update(`Installing dependencies`,o.packageManager),initLog.debug(`installing dependencies with ${o.packageManager}`);let l=n.now(),v=createInstallDiagnostics(),y=await n.runPackageManagerInstall(o.packageManager,o.projectPath,{autoApprove:!0,bypassMinimumReleaseAge:!0,progressDetails:!1,onOutput:e=>{v.append(e.text),u&&initLog.debug(e.text)}}),b=n.now()-l;if(!packageManagerInstallSucceeded(y)){_=packageManagerInstallFailureCode(y),initLog.debug(`dependency installation failed`,{ms:b}),h.stop();let{lines:e,truncated:t}=v.result();t&&i.error(`Earlier install output omitted; showing the final diagnostics.`);for(let t of e)i.error(t);if(e.length===0){let e=packageManagerInstallFailureMessage(y);e!==void 0&&i.error(e)}if(o.failurePolicy!==`preserve`){if(await cleanupFreshInitTarget(o.projectPath,o.failurePolicy,o.preservedTargetEntries)){let e=o.failurePolicy===`remove`?`eve removed the incomplete project at "${o.projectPath}".`:`eve restored "${o.projectPath}" to its original state.`,t=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies.\n\n${e}\n\nResolve the package-manager error above, then retry:\n ${o.retryCommand}${workspaceFailureNote(t)}`)}let e=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies, and eve could not completely clean "${o.projectPath}".\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in that directory. Or clean the target manually before rerunning eve init.${workspaceFailureNote(e)}`)}throw Error(`The eve agent was added, but dependency installation failed.\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in "${o.projectPath}".\n\nDo not rerun eve init; the agent is already configured.`)}if(initLog.debug(`dependencies installed`,{ms:b}),o.kind===`created`){g=`initialize_git`,c?.(g),h.update(`Initializing Git`),initLog.debug(`initializing git repository`);let e=await n.tryInitializeGit(o.projectPath);return{...o,elapsedMs:n.now()-p,agentLaunched:t,gitResult:e}}return{...o,elapsedMs:n.now()-p,agentLaunched:t}}catch(e){throw l?.(g,`error`,g===`install_dependencies`?_:void 0),e}finally{h.stop()}}async function runInitCommand(e,t,n,r,i=defaultDependencies,a,o){let s=await i.isCodingAgentLaunch(),c=i.hasInteractiveTerminal(),l=c&&!s&&!r.nonInteractive;c&&!s&&e.log(``),a?.(`resolve_target`);let u;try{if(await addAgentsToWorkspace(e,t,n,r,i.validateModelSlug)){a?.(`handoff`),o?.(`handoff`,`completed`);return}l||e.log(eveCliBanner()),u=await runInitSteps({agentLaunched:s,interactive:c,dependencies:i,logger:e,options:r,parentDirectory:t,target:n,trackStep:a,trackTerminal:o})}catch(e){if(e instanceof WizardCancelledError){o?.(`resolve_target`,`cancelled`);return}throw e instanceof InitTargetError&&o?.(`resolve_target`,`error`,e.failureCode),e}if(a?.(`handoff`),u.kind===`created`){e.log(`${pc.green(`✓`)} Created an ${EVE_WORDMARK} agent in ${pc.bold(u.projectPath)} ${pc.dim(`in ${formatElapsed(u.elapsedMs)}`)}`);for(let t of u.workspaceRootMutations)e.log(pc.yellow(`⚠ ${formatWorkspaceRootMutationWarning(t)}`))}else e.log(`${pc.green(`✓`)} Added an ${EVE_WORDMARK} agent to ${pc.bold(u.projectPath)} ${pc.dim(`in ${formatElapsed(u.elapsedMs)}`)}`);u.kind===`created`&&u.gitResult.kind===`failed`&&(e.error(pc.yellow(`Git initialization failed during ${u.gitResult.stage}: ${u.gitResult.reason}`)),u.gitResult.stage===`commit`&&e.error(pc.yellow(`The eve agent was created successfully. Git repository metadata and staged files were preserved at "${u.projectPath}"; the initial commit is optional.\n\nTo create it later, configure Git identity and run:\n git -C ${JSON.stringify(u.projectPath)} commit -m "Initial commit from eve"`)));let d=eveDevArguments(u.packageManager),f=[u.packageManager,...d].join(` `),p=initAgentDevHandoff({projectPath:u.projectPath,devCommand:f});if(u.agentLaunched){e.log(initAgentReadySummary(r.model,u.projectPath,{workspace:r.agents!==void 0})),e.log(p);return}if(!l){e.log(p);return}let m=u.kind===`created`,h=[...u.packageManager===`pnpm`?[`--reporter=silent`]:[],...d,...m?[`--onboard`]:[]];if(e.log(``),!resultSucceeded(await i.spawnPackageManager(u.packageManager,u.projectPath,h)))throw Error(`Development server exited unsuccessfully in "${u.projectPath}".`)}function resolveInitEvePackageOverride(){let e=process.env[EVE_INIT_PACKAGE_SPEC_ENV]?.trim();if(e!==void 0&&e.length!==0)return{nodeEngine:DEFAULT_EVE_PACKAGE_CONTRACT.nodeEngine,version:e}}export{EVE_INIT_PACKAGE_SPEC_ENV,runInitCommand};
|
|
@@ -63,7 +63,8 @@ export type AgentTUIToolApprovalRequest = {
|
|
|
63
63
|
approvalId: string;
|
|
64
64
|
toolCallId: string;
|
|
65
65
|
toolName: string;
|
|
66
|
-
|
|
66
|
+
/** The server's question for this approval, such as `Approve Deploy release?`. */
|
|
67
|
+
prompt: string;
|
|
67
68
|
input: unknown;
|
|
68
69
|
context?: AgentTUIInputContext;
|
|
69
70
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{PROMPT_COMMANDS,formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{failureKey,formatFailureDetail,formatFailureHint,formatFailureMessage,interruptedError,isInterruptedError,localFailureHint}from"./errors.js";import{conversationView,isWorking,tuiSessionReducer}from"./conversation-view.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{createMcpConnectionStatusTracker}from"./mcp-connection-status.js";import{describeRemoteAuthCompletedMutations}from"./remote-auth-result.js";import{createRemoteConnectionController}from"./remote-connection.js";import{prepareRemoteTuiAccess}from"./remote-startup.js";import{isTerminalToolCallPart}from"./terminal-tool-part.js";import{userText}from"./transcript-parts.js";import{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,normalizeLocalModelEndpoint,orderedSetupIssues}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import{isTaskRetryRefusal}from"#protocol/task-tools.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{inspectApplication}from"#services/inspect-application.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{toErrorMessage}from"#shared/errors.js";import{probeAgentInfo}from"#services/dev-client/agent-info-probe.js";import{openConversationInputs}from"#client/conversation-state.js";import{EveAgentStore,attachEveAgentStore,detachEveAgentStore}from"#client/eve-agent-store.js";import{isAbortError}from"#client/eve-agent-store-helpers.js";import{normalizeActionRequest,normalizeActionResult}from"#client/message-action-parts.js";import{renderApplicationInfo}from"#cli/commands/info.js";import{createDevelopmentRuntimeArtifactRefresher}from"#services/dev-client.js";function authIssueForStatus(e){if(e===`logged-out`)return LOGIN_SETUP_ISSUE;if(e===`cli-missing`)return CLI_MISSING_SETUP_ISSUE}var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=!1;#m;#h;#g=!0;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E=!1;#D;#O=!1;#k=new AbortController;#A=!1;#j=0;#M=0;#N=[];#P;#F;#I;#L;#R;#z=new Set;#B=[];#V;#H=new Set;#U;#W=new Set;#G=new Set;#K;constructor(e){if(this.#e=e.client,e.lifecycle!==void 0&&(this.#K=e.lifecycle),e.diagnostics!==void 0&&(this.#r=e.diagnostics),this.#n=createRenderer(e),this.#t=new EveAgentStore({client:e.client,followSubagents:!0,reducer:tuiSessionReducer}),this.#t.setCallbacks({onEvent:e=>this.#Le(e),onSessionChange:e=>{e!==void 0&&this.#n.setSessionId?.(e.sessionId)},prepareSend:e=>this.#ee(e)}),this.#i=e.name??`eve`,this.#y=e.withExclusiveTerminal,this.#a=e.formatTransportError??toErrorMessage,e.initialInput!==void 0&&(this.#l=e.initialInput),e.startup!==void 0&&(this.#u=e.startup),this.#f=e.onboard===!0,this.#m=e.onOnboardingStep,this.#h=e.onOnboardingTerminal,e.appRoot!==void 0){this.#c=e.appRoot;let t={appRoot:e.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};e.detectProjectIdentity!==void 0&&(t.detectIdentity=e.detectProjectIdentity),this.#F=createVercelStatusTracker(t),e.probeMcpConnection!==void 0&&(this.#I=createMcpConnectionStatusTracker({onChange:()=>{},probe:e.probeMcpConnection}))}e.promptCommandHandler!==void 0&&(this.#_=e.promptCommandHandler),this.#v=e.availablePromptCommands??PROMPT_COMMANDS,e.remote!==void 0&&(this.#x=e.remote.runAuthFlow,this.#b=createRemoteConnectionController({client:this.#e,credentials:e.remote.credentials,target:e.remote.target,onChange:e=>this.#n.setRemoteConnectionStatus?.(e),resolveOidcToken:e.remote.resolveOidcToken,resolveDeployment:e.remote.resolveDeployment})),this.#S=e.bootDetections??BOOT_DETECTIONS,this.#C=e.getVercelAuthStatus??getVercelAuthStatus,this.#w=e.inspectApplication??inspectApplication,e.onBootProgress!==void 0&&(this.#T=e.onBootProgress),e.serverUrl!==void 0&&(this.#s=e.serverUrl),e.serverUrl!==void 0&&e.remote===void 0&&(this.#o=createDevelopmentRuntimeArtifactRefresher({serverUrl:e.serverUrl}))}async#q(){if(this.#s===void 0){this.#X(),this.#f||await this.#ve(void 0);return}let e;if(this.#b!==void 0){let t=await this.#b.check();t.state===`ready`&&(e=t.info)}else{let t=this.#e;if(t!==void 0)try{let n=await devBootPhase(`connecting to agent`,()=>probeAgentInfo({client:t,timeoutMs:2e3}),this.#T);n.kind===`ready`&&(e=n.info)}catch{e=void 0}}this.#X();let t=this.#Y(e);this.#f||await this.#ve(t)}#J(){let e=this.#u?.finish();return this.#d=e?.queuedPrompt,e?.draft??this.#l}#Y(e){let t=this.#c===void 0?e:normalizeLocalModelEndpoint(e,process.env);this.#L=t;let n=this.#s;if(n===void 0||this.#g)return t;let r={name:this.#i,serverUrl:n,localDevelopment:this.#c!==void 0};return t!==void 0&&(r.info=t),this.#n.renderAgentHeader?.(r),t}#X(){let e=this.#T;this.#T=void 0,e?.({type:`before-first-paint`})}async run(){let onStop=()=>this.#n.requestInterrupt?.();this.#K?.signal.aborted===!0?onStop():this.#K?.signal.addEventListener(`abort`,onStop,{once:!0});let e=this.#t.subscribe(()=>this.#te());attachEveAgentStore(this.#t);try{await this.#Z()}catch(e){if(!isInterruptedError(e))throw e}finally{this.#K?.signal.removeEventListener(`abort`,onStop),this.#E=!0,this.#k.abort(),this.#R?.abort(),e(),detachEveAgentStore(this.#t),this.#n.shutdown?.(),this.#F?.dispose(),this.#I?.dispose(),this.#b?.dispose()}}async#Z(){let e=this.#i,t;this.#n.setStartupPhase?.(`starting`),await this.#q(),this.#F?.refreshIdentity(),this.#I?.refresh();let n=(this.#f||this.#L?.agent.model.endpoint?.kind===`gateway`&&!this.#L.agent.model.endpoint.connected)&&this.#c!==void 0&&this.#_!==void 0&&this.#n.setupFlow!==void 0,r;if(this.#b!==void 0&&this.#n.setupFlow!==void 0){let e=await prepareRemoteTuiAccess({connection:this.#b,renderer:this.#n.setupFlow,signal:this.#K?.signal,runAuthFlow:this.#x});if(e?.kind===`authenticated`){let e=this.#b.current().connection;e.state===`ready`&&this.#Y(e.info)}else e?.kind===`failed`||e?.kind===`unavailable`?r={failed:!0,message:e.kind===`failed`?e.message:e.failure.message}:e?.kind===`cancelled`&&(r={cancelled:!0},e.completedMutations.length>0&&(r.message=`Completed before cancellation: ${describeRemoteAuthCompletedMutations(e.completedMutations).join(`, `)}.`))}n&&(this.#n.setStartupPhase?.(`connecting`),r=await this.#De(e));let i=this.#J();for(r?.cancelled||r?.failed?i=[this.#d,i].filter(Boolean).join(`
|
|
2
2
|
|
|
3
3
|
`)||void 0:t=this.#d,this.#g=!1,this.#Y(this.#L),this.#ye(),this.#n.setStartupPhase?.(void 0),(!n||r?.cancelled||r?.failed)&&r?.message!==void 0&&this.#Se({kind:`result`,message:r.message});this.#K?.signal.aborted!==!0&&this.#n.exitRequested?.()!==!0;){if(this.#t.snapshot.data.sessionFailed){this.#ce();continue}if(this.#ae().length>0){await this.#oe(e);continue}let n=isWorking(this.#t.snapshot.status)?void 0:this.#B.shift();if(n!==void 0){this.#V=n;try{await this.#_e(n)}finally{this.#V=void 0}continue}if(t===void 0){let n=await this.#me({title:e,initialDraft:i});if(i=void 0,n===void 0)continue;if(n.type===`cancel`){this.#de();continue}if(n.type===`interrupt`){this.#ce(`Stopped following the turn and started a new session. Earlier context was cleared; the interrupted turn may still be running on the server.`);continue}t=n.text}let r=t;t=void 0;let a=parsePromptCommand(r);if(a===null){this.#$(r);continue}let o=await this.#Q(a,e);if(o===`exit`)return;o!==void 0&&(i=o.draft)}}async#Q(e,t){switch(e.type){case`exit`:return this.#Se({kind:`dismiss`}),this.#K?.requestStop(),`exit`;case`cancel`:{let e=isWorking(this.#t.snapshot.status);e&&this.#de(),this.#Se({kind:`result`,summary:e?`Cancellation requested`:`No active turn to cancel`});return}case`new`:await this.#pe();return;case`compact`:await this.#fe({absent:`No active session to compact`,accepted:`Compaction requested`,failed:`Couldn't compact the session`,invoke:()=>this.#t.compact()});return;case`clear`:await this.#fe({absent:`No active session to clear`,accepted:`Session context cleared`,failed:`Couldn't clear the session`,invoke:()=>this.#t.clear()});return;case`help`:{if(this.#n.choosePromptCommand===void 0){this.#Se({kind:`result`,message:formatPromptCommandHelp(this.#v)});return}let e=await this.#n.choosePromptCommand(this.#v);return e===void 0?void 0:{draft:e}}case`info`:await this.#Ae();return;case`loglevel`:{let t=this.#je(e.argument),n=t.startsWith(`/loglevel is not available`)||t.startsWith(`Unknown log level`);this.#Se(n?{kind:`result`,message:t}:{kind:`result`,summary:t});return}case`traces`:await this.#ke(e.argument);return;case`extension`:await this.#Ee(e,t,{trigger:`command`});return}}#$(e){let t=this.#t.snapshot,n=isWorking(t.status);this.#D=e,n||(this.#O=!1);let r=n?{message:e,turnPolicy:`steer`}:t.session===void 0?{message:e}:{message:e,turnPolicy:`queue`};this.#t.send(r).catch(e=>{this.#E||isAbortError(e)||this.#n.renderError?.(n?`Steering failed`:`Error`,this.#a(e))})}async#ee(e){return e.turnPolicy===`steer`?e:(this.#o!==void 0&&await this.#o.refresh({inputResponses:e.inputResponses,message:typeof e.message==`string`?e.message:void 0,onRuntimeArtifactsChanged:()=>this.#Fe()}),e.message!==void 0&&this.#n.flushDelayedDevBuildErrors?.(),e)}#te(){let e=this.#t.snapshot;this.#n.renderConversation?.(conversationView(e,this.#c===void 0?void 0:localFailureHint)),this.#re(e.error,e.data.sessionFailed),this.#Ie(e.conversation),this.#ie(e.conversation),this.#ge(e.conversation),this.#ne(e.conversation),(e.data.sessionFailed||this.#ae().length>0||!isWorking(e.status)&&this.#B.length>0)&&this.#R?.abort()}#ne(e){let t=this.#D;if(t===void 0)return;let n=e.messages.findLast(e=>e.role===`user`),r=n?.metadata?.turnId;if(n===void 0||r===void 0||userText(n)!==t)return;let i=e.turns[r]?.status;i!==void 0&&i!==`active`&&(this.#D=void 0,i===`cancelled`&&!this.#O&&this.#n.restoreDraft?.(t))}#re(e,t){e!==void 0&&e!==this.#U&&(this.#U=e,!t&&(this.#b?.reportFailure(e),this.#n.renderError?.(`Error`,this.#a(e))))}#ie(e){!this.#f||this.#p||!e.messages.some(e=>e.role===`assistant`&&e.parts.some(e=>e.type===`text`&&e.text.length>0))||(this.#p=!0,this.#m?.({flow:`onboarding`,step:`first_response`}))}#ae(){return openConversationInputs(this.#t.snapshot.conversation).filter(e=>!this.#z.has(e.request.requestId))}async#oe(e){for(let t=0;;t+=1){let n=this.#ae(),r=n[0];if(r===void 0)return;let i=inputContext(r,t+1,t+n.length),a=await this.#se(r.request,i,e);if(a===void 0){this.#z.add(r.request.requestId);continue}this.#t.send({inputResponses:[a]}).catch(e=>{this.#E||isAbortError(e)||this.#n.renderError?.(`Error`,this.#a(e))})}}async#se(e,t,n){if(e.kind===`tool-approval`){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);let r=await this.#n.readToolApproval(toAgentTUIToolApprovalRequest(e,t),{title:n});return{requestId:e.requestId,optionId:r.approved?`approve`:`cancel`}}if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);let r=await this.#n.readInputQuestion(toAgentTUIInputQuestion(e,t),{title:n});if(r===void 0)return;let i={requestId:e.requestId};return r.optionId!==void 0&&(i.optionId=r.optionId),r.text!==void 0&&(i.text=r.text),i}#ce(e){this.#n.renderSessionBoundary===void 0?e===void 0&&this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`):this.#n.renderSessionBoundary(),e!==void 0&&this.#n.renderNotice?.(e),this.#le()}#le(){this.#t.reset(),this.#ue()}#ue(){this.#z.clear(),this.#H.clear(),this.#W.clear(),this.#o?.clear()}#de(){this.#O=!0,this.#t.cancel().catch(e=>{this.#n.renderNotice?.(`Couldn't cancel the turn: ${toErrorMessage(e)}`)})}async#fe(e){if(this.#t.snapshot.session===void 0){this.#Se({kind:`result`,summary:e.absent});return}try{if((await e.invoke()).status!==`accepted`){this.#Se({kind:`result`,summary:e.absent});return}this.#Se({kind:`result`,summary:e.accepted})}catch(t){this.#Se({kind:`result`,message:toErrorMessage(t),summary:e.failed})}}async#pe(){try{await this.#t.retire()}catch(e){this.#Se({kind:`result`,message:`Couldn't reset the session: ${toErrorMessage(e)}`});return}this.#ue(),this.#n.reset?.(),this.#Se({kind:`dismiss`})}async#me(e){if(!this.#n.readInput)throw Error(`The renderer does not support prompt input.`);let t=new AbortController;this.#R=t;try{let n=await this.#he(this.#n.readInput({...e,signal:t.signal}));if(n===void 0&&!t.signal.aborted)throw interruptedError();return n}finally{this.#R===t&&(this.#R=void 0)}}async#he(e){let t=this.#o;if(t===void 0)return await e;let n=!1,r=!1,i,a=!1,o=0,refresh=async()=>{if(!(n||r)){r=!0;try{await t.refreshIdle({onRuntimeArtifactsChanged:()=>this.#Fe()}),this.#c!==void 0&&this.#L===void 0&&!a&&(a=!0,this.#Ne().finally(()=>{a=!1}));let e=this.#L?.agent.model.endpoint,n=e?.kind===`chatgpt`&&(e.state===`signed-out`||e.state===`reauth-required`),r=Date.now();n&&r-o>=5e3&&(o=r,this.#Ne())}finally{r=!1}}},startRefresh=()=>{if(n||r)return;let e=refresh().finally(()=>{i===e&&(i=void 0)});i=e};startRefresh();let s=setInterval(()=>{startRefresh()},500);s.unref?.();try{return await e}finally{n=!0,clearInterval(s),await i}}#ge(e){if(this.#c!==void 0)for(let{callId:t,address:n}of registryHandoffs(e))this.#H.has(t)||(this.#H.add(t),!(this.#V===n||this.#B.includes(n))&&this.#B.push(n))}async#_e(e){this.#n.renderCommandInvocation?.(`/add ${e}`),await this.#Ee({type:`extension`,name:`add`,argument:e},`Add to your agent`,{trigger:`command`})}async#ve(e){if(this.#c===void 0)return;let t={appRoot:this.#c,env:process.env};e!==void 0&&(t.info=e),this.#N=await detectSetupIssues(t,this.#S),this.#n.renderSetupWarning!==void 0&&(this.#ye(),this.#be())}#ye(){if(this.#g)return;let e=orderedSetupIssues(this.#N,this.#P);e.length>0?this.#n.renderSetupWarning?.(formatSetupIssuesLine(e)):this.#n.clearSetupWarning?.()}async#be(){let e=this.#c;if(e===void 0||process.env.EVE_MODEL_CONNECTION!==`ai-gateway-project`)return;let t;try{t=await this.#C(e,{signal:this.#k.signal})}catch{return}this.#E||this.#A||(this.#P=authIssueForStatus(t),this.#ye())}async#xe(e){let t=this.#c;if(t===void 0||this.#n.renderSetupWarning===void 0)return;let n=++this.#j,r={appRoot:t,env:process.env};e!==void 0&&(r.info=e);try{let[e,i]=await Promise.all([detectSetupIssues(r,this.#S),process.env.EVE_MODEL_CONNECTION===`ai-gateway-project`?this.#C(t,{signal:this.#k.signal}):void 0]);if(this.#E||n!==this.#j)return;this.#N=e,this.#P=i===void 0?void 0:authIssueForStatus(i),this.#ye()}catch{return}}#Se(e){if(this.#n.finishCommand!==void 0){this.#n.finishCommand(e);return}if(e.kind===`result`){let t=[e.summary,e.message].filter(Boolean).join(`
|
|
4
|
-
`);t!==``&&this.#n.renderNotice?.(t)}}async#Ce(e,t){let n=this.#_;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r=this.#L?.agent.model.endpoint,i={...t,renderer:this.#n,settleOutcome:e=>this.#Te(e),chatGptAccountLabel:r?.kind===`chatgpt`&&r.state===`ready`?r.accountLabel:void 0,withExclusiveTerminal:this.#y},a=this.#I?.current(),o=a!==void 0&&Object.keys(a).length>0?{...i,disabledConnectionReasons:a}:i;return await n.handle(e,o)}async#we(e){if(e?.kind===`model-access-changed`){this.#F?.applyEffect({kind:`refresh-identity`}),this.#A=!0,await this.#Me(e);return}e!==void 0&&(this.#F?.applyEffect(e),this.#A=!0,this.#xe(this.#L))}async#Te(e){if(e.effect===void 0)return e;let t=e.effect.kind===`model-access-changed`&&e.effect.reload?setTimeout(()=>{this.#g&&this.#n.setStartupPhase?.(`updating`),this.#n.setupFlow?.setStatus(`Loading selected model…`)},150):void 0;try{await this.#we(e.effect);let{effect:t,...n}=e;return n}catch{return{failed:!0,message:`Settings were saved, but the agent could not reload. Retry the command or restart eve dev.`}}finally{clearTimeout(t)}}async#Ee(e,t,n){let r=await this.#Ce(e,{...n,title:t}),i=r===void 0?void 0:await this.#Te(r);return!(n.suppressSuccessfulTranscript===!0&&i?.failed!==!0||n.suppressCancelledTranscript===!0&&i?.cancelled===!0)&&n.trigger!==`startup`&&(i===void 0?this.#Se({kind:`result`}):this.#Se({kind:`result`,message:i.message,summary:i.summary})),this.#Oe(),i}async#De(e){this.#m?.({flow:`onboarding`,step:`model_provider`});let t=await this.#Ee({type:`extension`,name:`login`,argument:``},e,{trigger:`startup`,initialModelStep:`provider`});return!t?.cancelled&&t?.failed!==!0&&this.#m?.({flow:`onboarding`,step:`connection_ready`}),this.#h?.({flow:`onboarding`,step:`model_provider`,result:t?.cancelled?`cancelled`:t?.failed===!0?`error`:`completed`}),t}#Oe(){if(this.#g)return;let e=this.#b?.current().connection;e?.state===`ready`&&e.info!==this.#L&&(this.#L=e.info,this.#s!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#i,serverUrl:this.#s}))}async#ke(e){if(this.#c===void 0||this.#n.traceViewer===void 0){this.#Se({kind:`result`,message:`/traces is only available in local dev sessions.`});return}try{await this.#n.traceViewer.open({appRoot:this.#c,sessionId:this.#t.snapshot.session?.sessionId,reference:e===``?void 0:e})}catch(e){if(isInterruptedError(e))return;throw e}finally{this.#Se({kind:`dismiss`})}}async#Ae(){let e=this.#c;if(e===void 0){this.#Se({kind:`result`,message:`/info is only available in local dev sessions.`});return}try{let t=renderApplicationInfo(await this.#w(e));this.#n.showInfoPanel===void 0?this.#Se({kind:`result`,message:t}):await this.#n.showInfoPanel(t)}catch(e){this.#Se({kind:`result`,message:`Couldn't inspect the application: ${toErrorMessage(e)}`})}}#je(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 none|error|warn|debug|all — 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 none, error, warn, debug, or all.`;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`error`:return`Showing errors.`;case`warn`:return`Showing warnings and errors.`;case`debug`:return`Showing all severity-tagged logs.`;case`all`:return`Showing all logs.`}}async#Me(e){let t=this.#c;t!==void 0&&(++this.#M,++this.#j,await loadDevelopmentEnvironmentFiles(t),e.reload&&await this.#o?.refreshAfterSourceChange({}),e.model&&this.#L?this.#Y({...this.#L,agent:{...this.#L.agent,model:{...this.#L.agent.model,...e.model}}}):this.#Y(this.#L),this.#N=[],this.#P=void 0,this.#ye(),this.#Ne())}async#Ne(e=!1){let t=this.#L,n=++this.#M,r=await this.#Pe();this.#E||n!==this.#M||r===void 0||(this.#Y(r),e&&!this.#n.renderAgentHeader&&this.#n.renderNotice?.(formatAgentUpdateNotice(t,r)),this.#xe(this.#L))}async#Pe(){let e=this.#e;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}#Fe(){this.#Ne(!0)}#Ie(e){let t=this.#r;if(t!==void 0){for(let n of Object.values(e.agents))if(n.observation.status!==`not-followed`)for(let e of n.observation.conversation?.messages??[])for(let r of e.parts)r.type===`dynamic-tool`&&r.state===`output-error`&&(this.#G.has(r.toolCallId)||(this.#G.add(r.toolCallId),t.append({source:`tool`,summary:`${r.toolName} failed (subagent ${n.name})`,detail:r.errorText})))}}#Le(e){let t=this.#r;if(t!==void 0)switch(e.type){case`turn.started`:this.#W.clear();break;case`actions.requested`:for(let n of e.data.actions){let e=normalizeActionRequest(n);e.kind===`tool-call`&&t.recordToolCall(e.toolName)}break;case`action.result`:isTaskRetryRefusal(e)?t.append({source:`tool`,summary:`${normalizeActionResult(e.data.result).toolName} was refused for the model to retry`,detail:e.data.error?.message??`Refused.`}):e.data.status===`failed`&&t.append({source:`tool`,summary:`${normalizeActionResult(e.data.result).toolName} failed`,detail:e.data.error?.message??`Tool failed.`});break;case`agent.started`:t.recordSubagentDispatch(e.data.callId);break;case`step.completed`:t.recordStepUsage(e.data.usage);break;case`step.failed`:case`turn.failed`:case`session.failed`:{let n=failureKey(e);if(this.#W.has(n))break;this.#W.add(n);let r=formatFailureMessage(e),i=formatFailureDetail(e)??r,a=formatFailureHint(e);t.append(a===void 0?{source:`workflow`,summary:`Error: ${r}`,detail:i}:{source:`workflow`,summary:`Error: ${r}`,detail:i,hint:a});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,availablePromptCommands:e.availablePromptCommands,argumentSuggestions:e.argumentSuggestions,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}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.`}function registryHandoffs(e){let t=[],collect=(e,n)=>{for(let r of e.messages)for(let e of r.parts){if(!isTerminalToolCallPart(e)||e.state!==`output-available`||e.partial)continue;let r=registryHandoffAddress(n,e.toolName,e.output);r!==void 0&&t.push({callId:e.toolCallId,address:r})}};collect(e,void 0);for(let t of Object.values(e.agents)){if(t.observation.status===`not-followed`)continue;let e=t.observation.conversation;e!==void 0&&collect(e,t.name)}return t}function registryHandoffAddress(e,t,n){if((e!==`self-modification__agent`||t!==`registry_add`)&&(e!==void 0||t!==`selfmod__registry_add`)||typeof n!=`object`||!n)return;let r=n;return r.status===`needs-terminal`&&typeof r.address==`string`?r.address:void 0}function inputContext(e,t,n){let r={};return n>1&&(r.position={index:t,total:n}),e.taskId!==void 0&&(r.taskId=e.taskId),r.position===void 0&&r.taskId===void 0?void 0:r}function toAgentTUIToolApprovalRequest(e,t){let n={approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,input:e.action.input};return t!==void 0&&(n.context=t),n}function toAgentTUIInputQuestion(e,t){let n=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,r={requestId:e.requestId,prompt:e.prompt,display:n};return e.options!==void 0&&(r.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&&(r.allowFreeform=e.allowFreeform),t!==void 0&&(r.context=t),r}export{EveTUIRunner,registryHandoffAddress};
|
|
4
|
+
`);t!==``&&this.#n.renderNotice?.(t)}}async#Ce(e,t){let n=this.#_;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r=this.#L?.agent.model.endpoint,i={...t,renderer:this.#n,settleOutcome:e=>this.#Te(e),chatGptAccountLabel:r?.kind===`chatgpt`&&r.state===`ready`?r.accountLabel:void 0,withExclusiveTerminal:this.#y},a=this.#I?.current(),o=a!==void 0&&Object.keys(a).length>0?{...i,disabledConnectionReasons:a}:i;return await n.handle(e,o)}async#we(e){if(e?.kind===`model-access-changed`){this.#F?.applyEffect({kind:`refresh-identity`}),this.#A=!0,await this.#Me(e);return}e!==void 0&&(this.#F?.applyEffect(e),this.#A=!0,this.#xe(this.#L))}async#Te(e){if(e.effect===void 0)return e;let t=e.effect.kind===`model-access-changed`&&e.effect.reload?setTimeout(()=>{this.#g&&this.#n.setStartupPhase?.(`updating`),this.#n.setupFlow?.setStatus(`Loading selected model…`)},150):void 0;try{await this.#we(e.effect);let{effect:t,...n}=e;return n}catch{return{failed:!0,message:`Settings were saved, but the agent could not reload. Retry the command or restart eve dev.`}}finally{clearTimeout(t)}}async#Ee(e,t,n){let r=await this.#Ce(e,{...n,title:t}),i=r===void 0?void 0:await this.#Te(r);return!(n.suppressSuccessfulTranscript===!0&&i?.failed!==!0||n.suppressCancelledTranscript===!0&&i?.cancelled===!0)&&n.trigger!==`startup`&&(i===void 0?this.#Se({kind:`result`}):this.#Se({kind:`result`,message:i.message,summary:i.summary})),this.#Oe(),i}async#De(e){this.#m?.({flow:`onboarding`,step:`model_provider`});let t=await this.#Ee({type:`extension`,name:`login`,argument:``},e,{trigger:`startup`,initialModelStep:`provider`});return!t?.cancelled&&t?.failed!==!0&&this.#m?.({flow:`onboarding`,step:`connection_ready`}),this.#h?.({flow:`onboarding`,step:`model_provider`,result:t?.cancelled?`cancelled`:t?.failed===!0?`error`:`completed`}),t}#Oe(){if(this.#g)return;let e=this.#b?.current().connection;e?.state===`ready`&&e.info!==this.#L&&(this.#L=e.info,this.#s!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#i,serverUrl:this.#s}))}async#ke(e){if(this.#c===void 0||this.#n.traceViewer===void 0){this.#Se({kind:`result`,message:`/traces is only available in local dev sessions.`});return}try{await this.#n.traceViewer.open({appRoot:this.#c,sessionId:this.#t.snapshot.session?.sessionId,reference:e===``?void 0:e})}catch(e){if(isInterruptedError(e))return;throw e}finally{this.#Se({kind:`dismiss`})}}async#Ae(){let e=this.#c;if(e===void 0){this.#Se({kind:`result`,message:`/info is only available in local dev sessions.`});return}try{let t=renderApplicationInfo(await this.#w(e));this.#n.showInfoPanel===void 0?this.#Se({kind:`result`,message:t}):await this.#n.showInfoPanel(t)}catch(e){this.#Se({kind:`result`,message:`Couldn't inspect the application: ${toErrorMessage(e)}`})}}#je(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 none|error|warn|debug|all — 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 none, error, warn, debug, or all.`;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`error`:return`Showing errors.`;case`warn`:return`Showing warnings and errors.`;case`debug`:return`Showing all severity-tagged logs.`;case`all`:return`Showing all logs.`}}async#Me(e){let t=this.#c;t!==void 0&&(++this.#M,++this.#j,await loadDevelopmentEnvironmentFiles(t),e.reload&&await this.#o?.refreshAfterSourceChange({}),e.model&&this.#L?this.#Y({...this.#L,agent:{...this.#L.agent,model:{...this.#L.agent.model,...e.model}}}):this.#Y(this.#L),this.#N=[],this.#P=void 0,this.#ye(),this.#Ne())}async#Ne(e=!1){let t=this.#L,n=++this.#M,r=await this.#Pe();this.#E||n!==this.#M||r===void 0||(this.#Y(r),e&&!this.#n.renderAgentHeader&&this.#n.renderNotice?.(formatAgentUpdateNotice(t,r)),this.#xe(this.#L))}async#Pe(){let e=this.#e;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}#Fe(){this.#Ne(!0)}#Ie(e){let t=this.#r;if(t!==void 0){for(let n of Object.values(e.agents))if(n.observation.status!==`not-followed`)for(let e of n.observation.conversation?.messages??[])for(let r of e.parts)r.type===`dynamic-tool`&&r.state===`output-error`&&(this.#G.has(r.toolCallId)||(this.#G.add(r.toolCallId),t.append({source:`tool`,summary:`${r.toolName} failed (subagent ${n.name})`,detail:r.errorText})))}}#Le(e){let t=this.#r;if(t!==void 0)switch(e.type){case`turn.started`:this.#W.clear();break;case`actions.requested`:for(let n of e.data.actions){let e=normalizeActionRequest(n);e.kind===`tool-call`&&t.recordToolCall(e.toolName)}break;case`action.result`:isTaskRetryRefusal(e)?t.append({source:`tool`,summary:`${normalizeActionResult(e.data.result).toolName} was refused for the model to retry`,detail:e.data.error?.message??`Refused.`}):e.data.status===`failed`&&t.append({source:`tool`,summary:`${normalizeActionResult(e.data.result).toolName} failed`,detail:e.data.error?.message??`Tool failed.`});break;case`agent.started`:t.recordSubagentDispatch(e.data.callId);break;case`step.completed`:t.recordStepUsage(e.data.usage);break;case`step.failed`:case`turn.failed`:case`session.failed`:{let n=failureKey(e);if(this.#W.has(n))break;this.#W.add(n);let r=formatFailureMessage(e),i=formatFailureDetail(e)??r,a=formatFailureHint(e);t.append(a===void 0?{source:`workflow`,summary:`Error: ${r}`,detail:i}:{source:`workflow`,summary:`Error: ${r}`,detail:i,hint:a});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,availablePromptCommands:e.availablePromptCommands,argumentSuggestions:e.argumentSuggestions,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}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.`}function registryHandoffs(e){let t=[],collect=(e,n)=>{for(let r of e.messages)for(let e of r.parts){if(!isTerminalToolCallPart(e)||e.state!==`output-available`||e.partial)continue;let r=registryHandoffAddress(n,e.toolName,e.output);r!==void 0&&t.push({callId:e.toolCallId,address:r})}};collect(e,void 0);for(let t of Object.values(e.agents)){if(t.observation.status===`not-followed`)continue;let e=t.observation.conversation;e!==void 0&&collect(e,t.name)}return t}function registryHandoffAddress(e,t,n){if((e!==`self-modification__agent`||t!==`registry_add`)&&(e!==void 0||t!==`selfmod__registry_add`)||typeof n!=`object`||!n)return;let r=n;return r.status===`needs-terminal`&&typeof r.address==`string`?r.address:void 0}function inputContext(e,t,n){let r={};return n>1&&(r.position={index:t,total:n}),e.taskId!==void 0&&(r.taskId=e.taskId),r.position===void 0&&r.taskId===void 0?void 0:r}function toAgentTUIToolApprovalRequest(e,t){let n={approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,prompt:e.prompt,input:e.action.input};return t!==void 0&&(n.context=t),n}function toAgentTUIInputQuestion(e,t){let n=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,r={requestId:e.requestId,prompt:e.prompt,display:n};return e.options!==void 0&&(r.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&&(r.allowFreeform=e.allowFreeform),t!==void 0&&(r.context=t),r}export{EveTUIRunner,registryHandoffAddress};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{setConsoleRecordSubscriber}from"../console-records.js";import{buildAgentHeader}from"./agent-header.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand,promptCommandSpec}from"./prompt-commands.js";import{argumentTypeaheadCompletion,argumentTypeaheadFor,argumentTypeaheadLoadingLabel,argumentTypeaheadQuery,moveArgumentTypeaheadSelection,renderArgumentSuggestions,selectedArgumentSuggestion}from"./argument-typeahead.js";import{detectMarkdownRendering}from"./markdown.js";import{renderAttentionRows,renderBlockLines}from"./blocks.js";import{copyTextToClipboard}from"./clipboard.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{interruptedError}from"./errors.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{formatStoredDiagnostic,presentDiagnostic}from"./diagnostic-presentation.js";import{EMPTY_LINE,KillRing,PromptHistory,applyLineEditorKey,deleteForward,layoutPromptInput,lineOf,movePromptLine,visibleLine}from"./line-editor.js";import{enterBadge,flowMessageRows,renderAcknowledgeQuestion,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{renderFlowDrawer,renderTransientDrawer}from"./flow-drawer.js";import{isLogVisible,nextLogDisplayMode}from"./log-display-mode.js";import{MessageQueue,renderMessageQueueRows}from"./message-queue.js";import{initialPromptPlaceholder}from"./prompt-placeholder.js";import{initialProviderPickerState,transitionProviderPicker}from"./provider-picker.js";import{inputContextLabel,renderQuestionChoices,renderQuestionPanel}from"./question-panel.js";import{formatAssistantResponseStats,formatTokenFlow,formatTurnDuration,isIncompleteOsc,isIncompletePaste,nextKey,sanitizePastedText,stripPasteStart,stripPromptControlCharacters}from"./stream-format.js";import{groupToolBlocksForDisplay}from"./tool-block-groups.js";import{renderTaskPanelRows}from"./task-activity.js";import{ConversationTranscript,TASK_END_GRACE_MS,turnActivity}from"./transcript.js";import{TraceViewerSession}from"./traces/trace-viewer-session.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{TurnClock}from"./turn-clock.js";import{reduceSetupSelectInput,setupSelectionIntent}from"./setup-selection-input.js";import{BACKGROUND_COLOR_QUERY,parseBackgroundColorReply}from"./terminal-background.js";import{eveVersionTag}from"#cli/banner.js";import{format}from"node:util";import{clipVisible,renderInputText,renderInputWithBlockCursor,stripAnsi,stripTerminalControls,wrapVisibleLine}from"#cli/ui/terminal-text.js";import{initialSelectState,orderedSelection,reduceSelect,searchActionQuery,selectValueAtCursor}from"#setup/cli/select-state.js";import{toErrorMessage}from"#shared/errors.js";import{StringDecoder}from"node:string_decoder";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{LiveRegion}from"#cli/ui/live-region.js";import{AltScreen}from"#cli/ui/alt-screen.js";import{PROGRESS_PULSE_ASCII_GLYPH,PROGRESS_PULSE_GLYPH,isProgressPulseVisible}from"#cli/ui/progress-pulse.js";import{readGatewayServiceTier}from"#shared/gateway-service-tier.js";function isMultiSelectRequest(e){return e.kind===`multi`||e.kind===`searchable-multi`}function moveActionCursor(e,t,n){return n===0?void 0:e===void 0?t===`down`?0:n-1:(e+(t===`down`?1:-1)+n)%n}const incompletePasteFlushMs=1e3;var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h=[];#g=new Map;#_;#v=new Set;#y=[];#b=0;#x=new ConversationTranscript;#S;#C;#w=new Set;#T=[];#E;#D=`Send a message…`;#O;#k;#A;#j;#M=0;#N;#P=!1;#F;#I=[];#L;#R;#z;#B=``;#V=0;#H=new PromptHistory;#U=new KillRing;#W=!1;#G;#K;#q;#J=new Map;#Y=new Map;#X=!1;#Z=!1;#Q=new TurnClock;#$;#ee=EMPTY_LINE;#te;#ne=!1;#re;#ie;#ae=`eve`;#oe=!1;#se=!1;#ce=!1;#le=!1;#ue=!1;#de=!1;#fe;#pe=!0;#me=0;#he=Date.now();#ge;#_e;#ve;#ye=!1;#be;#xe=``;#Se=new StringDecoder(`utf8`);#Ce;#we;#Te=!1;#Ee=!1;#De;#Oe;#ke=``;#Ae=``;#je;#Me;#Ne;#Pe=!1;#Fe;#Ie=0;#Le;#Re;#ze;#Be;#Ve;#He=new MessageQueue;#Ue;#We;#Ge;#Ke;#qe;setupFlow={begin:e=>this.#st(e),setNavigation:e=>this.#ct(e),end:e=>this.#lt(e?.preserveDiagnostics??!0),readSelect:e=>this.#ut(e),readEditableSelect:e=>this.#ft(e),readProviderPicker:e=>this.#pt(e),readText:e=>this.#mt(e),readAcknowledge:e=>this.#ht(e),readChoice:e=>this.#dt(e),setStatus:e=>this.#Ct(e),renderLine:(e,t)=>this.#wt(e,t),replaceContent:e=>this.#Tt(e),renderOutput:e=>this.#Et(e),withInheritedStdio:e=>this.#Dt(e),withExclusiveTerminal:e=>this.#Dt(e),waitForInterrupt:e=>this.#bt(e)};traceViewer={open:e=>this.#kt(e)};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=new AltScreen(this.#t),this.#i=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#a=e?.renderMarkdown??detectMarkdownRendering(),this.#o=e?.tools??`auto-collapsed`,this.#s=e?.reasoning??`auto-collapsed`,this.#c=e?.subagents??`collapsed`,this.#l=e?.connectionAuth??`full`,this.#u=e?.assistantResponseStats??`tokensPerSecond`,this.#De=e?.contextSize,this.#d=e?.captureForeignOutput??this.#t===process.stdout,this.#f=e?.diagnostics,this.#fe=e?.onExitRequest,this.#q=e?.argumentSuggestions,this.#m=e?.logs??`error`,this.#p=e?.availablePromptCommands??PROMPT_COMMANDS}#Je(e){this.#G=typeaheadFor(this.#p,e,this.#G);let t=argumentTypeaheadQuery(e);if(t===void 0||this.#q===void 0){this.#K=void 0;return}let n=this.#J.get(t.command);if(n===void 0){this.#J.set(t.command,{kind:`loading`,visible:!1});let e=t.command;this.#Y.set(e,setTimeout(()=>{this.#Y.delete(e),this.#J.get(e)?.kind===`loading`&&(this.#J.set(e,{kind:`loading`,visible:!0}),this.#on())},500)),this.#q(e).catch(()=>[]).then(t=>{let n=this.#Y.get(e);n!==void 0&&clearTimeout(n),this.#Y.delete(e),this.#J.set(e,{kind:`ready`,suggestions:t}),this.#W&&this.#Je(this.#B),this.#on()}),this.#K=void 0;return}if(n.kind===`loading`){this.#K=void 0;return}this.#K=argumentTypeaheadFor(t,n.suggestions,this.#K)}#Ye(e){let t=argumentTypeaheadQuery(this.#B),n=t===void 0?void 0:this.#J.get(t.command);return n?.kind===`loading`&&n.visible&&t!==void 0?[clip(this.#i.colors.dim(`Loading ${argumentTypeaheadLoadingLabel(t.command)}…`),e)]:this.#K===void 0?this.#G!==void 0&&isTypeaheadOpen(this.#G)?renderCommandSuggestions(this.#G,this.#i,e):[]:renderArgumentSuggestions(this.#K,this.#i,e)}setStartupPhase(e){this.#k=e,e===void 0?this.#qt():this.#Kt(),this.#on()}renderAgentHeader(e){this.#N=void 0,this.#ae=e.name,this.#E=e,this.#O=e.info?.subagents.local.map(e=>e.name),this.#D=initialPromptPlaceholder(e.info,e.localDevelopment===!0),this.#Mt();let t=this.#dn().join(`
|
|
2
|
-
`);if(this.#P){t!==this.#F&&(this.#F=t,this.#en({kind:`agent-header`,body:t,live:!1})),this.#on();return}this.#P=!0,this.#F=t,this.#n.flush(this.#dn(),this.#gn(this.#Cn()))}beginStartupDraft(e){this.#Mt({title:e.title}),this.#W=!0,this.#X=!0,this.#k=`starting`,this.#N={name:e.title},this.#M=Date.now();let t=lineOf(stripPromptControlCharacters(e.initialDraft??``));this.#A=t,this.#et(t),this.#Ut(),this.#Kt(),this.#on();let apply=e=>{t=e,this.#A=e,this.#Gt(),this.#et(t),this.#on()};this.#j=e=>{if(e.type===`escape`&&this.#We!==void 0){this.#We(`escape`);return}if(e.type===`ctrl-c`&&this.#We!==void 0){this.#Ot(),this.#We(`ctrl-c`);return}let n=this.#U.apply(t,e,{multiline:!0});if(n!==void 0){apply(n);return}if(e.type===`enter`&&t.text.trim().length>0){this.#He.enqueue(t.text)&&apply(EMPTY_LINE);return}e.type===`ctrl-c`&&this.#fe?.()},this.#Xe()}#Xe(){this.#A!==void 0&&this.#j!==void 0&&(this.#Ht(),this.#et(this.#A),this.#W=!0,this.#be=this.#j,this.#Ft())}finishStartupDraft(){let e={draft:this.#A?.text??this.#B,queuedPrompt:this.#He.takePrompt()};return this.#A=void 0,this.#j=void 0,this.#It(),this.#Wt(),this.#W=!1,this.#X=!1,e}async readInput(e){this.#Mt(e),this.#C?.working!==!0&&this.#tn(),this.#W=!0,this.#X=!0,this.#ue=this.#de,this.#de=!1;let t=e?.initialDraft===void 0?this.#ee:lineOf(stripPromptControlCharacters(e.initialDraft));return this.#H.begin(t.text),this.#et(t),this.#Je(t.text),this.#Ut(),this.#on(),await new Promise((n,r)=>{let i=e?.signal,release=()=>{this.#te=void 0,i?.removeEventListener(`abort`,onAbort),this.#G=void 0,this.#K=void 0,this.#W=!1,this.#Wt(),this.#It(),this.#on()},finish=e=>{release(),n(e)},onAbort=()=>finish(void 0);if(i?.addEventListener(`abort`,onAbort,{once:!0}),i?.aborted){onAbort();return}this.#re=e=>{i?.removeEventListener(`abort`,onAbort),r(e)};let apply=e=>{t=e,this.#ee=e,this.#Gt(),this.#et(t),this.#Je(e.text),this.#on()};this.#te=apply;let recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#G=void 0,this.#Wt(),this.#Pt(),r(interruptedError())},cancel=()=>{this.#ne=!0,finish({type:`cancel`})},suggestions=()=>this.#G!==void 0&&isTypeaheadOpen(this.#G)?this.#G:void 0,argumentSuggestions=()=>this.#K?.suggestions.length?this.#K:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#be=e=>{e.type!==`ctrl-c`&&this.#ue&&(this.#ue=!1,this.#on());let n=this.#U.apply(t,e,{multiline:!0});if(n!==void 0){apply(n);return}let r=this.#C?.working===!0;switch(e.type){case`up`:case`ctrl-p`:{let e=argumentSuggestions();if(e!==void 0){this.#K=moveArgumentTypeaheadSelection(e,-1),this.#on();break}let n=suggestions();if(n!==void 0){this.#G=moveTypeaheadSelection(n,-1),this.#on();break}let r=movePromptLine(t,`up`);r===void 0?recall(this.#H.previous(t.text)):apply(r);break}case`down`:case`ctrl-n`:{let e=argumentSuggestions();if(e!==void 0){this.#K=moveArgumentTypeaheadSelection(e,1),this.#on();break}let n=suggestions();if(n!==void 0){this.#G=moveTypeaheadSelection(n,1),this.#on();break}let r=movePromptLine(t,`down`);r===void 0?recall(this.#H.next()):apply(r);break}case`tab`:{let e=argumentSuggestions(),t=e===void 0?void 0:selectedArgumentSuggestion(e);if(e!==void 0&&t!==void 0){apply(lineOf(argumentTypeaheadCompletion(e,t)));break}let n=highlighted();n!==void 0&&apply(lineOf(typeaheadCompletion(n)));break}case`escape`:{if(this.#K!==void 0){this.#K=void 0,this.#on();break}let e=suggestions();if(e!==void 0){this.#G=dismissTypeahead(e),this.#on();break}r&&!this.#ne&&cancel();break}case`enter`:{let e=argumentSuggestions(),n=e===void 0?void 0:selectedArgumentSuggestion(e),i=highlighted();if(e!==void 0&&n?.next!==void 0&&e.completed.length===0){apply(lineOf(`${argumentTypeaheadCompletion(e,n)} `));break}if(e===void 0&&i!==void 0&&this.#q!==void 0&&(i.name===`add`||i.name===`login`||i.name===`loglevel`||i.name===`model`)){apply(lineOf(typeaheadCompletion(i)));break}let a=e!==void 0&&n!==void 0?argumentTypeaheadCompletion(e,n):i!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(i).trimEnd():t.text;if(a.trim().length===0)break;promptCommandSpec(a)?.spec.history!==`omit`&&this.#H.add(a),this.#ee=EMPTY_LINE,this.#et(EMPTY_LINE),isPromptControlCommand(a)?(this.#at(stripTerminalControls(a.trim())),r&&parsePromptCommand(a)?.type===`cancel`&&(this.#ne=!0)):(this.#Z=!0,this.#f?.recordPrompt(),r&&this.#T.push(a)),finish({type:`submit`,text:a});break}case`ctrl-d`:t.text.length===0?(this.#Ot(),interrupt()):apply(deleteForward(t));break;case`ctrl-l`:this.#ln();break;case`ctrl-r`:this.#on();break;case`ctrl-c`:if(r){if(!this.#ne){cancel();break}this.#ne=!1,this.#de=!0,finish({type:`interrupt`});break}if(this.#ue){this.#Ot(),interrupt();break}this.#ue=!0,apply(EMPTY_LINE)}},this.#Ft()})}renderConversation(e){let t=this.#C?.working===!0;this.#C=e,e.conversation.messages.some(e=>e.role===`user`)&&(this.#Z=!0);let n=this.#x.project(e,this.#Qe());this.#Xt();let r=new Set;for(let[e,t]of n.entries()){let i=t.id;if(this.#v.has(i))continue;r.add(i);let a=this.#g.get(i);if(a!==t){if(t.updateSeq=++this.#b,a!==void 0){this.#h[this.#h.indexOf(a)]=t,this.#g.set(i,t);continue}if(t.kind===`user`){let e=this.#T.indexOf(t.body??``);e!==-1&&(this.#T.splice(e,1),t.promptOrigin=`steer`)}this.#Ze(t,n.slice(e+1))}}for(let e of this.#w)r.has(e)||this.#an(e);this.#w=r,e.working&&!t?this.#Q.armed||this.#Q.arm(e.data.usage):!e.working&&t&&(this.#ne=!1,this.#W&&this.#tn()),this.#$t(),this.#on()}#Ze(e,t){let n=t.find(e=>this.#g.has(e.id)),r=n===void 0?-1:this.#h.indexOf(this.#g.get(n.id));if(r===-1){this.#en(e);return}e.id!==this.#Me?.id&&this.#Ln(),this.#h.splice(r,0,e),this.#g.set(e.id,e)}#Qe(){return{tools:this.#o,reasoning:this.#s,subagents:this.#c,connectionAuth:this.#l,subagentNames:this.#O,diagnosticsPath:this.#f?.displayPath,dot:this.#i.glyph.dot}}#$e(e){if(e?.taskId===void 0||e.requester!==void 0||this.#C===void 0)return inputContextLabel(e,this.#i);let t=this.#x.taskLabel(this.#C.conversation,e.taskId);return inputContextLabel(t===void 0?e:{...e,requester:t},this.#i)}#et(e){this.#B=e.text,this.#V=e.cursor}async readToolApproval(e,t){this.#Mt(t),this.#W=!1;let n=0;return this.#Le=t=>renderTransientDrawer([` ${this.#i.colors.bold(`Approve ${formatToolApprovalTitle(e)}?`)}`,``,...renderQuestionChoices([{id:`yes`,label:`Yes`},{id:`no`,label:`No`}],n,this.#i)],[`y yes · n no · Ctrl-C cancel`],this.#i,t,this.#$e(e.context),!1,`left`),this.#on(),await new Promise((e,t)=>{let approve=()=>{this.#Le=void 0,this.#It(),this.#on(),e({approved:!0})},deny=()=>{this.#Le=void 0,this.#It(),this.#on(),e({approved:!1,reason:`Denied by user.`})};this.#re=t,this.#be=e=>{switch(e.type){case`text`:{if(e.framing!==`unframed`)break;let t=e.value.toLowerCase();t===`y`?approve():t===`n`&&deny();break}case`up`:case`ctrl-p`:n=0,this.#on();break;case`down`:case`ctrl-n`:n=1,this.#on();break;case`enter`:n===0?approve():deny();break;case`ctrl-r`:this.#on();break;case`ctrl-c`:this.#Le=void 0,this.#Pt(),t(interruptedError())}},this.#Ft()})}async readInputQuestion(e,t){this.#Mt(t),this.#W=!1,this.#X=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`select`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,selectDrawer=t=>renderTransientDrawer([...renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#pe},this.#i,t)],[`↑/↓ move · enter to select · esc to dismiss`],this.#i,t,this.#$e(e.context),!1,`left`),textPanel=t=>{let n=promptInputRows({text:l.text,cursor:l.cursor,width:Math.max(1,t-2),theme:this.#i,caretVisible:this.#pe,ghost:``,maxRows:3});return n.at(-1)===``&&n.pop(),renderTransientDrawer([` ${this.#i.colors.bold(stripTerminalControls(e.prompt))}`,``,...n.map(e=>` ${e}`)],[`Enter submit · Esc dismiss`],this.#i,t,this.#$e(e.context),!1,`left`)},syncFreeformCaret=()=>{isOnFreeformRow()?this.#Ut():(this.#Wt(),this.#Gt())};s===`select`?(s=`select`,this.#W=!1,this.#an(o),this.#Le=selectDrawer,syncFreeformCaret(),this.#on()):(s=`text`,this.#Le=textPanel,this.#W=!0,this.#et(l),this.#Ut(),this.#on());let finalize=t=>{this.#Le=void 0,this.#in({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#W=!1,this.#Wt(),this.#It(),this.#on();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#Le=void 0,this.#in({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Skipped. The question stays open.`)}`,preformatted:!0,live:!1}),this.#W=!1,this.#Wt(),this.#It(),this.#on(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#on())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,n)=>{this.#re=n,u=t,this.#be=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#Gt(),s===`text`&&this.#et(l),this.#on();return}this.#Le=void 0,this.#Wt(),this.#Pt(),n(interruptedError());return}if(t.type===`ctrl-r`){this.#on();return}if(s===`select`){let n=setupSelectionIntent(t,{textNavigation:!isOnFreeformRow()});if(n?.kind===`move`){moveCursor(n.direction===`up`?-1:1);return}switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#Gt(),this.#on();break}dismiss();break;default:if(isOnFreeformRow()){let e=this.#U.apply(l,t);e!==void 0&&(l=e,this.#Gt(),this.#on())}}return}let r=this.#U.apply(l,t,{multiline:!0});if(r!==void 0){l=r,this.#Gt(),this.#et(l),this.#on();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#Gt(),this.#et(l),this.#on());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#Gt(),this.#et(l),this.#on();break}dismiss()}},this.#Ft()})}setVercelStatus(e){this.#R=e,this.#on()}setRemoteConnectionStatus(e){this.#z=e,this.#on()}reset(){this.#h=[],this.#g.clear(),this.#v.clear(),this.#L=void 0,this.#I.length=0,this.#y.length=0,this.#P=!1,this.#F=void 0,this.#tt(),this.#Z=!1,this.#Me=void 0,this.#oe&&(this.#n.clearAll(),this.#on())}renderSessionBoundary(){this.#tn();let e=this.#x.stopWorking(this.#Qe());for(let e of this.#w){let t=this.#g.get(e);if(t===void 0)continue;this.#g.delete(e);let n=this.#h.indexOf(t),{id:r,...i}=t;this.#h[n]={...i,live:!1}}for(let{id:t,...n}of e)this.#en(n);this.#v.clear(),this.#tt();let t=this.#i.colors,n=this.#i.glyph,r=t.dim(`${n.cornerOpen}${n.dash.repeat(2)} Session restarted, clear context.`);this.#en({kind:`session-boundary`,body:r,live:!1}),this.#on()}#tt(){this.#x.reset(),this.#Zt(),this.#C=void 0,this.#w=new Set,this.#T.length=0,this.#ne=!1,this.#Q.reset(),this.#$t()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Mt(),this.#en({kind:`notice`,body:t,live:!1}),this.#on())}restoreDraft(e){let t=this.#W?this.#te:void 0;if((t===void 0?this.#ee.text:this.#B).length>0)return;let n=lineOf(stripPromptControlCharacters(e));t===void 0?this.#ee=n:t(n),this.renderNotice(`The turn was cancelled from outside this prompt, so its message is back in the input.`)}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#nt();return}this.#Mt(),this.#Ve=t,this.#on()}clearSetupWarning(){this.#nt()}#nt(){this.#Ve!==void 0&&(this.#Ve=void 0,this.#on())}renderCommandInvocation(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Mt(),this.#at(t),this.#on())}async choosePromptCommand(e){this.#Mt(),this.#W=!1;let t=typeaheadFor(e,`/`);return this.#Re=e=>{let n=renderCommandSuggestions(t,this.#i,e),r=Math.max(1,this.#wn()-7),i=Math.max(0,Math.min(t.selectedIndex-r+1,n.length-r));return renderTransientDrawer(n.slice(i,i+r),[`↑/↓ move · Enter select · Esc close`],this.#i,e)},this.#on(),await new Promise(e=>{this.#ze=()=>e(void 0),this.#be=n=>{if(n.type===`up`||n.type===`ctrl-p`)t=moveTypeaheadSelection(t,-1),this.#on();else if(n.type===`down`||n.type===`ctrl-n`)t=moveTypeaheadSelection(t,1),this.#on();else if(n.type===`enter`){let n=selectedTypeaheadCommand(t);this.#rt(),e(n===void 0?void 0:typeaheadCompletion(n))}else(n.type===`escape`||n.type===`ctrl-c`)&&(this.#rt(),e(void 0))},this.#Ft()})}async showInfoPanel(e){this.#Mt(),this.#W=!1;let t=stripAnsi(e),n=0,infoRows=e=>t.split(`
|
|
2
|
+
`);if(this.#P){t!==this.#F&&(this.#F=t,this.#en({kind:`agent-header`,body:t,live:!1})),this.#on();return}this.#P=!0,this.#F=t,this.#n.flush(this.#dn(),this.#gn(this.#Cn()))}beginStartupDraft(e){this.#Mt({title:e.title}),this.#W=!0,this.#X=!0,this.#k=`starting`,this.#N={name:e.title},this.#M=Date.now();let t=lineOf(stripPromptControlCharacters(e.initialDraft??``));this.#A=t,this.#et(t),this.#Ut(),this.#Kt(),this.#on();let apply=e=>{t=e,this.#A=e,this.#Gt(),this.#et(t),this.#on()};this.#j=e=>{if(e.type===`escape`&&this.#We!==void 0){this.#We(`escape`);return}if(e.type===`ctrl-c`&&this.#We!==void 0){this.#Ot(),this.#We(`ctrl-c`);return}let n=this.#U.apply(t,e,{multiline:!0});if(n!==void 0){apply(n);return}if(e.type===`enter`&&t.text.trim().length>0){this.#He.enqueue(t.text)&&apply(EMPTY_LINE);return}e.type===`ctrl-c`&&this.#fe?.()},this.#Xe()}#Xe(){this.#A!==void 0&&this.#j!==void 0&&(this.#Ht(),this.#et(this.#A),this.#W=!0,this.#be=this.#j,this.#Ft())}finishStartupDraft(){let e={draft:this.#A?.text??this.#B,queuedPrompt:this.#He.takePrompt()};return this.#A=void 0,this.#j=void 0,this.#It(),this.#Wt(),this.#W=!1,this.#X=!1,e}async readInput(e){this.#Mt(e),this.#C?.working!==!0&&this.#tn(),this.#W=!0,this.#X=!0,this.#ue=this.#de,this.#de=!1;let t=e?.initialDraft===void 0?this.#ee:lineOf(stripPromptControlCharacters(e.initialDraft));return this.#H.begin(t.text),this.#et(t),this.#Je(t.text),this.#Ut(),this.#on(),await new Promise((n,r)=>{let i=e?.signal,release=()=>{this.#te=void 0,i?.removeEventListener(`abort`,onAbort),this.#G=void 0,this.#K=void 0,this.#W=!1,this.#Wt(),this.#It(),this.#on()},finish=e=>{release(),n(e)},onAbort=()=>finish(void 0);if(i?.addEventListener(`abort`,onAbort,{once:!0}),i?.aborted){onAbort();return}this.#re=e=>{i?.removeEventListener(`abort`,onAbort),r(e)};let apply=e=>{t=e,this.#ee=e,this.#Gt(),this.#et(t),this.#Je(e.text),this.#on()};this.#te=apply;let recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#G=void 0,this.#Wt(),this.#Pt(),r(interruptedError())},cancel=()=>{this.#ne=!0,finish({type:`cancel`})},suggestions=()=>this.#G!==void 0&&isTypeaheadOpen(this.#G)?this.#G:void 0,argumentSuggestions=()=>this.#K?.suggestions.length?this.#K:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#be=e=>{e.type!==`ctrl-c`&&this.#ue&&(this.#ue=!1,this.#on());let n=this.#U.apply(t,e,{multiline:!0});if(n!==void 0){apply(n);return}let r=this.#C?.working===!0;switch(e.type){case`up`:case`ctrl-p`:{let e=argumentSuggestions();if(e!==void 0){this.#K=moveArgumentTypeaheadSelection(e,-1),this.#on();break}let n=suggestions();if(n!==void 0){this.#G=moveTypeaheadSelection(n,-1),this.#on();break}let r=movePromptLine(t,`up`);r===void 0?recall(this.#H.previous(t.text)):apply(r);break}case`down`:case`ctrl-n`:{let e=argumentSuggestions();if(e!==void 0){this.#K=moveArgumentTypeaheadSelection(e,1),this.#on();break}let n=suggestions();if(n!==void 0){this.#G=moveTypeaheadSelection(n,1),this.#on();break}let r=movePromptLine(t,`down`);r===void 0?recall(this.#H.next()):apply(r);break}case`tab`:{let e=argumentSuggestions(),t=e===void 0?void 0:selectedArgumentSuggestion(e);if(e!==void 0&&t!==void 0){apply(lineOf(argumentTypeaheadCompletion(e,t)));break}let n=highlighted();n!==void 0&&apply(lineOf(typeaheadCompletion(n)));break}case`escape`:{if(this.#K!==void 0){this.#K=void 0,this.#on();break}let e=suggestions();if(e!==void 0){this.#G=dismissTypeahead(e),this.#on();break}r&&!this.#ne&&cancel();break}case`enter`:{let e=argumentSuggestions(),n=e===void 0?void 0:selectedArgumentSuggestion(e),i=highlighted();if(e!==void 0&&n?.next!==void 0&&e.completed.length===0){apply(lineOf(`${argumentTypeaheadCompletion(e,n)} `));break}if(e===void 0&&i!==void 0&&this.#q!==void 0&&(i.name===`add`||i.name===`login`||i.name===`loglevel`||i.name===`model`)){apply(lineOf(typeaheadCompletion(i)));break}let a=e!==void 0&&n!==void 0?argumentTypeaheadCompletion(e,n):i!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(i).trimEnd():t.text;if(a.trim().length===0)break;promptCommandSpec(a)?.spec.history!==`omit`&&this.#H.add(a),this.#ee=EMPTY_LINE,this.#et(EMPTY_LINE),isPromptControlCommand(a)?(this.#at(stripTerminalControls(a.trim())),r&&parsePromptCommand(a)?.type===`cancel`&&(this.#ne=!0)):(this.#Z=!0,this.#f?.recordPrompt(),r&&this.#T.push(a)),finish({type:`submit`,text:a});break}case`ctrl-d`:t.text.length===0?(this.#Ot(),interrupt()):apply(deleteForward(t));break;case`ctrl-l`:this.#ln();break;case`ctrl-r`:this.#on();break;case`ctrl-c`:if(r){if(!this.#ne){cancel();break}this.#ne=!1,this.#de=!0,finish({type:`interrupt`});break}if(this.#ue){this.#Ot(),interrupt();break}this.#ue=!0,apply(EMPTY_LINE)}},this.#Ft()})}renderConversation(e){let t=this.#C?.working===!0;this.#C=e,e.conversation.messages.some(e=>e.role===`user`)&&(this.#Z=!0);let n=this.#x.project(e,this.#Qe());this.#Xt();let r=new Set;for(let[e,t]of n.entries()){let i=t.id;if(this.#v.has(i))continue;r.add(i);let a=this.#g.get(i);if(a!==t){if(t.updateSeq=++this.#b,a!==void 0){this.#h[this.#h.indexOf(a)]=t,this.#g.set(i,t);continue}if(t.kind===`user`){let e=this.#T.indexOf(t.body??``);e!==-1&&(this.#T.splice(e,1),t.promptOrigin=`steer`)}this.#Ze(t,n.slice(e+1))}}for(let e of this.#w)r.has(e)||this.#an(e);this.#w=r,e.working&&!t?this.#Q.armed||this.#Q.arm(e.data.usage):!e.working&&t&&(this.#ne=!1,this.#W&&this.#tn()),this.#$t(),this.#on()}#Ze(e,t){let n=t.find(e=>this.#g.has(e.id)),r=n===void 0?-1:this.#h.indexOf(this.#g.get(n.id));if(r===-1){this.#en(e);return}e.id!==this.#Me?.id&&this.#Ln(),this.#h.splice(r,0,e),this.#g.set(e.id,e)}#Qe(){return{tools:this.#o,reasoning:this.#s,subagents:this.#c,connectionAuth:this.#l,subagentNames:this.#O,diagnosticsPath:this.#f?.displayPath,dot:this.#i.glyph.dot}}#$e(e){if(e?.taskId===void 0||e.requester!==void 0||this.#C===void 0)return inputContextLabel(e,this.#i);let t=this.#x.taskLabel(this.#C.conversation,e.taskId);return inputContextLabel(t===void 0?e:{...e,requester:t},this.#i)}#et(e){this.#B=e.text,this.#V=e.cursor}async readToolApproval(e,t){this.#Mt(t),this.#W=!1;let n=0;return this.#Le=t=>renderTransientDrawer([` ${this.#i.colors.bold(stripTerminalControls(e.prompt))}`,``,...renderQuestionChoices([{id:`yes`,label:`Yes`},{id:`no`,label:`No`}],n,this.#i)],[`y yes · n no · Ctrl-C cancel`],this.#i,t,this.#$e(e.context),!1,`left`),this.#on(),await new Promise((e,t)=>{let approve=()=>{this.#Le=void 0,this.#It(),this.#on(),e({approved:!0})},deny=()=>{this.#Le=void 0,this.#It(),this.#on(),e({approved:!1,reason:`Denied by user.`})};this.#re=t,this.#be=e=>{switch(e.type){case`text`:{if(e.framing!==`unframed`)break;let t=e.value.toLowerCase();t===`y`?approve():t===`n`&&deny();break}case`up`:case`ctrl-p`:n=0,this.#on();break;case`down`:case`ctrl-n`:n=1,this.#on();break;case`enter`:n===0?approve():deny();break;case`ctrl-r`:this.#on();break;case`ctrl-c`:this.#Le=void 0,this.#Pt(),t(interruptedError())}},this.#Ft()})}async readInputQuestion(e,t){this.#Mt(t),this.#W=!1,this.#X=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`select`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,selectDrawer=t=>renderTransientDrawer([...renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#pe},this.#i,t)],[`↑/↓ move · enter to select · esc to dismiss`],this.#i,t,this.#$e(e.context),!1,`left`),textPanel=t=>{let n=promptInputRows({text:l.text,cursor:l.cursor,width:Math.max(1,t-2),theme:this.#i,caretVisible:this.#pe,ghost:``,maxRows:3});return n.at(-1)===``&&n.pop(),renderTransientDrawer([` ${this.#i.colors.bold(stripTerminalControls(e.prompt))}`,``,...n.map(e=>` ${e}`)],[`Enter submit · Esc dismiss`],this.#i,t,this.#$e(e.context),!1,`left`)},syncFreeformCaret=()=>{isOnFreeformRow()?this.#Ut():(this.#Wt(),this.#Gt())};s===`select`?(s=`select`,this.#W=!1,this.#an(o),this.#Le=selectDrawer,syncFreeformCaret(),this.#on()):(s=`text`,this.#Le=textPanel,this.#W=!0,this.#et(l),this.#Ut(),this.#on());let finalize=t=>{this.#Le=void 0,this.#in({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#W=!1,this.#Wt(),this.#It(),this.#on();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#Le=void 0,this.#in({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Skipped. The question stays open.`)}`,preformatted:!0,live:!1}),this.#W=!1,this.#Wt(),this.#It(),this.#on(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#on())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,n)=>{this.#re=n,u=t,this.#be=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#Gt(),s===`text`&&this.#et(l),this.#on();return}this.#Le=void 0,this.#Wt(),this.#Pt(),n(interruptedError());return}if(t.type===`ctrl-r`){this.#on();return}if(s===`select`){let n=setupSelectionIntent(t,{textNavigation:!isOnFreeformRow()});if(n?.kind===`move`){moveCursor(n.direction===`up`?-1:1);return}switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#Gt(),this.#on();break}dismiss();break;default:if(isOnFreeformRow()){let e=this.#U.apply(l,t);e!==void 0&&(l=e,this.#Gt(),this.#on())}}return}let r=this.#U.apply(l,t,{multiline:!0});if(r!==void 0){l=r,this.#Gt(),this.#et(l),this.#on();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#Gt(),this.#et(l),this.#on());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#Gt(),this.#et(l),this.#on();break}dismiss()}},this.#Ft()})}setVercelStatus(e){this.#R=e,this.#on()}setRemoteConnectionStatus(e){this.#z=e,this.#on()}reset(){this.#h=[],this.#g.clear(),this.#v.clear(),this.#L=void 0,this.#I.length=0,this.#y.length=0,this.#P=!1,this.#F=void 0,this.#tt(),this.#Z=!1,this.#Me=void 0,this.#oe&&(this.#n.clearAll(),this.#on())}renderSessionBoundary(){this.#tn();let e=this.#x.stopWorking(this.#Qe());for(let e of this.#w){let t=this.#g.get(e);if(t===void 0)continue;this.#g.delete(e);let n=this.#h.indexOf(t),{id:r,...i}=t;this.#h[n]={...i,live:!1}}for(let{id:t,...n}of e)this.#en(n);this.#v.clear(),this.#tt();let t=this.#i.colors,n=this.#i.glyph,r=t.dim(`${n.cornerOpen}${n.dash.repeat(2)} Session restarted, clear context.`);this.#en({kind:`session-boundary`,body:r,live:!1}),this.#on()}#tt(){this.#x.reset(),this.#Zt(),this.#C=void 0,this.#w=new Set,this.#T.length=0,this.#ne=!1,this.#Q.reset(),this.#$t()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Mt(),this.#en({kind:`notice`,body:t,live:!1}),this.#on())}restoreDraft(e){let t=this.#W?this.#te:void 0;if((t===void 0?this.#ee.text:this.#B).length>0)return;let n=lineOf(stripPromptControlCharacters(e));t===void 0?this.#ee=n:t(n),this.renderNotice(`The turn was cancelled from outside this prompt, so its message is back in the input.`)}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#nt();return}this.#Mt(),this.#Ve=t,this.#on()}clearSetupWarning(){this.#nt()}#nt(){this.#Ve!==void 0&&(this.#Ve=void 0,this.#on())}renderCommandInvocation(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Mt(),this.#at(t),this.#on())}async choosePromptCommand(e){this.#Mt(),this.#W=!1;let t=typeaheadFor(e,`/`);return this.#Re=e=>{let n=renderCommandSuggestions(t,this.#i,e),r=Math.max(1,this.#wn()-7),i=Math.max(0,Math.min(t.selectedIndex-r+1,n.length-r));return renderTransientDrawer(n.slice(i,i+r),[`↑/↓ move · Enter select · Esc close`],this.#i,e)},this.#on(),await new Promise(e=>{this.#ze=()=>e(void 0),this.#be=n=>{if(n.type===`up`||n.type===`ctrl-p`)t=moveTypeaheadSelection(t,-1),this.#on();else if(n.type===`down`||n.type===`ctrl-n`)t=moveTypeaheadSelection(t,1),this.#on();else if(n.type===`enter`){let n=selectedTypeaheadCommand(t);this.#rt(),e(n===void 0?void 0:typeaheadCompletion(n))}else(n.type===`escape`||n.type===`ctrl-c`)&&(this.#rt(),e(void 0))},this.#Ft()})}async showInfoPanel(e){this.#Mt(),this.#W=!1;let t=stripAnsi(e),n=0,infoRows=e=>t.split(`
|
|
3
3
|
`).flatMap(t=>wrapVisibleLine(t,Math.max(1,e-4)).map(e=>` ${e}`));this.#Re=e=>{let t=infoRows(e),r=Math.max(1,this.#wn()-7);return n=Math.min(n,Math.max(0,t.length-r)),renderTransientDrawer(t.slice(n,n+r),[t.length>r?`↑/↓ scroll · Esc close`:`Esc to close`],this.#i,e)},this.#on(),await new Promise(e=>{this.#ze=e,this.#be=t=>{if(t.type===`up`||t.type===`ctrl-p`)n=Math.max(0,n-1),this.#on();else if(t.type===`down`||t.type===`ctrl-n`){let e=Math.max(1,this.#wn()-7);n=Math.min(n+1,Math.max(0,infoRows(this.#Cn()).length-e)),this.#on()}else(t.type===`escape`||t.type===`ctrl-c`||t.type===`enter`)&&(this.#rt(),e())},this.#Ft()})}#rt(){this.#Re=void 0,this.finishCommand({kind:`dismiss`}),this.#be=void 0,this.#ze=void 0,this.#It(),this.#on()}finishCommand(e){if(e.kind===`dismiss`){this.#it()&&this.#on();return}let t=this.#ot(e.summary);t!==void 0&&(t.status=`done`);let n=e.message===void 0?``:stripAnsi(e.message);if(n.trim().length===0){t!==void 0&&this.#on();return}this.#Mt();let r={kind:`result`,body:n,live:!1};this.#en(r);let i=t===void 0?-1:this.#h.indexOf(t);i!==-1&&(this.#h.pop(),this.#h.splice(i+1,0,r)),this.#on()}#it(){let e=this.#_;return e!==void 0&&(this.#_=void 0,this.#h=this.#h.filter(t=>t!==e),!0)}#at(e){this.#_!==void 0&&this.#ot();let t={kind:`command`,body:e,live:!0};this.#_=t,this.#en(t)}#ot(e){let t=this.#_;if(t!==void 0)return this.#_=void 0,t.live=!1,e!==void 0&&(t.result=stripTerminalControls(e)),t}#st(e){this.#Mt(),this.#A===void 0&&(this.#W=!1),this.#Be={title:stripTerminalControls(e),startedAtMs:Date.now(),lines:[],outputBuffer:[]},this.#Kt(),this.#on()}#ct(e){this.#Be!==void 0&&(this.#Be.navigation=e,this.#on())}#lt(e){this.#We=void 0,this.#St();let t=this.#Be;if(t!==void 0){if(this.#Be=void 0,this.#A===void 0?this.#qt():this.#Xe(),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.#en({kind:`flow`,title:`info`,body:e.join(`
|
|
4
4
|
`),live:!1}),this.#en({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#on()}}async#ut(e){let t=this.#gt(e.message),n=isMultiSelectRequest(e),r=e.kind===`search`?e.searchAction:void 0,i=e.kind===`search`&&e.layout===void 0,a=e.options,o=e.navigation?.kind===`planner`,s={options:a,searchAction:r,submitRow:n&&!o};`initialValue`in e&&e.initialValue!==void 0&&(s.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(s.initialValues=e.initialValues);let c=initialSelectState(s),l,u=!1,d=0,isCurrentSearch=e=>e===d,clearSearch=()=>{d+=1,u=!1,c=reduceSelect(c,{type:`clear`},{options:a,searchAction:r,submitRow:n&&!o}),this.#on()},loadSearch=async(e,t)=>{u=!0,l=void 0;let i=++d;this.#on();try{let s=await t(e);if(!isCurrentSearch(i))return;let l=c.filter;a=s,c={...initialSelectState({options:s,searchAction:r,submitRow:n&&!o}),filter:l}}catch(e){isCurrentSearch(i)&&(l=toErrorMessage(e))}finally{isCurrentSearch(i)&&(u=!1,this.#on())}},f=e.notices;if(e.kind===`task-list`||e.kind===`search`&&e.layout===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));f=e.notices??r,t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,message:``,options:a,select:c};return f!==void 0&&f.length>0&&(t.notices=f),l!==void 0&&(t.error=l),u&&(t.loadingFrame=this.#pn()),i&&(t.caretVisible=this.#pe),t};return t.question=e=>renderSelectQuestion(panelState(),this.#i,e),i&&this.#Ut(),this.#on(),await this.#yt((t,s)=>{let close=e=>{d+=1,s(e)};if(u){t.type===`ctrl-c`?close(void 0):t.type===`escape`?clearSearch():t.type===`ctrl-r`&&this.#on();return}let f=e.navigation?.kind===`planner`?e.navigation:void 0,p=t.type===`left`&&(f?.activeStep??0)>(f?.firstNavigableStep??0)?`back`:t.type===`right`&&f!==void 0&&f.activeStep>=(f.firstNavigableStep??0)&&f.activeStep<f.steps.length-1?`forward`:void 0;if(p!==void 0){close({kind:`navigate`,direction:p,values:n?orderedSelection(a,c.selected):[]});return}let m={key:t,options:a,searchAction:r,select:c},h=reduceSetupSelectInput(n?{...m,kind:e.kind,required:e.required,plannerNavigation:o||void 0}:{...m,kind:e.kind});switch(h.kind){case`cancel`:close(void 0);return;case`repaint`:this.#on();return;case`update`:c=h.select,l=void 0,i&&this.#Gt(),this.#on();return;case`submit`:{let e=searchActionQuery(h.values[0]??``),t=r?.load;if(e===void 0||t===void 0){close(h.values);return}loadSearch(e,t);return}case`error`:l=h.message,this.#on();return;case`ignore`:return}},i?()=>this.#Wt():void 0).promise}#dt(e){this.#Mt();let t=this.#_t();t.status={text:stripTerminalControls(e.status),startedAtMs:Date.now()};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#i,t),this.#on();let r=this.#yt((t,r)=>{let i=setupSelectionIntent(t,{textNavigation:!0});switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#on();return;case`repaint`:this.#on();return;case`submit`:n!==void 0&&r(e.actions[n].value);return;case void 0:return}},()=>{t.status=void 0});return{choice:r.promise,close:()=>r.settle(void 0)}}async#ft(e){let t=this.#gt(e.message),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`inline-edit`,layout:`task-list`,message:``,options:e.options,select:r,edit:{optionValue:e.editable.value,caretVisible:this.#pe,editor:{kind:`rename`,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint}}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#i,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?this.#Ut():(i=lineOf(``),this.#Wt())};return syncEditableRow(),this.#on(),await this.#yt((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#Gt(),this.#on()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#on()},submit=()=>{let t=selectValueAtCursor([...e.options],r.cursor);if(t===void 0)return;if(t!==e.editable.value){n({kind:`selected`,value:t});return}let o=(i.text||e.editable.defaultValue).trim(),s=e.editable.validate?.(o);if(s!==void 0){a=s,this.#on();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t,{textNavigation:!onEditableRow()});switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#on();return;case void 0:}if(!onEditableRow())return;let s=this.#U.apply(i,t);s!==void 0&&applyEditor(s)},()=>this.#Wt()).promise}async#pt(e){this.#U.clear();let t=this.#gt(e.message),n=initialProviderPickerState(e.options,e.initialValue),r,cursorBadge=()=>{if(n.phase.kind!==`inactive`)return;let t=selectValueAtCursor([...e.options],n.select.cursor),r=e.options.find(e=>e.value===t);if(r!==void 0)return enterBadge(this.#i,r.checked===!0?`change`:void 0)};t.question=t=>{let r=cursorBadge(),i={kind:`inline-edit`,layout:`stacked`,message:``,options:e.options,select:n.select,edit:{optionValue:`ai-gateway-key`,caretVisible:this.#pe,editor:{kind:`key`,phase:n.phase}}};return r!==void 0&&(i.cursorBadge=r),renderSelectQuestion(i,this.#i,t)};let syncCaret=()=>{n.phase.kind===`editing`||n.phase.kind===`invalid`?this.#Ut():this.#Wt()};return syncCaret(),this.#on(),await this.#yt((t,i,a)=>{let dispatch=t=>{let o=transitionProviderPicker(n,t,e.options);switch(o.kind){case`ignore`:return;case`clear`:r?.abort(),r=void 0,n=o.state,syncCaret(),this.#on();return;case`cancel`:i(void 0);return;case`render`:n=o.state,syncCaret(),this.#on();return;case`validate`:{n=o.state,syncCaret(),this.#on();let t=new AbortController;r=t;let i;try{i=e.validateInlineKey(o.key,t.signal)}catch(e){a(e);return}i.then(e=>{r!==t||t.signal.aborted||(r=void 0,dispatch({type:`validated`,validation:e}))},e=>{r!==t||t.signal.aborted||(r=void 0,a(e))});return}case`settle`:i(o.result);return}},o=setupSelectionIntent(t,{textNavigation:n.phase.kind===`inactive`});switch(o?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:o.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#on();return;case void 0:}if(n.phase.kind!==`editing`&&n.phase.kind!==`invalid`)return;let s=applyLineEditorKey(n.phase.editor,t);s!==void 0&&(this.#Gt(),dispatch({type:`edit`,editor:s}))},()=>{r?.abort(),r=void 0,this.#Wt()}).promise}async#mt(e){e.mask===!0&&this.#U.clear();let t=this.#gt(e.message),n=lineOf(``),r;return t.question=t=>{let i={message:``,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#pe)},this.#Ut(),this.#on(),await this.#yt((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Gt(),this.#on()},a=e.mask?applyLineEditorKey(n,t):this.#U.apply(n,t);if(a!==void 0){apply(a);return}switch(t.type){case`ctrl-c`:case`escape`:i(void 0);return;case`ctrl-r`:this.#on();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#on();return}i(t);return}default:return}},()=>this.#Wt()).promise}async#ht(e){let t=this.#gt(e.message);return t.question=t=>renderAcknowledgeQuestion({message:``,lines:e.lines},this.#i,t),this.#on(),await this.#yt((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#on();return;default:return}}).promise}#gt(e){this.#Mt(),this.#W=!1;let t=this.#_t();return t.questionTitle=stripTerminalControls(e),t.status!==void 0&&(t.status=void 0,t.summary=void 0,t.preview=void 0),t}#_t(){return this.#Be===void 0&&(this.#Be={title:``,startedAtMs:Date.now(),lines:[],outputBuffer:[],implicit:!0}),this.#Be}#vt(){this.#Be?.implicit===!0?this.#Be=void 0:this.#Be!==void 0&&(this.#Be.question=void 0,this.#Be.questionTitle=void 0,this.#Be.hideLinesWhileQuestion=!1),this.#be=void 0,this.#It(),this.#A===void 0?this.#Be!==void 0&&this.#xt():this.#Xe(),this.#Be===void 0&&this.#on()}#yt(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#vt(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#vt(),i(e))};return this.#Ht(),this.#be=t=>{t.type===`ctrl-c`&&this.#Ot(),e(t,settle,reject)},this.#Ft(),{promise:a,settle}}#bt(e){let t,n=new Promise(e=>{t=e});return this.#We=t,this.#xt(e?.interruptible??!0),{promise:n,dispose:()=>{this.#We===t&&(this.#We=void 0,this.#St())}}}#xt(e=!0){if(this.#A!==void 0){this.#Xe();return}if(this.#We===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#Ot();let e=this.#We;this.#We=void 0,this.#St(),e?.(t.type===`ctrl-c`?`ctrl-c`:`escape`);return}t.type===`ctrl-r`&&this.#on()};this.#Ge=consumer,this.#Ht(),this.#be=consumer,this.#Ft()}#St(){this.#Ge!==void 0&&(this.#be===this.#Ge&&this.#It(),this.#Ge=void 0)}#Ct(e){let t=e===void 0?void 0:{text:stripTerminalControls(e),startedAtMs:Date.now()};if(this.#Be!==void 0){this.#Be.status=t,t===void 0&&(this.#Be.preview=void 0),this.#on();return}if(!(this.#W||this.#C?.working===!0)){if(t===void 0){this.#ie=void 0,this.#qt(),this.#on();return}this.#Mt(),this.#he=Date.now(),this.#Kt(),this.#ie=t.text,this.#on()}}#wt(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Be;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#on();return}this.#Mt(),this.#en({kind:`flow`,title:t,body:n,live:!1}),this.#on()}#Tt(e){let t=this.#Be;t!==void 0&&(t.lines=[],t.outputBuffer=[],t.preview=void 0,t.status=void 0,t.summary=e===void 0?void 0:{headline:stripTerminalControls(e.headline),facts:e.facts.map(e=>({label:stripTerminalControls(e.label),value:stripTerminalControls(e.value)}))},this.#on())}#Et(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Be;if(n===void 0){this.#wt(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#on()}async#Dt(e){this.#xe=``,this.#Ht(),this.#We=void 0,this.#St(),this.#It(),this.#Jt(),this.#n.clear(),this.#En(),this.#r.enter({cursor:`visible`,mouse:!1}),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#r.exit(),this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#xe=``,this.#Ht(),this.#n.hideCursor(),this.#Tn(),this.#Be===void 0?this.#$t():(this.#Kt(),this.#xt()),this.#n.reset(),this.#on()}}setSessionId(e){this.#Ue=e}shutdown(){this.#Pt();for(let e of this.#Y.values())clearTimeout(e);if(this.#Y.clear(),this.#se&&!this.#ce){this.#ce=!0;let e=this.#Ue===void 0?``:` ${this.#i.glyph.dot} session ${this.#Ue}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}requestInterrupt(){this.#Be!==void 0&&this.#be?.({type:`ctrl-c`}),this.#Pt()}exitRequested(){return this.#le}#Ot(){this.#le=!0,this.#fe?.()}async#kt(e){if(this.#Ke!==void 0||!this.#oe)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Cn(),height:this.#wn()}),paint:e=>this.#r.paint(e,this.#wn()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#qe});this.#Ke=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#jt=e,this.#be=e=>{t.handleKey(e)===`close`&&this.#At()},this.#Ft(),t.start()})}#At(){let e=this.#Ke;if(e===void 0)return;this.#Ke=void 0,e.dispose(),this.#It(),this.#r.exit(),this.#n.hideCursor(),this.#on(),this.#n.showCursor();let t=this.#jt;this.#jt=void 0,t?.()}#jt;#Mt(e){this.#ae=e?.title??this.#ae,!this.#oe&&(this.#oe=!0,this.#se=!0,this.#n.reset(),this.#n.hideCursor(),this.#Tn(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#we=()=>this.#on(),this.#t.on(`resize`,this.#we),process.on(`exit`,this.#Nt))}#Nt=()=>{this.#oe&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#Pt(){this.#Le=void 0;let e=this.#ze;e!==void 0&&(this.#ze=void 0,this.#Re=void 0,this.finishCommand({kind:`dismiss`}),this.#be=void 0,e()),this.#At();let t=this.#re;if(this.#re=void 0,t?.(interruptedError()),this.#It(),this.#Wt(),this.#Jt(),this.#ve!==void 0&&(clearTimeout(this.#ve),this.#ve=void 0),this.#ye=!1,this.#Fn(),this.#oe){this.#Ln(),this.#ot();for(let e of this.#h)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#on(),this.#n.clear(),this.#n.showCursor(),this.#En(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#we&&=(this.#t.off(`resize`,this.#we),void 0),process.off(`exit`,this.#Nt),this.#oe=!1}}#Ft(){this.#e.off(`data`,this.#Lt),this.#e.on(`data`,this.#Lt),this.#xe.length>0&&queueMicrotask(()=>{this.#be!==void 0&&this.#xe.length>0&&(this.#Bt(),this.#Rt())})}#It(){this.#e.off(`data`,this.#Lt),this.#Ht(),this.#be=void 0}#Lt=e=>{this.#Ht(),this.#xe+=this.#Se.write(e),this.#Bt(),this.#Rt()};#Rt(){if(this.#xe===`\x1B`){this.#Ce=setTimeout(()=>{this.#xe===`\x1B`&&(this.#xe=``,this.#zt({type:`escape`}))},30),this.#Ce.unref?.();return}if(isIncompletePaste(this.#xe)){let e=this.#xe;this.#Ce=setTimeout(()=>{if(this.#xe!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#xe=``,t.length>0&&this.#zt({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#Ce.unref?.();return}if(isIncompleteOsc(this.#xe)){let e=this.#xe;this.#Ce=setTimeout(()=>{this.#xe===e&&(this.#xe=``)},incompletePasteFlushMs),this.#Ce.unref?.()}}#zt(e){this.#U.interruptYank(e),this.#be?.(e)}#Bt(){for(;this.#xe.length>0;){let e=nextKey(this.#xe);if(e.incomplete)return;if(this.#xe=this.#xe.slice(e.consumed),e.key!==void 0&&e.key.type!==`ignore`){if(e.key.type===`osc`){this.#Vt(e.key.value);continue}this.#zt(e.key)}}}#Vt(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#qe=t,this.#Ke?.setTerminalBackground(t))}#Ht(){this.#Ce&&=(clearTimeout(this.#Ce),void 0)}#Ut(){this.#Wt(),this.#Gt(),this.#ge=setInterval(()=>{this.#pe=!this.#pe,this.#on()},500),this.#ge.unref?.()}#Wt(){this.#ge&&=(clearInterval(this.#ge),void 0),this.#pe=!0}#Gt(){this.#pe=!0}#Kt(){this.#Jt(),this.#_e=setInterval(()=>{this.#me+=1,this.#on()},90),this.#_e.unref?.()}#qt(){this.#Yt()||this.#Jt()}#Jt(){this.#_e&&=(clearInterval(this.#_e),void 0)}#Yt(){return this.#C?.working===!0||this.#x.tasks.length>0}#Xt(){this.#x.finishing&&this.#S===void 0&&(this.#S=setTimeout(()=>{this.#S=void 0,this.#C!==void 0&&this.renderConversation(this.#C)},TASK_END_GRACE_MS),this.#S.unref?.())}#Zt(){this.#S!==void 0&&(clearTimeout(this.#S),this.#S=void 0)}#Qt(e,t=Math.max(8,Math.floor(this.#wn()/2))){let n=this.#x.tasks;if(n.length===0)return[];let r=this.#C?.working===!0&&this.#ie===void 0,i=Date.now(),a=r&&this.#C!==void 0?turnActivity(this.#C,n):`Working`;return renderTaskPanelRows(n,{width:e,theme:this.#i,nowMs:i,maxRows:t,activity:a.startsWith(`Waiting for `)?`Waiting`:a,turnElapsedMs:r?Math.max(0,i-(this.#Q.startedAtMs??i)):void 0})}#$t(){this.#Yt()?this.#_e===void 0&&(this.#he=Date.now(),this.#Kt()):this.#Be===void 0&&this.#k===void 0&&this.#ie===void 0&&this.#Jt()}#en(e){e.id!==this.#Me?.id&&this.#Ln(),e.updateSeq=++this.#b,this.#h.push(e),e.id&&this.#g.set(e.id,e)}#tn(){let e=this.#Q.settle(this.#nn());if(e===void 0||(this.#$=e,this.#f?.reportStats(),e.elapsedMs<=1e4&&e.inputTokens<=2e4))return;let t=`Done in ${this.#vn(e)}`,n=this.#C?.data.lastStepUsage?.inputTokens??0;if(this.#De!==void 0&&this.#De>0&&n>0){let e=Math.round(n/this.#De*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#en({kind:`turn-stats`,body:t,live:!1})}#nn(){return this.#C?.data.usage??{inputTokens:0,outputTokens:0}}renderError(e,t){this.#Mt(),this.#rn(e,t)}#rn(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#f?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#f===void 0?a:`details: ${this.#f.displayPath}`),this.#en(c),this.#on()}#in(e){if(e.id&&this.#v.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#b;return}this.#en(e)}#an(e){this.#h=this.#h.filter(t=>t.id!==e),this.#g.delete(e)}#on(){if(this.#oe){if(this.#Te){this.#Ee=!0;return}this.#Te=!0;try{do this.#Ee=!1,this.#sn();while(this.#Ee)}finally{this.#Te=!1}}}#sn(){if(!this.#oe)return;if(this.#Ke!==void 0){this.#Ke.repaint();return}let e=this.#Cn(),t=this.#gn(e),n=this.#N===void 0?[]:this.#dn(),r=Math.max(1,this.#wn()-n.length-t.length),i=[],a=this.#L,o=groupToolBlocksForDisplay(this.#h),s=0;for(;s<o.length&&o[s].display.live===!1;)s+=1;if(s>0){let e=new Set(o.slice(0,s).flatMap(e=>e.members));for(let t=this.#h.length-1;t>=0;--t)e.has(this.#h[t])&&this.#h.splice(t,1)}for(let t of o.slice(0,s)){for(let e of t.members)this.#y.push(e),e.id&&(this.#v.add(e.id),this.#g.delete(e.id));if(this.#zn(t.display))continue;let n=this.#fn(t.display,e,a);a=previousBlockOf(t.display),this.#L=a,i.push(...n),this.#I.push(...n)}let c=[];for(let{display:t}of o.slice(s)){if(this.#zn(t))continue;let n=this.#fn(t,e,a);a=previousBlockOf(t);for(let e=0;e<n.length;e+=1)c.push({block:t,row:n[e]})}let l=[...n,...clipLiveRows(c.map(e=>e.row),r,e,this.#i),...t];i.length>0?this.#n.flush(i,l):this.#n.update(l)}#cn(){if(!this.#oe)return;let e=this.#Cn(),t=this.#gn(e),n=Math.max(1,this.#wn()-t.length),r=this.#L,i=[];for(let{display:t}of groupToolBlocksForDisplay(this.#h)){if(this.#zn(t))continue;let n=this.#fn(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#i),...t];this.#n.clearAll(),this.#n.flush([...this.#dn(),...this.#I],a)}logDisplayMode(){return this.#m}setLogDisplayMode(e){e!==this.#m&&(this.#m=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#un(),this.#oe&&this.#cn())}flushDelayedDevBuildErrors(){let e=this.#je;e!==void 0&&(this.#je=void 0,this.#en({kind:`log`,title:`stderr`,logLevel:`error`,body:e,live:!1}),this.#on())}#ln(){this.#ye=!0,this.#ve!==void 0&&clearTimeout(this.#ve),this.#ve=setTimeout(()=>{this.#ye=!1,this.#ve=void 0,this.#on()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#m)),this.#on()}#un(){let e=this.#Cn();this.#I.length=0;let t;for(let{display:n}of groupToolBlocksForDisplay(this.#y,{logCoalescing:`runs`})){if(this.#zn(n))continue;let r=this.#fn(n,e,t);t=previousBlockOf(n),this.#I.push(...r)}this.#L=t}#dn(){let e=this.#E,t=this.#N;if(e===void 0&&t===void 0)return[];let n={name:e?.name??t?.name,theme:this.#i,width:this.#Cn()};return e?.info!==void 0&&(n.info=e.info),buildAgentHeader(n)}#fn(e,t,n){let r={renderMarkdown:this.#a,activityPulse:this.#mn(this.#he,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)};n!==void 0&&(r.previous=n),this.#Be!==void 0&&(r.setupFlowOpen=!0),this.#Re!==void 0&&(r.transientPanelOpen=!0);let i=renderBlockLines(e,t,this.#i,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#pn(){return this.#i.spinner[this.#me%this.#i.spinner.length]??``}#mn(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#hn(e){return{glyph:this.#mn(e.startedAtMs,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)}}#gn(e){let t=this.#i.colors,n=[``];if(this.#Re!==void 0){let t=this.#Re(e);return[...t.rows,...t.controls]}if(this.#Le!==void 0){let t=this.#Le(e),n=this.#wn()-t.rows.length-t.controls.length-1;return[...(n>=4?this.#Qt(e,n+1):[]).slice(0,-1),...t.rows,...t.controls]}let r=this.#Be;if(r!==void 0&&(this.#A===void 0||r.question!==void 0)){let t=this.#hn(r),i;if(r.status!==void 0){let{startedAtMs:e,...n}=r.status,a=Date.now()-e,o=a>=5e3?` ${formatTurnDuration(a)}`:``;i={...n,text:`${n.text}${o}`,indicator:t}}let a;if(r.question!==void 0){let t=r.question(e);a={kind:`question`,title:r.questionTitle,rows:t},i!==void 0&&(a={kind:`question`,title:r.questionTitle,rows:t,status:i})}else i===void 0?a=r.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:r.preview,indicator:t}:(a={kind:`status`,status:i},r.preview!==void 0&&(a={kind:`status`,status:i,preview:r.preview}));let o={title:r.title,navigation:r.navigation,lines:r.summary===void 0?r.hideLinesWhileQuestion===!0?[]:r.lines:[{text:r.summary.headline,tone:`success`},...r.summary.facts.map(e=>({text:`${e.label}: ${e.value}`,tone:`info`}))],content:a},s=renderFlowDrawer(o,this.#i,e);return n.length===1&&n[0]===``&&(n.length=0),n.push(...s.rows),s.controls.length>0&&n.push(...s.controls),this.#xn(n,e),n}r!==void 0&&n.push(...flowMessageRows(r.lines,this.#i).map(t=>t.length===0?``:clip(` ${t}`,e))),this.#k===void 0&&this.#Ve!==void 0&&n.push(...renderAttentionRows(this.#Ve,e,this.#i),``);let i=this.#C?.working===!0&&this.#ie===void 0,a=this.#Qt(e);a.length>0&&n.push(...a);let o=renderMessageQueueRows({view:this.#He.view(),width:e,theme:this.#i});if(o.length>0&&n.push(...o,``),i&&(a.length===0&&n.push(this.#_n(e)),this.#ne&&n.push(clip(`${t.yellow(this.#i.glyph.dotActive)} ${t.dim(`Cancelling turn… · Ctrl+C to stop waiting, then again to exit`)}`,e)),(a.length===0||this.#ne)&&n.push(``)),this.#W){let r=this.#G===void 0?void 0:inlineCommandHint(this.#G),a=this.#Ye(e);this.#ue&&n.push(clip(t.dim(`Press Ctrl+C again to exit`),e),``);let o=r?t.dim(` ${r}`):``,s=[];this.#bn(s,e);let c=Math.max(1,this.#wn()-1-n.length-1-a.length-s.length-(a.length>0?2:0)),l={text:this.#B,cursor:this.#V,width:e,theme:this.#i,caretVisible:this.#pe,ghost:o,maxRows:c};this.#X&&this.#B.length===0&&(l.placeholder=this.#A===void 0?this.#Z||i?``:this.#D:`Message · Enter to queue`);let u=promptInputRows(l);return a.length>0&&u.at(-1)===``&&u.pop(),n.push(...u),a.length>0&&n.push(t.dim(this.#i.glyph.dash.repeat(e))),n.push(...a),a.length>0&&s.length>0&&n.push(t.dim(this.#i.glyph.dash.repeat(e))),n.push(...s),n}if(i||this.#ee.text.length>0)return this.#yn(n,e,{inert:i,adjacent:a.length>0}),this.#bn(n,e),n;let s=this.#ie??`Ready`,c=this.#Sn(),l=t.dim(this.#i.glyph.dot),u=c?`${l} ${s} ${t.dim(this.#i.glyph.dot)} ${c}`:`${l} ${s}`;return n.push(clip(u,e)),this.#bn(n,e),n}#_n(e){let t=this.#i.colors,n=this.#Q.startedAtMs??Date.now(),r=Math.max(0,Date.now()-n),i=r%1e3<500?this.#i.unicode?`•`:`*`:` `,a=r<1e3?`0s`:formatTurnDuration(Math.floor(r/1e3)*1e3),o=`${this.#C===void 0?`Thinking`:turnActivity(this.#C,this.#x.tasks)} (${a})`,{inputTokens:s,outputTokens:c}=this.#Q.usage(this.#nn());return clip(`${i} ${o}${s>0||c>0?t.dim(` (${formatTokenFlow({inputTokens:s,outputTokens:c},this.#i.glyph)})`):``}`,e)}#vn(e){let{inputTokens:t,outputTokens:n}=e,r=t===0&&n===0?``:` (${formatTokenFlow({inputTokens:t,outputTokens:n},this.#i.glyph)})`;return`${formatTurnDuration(e.elapsedMs)}${r}`}#yn(e,t,n){!n.adjacent&&e.at(-1)!==``&&e.push(``);let r={text:this.#ee.text,cursor:this.#ee.cursor,width:t,theme:this.#i,caretVisible:!0,ghost:``,maxRows:4,inert:n.inert};n.inert&&this.#ee.text.length===0&&(r.placeholder=``),e.push(...promptInputRows(r))}#bn(e,t){if(this.#k!==void 0){let n=this.#Be?.status?.text??{starting:`Starting agent…`,connecting:`Reading saved connection…`,updating:`Loading selected model…`}[this.#k],r=this.#mn(this.#M,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH);e.push(clip(this.#i.colors.dim(`${r} ${n}`),t));return}let n=this.#z===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#i,width:r};this.#Pe&&this.#Ne!==void 0&&(i.devBuild=this.#Ne),this.#ye&&(i.logLevel=this.#m);let a=this.#E?.info?.agent.model;if(a?.routing.kind===`dynamic`){let e=this.#C?.data.modelId;i.dynamicModel=!0,e!==void 0&&(i.model=e)}else a?.id!==void 0&&(i.model=a.id);a?.reasoning!==void 0&&a.reasoning!==`provider-default`&&(i.reasoning=a.reasoning),readGatewayServiceTier(a?.providerOptions).kind===`priority`&&(i.fastMode=!0);let o=a?.endpoint;o!==void 0&&(i.endpoint=o),this.#R!==void 0&&(i.vercel=this.#R),this.#z!==void 0&&(i.remote=this.#z);let s=buildStatusLine(i);s!==void 0&&e.push(clip(`${n}${s}`,t))}#xn(e,t){if(this.#z===void 0)return;let n=Math.max(1,t-2),r=buildStatusLine({remote:this.#z,theme:this.#i,width:n});r!==void 0&&e.push(``,clip(` ${r}`,t))}#Sn(){let e=this.#i.colors,t=[],n=this.#$,r=n===void 0?void 0:formatAssistantResponseStats({totalTokens:n.inputTokens+n.outputTokens,outputTokens:n.outputTokens,tokensPerSecond:n.elapsedMs>0?n.outputTokens/(n.elapsedMs/1e3):void 0},this.#u);return r&&t.push(r),t.length>0?e.dim(t.join(` ${this.#i.glyph.dot} `)):``}#Cn(){return Math.max(20,this.#t.columns||80)}#wn(){return Math.max(8,this.#t.rows||24)}#Tn(){if(this.#Oe!==void 0||!this.#d)return;this.#ke=``,this.#Ae=``;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.#kn(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=[`error`,`warn`,`log`,`info`,`debug`],t=e.map(e=>[e,console[e]]);for(let t of e)console[t]=(...e)=>this.#On({level:t===`log`?`info`:t,text:format(...e)});setConsoleRecordSubscriber(e=>this.#On(e));let n=capture(process.stdout,`stdout`),r=capture(process.stderr,`stderr`);this.#f?.subscribeLogRecords(e=>this.#Dn(e)),this.#Oe=()=>{this.#f?.unsubscribeLogRecords(),setConsoleRecordSubscriber(void 0);for(let[e,n]of t)console[e]=n;n(),r()}}#En(){let e=this.#Oe;e!==void 0&&(this.#Oe=void 0,e(),this.#ke.length>0&&(this.#f?.append({source:`stdout`,detail:this.#ke}),this.#Rn()&&process.stdout.write(`${this.#ke}\n`),this.#ke=``),this.#Ae.length>0&&(this.#f?.append({source:`stderr`,detail:this.#Ae}),this.#Rn()&&process.stderr.write(`${this.#Ae}\n`),this.#Ae=``))}#Dn(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#jn(`[eve:${e.namespace}] ${e.message}${t}`,e.level),this.#on()}#On(e){let t=e.level===`error`||e.level===`warn`?`stderr`:`stdout`;this.#f?.append({source:t,level:e.level,detail:e.text}),t===`stderr`?this.#jn(stripAnsi(e.text),e.level):this.#An(stripAnsi(e.text),e.level),this.#on()}#kn(e,t){let n=(e===`stdout`?this.#ke:this.#Ae)+t;if(e===`stdout`&&parseDevRebuildLogLine(n.trimEnd())!==void 0){this.#ke=``,this.#f?.append({source:e,detail:n.trimEnd()}),this.#An(n.trimEnd()),this.#on();return}let r=n.lastIndexOf(`
|
|
5
5
|
`),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#ke=i:this.#Ae=i,r===-1)return;let a=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);a.trim().length!==0&&(this.#f?.append({source:e,detail:a}),e===`stdout`?this.#An(a):this.#jn(a),this.#on())}#An(e,t){let n=[],flushPending=()=>{if(n.length===0)return;let e=n.join(`
|
|
@@ -7,4 +7,4 @@ import{setConsoleRecordSubscriber}from"../console-records.js";import{buildAgentH
|
|
|
7
7
|
`)){let e=parseSandboxLogLine(r.trimEnd());if(e!==void 0){flushPending(),this.#en({kind:`sandbox`,logLevel:t,body:e,live:!1});continue}let i=parseDevRebuildLogLine(r.trimEnd());if(i===void 0){n.push(r);continue}flushPending(),this.#Nn(i,r.trimEnd())}flushPending()}#jn(e,t){let n=e.split(`
|
|
8
8
|
`),r=n.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(r===-1){if(this.#f===void 0){this.#en({kind:`log`,title:`stderr`,logLevel:t,body:e,live:!1});return}let n=presentDiagnostic(e,this.#f.displayPath);if(n.kind===`inline`){this.#en({kind:`log`,title:`stderr`,logLevel:t,body:n.text,live:!1});return}this.#en({kind:`log`,title:`stderr`,body:formatStoredDiagnostic(n),logVisibility:`summary`,logLevel:t,live:!1}),this.#en({kind:`log`,title:`stderr`,body:e,logVisibility:`all-only`,logLevel:t,live:!1});return}let i=n.slice(0,r).join(`
|
|
9
9
|
`);i.trim().length>0&&this.#en({kind:`log`,title:`stderr`,logLevel:t,body:i,live:!1});let a=n.slice(r).join(`
|
|
10
|
-
`);this.#Mn(a)}#Mn(e){if(this.#Fn(),this.#m===`all`){if(e.trim().length===0)return;this.#en({kind:`log`,title:`stderr`,logLevel:`error`,body:e,live:!1});return}this.#je=e}#Nn(e,t){let n=this.#In();if(e.kind===`failed`){this.#Mn(t);return}if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(this.#Pn({phase:`building`,summary:t}),n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#Ie}`;this.#Ie+=1,this.#Me={id:r,summary:t},this.#en({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}let r=n?.state.summary??this.#Ne?.summary;if(r!==void 0&&this.#Pn({phase:`complete`,summary:r}),n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind),e.kind===`rebuilt`&&(this.#je=void 0);return}e.kind===`rebuilt`&&(this.#je=void 0),this.#en({kind:`log`,title:`stdout`,body:t,live:!1})}#Pn(e){this.#Fe!==void 0&&clearTimeout(this.#Fe),this.#Ne=e,this.#Pe=e.phase===`complete`,this.#Fe=setTimeout(()=>{e.phase===`building`?(this.#Pe=!0,this.#Fe=void 0):this.#Fn(),this.#on()},e.phase===`building`?250:4e3)}#Fn(){this.#Fe!==void 0&&clearTimeout(this.#Fe),this.#Ne=void 0,this.#Pe=!1,this.#Fe=void 0}#In(){let e=this.#Me;if(e===void 0)return;let t=this.#g.get(e.id);if(t!==void 0&&t.live===!0)return{state:e,block:t}}#Ln(){let e=this.#Me;if(e===void 0)return;this.#Me=void 0;let t=this.#g.get(e.id);t!==void 0&&(t.live=!1)}#Rn(e){return isLogVisible(this.#m,e)}#zn(e){return e.kind===`sandbox`?!this.#Rn(e.logLevel):e.kind===`log`?e.logVisibility===`summary`&&this.#m===`all`?!0:e.logVisibility===`all-only`?this.#m!==`all`:!this.#Rn(e.logLevel):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}function clip(e,t){return clipVisible(e,t)}function promptInputRows({text:e,cursor:t,width:n,theme:r,caretVisible:i,ghost:a,maxRows:o,placeholder:s,inert:c}){let l=r.colors;if(e.length===0&&s!==void 0){let e=renderInputWithBlockCursor({...visibleLine({text:s,cursor:0},Math.max(1,n-3),r.glyph.ellipsis),visible:i,inverse:l.inverse,render:e=>l.dim(renderInputText(e))});return[clip(`${r.glyph.prompt} ${e}`,n),``]}let u=renderInputText,d=layoutPromptInput({text:e,cursor:t}),f=Math.min(Math.max(1,o),d.rows.length),p=Math.max(0,Math.min(d.caretRow-f+1,d.rows.length-f)),m=c===!0?l.dim(r.glyph.prompt):e.startsWith(`/`)?r.glyph.user:r.glyph.prompt,h=l.dim(r.glyph.ellipsis),g=Math.max(1,n-3),_=[];for(let e=p;e<p+f;e+=1){let t=d.rows[e],o=e===0?m:` `;(e===p&&p>0||e===p+f-1&&p+f<d.rows.length)&&(o=h);let s;if(e===d.caretRow){let{before:e,under:n,after:o}=visibleLine({text:t.text,cursor:d.caretOffset},g,r.glyph.ellipsis);s=renderInputWithBlockCursor({before:e,under:n,after:o,visible:i,inverse:l.inverse,render:u}),a.length>0&&d.rows.length===1&&(s+=a)}else s=u(t.text);_.push(clip(`${o} ${s}`,n))}return _.push(``),_}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),e.subagentCallId!==void 0&&(t.subagentCallId=e.subagentCallId),t}function leadsWithGap(e,t){if((e.kind===`tool`||e.kind===`task`)&&(t?.kind===`user`||t?.kind===`assistant`||t?.kind===`question`))return!0;if(e.kind===`sandbox`&&t?.kind===`sandbox`)return!1;if(t?.kind===`sandbox`&&e.kind!==`sandbox`||t?.kind===`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`error`:case`notice`:case`question`:case`connection-auth`:case`sandbox`:case`log`:case`command`:case`warning`:case`flow`:case`turn-stats`:case`session-boundary`:case`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
|
|
10
|
+
`);this.#Mn(a)}#Mn(e){if(this.#Fn(),this.#m===`all`){if(e.trim().length===0)return;this.#en({kind:`log`,title:`stderr`,logLevel:`error`,body:e,live:!1});return}this.#je=e}#Nn(e,t){let n=this.#In();if(e.kind===`failed`){this.#Mn(t);return}if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(this.#Pn({phase:`building`,summary:t}),n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#Ie}`;this.#Ie+=1,this.#Me={id:r,summary:t},this.#en({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}let r=n?.state.summary??this.#Ne?.summary;if(r!==void 0&&this.#Pn({phase:`complete`,summary:r}),n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind),e.kind===`rebuilt`&&(this.#je=void 0);return}e.kind===`rebuilt`&&(this.#je=void 0),this.#en({kind:`log`,title:`stdout`,body:t,live:!1})}#Pn(e){this.#Fe!==void 0&&clearTimeout(this.#Fe),this.#Ne=e,this.#Pe=e.phase===`complete`,this.#Fe=setTimeout(()=>{e.phase===`building`?(this.#Pe=!0,this.#Fe=void 0):this.#Fn(),this.#on()},e.phase===`building`?250:4e3)}#Fn(){this.#Fe!==void 0&&clearTimeout(this.#Fe),this.#Ne=void 0,this.#Pe=!1,this.#Fe=void 0}#In(){let e=this.#Me;if(e===void 0)return;let t=this.#g.get(e.id);if(t!==void 0&&t.live===!0)return{state:e,block:t}}#Ln(){let e=this.#Me;if(e===void 0)return;this.#Me=void 0;let t=this.#g.get(e.id);t!==void 0&&(t.live=!1)}#Rn(e){return isLogVisible(this.#m,e)}#zn(e){return e.kind===`sandbox`?!this.#Rn(e.logLevel):e.kind===`log`?e.logVisibility===`summary`&&this.#m===`all`?!0:e.logVisibility===`all-only`?this.#m!==`all`:!this.#Rn(e.logLevel):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}function clip(e,t){return clipVisible(e,t)}function promptInputRows({text:e,cursor:t,width:n,theme:r,caretVisible:i,ghost:a,maxRows:o,placeholder:s,inert:c}){let l=r.colors;if(e.length===0&&s!==void 0){let e=renderInputWithBlockCursor({...visibleLine({text:s,cursor:0},Math.max(1,n-3),r.glyph.ellipsis),visible:i,inverse:l.inverse,render:e=>l.dim(renderInputText(e))});return[clip(`${r.glyph.prompt} ${e}`,n),``]}let u=renderInputText,d=layoutPromptInput({text:e,cursor:t}),f=Math.min(Math.max(1,o),d.rows.length),p=Math.max(0,Math.min(d.caretRow-f+1,d.rows.length-f)),m=c===!0?l.dim(r.glyph.prompt):e.startsWith(`/`)?r.glyph.user:r.glyph.prompt,h=l.dim(r.glyph.ellipsis),g=Math.max(1,n-3),_=[];for(let e=p;e<p+f;e+=1){let t=d.rows[e],o=e===0?m:` `;(e===p&&p>0||e===p+f-1&&p+f<d.rows.length)&&(o=h);let s;if(e===d.caretRow){let{before:e,under:n,after:o}=visibleLine({text:t.text,cursor:d.caretOffset},g,r.glyph.ellipsis);s=renderInputWithBlockCursor({before:e,under:n,after:o,visible:i,inverse:l.inverse,render:u}),a.length>0&&d.rows.length===1&&(s+=a)}else s=u(t.text);_.push(clip(`${o} ${s}`,n))}return _.push(``),_}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),e.subagentCallId!==void 0&&(t.subagentCallId=e.subagentCallId),t}function leadsWithGap(e,t){if((e.kind===`tool`||e.kind===`task`)&&(t?.kind===`user`||t?.kind===`assistant`||t?.kind===`question`))return!0;if(e.kind===`sandbox`&&t?.kind===`sandbox`)return!1;if(t?.kind===`sandbox`&&e.kind!==`sandbox`||t?.kind===`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`error`:case`notice`:case`question`:case`connection-auth`:case`sandbox`:case`log`:case`command`:case`warning`:case`flow`:case`turn-stats`:case`session-boundary`:case`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 questionSectionId(e){return`question:${e}`}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};
|
|
@@ -32,7 +32,13 @@ export declare class MockScreen extends EventEmitter implements TerminalOutput {
|
|
|
32
32
|
});
|
|
33
33
|
write(chunk: string | Uint8Array, encodingOrCallback?: BufferEncoding | ((error?: Error | null) => void), callback?: (error?: Error | null) => void): boolean;
|
|
34
34
|
resize(columns: number, rows: number): void;
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The visible grid as text. `hideDim` blanks dim cells, leaving what the
|
|
37
|
+
* screen draws at full weight, such as option labels without descriptions.
|
|
38
|
+
*/
|
|
39
|
+
snapshot({ hideDim }?: {
|
|
40
|
+
readonly hideDim?: boolean;
|
|
41
|
+
}): string;
|
|
36
42
|
rawOutput(): string;
|
|
37
43
|
/**
|
|
38
44
|
* Resolves once the runner parks at an idle prompt: a column-0 `❯` row
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import{EventEmitter}from"node:events";const ansiControlSequencePattern=RegExp(`^\x1B\\[([0-9?;]*)([ -/]*)([@-~])`);var MockUserInput=class extends EventEmitter{isTTY=!0;rawModes=[];resumeCalls=0;pauseCalls=0;setRawMode(e){return this.rawModes.push(e),this}resume(){return this.resumeCalls+=1,this}pause(){return this.pauseCalls+=1,this}type(e){this.emit(`data`,Buffer.from(e))}send(e){this.emit(`data`,Buffer.from(e))}enter(){this.send(`\r`)}backspace(){this.send(``)}up(){this.send(`\x1B[A`)}down(){this.send(`\x1B[B`)}left(){this.send(`\x1B[D`)}right(){this.send(`\x1B[C`)}ctrlC(){this.send(``)}ctrlN(){this.send(``)}ctrlP(){this.send(``)}},MockScreen=class extends EventEmitter{isTTY=!0;columns;rows;#e=``;#t=[];#n=
|
|
2
|
-
`)
|
|
3
|
-
`)
|
|
1
|
+
import{EventEmitter}from"node:events";const ansiControlSequencePattern=RegExp(`^\x1B\\[([0-9?;]*)([ -/]*)([@-~])`);var MockUserInput=class extends EventEmitter{isTTY=!0;rawModes=[];resumeCalls=0;pauseCalls=0;setRawMode(e){return this.rawModes.push(e),this}resume(){return this.resumeCalls+=1,this}pause(){return this.pauseCalls+=1,this}type(e){this.emit(`data`,Buffer.from(e))}send(e){this.emit(`data`,Buffer.from(e))}enter(){this.send(`\r`)}backspace(){this.send(``)}up(){this.send(`\x1B[A`)}down(){this.send(`\x1B[B`)}left(){this.send(`\x1B[D`)}right(){this.send(`\x1B[C`)}ctrlC(){this.send(``)}ctrlN(){this.send(``)}ctrlP(){this.send(``)}},MockScreen=class extends EventEmitter{isTTY=!0;columns;rows;#e=``;#t=[];#n=[];#r=!1;#i=0;#a=0;#o;#s=[];constructor({columns:e,rows:t}){super(),this.columns=e,this.rows=t}write(e,t,n){let r=String(e);return this.#e+=r,this.#l(r),typeof t==`function`&&t(),n?.(),this.#c(),!0}resize(e,t){this.columns=e,this.rows=t,this.emit(`resize`)}snapshot({hideDim:e=!1}={}){return e?this.#t.map((e,t)=>{let n=this.#n[t]??``;return e.replace(/./gsu,(e,t)=>n[t]===`d`?` `.repeat(e.length):e)}).join(`
|
|
2
|
+
`):this.#t.join(`
|
|
3
|
+
`)}rawOutput(){return this.#e}async waitForIdlePrompt(e=1e3){let t=/^[•* ] (?:Thinking|Generating|Running) \(\d/mu,idle=()=>{let e=this.snapshot();return/^[❯]/mu.test(e)&&!t.test(e)},n=Date.now()+e;for(;Date.now()<n;){if(idle())return;await new Promise(e=>setTimeout(e,25))}throw Error(`Timed out waiting for an idle prompt.\n\nScreen:\n${this.snapshot()}`)}async waitForText(e,t=1e3,n=()=>this.snapshot()){this.snapshot().includes(e)||await new Promise((r,i)=>{let a={text:e,resolve:r,reject:i,timeout:setTimeout(()=>{this.#s=this.#s.filter(e=>e!==a),i(Error(`Timed out waiting for screen text: ${e}\n\nScreen:\n${n()}`))},t)};this.#s.push(a)})}#c(){let e=this.snapshot();for(let t of this.#s.slice())e.includes(t.text)&&(clearTimeout(t.timeout),this.#s=this.#s.filter(e=>e!==t),t.resolve())}#l(e){let t=0;for(;t<e.length;){if(e[t]===`\x1B`){let n=this.#u(e,t);if(n>t){t=n;continue}}let n=e[t];if(t+=1,n!==void 0){if(n===`
|
|
4
|
+
`){this.#i+=1,this.#a=0;continue}if(n===`\r`){this.#a=0;continue}this.#m(n)}}}#u(e,t){let n=e.slice(t).match(ansiControlSequencePattern);if(!n)return t;let[r,i=``,,a]=n,o=i.startsWith(`?`),s=i&&!o?i.split(`;`):[],first=e=>s[0]===void 0||s[0]===``?e:Number(s[0]);if(o)return i===`?1049`&&(a===`h`||a===`l`)&&(a===`h`?(this.#o={lines:this.#t,dimCells:this.#n,cursorLine:this.#i,cursorColumn:this.#a},this.#t=[],this.#n=[],this.#i=0,this.#a=0):this.#o!==void 0&&(this.#t=this.#o.lines,this.#n=this.#o.dimCells,this.#i=this.#o.cursorLine,this.#a=this.#o.cursorColumn,this.#o=void 0)),t+r.length;switch(a){case`H`:case`f`:this.#i=first(1)-1,this.#a=(s[1]?Number(s[1]):1)-1;break;case`A`:this.#i=Math.max(0,this.#i-first(1));break;case`B`:this.#i+=first(1);break;case`C`:this.#a+=first(1);break;case`D`:this.#a=Math.max(0,this.#a-first(1));break;case`E`:this.#i+=first(1),this.#a=0;break;case`F`:this.#i=Math.max(0,this.#i-first(1)),this.#a=0;break;case`G`:this.#a=first(1)-1;break;case`J`:this.#f(first(0));break;case`K`:this.#p(first(0));break;case`m`:this.#d(s)}return t+r.length}#d(e){let t=(e.length===0?[``]:e).map(e=>e===``?0:Number(e));for(let e=0;e<t.length;e+=1){let n=t[e];if(n===38||n===48||n===58){let n=t[e+1];e+=n===5?2:n===2?4:1}else n===2?this.#r=!0:(n===0||n===22)&&(this.#r=!1)}}#f(e){if(e===2||e===3){this.#t=[],this.#n=[],this.#i=0,this.#a=0;return}if(e===1){for(let e=0;e<this.#i;e+=1)this.#t[e]=``,this.#n[e]=``;this.#p(1);return}this.#p(0),this.#t.length=Math.min(this.#t.length,this.#i+1),this.#n.length=Math.min(this.#n.length,this.#i+1)}#p(e){for(let t of[this.#t,this.#n]){let n=t[this.#i]??``;e===2?t[this.#i]=``:e===1?t[this.#i]=` `.repeat(this.#a)+n.slice(this.#a):t[this.#i]=n.slice(0,this.#a)}}#m(e){let write=(e,t)=>{let n=(e[this.#i]??``).padEnd(this.#a,` `);e[this.#i]=n.slice(0,this.#a)+t+n.slice(this.#a+t.length)};write(this.#t,e),write(this.#n,(this.#r?`d`:` `).repeat(e.length)),this.#a+=e.length}};export{MockScreen,MockUserInput};
|
|
@@ -92,7 +92,7 @@ export interface ThemeGlyphs {
|
|
|
92
92
|
arrowUp: string;
|
|
93
93
|
/** `↓` — output (response) tokens in the token-flow segment. */
|
|
94
94
|
arrowDown: string;
|
|
95
|
-
/**
|
|
95
|
+
/** `↯` — intrinsic speed or Fast mode (Gateway priority tier) marker. */
|
|
96
96
|
fast: string;
|
|
97
97
|
/** `↵` — the Enter affordance inside a selection badge. */
|
|
98
98
|
enter: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}[39m`}const UNICODE_GLYPHS={brand:`▲`,user:`│`,reasoning:`○`,square:`▪`,corner:`└`,cornerOpen:`┌`,external:`⌝`,dotActive:`⏺`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`※`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`›`,selectedPointer:`›`,option:` `,prompt:`❯`,elbow:`⎿`,hrule:`▔`,dash:`─`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown:`↓`,fast
|
|
1
|
+
function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}[39m`}const UNICODE_GLYPHS={brand:`▲`,user:`│`,reasoning:`○`,square:`▪`,corner:`└`,cornerOpen:`┌`,external:`⌝`,dotActive:`⏺`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`※`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`›`,selectedPointer:`›`,option:` `,prompt:`❯`,elbow:`⎿`,hrule:`▔`,dash:`─`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown:`↓`,fast:`↯`,enter:`↵`,validating:`▪`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,square:`*`,corner:"`",cornerOpen:`,`,external:`^`,dotActive:`*`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,selectedPointer:`>`,option:`.`,prompt:`>`,elbow:"`-",hrule:`=`,dash:`-`,caret:`_`,dot:`-`,ellipsis:`...`,arrowUp:`^`,arrowDown:`v`,fast:`>>`,enter:`<-'`,validating:`o`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(e={}){let t=e.color??!0,n=e.unicode??!0;return{color:t,unicode:n,colors:{reset:ansi(0,0,t),bold:ansi(1,22,t),dim:ansi(2,22,t),inverse:ansi(7,27,t),italic:ansi(3,23,t),white:ansi(97,39,t),gray:ansi(90,39,t),cyan:ansi(36,39,t),green:ansi(32,39,t),red:ansi(31,39,t),yellow:ansi(33,39,t),magenta:ansi(35,39,t),blue:ansi(34,39,t),orange:ansi256(208,t)},glyph:n?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:n?UNICODE_SPINNER:ASCII_SPINNER}}function detectUnicode(e=process.env){let t=e.EVE_TUI_UNICODE;return t===`0`||t===`false`?!1:t===`1`||t===`true`?!0:e.TERM===`dumb`?!1:process.platform!==`win32`||!!(e.WT_SESSION||e.TERM_PROGRAM===`vscode`)}export{createTheme,detectUnicode};
|
|
@@ -23,7 +23,7 @@ export interface ToolPresentationContext {
|
|
|
23
23
|
/**
|
|
24
24
|
* True when the tool dispatches a named subagent (each subagent exposes a
|
|
25
25
|
* tool bearing its own name). The presentation reads as a delegation —
|
|
26
|
-
* `Delegate stock
|
|
26
|
+
* `Delegate subagent(stock price)` — instead of a generic tool call.
|
|
27
27
|
*/
|
|
28
28
|
readonly isSubagent?: boolean;
|
|
29
29
|
/** The tool's own `label.start` copy, used when eve has no copy of its own for the tool. */
|
|
@@ -53,6 +53,11 @@ export declare function readWriteFileInput(toolName: string, input: unknown): {
|
|
|
53
53
|
* calls keep the generic formatter, so presentation can never break execution.
|
|
54
54
|
*/
|
|
55
55
|
export declare function presentTool(toolName: string, input: unknown, context?: ToolPresentationContext): ToolPresentation;
|
|
56
|
+
/**
|
|
57
|
+
* A person's name for a tool with no copy of its own: `linear__list_issues` →
|
|
58
|
+
* `List issues`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function toolDisplayTitle(toolName: string): string;
|
|
56
61
|
/**
|
|
57
62
|
* The bundled self-modification subagent's compiled name: its extension
|
|
58
63
|
* namespace joined to `subagents/agent` by the compiler's `__` rule.
|
|
@@ -60,8 +65,16 @@ export declare function presentTool(toolName: string, input: unknown, context?:
|
|
|
60
65
|
export declare const SELF_MODIFICATION_AGENT_NAME = "self-modification__agent";
|
|
61
66
|
/** True for the bundled self-modification subagent's dispatch tool. */
|
|
62
67
|
export declare function isSelfModificationAgent(toolName: string): boolean;
|
|
63
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* The name an agent task goes by in the delegate row, task line, and task
|
|
70
|
+
* panel, from its {@link agentDisplayName} and any `:N` ordinal.
|
|
71
|
+
*/
|
|
64
72
|
export declare function agentTaskLabel(name: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* A person's name for the agent a tool dispatches: `code__worker` →
|
|
75
|
+
* `worker`. An extension's own subagent compiles to `<extension>__agent`, so
|
|
76
|
+
* the extension names it.
|
|
77
|
+
*/
|
|
65
78
|
export declare function agentDisplayName(toolName: string): string;
|
|
66
79
|
/**
|
|
67
80
|
* Placeholder copy for a call whose input is still streaming from the model
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{diffWriteDetail}from"./line-diff.js";import{stripTerminalControls}from"#cli/ui/terminal-text.js";const WRITE_FILE_VERB=`Write`,DELEGATE_VERB=`Delegate`,FINAL_OUTPUT_TITLE=`Return final output`,BUILTIN_TOOL_COPY={agent:{verb:`Delegate`,pastVerb:`Delegated`,argKey:`message`,singularNoun:`task`,pluralNoun:`tasks`},ask_question:{verb:`Ask`,pastVerb:`Asked`,argKey:`question`,singularNoun:`question`,pluralNoun:`questions`},bash:{verb:`Run`,pastVerb:`Ran`,argKey:`command`,singularNoun:`command`,pluralNoun:`commands`},connection_execute:{verb:`Call`,pastVerb:`Called`,argKey:``,extractItem:e=>{let t=salientArg(e,`connection`),n=salientArg(e,`tool`);return t===void 0||n===void 0?void 0:`${t}.${n}`},singularNoun:`connection tool`,pluralNoun:`connection tools`},connection_search:{verb:`Search`,pastVerb:`Searched`,argKey:`query`,extractItem:e=>salientArg(e,`connection`),singularNoun:`tool search`,pluralNoun:`tool searches`},glob:{verb:`Glob`,pastVerb:`Globbed`,argKey:`pattern`,singularNoun:`pattern`,pluralNoun:`patterns`},grep:{verb:`Grep`,pastVerb:`Grepped`,argKey:`pattern`,singularNoun:`pattern`,pluralNoun:`patterns`},load_skill:{verb:`Load`,pastVerb:`Loaded`,argKey:`skill`,singularNoun:`skill`,pluralNoun:`skills`},read_file:{verb:`Read`,pastVerb:`Read`,argKey:`filePath`,singularNoun:`file`,pluralNoun:`files`},web_fetch:{verb:`Fetch`,pastVerb:`Fetched`,argKey:`url`,singularNoun:`URL`,pluralNoun:`URLs`},web_search:{verb:`Search`,pastVerb:`Searched`,argKey:`query`,extractItem:e=>salientArg(e,`objective`)??salientArg(e,`search_query`)??salientArg(e,`searchQuery`)??webSearchActionArg(e),singularNoun:`query`,pluralNoun:`queries`}};function presentWriteFileTool(e,t,n){let r=readWriteFileInput(e,t);if(r===void 0)return{title:e,subtitle:summarizeToolArgs(t),summarizeResult:summarizeToolResult};let i=diffWriteDetail(n?.previousContent,r.content,n?.existed).map(e=>e.kind===`gap`?e:{...e,text:stripTerminalControls(e.text)});return{title:`${WRITE_FILE_VERB} ${salientLine(r.path)??r.path}`,doneTitle:`Wrote ${salientLine(r.path)??r.path}`,subtitle:``,summarizeResult:()=>void 0,detail:i,keepDetailWhenDone:!0}}function readWriteFileInput(e,t){if(toolBaseName(e)!==`write_file`||typeof t!=`object`||!t||Array.isArray(t))return;let n=t,r=n.filePath,i=n.content;if(typeof r==`string`&&r.trim().length!==0&&typeof i==`string`)return{path:r,content:i}}function presentTool(e,t,n){let r=toolBaseName(e);if(r===`write_file`)return presentWriteFileTool(e,t,n);if(n?.isSubagent===!0){let n=isSelfModificationAgent(e)?agentDisplayName(e):agentTaskLabel(agentDisplayName(e));return{title:`${DELEGATE_VERB} ${n}`,doneTitle:`Delegated ${n}`,subtitle:salientArg(t,`message`)??``,summarizeResult:()=>void 0}}if(r===`final_output`)return{title:FINAL_OUTPUT_TITLE,subtitle:``,summarizeResult:()=>void 0};let i=BUILTIN_TOOL_COPY[r];if(i!==void 0){let e=salientArg(t,i.argKey)??i.extractItem?.(t);if(e!==void 0)return{title:`${i.verb} ${e}`,doneTitle:`${i.pastVerb} ${e}`,subtitle:``,summarizeResult:()=>void 0,group:{verb:i.verb,pastVerb:i.pastVerb,singularNoun:i.singularNoun,pluralNoun:i.pluralNoun,item:e}}}if(n?.label!==void 0){let e={title:n.label,subtitle:``,summarizeResult:summarizeToolResult};return n.completeLabel===void 0?e:{...e,doneTitle:n.completeLabel}}return{title:e,subtitle:summarizeToolArgs(t),summarizeResult:summarizeToolResult}}const SELF_MODIFICATION_AGENT_NAME=`self-modification__agent`,AGENT_DISPLAY_NAMES=new Map([[`agent`,`subagent`],[SELF_MODIFICATION_AGENT_NAME,`agent editor`]]);function isSelfModificationAgent(e){return toolBaseName(e)===SELF_MODIFICATION_AGENT_NAME}function agentTaskLabel(e){
|
|
1
|
+
import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{diffWriteDetail}from"./line-diff.js";import{displayName,displayTitle}from"#shared/display-name.js";import{stripTerminalControls}from"#cli/ui/terminal-text.js";const WRITE_FILE_VERB=`Write`,DELEGATE_VERB=`Delegate`,FINAL_OUTPUT_TITLE=`Return final output`,BUILTIN_TOOL_COPY={agent:{verb:`Delegate`,pastVerb:`Delegated`,argKey:`message`,singularNoun:`task`,pluralNoun:`tasks`},ask_question:{verb:`Ask`,pastVerb:`Asked`,argKey:`question`,singularNoun:`question`,pluralNoun:`questions`},bash:{verb:`Run`,pastVerb:`Ran`,argKey:`command`,singularNoun:`command`,pluralNoun:`commands`},connection_execute:{verb:`Call`,pastVerb:`Called`,argKey:``,extractItem:e=>{let t=salientArg(e,`connection`),n=salientArg(e,`tool`);return t===void 0||n===void 0?void 0:`${t}.${n}`},singularNoun:`connection tool`,pluralNoun:`connection tools`},connection_search:{verb:`Search`,pastVerb:`Searched`,argKey:`query`,extractItem:e=>salientArg(e,`connection`),singularNoun:`tool search`,pluralNoun:`tool searches`},glob:{verb:`Glob`,pastVerb:`Globbed`,argKey:`pattern`,singularNoun:`pattern`,pluralNoun:`patterns`},grep:{verb:`Grep`,pastVerb:`Grepped`,argKey:`pattern`,singularNoun:`pattern`,pluralNoun:`patterns`},load_skill:{verb:`Load`,pastVerb:`Loaded`,argKey:`skill`,singularNoun:`skill`,pluralNoun:`skills`},read_file:{verb:`Read`,pastVerb:`Read`,argKey:`filePath`,singularNoun:`file`,pluralNoun:`files`},web_fetch:{verb:`Fetch`,pastVerb:`Fetched`,argKey:`url`,singularNoun:`URL`,pluralNoun:`URLs`},web_search:{verb:`Search`,pastVerb:`Searched`,argKey:`query`,extractItem:e=>salientArg(e,`objective`)??salientArg(e,`search_query`)??salientArg(e,`searchQuery`)??webSearchActionArg(e),singularNoun:`query`,pluralNoun:`queries`}};function presentWriteFileTool(e,t,n){let r=readWriteFileInput(e,t);if(r===void 0)return{title:toolDisplayTitle(e),subtitle:summarizeToolArgs(t),summarizeResult:summarizeToolResult};let i=diffWriteDetail(n?.previousContent,r.content,n?.existed).map(e=>e.kind===`gap`?e:{...e,text:stripTerminalControls(e.text)});return{title:`${WRITE_FILE_VERB} ${salientLine(r.path)??r.path}`,doneTitle:`Wrote ${salientLine(r.path)??r.path}`,subtitle:``,summarizeResult:()=>void 0,detail:i,keepDetailWhenDone:!0}}function readWriteFileInput(e,t){if(toolBaseName(e)!==`write_file`||typeof t!=`object`||!t||Array.isArray(t))return;let n=t,r=n.filePath,i=n.content;if(typeof r==`string`&&r.trim().length!==0&&typeof i==`string`)return{path:r,content:i}}function presentTool(e,t,n){let r=toolBaseName(e);if(r===`write_file`)return presentWriteFileTool(e,t,n);if(n?.isSubagent===!0){let n=isSelfModificationAgent(e)?agentDisplayName(e):agentTaskLabel(agentDisplayName(e));return{title:`${DELEGATE_VERB} ${n}`,doneTitle:`Delegated ${n}`,subtitle:salientArg(t,`message`)??``,summarizeResult:()=>void 0}}if(r===`final_output`)return{title:FINAL_OUTPUT_TITLE,subtitle:``,summarizeResult:()=>void 0};let i=BUILTIN_TOOL_COPY[r];if(i!==void 0){let e=salientArg(t,i.argKey)??i.extractItem?.(t);if(e!==void 0)return{title:`${i.verb} ${e}`,doneTitle:`${i.pastVerb} ${e}`,subtitle:``,summarizeResult:()=>void 0,group:{verb:i.verb,pastVerb:i.pastVerb,singularNoun:i.singularNoun,pluralNoun:i.pluralNoun,item:e}}}if(n?.label!==void 0){let e={title:n.label,subtitle:``,summarizeResult:summarizeToolResult};return n.completeLabel===void 0?e:{...e,doneTitle:n.completeLabel}}return{title:toolDisplayTitle(e),subtitle:summarizeToolArgs(t),summarizeResult:summarizeToolResult}}function toolDisplayTitle(e){return displayTitle(toolBaseName(e))}const SELF_MODIFICATION_AGENT_NAME=`self-modification__agent`,AGENT_DISPLAY_NAMES=new Map([[`agent`,`subagent`],[SELF_MODIFICATION_AGENT_NAME,`agent editor`]]);function isSelfModificationAgent(e){return toolBaseName(e)===SELF_MODIFICATION_AGENT_NAME}function agentTaskLabel(e){return/^subagent(?::\d+)?$/u.test(e)||e.startsWith(`agent editor`)?e:`subagent(${e})`}function agentDisplayName(e){let t=toolBaseName(e);return AGENT_DISPLAY_NAMES.get(t)??displayName(t.replace(/(?<=.)__agent$/u,``))}function presentPreparingTool(e,t){let n=toolBaseName(e);return n===`final_output`?{title:FINAL_OUTPUT_TITLE,subtitle:``,summarizeResult:()=>void 0}:t?.isSubagent===!0?{title:`${DELEGATE_VERB} ${agentTaskLabel(agentDisplayName(e))} …`,subtitle:``,summarizeResult:()=>void 0}:{title:`${(n===`write_file`?WRITE_FILE_VERB:BUILTIN_TOOL_COPY[n]?.verb)??toolDisplayTitle(e)} …`,subtitle:``,summarizeResult:()=>void 0}}function isPanelRoutedTool(e){return toolBaseName(e)===`ask_question`}function toolBaseName(e){return e.split(/[.:/]/u).at(-1)??e}function webSearchActionArg(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e.action;if(typeof t!=`object`||!t||Array.isArray(t))return;let n=t,r=n.queries;if(Array.isArray(r)){let e=r.filter(e=>typeof e==`string`).map(salientLine).filter(e=>e!==void 0).join(`, `);if(e.length>0)return e}for(let e of[`query`,`url`,`pattern`]){let t=n[e];if(typeof t==`string`){let e=salientLine(t);if(e!==void 0)return e}}}function salientArg(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return;let n=e[t];if(typeof n==`string`)return salientLine(n)}function salientLine(e){let t=stripTerminalControls(e).split(/\r?\n/u).find(e=>e.trim().length>0)?.trim()??``;return t.length>0?t:void 0}export{SELF_MODIFICATION_AGENT_NAME,agentDisplayName,agentTaskLabel,isPanelRoutedTool,isSelfModificationAgent,presentPreparingTool,presentTool,readWriteFileInput,toolBaseName,toolDisplayTitle};
|