niceeval 0.13.1 → 0.13.2
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/INDEX.md +25 -2
- package/README.md +9 -10
- package/README.zh.md +9 -10
- package/dist/agents/ai-sdk.cjs.map +1 -1
- package/dist/agents/ai-sdk.d.cts +1 -1
- package/dist/agents/ai-sdk.d.mts +1 -1
- package/dist/agents/ai-sdk.d.ts +1 -1
- package/dist/agents/bub-install-spec.cjs +19 -5
- package/dist/agents/bub-install-spec.cjs.map +1 -1
- package/dist/agents/bub-install-spec.d.cts +9 -2
- package/dist/agents/bub-install-spec.d.mts +9 -2
- package/dist/agents/bub-install-spec.d.ts +9 -2
- package/dist/agents/bub-install-spec.js +14 -12
- package/dist/agents/bub.cjs +10 -6
- 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.cjs.map +1 -1
- package/dist/agents/claude-code.d.cts +2 -2
- package/dist/agents/claude-code.d.mts +2 -2
- package/dist/agents/claude-code.d.ts +2 -2
- package/dist/agents/codex.cjs +4 -4
- 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/coding-cli-versions.cjs +10 -1
- package/dist/agents/coding-cli-versions.cjs.map +1 -1
- package/dist/agents/coding-cli-versions.d.cts +8 -3
- package/dist/agents/coding-cli-versions.d.mts +8 -3
- package/dist/agents/coding-cli-versions.d.ts +8 -3
- package/dist/agents/coding-cli-versions.js +18 -12
- package/dist/agents/deepseek-harness.cjs +151 -0
- package/dist/agents/deepseek-harness.cjs.map +1 -0
- package/dist/agents/deepseek-harness.d.cts +14 -0
- package/dist/agents/deepseek-harness.d.mts +14 -0
- package/dist/agents/deepseek-harness.d.ts +14 -0
- package/dist/agents/deepseek-harness.js +7 -0
- package/dist/agents/deepseek-harness.js.map +1 -0
- package/dist/agents/exact-npm-plugins.cjs +28 -0
- package/dist/agents/exact-npm-plugins.cjs.map +1 -0
- package/dist/agents/exact-npm-plugins.d.cts +10 -0
- package/dist/agents/exact-npm-plugins.d.mts +10 -0
- package/dist/agents/exact-npm-plugins.d.ts +10 -0
- package/dist/agents/exact-npm-plugins.js +8 -0
- package/dist/agents/exact-npm-plugins.js.map +1 -0
- package/dist/agents/index.cjs +5 -1
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +4 -0
- package/dist/agents/index.d.mts +4 -0
- package/dist/agents/index.d.ts +4 -0
- package/dist/agents/index.js +54 -50
- package/dist/agents/index.mjs +54 -50
- package/dist/agents/omp.cjs +170 -0
- package/dist/agents/omp.cjs.map +1 -0
- package/dist/agents/omp.d.cts +14 -0
- package/dist/agents/omp.d.mts +14 -0
- package/dist/agents/omp.d.ts +14 -0
- package/dist/agents/omp.js +7 -0
- package/dist/agents/omp.js.map +1 -0
- package/dist/agents/openclaw.cjs +51 -2
- package/dist/agents/openclaw.cjs.map +1 -1
- package/dist/agents/openclaw.d.cts +2 -0
- package/dist/agents/openclaw.d.mts +2 -0
- package/dist/agents/openclaw.d.ts +2 -0
- package/dist/agents/types.cjs.map +1 -1
- package/dist/agents/types.d.cts +4 -4
- package/dist/agents/types.d.mts +4 -4
- package/dist/agents/types.d.ts +4 -4
- package/dist/agents/ui-message-stream.cjs +24 -7
- package/dist/agents/ui-message-stream.cjs.map +1 -1
- package/dist/analysis/api.cjs +28 -2
- package/dist/analysis/api.cjs.map +1 -1
- package/dist/analysis/api.d.cts +22 -1
- package/dist/analysis/api.d.mts +22 -1
- package/dist/analysis/api.d.ts +22 -1
- package/dist/analysis/api.js +8 -6
- package/dist/analysis/bindings.cjs +11 -18
- package/dist/analysis/bindings.cjs.map +1 -1
- package/dist/analysis/bindings.d.cts +177 -49
- package/dist/analysis/bindings.d.mts +177 -49
- package/dist/analysis/bindings.d.ts +177 -49
- package/dist/analysis/contracts.cjs +1 -0
- package/dist/analysis/contracts.cjs.map +1 -1
- package/dist/analysis/contracts.d.cts +43 -3
- package/dist/analysis/contracts.d.mts +43 -3
- package/dist/analysis/contracts.d.ts +43 -3
- package/dist/analysis/cost-projection.cjs +2 -1
- package/dist/analysis/cost-projection.cjs.map +1 -1
- package/dist/analysis/cost-projection.d.cts +1 -1
- package/dist/analysis/cost-projection.d.mts +1 -1
- package/dist/analysis/cost-projection.d.ts +1 -1
- package/dist/analysis/cost.cjs +13 -3
- package/dist/analysis/cost.cjs.map +1 -1
- package/dist/analysis/cost.d.cts +10 -3
- package/dist/analysis/cost.d.mts +10 -3
- package/dist/analysis/cost.d.ts +10 -3
- package/dist/analysis/experiment-groups.cjs +96 -0
- package/dist/analysis/experiment-groups.cjs.map +1 -0
- package/dist/analysis/experiment-groups.d.cts +9 -0
- package/dist/analysis/experiment-groups.d.mts +9 -0
- package/dist/analysis/experiment-groups.d.ts +9 -0
- package/dist/analysis/experiment-groups.js +10 -0
- package/dist/analysis/experiment-groups.js.map +1 -0
- package/dist/analysis/index.cjs +4 -1
- package/dist/analysis/index.cjs.map +1 -1
- package/dist/analysis/index.d.cts +4 -2
- package/dist/analysis/index.d.mts +4 -2
- package/dist/analysis/index.d.ts +4 -2
- package/dist/analysis/index.js +40 -36
- package/dist/analysis/index.mjs +40 -36
- package/dist/assertions/limits.cjs +4 -0
- package/dist/assertions/limits.cjs.map +1 -1
- package/dist/assertions/limits.d.cts +4 -0
- package/dist/assertions/limits.d.mts +4 -0
- package/dist/assertions/limits.d.ts +4 -0
- package/dist/assertions/match.cjs +63 -25
- package/dist/assertions/match.cjs.map +1 -1
- package/dist/assertions/match.d.cts +7 -0
- package/dist/assertions/match.d.mts +7 -0
- package/dist/assertions/match.d.ts +7 -0
- package/dist/assertions/record/attachment.cjs +32 -4
- package/dist/assertions/record/attachment.cjs.map +1 -1
- package/dist/assertions/record/diff.cjs +10 -4
- package/dist/assertions/record/diff.cjs.map +1 -1
- package/dist/assertions/record/producer.cjs +101 -4
- package/dist/assertions/record/producer.cjs.map +1 -1
- package/dist/assertions/record/producer.d.cts +4 -1
- package/dist/assertions/record/producer.d.mts +4 -1
- package/dist/assertions/record/producer.d.ts +4 -1
- package/dist/assertions/runtime.cjs +45 -5
- package/dist/assertions/runtime.cjs.map +1 -1
- package/dist/cli/record.cjs +113 -8
- package/dist/cli/record.cjs.map +1 -1
- package/dist/cli/record.d.cts +20 -1
- package/dist/cli/record.d.mts +20 -1
- package/dist/cli/record.d.ts +20 -1
- package/dist/cli/record.js +4 -2
- package/dist/cli.cjs +386 -31
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +10 -2
- package/dist/cli.d.mts +10 -2
- package/dist/cli.d.ts +10 -2
- package/dist/context/send-retry.cjs +4 -4
- package/dist/context/send-retry.cjs.map +1 -1
- package/dist/coordination/host/runtime.cjs +8 -30
- package/dist/coordination/host/runtime.cjs.map +1 -1
- package/dist/coordination/host/runtime.d.cts +3 -3
- package/dist/coordination/host/runtime.d.mts +3 -3
- package/dist/coordination/host/runtime.d.ts +3 -3
- package/dist/coordination/host/types.cjs.map +1 -1
- package/dist/coordination/host/types.d.cts +0 -5
- package/dist/coordination/host/types.d.mts +0 -5
- package/dist/coordination/host/types.d.ts +0 -5
- package/dist/coordination/platform/node.cjs +90 -9
- package/dist/coordination/platform/node.cjs.map +1 -1
- package/dist/define.cjs +25 -1
- package/dist/define.cjs.map +1 -1
- package/dist/experiment/host/index.cjs +1 -0
- package/dist/experiment/host/index.cjs.map +1 -1
- package/dist/i18n/en.cjs +26 -8
- package/dist/i18n/en.cjs.map +1 -1
- package/dist/i18n/en.d.cts +19 -6
- package/dist/i18n/en.d.mts +19 -6
- package/dist/i18n/en.d.ts +19 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/o11y/parsers/hermes.cjs +1 -1
- package/dist/o11y/parsers/hermes.cjs.map +1 -1
- package/dist/o11y/prices.json +1 -1
- package/dist/o11y/record/families.cjs +12 -3
- package/dist/o11y/record/families.cjs.map +1 -1
- package/dist/o11y/record/families.d.cts +8 -8
- package/dist/o11y/record/families.d.mts +8 -8
- package/dist/o11y/record/families.d.ts +8 -8
- package/dist/o11y/record/family-projectors.d.cts +66 -18
- package/dist/o11y/record/family-projectors.d.mts +66 -18
- package/dist/o11y/record/family-projectors.d.ts +66 -18
- package/dist/o11y/record/family-writers.d.cts +11 -3
- package/dist/o11y/record/family-writers.d.mts +11 -3
- package/dist/o11y/record/family-writers.d.ts +11 -3
- package/dist/o11y/record/runner-producer.cjs +14 -4
- package/dist/o11y/record/runner-producer.cjs.map +1 -1
- package/dist/record/codec/core.d.cts +2 -2
- package/dist/record/codec/core.d.mts +2 -2
- package/dist/record/codec/core.d.ts +2 -2
- package/dist/record/family/catalog.d.cts +44 -12
- package/dist/record/family/catalog.d.mts +44 -12
- package/dist/record/family/catalog.d.ts +44 -12
- package/dist/record/family/index.js +128 -124
- package/dist/record/family/observability-v1.cjs +35 -0
- package/dist/record/family/observability-v1.cjs.map +1 -0
- package/dist/record/family/observability-v1.d.cts +3 -0
- package/dist/record/family/observability-v1.d.mts +3 -0
- package/dist/record/family/observability-v1.d.ts +3 -0
- package/dist/record/family/observability-v1.js +6 -0
- package/dist/record/family/observability-v1.js.map +1 -0
- package/dist/record/family/observability.cjs +58 -9
- package/dist/record/family/observability.cjs.map +1 -1
- package/dist/record/family/observability.d.cts +1014 -15
- package/dist/record/family/observability.d.mts +1014 -15
- package/dist/record/family/observability.d.ts +1014 -15
- package/dist/record/family/observability.js +22 -18
- package/dist/record/host/runtime.cjs +600 -31
- 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 +33 -9
- package/dist/record/host/types.d.mts +33 -9
- package/dist/record/host/types.d.ts +33 -9
- package/dist/record/maintenance/runtime.cjs +1 -2
- package/dist/record/maintenance/runtime.cjs.map +1 -1
- package/dist/record/model/core.cjs.map +1 -1
- package/dist/record/model/core.d.cts +1 -1
- package/dist/record/model/core.d.mts +1 -1
- package/dist/record/model/core.d.ts +1 -1
- package/dist/record/model/definition.d.cts +6 -6
- package/dist/record/model/definition.d.mts +6 -6
- package/dist/record/model/definition.d.ts +6 -6
- package/dist/record/model/identifiers.cjs +1 -1
- package/dist/record/model/identifiers.cjs.map +1 -1
- package/dist/record/model/identifiers.d.cts +1 -1
- package/dist/record/model/identifiers.d.mts +1 -1
- package/dist/record/model/identifiers.d.ts +1 -1
- package/dist/record/platform/node.cjs +159 -23
- 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 +15 -2
- package/dist/record/platform/services.d.mts +15 -2
- package/dist/record/platform/services.d.ts +15 -2
- package/dist/record/reader/errors.cjs +37 -1
- package/dist/record/reader/errors.cjs.map +1 -1
- package/dist/record/reader/errors.d.cts +49 -1
- package/dist/record/reader/errors.d.mts +49 -1
- package/dist/record/reader/errors.d.ts +49 -1
- package/dist/record/reader/errors.js +22 -12
- package/dist/record/reader/format.cjs +76 -17
- package/dist/record/reader/format.cjs.map +1 -1
- package/dist/record/reader/format.d.cts +11 -4
- package/dist/record/reader/format.d.mts +11 -4
- package/dist/record/reader/format.d.ts +11 -4
- package/dist/record/reader/format.js +2 -0
- package/dist/record/reader/index.js +32 -18
- package/dist/record/reader/runtime.cjs +64 -0
- package/dist/record/reader/runtime.cjs.map +1 -1
- package/dist/record/reader/runtime.d.cts +15 -0
- package/dist/record/reader/runtime.d.mts +15 -0
- package/dist/record/reader/runtime.d.ts +15 -0
- package/dist/record/reader/runtime.js +2 -0
- package/dist/report/assets/styles.css +53 -29
- package/dist/report/built-in/analysis-values.cjs +21 -13
- package/dist/report/built-in/analysis-values.cjs.map +1 -1
- package/dist/report/built-in/analysis-values.d.cts +11 -22
- package/dist/report/built-in/analysis-values.d.mts +11 -22
- package/dist/report/built-in/analysis-values.d.ts +11 -22
- package/dist/report/built-in/analysis-values.js +4 -6
- package/dist/report/built-in/index.cjs +1 -3
- package/dist/report/built-in/index.cjs.map +1 -1
- package/dist/report/built-in/index.d.cts +1 -1
- package/dist/report/built-in/index.d.mts +1 -1
- package/dist/report/built-in/index.d.ts +1 -1
- package/dist/report/built-in/index.js +4 -8
- package/dist/report/built-in/index.mjs +4 -8
- package/dist/report/built-in/machine.cjs +0 -2
- package/dist/report/built-in/machine.cjs.map +1 -1
- package/dist/report/built-in/machine.d.cts +0 -2
- package/dist/report/built-in/machine.d.mts +0 -2
- package/dist/report/built-in/machine.d.ts +0 -2
- package/dist/report/built-in/result-components.cjs +49 -51
- package/dist/report/built-in/result-components.cjs.map +1 -1
- package/dist/report/built-in/result-components.d.cts +16 -17
- package/dist/report/built-in/result-components.d.mts +16 -17
- package/dist/report/built-in/result-components.d.ts +16 -17
- package/dist/report/built-in/result-components.js +0 -4
- package/dist/report/built-in/run-membership-overview.cjs +126 -17
- package/dist/report/built-in/run-membership-overview.cjs.map +1 -1
- package/dist/report/built-in/run-membership-overview.d.cts +14 -0
- package/dist/report/built-in/run-membership-overview.d.mts +14 -0
- package/dist/report/built-in/run-membership-overview.d.ts +14 -0
- package/dist/report/built-in/run-membership-overview.js +4 -2
- package/dist/report/built-in/standard.cjs +80 -45
- package/dist/report/built-in/standard.cjs.map +1 -1
- package/dist/report/built-in/standard.d.cts +19 -41
- package/dist/report/built-in/standard.d.mts +19 -41
- package/dist/report/built-in/standard.d.ts +19 -41
- package/dist/report/built-in/standard.js +6 -6
- package/dist/report/components/attempt-detail/compute.cjs +78 -2
- package/dist/report/components/attempt-detail/compute.cjs.map +1 -1
- package/dist/report/components/attempt-detail/compute.d.cts +1 -1
- package/dist/report/components/attempt-detail/compute.d.mts +1 -1
- package/dist/report/components/attempt-detail/compute.d.ts +1 -1
- package/dist/report/components/attempt-detail/content.cjs +1 -1
- package/dist/report/components/attempt-detail/content.cjs.map +1 -1
- package/dist/report/components/entity-lists/compute.cjs +42 -5
- package/dist/report/components/entity-lists/compute.cjs.map +1 -1
- package/dist/report/components/entity-lists/compute.d.cts +10 -8
- package/dist/report/components/entity-lists/compute.d.mts +10 -8
- package/dist/report/components/entity-lists/compute.d.ts +10 -8
- package/dist/report/components/entity-lists/content.cjs +31 -6
- package/dist/report/components/entity-lists/content.cjs.map +1 -1
- package/dist/report/components/entity-lists/index.cjs +9 -4
- package/dist/report/components/entity-lists/index.cjs.map +1 -1
- package/dist/report/components/entity-lists/index.d.cts +4 -7
- package/dist/report/components/entity-lists/index.d.mts +4 -7
- package/dist/report/components/entity-lists/index.d.ts +4 -7
- package/dist/report/components/summaries/compute.cjs +8 -1
- package/dist/report/components/summaries/compute.cjs.map +1 -1
- package/dist/report/components/summaries/compute.d.cts +9 -1
- package/dist/report/components/summaries/compute.d.mts +9 -1
- package/dist/report/components/summaries/compute.d.ts +9 -1
- package/dist/report/components/summaries/index.cjs +48 -4
- package/dist/report/components/summaries/index.cjs.map +1 -1
- package/dist/report/components/summaries/index.d.cts +7 -4
- package/dist/report/components/summaries/index.d.mts +7 -4
- package/dist/report/components/summaries/index.d.ts +7 -4
- package/dist/report/definition/cell.cjs +3 -0
- package/dist/report/definition/cell.cjs.map +1 -1
- package/dist/report/definition/cell.d.cts +2 -0
- package/dist/report/definition/cell.d.mts +2 -0
- package/dist/report/definition/cell.d.ts +2 -0
- package/dist/report/definition/primitives/chart.cjs +8 -5
- package/dist/report/definition/primitives/chart.cjs.map +1 -1
- package/dist/report/definition/primitives/points-dataset.cjs +1 -0
- package/dist/report/definition/primitives/points-dataset.cjs.map +1 -1
- package/dist/report/definition/primitives.cjs +15 -2
- package/dist/report/definition/primitives.cjs.map +1 -1
- package/dist/report/definition/report.cjs +27 -3
- package/dist/report/definition/report.cjs.map +1 -1
- package/dist/report/definition/report.d.cts +8 -0
- package/dist/report/definition/report.d.mts +8 -0
- package/dist/report/definition/report.d.ts +8 -0
- package/dist/report/execution/machine.cjs +30 -14
- package/dist/report/execution/machine.cjs.map +1 -1
- package/dist/report/execution/machine.d.cts +20 -10
- package/dist/report/execution/machine.d.mts +20 -10
- package/dist/report/execution/machine.d.ts +20 -10
- package/dist/report/execution/machine.js +6 -6
- package/dist/report/host/execute.cjs +25 -16
- package/dist/report/host/execute.cjs.map +1 -1
- package/dist/report/host/execute.d.cts +4 -0
- package/dist/report/host/execute.d.mts +4 -0
- package/dist/report/host/execute.d.ts +4 -0
- package/dist/report/host/from-record.cjs +22 -5
- package/dist/report/host/from-record.cjs.map +1 -1
- package/dist/report/host/machine.cjs +53 -11
- package/dist/report/host/machine.cjs.map +1 -1
- package/dist/report/host/site-runtime.cjs +9 -8
- package/dist/report/host/site-runtime.cjs.map +1 -1
- package/dist/report/host/site-runtime.d.cts +1 -1
- package/dist/report/host/site-runtime.d.mts +1 -1
- package/dist/report/host/site-runtime.d.ts +1 -1
- package/dist/report/host/static.cjs +56 -9
- package/dist/report/host/static.cjs.map +1 -1
- package/dist/report/index.cjs.map +1 -1
- package/dist/report/index.d.cts +1 -1
- package/dist/report/index.d.mts +1 -1
- package/dist/report/index.d.ts +1 -1
- package/dist/report/model/dataset.cjs +7 -2
- package/dist/report/model/dataset.cjs.map +1 -1
- package/dist/report/model/locale.cjs +2 -0
- package/dist/report/model/locale.cjs.map +1 -1
- package/dist/report/model/locale.d.cts +1 -0
- package/dist/report/model/locale.d.mts +1 -0
- package/dist/report/model/locale.d.ts +1 -0
- package/dist/report/model/metrics.cjs +3 -1
- package/dist/report/model/metrics.cjs.map +1 -1
- package/dist/report/model/pricing.cjs +16 -11
- package/dist/report/model/pricing.cjs.map +1 -1
- package/dist/report/react/styles.css +53 -29
- package/dist/runner/adoption.cjs +1 -0
- package/dist/runner/adoption.cjs.map +1 -1
- package/dist/runner/attempt.cjs +44 -5
- package/dist/runner/attempt.cjs.map +1 -1
- package/dist/runner/attempt.d.cts +13 -1
- package/dist/runner/attempt.d.mts +13 -1
- package/dist/runner/attempt.d.ts +13 -1
- package/dist/runner/config-identity.cjs +10 -2
- package/dist/runner/config-identity.cjs.map +1 -1
- package/dist/runner/config-identity.d.cts +4 -2
- package/dist/runner/config-identity.d.mts +4 -2
- package/dist/runner/config-identity.d.ts +4 -2
- package/dist/runner/feedback/human.cjs +298 -59
- package/dist/runner/feedback/human.cjs.map +1 -1
- package/dist/runner/feedback/json.cjs +14 -6
- package/dist/runner/feedback/json.cjs.map +1 -1
- package/dist/runner/feedback/json.d.cts +3 -2
- package/dist/runner/feedback/json.d.mts +3 -2
- package/dist/runner/feedback/json.d.ts +3 -2
- package/dist/runner/feedback/reducer.cjs +2 -0
- package/dist/runner/feedback/reducer.cjs.map +1 -1
- package/dist/runner/judge-config.cjs +1 -1
- package/dist/runner/judge-config.cjs.map +1 -1
- package/dist/runner/ledger.cjs +124 -12
- package/dist/runner/ledger.cjs.map +1 -1
- package/dist/runner/project-current.cjs +13 -5
- package/dist/runner/project-current.cjs.map +1 -1
- package/dist/runner/run.cjs +564 -256
- package/dist/runner/run.cjs.map +1 -1
- package/dist/runner/sandbox-pool.cjs +161 -30
- package/dist/runner/sandbox-pool.cjs.map +1 -1
- package/dist/runner/sandbox-pool.d.cts +34 -2
- package/dist/runner/sandbox-pool.d.mts +34 -2
- package/dist/runner/sandbox-pool.d.ts +34 -2
- package/dist/runner/shared-state-lease.cjs +803 -0
- package/dist/runner/shared-state-lease.cjs.map +1 -0
- package/dist/runner/shared-state-lease.d.cts +121 -0
- package/dist/runner/shared-state-lease.d.mts +121 -0
- package/dist/runner/shared-state-lease.d.ts +121 -0
- package/dist/runner/shared-state-lease.js +24 -0
- package/dist/runner/shared-state-lease.js.map +1 -0
- package/dist/runner/teardown-registry.cjs +97 -34
- package/dist/runner/teardown-registry.cjs.map +1 -1
- package/dist/runner/teardown-registry.d.cts +27 -1
- package/dist/runner/teardown-registry.d.mts +27 -1
- package/dist/runner/teardown-registry.d.ts +27 -1
- package/dist/runner/teardown-registry.js +20 -16
- package/dist/runner/types.cjs.map +1 -1
- package/dist/runner/types.d.cts +31 -5
- package/dist/runner/types.d.mts +31 -5
- package/dist/runner/types.d.ts +31 -5
- package/dist/sample/analysis.cjs +249 -459
- package/dist/sample/analysis.cjs.map +1 -1
- package/dist/sample/capability.cjs +138 -7
- package/dist/sample/capability.cjs.map +1 -1
- package/dist/sample/capability.d.cts +3 -1
- package/dist/sample/capability.d.mts +3 -1
- package/dist/sample/capability.d.ts +3 -1
- package/dist/sample/capability.js +8 -6
- package/dist/sandbox/docker-agent-image.cjs +5 -1
- package/dist/sandbox/docker-agent-image.cjs.map +1 -1
- package/dist/sandbox/docker-agent-image.d.cts +2 -0
- package/dist/sandbox/docker-agent-image.d.mts +2 -0
- package/dist/sandbox/docker-agent-image.d.ts +2 -0
- package/dist/sandbox/docker-agent-image.js +14 -10
- package/dist/sandbox/docker-profile/schema.cjs +283 -534
- package/dist/sandbox/docker-profile/schema.cjs.map +1 -1
- package/dist/sandbox/docker-profile/schema.d.cts +10 -27
- package/dist/sandbox/docker-profile/schema.d.mts +10 -27
- package/dist/sandbox/docker-profile/schema.d.ts +10 -27
- package/dist/sandbox/e2b-agent-template.cjs +5 -2
- package/dist/sandbox/e2b-agent-template.cjs.map +1 -1
- package/dist/sandbox/index.cjs +4 -2
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.d.cts +1 -1
- package/dist/sandbox/index.d.mts +1 -1
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +120 -116
- package/dist/sandbox/index.mjs +120 -116
- package/dist/sandbox/keep-registry.cjs +28 -66
- package/dist/sandbox/keep-registry.cjs.map +1 -1
- package/dist/sandbox/types.cjs.map +1 -1
- package/dist/sandbox/types.d.cts +1 -1
- package/dist/sandbox/types.d.mts +1 -1
- package/dist/sandbox/types.d.ts +1 -1
- package/dist/shared/aggregate.cjs +16 -6
- package/dist/shared/aggregate.cjs.map +1 -1
- package/dist/shared/aggregate.d.cts +12 -4
- package/dist/shared/aggregate.d.mts +12 -4
- package/dist/shared/aggregate.d.ts +12 -4
- package/dist/shared/turn-label.cjs +20 -2
- package/dist/shared/turn-label.cjs.map +1 -1
- package/dist/shared/turn-label.d.cts +2 -0
- package/dist/shared/turn-label.d.mts +2 -0
- package/dist/shared/turn-label.d.ts +2 -0
- package/dist/shared/turn-label.js +4 -2
- package/dist/vendor/remark/remark-gfm.cjs +7 -7
- package/dist/vendor/remark/remark-gfm.cjs.map +1 -1
- package/dist/vendor/remark/remark-parse.cjs +12 -12
- package/dist/vendor/remark/remark-parse.cjs.map +1 -1
- package/dist/vendor/remark/remark.cjs +13 -13
- package/dist/vendor/remark/remark.cjs.map +1 -1
- package/dist/view/server.cjs +6 -0
- package/dist/view/server.cjs.map +1 -1
- package/docs-site/images/hitl-handshake-zh.svg +3 -3
- package/docs-site/zh/examples/ai-agent-application.mdx +1 -1
- package/docs-site/zh/examples/coding-agent-extensions.mdx +1 -1
- package/docs-site/zh/examples/integrations/ai-sdk-v7.mdx +4 -3
- package/docs-site/zh/examples/integrations/claude-sdk.mdx +3 -3
- package/docs-site/zh/examples/integrations/codex-sdk.mdx +5 -5
- package/docs-site/zh/examples/integrations/langgraph.mdx +4 -4
- package/docs-site/zh/examples/integrations/pi-sdk.mdx +5 -5
- package/docs-site/zh/explanation/adapter.mdx +5 -5
- package/docs-site/zh/explanation/assert.mdx +7 -7
- package/docs-site/zh/explanation/drive.mdx +4 -2
- package/docs-site/zh/explanation/evals.mdx +10 -8
- package/docs-site/zh/explanation/experiment.mdx +2 -2
- package/docs-site/zh/explanation/hitl.mdx +9 -9
- package/docs-site/zh/explanation/judge.mdx +5 -5
- package/docs-site/zh/explanation/overview.mdx +3 -3
- package/docs-site/zh/explanation/runner.mdx +1 -1
- package/docs-site/zh/index.mdx +3 -3
- package/docs-site/zh/reference/builtin-agents.mdx +13 -13
- package/docs-site/zh/reference/capabilities.mdx +1 -1
- package/docs-site/zh/reference/cli.mdx +18 -12
- package/docs-site/zh/reference/define-agent.mdx +130 -5
- package/docs-site/zh/reference/define-config.mdx +2 -2
- package/docs-site/zh/reference/define-eval.mdx +4 -4
- package/docs-site/zh/reference/events.mdx +11 -11
- package/docs-site/zh/reference/official-adapters.mdx +6 -6
- package/docs-site/zh/reference/results-data.mdx +6 -0
- package/docs-site/zh/troubleshooting/debugging.mdx +1 -1
- package/docs-site/zh/troubleshooting/recover-after-kill.mdx +37 -5
- package/docs-site/zh/tutorials/accept-results.mdx +72 -0
- package/docs-site/zh/tutorials/agent-onboarding.mdx +6 -6
- package/docs-site/zh/tutorials/authoring.mdx +9 -13
- package/docs-site/zh/tutorials/ci-integration.mdx +6 -6
- package/docs-site/zh/tutorials/compare-runs.mdx +61 -0
- package/docs-site/zh/tutorials/concurrency.mdx +13 -12
- package/docs-site/zh/tutorials/configuration.mdx +4 -6
- package/docs-site/zh/tutorials/connect-your-agent.mdx +1 -1
- package/docs-site/zh/tutorials/control-run-cost.mdx +58 -0
- package/docs-site/zh/tutorials/criteria-files.mdx +2 -2
- package/docs-site/zh/tutorials/custom-reports.mdx +2 -2
- package/docs-site/zh/tutorials/debug-lifecycle-plan.mdx +46 -0
- package/docs-site/zh/tutorials/docker-in-docker.mdx +52 -43
- package/docs-site/zh/tutorials/eval-groups.mdx +6 -6
- package/docs-site/zh/tutorials/evaluation-kinds.mdx +3 -3
- package/docs-site/zh/tutorials/experiments.mdx +2 -3
- package/docs-site/zh/tutorials/handle-execution-failures.mdx +18 -10
- package/docs-site/zh/tutorials/install-custom-sandbox-agent.mdx +16 -8
- package/docs-site/zh/tutorials/nixos-managed-dind.mdx +160 -0
- package/docs-site/zh/tutorials/plugins.mdx +14 -0
- package/docs-site/zh/tutorials/rerun-and-cache.mdx +4 -2
- package/docs-site/zh/tutorials/sandbox-agent.mdx +17 -11
- package/docs-site/zh/tutorials/sandbox-providers.mdx +17 -13
- package/docs-site/zh/tutorials/sandbox-reuse.mdx +12 -19
- package/docs-site/zh/tutorials/select-and-preview.mdx +65 -0
- package/docs-site/zh/tutorials/verify-judge.mdx +78 -0
- package/docs-site/zh/tutorials/viewing-results.mdx +38 -1
- package/docs-site/zh/tutorials/write-experiment.mdx +7 -5
- package/docs-site/zh/tutorials/write-send.mdx +9 -8
- package/package.json +9 -5
- package/dist/report/built-in/overview.cjs +0 -44
- package/dist/report/built-in/overview.cjs.map +0 -1
- package/dist/report/built-in/overview.d.cts +0 -6
- package/dist/report/built-in/overview.d.mts +0 -6
- package/dist/report/built-in/overview.d.ts +0 -6
- package/dist/report/built-in/overview.js +0 -9
- package/dist/report/built-in/overview.js.map +0 -1
- package/dist/runner/gate-lease.cjs +0 -283
- package/dist/runner/gate-lease.cjs.map +0 -1
- package/dist/runner/gate-lease.d.cts +0 -62
- package/dist/runner/gate-lease.d.mts +0 -62
- package/dist/runner/gate-lease.d.ts +0 -62
- package/dist/runner/gate-lease.js +0 -22
- package/dist/runner/gate-lease.js.map +0 -1
package/dist/cli.d.cts
CHANGED
|
@@ -59,7 +59,7 @@ export interface Flags {
|
|
|
59
59
|
host?: string;
|
|
60
60
|
help: boolean;
|
|
61
61
|
version: boolean;
|
|
62
|
-
/** `clean` / `migrate` 专用:确认删除未完成 Run
|
|
62
|
+
/** `clean` / `migrate` 专用:确认删除未完成 Run 或在 clean Git restore point 下执行 migration。 */
|
|
63
63
|
yes: boolean;
|
|
64
64
|
source?: true | string;
|
|
65
65
|
execution: boolean;
|
|
@@ -90,6 +90,14 @@ export interface Flags {
|
|
|
90
90
|
orphans: boolean;
|
|
91
91
|
/** `exp` 命令专用:只对选中实验各执行一次实验级 teardown,不派发 attempt、不跑 setup。 */
|
|
92
92
|
teardown: boolean;
|
|
93
|
+
/** `exp --teardown` 专用:请求显式恢复的 sharedState key。 */
|
|
94
|
+
recoverSharedState?: string;
|
|
95
|
+
/** `exp --teardown --recover-shared-state` 专用:不可变 lease owner token。 */
|
|
96
|
+
ownerToken?: string;
|
|
97
|
+
/** 明确确认记录的 owner 已终止;没有它恢复拒绝执行。 */
|
|
98
|
+
confirmOwnerTerminated: boolean;
|
|
99
|
+
/** 明确确认远端外部状态已静止;没有它恢复拒绝执行。 */
|
|
100
|
+
confirmRemoteQuiesced: boolean;
|
|
93
101
|
}
|
|
94
102
|
/**
|
|
95
103
|
* Fold the invocation's real fresh results and current Record readbacks at the
|
|
@@ -136,5 +144,5 @@ export declare function renderExperimentRenameJson(document: ExperimentRenameJso
|
|
|
136
144
|
export declare function experimentRenameRejectedFromError(error: ExperimentRenameError): ExperimentRenameRejected;
|
|
137
145
|
/** 退出码:可迁移预览与成功执行为 0;blocked 预览 / rejected 整批零写入按失败退出。 */
|
|
138
146
|
export declare function experimentRenameExitCode(document: ExperimentRenameJsonDocument): number;
|
|
139
|
-
export declare const cliProgram: (interruption?: CliInterruptionOwnership) => Effect.Effect<number, CliFailure, import("effect/Scope").Scope | import("./coordination/record-leases.cjs").RecordCoordination | import("./record/platform/services.cjs").RecordFileSystem | import("./record/platform/services.cjs").RecordEntropy>;
|
|
147
|
+
export declare const cliProgram: (interruption?: CliInterruptionOwnership) => Effect.Effect<number, CliFailure, import("effect/Scope").Scope | import("./coordination/record-leases.cjs").RecordCoordination | import("./record/platform/services.cjs").RecordFileSystem | import("./record/platform/services.cjs").RecordEntropy | import("./record/platform/services.cjs").RecordGit>;
|
|
140
148
|
export {};
|
package/dist/cli.d.mts
CHANGED
|
@@ -59,7 +59,7 @@ export interface Flags {
|
|
|
59
59
|
host?: string;
|
|
60
60
|
help: boolean;
|
|
61
61
|
version: boolean;
|
|
62
|
-
/** `clean` / `migrate` 专用:确认删除未完成 Run
|
|
62
|
+
/** `clean` / `migrate` 专用:确认删除未完成 Run 或在 clean Git restore point 下执行 migration。 */
|
|
63
63
|
yes: boolean;
|
|
64
64
|
source?: true | string;
|
|
65
65
|
execution: boolean;
|
|
@@ -90,6 +90,14 @@ export interface Flags {
|
|
|
90
90
|
orphans: boolean;
|
|
91
91
|
/** `exp` 命令专用:只对选中实验各执行一次实验级 teardown,不派发 attempt、不跑 setup。 */
|
|
92
92
|
teardown: boolean;
|
|
93
|
+
/** `exp --teardown` 专用:请求显式恢复的 sharedState key。 */
|
|
94
|
+
recoverSharedState?: string;
|
|
95
|
+
/** `exp --teardown --recover-shared-state` 专用:不可变 lease owner token。 */
|
|
96
|
+
ownerToken?: string;
|
|
97
|
+
/** 明确确认记录的 owner 已终止;没有它恢复拒绝执行。 */
|
|
98
|
+
confirmOwnerTerminated: boolean;
|
|
99
|
+
/** 明确确认远端外部状态已静止;没有它恢复拒绝执行。 */
|
|
100
|
+
confirmRemoteQuiesced: boolean;
|
|
93
101
|
}
|
|
94
102
|
/**
|
|
95
103
|
* Fold the invocation's real fresh results and current Record readbacks at the
|
|
@@ -136,5 +144,5 @@ export declare function renderExperimentRenameJson(document: ExperimentRenameJso
|
|
|
136
144
|
export declare function experimentRenameRejectedFromError(error: ExperimentRenameError): ExperimentRenameRejected;
|
|
137
145
|
/** 退出码:可迁移预览与成功执行为 0;blocked 预览 / rejected 整批零写入按失败退出。 */
|
|
138
146
|
export declare function experimentRenameExitCode(document: ExperimentRenameJsonDocument): number;
|
|
139
|
-
export declare const cliProgram: (interruption?: CliInterruptionOwnership) => Effect.Effect<number, CliFailure, import("effect/Scope").Scope | import("./coordination/record-leases.mjs").RecordCoordination | import("./record/platform/services.mjs").RecordFileSystem | import("./record/platform/services.mjs").RecordEntropy>;
|
|
147
|
+
export declare const cliProgram: (interruption?: CliInterruptionOwnership) => Effect.Effect<number, CliFailure, import("effect/Scope").Scope | import("./coordination/record-leases.mjs").RecordCoordination | import("./record/platform/services.mjs").RecordFileSystem | import("./record/platform/services.mjs").RecordEntropy | import("./record/platform/services.mjs").RecordGit>;
|
|
140
148
|
export {};
|
package/dist/cli.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export interface Flags {
|
|
|
59
59
|
host?: string;
|
|
60
60
|
help: boolean;
|
|
61
61
|
version: boolean;
|
|
62
|
-
/** `clean` / `migrate` 专用:确认删除未完成 Run
|
|
62
|
+
/** `clean` / `migrate` 专用:确认删除未完成 Run 或在 clean Git restore point 下执行 migration。 */
|
|
63
63
|
yes: boolean;
|
|
64
64
|
source?: true | string;
|
|
65
65
|
execution: boolean;
|
|
@@ -90,6 +90,14 @@ export interface Flags {
|
|
|
90
90
|
orphans: boolean;
|
|
91
91
|
/** `exp` 命令专用:只对选中实验各执行一次实验级 teardown,不派发 attempt、不跑 setup。 */
|
|
92
92
|
teardown: boolean;
|
|
93
|
+
/** `exp --teardown` 专用:请求显式恢复的 sharedState key。 */
|
|
94
|
+
recoverSharedState?: string;
|
|
95
|
+
/** `exp --teardown --recover-shared-state` 专用:不可变 lease owner token。 */
|
|
96
|
+
ownerToken?: string;
|
|
97
|
+
/** 明确确认记录的 owner 已终止;没有它恢复拒绝执行。 */
|
|
98
|
+
confirmOwnerTerminated: boolean;
|
|
99
|
+
/** 明确确认远端外部状态已静止;没有它恢复拒绝执行。 */
|
|
100
|
+
confirmRemoteQuiesced: boolean;
|
|
93
101
|
}
|
|
94
102
|
/**
|
|
95
103
|
* Fold the invocation's real fresh results and current Record readbacks at the
|
|
@@ -136,5 +144,5 @@ export declare function renderExperimentRenameJson(document: ExperimentRenameJso
|
|
|
136
144
|
export declare function experimentRenameRejectedFromError(error: ExperimentRenameError): ExperimentRenameRejected;
|
|
137
145
|
/** 退出码:可迁移预览与成功执行为 0;blocked 预览 / rejected 整批零写入按失败退出。 */
|
|
138
146
|
export declare function experimentRenameExitCode(document: ExperimentRenameJsonDocument): number;
|
|
139
|
-
export declare const cliProgram: (interruption?: CliInterruptionOwnership) => Effect.Effect<number, CliFailure, import("effect/Scope").Scope | import("./coordination/record-leases.js").RecordCoordination | import("./record/platform/services.js").RecordFileSystem | import("./record/platform/services.js").RecordEntropy>;
|
|
147
|
+
export declare const cliProgram: (interruption?: CliInterruptionOwnership) => Effect.Effect<number, CliFailure, import("effect/Scope").Scope | import("./coordination/record-leases.js").RecordCoordination | import("./record/platform/services.js").RecordFileSystem | import("./record/platform/services.js").RecordEntropy | import("./record/platform/services.js").RecordGit>;
|
|
140
148
|
export {};
|
|
@@ -17,19 +17,19 @@ function createAttemptRetryBudget() {
|
|
|
17
17
|
return { remaining: exports.ATTEMPT_MAX_RETRIES };
|
|
18
18
|
}
|
|
19
19
|
/** Adapt the Attempt-owned AbortSignal into interruption, without turning it into a send failure. */
|
|
20
|
-
function
|
|
20
|
+
function awaitAbort(signal) {
|
|
21
21
|
return effect_1.Effect.async((resume) => {
|
|
22
22
|
if (signal.aborted) {
|
|
23
|
-
resume(effect_1.Effect.
|
|
23
|
+
resume(effect_1.Effect.void);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const onAbort = () => resume(effect_1.Effect.
|
|
26
|
+
const onAbort = () => resume(effect_1.Effect.void);
|
|
27
27
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
28
28
|
return effect_1.Effect.sync(() => signal.removeEventListener("abort", onAbort));
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
function retrySleep(signal, delayMs) {
|
|
32
|
-
return effect_1.Effect.raceFirst(effect_1.Effect.sleep(delayMs),
|
|
32
|
+
return effect_1.Effect.raceFirst(effect_1.Effect.sleep(delayMs).pipe(effect_1.Effect.as("delay")), awaitAbort(signal).pipe(effect_1.Effect.as("aborted"))).pipe(effect_1.Effect.flatMap((winner) => winner === "aborted" ? effect_1.Effect.interrupt : effect_1.Effect.void));
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* A retried Attempt gives its global slot back while waiting. acquireUseRelease
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-retry.js","sourceRoot":"","sources":["send-retry.ts"],"names":[],"mappings":";;;AAaA,4DAEC;AAsDD,8CA0CC;AA/GD,4DAA4D;AAC5D,0EAA0E;AAC1E,mCAA+C;AAC/C,+CAAqC;AACrC,iEAAkH;AAClH,yDAAoK;AACpK,mEAAqE;AACxD,QAAA,iBAAiB,GAAG,CAAC,CAAC;AACtB,QAAA,mBAAmB,GAAG,CAA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AM,MAAM,GAAG,KAAK,KAAK,MAAM;QAC3B,CAAC,CAAC,IAAA,YAAC,EAAC,gCAAgC,EAAE,EAAE,WAAW,EAAE,yBAAiB,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;QAC7F,CAAC,CAAC,IAAA,YAAC,EAAC,kCAAkC,EAAE,EAAE,UAAU,EAAE,2BAAmB,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACrG,MAAM,OAAO,GAAG,IAAA,kCAAe,EAAC;QAC5B,GAAG,OAAO;QACV,OAAO,EAAE,IAAA,kCAAe,EAAC,OAAO,CAAC,GAAG,MAAM;QAC1C,KAAK,EAAE,IAAA,0CAAsB,EAAC,OAAO,CAAC;KACzC,CAAC,CAAC;IACH,OAAO,IAAA,qCAAkB,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// Agent send 的唯一重试执行体。正常返回的三种 Turn status 都原样交回;只有 reject 的\n// SendFailure 进入分类和重试(docs/feature/error-classification/architecture.md)。\nimport { Clock, Effect, Random } from \"effect\";\nimport { t } from \"../i18n/index.ts\";\nimport { attachFailureClass, type AttemptFailureClassifier, type FailureClass } from \"../shared/failure-class.ts\";\nimport { makeSendFailure, normalizeSendFailure, resolveSendFailureClass, sendFailureText, type SendFailure, type SendFailureClassifier, } from \"./send-failures.ts\";\nimport { normalizeExternalCause } from \"../shared/external-cause.ts\";\nexport const SEND_MAX_ATTEMPTS = 4;\nexport const ATTEMPT_MAX_RETRIES = 8;\nconst BASE_DELAY_MS = 5000;\nexport interface AttemptRetryBudget {\n remaining: number;\n}\nexport function createAttemptRetryBudget(): AttemptRetryBudget {\n return { remaining: ATTEMPT_MAX_RETRIES };\n}\nexport interface ConcurrencySlot {\n readonly release: Effect.Effect<void>;\n readonly reacquire: Effect.Effect<void>;\n}\nexport interface RetriedSendFailure {\n /** 同一逻辑 send 内从 0 开始的物理尝试序号。 */\n sendAttempt: number;\n startedAt: string;\n durationMs: number;\n failure: SendFailure;\n classification: Extract<FailureClass, {\n retryable: true;\n }>;\n}\nexport interface SendRetryDeps {\n classifier?: SendFailureClassifier;\n experimentClassifier?: AttemptFailureClassifier;\n /** 只回报被自动重试吸收的物理失败;终局失败由抛出值承载。 */\n onRetryAttempt?: (attempt: RetriedSendFailure) => void;\n budget: AttemptRetryBudget;\n slot?: ConcurrencySlot;\n reportRetry?: (message: string) => void;\n signal: AbortSignal;\n}\n/** Adapt the Attempt-owned AbortSignal into interruption, without turning it into a send failure. */\nfunction interruptWhenAborted(signal: AbortSignal): Effect.Effect<never> {\n return Effect.async<never>((resume) => {\n if (signal.aborted) {\n resume(Effect.interrupt);\n return;\n }\n const onAbort = () => resume(Effect.interrupt);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n return Effect.sync(() => signal.removeEventListener(\"abort\", onAbort));\n });\n}\nfunction retrySleep(signal: AbortSignal, delayMs: number): Effect.Effect<void> {\n return Effect.raceFirst(Effect.sleep(delayMs), interruptWhenAborted(signal));\n}\n/**\n * A retried Attempt gives its global slot back while waiting. acquireUseRelease\n * registers reacquire before entering the interruptible sleep, so interruption\n * cannot permanently shrink available capacity.\n */\nfunction sleepWithReleasedSlot(slot: ConcurrencySlot | undefined, sleep: Effect.Effect<void, unknown>): Effect.Effect<void, unknown> {\n if (slot === undefined)\n return sleep;\n return Effect.acquireUseRelease(Effect.suspend(() => slot.release), () => sleep, () => Effect.suspend(() => slot.reacquire));\n}\n/**\n * 对同一个物理输入至多调用四次。adapter 未使用 makeSendFailure 而直接抛出的值在这里\n * 保守归一为 acceptance=unknown,因此会得到稳定 agent-send-failed,而不会被误重发。\n */\nexport function sendWithTurnRetry<T>(callOnce: Effect.Effect<T, unknown>, deps: SendRetryDeps): Effect.Effect<T, unknown> {\n const retry = (sendAttempt: number): Effect.Effect<T, unknown> => Effect.gen(function* () {\n const startedAtMs = yield* Clock.currentTimeMillis;\n const monotonicStartedAt = yield* Clock.currentTimeNanos;\n return yield* callOnce.pipe(Effect.mapError(normalizeSendFailure), Effect.catchAll((failure) => Effect.gen(function* () {\n const monotonicEndedAt = yield* Clock.currentTimeNanos;\n const durationMs = Math.max(0, Number(monotonicEndedAt - monotonicStartedAt) / 1000000);\n const cls = resolveSendFailureClass(failure, {\n experiment: deps.experimentClassifier,\n adapter: deps.classifier,\n });\n if (!cls.retryable)\n return yield* Effect.fail(attachFailureClass(failure, cls));\n if (sendAttempt + 1 >= SEND_MAX_ATTEMPTS) {\n return yield* Effect.fail(finalizeExhausted(failure, cls, \"send\"));\n }\n if (deps.budget.remaining <= 0) {\n return yield* Effect.fail(finalizeExhausted(failure, cls, \"attempt\"));\n }\n const jitter = yield* Random.next;\n const delayMs = BASE_DELAY_MS * 2 ** sendAttempt * jitter;\n yield* Effect.sync(() => {\n deps.onRetryAttempt?.({\n sendAttempt,\n startedAt: new Date(startedAtMs).toISOString(),\n durationMs,\n failure,\n classification: cls,\n });\n deps.budget.remaining -= 1;\n deps.reportRetry?.(t(\"session.turnRetry\", {\n attempt: sendAttempt + 2,\n maxAttempts: SEND_MAX_ATTEMPTS,\n reason: cls.reason,\n seconds: Math.round(delayMs / 1000),\n }));\n });\n yield* sleepWithReleasedSlot(deps.slot, retrySleep(deps.signal, delayMs));\n return yield* retry(sendAttempt + 1);\n })));\n });\n return retry(0);\n}\nfunction finalizeExhausted(failure: SendFailure, cls: Extract<FailureClass, {\n retryable: true;\n}>, layer: \"send\" | \"attempt\"): SendFailure {\n const suffix = layer === \"send\"\n ? t(\"session.turnRetrySendExhausted\", { maxAttempts: SEND_MAX_ATTEMPTS, reason: cls.reason })\n : t(\"session.turnRetryBudgetExhausted\", { maxRetries: ATTEMPT_MAX_RETRIES, reason: cls.reason });\n const wrapped = makeSendFailure({\n ...failure,\n message: sendFailureText(failure) + suffix,\n cause: normalizeExternalCause(failure),\n });\n return attachFailureClass(wrapped, cls);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"send-retry.js","sourceRoot":"","sources":["send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AAM,EAAE,GAAG,CAAC,MAAM;oBAClB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;iBACtC,CAAC,CAAC,CAAC;YACR,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;YAC1E,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AACD,SAAS,iBAAiB,CAAC,OAAoB,EAAE,GAE/C,EAAE,KAAyB;IACzB,MAAM,MAAM,GAAG,KAAK,KAAK,MAAM;QAC3B,CAAC,CAAC,IAAA,YAAC,EAAC,gCAAgC,EAAE,EAAE,WAAW,EAAE,yBAAiB,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;QAC7F,CAAC,CAAC,IAAA,YAAC,EAAC,kCAAkC,EAAE,EAAE,UAAU,EAAE,2BAAmB,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACrG,MAAM,OAAO,GAAG,IAAA,kCAAe,EAAC;QAC5B,GAAG,OAAO;QACV,OAAO,EAAE,IAAA,kCAAe,EAAC,OAAO,CAAC,GAAG,MAAM;QAC1C,KAAK,EAAE,IAAA,0CAAsB,EAAC,OAAO,CAAC;KACzC,CAAC,CAAC;IACH,OAAO,IAAA,qCAAkB,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// Agent send 的唯一重试执行体。正常返回的三种 Turn status 都原样交回;只有 reject 的\n// SendFailure 进入分类和重试(docs/feature/error-classification/architecture.md)。\nimport { Clock, Effect, Random } from \"effect\";\nimport { t } from \"../i18n/index.ts\";\nimport { attachFailureClass, type AttemptFailureClassifier, type FailureClass } from \"../shared/failure-class.ts\";\nimport { makeSendFailure, normalizeSendFailure, resolveSendFailureClass, sendFailureText, type SendFailure, type SendFailureClassifier, } from \"./send-failures.ts\";\nimport { normalizeExternalCause } from \"../shared/external-cause.ts\";\nexport const SEND_MAX_ATTEMPTS = 4;\nexport const ATTEMPT_MAX_RETRIES = 8;\nconst BASE_DELAY_MS = 5000;\nexport interface AttemptRetryBudget {\n remaining: number;\n}\nexport function createAttemptRetryBudget(): AttemptRetryBudget {\n return { remaining: ATTEMPT_MAX_RETRIES };\n}\nexport interface ConcurrencySlot {\n readonly release: Effect.Effect<void>;\n readonly reacquire: Effect.Effect<void>;\n}\nexport interface RetriedSendFailure {\n /** 同一逻辑 send 内从 0 开始的物理尝试序号。 */\n sendAttempt: number;\n startedAt: string;\n durationMs: number;\n failure: SendFailure;\n classification: Extract<FailureClass, {\n retryable: true;\n }>;\n}\nexport interface SendRetryDeps {\n classifier?: SendFailureClassifier;\n experimentClassifier?: AttemptFailureClassifier;\n /** 只回报被自动重试吸收的物理失败;终局失败由抛出值承载。 */\n onRetryAttempt?: (attempt: RetriedSendFailure) => void;\n budget: AttemptRetryBudget;\n slot?: ConcurrencySlot;\n reportRetry?: (message: string) => void;\n signal: AbortSignal;\n}\n/** Adapt the Attempt-owned AbortSignal into interruption, without turning it into a send failure. */\nfunction awaitAbort(signal: AbortSignal): Effect.Effect<void> {\n return Effect.async<void>((resume) => {\n if (signal.aborted) {\n resume(Effect.void);\n return;\n }\n const onAbort = () => resume(Effect.void);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n return Effect.sync(() => signal.removeEventListener(\"abort\", onAbort));\n });\n}\nfunction retrySleep(signal: AbortSignal, delayMs: number): Effect.Effect<void> {\n return Effect.raceFirst(Effect.sleep(delayMs).pipe(Effect.as(\"delay\" as const)), awaitAbort(signal).pipe(Effect.as(\"aborted\" as const))).pipe(Effect.flatMap((winner) => winner === \"aborted\" ? Effect.interrupt : Effect.void));\n}\n/**\n * A retried Attempt gives its global slot back while waiting. acquireUseRelease\n * registers reacquire before entering the interruptible sleep, so interruption\n * cannot permanently shrink available capacity.\n */\nfunction sleepWithReleasedSlot(slot: ConcurrencySlot | undefined, sleep: Effect.Effect<void, unknown>): Effect.Effect<void, unknown> {\n if (slot === undefined)\n return sleep;\n return Effect.acquireUseRelease(Effect.suspend(() => slot.release), () => sleep, () => Effect.suspend(() => slot.reacquire));\n}\n/**\n * 对同一个物理输入至多调用四次。adapter 未使用 makeSendFailure 而直接抛出的值在这里\n * 保守归一为 acceptance=unknown,因此会得到稳定 agent-send-failed,而不会被误重发。\n */\nexport function sendWithTurnRetry<T>(callOnce: Effect.Effect<T, unknown>, deps: SendRetryDeps): Effect.Effect<T, unknown> {\n const retry = (sendAttempt: number): Effect.Effect<T, unknown> => Effect.gen(function* () {\n const startedAtMs = yield* Clock.currentTimeMillis;\n const monotonicStartedAt = yield* Clock.currentTimeNanos;\n return yield* callOnce.pipe(Effect.mapError(normalizeSendFailure), Effect.catchAll((failure) => Effect.gen(function* () {\n const monotonicEndedAt = yield* Clock.currentTimeNanos;\n const durationMs = Math.max(0, Number(monotonicEndedAt - monotonicStartedAt) / 1000000);\n const cls = resolveSendFailureClass(failure, {\n experiment: deps.experimentClassifier,\n adapter: deps.classifier,\n });\n if (!cls.retryable)\n return yield* Effect.fail(attachFailureClass(failure, cls));\n if (sendAttempt + 1 >= SEND_MAX_ATTEMPTS) {\n return yield* Effect.fail(finalizeExhausted(failure, cls, \"send\"));\n }\n if (deps.budget.remaining <= 0) {\n return yield* Effect.fail(finalizeExhausted(failure, cls, \"attempt\"));\n }\n const jitter = yield* Random.next;\n const delayMs = BASE_DELAY_MS * 2 ** sendAttempt * jitter;\n yield* Effect.sync(() => {\n deps.onRetryAttempt?.({\n sendAttempt,\n startedAt: new Date(startedAtMs).toISOString(),\n durationMs,\n failure,\n classification: cls,\n });\n deps.budget.remaining -= 1;\n deps.reportRetry?.(t(\"session.turnRetry\", {\n attempt: sendAttempt + 2,\n maxAttempts: SEND_MAX_ATTEMPTS,\n reason: cls.reason,\n seconds: Math.round(delayMs / 1000),\n }));\n });\n yield* sleepWithReleasedSlot(deps.slot, retrySleep(deps.signal, delayMs));\n return yield* retry(sendAttempt + 1);\n })));\n });\n return retry(0);\n}\nfunction finalizeExhausted(failure: SendFailure, cls: Extract<FailureClass, {\n retryable: true;\n}>, layer: \"send\" | \"attempt\"): SendFailure {\n const suffix = layer === \"send\"\n ? t(\"session.turnRetrySendExhausted\", { maxAttempts: SEND_MAX_ATTEMPTS, reason: cls.reason })\n : t(\"session.turnRetryBudgetExhausted\", { maxRetries: ATTEMPT_MAX_RETRIES, reason: cls.reason });\n const wrapped = makeSendFailure({\n ...failure,\n message: sendFailureText(failure) + suffix,\n cause: normalizeExternalCause(failure),\n });\n return attachFailureClass(wrapped, cls);\n}\n"]}
|
|
@@ -5,44 +5,22 @@ exports.claimExecution = claimExecution;
|
|
|
5
5
|
const effect_1 = require("effect");
|
|
6
6
|
const node_os_1 = require("node:os");
|
|
7
7
|
const lock_ts_1 = require("../../runner/lock.cjs");
|
|
8
|
-
const gate_lease_ts_1 = require("../../runner/gate-lease.cjs");
|
|
9
8
|
const record_leases_ts_1 = require("../record-leases.cjs");
|
|
10
9
|
/**
|
|
11
|
-
* Compose the existing case
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Compose the existing case-lock primitive into one named Coordination operation.
|
|
11
|
+
* The underlying algorithm remains the single source of truth; this facade only
|
|
12
|
+
* gives its lifecycle a host name.
|
|
14
13
|
*/
|
|
15
14
|
function claimExecution(request) {
|
|
16
15
|
const identity = request.identity ?? Object.freeze({ pid: process.pid, host: (0, node_os_1.hostname)() });
|
|
17
16
|
return effect_1.Effect.uninterruptibleMask((restore) => restore((0, lock_ts_1.acquireCaseLockEffect)(request.localRoot, request.experimentId, request.evalId, identity, {
|
|
18
17
|
...(request.signal === undefined ? {} : { signal: request.signal }),
|
|
19
18
|
...(request.onCaseWait === undefined ? {} : { onWaitStart: request.onCaseWait }),
|
|
20
|
-
})).pipe(effect_1.Effect.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (request.maxConcurrency === undefined) {
|
|
26
|
-
return effect_1.Effect.succeed(Object.freeze({
|
|
27
|
-
...base,
|
|
28
|
-
release: caseResult.claim.release,
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
return restore((0, gate_lease_ts_1.acquireGateSlotEffect)(request.localRoot, request.experimentId, request.maxConcurrency, identity, {
|
|
32
|
-
...(request.signal === undefined ? {} : { signal: request.signal }),
|
|
33
|
-
...(request.onGateWait === undefined ? {} : { onWaitStart: request.onGateWait }),
|
|
34
|
-
})).pipe(
|
|
35
|
-
// A typed failure, defect, or interruption while waiting for the
|
|
36
|
-
// gate must not strand the case claim acquired immediately before it.
|
|
37
|
-
effect_1.Effect.onExit((exit) => effect_1.Exit.isSuccess(exit)
|
|
38
|
-
? effect_1.Effect.void
|
|
39
|
-
: caseResult.claim.release.pipe(effect_1.Effect.ignore)), effect_1.Effect.map((gateResult) => Object.freeze({
|
|
40
|
-
...base,
|
|
41
|
-
gateClaim: gateResult.claim,
|
|
42
|
-
...(gateResult.takenOver ? { gateTakenOver: true } : {}),
|
|
43
|
-
release: gateResult.claim.release.pipe(effect_1.Effect.ensuring(caseResult.claim.release.pipe(effect_1.Effect.ignore))),
|
|
44
|
-
})));
|
|
45
|
-
})));
|
|
19
|
+
})).pipe(effect_1.Effect.map((caseResult) => Object.freeze({
|
|
20
|
+
caseClaim: caseResult.claim,
|
|
21
|
+
caseTakenOver: caseResult.takenOver,
|
|
22
|
+
release: caseResult.claim.release,
|
|
23
|
+
}))));
|
|
46
24
|
}
|
|
47
25
|
/**
|
|
48
26
|
* The host facade exposes names, not a generic lock primitive. Each acquired
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["runtime.ts"],"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,EAAE,EAAE,CAAC,eAAM,CAAC,OAAO,CAAC,qCAAkB,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/H,iBAAiB,EAAE,CAAC,IAAgB,EAAE,EAAE,CAAC,eAAM,CAAC,OAAO,CAAC,qCAAkB,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACnI,sBAAsB,EAAE,CAAC,IAAgB,EAAE,EAAE,CAAC,eAAM,CAAC,OAAO,CAAC,qCAAkB,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;CAChJ,CAAC,CAAC","sourcesContent":["import { Effect } from \"effect\";\nimport { hostname } from \"node:os\";\nimport type { RecordRoot } from \"../../record/platform/root.ts\";\nimport { acquireCaseLockEffect, } from \"../../runner/lock.ts\";\nimport { RecordCoordination } from \"../record-leases.ts\";\nimport type { ClaimExecutionRequest, CoordinationHostSDK, ExecutionClaim, } from \"./types.ts\";\n/**\n * Compose the existing case-lock primitive into one named Coordination operation.\n * The underlying algorithm remains the single source of truth; this facade only\n * gives its lifecycle a host name.\n */\nexport function claimExecution(request: ClaimExecutionRequest): Effect.Effect<ExecutionClaim, unknown> {\n const identity = request.identity ?? Object.freeze({ pid: process.pid, host: hostname() });\n return Effect.uninterruptibleMask((restore) => restore(acquireCaseLockEffect(request.localRoot, request.experimentId, request.evalId, identity, {\n ...(request.signal === undefined ? {} : { signal: request.signal }),\n ...(request.onCaseWait === undefined ? {} : { onWaitStart: request.onCaseWait }),\n })).pipe(Effect.map((caseResult) => Object.freeze({\n caseClaim: caseResult.claim,\n caseTakenOver: caseResult.takenOver,\n release: caseResult.claim.release,\n }))));\n}\n/**\n * The host facade exposes names, not a generic lock primitive. Each acquired\n * lease is registered in the caller's Scope by the Coordination service.\n */\nexport const coordinationHost: CoordinationHostSDK = Object.freeze({\n claimExecution,\n enterRecordRead: (root: RecordRoot) => Effect.flatMap(RecordCoordination, (coordination) => coordination.enterRecordRead(root)),\n enterRecordAppend: (root: RecordRoot) => Effect.flatMap(RecordCoordination, (coordination) => coordination.enterRecordAppend(root)),\n enterRecordMaintenance: (root: RecordRoot) => Effect.flatMap(RecordCoordination, (coordination) => coordination.enterRecordMaintenance(root)),\n});\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { ClaimExecutionRequest, CoordinationHostSDK, ExecutionClaim } from "./types.cjs";
|
|
3
3
|
/**
|
|
4
|
-
* Compose the existing case
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Compose the existing case-lock primitive into one named Coordination operation.
|
|
5
|
+
* The underlying algorithm remains the single source of truth; this facade only
|
|
6
|
+
* gives its lifecycle a host name.
|
|
7
7
|
*/
|
|
8
8
|
export declare function claimExecution(request: ClaimExecutionRequest): Effect.Effect<ExecutionClaim, unknown>;
|
|
9
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { ClaimExecutionRequest, CoordinationHostSDK, ExecutionClaim } from "./types.mjs";
|
|
3
3
|
/**
|
|
4
|
-
* Compose the existing case
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Compose the existing case-lock primitive into one named Coordination operation.
|
|
5
|
+
* The underlying algorithm remains the single source of truth; this facade only
|
|
6
|
+
* gives its lifecycle a host name.
|
|
7
7
|
*/
|
|
8
8
|
export declare function claimExecution(request: ClaimExecutionRequest): Effect.Effect<ExecutionClaim, unknown>;
|
|
9
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { ClaimExecutionRequest, CoordinationHostSDK, ExecutionClaim } from "./types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Compose the existing case
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Compose the existing case-lock primitive into one named Coordination operation.
|
|
5
|
+
* The underlying algorithm remains the single source of truth; this facade only
|
|
6
|
+
* gives its lifecycle a host name.
|
|
7
7
|
*/
|
|
8
8
|
export declare function claimExecution(request: ClaimExecutionRequest): Effect.Effect<ExecutionClaim, unknown>;
|
|
9
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Effect } from \"effect\";\nimport type { RecordRoot } from \"../../record/platform/root.ts\";\nimport type { CaseLockEffectClaim, CaseLockRecord, } from \"../../runner/lock.ts\";\nimport type {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Effect } from \"effect\";\nimport type { RecordRoot } from \"../../record/platform/root.ts\";\nimport type { CaseLockEffectClaim, CaseLockRecord, } from \"../../runner/lock.ts\";\nimport type { RecordCoordination, RecordCoordinationError, RecordLease, } from \"../record-leases.ts\";\n/**\n * One short-lived execution claim. It owns only local scheduling state and\n * never grants access to a portable Record writer.\n */\nexport interface ExecutionClaim {\n readonly caseClaim: CaseLockEffectClaim;\n readonly caseTakenOver: boolean;\n readonly release: Effect.Effect<void, unknown>;\n}\n/** Input is rooted in project-local `.niceeval`, never in the portable Record root. */\nexport interface ClaimExecutionRequest {\n readonly localRoot: string;\n readonly experimentId: string;\n readonly evalId: string;\n readonly identity?: {\n readonly pid: number;\n readonly host: string;\n };\n readonly signal?: AbortSignal;\n readonly onCaseWait?: (holder: CaseLockRecord) => void;\n}\n/** Narrow coordination operations shared by the Record and command hosts. */\nexport interface CoordinationHostSDK {\n readonly claimExecution: (request: ClaimExecutionRequest) => Effect.Effect<ExecutionClaim, unknown>;\n readonly enterRecordRead: (root: RecordRoot) => Effect.Effect<RecordLease, RecordCoordinationError, import(\"effect\").Scope.Scope | RecordCoordination>;\n readonly enterRecordAppend: (root: RecordRoot) => Effect.Effect<RecordLease, RecordCoordinationError, import(\"effect\").Scope.Scope | RecordCoordination>;\n readonly enterRecordMaintenance: (root: RecordRoot) => Effect.Effect<RecordLease, RecordCoordinationError, import(\"effect\").Scope.Scope | RecordCoordination>;\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Effect } from "effect";
|
|
2
2
|
import type { RecordRoot } from "../../record/platform/root.cjs";
|
|
3
3
|
import type { CaseLockEffectClaim, CaseLockRecord } from "../../runner/lock.cjs";
|
|
4
|
-
import type { GateLeaseEffectClaim, GateLeaseRecord } from "../../runner/gate-lease.cjs";
|
|
5
4
|
import type { RecordCoordination, RecordCoordinationError, RecordLease } from "../record-leases.cjs";
|
|
6
5
|
/**
|
|
7
6
|
* One short-lived execution claim. It owns only local scheduling state and
|
|
@@ -9,9 +8,7 @@ import type { RecordCoordination, RecordCoordinationError, RecordLease } from ".
|
|
|
9
8
|
*/
|
|
10
9
|
export interface ExecutionClaim {
|
|
11
10
|
readonly caseClaim: CaseLockEffectClaim;
|
|
12
|
-
readonly gateClaim?: GateLeaseEffectClaim;
|
|
13
11
|
readonly caseTakenOver: boolean;
|
|
14
|
-
readonly gateTakenOver?: boolean;
|
|
15
12
|
readonly release: Effect.Effect<void, unknown>;
|
|
16
13
|
}
|
|
17
14
|
/** Input is rooted in project-local `.niceeval`, never in the portable Record root. */
|
|
@@ -19,14 +16,12 @@ export interface ClaimExecutionRequest {
|
|
|
19
16
|
readonly localRoot: string;
|
|
20
17
|
readonly experimentId: string;
|
|
21
18
|
readonly evalId: string;
|
|
22
|
-
readonly maxConcurrency?: number;
|
|
23
19
|
readonly identity?: {
|
|
24
20
|
readonly pid: number;
|
|
25
21
|
readonly host: string;
|
|
26
22
|
};
|
|
27
23
|
readonly signal?: AbortSignal;
|
|
28
24
|
readonly onCaseWait?: (holder: CaseLockRecord) => void;
|
|
29
|
-
readonly onGateWait?: (holders: readonly GateLeaseRecord[]) => void;
|
|
30
25
|
}
|
|
31
26
|
/** Narrow coordination operations shared by the Record and command hosts. */
|
|
32
27
|
export interface CoordinationHostSDK {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Effect } from "effect";
|
|
2
2
|
import type { RecordRoot } from "../../record/platform/root.mjs";
|
|
3
3
|
import type { CaseLockEffectClaim, CaseLockRecord } from "../../runner/lock.mjs";
|
|
4
|
-
import type { GateLeaseEffectClaim, GateLeaseRecord } from "../../runner/gate-lease.mjs";
|
|
5
4
|
import type { RecordCoordination, RecordCoordinationError, RecordLease } from "../record-leases.mjs";
|
|
6
5
|
/**
|
|
7
6
|
* One short-lived execution claim. It owns only local scheduling state and
|
|
@@ -9,9 +8,7 @@ import type { RecordCoordination, RecordCoordinationError, RecordLease } from ".
|
|
|
9
8
|
*/
|
|
10
9
|
export interface ExecutionClaim {
|
|
11
10
|
readonly caseClaim: CaseLockEffectClaim;
|
|
12
|
-
readonly gateClaim?: GateLeaseEffectClaim;
|
|
13
11
|
readonly caseTakenOver: boolean;
|
|
14
|
-
readonly gateTakenOver?: boolean;
|
|
15
12
|
readonly release: Effect.Effect<void, unknown>;
|
|
16
13
|
}
|
|
17
14
|
/** Input is rooted in project-local `.niceeval`, never in the portable Record root. */
|
|
@@ -19,14 +16,12 @@ export interface ClaimExecutionRequest {
|
|
|
19
16
|
readonly localRoot: string;
|
|
20
17
|
readonly experimentId: string;
|
|
21
18
|
readonly evalId: string;
|
|
22
|
-
readonly maxConcurrency?: number;
|
|
23
19
|
readonly identity?: {
|
|
24
20
|
readonly pid: number;
|
|
25
21
|
readonly host: string;
|
|
26
22
|
};
|
|
27
23
|
readonly signal?: AbortSignal;
|
|
28
24
|
readonly onCaseWait?: (holder: CaseLockRecord) => void;
|
|
29
|
-
readonly onGateWait?: (holders: readonly GateLeaseRecord[]) => void;
|
|
30
25
|
}
|
|
31
26
|
/** Narrow coordination operations shared by the Record and command hosts. */
|
|
32
27
|
export interface CoordinationHostSDK {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Effect } from "effect";
|
|
2
2
|
import type { RecordRoot } from "../../record/platform/root.js";
|
|
3
3
|
import type { CaseLockEffectClaim, CaseLockRecord } from "../../runner/lock.js";
|
|
4
|
-
import type { GateLeaseEffectClaim, GateLeaseRecord } from "../../runner/gate-lease.js";
|
|
5
4
|
import type { RecordCoordination, RecordCoordinationError, RecordLease } from "../record-leases.js";
|
|
6
5
|
/**
|
|
7
6
|
* One short-lived execution claim. It owns only local scheduling state and
|
|
@@ -9,9 +8,7 @@ import type { RecordCoordination, RecordCoordinationError, RecordLease } from ".
|
|
|
9
8
|
*/
|
|
10
9
|
export interface ExecutionClaim {
|
|
11
10
|
readonly caseClaim: CaseLockEffectClaim;
|
|
12
|
-
readonly gateClaim?: GateLeaseEffectClaim;
|
|
13
11
|
readonly caseTakenOver: boolean;
|
|
14
|
-
readonly gateTakenOver?: boolean;
|
|
15
12
|
readonly release: Effect.Effect<void, unknown>;
|
|
16
13
|
}
|
|
17
14
|
/** Input is rooted in project-local `.niceeval`, never in the portable Record root. */
|
|
@@ -19,14 +16,12 @@ export interface ClaimExecutionRequest {
|
|
|
19
16
|
readonly localRoot: string;
|
|
20
17
|
readonly experimentId: string;
|
|
21
18
|
readonly evalId: string;
|
|
22
|
-
readonly maxConcurrency?: number;
|
|
23
19
|
readonly identity?: {
|
|
24
20
|
readonly pid: number;
|
|
25
21
|
readonly host: string;
|
|
26
22
|
};
|
|
27
23
|
readonly signal?: AbortSignal;
|
|
28
24
|
readonly onCaseWait?: (holder: CaseLockRecord) => void;
|
|
29
|
-
readonly onGateWait?: (holders: readonly GateLeaseRecord[]) => void;
|
|
30
25
|
}
|
|
31
26
|
/** Narrow coordination operations shared by the Record and command hosts. */
|
|
32
27
|
export interface CoordinationHostSDK {
|
|
@@ -11,6 +11,7 @@ const identity_ts_1 = require("../identity.cjs");
|
|
|
11
11
|
const record_leases_ts_1 = require("../record-leases.cjs");
|
|
12
12
|
const textEncoder = new TextEncoder();
|
|
13
13
|
const leases = new WeakMap();
|
|
14
|
+
const MAXIMUM_LEASE_PAYLOAD_BYTES = 4096;
|
|
14
15
|
function errorCode(cause) {
|
|
15
16
|
return typeof cause === "object" && cause !== null && "code" in cause &&
|
|
16
17
|
typeof cause.code === "string"
|
|
@@ -112,6 +113,65 @@ function leasePayload(kind) {
|
|
|
112
113
|
nonce: (0, node_crypto_1.randomUUID)(),
|
|
113
114
|
}));
|
|
114
115
|
}
|
|
116
|
+
function decodeLeasePayload(value) {
|
|
117
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
118
|
+
return undefined;
|
|
119
|
+
if (Object.keys(value).length !== 5 ||
|
|
120
|
+
Reflect.get(value, "version") !== 1 ||
|
|
121
|
+
(Reflect.get(value, "kind") !== "read" &&
|
|
122
|
+
Reflect.get(value, "kind") !== "append" &&
|
|
123
|
+
Reflect.get(value, "kind") !== "maintenance") ||
|
|
124
|
+
typeof Reflect.get(value, "host") !== "string" ||
|
|
125
|
+
typeof Reflect.get(value, "pid") !== "number" ||
|
|
126
|
+
!Number.isSafeInteger(Reflect.get(value, "pid")) ||
|
|
127
|
+
Reflect.get(value, "pid") <= 0 ||
|
|
128
|
+
typeof Reflect.get(value, "nonce") !== "string" ||
|
|
129
|
+
Reflect.get(value, "nonce").length === 0)
|
|
130
|
+
return undefined;
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
/** Only ESRCH proves that a same-host lease owner no longer exists. */
|
|
134
|
+
function ownerIsKnownDead(payload) {
|
|
135
|
+
if (payload.host !== (0, node_os_1.hostname)())
|
|
136
|
+
return false;
|
|
137
|
+
try {
|
|
138
|
+
process.kill(payload.pid, 0);
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
catch (cause) {
|
|
142
|
+
return errorCode(cause) === "ESRCH";
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function sharedLeaseIsKnownStale(path, expectedKind) {
|
|
146
|
+
return effect_1.Effect.gen(function* () {
|
|
147
|
+
const metadata = yield* nodeIo({
|
|
148
|
+
operation: "read-file",
|
|
149
|
+
path,
|
|
150
|
+
run: () => (0, promises_1.lstat)(path),
|
|
151
|
+
}).pipe(effect_1.Effect.catchAll((error) => isMissing(error.cause) ? effect_1.Effect.succeed(undefined) : effect_1.Effect.fail(error)));
|
|
152
|
+
if (metadata === undefined)
|
|
153
|
+
return true;
|
|
154
|
+
if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size > MAXIMUM_LEASE_PAYLOAD_BYTES) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const bytes = yield* nodeIo({
|
|
158
|
+
operation: "read-file",
|
|
159
|
+
path,
|
|
160
|
+
run: () => (0, promises_1.readFile)(path),
|
|
161
|
+
}).pipe(effect_1.Effect.catchAll((error) => isMissing(error.cause) ? effect_1.Effect.succeed(undefined) : effect_1.Effect.fail(error)));
|
|
162
|
+
if (bytes === undefined)
|
|
163
|
+
return true;
|
|
164
|
+
let value;
|
|
165
|
+
try {
|
|
166
|
+
value = JSON.parse(bytes.toString("utf8"));
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
const payload = decodeLeasePayload(value);
|
|
172
|
+
return payload !== undefined && payload.kind === expectedKind && ownerIsKnownDead(payload);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
115
175
|
function makeLease(kind, path) {
|
|
116
176
|
const lease = (0, record_leases_ts_1.issueRecordLease)(kind);
|
|
117
177
|
leases.set(lease, path);
|
|
@@ -120,13 +180,32 @@ function makeLease(kind, path) {
|
|
|
120
180
|
function sharedDirectory(layout, kind) {
|
|
121
181
|
return kind === "read" ? layout.readDirectory : layout.appendDirectory;
|
|
122
182
|
}
|
|
123
|
-
function
|
|
124
|
-
const directories = [
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
183
|
+
function liveSharedEntriesPresent(layout) {
|
|
184
|
+
const directories = [
|
|
185
|
+
{ path: layout.readDirectory, kind: "read" },
|
|
186
|
+
{ path: layout.appendDirectory, kind: "append" },
|
|
187
|
+
];
|
|
188
|
+
return effect_1.Effect.gen(function* () {
|
|
189
|
+
let occupied = false;
|
|
190
|
+
for (const directory of directories) {
|
|
191
|
+
yield* ensureDirectory(directory.path);
|
|
192
|
+
const entries = yield* nodeIo({
|
|
193
|
+
operation: "list-directory",
|
|
194
|
+
path: directory.path,
|
|
195
|
+
run: () => (0, promises_1.readdir)(directory.path),
|
|
196
|
+
});
|
|
197
|
+
for (const entry of entries) {
|
|
198
|
+
const path = (0, node_path_1.join)(directory.path, entry);
|
|
199
|
+
if (yield* sharedLeaseIsKnownStale(path, directory.kind)) {
|
|
200
|
+
yield* removeFileIfPresent(path);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
occupied = true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return occupied;
|
|
208
|
+
});
|
|
130
209
|
}
|
|
131
210
|
function maintenanceBusy(requested) {
|
|
132
211
|
return new errors_ts_1.RecordMaintenanceBusy({ code: "record-maintenance-busy", requested });
|
|
@@ -149,7 +228,8 @@ function enterSharedLease(root, kind) {
|
|
|
149
228
|
if (!created) {
|
|
150
229
|
return yield* effect_1.Effect.fail(maintenanceBusy("shared"));
|
|
151
230
|
}
|
|
152
|
-
|
|
231
|
+
const maintenancePresent = yield* pathPresent(layout.maintenanceFile).pipe(effect_1.Effect.tapError(() => removeFileIfPresent(path).pipe(effect_1.Effect.orDie)));
|
|
232
|
+
if (maintenancePresent) {
|
|
153
233
|
yield* removeFileIfPresent(path);
|
|
154
234
|
return yield* effect_1.Effect.fail(maintenanceBusy("shared"));
|
|
155
235
|
}
|
|
@@ -169,7 +249,8 @@ function enterMaintenanceLease(root) {
|
|
|
169
249
|
if (!created) {
|
|
170
250
|
return yield* effect_1.Effect.fail(maintenanceBusy("exclusive"));
|
|
171
251
|
}
|
|
172
|
-
|
|
252
|
+
const sharedPresent = yield* liveSharedEntriesPresent(layout).pipe(effect_1.Effect.tapError(() => removeFileIfPresent(layout.maintenanceFile).pipe(effect_1.Effect.orDie)));
|
|
253
|
+
if (sharedPresent) {
|
|
173
254
|
yield* removeFileIfPresent(layout.maintenanceFile);
|
|
174
255
|
return yield* effect_1.Effect.fail(maintenanceBusy("exclusive"));
|
|
175
256
|
}
|