niceeval 0.13.2 → 0.13.3
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/dist/agents/bub.cjs +4 -4
- package/dist/agents/bub.cjs.map +1 -1
- package/dist/agents/bub.d.cts +2 -2
- package/dist/agents/bub.d.mts +2 -2
- package/dist/agents/bub.d.ts +2 -2
- package/dist/agents/claude-code-native.cjs +213 -0
- package/dist/agents/claude-code-native.cjs.map +1 -0
- package/dist/agents/claude-code-native.d.cts +5 -0
- package/dist/agents/claude-code-native.d.mts +5 -0
- package/dist/agents/claude-code-native.d.ts +5 -0
- package/dist/agents/claude-code-native.js +6 -0
- package/dist/agents/claude-code-native.js.map +1 -0
- package/dist/agents/claude-code.cjs +26 -80
- package/dist/agents/claude-code.cjs.map +1 -1
- package/dist/agents/codex-app-server.cjs +314 -0
- package/dist/agents/codex-app-server.cjs.map +1 -0
- package/dist/agents/codex-app-server.d.cts +9 -0
- package/dist/agents/codex-app-server.d.mts +9 -0
- package/dist/agents/codex-app-server.d.ts +9 -0
- package/dist/agents/codex-app-server.js +6 -0
- package/dist/agents/codex-app-server.js.map +1 -0
- package/dist/agents/codex.cjs +19 -68
- package/dist/agents/codex.cjs.map +1 -1
- package/dist/agents/codex.d.cts +3 -3
- package/dist/agents/codex.d.mts +3 -3
- package/dist/agents/codex.d.ts +3 -3
- package/dist/agents/index.cjs +3 -1
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +1 -0
- package/dist/agents/index.d.mts +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.js +84 -82
- package/dist/agents/index.mjs +84 -82
- package/dist/agents/managed-jsonl.cjs +207 -0
- package/dist/agents/managed-jsonl.cjs.map +1 -0
- package/dist/agents/managed-jsonl.d.cts +39 -0
- package/dist/agents/managed-jsonl.d.mts +39 -0
- package/dist/agents/managed-jsonl.d.ts +39 -0
- package/dist/agents/managed-jsonl.js +6 -0
- package/dist/agents/managed-jsonl.js.map +1 -0
- package/dist/agents/managed-process.cjs +31 -0
- package/dist/agents/managed-process.cjs.map +1 -0
- package/dist/agents/managed-process.d.cts +3 -0
- package/dist/agents/managed-process.d.mts +3 -0
- package/dist/agents/managed-process.d.ts +3 -0
- package/dist/agents/managed-process.js +6 -0
- package/dist/agents/managed-process.js.map +1 -0
- package/dist/agents/omp.cjs +18 -1
- package/dist/agents/omp.cjs.map +1 -1
- package/dist/agents/sdk-streams.cjs +11 -4
- package/dist/agents/sdk-streams.cjs.map +1 -1
- package/dist/agents/types.cjs.map +1 -1
- package/dist/agents/types.d.cts +8 -0
- package/dist/agents/types.d.mts +8 -0
- package/dist/agents/types.d.ts +8 -0
- package/dist/analysis/bindings.cjs +74 -19
- package/dist/analysis/bindings.cjs.map +1 -1
- package/dist/analysis/bindings.d.cts +534 -156
- package/dist/analysis/bindings.d.mts +534 -156
- package/dist/analysis/bindings.d.ts +534 -156
- package/dist/analysis/domain-view.cjs.map +1 -1
- package/dist/analysis/domain-view.d.cts +137 -8
- package/dist/analysis/domain-view.d.mts +137 -8
- package/dist/analysis/domain-view.d.ts +137 -8
- package/dist/analysis/index.cjs.map +1 -1
- package/dist/analysis/index.d.cts +1 -1
- package/dist/analysis/index.d.mts +1 -1
- package/dist/analysis/index.d.ts +1 -1
- package/dist/assertions/api.cjs.map +1 -1
- package/dist/assertions/api.d.cts +62 -0
- package/dist/assertions/api.d.mts +62 -0
- package/dist/assertions/api.d.ts +62 -0
- package/dist/assertions/judge.cjs +56 -5
- package/dist/assertions/judge.cjs.map +1 -1
- package/dist/assertions/match.cjs +66 -42
- package/dist/assertions/match.cjs.map +1 -1
- package/dist/assertions/match.d.cts +13 -0
- package/dist/assertions/match.d.mts +13 -0
- package/dist/assertions/match.d.ts +13 -0
- package/dist/assertions/record/attachment.cjs +104 -33
- package/dist/assertions/record/attachment.cjs.map +1 -1
- package/dist/assertions/record/attachment.d.cts +294 -57
- package/dist/assertions/record/attachment.d.mts +294 -57
- package/dist/assertions/record/attachment.d.ts +294 -57
- package/dist/assertions/record/codec.cjs +91 -17
- package/dist/assertions/record/codec.cjs.map +1 -1
- package/dist/assertions/record/codec.d.cts +280 -52
- package/dist/assertions/record/codec.d.mts +280 -52
- package/dist/assertions/record/codec.d.ts +280 -52
- package/dist/assertions/record/index.js +2 -0
- package/dist/assertions/record/model.cjs +16 -0
- package/dist/assertions/record/model.cjs.map +1 -1
- package/dist/assertions/record/model.d.cts +120 -13
- package/dist/assertions/record/model.d.mts +120 -13
- package/dist/assertions/record/model.d.ts +120 -13
- package/dist/assertions/record/model.js +2 -0
- package/dist/assertions/record/producer.cjs +70 -50
- package/dist/assertions/record/producer.cjs.map +1 -1
- package/dist/assertions/record/producer.d.cts +8 -7
- package/dist/assertions/record/producer.d.mts +8 -7
- package/dist/assertions/record/producer.d.ts +8 -7
- package/dist/assertions/runtime.cjs +49 -7
- package/dist/assertions/runtime.cjs.map +1 -1
- package/dist/cli/application.cjs +40 -0
- package/dist/cli/application.cjs.map +1 -0
- package/dist/cli/application.d.cts +129 -0
- package/dist/cli/application.d.mts +129 -0
- package/dist/cli/application.d.ts +129 -0
- package/dist/cli/application.js +24 -0
- package/dist/cli/application.js.map +1 -0
- package/dist/cli/bootstrap.cjs +10 -4
- package/dist/cli/bootstrap.cjs.map +1 -1
- package/dist/cli/node-application.cjs +123 -0
- package/dist/cli/node-application.cjs.map +1 -0
- package/dist/cli/node-application.d.cts +14 -0
- package/dist/cli/node-application.d.mts +14 -0
- package/dist/cli/node-application.d.ts +14 -0
- package/dist/cli/node-application.js +26 -0
- package/dist/cli/node-application.js.map +1 -0
- package/dist/cli/program.cjs +2807 -0
- package/dist/cli/program.cjs.map +1 -0
- package/dist/cli/program.d.cts +352 -0
- package/dist/cli/program.d.mts +352 -0
- package/dist/cli/program.d.ts +352 -0
- package/dist/cli/program.js +36 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/project-configuration.cjs +134 -0
- package/dist/cli/project-configuration.cjs.map +1 -0
- package/dist/cli/project-configuration.d.cts +64 -0
- package/dist/cli/project-configuration.d.mts +64 -0
- package/dist/cli/project-configuration.d.ts +64 -0
- package/dist/cli/project-configuration.js +22 -0
- package/dist/cli/project-configuration.js.map +1 -0
- package/dist/cli/record.cjs +20 -4
- package/dist/cli/record.cjs.map +1 -1
- package/dist/cli/record.d.cts +3 -3
- package/dist/cli/record.d.mts +3 -3
- package/dist/cli/record.d.ts +3 -3
- package/dist/cli.cjs +19 -3130
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +2 -148
- package/dist/cli.d.mts +2 -148
- package/dist/cli.d.ts +2 -148
- package/dist/cli.js +22 -30
- package/dist/context/assert-first.cjs +21 -15
- package/dist/context/assert-first.cjs.map +1 -1
- package/dist/context/assert-first.d.cts +1 -0
- package/dist/context/assert-first.d.mts +1 -0
- package/dist/context/assert-first.d.ts +1 -0
- package/dist/context/attempt-resources.cjs +13 -0
- package/dist/context/attempt-resources.cjs.map +1 -0
- package/dist/context/attempt-resources.d.cts +3 -0
- package/dist/context/attempt-resources.d.mts +3 -0
- package/dist/context/attempt-resources.d.ts +3 -0
- package/dist/context/attempt-resources.js +8 -0
- package/dist/context/attempt-resources.js.map +1 -0
- package/dist/context/session.cjs +4 -3
- package/dist/context/session.cjs.map +1 -1
- package/dist/context/session.d.cts +1 -0
- package/dist/context/session.d.mts +1 -0
- package/dist/context/session.d.ts +1 -0
- package/dist/eval/record/verdict.cjs +3 -2
- package/dist/eval/record/verdict.cjs.map +1 -1
- package/dist/experiment/host/index.cjs +1 -6
- package/dist/experiment/host/index.cjs.map +1 -1
- package/dist/experiment/host/index.d.cts +1 -0
- package/dist/experiment/host/index.d.mts +1 -0
- package/dist/experiment/host/index.d.ts +1 -0
- package/dist/load-config.cjs +13 -4
- package/dist/load-config.cjs.map +1 -1
- package/dist/load-config.d.cts +4 -3
- package/dist/load-config.d.mts +4 -3
- package/dist/load-config.d.ts +4 -3
- package/dist/load-config.js +4 -2
- package/dist/o11y/parsers/codex.cjs +29 -7
- package/dist/o11y/parsers/codex.cjs.map +1 -1
- package/dist/record/codec/core.d.cts +0 -2
- package/dist/record/codec/core.d.mts +0 -2
- package/dist/record/codec/core.d.ts +0 -2
- package/dist/record/codec/identifiers.cjs +2 -3
- package/dist/record/codec/identifiers.cjs.map +1 -1
- package/dist/record/codec/identifiers.d.cts +1 -2
- package/dist/record/codec/identifiers.d.mts +1 -2
- package/dist/record/codec/identifiers.d.ts +1 -2
- package/dist/record/codec/identifiers.js +10 -12
- package/dist/record/codec/index.js +42 -44
- package/dist/record/definition/attachment.cjs +1 -0
- package/dist/record/definition/attachment.cjs.map +1 -1
- package/dist/record/definition/attachment.d.cts +14 -0
- package/dist/record/definition/attachment.d.mts +14 -0
- package/dist/record/definition/attachment.d.ts +14 -0
- package/dist/record/family/assertions-v1.cjs +104 -0
- package/dist/record/family/assertions-v1.cjs.map +1 -0
- package/dist/record/family/assertions-v1.d.cts +2 -0
- package/dist/record/family/assertions-v1.d.mts +2 -0
- package/dist/record/family/assertions-v1.d.ts +2 -0
- package/dist/record/family/assertions-v1.js +6 -0
- package/dist/record/family/assertions-v1.js.map +1 -0
- package/dist/record/family/assertions.cjs +16 -5
- package/dist/record/family/assertions.cjs.map +1 -1
- package/dist/record/family/assertions.d.cts +510 -56
- package/dist/record/family/assertions.d.mts +510 -56
- package/dist/record/family/assertions.d.ts +510 -56
- package/dist/record/family/assertions.js +14 -10
- package/dist/record/family/catalog.cjs +17 -1
- package/dist/record/family/catalog.cjs.map +1 -1
- package/dist/record/family/catalog.d.cts +1292 -104
- package/dist/record/family/catalog.d.mts +1292 -104
- package/dist/record/family/catalog.d.ts +1292 -104
- package/dist/record/family/catalog.js +22 -20
- package/dist/record/family/index.js +144 -138
- package/dist/record/family/observability-v1.cjs +5 -0
- package/dist/record/family/observability-v1.cjs.map +1 -1
- package/dist/record/family/observability.cjs +1 -1
- package/dist/record/family/observability.cjs.map +1 -1
- package/dist/record/host/runtime.cjs +323 -173
- package/dist/record/host/runtime.cjs.map +1 -1
- package/dist/record/host/types.cjs.map +1 -1
- package/dist/record/host/types.d.cts +9 -7
- package/dist/record/host/types.d.mts +9 -7
- package/dist/record/host/types.d.ts +9 -7
- package/dist/record/model/core.cjs.map +1 -1
- package/dist/record/model/core.d.cts +1 -2
- package/dist/record/model/core.d.mts +1 -2
- package/dist/record/model/core.d.ts +1 -2
- package/dist/record/model/definition.cjs +1 -2
- package/dist/record/model/definition.cjs.map +1 -1
- package/dist/record/model/definition.d.cts +1 -7
- package/dist/record/model/definition.d.mts +1 -7
- package/dist/record/model/definition.d.ts +1 -7
- package/dist/record/model/identifiers.cjs +2 -3
- package/dist/record/model/identifiers.cjs.map +1 -1
- package/dist/record/model/identifiers.d.cts +1 -3
- package/dist/record/model/identifiers.d.mts +1 -3
- package/dist/record/model/identifiers.d.ts +1 -3
- package/dist/record/model/identifiers.js +36 -38
- package/dist/record/model/index.js +60 -62
- package/dist/record/platform/node.cjs +17 -7
- package/dist/record/platform/node.cjs.map +1 -1
- package/dist/record/platform/services.cjs.map +1 -1
- package/dist/record/platform/services.d.cts +8 -3
- package/dist/record/platform/services.d.mts +8 -3
- package/dist/record/platform/services.d.ts +8 -3
- package/dist/record/reader/format.cjs +16 -65
- package/dist/record/reader/format.cjs.map +1 -1
- package/dist/record/reader/format.d.cts +5 -9
- package/dist/record/reader/format.d.mts +5 -9
- package/dist/record/reader/format.d.ts +5 -9
- package/dist/record/reader/index.js +10 -8
- package/dist/record/reader/runtime.cjs +63 -32
- package/dist/record/reader/runtime.cjs.map +1 -1
- package/dist/record/reader/runtime.d.cts +40 -4
- package/dist/record/reader/runtime.d.mts +40 -4
- package/dist/record/reader/runtime.d.ts +40 -4
- package/dist/record/reader/runtime.js +6 -4
- package/dist/report/assets/enhance.js +5 -5
- package/dist/report/assets/styles.css +190 -24
- package/dist/report/built-in/result-components.cjs +8 -5
- package/dist/report/built-in/result-components.cjs.map +1 -1
- package/dist/report/built-in/standard.cjs +3 -0
- package/dist/report/built-in/standard.cjs.map +1 -1
- package/dist/report/built-in/standard.d.cts +2 -0
- package/dist/report/built-in/standard.d.mts +2 -0
- package/dist/report/built-in/standard.d.ts +2 -0
- package/dist/report/client-dist/app.js +53 -0
- package/dist/report/components/attempt-detail/compute.cjs +108 -231
- package/dist/report/components/attempt-detail/compute.cjs.map +1 -1
- package/dist/report/components/attempt-detail/compute.d.cts +11 -45
- package/dist/report/components/attempt-detail/compute.d.mts +11 -45
- package/dist/report/components/attempt-detail/compute.d.ts +11 -45
- package/dist/report/components/attempt-detail/compute.js +2 -4
- package/dist/report/components/attempt-detail/content.cjs +4 -4
- package/dist/report/components/attempt-detail/content.cjs.map +1 -1
- package/dist/report/components/attempt-detail/validate.cjs +47 -4
- package/dist/report/components/attempt-detail/validate.cjs.map +1 -1
- package/dist/report/components/entity-lists/compute.cjs +9 -15
- package/dist/report/components/entity-lists/compute.cjs.map +1 -1
- package/dist/report/components/entity-lists/content.cjs +53 -40
- package/dist/report/components/entity-lists/content.cjs.map +1 -1
- package/dist/report/components/entity-lists/index.cjs +1 -3
- package/dist/report/components/entity-lists/index.cjs.map +1 -1
- package/dist/report/components/experiment-detail/compute.cjs +4 -6
- package/dist/report/components/experiment-detail/compute.cjs.map +1 -1
- package/dist/report/components/summaries/index.cjs +5 -1
- package/dist/report/components/summaries/index.cjs.map +1 -1
- package/dist/report/definition/cell.cjs +14 -7
- package/dist/report/definition/cell.cjs.map +1 -1
- package/dist/report/definition/cell.d.cts +4 -0
- package/dist/report/definition/cell.d.mts +4 -0
- package/dist/report/definition/cell.d.ts +4 -0
- package/dist/report/definition/primitives/assertion-evidence.cjs +96 -0
- package/dist/report/definition/primitives/assertion-evidence.cjs.map +1 -0
- package/dist/report/definition/primitives/assertion-evidence.d.cts +11 -0
- package/dist/report/definition/primitives/assertion-evidence.d.mts +11 -0
- package/dist/report/definition/primitives/assertion-evidence.d.ts +11 -0
- package/dist/report/definition/primitives/assertion-evidence.js +6 -0
- package/dist/report/definition/primitives/assertion-evidence.js.map +1 -0
- package/dist/report/definition/primitives/conversation.cjs +7 -0
- package/dist/report/definition/primitives/conversation.cjs.map +1 -1
- package/dist/report/definition/primitives/conversation.d.cts +2 -0
- package/dist/report/definition/primitives/conversation.d.mts +2 -0
- package/dist/report/definition/primitives/conversation.d.ts +2 -0
- package/dist/report/definition/primitives/turn-trace.cjs +53 -3
- package/dist/report/definition/primitives/turn-trace.cjs.map +1 -1
- package/dist/report/definition/primitives.cjs +14 -1
- package/dist/report/definition/primitives.cjs.map +1 -1
- package/dist/report/definition/report.cjs +16 -8
- package/dist/report/definition/report.cjs.map +1 -1
- package/dist/report/definition/report.d.cts +6 -0
- package/dist/report/definition/report.d.mts +6 -0
- package/dist/report/definition/report.d.ts +6 -0
- package/dist/report/definition/table-text.cjs +12 -3
- package/dist/report/definition/table-text.cjs.map +1 -1
- package/dist/report/definition/table-text.d.cts +6 -1
- package/dist/report/definition/table-text.d.mts +6 -1
- package/dist/report/definition/table-text.d.ts +6 -1
- package/dist/report/execution/model.cjs +6 -14
- package/dist/report/execution/model.cjs.map +1 -1
- package/dist/report/execution/model.d.cts +5 -10
- package/dist/report/execution/model.d.mts +5 -10
- package/dist/report/execution/model.d.ts +5 -10
- package/dist/report/execution/model.js +6 -6
- package/dist/report/execution/paths.cjs +0 -11
- package/dist/report/execution/paths.cjs.map +1 -1
- package/dist/report/execution/paths.d.cts +0 -1
- package/dist/report/execution/paths.d.mts +0 -1
- package/dist/report/execution/paths.d.ts +0 -1
- package/dist/report/execution/paths.js +6 -8
- package/dist/report/host/execute.cjs +13 -22
- package/dist/report/host/execute.cjs.map +1 -1
- package/dist/report/host/execute.d.cts +1 -4
- package/dist/report/host/execute.d.mts +1 -4
- package/dist/report/host/execute.d.ts +1 -4
- package/dist/report/host/from-record.cjs +3 -0
- package/dist/report/host/from-record.cjs.map +1 -1
- package/dist/report/host/from-record.d.cts +4 -1
- package/dist/report/host/from-record.d.mts +4 -1
- package/dist/report/host/from-record.d.ts +4 -1
- package/dist/report/host/site-assets.cjs +1 -2
- package/dist/report/host/site-assets.cjs.map +1 -1
- package/dist/report/host/site-assets.d.cts +0 -1
- package/dist/report/host/site-assets.d.mts +0 -1
- package/dist/report/host/site-assets.d.ts +0 -1
- package/dist/report/host/site-assets.js +2 -4
- package/dist/report/host/static.cjs +71 -346
- package/dist/report/host/static.cjs.map +1 -1
- package/dist/report/host/static.d.cts +1 -3
- package/dist/report/host/static.d.mts +1 -3
- package/dist/report/host/static.d.ts +1 -3
- package/dist/report/host/static.js +2 -2
- package/dist/report/host/view-session.cjs.map +1 -1
- package/dist/report/host/view-session.d.cts +1 -1
- package/dist/report/host/view-session.d.mts +1 -1
- package/dist/report/host/view-session.d.ts +1 -1
- package/dist/report/model/locale.cjs +1 -1
- package/dist/report/model/locale.cjs.map +1 -1
- package/dist/report/model/locale.d.cts +1 -1
- package/dist/report/model/locale.d.mts +1 -1
- package/dist/report/model/locale.d.ts +1 -1
- package/dist/report/model/pricing.cjs +2 -2
- package/dist/report/model/pricing.cjs.map +1 -1
- package/dist/report/react/enhance.js +5 -5
- package/dist/report/react/styles.css +190 -24
- package/dist/runner/adoption.cjs +4 -7
- package/dist/runner/adoption.cjs.map +1 -1
- package/dist/runner/attempt-resources.cjs +60 -0
- package/dist/runner/attempt-resources.cjs.map +1 -0
- package/dist/runner/attempt-resources.d.cts +13 -0
- package/dist/runner/attempt-resources.d.mts +13 -0
- package/dist/runner/attempt-resources.d.ts +13 -0
- package/dist/runner/attempt-resources.js +6 -0
- package/dist/runner/attempt-resources.js.map +1 -0
- package/dist/runner/attempt.cjs +37 -3
- package/dist/runner/attempt.cjs.map +1 -1
- package/dist/runner/feedback/failure.cjs +77 -2
- package/dist/runner/feedback/failure.cjs.map +1 -1
- package/dist/runner/feedback/failure.d.cts +2 -1
- package/dist/runner/feedback/failure.d.mts +2 -1
- package/dist/runner/feedback/failure.d.ts +2 -1
- package/dist/runner/project-current.cjs +2 -13
- package/dist/runner/project-current.cjs.map +1 -1
- package/dist/runner/project-current.d.cts +4 -2
- package/dist/runner/project-current.d.mts +4 -2
- package/dist/runner/project-current.d.ts +4 -2
- package/dist/runner/reporters/braintrust.cjs +7 -7
- package/dist/runner/reporters/braintrust.cjs.map +1 -1
- package/dist/runner/reuse-readback.cjs +3 -4
- package/dist/runner/reuse-readback.cjs.map +1 -1
- package/dist/runner/run.cjs +5 -2
- package/dist/runner/run.cjs.map +1 -1
- package/dist/sandbox/backend.cjs +32 -2
- package/dist/sandbox/backend.cjs.map +1 -1
- package/dist/sandbox/backend.d.cts +12 -1
- package/dist/sandbox/backend.d.mts +12 -1
- package/dist/sandbox/backend.d.ts +12 -1
- package/dist/sandbox/backend.js +28 -22
- package/dist/sandbox/docker.cjs +140 -0
- package/dist/sandbox/docker.cjs.map +1 -1
- package/dist/sandbox/docker.d.cts +3 -1
- package/dist/sandbox/docker.d.mts +3 -1
- package/dist/sandbox/docker.d.ts +3 -1
- package/dist/sandbox/e2b.cjs +42 -0
- package/dist/sandbox/e2b.cjs.map +1 -1
- package/dist/sandbox/e2b.d.cts +2 -0
- package/dist/sandbox/e2b.d.mts +2 -0
- package/dist/sandbox/e2b.d.ts +2 -0
- package/dist/sandbox/local.cjs +64 -0
- package/dist/sandbox/local.cjs.map +1 -1
- package/dist/sandbox/local.d.cts +3 -1
- package/dist/sandbox/local.d.mts +3 -1
- package/dist/sandbox/local.d.ts +3 -1
- package/dist/sandbox/managed-process.cjs +49 -0
- package/dist/sandbox/managed-process.cjs.map +1 -0
- package/dist/sandbox/managed-process.d.cts +11 -0
- package/dist/sandbox/managed-process.d.mts +11 -0
- package/dist/sandbox/managed-process.d.ts +11 -0
- package/dist/sandbox/managed-process.js +6 -0
- package/dist/sandbox/managed-process.js.map +1 -0
- package/dist/sandbox/types.cjs.map +1 -1
- package/dist/sandbox/types.d.cts +24 -0
- package/dist/sandbox/types.d.mts +24 -0
- package/dist/sandbox/types.d.ts +24 -0
- package/dist/sandbox/vercel.cjs +1 -0
- package/dist/sandbox/vercel.cjs.map +1 -1
- package/dist/sandbox/vercel.d.cts +1 -0
- package/dist/sandbox/vercel.d.mts +1 -0
- package/dist/sandbox/vercel.d.ts +1 -0
- package/dist/view/server.cjs +2 -37
- package/dist/view/server.cjs.map +1 -1
- package/dist/view/server.d.cts +0 -3
- package/dist/view/server.d.mts +0 -3
- package/dist/view/server.d.ts +0 -3
- package/docs-site/zh/reference/builtin-agents.mdx +7 -7
- package/docs-site/zh/reference/official-adapters.mdx +4 -4
- package/docs-site/zh/reference/report-components.mdx +2 -2
- package/docs-site/zh/tutorials/configuration.mdx +2 -2
- package/docs-site/zh/tutorials/deploy-report-site.mdx +24 -2
- package/docs-site/zh/tutorials/publish-report.mdx +4 -4
- package/docs-site/zh/tutorials/sandbox-agent.mdx +5 -5
- package/docs-site/zh/tutorials/theming.mdx +2 -2
- package/package.json +4 -6
- package/dist/record/migration/index.cjs +0 -5
- package/dist/record/migration/index.cjs.map +0 -1
- package/dist/record/migration/index.d.cts +0 -11
- package/dist/record/migration/index.d.mts +0 -11
- package/dist/record/migration/index.d.ts +0 -11
- package/dist/record/migration/index.js +0 -6
- package/dist/record/migration/index.js.map +0 -1
- package/dist/report/host/site-runtime.cjs +0 -92
- package/dist/report/host/site-runtime.cjs.map +0 -1
- package/dist/report/host/site-runtime.d.cts +0 -9
- package/dist/report/host/site-runtime.d.mts +0 -9
- package/dist/report/host/site-runtime.d.ts +0 -9
- package/dist/report/host/site-runtime.js +0 -10
- package/dist/report/host/site-runtime.js.map +0 -1
- package/dist/view/client-dist/app.css +0 -2
- package/dist/view/client-dist/app.js +0 -49
- package/dist/view/data.cjs +0 -3
- package/dist/view/data.cjs.map +0 -1
- package/dist/view/data.d.cts +0 -9
- package/dist/view/data.d.mts +0 -9
- package/dist/view/data.d.ts +0 -9
- package/dist/view/data.js +0 -4
- package/dist/view/data.js.map +0 -1
- package/dist/view/index.cjs +0 -24
- package/dist/view/index.cjs.map +0 -1
- package/dist/view/index.d.cts +0 -9
- package/dist/view/index.d.mts +0 -9
- package/dist/view/index.d.ts +0 -9
- package/dist/view/index.js +0 -28
- package/dist/view/index.js.map +0 -1
- package/dist/view/report-view-cache.cjs +0 -200
- package/dist/view/report-view-cache.cjs.map +0 -1
- package/dist/view/report-view-cache.d.cts +0 -67
- package/dist/view/report-view-cache.d.mts +0 -67
- package/dist/view/report-view-cache.d.ts +0 -67
- package/dist/view/report-view-cache.js +0 -8
- package/dist/view/report-view-cache.js.map +0 -1
- package/dist/view/shared/types.cjs +0 -3
- package/dist/view/shared/types.cjs.map +0 -1
- package/dist/view/shared/types.d.cts +0 -51
- package/dist/view/shared/types.d.mts +0 -51
- package/dist/view/shared/types.d.ts +0 -51
- package/dist/view/shared/types.js +0 -4
- package/dist/view/shared/types.js.map +0 -1
- package/dist/view/site.cjs +0 -32
- package/dist/view/site.cjs.map +0 -1
- package/dist/view/site.d.cts +0 -24
- package/dist/view/site.d.mts +0 -24
- package/dist/view/site.d.ts +0 -24
- package/dist/view/site.js +0 -8
- package/dist/view/site.js.map +0 -1
- package/dist/view/styles.css +0 -170
- package/dist/view/template.html +0 -17
package/dist/sandbox/backend.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.noSandboxBackendCapabilities = exports.unsupportedBackendCapability = void 0;
|
|
3
|
+
exports.SandboxManagedProcessCapabilityError = exports.noSandboxBackendCapabilities = exports.unsupportedBackendCapability = void 0;
|
|
4
|
+
exports.unsupportedBackendCapabilityBecause = unsupportedBackendCapabilityBecause;
|
|
4
5
|
exports.supportedBackendCapability = supportedBackendCapability;
|
|
5
6
|
exports.providerBoundaryEffect = providerBoundaryEffect;
|
|
6
7
|
exports.providerCompatibilityPromise = providerCompatibilityPromise;
|
|
@@ -9,18 +10,24 @@ exports.registerSandboxCapabilities = registerSandboxCapabilities;
|
|
|
9
10
|
exports.inheritSandboxCapabilities = inheritSandboxCapabilities;
|
|
10
11
|
exports.sandboxCapabilities = sandboxCapabilities;
|
|
11
12
|
exports.sandboxSupportsRootCommands = sandboxSupportsRootCommands;
|
|
13
|
+
exports.requireManagedProcessCapability = requireManagedProcessCapability;
|
|
12
14
|
exports.sandboxReuseCapability = sandboxReuseCapability;
|
|
13
15
|
// Provider Promise SDK 与公共 Sandbox facade 之间的唯一边界。
|
|
14
16
|
const effect_1 = require("effect");
|
|
15
17
|
exports.unsupportedBackendCapability = Object.freeze({
|
|
16
18
|
_tag: "Unsupported",
|
|
19
|
+
reason: "the provider does not implement this capability",
|
|
17
20
|
});
|
|
21
|
+
function unsupportedBackendCapabilityBecause(reason) {
|
|
22
|
+
return Object.freeze({ _tag: "Unsupported", reason });
|
|
23
|
+
}
|
|
18
24
|
exports.noSandboxBackendCapabilities = Object.freeze({
|
|
19
25
|
rootCommands: exports.unsupportedBackendCapability,
|
|
20
26
|
appendLog: exports.unsupportedBackendCapability,
|
|
21
27
|
suspend: exports.unsupportedBackendCapability,
|
|
22
28
|
ensureLifetime: exports.unsupportedBackendCapability,
|
|
23
29
|
setCommandDeadline: exports.unsupportedBackendCapability,
|
|
30
|
+
managedProcess: exports.unsupportedBackendCapability,
|
|
24
31
|
});
|
|
25
32
|
function supportedBackendCapability(value) {
|
|
26
33
|
return Object.freeze({ _tag: "Supported", value });
|
|
@@ -56,7 +63,10 @@ function customSandboxBackend(sandbox) {
|
|
|
56
63
|
const appendLog = sandbox.appendLog;
|
|
57
64
|
// Provider facade 产出的 Sandbox 再经 runtime 归一化时必须保留 provider-only capabilities;
|
|
58
65
|
// 作者直接返回的普通 Sandbox 没有登记项,仍严格退回 Unsupported,不能靠鸭子类型猜能力。
|
|
59
|
-
const registered = SANDBOX_CAPABILITIES.get(sandbox) ??
|
|
66
|
+
const registered = SANDBOX_CAPABILITIES.get(sandbox) ?? {
|
|
67
|
+
...exports.noSandboxBackendCapabilities,
|
|
68
|
+
managedProcess: unsupportedBackendCapabilityBecause("custom Sandbox facades do not declare the internal managed-process capability"),
|
|
69
|
+
};
|
|
60
70
|
return {
|
|
61
71
|
get workdir() {
|
|
62
72
|
return sandbox.workdir;
|
|
@@ -108,6 +118,26 @@ function sandboxCapabilities(sandbox) {
|
|
|
108
118
|
function sandboxSupportsRootCommands(sandbox) {
|
|
109
119
|
return SANDBOX_CAPABILITIES.get(sandbox)?.rootCommands._tag === "Supported";
|
|
110
120
|
}
|
|
121
|
+
class SandboxManagedProcessCapabilityError extends Error {
|
|
122
|
+
agent;
|
|
123
|
+
sandboxId;
|
|
124
|
+
reason;
|
|
125
|
+
name = "SandboxManagedProcessCapabilityError";
|
|
126
|
+
constructor(agent, sandboxId, reason) {
|
|
127
|
+
super(`Agent ${agent} requires the sandbox managed-process capability, but sandbox ${sandboxId} does not support it: ${reason}`);
|
|
128
|
+
this.agent = agent;
|
|
129
|
+
this.sandboxId = sandboxId;
|
|
130
|
+
this.reason = reason;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.SandboxManagedProcessCapabilityError = SandboxManagedProcessCapabilityError;
|
|
134
|
+
function requireManagedProcessCapability(sandbox, agent) {
|
|
135
|
+
const capability = sandboxCapabilities(sandbox).managedProcess;
|
|
136
|
+
if (capability._tag === "Unsupported") {
|
|
137
|
+
throw new SandboxManagedProcessCapabilityError(agent, sandbox.sandboxId, capability.reason);
|
|
138
|
+
}
|
|
139
|
+
return capability.value;
|
|
140
|
+
}
|
|
111
141
|
/** Provider facade 登记的复用寿命能力;不存在时保持显式 Unsupported,不做鸭子类型探测。 */
|
|
112
142
|
function sandboxReuseCapability(sandbox) {
|
|
113
143
|
const capability = sandboxCapabilities(sandbox).ensureLifetime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.js","sourceRoot":"","sources":["backend.ts"],"names":[],"mappings":";;;AA+CA,gEAEC;AAKD,wDAOC;AAOD,oEAOC;AAED,oDAkCC;AAED,kEAEC;AAED,gEAIC;AACD,kDAMC;AAED,kEAEC;AAED,wDA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,CAAC;AACxB,CAAC;AACD,8DAA8D;AAC9D,SAAgB,2BAA2B,CAAC,OAAgB;IACxD,OAAO,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC,IAAI,KAAK,WAAW,CAAC;AAChF,CAAC;AACD,+DAA+D;AAC/D,SAAgB,sBAAsB,CAAC,OAAgB;IACnD,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC;IAC/D,OAAO,UAAU,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9F,CAAC","sourcesContent":["// Provider Promise SDK 与公共 Sandbox facade 之间的唯一边界。\nimport { Effect } from \"effect\";\nimport type { CommandOptions, CommandResult, Sandbox, SandboxReuseCapability, SandboxTransferOperations, } from \"./types.ts\";\nexport type SandboxBackendSupport<T> = {\n readonly _tag: \"Supported\";\n readonly value: T;\n} | {\n readonly _tag: \"Unsupported\";\n};\nexport interface SandboxBackendCapabilities {\n /** Provider 能否兑现 CommandOptions.user 的 root 覆盖;runner 私有基础设施按这项能力选择身份。 */\n readonly rootCommands: SandboxBackendSupport<true>;\n readonly appendLog: SandboxBackendSupport<(line: string) => Promise<void>>;\n readonly suspend: SandboxBackendSupport<() => Promise<void>>;\n readonly ensureLifetime: SandboxBackendSupport<(minRemainingMs: number) => Promise<{\n ready: true;\n expiresAt?: string;\n } | {\n ready: false;\n reason: string;\n }>>;\n readonly setCommandDeadline: SandboxBackendSupport<(deadlineAt?: number) => void>;\n}\nexport interface SandboxProviderBackend extends SandboxTransferOperations {\n readonly workdir: string;\n readonly sandboxId: string;\n readonly otlpHost: string | null;\n readonly capabilities: SandboxBackendCapabilities;\n runCommand(command: string, args?: readonly string[], options?: CommandOptions): Promise<CommandResult>;\n runShell(script: string, options?: CommandOptions): Promise<CommandResult>;\n readText(path: string): Promise<string>;\n writeText(path: string, content: string): Promise<void>;\n readBytes(path: string): Promise<Uint8Array>;\n writeBytes(path: string, content: Uint8Array): Promise<void>;\n pathExists(path: string): Promise<boolean>;\n stop(): Promise<void>;\n}\nexport const unsupportedBackendCapability: SandboxBackendSupport<never> = Object.freeze({\n _tag: \"Unsupported\",\n});\nexport const noSandboxBackendCapabilities: SandboxBackendCapabilities = Object.freeze({\n rootCommands: unsupportedBackendCapability,\n appendLog: unsupportedBackendCapability,\n suspend: unsupportedBackendCapability,\n ensureLifetime: unsupportedBackendCapability,\n setCommandDeadline: unsupportedBackendCapability,\n});\nexport function supportedBackendCapability<T>(value: T): SandboxBackendSupport<T> {\n return Object.freeze({ _tag: \"Supported\", value });\n}\nfunction providerBoundaryError(cause: unknown): Error {\n return cause instanceof Error ? cause : new Error(String(cause));\n}\n/** Promise provider SDK 在这一处 lift 成 typed-error Effect;Error 实例原样保留给现有归因逻辑。 */\nexport function providerBoundaryEffect<T>(operation: (signal: AbortSignal) => Promise<T>): Effect.Effect<T, Error> {\n return Effect.tryPromise({\n // 保留 Effect 运行时的取消信号,供真正支持 AbortSignal 的 SDK adapter 接入;不把中断\n // 编码成 Error,也不在这里启动嵌套 runtime。\n try: (signal) => operation(signal),\n catch: providerBoundaryError,\n });\n}\n/**\n * 公开 Sandbox Promise 接口唯一的兼容入口。\n *\n * 这不是内部 Effect runner:它只把 provider Promise 原样留在公开兼容面,并归一化非 Error\n * rejection。runtime / resource lifecycle 必须改用 providerBoundaryEffect() 组合 Effect。\n */\nexport async function providerCompatibilityPromise<T>(operation: () => Promise<T>): Promise<T> {\n try {\n return await operation();\n }\n catch (cause) {\n throw providerBoundaryError(cause);\n }\n}\n/** defineSandbox() 的公共新接口实现显式降成 provider backend;不探测任何旧方法。 */\nexport function customSandboxBackend(sandbox: Sandbox): SandboxProviderBackend {\n const appendLog = sandbox.appendLog;\n // Provider facade 产出的 Sandbox 再经 runtime 归一化时必须保留 provider-only capabilities;\n // 作者直接返回的普通 Sandbox 没有登记项,仍严格退回 Unsupported,不能靠鸭子类型猜能力。\n const registered = SANDBOX_CAPABILITIES.get(sandbox) ?? noSandboxBackendCapabilities;\n return {\n get workdir() {\n return sandbox.workdir;\n },\n get sandboxId() {\n return sandbox.sandboxId;\n },\n get otlpHost() {\n return sandbox.otlpHost;\n },\n capabilities: {\n ...registered,\n appendLog: appendLog === undefined\n ? unsupportedBackendCapability\n : supportedBackendCapability((line) => appendLog.call(sandbox, line)),\n },\n runCommand: (command, args, options) => sandbox.runCommand(command, args, options),\n runShell: (script, options) => sandbox.runShell(script, options),\n readText: (path) => sandbox.readText(path),\n writeText: (path, content) => sandbox.writeText(path, content),\n readBytes: (path) => sandbox.readBytes(path),\n writeBytes: (path, content) => sandbox.writeBytes(path, content),\n pathExists: (path) => sandbox.pathExists(path),\n uploadFile: (source, targetPath) => sandbox.uploadFile(source, targetPath),\n uploadDirectory: (sourceDir, targetDir, options) => sandbox.uploadDirectory(sourceDir, targetDir, options),\n downloadFile: (sourcePath, target) => sandbox.downloadFile(sourcePath, target),\n downloadDirectory: (sourceDir, targetDir, options) => sandbox.downloadDirectory(sourceDir, targetDir, options),\n stop: () => sandbox.stop(),\n };\n}\nconst SANDBOX_CAPABILITIES = new WeakMap<Sandbox, SandboxBackendCapabilities>();\nexport function registerSandboxCapabilities(sandbox: Sandbox, capabilities: SandboxBackendCapabilities): void {\n SANDBOX_CAPABILITIES.set(sandbox, capabilities);\n}\n/** 装饰器产生新 Sandbox 对象时显式继承同一份 provider-only 能力,不靠接口外成员探测。 */\nexport function inheritSandboxCapabilities(source: Sandbox, target: Sandbox): void {\n const capabilities = SANDBOX_CAPABILITIES.get(source);\n if (capabilities !== undefined)\n SANDBOX_CAPABILITIES.set(target, capabilities);\n}\nexport function sandboxCapabilities(sandbox: Sandbox): SandboxBackendCapabilities {\n const capabilities = SANDBOX_CAPABILITIES.get(sandbox);\n if (capabilities === undefined) {\n throw new Error(`sandbox ${sandbox.sandboxId} was not constructed by the provider facade`);\n }\n return capabilities;\n}\n/** 未经 provider facade 登记的普通自定义 Sandbox 保守视为不支持提权,不做鸭子类型猜测。 */\nexport function sandboxSupportsRootCommands(sandbox: Sandbox): boolean {\n return SANDBOX_CAPABILITIES.get(sandbox)?.rootCommands._tag === \"Supported\";\n}\n/** Provider facade 登记的复用寿命能力;不存在时保持显式 Unsupported,不做鸭子类型探测。 */\nexport function sandboxReuseCapability(sandbox: Sandbox): SandboxReuseCapability | undefined {\n const capability = sandboxCapabilities(sandbox).ensureLifetime;\n return capability._tag === \"Supported\" ? { ensureLifetime: capability.value } : undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["backend.ts"],"names":[],"mappings":";;;AA2CA,kFAEC;AASD,gEAEC;AAKD,wDAOC;AAOD,oEAOC;AAED,oDAqCC;AAED,kEAEC;AAED,gEAIC;AACD,kDAMC;AAED,kEAEC;AAOD,0EAMC;AAED,wDAGC;AAhKD,mDAAmD;AACnD,mCAAgC;AAsCnB,QAAA,4BAA4B,GAAiC,MAAM,CAAC,MAAM,CAAC;IACpF,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,iDAAiD;CAC5D,CAAC,CAAC;AACH,SAAgB,mCAAmC,CAAC,MAAc;IAC9D,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1D,CAAC;AACY,QAAA,4BAA4B,GAA+B,MAAM,CAAC,MAAM,CAAC;IAClF,YAAY,EAAE,oCAA4B;IAC1C,SAAS,EAAE,oCAA4B;IACvC,OAAO,EAAE,oCAA4B;IACrC,cAAc,EAAE,oCAA4B;IAC5C,kBAAkB,EAAE,oCAA4B;IAChD,cAAc,EAAE,oCAA4B;CAC/C,CAAC,CAAC;AACH,SAAgB,0BAA0B,CAAI,KAAQ;IAClD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;AACvD,CA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AK,CAAQ;QAAW,cAAS,GAAT,SAAS,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAQ;IAEvF,CAAC;CACJ;AALD,oFAKC;AACD,SAAgB,+BAA+B,CAAC,OAAgB,EAAE,KAAa;IAC3E,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC;IAC/D,IAAI,UAAU,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QACpC,MAAM,IAAI,oCAAoC,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,CAAC;AAC5B,CAAC;AACD,+DAA+D;AAC/D,SAAgB,sBAAsB,CAAC,OAAgB;IACnD,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC;IAC/D,OAAO,UAAU,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9F,CAAC","sourcesContent":["// Provider Promise SDK 与公共 Sandbox facade 之间的唯一边界。\nimport { Effect } from \"effect\";\nimport type { CommandOptions, CommandResult, Sandbox, ManagedProcess, ManagedProcessStart, SandboxReuseCapability, SandboxTransferOperations, } from \"./types.ts\";\nexport type SandboxBackendSupport<T> = {\n readonly _tag: \"Supported\";\n readonly value: T;\n} | {\n readonly _tag: \"Unsupported\";\n readonly reason: string;\n};\nexport interface SandboxBackendCapabilities {\n /** Provider 能否兑现 CommandOptions.user 的 root 覆盖;runner 私有基础设施按这项能力选择身份。 */\n readonly rootCommands: SandboxBackendSupport<true>;\n readonly appendLog: SandboxBackendSupport<(line: string) => Promise<void>>;\n readonly suspend: SandboxBackendSupport<() => Promise<void>>;\n readonly ensureLifetime: SandboxBackendSupport<(minRemainingMs: number) => Promise<{\n ready: true;\n expiresAt?: string;\n } | {\n ready: false;\n reason: string;\n }>>;\n readonly setCommandDeadline: SandboxBackendSupport<(deadlineAt?: number) => void>;\n readonly managedProcess: SandboxBackendSupport<(input: ManagedProcessStart) => Promise<ManagedProcess>>;\n}\nexport interface SandboxProviderBackend extends SandboxTransferOperations {\n readonly workdir: string;\n readonly sandboxId: string;\n readonly otlpHost: string | null;\n readonly capabilities: SandboxBackendCapabilities;\n runCommand(command: string, args?: readonly string[], options?: CommandOptions): Promise<CommandResult>;\n runShell(script: string, options?: CommandOptions): Promise<CommandResult>;\n readText(path: string): Promise<string>;\n writeText(path: string, content: string): Promise<void>;\n readBytes(path: string): Promise<Uint8Array>;\n writeBytes(path: string, content: Uint8Array): Promise<void>;\n pathExists(path: string): Promise<boolean>;\n stop(): Promise<void>;\n}\nexport const unsupportedBackendCapability: SandboxBackendSupport<never> = Object.freeze({\n _tag: \"Unsupported\",\n reason: \"the provider does not implement this capability\",\n});\nexport function unsupportedBackendCapabilityBecause(reason: string): SandboxBackendSupport<never> {\n return Object.freeze({ _tag: \"Unsupported\", reason });\n}\nexport const noSandboxBackendCapabilities: SandboxBackendCapabilities = Object.freeze({\n rootCommands: unsupportedBackendCapability,\n appendLog: unsupportedBackendCapability,\n suspend: unsupportedBackendCapability,\n ensureLifetime: unsupportedBackendCapability,\n setCommandDeadline: unsupportedBackendCapability,\n managedProcess: unsupportedBackendCapability,\n});\nexport function supportedBackendCapability<T>(value: T): SandboxBackendSupport<T> {\n return Object.freeze({ _tag: \"Supported\", value });\n}\nfunction providerBoundaryError(cause: unknown): Error {\n return cause instanceof Error ? cause : new Error(String(cause));\n}\n/** Promise provider SDK 在这一处 lift 成 typed-error Effect;Error 实例原样保留给现有归因逻辑。 */\nexport function providerBoundaryEffect<T>(operation: (signal: AbortSignal) => Promise<T>): Effect.Effect<T, Error> {\n return Effect.tryPromise({\n // 保留 Effect 运行时的取消信号,供真正支持 AbortSignal 的 SDK adapter 接入;不把中断\n // 编码成 Error,也不在这里启动嵌套 runtime。\n try: (signal) => operation(signal),\n catch: providerBoundaryError,\n });\n}\n/**\n * 公开 Sandbox Promise 接口唯一的兼容入口。\n *\n * 这不是内部 Effect runner:它只把 provider Promise 原样留在公开兼容面,并归一化非 Error\n * rejection。runtime / resource lifecycle 必须改用 providerBoundaryEffect() 组合 Effect。\n */\nexport async function providerCompatibilityPromise<T>(operation: () => Promise<T>): Promise<T> {\n try {\n return await operation();\n }\n catch (cause) {\n throw providerBoundaryError(cause);\n }\n}\n/** defineSandbox() 的公共新接口实现显式降成 provider backend;不探测任何旧方法。 */\nexport function customSandboxBackend(sandbox: Sandbox): SandboxProviderBackend {\n const appendLog = sandbox.appendLog;\n // Provider facade 产出的 Sandbox 再经 runtime 归一化时必须保留 provider-only capabilities;\n // 作者直接返回的普通 Sandbox 没有登记项,仍严格退回 Unsupported,不能靠鸭子类型猜能力。\n const registered = SANDBOX_CAPABILITIES.get(sandbox) ?? {\n ...noSandboxBackendCapabilities,\n managedProcess: unsupportedBackendCapabilityBecause(\"custom Sandbox facades do not declare the internal managed-process capability\"),\n };\n return {\n get workdir() {\n return sandbox.workdir;\n },\n get sandboxId() {\n return sandbox.sandboxId;\n },\n get otlpHost() {\n return sandbox.otlpHost;\n },\n capabilities: {\n ...registered,\n appendLog: appendLog === undefined\n ? unsupportedBackendCapability\n : supportedBackendCapability((line) => appendLog.call(sandbox, line)),\n },\n runCommand: (command, args, options) => sandbox.runCommand(command, args, options),\n runShell: (script, options) => sandbox.runShell(script, options),\n readText: (path) => sandbox.readText(path),\n writeText: (path, content) => sandbox.writeText(path, content),\n readBytes: (path) => sandbox.readBytes(path),\n writeBytes: (path, content) => sandbox.writeBytes(path, content),\n pathExists: (path) => sandbox.pathExists(path),\n uploadFile: (source, targetPath) => sandbox.uploadFile(source, targetPath),\n uploadDirectory: (sourceDir, targetDir, options) => sandbox.uploadDirectory(sourceDir, targetDir, options),\n downloadFile: (sourcePath, target) => sandbox.downloadFile(sourcePath, target),\n downloadDirectory: (sourceDir, targetDir, options) => sandbox.downloadDirectory(sourceDir, targetDir, options),\n stop: () => sandbox.stop(),\n };\n}\nconst SANDBOX_CAPABILITIES = new WeakMap<Sandbox, SandboxBackendCapabilities>();\nexport function registerSandboxCapabilities(sandbox: Sandbox, capabilities: SandboxBackendCapabilities): void {\n SANDBOX_CAPABILITIES.set(sandbox, capabilities);\n}\n/** 装饰器产生新 Sandbox 对象时显式继承同一份 provider-only 能力,不靠接口外成员探测。 */\nexport function inheritSandboxCapabilities(source: Sandbox, target: Sandbox): void {\n const capabilities = SANDBOX_CAPABILITIES.get(source);\n if (capabilities !== undefined)\n SANDBOX_CAPABILITIES.set(target, capabilities);\n}\nexport function sandboxCapabilities(sandbox: Sandbox): SandboxBackendCapabilities {\n const capabilities = SANDBOX_CAPABILITIES.get(sandbox);\n if (capabilities === undefined) {\n throw new Error(`sandbox ${sandbox.sandboxId} was not constructed by the provider facade`);\n }\n return capabilities;\n}\n/** 未经 provider facade 登记的普通自定义 Sandbox 保守视为不支持提权,不做鸭子类型猜测。 */\nexport function sandboxSupportsRootCommands(sandbox: Sandbox): boolean {\n return SANDBOX_CAPABILITIES.get(sandbox)?.rootCommands._tag === \"Supported\";\n}\nexport class SandboxManagedProcessCapabilityError extends Error {\n readonly name = \"SandboxManagedProcessCapabilityError\";\n constructor(readonly agent: string, readonly sandboxId: string, readonly reason: string) {\n super(`Agent ${agent} requires the sandbox managed-process capability, but sandbox ${sandboxId} does not support it: ${reason}`);\n }\n}\nexport function requireManagedProcessCapability(sandbox: Sandbox, agent: string): (input: ManagedProcessStart) => Promise<ManagedProcess> {\n const capability = sandboxCapabilities(sandbox).managedProcess;\n if (capability._tag === \"Unsupported\") {\n throw new SandboxManagedProcessCapabilityError(agent, sandbox.sandboxId, capability.reason);\n }\n return capability.value;\n}\n/** Provider facade 登记的复用寿命能力;不存在时保持显式 Unsupported,不做鸭子类型探测。 */\nexport function sandboxReuseCapability(sandbox: Sandbox): SandboxReuseCapability | undefined {\n const capability = sandboxCapabilities(sandbox).ensureLifetime;\n return capability._tag === \"Supported\" ? { ensureLifetime: capability.value } : undefined;\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import type { CommandOptions, CommandResult, Sandbox, SandboxReuseCapability, SandboxTransferOperations } from "./types.cjs";
|
|
2
|
+
import type { CommandOptions, CommandResult, Sandbox, ManagedProcess, ManagedProcessStart, SandboxReuseCapability, SandboxTransferOperations } from "./types.cjs";
|
|
3
3
|
export type SandboxBackendSupport<T> = {
|
|
4
4
|
readonly _tag: "Supported";
|
|
5
5
|
readonly value: T;
|
|
6
6
|
} | {
|
|
7
7
|
readonly _tag: "Unsupported";
|
|
8
|
+
readonly reason: string;
|
|
8
9
|
};
|
|
9
10
|
export interface SandboxBackendCapabilities {
|
|
10
11
|
/** Provider 能否兑现 CommandOptions.user 的 root 覆盖;runner 私有基础设施按这项能力选择身份。 */
|
|
@@ -19,6 +20,7 @@ export interface SandboxBackendCapabilities {
|
|
|
19
20
|
reason: string;
|
|
20
21
|
}>>;
|
|
21
22
|
readonly setCommandDeadline: SandboxBackendSupport<(deadlineAt?: number) => void>;
|
|
23
|
+
readonly managedProcess: SandboxBackendSupport<(input: ManagedProcessStart) => Promise<ManagedProcess>>;
|
|
22
24
|
}
|
|
23
25
|
export interface SandboxProviderBackend extends SandboxTransferOperations {
|
|
24
26
|
readonly workdir: string;
|
|
@@ -35,6 +37,7 @@ export interface SandboxProviderBackend extends SandboxTransferOperations {
|
|
|
35
37
|
stop(): Promise<void>;
|
|
36
38
|
}
|
|
37
39
|
export declare const unsupportedBackendCapability: SandboxBackendSupport<never>;
|
|
40
|
+
export declare function unsupportedBackendCapabilityBecause(reason: string): SandboxBackendSupport<never>;
|
|
38
41
|
export declare const noSandboxBackendCapabilities: SandboxBackendCapabilities;
|
|
39
42
|
export declare function supportedBackendCapability<T>(value: T): SandboxBackendSupport<T>;
|
|
40
43
|
/** Promise provider SDK 在这一处 lift 成 typed-error Effect;Error 实例原样保留给现有归因逻辑。 */
|
|
@@ -54,5 +57,13 @@ export declare function inheritSandboxCapabilities(source: Sandbox, target: Sand
|
|
|
54
57
|
export declare function sandboxCapabilities(sandbox: Sandbox): SandboxBackendCapabilities;
|
|
55
58
|
/** 未经 provider facade 登记的普通自定义 Sandbox 保守视为不支持提权,不做鸭子类型猜测。 */
|
|
56
59
|
export declare function sandboxSupportsRootCommands(sandbox: Sandbox): boolean;
|
|
60
|
+
export declare class SandboxManagedProcessCapabilityError extends Error {
|
|
61
|
+
readonly agent: string;
|
|
62
|
+
readonly sandboxId: string;
|
|
63
|
+
readonly reason: string;
|
|
64
|
+
readonly name = "SandboxManagedProcessCapabilityError";
|
|
65
|
+
constructor(agent: string, sandboxId: string, reason: string);
|
|
66
|
+
}
|
|
67
|
+
export declare function requireManagedProcessCapability(sandbox: Sandbox, agent: string): (input: ManagedProcessStart) => Promise<ManagedProcess>;
|
|
57
68
|
/** Provider facade 登记的复用寿命能力;不存在时保持显式 Unsupported,不做鸭子类型探测。 */
|
|
58
69
|
export declare function sandboxReuseCapability(sandbox: Sandbox): SandboxReuseCapability | undefined;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import type { CommandOptions, CommandResult, Sandbox, SandboxReuseCapability, SandboxTransferOperations } from "./types.mjs";
|
|
2
|
+
import type { CommandOptions, CommandResult, Sandbox, ManagedProcess, ManagedProcessStart, SandboxReuseCapability, SandboxTransferOperations } from "./types.mjs";
|
|
3
3
|
export type SandboxBackendSupport<T> = {
|
|
4
4
|
readonly _tag: "Supported";
|
|
5
5
|
readonly value: T;
|
|
6
6
|
} | {
|
|
7
7
|
readonly _tag: "Unsupported";
|
|
8
|
+
readonly reason: string;
|
|
8
9
|
};
|
|
9
10
|
export interface SandboxBackendCapabilities {
|
|
10
11
|
/** Provider 能否兑现 CommandOptions.user 的 root 覆盖;runner 私有基础设施按这项能力选择身份。 */
|
|
@@ -19,6 +20,7 @@ export interface SandboxBackendCapabilities {
|
|
|
19
20
|
reason: string;
|
|
20
21
|
}>>;
|
|
21
22
|
readonly setCommandDeadline: SandboxBackendSupport<(deadlineAt?: number) => void>;
|
|
23
|
+
readonly managedProcess: SandboxBackendSupport<(input: ManagedProcessStart) => Promise<ManagedProcess>>;
|
|
22
24
|
}
|
|
23
25
|
export interface SandboxProviderBackend extends SandboxTransferOperations {
|
|
24
26
|
readonly workdir: string;
|
|
@@ -35,6 +37,7 @@ export interface SandboxProviderBackend extends SandboxTransferOperations {
|
|
|
35
37
|
stop(): Promise<void>;
|
|
36
38
|
}
|
|
37
39
|
export declare const unsupportedBackendCapability: SandboxBackendSupport<never>;
|
|
40
|
+
export declare function unsupportedBackendCapabilityBecause(reason: string): SandboxBackendSupport<never>;
|
|
38
41
|
export declare const noSandboxBackendCapabilities: SandboxBackendCapabilities;
|
|
39
42
|
export declare function supportedBackendCapability<T>(value: T): SandboxBackendSupport<T>;
|
|
40
43
|
/** Promise provider SDK 在这一处 lift 成 typed-error Effect;Error 实例原样保留给现有归因逻辑。 */
|
|
@@ -54,5 +57,13 @@ export declare function inheritSandboxCapabilities(source: Sandbox, target: Sand
|
|
|
54
57
|
export declare function sandboxCapabilities(sandbox: Sandbox): SandboxBackendCapabilities;
|
|
55
58
|
/** 未经 provider facade 登记的普通自定义 Sandbox 保守视为不支持提权,不做鸭子类型猜测。 */
|
|
56
59
|
export declare function sandboxSupportsRootCommands(sandbox: Sandbox): boolean;
|
|
60
|
+
export declare class SandboxManagedProcessCapabilityError extends Error {
|
|
61
|
+
readonly agent: string;
|
|
62
|
+
readonly sandboxId: string;
|
|
63
|
+
readonly reason: string;
|
|
64
|
+
readonly name = "SandboxManagedProcessCapabilityError";
|
|
65
|
+
constructor(agent: string, sandboxId: string, reason: string);
|
|
66
|
+
}
|
|
67
|
+
export declare function requireManagedProcessCapability(sandbox: Sandbox, agent: string): (input: ManagedProcessStart) => Promise<ManagedProcess>;
|
|
57
68
|
/** Provider facade 登记的复用寿命能力;不存在时保持显式 Unsupported,不做鸭子类型探测。 */
|
|
58
69
|
export declare function sandboxReuseCapability(sandbox: Sandbox): SandboxReuseCapability | undefined;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import type { CommandOptions, CommandResult, Sandbox, SandboxReuseCapability, SandboxTransferOperations } from "./types.js";
|
|
2
|
+
import type { CommandOptions, CommandResult, Sandbox, ManagedProcess, ManagedProcessStart, SandboxReuseCapability, SandboxTransferOperations } from "./types.js";
|
|
3
3
|
export type SandboxBackendSupport<T> = {
|
|
4
4
|
readonly _tag: "Supported";
|
|
5
5
|
readonly value: T;
|
|
6
6
|
} | {
|
|
7
7
|
readonly _tag: "Unsupported";
|
|
8
|
+
readonly reason: string;
|
|
8
9
|
};
|
|
9
10
|
export interface SandboxBackendCapabilities {
|
|
10
11
|
/** Provider 能否兑现 CommandOptions.user 的 root 覆盖;runner 私有基础设施按这项能力选择身份。 */
|
|
@@ -19,6 +20,7 @@ export interface SandboxBackendCapabilities {
|
|
|
19
20
|
reason: string;
|
|
20
21
|
}>>;
|
|
21
22
|
readonly setCommandDeadline: SandboxBackendSupport<(deadlineAt?: number) => void>;
|
|
23
|
+
readonly managedProcess: SandboxBackendSupport<(input: ManagedProcessStart) => Promise<ManagedProcess>>;
|
|
22
24
|
}
|
|
23
25
|
export interface SandboxProviderBackend extends SandboxTransferOperations {
|
|
24
26
|
readonly workdir: string;
|
|
@@ -35,6 +37,7 @@ export interface SandboxProviderBackend extends SandboxTransferOperations {
|
|
|
35
37
|
stop(): Promise<void>;
|
|
36
38
|
}
|
|
37
39
|
export declare const unsupportedBackendCapability: SandboxBackendSupport<never>;
|
|
40
|
+
export declare function unsupportedBackendCapabilityBecause(reason: string): SandboxBackendSupport<never>;
|
|
38
41
|
export declare const noSandboxBackendCapabilities: SandboxBackendCapabilities;
|
|
39
42
|
export declare function supportedBackendCapability<T>(value: T): SandboxBackendSupport<T>;
|
|
40
43
|
/** Promise provider SDK 在这一处 lift 成 typed-error Effect;Error 实例原样保留给现有归因逻辑。 */
|
|
@@ -54,5 +57,13 @@ export declare function inheritSandboxCapabilities(source: Sandbox, target: Sand
|
|
|
54
57
|
export declare function sandboxCapabilities(sandbox: Sandbox): SandboxBackendCapabilities;
|
|
55
58
|
/** 未经 provider facade 登记的普通自定义 Sandbox 保守视为不支持提权,不做鸭子类型猜测。 */
|
|
56
59
|
export declare function sandboxSupportsRootCommands(sandbox: Sandbox): boolean;
|
|
60
|
+
export declare class SandboxManagedProcessCapabilityError extends Error {
|
|
61
|
+
readonly agent: string;
|
|
62
|
+
readonly sandboxId: string;
|
|
63
|
+
readonly reason: string;
|
|
64
|
+
readonly name = "SandboxManagedProcessCapabilityError";
|
|
65
|
+
constructor(agent: string, sandboxId: string, reason: string);
|
|
66
|
+
}
|
|
67
|
+
export declare function requireManagedProcessCapability(sandbox: Sandbox, agent: string): (input: ManagedProcessStart) => Promise<ManagedProcess>;
|
|
57
68
|
/** Provider facade 登记的复用寿命能力;不存在时保持显式 Unsupported,不做鸭子类型探测。 */
|
|
58
69
|
export declare function sandboxReuseCapability(sandbox: Sandbox): SandboxReuseCapability | undefined;
|
package/dist/sandbox/backend.js
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { createRequire as __niceevalCreateRequire } from "node:module";
|
|
2
2
|
const __niceevalRequire = __niceevalCreateRequire(import.meta.url);
|
|
3
3
|
const __niceevalCanonical = __niceevalRequire("./backend.cjs");
|
|
4
|
-
const __niceevalExport0 = __niceevalCanonical["
|
|
5
|
-
export { __niceevalExport0 as
|
|
6
|
-
const __niceevalExport1 = __niceevalCanonical["
|
|
7
|
-
export { __niceevalExport1 as
|
|
8
|
-
const __niceevalExport2 = __niceevalCanonical["
|
|
9
|
-
export { __niceevalExport2 as
|
|
10
|
-
const __niceevalExport3 = __niceevalCanonical["
|
|
11
|
-
export { __niceevalExport3 as
|
|
12
|
-
const __niceevalExport4 = __niceevalCanonical["
|
|
13
|
-
export { __niceevalExport4 as
|
|
14
|
-
const __niceevalExport5 = __niceevalCanonical["
|
|
15
|
-
export { __niceevalExport5 as
|
|
16
|
-
const __niceevalExport6 = __niceevalCanonical["
|
|
17
|
-
export { __niceevalExport6 as
|
|
18
|
-
const __niceevalExport7 = __niceevalCanonical["
|
|
19
|
-
export { __niceevalExport7 as
|
|
20
|
-
const __niceevalExport8 = __niceevalCanonical["
|
|
21
|
-
export { __niceevalExport8 as
|
|
22
|
-
const __niceevalExport9 = __niceevalCanonical["
|
|
23
|
-
export { __niceevalExport9 as
|
|
24
|
-
const __niceevalExport10 = __niceevalCanonical["
|
|
25
|
-
export { __niceevalExport10 as
|
|
4
|
+
const __niceevalExport0 = __niceevalCanonical["SandboxManagedProcessCapabilityError"];
|
|
5
|
+
export { __niceevalExport0 as SandboxManagedProcessCapabilityError };
|
|
6
|
+
const __niceevalExport1 = __niceevalCanonical["customSandboxBackend"];
|
|
7
|
+
export { __niceevalExport1 as customSandboxBackend };
|
|
8
|
+
const __niceevalExport2 = __niceevalCanonical["inheritSandboxCapabilities"];
|
|
9
|
+
export { __niceevalExport2 as inheritSandboxCapabilities };
|
|
10
|
+
const __niceevalExport3 = __niceevalCanonical["noSandboxBackendCapabilities"];
|
|
11
|
+
export { __niceevalExport3 as noSandboxBackendCapabilities };
|
|
12
|
+
const __niceevalExport4 = __niceevalCanonical["providerBoundaryEffect"];
|
|
13
|
+
export { __niceevalExport4 as providerBoundaryEffect };
|
|
14
|
+
const __niceevalExport5 = __niceevalCanonical["providerCompatibilityPromise"];
|
|
15
|
+
export { __niceevalExport5 as providerCompatibilityPromise };
|
|
16
|
+
const __niceevalExport6 = __niceevalCanonical["registerSandboxCapabilities"];
|
|
17
|
+
export { __niceevalExport6 as registerSandboxCapabilities };
|
|
18
|
+
const __niceevalExport7 = __niceevalCanonical["requireManagedProcessCapability"];
|
|
19
|
+
export { __niceevalExport7 as requireManagedProcessCapability };
|
|
20
|
+
const __niceevalExport8 = __niceevalCanonical["sandboxCapabilities"];
|
|
21
|
+
export { __niceevalExport8 as sandboxCapabilities };
|
|
22
|
+
const __niceevalExport9 = __niceevalCanonical["sandboxReuseCapability"];
|
|
23
|
+
export { __niceevalExport9 as sandboxReuseCapability };
|
|
24
|
+
const __niceevalExport10 = __niceevalCanonical["sandboxSupportsRootCommands"];
|
|
25
|
+
export { __niceevalExport10 as sandboxSupportsRootCommands };
|
|
26
|
+
const __niceevalExport11 = __niceevalCanonical["supportedBackendCapability"];
|
|
27
|
+
export { __niceevalExport11 as supportedBackendCapability };
|
|
28
|
+
const __niceevalExport12 = __niceevalCanonical["unsupportedBackendCapability"];
|
|
29
|
+
export { __niceevalExport12 as unsupportedBackendCapability };
|
|
30
|
+
const __niceevalExport13 = __niceevalCanonical["unsupportedBackendCapabilityBecause"];
|
|
31
|
+
export { __niceevalExport13 as unsupportedBackendCapabilityBecause };
|
|
26
32
|
//# sourceMappingURL=backend.js.map
|
package/dist/sandbox/docker.cjs
CHANGED
|
@@ -14,6 +14,7 @@ exports.dockerManagedNetworkOptions = dockerManagedNetworkOptions;
|
|
|
14
14
|
// 改编自 agent-eval 的 docker-sandbox.ts,签名对齐 ../types.ts 的 Sandbox 契约
|
|
15
15
|
//(runShell/runCommand 的 opts 一律是选项对象,不再用位置参数)。
|
|
16
16
|
const node_path_1 = require("node:path");
|
|
17
|
+
const node_stream_1 = require("node:stream");
|
|
17
18
|
const node_crypto_1 = require("node:crypto");
|
|
18
19
|
const promises_1 = require("node:fs/promises");
|
|
19
20
|
const dockerode_1 = __importDefault(require("dockerode"));
|
|
@@ -30,6 +31,7 @@ const errors_ts_1 = require("./errors.cjs");
|
|
|
30
31
|
const run_identity_ts_1 = require("./run-identity.cjs");
|
|
31
32
|
const backend_ts_1 = require("./backend.cjs");
|
|
32
33
|
const dind_supervisor_ts_1 = require("./dind-supervisor.cjs");
|
|
34
|
+
const managed_process_ts_1 = require("./managed-process.cjs");
|
|
33
35
|
/**
|
|
34
36
|
* dockerode 对镜像拉取限流没有专门的错误类型;Docker Hub 429 体现在错误 message 里
|
|
35
37
|
* (如 "toomanyrequests: You have reached your pull rate limit")。
|
|
@@ -267,7 +269,145 @@ class DockerSandbox {
|
|
|
267
269
|
suspend: (0, backend_ts_1.supportedBackendCapability)(() => this.suspend()),
|
|
268
270
|
ensureLifetime: (0, backend_ts_1.supportedBackendCapability)((minRemainingMs) => this.ensureLifetime(minRemainingMs)),
|
|
269
271
|
setCommandDeadline: (0, backend_ts_1.supportedBackendCapability)((deadlineAt) => this.setCommandDeadline(deadlineAt)),
|
|
272
|
+
managedProcess: (0, backend_ts_1.supportedBackendCapability)((input) => this.startManagedProcess(input)),
|
|
270
273
|
};
|
|
274
|
+
async startManagedProcess(input) {
|
|
275
|
+
if (!this.container)
|
|
276
|
+
throw new Error((0, index_ts_1.t)("docker.containerNotInitialized"));
|
|
277
|
+
const [command, ...args] = input.argv;
|
|
278
|
+
const env = {
|
|
279
|
+
HOME: this.defaultHome,
|
|
280
|
+
USER: this.defaultUserName,
|
|
281
|
+
LOGNAME: this.defaultUserName,
|
|
282
|
+
...input.env,
|
|
283
|
+
PATH: this.sandboxPath,
|
|
284
|
+
...(this.defaultIsRoot ? { npm_config_unsafe_perm: "true" } : {}),
|
|
285
|
+
};
|
|
286
|
+
const marker = `__NICEEVAL_MANAGED_PID_${(0, node_crypto_1.randomUUID)()}__`;
|
|
287
|
+
const exec = await this.container.exec({
|
|
288
|
+
// If the Docker exec leader is already a process-group leader, setsid
|
|
289
|
+
// forks. --wait keeps Docker's receipt tied to the native child lifetime.
|
|
290
|
+
Cmd: ["setsid", "--wait", "sh", "-c", `printf '${marker}%s\\n' "$$" >&2; exec "$@"`, "sh", command, ...args],
|
|
291
|
+
AttachStdin: true,
|
|
292
|
+
AttachStdout: true,
|
|
293
|
+
AttachStderr: true,
|
|
294
|
+
WorkingDir: (0, paths_ts_1.resolveSandboxPath)(this.workdir, input.cwd),
|
|
295
|
+
Env: Object.entries(env).map(([key, value]) => `${key}=${value}`),
|
|
296
|
+
User: this.userOverride,
|
|
297
|
+
});
|
|
298
|
+
const stream = await exec.start({ hijack: true, stdin: true });
|
|
299
|
+
const output = new managed_process_ts_1.ManagedProcessOutput();
|
|
300
|
+
const stdout = new node_stream_1.PassThrough();
|
|
301
|
+
const stderr = new node_stream_1.PassThrough();
|
|
302
|
+
stdout.on("data", (bytes) => output.push({ _tag: "Stdout", bytes: new Uint8Array(bytes) }));
|
|
303
|
+
let stderrPrefix = Buffer.alloc(0);
|
|
304
|
+
let processGroup;
|
|
305
|
+
stderr.on("data", (bytes) => {
|
|
306
|
+
if (processGroup !== undefined) {
|
|
307
|
+
output.push({ _tag: "Stderr", bytes: new Uint8Array(bytes) });
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
stderrPrefix = Buffer.concat([stderrPrefix, bytes]);
|
|
311
|
+
const newline = stderrPrefix.indexOf(10);
|
|
312
|
+
if (newline < 0)
|
|
313
|
+
return;
|
|
314
|
+
const first = stderrPrefix.subarray(0, newline).toString("utf8");
|
|
315
|
+
if (!first.startsWith(marker) || !/^\d+$/.test(first.slice(marker.length))) {
|
|
316
|
+
output.push({ _tag: "Stderr", bytes: new Uint8Array(stderrPrefix) });
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
processGroup = Number(first.slice(marker.length));
|
|
320
|
+
const rest = stderrPrefix.subarray(newline + 1);
|
|
321
|
+
if (rest.length > 0)
|
|
322
|
+
output.push({ _tag: "Stderr", bytes: new Uint8Array(rest) });
|
|
323
|
+
}
|
|
324
|
+
stderrPrefix = Buffer.alloc(0);
|
|
325
|
+
});
|
|
326
|
+
this.docker.modem.demuxStream(stream, stdout, stderr);
|
|
327
|
+
let poll;
|
|
328
|
+
let settled = false;
|
|
329
|
+
let rejectExit;
|
|
330
|
+
const finishError = (error) => {
|
|
331
|
+
if (settled)
|
|
332
|
+
return;
|
|
333
|
+
settled = true;
|
|
334
|
+
if (poll !== undefined)
|
|
335
|
+
clearInterval(poll);
|
|
336
|
+
output.end();
|
|
337
|
+
stream.destroy();
|
|
338
|
+
rejectExit(error);
|
|
339
|
+
};
|
|
340
|
+
const exit = new Promise((resolve, reject) => {
|
|
341
|
+
rejectExit = reject;
|
|
342
|
+
stream.once("error", finishError);
|
|
343
|
+
poll = setInterval(() => {
|
|
344
|
+
void exec.inspect().then((inspection) => {
|
|
345
|
+
if (inspection.Running)
|
|
346
|
+
return;
|
|
347
|
+
if (settled)
|
|
348
|
+
return;
|
|
349
|
+
settled = true;
|
|
350
|
+
if (poll !== undefined)
|
|
351
|
+
clearInterval(poll);
|
|
352
|
+
output.end();
|
|
353
|
+
stream.destroy();
|
|
354
|
+
resolve({ exitCode: inspection.ExitCode ?? null });
|
|
355
|
+
}, finishError);
|
|
356
|
+
}, 100);
|
|
357
|
+
});
|
|
358
|
+
let closeReceipt;
|
|
359
|
+
let terminateReceipt;
|
|
360
|
+
let stdinState = "open";
|
|
361
|
+
return {
|
|
362
|
+
output,
|
|
363
|
+
writeStdin: (bytes) => new Promise((resolve, reject) => {
|
|
364
|
+
if (stdinState !== "open") {
|
|
365
|
+
reject(new Error("managed process stdin is closed"));
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
stream.write(Buffer.from(bytes), (error) => error ? reject(error) : resolve());
|
|
369
|
+
}),
|
|
370
|
+
closeStdin: () => closeReceipt ??= new Promise((resolve) => {
|
|
371
|
+
stdinState = "closing";
|
|
372
|
+
stream.end(() => { stdinState = "closed"; resolve(); });
|
|
373
|
+
}),
|
|
374
|
+
wait: () => exit,
|
|
375
|
+
terminate: () => terminateReceipt ??= (async () => {
|
|
376
|
+
stdinState = "closing";
|
|
377
|
+
const inspection = await exec.inspect().catch(() => undefined);
|
|
378
|
+
if (!inspection?.Running) {
|
|
379
|
+
await exit.catch(() => undefined);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (processGroup === undefined) {
|
|
383
|
+
const error = new Error("docker managed process did not disclose its process-group identity; sandbox retirement is required");
|
|
384
|
+
finishError(error);
|
|
385
|
+
throw error;
|
|
386
|
+
}
|
|
387
|
+
// Do not route this provider-owned control operation through runCommand's
|
|
388
|
+
// command-tree supervisor: killing the target exec while that supervisor
|
|
389
|
+
// samples the same tree creates an ambiguous non-zero receipt. Docker's
|
|
390
|
+
// own exec receipt is the exact acknowledgement for this one kill(2).
|
|
391
|
+
const killer = await this.container.exec({
|
|
392
|
+
// POSIX `kill` is a shell builtin in slim images (no /usr/bin/kill).
|
|
393
|
+
// The PGID is a separate positional parameter, never interpolated.
|
|
394
|
+
Cmd: ["sh", "-c", "kill -KILL \"$1\"", "sh", `-${processGroup}`],
|
|
395
|
+
AttachStdout: true,
|
|
396
|
+
AttachStderr: true,
|
|
397
|
+
User: "root",
|
|
398
|
+
});
|
|
399
|
+
const killStream = await killer.start({});
|
|
400
|
+
const killOutput = await (0, docker_stream_ts_1.readableToBuffer)(killStream);
|
|
401
|
+
const killed = await killer.inspect();
|
|
402
|
+
if (killed.ExitCode !== 0) {
|
|
403
|
+
const error = new Error(`docker could not terminate managed process group ${processGroup}; sandbox retirement is required: ${killOutput.toString("utf8")}`);
|
|
404
|
+
finishError(error);
|
|
405
|
+
throw error;
|
|
406
|
+
}
|
|
407
|
+
await exit;
|
|
408
|
+
})(),
|
|
409
|
+
};
|
|
410
|
+
}
|
|
271
411
|
constructor(options = {}) {
|
|
272
412
|
this.docker = new dockerode_1.default(options.dockerSocketPath === undefined ? undefined : { socketPath: options.dockerSocketPath });
|
|
273
413
|
this.workdir = options.workdir ?? CONTAINER_WORKDIR;
|