eve 0.56.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 +40 -0
- package/dist/src/channel/adapter-context.d.ts +1 -1
- package/dist/src/channel/adapter.d.ts +2 -2
- package/dist/src/channel/channel-address.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-RUGSwq8b.js → use-eve-agent-C2APNCdP.js} +45 -12
- package/dist/src/chunks/{use-eve-agent-CMdMlS7Y.js → use-eve-agent-D0YnDLi_.js} +45 -12
- package/dist/src/cli/commands/init.d.ts +2 -6
- package/dist/src/cli/commands/init.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 +1 -6
- package/dist/src/cli/dev/tui/blocks.js +1 -1
- package/dist/src/cli/dev/tui/command-typeahead.js +1 -1
- 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 +12 -18
- 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 +3 -2
- 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/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/client/agent-info-schema.d.ts +2 -0
- 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 +15 -6
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +3 -1
- package/dist/src/context/keys.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.js +4 -3
- 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/create-session-step.d.ts +1 -1
- package/dist/src/execution/durable-session-store.d.ts +10 -48
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/eve-workflow-attributes.d.ts +0 -16
- 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 -0
- 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/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.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.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/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 -0
- package/dist/src/instrumentation/ai-sdk-hook-bridge.js +1 -1
- package/dist/src/instrumentation/channel-delivery.js +1 -1
- package/dist/src/instrumentation/lifecycle.d.ts +1 -0
- package/dist/src/instrumentation/native-events.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/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/dev-authored-source-watcher.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/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/discord/discordChannel.js +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/telegramChannel.js +1 -1
- package/dist/src/public/definitions/channel.d.ts +1 -1
- package/dist/src/public/definitions/channel.js +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/vercel/index.d.ts +2 -1
- package/dist/src/public/vercel/index.js +1 -1
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/self-modification/agent.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 +1 -1
- 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/chatgpt-model.d.ts +2 -2
- package/dist/src/shared/chatgpt-model.js +1 -1
- 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/vercel-services.d.ts +1 -0
- package/dist/src/shared/vercel-services.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.js +1 -1
- package/dist/src/tasks/types.d.ts +1 -1
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- 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/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +22 -22
- package/docs/channels/chat-sdk.mdx +4 -2
- package/docs/channels/custom.mdx +16 -10
- package/docs/channels/eve.mdx +3 -1
- package/docs/channels/linq.mdx +1 -1
- package/docs/channels/overview.mdx +4 -2
- package/docs/channels/photon.mdx +4 -1
- package/docs/channels/slack.mdx +3 -1
- package/docs/concepts/execution-model-and-durability.mdx +62 -13
- package/docs/concepts/sessions-runs-and-streaming.md +14 -5
- package/docs/getting-started.mdx +7 -3
- package/docs/guides/deployment/vercel.mdx +1 -1
- package/docs/guides/dev-tui.md +54 -27
- package/docs/guides/frontend/overview.mdx +3 -1
- package/docs/guides/instrumentation/meta.json +1 -0
- package/docs/memory/custom-provider.md +1 -1
- package/docs/protocols/acp.md +1 -1
- package/docs/reference/cli.md +2 -2
- package/docs/reference/telemetry.md +1 -1
- package/docs/reference/typescript-api.md +12 -5
- package/docs/sandbox.mdx +3 -3
- package/docs/subagents/index.mdx +2 -2
- package/docs/tools/workflows.mdx +1 -1
- 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/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 -85
- 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/subagents/handles/rebase.d.ts +0 -4
- package/dist/src/subagents/handles/rebase.js +0 -1
- /package/dist/src/{execution/next-driver-action.js → client/eve-agent-store-state.js} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { relative } from "node:path";
|
|
2
|
+
import { captureVercel, runVercelCaptureStdout } from "#setup/primitives/run-vercel.js";
|
|
3
|
+
import type { VercelProjectReference } from "#setup/project-resolution.js";
|
|
2
4
|
export interface SelfModificationSetupValues {
|
|
3
5
|
readonly branch: string;
|
|
4
6
|
readonly channelNames: readonly string[];
|
|
@@ -15,13 +17,17 @@ export interface DetectedGitRepository {
|
|
|
15
17
|
readonly remoteKind: "github" | "missing" | "other";
|
|
16
18
|
}
|
|
17
19
|
export interface SelfModificationSetupOperations {
|
|
18
|
-
attachConnector(connector: string): Promise<void>;
|
|
20
|
+
attachConnector(connector: string, project: VercelProjectReference): Promise<void>;
|
|
19
21
|
detectChannelNames(): Promise<readonly string[]>;
|
|
20
22
|
detectGitRepository(): Promise<DetectedGitRepository>;
|
|
21
|
-
findOrCreateConnector(name: string): Promise<string>;
|
|
23
|
+
findOrCreateConnector(name: string, project: VercelProjectReference): Promise<string>;
|
|
22
24
|
readConfig(): Promise<string | undefined>;
|
|
23
25
|
writeConfig(source: string): Promise<void>;
|
|
24
26
|
}
|
|
27
|
+
export interface SelfModificationSetupDependencies {
|
|
28
|
+
captureVercel: typeof captureVercel;
|
|
29
|
+
runVercelCaptureStdout: typeof runVercelCaptureStdout;
|
|
30
|
+
}
|
|
25
31
|
export declare function connectorName(owner: string, repo: string): string;
|
|
26
32
|
export declare function renderSelfModificationConfig(values?: SelfModificationSetupValues): string;
|
|
27
33
|
/** Distinguishes resumable generated source from authored source without evaluating it. */
|
|
@@ -30,7 +36,7 @@ export declare function parseGitHubRemote(remote: string): {
|
|
|
30
36
|
owner: string;
|
|
31
37
|
repo: string;
|
|
32
38
|
} | undefined;
|
|
33
|
-
export declare function defaultSelfModificationSetupOperations(appRoot: string): SelfModificationSetupOperations;
|
|
39
|
+
export declare function defaultSelfModificationSetupOperations(appRoot: string, deps?: SelfModificationSetupDependencies): SelfModificationSetupOperations;
|
|
34
40
|
export declare function repositoryRelativeDirectory(repositoryRoot: string, appRoot: string, relativePath?: typeof relative): string;
|
|
35
41
|
export declare function repositoryPartError(value: string): string | undefined;
|
|
36
42
|
export declare function directoryError(value: string): string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{SELF_MODIFICATION_CONFIG_PATH}from"./git-workspace.js";import{createHash}from"node:crypto";import{readFile,writeFile}from"node:fs/promises";import{join,relative}from"node:path";import{discoverAgent}from"#discover/discover-agent.js";import{execFile}from"node:child_process";import{promisify}from"node:util";import{stripLogicalPathExtension}from"#discover/filesystem.js";const runFile=promisify(execFile);function connectorName(e,t){return`selfmod-${e}-${t}`.toLowerCase().replaceAll(/[^a-z0-9-]/gu,`-`)}function renderSelfModificationConfig(e){if(e===void 0)return`import { defineSelfModificationConfig } from "eve/self-modification/config";
|
|
1
|
+
import{SELF_MODIFICATION_CONFIG_PATH}from"./git-workspace.js";import{createHash}from"node:crypto";import{readFile,writeFile}from"node:fs/promises";import{join,relative}from"node:path";import{discoverAgent}from"#discover/discover-agent.js";import{execFile}from"node:child_process";import{promisify}from"node:util";import{stripLogicalPathExtension}from"#discover/filesystem.js";import{captureVercel,runVercelCaptureStdout}from"#setup/primitives/run-vercel.js";const runFile=promisify(execFile),defaultDependencies={captureVercel,runVercelCaptureStdout};function connectorName(e,t){return`selfmod-${e}-${t}`.toLowerCase().replaceAll(/[^a-z0-9-]/gu,`-`)}function renderSelfModificationConfig(e){if(e===void 0)return`import { defineSelfModificationConfig } from "eve/self-modification/config";
|
|
2
2
|
|
|
3
3
|
export default defineSelfModificationConfig({
|
|
4
4
|
local: { enabled: true },
|
|
@@ -45,4 +45,4 @@ ${r} default:
|
|
|
45
45
|
export default defineSelfModificationConfig({});
|
|
46
46
|
`)return`local`;let[t,...n]=e.split(`
|
|
47
47
|
`);return/^\/\/ eve-self-modification: generated-v1 digest:([a-f0-9]{64})$/u.exec(t??``)?.[1]===createHash(`sha256`).update(n.join(`
|
|
48
|
-
`)).digest(`hex`)?`generated`:`authored`}function parseGitHubRemote(e){let t=e.trim().match(/^(?:https?:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([^/]+)\/([^/]+?)(?:\.git)?$/u);return t?.[1]===void 0||t[2]===void 0?void 0:{owner:t[1],repo:t[2]}}function defaultSelfModificationSetupOperations(e){let
|
|
48
|
+
`)).digest(`hex`)?`generated`:`authored`}function parseGitHubRemote(e){let t=e.trim().match(/^(?:https?:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([^/]+)\/([^/]+?)(?:\.git)?$/u);return t?.[1]===void 0||t[2]===void 0?void 0:{owner:t[1],repo:t[2]}}function defaultSelfModificationSetupOperations(e,t=defaultDependencies){let n=join(e,SELF_MODIFICATION_CONFIG_PATH);return{async detectChannelNames(){return(await discoverAgent({appRoot:e,agentRoot:join(e,`agent`)})).manifest.channels.map(e=>stripLogicalPathExtension(e.logicalPath).replace(/^channels\//,``))},async detectGitRepository(){let t=await gitOutput(e,[`config`,`--get`,`remote.origin.url`]),n=t===void 0?void 0:parseGitHubRemote(t),r=await gitOutput(e,[`symbolic-ref`,`--quiet`,`--short`,`refs/remotes/origin/HEAD`]),i=await gitOutput(e,[`rev-parse`,`--show-toplevel`]);return{...n,branch:r?.replace(/^origin\//u,``),directory:i===void 0?void 0:repositoryRelativeDirectory(i,e),remoteKind:t===void 0?`missing`:n===void 0?`other`:`github`}},async readConfig(){try{return await readFile(n,`utf8`)}catch(e){if(e.code===`ENOENT`)return;throw e}},writeConfig:e=>writeFile(n,e,`utf8`),async findOrCreateConnector(n,r){let i=await listGitHubConnectors(e,r,t.captureVercel),a=`github/${n}`,o=i.find(e=>e.uid===a);if(o!==void 0){if(o.type!==`github`)throw Error(`The existing connector ${a} is not a GitHub connector.`);return o.uid}let s=await t.runVercelCaptureStdout([`connect`,`create`,`github`,`--name`,n,`-F`,`json`,`--scope`,r.orgId],{cwd:e}),c=s.ok?parseCreatedConnector(s.stdout):void 0;if(c===void 0||!c.startsWith(`github/`))throw Error(`Could not create a GitHub Vercel Connect connector.`);return c},async attachConnector(n,r){if(!(await t.runVercelCaptureStdout([`connect`,`attach`,n,`--project`,r.projectId,`--environment`,`production`,`--yes`,`--scope`,r.orgId],{cwd:e})).ok)throw Error(`Could not attach ${n} to the selected Vercel project for Production.`)}}}function parseCreatedConnector(e){try{let t=JSON.parse(e);return typeof t.uid==`string`?t.uid:void 0}catch{return}}function parseConnectorListPage(e){try{let t=JSON.parse(e);if(!Array.isArray(t.connectors))return;let n=t.connectors.flatMap(e=>typeof e==`object`&&e&&typeof e.uid==`string`&&typeof e.type==`string`?[{uid:e.uid,type:e.type}]:[]);return typeof t.cursor==`string`?{connectors:n,cursor:t.cursor}:{connectors:n}}catch{return}}async function listGitHubConnectors(e,t,n){let r=[],i=new Set,a;do{let o=[`connect`,`list`,`--all-projects`,`--service`,`github`,`-F`,`json`,`--scope`,t.orgId];a!==void 0&&o.push(`--next`,a);let s=await n(o,{cwd:e});if(!s.ok)throw Error(`Could not list GitHub connectors for the selected Vercel project. ${s.failure.message}`);let c=parseConnectorListPage(s.stdout);if(c===void 0)throw Error(`Vercel returned an invalid GitHub connector list for the selected project.`);if(r.push(...c.connectors),c.cursor!==void 0&&i.has(c.cursor))throw Error(`The GitHub connector list repeated cursor ${c.cursor}.`);c.cursor!==void 0&&i.add(c.cursor),a=c.cursor}while(a!==void 0);return r}function repositoryRelativeDirectory(e,t,n=relative){return n(e,t).replaceAll(`\\`,`/`)||`.`}function repositoryPartError(e){return/^[A-Za-z0-9_.-]+$/u.test(e)?void 0:`Enter a valid GitHub owner or repository name.`}function directoryError(e){return e===`.`||e.length>0&&!e.startsWith(`/`)&&!e.includes(`\\`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)?void 0:`Enter a safe repository-relative directory or ".".`}function gitRefError(e){return/^[A-Za-z0-9][A-Za-z0-9._/-]*$/u.test(e)&&!e.endsWith(`.`)&&!e.endsWith(`/`)&&!e.includes(`..`)&&!e.includes(`//`)&&!e.includes(`@{`)?void 0:`Enter a valid branch name.`}async function gitOutput(e,t){try{return(await runFile(`git`,t,{cwd:e})).stdout.trim()||void 0}catch{return}}export{classifySelfModificationConfig,connectorName,defaultSelfModificationSetupOperations,directoryError,gitRefError,parseGitHubRemote,renderSelfModificationConfig,repositoryPartError,repositoryRelativeDirectory};
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
/** The color primitives the row painter needs; satisfied by both the TUI theme and the CLI palette. */
|
|
14
14
|
export interface RowColors {
|
|
15
15
|
blue(text: string): string;
|
|
16
|
+
bold?(text: string): string;
|
|
16
17
|
dim(text: string): string;
|
|
17
18
|
green(text: string): string;
|
|
18
19
|
inverse(text: string): string;
|
|
@@ -83,7 +84,7 @@ export declare function resolveOptionRowState(option: {
|
|
|
83
84
|
lockedReason?: string;
|
|
84
85
|
}, checked: boolean): OptionRowState;
|
|
85
86
|
/** Paints a row with the shared leading cell and optional cursor highlight. */
|
|
86
|
-
export declare function renderCursorRow(text: string, selected: boolean, colors: Pick<RowColors, "blue" | "inverse" | "yellow">, accent?: "warning"): string;
|
|
87
|
+
export declare function renderCursorRow(text: string, selected: boolean, colors: Pick<RowColors, "blue" | "inverse" | "yellow" | "bold">, accent?: "warning"): string;
|
|
87
88
|
/** Prefixes a continuation line so its text starts in the option label column. */
|
|
88
89
|
export declare function renderOptionRowContinuation(text: string): string;
|
|
89
90
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const UNICODE_ROW_GLYPHS={pointer
|
|
1
|
+
const UNICODE_ROW_GLYPHS={pointer:`›`,selectedPointer:`›`,success:`✓`,placeholder:` `,dot:`·`,warning:`⚠`};function resolveOptionRowState(e,t){if(Number(e.disabled===!0)+Number(e.completed===!0)+Number(e.locked===!0)>1)throw Error(`An option row cannot combine disabled, completed, or locked states.`);if(e.disabled===!0){let t={kind:`disabled`};return e.disabledReason!==void 0&&(t.reason=e.disabledReason),e.disabledReasonTone!==void 0&&(t.reasonTone=e.disabledReasonTone),t}if(e.completed===!0)return{kind:`completed`};if(e.locked===!0){let t={kind:`locked`};return e.lockedReason!==void 0&&(t.reason=e.lockedReason),t}return{kind:`available`,checked:t}}function parenthetical(e){return e===void 0?``:` (${e})`}function unfocusedGlyph(e){return e.placeholder?e.colors.dim(e.glyphs.placeholder):` `}function disabledLabel(e,t,n,r){if(t.reasonTone===`warning`){let i=t.reason===void 0?``:` ${r.warning} ${t.reason}`;return`${n.dim(e)}${n.yellow(i)}`}let i=parenthetical(t.reason);return n.dim(`${e}${i}`)}function optionRowPresentation(e){let{colors:t,glyphs:n,state:r}=e;switch(r.kind){case`available`:return e.isCursor?{glyph:r.checked?n.success:n.selectedPointer,label:e.label}:{glyph:r.checked?t.green(n.success):unfocusedGlyph(e),label:e.accent===`warning`?t.yellow(e.label):e.label};case`completed`:return{glyph:e.isCursor?t.dim(n.pointer):t.green(n.success),label:t.dim(e.label)};case`disabled`:return{glyph:e.isCursor?t.dim(n.pointer):unfocusedGlyph(e),label:disabledLabel(e.label,r,t,n)};case`locked`:return{glyph:t.dim(t.green(n.success)),label:t.dim(`${e.label}${parenthetical(r.reason)}`)}}return r}function renderCursorRow(e,t,n,r){return t?(r===`warning`?n.yellow:n.bold??(e=>e))(` ${e}`):` ${e}`}function renderOptionRowContinuation(e){return` ${e}`}function renderOptionRow(e){let{colors:t,glyphs:n}=e,{glyph:r,label:i}=optionRowPresentation(e),a=e.isCursor&&e.state.kind===`available`,o=e.hint;e.isCursor&&e.focusHint!==void 0&&(o=e.focusHint);let s=``;if(o!==void 0){let r=Math.max(0,(e.hintPadding??0)+1);s=t.dim(`${` `.repeat(r)}${n.dot} ${o}`)}return`${renderCursorRow(`${r} ${i}`,a,t,e.accent)}${s}`}export{UNICODE_ROW_GLYPHS,renderCursorRow,renderOptionRow,renderOptionRowContinuation,resolveOptionRowState};
|
|
@@ -21,6 +21,8 @@ export interface PromptColors {
|
|
|
21
21
|
export interface PromptOption<T extends PromptValue> {
|
|
22
22
|
value: T;
|
|
23
23
|
label: string;
|
|
24
|
+
/** Additional searchable text that is never rendered in the menu. */
|
|
25
|
+
keywords?: readonly string[];
|
|
24
26
|
/** Completion action kept after searchable results instead of being filtered. */
|
|
25
27
|
trailingAction?: boolean;
|
|
26
28
|
/** Supporting copy; stacked prompts render newline-separated text on separate rows. */
|
|
@@ -2,4 +2,4 @@ import{UNICODE_ROW_GLYPHS,renderCursorRow,renderOptionRow,renderOptionRowContinu
|
|
|
2
2
|
`);return`${t.green(`│`)}\n${t.green(`●`)} ${n}\n`}function formatPromptCancellation(e,t){let n=e.replace(/\n/g,`
|
|
3
3
|
`);return`${t.red(`│`)}\n${t.red(`●`)} ${t.red(n)}\n`}function formatRailLine(e,t,n){if(e===``)return`${t.green(`│`)}\n`;let r=`${t.green(`│`)} `;return`${e.split(`
|
|
4
4
|
`).map(e=>e===``?t.green(`│`):wrapTextWithPrefix(n,e,r)).join(`
|
|
5
|
-
`)}\n`}function renderMultiselectPrompt(e){let t=railFor(e.state,e.colors),n=formatPromptHeader(e.state,e.message,{colors:e.colors,leadingRail:e.leadingRail}),r=new Set(e.selectedValues),i=e.options.some(e=>!e.disabled)?``:`\n${t}\n${t} ${e.colors.dim(`(no channels available to add)`)}`;switch(e.state){case`submit`:{let t=r.size===0?e.colors.dim(`(none selected)`):e.options.filter(e=>r.has(e.value)).map(e=>e.label).join(`, `);return formatPromptSubmission(e.state,e.message,t,{colors:e.colors,leadingRail:e.leadingRail})}case`cancel`:return`${n}${t} ${e.colors.strikethrough(e.colors.dim(`cancelled`))}\n${t}`;case`error`:{let r=renderMultiselectRows({...e,rail:t});return`${n.trim()}\n${t} ${r}${i}\n${cornerFor(e.state,e.colors)} ${e.colors.red(e.error??``)}\n`}case`initial`:case`active`:return`${n}${t} ${renderMultiselectRows({...e,rail:t})}${i}\n${cornerWithNote(cornerFor(e.state,e.colors),e.footerNote)}\n`}}function cornerWithNote(e,t){return t?`${e} ${t}`:e}function renderSelectPrompt(e){let t=railFor(e.state,e.colors),n=formatPromptHeader(e.state,e.message,{colors:e.colors,leadingRail:e.leadingRail}),r=e.options[e.cursor];switch(e.state){case`submit`:{let t=r?r.label:``;return formatPromptSubmission(e.state,e.message,t,{colors:e.colors,leadingRail:e.leadingRail})}case`cancel`:return`${n}${t} ${r?e.colors.strikethrough(e.colors.dim(r.label)):``}\n${t}`;case`initial`:case`active`:case`error`:{let r=labelColumnWidth(e.options);return`${n}${t} ${e.options.map((n,i)=>{let a=i===e.cursor;return`${optionRow(n,{colors:e.colors,isCursor:a,isChecked:!1,placeholder:!1,hintPadding:r-n.label.length})}${descriptionLine(n,a,t,e.colors)}`}).join(`\n${t} `)}\n${cornerWithNote(cornerFor(e.state,e.colors),e.footerNote)}\n`}}}function labelColumnWidth(e){return e.reduce((e,t)=>Math.max(e,t.label.length),0)}function optionRow(e,t){return renderOptionRow({colors:t.colors,glyphs:UNICODE_ROW_GLYPHS,label:e.label,hint:e.hint,focusHint:e.focusHint,accent:e.accent,isCursor:t.isCursor,state:resolveOptionRowState(e,t.isChecked),placeholder:t.placeholder,hintPadding:t.hintPadding})}function descriptionLine(e,t,n,r){return t&&e.description&&!e.disabled?`\n${n} ${renderOptionRowContinuation(r.dim(e.description))}`:``}function renderSubmitRow(e,t,n=`Submit`){let r=t.bold(n),i=e?`${UNICODE_ROW_GLYPHS.selectedPointer} ${r}`:` ${t.dim(r)}
|
|
5
|
+
`)}\n`}function renderMultiselectPrompt(e){let t=railFor(e.state,e.colors),n=formatPromptHeader(e.state,e.message,{colors:e.colors,leadingRail:e.leadingRail}),r=new Set(e.selectedValues),i=e.options.some(e=>!e.disabled)?``:`\n${t}\n${t} ${e.colors.dim(`(no channels available to add)`)}`;switch(e.state){case`submit`:{let t=r.size===0?e.colors.dim(`(none selected)`):e.options.filter(e=>r.has(e.value)).map(e=>e.label).join(`, `);return formatPromptSubmission(e.state,e.message,t,{colors:e.colors,leadingRail:e.leadingRail})}case`cancel`:return`${n}${t} ${e.colors.strikethrough(e.colors.dim(`cancelled`))}\n${t}`;case`error`:{let r=renderMultiselectRows({...e,rail:t});return`${n.trim()}\n${t} ${r}${i}\n${cornerFor(e.state,e.colors)} ${e.colors.red(e.error??``)}\n`}case`initial`:case`active`:return`${n}${t} ${renderMultiselectRows({...e,rail:t})}${i}\n${cornerWithNote(cornerFor(e.state,e.colors),e.footerNote)}\n`}}function cornerWithNote(e,t){return t?`${e} ${t}`:e}function renderSelectPrompt(e){let t=railFor(e.state,e.colors),n=formatPromptHeader(e.state,e.message,{colors:e.colors,leadingRail:e.leadingRail}),r=e.options[e.cursor];switch(e.state){case`submit`:{let t=r?r.label:``;return formatPromptSubmission(e.state,e.message,t,{colors:e.colors,leadingRail:e.leadingRail})}case`cancel`:return`${n}${t} ${r?e.colors.strikethrough(e.colors.dim(r.label)):``}\n${t}`;case`initial`:case`active`:case`error`:{let r=labelColumnWidth(e.options);return`${n}${t} ${e.options.map((n,i)=>{let a=i===e.cursor;return`${optionRow(n,{colors:e.colors,isCursor:a,isChecked:!1,placeholder:!1,hintPadding:r-n.label.length})}${descriptionLine(n,a,t,e.colors)}`}).join(`\n${t} `)}\n${cornerWithNote(cornerFor(e.state,e.colors),e.footerNote)}\n`}}}function labelColumnWidth(e){return e.reduce((e,t)=>Math.max(e,t.label.length),0)}function optionRow(e,t){return renderOptionRow({colors:t.colors,glyphs:UNICODE_ROW_GLYPHS,label:e.label,hint:e.hint,focusHint:e.focusHint,accent:e.accent,isCursor:t.isCursor,state:resolveOptionRowState(e,t.isChecked),placeholder:t.placeholder,hintPadding:t.hintPadding})}function descriptionLine(e,t,n,r){return t&&e.description&&!e.disabled?`\n${n} ${renderOptionRowContinuation(r.dim(e.description))}`:``}function renderSubmitRow(e,t,n=`Submit`){let r=t.bold(n),i=e?`${UNICODE_ROW_GLYPHS.selectedPointer} ${r}`:` ${t.dim(r)}`;return`${renderCursorRow(i,e,t)} ${t.green(UNICODE_ROW_GLYPHS.success)}`}function renderMultiselectRows(e){let t=new Set(e.selectedValues),n=labelColumnWidth(e.options),r=e.options.map((r,i)=>{let a=i===e.cursor;return`${optionRow(r,{colors:e.colors,isCursor:a,isChecked:t.has(r.value),placeholder:!0,hintPadding:n-r.label.length})}${descriptionLine(r,a,e.rail,e.colors)}`}).join(`\n${e.rail} `),i=renderSubmitRow(e.cursor===e.options.length,e.colors,e.submitLabel);return`${r}\n${e.rail}\n${e.rail} ${i}`}function searchableHelpLine(e,t,n){let r=(n?[[t.cyan(`type`),`to filter`]]:[[t.cyan(`type`),`to filter`],[t.cyan(`enter`),`to select`]]).map(([e,n])=>`${e}${t.dim(` ${n}`)}`).join(t.dim(` · `));return`\n${e} ${t.dim(`(`)}${r}${t.dim(`)`)}`}function renderSearchableSelect(e){let{colors:t}=e,n=railFor(e.state,t),r=formatPromptHeader(e.state,e.message,{colors:t,leadingRail:e.leadingRail});if(e.state===`submit`)return formatPromptSubmission(e.state,e.message,e.submitDisplay,{colors:t,leadingRail:e.leadingRail});if(e.state===`cancel`)return`${r}${n} ${t.strikethrough(t.dim(e.filter))}${e.filter.trim()?`\n${n}`:``}`;let i=new Set(e.selectedValues),a=0;for(;e.options[a]?.featured;)a+=1;let o=e.viewSize??8,s=e.filter===``&&a>0?Math.min(a,o):o,c=e.multiple&&e.cursor>=e.options.length,l=!c&&e.cursor>=e.options.length?0:e.cursor,u=t.inverse(` `);e.filter.length>0?u=e.filter+t.inverse(` `):e.placeholder&&(u=t.dim(e.placeholder));let d=Math.max(0,Math.min(l-Math.floor(s/2),Math.max(0,e.options.length-s))),f=Math.min(d+s,e.options.length),p=e.options.slice(d,f),m=labelColumnWidth(p),h=p.length===0?t.dim(`(no matches)`):p.map((r,a)=>{let o=!c&&a+d===l;return`${optionRow(r,{colors:t,isCursor:o,isChecked:e.multiple&&i.has(r.value),placeholder:!1,hintPadding:m-r.label.length})}${descriptionLine(r,o,n,t)}`}).join(`\n${n} `),g=e.multiple?`\n${n}\n${n} ${renderSubmitRow(c,t,e.submitLabel)}`:``,_=e.options.length>p.length?`\n${n} ${t.dim(`↑↓ ${e.options.length} options, showing ${d+1}–${f}`)}`:``,v=searchableHelpLine(n,t,e.multiple),y=`${n} ${t.dim(` `)} ${u}\n${n} ${h}${g}${_}${v}`;return e.state===`error`?`${r.trim()}\n${y}\n${cornerFor(e.state,t)} ${t.red(e.error??``)}\n`:`${r}${y}\n${cornerWithNote(cornerFor(e.state,t),e.footerNote)}\n`}export{CORNER,RAIL,bulletFor,cornerFor,formatPromptCancellation,formatPromptHeader,formatPromptOpener,formatPromptOutro,formatPromptSubmission,formatRailLine,railFor,renderMultiselectPrompt,renderSearchableSelect,renderSelectPrompt,renderSubmitRow};
|
|
@@ -49,7 +49,7 @@ export interface SelectContext {
|
|
|
49
49
|
/** Cursor index of the virtual Submit row: one past the visible options. */
|
|
50
50
|
export declare function submitRowIndex(visible: readonly PromptOption<string>[]): number;
|
|
51
51
|
/**
|
|
52
|
-
* Case-insensitive substring match across an option's label, value, and
|
|
52
|
+
* Case-insensitive substring match across an option's label, value, hints, and keywords.
|
|
53
53
|
* An empty query returns every option, so the cursor can always scroll the
|
|
54
54
|
* full list; `featured` only shapes the searchable picker's default viewport,
|
|
55
55
|
* not which rows exist.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{previousGraphemeBoundary}from"#shared/text-boundaries.js";const SEARCH_ACTION_PREFIX=`\0search-action:`;function searchActionValue(e){return`${SEARCH_ACTION_PREFIX}${e}`}function searchActionQuery(e){return e.startsWith(SEARCH_ACTION_PREFIX)?e.slice(15):void 0}function submitRowIndex(e){return e.length}function filterOptions(e,t,n){let r=t.trim();if(r===``)return[...e];let i=r.toLowerCase(),a=e.filter(e=>e.trailingAction!==!0&&(e.label.toLowerCase().includes(i)||e.value.toLowerCase().includes(i)||(e.hint?.toLowerCase().includes(i)??!1)||(e.focusHint?.toLowerCase().includes(i)??!1)));return n!==void 0&&a.push({value:searchActionValue(r),label:n.label(r)}),[...a,...e.filter(e=>e.trailingAction===!0)]}function isFocusable(e){return!e.disabled&&!e.locked}function isActionable(e){return isFocusable(e)&&!e.completed}function firstFocusableIndex(e,t){let n=e.findIndex(isFocusable);return n>=0?n:t?submitRowIndex(e):0}function stepCursor(e,t,n,r){let i=e.length+ +!!r;if(i===0)return t;let a=t;for(let t=0;t<i;t+=1){if(a=(a+n+i)%i,r&&a===submitRowIndex(e))return a;let t=e[a];if(t&&isFocusable(t))return a}return t}function reduceSelect(e,t,n){let r=n.submitRow===!0;switch(t.type){case`char`:{let i=e.filter+t.char;return{...e,filter:i,cursor:firstFocusableIndex(filterOptions(n.options,i,n.searchAction),r)}}case`backspace`:{if(e.filter.length===0)return e;let t=e.filter.slice(0,previousGraphemeBoundary(e.filter,e.filter.length));return{...e,filter:t,cursor:firstFocusableIndex(filterOptions(n.options,t,n.searchAction),r)}}case`clear`:return e.filter.length===0?e:{...e,filter:``,cursor:firstFocusableIndex(filterOptions(n.options,``,n.searchAction),r)};case`up`:case`down`:{let i=filterOptions(n.options,e.filter,n.searchAction),a=t.type===`up`?-1:1,o=stepCursor(i,e.cursor,a,r);return o===e.cursor?e:{...e,cursor:o}}case`toggle`:{let t=filterOptions(n.options,e.filter,n.searchAction)[e.cursor];if(t===void 0||!isActionable(t))return e;let r=new Set(e.selected);return r.has(t.value)?r.delete(t.value):r.add(t.value),{...e,selected:r}}}}function initialSelectState(e){let t=e.filter??``,n=filterOptions(e.options,t,e.searchAction),r=firstFocusableIndex(n,e.submitRow===!0);if(e.defaultValue!==void 0){let t=n.findIndex(t=>isFocusable(t)&&t.value===e.defaultValue);t>=0&&(r=t)}let i=e.options.filter(e=>e.locked).map(e=>e.value);return{filter:t,cursor:r,selected:new Set([...e.initialValues??[],...i])}}function selectValueAtCursor(e,t){let n=e[t];return n&&isActionable(n)?n.value:void 0}function orderedSelection(e,t){return e.filter(e=>t.has(e.value)).map(e=>e.value)}export{filterOptions,initialSelectState,orderedSelection,reduceSelect,searchActionQuery,searchActionValue,selectValueAtCursor,submitRowIndex};
|
|
1
|
+
import{previousGraphemeBoundary}from"#shared/text-boundaries.js";const SEARCH_ACTION_PREFIX=`\0search-action:`;function searchActionValue(e){return`${SEARCH_ACTION_PREFIX}${e}`}function searchActionQuery(e){return e.startsWith(SEARCH_ACTION_PREFIX)?e.slice(15):void 0}function submitRowIndex(e){return e.length}function filterOptions(e,t,n){let r=t.trim();if(r===``)return[...e];let i=r.toLowerCase(),a=e.filter(e=>e.trailingAction!==!0&&(e.label.toLowerCase().includes(i)||e.value.toLowerCase().includes(i)||(e.hint?.toLowerCase().includes(i)??!1)||(e.focusHint?.toLowerCase().includes(i)??!1)||(e.keywords?.some(e=>e.toLowerCase().includes(i))??!1)));return n!==void 0&&a.push({value:searchActionValue(r),label:n.label(r)}),[...a,...e.filter(e=>e.trailingAction===!0)]}function isFocusable(e){return!e.disabled&&!e.locked}function isActionable(e){return isFocusable(e)&&!e.completed}function firstFocusableIndex(e,t){let n=e.findIndex(isFocusable);return n>=0?n:t?submitRowIndex(e):0}function stepCursor(e,t,n,r){let i=e.length+ +!!r;if(i===0)return t;let a=t;for(let t=0;t<i;t+=1){if(a=(a+n+i)%i,r&&a===submitRowIndex(e))return a;let t=e[a];if(t&&isFocusable(t))return a}return t}function reduceSelect(e,t,n){let r=n.submitRow===!0;switch(t.type){case`char`:{let i=e.filter+t.char;return{...e,filter:i,cursor:firstFocusableIndex(filterOptions(n.options,i,n.searchAction),r)}}case`backspace`:{if(e.filter.length===0)return e;let t=e.filter.slice(0,previousGraphemeBoundary(e.filter,e.filter.length));return{...e,filter:t,cursor:firstFocusableIndex(filterOptions(n.options,t,n.searchAction),r)}}case`clear`:return e.filter.length===0?e:{...e,filter:``,cursor:firstFocusableIndex(filterOptions(n.options,``,n.searchAction),r)};case`up`:case`down`:{let i=filterOptions(n.options,e.filter,n.searchAction),a=t.type===`up`?-1:1,o=stepCursor(i,e.cursor,a,r);return o===e.cursor?e:{...e,cursor:o}}case`toggle`:{let t=filterOptions(n.options,e.filter,n.searchAction)[e.cursor];if(t===void 0||!isActionable(t))return e;let r=new Set(e.selected);return r.has(t.value)?r.delete(t.value):r.add(t.value),{...e,selected:r}}}}function initialSelectState(e){let t=e.filter??``,n=filterOptions(e.options,t,e.searchAction),r=firstFocusableIndex(n,e.submitRow===!0);if(e.defaultValue!==void 0){let t=n.findIndex(t=>isFocusable(t)&&t.value===e.defaultValue);t>=0&&(r=t)}let i=e.options.filter(e=>e.locked).map(e=>e.value);return{filter:t,cursor:r,selected:new Set([...e.initialValues??[],...i])}}function selectValueAtCursor(e,t){let n=e[t];return n&&isActionable(n)?n.value:void 0}function orderedSelection(e,t){return e.filter(e=>t.has(e.value)).map(e=>e.value)}export{filterOptions,initialSelectState,orderedSelection,reduceSelect,searchActionQuery,searchActionValue,selectValueAtCursor,submitRowIndex};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash,randomBytes}from"node:crypto";import{isErrnoCode,isObject}from"#shared/guards.js";import{createServer}from"node:http";import{spawn}from"node:child_process";import{WizardCancelledError}from"#setup/step.js";import{createProcessOutputBuffer}from"#setup/primitives/process-output.js";import{setTimeout as setTimeout$1}from"node:timers/promises";import{getDefaultCodexTokenBroker}from"#public/models/openai/chatgpt/token-broker.js";import{ChatGptInvalidStoredSessionError,getDefaultChatGptCredentialStore}from"#public/models/openai/chatgpt/credential-store.js";import{CHATGPT_CLIENT_ID,CHATGPT_ISSUER,readChatGptAuthResponse,requestChatGptTokens}from"#public/models/openai/chatgpt/oauth.js";import{openUrl}from"#setup/primitives/open-url.js";const REDIRECT_URI=`http://localhost:1455/auth/callback`;async function ensureChatGptAuth(e={}){let t=e.broker??getDefaultCodexTokenBroker(),n=e.store??getDefaultChatGptCredentialStore();e.signal?.throwIfAborted();let r=await t.refreshState();if(r.kind===`ready`)return;let i=t.credentialOwner();if(i===void 0)throw Error(`ChatGPT credential owner could not be resolved.`);if(i===`codex`){if(r.kind===`unavailable`)throw Error(r.reason);try{let n=e.log??(e=>process.stdout.write(`${e}\n`));await(e.codexLogin??(e=>loginWithCodex(e,n)))(e.signal),await assertChatGptAuthReady(t,`Codex login completed without a usable ChatGPT session.`);return}catch(e){if(!isErrnoCode(e,`ENOENT`))throw e;let n=await t.refreshState();if(t.credentialOwner()!==`eve`)throw e;if(n.kind===`ready`)return;if(n.kind===`unavailable`)throw Error(n.reason)}}try{await n.read()}catch(e){if(!(e instanceof ChatGptInvalidStoredSessionError))throw e}await signInWithOwnedCredentials(e,t,n)}async function signInWithOwnedCredentials(e,t,n){let r=new AbortController,cancel=()=>r.abort(new WizardCancelledError);process.once(`SIGINT`,cancel);let i=setTimeout(()=>r.abort(Error(`ChatGPT sign-in timed out. Retry from /model.`)),3e5),a=AbortSignal.any([r.signal,...e.signal?[e.signal]:[]]),o=e.log??(e=>process.stdout.write(`${e}\n`)),s=e.open??openUrl;try{let r=e.headless??!!(process.env.SSH_CONNECTION||process.env.SSH_TTY)?await deviceLogin({...e,signal:a,log:o,open:s}):await browserLogin({...e,signal:a,log:o,open:s});a.throwIfAborted(),await n.update(async()=>(a.throwIfAborted(),r),{replace:!0}),await assertChatGptAuthReady(t,`ChatGPT sign-in could not be verified. Retry from /model.`)
|
|
1
|
+
import{createHash,randomBytes}from"node:crypto";import{isErrnoCode,isObject}from"#shared/guards.js";import{createServer}from"node:http";import{spawn}from"node:child_process";import{WizardCancelledError}from"#setup/step.js";import{createProcessOutputBuffer}from"#setup/primitives/process-output.js";import{setTimeout as setTimeout$1}from"node:timers/promises";import{getDefaultCodexTokenBroker}from"#public/models/openai/chatgpt/token-broker.js";import{ChatGptInvalidStoredSessionError,getDefaultChatGptCredentialStore}from"#public/models/openai/chatgpt/credential-store.js";import{CHATGPT_CLIENT_ID,CHATGPT_ISSUER,readChatGptAuthResponse,requestChatGptTokens}from"#public/models/openai/chatgpt/oauth.js";import{openUrl}from"#setup/primitives/open-url.js";const REDIRECT_URI=`http://localhost:1455/auth/callback`;async function ensureChatGptAuth(e={}){let t=e.broker??getDefaultCodexTokenBroker(),n=e.store??getDefaultChatGptCredentialStore();e.signal?.throwIfAborted();let r=await t.refreshState();if(r.kind===`ready`)return;let i=t.credentialOwner();if(i===void 0)throw Error(`ChatGPT credential owner could not be resolved.`);if(i===`codex`){if(r.kind===`unavailable`)throw Error(r.reason);try{let n=e.log??(e=>process.stdout.write(`${e}\n`));await(e.codexLogin??(e=>loginWithCodex(e,n)))(e.signal),await assertChatGptAuthReady(t,`Codex login completed without a usable ChatGPT session.`);return}catch(e){if(!isErrnoCode(e,`ENOENT`))throw e;let n=await t.refreshState();if(t.credentialOwner()!==`eve`)throw e;if(n.kind===`ready`)return;if(n.kind===`unavailable`)throw Error(n.reason)}}try{await n.read()}catch(e){if(!(e instanceof ChatGptInvalidStoredSessionError))throw e}await signInWithOwnedCredentials(e,t,n)}async function signInWithOwnedCredentials(e,t,n){let r=new AbortController,cancel=()=>r.abort(new WizardCancelledError);process.once(`SIGINT`,cancel);let i=setTimeout(()=>r.abort(Error(`ChatGPT sign-in timed out. Retry from /model.`)),3e5),a=AbortSignal.any([r.signal,...e.signal?[e.signal]:[]]),o=e.log??(e=>process.stdout.write(`${e}\n`)),s=e.open??openUrl;try{let r=e.headless??!!(process.env.SSH_CONNECTION||process.env.SSH_TTY)?await deviceLogin({...e,signal:a,log:o,open:s}):await browserLogin({...e,signal:a,log:o,open:s});a.throwIfAborted(),await n.update(async()=>(a.throwIfAborted(),r),{replace:!0}),await assertChatGptAuthReady(t,`ChatGPT sign-in could not be verified. Retry from /model.`)}catch(e){throw a.throwIfAborted(),e}finally{clearTimeout(i),process.removeListener(`SIGINT`,cancel)}}async function assertChatGptAuthReady(e,t){if((await e.refreshState()).kind!==`ready`)throw Error(t)}async function loginWithCodex(e,t){let n=spawn(`codex`,[`login`],{stdio:[`ignore`,`pipe`,`pipe`],...e!==void 0&&{signal:e}}),r=createProcessOutputBuffer(({text:e})=>t(e));n.stdout.on(`data`,e=>r.write(`stdout`,e)),n.stderr.on(`data`,e=>r.write(`stderr`,e));try{await new Promise((e,t)=>{n.once(`error`,t),n.once(`close`,(n,r)=>{n===0?e():t(Error(`codex login failed (${r??n??`unknown`}).`))})})}finally{r.flush()}}async function browserLogin(e){let t=randomBytes(32).toString(`base64url`),n=randomBytes(32).toString(`base64url`),r=new URL(`${CHATGPT_ISSUER}/oauth/authorize`);r.search=new URLSearchParams({response_type:`code`,client_id:CHATGPT_CLIENT_ID,redirect_uri:REDIRECT_URI,scope:`openid profile email offline_access`,code_challenge:createHash(`sha256`).update(t).digest(`base64url`),code_challenge_method:`S256`,id_token_add_organizations:`true`,codex_cli_simplified_flow:`true`,state:n,originator:`eve`}).toString();let i=Promise.withResolvers();i.promise.catch(()=>{});let a=createServer({requestTimeout:1e4,headersTimeout:1e4,maxHeaderSize:8192},(e,t)=>{let r=URL.parse(e.url??``,REDIRECT_URI);if(t.setHeader(`content-type`,`text/plain; charset=utf-8`),t.setHeader(`cache-control`,`no-store`),e.method!==`GET`||r?.pathname!==`/auth/callback`){t.writeHead(404).end(`Not found.`);return}if(r.searchParams.get(`state`)!==n){t.writeHead(400).end(`This sign-in belongs to another attempt. Return to eve and use its sign-in link.`);return}if(r.searchParams.has(`error`)){t.writeHead(400).end(`ChatGPT sign-in was declined. Return to eve to retry.`),i.reject(Error(`ChatGPT sign-in was declined. Retry from /model.`));return}let a=r.searchParams.get(`code`);if(!a){t.writeHead(400).end(`Missing authorization code.`);return}t.end(`Authorization received. Return to eve to finish connecting your ChatGPT subscription.`),i.resolve(a)});a.maxConnections=10;let abort=()=>i.reject(e.signal.reason);e.signal.addEventListener(`abort`,abort,{once:!0});try{e.signal.throwIfAborted();try{await new Promise((e,t)=>{a.once(`error`,t),a.listen(1455,`127.0.0.1`,e)})}catch(t){if(!isErrnoCode(t,`EADDRINUSE`))throw Error(`Could not start ChatGPT sign-in on localhost:1455. Free the port and retry from /model.`);return e.log(`Local sign-in port is in use. Continuing with a device code.`),await deviceLogin(e)}e.signal.throwIfAborted(),e.log(`Sign in to ChatGPT in your browser:\n${r.href}\nWaiting for sign-in. Press Ctrl+C to cancel.`),e.open(r.href);let n=await i.promise;return await requestChatGptTokens({grant_type:`authorization_code`,code:n,code_verifier:t,redirect_uri:REDIRECT_URI},e)}finally{e.signal.removeEventListener(`abort`,abort),a.closeAllConnections(),await new Promise(e=>a.close(()=>e()))}}async function deviceLogin(e){let t=await deviceRequest(`usercode`,{client_id:CHATGPT_CLIENT_ID},e);if(!t.ok)throw Error(`ChatGPT device sign-in is unavailable (HTTP ${t.status}). Enable device code authorization in ChatGPT Settings > Security, then retry from /model.`);let n=await readChatGptAuthResponse(t);if(!isObject(n)||typeof n.device_auth_id!=`string`||!n.device_auth_id||typeof n.user_code!=`string`||!/^[A-Z0-9-]{4,32}$/iu.test(n.user_code))throw Error(`ChatGPT returned an invalid device code. Retry from /model.`);let r=Math.min(30,Math.max(1,Number(n.interval)||5))*1e3,i=`${CHATGPT_ISSUER}/codex/device`;for(e.log(`Open ${i} and enter code: ${n.user_code}\nIf prompted, enable device code authorization in ChatGPT Settings > Security.\nWaiting for sign-in. Press Ctrl+C to cancel.`),e.open(i);;){await setTimeout$1(r+1e3,void 0,{signal:e.signal});let t=await deviceRequest(`token`,{device_auth_id:n.device_auth_id,user_code:n.user_code},e);if(t.status===403||t.status===404)continue;if(!t.ok)throw Error(`ChatGPT device sign-in failed (HTTP ${t.status}). Retry from /model.`);let i=await readChatGptAuthResponse(t);if(!isObject(i)||typeof i.authorization_code!=`string`||!i.authorization_code||typeof i.code_verifier!=`string`||!i.code_verifier)throw Error(`ChatGPT returned an invalid device authorization. Retry from /model.`);return requestChatGptTokens({grant_type:`authorization_code`,code:i.authorization_code,code_verifier:i.code_verifier,redirect_uri:`${CHATGPT_ISSUER}/deviceauth/callback`},e)}}async function deviceRequest(e,t,n){try{return await(n.fetch??fetch)(`${CHATGPT_ISSUER}/api/accounts/deviceauth/${e}`,{method:`POST`,headers:{"content-type":`application/json`,"user-agent":`eve`},body:JSON.stringify(t),redirect:`error`,signal:AbortSignal.any([n.signal,AbortSignal.timeout(3e4)])})}catch{throw n.signal.throwIfAborted(),Error(`Could not reach ChatGPT device sign-in. Check your connection and retry from /model.`)}}export{ensureChatGptAuth};
|
|
@@ -4,12 +4,14 @@ import { type LinkProjectDeps } from "../boxes/link-project.js";
|
|
|
4
4
|
import { type ResolveProvisioningDeps } from "../boxes/resolve-provisioning.js";
|
|
5
5
|
import { detectDeployment } from "../project-resolution.js";
|
|
6
6
|
import type { Prompter } from "../prompter.js";
|
|
7
|
+
import { runInstallVercelCliFlow } from "./install-vercel-cli.js";
|
|
7
8
|
import { runLoginFlow } from "./login.js";
|
|
8
9
|
/** Injected for tests; defaults to the real detection and box effects. */
|
|
9
10
|
export interface DeployFlowDeps {
|
|
10
11
|
detectDeployment: typeof detectDeployment;
|
|
11
12
|
inspectApplication: typeof inspectApplication;
|
|
12
13
|
runLoginFlow: typeof runLoginFlow;
|
|
14
|
+
runInstallVercelCliFlow: typeof runInstallVercelCliFlow;
|
|
13
15
|
resolveProvisioning?: ResolveProvisioningDeps;
|
|
14
16
|
linkProject?: LinkProjectDeps;
|
|
15
17
|
deployProject?: DeployProjectDeps;
|
|
@@ -27,15 +29,8 @@ export type DeployFlowResult = {
|
|
|
27
29
|
kind: "needs-link";
|
|
28
30
|
};
|
|
29
31
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* decision time, never trusted from an earlier render. An already-linked
|
|
33
|
-
* project goes straight to the deploy box; an unlinked one walks the same
|
|
34
|
-
* login and team/project flow as onboarding (resolve-provisioning with the
|
|
35
|
-
* deploy gate pre-answered — invoking deploy IS the deploy decision), then
|
|
36
|
-
* links non-interactively so the deploy box never hits its bare-`vercel link`
|
|
37
|
-
* fallback. A non-interactive run with no link refuses with `needs-link`
|
|
38
|
-
* before any side effect.
|
|
32
|
+
* Interactive deployment prepares CLI access before linking or deploying.
|
|
33
|
+
* Noninteractive deployment never installs tools or starts browser login.
|
|
39
34
|
*/
|
|
40
35
|
export declare function runDeployFlow(input: {
|
|
41
36
|
appRoot: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{interactiveAsker,withAnswers}from"../ask.js";import{detectDeployment,isProjectResolved,projectResolutionFromDeployment}from"../project-resolution.js";import{withSpinner}from"../with-spinner.js";import{snapshotSetupState}from"../state.js";import{deployProject}from"../boxes/deploy-project.js";import{linkVercelProject}from"../boxes/link-project.js";import{resolveProvisioning}from"../boxes/resolve-provisioning.js";import{runHeadless,runInteractive}from"../runner.js";import{inProjectSetupState,prompterSink}from"./in-project.js";import{runLoginFlow}from"./login.js";import{inspectApplication}from"#services/inspect-application.js";import{isChatGptModelRouting}from"#shared/chatgpt-model.js";function productionUrlOf(e){return e.kind===`deployed`?e.productionUrl:void 0}async function runDeployFlow(e){let{appRoot:t,prompter:n,interactive:r,signal:i}=e,a={detectDeployment,inspectApplication,runLoginFlow,...e.deps};try{let e=(await a.inspectApplication(t)).compiledState?.manifest.config.model?.routing;if(isChatGptModelRouting(e))return{kind:`local-model`}}catch{}let o=await withSpinner(n,`Checking the current Vercel link...`,async()=>{let e=await a.detectDeployment(t,{signal:i});return i?.throwIfAborted(),projectResolutionFromDeployment(e)}),s=isProjectResolved(o);if(!s&&!r)return{kind:`needs-link`};if(
|
|
1
|
+
import{interactiveAsker,withAnswers}from"../ask.js";import{detectDeployment,isProjectResolved,projectResolutionFromDeployment}from"../project-resolution.js";import{withSpinner}from"../with-spinner.js";import{snapshotSetupState}from"../state.js";import{deployProject}from"../boxes/deploy-project.js";import{linkVercelProject}from"../boxes/link-project.js";import{resolveProvisioning}from"../boxes/resolve-provisioning.js";import{runHeadless,runInteractive}from"../runner.js";import{inProjectSetupState,prompterSink}from"./in-project.js";import{runInstallVercelCliFlow}from"./install-vercel-cli.js";import{runLoginFlow}from"./login.js";import{inspectApplication}from"#services/inspect-application.js";import{isChatGptModelRouting}from"#shared/chatgpt-model.js";function productionUrlOf(e){return e.kind===`deployed`?e.productionUrl:void 0}async function runDeployFlow(e){let{appRoot:t,prompter:n,interactive:r,signal:i}=e,a={detectDeployment,inspectApplication,runLoginFlow,runInstallVercelCliFlow,...e.deps};try{let e=(await a.inspectApplication(t)).compiledState?.manifest.config.model?.routing;if(isChatGptModelRouting(e))return{kind:`local-model`}}catch{}let o=await withSpinner(n,`Checking the current Vercel link...`,async()=>{let e=await a.detectDeployment(t,{signal:i});return i?.throwIfAborted(),projectResolutionFromDeployment(e)}),s=isProjectResolved(o);if(!s&&!r)return{kind:`needs-link`};if(r){let e=await a.runLoginFlow({appRoot:t,prompter:n,signal:i});if(e.kind===`cli-missing`){let r=await a.runInstallVercelCliFlow({appRoot:t,prompter:n,signal:i});if(r.kind===`cancelled`)return{kind:`cancelled`};if(r.kind===`failed`)throw Error("Could not install the Vercel CLI. Install it with `npm i -g vercel@latest`, then retry deployment.");e=await a.runLoginFlow({appRoot:t,prompter:n,signal:i})}if(e.kind===`cancelled`)return{kind:`cancelled`};if(e.kind!==`already`&&e.kind!==`logged-in`)throw Error(e.kind===`unavailable`?`Could not reach Vercel. Check your connection and retry deployment.`:`Vercel login did not complete. Retry deployment to sign in.`)}let c=inProjectSetupState(t,o,{deploymentPending:!0}),l=s?[deployProject({prompter:n,headless:!r,deps:a.deployProject})]:[resolveProvisioning({asker:withAnswers({deploy:`vercel`})(interactiveAsker(n)),prompter:n,targetDirectory:t,mode:{headless:!1},deps:a.resolveProvisioning}),linkVercelProject({prompter:n,deps:a.linkProject}),deployProject({prompter:n,headless:!r,deps:a.deployProject})],u=prompterSink(n);if(!r)return{kind:`deployed`,productionUrl:productionUrlOf((await runHeadless(l,c,u,{snapshot:snapshotSetupState,signal:i})).project)};let d=await runInteractive(l,c,u,{snapshot:snapshotSetupState,signal:i});return d.kind===`cancelled`?{kind:`cancelled`}:{kind:`deployed`,productionUrl:productionUrlOf(d.state.project)}}export{runDeployFlow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{interactiveAsker,withAnswers}from"../ask.js";import{readProjectLink}from"../project-resolution.js";import{snapshotSetupState}from"../state.js";import{requireAuth}from"../vercel-project.js";import{linkVercelProject}from"../boxes/link-project.js";import{resolveProvisioning}from"../boxes/resolve-provisioning.js";import{WizardCancelledError}from"../step.js";import{runInteractive}from"../runner.js";import{inProjectSetupState,prompterSink}from"./in-project.js";import{runLoginFlow}from"./login.js";async function ensureVercelProject(e){let t=e.deps?.readProjectLink??readProjectLink,n=await(e.deps?.runLoginFlow??runLoginFlow)({appRoot:e.appRoot,prompter:e.prompter,signal:e.signal});if(n.kind===`cancelled`)throw new WizardCancelledError;n.kind!==`already`&&n.kind!==`logged-in`&&await(e.deps?.requireAuth??requireAuth)(e.appRoot,e.prompter,{signal:e.signal});let r=await t(e.appRoot);if(r!==void 0)return r;let i=inProjectSetupState(e.appRoot,{kind:`unresolved`}),a=[resolveProvisioning({asker:withAnswers({deploy:`vercel`})(interactiveAsker(e.prompter)),prompter:e.prompter,targetDirectory:e.appRoot,mode:{headless:!1},adoptExistingLink:!1,projectSelection:`create-or-link`,teamSelectMessage:e.teamSelectMessage,deps:e.deps?.resolveProvisioning}),linkVercelProject({prompter:e.prompter,deps:e.deps?.linkProject})];if((await runInteractive(a,i,prompterSink(e.prompter),{snapshot:snapshotSetupState,signal:e.signal})).kind===`cancelled`)throw e.signal?.throwIfAborted(),new WizardCancelledError;let o=await t(e.appRoot);if(o===void 0)throw Error(`Vercel project linking failed.`);return o}export{ensureVercelProject};
|
|
1
|
+
import{interactiveAsker,withAnswers}from"../ask.js";import{readProjectLink}from"../project-resolution.js";import{snapshotSetupState}from"../state.js";import{requireAuth}from"../vercel-project.js";import{linkVercelProject}from"../boxes/link-project.js";import{resolveProvisioning}from"../boxes/resolve-provisioning.js";import{WizardCancelledError}from"../step.js";import{runInteractive}from"../runner.js";import{inProjectSetupState,prompterSink}from"./in-project.js";import{runLoginFlow}from"./login.js";async function ensureVercelProject(e){let t=e.deps?.readProjectLink??readProjectLink,n=await(e.deps?.runLoginFlow??runLoginFlow)({appRoot:e.appRoot,prompter:e.prompter,signal:e.signal,allowLogin:!1});if(n.kind===`cancelled`)throw new WizardCancelledError;n.kind!==`already`&&n.kind!==`logged-in`&&await(e.deps?.requireAuth??requireAuth)(e.appRoot,e.prompter,{signal:e.signal});let r=await t(e.appRoot);if(r!==void 0)return r;let i=inProjectSetupState(e.appRoot,{kind:`unresolved`}),a=[resolveProvisioning({asker:withAnswers({deploy:`vercel`})(interactiveAsker(e.prompter)),prompter:e.prompter,targetDirectory:e.appRoot,mode:{headless:!1},adoptExistingLink:!1,projectSelection:`create-or-link`,teamSelectMessage:e.teamSelectMessage,deps:e.deps?.resolveProvisioning}),linkVercelProject({prompter:e.prompter,deps:e.deps?.linkProject})];if((await runInteractive(a,i,prompterSink(e.prompter),{snapshot:snapshotSetupState,signal:e.signal})).kind===`cancelled`)throw e.signal?.throwIfAborted(),new WizardCancelledError;let o=await t(e.appRoot);if(o===void 0)throw Error(`Vercel project linking failed.`);return o}export{ensureVercelProject};
|
|
@@ -28,9 +28,8 @@ export interface InstallVercelCliDeps {
|
|
|
28
28
|
spawnPackageManager: typeof spawnPackageManager;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* command. Short-circuits when the CLI already resolves; otherwise runs a
|
|
31
|
+
* Prepares the Vercel CLI during deployment. Short-circuits when the CLI
|
|
32
|
+
* already resolves; otherwise runs a
|
|
34
33
|
* global install with the project's package manager, streaming output to the
|
|
35
34
|
* rail, then re-probes. A global install can exit clean yet leave the binary
|
|
36
35
|
* off PATH (pnpm/yarn global bins commonly aren't), so success is confirmed by
|
|
@@ -36,7 +36,7 @@ export interface LoginFlowDeps {
|
|
|
36
36
|
}) => Promise<boolean>;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* THE LOGIN FLOW for the dev TUI's `/
|
|
39
|
+
* THE LOGIN FLOW for the dev TUI's `/deploy`. Short-circuits when already
|
|
40
40
|
* authenticated; otherwise runs `vercel login` as a browser flow the TUI waits
|
|
41
41
|
* on (see {@link runVercelLoginWithControls}) and re-probes after, so a
|
|
42
42
|
* half-finished or abandoned login reports `failed`, never a false success.
|
|
@@ -46,6 +46,8 @@ export declare function runLoginFlow(input: {
|
|
|
46
46
|
prompter: Prompter;
|
|
47
47
|
/** Run the browser login even when the account-level Vercel session is valid. */
|
|
48
48
|
force?: boolean;
|
|
49
|
+
/** False for remote access: reuse the existing session without opening a browser. */
|
|
50
|
+
allowLogin?: boolean;
|
|
49
51
|
signal?: AbortSignal;
|
|
50
52
|
deps?: Partial<LoginFlowDeps>;
|
|
51
53
|
}): Promise<LoginFlowResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{withSpinner}from"../with-spinner.js";import{runVercel}from"#setup/primitives/run-vercel.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{createPromptCommandOutput}from"#setup/cli/index.js";function vercelLoginUrl(e){return e.match(/https:\/\/vercel\.com\/oauth\/device\?[^\s]+/u)?.[0]}const defaultDeps={getVercelAuthStatus,runVercelLogin:({cwd:e,onOutput:t,signal:n})=>runVercel([`login`],{cwd:e,nonInteractive:!0,onOutput:t,timeoutMs:3e5,signal:n})};async function runVercelLoginWithControls(e,t,n,r,i){if(r.awaitChoice===void 0)return withSpinner(r,`Opening Vercel login in your browser…`,()=>e.runVercelLogin({cwd:t,onOutput:n,signal:i}));let a=new AbortController,o=i?AbortSignal.any([i,a.signal]):a.signal,s=r.awaitChoice({status:`Logging in to Vercel…`,context:`Complete the login in your browser`,actions:[{value:`cancel`,label:`Cancel`}]}),c=e.runVercelLogin({cwd:t,onOutput:n,signal:o});try{let e=await Promise.race([c.then(e=>({via:`work`,ok:e})),s.choice.then(()=>({via:`choice`}))]);return e.via===`work`?e.ok:(a.abort(),await c.catch(()=>{}),`cancelled`)}finally{s.close()}}async function runLoginFlow(e){let{appRoot:t,prompter:n,signal:r}=e,i={...defaultDeps,...e.deps},a=createPromptCommandOutput(n.log),o,onOutput=e=>{a(e);let t=vercelLoginUrl(e.text);t!==void 0&&t!==o&&(o=t,n.log.info(`Open ${t}`))},probeAuth=()=>i.getVercelAuthStatus(t,{signal:r}),s=await withSpinner(n,`Checking your Vercel login…`,probeAuth);switch(r?.throwIfAborted(),s){case`authenticated`:if(e.force!==!0)return{kind:`already`};break;case`cli-missing`:return{kind:`cli-missing`};case`unavailable`:return{kind:`unavailable`};case`logged-out`:break;default:return s}let c=await runVercelLoginWithControls(i,t,onOutput,n,r);if(c===`cancelled`)return{kind:`cancelled`};if(!c)return{kind:`failed`};let l=await withSpinner(n,`Confirming your Vercel login…`,probeAuth);switch(r?.throwIfAborted(),l){case`authenticated`:return{kind:`logged-in`};case`logged-out`:return{kind:`failed`};case`cli-missing`:return{kind:`cli-missing`};case`unavailable`:return{kind:`unavailable`};default:return l}}export{runLoginFlow};
|
|
1
|
+
import{withSpinner}from"../with-spinner.js";import{runVercel}from"#setup/primitives/run-vercel.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{createPromptCommandOutput}from"#setup/cli/index.js";function vercelLoginUrl(e){return e.match(/https:\/\/vercel\.com\/oauth\/device\?[^\s]+/u)?.[0]}const defaultDeps={getVercelAuthStatus,runVercelLogin:({cwd:e,onOutput:t,signal:n})=>runVercel([`login`],{cwd:e,nonInteractive:!0,onOutput:t,timeoutMs:3e5,signal:n})};async function runVercelLoginWithControls(e,t,n,r,i){if(r.awaitChoice===void 0)return withSpinner(r,`Opening Vercel login in your browser…`,()=>e.runVercelLogin({cwd:t,onOutput:n,signal:i}));let a=new AbortController,o=i?AbortSignal.any([i,a.signal]):a.signal,s=r.awaitChoice({status:`Logging in to Vercel…`,context:`Complete the login in your browser`,actions:[{value:`cancel`,label:`Cancel`}]}),c=e.runVercelLogin({cwd:t,onOutput:n,signal:o});try{let e=await Promise.race([c.then(e=>({via:`work`,ok:e})),s.choice.then(()=>({via:`choice`}))]);return e.via===`work`?e.ok:(a.abort(),await c.catch(()=>{}),`cancelled`)}finally{s.close()}}async function runLoginFlow(e){let{appRoot:t,prompter:n,signal:r}=e,i={...defaultDeps,...e.deps},a=createPromptCommandOutput(n.log),o,onOutput=e=>{a(e);let t=vercelLoginUrl(e.text);t!==void 0&&t!==o&&(o=t,n.log.info(`Open ${t}`))},probeAuth=()=>i.getVercelAuthStatus(t,{signal:r}),s=await withSpinner(n,`Checking your Vercel login…`,probeAuth);switch(r?.throwIfAborted(),s){case`authenticated`:if(e.force!==!0)return{kind:`already`};break;case`cli-missing`:return{kind:`cli-missing`};case`unavailable`:return{kind:`unavailable`};case`logged-out`:break;default:return s}if(e.allowLogin===!1)return{kind:`failed`};let c=await runVercelLoginWithControls(i,t,onOutput,n,r);if(c===`cancelled`)return{kind:`cancelled`};if(!c)return{kind:`failed`};let l=await withSpinner(n,`Confirming your Vercel login…`,probeAuth);switch(r?.throwIfAborted(),l){case`authenticated`:return{kind:`logged-in`};case`logged-out`:return{kind:`failed`};case`cli-missing`:return{kind:`cli-missing`};case`unavailable`:return{kind:`unavailable`};default:return l}}export{runLoginFlow};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ModelConnectionSelection } from "#internal/model-auth/store.js";
|
|
2
|
+
import type { Prompter } from "#setup/prompter.js";
|
|
3
|
+
export declare const CONNECTION_OPTIONS: readonly [{
|
|
4
|
+
readonly value: "vercel";
|
|
5
|
+
readonly label: "Vercel Account";
|
|
6
|
+
}, {
|
|
7
|
+
readonly value: "ai-gateway-key";
|
|
8
|
+
readonly label: "Vercel AI Gateway API Key";
|
|
9
|
+
}, {
|
|
10
|
+
readonly value: "chatgpt";
|
|
11
|
+
readonly label: "ChatGPT Subscription";
|
|
12
|
+
}, {
|
|
13
|
+
readonly value: "openai";
|
|
14
|
+
readonly label: "OpenAI API Key";
|
|
15
|
+
}, {
|
|
16
|
+
readonly value: "anthropic";
|
|
17
|
+
readonly label: "Anthropic API Key";
|
|
18
|
+
}];
|
|
19
|
+
type Team = {
|
|
20
|
+
teamId: string;
|
|
21
|
+
teamName: string;
|
|
22
|
+
};
|
|
23
|
+
/** Evidence from this login attempt; credentials stay with their existing owner. */
|
|
24
|
+
export interface ValidatedModelConnection {
|
|
25
|
+
selected: ModelConnectionSelection;
|
|
26
|
+
team?: Team;
|
|
27
|
+
availableModels?: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare function reuseModelConnection(selected: ModelConnectionSelection, team: Team | undefined, signal?: AbortSignal): Promise<ValidatedModelConnection | undefined>;
|
|
30
|
+
export declare function authenticateModelConnection(input: {
|
|
31
|
+
selected: ModelConnectionSelection;
|
|
32
|
+
team?: Team;
|
|
33
|
+
prompter: Prompter;
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
}): Promise<ValidatedModelConnection>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ensureChatGptAuth}from"./chatgpt-auth.js";import{withLoginProgress}from"./model-login-progress.js";import{loginVercelModel}from"./vercel-model-login.js";import{getVercelOidcToken}from"#compiled/@vercel/oidc/index.js";import{getDefaultCodexTokenBroker}from"#public/models/openai/chatgpt/token-broker.js";import{resolveModelApiKey}from"#internal/model-auth/transport.js";import{availableDirectModels}from"#internal/model-auth/available-models.js";import{modelKeySecretName,readVercelSession,writeModelSecret}from"#internal/model-auth/store.js";import{readVercelCliConnection,refreshVercelCliConnection}from"#internal/model-auth/vercel-cli.js";import{VERCEL_MODEL_CLIENT_ID,resolveVercelSession,validateVercelAccess}from"#internal/model-auth/vercel.js";import{validateGatewayApiKey}from"#setup/validate-gateway-key.js";const CONNECTION_OPTIONS=[{value:`vercel`,label:`Vercel Account`},{value:`ai-gateway-key`,label:`Vercel AI Gateway API Key`},{value:`chatgpt`,label:`ChatGPT Subscription`},{value:`openai`,label:`OpenAI API Key`},{value:`anthropic`,label:`Anthropic API Key`}];async function reuseModelConnection(e,t,n){switch(e){case`chatgpt`:return(await getDefaultCodexTokenBroker().refreshState()).kind===`ready`?{selected:e}:void 0;case`vercel`:{if(!await readVercelSession(VERCEL_MODEL_CLIENT_ID))return;let r=await resolveVercelSession();return t??={teamId:r.teamId,teamName:r.teamName},await validateVercelAccess(r.accessToken,t.teamId,n),{selected:e,team:t}}case`vercel-cli`:{let r=await readVercelCliConnection();if(!r)return;t??={teamId:r.teamId,teamName:r.teamId};try{await validateVercelAccess(r.token,t.teamId,n)}catch{if(n?.throwIfAborted(),await refreshVercelCliConnection(),r=await readVercelCliConnection(),!r)return;await validateVercelAccess(r.token,t.teamId,n)}return{selected:e,team:t}}case`ai-gateway-project`:return await getVercelOidcToken().catch(()=>void 0)?{selected:e}:void 0;case`ai-gateway-key`:{let t=await resolveModelApiKey(e);return(await validateGatewayApiKey(t,n)).kind===`valid`?{selected:e}:void 0}case`openai`:case`anthropic`:return{selected:e,availableModels:await availableDirectModels(e,await resolveModelApiKey(e),n)}}}async function authenticateModelConnection(e){let{selected:t,prompter:n,signal:r}=e;if(t===`vercel`)return{selected:t,team:await loginVercelModel(n,r,e.team?.teamId)};if(t===`chatgpt`)return await ensureChatGptAuth({signal:r,log:e=>n.log.info(e)}),{selected:t};if(t===`vercel-cli`||t===`ai-gateway-project`)throw Error(`Choose a connection with /login.`);let i=CONNECTION_OPTIONS.find(e=>e.value===t).label,a=(await n.password({message:i,validate:e=>e.trim()?void 0:`Enter an API key.`})).trim(),o=await withLoginProgress(n,`Checking ${i}…`,async()=>{if(t!==`ai-gateway-key`)return availableDirectModels(t,a,r);if((await validateGatewayApiKey(a,r)).kind!==`valid`)throw Error(`Could not validate the Gateway key. Check the key and your connection, then retry.`)});return r?.throwIfAborted(),await writeModelSecret(modelKeySecretName(t),a),{selected:t,availableModels:o}}export{CONNECTION_OPTIONS,authenticateModelConnection,reuseModelConnection};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Prompter } from "#setup/prompter.js";
|
|
2
|
+
type LoginStage = "source_inspection" | "gateway_catalog" | "authentication" | "activation";
|
|
3
|
+
/** Fixed stage names and durations only: no credentials, team names, or provider responses. */
|
|
4
|
+
export declare function measureLoginStage<T>(stage: LoginStage, task: () => Promise<T>): Promise<T>;
|
|
5
|
+
/** Avoid painting a loading phase for quick local work. */
|
|
6
|
+
export declare function withLoginProgress<T>(prompter: Prompter, message: string, task: () => Promise<T>): Promise<T>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{withSpinner}from"#setup/with-spinner.js";const log=createLogger(`setup.model-login`);async function measureLoginStage(e,t){let n=performance.now();try{return await t()}finally{log.debug(e,{elapsedMs:Math.round(performance.now()-n)})}}function withLoginProgress(e,t,n){return withSpinner(e,t,n,150)}export{measureLoginStage,withLoginProgress};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ConnectedModel } from "#shared/model-connection.js";
|
|
2
|
+
import { type ModelConnectionSelection } from "#internal/model-auth/store.js";
|
|
3
|
+
import type { Prompter } from "#setup/prompter.js";
|
|
4
|
+
export declare function environmentConnection(env: Record<string, string | undefined>): ModelConnectionSelection | undefined;
|
|
5
|
+
type LoginInput = {
|
|
6
|
+
appRoot: string;
|
|
7
|
+
agentRoot?: string;
|
|
8
|
+
prompter: Prompter;
|
|
9
|
+
automatic?: boolean;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
/** Applies writes under one watcher lease and waits for runtime activation. */
|
|
12
|
+
withConnectionUpdate?(task: () => Promise<void>): Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
export type ModelLoginResult = {
|
|
15
|
+
kind: "ready";
|
|
16
|
+
reload: boolean;
|
|
17
|
+
model?: ConnectedModel;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "cancelled";
|
|
20
|
+
};
|
|
21
|
+
export declare function runModelLogin(input: LoginInput): Promise<ModelLoginResult>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fetchGatewayCatalog}from"../boxes/select-model.js";import{measureLoginStage,withLoginProgress}from"./model-login-progress.js";import{CONNECTION_OPTIONS,authenticateModelConnection,reuseModelConnection}from"./model-login-connection.js";import{changeValidatedAgentModel,readAuthoredModelSelection}from"./model-source-change.js";import{inspectApplication}from"#services/inspect-application.js";import{WizardCancelledError}from"#setup/step.js";import{MODEL_HELPERS,parseModelHelper}from"#shared/model-helper.js";import{providerSettingsMatch,readProviderKeySourceSync,readProviderSelection,readProviderTeamSync,resolveAvailableProviders,writeProviderSelection}from"#setup/provider-settings.js";import{resolveModelEndpointStatus}from"#internal/resolve-model-endpoint-status.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{MODEL_CONNECTION_ENV as MODEL_CONNECTION_ENV$1}from"#internal/model-auth/transport.js";import{availableHelperModels}from"#internal/model-auth/available-models.js";import{isModelConnection,readDefaultConnection,writeDefaultConnection}from"#internal/model-auth/store.js";function environmentConnection(e){if(e.AI_GATEWAY_API_KEY?.trim())return`ai-gateway-key`;if(e.VERCEL_OIDC_TOKEN?.trim())return`ai-gateway-project`;if(e.OPENAI_API_KEY?.trim())return`openai`;if(e.ANTHROPIC_API_KEY?.trim())return`anthropic`}async function readLoginModel(e){let t=await readAuthoredModelSelection(e);if(t!==void 0)return{selection:t,external:parseModelHelper(t)!==void 0};let n=(await inspectApplication(e)).compiledState?.manifest.config.model;return{selection:n?.routing.kind===`gateway`&&n.source===void 0?n.id:void 0,external:n?.routing.kind===`external`}}function modelSelection(e,t){let n=e===`chatgpt`||e===`openai`||e===`anthropic`?e:void 0,r=t.selection===void 0?void 0:parseModelHelper(t.selection),i=n?r?.helper===n:t.selection!==void 0&&!t.external,a=n?MODEL_HELPERS[n].defaultModel:`openai/gpt-5.6-luna-fast`,o=r?.id??t.selection;return{helper:n,compatible:i,defaultId:a,needsModels:!i||o===a}}async function applyConnection(e,t,n,r){let{appRoot:i,prompter:a,signal:o}=e,{selected:s,team:c}=t,{helper:l,compatible:u,defaultId:d,needsModels:f}=modelSelection(s,n),p;if(f){let e=t.availableModels??r??(l?await withLoginProgress(a,`Loading available models…`,()=>availableHelperModels(l,o)):[]),i=d;if(!e.includes(i)){if(e.length===0)throw Error(`No models are available for this connection. Choose another connection with /login.`);i=await a.select({message:`Choose an available model`,search:!0,options:e.map(e=>({value:e,label:e}))})}let s=l?MODEL_HELPERS[l].prefix+i:i;(!u||s!==n.selection)&&(p=s)}let m=s===`openai`||s===`anthropic`||s===`ai-gateway-key`?e.automatic?readProviderKeySourceSync(i)??(environmentConnection(process.env)===s?`environment`:`secret`):`secret`:void 0,h={selected:s,...c,keySource:m},g=!await providerSettingsMatch(i,h),save=async()=>{if(o?.throwIfAborted(),p!==void 0){let t=await changeValidatedAgentModel({appRoot:e.agentRoot??i,slug:p});if(t.kind===`rejected`)throw Error(t.message)}g&&await writeProviderSelection(i,s,c,m),process.env[MODEL_CONNECTION_ENV$1]=s,m?process.env.EVE_MODEL_KEY_SOURCE=m:delete process.env.EVE_MODEL_KEY_SOURCE,c?(process.env.EVE_MODEL_TEAM=c.teamId,process.env.EVE_MODEL_TEAM_NAME=c.teamName):(delete process.env.EVE_MODEL_TEAM,delete process.env.EVE_MODEL_TEAM_NAME)};p===void 0?await save():await withLoginProgress(a,`Loading selected model…`,()=>measureLoginStage(`activation`,()=>e.withConnectionUpdate?e.withConnectionUpdate(save):save())),e.automatic||await writeDefaultConnection(s);let _=p??n.selection,v=l&&_?parseModelHelper(_)?.id:_,y;if(v){let e=l?{kind:`external`,provider:MODEL_HELPERS[l].provider}:classifyModelRouting(v);y={id:v,routing:e,endpoint:resolveModelEndpointStatus(e,{apiKey:s===`ai-gateway-key`,oidc:s===`ai-gateway-project`,account:s===`vercel`||s===`vercel-cli`,team:c?.teamName},{state:`ready`})}}return{kind:`ready`,reload:p!==void 0&&e.withConnectionUpdate===void 0,...y&&{model:y}}}async function runModelLogin(e){let{appRoot:t,prompter:n,signal:r}=e,i,getModel=()=>i??=measureLoginStage(`source_inspection`,()=>readLoginModel(e.agentRoot??t)),connect=async(i,a)=>{let o=new AbortController,s=r?AbortSignal.any([r,o.signal]):o.signal,c=getModel().then(async e=>{let t=modelSelection(i,e);return{model:e,models:!t.helper&&t.needsModels?(await measureLoginStage(`gateway_catalog`,()=>fetchGatewayCatalog(s))).filter(e=>e.type===`language`).map(e=>e.id):void 0}}).then(e=>({value:e}),e=>({error:e}));try{let r=readProviderTeamSync(t),o=await measureLoginStage(`authentication`,async()=>a?await withLoginProgress(n,`Checking model access…`,()=>reuseModelConnection(i,r,s)):await authenticateModelConnection({selected:i,team:r,prompter:n,signal:s}));if(!o)return;let l=await withLoginProgress(n,`Loading available models…`,()=>c);if(`error`in l)throw l.error;return await applyConnection({...e,automatic:a,signal:s},o,l.value.model,l.value.models)}finally{o.abort()}};try{if(e.automatic){let{model:e,selected:a}=await withLoginProgress(n,`Reading saved connection…`,async()=>{let[e,n,r,i]=await Promise.all([getModel(),readProviderSelection(t),resolveAvailableProviders(t),readDefaultConnection()]),a=e.selection===void 0?void 0:parseModelHelper(e.selection)?.helper;return{model:e,selected:n??a??environmentConnection(process.env)??(r.includes(`ai-gateway-project`)?`ai-gateway-project`:void 0)??i??`vercel-cli`}});if(e.external&&e.selection===void 0)return{kind:`ready`,reload:!1};try{let e=await connect(a,!0);if(e)return e}catch(e){i=void 0,r?.throwIfAborted(),n.log.warning(e instanceof Error?e.message:`Could not connect automatically. Retry /login.`)}}for(;;){let e=await n.select({message:`Choose a connection`,search:!0,options:[...CONNECTION_OPTIONS]});if(!isModelConnection(e))throw Error(`Choose a model connection.`);try{let t=await connect(e,!1);if(t)return t}catch(e){if(i=void 0,e instanceof WizardCancelledError)return{kind:`cancelled`};r?.throwIfAborted(),n.log.warning(e instanceof Error?e.message:`Connection failed. Retry /login.`)}}}catch(e){if(e instanceof WizardCancelledError)return{kind:`cancelled`};throw e}}export{environmentConnection,runModelLogin};
|
|
@@ -36,4 +36,11 @@ export declare function changeAgentModel(input: {
|
|
|
36
36
|
readonly appRoot: string;
|
|
37
37
|
readonly slug: string;
|
|
38
38
|
}): Promise<ApplyModelOutcome>;
|
|
39
|
+
/** Applies a selection already confirmed by the provider catalog, retaining source-edit guards. */
|
|
40
|
+
export declare function changeValidatedAgentModel(input: {
|
|
41
|
+
readonly appRoot: string;
|
|
42
|
+
readonly slug: string;
|
|
43
|
+
}): Promise<ApplyModelOutcome>;
|
|
39
44
|
export declare function validateModelSlug(appRoot: string, slug: string): Promise<string | null>;
|
|
45
|
+
/** Uses the same source grammar as model edits, never the provider endpoint. */
|
|
46
|
+
export declare function readAuthoredModelSelection(startPath: string): Promise<string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join}from"node:path";import pc from"#compiled/picocolors/index.js";import{discoverAgent}from"#discover/discover-agent.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{CHATGPT_MODEL_SELECTION_PREFIX
|
|
1
|
+
import{readFile}from"node:fs/promises";import{join}from"node:path";import{resolveDiscoveryProject}from"#discover/project.js";import pc from"#compiled/picocolors/index.js";import{discoverAgent}from"#discover/discover-agent.js";import{parseModelHelper}from"#shared/model-helper.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{CHATGPT_MODEL_SELECTION_PREFIX}from"#shared/chatgpt-model.js";import{createCompiledRuntimeModelCatalogLoader}from"#compiler/model-catalog.js";import{readModelSelectionFromSource}from"#source-change/apply-model-selection.js";import{createStaticSourceChange}from"#source-change/static-source-change.js";function formatApplyModelSettingsOutcome(e){return e.kind===`rejected`?e.message:e.kind===`unchanged`?`Model settings are already up to date.`:e.changed.length===1&&e.changed[0]===`model`&&e.model!==void 0?`Model changed to ${pc.bold(e.model)}. Live on your next prompt.`:`Model settings updated: ${e.changed.map(t=>t===`model`?`model ${e.model??`updated`}`:t===`reasoning`?`reasoning ${e.reasoning??`provider default`}`:`Fast mode ${e.fastMode?`on`:`off`}`).join(`, `)}. Live on your next prompt.`}function formatApplyModelOutcome(e){switch(e.kind){case`changed`:return`Model changed to ${pc.bold(e.to)}. Live on your next prompt.`;case`unchanged`:return`Model is already \`${e.model}\`.`;case`rejected`:return e.message}}async function changeAgentModelSettings(e){let{appRoot:t,patch:n}=e;if(n.model.kind===`set`){let e=await validateModelSlug(t,n.model.value);if(e!==null)return{kind:`rejected`,message:e}}let r=await resolveDiscoveryProject(t),{manifest:i}=await discoverAgent(r),a=await createStaticSourceChange(i).updateModelSettings(n);if(a.kind===`bail`)return{kind:`rejected`,message:`Couldn't edit ${a.at.logicalPath}: ${a.reason}. Change the model settings by hand.`};if(a.changed.length===0)return{kind:`unchanged`};let o={kind:`changed`,changed:a.changed};return n.model.kind===`set`&&(o.model=n.model.value),n.reasoning.kind!==`keep`&&(o.reasoning=n.reasoning.kind===`set`?n.reasoning.value:null),n.gatewayServiceTier.kind!==`keep`&&(o.fastMode=n.gatewayServiceTier.kind===`set`),o}async function changeAgentModel(e){let{appRoot:t,slug:n}=e,r=await validateModelSlug(t,n);return r===null?changeValidatedAgentModel(e):{kind:`rejected`,message:r}}async function changeValidatedAgentModel(e){let{appRoot:t,slug:n}=e,r=await resolveDiscoveryProject(t),{manifest:i}=await discoverAgent(r),a=await createStaticSourceChange(i).updateModelName(n);return a.kind===`bail`?{kind:`rejected`,message:`Couldn't edit ${a.at.logicalPath}: ${a.reason}. Change \`model\` by hand.`}:a.from===a.to?{kind:`unchanged`,model:a.to}:{kind:`changed`,to:a.to}}async function validateModelSlug(e,t){if(parseModelHelper(t)!==void 0)return null;if(t.startsWith(CHATGPT_MODEL_SELECTION_PREFIX))return"Choose a bare OpenAI model id after `chatgpt/`.";if(!t.includes(`/`))return`\`${t}\` isn't a provider/model id (e.g. anthropic/claude-sonnet-5).`;let n=createCompiledRuntimeModelCatalogLoader(e);try{if(await n.getModelLimits(formatLanguageModelGatewayId(t))===null)return`I couldn't confirm \`${t}\` in the AI Gateway model catalog, so I didn't change agent.ts.`}catch{return null}return null}async function readAuthoredModelSelection(e){let t=await resolveDiscoveryProject(e),{manifest:n}=await discoverAgent(t);if(!n.configModule)return;let r=await readFile(join(t.agentRoot,n.configModule.logicalPath),`utf8`);return readModelSelectionFromSource(r)}export{changeAgentModel,changeAgentModelSettings,changeValidatedAgentModel,formatApplyModelOutcome,formatApplyModelSettingsOutcome,readAuthoredModelSelection,validateModelSlug};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ModelHelper } from "#shared/model-helper.js";
|
|
2
|
+
import type { ProviderSelection } from "#setup/provider-settings.js";
|
|
2
3
|
import type { AgentModelSettingsPatch } from "#source-change/apply-agent-model-settings.js";
|
|
3
4
|
import { type SelectModelDeps } from "../boxes/select-model.js";
|
|
4
5
|
import { type GatewayModelCapabilities, type ReasoningLevel } from "../boxes/model-capabilities.js";
|
|
@@ -6,11 +7,10 @@ import type { AgentReasoningDefinition, ModelRouting } from "#shared/agent-defin
|
|
|
6
7
|
import { type GatewayServiceTierState } from "#shared/gateway-service-tier.js";
|
|
7
8
|
import type { Prompter, SelectOption } from "../prompter.js";
|
|
8
9
|
import { type ApplyModelSettingsOutcome } from "./model-source-change.js";
|
|
9
|
-
import { ensureChatGptAuth } from "./chatgpt-auth.js";
|
|
10
|
-
import { runProviderFlow } from "./provider.js";
|
|
11
10
|
/** The current model id, its routing, and whether `/model` can rewrite it. */
|
|
12
11
|
export interface CurrentAgentModel {
|
|
13
12
|
id: string | null;
|
|
13
|
+
helper?: ModelHelper;
|
|
14
14
|
routing: ModelRouting | null;
|
|
15
15
|
reasoning: AgentReasoningDefinition | null;
|
|
16
16
|
serviceTier: GatewayServiceTierState;
|
|
@@ -51,7 +51,7 @@ export interface ModelSettingsRequest {
|
|
|
51
51
|
capabilitiesFor(modelId: string | null): GatewayModelCapabilities | undefined;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* A completed model or setting selection. Each field is present only when it differs from
|
|
55
55
|
* the authored value; `"default"` and `"standard"` mean "remove the setting".
|
|
56
56
|
*/
|
|
57
57
|
export interface ModelSettingsResult {
|
|
@@ -77,19 +77,10 @@ export interface ModelFlowDeps {
|
|
|
77
77
|
selectModel?: SelectModelDeps;
|
|
78
78
|
/** The composite Change-model screen; the dev TUI renderer implements it. */
|
|
79
79
|
pickModelSettings?: ModelSettingsPicker;
|
|
80
|
-
/** Resolves provider credentials available to this project. */
|
|
81
|
-
resolveAvailableProviders: typeof resolveAvailableProviders;
|
|
82
|
-
/** Reads the explicit provider selection, if one has been made. */
|
|
83
|
-
readProviderSelection: typeof readProviderSelection;
|
|
84
|
-
/** The provider sub-flow behind the menu's provider row. */
|
|
85
|
-
runProviderFlow: typeof runProviderFlow;
|
|
86
|
-
/** Ensures eve has a usable ChatGPT login before selecting the subscription. */
|
|
87
|
-
ensureChatGptAuth: typeof ensureChatGptAuth;
|
|
88
|
-
writeProviderSelection: typeof writeProviderSelection;
|
|
89
80
|
}
|
|
90
81
|
export type ModelFlowResult = {
|
|
91
82
|
kind: "cancelled";
|
|
92
|
-
/**
|
|
83
|
+
/** Whether an incomplete selection was discarded. */
|
|
93
84
|
discardedDraft?: boolean;
|
|
94
85
|
} | {
|
|
95
86
|
kind: "done";
|
|
@@ -100,16 +91,7 @@ export type ModelFlowResult = {
|
|
|
100
91
|
/** The provider selected in a completed provider sub-flow. */
|
|
101
92
|
providerSelection?: ProviderSelection;
|
|
102
93
|
};
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* THE MODEL FLOW for the dev TUI's `/model`: a root menu whose Change model
|
|
106
|
-
* row opens the composite model screen (catalog pick, reasoning-effort slider,
|
|
107
|
-
* service-tier toggle) and whose provider row runs {@link runProviderFlow}.
|
|
108
|
-
* Authored setting changes stay in memory until Done, then land through one
|
|
109
|
-
* source transform and atomic rename. A completed provider change commits the
|
|
110
|
-
* current draft and returns to the prompt; cancelled flows and
|
|
111
|
-
* external-provider instructions return to the menu.
|
|
112
|
-
*/
|
|
94
|
+
/** Selects a model or setting and applies the completed edit immediately. */
|
|
113
95
|
export declare function runModelFlow(input: {
|
|
114
96
|
/** Selected agent root whose authored model settings are edited. */
|
|
115
97
|
appRoot: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{withSpinner}from"../with-spinner.js";import{gatewayModelCapabilities}from"../boxes/model-capabilities.js";import{fetchGatewayCatalog,modelOptionsFromCatalog}from"../boxes/select-model.js";import{changeAgentModelSettings,formatApplyModelSettingsOutcome,readAuthoredModelSelection}from"./model-source-change.js";import{inspectApplication}from"#services/inspect-application.js";import{MODEL_HELPERS,parseModelHelper}from"#shared/model-helper.js";import{readGatewayServiceTier}from"#shared/gateway-service-tier.js";import{availableHelperModels}from"#internal/model-auth/available-models.js";async function runModelFlow(e){let{appRoot:t,prompter:n,signal:r}=e,i={readCurrentModel:readCurrentAgentModel,applySettings:changeAgentModelSettings,...e.deps},[a,o]=await withSpinner(n,`Loading models…`,()=>Promise.all([i.readCurrentModel(t),(i.selectModel?.fetchModels??fetchGatewayCatalog)(r).catch(()=>void 0)])),s=a.helper===void 0?void 0:[a.helper,MODEL_HELPERS[a.helper]],c=s?(await availableHelperModels(s[0],r)).map(e=>({value:s[1].prefix+e,label:e})):modelOptionsFromCatalog(o);if(!i.pickModelSettings)throw Error(`The model picker is unavailable.`);let l=await i.pickModelSettings({model:a.editable?{kind:`pick`,options:c,current:s&&a.id?s[1].prefix+a.id.replace(/^[^/]+\//u,``):a.id}:{kind:`fixed`,current:a.id,reason:`This model is configured in agent.ts.`},reasoning:a.reasoning===`provider-default`?null:a.reasoning,serviceTier:a.serviceTier,settingsEditable:a.settingsEditable,externalRouting:a.routing?.kind===`external`,capabilitiesFor:e=>gatewayModelCapabilities(o,s&&e?`${s[0]===`chatgpt`?`openai`:s[0]}/${e.slice(s[1].prefix.length)}`:e)});if(!l)return{kind:`cancelled`};r?.throwIfAborted();let u=await i.applySettings({appRoot:t,patch:{model:l.model===void 0?{kind:`keep`}:{kind:`set`,value:l.model},reasoning:l.reasoning===void 0?{kind:`keep`}:l.reasoning==="default"?{kind:`remove`}:{kind:`set`,value:l.reasoning},gatewayServiceTier:l.serviceTier===void 0?{kind:`keep`}:l.serviceTier===`standard`?{kind:`remove`}:{kind:`set`,value:`priority`}}});return{kind:`done`,accessChanged:u.kind===`changed`,modelMessage:formatApplyModelSettingsOutcome(u)}}async function readCurrentAgentModel(e){try{let{compiledState:t}=await inspectApplication(e),n=t?.manifest.config,r=n?.model,i=r?.source===void 0?void 0:await readAuthoredModelSelection(e),a=i===void 0?void 0:parseModelHelper(i)?.helper;return{id:a&&r!==void 0?`${MODEL_HELPERS[a].prefix}${r.id}`:r?.id??null,helper:a,routing:r?.routing??null,reasoning:n?.reasoning??null,serviceTier:readGatewayServiceTier(r?.providerOptions),editable:r!==void 0&&(r.source===void 0||a!==void 0),settingsEditable:n?.source!==void 0}}catch{return{id:null,routing:null,reasoning:null,serviceTier:{kind:`standard`},editable:!1,settingsEditable:!1}}}async function modelChangeRefusalForUneditableModel(e){let{editable:t,routing:n}=await readCurrentAgentModel(e);return t?null:`Model is set via ${n?.kind===`external`?`the external provider \`${n.provider}\``:`an SDK model call`} in agent.ts, not a string literal; /model can't rewrite it. Edit \`model\` in agent.ts.`}export{modelChangeRefusalForUneditableModel,runModelFlow};
|
|
@@ -2,21 +2,6 @@ import type { RegistryCatalogItem } from "#cli/commands/registry.js";
|
|
|
2
2
|
import type { Prompter } from "#setup/prompter.js";
|
|
3
3
|
import { type RegistrySessionResult } from "./registry-session.js";
|
|
4
4
|
type Item = RegistryCatalogItem;
|
|
5
|
-
export interface RegistryPlannerContext {
|
|
6
|
-
/** Steps owned by an enclosing journey, rendered before the registry steps. */
|
|
7
|
-
prefixSteps?: readonly {
|
|
8
|
-
label: string;
|
|
9
|
-
complete?: boolean;
|
|
10
|
-
}[];
|
|
11
|
-
/** Facts owned by the enclosing journey, rendered before registry selections. */
|
|
12
|
-
reviewMetadata?: readonly {
|
|
13
|
-
label: string;
|
|
14
|
-
value: string;
|
|
15
|
-
}[];
|
|
16
|
-
reviewMessage?: string;
|
|
17
|
-
primaryActionLabel?: string;
|
|
18
|
-
emptyActionLabel?: string;
|
|
19
|
-
}
|
|
20
5
|
export interface RegistryFlowDeps {
|
|
21
6
|
browseRegistryCatalog: (typeof import("#cli/commands/registry.js"))["browseRegistryCatalog"];
|
|
22
7
|
installRegistryItem: (typeof import("#cli/commands/registry.js"))["installRegistryItem"];
|
|
@@ -27,16 +12,15 @@ export declare class RegistryFlowFailedError extends Error {
|
|
|
27
12
|
readonly completed: RegistrySessionResult;
|
|
28
13
|
constructor(error: unknown, completed: RegistrySessionResult);
|
|
29
14
|
}
|
|
30
|
-
/**
|
|
15
|
+
/** Searches the catalog and installs one selected item with its required setup. */
|
|
31
16
|
export declare function runRegistryFlow(input: {
|
|
32
17
|
appRoot: string;
|
|
33
18
|
prompter: Prompter;
|
|
34
19
|
signal?: AbortSignal;
|
|
35
|
-
/** Registry item supplied by `/add <item>`,
|
|
20
|
+
/** Registry item supplied by `/add <item>`, installed directly. */
|
|
36
21
|
initialAddress?: string;
|
|
37
|
-
plannerContext?: RegistryPlannerContext;
|
|
38
22
|
onScreen?: (input: {
|
|
39
|
-
screen: "
|
|
23
|
+
screen: "registry_install";
|
|
40
24
|
registrySelectedCount?: number;
|
|
41
25
|
}) => void;
|
|
42
26
|
onItemStart?: (item: Item, index: number, total: number) => void;
|