eve 0.7.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +11 -11
- package/dist/src/chunks/{use-eve-agent-DErQj5hs.js → use-eve-agent-BSXZSn-R.js} +6 -1
- package/dist/src/chunks/{use-eve-agent-DoR8C4i6.js → use-eve-agent-Dlut2Qzt.js} +6 -1
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/tui/blocks.d.ts +1 -1
- package/dist/src/cli/dev/tui/blocks.js +4 -3
- package/dist/src/cli/dev/tui/command-typeahead.d.ts +13 -3
- package/dist/src/cli/dev/tui/command-typeahead.js +1 -1
- package/dist/src/cli/dev/tui/line-editor.d.ts +6 -0
- package/dist/src/cli/dev/tui/line-editor.js +1 -1
- package/dist/src/cli/dev/tui/prompt-command-handler.d.ts +2 -0
- package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +10 -0
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/setup-commands.d.ts +11 -7
- package/dist/src/cli/dev/tui/setup-commands.js +2 -2
- package/dist/src/cli/dev/tui/setup-flow.d.ts +72 -10
- package/dist/src/cli/dev/tui/setup-issues.js +1 -1
- package/dist/src/cli/dev/tui/setup-panel.d.ts +91 -39
- package/dist/src/cli/dev/tui/setup-panel.js +3 -1
- package/dist/src/cli/dev/tui/setup-selection-input.d.ts +48 -0
- package/dist/src/cli/dev/tui/setup-selection-input.js +1 -0
- package/dist/src/cli/dev/tui/status-line.d.ts +13 -7
- package/dist/src/cli/dev/tui/status-line.js +1 -1
- package/dist/src/cli/dev/tui/stream-format.d.ts +2 -0
- package/dist/src/cli/dev/tui/stream-format.js +2 -2
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +4 -2
- package/dist/src/cli/dev/tui/terminal-renderer.js +6 -5
- package/dist/src/cli/dev/tui/theme.d.ts +3 -1
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/cli/dev/tui/tui-prompter.js +1 -1
- package/dist/src/cli/dev/tui/tui.d.ts +6 -0
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/dev/tui/vercel-status.d.ts +4 -4
- package/dist/src/cli/dev/tui/vercel-status.js +1 -1
- package/dist/src/cli/run.d.ts +4 -3
- package/dist/src/cli/run.js +2 -2
- package/dist/src/client/client.js +1 -1
- package/dist/src/client/session-utils.d.ts +1 -0
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.d.ts +1 -0
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +19 -0
- package/dist/src/compiled/.vendor-stamp.json +1 -2
- package/dist/src/compiler/compile-from-memory.js +1 -1
- package/dist/src/compiler/manifest.d.ts +28 -7
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-sandbox.js +1 -1
- package/dist/src/evals/cli/eval-client.js +1 -1
- package/dist/src/execution/sandbox/bash-tool.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-base-setup.d.ts +9 -0
- package/dist/src/execution/sandbox/bindings/docker-base-setup.js +2 -0
- package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +77 -0
- package/dist/src/execution/sandbox/bindings/docker-cli.js +2 -0
- package/dist/src/execution/sandbox/bindings/docker-container.d.ts +16 -0
- package/dist/src/execution/sandbox/bindings/docker-container.js +1 -0
- package/dist/src/execution/sandbox/bindings/docker-network.d.ts +8 -0
- package/dist/src/execution/sandbox/bindings/docker-network.js +1 -0
- package/dist/src/execution/sandbox/bindings/docker-options.d.ts +21 -0
- package/dist/src/execution/sandbox/bindings/docker-options.js +1 -0
- package/dist/src/execution/sandbox/bindings/docker-session.d.ts +7 -0
- package/dist/src/execution/sandbox/bindings/docker-session.js +2 -0
- package/dist/src/execution/sandbox/bindings/docker-templates.d.ts +35 -0
- package/dist/src/execution/sandbox/bindings/docker-templates.js +1 -0
- package/dist/src/execution/sandbox/bindings/docker-utils.d.ts +2 -0
- package/dist/src/execution/sandbox/bindings/docker-utils.js +1 -0
- package/dist/src/execution/sandbox/bindings/docker.d.ts +33 -0
- package/dist/src/execution/sandbox/bindings/docker.js +1 -0
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.d.ts +30 -0
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -0
- package/dist/src/execution/sandbox/bindings/just-bash.d.ts +33 -0
- package/dist/src/execution/sandbox/bindings/just-bash.js +1 -0
- package/dist/src/execution/sandbox/bindings/local-backend-utils.d.ts +23 -0
- package/dist/src/execution/sandbox/bindings/local-backend-utils.js +1 -0
- package/dist/src/execution/sandbox/bindings/local-template-prune.d.ts +16 -0
- package/dist/src/execution/sandbox/bindings/local-template-prune.js +1 -0
- package/dist/src/execution/sandbox/bindings/local.d.ts +16 -25
- package/dist/src/execution/sandbox/bindings/local.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.d.ts +16 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +1 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-metadata.d.ts +21 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-metadata.js +1 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-network.d.ts +18 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-network.js +1 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-options.d.ts +34 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-options.js +1 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-platform.d.ts +22 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-platform.js +178 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-process.d.ts +3 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-process.js +1 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.d.ts +75 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-templates.d.ts +13 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +1 -0
- package/dist/src/execution/sandbox/bindings/microsandbox.d.ts +22 -0
- package/dist/src/execution/sandbox/bindings/microsandbox.js +1 -0
- package/dist/src/execution/sandbox/bindings/vercel-create-api.d.ts +20 -0
- package/dist/src/execution/sandbox/bindings/vercel-create-api.js +1 -0
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +7 -8
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/sandbox/development-cleanup.d.ts +4 -0
- package/dist/src/execution/sandbox/development-cleanup.js +1 -0
- package/dist/src/execution/sandbox/development-prewarm.d.ts +11 -0
- package/dist/src/execution/sandbox/development-prewarm.js +1 -0
- package/dist/src/execution/sandbox/development-run.d.ts +8 -0
- package/dist/src/execution/sandbox/development-run.js +1 -0
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/sandbox/lazy-backend.d.ts +1 -1
- package/dist/src/execution/sandbox/logging-session.d.ts +5 -0
- package/dist/src/execution/sandbox/logging-session.js +1 -0
- package/dist/src/execution/sandbox/prewarm.js +1 -1
- package/dist/src/execution/sandbox/template-prewarm-lock.d.ts +8 -0
- package/dist/src/execution/sandbox/template-prewarm-lock.js +1 -0
- package/dist/src/internal/application/optional-package-install.d.ts +40 -0
- package/dist/src/internal/application/optional-package-install.js +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/sandbox.d.ts +1 -1
- package/dist/src/internal/authored-definition/sandbox.js +1 -1
- package/dist/src/internal/authored-module-loader.js +2 -2
- package/dist/src/internal/classify-model-routing.d.ts +24 -0
- package/dist/src/internal/classify-model-routing.js +1 -0
- package/dist/src/internal/nitro/host/channel-routes.js +2 -2
- package/dist/src/internal/nitro/host/compiled-sandbox-backend-prune-plugin.d.ts +5 -2
- package/dist/src/internal/nitro/host/compiled-sandbox-backend-prune-plugin.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts +10 -0
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-live-virtual-modules.d.ts +15 -0
- package/dist/src/internal/nitro/host/dev-live-virtual-modules.js +1 -0
- package/dist/src/internal/nitro/host/optional-engine-dependency-plugin.d.ts +28 -0
- package/dist/src/internal/nitro/host/optional-engine-dependency-plugin.js +1 -0
- package/dist/src/internal/nitro/host/start-development-server.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.d.ts +2 -0
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +4 -0
- package/dist/src/internal/nitro/routes/info.js +1 -1
- package/dist/src/internal/nitro/routes/runtime-artifacts.js +1 -1
- package/dist/src/internal/resolve-model-endpoint-status.d.ts +23 -0
- package/dist/src/internal/resolve-model-endpoint-status.js +1 -0
- package/dist/src/internal/workflow-bundle/builder-support.js +2 -2
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
- package/dist/src/public/definitions/sandbox-backend.js +1 -1
- package/dist/src/public/sandbox/backends/default.d.ts +37 -10
- package/dist/src/public/sandbox/backends/default.js +1 -1
- package/dist/src/public/sandbox/backends/docker.d.ts +14 -0
- package/dist/src/public/sandbox/backends/docker.js +1 -0
- package/dist/src/public/sandbox/backends/just-bash.d.ts +17 -0
- package/dist/src/public/sandbox/backends/just-bash.js +1 -0
- package/dist/src/public/sandbox/backends/microsandbox.d.ts +17 -0
- package/dist/src/public/sandbox/backends/microsandbox.js +1 -0
- package/dist/src/public/sandbox/backends/vercel.d.ts +5 -2
- package/dist/src/public/sandbox/backends/vercel.js +1 -1
- package/dist/src/public/sandbox/docker-sandbox.d.ts +45 -0
- package/dist/src/public/sandbox/index.d.ts +8 -4
- package/dist/src/public/sandbox/index.js +1 -1
- package/dist/src/public/sandbox/just-bash-sandbox.d.ts +17 -0
- package/dist/src/public/sandbox/just-bash-sandbox.js +1 -0
- package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +54 -0
- package/dist/src/public/sandbox/microsandbox-sandbox.js +1 -0
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +1 -1
- package/dist/src/runtime/compiled-artifacts-source.d.ts +11 -0
- package/dist/src/runtime/compiled-artifacts-source.js +1 -1
- package/dist/src/runtime/resolve-sandbox.js +1 -1
- package/dist/src/runtime/sandbox/keys.js +1 -1
- package/dist/src/runtime/sandbox/registry.d.ts +2 -2
- package/dist/src/runtime/types.d.ts +1 -1
- package/dist/src/runtime/workspace/spec.js +1 -1
- package/dist/src/setup/boxes/add-channels.d.ts +3 -2
- package/dist/src/setup/boxes/add-channels.js +2 -2
- package/dist/src/setup/boxes/apply-ai-gateway-credential.js +1 -1
- package/dist/src/setup/boxes/deploy-project.js +1 -1
- package/dist/src/setup/boxes/link-project.js +1 -1
- package/dist/src/setup/boxes/resolve-provisioning.d.ts +6 -0
- package/dist/src/setup/boxes/resolve-provisioning.js +1 -1
- package/dist/src/setup/boxes/select-model.d.ts +2 -2
- package/dist/src/setup/boxes/select-model.js +1 -1
- package/dist/src/setup/cli/channel-setup-prompter.d.ts +28 -0
- package/dist/src/setup/cli/channel-setup-prompter.js +1 -1
- package/dist/src/setup/cli/index.d.ts +2 -2
- package/dist/src/setup/cli/index.js +1 -1
- package/dist/src/setup/cli/option-row.d.ts +89 -0
- package/dist/src/setup/cli/option-row.js +1 -0
- package/dist/src/setup/cli/prompt-ui.d.ts +15 -29
- package/dist/src/setup/cli/prompt-ui.js +2 -2
- package/dist/src/setup/cli/select-component.d.ts +4 -3
- package/dist/src/setup/cli/select-component.js +1 -1
- package/dist/src/setup/cli/select-state.d.ts +3 -3
- package/dist/src/setup/cli/select-state.js +1 -1
- package/dist/src/setup/flows/channels.d.ts +29 -14
- package/dist/src/setup/flows/channels.js +1 -1
- package/dist/src/setup/flows/deploy.d.ts +1 -0
- package/dist/src/setup/flows/deploy.js +1 -1
- package/dist/src/setup/flows/link.d.ts +1 -0
- package/dist/src/setup/flows/link.js +1 -1
- package/dist/src/setup/flows/model.d.ts +30 -6
- package/dist/src/setup/flows/model.js +1 -1
- package/dist/src/setup/flows/vercel.d.ts +4 -1
- package/dist/src/setup/flows/vercel.js +2 -2
- package/dist/src/setup/index.js +1 -1
- package/dist/src/setup/primitives/open-url.d.ts +14 -0
- package/dist/src/setup/primitives/open-url.js +1 -0
- package/dist/src/setup/primitives/pm/pnpm.d.ts +9 -0
- package/dist/src/setup/primitives/pm/pnpm.js +2 -2
- package/dist/src/setup/primitives/pm/run.d.ts +12 -4
- package/dist/src/setup/primitives/pm/run.js +1 -1
- package/dist/src/setup/primitives/pm/types.d.ts +3 -0
- package/dist/src/setup/primitives/process-abort.d.ts +7 -0
- package/dist/src/setup/primitives/process-abort.js +1 -0
- package/dist/src/setup/primitives/run-vercel.d.ts +2 -0
- package/dist/src/setup/primitives/run-vercel.js +1 -1
- package/dist/src/setup/project-resolution.d.ts +6 -3
- package/dist/src/setup/project-resolution.js +1 -1
- package/dist/src/setup/prompter.d.ts +63 -6
- package/dist/src/setup/prompter.js +1 -1
- package/dist/src/setup/run-vercel-link.d.ts +1 -1
- package/dist/src/setup/run-vercel-link.js +1 -1
- package/dist/src/setup/runner.d.ts +2 -0
- package/dist/src/setup/runner.js +1 -1
- package/dist/src/setup/scaffold/channels-catalog.d.ts +2 -0
- package/dist/src/setup/scaffold/channels-catalog.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.d.ts +1 -0
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.d.ts +2 -0
- package/dist/src/setup/scaffold/create/project.js +6 -3
- package/dist/src/setup/scaffold/update/channels.d.ts +2 -0
- package/dist/src/setup/scaffold/update/channels.js +3 -3
- package/dist/src/setup/slack-connect-lifecycle.d.ts +97 -0
- package/dist/src/setup/slack-connect-lifecycle.js +1 -0
- package/dist/src/setup/slack-connect.d.ts +51 -0
- package/dist/src/setup/slack-connect.js +1 -0
- package/dist/src/setup/slackbot.d.ts +60 -47
- package/dist/src/setup/slackbot.js +1 -1
- package/dist/src/setup/state.d.ts +2 -1
- package/dist/src/setup/state.js +1 -1
- package/dist/src/setup/step.d.ts +4 -0
- package/dist/src/setup/validate-gateway-key.d.ts +30 -0
- package/dist/src/setup/validate-gateway-key.js +1 -0
- package/dist/src/setup/vercel-project.d.ts +19 -12
- package/dist/src/setup/vercel-project.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +26 -0
- package/dist/src/shared/model-endpoint-status.d.ts +27 -0
- package/dist/src/shared/model-endpoint-status.js +1 -0
- package/dist/src/shared/sandbox-backend.d.ts +8 -2
- package/dist/src/shared/sandbox-definition.d.ts +4 -3
- package/dist/src/shared/sandbox-network-policy.d.ts +4 -2
- package/dist/src/shared/sandbox-session.d.ts +3 -2
- package/dist/src/svelte/index.js +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.js +1 -1
- package/{dist/docs/public → docs}/getting-started.mdx +14 -4
- package/{dist/docs/public → docs}/guides/deployment.md +3 -3
- package/{dist/docs/public → docs}/guides/dev-tui.md +2 -2
- package/{dist/docs/public → docs}/reference/cli.md +2 -1
- package/{dist/docs/public → docs}/sandbox.mdx +39 -15
- package/package.json +11 -1
- package/dist/src/compiled/just-bash/LICENSE +0 -201
- package/dist/src/compiled/just-bash/index.d.ts +0 -139
- package/dist/src/compiled/just-bash/index.js +0 -2200
- package/dist/src/compiled/just-bash/network/types.d.ts +0 -155
- package/dist/src/public/sandbox/backends/local.d.ts +0 -16
- package/dist/src/public/sandbox/backends/local.js +0 -1
- package/dist/src/public/sandbox/local-sandbox.d.ts +0 -7
- /package/dist/src/public/sandbox/{local-sandbox.js → docker-sandbox.js} +0 -0
- /package/{dist/docs/public → docs}/README.md +0 -0
- /package/{dist/docs/public → docs}/agent-config.md +0 -0
- /package/{dist/docs/public → docs}/channels/custom.mdx +0 -0
- /package/{dist/docs/public → docs}/channels/discord.mdx +0 -0
- /package/{dist/docs/public → docs}/channels/eve.mdx +0 -0
- /package/{dist/docs/public → docs}/channels/github.mdx +0 -0
- /package/{dist/docs/public → docs}/channels/linear.mdx +0 -0
- /package/{dist/docs/public → docs}/channels/meta.json +0 -0
- /package/{dist/docs/public → docs}/channels/overview.mdx +0 -0
- /package/{dist/docs/public → docs}/channels/slack.mdx +0 -0
- /package/{dist/docs/public → docs}/channels/teams.mdx +0 -0
- /package/{dist/docs/public → docs}/channels/telegram.mdx +0 -0
- /package/{dist/docs/public → docs}/channels/twilio.mdx +0 -0
- /package/{dist/docs/public → docs}/concepts/context-control.md +0 -0
- /package/{dist/docs/public → docs}/concepts/default-harness.md +0 -0
- /package/{dist/docs/public → docs}/concepts/execution-model-and-durability.md +0 -0
- /package/{dist/docs/public → docs}/concepts/meta.json +0 -0
- /package/{dist/docs/public → docs}/concepts/security-model.md +0 -0
- /package/{dist/docs/public → docs}/concepts/sessions-runs-and-streaming.md +0 -0
- /package/{dist/docs/public → docs}/connections.mdx +0 -0
- /package/{dist/docs/public → docs}/evals/assertions.mdx +0 -0
- /package/{dist/docs/public → docs}/evals/cases.mdx +0 -0
- /package/{dist/docs/public → docs}/evals/judge.mdx +0 -0
- /package/{dist/docs/public → docs}/evals/meta.json +0 -0
- /package/{dist/docs/public → docs}/evals/overview.mdx +0 -0
- /package/{dist/docs/public → docs}/evals/reporters.mdx +0 -0
- /package/{dist/docs/public → docs}/evals/running.mdx +0 -0
- /package/{dist/docs/public → docs}/evals/targets.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/auth-and-route-protection.md +0 -0
- /package/{dist/docs/public → docs}/guides/client/continuations.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/client/messages.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/client/meta.json +0 -0
- /package/{dist/docs/public → docs}/guides/client/output-schema.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/client/overview.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/client/streaming.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/dynamic-capabilities.md +0 -0
- /package/{dist/docs/public → docs}/guides/dynamic-workflows.md +0 -0
- /package/{dist/docs/public → docs}/guides/frontend/meta.json +0 -0
- /package/{dist/docs/public → docs}/guides/frontend/nextjs.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/frontend/nuxt.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/frontend/overview.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/frontend/sveltekit.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/frontend/use-eve-agent-svelte.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/frontend/use-eve-agent-vue.mdx +0 -0
- /package/{dist/docs/public → docs}/guides/hooks.md +0 -0
- /package/{dist/docs/public → docs}/guides/instrumentation.md +0 -0
- /package/{dist/docs/public → docs}/guides/meta.json +0 -0
- /package/{dist/docs/public → docs}/guides/remote-agents.md +0 -0
- /package/{dist/docs/public → docs}/guides/session-context.md +0 -0
- /package/{dist/docs/public → docs}/guides/state.md +0 -0
- /package/{dist/docs/public → docs}/instructions.mdx +0 -0
- /package/{dist/docs/public → docs}/introduction.md +0 -0
- /package/{dist/docs/public → docs}/meta.json +0 -0
- /package/{dist/docs/public → docs}/reference/meta.json +0 -0
- /package/{dist/docs/public → docs}/reference/project-layout.md +0 -0
- /package/{dist/docs/public → docs}/reference/typescript-api.md +0 -0
- /package/{dist/docs/public → docs}/schedules.mdx +0 -0
- /package/{dist/docs/public → docs}/skills.mdx +0 -0
- /package/{dist/docs/public → docs}/subagents.mdx +0 -0
- /package/{dist/docs/public → docs}/tools.mdx +0 -0
- /package/{dist/docs/public → docs}/tutorial/connect-a-warehouse.mdx +0 -0
- /package/{dist/docs/public → docs}/tutorial/first-agent.mdx +0 -0
- /package/{dist/docs/public → docs}/tutorial/guard-the-spend.mdx +0 -0
- /package/{dist/docs/public → docs}/tutorial/how-it-runs.mdx +0 -0
- /package/{dist/docs/public → docs}/tutorial/meta.json +0 -0
- /package/{dist/docs/public → docs}/tutorial/query-sample-data.mdx +0 -0
- /package/{dist/docs/public → docs}/tutorial/remember-definitions.mdx +0 -0
- /package/{dist/docs/public → docs}/tutorial/run-analysis.mdx +0 -0
- /package/{dist/docs/public → docs}/tutorial/ship-it.mdx +0 -0
- /package/{dist/docs/public → docs}/tutorial/team-playbooks.mdx +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import{sliceVisible,stripAnsi,stripTerminalControls,visibleLength}from"./terminal-text.js";import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{buildAgentHeader}from"./agent-header.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderBlockLines}from"./blocks.js";import{dismissTypeahead,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{interruptedError}from"./errors.js";import{EMPTY_LINE,PromptHistory,
|
|
2
|
-
`),live:!1}),this.#Ge();return}this.#b=!0,this.#n.flush(this.#Ye(),[])}async readPrompt(e){this.#ve(e),this.#k=!0,this.#j=!1,this.#M=``,this.#D=`Type to chat ${this.#r.glyph.dot} / for commands`;let t=lineOf(``);return this.#O.begin(t.text),this.#oe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,t.text),this.#Ee(),this.#Ge(),await new Promise((e,r)=>{let apply=e=>{t=e,this.#Oe(),this.#oe(t),this.#A=typeaheadFor(PROMPT_COMMANDS,e.text,this.#A),this.#Ge()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#A=void 0,this.#De(),this.#ye(),r(interruptedError())},suggestions=()=>this.#A!==void 0&&isTypeaheadOpen(this.#A)?this.#A:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#B=r=>{switch(r.type){case`character`:apply(insert(t,r.value));break;case`backspace`:apply(backspace(t));break;case`delete`:apply(deleteForward(t));break;case`left`:apply(moveLeft(t));break;case`right`:apply(moveRight(t));break;case`home`:case`ctrl-a`:apply(moveHome(t));break;case`end`:case`ctrl-e`:apply(moveEnd(t));break;case`ctrl-k`:apply(killToEnd(t));break;case`ctrl-u`:apply(killToStart(t));break;case`ctrl-w`:apply(deleteWord(t));break;case`up`:{let e=suggestions();e===void 0?recall(this.#O.previous(t.text)):(this.#A=moveTypeaheadSelection(e,-1),this.#Ge());break}case`down`:{let e=suggestions();e===void 0?recall(this.#O.next()):(this.#A=moveTypeaheadSelection(e,1),this.#Ge());break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#A=dismissTypeahead(e),this.#Ge());break}case`enter`:{let r=highlighted(),i=r!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(r).trimEnd():t.text;this.#A=void 0,this.#O.add(i),this.#k=!1,this.#De(),this.#M=STATUS.processing,isPromptControlCommand(i)?this.#je({kind:`command`,body:stripTerminalControls(i.trim()),live:!1}):(this.#Me(i),this.#ie=i),this.#oe(EMPTY_LINE),this.#Ge(),this.#xe(),e(i);break}case`ctrl-d`:t.text.length===0?interrupt():apply(deleteForward(t));break;case`ctrl-l`:case`ctrl-r`:this.#Ge();break;case`ctrl-c`:interrupt();break;default:break}},this.#be()})}#oe(e){this.#T=e.text,this.#E=e.cursor}async renderStream(e,t){this.#ve(t),this.#m.clear(),this.#k=!1,this.#j=!0,this.#M=STATUS.processing,this.#Ne(t?.submittedPrompt),this.#F=!1,this.#q=void 0,this.#J=void 0,this.#X=void 0,this.#Z=void 0,this.#Q=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#ke(),this.#Ge();let r=new Promise(e=>{this.#W=e});this.#B=e=>this.#Te(e),this.#be();let i={text:new Map,reasoning:new Map,tools:new Map,hasPendingToolResults:!1};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#F)break;this.#ze(t,n,i)}}catch(e){this.#Pe(`Error`,toErrorMessage(e))}finally{this.#W=void 0,this.#F&&e.abort?.(),this.#xe(),this.#Ae(),this.#j=!1,this.#M=this.#F?`Interrupted`:t?.continueSession?`Ready`:`Done`,this.#Re(),this.#Ge(),(this.#F||!t?.continueSession)&&this.#ye()}if(this.#F)throw interruptedError()}async readToolApproval(e,t){return this.#ve(t),this.#k=!1,this.#j=!1,this.#M=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#F=!1,this.#Ge(),await new Promise((t,n)=>{this.#B=r=>{switch(r.type){case`character`:{let n=r.value.toLowerCase();n===`y`?(this.#M=STATUS.processing,this.#xe(),this.#Ge(),t({approved:!0})):n===`n`&&(this.#M=STATUS.processing,this.#se(e.toolCallId),this.#xe(),this.#Ge(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#Ge();break;case`ctrl-c`:this.#F=!0,this.#ye(),n(interruptedError());break;default:break}},this.#be()})}async readInputQuestion(e,t){this.#ve(t),this.#k=!1,this.#j=!1,this.#F=!1,this.#D=void 0;let r=e.options??[],i=r.length>0,a=(e.allowFreeform===!0||!i)&&i,o=r.length+ +!!a,s=questionSectionId(e.requestId),c=i?`select`:`text`,l=0,u=``,isOnFreeformRow=()=>a&&l===r.length,renderSection=()=>{this.#Ie({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,l,this.#r),preformatted:!0,live:!0})},repaintStatus=()=>{if(c===`select`){let e=isOnFreeformRow()?`type`:`select`;this.#M=`↑/↓ move · enter ${e} · Ctrl+C quit`,this.#k=!1}else this.#k=!0,this.#oe(lineOf(u)),this.#M=``;this.#Ge()};renderSection(),c===`text`&&this.#Ee(),repaintStatus();let finalize=t=>{this.#Ie({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:` ${this.#r.colors.green(this.#r.glyph.success)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#k=!1,this.#M=STATUS.processing,this.#De(),this.#xe(),this.#Ge();let r={};return t.optionId!==void 0&&(r.optionId=t.optionId),t.text!==void 0&&(r.text=t.text),r};return await new Promise((t,n)=>{this.#B=a=>{if(a.type===`ctrl-c`){this.#F=!0,this.#De(),this.#ye(),n(interruptedError());return}if(a.type===`ctrl-r`){this.#Ge();return}if(c===`select`){switch(a.type){case`up`:o>0&&(l=(l-1+o)%o,renderSection(),repaintStatus());break;case`down`:o>0&&(l=(l+1)%o,renderSection(),repaintStatus());break;case`enter`:{if(isOnFreeformRow()){c=`text`,u=``,this.#Ee(),repaintStatus();break}let e=r[l];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}switch(a.type){case`character`:u+=a.value,this.#Oe(),repaintStatus();break;case`backspace`:u=u.slice(0,-1),this.#Oe(),repaintStatus();break;case`enter`:{let n=resolveQuestionText(u,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(i){if(u.length>0){u=``,this.#Oe(),repaintStatus();break}c=`select`,u=``,this.#k=!1,this.#De(),repaintStatus();break}u=``,this.#Oe(),repaintStatus();break;default:break}},this.#be()})}upsertSubagentStep(e){if(this.#o===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),r=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&r.length===0)){if(this.#Fe(e.callId,e.subagentName),this.#o===`collapsed`){this.#Ge();return}this.#Ie({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:r,live:!e.finalized}),this.#Ge()}}upsertSubagentTool(e){if(this.#o===`hidden`)return;if(this.#Fe(e.callId,e.subagentName),this.#o===`collapsed`){this.#Ge();return}let t=subagentToolStatus(e.status),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,depth:1,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:t,live:t===`running`||t===`approval`,expanded:this.#o===`full`,toolInput:e.input};e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=summarizeToolResult(e.output),r.toolOutput=e.output),this.#Ie(r),this.#Ge()}markChildToolCallId(e){this.#g.add(e);let t=this.#_.get(e);t!==void 0&&(this.#Le(t),this.#_.delete(e),this.#Ge())}#se(e){let t=this.#p.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#s===`hidden`)return;let t=e.state===`authorized`||e.state===`declined`||e.state===`failed`||e.state===`timed-out`;this.#Ie({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e),preformatted:!0,live:!t}),this.#Ge()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#C)return;let n=this.#C>0;this.#C=t,t>0?(this.#M=STATUS.connectionAuth,this.#Ge()):n&&(this.#M=STATUS.processing,this.#Ge())}setVercelStatus(e){this.#w=e,this.#Ge()}reset(){this.#f=[],this.#p.clear(),this.#m.clear(),this.#S=void 0,this.#x.length=0,this.#h.length=0,this.#b=!1,this.#g.clear(),this.#_.clear(),this.#v.clear(),this.#ie=void 0,this.#ne=void 0,this.#C=0,this.#q=void 0,this.#J=void 0,this.#X=void 0,this.#Z=void 0,this.#Q=void 0,this.#P&&(this.#n.clearAll(),this.#Ge())}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#ve(),this.#je({kind:`notice`,body:t,live:!1}),this.#Ge())}renderSetupWarning(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#ve(),this.#je({kind:`warning`,body:t,live:!1}),this.#Ge())}renderCommandResult(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#ve(),this.#je({kind:`result`,body:t,live:!1}),this.#Ge())}#ce(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``,this.#ae={title:stripTerminalControls(e),lines:[],outputBuffer:[]},this.#ke(),this.#Ge()}#le(e){let t=this.#ae;if(t!==void 0){if(this.#ae=void 0,this.#Ae(),e)for(let e of t.lines)(e.tone===`warning`||e.tone===`error`)&&this.#je({kind:`flow`,title:e.tone,body:e.text,live:!1});this.#Ge()}}async#ue(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t={options:e.options,submitRow:e.multiple},n={options:e.options,submitRow:e.multiple};e.initialValue!==void 0&&(n.defaultValue=e.initialValue),e.initialValues!==void 0&&(n.initialValues=e.initialValues);let r=initialSelectState(n),i,a=this.#pe(),panelState=()=>{let t={message:e.message,options:e.options,multiple:e.multiple,search:e.search,select:r};return e.placeholder!==void 0&&(t.placeholder=e.placeholder),e.layout!==void 0&&(t.layout=e.layout),e.notices!==void 0&&(t.notices=e.notices),i!==void 0&&(t.error=i),t};return a.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#Ge(),await new Promise(n=>{let settle=e=>{this.#me(),n(e)},apply=e=>{r=reduceSelect(r,e,t),i=void 0,this.#Ge()};this.#B=n=>{switch(n.type){case`ctrl-c`:case`escape`:settle(void 0);return;case`ctrl-r`:this.#Ge();return;case`up`:apply({type:`up`});return;case`down`:apply({type:`down`});return;case`backspace`:e.search&&apply({type:`backspace`});return;case`character`:if(e.multiple&&n.value===` `){apply({type:`toggle`});return}if(numbersSelectRows(e)&&/^[1-9]$/.test(n.value)){let t=Number(n.value)-1,a=e.options[t];a!==void 0&&!a.disabled&&!a.locked&&(r={...r,cursor:t},i=void 0,this.#Ge());return}if(e.search){for(let e of n.value)e>=` `&&e!==``&&(r=reduceSelect(r,{type:`char`,char:e},t));i=void 0,this.#Ge()}return;case`enter`:{let t=e.search?filterOptions(e.options,r.filter):[...e.options];if(e.multiple){if(r.cursor===submitRowIndex(t)){if(e.required&&r.selected.size===0){i=`Select at least one option, then submit.`,this.#Ge();return}settle(orderedSelection(e.options,r.selected));return}apply({type:`toggle`});return}let n=selectValueAtCursor(t,r.cursor);if(n===void 0){i=`Type to match an option, then press enter.`,this.#Ge();return}settle([n]);return}default:return}},this.#be()})}async#de(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t=lineOf(``),n,r=this.#pe();return r.question=r=>{let i={message:e.message,editor:t,mask:e.mask===!0};return e.placeholder!==void 0&&(i.placeholder=e.placeholder),n!==void 0&&(i.error=n),renderTextQuestion(i,this.#r,r,this.#I)},this.#Ee(),this.#Ge(),await new Promise(r=>{let settle=e=>{this.#De(),this.#me(),r(e)},apply=e=>{t=e,n=void 0,this.#Oe(),this.#Ge()};this.#B=r=>{switch(r.type){case`ctrl-c`:case`escape`:settle(void 0);return;case`ctrl-r`:this.#Ge();return;case`character`:apply(insert(t,r.value));return;case`backspace`:apply(backspace(t));return;case`delete`:apply(deleteForward(t));return;case`left`:apply(moveLeft(t));return;case`right`:apply(moveRight(t));return;case`home`:case`ctrl-a`:apply(moveHome(t));return;case`end`:case`ctrl-e`:apply(moveEnd(t));return;case`ctrl-k`:apply(killToEnd(t));return;case`ctrl-u`:apply(killToStart(t));return;case`ctrl-w`:apply(deleteWord(t));return;case`enter`:{let r=t.text.length>0?t.text:e.defaultValue??``,i=e.validate?.(r);if(i!==void 0){n=i,this.#Ge();return}settle(r);return}default:return}},this.#be()})}async#fe(e){this.#ve(),this.#k=!1,this.#j=!1,this.#M=``;let t=this.#pe();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#Ge(),await new Promise(e=>{this.#B=t=>{switch(t.type){case`enter`:case`escape`:case`ctrl-c`:this.#me(),e();return;case`ctrl-r`:this.#Ge();return;default:return}},this.#be()})}#pe(){return this.#ae===void 0&&(this.#ae={title:``,lines:[],outputBuffer:[]}),this.#ae}#me(){this.#ae!==void 0&&(this.#ae.question=void 0),this.#B=void 0,this.#xe(),this.#Ge()}#he(e){let t=e===void 0?void 0:stripTerminalControls(e);if(this.#ae!==void 0){this.#ae.status=t,t===void 0&&(this.#ae.preview=void 0),this.#Ge();return}if(t===void 0){this.#j=!1,this.#M=``,this.#Ae(),this.#Ge();return}this.#ve(),this.#j=!0,this.#M=t,this.#ke(),this.#Ge()}#ge(e,t){let r=stripTerminalControls(e);if(r.trim().length===0)return;let i=this.#ae;if(i!==void 0){if(i.preview=void 0,t===`warning`||t===`error`)for(let e of i.outputBuffer)i.lines.push({text:e,tone:`info`});i.outputBuffer=[],i.lines.push({text:r,tone:t}),this.#Ge();return}this.#ve(),this.#je({kind:`flow`,title:t,body:r,live:!1}),this.#Ge()}#_e(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let r=this.#ae;if(r===void 0){this.#ge(t,`info`);return}r.preview=t,r.outputBuffer.push(t),r.outputBuffer.length>8&&r.outputBuffer.shift(),this.#Ge()}shutdown(){this.#ye()}#ve(e){this.#N=e?.title??this.#N,this.#Y=e?.contextSize??this.#l,!this.#P&&(this.#P=!0,this.#n.reset(),this.#n.hideCursor(),this.#rt(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume()),this.#U=()=>this.#Ge(),this.#t.on(`resize`,this.#U))}#ye(){this.#xe(),this.#De(),this.#Ae(),this.#P&&=(this.#lt(),this.#Ge(),this.#n.clear(),this.#n.showCursor(),this.#it(),this.#n.newline(),this.#e.isTTY&&(this.#e.setRawMode?.(!1),this.#e.pause()),this.#U&&=(this.#t.off(`resize`,this.#U),void 0),!1)}#be(){this.#e.on(`data`,this.#Se)}#xe(){this.#e.off(`data`,this.#Se),this.#we(),this.#V=``,this.#B=void 0}#Se=e=>{this.#we(),this.#V+=e.toString(`utf8`),this.#Ce(),this.#V===`\x1B`&&(this.#H=setTimeout(()=>{this.#V===`\x1B`&&(this.#V=``,this.#B?.({type:`escape`}))},30),this.#H.unref?.())};#Ce(){for(;this.#V.length>0;){let e=nextKey(this.#V);if(e.incomplete)return;this.#V=this.#V.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#B?.(e.key)}}#we(){this.#H&&=(clearTimeout(this.#H),void 0)}#Te(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#Ge();break;case`ctrl-c`:this.#F=!0,this.#W?.();break;default:break}}#Ee(){this.#De(),this.#Oe(),this.#R=setInterval(()=>{this.#I=!this.#I,this.#Ge()},500),this.#R.unref?.()}#De(){this.#R&&=(clearInterval(this.#R),void 0),this.#I=!0}#Oe(){this.#I=!0}#ke(){this.#Ae(),this.#z=setInterval(()=>{this.#L+=1,this.#Ge()},90),this.#z.unref?.()}#Ae(){this.#z&&=(clearInterval(this.#z),void 0)}#je(e){e.id!==this.#ne?.id&&this.#lt(),this.#f.push(e),e.id&&this.#p.set(e.id,e)}#Me(e){this.#je({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#Ge()}#Ne(e){if(e!=null){if(this.#ie===e){this.#ie=void 0;return}this.#je({kind:`user`,body:stripTerminalControls(e),live:!1})}}#Pe(e,t,r){let i={kind:`error`,title:stripTerminalControls(e),body:stripTerminalControls(t),live:!1};r!==void 0&&(i.detail=stripTerminalControls(r)),this.#je(i),this.#Ge()}#Fe(e,t){this.#v.has(e)||(this.#v.add(e),this.#je({id:subagentHeaderId(e),kind:`subagent`,title:stripTerminalControls(t),live:!1}))}#Ie(e){if(e.id&&this.#m.has(e.id))return;let t=e.id?this.#p.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#je(e)}#Le(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#Re(){for(let e of this.#f)e.status!==`approval`&&(e.live=!1)}#ze(e,t,r){switch(e.type){case`step-start`:this.#Be(r.hasPendingToolResults?STATUS.toolResults:STATUS.processing),r.hasPendingToolResults=!1;break;case`step-finish`:this.#We(e.usage),this.#Ge();break;case`assistant-delta`:{this.#Be(STATUS.streaming);let t=(r.text.get(e.id)??``)+stripTerminalControls(e.delta);r.text.set(e.id,t),this.#Ve(e.id,t,!0);break}case`assistant-complete`:{let t=r.text.get(e.id)??``,i=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;r.text.set(e.id,i),this.#Ve(e.id,i,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#Be(STATUS.streaming);let i=(r.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);r.reasoning.set(e.id,i),this.#He(e.id,i,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let n=r.reasoning.get(e.id)??``;this.#He(e.id,n,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#Be(STATUS.executingTools),this.#Ue({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,r);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;this.#Ue({...n,status:`approval`},t,r);break}case`tool-result`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;r.hasPendingToolResults=!0,this.#Be(STATUS.toolResults),this.#Ue({...n,output:e.output,status:`done`},t,r);break}case`tool-error`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;r.hasPendingToolResults=!0,this.#Be(STATUS.toolResults),this.#Ue({...n,errorText:e.errorText,status:`error`},t,r);break}case`error`:this.#Pe(`Error`,e.errorText,e.detail);break;case`finish`:this.#We(e.usage),this.#Ge();break}}#Be(e){let t=this.#C>0?STATUS.connectionAuth:e;this.#M!==t&&(this.#M=t,this.#Ge())}#Ve(e,t,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Ie({id:e,kind:`assistant`,body:i,live:r}),this.#Ge())}#He(e,t,r,i){let a=stripTerminalControls(t).trim();a.length!==0&&(this.#Ie({id:e,kind:`reasoning`,body:a,collapsed:collapseReasoning(i.reasoning,r),live:r}),this.#Ge())}#Ue(e,t,n){if(n.tools.set(e.toolCallId,e),this.#g.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#_.set(e.toolCallId,r),this.#Ie(renderNativeToolBlock(e,r,t.tools===`full`)),this.#Ge()}#We(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#q=(t??0)+(n??0)),this.#J=t??this.#J,this.#X=n??this.#X,this.#X!=null&&this.#Q!==void 0){let e=(Date.now()-this.#Q)/1e3;e>0&&(this.#Z=this.#X/e)}}#Ge(){if(this.#P){if(this.#G){this.#K=!0;return}this.#G=!0;try{do this.#K=!1,this.#Ke();while(this.#K)}finally{this.#G=!1}}}#Ke(){if(!this.#P)return;let e=this.#tt(),t=this.#Qe(e),n=Math.max(1,this.#nt()-t.length),r=[],i=this.#S;for(;this.#f.length>0&&this.#f[0].live===!1;){let t=this.#f.shift();if(this.#h.push(t),t.id&&(this.#m.add(t.id),this.#p.delete(t.id)),this.#dt(t))continue;let n=this.#Xe(t,e,i);i=previousBlockOf(t),this.#S=i,r.push(...n),this.#x.push(...n)}let a=[];for(let t of this.#f){if(this.#dt(t))continue;let n=this.#Xe(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)a.push({block:t,row:n[e]})}let o=[...clipLiveRows(a.map(e=>e.row),n,e,this.#r),...t];r.length>0?this.#n.flush(r,o):this.#n.update(o)}#qe(){if(!this.#P)return;let e=this.#tt(),t=this.#Qe(e),n=Math.max(1,this.#nt()-t.length),r=this.#S,i=[];for(let t of this.#f){if(this.#dt(t))continue;let n=this.#Xe(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#r),...t];this.#n.clearAll(),this.#n.flush([...this.#Ye(),...this.#x],a)}logDisplayMode(){return this.#d}setLogDisplayMode(e){e!==this.#d&&(this.#d=e,this.#Je(),this.#P&&this.#qe())}#Je(){let e=this.#tt();this.#x.length=0;let t;for(let n of this.#h){if(this.#dt(n))continue;let r=this.#Xe(n,e,t);t=previousBlockOf(n),this.#x.push(...r)}this.#S=t}#Ye(){let e=this.#y;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#tt()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#Xe(e,t,n){let r={spinner:this.#Ze()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#Ze(){return this.#r.spinner[this.#L%this.#r.spinner.length]??``}#Qe(e){let t=this.#r.colors,n=[``],r=this.#ae;if(r!==void 0){let t={title:r.title,lines:r.lines,frame:this.#Ze()};return r.question===void 0?(r.status!==void 0&&(t.status={text:r.status,frame:this.#Ze()}),r.preview!==void 0&&(t.preview=r.preview)):t.question=r.question(e),n.push(...renderFlowPanel(t,this.#r,e)),n}if(this.#k){this.#A!==void 0&&isTypeaheadOpen(this.#A)&&n.push(...renderCommandSuggestions(this.#A,this.#r,e));let r=Math.max(4,e-3),{before:i,after:a}=visibleLine({text:this.#T,cursor:this.#E},r,this.#r.glyph.ellipsis),o=isPromptControlCommand(this.#T),style=e=>o&&e.length>0?t.blue(e):e,s=this.#I?t.cyan(this.#r.glyph.caret):` `,l=this.#T.length===0&&this.#D!==void 0?`${s}${t.dim(this.#D)}`:`${style(i)}${s}${style(a)}`;return n.push(clip(`${t.cyan(this.#r.glyph.prompt)} ${l}`,e)),this.#$e(n,e),n}let i=this.#j?t.yellow(this.#Ze()):t.dim(this.#r.glyph.dot),a=this.#M.length>0?this.#M:`Ready`,o=this.#j?t.dim(a):a,s=this.#et(),l=s?`${i} ${o} ${t.dim(this.#r.glyph.dot)} ${s}`:`${i} ${o}`;return n.push(clip(l,e)),this.#$e(n,e),n}#$e(e,t){let n={theme:this.#r,width:t},r=this.#y?.info?.agent.model.id;r!==void 0&&(n.model=r);let i={inputTokens:this.#J??0,outputTokens:this.#X??0};this.#Y!==void 0&&(i.contextSize=this.#Y),n.tokens=formatTokenFlow(i,this.#r.glyph),this.#w!==void 0&&(n.vercel=this.#w);let a=buildStatusLine(n);a!==void 0&&e.push(a)}#et(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#q,outputTokens:this.#X,tokensPerSecond:this.#Z},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#tt(){return Math.max(20,this.#t.columns||80)}#nt(){return Math.max(8,this.#t.rows||24)}#rt(){if(this.#$!==void 0||!this.#u)return;this.#ee=``,this.#te=``;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.#at(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#$=()=>{e(),t()}}#it(){let e=this.#$;e!==void 0&&(this.#$=void 0,e(),this.#ee.length>0&&(this.#ut(`stdout`)&&process.stdout.write(`${this.#ee}\n`),this.#ee=``),this.#te.length>0&&(this.#ut(`stderr`)&&process.stderr.write(`${this.#te}\n`),this.#te=``))}#at(e,n){let r=(e===`stdout`?this.#ee:this.#te)+n,i=r.lastIndexOf(`
|
|
3
|
-
`),a=i===-1?r:r.slice(i+1);if(e===`stdout`?this.#ee=a:this.#te=a,i===-1)return;let o=stripAnsi(r.slice(0,i)).replace(/\s+$/u,``);o.trim().length!==0&&(e===`stdout`?this.#ot(o):this.#je({kind:`log`,title:e,body:o,live:!1}),this.#Ge())}#ot(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
|
|
4
|
-
`);
|
|
5
|
-
`)
|
|
1
|
+
import{sliceVisible,stripAnsi,stripTerminalControls,visibleLength}from"./terminal-text.js";import{summarizeToolArgs,summarizeToolResult}from"./tool-format.js";import{buildAgentHeader}from"./agent-header.js";import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{renderBlockLines}from"./blocks.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{interruptedError}from"./errors.js";import{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,lineOf,visibleLine}from"./line-editor.js";import{LiveRegion}from"./live-region.js";import{renderAcknowledgeQuestion,renderFlowPanel,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{reduceSetupSelectInput,setupSelectionIntent}from"./setup-selection-input.js";import{formatAssistantResponseStats,formatTokenFlow,nextKey,stripPromptControlCharacters,takeUntil}from"./stream-format.js";import{toErrorMessage}from"#shared/errors.js";import{initialSelectState,reduceSelect,selectValueAtCursor}from"#setup/cli/select-state.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";function isMultiSelectRequest(e){return e.kind===`multi`||e.kind===`searchable-multi`}function moveActionCursor(e,t,n){return n===0?void 0:e===void 0?t===`down`?0:n-1:(e+(t===`down`?1:-1)+n)%n}function completedTurnStatus(e,t){return e?`Interrupted`:t?`Ready`:`Done`}const STATUS={processing:`Working…`,toolResults:`Reading results…`,streaming:`Responding…`,executingTools:`Running tools…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f=[];#p=new Map;#m=new Set;#h=[];#g=new Set;#_=new Map;#v=new Set;#y;#b=!1;#x;#S=[];#C;#w=0;#T;#E=``;#D=0;#O;#k=new PromptHistory;#A=!1;#j;#M=!1;#N=STATUS.processing;#P=`Eve`;#F=!1;#I=!1;#L=!0;#R=0;#z;#B;#V;#H=``;#U;#W;#G;#K=!1;#q=!1;#J;#Y;#X;#Z;#Q;#$;#ee;#te=``;#ne=``;#re;#ie=0;#ae;#oe;#se;#ce;setupFlow={begin:e=>this.#de(e),end:e=>this.#fe(e?.preserveDiagnostics??!0),readSelect:e=>this.#pe(e),readEditableSelect:e=>this.#he(e),readText:e=>this.#ge(e),readAcknowledge:e=>this.#_e(e),readChoice:e=>this.#me(e),setStatus:e=>this.#Te(e),renderLine:(e,t)=>this.#Ee(e,t),renderOutput:e=>this.#De(e),waitForInterrupt:()=>this.#Se()};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#i=e?.tools??`auto-collapsed`,this.#a=e?.reasoning??`full`,this.#o=e?.subagents??`auto-collapsed`,this.#s=e?.connectionAuth??`full`,this.#c=e?.assistantResponseStats??`tokensPerSecond`,this.#l=e?.contextSize,this.#X=e?.contextSize,this.#u=e?.captureForeignOutput??this.#t===process.stdout,this.#d=e?.logs??`none`}renderAgentHeader(e){this.#P=e.name,this.#y=e,this.#Oe();let t=this.#ot().join(`
|
|
2
|
+
`);if(this.#b){t!==this.#x&&(this.#x=t,this.#Ve({kind:`agent-header`,body:t,live:!1})),this.#nt();return}this.#b=!0,this.#x=t,this.#n.flush(this.#ot(),[])}async readPrompt(e){this.#Oe(e),this.#A=!0,this.#M=!1,this.#N=``,this.#O=`Type to chat ${this.#r.glyph.dot} / for commands`;let t=lineOf(stripPromptControlCharacters(e?.initialDraft??``));return this.#k.begin(t.text),this.#le(t),this.#j=typeaheadFor(PROMPT_COMMANDS,t.text),this.#Ie(),this.#nt(),await new Promise((e,r)=>{let apply=e=>{t=e,this.#Re(),this.#le(t),this.#j=typeaheadFor(PROMPT_COMMANDS,e.text,this.#j),this.#nt()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#j=void 0,this.#Le(),this.#ke(),r(interruptedError())},suggestions=()=>this.#j!==void 0&&isTypeaheadOpen(this.#j)?this.#j:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#V=r=>{let i=applyLineEditorKey(t,r);if(i!==void 0){apply(i);return}switch(r.type){case`up`:{let e=suggestions();e===void 0?recall(this.#k.previous(t.text)):(this.#j=moveTypeaheadSelection(e,-1),this.#nt());break}case`down`:{let e=suggestions();e===void 0?recall(this.#k.next()):(this.#j=moveTypeaheadSelection(e,1),this.#nt());break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#j=dismissTypeahead(e),this.#nt());break}case`enter`:{let r=highlighted(),i=r!==void 0&&parsePromptCommand(t.text)===null?typeaheadCompletion(r).trimEnd():t.text;this.#j=void 0,this.#k.add(i),this.#A=!1,this.#Le(),this.#N=STATUS.processing,isPromptControlCommand(i)?this.#Ve({kind:`command`,body:stripTerminalControls(i.trim()),live:!1}):(this.#He(i),this.#ae=i),this.#le(EMPTY_LINE),this.#nt(),this.#je(),e(i);break}case`ctrl-d`:t.text.length===0?interrupt():apply(deleteForward(t));break;case`ctrl-l`:case`ctrl-r`:this.#nt();break;case`ctrl-c`:interrupt();break;default:break}},this.#Ae()})}#le(e){this.#E=e.text,this.#D=e.cursor}async renderStream(e,t){this.#Oe(t),this.#m.clear(),this.#A=!1,this.#M=!0,this.#N=STATUS.processing,this.#Ue(t?.submittedPrompt),this.#I=!1,this.#J=void 0,this.#Y=void 0,this.#Z=void 0,this.#Q=void 0,this.#$=Date.now();let n={tools:t?.tools??this.#i,reasoning:t?.reasoning??this.#a,assistantResponseStats:t?.assistantResponseStats??this.#c};this.#ze(),this.#nt();let r=new Promise(e=>{this.#G=e});this.#V=e=>this.#Fe(e),this.#Ae();let i={text:new Map,reasoning:new Map,tools:new Map,hasPendingToolResults:!1};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#I)break;this.#Ye(t,n,i)}}catch(e){this.#We(`Error`,toErrorMessage(e))}finally{this.#G=void 0,this.#I&&e.abort?.(),this.#je(),this.#Be(),this.#M=!1,this.#N=completedTurnStatus(this.#I,t?.continueSession===!0),this.#Je(),this.#nt(),(this.#I||!t?.continueSession)&&this.#ke()}if(this.#I)throw interruptedError()}async readToolApproval(e,t){return this.#Oe(t),this.#A=!1,this.#M=!1,this.#N=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#I=!1,this.#nt(),await new Promise((t,n)=>{this.#V=r=>{switch(r.type){case`character`:{let n=r.value.toLowerCase();n===`y`?(this.#N=STATUS.processing,this.#je(),this.#nt(),t({approved:!0})):n===`n`&&(this.#N=STATUS.processing,this.#ue(e.toolCallId),this.#je(),this.#nt(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#nt();break;case`ctrl-c`:this.#I=!0,this.#ke(),n(interruptedError());break;default:break}},this.#Ae()})}async readInputQuestion(e,t){this.#Oe(t),this.#A=!1,this.#M=!1,this.#I=!1,this.#O=void 0;let r=e.options??[],i=r.length>0,a=(e.allowFreeform===!0||!i)&&i,o=r.length+ +!!a,s=questionSectionId(e.requestId),c=i?`select`:`text`,l=0,u=``,isOnFreeformRow=()=>a&&l===r.length,renderSection=()=>{this.#Ke({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,l,this.#r),preformatted:!0,live:!0})},repaintStatus=()=>{if(c===`select`){let e=isOnFreeformRow()?`type`:`select`;this.#N=`↑/↓ move · enter ${e} · Ctrl+C quit`,this.#A=!1}else this.#A=!0,this.#le(lineOf(u)),this.#N=``;this.#nt()};renderSection(),c===`text`&&this.#Ie(),repaintStatus();let finalize=t=>{this.#Ke({id:s,kind:`question`,title:stripTerminalControls(e.prompt),body:` ${this.#r.colors.green(this.#r.glyph.success)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#A=!1,this.#N=STATUS.processing,this.#Le(),this.#je(),this.#nt();let r={};return t.optionId!==void 0&&(r.optionId=t.optionId),t.text!==void 0&&(r.text=t.text),r};return await new Promise((t,n)=>{this.#V=a=>{if(a.type===`ctrl-c`){this.#I=!0,this.#Le(),this.#ke(),n(interruptedError());return}if(a.type===`ctrl-r`){this.#nt();return}if(c===`select`){switch(a.type){case`up`:o>0&&(l=(l-1+o)%o,renderSection(),repaintStatus());break;case`down`:o>0&&(l=(l+1)%o,renderSection(),repaintStatus());break;case`enter`:{if(isOnFreeformRow()){c=`text`,u=``,this.#Ie(),repaintStatus();break}let e=r[l];e&&t(finalize({optionId:e.id,label:e.label}));break}default:break}return}switch(a.type){case`character`:u+=a.value,this.#Re(),repaintStatus();break;case`backspace`:u=u.slice(0,-1),this.#Re(),repaintStatus();break;case`enter`:{let n=resolveQuestionText(u,e);if(n===void 0)break;t(finalize(n));break}case`escape`:if(i){if(u.length>0){u=``,this.#Re(),repaintStatus();break}c=`select`,u=``,this.#A=!1,this.#Le(),repaintStatus();break}u=``,this.#Re(),repaintStatus();break;default:break}},this.#Ae()})}upsertSubagentStep(e){if(this.#o===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),r=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&r.length===0)){if(this.#Ge(e.callId,e.subagentName),this.#o===`collapsed`){this.#nt();return}this.#Ke({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,depth:1,reasoning:t,body:r,live:!e.finalized}),this.#nt()}}upsertSubagentTool(e){if(this.#o===`hidden`)return;if(this.#Ge(e.callId,e.subagentName),this.#o===`collapsed`){this.#nt();return}let t=subagentToolStatus(e.status),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,depth:1,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:t,live:t===`running`||t===`approval`,expanded:this.#o===`full`,toolInput:e.input};e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=summarizeToolResult(e.output),r.toolOutput=e.output),this.#Ke(r),this.#nt()}markChildToolCallId(e){this.#g.add(e);let t=this.#_.get(e);t!==void 0&&(this.#qe(t),this.#_.delete(e),this.#nt())}#ue(e){let t=this.#p.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#s===`hidden`)return;let t=e.state===`authorized`||e.state===`declined`||e.state===`failed`||e.state===`timed-out`;this.#Ke({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e),preformatted:!0,live:!t}),this.#nt()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#w)return;let n=this.#w>0;this.#w=t,t>0?(this.#N=STATUS.connectionAuth,this.#nt()):n&&(this.#N=STATUS.processing,this.#nt())}setVercelStatus(e){this.#T=e,this.#nt()}reset(){this.#f=[],this.#p.clear(),this.#m.clear(),this.#C=void 0,this.#S.length=0,this.#h.length=0,this.#b=!1,this.#x=void 0,this.#g.clear(),this.#_.clear(),this.#v.clear(),this.#ae=void 0,this.#re=void 0,this.#w=0,this.#J=void 0,this.#Y=void 0,this.#Z=void 0,this.#Q=void 0,this.#$=void 0,this.#F&&(this.#n.clearAll(),this.#nt())}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Oe(),this.#Ve({kind:`notice`,body:t,live:!1}),this.#nt())}renderSetupWarning(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Oe(),this.#Ve({kind:`warning`,body:t,live:!1}),this.#nt())}renderCommandResult(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Oe(),this.#Ve({kind:`result`,body:t,live:!1}),this.#nt())}#de(e){this.#Oe(),this.#A=!1,this.#M=!1,this.#N=``,this.#oe={title:stripTerminalControls(e),lines:[],outputBuffer:[]},this.#ze(),this.#nt()}#fe(e){this.#se=void 0,this.#we();let t=this.#oe;if(t!==void 0){if(this.#oe=void 0,this.#Be(),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.#Ve({kind:`flow`,title:`info`,body:e.join(`
|
|
3
|
+
`),live:!1}),this.#Ve({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#nt()}}async#pe(e){let t=this.#ve(),n=isMultiSelectRequest(e),r={options:e.options,submitRow:n};`initialValue`in e&&e.initialValue!==void 0&&(r.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(r.initialValues=e.initialValues);let i=initialSelectState(r),a,o=e.notices;if(e.kind===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));o=[...e.notices??[],...r],t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,select:i};return o!==void 0&&o.length>0&&(t.notices=o),a!==void 0&&(t.error=a),t};return t.question=e=>renderSelectQuestion(panelState(),this.#r,e),this.#nt(),await this.#xe((t,r)=>{let o={key:t,options:e.options,select:i},s=reduceSetupSelectInput(n?{...o,kind:e.kind,required:e.required}:{...o,kind:e.kind});switch(s.kind){case`cancel`:r(void 0);return;case`repaint`:this.#nt();return;case`update`:i=s.select,a=void 0,this.#nt();return;case`submit`:r(s.values);return;case`error`:a=s.message,this.#nt();return;case`ignore`:return}}).promise}#me(e){this.#Oe();let t=this.#ye();t.status=e.status;let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#r,t),this.#nt();let r=this.#xe((t,r)=>{let i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#nt();return;case`repaint`:this.#nt();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#he(e){let t=this.#ve(),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`editable`,message:e.message,options:e.options,select:r,edit:{optionValue:e.editable.value,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint,caretVisible:this.#L}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#r,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?(i.text.length===0&&(i=lineOf(e.editable.defaultValue)),this.#Ie()):(i=lineOf(``),this.#Le())};return syncEditableRow(),this.#nt(),await this.#xe((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#Re(),this.#nt()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#nt()},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.#nt();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t);switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#nt();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Le()).promise}async#ge(e){let t=this.#ve(),n=lineOf(``),r;return t.question=t=>{let i={message:e.message,editor:n,mask:e.mask===!0};return e.placeholder!==void 0&&(i.placeholder=e.placeholder),e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#r,t,this.#L)},this.#Ie(),this.#nt(),await this.#xe((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Re(),this.#nt()},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.#nt();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#nt();return}i(t);return}default:return}},()=>this.#Le()).promise}async#_e(e){let t=this.#ve();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#r,t),this.#nt(),await this.#xe((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#nt();return;default:return}}).promise}#ve(){return this.#Oe(),this.#A=!1,this.#M=!1,this.#N=``,this.#ye()}#ye(){return this.#oe===void 0&&(this.#oe={title:``,lines:[],outputBuffer:[]}),this.#oe}#be(){this.#oe!==void 0&&(this.#oe.question=void 0,this.#oe.hideLinesWhileQuestion=!1),this.#V=void 0,this.#je(),this.#Ce(),this.#nt()}#xe(e,t){let n=!1,r,i=new Promise(e=>{r=e}),settle=e=>{n||(n=!0,t?.(),this.#be(),r(e))};return this.#V=t=>e(t,settle),this.#Ae(),{promise:i,settle}}#Se(){let e,t=new Promise(t=>{e=t});return this.#se=e,this.#Ce(),{promise:t,dispose:()=>{this.#se===e&&(this.#se=void 0,this.#we())}}}#Ce(){if(this.#se===void 0)return;let consumer=e=>{if(e.type===`ctrl-c`||e.type===`escape`){let e=this.#se;this.#se=void 0,this.#we(),e?.();return}e.type===`ctrl-r`&&this.#nt()};this.#ce=consumer,this.#V=consumer,this.#Ae()}#we(){this.#ce!==void 0&&(this.#V===this.#ce&&this.#je(),this.#ce=void 0)}#Te(e){let t=e===void 0?void 0:stripTerminalControls(e);if(this.#oe!==void 0){this.#oe.status=t,t===void 0&&(this.#oe.preview=void 0),this.#nt();return}if(t===void 0){this.#M=!1,this.#N=``,this.#Be(),this.#nt();return}this.#Oe(),this.#M=!0,this.#N=t,this.#ze(),this.#nt()}#Ee(e,t){let r=stripTerminalControls(e);if(r.trim().length===0)return;let i=this.#oe;if(i!==void 0){if(i.preview=void 0,t===`warning`||t===`error`)for(let e of i.outputBuffer)i.lines.push({text:e,tone:`info`,evidence:!0});i.outputBuffer=[],i.lines.push({text:r,tone:t}),this.#nt();return}this.#Oe(),this.#Ve({kind:`flow`,title:t,body:r,live:!1}),this.#nt()}#De(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let r=this.#oe;if(r===void 0){this.#Ee(t,`info`);return}r.preview=t,r.outputBuffer.push(t),r.outputBuffer.length>40&&r.outputBuffer.shift(),this.#nt()}shutdown(){this.#ke()}#Oe(e){this.#P=e?.title??this.#P,this.#X=e?.contextSize??this.#l,!this.#F&&(this.#F=!0,this.#n.reset(),this.#n.hideCursor(),this.#mt(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume()),this.#W=()=>this.#nt(),this.#t.on(`resize`,this.#W))}#ke(){this.#je(),this.#Le(),this.#Be(),this.#F&&=(this.#bt(),this.#nt(),this.#n.clear(),this.#n.showCursor(),this.#ht(),this.#n.newline(),this.#e.isTTY&&(this.#e.setRawMode?.(!1),this.#e.pause()),this.#W&&=(this.#t.off(`resize`,this.#W),void 0),!1)}#Ae(){this.#e.off(`data`,this.#Me),this.#e.on(`data`,this.#Me)}#je(){this.#e.off(`data`,this.#Me),this.#Pe(),this.#H=``,this.#V=void 0}#Me=e=>{this.#Pe(),this.#H+=e.toString(`utf8`),this.#Ne(),this.#H===`\x1B`&&(this.#U=setTimeout(()=>{this.#H===`\x1B`&&(this.#H=``,this.#V?.({type:`escape`}))},30),this.#U.unref?.())};#Ne(){for(;this.#H.length>0;){let e=nextKey(this.#H);if(e.incomplete)return;this.#H=this.#H.slice(e.consumed),e.key&&e.key.type!==`ignore`&&this.#V?.(e.key)}}#Pe(){this.#U&&=(clearTimeout(this.#U),void 0)}#Fe(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#nt();break;case`ctrl-c`:this.#I=!0,this.#G?.();break;default:break}}#Ie(){this.#Le(),this.#Re(),this.#z=setInterval(()=>{this.#L=!this.#L,this.#nt()},500),this.#z.unref?.()}#Le(){this.#z&&=(clearInterval(this.#z),void 0),this.#L=!0}#Re(){this.#L=!0}#ze(){this.#Be(),this.#B=setInterval(()=>{this.#R+=1,this.#nt()},90),this.#B.unref?.()}#Be(){this.#B&&=(clearInterval(this.#B),void 0)}#Ve(e){e.id!==this.#re?.id&&this.#bt(),this.#f.push(e),e.id&&this.#p.set(e.id,e)}#He(e){this.#Ve({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#nt()}#Ue(e){if(e!=null){if(this.#ae===e){this.#ae=void 0;return}this.#Ve({kind:`user`,body:stripTerminalControls(e),live:!1})}}#We(e,t,r){let i={kind:`error`,title:stripTerminalControls(e),body:stripTerminalControls(t),live:!1};r!==void 0&&(i.detail=stripTerminalControls(r)),this.#Ve(i),this.#nt()}#Ge(e,t){this.#v.has(e)||(this.#v.add(e),this.#Ve({id:subagentHeaderId(e),kind:`subagent`,title:stripTerminalControls(t),live:!1}))}#Ke(e){if(e.id&&this.#m.has(e.id))return;let t=e.id?this.#p.get(e.id):void 0;if(t){Object.assign(t,e);return}this.#Ve(e)}#qe(e){this.#f=this.#f.filter(t=>t.id!==e),this.#p.delete(e)}#Je(){for(let e of this.#f)e.status===`approval`||e.status===`running`||(e.live=!1)}#Ye(e,t,r){switch(e.type){case`step-start`:this.#Xe(r.hasPendingToolResults?STATUS.toolResults:STATUS.processing),r.hasPendingToolResults=!1;break;case`step-finish`:this.#tt(e.usage),this.#nt();break;case`assistant-delta`:{this.#Xe(STATUS.streaming);let t=(r.text.get(e.id)??``)+stripTerminalControls(e.delta);r.text.set(e.id,t),this.#Ze(e.id,t,!0);break}case`assistant-complete`:{let t=r.text.get(e.id)??``,i=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;r.text.set(e.id,i),this.#Ze(e.id,i,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;this.#Xe(STATUS.streaming);let i=(r.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);r.reasoning.set(e.id,i),this.#Qe(e.id,i,!0,t);break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let n=r.reasoning.get(e.id)??``;this.#Qe(e.id,n,!1,t);break}case`tool-call`:if(t.tools===`hidden`)break;this.#Xe(STATUS.executingTools),this.#$e({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,r);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let n=r.tools.get(e.toolCallId);if(n===void 0)break;this.#$e({...n,status:`approval`},t,r);break}case`tool-result`:{if(t.tools===`hidden`)break;let n=this.#et(e.toolCallId,r);if(n===void 0)break;r.hasPendingToolResults=!0,this.#Xe(STATUS.toolResults),this.#$e({...n,output:e.output,status:`done`},t,r);break}case`tool-error`:{if(t.tools===`hidden`)break;let n=this.#et(e.toolCallId,r);if(n===void 0)break;r.hasPendingToolResults=!0,this.#Xe(STATUS.toolResults),this.#$e({...n,errorText:e.errorText,status:`error`},t,r);break}case`error`:this.#We(`Error`,e.errorText,e.detail);break;case`finish`:this.#tt(e.usage),this.#nt();break}}#Xe(e){let t=this.#w>0?STATUS.connectionAuth:e;this.#N!==t&&(this.#N=t,this.#nt())}#Ze(e,t,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Ke({id:e,kind:`assistant`,body:i,live:r}),this.#nt())}#Qe(e,t,r,i){let a=stripTerminalControls(t).trim();a.length!==0&&(this.#Ke({id:e,kind:`reasoning`,body:a,collapsed:collapseReasoning(i.reasoning,r),live:r}),this.#nt())}#$e(e,t,n){if(n.tools.set(e.toolCallId,e),this.#g.has(e.toolCallId))return;let r=toolSectionId(e.toolCallId);this.#_.set(e.toolCallId,r),this.#Ke(renderNativeToolBlock(e,r,t.tools===`full`)),this.#nt()}#et(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#_.get(e)??toolSectionId(e),i=this.#p.get(r);if(!(i===void 0||i.kind!==`tool`))return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.title??`tool`}}#tt(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#J=(t??0)+(n??0)),this.#Y=t??this.#Y,this.#Z=n??this.#Z,this.#Z!=null&&this.#$!==void 0){let e=(Date.now()-this.#$)/1e3;e>0&&(this.#Q=this.#Z/e)}}#nt(){if(this.#F){if(this.#K){this.#q=!0;return}this.#K=!0;try{do this.#q=!1,this.#rt();while(this.#q)}finally{this.#K=!1}}}#rt(){if(!this.#F)return;let e=this.#ft(),t=this.#lt(e),n=Math.max(1,this.#pt()-t.length),r=[],i=this.#C;for(;this.#f.length>0&&this.#f[0].live===!1;){let t=this.#f.shift();if(this.#h.push(t),t.id&&(this.#m.add(t.id),this.#p.delete(t.id)),this.#St(t))continue;let n=this.#st(t,e,i);i=previousBlockOf(t),this.#C=i,r.push(...n),this.#S.push(...n)}let a=[];for(let t of this.#f){if(this.#St(t))continue;let n=this.#st(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)a.push({block:t,row:n[e]})}let o=[...clipLiveRows(a.map(e=>e.row),n,e,this.#r),...t];r.length>0?this.#n.flush(r,o):this.#n.update(o)}#it(){if(!this.#F)return;let e=this.#ft(),t=this.#lt(e),n=Math.max(1,this.#pt()-t.length),r=this.#C,i=[];for(let t of this.#f){if(this.#St(t))continue;let n=this.#st(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#r),...t];this.#n.clearAll(),this.#n.flush([...this.#ot(),...this.#S],a)}logDisplayMode(){return this.#d}setLogDisplayMode(e){e!==this.#d&&(this.#d=e,this.#at(),this.#F&&this.#it())}#at(){let e=this.#ft();this.#S.length=0;let t;for(let n of this.#h){if(this.#St(n))continue;let r=this.#st(n,e,t);t=previousBlockOf(n),this.#S.push(...r)}this.#C=t}#ot(){let e=this.#y;if(e===void 0)return[];let t={name:e.name,theme:this.#r,width:this.#ft()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#st(e,t,n){let r={spinner:this.#ct()};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#r,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#ct(){return this.#r.spinner[this.#R%this.#r.spinner.length]??``}#lt(e){let t=this.#r.colors,n=[``],r=this.#oe;if(r!==void 0){let t=this.#ct(),i;if(r.question!==void 0){let n=r.question(e);i={kind:`question`,rows:n},r.status!==void 0&&(i={kind:`question`,rows:n,status:{text:r.status,frame:t}})}else r.status===void 0?i=r.preview===void 0?{kind:`idle`,frame:t}:{kind:`preview`,text:r.preview,frame:t}:(i={kind:`status`,status:{text:r.status,frame:t}},r.preview!==void 0&&(i={kind:`status`,status:{text:r.status,frame:t},preview:r.preview}));let a={title:r.title,lines:r.hideLinesWhileQuestion===!0?[]:r.lines,content:i};return n.push(...renderFlowPanel(a,this.#r,e)),n}if(this.#A){let r=this.#j===void 0?void 0:inlineCommandHint(this.#j);r===void 0&&this.#j!==void 0&&isTypeaheadOpen(this.#j)&&n.push(...renderCommandSuggestions(this.#j,this.#r,e));let i=Math.max(4,e-3),{before:a,after:o}=visibleLine({text:this.#E,cursor:this.#D},i,this.#r.glyph.ellipsis),s=isPromptControlCommand(this.#E),style=e=>s&&e.length>0?t.blue(e):e,l=this.#L?t.cyan(this.#r.glyph.caret):` `,u=r?t.dim(` ${r}`):``,d=this.#E.length===0&&this.#O!==void 0?`${l}${t.dim(this.#O)}`:`${style(a)}${l}${style(o)}${u}`;return n.push(...promptInputRows(d,e,this.#r,!0)),this.#ut(n,e),n}let i=this.#M?t.yellow(this.#ct()):t.dim(this.#r.glyph.dot),a=this.#N.length>0?this.#N:`Ready`,o=this.#M?t.dim(a):a,s=this.#dt(),l=s?`${i} ${o} ${t.dim(this.#r.glyph.dot)} ${s}`:`${i} ${o}`;return n.push(clip(l,e)),this.#ut(n,e),n}#ut(e,t){let n={theme:this.#r,width:t},r=this.#y?.info?.agent.model.id;r!==void 0&&(n.model=r);let i=this.#y?.info?.agent.model.endpoint;i!==void 0&&(n.endpoint=i);let a=this.#Y??0,o=this.#Z??0;if(a>0||o>0){let e={inputTokens:a,outputTokens:o};this.#X!==void 0&&(e.contextSize=this.#X),n.tokens=formatTokenFlow(e,this.#r.glyph)}this.#T!==void 0&&(n.vercel=this.#T);let s=buildStatusLine(n);s!==void 0&&e.push(s)}#dt(){let e=this.#r.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#J,outputTokens:this.#Z,tokensPerSecond:this.#Q},this.#c);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#r.glyph.dot} `)):``}#ft(){return Math.max(20,this.#t.columns||80)}#pt(){return Math.max(8,this.#t.rows||24)}#mt(){if(this.#ee!==void 0||!this.#u)return;this.#te=``,this.#ne=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#gt(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#ee=()=>{e(),t()}}#ht(){let e=this.#ee;e!==void 0&&(this.#ee=void 0,e(),this.#te.length>0&&(this.#xt(`stdout`)&&process.stdout.write(`${this.#te}\n`),this.#te=``),this.#ne.length>0&&(this.#xt(`stderr`)&&process.stderr.write(`${this.#ne}\n`),this.#ne=``))}#gt(e,n){let r=(e===`stdout`?this.#te:this.#ne)+n,i=r.lastIndexOf(`
|
|
4
|
+
`),a=i===-1?r:r.slice(i+1);if(e===`stdout`?this.#te=a:this.#ne=a,i===-1)return;let o=stripAnsi(r.slice(0,i)).replace(/\s+$/u,``);o.trim().length!==0&&(e===`stdout`?this.#_t(o):this.#Ve({kind:`log`,title:e,body:o,live:!1}),this.#nt())}#_t(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
|
|
5
|
+
`);t=[],e.trim().length!==0&&this.#Ve({kind:`log`,title:`stdout`,body:e,live:!1})};for(let n of e.split(`
|
|
6
|
+
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#Ve({kind:`sandbox`,body:e,live:!1});continue}let r=parseDevRebuildLogLine(n.trimEnd());if(r===void 0){t.push(n);continue}flushPending(),this.#vt(r,n.trimEnd())}flushPending()}#vt(e,t){let n=this.#yt();if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#ie}`;this.#ie+=1,this.#re={id:r,summary:t},this.#Ve({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}if(n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind);return}this.#Ve({kind:`log`,title:`stdout`,body:t,live:!1})}#yt(){let e=this.#re;if(e===void 0)return;let t=this.#p.get(e.id);if(!(t===void 0||t.live!==!0))return{state:e,block:t}}#bt(){let e=this.#re;if(e===void 0)return;this.#re=void 0;let t=this.#p.get(e.id);t!==void 0&&(t.live=!1)}#xt(e){switch(this.#d){case`none`:return!1;case`stderr`:return e===`stderr`;case`all`:return!0}}#St(e){return e.kind===`log`?!this.#xt(e.title===`stderr`?`stderr`:`stdout`):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}async function*iterateTUIStream(e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}return}yield*e}function clip(t,n){return visibleLength(t)>n?sliceVisible(t,n):t}function promptInputRows(e,t,n,r){let i=n.colors;return[clip(`${r?i.cyan(n.glyph.prompt):i.dim(n.glyph.prompt)} ${r?e:i.dim(e)}`,t),``]}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function leadsWithGap(e,t){if(e.kind===`sandbox`&&t?.kind===`sandbox`)return!1;if(t?.kind===`sandbox`&&e.kind!==`sandbox`)return!0;if(e.kind===`log`&&t?.kind===`log`)return t.title!==e.title;if(t?.kind===`log`&&e.kind!==`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`subagent`:case`error`:case`notice`:case`question`:case`connection-auth`:case`sandbox`:case`log`:case`command`:case`warning`:case`flow`:case`agent-header`:return!0;default:return!1}}function parseSandboxLogLine(e){let t=e.trim();if(!t.startsWith(`Eve: `))return;let n=t.slice(5);return/\bsandbox\b/i.test(n)?n:void 0}function clipLiveRows(e,t,n,r){if(e.length<=t)return[...e];if(t<=1)return[clip(hiddenRowsMarker(e.length,r),n)];let i=t-1;return[clip(hiddenRowsMarker(e.length-i,r),n),...e.slice(e.length-i)]}function hiddenRowsMarker(e,t){let n=e.toLocaleString(),r=e===1?`row`:`rows`;return t.colors.dim(`${t.glyph.dot} ${t.glyph.ellipsis} ${n} earlier ${r} hidden while streaming`)}function collapseReasoning(e,t){switch(e){case`collapsed`:return!0;case`auto-collapsed`:return!t;default:return!1}}function renderNativeToolBlock(e,t,r){let o={id:t,kind:`tool`,title:stripTerminalControls(e.toolName),subtitle:summarizeToolArgs(e.input),status:e.status,live:e.status===`running`||e.status===`approval`,expanded:r,toolInput:e.input};return e.output===void 0?e.errorText!==void 0&&(o.result=stripTerminalControls(e.errorText)):(o.result=summarizeToolResult(e.output),o.toolOutput=e.output),o}function subagentToolStatus(e){switch(e){case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`}}function formatToolApprovalTitle(e){return stripTerminalControls(e.title??e.toolName)}function toolSectionId(e){return`tool:${e}`}function questionSectionId(e){return`question:${e}`}function subagentHeaderId(e){return`subagent:${e}:header`}function subagentStepSectionId(e,t){return`subagent:${e}:step:${t}`}function subagentToolSectionId(e,t){return`subagent:${e}:tool:${t}`}function connectionAuthSectionId(e){return`connection-auth:${e}`}function formatConnectionAuthContent(e){let t=[],r=stripTerminalControls(e.description);r.length>0&&t.push(r);let i=e.challenge;if(i?.url&&t.push(`URL: ${stripTerminalControls(i.url)}`),i?.userCode&&t.push(`Code: ${stripTerminalControls(i.userCode)}`),i?.expiresAt&&t.push(`Expires: ${stripTerminalControls(i.expiresAt)}`),i?.instructions&&t.push(stripTerminalControls(i.instructions)),e.reason!==void 0){let r=stripTerminalControls(e.reason);r.length>0&&t.push(`Reason: ${r}`)}return t.join(`
|
|
6
7
|
`)}function formatQuestionContent(e,t,r){let i=r.colors,a=[],o=e.options??[];if(o.length>0){for(let[e,s]of o.entries()){let o=stripTerminalControls(s.label),c=s.description===void 0?``:stripTerminalControls(s.description),l=c.length>0?` ${i.dim(`— ${c}`)}`:``,u=t===e,d=u?`${i.cyan(r.glyph.pointer)} `:` `,f=u?i.cyan(o):o;a.push(`${d}${f}${l}`)}if(e.allowFreeform===!0){let e=t===o.length,n=e?`${i.cyan(r.glyph.pointer)} `:` `,s=`Type your own answer`;a.push(`${n}${e?i.cyan(s):i.dim(s)}`)}}else a.push(i.dim(` (type your answer)`));return a.join(`
|
|
7
8
|
`)}function resolveQuestionText(e,t){let n=e.trim();if(n.length===0)return;let r=n.toLowerCase(),i=t.options??[];if(i.length>0){let e=matchQuestionOption(r,i);if(e!==void 0)return{optionId:e.id,label:e.label}}if(t.allowFreeform===!0||i.length===0)return{text:n,label:n}}function matchQuestionOption(e,t){let n=t.find(t=>t.id.toLowerCase()===e);if(n!==void 0)return n;let r=t.find(t=>t.label.toLowerCase()===e);if(r!==void 0)return r;let i=Number(e);if(Number.isInteger(i)&&i>0&&i<=t.length)return t[i-1]}export{TerminalRenderer};
|
|
@@ -56,8 +56,10 @@ export interface ThemeGlyphs {
|
|
|
56
56
|
connection: string;
|
|
57
57
|
/** `→` — separates a tool call from its summarized result. */
|
|
58
58
|
arrow: string;
|
|
59
|
-
/**
|
|
59
|
+
/** `▷` — selected-option marker in question lists. */
|
|
60
60
|
pointer: string;
|
|
61
|
+
/** `◦` — available, unselected option marker. */
|
|
62
|
+
option: string;
|
|
61
63
|
/** `❯` — the input prompt mark. */
|
|
62
64
|
prompt: string;
|
|
63
65
|
/** `⎿` — hangs a command's result under its invocation. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}[39m`}const UNICODE_GLYPHS={brand:`▲`,user:`▌`,reasoning:`○`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`◆`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer
|
|
1
|
+
function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}[39m`}const UNICODE_GLYPHS={brand:`▲`,user:`▌`,reasoning:`○`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`◆`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`▷`,option:`◦`,prompt:`❯`,elbow:`⎿`,hrule:`▔`,caret:`▏`,dot:`·`,ellipsis:`…`,tokens:`⁕`,arrowUp:`↑`,arrowDown:`↓`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,option:`.`,prompt:`>`,elbow:"`-",hrule:`=`,caret:`_`,dot:`-`,ellipsis:`...`,tokens:`*`,arrowUp:`^`,arrowDown:`v`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(i={}){let a=i.color??!0,o=i.unicode??!0;return{color:a,unicode:o,colors:{reset:ansi(0,0,a),bold:ansi(1,22,a),dim:ansi(2,22,a),italic:ansi(3,23,a),white:ansi(97,39,a),gray:ansi(90,39,a),cyan:ansi(36,39,a),green:ansi(32,39,a),red:ansi(31,39,a),yellow:ansi(33,39,a),magenta:ansi(35,39,a),blue:ansi(34,39,a),orange:ansi256(208,a)},glyph:o?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:o?UNICODE_SPINNER:ASCII_SPINNER}}function detectUnicode(e=process.env){let t=e.EVE_TUI_UNICODE;return t===`0`||t===`false`?!1:t===`1`||t===`true`?!0:e.TERM===`dumb`?!1:process.platform===`win32`?!!(e.WT_SESSION||e.TERM_PROGRAM===`vscode`):!0}export{createTheme,detectUnicode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WizardCancelledError}from"#setup/step.js";import{createSelectOptionCodec}from"#setup/cli/select-option-codec.js";function
|
|
1
|
+
import{WizardCancelledError}from"#setup/step.js";import{createSelectOptionCodec}from"#setup/cli/select-option-codec.js";function setupSelectRequest(e,t,n){let r={message:e.message,options:t},withNotices=t=>(e.notices!==void 0&&(t.notices=e.notices),t);if(e.multiple===!0){if(e.hintLayout!==void 0)throw Error(`Multi-select setup questions do not support a hint layout.`);let t;return e.search===!0?(t={...r,kind:`searchable-multi`,required:e.required??!1},e.placeholder!==void 0&&(t.placeholder=e.placeholder)):t={...r,kind:`multi`,required:e.required??!1},e.initialValues!==void 0&&(t.initialValues=e.initialValues.map(n)),withNotices(t)}if(e.search===!0&&e.hintLayout!==void 0)throw Error(`Searchable setup questions do not support a hint layout.`);let i;if(e.search===!0)i={...r,kind:`search`},e.placeholder!==void 0&&(i.placeholder=e.placeholder);else{let t=e.hintLayout===`inline`?`task-list`:e.hintLayout??`single`;i={...r,kind:t}}return e.initialValue!==void 0&&(i.initialValue=n(e.initialValue)),withNotices(i)}function createTuiPrompter(n){function guardCancel(t){if(t===void 0)throw new WizardCancelledError;return t}async function select(e){let r=createSelectOptionCodec(e.options),i=setupSelectRequest(e,r.options,r.encode),a=guardCancel(await n.readSelect(i)).map(e=>r.decode(e));if(e.multiple===!0)return a;let o=a[0];if(o===void 0)throw Error(`Single-select returned no option.`);return o}function line(e){return t=>n.renderLine(t,e)}return{async text(e){let t={message:e.message};return e.placeholder!==void 0&&(t.placeholder=e.placeholder),e.defaultValue!==void 0&&(t.defaultValue=e.defaultValue),e.validate!==void 0&&(t.validate=e.validate),e.notices!==void 0&&(t.notices=e.notices),guardCancel(await n.readText(t))},async password(e){let t={message:e.message,mask:!0};return e.validate!==void 0&&(t.validate=e.validate),guardCancel(await n.readText(t))},select,async selectEditable(e){let r=createSelectOptionCodec(e.options),i={value:r.encode(e.editable.value),defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint};e.editable.validate!==void 0&&(i.validate=e.editable.validate);let a={message:e.message,options:r.options,editable:i};e.initialValue!==void 0&&(a.initialValue=r.encode(e.initialValue));let o=guardCancel(await n.readEditableSelect(a)),s=r.decode(o.value);return o.kind===`edited`?{kind:`edited`,value:s,text:o.text}:{kind:`selected`,value:s}},async acknowledge(e){await n.readAcknowledge({message:e.message,lines:e.lines??[]})},awaitChoice(e){return n.readChoice(e)},note(e,t,r){let i=r?.tone===`success`?`success`:`warning`;t&&n.renderLine(t,i),n.renderLine(e,i)},intro(){},outro(){},log:{message:line(`info`),info:line(`info`),success:line(`success`),warning:line(`warning`),error:line(`error`),commandOutput:e=>n.renderOutput(e),section(e,t){n.renderLine(e,`info`);for(let e of t)n.renderLine(` ${e}`,`info`)},spinner(e){n.setStatus(e);let t=!1;return{stop(){t||(t=!0,n.setStatus(void 0))}}}}}}export{createTuiPrompter};
|
|
@@ -14,6 +14,12 @@ export interface RunDevelopmentTuiInput extends TuiDisplayOptions {
|
|
|
14
14
|
* Omitted for remote (`--url`) targets.
|
|
15
15
|
*/
|
|
16
16
|
readonly appRoot?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Text to seed the prompt input with after the UI launches. The buffer is
|
|
19
|
+
* editable and is not auto-submitted — the user presses Enter to send it.
|
|
20
|
+
* Applies to the first prompt only.
|
|
21
|
+
*/
|
|
22
|
+
readonly initialInput?: string;
|
|
17
23
|
}
|
|
18
24
|
/**
|
|
19
25
|
* Runs the `eve dev` terminal UI against the given server URL until the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createPromptCommandHandler}from"./prompt-command-handler.js";import{EveTUIRunner}from"./runner.js";import{toErrorMessage}from"#shared/errors.js";import{Client}from"#client/index.js";import{resolveDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{formatVercelAuthChallengeMessage,isVercelAuthChallenge}from"#services/dev-client/vercel-auth-error.js";async function runDevelopmentTui(t){let{serverUrl:n,appRoot:r,...
|
|
1
|
+
import{createPromptCommandHandler}from"./prompt-command-handler.js";import{EveTUIRunner}from"./runner.js";import{toErrorMessage}from"#shared/errors.js";import{Client}from"#client/index.js";import{resolveDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{formatVercelAuthChallengeMessage,isVercelAuthChallenge}from"#services/dev-client/vercel-auth-error.js";async function runDevelopmentTui(t){let{serverUrl:n,appRoot:r,initialInput:i,...a}=t,o=new Client(resolveDevelopmentClientOptions(n)),s={...a,session:o.session(),client:o,serverUrl:n,promptCommandHandler:createPromptCommandHandler({appRoot:r}),formatTransportError:e=>isVercelAuthChallenge(e)?formatVercelAuthChallengeMessage({serverUrl:n}):toErrorMessage(e)};r!==void 0&&(s.appRoot=r),i!==void 0&&(s.initialInput=i),await new EveTUIRunner(s).run()}export{runDevelopmentTui};
|
|
@@ -16,7 +16,7 @@ export type VercelStatusEffect = {
|
|
|
16
16
|
} | {
|
|
17
17
|
kind: "deployed";
|
|
18
18
|
} | {
|
|
19
|
-
kind: "
|
|
19
|
+
kind: "refresh-identity";
|
|
20
20
|
};
|
|
21
21
|
export interface VercelStatusTrackerOptions {
|
|
22
22
|
/** Absolute local application root holding the `.vercel` link directory. */
|
|
@@ -30,10 +30,10 @@ export interface VercelStatusTrackerOptions {
|
|
|
30
30
|
* Owns the Vercel segment of the dev TUI status line: one cached link
|
|
31
31
|
* identity and the session-scoped pending-deploy flag. The identity probe is
|
|
32
32
|
* network-bound (it shells `vercel api`), so it runs only at startup and
|
|
33
|
-
* after
|
|
33
|
+
* after provider setup or a /deploy — never on a poll. A linked directory
|
|
34
34
|
* whose `vercel` CLI call fails resolves to the raw project id as the name
|
|
35
|
-
* (see {@link detectProjectIdentity}); an unlinked one resolves to no
|
|
36
|
-
*
|
|
35
|
+
* (see {@link detectProjectIdentity}); an unlinked one resolves to no identity,
|
|
36
|
+
* which hides the segment.
|
|
37
37
|
*/
|
|
38
38
|
export interface VercelStatusTracker {
|
|
39
39
|
/** Fire-and-forget identity re-probe; stale resolutions are discarded. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{detectProjectIdentity}from"#setup/project-resolution.js";function createVercelStatusTracker(t){let n=t.detectIdentity??detectProjectIdentity,r,i=!1,a=0,o=!1,snapshot=()=>{let e={pendingDeploy:i};return r!==void 0&&(e.identity=r),e},emit=()=>{o||t.onChange(snapshot())},refreshIdentity=()=>{a+=1;let e=a;(async()=>{let i;try{i=await n(t.appRoot)}catch{return}o||e!==a||(r=i,emit())})()};return{refreshIdentity,applyEffect(e){switch(e.kind){case`channels-added`:i=!0,emit();return;case`deployed`:i=!1,emit(),refreshIdentity();return;case`
|
|
1
|
+
import{detectProjectIdentity}from"#setup/project-resolution.js";function createVercelStatusTracker(t){let n=t.detectIdentity??detectProjectIdentity,r,i=!1,a=0,o=!1,snapshot=()=>{let e={pendingDeploy:i};return r!==void 0&&(e.identity=r),e},emit=()=>{o||t.onChange(snapshot())},refreshIdentity=()=>{a+=1;let e=a;(async()=>{let i;try{i=await n(t.appRoot)}catch{return}o||e!==a||(r=i,emit())})()};return{refreshIdentity,applyEffect(e){switch(e.kind){case`channels-added`:i=!0,emit();return;case`deployed`:i=!1,emit(),refreshIdentity();return;case`refresh-identity`:refreshIdentity();return}},current:snapshot,dispose(){o=!0,a+=1}}}export{createVercelStatusTracker};
|
package/dist/src/cli/run.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface DevelopmentCliOptions {
|
|
|
8
8
|
connectionAuth?: TerminalPartDisplayMode;
|
|
9
9
|
contextSize?: number;
|
|
10
10
|
host?: string;
|
|
11
|
+
input?: string;
|
|
11
12
|
logs?: LogDisplayMode;
|
|
12
13
|
name?: string;
|
|
13
14
|
port?: number;
|
|
@@ -34,6 +35,7 @@ interface CliRuntimeDependencies {
|
|
|
34
35
|
runDevelopmentTui(input: {
|
|
35
36
|
serverUrl: string;
|
|
36
37
|
appRoot?: string;
|
|
38
|
+
initialInput?: string;
|
|
37
39
|
} & TuiDisplayOptions): Promise<void>;
|
|
38
40
|
runEvalCommand(evalIds: readonly string[], options: EvalCliOptions, logger: CliLogger): Promise<void>;
|
|
39
41
|
startHost(appRoot: string, options?: {
|
|
@@ -91,9 +93,8 @@ export declare function resolveTuiTitle(input: {
|
|
|
91
93
|
}): string | undefined;
|
|
92
94
|
/**
|
|
93
95
|
* Builds the terminal-UI display options for `eve dev`. Tools default to
|
|
94
|
-
* `auto-collapsed
|
|
95
|
-
*
|
|
96
|
-
* back to the runner's own defaults when unset.
|
|
96
|
+
* `auto-collapsed`, reasoning to `full`, and stderr logs are visible so
|
|
97
|
+
* long-running local sandbox work can report progress.
|
|
97
98
|
*/
|
|
98
99
|
export declare function resolveTuiDisplayOptions(options: DevelopmentCliOptions): TuiDisplayOptions;
|
|
99
100
|
/**
|
package/dist/src/cli/run.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{basename}from"node:path";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{eveCliBanner}from"#cli/banner.js";import{Command,CommanderError,InvalidArgumentError}from"#compiled/commander/index.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";async function loadBuildHost(){return(await import(`#internal/nitro/host.js`)).buildApplication}async function loadPrintApplicationInfo(){return(await import(`#cli/commands/info.js`)).printApplicationInfo}async function loadRunDevelopmentTui(){return(await import(`#cli/dev/tui/tui.js`)).runDevelopmentTui}async function loadRunEvalCommand(){return(await import(`#evals/cli/eval.js`)).runEvalCommand}async function loadStartHost(){return(await import(`#internal/nitro/host.js`)).startDevelopmentServer}async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function shouldPrintCliBootBanner(e){return e.name()===`info`||e.name()===`dev`||e.name()===`init`}async function waitForShutdownSignal(e){await new Promise((t,n)=>{let r=!1,cleanup=()=>{process.off(`SIGINT`,handleSignal),process.off(`SIGTERM`,handleSignal)},handleSignal=()=>{r||(r=!0,cleanup(),e.close().then(t,n))};process.once(`SIGINT`,handleSignal),process.once(`SIGTERM`,handleSignal)})}async function waitForProductionServer(e){await Promise.race([e.wait(),waitForShutdownSignal({close:()=>e.close()})])}function parsePortOption(e){if(!/^-?\d+$/.test(e))throw new InvalidArgumentError(`Expected a numeric port, received "${e}".`);let t=Number(e);if(t<0||t>65535)throw new InvalidArgumentError(`Expected a port between 0 and 65535, received "${e}".`);return t}const DISPLAY_MODES=new Set([`full`,`collapsed`,`auto-collapsed`,`hidden`]),STATS_MODES=new Set([`tokens`,`tokensPerSecond`]),LOG_MODES=new Set([`all`,`stderr`,`none`]);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){if(!LOG_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...LOG_MODES].join(`, `)}, received "${e}".`);return e}function parseContextSizeOption(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)throw new InvalidArgumentError(`Expected a positive number, received "${e}".`);return t}function resolveDevUiMode(e){return e.options.ui===!1||!e.interactive?`headless`:`tui`}function resolveTuiTitle(e){if(e.name!==void 0&&e.name.length>0)return e.name;if(e.remoteServerUrl!==void 0)try{return new URL(e.remoteServerUrl).host}catch{return}let n=humanizeProjectName(basename(e.appRoot));return n.length>0?n:void 0}function humanizeProjectName(e){return e.replace(/[-_.]+/gu,` `).trim().split(/\s+/u).filter(e=>e.length>0).map(e=>e[0].toUpperCase()+e.slice(1)).join(` `)}function resolveTuiDisplayOptions(e){let t={reasoning:e.reasoning??`full`,tools:e.tools??`auto-collapsed`};return e.subagents!==void 0&&(t.subagents=e.subagents),e.connectionAuth!==void 0&&(t.connectionAuth=e.connectionAuth),e.assistantResponseStats!==void 0&&(t.assistantResponseStats=e.assistantResponseStats),e.contextSize!==void 0&&(t.contextSize=e.contextSize),
|
|
1
|
+
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{basename}from"node:path";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{eveCliBanner}from"#cli/banner.js";import{Command,CommanderError,InvalidArgumentError}from"#compiled/commander/index.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";async function loadBuildHost(){return(await import(`#internal/nitro/host.js`)).buildApplication}async function loadPrintApplicationInfo(){return(await import(`#cli/commands/info.js`)).printApplicationInfo}async function loadRunDevelopmentTui(){return(await import(`#cli/dev/tui/tui.js`)).runDevelopmentTui}async function loadRunEvalCommand(){return(await import(`#evals/cli/eval.js`)).runEvalCommand}async function loadStartHost(){return(await import(`#internal/nitro/host.js`)).startDevelopmentServer}async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function shouldPrintCliBootBanner(e){return e.name()===`info`||e.name()===`dev`||e.name()===`init`}async function waitForShutdownSignal(e){await new Promise((t,n)=>{let r=!1,cleanup=()=>{process.off(`SIGINT`,handleSignal),process.off(`SIGTERM`,handleSignal)},handleSignal=()=>{r||(r=!0,cleanup(),e.close().then(t,n))};process.once(`SIGINT`,handleSignal),process.once(`SIGTERM`,handleSignal)})}async function waitForProductionServer(e){await Promise.race([e.wait(),waitForShutdownSignal({close:()=>e.close()})])}function parsePortOption(e){if(!/^-?\d+$/.test(e))throw new InvalidArgumentError(`Expected a numeric port, received "${e}".`);let t=Number(e);if(t<0||t>65535)throw new InvalidArgumentError(`Expected a port between 0 and 65535, received "${e}".`);return t}const DISPLAY_MODES=new Set([`full`,`collapsed`,`auto-collapsed`,`hidden`]),STATS_MODES=new Set([`tokens`,`tokensPerSecond`]),LOG_MODES=new Set([`all`,`stderr`,`none`]);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){if(!LOG_MODES.has(e))throw new InvalidArgumentError(`Expected one of ${[...LOG_MODES].join(`, `)}, received "${e}".`);return e}function parseContextSizeOption(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)throw new InvalidArgumentError(`Expected a positive number, received "${e}".`);return t}function resolveDevUiMode(e){return e.options.ui===!1||!e.interactive?`headless`:`tui`}function resolveTuiTitle(e){if(e.name!==void 0&&e.name.length>0)return e.name;if(e.remoteServerUrl!==void 0)try{return new URL(e.remoteServerUrl).host}catch{return}let n=humanizeProjectName(basename(e.appRoot));return n.length>0?n:void 0}function humanizeProjectName(e){return e.replace(/[-_.]+/gu,` `).trim().split(/\s+/u).filter(e=>e.length>0).map(e=>e[0].toUpperCase()+e.slice(1)).join(` `)}function resolveTuiDisplayOptions(e){let t={logs:e.logs??`stderr`,reasoning:e.reasoning??`full`,tools:e.tools??`auto-collapsed`};return e.subagents!==void 0&&(t.subagents=e.subagents),e.connectionAuth!==void 0&&(t.connectionAuth=e.connectionAuth),e.assistantResponseStats!==void 0&&(t.assistantResponseStats=e.assistantResponseStats),e.contextSize!==void 0&&(t.contextSize=e.contextSize),t}function hasInteractiveTerminal(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function rewriteDevelopmentUrlShorthand(e){let t=e[1];return e[0]!==`dev`||e.length!==2||t===void 0||t.startsWith(`-`)?[...e]:[`dev`,`--url`,t]}function resolveRemoteDevelopmentServerUrl(e){if(e.url){if(e.host!==void 0)throw new InvalidArgumentError(`The --host option cannot be used with --url.`);if(e.port!==void 0)throw new InvalidArgumentError(`The --port option cannot be used with --url.`);if(e.ui===!1)throw new InvalidArgumentError(`The --no-ui option cannot be used with --url.`);return e.url}}function createCliProgram(t,o){let d=resolveApplicationRoot(),f=resolveInstalledPackageInfo().version,p=new Command,m=createCliTheme();p.name(`eve`).description(`Build and run an Eve application.`).version(f).showHelpAfterError().exitOverride().hook(`preAction`,(e,n)=>{shouldPrintCliBootBanner(n)&&t.log(eveCliBanner())}).configureOutput({writeErr:e=>{t.error(e.trimEnd())},writeOut:e=>{t.log(e.trimEnd())}});let h=p.command(`channels`).description(`Manage user-authored channels in the current project.`);return h.command(`add [kind]`).description(`Add channels interactively, or scaffold a channel kind (slack | web).`).option(`-f, --force`,`Overwrite existing channel files`).option(`-y, --yes`,`Assume yes for confirmations; requires an explicit channel kind`).action(async(e,n)=>{let{runChannelsAddCommand:r}=await import(`#cli/commands/channels.js`);await r(t,d,{kind:e,options:n})}),h.command(`list`).description(`List user-authored channels in the current project.`).option(`--json`,`Output as JSON`).action(async e=>{let{runChannelsListCommand:n}=await import(`#cli/commands/channels.js`);await n(t,d,e)}),p.command(`init <target>`).description(`Create a new Eve agent, or add one to an existing project directory.`).option(`--channel-web-nextjs`,`Add the Web Chat application (Next.js)`).action(async(e,n)=>{let{runInitCommand:r}=await import(`#cli/commands/init.js`);await r(t,d,e,n)}),registerProjectCommands({program:p,logger:t,appRoot:d}),p.command(`build`).description(`Build the current Eve application.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:e}=await import(`#cli/dev/environment.js`);e(d);let n=await(o.buildHost??await loadBuildHost())(d);t.log(renderCliTaggedLine(m,{message:`built output at ${n}`,tag:`build`,tone:`success`}))}),p.command(`start`).description(`Start a built Eve application.`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).action(async e=>{let{loadDevelopmentEnvironmentFiles:n}=await import(`#cli/dev/environment.js`);n(d);let i=await(o.startProductionHost??await loadStartProductionHost())(d,{host:e.host,port:e.port});t.log(renderCliTaggedLine(m,{message:`server listening at ${i.url}`,tag:`start`,tone:`success`})),await waitForProductionServer(i)}),p.command(`dev`).description(`Start the Eve development server or connect to an existing URL.`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).option(`-u, --url <url>`,`Connect to an existing server URL`,parseDevelopmentServerUrl).option(`--no-ui`,`Start the server without an interactive UI`).option(`--name <name>`,`Title shown in the terminal UI (defaults to the app folder name)`).option(`--input <text>`,`Pre-fill the prompt input after launching the UI`).option(`--tools <mode>`,`How tool calls render: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--reasoning <mode>`,`How reasoning renders: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--subagents <mode>`,`How subagent sections render: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--connection-auth <mode>`,`How connection authorization renders: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--assistant-response-stats <mode>`,`Assistant header statistic: tokens | tokensPerSecond`,parseStatsMode).option(`--context-size <tokens>`,`Model context window size, shown as a usage percentage`,parseContextSizeOption).option(`--logs <mode>`,`Which server/agent logs to show: all | stderr | none`,parseLogsMode).addHelpText(`after`,`
|
|
2
2
|
You can also pass a bare URL as the only argument, for example: eve dev https://example.com
|
|
3
|
-
`).action(async e=>{let n=resolveRemoteDevelopmentServerUrl(e),{
|
|
3
|
+
`).action(async e=>{let n=resolveRemoteDevelopmentServerUrl(e),i=hasInteractiveTerminal(),a=resolveDevUiMode({options:e,interactive:i});if(e.input!==void 0&&a===`headless`)throw new InvalidArgumentError(`--input requires the interactive UI.`);let{loadDevelopmentEnvironmentFiles:c}=await import(`#cli/dev/environment.js`);c(d);let runInteractiveUi=async r=>{t.log(``);let i=o.runDevelopmentTui??await loadRunDevelopmentTui(),a=resolveTuiDisplayOptions(e),s=resolveTuiTitle({name:e.name,remoteServerUrl:n,appRoot:d});s!==void 0&&(a.name=s);let c={serverUrl:r,...a};n===void 0&&(c.appRoot=d),e.input!==void 0&&(c.initialInput=e.input),await i(c)};if(n){if(t.log(renderCliTaggedLine(m,{message:`connecting to ${n}`,tag:`dev`,tone:`info`})),a===`headless`){t.log(renderCliTaggedLine(m,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}await runInteractiveUi(n);return}let l=await(o.startHost??await loadStartHost())(d,{host:e.host,port:e.port}),u=!1,closeServer=async()=>{u||(u=!0,await l.close())};try{if(a!==`tui`&&t.log(renderCliTaggedLine(m,{message:`server listening at ${l.url}`,tag:`dev`,tone:`success`})),a===`headless`)return e.ui!==!1&&!i&&t.log(renderCliTaggedLine(m,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForShutdownSignal({close:closeServer});await runInteractiveUi(l.url)}finally{await closeServer()}}),p.command(`info`).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async e=>{await(o.printApplicationInfo??await loadPrintApplicationInfo())(t,d,e)}),p.command(`eval`).description(`Run evals against an Eve agent.`).argument(`[evalIds...]`,`Eval ids (or directory prefixes) to run (all discovered evals when omitted)`).option(`--url <url>`,`Remote agent URL (skip local host startup)`).option(`--tag <tag...>`,`Run only evals carrying a tag`).option(`--strict`,`Fail the exit code when any score falls below its threshold`).option(`--list`,`Print discovered evals without running them`).option(`--timeout <ms>`,`Per-eval timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent eval executions`).option(`--json`,`Output results as JSON`).option(`--junit <path>`,`Write JUnit XML results to a file`).option(`--skip-report`,`Skip eval-defined reporters (e.g. Braintrust)`).option(`--verbose`,`Stream per-eval ctx.log lines to stdout`).action(async(e,n)=>{await(o.runEvalCommand??await loadRunEvalCommand())(e,n,t)}),p}async function runCli(e=process.argv.slice(2),t=console,n={}){let r=createCliProgram(t,n),i=e.length===0?[`dev`]:rewriteDevelopmentUrlShorthand(e);try{await r.parseAsync(i,{from:`user`})}catch(e){if(e instanceof CommanderError){if(e.exitCode===0)return;throw Error(e.message)}throw e}}export{resolveDevUiMode,resolveTuiDisplayOptions,resolveTuiTitle,runCli};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{ClientError}from"#client/client-error.js";import{ClientSession}from"#client/session.js";import{createInitialSessionState}from"#client/session-utils.js";import{createClientUrl}from"#client/url.js";var Client=class{#e;#t;#n;#r;constructor(e){this.#n=e.host,this.#e=e.auth,this.#t=e.headers,this.#r=e.maxReconnectAttempts??3}async health(){let t=createClientUrl(this.#n,EVE_HEALTH_ROUTE_PATH),r=await this.#
|
|
1
|
+
import{EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{ClientError}from"#client/client-error.js";import{ClientSession}from"#client/session.js";import{createInitialSessionState}from"#client/session-utils.js";import{createClientUrl}from"#client/url.js";var Client=class{#e;#t;#n;#r;#i;constructor(e){this.#n=e.host,this.#e=e.auth,this.#t=e.headers,this.#r=e.maxReconnectAttempts??3,this.#i=e.preserveCompletedSessions??!1}async health(){let t=createClientUrl(this.#n,EVE_HEALTH_ROUTE_PATH),r=await this.#a(),i=await fetch(t,{headers:r});if(!i.ok){let e=await i.text();throw new ClientError(i.status,e)}return await i.json()}async info(){let e=createClientUrl(this.#n,EVE_INFO_ROUTE_PATH),r=await this.#a(),i=await fetch(e,{headers:r});if(!i.ok){let e=await i.text();throw new ClientError(i.status,e)}return await i.json()}async fetch(e,t={}){let n=createClientUrl(this.#n,e),r=await this.#a(headersInitToRecord(t.headers));return await fetch(n,{...t,headers:r})}session(e){let t;return t=typeof e==`string`?{continuationToken:e,streamIndex:0}:e||createInitialSessionState(),new ClientSession({host:this.#n,maxReconnectAttempts:this.#r,preserveCompletedSessions:this.#i,resolveHeaders:e=>this.#a(e)},t)}async#a(e){let t=new Headers,n=await resolveHeadersValue(this.#t);for(let[e,r]of Object.entries(n))t.set(e,r);if(e)for(let[n,r]of Object.entries(e))t.set(n,r);let r=await this.#o();return r&&t.set(`authorization`,r),t}async#o(){let e=this.#e;if(e){if(`bearer`in e){let t=(await resolveTokenValue(e.bearer)).trim();return t.length===0?void 0:`Bearer ${t}`}if(`basic`in e){let t=await resolveTokenValue(e.basic.password);return`Basic ${encodeBasicCredentials(e.basic.username,t)}`}}}};async function resolveTokenValue(e){return typeof e==`function`?e():e}async function resolveHeadersValue(e){return e===void 0?{}:typeof e==`function`?await e():e}function headersInitToRecord(e){return e===void 0?{}:Object.fromEntries(new Headers(e).entries())}function encodeBasicCredentials(e,t){let n=new TextEncoder().encode(`${e}:${t}`),r=Array.from(n,e=>String.fromCodePoint(e)).join(``);return btoa(r)}export{Client};
|
|
@@ -15,6 +15,7 @@ export declare function createInitialSessionState(): SessionState;
|
|
|
15
15
|
export declare function advanceSession(input: {
|
|
16
16
|
readonly continuationToken?: string;
|
|
17
17
|
readonly events: readonly HandleMessageStreamEvent[];
|
|
18
|
+
readonly preserveCompletedSessions?: boolean;
|
|
18
19
|
readonly sessionId: string;
|
|
19
20
|
readonly session: SessionState;
|
|
20
21
|
}): SessionState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isCurrentTurnBoundaryEvent}from"#protocol/message.js";function createInitialSessionState(){return{streamIndex:0}}function advanceSession(e){let t=findBoundaryEvent(e.events),n=e.session.streamIndex+e.events.length;return t?.type===`session.waiting`?{continuationToken:e.continuationToken??e.session.continuationToken,sessionId:e.sessionId,streamIndex:n}:createInitialSessionState()}function extractCompletedMessage(e){let t;for(let n of e)isFinalMessageCompleted(n)&&(t=n.data.message??void 0);return t}function deriveResultStatus(e){let t=findBoundaryEvent(e);return t?.type===`session.waiting`?`waiting`:t?.type===`session.failed`?`failed`:`completed`}function extractInputRequests(e){let t=[];for(let n of e)n.type===`input.requested`&&t.push(...n.data.requests);return t}function findBoundaryEvent(t){for(let n=t.length-1;n>=0;n--){let r=t[n];if(r!==void 0&&isCurrentTurnBoundaryEvent(r))return r}}function isFinalMessageCompleted(e){return e.type===`message.completed`&&e.data.finishReason!==`tool-calls`}export{advanceSession,createInitialSessionState,deriveResultStatus,extractCompletedMessage,extractInputRequests};
|
|
1
|
+
import{isCurrentTurnBoundaryEvent}from"#protocol/message.js";function createInitialSessionState(){return{streamIndex:0}}function advanceSession(e){let t=findBoundaryEvent(e.events),n=e.session.streamIndex+e.events.length;return t?.type===`session.waiting`||e.preserveCompletedSessions===!0&&t?.type===`session.completed`?{continuationToken:e.continuationToken??e.session.continuationToken,sessionId:e.sessionId,streamIndex:n}:createInitialSessionState()}function extractCompletedMessage(e){let t;for(let n of e)isFinalMessageCompleted(n)&&(t=n.data.message??void 0);return t}function deriveResultStatus(e){let t=findBoundaryEvent(e);return t?.type===`session.waiting`?`waiting`:t?.type===`session.failed`?`failed`:`completed`}function extractInputRequests(e){let t=[];for(let n of e)n.type===`input.requested`&&t.push(...n.data.requests);return t}function findBoundaryEvent(t){for(let n=t.length-1;n>=0;n--){let r=t[n];if(r!==void 0&&isCurrentTurnBoundaryEvent(r))return r}}function isFinalMessageCompleted(e){return e.type===`message.completed`&&e.data.finishReason!==`tool-calls`}export{advanceSession,createInitialSessionState,deriveResultStatus,extractCompletedMessage,extractInputRequests};
|
|
@@ -8,6 +8,7 @@ import type { SendTurnInput, SessionState, StreamOptions } from "#client/types.j
|
|
|
8
8
|
interface SessionContext {
|
|
9
9
|
readonly host: string;
|
|
10
10
|
readonly maxReconnectAttempts: number;
|
|
11
|
+
readonly preserveCompletedSessions: boolean;
|
|
11
12
|
resolveHeaders(perRequest?: Readonly<Record<string, string>>): Promise<Headers>;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EVE_CREATE_SESSION_ROUTE_PATH,createEveContinueSessionRoutePath}from"#protocol/routes.js";import{ClientError}from"#client/client-error.js";import{advanceSession}from"#client/session-utils.js";import{createClientUrl}from"#client/url.js";import{MessageResponse}from"#client/message-response.js";import{EVE_SESSION_ID_HEADER,isCurrentTurnBoundaryEvent}from"#protocol/message.js";import{normalizeOutputSchemaForRequest}from"#client/output-schema.js";import{isStreamDisconnectError,readNdjsonStream}from"#client/ndjson.js";import{openStreamBody,openStreamIterable}from"#client/open-stream.js";var ClientSession=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get state(){return this.#t}async send(e){let t=normalizeSendTurnInput(e),n=this.#t,{continuationToken:r,sessionId:i}=await this.#n(t,n);return new MessageResponse({continuationToken:r,createStream:()=>this.#r(i,r,n,t),sessionId:i})}stream(e){let t=this.#t.sessionId;if(!t)throw Error(`Session has no session ID. Send a message first.`);return this.#a(t,e)}async#n(n,r){let a=r.sessionId?createEveContinueSessionRoutePath(r.sessionId):EVE_CREATE_SESSION_ROUTE_PATH,s=createClientUrl(this.#e.host,a),c=await this.#e.resolveHeaders(n.headers);c.set(`content-type`,`application/json`);let l=createHandleMessageBody({input:n,outputSchema:normalizeOutputSchemaForRequest(n.outputSchema),session:r});if(l===null)throw Error(`Session.send requires a non-empty message, inputResponses, or both.`);let u=await postTurnWithRetry({body:JSON.stringify(l),headers:c,mustDeliver:(n.inputResponses?.length??0)>0,signal:n.signal,url:s}),d=await u.json(),f=(typeof d.sessionId==`string`?d.sessionId:void 0)??u.headers.get(EVE_SESSION_ID_HEADER)?.trim()??r.sessionId;if(!f)throw Error(`Message route did not return a session id.`);return{continuationToken:typeof d.continuationToken==`string`?d.continuationToken:void 0,sessionId:f}}async*#r(e,t,n,i){let a=[];try{let t=n.sessionId===e?n.streamIndex:0,r=this.#e.maxReconnectAttempts;for(;;){let n=await this.#i(e,t,i.signal,i.headers),o=!1;try{for await(let e of readNdjsonStream(n))if(a.push(e),t+=1,yield e,isCurrentTurnBoundaryEvent(e)){o=!0;break}}catch(e){if(!isStreamDisconnectError(e))throw e}if(o||i.signal?.aborted||r<=0)break;--r}}finally{this.#t=advanceSession({continuationToken:t,events:a,sessionId:e,session:n})}}async#i(e,t,n,r){return await openStreamBody({host:this.#e.host,resolveHeaders:()=>this.#e.resolveHeaders(r),sessionId:e,signal:n,startIndex:t})}async*#a(e,t){let n=this.#t,i=t?.startIndex??n.streamIndex,a=[];try{for await(let n of openStreamIterable({host:this.#e.host,maxReconnectAttempts:this.#e.maxReconnectAttempts,resolveHeaders:()=>this.#e.resolveHeaders(),sessionId:e,signal:t?.signal,startIndex:i}))a.push(n),yield n}finally{this.#t=advanceSession({continuationToken:n.continuationToken,events:a,session:{...n,sessionId:e,streamIndex:i},sessionId:e})}}};async function postTurnWithRetry(e){let t=e.mustDeliver?10:1,r,i;for(let a=0;a<t;a+=1){let o=await fetch(e.url,{body:e.body,headers:e.headers,method:`POST`,signal:e.signal??null});if(o.ok)return o;if(r=o.status,i=await o.text(),!isRetryableDeliveryFailure(o.status,i))throw new ClientError(o.status,i);a<t-1&&await sleep(200)}throw new ClientError(r??0,i??`Failed to deliver session turn.`)}function isRetryableDeliveryFailure(e,t){return e===500&&/target session was not found/i.test(t)}async function sleep(e){await new Promise(t=>setTimeout(t,e))}function normalizeSendTurnInput(e){return typeof e==`string`?{message:e}:e}function createHandleMessageBody(e){let t={};return e.input.message!==void 0&&(t.message=e.input.message),e.input.inputResponses!==void 0&&e.input.inputResponses.length>0&&(t.inputResponses=e.input.inputResponses),e.input.clientContext!==void 0&&(t.clientContext=e.input.clientContext),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),e.session.continuationToken!==void 0&&(t.continuationToken=e.session.continuationToken),Object.keys(t).length===0||e.session.continuationToken===void 0&&t.message===void 0||e.session.continuationToken!==void 0&&t.message===void 0&&t.inputResponses===void 0?null:t}export{ClientSession};
|
|
1
|
+
import{EVE_CREATE_SESSION_ROUTE_PATH,createEveContinueSessionRoutePath}from"#protocol/routes.js";import{ClientError}from"#client/client-error.js";import{advanceSession}from"#client/session-utils.js";import{createClientUrl}from"#client/url.js";import{MessageResponse}from"#client/message-response.js";import{EVE_SESSION_ID_HEADER,isCurrentTurnBoundaryEvent}from"#protocol/message.js";import{normalizeOutputSchemaForRequest}from"#client/output-schema.js";import{isStreamDisconnectError,readNdjsonStream}from"#client/ndjson.js";import{openStreamBody,openStreamIterable}from"#client/open-stream.js";var ClientSession=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get state(){return this.#t}async send(e){let t=normalizeSendTurnInput(e),n=this.#t,{continuationToken:r,sessionId:i}=await this.#n(t,n);return new MessageResponse({continuationToken:r,createStream:()=>this.#r(i,r,n,t),sessionId:i})}stream(e){let t=this.#t.sessionId;if(!t)throw Error(`Session has no session ID. Send a message first.`);return this.#a(t,e)}async#n(n,r){let a=r.sessionId?createEveContinueSessionRoutePath(r.sessionId):EVE_CREATE_SESSION_ROUTE_PATH,s=createClientUrl(this.#e.host,a),c=await this.#e.resolveHeaders(n.headers);c.set(`content-type`,`application/json`);let l=createHandleMessageBody({input:n,outputSchema:normalizeOutputSchemaForRequest(n.outputSchema),session:r});if(l===null)throw Error(`Session.send requires a non-empty message, inputResponses, or both.`);let u=await postTurnWithRetry({body:JSON.stringify(l),headers:c,mustDeliver:(n.inputResponses?.length??0)>0,signal:n.signal,url:s}),d=await u.json(),f=(typeof d.sessionId==`string`?d.sessionId:void 0)??u.headers.get(EVE_SESSION_ID_HEADER)?.trim()??r.sessionId;if(!f)throw Error(`Message route did not return a session id.`);return{continuationToken:typeof d.continuationToken==`string`?d.continuationToken:void 0,sessionId:f}}async*#r(e,t,n,i){let a=[];try{let t=n.sessionId===e?n.streamIndex:0,r=this.#e.maxReconnectAttempts;for(;;){let n=await this.#i(e,t,i.signal,i.headers),o=!1;try{for await(let e of readNdjsonStream(n))if(a.push(e),t+=1,yield e,isCurrentTurnBoundaryEvent(e)){o=!0;break}}catch(e){if(!isStreamDisconnectError(e))throw e}if(o||i.signal?.aborted||r<=0)break;--r}}finally{this.#t=advanceSession({continuationToken:t,events:a,preserveCompletedSessions:this.#e.preserveCompletedSessions,sessionId:e,session:n})}}async#i(e,t,n,r){return await openStreamBody({host:this.#e.host,resolveHeaders:()=>this.#e.resolveHeaders(r),sessionId:e,signal:n,startIndex:t})}async*#a(e,t){let n=this.#t,i=t?.startIndex??n.streamIndex,a=[];try{for await(let n of openStreamIterable({host:this.#e.host,maxReconnectAttempts:this.#e.maxReconnectAttempts,resolveHeaders:()=>this.#e.resolveHeaders(),sessionId:e,signal:t?.signal,startIndex:i}))a.push(n),yield n}finally{this.#t=advanceSession({continuationToken:n.continuationToken,events:a,preserveCompletedSessions:this.#e.preserveCompletedSessions,session:{...n,sessionId:e,streamIndex:i},sessionId:e})}}};async function postTurnWithRetry(e){let t=e.mustDeliver?10:1,r,i;for(let a=0;a<t;a+=1){let o=await fetch(e.url,{body:e.body,headers:e.headers,method:`POST`,signal:e.signal??null});if(o.ok)return o;if(r=o.status,i=await o.text(),!isRetryableDeliveryFailure(o.status,i))throw new ClientError(o.status,i);a<t-1&&await sleep(200)}throw new ClientError(r??0,i??`Failed to deliver session turn.`)}function isRetryableDeliveryFailure(e,t){return e===500&&/target session was not found/i.test(t)}async function sleep(e){await new Promise(t=>setTimeout(t,e))}function normalizeSendTurnInput(e){return typeof e==`string`?{message:e}:e}function createHandleMessageBody(e){let t={};return e.input.message!==void 0&&(t.message=e.input.message),e.input.inputResponses!==void 0&&e.input.inputResponses.length>0&&(t.inputResponses=e.input.inputResponses),e.input.clientContext!==void 0&&(t.clientContext=e.input.clientContext),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),e.session.continuationToken!==void 0&&(t.continuationToken=e.session.continuationToken),Object.keys(t).length===0||e.session.continuationToken===void 0&&t.message===void 0||e.session.continuationToken!==void 0&&t.message===void 0&&t.inputResponses===void 0?null:t}export{ClientSession};
|
|
@@ -3,6 +3,8 @@ import type { StandardJSONSchemaV1 } from "#compiled/@standard-schema/spec/index
|
|
|
3
3
|
import type { HandleMessageStreamEvent } from "#protocol/message.js";
|
|
4
4
|
import type { InputRequest, InputResponse } from "#runtime/input/types.js";
|
|
5
5
|
import type { JsonObject } from "#shared/json.js";
|
|
6
|
+
import type { ModelRouting } from "#shared/agent-definition.js";
|
|
7
|
+
import type { ModelEndpointStatus } from "#shared/model-endpoint-status.js";
|
|
6
8
|
/**
|
|
7
9
|
* Static credential value or per-request credential resolver.
|
|
8
10
|
*/
|
|
@@ -51,6 +53,19 @@ export interface ClientOptions {
|
|
|
51
53
|
* @default 3
|
|
52
54
|
*/
|
|
53
55
|
readonly maxReconnectAttempts?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Keep a session's continuation token after a normal `session.completed`
|
|
58
|
+
* boundary.
|
|
59
|
+
*
|
|
60
|
+
* By default, completed turns reset the client-side session so the next
|
|
61
|
+
* `send()` starts a fresh server-side conversation. Interactive clients can
|
|
62
|
+
* set this to preserve durable session state, including framework-managed
|
|
63
|
+
* sandbox state, across follow-up prompts until they explicitly create a new
|
|
64
|
+
* session.
|
|
65
|
+
*
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
readonly preserveCompletedSessions?: boolean;
|
|
54
69
|
}
|
|
55
70
|
/**
|
|
56
71
|
* Input payload for {@link ClientSession.send}. Pass a string as shorthand for
|
|
@@ -283,6 +298,10 @@ export interface AgentInfoResult {
|
|
|
283
298
|
readonly id: string;
|
|
284
299
|
readonly providerOptions?: unknown;
|
|
285
300
|
readonly source?: AgentInfoSource;
|
|
301
|
+
/** How the model is routed (gateway vs external), decided at compile time. */
|
|
302
|
+
readonly routing?: ModelRouting;
|
|
303
|
+
/** Composed routing + runtime credential readiness; absent only on legacy payloads. */
|
|
304
|
+
readonly endpoint?: ModelEndpointStatus;
|
|
286
305
|
};
|
|
287
306
|
readonly name: string;
|
|
288
307
|
readonly outputSchema?: unknown;
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"@ai-sdk/google": "4.0.0-canary.80",
|
|
11
11
|
"gray-matter": "4.0.3",
|
|
12
12
|
"jose": "6.2.3",
|
|
13
|
-
"just-bash": "3.0.1",
|
|
14
13
|
"jsonc-parser": "3.3.1",
|
|
15
14
|
"@ai-sdk/mcp": "2.0.0-canary.62",
|
|
16
15
|
"@ai-sdk/openai": "4.0.0-canary.72",
|
|
@@ -28,5 +27,5 @@
|
|
|
28
27
|
"zod": "4.4.3",
|
|
29
28
|
"zod-validation-error": "5.0.0"
|
|
30
29
|
},
|
|
31
|
-
"scriptHash": "
|
|
30
|
+
"scriptHash": "5cda2165432db2d6632ee6089689c9905ec228646594d4b93b0abded817fb7cb"
|
|
32
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ROOT_COMPILED_AGENT_NODE_ID,createCompiledAgentManifest}from"#compiler/manifest.js";function compileFromMemory(t){let n=t.appRoot??`/virtual/eve-memory-app`,r=t.agentRoot??`${n}/agent`,i=t.name??`memory-agent`,a={model:{id:t.model},name:i};t.outputSchema!==void 0&&(a.outputSchema=t.outputSchema);let o=(t.tools??[]).map(e=>({description:e.description??`${e.name} test tool.`,inputSchema:e.inputSchema??null,logicalPath:`tools/${e.name}.ts`,name:e.name,outputSchema:e.outputSchema,sourceId:createMemorySourceId(`tools/${e.name}.ts`),sourceKind:`module`}));return{manifest:createCompiledAgentManifest({agentRoot:r,appRoot:n,config:a,skills:(t.skills??[]).map(e=>({description:e.description,logicalPath:`skills/${e.name}.md`,markdown:e.markdown??`# ${e.name}\n`,name:e.name,sourceId:createMemorySourceId(`skills/${e.name}.md`),sourceKind:`markdown`})),tools:o}),moduleMap:{nodes:{[ROOT_COMPILED_AGENT_NODE_ID]:{modules:Object.fromEntries(o.map(e=>[e.sourceId,Object.freeze({})]))}}}}}function createMemorySourceId(e){return`memory::${e}`}export{compileFromMemory};
|
|
1
|
+
import{classifyModelRouting}from"#internal/classify-model-routing.js";import{ROOT_COMPILED_AGENT_NODE_ID,createCompiledAgentManifest}from"#compiler/manifest.js";function compileFromMemory(t){let n=t.appRoot??`/virtual/eve-memory-app`,r=t.agentRoot??`${n}/agent`,i=t.name??`memory-agent`,a={model:{id:t.model,routing:classifyModelRouting(t.model)},name:i};t.outputSchema!==void 0&&(a.outputSchema=t.outputSchema);let o=(t.tools??[]).map(e=>({description:e.description??`${e.name} test tool.`,inputSchema:e.inputSchema??null,logicalPath:`tools/${e.name}.ts`,name:e.name,outputSchema:e.outputSchema,sourceId:createMemorySourceId(`tools/${e.name}.ts`),sourceKind:`module`}));return{manifest:createCompiledAgentManifest({agentRoot:r,appRoot:n,config:a,skills:(t.skills??[]).map(e=>({description:e.description,logicalPath:`skills/${e.name}.md`,markdown:e.markdown??`# ${e.name}\n`,name:e.name,sourceId:createMemorySourceId(`skills/${e.name}.md`),sourceKind:`markdown`})),tools:o}),moduleMap:{nodes:{[ROOT_COMPILED_AGENT_NODE_ID]:{modules:Object.fromEntries(o.map(e=>[e.sourceId,Object.freeze({})]))}}}}}function createMemorySourceId(e){return`memory::${e}`}export{compileFromMemory};
|
|
@@ -5,7 +5,7 @@ import type { ChannelRouteMethod } from "#public/definitions/channel.js";
|
|
|
5
5
|
import type { Node } from "#shared/node.js";
|
|
6
6
|
import type { MarkdownSourceRef, ModuleSourceRef, SkillPackageSourceRef } from "#shared/source-ref.js";
|
|
7
7
|
import type { NamedSkillDefinition } from "#shared/skill-definition.js";
|
|
8
|
-
import type { InternalAgentDefinition, InternalAgentModelDefinition } from "#shared/agent-definition.js";
|
|
8
|
+
import type { InternalAgentDefinition, InternalAgentModelDefinition, InternalAgentCompactionDefinition, ModelRouting } from "#shared/agent-definition.js";
|
|
9
9
|
import type { InternalToolDefinition } from "#shared/tool-definition.js";
|
|
10
10
|
/**
|
|
11
11
|
* Stable manifest kind emitted by the compiler for runtime loading.
|
|
@@ -18,7 +18,7 @@ export declare const ROOT_COMPILED_AGENT_NODE_ID = "__root__";
|
|
|
18
18
|
/**
|
|
19
19
|
* Current compiled manifest schema version.
|
|
20
20
|
*/
|
|
21
|
-
export declare const COMPILED_AGENT_MANIFEST_VERSION =
|
|
21
|
+
export declare const COMPILED_AGENT_MANIFEST_VERSION = 29;
|
|
22
22
|
/**
|
|
23
23
|
* Compiled channel entry preserved in the compiled manifest.
|
|
24
24
|
*/
|
|
@@ -57,12 +57,30 @@ interface DisabledCompiledChannelEntry {
|
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Serializable runtime model reference preserved in the compiled manifest.
|
|
60
|
+
*
|
|
61
|
+
* Carries {@link ModelRouting} — decided at compile time from the authored model
|
|
62
|
+
* value — so consumers (the dev server's `/eve/v1/info`, the TUI) can tell how
|
|
63
|
+
* the model is reached without re-resolving it. Runtime model resolution uses
|
|
64
|
+
* the routing-free {@link InternalAgentModelDefinition}; routing is a
|
|
65
|
+
* compiled-output concern only.
|
|
66
|
+
*/
|
|
67
|
+
export type CompiledRuntimeModelReference = InternalAgentModelDefinition & {
|
|
68
|
+
routing: ModelRouting;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Normalized authored compaction configuration preserved in the compiled
|
|
72
|
+
* manifest.
|
|
60
73
|
*/
|
|
61
|
-
|
|
74
|
+
type CompiledAgentCompactionDefinition = Omit<InternalAgentCompactionDefinition, "model"> & {
|
|
75
|
+
model?: CompiledRuntimeModelReference;
|
|
76
|
+
};
|
|
62
77
|
/**
|
|
63
78
|
* Normalized additive agent configuration preserved in the compiled manifest.
|
|
64
79
|
*/
|
|
65
|
-
export type CompiledAgentDefinition = InternalAgentDefinition
|
|
80
|
+
export type CompiledAgentDefinition = Omit<InternalAgentDefinition, "model" | "compaction"> & {
|
|
81
|
+
model: CompiledRuntimeModelReference;
|
|
82
|
+
compaction?: CompiledAgentCompactionDefinition;
|
|
83
|
+
};
|
|
66
84
|
/**
|
|
67
85
|
* Normalized authored instructions prompt preserved in the compiled
|
|
68
86
|
* manifest.
|
|
@@ -186,6 +204,7 @@ declare const compiledScheduleDefinitionSchema: z.ZodObject<{
|
|
|
186
204
|
sourceKind: z.ZodUnion<readonly [z.ZodLiteral<"markdown">, z.ZodLiteral<"module">]>;
|
|
187
205
|
}, z.core.$strict>;
|
|
188
206
|
declare const compiledSandboxDefinitionSchema: z.ZodObject<{
|
|
207
|
+
backendName: z.ZodOptional<z.ZodString>;
|
|
189
208
|
description: z.ZodOptional<z.ZodString>;
|
|
190
209
|
exportName: z.ZodOptional<z.ZodString>;
|
|
191
210
|
logicalPath: z.ZodString;
|
|
@@ -228,7 +247,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
|
|
|
228
247
|
agentRoot: z.ZodString;
|
|
229
248
|
appRoot: z.ZodString;
|
|
230
249
|
channels: z.ZodArray<z.ZodType<CompiledChannelEntry, unknown, z.core.$ZodTypeInternals<CompiledChannelEntry, unknown>>>;
|
|
231
|
-
config: z.ZodType<
|
|
250
|
+
config: z.ZodType<CompiledAgentDefinition, unknown, z.core.$ZodTypeInternals<CompiledAgentDefinition, unknown>>;
|
|
232
251
|
connections: z.ZodArray<z.ZodObject<{
|
|
233
252
|
connectionName: z.ZodString;
|
|
234
253
|
description: z.ZodString;
|
|
@@ -256,6 +275,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
|
|
|
256
275
|
dynamicTools: z.ZodDefault<z.ZodArray<z.ZodType<CompiledDynamicToolDefinition, unknown, z.core.$ZodTypeInternals<CompiledDynamicToolDefinition, unknown>>>>;
|
|
257
276
|
hooks: z.ZodArray<z.ZodType<CompiledHookDefinition, unknown, z.core.$ZodTypeInternals<CompiledHookDefinition, unknown>>>;
|
|
258
277
|
sandbox: z.ZodNullable<z.ZodObject<{
|
|
278
|
+
backendName: z.ZodOptional<z.ZodString>;
|
|
259
279
|
description: z.ZodOptional<z.ZodString>;
|
|
260
280
|
exportName: z.ZodOptional<z.ZodString>;
|
|
261
281
|
logicalPath: z.ZodString;
|
|
@@ -327,7 +347,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
|
|
|
327
347
|
agentRoot: z.ZodString;
|
|
328
348
|
appRoot: z.ZodString;
|
|
329
349
|
channels: z.ZodArray<z.ZodType<CompiledChannelEntry, unknown, z.core.$ZodTypeInternals<CompiledChannelEntry, unknown>>>;
|
|
330
|
-
config: z.ZodType<
|
|
350
|
+
config: z.ZodType<CompiledAgentDefinition, unknown, z.core.$ZodTypeInternals<CompiledAgentDefinition, unknown>>;
|
|
331
351
|
connections: z.ZodArray<z.ZodObject<{
|
|
332
352
|
connectionName: z.ZodString;
|
|
333
353
|
description: z.ZodString;
|
|
@@ -373,6 +393,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
|
|
|
373
393
|
url: string;
|
|
374
394
|
}>, unknown>>>;
|
|
375
395
|
sandbox: z.ZodNullable<z.ZodObject<{
|
|
396
|
+
backendName: z.ZodOptional<z.ZodString>;
|
|
376
397
|
description: z.ZodOptional<z.ZodString>;
|
|
377
398
|
exportName: z.ZodOptional<z.ZodString>;
|
|
378
399
|
logicalPath: z.ZodString;
|
|
@@ -428,7 +449,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
|
|
|
428
449
|
sourceId: z.ZodString;
|
|
429
450
|
sourceKind: z.ZodLiteral<"module">;
|
|
430
451
|
}, z.core.$strict>>;
|
|
431
|
-
version: z.ZodLiteral<
|
|
452
|
+
version: z.ZodLiteral<29>;
|
|
432
453
|
workspaceResourceRoot: z.ZodObject<{
|
|
433
454
|
contentHash: z.ZodOptional<z.ZodString>;
|
|
434
455
|
logicalPath: z.ZodString;
|