eve 0.90.0 → 1.0.0-rc.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 +21 -23
- package/README.md +1 -3
- package/dist/src/channel/auth/http-basic.js +1 -1
- package/dist/src/channel/channel-operations.d.ts +1 -1
- package/dist/src/channel/routes.d.ts +7 -3
- package/dist/src/channel/skill-files.d.ts +22 -25
- package/dist/src/channel/skill-files.js +1 -1
- package/dist/src/channel/types.d.ts +2 -0
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/tui/prompt-commands.d.ts +1 -1
- package/dist/src/client/session.d.ts +1 -1
- package/dist/src/compiled/.vendor-stamp.json +3 -3
- package/dist/src/compiled/semver/index.d.ts +5 -1
- package/dist/src/compiler/channel-route-plan.d.ts +2 -0
- package/dist/src/compiler/channel-route-plan.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/sandbox/bash.js +2 -2
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/admission.d.ts +6 -0
- package/dist/src/execution/session/admission.js +1 -1
- package/dist/src/execution/session/delivery-facts.js +1 -1
- package/dist/src/execution/session/next-input.d.ts +2 -2
- package/dist/src/execution/session/next-input.js +1 -1
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session-inbox/inbox.d.ts +2 -2
- package/dist/src/execution/session-inbox/inbox.js +1 -1
- package/dist/src/execution/session-inbox/protocol.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/extensions/git/extension/lib/gh-tool.js +1 -1
- package/dist/src/framework/host-inventory.js +1 -1
- package/dist/src/harness/compaction/engine.js +2 -2
- package/dist/src/harness/current-messages.js +1 -1
- package/dist/src/harness/emission.d.ts +3 -0
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/facts.d.ts +5 -2
- package/dist/src/harness/facts.js +1 -1
- package/dist/src/harness/model-call/call.d.ts +7 -1
- package/dist/src/harness/model-call/call.js +3 -1
- package/dist/src/harness/provider-tool-history.d.ts +8 -0
- package/dist/src/harness/provider-tool-history.js +1 -1
- package/dist/src/harness/session-machine/transitions.d.ts +3 -2
- package/dist/src/harness/step/after-model.js +1 -1
- package/dist/src/harness/step/context.js +1 -1
- package/dist/src/harness/step/intake.js +1 -1
- package/dist/src/harness/step/prompt.js +1 -1
- package/dist/src/harness/tool-history-repair.d.ts +2 -0
- package/dist/src/harness/tool-history-repair.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.d.ts +0 -11
- package/dist/src/internal/application/compiled-artifacts.js +3 -3
- package/dist/src/internal/application/import-specifier.d.ts +6 -0
- package/dist/src/internal/application/import-specifier.js +1 -1
- package/dist/src/internal/application/paths.d.ts +2 -10
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/authored-asset-import-plugin.d.ts +18 -1
- package/dist/src/internal/authored-asset-import-plugin.js +1 -1
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/authored-package-tsconfig-paths.js +1 -1
- package/dist/src/internal/bundler/extension-mount-plugin.d.ts +19 -1
- package/dist/src/internal/bundler/extension-scope-plugin.d.ts +15 -5
- package/dist/src/internal/bundler/extension-scope-plugin.js +2 -2
- package/dist/src/internal/bundler/filters.d.ts +7 -0
- package/dist/src/internal/bundler/filters.js +1 -0
- package/dist/src/internal/bundler/pseudo-packages.d.ts +17 -7
- package/dist/src/internal/bundler/pseudo-packages.js +1 -1
- package/dist/src/internal/bundler/vendored-dependency-log.d.ts +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts-retention.d.ts +0 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts-retention.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.d.ts +2 -6
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-local-roots.d.ts +0 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-local-roots.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot.js +1 -1
- package/dist/src/internal/nitro/development-generation.d.ts +18 -6
- package/dist/src/internal/nitro/development-generation.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/create-host-nitro.d.ts +7 -0
- package/dist/src/internal/nitro/host/create-host-nitro.js +1 -0
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.d.ts +2 -0
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-build-operations.js +1 -1
- package/dist/src/internal/nitro/host/dev-host-fingerprint.d.ts +4 -0
- package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
- package/dist/src/internal/nitro/host/drained-nitro-dev-server.js +1 -1
- package/dist/src/internal/nitro/host/extension-external-dependencies.d.ts +7 -0
- package/dist/src/internal/nitro/host/extension-external-dependencies.js +1 -0
- package/dist/src/internal/nitro/host/{external-dependency-output-check-plugin.d.ts → external-dependency-output-check.d.ts} +4 -9
- package/dist/src/internal/nitro/host/external-dependency-output-check.js +3 -0
- package/dist/src/internal/nitro/host/externals-policy.d.ts +21 -0
- package/dist/src/internal/nitro/host/externals-policy.js +1 -0
- package/dist/src/internal/nitro/host/host-plugins.d.ts +41 -0
- package/dist/src/internal/nitro/host/host-plugins.js +1 -0
- package/dist/src/internal/nitro/host/host-routes.d.ts +90 -0
- package/dist/src/internal/nitro/host/host-routes.js +1 -0
- package/dist/src/internal/nitro/host/host-spec.d.ts +65 -0
- package/dist/src/internal/nitro/host/host-spec.js +1 -0
- package/dist/src/internal/nitro/host/hosted-graph-plugin.d.ts +41 -0
- package/dist/src/internal/nitro/host/hosted-graph-plugin.js +5 -0
- package/dist/src/internal/nitro/host/instrumentation-entry.d.ts +35 -3
- package/dist/src/internal/nitro/host/instrumentation-entry.js +2 -2
- package/dist/src/internal/nitro/host/nitro-bundler-config.d.ts +2 -5
- package/dist/src/internal/nitro/host/nitro-bundler-config.js +1 -1
- package/dist/src/internal/nitro/host/nitro-routing-import-specifier-plugin.d.ts +14 -4
- package/dist/src/internal/nitro/host/nitro-routing-import-specifier-plugin.js +1 -1
- package/dist/src/internal/nitro/host/ports.d.ts +10 -0
- package/dist/src/internal/nitro/host/ports.js +1 -1
- package/dist/src/internal/nitro/host/route-handlers.d.ts +62 -0
- package/dist/src/internal/nitro/host/route-handlers.js +9 -0
- package/dist/src/internal/nitro/host/skill-files-plugin.d.ts +21 -0
- package/dist/src/internal/nitro/host/skill-files-plugin.js +2 -0
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/start-production-server.js +1 -1
- package/dist/src/internal/nitro/host/vercel-build-output-config.d.ts +16 -19
- package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
- package/dist/src/internal/nitro/host/vercel-output.d.ts +15 -0
- package/dist/src/internal/nitro/host/vercel-output.js +1 -0
- package/dist/src/internal/nitro/host/workspace-extensions.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.d.ts +4 -3
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/connection-events.js +1 -1
- package/dist/src/internal/nitro/routes/dev-schedule-dispatch.d.ts +1 -1
- package/dist/src/internal/nitro/routes/method-guard.d.ts +6 -0
- package/dist/src/internal/nitro/routes/method-guard.js +1 -0
- package/dist/src/internal/nitro/routes/schedule-collection-consumer.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +0 -9
- package/dist/src/internal/workflow-bundle/builder.d.ts +9 -5
- package/dist/src/internal/workflow-bundle/builder.js +2 -2
- package/dist/src/internal/workflow-bundle/flow-route.d.ts +2 -0
- package/dist/src/internal/workflow-bundle/flow-route.js +1 -0
- package/dist/src/internal/workflow-bundle/nitro-step-entry.d.ts +7 -5
- package/dist/src/internal/workflow-bundle/nitro-step-entry.js +2 -2
- package/dist/src/protocol/session-events/families/delivery.d.ts +5 -3
- package/dist/src/protocol/session-events/families/delivery.js +1 -1
- package/dist/src/protocol/session-projection/fold.js +1 -1
- package/dist/src/public/channels/discord/hitl.js +1 -1
- package/dist/src/public/channels/slack/hitl.d.ts +2 -1
- package/dist/src/public/channels/slack/hitl.js +3 -3
- package/dist/src/public/channels/slack/interaction-cards.js +1 -1
- package/dist/src/public/channels/slack/request-card-render.js +1 -1
- package/dist/src/public/channels/teams/hitl.js +1 -1
- package/dist/src/public/channels/teams/verify.js +1 -1
- package/dist/src/public/definitions/hook.d.ts +90 -7
- package/dist/src/public/definitions/hook.js +1 -1
- package/dist/src/public/hooks/index.d.ts +3 -2
- package/dist/src/reactions/continuation.d.ts +19 -0
- package/dist/src/reactions/continuation.js +1 -0
- package/dist/src/reactions/intents.d.ts +10 -4
- package/dist/src/reactions/intents.js +1 -1
- package/dist/src/reactions/kinds/hook.js +1 -1
- package/dist/src/reactions/runner.js +1 -1
- package/dist/src/reactions/state.d.ts +15 -2
- package/dist/src/reactions/state.js +1 -1
- package/dist/src/runtime/resolve-connection.js +1 -1
- package/dist/src/runtime/sessions/runtime-session.d.ts +3 -0
- package/dist/src/runtime/sessions/runtime-session.js +1 -1
- package/dist/src/runtime/subagents/workflow.js +1 -1
- package/dist/src/setup/primitives/open-url.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/path-inside.d.ts +2 -0
- package/dist/src/shared/path-inside.js +1 -0
- package/dist/src/shared/value-delta.d.ts +5 -4
- package/dist/src/shared/value-delta.js +1 -1
- package/dist/src/shared/workflow-sandbox.d.ts +5 -1
- package/dist/src/shared/workflow-sandbox.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tools/provided/web-fetch.js +1 -1
- package/docs/README.md +0 -2
- package/docs/agent-config.md +199 -222
- package/docs/channels/chat-sdk.mdx +60 -64
- package/docs/channels/custom.mdx +270 -281
- package/docs/channels/discord.mdx +176 -123
- package/docs/channels/eve.mdx +136 -206
- package/docs/channels/github.mdx +24 -22
- package/docs/channels/linear.mdx +30 -30
- package/docs/channels/linq.mdx +25 -13
- package/docs/channels/mcp.mdx +154 -116
- package/docs/channels/overview.mdx +31 -32
- package/docs/channels/photon.mdx +32 -56
- package/docs/channels/slack.mdx +547 -408
- package/docs/channels/teams.mdx +40 -26
- package/docs/channels/telegram.mdx +13 -13
- package/docs/channels/twilio.mdx +11 -11
- package/docs/code-extension.mdx +40 -42
- package/docs/concepts/built-in-tools.md +89 -57
- package/docs/concepts/context-control.md +20 -20
- package/docs/concepts/default-harness.md +20 -36
- package/docs/concepts/execution-model-and-durability.mdx +96 -160
- package/docs/concepts/meta.json +0 -1
- package/docs/concepts/project-structure.mdx +21 -14
- package/docs/concepts/security-model.md +27 -27
- package/docs/concepts/sessions-runs-and-streaming.md +184 -198
- package/docs/concepts/state.md +7 -15
- package/docs/connections/mcp.mdx +109 -93
- package/docs/connections/openapi.mdx +57 -59
- package/docs/connections/overview.mdx +175 -170
- package/docs/evals/assertions.mdx +36 -29
- package/docs/evals/cases.mdx +38 -42
- package/docs/evals/judge.mdx +21 -29
- package/docs/evals/overview.mdx +42 -38
- package/docs/evals/reporters.mdx +54 -27
- package/docs/evals/running.mdx +15 -8
- package/docs/evals/targets.mdx +16 -19
- package/docs/evals/tool-stubs.mdx +111 -97
- package/docs/experimental/dynamic-schedules.mdx +118 -63
- package/docs/extensions.md +58 -65
- package/docs/getting-started.mdx +5 -7
- package/docs/guides/auth-and-route-protection.md +87 -70
- package/docs/guides/client/continuations.mdx +23 -26
- package/docs/guides/client/messages.mdx +47 -66
- package/docs/guides/client/output-schema.mdx +8 -8
- package/docs/guides/client/overview.mdx +45 -43
- package/docs/guides/client/streaming.mdx +62 -71
- package/docs/guides/decide.md +24 -79
- package/docs/guides/deployment/meta.json +1 -1
- package/docs/guides/deployment/overview.md +29 -18
- package/docs/guides/deployment/self-hosted-operations.md +99 -0
- package/docs/guides/deployment/self-hosting.md +63 -80
- package/docs/guides/deployment/vercel.mdx +31 -27
- package/docs/guides/deployment/workflow-worlds.md +100 -0
- package/docs/guides/dev-tui.md +48 -41
- package/docs/guides/dynamic-capabilities.md +49 -50
- package/docs/guides/frontend/nextjs.mdx +2 -2
- package/docs/guides/frontend/nuxt.mdx +11 -11
- package/docs/guides/frontend/overview.mdx +1 -1
- package/docs/guides/frontend/sveltekit.mdx +11 -11
- package/docs/guides/frontend/tanstack.mdx +16 -16
- package/docs/guides/frontend/use-eve-agent-svelte.mdx +21 -21
- package/docs/guides/frontend/use-eve-agent-vue.mdx +22 -22
- package/docs/guides/frontend/use-eve-agent.mdx +25 -25
- package/docs/guides/hooks.md +152 -106
- package/docs/guides/instrumentation/agent-runs.mdx +26 -30
- package/docs/guides/instrumentation/instrumentation.mdx +49 -76
- package/docs/guides/instrumentation/meta.json +1 -1
- package/docs/guides/instrumentation/otel.mdx +113 -179
- package/docs/guides/remote-agents.md +125 -187
- package/docs/guides/self-modification.md +18 -18
- package/docs/guides/session-context.md +16 -16
- package/docs/guides/upgrade/agent-files.md +178 -0
- package/docs/guides/upgrade/channels.md +61 -0
- package/docs/guides/upgrade/clients.md +130 -0
- package/docs/guides/upgrade/evals-and-cli.md +44 -0
- package/docs/guides/upgrade/index.md +90 -0
- package/docs/guides/upgrade/meta.json +13 -0
- package/docs/guides/upgrade/saved-history.md +86 -0
- package/docs/guides/upgrade/session-events.md +139 -0
- package/docs/install-integrations.mdx +26 -24
- package/docs/instructions.mdx +37 -42
- package/docs/memory/custom-provider.md +35 -41
- package/docs/memory/file.md +93 -76
- package/docs/memory/overview.mdx +145 -156
- package/docs/meta.json +1 -1
- package/docs/patterns/durable-cross-channel-notifications.md +15 -19
- package/docs/patterns/dynamic-scheduling.md +19 -23
- package/docs/patterns/multi-tenant-approvals.md +17 -22
- package/docs/patterns/multi-tenant-auth.md +43 -42
- package/docs/patterns/multi-tenant-memory.md +39 -36
- package/docs/patterns/voice-notes.md +3 -3
- package/docs/protocols/acp.md +13 -13
- package/docs/protocols/ucp.mdx +7 -7
- package/docs/reference/agent-files.md +6 -6
- package/docs/reference/cli.md +99 -98
- package/docs/reference/telemetry.md +1 -1
- package/docs/reference/typescript-api.md +54 -53
- package/docs/responsible-use.md +2 -2
- package/docs/sandbox/custom-providers.mdx +60 -56
- package/docs/sandbox/default.mdx +23 -24
- package/docs/sandbox/docker.mdx +16 -10
- package/docs/sandbox/index.mdx +93 -61
- package/docs/sandbox/just-bash.mdx +17 -11
- package/docs/sandbox/troubleshooting.mdx +29 -23
- package/docs/sandbox/vercel.mdx +45 -52
- package/docs/schedules.mdx +65 -54
- package/docs/skills.mdx +74 -49
- package/docs/subagents/index.mdx +97 -136
- package/docs/tools/human-in-the-loop.md +160 -90
- package/docs/tools/meta.json +1 -1
- package/docs/tools/overview.mdx +229 -237
- package/docs/tools/tasks.md +118 -117
- package/docs/tools/workflows.mdx +447 -543
- package/docs/tutorial/connect-a-warehouse.mdx +11 -13
- package/docs/tutorial/first-agent.mdx +14 -16
- package/docs/tutorial/guard-the-spend.mdx +6 -8
- package/docs/tutorial/how-it-runs.mdx +8 -8
- package/docs/tutorial/query-sample-data.mdx +8 -8
- package/docs/tutorial/remember-definitions.mdx +4 -4
- package/docs/tutorial/run-analysis.mdx +20 -22
- package/docs/tutorial/ship-it.mdx +19 -19
- package/docs/tutorial/team-playbooks.mdx +9 -9
- package/docs/use-cases.mdx +13 -11
- package/package.json +2 -2
- package/dist/src/internal/application/cache-metadata.d.ts +0 -9
- package/dist/src/internal/application/cache-metadata.js +0 -1
- package/dist/src/internal/nitro/host/application-route-registry.d.ts +0 -54
- package/dist/src/internal/nitro/host/application-route-registry.js +0 -1
- package/dist/src/internal/nitro/host/channel-routes.d.ts +0 -21
- package/dist/src/internal/nitro/host/channel-routes.js +0 -5
- package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.d.ts +0 -18
- package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.js +0 -3
- package/dist/src/internal/nitro/host/configure-nitro-routes.d.ts +0 -12
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +0 -3
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts +0 -34
- package/dist/src/internal/nitro/host/create-application-nitro.js +0 -1
- package/dist/src/internal/nitro/host/cron-handler-route.d.ts +0 -41
- package/dist/src/internal/nitro/host/cron-handler-route.js +0 -1
- package/dist/src/internal/nitro/host/development-runtime-prune-plugin.d.ts +0 -12
- package/dist/src/internal/nitro/host/development-runtime-prune-plugin.js +0 -3
- package/dist/src/internal/nitro/host/extension-external-dependency-plugin.d.ts +0 -16
- package/dist/src/internal/nitro/host/extension-external-dependency-plugin.js +0 -1
- package/dist/src/internal/nitro/host/external-dependency-output-check-plugin.js +0 -3
- package/dist/src/internal/nitro/host/optional-engine-dependency-plugin.d.ts +0 -28
- package/dist/src/internal/nitro/host/optional-engine-dependency-plugin.js +0 -1
- package/dist/src/internal/nitro/host/schedule-task-routes.d.ts +0 -36
- package/dist/src/internal/nitro/host/schedule-task-routes.js +0 -2
- package/dist/src/internal/nitro/host/skill-server-assets.d.ts +0 -29
- package/dist/src/internal/nitro/host/skill-server-assets.js +0 -1
- package/dist/src/internal/workflow-bundle/build-queue.d.ts +0 -1
- package/dist/src/internal/workflow-bundle/build-queue.js +0 -1
- package/dist/src/internal/workflow-bundle/eve-service-route-output.d.ts +0 -5
- package/dist/src/internal/workflow-bundle/eve-service-route-output.js +0 -1
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.d.ts +0 -34
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +0 -1
- package/docs/concepts/upgrade-to-v27-events.md +0 -197
- package/docs/guides/instrumentation/migration.md +0 -96
- package/docs/guides/prepare-for-1-0.md +0 -277
- package/docs/tools/tasks-upgrade.md +0 -218
package/CHANGELOG.md
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
# eve 0.
|
|
1
|
+
# eve 1.0.0-rc.0
|
|
2
2
|
|
|
3
|
-
Released 2026-10-
|
|
3
|
+
Released 2026-10-30 · [Compare with 0.91.0](https://github.com/vercel/eve/compare/eve%400.91.0...eve%401.0.0-rc.0)
|
|
4
4
|
|
|
5
5
|
## Breaking Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
The
|
|
9
|
-
- Tool-stub grants on Vercel OIDC subjects move from `vercelOidc` to the new `eveVercelOidc` helper in `eve/channels/eve`.
|
|
10
|
-
`vercelOidc` and `AuthResult` from `eve/channels/auth` now carry identity only. Rename grant-bearing `vercelOidc` calls to `eveVercelOidc`; the options are unchanged. `vercelOidc` now throws when a `subjects` entry is not a string. Type custom callbacks that return `allowToolStubs` as `EveAuthFn` from `eve/channels/eve`. ([#5542](https://github.com/vercel/eve/pull/5542))
|
|
7
|
+
- eve 1.0 puts stable APIs under semantic versioning: they change incompatibly only in a major release, and a deprecated API keeps working until the next one.
|
|
8
|
+
The [stability policy](https://eve.dev/docs/reference/typescript-api#stability-policy) lists which APIs are stable and which are experimental. To move an existing project, follow [Upgrade to 1.0](https://eve.dev/docs/guides/upgrade). ([#5620](https://github.com/vercel/eve/pull/5620))
|
|
11
9
|
|
|
12
10
|
## Features
|
|
13
11
|
|
|
14
|
-
-
|
|
15
|
-
|
|
12
|
+
- Setup prompts for coding agents from a prerelease eve CLI now use its dist-tag, such as `npx eve@rc init`, instead of `npx eve@latest`. ([#5620](https://github.com/vercel/eve/pull/5620))
|
|
13
|
+
- `eve add` now installs a registry item on an eve prerelease, such as `1.0.0-rc.0`, when that version meets the item's minimum eve version.
|
|
14
|
+
Previously no prerelease satisfied a requirement such as `>=0.62.0`, so every item that declared one failed with "This registry item requires eve". ([#5620](https://github.com/vercel/eve/pull/5620))
|
|
16
15
|
|
|
17
16
|
## Bug Fixes
|
|
18
17
|
|
|
19
|
-
- `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
For an upgrade across multiple releases, review each version between the installed and target versions in the [target version's changelog](https://raw.githubusercontent.com/vercel/eve/refs/tags/eve%400.90.0/packages/eve/CHANGELOG.md).
|
|
18
|
+
- A `HEAD` request to a channel path that declares `GET` but not `HEAD` now gets `405 Method Not Allowed` with an `Allow` header instead of `404`, and the `GET` handler doesn't run.
|
|
19
|
+
Declare `HEAD()` on a path to answer `HEAD` requests there, under any parameter name: `HEAD("/items/:itemId")` answers for `GET("/items/:id")`. Paths that already declare `HEAD()`, such as `/` and `/eve/v1/health`, are unchanged. On a CORS-enabled path, the `405` carries the CORS headers, so a browser can read it.
|
|
20
|
+
`eve build` and `eve dev` no longer merge the app root's `nitro.config`, `.nitrorc`, or `.env` files into eve's own Nitro host, and no longer serve an app-root `server.*` or `index.html` as a catch-all in front of eve's routes. A Nitro app that shares its root with an eve agent, such as a TanStack Start host, keeps its Nitro configuration to itself. eve still loads `.env`, `.env.local`, `.env.development`, and `.env.development.local` for `eve dev` through its own environment handling, and still serves files in an app-root `public/` directory as static files.
|
|
21
|
+
`eve dev` now rebuilds its host when a connection turns on events or an extension mount changes the package export it imports. Before, those edits reused the running host, so the event receiver route or the new mount stayed missing until `eve dev` restarted. ([#5692](https://github.com/vercel/eve/pull/5692))
|
|
22
|
+
- Background work a channel route registers with `waitUntil` while its streamed response is still being sent now runs to completion on hosted platforms, instead of being dropped.
|
|
23
|
+
Channel route `params` keep encoded path separators (`%2F` and `%5C`) encoded, so a param can no longer contain a `/` or `\` that the request path never had. Other percent-encoded characters are still decoded, so `/files/caf%C3%A9` gives `café`; a handler that expected `%2F` decoded to `/` must now decode it itself.
|
|
24
|
+
Agent text that mentions a Nitro build constant such as `import.meta.dev` now reaches production builds unchanged, instead of being rewritten to its value or failing the build. Skill files are embedded in the server bundle instead of Nitro server assets, so hosted output no longer ships Nitro's storage layer unless authored code imports Nitro storage itself.
|
|
25
|
+
A channel path that declares both `GET()` and `WS()` now accepts WebSocket upgrades, which the `GET` route used to answer as a plain HTTP request. WebSocket routes register for `GET` only, the method an upgrade uses. Because one handler serves both, the two routes must name their path parameters the same way; `eve build` rejects a pair such as `GET("/rooms/:id")` and `WS("/rooms/:room")`.
|
|
26
|
+
Vercel service builds keep the schedule consumer function and its queue trigger, so dynamic schedules deliver their occurrences.
|
|
27
|
+
`eve start` now runs the server's shutdown hooks, such as flushing instrumentation, when it stops the server in an environment that sets `CI`. The built server no longer inherits `CI` or `NITRO_UNIX_SOCKET` from `eve start`.
|
|
28
|
+
A server without eve's workflow program runtime installed now fails a generated workflow program with an error that explains why, instead of importing the runtime from a path hosted output can't resolve. ([#5698](https://github.com/vercel/eve/pull/5698))
|
|
29
|
+
- Show the expected GitHub-side result as the gh tool's activity label instead of the generic tool name. ([#5668](https://github.com/vercel/eve/pull/5668))
|
|
30
|
+
|
|
31
|
+
For an upgrade across multiple releases, review each version between the installed and target versions in the [target version's changelog](https://raw.githubusercontent.com/vercel/eve/refs/tags/eve%401.0.0-rc.0/packages/eve/CHANGELOG.md).
|
package/README.md
CHANGED
|
@@ -10,9 +10,7 @@ The framework is called eve. The published npm package is `eve`. The CLI binary
|
|
|
10
10
|
|
|
11
11
|
The installed package contains its release notes in `CHANGELOG.md`, with a link to the full changelog through that version. For an upgrade across releases, review the target version's history at `https://raw.githubusercontent.com/vercel/eve/refs/tags/eve%40<version>/packages/eve/CHANGELOG.md`.
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
eve is currently a preview and subject to the Vercel beta terms; the framework, APIs, documentation, and behavior may change before general availability.
|
|
13
|
+
## Safeguards
|
|
16
14
|
|
|
17
15
|
As the deployer, it is your responsibility to ensure your agent complies with applicable laws.
|
|
18
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash,timingSafeEqual}from"node:crypto";function authenticateHttpBasicStrategy(e){let t=parseBasicAuthorizationHeader(e.authorization);
|
|
1
|
+
import{createHash,timingSafeEqual}from"node:crypto";function authenticateHttpBasicStrategy(e){let t=parseBasicAuthorizationHeader(e.authorization);if(t===null)return{kind:`not-authenticated`};let n=timingSafeStringEquals(normalizeCredential(t.username),normalizeCredential(e.strategy.username)),r=timingSafeStringEquals(normalizeCredential(t.password),normalizeCredential(e.strategy.password));return!n||!r?{kind:`not-authenticated`}:{kind:`authenticated`,principal:{attributes:Object.freeze({}),authenticator:`http-basic`,claims:Object.freeze({}),principalId:e.strategy.username,principalType:`user`}}}function parseBasicAuthorizationHeader(e){let t=/^Basic\s+(.+)$/i.exec(e);if(t===null)return null;let n=t[1];if(n===void 0)return null;let r;try{r=Buffer.from(n,`base64`).toString(`utf8`)}catch{return null}let i=r.indexOf(`:`);return i===-1?null:{password:r.slice(i+1),username:r.slice(0,i)}}function normalizeCredential(e){return e.normalize(`NFC`)}function timingSafeStringEquals(e,t){return timingSafeEqual(hashString(e),hashString(t))}function hashString(e){return createHash(`sha256`).update(e,`utf8`).digest()}export{authenticateHttpBasicStrategy};
|
|
@@ -53,7 +53,7 @@ export interface ChannelSource<TState = undefined> {
|
|
|
53
53
|
} & SessionControlOptions): Promise<Delivery>;
|
|
54
54
|
/** Queues context compaction without creating a session. */
|
|
55
55
|
compact(options?: SessionControlOptions): Promise<Delivery>;
|
|
56
|
-
/**
|
|
56
|
+
/** Cancels a running turn and every working task, then clears model-message history in place. */
|
|
57
57
|
clear(options?: SessionControlOptions): Promise<Delivery>;
|
|
58
58
|
/** Retires the current owner without creating a replacement. */
|
|
59
59
|
end(options?: {
|
|
@@ -26,7 +26,11 @@ export interface RouteHandlerArgs<TState = undefined> {
|
|
|
26
26
|
* on the returned handle; the target channel owns its address and initial state.
|
|
27
27
|
*/
|
|
28
28
|
readonly to: CrossChannelToFn;
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Path parameters matched for the current route, percent-decoded except
|
|
31
|
+
* `%2F` and `%5C`, which stay encoded so a parameter never gains a path
|
|
32
|
+
* separator.
|
|
33
|
+
*/
|
|
30
34
|
params: Readonly<Record<string, string>>;
|
|
31
35
|
/** Keeps background work alive after the route returns its response. */
|
|
32
36
|
waitUntil: (task: Promise<unknown>) => void;
|
|
@@ -49,8 +53,8 @@ export interface RouteHandlerArgs<TState = undefined> {
|
|
|
49
53
|
* Reads one file of a compiled skill as raw bytes. `path` is relative to
|
|
50
54
|
* the skill root and defaults to its `SKILL.md`. Rejects paths that are
|
|
51
55
|
* absolute or contain `.`, `..`, or empty segments, files the skill does
|
|
52
|
-
* not list, and files over 512 KiB. Production builds
|
|
53
|
-
* server
|
|
56
|
+
* not list, and files over 512 KiB. Production builds embed skill files in
|
|
57
|
+
* the server bundle, so they count toward the deployed function's size.
|
|
54
58
|
*/
|
|
55
59
|
readSkill(skill: string, path?: string): Promise<Uint8Array>;
|
|
56
60
|
/** Runs one of the agent's tools as `auth`, outside any conversation. */
|
|
@@ -34,26 +34,17 @@ export interface SkillFileSource {
|
|
|
34
34
|
listDirectories(skill: string): Promise<readonly string[]>;
|
|
35
35
|
readFile(skill: string, path: string): Promise<Uint8Array>;
|
|
36
36
|
}
|
|
37
|
-
/** Nitro `serverAssets` base that holds the root agent's shipped skill files. */
|
|
38
|
-
export declare const SKILL_FILES_SERVER_ASSET_BASE = "eve-skills";
|
|
39
|
-
/** Nitro `serverAssets` base that holds {@link SKILL_FILES_INDEX_KEY}. */
|
|
40
|
-
export declare const SKILL_FILES_INDEX_SERVER_ASSET_BASE = "eve-skill-index";
|
|
41
|
-
/** Key of the skill file index inside {@link SKILL_FILES_INDEX_SERVER_ASSET_BASE}. */
|
|
42
|
-
export declare const SKILL_FILES_INDEX_KEY = "skills.json";
|
|
43
37
|
/**
|
|
44
38
|
* One indexed file: `[path, size, sha256]`. `sha256` is `null` for files over
|
|
45
|
-
* {@link MAX_SKILL_FILE_BYTES}, which are listed but not shipped.
|
|
46
|
-
* file's storage key is {@link skillFileStorageKey} of its digest.
|
|
39
|
+
* {@link MAX_SKILL_FILE_BYTES}, which are listed but not shipped.
|
|
47
40
|
*/
|
|
48
41
|
export type SkillFilesIndexEntry = readonly [path: string, size: number, sha256: string | null];
|
|
49
42
|
/**
|
|
50
43
|
* Index of the skill files a production build ships, written by `eve build`.
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* not object keys, so names such as `__proto__` stay plain data.
|
|
44
|
+
* Entries are arrays, not object keys, so names such as `__proto__` stay
|
|
45
|
+
* plain data.
|
|
54
46
|
*/
|
|
55
47
|
export interface SkillFilesIndex {
|
|
56
|
-
readonly version: 1;
|
|
57
48
|
/** `[skill, files, directories]`, sorted by skill then path. */
|
|
58
49
|
readonly skills: readonly (readonly [
|
|
59
50
|
skill: string,
|
|
@@ -61,30 +52,35 @@ export interface SkillFilesIndex {
|
|
|
61
52
|
directories: readonly string[]
|
|
62
53
|
])[];
|
|
63
54
|
}
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
/** The skill files a production build embeds, as its generated Nitro plugin installs them. */
|
|
56
|
+
export interface BundledSkillFiles {
|
|
57
|
+
/** The JSON text of a {@link SkillFilesIndex}. */
|
|
58
|
+
readonly index: string;
|
|
59
|
+
/** Loads the shipped bytes with this SHA-256. Every file with that digest shares the array. */
|
|
60
|
+
readonly read: (sha256: string) => Promise<Uint8Array>;
|
|
61
|
+
}
|
|
62
|
+
/** The parsed form of {@link BundledSkillFiles} a runtime session holds. */
|
|
63
|
+
export interface InstalledSkillFiles {
|
|
64
|
+
readonly read: (sha256: string) => Promise<Uint8Array>;
|
|
65
|
+
readonly skills: ReadonlyMap<string, IndexedSkill>;
|
|
66
|
+
}
|
|
67
|
+
interface IndexedSkill {
|
|
68
|
+
readonly files: readonly SkillFilesIndexEntry[];
|
|
69
|
+
readonly directories: readonly string[];
|
|
73
70
|
}
|
|
74
|
-
/**
|
|
75
|
-
export
|
|
71
|
+
/** Installs a production build's embedded skill files on the active runtime session. */
|
|
72
|
+
export declare function installBundledSkillFiles(input: BundledSkillFiles): void;
|
|
76
73
|
/**
|
|
77
74
|
* Selects the skill file source for the active compiled artifacts.
|
|
78
75
|
*
|
|
79
76
|
* Skill files are materialized under the node's workspace resource root by
|
|
80
77
|
* `compiler/workspace-resources.ts`. Disk artifacts (dev) read that tree with
|
|
81
78
|
* {@link createDiskSkillFileSource}; bundled artifacts (production builds)
|
|
82
|
-
* read the
|
|
79
|
+
* read the files `eve build` embedded for the root agent.
|
|
83
80
|
*/
|
|
84
81
|
export declare function createCompiledSkillFileSource(input: {
|
|
85
82
|
readonly compiledArtifactsSource: RuntimeCompiledArtifactsSource;
|
|
86
83
|
readonly workspaceResourceRoot: CompiledWorkspaceResourceRoot;
|
|
87
|
-
readonly openStorage?: OpenSkillFileStorage;
|
|
88
84
|
}): SkillFileSource;
|
|
89
85
|
/**
|
|
90
86
|
* Reads skill files from a materialized `skills/<name>/` tree.
|
|
@@ -112,3 +108,4 @@ export declare function readSkillFile(input: {
|
|
|
112
108
|
readonly source: SkillFileSource;
|
|
113
109
|
}): Promise<Uint8Array>;
|
|
114
110
|
export declare function comparePaths(left: string, right: string): number;
|
|
111
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{lstat,open,readdir,realpath}from"node:fs/promises";import{getActiveRuntimeSession}from"#runtime/sessions/runtime-session.js";import{constants}from"node:fs";import nodePath from"node:path";import{resolveRuntimeCompilerArtifactPaths}from"#runtime/loaders/artifact-paths.js";const MAX_SKILL_FILE_BYTES=524288,SKILL_ENTRY_FILE_NAME=`SKILL.md`;function isSkillEntryFileName(e){return e.toLowerCase()===`skill.md`}var SkillReadError=class extends Error{code;constructor(e,t){super(t),this.name=`SkillReadError`,this.code=e}};function installBundledSkillFiles(e){let t=JSON.parse(e.index);getActiveRuntimeSession().skillFiles={read:e.read,skills:new Map(t.skills.map(([e,t,n])=>[e,{directories:n,files:t}]))}}function createCompiledSkillFileSource(e){if(e.compiledArtifactsSource.kind!==`disk`)return bundledSkillFileSource;let{compileDirectoryPath:t}=resolveRuntimeCompilerArtifactPaths(e.compiledArtifactsSource.appRoot);return createDiskSkillFileSource(`${t}/${e.workspaceResourceRoot.logicalPath}/skills`)}const bundledSkillFileSource={async listFiles(e){return(installedSkillFiles().skills.get(e)?.files??[]).map(([e,t])=>({path:e,size:t}))},async listDirectories(e){return installedSkillFiles().skills.get(e)?.directories??[]},async readFile(e,t){let n=installedSkillFiles(),r=n.skills.get(e)?.files.find(([e])=>e===t);if(r===void 0)throw unknownFile(e,t);let[,i,a]=r;if(a===null)throw tooLarge(e,t,i);return(await n.read(a)).slice()}};function installedSkillFiles(){let e=getActiveRuntimeSession().skillFiles;if(e===null)throw new SkillReadError(`unavailable`,"Skill files are not available: this server was not built by `eve build`, so it carries no skill files.");return e}function createDiskSkillFileSource(e){return{async listFiles(t){let n=`${e}/${t}`;if(!await isRealDirectory(n))return[];let{files:r}=await walkSkill(n);return r.sort((e,t)=>comparePaths(e.path,t.path))},async listDirectories(t){let n=`${e}/${t}`;if(!await isRealDirectory(n))return[];let{directories:r}=await walkSkill(n);return r.sort(comparePaths)},async readFile(t,n){let r=`${e}/${t}`;if(!await isRealDirectory(r))throw unknownFile(t,n);let i=n.split(`/`),a=r;for(let[e,r]of i.entries()){a=`${a}/${r}`;let o=await lstatOrUndefined(a),s=e===i.length-1;if(o===void 0||(s?!o.isFile():!o.isDirectory()))throw unknownFile(t,n)}let[o,s]=await Promise.all([realpath(r),realpath(a)]),c=nodePath.relative(o,s);if(c===``||nodePath.isAbsolute(c)||c.split(nodePath.sep)[0]===`..`)throw unknownFile(t,n);let l=await open(a,constants.O_RDONLY|(constants.O_NOFOLLOW??0));try{let e=await l.stat();if(!e.isFile())throw unknownFile(t,n);if(e.size>524288)throw tooLarge(t,n,e.size);return new Uint8Array(await l.readFile())}finally{await l.close()}}}}async function lstatOrUndefined(e){try{return await lstat(e)}catch(e){if(e instanceof Error&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`))return;throw e}}async function isRealDirectory(e){return(await lstatOrUndefined(e))?.isDirectory()===!0}async function walkSkill(e){let t=[],n=[],walk=async(e,r)=>{for(let i of await readdir(e,{withFileTypes:!0})){let a=r===``?i.name:`${r}/${i.name}`;if(i.isDirectory())n.push(a),await walk(`${e}/${i.name}`,a);else if(i.isFile()){let n=await lstatOrUndefined(`${e}/${i.name}`);n?.isFile()===!0&&t.push({path:a,size:n.size})}}};return await walk(e,``),{directories:n,files:t}}function unknownFile(e,t){return new SkillReadError(`unknown-file`,`Skill "${e}" has no file "${t}".`)}function tooLarge(e,t,n){return new SkillReadError(`too-large`,`Skill "${e}" file "${t}" is ${n} bytes, over the ${MAX_SKILL_FILE_BYTES}-byte limit.`)}async function readSkillFile(e){let t=e.path??`SKILL.md`;assertRelativeSkillPath(t);let n=await e.source.listFiles(e.skill),r=n.find(e=>e.path===t)??(isSkillEntryFileName(t)?n.find(e=>isSkillEntryFileName(e.path)):void 0);if(r===void 0)throw unknownFile(e.skill,t);if(r.size>524288)throw tooLarge(e.skill,r.path,r.size);let i=await e.source.readFile(e.skill,r.path);if(i.byteLength>524288)throw tooLarge(e.skill,r.path,i.byteLength);return i}function assertRelativeSkillPath(e){let invalid=t=>new SkillReadError(`invalid-path`,`Skill file path "${e}" ${t}.`);if(e.length===0)throw invalid(`must not be empty`);if(e.startsWith(`/`)||/^[A-Za-z]:/.test(e))throw invalid(`must be relative to the skill root`);if(e.includes(`\\`)||e.includes(`\0`))throw invalid(`must use "/" separators and contain no NUL bytes`);if(e.split(`/`).some(e=>e===``||e===`.`||e===`..`))throw invalid(`must not contain empty, ".", or ".." segments`)}function comparePaths(e,t){return e<t?-1:+(e>t)}export{MAX_SKILL_FILE_BYTES,SKILL_ENTRY_FILE_NAME,SkillReadError,comparePaths,createCompiledSkillFileSource,createDiskSkillFileSource,installBundledSkillFiles,isSkillEntryFileName,readSkillFile};
|
|
@@ -103,6 +103,8 @@ export interface ChannelDeliveryMetadata {
|
|
|
103
103
|
readonly channelKind: string;
|
|
104
104
|
readonly channelName: string;
|
|
105
105
|
readonly deliveryId: string;
|
|
106
|
+
/** The hook whose `ctx.continue()` made the delivery, recorded on its `delivery.admitted`. */
|
|
107
|
+
readonly hook?: string;
|
|
106
108
|
readonly requestId?: string;
|
|
107
109
|
readonly requestTraceContext?: SessionTraceSeed;
|
|
108
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hasInteractiveTerminal}from"./preconditions.js";import{headlessSetupContinuation,serializeHeadlessSetupEvent}from"./setup-headless.js";import{prepareWebChatProjectRoot,prepareWebRegistryProject,readRegistryConfig,resolveWebChatFramework}from"./registry-project.js";import{errorMessage,reportRegistryCompletion,resolveRegistryItemForAdd,runRegistryAction,setupReminder,setupResumeCommand}from"./registry-recovery.js";import{runRegistryAddCommand}from"./registry-add-command.js";import{RegistrySetupFailedError,runDeclaredSetups}from"./registry-declared-setups.js";import{installRegistryItemTransaction}from"./registry-install-transaction.js";import{eveMetadataFromRegistryItem,parseOfficialRegistrySearchMetadata}from"./registry-metadata.js";import{prepareDeclaredPnpmBuildPolicy}from"./registry-pnpm-build-policy-flow.js";import{printRegistrySearchResults,registryViewText}from"./registry-presentation.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createPrompter}from"#setup/prompter.js";import{WizardCancelledError}from"#setup/step.js";import{InvalidAnswerError,headlessAsker,interactiveAsker,withAnswers,withPolicy}from"#setup/ask.js";import{setupQuestionToWire}from"#setup/setup-question-wire.js";import{addRegistryItems,getRegistryItems,searchRegistries}from"#compiled/shadcn-registry/index.js";import semver from"#compiled/semver/index.js";const defaultAddCommandDependencies={createPrompter,hasInteractiveTerminal,loadSetupCommandRunner:async()=>(await import(`./registry-setup-command.js`)).runRegistrySetupCommand,prepareWebRegistryProject};function resolveOfficialRegistryUrl(e=process.env.EVE_DEV_OFFICIAL_REGISTRY_URL){if(e===void 0)return`https://eve.dev/r`;let t;try{t=new URL(e)}catch{throw Error(`EVE_DEV_OFFICIAL_REGISTRY_URL must be an HTTP(S) URL.`)}if(t.protocol!==`http:`&&t.protocol!==`https:`)throw Error(`EVE_DEV_OFFICIAL_REGISTRY_URL must be an HTTP(S) URL.`);if(t.username!==``||t.password!==``)throw Error(`EVE_DEV_OFFICIAL_REGISTRY_URL must not include credentials.`);if(t.search!==``||t.hash!==``)throw Error(`EVE_DEV_OFFICIAL_REGISTRY_URL must not include a query or fragment.`);return t.pathname=t.pathname.replace(/\/+$/,``),t.toString().replace(/\/$/,``)}const OFFICIAL_REGISTRY=resolveOfficialRegistryUrl(),OFFICIAL_CATALOG=`${OFFICIAL_REGISTRY}/registry.json`,SKILLS_REGISTRY=`@skills`;function itemAddress(e){return e.startsWith(`@`)||/^https?:\/\//.test(e)?e:`${OFFICIAL_REGISTRY}/${e}.json`}const WEB_CHAT_ITEMS={next:`channel/web`,tanstack:`channel/web-tanstack`};async function askWebChatFramework(e,t,n,r,i){let a=r.nonInteractive===!0,o=r.setupAuthorized===!0||(i.hasInteractiveTerminal??defaultAddCommandDependencies.hasInteractiveTerminal)(),s=withAnswers(r.answers??{})(r.yes===!0||a||!o?withPolicy(`assume`)(headlessAsker()):interactiveAsker(r.prompter??i.createPrompter?.()??defaultAddCommandDependencies.createPrompter()));try{return await resolveWebChatFramework(t,s,r.answers)}catch(t){if(t instanceof WizardCancelledError)return!1;if(!a||!(t instanceof InvalidAnswerError))throw t;let i=setupQuestionToWire(t.question);e.error(serializeHeadlessSetupEvent({version:1,type:`blocked`,item:n,installed:!1,completedItems:[],status:`input_required`,question:i,issue:{code:`invalid_answer`,message:t.message},next:headlessSetupContinuation({item:n,installed:!1,answers:r.answers,question:i})})),process.exitCode=2;return}}function assertCompatibleEveVersion(e){if(e===void 0)return;let t=resolveInstalledPackageInfo().version;if(semver.validRange(e)===null)throw Error(`Registry item has an invalid eve version requirement: ${e}.`);if(!semver.subset(t,e))throw Error(`This registry item requires eve ${e}, but this project is using eve ${t}. Upgrade eve and run the command again.`)}function isOfficialItemAddress(e){return e.startsWith(`${OFFICIAL_REGISTRY}/`)}function withBuiltInRegistries(e){return{...e,registries:{[SKILLS_REGISTRY]:`https://www.skills.sh/r/{name}?agent=eve`,...e.registries}}}async function readEveRegistryConfig(e){return withBuiltInRegistries(await readRegistryConfig(e))}function configuredRegistrySources(e){return Object.keys(e.registries??{})}function validateRegistrySource(e){if(e!==void 0&&!e.startsWith(`@`)&&!/^https?:\/\//.test(e))throw Error(`Registry sources must be a namespace or URL: ${e}`)}async function loadOfficialSearchMetadata(){let e=await fetch(OFFICIAL_CATALOG);if(!e.ok)throw Error(`Could not read the eve registry (${e.status}).`);return parseOfficialRegistrySearchMetadata(await e.json())}function searchItemAddress(e){return e.registry===OFFICIAL_CATALOG?e.name:e.addCommandArgument}function enrichSearchItem(e,t){let n=searchItemAddress(e);return{item:e,address:n,...t.get(n)}}function registrySourceLabel(e){return e===OFFICIAL_CATALOG?`eve`:e===SKILLS_REGISTRY?`skills.sh`:e}function searchPresentationSections(e,t,n){return e.flatMap(e=>{let r=t.get(e);return r===void 0?[]:[{label:registrySourceLabel(e),items:r.items.map(e=>enrichSearchItem(e,n)),total:r.pagination.total}]})}async function printAddSuggestions(e,t,n){try{let r=n.split(`/`).at(-1)||n,{resultsBySource:i,sources:a,metadataByAddress:o}=await searchRegistryCatalog(t,{limit:5,query:r}),s=searchPresentationSections(a,i,o);if(s.every(e=>e.items.length===0))return;e.log(`Did you mean?`),printRegistrySearchResults(e,{query:r,sections:s})}catch{}}async function searchRegistryCatalog(e,t){validateRegistrySource(t.source);let n=await readEveRegistryConfig(e),r=t.source?[t.source]:[OFFICIAL_CATALOG,...configuredRegistrySources(n).filter(e=>t.query!==void 0||e!==SKILLS_REGISTRY)],i=await Promise.all(r.map(async e=>{try{return{result:await searchRegistries([e],{config:n,limit:t.limit??500,query:t.query}),source:e}}catch(t){return{error:t,source:e}}})),a=[],o=new Map;for(let e of i)if(`error`in e)a.push({message:errorMessage(e.error),registry:e.source});else{let t=e.result.errors??[];if(a.push(...t),t.length===0){let t=e.result.items.filter(t=>t.registry===e.source);o.set(e.source,{...e.result,items:t,pagination:{...e.result.pagination,total:e.result.items.length===t.length?e.result.pagination.total:0}})}}let s=new Map(a.map(e=>[`${e.registry}\0${e.message}`,e])),c=o.has(OFFICIAL_CATALOG)?await loadOfficialSearchMetadata():new Map,l=o.get(OFFICIAL_CATALOG);if(l!==void 0){let e=l.items.filter(e=>c.get(searchItemAddress(e))?.hidden!==!0);l.items=e,l.pagination={...l.pagination,total:e.length},l.items.sort((e,t)=>{let rank=e=>c.get(searchItemAddress(e))?.implementation===`native`?0:1;return rank(e)-rank(t)})}let u=[...o.values()];return{config:n,result:{items:u.flatMap(e=>e.items),pagination:{hasMore:u.some(e=>e.pagination.hasMore),limit:t.limit??500,offset:0,total:u.reduce((e,t)=>e+t.pagination.total,0)},...s.size>0?{errors:[...s.values()]}:{}},resultsBySource:o,sources:r,metadataByAddress:c}}async function browseRegistryCatalog(e,t={}){let{result:n}=await searchRegistryCatalog(e,t);return{items:n.items.map(e=>{let t={address:e.registry===OFFICIAL_CATALOG?e.name:e.addCommandArgument,name:e.name,source:e.registry===OFFICIAL_CATALOG?`Vercel`:e.registry};return e.title!==void 0&&(t.title=e.title),e.type!==void 0&&(t.type=e.type),e.description!==void 0&&(t.description=e.description),t}),total:n.pagination.total,errors:n.errors??[]}}async function browseRegistryItems(e,t,n,r,i={}){let{result:a,resultsBySource:o,sources:s,metadataByAddress:c}=await searchRegistryCatalog(t,{limit:i.limit,query:n,source:r}),l=a.errors??[];if(i.json||o.size>0){let t=a.items.map(e=>({...e,...c.get(searchItemAddress(e))})),r={query:n,sections:searchPresentationSections(s,o,c)};i.json&&(r.json={...a,items:t}),printRegistrySearchResults(e,r)}for(let t of l)e.error(`${t.registry}: ${t.message}`);l.length>0&&(process.exitCode=1)}async function installRegistryItem(e,t,n={},r=defaultAddCommandDependencies){let i,a=[],o={error:e=>{i=e},log:e=>a.push(e)},s=process.exitCode,c;try{c=await runAddCommand(o,e,t,{...n,yes:n.prompter===void 0||n.yes,setupAuthorized:n.prompter!==void 0,throwSetupFailures:!0},r)}catch(e){if(process.exitCode=s,!(e instanceof RegistrySetupFailedError))throw e;let t={resumeCommand:e.resumeCommand,reason:e.reason};return e.prerequisite!==void 0&&(t.prerequisite=e.prerequisite),{output:a,setupIncomplete:t}}if(process.exitCode=s,i!==void 0)throw Error(i);if(c===!1)throw new WizardCancelledError;if(c===`setup-incomplete`)return{output:a,setupIncomplete:{resumeCommand:setupResumeCommand(t)}};let l={output:a};return c!==void 0&&(l.setup=c),l}async function runAddCommand(e,t,n,r,i=defaultAddCommandDependencies){let setupIncomplete=t=>(r.silent!==!0&&e.log(setupReminder(n,t)),`setup-incomplete`);return runRegistryAction(e,t,async()=>{let a=itemAddress(n),o;if(a===itemAddress(WEB_CHAT_ITEMS.next)&&r.skipInstall!==!0){let a=await askWebChatFramework(e,t,n,r,i);if(a===!1||a===void 0)return a;o=a}let s=o===void 0?a:itemAddress(WEB_CHAT_ITEMS[o]),c=o===void 0?t:await prepareWebChatProjectRoot(t,o),l=await readEveRegistryConfig(t);if(r.skipInstall===!0){if(r.overwrite===!0)throw Error(`--overwrite cannot be used with --skip-install.`);if(r.skipSetup===!0)throw Error(`--skip-install cannot be used with --skip-setup.`);if(!isOfficialItemAddress(a))throw Error(`Setup flows are currently supported only for official eve registry items.`)}let u=await resolveRegistryItemForAdd(e,async()=>(await getRegistryItems([s],{config:l}))[0],()=>printAddSuggestions(e,t,n));if(!u.found)return;let d=u.item,f=isOfficialItemAddress(a)?eveMetadataFromRegistryItem(d):void 0;if(assertCompatibleEveVersion(f?.requires),r.skipInstall===!0){if(f?.setup===void 0)throw Error(`Registry item "${n}" does not declare a setup flow.`);let a=await runDeclaredSetups({logger:e,appRoot:t,item:n,setups:f.setup,options:r,dependencies:i,resumeCommand:setupResumeCommand(n)});return a===!1&&!r.nonInteractive?setupIncomplete(`cancelled`):reportRegistryCompletion(e,n,a,r)}if(!await prepareDeclaredPnpmBuildPolicy({logger:e,appRoot:c,item:n,policies:f?.install?.pnpm?.buildScripts,options:r}))return!1;if(o!==void 0&&await(i.prepareWebRegistryProject??prepareWebRegistryProject)(c,o),await installRegistryItemTransaction({appRoot:c,item:n,registryItem:d,nonInteractive:r.nonInteractive,logger:e,install:async()=>{await addRegistryItems([s],{config:l,cwd:c,overwrite:r.overwrite,silent:r.silent})}}),f?.setup===void 0)return reportRegistryCompletion(e,n,{facts:[]},r);let p=i.hasInteractiveTerminal?.()??defaultAddCommandDependencies.hasInteractiveTerminal();if(r.nonInteractive&&e.log(serializeHeadlessSetupEvent({version:1,type:`progress`,message:r.skipInstall?`Setup ${n}`:`Installed ${n}`})),r.skipSetup===!0)return r.nonInteractive?reportRegistryCompletion(e,n,{facts:[]},r):setupIncomplete(`skipped`);if(!r.nonInteractive&&!r.yes&&!p&&r.setupAuthorized!==!0)return setupIncomplete(`skipped`);if(!r.nonInteractive&&!r.yes&&r.setupAuthorized!==!0)try{if(await(r.prompter??i.createPrompter?.()??defaultAddCommandDependencies.createPrompter()).select({message:`Set up ${n} now?`,initialValue:`yes`,options:[{value:`yes`,label:`Yes`},{value:`no`,label:`No`}]})===`no`)return setupIncomplete(`skipped`)}catch(e){if(!(e instanceof WizardCancelledError))throw e;return setupIncomplete(`cancelled`)}let m=await runDeclaredSetups({logger:e,appRoot:t,item:n,setups:f.setup,options:{...r,force:r.overwrite},dependencies:i,resumeCommand:setupResumeCommand(n)});return m===!1&&!r.nonInteractive?setupIncomplete(`cancelled`):reportRegistryCompletion(e,n,m,r)},{rethrow:e=>r.throwSetupFailures===!0&&e instanceof RegistrySetupFailedError})}async function runRegistryListCommand(e,t,n,r={}){await runRegistryAction(e,t,()=>browseRegistryItems(e,t,void 0,n,r))}async function runRegistrySearchCommand(e,t,n,r,i={}){await runRegistryAction(e,t,()=>browseRegistryItems(e,t,n,r,{...i,limit:i.limit??10}))}async function runRegistryViewCommand(e,t,n,r={}){await runRegistryAction(e,t,async()=>{let i=await readEveRegistryConfig(t),a=await getRegistryItems([itemAddress(n)],{config:i}),o=a.length===1?a[0]:a;e.log(r.json?JSON.stringify(o,null,2):registryViewText(n,o))})}export{browseRegistryCatalog,installRegistryItem,resolveOfficialRegistryUrl,runAddCommand,runRegistryAddCommand,runRegistryListCommand,runRegistrySearchCommand,runRegistryViewCommand};
|
|
1
|
+
import{hasInteractiveTerminal}from"./preconditions.js";import{headlessSetupContinuation,serializeHeadlessSetupEvent}from"./setup-headless.js";import{prepareWebChatProjectRoot,prepareWebRegistryProject,readRegistryConfig,resolveWebChatFramework}from"./registry-project.js";import{errorMessage,reportRegistryCompletion,resolveRegistryItemForAdd,runRegistryAction,setupReminder,setupResumeCommand}from"./registry-recovery.js";import{runRegistryAddCommand}from"./registry-add-command.js";import{RegistrySetupFailedError,runDeclaredSetups}from"./registry-declared-setups.js";import{installRegistryItemTransaction}from"./registry-install-transaction.js";import{eveMetadataFromRegistryItem,parseOfficialRegistrySearchMetadata}from"./registry-metadata.js";import{prepareDeclaredPnpmBuildPolicy}from"./registry-pnpm-build-policy-flow.js";import{printRegistrySearchResults,registryViewText}from"./registry-presentation.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createPrompter}from"#setup/prompter.js";import{WizardCancelledError}from"#setup/step.js";import{InvalidAnswerError,headlessAsker,interactiveAsker,withAnswers,withPolicy}from"#setup/ask.js";import{setupQuestionToWire}from"#setup/setup-question-wire.js";import{addRegistryItems,getRegistryItems,searchRegistries}from"#compiled/shadcn-registry/index.js";import semver from"#compiled/semver/index.js";const defaultAddCommandDependencies={createPrompter,hasInteractiveTerminal,loadSetupCommandRunner:async()=>(await import(`./registry-setup-command.js`)).runRegistrySetupCommand,prepareWebRegistryProject};function resolveOfficialRegistryUrl(e=process.env.EVE_DEV_OFFICIAL_REGISTRY_URL){if(e===void 0)return`https://eve.dev/r`;let t;try{t=new URL(e)}catch{throw Error(`EVE_DEV_OFFICIAL_REGISTRY_URL must be an HTTP(S) URL.`)}if(t.protocol!==`http:`&&t.protocol!==`https:`)throw Error(`EVE_DEV_OFFICIAL_REGISTRY_URL must be an HTTP(S) URL.`);if(t.username!==``||t.password!==``)throw Error(`EVE_DEV_OFFICIAL_REGISTRY_URL must not include credentials.`);if(t.search!==``||t.hash!==``)throw Error(`EVE_DEV_OFFICIAL_REGISTRY_URL must not include a query or fragment.`);return t.pathname=t.pathname.replace(/\/+$/,``),t.toString().replace(/\/$/,``)}const OFFICIAL_REGISTRY=resolveOfficialRegistryUrl(),OFFICIAL_CATALOG=`${OFFICIAL_REGISTRY}/registry.json`,SKILLS_REGISTRY=`@skills`;function itemAddress(e){return e.startsWith(`@`)||/^https?:\/\//.test(e)?e:`${OFFICIAL_REGISTRY}/${e}.json`}const WEB_CHAT_ITEMS={next:`channel/web`,tanstack:`channel/web-tanstack`};async function askWebChatFramework(e,t,n,r,i){let a=r.nonInteractive===!0,o=r.setupAuthorized===!0||(i.hasInteractiveTerminal??defaultAddCommandDependencies.hasInteractiveTerminal)(),s=withAnswers(r.answers??{})(r.yes===!0||a||!o?withPolicy(`assume`)(headlessAsker()):interactiveAsker(r.prompter??i.createPrompter?.()??defaultAddCommandDependencies.createPrompter()));try{return await resolveWebChatFramework(t,s,r.answers)}catch(t){if(t instanceof WizardCancelledError)return!1;if(!a||!(t instanceof InvalidAnswerError))throw t;let i=setupQuestionToWire(t.question);e.error(serializeHeadlessSetupEvent({version:1,type:`blocked`,item:n,installed:!1,completedItems:[],status:`input_required`,question:i,issue:{code:`invalid_answer`,message:t.message},next:headlessSetupContinuation({item:n,installed:!1,answers:r.answers,question:i})})),process.exitCode=2;return}}function assertCompatibleEveVersion(e){if(e===void 0)return;let t=resolveInstalledPackageInfo().version;if(semver.validRange(e)===null)throw Error(`Registry item has an invalid eve version requirement: ${e}.`);if(!semver.subset(t,e,{includePrerelease:!0}))throw Error(`This registry item requires eve ${e}, but this project is using eve ${t}. Upgrade eve and run the command again.`)}function isOfficialItemAddress(e){return e.startsWith(`${OFFICIAL_REGISTRY}/`)}function withBuiltInRegistries(e){return{...e,registries:{[SKILLS_REGISTRY]:`https://www.skills.sh/r/{name}?agent=eve`,...e.registries}}}async function readEveRegistryConfig(e){return withBuiltInRegistries(await readRegistryConfig(e))}function configuredRegistrySources(e){return Object.keys(e.registries??{})}function validateRegistrySource(e){if(e!==void 0&&!e.startsWith(`@`)&&!/^https?:\/\//.test(e))throw Error(`Registry sources must be a namespace or URL: ${e}`)}async function loadOfficialSearchMetadata(){let e=await fetch(OFFICIAL_CATALOG);if(!e.ok)throw Error(`Could not read the eve registry (${e.status}).`);return parseOfficialRegistrySearchMetadata(await e.json())}function searchItemAddress(e){return e.registry===OFFICIAL_CATALOG?e.name:e.addCommandArgument}function enrichSearchItem(e,t){let n=searchItemAddress(e);return{item:e,address:n,...t.get(n)}}function registrySourceLabel(e){return e===OFFICIAL_CATALOG?`eve`:e===SKILLS_REGISTRY?`skills.sh`:e}function searchPresentationSections(e,t,n){return e.flatMap(e=>{let r=t.get(e);return r===void 0?[]:[{label:registrySourceLabel(e),items:r.items.map(e=>enrichSearchItem(e,n)),total:r.pagination.total}]})}async function printAddSuggestions(e,t,n){try{let r=n.split(`/`).at(-1)||n,{resultsBySource:i,sources:a,metadataByAddress:o}=await searchRegistryCatalog(t,{limit:5,query:r}),s=searchPresentationSections(a,i,o);if(s.every(e=>e.items.length===0))return;e.log(`Did you mean?`),printRegistrySearchResults(e,{query:r,sections:s})}catch{}}async function searchRegistryCatalog(e,t){validateRegistrySource(t.source);let n=await readEveRegistryConfig(e),r=t.source?[t.source]:[OFFICIAL_CATALOG,...configuredRegistrySources(n).filter(e=>t.query!==void 0||e!==SKILLS_REGISTRY)],i=await Promise.all(r.map(async e=>{try{return{result:await searchRegistries([e],{config:n,limit:t.limit??500,query:t.query}),source:e}}catch(t){return{error:t,source:e}}})),a=[],o=new Map;for(let e of i)if(`error`in e)a.push({message:errorMessage(e.error),registry:e.source});else{let t=e.result.errors??[];if(a.push(...t),t.length===0){let t=e.result.items.filter(t=>t.registry===e.source);o.set(e.source,{...e.result,items:t,pagination:{...e.result.pagination,total:e.result.items.length===t.length?e.result.pagination.total:0}})}}let s=new Map(a.map(e=>[`${e.registry}\0${e.message}`,e])),c=o.has(OFFICIAL_CATALOG)?await loadOfficialSearchMetadata():new Map,l=o.get(OFFICIAL_CATALOG);if(l!==void 0){let e=l.items.filter(e=>c.get(searchItemAddress(e))?.hidden!==!0);l.items=e,l.pagination={...l.pagination,total:e.length},l.items.sort((e,t)=>{let rank=e=>c.get(searchItemAddress(e))?.implementation===`native`?0:1;return rank(e)-rank(t)})}let u=[...o.values()];return{config:n,result:{items:u.flatMap(e=>e.items),pagination:{hasMore:u.some(e=>e.pagination.hasMore),limit:t.limit??500,offset:0,total:u.reduce((e,t)=>e+t.pagination.total,0)},...s.size>0?{errors:[...s.values()]}:{}},resultsBySource:o,sources:r,metadataByAddress:c}}async function browseRegistryCatalog(e,t={}){let{result:n}=await searchRegistryCatalog(e,t);return{items:n.items.map(e=>{let t={address:e.registry===OFFICIAL_CATALOG?e.name:e.addCommandArgument,name:e.name,source:e.registry===OFFICIAL_CATALOG?`Vercel`:e.registry};return e.title!==void 0&&(t.title=e.title),e.type!==void 0&&(t.type=e.type),e.description!==void 0&&(t.description=e.description),t}),total:n.pagination.total,errors:n.errors??[]}}async function browseRegistryItems(e,t,n,r,i={}){let{result:a,resultsBySource:o,sources:s,metadataByAddress:c}=await searchRegistryCatalog(t,{limit:i.limit,query:n,source:r}),l=a.errors??[];if(i.json||o.size>0){let t=a.items.map(e=>({...e,...c.get(searchItemAddress(e))})),r={query:n,sections:searchPresentationSections(s,o,c)};i.json&&(r.json={...a,items:t}),printRegistrySearchResults(e,r)}for(let t of l)e.error(`${t.registry}: ${t.message}`);l.length>0&&(process.exitCode=1)}async function installRegistryItem(e,t,n={},r=defaultAddCommandDependencies){let i,a=[],o={error:e=>{i=e},log:e=>a.push(e)},s=process.exitCode,c;try{c=await runAddCommand(o,e,t,{...n,yes:n.prompter===void 0||n.yes,setupAuthorized:n.prompter!==void 0,throwSetupFailures:!0},r)}catch(e){if(process.exitCode=s,!(e instanceof RegistrySetupFailedError))throw e;let t={resumeCommand:e.resumeCommand,reason:e.reason};return e.prerequisite!==void 0&&(t.prerequisite=e.prerequisite),{output:a,setupIncomplete:t}}if(process.exitCode=s,i!==void 0)throw Error(i);if(c===!1)throw new WizardCancelledError;if(c===`setup-incomplete`)return{output:a,setupIncomplete:{resumeCommand:setupResumeCommand(t)}};let l={output:a};return c!==void 0&&(l.setup=c),l}async function runAddCommand(e,t,n,r,i=defaultAddCommandDependencies){let setupIncomplete=t=>(r.silent!==!0&&e.log(setupReminder(n,t)),`setup-incomplete`);return runRegistryAction(e,t,async()=>{let a=itemAddress(n),o;if(a===itemAddress(WEB_CHAT_ITEMS.next)&&r.skipInstall!==!0){let a=await askWebChatFramework(e,t,n,r,i);if(a===!1||a===void 0)return a;o=a}let s=o===void 0?a:itemAddress(WEB_CHAT_ITEMS[o]),c=o===void 0?t:await prepareWebChatProjectRoot(t,o),l=await readEveRegistryConfig(t);if(r.skipInstall===!0){if(r.overwrite===!0)throw Error(`--overwrite cannot be used with --skip-install.`);if(r.skipSetup===!0)throw Error(`--skip-install cannot be used with --skip-setup.`);if(!isOfficialItemAddress(a))throw Error(`Setup flows are currently supported only for official eve registry items.`)}let u=await resolveRegistryItemForAdd(e,async()=>(await getRegistryItems([s],{config:l}))[0],()=>printAddSuggestions(e,t,n));if(!u.found)return;let d=u.item,f=isOfficialItemAddress(a)?eveMetadataFromRegistryItem(d):void 0;if(assertCompatibleEveVersion(f?.requires),r.skipInstall===!0){if(f?.setup===void 0)throw Error(`Registry item "${n}" does not declare a setup flow.`);let a=await runDeclaredSetups({logger:e,appRoot:t,item:n,setups:f.setup,options:r,dependencies:i,resumeCommand:setupResumeCommand(n)});return a===!1&&!r.nonInteractive?setupIncomplete(`cancelled`):reportRegistryCompletion(e,n,a,r)}if(!await prepareDeclaredPnpmBuildPolicy({logger:e,appRoot:c,item:n,policies:f?.install?.pnpm?.buildScripts,options:r}))return!1;if(o!==void 0&&await(i.prepareWebRegistryProject??prepareWebRegistryProject)(c,o),await installRegistryItemTransaction({appRoot:c,item:n,registryItem:d,nonInteractive:r.nonInteractive,logger:e,install:async()=>{await addRegistryItems([s],{config:l,cwd:c,overwrite:r.overwrite,silent:r.silent})}}),f?.setup===void 0)return reportRegistryCompletion(e,n,{facts:[]},r);let p=i.hasInteractiveTerminal?.()??defaultAddCommandDependencies.hasInteractiveTerminal();if(r.nonInteractive&&e.log(serializeHeadlessSetupEvent({version:1,type:`progress`,message:r.skipInstall?`Setup ${n}`:`Installed ${n}`})),r.skipSetup===!0)return r.nonInteractive?reportRegistryCompletion(e,n,{facts:[]},r):setupIncomplete(`skipped`);if(!r.nonInteractive&&!r.yes&&!p&&r.setupAuthorized!==!0)return setupIncomplete(`skipped`);if(!r.nonInteractive&&!r.yes&&r.setupAuthorized!==!0)try{if(await(r.prompter??i.createPrompter?.()??defaultAddCommandDependencies.createPrompter()).select({message:`Set up ${n} now?`,initialValue:`yes`,options:[{value:`yes`,label:`Yes`},{value:`no`,label:`No`}]})===`no`)return setupIncomplete(`skipped`)}catch(e){if(!(e instanceof WizardCancelledError))throw e;return setupIncomplete(`cancelled`)}let m=await runDeclaredSetups({logger:e,appRoot:t,item:n,setups:f.setup,options:{...r,force:r.overwrite},dependencies:i,resumeCommand:setupResumeCommand(n)});return m===!1&&!r.nonInteractive?setupIncomplete(`cancelled`):reportRegistryCompletion(e,n,m,r)},{rethrow:e=>r.throwSetupFailures===!0&&e instanceof RegistrySetupFailedError})}async function runRegistryListCommand(e,t,n,r={}){await runRegistryAction(e,t,()=>browseRegistryItems(e,t,void 0,n,r))}async function runRegistrySearchCommand(e,t,n,r,i={}){await runRegistryAction(e,t,()=>browseRegistryItems(e,t,n,r,{...i,limit:i.limit??10}))}async function runRegistryViewCommand(e,t,n,r={}){await runRegistryAction(e,t,async()=>{let i=await readEveRegistryConfig(t),a=await getRegistryItems([itemAddress(n)],{config:i}),o=a.length===1?a[0]:a;e.log(r.json?JSON.stringify(o,null,2):registryViewText(n,o))})}export{browseRegistryCatalog,installRegistryItem,resolveOfficialRegistryUrl,runAddCommand,runRegistryAddCommand,runRegistryListCommand,runRegistrySearchCommand,runRegistryViewCommand};
|
|
@@ -245,7 +245,7 @@ export declare function isPromptCommandAvailableFor(name: PromptCommandExtension
|
|
|
245
245
|
/**
|
|
246
246
|
* Recognizes the slash commands the prompt accepts. `/new` (and `/reset`)
|
|
247
247
|
* starts a fresh session and transcript; `/cancel` stops the running turn;
|
|
248
|
-
* `/clear` clears context in place; `/compact` queues context compaction; `/exit` (and
|
|
248
|
+
* `/clear` stops the running turn and clears context in place; `/compact` queues context compaction; `/exit` (and
|
|
249
249
|
* `/quit`) terminate the TUI like Ctrl+C; extension commands are dispatched
|
|
250
250
|
* outside the runner. Anything else — including unknown `/text` — is a normal
|
|
251
251
|
* message.
|
|
@@ -46,7 +46,7 @@ export declare class ClientSession {
|
|
|
46
46
|
readonly signal?: AbortSignal;
|
|
47
47
|
readonly turnId?: string | null;
|
|
48
48
|
}): Promise<Delivery>;
|
|
49
|
-
/**
|
|
49
|
+
/** Cancels a running turn and every working task, then removes this session's model history. */
|
|
50
50
|
clear(options?: {
|
|
51
51
|
readonly signal?: AbortSignal;
|
|
52
52
|
}): Promise<Delivery>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"moduleFingerprints": {
|
|
3
3
|
"@eve/catalog": "29b7529f6044427c750e4c27fe91da792014c60c660db31b7ca1fff0afe7f603",
|
|
4
4
|
"just-secrets": "1ce67d437d0bb06df02e4e99180a3c5f5edf0010314010226e97b96d462bba5d",
|
|
5
|
-
"@vercel/agent-runs": "
|
|
5
|
+
"@vercel/agent-runs": "4fe062e4547dd55d36cfcc0ef0233894c4814d3208a0014ad08996eb474bfc79",
|
|
6
6
|
"@workflow/world-local": "a10e78551f65fc607cf75261a569d852c40bc9cfac13a7fb6e15c88bf1ccf429"
|
|
7
7
|
},
|
|
8
8
|
"moduleVersions": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@shadcn/registry": "0.1.3",
|
|
43
43
|
"@standard-schema/spec": "1.1.0",
|
|
44
44
|
"turndown": "7.2.4",
|
|
45
|
-
"@vercel/agent-runs": "0.0.
|
|
45
|
+
"@vercel/agent-runs": "1.0.0-rc.0",
|
|
46
46
|
"@vercel/blob": "2.8.0",
|
|
47
47
|
"@vercel/connect": "2.5.2",
|
|
48
48
|
"@vercel/detect-agent": "1.2.3",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"zod": "4.5.4",
|
|
62
62
|
"zod-validation-error": "5.0.0"
|
|
63
63
|
},
|
|
64
|
-
"scriptHash": "
|
|
64
|
+
"scriptHash": "27398ae2b7e55db0a3ae2cb9eeb8b9507f9ee326f652938412502cdda4395acc",
|
|
65
65
|
"toolVersions": {
|
|
66
66
|
"rolldown": "1.2.9",
|
|
67
67
|
"typescript": "7.0.2"
|
|
@@ -15,7 +15,11 @@ export interface SemVerApi {
|
|
|
15
15
|
gte(version: string, minimumVersion: string): boolean;
|
|
16
16
|
intersects(rangeA: string, rangeB: string): boolean;
|
|
17
17
|
minVersion(range: string): SemVer | null;
|
|
18
|
-
subset(
|
|
18
|
+
subset(
|
|
19
|
+
candidateRange: string,
|
|
20
|
+
requiredRange: string,
|
|
21
|
+
options?: { includePrerelease?: boolean },
|
|
22
|
+
): boolean;
|
|
19
23
|
valid(version: string): string | null;
|
|
20
24
|
validRange(range: string): string | null;
|
|
21
25
|
}
|
|
@@ -8,3 +8,5 @@ export declare function createCompiledChannelRoutePlan(input: {
|
|
|
8
8
|
readonly nodeId: string;
|
|
9
9
|
readonly sources: Readonly<Record<string, AgentSourceDescriptor>>;
|
|
10
10
|
}): CompiledChannelRoutePlan;
|
|
11
|
+
/** A route's identity for matching: `/items/:id` and `/items/:itemId` are one route. */
|
|
12
|
+
export declare function normalizeRoutePattern(path: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createChannelRouteShadowedDiagnostic}from"#compiler/diagnostics.js";import{HOST_HTTP_INVENTORY}from"#framework/host-inventory.js";function createCompiledChannelRoutePlan(e){let t=[],n=[];for(let r of e.channels){let i=HOST_HTTP_INVENTORY.find(e=>routesOverlap(r,e));if(i!==void 0)throw Error(`compile/reserved-route-collision: ${r.method} ${r.urlPath} overlaps reserved ${i.method} ${i.path}.`);let a=t.find(e=>routesOverlap(r,e));if(a===void 0){t.push(r);continue}if(a.sourceId===r.sourceId)throw Error(`compile/channel-route-duplicate: source "${r.sourceId}" emits ${r.method} ${r.urlPath} more than once.`);let o=e.bindings[r.sourceId],s=e.sources[r.sourceId],c=e.sources[a.sourceId];if(o===void 0||s===void 0||c===void 0)throw Error(`Channel source "${r.sourceId}" has no compiled binding.`);n.push({method:r.method,source:s,urlPath:r.urlPath,winnerSourceId:a.sourceId}),e.diagnostics?.push(createChannelRouteShadowedDiagnostic({loser:s,method:r.method,nodeId:e.nodeId,urlPath:r.urlPath,winner:c}))}let r=derivePreflights(t);return{effective:Object.freeze(t),preflight:Object.freeze(r),shadowed:Object.freeze(n)}}function derivePreflights(e){let t=e.filter(e=>e.method!==`WEBSOCKET`&&e.cors!==void 0);for(let[e,n]of t.entries()){let r=t.slice(e+1).find(e=>routePatternsOverlap(n.urlPath,e.urlPath)&&JSON.stringify(n.cors)!==JSON.stringify(e.cors));if(r!==void 0)throw Error(`compile/channel-cors-conflict: overlapping routes at "${n.urlPath}" and "${r.urlPath}" declare different CORS policies.`)}let n=new Map;for(let e of t){let t=normalizeRoutePattern(e.urlPath),r=n.get(t)??[];r.push(e),n.set(t,r)}let r=[];for(let t of n.values()){let n=t[0],i=JSON.stringify(n.cors);if(t.some(e=>JSON.stringify(e.cors)!==i))throw Error(`compile/channel-cors-conflict: routes at "${n.urlPath}" declare different CORS policies.`);if(e.some(e=>e.method===`OPTIONS`&&routePatternsOverlap(e.urlPath,n.urlPath)))throw Error(`compile/channel-preflight-collision: explicit OPTIONS route overlaps generated preflight at "${n.urlPath}".`);r.push({cors:n.cors,method:`OPTIONS`,sourceIds:[...new Set(t.map(e=>e.sourceId))],urlPath:n.urlPath})}return r}function routesOverlap(e,t){return methodsOverlap(e.method,t.method)&&routePatternsOverlap(e.urlPath,t.path??t.urlPath)}function methodsOverlap(e,t){return e===`ALL`||t===`ALL`||e===t}function routePatternsOverlap(e,t){let n=splitRoute(e),r=splitRoute(t);return n.length===r.length&&n.every((e,t)=>isParameter(e)||isParameter(r[t])||e===r[t])}function normalizeRoutePattern(e){return splitRoute(e).map(e=>isParameter(e)?`:`:e).join(`/`)}function splitRoute(e){return e.replace(/^\/+|\/+$/g,``).split(`/`)}function isParameter(e){return e.startsWith(`:`)||/^\[[^\]]+\]$/.test(e)}export{createCompiledChannelRoutePlan};
|
|
1
|
+
import{createChannelRouteShadowedDiagnostic}from"#compiler/diagnostics.js";import{HOST_HTTP_INVENTORY}from"#framework/host-inventory.js";function createCompiledChannelRoutePlan(e){let t=[],n=[];for(let r of e.channels){let i=HOST_HTTP_INVENTORY.find(e=>routesOverlap(r,e));if(i!==void 0)throw Error(`compile/reserved-route-collision: ${r.method} ${r.urlPath} overlaps reserved ${i.method} ${i.path}.`);let a=t.find(e=>routesOverlap(r,e));if(a===void 0){t.push(r);continue}if(a.sourceId===r.sourceId)throw Error(`compile/channel-route-duplicate: source "${r.sourceId}" emits ${r.method} ${r.urlPath} more than once.`);let o=e.bindings[r.sourceId],s=e.sources[r.sourceId],c=e.sources[a.sourceId];if(o===void 0||s===void 0||c===void 0)throw Error(`Channel source "${r.sourceId}" has no compiled binding.`);n.push({method:r.method,source:s,urlPath:r.urlPath,winnerSourceId:a.sourceId}),e.diagnostics?.push(createChannelRouteShadowedDiagnostic({loser:s,method:r.method,nodeId:e.nodeId,urlPath:r.urlPath,winner:c}))}rejectWebSocketParameterMismatches(t);let r=derivePreflights(t);return{effective:Object.freeze(t),preflight:Object.freeze(r),shadowed:Object.freeze(n)}}function derivePreflights(e){let t=e.filter(e=>e.method!==`WEBSOCKET`&&e.cors!==void 0);for(let[e,n]of t.entries()){let r=t.slice(e+1).find(e=>routePatternsOverlap(n.urlPath,e.urlPath)&&JSON.stringify(n.cors)!==JSON.stringify(e.cors));if(r!==void 0)throw Error(`compile/channel-cors-conflict: overlapping routes at "${n.urlPath}" and "${r.urlPath}" declare different CORS policies.`)}let n=new Map;for(let e of t){let t=normalizeRoutePattern(e.urlPath),r=n.get(t)??[];r.push(e),n.set(t,r)}let r=[];for(let t of n.values()){let n=t[0],i=JSON.stringify(n.cors);if(t.some(e=>JSON.stringify(e.cors)!==i))throw Error(`compile/channel-cors-conflict: routes at "${n.urlPath}" declare different CORS policies.`);if(e.some(e=>e.method===`OPTIONS`&&routePatternsOverlap(e.urlPath,n.urlPath)))throw Error(`compile/channel-preflight-collision: explicit OPTIONS route overlaps generated preflight at "${n.urlPath}".`);r.push({cors:n.cors,method:`OPTIONS`,sourceIds:[...new Set(t.map(e=>e.sourceId))],urlPath:n.urlPath})}return r}function rejectWebSocketParameterMismatches(e){for(let t of e.filter(e=>e.method===`WEBSOCKET`)){let n=normalizeRoutePattern(t.urlPath),r=e.find(e=>e.method===`GET`&&normalizeRoutePattern(e.urlPath)===n);if(r===void 0)continue;let i=parameterNames(r.urlPath),a=parameterNames(t.urlPath);if(i.join(`/`)!==a.join(`/`))throw Error(`compile/channel-websocket-params-mismatch: GET ${r.urlPath} and WS ${t.urlPath} match the same requests but name their parameters differently (${i.join(`, `)} vs ${a.join(`, `)}). One handler serves both, so rename the parameters in one route to match the other.`)}}function parameterNames(e){return splitRoute(e).filter(isParameter).map(e=>e.replace(/^:|^\[|\]$/g,``))}function routesOverlap(e,t){return methodsOverlap(e.method,t.method)&&routePatternsOverlap(e.urlPath,t.path??t.urlPath)}function methodsOverlap(e,t){return e===`ALL`||t===`ALL`||e===t}function routePatternsOverlap(e,t){let n=splitRoute(e),r=splitRoute(t);return n.length===r.length&&n.every((e,t)=>isParameter(e)||isParameter(r[t])||e===r[t])}function normalizeRoutePattern(e){return splitRoute(e).map(e=>isParameter(e)?`:`:e).join(`/`)}function splitRoute(e){return e.replace(/^\/+|\/+$/g,``).split(`/`)}function isParameter(e){return e.startsWith(`:`)||/^\[[^\]]+\]$/.test(e)}export{createCompiledChannelRoutePlan,normalizeRoutePattern};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{relative,resolve}from"node:path";import{normalizeLogicalPath}from"#discover/filesystem.js";import{toErrorMessage}from"#shared/errors.js";import{parseJsonObject}from"#shared/json.js";import{isDynamicModelDefinition}from"#shared/agent-definition.js";import{createCompiledBindingNamespaceLoader}from"#compiler/load-binding-namespace.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{isDefinedAgent}from"#public/definitions/agent.js";import{isDynamicSentinel}from"#dynamic/definition.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{isMockModel}from"#internal/mock-model-identity.js";import{isChatGptModelRouting}from"#shared/chatgpt-model.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{isPathInsideOrEqual}from"#shared/path-inside.js";async function compileAgentConfig(e,t,n){let r=n.source,i=formatAgentConfigModulePath(e,r,n.binding),a=Object.hasOwn(n,`definition`)?n.definition:await loadModuleBackedDefinition({binding:n.binding,displayPath:i,kind:`agent config`,loadNamespace:createCompiledBindingNamespaceLoader({appRoot:e.appRoot,bindings:{[r.sourceId]:n.binding},registries:t.registries}),source:r});if(!isDefinedAgent(a)&&!isDynamicSentinel(a))throw Error(`Export defineAgent({...}) from "${i}".`);let o=normalizeAgentDefinition(a,`Expected the agent config export "${r.exportName??`default`}" from "${i}" to match the public eve shape.`),s=isDynamicModelDefinition(o.model)?o.model:void 0,c=s===void 0?await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:o.modelContextWindowTokens,promptCache:o.modelOptions?.promptCache,providerOptions:o.modelOptions?.providerOptions,source:r,sourcePath:i,value:o.model}):void 0,l={},u={compaction:l,name:e.agentId,source:{...r}};o.defaultTools!==void 0&&(u.defaultTools=o.defaultTools),o.description!==void 0&&(u.description=o.description);let d;s!==void 0&&(d={exportName:r.exportName,sourceKind:`module`,logicalPath:r.logicalPath,sourceId:r.sourceId});let f=normalizeExperimentalDefinition(o.experimental);if(f!==void 0&&(u.experimental=f),o.build!==void 0&&(u.build={externalDependencies:o.build.externalDependencies===void 0?void 0:[...o.build.externalDependencies]}),o.reasoning!==void 0&&(u.reasoning=o.reasoning),o.tool!==void 0&&(u.tool=o.tool),o.limits!==void 0&&(u.limits={sessionTimeoutMs:o.limits.sessionTimeoutMs,sessionUsage:typeof o.limits.sessionUsage==`function`||o.limits.sessionUsage}),o.compaction?.model!==void 0&&(l.model=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:o.compaction.modelContextWindowTokens,providerOptions:o.modelOptions?.providerOptions,source:r,sourceField:`compaction.model`,sourcePath:i,value:o.compaction.model})),o.compaction?.threshold!==void 0&&(l.thresholdPercent=o.compaction.threshold),d!==void 0)return{...u,dynamicModel:d};if(c===void 0)throw Error(`Expected a static agent model to compile to a concrete model reference.`);return{...u,model:c}}function normalizeExperimentalDefinition(e){if(e===void 0)return;let t={};return e.workflow!==void 0&&(t.workflow={modelCallsPerStep:e.workflow.modelCallsPerStep,retention:e.workflow.retention,world:e.workflow.world}),t}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`){let t=classifyModelRouting(e.value,e.providerOptions);return rejectGatewayPromptCache(e,t),await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:t},e)}let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${e.sourcePath??t.logicalPath}" to provide a valid AI SDK language model.`);let i=classifyModelRouting(n,e.providerOptions);rejectGatewayPromptCache(e,i);let a={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:i};if(e.sourceField!==void 0&&(a.sourceField=e.sourceField),e.promptCache!==void 0&&(a.promptCache=e.promptCache),e.contextWindowTokens===void 0){if(isChatGptModelRouting(a.routing))return{...a,contextWindowTokens:2e5};if(isMockModel(n))return{...a,contextWindowTokens:1e6};try{let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...a,id:t.slug,contextWindowTokens:t.contextWindowTokens}}catch{}}return await withCompiledRuntimeModelLimits(a,e)}function rejectGatewayPromptCache(e,t){if(e.promptCache!==void 0&&t.kind===`gateway`)throw Error(`${e.sourcePath??`agent.ts`}: modelOptions.promptCache applies only to models eve calls directly, but "${formatLanguageModelGatewayId(e.value)}" routes through AI Gateway, which manages its own prompt caching. Remove promptCache, or configure Gateway caching with providerOptions.gateway.caching.`)}function formatAgentConfigModulePath(e,t,n){return n.backing.kind===`programmatic`?t.logicalPath:normalizeLogicalPath(relative(resolveTopLevelAgentRoot(e),n.backing.sourcePath))}function resolveTopLevelAgentRoot(e){let t=resolve(e.appRoot),n=resolve(t,`agent`),r=resolve(e.agentRoot);return isPathInsideOrEqual(r,n)?n:t}async function withCompiledRuntimeModelLimits(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n=await t.modelCatalog.getModelLimits(e.id).catch(n=>{throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${toErrorMessage(n)}`)});if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{compileAgentConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{runJsProgram}from"#execution/dynamic-workflow/workflow.js";async function runWorkflowProgramTask(e,t){"use workflow";return runJsProgram(e.js,t,{maxSubagents:e.maxSubagents??0})}runWorkflowProgramTask.workflowId=`workflow//eve@0.
|
|
1
|
+
import{runJsProgram}from"#execution/dynamic-workflow/workflow.js";async function runWorkflowProgramTask(e,t){"use workflow";return runJsProgram(e.js,t,{maxSubagents:e.maxSubagents??0})}runWorkflowProgramTask.workflowId=`workflow//eve@1.0.0-rc.0//runWorkflowProgramTask`;export{runWorkflowProgramTask};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{activeTurn,interactionOwner,waiting}from"#protocol/session-projection/selectors.js";import{AuthKey,TurnDeliveryIdsKey}from"#context/keys.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{storedProjection}from"#harness/session-machine/view.js";import{V26_INPUT_REMOTE_AGENT_PROTOCOL}from"#protocol/remote-agent-protocol.js";import{hasDelegatedSessionContext}from"#execution/delegated-session-context.js";import{resolveRemoteAgentStreamHeaders,respondToRemoteAgentSession}from"#execution/agent-sessions/remote.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{readHitlState}from"#harness/hitl/index.js";import{selectDeliveryPayloads}from"#harness/messages.js";import{resumeSessionInbox}from"#execution/session-inbox/resume.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{commitSessionStep,publishSessionEvents}from"#execution/publish-session-events.js";import"#execution/session/state-delta.js";import{withSessionStateDelta}from"#execution/session/step-state-delta.js";import{routeAnswer}from"#harness/session-machine/transitions.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{fact}from"#harness/facts.js";import{userPartsOf}from"#harness/user-parts.js";import{principalOf}from"#execution/session/delivery-facts.js";import{setChannelContext}from"#execution/channel-context.js";import{isSteeringDelivery}from"#execution/session/input-queue.js";import{continueTurnAuth,resolveTurnPrincipal}from"#execution/session/principal.js";import{routeDeliverPayload}from"#subagents/hitl-proxy.js";import{protocolTwoAnswersSettledOnForward}from"#subagents/protocol-two-callback.js";import{sendWorkflowAskAnswers}from"#execution/tools/workflow/answer.js";async function routeProxiedDeliverStep(e){"use step";return await withSessionStateDelta(e,routeProxiedDeliver)}async function routeProxiedDeliver(e){let t=readHitlState(readDurableSession(e.sessionState).state).relays,{delivery:n,serializedContext:r}=await deliverChannelAnswers({...e,routable:e=>t.has(e.interactionId)}),i=readDurableSession(e.sessionState),a=new Map,o=new Map,s,c=!hasDelegatedSessionContext(r)&&isSteeringDelivery(n,{callerCallId:void 0,principal:resolveTurnPrincipal(void 0,r)},{heldOnPerson:!0}),l=new Set,u=[],d=!1,f=storedProjection(i.state).view,p=activeTurn(f),m=p===void 0?void 0:waiting(f,p.turnId),askedTurn=e=>{let t=interactionOwner(f,e).turnId;return t!==void 0&&f.turns[t]?.status===`running`?t:m?.on===`interaction`&&m.interactions.some(t=>t.interactionId===e.interactionId)?p?.turnId:void 0},h=[],g=[];for(let[e,t]of n.payloads.entries()){let r=routeDeliverPayload({allowRoute:e=>!l.has(e),payload:t,resolveMessage:c,state:i.state});s??=r.parentAction,r.forSelf!==void 0&&a.set(e,r.forSelf);let p=(n.deliveryMetadata??[]).filter(t=>t.payloadIndex===e),m=p[0]?.deliveryId;if(r.forChildren.length>0&&m!==void 0){let e=r.forChildren.find(e=>e.message!==void 0),i=r.forChildren.flatMap(e=>e.payload.answers).map(e=>f.interactions[e.interactionId]).find(e=>e!==void 0&&askedTurn(e)!==void 0),a=i===void 0?void 0:askedTurn(i);e!==void 0&&a!==void 0&&(d=!0),r.forSelf===void 0&&a!==void 0&&u.push(...p.map(e=>e.deliveryId));for(let t of p)h.push({consumed:r.forSelf===void 0&&a!==void 0?{parts:e?.message===void 0?[]:userPartsOf(e.message),turnId:a}:void 0,continues:r.forSelf!==void 0||void 0,deliveryId:t.deliveryId,principal:principalOf(n.auth),source:t.channelKind===void 0?void 0:{channel:t.channelKind}});for(let e of r.forChildren)for(let n of e.payload.answers){let e=(t.answers??[]).indexOf(n),r={};n.optionId!==void 0&&(r.optionId=n.optionId),n.text!==void 0&&(r.text=n.text),g.push({deliveryId:m,interactionId:n.interactionId,responseId:`response_${m}_forwarded_${e===-1?`typed_0`:String(e)}`,value:r})}}for(let[t,i]of r.forChildren.entries()){if(i.workflowAsk!==void 0||i.message!==void 0)for(let{interactionId:e}of i.payload.answers)l.add(e);let a=JSON.stringify([i.childContinuationToken,i.childSessionInbox?.sessionId??``,i.remote?.sessionId??``,i.inputSource??null,i.workflowAsk?.control??null]),s=o.get(a)??{workflowAsk:i.workflowAsk,remote:i.remote,childContinuationToken:i.childContinuationToken,childSessionInbox:i.childSessionInbox,metadata:[],payloads:[]},c=s.payloads.length;if(s.payloads.push(i.payload),r.forSelf===void 0&&t===0)for(let t of n.deliveryMetadata??[])t.payloadIndex===e&&s.metadata.push({...t,payloadIndex:c});o.set(a,s)}}let _={serializedContext:joinAnswerToTurn(r,{auth:d?n.auth:void 0,deliveryIds:u}),sessionState:e.sessionState},v=!1,y=h.filter(e=>e.consumed!==void 0),b=y.length===0?_:await commitSessionStep({..._,sessionWritable:e.sessionWritable},e=>[routeAnswer(e,{deliveries:y,forwarded:[],decided:[]})],{origin:`own`,cancelTurn:()=>{v=!0}});if(v){let t=storedProjection(readDurableSession(b.sessionState).state).view,r=(n.deliveryMetadata??[]).filter(({deliveryId:e,payloadIndex:n})=>a.has(n)&&t.deliveries[e]?.status!==`settled`);if(r.length===0)return{...b,kind:`cancel-turn`};let i=await publishSessionEvents({...b,sessionWritable:e.sessionWritable},r.flatMap(({channelKind:e,deliveryId:r})=>[...t.deliveries[r]===void 0?[fact(`delivery.admitted`,{deliveryId:r,principal:principalOf(n.auth),source:e===void 0?void 0:{channel:e}})]:[],fact(`delivery.settled`,{deliveryId:r,outcome:`ignored`})]));return{kind:`cancel-turn`,serializedContext:i.serializedContext,sessionState:i.sessionState}}let x=[];for(let[e,t]of o)if(t.workflowAsk!==void 0){let e=coalesceDeliverPayloads(t.payloads).answers??[];x.push(...e.map(e=>({answer:e,outcome:`accepted`}))),await sendWorkflowAskAnswers(t.workflowAsk,e,principalOf(n.auth))}else{let i={...n,deliveryMetadata:t.metadata.length===0?void 0:t.metadata,payloads:t.payloads},a=t.remote;if(a!==void 0){let i=await deserializeContext(r),o=await resolveRemoteAgentStreamHeaders({bundle:i.require(BundleKey),name:a.name,dynamicBinding:a.dynamicBinding,resolverId:a.resolverId,url:a.url}),c=coalesceDeliverPayloads(t.payloads).answers??[];if(await respondToRemoteAgentSession({remote:a,headers:o,auth:n.auth,idempotencyKey:await answersIdempotencyKey(n,e),responses:c}),a.earlierProtocol===V26_INPUT_REMOTE_AGENT_PROTOCOL)for(let e of protocolTwoAnswersSettledOnForward({answers:c,decidedHere:s?.answer.interactionId,kindOf:e=>f.interactions[e]?.request.kind}))x.push({answer:e,outcome:`accepted`})}else await resumeSessionInbox(t.childSessionInbox??t.childContinuationToken,i)}let S=await commitSessionStep({...b,sessionWritable:e.sessionWritable},e=>[routeAnswer(e,{decided:s===void 0?x:[...x,{answer:s.answer,outcome:`declined`}],deliveries:h,forwarded:g})],{origin:`relayed`});if(s!==void 0)return{...S,kind:s.kind};let C=[...a].sort(([e],[t])=>e-t),w=C.length===0?void 0:selectDeliveryPayloads(n,C.map(([e,t])=>({index:e,payload:t})));return{...S,kind:`continue`,remainder:w}}async function answersIdempotencyKey(e,t){let n=(e.deliveryMetadata??[]).map(e=>e.deliveryId);if(n.length===0)return;let r=JSON.stringify([n,t]),i=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(r));return`eve-answers:${Array.from(new Uint8Array(i),e=>e.toString(16).padStart(2,`0`)).join(``)}`}function joinAnswerToTurn(e,t){let n={...e};if(t.auth!==void 0&&(n[AuthKey.name]=continueTurnAuth(e[AuthKey.name],t.auth)),t.deliveryIds.length>0){let e=n[TurnDeliveryIdsKey.name]??[];n[TurnDeliveryIdsKey.name]=[...new Set([...e,...t.deliveryIds])]}return n}async function mapHeldAnswersStep(e){"use step";return await withSessionStateDelta(e,async()=>{let t=new Set(e.requestIds),n=await deliverChannelAnswers({...e,routable:e=>t.has(e.interactionId)});return n.delivery===e.delivery?{delivery:void 0}:{delivery:n.delivery,serializedContext:n.serializedContext}})}async function deliverChannelAnswers(e){let{routable:t}=e;if(!e.delivery.payloads.some(e=>e.answers?.some(e=>!t(e))===!0))return e;let n=await deserializeContext(e.serializedContext),r=n.require(ChannelKey);if(r.deliver===void 0)return e;e.delivery.auth!==void 0&&n.set(AuthKey,e.delivery.auth??null);let i=r.state??{},a=!1,o=[];for(let s of e.delivery.payloads){if(s.answers===void 0){o.push(s);continue}let e=[];for(let o of s.answers){if(t(o)){e.push(o);continue}let c=buildAdapterContext({...r,state:structuredClone(i)},n),l=(await r.deliver({...s,answers:[o],message:void 0},c))?.answers?.filter(t)??[];if(l.length===0){e.push(o);continue}a=!0,i=c.state,e.push(...l)}o.push({...s,answers:e})}if(!a)return e;let s=await deserializeContext(e.serializedContext);return setChannelContext(s,{...r,state:i}),{delivery:{...e.delivery,payloads:o},serializedContext:serializeContext(s)}}export{answersIdempotencyKey,mapHeldAnswersStep,routeProxiedDeliverStep};
|
|
1
|
+
import{activeTurn,interactionOwner,waiting}from"#protocol/session-projection/selectors.js";import{AuthKey,TurnDeliveryIdsKey}from"#context/keys.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{storedProjection}from"#harness/session-machine/view.js";import{V26_INPUT_REMOTE_AGENT_PROTOCOL}from"#protocol/remote-agent-protocol.js";import{hasDelegatedSessionContext}from"#execution/delegated-session-context.js";import{resolveRemoteAgentStreamHeaders,respondToRemoteAgentSession}from"#execution/agent-sessions/remote.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{readDurableSession}from"#execution/durable-session-store.js";import{readHitlState}from"#harness/hitl/index.js";import{selectDeliveryPayloads}from"#harness/messages.js";import{resumeSessionInbox}from"#execution/session-inbox/resume.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{commitSessionStep,publishSessionEvents}from"#execution/publish-session-events.js";import"#execution/session/state-delta.js";import{withSessionStateDelta}from"#execution/session/step-state-delta.js";import{routeAnswer}from"#harness/session-machine/transitions.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{fact}from"#harness/facts.js";import{userPartsOf}from"#harness/user-parts.js";import{principalOf}from"#execution/session/delivery-facts.js";import{setChannelContext}from"#execution/channel-context.js";import{isSteeringDelivery}from"#execution/session/input-queue.js";import{continueTurnAuth,resolveTurnPrincipal}from"#execution/session/principal.js";import{routeDeliverPayload}from"#subagents/hitl-proxy.js";import{protocolTwoAnswersSettledOnForward}from"#subagents/protocol-two-callback.js";import{sendWorkflowAskAnswers}from"#execution/tools/workflow/answer.js";async function routeProxiedDeliverStep(e){"use step";return await withSessionStateDelta(e,routeProxiedDeliver)}async function routeProxiedDeliver(e){let t=readHitlState(readDurableSession(e.sessionState).state).relays,{delivery:n,serializedContext:r}=await deliverChannelAnswers({...e,routable:e=>t.has(e.interactionId)}),i=readDurableSession(e.sessionState),a=new Map,o=new Map,s,c=!hasDelegatedSessionContext(r)&&!(n.deliveryMetadata??[]).some(e=>e.hook!==void 0)&&isSteeringDelivery(n,{callerCallId:void 0,principal:resolveTurnPrincipal(void 0,r)},{heldOnPerson:!0}),l=new Set,u=[],d=!1,f=storedProjection(i.state).view,p=activeTurn(f),m=p===void 0?void 0:waiting(f,p.turnId),askedTurn=e=>{let t=interactionOwner(f,e).turnId;return t!==void 0&&f.turns[t]?.status===`running`?t:m?.on===`interaction`&&m.interactions.some(t=>t.interactionId===e.interactionId)?p?.turnId:void 0},h=[],g=[];for(let[e,t]of n.payloads.entries()){let r=routeDeliverPayload({allowRoute:e=>!l.has(e),payload:t,resolveMessage:c,state:i.state});s??=r.parentAction,r.forSelf!==void 0&&a.set(e,r.forSelf);let p=(n.deliveryMetadata??[]).filter(t=>t.payloadIndex===e),m=p[0]?.deliveryId;if(r.forChildren.length>0&&m!==void 0){let e=r.forChildren.find(e=>e.message!==void 0),i=r.forChildren.flatMap(e=>e.payload.answers).map(e=>f.interactions[e.interactionId]).find(e=>e!==void 0&&askedTurn(e)!==void 0),a=i===void 0?void 0:askedTurn(i);e!==void 0&&a!==void 0&&(d=!0),r.forSelf===void 0&&a!==void 0&&u.push(...p.map(e=>e.deliveryId));for(let t of p)h.push({consumed:r.forSelf===void 0&&a!==void 0?{parts:e?.message===void 0?[]:userPartsOf(e.message),turnId:a}:void 0,continues:r.forSelf!==void 0||void 0,deliveryId:t.deliveryId,principal:principalOf(n.auth),source:t.channelKind===void 0?void 0:{channel:t.channelKind}});for(let e of r.forChildren)for(let n of e.payload.answers){let e=(t.answers??[]).indexOf(n),r={};n.optionId!==void 0&&(r.optionId=n.optionId),n.text!==void 0&&(r.text=n.text),g.push({deliveryId:m,interactionId:n.interactionId,responseId:`response_${m}_forwarded_${e===-1?`typed_0`:String(e)}`,value:r})}}for(let[t,i]of r.forChildren.entries()){if(i.workflowAsk!==void 0||i.message!==void 0)for(let{interactionId:e}of i.payload.answers)l.add(e);let a=JSON.stringify([i.childContinuationToken,i.childSessionInbox?.sessionId??``,i.remote?.sessionId??``,i.inputSource??null,i.workflowAsk?.control??null]),s=o.get(a)??{workflowAsk:i.workflowAsk,remote:i.remote,childContinuationToken:i.childContinuationToken,childSessionInbox:i.childSessionInbox,metadata:[],payloads:[]},c=s.payloads.length;if(s.payloads.push(i.payload),r.forSelf===void 0&&t===0)for(let t of n.deliveryMetadata??[])t.payloadIndex===e&&s.metadata.push({...t,payloadIndex:c});o.set(a,s)}}let _={serializedContext:joinAnswerToTurn(r,{auth:d?n.auth:void 0,deliveryIds:u}),sessionState:e.sessionState},v=!1,y=h.filter(e=>e.consumed!==void 0),b=y.length===0?_:await commitSessionStep({..._,sessionWritable:e.sessionWritable},e=>[routeAnswer(e,{deliveries:y,forwarded:[],decided:[]})],{origin:`own`,cancelTurn:()=>{v=!0}});if(v){let t=storedProjection(readDurableSession(b.sessionState).state).view,r=(n.deliveryMetadata??[]).filter(({deliveryId:e,payloadIndex:n})=>a.has(n)&&t.deliveries[e]?.status!==`settled`);if(r.length===0)return{...b,kind:`cancel-turn`};let i=await publishSessionEvents({...b,sessionWritable:e.sessionWritable},r.flatMap(({channelKind:e,deliveryId:r})=>[...t.deliveries[r]===void 0?[fact(`delivery.admitted`,{deliveryId:r,principal:principalOf(n.auth),source:e===void 0?void 0:{channel:e}})]:[],fact(`delivery.settled`,{deliveryId:r,outcome:`ignored`})]));return{kind:`cancel-turn`,serializedContext:i.serializedContext,sessionState:i.sessionState}}let x=[];for(let[e,t]of o)if(t.workflowAsk!==void 0){let e=coalesceDeliverPayloads(t.payloads).answers??[];x.push(...e.map(e=>({answer:e,outcome:`accepted`}))),await sendWorkflowAskAnswers(t.workflowAsk,e,principalOf(n.auth))}else{let i={...n,deliveryMetadata:t.metadata.length===0?void 0:t.metadata,payloads:t.payloads},a=t.remote;if(a!==void 0){let i=await deserializeContext(r),o=await resolveRemoteAgentStreamHeaders({bundle:i.require(BundleKey),name:a.name,dynamicBinding:a.dynamicBinding,resolverId:a.resolverId,url:a.url}),c=coalesceDeliverPayloads(t.payloads).answers??[];if(await respondToRemoteAgentSession({remote:a,headers:o,auth:n.auth,idempotencyKey:await answersIdempotencyKey(n,e),responses:c}),a.earlierProtocol===V26_INPUT_REMOTE_AGENT_PROTOCOL)for(let e of protocolTwoAnswersSettledOnForward({answers:c,decidedHere:s?.answer.interactionId,kindOf:e=>f.interactions[e]?.request.kind}))x.push({answer:e,outcome:`accepted`})}else await resumeSessionInbox(t.childSessionInbox??t.childContinuationToken,i)}let S=await commitSessionStep({...b,sessionWritable:e.sessionWritable},e=>[routeAnswer(e,{decided:s===void 0?x:[...x,{answer:s.answer,outcome:`declined`}],deliveries:h,forwarded:g})],{origin:`relayed`});if(s!==void 0)return{...S,kind:s.kind};let C=[...a].sort(([e],[t])=>e-t),w=C.length===0?void 0:selectDeliveryPayloads(n,C.map(([e,t])=>({index:e,payload:t})));return{...S,kind:`continue`,remainder:w}}async function answersIdempotencyKey(e,t){let n=(e.deliveryMetadata??[]).map(e=>e.deliveryId);if(n.length===0)return;let r=JSON.stringify([n,t]),i=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(r));return`eve-answers:${Array.from(new Uint8Array(i),e=>e.toString(16).padStart(2,`0`)).join(``)}`}function joinAnswerToTurn(e,t){let n={...e};if(t.auth!==void 0&&(n[AuthKey.name]=continueTurnAuth(e[AuthKey.name],t.auth)),t.deliveryIds.length>0){let e=n[TurnDeliveryIdsKey.name]??[];n[TurnDeliveryIdsKey.name]=[...new Set([...e,...t.deliveryIds])]}return n}async function mapHeldAnswersStep(e){"use step";return await withSessionStateDelta(e,async()=>{let t=new Set(e.requestIds),n=await deliverChannelAnswers({...e,routable:e=>t.has(e.interactionId)});return n.delivery===e.delivery?{delivery:void 0}:{delivery:n.delivery,serializedContext:n.serializedContext}})}async function deliverChannelAnswers(e){let{routable:t}=e;if(!e.delivery.payloads.some(e=>e.answers?.some(e=>!t(e))===!0))return e;let n=await deserializeContext(e.serializedContext),r=n.require(ChannelKey);if(r.deliver===void 0)return e;e.delivery.auth!==void 0&&n.set(AuthKey,e.delivery.auth??null);let i=r.state??{},a=!1,o=[];for(let s of e.delivery.payloads){if(s.answers===void 0){o.push(s);continue}let e=[];for(let o of s.answers){if(t(o)){e.push(o);continue}let c=buildAdapterContext({...r,state:structuredClone(i)},n),l=(await r.deliver({...s,answers:[o],message:void 0},c))?.answers?.filter(t)??[];if(l.length===0){e.push(o);continue}a=!0,i=c.state,e.push(...l)}o.push({...s,answers:e})}if(!a)return e;let s=await deserializeContext(e.serializedContext);return setChannelContext(s,{...r,state:i}),{delivery:{...e.delivery,payloads:o},serializedContext:serializeContext(s)}}export{answersIdempotencyKey,mapHeldAnswersStep,routeProxiedDeliverStep};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{randomUUID}from"node:crypto";import{isEveDevEnvironment}from"#internal/application/dev-environment.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{
|
|
1
|
+
import{randomUUID}from"node:crypto";import{isEveDevEnvironment}from"#internal/application/dev-environment.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{MAX_OUTPUT_BYTES,truncateTail}from"#execution/sandbox/truncate-output.js";const BASH_YIELD_SECONDS=30;async function executeBashOnSandbox(e,t,n={}){let r=formatCommand(t.command);logDevelopmentSandboxCommand(`eve: starting sandbox command: ${r}`);let i=await withDevelopmentSandboxProgress(r,()=>runCommand(e,t.command,n.abortSignal));return logDevelopmentSandboxCommand(i.status===`running`?`eve: sandbox command still running as pid ${i.pid}: ${r}`:`eve: sandbox command finished (exit ${i.exitCode}): ${r}`),i}async function runCommand(e,t,n){n?.throwIfAborted();let r=randomUUID().slice(0,8),i=`/tmp/.eve/jobs/${r}`,a=new AbortController,cancel=()=>{a.abort(n?.reason),Promise.resolve(e.run({command:`kill -TERM -- -"$(cat ${shellQuote(i)}/pid 2>/dev/null)" 2>/dev/null; rm -rf ${shellQuote(i)}`})).catch(()=>{})};n?.addEventListener(`abort`,cancel,{once:!0});try{let n=await e.spawn({signal:a.signal,command:launchCommand(t,i)}),o=Promise.all([readTail(n.stdout),readTail(n.stderr),n.wait()]).then(([e,t,{exitCode:n}])=>({exitCode:n,stderr:t,stdout:e})),s=await waitUpTo(o,3e4);if(s!==void 0)return completed(s.exitCode,s);let c=await claimRunningJob(e,i,r);if(c===void 0){let e=await o;return completed(e.exitCode,e)}return o.catch(()=>{}),c}finally{n?.removeEventListener(`abort`,cancel)}}function launchCommand(e,t){return[`if command -v bash >/dev/null 2>&1 && kill -0 "$$" 2>/dev/null; then`,` set -- ${shellQuote(t)} ${shellQuote(e)}`,` eval ${shellQuote(`d=$1
|
|
2
2
|
mkdir -p "$d" 2>/dev/null || { eval "$2"; exit; }
|
|
3
3
|
trap 'exit 0' USR1
|
|
4
4
|
echo "$$" > "$d/launcher"
|
|
@@ -21,4 +21,4 @@ cat "$d/stderr" >&2
|
|
|
21
21
|
rm -rf "$d"
|
|
22
22
|
exit "$code"`)}`,`fi`,`eval ${shellQuote(e)}`].join(`
|
|
23
23
|
`)}async function claimRunningJob(e,t,n){let r=`eve-bash:${n}`,i=await e.run({command:[`cd ${shellQuote(t)} 2>/dev/null && mkdir claimed 2>/dev/null || exit 0`,`kill -USR1 "$(cat launcher)" 2>/dev/null`,`printf '%s %s %s %s\\n' ${r} "$(cat pid)" "$(($(wc -c < stdout)))" "$(($(wc -c < stderr)))"`,`tail -c ${MAX_OUTPUT_BYTES} stdout`,`tail -c ${MAX_OUTPUT_BYTES} stderr >&2`].join(`
|
|
24
|
-
`)}),a=RegExp(`(?:^|\\n)${r} (\\d+) (\\d+) (\\d+)\\n`).exec(i.stdout);if(a===null)return;let o=Number(a[1]),s=i.stdout.slice(a.index+a[0].length),c={stderr:Math.max(0,Number(a[3])-Buffer.byteLength(i.stderr)),stdout:Math.max(0,Number(a[2])-Buffer.byteLength(s))};return{...formatStreams({stderr:i.stderr,stdout:s},c),message:`The command is still running after 30 seconds as process group ${o}; stdout and stderr show its output so far. It keeps writing to ${t}/stdout and ${t}/stderr, and writes its exit code to ${t}/exit when it finishes. Check on it with later commands such as \`tail ${t}/stdout\` or \`cat ${t}/exit\`, and stop it with \`kill -- -${o}\`.`,outputDirectory:t,pid:o,status:`running`}}async function
|
|
24
|
+
`)}),a=RegExp(`(?:^|\\n)${r} (\\d+) (\\d+) (\\d+)\\n`).exec(i.stdout);if(a===null)return;let o=Number(a[1]),s=i.stdout.slice(a.index+a[0].length),c={stderr:Math.max(0,Number(a[3])-Buffer.byteLength(i.stderr)),stdout:Math.max(0,Number(a[2])-Buffer.byteLength(s))};return{...formatStreams({stderr:i.stderr,stdout:s},c),message:`The command is still running after 30 seconds as process group ${o}; stdout and stderr show its output so far. It keeps writing to ${t}/stdout and ${t}/stderr, and writes its exit code to ${t}/exit when it finishes. Check on it with later commands such as \`tail ${t}/stdout\` or \`cat ${t}/exit\`, and stop it with \`kill -- -${o}\`.`,outputDirectory:t,pid:o,status:`running`}}async function readTail(e){let t=[],n=0,r=0,keepTail=()=>{let e=Buffer.concat(t).subarray(-MAX_OUTPUT_BYTES);return r+=n-e.byteLength,t=[e],n=e.byteLength,e};for await(let r of e)t.push(r),n+=r.byteLength,n>2*MAX_OUTPUT_BYTES&&keepTail();let i=new TextDecoder().decode(keepTail());return{omittedBytes:r,text:i}}async function waitUpTo(e,t){let n;try{return await Promise.race([e,new Promise(e=>{n=setTimeout(()=>e(void 0),t)})])}finally{clearTimeout(n)}}function completed(e,{stderr:t,stdout:n}){return{...formatStreams({stderr:t.text,stdout:n.text},{stderr:t.omittedBytes,stdout:n.omittedBytes}),exitCode:e,status:`completed`}}function formatStreams(e,t){let n=formatStream(`stdout`,e.stdout,t.stdout),r=formatStream(`stderr`,e.stderr,t.stderr);return{stderr:r.output,stdout:n.output,truncated:n.truncated||r.truncated}}function formatStream(e,t,n){let r=truncateTail(t);return!r.truncated&&n===0?{output:r.output,truncated:!1}:{output:`${n===0?`[${e} truncated: showing last ${r.outputLines} of ${r.totalLines} lines]`:`[${e} truncated: showing last ${r.outputLines} lines; earlier output omitted]`}\n${r.output}`,truncated:!0}}async function withDevelopmentSandboxProgress(e,t){if(!isEveDevEnvironment())return await t();let n=Date.now(),r=setInterval(()=>{logDevelopmentSandboxCommand(`eve: waiting for sandbox command (${Math.round((Date.now()-n)/1e3)}s elapsed): ${e}`)},5e3);r.unref?.();try{return await t()}catch(t){throw logDevelopmentSandboxCommand(`eve: sandbox command failed: ${e}`),t}finally{clearInterval(r)}}function logDevelopmentSandboxCommand(e){isEveDevEnvironment()&&console.log(e)}function formatCommand(e){let t=e.replaceAll(/\s+/g,` `).trim();return t.length<=240?t:`${t.slice(0,239)}…`}export{BASH_YIELD_SECONDS,executeBashOnSandbox};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{answersDeliveryId}from"#shared/answers-delivery-id.js";import{activeTurnId,storedProjection,turnPosition}from"#harness/session-machine/view.js";import{coalesceDeliveries,selectDeliveryPayloads}from"#harness/messages.js";import{readDurableSession}from"#execution/durable-session-read.js";import{isSteeringDelivery,isSteeringMessage}from"#execution/session/input-queue.js";import{mapHeldAnswersStep}from"#execution/proxied-deliver-step.js";import{controlDeliveryOf}from"#execution/session/control-delivery.js";import{settleControlDeliveryStep}from"#execution/session/settle-control-delivery-step.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{admitSessionInboxPayload}from"#execution/session/admission.js";import{routeSelectedDelivery}from"#execution/session/route-selected-delivery.js";import{createTurnControl}from"#execution/session/turn-control.js";import{decodeSessionInboxPayload}from"#execution/session-inbox/protocol.js";import{isAgentSessionMessage,runMessageBatchBudget}from"#execution/tools/workflow/messages.js";import{isAppliedRunMessage,takeLeadingAppliedRunMessages}from"#execution/session-workflow-tool-run.js";import{TurnCancelledError}from"#harness/turn-cancellation.js";var ActiveTurn=class{admitted=new Set;routedToChildren=new Set;mappedForHeldRequest=new Set;runtimeResults=[];controller;#e;#t;expectedTurnId;input;identity;unsubscribe;unsubscribeDelivery;steeringController;caller;compacted=!1;constructor(e,t,n=createTurnControl()){this.controller=n.cancellation,this.steeringController=n.steering,this.input=e,this.caller=t.caller,this.#t=t.control===!0,this.identity={callerCallId:t.caller?.callId,principal:t.principal},this.expectedTurnId=activeTurnId(turnPosition(storedProjection(readDurableSession(e.cursor.sessionState).state))),this.unsubscribe=e.inbox.onInterrupt(e=>{this.cancelsThisTurn(e)&&this.abort()}),this.unsubscribeDelivery=e.inbox.onDelivery(this.signalSteering)}signalSteering=e=>{let t;try{t=decodeSessionInboxPayload(e)}catch{return}t.kind===`deliver`&&!this.input.queue.isDuplicate(t)&&isSteeringMessage(t,this.identity)&&!this.input.cursor.sessionState.hasProxyInputRequests&&this.steeringController.abort()};get signal(){return this.controller.signal}dispose(){this.unsubscribe(),this.unsubscribeDelivery()}get steeringSignal(){return this.steeringController.signal}resetSteering(){this.steeringController.signal.aborted&&(this.unsubscribeDelivery(),this.steeringController=new AbortController,this.unsubscribeDelivery=this.input.inbox.onDelivery(this.signalSteering))}async admitBoundary(e=!1){let t=this.input.inbox.drain();for(let n of t)await this.admit(n,e)}async takeSteering(e){let t=[];for(;;){let n=this.input.queue.takeSteering(this.admitted,this.identity,e);if(n===void 0)break;for(let e of n.sequences)this.admitted.delete(e);let r=await routeSelectedDelivery(n,this.input.cursor);if(r.kind===`cancel-turn`){this.abort();break}r.kind===`turn`&&t.push(r.delivery)}if(this.resetSteering(),t.length===0)return;let n=t.length===1?t[0]:coalesceDeliveries(t);return n.caller!==void 0&&(this.caller=n.caller),n}takeBoundaryMessages(e){let t=[],n=[];for(let r of this.runtimeResults){let i=asBoundaryMessage(r);i===void 0||e!==void 0&&!e(i)?n.push(r):t.push(i)}return this.runtimeResults.splice(0,this.runtimeResults.length,...n),t}takeAppliedRunMessages(){let e=runMessageBatchBudget(),t=[];for(let n=this.runtimeResults[0];n!==void 0;n=this.runtimeResults[0]){if(n===`cancelled`||n.kind!==`workflow`||!isAppliedRunMessage(n.message)||!e(n.message))return t;t.push(n.message),this.runtimeResults.shift()}return[...t,...takeLeadingAppliedRunMessages(this.input.inbox,e)]}async nextRuntimeEvent(e){for(;;){let t=await this.routeAdmittedToChildren();if(this.signal.aborted)return`cancelled`;if(t)return{kind:`steering`};let n=this.runtimeResults.shift();if(n!==void 0)return n;let r=await this.waitForInboxOrTimer(e);if(r!==void 0)return{callId:r,kind:`timeout`};let i=await this.input.inbox.next();if(i===void 0)throw Error(`Session inbox closed before runtime actions completed.`);if(await this.admit(i))return{kind:`input`}}}async takeAnswers(e){for(let t of this.admitted){let n=this.input.queue.delivery(t);if(n===void 0)continue;let r=n.payloads.flatMap(e=>e.answers??[]);if(r.length===0)continue;if(!r.some(t=>e.has(t.interactionId))){if(this.mappedForHeldRequest.has(t))continue;this.mappedForHeldRequest.add(t);let r=n,i=await this.input.cursor.advance(t=>mapHeldAnswersStep({delivery:r,requestIds:[...e],...t}));if(i.delivery===void 0)continue;n=i.delivery}this.admitted.delete(t);let i=isSteeringDelivery(n,this.identity,{heldOnPerson:!0})?void 0:splitAnswers(n);return this.input.queue.replaceDelivery(t,i?.rest),i?.answers??n}}async waitForInboxOrTimer(e){if(e.length===0||this.input.inbox.hasPending())return;let t=this.input.inbox.whenPending().then(()=>void 0);return await Promise.race([t,...e])}cancelsThisTurn(e){return e.kind===`reset`||e.kind===`session-failure`?!0:
|
|
1
|
+
import{answersDeliveryId}from"#shared/answers-delivery-id.js";import{activeTurnId,storedProjection,turnPosition}from"#harness/session-machine/view.js";import{coalesceDeliveries,selectDeliveryPayloads}from"#harness/messages.js";import{readDurableSession}from"#execution/durable-session-read.js";import{isSteeringDelivery,isSteeringMessage}from"#execution/session/input-queue.js";import{mapHeldAnswersStep}from"#execution/proxied-deliver-step.js";import{controlDeliveryOf}from"#execution/session/control-delivery.js";import{settleControlDeliveryStep}from"#execution/session/settle-control-delivery-step.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{admitSessionInboxPayload}from"#execution/session/admission.js";import{routeSelectedDelivery}from"#execution/session/route-selected-delivery.js";import{createTurnControl}from"#execution/session/turn-control.js";import{decodeSessionInboxPayload}from"#execution/session-inbox/protocol.js";import{isAgentSessionMessage,runMessageBatchBudget}from"#execution/tools/workflow/messages.js";import{isAppliedRunMessage,takeLeadingAppliedRunMessages}from"#execution/session-workflow-tool-run.js";import{TurnCancelledError}from"#harness/turn-cancellation.js";var ActiveTurn=class{admitted=new Set;routedToChildren=new Set;mappedForHeldRequest=new Set;runtimeResults=[];controller;#e;#t;expectedTurnId;input;identity;unsubscribe;unsubscribeDelivery;steeringController;caller;compacted=!1;constructor(e,t,n=createTurnControl()){this.controller=n.cancellation,this.steeringController=n.steering,this.input=e,this.caller=t.caller,this.#t=t.control===!0,this.identity={callerCallId:t.caller?.callId,principal:t.principal},this.expectedTurnId=activeTurnId(turnPosition(storedProjection(readDurableSession(e.cursor.sessionState).state))),this.unsubscribe=e.inbox.onInterrupt(e=>{this.cancelsThisTurn(e)&&this.abort()}),this.unsubscribeDelivery=e.inbox.onDelivery(this.signalSteering)}signalSteering=e=>{let t;try{t=decodeSessionInboxPayload(e)}catch{return}t.kind===`deliver`&&!this.input.queue.isDuplicate(t)&&isSteeringMessage(t,this.identity)&&!this.input.cursor.sessionState.hasProxyInputRequests&&this.steeringController.abort()};get signal(){return this.controller.signal}dispose(){this.unsubscribe(),this.unsubscribeDelivery()}get steeringSignal(){return this.steeringController.signal}resetSteering(){this.steeringController.signal.aborted&&(this.unsubscribeDelivery(),this.steeringController=new AbortController,this.unsubscribeDelivery=this.input.inbox.onDelivery(this.signalSteering))}async admitBoundary(e=!1){let t=this.input.inbox.drain();for(let n of t)await this.admit(n,e)}async takeSteering(e){let t=[];for(;;){let n=this.input.queue.takeSteering(this.admitted,this.identity,e);if(n===void 0)break;for(let e of n.sequences)this.admitted.delete(e);let r=await routeSelectedDelivery(n,this.input.cursor);if(r.kind===`cancel-turn`){this.abort();break}r.kind===`turn`&&t.push(r.delivery)}if(this.resetSteering(),t.length===0)return;let n=t.length===1?t[0]:coalesceDeliveries(t);return n.caller!==void 0&&(this.caller=n.caller),n}takeBoundaryMessages(e){let t=[],n=[];for(let r of this.runtimeResults){let i=asBoundaryMessage(r);i===void 0||e!==void 0&&!e(i)?n.push(r):t.push(i)}return this.runtimeResults.splice(0,this.runtimeResults.length,...n),t}takeAppliedRunMessages(){let e=runMessageBatchBudget(),t=[];for(let n=this.runtimeResults[0];n!==void 0;n=this.runtimeResults[0]){if(n===`cancelled`||n.kind!==`workflow`||!isAppliedRunMessage(n.message)||!e(n.message))return t;t.push(n.message),this.runtimeResults.shift()}return[...t,...takeLeadingAppliedRunMessages(this.input.inbox,e)]}async nextRuntimeEvent(e){for(;;){let t=await this.routeAdmittedToChildren();if(this.signal.aborted)return`cancelled`;if(t)return{kind:`steering`};let n=this.runtimeResults.shift();if(n!==void 0)return n;let r=await this.waitForInboxOrTimer(e);if(r!==void 0)return{callId:r,kind:`timeout`};let i=await this.input.inbox.next();if(i===void 0)throw Error(`Session inbox closed before runtime actions completed.`);if(await this.admit(i))return{kind:`input`}}}async takeAnswers(e){for(let t of this.admitted){let n=this.input.queue.delivery(t);if(n===void 0)continue;let r=n.payloads.flatMap(e=>e.answers??[]);if(r.length===0)continue;if(!r.some(t=>e.has(t.interactionId))){if(this.mappedForHeldRequest.has(t))continue;this.mappedForHeldRequest.add(t);let r=n,i=await this.input.cursor.advance(t=>mapHeldAnswersStep({delivery:r,requestIds:[...e],...t}));if(i.delivery===void 0)continue;n=i.delivery}this.admitted.delete(t);let i=isSteeringDelivery(n,this.identity,{heldOnPerson:!0})?void 0:splitAnswers(n);return this.input.queue.replaceDelivery(t,i?.rest),i?.answers??n}}async waitForInboxOrTimer(e){if(e.length===0||this.input.inbox.hasPending())return;let t=this.input.inbox.whenPending().then(()=>void 0);return await Promise.race([t,...e])}cancelsThisTurn(e){return e.kind===`reset`||e.kind===`session-failure`?!0:this.#t?!1:e.kind===`clear`?!0:e.kind===`cancel`?e.turnId===void 0||e.turnId===this.expectedTurnId:!1}async admit(e,t=!1){let n=await admitSessionInboxPayload(e,this.input);switch(n.kind){case`delivery`:return this.admitted.add(n.admission.sequence),!0;case`runtime-action-result`:return this.runtimeResults.push({kind:`runtime-action-result`,results:n.payload.results}),!1;case`workflow`:return this.runtimeResults.push({kind:`workflow`,message:n.message}),!1;case`cancel`:if((!t||e.kind!==`cancel`)&&this.cancelsThisTurn(e)&&this.#e===void 0)this.#e??=n.origin,this.abort();else if(n.origin!==void 0){let e=controlDeliveryOf(n.origin);await this.input.cursor.advance(t=>settleControlDeliveryStep({...t,settlement:{control:e,outcome:`ignored`,source:`cancel`}}))}return!1;case`unsupported`:{let{settlement:e}=n;return await this.input.cursor.advance(t=>settleControlDeliveryStep({...t,settlement:e})),!1}case`consumed`:return e.kind===`authorization-callback`}}async routeAdmittedToChildren(){let e=!1;for(let t of this.admitted){if(this.routedToChildren.has(t))continue;let n=this.input.queue.delivery(t);if(n===void 0){this.admitted.delete(t);continue}this.routedToChildren.add(t);let r=await this.input.cursor.advance(e=>routeDeliverToChildren({delivery:n,...e}));if(r.kind===`cancel-turn`)return this.input.queue.replaceDelivery(t,void 0),this.admitted.delete(t),this.abort(),!1;if(this.input.queue.replaceDelivery(t,r.remainder),r.remainder===void 0){this.admitted.delete(t);continue}isSteeringMessage(r.remainder,this.identity)&&(e=!0)}return e}get cancelledBy(){return this.#e}abort(){this.controller.signal.aborted||this.controller.abort(new TurnCancelledError)}};function asBoundaryMessage(e){if(e!==`cancelled`&&e.kind===`workflow`&&(e.message.from.taskId!==void 0||isAgentSessionMessage(e.message)))return e.message}function splitAnswers(e){let t=e.payloads.flatMap((e,t)=>e.answers===void 0?[]:[{index:t,payload:{answers:e.answers}}]),n=e.payloads.flatMap((e,t)=>{if(e.message===void 0)return[];let{answers:n,...r}=e;return[{index:t,payload:r}]}),r=selectDeliveryPayloads(e,t),i=new Set(n.map(({index:e})=>e));return{answers:{...r,deliveryMetadata:r.deliveryMetadata?.map(e=>({...e,deliveryId:i.has(t[e.payloadIndex].index)?answersDeliveryId(e.deliveryId):e.deliveryId}))},rest:n.length===0?void 0:selectDeliveryPayloads(e,n)}}export{ActiveTurn};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SessionStateCursor } from "#execution/session/state-cursor.js";
|
|
2
2
|
import type { RuntimeActionResultHookPayload, SessionControlIdentity } from "#channel/types.js";
|
|
3
|
+
import type { ControlSettlement } from "#harness/facts.js";
|
|
3
4
|
import type { ControlOrigin, DeliveryAdmission, SessionInputQueue } from "#execution/session/input-queue.js";
|
|
4
5
|
import { type SessionInboxPayload } from "#execution/session-inbox/inbox.js";
|
|
5
6
|
import type { WorkflowToolRunMessage } from "#execution/tools/workflow/messages.js";
|
|
@@ -12,6 +13,11 @@ type SessionAdmission = {
|
|
|
12
13
|
readonly origin?: ControlOrigin;
|
|
13
14
|
} | {
|
|
14
15
|
readonly kind: "consumed";
|
|
16
|
+
}
|
|
17
|
+
/** A control this owner cannot run: settle it failed, so its sender doesn't wait forever. */
|
|
18
|
+
| {
|
|
19
|
+
readonly kind: "unsupported";
|
|
20
|
+
readonly settlement: ControlSettlement;
|
|
15
21
|
} | {
|
|
16
22
|
readonly kind: "runtime-action-result";
|
|
17
23
|
readonly payload: RuntimeActionResultHookPayload;
|