eve 0.72.1 → 0.74.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 +44 -0
- package/dist/src/_virtual/_rolldown/runtime.js +1 -1
- package/dist/src/channel/agent-description.d.ts +49 -9
- package/dist/src/channel/agent-description.js +1 -1
- package/dist/src/channel/invoke-tool.d.ts +26 -4
- package/dist/src/channel/invoke-tool.js +1 -1
- package/dist/src/channel/principal-identity.d.ts +9 -0
- package/dist/src/channel/principal-identity.js +1 -0
- package/dist/src/channel/prompt-queue.d.ts +31 -0
- package/dist/src/channel/prompt-queue.js +1 -0
- package/dist/src/channel/routes.d.ts +19 -4
- package/dist/src/channel/schedule.d.ts +20 -6
- package/dist/src/channel/schedule.js +1 -1
- package/dist/src/channel/skill-files.d.ts +114 -0
- package/dist/src/channel/skill-files.js +1 -0
- package/dist/src/channel/types.d.ts +4 -0
- package/dist/src/chunks/{use-eve-agent-C1GYGCtb.js → use-eve-agent-DOOXadF0.js} +13 -3
- package/dist/src/chunks/{use-eve-agent-hZJ7CB8t.js → use-eve-agent-mP0M7SrL.js} +13 -3
- package/dist/src/cli/commands/agent-instructions.js +1 -1
- package/dist/src/cli/commands/extension-init.js +1 -1
- package/dist/src/cli/commands/init-agent-workspace.js +1 -1
- package/dist/src/cli/commands/init-project.js +1 -1
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/diagnostic-dump.js +1 -1
- package/dist/src/cli/dev/tui/blocks.d.ts +6 -0
- package/dist/src/cli/dev/tui/blocks.js +2 -2
- package/dist/src/cli/dev/tui/markdown.d.ts +5 -0
- package/dist/src/cli/dev/tui/markdown.js +2 -2
- package/dist/src/cli/dev/tui/stream-format.js +2 -2
- package/dist/src/cli/dev/tui/transcript-parts.d.ts +4 -1
- package/dist/src/cli/dev/tui/transcript-parts.js +2 -2
- package/dist/src/cli/dev/tui/transcript.js +1 -1
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +9 -8
- package/dist/src/compiled/@eve/catalog/index.js +1 -1
- package/dist/src/compiled/@modelcontextprotocol/server/index.d.ts +68 -7
- package/dist/src/compiled/@vercel/schedules/index.d.ts +158 -0
- package/dist/src/compiled/@vercel/schedules/index.js +17 -0
- package/dist/src/compiled/@workflow/core/capabilities.d.ts +33 -6
- package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/index.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +6 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +8 -8
- package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +13 -5
- package/dist/src/compiled/@workflow/core/serialization.d.ts +9 -9
- package/dist/src/compiled/@workflow/core/serialization.js +1 -1
- package/dist/src/compiled/@workflow/core/symbols.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/index.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/events.d.ts +11 -0
- package/dist/src/compiled/@workflow/world/hooks.d.ts +2 -0
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +6 -0
- package/dist/src/compiled/@workflow/world-local/index.js +3 -3
- package/dist/src/compiled/@workflow/world-vercel/index.js +13 -13
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-VaTKT4K8.js → attribute-changes-CSqvJx6j.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{dist-B7NC1c9-.js → dist-DmXynLVH.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/dist-T5NnW-0k.js +3 -0
- package/dist/src/compiled/_chunks/workflow/helpers-BXCuoPUb.js +1 -0
- package/dist/src/compiled/_chunks/workflow/private-Dlf90Zvn.js +1 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-CvENCrxc.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{run-DYKeqbob.js → run-8pLWuR2U.js} +6 -6
- package/dist/src/compiled/_chunks/workflow/serialization-vDozzDhh.js +16 -0
- package/dist/src/compiled/_chunks/workflow/sleep-BMqbraZM.js +1 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-A344L2AG.js +1 -0
- package/dist/src/compiled/shadcn-registry/index.js +3408 -35163
- package/dist/src/compiler/artifacts.js +1 -1
- package/dist/src/compiler/compile-agent.js +1 -1
- package/dist/src/compiler/development-extensions.js +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/load-binding-namespace.d.ts +5 -0
- package/dist/src/compiler/load-binding-namespace.js +1 -1
- package/dist/src/compiler/manifest.d.ts +39 -0
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/memory-wrapper-candidates.d.ts +2 -0
- package/dist/src/compiler/memory-wrapper-candidates.js +1 -0
- package/dist/src/compiler/module-lifecycle.d.ts +1 -1
- package/dist/src/compiler/module-lifecycle.js +1 -1
- package/dist/src/compiler/module-map.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-schedule-collection.d.ts +3 -0
- package/dist/src/compiler/normalize-schedule-collection.js +1 -0
- package/dist/src/compiler/normalize-schedule.d.ts +2 -2
- package/dist/src/compiler/normalize-schedule.js +1 -1
- package/dist/src/compiler/resolve-workspace-subagent.js +1 -1
- package/dist/src/compiler/schedule-collection-wrapper-candidates.d.ts +2 -0
- package/dist/src/compiler/schedule-collection-wrapper-candidates.js +1 -0
- package/dist/src/compiler/validate-artifact.js +1 -1
- package/dist/src/context/build-callback-context.js +1 -1
- package/dist/src/context/dynamic-resolve-context.js +1 -1
- package/dist/src/context/key-names.d.ts +1 -0
- package/dist/src/context/key-names.js +1 -1
- package/dist/src/context/keys.d.ts +2 -0
- package/dist/src/context/keys.js +1 -1
- package/dist/src/context/providers/session.js +1 -1
- package/dist/src/context/schedule-collection-tools.d.ts +9 -0
- package/dist/src/context/schedule-collection-tools.js +1 -0
- package/dist/src/context/session-context.d.ts +4 -1
- package/dist/src/context/session-schedule.d.ts +9 -0
- package/dist/src/context/session-schedule.js +1 -0
- package/dist/src/context/turn-principals.d.ts +12 -0
- package/dist/src/context/turn-principals.js +1 -0
- package/dist/src/dynamic/definition.d.ts +1 -0
- package/dist/src/evals/cli/eval-client.js +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/agent-sessions/context.d.ts +2 -0
- package/dist/src/execution/agent-sessions/context.js +1 -1
- package/dist/src/execution/agent-sessions/steps.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/invoke-tool.d.ts +6 -2
- package/dist/src/execution/invoke-tool.js +1 -1
- package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
- package/dist/src/execution/node-step.d.ts +1 -0
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/publish-session-events.js +1 -1
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-errors.d.ts +11 -0
- package/dist/src/execution/sandbox/bindings/vercel-errors.js +2 -1
- package/dist/src/execution/sandbox/bindings/vercel-tool-sessions.d.ts +7 -0
- package/dist/src/execution/sandbox/bindings/vercel-tool-sessions.js +1 -0
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/sandbox/development-lazy-prewarm.js +1 -1
- package/dist/src/execution/sandbox/ensure.d.ts +14 -1
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/sandbox/prewarm.js +1 -1
- package/dist/src/execution/session/active-turn.d.ts +2 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/entry.d.ts +10 -1
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/program.d.ts +4 -0
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/timeout-control.d.ts +1 -2
- package/dist/src/execution/session/timeout-control.js +1 -1
- package/dist/src/execution/session/turn-control.d.ts +7 -0
- package/dist/src/execution/session/turn-control.js +1 -0
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn.d.ts +2 -0
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-inbox/protocol.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/tool-session/id.d.ts +22 -0
- package/dist/src/execution/tool-session/id.js +1 -0
- package/dist/src/execution/tool-session/sandbox.d.ts +22 -0
- package/dist/src/execution/tool-session/sandbox.js +1 -0
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/connection-tools.js +1 -1
- package/dist/src/framework/sources/modules/schedule-collection-wrapper.d.ts +2 -0
- package/dist/src/framework/sources/modules/schedule-collection-wrapper.js +1 -0
- package/dist/src/framework/sources/registry.d.ts +1 -0
- package/dist/src/framework/sources/registry.js +1 -1
- package/dist/src/harness/compaction/step.js +1 -1
- package/dist/src/harness/emission.d.ts +1 -0
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/hitl/approvals.d.ts +1 -1
- package/dist/src/harness/hitl/approvals.js +1 -1
- package/dist/src/harness/hitl/delivery.d.ts +9 -2
- package/dist/src/harness/hitl/delivery.js +1 -1
- package/dist/src/harness/hitl/intake.js +1 -1
- package/dist/src/harness/model-call/call.d.ts +5 -0
- package/dist/src/harness/model-call/call.js +1 -1
- package/dist/src/harness/model-call/usage.js +1 -1
- package/dist/src/harness/open-input-request.d.ts +8 -0
- package/dist/src/harness/open-input-request.js +1 -0
- package/dist/src/harness/session-machine/current.js +1 -1
- package/dist/src/harness/session-machine/transitions.d.ts +13 -0
- package/dist/src/harness/session-machine/transitions.js +1 -1
- package/dist/src/harness/stream-actions.d.ts +6 -1
- package/dist/src/harness/stream-actions.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/types.d.ts +2 -0
- package/dist/src/instrumentation/ai-sdk-hook-bridge.js +1 -1
- package/dist/src/instrumentation/lifecycle.d.ts +1 -0
- package/dist/src/internal/application/cache-metadata.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/application/runtime-compiled-artifacts-source.js +1 -1
- package/dist/src/internal/authored-definition/connection.js +1 -1
- package/dist/src/internal/authored-definition/schedule-collection.d.ts +2 -0
- package/dist/src/internal/authored-definition/schedule-collection.js +1 -0
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +7 -0
- package/dist/src/internal/authored-module-loader.js +2 -2
- package/dist/src/internal/authored-module-map-loader.js +1 -1
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/authored-runtime-modules.d.ts +1 -0
- package/dist/src/internal/authored-runtime-modules.js +1 -1
- package/dist/src/internal/invocation/metadata.js +1 -1
- package/dist/src/internal/mcp/forwarded-principal-header.d.ts +31 -0
- package/dist/src/internal/mcp/forwarded-principal-header.js +1 -0
- package/dist/src/internal/mcp/published-tools.d.ts +9 -2
- package/dist/src/internal/mcp/published-tools.js +1 -1
- package/dist/src/internal/mcp/skills.d.ts +57 -0
- package/dist/src/internal/mcp/skills.js +1 -0
- package/dist/src/internal/mcp/streamable-http-server.d.ts +38 -6
- package/dist/src/internal/mcp/streamable-http-server.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/development-generation.js +1 -1
- package/dist/src/internal/nitro/host/artifacts-config.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-extension.js +1 -1
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-runner.js +1 -1
- package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -1
- package/dist/src/internal/nitro/host/local-tracing-runtime-plugin.js +1 -1
- package/dist/src/internal/nitro/host/skill-server-assets.d.ts +29 -0
- package/dist/src/internal/nitro/host/skill-server-assets.js +1 -0
- package/dist/src/internal/nitro/host/start-production-server.js +1 -1
- package/dist/src/internal/nitro/host/vercel-build-output-config.d.ts +12 -0
- package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
- package/dist/src/internal/nitro/host/workspace-extensions.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-route-context.d.ts +4 -0
- package/dist/src/internal/nitro/routes/channel-route-context.js +1 -1
- package/dist/src/internal/nitro/routes/schedule-collection-consumer.d.ts +3 -0
- package/dist/src/internal/nitro/routes/schedule-collection-consumer.js +1 -0
- package/dist/src/internal/schedules/consumer-route.d.ts +17 -0
- package/dist/src/internal/schedules/consumer-route.js +1 -0
- package/dist/src/internal/schedules/verify-delivery.d.ts +25 -0
- package/dist/src/internal/schedules/verify-delivery.js +1 -0
- package/dist/src/internal/vercel/build-agent-workspace.js +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/internal/workflow/validate-world.js +1 -1
- package/dist/src/internal/workflow/vercel-world-defaults.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.js +1 -1
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/cli-config.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/cred-storage.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/index.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/schema.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/schema.zod.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-config@0.2.0/node_modules/@vercel/cli-config/dist/types.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/envpath.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/errors.js +2 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/errutils.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/exec.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/fsutils.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/index.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/lookup.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_cli-exec@1.0.0/node_modules/@vercel/cli-exec/dist/safety.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/auth-errors.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/exchange-vercel-oidc-token.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/get-context.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-sync.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token-with-refresh.js +2 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/index.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/oauth.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/token-error.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/token-io.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/token-util.js +2 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/token.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/verify-vercel-oidc-token.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_oidc@3.8.0/node_modules/@vercel/oidc/dist/version.js +1 -0
- package/dist/src/node_modules/.pnpm/@vercel_queue@0.5.1_@opentelemetry_api@1.9.1/node_modules/@vercel/queue/dist/index.js +36 -0
- package/dist/src/node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js +1 -0
- package/dist/src/node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js +1 -0
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js +1 -0
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js +1 -0
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js +1 -0
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js +1 -0
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js +1 -0
- package/dist/src/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js +1 -0
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js +1 -0
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/command.js +1 -0
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js +2 -0
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/kill.js +1 -0
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/promise.js +1 -0
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/stdio.js +1 -0
- package/dist/src/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/stream.js +1 -0
- package/dist/src/node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/buffer-stream.js +1 -0
- package/dist/src/node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/index.js +1 -0
- package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/core.js +1 -0
- package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/main.js +1 -0
- package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/realtime.js +1 -0
- package/dist/src/node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/signals.js +1 -0
- package/dist/src/node_modules/.pnpm/is-stream@2.0.1/node_modules/is-stream/index.js +1 -0
- package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js +1 -0
- package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js +1 -0
- package/dist/src/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/index.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/compact/decrypt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/compact/encrypt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/flattened/decrypt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/flattened/encrypt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/general/decrypt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwe/general/encrypt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwk/embedded.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwk/thumbprint.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwks/local.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwks/remote.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/compact/sign.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/compact/verify.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/flattened/sign.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/flattened/verify.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/general/sign.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jws/general/verify.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/decrypt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/encrypt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/produce.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/sign.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/unsecured.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/jwt/verify.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/export.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/generate_key_pair.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/generate_secret.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/key/import.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/aesgcmkw.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/buffer_utils.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/cek.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_iv_length.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_key_type.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/check_p2s.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/crypto_key.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/decrypt_key_management.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/encrypt_key_management.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/epoch.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/invalid_key_input.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_disjoint.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_jwk.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/is_object.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/iv.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/jwt_claims_set.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/private_symbols.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/secs.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/validate_algorithms.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/lib/validate_crit.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/aeskw.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/asn1.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/base64url.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/cbc_tag.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/check_cek_length.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/check_key_length.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/ciphers.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/decrypt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/digest.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/dsa_digest.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/ecdhes.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/encrypt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/fetch_jwks.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/generate.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/get_named_curve.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/get_sign_verify_key.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/hmac_digest.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/is_key_like.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/is_key_object.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/jwk_to_key.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/key_to_jwk.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/node_key.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/normalize_key.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/pbes2kw.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/random.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/rsaes.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/runtime.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/sign.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/timing_safe_equal.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/verify.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/runtime/webcrypto.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/base64url.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/decode_jwt.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/decode_protected_header.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/errors.js +1 -0
- package/dist/src/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/cjs/util/runtime.js +1 -0
- package/dist/src/node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js +1 -0
- package/dist/src/node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js +1 -0
- package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/assert-valid-pattern.js +1 -0
- package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/ast.js +1 -0
- package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js +1 -0
- package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js +1 -0
- package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/index.js +1 -0
- package/dist/src/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/unescape.js +1 -0
- package/dist/src/node_modules/.pnpm/mixpart@0.0.6/node_modules/mixpart/dist/index.js +7 -0
- package/dist/src/node_modules/.pnpm/npm-run-path@4.0.1/node_modules/npm-run-path/index.js +1 -0
- package/dist/src/node_modules/.pnpm/onetime@5.1.2/node_modules/onetime/index.js +1 -0
- package/dist/src/node_modules/.pnpm/os-paths@4.4.0/node_modules/os-paths/src/lib/index.js +1 -0
- package/dist/src/node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js +1 -0
- package/dist/src/node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js +1 -0
- package/dist/src/node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js +1 -0
- package/dist/src/node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js +1 -0
- package/dist/src/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js +1 -0
- package/dist/src/node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js +1 -0
- package/dist/src/node_modules/.pnpm/strip-final-newline@2.0.0/node_modules/strip-final-newline/index.js +2 -0
- package/dist/src/node_modules/.pnpm/which@2.0.2/node_modules/which/which.js +1 -0
- package/dist/src/node_modules/.pnpm/xdg-app-paths@5.5.1/node_modules/xdg-app-paths/src/lib/index.js +1 -0
- package/dist/src/node_modules/.pnpm/xdg-portable@7.3.0/node_modules/xdg-portable/src/lib/index.js +1 -0
- package/dist/src/public/channels/chat-sdk/authorization.js +1 -1
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +7 -1
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
- package/dist/src/public/channels/discord/defaults.d.ts +8 -7
- package/dist/src/public/channels/discord/discordChannel.d.ts +21 -1
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/discord/index.d.ts +1 -1
- package/dist/src/public/channels/github/defaults.js +3 -3
- package/dist/src/public/channels/github/githubChannel.d.ts +4 -1
- package/dist/src/public/channels/github/state.d.ts +2 -1
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/channels/linear/defaults.js +1 -1
- package/dist/src/public/channels/linear/linearChannel.d.ts +4 -1
- package/dist/src/public/channels/mcp.d.ts +26 -5
- package/dist/src/public/channels/mcp.js +1 -1
- package/dist/src/public/channels/slack/index.d.ts +1 -0
- package/dist/src/public/channels/slack/index.js +1 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +6 -0
- package/dist/src/public/channels/twilio/defaults.js +2 -4
- package/dist/src/public/channels/twilio/twilioChannel.d.ts +4 -1
- package/dist/src/public/definitions/channel.d.ts +1 -1
- package/dist/src/public/definitions/connections/mcp.d.ts +11 -0
- package/dist/src/public/experimental/schedules/client.d.ts +7 -0
- package/dist/src/public/experimental/schedules/client.js +1 -0
- package/dist/src/public/experimental/schedules/index.d.ts +5 -0
- package/dist/src/public/experimental/schedules/index.js +1 -0
- package/dist/src/public/experimental/schedules/testing.d.ts +2 -0
- package/dist/src/public/experimental/schedules/testing.js +1 -0
- package/dist/src/public/experimental/schedules/vercel.d.ts +2 -0
- package/dist/src/public/experimental/schedules/vercel.js +1 -0
- package/dist/src/public/memory/scope.js +1 -1
- package/dist/src/public/schedules/provider-types.d.ts +16 -0
- package/dist/src/public/schedules/provider-types.js +1 -0
- package/dist/src/public/schedules/providers/in-memory.d.ts +5 -0
- package/dist/src/public/schedules/providers/in-memory.js +1 -0
- package/dist/src/public/schedules/providers/vercel.d.ts +10 -0
- package/dist/src/public/schedules/providers/vercel.js +1 -0
- package/dist/src/public/schedules/scope.d.ts +2 -0
- package/dist/src/public/schedules/scope.js +1 -0
- package/dist/src/public/schedules/subscription.d.ts +259 -0
- package/dist/src/public/schedules/subscription.js +1 -0
- package/dist/src/public/schedules/testing.d.ts +1 -0
- package/dist/src/public/schedules/testing.js +1 -0
- package/dist/src/public/sveltekit/dev-server.js +1 -1
- package/dist/src/runtime/cache-key.js +1 -1
- package/dist/src/runtime/connections/mcp-client.js +1 -1
- package/dist/src/runtime/loaders/compile-metadata.js +1 -1
- package/dist/src/runtime/loaders/manifest.js +1 -1
- package/dist/src/runtime/loaders/module-map.js +1 -1
- package/dist/src/runtime/resolve-connection.js +1 -1
- package/dist/src/runtime/sandbox/prepared-artifacts.js +1 -1
- package/dist/src/runtime/schedules/collection-client.d.ts +20 -0
- package/dist/src/runtime/schedules/collection-client.js +1 -0
- package/dist/src/runtime/schedules/dispatch-occurrence.d.ts +12 -0
- package/dist/src/runtime/schedules/dispatch-occurrence.js +1 -0
- package/dist/src/runtime/schedules/load-collection.d.ts +14 -0
- package/dist/src/runtime/schedules/load-collection.js +1 -0
- package/dist/src/runtime/schedules/payload.d.ts +24 -0
- package/dist/src/runtime/schedules/payload.js +1 -0
- package/dist/src/runtime/schedules/provider-types.d.ts +1 -0
- package/dist/src/runtime/schedules/provider-types.js +1 -0
- package/dist/src/runtime/schedules/queue-namespace.d.ts +2 -0
- package/dist/src/runtime/schedules/queue-namespace.js +1 -0
- package/dist/src/runtime/schedules/record.d.ts +4 -0
- package/dist/src/runtime/schedules/record.js +1 -0
- package/dist/src/runtime/schedules/validation.d.ts +6 -0
- package/dist/src/runtime/schedules/validation.js +1 -0
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/runtime/sessions/runtime-context-keys.js +1 -1
- package/dist/src/runtime/sessions/runtime-session.d.ts +10 -0
- package/dist/src/runtime/sessions/runtime-session.js +1 -1
- package/dist/src/runtime/types.d.ts +2 -0
- package/dist/src/self-modification/config.d.ts +4 -63
- package/dist/src/self-modification/config.js +1 -1
- package/dist/src/self-modification/credentials.d.ts +1 -1
- package/dist/src/self-modification/deployed-sandbox.d.ts +14 -0
- package/dist/src/self-modification/deployed-sandbox.js +1 -0
- package/dist/src/self-modification/extension/config-schema.d.ts +2 -17
- package/dist/src/self-modification/extension/config-schema.js +1 -1
- package/dist/src/self-modification/extension/local-only.d.ts +1 -1
- package/dist/src/self-modification/extension/local-only.js +1 -1
- package/dist/src/self-modification/extension/subagents/agent/agent.d.ts +1 -1
- package/dist/src/self-modification/extension/subagents/agent/agent.js +1 -1
- package/dist/src/self-modification/extension/subagents/agent/instructions.js +3 -35
- package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.d.ts +3 -31
- package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.js +1 -1
- package/dist/src/self-modification/git-workspace.d.ts +1 -2
- package/dist/src/self-modification/git-workspace.js +1 -1
- package/dist/src/self-modification/github-publisher.d.ts +1 -1
- package/dist/src/self-modification/mode.d.ts +4 -4
- package/dist/src/self-modification/mode.js +1 -1
- package/dist/src/self-modification/proposal.js +1 -1
- package/dist/src/self-modification/remote/config-schema.d.ts +20 -0
- package/dist/src/self-modification/remote/config-schema.js +1 -0
- package/dist/src/self-modification/remote/config.d.ts +66 -0
- package/dist/src/self-modification/remote/config.js +1 -0
- package/dist/src/self-modification/remote/extension.d.ts +5 -0
- package/dist/src/self-modification/remote/extension.js +1 -0
- package/dist/src/self-modification/remote/production-registry-add.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/agent.d.ts +4 -0
- package/dist/src/self-modification/remote/subagents/agent/agent.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/instructions.d.ts +2 -0
- package/dist/src/self-modification/remote/subagents/agent/instructions.js +5 -0
- package/dist/src/self-modification/remote/subagents/agent/sandbox.d.ts +2 -0
- package/dist/src/self-modification/remote/subagents/agent/sandbox.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/edit_file.d.ts +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/edit_file.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/publish.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/registry_add.d.ts +32 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/registry_add.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/search_models.d.ts +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/search_models.js +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/search_registry.d.ts +1 -0
- package/dist/src/self-modification/remote/subagents/agent/tools/search_registry.js +1 -0
- package/dist/src/self-modification/sandbox.d.ts +1 -6
- package/dist/src/self-modification/sandbox.js +1 -1
- package/dist/src/self-modification/scaffold.js +1 -1
- package/dist/src/self-modification/setup.d.ts +6 -0
- package/dist/src/self-modification/setup.js +46 -48
- package/dist/src/self-modification/subagent-guidance.d.ts +15 -0
- package/dist/src/self-modification/subagent-guidance.js +29 -0
- package/dist/src/services/dev-client/request-headers.js +1 -1
- package/dist/src/setup/flows/model-source-change.js +1 -1
- package/dist/src/setup/integrations/self-modification/setup.js +1 -1
- package/dist/src/setup/project-resolution.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/verified-remote-client.d.ts +3 -0
- package/dist/src/setup/verified-remote-client.js +1 -1
- package/dist/src/shared/framework-eve-server.js +1 -1
- package/dist/src/shared/principal-scope.d.ts +2 -0
- package/dist/src/shared/principal-scope.js +1 -0
- package/dist/src/shared/schedule-collection-definition.d.ts +11 -0
- package/dist/src/shared/schedule-collection-definition.js +1 -0
- package/dist/src/shared/schedule-collection-tools.d.ts +1 -0
- package/dist/src/shared/schedule-collection-tools.js +1 -0
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/subagents/tool.d.ts +1 -0
- package/dist/src/subagents/tool.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/framework/agent.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/read-file.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tracing/agent-otel-content.d.ts +2 -0
- package/dist/src/tracing/agent-otel-content.js +2 -2
- package/dist/src/tracing/agent-otel-provider.js +1 -1
- package/dist/src/tracing/invoke-tool-span.d.ts +1 -0
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/chat-sdk.mdx +27 -0
- package/docs/channels/custom.mdx +5 -2
- package/docs/channels/discord.mdx +22 -0
- package/docs/channels/mcp.mdx +102 -4
- package/docs/channels/slack.mdx +1 -1
- package/docs/connections/mcp.mdx +19 -0
- package/docs/evals/targets.mdx +5 -1
- package/docs/guides/self-modification.md +50 -3
- package/docs/tools/human-in-the-loop.md +14 -2
- package/docs/tools/workflows.mdx +6 -4
- package/docs/tutorial/guard-the-spend.mdx +1 -1
- package/package.json +46 -8
- package/dist/src/compiled/@workflow/core/runtime/vm-serde-bundle.generated.d.ts +0 -14
- package/dist/src/compiled/_chunks/workflow/dist-CaNNONeg.js +0 -3
- package/dist/src/compiled/_chunks/workflow/global-DKbOgrts.js +0 -1
- package/dist/src/compiled/_chunks/workflow/helpers-CP9TjeO8.js +0 -1
- package/dist/src/compiled/_chunks/workflow/logger-oqfblE3p.js +0 -14
- package/dist/src/compiled/_chunks/workflow/resume-hook-yq-NAdBu.js +0 -1
- package/dist/src/compiled/_chunks/workflow/serialization-APSKphN5.js +0 -3
- package/dist/src/compiled/_chunks/workflow/sleep-Ba8SExMt.js +0 -1
- package/dist/src/compiled/_chunks/workflow/wait-until-Dc9s3yyP.js +0 -1
- package/dist/src/self-modification/extension/production-registry-add.js +0 -1
- package/dist/src/self-modification/extension/subagents/agent/tools/publish.js +0 -1
- /package/dist/src/self-modification/{extension → remote}/production-registry-add.d.ts +0 -0
- /package/dist/src/self-modification/{extension → remote}/subagents/agent/tools/publish.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import"#protocol/session-projection.js";import{createLogger}from"#internal/logging.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{AuthKey,InitiatorAuthKey,ParentSessionKey,SessionKey,TurnDeliveryIdsKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{validateHarnessModelMessages}from"#harness/messages.js";import{activeTurnId,turnPosition}from"#harness/session-machine/view.js";import{
|
|
1
|
+
import"#protocol/session-projection.js";import{createLogger}from"#internal/logging.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{currentProjection,enterSessionProjection,recordPublishedEvent,saveSessionProjection}from"#harness/session-machine/current.js";import{AuthKey,InitiatorAuthKey,ParentSessionKey,SessionKey,TurnDeliveryIdsKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{validateHarnessModelMessages}from"#harness/messages.js";import{activeTurnId,turnPosition}from"#harness/session-machine/view.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{dropClosedRecords}from"#harness/session-machine/commit.js";import{setChannelContext}from"#execution/channel-context.js";import{dispatchStreamEventHooks}from"#context/hook-lifecycle.js";import{withContextScope}from"#context/run-step.js";import{forwardSessionInput}from"#execution/forward-session-input.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{bindSessionInstrumentation}from"#instrumentation/runtime.js";const log=createLogger(`execution.publish-session-events`);async function publishSessionEvents(e,t){return await publishEventsFromStep(e,`own`,t)}async function relaySessionEvents(e,t){return await publishEventsFromStep(e,`relayed`,t)}async function publishEventsFromStep(e,t,n){if(n.length===0)return{serializedContext:e.serializedContext,sessionState:e.sessionState};let{published:r}=await publishFromSessionStep(await restoreSessionStep(e),{origin:t,async publish(e){for(let t of n)await e(t)}});return r}async function restoreSessionStep(e){return{ctx:await deserializeContext(e.serializedContext),durableSession:readDurableSession(e.sessionState),sessionWritable:e.sessionWritable}}async function publishFromSessionStep(e,t){let{ctx:n}=e,r=await publishInSessionScope(e,t),i=t.updateSession?.(r.session,r.result)??{session:r.session},a=readSessionProjection(n),o=reconcileSessionContinuationToken(n,saveSessionProjection(dropClosedRecords(i.session,a),n));return{published:{serializedContext:serializeContext(n),sessionState:createDurableSessionState({session:o}),...`history`in o&&{history:o.history}},result:i.result}}async function publishInSessionScope(e,t){let{ctx:n}=e;enterSessionProjection(n,e.durableSession.state);let r=resolveEffectiveAgentRuntime(n.require(BundleKey),n),i=hydrateDurableSession({compactionOverrides:{thresholdPercent:r.thresholdPercent},durable:e.durableSession,turnAgent:r.turnAgent}),a=e.history===void 0?i:{...i,history:validateHarnessModelMessages(e.history)},o=t.origin===`own`?bindSessionInstrumentation({agentName:r.turnAgent.id,ctx:n,rootSessionId:a.rootSessionId??a.sessionId,sessionId:a.sessionId}):void 0,s=openSessionEventPublisher({ctx:n,inputSource:t.inputSource,origin:t.origin,sessionWritable:e.sessionWritable});try{return await withContextScope(n,a,async e=>{let r=o?.createHandleEvent({handleEvent:s.publish,turnId:activeTurnId(turnPosition(readSessionProjection(n)))})??s.publish;return{result:await t.publish(r,e),session:e}})}finally{await o?.flush(),s.writer.release()}}function openSessionEventPublisher(e){let{ctx:t,origin:n}=e,r=createSessionEventDispatcher(e),i=openSessionEventWriter({deliveryIds:()=>n===`own`?t.get(TurnDeliveryIdsKey):void 0,sessionWritable:e.sessionWritable}),emit=async e=>{let n=await i.write(await r.deliver(e));return recordPublishedEvent(t,n),n};return{dispatcher:r,writer:i,emit,async publish(e){await r.runHooks(await emit(e))}}}function createSessionEventDispatcher(e){let{ctx:t,inputSource:n}=e,r=t.require(ChannelKey),i=buildAdapterContext(r,t);return{adapterCtx:i,async deliver(e){let a=await forwardSessionInput(t,e,n)?e:await callAdapterEventHandler(r,e,n===void 0?i:{...i,inputSource:n});return setChannelContext(t,{...r,state:{...i.state}}),a},async runHooks(e,n){await dispatchStreamEventHooks({cancelTurn:n,ctx:t,event:e,registry:t.require(BundleKey).hookRegistry})}}}function openSessionEventWriter(e){let t=e.sessionWritable.getWriter(),n=!1,release=()=>{n||(n=!0,t.releaseLock())};return{async write(n){let r=stampMessageStreamEvent(n,e.deliveryIds());return await t.write(encodeMessageStreamEvent(r)),r},close:async()=>{await t.close(),release()},release}}function readSessionProjection(e){return currentProjection(e)}async function publishTerminalSessionEvent(e){let t=e.serializedContext[`eve.sessionId`]??``,n={errorId:e.errorId,sessionId:t},{type:r}=e.event,i,a;try{i=await deserializeContext(e.serializedContext),enterSessionProjection(i,void 0),a=openSessionEventPublisher({ctx:i,origin:`own`,sessionWritable:e.sessionWritable})}catch(t){log.error(`failed to restore context for terminal ${r} event`,{...n,error:t}),await writeUnroutedSessionEvent(e.sessionWritable,e.event).catch(e=>log.error(`failed to write terminal ${r} event`,{...n,error:e}));return}let o=i.get(AuthKey)??null;i.setVirtualContext(SessionKey,{auth:{current:o,initiator:i.get(InitiatorAuthKey)??o},parent:i.get(ParentSessionKey),sessionId:t,turn:e.turn??{id:`turn_0`,sequence:0}});let publish=async e=>{await a.emit(e),await a.writer.close()},s;try{s=bindSessionInstrumentation({agentName:i.require(BundleKey).turnAgent.id,ctx:i,rootSessionId:i.get(ParentSessionKey)?.rootSessionId??t,sessionId:t})}catch(e){log.error(`failed to bind instrumentation for terminal ${r} event`,{...n,error:e})}let c=s?.createHandleEvent({handleEvent:publish,turnId:e.turnId})??publish;try{await contextStorage.run(i,()=>c(e.event))}catch(e){log.error(`failed to publish terminal ${r} event`,{...n,error:e})}finally{a.writer.release();try{await s?.flush()}catch(e){log.error(`failed to flush instrumentation after terminal ${r} event`,{...n,error:e})}}}async function writeUnroutedSessionEvent(e,t){let n=openSessionEventWriter({deliveryIds:()=>void 0,sessionWritable:e});try{await n.write(t),await n.close()}finally{n.release()}}export{openSessionEventPublisher,publishFromSessionStep,publishSessionEvents,publishTerminalSessionEvent,readSessionProjection,relaySessionEvents,restoreSessionStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ConversationContextKey}from"#shared/conversation-context.js";import{ContextContainer,contextStorage}from"#context/container.js";import{AuthKey,CapabilitiesKey,ChannelDeliveryKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationHookTokensKey,ContinuationTokenKey,ConversationIdKey,DynamicSubagentAgentConfigKey,InitiatorAuthKey,LegacyRemoteAgentCallerKey,ParentSessionKey,ParentTraceContextKey,ScheduleIdKey,SessionCallbackKey,SessionTitleKey,TraceRootKey}from"#context/keys.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{resolveInstrumentationEnvironment}from"#internal/application/dev-environment.js";import{readConversationId}from"#shared/conversation-identity.js";import{setChannelContext}from"#execution/channel-context.js";import{deriveSessionTitle}from"#execution/eve-workflow-attributes.js";import{buildConversationContext}from"#channel/conversation-context.js";function buildRunContext(e){let{bundle:t,run:n}=e,r=new ContextContainer,i=n.auth,a=readConversationId(n.conversationId);if(a!==void 0&&r.set(ConversationIdKey,a),r.set(BundleKey,t),setChannelContext(r,n.adapter,{channelName:n.channelName}),r.set(ConversationContextKey,buildConversationContext(n,resolveInstrumentationEnvironment())),n.parent===void 0||n.traceRoot?.kind===`own`){let e=deriveSessionTitle(n.title??n.input.message);e!==void 0&&r.set(SessionTitleKey,e)}if(n.channelMetadata!==void 0){let e=r.get(ChannelInstrumentationKey);r.set(ChannelInstrumentationKey,{channelType:e?.channelType??n.channelMetadata.channelType,kind:e?.kind??n.channelMetadata.kind,metadata:n.channelMetadata.metadata})}n.continuationToken!==void 0&&(r.set(ContinuationTokenKey,n.continuationToken),r.set(ContinuationHookTokensKey,[n.continuationToken])),r.set(AuthKey,i),(n.initiatorAuth!==void 0||n.input.message!==void 0)&&r.set(InitiatorAuthKey,n.initiatorAuth??i),e.dynamicSubagentAgentConfig!==void 0&&r.set(DynamicSubagentAgentConfigKey,e.dynamicSubagentAgentConfig),n.capabilities!==void 0&&r.set(CapabilitiesKey,n.capabilities),n.requestId!==void 0&&r.set(ChannelRequestIdKey,n.requestId);let
|
|
1
|
+
import{ConversationContextKey}from"#shared/conversation-context.js";import{ContextContainer,contextStorage}from"#context/container.js";import{AuthKey,CapabilitiesKey,ChannelDeliveryKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationHookTokensKey,ContinuationTokenKey,ConversationIdKey,DynamicSubagentAgentConfigKey,InitiatorAuthKey,LegacyRemoteAgentCallerKey,OccurrenceIdKey,ParentSessionKey,ParentTraceContextKey,ScheduleIdKey,ScheduleInstanceKey,SessionCallbackKey,SessionTitleKey,TraceRootKey}from"#context/keys.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{resolveInstrumentationEnvironment}from"#internal/application/dev-environment.js";import{readConversationId}from"#shared/conversation-identity.js";import{setChannelContext}from"#execution/channel-context.js";import{deriveSessionTitle}from"#execution/eve-workflow-attributes.js";import{buildConversationContext}from"#channel/conversation-context.js";function buildRunContext(e){let{bundle:t,run:n}=e,r=new ContextContainer,i=n.auth,a=readConversationId(n.conversationId);if(a!==void 0&&r.set(ConversationIdKey,a),r.set(BundleKey,t),setChannelContext(r,n.adapter,{channelName:n.channelName}),r.set(ConversationContextKey,buildConversationContext(n,resolveInstrumentationEnvironment())),n.parent===void 0||n.traceRoot?.kind===`own`){let e=deriveSessionTitle(n.title??n.input.message);e!==void 0&&r.set(SessionTitleKey,e)}if(n.channelMetadata!==void 0){let e=r.get(ChannelInstrumentationKey);r.set(ChannelInstrumentationKey,{channelType:e?.channelType??n.channelMetadata.channelType,kind:e?.kind??n.channelMetadata.kind,metadata:n.channelMetadata.metadata})}n.continuationToken!==void 0&&(r.set(ContinuationTokenKey,n.continuationToken),r.set(ContinuationHookTokensKey,[n.continuationToken]));let o=n.schedule?.occurrenceId??contextStorage.getStore()?.get(OccurrenceIdKey);o!==void 0&&r.set(OccurrenceIdKey,o),r.set(AuthKey,i),(n.initiatorAuth!==void 0||n.input.message!==void 0)&&r.set(InitiatorAuthKey,n.initiatorAuth??i),e.dynamicSubagentAgentConfig!==void 0&&r.set(DynamicSubagentAgentConfigKey,e.dynamicSubagentAgentConfig),n.capabilities!==void 0&&r.set(CapabilitiesKey,n.capabilities),n.requestId!==void 0&&r.set(ChannelRequestIdKey,n.requestId);let s=n.schedule?.instance??contextStorage.getStore()?.get(ScheduleInstanceKey);s!==void 0&&r.set(ScheduleInstanceKey,s);let c=n.schedule?.definition??contextStorage.getStore()?.get(ScheduleIdKey);return c!==void 0&&r.set(ScheduleIdKey,c),n.delivery!==void 0&&r.set(ChannelDeliveryKey,n.delivery),n.callback!==void 0&&r.set(SessionCallbackKey,n.callback),n.legacyRemoteAgentCaller!==void 0&&r.set(LegacyRemoteAgentCallerKey,n.legacyRemoteAgentCaller),n.parent!==void 0&&r.set(ParentSessionKey,n.parent),n.traceRoot!==void 0&&r.set(TraceRootKey,n.traceRoot),n.parentTraceContext!==void 0&&r.set(ParentTraceContextKey,n.parentTraceContext),r}export{buildRunContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomUUID}from"node:crypto";import{mkdir,readdir,rename,rm,stat}from"node:fs/promises";import"node:fs";import{dirname,join}from"node:path";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{copyDirectoryAtomically,createFileBackedInternalSandboxSession,pathExists,resolveLocalProviderSessionRootPath,resolveLocalProviderTemplateRootPath,resolveLocalProviderTemplatesDirectory,touchDirectory,writeSandboxSeedFiles}from"#execution/sandbox/bindings/local-provider-utils.js";import{LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,selectStaleTemplateEntries}from"#execution/sandbox/bindings/local-template-prune.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{createSandboxProviderIdentity}from"#execution/sandbox/provider-identity.js";import{isSandboxPreparedArtifactRecord,providerResourceTargetFiles,sandboxProviderResourceIdentity}from"#shared/sandbox-provider.js";import{SandboxTemplateNotProvisionedError}from"#shared/sandbox-template-error.js";import{createBashSandbox,createJustBashHandle}from"#execution/sandbox/bindings/just-bash-runtime.js";const JUST_BASH_CACHE_DIRECTORY_NAME=`just-bash`,JUST_BASH_PROVIDER_NAME=`just-bash`;function createJustBashSandboxProvider(e=void 0){let t=e??{},n=t.autoInstall??!0,r={autoInstall:n,customCommands:t.customCommands,filesystem:t.filesystem,version:2};return{async prepare(e){let i=createSandboxProviderIdentity({...r,resources:sandboxProviderResourceIdentity(e.resources),sourceRevision:e.sourceRevision}).slice(0,24),a=resolveTemplateRootPath(e.storagePath,i);if(await pathExists(a))return await touchDirectory(a),e.log?.(`reusing cached template filesystem`),{templateRootPath:a};let o=`${a}.${randomUUID()}.tmp`,s=!1,c=await createBashSandbox({autoInstall:n,host:e.host,rootPath:o,sessionKey:`prepare-${i}`,storagePath:e.storagePath}),l=buildSandboxSession(createFileBackedInternalSandboxSession({sandbox:c}));try{await writeSandboxSeedFiles(l,providerResourceTargetFiles(e.resources)),t.prepare!==void 0&&(e.log?.(`running sandbox preparation`),await t.prepare(createLoggingSandboxSession({log:e.log,session:l}))),await c.captureState(),await mkdir(dirname(a),{recursive:!0});try{await rename(o,a),s=!0}catch(e){if(await pathExists(a))return{templateRootPath:a};throw e}}finally{await c.dispose(),s||await rm(o,{force:!0,recursive:!0})}return{templateRootPath:a}},async resume(e,n,r){let i=requirePreparedJustBashArtifact(n),a=requireJustBashSessionState(r),o=createSandboxProviderIdentity({artifact:i,version:1}),s=sessionRootPath(e,i);if(a.generation!==o||a.rootPath!==s)throw Error(`just-bash session state is incompatible with this environment.`);if(!await pathExists(a.rootPath))throw Error(`just-bash session root "${a.rootPath}" no longer exists.`);return await openHandle(e,a.rootPath,t)},async start(e,n,r){let i=requirePreparedJustBashArtifact(r),a=sessionRootPath(e,i);return await ensureSessionRoot(i,a),{handle:await openHandle(e,a,t),state:{generation:createSandboxProviderIdentity({artifact:i,version:1}),rootPath:a,version:2}}}}}function sessionRootPath(e,t){return resolveSessionRootPath(e.storagePath,createSandboxProviderIdentity({artifact:t,sessionId:e.session.id,version:1}).slice(0,24))}async function ensureSessionRoot(e,t){if(!await pathExists(t)){if(!await pathExists(e.templateRootPath))throw new SandboxTemplateNotProvisionedError({providerName:JUST_BASH_PROVIDER_NAME,templateKey:e.templateRootPath});await copyDirectoryAtomically(e.templateRootPath,t)}}async function openHandle(e,t,n){let r=await createBashSandbox({autoInstall:n.autoInstall??!0,customCommands:n.customCommands,filesystem:n.filesystem,host:e.host,rootPath:t,sessionKey:e.session.id,storagePath:e.storagePath});return createJustBashHandle(r)}async function pruneJustBashSandboxTemplates(e){let t=resolveLocalProviderTemplatesDirectory(resolveSandboxCacheDirectory(e.appRoot),JUST_BASH_CACHE_DIRECTORY_NAME),n=e.now??Date.now(),r=e.recentWindowMs??LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,i=e.retainCount??LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,a;try{a=await readdir(t,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let o=await Promise.all(a.filter(e=>e.isDirectory()).map(async e=>{let n=join(t,e.name);return{isTemporary:e.name.endsWith(`.tmp`),mtimeMs:(await stat(n)).mtimeMs,path:n}})),s=selectStaleTemplateEntries(o.filter(e=>!e.isTemporary),{now:n,recentWindowMs:r,retainCount:i}),c=selectStaleTemplateEntries(o.filter(e=>e.isTemporary),{now:n,recentWindowMs:r,retainCount:0});await Promise.all([...s,...c].map(async e=>await rm(e.path,{force:!0,recursive:!0})))}function requirePreparedJustBashArtifact(e){if(!isSandboxPreparedArtifactRecord(e)||typeof e.templateRootPath!=`string`)throw Error(`Invalid prepared just-bash artifact.`);return{templateRootPath:e.templateRootPath}}function requireJustBashSessionState(e){if(!isSandboxPreparedArtifactRecord(e)||e.version!==2||typeof e.generation!=`string`||typeof e.rootPath!=`string`)throw Error(`Invalid just-bash session state.`);return{generation:e.generation,rootPath:e.rootPath,version:2}}function resolveTemplateRootPath(e,t){return resolveLocalProviderTemplateRootPath(e,JUST_BASH_CACHE_DIRECTORY_NAME,t)}function resolveSessionRootPath(e,t){return resolveLocalProviderSessionRootPath(e,JUST_BASH_CACHE_DIRECTORY_NAME,t)}export{JUST_BASH_PROVIDER_NAME,createJustBashSandboxProvider,pruneJustBashSandboxTemplates};
|
|
1
|
+
import{randomUUID}from"node:crypto";import{mkdir,readdir,rename,rm,stat}from"node:fs/promises";import"node:fs";import{dirname,join}from"node:path";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{withToolSessionSandboxes}from"#execution/tool-session/sandbox.js";import{copyDirectoryAtomically,createFileBackedInternalSandboxSession,pathExists,resolveLocalProviderSessionRootPath,resolveLocalProviderTemplateRootPath,resolveLocalProviderTemplatesDirectory,touchDirectory,writeSandboxSeedFiles}from"#execution/sandbox/bindings/local-provider-utils.js";import{LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,selectStaleTemplateEntries}from"#execution/sandbox/bindings/local-template-prune.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{createSandboxProviderIdentity}from"#execution/sandbox/provider-identity.js";import{isSandboxPreparedArtifactRecord,providerResourceTargetFiles,sandboxProviderResourceIdentity}from"#shared/sandbox-provider.js";import{SandboxTemplateNotProvisionedError}from"#shared/sandbox-template-error.js";import{createBashSandbox,createJustBashHandle}from"#execution/sandbox/bindings/just-bash-runtime.js";const JUST_BASH_CACHE_DIRECTORY_NAME=`just-bash`,JUST_BASH_PROVIDER_NAME=`just-bash`;function createJustBashSandboxProvider(e=void 0){let t=e??{},n=t.autoInstall??!0,r={autoInstall:n,customCommands:t.customCommands,filesystem:t.filesystem,version:2};return withToolSessionSandboxes({async prepare(e){let i=createSandboxProviderIdentity({...r,resources:sandboxProviderResourceIdentity(e.resources),sourceRevision:e.sourceRevision}).slice(0,24),a=resolveTemplateRootPath(e.storagePath,i);if(await pathExists(a))return await touchDirectory(a),e.log?.(`reusing cached template filesystem`),{templateRootPath:a};let o=`${a}.${randomUUID()}.tmp`,s=!1,c=await createBashSandbox({autoInstall:n,host:e.host,rootPath:o,sessionKey:`prepare-${i}`,storagePath:e.storagePath}),l=buildSandboxSession(createFileBackedInternalSandboxSession({sandbox:c}));try{await writeSandboxSeedFiles(l,providerResourceTargetFiles(e.resources)),t.prepare!==void 0&&(e.log?.(`running sandbox preparation`),await t.prepare(createLoggingSandboxSession({log:e.log,session:l}))),await c.captureState(),await mkdir(dirname(a),{recursive:!0});try{await rename(o,a),s=!0}catch(e){if(await pathExists(a))return{templateRootPath:a};throw e}}finally{await c.dispose(),s||await rm(o,{force:!0,recursive:!0})}return{templateRootPath:a}},async resume(e,n,r){let i=requirePreparedJustBashArtifact(n),a=requireJustBashSessionState(r),o=createSandboxProviderIdentity({artifact:i,version:1}),s=sessionRootPath(e,i);if(a.generation!==o||a.rootPath!==s)throw Error(`just-bash session state is incompatible with this environment.`);if(!await pathExists(a.rootPath))throw Error(`just-bash session root "${a.rootPath}" no longer exists.`);return await openHandle(e,a.rootPath,t)},async start(e,n,r){let i=requirePreparedJustBashArtifact(r),a=sessionRootPath(e,i);return await ensureSessionRoot(i,a),{handle:await openHandle(e,a,t),state:{generation:createSandboxProviderIdentity({artifact:i,version:1}),rootPath:a,version:2}}}},{releaseHandle:e=>e.onSessionStop()})}function sessionRootPath(e,t){return resolveSessionRootPath(e.storagePath,createSandboxProviderIdentity({artifact:t,sessionId:e.session.id,version:1}).slice(0,24))}async function ensureSessionRoot(e,t){if(!await pathExists(t)){if(!await pathExists(e.templateRootPath))throw new SandboxTemplateNotProvisionedError({providerName:JUST_BASH_PROVIDER_NAME,templateKey:e.templateRootPath});await copyDirectoryAtomically(e.templateRootPath,t)}}async function openHandle(e,t,n){let r=await createBashSandbox({autoInstall:n.autoInstall??!0,customCommands:n.customCommands,filesystem:n.filesystem,host:e.host,rootPath:t,sessionKey:e.session.id,storagePath:e.storagePath});return createJustBashHandle(r)}async function pruneJustBashSandboxTemplates(e){let t=resolveLocalProviderTemplatesDirectory(resolveSandboxCacheDirectory(e.appRoot),JUST_BASH_CACHE_DIRECTORY_NAME),n=e.now??Date.now(),r=e.recentWindowMs??LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,i=e.retainCount??LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,a;try{a=await readdir(t,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let o=await Promise.all(a.filter(e=>e.isDirectory()).map(async e=>{let n=join(t,e.name);return{isTemporary:e.name.endsWith(`.tmp`),mtimeMs:(await stat(n)).mtimeMs,path:n}})),s=selectStaleTemplateEntries(o.filter(e=>!e.isTemporary),{now:n,recentWindowMs:r,retainCount:i}),c=selectStaleTemplateEntries(o.filter(e=>e.isTemporary),{now:n,recentWindowMs:r,retainCount:0});await Promise.all([...s,...c].map(async e=>await rm(e.path,{force:!0,recursive:!0})))}function requirePreparedJustBashArtifact(e){if(!isSandboxPreparedArtifactRecord(e)||typeof e.templateRootPath!=`string`)throw Error(`Invalid prepared just-bash artifact.`);return{templateRootPath:e.templateRootPath}}function requireJustBashSessionState(e){if(!isSandboxPreparedArtifactRecord(e)||e.version!==2||typeof e.generation!=`string`||typeof e.rootPath!=`string`)throw Error(`Invalid just-bash session state.`);return{generation:e.generation,rootPath:e.rootPath,version:2}}function resolveTemplateRootPath(e,t){return resolveLocalProviderTemplateRootPath(e,JUST_BASH_CACHE_DIRECTORY_NAME,t)}function resolveSessionRootPath(e,t){return resolveLocalProviderSessionRootPath(e,JUST_BASH_CACHE_DIRECTORY_NAME,t)}export{JUST_BASH_PROVIDER_NAME,createJustBashSandboxProvider,pruneJustBashSandboxTemplates};
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
export declare function isVercelSnapshotUnavailableError(error: unknown): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* A resume that found the sandbox's snapshot expired or deleted: 410 with the
|
|
4
|
+
* `snapshot_not_found` code, rather than any other 410.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isVercelSnapshotNotFoundError(error: unknown): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* A create that lost the race for a sandbox name. The Sandbox API answers a
|
|
9
|
+
* taken name with 400 `bad_request` "A sandbox with the name '…' already
|
|
10
|
+
* exists"; 409 is accepted too in case it moves to a proper Conflict.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isVercelSandboxNameConflictError(error: unknown): boolean;
|
|
2
13
|
export declare function isVercelSandboxMissingError(error: unknown): boolean;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
function isVercelSnapshotUnavailableError(e){return errorChainContainsStatus(e,410)}function
|
|
1
|
+
function isVercelSnapshotUnavailableError(e){return errorChainContainsStatus(e,410)}function isVercelSnapshotNotFoundError(e){for(let t of walkErrorChain(e))if(readErrorStatus(t)===410&&isRecord(t)&&(isRecord(t.json)&&isRecord(t.json.error)?t.json.error:void 0)?.code===`snapshot_not_found`)return!0;return!1}function isVercelSandboxNameConflictError(e){for(let t of walkErrorChain(e)){let e=readErrorStatus(t);if(e===409||e===400&&/\bsandbox with the name\b.*\balready exists\b/is.test(readErrorText(t)))return!0}return!1}function readErrorText(e){if(!isRecord(e))return``;let t=[];typeof e.message==`string`&&t.push(e.message),typeof e.text==`string`&&t.push(e.text);let n=isRecord(e.json)&&isRecord(e.json.error)?e.json.error:void 0;return n!==void 0&&typeof n.message==`string`&&t.push(n.message),t.join(`
|
|
2
|
+
`)}function isVercelSandboxMissingError(e){return errorChainContainsStatus(e,404)}function errorChainContainsStatus(e,t){for(let n of walkErrorChain(e))if(readErrorStatus(n)===t)return!0;return!1}function readErrorStatus(e){if(isRecord(e))return typeof e.status==`number`?e.status:typeof e.statusCode==`number`?e.statusCode:isRecord(e.response)&&typeof e.response.status==`number`?e.response.status:void 0}function*walkErrorChain(e){let t=e,n=new Set;for(;t!=null&&!n.has(t);)n.add(t),yield t,t=isRecord(t)?t.cause:void 0}function isRecord(e){return typeof e==`object`&&!!e}export{isVercelSandboxMissingError,isVercelSandboxNameConflictError,isVercelSnapshotNotFoundError,isVercelSnapshotUnavailableError};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VercelCreateOptions } from "#execution/sandbox/bindings/vercel-sdk-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* How long a tool session's saved filesystem outlives its last use. It is
|
|
4
|
+
* also the shortest `snapshotExpiration` the Sandbox API accepts.
|
|
5
|
+
*/
|
|
6
|
+
export declare const VERCEL_TOOL_SESSION_SNAPSHOT_EXPIRATION_MS: number;
|
|
7
|
+
export declare function withToolSessionRetention(options: VercelCreateOptions): VercelCreateOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const VERCEL_TOOL_SESSION_SNAPSHOT_EXPIRATION_MS=864e5;function withToolSessionRetention(e){return{...e,keepLastSnapshots:{count:1},snapshotExpiration:VERCEL_TOOL_SESSION_SNAPSHOT_EXPIRATION_MS}}export{VERCEL_TOOL_SESSION_SNAPSHOT_EXPIRATION_MS,withToolSessionRetention};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{streamToBuffer}from"#execution/sandbox/stream-utils.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{VERCEL_EVE_SANDBOX_IMAGE}from"#execution/sandbox/bindings/eve-image.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{createSandboxProviderIdentity}from"#execution/sandbox/provider-identity.js";import{isSandboxPreparedArtifactRecord,providerResourceTargetFiles,sandboxProviderResourceIdentity}from"#shared/sandbox-provider.js";import{SandboxTemplateNotProvisionedError}from"#shared/sandbox-template-error.js";import{adaptMultiplexedCommandToSandboxProcess}from"#execution/sandbox/multiplexed-command.js";import{resolveSandboxModelPath}from"#shared/skill-paths.js";import{isVercelSandboxMissingError,isVercelSnapshotUnavailableError}from"#execution/sandbox/bindings/vercel-errors.js";import{ensureVercelSandboxTags,errorMessage,resolveVercelSandboxTags}from"#execution/sandbox/bindings/vercel-options.js";import{applyInitialVercelNetworkPolicy,createVercelNetworkPolicySetter,ensureVercelSandboxBaseRuntime,withBaseSetupNetworkPolicy}from"#execution/sandbox/bindings/vercel-base-runtime.js";import{createVercelEveImageSandbox}from"#execution/sandbox/bindings/vercel-create-sdk.js";import{getNamedVercelSandbox}from"#execution/sandbox/bindings/vercel-lookup.js";import{deleteUnusableVercelSandbox,deleteVercelSandbox,stopVercelSandbox}from"#execution/sandbox/bindings/vercel-lifecycle.js";import{normalizeVercelReadStream}from"#execution/sandbox/bindings/vercel-read-stream.js";function createVercelSandboxProvider(e){let{prepare:t,...n}=e??{};return createVercelSandbox({createOptions:n,prepare:t})}function createVercelSandbox(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n=e.loadDeleteSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),r={timeout:DEFAULT_SANDBOX_TIMEOUT_MS,...e.createOptions},i=e.createSandbox??createVercelEveImageSandbox;async function openSession(e,a,o,s){let c=requirePreparedVercelTemplate(o),{mounts:l,...u}=a??{},d={...r,...u},f=resolveVercelSandboxTags(d.tags,{sessionId:e.session.id}),p=await t(),m={createOptions:d,createSandbox:i,resolveSessionCreateOptions:l===void 0?void 0:async()=>({mounts:l}),sandboxModule:p,sessionKey:s,snapshotId:c.snapshotId,tags:f},h;try{if(h=await ensureSession(m),h=await ensureUsableSession({input:m,loadDeleteSandboxModule:n,session:h}),h.created&&c.snapshotId===void 0&&u.networkPolicy!==void 0)try{await applyInitialVercelNetworkPolicy(h.sandbox,u.networkPolicy)}catch(t){try{await deleteVercelSandbox({createOptions:d,loadDeleteSandboxModule:n,sandbox:h.sandbox})}catch(n){throw AggregateError([t,n],`Failed to apply network policy and discard Vercel sandbox session "${e.session.id}".`,{cause:t})}throw t}}catch(t){throw isVercelSnapshotUnavailableError(t)&&c.snapshotId!==void 0?new SandboxTemplateNotProvisionedError({providerName:`vercel`,templateKey:c.snapshotId}):Error(`Failed to open Vercel sandbox session "${e.session.id}": ${errorMessage(t)}`,{cause:t})}return createHandle({createOptions:d,loadDeleteSandboxModule:n,sandbox:h.sandbox})}return{async prepare(n){let a=providerResourceTargetFiles(n.resources);if(e.skipEmptyPreparation===!0&&e.prepare===void 0&&a.length===0)return{};let o=`eve-sbx-tpl-vercel-${createSandboxProviderIdentity({createOptions:vercelIdentityOptions(r),resolvedImage:r.source===void 0?r.image??VERCEL_EVE_SANDBOX_IMAGE:void 0,resources:sandboxProviderResourceIdentity(n.resources),sourceRevision:n.sourceRevision,version:2}).slice(0,32)}`;try{return{snapshotId:(await ensureTemplateWithUnavailableRetry({createOptions:r,createSandbox:i,loadSandboxModule:t,log:n.log,prepareSandbox:e.prepare,seedFiles:a,templateKey:o})).template.snapshotId}}catch(e){throw Error(`Failed to prepare Vercel sandbox snapshot: ${errorMessage(e)}`,{cause:e})}},async resume(e,i,a){requirePreparedVercelTemplate(i);let o=requireVercelSessionState(a),s=await t(),c=await getNamedVercelSandbox({createOptions:r,sandboxModule:s,sandboxName:o.sandboxName});if(c===null)throw Error(`Vercel sandbox session "${o.sandboxName}" no longer exists.`);return await ensureVercelSandboxBaseRuntime(c),createHandle({createOptions:r,loadDeleteSandboxModule:n,sandbox:c})},async start(e,t,n){let i=vercelSessionName(e.session.id,t,n,r);return{handle:await openSession(e,t,n,i),state:{sandboxName:i,version:3}}}}}function vercelSessionName(e,t,n,r){let i=requirePreparedVercelTemplate(n);return`eve-sbx-vercel-${createSandboxProviderIdentity({artifact:i,createOptions:vercelIdentityOptions(r),options:vercelIdentityOptions(t),sessionId:e,version:1}).slice(0,32)}`}function vercelIdentityOptions(e){if(e===void 0)return;let t=new Set([`fetch`,`projectId`,`signal`,`teamId`,`token`]);return Object.fromEntries(Object.entries(e).filter(([e])=>!t.has(e)))}function requireVercelSessionState(e){if(!isSandboxPreparedArtifactRecord(e)||e.version!==3||typeof e.sandboxName!=`string`)throw Error(`Invalid Vercel sandbox session state.`);return{sandboxName:e.sandboxName,version:3}}function requirePreparedVercelTemplate(e){if(!isSandboxPreparedArtifactRecord(e)||e.snapshotId!==void 0&&typeof e.snapshotId!=`string`)throw Error(`Invalid prepared Vercel sandbox artifact.`);return e.snapshotId===void 0?{}:{snapshotId:e.snapshotId}}async function ensureTemplateWithUnavailableRetry(e){try{return await ensureTemplate(e)}catch(t){if(!isVercelSnapshotUnavailableError(t)&&!isVercelSandboxMissingError(t))throw t;return e.log?.(`cached template disappeared; rebuilding sandbox template`),await ensureTemplate(e)}}async function ensureTemplate(e){let t=await e.loadSandboxModule(),n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:t,sandboxName:e.templateKey}),r=resolveVercelSandboxTags(e.createOptions.tags,e.tags),i=extractAuthorSnapshotId(e.createOptions);n!==null&&isUnprovisionedTerminalTemplateSandbox(n,i)&&(await n.delete(),n=null),n===null?n=await e.createSandbox({sandboxModule:t,createOptions:withBaseSetupNetworkPolicy({...e.createOptions,name:e.templateKey,persistent:!0,tags:r})}):await ensureVercelSandboxTags(n,r);let a=typeof n.currentSnapshotId==`string`&&n.currentSnapshotId.length>0&&n.currentSnapshotId!==i?n.currentSnapshotId:null;if(a!==null)return{template:{sandboxName:n.name,snapshotId:a,templateKey:e.templateKey}};e.log?.(`preparing base runtime inside sandbox`),await ensureVercelSandboxBaseRuntime(n),await applyInitialVercelNetworkPolicy(n,e.createOptions.networkPolicy);let o=buildSandboxSession(createVercelInternalSandboxSession(n),createVercelNetworkPolicySetter(n));await writeVercelSandboxSeedFiles({sandbox:n,seedFiles:e.seedFiles,session:o}),e.log?.(`running sandbox preparation`),await e.prepareSandbox?.(createLoggingSandboxSession({log:e.log,session:o}));let s=await n.snapshot();return{template:{sandboxName:n.name,snapshotId:s.snapshotId,templateKey:e.templateKey}}}async function ensureUsableSession(e){try{return await ensureVercelSandboxBaseRuntime(e.session.sandbox),e.session}catch(t){if(e.session.created||!isVercelSnapshotUnavailableError(t))throw t}await deleteUnusableVercelSandbox({createOptions:e.input.createOptions,loadDeleteSandboxModule:e.loadDeleteSandboxModule,sandbox:e.session.sandbox});let t=await ensureSession(e.input);return await ensureVercelSandboxBaseRuntime(t.sandbox),t}async function ensureSession(e){let t=e.sessionKey,n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:e.sandboxModule,sandboxName:t});if(n!==null)return await ensureVercelSandboxTags(n,e.tags),{created:!1,sandbox:n};let r=createSessionCreateParams(e,t,await e.resolveSessionCreateOptions?.());return e.tags!==void 0&&(r.tags=e.tags),{created:!0,sandbox:await e.createSandbox({createOptions:r,sandboxModule:e.sandboxModule})}}function createSessionCreateParams(e,t,n={}){let r={...e.createOptions,...n};if(e.snapshotId===void 0)return withBaseSetupNetworkPolicy({...r,name:t,persistent:!0});let{image:i,runtime:a,source:o,...s}=r;return{...s,name:t,persistent:!0,source:{snapshotId:e.snapshotId,type:`snapshot`}}}function createHandle(e){let{sandbox:t}=e;return{sandbox:buildSandboxSession(createVercelInternalSandboxSession(t),createVercelNetworkPolicySetter(t)),async onSessionDelete(n){await deleteVercelSandbox({createOptions:e.createOptions,loadDeleteSandboxModule:e.loadDeleteSandboxModule,sandbox:t,signal:n?.abortSignal})},async onSessionStop(){await stopVercelSandbox(t)},async onRuntimeShutdown(){try{await stopVercelSandbox(t)}catch{}}}}function createVercelInternalSandboxSession(e){return{resolvePath:resolveVercelSandboxPath,async spawn(t){let n=await e.runCommand({args:[`-lc`,t.command],cmd:`bash`,cwd:t.workingDirectory??WORKSPACE_ROOT,detached:!0,env:t.env,signal:t.abortSignal});return adaptMultiplexedCommandToSandboxProcess({command:n,getOutput:e=>e.stream})},async readFile(t){return normalizeVercelReadStream(await e.readFile({path:t.path}))},async writeFile(t){let n=await streamToBuffer(t.content),r=await resolveVercelWritePath(e,t.path,t.abortSignal);await e.writeFiles([{content:n,path:r}],{signal:t.abortSignal})},async removePath(t){await e.fs.rm(t.path,{force:t.force,recursive:t.recursive,signal:t.abortSignal})}}}async function writeVercelSandboxSeedFiles(e){if(e.seedFiles.length===0)return;let t=await Promise.all(e.seedFiles.map(async t=>({content:typeof t.content==`string`?Buffer.from(t.content):t.content,path:await resolveSandboxModelPath({path:t.path,sandbox:e.session})})));await e.sandbox.writeFiles(t)}function resolveVercelSandboxPath(e){return e.startsWith(`/`)?e:`${WORKSPACE_ROOT}/${e}`}async function resolveVercelWritePath(e,t,n){let r=await e.runCommand({args:[`-m`,`--`,t],cmd:`realpath`,signal:n}),i=(await r.stdout()).trim();if(r.exitCode!==0||!i.startsWith(`/`)||i.includes(`
|
|
1
|
+
import{isToolSessionId}from"#execution/tool-session/id.js";import{withToolSessionSandboxes}from"#execution/tool-session/sandbox.js";import{streamToBuffer}from"#execution/sandbox/stream-utils.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{VERCEL_EVE_SANDBOX_IMAGE}from"#execution/sandbox/bindings/eve-image.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{createSandboxProviderIdentity}from"#execution/sandbox/provider-identity.js";import{isSandboxPreparedArtifactRecord,providerResourceTargetFiles,sandboxProviderResourceIdentity}from"#shared/sandbox-provider.js";import{SandboxTemplateNotProvisionedError}from"#shared/sandbox-template-error.js";import{adaptMultiplexedCommandToSandboxProcess}from"#execution/sandbox/multiplexed-command.js";import{resolveSandboxModelPath}from"#shared/skill-paths.js";import{isVercelSandboxMissingError,isVercelSandboxNameConflictError,isVercelSnapshotNotFoundError,isVercelSnapshotUnavailableError}from"#execution/sandbox/bindings/vercel-errors.js";import{ensureVercelSandboxTags,errorMessage,resolveVercelSandboxTags}from"#execution/sandbox/bindings/vercel-options.js";import{applyInitialVercelNetworkPolicy,createVercelNetworkPolicySetter,ensureVercelSandboxBaseRuntime,withBaseSetupNetworkPolicy}from"#execution/sandbox/bindings/vercel-base-runtime.js";import{createVercelEveImageSandbox}from"#execution/sandbox/bindings/vercel-create-sdk.js";import{withToolSessionRetention}from"#execution/sandbox/bindings/vercel-tool-sessions.js";import{getNamedVercelSandbox}from"#execution/sandbox/bindings/vercel-lookup.js";import{deleteUnusableVercelSandbox,deleteVercelSandbox,stopVercelSandbox}from"#execution/sandbox/bindings/vercel-lifecycle.js";import{normalizeVercelReadStream}from"#execution/sandbox/bindings/vercel-read-stream.js";function createVercelSandboxProvider(e){let{prepare:t,...n}=e??{};return createVercelSandbox({createOptions:n,prepare:t})}function createVercelSandbox(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n=e.loadDeleteSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),r={timeout:DEFAULT_SANDBOX_TIMEOUT_MS,...e.createOptions},i=e.createSandbox??createVercelEveImageSandbox;async function openSession(e,a,o,s){let c=requirePreparedVercelTemplate(o),{mounts:l,...u}=a??{},d=isToolSessionId(e.session.id),f={...r,...u},p=d?withToolSessionRetention(f):f,m=resolveVercelSandboxTags(p.tags,{sessionId:e.session.id}),h=await t(),g={createOptions:p,createSandbox:i,resolveSessionCreateOptions:l===void 0?void 0:async()=>({mounts:l}),sandboxModule:h,sessionKey:s,snapshotId:c.snapshotId,tags:m},_;try{if(_=await ensureSession(g),_=await ensureUsableSession({expired:d?isVercelSnapshotNotFoundError:isVercelSnapshotUnavailableError,input:g,loadDeleteSandboxModule:n,session:_}),_.created&&c.snapshotId===void 0&&u.networkPolicy!==void 0)try{await applyInitialVercelNetworkPolicy(_.sandbox,u.networkPolicy)}catch(t){try{await deleteVercelSandbox({createOptions:p,loadDeleteSandboxModule:n,sandbox:_.sandbox})}catch(n){throw AggregateError([t,n],`Failed to apply network policy and discard Vercel sandbox session "${e.session.id}".`,{cause:t})}throw t}}catch(t){throw isVercelSnapshotUnavailableError(t)&&c.snapshotId!==void 0?new SandboxTemplateNotProvisionedError({providerName:`vercel`,templateKey:c.snapshotId}):Error(`Failed to open Vercel sandbox session "${e.session.id}": ${errorMessage(t)}`,{cause:t})}return createHandle({createOptions:p,loadDeleteSandboxModule:n,sandbox:_.sandbox})}return withToolSessionSandboxes({async prepare(n){let a=providerResourceTargetFiles(n.resources);if(e.skipEmptyPreparation===!0&&e.prepare===void 0&&a.length===0)return{};let o=`eve-sbx-tpl-vercel-${createSandboxProviderIdentity({createOptions:vercelIdentityOptions(r),resolvedImage:r.source===void 0?r.image??VERCEL_EVE_SANDBOX_IMAGE:void 0,resources:sandboxProviderResourceIdentity(n.resources),sourceRevision:n.sourceRevision,version:2}).slice(0,32)}`;try{return{snapshotId:(await ensureTemplateWithUnavailableRetry({createOptions:r,createSandbox:i,loadSandboxModule:t,log:n.log,prepareSandbox:e.prepare,seedFiles:a,templateKey:o})).template.snapshotId}}catch(e){throw Error(`Failed to prepare Vercel sandbox snapshot: ${errorMessage(e)}`,{cause:e})}},async resume(e,i,a){requirePreparedVercelTemplate(i);let o=requireVercelSessionState(a),s=await t(),c=await getNamedVercelSandbox({createOptions:r,sandboxModule:s,sandboxName:o.sandboxName});if(c===null)throw Error(`Vercel sandbox session "${o.sandboxName}" no longer exists.`);return await ensureVercelSandboxBaseRuntime(c),createHandle({createOptions:r,loadDeleteSandboxModule:n,sandbox:c})},async start(e,t,n){let i=vercelSessionName(e.session.id,t,n,r);return{handle:await openSession(e,t,n,i),state:{sandboxName:i,version:3}}}})}function vercelSessionName(e,t,n,r){let i=requirePreparedVercelTemplate(n);return`eve-sbx-vercel-${createSandboxProviderIdentity({artifact:i,createOptions:vercelIdentityOptions(r),options:vercelIdentityOptions(t),sessionId:e,version:1}).slice(0,32)}`}function vercelIdentityOptions(e){if(e===void 0)return;let t=new Set([`fetch`,`projectId`,`signal`,`teamId`,`token`]);return Object.fromEntries(Object.entries(e).filter(([e])=>!t.has(e)))}function requireVercelSessionState(e){if(!isSandboxPreparedArtifactRecord(e)||e.version!==3||typeof e.sandboxName!=`string`)throw Error(`Invalid Vercel sandbox session state.`);return{sandboxName:e.sandboxName,version:3}}function requirePreparedVercelTemplate(e){if(!isSandboxPreparedArtifactRecord(e)||e.snapshotId!==void 0&&typeof e.snapshotId!=`string`)throw Error(`Invalid prepared Vercel sandbox artifact.`);return e.snapshotId===void 0?{}:{snapshotId:e.snapshotId}}async function ensureTemplateWithUnavailableRetry(e){try{return await ensureTemplate(e)}catch(t){if(!isVercelSnapshotUnavailableError(t)&&!isVercelSandboxMissingError(t))throw t;return e.log?.(`cached template disappeared; rebuilding sandbox template`),await ensureTemplate(e)}}async function ensureTemplate(e){let t=await e.loadSandboxModule(),n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:t,sandboxName:e.templateKey}),r=resolveVercelSandboxTags(e.createOptions.tags,e.tags),i=extractAuthorSnapshotId(e.createOptions);n!==null&&isUnprovisionedTerminalTemplateSandbox(n,i)&&(await n.delete(),n=null),n===null?n=await e.createSandbox({sandboxModule:t,createOptions:withBaseSetupNetworkPolicy({...e.createOptions,name:e.templateKey,persistent:!0,tags:r})}):await ensureVercelSandboxTags(n,r);let a=typeof n.currentSnapshotId==`string`&&n.currentSnapshotId.length>0&&n.currentSnapshotId!==i?n.currentSnapshotId:null;if(a!==null)return{template:{sandboxName:n.name,snapshotId:a,templateKey:e.templateKey}};e.log?.(`preparing base runtime inside sandbox`),await ensureVercelSandboxBaseRuntime(n),await applyInitialVercelNetworkPolicy(n,e.createOptions.networkPolicy);let o=buildSandboxSession(createVercelInternalSandboxSession(n),createVercelNetworkPolicySetter(n));await writeVercelSandboxSeedFiles({sandbox:n,seedFiles:e.seedFiles,session:o}),e.log?.(`running sandbox preparation`),await e.prepareSandbox?.(createLoggingSandboxSession({log:e.log,session:o}));let s=await n.snapshot();return{template:{sandboxName:n.name,snapshotId:s.snapshotId,templateKey:e.templateKey}}}async function ensureUsableSession(e){try{return await ensureVercelSandboxBaseRuntime(e.session.sandbox),e.session}catch(t){if(e.session.created||!e.expired(t))throw t}try{await deleteUnusableVercelSandbox({createOptions:e.input.createOptions,loadDeleteSandboxModule:e.loadDeleteSandboxModule,sandbox:e.session.sandbox})}catch(e){if(!isVercelSandboxMissingError(e))throw e}let t=await ensureSession(e.input);return await ensureVercelSandboxBaseRuntime(t.sandbox),t}async function ensureSession(e){let t=e.sessionKey,n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:e.sandboxModule,sandboxName:t});if(n!==null)return await ensureVercelSandboxTags(n,e.tags),{created:!1,sandbox:n};let r=createSessionCreateParams(e,t,await e.resolveSessionCreateOptions?.());e.tags!==void 0&&(r.tags=e.tags);try{return{created:!0,sandbox:await e.createSandbox({createOptions:r,sandboxModule:e.sandboxModule})}}catch(n){if(!isVercelSandboxNameConflictError(n))throw n;let r=await getNamedVercelSandbox({...e,sandboxName:t});if(r===null)throw n;return{created:!1,sandbox:r}}}function createSessionCreateParams(e,t,n={}){let r={...e.createOptions,...n};if(e.snapshotId===void 0)return withBaseSetupNetworkPolicy({...r,name:t,persistent:!0});let{image:i,runtime:a,source:o,...s}=r;return{...s,name:t,persistent:!0,source:{snapshotId:e.snapshotId,type:`snapshot`}}}function createHandle(e){let{sandbox:t}=e;return{sandbox:buildSandboxSession(createVercelInternalSandboxSession(t),createVercelNetworkPolicySetter(t)),async onSessionDelete(n){await deleteVercelSandbox({createOptions:e.createOptions,loadDeleteSandboxModule:e.loadDeleteSandboxModule,sandbox:t,signal:n?.abortSignal})},async onSessionStop(){await stopVercelSandbox(t)},async onRuntimeShutdown(){try{await stopVercelSandbox(t)}catch{}}}}function createVercelInternalSandboxSession(e){return{resolvePath:resolveVercelSandboxPath,async spawn(t){let n=await e.runCommand({args:[`-lc`,t.command],cmd:`bash`,cwd:t.workingDirectory??WORKSPACE_ROOT,detached:!0,env:t.env,signal:t.abortSignal});return adaptMultiplexedCommandToSandboxProcess({command:n,getOutput:e=>e.stream})},async readFile(t){return normalizeVercelReadStream(await e.readFile({path:t.path}))},async writeFile(t){let n=await streamToBuffer(t.content),r=await resolveVercelWritePath(e,t.path,t.abortSignal);await e.writeFiles([{content:n,path:r}],{signal:t.abortSignal})},async removePath(t){await e.fs.rm(t.path,{force:t.force,recursive:t.recursive,signal:t.abortSignal})}}}async function writeVercelSandboxSeedFiles(e){if(e.seedFiles.length===0)return;let t=await Promise.all(e.seedFiles.map(async t=>({content:typeof t.content==`string`?Buffer.from(t.content):t.content,path:await resolveSandboxModelPath({path:t.path,sandbox:e.session})})));await e.sandbox.writeFiles(t)}function resolveVercelSandboxPath(e){return e.startsWith(`/`)?e:`${WORKSPACE_ROOT}/${e}`}async function resolveVercelWritePath(e,t,n){let r=await e.runCommand({args:[`-m`,`--`,t],cmd:`realpath`,signal:n}),i=(await r.stdout()).trim();if(r.exitCode!==0||!i.startsWith(`/`)||i.includes(`
|
|
2
2
|
`))throw Error(`Failed to resolve Vercel Sandbox write path: ${t}`);return i}function isUnprovisionedTerminalTemplateSandbox(e,t){let n=e.currentSnapshotId;return typeof n==`string`&&n.length>0&&n!==t?!1:e.status===`aborted`||e.status===`failed`||e.status===`stopped`}function extractAuthorSnapshotId(e){let t=e.source;if(t?.type===`snapshot`&&typeof t.snapshotId==`string`)return t.snapshotId}const DEFAULT_SANDBOX_TIMEOUT_MS=18e5;export{createVercelSandbox,createVercelSandboxProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{prewarmAppSandboxes}from"./prewarm.js";import{randomUUID}from"node:crypto";import{mkdir}from"node:fs/promises";import{join}from"node:path";import{acquireRecoveryLease,startPublicationJournalHeartbeat}from"#internal/application/output-publication-lock.js";import{loadSandboxPreparedArtifact}from"#runtime/sandbox/prepared-artifacts.js";
|
|
1
|
+
import{prewarmAppSandboxes}from"./prewarm.js";import{randomUUID}from"node:crypto";import{mkdir}from"node:fs/promises";import{join}from"node:path";import{resolveRuntimeCompilerArtifactPaths}from"#runtime/loaders/artifact-paths.js";import{acquireRecoveryLease,startPublicationJournalHeartbeat}from"#internal/application/output-publication-lock.js";import{loadSandboxPreparedArtifact}from"#runtime/sandbox/prepared-artifacts.js";async function ensureDevelopmentSandboxesPrepared(e){if(await loadSandboxPreparedArtifact(e)!==void 0)return;let t=e.compiledArtifactsSource,{compileDirectoryPath:n}=resolveRuntimeCompilerArtifactPaths(t.appRoot),r=join(n,`sandbox-preparation.lock`),i=Date.now()+6e5;await mkdir(n,{recursive:!0});let a=randomUUID(),o;for(;(o=await acquireRecoveryLease(r,a))===void 0;){if(Date.now()>=i)throw Error(`Timed out waiting for development sandbox preparation.`);await new Promise(e=>setTimeout(e,250))}let s=startPublicationJournalHeartbeat(join(r,`lease`));try{if(await loadSandboxPreparedArtifact(e)!==void 0)return;await prewarmAppSandboxes({appRoot:t.sandboxAppRoot??t.appRoot,compiledArtifactsSource:t,log:e=>console.info(e)})}finally{s(),await o.complete()}}export{ensureDevelopmentSandboxesPrepared};
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import { type RuntimeCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";
|
|
2
2
|
import type { RuntimeSandboxRegistry } from "#runtime/sandbox/registry.js";
|
|
3
3
|
import type { SandboxAccess, SandboxState } from "#sandbox/state.js";
|
|
4
|
+
import { type SandboxProviderHandle } from "#shared/sandbox-provider.js";
|
|
4
5
|
interface EnsureSandboxAccessInput {
|
|
5
6
|
readonly compiledArtifactsSource: RuntimeCompiledArtifactsSource;
|
|
6
7
|
readonly nodeId: string;
|
|
8
|
+
/** `false` when the sandbox outlives this access: it may not delete it, even after a failed start. */
|
|
7
9
|
readonly ownsSandbox?: boolean;
|
|
8
10
|
readonly registry: RuntimeSandboxRegistry;
|
|
9
11
|
readonly sessionId: string;
|
|
10
12
|
readonly state: SandboxState | null;
|
|
11
13
|
}
|
|
12
|
-
|
|
14
|
+
/** The access `ensureSandboxAccess` builds, with what the opener may do beyond the sandbox API. */
|
|
15
|
+
export interface EnsuredSandboxAccess extends SandboxAccess {
|
|
16
|
+
/**
|
|
17
|
+
* Lets go of the handle this access opened, if any, without stopping or
|
|
18
|
+
* deleting the sandbox, and returns it so the caller can free what it
|
|
19
|
+
* holds in this process. For a sandbox that outlives the access, such as a
|
|
20
|
+
* tool session's. Waits for an open still in flight, so a caller that
|
|
21
|
+
* finished early never leaves that handle behind.
|
|
22
|
+
*/
|
|
23
|
+
detach(): Promise<SandboxProviderHandle | undefined>;
|
|
24
|
+
}
|
|
25
|
+
export declare function ensureSandboxAccess(input: EnsureSandboxAccessInput): Promise<EnsuredSandboxAccess>;
|
|
13
26
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{contextStorage}from"#context/container.js";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{getSandboxEnvironmentRuntime,runWithSandboxConstructorRuntime}from"#shared/sandbox-environment.js";import{buildCallbackContext,withRuntimeSandboxLifecycle}from"#context/build-callback-context.js";import{isEveDevEnvironment}from"#internal/application/dev-environment.js";import{trackActiveSandboxHandle,untrackActiveSandboxHandle}from"#execution/sandbox/active-handles.js";import{isSandboxPreparedArtifact}from"#shared/sandbox-provider.js";import{SandboxTemplateNotProvisionedError}from"#shared/sandbox-template-error.js";import{loadSandboxPreparedArtifact}from"#runtime/sandbox/prepared-artifacts.js";import{
|
|
1
|
+
import{getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{contextStorage}from"#context/container.js";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{getSandboxEnvironmentRuntime,runWithSandboxConstructorRuntime}from"#shared/sandbox-environment.js";import{buildCallbackContext,withRuntimeSandboxLifecycle}from"#context/build-callback-context.js";import{isEveDevEnvironment}from"#internal/application/dev-environment.js";import{trackActiveSandboxHandle,untrackActiveSandboxHandle}from"#execution/sandbox/active-handles.js";import{isSandboxPreparedArtifact}from"#shared/sandbox-provider.js";import{SandboxTemplateNotProvisionedError}from"#shared/sandbox-template-error.js";import{loadSandboxPreparedArtifact}from"#runtime/sandbox/prepared-artifacts.js";import{ensureDevelopmentSandboxesPrepared}from"#execution/sandbox/development-lazy-prewarm.js";import{createSandboxProviderHost}from"#execution/sandbox/provider-host.js";const pendingSandboxStarts=new Map;async function ensureSandboxAccess(e){let t=e.state?.session?.providerName===void 0?null:e.state.session,n,r,i,a=getRuntimeCompiledArtifactsSandboxAppRoot(e.compiledArtifactsSource)??process.cwd(),o=e.registry.sandbox;if(o===null)return{async captureState(){return{session:t}},async detach(){},async get(){return null},async stop(){}};async function open(n,i,s,c){if(r!==void 0)throw Error(`A sandbox definition can open only one sandbox.`);let l=o.inheritance,u=l?.definition??o.definition;if(u.kind!==`independent`)throw Error(`Sandbox "${u.logicalPath}" has no environment.`);if(s!==u.environment)throw Error(`Sandbox "${u.logicalPath}" selected a different environment.`);if(n!==getSandboxEnvironmentRuntime(u.environment))throw Error(`Sandbox "${u.logicalPath}" selected a different provider.`);if(t!==null)throw Error(`Sandbox "${u.logicalPath}" is already initialized.`);let d=l?.nodeId??e.nodeId,f=await loadSandboxPreparedArtifact({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:d,providerName:n.providerName});if(f===void 0)throw new SandboxTemplateNotProvisionedError({providerName:n.providerName,templateKey:d});let p={host:createSandboxProviderHost(a),session:c,storagePath:resolveSandboxCacheDirectory(a)};r=(async()=>{let e=await n.implementation.start(p,i,f);if(!isSandboxPreparedArtifact(e.state))throw Error(`Sandbox provider "${n.providerName}" returned non-serializable session state.`);return t={providerName:n.providerName,state:e.state,stateProtocolVersion:n.stateProtocolVersion},e.handle})().catch(e=>{throw r=void 0,e});let m=await r;return installHandle(n.providerName,m)}function installHandle(e,t){let r=withRuntimeSandboxLifecycle(t.sandbox,e=>t.onSessionDelete(e),()=>t.onSessionStop());return n={handle:t,providerName:e,sandbox:r},r}async function resumePersisted(n,i){if(t===null)throw Error(`Sandbox session state is missing.`);let s=getSandboxEnvironmentRuntime(n.environment);if(t.providerName!==s.providerName)throw Error(`Sandbox session state belongs to provider "${t.providerName}", not "${s.providerName}".`);if(t.stateProtocolVersion!==s.stateProtocolVersion)throw Error(`Sandbox session state protocol ${t.stateProtocolVersion} is incompatible with provider "${s.providerName}" protocol ${s.stateProtocolVersion}.`);let c=o.inheritance?.nodeId??e.nodeId,l=await loadSandboxPreparedArtifact({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:c,providerName:s.providerName});if(l===void 0)throw new SandboxTemplateNotProvisionedError({providerName:s.providerName,templateKey:c});let u={host:createSandboxProviderHost(a),session:i,storagePath:resolveSandboxCacheDirectory(a)};r=s.implementation.resume(u,l,t.state).catch(e=>{throw r=void 0,e});let d=await r;return installHandle(s.providerName,d),trackActiveSandboxHandle({handle:d,providerName:s.providerName,sessionId:e.sessionId}),d}async function resolveHandle(){let n=o.inheritance,r=n?.definition??o.definition;if(r.kind!==`independent`)throw Error(`Sandbox "${r.logicalPath}" has no resolved parent.`);isEveDevEnvironment()&&e.compiledArtifactsSource.kind===`disk`&&await ensureDevelopmentSandboxesPrepared({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:n?.nodeId??e.nodeId,providerName:getSandboxEnvironmentRuntime(r.environment).providerName});let i={...contextStorage.getStore()===void 0?{auth:{current:null,initiator:null},id:e.sessionId,turn:{id:`sandbox-initialization`,sequence:0}}:buildCallbackContext().session,id:e.sessionId};if(t!==null)return await resumePersisted(r,i);let a=`${n?.nodeId??e.nodeId}\0${e.sessionId}`,s=pendingSandboxStarts.get(a);for(;s!==void 0;){if(t=await s,t!==null)return await resumePersisted(r,i);s=pendingSandboxStarts.get(a)}let c=startHandle(r,i),l=c.then(()=>t,()=>null);pendingSandboxStarts.set(a,l);try{return await c}finally{pendingSandboxStarts.get(a)===l&&pendingSandboxStarts.delete(a)}}async function startHandle(i,a){if(o.inheritance!==void 0)await open(getSandboxEnvironmentRuntime(i.environment),void 0,i.environment,a);else try{let e=await runWithSandboxConstructorRuntime({open:({environment:e,options:t,provider:n})=>open(n,t,e,a)},async()=>i.selector({session:a}));if(n===void 0||e!==n.sandbox)throw Error(`Sandbox "${i.logicalPath}" must return the sandbox it opens.`)}catch(a){let o=n?.handle;if(n=void 0,r=void 0,t=null,o!==void 0&&e.ownsSandbox!==!1)try{await o.onSessionDelete()}catch(e){throw AggregateError([a,e],`Sandbox "${i.logicalPath}" initialization and cleanup both failed.`,{cause:a})}throw a}if(n===void 0)throw Error(`Sandbox "${i.logicalPath}" did not open a provider handle.`);return trackActiveSandboxHandle({handle:n.handle,providerName:n.providerName,sessionId:e.sessionId}),n.handle}function requireHandle(){return i===void 0&&(i=resolveHandle().catch(e=>{throw i=void 0,e})),i}let s=o.inheritance?.definition??o.definition;return{environment:s.kind===`independent`?s.environment:void 0,async captureState(){return r!==void 0&&await r,{session:t}},async delete(a){if(e.ownsSandbox===!1)throw Error(`Only the owning session can delete this sandbox.`);let o=await requireHandle(),s=n?.providerName;await o.onSessionDelete(a),s!==void 0&&untrackActiveSandboxHandle({handle:o,providerName:s,sessionId:e.sessionId}),n=void 0,r=void 0,t=null,i=void 0},async detach(){i!==void 0&&await i.catch(()=>void 0);let t=n;if(t!==void 0)return untrackActiveSandboxHandle({handle:t.handle,providerName:t.providerName,sessionId:e.sessionId}),n=void 0,r=void 0,i=void 0,t.handle},async get(){return await requireHandle(),n?.sandbox??null},async stop(){await(await requireHandle()).onSessionStop(),n=void 0,r=void 0,i=void 0}}}export{ensureSandboxAccess};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{loadCompiledManifest}from"#runtime/loaders/manifest.js";import{join,relative,resolve}from"node:path";import{toErrorMessage}from"#shared/errors.js";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{getSandboxEnvironmentRuntime}from"#shared/sandbox-environment.js";import{ROOT_RUNTIME_AGENT_NODE_ID,getResolvedRuntimeAgentNode}from"#runtime/graph.js";import{createSandboxProviderResources}from"#shared/sandbox-provider.js";import{writeSandboxPreparedArtifactsManifest}from"#runtime/sandbox/prepared-artifacts.js";import{
|
|
1
|
+
import{getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{loadCompiledManifest}from"#runtime/loaders/manifest.js";import{join,relative,resolve}from"node:path";import{resolveRuntimeCompilerArtifactPaths}from"#runtime/loaders/artifact-paths.js";import{toErrorMessage}from"#shared/errors.js";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{getSandboxEnvironmentRuntime}from"#shared/sandbox-environment.js";import{ROOT_RUNTIME_AGENT_NODE_ID,getResolvedRuntimeAgentNode}from"#runtime/graph.js";import{createSandboxProviderResources}from"#shared/sandbox-provider.js";import{writeSandboxPreparedArtifactsManifest}from"#runtime/sandbox/prepared-artifacts.js";import{loadCompiledModuleMapFromAuthoredSource}from"#internal/authored-module-map-loader.js";import{createAuthoredSourceRuntimeCompiledArtifactsSource}from"#internal/application/runtime-compiled-artifacts-source.js";import{resolveRuntimeAgentGraph}from"#runtime/resolve-agent-graph.js";import{createSandboxProviderFiles}from"#execution/sandbox/provider-files.js";import{createDevelopmentSandboxProviderHost}from"#execution/sandbox/provider-host-development.js";import{materializeWorkspaceDirectory}from"#runtime/workspace/seed-files.js";const diskPreparedArtifactStore={async write(e){await writeSandboxPreparedArtifactsManifest(e)}};async function prewarmSandboxes(e){let t=await collectPrewarmTargets(e);if(t.length===0)return;let n=e.preparedArtifactStore??diskPreparedArtifactStore,r=e.dispatch??(async({context:e,provider:t})=>await t.implementation.prepare(e));e.log?.(`eve: initializing ${formatSandboxTemplateCount(t.length)}...`);let i=await Promise.allSettled(t.map(async({context:t,label:n,nodeId:i,provider:a})=>{let logProviderProgress=t=>{shouldLogSandboxPrewarmProgress(t)&&e.log?.(`eve: sandbox template "${n}" (${a.providerName}): ${t}`)};try{return{nodeId:i,provider:a,result:await r({context:{...t,log:e.log===void 0?void 0:logProviderProgress},provider:a})}}catch(t){let r=formatPrewarmFailureForEnvironment({providerName:a.providerName,error:t});throw e.log?.(`eve: failed to initialize sandbox template "${n}" on provider "${a.providerName}": ${toErrorMessage(r)}`),r}})),a=i.find(e=>e.status===`rejected`);if(a?.status===`rejected`)throw a.reason;let o=i.flatMap(e=>e.status===`fulfilled`?[{artifact:e.value.result,nodeId:e.value.nodeId,providerName:e.value.provider.providerName}]:[]);await n.write({compileDirectoryPath:e.compileDirectoryPath,entries:o}),e.log?.(`eve: initialized ${formatSandboxTemplateCount(t.length)}.`)}async function prewarmAppSandboxes(e){let t=e.compiledArtifactsSource??createAuthoredSourceRuntimeCompiledArtifactsSource(e.appRoot);if(t.kind!==`disk`)throw Error(`prewarmAppSandboxes requires disk-backed compiled artifacts.`);let n=await(e.loadAgentGraph??loadGraphFromArtifacts)({compiledArtifactsSource:t});await prewarmSandboxes({appRoot:getRuntimeCompiledArtifactsSandboxAppRoot(t)??e.appRoot,compileDirectoryPath:resolveRuntimeCompilerArtifactPaths(t.appRoot).compileDirectoryPath,compiledArtifactsSource:t,dispatch:e.dispatch,graph:n,log:e.log,preparedArtifactStore:e.preparedArtifactStore})}async function collectPrewarmTargets(e){let t=[];return await Promise.all(collectNodeSandboxes(e.graph).map(async({definition:n,nodeId:r,workspaceResourceRoot:i})=>{let a=getResolvedRuntimeAgentNode(e.graph,r).agent,o=join(resolve(e.appRoot,relative(a.metadata.appRoot,a.metadata.agentRoot)),`sandbox`),s=getSandboxEnvironmentRuntime(n.environment),c=await loadResourceRootSeedFiles({compileDirectoryPath:e.compileDirectoryPath,workspaceResourceRoot:i});t.push({context:{files:createSandboxProviderFiles(o),host:createDevelopmentSandboxProviderHost(e.appRoot),resources:createSandboxProviderResources({resourcesKey:i.contentHash,resourcesPath:i.contentHash===void 0?void 0:`${e.compileDirectoryPath}/${i.logicalPath}`,seedFiles:c}),sourceRevision:n.revisionHash,storagePath:resolveSandboxCacheDirectory(e.appRoot)},label:formatLabel(r),nodeId:r,provider:s})})),t.sort((e,t)=>e.label.localeCompare(t.label))}async function loadResourceRootSeedFiles(e){return e.workspaceResourceRoot.contentHash===void 0&&e.workspaceResourceRoot.rootEntries.length===0?[]:(await materializeWorkspaceDirectory(`${e.compileDirectoryPath}/${e.workspaceResourceRoot.logicalPath}`)).map(e=>({content:e.content,path:e.path}))}async function loadGraphFromArtifacts(e){let[t,n]=await Promise.all([loadCompiledManifest({compiledArtifactsSource:e.compiledArtifactsSource}),loadCompiledModuleMapFromAuthoredSource({compiledArtifactsSource:e.compiledArtifactsSource})]);return await resolveRuntimeAgentGraph({manifest:t,moduleMap:n})}function collectNodeSandboxes(e){return[...e.nodesByNodeId.entries()].flatMap(([e,t])=>{let n=t.sandboxRegistry.sandbox;return n.definition.kind===`parent`?[]:[{...n,definition:n.definition,nodeId:e}]})}function formatLabel(e){return e===ROOT_RUNTIME_AGENT_NODE_ID?`root`:e}function formatSandboxTemplateCount(e){return`${e} sandbox ${e===1?`template`:`templates`}`}function shouldLogSandboxPrewarmProgress(e){return!e.startsWith(`checking `)&&!e.startsWith(`reusing `)&&e!==`loading microsandbox runtime`&&e!==`microsandbox runtime ready`}function formatPrewarmFailureForEnvironment(e){return!isVercelEnvironment()||!isLocalSandboxProvider(e.providerName)?e.error:Error(`The ${e.providerName} sandbox provider is not available when deploying on Vercel. Vercel build containers cannot run local Docker containers or microsandbox VMs. Use DefaultSandbox.environment() so eve selects Vercel Sandbox on Vercel, or configure VercelSandbox.environment() explicitly. Original ${e.providerName} error: ${toErrorMessage(e.error)}`,{cause:e.error})}function isVercelEnvironment(){return!!process.env.VERCEL?.trim()}function isLocalSandboxProvider(e){return e===`docker`||e===`microsandbox`}export{prewarmAppSandboxes};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeliverHookPayload, TurnCaller } from "#channel/types.js";
|
|
2
2
|
import { type SteeringOptions } from "#execution/session/input-queue.js";
|
|
3
3
|
import type { SessionExecutionInput } from "#execution/session/turn.js";
|
|
4
|
+
import { type TurnControl } from "#execution/session/turn-control.js";
|
|
4
5
|
import type { WorkflowToolRunMessage } from "#execution/tools/workflow/messages.js";
|
|
5
6
|
import type { RuntimeActionResult } from "#shared/action-types.js";
|
|
6
7
|
export type RuntimeEvent = {
|
|
@@ -53,7 +54,7 @@ export declare class ActiveTurn {
|
|
|
53
54
|
constructor(input: SessionExecutionInput, owner: {
|
|
54
55
|
readonly caller: TurnCaller | undefined;
|
|
55
56
|
readonly principal: string;
|
|
56
|
-
});
|
|
57
|
+
}, control?: TurnControl);
|
|
57
58
|
private readonly signalSteering;
|
|
58
59
|
get signal(): AbortSignal;
|
|
59
60
|
dispose(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{coalesceDeliveries}from"#harness/messages.js";import{activeTurnId,storedProjection,turnPosition}from"#harness/session-machine/view.js";import{readDurableSession}from"#execution/durable-session-read.js";import{mapHeldInputResponsesStep}from"#execution/proxied-deliver-step.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{admitSessionInboxPayload}from"#execution/session/admission.js";import{isSteeringDelivery,isSteeringMessage}from"#execution/session/input-queue.js";import{routeSelectedDelivery}from"#execution/session/route-selected-delivery.js";import{decodeSessionInboxPayload}from"#execution/session-inbox/protocol.js";import{TurnCancelledError}from"#harness/turn-cancellation.js";var ActiveTurn=class{admitted=new Set;routedToChildren=new Set;mappedForHeldRequest=new Set;runtimeResults=[];controller
|
|
1
|
+
import{coalesceDeliveries}from"#harness/messages.js";import{activeTurnId,storedProjection,turnPosition}from"#harness/session-machine/view.js";import{readDurableSession}from"#execution/durable-session-read.js";import{mapHeldInputResponsesStep}from"#execution/proxied-deliver-step.js";import{routeDeliverToChildren}from"#execution/route-child-delivery.js";import{admitSessionInboxPayload}from"#execution/session/admission.js";import{isSteeringDelivery,isSteeringMessage}from"#execution/session/input-queue.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{TurnCancelledError}from"#harness/turn-cancellation.js";var ActiveTurn=class{admitted=new Set;routedToChildren=new Set;mappedForHeldRequest=new Set;runtimeResults=[];controller;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.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`&&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(){let e=this.input.inbox.drain();for(let t of e)await this.admit(t)}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&&i.kind!==e?n.push(r):t.push(i)}return this.runtimeResults.splice(0,this.runtimeResults.length,...n),t}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 takeInputResponses(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.inputResponses??[]);if(r.length===0)continue;if(!r.some(t=>e.has(t.requestId))){if(this.mappedForHeldRequest.has(t))continue;this.mappedForHeldRequest.add(t);let r=n,i=await this.input.cursor.advance(t=>mapHeldInputResponsesStep({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`?!0:e.kind===`cancel`?e.turnId===void 0||e.turnId===this.expectedTurnId:!1}async admit(e){let t=await admitSessionInboxPayload(e,this.input);switch(t.kind){case`delivery`:return this.admitted.add(t.admission.sequence),!0;case`runtime-action-result`:return this.runtimeResults.push({kind:`runtime-action-result`,results:t.payload.results}),!1;case`workflow`:return this.runtimeResults.push({kind:`workflow`,message:t.message}),!1;case`cancel`:return this.cancelsThisTurn(e)&&this.abort(),!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}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||e.message.kind===`agent-started`))return e.message}function splitAnswers(e){let t=e.payloads.flatMap(e=>e.inputResponses===void 0?[]:[{inputResponses:e.inputResponses}]),n=e.payloads.flatMap(e=>{let{inputResponses:t,...n}=e;return Object.keys(n).length===0?[]:[n]});return{answers:{...e,payloads:t},rest:n.length===0?void 0:{...e,payloads:n}}}export{ActiveTurn};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type SessionBoot } from "#execution/session/program.js";
|
|
2
|
+
import { type SessionInboxHandle } from "#execution/session-inbox/inbox.js";
|
|
3
|
+
import type { InitialWorkflowEntryInput, WorkflowEntryInput, WorkflowEntryResult } from "#execution/session/entry-input.js";
|
|
2
4
|
/**
|
|
3
5
|
* Long-lived workflow entrypoint. Handles both root sessions and
|
|
4
6
|
* delegated child sessions: root sessions expose only parent
|
|
@@ -11,3 +13,10 @@ import type { WorkflowEntryInput, WorkflowEntryResult } from "#execution/session
|
|
|
11
13
|
* original run remains parked as the public stream anchor.
|
|
12
14
|
*/
|
|
13
15
|
export declare function workflowEntry(input: WorkflowEntryInput): Promise<WorkflowEntryResult>;
|
|
16
|
+
interface BootOutcome {
|
|
17
|
+
readonly inbox: SessionInboxHandle;
|
|
18
|
+
readonly session: SessionBoot;
|
|
19
|
+
}
|
|
20
|
+
/** Returns `undefined` when a competing continuation owner already exists. */
|
|
21
|
+
export declare function bootInitialOwner(input: InitialWorkflowEntryInput, sessionId: string): Promise<BootOutcome | undefined>;
|
|
22
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{SESSION_INBOX_CONTEXT_KEY,sessionCommandHookToken}from"#execution/session-inbox/address.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{DEFAULT_SESSION_TIMEOUT_MS,sessionTimeoutDeadline}from"#execution/session/timeout.js";import{sessionHookTokens}from"#execution/session/hook-tokens.js";import{createSessionInbox}from"#execution/session-inbox/inbox.js";import{failSession,runPreparedSession}from"#execution/session/program.js";import{hasDelegatedSessionContext}from"#execution/delegated-session-context.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleContinuationConflictStep}from"#execution/continuation-conflict-step.js";import{signalSessionOwnerActivationStep,stopUntrackedChildSessionsStep,validateSessionCheckpointStep}from"#execution/session/handoff-steps.js";import{migrateSessionCheckpoint}from"#execution/session/checkpoint-migrations.js";async function workflowEntry(e){"use workflow";let t=e.kind===`initial`?await bootInitialOwner(e,getWorkflowMetadata().workflowRunId):await bootHandoffOwner(e);return t===void 0?{output:``}:{output:(await runPreparedSession(t.session,t.inbox)).output}}function stampSessionIdentity(e,t){return{...e,"eve.sessionId":t,[SESSION_INBOX_CONTEXT_KEY]:{sessionId:t}}}async function bootInitialOwner(e,t){let n=stampSessionIdentity(e.serializedContext,t),r=getWritable(),i=createSessionInbox(t),{workflowStartedAt:a}=getWorkflowMetadata(),o=e.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS,s=n[`eve.continuationToken`]||``,
|
|
1
|
+
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{SESSION_INBOX_CONTEXT_KEY,sessionCommandHookToken}from"#execution/session-inbox/address.js";import{readSerializedSessionSchedule}from"#context/session-schedule.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{DEFAULT_SESSION_TIMEOUT_MS,sessionTimeoutDeadline}from"#execution/session/timeout.js";import{sessionHookTokens}from"#execution/session/hook-tokens.js";import{createSessionInbox}from"#execution/session-inbox/inbox.js";import{failSession,runPreparedSession}from"#execution/session/program.js";import{createSessionTimeoutControl}from"#execution/session/timeout-control.js";import{hasDelegatedSessionContext}from"#execution/delegated-session-context.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{createTurnControl}from"#execution/session/turn-control.js";import{resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleContinuationConflictStep}from"#execution/continuation-conflict-step.js";import{signalSessionOwnerActivationStep,stopUntrackedChildSessionsStep,validateSessionCheckpointStep}from"#execution/session/handoff-steps.js";import{migrateSessionCheckpoint}from"#execution/session/checkpoint-migrations.js";async function workflowEntry(e){"use workflow";let t=e.kind===`initial`?await bootInitialOwner(e,getWorkflowMetadata().workflowRunId):await bootHandoffOwner(e);return t===void 0?{output:``}:{output:(await runPreparedSession(t.session,t.inbox)).output}}function stampSessionIdentity(e,t){return{...e,"eve.sessionId":t,[SESSION_INBOX_CONTEXT_KEY]:{sessionId:t}}}async function prepareInitialOwner(e,t){let[n,r]=await Promise.allSettled([e.claimSessionHook(sessionCommandHookToken(t.sessionId)),t.continuationToken===``?Promise.resolve():e.claimSessionHook(t.continuationToken)]);if(n.status===`rejected`)throw n.reason;if(r.status===`rejected`){if(isHookConflictError(r.reason))return{kind:`alias-conflict`};throw r.reason}let i=createTurnControl(),a=t.deadline===void 0?void 0:createSessionTimeoutControl({deadline:t.deadline,sessionId:t.sessionId}),o={kind:`owned`,timeoutControl:a,turnControl:i,async dispose(){i.dispose(),await a?.dispose()}};return a?.start().catch(()=>{}),o}function unwrapSettled(e){if(e.status===`rejected`)throw e.reason;return e.value}async function disposeInitialBoot(e,t){let[n,r]=await Promise.allSettled([t?.dispose(),e.dispose()]);if(n.status===`rejected`)throw n.reason;if(r.status===`rejected`)throw r.reason}async function bootInitialOwner(e,t){let n=stampSessionIdentity(e.serializedContext,t),r=getWritable(),i=createSessionInbox(t),{workflowStartedAt:a}=getWorkflowMetadata(),o=e.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS,s=sessionTimeoutDeadline(o,a.getTime()),c=n[`eve.continuationToken`]||``,l=n[`eve.bundle`],u;try{let a=createSessionStep({compiledArtifactsSource:l.source,continuationToken:c,dynamicSubagentAgentConfig:n[`eve.dynamicSubagentAgentConfig`],inheritedLimits:e.limits,nodeId:l.nodeId,outputSchema:e.input.outputSchema,rootSessionId:readRootSessionId(n),sessionId:t}),d=prepareInitialOwner(i,{continuationToken:c,deadline:s,sessionId:t}),f=hasDelegatedSessionContext(n)?resolveInitialTurnCallerStep({serializedContext:n}):Promise.resolve(void 0),[p,m,h]=await Promise.allSettled([a,d,f]);m.status===`fulfilled`&&m.value.kind===`owned`&&(u=m.value);let g=unwrapSettled(p),_=unwrapSettled(m);if(_.kind===`alias-conflict`){e.continuationConflictCommand!==void 0&&await settleContinuationConflictStep({command:e.continuationConflictCommand,continuationToken:c}),await disposeInitialBoot(i,u);return}return{inbox:i,session:{anchor:{kind:`self`},caller:unwrapSettled(h),capabilities:n[`eve.capabilities`],deploymentId:e.ownerDeploymentId,history:g.history,start:e.input.message===void 0?{kind:`first-message`}:{input:createInitialDelivery(e,n),kind:`turn`},initialTurnControl:_.turnControl,retention:e.retention,serializedContext:n,sessionId:t,sessionState:g.state,sessionTimeoutControl:_.timeoutControl,sessionTimeoutMs:o,sessionTimeoutDeadline:s,sessionWritable:r}}}catch(e){return await disposeInitialBoot(i,u),await failSession({error:e,serializedContext:n,sessionId:t,sessionState:void 0,sessionWritable:r})}}async function bootHandoffOwner(e){let{sessionId:t}=e,n=createSessionInbox(t),r,i,a;try{let o=migrateSessionCheckpoint(e.checkpoint),s=await validateSessionCheckpointStep({migration:o,sessionId:t});if(o.kind===`incompatible`||s.kind===`incompatible`){let t=await n.release();await signalSessionOwnerActivationStep({activation:{kind:`incompatible`,payloads:t,reason:`checkpoint-version`},token:e.activationToken});return}({checkpoint:r,childRunIdsToStop:i}=o),a=stampSessionIdentity(r.serializedContext,t),await n.claimSessionHooks(sessionHookTokens({serializedContext:a,sessionState:r.sessionState})),await signalSessionOwnerActivationStep({activation:{kind:`active`},token:e.activationToken})}catch(t){let r=await n.release();await signalSessionOwnerActivationStep({activation:{error:normalizeSerializableError(t),kind:`failed`,payloads:r},token:e.activationToken});return}i.length>0&&await stopUntrackedChildSessionsStep({runIds:i,sessionId:t});let o=e.reason===`compaction`?e.sessionTimeoutDeadline:sessionTimeoutDeadline(r.sessionTimeoutMs,Date.now()),s=o===void 0?void 0:createSessionTimeoutControl({deadline:o,sessionId:t});return{inbox:n,session:{anchor:{kind:`successor`},caller:e.delivery?.caller,capabilities:r.capabilities,deploymentId:e.ownerDeploymentId,history:r.history,start:e.delivery===void 0?{kind:`parked`}:{input:e.delivery,kind:`turn`},retention:r.retention,serializedContext:a,sessionId:t,sessionState:r.sessionState,sessionTimeoutControl:s,sessionTimeoutMs:r.sessionTimeoutMs,sessionTimeoutDeadline:o,sessionWritable:e.sessionWritable}}}function createInitialDelivery(e,t){if(e.input.message!==void 0)return{schedule:readSerializedSessionSchedule(t),deliveryMetadata:t[`eve.channelDelivery`]===void 0?void 0:[{...t[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[attachClientContext({message:e.input.message,context:e.input.context,outputSchema:e.input.outputSchema,state:e.input.state},readClientContext(e.input))],requestId:readChannelRequestId(t)}}workflowEntry.workflowId=`workflow//eve//workflowEntry`;export{bootInitialOwner,workflowEntry};
|
|
@@ -2,7 +2,9 @@ import type { DeliverHookPayload, SessionCapabilities, TurnCaller } from "#chann
|
|
|
2
2
|
import type { AgentWorkflowRetentionDefinition } from "#shared/agent-definition.js";
|
|
3
3
|
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
4
4
|
import type { HarnessModelMessage } from "#harness/messages.js";
|
|
5
|
+
import { type TurnControl } from "#execution/session/turn-control.js";
|
|
5
6
|
import { type SessionInboxHandle } from "#execution/session-inbox/inbox.js";
|
|
7
|
+
import type { SessionTimeoutControl } from "#execution/session/timeout-control.js";
|
|
6
8
|
import type { WorkflowEntryResult } from "#execution/session/entry-input.js";
|
|
7
9
|
/**
|
|
8
10
|
* Who to tell when this owner exits. The original run anchors the public
|
|
@@ -37,11 +39,13 @@ export interface SessionBoot {
|
|
|
37
39
|
readonly capabilities?: SessionCapabilities;
|
|
38
40
|
readonly deploymentId: string;
|
|
39
41
|
readonly history: HarnessModelMessage[];
|
|
42
|
+
readonly initialTurnControl?: TurnControl;
|
|
40
43
|
readonly start: SessionStart;
|
|
41
44
|
readonly retention?: AgentWorkflowRetentionDefinition;
|
|
42
45
|
readonly serializedContext: Record<string, unknown>;
|
|
43
46
|
readonly sessionId: string;
|
|
44
47
|
readonly sessionState: DurableSessionState;
|
|
48
|
+
readonly sessionTimeoutControl?: SessionTimeoutControl;
|
|
45
49
|
readonly sessionTimeoutDeadline?: Date;
|
|
46
50
|
readonly sessionTimeoutMs: number | false;
|
|
47
51
|
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{workingTasks}from"#execution/tasks/table.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import"#execution/session-inbox/inbox.js";import{SessionInputQueue}from"#execution/session/input-queue.js";import{SessionHandoff,sessionAnchorToken}from"#execution/session/handoff.js";import{notifyCancelledTaskCallerStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{signalSessionAnchorStep}from"#execution/session/handoff-steps.js";import{nextTurnDelivery}from"#execution/session/next-input.js";import{SessionExecution}from"#execution/session/turn.js";import{SessionStateCursor}from"#execution/session/state-cursor.js";import{cancelWorkingTasks,sessionTaskTable}from"#execution/tasks/session.js";import{finalizeSession}from"#execution/session/finalization.js";
|
|
1
|
+
import{workingTasks}from"#execution/tasks/table.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import"#execution/session-inbox/inbox.js";import{SessionInputQueue}from"#execution/session/input-queue.js";import{createTurnControl}from"#execution/session/turn-control.js";import{SessionHandoff,sessionAnchorToken}from"#execution/session/handoff.js";import{notifyCancelledTaskCallerStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#subagents/parent-notification.js";import{signalSessionAnchorStep}from"#execution/session/handoff-steps.js";import{nextTurnDelivery}from"#execution/session/next-input.js";import{SessionExecution}from"#execution/session/turn.js";import{SessionStateCursor}from"#execution/session/state-cursor.js";import{cancelWorkingTasks,sessionTaskTable}from"#execution/tasks/session.js";import{finalizeSession}from"#execution/session/finalization.js";function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runPreparedSession(e,t){let n=new SessionStateCursor({history:e.history,inbox:t,sessionWritable:e.sessionWritable,serializedContext:e.serializedContext,sessionState:e.sessionState}),r={caller:e.caller,terminalEmitted:!1},i=new SessionHandoff({checkpoint:{capabilities:e.capabilities,retention:e.retention,sessionTimeoutMs:e.sessionTimeoutMs},deploymentId:e.deploymentId,inbox:t,isInitialOwner:e.anchor.kind===`self`,sessionId:e.sessionId}),a={output:``,isError:!0},o;try{try{o=await runSessionLoop(e,{cursor:n,handoff:i,inbox:t,progress:r})}finally{await t.dispose()}return o.kind===`transferred`?e.anchor.kind===`self`?(a=await i.awaitAnchoredResult(),a):{output:``}:(a=await finalizeSession(o.outcome,{caller:r.caller,cursor:n,sessionWritable:e.sessionWritable}),r.terminalEmitted=!0,a)}catch(t){throw r.terminalEmitted||await finalizeSession({error:t,kind:`failed`,turnId:r.turnId},{caller:r.caller,cursor:n,sessionWritable:e.sessionWritable}),createSafeOuterWorkflowError()}finally{await reportResultToAnchor(e,a,i,o)}}async function failSession(e){let t;try{t=await resolveInitialTurnCallerStep({serializedContext:e.serializedContext})}catch{}throw await finalizeSession({error:e.error,kind:`failed`},{caller:t,cursor:{serializedContext:e.serializedContext,sessionState:e.sessionState},sessionWritable:e.sessionWritable}),createSafeOuterWorkflowError()}async function reportResultToAnchor(e,t,n,r){switch(e.anchor.kind){case`self`:await n.disposeAnchor(),await e.anchor.notify?.(t);return;case`successor`:if(r?.kind===`transferred`)return;await signalSessionAnchorStep({result:t,token:sessionAnchorToken(e.sessionId)});return}}async function runSessionLoop(e,t){let{cursor:n,handoff:r,inbox:i,progress:a}=t,o=new SessionInputQueue,s=new SessionExecution({capabilities:e.capabilities,cursor:n,inbox:i,queue:o,sessionId:e.sessionId}),c=e.sessionTimeoutControl,nextParkedActivity=async()=>{for(;;){let e=await nextTurnDelivery({cursor:n,hasWorkingTasks:()=>workingTasks(sessionTaskTable(n)).length>0,inbox:i,queue:o});if(e.kind===`workflow`){await s.handleWorkflowMessage(e.message);continue}if(e.kind===`cancel-working-tasks`){await cancelWorkingTasks(n,`turn_cancelled`);continue}return e}},l=e.initialTurnControl??(e.anchor.kind===`self`?createTurnControl():void 0),u=0,d=!1,runTurn=async e=>{let t=a.caller,n=l;l=void 0,a.turnId=`turn_${String(u++)}`;let r=await s.runTurn(e,{caller:t,control:n});return r.caller!==void 0&&(a.caller=r.caller),r.compacted===!0&&(d=!0),r},transferState=()=>({history:n.history,serializedContext:n.serializedContext,sessionState:n.sessionState}),dueCompactionHandoff=()=>d&&a.caller===void 0&&workingTasks(sessionTaskTable(n)).length===0?{sessionTimeoutDeadline:e.sessionTimeoutDeadline}:void 0,tryCompactionHandoff=async()=>{let e=dueCompactionHandoff();if(e===void 0||o.pendingCount>0||i.hasPending())return;let t=await r.tryCompactionTransfer(transferState(),e);return t.kind===`transferred`?t:void 0},runDeliveredTurn=async e=>{let t=await r.tryTransfer(e,transferState(),{compaction:dueCompactionHandoff()});return t.kind===`transferred`?t:(e.delivery.caller!==void 0&&(a.caller=e.delivery.caller),{action:await runTurn({delivery:e.delivery}),kind:`action`})},settleCancelledTurn=async e=>{let t=await n.advanceWithHistory(t=>settleCancelledTurnStep({...t,reportUsage:e}));return a.caller=void 0,t},awaitPrewarmedAction=async()=>{for(;;){let e=await nextParkedActivity();switch(e.kind){case`expired`:case`reset`:case`closed`:return{kind:`terminal`,outcome:{kind:`expired`}};case`clear`:case`compact`:continue;case`turn`:return await runDeliveredTurn(e);case`cancel-turn`:continue}}},runInitialAction=async()=>{switch(e.start.kind){case`first-message`:return await awaitPrewarmedAction();case`parked`:return{action:{kind:`park`},kind:`action`};case`turn`:{let{input:t}=e.start;return{action:await runTurn(t===void 0?void 0:{delivery:t}),kind:`action`}}}};try{let[t,n]=await Promise.allSettled([runInitialAction(),c?.start()]);if(n.status===`rejected`)throw n.reason;if(t.status===`rejected`)throw t.reason;let r=t.value;if(r.kind!==`action`)return r;let i=r.action;for(;;){if(i.kind===`done`)return{kind:`terminal`,outcome:{action:i,kind:`done`}};if(i.cancelled===!0){let{caller:t}=a,n=await settleCancelledTurn(t!==void 0);if(t!==void 0){let r={caller:t,sessionId:e.sessionId};await notifyCancelledTaskCallerStep(n.usage===void 0?r:{...r,usage:n.usage})}}else i.settled!==void 0&&(a.caller!==void 0&&await notifyTurnCallerStep({caller:a.caller,lifecycle:`parked`,sessionId:e.sessionId,settled:i.settled}),a.caller=void 0);let t=await tryCompactionHandoff();if(t!==void 0)return t;let n=await nextParkedActivity();switch(n.kind){case`expired`:case`reset`:case`closed`:return{kind:`terminal`,outcome:{kind:`expired`}};case`clear`:case`compact`:i=await runTurn({control:n.kind});continue;case`cancel-turn`:await s.cancelTurnWork(),await settleCancelledTurn(!1),i={...i,settled:void 0};continue;case`turn`:{let e=await runDeliveredTurn(n);if(e.kind!==`action`)return e;i=e.action;continue}}}}finally{l?.dispose(),await c?.dispose()}}export{failSession,runPreparedSession};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Workflow-body handle that targets a durable deadline at the stable command inbox. */
|
|
2
|
-
interface SessionTimeoutControl {
|
|
2
|
+
export interface SessionTimeoutControl {
|
|
3
3
|
dispose(): Promise<void>;
|
|
4
4
|
start(): Promise<void>;
|
|
5
5
|
}
|
|
@@ -8,4 +8,3 @@ export declare function createSessionTimeoutControl(input: {
|
|
|
8
8
|
readonly deadline: Date;
|
|
9
9
|
readonly sessionId: string;
|
|
10
10
|
}): SessionTimeoutControl;
|
|
11
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sessionCommandHookToken}from"#execution/session-inbox/address.js";import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{cancelSessionTimeoutStep,startSessionTimeoutStep}from"#execution/session/timeout-steps.js";function createSessionTimeoutControl(e){let t;return{async dispose(){if(t===void 0)return;let e=t;t=void 0,await cancelSessionTimeoutStep({runId:e.runId})},async start(){
|
|
1
|
+
import{sessionCommandHookToken}from"#execution/session-inbox/address.js";import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{cancelSessionTimeoutStep,startSessionTimeoutStep}from"#execution/session/timeout-steps.js";function createSessionTimeoutControl(e){let t,n;return{async dispose(){try{await n}catch{}if(t===void 0)return;let e=t;t=void 0,await cancelSessionTimeoutStep({runId:e.runId})},async start(){n??=(async()=>{t=await startSessionTimeoutStep({deadline:e.deadline,ownerRunId:getWorkflowMetadata().workflowRunId,token:sessionCommandHookToken(e.sessionId)})})(),await n}}}export{createSessionTimeoutControl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function createTurnControl(){let e=new AbortController,t=new AbortController;return{cancellation:e,steering:t,dispose(){e.abort(),t.abort()}}}export{createTurnControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defaultDeliverResult}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{AuthKey,CapabilitiesKey,ChannelDeliveryKey,HandleEventKey,InitiatorAuthKey,ParentSessionKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey,SessionTitleKey,StaticModelReferenceKey,TurnDeliveryIdsKey}from"#context/keys.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{coalesceTurnInputs,validateHarnessModelMessages}from"#harness/messages.js";import{activeTurnId,isBetweenTurns,turnPosition}from"#harness/session-machine/view.js";import{currentProjection,enterSessionProjection,saveSessionProjection}from"#harness/session-machine/current.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{createDurableSessionValues,readDurableSession}from"#execution/durable-session-store.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import*as agentTraceState from"#tracing/agent-trace-context-store.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{openSessionEventPublisher}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{dropClosedRecords}from"#harness/session-machine/commit.js";import{sessionStartedForResolvers,turnStartedForResolvers}from"#harness/session-machine/resolver-events.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey,clearPendingAuthorization,getPendingAuthorization}from"#harness/authorization.js";import{derivePendingState}from"#execution/session/pending-turn-state.js";import{rebindMissingCompiledDynamicToolCallbacks,refreshDynamicSessionToolsForRuntimeRevision}from"#context/dynamic-tool-lifecycle.js";import{setChannelContext}from"#execution/channel-context.js";import{runStep}from"#context/run-step.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{bindSessionInstrumentation}from"#instrumentation/runtime.js";import{deriveSessionTitle}from"#execution/eve-workflow-attributes.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{bindTurnCallerContext}from"#subagents/parent-notification.js";import{bindDynamicConnections}from"#execution/dynamic-connections.js";import{setEveAttributes}from"#runtime/attributes/emit.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{attributeAnswers}from"#execution/session/answer-caller.js";import{resolveSessionStepResult}from"#execution/session/turn-step-result.js";import{createTurnEventHandler}from"#execution/session/turn-event-handler.js";import{countRunUsage}from"#execution/agent-sessions/usage.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{createExecutionHistoryView}from"#execution/history-view.js";import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";import{runModelCallBatch}from"#execution/model-call-batching.js";import{createCancelledModelCallBatchResult}from"#execution/cancelled-model-call-batch.js";function channelDeliveryErrorCode(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`&&t.length>0)return t}return`CHANNEL_DELIVERY_FAILED`}async function turnStep(e){"use step";return await withSessionStateDelta(e,e=>runSessionStep({...e,serializedContext:bindTurnCallerContext(e.caller,e.serializedContext)}))}async function runSessionStep(e){let t=e.input?.delivery,n=t,r=e.input?.runtimeResults,i=readDurableSession(e.sessionState);for(let e of r?.delegatedUsage??[])i=countRunUsage(i,e);let a=await deserializeContext(e.serializedContext);enterSessionProjection(a,i.state);let o=a.require(ChannelKey),s=a.require(BundleKey),c=resolveEffectiveAgentRuntime(s,a);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&a.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let l=getPendingAuthorization(i.state),u;if(l&&n!==void 0){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(l,n.payloads);if(n={...n,payloads:t},e.length>0){let r=e.map(e=>e.result.attemptId),o=e.map(e=>e.result);a.set(PendingAuthorizationResultKey,o),i={...i,state:clearPendingAuthorization(i.state,r)},u=e,t.length===0&&(n=void 0)}}let d=a.get(AuthKey),f=a.has(InitiatorAuthKey);n?.auth!==void 0&&(a.set(AuthKey,n.auth??null),a.has(InitiatorAuthKey)||a.set(InitiatorAuthKey,n.auth??null));let p=n===void 0?u?.find(({challenge:e})=>e.candidateId===void 0)?.challenge.requester:void 0;p!==void 0&&a.set(AuthKey,p);let m={...hydrateDurableSession({compactionOverrides:{thresholdPercent:c.thresholdPercent},durable:i,turnAgent:c.turnAgent}),history:validateHarnessModelMessages(e.history)},h=createExecutionHistoryView(m),g=bindSessionInstrumentation({agentName:c.turnAgent.id,ctx:a,rootSessionId:m.rootSessionId??m.sessionId,sessionId:m.sessionId}),_=turnPosition(currentProjection(a)),v=isBetweenTurns(currentProjection(a));if(!_.sessionStarted&&!a.has(SessionTitleKey)&&!a.has(ParentSessionKey)){let e=t?.payloads.find(e=>e.message!==void 0)?.message,n=deriveSessionTitle(t?.title??e);n!==void 0&&(a.set(SessionTitleKey,n),await setEveAttributes({"$eve.title":n}))}t!==void 0&&(await contextStorage.run(a,()=>g?.preparePreamble({sequence:_.sequence,sessionStarted:_.sessionStarted})),await contextStorage.run(a,()=>g?.instrumentChannelDelivery({agentName:s.turnAgent.id,ctx:a,delivery:t,rootSessionId:m.rootSessionId??m.sessionId,sequence:_.sequence,sessionId:m.sessionId,turnId:activeTurnId(_)})));let failChannelDeliveries=async e=>{await contextStorage.run(a,()=>g?.instrumentChannelDelivery({ctx:a,error:e,errorCode:channelDeliveryErrorCode(e),includeTurn:!1,outcome:`failed`})),await g?.flush()},y=openSessionEventPublisher({ctx:a,origin:`own`,sessionWritable:e.sessionWritable}),{adapterCtx:b}=y.dispatcher,x=new AbortController,S=e.abortSignal===void 0?x.signal:AbortSignal.any([e.abortSignal,x.signal]);try{let l=bindDynamicConnections(a,s.resolvedAgent),p={...s.graph.root,turnAgent:c.turnAgent},C=!1,w=createTurnEventHandler({abortSignal:S,bundle:s,canCancelTurn:e.input?.control===void 0,hookCancellation:x,ctx:a,dynamicConnections:l,effectiveAgent:c,effectiveNode:p,instrumentation:g,publisher:y}),handleEvent=async(e,t)=>{e.type===`compaction.completed`&&(C=!0),await w(e,t)},T=n!==void 0&&!v?structuredClone(b.state):void 0,E;if(n!==void 0){let e=[];try{for(let t of n.payloads){let n=o.deliver?await o.deliver(t,b):defaultDeliverResult(t);n!=null&&e.push(n)}}catch(e){throw await failChannelDeliveries(e),e}E=e.length===0?void 0:e.reduce(coalesceTurnInputs)}let D=n?.auth===void 0?void 0:attributeAnswers({responder:n.auth,state:i.state,stepInput:E});if(D!==void 0&&(E=D,d===void 0?a.delete(AuthKey):a.set(AuthKey,d),f||a.delete(InitiatorAuthKey)),n!==void 0&&E===void 0&&!v)d===void 0?a.delete(AuthKey):a.set(AuthKey,d),b.state=T;else if(t?.payloads.some(e=>e.message!==void 0)){let e=t.deliveryMetadata?.map(e=>e.deliveryId)??[];a.set(TurnDeliveryIdsKey,_.turnId?[...new Set([...a.get(TurnDeliveryIdsKey)??[],...e])]:e)}else!_.sessionStarted&&a.get(ChannelDeliveryKey)!==void 0&&a.set(TurnDeliveryIdsKey,[a.require(ChannelDeliveryKey).deliveryId]);if(r!==void 0&&(r.acceptedAtMsByCallId!==void 0&&a.set(RuntimeActionSettlementTimesKey,r.acceptedAtMsByCallId),E={...E,runtimeActionResults:r.results}),t!==void 0){let e={...o,state:{...b.state}};setChannelContext(a,e)}if(n!==void 0&&E===void 0&&v){await contextStorage.run(a,()=>g?.instrumentChannelDelivery({ctx:a,includeTurn:!1,outcome:`completed`})),await g?.flush();let t=saveSessionProjection(reconcileSessionContinuationToken(a,m),a),n=serializeContext(a),r=t===m?{history:e.history,sessionState:e.sessionState}:createDurableSessionValues(t);return{action:`park`,...derivePendingState(t,currentProjection(a)),serializedContext:n,...r}}let O=s.subagentRegistry.dynamicResolvers??[],k=s.resolvedAgent.dynamicToolResolvers??[],A=buildRuntimeIdentity(p);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(s.compiledArtifactsSource),n=_.sessionStarted;if(a.setVirtualContext(StaticModelReferenceKey,c.turnAgent.model??null),!n)a.set(SessionDynamicSubagentRuntimeRevisionKey,t),a.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=sessionStartedForResolvers(A);await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:a,resolvers:O,event:e,messages:h.initial.messages,runtimeRevision:t}),contextStorage.run(a,async()=>await refreshDynamicSessionToolsForRuntimeRevision({ctx:a,resolvers:k,event:e,messages:h.initial.messages,runtimeRevision:t}))]),v||await rebindMissingCompiledDynamicToolCallbacks({ctx:a,event:turnStartedForResolvers({sequence:_.sequence,turnId:activeTurnId(_)}),messages:h.initial.messages,resolvers:k})}}catch(e){throw await failChannelDeliveries(e),e}let j=s.resolvedAgent.config?.experimental?.workflow?.modelCallsPerStep??1,M=a.get(CapabilitiesKey),runHarnessStep=async(t,n,r)=>{let i=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:c.thresholdPercent},session:t,turnAgent:c.turnAgent});return createExecutionNodeStep({steeringSignal:e.steeringSignal,abortSignal:S,capabilities:M,clearOnly:e.input?.control===`clear`,compactOnly:e.input?.control===`compact`,createRuntime:createWorkflowRuntime,handleEvent,prepareApprovalTurn:e=>l.dispatch(turnStartedForResolvers(e)),signInCompletions:r,historyProjector:h.projector,historyView:h.prepare(i),instrumentation:g,modelResolutionScope:{moduleMap:s.moduleMap,nodeId:s.nodeId},node:p})(i,n)},N,P;try{throwIfTurnAborted(S),P=await runModelCallBatch({steeringSignal:e.steeringSignal,initialInput:E,initialSession:m,modelCallsPerStep:j,runStep:async({firstCall:e,session:t,stepInput:n})=>{let r=await runStep(a,t,async t=>{a.setVirtualContext(HandleEventKey,handleEvent),a.setVirtualContext(StaticModelReferenceKey,c.turnAgent.model??null);let r=e&&E?.outputSchema!==void 0?{...t,outputSchema:E.outputSchema}:t,i=turnPosition(currentProjection(a));await l.rehydrate(i,A,isBetweenTurns(currentProjection(a))?void 0:{sequence:i.sequence,turnId:activeTurnId(i)});let o=e&&u!==void 0?u.map(({challenge:e})=>e):void 0;return runHarnessStep(r,n,o)});r.settledTurn===void 0&&throwIfTurnAborted(S);let i={...r,session:saveSessionProjection(r.session,a)};return N={result:i,serializedContext:serializeContext(a)},i}})}catch(t){if(!isTurnCancellation(t)&&!S.aborted)throw await failChannelDeliveries(t),t;return createCancelledModelCallBatchResult({beforeBatchContext:e.serializedContext,checkpoint:N,ctx:a,initialSession:m,stepInput:E})}let F=saveSessionProjection(dropClosedRecords(reconcileSessionContinuationToken(a,P.session),currentProjection(a)),a);agentTraceState.pruneAgentTraceState(a,F.sessionId,F.state);let I=serializeContext(a);P={...P,session:F};let L=resolveSessionStepResult(P,I);return L.action===`done`&&await y.writer.close(),C?{...L,compacted:!0}:L}finally{y.writer.release()}}export{turnStep};
|
|
1
|
+
import{resolveRuntimeCompiledArtifactsVersionedCacheKey}from"#runtime/cache-key.js";import{defaultDeliverResult}from"#channel/adapter.js";import{contextStorage}from"#context/container.js";import{currentProjection,enterSessionProjection,saveSessionProjection}from"#harness/session-machine/current.js";import{AuthKey,CapabilitiesKey,ChannelDeliveryKey,HandleEventKey,InitiatorAuthKey,OccurrenceIdKey,ParentSessionKey,ScheduleIdKey,ScheduleInstanceKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicToolRuntimeRevisionKey,SessionTitleKey,StaticModelReferenceKey,TurnDeliveryIdsKey}from"#context/keys.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{coalesceTurnInputs,validateHarnessModelMessages}from"#harness/messages.js";import{activeTurnId,isBetweenTurns,turnPosition}from"#harness/session-machine/view.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{createDurableSessionValues,readDurableSession}from"#execution/durable-session-store.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import*as agentTraceState from"#tracing/agent-trace-context-store.js";import{hydrateDurableSession,refreshSessionFromTurnAgent}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{refreshDynamicSessionSubagentsForRuntimeRevision}from"#context/dynamic-subagent-lifecycle.js";import{openSessionEventPublisher}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{dropClosedRecords}from"#harness/session-machine/commit.js";import{sessionStartedForResolvers,turnStartedForResolvers}from"#harness/session-machine/resolver-events.js";import{CallbackBaseUrlKey,PendingAuthorizationResultKey,clearPendingAuthorization,getPendingAuthorization}from"#harness/authorization.js";import{derivePendingState}from"#execution/session/pending-turn-state.js";import{rebindMissingCompiledDynamicToolCallbacks,refreshDynamicSessionToolsForRuntimeRevision}from"#context/dynamic-tool-lifecycle.js";import{setChannelContext}from"#execution/channel-context.js";import{runStep}from"#context/run-step.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{bindSessionInstrumentation}from"#instrumentation/runtime.js";import{deriveSessionTitle}from"#execution/eve-workflow-attributes.js";import{isTurnCancellation,throwIfTurnAborted}from"#harness/turn-cancellation.js";import{bindTurnCallerContext}from"#subagents/parent-notification.js";import{bindDynamicConnections}from"#execution/dynamic-connections.js";import{setEveAttributes}from"#runtime/attributes/emit.js";import{RuntimeActionSettlementTimesKey}from"#harness/runtime-action-settlement-state.js";import{matchAuthorizationCallbacks}from"#execution/authorization-callback-match.js";import{attributeAnswers}from"#execution/session/answer-caller.js";import{resolveSessionStepResult}from"#execution/session/turn-step-result.js";import{createTurnEventHandler}from"#execution/session/turn-event-handler.js";import{countRunUsage}from"#execution/agent-sessions/usage.js";import{buildRuntimeIdentity,createExecutionNodeStep}from"#execution/node-step.js";import{createExecutionHistoryView}from"#execution/history-view.js";import{runModelCallBatch}from"#execution/model-call-batching.js";import{createCancelledModelCallBatchResult}from"#execution/cancelled-model-call-batch.js";function channelDeliveryErrorCode(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`&&t.length>0)return t}return`CHANNEL_DELIVERY_FAILED`}async function turnStep(e){"use step";return await withSessionStateDelta(e,e=>runSessionStep({...e,serializedContext:bindTurnCallerContext(e.caller,e.serializedContext)}))}async function runSessionStep(e){let t={};try{return await runSessionStepBody(e,t)}finally{await t.title}}async function runSessionStepBody(e,t){let n=e.input?.delivery,r=n,i=e.input?.runtimeResults,a=readDurableSession(e.sessionState);for(let e of i?.delegatedUsage??[])a=countRunUsage(a,e);let o=await deserializeContext(e.serializedContext);enterSessionProjection(o,a.state);let s=o.require(ChannelKey),c=o.require(BundleKey),l=resolveEffectiveAgentRuntime(c,o);try{let{getWorkflowMetadata:e}=await import(`#compiled/@workflow/core/index.js`),t=e();typeof t.url==`string`&&o.set(CallbackBaseUrlKey,resolveWorkflowCallbackBaseUrl(t.url))}catch{}let u=getPendingAuthorization(a.state),d;if(u&&r!==void 0){let{matches:e,remainingPayloads:t}=matchAuthorizationCallbacks(u,r.payloads);if(r={...r,payloads:t},e.length>0){let n=e.map(e=>e.result.attemptId),i=e.map(e=>e.result);o.set(PendingAuthorizationResultKey,i),a={...a,state:clearPendingAuthorization(a.state,n)},d=e,t.length===0&&(r=void 0)}}r?.payloads.some(e=>e.message!==void 0)&&(o.delete(ScheduleIdKey),o.delete(ScheduleInstanceKey),o.delete(OccurrenceIdKey),r.schedule!==void 0&&(o.set(ScheduleIdKey,r.schedule.definition),r.schedule.instance!==void 0&&o.set(ScheduleInstanceKey,r.schedule.instance),r.schedule.occurrenceId!==void 0&&o.set(OccurrenceIdKey,r.schedule.occurrenceId)));let f=o.get(AuthKey),p=o.has(InitiatorAuthKey);r?.auth!==void 0&&(o.set(AuthKey,r.auth??null),o.has(InitiatorAuthKey)||o.set(InitiatorAuthKey,r.auth??null));let m=r===void 0?d?.find(({challenge:e})=>e.candidateId===void 0)?.challenge.requester:void 0;m!==void 0&&o.set(AuthKey,m);let h={...hydrateDurableSession({compactionOverrides:{thresholdPercent:l.thresholdPercent},durable:a,turnAgent:l.turnAgent}),history:validateHarnessModelMessages(e.history)},g=createExecutionHistoryView(h),_=bindSessionInstrumentation({agentName:l.turnAgent.id,ctx:o,rootSessionId:h.rootSessionId??h.sessionId,sessionId:h.sessionId}),v=turnPosition(currentProjection(o)),y=isBetweenTurns(currentProjection(o));if(!v.sessionStarted&&!o.has(SessionTitleKey)&&!o.has(ParentSessionKey)){let e=n?.payloads.find(e=>e.message!==void 0)?.message,r=deriveSessionTitle(n?.title??e);r!==void 0&&(o.set(SessionTitleKey,r),t.title=setEveAttributes({"$eve.title":r}))}n!==void 0&&(await contextStorage.run(o,()=>_?.preparePreamble({sequence:v.sequence,sessionStarted:v.sessionStarted})),await contextStorage.run(o,()=>_?.instrumentChannelDelivery({agentName:c.turnAgent.id,ctx:o,delivery:n,rootSessionId:h.rootSessionId??h.sessionId,sequence:v.sequence,sessionId:h.sessionId,turnId:activeTurnId(v)})));let failChannelDeliveries=async e=>{await contextStorage.run(o,()=>_?.instrumentChannelDelivery({ctx:o,error:e,errorCode:channelDeliveryErrorCode(e),includeTurn:!1,outcome:`failed`})),await _?.flush()},b=openSessionEventPublisher({ctx:o,origin:`own`,sessionWritable:e.sessionWritable}),{adapterCtx:x}=b.dispatcher,S=new AbortController,C=e.abortSignal===void 0?S.signal:AbortSignal.any([e.abortSignal,S.signal]);try{let u=bindDynamicConnections(o,c.resolvedAgent),m={...c.graph.root,turnAgent:l.turnAgent},w=!1,T=createTurnEventHandler({abortSignal:C,bundle:c,canCancelTurn:e.input?.control===void 0,hookCancellation:S,ctx:o,dynamicConnections:u,effectiveAgent:l,effectiveNode:m,instrumentation:_,publisher:b}),handleEvent=async(e,t)=>{e.type===`compaction.completed`&&(w=!0),await T(e,t)},E=r!==void 0&&!y?structuredClone(x.state):void 0,D;if(r!==void 0){let e=[];try{for(let t of r.payloads){let n=s.deliver?await s.deliver(t,x):defaultDeliverResult(t);n!=null&&e.push(n)}}catch(e){throw await failChannelDeliveries(e),e}D=e.length===0?void 0:e.reduce(coalesceTurnInputs)}let O=r?.auth===void 0?void 0:attributeAnswers({responder:r.auth,state:a.state,stepInput:D});if(O!==void 0&&(D=O,f===void 0?o.delete(AuthKey):o.set(AuthKey,f),p||o.delete(InitiatorAuthKey)),r!==void 0&&D===void 0&&!y)f===void 0?o.delete(AuthKey):o.set(AuthKey,f),x.state=E;else if(n?.payloads.some(e=>e.message!==void 0)){let e=n.deliveryMetadata?.map(e=>e.deliveryId)??[];o.set(TurnDeliveryIdsKey,v.turnId?[...new Set([...o.get(TurnDeliveryIdsKey)??[],...e])]:e)}else!v.sessionStarted&&o.get(ChannelDeliveryKey)!==void 0&&o.set(TurnDeliveryIdsKey,[o.require(ChannelDeliveryKey).deliveryId]);if(i!==void 0&&(i.acceptedAtMsByCallId!==void 0&&o.set(RuntimeActionSettlementTimesKey,i.acceptedAtMsByCallId),D={...D,runtimeActionResults:i.results}),n!==void 0){let e={...s,state:{...x.state}};setChannelContext(o,e)}if(r!==void 0&&D===void 0&&y){await contextStorage.run(o,()=>_?.instrumentChannelDelivery({ctx:o,includeTurn:!1,outcome:`completed`})),await _?.flush();let t=saveSessionProjection(reconcileSessionContinuationToken(o,h),o),n=serializeContext(o),r=t===h?{history:e.history,sessionState:e.sessionState}:createDurableSessionValues(t);return{action:`park`,...derivePendingState(t,currentProjection(o)),serializedContext:n,...r}}let k=c.subagentRegistry.dynamicResolvers??[],A=c.resolvedAgent.dynamicToolResolvers??[],j=buildRuntimeIdentity(m);try{let e=process.env.VERCEL_DEPLOYMENT_ID?.trim(),t=e?`deployment:${e}`:await resolveRuntimeCompiledArtifactsVersionedCacheKey(c.compiledArtifactsSource),n=v.sessionStarted;if(o.setVirtualContext(StaticModelReferenceKey,l.turnAgent.model??null),!n)o.set(SessionDynamicSubagentRuntimeRevisionKey,t),o.set(SessionDynamicToolRuntimeRevisionKey,t);else{let e=sessionStartedForResolvers(j);await Promise.all([refreshDynamicSessionSubagentsForRuntimeRevision({ctx:o,resolvers:k,event:e,messages:g.initial.messages,runtimeRevision:t}),contextStorage.run(o,async()=>await refreshDynamicSessionToolsForRuntimeRevision({ctx:o,resolvers:A,event:e,messages:g.initial.messages,runtimeRevision:t}))]),y||await rebindMissingCompiledDynamicToolCallbacks({ctx:o,event:turnStartedForResolvers({sequence:v.sequence,turnId:activeTurnId(v)}),messages:g.initial.messages,resolvers:A})}}catch(e){throw await failChannelDeliveries(e),e}let M=c.resolvedAgent.config?.experimental?.workflow?.modelCallsPerStep??1,N=o.get(CapabilitiesKey),runHarnessStep=async(n,r,i)=>{let a=refreshSessionFromTurnAgent({compactionOverrides:{thresholdPercent:l.thresholdPercent},session:n,turnAgent:l.turnAgent});return createExecutionNodeStep({steeringSignal:e.steeringSignal,abortSignal:C,capabilities:N,clearOnly:e.input?.control===`clear`,compactOnly:e.input?.control===`compact`,createRuntime:createWorkflowRuntime,handleEvent,prepareApprovalTurn:e=>u.dispatch(turnStartedForResolvers(e)),signInCompletions:i,historyProjector:g.projector,historyView:g.prepare(a),instrumentation:_,modelResolutionScope:{moduleMap:c.moduleMap,nodeId:c.nodeId},node:m,titleAttributeWrite:t.title})(a,r)},P,F;try{throwIfTurnAborted(C),F=await runModelCallBatch({steeringSignal:e.steeringSignal,initialInput:D,initialSession:h,modelCallsPerStep:M,runStep:async({firstCall:e,session:t,stepInput:n})=>{let r=await runStep(o,t,async t=>{o.setVirtualContext(HandleEventKey,handleEvent),o.setVirtualContext(StaticModelReferenceKey,l.turnAgent.model??null);let r=e&&D?.outputSchema!==void 0?{...t,outputSchema:D.outputSchema}:t,i=turnPosition(currentProjection(o));await u.rehydrate(i,j,isBetweenTurns(currentProjection(o))?void 0:{sequence:i.sequence,turnId:activeTurnId(i)});let a=e&&d!==void 0?d.map(({challenge:e})=>e):void 0;return runHarnessStep(r,n,a)});r.settledTurn===void 0&&throwIfTurnAborted(C);let i={...r,session:saveSessionProjection(r.session,o)};return P={result:i,serializedContext:serializeContext(o)},i}})}catch(t){if(!isTurnCancellation(t)&&!C.aborted)throw await failChannelDeliveries(t),t;return createCancelledModelCallBatchResult({beforeBatchContext:e.serializedContext,checkpoint:P,ctx:o,initialSession:h,stepInput:D})}let I=saveSessionProjection(dropClosedRecords(reconcileSessionContinuationToken(o,F.session),currentProjection(o)),o);agentTraceState.pruneAgentTraceState(o,I.sessionId,I.state);let L=serializeContext(o);F={...F,session:I};let R=resolveSessionStepResult(F,L);return R.action===`done`&&await b.writer.close(),w?{...R,compacted:!0}:R}finally{b.writer.release()}}export{turnStep};
|
|
@@ -4,6 +4,7 @@ import type { SessionInboxReader } from "#execution/session-inbox/inbox.js";
|
|
|
4
4
|
import type { SessionStateCursor } from "#execution/session/state-cursor.js";
|
|
5
5
|
import type { WorkflowToolRunMessage } from "#execution/tools/workflow/messages.js";
|
|
6
6
|
import type { TurnOutcome, TurnStepPayload } from "#execution/session/turn-step-types.js";
|
|
7
|
+
import type { TurnControl } from "#execution/session/turn-control.js";
|
|
7
8
|
import type { RuntimeActionResult } from "#shared/action-types.js";
|
|
8
9
|
/** True when a delegating parent (local or remote) receives this session's input requests. */
|
|
9
10
|
export declare function hasDelegatedCallerContext(serializedContext: Record<string, unknown>): boolean;
|
|
@@ -29,6 +30,7 @@ export declare class SessionExecution {
|
|
|
29
30
|
* input carries no caller. The turn's first step binds it into the context.
|
|
30
31
|
*/
|
|
31
32
|
readonly caller?: TurnCaller;
|
|
33
|
+
readonly control?: TurnControl;
|
|
32
34
|
}): Promise<TurnOutcome>;
|
|
33
35
|
/**
|
|
34
36
|
* Applies what runs reported while the model step ran, so the next step sees
|