eve 0.57.0 → 0.58.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +1 -0
- package/dist/src/channel/activity-sink.js +1 -1
- package/dist/src/channel/session-callback.js +1 -1
- package/dist/src/chunks/{use-eve-agent-C2APNCdP.js → use-eve-agent-CxWcZCsU.js} +22 -3
- package/dist/src/chunks/{use-eve-agent-D0YnDLi_.js → use-eve-agent-X0asmJg-.js} +22 -3
- package/dist/src/cli/commands/integration-setup.js +1 -1
- package/dist/src/cli/dev/command.d.ts +30 -0
- package/dist/src/cli/dev/command.js +3 -0
- package/dist/src/cli/dev/tui/setup-commands.js +1 -1
- package/dist/src/cli/dev/tui/setup-issues.js +1 -1
- package/dist/src/cli/dev/tui/setup-panel.js +2 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +1 -1
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/option-parsers.js +1 -1
- package/dist/src/cli/run.js +1 -3
- package/dist/src/client/agent-host.js +1 -1
- package/dist/src/client/url.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +2 -2
- package/dist/src/compiled/@ai-sdk/code-mode/index.d.ts +18 -2
- package/dist/src/compiled/@ai-sdk/code-mode/index.js +16 -14
- package/dist/src/compiler/extension-compatibility.d.ts +12 -12
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/context/dynamic-model-lifecycle.d.ts +1 -0
- package/dist/src/context/dynamic-model-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +11 -3
- package/dist/src/context/memory-lifecycle.d.ts +2 -5
- package/dist/src/context/memory-lifecycle.js +1 -1
- package/dist/src/dynamic/definition.d.ts +2 -0
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/session/event-sink.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/tools/sleep-workflow.js +1 -1
- package/dist/src/execution/workflow-callback-url.js +1 -1
- package/dist/src/experimental/evaluate/auto-model.d.ts +16 -0
- package/dist/src/experimental/evaluate/auto-model.js +2 -0
- package/dist/src/harness/emission.d.ts +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/messages.d.ts +1 -0
- package/dist/src/harness/messages.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/authored-definition/core.js +1 -1
- package/dist/src/internal/model-auth/transport.d.ts +3 -1
- package/dist/src/internal/model-auth/transport.js +1 -1
- package/dist/src/internal/nitro/host/normalize-vercel-service-crons.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +1 -1
- package/dist/src/internal/runtime-model.d.ts +3 -0
- package/dist/src/internal/runtime-model.js +1 -1
- package/dist/src/internal/vercel/build-agent-workspace.js +1 -1
- package/dist/src/internal/vercel/eve-service-contribution.d.ts +1 -0
- package/dist/src/internal/vercel/eve-service-contribution.js +1 -1
- package/dist/src/internal/vercel/vercel-services-config.d.ts +1 -0
- package/dist/src/internal/vercel/vercel-services-config.js +1 -1
- package/dist/src/public/definitions/workspace-agent.js +1 -1
- package/dist/src/public/experimental/evaluate/index.d.ts +1 -0
- package/dist/src/public/experimental/evaluate/index.js +1 -0
- package/dist/src/public/models/anthropic/index.js +1 -1
- package/dist/src/public/next/index.d.ts +1 -1
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/vercel/index.d.ts +1 -1
- package/dist/src/public/vercel/index.js +1 -1
- package/dist/src/react/use-eve-agent.d.ts +1 -1
- package/dist/src/runtime/agent/bootstrap.d.ts +4 -2
- package/dist/src/runtime/agent/resolve-model.d.ts +0 -1
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/self-modification/agent.d.ts +6 -18
- package/dist/src/self-modification/agent.js +1 -1
- package/dist/src/self-modification/config.d.ts +17 -12
- package/dist/src/self-modification/config.js +1 -1
- package/dist/src/self-modification/credentials.d.ts +1 -10
- package/dist/src/self-modification/credentials.js +1 -1
- package/dist/src/self-modification/extension/extension.d.ts +7 -13
- package/dist/src/self-modification/extension/extension.js +1 -1
- package/dist/src/self-modification/github-publisher.d.ts +1 -1
- package/dist/src/self-modification/mode.js +1 -1
- package/dist/src/self-modification/setup.d.ts +1 -1
- package/dist/src/self-modification/setup.js +23 -4
- package/dist/src/setup/flows/model-login-connection.js +1 -1
- package/dist/src/setup/flows/registry.d.ts +3 -0
- package/dist/src/setup/flows/registry.js +2 -2
- package/dist/src/setup/integrations/discord/setup.js +1 -1
- package/dist/src/setup/integrations/file-memory/setup.js +2 -2
- package/dist/src/setup/integrations/github/setup.js +1 -1
- package/dist/src/setup/integrations/linear/setup.js +1 -1
- package/dist/src/setup/integrations/linq/setup.js +1 -1
- package/dist/src/setup/integrations/photon/setup-flow.js +1 -1
- package/dist/src/setup/integrations/registry.js +1 -1
- package/dist/src/setup/integrations/runner.d.ts +3 -0
- package/dist/src/setup/integrations/runner.js +1 -1
- package/dist/src/setup/integrations/self-modification/setup.d.ts +7 -1
- package/dist/src/setup/integrations/self-modification/setup.js +1 -1
- package/dist/src/setup/integrations/shared/scaffold.js +1 -1
- package/dist/src/setup/integrations/shared/ui.d.ts +1 -0
- package/dist/src/setup/integrations/shared/ui.js +1 -1
- package/dist/src/setup/integrations/shopify/setup.js +1 -1
- package/dist/src/setup/integrations/slack/setup.js +1 -1
- package/dist/src/setup/integrations/teams/connect.d.ts +22 -0
- package/dist/src/setup/integrations/teams/connect.js +1 -0
- package/dist/src/setup/integrations/teams/setup.d.ts +21 -0
- package/dist/src/setup/integrations/teams/setup.js +7 -0
- package/dist/src/setup/integrations/types.d.ts +6 -0
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.d.ts +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/update/channels.d.ts +2 -0
- package/dist/src/setup/scaffold/update/channels.js +2 -2
- package/dist/src/setup/scaffold/update/connections.js +3 -3
- package/dist/src/setup/scaffold/update/web-options.js +1 -1
- package/dist/src/setup/scaffold/version-tokens.d.ts +2 -1
- package/dist/src/setup/scaffold/version-tokens.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +2 -0
- package/dist/src/shared/eve-route-path.d.ts +4 -0
- package/dist/src/shared/eve-route-path.js +1 -0
- package/dist/src/shared/public-route-prefix.d.ts +1 -1
- package/dist/src/subagents/remote-route-url.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.d.ts +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.d.ts +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/README.md +45 -40
- package/docs/agent-config.md +8 -1
- package/docs/channels/teams.mdx +29 -0
- package/docs/concepts/meta.json +1 -0
- package/docs/concepts/project-structure.mdx +111 -0
- package/docs/getting-started.mdx +18 -106
- package/docs/guides/auth-and-route-protection.md +8 -4
- package/docs/guides/deployment/self-hosting.md +40 -0
- package/docs/guides/deployment/vercel.mdx +26 -23
- package/docs/guides/dynamic-capabilities.md +4 -0
- package/docs/guides/evaluate.md +118 -0
- package/docs/guides/frontend/nextjs.mdx +61 -20
- package/docs/guides/frontend/overview.mdx +3 -3
- package/docs/guides/instrumentation/otel.mdx +7 -2
- package/docs/guides/instrumentation/providers.mdx +2 -3
- package/docs/guides/remote-agents.md +5 -1
- package/docs/install-integrations.mdx +1 -1
- package/docs/meta.json +1 -0
- package/docs/reference/agent-files.md +104 -0
- package/docs/reference/cli.md +2 -2
- package/docs/reference/meta.json +1 -1
- package/docs/reference/typescript-api.md +2 -1
- package/docs/schedules.mdx +1 -1
- package/docs/subagents/index.mdx +2 -2
- package/package.json +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.58.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 40f0c45: Fix `autoModel` to use `typesafe-ai/jev` and the `/login` Gateway connection during `eve dev`, while preserving custom AI SDK default providers.
|
|
8
|
+
Show `dynamic model` in the TUI footer instead of a missing-connection warning for dynamic selectors.
|
|
9
|
+
|
|
10
|
+
## 0.58.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 9f301b6: Named workspace agent routes now use `/eve/<name>/v1/*` across `eve/next`, `eve/vercel`, and agent-only workspace builds. Update existing named-agent URLs to the new route; root single-agent routes remain at `/eve/v1/*`, and `eve/vercel` can now compose them.
|
|
15
|
+
- bfc899d: Replace the Vercel-specific deployed self-modification credential configuration with an application-supplied GitHub credential provider. Generated Vercel setup now writes an inline `@vercel/connect` adapter, while the self-hosted PAT configuration remains available through `{ pat: true }`.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 29af29d: Add experimental `autoModel` routing at `eve/experimental/evaluate`. It defaults to TypeSafe Jev through AI Gateway, accepts any AI SDK evaluation model, and chooses a Gateway model ID or provider model instance from the incoming task with per-option reasoning and per-turn retention.
|
|
20
|
+
- 910bb45: Fix `turn.started` dynamic model, tool, skill, and subagent resolvers receiving an empty message snapshot. `ctx.messages` now includes visible conversation history and incoming input, including deferred session-limit turns and authorization resumes, with history projection preserved after memory recall.
|
|
21
|
+
- ab5b8e9: Install integrations selected through the development TUI's `/add` command into the active workspace agent while keeping shared environment, Vercel, dependency, and deployment effects at the workspace root.
|
|
22
|
+
- 987c3a0: Add development commands to generated hostless workspace services so `vercel dev --local` can start every agent. Default `defineWorkspaceAgent` transports route through the local Vercel service graph without deployment credentials.
|
|
23
|
+
- 0fa8916: Add guided Microsoft Teams setup through `eve add channel/teams`. The flow delegates app creation, installation, and Activity routing to the Vercel Connect CLI, then scaffolds the Connect-backed channel.
|
|
24
|
+
- fd9a007: Reorganize the `eve dev` command implementation without changing its behavior.
|
|
25
|
+
- 16e11f9: Prevent multiline setup prompts, including the Vercel project-link question shown by `/add`, from being duplicated into TUI scrollback during repaints.
|
|
26
|
+
|
|
3
27
|
## 0.57.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -156,6 +156,7 @@ These files ship inside the installed package at `node_modules/eve/docs/`:
|
|
|
156
156
|
- [Getting Started](https://eve.dev/docs/getting-started) — install, scaffold, and run locally
|
|
157
157
|
- [Project Layout](https://eve.dev/docs/getting-started#project-layout) — every authored directory in depth
|
|
158
158
|
- [`agent.ts`](https://eve.dev/docs/agent-config) — agent config reference
|
|
159
|
+
- [Automatic Model Selection](https://eve.dev/docs/guides/evaluate) — choose an agent model for each request
|
|
159
160
|
- [TypeScript API Reference](https://eve.dev/docs/reference/typescript-api) — complete `define*` and runtime helper reference
|
|
160
161
|
- [Vercel Deployment](https://eve.dev/docs/guides/deployment/overview) — deploy to production
|
|
161
162
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{EVE_ACTIVITY_ROUTE_PATTERN}from"#protocol/routes.js";import{isReservedIpAddress}from"#shared/network-address.js";const schema=z.object({url:z.string().min(1),version:z.literal(1)}).strict();function parseActivitySink(e){if(e===void 0)return;let t=schema.safeParse(e);if(!t.success)throw Error(`Expected activitySink version 1.`);let n;try{n=new URL(t.data.url)}catch{throw Error(`Activity sink url must be absolute.`)}let r=EVE_ACTIVITY_ROUTE_PATTERN.slice(0,-6),i=
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{EVE_ACTIVITY_ROUTE_PATTERN}from"#protocol/routes.js";import{normalizePublicEveRoutePath}from"#shared/eve-route-path.js";import{isReservedIpAddress}from"#shared/network-address.js";const schema=z.object({url:z.string().min(1),version:z.literal(1)}).strict();function parseActivitySink(e){if(e===void 0)return;let t=schema.safeParse(e);if(!t.success)throw Error(`Expected activitySink version 1.`);let n;try{n=new URL(t.data.url)}catch{throw Error(`Activity sink url must be absolute.`)}let r=EVE_ACTIVITY_ROUTE_PATTERN.slice(0,-6),i=normalizePublicEveRoutePath(n.pathname),a=i.lastIndexOf(r),o=i.slice(a+r.length);if(a<0||o.length<32)throw Error(`Activity sink url must contain an opaque activity token.`);if(isReservedIpAddress(n.hostname))throw Error(`Activity sink url host must not be a private or reserved address.`);return t.data}export{parseActivitySink};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{createEveCallbackRoutePath}from"#protocol/routes.js";import{isReservedIpAddress}from"#shared/network-address.js";const sessionCallbackSchema=z.object({callId:z.string().min(1),subagentName:z.string().min(1),taskId:z.string().min(1).optional(),token:z.string().min(1),url:z.string().min(1)}).strict().superRefine((e,t)=>{let n;try{n=new URL(e.url)}catch{t.addIssue({code:`custom`,message:`Callback url must be absolute.`,path:[`url`]});return}readCallbackUrlToken(n)!==e.token&&t.addIssue({code:`custom`,message:`Callback url token must match callback token.`,path:[`url`]}),isReservedIpAddress(n.hostname)&&t.addIssue({code:`custom`,message:`Callback url host must not be a private or reserved address.`,path:[`url`]})});function parseSessionCallback(e){let t=sessionCallbackSchema.safeParse(e);return t.success?{callback:t.data,ok:!0}:{cause:t.error,message:formatSessionCallbackParseError(t.error),ok:!1}}function readCallbackUrlToken(e){let t=createEveCallbackRoutePath(``),n=e.pathname.lastIndexOf(t);if(
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{createEveCallbackRoutePath}from"#protocol/routes.js";import{normalizePublicEveRoutePath}from"#shared/eve-route-path.js";import{isReservedIpAddress}from"#shared/network-address.js";const sessionCallbackSchema=z.object({callId:z.string().min(1),subagentName:z.string().min(1),taskId:z.string().min(1).optional(),token:z.string().min(1),url:z.string().min(1)}).strict().superRefine((e,t)=>{let n;try{n=new URL(e.url)}catch{t.addIssue({code:`custom`,message:`Callback url must be absolute.`,path:[`url`]});return}readCallbackUrlToken(n)!==e.token&&t.addIssue({code:`custom`,message:`Callback url token must match callback token.`,path:[`url`]}),isReservedIpAddress(n.hostname)&&t.addIssue({code:`custom`,message:`Callback url host must not be a private or reserved address.`,path:[`url`]})});function parseSessionCallback(e){let t=sessionCallbackSchema.safeParse(e);return t.success?{callback:t.data,ok:!0}:{cause:t.error,message:formatSessionCallbackParseError(t.error),ok:!1}}function readCallbackUrlToken(e){let t=createEveCallbackRoutePath(``),n=normalizePublicEveRoutePath(e.pathname),r=n.lastIndexOf(t);if(r===-1)return null;let i=n.slice(r+t.length);if(i.length===0||i.includes(`/`))return null;try{return decodeURIComponent(i)}catch{return null}}function formatSessionCallbackParseError(e){return`Invalid callback metadata: ${e.issues.map(e=>`${e.path.length===0?`callback`:`callback.${e.path.join(`.`)}`}: ${e.message}`).join(`; `)}`}export{parseSessionCallback};
|
|
@@ -964,6 +964,24 @@ function readMessageStreamVersion(headers) {
|
|
|
964
964
|
throw new TypeError(`Unsupported message stream version: ${version}.`);
|
|
965
965
|
}
|
|
966
966
|
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/shared/eve-route-path.ts
|
|
969
|
+
const EVE_NAMED_AGENT_MOUNT_PATTERN = /^\/eve\/[a-z0-9][a-z0-9_-]*$/;
|
|
970
|
+
const EVE_NAMED_AGENT_PROTOCOL_PATTERN = /^\/eve\/[a-z0-9][a-z0-9_-]*\/v1$/;
|
|
971
|
+
function joinEveRoutePath(basePath, routePath) {
|
|
972
|
+
const base = trimTrailingSlash$1(basePath);
|
|
973
|
+
const route = routePath.startsWith("/") ? routePath : `/${routePath}`;
|
|
974
|
+
if (route === "/eve/v1" || route.startsWith(`${"/eve/v1"}/`)) {
|
|
975
|
+
if (EVE_NAMED_AGENT_MOUNT_PATTERN.test(base)) return `${base}${route.slice(4)}`;
|
|
976
|
+
if (EVE_NAMED_AGENT_PROTOCOL_PATTERN.test(base)) return `${base}${route.slice(EVE_ROUTE_PREFIX.length)}`;
|
|
977
|
+
}
|
|
978
|
+
return `${base}${route}`;
|
|
979
|
+
}
|
|
980
|
+
function trimTrailingSlash$1(value) {
|
|
981
|
+
if (value === "/") return "";
|
|
982
|
+
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
983
|
+
}
|
|
984
|
+
|
|
967
985
|
//#endregion
|
|
968
986
|
//#region src/client/url.ts
|
|
969
987
|
function createClientUrl(host, routePath, searchParams) {
|
|
@@ -973,7 +991,8 @@ function createClientUrl(host, routePath, searchParams) {
|
|
|
973
991
|
const normalizedRoute = pathOnly.startsWith("/") ? pathOnly : `/${pathOnly}`;
|
|
974
992
|
if (isAbsoluteUrl(host)) {
|
|
975
993
|
const url = new URL(host);
|
|
976
|
-
|
|
994
|
+
const basePath = trimTrailingSlash(url.pathname);
|
|
995
|
+
url.pathname = joinEveRoutePath(basePath, normalizedRoute);
|
|
977
996
|
mergeEmbeddedQuery(url.searchParams, embeddedQuery);
|
|
978
997
|
mergeSearchParams(url.searchParams, searchParams);
|
|
979
998
|
url.hash = "";
|
|
@@ -983,7 +1002,7 @@ function createClientUrl(host, routePath, searchParams) {
|
|
|
983
1002
|
const basePath = trimTrailingSlash(url.pathname);
|
|
984
1003
|
mergeEmbeddedQuery(url.searchParams, embeddedQuery);
|
|
985
1004
|
mergeSearchParams(url.searchParams, searchParams);
|
|
986
|
-
return `${basePath
|
|
1005
|
+
return `${joinEveRoutePath(basePath, normalizedRoute)}${formatSearch(url.searchParams)}`;
|
|
987
1006
|
}
|
|
988
1007
|
function mergeEmbeddedQuery(target, embeddedQuery) {
|
|
989
1008
|
if (embeddedQuery.length === 0) return;
|
|
@@ -2266,7 +2285,7 @@ function detachEveAgentStore(store) {
|
|
|
2266
2285
|
//#endregion
|
|
2267
2286
|
//#region src/client/agent-host.ts
|
|
2268
2287
|
const AGENT_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
|
|
2269
|
-
const EVE_NAMED_AGENT_ROUTE_PREFIX = "/eve
|
|
2288
|
+
const EVE_NAMED_AGENT_ROUTE_PREFIX = "/eve";
|
|
2270
2289
|
function resolveEveAgentHost(input) {
|
|
2271
2290
|
if (input.agent === void 0) return input.host ?? "";
|
|
2272
2291
|
if (input.host !== void 0) throw new Error("useEveAgent cannot combine agent and host. Use one target option.");
|
|
@@ -964,6 +964,24 @@ function readMessageStreamVersion(headers) {
|
|
|
964
964
|
throw new TypeError(`Unsupported message stream version: ${version}.`);
|
|
965
965
|
}
|
|
966
966
|
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/shared/eve-route-path.ts
|
|
969
|
+
const EVE_NAMED_AGENT_MOUNT_PATTERN = /^\/eve\/[a-z0-9][a-z0-9_-]*$/;
|
|
970
|
+
const EVE_NAMED_AGENT_PROTOCOL_PATTERN = /^\/eve\/[a-z0-9][a-z0-9_-]*\/v1$/;
|
|
971
|
+
function joinEveRoutePath(basePath, routePath) {
|
|
972
|
+
const base = trimTrailingSlash$1(basePath);
|
|
973
|
+
const route = routePath.startsWith("/") ? routePath : `/${routePath}`;
|
|
974
|
+
if (route === "/eve/v1" || route.startsWith(`${"/eve/v1"}/`)) {
|
|
975
|
+
if (EVE_NAMED_AGENT_MOUNT_PATTERN.test(base)) return `${base}${route.slice(4)}`;
|
|
976
|
+
if (EVE_NAMED_AGENT_PROTOCOL_PATTERN.test(base)) return `${base}${route.slice(EVE_ROUTE_PREFIX.length)}`;
|
|
977
|
+
}
|
|
978
|
+
return `${base}${route}`;
|
|
979
|
+
}
|
|
980
|
+
function trimTrailingSlash$1(value) {
|
|
981
|
+
if (value === "/") return "";
|
|
982
|
+
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
983
|
+
}
|
|
984
|
+
|
|
967
985
|
//#endregion
|
|
968
986
|
//#region src/client/url.ts
|
|
969
987
|
function createClientUrl(host, routePath, searchParams) {
|
|
@@ -973,7 +991,8 @@ function createClientUrl(host, routePath, searchParams) {
|
|
|
973
991
|
const normalizedRoute = pathOnly.startsWith("/") ? pathOnly : `/${pathOnly}`;
|
|
974
992
|
if (isAbsoluteUrl(host)) {
|
|
975
993
|
const url = new URL(host);
|
|
976
|
-
|
|
994
|
+
const basePath = trimTrailingSlash(url.pathname);
|
|
995
|
+
url.pathname = joinEveRoutePath(basePath, normalizedRoute);
|
|
977
996
|
mergeEmbeddedQuery(url.searchParams, embeddedQuery);
|
|
978
997
|
mergeSearchParams(url.searchParams, searchParams);
|
|
979
998
|
url.hash = "";
|
|
@@ -983,7 +1002,7 @@ function createClientUrl(host, routePath, searchParams) {
|
|
|
983
1002
|
const basePath = trimTrailingSlash(url.pathname);
|
|
984
1003
|
mergeEmbeddedQuery(url.searchParams, embeddedQuery);
|
|
985
1004
|
mergeSearchParams(url.searchParams, searchParams);
|
|
986
|
-
return `${basePath
|
|
1005
|
+
return `${joinEveRoutePath(basePath, normalizedRoute)}${formatSearch(url.searchParams)}`;
|
|
987
1006
|
}
|
|
988
1007
|
function mergeEmbeddedQuery(target, embeddedQuery) {
|
|
989
1008
|
if (embeddedQuery.length === 0) return;
|
|
@@ -2266,7 +2285,7 @@ function detachEveAgentStore(store) {
|
|
|
2266
2285
|
//#endregion
|
|
2267
2286
|
//#region src/client/agent-host.ts
|
|
2268
2287
|
const AGENT_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
|
|
2269
|
-
const EVE_NAMED_AGENT_ROUTE_PREFIX = "/eve
|
|
2288
|
+
const EVE_NAMED_AGENT_ROUTE_PREFIX = "/eve";
|
|
2270
2289
|
function resolveEveAgentHost(input) {
|
|
2271
2290
|
if (input.agent === void 0) return input.host ?? "";
|
|
2272
2291
|
if (input.host !== void 0) throw new Error("useEveAgent cannot combine agent and host. Use one target option.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{serializeHeadlessSetupEvent}from"./setup-headless.js";import{createPrompter}from"#setup/prompter.js";import{ensureVercelProject}from"#setup/flows/ensure-vercel-project.js";import{createHeadlessPrompter}from"#setup/headless.js";import{SetupPrerequisiteRequired}from"#setup/integrations/shared/prerequisite.js";import{createRegistrySetupClient}from"#setup/registry-setup-client.js";import{InteractionRequired,InvalidAnswerError,headlessAsker,interactiveAsker,withAnswers,withPolicy}from"#setup/ask.js";import{runIntegrationSetup}from"#setup/integrations/runner.js";import{setupQuestionToWire}from"#setup/setup-question-wire.js";const defaultIntegrationSetupDependencies={};async function runIntegrationSetupCommand(e,t,n,r={},i=defaultIntegrationSetupDependencies){let a=createRegistrySetupClient({process:i.setupProcess,signal:r.signal});try{let o=r.nonInteractive===!0,s=a?.prompter??i.createPrompter?.()??(o?createHeadlessPrompter(()=>{}):createPrompter()),
|
|
1
|
+
import{serializeHeadlessSetupEvent}from"./setup-headless.js";import{createPrompter}from"#setup/prompter.js";import{resolveEveProjectContext}from"#internal/project-context.js";import{ensureVercelProject}from"#setup/flows/ensure-vercel-project.js";import{createHeadlessPrompter}from"#setup/headless.js";import{SetupPrerequisiteRequired}from"#setup/integrations/shared/prerequisite.js";import{createRegistrySetupClient}from"#setup/registry-setup-client.js";import{InteractionRequired,InvalidAnswerError,headlessAsker,interactiveAsker,withAnswers,withPolicy}from"#setup/ask.js";import{runIntegrationSetup}from"#setup/integrations/runner.js";import{setupQuestionToWire}from"#setup/setup-question-wire.js";const defaultIntegrationSetupDependencies={};async function runIntegrationSetupCommand(e,t,n,r={},i=defaultIntegrationSetupDependencies){let a=createRegistrySetupClient({process:i.setupProcess,signal:r.signal});try{let o=r.nonInteractive===!0,s=(await resolveEveProjectContext(t)).environmentRoot,c=a?.prompter??i.createPrompter?.()??(o?createHeadlessPrompter(()=>{}):createPrompter()),l=o?headlessAsker():interactiveAsker(c),u=r.yes?withPolicy(`assume`)(l):l,d=withAnswers(r.answers??{})(u),f=await runIntegrationSetup(n,{appRoot:t,projectRoot:s,prompter:c,asker:d,force:r.force,resolveVercelProject:o?void 0:()=>ensureVercelProject({appRoot:s,prompter:c,signal:a?.signal??r.signal}),signal:a?.signal??r.signal,beginExternalAction:o?t=>{let n=`external-action-${crypto.randomUUID()}`;return e.log(serializeHeadlessSetupEvent({version:1,type:`external_action`,id:n,blocking:!0,...t})),{complete(){e.log(serializeHeadlessSetupEvent({version:1,type:`external_action_resolved`,id:n}))}}}:void 0},i.runnerDeps);if(f.kind===`cancelled`){a?.cancel(),process.env.EVE_SETUP===`1`?process.exitCode=130:o&&e.error(serializeHeadlessSetupEvent({version:1,type:`cancelled`,item:n}));return}c.outro(`Integration set up.`),a?.complete(f.completion),o&&a===void 0&&e.log(serializeHeadlessSetupEvent({version:1,type:`completed`,item:n}))}catch(t){if(a?.fail(t),a!==void 0)return;r.nonInteractive&&t instanceof InteractionRequired?(e.error(serializeHeadlessSetupEvent({version:1,type:`blocked`,status:`input_required`,question:setupQuestionToWire(t.question)})),process.exitCode=2):r.nonInteractive&&t instanceof InvalidAnswerError?(e.error(serializeHeadlessSetupEvent({version:1,type:`blocked`,status:`input_required`,question:setupQuestionToWire(t.question),issue:{code:`invalid_answer`,message:t.message}})),process.exitCode=2):r.nonInteractive&&t instanceof SetupPrerequisiteRequired?(e.error(serializeHeadlessSetupEvent({version:1,type:`blocked`,status:`prerequisite_required`,prerequisite:t.prerequisite})),process.exitCode=2):(e.error(t instanceof Error?t.message:String(t)),process.exitCode=1)}}export{runIntegrationSetupCommand};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Command } from "#compiled/commander/index.js";
|
|
2
|
+
import type { CliApplicationContext } from "#cli/application-command.js";
|
|
3
|
+
import type { EveCliTelemetry } from "#cli/telemetry/index.js";
|
|
4
|
+
import type { DevelopmentServer, DevelopmentServerOptions } from "#internal/nitro/host/types.js";
|
|
5
|
+
import type { RunDevelopmentTuiInput } from "./tui/tui.js";
|
|
6
|
+
interface DevelopmentCommandLogger {
|
|
7
|
+
log(message: string): void;
|
|
8
|
+
}
|
|
9
|
+
interface DevelopmentCommandRuntime {
|
|
10
|
+
isActiveDevelopmentServerForApp?(input: {
|
|
11
|
+
readonly appRoot: string;
|
|
12
|
+
readonly serverUrl: string;
|
|
13
|
+
}): Promise<boolean>;
|
|
14
|
+
runDevelopmentTui?: (input: RunDevelopmentTuiInput) => Promise<void>;
|
|
15
|
+
startHost?: (appRoot: string, options?: DevelopmentServerOptions) => DevelopmentServer;
|
|
16
|
+
}
|
|
17
|
+
interface DevelopmentCommandTelemetry {
|
|
18
|
+
trackDevContext: EveCliTelemetry["trackDevContext"];
|
|
19
|
+
trackSetupStep: EveCliTelemetry["trackSetupStep"];
|
|
20
|
+
trackSetupTerminal: EveCliTelemetry["trackSetupTerminal"];
|
|
21
|
+
}
|
|
22
|
+
/** Registers the local and remote development server command. */
|
|
23
|
+
export declare function registerDevelopmentCommand(input: {
|
|
24
|
+
applicationContext: CliApplicationContext;
|
|
25
|
+
logger: DevelopmentCommandLogger;
|
|
26
|
+
program: Command;
|
|
27
|
+
runtime: DevelopmentCommandRuntime;
|
|
28
|
+
telemetry: DevelopmentCommandTelemetry;
|
|
29
|
+
}): void;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createDevBootProgressReporter}from"./boot-progress.js";import{resolveDevUiMode,resolveTuiDisplayOptions}from"./ui-options.js";import{runInteractiveDevelopmentUi}from"./run-interactive-ui.js";import{parseDevelopmentHeaderOption,resolveDevelopmentUrlTarget}from"./url-target.js";import{parseDevelopmentServerUrl}from"./url.js";import{waitForServerOrStop,waitForUiOrServer}from"./wait-for-ui.js";import{parseContextSizeOption,parseDisplayMode,parseLogsMode,parsePortOption,parseStatsMode}from"../option-parsers.js";import{InvalidArgumentError,Option}from"#compiled/commander/index.js";import{agentCommand}from"#cli/agent-command.js";import{FORCED_EXIT_BACKSTOP_MS,installShutdownSignal}from"#cli/shutdown.js";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{eveCliBanner}from"#cli/banner.js";import{startCliLiveRow}from"#cli/ui/live-row.js";async function loadDevelopmentTuiModule(){return await import(`#cli/dev/tui/tui.js`)}async function loadStartHost(){return(await import(`#cli/dev/local-server-process.js`)).createDevelopmentServer}const loadIsActiveDevelopmentServerForApp=async()=>(await import(`#internal/nitro/host.js`)).isActiveDevelopmentServerForApp;function hasInteractiveTerminal(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function registerDevelopmentCommand(e){let{applicationContext:t,logger:n,program:r,runtime:i,telemetry:a}=e,o=createCliTheme();agentCommand(r.command(`dev`),t,e=>{let t=e.opts();return resolveDevelopmentUrlTarget(t,e.processedArgs[0])===void 0}).description(`Start the eve development server or connect to an existing URL.`).argument(`[url]`,`Connect to an existing server URL`,parseDevelopmentServerUrl).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 2000)`,parsePortOption).option(`-u, --url <url>`,`Connect to an existing server URL`,parseDevelopmentServerUrl).option(`-H, --header <header>`,`Request header for a URL target, in "Name: value" form (repeatable)`,parseDevelopmentHeaderOption).option(`--no-ui`,`Start the server without an interactive UI`).option(`--name <name>`,`Title shown in the terminal UI (defaults to the app folder name)`).option(`--input <text>`,`Pre-fill the prompt input`).addOption(new Option(`--onboard`,`Start fresh-agent onboarding`).hideHelp()).option(`--tools <mode>`,`How tool calls render: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--reasoning <mode>`,`How reasoning renders: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--subagents <mode>`,`How subagent sections render: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--connection-auth <mode>`,`How connection authorization renders: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--assistant-response-stats <mode>`,`Assistant header statistic: tokens | tokensPerSecond`,parseStatsMode).option(`--context-size <tokens>`,`Model context window size, shown as a usage percentage`,parseContextSizeOption).option(`--logs <mode>`,`Which server/agent logs to show: all | stderr | sandbox | none`,parseLogsMode).addHelpText(`after`,`
|
|
2
|
+
You can also pass a bare URL, for example: eve dev https://example.com
|
|
3
|
+
`).action(async(e,r)=>{let s=resolveDevelopmentUrlTarget(r,e),c=s?.serverUrl,l=hasInteractiveTerminal(),u=resolveDevUiMode({options:r,interactive:l});if(a.trackDevContext({target:s?`remote`:`local`,ui:u}),u===`headless`&&n.log(eveCliBanner()),r.input!==void 0&&u===`headless`)throw new InvalidArgumentError(`--input requires the interactive UI.`);let d=!1;if(c!==void 0&&(d=await(i.isActiveDevelopmentServerForApp??await loadIsActiveDevelopmentServerForApp())({appRoot:t.root,serverUrl:c})),c){let{loadDevelopmentEnvironmentFiles:e}=await import(`#cli/dev/environment.js`);if(await e(t.root),n.log(`↗ ${d?`local`:`remote`} mode targeting ${o.info(new URL(c).host)}`),u===`headless`){n.log(renderCliTaggedLine(o,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}n.log(``);let l=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS});try{await runInteractiveDevelopmentUi({applicationRoot:t.root,existingLocalServer:d,lifecycle:l,onOnboardingStep:a.trackSetupStep,onOnboardingTerminal:a.trackSetupTerminal,options:r,remoteTarget:s,runDevelopmentTui:i.runDevelopmentTui,server:{serverUrl:c}})}finally{l.dispose()}return}let f=u===`tui`?startCliLiveRow(n):void 0,p=createDevBootProgressReporter(f);f?.update(`Building your agent`);let m,h,closeServer=()=>m===void 0?Promise.resolve():(h??=m.close(),h.catch(()=>void 0),h),g=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS,onStop:()=>{closeServer()}}),_,v=u===`tui`&&i.runDevelopmentTui===void 0?loadDevelopmentTuiModule().then(e=>(p({type:`before-first-paint`}),e.startDevelopmentTuiStartup({appRoot:t.root,initialInput:r.input,onExitRequest:g.requestStop,...resolveTuiDisplayOptions(r)}))):void 0;try{m=(i.startHost??await loadStartHost())(t.root,{existing:u===`tui`?`attach-if-unconfigured`:`reject`,host:r.host,onBootProgress:p,port:r.port});let[e,s]=await Promise.all([Promise.race([m.start().then(e=>({handle:e})),g.stopped.then(()=>({handle:void 0}))]),v]),c=e.handle;if(c===void 0){_=s,await _?.shutdown();return}if(_=s,u!==`tui`&&n.log(renderCliTaggedLine(o,{message:`server listening at ${c.url}`,tag:`dev`,tone:`success`})),u===`headless`){r.ui!==!1&&!l&&n.log(renderCliTaggedLine(o,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForServerOrStop(m,g);return}await waitForUiOrServer({handle:c,lifecycle:g,server:m,runUi:async()=>await runInteractiveDevelopmentUi({applicationRoot:t.root,existingLocalServer:!1,lifecycle:g,onOnboardingStep:a.trackSetupStep,onOnboardingTerminal:a.trackSetupTerminal,options:r,report:p,runDevelopmentTui:i.runDevelopmentTui,server:{appRoot:c.appRoot,serverUrl:c.url},startup:_})})}finally{f?.stop(),_===void 0&&(_=await v?.catch(()=>void 0),await _?.shutdown()),await closeServer(),g.dispose()}})}export{registerDevelopmentCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{formatRegistrySessionResult,registryItemProgress,registryResultTone}from"./registry-result-message.js";import{createTuiPrompter}from"./tui-prompter.js";import{runDeployFlow}from"#setup/flows/deploy.js";import{WizardCancelledError}from"#setup/step.js";import{runModelLogin}from"#setup/flows/model-login.js";import{HumanActionRequiredError}from"#setup/human-action.js";import{runInstallVercelCliFlow}from"#setup/flows/install-vercel-cli.js";import{runModelFlow}from"#setup/flows/model.js";import{RegistryFlowFailedError,runRegistryFlow}from"#setup/flows/registry.js";const SETUP_FLOW_CONFIG={login:{title:`Connecting your model`,indicator:`pulse`},model:{title:`Configure the agent model`,indicator:`pulse`},add:{title:`Add to your agent`,indicator:`pulse`},deploy:{title:`Deploy to Vercel`,indicator:`spinner`}};function muteableRenderer(e,t,n){return{readSelect:n=>t()?Promise.resolve(void 0):e.readSelect(n),readEditableSelect:n=>t()?Promise.resolve(void 0):e.readEditableSelect(n),readProviderPicker:n=>t()?Promise.resolve(void 0):e.readProviderPicker(n),readModelEditor:n=>t()?Promise.resolve(void 0):e.readModelEditor(n),readText:n=>t()?Promise.resolve(void 0):e.readText(n),readAcknowledge:n=>t()?Promise.resolve():e.readAcknowledge(n),readChoice:n=>t()?{choice:Promise.resolve(void 0),close:()=>{}}:e.readChoice(n),setNavigation:n=>{t()||e.setNavigation?.(n)},setStatus:n=>{t()||e.setStatus(n)},renderLine:(n,r)=>{(!t()||r===`warning`||r===`error`)&&e.renderLine(n,r)},replaceContent:n=>{t()||e.replaceContent?.(n)},renderOutput:n=>{t()||e.renderOutput(n)},withInheritedStdio:t=>e.withInheritedStdio(t),withExclusiveTerminal:e=>n?.(e)??e()}}function cancelledSetupResult(){return{message:``,cancelled:!0,preserveFlowDiagnostics:!1}}async function runTuiSetupCommand(e){let{command:t}=e,n=!1,r=new AbortController,i=muteableRenderer(e.renderer,()=>n,e.withExclusiveTerminal),a=(e.createPrompter??createTuiPrompter)(i),cancelActiveRegistryItem,runRegistryItem=async e=>{let t=new AbortController;cancelActiveRegistryItem=()=>t.abort(new WizardCancelledError);try{return await e(AbortSignal.any([r.signal,t.signal]))}finally{cancelActiveRegistryItem=void 0}},o=e.renderer.waitForInterrupt(),s=executeSetupCommand(e,a,i,r.signal,runRegistryItem),c=s.then(e=>({kind:`outcome`,value:e}));try{for(;;){let i=!1;try{let e=await Promise.race([c,o.promise.then(e=>({kind:`interrupt`,interrupt:e}))]);if(e.kind===`outcome`)return e.value;if(t===`add`&&e.interrupt===`escape`&&cancelActiveRegistryItem!==void 0)cancelActiveRegistryItem(),i=!0;else{n=!0,r.abort(new WizardCancelledError);let e=await s;return e.partial===!0?e:{...e,...cancelledSetupResult(),tone:void 0}}}finally{o.dispose()}i&&(o=e.renderer.waitForInterrupt())}}finally{e.renderer.setStatus(void 0)}}async function executeSetupCommand(e,t,n,r,i){let{command:a,appRoot:o}=e,s={runInstallVercelCliFlow,runModelFlow,runRegistryFlow,runDeployFlow,...e.flows};try{switch(a){case`login`:{let n=await(s.runModelLogin??runModelLogin)({appRoot:o,agentRoot:e.agentRoot,prompter:t,signal:r,automatic:e.initialModelStep===`provider`,withConnectionUpdate:e.withExclusiveTerminal});return n.kind===`cancelled`?{message:`Connect a model with /login when you’re ready.`,cancelled:!0,preserveFlowDiagnostics:!1}:{message:`Connected. Start chatting · /add to extend your agent`,effect:{kind:`model-access-changed`,reload:n.reload,...n.model&&{model:n.model}},preserveFlowDiagnostics:!1}}case`model`:{let i={appRoot:e.agentRoot??o,environmentRoot:o,prompter:t,signal:r,chatGptAccountLabel:e.chatGptAccountLabel,deps:{pickModelSettings:e=>n.readModelEditor(e)}};e.initialModelStep!==void 0&&(i.initialStep=e.initialModelStep),e.onOnboardingScreen!==void 0&&(i.onScreen=t=>e.onOnboardingScreen?.({screen:t}));let a=await s.runModelFlow(i);if(a.kind===`cancelled`)return cancelledSetupResult();let c=[];a.modelMessage!==void 0&&c.push(a.modelMessage),a.providerSelection!==void 0&&c.push(providerSelectionMessage(a.providerSelection));let l={message:c.join(`
|
|
2
|
-
`),preserveFlowDiagnostics:!1};return a.accessChanged&&(l.effect={kind:`model-access-changed`,reload:!0}),l}case`add`:{let a=await s.runRegistryFlow({appRoot:o,prompter:t,signal:r,initialAddress:e.initialRegistryAddress,onScreen:e.onOnboardingScreen,onItemStart:registryItemProgress(n),runItem:i});if(a.kind===`cancelled`)return cancelledSetupResult();let c=a.result,l=registryResultTone(c),u=c.items.length>0||c.failures.length>0||c.outcomes!==void 0?formatRegistrySessionResult(c):`No integrations selected.`,d={message:l===`error`?`/add failed — ${u}`:u,preserveFlowDiagnostics:!0};return c.cancelled===!0?(d.partial=!0,d.tone=`error`):l!==void 0&&(d.tone=l),c.deployed===`production`&&(d.effect={kind:`deployed`}),d}case`deploy`:{let e=await s.runDeployFlow({appRoot:o,prompter:t,interactive:!0,signal:r});return e.kind===`cancelled`?cancelledSetupResult():e.kind===`needs-link`?{message:`Not linked to a Vercel project. Run eve deploy in an interactive terminal to link it.`,preserveFlowDiagnostics:!0}:e.kind===`local-model`?{message:`ChatGPT subscription models are local-only. Switch to an AI Gateway or server-authenticated model before deploying.`,preserveFlowDiagnostics:!0}:{message:e.productionUrl===void 0?`Deployed.`:`Deployed: ${e.productionUrl}`,preserveFlowDiagnostics:!0,effect:{kind:`deployed`}}}}}catch(e){if(e instanceof WizardCancelledError)return cancelledSetupResult();let n=e instanceof RegistryFlowFailedError?e.cause:e,i=await vercelCliUpgradeOutcome(n,a,s,{appRoot:o,prompter:t,signal:r});if(i!==void 0)return withRegistryResults(i,e);let c=vercelActionOutcome(n,a);return c===void 0?e instanceof RegistryFlowFailedError?{message:`${formatRegistrySessionResult(e.completed)}\n\n${e.message}`,partial:!0,tone:`error`,preserveFlowDiagnostics:!0}:{message:`/${a} failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`,preserveFlowDiagnostics:!0}:withRegistryResults(c,e)}}function withRegistryResults(e,t){return t instanceof RegistryFlowFailedError?{...e,message:`${formatRegistrySessionResult(t.completed)}\n\n${e.message}`,partial:!0,tone:`error`,preserveFlowDiagnostics:!0}:e}async function vercelCliUpgradeOutcome(e,t,n,r){if(!(e instanceof HumanActionRequiredError)||e.action.kind!==`vercel-cli-upgrade`)return;let i;try{i=await r.prompter.select({message:`Your Vercel CLI needs an update to list your teams. Upgrade now?`,options:[{value:`upgrade`,label:`Upgrade Vercel CLI`,description:`Run the Vercel CLI's native upgrader`},{value:`later`,label:`Not now`}],initialValue:`upgrade`})}catch{i=`later`}if(i===`later`)return{message:`The Vercel CLI needs an update — run \`vercel upgrade\`, then retry /${t}.`,tone:`error`,preserveFlowDiagnostics:!0};let a;try{a=await n.runInstallVercelCliFlow({appRoot:r.appRoot,prompter:r.prompter,signal:r.signal,upgrade:!0})}catch(e){return{message:vercelCliUpgradeFailureMessage(t,errorMessage(e)),tone:`error`,preserveFlowDiagnostics:!0}}switch(a.kind){case`installed`:return{message:`Upgraded the Vercel CLI. Retry /${t}.`,tone:`error`,preserveFlowDiagnostics:!1};case`failed`:return{message:vercelCliUpgradeFailureMessage(t,a.reason),tone:`error`,preserveFlowDiagnostics:!0};case`cancelled`:return{message:`Vercel CLI upgrade cancelled — run \`vercel upgrade\`, then retry /${t}.`,tone:`error`,preserveFlowDiagnostics:!0};case`already`:return{message:`The Vercel CLI is already up to date. Retry /${t}.`,tone:`error`,preserveFlowDiagnostics:!1}}}function errorMessage(e){let t=(e instanceof Error?e.message:String(e)).replace(/\s+/gu,` `).trim();return t.length<=240?t:`${t.slice(0,239)}…`}function vercelCliUpgradeFailureMessage(e,t){return`Couldn't upgrade the Vercel CLI${t===void 0||t===``?``:` (${t})`} — run \`vercel upgrade\`, then retry /${e}.`}function vercelActionOutcome(e,t){if(!(e instanceof HumanActionRequiredError))return;let n=vercelActionMessage(e.action.kind,t);return n===void 0?void 0:{message:n,tone:`error`,preserveFlowDiagnostics:!0}}function vercelActionMessage(e,t){switch(e){case`vercel-login`:return`You're not logged in to Vercel — run /deploy to connect your Vercel account, then retry /${t}.`;case`vercel-forbidden`:return`Vercel denied access to that team — check your team access and SSO, then retry /${t}.`;case`vercel-cli-missing`:return`The Vercel CLI isn't installed — run /deploy to install it, then retry /${t}.`;case`vercel-cli-upgrade`:return`The Vercel CLI needs an update — run \`vercel upgrade\`, then retry /${t}.`;default:return}}function providerSelectionMessage(e){return e===`chatgpt`?`ChatGPT subscription selected.`:e===`ai-gateway-project`?`AI Gateway via Project selected.`:`AI Gateway via API key selected.`}export{SETUP_FLOW_CONFIG,runTuiSetupCommand};
|
|
2
|
+
`),preserveFlowDiagnostics:!1};return a.accessChanged&&(l.effect={kind:`model-access-changed`,reload:!0}),l}case`add`:{let a=await s.runRegistryFlow({appRoot:o,installRoot:e.agentRoot,prompter:t,signal:r,initialAddress:e.initialRegistryAddress,onScreen:e.onOnboardingScreen,onItemStart:registryItemProgress(n),runItem:i});if(a.kind===`cancelled`)return cancelledSetupResult();let c=a.result,l=registryResultTone(c),u=c.items.length>0||c.failures.length>0||c.outcomes!==void 0?formatRegistrySessionResult(c):`No integrations selected.`,d={message:l===`error`?`/add failed — ${u}`:u,preserveFlowDiagnostics:!0};return c.cancelled===!0?(d.partial=!0,d.tone=`error`):l!==void 0&&(d.tone=l),c.deployed===`production`&&(d.effect={kind:`deployed`}),d}case`deploy`:{let e=await s.runDeployFlow({appRoot:o,prompter:t,interactive:!0,signal:r});return e.kind===`cancelled`?cancelledSetupResult():e.kind===`needs-link`?{message:`Not linked to a Vercel project. Run eve deploy in an interactive terminal to link it.`,preserveFlowDiagnostics:!0}:e.kind===`local-model`?{message:`ChatGPT subscription models are local-only. Switch to an AI Gateway or server-authenticated model before deploying.`,preserveFlowDiagnostics:!0}:{message:e.productionUrl===void 0?`Deployed.`:`Deployed: ${e.productionUrl}`,preserveFlowDiagnostics:!0,effect:{kind:`deployed`}}}}}catch(e){if(e instanceof WizardCancelledError)return cancelledSetupResult();let n=e instanceof RegistryFlowFailedError?e.cause:e,i=await vercelCliUpgradeOutcome(n,a,s,{appRoot:o,prompter:t,signal:r});if(i!==void 0)return withRegistryResults(i,e);let c=vercelActionOutcome(n,a);return c===void 0?e instanceof RegistryFlowFailedError?{message:`${formatRegistrySessionResult(e.completed)}\n\n${e.message}`,partial:!0,tone:`error`,preserveFlowDiagnostics:!0}:{message:`/${a} failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`,preserveFlowDiagnostics:!0}:withRegistryResults(c,e)}}function withRegistryResults(e,t){return t instanceof RegistryFlowFailedError?{...e,message:`${formatRegistrySessionResult(t.completed)}\n\n${e.message}`,partial:!0,tone:`error`,preserveFlowDiagnostics:!0}:e}async function vercelCliUpgradeOutcome(e,t,n,r){if(!(e instanceof HumanActionRequiredError)||e.action.kind!==`vercel-cli-upgrade`)return;let i;try{i=await r.prompter.select({message:`Your Vercel CLI needs an update to list your teams. Upgrade now?`,options:[{value:`upgrade`,label:`Upgrade Vercel CLI`,description:`Run the Vercel CLI's native upgrader`},{value:`later`,label:`Not now`}],initialValue:`upgrade`})}catch{i=`later`}if(i===`later`)return{message:`The Vercel CLI needs an update — run \`vercel upgrade\`, then retry /${t}.`,tone:`error`,preserveFlowDiagnostics:!0};let a;try{a=await n.runInstallVercelCliFlow({appRoot:r.appRoot,prompter:r.prompter,signal:r.signal,upgrade:!0})}catch(e){return{message:vercelCliUpgradeFailureMessage(t,errorMessage(e)),tone:`error`,preserveFlowDiagnostics:!0}}switch(a.kind){case`installed`:return{message:`Upgraded the Vercel CLI. Retry /${t}.`,tone:`error`,preserveFlowDiagnostics:!1};case`failed`:return{message:vercelCliUpgradeFailureMessage(t,a.reason),tone:`error`,preserveFlowDiagnostics:!0};case`cancelled`:return{message:`Vercel CLI upgrade cancelled — run \`vercel upgrade\`, then retry /${t}.`,tone:`error`,preserveFlowDiagnostics:!0};case`already`:return{message:`The Vercel CLI is already up to date. Retry /${t}.`,tone:`error`,preserveFlowDiagnostics:!1}}}function errorMessage(e){let t=(e instanceof Error?e.message:String(e)).replace(/\s+/gu,` `).trim();return t.length<=240?t:`${t.slice(0,239)}…`}function vercelCliUpgradeFailureMessage(e,t){return`Couldn't upgrade the Vercel CLI${t===void 0||t===``?``:` (${t})`} — run \`vercel upgrade\`, then retry /${e}.`}function vercelActionOutcome(e,t){if(!(e instanceof HumanActionRequiredError))return;let n=vercelActionMessage(e.action.kind,t);return n===void 0?void 0:{message:n,tone:`error`,preserveFlowDiagnostics:!0}}function vercelActionMessage(e,t){switch(e){case`vercel-login`:return`You're not logged in to Vercel — run /deploy to connect your Vercel account, then retry /${t}.`;case`vercel-forbidden`:return`Vercel denied access to that team — check your team access and SSO, then retry /${t}.`;case`vercel-cli-missing`:return`The Vercel CLI isn't installed — run /deploy to install it, then retry /${t}.`;case`vercel-cli-upgrade`:return`The Vercel CLI needs an update — run \`vercel upgrade\`, then retry /${t}.`;default:return}}function providerSelectionMessage(e){return e===`chatgpt`?`ChatGPT subscription selected.`:e===`ai-gateway-project`?`AI Gateway via Project selected.`:`AI Gateway via API key selected.`}export{SETUP_FLOW_CONFIG,runTuiSetupCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join}from"node:path";import{pathExists}from"#setup/path-exists.js";import{hasEnvValue,resolveGatewayCredential}from"#internal/resolve-model-endpoint-status.js";function normalizeLocalModelEndpoint(e,t){let n=modelProviderAccess({env:t,info:e});if(e===void 0||n.kind!==`gateway`||n.runtime.status!==`connected`)return e;let{credential:r}=n.runtime,i=e.agent.model;if(i.id===void 0||i.routing.kind!==`gateway`)return e;let a=i.endpoint;if(a?.kind===`gateway`&&a.connected&&a.credential===r)return e;let o={connected:!0,credential:r,kind:`gateway`};return{...e,agent:{...e.agent,model:{contextWindowTokens:i.contextWindowTokens,endpoint:o,id:i.id,providerOptions:i.providerOptions,reasoning:i.reasoning,routing:i.routing,source:i.source}}}}function modelProviderAccess(e){let t=e.info?.agent.model;if(t?.routing?.kind===`external`)return{kind:`external`};if(t?.routing?.kind!==`gateway`)return{kind:`unknown`};let n=e.env.EVE_MODEL_CONNECTION,r=resolveGatewayCredential({apiKeyInEnv:(n===void 0||n===`ai-gateway-key`&&e.env.EVE_MODEL_KEY_SOURCE!==`secret`)&&hasEnvValue(e.env.AI_GATEWAY_API_KEY),oidcAvailable:(n===void 0||n===`ai-gateway-project`)&&hasEnvValue(e.env.VERCEL_OIDC_TOKEN)});if(r?.credential===`api-key`)return{kind:`gateway`,runtime:{status:`connected`,credential:`api-key`}};let i=t.endpoint;return i?.kind===`gateway`&&i.connected?{kind:`gateway`,runtime:{status:`connected`,credential:i.credential}}:r===void 0?i?.kind===`gateway`?{kind:`gateway`,runtime:{status:`disconnected`}}:{kind:`gateway`,runtime:{status:`unknown`}}:{kind:`gateway`,runtime:{status:`connected`,credential:r.credential}}}const BOOT_DETECTIONS=[{id:`model-provider`,async detect({appRoot:e,env:t,info:n}){let r=modelProviderAccess({env:t,info:n});if(r.kind===`external`)return[];if(r.kind===`gateway`){if(r.runtime.status===`connected`)return[];if(r.runtime.status===`disconnected`)return[{kind:`attention`,label:await pathExists(join(e,`.vercel`,`project.json`))?`AI Gateway credentials missing`:`connect a model`,command:`/login`}]}return await pathExists(join(e,`.vercel`,`project.json`))?[{kind:`attention`,label:`AI Gateway credentials missing`,command:`/login`}]:[{kind:`attention`,label:`connect a model`,command:`/login`}]}}],LOGIN_SETUP_ISSUE={kind:`attention`,label:`not logged in`,command:`/deploy`},CLI_MISSING_SETUP_ISSUE={kind:`attention`,label:`Vercel CLI not found`,command:`/deploy`};async function detectSetupIssues(e,t=BOOT_DETECTIONS){return(await Promise.all(t.map(async t=>{try{return await t.detect(e)}catch{return[]}}))).flat()}function orderedSetupIssues(e,t){return t===void 0?[...e]:[t,...e]}function formatSetupIssuesLine(e){let t=e.length===1?`setup issue`:`setup issues`,n=e.map(e=>`${e.label} · ${e.command}`).join(`, `);return`${e.length} ${t}: ${n}`}export{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,normalizeLocalModelEndpoint,orderedSetupIssues};
|
|
1
|
+
import{join}from"node:path";import{pathExists}from"#setup/path-exists.js";import{hasEnvValue,resolveGatewayCredential}from"#internal/resolve-model-endpoint-status.js";function normalizeLocalModelEndpoint(e,t){let n=modelProviderAccess({env:t,info:e});if(e===void 0||n.kind!==`gateway`||n.runtime.status!==`connected`)return e;let{credential:r}=n.runtime,i=e.agent.model;if(i.id===void 0||i.routing.kind!==`gateway`)return e;let a=i.endpoint;if(a?.kind===`gateway`&&a.connected&&a.credential===r)return e;let o={connected:!0,credential:r,kind:`gateway`};return{...e,agent:{...e.agent,model:{contextWindowTokens:i.contextWindowTokens,endpoint:o,id:i.id,providerOptions:i.providerOptions,reasoning:i.reasoning,routing:i.routing,source:i.source}}}}function modelProviderAccess(e){let t=e.info?.agent.model;if(t?.routing?.kind===`dynamic`)return{kind:`dynamic`};if(t?.routing?.kind===`external`)return{kind:`external`};if(t?.routing?.kind!==`gateway`)return{kind:`unknown`};let n=e.env.EVE_MODEL_CONNECTION,r=resolveGatewayCredential({apiKeyInEnv:(n===void 0||n===`ai-gateway-key`&&e.env.EVE_MODEL_KEY_SOURCE!==`secret`)&&hasEnvValue(e.env.AI_GATEWAY_API_KEY),oidcAvailable:(n===void 0||n===`ai-gateway-project`)&&hasEnvValue(e.env.VERCEL_OIDC_TOKEN)});if(r?.credential===`api-key`)return{kind:`gateway`,runtime:{status:`connected`,credential:`api-key`}};let i=t.endpoint;return i?.kind===`gateway`&&i.connected?{kind:`gateway`,runtime:{status:`connected`,credential:i.credential}}:r===void 0?i?.kind===`gateway`?{kind:`gateway`,runtime:{status:`disconnected`}}:{kind:`gateway`,runtime:{status:`unknown`}}:{kind:`gateway`,runtime:{status:`connected`,credential:r.credential}}}const BOOT_DETECTIONS=[{id:`model-provider`,async detect({appRoot:e,env:t,info:n}){let r=modelProviderAccess({env:t,info:n});if(r.kind===`external`||r.kind===`dynamic`)return[];if(r.kind===`gateway`){if(r.runtime.status===`connected`)return[];if(r.runtime.status===`disconnected`)return[{kind:`attention`,label:await pathExists(join(e,`.vercel`,`project.json`))?`AI Gateway credentials missing`:`connect a model`,command:`/login`}]}return await pathExists(join(e,`.vercel`,`project.json`))?[{kind:`attention`,label:`AI Gateway credentials missing`,command:`/login`}]:[{kind:`attention`,label:`connect a model`,command:`/login`}]}}],LOGIN_SETUP_ISSUE={kind:`attention`,label:`not logged in`,command:`/deploy`},CLI_MISSING_SETUP_ISSUE={kind:`attention`,label:`Vercel CLI not found`,command:`/deploy`};async function detectSetupIssues(e,t=BOOT_DETECTIONS){return(await Promise.all(t.map(async t=>{try{return await t.detect(e)}catch{return[]}}))).flat()}function orderedSetupIssues(e,t){return t===void 0?[...e]:[t,...e]}function formatSetupIssuesLine(e){let t=e.length===1?`setup issue`:`setup issues`,n=e.map(e=>`${e.label} · ${e.command}`).join(`, `);return`${e.length} ${t}: ${n}`}export{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,normalizeLocalModelEndpoint,orderedSetupIssues};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import{maskLine,visibleLine}from"./line-editor.js";import{modelEditorMenuRows,reasoningPositions}from"./model-editor.js";import{clipVisible,renderInputText,renderInputWithBlockCursor,visibleLength,wrapVisibleLine}from"#cli/ui/terminal-text.js";import{renderCursorRow,renderOptionRow,resolveOptionRowState}from"#setup/cli/option-row.js";import{filterOptions,submitRowIndex}from"#setup/cli/select-state.js";function clip(e,t){return clipVisible(e,t)}function questionFooter(e,t,n){let r=t.colors,i=e.join(` ${t.glyph.dot} `);return[``,...(n===void 0?[i]:wrapVisibleLine(i,Math.max(1,n-3))).map(e=>` ${r.dim(e)}`)]}function solidWithinDim(e,t){return t.color?`[22m${e}[2m`:e}function toneGlyph(e,t){let n=t.colors;switch(e){case`success`:return n.green(t.glyph.success);case`warning`:return n.yellow(t.glyph.warning);case`error`:return n.red(t.glyph.error);case`info`:return n.dim(t.glyph.dot)}}function renderIndicator(e,t){return e.color===`green`?t.colors.green(e.glyph):t.colors.yellow(e.glyph)}function renderStatusText(e,t){if(e.kind===`progress`)return t.colors.dim(e.text);let n=e.text.indexOf(e.emphasis);if(n===-1)return t.colors.dim(e.text);let r=n+e.emphasis.length;return`${t.colors.dim(e.text.slice(0,n))}${t.colors.yellow(e.text.slice(n,r))}${t.colors.dim(e.text.slice(r))}`}function renderFlowPanelStatus(e,t){return`${renderIndicator(e.indicator,t)} ${renderStatusText(e,t)}`}function flowMessageRows(e,t){let n=t.colors,r=[],i=e.slice(-6);for(let e of i){let i=e.text.split(`
|
|
2
|
-
`);for(let[a,o]of i.entries()){let i=e.tone===`info`?n.dim(o):o,s=a===0?`${toneGlyph(e.tone,t)} `:` `;r.push(` ${s}${i}`)}}return i.length>0&&r.push(``),r}function renderFlowPanel(e,t,n){let r=t.colors,i=[],a=e.content.kind===`question`?e.content.title??e.title:e.title;
|
|
2
|
+
`);for(let[a,o]of i.entries()){let i=e.tone===`info`?n.dim(o):o,s=a===0?`${toneGlyph(e.tone,t)} `:` `;r.push(` ${s}${i}`)}}return i.length>0&&r.push(``),r}function renderFlowPanel(e,t,n){let r=t.colors,i=[],a=e.content.kind===`question`?e.content.title??e.title:e.title;if(a.length>0){for(let e of a.split(`
|
|
3
|
+
`))i.push(e.length===0?``:` ${r.bold(e)}`);i.push(``)}switch(e.navigation?.kind===`planner`&&i.push(...plannerStepRows(e.navigation,void 0,t)),i.push(...flowMessageRows(e.lines,t)),e.content.kind){case`question`:e.content.status!==void 0&&i.push(` ${renderFlowPanelStatus(e.content.status,t)}`,``),i.push(...e.content.rows);break;case`status`:if(i.push(` ${renderFlowPanelStatus(e.content.status,t)}`),e.content.preview!==void 0)for(let t of e.content.preview.split(`
|
|
3
4
|
`))i.push(` ${r.dim(t)}`);break;case`preview`:{let[n,...a]=e.content.text.split(`
|
|
4
5
|
`);i.push(` ${renderIndicator(e.content.indicator,t)} ${r.dim(n??``)}`);for(let e of a)i.push(` ${r.dim(e)}`);break}case`idle`:i.push(` ${renderIndicator(e.content.indicator,t)} ${r.dim(`Working…`)}`)}return i.map(e=>e.length===0?clip(e,n):clip(` ${e}`,n))}function optionRow(e){let{option:t,theme:n}=e,r=e.railed===!0;return renderOptionRow({colors:n.colors,glyphs:{pointer:n.glyph.pointer,selectedPointer:n.glyph.selectedPointer,success:n.glyph.success,placeholder:n.glyph.option,dot:r?``:n.glyph.dot,warning:n.glyph.warning},label:t.label,hint:t.hint,focusHint:t.focusHint,accent:t.accent,isCursor:e.isCursor,state:resolveOptionRowState(t,e.isChecked),placeholder:e.placeholder,hintPadding:e.hintPadding})}function selectPresentation(e){switch(e.kind){case`single`:return{selection:`single`,filter:void 0,layout:`plain`,edit:void 0};case`search`:return{selection:`single`,filter:{placeholder:e.placeholder},layout:e.layout??`plain`,edit:void 0};case`multi`:return{selection:`multiple`,filter:void 0,layout:`plain`,edit:void 0};case`searchable-multi`:return{selection:`multiple`,filter:{placeholder:e.placeholder},layout:e.layout??`plain`,edit:void 0};case`stacked`:return{selection:`single`,filter:void 0,layout:`stacked`,edit:void 0};case`task-list`:return{selection:`single`,filter:void 0,layout:`task-list`,edit:void 0};case`inline-edit`:return{selection:`single`,filter:void 0,layout:e.layout,edit:e.edit}}}function canNavigateBack(e){return e.activeStep>(e.firstNavigableStep??0)}function canNavigateForward(e){return e.activeStep>=(e.firstNavigableStep??0)&&e.activeStep<e.steps.length-1}function plannerStepRows(e,t,n){let r=e.steps.map((r,i)=>{let a=i===e.activeStep?t:r.count,o=a===void 0||a===0?``:` (${a})`,s=`${r.complete===!0?`${n.glyph.success} `:``}${r.label}${o}`;return i===e.activeStep?n.colors.bold(` ${s}`):r.complete===!0?n.colors.green(s):n.colors.dim(s)});return[` ${r.flatMap((t,i)=>{if(i===r.length-1)return[t];let a=e.activeStep===i&&canNavigateForward(e)?` → `:e.activeStep===i+1&&canNavigateBack(e)?` ← `:` · `;return[t,n.colors.dim(a)]}).join(``)}`,``]}function selectMessageRows(e,t,n){if(e===``)return[];let r=e.split(`
|
|
5
6
|
`).map((e,r)=>` ${t===`stacked`||r>0?n.colors.bold(e):e}`);return r.push(``),r}function searchFilter(e,t,n,r,i){let a=r.colors.dim(r.glyph.caret),o=a;return i?o=e.length>0?e+a:r.colors.dim(t??`type to filter`):e.length>0?o=e+a:t!==void 0&&(o=r.colors.dim(`> ${t}`)),n===void 0?o:`${o} ${r.colors.yellow(n)}`}function isRailedSearch(e){return e.filter!==void 0&&e.layout===`plain`&&e.selection===`single`&&e.edit===void 0}function selectViewSize(e){return e.search?e.railed?5:e.stacked?Math.min(e.optionCount,8):8:e.optionCount}function noticeBody(e,t,n){return e.tone===`info`?n.colors.dim(e.text):e.tone===`success`&&t===`task-list`?n.colors.bold(e.text):e.text}function renameHint(e,t,n,r){let i={text:n.editor.text||n.defaultValue,cursor:n.editor.cursor},a=renderInputWithBlockCursor({...visibleLine(i,1/0),visible:t,inverse:r.colors.inverse});return n.editor.text.length>0&&(a=solidWithinDim(a,r)),{...e,hint:n.formatHint(a)}}function keyHint(e,t,n,r,i){let a=n.phase;if(a.kind===`inactive`)return e;let o=r.colors,s=maskLine(a.editor),c=a.kind!==`validating`&&a.kind!==`invalid`,l=``;a.kind===`editing`?l=` ${enterBadge(r,`validate`)}`:a.kind===`validating`?l=` ${o.yellow(r.glyph.validating)} ${o.dim(`validating`)}`:a.kind===`invalid`&&(l=` ${o.red(`${r.glyph.error} API key is not valid`)}`);let u=`${r.glyph.elbow} `,d=a.editor.text.length===0?`type your key`:void 0,f=d===void 0?s:{text:d,cursor:0},p=Math.max(1,i-visibleLength(`${u}${l}`)),m=visibleLine(f,p,r.glyph.ellipsis),h=c?renderInputWithBlockCursor({...m,visible:t,inverse:r.colors.inverse}):renderInputText(`${m.before}${m.under}${m.after}`);return{...e,hint:`${u}${h}${l}`}}function inlineEditOption(e,t,n,r,i){if(!t||n===void 0||e.value!==n.optionValue)return e;switch(n.editor.kind){case`rename`:return renameHint(e,n.caretVisible,n.editor,r);case`key`:return keyHint(e,n.caretVisible,n.editor,r,i)}}function optionUsesPlaceholder(e,t){let n=e.filter!==void 0&&e.layout!==`task-list`,r=e.selection===`multiple`,i=e.layout!==`plain`;return!n&&!t&&(r||i)}function appendSelectOptionRows(e){let{rows:t,state:n,presentation:r,visible:i,start:a,end:o,cursor:s,visibleLabelWidth:c,width:l,theme:u}=e,d=!1;for(let e=a;e<o;e+=1){let o=i[e],f=e===s,p=r.layout===`task-list`&&o.trailingAction===!0;p&&(appendSelectNotices(t,n.notices,r.layout,u,l),d=!0),p&&(e>a||(n.notices?.length??0)>0)&&t.push(``);let m=r.layout===`stacked`?Math.max(1,l-6):Math.max(1,l-Math.max(c,o.label.length)-9),h=inlineEditOption(o,f,r.edit,u,m),g=r.edit?.editor.kind===`key`&&f,_={...h,hint:(h.hint??(f||o.disabled?o.description:void 0))?.replace(/\s*\n\s*/gu,` `)};g&&(_.hint=void 0);let v=isRailedSearch(r),y=n.cursorBadge??(v&&!p?enterBadge(u):void 0),b=f&&y!==void 0?` ${y}`:``;t.push(` ${optionRow({option:_,isCursor:f,isChecked:r.selection===`multiple`?n.select.selected.has(o.value):o.checked===!0,placeholder:v||optionUsesPlaceholder(r,p),railed:v,hintPadding:Math.max(0,c-_.label.length),theme:u})}${b}`),g&&h.hint&&t.push(` ${h.hint}`)}return d}function appendSubmitRow(e,t,n,r){if(n<0)return;let i=t===n,a=i?`${r.glyph.selectedPointer} ${r.colors.bold(`Submit`)}`:` Submit`;e.push(``,` ${renderCursorRow(a,i,r.colors)}`)}function appendSelectNotices(e,t,n,r,i){if(t!==void 0&&t.length!==0){e.push(``);for(let a of t){let t=toneGlyph(a.tone,r),o=` `.repeat(visibleLength(t)+1),s=Math.max(1,i-2-visibleLength(t)-1),c=wrapVisibleLine(a.text,s);for(let[i,s]of c.entries()){let c=noticeBody({...a,text:s},n,r);e.push(i===0?` ${t} ${c}`:` ${o}${c}`)}}}}function selectFooterHints(e,t,n,r){let i=[],a=`esc to cancel`,o=e.edit;if(o!==void 0&&t[n]?.value===o.optionValue){if(o.editor.kind===`key`){let e=o.editor.phase;if(e.kind!==`inactive`&&e.editor.text.length>0&&(a=`esc to clear`),e.kind===`validating`)return[a];i.push(`type your key`)}else i.push(`type to rename`)}if(e.filter!==void 0&&i.push(`type to filter`),i.push(`↑/↓ move`),r!==void 0){let t=canNavigateBack(r),n=canNavigateForward(r);return i.push(e.selection===`multiple`?`space/enter toggle`:`enter to select`),t&&n?i.push(`←/→ steps`):t?i.push(`← back`):n&&i.push(`→ next`),i.push(a),i}return i.push(e.selection===`multiple`?`space to toggle`:`enter to select`),e.selection===`multiple`&&i.push(`enter on Submit to confirm`),i.push(a),i}function renderActionQuestion(e,t,n){let r=[` ${t.colors.dim(`${t.glyph.dot} ${e.context}`)}`,``];for(let[n,i]of e.actions.entries())r.push(` ${optionRow({option:i,isCursor:n===e.cursor,isChecked:!1,placeholder:!0,hintPadding:0,theme:t})}`);return r.push(...questionFooter([`↑/↓ move`,`enter to select`,`esc to cancel`],t)),r.map(e=>clip(e,n))}function renderSelectQuestion(e,t,n){if(e.kind===`actions`)return renderActionQuestion(e,t,n);let r=t.colors,i=selectPresentation(e),a=i.filter?filterOptions(e.options,e.select.filter,e.searchAction):e.options,o=e.navigation?.kind===`planner`?e.navigation:void 0,s=i.selection===`multiple`&&o===void 0?submitRowIndex(a):-1,c=e.select.cursor,l=isRailedSearch(i),u=[...e.navigation?.kind===`planner`?plannerStepRows(e.navigation,i.selection===`multiple`?e.select.selected.size:void 0,t):[],...selectMessageRows(e.message,i.layout,t)];if(e.description!==void 0||e.metadata!==void 0){if(u.at(-1)===``&&u.pop(),e.description!==void 0)for(let t of wrapVisibleLine(e.description,Math.max(1,n-4)))u.push(` ${r.dim(t)}`);for(let{label:t,value:i}of e.metadata??[]){let e=`${t}: `,a=wrapVisibleLine(i,Math.max(1,n-4-e.length));u.push(` ${r.dim(`${e}${a[0]??``}`)}`);for(let t of a.slice(1))u.push(` ${r.dim(`${` `.repeat(e.length)}${t}`)}`)}u.push(``)}i.filter!==void 0&&u.push(` ${l?` `:``}${searchFilter(e.select.filter,i.filter.placeholder,e.loadingFrame,t,l)}`);let d=selectViewSize({search:i.filter!==void 0,filter:e.select.filter,optionCount:a.length,railed:l,stacked:i.layout===`stacked`}),f=Math.max(0,Math.min(c-Math.floor(d/2),Math.max(0,a.length-d))),p=Math.min(f+d,a.length),m=a.slice(f,p).filter(e=>e.hint!==void 0||e.focusHint!==void 0).reduce((e,t)=>Math.max(e,t.label.length),0);a.length===0&&u.push(` ${r.dim(`(no matches)`)}`);let h=appendSelectOptionRows({rows:u,state:e,presentation:i,visible:a,start:f,end:p,cursor:c,visibleLabelWidth:m,width:n,theme:t});if(appendSubmitRow(u,c,s,t),o!==void 0&&i.selection===`multiple`){let t=e.select.selected.size;u.push(``,` ${r.dim(`${t} selected`)}`)}return!l&&a.length>p-f&&u.push(` ${r.dim(`↑↓ ${a.length} options, showing ${f+1}–${p}`)}`),h||appendSelectNotices(u,e.notices,i.layout,t,n),e.error!==void 0&&u.push(``,` ${r.red(e.error)}`),u.push(...questionFooter(l?[`Enter select`,`Esc back`]:selectFooterHints(i,a,c,o),t,n)),u.map(e=>clip(e,n))}function enterBadge(e,t){return e.colors.dim(t===void 0?e.glyph.enter:`${e.glyph.enter} ${t}`)}function reasoningTrack(e){let{count:t,index:n,theme:r}=e,i=r.glyph,a=i.trackLine.repeat(e.connectorWidth),o=[];for(let e=0;e<t;e+=1)e>0&&o.push(a),o.push(e<n?i.trackFilled:e===n?i.trackCurrent:i.trackEmpty);if(!e.accent||n<0)return o.join(``);let s=o.slice(0,2*n+1).join(``);return`${r.colors.blue(s)}${o.slice(2*n+1).join(``)}`}function renderModelEditorQuestion(e,t,n,r=`Select the model`){let{request:i,state:a}=e;switch(a.screen.kind){case`menu`:return renderModelEditorMenu(e,a.screen.cursor,t,n);case`model`:return renderModelEditorModelScreen(i,a.screen.select,t,n,r)}}function renderModelEditorMenu(e,t,n,r){let{request:i,state:a}=e,{draft:o}=a,s=modelEditorMenuRows(i,o,a.capabilities).map(e=>{if(e.disabled===!0&&e.value===`model`)return o.modelId===null?{...e}:{...e,hint:o.modelId};if(e.disabled===!0||e.value===`done`)return{...e};switch(e.value){case`model`:return{...e,hint:o.modelId??void 0};case`reasoning`:{let r=reasoningPositions(a.capabilities,o.reasoning),i=o.reasoning==="default"?-1:r.indexOf(o.reasoning),s=reasoningTrack({count:r.length,index:i,connectorWidth:1,accent:e.value===t,theme:n}),c=o.reasoning==="default"?`provider default`:o.reasoning;return{...e,hint:`${s} ${c}`}}case`tier`:return{...e,hint:o.tier===`priority`?`fast ${n.glyph.fast}`:`normal`};default:return{...e}}});return renderSelectQuestion({kind:`stacked`,message:``,options:s,select:{filter:``,cursor:Math.max(0,s.findIndex(e=>e.value===t)),selected:new Set}},n,r)}function renderModelEditorModelScreen(e,t,n,r,i){return renderSelectQuestion({kind:`search`,message:i,options:e.model.kind===`pick`?e.model.options:[],placeholder:`type to search`,select:t},n,r)}function renderTextQuestion(e,t,n,r){let i=t.colors,a=[];for(let n of e.notices??[]){let e=n.tone===`info`?i.dim(n.text):n.text;a.push(`${toneGlyph(n.tone,t)} ${e}`)}e.message!==``&&a.push(...e.message.split(`
|
|
@@ -4,7 +4,7 @@ import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-c
|
|
|
4
4
|
`),n=stripPromptControlCharacters(e?.initialDraft??this.#J.text),r=t===void 0?n:n.length===0?t:`${t}\n\n${n}`,i=lineOf(r);return this.#J=EMPTY_LINE,this.#H.begin(i.text),this.#it(i),this.#W=typeaheadFor(this.#p,i.text),this.#qt(),this.#Sn(),await new Promise((e,t)=>{this.#Z=t;let apply=e=>{i=e,this.#Yt(),this.#it(i),this.#W=typeaheadFor(this.#p,e.text,this.#W),this.#Sn()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#W=void 0,this.#Jt(),this.#Lt(),t(interruptedError())},suggestions=()=>this.#W!==void 0&&isTypeaheadOpen(this.#W)?this.#W:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#ge=t=>{t.type!==`ctrl-c`&&this.#oe&&(this.#oe=!1,this.#Sn());let n=applyLineEditorKey(i,t,{multiline:!0});if(n!==void 0){apply(n);return}switch(t.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#W=moveTypeaheadSelection(e,-1),this.#Sn();break}let t=movePromptLine(i,`up`);t===void 0?recall(this.#H.previous(i.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#W=moveTypeaheadSelection(e,1),this.#Sn();break}let t=movePromptLine(i,`down`);t===void 0?recall(this.#H.next()):apply(t);break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#W=dismissTypeahead(e),this.#Sn());break}case`enter`:{let t=highlighted(),n=t!==void 0&&parsePromptCommand(i.text)===null?typeaheadCompletion(t).trimEnd():i.text;if(n.trim().length===0)break;this.#W=void 0,this.#H.add(n),this.#U=!1,this.#Jt(),this.#Q=STATUS.processing,isPromptControlCommand(n)?this.#$t({kind:`command`,body:stripTerminalControls(n.trim()),live:!1}):(this.#Zt(),this.#en(n),this.#ze=n,this.#q.arm()),this.#it(EMPTY_LINE),this.#Sn(),this.#zt(),e(n);break}case`ctrl-d`:i.text.length===0?(this.#jt(),interrupt()):apply(deleteForward(i));break;case`ctrl-l`:this.#Tn();break;case`ctrl-r`:this.#Sn();break;case`ctrl-c`:if(this.#oe){this.#jt(),interrupt();break}this.#oe=!0,apply(EMPTY_LINE)}},this.#Rt()})}#it(e){this.#B=e.text,this.#V=e.cursor}takeQueuedPrompt(){let e=this.#Ge.view().steering,t=this.#Ge.takePrompt();return t!==void 0&&(this.#Xe=e?`steer`:`queue`),t}async renderStream(e,t){this.#Ft(t),this.#_.clear(),this.#U=!1,this.#X.kind!==`waiting`&&(this.#X={kind:`waiting`,startedAtMs:Date.now()}),this.#Q=this.#L>0?STATUS.connectionAuth:STATUS.processing,this.#nn(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#f?.recordPrompt(),t?.submittedPrompt!==void 0&&!this.#q.armed&&this.#q.arm(),this.#ie=!1,this.#Je=!1,this.#Ze=!1,this.#Qe=t?.submittedPrompt,this.#Ge.beginTurn(),this.#Ke=e.cancel,this.#qe=e.steer,this.#we=void 0,this.#Te=void 0,this.#De=void 0,this.#Oe=void 0,this.#ke=Date.now();let n={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u};this.#Xt(),this.#Y=!0,this.#Sn();let r=new Promise(e=>{this.#xe=e});this.#ge=e=>this.#Gt(e),this.#Rt();let i={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!0};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#ie)break;this.#un(t,n,i)}}catch(e){let t=summarizeKnownError(e);t===null?this.#rn(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#rn(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#xe=void 0,this.#ie&&e.abort?.(),this.#Ke=void 0,this.#qe=void 0,this.#zt(),this.#Qt(),this.#Y=!1,this.#X.kind===`waiting`&&(this.#X={kind:`idle`}),this.#Q=completedTurnStatus({interrupted:this.#ie,cancelled:this.#Je,continueSession:t?.continueSession===!0}),this.#_n(i),(this.#ie||i.cancelled)&&this.#gn(i),this.#ln(),this.#f?.reportStats(),this.#Sn(),t?.continueSession||this.#Lt()}}async renderIdleStream(e,t){let n={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u},r={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!1};try{for await(let t of iterateTUIStream(e.events))this.#un(t,n,r)}catch(e){let t=summarizeKnownError(e);t===null?this.#rn(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#rn(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#_n(r),r.cancelled&&this.#gn(r),this.#ln(),this.#f?.reportStats(),this.#Sn()}}async readToolApproval(e,t){return this.#Ft(t),this.#Qt(),this.#U=!1,this.#X={kind:`idle`},this.#Q=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#ie=!1,this.#Sn(),await new Promise((t,n)=>{this.#Z=n,this.#ge=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#Zt(),this.#Q=STATUS.processing,this.#zt(),this.#Sn(),t({approved:!0})):n===`n`&&(this.#Zt(),this.#Q=STATUS.processing,this.#ot(e.toolCallId),this.#zt(),this.#Sn(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#Sn();break;case`ctrl-c`:this.#ie=!0,this.#Lt(),n(interruptedError())}},this.#Rt()})}async readInputQuestion(e,t){this.#Ft(t),this.#Qt(),this.#U=!1,this.#G=!1,this.#X={kind:`idle`},this.#ie=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`overlay`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,overlayPanel=t=>renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#le},this.#i,t),renderTextSection=()=>{this.#an({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,void 0,this.#i),preformatted:!0,live:!0})},syncFreeformCaret=()=>{isOnFreeformRow()?this.#qt():(this.#Jt(),this.#Yt())};s===`overlay`?(s=`overlay`,this.#U=!1,this.#sn(o),this.#Be=overlayPanel,this.#Q=``,syncFreeformCaret(),this.#Sn()):(s=`text`,this.#Be=void 0,renderTextSection(),this.#U=!0,this.#it(l),this.#Q=``,this.#qt(),this.#Sn());let finalize=t=>{this.#Be=void 0,this.#an({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#U=!1,this.#Zt(),this.#Q=STATUS.processing,this.#Jt(),this.#zt(),this.#Sn();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#Be=void 0,this.#an({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Dismissed.`)}`,preformatted:!0,live:!1}),this.#U=!1,this.#Q=``,this.#Jt(),this.#zt(),this.#Sn(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#Sn())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,r)=>{this.#Z=r,u=t,this.#ge=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#Yt(),s===`text`&&this.#it(l),this.#Sn();return}this.#ie=!0,this.#Be=void 0,this.#Jt(),this.#Lt(),r(interruptedError());return}if(t.type===`ctrl-r`){this.#Sn();return}if(s===`overlay`){let r=setupSelectionIntent(t,{textNavigation:!isOnFreeformRow()});if(r?.kind===`move`){moveCursor(r.direction===`up`?-1:1);return}switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#Yt(),this.#Sn();break}dismiss();break;default:if(isOnFreeformRow()){let e=applyLineEditorKey(l,t);e!==void 0&&(l=e,this.#Yt(),this.#Sn());break}if(t.type===`text`&&/^[1-9]$/u.test(t.value)){let e=Number(t.value)-1;e<n.length?selectOptionAt(e):e===n.length&&i&&(c=e,syncFreeformCaret(),this.#Sn())}}return}let a=applyLineEditorKey(l,t,{multiline:!0});if(a!==void 0){l=a,this.#Yt(),this.#it(l),this.#Sn();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#Yt(),this.#it(l),this.#Sn());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.#Yt(),this.#it(l),this.#Sn();break}dismiss()}},this.#Rt()})}upsertSubagentStep(e){if(this.#f?.recordSubagentDispatch(e.callId),this.#c===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(t.length!==0||n.length!==0){if(this.#in(e.callId,e.subagentName),this.#c===`collapsed`){this.#Sn();return}this.#on({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,subagentCallId:e.callId,depth:1,reasoning:t,body:n,collapsed:this.#c!==`full`,live:!e.finalized}),this.#Sn()}}upsertSubagentTool(e){if(this.#f?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#f?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#c===`hidden`)return;if(this.#in(e.callId,e.subagentName),this.#c===`collapsed`){this.#Sn();return}let t=subagentToolStatus(e.status),n=e.status===`preparing`?presentPreparingTool(e.toolName):presentTool(e.toolName,e.input,this.#mn({input:e.input,output:e.output,toolCallId:e.childCallId,toolName:e.toolName})),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,subagentCallId:e.callId,depth:1,title:stripTerminalControls(n.title),subtitle:stripTerminalControls(n.subtitle),status:t,live:t===`running`||t===`approval`,expanded:this.#c===`full`,toolName:e.toolName,toolGroup:n.group,toolInput:e.input};n.doneTitle!==void 0&&(r.doneTitle=stripTerminalControls(n.doneTitle)),n.detail!==void 0&&(r.detailLines=n.detail,r.keepDetailWhenDone=n.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=n.summarizeResult(e.output),r.toolOutput=e.output),this.#on(r),this.#at(e.callId),this.#Sn()}#at(e){applyCohortLiveness(this.#h.filter(t=>t.kind===`subagent-tool`&&t.subagentCallId===e).map(e=>({block:e,active:isActiveToolStatus(e.status)})))}removeSubagentTool(e){this.#sn(subagentToolSectionId(e.callId,e.childCallId)),this.#Sn()}subagents={begin:e=>this.beginSubagent(e),background:e=>this.backgroundSubagent(e),upsertStep:e=>this.upsertSubagentStep(e),upsertTool:e=>this.upsertSubagentTool(e),removeTool:e=>this.removeSubagentTool(e),complete:e=>this.completeSubagent(e),markChildToolCallId:e=>this.markChildToolCallId(e)};beginSubagent(e){if(this.#c===`hidden`)return;this.#in(e.callId,e.name);let t=this.#g.get(subagentHeaderId(e.callId));t!==void 0&&(t.status===`done`&&delete t.status,t.live=!0),this.#w.delete(e.callId),this.#Sn()}backgroundSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t===void 0||this.#_.has(subagentHeaderId(e.callId)))return;t.status=`running`,t.live=!0,t.updateSeq=++this.#x;let n=this.#C.has(e.callId);this.#C.add(e.callId),n||this.#cn(e.callId),this.#Sn()}completeSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t!==void 0){if(t.status=`done`,e.authoritative){this.#C.delete(e.callId),this.#w.delete(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!1)}else{this.#w.add(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!0)}this.#Sn()}}markChildToolCallId(e){this.#y.add(e);let t=this.#b.get(e);t!==void 0&&(this.#sn(t),this.#b.delete(e),this.#Sn())}#ot(e){let t=this.#g.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#l===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#an({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e,t),preformatted:!0,live:t===void 0}),this.#Sn()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#L)return;let n=this.#L>0;this.#L=t,t>0?(this.#Q=STATUS.connectionAuth,this.#Sn()):n&&(this.#Q=STATUS.processing,this.#Sn())}setVercelStatus(e){this.#R=e,this.#Sn()}setRemoteConnectionStatus(e){this.#z=e,this.#Sn()}reset(){this.#h=[],this.#g.clear(),this.#_.clear(),this.#I=void 0,this.#F.length=0,this.#v.length=0,this.#N=!1,this.#P=void 0,this.#st(),this.#K=!1,this.#ze=void 0,this.#Pe=void 0,this.#L=0,this.#we=void 0,this.#Te=void 0,this.#De=void 0,this.#Oe=void 0,this.#ke=void 0,this.#te&&(this.#n.clearAll(),this.#Sn())}renderSessionBoundary(){this.#tn(),this.#st();let e=this.#i.colors,t=this.#i.glyph,n=e.dim(`${t.cornerOpen}${t.dash.repeat(2)} Session restarted, clear context.`);this.#$t({kind:`session-boundary`,body:n,live:!1}),this.#Sn()}#st(){this.#y.clear(),this.#b.clear(),this.#E.clear(),this.#C.clear(),this.#w.clear(),this.#S.clear(),this.#Ue=void 0,this.#We=void 0,this.#Ge.reset(),this.#Xe=void 0,this.#T.clear(),this.#q.reset()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Ft(),this.#$t({kind:`notice`,body:t,live:!1}),this.#Sn())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#f?.append({source:`sandbox`,detail:t}),this.#Ft(),this.#$t({kind:`sandbox`,body:t,live:!1}),this.#Sn())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#ct();return}this.#Ft(),this.#He=t,this.#Sn()}clearSetupWarning(){this.#ct()}#ct(){this.#He!==void 0&&(this.#He=void 0,this.#Sn())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#Ft();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#$t(r),this.#Sn()}renderCommandResult(e,t){let n=stripAnsi(e);n.trim().length!==0&&(this.#Ft(),this.#$t({kind:`result`,body:n,live:!1,status:t===`success`?`done`:void 0}),this.#Sn())}#lt(e,t=`spinner`){this.#Ft(),this.#k===void 0&&(this.#U=!1),this.#X={kind:`idle`},this.#Q=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#Ve={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#Xt(),this.#Sn()}#ut(e){this.#Ve!==void 0&&(this.#Ve.navigation=e,this.#Sn())}#dt(e){this.#$e=void 0,this.#Tt();let t=this.#Ve;if(t!==void 0){if(this.#Ve=void 0,this.#k===void 0?this.#Qt():this.#rt(),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.#$t({kind:`flow`,title:`info`,body:e.join(`
|
|
5
5
|
`),live:!1}),this.#$t({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#Sn()}}async#ft(e){let t=this.#yt(e.message),n=isMultiSelectRequest(e),r=e.kind===`search`?e.searchAction:void 0,i=e.options,a=e.navigation?.kind===`planner`,o={options:i,searchAction:r,submitRow:n&&!a};`initialValue`in e&&e.initialValue!==void 0&&(o.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(o.initialValues=e.initialValues);let s=initialSelectState(o),c,l=!1,u=0,isCurrentSearch=e=>e===u,clearSearch=()=>{u+=1,l=!1,s=reduceSelect(s,{type:`clear`},{options:i,searchAction:r,submitRow:n&&!a}),this.#Sn()},loadSearch=async(e,t)=>{l=!0,c=void 0;let o=++u;this.#Sn();try{let c=await t(e);if(!isCurrentSearch(o))return;let l=s.filter;i=c,s={...initialSelectState({options:c,searchAction:r,submitRow:n&&!a}),filter:l}}catch(e){isCurrentSearch(o)&&(c=toErrorMessage(e))}finally{isCurrentSearch(o)&&(l=!1,this.#Sn())}},d=e.notices;if(e.kind===`task-list`||e.kind===`search`&&e.layout===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));d=e.notices??r,t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,message:``,options:i,select:s};return d!==void 0&&d.length>0&&(t.notices=d),c!==void 0&&(t.error=c),l&&(t.loadingFrame=this.#kn()),t};return t.question=e=>renderSelectQuestion(panelState(),this.#i,e),this.#Sn(),await this.#St((t,o)=>{let close=e=>{u+=1,o(e)};if(l){t.type===`ctrl-c`?close(void 0):t.type===`escape`?clearSearch():t.type===`ctrl-r`&&this.#Sn();return}let d=e.navigation?.kind===`planner`?e.navigation:void 0,f=t.type===`left`&&(d?.activeStep??0)>(d?.firstNavigableStep??0)?`back`:t.type===`right`&&d!==void 0&&d.activeStep>=(d.firstNavigableStep??0)&&d.activeStep<d.steps.length-1?`forward`:void 0;if(f!==void 0){close({kind:`navigate`,direction:f,values:n?orderedSelection(i,s.selected):[]});return}let p={key:t,options:i,searchAction:r,select:s},m=reduceSetupSelectInput(n?{...p,kind:e.kind,required:e.required,plannerNavigation:a||void 0}:{...p,kind:e.kind});switch(m.kind){case`cancel`:close(void 0);return;case`repaint`:this.#Sn();return;case`update`:s=m.select,c=void 0,this.#Sn();return;case`submit`:{let e=searchActionQuery(m.values[0]??``),t=r?.load;if(e===void 0||t===void 0){close(m.values);return}loadSearch(e,t);return}case`error`:c=m.message,this.#Sn();return;case`ignore`:return}}).promise}#pt(e){this.#Ft();let t=this.#bt();t.status={kind:`progress`,text:stripTerminalControls(e.status),startedAtMs:Date.now()};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#i,t),this.#Sn();let r=this.#St((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.#Sn();return;case`repaint`:this.#Sn();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#mt(e){let t=this.#yt(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.#le,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.#qt():(i=lineOf(``),this.#Jt())};return syncEditableRow(),this.#Sn(),await this.#St((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#Yt(),this.#Sn()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#Sn()},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.#Sn();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.#Sn();return;case void 0:}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Jt()).promise}async#ht(e){let t=this.#yt(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.#le,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.#qt():this.#Jt()};return syncCaret(),this.#Sn(),await this.#St((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.#Sn();return;case`cancel`:i(void 0);return;case`render`:n=o.state,syncCaret(),this.#Sn();return;case`validate`:{n=o.state,syncCaret(),this.#Sn();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.#Sn();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.#Yt(),dispatch({type:`edit`,editor:s}))},()=>{r?.abort(),r=void 0,this.#Jt()}).promise}async#gt(e){let t=this.#yt(`Select the model`),n=initialModelEditorState(e);return t.question=t=>renderModelEditorQuestion({request:e,state:n},this.#i,t,``),this.#Sn(),await this.#St((t,r)=>{let dispatch=t=>{let i=transitionModelEditor(n,t,e);switch(i.kind){case`ignore`:return;case`render`:n=i.state,this.#Sn();return;case`cancel`:r(void 0);return;case`settle`:r(i.result);return}},i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:i.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#Sn();return;case void 0:}if(t.type===`left`||t.type===`right`){dispatch({type:`adjust`,direction:t.type});return}if(t.type===`tab`){dispatch({type:`adjust`,direction:`right`});return}if(t.type===`backspace`){dispatch({type:`backspace`});return}if(t.type===`text`)for(let e of t.value.replaceAll(`
|
|
6
6
|
`,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#_t(e){let t=this.#yt(e.message),n=lineOf(``),r;return t.question=t=>{let i={message:``,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#le)},this.#qt(),this.#Sn(),await this.#St((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Yt(),this.#Sn()},a=applyLineEditorKey(n,t);if(a!==void 0){apply(a);return}switch(t.type){case`ctrl-c`:case`escape`:i(void 0);return;case`ctrl-r`:this.#Sn();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#Sn();return}i(t);return}default:return}},()=>this.#Jt()).promise}async#vt(e){let t=this.#yt(e.message);return t.question=t=>renderAcknowledgeQuestion({message:``,lines:e.lines},this.#i,t),this.#Sn(),await this.#St((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#Sn();return;default:return}}).promise}#yt(e){this.#Ft(),this.#U=!1,this.#X={kind:`idle`},this.#Q=``;let t=this.#bt();return t.questionTitle=stripTerminalControls(e),t.status!==void 0&&(t.status=void 0,t.summary=void 0,t.preview=void 0),t}#bt(){return this.#Ve===void 0&&(this.#Ve={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#Ve}#xt(){this.#Ve?.implicit===!0?this.#Ve=void 0:this.#Ve!==void 0&&(this.#Ve.question=void 0,this.#Ve.questionTitle=void 0,this.#Ve.hideLinesWhileQuestion=!1),this.#ge=void 0,this.#zt(),this.#k===void 0?this.#Ve!==void 0&&this.#wt():this.#rt(),this.#Ve===void 0&&this.#Sn()}#St(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#xt(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#xt(),i(e))};return this.#Wt(),this.#ge=t=>{t.type===`ctrl-c`&&this.#jt(),e(t,settle,reject)},this.#Rt(),{promise:a,settle}}#Ct(e){let t,n=new Promise(e=>{t=e});return this.#$e=t,this.#wt(e?.interruptible??!0),{promise:n,dispose:()=>{this.#$e===t&&(this.#$e=void 0,this.#Tt())}}}#wt(e=!0){if(this.#k!==void 0){this.#rt();return}if(this.#$e===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#jt();let e=this.#$e;this.#$e=void 0,this.#Tt(),e?.(t.type===`ctrl-c`?`ctrl-c`:`escape`);return}t.type===`ctrl-r`&&this.#Sn()};this.#et=consumer,this.#Wt(),this.#ge=consumer,this.#Rt()}#Tt(){this.#et!==void 0&&(this.#ge===this.#et&&this.#zt(),this.#et=void 0)}#Et(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#Ve!==void 0){this.#Ve.status=t,t===void 0&&(this.#Ve.preview=void 0),this.#Sn();return}if(!(this.#U||this.#Y)){if(t===void 0){this.#X={kind:`idle`},this.#$=void 0,this.#Qt(),this.#Sn();return}this.#Ft(),this.#Zt(),this.#$=t.text,this.#Sn()}}#Dt(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Ve;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#Sn();return}this.#Ft(),this.#$t({kind:`flow`,title:t,body:n,live:!1}),this.#Sn()}#Ot(e){let t=this.#Ve;t!==void 0&&(t.lines=[],t.outputBuffer=[],t.preview=void 0,t.status=void 0,t.summary=e===void 0?void 0:{headline:stripTerminalControls(e.headline),facts:e.facts.map(e=>({label:stripTerminalControls(e.label),value:stripTerminalControls(e.value)}))},this.#Sn())}#kt(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Ve;if(n===void 0){this.#Dt(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#Sn()}async#At(e){this.#_e=``,this.#Wt(),this.#$e=void 0,this.#Tt(),this.#zt(),this.#Qt(),this.#n.clear(),this.#Wn(),this.#r.enter({cursor:`visible`,mouse:!1}),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#r.exit(),this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#_e=``,this.#Wt(),this.#n.hideCursor(),this.#Un(),this.#Ve!==void 0&&(this.#Xt(),this.#wt()),this.#n.reset(),this.#Sn()}}setSessionId(e){this.#Ye=e}shutdown(){if(this.#Lt(),this.#ne&&!this.#re){this.#re=!0;let e=this.#Ye===void 0?``:` ${this.#i.glyph.dot} session ${this.#Ye}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}suspendPromptForInput(){this.#J={cursor:this.#V,text:this.#B},this.#Lt()}requestInterrupt(){this.#ie=!0,this.#Ve!==void 0&&this.#ge?.({type:`ctrl-c`}),this.#xe?.(),this.#Lt()}exitRequested(){return this.#ae}#jt(){this.#ae=!0,this.#ce?.()}async#Mt(e){if(this.#tt!==void 0||!this.#te)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Vn(),height:this.#Hn()}),paint:e=>this.#r.paint(e,this.#Hn()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#nt});this.#tt=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#Pt=e,this.#ge=e=>{t.handleKey(e)===`close`&&this.#Nt()},this.#Rt(),t.start()})}#Nt(){let e=this.#tt;if(e===void 0)return;this.#tt=void 0,e.dispose(),this.#zt(),this.#r.exit(),this.#n.hideCursor(),this.#Sn(),this.#n.showCursor();let t=this.#Pt;this.#Pt=void 0,t?.()}#Pt;#Ft(e){this.#ee=e?.title??this.#ee,e?.contextSize!==void 0&&(this.#Ee=e.contextSize),!this.#te&&(this.#te=!0,this.#ne=!0,this.#n.reset(),this.#n.hideCursor(),this.#Un(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#be=()=>this.#Sn(),this.#t.on(`resize`,this.#be),process.on(`exit`,this.#It))}#It=()=>{this.#te&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#Lt(){this.#Nt();let e=this.#Z;if(this.#Z=void 0,e?.(interruptedError()),this.#zt(),this.#Jt(),this.#Qt(),this.#me!==void 0&&(clearTimeout(this.#me),this.#me=void 0),this.#he=!1,this.#Qn(),this.#te){this.#er();for(let e of this.#h)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#Sn(),this.#n.clear(),this.#n.showCursor(),this.#Wn(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#be&&=(this.#t.off(`resize`,this.#be),void 0),process.off(`exit`,this.#It),this.#te=!1}}#Rt(){this.#e.off(`data`,this.#Bt),this.#e.on(`data`,this.#Bt),this.#_e.length>0&&queueMicrotask(()=>{this.#ge!==void 0&&this.#_e.length>0&&(this.#Ht(),this.#Vt())})}#zt(){this.#e.off(`data`,this.#Bt),this.#Wt(),this.#ge=void 0}#Bt=e=>{this.#Wt(),this.#_e+=this.#ve.write(e),this.#Ht(),this.#Vt()};#Vt(){if(this.#_e===`\x1B`){this.#ye=setTimeout(()=>{this.#_e===`\x1B`&&(this.#_e=``,this.#ge?.({type:`escape`}))},30),this.#ye.unref?.();return}if(isIncompletePaste(this.#_e)){let e=this.#_e;this.#ye=setTimeout(()=>{if(this.#_e!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#_e=``,t.length>0&&this.#ge?.({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#ye.unref?.();return}if(isIncompleteOsc(this.#_e)){let e=this.#_e;this.#ye=setTimeout(()=>{this.#_e===e&&(this.#_e=``)},incompletePasteFlushMs),this.#ye.unref?.()}}#Ht(){for(;this.#_e.length>0;){let e=nextKey(this.#_e);if(e.incomplete)return;if(this.#_e=this.#_e.slice(e.consumed),e.key!==void 0&&e.key.type!==`ignore`){if(e.key.type===`osc`){this.#Ut(e.key.value);continue}this.#ge?.(e.key)}}}#Ut(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#nt=t,this.#tt?.setTerminalBackground(t))}#Wt(){this.#ye&&=(clearTimeout(this.#ye),void 0)}#Gt(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#Sn();break;case`enter`:{let e=this.#J.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#Ke!==void 0){this.#J=EMPTY_LINE,this.#Ge.requestCancellation(),this.#Ze=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#Ke(),this.#Sn();break}let t=this.#qe;t!==void 0&&parsePromptCommand(e)===null?(this.#J=EMPTY_LINE,this.#Kt(e,t)):this.#Ge.enqueue(e)&&(this.#J=EMPTY_LINE),this.#Sn();break}case`ctrl-c`:case`escape`:if(e.type===`ctrl-c`&&this.#Ge.view().cancelling){this.#ie=!0,this.#se=!0,this.#X={kind:`idle`},this.#Q=`Interrupted`,this.#xe?.(),this.#Sn();break}if(this.#Ge.idle&&this.#Ke===void 0)break;if(this.#Ge.handleEscape()===`steer`){let e=this.#qe;if(e!==void 0){let t=this.#Ge.takeSteering();this.#Kt(t,e)}}else this.#Ze=!0,this.#Ke?.();this.#Sn();break;default:{let t=applyLineEditorKey(this.#J,e,{multiline:!0});t!==void 0&&(this.#J=t,this.#Sn());break}}}#Kt(e,t){this.#Xe=`steer`,this.#nn(e),t(e).catch(t=>{this.#Ge.restoreSteering(e),this.#rn(`Steering failed`,toErrorMessage(t)),this.#Sn()})}#qt(){this.#Jt(),this.#Yt(),this.#fe=setInterval(()=>{this.#le=!this.#le,this.#Sn()},500),this.#fe.unref?.()}#Jt(){this.#fe&&=(clearInterval(this.#fe),void 0),this.#le=!0}#Yt(){this.#le=!0}#Xt(){this.#Qt(),this.#pe=setInterval(()=>{this.#ue+=1,this.#Sn()},90),this.#pe.unref?.()}#Zt(){let e=Date.now();this.#de=e,this.#X={kind:`waiting`,startedAtMs:e},this.#Xt()}#Qt(){this.#pe&&=(clearInterval(this.#pe),void 0)}#$t(e){e.id!==this.#Pe?.id&&this.#er(),e.updateSeq=++this.#x;let t=e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId)?-1:this.#h.findIndex(e=>e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId));t<0?this.#h.push(e):this.#h.splice(t,0,e),e.id&&this.#g.set(e.id,e)}#en(e){this.#K=!0,this.#$t({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#Sn()}#tn(){let e=this.#q.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#Pn(e.elapsedMs)}`,n=this.#Te??0;if(this.#Ee!==void 0&&this.#Ee>0&&n>0){let e=Math.round(n/this.#Ee*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#$t({kind:`turn-stats`,body:t,live:!1})}#nn(e){if(e==null)return;let t=this.#Xe;if(this.#Xe=void 0,this.#ze===e){this.#ze=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#$t(n)}#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.#$t(c),this.#Sn()}#in(e,t){if(this.#E.has(e))return;this.#E.add(e);let n=stripTerminalControls(t),r=this.#S.get(n)??[];if(r.push(e),this.#S.set(n,r),r.length===2){let e=this.#g.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#$t(i)}#an(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#x;return}this.#$t(e)}#on(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t!==void 0){Object.assign(t,e),t.updateSeq=++this.#x;return}let n=e.subagentCallId;if(n===void 0){this.#$t(e);return}e.id!==this.#Pe?.id&&this.#er(),e.updateSeq=++this.#x;let r=-1;for(let e=0;e<this.#h.length;e+=1)this.#h[e]?.subagentCallId===n&&(r=e);this.#h.splice(r<0?this.#h.length:r+1,0,e),e.id!==void 0&&this.#g.set(e.id,e)}#sn(e){this.#h=this.#h.filter(t=>t.id!==e),this.#g.delete(e)}#cn(e){let t=this.#h.filter(t=>t.subagentCallId===e);t.length!==0&&(this.#h=this.#h.filter(t=>t.subagentCallId!==e),this.#h.push(...t))}#ln(){for(let e of this.#h)e.subagentCallId!==void 0&&this.#w.has(e.subagentCallId)||e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#un(e,t,n){switch(e.type){case`step-finish`:this.#f?.recordStepUsage(e.usage),e.usage!==void 0&&this.#q.addUsage(e.usage),this.#_n(n),this.#xn(e.usage),this.#Sn();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#dn(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=typeof e.text==`string`?stripTerminalControls(e.text):t;n.text.set(e.id,r),this.#dn(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#fn(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#fn(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#pn({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#f?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#pn({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#pn({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#bn(e.toolCallId,n);if(r===void 0)break;this.#pn({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#bn(e.toolCallId,n);if(this.#f?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#pn({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#bn(e.toolCallId,n);if(r===void 0)break;this.#pn({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#rn(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:if(n.cancelled=!0,!n.restoreCancelledPrompt)break;this.#Je=!0,!this.#Ze&&this.#Qe!==void 0&&this.#J.text.length===0&&(this.#J=lineOf(this.#Qe),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#xn(e.usage),this.#Sn()}}#dn(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#an({id:e,kind:`assistant`,body:r,live:n}),this.#Sn())}#fn(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#an({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#Sn())}#pn(e,t,n){if(n.tools.set(e.toolCallId,e),this.#y.has(e.toolCallId)||this.#vn(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#b.set(e.toolCallId,r);let i=this.#mn(e);this.#an(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#yn(n),this.#Sn()}#mn(e){e.output!==void 0&&this.#T.observeRead(e.output);let t={};this.#hn(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#T.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#hn(e){let t=this.#D?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#gn(e){for(let t of e.tools.keys()){if(this.#y.has(t))continue;let e=this.#b.get(t)??toolSectionId(t),n=this.#g.get(e);n?.kind===`tool`&&n.status===`running`&&(n.status=`error`,n.result=`interrupted`,n.live=!1)}}#_n(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#b.get(t)??toolSectionId(t);this.#sn(r),this.#b.delete(t)}}#vn(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#We!==e&&(this.#We=e,this.#$t({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#Vn(),this.#i).join(`
|
|
7
|
-
`),live:!1})),this.#Ue=void 0}else this.#Ue=t.length>0?t:void 0,this.#We=void 0;return this.#Sn(),!0}#yn(e){let t=[];for(let n of e.tools.values()){if(this.#y.has(n.toolCallId))continue;let e=this.#b.get(n.toolCallId)??toolSectionId(n.toolCallId),r=this.#g.get(e);r?.kind===`tool`&&t.push({block:r,active:isActiveToolStatus(n.status)})}applyCohortLiveness(t)}#bn(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#b.get(e)??toolSectionId(e),i=this.#g.get(r);if(i!==void 0&&i.kind===`tool`)return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.toolName??i.title??`tool`}}#xn(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#we=(t??0)+(n??0)),this.#Te=t??this.#Te,this.#De=n??this.#De,this.#De!=null&&this.#ke!==void 0){let e=(Date.now()-this.#ke)/1e3;e>0&&(this.#Oe=this.#De/e)}}#Sn(){if(this.#te){if(this.#Se){this.#Ce=!0;return}this.#Se=!0;try{do this.#Ce=!1,this.#Cn();while(this.#Ce)}finally{this.#Se=!1}}}#Cn(){if(!this.#te)return;if(this.#tt!==void 0){this.#tt.repaint();return}let e=this.#Vn(),t=this.#Mn(e),n=this.#M===void 0?[]:this.#Dn(),r=Math.max(1,this.#Hn()-n.length-t.length),i=[],a=this.#I,o=groupToolBlocksForDisplay(this.#h),s=0;for(;s<o.length&&o[s].display.live===!1;)s+=1;if(s>0){let e=new Set(o.slice(0,s).flatMap(e=>e.members));for(let t=this.#h.length-1;t>=0;--t)e.has(this.#h[t])&&this.#h.splice(t,1)}for(let t of o.slice(0,s)){for(let e of t.members)this.#v.push(e),e.id&&(this.#_.add(e.id),this.#g.delete(e.id));if(this.#nr(t.display))continue;let n=this.#On(t.display,e,a);a=previousBlockOf(t.display),this.#I=a,i.push(...n),this.#F.push(...n)}let c=[];for(let{display:t}of o.slice(s)){if(this.#nr(t))continue;let n=this.#On(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)}#wn(){if(!this.#te)return;let e=this.#Vn(),t=this.#Mn(e),n=Math.max(1,this.#Hn()-t.length),r=this.#I,i=[];for(let{display:t}of groupToolBlocksForDisplay(this.#h)){if(this.#nr(t))continue;let n=this.#On(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.#F],a)}logDisplayMode(){return this.#m}setLogDisplayMode(e){e!==this.#m&&(this.#m=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#En(),this.#te&&this.#wn())}flushDelayedDevBuildErrors(){let e=this.#Ne;e!==void 0&&(this.#Ne=void 0,this.#$t({kind:`log`,title:`stderr`,body:e,live:!0}),this.#Sn())}#Tn(){this.#he=!0,this.#me!==void 0&&clearTimeout(this.#me),this.#me=setTimeout(()=>{this.#he=!1,this.#me=void 0,this.#Sn()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#m)),this.#Sn()}#En(){let e=this.#Vn();this.#F.length=0;let t;for(let{display:n}of groupToolBlocksForDisplay(this.#v,{logCoalescing:`runs`})){if(this.#nr(n))continue;let r=this.#On(n,e,t);t=previousBlockOf(n),this.#F.push(...r)}this.#I=t}#Dn(){let e=this.#D,t=this.#M;if(e===void 0&&t===void 0)return[];let n={name:e?.name??t?.name,theme:this.#i,width:this.#Vn()};e?.info!==void 0&&(n.info=e.info);let r=e?.tip??t?.tip;return r!==void 0&&(n.tip=r),buildAgentHeader(n)}#On(e,t,n){let r={renderMarkdown:this.#a,activityPulse:this.#An(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#i,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#kn(){return this.#i.spinner[this.#ue%this.#i.spinner.length]??``}#An(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#jn(e,t){return e.indicator.kind===`spinner`?{glyph:this.#kn(),color:`yellow`}:{glyph:this.#An(e.indicator.startedAtMs,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#Mn(e){let t=this.#i.colors,n=[``];if(this.#Be!==void 0)return n.push(...this.#Be(e),``),this.#Rn(n,e),n;let r=this.#Ve;if(r!==void 0&&(this.#k===void 0||r.question!==void 0)){let t=this.#jn(r,r.status),i;if(r.status!==void 0){let{startedAtMs:e,...n}=r.status,a=Date.now()-e,o=a>=5e3?` ${formatTurnDuration(a)}`:``;i={...n,text:`${n.text}${o}`,indicator:t}}let a;if(r.question!==void 0){let t=r.question(e);a={kind:`question`,title:r.questionTitle,rows:t},i!==void 0&&(a={kind:`question`,title:r.questionTitle,rows:t,status:i})}else i===void 0?a=r.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:r.preview,indicator:t}:(a={kind:`status`,status:i},r.preview!==void 0&&(a={kind:`status`,status:i,preview:r.preview}));let o={title:r.title,navigation:r.navigation,lines:r.summary===void 0?r.hideLinesWhileQuestion===!0?[]:r.lines:[{text:r.summary.headline,tone:`success`},...r.summary.facts.map(e=>({text:`${e.label}: ${e.value}`,tone:`info`}))],content:a};return n.push(...renderFlowPanel(o,this.#i,e)),this.#zn(n,e),n}r!==void 0&&n.push(...flowMessageRows(r.lines,this.#i).map(t=>t.length===0?``:clip(` ${t}`,e))),this.#O===void 0&&this.#He!==void 0&&n.push(...renderAttentionRows(this.#He,e,this.#i),``),this.#Ue!==void 0&&n.push(...renderTodoPanelRows({items:this.#Ue,width:e,theme:this.#i,working:this.#Y||this.#X.kind===`waiting`,pulse:this.#An(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)}),``);let i=renderMessageQueueRows({view:this.#Ge.view(),width:e,theme:this.#i,working:this.#Y});if(i.length>0&&n.push(...i,``),this.#U){let r=this.#W===void 0?void 0:inlineCommandHint(this.#W);r===void 0&&this.#W!==void 0&&isTypeaheadOpen(this.#W)&&n.push(...renderCommandSuggestions(this.#W,this.#i,e)),this.#oe&&n.push(clip(t.dim(`Press Ctrl+C again to exit`),e),``);let i=isPromptControlCommand(this.#B),a=r?t.dim(` ${r}`):``,o=[];this.#Rn(o,e);let s=Math.max(1,this.#Hn()-1-n.length-1-o.length),c={text:this.#B,cursor:this.#V,width:e,theme:this.#i,caretVisible:this.#le,isCommand:i,ghost:a,maxRows:s};return this.#G&&this.#B.length===0&&(c.placeholder=this.#k===void 0?this.#K?``:`Send a message…`:`Message · Enter to queue`),n.push(...promptInputRows(c)),n.push(...o),n}let a=this.#X.kind===`waiting`&&this.#$===void 0;if(this.#Y||a){n.push(this.#Nn(e)),this.#In(n,e);let t=[];return this.#Rn(t,e),!this.#Y&&t.length>0&&n.push(``),n.push(...t),n}if(this.#J.text.length>0)return this.#Ln(n,e,{inert:!1}),this.#Rn(n,e),n;let o=this.#$??(this.#Q.length>0?this.#Q:`Ready`),s=this.#Bn(),c=t.dim(this.#i.glyph.dot),l=s?`${c} ${o} ${t.dim(this.#i.glyph.dot)} ${s}`:`${c} ${o}`;return n.push(clip(l,e)),this.#Rn(n,e),n}#Nn(e){let t=this.#i.colors,n=this.#An(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),r=this.#X,i=this.#q.startedAtMs??this.#ke??(r.kind===`waiting`?r.startedAtMs:Date.now()),a=Date.now()-i,o=`${typewriterText(`Working for`,a,80)} ${this.#Pn(a)}`;return clip(`${t.yellow(n)} ${t.dim(o)}`,e)}#Pn(e){return`${formatTurnDuration(e)}${this.#Fn()}`}#Fn(){let{inputTokens:e,outputTokens:t}=this.#q.usage;return e===0&&t===0?``:` ${this.#i.glyph.dash.repeat(2)} ${formatTokenFlow({inputTokens:e,outputTokens:t},this.#i.glyph)}`}#In(e,t){this.#Y&&this.#Ln(e,t,{inert:!0})}#Ln(e,t,n){e.push(``);let r={text:this.#J.text,cursor:this.#J.cursor,width:t,theme:this.#i,caretVisible:!0,isCommand:!1,ghost:``,maxRows:4,inert:n.inert};n.inert&&this.#J.text.length===0&&(r.placeholder=``),e.push(...promptInputRows(r))}#Rn(e,t){if(this.#O!==void 0){let n=this.#Ve?.status?.text??{starting:`Starting agent…`,connecting:`Reading saved connection…`,updating:`Loading selected model…`}[this.#O],r=this.#An(this.#j,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH);e.push(clip(this.#i.colors.dim(`${r} ${n}`),t));return}let n=this.#z===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#i,width:r};this.#Ie&&this.#Fe!==void 0&&(i.devBuild=this.#Fe),this.#he&&(i.logLevel=this.#m);let a=this.#D?.info?.agent.model;a?.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))}#zn(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))}#Bn(){let e=this.#i.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#we,outputTokens:this.#De,tokensPerSecond:this.#Oe},this.#u);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#i.glyph.dot} `)):``}#Vn(){return Math.max(20,this.#t.columns||80)}#Hn(){return Math.max(8,this.#t.rows||24)}#Un(){if(this.#Ae!==void 0||!this.#d)return;this.#je=``,this.#Me=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#Kn(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#f?.subscribeLogRecords(e=>this.#Gn(e)),this.#Ae=()=>{this.#f?.unsubscribeLogRecords(),e(),t()}}#Wn(){let e=this.#Ae;e!==void 0&&(this.#Ae=void 0,e(),this.#je.length>0&&(this.#f?.append({source:`stdout`,detail:this.#je}),this.#tr(`stdout`)&&process.stdout.write(`${this.#je}\n`),this.#je=``),this.#Me.length>0&&(this.#f?.append({source:`stderr`,detail:this.#Me}),this.#tr(`stderr`)&&process.stderr.write(`${this.#Me}\n`),this.#Me=``))}#Gn(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#Jn(`[eve:${e.namespace}] ${e.message}${t}`),this.#Sn()}#Kn(e,t){let n=(e===`stdout`?this.#je:this.#Me)+t;if(e===`stdout`&&parseDevRebuildLogLine(n.trimEnd())!==void 0){this.#je=``,this.#f?.append({source:e,detail:n.trimEnd()}),this.#qn(n.trimEnd()),this.#Sn();return}let r=n.lastIndexOf(`
|
|
7
|
+
`),live:!1})),this.#Ue=void 0}else this.#Ue=t.length>0?t:void 0,this.#We=void 0;return this.#Sn(),!0}#yn(e){let t=[];for(let n of e.tools.values()){if(this.#y.has(n.toolCallId))continue;let e=this.#b.get(n.toolCallId)??toolSectionId(n.toolCallId),r=this.#g.get(e);r?.kind===`tool`&&t.push({block:r,active:isActiveToolStatus(n.status)})}applyCohortLiveness(t)}#bn(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#b.get(e)??toolSectionId(e),i=this.#g.get(r);if(i!==void 0&&i.kind===`tool`)return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.toolName??i.title??`tool`}}#xn(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#we=(t??0)+(n??0)),this.#Te=t??this.#Te,this.#De=n??this.#De,this.#De!=null&&this.#ke!==void 0){let e=(Date.now()-this.#ke)/1e3;e>0&&(this.#Oe=this.#De/e)}}#Sn(){if(this.#te){if(this.#Se){this.#Ce=!0;return}this.#Se=!0;try{do this.#Ce=!1,this.#Cn();while(this.#Ce)}finally{this.#Se=!1}}}#Cn(){if(!this.#te)return;if(this.#tt!==void 0){this.#tt.repaint();return}let e=this.#Vn(),t=this.#Mn(e),n=this.#M===void 0?[]:this.#Dn(),r=Math.max(1,this.#Hn()-n.length-t.length),i=[],a=this.#I,o=groupToolBlocksForDisplay(this.#h),s=0;for(;s<o.length&&o[s].display.live===!1;)s+=1;if(s>0){let e=new Set(o.slice(0,s).flatMap(e=>e.members));for(let t=this.#h.length-1;t>=0;--t)e.has(this.#h[t])&&this.#h.splice(t,1)}for(let t of o.slice(0,s)){for(let e of t.members)this.#v.push(e),e.id&&(this.#_.add(e.id),this.#g.delete(e.id));if(this.#nr(t.display))continue;let n=this.#On(t.display,e,a);a=previousBlockOf(t.display),this.#I=a,i.push(...n),this.#F.push(...n)}let c=[];for(let{display:t}of o.slice(s)){if(this.#nr(t))continue;let n=this.#On(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)}#wn(){if(!this.#te)return;let e=this.#Vn(),t=this.#Mn(e),n=Math.max(1,this.#Hn()-t.length),r=this.#I,i=[];for(let{display:t}of groupToolBlocksForDisplay(this.#h)){if(this.#nr(t))continue;let n=this.#On(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.#F],a)}logDisplayMode(){return this.#m}setLogDisplayMode(e){e!==this.#m&&(this.#m=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#En(),this.#te&&this.#wn())}flushDelayedDevBuildErrors(){let e=this.#Ne;e!==void 0&&(this.#Ne=void 0,this.#$t({kind:`log`,title:`stderr`,body:e,live:!0}),this.#Sn())}#Tn(){this.#he=!0,this.#me!==void 0&&clearTimeout(this.#me),this.#me=setTimeout(()=>{this.#he=!1,this.#me=void 0,this.#Sn()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#m)),this.#Sn()}#En(){let e=this.#Vn();this.#F.length=0;let t;for(let{display:n}of groupToolBlocksForDisplay(this.#v,{logCoalescing:`runs`})){if(this.#nr(n))continue;let r=this.#On(n,e,t);t=previousBlockOf(n),this.#F.push(...r)}this.#I=t}#Dn(){let e=this.#D,t=this.#M;if(e===void 0&&t===void 0)return[];let n={name:e?.name??t?.name,theme:this.#i,width:this.#Vn()};e?.info!==void 0&&(n.info=e.info);let r=e?.tip??t?.tip;return r!==void 0&&(n.tip=r),buildAgentHeader(n)}#On(e,t,n){let r={renderMarkdown:this.#a,activityPulse:this.#An(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#i,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#kn(){return this.#i.spinner[this.#ue%this.#i.spinner.length]??``}#An(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#jn(e,t){return e.indicator.kind===`spinner`?{glyph:this.#kn(),color:`yellow`}:{glyph:this.#An(e.indicator.startedAtMs,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#Mn(e){let t=this.#i.colors,n=[``];if(this.#Be!==void 0)return n.push(...this.#Be(e),``),this.#Rn(n,e),n;let r=this.#Ve;if(r!==void 0&&(this.#k===void 0||r.question!==void 0)){let t=this.#jn(r,r.status),i;if(r.status!==void 0){let{startedAtMs:e,...n}=r.status,a=Date.now()-e,o=a>=5e3?` ${formatTurnDuration(a)}`:``;i={...n,text:`${n.text}${o}`,indicator:t}}let a;if(r.question!==void 0){let t=r.question(e);a={kind:`question`,title:r.questionTitle,rows:t},i!==void 0&&(a={kind:`question`,title:r.questionTitle,rows:t,status:i})}else i===void 0?a=r.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:r.preview,indicator:t}:(a={kind:`status`,status:i},r.preview!==void 0&&(a={kind:`status`,status:i,preview:r.preview}));let o={title:r.title,navigation:r.navigation,lines:r.summary===void 0?r.hideLinesWhileQuestion===!0?[]:r.lines:[{text:r.summary.headline,tone:`success`},...r.summary.facts.map(e=>({text:`${e.label}: ${e.value}`,tone:`info`}))],content:a};return n.push(...renderFlowPanel(o,this.#i,e)),this.#zn(n,e),n}r!==void 0&&n.push(...flowMessageRows(r.lines,this.#i).map(t=>t.length===0?``:clip(` ${t}`,e))),this.#O===void 0&&this.#He!==void 0&&n.push(...renderAttentionRows(this.#He,e,this.#i),``),this.#Ue!==void 0&&n.push(...renderTodoPanelRows({items:this.#Ue,width:e,theme:this.#i,working:this.#Y||this.#X.kind===`waiting`,pulse:this.#An(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)}),``);let i=renderMessageQueueRows({view:this.#Ge.view(),width:e,theme:this.#i,working:this.#Y});if(i.length>0&&n.push(...i,``),this.#U){let r=this.#W===void 0?void 0:inlineCommandHint(this.#W);r===void 0&&this.#W!==void 0&&isTypeaheadOpen(this.#W)&&n.push(...renderCommandSuggestions(this.#W,this.#i,e)),this.#oe&&n.push(clip(t.dim(`Press Ctrl+C again to exit`),e),``);let i=isPromptControlCommand(this.#B),a=r?t.dim(` ${r}`):``,o=[];this.#Rn(o,e);let s=Math.max(1,this.#Hn()-1-n.length-1-o.length),c={text:this.#B,cursor:this.#V,width:e,theme:this.#i,caretVisible:this.#le,isCommand:i,ghost:a,maxRows:s};return this.#G&&this.#B.length===0&&(c.placeholder=this.#k===void 0?this.#K?``:`Send a message…`:`Message · Enter to queue`),n.push(...promptInputRows(c)),n.push(...o),n}let a=this.#X.kind===`waiting`&&this.#$===void 0;if(this.#Y||a){n.push(this.#Nn(e)),this.#In(n,e);let t=[];return this.#Rn(t,e),!this.#Y&&t.length>0&&n.push(``),n.push(...t),n}if(this.#J.text.length>0)return this.#Ln(n,e,{inert:!1}),this.#Rn(n,e),n;let o=this.#$??(this.#Q.length>0?this.#Q:`Ready`),s=this.#Bn(),c=t.dim(this.#i.glyph.dot),l=s?`${c} ${o} ${t.dim(this.#i.glyph.dot)} ${s}`:`${c} ${o}`;return n.push(clip(l,e)),this.#Rn(n,e),n}#Nn(e){let t=this.#i.colors,n=this.#An(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),r=this.#X,i=this.#q.startedAtMs??this.#ke??(r.kind===`waiting`?r.startedAtMs:Date.now()),a=Date.now()-i,o=`${typewriterText(`Working for`,a,80)} ${this.#Pn(a)}`;return clip(`${t.yellow(n)} ${t.dim(o)}`,e)}#Pn(e){return`${formatTurnDuration(e)}${this.#Fn()}`}#Fn(){let{inputTokens:e,outputTokens:t}=this.#q.usage;return e===0&&t===0?``:` ${this.#i.glyph.dash.repeat(2)} ${formatTokenFlow({inputTokens:e,outputTokens:t},this.#i.glyph)}`}#In(e,t){this.#Y&&this.#Ln(e,t,{inert:!0})}#Ln(e,t,n){e.push(``);let r={text:this.#J.text,cursor:this.#J.cursor,width:t,theme:this.#i,caretVisible:!0,isCommand:!1,ghost:``,maxRows:4,inert:n.inert};n.inert&&this.#J.text.length===0&&(r.placeholder=``),e.push(...promptInputRows(r))}#Rn(e,t){if(this.#O!==void 0){let n=this.#Ve?.status?.text??{starting:`Starting agent…`,connecting:`Reading saved connection…`,updating:`Loading selected model…`}[this.#O],r=this.#An(this.#j,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH);e.push(clip(this.#i.colors.dim(`${r} ${n}`),t));return}let n=this.#z===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#i,width:r};this.#Ie&&this.#Fe!==void 0&&(i.devBuild=this.#Fe),this.#he&&(i.logLevel=this.#m);let a=this.#D?.info?.agent.model;a?.routing.kind===`dynamic`?i.model=`dynamic model`: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))}#zn(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))}#Bn(){let e=this.#i.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#we,outputTokens:this.#De,tokensPerSecond:this.#Oe},this.#u);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#i.glyph.dot} `)):``}#Vn(){return Math.max(20,this.#t.columns||80)}#Hn(){return Math.max(8,this.#t.rows||24)}#Un(){if(this.#Ae!==void 0||!this.#d)return;this.#je=``,this.#Me=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#Kn(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#f?.subscribeLogRecords(e=>this.#Gn(e)),this.#Ae=()=>{this.#f?.unsubscribeLogRecords(),e(),t()}}#Wn(){let e=this.#Ae;e!==void 0&&(this.#Ae=void 0,e(),this.#je.length>0&&(this.#f?.append({source:`stdout`,detail:this.#je}),this.#tr(`stdout`)&&process.stdout.write(`${this.#je}\n`),this.#je=``),this.#Me.length>0&&(this.#f?.append({source:`stderr`,detail:this.#Me}),this.#tr(`stderr`)&&process.stderr.write(`${this.#Me}\n`),this.#Me=``))}#Gn(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#Jn(`[eve:${e.namespace}] ${e.message}${t}`),this.#Sn()}#Kn(e,t){let n=(e===`stdout`?this.#je:this.#Me)+t;if(e===`stdout`&&parseDevRebuildLogLine(n.trimEnd())!==void 0){this.#je=``,this.#f?.append({source:e,detail:n.trimEnd()}),this.#qn(n.trimEnd()),this.#Sn();return}let r=n.lastIndexOf(`
|
|
8
8
|
`),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#je=i:this.#Me=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.#qn(a):this.#Jn(a),this.#Sn())}#qn(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
|
|
9
9
|
`);t=[],e.trim().length!==0&&this.#$t({kind:`log`,title:`stdout`,body:e,live:!0})};for(let n of e.split(`
|
|
10
10
|
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#$t({kind:`sandbox`,body:e,live:!1});continue}let r=parseDevRebuildLogLine(n.trimEnd());if(r===void 0){t.push(n);continue}flushPending(),this.#Xn(r,n.trimEnd())}flushPending()}#Jn(e){let t=e.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{remoteHost}from"./target.js";import{createDevDiagnostics}from"../diagnostics.js";import{promptCommandsFor}from"./prompt-commands.js";import{pickAgentHeaderTip}from"./agent-header.js";import{probeMcpConnection}from"./mcp-connection-status.js";import{createPromptCommandHandler}from"./prompt-command-handler.js";import{formatRemoteAuthChallengeMessage}from"./remote-auth-result.js";import{TerminalRenderer}from"./terminal-renderer.js";import{EveTUIRunner}from"./runner.js";import{Client}from"#client/index.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{toErrorMessage}from"#shared/errors.js";import{resolveDevelopmentOidcToken,resolveLinkedDevelopmentOidcToken}from"#services/dev-client/request-headers.js";import{isVercelAuthChallenge}from"#services/dev-client/vercel-auth-error.js";import{resolveVercelDeployment}from"#setup/vercel-deployment.js";import{appendUserAgentProduct}from"#internal/user-agent.js";import{resolveLocalDevelopmentClientOptions,resolveRemoteDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{createDevelopmentCredentialGate}from"#services/dev-client/credential-gate.js";async function startDevelopmentTuiStartup(e){let t=await createDevDiagnostics(e.appRoot).catch(()=>void 0),n=pickAgentHeaderTip(),r=new TerminalRenderer({...e,diagnostics:t,onExitRequest:e.onExitRequest});return r.beginStartupDraft({initialDraft:e.initialInput,tip:n,title:e.name??`eve`}),{diagnostics:t,headerTip:n,renderer:r,finish:()=>r.finishStartupDraft(),async shutdown(){r.shutdown(),await t?.close()}}}function prepareRemoteTarget(e){return{target:e,credentials:createDevelopmentCredentialGate(e.serverUrl),resolveOidcToken:resolveDevelopmentOidcToken,resolveDeployment:t=>resolveVercelDeployment({workspaceRoot:e.workspaceRoot,host:remoteHost(e),signal:t})}}function prepareDevelopmentTarget(e){return e.kind===`local`?{kind:`local`,target:e}:{kind:`remote`,target:e,remote:prepareRemoteTarget(e)}}function withTuiUserAgent(e){let t=new Headers(e);return appendUserAgentProduct(t,`eve-tui/${resolveInstalledPackageInfo().version}`),Object.fromEntries(t.entries())}async function runDevelopmentTui(e){let{target:t,headers:n,initialInput:r,onboard:i,onOnboardingStep:a,onOnboardingTerminal:o,onBootProgress:s,lifecycle:c,startup:l,withExclusiveTerminal:u,...d}=e,f=prepareDevelopmentTarget(t),{serverUrl:p}=t,m={headers:withTuiUserAgent(n)},h=new Client(f.kind===`local`?resolveLocalDevelopmentClientOptions({...m,interactiveClient:!0,serverUrl:p,token:()=>resolveLinkedDevelopmentOidcToken(f.target.workspaceRoot)}):resolveRemoteDevelopmentClientOptions({...m,serverUrl:p,credentials:f.remote.credentials})),g={...d,client:h,serverUrl:p,promptCommandHandler:createPromptCommandHandler({target:t}),availablePromptCommands:promptCommandsFor(t.kind),formatTransportError:e=>isVercelAuthChallenge(e)?formatRemoteAuthChallengeMessage(p):toErrorMessage(e)};f.kind===`local`?(g.appRoot=f.target.workspaceRoot,g.probeMcpConnection=probeMcpConnection):g.remote=f.remote,r!==void 0&&(g.initialInput=r),l!==void 0&&(g.renderer=l.renderer,g.startup=l),i!==void 0&&(g.onboard=i),a!==void 0&&(g.onOnboardingStep=a),o!==void 0&&(g.onOnboardingTerminal=o),s!==void 0&&(g.onBootProgress=s),c!==void 0&&(g.lifecycle=c),u!==void 0&&(g.withExclusiveTerminal=u);let _=l?.diagnostics??(f.kind===`local`?await createDevDiagnostics(f.target.workspaceRoot).catch(()=>void 0):void 0);_!==void 0&&(g.diagnostics=_);try{await new EveTUIRunner(g).run()}finally{await _?.close()}}export{runDevelopmentTui,startDevelopmentTuiStartup};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{InvalidArgumentError}from"#compiled/commander/index.js";import{
|
|
1
|
+
import{InvalidArgumentError}from"#compiled/commander/index.js";import{LOG_DISPLAY_MODES,parseLogDisplayMode}from"#cli/dev/tui/log-display-mode.js";import{ALL_REASONING_LEVELS}from"#setup/boxes/model-capabilities.js";function parsePortOption(e){if(!/^-?\d+$/.test(e))throw new InvalidArgumentError(`Expected a numeric port, received "${e}".`);let t=Number(e);if(t<0||t>65535)throw new InvalidArgumentError(`Expected a port between 0 and 65535, received "${e}".`);return t}const DISPLAY_MODES=new Set([`full`,`collapsed`,`auto-collapsed`,`hidden`]),STATS_MODES=new Set([`tokens`,`tokensPerSecond`]);function parseDisplayMode(e){if(!DISPLAY_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...DISPLAY_MODES].join(`, `)}, received "${e}".`);return e}function parseStatsMode(e){if(!STATS_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...STATS_MODES].join(`, `)}, received "${e}".`);return e}function parseLogsMode(e){let t=parseLogDisplayMode(e);if(t===void 0)throw new InvalidArgumentError(`Expected one of ${LOG_DISPLAY_MODES.join(`, `)}, received "${e}".`);return t}function parseContextSizeOption(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)throw new InvalidArgumentError(`Expected a positive number, received "${e}".`);return t}const REASONING_VALUES=[`provider-default`,...ALL_REASONING_LEVELS];function parseAgentNamesOption(e){let t=e.split(`,`).map(e=>e.trim());if(t.length===0||t.some(e=>e===``))throw new InvalidArgumentError(`--agents requires a comma-separated list of at least one agent name.`);return t}function parseReasoningOption(e){if(!REASONING_VALUES.some(t=>t===e))throw new InvalidArgumentError(`Expected one of ${REASONING_VALUES.join(`, `)}, received "${e}".`);return e}export{parseAgentNamesOption,parseContextSizeOption,parseDisplayMode,parseLogsMode,parsePortOption,parseReasoningOption,parseStatsMode};
|
package/dist/src/cli/run.js
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import{Command,CommanderError
|
|
2
|
-
You can also pass a bare URL, for example: eve dev https://example.com
|
|
3
|
-
`).action(async(i,a)=>{let s=resolveDevelopmentUrlTarget(a,i),c=s?.serverUrl,l=hasInteractiveTerminal(),u=resolveDevUiMode({options:a,interactive:l});if(r.trackDevContext({target:s?`remote`:`local`,ui:u}),u===`headless`&&e.log(eveCliBanner()),a.input!==void 0&&u===`headless`)throw new InvalidArgumentError(`--input requires the interactive UI.`);let d=!1;if(c!==void 0&&(d=await(t.isActiveDevelopmentServerForApp??await loadIsActiveDevelopmentServerForApp())({appRoot:n.root,serverUrl:c})),c){let{loadDevelopmentEnvironmentFiles:i}=await import(`#cli/dev/environment.js`);if(await i(n.root),e.log(`↗ ${d?`local`:`remote`} mode targeting ${o.info(new URL(c).host)}`),u===`headless`){e.log(renderCliTaggedLine(o,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}e.log(``);let l=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS});try{await runInteractiveDevelopmentUi({applicationRoot:n.root,existingLocalServer:d,lifecycle:l,onOnboardingStep:r.trackSetupStep,onOnboardingTerminal:r.trackSetupTerminal,options:a,remoteTarget:s,runDevelopmentTui:t.runDevelopmentTui,server:{serverUrl:c}})}finally{l.dispose()}return}let f=u===`tui`?startCliLiveRow(e):void 0,p=createDevBootProgressReporter(f);f?.update(`Building your agent`);let m,h,closeServer=()=>m===void 0?Promise.resolve():(h??=m.close(),h.catch(()=>void 0),h),g=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS,onStop:()=>{closeServer()}}),_,v=u===`tui`&&t.runDevelopmentTui===void 0?loadDevelopmentTuiModule().then(e=>(p({type:`before-first-paint`}),e.startDevelopmentTuiStartup({appRoot:n.root,initialInput:a.input,onExitRequest:g.requestStop,...resolveTuiDisplayOptions(a)}))):void 0;try{m=(t.startHost??await loadStartHost())(n.root,{existing:u===`tui`?`attach-if-unconfigured`:`reject`,host:a.host,onBootProgress:p,port:a.port});let[i,s]=await Promise.all([Promise.race([m.start().then(e=>({handle:e})),g.stopped.then(()=>({handle:void 0}))]),v]),c=i.handle;if(c===void 0){_=s,await _?.shutdown();return}if(_=s,u!==`tui`&&e.log(renderCliTaggedLine(o,{message:`server listening at ${c.url}`,tag:`dev`,tone:`success`})),u===`headless`){a.ui!==!1&&!l&&e.log(renderCliTaggedLine(o,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForServerOrStop(m,g);return}await waitForUiOrServer({handle:c,lifecycle:g,server:m,runUi:async()=>await runInteractiveDevelopmentUi({applicationRoot:n.root,existingLocalServer:!1,lifecycle:g,onOnboardingStep:r.trackSetupStep,onOnboardingTerminal:r.trackSetupTerminal,options:a,report:p,runDevelopmentTui:t.runDevelopmentTui,server:{appRoot:c.appRoot,serverUrl:c.url},startup:_})})}finally{f?.stop(),_===void 0&&(_=await v?.catch(()=>void 0),await _?.shutdown()),await closeServer(),g.dispose()}});let c=a.command(`logs`).description("Inspect local `eve dev` diagnostic logs (.eve/logs).");return agentCommand(c.command(`show [logid]`,{isDefault:!0}),n).description(`Print a diagnostic log (the most recent when logid is omitted).`).option(`--dump`,`Prepend the log's environment dump (.dump sibling)`).option(`--events`,`Interleave session events from the local workflow store`).action(async(t,r)=>{let{runLogsShowCommand:i}=await import(`#cli/commands/logs.js`);await i(e,n.root,t,r)}),agentCommand(c.command(`ls`),n).description(`List diagnostic logs, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runLogsListCommand:r}=await import(`#cli/commands/logs.js`);await r(e,n.root,t)}),agentCommand(a.command(`traces [trace]`),n).usage(`[options] [trace]
|
|
1
|
+
import{Command,CommanderError}from"#compiled/commander/index.js";import{agentCommand}from"#cli/agent-command.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";import{waitForShutdownSignal}from"#cli/shutdown.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{findEveProjectContext,resolveEveProjectContext}from"#internal/project-context.js";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{eveCliBanner}from"#cli/banner.js";import{registerBuildCommand}from"#cli/commands/build.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{findCliApplicationRoot,resolveCliApplicationProject}from"#cli/application-root.js";import{registerIntegrationCommands}from"#cli/commands/register-integration-commands.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{registerRegistryCommands}from"#cli/commands/register-registry-commands.js";import{registerDevelopmentCommand}from"#cli/dev/command.js";import{resolveDevUiMode,resolveTuiDisplayOptions}from"#cli/dev/ui-options.js";import{registerAcpCommand}from"#cli/acp/command.js";import{registerRuntimeInvokeCommand}from"#cli/invoke/command.js";import{parseAgentNamesOption,parsePortOption,parseReasoningOption}from"#cli/option-parsers.js";import{registerEveTelemetryCommands}from"#cli/telemetry/command.js";import{canonicalCommand,createEveCliTelemetry}from"#cli/telemetry/index.js";async function loadPrintApplicationInfo(){return(await import(`#cli/commands/info.js`)).printApplicationInfo}async function loadRunEvalCommand(){return(await import(`#evals/cli/eval.js`)).runEvalCommand}async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function createCliProgram(e,t,n,r){let i=resolveInstalledPackageInfo().version,a=new Command,o=createCliTheme();a.name(`eve`).description(`Build and run an eve application.`).version(i).showHelpAfterError().exitOverride().hook(`preAction`,(t,n)=>{let{json:r}=n.opts();[`info`,`init`].includes(n.name())&&!r&&e.log(eveCliBanner())}).configureOutput({writeErr:t=>{e.error(t.trimEnd())},writeOut:t=>{e.log(t.trimEnd())}}),agentCommand(a.command(`channels`).description(`Manage user-authored channels in the current project.`).command(`list`),n).description(`List user-authored channels in the current project.`).option(`--json`,`Output as JSON`).action(async t=>{let{runChannelsListCommand:r}=await import(`#cli/commands/channels.js`);await r(e,n.project,t)}),registerEveTelemetryCommands(a,e),registerIntegrationCommands({program:a,logger:e,applicationContext:n});let s=a.command(`extension`).description(`Create and build reusable eve extension packages.`);s.command(`init [target]`).description(`Create a new eve extension package.`).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve extension init.`);let{runExtensionInitCommand:a}=await import(`#cli/commands/extension-init.js`);await a(e,n.root,t,void 0,e=>{r.trackSetupStep({flow:`extension_init`,step:e})})}),s.command(`build`).description(`Build the current package as an eve extension.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);await t(n.root);let{runExtensionBuildCommand:r}=await import(`#cli/commands/extension-build.js`);await r(e,n.root)}),registerRegistryCommands({program:a,logger:e,applicationContext:n}),a.command(`init [target]`).description(`Create a new eve agent, or add one to an existing project directory.`).option(`--channel-web-nextjs`,`Add the Web Chat application (Next.js)`).option(`--agents <names>`,`Create an agents/ workspace with comma-separated agent names`,parseAgentNamesOption).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve init.`);let{runInitCommand:a}=await import(`#cli/commands/init.js`);await a(e,n.root,t,{agents:i.agents,channelWebNextjs:i.channelWebNextjs,model:i.model,reasoning:i.reasoning},void 0,e=>{r.trackSetupStep({flow:`init`,step:e})},(e,t,n)=>{r.trackSetupTerminal({flow:`init`,step:e,result:t,failureCode:n})})}),agentCommand(a.command(`set`),n).description(`Change root agent model settings.`).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).action(async t=>{let{runSetCommand:r}=await import(`#cli/commands/set.js`);await r(e,n.root,t)}),registerProjectCommands({program:a,logger:e,applicationContext:n}),registerBuildCommand({applicationContext:n,buildHost:t.buildHost,logger:e,program:a}),agentCommand(a.command(`start`),n).description(`Start a built eve application.`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).action(async r=>{let{loadDevelopmentEnvironmentFiles:i}=await import(`#cli/dev/environment.js`);await i(n.root);let a=await(t.startProductionHost??await loadStartProductionHost())(n.root,{host:r.host,port:r.port});e.log(renderCliTaggedLine(o,{message:`server listening at ${a.url}`,tag:`start`,tone:`success`})),await waitForShutdownSignal({close:()=>a.close(),wait:()=>a.wait()})}),registerRuntimeInvokeCommand({applicationContext:n,logger:e,program:a,runtime:t}),registerAcpCommand({applicationContext:n,eveVersion:i,program:a,resolveVerifiedRemoteDevelopmentClient:t.resolveVerifiedRemoteDevelopmentClient,runAcpServer:t.runAcpServer,startHost:t.startHost}),registerDevelopmentCommand({applicationContext:n,logger:e,program:a,runtime:t,telemetry:r});let c=a.command(`logs`).description("Inspect local `eve dev` diagnostic logs (.eve/logs).");return agentCommand(c.command(`show [logid]`,{isDefault:!0}),n).description(`Print a diagnostic log (the most recent when logid is omitted).`).option(`--dump`,`Prepend the log's environment dump (.dump sibling)`).option(`--events`,`Interleave session events from the local workflow store`).action(async(t,r)=>{let{runLogsShowCommand:i}=await import(`#cli/commands/logs.js`);await i(e,n.root,t,r)}),agentCommand(c.command(`ls`),n).description(`List diagnostic logs, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runLogsListCommand:r}=await import(`#cli/commands/logs.js`);await r(e,n.root,t)}),agentCommand(a.command(`traces [trace]`),n).usage(`[options] [trace]
|
|
4
2
|
eve traces ls [options]`).description("Show a local `eve dev` trace (the most recent when trace is omitted).").option(`--verbose`,`Expand every span with all attributes and events`).option(`--json`,`Output as JSON`).action(async(t,r)=>{let{runTraceShowCommand:i}=await import(`#cli/commands/trace.js`);await i(e,n.root,t,r)}).command(`ls`).description(`List local traces, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runTraceListCommand:r}=await import(`#cli/commands/trace.js`);await r(e,n.root,t)}),agentCommand(a.command(`info`),n).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async r=>{await(t.printApplicationInfo??await loadPrintApplicationInfo())(e,n.root,r)}),agentCommand(a.command(`eval`),n,e=>e.opts().url===void 0).description(`Run evals against an eve agent.`).argument(`[evalIds...]`,`Eval ids (or directory prefixes) to run (all discovered evals when omitted)`).option(`--url <url>`,`Remote agent URL (skip local host startup)`,parseDevelopmentServerUrl).option(`--tag <tag...>`,`Run only evals carrying a tag`).option(`--exclude-tag <tag...>`,`Skip evals carrying a tag`).option(`--strict`,`Fail the exit code when any score falls below its threshold`).option(`--list`,`Print discovered evals without running them`).option(`--timeout <ms>`,`Per-eval timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent eval executions`).option(`--json`,`Output results as JSON`).option(`--junit <path>`,`Write JUnit XML results to a file`).option(`--skip-report`,`Skip eval-defined reporters (e.g. Braintrust)`).option(`--verbose`,`Stream per-eval logs and workflow run IDs to stdout`).action(async(r,i)=>{await(t.runEvalCommand??await loadRunEvalCommand())(r,i,e,n.root)}),a}async function runCli(e=process.argv.slice(2),t=console,n={}){let r={root:resolveApplicationRoot(),async resolve(){let e=await(n.resolveApplicationProject??resolveCliApplicationProject)(r.root);r.project=e,r.root=e.appRoot},async resolveAgent(){return resolveEveProjectContext(r.root)}},i=createEveCliTelemetry(resolveInstalledPackageInfo().version),a=createCliProgram(t,n,r,i),o=e;if(o.length===0){let e=await(n.findApplicationRoot??findCliApplicationRoot)(r.root);e===void 0?o=(await findEveProjectContext(r.root))?.kind===`workspace`?[`dev`]:[`init`]:(r.root=e,o=[`dev`])}let s=canonicalCommand(o);i.trackCommand(s),s!==`telemetry`&&await i.notify(t);try{await a.parseAsync(o,{from:`user`}),i.trackOutcome(`success`)}catch(e){if(e instanceof CommanderError&&e.exitCode===0){i.trackOutcome(`success`);return}if(i.trackOutcome(e instanceof CommanderError?`usage_error`:`error`),e instanceof CommanderError){let r=await(n.isCodingAgentLaunch??isCodingAgentLaunch)();if(o[0]===`init`&&r){let{initAgentInstructions:e}=await import(`#cli/commands/agent-instructions.js`);t.log(e())}throw Error(e.message)}throw e}finally{await i.flush()}}export{createCliProgram,resolveDevUiMode,resolveTuiDisplayOptions,runCli};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const AGENT_NAME_PATTERN=/^[a-z0-9][a-z0-9_-]*$/;function resolveEveAgentHost(e){if(e.agent===void 0)return e.host??``;if(e.host!==void 0)throw Error(`useEveAgent cannot combine agent and host. Use one target option.`);return assertValidAgentName(e.agent),`/eve
|
|
1
|
+
const AGENT_NAME_PATTERN=/^[a-z0-9][a-z0-9_-]*$/;function resolveEveAgentHost(e){if(e.agent===void 0)return e.host??``;if(e.host!==void 0)throw Error(`useEveAgent cannot combine agent and host. Use one target option.`);return assertValidAgentName(e.agent),`/eve/${e.agent}`}function assertValidAgentName(e){if(!AGENT_NAME_PATTERN.test(e))throw Error(`eve agent name ${JSON.stringify(e)} is invalid. Use lowercase letters, numbers, underscores, or hyphens, starting with a letter or number.`)}export{resolveEveAgentHost};
|
package/dist/src/client/url.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function createClientUrl(e,t,n){let r=t.indexOf(`?`),i=r===-1?t:t.slice(0,r),a=r===-1?``:t.slice(r+1),o=i.startsWith(`/`)?i:`/${i}`;if(isAbsoluteUrl(e)){let t=new URL(e);return t.pathname
|
|
1
|
+
import{joinEveRoutePath}from"#shared/eve-route-path.js";function createClientUrl(e,t,n){let r=t.indexOf(`?`),i=r===-1?t:t.slice(0,r),a=r===-1?``:t.slice(r+1),o=i.startsWith(`/`)?i:`/${i}`;if(isAbsoluteUrl(e)){let t=new URL(e),r=trimTrailingSlash(t.pathname);return t.pathname=joinEveRoutePath(r,o),mergeEmbeddedQuery(t.searchParams,a),mergeSearchParams(t.searchParams,n),t.hash=``,t.toString()}let s=new URL(e,`http://eve.local`),c=trimTrailingSlash(s.pathname);return mergeEmbeddedQuery(s.searchParams,a),mergeSearchParams(s.searchParams,n),`${joinEveRoutePath(c,o)}${formatSearch(s.searchParams)}`}function mergeEmbeddedQuery(e,t){if(t.length!==0)for(let[n,r]of new URLSearchParams(t))e.append(n,r)}function isAbsoluteUrl(e){return/^[a-z][a-z\d+\-.]*:/i.test(e)}function trimTrailingSlash(e){return e===`/`?``:e.endsWith(`/`)?e.slice(0,-1):e}function mergeSearchParams(e,t){if(t!==void 0)for(let[n,r]of Object.entries(t))e.set(n,r)}function formatSearch(e){let t=e.toString();return t.length===0?``:`?${t}`}export{createClientUrl};
|