eve 0.69.0 → 0.70.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 +36 -0
- package/dist/src/acp/adapter.js +1 -1
- package/dist/src/channel/task-card.d.ts +3 -3
- package/dist/src/channel/task-card.js +1 -1
- package/dist/src/channel/types.d.ts +18 -0
- package/dist/src/chunks/{use-eve-agent-Dab2MnT2.js → use-eve-agent-CJQeE7-t.js} +1873 -1236
- package/dist/src/chunks/{use-eve-agent-D_5129A9.js → use-eve-agent-DdemtY6C.js} +1874 -1234
- package/dist/src/cli/dev/command.js +1 -1
- package/dist/src/cli/dev/console-records-preload.d.ts +1 -0
- package/dist/src/cli/dev/console-records-preload.js +1 -0
- package/dist/src/cli/dev/console-records.d.ts +17 -0
- package/dist/src/cli/dev/console-records.js +3 -0
- package/dist/src/cli/dev/diagnostic-sink.d.ts +1 -0
- package/dist/src/cli/dev/local-server-process.js +1 -1
- package/dist/src/cli/dev/tui/blocks.d.ts +2 -1
- package/dist/src/cli/dev/tui/blocks.js +3 -3
- package/dist/src/cli/dev/tui/conversation-view.d.ts +54 -0
- package/dist/src/cli/dev/tui/conversation-view.js +1 -0
- package/dist/src/cli/dev/tui/flow-drawer.d.ts +5 -2
- package/dist/src/cli/dev/tui/flow-drawer.js +1 -1
- package/dist/src/cli/dev/tui/log-display-mode.d.ts +4 -10
- package/dist/src/cli/dev/tui/log-display-mode.js +1 -1
- package/dist/src/cli/dev/tui/message-queue.d.ts +7 -63
- package/dist/src/cli/dev/tui/message-queue.js +3 -1
- package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
- package/dist/src/cli/dev/tui/question-panel.d.ts +3 -1
- package/dist/src/cli/dev/tui/question-panel.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +56 -193
- package/dist/src/cli/dev/tui/runner.js +3 -3
- package/dist/src/cli/dev/tui/task-activity.d.ts +11 -7
- package/dist/src/cli/dev/tui/task-activity.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +15 -37
- package/dist/src/cli/dev/tui/terminal-renderer.js +10 -13
- package/dist/src/cli/dev/tui/terminal-tool-part.d.ts +2 -0
- package/dist/src/cli/dev/tui/terminal-tool-part.js +1 -0
- package/dist/src/cli/dev/tui/test/fake-eve-server.d.ts +34 -0
- package/dist/src/cli/dev/tui/test/fake-eve-server.js +1 -0
- package/dist/src/cli/dev/tui/test/index.d.ts +1 -0
- package/dist/src/cli/dev/tui/test/index.js +1 -1
- package/dist/src/cli/dev/tui/tool-block-groups.js +1 -1
- package/dist/src/cli/dev/tui/tool-presentation.d.ts +1 -0
- package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
- package/dist/src/cli/dev/tui/tool-rows.d.ts +1 -0
- package/dist/src/cli/dev/tui/tool-rows.js +2 -2
- package/dist/src/cli/dev/tui/transcript-parts.d.ts +73 -0
- package/dist/src/cli/dev/tui/transcript-parts.js +3 -0
- package/dist/src/cli/dev/tui/transcript.d.ts +47 -0
- package/dist/src/cli/dev/tui/transcript.js +1 -0
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/dev/tui/turn-clock.d.ts +11 -26
- package/dist/src/cli/dev/tui/turn-clock.js +1 -1
- package/dist/src/cli/dev/tui/types.d.ts +2 -4
- package/dist/src/cli/dev/ui-options.js +1 -1
- package/dist/src/client/agent-stream-follower.d.ts +26 -0
- package/dist/src/client/agent-stream-follower.js +1 -0
- package/dist/src/client/authorization-message-parts.js +1 -1
- package/dist/src/client/conversation-client.d.ts +40 -0
- package/dist/src/client/conversation-client.js +1 -0
- package/dist/src/client/conversation-reducer.d.ts +29 -0
- package/dist/src/client/conversation-reducer.js +1 -0
- package/dist/src/client/conversation-state.d.ts +110 -0
- package/dist/src/client/conversation-state.js +1 -0
- package/dist/src/client/eve-agent-projection.d.ts +24 -7
- package/dist/src/client/eve-agent-projection.js +1 -1
- package/dist/src/client/eve-agent-store-helpers.d.ts +21 -2
- package/dist/src/client/eve-agent-store-helpers.js +2 -2
- package/dist/src/client/eve-agent-store-state.d.ts +15 -3
- package/dist/src/client/eve-agent-store.d.ts +10 -1
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/index.d.ts +4 -1
- package/dist/src/client/index.js +1 -1
- package/dist/src/client/message-reducer-primitives.d.ts +1 -2
- package/dist/src/client/message-reducer-primitives.js +1 -1
- package/dist/src/client/message-reducer-types.d.ts +9 -2
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/client/message-response.js +1 -1
- package/dist/src/client/message-run-parts.d.ts +10 -6
- package/dist/src/client/message-run-parts.js +1 -1
- package/dist/src/client/optimistic-message-submissions.d.ts +6 -4
- package/dist/src/client/optimistic-message-submissions.js +1 -1
- package/dist/src/client/reducer.d.ts +5 -1
- package/dist/src/client/session-turn-dispatch.d.ts +15 -0
- package/dist/src/client/session-turn-dispatch.js +1 -0
- package/dist/src/client/session-utils.d.ts +27 -10
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +2 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/load-binding-namespace.js +1 -1
- package/dist/src/context/keys.d.ts +5 -2
- package/dist/src/context/keys.js +1 -1
- package/dist/src/context/provider.d.ts +5 -9
- package/dist/src/context/run-step.d.ts +4 -4
- package/dist/src/context/run-step.js +1 -1
- package/dist/src/evals/runner/derive-run-facts.js +1 -1
- package/dist/src/evals/runner/execute-task.js +1 -1
- package/dist/src/evals/session.js +2 -2
- package/dist/src/evals/types.d.ts +16 -0
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/execution/agent-sessions/context.d.ts +4 -2
- package/dist/src/execution/agent-sessions/context.js +1 -1
- package/dist/src/execution/agent-sessions/steps.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +6 -4
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +4 -2
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +10 -4
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/legacy-session/completion-step.d.ts +2 -0
- package/dist/src/execution/legacy-session/completion-step.js +1 -1
- package/dist/src/execution/legacy-session/interrupt-step.js +1 -1
- package/dist/src/execution/legacy-session/prepare-step.d.ts +1 -0
- package/dist/src/execution/legacy-session/prepare-step.js +1 -1
- package/dist/src/execution/legacy-session/snapshot.d.ts +8 -4
- package/dist/src/execution/legacy-session/snapshot.js +1 -1
- package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/publish-session-events.d.ts +27 -7
- package/dist/src/execution/publish-session-events.js +1 -1
- package/dist/src/execution/reconcile-session-continuation-token.d.ts +2 -2
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session/active-turn.d.ts +97 -0
- package/dist/src/execution/session/active-turn.js +1 -0
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/finalization.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +5 -3
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +19 -13
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/next-input.d.ts +2 -10
- package/dist/src/execution/session/next-input.js +1 -1
- package/dist/src/execution/session/program.d.ts +2 -0
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/state-cursor.d.ts +22 -16
- package/dist/src/execution/session/state-cursor.js +1 -1
- package/dist/src/execution/session/state-delta.d.ts +8 -1
- package/dist/src/execution/session/state-delta.js +1 -1
- package/dist/src/execution/session/turn-event-handler.js +1 -1
- package/dist/src/execution/session/turn-step-result.js +1 -1
- package/dist/src/execution/session/turn-step-types.d.ts +13 -4
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn-waiting-step.js +1 -1
- package/dist/src/execution/session/turn.d.ts +8 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session.d.ts +5 -5
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +5 -4
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/tasks/start.d.ts +2 -2
- package/dist/src/execution/tasks/task-id-input.d.ts +1 -1
- package/dist/src/execution/tasks/task-id-input.js +1 -1
- package/dist/src/execution/terminal-session-completion-step.d.ts +2 -0
- package/dist/src/execution/terminal-session-completion-step.js +1 -1
- package/dist/src/execution/terminal-session-failure-step.d.ts +2 -0
- package/dist/src/execution/terminal-session-failure-step.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/connection-target.d.ts +5 -0
- package/dist/src/execution/tools/connection-target.js +1 -1
- package/dist/src/execution/tools/connection-tools.js +2 -2
- package/dist/src/execution/tools/workflow/start.d.ts +3 -3
- package/dist/src/harness/authorization.d.ts +15 -2
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/cancelled-turn-emission.d.ts +2 -1
- package/dist/src/harness/cancelled-turn-emission.js +1 -1
- package/dist/src/harness/coordination.d.ts +5 -3
- package/dist/src/harness/emission.d.ts +5 -2
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/held-requests.d.ts +18 -0
- package/dist/src/harness/held-requests.js +1 -0
- package/dist/src/harness/hitl/approval-input-requests.d.ts +16 -0
- package/dist/src/harness/hitl/approval-input-requests.js +1 -1
- package/dist/src/harness/input-extraction.js +1 -1
- package/dist/src/harness/input-requests.d.ts +0 -4
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/model-call-error.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +4 -4
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/stale-input-responses.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/turn-tag-state.d.ts +2 -0
- package/dist/src/harness/turn-tag-state.js +1 -1
- package/dist/src/harness/types.d.ts +23 -11
- package/dist/src/instrumentation/channel-delivery.d.ts +1 -0
- package/dist/src/instrumentation/channel-delivery.js +1 -1
- package/dist/src/instrumentation/lifecycle.d.ts +4 -0
- package/dist/src/instrumentation/memory.d.ts +2 -0
- package/dist/src/instrumentation/memory.js +1 -1
- package/dist/src/instrumentation/native-events.d.ts +1 -0
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/runtime.d.ts +4 -3
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/instrumentation/session-init.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +14 -6
- package/dist/src/internal/authored-module-loader.js +1 -1
- package/dist/src/internal/authored-package-boundary.d.ts +1 -1
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/bundler/extension-mount-plugin.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.d.ts +27 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +2 -2
- package/dist/src/protocol/message.d.ts +41 -3
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/public/channels/slack/action-status.d.ts +2 -2
- package/dist/src/public/channels/slack/action-status.js +1 -1
- package/dist/src/public/channels/slack/approval-cards.d.ts +15 -0
- package/dist/src/public/channels/slack/approval-cards.js +2 -0
- package/dist/src/public/channels/slack/auth.d.ts +2 -0
- package/dist/src/public/channels/slack/auth.js +1 -1
- package/dist/src/public/channels/slack/connections.d.ts +15 -11
- package/dist/src/public/channels/slack/connections.js +1 -1
- package/dist/src/public/channels/slack/defaults.d.ts +1 -15
- package/dist/src/public/channels/slack/defaults.js +3 -4
- package/dist/src/public/channels/slack/hitl.js +1 -1
- package/dist/src/public/channels/slack/inbound.d.ts +10 -2
- package/dist/src/public/channels/slack/inbound.js +1 -1
- package/dist/src/public/channels/slack/index.d.ts +2 -0
- package/dist/src/public/channels/slack/index.js +1 -1
- package/dist/src/public/channels/slack/input-response.js +1 -1
- package/dist/src/public/channels/slack/interaction-cards.js +1 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/limits.d.ts +5 -3
- package/dist/src/public/channels/slack/private-approval-delivery.js +1 -1
- package/dist/src/public/channels/slack/renderers.d.ts +1 -1
- package/dist/src/public/channels/slack/renderers.js +1 -1
- package/dist/src/public/channels/slack/reply-delivery.d.ts +72 -0
- package/dist/src/public/channels/slack/reply-delivery.js +1 -0
- package/dist/src/public/channels/slack/sign-in-cancel.d.ts +20 -0
- package/dist/src/public/channels/slack/sign-in-cancel.js +1 -0
- package/dist/src/public/channels/slack/slackChannel.d.ts +15 -0
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/slack/task-card.js +1 -1
- package/dist/src/public/channels/teams/defaults.d.ts +1 -1
- package/dist/src/public/channels/teams/defaults.js +2 -2
- package/dist/src/public/definitions/channel.d.ts +1 -0
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/server.d.ts +2 -0
- package/dist/src/public/next/server.js +1 -2
- package/dist/src/public/nuxt/module.d.ts +6 -0
- package/dist/src/public/nuxt/module.js +1 -1
- package/dist/src/react/index.d.ts +3 -0
- package/dist/src/react/index.js +1 -1
- package/dist/src/react/use-eve-agent.d.ts +7 -5
- package/dist/src/react/use-eve-agent.js +1 -1
- package/dist/src/runtime/connections/scoped-authorization.d.ts +2 -0
- package/dist/src/runtime/connections/scoped-authorization.js +1 -1
- package/dist/src/setup/boxes/deploy-project.js +1 -1
- package/dist/src/setup/integrations/web/setup.js +6 -2
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +2 -2
- package/dist/src/setup/scaffold/create/web-template.js +28 -9
- package/dist/src/setup/vercel-project-framework.js +1 -1
- package/dist/src/shared/display-name.d.ts +15 -0
- package/dist/src/shared/display-name.js +1 -0
- package/dist/src/shared/framework-eve-server.d.ts +43 -0
- package/dist/src/shared/framework-eve-server.js +2 -0
- package/dist/src/shared/token-usage.d.ts +2 -0
- package/dist/src/shared/token-usage.js +1 -1
- package/dist/src/shared/trace-root.d.ts +8 -0
- package/dist/src/shared/trace-root.js +1 -0
- package/dist/src/subagents/hitl-proxy.d.ts +3 -3
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/subagents/invocation.d.ts +3 -1
- package/dist/src/subagents/tool.js +1 -1
- package/dist/src/svelte/index.d.ts +3 -0
- package/dist/src/svelte/index.js +2 -2
- package/dist/src/svelte/use-eve-agent.d.ts +7 -4
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/load-skill.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tracing/agent-action-instrumentation.js +1 -1
- package/dist/src/tracing/agent-approval-instrumentation.js +1 -1
- package/dist/src/tracing/agent-memory-instrumentation.js +1 -1
- package/dist/src/tracing/agent-otel-attributes.d.ts +6 -0
- package/dist/src/tracing/agent-otel-attributes.js +1 -1
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/tracing/agent-otel-runtime-context.d.ts +1 -1
- package/dist/src/tracing/agent-otel-runtime-context.js +1 -1
- package/dist/src/tracing/agent-otel-session-context.js +1 -1
- package/dist/src/tracing/agent-span-contract.js +1 -1
- package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
- package/dist/src/tracing/agent-trace-context-codec.d.ts +4 -0
- package/dist/src/tracing/agent-trace-context-codec.js +1 -1
- package/dist/src/tracing/agent-trace-span-processor.js +1 -1
- package/dist/src/tracing/agent-trace-state.d.ts +3 -0
- package/dist/src/tracing/conversation-context.d.ts +10 -0
- package/dist/src/tracing/conversation-context.js +1 -1
- package/dist/src/tracing/otel-registration.js +1 -1
- package/dist/src/vue/index.d.ts +3 -0
- package/dist/src/vue/index.js +2 -2
- package/dist/src/vue/use-eve-agent.d.ts +7 -3
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/slack.mdx +60 -13
- package/docs/concepts/built-in-tools.md +3 -2
- package/docs/concepts/sessions-runs-and-streaming.md +4 -4
- package/docs/connections/overview.mdx +9 -3
- package/docs/evals/reporters.mdx +4 -0
- package/docs/extensions.md +11 -0
- package/docs/guides/client/streaming.mdx +7 -6
- package/docs/guides/deployment/vercel.mdx +2 -1
- package/docs/guides/dev-tui.md +15 -15
- package/docs/guides/dynamic-capabilities.md +1 -1
- package/docs/guides/frontend/nuxt.mdx +24 -4
- package/docs/guides/frontend/overview.mdx +44 -38
- package/docs/guides/frontend/use-eve-agent-svelte.mdx +4 -10
- package/docs/guides/frontend/use-eve-agent-vue.mdx +4 -10
- package/docs/guides/instrumentation/otel.mdx +24 -6
- package/docs/guides/remote-agents.md +26 -8
- package/docs/reference/cli.md +4 -4
- package/docs/tools/human-in-the-loop.md +4 -4
- package/docs/tools/overview.mdx +1 -1
- package/docs/tools/tasks.md +8 -8
- package/package.json +1 -1
- package/dist/src/cli/dev/tui/steering-stream.d.ts +0 -15
- package/dist/src/cli/dev/tui/steering-stream.js +0 -1
- package/dist/src/cli/dev/tui/subagent-pump.d.ts +0 -134
- package/dist/src/cli/dev/tui/subagent-pump.js +0 -1
- package/dist/src/public/nuxt/dev-server.d.ts +0 -25
- package/dist/src/public/nuxt/dev-server.js +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { ModelAccessChange } from "#shared/model-connection.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { AgentInfoResult, Client } from "#client/index.js";
|
|
3
3
|
import type { EveCliSetupStepEvent, EveCliSetupTerminalEvent } from "#cli/telemetry/index.js";
|
|
4
4
|
import type { OnboardingScreenEvent } from "./setup-commands.js";
|
|
5
5
|
import { inspectApplication } from "#services/inspect-application.js";
|
|
6
|
-
import { type
|
|
7
|
-
export type { SubagentRun, SubagentStepUpdate, SubagentToolUpdate, SubagentView, } from "./subagent-pump.js";
|
|
6
|
+
import { type AgentTUIConversationView } from "./conversation-view.js";
|
|
8
7
|
import { type DevBootProgressReporter } from "#internal/dev-boot-progress.js";
|
|
9
8
|
import { type PromptCommand, type PromptCommandSpec, type ArgumentTypeaheadCommand } from "./prompt-commands.js";
|
|
10
9
|
import type { PromptArgumentSuggestion } from "./argument-typeahead.js";
|
|
@@ -15,7 +14,7 @@ import { type BootDetection } from "./setup-issues.js";
|
|
|
15
14
|
import type { SetupFlowRenderer } from "./setup-flow.js";
|
|
16
15
|
import type { TraceViewerRenderer } from "./traces/trace-viewer-session.js";
|
|
17
16
|
import type { RemoteDevelopmentTarget } from "./target.js";
|
|
18
|
-
import type {
|
|
17
|
+
import type { LogDisplayMode, TuiDisplayOptions } from "./types.js";
|
|
19
18
|
import { type TerminalInput, type TerminalOutput } from "./terminal-renderer.js";
|
|
20
19
|
import { type VercelStatusEffect, type VercelStatusSnapshot } from "./vercel-status.js";
|
|
21
20
|
import { type McpConnectionProbe } from "./mcp-connection-status.js";
|
|
@@ -23,133 +22,42 @@ import type { detectProjectIdentity } from "#setup/project-resolution.js";
|
|
|
23
22
|
import { getVercelAuthStatus } from "#setup/vercel-project.js";
|
|
24
23
|
import type { DevDiagnostics } from "../diagnostics.js";
|
|
25
24
|
import type { CommandLifecycle } from "../../shutdown.js";
|
|
26
|
-
export type
|
|
27
|
-
|
|
28
|
-
events: AsyncIterable<AgentTUIStreamEvent> | ReadableStream<AgentTUIStreamEvent>;
|
|
29
|
-
abort?: () => void;
|
|
25
|
+
export type AgentTUISessionOptions = {
|
|
26
|
+
title?: string;
|
|
30
27
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* {@link abort} — which drops the client stream and forces a fresh session —
|
|
34
|
-
* the server settles the turn as `turn.cancelled` → `session.waiting`, so
|
|
35
|
-
* the stream reaches its boundary normally and the session keeps its context.
|
|
36
|
-
* Best-effort and idempotent; scoped to the turn the user observed when its id is known.
|
|
28
|
+
* Text to seed the composer's draft with before the user types. Set by the
|
|
29
|
+
* runner for the first prompt when `eve dev --input` is used.
|
|
37
30
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export type AgentTUIStreamUsage = {
|
|
42
|
-
inputTokens?: number;
|
|
43
|
-
outputTokens?: number;
|
|
31
|
+
initialDraft?: string;
|
|
32
|
+
/** Closes the composer without discarding its draft. */
|
|
33
|
+
signal?: AbortSignal;
|
|
44
34
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
type: "
|
|
50
|
-
|
|
51
|
-
} | {
|
|
52
|
-
type: "step-finish";
|
|
53
|
-
usage?: AgentTUIStreamUsage;
|
|
54
|
-
} | {
|
|
55
|
-
type: "assistant-delta";
|
|
56
|
-
id: string;
|
|
57
|
-
delta: string;
|
|
58
|
-
} | {
|
|
59
|
-
type: "assistant-complete";
|
|
60
|
-
id: string;
|
|
61
|
-
text?: string | null;
|
|
62
|
-
} | {
|
|
63
|
-
type: "reasoning-delta";
|
|
64
|
-
id: string;
|
|
65
|
-
delta: string;
|
|
66
|
-
} | {
|
|
67
|
-
type: "reasoning-complete";
|
|
68
|
-
id: string;
|
|
69
|
-
} | {
|
|
70
|
-
type: "tool-call-preparing";
|
|
71
|
-
toolCallId: string;
|
|
72
|
-
toolName: string;
|
|
73
|
-
} | {
|
|
74
|
-
type: "tool-call";
|
|
75
|
-
toolCallId: string;
|
|
76
|
-
toolName: string;
|
|
77
|
-
input: unknown;
|
|
78
|
-
/** The tool's own `label.start` copy, when it defines one. */
|
|
79
|
-
label?: string;
|
|
80
|
-
} | {
|
|
81
|
-
type: "tool-approval-request";
|
|
82
|
-
approvalId: string;
|
|
83
|
-
toolCallId: string;
|
|
84
|
-
} | {
|
|
85
|
-
type: "tool-result";
|
|
86
|
-
toolCallId: string;
|
|
87
|
-
output: unknown;
|
|
88
|
-
/** The tool's own `label.complete` copy, when it defines one. */
|
|
89
|
-
label?: string;
|
|
90
|
-
} | {
|
|
91
|
-
type: "tool-error";
|
|
92
|
-
toolCallId: string;
|
|
93
|
-
errorText: string;
|
|
94
|
-
} | {
|
|
95
|
-
type: "tool-rejected";
|
|
96
|
-
toolCallId: string;
|
|
97
|
-
reason: string;
|
|
35
|
+
/** One user action from the composer. */
|
|
36
|
+
export type AgentTUIInput =
|
|
37
|
+
/** A message or slash command. Messages sent while work runs steer it. */
|
|
38
|
+
{
|
|
39
|
+
type: "submit";
|
|
40
|
+
text: string;
|
|
98
41
|
}
|
|
99
|
-
/**
|
|
42
|
+
/** `Esc` or `Ctrl+C` while work runs. */
|
|
100
43
|
| {
|
|
101
|
-
type: "
|
|
102
|
-
toolCallId: string;
|
|
103
|
-
reason: string;
|
|
44
|
+
type: "cancel";
|
|
104
45
|
}
|
|
105
|
-
/**
|
|
46
|
+
/** `Ctrl+C` again while cancellation is pending: stop following the turn. */
|
|
106
47
|
| {
|
|
107
|
-
type: "
|
|
108
|
-
toolCallId: string;
|
|
109
|
-
kind: "agent" | "tool";
|
|
110
|
-
toolName: string;
|
|
111
|
-
} | {
|
|
112
|
-
type: "task-settled";
|
|
113
|
-
toolCallId: string;
|
|
114
|
-
status: "completed" | "failed" | "cancelled";
|
|
115
|
-
output?: unknown;
|
|
116
|
-
errorText?: string;
|
|
117
|
-
} | {
|
|
118
|
-
type: "error";
|
|
119
|
-
errorText: string;
|
|
120
|
-
hint?: string;
|
|
121
|
-
detail?: string;
|
|
122
|
-
} | {
|
|
123
|
-
type: "turn-cancelled";
|
|
124
|
-
} | {
|
|
125
|
-
type: "finish";
|
|
126
|
-
usage?: AgentTUIStreamUsage;
|
|
127
|
-
};
|
|
128
|
-
export type AgentTUITurnState = {
|
|
129
|
-
aborted?: boolean;
|
|
130
|
-
boundaryEvent?: "session.completed" | "session.failed" | "session.waiting" | "turn.waiting";
|
|
131
|
-
pendingApprovals: AgentTUIToolApprovalRequest[];
|
|
132
|
-
pendingQuestions: InputRequest[];
|
|
133
|
-
sawSessionFailure: boolean;
|
|
134
|
-
/** Id of the streaming turn, once `turn.started` names it. Scopes cancels. */
|
|
135
|
-
turnId?: string;
|
|
136
|
-
/** True while a cooperative-cancel request loop is running for this turn. */
|
|
137
|
-
cancelInFlight?: boolean;
|
|
48
|
+
type: "interrupt";
|
|
138
49
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
connectionAuth?: TerminalPartDisplayMode;
|
|
151
|
-
assistantResponseStats?: AssistantResponseStatsMode;
|
|
152
|
-
contextSize?: number;
|
|
50
|
+
/** Where a prompt sits among the requests being answered, and who asked, when that helps. */
|
|
51
|
+
export type AgentTUIInputContext = {
|
|
52
|
+
/** 1-based position among the requests answered in a row; the total grows as more arrive. */
|
|
53
|
+
position?: {
|
|
54
|
+
index: number;
|
|
55
|
+
total: number;
|
|
56
|
+
};
|
|
57
|
+
/** The task that asked, named as its transcript lines are. */
|
|
58
|
+
requester?: string;
|
|
59
|
+
/** The task whose run asked; the renderer names it as its task lines do. */
|
|
60
|
+
taskId?: string;
|
|
153
61
|
};
|
|
154
62
|
export type AgentTUIToolApprovalRequest = {
|
|
155
63
|
approvalId: string;
|
|
@@ -157,6 +65,7 @@ export type AgentTUIToolApprovalRequest = {
|
|
|
157
65
|
toolName: string;
|
|
158
66
|
title?: string;
|
|
159
67
|
input: unknown;
|
|
68
|
+
context?: AgentTUIInputContext;
|
|
160
69
|
};
|
|
161
70
|
export type AgentTUIToolApprovalResponse = {
|
|
162
71
|
approved: boolean;
|
|
@@ -174,6 +83,7 @@ export type AgentTUIInputQuestion = {
|
|
|
174
83
|
display: "select" | "text";
|
|
175
84
|
options?: ReadonlyArray<AgentTUIInputOption>;
|
|
176
85
|
allowFreeform?: boolean;
|
|
86
|
+
context?: AgentTUIInputContext;
|
|
177
87
|
};
|
|
178
88
|
export type AgentTUIInputQuestionResponse = {
|
|
179
89
|
optionId?: string;
|
|
@@ -199,10 +109,16 @@ export type AgentTUIRenderer = {
|
|
|
199
109
|
* recovery and slash-command results. Optional.
|
|
200
110
|
*/
|
|
201
111
|
renderNotice?(text: string): void;
|
|
112
|
+
/**
|
|
113
|
+
* Puts back a message whose turn was cancelled from outside this prompt, such as `/cancel` from
|
|
114
|
+
* another client, when the composer is empty. Optional.
|
|
115
|
+
*/
|
|
116
|
+
restoreDraft?(text: string): void;
|
|
202
117
|
/**
|
|
203
118
|
* Commits the session boundary (`┌── Session restarted, clear context.`)
|
|
204
|
-
* when a dead session is replaced mid-conversation.
|
|
205
|
-
*
|
|
119
|
+
* when a dead session is replaced mid-conversation. The old conversation's
|
|
120
|
+
* transcript settles as shown; the next `renderConversation` starts fresh.
|
|
121
|
+
* Optional; renderers without it get the plain notice.
|
|
206
122
|
*/
|
|
207
123
|
renderSessionBoundary?(): void;
|
|
208
124
|
/**
|
|
@@ -223,15 +139,15 @@ export type AgentTUIRenderer = {
|
|
|
223
139
|
* The returned promise resolves when the user closes the viewer.
|
|
224
140
|
*/
|
|
225
141
|
readonly traceViewer?: TraceViewerRenderer;
|
|
226
|
-
readPrompt?(options?: AgentTUISessionOptions): Promise<string | undefined>;
|
|
227
142
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* during the turn coalesced into one. The runner calls this at a clean
|
|
231
|
-
* turn boundary and submits the result as the next turn without reading
|
|
232
|
-
* the prompt. Optional — renderers without mid-turn input never queue.
|
|
143
|
+
* Reads the next composer action. Resolves `undefined` when `signal`
|
|
144
|
+
* aborts and rejects with an interrupt when the user leaves.
|
|
233
145
|
*/
|
|
234
|
-
|
|
146
|
+
readInput?(options?: AgentTUISessionOptions): Promise<AgentTUIInput | undefined>;
|
|
147
|
+
/** Draws the session's transcript from one conversation snapshot. */
|
|
148
|
+
renderConversation?(view: AgentTUIConversationView): void;
|
|
149
|
+
/** Commits one error block, such as a message the session did not accept. */
|
|
150
|
+
renderError?(title: string, message: string): void;
|
|
235
151
|
/**
|
|
236
152
|
* Reports the server session id backing the conversation — pushed by the
|
|
237
153
|
* runner once a send is accepted, and overwritten when a later session's
|
|
@@ -244,36 +160,6 @@ export type AgentTUIRenderer = {
|
|
|
244
160
|
setSessionId?(sessionId: string): void;
|
|
245
161
|
readToolApproval?(request: AgentTUIToolApprovalRequest, options?: AgentTUISessionOptions): Promise<AgentTUIToolApprovalResponse>;
|
|
246
162
|
readInputQuestion?(question: AgentTUIInputQuestion, options?: AgentTUISessionOptions): Promise<AgentTUIInputQuestionResponse | undefined>;
|
|
247
|
-
renderStream(result: AgentTUIStreamResult, options?: AgentTUISessionOptions): Promise<void>;
|
|
248
|
-
/**
|
|
249
|
-
* Renders a server-initiated turn while `readPrompt` still owns input.
|
|
250
|
-
* Unlike `renderStream`, this must not replace the active key consumer or
|
|
251
|
-
* clear the user's draft.
|
|
252
|
-
*/
|
|
253
|
-
renderIdleStream?(result: AgentTUIStreamResult, options?: AgentTUISessionOptions): Promise<void>;
|
|
254
|
-
/**
|
|
255
|
-
* The renderer's whole subagent surface — sections, nested steps and
|
|
256
|
-
* tools, ghost sweeps, completion. One optional capability with required
|
|
257
|
-
* members: a renderer either has a subagent view or it doesn't, and a
|
|
258
|
-
* type-legal partial implementation (which would ghost placeholders or
|
|
259
|
-
* duplicate parent tool rows) cannot exist.
|
|
260
|
-
*/
|
|
261
|
-
readonly subagents?: SubagentView;
|
|
262
|
-
/**
|
|
263
|
-
* Out-of-band update for one MCP connection authorization lifecycle.
|
|
264
|
-
* Called by the runner as `authorization.*` events arrive.
|
|
265
|
-
* The renderer renders this as a persistent body section per
|
|
266
|
-
* connection that transitions through `required` → `pending` →
|
|
267
|
-
* one of the terminal `ConnectionAuthorizationOutcome` states.
|
|
268
|
-
*/
|
|
269
|
-
upsertConnectionAuth?(update: ConnectionAuthUpdate): void;
|
|
270
|
-
/**
|
|
271
|
-
* Sets the number of connections currently awaiting an OAuth
|
|
272
|
-
* callback. The renderer overrides its bottom status bar with a
|
|
273
|
-
* "waiting for connection authorization" hint while this is > 0,
|
|
274
|
-
* so the user understands the agent is parked, not hung.
|
|
275
|
-
*/
|
|
276
|
-
setConnectionAuthPendingCount?(count: number): void;
|
|
277
163
|
/**
|
|
278
164
|
* The log display mode currently in effect. Paired with
|
|
279
165
|
* {@link setLogDisplayMode}; both are absent on renderers that do not
|
|
@@ -312,8 +198,6 @@ export type AgentTUIRenderer = {
|
|
|
312
198
|
* lifecycle ends.
|
|
313
199
|
*/
|
|
314
200
|
shutdown?(): void;
|
|
315
|
-
/** Suspends an idle prompt so a server-initiated HITL request can own input. */
|
|
316
|
-
suspendPromptForInput?(): void;
|
|
317
201
|
requestInterrupt?(): void;
|
|
318
202
|
exitRequested?(): boolean;
|
|
319
203
|
};
|
|
@@ -362,27 +246,19 @@ type TuiStartup = {
|
|
|
362
246
|
};
|
|
363
247
|
};
|
|
364
248
|
export type EveTUIRunnerOptions = TuiDisplayOptions & {
|
|
365
|
-
session?: ClientSession;
|
|
366
249
|
/** Production TUI probe injected by the launcher; omitted in hermetic runners. */
|
|
367
250
|
probeMcpConnection?: McpConnectionProbe;
|
|
368
|
-
/**
|
|
369
|
-
|
|
370
|
-
* stream observation. When omitted, the TUI still shows the subagent
|
|
371
|
-
* section but cannot surface the subagent's reasoning / response /
|
|
372
|
-
* intermediate events — only the parent-stream `called` and
|
|
373
|
-
* `completed` transitions.
|
|
374
|
-
*/
|
|
375
|
-
client?: Client;
|
|
251
|
+
/** Configured client for the conversation's sessions and their subagent streams. */
|
|
252
|
+
client: Client;
|
|
376
253
|
renderer?: AgentTUIRenderer;
|
|
377
254
|
screen?: TerminalOutput;
|
|
378
255
|
userInput?: TerminalInput;
|
|
379
256
|
/**
|
|
380
|
-
* Formats
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
* a richer formatter here.
|
|
257
|
+
* Formats a session error (a failed send — e.g. a transport failure or a
|
|
258
|
+
* Vercel Deployment Protection challenge) into the text rendered in the
|
|
259
|
+
* inline error region. Defaults to the error's message. Callers that know
|
|
260
|
+
* about transport-specific challenges (the `eve dev` glue) inject a richer
|
|
261
|
+
* formatter here.
|
|
386
262
|
*/
|
|
387
263
|
formatTransportError?: (error: unknown) => string;
|
|
388
264
|
/**
|
|
@@ -440,17 +316,4 @@ export declare class EveTUIRunner {
|
|
|
440
316
|
}
|
|
441
317
|
/** Returns the registry address carried by a packaged self-modification terminal handoff. */
|
|
442
318
|
export declare function registryHandoffAddress(subagentName: string | undefined, toolName: string | undefined, output: unknown): string | undefined;
|
|
443
|
-
export
|
|
444
|
-
url?: string;
|
|
445
|
-
userCode?: string;
|
|
446
|
-
expiresAt?: string;
|
|
447
|
-
instructions?: string;
|
|
448
|
-
};
|
|
449
|
-
export type ConnectionAuthState = "required" | "pending" | ConnectionAuthorizationOutcome;
|
|
450
|
-
export type ConnectionAuthUpdate = {
|
|
451
|
-
name: string;
|
|
452
|
-
description: string;
|
|
453
|
-
state: ConnectionAuthState;
|
|
454
|
-
challenge?: ConnectionAuthChallenge;
|
|
455
|
-
reason?: string;
|
|
456
|
-
};
|
|
319
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{PROMPT_COMMANDS,formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{failureKey,formatFailureDetail,formatFailureHint,formatFailureMessage,isInterruptedError,localFailureHint}from"./errors.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{createMcpConnectionStatusTracker}from"./mcp-connection-status.js";import
|
|
1
|
+
import{PROMPT_COMMANDS,formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{failureKey,formatFailureDetail,formatFailureHint,formatFailureMessage,interruptedError,isInterruptedError,localFailureHint}from"./errors.js";import{conversationView,isWorking,tuiSessionReducer}from"./conversation-view.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{createMcpConnectionStatusTracker}from"./mcp-connection-status.js";import{describeRemoteAuthCompletedMutations}from"./remote-auth-result.js";import{createRemoteConnectionController}from"./remote-connection.js";import{prepareRemoteTuiAccess}from"./remote-startup.js";import{isTerminalToolCallPart}from"./terminal-tool-part.js";import{userText}from"./transcript-parts.js";import{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,normalizeLocalModelEndpoint,orderedSetupIssues}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import{isTaskRetryRefusal}from"#protocol/task-tools.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{inspectApplication}from"#services/inspect-application.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{toErrorMessage}from"#shared/errors.js";import{probeAgentInfo}from"#services/dev-client/agent-info-probe.js";import{openConversationInputs}from"#client/conversation-state.js";import{EveAgentStore,attachEveAgentStore,detachEveAgentStore}from"#client/eve-agent-store.js";import{isAbortError}from"#client/eve-agent-store-helpers.js";import{normalizeActionRequest,normalizeActionResult}from"#client/message-action-parts.js";import{renderApplicationInfo}from"#cli/commands/info.js";import{createDevelopmentRuntimeArtifactRefresher}from"#services/dev-client.js";function authIssueForStatus(e){if(e===`logged-out`)return LOGIN_SETUP_ISSUE;if(e===`cli-missing`)return CLI_MISSING_SETUP_ISSUE}var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=!1;#m;#h;#g=!0;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E=!1;#D;#O=!1;#k=new AbortController;#A=!1;#j=0;#M=0;#N=[];#P;#F;#I;#L;#R;#z=new Set;#B=[];#V;#H=new Set;#U;#W=new Set;#G=new Set;#K;constructor(e){if(this.#e=e.client,e.lifecycle!==void 0&&(this.#K=e.lifecycle),e.diagnostics!==void 0&&(this.#r=e.diagnostics),this.#n=createRenderer(e),this.#t=new EveAgentStore({client:e.client,followSubagents:!0,reducer:tuiSessionReducer}),this.#t.setCallbacks({onEvent:e=>this.#Le(e),onSessionChange:e=>{e!==void 0&&this.#n.setSessionId?.(e.sessionId)},prepareSend:e=>this.#ee(e)}),this.#i=e.name??`eve`,this.#y=e.withExclusiveTerminal,this.#a=e.formatTransportError??toErrorMessage,e.initialInput!==void 0&&(this.#l=e.initialInput),e.startup!==void 0&&(this.#u=e.startup),this.#f=e.onboard===!0,this.#m=e.onOnboardingStep,this.#h=e.onOnboardingTerminal,e.appRoot!==void 0){this.#c=e.appRoot;let t={appRoot:e.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};e.detectProjectIdentity!==void 0&&(t.detectIdentity=e.detectProjectIdentity),this.#F=createVercelStatusTracker(t),e.probeMcpConnection!==void 0&&(this.#I=createMcpConnectionStatusTracker({onChange:()=>{},probe:e.probeMcpConnection}))}e.promptCommandHandler!==void 0&&(this.#_=e.promptCommandHandler),this.#v=e.availablePromptCommands??PROMPT_COMMANDS,e.remote!==void 0&&(this.#x=e.remote.runAuthFlow,this.#b=createRemoteConnectionController({client:this.#e,credentials:e.remote.credentials,target:e.remote.target,onChange:e=>this.#n.setRemoteConnectionStatus?.(e),resolveOidcToken:e.remote.resolveOidcToken,resolveDeployment:e.remote.resolveDeployment})),this.#S=e.bootDetections??BOOT_DETECTIONS,this.#C=e.getVercelAuthStatus??getVercelAuthStatus,this.#w=e.inspectApplication??inspectApplication,e.onBootProgress!==void 0&&(this.#T=e.onBootProgress),e.serverUrl!==void 0&&(this.#s=e.serverUrl),e.serverUrl!==void 0&&e.remote===void 0&&(this.#o=createDevelopmentRuntimeArtifactRefresher({serverUrl:e.serverUrl}))}async#q(){if(this.#s===void 0){this.#X(),this.#f||await this.#ve(void 0);return}let e;if(this.#b!==void 0){let t=await this.#b.check();t.state===`ready`&&(e=t.info)}else{let t=this.#e;if(t!==void 0)try{let n=await devBootPhase(`connecting to agent`,()=>probeAgentInfo({client:t,timeoutMs:2e3}),this.#T);n.kind===`ready`&&(e=n.info)}catch{e=void 0}}this.#X();let t=this.#Y(e);this.#f||await this.#ve(t)}#J(){let e=this.#u?.finish();return this.#d=e?.queuedPrompt,e?.draft??this.#l}#Y(e){let t=this.#c===void 0?e:normalizeLocalModelEndpoint(e,process.env);this.#L=t;let n=this.#s;if(n===void 0||this.#g)return t;let r={name:this.#i,serverUrl:n,localDevelopment:this.#c!==void 0};return t!==void 0&&(r.info=t),this.#n.renderAgentHeader?.(r),t}#X(){let e=this.#T;this.#T=void 0,e?.({type:`before-first-paint`})}async run(){let onStop=()=>this.#n.requestInterrupt?.();this.#K?.signal.aborted===!0?onStop():this.#K?.signal.addEventListener(`abort`,onStop,{once:!0});let e=this.#t.subscribe(()=>this.#te());attachEveAgentStore(this.#t);try{await this.#Z()}catch(e){if(!isInterruptedError(e))throw e}finally{this.#K?.signal.removeEventListener(`abort`,onStop),this.#E=!0,this.#k.abort(),this.#R?.abort(),e(),detachEveAgentStore(this.#t),this.#n.shutdown?.(),this.#F?.dispose(),this.#I?.dispose(),this.#b?.dispose()}}async#Z(){let e=this.#i,t;this.#n.setStartupPhase?.(`starting`),await this.#q(),this.#F?.refreshIdentity(),this.#I?.refresh();let n=(this.#f||this.#L?.agent.model.endpoint?.kind===`gateway`&&!this.#L.agent.model.endpoint.connected)&&this.#c!==void 0&&this.#_!==void 0&&this.#n.setupFlow!==void 0,r;if(this.#b!==void 0&&this.#n.setupFlow!==void 0){let e=await prepareRemoteTuiAccess({connection:this.#b,renderer:this.#n.setupFlow,signal:this.#K?.signal,runAuthFlow:this.#x});if(e?.kind===`authenticated`){let e=this.#b.current().connection;e.state===`ready`&&this.#Y(e.info)}else e?.kind===`failed`||e?.kind===`unavailable`?r={failed:!0,message:e.kind===`failed`?e.message:e.failure.message}:e?.kind===`cancelled`&&(r={cancelled:!0},e.completedMutations.length>0&&(r.message=`Completed before cancellation: ${describeRemoteAuthCompletedMutations(e.completedMutations).join(`, `)}.`))}n&&(this.#n.setStartupPhase?.(`connecting`),r=await this.#De(e));let i=this.#J();for(r?.cancelled||r?.failed?i=[this.#d,i].filter(Boolean).join(`
|
|
2
2
|
|
|
3
|
-
`)||void 0:t=this.#h,this.#b=!1,this.#Q(this.#z),this.#he(),this.#n.setStartupPhase?.(void 0),(!o||s?.cancelled||s?.failed)&&s?.message!==void 0&&this.#ve({kind:`result`,message:s.message});;){if(this.#Y?.signal.aborted===!0||this.#n.exitRequested?.()===!0)return;let o=this.#H[0];if(o!==void 0&&n===void 0&&this.#V===void 0){this.#H.shift(),this.#U=o;try{await this.#pe(o)}finally{this.#U=void 0}i=!1,a=!1,t=void 0;continue}if(!a){if(t==null){if(!this.#n.readPrompt){if(r)return;throw Error(`No prompt was provided and the renderer does not support prompt input.`)}let n={title:e};c!==void 0&&(n.initialDraft=c,c=void 0);try{this.#W=!0,t=await this.#oe(n)}catch(e){if(isInterruptedError(e)){if(this.#V===void 0&&this.#H.length===0)return;a=!0,t=``}else throw e}finally{this.#W=!1}if(this.#H.length>0&&this.#V===void 0){t=void 0;continue}if(t==null&&this.#V===void 0)return}let o=this.#V===void 0?parsePromptCommand(t):null;if(o?.type===`exit`){this.#ve({kind:`dismiss`}),this.#Y?.requestStop();return}if(o?.type===`cancel`&&(i=await this.#re({absent:`No active turn to cancel`,accepted:`Cancellation requested`,failed:`Couldn't cancel the turn`,invoke:e=>e.cancel()}),n=void 0,a=!1,t=void 0,!i))continue;if(o?.type===`reset`){if(!await this.#ie()){n=void 0,a=!1,t=void 0;continue}this.#ve({kind:`dismiss`}),n=void 0,a=!1,t=void 0;continue}if(o?.type===`compact`&&(i=await this.#re({absent:`No active session to compact`,accepted:`Compaction requested`,failed:`Couldn't compact the session`,invoke:e=>e.compact()}),n=void 0,a=!1,t=void 0,!i)||o?.type===`clear`&&(i=await this.#re({absent:`No active session to clear`,failed:`Couldn't clear the session`,dismissOnAccepted:!0,invoke:e=>e.clear()}),n=void 0,a=!1,t=void 0,!i))continue;if(o?.type===`help`){if(this.#n.choosePromptCommand!==void 0){let e=await this.#n.choosePromptCommand(this.#S);e!==void 0&&(c=e)}else this.#ve({kind:`result`,message:formatPromptCommandHelp(this.#S)});n=void 0,a=!1,t=void 0;continue}if(o?.type===`info`){await this.#Ee(),n=void 0,a=!1,t=void 0;continue}if(o?.type===`loglevel`){let e=this.#De(o.argument),r=e.startsWith(`/loglevel is not available`)||e.startsWith(`Unknown log level`);this.#ve(r?{kind:`result`,message:e}:{kind:`result`,summary:e}),n=void 0,a=!1,t=void 0;continue}if(o?.type===`traces`){await this.#Te(o.argument),n=void 0,a=!1,t=void 0;continue}if(o?.type===`extension`){try{await this.#Se(o,e,{trigger:`command`})}catch(e){if(isInterruptedError(e))return;throw e}n=void 0,t=void 0,a=!1;continue}r=!0}let s=this.#V;this.#V=void 0;let l=s??(i?this.#ue():await(async()=>(this.#ne(),await this.#ce({prompt:a?void 0:t,inputResponses:n})))()),u=this.#e?.state.sessionId;u!==void 0&&this.#n.setSessionId?.(u);let d=t,f=!1;try{for(;;){await this.#n.renderStream(l,{title:e,submittedPrompt:d,continueSession:!!this.#n.readPrompt,tools:this.#i,reasoning:this.#a,connectionAuth:this.#o,assistantResponseStats:this.#s,contextSize:this.#c});let r=l.turnState?.pendingApprovals??[],i=l.turnState?.pendingQuestions??[];if(r.length>0||i.length>0){let o=[];if(r.length>0){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);for(let t of r){let n=await this.#n.readToolApproval(t,{title:e});o.push({requestId:t.approvalId,optionId:n.approved?`approve`:`cancel`})}}if(i.length>0){if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);for(let t of i){let n=toAgentTUIInputQuestion(t),r=await this.#n.readInputQuestion(n,{title:e});if(r===void 0)continue;let i={requestId:t.requestId};r.optionId!==void 0&&(i.optionId=r.optionId),r.text!==void 0&&(i.text=r.text),o.push(i)}}if(o.length===0)break;a=!0,n=o,t=void 0,f=!0;break}if(this.#Ne(l)){l=this.#ue(),d=void 0;continue}if(l.turnState&&l.turnState.boundaryEvent===void 0&&!l.turnState.aborted){let e=this.#e?.state.sessionId;this.#n.renderNotice?.(e?`Lost the event stream — the turn may still be running on the server (session ${e}). Your next message resumes this session; use /cancel to stop the turn.`:`Lost the connection to the running turn.`)}break}}catch(e){if(isInterruptedError(e))return;throw e}if(f)continue;i=!1,a=!1,n=void 0,t=void 0;let p=l.turnState?.boundaryEvent;this.#J!==this.#e&&(p===`session.waiting`||p===`session.completed`)&&(t=this.#n.takeQueuedPrompt?.()),this.#ne(l.turnState?.aborted===!0)}}#te(){this.#G.abortAll(),this.#B.clear(),this.#K.clear(),this.#q.clear(),this.#n.setConnectionAuthPendingCount?.(0),this.#e=void 0,this.#u?.clear()}#ne(e=!1){let t=this.#J;t!==void 0&&(this.#J=void 0,this.#e===t&&(this.#te(),e?this.#n.renderNotice?.(`Stopped following the turn and started a new session. Earlier context was cleared; the interrupted turn may still be running on the server.`):this.#n.renderSessionBoundary===void 0?this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`):this.#n.renderSessionBoundary()))}async#re(e){let t=this.#e;if(t===void 0)return this.#ve({kind:`result`,summary:e.absent}),!1;try{return(await e.invoke(t)).status===`accepted`?(this.#ve(e.dismissOnAccepted===!0?{kind:`dismiss`}:{kind:`result`,summary:e.accepted}),!0):(this.#ve({kind:`result`,summary:e.absent}),!1)}catch(t){return this.#ve({kind:`result`,message:toErrorMessage(t),summary:e.failed}),!1}}async#ie(){if(this.#e===void 0)return this.#te(),this.#n.reset?.(),!0;try{await this.#e.reset()}catch(e){return this.#ve({kind:`result`,message:`Couldn't reset the session: ${toErrorMessage(e)}`}),!1}return this.#te(),this.#n.reset?.(),!0}async#ae(e){if(!this.#n.readPrompt)return;let t=this.#n.readPrompt(e),n=this.#u;if(n===void 0)return await t;let r=!1,i=!1,a,o=!1,s=0,refresh=async()=>{if(!(r||i)){i=!0;try{await n.refreshIdle({onRuntimeArtifactsChanged:()=>this.#je()}),this.#f!==void 0&&this.#z===void 0&&!o&&(o=!0,this.#ke().finally(()=>{o=!1}));let e=this.#z?.agent.model.endpoint,t=e?.kind===`chatgpt`&&(e.state===`signed-out`||e.state===`reauth-required`),r=Date.now();t&&r-s>=5e3&&(s=r,this.#ke())}finally{i=!1}}},startRefresh=()=>{if(r||i)return;let e=refresh().finally(()=>{a===e&&(a=void 0)});a=e};startRefresh();let c=setInterval(()=>{startRefresh()},500);c.unref?.();try{return await t}finally{r=!0,clearInterval(c),await a}}async#oe(e){let t=this.#ae(e);if(this.#n.renderIdleStream===void 0||this.#e?.state.sessionId===void 0)return await t;let n=new AbortController,r=this.#se(n.signal,e).catch(e=>{n.signal.aborted||this.#n.renderNotice?.(`Stopped following session updates: ${toErrorMessage(e)}`)});try{return await t}finally{n.abort(),await r}}async#se(e,t){let n=this.#e;if(n===void 0)return;let r=100;for(;!e.aborted;){let i=n.stream({signal:e})[Symbol.asyncIterator](),a=!1;try{for(;!e.aborted;){let r=!1,o={async*[Symbol.asyncIterator](){for(;!e.aborted;){let e=await i.next();if(e.done===!0||(r=!0,a=!0,yield e.value,isCurrentTurnBoundaryEvent(e.value)))return}}},s=this.#de(o,()=>{},n);if(await this.#n.renderIdleStream(s,{...t,continueSession:!0}),this.#Ne(s),(s.turnState?.pendingApprovals.length??0)>0||(s.turnState?.pendingQuestions.length??0)>0){this.#V={events:(async function*(){})(),turnState:s.turnState},this.#n.suspendPromptForInput?.();return}if(s.turnState?.boundaryEvent===`session.completed`||s.turnState?.boundaryEvent===`session.failed`)return;if(!r)break}}finally{await i.return?.()}r=a?100:Math.min(r*2,2e3),e.aborted||await abortableDelay(r,e)}}async#ce(e){let t=new AbortController,n={signal:t.signal};e.prompt!==void 0&&(n.message=e.prompt),e.inputResponses!==void 0&&e.inputResponses.length>0&&(n.inputResponses=e.inputResponses);let r,i=this.#e;try{if(this.#u!==void 0&&await this.#u.refresh({inputResponses:n.inputResponses,message:n.message,onRuntimeArtifactsChanged:()=>this.#je()}),n.message!==void 0&&(n.inputResponses?.length??0)===0&&this.#n.flushDelayedDevBuildErrors?.(),this.#e===void 0){if(this.#t===void 0)throw Error(`Cannot create a session without an eve client.`);if(n.message===void 0)throw Error(`Cannot answer an input request before the session starts.`);let e=await this.#t.sessions.create({...n,message:n.message});this.#e=e.session,r=e.response}else r=n.inputResponses===void 0?await this.#e.send(n.message,{signal:n.signal,turnPolicy:`queue`}):await this.#e.respond(n.inputResponses,{signal:n.signal})}catch(e){if(isInterruptedError(e))throw e;return this.#w?.reportFailure(e),this.#J=i,{events:errorOnlyTUIStream({errorText:this.#l(e)}),turnState:createTurnState()}}return this.#de(r,()=>t.abort(),this.#e)}async#le(e,t){if(e.cancelInFlight!==!0){e.cancelInFlight=!0;try{for(let n=0;n<8;n+=1){if(e.boundaryEvent!==void 0||e.aborted===!0)return;let n=e.turnId;try{if((await t?.cancel(n===void 0?void 0:{turnId:n}))?.status===`accepted`)return}catch{}await delayMs(250)}}finally{e.cancelInFlight=!1}}}#ue(){if(this.#e===void 0)throw Error(`Cannot stream a session before its first turn is accepted.`);let e=new AbortController,t=this.#e;return this.#de(t.stream({signal:e.signal}),()=>e.abort(),t)}#de(e,t,n){let r=createTurnState(),i=n===void 0?void 0:new SteeringStream(e,n);return{steer:i===void 0?void 0:e=>i.send(e),abort:()=>{r.aborted=!0,this.#J=n,i?.abort(),t()},cancel:()=>{this.#le(r,n)},events:eveEventsToTUIStream({onAssistantResponse:()=>{this.#g&&!this.#_&&(this.#_=!0,this.#v?.({flow:`onboarding`,step:`first_response`}))},events:i??e,pendingInputRequests:this.#B,turnState:r,onTaskStarted:e=>this.#G.taskStarted(e,n?.state.sessionId),onAgentStarted:e=>this.#G.agentStarted(e,n?.state.sessionId),onTurnCancelled:e=>this.#G.settleCancelledTurn(e),onConnectionAuthRequired:e=>this.#Me(e),onConnectionAuthCompleted:e=>this.#Pe(e),onRegistryHandoff:this.#f===void 0?void 0:async e=>this.#fe(e),onTerminalFailure:()=>{this.#J=n},failureHintOverride:this.#f===void 0?void 0:localFailureHint}),turnState:r}}#fe(e){this.#U===e||this.#H.includes(e)||(this.#H.push(e),this.#W&&this.#n.suspendPromptForInput?.())}async#pe(e){this.#n.renderCommandInvocation?.(`/add ${e}`),await this.#Se({type:`extension`,name:`add`,argument:e},`Add to your agent`,{trigger:`command`})}async#me(e){if(this.#f===void 0)return;let t={appRoot:this.#f,env:process.env};e!==void 0&&(t.info=e),this.#F=await detectSetupIssues(t,this.#E),this.#n.renderSetupWarning!==void 0&&(this.#he(),this.#ge())}#he(){if(this.#b)return;let e=orderedSetupIssues(this.#F,this.#I);e.length>0?this.#n.renderSetupWarning?.(formatSetupIssuesLine(e)):this.#n.clearSetupWarning?.()}async#ge(){let e=this.#f;if(e===void 0||process.env.EVE_MODEL_CONNECTION!==`ai-gateway-project`)return;let t;try{t=await this.#D(e,{signal:this.#j.signal})}catch{return}this.#A||this.#M||(this.#I=authIssueForStatus(t),this.#he())}async#_e(e){let t=this.#f;if(t===void 0||this.#n.renderSetupWarning===void 0)return;let n=++this.#N,r={appRoot:t,env:process.env};e!==void 0&&(r.info=e);try{let[e,i]=await Promise.all([detectSetupIssues(r,this.#E),process.env.EVE_MODEL_CONNECTION===`ai-gateway-project`?this.#D(t,{signal:this.#j.signal}):void 0]);if(this.#A||n!==this.#N)return;this.#F=e,this.#I=i===void 0?void 0:authIssueForStatus(i),this.#he()}catch{return}}#ve(e){if(this.#n.finishCommand!==void 0){this.#n.finishCommand(e);return}if(e.kind===`result`){let t=[e.summary,e.message].filter(Boolean).join(`
|
|
4
|
-
`);t!==``&&this.#n.renderNotice?.(t)}}async#ye(e,t){let n=this.#x;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r=this.#z?.agent.model.endpoint,i={...t,renderer:this.#n,settleOutcome:e=>this.#xe(e),chatGptAccountLabel:r?.kind===`chatgpt`&&r.state===`ready`?r.accountLabel:void 0,withExclusiveTerminal:this.#C},a=this.#R?.current(),o=a!==void 0&&Object.keys(a).length>0?{...i,disabledConnectionReasons:a}:i;return await n.handle(e,o)}async#be(e){if(e?.kind===`model-access-changed`){this.#L?.applyEffect({kind:`refresh-identity`}),this.#M=!0,await this.#Oe(e);return}e!==void 0&&(this.#L?.applyEffect(e),this.#M=!0,this.#_e(this.#z))}async#xe(e){if(e.effect===void 0)return e;let t=e.effect.kind===`model-access-changed`&&e.effect.reload?setTimeout(()=>{this.#b&&this.#n.setStartupPhase?.(`updating`),this.#n.setupFlow?.setStatus(`Loading selected model…`)},150):void 0;try{await this.#be(e.effect);let{effect:t,...n}=e;return n}catch{return{failed:!0,message:`Settings were saved, but the agent could not reload. Retry the command or restart eve dev.`}}finally{clearTimeout(t)}}async#Se(e,t,n){let r=await this.#ye(e,{...n,title:t}),i=r===void 0?void 0:await this.#xe(r);return!(n.suppressSuccessfulTranscript===!0&&i?.failed!==!0||n.suppressCancelledTranscript===!0&&i?.cancelled===!0)&&n.trigger!==`startup`&&(i===void 0?this.#ve({kind:`result`}):this.#ve({kind:`result`,message:i.message,summary:i.summary})),this.#we(),i}async#Ce(e){this.#v?.({flow:`onboarding`,step:`model_provider`});let t=await this.#Se({type:`extension`,name:`login`,argument:``},e,{trigger:`startup`,initialModelStep:`provider`});return!t?.cancelled&&t?.failed!==!0&&this.#v?.({flow:`onboarding`,step:`connection_ready`}),this.#y?.({flow:`onboarding`,step:`model_provider`,result:t?.cancelled?`cancelled`:t?.failed===!0?`error`:`completed`}),t}#we(){if(this.#b)return;let e=this.#w?.current().connection;e?.state===`ready`&&e.info!==this.#z&&(this.#z=e.info,this.#d!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#r,serverUrl:this.#d}))}async#Te(e){if(this.#f===void 0||this.#n.traceViewer===void 0){this.#ve({kind:`result`,message:`/traces is only available in local dev sessions.`});return}try{await this.#n.traceViewer.open({appRoot:this.#f,sessionId:this.#e?.state.sessionId,reference:e===``?void 0:e})}catch(e){if(isInterruptedError(e))return;throw e}finally{this.#ve({kind:`dismiss`})}}async#Ee(){let e=this.#f;if(e===void 0){this.#ve({kind:`result`,message:`/info is only available in local dev sessions.`});return}try{let t=renderApplicationInfo(await this.#O(e));this.#n.showInfoPanel===void 0?this.#ve({kind:`result`,message:t}):await this.#n.showInfoPanel(t)}catch(e){this.#ve({kind:`result`,message:`Couldn't inspect the application: ${toErrorMessage(e)}`})}}#De(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel all|stderr|sandbox|none — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use all, stderr, sandbox, or none.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`stderr`:return`Showing stderr logs only.`;case`sandbox`:return`Showing sandbox logs only.`;case`all`:return`Showing all logs.`}}async#Oe(e){let t=this.#f;t!==void 0&&(++this.#P,++this.#N,await loadDevelopmentEnvironmentFiles(t),e.reload&&await this.#u?.refreshAfterSourceChange({}),e.model&&this.#z?this.#Q({...this.#z,agent:{...this.#z.agent,model:{...this.#z.agent.model,...e.model}}}):this.#Q(this.#z),this.#F=[],this.#I=void 0,this.#he(),this.#ke())}async#ke(e=!1){let t=this.#z,n=++this.#P,r=await this.#Ae();this.#A||n!==this.#P||r===void 0||(this.#Q(r),e&&!this.#n.renderAgentHeader&&this.#n.renderNotice?.(formatAgentUpdateNotice(t,r)),this.#_e(this.#z))}async#Ae(){let e=this.#t;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}#je(){this.#ke(!0)}#Me(e){let t={name:e.data.name,description:e.data.description,state:`required`};e.data.authorization!==void 0&&(t.challenge=e.data.authorization),e.data.webhookUrl!==void 0&&(t.webhookUrl=e.data.webhookUrl),this.#K.set(e.data.name,t),this.#Fe(t)}#Ne(e){if(e.turnState?.boundaryEvent!==`session.waiting`)return!1;let t=!1;for(let e of this.#K.values())e.state===`required`&&e.webhookUrl!==void 0&&(e.state=`pending`,this.#q.add(e.name),this.#Fe(e),t=!0);return t&&this.#n.setConnectionAuthPendingCount?.(this.#q.size),this.#q.size>0}#Pe(e){let t=this.#K.get(e.data.name)??{name:e.data.name,description:``,state:e.data.outcome};t.state=e.data.outcome,e.data.reason!==void 0&&(t.reason=e.data.reason),this.#K.set(e.data.name,t),this.#q.delete(e.data.name),this.#Fe(t),this.#n.setConnectionAuthPendingCount?.(this.#q.size)}#Fe(e){let t={name:e.name,description:e.description,state:e.state};e.challenge!==void 0&&(t.challenge=e.challenge),e.reason!==void 0&&(t.reason=e.reason),this.#n.upsertConnectionAuth?.(t)}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,availablePromptCommands:e.availablePromptCommands,argumentSuggestions:e.argumentSuggestions,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}function registryHandoffAddress(e,t,n){if((e!==`self-modification__agent`||t!==`registry_add`)&&(e!==void 0||t!==`selfmod__registry_add`)||typeof n!=`object`||!n)return;let r=n;return r.status===`needs-terminal`&&typeof r.address==`string`?r.address:void 0}async function*eveEventsToTUIStream(e){let{events:t,pendingInputRequests:n,turnState:r,onTaskStarted:i,onAgentStarted:a,onTurnCancelled:o,onConnectionAuthRequired:s,onConnectionAuthCompleted:c,onRegistryHandoff:l,onTerminalFailure:u,failureHintOverride:d}=e,f=new Map,p=new Map,m=new Map,h=createEventDeduper(),g=0,_=new Set,v=new Set,y=new Set,b=new Set,x=new Set,S=!1,C=!1,w;for await(let T of t)if(h.admit(T)&&!(C&&isPostTurnVisibleEvent(T)))switch(T.type){case`session.started`:case`message.received`:break;case`turn.started`:T.data.turnId!==r.turnId&&(C=!1),r.turnId=T.data.turnId,yield{type:`turn-start`,turnId:T.data.turnId};break;case`step.started`:g+=1,yield{type:`step-start`,modelId:T.data.modelId};break;case`step.completed`:{let e=T;w=e.data.usage,yield*closeOpenParts(f,`assistant-complete`,g),yield*closeOpenParts(p,`reasoning-complete`,g),yield{type:`step-finish`,usage:e.data.usage};break}case`message.appended`:{let t=T,n=textPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(f,n);if(r.completed){if(g<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}let i=t.data.messageDelta;if(i.length===0)break;r.text+=i,i&&e.onAssistantResponse?.(),yield{type:`assistant-delta`,id:partGenerationId(n,r.generation),delta:i};break}case`message.completed`:{let t=textPartId(T.data.turnId,T.data.stepIndex),n=partStateFor(f,t),r=T.data.message;if(n.completed){if(g<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=g,yield{type:`assistant-complete`,id:partGenerationId(t,n.generation),text:r};break}let i=partGenerationId(t,n.generation);if(n.text.length===0)n.text=r,n.completed=!0,n.completedEpoch=g,yield{type:`assistant-complete`,id:i,text:r};else if(r.startsWith(n.text)){let t=r.slice(n.text.length);t.length>0&&(t&&e.onAssistantResponse?.(),yield{type:`assistant-delta`,id:i,delta:t}),n.text=r,n.completed=!0,n.completedEpoch=g,yield{type:`assistant-complete`,id:i}}else n.text=r,n.completed=!0,n.completedEpoch=g,yield{type:`assistant-complete`,id:i,text:r};break}case`reasoning.appended`:{let e=T,t=reasoningPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(p,t);if(n.completed){if(g<=n.completedEpoch)break;n.generation+=1,n.text=``,n.completed=!1}let r=e.data.reasoningDelta;if(r.length===0)break;n.text+=r,yield{type:`reasoning-delta`,id:partGenerationId(t,n.generation),delta:r};break}case`reasoning.completed`:{let e=reasoningPartId(T.data.turnId,T.data.stepIndex),t=partStateFor(p,e),n=T.data.reasoning;if(t.completed){if(n.length===0||g<=t.completedEpoch)break;t.generation+=1,t.text=n,t.completedEpoch=g;let r=partGenerationId(e,t.generation);yield{type:`reasoning-delta`,id:r,delta:n},yield{type:`reasoning-complete`,id:r};break}let r=partGenerationId(e,t.generation);if(t.text.length===0&&n.length>0)t.text=n,yield{type:`reasoning-delta`,id:r,delta:n};else if(n.length>0&&!n.startsWith(t.text)){yield{type:`reasoning-complete`,id:r},t.generation+=1,t.text=n,t.completed=!0,t.completedEpoch=g;let i=partGenerationId(e,t.generation);yield{type:`reasoning-delta`,id:i,delta:n},yield{type:`reasoning-complete`,id:i};break}t.completed=!0,t.completedEpoch=g,yield{type:`reasoning-complete`,id:r};break}case`action.input.appended`:{let{callId:e,toolName:t}=T.data;if(_.has(e)||v.has(e)||isTaskControlTool(t))break;v.add(e),yield{type:`tool-call-preparing`,toolCallId:e,toolName:t};break}case`actions.requested`:{let e=T.data,t=e.actions.flatMap(e=>e.kind===`tool-call`&&e.parentCallId===void 0&&!isTaskControlTool(e.toolName)?[e]:[]);if(t.length===0)break;g+=1;for(let n of t){if(m.set(n.callId,n.toolName),_.has(n.callId))continue;_.add(n.callId);let t={type:`tool-call`,toolCallId:n.callId,toolName:n.toolName,input:n.input},r=e.presentation?.[n.callId]?.label;r!==void 0&&(t.label=r),yield t}break}case`input.requested`:{let e=T.data.requests.filter(e=>e.action.kind===`tool-call`&&!isTaskControlTool(e.action.toolName));if(e.length===0)break;for(let t of e){let e=t.action.callId;if(m.set(e,t.action.toolName),t.kind!==`session-limit`&&!_.has(e)&&(_.add(e),yield{type:`tool-call`,toolCallId:e,toolName:t.action.toolName,input:t.action.input}),!b.has(t.requestId)){if(b.add(t.requestId),n.set(t.requestId,t),t.kind!==`tool-approval`){upsertPendingQuestion(r,t);continue}upsertPendingApproval(r,t),yield{type:`tool-approval-request`,approvalId:t.requestId,toolCallId:e}}}break}case`approval.candidate`:{if(T.data.outcome===`pending`)break;let e=n.get(T.data.requestId);e!==void 0&&upsertPendingApproval(r,e);break}case`approval.settled`:case`input.resolved`:{let e=new Set(T.type===`input.resolved`?T.data.resolutions.map(e=>e.requestId):[T.data.requestId]);for(let t of e)n.delete(t);r.pendingApprovals=r.pendingApprovals.filter(t=>!e.has(t.approvalId)),r.pendingQuestions=r.pendingQuestions.filter(t=>!e.has(t.requestId));break}case`action.result`:{let e=T;if(e.data.result.kind!==`tool-result`)break;let t=e.data.result.callId;if(!_.has(t)||y.has(t))break;if(isTaskRetryRefusal(e)){yield{type:`tool-withdrawn`,toolCallId:t,reason:formatActionResultError(e)};break}switch(g+=1,e.data.status){case`completed`:{let n=e.data.result.output,r={type:`tool-result`,toolCallId:t,output:n},i=e.data.presentation?.[t]?.label;i!==void 0&&(r.label=i),yield r;let a=registryHandoffAddress(void 0,m.get(t),n);a!==void 0&&await l?.(a);break}case`failed`:yield{type:`tool-error`,toolCallId:t,errorText:formatActionResultError(e)};break;case`rejected`:yield{type:`tool-rejected`,toolCallId:t,reason:formatActionResultError(e)}}break}case`step.failed`:case`turn.failed`:{let e=toFailureEvent(T,x,d);e&&(yield e);break}case`session.failed`:{r.sawSessionFailure=!0,u?.(T);let e=toFailureEvent(T,x,d);e&&(yield e),r.boundaryEvent=T.type,yield*closeOpenParts(f,`assistant-complete`,g),yield*closeOpenParts(p,`reasoning-complete`,g),yield{type:`finish`,usage:w},S=!0;return}case`session.waiting`:case`session.completed`:r.boundaryEvent=T.type,yield*closeOpenParts(f,`assistant-complete`,g),yield*closeOpenParts(p,`reasoning-complete`,g),yield{type:`finish`,usage:w},S=!0;return;case`turn.waiting`:if(r.pendingApprovals.length===0&&r.pendingQuestions.length===0)break;r.boundaryEvent=T.type,yield*closeOpenParts(f,`assistant-complete`,g),yield*closeOpenParts(p,`reasoning-complete`,g),yield{type:`finish`,usage:w},S=!0;return;case`turn.completed`:C=!0,yield*closeOpenParts(f,`assistant-complete`,g),yield*closeOpenParts(p,`reasoning-complete`,g);break;case`turn.cancelled`:o?.(T.data.turnId),yield*closeOpenParts(f,`assistant-complete`,g),yield*closeOpenParts(p,`reasoning-complete`,g),yield{type:`turn-cancelled`};break;case`task.started`:y.add(T.data.callId),i?.(T),yield{type:`task-started`,toolCallId:T.data.callId,kind:T.data.kind,toolName:T.data.name};break;case`agent.started`:a?.(T);break;case`task.settled`:{let{callId:e,error:t,output:n,status:r}=T.data,i={type:`task-settled`,toolCallId:e,status:r};n!==void 0&&(i.output=n),t!==void 0&&(i.errorText=t.message),yield i;break}case`authorization.required`:s?.(T);break;case`authorization.completed`:c?.(T)}S||(yield*closeOpenParts(f,`assistant-complete`,g),yield*closeOpenParts(p,`reasoning-complete`,g),yield{type:`finish`,usage:w})}async function*errorOnlyTUIStream(e){yield{type:`error`,errorText:e.errorText},yield{type:`finish`}}function createTurnState(){return{aborted:!1,pendingApprovals:[],pendingQuestions:[],sawSessionFailure:!1}}function upsertPendingApproval(e,t){let n=toAgentTUIToolApprovalRequest(t),r=e.pendingApprovals.findIndex(e=>e.approvalId===n.approvalId);r===-1?e.pendingApprovals.push(n):e.pendingApprovals[r]=n}function toAgentTUIToolApprovalRequest(e){return{approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,input:e.action.input}}function upsertPendingQuestion(e,t){let n=e.pendingQuestions.findIndex(e=>e.requestId===t.requestId);n===-1?e.pendingQuestions.push(t):e.pendingQuestions[n]=t}function textPartId(e,t){return`text:${e}:${t}`}function reasoningPartId(e,t){return`reasoning:${e}:${t}`}function partStateFor(e,t){let n=e.get(t);return n===void 0&&(n={generation:0,text:``,completed:!1,completedEpoch:0},e.set(t,n)),n}function partGenerationId(e,t){return t===0?e:`${e}#${t}`}function*closeOpenParts(e,t,n){for(let[r,i]of e)i.completed||i.text.length===0||(i.completed=!0,i.completedEpoch=n,yield{type:t,id:partGenerationId(r,i.generation)})}function isPostTurnVisibleEvent(e){switch(e.type){case`actions.requested`:case`authorization.completed`:case`authorization.required`:case`input.requested`:case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:case`result.completed`:case`step.completed`:case`step.failed`:case`step.started`:case`agent.started`:case`task.settled`:case`task.started`:case`turn.completed`:case`turn.failed`:return!0;default:return!1}}function formatActionResultError(e){if(e.data.error?.message)return e.data.error.message;let t=e.data.result.output;if(typeof t==`string`)return t;try{return JSON.stringify(t)}catch{return`Tool execution failed.`}}function toFailureEvent(e,t,n){let r=failureKey(e);if(t.has(r))return;t.add(r);let i={type:`error`,errorText:formatFailureMessage(e)},a=n?.(e)??formatFailureHint(e);a!==void 0&&(i.hint=a);let o=formatFailureDetail(e);return o!==void 0&&(i.detail=o),i}function toAgentTUIInputQuestion(e){let t=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,n={requestId:e.requestId,prompt:e.prompt,display:t};return e.options!==void 0&&(n.options=e.options.map(e=>{let t={id:e.id,label:e.label};return e.description!==void 0&&(t.description=e.description),e.style!==void 0&&(t.style=e.style),t})),e.allowFreeform!==void 0&&(n.allowFreeform=e.allowFreeform),n}export{EveTUIRunner,registryHandoffAddress};
|
|
3
|
+
`)||void 0:t=this.#d,this.#g=!1,this.#Y(this.#L),this.#ye(),this.#n.setStartupPhase?.(void 0),(!n||r?.cancelled||r?.failed)&&r?.message!==void 0&&this.#Se({kind:`result`,message:r.message});this.#K?.signal.aborted!==!0&&this.#n.exitRequested?.()!==!0;){if(this.#t.snapshot.data.sessionFailed){this.#ce();continue}if(this.#ae().length>0){await this.#oe(e);continue}let n=isWorking(this.#t.snapshot.status)?void 0:this.#B.shift();if(n!==void 0){this.#V=n;try{await this.#_e(n)}finally{this.#V=void 0}continue}if(t===void 0){let n=await this.#me({title:e,initialDraft:i});if(i=void 0,n===void 0)continue;if(n.type===`cancel`){this.#de();continue}if(n.type===`interrupt`){this.#ce(`Stopped following the turn and started a new session. Earlier context was cleared; the interrupted turn may still be running on the server.`);continue}t=n.text}let r=t;t=void 0;let a=parsePromptCommand(r);if(a===null){this.#$(r);continue}let o=await this.#Q(a,e);if(o===`exit`)return;o!==void 0&&(i=o.draft)}}async#Q(e,t){switch(e.type){case`exit`:return this.#Se({kind:`dismiss`}),this.#K?.requestStop(),`exit`;case`cancel`:{let e=isWorking(this.#t.snapshot.status);e&&this.#de(),this.#Se({kind:`result`,summary:e?`Cancellation requested`:`No active turn to cancel`});return}case`reset`:await this.#pe();return;case`compact`:await this.#fe({absent:`No active session to compact`,accepted:`Compaction requested`,failed:`Couldn't compact the session`,invoke:()=>this.#t.compact()});return;case`clear`:await this.#fe({absent:`No active session to clear`,failed:`Couldn't clear the session`,dismissOnAccepted:!0,invoke:()=>this.#t.clear()});return;case`help`:{if(this.#n.choosePromptCommand===void 0){this.#Se({kind:`result`,message:formatPromptCommandHelp(this.#v)});return}let e=await this.#n.choosePromptCommand(this.#v);return e===void 0?void 0:{draft:e}}case`info`:await this.#Ae();return;case`loglevel`:{let t=this.#je(e.argument),n=t.startsWith(`/loglevel is not available`)||t.startsWith(`Unknown log level`);this.#Se(n?{kind:`result`,message:t}:{kind:`result`,summary:t});return}case`traces`:await this.#ke(e.argument);return;case`extension`:await this.#Ee(e,t,{trigger:`command`});return}}#$(e){let t=this.#t.snapshot,n=isWorking(t.status);this.#D=e,n||(this.#O=!1);let r=n?{message:e,turnPolicy:`steer`}:t.session===void 0?{message:e}:{message:e,turnPolicy:`queue`};this.#t.send(r).catch(e=>{this.#E||isAbortError(e)||this.#n.renderError?.(n?`Steering failed`:`Error`,this.#a(e))})}async#ee(e){return e.turnPolicy===`steer`?e:(this.#o!==void 0&&await this.#o.refresh({inputResponses:e.inputResponses,message:typeof e.message==`string`?e.message:void 0,onRuntimeArtifactsChanged:()=>this.#Fe()}),e.message!==void 0&&this.#n.flushDelayedDevBuildErrors?.(),e)}#te(){let e=this.#t.snapshot;this.#n.renderConversation?.(conversationView(e,this.#c===void 0?void 0:localFailureHint)),this.#re(e.error,e.data.sessionFailed),this.#Ie(e.conversation),this.#ie(e.conversation),this.#ge(e.conversation),this.#ne(e.conversation),(e.data.sessionFailed||this.#ae().length>0||!isWorking(e.status)&&this.#B.length>0)&&this.#R?.abort()}#ne(e){let t=this.#D;if(t===void 0)return;let n=e.messages.findLast(e=>e.role===`user`),r=n?.metadata?.turnId;if(n===void 0||r===void 0||userText(n)!==t)return;let i=e.turns[r]?.status;i!==void 0&&i!==`active`&&(this.#D=void 0,i===`cancelled`&&!this.#O&&this.#n.restoreDraft?.(t))}#re(e,t){e!==void 0&&e!==this.#U&&(this.#U=e,!t&&(this.#b?.reportFailure(e),this.#n.renderError?.(`Error`,this.#a(e))))}#ie(e){!this.#f||this.#p||!e.messages.some(e=>e.role===`assistant`&&e.parts.some(e=>e.type===`text`&&e.text.length>0))||(this.#p=!0,this.#m?.({flow:`onboarding`,step:`first_response`}))}#ae(){return openConversationInputs(this.#t.snapshot.conversation).filter(e=>!this.#z.has(e.request.requestId))}async#oe(e){for(let t=0;;t+=1){let n=this.#ae(),r=n[0];if(r===void 0)return;let i=inputContext(r,t+1,t+n.length),a=await this.#se(r.request,i,e);if(a===void 0){this.#z.add(r.request.requestId);continue}this.#t.send({inputResponses:[a]}).catch(e=>{this.#E||isAbortError(e)||this.#n.renderError?.(`Error`,this.#a(e))})}}async#se(e,t,n){if(e.kind===`tool-approval`){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);let r=await this.#n.readToolApproval(toAgentTUIToolApprovalRequest(e,t),{title:n});return{requestId:e.requestId,optionId:r.approved?`approve`:`cancel`}}if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);let r=await this.#n.readInputQuestion(toAgentTUIInputQuestion(e,t),{title:n});if(r===void 0)return;let i={requestId:e.requestId};return r.optionId!==void 0&&(i.optionId=r.optionId),r.text!==void 0&&(i.text=r.text),i}#ce(e){this.#n.renderSessionBoundary===void 0?e===void 0&&this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`):this.#n.renderSessionBoundary(),e!==void 0&&this.#n.renderNotice?.(e),this.#le()}#le(){this.#t.reset(),this.#ue()}#ue(){this.#z.clear(),this.#H.clear(),this.#W.clear(),this.#o?.clear()}#de(){this.#O=!0,this.#t.cancel().catch(e=>{this.#n.renderNotice?.(`Couldn't cancel the turn: ${toErrorMessage(e)}`)})}async#fe(e){if(this.#t.snapshot.session===void 0){this.#Se({kind:`result`,summary:e.absent});return}try{if((await e.invoke()).status!==`accepted`){this.#Se({kind:`result`,summary:e.absent});return}this.#Se(e.dismissOnAccepted===!0?{kind:`dismiss`}:{kind:`result`,summary:e.accepted})}catch(t){this.#Se({kind:`result`,message:toErrorMessage(t),summary:e.failed})}}async#pe(){try{await this.#t.retire()}catch(e){this.#Se({kind:`result`,message:`Couldn't reset the session: ${toErrorMessage(e)}`});return}this.#ue(),this.#n.reset?.(),this.#Se({kind:`dismiss`})}async#me(e){if(!this.#n.readInput)throw Error(`The renderer does not support prompt input.`);let t=new AbortController;this.#R=t;try{let n=await this.#he(this.#n.readInput({...e,signal:t.signal}));if(n===void 0&&!t.signal.aborted)throw interruptedError();return n}finally{this.#R===t&&(this.#R=void 0)}}async#he(e){let t=this.#o;if(t===void 0)return await e;let n=!1,r=!1,i,a=!1,o=0,refresh=async()=>{if(!(n||r)){r=!0;try{await t.refreshIdle({onRuntimeArtifactsChanged:()=>this.#Fe()}),this.#c!==void 0&&this.#L===void 0&&!a&&(a=!0,this.#Ne().finally(()=>{a=!1}));let e=this.#L?.agent.model.endpoint,n=e?.kind===`chatgpt`&&(e.state===`signed-out`||e.state===`reauth-required`),r=Date.now();n&&r-o>=5e3&&(o=r,this.#Ne())}finally{r=!1}}},startRefresh=()=>{if(n||r)return;let e=refresh().finally(()=>{i===e&&(i=void 0)});i=e};startRefresh();let s=setInterval(()=>{startRefresh()},500);s.unref?.();try{return await e}finally{n=!0,clearInterval(s),await i}}#ge(e){if(this.#c!==void 0)for(let{callId:t,address:n}of registryHandoffs(e))this.#H.has(t)||(this.#H.add(t),!(this.#V===n||this.#B.includes(n))&&this.#B.push(n))}async#_e(e){this.#n.renderCommandInvocation?.(`/add ${e}`),await this.#Ee({type:`extension`,name:`add`,argument:e},`Add to your agent`,{trigger:`command`})}async#ve(e){if(this.#c===void 0)return;let t={appRoot:this.#c,env:process.env};e!==void 0&&(t.info=e),this.#N=await detectSetupIssues(t,this.#S),this.#n.renderSetupWarning!==void 0&&(this.#ye(),this.#be())}#ye(){if(this.#g)return;let e=orderedSetupIssues(this.#N,this.#P);e.length>0?this.#n.renderSetupWarning?.(formatSetupIssuesLine(e)):this.#n.clearSetupWarning?.()}async#be(){let e=this.#c;if(e===void 0||process.env.EVE_MODEL_CONNECTION!==`ai-gateway-project`)return;let t;try{t=await this.#C(e,{signal:this.#k.signal})}catch{return}this.#E||this.#A||(this.#P=authIssueForStatus(t),this.#ye())}async#xe(e){let t=this.#c;if(t===void 0||this.#n.renderSetupWarning===void 0)return;let n=++this.#j,r={appRoot:t,env:process.env};e!==void 0&&(r.info=e);try{let[e,i]=await Promise.all([detectSetupIssues(r,this.#S),process.env.EVE_MODEL_CONNECTION===`ai-gateway-project`?this.#C(t,{signal:this.#k.signal}):void 0]);if(this.#E||n!==this.#j)return;this.#N=e,this.#P=i===void 0?void 0:authIssueForStatus(i),this.#ye()}catch{return}}#Se(e){if(this.#n.finishCommand!==void 0){this.#n.finishCommand(e);return}if(e.kind===`result`){let t=[e.summary,e.message].filter(Boolean).join(`
|
|
4
|
+
`);t!==``&&this.#n.renderNotice?.(t)}}async#Ce(e,t){let n=this.#_;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r=this.#L?.agent.model.endpoint,i={...t,renderer:this.#n,settleOutcome:e=>this.#Te(e),chatGptAccountLabel:r?.kind===`chatgpt`&&r.state===`ready`?r.accountLabel:void 0,withExclusiveTerminal:this.#y},a=this.#I?.current(),o=a!==void 0&&Object.keys(a).length>0?{...i,disabledConnectionReasons:a}:i;return await n.handle(e,o)}async#we(e){if(e?.kind===`model-access-changed`){this.#F?.applyEffect({kind:`refresh-identity`}),this.#A=!0,await this.#Me(e);return}e!==void 0&&(this.#F?.applyEffect(e),this.#A=!0,this.#xe(this.#L))}async#Te(e){if(e.effect===void 0)return e;let t=e.effect.kind===`model-access-changed`&&e.effect.reload?setTimeout(()=>{this.#g&&this.#n.setStartupPhase?.(`updating`),this.#n.setupFlow?.setStatus(`Loading selected model…`)},150):void 0;try{await this.#we(e.effect);let{effect:t,...n}=e;return n}catch{return{failed:!0,message:`Settings were saved, but the agent could not reload. Retry the command or restart eve dev.`}}finally{clearTimeout(t)}}async#Ee(e,t,n){let r=await this.#Ce(e,{...n,title:t}),i=r===void 0?void 0:await this.#Te(r);return!(n.suppressSuccessfulTranscript===!0&&i?.failed!==!0||n.suppressCancelledTranscript===!0&&i?.cancelled===!0)&&n.trigger!==`startup`&&(i===void 0?this.#Se({kind:`result`}):this.#Se({kind:`result`,message:i.message,summary:i.summary})),this.#Oe(),i}async#De(e){this.#m?.({flow:`onboarding`,step:`model_provider`});let t=await this.#Ee({type:`extension`,name:`login`,argument:``},e,{trigger:`startup`,initialModelStep:`provider`});return!t?.cancelled&&t?.failed!==!0&&this.#m?.({flow:`onboarding`,step:`connection_ready`}),this.#h?.({flow:`onboarding`,step:`model_provider`,result:t?.cancelled?`cancelled`:t?.failed===!0?`error`:`completed`}),t}#Oe(){if(this.#g)return;let e=this.#b?.current().connection;e?.state===`ready`&&e.info!==this.#L&&(this.#L=e.info,this.#s!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#i,serverUrl:this.#s}))}async#ke(e){if(this.#c===void 0||this.#n.traceViewer===void 0){this.#Se({kind:`result`,message:`/traces is only available in local dev sessions.`});return}try{await this.#n.traceViewer.open({appRoot:this.#c,sessionId:this.#t.snapshot.session?.sessionId,reference:e===``?void 0:e})}catch(e){if(isInterruptedError(e))return;throw e}finally{this.#Se({kind:`dismiss`})}}async#Ae(){let e=this.#c;if(e===void 0){this.#Se({kind:`result`,message:`/info is only available in local dev sessions.`});return}try{let t=renderApplicationInfo(await this.#w(e));this.#n.showInfoPanel===void 0?this.#Se({kind:`result`,message:t}):await this.#n.showInfoPanel(t)}catch(e){this.#Se({kind:`result`,message:`Couldn't inspect the application: ${toErrorMessage(e)}`})}}#je(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel none|error|warn|debug|all — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use none, error, warn, debug, or all.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`error`:return`Showing errors.`;case`warn`:return`Showing warnings and errors.`;case`debug`:return`Showing all severity-tagged logs.`;case`all`:return`Showing all logs.`}}async#Me(e){let t=this.#c;t!==void 0&&(++this.#M,++this.#j,await loadDevelopmentEnvironmentFiles(t),e.reload&&await this.#o?.refreshAfterSourceChange({}),e.model&&this.#L?this.#Y({...this.#L,agent:{...this.#L.agent,model:{...this.#L.agent.model,...e.model}}}):this.#Y(this.#L),this.#N=[],this.#P=void 0,this.#ye(),this.#Ne())}async#Ne(e=!1){let t=this.#L,n=++this.#M,r=await this.#Pe();this.#E||n!==this.#M||r===void 0||(this.#Y(r),e&&!this.#n.renderAgentHeader&&this.#n.renderNotice?.(formatAgentUpdateNotice(t,r)),this.#xe(this.#L))}async#Pe(){let e=this.#e;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}#Fe(){this.#Ne(!0)}#Ie(e){let t=this.#r;if(t!==void 0){for(let n of Object.values(e.agents))if(n.observation.status!==`not-followed`)for(let e of n.observation.conversation?.messages??[])for(let r of e.parts)r.type===`dynamic-tool`&&r.state===`output-error`&&(this.#G.has(r.toolCallId)||(this.#G.add(r.toolCallId),t.append({source:`tool`,summary:`${r.toolName} failed (subagent ${n.name})`,detail:r.errorText})))}}#Le(e){let t=this.#r;if(t!==void 0)switch(e.type){case`turn.started`:this.#W.clear();break;case`actions.requested`:for(let n of e.data.actions){let e=normalizeActionRequest(n);e.kind===`tool-call`&&t.recordToolCall(e.toolName)}break;case`action.result`:isTaskRetryRefusal(e)?t.append({source:`tool`,summary:`${normalizeActionResult(e.data.result).toolName} was refused for the model to retry`,detail:e.data.error?.message??`Refused.`}):e.data.status===`failed`&&t.append({source:`tool`,summary:`${normalizeActionResult(e.data.result).toolName} failed`,detail:e.data.error?.message??`Tool failed.`});break;case`agent.started`:t.recordSubagentDispatch(e.data.callId);break;case`step.completed`:t.recordStepUsage(e.data.usage);break;case`step.failed`:case`turn.failed`:case`session.failed`:{let n=failureKey(e);if(this.#W.has(n))break;this.#W.add(n);let r=formatFailureMessage(e),i=formatFailureDetail(e)??r,a=formatFailureHint(e);t.append(a===void 0?{source:`workflow`,summary:`Error: ${r}`,detail:i}:{source:`workflow`,summary:`Error: ${r}`,detail:i,hint:a});break}}}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,availablePromptCommands:e.availablePromptCommands,argumentSuggestions:e.argumentSuggestions,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}function registryHandoffs(e){let t=[],collect=(e,n)=>{for(let r of e.messages)for(let e of r.parts){if(!isTerminalToolCallPart(e)||e.state!==`output-available`||e.partial)continue;let r=registryHandoffAddress(n,e.toolName,e.output);r!==void 0&&t.push({callId:e.toolCallId,address:r})}};collect(e,void 0);for(let t of Object.values(e.agents)){if(t.observation.status===`not-followed`)continue;let e=t.observation.conversation;e!==void 0&&collect(e,t.name)}return t}function registryHandoffAddress(e,t,n){if((e!==`self-modification__agent`||t!==`registry_add`)&&(e!==void 0||t!==`selfmod__registry_add`)||typeof n!=`object`||!n)return;let r=n;return r.status===`needs-terminal`&&typeof r.address==`string`?r.address:void 0}function inputContext(e,t,n){let r={};return n>1&&(r.position={index:t,total:n}),e.taskId!==void 0&&(r.taskId=e.taskId),r.position===void 0&&r.taskId===void 0?void 0:r}function toAgentTUIToolApprovalRequest(e,t){let n={approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,input:e.action.input};return t!==void 0&&(n.context=t),n}function toAgentTUIInputQuestion(e,t){let n=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,r={requestId:e.requestId,prompt:e.prompt,display:n};return e.options!==void 0&&(r.options=e.options.map(e=>{let t={id:e.id,label:e.label};return e.description!==void 0&&(t.description=e.description),e.style!==void 0&&(t.style=e.style),t})),e.allowFreeform!==void 0&&(r.allowFreeform=e.allowFreeform),t!==void 0&&(r.context=t),r}export{EveTUIRunner,registryHandoffAddress};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* The tasks a turn has working: agents and tools that keep running while the
|
|
3
3
|
* turn goes on. The transcript only ever grows at its end, so a task writes
|
|
4
4
|
* one line when it starts and one when it ends; what it is doing in between
|
|
5
|
-
* lives here
|
|
6
|
-
*
|
|
5
|
+
* lives here in the activity drawer above the prompt, keeping live updates
|
|
6
|
+
* out of immutable terminal scrollback.
|
|
7
7
|
*/
|
|
8
8
|
import type { Block } from "./blocks.js";
|
|
9
9
|
import type { Theme } from "./theme.js";
|
|
@@ -17,6 +17,10 @@ export interface TaskEntry {
|
|
|
17
17
|
readonly input: unknown;
|
|
18
18
|
readonly label: string | undefined;
|
|
19
19
|
readonly startedAtMs: number;
|
|
20
|
+
readonly purpose?: string;
|
|
21
|
+
readonly children?: readonly TaskEntry[];
|
|
22
|
+
readonly omittedTasks?: number;
|
|
23
|
+
readonly omittedAttention?: boolean;
|
|
20
24
|
/** An agent's latest words or thinking, one line. */
|
|
21
25
|
step?: string;
|
|
22
26
|
/** Settled, waiting only for the agent's own last events. */
|
|
@@ -43,13 +47,13 @@ export declare class TaskActivity {
|
|
|
43
47
|
}
|
|
44
48
|
/** Joins the working tasks' names for the turn bar: `Waiting for researcher and reviewer`. */
|
|
45
49
|
export declare function waitingLabel(entries: readonly TaskEntry[]): string;
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
* capped so a wide fan-out cannot push the prompt off screen.
|
|
49
|
-
*/
|
|
50
|
+
/** Names the connections a parked session waits on: `Waiting for sign-in to Linear`. */
|
|
51
|
+
export declare function signInLabel(names: readonly string[]): string;
|
|
50
52
|
export declare function renderTaskPanelRows(entries: readonly TaskEntry[], options: {
|
|
51
53
|
readonly width: number;
|
|
52
54
|
readonly theme: Theme;
|
|
53
55
|
readonly nowMs: number;
|
|
54
|
-
readonly
|
|
56
|
+
readonly activity?: string;
|
|
57
|
+
readonly turnElapsedMs?: number;
|
|
58
|
+
readonly maxRows?: number;
|
|
55
59
|
}): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{truncate}from"./tool-format.js";import"./
|
|
1
|
+
import{truncate}from"./tool-format.js";import{renderTransientDrawer}from"./flow-drawer.js";import{agentTaskLabel,isSelfModificationAgent}from"./tool-presentation.js";import{formatTurnDuration}from"./stream-format.js";import{clipVisible,visibleLength}from"#cli/ui/terminal-text.js";var TaskActivity=class{#e=new Map;start(e){let t={callId:e.callId,kind:e.kind,name:this.#t(e.baseName),toolName:e.toolName,input:e.input,label:e.label,startedAtMs:e.nowMs,childTools:new Map};return this.#e.set(e.callId,t),t}get(e){return this.#e.get(e)}finish(e){let t=this.#e.get(e);return this.#e.delete(e),t}working(){return[...this.#e.values()]}clear(){this.#e.clear()}#t(e){let t=new Set([...this.#e.values()].map(e=>e.name));if(!t.has(e))return e;for(let n=2;;n+=1){let r=`${e}:${String(n)}`;if(!t.has(r))return r}}};function waitingLabel(e){if(e.length===1&&isSelfModificationAgent(e[0].toolName))return`Modifying your agent`;let t=e.map(taskLabel);return t.length===1?`Waiting for ${t[0]}`:t.length===2?`Waiting for ${t[0]} and ${t[1]}`:`Waiting for ${String(t.length)} tasks`}function signInLabel(e){let t=[...new Set(e)];return t.length===1?`Waiting for sign-in to ${t[0]}`:t.length===2?`Waiting for sign-in to ${t[0]} and ${t[1]}`:`Waiting for ${String(t.length)} sign-ins`}function currentActivity(e){if(e.finishing===!0)return{text:`Finishing`,attention:!1};let t=[...e.childTools.values()],n=t.findLast(e=>e.status===`approval`);if(n!==void 0)return{text:`Needs your approval: ${n.title??`tool`}`,attention:!0};let r=t.findLast(e=>e.status===`running`);if(r!==void 0)return{text:r.title??`Working`,attention:!1};let i=t.at(-1);return i?.title===void 0?e.step===void 0?{text:``,attention:!1}:{text:e.step,attention:!1}:{text:i.title,attention:!1}}function taskLabel(e){return e.kind===`agent`?agentTaskLabel(e.name):e.name}function panelEntries(e){let t=[],visit=(e,n)=>{for(let r of e)t.push({entry:r,path:n}),visit(r.children??[],[...n,r])};return visit(e,[]),t}function renderTaskPanelRows(e,t){if(e.length===0)return[];let{width:n,theme:r,nowMs:i}=t,a=r.colors,o=panelEntries(e),s=o.reduce((e,{entry:t})=>e+(t.omittedTasks??0),0),c=o.some(({entry:e})=>e.omittedAttention),l=o.length+s,u=Math.max(2,Math.min(15,t.maxRows??15)),d=u>=5,f=Math.max(0,u-(d?4:2)),p=s>0||o.length*2>f,m=Math.max(0,Math.floor((f-+!!p)/2)),h=o.filter(({entry:e})=>currentActivity(e).attention),g=new Set([...h,...o.filter(e=>!h.includes(e))].slice(0,m)),_=o.filter(e=>g.has(e)),v=[];for(let{entry:e,path:t}of _){let o=t.length>0,s=` ${o?`${r.glyph.corner} `:``}`,c=_.some(e=>e.entry===t.at(-1))?t.slice(1):t,l=c.length>0?`${c.map(taskLabel).join(` ${r.glyph.arrow} `)} ${r.glyph.arrow} `:``,u=formatTurnDuration(i-e.startedAtMs);v.push(clipVisible(`${s}${a.bold(`${l}${taskLabel(e)}`)} ${a.dim(u)}`,n));let d=currentActivity(e),f=` ${o?` `:``}${r.glyph.elbow} `,p=truncate(d.text,Math.max(0,n-visibleLength(f))),m=d.attention?a.yellow:a.dim;p.length>0&&v.push(clipVisible(`${f}${m(p)}`,n))}let y=l-_.length;if(y>0&&v.length<f){let e=`${r.glyph.ellipsis} ${s>0?`at least `:``}${y} more working${c?` · Approval needed`:``}`;v.push(clipVisible(` ${c?a.yellow(e):a.dim(e)}`,n))}return renderTransientDrawer(v,[],r,n,`${t.activity??`Working`} ${r.glyph.dot} ${l}${s>0?`+`:``} ${l===1?`task`:`tasks`}${t.turnElapsedMs===void 0?``:` ${r.glyph.dot} ${formatTurnDuration(t.turnElapsedMs)}`}`,!d,`left`).rows}export{TaskActivity,renderTaskPanelRows,signInLabel,waitingLabel};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DevDiagnostics } from "../diagnostics.js";
|
|
2
|
-
import type { AgentTUIInputQuestion, AgentTUIInputQuestionResponse, AgentTUIRenderer, AgentTUISessionOptions,
|
|
2
|
+
import type { AgentTUIInput, AgentTUIInputQuestion, AgentTUIInputQuestionResponse, AgentTUIRenderer, AgentTUISessionOptions, AgentTUIToolApprovalRequest, AgentTUIToolApprovalResponse, CommandPresentation } from "./runner.js";
|
|
3
|
+
import type { AgentTUIConversationView } from "./conversation-view.js";
|
|
3
4
|
import { type PromptArgumentSuggestion } from "./argument-typeahead.js";
|
|
4
5
|
import { type ArgumentTypeaheadCommand, type PromptCommandSpec } from "./prompt-commands.js";
|
|
5
6
|
import type { SetupFlowRenderer } from "./setup-flow.js";
|
|
@@ -76,47 +77,21 @@ export declare class TerminalRenderer implements AgentTUIRenderer {
|
|
|
76
77
|
draft: string;
|
|
77
78
|
queuedPrompt: string | undefined;
|
|
78
79
|
};
|
|
79
|
-
readPrompt(options?: AgentTUISessionOptions): Promise<string>;
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
81
|
+
* Opens the composer until the user submits, cancels work, or leaves. The
|
|
82
|
+
* composer stays usable while work runs: `Enter` submits (the runner steers),
|
|
83
|
+
* and `Esc` or `Ctrl+C` asks to cancel. Aborting `signal` keeps the draft for
|
|
84
|
+
* the next read, so other input surfaces can briefly take the keyboard.
|
|
85
85
|
*/
|
|
86
|
-
|
|
87
|
-
renderStream(result: AgentTUIStreamResult, options?: AgentTUISessionOptions): Promise<void>;
|
|
86
|
+
readInput(options?: AgentTUISessionOptions): Promise<AgentTUIInput | undefined>;
|
|
88
87
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
88
|
+
* Reconciles the session's transcript with one conversation snapshot. Blocks
|
|
89
|
+
* keep their position once shown; a block leaves the live region when its
|
|
90
|
+
* part can no longer change.
|
|
92
91
|
*/
|
|
93
|
-
|
|
92
|
+
renderConversation(view: AgentTUIConversationView): void;
|
|
94
93
|
readToolApproval(request: AgentTUIToolApprovalRequest, options?: AgentTUISessionOptions): Promise<AgentTUIToolApprovalResponse>;
|
|
95
94
|
readInputQuestion(question: AgentTUIInputQuestion, options?: AgentTUISessionOptions): Promise<AgentTUIInputQuestionResponse | undefined>;
|
|
96
|
-
/**
|
|
97
|
-
* An agent's words or thinking. The task panel shows the latest line;
|
|
98
|
-
* `--subagents full` also writes each finished message, in order.
|
|
99
|
-
*/
|
|
100
|
-
upsertSubagentStep(update: SubagentStepUpdate): void;
|
|
101
|
-
/**
|
|
102
|
-
* An agent's own tool call. The task panel shows what is running and counts
|
|
103
|
-
* finished calls for the task's end line; `--subagents full` also writes each
|
|
104
|
-
* finished call, in order.
|
|
105
|
-
*/
|
|
106
|
-
upsertSubagentTool(update: SubagentToolUpdate): void;
|
|
107
|
-
removeSubagentTool(update: {
|
|
108
|
-
callId: string;
|
|
109
|
-
childCallId: string;
|
|
110
|
-
reason?: string;
|
|
111
|
-
}): void;
|
|
112
|
-
/**
|
|
113
|
-
* The runner-facing subagent surface (see {@link SubagentView}); the
|
|
114
|
-
* public methods below are its implementation and the unit tests' seam.
|
|
115
|
-
*/
|
|
116
|
-
readonly subagents: SubagentView;
|
|
117
|
-
markChildToolCallId(callId: string): void;
|
|
118
|
-
upsertConnectionAuth(update: ConnectionAuthUpdate): void;
|
|
119
|
-
setConnectionAuthPendingCount(count: number): void;
|
|
120
95
|
setVercelStatus(status: VercelStatusSnapshot): void;
|
|
121
96
|
setRemoteConnectionStatus(status: RemoteConnectionSnapshot): void;
|
|
122
97
|
reset(): void;
|
|
@@ -131,6 +106,8 @@ export declare class TerminalRenderer implements AgentTUIRenderer {
|
|
|
131
106
|
* text is blank.
|
|
132
107
|
*/
|
|
133
108
|
renderNotice(text: string): void;
|
|
109
|
+
/** Puts a cancelled turn's message back into an empty composer, with a notice. */
|
|
110
|
+
restoreDraft(text: string): void;
|
|
134
111
|
/**
|
|
135
112
|
* Sets the setup attention line (yellow `⚠`, commands blue) as a live footer
|
|
136
113
|
* element above the prompt. Unlike committed scrollback, it can be cleared:
|
|
@@ -152,9 +129,10 @@ export declare class TerminalRenderer implements AgentTUIRenderer {
|
|
|
152
129
|
/** Last server session id the runner reported; named in the parting line. */
|
|
153
130
|
setSessionId(sessionId: string): void;
|
|
154
131
|
shutdown(): void;
|
|
155
|
-
suspendPromptForInput(): void;
|
|
156
132
|
requestInterrupt(): void;
|
|
157
133
|
exitRequested(): boolean;
|
|
134
|
+
/** Commits one error block, such as a message the session did not accept. */
|
|
135
|
+
renderError(title: string, message: string): void;
|
|
158
136
|
/** The log sources the transcript currently renders. */
|
|
159
137
|
logDisplayMode(): LogDisplayMode;
|
|
160
138
|
/**
|