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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.57.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 61d4097: Run every conversational turn directly inside the session's owning workflow instead of dispatching a child turn run per message. An idle session hands its settled state to the exact deployment that accepted a new delivery, whether the delivery arrives through the session ID or any channel continuation address, keeping the original session ID and event stream and renewing the session's configured timeout. Deliveries that land while a handoff is in progress wait for the successor instead of starting a replacement session.
|
|
8
|
+
|
|
9
|
+
Steering a running turn applies at the next committed step boundary without cancelling in-flight model or tool work and preserves the turn's identity and usage; input that arrives after the model has answered starts the next turn. `continuation.rekey()` is replaced by `continuation.alias()`: every claimed address stays active, and the most recently selected alias is exposed as `continuation.token`.
|
|
10
|
+
|
|
11
|
+
Sessions from the former driver/turn execution model are imported on their next turn, preserving identity, history, and the original stream while interrupting pending work; drivers started before eve 0.45 are reported inactive and their channel starts a fresh session. Retain the original deployment until imported sessions end, and retire sessions before rolling back across this boundary.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 32aca9b: Restored `agent` tools now dispatch through the shared subagent workflow when framework defaults are disabled.
|
|
16
|
+
- 7b17b27: Simplify the TUI footer by removing the local port and separating the model and connection with dots. Vercel account connections show the resolved team slug instead of a team ID.
|
|
17
|
+
- f21e63f: Declare `.vercel/output` for generated eve services so Vercel consumes the Build Output API directory that their build commands produce instead of looking for the framework preset's `.output` default.
|
|
18
|
+
- 7b17b27: Model login shares resolved credentials with the running agent, avoids rebuilds for account, team, and key changes, and refreshes agent information without delaying chat. Clear status messages show when to finish browser sign-in and what eve is waiting for, without flashing indicators for quick steps.
|
|
19
|
+
- e1ae8eb: Flush the final activity snapshot when an activity stream closes during the render debounce window.
|
|
20
|
+
- f21e63f: Make `withEve` discover a containing workspace when Vercel evaluates `vercel.ts` from its temporary `.vercel` directory.
|
|
21
|
+
- fe6451c: Keep automatic prompt caching enabled when local model authentication resolves an AI Gateway model to a provider object. Anthropic models retain cache reuse after signing in through `eve dev`.
|
|
22
|
+
- 032860c: Bound negotiated session stream responses with renewable leases so abandoned serverless invocations release their durable stream readers. The eve client renews these responses from its cursor without exposing transport heartbeats or lease records as session events; tail-relative reads and streams with reconnection disabled remain unleased.
|
|
23
|
+
- 7b17b27: Fix a local workflow health-check failure after model or source changes. Capability probes no longer look up a run before it exists, avoiding a spurious queue error and startup delay.
|
|
24
|
+
- 7b17b27: Allow switching Vercel teams through `/login` by always showing the team picker when multiple teams are available. The current team is highlighted rather than silently selected; automatic startup still reuses the saved connection.
|
|
25
|
+
- 7b17b27: Match the Vercel label's color to the surrounding model and team text in the TUI footer.
|
|
26
|
+
- ba0b866: When a self-modified tool or capability later fails or behaves incorrectly, the agent now offers to delegate a repair. It waits for your confirmation before sending the observed and expected behavior back to self-modification.
|
|
27
|
+
- 7b17b27: Use the same full-size arrow for empty and populated TUI prompts, with the empty arrow in the terminal's default foreground color for better visibility.
|
|
28
|
+
- 7b17b27: Open the TUI directly after init, connect models through `/login` without requiring a Vercel project, and store local credentials securely. Add direct OpenAI and Anthropic model helpers, apply model selections immediately, and simplify menus and `/add` to get to chat sooner. Vercel CLI installation and login now run during deployment instead of separate `/vc:install` and `/vc:login` commands.
|
|
29
|
+
- 8bb62e2: Recognize AI Gateway credit-balance and project-budget refusals in semantic error summaries.
|
|
30
|
+
- 7b17b27: Restore guided Trusted Sources setup when Deployment Protection blocks `eve dev --url`. eve reuses the existing Vercel CLI session, asks before changing project access, and verifies the connection before returning to chat.
|
|
31
|
+
- 7b17b27: Use the base release version for default sandbox images when running commit or git-ref tarballs. Build metadata such as `+git.<sha>` no longer produces invalid image tags for Docker, microsandbox, or Vercel Sandbox.
|
|
32
|
+
- 7b17b27: Search `/add` by capabilities such as iMessage or SMS, as well as item names and addresses. The picker now searches catalog titles and descriptions without adding extra text to menu rows.
|
|
33
|
+
- a08e4bb: Prompt for and resolve the target Vercel project before configuring production self-modification, and scope GitHub connector creation and attachment to that project's owner.
|
|
34
|
+
- 7b17b27: Keep the composer available while startup connects your model and prepares chat, with animated progress and prompts only when input is needed. Preserve drafts and queued messages through setup, and announce readiness only after the runtime refresh succeeds.
|
|
35
|
+
- 61d4097: Batch closely spaced stream events on Vercel within a 10 ms window to reduce network writes. Explicit Workflow stream-flush overrides remain supported.
|
|
36
|
+
- 53fad6c: Emits canonical GenAI cache-write tokens, reports the provider-confirmed response model, and adds the executing agent name to tool spans.
|
|
37
|
+
- 7b17b27: Replace rotating TUI prompt suggestions with a stable “Send a message…” placeholder that does not assume agent capabilities.
|
|
38
|
+
- fe6451c: Apply steering in the core runtime before a pending model request produces an answer, continuing the same turn with the correction across clients and channels. Preserve executing tools and their results, prevent duplicate in-process model execution on background wakeups, and keep boundary steering after assistant output begins.
|
|
39
|
+
- 7b17b27: Pressing Enter during a TUI response now steers the active agent immediately instead of queuing the message until the turn finishes. Startup messages and sessions without steering support continue to queue.
|
|
40
|
+
- 7b17b27: Distinguish steered TUI messages with a yellow left gutter instead of an extra arrow row. Queued messages also render without an arrow row.
|
|
41
|
+
- 1e6437b: Announce when dynamic skills are withdrawn completely so agents do not retain stale skill lists.
|
|
42
|
+
|
|
3
43
|
## 0.56.0
|
|
4
44
|
|
|
5
45
|
### Minor Changes
|
|
@@ -6,6 +6,6 @@ import type { ChannelAdapter, ChannelAdapterContext } from "#channel/adapter.js"
|
|
|
6
6
|
*
|
|
7
7
|
* Populates `session` with a live {@link SessionHandle} backed by the
|
|
8
8
|
* supplied accessor so handlers can read identity / auth and call
|
|
9
|
-
* `session.continuation.
|
|
9
|
+
* `session.continuation.alias(...)` to add an address for the parked session.
|
|
10
10
|
*/
|
|
11
11
|
export declare function buildAdapterContext<TCtx extends ChannelAdapterContext<any> = ChannelAdapterContext>(adapter: ChannelAdapter<TCtx>, accessor: ContextAccessor): TCtx;
|
|
@@ -15,8 +15,8 @@ import type { ChannelAudienceProjector } from "#channel/audience.js";
|
|
|
15
15
|
* {@link ContextAccessor} that tools and providers use).
|
|
16
16
|
*
|
|
17
17
|
* `session` is a live handle to the current session — id, auth,
|
|
18
|
-
* optional channel continuation address, including an imperative `
|
|
19
|
-
* for channels that need to
|
|
18
|
+
* optional channel continuation address, including an imperative `alias()`
|
|
19
|
+
* for channels that need to add an alias for the session mid-turn (e.g. Slack's
|
|
20
20
|
* auto-anchor on first post).
|
|
21
21
|
*/
|
|
22
22
|
export interface ChannelAdapterContext<TState = Record<string, unknown>> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSession,sessionCallbackToTurnCaller}from"#channel/session.js";import{copyChannelActivityPresentation}from"#channel/activity-renderer.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{normalizeSendInput,serializeUrlFilePartsInMessage}from"#channel/send-input.js";import{DEFAULT_TURN_POLICY}from"#channel/types.js";import{isReservedSessionCommandToken}from"#execution/session-
|
|
1
|
+
import{createSession,sessionCallbackToTurnCaller}from"#channel/session.js";import{copyChannelActivityPresentation}from"#channel/activity-renderer.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{normalizeSendInput,serializeUrlFilePartsInMessage}from"#channel/send-input.js";import{DEFAULT_TURN_POLICY}from"#channel/types.js";import{isReservedSessionCommandToken}from"#execution/session-inbox/address.js";function createChannelAddress(e){let t=e.metadata??{},n=`${e.channelName}:${e.continuationToken}`;if(isReservedSessionCommandToken(n))throw Error(`Channel address "${n}" uses eve's reserved session namespace.`);return{continuationToken:e.continuationToken,async deliver(r,i){let a=t.channelKind!==void 0&&t.channelName!==void 0?createChannelDeliveryMetadata(t):void 0,o=normalizeSendInput(r),s=sessionCallbackToTurnCaller(i.callback),c={auth:i.auth,delivery:a,kind:`send`,payload:{...o,message:serializeUrlFilePartsInMessage(o.message)},requestId:t.requestId,turnPolicy:o.message===void 0?void 0:i.turnPolicy??e.turnPolicy??DEFAULT_TURN_POLICY},l=s===void 0?c:{...c,caller:s},u=await(async()=>{let r=await e.runtime.dispatchContinuation({command:l,continuationToken:n});return r.status===`accepted`?createSession(r.sessionId,e.runtime,{...t,turnPolicy:e.turnPolicy}):void 0})();if(u!==void 0)return u;if(o.inputResponses&&o.inputResponses.length>0)throw Error(`Cannot deliver inputResponses — the target session was not found via continuation token.`);let d=i.state,f=d===void 0?e.adapter:{...e.adapter,state:{...e.adapter.state,...d}};f!==e.adapter&©ChannelActivityPresentation(e.adapter,f);let p=i.mode===`task`?void 0:{requestInput:!0},m={adapter:f,auth:i.auth,capabilities:p,callback:i.callback,channelName:e.channelName,continuationConflictCommand:l,continuationToken:n,delivery:a,initiatorAuth:i.initiatorAuth,input:{context:o.context,message:serializeUrlFilePartsInMessage(o.message)??``,outputSchema:o.outputSchema},mode:i.mode??`conversation`,requestId:t.requestId,title:i.title},h=await e.runtime.createSession(m);return createSession(h.sessionId,e.runtime,{...t,turnPolicy:e.turnPolicy})},async send(e,t){return await this.deliver({message:e},t)},async respond(e,t){if(e===void 0||e.length===0)throw Error(`respond() requires at least one input response.`);return await this.deliver({inputResponses:e},t)},async cancel(t){return await e.runtime.dispatchContinuation({command:{kind:`cancel`,turnId:t?.turnId},continuationToken:n})},async compact(){return await e.runtime.dispatchContinuation({command:{kind:`compact`},continuationToken:n})},async clear(){return await e.runtime.dispatchContinuation({command:{kind:`clear`},continuationToken:n})},async reset(t){return await e.runtime.dispatchContinuation({command:{kind:`reset`,reason:t?.reason},continuationToken:n})},async resolveSession(){let r=await e.runtime.resolveContinuation(n);return r===void 0?void 0:createSession(r.sessionId,e.runtime,{...t,turnPolicy:e.turnPolicy})}}}function createChannelAddressFn(e){return t=>createChannelAddress({...e,continuationToken:t})}export{createChannelAddress,createChannelAddressFn};
|
|
@@ -50,15 +50,16 @@ export type SessionRespondOptions = SessionDeliveryOptions;
|
|
|
50
50
|
* Live handle to the current session, exposed on `ctx.session` to
|
|
51
51
|
* `deliver` and event handlers. The framework hydrates the read-only
|
|
52
52
|
* fields from the active context at step start. A write through
|
|
53
|
-
* `continuation.
|
|
54
|
-
* runtime can
|
|
53
|
+
* `continuation.alias()` selects a new current address and records it so the
|
|
54
|
+
* runtime can add its hook to the session inbox at the next step boundary.
|
|
55
|
+
* Previously claimed addresses remain active.
|
|
55
56
|
*/
|
|
56
57
|
export interface SessionHandle {
|
|
57
58
|
readonly id: string;
|
|
58
59
|
readonly auth: SessionAuth;
|
|
59
60
|
readonly continuation?: {
|
|
60
61
|
readonly token: string;
|
|
61
|
-
|
|
62
|
+
alias(rawToken: string): void;
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
export declare function createSession(id: string, runtime: Runtime, metadata?: Partial<ChannelDeliverySource> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{serializeUrlFilePartsInMessage}from"#channel/send-input.js";import{DEFAULT_TURN_POLICY}from"#channel/types.js";import{parseInputResponses}from"#shared/input.js";import{AuthKey,ContinuationTokenKey,InitiatorAuthKey,SessionIdKey}from"#context/keys.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";function createSession(e,t,n={}){return{id:e,async send(r,i){let a=createDelivery(n),o=sessionCallbackToTurnCaller(i.callback,i.activityObserver),s=attachClientContext({message:serializeUrlFilePartsInMessage(r)},readClientContext(i));i.context!==void 0&&(s.context=i.context),i.outputSchema!==void 0&&(s.outputSchema=i.outputSchema);let c={auth:i.auth,delivery:a,kind:`send`,payload:s,requestId:n.requestId,turnPolicy:i.turnPolicy??n.turnPolicy??DEFAULT_TURN_POLICY};return await t.dispatchSession({command:o===void 0?c:{...c,caller:o},sessionId:e})},async respond(r,i){if(r.length===0)throw Error(`respond() requires at least one input response.`);let a=parseInputResponses(r),o=sessionCallbackToTurnCaller(i.callback,i.activityObserver),s=createDelivery(n),c=attachClientContext({inputResponses:a},readClientContext(i));i.context!==void 0&&(c.context=i.context),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={auth:i.auth,delivery:s,kind:`send`,payload:c,requestId:n.requestId};return await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e})},async cancel(n){let r={kind:`cancel`};return n?.taskId!==void 0&&(r.taskId=n.taskId),n?.tasks!==void 0&&(r.tasks=n.tasks),n?.turnId!==void 0&&(r.turnId=n.turnId),await t.dispatchSession({command:r,sessionId:e})},async compact(){return await t.dispatchSession({command:{kind:`compact`},sessionId:e})},async clear(){return await t.dispatchSession({command:{kind:`clear`},sessionId:e})},async reset(n){return await t.dispatchSession({command:{kind:`reset`,reason:n?.reason},sessionId:e})},async getEventStream(n){return t.getEventStream(e,n)},async getStreamTailIndex(){return t.getStreamTailIndex(e)}}}function createAttachSessionFn(e,t={}){return n=>createSession(n,e,t)}function createDelivery(e){return e.channelKind!==void 0&&e.channelName!==void 0?createChannelDeliveryMetadata(e):void 0}function buildSessionHandle(e){return{get id(){return e.get(SessionIdKey)??``},get auth(){return{current:e.get(AuthKey)??null,initiator:e.get(InitiatorAuthKey)??null}},get continuation(){let t=e.get(ContinuationTokenKey);if(t!==void 0&&t.length!==0)return{token:toChannelLocalContinuationToken(t),
|
|
1
|
+
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{serializeUrlFilePartsInMessage}from"#channel/send-input.js";import{DEFAULT_TURN_POLICY}from"#channel/types.js";import{parseInputResponses}from"#shared/input.js";import{AuthKey,ContinuationHookTokensKey,ContinuationTokenKey,InitiatorAuthKey,SessionIdKey}from"#context/keys.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";function createSession(e,t,n={}){return{id:e,async send(r,i){let a=createDelivery(n),o=sessionCallbackToTurnCaller(i.callback,i.activityObserver),s=attachClientContext({message:serializeUrlFilePartsInMessage(r)},readClientContext(i));i.context!==void 0&&(s.context=i.context),i.outputSchema!==void 0&&(s.outputSchema=i.outputSchema);let c={auth:i.auth,delivery:a,kind:`send`,payload:s,requestId:n.requestId,turnPolicy:i.turnPolicy??n.turnPolicy??DEFAULT_TURN_POLICY};return await t.dispatchSession({command:o===void 0?c:{...c,caller:o},sessionId:e})},async respond(r,i){if(r.length===0)throw Error(`respond() requires at least one input response.`);let a=parseInputResponses(r),o=sessionCallbackToTurnCaller(i.callback,i.activityObserver),s=createDelivery(n),c=attachClientContext({inputResponses:a},readClientContext(i));i.context!==void 0&&(c.context=i.context),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={auth:i.auth,delivery:s,kind:`send`,payload:c,requestId:n.requestId};return await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e})},async cancel(n){let r={kind:`cancel`};return n?.taskId!==void 0&&(r.taskId=n.taskId),n?.tasks!==void 0&&(r.tasks=n.tasks),n?.turnId!==void 0&&(r.turnId=n.turnId),await t.dispatchSession({command:r,sessionId:e})},async compact(){return await t.dispatchSession({command:{kind:`compact`},sessionId:e})},async clear(){return await t.dispatchSession({command:{kind:`clear`},sessionId:e})},async reset(n){return await t.dispatchSession({command:{kind:`reset`,reason:n?.reason},sessionId:e})},async getEventStream(n){return t.getEventStream(e,n)},async getStreamTailIndex(){return t.getStreamTailIndex(e)}}}function createAttachSessionFn(e,t={}){return n=>createSession(n,e,t)}function createDelivery(e){return e.channelKind!==void 0&&e.channelName!==void 0?createChannelDeliveryMetadata(e):void 0}function buildSessionHandle(e){return{get id(){return e.get(SessionIdKey)??``},get auth(){return{current:e.get(AuthKey)??null,initiator:e.get(InitiatorAuthKey)??null}},get continuation(){let t=e.get(ContinuationTokenKey);if(t!==void 0&&t.length!==0)return{token:toChannelLocalContinuationToken(t),alias(n){if(n.length===0)throw Error(`A session alias requires a nonempty token.`);let r=namespaceContinuationToken(t,n);t!==r&&(e.set(ContinuationHookTokensKey,e=>{let n=e??[t];return n.includes(r)?n:[...n,r]}),e.set(ContinuationTokenKey,r))}}}}}function namespaceContinuationToken(e,t){let n=e.indexOf(`:`);if(n<=0)throw Error(`Cannot set session continuation token without an existing namespaced continuation token. Start the session with a placeholder continuationToken.`);return`${e.slice(0,n+1)}${t}`}function sessionCallbackToTurnCaller(e,t){return e===void 0?void 0:{activityObserver:t,callId:e.callId,replyTo:{kind:`callback`,token:e.token,url:e.url},subagentName:e.subagentName,taskId:e.taskId}}export{buildSessionHandle,createAttachSessionFn,createSession,sessionCallbackToTurnCaller};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UserContent } from "ai";
|
|
2
|
-
import type { SessionInboxAddress } from "#execution/
|
|
2
|
+
import type { SessionInboxAddress } from "#execution/session-inbox/address.js";
|
|
3
3
|
import type { MessageStreamEvent, UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
4
4
|
import type { CancelTurnResult as ProtocolCancelTurnResult } from "#protocol/cancel-turn.js";
|
|
5
5
|
import type { RunMode } from "#shared/run-mode.js";
|
|
@@ -255,6 +255,8 @@ export interface DeliverHookPayload {
|
|
|
255
255
|
/** Internal deadline signal sent through the stable session command inbox. */
|
|
256
256
|
export interface SessionTimeoutHookPayload {
|
|
257
257
|
readonly kind: "session-timeout";
|
|
258
|
+
/** The owner run that armed this timer; a later owner ignores a predecessor's deadline. */
|
|
259
|
+
readonly ownerRunId: string;
|
|
258
260
|
}
|
|
259
261
|
/** Requests a context compaction without delivering model input. */
|
|
260
262
|
export interface CompactSessionHookPayload {
|
|
@@ -428,10 +430,11 @@ export interface RunInput {
|
|
|
428
430
|
readonly activityObserver?: ActivityObserverConfig;
|
|
429
431
|
/**
|
|
430
432
|
* Session continuation token for delivery and hook creation. Channels can
|
|
431
|
-
*
|
|
432
|
-
* `ctx.session.continuation.
|
|
433
|
+
* add a continuation address during the first turn via
|
|
434
|
+
* `ctx.session.continuation.alias(...)` (e.g. Slack adopts its first
|
|
433
435
|
* post's `ts` as the thread root), so an initial placeholder token is
|
|
434
|
-
* acceptable when full identity isn't known until the first message.
|
|
436
|
+
* acceptable when full identity isn't known until the first message. Earlier
|
|
437
|
+
* addresses remain valid after an alias. ID-only
|
|
435
438
|
* transports omit this field.
|
|
436
439
|
*/
|
|
437
440
|
readonly continuationToken?: string;
|
|
@@ -21,7 +21,6 @@ const EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH = `${EVE_DEV_RUNTIME_ARTIFACT
|
|
|
21
21
|
const EVE_DEV_RUNTIME_ARTIFACTS_SUSPEND_ROUTE_PATH = `${EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}/suspend`;
|
|
22
22
|
const EVE_DEV_RUNTIME_ARTIFACTS_RESUME_ROUTE_PATH = `${EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}/resume`;
|
|
23
23
|
const EVE_CONNECTION_CALLBACK_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/connections/:name/callback/:attemptId/:token`;
|
|
24
|
-
const EVE_LEGACY_CONNECTION_CALLBACK_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/connections/:name/callback/:token`;
|
|
25
24
|
const EVE_CALLBACK_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/callback/:token`;
|
|
26
25
|
const EVE_TASK_INPUT_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/task-input/:token`;
|
|
27
26
|
const EVE_ACTIVITY_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/activity/:token`;
|
|
@@ -164,7 +163,12 @@ const modelEndpoint = z.union([
|
|
|
164
163
|
z.object({
|
|
165
164
|
kind: z.literal("gateway"),
|
|
166
165
|
connected: z.literal(true),
|
|
167
|
-
credential: z.enum([
|
|
166
|
+
credential: z.enum([
|
|
167
|
+
"api-key",
|
|
168
|
+
"oidc",
|
|
169
|
+
"oauth"
|
|
170
|
+
]),
|
|
171
|
+
team: z.optional(z.string())
|
|
168
172
|
}).strict(),
|
|
169
173
|
z.object({
|
|
170
174
|
kind: z.literal("gateway"),
|
|
@@ -669,6 +673,11 @@ function incrementRandom(bytes) {
|
|
|
669
673
|
const EVE_SESSION_ID_HEADER = "x-eve-session-id";
|
|
670
674
|
const EVE_STREAM_TAIL_INDEX_HEADER = "x-eve-stream-tail-index";
|
|
671
675
|
const EVE_STREAM_VERSION_HEADER = "x-eve-stream-version";
|
|
676
|
+
const EVE_STREAM_CONTROL_VERSION_QUERY = "streamControlVersion";
|
|
677
|
+
const EVE_STREAM_LEASE_ENDED_CONTROL = {
|
|
678
|
+
$eve: "stream.lease-ended",
|
|
679
|
+
version: 1
|
|
680
|
+
};
|
|
672
681
|
const textEncoder = new TextEncoder();
|
|
673
682
|
function isCurrentTurnBoundaryEvent(event) {
|
|
674
683
|
return event.type === "session.completed" || event.type === "session.failed" || event.type === "session.waiting";
|
|
@@ -897,20 +906,32 @@ async function* readNdjsonStream(body, options) {
|
|
|
897
906
|
while (newlineIndex !== -1) {
|
|
898
907
|
const line = buffer.slice(0, newlineIndex).trim();
|
|
899
908
|
buffer = buffer.slice(newlineIndex + 1);
|
|
900
|
-
if (line.length > 0)
|
|
909
|
+
if (line.length > 0) {
|
|
910
|
+
const value = JSON.parse(line);
|
|
911
|
+
if (options.controlVersion === "1" && isLeaseEndedControl(value)) options.onLeaseEnded?.();
|
|
912
|
+
else yield parseMessageStreamEvent(value, options.streamVersion);
|
|
913
|
+
}
|
|
901
914
|
newlineIndex = buffer.indexOf("\n");
|
|
902
915
|
}
|
|
903
916
|
}
|
|
904
917
|
const trailing = buffer.trim();
|
|
905
|
-
if (trailing.length > 0)
|
|
918
|
+
if (trailing.length > 0) {
|
|
919
|
+
const value = JSON.parse(trailing);
|
|
920
|
+
if (options.controlVersion === "1" && isLeaseEndedControl(value)) options.onLeaseEnded?.();
|
|
921
|
+
else yield parseMessageStreamEvent(value, options.streamVersion);
|
|
922
|
+
}
|
|
906
923
|
} finally {
|
|
907
924
|
if (!reachedEof) reader.cancel().catch(() => {});
|
|
908
925
|
reader.releaseLock();
|
|
909
926
|
}
|
|
910
927
|
}
|
|
911
|
-
function
|
|
912
|
-
|
|
913
|
-
|
|
928
|
+
function isLeaseEndedControl(value) {
|
|
929
|
+
if (value === null || typeof value !== "object") return false;
|
|
930
|
+
const record = value;
|
|
931
|
+
return record.$eve === EVE_STREAM_LEASE_ENDED_CONTROL.$eve && record.version === EVE_STREAM_LEASE_ENDED_CONTROL.version;
|
|
932
|
+
}
|
|
933
|
+
function parseMessageStreamEvent(value, version) {
|
|
934
|
+
return normalizeMessageStreamEvent(version, value);
|
|
914
935
|
}
|
|
915
936
|
async function readWithIdleTimeout(reader, idleTimeoutMs) {
|
|
916
937
|
let timeout;
|
|
@@ -1068,9 +1089,14 @@ async function* followStreamIterable(input) {
|
|
|
1068
1089
|
return;
|
|
1069
1090
|
}
|
|
1070
1091
|
let deliveredEvent = false;
|
|
1092
|
+
let leaseEnded = false;
|
|
1071
1093
|
try {
|
|
1072
1094
|
for await (const event of readNdjsonStream(connection.body, {
|
|
1095
|
+
controlVersion: connection.controlVersion,
|
|
1073
1096
|
idleTimeoutMs: input.streamReadIdleTimeoutMs ?? DEFAULT_STREAM_READ_IDLE_TIMEOUT_MS,
|
|
1097
|
+
onLeaseEnded: () => {
|
|
1098
|
+
leaseEnded = true;
|
|
1099
|
+
},
|
|
1074
1100
|
streamVersion: connection.streamVersion
|
|
1075
1101
|
})) {
|
|
1076
1102
|
startIndex += 1;
|
|
@@ -1086,6 +1112,7 @@ async function* followStreamIterable(input) {
|
|
|
1086
1112
|
connection.close();
|
|
1087
1113
|
}
|
|
1088
1114
|
if (input.signal?.aborted || input.startIndex < 0 || idleRetryPolicy.maxAttempts === 0) return;
|
|
1115
|
+
if (leaseEnded) continue;
|
|
1089
1116
|
if (input.keepAlive !== true && !deliveredEvent && !initialConnection && (idleReconnects += 1) >= idleRetryPolicy.maxAttempts) return;
|
|
1090
1117
|
initialConnection = false;
|
|
1091
1118
|
await sleep(reconnectDelayMs, input.signal);
|
|
@@ -1094,13 +1121,15 @@ async function* followStreamIterable(input) {
|
|
|
1094
1121
|
}
|
|
1095
1122
|
}
|
|
1096
1123
|
async function openStreamBody(input) {
|
|
1097
|
-
const retryPolicy = input.retryPolicy ??
|
|
1124
|
+
const retryPolicy = input.retryPolicy ?? resolveStreamReconnectPolicy(input.streamReconnectPolicy);
|
|
1098
1125
|
const openRetryPolicy = retryPolicy.streamOpenReconnectPolicy;
|
|
1099
1126
|
let lastStatus;
|
|
1100
1127
|
let lastBody;
|
|
1101
1128
|
let lastHeaders;
|
|
1102
1129
|
let retryDelayMs = openRetryPolicy.baseDelayMs;
|
|
1130
|
+
const controlVersion = input.startIndex >= 0 && retryPolicy.streamIdleReconnectPolicy.maxAttempts > 0 ? "1" : void 0;
|
|
1103
1131
|
const searchParams = {};
|
|
1132
|
+
if (controlVersion !== void 0) searchParams[EVE_STREAM_CONTROL_VERSION_QUERY] = controlVersion;
|
|
1104
1133
|
if (input.startIndex !== 0) searchParams.startIndex = String(input.startIndex);
|
|
1105
1134
|
if (input.requestTailIndex === true) searchParams.includeTailIndex = "1";
|
|
1106
1135
|
for (let attempt = 0; attempt < openRetryPolicy.maxAttempts; attempt += 1) {
|
|
@@ -1133,6 +1162,7 @@ async function openStreamBody(input) {
|
|
|
1133
1162
|
response.body?.cancel().catch(() => {});
|
|
1134
1163
|
connectionController.abort();
|
|
1135
1164
|
},
|
|
1165
|
+
controlVersion,
|
|
1136
1166
|
streamVersion: readMessageStreamVersion(response.headers),
|
|
1137
1167
|
tailIndex: parseTailIndexHeader(response.headers)
|
|
1138
1168
|
};
|
|
@@ -1881,6 +1911,7 @@ var EveAgentStore = class {
|
|
|
1881
1911
|
completion: completion.promise,
|
|
1882
1912
|
followUpDispatches: /* @__PURE__ */ new Set(),
|
|
1883
1913
|
receivedFollowUps: 0,
|
|
1914
|
+
followUpSubmissionIds: /* @__PURE__ */ new Set(),
|
|
1884
1915
|
resolveCompletion: completion.resolve,
|
|
1885
1916
|
response: response.promise,
|
|
1886
1917
|
resolveResponse: response.resolve
|
|
@@ -1956,6 +1987,7 @@ var EveAgentStore = class {
|
|
|
1956
1987
|
completion: completion.promise,
|
|
1957
1988
|
followUpDispatches: /* @__PURE__ */ new Set(),
|
|
1958
1989
|
receivedFollowUps: 0,
|
|
1990
|
+
followUpSubmissionIds: /* @__PURE__ */ new Set(),
|
|
1959
1991
|
resolveCompletion: completion.resolve,
|
|
1960
1992
|
response: response.promise,
|
|
1961
1993
|
resolveResponse: response.resolve
|
|
@@ -2055,12 +2087,13 @@ var EveAgentStore = class {
|
|
|
2055
2087
|
this.#publish();
|
|
2056
2088
|
}
|
|
2057
2089
|
async #sendFollowUp(turn, input) {
|
|
2058
|
-
if (input.message === void 0 || input.turnPolicy !== "steer") throw new Error("eve session is already processing a turn. Send a message with turnPolicy: \"steer\" to
|
|
2090
|
+
if (input.message === void 0 || input.turnPolicy !== "steer") throw new Error("eve session is already processing a turn. Send a message with turnPolicy: \"steer\" to guide it at the next boundary.");
|
|
2059
2091
|
const preparedInput = await this.#callbacks.prepareSend?.(input) ?? input;
|
|
2060
2092
|
assertExclusiveTurnInput(preparedInput);
|
|
2061
2093
|
if (preparedInput.message === void 0 || preparedInput.turnPolicy !== "steer") throw new Error("An in-flight follow-up requires a message with turnPolicy: \"steer\".");
|
|
2062
2094
|
if (!this.#isActiveTurn(turn)) return await this.send(preparedInput);
|
|
2063
2095
|
const submissionId = this.#projectOptimisticMessage(preparedInput);
|
|
2096
|
+
if (submissionId !== void 0) turn.followUpSubmissionIds.add(submissionId);
|
|
2064
2097
|
this.#publish();
|
|
2065
2098
|
let dispatch;
|
|
2066
2099
|
dispatch = (async () => {
|
|
@@ -2087,7 +2120,6 @@ var EveAgentStore = class {
|
|
|
2087
2120
|
if (turn.receivedFollowUps >= turn.acceptedFollowUps || this.#session === void 0) return;
|
|
2088
2121
|
for await (const event of this.#session.stream({ signal: turn.abortController.signal })) {
|
|
2089
2122
|
if (!this.#isActiveTurn(turn)) return;
|
|
2090
|
-
if (event.type === "message.received") turn.receivedFollowUps += 1;
|
|
2091
2123
|
this.#acceptServerEvent(event);
|
|
2092
2124
|
if (isCurrentTurnBoundaryEvent(event)) {
|
|
2093
2125
|
while (turn.followUpDispatches.size > 0) await Promise.allSettled(turn.followUpDispatches);
|
|
@@ -2120,7 +2152,7 @@ var EveAgentStore = class {
|
|
|
2120
2152
|
return this.#activeTurn === turn;
|
|
2121
2153
|
}
|
|
2122
2154
|
#projectOptimisticMessage(input) {
|
|
2123
|
-
if (
|
|
2155
|
+
if (input.message === void 0) return;
|
|
2124
2156
|
const id = createSubmissionId();
|
|
2125
2157
|
const pending = {
|
|
2126
2158
|
createdAt: Date.now(),
|
|
@@ -2128,7 +2160,7 @@ var EveAgentStore = class {
|
|
|
2128
2160
|
message: summarizeUserContent(input.message)
|
|
2129
2161
|
};
|
|
2130
2162
|
this.#pendingMessageSubmissions = [...this.#pendingMessageSubmissions, pending];
|
|
2131
|
-
this.#appendProjectionEvent({
|
|
2163
|
+
if (this.#optimistic) this.#appendProjectionEvent({
|
|
2132
2164
|
data: {
|
|
2133
2165
|
createdAt: pending.createdAt,
|
|
2134
2166
|
message: pending.message,
|
|
@@ -2161,6 +2193,7 @@ var EveAgentStore = class {
|
|
|
2161
2193
|
const pendingSubmission = this.#pendingMessageSubmissions[0];
|
|
2162
2194
|
if (event.type === "message.received" && pendingSubmission !== void 0) {
|
|
2163
2195
|
const submissionId = pendingSubmission.id;
|
|
2196
|
+
if (this.#activeTurn?.followUpSubmissionIds.delete(submissionId)) this.#activeTurn.receivedFollowUps += 1;
|
|
2164
2197
|
this.#pendingMessageSubmissions = this.#pendingMessageSubmissions.slice(1);
|
|
2165
2198
|
this.#replaceProjectionEvent((candidate) => candidate.type === "client.message.submitted" && candidate.data.submissionId === submissionId, event);
|
|
2166
2199
|
return;
|
|
@@ -21,7 +21,6 @@ const EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH = `${EVE_DEV_RUNTIME_ARTIFACT
|
|
|
21
21
|
const EVE_DEV_RUNTIME_ARTIFACTS_SUSPEND_ROUTE_PATH = `${EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}/suspend`;
|
|
22
22
|
const EVE_DEV_RUNTIME_ARTIFACTS_RESUME_ROUTE_PATH = `${EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}/resume`;
|
|
23
23
|
const EVE_CONNECTION_CALLBACK_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/connections/:name/callback/:attemptId/:token`;
|
|
24
|
-
const EVE_LEGACY_CONNECTION_CALLBACK_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/connections/:name/callback/:token`;
|
|
25
24
|
const EVE_CALLBACK_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/callback/:token`;
|
|
26
25
|
const EVE_TASK_INPUT_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/task-input/:token`;
|
|
27
26
|
const EVE_ACTIVITY_ROUTE_PATTERN = `${EVE_ROUTE_PREFIX}/activity/:token`;
|
|
@@ -164,7 +163,12 @@ const modelEndpoint = z.union([
|
|
|
164
163
|
z.object({
|
|
165
164
|
kind: z.literal("gateway"),
|
|
166
165
|
connected: z.literal(true),
|
|
167
|
-
credential: z.enum([
|
|
166
|
+
credential: z.enum([
|
|
167
|
+
"api-key",
|
|
168
|
+
"oidc",
|
|
169
|
+
"oauth"
|
|
170
|
+
]),
|
|
171
|
+
team: z.optional(z.string())
|
|
168
172
|
}).strict(),
|
|
169
173
|
z.object({
|
|
170
174
|
kind: z.literal("gateway"),
|
|
@@ -669,6 +673,11 @@ function incrementRandom(bytes) {
|
|
|
669
673
|
const EVE_SESSION_ID_HEADER = "x-eve-session-id";
|
|
670
674
|
const EVE_STREAM_TAIL_INDEX_HEADER = "x-eve-stream-tail-index";
|
|
671
675
|
const EVE_STREAM_VERSION_HEADER = "x-eve-stream-version";
|
|
676
|
+
const EVE_STREAM_CONTROL_VERSION_QUERY = "streamControlVersion";
|
|
677
|
+
const EVE_STREAM_LEASE_ENDED_CONTROL = {
|
|
678
|
+
$eve: "stream.lease-ended",
|
|
679
|
+
version: 1
|
|
680
|
+
};
|
|
672
681
|
const textEncoder = new TextEncoder();
|
|
673
682
|
function isCurrentTurnBoundaryEvent(event) {
|
|
674
683
|
return event.type === "session.completed" || event.type === "session.failed" || event.type === "session.waiting";
|
|
@@ -897,20 +906,32 @@ async function* readNdjsonStream(body, options) {
|
|
|
897
906
|
while (newlineIndex !== -1) {
|
|
898
907
|
const line = buffer.slice(0, newlineIndex).trim();
|
|
899
908
|
buffer = buffer.slice(newlineIndex + 1);
|
|
900
|
-
if (line.length > 0)
|
|
909
|
+
if (line.length > 0) {
|
|
910
|
+
const value = JSON.parse(line);
|
|
911
|
+
if (options.controlVersion === "1" && isLeaseEndedControl(value)) options.onLeaseEnded?.();
|
|
912
|
+
else yield parseMessageStreamEvent(value, options.streamVersion);
|
|
913
|
+
}
|
|
901
914
|
newlineIndex = buffer.indexOf("\n");
|
|
902
915
|
}
|
|
903
916
|
}
|
|
904
917
|
const trailing = buffer.trim();
|
|
905
|
-
if (trailing.length > 0)
|
|
918
|
+
if (trailing.length > 0) {
|
|
919
|
+
const value = JSON.parse(trailing);
|
|
920
|
+
if (options.controlVersion === "1" && isLeaseEndedControl(value)) options.onLeaseEnded?.();
|
|
921
|
+
else yield parseMessageStreamEvent(value, options.streamVersion);
|
|
922
|
+
}
|
|
906
923
|
} finally {
|
|
907
924
|
if (!reachedEof) reader.cancel().catch(() => {});
|
|
908
925
|
reader.releaseLock();
|
|
909
926
|
}
|
|
910
927
|
}
|
|
911
|
-
function
|
|
912
|
-
|
|
913
|
-
|
|
928
|
+
function isLeaseEndedControl(value) {
|
|
929
|
+
if (value === null || typeof value !== "object") return false;
|
|
930
|
+
const record = value;
|
|
931
|
+
return record.$eve === EVE_STREAM_LEASE_ENDED_CONTROL.$eve && record.version === EVE_STREAM_LEASE_ENDED_CONTROL.version;
|
|
932
|
+
}
|
|
933
|
+
function parseMessageStreamEvent(value, version) {
|
|
934
|
+
return normalizeMessageStreamEvent(version, value);
|
|
914
935
|
}
|
|
915
936
|
async function readWithIdleTimeout(reader, idleTimeoutMs) {
|
|
916
937
|
let timeout;
|
|
@@ -1068,9 +1089,14 @@ async function* followStreamIterable(input) {
|
|
|
1068
1089
|
return;
|
|
1069
1090
|
}
|
|
1070
1091
|
let deliveredEvent = false;
|
|
1092
|
+
let leaseEnded = false;
|
|
1071
1093
|
try {
|
|
1072
1094
|
for await (const event of readNdjsonStream(connection.body, {
|
|
1095
|
+
controlVersion: connection.controlVersion,
|
|
1073
1096
|
idleTimeoutMs: input.streamReadIdleTimeoutMs ?? DEFAULT_STREAM_READ_IDLE_TIMEOUT_MS,
|
|
1097
|
+
onLeaseEnded: () => {
|
|
1098
|
+
leaseEnded = true;
|
|
1099
|
+
},
|
|
1074
1100
|
streamVersion: connection.streamVersion
|
|
1075
1101
|
})) {
|
|
1076
1102
|
startIndex += 1;
|
|
@@ -1086,6 +1112,7 @@ async function* followStreamIterable(input) {
|
|
|
1086
1112
|
connection.close();
|
|
1087
1113
|
}
|
|
1088
1114
|
if (input.signal?.aborted || input.startIndex < 0 || idleRetryPolicy.maxAttempts === 0) return;
|
|
1115
|
+
if (leaseEnded) continue;
|
|
1089
1116
|
if (input.keepAlive !== true && !deliveredEvent && !initialConnection && (idleReconnects += 1) >= idleRetryPolicy.maxAttempts) return;
|
|
1090
1117
|
initialConnection = false;
|
|
1091
1118
|
await sleep(reconnectDelayMs, input.signal);
|
|
@@ -1094,13 +1121,15 @@ async function* followStreamIterable(input) {
|
|
|
1094
1121
|
}
|
|
1095
1122
|
}
|
|
1096
1123
|
async function openStreamBody(input) {
|
|
1097
|
-
const retryPolicy = input.retryPolicy ??
|
|
1124
|
+
const retryPolicy = input.retryPolicy ?? resolveStreamReconnectPolicy(input.streamReconnectPolicy);
|
|
1098
1125
|
const openRetryPolicy = retryPolicy.streamOpenReconnectPolicy;
|
|
1099
1126
|
let lastStatus;
|
|
1100
1127
|
let lastBody;
|
|
1101
1128
|
let lastHeaders;
|
|
1102
1129
|
let retryDelayMs = openRetryPolicy.baseDelayMs;
|
|
1130
|
+
const controlVersion = input.startIndex >= 0 && retryPolicy.streamIdleReconnectPolicy.maxAttempts > 0 ? "1" : void 0;
|
|
1103
1131
|
const searchParams = {};
|
|
1132
|
+
if (controlVersion !== void 0) searchParams[EVE_STREAM_CONTROL_VERSION_QUERY] = controlVersion;
|
|
1104
1133
|
if (input.startIndex !== 0) searchParams.startIndex = String(input.startIndex);
|
|
1105
1134
|
if (input.requestTailIndex === true) searchParams.includeTailIndex = "1";
|
|
1106
1135
|
for (let attempt = 0; attempt < openRetryPolicy.maxAttempts; attempt += 1) {
|
|
@@ -1133,6 +1162,7 @@ async function openStreamBody(input) {
|
|
|
1133
1162
|
response.body?.cancel().catch(() => {});
|
|
1134
1163
|
connectionController.abort();
|
|
1135
1164
|
},
|
|
1165
|
+
controlVersion,
|
|
1136
1166
|
streamVersion: readMessageStreamVersion(response.headers),
|
|
1137
1167
|
tailIndex: parseTailIndexHeader(response.headers)
|
|
1138
1168
|
};
|
|
@@ -1881,6 +1911,7 @@ var EveAgentStore = class {
|
|
|
1881
1911
|
completion: completion.promise,
|
|
1882
1912
|
followUpDispatches: /* @__PURE__ */ new Set(),
|
|
1883
1913
|
receivedFollowUps: 0,
|
|
1914
|
+
followUpSubmissionIds: /* @__PURE__ */ new Set(),
|
|
1884
1915
|
resolveCompletion: completion.resolve,
|
|
1885
1916
|
response: response.promise,
|
|
1886
1917
|
resolveResponse: response.resolve
|
|
@@ -1956,6 +1987,7 @@ var EveAgentStore = class {
|
|
|
1956
1987
|
completion: completion.promise,
|
|
1957
1988
|
followUpDispatches: /* @__PURE__ */ new Set(),
|
|
1958
1989
|
receivedFollowUps: 0,
|
|
1990
|
+
followUpSubmissionIds: /* @__PURE__ */ new Set(),
|
|
1959
1991
|
resolveCompletion: completion.resolve,
|
|
1960
1992
|
response: response.promise,
|
|
1961
1993
|
resolveResponse: response.resolve
|
|
@@ -2055,12 +2087,13 @@ var EveAgentStore = class {
|
|
|
2055
2087
|
this.#publish();
|
|
2056
2088
|
}
|
|
2057
2089
|
async #sendFollowUp(turn, input) {
|
|
2058
|
-
if (input.message === void 0 || input.turnPolicy !== "steer") throw new Error("eve session is already processing a turn. Send a message with turnPolicy: \"steer\" to
|
|
2090
|
+
if (input.message === void 0 || input.turnPolicy !== "steer") throw new Error("eve session is already processing a turn. Send a message with turnPolicy: \"steer\" to guide it at the next boundary.");
|
|
2059
2091
|
const preparedInput = await this.#callbacks.prepareSend?.(input) ?? input;
|
|
2060
2092
|
assertExclusiveTurnInput(preparedInput);
|
|
2061
2093
|
if (preparedInput.message === void 0 || preparedInput.turnPolicy !== "steer") throw new Error("An in-flight follow-up requires a message with turnPolicy: \"steer\".");
|
|
2062
2094
|
if (!this.#isActiveTurn(turn)) return await this.send(preparedInput);
|
|
2063
2095
|
const submissionId = this.#projectOptimisticMessage(preparedInput);
|
|
2096
|
+
if (submissionId !== void 0) turn.followUpSubmissionIds.add(submissionId);
|
|
2064
2097
|
this.#publish();
|
|
2065
2098
|
let dispatch;
|
|
2066
2099
|
dispatch = (async () => {
|
|
@@ -2087,7 +2120,6 @@ var EveAgentStore = class {
|
|
|
2087
2120
|
if (turn.receivedFollowUps >= turn.acceptedFollowUps || this.#session === void 0) return;
|
|
2088
2121
|
for await (const event of this.#session.stream({ signal: turn.abortController.signal })) {
|
|
2089
2122
|
if (!this.#isActiveTurn(turn)) return;
|
|
2090
|
-
if (event.type === "message.received") turn.receivedFollowUps += 1;
|
|
2091
2123
|
this.#acceptServerEvent(event);
|
|
2092
2124
|
if (isCurrentTurnBoundaryEvent(event)) {
|
|
2093
2125
|
while (turn.followUpDispatches.size > 0) await Promise.allSettled(turn.followUpDispatches);
|
|
@@ -2120,7 +2152,7 @@ var EveAgentStore = class {
|
|
|
2120
2152
|
return this.#activeTurn === turn;
|
|
2121
2153
|
}
|
|
2122
2154
|
#projectOptimisticMessage(input) {
|
|
2123
|
-
if (
|
|
2155
|
+
if (input.message === void 0) return;
|
|
2124
2156
|
const id = createSubmissionId();
|
|
2125
2157
|
const pending = {
|
|
2126
2158
|
createdAt: Date.now(),
|
|
@@ -2128,7 +2160,7 @@ var EveAgentStore = class {
|
|
|
2128
2160
|
message: summarizeUserContent(input.message)
|
|
2129
2161
|
};
|
|
2130
2162
|
this.#pendingMessageSubmissions = [...this.#pendingMessageSubmissions, pending];
|
|
2131
|
-
this.#appendProjectionEvent({
|
|
2163
|
+
if (this.#optimistic) this.#appendProjectionEvent({
|
|
2132
2164
|
data: {
|
|
2133
2165
|
createdAt: pending.createdAt,
|
|
2134
2166
|
message: pending.message,
|
|
@@ -2161,6 +2193,7 @@ var EveAgentStore = class {
|
|
|
2161
2193
|
const pendingSubmission = this.#pendingMessageSubmissions[0];
|
|
2162
2194
|
if (event.type === "message.received" && pendingSubmission !== void 0) {
|
|
2163
2195
|
const submissionId = pendingSubmission.id;
|
|
2196
|
+
if (this.#activeTurn?.followUpSubmissionIds.delete(submissionId)) this.#activeTurn.receivedFollowUps += 1;
|
|
2164
2197
|
this.#pendingMessageSubmissions = this.#pendingMessageSubmissions.slice(1);
|
|
2165
2198
|
this.#replaceProjectionEvent((candidate) => candidate.type === "client.message.submitted" && candidate.data.submissionId === submissionId, event);
|
|
2166
2199
|
return;
|
|
@@ -7,8 +7,7 @@ import { ensureChannel, scaffoldBaseProject } from "#setup/scaffold/index.js";
|
|
|
7
7
|
import { validateModelSlug } from "#setup/flows/model-source-change.js";
|
|
8
8
|
import { type InitCliLogger, type InitCommandOptions } from "./init-agent-workspace.js";
|
|
9
9
|
import { tryInitializeGit } from "./init-git.js";
|
|
10
|
-
import {
|
|
11
|
-
import { selectInitHandoff, spawnCodingAgentRepl } from "./init-repl.js";
|
|
10
|
+
import { hasInteractiveTerminal } from "./preconditions.js";
|
|
12
11
|
export type { InitCliLogger, InitCommandOptions } from "./init-agent-workspace.js";
|
|
13
12
|
export interface InitCommandDependencies {
|
|
14
13
|
addAgentToProject: typeof addAgentToProject;
|
|
@@ -19,10 +18,7 @@ export interface InitCommandDependencies {
|
|
|
19
18
|
now: () => number;
|
|
20
19
|
runPackageManagerInstall: typeof runPackageManagerInstall;
|
|
21
20
|
scaffoldBaseProject: typeof scaffoldBaseProject;
|
|
22
|
-
|
|
23
|
-
selectInitSelfModification: typeof selectInitSelfModification;
|
|
24
|
-
installSelfModification(appRoot: string): Promise<void>;
|
|
25
|
-
spawnCodingAgentRepl: typeof spawnCodingAgentRepl;
|
|
21
|
+
hasInteractiveTerminal: typeof hasInteractiveTerminal;
|
|
26
22
|
spawnPackageManager: typeof spawnPackageManager;
|
|
27
23
|
tryInitializeGit: typeof tryInitializeGit;
|
|
28
24
|
validateModelSlug: typeof validateModelSlug;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initAgentDevHandoff,initAgentReadySummary,initAgentReplPrompt}from"./agent-instructions.js";import{tryInitializeGit}from"./init-git.js";import{InitTargetError}from"./init-telemetry.js";import{addAgentsToWorkspace,convertScaffoldToAgentWorkspace,formatWorkspaceRootMutationWarning}from"./init-agent-workspace.js";import{NPM_NOISE_LINE,installProgressDetail,packageManagerInstallFailureCode}from"./init-install.js";import{reportExistingProjectChanges}from"./init-project.js";import{cleanupFreshInitTarget,workspaceFailureNote}from"./init-recovery.js";import{selectInitHandoff,spawnCodingAgentRepl}from"./init-repl.js";import{selectInitSelfModification}from"./init-self-modification.js";import{resolveInitTarget}from"./init-target.js";import{mkdtemp,readdir,rename,rm}from"node:fs/promises";import{createLogger,isLogLevelEnabled}from"#internal/logging.js";import{basename,join,resolve}from"node:path";import pc from"#compiled/picocolors/index.js";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{ensureChannel,scaffoldBaseProject}from"#setup/scaffold/index.js";import{eveDevArguments,packageManagerInstallFailureMessage,packageManagerInstallSucceeded,resultSucceeded,runPackageManagerInstall,spawnPackageManager}from"#setup/primitives/index.js";import{performance}from"node:perf_hooks";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{EVE_WORDMARK}from"#cli/banner.js";import{formatElapsed}from"#cli/format-elapsed.js";import{startCliLiveRow}from"#cli/ui/live-row.js";import{detectInvokingPackageManager,detectPackageManager}from"#setup/package-manager.js";import{pathExists}from"#setup/path-exists.js";import{DEFAULT_EVE_PACKAGE_CONTRACT}from"#setup/scaffold/create/project.js";import{validateModelSlug}from"#setup/flows/model-source-change.js";import{addAgentToProject}from"#setup/scaffold/create/add-to-project.js";import{WizardCancelledError}from"#setup/step.js";import{isPackageManagerWorkspaceMember}from"#setup/scaffold/workspace-root.js";const defaultDependencies={addAgentToProject,detectInvokingPackageManager,detectPackageManager,ensureChannel,isCodingAgentLaunch,now:()=>performance.now(),runPackageManagerInstall,scaffoldBaseProject,selectInitHandoff,selectInitSelfModification,installSelfModification:async e=>{let{installRegistryItem:t}=await import(`./registry.js`);await t(e,`eve/self-modification`,{silent:!0,skipSetup:!0})},spawnCodingAgentRepl,spawnPackageManager,tryInitializeGit,validateModelSlug},EVE_INIT_PACKAGE_SPEC_ENV=`EVE_INIT_PACKAGE_SPEC`,initLog=createLogger(`init`);async function moveDirectoryContents(e,t){for(let n of await readdir(e))await rename(join(e,n),join(t,n))}function uniqueWorkspaceRootMutations(e){let t=new Map;for(let n of e){let e=`${n.kind}:${n.path}`,r=t.get(e);t.set(e,{...n,nodeEngineOverride:n.nodeEngineOverride??r?.nodeEngineOverride})}return[...t.values()]}async function addToExistingProject(e,t,n,r){if(t.channelWebNextjs===!0)throw Error("`--channel-web-nextjs` is not supported when adding an agent to an existing project. Run `eve add channel/web` from the project afterwards instead.");if(t.model!==void 0){let r=await n.validateModelSlug(e,t.model);if(r!==null)throw Error(r)}let i=await n.detectPackageManager(e),a=await n.addAgentToProject({projectRoot:e,model:t.model??DEFAULT_AGENT_MODEL_ID,reasoning:t.reasoning,packageManager:i.kind,evePackage:r});return{configurationFilesChanged:a.configurationFilesChanged,dependenciesAdded:a.dependenciesAdded,filesWritten:a.filesWritten,packageManager:i.kind,nodeEngineOverride:a.nodeEngineOverride}}async function resolveScaffoldPackageManager(e,t){let n=await t.detectPackageManager(e);return n.source==="default"?t.detectInvokingPackageManager()??`pnpm`:n.kind}async function scaffoldProject(e,t,n,r,i,a,o,s){let c=resolve(e,`..`),l=!n&&await pathExists(e)&&(await readdir(e)).length===0;if(!n&&await pathExists(e)&&!l)throw Error(`Cannot create project because "${e}" already exists.`);let u=n&&s?void 0:await mkdtemp(join(c,`.eve-init-`)),d=[];try{let c=u??e;if(i.model!==void 0){let e=await a.validateModelSlug(c,i.model);if(e!==null)throw Error(e)}let f={projectName:u===void 0?`.`:n?basename(e):t,model:i.model??DEFAULT_AGENT_MODEL_ID,reasoning:i.reasoning,evePackage:o,targetDirectory:c,overwriteExisting:s,workspaceProbeDirectory:e,packageManager:r,onWorkspaceRootMutation:e=>{d.push(e)}},p=await a.scaffoldBaseProject(f);return i.agents!==void 0&&await convertScaffoldToAgentWorkspace(p,i.agents,i),i.channelWebNextjs===!0&&await a.ensureChannel({projectRoot:p,kind:`web`,packageManager:r,force:s,workspaceProbeDirectory:e,configureVercelServices:!1,onWorkspaceRootMutation:e=>{d.push(e)}}),u!==void 0&&(n||l?await moveDirectoryContents(p,e):await rename(p,e)),{projectPath:e,workspaceRootMutations:uniqueWorkspaceRootMutations(d)}}finally{u!==void 0&&await rm(u,{recursive:!0,force:!0})}}async function runInitSteps(e){let{agentLaunched:t,dependencies:n,logger:r,options:i,parentDirectory:a,target:o,trackStep:s,trackTerminal:c}=e,l=isLogLevelEnabled(`debug`),u=await resolveInitTarget({parentDirectory:a,target:o}),d=resolveInitEvePackageOverride(),f=!t&&i.agents===void 0&&await n.selectInitSelfModification(),p=startCliLiveRow(r),m=`scaffold`,h;p.update(`Preparing project`);try{let e=u.kind===`fresh`?`creating agent`:`adding agent`;s?.(m),p.update(u.kind===`fresh`?`Creating agent`:`Adding agent`),initLog.debug(e);let a=n.now(),o;if(u.kind===`fresh`){let e=await resolveScaffoldPackageManager(u.projectPath,n),t=isPackageManagerWorkspaceMember(e,u.projectPath),r;try{r=await scaffoldProject(u.projectPath,u.projectName,u.createInPlace,e,i,n,d,u.overwriteExisting)}catch(e){if(u.failurePolicy===`clear`){let n=await cleanupFreshInitTarget(u.projectPath,u.failurePolicy,u.preservedEntries),r=e instanceof Error?e.message:String(e),i=n?`eve restored "${u.projectPath}" to its original state.`:`eve could not completely clean "${u.projectPath}".`;throw Error(`${r}\n\n${i}${workspaceFailureNote(t)}`)}if(u.failurePolicy===`remove`&&t){let t=e instanceof Error?e.message:String(e);throw Error(`${t}${workspaceFailureNote(!0)}`)}throw e}o={failurePolicy:u.failurePolicy,kind:`created`,packageManager:e,preservedTargetEntries:u.preservedEntries,projectPath:r.projectPath,retryCommand:`eve init ${u.projectPath}`,workspaceMember:t,workspaceRootMutations:r.workspaceRootMutations}}else{let e=await addToExistingProject(u.projectPath,i,n,d);o=e.nodeEngineOverride===void 0?{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,packageManager:e.packageManager,projectPath:u.projectPath}:{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,nodeEngineOverride:e.nodeEngineOverride,packageManager:e.packageManager,projectPath:u.projectPath}}let c=n.now()-a;initLog.debug(`${e} done`,{ms:c}),o.kind===`added`&&(p.stop(),reportExistingProjectChanges(r,o),p=startCliLiveRow(r)),m=`install_dependencies`,s?.(m),p.update(`Installing dependencies`,`${o.packageManager} install`),initLog.debug(`installing dependencies with ${o.packageManager}`);let g=n.now(),_=[],v=[],y=await n.runPackageManagerInstall(o.packageManager,o.projectPath,{progressDetails:process.stdout.isTTY===!0&&!l,onOutput:e=>{e.text.trim()!==``&&(v.push(e.text),v.length>20&&v.shift(),NPM_NOISE_LINE.test(e.text)||_.push(e.text)),l&&initLog.debug(e.text);let t=installProgressDetail(o.packageManager,e);t!==void 0&&p.update(`Installing dependencies`,t)}}),b=n.now()-g;if(!packageManagerInstallSucceeded(y)){h=packageManagerInstallFailureCode(y),initLog.debug(`dependency installation failed`,{ms:b}),p.stop();let e=_.length>0?_:v;for(let t of e)r.error(t);if(e.length===0){let e=packageManagerInstallFailureMessage(y);e!==void 0&&r.error(e)}if(o.failurePolicy!==`preserve`){if(await cleanupFreshInitTarget(o.projectPath,o.failurePolicy,o.preservedTargetEntries)){let e=o.failurePolicy===`remove`?`eve removed the incomplete project at "${o.projectPath}".`:`eve restored "${o.projectPath}" to its original state.`,t=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies.\n\n${e}\n\nResolve the package-manager error above, then retry:\n ${o.retryCommand}${workspaceFailureNote(t)}`)}let e=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies, and eve could not completely clean "${o.projectPath}".\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in that directory. Or clean the target manually before rerunning eve init.${workspaceFailureNote(e)}`)}throw Error(`The eve agent was added, but dependency installation failed.\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in "${o.projectPath}".\n\nDo not rerun eve init; the agent is already configured.`)}return initLog.debug(`dependencies installed`,{ms:b}),f&&(m=`registry_install`,s?.(m),p.update(`Enabling self-modification`),await n.installSelfModification(o.projectPath)),o.kind===`created`?(m=`initialize_git`,s?.(m),p.update(`Initializing Git repository`),initLog.debug(`initializing git repository`),{...o,agentElapsedMs:c,agentLaunched:t,gitResult:await n.tryInitializeGit(o.projectPath),installElapsedMs:b,selfModificationEnabled:f}):{...o,agentElapsedMs:c,agentLaunched:t,installElapsedMs:b,selfModificationEnabled:f}}catch(e){throw c?.(m,`error`,m===`install_dependencies`?h:void 0),e}finally{p.stop()}}async function runInitCommand(e,t,n,r,i=defaultDependencies,a,o){a?.(`resolve_target`);let s;try{if(await addAgentsToWorkspace(e,t,n,r,i.validateModelSlug)){a?.(`handoff`),o?.(`handoff`,`completed`);return}s=await runInitSteps({agentLaunched:await i.isCodingAgentLaunch(),dependencies:i,logger:e,options:r,parentDirectory:t,target:n,trackStep:a,trackTerminal:o})}catch(e){if(e instanceof WizardCancelledError){o?.(`resolve_target`,`cancelled`);return}throw e instanceof InitTargetError&&o?.(`resolve_target`,`error`,e.failureCode),e}if(a?.(`handoff`),s.kind===`created`){e.log(`${pc.green(`✓`)} Created an ${EVE_WORDMARK} agent in ${pc.bold(s.projectPath)} ${pc.dim(`in ${formatElapsed(s.agentElapsedMs)}`)}`);for(let t of s.workspaceRootMutations)e.log(pc.yellow(`⚠ ${formatWorkspaceRootMutationWarning(t)}`))}else e.log(`${pc.green(`✓`)} Added an ${EVE_WORDMARK} agent to ${pc.bold(s.projectPath)} ${pc.dim(`in ${formatElapsed(s.agentElapsedMs)}`)}`);e.log(`${pc.green(`✓`)} Installed dependencies ${pc.dim(`in ${formatElapsed(s.installElapsedMs)}`)}`),s.selfModificationEnabled&&e.log(`${pc.green(`✓`)} Enabled self-modification`),s.kind===`created`&&s.gitResult.kind===`failed`&&(e.error(pc.yellow(`Git initialization failed during ${s.gitResult.stage}: ${s.gitResult.reason}`)),s.gitResult.stage===`commit`&&e.error(pc.yellow(`The eve agent was created successfully. Git repository metadata and staged files were preserved at "${s.projectPath}"; the initial commit is optional.\n\nTo create it later, configure Git identity and run:\n git -C ${JSON.stringify(s.projectPath)} commit -m "Initial commit from eve"`)));let c=eveDevArguments(s.packageManager),l=[s.packageManager,...c].join(` `),u=initAgentDevHandoff({projectPath:s.projectPath,devCommand:l});if(s.agentLaunched){e.log(initAgentReadySummary(r.model,s.projectPath,{workspace:r.agents!==void 0})),e.log(u);return}let d;if(s.selfModificationEnabled)d=`eve-dev`;else try{d=await i.selectInitHandoff({agentName:basename(s.projectPath)})}catch(e){if(e instanceof WizardCancelledError)return;throw e}if(d===`exit`)return;if(d!==`eve-dev`){if(e.log(pc.dim(`$ ${d}`)),!await i.spawnCodingAgentRepl({command:d,cwd:s.projectPath,prompt:initAgentReplPrompt({devCommand:l}),onPromptUnseeded:t=>{e.log(pc.yellow(`Could not seed ${d} automatically. Paste this prompt into it:`)),e.log(t)}}))throw Error(`Coding-agent REPL exited unsuccessfully in "${s.projectPath}".`);return}let f=s.kind===`created`?[...c,`--onboard`]:c;if(e.log(pc.dim(`$ eve dev`)),!resultSucceeded(await i.spawnPackageManager(s.packageManager,s.projectPath,f)))throw Error(`Development server exited unsuccessfully in "${s.projectPath}".`)}function resolveInitEvePackageOverride(){let e=process.env[EVE_INIT_PACKAGE_SPEC_ENV]?.trim();if(e!==void 0&&e.length!==0)return{nodeEngine:DEFAULT_EVE_PACKAGE_CONTRACT.nodeEngine,version:e}}export{EVE_INIT_PACKAGE_SPEC_ENV,runInitCommand};
|
|
1
|
+
import{initAgentDevHandoff,initAgentReadySummary}from"./agent-instructions.js";import{hasInteractiveTerminal}from"./preconditions.js";import{tryInitializeGit}from"./init-git.js";import{InitTargetError}from"./init-telemetry.js";import{addAgentsToWorkspace,convertScaffoldToAgentWorkspace,formatWorkspaceRootMutationWarning}from"./init-agent-workspace.js";import{NPM_NOISE_LINE,installProgressDetail,packageManagerInstallFailureCode}from"./init-install.js";import{reportExistingProjectChanges}from"./init-project.js";import{cleanupFreshInitTarget,workspaceFailureNote}from"./init-recovery.js";import{resolveInitTarget}from"./init-target.js";import{mkdtemp,readdir,rename,rm}from"node:fs/promises";import{createLogger,isLogLevelEnabled}from"#internal/logging.js";import{basename,join,resolve}from"node:path";import pc from"#compiled/picocolors/index.js";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{ensureChannel,scaffoldBaseProject}from"#setup/scaffold/index.js";import{eveDevArguments,packageManagerInstallFailureMessage,packageManagerInstallSucceeded,resultSucceeded,runPackageManagerInstall,spawnPackageManager}from"#setup/primitives/index.js";import{performance}from"node:perf_hooks";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{EVE_WORDMARK}from"#cli/banner.js";import{formatElapsed}from"#cli/format-elapsed.js";import{startCliLiveRow}from"#cli/ui/live-row.js";import{detectInvokingPackageManager,detectPackageManager}from"#setup/package-manager.js";import{pathExists}from"#setup/path-exists.js";import{DEFAULT_EVE_PACKAGE_CONTRACT}from"#setup/scaffold/create/project.js";import{validateModelSlug}from"#setup/flows/model-source-change.js";import{addAgentToProject}from"#setup/scaffold/create/add-to-project.js";import{WizardCancelledError}from"#setup/step.js";import{isPackageManagerWorkspaceMember}from"#setup/scaffold/workspace-root.js";const defaultDependencies={addAgentToProject,detectInvokingPackageManager,detectPackageManager,ensureChannel,isCodingAgentLaunch,now:()=>performance.now(),runPackageManagerInstall,scaffoldBaseProject,hasInteractiveTerminal,spawnPackageManager,tryInitializeGit,validateModelSlug},EVE_INIT_PACKAGE_SPEC_ENV=`EVE_INIT_PACKAGE_SPEC`,initLog=createLogger(`init`);async function moveDirectoryContents(e,t){for(let n of await readdir(e))await rename(join(e,n),join(t,n))}function uniqueWorkspaceRootMutations(e){let t=new Map;for(let n of e){let e=`${n.kind}:${n.path}`,r=t.get(e);t.set(e,{...n,nodeEngineOverride:n.nodeEngineOverride??r?.nodeEngineOverride})}return[...t.values()]}async function addToExistingProject(e,t,n,r){if(t.channelWebNextjs===!0)throw Error("`--channel-web-nextjs` is not supported when adding an agent to an existing project. Run `eve add channel/web` from the project afterwards instead.");if(t.model!==void 0){let r=await n.validateModelSlug(e,t.model);if(r!==null)throw Error(r)}let i=await n.detectPackageManager(e),a=await n.addAgentToProject({projectRoot:e,model:t.model??DEFAULT_AGENT_MODEL_ID,reasoning:t.reasoning,packageManager:i.kind,evePackage:r});return{configurationFilesChanged:a.configurationFilesChanged,dependenciesAdded:a.dependenciesAdded,filesWritten:a.filesWritten,packageManager:i.kind,nodeEngineOverride:a.nodeEngineOverride}}async function resolveScaffoldPackageManager(e,t){let n=await t.detectPackageManager(e);return n.source==="default"?t.detectInvokingPackageManager()??`pnpm`:n.kind}async function scaffoldProject(e,t,n,r,i,a,o,s){let c=resolve(e,`..`),l=!n&&await pathExists(e)&&(await readdir(e)).length===0;if(!n&&await pathExists(e)&&!l)throw Error(`Cannot create project because "${e}" already exists.`);let u=n&&s?void 0:await mkdtemp(join(c,`.eve-init-`)),d=[];try{let c=u??e;if(i.model!==void 0){let e=await a.validateModelSlug(c,i.model);if(e!==null)throw Error(e)}let f={projectName:u===void 0?`.`:n?basename(e):t,model:i.model??DEFAULT_AGENT_MODEL_ID,reasoning:i.reasoning,evePackage:o,targetDirectory:c,overwriteExisting:s,workspaceProbeDirectory:e,packageManager:r,onWorkspaceRootMutation:e=>{d.push(e)}},p=await a.scaffoldBaseProject(f);return i.agents!==void 0&&await convertScaffoldToAgentWorkspace(p,i.agents,i),i.channelWebNextjs===!0&&await a.ensureChannel({projectRoot:p,kind:`web`,packageManager:r,force:s,workspaceProbeDirectory:e,configureVercelServices:!1,onWorkspaceRootMutation:e=>{d.push(e)}}),u!==void 0&&(n||l?await moveDirectoryContents(p,e):await rename(p,e)),{projectPath:e,workspaceRootMutations:uniqueWorkspaceRootMutations(d)}}finally{u!==void 0&&await rm(u,{recursive:!0,force:!0})}}async function runInitSteps(e){let{agentLaunched:t,dependencies:n,logger:r,options:i,parentDirectory:a,target:o,trackStep:s,trackTerminal:c}=e,l=isLogLevelEnabled(`debug`),u=await resolveInitTarget({parentDirectory:a,target:o}),d=resolveInitEvePackageOverride(),f=startCliLiveRow(r),p=`scaffold`,m;f.update(`Preparing project`);try{let e=u.kind===`fresh`?`creating agent`:`adding agent`;s?.(p),f.update(u.kind===`fresh`?`Creating agent`:`Adding agent`),initLog.debug(e);let a=n.now(),o;if(u.kind===`fresh`){let e=await resolveScaffoldPackageManager(u.projectPath,n),t=isPackageManagerWorkspaceMember(e,u.projectPath),r;try{r=await scaffoldProject(u.projectPath,u.projectName,u.createInPlace,e,i,n,d,u.overwriteExisting)}catch(e){if(u.failurePolicy===`clear`){let n=await cleanupFreshInitTarget(u.projectPath,u.failurePolicy,u.preservedEntries),r=e instanceof Error?e.message:String(e),i=n?`eve restored "${u.projectPath}" to its original state.`:`eve could not completely clean "${u.projectPath}".`;throw Error(`${r}\n\n${i}${workspaceFailureNote(t)}`)}if(u.failurePolicy===`remove`&&t){let t=e instanceof Error?e.message:String(e);throw Error(`${t}${workspaceFailureNote(!0)}`)}throw e}o={failurePolicy:u.failurePolicy,kind:`created`,packageManager:e,preservedTargetEntries:u.preservedEntries,projectPath:r.projectPath,retryCommand:`eve init ${u.projectPath}`,workspaceMember:t,workspaceRootMutations:r.workspaceRootMutations}}else{let e=await addToExistingProject(u.projectPath,i,n,d);o=e.nodeEngineOverride===void 0?{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,packageManager:e.packageManager,projectPath:u.projectPath}:{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,nodeEngineOverride:e.nodeEngineOverride,packageManager:e.packageManager,projectPath:u.projectPath}}let c=n.now()-a;initLog.debug(`${e} done`,{ms:c}),o.kind===`added`&&(f.stop(),reportExistingProjectChanges(r,o),f=startCliLiveRow(r)),p=`install_dependencies`,s?.(p),f.update(`Installing dependencies`,`${o.packageManager} install`),initLog.debug(`installing dependencies with ${o.packageManager}`);let h=n.now(),g=[],_=[],v=await n.runPackageManagerInstall(o.packageManager,o.projectPath,{progressDetails:process.stdout.isTTY===!0&&!l,onOutput:e=>{e.text.trim()!==``&&(_.push(e.text),_.length>20&&_.shift(),NPM_NOISE_LINE.test(e.text)||g.push(e.text)),l&&initLog.debug(e.text);let t=installProgressDetail(o.packageManager,e);t!==void 0&&f.update(`Installing dependencies`,t)}}),y=n.now()-h;if(!packageManagerInstallSucceeded(v)){m=packageManagerInstallFailureCode(v),initLog.debug(`dependency installation failed`,{ms:y}),f.stop();let e=g.length>0?g:_;for(let t of e)r.error(t);if(e.length===0){let e=packageManagerInstallFailureMessage(v);e!==void 0&&r.error(e)}if(o.failurePolicy!==`preserve`){if(await cleanupFreshInitTarget(o.projectPath,o.failurePolicy,o.preservedTargetEntries)){let e=o.failurePolicy===`remove`?`eve removed the incomplete project at "${o.projectPath}".`:`eve restored "${o.projectPath}" to its original state.`,t=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies.\n\n${e}\n\nResolve the package-manager error above, then retry:\n ${o.retryCommand}${workspaceFailureNote(t)}`)}let e=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies, and eve could not completely clean "${o.projectPath}".\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in that directory. Or clean the target manually before rerunning eve init.${workspaceFailureNote(e)}`)}throw Error(`The eve agent was added, but dependency installation failed.\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in "${o.projectPath}".\n\nDo not rerun eve init; the agent is already configured.`)}return initLog.debug(`dependencies installed`,{ms:y}),o.kind===`created`?(p=`initialize_git`,s?.(p),f.update(`Initializing Git repository`),initLog.debug(`initializing git repository`),{...o,agentElapsedMs:c,agentLaunched:t,gitResult:await n.tryInitializeGit(o.projectPath),installElapsedMs:y,selfModificationEnabled:!1}):{...o,agentElapsedMs:c,agentLaunched:t,installElapsedMs:y,selfModificationEnabled:!1}}catch(e){throw c?.(p,`error`,p===`install_dependencies`?m:void 0),e}finally{f.stop()}}async function runInitCommand(e,t,n,r,i=defaultDependencies,a,o){a?.(`resolve_target`);let s;try{if(await addAgentsToWorkspace(e,t,n,r,i.validateModelSlug)){a?.(`handoff`),o?.(`handoff`,`completed`);return}s=await runInitSteps({agentLaunched:await i.isCodingAgentLaunch(),dependencies:i,logger:e,options:r,parentDirectory:t,target:n,trackStep:a,trackTerminal:o})}catch(e){if(e instanceof WizardCancelledError){o?.(`resolve_target`,`cancelled`);return}throw e instanceof InitTargetError&&o?.(`resolve_target`,`error`,e.failureCode),e}if(a?.(`handoff`),s.kind===`created`){e.log(`${pc.green(`✓`)} Created an ${EVE_WORDMARK} agent in ${pc.bold(s.projectPath)} ${pc.dim(`in ${formatElapsed(s.agentElapsedMs)}`)}`);for(let t of s.workspaceRootMutations)e.log(pc.yellow(`⚠ ${formatWorkspaceRootMutationWarning(t)}`))}else e.log(`${pc.green(`✓`)} Added an ${EVE_WORDMARK} agent to ${pc.bold(s.projectPath)} ${pc.dim(`in ${formatElapsed(s.agentElapsedMs)}`)}`);e.log(`${pc.green(`✓`)} Installed dependencies ${pc.dim(`in ${formatElapsed(s.installElapsedMs)}`)}`),s.selfModificationEnabled&&e.log(`${pc.green(`✓`)} Enabled self-modification`),s.kind===`created`&&s.gitResult.kind===`failed`&&(e.error(pc.yellow(`Git initialization failed during ${s.gitResult.stage}: ${s.gitResult.reason}`)),s.gitResult.stage===`commit`&&e.error(pc.yellow(`The eve agent was created successfully. Git repository metadata and staged files were preserved at "${s.projectPath}"; the initial commit is optional.\n\nTo create it later, configure Git identity and run:\n git -C ${JSON.stringify(s.projectPath)} commit -m "Initial commit from eve"`)));let c=eveDevArguments(s.packageManager),l=[s.packageManager,...c].join(` `),u=initAgentDevHandoff({projectPath:s.projectPath,devCommand:l});if(s.agentLaunched){e.log(initAgentReadySummary(r.model,s.projectPath,{workspace:r.agents!==void 0})),e.log(u);return}if(!i.hasInteractiveTerminal()){e.log(u);return}let d=s.kind===`created`?[...c,`--onboard`]:c;if(e.log(pc.dim(`$ eve dev`)),!resultSucceeded(await i.spawnPackageManager(s.packageManager,s.projectPath,d)))throw Error(`Development server exited unsuccessfully in "${s.projectPath}".`)}function resolveInitEvePackageOverride(){let e=process.env[EVE_INIT_PACKAGE_SPEC_ENV]?.trim();if(e!==void 0&&e.length!==0)return{nodeEngine:DEFAULT_EVE_PACKAGE_CONTRACT.nodeEngine,version:e}}export{EVE_INIT_PACKAGE_SPEC_ENV,runInitCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sanitizeForTerminal}from"#cli/ui/output.js";import{formatElapsed}from"#cli/format-elapsed.js";import{formatCompactTokenCount}from"#cli/dev/tui/stream-format.js";import{formatAttributeContent}from"#cli/dev/tui/traces/trace-content.js";import{AGENT_USAGE_ATTRIBUTES}from"#tracing/agent-span-contract.js";function spanMetricChips(e){let t=[],n=numberAttribute(e,`agent.usage.input_tokens`),r=numberAttribute(e,`agent.usage.output_tokens`);n!==void 0&&t.push(`↑${formatCompactTokenCount(n)}`),r!==void 0&&t.push(`↓${formatCompactTokenCount(r)}`);let i=spanCostUsd(e);return i!==void 0&&t.push(formatCostUsd(i)),t}function summarizeLocalTrace(e){let t=[],n=0,r=0,i,a=0,o=0,s=0;for(let c of e){let e=stringAttribute(c,`agent.model.id`)??stringAttribute(c,`gen_ai.request.model`);if(e!==void 0&&!t.includes(e)&&t.push(e),c.statusCode===2&&(a+=1),c.name!==`agent.step`)continue;o+=numberAttribute(c,`agent.usage.input_tokens`)??0,s+=numberAttribute(c,`agent.usage.output_tokens`)??0,n+=numberAttribute(c,AGENT_USAGE_ATTRIBUTES.cacheReadTokens)??numberAttribute(c,`gen_ai.usage.cache_read.input_tokens`)??0,r+=numberAttribute(c,AGENT_USAGE_ATTRIBUTES.cacheWriteTokens)??numberAttribute(c,`gen_ai.usage.cache_creation.input_tokens`)??0;let l=spanCostUsd(c);l!==void 0&&(i=(i??0)+l)}return{cacheReadTokens:n,cacheWriteTokens:r,costUsd:i,errorCount:a,inputTokens:o,models:t,outputTokens:s}}function formatTokenSummary(e){let t=[`↑${formatCompactTokenCount(e.inputTokens)} in`,`↓${formatCompactTokenCount(e.outputTokens)} out`];return e.cacheReadTokens>0&&t.push(`${formatCompactTokenCount(e.cacheReadTokens)} cached`),e.cacheWriteTokens>0&&t.push(`${formatCompactTokenCount(e.cacheWriteTokens)} cache write`),t.join(` · `)}function formatCostUsd(e){return e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function renderSpanDetailTree(e,t){let n=spanDetailEntries(e,t.width-t.margin.length-3),r=[];return n.forEach((e,r)=>{let i=r===n.length-1&&!t.childrenFollow;emit(e,t.margin,i?`└─ `:`├─ `)}),r;function emit(e,n,i){r.push(t.mute(`${n}${i}${e.head}`));let a=`${n}${i===`└─ `?` `:`│ `}`;for(let n of e.lines)r.push(t.mute(`${a} ${n}`));e.entries.forEach((t,n)=>{emit(t,a,n===e.entries.length-1?`└─ `:`├─ `)})}}function spanDetailEntries(e,t){let dim=e=>e,n=Math.max(40,t),r=[],push=(e,t=[],n=[])=>{r.push({entries:n,head:e,lines:t})},i=e.statusCode===2;push(`status: ${i&&e.statusMessage!==void 0?`ERROR — ${sanitizeForTerminal(e.statusMessage)}`:i?`ERROR`:`ok`}`),push(`duration: ${formatElapsed(durationMs(e.startTimeNs,e.endTimeNs))}`),push(`started: ${new Date(Number(e.startTimeNs/1000000n)).toISOString()}`),push(`span: ${e.spanId}`),e.parentSpanId!==void 0&&push(`parent: ${e.parentSpanId}`),e.scope!==void 0&&push(`scope: ${sanitizeForTerminal(e.scope)}`),e.kind!==void 0&&e.kind!==1&&push(`kind: ${spanKind(e.kind)}`);for(let t of Object.keys(e.attributes).sort()){let r=formatAttributeContent(t,e.attributes[t],dim,n-2),i=sanitizeForTerminal(t);r.length===1?push(`${i}: ${r[0]}`):push(`${i}:`,r)}return e.events.length>0&&push(`events:`,[],e.events.map(t=>{let r=Math.max(0,durationMs(e.startTimeNs,t.timeNs)),i=[];for(let e of Object.keys(t.attributes).sort()){let r=formatAttributeContent(e,t.attributes[e],dim,n-6),a=sanitizeForTerminal(e);r.length===1?i.push(`${a}: ${r[0]}`):i.push(`${a}:`,...r.map(e=>` ${e}`))}return{entries:[],head:`${sanitizeForTerminal(t.name)} +${formatElapsed(r)}`,lines:i}})),r}function spanCostUsd(e){return numberAttribute(e,`gen_ai.usage.gateway_cost`)??numberAttribute(e,`gen_ai.usage.cost`)}function spanKind(e){switch(e){case 2:return`server`;case 3:return`client`;case 4:return`producer`;case 5:return`consumer`;default:return`unknown (${e})`}}function numberAttribute(e,t){let n=e.attributes[t];if(typeof n==`number`)return n;if(typeof n==`string`&&n!==``){let e=Number(n);return Number.isFinite(e)?e:void 0}}function stringAttribute(e,t){let n=e.attributes[t];return typeof n==`string`&&n.length>0?n:void 0}function durationMs(e,t){return Number(t-e)/1e6}export{formatCostUsd,formatTokenSummary,renderSpanDetailTree,spanMetricChips,summarizeLocalTrace};
|
|
1
|
+
import{sanitizeForTerminal}from"#cli/ui/output.js";import{formatElapsed}from"#cli/format-elapsed.js";import{formatCompactTokenCount}from"#cli/dev/tui/stream-format.js";import{formatAttributeContent}from"#cli/dev/tui/traces/trace-content.js";import{AGENT_USAGE_ATTRIBUTES}from"#tracing/agent-span-contract.js";function spanMetricChips(e){let t=[],n=numberAttribute(e,`agent.usage.input_tokens`),r=numberAttribute(e,`agent.usage.output_tokens`);n!==void 0&&t.push(`↑${formatCompactTokenCount(n)}`),r!==void 0&&t.push(`↓${formatCompactTokenCount(r)}`);let i=spanCostUsd(e);return i!==void 0&&t.push(formatCostUsd(i)),t}function summarizeLocalTrace(e){let t=[],n=0,r=0,i,a=0,o=0,s=0;for(let c of e){let e=stringAttribute(c,`agent.model.id`)??stringAttribute(c,`gen_ai.request.model`);if(e!==void 0&&!t.includes(e)&&t.push(e),c.statusCode===2&&(a+=1),c.name!==`agent.step`)continue;o+=numberAttribute(c,`agent.usage.input_tokens`)??0,s+=numberAttribute(c,`agent.usage.output_tokens`)??0,n+=numberAttribute(c,AGENT_USAGE_ATTRIBUTES.cacheReadTokens)??numberAttribute(c,`gen_ai.usage.cache_read.input_tokens`)??0,r+=numberAttribute(c,AGENT_USAGE_ATTRIBUTES.cacheWriteTokens)??numberAttribute(c,`gen_ai.usage.cache_write.input_tokens`)??numberAttribute(c,`gen_ai.usage.cache_creation.input_tokens`)??0;let l=spanCostUsd(c);l!==void 0&&(i=(i??0)+l)}return{cacheReadTokens:n,cacheWriteTokens:r,costUsd:i,errorCount:a,inputTokens:o,models:t,outputTokens:s}}function formatTokenSummary(e){let t=[`↑${formatCompactTokenCount(e.inputTokens)} in`,`↓${formatCompactTokenCount(e.outputTokens)} out`];return e.cacheReadTokens>0&&t.push(`${formatCompactTokenCount(e.cacheReadTokens)} cached`),e.cacheWriteTokens>0&&t.push(`${formatCompactTokenCount(e.cacheWriteTokens)} cache write`),t.join(` · `)}function formatCostUsd(e){return e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function renderSpanDetailTree(e,t){let n=spanDetailEntries(e,t.width-t.margin.length-3),r=[];return n.forEach((e,r)=>{let i=r===n.length-1&&!t.childrenFollow;emit(e,t.margin,i?`└─ `:`├─ `)}),r;function emit(e,n,i){r.push(t.mute(`${n}${i}${e.head}`));let a=`${n}${i===`└─ `?` `:`│ `}`;for(let n of e.lines)r.push(t.mute(`${a} ${n}`));e.entries.forEach((t,n)=>{emit(t,a,n===e.entries.length-1?`└─ `:`├─ `)})}}function spanDetailEntries(e,t){let dim=e=>e,n=Math.max(40,t),r=[],push=(e,t=[],n=[])=>{r.push({entries:n,head:e,lines:t})},i=e.statusCode===2;push(`status: ${i&&e.statusMessage!==void 0?`ERROR — ${sanitizeForTerminal(e.statusMessage)}`:i?`ERROR`:`ok`}`),push(`duration: ${formatElapsed(durationMs(e.startTimeNs,e.endTimeNs))}`),push(`started: ${new Date(Number(e.startTimeNs/1000000n)).toISOString()}`),push(`span: ${e.spanId}`),e.parentSpanId!==void 0&&push(`parent: ${e.parentSpanId}`),e.scope!==void 0&&push(`scope: ${sanitizeForTerminal(e.scope)}`),e.kind!==void 0&&e.kind!==1&&push(`kind: ${spanKind(e.kind)}`);for(let t of Object.keys(e.attributes).sort()){let r=formatAttributeContent(t,e.attributes[t],dim,n-2),i=sanitizeForTerminal(t);r.length===1?push(`${i}: ${r[0]}`):push(`${i}:`,r)}return e.events.length>0&&push(`events:`,[],e.events.map(t=>{let r=Math.max(0,durationMs(e.startTimeNs,t.timeNs)),i=[];for(let e of Object.keys(t.attributes).sort()){let r=formatAttributeContent(e,t.attributes[e],dim,n-6),a=sanitizeForTerminal(e);r.length===1?i.push(`${a}: ${r[0]}`):i.push(`${a}:`,...r.map(e=>` ${e}`))}return{entries:[],head:`${sanitizeForTerminal(t.name)} +${formatElapsed(r)}`,lines:i}})),r}function spanCostUsd(e){return numberAttribute(e,`gen_ai.usage.gateway_cost`)??numberAttribute(e,`gen_ai.usage.cost`)}function spanKind(e){switch(e){case 2:return`server`;case 3:return`client`;case 4:return`producer`;case 5:return`consumer`;default:return`unknown (${e})`}}function numberAttribute(e,t){let n=e.attributes[t];if(typeof n==`number`)return n;if(typeof n==`string`&&n!==``){let e=Number(n);return Number.isFinite(e)?e:void 0}}function stringAttribute(e,t){let n=e.attributes[t];return typeof n==`string`&&n.length>0?n:void 0}function durationMs(e,t){return Number(t-e)/1e6}export{formatCostUsd,formatTokenSummary,renderSpanDetailTree,spanMetricChips,summarizeLocalTrace};
|