eve 0.81.1 → 0.83.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 +93 -0
- package/NOTICE +1 -1
- package/dist/src/channel/channel-address.d.ts +21 -2
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/channel-operations.d.ts +32 -1
- package/dist/src/channel/channel-operations.js +1 -1
- package/dist/src/channel/delivery-idempotency.d.ts +4 -0
- package/dist/src/channel/delivery-idempotency.js +1 -0
- package/dist/src/channel/pending-authorization.d.ts +5 -0
- package/dist/src/channel/pending-authorization.js +1 -1
- package/dist/src/channel/routes.d.ts +6 -0
- package/dist/src/channel/session.d.ts +7 -0
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +19 -11
- package/dist/src/chunks/{use-eve-agent-DLkjJIm3.js → use-eve-agent-3-WRmJkd.js} +76 -5
- package/dist/src/chunks/{use-eve-agent-Bp6nbhfV.js → use-eve-agent-Ci5dr0aR.js} +76 -5
- package/dist/src/cli/dev/command-options.d.ts +1 -0
- package/dist/src/cli/dev/diagnostic-dump.js +1 -1
- package/dist/src/cli/dev/local-server-child.js +1 -1
- package/dist/src/cli/dev/local-server-cleanup.js +1 -1
- package/dist/src/cli/dev/tui/question-panel.d.ts +4 -1
- package/dist/src/cli/dev/tui/question-panel.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +4 -4
- package/dist/src/cli/run.d.ts +1 -0
- package/dist/src/cli/run.js +1 -1
- package/dist/src/client/eve-agent-store.d.ts +1 -1
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/index.d.ts +2 -1
- package/dist/src/client/message-reducer-types.d.ts +7 -3
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/client/session-controls.d.ts +6 -0
- package/dist/src/client/session-controls.js +1 -1
- package/dist/src/client/session.d.ts +4 -0
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/transcript-reducer.d.ts +6 -3
- package/dist/src/client/transcript-reducer.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +8 -8
- package/dist/src/compiled/@eve/catalog/index.js +1 -1
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.d.ts +5 -3
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +1 -37
- package/dist/src/compiled/@workflow/core/runtime/event-limit-warning.d.ts +32 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +5 -6
- package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +16 -0
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +15 -18
- package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +20 -0
- package/dist/src/compiled/@workflow/core/runtime.js +4 -4
- package/dist/src/compiled/@workflow/core/seeded-nanoid.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +14 -3
- package/dist/src/compiled/@workflow/core/serialization.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization.js +1 -1
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +0 -18
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.d.ts +48 -0
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/env-config.d.ts +24 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +126 -7
- package/dist/src/compiled/@workflow/world/index.d.ts +3 -3
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +59 -8
- package/dist/src/compiled/@workflow/world/queue.d.ts +71 -9
- package/dist/src/compiled/@workflow/world/recovery.d.ts +6 -0
- package/dist/src/compiled/@workflow/world/test-support/duplicate-event-fixtures.d.ts +3 -0
- package/dist/src/compiled/@workflow/world/test-support/in-band-fence-conformance.d.ts +46 -0
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +18 -18
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-BW-kbMMn.js → attribute-changes-7se_SE2q.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/dist-CcnNPAp4.js +1 -0
- package/dist/src/compiled/_chunks/workflow/dist-S9cZRway.js +3 -0
- package/dist/src/compiled/_chunks/workflow/helpers-CxNRXH0a.js +1 -0
- package/dist/src/compiled/_chunks/workflow/private-DLYTSBbu.js +1 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-CPiIfe8r.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{run-DzdAqdb1.js → run-BJSLCXR4.js} +6 -6
- package/dist/src/compiled/_chunks/workflow/serialization-B9gneT9Z.js +15 -0
- package/dist/src/compiled/_chunks/workflow/sleep-BL0oQs3R.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{wait-until-xbRRDuUf.js → wait-until-BPou0RGO.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/workflow-routes-BaljomCk.js +1 -0
- package/dist/src/compiled/{@ai-sdk/code-mode → run}/LICENSE +1 -1
- package/dist/src/compiled/run/index.d.ts +384 -0
- package/dist/src/compiled/run/index.js +650 -0
- package/dist/src/compiler/extension-compatibility.d.ts +28 -20
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/load-binding-namespace.d.ts +2 -0
- package/dist/src/compiler/load-binding-namespace.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- 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-sandbox.js +1 -1
- package/dist/src/compiler/project-sources.d.ts +6 -0
- package/dist/src/compiler/project-sources.js +1 -1
- package/dist/src/compiler/workspace-resources.js +1 -1
- package/dist/src/context/build-callback-context.js +1 -1
- package/dist/src/context/dynamic-skill-lifecycle.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/sandbox.js +1 -1
- package/dist/src/discover/extension-specifier.d.ts +1 -0
- package/dist/src/discover/extension-specifier.js +1 -1
- package/dist/src/evals/cli/eval-state-directory.d.ts +7 -0
- package/dist/src/evals/cli/eval-state-directory.js +1 -0
- package/dist/src/evals/cli/eval.js +2 -2
- package/dist/src/evals/runner/artifacts.js +1 -1
- package/dist/src/evals/runner/derive-run-facts.d.ts +12 -0
- package/dist/src/evals/runner/derive-run-facts.js +1 -1
- package/dist/src/evals/runner/execute-task.js +1 -1
- package/dist/src/evals/types.d.ts +3 -2
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.d.ts +0 -1
- package/dist/src/eve-channel/request.js +2 -2
- package/dist/src/eve-channel/support.d.ts +2 -0
- package/dist/src/eve-channel/support.js +1 -1
- package/dist/src/eve-channel/types.d.ts +7 -0
- package/dist/src/execution/agent-sessions/context.d.ts +3 -14
- package/dist/src/execution/agent-sessions/context.js +1 -1
- package/dist/src/execution/agent-sessions/runtime-overrides.d.ts +5 -0
- package/dist/src/execution/agent-sessions/session.d.ts +2 -2
- package/dist/src/execution/agent-sessions/session.js +1 -1
- package/dist/src/execution/agent-sessions/steps.d.ts +2 -0
- package/dist/src/execution/agent-sessions/steps.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +8 -5
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/coordination-dispatch-step.d.ts +17 -2
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +5 -2
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/deliver-payloads.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +0 -1
- package/dist/src/execution/dynamic-connection-recovery.js +1 -1
- package/dist/src/execution/dynamic-workflow/program-step.d.ts +7 -7
- package/dist/src/execution/dynamic-workflow/program-step.js +1 -1
- package/dist/src/execution/dynamic-workflow/schema.d.ts +18 -11
- package/dist/src/execution/dynamic-workflow/schema.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/dynamic-workflow/workflow.js +1 -1
- package/dist/src/execution/effective-agent-config.d.ts +8 -2
- package/dist/src/execution/effective-agent-config.js +1 -1
- package/dist/src/execution/eve-workflow-attributes.d.ts +3 -1
- package/dist/src/execution/eve-workflow-attributes.js +1 -1
- package/dist/src/execution/install-workflow-deployment-id.d.ts +3 -0
- package/dist/src/execution/install-workflow-deployment-id.js +1 -0
- 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/runtime-context.d.ts +2 -0
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/sandbox/abort-bound-session.js +1 -1
- package/dist/src/execution/sandbox/active-connections.d.ts +28 -0
- package/dist/src/execution/sandbox/active-connections.js +1 -0
- package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +10 -2
- package/dist/src/execution/sandbox/bindings/docker-cli.js +2 -2
- package/dist/src/execution/sandbox/bindings/docker-connection.d.ts +15 -0
- package/dist/src/execution/sandbox/bindings/docker-connection.js +2 -0
- package/dist/src/execution/sandbox/bindings/docker-container.d.ts +2 -0
- package/dist/src/execution/sandbox/bindings/docker-container.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-network.d.ts +5 -0
- package/dist/src/execution/sandbox/bindings/docker-network.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-templates.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker.d.ts +12 -15
- package/dist/src/execution/sandbox/bindings/docker.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.d.ts +19 -29
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.d.ts +2 -4
- package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
- package/dist/src/execution/sandbox/bindings/local-provider-utils.d.ts +0 -20
- package/dist/src/execution/sandbox/bindings/local-provider-utils.js +1 -1
- package/dist/src/execution/sandbox/bindings/local.d.ts +4 -6
- package/dist/src/execution/sandbox/bindings/local.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-base-runtime.d.ts +2 -0
- package/dist/src/execution/sandbox/bindings/vercel-base-runtime.js +2 -2
- package/dist/src/execution/sandbox/bindings/vercel-errors.js +2 -2
- package/dist/src/execution/sandbox/bindings/vercel-lifecycle.d.ts +7 -5
- package/dist/src/execution/sandbox/bindings/vercel-lifecycle.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +5 -11
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -2
- package/dist/src/execution/sandbox/development-cleanup.d.ts +0 -1
- package/dist/src/execution/sandbox/development-cleanup.js +1 -1
- package/dist/src/execution/sandbox/development-lazy-prewarm.js +1 -1
- package/dist/src/execution/sandbox/development-run.d.ts +0 -2
- package/dist/src/execution/sandbox/development-run.js +1 -1
- package/dist/src/execution/sandbox/dockerfile.d.ts +0 -4
- package/dist/src/execution/sandbox/dockerfile.js +1 -1
- package/dist/src/execution/sandbox/ensure.d.ts +23 -11
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/sandbox/glob-tool.js +3 -3
- package/dist/src/execution/sandbox/grep-tool.js +1 -1
- package/dist/src/execution/sandbox/logging-session.js +1 -1
- package/dist/src/execution/sandbox/prewarm.d.ts +23 -3
- package/dist/src/execution/sandbox/prewarm.js +2 -1
- package/dist/src/execution/sandbox/read-file.js +1 -1
- package/dist/src/execution/sandbox/require-sandbox.d.ts +3 -2
- package/dist/src/execution/sandbox/require-sandbox.js +1 -1
- package/dist/src/execution/sandbox/ripgrep-probe.js +1 -1
- package/dist/src/execution/sandbox/session.d.ts +10 -20
- package/dist/src/execution/sandbox/session.js +2 -2
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/admission.js +1 -1
- package/dist/src/execution/session/checkpoint-migrations.js +1 -1
- package/dist/src/execution/session/entry-input.d.ts +5 -6
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/finalization.js +1 -1
- package/dist/src/execution/session/handoff-state.d.ts +5 -0
- package/dist/src/execution/session/handoff-state.js +1 -0
- package/dist/src/execution/session/handoff-steps.d.ts +0 -5
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +7 -9
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +8 -1
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/next-input.d.ts +3 -0
- package/dist/src/execution/session/next-input.js +1 -1
- package/dist/src/execution/session/pending-history.d.ts +5 -0
- package/dist/src/execution/session/pending-history.js +1 -0
- package/dist/src/execution/session/pending-turn-state.js +1 -1
- package/dist/src/execution/session/program.d.ts +1 -1
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/timeout-control.d.ts +22 -4
- package/dist/src/execution/session/timeout-control.js +1 -1
- package/dist/src/execution/session/timeout.d.ts +1 -2
- package/dist/src/execution/session/timeout.js +1 -1
- package/dist/src/execution/session/turn-control.d.ts +5 -2
- package/dist/src/execution/session/turn-control.js +1 -1
- package/dist/src/execution/session/turn-event-handler.js +1 -1
- package/dist/src/execution/session/turn-step-result.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn-waiting-step.js +1 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-inbox/inbox.d.ts +9 -1
- package/dist/src/execution/session-inbox/inbox.js +1 -1
- package/dist/src/execution/session-inbox/protocol.d.ts +2 -1
- package/dist/src/execution/session-inbox/protocol.js +1 -1
- package/dist/src/execution/session-inbox/resume.d.ts +2 -1
- package/dist/src/execution/session-inbox/resume.js +1 -1
- package/dist/src/execution/session-prewarm.d.ts +8 -0
- package/dist/src/execution/session-prewarm.js +1 -0
- package/dist/src/execution/session.d.ts +0 -12
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/skills/instructions.js +1 -1
- package/dist/src/execution/tasks/model-step.js +1 -1
- package/dist/src/execution/tasks/start.d.ts +4 -4
- package/dist/src/execution/tasks/start.js +1 -1
- package/dist/src/execution/tasks/steps.js +1 -1
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/workflow/body.d.ts +2 -2
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/step-context.d.ts +11 -0
- package/dist/src/execution/tools/workflow/step-execution.js +1 -1
- package/dist/src/execution/tools/workflow/step.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +5 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/extensions/git/extension/lib/github-shell-schema.js +1 -1
- package/dist/src/framework/sources/modules/sandbox.d.ts +1 -1
- package/dist/src/harness/attachment-staging.d.ts +0 -7
- package/dist/src/harness/attachment-staging.js +1 -1
- package/dist/src/harness/hitl/approvals.js +1 -1
- package/dist/src/harness/hitl/budget-request.d.ts +12 -6
- package/dist/src/harness/hitl/budget-request.js +1 -1
- package/dist/src/harness/hitl/budget.d.ts +7 -1
- package/dist/src/harness/hitl/budget.js +1 -1
- package/dist/src/harness/hitl/coordinator.js +1 -1
- package/dist/src/harness/hitl/delivery.d.ts +1 -1
- package/dist/src/harness/hitl/delivery.js +1 -1
- package/dist/src/harness/hitl/index.d.ts +2 -1
- package/dist/src/harness/hitl/index.js +1 -1
- package/dist/src/harness/hitl/intake.d.ts +2 -2
- package/dist/src/harness/hitl/intake.js +1 -1
- package/dist/src/harness/hitl/view.d.ts +1 -0
- package/dist/src/harness/hitl/view.js +1 -0
- package/dist/src/harness/messages.d.ts +5 -0
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/model-call/call.d.ts +2 -2
- package/dist/src/harness/model-call/request.d.ts +2 -2
- package/dist/src/harness/model-call/run.js +1 -1
- package/dist/src/harness/semantic-errors/rules/sandbox.d.ts +3 -5
- package/dist/src/harness/semantic-errors/rules/sandbox.js +1 -1
- package/dist/src/harness/session-machine/transitions.d.ts +3 -1
- package/dist/src/harness/session-machine/transitions.js +1 -1
- package/dist/src/harness/step/context.d.ts +3 -0
- package/dist/src/harness/step/context.js +1 -1
- package/dist/src/harness/step/intake.d.ts +5 -2
- package/dist/src/harness/step/intake.js +1 -1
- package/dist/src/harness/step/prompt.js +1 -1
- package/dist/src/harness/tool-history-repair.d.ts +9 -0
- package/dist/src/harness/tool-history-repair.js +1 -0
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/tool-model-output.d.ts +19 -3
- package/dist/src/harness/tool-model-output.js +1 -1
- package/dist/src/harness/turn-tag-state.d.ts +7 -26
- package/dist/src/harness/turn-tag-state.js +1 -1
- package/dist/src/harness/types.d.ts +10 -25
- package/dist/src/internal/application/build-profile.d.ts +3 -0
- package/dist/src/internal/application/build-profile.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +10 -6
- package/dist/src/internal/application/dev-environment.d.ts +13 -0
- package/dist/src/internal/application/dev-environment.js +1 -1
- package/dist/src/internal/application/optional-package-import.d.ts +10 -0
- package/dist/src/internal/application/optional-package-import.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/attachments/limited-read.d.ts +2 -2
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/authored-module-build-options.d.ts +13 -0
- package/dist/src/internal/authored-module-build-options.js +1 -0
- package/dist/src/internal/authored-module-cache.d.ts +10 -0
- package/dist/src/internal/authored-module-cache.js +1 -0
- package/dist/src/internal/authored-module-graph.d.ts +13 -0
- package/dist/src/internal/authored-module-graph.js +1 -0
- package/dist/src/internal/authored-module-loader.d.ts +22 -1
- package/dist/src/internal/authored-module-loader.js +1 -3
- package/dist/src/internal/authored-module.d.ts +7 -0
- package/dist/src/internal/authored-module.js +1 -1
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/authored-relative-extension-resolver.js +1 -1
- package/dist/src/internal/bundler/nitro-rolldown.d.ts +8 -2
- package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
- package/dist/src/internal/bundler/pseudo-packages.d.ts +11 -0
- package/dist/src/internal/bundler/pseudo-packages.js +1 -0
- package/dist/src/internal/development-programmatic-source-loader.d.ts +1 -0
- package/dist/src/internal/development-programmatic-source-loader.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-generation-metadata.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-deployment-id.d.ts +8 -0
- package/dist/src/internal/nitro/host/build-deployment-id.js +1 -0
- package/dist/src/internal/nitro/host/build-extension.d.ts +6 -0
- package/dist/src/internal/nitro/host/build-extension.js +2 -2
- package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.d.ts +3 -1
- package/dist/src/internal/nitro/host/compiled-sandbox-provider-prune-plugin.js +3 -5
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts +2 -3
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.d.ts +2 -0
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-build-host.d.ts +83 -0
- package/dist/src/internal/nitro/host/dev-build-host.js +1 -0
- package/dist/src/internal/nitro/host/dev-build-operations.d.ts +6 -0
- package/dist/src/internal/nitro/host/dev-build-operations.js +1 -0
- package/dist/src/internal/nitro/host/dev-build-process.d.ts +1 -0
- package/dist/src/internal/nitro/host/dev-build-process.js +1 -0
- package/dist/src/internal/nitro/host/dev-server-state.js +1 -1
- package/dist/src/internal/nitro/host/development-runtime-prune-plugin.d.ts +4 -1
- package/dist/src/internal/nitro/host/development-runtime-prune-plugin.js +3 -2
- package/dist/src/internal/nitro/host/drained-nitro-dev-server.d.ts +13 -0
- package/dist/src/internal/nitro/host/drained-nitro-dev-server.js +1 -1
- package/dist/src/internal/nitro/host/optional-engine-dependency-plugin.js +1 -1
- package/dist/src/internal/nitro/host/prepare-application-host.d.ts +3 -0
- package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
- package/dist/src/internal/nitro/host/sandbox-shutdown-plugin.js +1 -1
- package/dist/src/internal/nitro/host/skill-server-assets.js +1 -1
- package/dist/src/internal/nitro/host/stage-build-deployment-id.d.ts +2 -0
- package/dist/src/internal/nitro/host/stage-build-deployment-id.js +1 -0
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/start-production-server.d.ts +1 -0
- package/dist/src/internal/nitro/host/start-production-server.js +3 -3
- package/dist/src/internal/nitro/host/workflow-sandbox-runtime-plugin.js +1 -1
- package/dist/src/internal/nitro/host.js +1 -1
- package/dist/src/internal/nitro/routes/schedule-task.d.ts +3 -0
- package/dist/src/internal/nitro/routes/schedule-task.js +1 -1
- package/dist/src/internal/programmatic-source-loader.d.ts +1 -0
- package/dist/src/internal/programmatic-source-loader.js +1 -1
- package/dist/src/internal/schedules/disabled.d.ts +2 -0
- package/dist/src/internal/schedules/disabled.js +1 -0
- package/dist/src/internal/workflow/development-world-server.js +1 -1
- package/dist/src/internal/workflow/local-world-data-directory.d.ts +2 -1
- package/dist/src/internal/workflow/local-world-data-directory.js +1 -1
- package/dist/src/internal/workflow/local-world-delivery-auth.d.ts +17 -0
- package/dist/src/internal/workflow/local-world-delivery-auth.js +1 -0
- package/dist/src/internal/workflow/queue-namespace.d.ts +2 -0
- package/dist/src/internal/workflow/queue-namespace.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +0 -1
- package/dist/src/internal/workflow-bundle/builder-support.js +2 -2
- package/dist/src/internal/workflow-bundle/builder.js +2 -2
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
- package/dist/src/protocol/message.d.ts +27 -1
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/protocol/prewarm-session.d.ts +14 -0
- package/dist/src/protocol/prewarm-session.js +1 -0
- package/dist/src/protocol/routes.d.ts +2 -2
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +13 -0
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
- package/dist/src/public/channels/chat-sdk/fetch-message.d.ts +10 -0
- package/dist/src/public/channels/chat-sdk/fetch-message.js +1 -0
- package/dist/src/public/channels/chat-sdk/index.d.ts +1 -1
- package/dist/src/public/channels/chat-sdk/reply-context.d.ts +15 -0
- package/dist/src/public/channels/chat-sdk/reply-context.js +2 -0
- package/dist/src/public/channels/discord/authorization.d.ts +45 -0
- package/dist/src/public/channels/discord/authorization.js +3 -0
- package/dist/src/public/channels/discord/defaults.d.ts +14 -3
- package/dist/src/public/channels/discord/defaults.js +2 -2
- package/dist/src/public/channels/discord/discordChannel.d.ts +18 -1
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/discord/gateway/connection.d.ts +26 -0
- package/dist/src/public/channels/discord/gateway/connection.js +1 -0
- package/dist/src/public/channels/discord/gateway/forwarder.d.ts +14 -0
- package/dist/src/public/channels/discord/gateway/forwarder.js +1 -0
- package/dist/src/public/channels/discord/gateway/index.d.ts +59 -0
- package/dist/src/public/channels/discord/gateway/index.js +1 -0
- package/dist/src/public/channels/discord/inbound.d.ts +10 -3
- package/dist/src/public/channels/discord/inbound.js +2 -2
- package/dist/src/public/channels/discord/index.d.ts +3 -2
- package/dist/src/public/channels/discord/index.js +1 -1
- package/dist/src/public/channels/discord/messages.d.ts +116 -0
- package/dist/src/public/channels/discord/messages.js +2 -0
- package/dist/src/public/channels/github/checkout.js +1 -1
- package/dist/src/public/channels/github/dispatch.js +1 -1
- package/dist/src/public/channels/github/githubChannel.d.ts +3 -0
- package/dist/src/public/channels/imessage-tapbacks.d.ts +74 -0
- package/dist/src/public/channels/imessage-tapbacks.js +1 -0
- package/dist/src/public/channels/index.d.ts +2 -1
- package/dist/src/public/channels/index.js +1 -1
- package/dist/src/public/channels/linear/linearChannel.d.ts +3 -0
- package/dist/src/public/channels/linear/linearChannel.js +1 -1
- package/dist/src/public/channels/linq/inboundContent.d.ts +7 -0
- package/dist/src/public/channels/linq/inboundContent.js +1 -1
- package/dist/src/public/channels/linq/index.d.ts +1 -0
- package/dist/src/public/channels/linq/index.js +1 -1
- package/dist/src/public/channels/linq/linqChannel.d.ts +21 -2
- package/dist/src/public/channels/linq/linqChannel.js +1 -1
- package/dist/src/public/channels/photon/inboundContent.d.ts +7 -0
- package/dist/src/public/channels/photon/inboundContent.js +2 -1
- package/dist/src/public/channels/photon/index.d.ts +1 -0
- package/dist/src/public/channels/photon/index.js +1 -1
- package/dist/src/public/channels/photon/photonIMessageChannel.d.ts +17 -1
- package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
- package/dist/src/public/channels/same-environment-oidc.d.ts +7 -0
- package/dist/src/public/channels/same-environment-oidc.js +1 -0
- package/dist/src/public/channels/slack/api.d.ts +6 -0
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/model-context.d.ts +7 -0
- package/dist/src/public/channels/slack/model-context.js +1 -1
- package/dist/src/public/channels/slack/reply-delivery.d.ts +5 -0
- package/dist/src/public/channels/slack/reply-delivery.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +17 -3
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.d.ts +3 -0
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.d.ts +3 -0
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/definitions/agent.d.ts +1 -1
- package/dist/src/public/definitions/channel.d.ts +2 -2
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/hook.d.ts +1 -0
- package/dist/src/public/definitions/sandbox.d.ts +1 -1
- package/dist/src/public/index.d.ts +1 -1
- package/dist/src/public/next/server.js +1 -1
- package/dist/src/public/sandbox/docker-sandbox.d.ts +6 -1
- package/dist/src/public/sandbox/docker.d.ts +1 -8
- package/dist/src/public/sandbox/index.d.ts +3 -3
- package/dist/src/public/sandbox/just-bash-sandbox.d.ts +87 -7
- package/dist/src/public/sandbox/just-bash.d.ts +1 -1
- package/dist/src/public/sandbox/provider.d.ts +5 -1
- package/dist/src/public/sandbox/provider.js +1 -1
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +16 -9
- package/dist/src/public/sandbox/vercel.d.ts +0 -1
- package/dist/src/public/sandbox/vercel.js +1 -1
- package/dist/src/public/tools/agent.d.ts +8 -1
- package/dist/src/public/tools/agent.js +1 -1
- package/dist/src/public/tools/index.d.ts +1 -1
- package/dist/src/react/use-eve-agent.d.ts +1 -1
- package/dist/src/runtime/agent/resolve-model.d.ts +4 -0
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/connections/openapi-client.d.ts +2 -0
- package/dist/src/runtime/connections/openapi-client.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/resolve-channel.js +1 -1
- package/dist/src/runtime/resolve-sandbox.js +1 -1
- package/dist/src/runtime/sandbox/prepared-artifacts.js +1 -1
- package/dist/src/runtime/sandbox/registry.d.ts +2 -0
- package/dist/src/runtime/sandbox/registry.js +1 -1
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/runtime/subagents/dynamic-agent-config.d.ts +2 -1
- package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -1
- package/dist/src/runtime/subagents/workflow.d.ts +6 -0
- package/dist/src/runtime/subagents/workflow.js +1 -1
- package/dist/src/runtime/types.d.ts +3 -2
- package/dist/src/runtime/workspace/seed-files.d.ts +9 -12
- package/dist/src/runtime/workspace/seed-files.js +1 -1
- package/dist/src/runtime/workspace/spec.d.ts +1 -1
- package/dist/src/runtime/workspace/spec.js +1 -1
- package/dist/src/runtime/workspace/types.d.ts +2 -6
- package/dist/src/sandbox/provider.d.ts +185 -0
- package/dist/src/sandbox/provider.js +1 -0
- package/dist/src/sandbox/providers/default.d.ts +20 -19
- package/dist/src/sandbox/providers/default.js +1 -1
- package/dist/src/sandbox/providers/docker.d.ts +5 -2
- package/dist/src/sandbox/providers/docker.js +1 -1
- package/dist/src/sandbox/providers/just-bash.d.ts +4 -3
- package/dist/src/sandbox/providers/just-bash.js +1 -1
- package/dist/src/sandbox/providers/vercel.d.ts +4 -10
- package/dist/src/sandbox/providers/vercel.js +1 -1
- package/dist/src/sandbox/providers.d.ts +0 -1
- package/dist/src/sandbox/providers.js +1 -1
- package/dist/src/sandbox/state.d.ts +44 -0
- package/dist/src/sandbox/state.js +1 -1
- package/dist/src/self-modification/deployed-sandbox.d.ts +4 -9
- package/dist/src/self-modification/deployed-sandbox.js +1 -1
- package/dist/src/self-modification/filesystem.d.ts +3 -3
- package/dist/src/self-modification/remote/config.d.ts +2 -2
- package/dist/src/self-modification/remote/config.js +1 -1
- package/dist/src/self-modification/setup.d.ts +0 -1
- package/dist/src/self-modification/setup.js +8 -8
- package/dist/src/setup/integrations/discord/api.d.ts +7 -0
- package/dist/src/setup/integrations/discord/api.js +1 -1
- package/dist/src/setup/integrations/discord/daemon.d.ts +18 -0
- package/dist/src/setup/integrations/discord/daemon.js +21 -0
- package/dist/src/setup/integrations/discord/setup.d.ts +24 -4
- package/dist/src/setup/integrations/discord/setup.js +5 -4
- package/dist/src/setup/integrations/self-modification/setup.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/update/web-options.js +1 -1
- package/dist/src/setup/scaffold/version-tokens.d.ts +0 -1
- package/dist/src/setup/scaffold/version-tokens.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +33 -42
- package/dist/src/shared/built-server-start-failure.d.ts +12 -0
- package/dist/src/shared/built-server-start-failure.js +3 -0
- package/dist/src/shared/framework-eve-server.d.ts +2 -0
- package/dist/src/shared/framework-eve-server.js +2 -2
- package/dist/src/shared/sandbox-environment.d.ts +4 -10
- package/dist/src/shared/sandbox-environment.js +1 -1
- package/dist/src/shared/sandbox-network-policy.d.ts +45 -9
- package/dist/src/shared/sandbox-provider.d.ts +0 -103
- package/dist/src/shared/sandbox-provider.js +1 -1
- package/dist/src/shared/sandbox-recorded-data-error.d.ts +4 -0
- package/dist/src/shared/sandbox-recorded-data-error.js +1 -0
- package/dist/src/shared/sandbox-session-gone-error.d.ts +12 -0
- package/dist/src/shared/sandbox-session-gone-error.js +1 -0
- package/dist/src/shared/sandbox-session.d.ts +97 -83
- package/dist/src/shared/sandbox-template-error.d.ts +19 -4
- package/dist/src/shared/sandbox-template-error.js +1 -1
- package/dist/src/shared/sandbox-tool-session-error.d.ts +4 -0
- package/dist/src/shared/sandbox-tool-session-error.js +1 -0
- package/dist/src/shared/session-history.d.ts +22 -0
- package/dist/src/shared/session-history.js +1 -0
- package/dist/src/shared/skill-package.js +1 -1
- package/dist/src/shared/skill-paths.d.ts +4 -5
- package/dist/src/shared/skill-paths.js +2 -2
- package/dist/src/shared/workflow-sandbox.d.ts +4 -41
- package/dist/src/shared/workflow-sandbox.js +1 -1
- package/dist/src/subagents/tool.d.ts +1 -3
- package/dist/src/subagents/tool.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.d.ts +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/model-output.d.ts +23 -5
- package/dist/src/tools/model-output.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/glob.js +1 -1
- package/dist/src/tools/provided/grep.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/tools/provided/workflow.js +1 -1
- package/dist/src/tools/provided/write-file.js +1 -1
- package/dist/src/tools/workflow-definition.d.ts +33 -5
- package/dist/src/tracing/eve/conversation-context.d.ts +4 -1
- package/dist/src/tracing/eve/conversation-context.js +1 -1
- package/dist/src/tracing/eve/invoke-tool-span.js +1 -1
- package/dist/src/tracing/eve/operation-input.d.ts +0 -5
- package/dist/src/tracing/eve/operation-input.js +1 -1
- package/dist/src/tracing/eve/otel-registration.js +1 -1
- package/dist/src/tracing/eve/session.d.ts +3 -2
- package/dist/src/tracing/eve/session.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.d.ts +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +86 -65
- package/docs/channels/chat-sdk.mdx +6 -1
- package/docs/channels/custom.mdx +41 -9
- package/docs/channels/discord.mdx +279 -7
- package/docs/channels/eve.mdx +58 -1
- package/docs/channels/linq.mdx +53 -2
- package/docs/channels/mcp.mdx +2 -2
- package/docs/channels/overview.mdx +1 -1
- package/docs/channels/photon.mdx +65 -1
- package/docs/channels/slack.mdx +4 -2
- package/docs/concepts/built-in-tools.md +32 -9
- package/docs/concepts/execution-model-and-durability.mdx +15 -103
- package/docs/concepts/security-model.md +2 -0
- package/docs/concepts/sessions-runs-and-streaming.md +52 -43
- package/docs/connections/openapi.mdx +2 -0
- package/docs/connections/overview.mdx +1 -1
- package/docs/evals/reporters.mdx +1 -1
- package/docs/evals/running.mdx +1 -1
- package/docs/experimental/dynamic-schedules.mdx +186 -0
- package/docs/experimental/meta.json +4 -0
- package/docs/guides/client/messages.mdx +1 -1
- package/docs/guides/client/streaming.mdx +1 -0
- package/docs/guides/deployment/overview.md +4 -4
- package/docs/guides/deployment/self-hosting.md +53 -1
- package/docs/guides/dev-tui.md +1 -1
- package/docs/guides/dynamic-capabilities.md +1 -1
- package/docs/guides/frontend/overview.mdx +26 -6
- package/docs/guides/hooks.md +21 -1
- package/docs/guides/instrumentation/agent-runs.mdx +16 -0
- package/docs/guides/self-modification.md +1 -1
- package/docs/guides/session-context.md +1 -1
- package/docs/instructions.mdx +1 -1
- package/docs/memory/overview.mdx +2 -1
- package/docs/patterns/dynamic-scheduling.md +3 -1
- package/docs/reference/agent-files.md +3 -3
- package/docs/reference/cli.md +21 -9
- package/docs/reference/typescript-api.md +9 -3
- package/docs/sandbox/custom-providers.mdx +254 -0
- package/docs/sandbox/default.mdx +71 -4
- package/docs/sandbox/docker.mdx +15 -3
- package/docs/sandbox/index.mdx +27 -103
- package/docs/sandbox/just-bash.mdx +54 -0
- package/docs/sandbox/meta.json +9 -1
- package/docs/sandbox/troubleshooting.mdx +215 -0
- package/docs/sandbox/vercel.mdx +48 -7
- package/docs/schedules.mdx +2 -0
- package/docs/skills.mdx +1 -1
- package/docs/subagents/index.mdx +3 -1
- package/docs/tools/overview.mdx +21 -1
- package/docs/tools/tasks-upgrade.md +12 -7
- package/docs/tools/tasks.md +10 -6
- package/docs/tools/workflows.mdx +109 -10
- package/docs/tutorial/connect-a-warehouse.mdx +1 -1
- package/docs/tutorial/run-analysis.mdx +3 -3
- package/package.json +14 -20
- package/dist/src/compiled/@ai-sdk/code-mode/_run.d.ts +0 -1
- package/dist/src/compiled/@ai-sdk/code-mode/index.d.ts +0 -325
- package/dist/src/compiled/@ai-sdk/code-mode/index.js +0 -660
- package/dist/src/compiled/_chunks/workflow/dist-CyBgVS7g.js +0 -1
- package/dist/src/compiled/_chunks/workflow/dist-T5NnW-0k.js +0 -3
- package/dist/src/compiled/_chunks/workflow/helpers-DlLD3ov_.js +0 -1
- package/dist/src/compiled/_chunks/workflow/private-tQUuwBoQ.js +0 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-DMsV_b4n.js +0 -1
- package/dist/src/compiled/_chunks/workflow/serialization-DPdYS_w2.js +0 -16
- package/dist/src/compiled/_chunks/workflow/sleep-BY6leHh8.js +0 -1
- package/dist/src/compiled/_chunks/workflow/workflow-routes-CwqB063q.js +0 -1
- package/dist/src/execution/run-session-limits.d.ts +0 -12
- package/dist/src/execution/run-session-limits.js +0 -1
- package/dist/src/execution/sandbox/active-handles.d.ts +0 -32
- package/dist/src/execution/sandbox/active-handles.js +0 -1
- package/dist/src/execution/sandbox/bindings/docker-session.d.ts +0 -6
- package/dist/src/execution/sandbox/bindings/docker-session.js +0 -2
- package/dist/src/execution/sandbox/bindings/immutable-resources.d.ts +0 -15
- package/dist/src/execution/sandbox/bindings/immutable-resources.js +0 -2
- package/dist/src/execution/sandbox/bindings/microsandbox-create.d.ts +0 -12
- package/dist/src/execution/sandbox/bindings/microsandbox-create.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.d.ts +0 -42
- package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-metadata.d.ts +0 -29
- package/dist/src/execution/sandbox/bindings/microsandbox-metadata.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-network.d.ts +0 -18
- package/dist/src/execution/sandbox/bindings/microsandbox-network.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-options.d.ts +0 -37
- package/dist/src/execution/sandbox/bindings/microsandbox-options.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-platform.d.ts +0 -21
- package/dist/src/execution/sandbox/bindings/microsandbox-platform.js +0 -21
- package/dist/src/execution/sandbox/bindings/microsandbox-process.d.ts +0 -3
- package/dist/src/execution/sandbox/bindings/microsandbox-process.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-provider-state.d.ts +0 -11
- package/dist/src/execution/sandbox/bindings/microsandbox-provider-state.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.d.ts +0 -82
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-templates.d.ts +0 -12
- package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +0 -1
- package/dist/src/execution/sandbox/bindings/microsandbox.d.ts +0 -16
- package/dist/src/execution/sandbox/bindings/microsandbox.js +0 -1
- package/dist/src/execution/sandbox/provider-host-development.d.ts +0 -2
- package/dist/src/execution/sandbox/provider-host-development.js +0 -1
- package/dist/src/execution/sandbox/provider-host.d.ts +0 -2
- package/dist/src/execution/sandbox/provider-host.js +0 -1
- package/dist/src/execution/tool-session/sandbox.d.ts +0 -22
- package/dist/src/execution/tool-session/sandbox.js +0 -1
- package/dist/src/harness/session-usage-limits.d.ts +0 -49
- package/dist/src/harness/session-usage-limits.js +0 -1
- package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +0 -48
- package/dist/src/public/sandbox/microsandbox.d.ts +0 -9
- package/dist/src/public/sandbox/microsandbox.js +0 -1
- package/dist/src/sandbox/providers/microsandbox.d.ts +0 -12
- package/dist/src/sandbox/providers/microsandbox.js +0 -1
- package/dist/src/subagents/token-budget.d.ts +0 -15
- package/dist/src/subagents/token-budget.js +0 -1
- package/docs/sandbox/microsandbox.mdx +0 -31
- /package/dist/src/{public/sandbox/microsandbox-sandbox.js → execution/agent-sessions/runtime-overrides.js} +0 -0
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{randomBytes}from"node:crypto";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{SANDBOX_AGENT_ENV,buildSandboxSession}from"#execution/sandbox/session.js";import{VERCEL_EVE_SANDBOX_IMAGE}from"#execution/sandbox/bindings/eve-image.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-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,isVercelSnapshotCreated}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={...e.createOptions,timeout:e.createOptions?.timeout??DEFAULT_SANDBOX_TIMEOUT_MS},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:3}).slice(0,32)}`;try{return{snapshotId:await ensureTemplate({createOptions:r,createSandbox:i,loadSandboxModule:t,log:n.log,prepareSandbox:e.prepare,seedFiles:a,templateKey:o})}}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 ensureTemplate(e){let t=await e.loadSandboxModule(),n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:t,sandboxName:e.templateKey}),r=n?.sourceSnapshotId;if(r!==void 0&&await isVercelSnapshotCreated({createOptions:e.createOptions,sandboxModule:t,snapshotId:r}))return e.log?.(`reusing prepared sandbox template`),r;let i=await prepareTemplateSnapshot(e,t);return await publishTemplatePointer(e,t,n,i).catch(t=>{e.log?.(`could not publish sandbox template: ${errorMessage(t)}`)}),i}async function prepareTemplateSnapshot(e,t){let n=await e.createSandbox({sandboxModule:t,createOptions:withBaseSetupNetworkPolicy({...e.createOptions,name:`${e.templateKey}-${randomBytes(4).toString(`hex`)}`,persistent:!1})});try{e.log?.(`preparing base runtime inside sandbox`),await ensureVercelSandboxBaseRuntime(n),await applyInitialVercelNetworkPolicy(n,e.createOptions.networkPolicy);let t=buildSandboxSession(createVercelInternalSandboxSession(n,e.createOptions.env),createVercelNetworkPolicySetter(n));return await writeVercelSandboxSeedFiles({sandbox:n,seedFiles:e.seedFiles,session:t}),e.log?.(`running sandbox preparation`),await e.prepareSandbox?.(createLoggingSandboxSession({log:e.log,session:t})),(await n.snapshot()).snapshotId}finally{await n.delete().catch(t=>{e.log?.(`could not delete sandbox ${n.name}: ${errorMessage(t)}`)})}}async function publishTemplatePointer(e,t,n,r){if(n!==null)try{await n.delete()}catch(e){if(!isVercelSandboxMissingError(e))throw e}let{image:i,runtime:a,source:o,...s}=e.createOptions,c;try{c=await e.createSandbox({sandboxModule:t,createOptions:{...s,name:e.templateKey,persistent:!1,source:{snapshotId:r,type:`snapshot`}}})}catch(e){if(isVercelSandboxNameConflictError(e))return;throw e}await stopVercelSandbox(c)}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,e.createOptions.env),createVercelNetworkPolicySetter(t)),name:t.name},async onSandboxDelete(n){await deleteVercelSandbox({createOptions:e.createOptions,loadDeleteSandboxModule:e.loadDeleteSandboxModule,sandbox:t,signal:n?.abortSignal})},async onSandboxStop(){await stopVercelSandbox(t)},async onRuntimeShutdown(){try{await stopVercelSandbox(t)}catch{}}}}function createVercelInternalSandboxSession(e,t){let n={...SANDBOX_AGENT_ENV,...t};return{resolvePath:resolveVercelSandboxPath,async spawn(t){let r=await e.runCommand({args:[`-lc`,t.command],cmd:`bash`,cwd:t.workingDirectory??WORKSPACE_ROOT,detached:!0,env:{...n,...t.env},signal:t.abortSignal});return adaptMultiplexedCommandToSandboxProcess({command:r,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
|
-
`))throw Error(`Failed to resolve Vercel Sandbox write path: ${t}`);return i}const DEFAULT_SANDBOX_TIMEOUT_MS=18e5;export{createVercelSandbox,createVercelSandboxProvider};
|
|
1
|
+
import{randomBytes}from"node:crypto";import{isObject}from"#shared/guards.js";import{SANDBOX_AGENT_ENV,SandboxSessionGoneError,SandboxTemplateNotProvisionedError}from"#public/sandbox/provider.js";import{VERCEL_EVE_SANDBOX_IMAGE}from"#execution/sandbox/bindings/eve-image.js";import{createSandboxProviderIdentity}from"#execution/sandbox/provider-identity.js";import{invalidPreparedSandboxArtifactError,invalidSandboxSessionStateError}from"#shared/sandbox-recorded-data-error.js";import{adaptMultiplexedCommandToSandboxProcess}from"#execution/sandbox/multiplexed-command.js";import{isVercelSandboxMissingError,isVercelSandboxNameConflictError,isVercelSnapshotNotFoundError,isVercelSnapshotUnavailableError}from"#execution/sandbox/bindings/vercel-errors.js";import{getNamedVercelSandbox,isVercelSnapshotCreated}from"#execution/sandbox/bindings/vercel-lookup.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{deleteNamedVercelSandbox,deleteUnusableVercelSandbox,stopVercelSandbox}from"#execution/sandbox/bindings/vercel-lifecycle.js";import{normalizeVercelReadStream}from"#execution/sandbox/bindings/vercel-read-stream.js";import{withToolSessionRetention}from"#execution/sandbox/bindings/vercel-tool-sessions.js";function createVercelSandbox(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n={...e.createOptions,env:{...SANDBOX_AGENT_ENV,...e.createOptions?.env},timeout:e.createOptions?.timeout??DEFAULT_SANDBOX_TIMEOUT_MS},r=e.createSandbox??createVercelEveImageSandbox,i=n.source===void 0&&(n.image??VERCEL_EVE_SANDBOX_IMAGE)===VERCEL_EVE_SANDBOX_IMAGE;return{async onSessionEnd(e,r,{abortSignal:i}){await deleteNamedVercelSandbox({createOptions:n,sandboxModule:await t(),sandboxName:r?.sandboxName??vercelSessionName(e.session.id),signal:i})},async prepare(e){if(e.isEmpty&&n.source===void 0)return{};try{let i=`eve-sbx-tpl-vercel-${e.templateKey({createOptions:vercelIdentityOptions(n),resolvedImage:n.source===void 0?n.image??VERCEL_EVE_SANDBOX_IMAGE:void 0,version:4}).slice(0,32)}`;return{snapshotId:await ensureTemplate({context:e,createOptions:n,createSandbox:r,loadSandboxModule:t,templateKey:i})}}catch(e){throw Error(`Failed to prepare Vercel sandbox snapshot: ${errorMessage(e)}`,{cause:e})}},async resume(e,r,i){requirePreparedVercelTemplate(r);let a=requireVercelSessionState(i),o=await t(),s=await getNamedVercelSandbox({createOptions:n,sandboxModule:o,sandboxName:a.sandboxName});if(s===null)throw new SandboxSessionGoneError(`Vercel sandbox session "${a.sandboxName}" no longer exists.`);return await ensureVercelSandboxBaseRuntime(s),createVercelConnection(s)},async start(e,t,n){let r=vercelSessionName(e.session.id);return{connection:createVercelConnection(await openSession(e,t,n,r)),state:{sandboxName:r,version:3}}},toolSessions:!0};async function openSession(e,a,o,s){let c=requirePreparedVercelTemplate(o),{mounts:l,...u}=a??{},d=e.kind===`tool-session`,f={...n,...u,env:{...SANDBOX_AGENT_ENV,...u.env??n.env}},p=d?withToolSessionRetention(f):f,m=resolveVercelSandboxTags(p.tags,{sessionId:e.session.id}),h=await t(),g={createOptions:p,createSandbox:r,mounts:l===void 0?void 0:toVercelMounts(l),sandboxModule:h,sessionKey:s,snapshotId:c.snapshotId,tags:m};try{let t=await ensureUsableSession({expired:d?isVercelSnapshotNotFoundError:isVercelSnapshotUnavailableError,inheritsBaseRuntime:c.snapshotId!==void 0&&l===void 0&&i,input:g,session:await ensureSession(g)}),r=u.networkPolicy??n.networkPolicy;if(t.created&&c.snapshotId===void 0&&r!==void 0)try{await applyInitialVercelNetworkPolicy(t.sandbox,r)}catch(n){try{await deleteNamedVercelSandbox({createOptions:p,sandboxModule:h,sandboxName:t.sandbox.name})}catch(t){throw AggregateError([n,t],`Failed to apply network policy and discard Vercel sandbox session "${e.session.id}".`,{cause:n})}throw n}return t.sandbox}catch(t){throw isVercelSnapshotUnavailableError(t)&&c.snapshotId!==void 0?new SandboxTemplateNotProvisionedError({providerName:`vercel`,reason:`The Vercel Sandbox snapshot expired or was deleted.`,templateKey:c.snapshotId}):Error(`Failed to open Vercel sandbox session "${e.session.id}": ${errorMessage(t)}`,{cause:t})}}}function vercelSessionName(e){return`eve-sbx-vercel-${createSandboxProviderIdentity({sessionId:e,version:2}).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(!isObject(e)||e.version!==3||typeof e.sandboxName!=`string`)throw invalidSandboxSessionStateError(`Vercel sandbox`);return{sandboxName:e.sandboxName,version:3}}function requirePreparedVercelTemplate(e){if(!isObject(e)||e.snapshotId!==void 0&&typeof e.snapshotId!=`string`)throw invalidPreparedSandboxArtifactError(`Vercel sandbox`);return e.snapshotId===void 0?{}:{snapshotId:e.snapshotId}}function toVercelMounts(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,`mode`in t?{drive:t.drive,mode:t.mode}:{drive:t.name,mode:`read-write`}]))}async function ensureTemplate(e){let t=await e.loadSandboxModule(),n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:t,sandboxName:e.templateKey}),r=n?.sourceSnapshotId;if(r!==void 0&&await isVercelSnapshotCreated({createOptions:e.createOptions,sandboxModule:t,snapshotId:r}))return e.context.log(`reusing prepared sandbox template`),r;let i=await prepareTemplateSnapshot(e,t);return await publishTemplatePointer(e,t,n,i).catch(t=>{e.context.log(`could not publish sandbox template: ${errorMessage(t)}`)}),i}async function prepareTemplateSnapshot(e,t){let n=await e.createSandbox({sandboxModule:t,createOptions:withBaseSetupNetworkPolicy({...e.createOptions,name:`${e.templateKey}-${randomBytes(4).toString(`hex`)}`,persistent:!1})});try{return e.context.log(`preparing base runtime inside sandbox`),await ensureVercelSandboxBaseRuntime(n),await applyInitialVercelNetworkPolicy(n,e.createOptions.networkPolicy),await e.context.populate(createVercelConnection(n)),await ensureVercelSandboxBaseRuntime(n),(await n.snapshot()).snapshotId}finally{await n.delete().catch(t=>{e.context.log(`could not delete sandbox ${n.name}: ${errorMessage(t)}`)})}}async function publishTemplatePointer(e,t,n,r){if(n!==null)try{await n.delete()}catch(e){if(!isVercelSandboxMissingError(e))throw e}let{image:i,runtime:a,source:o,...s}=e.createOptions,c;try{c=await e.createSandbox({sandboxModule:t,createOptions:{...s,name:e.templateKey,persistent:!1,source:{snapshotId:r,type:`snapshot`}}})}catch(e){if(isVercelSandboxNameConflictError(e))return;throw e}await stopVercelSandbox(c)}async function ensureUsableSession(e){let ensureBaseRuntime=async t=>{t.created&&e.inheritsBaseRuntime||await ensureVercelSandboxBaseRuntime(t.sandbox)};try{return await ensureBaseRuntime(e.session),e.session}catch(t){if(e.session.created||!e.expired(t))throw t}try{await deleteUnusableVercelSandbox({createOptions:e.input.createOptions,sandboxModule:e.input.sandboxModule,sandboxName:e.session.sandbox.name})}catch(e){if(!isVercelSandboxMissingError(e))throw e}let t=await ensureSession(e.input);return await ensureBaseRuntime(t),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);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){let n={...e.createOptions};if(e.mounts!==void 0&&(n.mounts=e.mounts),e.snapshotId===void 0)return withBaseSetupNetworkPolicy({...n,name:t,persistent:!0});let{image:r,runtime:i,source:a,...o}=n;return{...o,name:t,persistent:!0,source:{snapshotId:e.snapshotId,type:`snapshot`}}}function createVercelConnection(e){return{extensions:{name:e.name,setNetworkPolicy:createVercelNetworkPolicySetter(e)},async readFile(t){return normalizeVercelReadStream(await e.readFile({path:t.path}))},async removePath(t){await e.fs.rm(t.path,{force:t.force,recursive:t.recursive,signal:t.abortSignal})},async spawn(t){let n=await e.runCommand({args:[`-lc`,t.command],cmd:`bash`,cwd:t.workingDirectory,detached:!0,env:t.env,signal:t.abortSignal});return adaptMultiplexedCommandToSandboxProcess({command:n,getOutput:e=>e.stream})},async stop(){await stopVercelSandbox(e)},async writeFiles(t){t.files.length!==0&&await e.writeFiles(await resolveVercelWriteFiles(e,t.files,t.abortSignal),{signal:t.abortSignal})}}}async function resolveVercelWriteFiles(e,t,n){let r=[],i=[],a=0;for(let o of t){let t=Buffer.byteLength(o.path)+1;i.length>0&&a+t>65536&&(r.push(...await resolveVercelPaths(e,i,n)),i=[],a=0),i.push(o.path),a+=t}return r.push(...await resolveVercelPaths(e,i,n)),t.map((e,t)=>{let n=r[t];if(n===void 0||!n.startsWith(`/`))throw Error(`Failed to resolve Vercel Sandbox write path: ${e.path}`);return{content:e.content,path:n}})}async function resolveVercelPaths(e,t,n){let r=await e.runCommand({args:[`-m`,`-z`,`--`,...t],cmd:`realpath`,signal:n});if(r.exitCode!==0){let e=(await r.stderr()).trim();throw Error(`Failed to resolve Vercel Sandbox write paths with realpath: ${e}`)}let i=(await r.stdout()).split(`\0`).slice(0,-1);if(i.length!==t.length)throw Error(`Failed to resolve Vercel Sandbox write paths: realpath printed ${i.length} paths for ${t.length} files.`);return i}const DEFAULT_SANDBOX_TIMEOUT_MS=18e5;export{createVercelSandbox};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{EVE_DEVELOPMENT_SANDBOX_RUN_ID_TAG}from"#execution/sandbox/development-run.js";import{toErrorMessage}from"#shared/errors.js";import{DOCKER_SANDBOX_LABEL,stopDockerContainerIfRunning}from"#execution/sandbox/bindings/docker-container.js";import{DockerUnavailableError,createDockerCli}from"#execution/sandbox/bindings/docker-cli.js";async function stopDevelopmentSandboxResources(e){try{await stopDevelopmentDockerResources(e.devRunId)}catch(t){e.log?.(`failed to stop development sandbox resources: ${toErrorMessage(t)}`)}}async function stopDevelopmentDockerResources(e){let t=createDockerCli(),n=[`label=${DOCKER_SANDBOX_LABEL}=1`,`label=${DOCKER_SANDBOX_LABEL}.tag.${EVE_DEVELOPMENT_SANDBOX_RUN_ID_TAG}=${e}`],r;try{r=await t.run([`ps`,`-q`,...n.flatMap(e=>[`--filter`,e])])}catch(e){if(e instanceof DockerUnavailableError)return;throw e}if(r.exitCode!==0)return;let i=r.stdout.trim().split(/\s+/u).filter(Boolean);await Promise.all(i.map(e=>stopDockerContainerIfRunning(t,e)))}export{stopDevelopmentSandboxResources};
|
|
@@ -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{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()+
|
|
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";const PREPARATION_WAIT_TIMEOUT_MS=6e5;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()+PREPARATION_WAIT_TIMEOUT_MS;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 after ${PREPARATION_WAIT_TIMEOUT_MS/6e4} minutes waiting for another request or eve dev worker to prepare sandbox environments (this request needs provider "${e.providerName}"). Check the eve dev output or run \`eve logs\` to see which step is slow, such as an image pull, a Dockerfile build, or a \`prepare\` callback. Retry after preparation finishes, or restart eve dev to cancel it.`);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,7 +1,5 @@
|
|
|
1
1
|
export declare const EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV = "EVE_DEVELOPMENT_SANDBOX_RUN_ID";
|
|
2
|
-
export declare const EVE_DEVELOPMENT_SANDBOX_METADATA_PATH_TAG = "eve.metadataPath";
|
|
3
2
|
export declare const EVE_DEVELOPMENT_SANDBOX_RUN_ID_TAG = "devRunId";
|
|
4
3
|
export declare function createDevelopmentSandboxRunId(): string;
|
|
5
4
|
export declare function getDevelopmentSandboxRunId(): string | undefined;
|
|
6
5
|
export declare function withDevelopmentSandboxTags(tags: Readonly<Record<string, string>> | undefined): Readonly<Record<string, string>> | undefined;
|
|
7
|
-
export declare function withDevelopmentSandboxMetadataPathTag(tags: Readonly<Record<string, string>> | undefined, metadataPath: string): Readonly<Record<string, string>> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomUUID}from"node:crypto";const EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV=`EVE_DEVELOPMENT_SANDBOX_RUN_ID`,
|
|
1
|
+
import{randomUUID}from"node:crypto";const EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV=`EVE_DEVELOPMENT_SANDBOX_RUN_ID`,EVE_DEVELOPMENT_SANDBOX_RUN_ID_TAG=`devRunId`;function createDevelopmentSandboxRunId(){return randomUUID()}function getDevelopmentSandboxRunId(){let e=process.env[EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV];return e===void 0||e.trim()===``?void 0:e}function withDevelopmentSandboxTags(e){let t=getDevelopmentSandboxRunId();return t===void 0?e:{...e,[EVE_DEVELOPMENT_SANDBOX_RUN_ID_TAG]:t}}export{EVE_DEVELOPMENT_SANDBOX_RUN_ID_ENV,EVE_DEVELOPMENT_SANDBOX_RUN_ID_TAG,createDevelopmentSandboxRunId,getDevelopmentSandboxRunId,withDevelopmentSandboxTags};
|
|
@@ -18,7 +18,3 @@ export declare function buildSandboxDockerfile(input: {
|
|
|
18
18
|
readonly dockerfile: SandboxDockerfile;
|
|
19
19
|
readonly imageReference: string;
|
|
20
20
|
}): Promise<void>;
|
|
21
|
-
export declare function publishDockerImageForMicrosandbox(input: {
|
|
22
|
-
readonly cli: DockerCli;
|
|
23
|
-
readonly imageReference: string;
|
|
24
|
-
}): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash,randomUUID}from"node:crypto";import{access,mkdir,rename,rm,writeFile}from"node:fs/promises";import{dirname,join}from"node:path";import{expectDockerSuccess}from"#execution/sandbox/bindings/docker-utils.js";async function materializeSandboxDockerfile(e){let t;try{t=await e.files.read(`Dockerfile`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let n=await e.files.list(),r=createHash(`sha256`),i=await Promise.all(n.map(async t=>({content:await e.files.read(t),path:t})));for(let e of i)r.update(e.path).update(`\0`).update(e.content).update(`\0`);let a=r.digest(`hex`),o=join(e.storagePath,`dockerfiles`,a);try{return await access(join(o,`Dockerfile`)),{contentHash:a,contextPath:o,path:join(o,`Dockerfile`)}}catch(e){if(!isFileNotFoundError(e))throw e}let s=`${o}.${randomUUID()}.tmp`;await Promise.all(i.map(async e=>{let t=join(s,e.path);await mkdir(dirname(t),{recursive:!0}),await writeFile(t,e.content)})),n.includes(`Dockerfile`)||(await mkdir(s,{recursive:!0}),await writeFile(join(s,`Dockerfile`),t)),await mkdir(dirname(o),{recursive:!0});try{await rename(s,o)}catch(e){try{await access(join(o,`Dockerfile`))}catch{throw e}}finally{await rm(s,{force:!0,recursive:!0})}return{contentHash:a,contextPath:o,path:join(o,`Dockerfile`)}}function dockerfileImageReference(e){return`eve-sandbox-dockerfile:${createHash(`sha256`).update(`${e.templateKey}:${e.dockerfile.contentHash}`).digest(`hex`).slice(0,24)}`}async function buildSandboxDockerfile(e){expectDockerSuccess(await e.cli.run([`build`,`--file`,e.dockerfile.path,`--tag`,e.imageReference,e.dockerfile.contextPath]),`build sandbox Dockerfile "${e.dockerfile.path}"`)}
|
|
1
|
+
import{createHash,randomUUID}from"node:crypto";import{access,mkdir,rename,rm,writeFile}from"node:fs/promises";import{dirname,join}from"node:path";import{expectDockerSuccess}from"#execution/sandbox/bindings/docker-utils.js";async function materializeSandboxDockerfile(e){let t;try{t=await e.files.read(`Dockerfile`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let n=await e.files.list(),r=createHash(`sha256`),i=await Promise.all(n.map(async t=>({content:await e.files.read(t),path:t})));for(let e of i)r.update(e.path).update(`\0`).update(e.content).update(`\0`);let a=r.digest(`hex`),o=join(e.storagePath,`dockerfiles`,a);try{return await access(join(o,`Dockerfile`)),{contentHash:a,contextPath:o,path:join(o,`Dockerfile`)}}catch(e){if(!isFileNotFoundError(e))throw e}let s=`${o}.${randomUUID()}.tmp`;await Promise.all(i.map(async e=>{let t=join(s,e.path);await mkdir(dirname(t),{recursive:!0}),await writeFile(t,e.content)})),n.includes(`Dockerfile`)||(await mkdir(s,{recursive:!0}),await writeFile(join(s,`Dockerfile`),t)),await mkdir(dirname(o),{recursive:!0});try{await rename(s,o)}catch(e){try{await access(join(o,`Dockerfile`))}catch{throw e}}finally{await rm(s,{force:!0,recursive:!0})}return{contentHash:a,contextPath:o,path:join(o,`Dockerfile`)}}function dockerfileImageReference(e){return`eve-sandbox-dockerfile:${createHash(`sha256`).update(`${e.templateKey}:${e.dockerfile.contentHash}`).digest(`hex`).slice(0,24)}`}async function buildSandboxDockerfile(e){expectDockerSuccess(await e.cli.run([`build`,`--file`,e.dockerfile.path,`--tag`,e.imageReference,e.dockerfile.contextPath]),`build sandbox Dockerfile "${e.dockerfile.path}"`)}function isFileNotFoundError(e){return e instanceof Error&&`code`in e&&e.code===`ENOENT`}export{buildSandboxDockerfile,dockerfileImageReference,materializeSandboxDockerfile};
|
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
import { type RuntimeCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
import { type SandboxProviderHandle } from "#shared/sandbox-provider.js";
|
|
2
|
+
import { type RuntimeSandboxRegistry } from "#runtime/sandbox/registry.js";
|
|
3
|
+
import { type SandboxAccess, type SandboxSessionEndReason, type SandboxState } from "#sandbox/state.js";
|
|
5
4
|
interface EnsureSandboxAccessInput {
|
|
6
5
|
readonly compiledArtifactsSource: RuntimeCompiledArtifactsSource;
|
|
7
6
|
readonly nodeId: string;
|
|
8
|
-
/** `false` when the sandbox outlives this access: it may
|
|
7
|
+
/** `false` when the sandbox outlives this access: it may neither delete nor end it. */
|
|
9
8
|
readonly ownsSandbox?: boolean;
|
|
10
9
|
readonly registry: RuntimeSandboxRegistry;
|
|
11
10
|
readonly sessionId: string;
|
|
12
11
|
readonly state: SandboxState | null;
|
|
12
|
+
/**
|
|
13
|
+
* How long the server-shutdown registry, which holds one connection per
|
|
14
|
+
* session, keeps this access's connection. `"session"`, the default for a
|
|
15
|
+
* session's own steps, keeps a connection without `close()` after release,
|
|
16
|
+
* so shutdown still stops the session's sandbox. `"call"` drops it at
|
|
17
|
+
* release, for a keyed tool call, whose sandbox no session ends. `"none"`
|
|
18
|
+
* never registers it, for a workflow step that borrows a session's sandbox
|
|
19
|
+
* outside its turns and must not replace or drop the session's own.
|
|
20
|
+
*/
|
|
21
|
+
readonly shutdownTracking?: "call" | "none" | "session";
|
|
13
22
|
}
|
|
14
23
|
/** The access `ensureSandboxAccess` builds, with what the opener may do beyond the sandbox API. */
|
|
15
24
|
export interface EnsuredSandboxAccess extends SandboxAccess {
|
|
16
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Permanently releases what the provider keeps under this access's key
|
|
27
|
+
* when the owning session ends, even when its last checkpoint recorded no
|
|
28
|
+
* sandbox. Waits for this access's open still in flight first.
|
|
29
|
+
*/
|
|
17
30
|
end(reason: SandboxSessionEndReason): Promise<void>;
|
|
18
31
|
/**
|
|
19
|
-
* Lets go of the
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* finished early never leaves that handle behind.
|
|
32
|
+
* Lets go of the connection this access opened, if any, when the step that
|
|
33
|
+
* opened it ends: closes it without stopping or deleting the sandbox.
|
|
34
|
+
* Waits for an open still in flight, so a caller that finished early never
|
|
35
|
+
* leaves that connection behind.
|
|
24
36
|
*/
|
|
25
|
-
|
|
37
|
+
release(): Promise<void>;
|
|
26
38
|
}
|
|
27
39
|
export declare function ensureSandboxAccess(input: EnsureSandboxAccessInput): Promise<EnsuredSandboxAccess>;
|
|
28
40
|
export {};
|
|
@@ -1 +1 @@
|
|
|
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{
|
|
1
|
+
import{randomUUID}from"node:crypto";import{createLogger}from"#internal/logging.js";import{getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{contextStorage}from"#context/container.js";import{resolve}from"node:path";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{trackActiveSandboxConnection,untrackActiveSandboxConnection}from"#execution/sandbox/active-connections.js";import{isToolSessionId}from"#execution/tool-session/id.js";import{ToolSessionSandboxUnsupportedError}from"#shared/sandbox-tool-session-error.js";import{loadSandboxPreparedArtifact}from"#runtime/sandbox/prepared-artifacts.js";import{createConnectionSession}from"#execution/sandbox/session.js";import{ensureDevelopmentSandboxesPrepared}from"#execution/sandbox/development-lazy-prewarm.js";import{owningSandboxDefinition}from"#runtime/sandbox/registry.js";import{getSessionEndWithArtifact,resolvePersistedSandboxSessionState}from"#sandbox/state.js";import{isSandboxPreparedArtifact}from"#shared/sandbox-provider.js";import{SandboxSessionGoneError}from"#shared/sandbox-session-gone-error.js";import{SandboxTemplateNotProvisionedError}from"#shared/sandbox-template-error.js";const pendingSandboxStarts=new Map,log=createLogger(`execution.sandbox`);async function ensureSandboxAccess(e){let t=e.registry.sandbox,n=t===null?void 0:owningSandboxDefinition(t),r=resolvePersistedSandboxSessionState(e.state?.session,n?.kind===`independent`?getSandboxEnvironmentRuntime(n.environment):void 0),i,a,o,s,c=e.shutdownTracking??`session`,l=getRuntimeCompiledArtifactsSandboxAppRoot(e.compiledArtifactsSource)??process.cwd(),captured=()=>({session:r});if(t===null)return{async captureState(){return captured()},async end(){},async get(){return null},async release(){},async stop(){}};let u=owningSandboxDefinition(t),d=t.inheritance?.nodeId??e.nodeId;function providerContext(t){let n=contextStorage.getStore()===void 0?{auth:{current:null,initiator:null},id:e.sessionId,turn:{id:t,sequence:0}}:buildCallbackContext().session;return{kind:isToolSessionId(e.sessionId)?`tool-session`:`session`,resolveProjectPath:e=>resolve(l,e),session:{...n,id:e.sessionId},storagePath:resolveSandboxCacheDirectory(l)}}function activeDefinition(){if(u.kind!==`independent`)throw Error(`Sandbox "${u.logicalPath}" uses defineParentSandbox(), but this agent has no parent sandbox to share. Only a declared subagent can share its parent's sandbox. Give this agent its own sandbox with defineSandbox() and an exported environment.`);return u}async function loadArtifact(t){let n=await loadSandboxPreparedArtifact({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:d,providerName:t.providerName});if(n===void 0)throw new SandboxTemplateNotProvisionedError({nodeId:d,providerName:t.providerName});return n}async function open(e,t,n,a){if(o!==void 0)throw Error("A sandbox definition can open only one sandbox. Call `environment.open()` once in the defineSandbox() selector and return that sandbox.");let s=activeDefinition();if(n!==s.environment)throw Error(`Sandbox "${s.logicalPath}" opened an environment other than the one it exports as \`environment\`. Call \`open()\` on the exported environment. A selector cannot open an environment created inside the selector or exported by another sandbox file.`);if(e!==getSandboxEnvironmentRuntime(s.environment))throw Error(`Sandbox "${s.logicalPath}" selected a different provider.`);if(r!==null)throw Error(`Sandbox "${s.logicalPath}" already opened this session's sandbox. Call \`environment.open()\` once in the defineSandbox() selector and return that sandbox.`);let c=await loadArtifact(e);return o=(async()=>{let n=await e.implementation.start(a,t,c);if(!isSandboxPreparedArtifact(n.state))throw Error(`Sandbox provider "${e.providerName}" returned non-serializable session state.`);let i=await openSandbox(e,a,n.connection,n.state);return r={generation:randomUUID(),providerName:e.providerName,state:n.state,stateProtocolVersion:e.stateProtocolVersion},i})().catch(e=>{throw o=void 0,e}),i=await o,i.sandbox}async function resumePersisted(e){if(r===null)throw Error(`Sandbox session state is missing.`);let t=getSandboxEnvironmentRuntime(activeDefinition().environment);if(r.providerName!==t.providerName)throw new SandboxSessionGoneError(`This session's sandbox was created by provider "${r.providerName}", but the agent now selects provider "${t.providerName}". eve cannot move a sandbox between providers, so the session continues in a fresh sandbox without the old sandbox's files.`);if(r.stateProtocolVersion!==t.stateProtocolVersion)throw new SandboxSessionGoneError(`Sandbox session state protocol ${r.stateProtocolVersion} is incompatible with provider "${t.providerName}" protocol ${t.stateProtocolVersion}.`);let n=await loadArtifact(t),a=r.state;return o=t.implementation.resume(e,n,a).then(n=>openSandbox(t,e,n,a)).catch(e=>{throw o=void 0,e}),i=await o,track(i),i}async function resolveOpened(){let t=activeDefinition(),n=getSandboxEnvironmentRuntime(t.environment),i=providerContext(`sandbox-initialization`);if(i.kind===`tool-session`&&n.implementation.toolSessions!==!0)throw new ToolSessionSandboxUnsupportedError(n.providerName);if(isEveDevEnvironment()&&e.compiledArtifactsSource.kind===`disk`&&await ensureDevelopmentSandboxesPrepared({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:d,providerName:n.providerName}),r!==null)try{return await resumePersisted(i)}catch(t){if(!SandboxSessionGoneError.is(t))throw t;log.warn(`session sandbox is gone, starting a fresh one`,{error:t,providerName:r.providerName,sessionId:e.sessionId}),r=null}let a=[l,d,e.sessionId].join(`\0`),o=pendingSandboxStarts.get(a);for(;o!==void 0;){if(r=await o,r!==null)return await resumePersisted(i);o=pendingSandboxStarts.get(a)}let s=startOpened(i),c=s.then(()=>r,()=>null);pendingSandboxStarts.set(a,c);try{return await s}finally{pendingSandboxStarts.get(a)===c&&pendingSandboxStarts.delete(a)}}async function startOpened(e){let t=activeDefinition();try{let n=await runWithSandboxConstructorRuntime({open:({environment:t,options:n,provider:r})=>open(r,n,t,e)},async()=>t.selector({session:e.session}));if(i===void 0||n!==i.sandbox)throw Error(`Sandbox "${t.logicalPath}" must return the sandbox it opens.`)}catch(e){throw await i?.close().catch(()=>void 0),i=void 0,o=void 0,r=null,e}return track(i),i}function requireOpened(){return s===void 0&&(s=resolveOpened().catch(e=>{throw s=void 0,e})),s}function track(t){c!==`none`&&trackActiveSandboxConnection({connection:t,providerName:t.providerName,sessionId:e.sessionId})}function forgetOpened(){let e=i;return i=void 0,o=void 0,s=void 0,e}function forgetSandbox(t){forgetOpened(),a=void 0,untrackActiveSandboxConnection({providerName:t,sessionId:e.sessionId}),r=null}return{environment:u.kind===`independent`?u.environment:void 0,async captureState(){return o!==void 0&&await o,captured()},async delete(t){if(e.ownsSandbox===!1)throw Error(`Only the owning session can delete this sandbox.`);let n=await requireOpened();await n.delete(t),forgetSandbox(n.providerName)},async end(t){if(e.ownsSandbox===!1)return;s!==void 0&&await s.catch(()=>void 0),await i?.close().catch(t=>{log.warn(`failed to close a sandbox connection at session end`,{error:t,sessionId:e.sessionId})});let n=getSandboxEnvironmentRuntime(activeDefinition().environment),a=r?.providerName===n.providerName&&r.stateProtocolVersion===n.stateProtocolVersion?r.state:null,o=providerContext(`sandbox-cleanup`),c=getSessionEndWithArtifact(n.implementation);c===void 0?await n.implementation.onSessionEnd(o,a,{reason:t}):await c(o,a,{artifact:await loadSandboxPreparedArtifact({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:d,providerName:n.providerName}),reason:t}),forgetSandbox(n.providerName)},async get(){return(await requireOpened()).sandbox},async release(){s!==void 0&&await s.catch(()=>void 0);let t=forgetOpened();a!==void 0&&c!==`session`&&(untrackActiveSandboxConnection({connection:a,providerName:a.providerName,sessionId:e.sessionId}),a=void 0),!(t===void 0||c===`session`&&!t.closable)&&(untrackActiveSandboxConnection({connection:t,providerName:t.providerName,sessionId:e.sessionId}),await t.close())},async stop(){let t=await requireOpened();if(await t.stop(),forgetOpened(),!t.closable){a=t;return}untrackActiveSandboxConnection({connection:t,providerName:t.providerName,sessionId:e.sessionId})}};async function openSandbox(t,n,r,i){let a;try{a=createConnectionSession(r)}catch(t){throw await r.close?.().catch(t=>{log.warn(`failed to close a sandbox connection eve could not use`,{error:t,sessionId:e.sessionId})}),t}let o=shared(()=>r.stop()),s=once(async()=>await r.close?.()),c={closable:r.close!==void 0,close:s,async delete(e){try{await s()}finally{await t.implementation.onSessionEnd(n,i,{abortSignal:e?.abortSignal,reason:`deleted`})}},providerName:t.providerName,sandbox:withRuntimeSandboxLifecycle(a,e=>c.delete(e),()=>c.stop()),async stop(){try{await o()}finally{await s()}}};return c}}function shared(e){let t;return()=>t??=e().finally(()=>{t=void 0})}function once(e){let t;return()=>t??=e().catch(e=>{throw t=void 0,e})}export{ensureSandboxAccess};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{shellQuote}from"#execution/sandbox/shell-quote.js";import{MAX_OUTPUT_BYTES}from"#execution/sandbox/truncate-output.js";import{normalizeModelPath}from"#execution/tools/file-state.js";import{resolveAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{ripgrepIsAvailable}from"#execution/sandbox/ripgrep-probe.js";async function executeGlobOnSandbox(e,t){let n=
|
|
2
|
-
`).filter(e=>e.length>0),
|
|
3
|
-
`),count:
|
|
1
|
+
import{shellQuote}from"#execution/sandbox/shell-quote.js";import{MAX_OUTPUT_BYTES}from"#execution/sandbox/truncate-output.js";import{normalizeModelPath}from"#execution/tools/file-state.js";import{resolveAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{ripgrepIsAvailable}from"#execution/sandbox/ripgrep-probe.js";async function executeGlobOnSandbox(e,t){let n=await resolveAbsoluteFilePath(e,t.path??`.`),r=normalizeModelPath(n),i=Math.min(Math.max(1,t.limit??100),1e3),a=await ripgrepIsAvailable(e)?buildRipgrepCommand({normalizedPath:r,pattern:t.pattern}):buildPosixFindCommand({normalizedPath:r,pattern:t.pattern}),o=await e.run({command:a});if(o.exitCode!==0&&o.exitCode!==1||o.exitCode===1&&o.stderr.trim().length>0)throw buildGlobExecutionError(a,o.exitCode,o.stderr);let s=o.stdout.split(`
|
|
2
|
+
`).filter(e=>e.length>0),c=s.length>i,l=c?s.slice(0,i):s,u=[],d=0,f=!1;for(let e of l){let t=normalizeModelPath(e),n=Buffer.byteLength(t,`utf8`)+1;if(d+n>MAX_OUTPUT_BYTES&&u.length>0){f=!0;break}u.push(t),d+=n}if(u.length===0)return{content:`No files found`,count:0,path:r,truncated:!1};let p=c||f,m=[...u];return p&&(m.push(``),m.push(`(Results truncated: showing first ${u.length} results out of more. Use a more specific path or pattern to narrow results.)`)),{content:m.join(`
|
|
3
|
+
`),count:u.length,path:r,truncated:p}}function buildRipgrepCommand(e){return[`rg --files --hidden`,`--glob '!.git/*'`,`--glob ${shellQuote(e.pattern)}`,shellQuote(e.normalizedPath)].join(` `)}function buildPosixFindCommand(e){let t=translateGlobToFindPattern(e.pattern),n=t.includes(`/`)?`-path ${shellQuote(`*/${t}`)}`:`-name ${shellQuote(t)}`;return[`find ${shellQuote(e.normalizedPath)}`,`-type f`,`-not -path '*/.git/*'`,n].join(` `)}function translateGlobToFindPattern(e){let t=e.replaceAll(`**`,`*`);for(;t.startsWith(`*/`);)t=t.slice(2);return t}function buildGlobExecutionError(e,t,n){let r=n.trim(),i=r.length>0?r:`no stderr output`;return Error(`glob failed (exit ${t}): ${i}\nCommand: ${e}`)}export{executeGlobOnSandbox};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{shellQuote}from"#execution/sandbox/shell-quote.js";import{MAX_OUTPUT_BYTES,capLineLength}from"#execution/sandbox/truncate-output.js";import{normalizeModelPath}from"#execution/tools/file-state.js";import{resolveAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{ripgrepIsAvailable}from"#execution/sandbox/ripgrep-probe.js";async function executeGrepOnSandbox(e,t){let n=
|
|
1
|
+
import{shellQuote}from"#execution/sandbox/shell-quote.js";import{MAX_OUTPUT_BYTES,capLineLength}from"#execution/sandbox/truncate-output.js";import{normalizeModelPath}from"#execution/tools/file-state.js";import{resolveAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{ripgrepIsAvailable}from"#execution/sandbox/ripgrep-probe.js";async function executeGrepOnSandbox(e,t){let n=await resolveAbsoluteFilePath(e,t.path??`.`),r=normalizeModelPath(n),i=Math.min(Math.max(1,t.limit??100),1e3),a=t.context!==void 0&&t.context>0?t.context:0,o=await ripgrepIsAvailable(e)?buildRipgrepCommand({contextLines:a,effectiveLimit:i,glob:t.glob,ignoreCase:t.ignoreCase??!1,literal:t.literal??!1,normalizedPath:r,pattern:t.pattern}):buildPosixGrepCommand({contextLines:a,effectiveLimit:i,glob:t.glob,ignoreCase:t.ignoreCase??!1,literal:t.literal??!1,normalizedPath:r,pattern:t.pattern}),s=await e.run({command:o});if(s.exitCode!==0&&s.exitCode!==1||s.exitCode===1&&s.stderr.trim().length>0)throw buildGrepExecutionError(o,s.exitCode,s.stderr);let c=s.stdout;return c.trim().length===0?{content:`No matches found`,matchCount:0,path:r,truncated:!1}:processOutput({effectiveLimit:i,normalizedPath:r,stdout:c})}function buildRipgrepCommand(e){let t=[`rg`,`--line-number`,`--color=never`,`--hidden`,`--glob '!.git/*'`];return e.ignoreCase&&t.push(`--ignore-case`),e.literal&&t.push(`--fixed-strings`),e.glob!==void 0&&t.push(`--glob ${shellQuote(e.glob)}`),e.contextLines>0&&t.push(`--context ${e.contextLines}`),t.push(`--max-count ${e.effectiveLimit}`),t.push(`--`),t.push(shellQuote(e.pattern)),t.push(shellQuote(e.normalizedPath)),t.join(` `)}function buildPosixGrepCommand(e){let t=[`grep`,`-r`,`-n`,`--exclude-dir=.git`];return e.ignoreCase&&t.push(`-i`),e.literal?t.push(`-F`):t.push(`-E`),e.glob!==void 0&&t.push(`--include=${shellQuote(e.glob)}`),e.contextLines>0&&t.push(`-C ${e.contextLines}`),t.push(`-m ${e.effectiveLimit}`),t.push(`-e ${shellQuote(e.pattern)}`),t.push(shellQuote(e.normalizedPath)),t.join(` `)}function processOutput(e){let t=e.stdout.split(`
|
|
2
2
|
`),n=[],r=0,i=0,a=!1;for(let e=0;e<t.length;e+=1){let o=t[e]??``;if(o.length===0&&e===t.length-1)continue;o!==`--`&&o.length>0&&/^.+:\d+:/.test(o)&&i++;let s=capLineLength(o),c=Buffer.byteLength(s,`utf8`)+1;if(r+c>MAX_OUTPUT_BYTES&&n.length>0){a=!0;break}n.push(s),r+=c}let o=a||i>=e.effectiveLimit,s=n.join(`
|
|
3
3
|
`);if(o){let t=[];i>=e.effectiveLimit&&t.push(`Match limit reached (${e.effectiveLimit}). Use a larger limit or more specific pattern.`),a&&t.push(`Output truncated due to size. Use a more specific path or pattern.`),s+=`\n\n[${t.join(` `)}]`}return{content:s,matchCount:i,path:e.normalizedPath,truncated:o}}function buildGrepExecutionError(e,t,n){let r=n.trim(),i=r.length>0?r:`no stderr output`;return Error(`grep failed (exit ${t}): ${i}\nCommand: ${e}`)}export{executeGrepOnSandbox};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{truncateTail}from"#execution/sandbox/truncate-output.js";function createLoggingSandboxSession(e){let{log:t,session:n}=e;return{...n,async run(e){t?.(`preparation run: ${formatCommand(e.command)}`);let r=await n.run(e);if(r.exitCode===1)throw Error(formatPreparationRunFailure(e.command,r));return r},async spawn(e){return t?.(`preparation spawn: ${formatCommand(e.command)}`),await n.spawn(e)},async writeFile(e){return t?.(`preparation write file: ${e.path}`),await n.writeFile(e)},async writeBinaryFile(e){return t?.(`preparation write binary file: ${e.path} (${e.content.byteLength} bytes)`),await n.writeBinaryFile(e)},async writeTextFile(e){return t?.(`preparation write text file: ${e.path} (${e.content.length} chars)`),await n.writeTextFile(e)},async removePath(e){return t?.(`preparation remove path: ${e.path}`),await n.removePath(e)}}}function formatPreparationRunFailure(e,t){return[`Sandbox preparation failed because sandbox.run command exited with code 1:`,e,``,`stdout:`,formatCapturedOutput(`stdout`,t.stdout),``,`stderr:`,formatCapturedOutput(`stderr`,t.stderr)].join(`
|
|
1
|
+
import{truncateTail}from"#execution/sandbox/truncate-output.js";function createLoggingSandboxSession(e){let{log:t,session:n}=e;return{...n,async run(e){t?.(`preparation run: ${formatCommand(e.command)}`);let r=await n.run(e);if(r.exitCode===1)throw Error(formatPreparationRunFailure(e.command,r));return r},async spawn(e){return t?.(`preparation spawn: ${formatCommand(e.command)}`),await n.spawn(e)},async writeFile(e){return t?.(`preparation write file: ${e.path}`),await n.writeFile(e)},async writeBinaryFile(e){return t?.(`preparation write binary file: ${e.path} (${e.content.byteLength} bytes)`),await n.writeBinaryFile(e)},async writeTextFile(e){return t?.(`preparation write text file: ${e.path} (${e.content.length} chars)`),await n.writeTextFile(e)},async writeFiles(e){return t?.(`preparation write files: ${e.files.length} files`),await n.writeFiles(e)},async removePath(e){return t?.(`preparation remove path: ${e.path}`),await n.removePath(e)}}}function formatPreparationRunFailure(e,t){return[`Sandbox preparation failed because sandbox.run command exited with code 1:`,e,``,`stdout:`,formatCapturedOutput(`stdout`,t.stdout),``,`stderr:`,formatCapturedOutput(`stderr`,t.stderr)].join(`
|
|
2
2
|
`)}function formatCapturedOutput(e,t){let n=truncateTail(t);return n.truncated?`[${e} truncated: showing last ${n.outputLines} of ${n.totalLines} lines]\n${n.output}`:n.output}function formatCommand(e){return truncateOneLine(e)}function truncateOneLine(e){let t=e.replaceAll(/\s+/g,` `).trim();return t.length<=240?t:`${t.slice(0,239)}…`}export{createLoggingSandboxSession};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SandboxJson, SandboxPrepareContext, SandboxProviderRuntime } from "#sandbox/provider.js";
|
|
2
|
+
import type { SandboxProviderFiles, SandboxProviderResourceFile } from "#shared/sandbox-provider.js";
|
|
2
3
|
import { type RuntimeCompiledArtifactsSource, type RuntimeDiskCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";
|
|
3
4
|
import { type ResolvedAgentGraphBundle } from "#runtime/graph.js";
|
|
4
5
|
import type { SandboxPreparedArtifactEntry } from "#shared/sandbox-prepared-artifacts.js";
|
|
@@ -16,9 +17,9 @@ export interface SandboxPreparedArtifactStore {
|
|
|
16
17
|
* them.
|
|
17
18
|
*/
|
|
18
19
|
type SandboxProviderPrepareDispatch = (input: {
|
|
19
|
-
readonly context:
|
|
20
|
+
readonly context: SandboxPrepareContext;
|
|
20
21
|
readonly provider: SandboxProviderRuntime;
|
|
21
|
-
}) => Promise<
|
|
22
|
+
}) => Promise<SandboxJson>;
|
|
22
23
|
/**
|
|
23
24
|
* Loads the compiled runtime graph for one authored app root and
|
|
24
25
|
* prepares every provider sandbox template required by that graph.
|
|
@@ -38,4 +39,23 @@ export declare function prewarmAppSandboxes(input: {
|
|
|
38
39
|
readonly dispatch?: SandboxProviderPrepareDispatch;
|
|
39
40
|
readonly preparedArtifactStore?: SandboxPreparedArtifactStore;
|
|
40
41
|
}): Promise<void>;
|
|
42
|
+
/** The compiled workspace and skill files one sandbox template seeds. */
|
|
43
|
+
export interface SandboxTemplateResources {
|
|
44
|
+
/** The compiled resource tree's content hash; absent when the agent has none. */
|
|
45
|
+
readonly key?: string;
|
|
46
|
+
/** The compiled resource directory on the host, holding `workspace/` and `skills/`. */
|
|
47
|
+
readonly path?: string;
|
|
48
|
+
readonly skills?: readonly SandboxProviderResourceFile[];
|
|
49
|
+
readonly workspace?: readonly SandboxProviderResourceFile[];
|
|
50
|
+
}
|
|
51
|
+
/** The context eve passes to a provider's `prepare()` for one template. */
|
|
52
|
+
export declare function createSandboxPrepareContext(input: {
|
|
53
|
+
readonly appRoot: string;
|
|
54
|
+
readonly files: SandboxProviderFiles;
|
|
55
|
+
readonly log: (message: string) => void;
|
|
56
|
+
readonly provider: Pick<SandboxProviderRuntime, "prepare" | "providerName">;
|
|
57
|
+
readonly resources: SandboxTemplateResources;
|
|
58
|
+
readonly sourceRevision: string;
|
|
59
|
+
readonly storagePath: string;
|
|
60
|
+
}): SandboxPrepareContext;
|
|
41
61
|
export {};
|
|
@@ -1 +1,2 @@
|
|
|
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{
|
|
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{shellQuote}from"#execution/sandbox/shell-quote.js";import{createSandboxProviderIdentity}from"#execution/sandbox/provider-identity.js";import{copyDirectoryAtomically}from"#execution/sandbox/bindings/local-provider-utils.js";import{writeSandboxPreparedArtifactsManifest}from"#runtime/sandbox/prepared-artifacts.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{createConnectionSession}from"#execution/sandbox/session.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{materializeWorkspaceDirectory}from"#runtime/workspace/seed-files.js";import{MODEL_SKILL_ROOT,resolveSandboxModelPath}from"#shared/skill-paths.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({label:t,nodeId:n,provider:i,...a})=>{let logProviderProgress=n=>{shouldLogSandboxPrewarmProgress(n)&&e.log?.(`eve: sandbox template "${t}" (${i.providerName}): ${n}`)};try{return{nodeId:n,provider:i,result:await r({context:createSandboxPrepareContext({...a,appRoot:e.appRoot,log:logProviderProgress,provider:i,storagePath:resolveSandboxCacheDirectory(e.appRoot)}),provider:i})}}catch(n){let r=formatPrewarmFailureForEnvironment({providerName:i.providerName,error:n});throw e.log?.(`eve: failed to initialize sandbox template "${t}" on provider "${i.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 loadSandboxProviderResources({compileDirectoryPath:e.compileDirectoryPath,workspaceResourceRoot:i});t.push({files:createSandboxProviderFiles(o),label:formatLabel(r),nodeId:r,provider:s,resources:c,sourceRevision:n.revisionHash})})),t.sort((e,t)=>e.label.localeCompare(t.label))}async function loadSandboxProviderResources(e){let{contentHash:t,logicalPath:n}=e.workspaceResourceRoot;if(t===void 0)return{};let r=`${e.compileDirectoryPath}/${n}`;return{key:t,path:r,...await materializeWorkspaceDirectory(r)}}function createSandboxPrepareContext(e){let{log:t,resources:n,storagePath:r}=e,{prepare:i}=e.provider,a=n.workspace??[],o=n.skills??[],s=n.key===void 0?void 0:n.path;return{files:e.files,isEmpty:a.length===0&&o.length===0&&i===void 0,log:t,async populate(e,n){let r=createConnectionSession(e);if(n?.mountedAt!==void 0&&s!==void 0)t(`copying workspace and skills from mounted resources`),await copyMountedResources(r,shellQuote(n.mountedAt));else if(a.length>0||o.length>0){t(`writing workspace and skills`);let bytes=e=>typeof e.content==`string`?Buffer.from(e.content):e.content;await r.writeFiles({files:[...a.map(e=>({content:bytes(e),path:r.resolvePath(e.relativePath)})),...await Promise.all(o.map(async e=>({content:bytes(e),path:await resolveSandboxModelPath({path:`${MODEL_SKILL_ROOT}/${e.relativePath}`,sandbox:r})})))]})}i!==void 0&&(t(`running sandbox preparation`),await i(createLoggingSandboxSession({log:t,session:r})))},resolveProjectPath:t=>resolve(e.appRoot,t),async resourcesDirectory(){if(n.key===void 0||s===void 0)return;let t=join(r,e.provider.providerName,`resources`,n.key);return await copyDirectoryAtomically(s,t),t},storagePath:r,templateKey(t){assertSandboxIdentity(t,`identity`,new WeakSet);for(let e of[`resources`,`sourceRevision`])if(Object.hasOwn(t,e))throw Error(`ctx.templateKey() reserves "${e}": eve adds the workspace and skill files and the sandbox source revision itself. Rename that identity field.`);let r=n.key;return createSandboxProviderIdentity({...t,resources:{skills:r===void 0?void 0:`${r}:skills`,workspace:r===void 0?void 0:`${r}:workspace`},sourceRevision:e.sourceRevision})}}}async function copyMountedResources(e,t){let n=shellQuote(e.resolvePath(`.`)),r=await e.run({command:[`set -e`,`if [ -d ${t}/workspace ]; then cp -a ${t}/workspace/. ${n}/; fi`,`if [ -d ${t}/skills ]; then`,` mkdir -p "$HOME/.agents"`,` rm -rf "$HOME/.agents/skills"`,` mkdir -p "$HOME/.agents/skills"`,` cp -a ${t}/skills/. "$HOME/.agents/skills/"`,`fi`].join(`
|
|
2
|
+
`)});if(r.exitCode!==0)throw Error(`Failed to hydrate sandbox resources: ${r.stderr||r.stdout}`)}function assertSandboxIdentity(e,t,n){if(e==null||typeof e==`function`||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return;let r=typeof e==`object`?Object.getPrototypeOf(e):void 0;if(typeof e!=`object`||!(Array.isArray(e)||r===Object.prototype||r===null))throw Error(`ctx.templateKey() accepts only JSON values, plain objects, arrays, and functions, but ${t} is ${describeIdentityValue(e)}. Pass a JSON form, such as a string.`);if(n.has(e))throw Error(`ctx.templateKey() cannot hash a circular value at ${t}.`);n.add(e);for(let[r,i]of Object.entries(e))assertSandboxIdentity(i,Array.isArray(e)?`${t}[${r}]`:`${t}.${r}`,n);n.delete(e)}function describeIdentityValue(e){return typeof e==`object`&&e?`a ${e.constructor?.name??`non-plain object`}`:typeof e==`number`?String(e):`a ${typeof e}`}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 `)}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. 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`}export{createSandboxPrepareContext,prewarmAppSandboxes};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{loadContext}from"#context/container.js";import{MAX_OUTPUT_BYTES,capLineLength}from"#execution/sandbox/truncate-output.js";import{buildReadFileTargetKey,createReadFileStamp,normalizeModelPath,setReadFileStamp}from"#execution/tools/file-state.js";import{resolveAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{detectImageMediaType,hasPdfHeader,readMediaMetadata}from"#internal/attachments/media-metadata.js";import{inlinesSandboxRefAsBytes}from"#internal/attachments/sandbox-refs.js";async function executeReadFileOnSandbox(e,t){let{filePath:n,offset:r,limit:i}=t,a=await resolveAbsoluteFilePath(e,n),o=normalizeModelPath(a),s=await e.readBinaryFile({path:a});if(s===null)throw Error(`File not found: ${
|
|
1
|
+
import{loadContext}from"#context/container.js";import{MAX_OUTPUT_BYTES,capLineLength}from"#execution/sandbox/truncate-output.js";import{buildReadFileTargetKey,createReadFileStamp,normalizeModelPath,setReadFileStamp}from"#execution/tools/file-state.js";import{resolveAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{detectImageMediaType,hasPdfHeader,readMediaMetadata}from"#internal/attachments/media-metadata.js";import{inlinesSandboxRefAsBytes}from"#internal/attachments/sandbox-refs.js";async function executeReadFileOnSandbox(e,t){let{filePath:n,offset:r,limit:i}=t,a=await resolveAbsoluteFilePath(e,n),o=normalizeModelPath(a),s=await e.readBinaryFile({path:a});if(s===null)throw Error(`File not found: ${o}. Verify the path exists and is accessible in the sandbox.`);if(hasPdfHeader(s))return buildFileReadResult(s,o,`application/pdf`);let c=decodeUtf8(s);if(c===void 0||c.includes(`\0`)){let e=detectImageMediaType(s);if(e!==void 0)return buildFileReadResult(s,o,e);throw Error(`File "${o}" appears to be a binary file. read_file only supports text files, PNG, JPEG, GIF, or WebP images, and PDFs.`)}let l=r??1,u=i??2e3;if(l<1)throw Error(`offset must be >= 1. Received: ${l}.`);let d=c.split(`
|
|
2
2
|
`),f=d.length>0&&d[d.length-1]===``?d.length-1:d.length;if(f===0){if(l>1)throw Error(`offset ${l} is past the end of the file (0 lines). Use the default offset to read an empty file.`)}else if(l>f)throw Error(`offset ${l} is past the end of the file (${f} lines).`);let p=createReadFileStamp({content:c,filePath:o}),m=buildReadFileTargetKey(o);if(setReadFileStamp(loadContext(),m,p),f===0)return{content:``,path:o,totalLines:0,truncated:!1};let h=l-1,g=Math.min(h+u,f),_=d.slice(h,g),v=[],y=0,b=!1;for(let e=0;e<_.length;e++){let t=`${l+e}: ${capLineLength(_[e]??``)}`,n=Buffer.byteLength(t,`utf8`)+1;if(y+n>MAX_OUTPUT_BYTES&&v.length>0){b=!0;break}v.push(t),y+=n}let x=v.join(`
|
|
3
3
|
`),S=l+v.length-1;return S<f||b?{content:x,nextOffset:S+1,path:o,totalLines:f,truncated:!0}:{content:x,path:o,totalLines:f,truncated:!1}}function decodeUtf8(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return}}function buildFileReadResult(e,t,n){let r=readMediaMetadata(e,n),i=n===`application/pdf`;if(!inlinesSandboxRefAsBytes({...r,path:t}))throw Error(i?`PDF "${t}" is ${e.byteLength} bytes; read_file shows PDFs up to 20 MiB. Split it or extract its text in the sandbox first.`:`Image "${t}" is ${describeImage(r)}; read_file shows images up to 3 MiB and 8000 pixels per side. Resize or crop it in the sandbox first.`);let a=r.pages===void 0?``:`, ${r.pages} ${r.pages===1?`page`:`pages`}`;return{content:`${i?`PDF`:`Image`} ${t} (${n}, ${e.byteLength} bytes${a}).`,file:r,path:t,totalLines:0,truncated:!1}}function describeImage(e){let t=`${e.size} bytes`;return e.width===void 0?t:`${e.width}x${e.height} pixels, ${t}`}export{executeReadFileOnSandbox};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SandboxSession } from "#public/definitions/sandbox.js";
|
|
2
2
|
/**
|
|
3
|
-
* Resolves a model-supplied
|
|
4
|
-
* sandbox
|
|
3
|
+
* Resolves a model-supplied file path to an absolute sandbox path: a leading
|
|
4
|
+
* `$HOME` through the sandbox's home, and a relative path from the workspace
|
|
5
|
+
* root, where `bash` commands start.
|
|
5
6
|
*/
|
|
6
7
|
export declare function resolveAbsoluteFilePath(sandbox: SandboxSession, filePath: string): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveSandboxModelPath}from"#shared/skill-paths.js";async function resolveAbsoluteFilePath(e,t){let n=await resolveSandboxModelPath({path:t,sandbox:e});if(
|
|
1
|
+
import{resolveSandboxModelPath}from"#shared/skill-paths.js";async function resolveAbsoluteFilePath(e,t){let n=await resolveSandboxModelPath({path:t,sandbox:e});if(n===`$HOME`||n.startsWith(`$HOME/`))throw Error(`Cannot resolve "${t}": the sandbox has no usable $HOME. Use an absolute path or a path relative to the workspace root.`);return e.resolvePath(n)}export{resolveAbsoluteFilePath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function ripgrepIsAvailable(e){try{let t=await e.run({command:`command -v rg >/dev/null 2>&1 || exit 127; rg --line-number --color=never --hidden --glob '!.git/*' --max-count 1 -- '__eve_ripgrep_probe_never_matches__' /
|
|
1
|
+
async function ripgrepIsAvailable(e){try{let t=await e.run({command:`command -v rg >/dev/null 2>&1 || exit 127; rg --line-number --color=never --hidden --glob '!.git/*' --max-count 1 -- '__eve_ripgrep_probe_never_matches__' /dev/null`});return(t.exitCode===0||t.exitCode===1)&&t.stderr.trim().length===0}catch{return!1}}export{ripgrepIsAvailable};
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type
|
|
3
|
-
setNetworkPolicy(policy: SandboxNetworkPolicy): Promise<void>;
|
|
4
|
-
};
|
|
5
|
-
import type { InternalSandboxSession, SandboxSession } from "#shared/sandbox-session.js";
|
|
6
|
-
export type { InternalSandboxSession };
|
|
1
|
+
import type { SandboxConnection } from "#sandbox/provider.js";
|
|
2
|
+
import type { SandboxSession } from "#shared/sandbox-session.js";
|
|
7
3
|
/**
|
|
8
4
|
* Tells agent-aware CLIs (such as `vercel`) that an automated agent runs
|
|
9
|
-
* the command, so they skip interactive prompts.
|
|
10
|
-
*
|
|
5
|
+
* the command, so they skip interactive prompts. Providers apply it beneath
|
|
6
|
+
* environment-level and per-call env so authors can override it.
|
|
11
7
|
*/
|
|
12
8
|
export declare const SANDBOX_AGENT_ENV: Readonly<Record<string, string>>;
|
|
13
9
|
/**
|
|
14
|
-
* Builds
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* variants
|
|
18
|
-
*
|
|
19
|
-
* provider's `spawn`: collect stdout/stderr to strings, await `wait()`,
|
|
20
|
-
* then return the combined result.
|
|
21
|
-
*
|
|
22
|
-
* Providers without mutable firewall support omit `setNetworkPolicy`; the
|
|
23
|
-
* dedicated Vercel provider wires it to `sandbox.update`.
|
|
10
|
+
* Builds the {@link SandboxSession} eve hands out from a provider's
|
|
11
|
+
* connection: every path and working directory resolves from the
|
|
12
|
+
* connection's workspace root, `run` collects `spawn`, the read and write
|
|
13
|
+
* variants share the connection's byte primitives, and the connection's
|
|
14
|
+
* extensions merge on top.
|
|
24
15
|
*/
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function buildSandboxSession(primitives: InternalSandboxSession): SandboxSession;
|
|
16
|
+
export declare function createConnectionSession<Extensions extends object>(connection: SandboxConnection<Extensions>): SandboxSession & Extensions;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{bufferToStream,streamToBuffer}from"./stream-utils.js";const SANDBOX_AGENT_ENV={AI_AGENT:`eve`};function
|
|
1
|
+
import{bufferToStream,streamToBuffer}from"./stream-utils.js";import{posix}from"node:path";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";const SANDBOX_AGENT_ENV={AI_AGENT:`eve`};function createConnectionSession(e){let t=e.workspaceRoot??WORKSPACE_ROOT;if(!posix.isAbsolute(t))throw Error(`Sandbox connection workspaceRoot must be an absolute path, but received "${t}".`);let resolveSandboxPath=e=>posix.resolve(t,e);async function read(t){return await e.readFile({abortSignal:t.abortSignal,path:resolveSandboxPath(t.path)})}async function readBytes(e){let t=await read(e);return t===null?null:ArrayBuffer.isView(t)?Buffer.from(t):await streamToBuffer(t)}async function write(t,n){await e.writeFiles({abortSignal:t.abortSignal,files:[{content:n,path:resolveSandboxPath(t.path)}]})}async function spawn(t){return await e.spawn({abortSignal:t.abortSignal,command:t.command,env:t.env??{},workingDirectory:resolveSandboxPath(t.workingDirectory??`.`)})}let n={resolvePath:resolveSandboxPath,async run(e){let t=await spawn(e),[n,r,{exitCode:i}]=await Promise.all([collectStreamToString(t.stdout),collectStreamToString(t.stderr),t.wait()]);return{exitCode:i,stderr:r,stdout:n}},spawn,async readFile(e){let t=await read(e);return t===null||!ArrayBuffer.isView(t)?t:bufferToStream(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},readBinaryFile:e=>readBytes(e),async readTextFile(e){validateReadTextFileOptions(e);let t=await readBytes(e);return t===null?null:applyLineRange(decodeBytes(t,e.encoding??`utf-8`),e)},async writeFile(e){await write(e,await streamToBuffer(e.content))},async writeBinaryFile(e){await write(e,Buffer.from(e.content))},async writeTextFile(e){let t=e.encoding??`utf-8`;await write(e,Buffer.from(e.content,t))},async writeFiles(t){await e.writeFiles({abortSignal:t.abortSignal,files:t.files.map(e=>({content:e.content,path:resolveSandboxPath(e.path)}))})},async removePath(t){await e.removePath({abortSignal:t.abortSignal,force:t.force,path:resolveSandboxPath(t.path),recursive:t.recursive})}},r=e.extensions??{},i=Object.keys(r).filter(e=>Object.hasOwn(n,e)||e===`delete`||e===`stop`);if(i.length>0)throw Error(`Sandbox connection extensions cannot replace the session members eve provides: ${i.join(`, `)}. Rename them.`);return{...r,...n}}async function collectStreamToString(e){let t=await streamToBuffer(e);return new TextDecoder().decode(t)}function validateReadTextFileOptions(e){let{startLine:t,endLine:n}=e;if(t!==void 0&&(!Number.isInteger(t)||t<1))throw Error(`startLine must be a positive integer (1-based).`);if(n!==void 0&&(!Number.isInteger(n)||n<1))throw Error(`endLine must be a positive integer (1-based).`);if(t!==void 0&&n!==void 0&&t>n)throw Error(`startLine must not be greater than endLine.`)}function splitLinesPreservingEndings(e){let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`\r`?r+1<e.length&&e[r+1]===`
|
|
2
2
|
`?(t.push(e.slice(n,r+2)),n=r+2,r++):(t.push(e.slice(n,r+1)),n=r+1):e[r]===`
|
|
3
|
-
`&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}function applyLineRange(e,t){if(t.startLine===void 0&&t.endLine===void 0)return e;let n=splitLinesPreservingEndings(e),r=n.length,i=t.startLine??1,a=Math.min(t.endLine??r,r);return i>r?``:n.slice(i-1,a).join(``)}function decodeBytes(e,t){return t===`utf-8`||t===`utf8`?new TextDecoder(`utf-8`,{fatal:!0}).decode(e):Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(t)}
|
|
3
|
+
`&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}function applyLineRange(e,t){if(t.startLine===void 0&&t.endLine===void 0)return e;let n=splitLinesPreservingEndings(e),r=n.length,i=t.startLine??1,a=Math.min(t.endLine??r,r);return i>r?``:n.slice(i-1,a).join(``)}function decodeBytes(e,t){return t===`utf-8`||t===`utf8`?new TextDecoder(`utf-8`,{fatal:!0}).decode(e):Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(t)}export{SANDBOX_AGENT_ENV,createConnectionSession};
|
|
@@ -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{TurnCancelledError}from"#harness/turn-cancellation.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{runMessageBatchBudget}from"#execution/tools/workflow/messages.js";import{isAppliedRunMessage,takeLeadingAppliedRunMessages}from"#execution/session-workflow-tool-run.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
|
|
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{TurnCancelledError}from"#harness/turn-cancellation.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{runMessageBatchBudget}from"#execution/tools/workflow/messages.js";import{isAppliedRunMessage,takeLeadingAppliedRunMessages}from"#execution/session-workflow-tool-run.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`&&!this.input.queue.isDuplicate(t)&&isSteeringMessage(t,this.identity)&&!this.input.cursor.sessionState.hasProxyInputRequests&&this.steeringController.abort()};get signal(){return this.controller.signal}dispose(){this.unsubscribe(),this.unsubscribeDelivery()}get steeringSignal(){return this.steeringController.signal}resetSteering(){this.steeringController.signal.aborted&&(this.unsubscribeDelivery(),this.steeringController=new AbortController,this.unsubscribeDelivery=this.input.inbox.onDelivery(this.signalSteering))}async admitBoundary(){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}takeAppliedRunMessages(){let e=runMessageBatchBudget(),t=[];for(let n=this.runtimeResults[0];n!==void 0;n=this.runtimeResults[0]){if(n===`cancelled`||n.kind!==`workflow`||!isAppliedRunMessage(n.message)||!e(n.message))return t;t.push(n.message),this.runtimeResults.shift()}return[...t,...takeLeadingAppliedRunMessages(this.input.inbox,e)]}async nextRuntimeEvent(e){for(;;){let t=await this.routeAdmittedToChildren();if(this.signal.aborted)return`cancelled`;if(t)return{kind:`steering`};let n=this.runtimeResults.shift();if(n!==void 0)return n;let r=await this.waitForInboxOrTimer(e);if(r!==void 0)return{callId:r,kind:`timeout`};let i=await this.input.inbox.next();if(i===void 0)throw Error(`Session inbox closed before runtime actions completed.`);if(await this.admit(i))return{kind:`input`}}}async 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`||e.kind===`session-failure`?!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 +1 @@
|
|
|
1
|
-
import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{isWorkflowMessage}from"#execution/session-inbox/inbox.js";import{SessionInboxPayloadError,decodeSessionInboxPayload}from"#execution/session-inbox/protocol.js";import{reportDroppedWirePayloadStep}from"#execution/report-dropped-wire-payload-step.js";async function admitSessionInboxPayload(e,t){if(e.kind===`session-failure`)throw Error(e.error);if(e.kind===`runtime-action-result`)return{kind:`runtime-action-result`,payload:e};if(isWorkflowMessage(e))return{kind:`workflow`,message:e};if(e.kind===`authorization-callback`)return t.queue.enqueueAuthorization(e.payloads),{kind:`consumed`};if(e.kind===`subagent-input-request`||e.kind===`subagent-authorization-event`)return{kind:`consumed`};let n;try{n=decodeSessionInboxPayload(e)}catch(e){if(!(e instanceof SessionInboxPayloadError))throw e;return await reportDroppedWirePayloadStep({detail:e.message,family:`session-inbox`}),{kind:`consumed`}}switch(n.kind){case`
|
|
1
|
+
import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{isWorkflowMessage}from"#execution/session-inbox/inbox.js";import{SessionInboxPayloadError,decodeSessionInboxPayload}from"#execution/session-inbox/protocol.js";import{reportDroppedWirePayloadStep}from"#execution/report-dropped-wire-payload-step.js";async function admitSessionInboxPayload(e,t){if(e.kind===`session-failure`)throw Error(e.error);if(e.kind===`runtime-action-result`)return{kind:`runtime-action-result`,payload:e};if(isWorkflowMessage(e))return{kind:`workflow`,message:e};if(e.kind===`authorization-callback`)return t.queue.enqueueAuthorization(e.payloads),{kind:`consumed`};if(e.kind===`subagent-input-request`||e.kind===`subagent-authorization-event`)return{kind:`consumed`};let n;try{n=decodeSessionInboxPayload(e)}catch(e){if(!(e instanceof SessionInboxPayloadError))throw e;return await reportDroppedWirePayloadStep({detail:e.message,family:`session-inbox`}),{kind:`consumed`}}switch(n.kind){case`session-prewarm`:return n.expectedOwnerRunId===getWorkflowMetadata().workflowRunId&&t.queue.prepareOnDeployment(n.targetDeploymentId),{kind:`consumed`};case`deliver`:{let e=t.queue.enqueueDelivery(n);return e===void 0?{kind:`consumed`}:{admission:e,kind:`delivery`}}case`clear`:case`compact`:return t.queue.enqueueControl(n.kind),{kind:`consumed`};case`session-timeout`:return n.ownerRunId===getWorkflowMetadata().workflowRunId&&t.queue.enqueueControl(`expired`),{kind:`consumed`};case`reset`:return t.queue.enqueueControl(`reset`),{kind:`cancel`};case`cancel`:return{kind:`cancel`}}}export{admitSessionInboxPayload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initialSessionProjection}from"#protocol/session-projection.js";import{isObject}from"#shared/guards.js";import{getBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{SESSION_CHECKPOINT_VERSION}from"#execution/session/handoff.js";import{LEGACY_HITL_STATE_KEYS,upgradeLegacyHitlState}from"#harness/hitl/requests.js";const MIN_SESSION_CHECKPOINT_VERSION=8,CHECKPOINT_UPGRADES={8:e=>{let{mode:t,...n}=e;return{...n,serializedContext:omitKeys(readRecord(n,`serializedContext`),[`eve.mode`])}},9:(e,t)=>{let n=readRecord(e,`sessionState`),r=readRecord(n,`snapshot`),{taskId:i,...a}=readRecord(r,`session`);return{...e,serializedContext:upgradeLegacyCaller(omitKeys(readRecord(e,`serializedContext`),[`eve.activityObserver`,`eve.activityPendingBlockers`,`eve.activityRootTurnId`,`eve.connectionSearchResults`,`eve.internal.backgroundToolExecution`,`eve.runtime.taskDeliveryPolicy`,`eve.turnTaskDelivery`])),sessionState:{...n,snapshot:{...r,session:{...a,history:readArray(a,`history`).map(renameBackgroundTaskMessage),state:upgradeSessionState(a.state,t)}}}}},10:e=>{let t=readRecord(e,`sessionState`),n=readRecord(t,`snapshot`),{history:r,...i}=readRecord(n,`session`);return t.version!==1&&refuse(`durable session version is not 1`),Array.isArray(r)||refuse(`session history is missing`),{...e,history:r,sessionState:{...t,snapshot:{...n,session:i},version:2}}},11:upgradeIdleLifecycle,12:e=>e,13:e=>e,14:e=>{let t=readRecord(e,`sessionState`),n=readRecord(t,`snapshot`),r=readRecord(n,`session`);if(r.state===void 0)return e;let i=upgradeLegacyHitlState(readRecord(r,`state`));return{...e,sessionState:{...t,snapshot:{...n,session:{...r,state:i}}}}}};function migrateSessionCheckpoint(e){if(!isObject(e))return{kind:`incompatible`,detail:`checkpoint is not an object`};let{version:t}=e;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<8||t>SESSION_CHECKPOINT_VERSION)return{kind:`incompatible`,detail:`checkpoint version ${JSON.stringify(t)} is outside the supported range 8-${SESSION_CHECKPOINT_VERSION}`};let n={childRunIdsToStop:[]},r=e;try{for(let e=t;e<SESSION_CHECKPOINT_VERSION;e++){let t=CHECKPOINT_UPGRADES[e];t===void 0&&refuse(`no upgrade from checkpoint version ${e}`),r={...t(r,n),version:e+1}}}catch(e){if(!(e instanceof CheckpointRefusal))throw e;return{kind:`incompatible`,detail:`checkpoint version ${t}: ${e.message}`}}return isCurrentCheckpoint(r)?{kind:`current`,checkpoint:r,childRunIdsToStop:n.childRunIdsToStop}:{kind:`incompatible`,detail:`checkpoint version ${t} is incomplete`}}function upgradeIdleLifecycle(e){let t=readRecord(e,`sessionState`);t.version!==2&&refuse(`durable session version is not 2`);let n=readRecord(t,`snapshot`),r=readRecord(n,`session`),i=r.state===void 0?{}:readRecord(r,`state`),a=i[`eve.harness.emission`]??t.emissionState;(!isObject(a)||typeof a.sessionStarted!=`boolean`||!Number.isSafeInteger(a.sequence)||a.sequence<0||!Number.isSafeInteger(a.stepIndex)||a.stepIndex<0||a.turnId!==``)&&refuse(`lifecycle position is malformed or a turn is still open`),[LEGACY_HITL_STATE_KEYS.signIns,`eve.runtime.pendingInputBatch`,`eve.runtime.pendingCoordinationBatch`,`eve.runtime.deferredStepInput`,`eve.harness.pendingWorkflowInterrupt`].some(e=>i[e]!==void 0)&&refuse(`session holds pending work`);let o=i[`eve.runtime.pendingInputBatches`];o!==void 0&&(!Array.isArray(o)||o.length>0)&&refuse(`session holds pending input`);let s=i[LEGACY_HITL_STATE_KEYS.relays];(t.hasProxyInputRequests!==!1||s!==void 0&&(!isObject(s)||Object.keys(s).length>0))&&refuse(`session holds relayed input`);try{getBlockingWorkflowToolRuns(i).length>0&&refuse(`session holds workflow runs`)}catch(e){if(e instanceof CheckpointRefusal)throw e;refuse(`workflow tool run registry is incompatible`)}let c=i[LEGACY_HITL_STATE_KEYS.approvals];c!==void 0&&(!isObject(c)||!isObject(c.activeCandidates)||Object.keys(c.activeCandidates).length>0)&&refuse(`session holds approval candidates or malformed approval state`);let l=i[`eve.runtime.hitl.approvedTools`]??[];(!Array.isArray(l)||!l.every(e=>typeof e==`string`))&&refuse(`approval grants are malformed`),(i[`eve.harness.turnState`]!==void 0||i[`eve.harness.sessionProjection`]!==void 0)&&refuse(`v11 checkpoint already contains machine state`);let u={...initialSessionProjection(),nextSequence:a.sequence};a.sessionStarted&&(u.started=!0);let d={...omitKeys(i,[`eve.harness.emission`,`eve.runtime.hitl.approvedTools`,`eve.runtime.pendingInputBatches`]),"eve.harness.sessionProjection":u};l.length>0&&(d[`eve.harness.turnState`]={grants:[...l],suspended:[]});let{emissionState:f,...p}=t;return{...e,sessionState:{...p,snapshot:{...n,session:{...r,state:d}}}}}function isCurrentCheckpoint(e){return isObject(e)&&e.version===SESSION_CHECKPOINT_VERSION&&Array.isArray(e.history)&&isObject(e.serializedContext)&&isObject(e.sessionState)}var CheckpointRefusal=class extends Error{};function refuse(e){throw new CheckpointRefusal(e)}function readRecord(e,t){let n=e[t];return isObject(n)||refuse(`${t} is not an object`),n}function readArray(e,t){let n=e[t];return Array.isArray(n)||refuse(`${t} is not an array`),n}function omitKeys(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e)))}function upgradeLegacyCaller(e){let t=e[`eve.sessionCallback`];if(!isObject(t))return e;let{taskId:n,...r}=t;return{...e,"eve.legacyRemoteAgentCaller":typeof n==`string`&&n.length>0?{taskId:n}:{},"eve.sessionCallback":r}}function renameBackgroundTaskMessage(e){return isObject(e)&&e.role===`user`&&e.kind===`execution.background_task`?{...e,kind:`task.result`}:e}function upgradeSessionState(e,t){return isObject(e)?omitKeys(e,[...dropSettledWorkflowToolRuns(e),...stopIdleSubagents(e,t)]):e}function dropSettledWorkflowToolRuns(e){let t=e[`eve.workflowTool`];if(!isObject(t)||t.version!==3)return[];let n=t.runs;return(!Array.isArray(n)||!n.every(e=>isObject(e)&&e.lifetime===`session`&&isObject(e.task)&&e.task.outcome!==void 0))&&refuse(`workflow tool run registry version 3 holds unsettled runs`),[`eve.workflowTool`]}function stopIdleSubagents(e,t){let n=e[`eve.agent.handles`];if(n===void 0)return[];(!isObject(n)||!Array.isArray(n.handles))&&refuse(`subagent handles are malformed`);for(let e of n.handles){(!isObject(e)||e.phase!==`parked`&&e.phase!==`available`)&&refuse(`a subagent session is still working`);let n=e.address;isObject(n)&&(n.kind===`agent/local`||n.kind===`agent/self`)&&typeof n.sessionId==`string`&&n.sessionId.length>0&&t.childRunIdsToStop.push(n.sessionId)}return[`eve.agent.handles`]}export{MIN_SESSION_CHECKPOINT_VERSION,migrateSessionCheckpoint};
|
|
1
|
+
import{initialSessionProjection}from"#protocol/session-projection.js";import{isObject}from"#shared/guards.js";import{DELIVERY_IDEMPOTENCY_WINDOW,MAX_DELIVERY_IDEMPOTENCY_KEY_LENGTH}from"#channel/delivery-idempotency.js";import{getBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{SESSION_CHECKPOINT_VERSION}from"#execution/session/handoff.js";import{LEGACY_HITL_STATE_KEYS,upgradeLegacyHitlState}from"#harness/hitl/requests.js";const MIN_SESSION_CHECKPOINT_VERSION=8,CHECKPOINT_UPGRADES={8:e=>{let{mode:t,...n}=e;return{...n,serializedContext:omitKeys(readRecord(n,`serializedContext`),[`eve.mode`])}},9:(e,t)=>{let n=readRecord(e,`sessionState`),r=readRecord(n,`snapshot`),{taskId:i,...a}=readRecord(r,`session`);return{...e,serializedContext:upgradeLegacyCaller(omitKeys(readRecord(e,`serializedContext`),[`eve.activityObserver`,`eve.activityPendingBlockers`,`eve.activityRootTurnId`,`eve.connectionSearchResults`,`eve.internal.backgroundToolExecution`,`eve.runtime.taskDeliveryPolicy`,`eve.turnTaskDelivery`])),sessionState:{...n,snapshot:{...r,session:{...a,history:readArray(a,`history`).map(renameBackgroundTaskMessage),state:upgradeSessionState(a.state,t)}}}}},10:e=>{let t=readRecord(e,`sessionState`),n=readRecord(t,`snapshot`),{history:r,...i}=readRecord(n,`session`);return t.version!==1&&refuse(`durable session version is not 1`),Array.isArray(r)||refuse(`session history is missing`),{...e,history:r,sessionState:{...t,snapshot:{...n,session:i},version:2}}},11:upgradeIdleLifecycle,12:e=>e,13:e=>e,14:e=>{let t=readRecord(e,`sessionState`),n=readRecord(t,`snapshot`),r=readRecord(n,`session`);if(r.state===void 0)return e;let i=upgradeLegacyHitlState(readRecord(r,`state`));return{...e,sessionState:{...t,snapshot:{...n,session:{...r,state:i}}}}},15:e=>({...e,admittedDeliveryKeys:[]}),16:e=>e};function migrateSessionCheckpoint(e){if(!isObject(e))return{kind:`incompatible`,detail:`checkpoint is not an object`};let{version:t}=e;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<8||t>SESSION_CHECKPOINT_VERSION)return{kind:`incompatible`,detail:`checkpoint version ${JSON.stringify(t)} is outside the supported range 8-${SESSION_CHECKPOINT_VERSION}`};let n={childRunIdsToStop:[]},r=e;try{for(let e=t;e<SESSION_CHECKPOINT_VERSION;e++){let t=CHECKPOINT_UPGRADES[e];t===void 0&&refuse(`no upgrade from checkpoint version ${e}`),r={...t(r,n),version:e+1}}}catch(e){if(!(e instanceof CheckpointRefusal))throw e;return{kind:`incompatible`,detail:`checkpoint version ${t}: ${e.message}`}}return isCurrentCheckpoint(r)?{kind:`current`,checkpoint:r,childRunIdsToStop:n.childRunIdsToStop}:{kind:`incompatible`,detail:`checkpoint version ${t} is incomplete`}}function upgradeIdleLifecycle(e){let t=readRecord(e,`sessionState`);t.version!==2&&refuse(`durable session version is not 2`);let n=readRecord(t,`snapshot`),r=readRecord(n,`session`),i=r.state===void 0?{}:readRecord(r,`state`),a=i[`eve.harness.emission`]??t.emissionState;(!isObject(a)||typeof a.sessionStarted!=`boolean`||!Number.isSafeInteger(a.sequence)||a.sequence<0||!Number.isSafeInteger(a.stepIndex)||a.stepIndex<0||a.turnId!==``)&&refuse(`lifecycle position is malformed or a turn is still open`),[LEGACY_HITL_STATE_KEYS.signIns,`eve.runtime.pendingInputBatch`,`eve.runtime.pendingCoordinationBatch`,`eve.runtime.deferredStepInput`,`eve.harness.pendingWorkflowInterrupt`].some(e=>i[e]!==void 0)&&refuse(`session holds pending work`);let o=i[`eve.runtime.pendingInputBatches`];o!==void 0&&(!Array.isArray(o)||o.length>0)&&refuse(`session holds pending input`);let s=i[LEGACY_HITL_STATE_KEYS.relays];(t.hasProxyInputRequests!==!1||s!==void 0&&(!isObject(s)||Object.keys(s).length>0))&&refuse(`session holds relayed input`);try{getBlockingWorkflowToolRuns(i).length>0&&refuse(`session holds workflow runs`)}catch(e){if(e instanceof CheckpointRefusal)throw e;refuse(`workflow tool run registry is incompatible`)}let c=i[LEGACY_HITL_STATE_KEYS.approvals];c!==void 0&&(!isObject(c)||!isObject(c.activeCandidates)||Object.keys(c.activeCandidates).length>0)&&refuse(`session holds approval candidates or malformed approval state`);let l=i[`eve.runtime.hitl.approvedTools`]??[];(!Array.isArray(l)||!l.every(e=>typeof e==`string`))&&refuse(`approval grants are malformed`),(i[`eve.harness.turnState`]!==void 0||i[`eve.harness.sessionProjection`]!==void 0)&&refuse(`v11 checkpoint already contains machine state`);let u={...initialSessionProjection(),nextSequence:a.sequence};a.sessionStarted&&(u.started=!0);let d={...omitKeys(i,[`eve.harness.emission`,`eve.runtime.hitl.approvedTools`,`eve.runtime.pendingInputBatches`]),"eve.harness.sessionProjection":u};l.length>0&&(d[`eve.harness.turnState`]={grants:[...l],suspended:[]});let{emissionState:f,...p}=t;return{...e,sessionState:{...p,snapshot:{...n,session:{...r,state:d}}}}}function isCurrentCheckpoint(e){return isObject(e)&&e.version===SESSION_CHECKPOINT_VERSION&&Array.isArray(e.admittedDeliveryKeys)&&e.admittedDeliveryKeys.length<=DELIVERY_IDEMPOTENCY_WINDOW&&e.admittedDeliveryKeys.every(e=>typeof e==`string`&&e.length>0&&e.length<=MAX_DELIVERY_IDEMPOTENCY_KEY_LENGTH)&&Array.isArray(e.history)&&isObject(e.serializedContext)&&isObject(e.sessionState)}var CheckpointRefusal=class extends Error{};function refuse(e){throw new CheckpointRefusal(e)}function readRecord(e,t){let n=e[t];return isObject(n)||refuse(`${t} is not an object`),n}function readArray(e,t){let n=e[t];return Array.isArray(n)||refuse(`${t} is not an array`),n}function omitKeys(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e)))}function upgradeLegacyCaller(e){let t=e[`eve.sessionCallback`];if(!isObject(t))return e;let{taskId:n,...r}=t;return{...e,"eve.legacyRemoteAgentCaller":typeof n==`string`&&n.length>0?{taskId:n}:{},"eve.sessionCallback":r}}function renameBackgroundTaskMessage(e){return isObject(e)&&e.role===`user`&&e.kind===`execution.background_task`?{...e,kind:`task.result`}:e}function upgradeSessionState(e,t){return isObject(e)?omitKeys(e,[...dropSettledWorkflowToolRuns(e),...stopIdleSubagents(e,t)]):e}function dropSettledWorkflowToolRuns(e){let t=e[`eve.workflowTool`];if(!isObject(t)||t.version!==3)return[];let n=t.runs;return(!Array.isArray(n)||!n.every(e=>isObject(e)&&e.lifetime===`session`&&isObject(e.task)&&e.task.outcome!==void 0))&&refuse(`workflow tool run registry version 3 holds unsettled runs`),[`eve.workflowTool`]}function stopIdleSubagents(e,t){let n=e[`eve.agent.handles`];if(n===void 0)return[];(!isObject(n)||!Array.isArray(n.handles))&&refuse(`subagent handles are malformed`);for(let e of n.handles){(!isObject(e)||e.phase!==`parked`&&e.phase!==`available`)&&refuse(`a subagent session is still working`);let n=e.address;isObject(n)&&(n.kind===`agent/local`||n.kind===`agent/self`)&&typeof n.sessionId==`string`&&n.sessionId.length>0&&t.childRunIdsToStop.push(n.sessionId)}return[`eve.agent.handles`]}export{MIN_SESSION_CHECKPOINT_VERSION,migrateSessionCheckpoint};
|