eve 0.47.6 → 0.48.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 +54 -0
- package/dist/src/channel/adapter.js +1 -1
- package/dist/src/channel/delivery-metadata.d.ts +1 -0
- package/dist/src/channel/delivery-metadata.js +1 -1
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +10 -8
- package/dist/src/chunks/{use-eve-agent-DkUB0Ok4.js → use-eve-agent-BZnOzAVd.js} +25 -6
- package/dist/src/chunks/{use-eve-agent-DjYwFJF7.js → use-eve-agent-Bgp6INfi.js} +25 -6
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/commands/integration-connect.d.ts +2 -1
- package/dist/src/cli/commands/integration-connect.js +1 -1
- package/dist/src/cli/commands/register-integration-commands.d.ts +3 -1
- package/dist/src/cli/commands/register-integration-commands.js +1 -1
- package/dist/src/cli/commands/registry-declared-setups.js +1 -1
- package/dist/src/cli/commands/registry-install-transaction.d.ts +23 -0
- package/dist/src/cli/commands/registry-install-transaction.js +1 -0
- package/dist/src/cli/commands/registry-package.js +1 -1
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/commands/setup-headless.d.ts +6 -0
- package/dist/src/cli/commands/setup-headless.js +1 -1
- package/dist/src/cli/dev/command-options.d.ts +2 -0
- package/dist/src/cli/dev/run-interactive-ui.js +1 -1
- package/dist/src/cli/dev/tui/blocks.js +1 -1
- package/dist/src/cli/dev/tui/line-editor.d.ts +4 -0
- package/dist/src/cli/dev/tui/line-editor.js +3 -3
- package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
- package/dist/src/cli/dev/tui/registry-result-message.d.ts +17 -0
- package/dist/src/cli/dev/tui/registry-result-message.js +3 -0
- package/dist/src/cli/dev/tui/runner.d.ts +13 -4
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/setup-commands.d.ts +9 -3
- package/dist/src/cli/dev/tui/setup-commands.js +2 -3
- package/dist/src/cli/dev/tui/setup-flow.d.ts +15 -5
- package/dist/src/cli/dev/tui/setup-panel.d.ts +6 -1
- package/dist/src/cli/dev/tui/setup-panel.js +4 -4
- package/dist/src/cli/dev/tui/setup-selection-input.d.ts +1 -0
- package/dist/src/cli/dev/tui/setup-selection-input.js +1 -1
- package/dist/src/cli/dev/tui/stream-format.d.ts +8 -0
- package/dist/src/cli/dev/tui/stream-format.js +2 -2
- package/dist/src/cli/dev/tui/subagent-pump.d.ts +3 -0
- package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
- package/dist/src/cli/dev/tui/tui-prompter.js +1 -1
- package/dist/src/cli/dev/tui/tui.d.ts +3 -4
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/run.js +2 -2
- package/dist/src/client/agent-info-schema.d.ts +1 -1
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/open-stream.d.ts +1 -0
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +2 -1
- package/dist/src/compiled/@opentelemetry/api/index.d.ts +6 -0
- package/dist/src/compiled/@workflow/builders/LICENSE.md +201 -0
- package/dist/src/compiled/@workflow/builders/index.d.ts +62 -0
- package/dist/src/compiled/@workflow/builders/index.js +1 -0
- package/dist/src/compiler/extension-compatibility.d.ts +2 -2
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.d.ts +7 -17
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-tool.d.ts +0 -1
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/context/build-dynamic-tools.d.ts +2 -2
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/container.d.ts +7 -0
- package/dist/src/context/container.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.d.ts +16 -9
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-metadata.d.ts +44 -0
- package/dist/src/context/dynamic-tool-metadata.js +1 -0
- package/dist/src/context/keys.d.ts +14 -22
- package/dist/src/context/keys.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.d.ts +0 -1
- package/dist/src/eve-channel/request.js +2 -2
- package/dist/src/eve-channel/types.d.ts +7 -7
- package/dist/src/execution/accepted-delivery-deployment.d.ts +7 -0
- package/dist/src/execution/accepted-delivery-deployment.js +1 -0
- package/dist/src/execution/cancel-descendant-turns-step.d.ts +4 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/delegation-tool.d.ts +1 -2
- package/dist/src/execution/delegation-tool.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +14 -4
- package/dist/src/execution/dispatch-runtime-actions-shared.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/dispatch-turn-step.js +1 -1
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +1 -1
- package/dist/src/execution/durable-session-migrations/turn-workflow-v1-to-v2.d.ts +2 -0
- package/dist/src/execution/durable-session-migrations/turn-workflow-v1-to-v2.js +1 -0
- package/dist/src/execution/durable-session-migrations/turn-workflow.d.ts +25 -3
- package/dist/src/execution/durable-session-migrations/turn-workflow.js +1 -1
- package/dist/src/execution/eve-workflow-attributes.js +1 -1
- package/dist/src/execution/finalize-terminal-session.d.ts +17 -0
- package/dist/src/execution/finalize-terminal-session.js +1 -0
- package/dist/src/execution/inline-turn.d.ts +29 -0
- package/dist/src/execution/inline-turn.js +1 -0
- package/dist/src/execution/next-driver-action.d.ts +4 -0
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/parked-delivery-wait.js +1 -1
- package/dist/src/execution/pending-turn-state.d.ts +1 -0
- package/dist/src/execution/pending-turn-state.js +1 -1
- package/dist/src/execution/prepared-agent-action.d.ts +7 -0
- package/dist/src/execution/prepared-agent-action.js +1 -0
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/remote-agent-dispatch.d.ts +2 -0
- package/dist/src/execution/remote-agent-dispatch.js +1 -1
- package/dist/src/execution/session-command-token.d.ts +2 -0
- package/dist/src/execution/session-command-token.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +12 -0
- package/dist/src/execution/stable-workflow-names.js +1 -0
- package/dist/src/execution/subagent-event-proxy-step.d.ts +3 -0
- package/dist/src/execution/subagent-event-proxy-step.js +1 -1
- package/dist/src/execution/subagent-hitl-proxy.d.ts +2 -1
- package/dist/src/execution/subagent-hitl-proxy.js +1 -1
- package/dist/src/execution/subagent-start-local.d.ts +3 -0
- package/dist/src/execution/subagent-start-local.js +1 -1
- package/dist/src/execution/subagent-start-remote.d.ts +2 -0
- package/dist/src/execution/subagent-start-remote.js +1 -1
- package/dist/src/execution/subagent-tool.d.ts +1 -0
- package/dist/src/execution/subagent-tool.js +1 -1
- package/dist/src/execution/tasks/child/steps.d.ts +2 -0
- package/dist/src/execution/tasks/child/steps.js +1 -1
- package/dist/src/execution/tasks/child/update.d.ts +3 -2
- package/dist/src/execution/tasks/child/workflow.js +1 -1
- package/dist/src/execution/tasks/parent/control-shared.d.ts +5 -4
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch.d.ts +4 -3
- 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.js +1 -1
- package/dist/src/execution/terminal-session-event.d.ts +13 -0
- package/dist/src/execution/terminal-session-event.js +1 -0
- package/dist/src/execution/terminal-session-failure-step.d.ts +1 -0
- package/dist/src/execution/terminal-session-failure-step.js +1 -1
- package/dist/src/execution/tool-run/answer.d.ts +3 -0
- package/dist/src/execution/tool-run/answer.js +1 -0
- package/dist/src/execution/tool-run/background.d.ts +14 -0
- package/dist/src/execution/tool-run/background.js +1 -0
- package/dist/src/execution/tool-run/cancel.d.ts +7 -0
- package/dist/src/execution/tool-run/cancel.js +1 -0
- package/dist/src/execution/tool-run/dispatch.d.ts +24 -0
- package/dist/src/execution/tool-run/dispatch.js +1 -0
- package/dist/src/execution/tool-run/emit-run-report-step.d.ts +7 -0
- package/dist/src/execution/tool-run/emit-run-report-step.js +1 -0
- package/dist/src/execution/tool-run/messages.d.ts +70 -0
- package/dist/src/execution/tool-run/messages.js +1 -0
- package/dist/src/execution/tool-run/owner-channels.d.ts +29 -0
- package/dist/src/execution/tool-run/owner-channels.js +1 -0
- package/dist/src/execution/tool-run/owner-inbox.d.ts +11 -0
- package/dist/src/execution/tool-run/owner-inbox.js +1 -0
- package/dist/src/execution/tool-run/owner.d.ts +13 -0
- package/dist/src/execution/tool-run/owner.js +1 -0
- package/dist/src/execution/tool-run/resume-hook-step.d.ts +4 -0
- package/dist/src/execution/tool-run/resume-hook-step.js +1 -0
- package/dist/src/execution/tool-run/run-control.d.ts +18 -0
- package/dist/src/execution/tool-run/run-control.js +1 -0
- package/dist/src/execution/tool-run/start.d.ts +11 -0
- package/dist/src/execution/tool-run/start.js +1 -0
- package/dist/src/execution/tool-run/types.d.ts +21 -0
- package/dist/src/execution/tool-run/types.js +1 -0
- package/dist/src/execution/tool-run/workflow.d.ts +9 -0
- package/dist/src/execution/tool-run/workflow.js +1 -0
- package/dist/src/execution/tools/subagent/local.d.ts +3 -4
- package/dist/src/execution/tools/subagent/local.js +1 -1
- package/dist/src/execution/tools/subagent/remote.d.ts +4 -1
- package/dist/src/execution/tools/subagent/remote.js +1 -1
- package/dist/src/execution/turn-cancellation-control.d.ts +2 -0
- package/dist/src/execution/turn-cancellation-control.js +1 -1
- package/dist/src/execution/turn-control-receiver.js +1 -1
- package/dist/src/execution/turn-dispatch.d.ts +4 -2
- package/dist/src/execution/turn-dispatch.js +1 -1
- package/dist/src/execution/turn-execution-cursor.js +1 -1
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/wire/session-inbox-contract.d.ts +2 -2
- package/dist/src/execution/wire/session-inbox-contract.js +1 -1
- package/dist/src/execution/wire/session-inbox-encoder.d.ts +6 -2
- package/dist/src/execution/wire/session-inbox-encoder.js +1 -1
- package/dist/src/execution/wire/session-inbox-resume.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.v1.js +1 -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 +1 -1
- package/dist/src/execution/wire/session-inbox-wire.v2.migration.d.ts +3 -0
- package/dist/src/execution/wire/session-inbox-wire.v2.migration.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.v3.d.ts +480 -0
- package/dist/src/execution/wire/session-inbox-wire.v3.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.v3.migration.d.ts +3 -0
- package/dist/src/execution/wire/session-inbox-wire.v3.migration.js +1 -0
- package/dist/src/execution/workflow-entry-finalization.d.ts +22 -0
- package/dist/src/execution/workflow-entry-finalization.js +1 -0
- package/dist/src/execution/workflow-entry.d.ts +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-registry.d.ts +5 -0
- package/dist/src/execution/workflow-registry.js +1 -0
- package/dist/src/execution/workflow-runtime.d.ts +9 -11
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/execution/workflow-webhook-route.d.ts +4 -0
- package/dist/src/execution/workflow-webhook-route.js +1 -0
- package/dist/src/framework/sources/registry.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +3 -0
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/approval-delivery-coordinator.d.ts +6 -0
- package/dist/src/harness/approval-delivery-coordinator.js +1 -1
- package/dist/src/harness/attachment-staging.js +1 -1
- package/dist/src/harness/background-tools.d.ts +2 -0
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +2 -28
- package/dist/src/harness/hitl/pending-input-resolution.js +1 -1
- package/dist/src/harness/input-extraction.d.ts +3 -0
- package/dist/src/harness/input-extraction.js +1 -1
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +10 -0
- package/dist/src/harness/proxy-input-requests.js +1 -1
- package/dist/src/harness/runtime-actions.d.ts +11 -3
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/stale-input-responses.d.ts +2 -1
- package/dist/src/harness/stale-input-responses.js +1 -1
- package/dist/src/harness/subagent-depth.d.ts +3 -4
- package/dist/src/harness/subagent-depth.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/tool-runs.d.ts +21 -0
- package/dist/src/harness/tool-runs.js +1 -0
- package/dist/src/harness/tools.d.ts +0 -2
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/types.d.ts +6 -7
- package/dist/src/harness/workflow-runtime-action-state.d.ts +3 -3
- package/dist/src/harness/workflow-runtime-action-state.js +1 -1
- package/dist/src/harness/workflow-sandbox.js +1 -1
- package/dist/src/harness/workflow-subagent-limit.d.ts +4 -4
- package/dist/src/instrumentation/ai-sdk-telemetry.d.ts +1 -0
- package/dist/src/instrumentation/ai-sdk-telemetry.js +1 -1
- package/dist/src/instrumentation/content-policy.d.ts +3 -1
- package/dist/src/instrumentation/content-policy.js +1 -1
- package/dist/src/instrumentation/runtime.d.ts +5 -2
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/internal/application/build-output-environment.d.ts +2 -0
- package/dist/src/internal/application/build-output-environment.js +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/paths.d.ts +1 -2
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/attachments/errors.d.ts +3 -0
- package/dist/src/internal/authored-definition/schema-backed.d.ts +6 -2
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +7 -1
- package/dist/src/internal/authored-module-loader.js +3 -3
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/authored-runtime-modules.d.ts +2 -0
- package/dist/src/internal/authored-runtime-modules.js +1 -1
- package/dist/src/internal/client-context.d.ts +2 -0
- package/dist/src/internal/client-context.js +1 -0
- package/dist/src/internal/nitro/dev-client-address.d.ts +2 -0
- package/dist/src/internal/nitro/dev-client-address.js +1 -1
- package/dist/src/internal/nitro/development-generation.d.ts +2 -0
- package/dist/src/internal/nitro/development-generation.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.d.ts +2 -2
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/workflow-bundle/authored-workflow-directives.d.ts +17 -0
- package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -0
- package/dist/src/internal/workflow-bundle/authored-workflow-modules.d.ts +19 -0
- package/dist/src/internal/workflow-bundle/authored-workflow-modules.js +1 -0
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +17 -2
- package/dist/src/internal/workflow-bundle/builder-support.js +4 -3
- package/dist/src/internal/workflow-bundle/builder.d.ts +2 -2
- package/dist/src/internal/workflow-bundle/builder.js +2 -2
- package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.d.ts +2 -0
- package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.d.ts +3 -0
- package/dist/src/internal/workflow-bundle/dynamic-tool-transform.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +6 -2
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-core-shim.d.ts +3 -0
- package/dist/src/internal/workflow-bundle/workflow-core-shim.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-directive-ast.d.ts +7 -0
- package/dist/src/internal/workflow-bundle/workflow-directive-ast.js +1 -0
- package/dist/src/internal/workflow-bundle/workflow-transformer.d.ts +15 -1
- package/dist/src/internal/workflow-bundle/workflow-transformer.js +4 -4
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/protocol/baggage.d.ts +6 -0
- package/dist/src/protocol/baggage.js +1 -0
- package/dist/src/protocol/routes.d.ts +2 -2
- package/dist/src/public/channels/slack/attachments.js +1 -1
- package/dist/src/public/channels/teams/attachments.d.ts +2 -2
- package/dist/src/public/channels/teams/attachments.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/attachments.js +1 -1
- package/dist/src/public/definitions/remote-agent.d.ts +6 -3
- package/dist/src/public/local-dev.d.ts +9 -0
- package/dist/src/public/local-dev.js +1 -0
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/public/workflow/index.d.ts +3 -0
- package/dist/src/public/workflow/index.js +1 -0
- package/dist/src/public/workflow-modules.d.js +1 -0
- package/dist/src/public/workflow-modules.d.ts +11 -0
- package/dist/src/runtime/actions/keys.d.ts +3 -0
- package/dist/src/runtime/actions/keys.js +1 -1
- package/dist/src/runtime/agent/bootstrap.js +1 -1
- package/dist/src/runtime/loaders/bundled-artifacts.js +1 -1
- package/dist/src/runtime/local-dev-capability.d.ts +55 -0
- package/dist/src/runtime/local-dev-capability.js +1 -0
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/resolve-tool.js +1 -1
- package/dist/src/runtime/sessions/runtime-session.d.ts +1 -0
- package/dist/src/runtime/sessions/runtime-session.js +1 -1
- package/dist/src/runtime/sessions/turn.d.ts +3 -0
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/tools/registry.d.ts +1 -0
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/runtime/types.d.ts +2 -2
- package/dist/src/services/dev-client/client-options.d.ts +1 -0
- package/dist/src/services/dev-client/client-options.js +1 -1
- package/dist/src/services/dev-client/runtime-artifacts.d.ts +2 -0
- package/dist/src/services/dev-client/runtime-artifacts.js +1 -1
- package/dist/src/setup/connection-connector.d.ts +4 -2
- package/dist/src/setup/connection-connector.js +2 -2
- package/dist/src/setup/flows/login.js +1 -1
- package/dist/src/setup/flows/model.js +1 -1
- package/dist/src/setup/flows/provider.d.ts +5 -0
- package/dist/src/setup/flows/provider.js +4 -4
- package/dist/src/setup/flows/registry-session.d.ts +24 -7
- package/dist/src/setup/flows/registry-session.js +1 -1
- package/dist/src/setup/flows/registry.d.ts +35 -29
- package/dist/src/setup/flows/registry.js +2 -1
- package/dist/src/setup/integrations/web/setup.d.ts +0 -2
- package/dist/src/setup/integrations/web/setup.js +1 -1
- package/dist/src/setup/prompter.d.ts +24 -4
- package/dist/src/setup/prompter.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/vercel-project.js +0 -0
- package/dist/src/shared/dispatch-action.d.ts +30 -0
- package/dist/src/shared/dispatch-action.js +1 -0
- package/dist/src/shared/forwarded-trace-policy.d.ts +28 -0
- package/dist/src/shared/forwarded-trace-policy.js +1 -0
- package/dist/src/shared/instrumentation-decision.d.ts +3 -0
- package/dist/src/shared/instrumentation-decision.js +1 -1
- package/dist/src/shared/workflow-sandbox.d.ts +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tasks/json.js +1 -1
- package/dist/src/tools/behavior.d.ts +61 -0
- package/dist/src/tools/behavior.js +1 -0
- package/dist/src/tools/definition.d.ts +39 -3
- package/dist/src/tools/durable-callbacks.d.ts +1 -0
- package/dist/src/tools/framework/agent.d.ts +2 -11
- package/dist/src/tools/framework/agent.js +1 -1
- package/dist/src/tools/framework/ask-question.d.ts +2 -14
- package/dist/src/tools/framework/ask-question.js +1 -1
- package/dist/src/tools/framework/task-cancel.d.ts +2 -7
- package/dist/src/tools/framework/task-cancel.js +1 -1
- package/dist/src/tools/framework/task-contract.d.ts +0 -2
- package/dist/src/tools/framework/task-contract.js +1 -1
- package/dist/src/tools/framework/task-update.d.ts +2 -7
- package/dist/src/tools/framework/task-update.js +1 -1
- package/dist/src/tools/native-definition.d.ts +6 -0
- package/dist/src/tools/native-definition.js +1 -0
- package/dist/src/tools/provided/load-skill.js +1 -1
- package/dist/src/tracing/agent-approval-instrumentation.js +1 -1
- package/dist/src/tracing/agent-channel-delivery-instrumentation.js +1 -1
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/tracing/agent-otel-session-context.js +1 -1
- package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
- package/dist/src/tracing/agent-trace-context-store.d.ts +1 -1
- package/dist/src/tracing/agent-trace-context-store.js +1 -1
- package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
- package/dist/src/tracing/otel-declaration.d.ts +5 -3
- package/dist/src/tracing/otel-registration.d.ts +3 -1
- package/dist/src/tracing/otel-registration.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/custom.mdx +2 -0
- package/docs/channels/eve.mdx +5 -1
- package/docs/channels/teams.mdx +6 -1
- package/docs/concepts/sessions-runs-and-streaming.md +4 -2
- package/docs/guides/auth-and-route-protection.md +5 -1
- package/docs/guides/client/messages.mdx +6 -0
- package/docs/guides/dev-tui.md +30 -18
- package/docs/guides/remote-agents.md +25 -0
- package/docs/reference/cli.md +2 -2
- package/docs/reference/typescript-api.md +24 -0
- package/docs/tools/meta.json +1 -1
- package/docs/tools/overview.mdx +7 -0
- package/docs/tools/workflows.mdx +288 -0
- package/package.json +17 -1
- package/dist/src/execution/tools/tasks.d.ts +0 -18
- package/dist/src/execution/tools/tasks.js +0 -1
- package/dist/src/internal/authored-directive-prologue.d.ts +0 -4
- package/dist/src/internal/authored-directive-prologue.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{z}from"#compiled/zod/index.js";import{WORKFLOW_RUNTIME_ACTION_INTERRUPT_KIND}from"#harness/workflow-runtime-action-state.js";import{DEFAULT_WORKFLOW_MAX_SUBAGENTS}from"#harness/workflow-subagent-limit.js";import{WORKFLOW_TOOL_NAME,createWorkflowSandboxTool,readWorkflowSandboxResolution,requestWorkflowSandboxInterrupt}from"#shared/workflow-sandbox.js";import{workflowToolDescription}from"#harness/workflow-tool-description.js";const workflowInputSchema=z.strictObject({js:z.string().describe(`Complete JavaScript orchestration program. Call only the agents listed in the Workflow description and return one JSON-serializable result.`)});async function applyWorkflowTool(e){let t=createWorkflowHostTools(e.harnessTools,Object.keys(e.tools));if(Object.keys(t).length===0)return{hostTools:t,modelTools:e.tools};let n=await createWorkflowSandboxTool({bridgeRequestLimit:resolveWorkflowSandboxBridgeRequestLimit(e.maxSubagents),continuationSecurity:e.continuationSecurity,hostTools:t}),a=typeof n.description==`string`?n.description:``,o=workflowToolDescription(Object.keys(t),{maxSubagents:e.maxSubagents}),s=workflowApiReference(a),c={...e.tools};return c[WORKFLOW_TOOL_NAME]={...n,description:s.length>0?`${o}\n\n${s}`:o,inputSchema:workflowInputSchema},{hostTools:t,modelTools:c}}function resolveWorkflowSandboxBridgeRequestLimit(e){return Math.max(256,(e??DEFAULT_WORKFLOW_MAX_SUBAGENTS)+1)}function workflowApiReference(e){let t=e.indexOf(`Tools:
|
|
2
|
-
`);return t<0?e:`Available agent API:\n${e.slice(t+7)}`}function buildWorkflowHostTools(e){return createWorkflowHostTools(e.tools,e.tools.keys())}function createWorkflowHostTools(e,t){let n={};for(let r of t){let t=e.get(r);t?.
|
|
2
|
+
`);return t<0?e:`Available agent API:\n${e.slice(t+7)}`}function buildWorkflowHostTools(e){return createWorkflowHostTools(e.tools,e.tools.keys())}function createWorkflowHostTools(e,t){let n={};for(let r of t){let t=e.get(r);if(t===void 0)continue;let i=t.behavior?.handling?.kind===`dispatch`?t.behavior.handling.target:void 0;(i?.kind===`self-agent-call`||i?.kind===`subagent-call`||i?.kind===`remote-agent-call`)&&(n[r]=createWorkflowRuntimeActionHostTool(t))}return n}function createWorkflowRuntimeActionHostTool(e){return{description:e.description,inputSchema:e.inputSchema,execute:async(n,r)=>{let i=readWorkflowSandboxResolution(r);return i===void 0?requestWorkflowSandboxInterrupt({dispatchTarget:e.behavior?.handling?.kind===`dispatch`?e.behavior.handling.target:void 0,kind:WORKFLOW_RUNTIME_ACTION_INTERRUPT_KIND,toolInput:n,toolName:e.name}):i}}}export{applyWorkflowTool,buildWorkflowHostTools,resolveWorkflowSandboxBridgeRequestLimit};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PendingDispatchAction } from "#shared/dispatch-action.js";
|
|
2
2
|
/**
|
|
3
3
|
* Default maximum number of subagent (and remote-agent) calls one `Workflow`
|
|
4
4
|
* tool invocation may dispatch.
|
|
@@ -10,8 +10,8 @@ export declare const DEFAULT_WORKFLOW_MAX_SUBAGENTS = 100;
|
|
|
10
10
|
* actions must resolve with an error result instead of starting a child.
|
|
11
11
|
*/
|
|
12
12
|
export type WorkflowSubagentDispatchPlan = {
|
|
13
|
-
readonly allowed: readonly
|
|
14
|
-
readonly blocked: readonly
|
|
13
|
+
readonly allowed: readonly PendingDispatchAction[];
|
|
14
|
+
readonly blocked: readonly PendingDispatchAction[];
|
|
15
15
|
readonly maxSubagents: number;
|
|
16
16
|
readonly usedCalls: number;
|
|
17
17
|
};
|
|
@@ -22,7 +22,7 @@ export type WorkflowSubagentDispatchPlan = {
|
|
|
22
22
|
* program's call order.
|
|
23
23
|
*/
|
|
24
24
|
export declare function planWorkflowSubagentDispatch(input: {
|
|
25
|
-
readonly actions: readonly
|
|
25
|
+
readonly actions: readonly PendingDispatchAction[];
|
|
26
26
|
readonly maxSubagents?: number;
|
|
27
27
|
readonly usedCalls: number;
|
|
28
28
|
}): WorkflowSubagentDispatchPlan;
|
|
@@ -17,6 +17,7 @@ export declare function ensureOtelIntegration(): void;
|
|
|
17
17
|
* these forward or they stop receiving events.
|
|
18
18
|
*/
|
|
19
19
|
export declare function getRegisteredTelemetryIntegrations(options?: {
|
|
20
|
+
readonly excludeEveOtelIntegration?: boolean;
|
|
20
21
|
readonly sanitizeEveOtelErrors?: boolean;
|
|
21
22
|
}): readonly Telemetry[];
|
|
22
23
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{registerTelemetry}from"ai";import{OpenTelemetry}from"#compiled/@ai-sdk/otel/index.js";const log=createLogger(`harness.ai-sdk-telemetry`);let registered=!1,eveOtelIntegration,errorSafeEveOtelIntegration,warnedMissingEveOtelIntegration=!1;function ensureOtelIntegration(){registered||(registered=!0,eveOtelIntegration=new OpenTelemetry({runtimeContext:!0}),errorSafeEveOtelIntegration=telemetryWithoutErrorContent(eveOtelIntegration),registerTelemetry(eveOtelIntegration))}function getRegisteredTelemetryIntegrations(e){let t=globalThis.AI_SDK_TELEMETRY_INTEGRATIONS??[];if(e?.sanitizeEveOtelErrors!==!0)return
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{registerTelemetry}from"ai";import{OpenTelemetry}from"#compiled/@ai-sdk/otel/index.js";const log=createLogger(`harness.ai-sdk-telemetry`);let registered=!1,eveOtelIntegration,errorSafeEveOtelIntegration,warnedMissingEveOtelIntegration=!1;function ensureOtelIntegration(){registered||(registered=!0,eveOtelIntegration=new OpenTelemetry({runtimeContext:!0}),errorSafeEveOtelIntegration=telemetryWithoutErrorContent(eveOtelIntegration),registerTelemetry(eveOtelIntegration))}function getRegisteredTelemetryIntegrations(e){let t=globalThis.AI_SDK_TELEMETRY_INTEGRATIONS??[],n=e?.excludeEveOtelIntegration===!0?t.filter(e=>e!==eveOtelIntegration):t;if(e?.sanitizeEveOtelErrors!==!0)return n;let r=!1,i=n.map(e=>e!==eveOtelIntegration||errorSafeEveOtelIntegration===void 0?e:(r=!0,errorSafeEveOtelIntegration));return!r&&e.excludeEveOtelIntegration!==!0&&!warnedMissingEveOtelIntegration&&(warnedMissingEveOtelIntegration=!0,log.warn(`could not sanitize eve's AI SDK OpenTelemetry integration`,{reason:eveOtelIntegration===void 0?`eve OpenTelemetry integration was not registered`:`registered integration identity did not match`})),i}function telemetryWithoutErrorContent(e){let genericError=()=>Error(`AI SDK operation failed`);return new Proxy(e,{get(e,t){if(t===`onError`&&e.onError!==void 0)return t=>e.onError(typeof t==`object`&&t?{...t,error:genericError()}:genericError());if(t===`onToolExecutionEnd`&&e.onToolExecutionEnd!==void 0)return t=>e.onToolExecutionEnd(t.toolOutput.type===`tool-error`?{...t,toolOutput:{...t.toolOutput,error:genericError()}}:t);let n=Reflect.get(e,t);return typeof n==`function`?n.bind(e):n}})}export{ensureOtelIntegration,getRegisteredTelemetryIntegrations,telemetryWithoutErrorContent};
|
|
@@ -2,4 +2,6 @@ import type { InstrumentationEvent } from "#instrumentation/lifecycle.js";
|
|
|
2
2
|
import type { ChannelAudience } from "#shared/channel-audience.js";
|
|
3
3
|
import type { InstrumentationDecision } from "#shared/instrumentation-decision.js";
|
|
4
4
|
/** Applies OpenTelemetry's trace content ceiling to one OTel provider event. */
|
|
5
|
-
export declare function instrumentationEventForTraceDecision(event: InstrumentationEvent, decision: InstrumentationDecision, audience: ChannelAudience
|
|
5
|
+
export declare function instrumentationEventForTraceDecision(event: InstrumentationEvent, decision: InstrumentationDecision, audience: ChannelAudience, options?: {
|
|
6
|
+
readonly applyAudienceCeiling?: boolean;
|
|
7
|
+
}): InstrumentationEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyAudienceCeiling}from"#shared/instrumentation-content.js";import{withInstrumentationDecision,withoutInstrumentationContent}from"#instrumentation/content.js";function instrumentationEventForTraceDecision(e,t,n){let r
|
|
1
|
+
import{applyAudienceCeiling}from"#shared/instrumentation-content.js";import{withInstrumentationDecision,withoutInstrumentationContent}from"#instrumentation/content.js";function instrumentationEventForTraceDecision(e,t,n,r={}){let i=r.applyAudienceCeiling===!1?t:applyAudienceCeiling(t,n);return i.action===`drop`?withoutInstrumentationContent(e):withInstrumentationDecision(e,i)}export{instrumentationEventForTraceDecision};
|
|
@@ -54,11 +54,14 @@ export interface InstrumentationRuntime {
|
|
|
54
54
|
readonly hooks: InstrumentationHooks;
|
|
55
55
|
readonly idGenerator?: AgentSpanIdGenerator;
|
|
56
56
|
readonly instrumentationProviders?: boolean;
|
|
57
|
+
readonly ownsAgentSpans?: boolean;
|
|
57
58
|
readonly prepareSessionTrace?: (event: InstrumentationSessionStartedEvent) => Promise<InstrumentationTraceSeed>;
|
|
58
59
|
readonly prepareTurnTrace?: (event: InstrumentationTurnStartedEvent) => Promise<InstrumentationTraceSeed>;
|
|
59
60
|
otelSettings: OtelHarnessSettings | undefined;
|
|
60
61
|
readonly runtimeContextResolvers?: readonly RuntimeContextResolver[];
|
|
61
62
|
readonly runInContext: InstrumentationContextRunner;
|
|
63
|
+
/** Whether the installed OTel sampler would record a trace with this id. */
|
|
64
|
+
readonly samplesTrace?: (traceId: string) => boolean;
|
|
62
65
|
readonly shutdown: () => Promise<void>;
|
|
63
66
|
stepStartedRuntimeContextResolver?: InstrumentationEvents["step.started"];
|
|
64
67
|
}
|
|
@@ -72,9 +75,9 @@ export interface SessionInstrumentation {
|
|
|
72
75
|
}, execute: (scope: InstrumentationStepScope<TSession>) => Promise<TResult>) => Promise<TResult>;
|
|
73
76
|
}
|
|
74
77
|
export interface ExecutionInstrumentation {
|
|
75
|
-
readonly
|
|
78
|
+
readonly createHandleEvent: (input: {
|
|
76
79
|
readonly handleEvent?: HandleEventFn;
|
|
77
|
-
readonly turnId
|
|
80
|
+
readonly turnId?: string;
|
|
78
81
|
}) => HandleEventFn | undefined;
|
|
79
82
|
readonly flush: () => Promise<void>;
|
|
80
83
|
readonly instrumentChannelDelivery: (input: Omit<ChannelDeliveryStartInstrumentation, "hooks" | "policyAgentName"> | Omit<ChannelDeliveryTerminalInstrumentation, "hooks">) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{recordErrorOnSpan}from"#internal/logging.js";import{normalizeChannelAudience}from"#shared/channel-audience.js";import{contextStorage}from"#context/container.js";import{ChannelInstrumentationKey,OtelTraceEnabledKey,ParentSessionKey,ParentTraceContextKey,SessionTraceSeedKey}from"#context/keys.js";import{ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{readSessionTraceDecision}from"#tracing/agent-trace-context-store.js";import{applyAudienceCeiling,shouldCaptureInstrumentationContent}from"#shared/instrumentation-content.js";import{isSampledTrace,resolveTracePolicy,resolveTracePolicyDecision}from"#tracing/sampled-trace.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{attemptIdempotencyKey}from"#instrumentation/lifecycle.js";import{instrumentChannelDelivery}from"#instrumentation/channel-delivery.js";import{buildTelemetryRuntimeContext,snapshotInstrumentationRuntimeContext}from"#instrumentation/runtime-context.js";import{ensureOtelIntegration,getRegisteredTelemetryIntegrations}from"#instrumentation/ai-sdk-telemetry.js";import{createAiSdkHookBridge}from"#instrumentation/ai-sdk-hook-bridge.js";import{createInstrumentationHandleEvent,publishInputResolutions}from"#instrumentation/native-events.js";import{prepareTurnTraceContext}from"#instrumentation/prepare-trace-context.js";import{resolveParentLineage}from"#instrumentation/parent-lineage.js";const INSTRUMENTATION_RUNTIME_KEY=Symbol.for(`eve.instrumentation-runtime`),TURN_TRACE_STATE_KEY=`eve.harness.turnTrace`;function bindInstrumentationRuntime(i,l,u){if(i===void 0)return;let d=i.hooks,readSessionContext=()=>{let e=contextStorage.getStore()??l;return{channel:e.get(ChannelKey),context:e,instrumentation:e.get(ChannelInstrumentationKey),parent:e.get(ParentSessionKey),parentTraceContext:e.get(ParentTraceContextKey),traceSeed:e.get(SessionTraceSeedKey)}},bindHooks=e=>{let n=e.instrumentation;return d.forTrace?.({agentName:u.agentName,audience:normalizeChannelAudience(n?.metadata.audience),channelType:n?.channelType})??d},captureExecutionRuntime=()=>{let e=i.otelSettings;return e!==void 0&&ensureOtelIntegration(),{otelSettings:e,runtimeContextResolvers:i.runtimeContextResolvers,stepStartedRuntimeContextResolver:i.stepStartedRuntimeContextResolver,tracer:e===void 0?void 0:trace.getTracer(`eve`)}},preparePreamble=(e,n)=>{let r=n.instrumentation,a=normalizeChannelAudience(r?.metadata.audience);return prepareTurnTraceContext({...e,agentName:u.agentName,channelAudience:a,channelType:r?.channelType,instrumentation:i,parentLineage:resolveParentLineage(n.parent,n.channel),parentTraceContext:n.parentTraceContext,rootSessionId:n.parent?.rootSessionId??u.rootSessionId,sessionId:u.sessionId,traceSeed:n.traceSeed})};return{createCancellationHandleEvent:e=>{let t=readSessionContext();return createInstrumentationHandleEvent({agentName:u.agentName,channelKind:t.instrumentation?.kind,handleEvent:e.handleEvent,hooks:bindHooks(t),sessionId:u.sessionId,turnId:e.turnId})},flush:i.forceFlush,instrumentChannelDelivery:e=>instrumentChannelDelivery({...e,hooks:d,policyAgentName:u.agentName}),prepareExecution:()=>{let n=captureExecutionRuntime();return{runStep:async(r,a)=>{let o=readSessionContext(),s=bindHooks(o),c=n.otelSettings,l=resolveStepInstrumentationDecision(c,u.agentName,o.instrumentation,o.traceSeed,readSessionTraceDecision(o.context,u.sessionId)),d=n.tracer,f={"eve.environment":r.environment,"eve.session.id":r.session.sessionId,"eve.version":r.eveVersion},p=c?.functionId??u.agentName;p&&(f[`ai.telemetry.functionId`]=p);let m=d!==void 0&&l?.action!==`drop`&&r.hasInput?d.startSpan(`ai.eve.turn`,{attributes:f}):void 0,h=m?.spanContext(),g=h===void 0?r.session:{...r.session,state:{...r.session.state,[TURN_TRACE_STATE_KEY]:{spanId:h.spanId,traceFlags:h.traceFlags,traceId:h.traceId}}},_=m===void 0?void 0:trace.setSpan(context.active(),m);if(_===void 0&&d!==void 0){let e=r.session.state?.[TURN_TRACE_STATE_KEY];e!==void 0&&(_=trace.setSpan(context.active(),trace.wrapSpanContext({...e,isRemote:!0})))}let v=readSessionContext(),y=snapshotInstrumentationRuntimeContext(v.context),b=v.instrumentation,x=normalizeChannelAudience(b?.metadata.audience),S=shouldCaptureInstrumentationContent(x),C=l===void 0?void 0:applyAudienceCeiling(l,x),w=l?.action===`drop`,T={recordInputs:!w&&(C?.action===`record`?C.recordInputs:S)&&(c?.recordInputs??!1),recordOutputs:!w&&(C?.action===`record`?C.recordOutputs:S)&&(c?.recordOutputs??!1)},telemetry=e=>{if(c===void 0&&e.bridgeIntegration===void 0)return;let t={};for(let n of Object.keys(e.runtimeContext??{}))t[n]=!0;let n=c!==void 0&&!(T.recordInputs&&T.recordOutputs),integrations=()=>getRegisteredTelemetryIntegrations({sanitizeEveOtelErrors:n});return{functionId:c?.functionId??u.agentName,includeRuntimeContext:t,integrations:e.bridgeIntegration===void 0?n?[...integrations()]:void 0:[e.bridgeIntegration,...integrations()],isEnabled:!0,recordInputs:T.recordInputs,recordOutputs:T.recordOutputs}},run=()=>a({createHandleEvent:e=>createInstrumentationHandleEvent({...e,agentName:u.agentName,channelAudience:x,channelKind:b?.kind,hooks:s,parentLineage:resolveParentLineage(v.parent,v.channel),parentTraceContext:v.parentTraceContext,rootSessionId:v.parent?.rootSessionId,sessionId:u.sessionId}),prepareAttempt:e=>{let t={attemptId:`${u.sessionId}:${e.turnId}:${e.stepIndex}:${e.attemptIndex}`,attemptIndex:e.attemptIndex,channelAudience:x,functionId:c?.functionId??u.agentName,rootSessionId:v.parent?.rootSessionId??u.sessionId,sessionId:u.sessionId,stepIndex:e.stepIndex,turnId:e.turnId},n=createAiSdkHookBridge(t,s,i.runInContext,e.runtimeContext);return{complete:()=>s.publish({idempotencyKey:attemptIdempotencyKey(t),scope:t,type:`step.attempt.completed`}),fail:e=>s.publish({error:e,idempotencyKey:attemptIdempotencyKey(t),scope:t,type:`step.attempt.failed`}),scope:t,telemetry:telemetry({bridgeIntegration:n,runtimeContext:e.runtimeContext})}},preparePreamble:e=>preparePreamble(e,v),publishInputResolutions:e=>publishInputResolutions({...e,hooks:s}),recordError:t=>{m!==void 0&&recordErrorOnSpan(m,t)},resolveRuntimeContext:e=>{let r=normalizeChannelAudience(y.channel?.metadata.audience);return buildTelemetryRuntimeContext({...e,capturesContent:shouldCaptureInstrumentationContent(r),context:y,providerResolvers:n.runtimeContextResolvers,stepStartedResolver:n.stepStartedRuntimeContextResolver})},session:g,setTurnId:e=>m?.setAttribute(`eve.turn.id`,e),telemetry:()=>telemetry({}),traceContext:h===void 0||!isValidSpanContext(h)?void 0:{spanId:h.spanId,traceFlags:h.traceFlags,traceId:h.traceId}});try{return _===void 0?await run():await context.with(_,run)}finally{m?.end(),m=void 0}}}},preparePreamble:e=>preparePreamble(e,readSessionContext())}}function bindSessionInstrumentation(e){return bindInstrumentationRuntime(getInstrumentationRuntime(),e.ctx,{agentName:e.agentName,rootSessionId:e.rootSessionId,sessionId:e.sessionId})}function initializeSessionInstrumentation(e){let n=getInstrumentationRuntime(),a=e.ctx.get(ChannelInstrumentationKey),o=normalizeChannelAudience(a?.metadata.audience),c=allocateSessionTraceSeed({agentName:e.agentName,audience:o,channelType:a?.channelType,parentTraceContext:e.parentTraceContext,runtime:n});c!==void 0&&e.ctx.set(SessionTraceSeedKey,c),e.ctx.set(OtelTraceEnabledKey,n?.prepareSessionTrace!==void 0)}function allocateSessionTraceSeed(e){if(e.parentTraceContext!==void 0)return{decision:e.parentTraceContext.decision??resolveTracePolicyDecision(isSampledTrace(e.parentTraceContext),e.audience),spanId:e.parentTraceContext.spanId,traceFlags:e.parentTraceContext.traceFlags,traceId:e.parentTraceContext.traceId};if(e.runtime?.prepareSessionTrace===void 0||e.runtime.idGenerator===void 0)return;let t=resolveTracePolicy(e.runtime.otelSettings?.tracePolicy,{agentName:e.agentName,audience:e.audience,channelType:e.channelType});return{decision:t,spanId:e.runtime.idGenerator.allocateSpanId(),traceFlags:+(t.action===`record`),traceId:e.runtime.idGenerator.generateTraceId()}}function resolveStepInstrumentationDecision(e,n,r,i,a){if(e===void 0)return;if(i?.decision!==void 0)return i.decision;if(a!==void 0)return a;let o=normalizeChannelAudience(r?.metadata.audience);return i===void 0?resolveTracePolicy(e.tracePolicy,{agentName:n,audience:o,channelType:r?.channelType}):resolveTracePolicyDecision(isSampledTrace(i),o)}function isValidSpanContext(e){return/^[0-9a-f]{32}$/u.test(e.traceId)&&e.traceId!==`00000000000000000000000000000000`&&/^[0-9a-f]{16}$/u.test(e.spanId)&&e.spanId!==`0000000000000000`}const globalRuntime=globalThis;function registerInstrumentationRuntime(e){let t=globalRuntime[INSTRUMENTATION_RUNTIME_KEY];return t===void 0?(globalRuntime[INSTRUMENTATION_RUNTIME_KEY]=e,e):(t.otelSettings=e.otelSettings,t)}function getInstrumentationRuntime(){return globalRuntime[INSTRUMENTATION_RUNTIME_KEY]}export{bindInstrumentationRuntime,bindSessionInstrumentation,getInstrumentationRuntime,initializeSessionInstrumentation,registerInstrumentationRuntime};
|
|
1
|
+
import{createLogger,recordErrorOnSpan}from"#internal/logging.js";import{normalizeChannelAudience}from"#shared/channel-audience.js";import{contextStorage}from"#context/container.js";import{ChannelInstrumentationKey,OtelTraceEnabledKey,ParentSessionKey,ParentTraceContextKey,SessionTraceSeedKey}from"#context/keys.js";import{ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{applyLiveDeliveryAudienceCeiling,formatTraceContentCeiling,readForwardedTraceAssertion,resolveForwardedTraceSeed,traceContentCeilingToDecision}from"#shared/forwarded-trace-policy.js";import{readSessionTraceDecision}from"#tracing/agent-trace-context-store.js";import{shouldCaptureInstrumentationContent}from"#shared/instrumentation-content.js";import{isSampledTrace,resolveTracePolicy,resolveTracePolicyDecision}from"#tracing/sampled-trace.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{attemptIdempotencyKey}from"#instrumentation/lifecycle.js";import{instrumentChannelDelivery}from"#instrumentation/channel-delivery.js";import{buildTelemetryRuntimeContext,snapshotInstrumentationRuntimeContext}from"#instrumentation/runtime-context.js";import{ensureOtelIntegration,getRegisteredTelemetryIntegrations}from"#instrumentation/ai-sdk-telemetry.js";import{createAiSdkHookBridge}from"#instrumentation/ai-sdk-hook-bridge.js";import{createInstrumentationHandleEvent,publishInputResolutions}from"#instrumentation/native-events.js";import{prepareTurnTraceContext}from"#instrumentation/prepare-trace-context.js";import{resolveParentLineage}from"#instrumentation/parent-lineage.js";import{intersectInstrumentationDecisions,readInstrumentationDecision}from"#shared/instrumentation-decision.js";const INSTRUMENTATION_RUNTIME_KEY=Symbol.for(`eve.instrumentation-runtime`),TURN_TRACE_STATE_KEY=`eve.harness.turnTrace`,log=createLogger(`instrumentation.runtime`);function bindInstrumentationRuntime(e,a,d){if(e===void 0)return;let m=e.hooks,readSessionContext=()=>{let e=contextStorage.getStore()??a,t=e.get(SessionTraceSeedKey),n=resolveForwardedTraceSeed(t),u=t===void 0||n===void 0?void 0:{...t,...n},d=e.get(ParentTraceContextKey);return{channel:e.get(ChannelKey),context:e,instrumentation:e.get(ChannelInstrumentationKey),forwardedTracePolicy:readForwardedTraceAssertion(u?.forwardedTracePolicy),parent:e.get(ParentSessionKey),parentTraceContext:d,traceSeed:u}},bindHooks=e=>{let t=e.instrumentation;return m.forTrace?.({agentName:d.agentName,audience:normalizeChannelAudience(t?.metadata.audience),channelType:t?.channelType})??m},captureExecutionRuntime=()=>{let t=e.otelSettings,n=e.ownsAgentSpans===!0;return t!==void 0&&!n&&ensureOtelIntegration(),{ownsAgentSpans:n,otelSettings:t,runtimeContextResolvers:e.runtimeContextResolvers,stepStartedRuntimeContextResolver:e.stepStartedRuntimeContextResolver,tracer:t===void 0?void 0:trace.getTracer(`eve`)}},preparePreamble=(t,r)=>{let i=r.instrumentation,a=normalizeChannelAudience(i?.metadata.audience);return prepareTurnTraceContext({...t,agentName:d.agentName,channelAudience:a,channelType:i?.channelType,instrumentation:e,parentLineage:resolveParentLineage(r.parent,r.channel),parentTraceContext:r.parentTraceContext,rootSessionId:r.parent?.rootSessionId??d.rootSessionId,sessionId:d.sessionId,traceSeed:r.traceSeed})};return{createHandleEvent:e=>{let t=readSessionContext();return createInstrumentationHandleEvent({agentName:d.agentName,channelKind:t.instrumentation?.kind,handleEvent:e.handleEvent,hooks:bindHooks(t),sessionId:d.sessionId,turnId:e.turnId})},flush:e.forceFlush,instrumentChannelDelivery:e=>instrumentChannelDelivery({...e,hooks:m,policyAgentName:d.agentName}),prepareExecution:()=>{let r=captureExecutionRuntime();return{runStep:async(i,a)=>{let o=readSessionContext(),s=bindHooks(o),c=r.otelSettings,l=resolveStepInstrumentationDecision(c,d.agentName,o.instrumentation,o.traceSeed,readSessionTraceDecision(o.context,d.sessionId)),f=r.tracer,p={"eve.environment":i.environment,"eve.session.id":i.session.sessionId,"eve.version":i.eveVersion},m=c?.functionId??d.agentName;m&&(p[`ai.telemetry.functionId`]=m);let h=f!==void 0&&!r.ownsAgentSpans&&l?.action!==`drop`&&i.hasInput?f.startSpan(`ai.eve.turn`,{attributes:p}):void 0,g=h?.spanContext(),_=g===void 0?i.session:{...i.session,state:{...i.session.state,[TURN_TRACE_STATE_KEY]:{spanId:g.spanId,traceFlags:g.traceFlags,traceId:g.traceId}}},v=h===void 0?void 0:trace.setSpan(context.active(),h);if(v===void 0&&f!==void 0){let e=i.session.state?.[TURN_TRACE_STATE_KEY];e!==void 0&&(v=trace.setSpan(context.active(),trace.wrapSpanContext({...e,isRemote:!0})))}let y=readSessionContext(),b=snapshotInstrumentationRuntimeContext(y.context),x=y.instrumentation,S=normalizeChannelAudience(x?.metadata.audience),C=shouldCaptureInstrumentationContent(S),w=l===void 0?l:applyLiveDeliveryAudienceCeiling(l,S,y.forwardedTracePolicy),T=w===void 0?C:w.action===`record`&&w.recordInputs,E=l?.action===`drop`,D={recordInputs:!E&&(w?.action===`record`?w.recordInputs:C)&&(c?.recordInputs??!1),recordOutputs:!E&&(w?.action===`record`?w.recordOutputs:C)&&(c?.recordOutputs??!1)},telemetry=e=>{if(c===void 0&&e.bridgeIntegration===void 0)return;let t={};for(let n of Object.keys(e.runtimeContext??{}))t[n]=!0;let n=c!==void 0&&!(D.recordInputs&&D.recordOutputs),integrations=()=>getRegisteredTelemetryIntegrations({...r.ownsAgentSpans?{excludeEveOtelIntegration:!0}:void 0,sanitizeEveOtelErrors:n});return{functionId:c?.functionId??d.agentName,includeRuntimeContext:t,integrations:e.bridgeIntegration===void 0?n?[...integrations()]:void 0:[e.bridgeIntegration,...integrations()],isEnabled:!0,recordInputs:D.recordInputs,recordOutputs:D.recordOutputs}},run=()=>a({createHandleEvent:e=>createInstrumentationHandleEvent({...e,agentName:d.agentName,channelAudience:S,channelKind:x?.kind,hooks:s,parentLineage:resolveParentLineage(y.parent,y.channel),parentTraceContext:y.parentTraceContext,rootSessionId:y.parent?.rootSessionId,sessionId:d.sessionId}),prepareAttempt:t=>{let n={attemptId:`${d.sessionId}:${t.turnId}:${t.stepIndex}:${t.attemptIndex}`,attemptIndex:t.attemptIndex,channelAudience:S,functionId:c?.functionId??d.agentName,rootSessionId:y.parent?.rootSessionId??d.sessionId,sessionId:d.sessionId,stepIndex:t.stepIndex,turnId:t.turnId},r=createAiSdkHookBridge(n,s,e.runInContext,t.runtimeContext);return{complete:()=>s.publish({idempotencyKey:attemptIdempotencyKey(n),scope:n,type:`step.attempt.completed`}),fail:e=>s.publish({error:e,idempotencyKey:attemptIdempotencyKey(n),scope:n,type:`step.attempt.failed`}),scope:n,telemetry:telemetry({bridgeIntegration:r,runtimeContext:t.runtimeContext})}},preparePreamble:e=>preparePreamble(e,y),publishInputResolutions:e=>publishInputResolutions({...e,hooks:s}),recordError:e=>{h!==void 0&&recordErrorOnSpan(h,e)},resolveRuntimeContext:e=>buildTelemetryRuntimeContext({...e,capturesContent:T,context:b,providerResolvers:r.runtimeContextResolvers,stepStartedResolver:r.stepStartedRuntimeContextResolver}),session:_,setTurnId:e=>h?.setAttribute(`eve.turn.id`,e),telemetry:()=>telemetry({}),traceContext:g===void 0||!isValidSpanContext(g)?void 0:{spanId:g.spanId,traceFlags:g.traceFlags,traceId:g.traceId}});try{return v===void 0?await run():await context.with(v,run)}finally{h?.end(),h=void 0}}}},preparePreamble:e=>preparePreamble(e,readSessionContext())}}function bindSessionInstrumentation(e){return bindInstrumentationRuntime(getInstrumentationRuntime(),e.ctx,{agentName:e.agentName,rootSessionId:e.rootSessionId,sessionId:e.sessionId})}function initializeSessionInstrumentation(e){let t=getInstrumentationRuntime(),r=e.ctx.get(ChannelInstrumentationKey),o=readForwardedTraceAssertion(e.parentTraceContext?.forwardedTracePolicy),l=o?.originAudience??normalizeChannelAudience(r?.metadata.audience),u=allocateSessionTraceSeed({agentName:e.agentName,audience:l,channelType:r?.channelType,forwardedTracePolicy:o,parentTraceContext:e.parentTraceContext,runtime:t});if(u!==void 0&&(e.ctx.set(SessionTraceSeedKey,u),o!==void 0&&log.info(`resolved forwarded trace policy`,{ceilingEffective:u.decision?.action===`record`?formatTraceContentCeiling(u.decision):`drop`,ceilingIn:formatTraceContentCeiling(o.ceiling),originAudience:o.originAudience}),o!==void 0&&e.parentTraceContext!==void 0)){let t={...e.parentTraceContext,...u};delete t.forwardedTracePolicy,e.ctx.set(ParentTraceContextKey,t)}e.ctx.set(OtelTraceEnabledKey,t?.prepareSessionTrace!==void 0)}function allocateSessionTraceSeed(e){if(e.parentTraceContext!==void 0){let t=e.forwardedTracePolicy?traceContentCeilingToDecision(e.forwardedTracePolicy.ceiling):void 0,n=readInstrumentationDecision(e.parentTraceContext.decision),r=t?n===void 0?t:intersectInstrumentationDecisions(t,n):n??resolveTracePolicyDecision(isSampledTrace(e.parentTraceContext),e.audience),i=e.forwardedTracePolicy?intersectInstrumentationDecisions(r,resolveTracePolicy(e.runtime?.otelSettings?.tracePolicy,{agentName:e.agentName,audience:e.audience,channelType:e.channelType})):r;return{decision:i,forwardedTracePolicy:e.forwardedTracePolicy,spanId:e.parentTraceContext.spanId,traceFlags:e.forwardedTracePolicy!==void 0&&i.action===`drop`?e.parentTraceContext.traceFlags&-2:e.parentTraceContext.traceFlags,traceId:e.parentTraceContext.traceId}}if(e.runtime?.prepareSessionTrace===void 0||e.runtime.idGenerator===void 0)return;let t=resolveTracePolicy(e.runtime.otelSettings?.tracePolicy,{agentName:e.agentName,audience:e.audience,channelType:e.channelType}),n=e.runtime.idGenerator.generateTraceId(),r=t.action===`record`&&(e.runtime.samplesTrace?.(n)??!0);return{decision:t,spanId:e.runtime.idGenerator.allocateSpanId(),traceFlags:+!!r,traceId:n}}function resolveStepInstrumentationDecision(e,t,r,i,a){if(e===void 0)return;if(i?.decision!==void 0)return readInstrumentationDecision(i.decision);if(a!==void 0)return a;let o=normalizeChannelAudience(r?.metadata.audience);return i===void 0?resolveTracePolicy(e.tracePolicy,{agentName:t,audience:o,channelType:r?.channelType}):resolveTracePolicyDecision(isSampledTrace(i),o)}function isValidSpanContext(e){return/^[0-9a-f]{32}$/u.test(e.traceId)&&e.traceId!==`00000000000000000000000000000000`&&/^[0-9a-f]{16}$/u.test(e.spanId)&&e.spanId!==`0000000000000000`}const globalRuntime=globalThis;function registerInstrumentationRuntime(e){let t=globalRuntime[INSTRUMENTATION_RUNTIME_KEY];return t===void 0?(globalRuntime[INSTRUMENTATION_RUNTIME_KEY]=e,e):(t.otelSettings=e.otelSettings,t)}function getInstrumentationRuntime(){return globalRuntime[INSTRUMENTATION_RUNTIME_KEY]}export{bindInstrumentationRuntime,bindSessionInstrumentation,getInstrumentationRuntime,initializeSessionInstrumentation,registerInstrumentationRuntime};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV=`EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY`,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV=`EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY`;export{EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.
|
|
1
|
+
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.48.0`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function tryResolveVerifiedPackageRoot(e){try{let t=realpathSync.native(e);return tryReadInstalledPackageInfo(t,EVE_PACKAGE_NAME)===void 0?void 0:dirname(t)}catch{return}}function findNearestVerifiedPackageRoot(e){let t=e;for(;;){let e=tryResolveVerifiedPackageRoot(join(t,`package.json`));if(e!==void 0)return e;let i=dirname(t);if(i===t)return;t=i}}function tryResolveDirectBuildLocation(e){let i=dirname(e);for(;;){if(basename(i)===`dist`){let e=tryResolveVerifiedPackageRoot(join(dirname(i),`package.json`));if(e!==void 0)return{packageBuildRoot:i,packageRoot:e}}let e=dirname(i);if(e===i)return;i=e}}function isSourceCheckout(e){return existsSync(join(e,`src`,`internal`,`application`,`package.ts`))}function tryCreatePackageLocation(e){if(isSourceCheckout(e))return{packageBuildRoot:null,packageRoot:e};let t=join(e,`dist`);if(existsSync(t))return{packageBuildRoot:t,packageRoot:e}}function resolveSelfPackageJsonPath(t){return createRequire(t).resolve(`${EVE_PACKAGE_NAME}/package.json`)}function resolvePackageLocationFromModulePath(e,t=resolveSelfPackageJsonPath){let r=realpathSync.native(e),i=tryResolveDirectBuildLocation(r);if(i!==void 0)return i;let a=findNearestVerifiedPackageRoot(dirname(r));if(a!==void 0&&isSourceCheckout(a))return{packageBuildRoot:null,packageRoot:a};try{let e=tryResolveVerifiedPackageRoot(t(r)),n=e===void 0?void 0:tryCreatePackageLocation(e);if(n!==void 0)return n}catch{}let o=a===void 0?void 0:tryCreatePackageLocation(a);if(o!==void 0)return o;throw Error(`Failed to resolve the eve package root from "${e}".`)}function resolvePackageLocation(){return cachedPackageLocation??=resolvePackageLocationFromModulePath(resolveCurrentModulePath()),cachedPackageLocation}function resolvePackageBuildRoot(){return resolvePackageLocation().packageBuildRoot}function resolvePackageRoot(){return resolvePackageLocation().packageRoot}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageLocationFromModulePath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare const EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV = "EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY";
|
|
1
|
+
export { EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV, EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV, } from "#internal/application/build-output-environment.js";
|
|
3
2
|
export interface ApplicationInfo {
|
|
4
3
|
appRoot: string;
|
|
5
4
|
outputDir: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash}from"node:crypto";import{join,resolve}from"node:path";import{resolveInstalledPackageInfo,resolvePackageRoot,resolvePackageSourceDirectoryPath}from"#internal/application/package.js";import{existsSync,readFileSync,readdirSync,rmSync}from"node:fs";import{workflowEntryReference}from"#execution/workflow-runtime.js";
|
|
1
|
+
import{createHash}from"node:crypto";import{join,resolve}from"node:path";import{resolveInstalledPackageInfo,resolvePackageRoot,resolvePackageSourceDirectoryPath}from"#internal/application/package.js";import{existsSync,readFileSync,readdirSync,rmSync}from"node:fs";import{workflowEntryReference}from"#execution/workflow-runtime.js";import{EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV}from"#internal/application/build-output-environment.js";function resolveApplicationRoot(e=process.cwd()){return resolve(e)}function getWorkflowBuildCacheKey(t){return createHash(`sha256`).update(t).digest(`hex`).slice(0,12)}function isVercelBuildEnvironment(){return!!process.env.VERCEL}function resolveNitroBuildDirectory(e){return join(e,`.eve`,`nitro`)}function resolveApplicationHostArtifactsDirectory(e){return join(e,`.eve`,`host`)}function resolveWorkflowBuildDirectory(e){let n=join(resolvePackageRoot(),`.eve`,`workflow-cache`);return pruneStaleWorkflowCacheSiblings(n),join(n,getWorkflowBuildCacheKey(e))}function pruneStaleWorkflowCacheSiblings(e){if(!existsSync(e))return;let n=resolveInstalledPackageInfo().version,i;try{i=readdirSync(e)}catch{return}for(let r of i){let i=join(e,r),a=join(i,`eve-cache.json`);if(existsSync(a))try{let e=JSON.parse(readFileSync(a,`utf8`));typeof e.eveVersion==`string`&&e.eveVersion!==n&&rmSync(i,{force:!0,recursive:!0})}catch{}}}function resolveSandboxCacheDirectory(e){return join(e,`.eve`,`sandbox-cache`)}function resolveOutputDirectory(e){return isVercelBuildEnvironment()?join(e,`.vercel`,`output`):join(e,`.output`)}function getApplicationInfo(e){return{appRoot:e,outputDir:resolveOutputDirectory(e),workflowId:workflowEntryReference.workflowId,workflowBuildDir:resolveWorkflowBuildDirectory(e),workflowSourceDir:resolvePackageSourceDirectoryPath(`src/execution`)}}export{EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV,getApplicationInfo,isVercelBuildEnvironment,resolveApplicationHostArtifactsDirectory,resolveApplicationRoot,resolveNitroBuildDirectory,resolveOutputDirectory,resolveSandboxCacheDirectory,resolveWorkflowBuildDirectory};
|
|
@@ -26,6 +26,9 @@ interface EveAttachmentErrorInput {
|
|
|
26
26
|
* Channels can inspect the `.kind` discriminator to decide whether to
|
|
27
27
|
* drop the attachment and continue the turn (the default posture for
|
|
28
28
|
* every kind today) or fail the whole delivery (future strict mode).
|
|
29
|
+
* `.message` crosses into model-visible input when the attachment is
|
|
30
|
+
* dropped, so it must not contain URLs, credentials, or verbatim upstream
|
|
31
|
+
* error text. Preserve private diagnostics on `.cause` instead.
|
|
29
32
|
* The original failure, when there is one, is preserved on `.cause` so
|
|
30
33
|
* observability can surface the upstream error without losing context.
|
|
31
34
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InternalToolDefinition, ToolExecuteFn } from "#tools/definition.js";
|
|
2
|
+
import { type CompiledToolBehavior } from "#tools/behavior.js";
|
|
2
3
|
import { type DynamicToolEventName } from "#dynamic/definition.js";
|
|
3
4
|
/**
|
|
4
5
|
* Canonical normalized shape of one authored tool default export.
|
|
@@ -6,8 +7,11 @@ import { type DynamicToolEventName } from "#dynamic/definition.js";
|
|
|
6
7
|
* Identity is path-derived — the compiler stamps the filename slug onto
|
|
7
8
|
* the compiled entry. This shape never carries an authored `name`.
|
|
8
9
|
*/
|
|
9
|
-
type NormalizedAuthoredTool = Readonly<Omit<
|
|
10
|
+
type NormalizedAuthoredTool = Readonly<Omit<InternalToolDefinition, "name"> & {
|
|
11
|
+
readonly behavior?: CompiledToolBehavior;
|
|
12
|
+
readonly execute?: ToolExecuteFn;
|
|
10
13
|
readonly hasApproval: boolean;
|
|
14
|
+
readonly hasExecute: boolean;
|
|
11
15
|
readonly hasModelOutputProjection: boolean;
|
|
12
16
|
}>;
|
|
13
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{expectFunction,expectObjectRecord,expectOnlyKnownKeys,expectPositiveInteger,expectString}from"#internal/authored-module.js";import{serializeInputSchema,serializeOutputSchema}from"#tools/schema.js";import{isDisabledToolSentinel}from"#tools/definition.js";import{assertResolverOnlyDynamicSentinel,isDynamicSentinel}from"#dynamic/definition.js";import{shouldRebindDynamicCallbacks}from"#internal/dynamic-tool-rebind.js";import{normalizeApproval}from"#internal/authored-definition/approval.js";import{isExperimentalWorkflowToolDefinition}from"#tools/workflow.js";import{isWebSearchToolDefinition}from"#tools/provided/web-search.js";function normalizeToolDefinition(n,r){if(isDynamicSentinel(n))return assertResolverOnlyDynamicSentinel(n,r),{kind:`dynamic-tool`,eventNames:Object.keys(n.events),rebindMissingCallbacks:shouldRebindDynamicCallbacks(n)};if(isDisabledToolSentinel(n))return{kind:`disabled`};if(isExperimentalWorkflowToolDefinition(n)){let e=expectObjectRecord(n,r);return expectOnlyKnownKeys(e,[`kind`,`maxSubagents`],r),{kind:`workflow-tool`,maxSubagents:e.maxSubagents===void 0?void 0:expectPositiveInteger(e.maxSubagents,r)}}if(isWebSearchToolDefinition(n)){let e=expectObjectRecord(n,r);expectOnlyKnownKeys(e,[`kind`,`provider`],r);let t=expectString(e.provider,r);if(t!==`exa`&&t!==`parallel`)throw Error(`${r} Expected "provider" to be one of: exa, parallel.`);return{kind:`web-search-tool`,provider:t}}let i=expectObjectRecord(n,r);expectOnlyKnownKeys(i,[`auth`,`description`,`execute`,`execution`,`inputSchema`,`approval`,`outputSchema`,`toModelOutput`],r);let a=i.inputSchema===void 0?null:serializeInputSchema(i.inputSchema),o=serializeOutputSchema(i.outputSchema),s=
|
|
1
|
+
import{expectFunction,expectObjectRecord,expectOnlyKnownKeys,expectPositiveInteger,expectString}from"#internal/authored-module.js";import{serializeInputSchema,serializeOutputSchema}from"#tools/schema.js";import{isDisabledToolSentinel}from"#tools/definition.js";import{assertResolverOnlyDynamicSentinel,isDynamicSentinel}from"#dynamic/definition.js";import{shouldRebindDynamicCallbacks}from"#internal/dynamic-tool-rebind.js";import{normalizeApproval}from"#internal/authored-definition/approval.js";import{isExperimentalWorkflowToolDefinition}from"#tools/workflow.js";import{isWebSearchToolDefinition}from"#tools/provided/web-search.js";import{readToolBehavior}from"#tools/behavior.js";function normalizeToolDefinition(n,r){if(isDynamicSentinel(n))return assertResolverOnlyDynamicSentinel(n,r),{kind:`dynamic-tool`,eventNames:Object.keys(n.events),rebindMissingCallbacks:shouldRebindDynamicCallbacks(n)};if(isDisabledToolSentinel(n))return{kind:`disabled`};if(isExperimentalWorkflowToolDefinition(n)){let e=expectObjectRecord(n,r);return expectOnlyKnownKeys(e,[`kind`,`maxSubagents`],r),{kind:`workflow-tool`,maxSubagents:e.maxSubagents===void 0?void 0:expectPositiveInteger(e.maxSubagents,r)}}if(isWebSearchToolDefinition(n)){let e=expectObjectRecord(n,r);expectOnlyKnownKeys(e,[`kind`,`provider`],r);let t=expectString(e.provider,r);if(t!==`exa`&&t!==`parallel`)throw Error(`${r} Expected "provider" to be one of: exa, parallel.`);return{kind:`web-search-tool`,provider:t}}let i=expectObjectRecord(n,r);expectOnlyKnownKeys(i,[`auth`,`description`,`execute`,`execution`,`inputSchema`,`approval`,`outputSchema`,`toModelOutput`],r);let a=i.inputSchema===void 0?null:serializeInputSchema(i.inputSchema),o=serializeOutputSchema(i.outputSchema),s=readToolBehavior(n),c=i.execute!==void 0;!c&&s?.handling?.kind!==`dispatch`&&s?.handling?.kind!==`request-input`&&expectFunction(i.execute,r);let l={description:expectString(i.description,r),hasApproval:i.approval!==void 0,hasExecute:c,hasModelOutputProjection:i.toModelOutput!==void 0,inputSchema:a};if(s!==void 0&&(l.behavior=s),c&&(l.execute=expectFunction(i.execute,r)),i.execution!==void 0){if(!c)throw Error(`${r} Execute-less native tools cannot use background execution.`);let e=expectString(i.execution,r);if(e!==`background`)throw Error(`${r} Expected "execution" to be "background".`);l.execution=e}return o!==void 0&&(l.outputSchema=o),i.approval!==void 0&&normalizeApproval(i.approval,r),i.toModelOutput!==void 0&&expectFunction(i.toModelOutput,r),i.auth!==void 0&&expectFunction(expectObjectRecord(i.auth,r).getToken,r),{kind:`tool`,definition:l}}export{normalizeToolDefinition};
|
|
@@ -48,7 +48,13 @@ export declare function bundleExtensionDistributionGraph(input: {
|
|
|
48
48
|
* Shared dependencies are parsed and emitted once instead of once per authored
|
|
49
49
|
* entry.
|
|
50
50
|
*/
|
|
51
|
+
export interface AuthoredModuleMapBundle {
|
|
52
|
+
readonly code: string;
|
|
53
|
+
/** Fingerprint of the sources that also feed the driver and step registry; a change rebuilds the host. */
|
|
54
|
+
readonly workflowSourceFingerprint: string | undefined;
|
|
55
|
+
}
|
|
51
56
|
export declare function bundleAuthoredModuleMapForGeneration(input: {
|
|
52
57
|
readonly manifest: CompiledAgentManifest;
|
|
53
58
|
readonly moduleMapPath: string;
|
|
54
|
-
}): Promise<
|
|
59
|
+
}): Promise<AuthoredModuleMapBundle>;
|
|
60
|
+
export declare function resolveAuthoredPackageRoot(modulePath: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createHash}from"node:crypto";import{expectObjectRecord}from"#internal/authored-module.js";import{dirname,join,resolve}from"node:path";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{existsSync,mkdirSync,realpathSync,writeFileSync}from"node:fs";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";import{
|
|
2
|
-
`),moduleType:`js`}}}:null,...n.plugins,t.extensionScopeNamespace===void 0?null:createFixedNamespaceScopePlugin(t.extensionScopeNamespace),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:
|
|
1
|
+
import{createHash}from"node:crypto";import{expectObjectRecord}from"#internal/authored-module.js";import{dirname,join,relative,resolve,sep}from"node:path";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{existsSync,mkdirSync,realpathSync,writeFileSync}from"node:fs";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{createAuthoredModuleBundleError}from"#internal/authored-module-bundle.js";import{createAuthoredModuleEvaluationError}from"#internal/authored-module-evaluation-error.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createAuthoredRelativeExtensionResolverPlugin}from"#internal/authored-relative-extension-resolver.js";import{createExtensionScopePlugin,createFixedNamespaceScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{buildSingleRolldownChunk,buildWithNitroRolldown}from"#internal/bundler/nitro-rolldown.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";import{prepareAuthoredWorkflowDirectives}from"#internal/workflow-bundle/authored-workflow-directives.js";import{createDynamicCapabilityTransformPlugin}from"#internal/workflow-bundle/dynamic-capability-transform-plugin.js";import{applyWorkflowTransform,isAuthoredApplicationModule}from"#internal/workflow-bundle/workflow-builders.js";const AUTHORED_BUNDLED_MODULE_EXTENSION=/\.[cm]?[jt]sx?$/,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH=join(`node_modules`,`.cache`,`eve`,`authored-modules`),CHANNEL_MODULE_CACHE_KEY=`__eveChannelModuleCache__`;function getChannelModuleCache(){return globalThis[CHANNEL_MODULE_CACHE_KEY]}const inFlightModuleLoads=new Map;function loadAuthoredModuleNamespace(e,t={}){let n=createInFlightModuleLoadKey(resolve(e),t),r=inFlightModuleLoads.get(n);if(r!==void 0)return r;let i=(async()=>{try{return await doLoadAuthoredModuleNamespace(e,t)}finally{inFlightModuleLoads.delete(n)}})();return inFlightModuleLoads.set(n,i),i}async function doLoadAuthoredModuleNamespace(e,n){return expectObjectRecord(AUTHORED_BUNDLED_MODULE_EXTENSION.test(e)?await loadBundledAuthoredModule(e,n):await import(createFileImportSpecifier(e)),`Expected "${e}" to export a module namespace object.`)}function createFileImportSpecifier(e){let t=e.replaceAll(`\\`,`/`);return/^[A-Za-z]:\//.test(t)?`file:///${encodeURI(t)}`:t.startsWith(`/`)?`file://${encodeURI(t)}`:t}async function bundleAuthoredModuleCode(e,t={}){let n=resolveAuthoredPackageRoot(e);return await buildAuthoredModuleBundle(e,t,{channelIdentity:!0,packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:n}),plugins:[createAuthoredWorkflowDirectivePlugin({appRoot:n})],sourcemap:`inline`})}async function bundleAuthoredModuleForGeneration(e,t={}){return removeRolldownModuleRegionComments(await buildAuthoredModuleBundle(e,t,{channelIdentity:!1,packageBoundaryPlugin:createGenerationPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[createAuthoredDirectiveGuardPlugin()],sourcemap:!1}))}async function bundleExtensionDistributionGraph(e){let t=[createAuthoredDirectiveGuardPlugin(),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:e.packageRoot}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:e.packageRoot,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createDistributionPackageBoundaryPlugin({packageRoot:e.packageRoot,runtimeDependencies:e.runtimeDependencies})];try{let n=await buildWithNitroRolldown({cwd:e.packageRoot,input:Object.fromEntries(e.entries.map(e=>[e.name,e.path])),platform:`node`,plugins:t,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(e.packageRoot),write:!1,output:{chunkFileNames:`_chunks/[name]-[hash].mjs`,codeSplitting:!0,comments:!1,entryFileNames:`[name].mjs`,format:`esm`,sourcemap:!1}}),r=new Map;for(let e of n.output)e.type===`chunk`&&r.set(e.fileName,removeRolldownModuleRegionComments(e.code));return r}catch(t){throw createAuthoredModuleBundleError(e.packageRoot,t)}}async function bundleAuthoredModuleMapForGeneration(e){let t=resolveAuthoredPackageRoot(e.manifest.agentRoot),n=resolvePackageSourceFilePath(`src/internal/programmatic-source-loader.ts`),r=normalizeExternalDependencies([...e.manifest.config.build?.externalDependencies??[],...e.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])]),i=createCompiledModuleMapSource({manifest:e.manifest,moduleMapPath:e.moduleMapPath,programmaticLoaderImportSpecifier:n}),a=createExtensionScopePlugin([e.manifest,...e.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({packageNamespace:e.packageNamespace,sourceRoot:e.sourceRoot})))),o=new AuthoredWorkflowSourceRecorder(t),c=[createVirtualGenerationModuleMapPlugin({id:e.moduleMapPath,source:i}),createExternalRuntimeImportPlugin(n),createAuthoredWorkflowDirectivePlugin({appRoot:t,recorder:o}),createDynamicCapabilityTransformPlugin({workflowFunctions:e=>o.workflowFunctions(e)}),o.graphPlugin(),a,createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:t}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:t,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),createGenerationPackageBoundaryPlugin({externalDependencies:r,packageRoot:t})].filter(e=>e!==null);try{return{code:removeRolldownModuleRegionComments((await buildSingleRolldownChunk(`authored module map`,{cwd:t,input:e.moduleMapPath,platform:`node`,plugins:c,resolve:{conditionNames:[`eve-source`],extensions:[...RESOLVE_EXTENSIONS]},tsconfig:resolveAuthoredTsConfigPath(t),output:{comments:!1,format:`esm`,sourcemap:!1}})).code),workflowSourceFingerprint:o.fingerprint()}}catch(t){throw createAuthoredModuleBundleError(e.moduleMapPath,t)}}function createExternalRuntimeImportPlugin(e){let t=normalizeEsmImportSpecifier(e);return{name:`eve-external-runtime-import`,resolveId(e){return e===t?{external:!0,id:t}:void 0}}}var AuthoredWorkflowSourceRecorder=class{#e;#t=new Set;#n=new Map;#r=new Map;#i=new Map;constructor(e){this.#e=e}record(e,t,n){this.#r.set(e,t),(n.steps!==void 0||n.workflows!==void 0)&&this.#t.add(e);let r=Object.values(n.workflows??{})[0];r!==void 0&&this.#i.set(e,new Set(Object.keys(r)))}workflowFunctions(e){return this.#i.get(e)}graphPlugin(){let e=this.#n;return{name:`eve-authored-module-graph`,buildEnd(){for(let t of this.getModuleIds()){let n=this.getModuleInfo(t);n!==null&&e.set(t,[...n.importedIds,...n.dynamicallyImportedIds])}}}}fingerprint(){if(this.#t.size===0)return;let t=new Set,n=[...this.#t];for(let e=n.shift();e!==void 0;e=n.shift())t.has(e)||!this.#r.has(e)||(t.add(e),n.push(...this.#n.get(e)??[]));let r=createHash(`sha256`);for(let e of[...t].sort())r.update(relative(this.#e,e).split(sep).join(`/`)).update(`\0`).update(this.#r.get(e)??``).update(`\0`);return r.digest(`hex`)}};function createVirtualGenerationModuleMapPlugin(e){return{name:`eve-generation-module-map`,resolveId(t){return t===e.id?t:void 0},load(t){return t===e.id?{code:e.source,moduleType:`js`}:void 0}}}async function buildAuthoredModuleBundle(e,t,n){let r=n.channelIdentity?getChannelModuleCache():void 0,i=resolveAuthoredPackageRoot(e),o=resolveAuthoredTsConfigPath(i),s=[r&&r.size>0?{name:`eve-channel-identity`,async resolveId(e,t,n){if(!/channels[/\\]/.test(e)||n.kind!==`import-statement`)return;let i=await this.resolve(e,t,{kind:n.kind,skipSelf:!0});if(i===null||typeof i.id!=`string`)return;let o=resolve(i.id);if(r.has(o))return{id:`${CACHED_CHANNEL_PREFIX}${o}`}},load(e){if(!e.startsWith(CACHED_CHANNEL_PREFIX))return;let t=e.slice(CACHED_CHANNEL_PREFIX.length);return{code:[`const cache = globalThis["${CHANNEL_MODULE_CACHE_KEY}"];`,`export default cache.get(${JSON.stringify(t)});`].join(`
|
|
2
|
+
`),moduleType:`js`}}}:null,...n.plugins,t.extensionScopeNamespace===void 0?null:createFixedNamespaceScopePlugin(t.extensionScopeNamespace),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin({packageRoot:i}),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:i,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),n.packageBoundaryPlugin].filter(e=>e!==null);try{return(await buildSingleRolldownChunk(`authored module for "${e}"`,{cwd:i,input:e,platform:`node`,plugins:s,resolve:{conditionNames:[`eve-source`],extensions:[...RESOLVE_EXTENSIONS]},tsconfig:o,output:{comments:!1,format:`esm`,sourcemap:n.sourcemap}})).code}catch(t){throw createAuthoredModuleBundleError(e,t)}}function createAuthoredDirectiveGuardPlugin(){return{name:`eve-authored-directive-guard`,async transform(e,t){if(!AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)||isNodeModulesPath(t))return;let{hasDirectives:n}=await prepareAuthoredWorkflowDirectives({filePath:t,source:e});if(n)throw Error(`Module "${t}" uses Workflow directives ("use step" or "use workflow"). Workflow directives are supported in application modules only, not in extensions or instrumentation.`)}}}function createAuthoredWorkflowDirectivePlugin(e){return{name:`eve-authored-workflow-directives`,async transform(t,n){if(!AUTHORED_BUNDLED_MODULE_EXTENSION.test(n)||isNodeModulesPath(n)||!isAuthoredApplicationModule(n,e.appRoot))return;let r=await applyWorkflowTransform(n,t,`client`,n,e.appRoot);return e.recorder?.record(n,t,r.workflowManifest),r.code===t?void 0:{code:r.code,map:null}}}}function removeRolldownModuleRegionComments(e){return e.split(`
|
|
3
3
|
`).filter(e=>!e.startsWith(`//#region `)&&e!==`//#endregion`).join(`
|
|
4
|
-
`)}async function loadBundledAuthoredModule(t,n){let i=await bundleAuthoredModuleCode(t,n),a=normalizeExternalDependencies(n.externalDependencies),
|
|
4
|
+
`)}async function loadBundledAuthoredModule(t,n){let i=await bundleAuthoredModuleCode(t,n),a=normalizeExternalDependencies(n.externalDependencies),o=createHash(`sha1`).update(t).update(`\0`).update(a.join(`\0`)).update(`\0`).update(n.extensionScopeNamespace??``).update(`\0`).update(i).digest(`hex`),s=join(resolveAuthoredPackageRoot(t),AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH),l=join(s,`${o}.mjs`);existsSync(l)||(mkdirSync(s,{recursive:!0}),writeFileSync(l,i));try{return await import(`${createFileImportSpecifier(l)}?v=${o}`)}catch(e){throw createAuthoredModuleEvaluationError(t,e)}}function createInFlightModuleLoadKey(e,t){return`${e}\0${normalizeExternalDependencies(t.externalDependencies).join(`\0`)}\0${t.extensionScopeNamespace??``}`}function resolveAuthoredTsConfigPath(e){for(let t of[`tsconfig.json`,`jsconfig.json`]){let n=join(e,t);if(existsSync(n))return n}return!1}function resolveAuthoredPackageRoot(e){let t=dirname(e);for(;;){if(existsSync(join(t,`package.json`)))return realpathSync(t);let i=dirname(t);if(i===t)throw Error(`Failed to resolve the authored package root for "${e}".`);t=i}}export{bundleAuthoredModuleCode,bundleAuthoredModuleForGeneration,bundleAuthoredModuleMapForGeneration,bundleExtensionDistributionGraph,loadAuthoredModuleNamespace,resolveAuthoredPackageRoot};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isBuiltin}from"node:module";import{dirname,join,resolve,sep}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";const CACHED_CHANNEL_PREFIX=`eve-cached-channel:`,RESOLVE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createGenerationPackageBoundaryPlugin(e){return{name:`eve-generation-package-boundary`,async resolveId(t,n,r){if(isPackageImport(t)
|
|
1
|
+
import{isBuiltin}from"node:module";import{dirname,join,resolve,sep}from"node:path";import{resolveWorkflowModulePath}from"#internal/application/package.js";import{existsSync,readFileSync,realpathSync}from"node:fs";import{normalizeEsmImportSpecifier}from"#internal/application/import-specifier.js";const CACHED_CHANNEL_PREFIX=`eve-cached-channel:`,RESOLVE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createGenerationPackageBoundaryPlugin(e){return{name:`eve-generation-package-boundary`,async resolveId(t,n,r){if(isPackageImport(t)){if(isFrameworkRuntimeImport(t,n))return{external:!0,id:resolveFrameworkRuntimeImport(t)};if(await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:n,kind:r.kind,packageRoot:e.packageRoot,source:t})!==void 0)return{external:!0,id:t}}}}}function createRuntimeLoaderPackageBoundaryPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-runtime-loader-package-boundary`,async resolveId(n,i,a){if(!isPackageImport(n))return;if(isFrameworkRuntimeImport(n,i))return{external:!0,id:resolveFrameworkRuntimeImport(n)};let o=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:i,kind:a.kind,packageRoot:e.packageRoot,source:n});if(o!==void 0)return{external:!0,id:normalizeEsmImportSpecifier(resolveExistingExternalFilePath(o.resolvedId)??o.resolvedId)};let s=i===void 0||i.startsWith(`\0`)||i.startsWith(`eve-cached-channel:`)?void 0:resolve(i);if(s!==void 0&&isPathInsideOrEqual(toCanonicalPath(s),t)){let e=await this.resolve(n,i,{kind:a.kind,skipSelf:!0});if(e===null||typeof e.id!=`string`)throw Error(`Cannot resolve package "${n}" imported from "${s}". Install it with your package manager (e.g. \`pnpm install\`); a running \`eve dev\` retries on the next rebuild.`);if(isNodeModulesPath(e.id))return{external:!0,id:n}}}}}function createDistributionPackageBoundaryPlugin(t){let r=new Set(t.runtimeDependencies);return{name:`eve-extension-distribution-package-boundary`,async resolveId(i,a,o){if(!isPackageImport(i))return;if(i.startsWith(`#`)){let e=await this.resolve(i,a,{kind:o.kind,skipSelf:!0});if(e!==null&&typeof e.id==`string`&&!isPathInsideOrEqual(toCanonicalPath(e.id),toCanonicalPath(t.packageRoot))){let t=nearestPackageName(e.id);if(t!==void 0&&!r.has(t))throw Error(`Package import "${i}" resolves to undeclared package "${t}". Add "${t}" to dependencies, optionalDependencies, or peerDependencies.`)}return}if(isBuiltin(i))return{external:!0,id:i};let s=packageImportName(i);if(!r.has(s))throw Error(`Package "${i}" is not declared by the extension. Add "${s}" to dependencies, optionalDependencies, or peerDependencies.`);let c=await this.resolve(i,a,{kind:o.kind,skipSelf:!0});if(c===null&&(c=await this.resolve(i,join(t.packageRoot,`package.json`),{kind:o.kind,skipSelf:!0})),c===null||typeof c.id!=`string`)throw Error(`Cannot resolve declared package "${i}". Install the extension's dependencies before building.`);return{external:!0,id:i}}}}async function resolveConfiguredExternalModule(e){let t=resolveConfiguredExternalDependency(e.source,e.externalDependencies);if(t===void 0)return;let r=await this.resolve(e.source,e.importer,{kind:e.kind,skipSelf:!0});if(r===null&&(r=await this.resolve(e.source,join(e.packageRoot,`package.json`),{kind:e.kind,skipSelf:!0})),r===null||typeof r.id!=`string`)throw Error(`Cannot resolve external package "${e.source}".`);return{packageName:t,resolvedId:r.id}}function normalizeExternalDependencies(e=[]){return[...new Set(e)].sort()}function resolveConfiguredExternalDependency(e,t){return t.find(t=>e===t||e.startsWith(`${t}/`))}function packageImportName(e){return e.startsWith(`@`)?e.split(`/`,2).join(`/`):e.split(`/`,1)[0]}function nearestPackageName(e){let r=dirname(toCanonicalPath(e));for(;;){let e=join(r,`package.json`);if(existsSync(e))try{let t=JSON.parse(readFileSync(e,`utf8`));return typeof t.name==`string`&&t.name.length>0?t.name:void 0}catch{return}let i=dirname(r);if(i===r)return;r=i}}function resolveExistingExternalFilePath(e){if(existsSync(e))return e;for(let t of RESOLVE_EXTENSIONS){let n=`${e}${t}`;if(existsSync(n))return n}}function isPackageImport(e){return isPathImport(e)||/^(?:node|data|file):/.test(e)||e.startsWith(`@/`)?!1:!e.startsWith(CACHED_CHANNEL_PREFIX)}function isPathImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function isFrameworkRuntimeImport(e,t){return e===`eve`||e.startsWith(`eve/`)?!0:e===`workflow`||e.startsWith(`workflow/`)||e.startsWith(`@workflow/`)?t===void 0||!isNodeModulesPath(t):!1}function resolveFrameworkRuntimeImport(e){return e===`eve`||e.startsWith(`eve/`)?e:normalizeEsmImportSpecifier(resolveWorkflowModulePath(e))}function isNodeModulesPath(e){return e.replaceAll(`\\`,`/`).includes(`/node_modules/`)}function toCanonicalPath(e){try{return realpathSync(e)}catch{return resolve(e)}}function isPathInsideOrEqual(e,t){let n=resolve(e),a=resolve(t);return n===a||n.startsWith(`${a}${sep}`)}export{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createDistributionPackageBoundaryPlugin,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies};
|
|
@@ -6,6 +6,8 @@ interface PreparedAuthoredRuntimeInstrumentation {
|
|
|
6
6
|
export interface PreparedAuthoredRuntimeModules {
|
|
7
7
|
readonly instrumentation?: PreparedAuthoredRuntimeInstrumentation;
|
|
8
8
|
readonly moduleMapCode: string;
|
|
9
|
+
/** Identity of authored sources shared by the workflow driver and step registrations. */
|
|
10
|
+
readonly workflowSourceFingerprint: string | undefined;
|
|
9
11
|
}
|
|
10
12
|
/** Builds the authored runtime graph before a development or production host packages it. */
|
|
11
13
|
export declare function prepareAuthoredRuntimeModules(input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bundleAuthoredModuleForGeneration,bundleAuthoredModuleMapForGeneration}from"#internal/authored-module-loader.js";import{resolveInstrumentationLayout}from"#internal/instrumentation-layout.js";async function prepareAuthoredRuntimeModules(r){let
|
|
1
|
+
import{bundleAuthoredModuleForGeneration,bundleAuthoredModuleMapForGeneration}from"#internal/authored-module-loader.js";import{resolveInstrumentationLayout}from"#internal/instrumentation-layout.js";async function prepareAuthoredRuntimeModules(r){let{code:i,workflowSourceFingerprint:a}=await bundleAuthoredModuleMapForGeneration(r),o=r.manifest.config.experimental?.instrumentationProviders??!1?resolveInstrumentationLayout({agentRoot:r.manifest.agentRoot,providersEnabled:!0}):void 0,s=r.manifest.config.build?.externalDependencies??[],bundleInstrumentationModule=async t=>await bundleAuthoredModuleForGeneration(t,{externalDependencies:s}),c;if(o?.kind===`directory`){let e={};for(let[t,n]of Object.entries(o.modulePathsBySlot))e[t]=await bundleInstrumentationModule(n);c={kind:`directory`,moduleCodeBySlot:e}}return c===void 0?{moduleMapCode:i,workflowSourceFingerprint:a}:{instrumentation:c,moduleMapCode:i,workflowSourceFingerprint:a}}export{prepareAuthoredRuntimeModules};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const clientContextKey=`__eveClientContext`;function attachClientContext(e,t){return t!==void 0&&(e[clientContextKey]=t),e}function readClientContext(e){return e?.[clientContextKey]}export{attachClientContext,readClientContext};
|
|
@@ -15,6 +15,8 @@ export declare function stampDevelopmentClientAddress(headers: Headers | Incomin
|
|
|
15
15
|
* proxied dev topology is the parent's loopback hop.
|
|
16
16
|
*/
|
|
17
17
|
export declare function readTrustedDevelopmentClientAddress(headers: Headers, secret: string | undefined): string | undefined;
|
|
18
|
+
/** Verifies parent-stamped client provenance carried beyond the original request. */
|
|
19
|
+
export declare function isTrustedDevelopmentClientAddress(address: string, signature: string, secret: string | undefined): boolean;
|
|
18
20
|
/**
|
|
19
21
|
* Constant-time string comparison over fixed-length digests, so neither the
|
|
20
22
|
* length nor the content of a secret comparison leaks through timing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash,createHmac,timingSafeEqual}from"node:crypto";const DEVELOPMENT_CLIENT_ADDRESS_HEADER=`x-eve-dev-client-address`,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER=`x-eve-dev-client-address-signature`;function stampDevelopmentClientAddress(e,t,n){deleteHeader(e,DEVELOPMENT_CLIENT_ADDRESS_HEADER),deleteHeader(e,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER),!(t===void 0||t.length===0||n===void 0||n.length===0)&&(setHeader(e,DEVELOPMENT_CLIENT_ADDRESS_HEADER,t),setHeader(e,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER,signClientAddress(t,n)))}function readTrustedDevelopmentClientAddress(e,t){let n=e.get(DEVELOPMENT_CLIENT_ADDRESS_HEADER),i=e.get(DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER);
|
|
1
|
+
import{createHash,createHmac,timingSafeEqual}from"node:crypto";const DEVELOPMENT_CLIENT_ADDRESS_HEADER=`x-eve-dev-client-address`,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER=`x-eve-dev-client-address-signature`;function stampDevelopmentClientAddress(e,t,n){deleteHeader(e,DEVELOPMENT_CLIENT_ADDRESS_HEADER),deleteHeader(e,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER),!(t===void 0||t.length===0||n===void 0||n.length===0)&&(setHeader(e,DEVELOPMENT_CLIENT_ADDRESS_HEADER,t),setHeader(e,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER,signClientAddress(t,n)))}function readTrustedDevelopmentClientAddress(e,t){let n=e.get(DEVELOPMENT_CLIENT_ADDRESS_HEADER),i=e.get(DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER);return n!==null&&i!==null&&isTrustedDevelopmentClientAddress(n,i,t)?n:void 0}function isTrustedDevelopmentClientAddress(e,t,n){return e.length>0&&t.length>0&&n!==void 0&&n.length>0&&timingSafeEqualStrings(t,signClientAddress(e,n))}function timingSafeEqualStrings(t,r){return timingSafeEqual(createHash(`sha256`).update(t).digest(),createHash(`sha256`).update(r).digest())}function signClientAddress(e,n){return createHmac(`sha256`,n).update(e).digest(`base64url`)}function deleteHeader(e,t){if(e instanceof Headers){e.delete(t);return}delete e[t]}function setHeader(e,t,n){if(e instanceof Headers){e.set(t,n);return}e[t]=n}export{DEVELOPMENT_CLIENT_ADDRESS_HEADER,DEVELOPMENT_CLIENT_ADDRESS_SIGNATURE_HEADER,isTrustedDevelopmentClientAddress,readTrustedDevelopmentClientAddress,stampDevelopmentClientAddress,timingSafeEqualStrings};
|
|
@@ -2,6 +2,8 @@ import type { CompileAgentResult } from "#compiler/compile-agent.js";
|
|
|
2
2
|
import { type DevelopmentRuntimeArtifactsActivation, type DevelopmentRuntimeArtifactsSnapshot } from "#internal/nitro/dev-runtime-artifacts.js";
|
|
3
3
|
export interface DevelopmentGeneration extends DevelopmentRuntimeArtifactsSnapshot {
|
|
4
4
|
readonly fingerprint: string;
|
|
5
|
+
/** Identity of the authored sources the workflow driver and step registrations are built from. */
|
|
6
|
+
readonly workflowSourceFingerprint?: string;
|
|
5
7
|
}
|
|
6
8
|
export declare function stageDevelopmentGeneration(compileResult: CompileAgentResult): Promise<DevelopmentGeneration>;
|
|
7
9
|
export declare function publishDevelopmentGeneration(compileResult: CompileAgentResult): Promise<DevelopmentGeneration>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{rm}from"node:fs/promises";import{prepareAuthoredRuntimeModules}from"#internal/authored-runtime-modules.js";import{writeMaterializedAuthoredModules}from"#internal/materialized-authored-modules.js";import{activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,stageDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts.js";const developmentGenerationPruneStates=new Map;async function stageDevelopmentGeneration(r){let i=await prepareAuthoredRuntimeModules({manifest:r.manifest,moduleMapPath:r.paths.moduleMapPath}),a=await stageDevelopmentRuntimeArtifactsSnapshot(r);try{let e=await writeMaterializedAuthoredModules({prepared:i,runtimeAppRoot:a.runtimeAppRoot});return{...a,fingerprint:e.fingerprint}}catch(t){try{await rm(a.snapshotRoot,{force:!0,recursive:!0})}catch(e){throw AggregateError([t,e],`Failed to materialize and discard development generation "${a.snapshotRoot}".`)}throw t}}async function publishDevelopmentGeneration(e){let t=await stageDevelopmentGeneration(e);return await activateDevelopmentGeneration({appRoot:e.project.appRoot,generation:t}),t}async function activateDevelopmentGeneration(e){(await activateDevelopmentGenerationTransaction(e)).commit()}async function activateDevelopmentGenerationTransaction(e){let t=await activateDevelopmentRuntimeArtifactsSnapshotTransaction({appRoot:e.appRoot,snapshot:e.generation}),n=!1;return{commit(){n||(n=!0,t.commit(),requestDevelopmentGenerationPrune(e.appRoot))},async rollback(){n||(n=!0,await t.rollback())}}}async function discardDevelopmentGeneration(t){await rm(t.snapshotRoot,{force:!0,recursive:!0})}function requestDevelopmentGenerationPrune(e){let t=developmentGenerationPruneStates.get(e)??{requested:!1,running:void 0};developmentGenerationPruneStates.set(e,t),t.requested=!0,t.running===void 0&&startDevelopmentGenerationPruning(e,t)}function startDevelopmentGenerationPruning(e,t){t.running=(async()=>{for(;t.requested;)t.requested=!1,await pruneDevelopmentRuntimeArtifactsSnapshots({appRoot:e})})().catch(e=>{console.warn(`[eve:dev] failed to prune runtime generations: ${String(e)}`)}).finally(()=>{t.running=void 0,t.requested?startDevelopmentGenerationPruning(e,t):developmentGenerationPruneStates.delete(e)})}export{activateDevelopmentGeneration,activateDevelopmentGenerationTransaction,discardDevelopmentGeneration,publishDevelopmentGeneration,stageDevelopmentGeneration};
|
|
1
|
+
import{rm}from"node:fs/promises";import{prepareAuthoredRuntimeModules}from"#internal/authored-runtime-modules.js";import{writeMaterializedAuthoredModules}from"#internal/materialized-authored-modules.js";import{activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,stageDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts.js";const developmentGenerationPruneStates=new Map;async function stageDevelopmentGeneration(r){let i=await prepareAuthoredRuntimeModules({manifest:r.manifest,moduleMapPath:r.paths.moduleMapPath}),a=await stageDevelopmentRuntimeArtifactsSnapshot(r);try{let e=await writeMaterializedAuthoredModules({prepared:i,runtimeAppRoot:a.runtimeAppRoot});return i.workflowSourceFingerprint===void 0?{...a,fingerprint:e.fingerprint}:{...a,fingerprint:e.fingerprint,workflowSourceFingerprint:i.workflowSourceFingerprint}}catch(t){try{await rm(a.snapshotRoot,{force:!0,recursive:!0})}catch(e){throw AggregateError([t,e],`Failed to materialize and discard development generation "${a.snapshotRoot}".`)}throw t}}async function publishDevelopmentGeneration(e){let t=await stageDevelopmentGeneration(e);return await activateDevelopmentGeneration({appRoot:e.project.appRoot,generation:t}),t}async function activateDevelopmentGeneration(e){(await activateDevelopmentGenerationTransaction(e)).commit()}async function activateDevelopmentGenerationTransaction(e){let t=await activateDevelopmentRuntimeArtifactsSnapshotTransaction({appRoot:e.appRoot,snapshot:e.generation}),n=!1;return{commit(){n||(n=!0,t.commit(),requestDevelopmentGenerationPrune(e.appRoot))},async rollback(){n||(n=!0,await t.rollback())}}}async function discardDevelopmentGeneration(t){await rm(t.snapshotRoot,{force:!0,recursive:!0})}function requestDevelopmentGenerationPrune(e){let t=developmentGenerationPruneStates.get(e)??{requested:!1,running:void 0};developmentGenerationPruneStates.set(e,t),t.requested=!0,t.running===void 0&&startDevelopmentGenerationPruning(e,t)}function startDevelopmentGenerationPruning(e,t){t.running=(async()=>{for(;t.requested;)t.requested=!1,await pruneDevelopmentRuntimeArtifactsSnapshots({appRoot:e})})().catch(e=>{console.warn(`[eve:dev] failed to prune runtime generations: ${String(e)}`)}).finally(()=>{t.running=void 0,t.requested?startDevelopmentGenerationPruning(e,t):developmentGenerationPruneStates.delete(e)})}export{activateDevelopmentGeneration,activateDevelopmentGenerationTransaction,discardDevelopmentGeneration,publishDevelopmentGeneration,stageDevelopmentGeneration};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile}from"node:fs/promises";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import{resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{createExtensionScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{createExtensionExternalDependencyPlugin,resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createNitro}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{createCompiledSandboxBackendPrunePlugin}from"#internal/nitro/host/compiled-sandbox-backend-prune-plugin.js";import{configureDevelopmentNitroRoutes,configureProductionNitroRoutes}from"#internal/nitro/host/configure-nitro-routes.js";import{applyEveCronHandlerRoute}from"#internal/nitro/host/cron-handler-route.js";import{createNitroBundlerConfig}from"#internal/nitro/host/nitro-bundler-config.js";import{OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME,createOptionalEngineDependencyPlugin}from"#internal/nitro/host/optional-engine-dependency-plugin.js";import{addNitroRoutingImportSpecifierPlugin}from"#internal/nitro/host/nitro-routing-import-specifier-plugin.js";import{registerScheduleTaskHandlers}from"#internal/nitro/host/schedule-task-routes.js";import{createEveVercelOptions}from"#internal/nitro/host/vercel-build-output-config.js";import{applyWorkflowTransform}from"#internal/workflow-bundle/workflow-builders.js";const WORKFLOW_ALIAS_SPECIFIERS=[`workflow`,`workflow/api`,`workflow/errors`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`],WORKFLOW_TRANSFORM_PATCHED=Symbol(`eve.workflow-transform-patched`),FRAMEWORK_HOSTED_EXTERNAL_PACKAGES=[`@napi-rs/keyring`],LOCAL_SANDBOX_BACKEND_NAMES=new Set([`docker`,...Object.keys(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME)]);function resolveWorkflowAliases(){let e={};for(let t of WORKFLOW_ALIAS_SPECIFIERS)e[t]=resolveWorkflowModulePath(t);return e}function resolveProductionNitroPreset(){return process.env.VERCEL?`vercel`:void 0}function manifestEnablesWorkflow(e){return[e,...e.subagents.map(e=>e.agent)].some(e=>e.workflowTool!==void 0)}function manifestHasWebSocketChannel(e){return e.channelRoutes.effective.some(e=>e.method===`WEBSOCKET`)}function collectHostedTraceDependencies(e,t){let n=new Set(collectExtensionExternalDependencies(e.compileResult.manifest)),r=[...e.compileResult.manifest.config.build?.externalDependencies??[],...e.compileResult.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])];return[...new Set([...FRAMEWORK_HOSTED_EXTERNAL_PACKAGES,...t,...r,...[...n].map(e=>`${e}*`)])].filter(e=>e!==EVE_PACKAGE_NAME&&e!==`${EVE_PACKAGE_NAME}*`)}function collectExtensionExternalDependencies(e){return[e,...e.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.flatMap(e=>e.externalDependencies))}function collectConfiguredSandboxBackendNames(e){let t=[e,...e.subagents.map(e=>e.agent)];return new Set(t.map(e=>e.sandbox?.backendName).filter(e=>typeof e==`string`))}function shouldPruneLocalSandboxBackends(e){return e.preset===`vercel`&&![...e.configuredBackendNames].some(e=>LOCAL_SANDBOX_BACKEND_NAMES.has(e))}function createDevelopmentWatchOptions(e){return{ignored:[e,join(e,`**`)]}}function normalizePath(e){return e.replaceAll(`\\`,`/`)}function stripPathQueryAndHash(e){let t=e.indexOf(`?`),n=e.indexOf(`#`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?e:e.slice(0,r)}function stripFileSystemPrefix(e){return e.startsWith(`/@fs/`)?e.slice(4):e}function resolveNitroModuleComparisonPath(e,t){return t.startsWith(`file://`)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(fileURLToPath(t)))):isAbsolute(t)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(t))):normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(resolve(e,t))))}function isWorkflowBundlePath(e,t){let n=normalizePath(e);return n.startsWith(t)||n.includes(`/.eve/workflow-cache/`)}function normalizeStepTransformComparisonPath(e){let t=normalizePath(e);return process.platform===`win32`?t.toLowerCase():t}function parseImportedModuleSpecifiers(e){let t=/^\s*import\s+(?:.+?\s+from\s+)?["']([^"']+)["'];?\s*$/gm,n=[];for(let r of e.matchAll(t)){let e=r[1];e!==void 0&&n.push(e)}return n}function resolveNitroImportPath(e,n,r){return n.startsWith(`workflow`)?resolveWorkflowModulePath(n):n.startsWith(`.`)||n.startsWith(`/`)||n.startsWith(`file://`)?resolveNitroModuleComparisonPath(r===void 0?e:dirname(resolveNitroModuleComparisonPath(e,r)),n):null}async function collectNitroStepTransformTargets(t,n){let r=await readFile(t,`utf8`),i=new Set;for(let e of parseImportedModuleSpecifiers(r)){let r=resolveNitroImportPath(n,e,t);r!==null&&i.add(normalizeStepTransformComparisonPath(r))}return i}async function addNitroStepNoExternals(e,t){if(e.options.noExternals===!0)return;let n;try{n=await collectNitroStepTransformTargets(t,e.options.rootDir)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let r=Array.isArray(e.options.noExternals)?[...e.options.noExternals]:[];e.options.noExternals=[...new Set([...r,...n])]}function createRelativeTransformFilename(e,t){let n=createPackageRelativeTransformFilename(t);if(n!==void 0)return n;let r=normalizePath(e).replace(/\/$/,``),a=normalizePath(t),o=r.toLowerCase(),s=a.toLowerCase();if(s.startsWith(`${o}/`))return a.slice(r.length+1);if(s===o)return`.`;let c=relative(r,a).replaceAll(`\\`,`/`);if(c.startsWith(`../`)&&(c=c.split(`/`).filter(e=>e!==`..`).join(`/`)),c.includes(`:`)||c.startsWith(`/`)){let e=a.split(`/`).pop();return e===void 0||e.length===0?`unknown.ts`:e}return c}function createPackageRelativeTransformFilename(e){let t=normalizePath(resolvePackageRoot()).replace(/\/$/,``),n=normalizePath(e),r=t.toLowerCase(),i=n.toLowerCase(),a=`${t}/src/`,s=`${r}/src/`,c=`${t}/dist/src/`,l=`${r}/dist/src/`;if(i.startsWith(s))return`src/${n.slice(a.length)}`;if(i.startsWith(l))return`src/${n.slice(c.length)}`}function addWorkflowModuleSideEffectsPlugin(e,t){let n=[t,join(e.options.buildDir,`workflow`)].map(t=>resolveNitroModuleComparisonPath(e.options.rootDir,t));e.hooks.hook(`rollup:before`,(t,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({name:`eve:workflow-module-side-effects`,resolveId(t,r){let i=resolveNitroImportPath(e.options.rootDir,t,r)??resolveNitroModuleComparisonPath(e.options.rootDir,t);return n.some(e=>isWorkflowBundlePath(i,e))?{id:i,moduleSideEffects:`no-treeshake`}:null}})})}function addNitroStepModuleSideEffectsPlugin(e,t){let n=null,getStepTransformTargets=async()=>(n===null&&(n=await collectNitroStepTransformTargets(t.stepEntrypointPath,e.options.rootDir)),n),clearCachedStepTransformTargets=()=>{n=null};return e.hooks.hook(`build:before`,clearCachedStepTransformTargets),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({name:`eve:workflow-step-module-side-effects`,async resolveId(t,n){let r=resolveNitroImportPath(e.options.rootDir,t,n);return r===null||!(await getStepTransformTargets()).has(normalizeStepTransformComparisonPath(r))?null:{id:r,moduleSideEffects:`no-treeshake`}}})}),clearCachedStepTransformTargets}function addNitroStepTransformPlugin(e,t){let n=null,getStepTransformTargets=async()=>(n===null&&(n=await collectNitroStepTransformTargets(t.stepEntrypointPath,e.options.rootDir)),n),clearCachedStepTransformTargets=()=>{n=null};return e.hooks.hook(`build:before`,clearCachedStepTransformTargets),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({async transform(t,n){let r=await getStepTransformTargets(),i=resolveNitroModuleComparisonPath(e.options.rootDir,n);return r.has(normalizeStepTransformComparisonPath(i))?{code:(await applyWorkflowTransform(createRelativeTransformFilename(e.options.rootDir,i),t,`step`,i,e.options.rootDir)).code,map:null}:null},name:`eve:workflow-step-transform`})}),clearCachedStepTransformTargets}function addInstrumentationModuleSideEffectsPlugin(e,t){let n=new Set(t.map(normalizePath));e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`eve:instrumentation-module-side-effects`,resolveId(e){return n.has(normalizePath(e))?{id:e,moduleSideEffects:`no-treeshake`}:null}})})}function patchWorkflowTransformExcludePath(e,t){let n=normalizePath(t);e.hooks.hook(`rollup:before`,(e,t)=>{if(Array.isArray(t.plugins))for(let e of t.plugins){if(typeof e!=`object`||!e)continue;let t=e;if(t.name!==`workflow:transform`||t[WORKFLOW_TRANSFORM_PATCHED]===!0||typeof t.transform!=`function`)continue;let r=t.transform;t.transform=function(e,t,...i){return isWorkflowBundlePath(t,n)?null:r.call(this,e,t,...i)},t[WORKFLOW_TRANSFORM_PATCHED]=!0}})}function createApplicationNitroBundlerConfiguration(e,t){let n=collectConfiguredSandboxBackendNames(e.compileResult.manifest),r=shouldPruneLocalSandboxBackends({configuredBackendNames:n,preset:t})?createCompiledSandboxBackendPrunePlugin():null,i=[],a=[];for(let[e,t]of Object.entries(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME))(n.has(e)?i:a).push(t);let o=createExtensionScopePlugin([e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({sourceRoot:e.sourceRoot,packageNamespace:e.packageNamespace})))),s=[e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts),c=[r,createOptionalEngineDependencyPlugin(a),createExtensionExternalDependencyPlugin(s),o].filter(e=>e!==null);return{nitroRolldownConfig:createNitroBundlerConfig(c),nitroRollupConfig:createNitroBundlerConfig(c),tracedAppDependencies:collectHostedTraceDependencies(e,i),tracedAppDependencyPaths:resolveExtensionExternalDependencyPaths(s)}}function createApplicationNitroPlugins(e){let t=[e.compiledArtifacts.bootstrapPath,e.compiledArtifacts.workflowWorldPluginPath];return manifestEnablesWorkflow(e.compileResult.manifest)&&t.push(resolvePackageSourceFilePath(`src/internal/nitro/host/workflow-sandbox-runtime-plugin.ts`)),e.compiledArtifacts.instrumentationPluginPath!==void 0&&t.push(e.compiledArtifacts.instrumentationPluginPath),t}function configureSharedApplicationNitro(e,t){addNitroRoutingImportSpecifierPlugin(e);let n=resolveWorkflowAliases();for(let[t,r]of Object.entries(n))e.options.alias[t]=r;addWorkflowModuleSideEffectsPlugin(e,t.workflowBuildDir),patchWorkflowTransformExcludePath(e,t.workflowBuildDir),t.compiledArtifacts.instrumentationSourcePaths!==void 0&&addInstrumentationModuleSideEffectsPlugin(e,t.compiledArtifacts.instrumentationSourcePaths)}function configureNitroStepPlugins(e,t){return[addNitroStepModuleSideEffectsPlugin(e,{stepEntrypointPath:t}),addNitroStepTransformPlugin(e,{stepEntrypointPath:t})]}function externalizeDevelopmentWorkflowBundle(e,t){let n=new Set([normalizePath(join(t.workflowBuildDir,`workflows.mjs`))]);e.hooks.hook(`rollup:before`,(e,t)=>{let r=t.external;t.external=(e,...t)=>{if(n.has(normalizePath(e)))return!0;if(typeof r==`function`)return r(e,...t)}})}async function createDevelopmentApplicationNitro(e){let t=e.workspace.nitroBuildDir,n=createApplicationNitroBundlerConfiguration(e,void 0),i=createApplicationNitroPlugins(e);e.compiledArtifacts.instrumentationPluginPath===void 0&&i.unshift(resolvePackageSourceFilePath(`src/internal/nitro/host/local-tracing-runtime-plugin.ts`)),await prepareEveVersionedCacheDirectory(t);let a=await createNitro({_cli:{command:`dev`},buildDir:t,dev:!0,features:{websocket:!0},logLevel:1,output:{dir:e.workspace.nitroOutputDir},plugins:i,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:n.nitroRolldownConfig,rollupConfig:n.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:n.tracedAppDependencies,traceOpts:{nft:{paths:n.tracedAppDependencyPaths}},vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:!1}),watchOptions:createDevelopmentWatchOptions(e.appRoot)},{watch:!0});await writeEveVersionedCacheMetadata(t);let o=join(a.options.buildDir,`workflow`,`steps.mjs`);configureSharedApplicationNitro(a,e);let l=configureNitroStepPlugins(a,o);return a.hooks.hook(`dev:reload`,()=>{for(let e of l)e()}),externalizeDevelopmentWorkflowBundle(a,e),await configureDevelopmentNitroRoutes(a,e),await addNitroStepNoExternals(a,o),a}async function createProductionApplicationNitro(e,t){let n=resolveProductionNitroPreset(),i=createApplicationNitroBundlerConfiguration(e,n),a=createApplicationNitroPlugins(e);a.push(resolvePackageSourceFilePath(`src/internal/nitro/host/sandbox-shutdown-plugin.ts`)),await prepareEveVersionedCacheDirectory(t.buildDir);let o=await createNitro({_cli:{command:`build`},buildDir:t.buildDir,dev:!1,features:{websocket:manifestHasWebSocketChannel(e.compileResult.manifest)},output:{dir:t.outputDir},preset:n,plugins:a,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:i.nitroRolldownConfig,rollupConfig:i.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:i.tracedAppDependencies,traceOpts:{nft:{paths:i.tracedAppDependencyPaths}},vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:n===`vercel`,publicRoutePrefix:t.publicRoutePrefix})});return await writeEveVersionedCacheMetadata(t.buildDir),configureSharedApplicationNitro(o,e),configureNitroStepPlugins(o,join(e.workflowBuildDir,`steps.mjs`)),e.scheduleRegistrations.length>0&&(applyEveCronHandlerRoute(o),registerScheduleTaskHandlers(o,{artifactsConfig:createProductionNitroArtifactsConfig(),dispatchModulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/schedule-task.ts`),registrations:e.scheduleRegistrations})),await configureProductionNitroRoutes(o,e),await addNitroStepNoExternals(o,join(e.workflowBuildDir,`steps.mjs`)),o}export{createDevelopmentApplicationNitro,createProductionApplicationNitro,shouldPruneLocalSandboxBackends};
|
|
1
|
+
import{readFile}from"node:fs/promises";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import{resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{createExtensionScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{applyWorkflowTransform}from"#internal/workflow-bundle/workflow-builders.js";import{createExtensionExternalDependencyPlugin,resolveExtensionExternalDependencyPaths}from"#internal/nitro/host/extension-external-dependency-plugin.js";import{createNitro}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{createCompiledSandboxBackendPrunePlugin}from"#internal/nitro/host/compiled-sandbox-backend-prune-plugin.js";import{configureDevelopmentNitroRoutes,configureProductionNitroRoutes}from"#internal/nitro/host/configure-nitro-routes.js";import{applyEveCronHandlerRoute}from"#internal/nitro/host/cron-handler-route.js";import{createNitroBundlerConfig}from"#internal/nitro/host/nitro-bundler-config.js";import{OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME,createOptionalEngineDependencyPlugin}from"#internal/nitro/host/optional-engine-dependency-plugin.js";import{addNitroRoutingImportSpecifierPlugin}from"#internal/nitro/host/nitro-routing-import-specifier-plugin.js";import{registerScheduleTaskHandlers}from"#internal/nitro/host/schedule-task-routes.js";import{createEveVercelOptions}from"#internal/nitro/host/vercel-build-output-config.js";const WORKFLOW_ALIAS_SPECIFIERS=[`workflow`,`workflow/api`,`workflow/errors`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`],WORKFLOW_TRANSFORM_PATCHED=Symbol(`eve.workflow-transform-patched`),FRAMEWORK_HOSTED_EXTERNAL_PACKAGES=[`@napi-rs/keyring`],LOCAL_SANDBOX_BACKEND_NAMES=new Set([`docker`,...Object.keys(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME)]);function resolveWorkflowAliases(){let e={};for(let t of WORKFLOW_ALIAS_SPECIFIERS)e[t]=resolveWorkflowModulePath(t);return e}function resolveProductionNitroPreset(){return process.env.VERCEL?`vercel`:void 0}function manifestEnablesWorkflow(e){return[e,...e.subagents.map(e=>e.agent)].some(e=>e.workflowTool!==void 0)}function manifestHasWebSocketChannel(e){return e.channelRoutes.effective.some(e=>e.method===`WEBSOCKET`)}function collectHostedTraceDependencies(e,t){let n=new Set(collectExtensionExternalDependencies(e.compileResult.manifest)),r=[...e.compileResult.manifest.config.build?.externalDependencies??[],...e.compileResult.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])];return[...new Set([...FRAMEWORK_HOSTED_EXTERNAL_PACKAGES,...t,...r,...[...n].map(e=>`${e}*`)])].filter(e=>e!==EVE_PACKAGE_NAME&&e!==`${EVE_PACKAGE_NAME}*`)}function collectExtensionExternalDependencies(e){return[e,...e.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.flatMap(e=>e.externalDependencies))}function collectConfiguredSandboxBackendNames(e){let t=[e,...e.subagents.map(e=>e.agent)];return new Set(t.map(e=>e.sandbox?.backendName).filter(e=>typeof e==`string`))}function shouldPruneLocalSandboxBackends(e){return e.preset===`vercel`&&![...e.configuredBackendNames].some(e=>LOCAL_SANDBOX_BACKEND_NAMES.has(e))}function createDevelopmentWatchOptions(e){return{ignored:[e,join(e,`**`)]}}function normalizePath(e){return e.replaceAll(`\\`,`/`)}function stripPathQueryAndHash(e){let t=e.indexOf(`?`),n=e.indexOf(`#`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?e:e.slice(0,r)}function stripFileSystemPrefix(e){return e.startsWith(`/@fs/`)?e.slice(4):e}function resolveNitroModuleComparisonPath(e,t){return t.startsWith(`file://`)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(fileURLToPath(t)))):isAbsolute(t)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(t))):normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(resolve(e,t))))}function isWorkflowBundlePath(e,t){let n=normalizePath(e);return n.startsWith(t)||n.includes(`/.eve/workflow-cache/`)}function normalizeStepTransformComparisonPath(e){let t=normalizePath(e);return process.platform===`win32`?t.toLowerCase():t}function parseImportedModuleSpecifiers(e){let t=/^\s*import\s+(?:.+?\s+from\s+)?["']([^"']+)["'];?\s*$/gm,n=[];for(let r of e.matchAll(t)){let e=r[1];e!==void 0&&n.push(e)}return n}function resolveNitroImportPath(e,n,r){return n.startsWith(`workflow`)?resolveWorkflowModulePath(n):n.startsWith(`.`)||n.startsWith(`/`)||n.startsWith(`file://`)?resolveNitroModuleComparisonPath(r===void 0?e:dirname(resolveNitroModuleComparisonPath(e,r)),n):null}async function collectNitroStepTransformTargets(t,n){let r=await readFile(t,`utf8`),i=new Set;for(let e of parseImportedModuleSpecifiers(r)){let r=resolveNitroImportPath(n,e,t);r!==null&&i.add(normalizeStepTransformComparisonPath(r))}return i}async function addNitroStepNoExternals(e,t){if(e.options.noExternals===!0)return;let n;try{n=await collectNitroStepTransformTargets(t,e.options.rootDir)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let r=Array.isArray(e.options.noExternals)?[...e.options.noExternals]:[];e.options.noExternals=[...new Set([...r,...n])]}function createRelativeTransformFilename(e,t){let n=createPackageRelativeTransformFilename(t);if(n!==void 0)return n;let r=normalizePath(e).replace(/\/$/,``),a=normalizePath(t),o=r.toLowerCase(),s=a.toLowerCase();if(s.startsWith(`${o}/`))return a.slice(r.length+1);if(s===o)return`.`;let c=relative(r,a).replaceAll(`\\`,`/`);if(c.startsWith(`../`)&&(c=c.split(`/`).filter(e=>e!==`..`).join(`/`)),c.includes(`:`)||c.startsWith(`/`)){let e=a.split(`/`).pop();return e===void 0||e.length===0?`unknown.ts`:e}return c}function createPackageRelativeTransformFilename(e){let t=normalizePath(resolvePackageRoot()).replace(/\/$/,``),n=normalizePath(e),r=t.toLowerCase(),i=n.toLowerCase(),a=`${t}/src/`,s=`${r}/src/`,c=`${t}/dist/src/`,l=`${r}/dist/src/`;if(i.startsWith(s))return`src/${n.slice(a.length)}`;if(i.startsWith(l))return`src/${n.slice(c.length)}`}function addWorkflowModuleSideEffectsPlugin(e,t){let n=[t,join(e.options.buildDir,`workflow`)].map(t=>resolveNitroModuleComparisonPath(e.options.rootDir,t));e.hooks.hook(`rollup:before`,(t,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({name:`eve:workflow-module-side-effects`,resolveId(t,r){let i=resolveNitroImportPath(e.options.rootDir,t,r)??resolveNitroModuleComparisonPath(e.options.rootDir,t);return n.some(e=>isWorkflowBundlePath(i,e))?{id:i,moduleSideEffects:`no-treeshake`}:null}})})}function addNitroStepModuleSideEffectsPlugin(e,t){let n=null,getStepTransformTargets=async()=>(n===null&&(n=await collectNitroStepTransformTargets(t.stepEntrypointPath,e.options.rootDir)),n),clearCachedStepTransformTargets=()=>{n=null};return e.hooks.hook(`build:before`,clearCachedStepTransformTargets),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({name:`eve:workflow-step-module-side-effects`,async resolveId(t,n){let r=resolveNitroImportPath(e.options.rootDir,t,n);return r===null||!(await getStepTransformTargets()).has(normalizeStepTransformComparisonPath(r))?null:{id:r,moduleSideEffects:`no-treeshake`}}})}),clearCachedStepTransformTargets}function addNitroStepTransformPlugin(e,t){let n=null,getStepTransformTargets=async()=>(n===null&&(n=await collectNitroStepTransformTargets(t.stepEntrypointPath,e.options.rootDir)),n),clearCachedStepTransformTargets=()=>{n=null};return e.hooks.hook(`build:before`,clearCachedStepTransformTargets),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({async transform(t,n){let r=await getStepTransformTargets(),i=resolveNitroModuleComparisonPath(e.options.rootDir,n);return r.has(normalizeStepTransformComparisonPath(i))?{code:(await applyWorkflowTransform(createRelativeTransformFilename(e.options.rootDir,i),t,`step`,i,e.options.rootDir)).code,map:null}:null},name:`eve:workflow-step-transform`})}),clearCachedStepTransformTargets}function addInstrumentationModuleSideEffectsPlugin(e,t){let n=new Set(t.map(normalizePath));e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`eve:instrumentation-module-side-effects`,resolveId(e){return n.has(normalizePath(e))?{id:e,moduleSideEffects:`no-treeshake`}:null}})})}function patchWorkflowTransformExcludePath(e,t){let n=normalizePath(t);e.hooks.hook(`rollup:before`,(e,t)=>{if(Array.isArray(t.plugins))for(let e of t.plugins){if(typeof e!=`object`||!e)continue;let t=e;if(t.name!==`workflow:transform`||t[WORKFLOW_TRANSFORM_PATCHED]===!0||typeof t.transform!=`function`)continue;let r=t.transform;t.transform=function(e,t,...i){return isWorkflowBundlePath(t,n)?null:r.call(this,e,t,...i)},t[WORKFLOW_TRANSFORM_PATCHED]=!0}})}function createApplicationNitroBundlerConfiguration(e,t){let n=collectConfiguredSandboxBackendNames(e.compileResult.manifest),r=shouldPruneLocalSandboxBackends({configuredBackendNames:n,preset:t})?createCompiledSandboxBackendPrunePlugin():null,i=[],a=[];for(let[e,t]of Object.entries(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME))(n.has(e)?i:a).push(t);let o=createExtensionScopePlugin([e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({sourceRoot:e.sourceRoot,packageNamespace:e.packageNamespace})))),s=[e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts),c=[r,createOptionalEngineDependencyPlugin(a),createExtensionExternalDependencyPlugin(s),o].filter(e=>e!==null);return{nitroRolldownConfig:createNitroBundlerConfig(c),nitroRollupConfig:createNitroBundlerConfig(c),tracedAppDependencies:collectHostedTraceDependencies(e,i),tracedAppDependencyPaths:resolveExtensionExternalDependencyPaths(s)}}function createApplicationNitroPlugins(e){let t=[e.compiledArtifacts.bootstrapPath,e.compiledArtifacts.workflowWorldPluginPath];return manifestEnablesWorkflow(e.compileResult.manifest)&&t.push(resolvePackageSourceFilePath(`src/internal/nitro/host/workflow-sandbox-runtime-plugin.ts`)),e.compiledArtifacts.instrumentationPluginPath!==void 0&&t.push(e.compiledArtifacts.instrumentationPluginPath),t}function configureSharedApplicationNitro(e,t){addNitroRoutingImportSpecifierPlugin(e);let n=resolveWorkflowAliases();for(let[t,r]of Object.entries(n))e.options.alias[t]=r;addWorkflowModuleSideEffectsPlugin(e,t.workflowBuildDir),patchWorkflowTransformExcludePath(e,t.workflowBuildDir),t.compiledArtifacts.instrumentationSourcePaths!==void 0&&addInstrumentationModuleSideEffectsPlugin(e,t.compiledArtifacts.instrumentationSourcePaths)}function configureNitroStepPlugins(e,t){return[addNitroStepModuleSideEffectsPlugin(e,{stepEntrypointPath:t}),addNitroStepTransformPlugin(e,{stepEntrypointPath:t})]}function externalizeDevelopmentWorkflowBundle(e,t){let n=new Set([normalizePath(join(t.workflowBuildDir,`workflows.mjs`))]);e.hooks.hook(`rollup:before`,(e,t)=>{let r=t.external;t.external=(e,...t)=>{if(n.has(normalizePath(e)))return!0;if(typeof r==`function`)return r(e,...t)}})}async function createDevelopmentApplicationNitro(e){let t=e.workspace.nitroBuildDir,n=createApplicationNitroBundlerConfiguration(e,void 0),i=createApplicationNitroPlugins(e);e.compiledArtifacts.instrumentationPluginPath===void 0&&i.unshift(resolvePackageSourceFilePath(`src/internal/nitro/host/local-tracing-runtime-plugin.ts`)),await prepareEveVersionedCacheDirectory(t);let a=await createNitro({_cli:{command:`dev`},buildDir:t,dev:!0,features:{websocket:!0},logLevel:1,output:{dir:e.workspace.nitroOutputDir},plugins:i,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:n.nitroRolldownConfig,rollupConfig:n.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:n.tracedAppDependencies,traceOpts:{nft:{paths:n.tracedAppDependencyPaths}},vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:!1}),watchOptions:createDevelopmentWatchOptions(e.appRoot)},{watch:!0});await writeEveVersionedCacheMetadata(t);let o=join(a.options.buildDir,`workflow`,`steps.mjs`);configureSharedApplicationNitro(a,e);let l=configureNitroStepPlugins(a,o);return a.hooks.hook(`dev:reload`,()=>{for(let e of l)e()}),externalizeDevelopmentWorkflowBundle(a,e),await configureDevelopmentNitroRoutes(a,e),await addNitroStepNoExternals(a,o),a}async function createProductionApplicationNitro(e,t){let n=resolveProductionNitroPreset(),i=createApplicationNitroBundlerConfiguration(e,n),a=createApplicationNitroPlugins(e);a.push(resolvePackageSourceFilePath(`src/internal/nitro/host/sandbox-shutdown-plugin.ts`)),await prepareEveVersionedCacheDirectory(t.buildDir);let o=await createNitro({_cli:{command:`build`},buildDir:t.buildDir,dev:!1,features:{websocket:manifestHasWebSocketChannel(e.compileResult.manifest)},output:{dir:t.outputDir},preset:n,plugins:a,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:i.nitroRolldownConfig,rollupConfig:i.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:i.tracedAppDependencies,traceOpts:{nft:{paths:i.tracedAppDependencyPaths}},vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:n===`vercel`,publicRoutePrefix:t.publicRoutePrefix})});return await writeEveVersionedCacheMetadata(t.buildDir),configureSharedApplicationNitro(o,e),configureNitroStepPlugins(o,join(e.workflowBuildDir,`steps.mjs`)),e.scheduleRegistrations.length>0&&(applyEveCronHandlerRoute(o),registerScheduleTaskHandlers(o,{artifactsConfig:createProductionNitroArtifactsConfig(),dispatchModulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/schedule-task.ts`),registrations:e.scheduleRegistrations})),await configureProductionNitroRoutes(o,e),await addNitroStepNoExternals(o,join(e.workflowBuildDir,`steps.mjs`)),o}export{createDevelopmentApplicationNitro,createProductionApplicationNitro,shouldPruneLocalSandboxBackends};
|
|
@@ -7,8 +7,8 @@ export interface AuthoredSourceWatcherHandle {
|
|
|
7
7
|
close(): Promise<void>;
|
|
8
8
|
flush(): Promise<void>;
|
|
9
9
|
rebuild(): Promise<void>;
|
|
10
|
-
suspend(): Promise<void>;
|
|
11
|
-
resume(options?: {
|
|
10
|
+
suspend(leaseId: string): Promise<void>;
|
|
11
|
+
resume(leaseId: string, options?: {
|
|
12
12
|
silent?: boolean;
|
|
13
13
|
}): Promise<void>;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getDevelopmentEnvironmentFilePaths}from"#cli/dev/environment.js";import{dirname,join,normalize,resolve,sep}from"node:path";import{existsSync}from"node:fs";import{providerSettingsPath}from"#setup/provider-settings.js";import{toErrorMessage}from"#shared/errors.js";import{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{resolveDevelopmentSourceSnapshotWatchPaths}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{watch as watch$1}from"#compiled/chokidar/index.js";const WATCHED_LOCKFILE_NAMES=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],WATCH_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WATCHER_IGNORED_DIRECTORY_NAMES=new Set([`.devtools`,`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`build`,`dist`,`node_modules`]);async function startAuthoredSourceWatcher(e){let t=e.preparedHost,n=!1,r=Promise.resolve(),i,a=!1,o=
|
|
1
|
+
import{getDevelopmentEnvironmentFilePaths}from"#cli/dev/environment.js";import{dirname,join,normalize,resolve,sep}from"node:path";import{existsSync}from"node:fs";import{providerSettingsPath}from"#setup/provider-settings.js";import{toErrorMessage}from"#shared/errors.js";import{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{resolveDevelopmentSourceSnapshotWatchPaths}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{watch as watch$1}from"#compiled/chokidar/index.js";const WATCHED_LOCKFILE_NAMES=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],WATCH_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WATCHER_IGNORED_DIRECTORY_NAMES=new Set([`.devtools`,`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`build`,`dist`,`node_modules`]);async function startAuthoredSourceWatcher(e){let t=e.preparedHost,n=!1,r=Promise.resolve(),i,a=!1,o=new Set,s=new Map,c=new Set,l=await resolveAuthoredWatchPaths(t),u=createWatchPathMap(l),d=watch$1(l,{awaitWriteFinish:{pollInterval:50,stabilityThreshold:160},followSymlinks:!1,ignoreInitial:!0,ignored:e=>shouldIgnoreWatcherPath(e,t.appRoot,t.workspaceExtensions)}),f=waitForWatcherReady(d),rebuild=async(i,a=!1)=>{n||o.size>0||(r=r.then(async()=>{if(n)return;let r=[...s.values()];if(!i&&r.length===0)return;let o=[...c];s.clear(),c.clear();let l=t;!a&&r.length>0&&console.log(formatChangeDetectedLogLine(l.appRoot,r));try{let n=await e.coordinator.rebuild({changedPaths:o});t=n.host,a||(n.kind===`structural`?console.log(STRUCTURAL_RELOAD_LOG_LINE):console.log(AUTHORED_ARTIFACTS_UPDATED_LOG_LINE)),u=syncWatcherPaths({nextWatchPaths:await resolveAuthoredWatchPaths(t),previousWatchPathsByKey:u,watcher:d})}catch(e){console.error(`[eve:dev] rebuild failed: ${toErrorMessage(e)}`)}}).catch(e=>{console.error(`[eve:dev] rebuild queue error: ${toErrorMessage(e)}`)}),await r)},flush=async()=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!1)},forceRebuild=async(e=!1)=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!0,e)};return d.on(`all`,(e,t)=>{n||!a||e===`addDir`||e===`unlinkDir`||(s.set(`${e}:${t}`,{event:e,path:t}),c.add(t),i!==void 0&&clearTimeout(i),i=setTimeout(()=>{i=void 0,flush()},120))}),await f,a=!0,{async close(){n=!0,i!==void 0&&(clearTimeout(i),i=void 0),await d.close(),await r},flush,rebuild:forceRebuild,async suspend(e){o.has(e)||(o.add(e),i!==void 0&&(clearTimeout(i),i=void 0),await r)},async resume(e,t){o.delete(e)&&o.size===0&&await forceRebuild(t?.silent)}}}async function waitForWatcherReady(e){await new Promise((t,n)=>{e.on(`ready`,()=>{t()}),e.on(`error`,e=>{n(e)})})}async function resolveAuthoredWatchPaths(t){let r=new Set([t.compileResult.project.agentRoot,join(t.appRoot,`package.json`),join(t.appRoot,`jsconfig.json`),join(t.appRoot,`tsconfig.json`),join(t.appRoot,`tsconfig.*.json`),providerSettingsPath(t.appRoot)]),i=await resolveTsConfigWatchPaths(t.appRoot),a=await resolveDevelopmentSourceSnapshotWatchPaths(t.appRoot);for(let e of t.workspaceExtensions){r.add(e.config.sourceRoot);for(let t of e.buildConfigPaths)r.add(t)}for(let n of getDevelopmentEnvironmentFilePaths(t.appRoot))r.add(n);for(let e of a)r.add(e);for(let e of i)r.add(e);for(let e of resolveLockfileSearchDirectories(t.appRoot))for(let t of WATCHED_LOCKFILE_NAMES)r.add(join(e,t));return[...r].sort((e,t)=>e.localeCompare(t))}function createWatchPathMap(e){let t=new Map;for(let n of e)t.set(toWatchPathKey(n),n);return t}function syncWatcherPaths(e){let t=createWatchPathMap(e.nextWatchPaths),n=[],r=[];for(let[r,i]of t)e.previousWatchPathsByKey.has(r)||n.push(i);for(let[n,i]of e.previousWatchPathsByKey)t.has(n)||r.push(i);return n.length>0&&e.watcher.add(n),r.length>0&&e.watcher.unwatch(r),t}function toWatchPathKey(e){return normalize(resolve(e))}function resolveLockfileSearchDirectories(e){let n=resolve(e),r=[n],a=n;for(;;){if(hasWatchRootMarker(a))return r;let e=dirname(a);if(e===a)return[n];a=e,r.push(a)}}function hasWatchRootMarker(e){return WATCH_ROOT_MARKER_NAMES.some(t=>existsSync(join(e,t)))}async function resolveTsConfigWatchPaths(e){return await resolveTsConfigDependencyPaths(e)}function shouldIgnoreWatcherPath(e,t,n){let i=normalize(e),o=i.split(sep).filter(Boolean);return i!==normalize(providerSettingsPath(t))&&o.some(e=>WATCHER_IGNORED_DIRECTORY_NAMES.has(e))||n.some(t=>isPathInsideOrEqual(e,t.config.outDir))}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{startAuthoredSourceWatcher};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash}from"node:crypto";import{readFile}from"node:fs/promises";import{readDevelopmentEnvironmentHostValues}from"#cli/dev/environment.js";import{resolveCompiledModuleExtensionScopeNamespace}from"#compiler/module-map.js";import{bundleAuthoredModuleForGeneration}from"#internal/authored-module-loader.js";import{computeChannelRouteRegistrations}from"#internal/nitro/host/channel-routes.js";async function computeDevelopmentHostFingerprint(t){let r=t.compileResult.manifest,i=[r,...r.subagents.map(e=>e.agent)],o={agentName:r.config.name,bundler:{externalDependencies:[...new Set([...r.config.build?.externalDependencies??[],...r.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])])].sort((e,t)=>e.localeCompare(t)),extensionScopes:i.flatMap(e=>e.extensionMounts).map(e=>({packageNamespace:e.packageNamespace,sourceRoot:e.sourceRoot})).sort((e,t)=>e.sourceRoot.localeCompare(t.sourceRoot)),sandboxBackends:[...new Set(i.map(e=>e.sandbox?.backendName).filter(e=>e!==void 0))].sort((e,t)=>e.localeCompare(t))},channels:computeChannelRouteRegistrations(t),environment:readDevelopmentEnvironmentHostValues(t.appRoot),instrumentation:await readInstrumentationSource(t),workflow:{enabled:i.some(e=>e.workflowTool!==void 0),world:r.config.experimental?.workflow?.world??`local`}};return createHash(`sha256`).update(JSON.stringify(o)).digest(`hex`)}async function readInstrumentationSource(e){let n=e.compileResult.manifest.instrumentation;if(n!==void 0){let t=e.compileResult.manifest.bindings[n.sourceId];if(t===void 0)throw Error(`Compiled instrumentation source "${n.sourceId}" has no binding.`);return{kind:`file`,modules:[{slot:null,source:t.backing.kind===`filesystem`?await bundleAuthoredModuleForGeneration(t.backing.sourcePath,{externalDependencies:t.backing.externalDependencies,extensionScopeNamespace:resolveCompiledModuleExtensionScopeNamespace(t)}):JSON.stringify(t.backing)}]}}let a=e.compiledArtifacts.instrumentationSourcePaths,o=e.compiledArtifacts.instrumentationLayout;if(a===void 0||o===void 0)return null;let s=await Promise.all(a.map(async e=>await readFile(e,`utf8`)));return{kind:o.kind,modules:s.map((e,t)=>({slot:o.kind===`directory`?o.slots[t]??null:null,source:e}))}}export{computeDevelopmentHostFingerprint};
|
|
1
|
+
import{createHash}from"node:crypto";import{readFile}from"node:fs/promises";import{readDevelopmentEnvironmentHostValues}from"#cli/dev/environment.js";import{resolveCompiledModuleExtensionScopeNamespace}from"#compiler/module-map.js";import{bundleAuthoredModuleForGeneration}from"#internal/authored-module-loader.js";import{computeChannelRouteRegistrations}from"#internal/nitro/host/channel-routes.js";async function computeDevelopmentHostFingerprint(t){let r=t.compileResult.manifest,i=[r,...r.subagents.map(e=>e.agent)],o={agentName:r.config.name,bundler:{externalDependencies:[...new Set([...r.config.build?.externalDependencies??[],...r.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])])].sort((e,t)=>e.localeCompare(t)),extensionScopes:i.flatMap(e=>e.extensionMounts).map(e=>({packageNamespace:e.packageNamespace,sourceRoot:e.sourceRoot})).sort((e,t)=>e.sourceRoot.localeCompare(t.sourceRoot)),sandboxBackends:[...new Set(i.map(e=>e.sandbox?.backendName).filter(e=>e!==void 0))].sort((e,t)=>e.localeCompare(t))},channels:computeChannelRouteRegistrations(t),environment:readDevelopmentEnvironmentHostValues(t.appRoot),instrumentation:await readInstrumentationSource(t),workflow:{authoredSources:t.generation.workflowSourceFingerprint??null,enabled:i.some(e=>e.workflowTool!==void 0),world:r.config.experimental?.workflow?.world??`local`}};return createHash(`sha256`).update(JSON.stringify(o)).digest(`hex`)}async function readInstrumentationSource(e){let n=e.compileResult.manifest.instrumentation;if(n!==void 0){let t=e.compileResult.manifest.bindings[n.sourceId];if(t===void 0)throw Error(`Compiled instrumentation source "${n.sourceId}" has no binding.`);return{kind:`file`,modules:[{slot:null,source:t.backing.kind===`filesystem`?await bundleAuthoredModuleForGeneration(t.backing.sourcePath,{externalDependencies:t.backing.externalDependencies,extensionScopeNamespace:resolveCompiledModuleExtensionScopeNamespace(t)}):JSON.stringify(t.backing)}]}}let a=e.compiledArtifacts.instrumentationSourcePaths,o=e.compiledArtifacts.instrumentationLayout;if(a===void 0||o===void 0)return null;let s=await Promise.all(a.map(async e=>await readFile(e,`utf8`)));return{kind:o.kind,modules:s.map((e,t)=>({slot:o.kind===`directory`?o.slots[t]??null:null,source:e}))}}export{computeDevelopmentHostFingerprint};
|