eve 0.55.0 → 0.57.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 +58 -0
- package/dist/src/channel/adapter-context.d.ts +1 -1
- package/dist/src/channel/adapter.d.ts +2 -2
- package/dist/src/channel/audience.d.ts +3 -3
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/conversation-context.d.ts +4 -2
- package/dist/src/channel/conversation-context.js +1 -1
- package/dist/src/channel/session.d.ts +4 -3
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +7 -4
- package/dist/src/chunks/{use-eve-agent-D-KQzzyW.js → use-eve-agent-C2APNCdP.js} +45 -22
- package/dist/src/chunks/{use-eve-agent-CxPlg0KL.js → use-eve-agent-D0YnDLi_.js} +45 -22
- package/dist/src/cli/commands/init.d.ts +2 -6
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/registry-metadata.d.ts +0 -18
- package/dist/src/cli/commands/registry-metadata.js +1 -1
- package/dist/src/cli/commands/registry-pnpm-build-policy-flow.js +1 -1
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/commands/trace-detail.js +1 -1
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/run-interactive-ui.js +1 -1
- package/dist/src/cli/dev/tui/agent-header.js +1 -1
- package/dist/src/cli/dev/tui/blocks.d.ts +3 -6
- package/dist/src/cli/dev/tui/blocks.js +3 -3
- package/dist/src/cli/dev/tui/command-typeahead.js +1 -1
- package/dist/src/cli/dev/tui/markdown.d.ts +8 -1
- package/dist/src/cli/dev/tui/markdown.js +7 -7
- package/dist/src/cli/dev/tui/message-queue.d.ts +11 -7
- package/dist/src/cli/dev/tui/message-queue.js +1 -1
- package/dist/src/cli/dev/tui/model-editor.d.ts +1 -1
- package/dist/src/cli/dev/tui/model-editor.js +1 -1
- package/dist/src/cli/dev/tui/prompt-command-handler.d.ts +0 -3
- package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
- package/dist/src/cli/dev/tui/prompt-commands.d.ts +1 -1
- package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
- package/dist/src/cli/dev/tui/question-panel.js +1 -1
- package/dist/src/cli/dev/tui/remote-auth-result.js +1 -1
- package/dist/src/cli/dev/tui/remote-auth.js +1 -1
- package/dist/src/cli/dev/tui/remote-startup.d.ts +10 -0
- package/dist/src/cli/dev/tui/remote-startup.js +1 -0
- package/dist/src/cli/dev/tui/runner.d.ts +16 -19
- package/dist/src/cli/dev/tui/runner.js +3 -1
- package/dist/src/cli/dev/tui/setup-commands.d.ts +7 -13
- package/dist/src/cli/dev/tui/setup-commands.js +2 -2
- package/dist/src/cli/dev/tui/setup-issues.d.ts +1 -1
- package/dist/src/cli/dev/tui/setup-issues.js +1 -1
- package/dist/src/cli/dev/tui/setup-panel.d.ts +5 -17
- package/dist/src/cli/dev/tui/setup-panel.js +5 -6
- package/dist/src/cli/dev/tui/status-line.d.ts +1 -8
- package/dist/src/cli/dev/tui/status-line.js +1 -1
- package/dist/src/cli/dev/tui/steering-stream.d.ts +15 -0
- package/dist/src/cli/dev/tui/steering-stream.js +1 -0
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +8 -3
- package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
- package/dist/src/cli/dev/tui/test/mock-terminal.d.ts +2 -2
- package/dist/src/cli/dev/tui/test/mock-terminal.js +1 -1
- package/dist/src/cli/dev/tui/theme.d.ts +0 -2
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/cli/dev/tui/tui.d.ts +4 -1
- package/dist/src/cli/dev/tui/vercel-status.d.ts +4 -2
- package/dist/src/cli/dev/tui/vercel-status.js +1 -1
- package/dist/src/cli/run.js +1 -1
- package/dist/src/cli/telemetry/index.d.ts +1 -1
- package/dist/src/cli/telemetry/index.js +1 -1
- package/dist/src/cli/ui/terminal-text.js +1 -1
- package/dist/src/client/agent-info-schema.d.ts +2 -57
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/eve-agent-store-state.d.ts +19 -0
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/ndjson.d.ts +2 -0
- package/dist/src/client/ndjson.js +3 -3
- package/dist/src/client/open-stream.d.ts +1 -0
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -0
- package/dist/src/compiled/@workflow/core/runtime.js +2 -2
- package/dist/src/compiled/@workflow/core/serialization.js +1 -0
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +2 -2
- package/dist/src/compiled/_chunks/workflow/attribute-changes-DTFAjP0J.js +6 -0
- package/dist/src/compiled/_chunks/workflow/{dist-PLkAQ-U7.js → dist-C5KCXSdI.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{frames-BvATzM2t.js → frames-DJw9L4rO.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/global-DFW-hO6M.js +1 -0
- package/dist/src/compiled/_chunks/workflow/helpers-ClCA9Lmc.js +1 -0
- package/dist/src/compiled/_chunks/workflow/logger-D6vwIEf9.js +13 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-_baK8jaT.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-CRdL17z4.js +1 -0
- package/dist/src/compiled/_chunks/workflow/serialization-CWYPL4Eq.js +3 -0
- package/dist/src/compiled/_chunks/workflow/sleep-BL0kgJnT.js +1 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-DyIt9lEx.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{ws-transport-CVezyWwZ.js → ws-transport-Dl5FG4Sw.js} +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +27 -8
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.d.ts +12 -11
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-tool.d.ts +0 -3
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/compiler/validate-artifact.js +1 -1
- package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +5 -1
- package/dist/src/context/keys.js +1 -1
- package/dist/src/eve-channel/audience.d.ts +2 -2
- package/dist/src/eve-channel/audience.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.js +4 -3
- package/dist/src/eve-channel/types.d.ts +5 -5
- package/dist/src/execution/activity-cohort.js +1 -1
- package/dist/src/execution/activity-collector.js +1 -1
- package/dist/src/execution/authorization-callback-match.d.ts +2 -1
- package/dist/src/execution/authorization-callback-match.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/cancel-indexed-session-tasks-step.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.d.ts +1 -1
- package/dist/src/execution/connections/callback-route.d.ts +1 -11
- package/dist/src/execution/connections/callback-route.js +1 -1
- package/dist/src/execution/continuation-conflict-step.d.ts +0 -1
- package/dist/src/execution/continuation-conflict-step.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +1 -1
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/coordination-dispatch-step.d.ts +2 -2
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +1 -1
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +10 -49
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/dynamic-workflow/program-step.d.ts +21 -0
- package/dist/src/execution/dynamic-workflow/program-step.js +1 -0
- package/dist/src/execution/dynamic-workflow/schema.d.ts +36 -0
- package/dist/src/execution/dynamic-workflow/schema.js +1 -0
- package/dist/src/execution/dynamic-workflow/security-step.d.ts +3 -0
- package/dist/src/execution/dynamic-workflow/security-step.js +1 -0
- package/dist/src/execution/dynamic-workflow/tool.d.ts +8 -0
- package/dist/src/execution/dynamic-workflow/tool.js +1 -0
- package/dist/src/execution/dynamic-workflow/workflow.d.ts +10 -0
- package/dist/src/execution/dynamic-workflow/workflow.js +1 -0
- package/dist/src/execution/eve-workflow-attributes.d.ts +2 -17
- package/dist/src/execution/eve-workflow-attributes.js +1 -1
- package/dist/src/execution/hook-ownership.d.ts +2 -4
- package/dist/src/execution/hook-ownership.js +1 -1
- package/dist/src/execution/legacy-session/authorization.d.ts +9 -0
- package/dist/src/execution/legacy-session/authorization.js +1 -0
- package/dist/src/execution/legacy-session/completion-step.d.ts +10 -0
- package/dist/src/execution/legacy-session/completion-step.js +1 -0
- package/dist/src/execution/legacy-session/inbox.d.ts +24 -0
- package/dist/src/execution/legacy-session/inbox.js +1 -0
- package/dist/src/execution/legacy-session/input.d.ts +19 -0
- package/dist/src/execution/legacy-session/input.js +1 -0
- package/dist/src/execution/legacy-session/interrupt-step.d.ts +3 -0
- package/dist/src/execution/legacy-session/interrupt-step.js +1 -0
- package/dist/src/execution/legacy-session/prepare-step.d.ts +24 -0
- package/dist/src/execution/legacy-session/prepare-step.js +1 -0
- package/dist/src/execution/legacy-session/snapshot.d.ts +12 -0
- package/dist/src/execution/legacy-session/snapshot.js +1 -0
- package/dist/src/execution/legacy-session/turn-workflow.d.ts +8 -0
- package/dist/src/execution/legacy-session/turn-workflow.js +1 -0
- package/dist/src/execution/model-call-batching.d.ts +1 -0
- package/dist/src/execution/model-call-batching.js +1 -1
- package/dist/src/execution/node-step.d.ts +1 -5
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/proxied-deliver-step.d.ts +2 -20
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/reconcile-session-continuation-token.d.ts +1 -1
- package/dist/src/execution/report-dropped-wire-payload-step.d.ts +1 -1
- package/dist/src/execution/route-child-delivery.d.ts +2 -2
- package/dist/src/execution/route-child-delivery.js +1 -1
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/sandbox/bindings/eve-image.js +1 -1
- package/dist/src/execution/session/accepted-deployment.d.ts +3 -0
- package/dist/src/execution/session/accepted-deployment.js +1 -0
- package/dist/src/execution/session/admission.d.ts +38 -0
- package/dist/src/execution/session/admission.js +1 -0
- package/dist/src/execution/session/entry-input.d.ts +42 -0
- package/dist/src/execution/session/entry-input.js +1 -0
- package/dist/src/execution/session/entry.d.ts +13 -0
- package/dist/src/execution/session/entry.js +1 -0
- package/dist/src/execution/session/event-sink.d.ts +31 -0
- package/dist/src/execution/session/event-sink.js +1 -0
- package/dist/src/execution/session/finalization.d.ts +33 -0
- package/dist/src/execution/session/finalization.js +1 -0
- package/dist/src/execution/session/handoff-steps.d.ts +22 -0
- package/dist/src/execution/session/handoff-steps.js +1 -0
- package/dist/src/execution/session/handoff.d.ts +69 -0
- package/dist/src/execution/session/handoff.js +1 -0
- package/dist/src/execution/session/hook-tokens.d.ts +11 -0
- package/dist/src/execution/session/hook-tokens.js +1 -0
- package/dist/src/execution/session/input-queue.d.ts +72 -0
- package/dist/src/execution/session/input-queue.js +1 -0
- package/dist/src/execution/session/next-input.d.ts +32 -0
- package/dist/src/execution/session/next-input.js +1 -0
- package/dist/src/execution/{pending-turn-state.d.ts → session/pending-turn-state.d.ts} +0 -1
- package/dist/src/execution/{pending-turn-state.js → session/pending-turn-state.js} +1 -1
- package/dist/src/execution/session/program.d.ts +47 -0
- package/dist/src/execution/session/program.js +1 -0
- package/dist/src/execution/session/route-selected-delivery.d.ts +9 -0
- package/dist/src/execution/session/route-selected-delivery.js +1 -0
- package/dist/src/execution/session/state-cursor.d.ts +31 -0
- package/dist/src/execution/session/state-cursor.js +1 -0
- package/dist/src/execution/{session-timeout-control.d.ts → session/timeout-control.d.ts} +1 -1
- package/dist/src/execution/session/timeout-control.js +1 -0
- package/dist/src/execution/{session-timeout-steps.d.ts → session/timeout-steps.d.ts} +3 -2
- package/dist/src/execution/session/timeout-steps.js +1 -0
- package/dist/src/execution/{session-timeout-workflow.d.ts → session/timeout-workflow.d.ts} +3 -1
- package/dist/src/execution/session/timeout-workflow.js +1 -0
- package/dist/src/execution/session/timeout.d.ts +3 -0
- package/dist/src/execution/session/timeout.js +1 -0
- package/dist/src/execution/session/turn-step-result.d.ts +4 -0
- package/dist/src/execution/session/turn-step-result.js +1 -0
- package/dist/src/execution/session/turn-step-types.d.ts +68 -0
- package/dist/src/execution/session/turn-step-types.js +1 -0
- package/dist/src/execution/{workflow-steps.d.ts → session/turn-step.d.ts} +1 -2
- package/dist/src/execution/session/turn-step.js +1 -0
- package/dist/src/execution/session/turn.d.ts +31 -0
- package/dist/src/execution/session/turn.js +1 -0
- package/dist/src/execution/session-inbox/address.d.ts +21 -0
- package/dist/src/execution/session-inbox/address.js +1 -0
- package/dist/src/execution/session-inbox/inbox.d.ts +54 -0
- package/dist/src/execution/session-inbox/inbox.js +1 -0
- package/dist/src/execution/session-inbox/protocol.d.ts +10 -0
- package/dist/src/execution/session-inbox/protocol.js +1 -0
- package/dist/src/execution/session-inbox/release-step.d.ts +5 -0
- package/dist/src/execution/session-inbox/release-step.js +1 -0
- package/dist/src/execution/session-inbox/resume.d.ts +21 -0
- package/dist/src/execution/session-inbox/resume.js +1 -0
- package/dist/src/execution/{turn-workflow-tool-run.d.ts → session-workflow-tool-run.d.ts} +2 -2
- package/dist/src/execution/session-workflow-tool-run.js +1 -0
- package/dist/src/execution/session.d.ts +0 -1
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/skills/instructions.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +1 -1
- package/dist/src/execution/stable-workflow-names.js +1 -1
- package/dist/src/execution/task-input-response-route.js +1 -1
- package/dist/src/execution/tasks/child/steps.d.ts +1 -1
- package/dist/src/execution/tasks/child/steps.js +1 -1
- package/dist/src/execution/tasks/child/workflow.js +1 -1
- package/dist/src/execution/tasks/parent/delegate.d.ts +7 -0
- package/dist/src/execution/tasks/parent/delegate.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch.js +1 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/terminal-session-completion-step.d.ts +1 -1
- package/dist/src/execution/terminal-session-event.d.ts +1 -1
- package/dist/src/execution/terminal-session-event.js +1 -1
- package/dist/src/execution/terminal-session-failure-step.d.ts +1 -1
- package/dist/src/execution/terminal-session-failure-step.js +1 -1
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/tools/sleep-workflow.js +1 -1
- package/dist/src/execution/tools/subagent/accept-event-step.js +1 -1
- package/dist/src/execution/tools/subagent/emit-called-step.d.ts +1 -1
- package/dist/src/execution/tools/subagent/emit-called-step.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-agent.d.ts +1 -1
- package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-preparation.d.ts +6 -0
- package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-step.d.ts +2 -0
- package/dist/src/execution/tools/subagent/invoke-step.js +1 -1
- package/dist/src/execution/tools/subagent/steer.d.ts +13 -0
- package/dist/src/execution/tools/subagent/steer.js +1 -0
- package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +1 -1
- package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -1
- package/dist/src/execution/tools/subagent/task-cancel.js +1 -1
- package/dist/src/execution/tools/workflow/ask.d.ts +0 -9
- package/dist/src/execution/tools/workflow/ask.js +1 -1
- package/dist/src/execution/tools/workflow/body.d.ts +0 -2
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +1 -1
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +1 -1
- package/dist/src/execution/tools/workflow/messages.d.ts +0 -1
- package/dist/src/execution/tools/workflow/messages.js +1 -1
- package/dist/src/execution/tools/workflow/owner.d.ts +3 -1
- package/dist/src/execution/tools/workflow/owner.js +1 -1
- package/dist/src/execution/tools/workflow/resume-hook-step.d.ts +1 -1
- package/dist/src/execution/tools/workflow/step-context.d.ts +0 -1
- package/dist/src/execution/tools/workflow/step-execution.js +1 -1
- package/dist/src/execution/tools/workflow/step.js +1 -1
- package/dist/src/execution/tools/workflow/workflow.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +15 -18
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +0 -3
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/authorization.d.ts +5 -37
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/compaction.js +1 -1
- package/dist/src/harness/coordination.js +1 -1
- package/dist/src/harness/emission-state.d.ts +1 -0
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/generation-steering.d.ts +22 -0
- package/dist/src/harness/generation-steering.js +1 -0
- package/dist/src/harness/messages.d.ts +1 -1
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/prompt-cache.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +1 -1
- package/dist/src/harness/proxy-input-requests.js +1 -1
- package/dist/src/harness/semantic-errors/rules/gateway.js +1 -1
- package/dist/src/harness/semantic-errors/signals.js +1 -1
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/types.d.ts +2 -21
- package/dist/src/instrumentation/ai-sdk-hook-bridge.js +1 -1
- package/dist/src/instrumentation/channel-delivery.js +1 -1
- package/dist/src/instrumentation/content.js +1 -1
- package/dist/src/instrumentation/lifecycle.d.ts +6 -7
- package/dist/src/instrumentation/native-events.d.ts +2 -0
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/instrumentation/session-context.d.ts +2 -0
- package/dist/src/instrumentation/session-context.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +3 -2
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/connection.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.d.ts +3 -4
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/gateway.d.ts +1 -0
- package/dist/src/internal/gateway.js +1 -1
- package/dist/src/internal/model-auth/api-key.d.ts +7 -0
- package/dist/src/internal/model-auth/api-key.js +1 -0
- package/dist/src/internal/model-auth/available-models.d.ts +2 -0
- package/dist/src/internal/model-auth/available-models.js +1 -0
- package/dist/src/internal/model-auth/development-broker-client.d.ts +3 -0
- package/dist/src/internal/model-auth/development-broker-client.js +1 -0
- package/dist/src/internal/model-auth/development-broker-protocol.d.ts +12 -0
- package/dist/src/internal/model-auth/development-broker-protocol.js +1 -0
- package/dist/src/internal/model-auth/development-broker-server.d.ts +4 -0
- package/dist/src/internal/model-auth/development-broker-server.js +1 -0
- package/dist/src/internal/model-auth/gateway-credential.d.ts +2 -0
- package/dist/src/internal/model-auth/gateway-credential.js +1 -0
- package/dist/src/internal/model-auth/store.d.ts +16 -0
- package/dist/src/internal/model-auth/store.js +1 -0
- package/dist/src/internal/model-auth/transport.d.ts +6 -0
- package/dist/src/internal/model-auth/transport.js +1 -0
- package/dist/src/internal/model-auth/vercel-cli.d.ts +7 -0
- package/dist/src/internal/model-auth/vercel-cli.js +1 -0
- package/dist/src/internal/model-auth/vercel-team.d.ts +3 -0
- package/dist/src/internal/model-auth/vercel-team.js +1 -0
- package/dist/src/internal/model-auth/vercel.d.ts +13 -0
- package/dist/src/internal/model-auth/vercel.js +1 -0
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
- package/dist/src/internal/nitro/host/drained-nitro-dev-server.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/workflow-sandbox-runtime-plugin.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/info.js +1 -1
- package/dist/src/internal/resolve-model-endpoint-status.d.ts +2 -0
- package/dist/src/internal/resolve-model-endpoint-status.js +1 -1
- package/dist/src/internal/vercel/api-resource.d.ts +4 -0
- package/dist/src/internal/vercel/api-resource.js +1 -0
- package/dist/src/internal/vercel/eve-service-contribution.js +1 -1
- package/dist/src/internal/vercel/vercel-services-config.d.ts +2 -0
- package/dist/src/internal/vercel/vercel-services-config.js +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/internal/workflow/development-world-server.js +1 -1
- package/dist/src/internal/workflow/local-world-delivery-timeouts.d.ts +1 -1
- package/dist/src/internal/workflow/runtime.d.ts +1 -6
- package/dist/src/internal/workflow/runtime.js +1 -1
- package/dist/src/internal/workflow/vercel-world-defaults.d.ts +4 -0
- package/dist/src/internal/workflow/vercel-world-defaults.js +1 -0
- package/dist/src/protocol/activity.js +1 -1
- package/dist/src/protocol/message.d.ts +8 -0
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/protocol/routes.d.ts +0 -2
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/public/channels/chat-sdk/audience.d.ts +2 -2
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/audience.d.ts +2 -2
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/connections/index.d.ts +1 -1
- package/dist/src/public/definitions/channel.d.ts +2 -2
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/connections/mcp.d.ts +1 -1
- package/dist/src/public/definitions/connections/openapi.d.ts +1 -1
- package/dist/src/public/models/anthropic/index.d.ts +3 -0
- package/dist/src/public/models/anthropic/index.js +1 -0
- package/dist/src/public/models/openai/chatgpt/codex-app-server.js +1 -1
- package/dist/src/public/models/openai/chatgpt/credential-store.js +1 -1
- package/dist/src/public/models/openai/chatgpt/oauth.js +1 -1
- package/dist/src/public/models/openai/chatgpt/transport.js +1 -1
- package/dist/src/public/models/openai/index.d.ts +4 -2
- package/dist/src/public/models/openai/index.js +1 -1
- package/dist/src/public/sandbox/docker-sandbox.d.ts +1 -1
- package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +1 -1
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +1 -1
- package/dist/src/public/tools/workflow.d.ts +1 -4
- package/dist/src/public/tools/workflow.js +1 -1
- package/dist/src/public/vercel/index.d.ts +2 -1
- package/dist/src/public/vercel/index.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/connections/authorization-tokens.d.ts +2 -4
- package/dist/src/runtime/connections/principal.d.ts +6 -6
- package/dist/src/runtime/connections/principal.js +1 -1
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/resolve-tool.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/runtime/types.d.ts +3 -9
- package/dist/src/self-modification/agent.js +1 -1
- package/dist/src/self-modification/extension/classify-registry-item.d.ts +3 -3
- package/dist/src/self-modification/extension/classify-registry-item.js +1 -1
- package/dist/src/self-modification/extension/tools/search_registry.d.ts +1 -7
- package/dist/src/self-modification/extension/tools/search_registry.js +1 -1
- package/dist/src/self-modification/setup.d.ts +9 -3
- package/dist/src/self-modification/setup.js +2 -2
- package/dist/src/setup/cli/option-row.d.ts +2 -1
- package/dist/src/setup/cli/option-row.js +1 -1
- package/dist/src/setup/cli/prompt-ui.d.ts +2 -0
- package/dist/src/setup/cli/prompt-ui.js +1 -1
- package/dist/src/setup/cli/select-state.d.ts +1 -1
- package/dist/src/setup/cli/select-state.js +1 -1
- package/dist/src/setup/flows/chatgpt-auth.js +1 -1
- package/dist/src/setup/flows/deploy.d.ts +4 -9
- package/dist/src/setup/flows/deploy.js +1 -1
- package/dist/src/setup/flows/ensure-vercel-project.js +1 -1
- package/dist/src/setup/flows/install-vercel-cli.d.ts +2 -3
- package/dist/src/setup/flows/login.d.ts +3 -1
- package/dist/src/setup/flows/login.js +1 -1
- package/dist/src/setup/flows/model-login-connection.d.ts +36 -0
- package/dist/src/setup/flows/model-login-connection.js +1 -0
- package/dist/src/setup/flows/model-login-progress.d.ts +7 -0
- package/dist/src/setup/flows/model-login-progress.js +1 -0
- package/dist/src/setup/flows/model-login.d.ts +22 -0
- package/dist/src/setup/flows/model-login.js +1 -0
- package/dist/src/setup/flows/model-source-change.d.ts +7 -0
- package/dist/src/setup/flows/model-source-change.js +1 -1
- package/dist/src/setup/flows/model.d.ts +6 -24
- package/dist/src/setup/flows/model.js +1 -1
- package/dist/src/setup/flows/registry.d.ts +3 -19
- package/dist/src/setup/flows/registry.js +1 -1
- package/dist/src/setup/flows/vercel-model-login.d.ts +5 -0
- package/dist/src/setup/flows/vercel-model-login.js +1 -0
- package/dist/src/setup/integrations/self-modification/setup.d.ts +2 -0
- package/dist/src/setup/integrations/self-modification/setup.js +1 -1
- package/dist/src/setup/project-resolution.js +1 -1
- package/dist/src/setup/prompter.d.ts +3 -1
- package/dist/src/setup/provider-settings.d.ts +19 -6
- package/dist/src/setup/provider-settings.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +6 -2
- package/dist/src/setup/vercel-project.js +0 -0
- package/dist/src/setup/with-spinner.d.ts +1 -1
- package/dist/src/setup/with-spinner.js +1 -1
- package/dist/src/shared/action-types.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +6 -4
- package/dist/src/shared/channel-definition.d.ts +2 -2
- package/dist/src/shared/chatgpt-model.d.ts +2 -2
- package/dist/src/shared/chatgpt-model.js +1 -1
- package/dist/src/shared/connection-types.d.ts +20 -7
- package/dist/src/shared/conversation-context.d.ts +15 -0
- package/dist/src/shared/model-connection.d.ts +17 -0
- package/dist/src/shared/model-connection.js +1 -0
- package/dist/src/shared/model-endpoint-status.d.ts +2 -1
- package/dist/src/shared/model-helper.d.ts +26 -0
- package/dist/src/shared/model-helper.js +1 -0
- package/dist/src/shared/package-version.d.ts +2 -0
- package/dist/src/shared/package-version.js +1 -0
- package/dist/src/shared/validate-authorization.js +1 -1
- package/dist/src/shared/vercel-services.d.ts +1 -0
- package/dist/src/shared/vercel-services.js +1 -1
- package/dist/src/shared/workflow-sandbox.d.ts +18 -12
- package/dist/src/shared/workflow-sandbox.js +1 -1
- package/dist/src/source-change/agent-config-ast.d.ts +6 -0
- package/dist/src/source-change/agent-config-ast.js +1 -1
- package/dist/src/source-change/apply-model-selection.d.ts +3 -1
- package/dist/src/source-change/apply-model-selection.js +1 -2
- package/dist/src/source-change/static-source-change.js +1 -1
- package/dist/src/subagents/callback-route.js +1 -1
- package/dist/src/subagents/event-proxy-step.d.ts +3 -3
- package/dist/src/subagents/event-proxy-step.js +1 -1
- package/dist/src/subagents/handle-dispatch.d.ts +12 -2
- package/dist/src/subagents/handle-dispatch.js +1 -1
- package/dist/src/subagents/handles/operation-id.d.ts +1 -1
- package/dist/src/subagents/handles/query.d.ts +0 -6
- package/dist/src/subagents/handles/query.js +1 -1
- package/dist/src/subagents/handles/state-key.d.ts +1 -1
- package/dist/src/subagents/handles/store.d.ts +1 -1
- package/dist/src/subagents/handles/store.js +1 -1
- package/dist/src/subagents/hitl-proxy.d.ts +1 -1
- package/dist/src/subagents/parent-notification.d.ts +2 -2
- package/dist/src/subagents/parent-result.d.ts +1 -1
- package/dist/src/subagents/remote-dispatch.d.ts +1 -1
- package/dist/src/subagents/remote-dispatch.js +1 -1
- package/dist/src/subagents/start-local.js +1 -1
- package/dist/src/subagents/tool.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tasks/session-index.d.ts +11 -0
- package/dist/src/tasks/session-index.js +1 -1
- package/dist/src/tasks/types.d.ts +1 -1
- package/dist/src/tools/auth.d.ts +5 -6
- package/dist/src/tools/provided/workflow.d.ts +12 -0
- package/dist/src/tools/provided/workflow.js +1 -0
- package/dist/src/tools/workflow-program-input.d.ts +6 -0
- package/dist/src/tools/workflow-program-input.js +1 -0
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/tracing/agent-otel-runtime-context.d.ts +2 -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-otel-usage.js +1 -1
- package/dist/src/tracing/agent-span-contract.d.ts +1 -0
- 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.js +1 -1
- package/dist/src/tracing/agent-trace-state.d.ts +2 -0
- package/dist/src/tracing/content-attributes.js +1 -1
- package/dist/src/tracing/local-instrumentation-runtime.d.ts +1 -1
- package/dist/src/tracing/local-instrumentation-runtime.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +23 -23
- package/docs/channels/chat-sdk.mdx +11 -2
- package/docs/channels/custom.mdx +32 -16
- package/docs/channels/eve.mdx +21 -19
- package/docs/channels/linear.mdx +7 -3
- package/docs/channels/linq.mdx +1 -1
- package/docs/channels/overview.mdx +17 -2
- package/docs/channels/photon.mdx +4 -1
- package/docs/channels/slack.mdx +12 -2
- package/docs/concepts/execution-model-and-durability.mdx +62 -13
- package/docs/concepts/sessions-runs-and-streaming.md +14 -5
- package/docs/connections/mcp.mdx +4 -1
- package/docs/connections/openapi.mdx +8 -2
- package/docs/connections/overview.mdx +16 -13
- package/docs/getting-started.mdx +8 -4
- package/docs/guides/deployment/self-hosting.md +1 -1
- package/docs/guides/deployment/vercel.mdx +3 -3
- package/docs/guides/dev-tui.md +58 -31
- package/docs/guides/dynamic-capabilities.md +4 -4
- package/docs/guides/frontend/overview.mdx +3 -1
- package/docs/guides/hooks.md +1 -1
- package/docs/guides/instrumentation/meta.json +5 -0
- package/docs/guides/instrumentation/otel.mdx +149 -0
- package/docs/guides/instrumentation/overview.md +199 -0
- package/docs/guides/instrumentation/providers.mdx +169 -0
- package/docs/guides/meta.json +0 -1
- package/docs/guides/remote-agents.md +19 -21
- package/docs/install-integrations.mdx +2 -4
- package/docs/memory/custom-provider.md +1 -1
- package/docs/patterns/multi-tenant-auth.md +3 -3
- package/docs/protocols/acp.md +1 -1
- package/docs/reference/cli.md +16 -16
- package/docs/reference/telemetry.md +1 -1
- package/docs/reference/typescript-api.md +21 -14
- package/docs/sandbox.mdx +3 -3
- package/docs/subagents/index.mdx +4 -4
- package/docs/tools/workflows.mdx +57 -2
- package/docs/tutorial/how-it-runs.mdx +1 -1
- package/package.json +6 -1
- package/dist/src/cli/commands/init-repl.d.ts +0 -80
- package/dist/src/cli/commands/init-repl.js +0 -1
- package/dist/src/cli/commands/init-self-modification.d.ts +0 -7
- package/dist/src/cli/commands/init-self-modification.js +0 -1
- package/dist/src/cli/commands/registry-package.d.ts +0 -52
- package/dist/src/cli/commands/registry-package.js +0 -1
- package/dist/src/cli/dev/tui/prompt-placeholder.d.ts +0 -12
- package/dist/src/cli/dev/tui/prompt-placeholder.js +0 -1
- package/dist/src/cli/dev/tui/remote-auth-command.d.ts +0 -11
- package/dist/src/cli/dev/tui/remote-auth-command.js +0 -3
- package/dist/src/compiled/_chunks/workflow/attribute-changes-BAcgmlXp.js +0 -20
- package/dist/src/compiled/_chunks/workflow/private-CFJkQA7R.js +0 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-BEHe0Uut.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-ChHLjaCt.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-BB2HuVie.js +0 -1
- package/dist/src/execution/accepted-delivery-deployment.d.ts +0 -7
- package/dist/src/execution/accepted-delivery-deployment.js +0 -1
- package/dist/src/execution/dispatch-turn-step.d.ts +0 -5
- package/dist/src/execution/dispatch-turn-step.js +0 -1
- package/dist/src/execution/durable-session-migrations/chain.d.ts +0 -38
- package/dist/src/execution/durable-session-migrations/chain.js +0 -1
- package/dist/src/execution/durable-session-migrations/snapshot.d.ts +0 -6
- package/dist/src/execution/durable-session-migrations/snapshot.js +0 -1
- package/dist/src/execution/durable-session-migrations/turn-workflow-v0-to-v1.d.ts +0 -12
- package/dist/src/execution/durable-session-migrations/turn-workflow-v0-to-v1.js +0 -1
- package/dist/src/execution/durable-session-migrations/turn-workflow-v1-to-v2.d.ts +0 -2
- package/dist/src/execution/durable-session-migrations/turn-workflow-v1-to-v2.js +0 -1
- package/dist/src/execution/durable-session-migrations/turn-workflow.d.ts +0 -88
- package/dist/src/execution/durable-session-migrations/turn-workflow.js +0 -1
- package/dist/src/execution/forward-turn-cancellation-step.d.ts +0 -6
- package/dist/src/execution/forward-turn-cancellation-step.js +0 -1
- package/dist/src/execution/forward-turn-delivery-step.d.ts +0 -6
- package/dist/src/execution/forward-turn-delivery-step.js +0 -1
- package/dist/src/execution/inline-turn.d.ts +0 -31
- package/dist/src/execution/inline-turn.js +0 -1
- package/dist/src/execution/next-driver-action.d.ts +0 -93
- package/dist/src/execution/parked-delivery-wait.d.ts +0 -54
- package/dist/src/execution/parked-delivery-wait.js +0 -1
- package/dist/src/execution/session-command-inbox.d.ts +0 -52
- package/dist/src/execution/session-command-inbox.js +0 -1
- package/dist/src/execution/session-command-token.d.ts +0 -6
- package/dist/src/execution/session-command-token.js +0 -1
- package/dist/src/execution/session-state-cursor.d.ts +0 -25
- package/dist/src/execution/session-state-cursor.js +0 -1
- package/dist/src/execution/session-timeout-control.js +0 -1
- package/dist/src/execution/session-timeout-steps.js +0 -1
- package/dist/src/execution/session-timeout-workflow.js +0 -1
- package/dist/src/execution/session-timeout.d.ts +0 -2
- package/dist/src/execution/session-timeout.js +0 -1
- package/dist/src/execution/turn-cancellation-control.d.ts +0 -30
- package/dist/src/execution/turn-cancellation-control.js +0 -1
- package/dist/src/execution/turn-cancellation-token.d.ts +0 -10
- package/dist/src/execution/turn-cancellation-token.js +0 -1
- package/dist/src/execution/turn-control-protocol.d.ts +0 -36
- package/dist/src/execution/turn-control-protocol.js +0 -1
- package/dist/src/execution/turn-control-receiver.d.ts +0 -54
- package/dist/src/execution/turn-control-receiver.js +0 -1
- package/dist/src/execution/turn-dispatch.d.ts +0 -39
- package/dist/src/execution/turn-dispatch.js +0 -1
- package/dist/src/execution/turn-execution-cursor.d.ts +0 -49
- package/dist/src/execution/turn-execution-cursor.js +0 -1
- package/dist/src/execution/turn-workflow-tool-run.js +0 -1
- package/dist/src/execution/turn-workflow.d.ts +0 -13
- package/dist/src/execution/turn-workflow.js +0 -1
- package/dist/src/execution/wire/session-inbox-contract.d.ts +0 -38
- package/dist/src/execution/wire/session-inbox-contract.js +0 -1
- package/dist/src/execution/wire/session-inbox-encoder.d.ts +0 -47
- package/dist/src/execution/wire/session-inbox-encoder.js +0 -1
- package/dist/src/execution/wire/session-inbox-resume.d.ts +0 -12
- package/dist/src/execution/wire/session-inbox-resume.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.d.ts +0 -29
- package/dist/src/execution/wire/session-inbox-wire.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v0.d.ts +0 -5
- package/dist/src/execution/wire/session-inbox-wire.v0.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v1.d.ts +0 -237
- package/dist/src/execution/wire/session-inbox-wire.v1.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v2-migration.d.ts +0 -2
- package/dist/src/execution/wire/session-inbox-wire.v2-migration.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v2.d.ts +0 -478
- package/dist/src/execution/wire/session-inbox-wire.v2.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v2.migration.d.ts +0 -3
- package/dist/src/execution/wire/session-inbox-wire.v2.migration.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v3.d.ts +0 -480
- package/dist/src/execution/wire/session-inbox-wire.v3.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v3.migration.d.ts +0 -3
- package/dist/src/execution/wire/session-inbox-wire.v3.migration.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v4.d.ts +0 -267
- package/dist/src/execution/wire/session-inbox-wire.v4.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v4.migration.d.ts +0 -3
- package/dist/src/execution/wire/session-inbox-wire.v4.migration.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v5.d.ts +0 -341
- package/dist/src/execution/wire/session-inbox-wire.v5.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v5.migration.d.ts +0 -3
- package/dist/src/execution/wire/session-inbox-wire.v5.migration.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v6.d.ts +0 -341
- package/dist/src/execution/wire/session-inbox-wire.v6.js +0 -1
- package/dist/src/execution/wire/session-inbox-wire.v7.d.ts +0 -342
- package/dist/src/execution/wire/session-inbox-wire.v7.js +0 -1
- package/dist/src/execution/workflow-entry-crash.d.ts +0 -39
- package/dist/src/execution/workflow-entry-crash.js +0 -1
- package/dist/src/execution/workflow-entry-finalization.d.ts +0 -28
- package/dist/src/execution/workflow-entry-finalization.js +0 -1
- package/dist/src/execution/workflow-entry.d.ts +0 -37
- package/dist/src/execution/workflow-entry.js +0 -1
- package/dist/src/execution/workflow-steps.js +0 -1
- package/dist/src/harness/workflow-continuation-security.d.ts +0 -5
- package/dist/src/harness/workflow-continuation-security.js +0 -1
- package/dist/src/harness/workflow-interrupt-state.d.ts +0 -20
- package/dist/src/harness/workflow-interrupt-state.js +0 -1
- package/dist/src/harness/workflow-lifecycle.d.ts +0 -32
- package/dist/src/harness/workflow-lifecycle.js +0 -1
- package/dist/src/harness/workflow-sandbox.d.ts +0 -28
- package/dist/src/harness/workflow-sandbox.js +0 -2
- package/dist/src/harness/workflow-subagent-limit.d.ts +0 -28
- package/dist/src/harness/workflow-subagent-limit.js +0 -1
- package/dist/src/harness/workflow-task-state.d.ts +0 -9
- package/dist/src/harness/workflow-task-state.js +0 -1
- package/dist/src/harness/workflow-tool-description.d.ts +0 -22
- package/dist/src/harness/workflow-tool-description.js +0 -37
- package/dist/src/subagents/handles/rebase.d.ts +0 -4
- package/dist/src/subagents/handles/rebase.js +0 -1
- package/dist/src/tools/workflow.d.ts +0 -37
- package/dist/src/tools/workflow.js +0 -1
- package/docs/guides/instrumentation-providers.md +0 -249
- package/docs/guides/instrumentation.md +0 -453
- /package/dist/src/{execution/next-driver-action.js → client/eve-agent-store-state.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{remoteHost}from"./target.js";import{clipVisible,stripAnsi,visibleLength}from"#cli/ui/terminal-text.js";import{formatModelSummary}from"#shared/model-summary.js";function formatDevBuildStatus(e,t){let n=e.phase===`complete`;return`${n?t.glyph.success:t.glyph.validating} ${n?e.summary.replace(/ changed$/u,` updated`):`${e.summary.replace(/ (?:added|changed|removed)$/u,``)} updating…`}`}function renderModel(e){if(e.model===void 0)return;let t=e.theme.colors,n={model:e.model};if(e.reasoning!==void 0&&(n.reasoning=e.reasoning),e.fastMode===!0&&(n.fastGlyph=e.theme.glyph.fast),e.remote!==void 0){n.model=stripAnsi(e.model).replace(/\s+/gu,` `).trim();let r=stripAnsi(formatModelSummary(n)).replace(/\s+/gu,` `).trim();return t.dim(r)}return t.dim(formatModelSummary(n))}
|
|
1
|
+
import{remoteHost}from"./target.js";import{clipVisible,stripAnsi,visibleLength}from"#cli/ui/terminal-text.js";import{formatModelSummary}from"#shared/model-summary.js";function formatDevBuildStatus(e,t){let n=e.phase===`complete`;return`${n?t.glyph.success:t.glyph.validating} ${n?e.summary.replace(/ changed$/u,` updated`):`${e.summary.replace(/ (?:added|changed|removed)$/u,``)} updating…`}`}function renderModel(e){if(e.model===void 0)return;let t=e.theme.colors,n={model:e.model};if(e.reasoning!==void 0&&(n.reasoning=e.reasoning),e.fastMode===!0&&(n.fastGlyph=e.theme.glyph.fast),e.remote!==void 0){n.model=stripAnsi(e.model).replace(/\s+/gu,` `).trim();let r=stripAnsi(formatModelSummary(n)).replace(/\s+/gu,` `).trim();return t.dim(r)}return t.dim(formatModelSummary(n))}const EXTERNAL_PROVIDER_DISPLAY_NAMES={codex:`chatgpt-sub`};function renderEndpoint(e){if(e.remote!==void 0||e.endpoint===void 0)return;let t=e.theme.colors,n=e.theme.glyph,clause=(e,n)=>`${e}${t.dim(n)}`;if(e.endpoint.kind===`external`){let r=EXTERNAL_PROVIDER_DISPLAY_NAMES[e.endpoint.provider]??e.endpoint.provider;return`${t.dim(r)}${n.external}`}if(e.endpoint.kind===`chatgpt`)switch(e.endpoint.state){case`ready`:return`${t.dim(`chatgpt-sub`)}${n.external}`;case`checking`:return t.dim(`chatgpt-sub checking…`);case`signed-out`:case`reauth-required`:return t.yellow(`${n.warning} chatgpt-sub login · /login`);case`unavailable`:return t.yellow(`${n.warning} chatgpt-sub unavailable`)}if(!e.endpoint.connected)return t.yellow(`${n.warning} ai-gateway`);if(e.endpoint.credential===`api-key`)return clause(`ai-gateway`,`(api-key)`);if(e.endpoint.credential===`oauth`){let n=e.vercel?.modelTeamSlug;return t.dim(n?`Vercel · ${n}`:`Vercel`)}let r=e.vercel?.identity?.projectName;return clause(`ai-gateway`,`(${r===void 0?`oidc`:`oidc:${r}`})`)}function buildStatusLine(e){let{theme:t,width:n}=e,r=t.colors,i=e.devBuild===void 0?void 0:formatDevBuildStatus(e.devBuild,t),a=e.logLevel===void 0?void 0:r.cyan(`logs: ${e.logLevel}`),o=renderModel(e),s=e.remote===void 0?void 0:formatRemoteStatus(e.remote,t),c=renderEndpoint(e),l=s?.full,u=s?.badge,d=r.dim(` · `),compose=(e,t)=>{let n=t.filter(e=>e!==void 0).join(d);return e===void 0||n.length===0?e??n:`${e} ${n}`},f=[compose(l,[a,o,c]),compose(l,[a,o]),compose(l,[a]),compose(u,[a]),compose(u,[])];if(i!==void 0){for(let e of f){let t=visibleLength(e),r=visibleLength(i);if(!(t+(t>0?2:0)+r>n))return`${e}${` `.repeat(n-t-r)}${i}`}return clipVisible(i,n)}if(f[0].length===0)return;for(let e of f)if(e.length>0&&visibleLength(e)<=n)return e;let p=f.findLast(e=>e.length>0);return clipVisible(p,n)}function formatRemoteStatus(e,t){let n=t.colors,r=e.deployment===void 0?remoteHost(e.target):`${e.deployment.projectName} (${e.deployment.environment})`,i=formatRemoteBadge(` ${t.unicode?`↗`:`->`} ${r} `,e.connection.state,t),a;switch(e.connection.state){case`checking`:a=n.dim(`Checking access…`);break;case`ready`:break;case`auth-required`:a=n.yellow(`Authenticate via OIDC`);break;case`authenticating`:a=n.dim(`Authenticating via OIDC…`);break;case`auth-failed`:a=n.yellow(`Authentication failed`);break;case`unavailable`:a=n.yellow(`Remote unavailable`)}return{badge:i,full:a===void 0?i:`${i} ${a}`}}function formatRemoteBadge(e,t,n){let r=n.colors;switch(t){case`checking`:return r.inverse(r.gray(e));case`ready`:return r.inverse(r.blue(e));case`unavailable`:case`auth-required`:case`authenticating`:case`auth-failed`:return r.inverse(r.yellow(e))}}export{buildStatusLine};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type MessageStreamEvent } from "#protocol/message.js";
|
|
2
|
+
/**
|
|
3
|
+
* Follows accepted messages through their boundary, including a send racing
|
|
4
|
+
* settlement. Delivery responses may overlap; stream event IDs deduplicate them.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SteeringStream implements AsyncIterable<MessageStreamEvent> {
|
|
7
|
+
private readonly session;
|
|
8
|
+
private readonly streams;
|
|
9
|
+
private closed;
|
|
10
|
+
private readonly controller;
|
|
11
|
+
constructor(initial: AsyncIterable<MessageStreamEvent>, session: SteeringStream["session"]);
|
|
12
|
+
send(message: string): Promise<void>;
|
|
13
|
+
abort(): void;
|
|
14
|
+
[Symbol.asyncIterator](): AsyncGenerator<MessageStreamEvent>;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createEventDeduper}from"#protocol/event-dedupe.js";import{isCurrentTurnBoundaryEvent}from"#protocol/message.js";var SteeringStream=class{session;streams;closed=!1;controller=new AbortController;constructor(e,t){this.session=t,this.streams=[Promise.resolve(e)]}async send(e){if(this.closed)throw Error(`The active stream ended before steering was sent.`);let t=this.session.send(e,{turnPolicy:`steer`,signal:this.controller.signal});this.streams.push(t.then(e=>e,()=>void 0)),await t}abort(){this.closed=!0,this.controller.abort()}async*[Symbol.asyncIterator](){let e=createEventDeduper(),t;try{for(;this.streams.length>0;){let n=await this.streams.shift();if(n!==void 0){for await(let r of n)if(e.admit(r)){if(isCurrentTurnBoundaryEvent(r)){t=r;break}yield r}}}t!==void 0&&(yield t)}finally{this.abort()}}};export{SteeringStream};
|
|
@@ -36,6 +36,7 @@ export type TerminalRendererOptions = {
|
|
|
36
36
|
logs?: LogDisplayMode;
|
|
37
37
|
color?: boolean;
|
|
38
38
|
unicode?: boolean;
|
|
39
|
+
renderMarkdown?: boolean;
|
|
39
40
|
/** The process's diagnostics recorder (log, dump, stats); local sessions only. */
|
|
40
41
|
diagnostics?: DevDiagnostics;
|
|
41
42
|
/** Slash commands available in this local or remote session. */
|
|
@@ -55,6 +56,7 @@ export declare class TerminalRenderer implements AgentTUIRenderer {
|
|
|
55
56
|
/** The `/traces` full-screen viewer; resolves when the user closes it. */
|
|
56
57
|
readonly traceViewer: TraceViewerRenderer;
|
|
57
58
|
constructor(options?: TerminalRendererOptions);
|
|
59
|
+
setStartupPhase(phase: "starting" | "connecting" | "updating" | undefined): void;
|
|
58
60
|
/**
|
|
59
61
|
* Commits the startup agent header (brand mark + resolved configuration) to
|
|
60
62
|
* scrollback before the first prompt. Later calls (dev HMR refreshing fields
|
|
@@ -69,13 +71,16 @@ export declare class TerminalRenderer implements AgentTUIRenderer {
|
|
|
69
71
|
tip: string;
|
|
70
72
|
title: string;
|
|
71
73
|
}): void;
|
|
72
|
-
finishStartupDraft():
|
|
74
|
+
finishStartupDraft(): {
|
|
75
|
+
draft: string;
|
|
76
|
+
queuedPrompt: string | undefined;
|
|
77
|
+
};
|
|
73
78
|
readPrompt(options?: AgentTUISessionOptions): Promise<string>;
|
|
74
79
|
/**
|
|
75
80
|
* Consumes the next prompt produced by mid-turn input — the staged Esc
|
|
76
81
|
* steer message, or the whole queue coalesced into one. The runner calls
|
|
77
82
|
* this at a clean turn boundary and submits the result directly; the
|
|
78
|
-
* remembered origin
|
|
83
|
+
* remembered origin determines the echoed user block's gutter color.
|
|
79
84
|
*/
|
|
80
85
|
takeQueuedPrompt(): string | undefined;
|
|
81
86
|
renderStream(result: AgentTUIStreamResult, options?: AgentTUISessionOptions): Promise<void>;
|
|
@@ -147,7 +152,7 @@ export declare class TerminalRenderer implements AgentTUIRenderer {
|
|
|
147
152
|
/**
|
|
148
153
|
* Sets the setup attention line (yellow `⚠`, commands blue) as a live footer
|
|
149
154
|
* element above the prompt. Unlike committed scrollback, it can be cleared:
|
|
150
|
-
* once the underlying issue is fixed (e.g. `/
|
|
155
|
+
* once the underlying issue is fixed (e.g. `/deploy` succeeds) the runner calls
|
|
151
156
|
* {@link clearSetupWarning} and the line disappears rather than lingering
|
|
152
157
|
* stale in the transcript.
|
|
153
158
|
*/
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{buildAgentHeader}from"./agent-header.js";import{renderAttentionRows,renderBlockLines}from"./blocks.js";import{copyTextToClipboard}from"./clipboard.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{formatStoredDiagnostic,presentDiagnostic}from"./diagnostic-presentation.js";import{interruptedError}from"./errors.js";import{FileContentCache}from"./file-content-cache.js";import{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,layoutPromptInput,lineOf,movePromptLine,visibleLine}from"./line-editor.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{MessageQueue,renderMessageQueueRows}from"./message-queue.js";import{initialModelEditorState,transitionModelEditor}from"./model-editor.js";import{
|
|
2
|
-
`);if(this.#
|
|
1
|
+
import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-commands.js";import{buildAgentHeader}from"./agent-header.js";import{detectMarkdownRendering}from"./markdown.js";import{renderAttentionRows,renderBlockLines}from"./blocks.js";import{copyTextToClipboard}from"./clipboard.js";import{dismissTypeahead,inlineCommandHint,isTypeaheadOpen,moveTypeaheadSelection,renderCommandSuggestions,selectedTypeaheadCommand,typeaheadCompletion,typeaheadFor}from"./command-typeahead.js";import{formatDevRebuildStatus,summarizeChangedFiles}from"./dev-rebuild-status.js";import{formatStoredDiagnostic,presentDiagnostic}from"./diagnostic-presentation.js";import{interruptedError}from"./errors.js";import{FileContentCache}from"./file-content-cache.js";import{EMPTY_LINE,PromptHistory,applyLineEditorKey,deleteForward,layoutPromptInput,lineOf,movePromptLine,visibleLine}from"./line-editor.js";import{nextLogDisplayMode}from"./log-display-mode.js";import{MessageQueue,renderMessageQueueRows}from"./message-queue.js";import{initialModelEditorState,transitionModelEditor}from"./model-editor.js";import{initialProviderPickerState,transitionProviderPicker}from"./provider-picker.js";import{renderQuestionPanel}from"./question-panel.js";import{enterBadge,flowMessageRows,renderAcknowledgeQuestion,renderFlowPanel,renderModelEditorQuestion,renderSelectQuestion,renderTextQuestion}from"./setup-panel.js";import{formatAssistantResponseStats,formatTokenFlow,formatTurnDuration,isIncompleteOsc,isIncompletePaste,nextKey,sanitizePastedText,stripPasteStart,stripPromptControlCharacters,takeUntil,typewriterText}from"./stream-format.js";import{TraceViewerSession}from"./traces/trace-viewer-session.js";import{buildStatusLine}from"./status-line.js";import{createTheme,detectUnicode}from"./theme.js";import{isPanelRoutedTool,presentPreparingTool,presentTool,readWriteFileInput,toolBaseName}from"./tool-presentation.js";import{groupToolBlocksForDisplay}from"./tool-block-groups.js";import{TurnClock}from"./turn-clock.js";import{allTodoItemsSettled,readTodoToolItems,renderFinishedTodoRows,renderTodoPanelRows}from"./todo-panel.js";import{reduceSetupSelectInput,setupSelectionIntent}from"./setup-selection-input.js";import{BACKGROUND_COLOR_QUERY,parseBackgroundColorReply}from"./terminal-background.js";import{inspectError}from"#internal/logging.js";import{eveVersionTag}from"#cli/banner.js";import{clipVisible,renderInputText,renderInputWithBlockCursor,stripAnsi,stripTerminalControls}from"#cli/ui/terminal-text.js";import{renderCursorRow}from"#setup/cli/option-row.js";import{initialSelectState,orderedSelection,reduceSelect,searchActionQuery,selectValueAtCursor}from"#setup/cli/select-state.js";import{toErrorMessage}from"#shared/errors.js";import{StringDecoder}from"node:string_decoder";import{summarizeKnownError}from"#harness/semantic-errors/index.js";import{parseDevRebuildLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{LiveRegion}from"#cli/ui/live-region.js";import{AltScreen}from"#cli/ui/alt-screen.js";import{PROGRESS_PULSE_ASCII_GLYPH,PROGRESS_PULSE_GLYPH,isProgressPulseVisible}from"#cli/ui/progress-pulse.js";import{readGatewayServiceTier}from"#shared/gateway-service-tier.js";function isMultiSelectRequest(e){return e.kind===`multi`||e.kind===`searchable-multi`}function moveActionCursor(e,t,n){return n===0?void 0:e===void 0?t===`down`?0:n-1:(e+(t===`down`?1:-1)+n)%n}function completedTurnStatus(e){return e.interrupted?`Interrupted`:e.cancelled?`Cancelled`:e.continueSession?`Ready`:`Done`}const incompletePasteFlushMs=1e3,STATUS={processing:`Working…`,connectionAuth:`Waiting for connection authorization…`};var TerminalRenderer=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h=[];#g=new Map;#_=new Set;#v=[];#y=new Set;#b=new Map;#x=0;#S=new Map;#C=new Set;#w=new Set;#T=new FileContentCache;#E=new Set;#D;#O;#k;#A;#j=0;#M;#N=!1;#P;#F=[];#I;#L=0;#R;#z;#B=``;#V=0;#H=new PromptHistory;#U=!1;#W;#G=!1;#K=!1;#q=new TurnClock;#J=EMPTY_LINE;#Y=!1;#X={kind:`idle`};#Z;#Q=STATUS.processing;#$;#ee=`eve`;#te=!1;#ne=!1;#re=!1;#ie=!1;#ae=!1;#oe=!1;#se=!1;#ce;#le=!0;#ue=0;#de=Date.now();#fe;#pe;#me;#he=!1;#ge;#_e=``;#ve=new StringDecoder(`utf8`);#ye;#be;#xe;#Se=!1;#Ce=!1;#we;#Te;#Ee;#De;#Oe;#ke;#Ae;#je=``;#Me=``;#Ne;#Pe;#Fe;#Ie=!1;#Le;#Re=0;#ze;#Be;#Ve;#He;#Ue;#We;#Ge=new MessageQueue;#Ke;#qe;#Je=!1;#Ye;#Xe;#Ze=!1;#Qe;#$e;#et;#tt;#nt;setupFlow={begin:(e,t)=>this.#lt(e,t),setNavigation:e=>this.#ut(e),end:e=>this.#dt(e?.preserveDiagnostics??!0),readSelect:e=>this.#ft(e),readEditableSelect:e=>this.#mt(e),readProviderPicker:e=>this.#ht(e),readModelEditor:e=>this.#gt(e),readText:e=>this.#_t(e),readAcknowledge:e=>this.#vt(e),readChoice:e=>this.#pt(e),setStatus:e=>this.#Et(e),renderLine:(e,t)=>this.#Dt(e,t),replaceContent:e=>this.#Ot(e),renderOutput:e=>this.#kt(e),withInheritedStdio:e=>this.#At(e),withExclusiveTerminal:e=>this.#At(e),waitForInterrupt:e=>this.#Ct(e)};traceViewer={open:e=>this.#Mt(e)};constructor(e){this.#e=e?.input??process.stdin,this.#t=e?.output??process.stdout,this.#n=new LiveRegion(this.#t),this.#r=new AltScreen(this.#t),this.#i=createTheme({color:e?.color??!0,unicode:e?.unicode??detectUnicode()}),this.#a=e?.renderMarkdown??detectMarkdownRendering(),this.#o=e?.tools??`auto-collapsed`,this.#s=e?.reasoning??`auto-collapsed`,this.#c=e?.subagents??`auto-collapsed`,this.#l=e?.connectionAuth??`full`,this.#u=e?.assistantResponseStats??`tokensPerSecond`,this.#Ee=e?.contextSize,this.#d=e?.captureForeignOutput??this.#t===process.stdout,this.#f=e?.diagnostics,this.#ce=e?.onExitRequest,this.#m=e?.logs??`none`,this.#p=e?.availablePromptCommands??PROMPT_COMMANDS}setStartupPhase(e){this.#O=e,e===void 0?this.#Qt():this.#Xt(),this.#Sn()}renderAgentHeader(e){this.#M=void 0,this.#ee=e.name,this.#D=e,this.#Ft();let t=this.#Dn().join(`
|
|
2
|
+
`);if(this.#N){t!==this.#P&&(this.#P=t,this.#$t({kind:`agent-header`,body:t,live:!1})),this.#Sn();return}this.#N=!0,this.#P=t,this.#n.flush(this.#Dn(),this.#Mn(this.#Vn()))}beginStartupDraft(e){this.#Ft({title:e.title}),this.#U=!0,this.#G=!0,this.#O=`starting`,this.#M={name:e.title,tip:e.tip},this.#j=Date.now();let t=lineOf(stripPromptControlCharacters(e.initialDraft??``));this.#k=t,this.#it(t),this.#qt(),this.#Xt(),this.#Sn();let apply=e=>{t=e,this.#k=e,this.#Yt(),this.#it(t),this.#Sn()};this.#A=e=>{if(e.type===`escape`&&this.#$e!==void 0){this.#$e(`escape`);return}if(e.type===`ctrl-c`&&this.#$e!==void 0){this.#jt(),this.#$e(`ctrl-c`);return}let n=applyLineEditorKey(t,e,{multiline:!0});if(n!==void 0){apply(n);return}if(e.type===`enter`&&t.text.trim().length>0){this.#Ge.enqueue(t.text)&&apply(EMPTY_LINE);return}e.type===`ctrl-c`&&this.#ce?.()},this.#rt()}#rt(){this.#k!==void 0&&this.#A!==void 0&&(this.#Wt(),this.#it(this.#k),this.#U=!0,this.#ge=this.#A,this.#Rt())}finishStartupDraft(){let e={draft:this.#k?.text??this.#B,queuedPrompt:this.#Ge.takePrompt()};return this.#k=void 0,this.#A=void 0,this.#zt(),this.#Jt(),this.#U=!1,this.#G=!1,e}async readPrompt(e){this.#Ft(e),this.#Qt(),this.#tn(),this.#U=!0,this.#G=!0,this.#X={kind:`idle`},this.#Q=``,this.#oe=this.#se,this.#se=!1;let t=this.#Ge.restoreDraft()?.split(`
|
|
3
3
|
`).map(stripPromptControlCharacters).join(`
|
|
4
|
-
`),n=stripPromptControlCharacters(e?.initialDraft??this.#W.text),r=t===void 0?n:n.length===0?t:`${t}\n\n${n}`,i=lineOf(r);return this.#W=EMPTY_LINE,this.#L.begin(i.text),this.#Qe(i),this.#z=typeaheadFor(this.#f,i.text),this.#Bt(),this.#hn(),await new Promise((e,t)=>{this.#q=t;let apply=e=>{i=e,this.#Ht(),this.#Qe(i),this.#z=typeaheadFor(this.#f,e.text,this.#z),this.#hn()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#z=void 0,this.#Vt(),this.#jt(),t(interruptedError())},suggestions=()=>this.#z!==void 0&&isTypeaheadOpen(this.#z)?this.#z:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#fe=t=>{t.type!==`ctrl-c`&&this.#ne&&(this.#ne=!1,this.#hn());let n=applyLineEditorKey(i,t,{multiline:!0});if(n!==void 0){apply(n);return}switch(t.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#z=moveTypeaheadSelection(e,-1),this.#hn();break}let t=movePromptLine(i,`up`);t===void 0?recall(this.#L.previous(i.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#z=moveTypeaheadSelection(e,1),this.#hn();break}let t=movePromptLine(i,`down`);t===void 0?recall(this.#L.next()):apply(t);break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#z=dismissTypeahead(e),this.#hn());break}case`enter`:{let t=highlighted(),n=t!==void 0&&parsePromptCommand(i.text)===null?typeaheadCompletion(t).trimEnd():i.text;if(n.trim().length===0)break;this.#z=void 0,this.#L.add(n),this.#R=!1,this.#Vt(),this.#J=STATUS.processing,isPromptControlCommand(n)?this.#Kt({kind:`command`,body:stripTerminalControls(n.trim()),live:!1}):(this.#Wt(),this.#qt(n),this.#Fe=n,this.#U.arm()),this.#Qe(EMPTY_LINE),this.#hn(),this.#Nt(),e(n);break}case`ctrl-d`:i.text.length===0?(this.#Tt(),interrupt()):apply(deleteForward(i));break;case`ctrl-l`:this.#vn();break;case`ctrl-r`:this.#hn();break;case`ctrl-c`:if(this.#ne){this.#Tt(),interrupt();break}this.#ne=!0,apply(EMPTY_LINE)}},this.#Mt()})}#Qe(e){this.#F=e.text,this.#I=e.cursor}takeQueuedPrompt(){let e=this.#Ve.view().steering,t=this.#Ve.takePrompt();return t!==void 0&&(this.#Ge=e?`steer`:`queue`),t}async renderStream(e,t){this.#kt(t),this.#g.clear(),this.#R=!1,this.#K.kind!==`waiting`&&(this.#K={kind:`waiting`,startedAtMs:Date.now()}),this.#J=this.#M>0?STATUS.connectionAuth:STATUS.processing,this.#Yt(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#d?.recordPrompt(),t?.submittedPrompt!==void 0&&!this.#U.armed&&this.#U.arm(),this.#ee=!1,this.#Ue=!1,this.#Ke=!1,this.#qe=t?.submittedPrompt,this.#Ve.beginTurn(),this.#He=e.cancel,this.#be=void 0,this.#xe=void 0,this.#Ce=void 0,this.#we=void 0,this.#Te=Date.now();let n={tools:t?.tools??this.#a,reasoning:t?.reasoning??this.#o,assistantResponseStats:t?.assistantResponseStats??this.#l};this.#Ut(),this.#G=!0,this.#hn();let r=new Promise(e=>{this.#_e=e});this.#fe=e=>this.#zt(e),this.#Mt();let i={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!0};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#ee)break;this.#rn(t,n,i)}}catch(e){let t=summarizeKnownError(e);t===null?this.#Xt(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#Xt(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#_e=void 0,this.#ee&&e.abort?.(),this.#He=void 0,this.#Nt(),this.#Gt(),this.#G=!1,this.#K.kind===`waiting`&&(this.#K={kind:`idle`}),this.#J=completedTurnStatus({interrupted:this.#ee,cancelled:this.#Ue,continueSession:t?.continueSession===!0}),this.#un(i),(this.#ee||i.cancelled)&&this.#ln(i),this.#nn(),this.#d?.reportStats(),this.#hn(),t?.continueSession||this.#jt()}}async renderIdleStream(e,t){let n={tools:t?.tools??this.#a,reasoning:t?.reasoning??this.#o,assistantResponseStats:t?.assistantResponseStats??this.#l},r={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!1};try{for await(let t of iterateTUIStream(e.events))this.#rn(t,n,r)}catch(e){let t=summarizeKnownError(e);t===null?this.#Xt(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#Xt(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#un(r),r.cancelled&&this.#ln(r),this.#nn(),this.#d?.reportStats(),this.#hn()}}async readToolApproval(e,t){return this.#kt(t),this.#Gt(),this.#R=!1,this.#K={kind:`idle`},this.#J=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#ee=!1,this.#hn(),await new Promise((t,n)=>{this.#q=n,this.#fe=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#Wt(),this.#J=STATUS.processing,this.#Nt(),this.#hn(),t({approved:!0})):n===`n`&&(this.#Wt(),this.#J=STATUS.processing,this.#et(e.toolCallId),this.#Nt(),this.#hn(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#hn();break;case`ctrl-c`:this.#ee=!0,this.#jt(),n(interruptedError())}},this.#Mt()})}async readInputQuestion(e,t){this.#kt(t),this.#Gt(),this.#R=!1,this.#B=!1,this.#K={kind:`idle`},this.#ee=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`overlay`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,overlayPanel=t=>renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#ae},this.#i,t),renderTextSection=()=>{this.#Qt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,void 0,this.#i),preformatted:!0,live:!0})},syncFreeformCaret=()=>{isOnFreeformRow()?this.#Bt():(this.#Vt(),this.#Ht())};s===`overlay`?(s=`overlay`,this.#R=!1,this.#en(o),this.#Ie=overlayPanel,this.#J=``,syncFreeformCaret(),this.#hn()):(s=`text`,this.#Ie=void 0,renderTextSection(),this.#R=!0,this.#Qe(l),this.#J=``,this.#Bt(),this.#hn());let finalize=t=>{this.#Ie=void 0,this.#Qt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#R=!1,this.#Wt(),this.#J=STATUS.processing,this.#Vt(),this.#Nt(),this.#hn();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#Ie=void 0,this.#Qt({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Dismissed.`)}`,preformatted:!0,live:!1}),this.#R=!1,this.#J=``,this.#Vt(),this.#Nt(),this.#hn(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#hn())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,r)=>{this.#q=r,u=t,this.#fe=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#Ht(),s===`text`&&this.#Qe(l),this.#hn();return}this.#ee=!0,this.#Ie=void 0,this.#Vt(),this.#jt(),r(interruptedError());return}if(t.type===`ctrl-r`){this.#hn();return}if(s===`overlay`){let r=setupSelectionIntent(t,{textNavigation:!isOnFreeformRow()});if(r?.kind===`move`){moveCursor(r.direction===`up`?-1:1);return}switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#Ht(),this.#hn();break}dismiss();break;default:if(isOnFreeformRow()){let e=applyLineEditorKey(l,t);e!==void 0&&(l=e,this.#Ht(),this.#hn());break}if(t.type===`text`&&/^[1-9]$/u.test(t.value)){let e=Number(t.value)-1;e<n.length?selectOptionAt(e):e===n.length&&i&&(c=e,syncFreeformCaret(),this.#hn())}}return}let a=applyLineEditorKey(l,t,{multiline:!0});if(a!==void 0){l=a,this.#Ht(),this.#Qe(l),this.#hn();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#Ht(),this.#Qe(l),this.#hn());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#Ht(),this.#Qe(l),this.#hn();break}dismiss()}},this.#Mt()})}upsertSubagentStep(e){if(this.#d?.recordSubagentDispatch(e.callId),this.#s===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(t.length!==0||n.length!==0){if(this.#Zt(e.callId,e.subagentName),this.#s===`collapsed`){this.#hn();return}this.#$t({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,subagentCallId:e.callId,depth:1,reasoning:t,body:n,collapsed:this.#s!==`full`,live:!e.finalized}),this.#hn()}}upsertSubagentTool(e){if(this.#d?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#d?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#s===`hidden`)return;if(this.#Zt(e.callId,e.subagentName),this.#s===`collapsed`){this.#hn();return}let t=subagentToolStatus(e.status),n=e.status===`preparing`?presentPreparingTool(e.toolName):presentTool(e.toolName,e.input,this.#sn({input:e.input,output:e.output,toolCallId:e.childCallId,toolName:e.toolName})),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,subagentCallId:e.callId,depth:1,title:stripTerminalControls(n.title),subtitle:stripTerminalControls(n.subtitle),status:t,live:t===`running`||t===`approval`,expanded:this.#s===`full`,toolName:e.toolName,toolGroup:n.group,toolInput:e.input};n.doneTitle!==void 0&&(r.doneTitle=stripTerminalControls(n.doneTitle)),n.detail!==void 0&&(r.detailLines=n.detail,r.keepDetailWhenDone=n.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=n.summarizeResult(e.output),r.toolOutput=e.output),this.#$t(r),this.#$e(e.callId),this.#hn()}#$e(e){applyCohortLiveness(this.#m.filter(t=>t.kind===`subagent-tool`&&t.subagentCallId===e).map(e=>({block:e,active:isActiveToolStatus(e.status)})))}removeSubagentTool(e){this.#en(subagentToolSectionId(e.callId,e.childCallId)),this.#hn()}subagents={begin:e=>this.beginSubagent(e),background:e=>this.backgroundSubagent(e),upsertStep:e=>this.upsertSubagentStep(e),upsertTool:e=>this.upsertSubagentTool(e),removeTool:e=>this.removeSubagentTool(e),complete:e=>this.completeSubagent(e),markChildToolCallId:e=>this.markChildToolCallId(e)};beginSubagent(e){if(this.#s===`hidden`)return;this.#Zt(e.callId,e.name);let t=this.#h.get(subagentHeaderId(e.callId));t!==void 0&&(t.status===`done`&&delete t.status,t.live=!0),this.#C.delete(e.callId),this.#hn()}backgroundSubagent(e){let t=this.#h.get(subagentHeaderId(e.callId));if(t===void 0||this.#g.has(subagentHeaderId(e.callId)))return;t.status=`running`,t.live=!0,t.updateSeq=++this.#b;let n=this.#S.has(e.callId);this.#S.add(e.callId),n||this.#tn(e.callId),this.#hn()}completeSubagent(e){let t=this.#h.get(subagentHeaderId(e.callId));if(t!==void 0){if(t.status=`done`,e.authoritative){this.#S.delete(e.callId),this.#C.delete(e.callId);for(let t of this.#m)t.subagentCallId===e.callId&&(t.live=!1)}else{this.#C.add(e.callId);for(let t of this.#m)t.subagentCallId===e.callId&&(t.live=!0)}this.#hn()}}markChildToolCallId(e){this.#v.add(e);let t=this.#y.get(e);t!==void 0&&(this.#en(t),this.#y.delete(e),this.#hn())}#et(e){let t=this.#h.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#c===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#Qt({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e,t),preformatted:!0,live:t===void 0}),this.#hn()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#M)return;let n=this.#M>0;this.#M=t,t>0?(this.#J=STATUS.connectionAuth,this.#hn()):n&&(this.#J=STATUS.processing,this.#hn())}setVercelStatus(e){this.#N=e,this.#hn()}setRemoteConnectionStatus(e){this.#P=e,this.#hn()}reset(){this.#m=[],this.#h.clear(),this.#g.clear(),this.#j=void 0,this.#A.length=0,this.#_.length=0,this.#O=!1,this.#k=void 0,this.#tt(),this.#H=!1,this.#Fe=void 0,this.#Ae=void 0,this.#M=0,this.#be=void 0,this.#xe=void 0,this.#Ce=void 0,this.#we=void 0,this.#Te=void 0,this.#Z&&(this.#n.clearAll(),this.#hn())}renderSessionBoundary(){this.#Jt(),this.#tt();let e=this.#i.colors,t=this.#i.glyph,n=e.dim(`${t.cornerOpen}${t.dash.repeat(2)} Session restarted, clear context.`);this.#Kt({kind:`session-boundary`,body:n,live:!1}),this.#hn()}#tt(){this.#v.clear(),this.#y.clear(),this.#T.clear(),this.#S.clear(),this.#C.clear(),this.#x.clear(),this.#ze=void 0,this.#Be=void 0,this.#Ve.reset(),this.#Ge=void 0,this.#w.clear(),this.#U.reset()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#kt(),this.#Kt({kind:`notice`,body:t,live:!1}),this.#hn())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#d?.append({source:`sandbox`,detail:t}),this.#kt(),this.#Kt({kind:`sandbox`,body:t,live:!1}),this.#hn())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#nt();return}this.#kt(),this.#Re=t,this.#hn()}clearSetupWarning(){this.#nt()}#nt(){this.#Re!==void 0&&(this.#Re=void 0,this.#hn())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#kt();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#Kt(r),this.#hn()}renderCommandResult(e,t){let n=stripAnsi(e);n.trim().length!==0&&(this.#kt(),this.#Kt({kind:`result`,body:n,live:!1,status:t===`success`?`done`:void 0}),this.#hn())}#rt(e,t=`spinner`){this.#kt(),this.#R=!1,this.#K={kind:`idle`},this.#J=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#Le={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#Ut(),this.#hn()}#it(e){this.#Le!==void 0&&(this.#Le.navigation=e,this.#hn())}#at(e){this.#Je=void 0,this.#yt();let t=this.#Le;if(t!==void 0){if(this.#Le=void 0,this.#Gt(),e){let e=[];for(let n of t.lines){if(n.evidence===!0){e.push(n.text);continue}(n.tone===`warning`||n.tone===`error`)&&(e.length>0&&this.#Kt({kind:`flow`,title:`info`,body:e.join(`
|
|
5
|
-
`),live:!1}),this
|
|
6
|
-
`,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#dt(e){let t=this.#pt(),n=lineOf(``),r;return t.question=t=>{let i={message:e.message,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#ae)},this.#Bt(),this.#hn(),await this.#gt((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Ht(),this.#hn()},a=applyLineEditorKey(n,t);if(a!==void 0){apply(a);return}switch(t.type){case`ctrl-c`:case`escape`:i(void 0);return;case`ctrl-r`:this.#hn();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#hn();return}i(t);return}default:return}},()=>this.#Vt()).promise}async#ft(e){let t=this.#pt();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#i,t),this.#hn(),await this.#gt((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#hn();return;default:return}}).promise}#pt(){this.#kt(),this.#R=!1,this.#K={kind:`idle`},this.#J=``;let e=this.#mt();return e.status!==void 0&&(e.status=void 0,e.summary=void 0,e.preview=void 0),e}#mt(){return this.#Le===void 0&&(this.#Le={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#Le}#ht(){this.#Le?.implicit===!0?this.#Le=void 0:this.#Le!==void 0&&(this.#Le.question=void 0,this.#Le.hideLinesWhileQuestion=!1),this.#fe=void 0,this.#Nt(),this.#Le!==void 0&&this.#vt(),this.#hn()}#gt(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#ht(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#ht(),i(e))};return this.#Rt(),this.#fe=t=>{t.type===`ctrl-c`&&this.#Tt(),e(t,settle,reject)},this.#Mt(),{promise:a,settle}}#_t(e){let t,n=new Promise(e=>{t=e});return this.#Je=t,this.#vt(e?.interruptible??!0),{promise:n,dispose:()=>{this.#Je===t&&(this.#Je=void 0,this.#yt())}}}#vt(e=!0){if(this.#Je===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#Tt();let e=this.#Je;this.#Je=void 0,this.#yt(),e?.(t.type===`ctrl-c`?`ctrl-c`:`escape`);return}t.type===`ctrl-r`&&this.#hn()};this.#Ye=consumer,this.#Rt(),this.#fe=consumer,this.#Mt()}#yt(){this.#Ye!==void 0&&(this.#fe===this.#Ye&&this.#Nt(),this.#Ye=void 0)}#bt(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#Le!==void 0){this.#Le.status=t,t===void 0&&(this.#Le.preview=void 0),this.#hn();return}if(!(this.#R||this.#G)){if(t===void 0){this.#K={kind:`idle`},this.#Y=void 0,this.#Gt(),this.#hn();return}this.#kt(),this.#Wt(),this.#Y=t.text,this.#hn()}}#xt(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Le;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#hn();return}this.#kt(),this.#Kt({kind:`flow`,title:t,body:n,live:!1}),this.#hn()}#St(e){let t=this.#Le;t!==void 0&&(t.lines=[],t.outputBuffer=[],t.preview=void 0,t.status=void 0,t.summary=e===void 0?void 0:{headline:stripTerminalControls(e.headline),facts:e.facts.map(e=>({label:stripTerminalControls(e.label),value:stripTerminalControls(e.value)}))},this.#hn())}#Ct(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Le;if(n===void 0){this.#xt(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#hn()}async#wt(e){this.#pe=``,this.#Rt(),this.#Je=void 0,this.#yt(),this.#Nt(),this.#Gt(),this.#n.clear(),this.#Ln(),this.#r.enter({cursor:`visible`,mouse:!1}),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#r.exit(),this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#pe=``,this.#Rt(),this.#n.hideCursor(),this.#In(),this.#Le!==void 0&&(this.#Ut(),this.#vt()),this.#n.reset(),this.#hn()}}setSessionId(e){this.#We=e}shutdown(){if(this.#jt(),this.#Q&&!this.#$){this.#$=!0;let e=this.#We===void 0?``:` ${this.#i.glyph.dot} session ${this.#We}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}suspendPromptForInput(){this.#W={cursor:this.#I,text:this.#F},this.#jt()}requestInterrupt(){this.#ee=!0,this.#Le!==void 0&&this.#fe?.({type:`ctrl-c`}),this.#_e?.(),this.#jt()}exitRequested(){return this.#te}#Tt(){this.#te=!0,this.#ie?.()}async#Et(e){if(this.#Xe!==void 0||!this.#Z)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Pn(),height:this.#Fn()}),paint:e=>this.#r.paint(e,this.#Fn()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#Ze});this.#Xe=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#Ot=e,this.#fe=e=>{t.handleKey(e)===`close`&&this.#Dt()},this.#Mt(),t.start()})}#Dt(){let e=this.#Xe;if(e===void 0)return;this.#Xe=void 0,e.dispose(),this.#Nt(),this.#r.exit(),this.#n.hideCursor(),this.#hn(),this.#n.showCursor();let t=this.#Ot;this.#Ot=void 0,t?.()}#Ot;#kt(e){this.#X=e?.title??this.#X,e?.contextSize!==void 0&&(this.#Se=e.contextSize),!this.#Z&&(this.#Z=!0,this.#Q=!0,this.#n.reset(),this.#n.hideCursor(),this.#In(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#ge=()=>this.#hn(),this.#t.on(`resize`,this.#ge),process.on(`exit`,this.#At))}#At=()=>{this.#Z&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#jt(){this.#Dt();let e=this.#q;if(this.#q=void 0,e?.(interruptedError()),this.#Nt(),this.#Vt(),this.#Gt(),this.#ue!==void 0&&(clearTimeout(this.#ue),this.#ue=void 0),this.#de=!1,this.#Gn(),this.#Z){this.#qn();for(let e of this.#m)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#hn(),this.#n.clear(),this.#n.showCursor(),this.#Ln(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#ge&&=(this.#t.off(`resize`,this.#ge),void 0),process.off(`exit`,this.#At),this.#Z=!1}}#Mt(){this.#e.off(`data`,this.#Pt),this.#e.on(`data`,this.#Pt),this.#pe.length>0&&queueMicrotask(()=>{this.#fe!==void 0&&this.#pe.length>0&&(this.#It(),this.#Ft())})}#Nt(){this.#e.off(`data`,this.#Pt),this.#Rt(),this.#fe=void 0}#Pt=e=>{this.#Rt(),this.#pe+=this.#me.write(e),this.#It(),this.#Ft()};#Ft(){if(this.#pe===`\x1B`){this.#he=setTimeout(()=>{this.#pe===`\x1B`&&(this.#pe=``,this.#fe?.({type:`escape`}))},30),this.#he.unref?.();return}if(isIncompletePaste(this.#pe)){let e=this.#pe;this.#he=setTimeout(()=>{if(this.#pe!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#pe=``,t.length>0&&this.#fe?.({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#he.unref?.();return}if(isIncompleteOsc(this.#pe)){let e=this.#pe;this.#he=setTimeout(()=>{this.#pe===e&&(this.#pe=``)},incompletePasteFlushMs),this.#he.unref?.()}}#It(){for(;this.#pe.length>0;){let e=nextKey(this.#pe);if(e.incomplete)return;if(this.#pe=this.#pe.slice(e.consumed),e.key!==void 0&&e.key.type!==`ignore`){if(e.key.type===`osc`){this.#Lt(e.key.value);continue}this.#fe?.(e.key)}}}#Lt(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#Ze=t,this.#Xe?.setTerminalBackground(t))}#Rt(){this.#he&&=(clearTimeout(this.#he),void 0)}#zt(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#hn();break;case`enter`:{let e=this.#W.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#He!==void 0){this.#W=EMPTY_LINE,this.#Ve.requestCancellation(),this.#Ke=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#He(),this.#hn();break}this.#Ve.enqueue(e)&&(this.#W=EMPTY_LINE),this.#hn();break}case`ctrl-c`:case`escape`:if(e.type===`ctrl-c`&&this.#Ve.view().cancelling){this.#ee=!0,this.#re=!0,this.#K={kind:`idle`},this.#J=`Interrupted`,this.#_e?.(),this.#hn();break}if(this.#Ve.idle&&this.#He===void 0)break;this.#Ve.handleEscape(),this.#Ke=!0,this.#He?.(),this.#hn();break;default:{let t=applyLineEditorKey(this.#W,e,{multiline:!0});t!==void 0&&(this.#W=t,this.#hn());break}}}#Bt(){this.#Vt(),this.#Ht(),this.#ce=setInterval(()=>{this.#ae=!this.#ae,this.#hn()},500),this.#ce.unref?.()}#Vt(){this.#ce&&=(clearInterval(this.#ce),void 0),this.#ae=!0}#Ht(){this.#ae=!0}#Ut(){this.#Gt(),this.#le=setInterval(()=>{this.#oe+=1,this.#hn()},90),this.#le.unref?.()}#Wt(){let e=Date.now();this.#se=e,this.#K={kind:`waiting`,startedAtMs:e},this.#Ut()}#Gt(){this.#le&&=(clearInterval(this.#le),void 0)}#Kt(e){e.id!==this.#Ae?.id&&this.#qn(),e.updateSeq=++this.#b;let t=e.subagentCallId!==void 0&&this.#S.has(e.subagentCallId)?-1:this.#m.findIndex(e=>e.subagentCallId!==void 0&&this.#S.has(e.subagentCallId));t<0?this.#m.push(e):this.#m.splice(t,0,e),e.id&&this.#h.set(e.id,e)}#qt(e){this.#H=!0,this.#Kt({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#hn()}#Jt(){let e=this.#U.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#Dn(e.elapsedMs)}`,n=this.#xe??0;if(this.#Se!==void 0&&this.#Se>0&&n>0){let e=Math.round(n/this.#Se*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#Kt({kind:`turn-stats`,body:t,live:!1})}#Yt(e){if(e==null)return;let t=this.#Ge;if(this.#Ge=void 0,this.#Fe===e){this.#Fe=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#Kt(n)}#Xt(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#d?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#d===void 0?a:`details: ${this.#d.displayPath}`),this.#Kt(c),this.#hn()}#Zt(e,t){if(this.#T.has(e))return;this.#T.add(e);let n=stripTerminalControls(t),r=this.#x.get(n)??[];if(r.push(e),this.#x.set(n,r),r.length===2){let e=this.#h.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#Kt(i)}#Qt(e){if(e.id&&this.#g.has(e.id))return;let t=e.id?this.#h.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#b;return}this.#Kt(e)}#$t(e){if(e.id&&this.#g.has(e.id))return;let t=e.id?this.#h.get(e.id):void 0;if(t!==void 0){Object.assign(t,e),t.updateSeq=++this.#b;return}let n=e.subagentCallId;if(n===void 0){this.#Kt(e);return}e.id!==this.#Ae?.id&&this.#qn(),e.updateSeq=++this.#b;let r=-1;for(let e=0;e<this.#m.length;e+=1)this.#m[e]?.subagentCallId===n&&(r=e);this.#m.splice(r<0?this.#m.length:r+1,0,e),e.id!==void 0&&this.#h.set(e.id,e)}#en(e){this.#m=this.#m.filter(t=>t.id!==e),this.#h.delete(e)}#tn(e){let t=this.#m.filter(t=>t.subagentCallId===e);t.length!==0&&(this.#m=this.#m.filter(t=>t.subagentCallId!==e),this.#m.push(...t))}#nn(){for(let e of this.#m)e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId)||e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#rn(e,t,n){switch(e.type){case`step-finish`:this.#d?.recordStepUsage(e.usage),e.usage!==void 0&&this.#U.addUsage(e.usage),this.#un(n),this.#mn(e.usage),this.#hn();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#in(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=typeof e.text==`string`?stripTerminalControls(e.text):t;n.text.set(e.id,r),this.#in(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#an(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#an(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#on({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#d?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#on({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#on({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#pn(e.toolCallId,n);if(r===void 0)break;this.#on({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#pn(e.toolCallId,n);if(this.#d?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#on({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#pn(e.toolCallId,n);if(r===void 0)break;this.#on({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#Xt(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:if(n.cancelled=!0,!n.restoreCancelledPrompt)break;this.#Ue=!0,!this.#Ke&&this.#qe!==void 0&&this.#W.text.length===0&&(this.#W=lineOf(this.#qe),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#mn(e.usage),this.#hn()}}#in(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#Qt({id:e,kind:`assistant`,body:r,live:n}),this.#hn())}#an(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Qt({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#hn())}#on(e,t,n){if(n.tools.set(e.toolCallId,e),this.#v.has(e.toolCallId)||this.#dn(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#y.set(e.toolCallId,r);let i=this.#sn(e);this.#Qt(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#fn(n),this.#hn()}#sn(e){e.output!==void 0&&this.#w.observeRead(e.output);let t={};this.#cn(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#w.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#cn(e){let t=this.#E?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#ln(e){for(let t of e.tools.keys()){if(this.#v.has(t))continue;let e=this.#y.get(t)??toolSectionId(t),n=this.#h.get(e);n?.kind===`tool`&&n.status===`running`&&(n.status=`error`,n.result=`interrupted`,n.live=!1)}}#un(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#y.get(t)??toolSectionId(t);this.#en(r),this.#y.delete(t)}}#dn(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#Be!==e&&(this.#Be=e,this.#Kt({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#Pn(),this.#i).join(`
|
|
7
|
-
`),live:!1})),this.#
|
|
8
|
-
`),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#
|
|
9
|
-
`);t=[],e.trim().length!==0&&this
|
|
10
|
-
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this
|
|
11
|
-
`),n=t.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(n===-1){if(this.#
|
|
12
|
-
`);r.trim().length>0&&this
|
|
13
|
-
`);this.#
|
|
4
|
+
`),n=stripPromptControlCharacters(e?.initialDraft??this.#J.text),r=t===void 0?n:n.length===0?t:`${t}\n\n${n}`,i=lineOf(r);return this.#J=EMPTY_LINE,this.#H.begin(i.text),this.#it(i),this.#W=typeaheadFor(this.#p,i.text),this.#qt(),this.#Sn(),await new Promise((e,t)=>{this.#Z=t;let apply=e=>{i=e,this.#Yt(),this.#it(i),this.#W=typeaheadFor(this.#p,e.text,this.#W),this.#Sn()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#W=void 0,this.#Jt(),this.#Lt(),t(interruptedError())},suggestions=()=>this.#W!==void 0&&isTypeaheadOpen(this.#W)?this.#W:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#ge=t=>{t.type!==`ctrl-c`&&this.#oe&&(this.#oe=!1,this.#Sn());let n=applyLineEditorKey(i,t,{multiline:!0});if(n!==void 0){apply(n);return}switch(t.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#W=moveTypeaheadSelection(e,-1),this.#Sn();break}let t=movePromptLine(i,`up`);t===void 0?recall(this.#H.previous(i.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#W=moveTypeaheadSelection(e,1),this.#Sn();break}let t=movePromptLine(i,`down`);t===void 0?recall(this.#H.next()):apply(t);break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#W=dismissTypeahead(e),this.#Sn());break}case`enter`:{let t=highlighted(),n=t!==void 0&&parsePromptCommand(i.text)===null?typeaheadCompletion(t).trimEnd():i.text;if(n.trim().length===0)break;this.#W=void 0,this.#H.add(n),this.#U=!1,this.#Jt(),this.#Q=STATUS.processing,isPromptControlCommand(n)?this.#$t({kind:`command`,body:stripTerminalControls(n.trim()),live:!1}):(this.#Zt(),this.#en(n),this.#ze=n,this.#q.arm()),this.#it(EMPTY_LINE),this.#Sn(),this.#zt(),e(n);break}case`ctrl-d`:i.text.length===0?(this.#jt(),interrupt()):apply(deleteForward(i));break;case`ctrl-l`:this.#Tn();break;case`ctrl-r`:this.#Sn();break;case`ctrl-c`:if(this.#oe){this.#jt(),interrupt();break}this.#oe=!0,apply(EMPTY_LINE)}},this.#Rt()})}#it(e){this.#B=e.text,this.#V=e.cursor}takeQueuedPrompt(){let e=this.#Ge.view().steering,t=this.#Ge.takePrompt();return t!==void 0&&(this.#Xe=e?`steer`:`queue`),t}async renderStream(e,t){this.#Ft(t),this.#_.clear(),this.#U=!1,this.#X.kind!==`waiting`&&(this.#X={kind:`waiting`,startedAtMs:Date.now()}),this.#Q=this.#L>0?STATUS.connectionAuth:STATUS.processing,this.#nn(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#f?.recordPrompt(),t?.submittedPrompt!==void 0&&!this.#q.armed&&this.#q.arm(),this.#ie=!1,this.#Je=!1,this.#Ze=!1,this.#Qe=t?.submittedPrompt,this.#Ge.beginTurn(),this.#Ke=e.cancel,this.#qe=e.steer,this.#we=void 0,this.#Te=void 0,this.#De=void 0,this.#Oe=void 0,this.#ke=Date.now();let n={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u};this.#Xt(),this.#Y=!0,this.#Sn();let r=new Promise(e=>{this.#xe=e});this.#ge=e=>this.#Gt(e),this.#Rt();let i={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!0};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#ie)break;this.#un(t,n,i)}}catch(e){let t=summarizeKnownError(e);t===null?this.#rn(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#rn(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#xe=void 0,this.#ie&&e.abort?.(),this.#Ke=void 0,this.#qe=void 0,this.#zt(),this.#Qt(),this.#Y=!1,this.#X.kind===`waiting`&&(this.#X={kind:`idle`}),this.#Q=completedTurnStatus({interrupted:this.#ie,cancelled:this.#Je,continueSession:t?.continueSession===!0}),this.#_n(i),(this.#ie||i.cancelled)&&this.#gn(i),this.#ln(),this.#f?.reportStats(),this.#Sn(),t?.continueSession||this.#Lt()}}async renderIdleStream(e,t){let n={tools:t?.tools??this.#o,reasoning:t?.reasoning??this.#s,assistantResponseStats:t?.assistantResponseStats??this.#u},r={text:new Map,reasoning:new Map,tools:new Map,cancelled:!1,restoreCancelledPrompt:!1};try{for await(let t of iterateTUIStream(e.events))this.#un(t,n,r)}catch(e){let t=summarizeKnownError(e);t===null?this.#rn(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#rn(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#_n(r),r.cancelled&&this.#gn(r),this.#ln(),this.#f?.reportStats(),this.#Sn()}}async readToolApproval(e,t){return this.#Ft(t),this.#Qt(),this.#U=!1,this.#X={kind:`idle`},this.#Q=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#ie=!1,this.#Sn(),await new Promise((t,n)=>{this.#Z=n,this.#ge=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#Zt(),this.#Q=STATUS.processing,this.#zt(),this.#Sn(),t({approved:!0})):n===`n`&&(this.#Zt(),this.#Q=STATUS.processing,this.#ot(e.toolCallId),this.#zt(),this.#Sn(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#Sn();break;case`ctrl-c`:this.#ie=!0,this.#Lt(),n(interruptedError())}},this.#Rt()})}async readInputQuestion(e,t){this.#Ft(t),this.#Qt(),this.#U=!1,this.#G=!1,this.#X={kind:`idle`},this.#ie=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`overlay`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,overlayPanel=t=>renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#le},this.#i,t),renderTextSection=()=>{this.#an({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,void 0,this.#i),preformatted:!0,live:!0})},syncFreeformCaret=()=>{isOnFreeformRow()?this.#qt():(this.#Jt(),this.#Yt())};s===`overlay`?(s=`overlay`,this.#U=!1,this.#sn(o),this.#Be=overlayPanel,this.#Q=``,syncFreeformCaret(),this.#Sn()):(s=`text`,this.#Be=void 0,renderTextSection(),this.#U=!0,this.#it(l),this.#Q=``,this.#qt(),this.#Sn());let finalize=t=>{this.#Be=void 0,this.#an({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#U=!1,this.#Zt(),this.#Q=STATUS.processing,this.#Jt(),this.#zt(),this.#Sn();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#Be=void 0,this.#an({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Dismissed.`)}`,preformatted:!0,live:!1}),this.#U=!1,this.#Q=``,this.#Jt(),this.#zt(),this.#Sn(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#Sn())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,r)=>{this.#Z=r,u=t,this.#ge=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#Yt(),s===`text`&&this.#it(l),this.#Sn();return}this.#ie=!0,this.#Be=void 0,this.#Jt(),this.#Lt(),r(interruptedError());return}if(t.type===`ctrl-r`){this.#Sn();return}if(s===`overlay`){let r=setupSelectionIntent(t,{textNavigation:!isOnFreeformRow()});if(r?.kind===`move`){moveCursor(r.direction===`up`?-1:1);return}switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#Yt(),this.#Sn();break}dismiss();break;default:if(isOnFreeformRow()){let e=applyLineEditorKey(l,t);e!==void 0&&(l=e,this.#Yt(),this.#Sn());break}if(t.type===`text`&&/^[1-9]$/u.test(t.value)){let e=Number(t.value)-1;e<n.length?selectOptionAt(e):e===n.length&&i&&(c=e,syncFreeformCaret(),this.#Sn())}}return}let a=applyLineEditorKey(l,t,{multiline:!0});if(a!==void 0){l=a,this.#Yt(),this.#it(l),this.#Sn();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#Yt(),this.#it(l),this.#Sn());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#Yt(),this.#it(l),this.#Sn();break}dismiss()}},this.#Rt()})}upsertSubagentStep(e){if(this.#f?.recordSubagentDispatch(e.callId),this.#c===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(t.length!==0||n.length!==0){if(this.#in(e.callId,e.subagentName),this.#c===`collapsed`){this.#Sn();return}this.#on({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,subagentCallId:e.callId,depth:1,reasoning:t,body:n,collapsed:this.#c!==`full`,live:!e.finalized}),this.#Sn()}}upsertSubagentTool(e){if(this.#f?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#f?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#c===`hidden`)return;if(this.#in(e.callId,e.subagentName),this.#c===`collapsed`){this.#Sn();return}let t=subagentToolStatus(e.status),n=e.status===`preparing`?presentPreparingTool(e.toolName):presentTool(e.toolName,e.input,this.#mn({input:e.input,output:e.output,toolCallId:e.childCallId,toolName:e.toolName})),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,subagentCallId:e.callId,depth:1,title:stripTerminalControls(n.title),subtitle:stripTerminalControls(n.subtitle),status:t,live:t===`running`||t===`approval`,expanded:this.#c===`full`,toolName:e.toolName,toolGroup:n.group,toolInput:e.input};n.doneTitle!==void 0&&(r.doneTitle=stripTerminalControls(n.doneTitle)),n.detail!==void 0&&(r.detailLines=n.detail,r.keepDetailWhenDone=n.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=n.summarizeResult(e.output),r.toolOutput=e.output),this.#on(r),this.#at(e.callId),this.#Sn()}#at(e){applyCohortLiveness(this.#h.filter(t=>t.kind===`subagent-tool`&&t.subagentCallId===e).map(e=>({block:e,active:isActiveToolStatus(e.status)})))}removeSubagentTool(e){this.#sn(subagentToolSectionId(e.callId,e.childCallId)),this.#Sn()}subagents={begin:e=>this.beginSubagent(e),background:e=>this.backgroundSubagent(e),upsertStep:e=>this.upsertSubagentStep(e),upsertTool:e=>this.upsertSubagentTool(e),removeTool:e=>this.removeSubagentTool(e),complete:e=>this.completeSubagent(e),markChildToolCallId:e=>this.markChildToolCallId(e)};beginSubagent(e){if(this.#c===`hidden`)return;this.#in(e.callId,e.name);let t=this.#g.get(subagentHeaderId(e.callId));t!==void 0&&(t.status===`done`&&delete t.status,t.live=!0),this.#w.delete(e.callId),this.#Sn()}backgroundSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t===void 0||this.#_.has(subagentHeaderId(e.callId)))return;t.status=`running`,t.live=!0,t.updateSeq=++this.#x;let n=this.#C.has(e.callId);this.#C.add(e.callId),n||this.#cn(e.callId),this.#Sn()}completeSubagent(e){let t=this.#g.get(subagentHeaderId(e.callId));if(t!==void 0){if(t.status=`done`,e.authoritative){this.#C.delete(e.callId),this.#w.delete(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!1)}else{this.#w.add(e.callId);for(let t of this.#h)t.subagentCallId===e.callId&&(t.live=!0)}this.#Sn()}}markChildToolCallId(e){this.#y.add(e);let t=this.#b.get(e);t!==void 0&&(this.#sn(t),this.#b.delete(e),this.#Sn())}#ot(e){let t=this.#g.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#l===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#an({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e,t),preformatted:!0,live:t===void 0}),this.#Sn()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#L)return;let n=this.#L>0;this.#L=t,t>0?(this.#Q=STATUS.connectionAuth,this.#Sn()):n&&(this.#Q=STATUS.processing,this.#Sn())}setVercelStatus(e){this.#R=e,this.#Sn()}setRemoteConnectionStatus(e){this.#z=e,this.#Sn()}reset(){this.#h=[],this.#g.clear(),this.#_.clear(),this.#I=void 0,this.#F.length=0,this.#v.length=0,this.#N=!1,this.#P=void 0,this.#st(),this.#K=!1,this.#ze=void 0,this.#Pe=void 0,this.#L=0,this.#we=void 0,this.#Te=void 0,this.#De=void 0,this.#Oe=void 0,this.#ke=void 0,this.#te&&(this.#n.clearAll(),this.#Sn())}renderSessionBoundary(){this.#tn(),this.#st();let e=this.#i.colors,t=this.#i.glyph,n=e.dim(`${t.cornerOpen}${t.dash.repeat(2)} Session restarted, clear context.`);this.#$t({kind:`session-boundary`,body:n,live:!1}),this.#Sn()}#st(){this.#y.clear(),this.#b.clear(),this.#E.clear(),this.#C.clear(),this.#w.clear(),this.#S.clear(),this.#Ue=void 0,this.#We=void 0,this.#Ge.reset(),this.#Xe=void 0,this.#T.clear(),this.#q.reset()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#Ft(),this.#$t({kind:`notice`,body:t,live:!1}),this.#Sn())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#f?.append({source:`sandbox`,detail:t}),this.#Ft(),this.#$t({kind:`sandbox`,body:t,live:!1}),this.#Sn())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#ct();return}this.#Ft(),this.#He=t,this.#Sn()}clearSetupWarning(){this.#ct()}#ct(){this.#He!==void 0&&(this.#He=void 0,this.#Sn())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#Ft();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#$t(r),this.#Sn()}renderCommandResult(e,t){let n=stripAnsi(e);n.trim().length!==0&&(this.#Ft(),this.#$t({kind:`result`,body:n,live:!1,status:t===`success`?`done`:void 0}),this.#Sn())}#lt(e,t=`spinner`){this.#Ft(),this.#k===void 0&&(this.#U=!1),this.#X={kind:`idle`},this.#Q=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#Ve={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#Xt(),this.#Sn()}#ut(e){this.#Ve!==void 0&&(this.#Ve.navigation=e,this.#Sn())}#dt(e){this.#$e=void 0,this.#Tt();let t=this.#Ve;if(t!==void 0){if(this.#Ve=void 0,this.#k===void 0?this.#Qt():this.#rt(),e){let e=[];for(let n of t.lines){if(n.evidence===!0){e.push(n.text);continue}(n.tone===`warning`||n.tone===`error`)&&(e.length>0&&this.#$t({kind:`flow`,title:`info`,body:e.join(`
|
|
5
|
+
`),live:!1}),this.#$t({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#Sn()}}async#ft(e){let t=this.#yt(e.message),n=isMultiSelectRequest(e),r=e.kind===`search`?e.searchAction:void 0,i=e.options,a=e.navigation?.kind===`planner`,o={options:i,searchAction:r,submitRow:n&&!a};`initialValue`in e&&e.initialValue!==void 0&&(o.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(o.initialValues=e.initialValues);let s=initialSelectState(o),c,l=!1,u=0,isCurrentSearch=e=>e===u,clearSearch=()=>{u+=1,l=!1,s=reduceSelect(s,{type:`clear`},{options:i,searchAction:r,submitRow:n&&!a}),this.#Sn()},loadSearch=async(e,t)=>{l=!0,c=void 0;let o=++u;this.#Sn();try{let c=await t(e);if(!isCurrentSearch(o))return;let l=s.filter;i=c,s={...initialSelectState({options:c,searchAction:r,submitRow:n&&!a}),filter:l}}catch(e){isCurrentSearch(o)&&(c=toErrorMessage(e))}finally{isCurrentSearch(o)&&(l=!1,this.#Sn())}},d=e.notices;if(e.kind===`task-list`||e.kind===`search`&&e.layout===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));d=e.notices??r,t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,message:``,options:i,select:s};return d!==void 0&&d.length>0&&(t.notices=d),c!==void 0&&(t.error=c),l&&(t.loadingFrame=this.#kn()),t};return t.question=e=>renderSelectQuestion(panelState(),this.#i,e),this.#Sn(),await this.#St((t,o)=>{let close=e=>{u+=1,o(e)};if(l){t.type===`ctrl-c`?close(void 0):t.type===`escape`?clearSearch():t.type===`ctrl-r`&&this.#Sn();return}let d=e.navigation?.kind===`planner`?e.navigation:void 0,f=t.type===`left`&&(d?.activeStep??0)>(d?.firstNavigableStep??0)?`back`:t.type===`right`&&d!==void 0&&d.activeStep>=(d.firstNavigableStep??0)&&d.activeStep<d.steps.length-1?`forward`:void 0;if(f!==void 0){close({kind:`navigate`,direction:f,values:n?orderedSelection(i,s.selected):[]});return}let p={key:t,options:i,searchAction:r,select:s},m=reduceSetupSelectInput(n?{...p,kind:e.kind,required:e.required,plannerNavigation:a||void 0}:{...p,kind:e.kind});switch(m.kind){case`cancel`:close(void 0);return;case`repaint`:this.#Sn();return;case`update`:s=m.select,c=void 0,this.#Sn();return;case`submit`:{let e=searchActionQuery(m.values[0]??``),t=r?.load;if(e===void 0||t===void 0){close(m.values);return}loadSearch(e,t);return}case`error`:c=m.message,this.#Sn();return;case`ignore`:return}}).promise}#pt(e){this.#Ft();let t=this.#bt();t.status={kind:`progress`,text:stripTerminalControls(e.status),startedAtMs:Date.now()};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#i,t),this.#Sn();let r=this.#St((t,r)=>{let i=setupSelectionIntent(t,{textNavigation:!0});switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#Sn();return;case`repaint`:this.#Sn();return;case`submit`:n!==void 0&&r(e.actions[n].value);return;case void 0:return}},()=>{t.status=void 0});return{choice:r.promise,close:()=>r.settle(void 0)}}async#mt(e){let t=this.#yt(e.message),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`inline-edit`,layout:`task-list`,message:``,options:e.options,select:r,edit:{optionValue:e.editable.value,caretVisible:this.#le,editor:{kind:`rename`,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint}}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#i,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?this.#qt():(i=lineOf(``),this.#Jt())};return syncEditableRow(),this.#Sn(),await this.#St((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#Yt(),this.#Sn()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#Sn()},submit=()=>{let t=selectValueAtCursor([...e.options],r.cursor);if(t===void 0)return;if(t!==e.editable.value){n({kind:`selected`,value:t});return}let o=(i.text||e.editable.defaultValue).trim(),s=e.editable.validate?.(o);if(s!==void 0){a=s,this.#Sn();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t,{textNavigation:!onEditableRow()});switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#Sn();return;case void 0:}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Jt()).promise}async#ht(e){let t=this.#yt(e.message),n=initialProviderPickerState(e.options,e.initialValue),r,cursorBadge=()=>{if(n.phase.kind!==`inactive`)return;let t=selectValueAtCursor([...e.options],n.select.cursor),r=e.options.find(e=>e.value===t);if(r!==void 0)return enterBadge(this.#i,r.checked===!0?`change`:void 0)};t.question=t=>{let r=cursorBadge(),i={kind:`inline-edit`,layout:`stacked`,message:``,options:e.options,select:n.select,edit:{optionValue:`ai-gateway-key`,caretVisible:this.#le,editor:{kind:`key`,phase:n.phase}}};return r!==void 0&&(i.cursorBadge=r),renderSelectQuestion(i,this.#i,t)};let syncCaret=()=>{n.phase.kind===`editing`||n.phase.kind===`invalid`?this.#qt():this.#Jt()};return syncCaret(),this.#Sn(),await this.#St((t,i,a)=>{let dispatch=t=>{let o=transitionProviderPicker(n,t,e.options);switch(o.kind){case`ignore`:return;case`clear`:r?.abort(),r=void 0,n=o.state,syncCaret(),this.#Sn();return;case`cancel`:i(void 0);return;case`render`:n=o.state,syncCaret(),this.#Sn();return;case`validate`:{n=o.state,syncCaret(),this.#Sn();let t=new AbortController;r=t;let i;try{i=e.validateInlineKey(o.key,t.signal)}catch(e){a(e);return}i.then(e=>{r!==t||t.signal.aborted||(r=void 0,dispatch({type:`validated`,validation:e}))},e=>{r!==t||t.signal.aborted||(r=void 0,a(e))});return}case`settle`:i(o.result);return}},o=setupSelectionIntent(t,{textNavigation:n.phase.kind===`inactive`});switch(o?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:o.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#Sn();return;case void 0:}if(n.phase.kind!==`editing`&&n.phase.kind!==`invalid`)return;let s=applyLineEditorKey(n.phase.editor,t);s!==void 0&&(this.#Yt(),dispatch({type:`edit`,editor:s}))},()=>{r?.abort(),r=void 0,this.#Jt()}).promise}async#gt(e){let t=this.#yt(`Select the model`),n=initialModelEditorState(e);return t.question=t=>renderModelEditorQuestion({request:e,state:n},this.#i,t,``),this.#Sn(),await this.#St((t,r)=>{let dispatch=t=>{let i=transitionModelEditor(n,t,e);switch(i.kind){case`ignore`:return;case`render`:n=i.state,this.#Sn();return;case`cancel`:r(void 0);return;case`settle`:r(i.result);return}},i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:i.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#Sn();return;case void 0:}if(t.type===`left`||t.type===`right`){dispatch({type:`adjust`,direction:t.type});return}if(t.type===`tab`){dispatch({type:`adjust`,direction:`right`});return}if(t.type===`backspace`){dispatch({type:`backspace`});return}if(t.type===`text`)for(let e of t.value.replaceAll(`
|
|
6
|
+
`,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#_t(e){let t=this.#yt(e.message),n=lineOf(``),r;return t.question=t=>{let i={message:``,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#le)},this.#qt(),this.#Sn(),await this.#St((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Yt(),this.#Sn()},a=applyLineEditorKey(n,t);if(a!==void 0){apply(a);return}switch(t.type){case`ctrl-c`:case`escape`:i(void 0);return;case`ctrl-r`:this.#Sn();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#Sn();return}i(t);return}default:return}},()=>this.#Jt()).promise}async#vt(e){let t=this.#yt(e.message);return t.question=t=>renderAcknowledgeQuestion({message:``,lines:e.lines},this.#i,t),this.#Sn(),await this.#St((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#Sn();return;default:return}}).promise}#yt(e){this.#Ft(),this.#U=!1,this.#X={kind:`idle`},this.#Q=``;let t=this.#bt();return t.questionTitle=stripTerminalControls(e),t.status!==void 0&&(t.status=void 0,t.summary=void 0,t.preview=void 0),t}#bt(){return this.#Ve===void 0&&(this.#Ve={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#Ve}#xt(){this.#Ve?.implicit===!0?this.#Ve=void 0:this.#Ve!==void 0&&(this.#Ve.question=void 0,this.#Ve.questionTitle=void 0,this.#Ve.hideLinesWhileQuestion=!1),this.#ge=void 0,this.#zt(),this.#k===void 0?this.#Ve!==void 0&&this.#wt():this.#rt(),this.#Ve===void 0&&this.#Sn()}#St(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#xt(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#xt(),i(e))};return this.#Wt(),this.#ge=t=>{t.type===`ctrl-c`&&this.#jt(),e(t,settle,reject)},this.#Rt(),{promise:a,settle}}#Ct(e){let t,n=new Promise(e=>{t=e});return this.#$e=t,this.#wt(e?.interruptible??!0),{promise:n,dispose:()=>{this.#$e===t&&(this.#$e=void 0,this.#Tt())}}}#wt(e=!0){if(this.#k!==void 0){this.#rt();return}if(this.#$e===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#jt();let e=this.#$e;this.#$e=void 0,this.#Tt(),e?.(t.type===`ctrl-c`?`ctrl-c`:`escape`);return}t.type===`ctrl-r`&&this.#Sn()};this.#et=consumer,this.#Wt(),this.#ge=consumer,this.#Rt()}#Tt(){this.#et!==void 0&&(this.#ge===this.#et&&this.#zt(),this.#et=void 0)}#Et(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#Ve!==void 0){this.#Ve.status=t,t===void 0&&(this.#Ve.preview=void 0),this.#Sn();return}if(!(this.#U||this.#Y)){if(t===void 0){this.#X={kind:`idle`},this.#$=void 0,this.#Qt(),this.#Sn();return}this.#Ft(),this.#Zt(),this.#$=t.text,this.#Sn()}}#Dt(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Ve;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#Sn();return}this.#Ft(),this.#$t({kind:`flow`,title:t,body:n,live:!1}),this.#Sn()}#Ot(e){let t=this.#Ve;t!==void 0&&(t.lines=[],t.outputBuffer=[],t.preview=void 0,t.status=void 0,t.summary=e===void 0?void 0:{headline:stripTerminalControls(e.headline),facts:e.facts.map(e=>({label:stripTerminalControls(e.label),value:stripTerminalControls(e.value)}))},this.#Sn())}#kt(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Ve;if(n===void 0){this.#Dt(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#Sn()}async#At(e){this.#_e=``,this.#Wt(),this.#$e=void 0,this.#Tt(),this.#zt(),this.#Qt(),this.#n.clear(),this.#Wn(),this.#r.enter({cursor:`visible`,mouse:!1}),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#r.exit(),this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#_e=``,this.#Wt(),this.#n.hideCursor(),this.#Un(),this.#Ve!==void 0&&(this.#Xt(),this.#wt()),this.#n.reset(),this.#Sn()}}setSessionId(e){this.#Ye=e}shutdown(){if(this.#Lt(),this.#ne&&!this.#re){this.#re=!0;let e=this.#Ye===void 0?``:` ${this.#i.glyph.dot} session ${this.#Ye}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}suspendPromptForInput(){this.#J={cursor:this.#V,text:this.#B},this.#Lt()}requestInterrupt(){this.#ie=!0,this.#Ve!==void 0&&this.#ge?.({type:`ctrl-c`}),this.#xe?.(),this.#Lt()}exitRequested(){return this.#ae}#jt(){this.#ae=!0,this.#ce?.()}async#Mt(e){if(this.#tt!==void 0||!this.#te)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Vn(),height:this.#Hn()}),paint:e=>this.#r.paint(e,this.#Hn()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#nt});this.#tt=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#Pt=e,this.#ge=e=>{t.handleKey(e)===`close`&&this.#Nt()},this.#Rt(),t.start()})}#Nt(){let e=this.#tt;if(e===void 0)return;this.#tt=void 0,e.dispose(),this.#zt(),this.#r.exit(),this.#n.hideCursor(),this.#Sn(),this.#n.showCursor();let t=this.#Pt;this.#Pt=void 0,t?.()}#Pt;#Ft(e){this.#ee=e?.title??this.#ee,e?.contextSize!==void 0&&(this.#Ee=e.contextSize),!this.#te&&(this.#te=!0,this.#ne=!0,this.#n.reset(),this.#n.hideCursor(),this.#Un(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#be=()=>this.#Sn(),this.#t.on(`resize`,this.#be),process.on(`exit`,this.#It))}#It=()=>{this.#te&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#Lt(){this.#Nt();let e=this.#Z;if(this.#Z=void 0,e?.(interruptedError()),this.#zt(),this.#Jt(),this.#Qt(),this.#me!==void 0&&(clearTimeout(this.#me),this.#me=void 0),this.#he=!1,this.#Qn(),this.#te){this.#er();for(let e of this.#h)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#Sn(),this.#n.clear(),this.#n.showCursor(),this.#Wn(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#be&&=(this.#t.off(`resize`,this.#be),void 0),process.off(`exit`,this.#It),this.#te=!1}}#Rt(){this.#e.off(`data`,this.#Bt),this.#e.on(`data`,this.#Bt),this.#_e.length>0&&queueMicrotask(()=>{this.#ge!==void 0&&this.#_e.length>0&&(this.#Ht(),this.#Vt())})}#zt(){this.#e.off(`data`,this.#Bt),this.#Wt(),this.#ge=void 0}#Bt=e=>{this.#Wt(),this.#_e+=this.#ve.write(e),this.#Ht(),this.#Vt()};#Vt(){if(this.#_e===`\x1B`){this.#ye=setTimeout(()=>{this.#_e===`\x1B`&&(this.#_e=``,this.#ge?.({type:`escape`}))},30),this.#ye.unref?.();return}if(isIncompletePaste(this.#_e)){let e=this.#_e;this.#ye=setTimeout(()=>{if(this.#_e!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#_e=``,t.length>0&&this.#ge?.({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#ye.unref?.();return}if(isIncompleteOsc(this.#_e)){let e=this.#_e;this.#ye=setTimeout(()=>{this.#_e===e&&(this.#_e=``)},incompletePasteFlushMs),this.#ye.unref?.()}}#Ht(){for(;this.#_e.length>0;){let e=nextKey(this.#_e);if(e.incomplete)return;if(this.#_e=this.#_e.slice(e.consumed),e.key!==void 0&&e.key.type!==`ignore`){if(e.key.type===`osc`){this.#Ut(e.key.value);continue}this.#ge?.(e.key)}}}#Ut(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#nt=t,this.#tt?.setTerminalBackground(t))}#Wt(){this.#ye&&=(clearTimeout(this.#ye),void 0)}#Gt(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#Sn();break;case`enter`:{let e=this.#J.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#Ke!==void 0){this.#J=EMPTY_LINE,this.#Ge.requestCancellation(),this.#Ze=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#Ke(),this.#Sn();break}let t=this.#qe;t!==void 0&&parsePromptCommand(e)===null?(this.#J=EMPTY_LINE,this.#Kt(e,t)):this.#Ge.enqueue(e)&&(this.#J=EMPTY_LINE),this.#Sn();break}case`ctrl-c`:case`escape`:if(e.type===`ctrl-c`&&this.#Ge.view().cancelling){this.#ie=!0,this.#se=!0,this.#X={kind:`idle`},this.#Q=`Interrupted`,this.#xe?.(),this.#Sn();break}if(this.#Ge.idle&&this.#Ke===void 0)break;if(this.#Ge.handleEscape()===`steer`){let e=this.#qe;if(e!==void 0){let t=this.#Ge.takeSteering();this.#Kt(t,e)}}else this.#Ze=!0,this.#Ke?.();this.#Sn();break;default:{let t=applyLineEditorKey(this.#J,e,{multiline:!0});t!==void 0&&(this.#J=t,this.#Sn());break}}}#Kt(e,t){this.#Xe=`steer`,this.#nn(e),t(e).catch(t=>{this.#Ge.restoreSteering(e),this.#rn(`Steering failed`,toErrorMessage(t)),this.#Sn()})}#qt(){this.#Jt(),this.#Yt(),this.#fe=setInterval(()=>{this.#le=!this.#le,this.#Sn()},500),this.#fe.unref?.()}#Jt(){this.#fe&&=(clearInterval(this.#fe),void 0),this.#le=!0}#Yt(){this.#le=!0}#Xt(){this.#Qt(),this.#pe=setInterval(()=>{this.#ue+=1,this.#Sn()},90),this.#pe.unref?.()}#Zt(){let e=Date.now();this.#de=e,this.#X={kind:`waiting`,startedAtMs:e},this.#Xt()}#Qt(){this.#pe&&=(clearInterval(this.#pe),void 0)}#$t(e){e.id!==this.#Pe?.id&&this.#er(),e.updateSeq=++this.#x;let t=e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId)?-1:this.#h.findIndex(e=>e.subagentCallId!==void 0&&this.#C.has(e.subagentCallId));t<0?this.#h.push(e):this.#h.splice(t,0,e),e.id&&this.#g.set(e.id,e)}#en(e){this.#K=!0,this.#$t({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#Sn()}#tn(){let e=this.#q.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#Pn(e.elapsedMs)}`,n=this.#Te??0;if(this.#Ee!==void 0&&this.#Ee>0&&n>0){let e=Math.round(n/this.#Ee*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#$t({kind:`turn-stats`,body:t,live:!1})}#nn(e){if(e==null)return;let t=this.#Xe;if(this.#Xe=void 0,this.#ze===e){this.#ze=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#$t(n)}#rn(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#f?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#f===void 0?a:`details: ${this.#f.displayPath}`),this.#$t(c),this.#Sn()}#in(e,t){if(this.#E.has(e))return;this.#E.add(e);let n=stripTerminalControls(t),r=this.#S.get(n)??[];if(r.push(e),this.#S.set(n,r),r.length===2){let e=this.#g.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#$t(i)}#an(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#x;return}this.#$t(e)}#on(e){if(e.id&&this.#_.has(e.id))return;let t=e.id?this.#g.get(e.id):void 0;if(t!==void 0){Object.assign(t,e),t.updateSeq=++this.#x;return}let n=e.subagentCallId;if(n===void 0){this.#$t(e);return}e.id!==this.#Pe?.id&&this.#er(),e.updateSeq=++this.#x;let r=-1;for(let e=0;e<this.#h.length;e+=1)this.#h[e]?.subagentCallId===n&&(r=e);this.#h.splice(r<0?this.#h.length:r+1,0,e),e.id!==void 0&&this.#g.set(e.id,e)}#sn(e){this.#h=this.#h.filter(t=>t.id!==e),this.#g.delete(e)}#cn(e){let t=this.#h.filter(t=>t.subagentCallId===e);t.length!==0&&(this.#h=this.#h.filter(t=>t.subagentCallId!==e),this.#h.push(...t))}#ln(){for(let e of this.#h)e.subagentCallId!==void 0&&this.#w.has(e.subagentCallId)||e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#un(e,t,n){switch(e.type){case`step-finish`:this.#f?.recordStepUsage(e.usage),e.usage!==void 0&&this.#q.addUsage(e.usage),this.#_n(n),this.#xn(e.usage),this.#Sn();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#dn(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=typeof e.text==`string`?stripTerminalControls(e.text):t;n.text.set(e.id,r),this.#dn(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#fn(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#fn(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#pn({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#f?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#pn({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#pn({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#bn(e.toolCallId,n);if(r===void 0)break;this.#pn({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#bn(e.toolCallId,n);if(this.#f?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#pn({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#bn(e.toolCallId,n);if(r===void 0)break;this.#pn({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#rn(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:if(n.cancelled=!0,!n.restoreCancelledPrompt)break;this.#Je=!0,!this.#Ze&&this.#Qe!==void 0&&this.#J.text.length===0&&(this.#J=lineOf(this.#Qe),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#xn(e.usage),this.#Sn()}}#dn(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#an({id:e,kind:`assistant`,body:r,live:n}),this.#Sn())}#fn(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#an({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#Sn())}#pn(e,t,n){if(n.tools.set(e.toolCallId,e),this.#y.has(e.toolCallId)||this.#vn(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#b.set(e.toolCallId,r);let i=this.#mn(e);this.#an(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#yn(n),this.#Sn()}#mn(e){e.output!==void 0&&this.#T.observeRead(e.output);let t={};this.#hn(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#T.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#hn(e){let t=this.#D?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#gn(e){for(let t of e.tools.keys()){if(this.#y.has(t))continue;let e=this.#b.get(t)??toolSectionId(t),n=this.#g.get(e);n?.kind===`tool`&&n.status===`running`&&(n.status=`error`,n.result=`interrupted`,n.live=!1)}}#_n(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#b.get(t)??toolSectionId(t);this.#sn(r),this.#b.delete(t)}}#vn(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#We!==e&&(this.#We=e,this.#$t({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#Vn(),this.#i).join(`
|
|
7
|
+
`),live:!1})),this.#Ue=void 0}else this.#Ue=t.length>0?t:void 0,this.#We=void 0;return this.#Sn(),!0}#yn(e){let t=[];for(let n of e.tools.values()){if(this.#y.has(n.toolCallId))continue;let e=this.#b.get(n.toolCallId)??toolSectionId(n.toolCallId),r=this.#g.get(e);r?.kind===`tool`&&t.push({block:r,active:isActiveToolStatus(n.status)})}applyCohortLiveness(t)}#bn(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#b.get(e)??toolSectionId(e),i=this.#g.get(r);if(i!==void 0&&i.kind===`tool`)return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.toolName??i.title??`tool`}}#xn(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#we=(t??0)+(n??0)),this.#Te=t??this.#Te,this.#De=n??this.#De,this.#De!=null&&this.#ke!==void 0){let e=(Date.now()-this.#ke)/1e3;e>0&&(this.#Oe=this.#De/e)}}#Sn(){if(this.#te){if(this.#Se){this.#Ce=!0;return}this.#Se=!0;try{do this.#Ce=!1,this.#Cn();while(this.#Ce)}finally{this.#Se=!1}}}#Cn(){if(!this.#te)return;if(this.#tt!==void 0){this.#tt.repaint();return}let e=this.#Vn(),t=this.#Mn(e),n=this.#M===void 0?[]:this.#Dn(),r=Math.max(1,this.#Hn()-n.length-t.length),i=[],a=this.#I,o=groupToolBlocksForDisplay(this.#h),s=0;for(;s<o.length&&o[s].display.live===!1;)s+=1;if(s>0){let e=new Set(o.slice(0,s).flatMap(e=>e.members));for(let t=this.#h.length-1;t>=0;--t)e.has(this.#h[t])&&this.#h.splice(t,1)}for(let t of o.slice(0,s)){for(let e of t.members)this.#v.push(e),e.id&&(this.#_.add(e.id),this.#g.delete(e.id));if(this.#nr(t.display))continue;let n=this.#On(t.display,e,a);a=previousBlockOf(t.display),this.#I=a,i.push(...n),this.#F.push(...n)}let c=[];for(let{display:t}of o.slice(s)){if(this.#nr(t))continue;let n=this.#On(t,e,a);a=previousBlockOf(t);for(let e=0;e<n.length;e+=1)c.push({block:t,row:n[e]})}let l=[...n,...clipLiveRows(c.map(e=>e.row),r,e,this.#i),...t];i.length>0?this.#n.flush(i,l):this.#n.update(l)}#wn(){if(!this.#te)return;let e=this.#Vn(),t=this.#Mn(e),n=Math.max(1,this.#Hn()-t.length),r=this.#I,i=[];for(let{display:t}of groupToolBlocksForDisplay(this.#h)){if(this.#nr(t))continue;let n=this.#On(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#i),...t];this.#n.clearAll(),this.#n.flush([...this.#Dn(),...this.#F],a)}logDisplayMode(){return this.#m}setLogDisplayMode(e){e!==this.#m&&(this.#m=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#En(),this.#te&&this.#wn())}flushDelayedDevBuildErrors(){let e=this.#Ne;e!==void 0&&(this.#Ne=void 0,this.#$t({kind:`log`,title:`stderr`,body:e,live:!0}),this.#Sn())}#Tn(){this.#he=!0,this.#me!==void 0&&clearTimeout(this.#me),this.#me=setTimeout(()=>{this.#he=!1,this.#me=void 0,this.#Sn()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#m)),this.#Sn()}#En(){let e=this.#Vn();this.#F.length=0;let t;for(let{display:n}of groupToolBlocksForDisplay(this.#v,{logCoalescing:`runs`})){if(this.#nr(n))continue;let r=this.#On(n,e,t);t=previousBlockOf(n),this.#F.push(...r)}this.#I=t}#Dn(){let e=this.#D,t=this.#M;if(e===void 0&&t===void 0)return[];let n={name:e?.name??t?.name,theme:this.#i,width:this.#Vn()};e?.info!==void 0&&(n.info=e.info);let r=e?.tip??t?.tip;return r!==void 0&&(n.tip=r),buildAgentHeader(n)}#On(e,t,n){let r={renderMarkdown:this.#a,activityPulse:this.#An(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#i,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#kn(){return this.#i.spinner[this.#ue%this.#i.spinner.length]??``}#An(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#jn(e,t){return e.indicator.kind===`spinner`?{glyph:this.#kn(),color:`yellow`}:{glyph:this.#An(e.indicator.startedAtMs,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#Mn(e){let t=this.#i.colors,n=[``];if(this.#Be!==void 0)return n.push(...this.#Be(e),``),this.#Rn(n,e),n;let r=this.#Ve;if(r!==void 0&&(this.#k===void 0||r.question!==void 0)){let t=this.#jn(r,r.status),i;if(r.status!==void 0){let{startedAtMs:e,...n}=r.status,a=Date.now()-e,o=a>=5e3?` ${formatTurnDuration(a)}`:``;i={...n,text:`${n.text}${o}`,indicator:t}}let a;if(r.question!==void 0){let t=r.question(e);a={kind:`question`,title:r.questionTitle,rows:t},i!==void 0&&(a={kind:`question`,title:r.questionTitle,rows:t,status:i})}else i===void 0?a=r.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:r.preview,indicator:t}:(a={kind:`status`,status:i},r.preview!==void 0&&(a={kind:`status`,status:i,preview:r.preview}));let o={title:r.title,navigation:r.navigation,lines:r.summary===void 0?r.hideLinesWhileQuestion===!0?[]:r.lines:[{text:r.summary.headline,tone:`success`},...r.summary.facts.map(e=>({text:`${e.label}: ${e.value}`,tone:`info`}))],content:a};return n.push(...renderFlowPanel(o,this.#i,e)),this.#zn(n,e),n}r!==void 0&&n.push(...flowMessageRows(r.lines,this.#i).map(t=>t.length===0?``:clip(` ${t}`,e))),this.#O===void 0&&this.#He!==void 0&&n.push(...renderAttentionRows(this.#He,e,this.#i),``),this.#Ue!==void 0&&n.push(...renderTodoPanelRows({items:this.#Ue,width:e,theme:this.#i,working:this.#Y||this.#X.kind===`waiting`,pulse:this.#An(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)}),``);let i=renderMessageQueueRows({view:this.#Ge.view(),width:e,theme:this.#i,working:this.#Y});if(i.length>0&&n.push(...i,``),this.#U){let r=this.#W===void 0?void 0:inlineCommandHint(this.#W);r===void 0&&this.#W!==void 0&&isTypeaheadOpen(this.#W)&&n.push(...renderCommandSuggestions(this.#W,this.#i,e)),this.#oe&&n.push(clip(t.dim(`Press Ctrl+C again to exit`),e),``);let i=isPromptControlCommand(this.#B),a=r?t.dim(` ${r}`):``,o=[];this.#Rn(o,e);let s=Math.max(1,this.#Hn()-1-n.length-1-o.length),c={text:this.#B,cursor:this.#V,width:e,theme:this.#i,caretVisible:this.#le,isCommand:i,ghost:a,maxRows:s};return this.#G&&this.#B.length===0&&(c.placeholder=this.#k===void 0?this.#K?``:`Send a message…`:`Message · Enter to queue`),n.push(...promptInputRows(c)),n.push(...o),n}let a=this.#X.kind===`waiting`&&this.#$===void 0;if(this.#Y||a){n.push(this.#Nn(e)),this.#In(n,e);let t=[];return this.#Rn(t,e),!this.#Y&&t.length>0&&n.push(``),n.push(...t),n}if(this.#J.text.length>0)return this.#Ln(n,e,{inert:!1}),this.#Rn(n,e),n;let o=this.#$??(this.#Q.length>0?this.#Q:`Ready`),s=this.#Bn(),c=t.dim(this.#i.glyph.dot),l=s?`${c} ${o} ${t.dim(this.#i.glyph.dot)} ${s}`:`${c} ${o}`;return n.push(clip(l,e)),this.#Rn(n,e),n}#Nn(e){let t=this.#i.colors,n=this.#An(this.#de,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),r=this.#X,i=this.#q.startedAtMs??this.#ke??(r.kind===`waiting`?r.startedAtMs:Date.now()),a=Date.now()-i,o=`${typewriterText(`Working for`,a,80)} ${this.#Pn(a)}`;return clip(`${t.yellow(n)} ${t.dim(o)}`,e)}#Pn(e){return`${formatTurnDuration(e)}${this.#Fn()}`}#Fn(){let{inputTokens:e,outputTokens:t}=this.#q.usage;return e===0&&t===0?``:` ${this.#i.glyph.dash.repeat(2)} ${formatTokenFlow({inputTokens:e,outputTokens:t},this.#i.glyph)}`}#In(e,t){this.#Y&&this.#Ln(e,t,{inert:!0})}#Ln(e,t,n){e.push(``);let r={text:this.#J.text,cursor:this.#J.cursor,width:t,theme:this.#i,caretVisible:!0,isCommand:!1,ghost:``,maxRows:4,inert:n.inert};n.inert&&this.#J.text.length===0&&(r.placeholder=``),e.push(...promptInputRows(r))}#Rn(e,t){if(this.#O!==void 0){let n=this.#Ve?.status?.text??{starting:`Starting agent…`,connecting:`Reading saved connection…`,updating:`Loading selected model…`}[this.#O],r=this.#An(this.#j,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH);e.push(clip(this.#i.colors.dim(`${r} ${n}`),t));return}let n=this.#z===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#i,width:r};this.#Ie&&this.#Fe!==void 0&&(i.devBuild=this.#Fe),this.#he&&(i.logLevel=this.#m);let a=this.#D?.info?.agent.model;a?.id!==void 0&&(i.model=a.id),a?.reasoning!==void 0&&a.reasoning!==`provider-default`&&(i.reasoning=a.reasoning),readGatewayServiceTier(a?.providerOptions).kind===`priority`&&(i.fastMode=!0);let o=a?.endpoint;o!==void 0&&(i.endpoint=o),this.#R!==void 0&&(i.vercel=this.#R),this.#z!==void 0&&(i.remote=this.#z);let s=buildStatusLine(i);s!==void 0&&e.push(clip(`${n}${s}`,t))}#zn(e,t){if(this.#z===void 0)return;let n=Math.max(1,t-2),r=buildStatusLine({remote:this.#z,theme:this.#i,width:n});r!==void 0&&e.push(``,clip(` ${r}`,t))}#Bn(){let e=this.#i.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#we,outputTokens:this.#De,tokensPerSecond:this.#Oe},this.#u);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#i.glyph.dot} `)):``}#Vn(){return Math.max(20,this.#t.columns||80)}#Hn(){return Math.max(8,this.#t.rows||24)}#Un(){if(this.#Ae!==void 0||!this.#d)return;this.#je=``,this.#Me=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#Kn(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#f?.subscribeLogRecords(e=>this.#Gn(e)),this.#Ae=()=>{this.#f?.unsubscribeLogRecords(),e(),t()}}#Wn(){let e=this.#Ae;e!==void 0&&(this.#Ae=void 0,e(),this.#je.length>0&&(this.#f?.append({source:`stdout`,detail:this.#je}),this.#tr(`stdout`)&&process.stdout.write(`${this.#je}\n`),this.#je=``),this.#Me.length>0&&(this.#f?.append({source:`stderr`,detail:this.#Me}),this.#tr(`stderr`)&&process.stderr.write(`${this.#Me}\n`),this.#Me=``))}#Gn(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#Jn(`[eve:${e.namespace}] ${e.message}${t}`),this.#Sn()}#Kn(e,t){let n=(e===`stdout`?this.#je:this.#Me)+t;if(e===`stdout`&&parseDevRebuildLogLine(n.trimEnd())!==void 0){this.#je=``,this.#f?.append({source:e,detail:n.trimEnd()}),this.#qn(n.trimEnd()),this.#Sn();return}let r=n.lastIndexOf(`
|
|
8
|
+
`),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#je=i:this.#Me=i,r===-1)return;let a=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);a.trim().length!==0&&(this.#f?.append({source:e,detail:a}),e===`stdout`?this.#qn(a):this.#Jn(a),this.#Sn())}#qn(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
|
|
9
|
+
`);t=[],e.trim().length!==0&&this.#$t({kind:`log`,title:`stdout`,body:e,live:!0})};for(let n of e.split(`
|
|
10
|
+
`)){let e=parseSandboxLogLine(n.trimEnd());if(e!==void 0){flushPending(),this.#$t({kind:`sandbox`,body:e,live:!1});continue}let r=parseDevRebuildLogLine(n.trimEnd());if(r===void 0){t.push(n);continue}flushPending(),this.#Xn(r,n.trimEnd())}flushPending()}#Jn(e){let t=e.split(`
|
|
11
|
+
`),n=t.findIndex(e=>parseDevRebuildLogLine(e.trimEnd())?.kind===`failed`);if(n===-1){if(this.#f===void 0){this.#$t({kind:`log`,title:`stderr`,body:e,live:!0});return}let t=presentDiagnostic(e,this.#f.displayPath);if(t.kind===`inline`){this.#$t({kind:`log`,title:`stderr`,body:t.text,live:!0});return}this.#$t({kind:`log`,title:`stderr`,body:formatStoredDiagnostic(t),logVisibility:`stderr-only`,live:!0}),this.#$t({kind:`log`,title:`stderr`,body:e,logVisibility:`all-only`,live:!0});return}let r=t.slice(0,n).join(`
|
|
12
|
+
`);r.trim().length>0&&this.#$t({kind:`log`,title:`stderr`,body:r,live:!0});let i=t.slice(n).join(`
|
|
13
|
+
`);this.#Yn(i)}#Yn(e){if(this.#Qn(),this.#m===`all`){if(e.trim().length===0)return;this.#$t({kind:`log`,title:`stderr`,body:e,live:!0});return}this.#Ne=e}#Xn(e,t){let n=this.#$n();if(e.kind===`failed`){this.#Yn(t);return}if(e.kind===`rebuilding`){let t=summarizeChangedFiles(e.events,e.more);if(this.#Zn({phase:`building`,summary:t}),n!==void 0){n.state.summary=t,n.block.body=formatDevRebuildStatus(t,`rebuilding`);return}let r=`dev-rebuild:${this.#Re}`;this.#Re+=1,this.#Pe={id:r,summary:t},this.#$t({kind:`log`,id:r,title:`stdout`,body:formatDevRebuildStatus(t,`rebuilding`),live:!0});return}let r=n?.state.summary??this.#Fe?.summary;if(r!==void 0&&this.#Zn({phase:`complete`,summary:r}),n!==void 0){n.block.body=formatDevRebuildStatus(n.state.summary,e.kind),e.kind===`rebuilt`&&(this.#Ne=void 0);return}e.kind===`rebuilt`&&(this.#Ne=void 0),this.#$t({kind:`log`,title:`stdout`,body:t,live:!0})}#Zn(e){this.#Le!==void 0&&clearTimeout(this.#Le),this.#Fe=e,this.#Ie=e.phase===`complete`,this.#Le=setTimeout(()=>{e.phase===`building`?(this.#Ie=!0,this.#Le=void 0):this.#Qn(),this.#Sn()},e.phase===`building`?250:4e3)}#Qn(){this.#Le!==void 0&&clearTimeout(this.#Le),this.#Fe=void 0,this.#Ie=!1,this.#Le=void 0}#$n(){let e=this.#Pe;if(e===void 0)return;let t=this.#g.get(e.id);if(t!==void 0&&t.live===!0)return{state:e,block:t}}#er(){let e=this.#Pe;if(e===void 0)return;this.#Pe=void 0;let t=this.#g.get(e.id);t!==void 0&&(t.live=!1)}#tr(e){switch(this.#m){case`none`:return!1;case`stderr`:return e===`stderr`;case`sandbox`:return e===`sandbox`;case`all`:return!0}}#nr(e){return e.kind===`sandbox`?!this.#tr(`sandbox`):e.kind===`log`?e.logVisibility===`stderr-only`?this.#m!==`stderr`:e.logVisibility===`all-only`?this.#m!==`all`:!this.#tr(e.title===`stderr`?`stderr`:`stdout`):!1}};function chunkToString(e,t){return typeof e==`string`?e:Buffer.from(e).toString(t)}async function*iterateTUIStream(e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}return}yield*e}function clip(e,t){return clipVisible(e,t)}function promptInputRows({text:e,cursor:t,width:n,theme:r,caretVisible:i,isCommand:a,ghost:o,maxRows:s,placeholder:c,inert:l}){let u=r.colors;if(e.length===0&&c!==void 0){let e=renderInputWithBlockCursor({...visibleLine({text:c,cursor:0},Math.max(1,n-3),r.glyph.ellipsis),visible:i,inverse:u.inverse,render:e=>u.dim(renderInputText(e))});return[clip(`${r.glyph.prompt} ${e}`,n),``]}let style=e=>{let t=renderInputText(e);return a&&t.length>0?u.blue(t):t},d=layoutPromptInput({text:e,cursor:t}),f=Math.min(Math.max(1,s),d.rows.length),p=Math.max(0,Math.min(d.caretRow-f+1,d.rows.length-f)),m=l===!0?u.dim(r.glyph.prompt):u.cyan(r.glyph.prompt),h=u.dim(r.glyph.ellipsis),g=Math.max(1,n-3),_=[];for(let e=p;e<p+f;e+=1){let t=d.rows[e],a=e===0?m:` `;(e===p&&p>0||e===p+f-1&&p+f<d.rows.length)&&(a=h);let s;if(e===d.caretRow){let{before:e,under:n,after:a}=visibleLine({text:t.text,cursor:d.caretOffset},g,r.glyph.ellipsis);s=renderInputWithBlockCursor({before:e,under:n,after:a,visible:i,inverse:u.inverse,render:style}),o.length>0&&d.rows.length===1&&(s+=o)}else s=style(t.text);_.push(clip(`${a} ${s}`,n))}return _.push(``),_}function previousBlockOf(e){let t={kind:e.kind};return e.title!==void 0&&(t.title=e.title),t}function isActiveToolStatus(e){return e===`running`||e===`approval`}function applyCohortLiveness(e){let t=e.some(e=>e.active);for(let n of e)n.block.live=t||n.active}function leadsWithGap(e,t){if(e.kind===`tool`&&(t?.kind===`user`||t?.kind===`assistant`||t?.kind===`question`))return!0;if(e.kind===`sandbox`&&t?.kind===`sandbox`)return!1;if(t?.kind===`sandbox`&&e.kind!==`sandbox`||t?.kind===`log`)return!0;switch(e.kind){case`user`:case`assistant`:case`reasoning`:case`subagent`:case`error`:case`notice`:case`question`:case`connection-auth`:case`sandbox`:case`log`:case`command`:case`warning`:case`flow`:case`turn-stats`:case`session-boundary`:case`todo-list`:case`agent-header`:return!0;default:return!1}}function parseSandboxLogLine(e){let t=e.trim();if(!t.startsWith(`eve: `))return;let n=t.slice(5);return/\bsandbox\b/i.test(n)&&!isLowValueSandboxLogLine(n)?n:void 0}function isLowValueSandboxLogLine(e){return/^initializing (?:\d+ )?sandbox templates?\b/i.test(e)||/^initialized \d+ sandbox\b/i.test(e)||/^reused cached sandbox template\b/i.test(e)||/^sandbox template "[^"]+" \([^)]+\): (checking|reusing|loading microsandbox runtime|microsandbox runtime ready)\b/i.test(e)}function clipLiveRows(e,t,n,r){if(e.length<=t)return[...e];if(t<=1)return[clip(hiddenRowsMarker(e.length,r),n)];let i=t-1;return[clip(hiddenRowsMarker(e.length-i,r),n),...e.slice(e.length-i)]}function hiddenRowsMarker(e,t){let n=e.toLocaleString(),r=e===1?`row`:`rows`;return t.colors.dim(`${t.glyph.dot} ${t.glyph.ellipsis} ${n} earlier ${r} hidden while streaming`)}function collapseReasoning(e,t){switch(e){case`collapsed`:return!0;case`auto-collapsed`:return!t;default:return!1}}function renderNativeToolBlock(e,t,n,r){let i=e.preparing===!0?presentPreparingTool(e.toolName,r):presentTool(e.toolName,e.input,r),a={id:t,kind:`tool`,title:stripTerminalControls(i.title),subtitle:stripTerminalControls(i.subtitle),status:e.status,live:e.status===`running`||e.status===`approval`,expanded:n,toolInput:e.input,toolName:e.toolName,toolGroup:i.group};return i.doneTitle!==void 0&&(a.doneTitle=stripTerminalControls(i.doneTitle)),i.detail!==void 0&&(a.detailLines=i.detail,a.keepDetailWhenDone=i.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(a.result=stripTerminalControls(e.errorText)):(a.result=i.summarizeResult(e.output),a.toolOutput=e.output),a}function writeExistedFlag(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e.existed;return typeof t==`boolean`?t:void 0}function subagentToolStatus(e){switch(e){case`preparing`:return`running`;case`approval-requested`:return`approval`;case`executing`:return`running`;case`done`:return`done`;case`failed`:return`error`;case`rejected`:return`denied`}}function formatToolApprovalTitle(e){return stripTerminalControls(e.title??e.toolName)}function toolSectionId(e){return`tool:${e}`}function questionSectionId(e){return`question:${e}`}function subagentHeaderId(e){return`subagent:${e}:header`}function subagentStepSectionId(e,t){return`subagent:${e}:step:${t}`}function subagentToolSectionId(e,t){return`subagent:${e}:tool:${t}`}function connectionAuthSectionId(e){return`connection-auth:${e}`}function connectionAuthTerminalMessage(e){switch(e){case`authorized`:return`Authorization complete`;case`declined`:return`Authorization declined`;case`failed`:return`Authorization failed`;case`timed-out`:return`Authorization timed out`;case`required`:case`pending`:return}}function formatConnectionAuthContent(e,t){let n=[];if(t!==void 0)n.push(t);else{let t=stripTerminalControls(e.description);t.length>0&&n.push(t);let r=e.challenge;r?.url&&n.push(`URL: ${stripTerminalControls(r.url)}`),r?.userCode&&n.push(`Code: ${stripTerminalControls(r.userCode)}`),r?.expiresAt&&n.push(`Expires: ${stripTerminalControls(r.expiresAt)}`),r?.instructions&&n.push(stripTerminalControls(r.instructions))}if(e.reason!==void 0){let t=stripTerminalControls(e.reason);t.length>0&&n.push(`Reason: ${t}`)}return n.join(`
|
|
14
14
|
`)}function formatQuestionContent(e,t,n){let r=n.colors,i=[],a=e.options??[];if(a.length>0){for(let[e,o]of a.entries()){let a=stripTerminalControls(o.label),s=o.description===void 0?``:stripTerminalControls(o.description),c=t===e,l=s.length>0?`${c?` `:` `}${r.dim(`— ${s}`)}`:``,u=c?`${n.glyph.selectedPointer} ${a}`:` ${a}`,d=renderCursorRow(u,c,r);i.push(`${d}${l}`)}if(e.allowFreeform===!0){let e=t===a.length,o=`Type your own answer`,s=e?`${n.glyph.selectedPointer} ${o}`:` ${r.dim(o)}`;i.push(renderCursorRow(s,e,r))}}else i.push(r.dim(` (type your answer)`));return i.join(`
|
|
15
15
|
`)}function resolveQuestionText(e,t){let n=e.trim();if(n.length===0)return;let r=n.toLowerCase(),i=t.options??[];if(i.length>0){let e=matchQuestionOption(r,i);if(e!==void 0)return{optionId:e.id,label:e.label}}if(t.allowFreeform===!0||i.length===0)return{text:n,label:n}}function matchQuestionOption(e,t){let n=t.find(t=>t.id.toLowerCase()===e);if(n!==void 0)return n;let r=t.find(t=>t.label.toLowerCase()===e);if(r!==void 0)return r;let i=Number(e);if(Number.isInteger(i)&&i>0&&i<=t.length)return t[i-1]}export{TerminalRenderer};
|
|
@@ -35,9 +35,9 @@ export declare class MockScreen extends EventEmitter implements TerminalOutput {
|
|
|
35
35
|
snapshot(): string;
|
|
36
36
|
rawOutput(): string;
|
|
37
37
|
/**
|
|
38
|
-
* Resolves once the runner parks at an idle prompt: a column-0
|
|
38
|
+
* Resolves once the runner parks at an idle prompt: a column-0 `❯` row
|
|
39
39
|
* with no live turn bar on screen. A streaming turn keeps an identical
|
|
40
|
-
*
|
|
40
|
+
* `❯` prompt anchored (Enter inert), so the glyph alone cannot signal
|
|
41
41
|
* readiness — the bar's absence is the discriminator.
|
|
42
42
|
*/
|
|
43
43
|
waitForIdlePrompt(timeoutMs?: number): Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{EventEmitter}from"node:events";const ansiControlSequencePattern=RegExp(`^\x1B\\[([0-9?;]*)([ -/]*)([@-~])`);var MockUserInput=class extends EventEmitter{isTTY=!0;rawModes=[];resumeCalls=0;pauseCalls=0;setRawMode(e){return this.rawModes.push(e),this}resume(){return this.resumeCalls+=1,this}pause(){return this.pauseCalls+=1,this}type(e){this.emit(`data`,Buffer.from(e))}send(e){this.emit(`data`,Buffer.from(e))}enter(){this.send(`\r`)}backspace(){this.send(``)}up(){this.send(`\x1B[A`)}down(){this.send(`\x1B[B`)}left(){this.send(`\x1B[D`)}right(){this.send(`\x1B[C`)}ctrlC(){this.send(``)}ctrlN(){this.send(``)}ctrlP(){this.send(``)}},MockScreen=class extends EventEmitter{isTTY=!0;columns;rows;#e=``;#t=[];#n=0;#r=0;#i;#a=[];constructor({columns:e,rows:t}){super(),this.columns=e,this.rows=t}write(e,t,n){let r=String(e);return this.#e+=r,this.#s(r),typeof t==`function`&&t(),n?.(),this.#o(),!0}resize(e,t){this.columns=e,this.rows=t,this.emit(`resize`)}snapshot(){return this.#t.join(`
|
|
2
|
-
`)}rawOutput(){return this.#e}async waitForIdlePrompt(e=1e3){let t=Array.from({length:11},(e,t)=>`Working for`.slice(0,t+1)),n=RegExp(`^[▪* ] (?:${t.join(`|`)}) \\d`,`mu`),idle=()=>{let e=this.snapshot();return/^[
|
|
2
|
+
`)}rawOutput(){return this.#e}async waitForIdlePrompt(e=1e3){let t=Array.from({length:11},(e,t)=>`Working for`.slice(0,t+1)),n=RegExp(`^[▪* ] (?:${t.join(`|`)}) \\d`,`mu`),idle=()=>{let e=this.snapshot();return/^[❯]/mu.test(e)&&!n.test(e)},r=Date.now()+e;for(;Date.now()<r;){if(idle())return;await new Promise(e=>setTimeout(e,25))}throw Error(`Timed out waiting for an idle prompt.\n\nScreen:\n${this.snapshot()}`)}async waitForText(e,t=1e3,n=()=>this.snapshot()){this.snapshot().includes(e)||await new Promise((r,i)=>{let a={text:e,resolve:r,reject:i,timeout:setTimeout(()=>{this.#a=this.#a.filter(e=>e!==a),i(Error(`Timed out waiting for screen text: ${e}\n\nScreen:\n${n()}`))},t)};this.#a.push(a)})}#o(){let e=this.snapshot();for(let t of this.#a.slice())e.includes(t.text)&&(clearTimeout(t.timeout),this.#a=this.#a.filter(e=>e!==t),t.resolve())}#s(e){let t=0;for(;t<e.length;){if(e[t]===`\x1B`){let n=this.#c(e,t);if(n>t){t=n;continue}}let n=e[t];if(t+=1,n!==void 0){if(n===`
|
|
3
3
|
`){this.#n+=1,this.#r=0;continue}if(n===`\r`){this.#r=0;continue}this.#d(n)}}}#c(e,t){let n=e.slice(t).match(ansiControlSequencePattern);if(!n)return t;let[r,i=``,,a]=n,o=i.startsWith(`?`),s=i&&!o?i.split(`;`):[],first=e=>s[0]===void 0||s[0]===``?e:Number(s[0]);if(o)return i===`?1049`&&(a===`h`||a===`l`)&&(a===`h`?(this.#i={lines:this.#t,cursorLine:this.#n,cursorColumn:this.#r},this.#t=[],this.#n=0,this.#r=0):this.#i!==void 0&&(this.#t=this.#i.lines,this.#n=this.#i.cursorLine,this.#r=this.#i.cursorColumn,this.#i=void 0)),t+r.length;switch(a){case`H`:case`f`:this.#n=first(1)-1,this.#r=(s[1]?Number(s[1]):1)-1;break;case`A`:this.#n=Math.max(0,this.#n-first(1));break;case`B`:this.#n+=first(1);break;case`C`:this.#r+=first(1);break;case`D`:this.#r=Math.max(0,this.#r-first(1));break;case`E`:this.#n+=first(1),this.#r=0;break;case`F`:this.#n=Math.max(0,this.#n-first(1)),this.#r=0;break;case`G`:this.#r=first(1)-1;break;case`J`:this.#l(first(0));break;case`K`:this.#u(first(0))}return t+r.length}#l(e){if(e===2||e===3){this.#t=[],this.#n=0,this.#r=0;return}if(e===1){for(let e=0;e<this.#n;e+=1)this.#t[e]=``;this.#u(1);return}this.#u(0),this.#t.length=Math.min(this.#t.length,this.#n+1)}#u(e){let t=this.#t[this.#n]??``;if(e===2){this.#t[this.#n]=``;return}if(e===1){this.#t[this.#n]=` `.repeat(this.#r)+t.slice(this.#r);return}this.#t[this.#n]=t.slice(0,this.#r)}#d(e){let t=(this.#t[this.#n]??``).padEnd(this.#r,` `),n=t.slice(0,this.#r)+e+t.slice(this.#r+e.length);this.#t[this.#n]=n,this.#r+=e.length}};export{MockScreen,MockUserInput};
|
|
@@ -76,8 +76,6 @@ export interface ThemeGlyphs {
|
|
|
76
76
|
option: string;
|
|
77
77
|
/** `❯` — the input prompt mark. */
|
|
78
78
|
prompt: string;
|
|
79
|
-
/** `›` — the prompt mark's quiet form while the buffer is empty. */
|
|
80
|
-
promptIdle: string;
|
|
81
79
|
/** `⎿` — hangs a command's result under its invocation. */
|
|
82
80
|
elbow: string;
|
|
83
81
|
/** `▔` — strong full-width rule opening the bottom question panel. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}[39m`}const UNICODE_GLYPHS={brand:`▲`,user:`│`,reasoning:`○`,square:`▪`,corner:`└`,cornerOpen:`┌`,external:`⌝`,dotActive:`⏺`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`※`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer
|
|
1
|
+
function ansi(e,t,n){if(!n)return e=>e;let r=`[${e}m`,i=`[${t}m`;return e=>`${r}${e}${i}`}function ansi256(e,t){if(!t)return e=>e;let n=`[38;5;${e}m`;return e=>`${n}${e}[39m`}const UNICODE_GLYPHS={brand:`▲`,user:`│`,reasoning:`○`,square:`▪`,corner:`└`,cornerOpen:`┌`,external:`⌝`,dotActive:`⏺`,success:`✓`,error:`⨯`,warning:`⚠`,subagent:`※`,rule:`│`,question:`?`,connection:`●`,arrow:`→`,pointer:`›`,selectedPointer:`›`,option:` `,prompt:`❯`,elbow:`⎿`,hrule:`▔`,dash:`─`,caret:`▏`,dot:`·`,ellipsis:`…`,arrowUp:`↑`,arrowDown:`↓`,fast:`↯`,trackFilled:`●`,trackCurrent:`◉`,trackEmpty:`○`,trackLine:`─`,enter:`↵`,validating:`▪`},ASCII_GLYPHS={brand:`>`,user:`|`,reasoning:`o`,square:`*`,corner:"`",cornerOpen:`,`,external:`^`,dotActive:`*`,success:`+`,error:`x`,warning:`!`,subagent:`*`,rule:`|`,question:`?`,connection:`*`,arrow:`->`,pointer:`>`,selectedPointer:`>`,option:`.`,prompt:`>`,elbow:"`-",hrule:`=`,dash:`-`,caret:`_`,dot:`-`,ellipsis:`...`,arrowUp:`^`,arrowDown:`v`,fast:`>>`,trackFilled:`*`,trackCurrent:`O`,trackEmpty:`.`,trackLine:`-`,enter:`<-'`,validating:`o`},UNICODE_SPINNER=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],ASCII_SPINNER=[`-`,`\\`,`|`,`/`];function createTheme(e={}){let t=e.color??!0,n=e.unicode??!0;return{color:t,unicode:n,colors:{reset:ansi(0,0,t),bold:ansi(1,22,t),dim:ansi(2,22,t),inverse:ansi(7,27,t),italic:ansi(3,23,t),white:ansi(97,39,t),gray:ansi(90,39,t),cyan:ansi(36,39,t),green:ansi(32,39,t),red:ansi(31,39,t),yellow:ansi(33,39,t),magenta:ansi(35,39,t),blue:ansi(34,39,t),orange:ansi256(208,t)},glyph:n?UNICODE_GLYPHS:ASCII_GLYPHS,spinner:n?UNICODE_SPINNER:ASCII_SPINNER}}function detectUnicode(e=process.env){let t=e.EVE_TUI_UNICODE;return t===`0`||t===`false`?!1:t===`1`||t===`true`?!0:e.TERM===`dumb`?!1:process.platform!==`win32`||!!(e.WT_SESSION||e.TERM_PROGRAM===`vscode`)}export{createTheme,detectUnicode};
|
|
@@ -30,7 +30,10 @@ export interface DevelopmentTuiStartup {
|
|
|
30
30
|
readonly diagnostics: DevDiagnostics | undefined;
|
|
31
31
|
readonly headerTip: string;
|
|
32
32
|
readonly renderer: TerminalRenderer;
|
|
33
|
-
finish():
|
|
33
|
+
finish(): {
|
|
34
|
+
draft: string;
|
|
35
|
+
queuedPrompt: string | undefined;
|
|
36
|
+
};
|
|
34
37
|
shutdown(): Promise<void>;
|
|
35
38
|
}
|
|
36
39
|
export declare function startDevelopmentTuiStartup(input: TuiDisplayOptions & {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { resolveModelTeamSlug } from "#internal/model-auth/vercel-team.js";
|
|
1
2
|
import { detectProjectIdentity, type ProjectIdentity } from "#setup/project-resolution.js";
|
|
2
3
|
/** Workspace-scoped Vercel state shown in the dev TUI's status line. */
|
|
3
4
|
export interface VercelStatusSnapshot {
|
|
4
5
|
/** Resolved link identity; absent while unlinked or while a probe is in flight. */
|
|
5
6
|
identity?: ProjectIdentity;
|
|
7
|
+
modelTeamSlug?: string;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* Status-line effect a completed setup command reports back to the runner.
|
|
@@ -21,10 +23,10 @@ export interface VercelStatusTrackerOptions {
|
|
|
21
23
|
onChange: (snapshot: VercelStatusSnapshot) => void;
|
|
22
24
|
/** Test seam; defaults to the real network-bound probe. */
|
|
23
25
|
detectIdentity?: typeof detectProjectIdentity;
|
|
26
|
+
resolveTeamSlug?: typeof resolveModelTeamSlug;
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
|
-
* Owns the Vercel segment of the dev TUI status line:
|
|
27
|
-
* identity. The identity probe is network-bound (it shells `vercel api`), so it runs only at startup and
|
|
29
|
+
* Owns the Vercel segment of the dev TUI status line: cached deployment identity and model-account team slug. The identity probe is network-bound (it shells `vercel api`), so it runs only at startup and
|
|
28
30
|
* after provider setup or a /deploy — never on a poll. A linked directory
|
|
29
31
|
* whose `vercel` CLI call fails resolves to the raw project id as the name
|
|
30
32
|
* (see {@link detectProjectIdentity}); an unlinked one resolves to no identity,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{detectProjectIdentity}from"#setup/project-resolution.js";function createVercelStatusTracker(e){let t=e.detectIdentity??detectProjectIdentity,n,r=0,
|
|
1
|
+
import{detectProjectIdentity}from"#setup/project-resolution.js";import{resolveModelTeamSlug}from"#internal/model-auth/vercel-team.js";function createVercelStatusTracker(e){let t=e.detectIdentity??detectProjectIdentity,n,r,i=0,a=!1,o,snapshot=()=>{let e={};return n!==void 0&&(e.identity=n),r!==void 0&&(e.modelTeamSlug=r),e},emit=()=>{a||e.onChange(snapshot())},refreshIdentity=()=>{if(a)return;o?.abort();let s=new AbortController;o=s,i+=1;let c=i;(async()=>{let l,u;try{[l,u]=await Promise.all([t(e.appRoot,{signal:s.signal}),(e.resolveTeamSlug??resolveModelTeamSlug)(s.signal).catch(()=>void 0)])}catch{return}finally{o===s&&(o=void 0)}a||c!==i||(n=l,r=u,emit())})()};return{refreshIdentity,applyEffect(e){if(!a)switch(e.kind){case`deployed`:emit(),refreshIdentity();return;case`refresh-identity`:refreshIdentity();return}},current:snapshot,dispose(){a||(a=!0,i+=1,o?.abort(),o=void 0)}}}export{createVercelStatusTracker};
|
package/dist/src/cli/run.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{Command,CommanderError,InvalidArgumentError,Option}from"#compiled/commander/index.js";import{agentCommand}from"#cli/agent-command.js";import{parseDevelopmentHeaderOption,resolveDevelopmentUrlTarget}from"#cli/dev/url-target.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";import{FORCED_EXIT_BACKSTOP_MS,installShutdownSignal,waitForShutdownSignal}from"#cli/shutdown.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{findEveProjectContext,resolveEveProjectContext}from"#internal/project-context.js";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{eveCliBanner}from"#cli/banner.js";import{startCliLiveRow}from"#cli/ui/live-row.js";import{registerBuildCommand}from"#cli/commands/build.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{findCliApplicationRoot,resolveCliApplicationProject}from"#cli/application-root.js";import{registerIntegrationCommands}from"#cli/commands/register-integration-commands.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{registerRegistryCommands}from"#cli/commands/register-registry-commands.js";import{runInteractiveDevelopmentUi}from"#cli/dev/run-interactive-ui.js";import{resolveDevUiMode,resolveTuiDisplayOptions}from"#cli/dev/ui-options.js";import{registerAcpCommand}from"#cli/acp/command.js";import{waitForServerOrStop,waitForUiOrServer}from"#cli/dev/wait-for-ui.js";import{registerRuntimeInvokeCommand}from"#cli/invoke/command.js";import{parseAgentNamesOption,parseContextSizeOption,parseDisplayMode,parseLogsMode,parsePortOption,parseReasoningOption,parseStatsMode}from"#cli/option-parsers.js";import{createDevBootProgressReporter}from"#cli/dev/boot-progress.js";import{registerEveTelemetryCommands}from"#cli/telemetry/command.js";import{canonicalCommand,createEveCliTelemetry}from"#cli/telemetry/index.js";async function loadPrintApplicationInfo(){return(await import(`#cli/commands/info.js`)).printApplicationInfo}async function loadDevelopmentTuiModule(){return await import(`#cli/dev/tui/tui.js`)}async function loadRunEvalCommand(){return(await import(`#evals/cli/eval.js`)).runEvalCommand}async function loadStartHost(){return(await import(`#cli/dev/local-server-process.js`)).createDevelopmentServer}const loadIsActiveDevelopmentServerForApp=async()=>(await import(`#internal/nitro/host.js`)).isActiveDevelopmentServerForApp;async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function hasInteractiveTerminal(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function createCliProgram(e,t,n,r){let i=resolveInstalledPackageInfo().version,a=new Command,o=createCliTheme();a.name(`eve`).description(`Build and run an eve application.`).version(i).showHelpAfterError().exitOverride().hook(`preAction`,(t,n)=>{let{json:r}=n.opts();[`info`,`init`].includes(n.name())&&!r&&e.log(eveCliBanner())}).configureOutput({writeErr:t=>{e.error(t.trimEnd())},writeOut:t=>{e.log(t.trimEnd())}}),agentCommand(a.command(`channels`).description(`Manage user-authored channels in the current project.`).command(`list`),n).description(`List user-authored channels in the current project.`).option(`--json`,`Output as JSON`).action(async t=>{let{runChannelsListCommand:r}=await import(`#cli/commands/channels.js`);await r(e,n.project,t)}),registerEveTelemetryCommands(a,e),registerIntegrationCommands({program:a,logger:e,applicationContext:n});let s=a.command(`extension`).description(`Create and build reusable eve extension packages.`);s.command(`init [target]`).description(`Create a new eve extension package.`).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve extension init.`);let{runExtensionInitCommand:a}=await import(`#cli/commands/extension-init.js`);await a(e,n.root,t,void 0,e=>{r.trackSetupStep({flow:`extension_init`,step:e})})}),s.command(`build`).description(`Build the current package as an eve extension.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);await t(n.root);let{runExtensionBuildCommand:r}=await import(`#cli/commands/extension-build.js`);await r(e,n.root)}),registerRegistryCommands({program:a,logger:e,applicationContext:n}),a.command(`init [target]`).description(`Create a new eve agent, or add one to an existing project directory.`).option(`--channel-web-nextjs`,`Add the Web Chat application (Next.js)`).option(`--agents <names>`,`Create an agents/ workspace with comma-separated agent names`,parseAgentNamesOption).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve init.`);let{runInitCommand:a}=await import(`#cli/commands/init.js`);await a(e,n.root,t,{agents:i.agents,channelWebNextjs:i.channelWebNextjs,model:i.model,reasoning:i.reasoning},void 0,e=>{r.trackSetupStep({flow:`init`,step:e})},(e,t,n)=>{r.trackSetupTerminal({flow:`init`,step:e,result:t,failureCode:n})})}),agentCommand(a.command(`set`),n).description(`Change root agent model settings.`).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).action(async t=>{let{runSetCommand:r}=await import(`#cli/commands/set.js`);await r(e,n.root,t)}),registerProjectCommands({program:a,logger:e,applicationContext:n}),registerBuildCommand({applicationContext:n,buildHost:t.buildHost,logger:e,program:a}),agentCommand(a.command(`start`),n).description(`Start a built eve application.`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).action(async r=>{let{loadDevelopmentEnvironmentFiles:i}=await import(`#cli/dev/environment.js`);await i(n.root);let a=await(t.startProductionHost??await loadStartProductionHost())(n.root,{host:r.host,port:r.port});e.log(renderCliTaggedLine(o,{message:`server listening at ${a.url}`,tag:`start`,tone:`success`})),await waitForShutdownSignal({close:()=>a.close(),wait:()=>a.wait()})}),registerRuntimeInvokeCommand({applicationContext:n,logger:e,program:a,runtime:t}),registerAcpCommand({applicationContext:n,eveVersion:i,program:a,resolveVerifiedRemoteDevelopmentClient:t.resolveVerifiedRemoteDevelopmentClient,runAcpServer:t.runAcpServer,startHost:t.startHost}),agentCommand(a.command(`dev`),n,e=>{let t=e.opts();return resolveDevelopmentUrlTarget(t,e.processedArgs[0])===void 0}).description(`Start the eve development server or connect to an existing URL.`).argument(`[url]`,`Connect to an existing server URL`,parseDevelopmentServerUrl).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 2000)`,parsePortOption).option(`-u, --url <url>`,`Connect to an existing server URL`,parseDevelopmentServerUrl).option(`-H, --header <header>`,`Request header for a URL target, in "Name: value" form (repeatable)`,parseDevelopmentHeaderOption).option(`--no-ui`,`Start the server without an interactive UI`).option(`--name <name>`,`Title shown in the terminal UI (defaults to the app folder name)`).option(`--input <text>`,`Pre-fill the prompt input`).addOption(new Option(`--onboard`,`Start fresh-agent onboarding`).hideHelp()).option(`--tools <mode>`,`How tool calls render: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--reasoning <mode>`,`How reasoning renders: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--subagents <mode>`,`How subagent sections render: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--connection-auth <mode>`,`How connection authorization renders: full | collapsed | auto-collapsed | hidden`,parseDisplayMode).option(`--assistant-response-stats <mode>`,`Assistant header statistic: tokens | tokensPerSecond`,parseStatsMode).option(`--context-size <tokens>`,`Model context window size, shown as a usage percentage`,parseContextSizeOption).option(`--logs <mode>`,`Which server/agent logs to show: all | stderr | sandbox | none`,parseLogsMode).addHelpText(`after`,`
|
|
2
2
|
You can also pass a bare URL, for example: eve dev https://example.com
|
|
3
|
-
`).action(async(i,a)=>{let s=resolveDevelopmentUrlTarget(a,i),c=s?.serverUrl,l=hasInteractiveTerminal(),u=resolveDevUiMode({options:a,interactive:l});if(r.trackDevContext({target:s?`remote`:`local`,ui:u}),u===`headless`&&e.log(eveCliBanner()),a.input!==void 0&&u===`headless`)throw new InvalidArgumentError(`--input requires the interactive UI.`);let d=!1;if(c!==void 0&&(d=await(t.isActiveDevelopmentServerForApp??await loadIsActiveDevelopmentServerForApp())({appRoot:n.root,serverUrl:c})),c){let{loadDevelopmentEnvironmentFiles:i}=await import(`#cli/dev/environment.js`);if(await i(n.root),e.log(`↗ ${d?`local`:`remote`} mode targeting ${o.info(new URL(c).host)}`),u===`headless`){e.log(renderCliTaggedLine(o,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}e.log(``);let l=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS});try{await runInteractiveDevelopmentUi({applicationRoot:n.root,existingLocalServer:d,lifecycle:l,onOnboardingStep:r.trackSetupStep,onOnboardingTerminal:r.trackSetupTerminal,options:a,remoteTarget:s,runDevelopmentTui:t.runDevelopmentTui,server:{serverUrl:c}})}finally{l.dispose()}return}let f=u===`tui`?startCliLiveRow(e):void 0,p=createDevBootProgressReporter(f);f?.update(`Building your agent`);let m,h,closeServer=()=>m===void 0?Promise.resolve():(h??=m.close(),h.catch(()=>void 0),h),g=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS,onStop:()=>{closeServer()}}),_,v=u===`tui`&&
|
|
3
|
+
`).action(async(i,a)=>{let s=resolveDevelopmentUrlTarget(a,i),c=s?.serverUrl,l=hasInteractiveTerminal(),u=resolveDevUiMode({options:a,interactive:l});if(r.trackDevContext({target:s?`remote`:`local`,ui:u}),u===`headless`&&e.log(eveCliBanner()),a.input!==void 0&&u===`headless`)throw new InvalidArgumentError(`--input requires the interactive UI.`);let d=!1;if(c!==void 0&&(d=await(t.isActiveDevelopmentServerForApp??await loadIsActiveDevelopmentServerForApp())({appRoot:n.root,serverUrl:c})),c){let{loadDevelopmentEnvironmentFiles:i}=await import(`#cli/dev/environment.js`);if(await i(n.root),e.log(`↗ ${d?`local`:`remote`} mode targeting ${o.info(new URL(c).host)}`),u===`headless`){e.log(renderCliTaggedLine(o,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`}));return}e.log(``);let l=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS});try{await runInteractiveDevelopmentUi({applicationRoot:n.root,existingLocalServer:d,lifecycle:l,onOnboardingStep:r.trackSetupStep,onOnboardingTerminal:r.trackSetupTerminal,options:a,remoteTarget:s,runDevelopmentTui:t.runDevelopmentTui,server:{serverUrl:c}})}finally{l.dispose()}return}let f=u===`tui`?startCliLiveRow(e):void 0,p=createDevBootProgressReporter(f);f?.update(`Building your agent`);let m,h,closeServer=()=>m===void 0?Promise.resolve():(h??=m.close(),h.catch(()=>void 0),h),g=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS,onStop:()=>{closeServer()}}),_,v=u===`tui`&&t.runDevelopmentTui===void 0?loadDevelopmentTuiModule().then(e=>(p({type:`before-first-paint`}),e.startDevelopmentTuiStartup({appRoot:n.root,initialInput:a.input,onExitRequest:g.requestStop,...resolveTuiDisplayOptions(a)}))):void 0;try{m=(t.startHost??await loadStartHost())(n.root,{existing:u===`tui`?`attach-if-unconfigured`:`reject`,host:a.host,onBootProgress:p,port:a.port});let[i,s]=await Promise.all([Promise.race([m.start().then(e=>({handle:e})),g.stopped.then(()=>({handle:void 0}))]),v]),c=i.handle;if(c===void 0){_=s,await _?.shutdown();return}if(_=s,u!==`tui`&&e.log(renderCliTaggedLine(o,{message:`server listening at ${c.url}`,tag:`dev`,tone:`success`})),u===`headless`){a.ui!==!1&&!l&&e.log(renderCliTaggedLine(o,{message:`Interactive UI disabled because the current terminal is not a TTY.`,tag:`dev`,tone:`warning`})),await waitForServerOrStop(m,g);return}await waitForUiOrServer({handle:c,lifecycle:g,server:m,runUi:async()=>await runInteractiveDevelopmentUi({applicationRoot:n.root,existingLocalServer:!1,lifecycle:g,onOnboardingStep:r.trackSetupStep,onOnboardingTerminal:r.trackSetupTerminal,options:a,report:p,runDevelopmentTui:t.runDevelopmentTui,server:{appRoot:c.appRoot,serverUrl:c.url},startup:_})})}finally{f?.stop(),_===void 0&&(_=await v?.catch(()=>void 0),await _?.shutdown()),await closeServer(),g.dispose()}});let c=a.command(`logs`).description("Inspect local `eve dev` diagnostic logs (.eve/logs).");return agentCommand(c.command(`show [logid]`,{isDefault:!0}),n).description(`Print a diagnostic log (the most recent when logid is omitted).`).option(`--dump`,`Prepend the log's environment dump (.dump sibling)`).option(`--events`,`Interleave session events from the local workflow store`).action(async(t,r)=>{let{runLogsShowCommand:i}=await import(`#cli/commands/logs.js`);await i(e,n.root,t,r)}),agentCommand(c.command(`ls`),n).description(`List diagnostic logs, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runLogsListCommand:r}=await import(`#cli/commands/logs.js`);await r(e,n.root,t)}),agentCommand(a.command(`traces [trace]`),n).usage(`[options] [trace]
|
|
4
4
|
eve traces ls [options]`).description("Show a local `eve dev` trace (the most recent when trace is omitted).").option(`--verbose`,`Expand every span with all attributes and events`).option(`--json`,`Output as JSON`).action(async(t,r)=>{let{runTraceShowCommand:i}=await import(`#cli/commands/trace.js`);await i(e,n.root,t,r)}).command(`ls`).description(`List local traces, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runTraceListCommand:r}=await import(`#cli/commands/trace.js`);await r(e,n.root,t)}),agentCommand(a.command(`info`),n).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async r=>{await(t.printApplicationInfo??await loadPrintApplicationInfo())(e,n.root,r)}),agentCommand(a.command(`eval`),n,e=>e.opts().url===void 0).description(`Run evals against an eve agent.`).argument(`[evalIds...]`,`Eval ids (or directory prefixes) to run (all discovered evals when omitted)`).option(`--url <url>`,`Remote agent URL (skip local host startup)`,parseDevelopmentServerUrl).option(`--tag <tag...>`,`Run only evals carrying a tag`).option(`--exclude-tag <tag...>`,`Skip evals carrying a tag`).option(`--strict`,`Fail the exit code when any score falls below its threshold`).option(`--list`,`Print discovered evals without running them`).option(`--timeout <ms>`,`Per-eval timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent eval executions`).option(`--json`,`Output results as JSON`).option(`--junit <path>`,`Write JUnit XML results to a file`).option(`--skip-report`,`Skip eval-defined reporters (e.g. Braintrust)`).option(`--verbose`,`Stream per-eval logs and workflow run IDs to stdout`).action(async(r,i)=>{await(t.runEvalCommand??await loadRunEvalCommand())(r,i,e,n.root)}),a}async function runCli(e=process.argv.slice(2),t=console,n={}){let r={root:resolveApplicationRoot(),async resolve(){let e=await(n.resolveApplicationProject??resolveCliApplicationProject)(r.root);r.project=e,r.root=e.appRoot},async resolveAgent(){return resolveEveProjectContext(r.root)}},i=createEveCliTelemetry(resolveInstalledPackageInfo().version),a=createCliProgram(t,n,r,i),o=e;if(o.length===0){let e=await(n.findApplicationRoot??findCliApplicationRoot)(r.root);e===void 0?o=(await findEveProjectContext(r.root))?.kind===`workspace`?[`dev`]:[`init`]:(r.root=e,o=[`dev`])}let s=canonicalCommand(o);i.trackCommand(s),s!==`telemetry`&&await i.notify(t);try{await a.parseAsync(o,{from:`user`}),i.trackOutcome(`success`)}catch(e){if(e instanceof CommanderError&&e.exitCode===0){i.trackOutcome(`success`);return}if(i.trackOutcome(e instanceof CommanderError?`usage_error`:`error`),e instanceof CommanderError){let r=await(n.isCodingAgentLaunch??isCodingAgentLaunch)();if(o[0]===`init`&&r){let{initAgentInstructions:e}=await import(`#cli/commands/agent-instructions.js`);t.log(e())}throw Error(e.message)}throw e}finally{await i.flush()}}export{createCliProgram,resolveDevUiMode,resolveTuiDisplayOptions,runCli};
|