@bjoernrochel/sevro 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +34 -4
- package/README.md +7 -6
- package/dist/examples/basic/graded.json +13 -0
- package/dist/examples/basic/host.js +9 -0
- package/dist/examples/basic/host.js.map +1 -0
- package/dist/examples/basic/prompt-only.json +7 -0
- package/dist/examples/recipes/candidate.js +23 -0
- package/dist/examples/recipes/candidate.js.map +1 -0
- package/dist/examples/recipes/cases/coding-change.json +21 -0
- package/dist/examples/recipes/cases/host-tools.json +21 -0
- package/dist/examples/recipes/cases/mise.json +21 -0
- package/dist/examples/recipes/cases/node.json +21 -0
- package/dist/examples/recipes/cases/python-uv.json +21 -0
- package/dist/examples/recipes/cases/semantic.json +17 -0
- package/dist/examples/recipes/coding-change/check.js +16 -0
- package/dist/examples/recipes/coding-change/check.js.map +1 -0
- package/dist/examples/recipes/executable.js +20 -0
- package/dist/examples/recipes/executable.js.map +1 -0
- package/dist/examples/recipes/extension-artifacts.js +56 -0
- package/dist/examples/recipes/extension-artifacts.js.map +1 -0
- package/dist/examples/recipes/extension-methods.js +167 -0
- package/dist/examples/recipes/extension-methods.js.map +1 -0
- package/dist/examples/recipes/extension.js +28 -0
- package/dist/examples/recipes/extension.js.map +1 -0
- package/dist/examples/recipes/modules.js +9 -0
- package/dist/examples/recipes/modules.js.map +1 -0
- package/dist/examples/recipes/repository-skill/.agents/skills/startup-guide/SKILL.md +7 -0
- package/dist/examples/recipes/repository-skill/.claude/skills/startup-guide/SKILL.md +7 -0
- package/dist/examples/recipes/repository-skill/README.md +3 -0
- package/dist/examples/recipes/run-inputs.js +144 -0
- package/dist/examples/recipes/run-inputs.js.map +1 -0
- package/dist/examples/recipes/run-options.js +103 -0
- package/dist/examples/recipes/run-options.js.map +1 -0
- package/dist/examples/recipes/run.js +62 -0
- package/dist/examples/recipes/run.js.map +1 -0
- package/dist/examples/recipes/runtime/empty.json +1 -0
- package/dist/examples/recipes/runtime/goals.json +1 -0
- package/dist/examples/recipes/runtime/mise.json +6 -0
- package/dist/examples/recipes/runtime/path.json +1 -0
- package/dist/examples/recipes/runtime/plugins.json +4 -0
- package/dist/examples/recipes/runtime/python-uv.json +10 -0
- package/dist/examples/recipes/semantic-judge.js +27 -0
- package/dist/examples/recipes/semantic-judge.js.map +1 -0
- package/dist/examples/templates/coding/adapter.js +14 -0
- package/dist/examples/templates/coding/adapter.js.map +1 -0
- package/dist/examples/templates/coding/case.json +15 -0
- package/dist/examples/templates/repository-skill/.agents/skills/startup-guide/SKILL.md +6 -0
- package/dist/examples/templates/repository-skill/extension-data.js +61 -0
- package/dist/examples/templates/repository-skill/extension-data.js.map +1 -0
- package/dist/examples/templates/repository-skill/extension.js +29 -0
- package/dist/examples/templates/repository-skill/extension.js.map +1 -0
- package/dist/examples/templates/response/adapter.js +13 -0
- package/dist/examples/templates/response/adapter.js.map +1 -0
- package/dist/examples/templates/response/case.json +13 -0
- package/dist/src/advisory.js +86 -0
- package/dist/src/advisory.js.map +1 -0
- package/dist/src/candidate-artifacts.js +139 -0
- package/dist/src/candidate-artifacts.js.map +1 -0
- package/dist/src/candidate-codex-state.js +110 -0
- package/dist/src/candidate-codex-state.js.map +1 -0
- package/dist/src/case-validation.js +92 -0
- package/dist/src/case-validation.js.map +1 -0
- package/dist/src/cli/cancellation.js +21 -0
- package/dist/src/cli/cancellation.js.map +1 -0
- package/dist/src/cli/command.js +60 -0
- package/dist/src/cli/command.js.map +1 -0
- package/dist/src/cli/completion.js +14 -0
- package/dist/src/cli/completion.js.map +1 -0
- package/dist/src/cli/demo.js +45 -0
- package/dist/src/cli/demo.js.map +1 -0
- package/dist/src/cli/evaluation.js +40 -0
- package/dist/src/cli/evaluation.js.map +1 -0
- package/dist/src/cli/extension.js +54 -0
- package/dist/src/cli/extension.js.map +1 -0
- package/dist/src/cli/help.js +190 -0
- package/dist/src/cli/help.js.map +1 -0
- package/dist/src/cli/hosts.js +33 -0
- package/dist/src/cli/hosts.js.map +1 -0
- package/dist/src/cli/init-settings.js +29 -0
- package/dist/src/cli/init-settings.js.map +1 -0
- package/dist/src/cli/init.js +82 -0
- package/dist/src/cli/init.js.map +1 -0
- package/dist/src/cli/invocation.js +431 -0
- package/dist/src/cli/invocation.js.map +1 -0
- package/dist/src/cli/loading.js +110 -0
- package/dist/src/cli/loading.js.map +1 -0
- package/dist/src/cli/preparation.js +88 -0
- package/dist/src/cli/preparation.js.map +1 -0
- package/dist/src/cli/presentation.js +61 -0
- package/dist/src/cli/presentation.js.map +1 -0
- package/dist/src/cli/progress.js +5 -0
- package/dist/src/cli/progress.js.map +1 -0
- package/dist/src/cli/run-manifest.js +108 -0
- package/dist/src/cli/run-manifest.js.map +1 -0
- package/dist/src/cli/run-options.js +367 -0
- package/dist/src/cli/run-options.js.map +1 -0
- package/dist/src/cli/run-overrides.js +51 -0
- package/dist/src/cli/run-overrides.js.map +1 -0
- package/dist/src/cli/settings.js +127 -0
- package/dist/src/cli/settings.js.map +1 -0
- package/dist/src/cli/summary.js +28 -0
- package/dist/src/cli/summary.js.map +1 -0
- package/dist/src/cli.js +20 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/contract-types.js +2 -0
- package/dist/src/contract-types.js.map +1 -0
- package/dist/src/engine.js +4 -0
- package/dist/src/engine.js.map +1 -0
- package/dist/src/evaluation/advisory.js +85 -0
- package/dist/src/evaluation/advisory.js.map +1 -0
- package/dist/src/evaluation/check-plan.js +292 -0
- package/dist/src/evaluation/check-plan.js.map +1 -0
- package/dist/src/evaluation/collection.js +61 -0
- package/dist/src/evaluation/collection.js.map +1 -0
- package/dist/src/evaluation/context.js +2 -0
- package/dist/src/evaluation/context.js.map +1 -0
- package/dist/src/evaluation/grading-host.js +28 -0
- package/dist/src/evaluation/grading-host.js.map +1 -0
- package/dist/src/evaluation/grading.js +154 -0
- package/dist/src/evaluation/grading.js.map +1 -0
- package/dist/src/evaluation/invocation-plan.js +312 -0
- package/dist/src/evaluation/invocation-plan.js.map +1 -0
- package/dist/src/evaluation/plan.js +376 -0
- package/dist/src/evaluation/plan.js.map +1 -0
- package/dist/src/evaluation/progress.js +14 -0
- package/dist/src/evaluation/progress.js.map +1 -0
- package/dist/src/evaluation/resources.js +159 -0
- package/dist/src/evaluation/resources.js.map +1 -0
- package/dist/src/evaluation/run.js +148 -0
- package/dist/src/evaluation/run.js.map +1 -0
- package/dist/src/evaluation/scheduler.js +27 -0
- package/dist/src/evaluation/scheduler.js.map +1 -0
- package/dist/src/evaluation/semantic.js +183 -0
- package/dist/src/evaluation/semantic.js.map +1 -0
- package/dist/src/evaluation/trial.js +593 -0
- package/dist/src/evaluation/trial.js.map +1 -0
- package/dist/src/evaluation/types.js +20 -0
- package/dist/src/evaluation/types.js.map +1 -0
- package/dist/src/evidence/host-results.js +67 -0
- package/dist/src/evidence/host-results.js.map +1 -0
- package/dist/src/evidence/retained-artifacts.js +17 -0
- package/dist/src/evidence/retained-artifacts.js.map +1 -0
- package/dist/src/evidence/trial-writer.js +131 -0
- package/dist/src/evidence/trial-writer.js.map +1 -0
- package/dist/src/evidence/usage.js +14 -0
- package/dist/src/evidence/usage.js.map +1 -0
- package/dist/src/executable.js +20 -0
- package/dist/src/executable.js.map +1 -0
- package/dist/src/extension-client.js +212 -0
- package/dist/src/extension-client.js.map +1 -0
- package/dist/src/extension-session.js +236 -0
- package/dist/src/extension-session.js.map +1 -0
- package/dist/src/fixtures/advisory.js +206 -0
- package/dist/src/fixtures/advisory.js.map +1 -0
- package/dist/src/fixtures/bin.js +41 -0
- package/dist/src/fixtures/bin.js.map +1 -0
- package/dist/src/fixtures/cleanup.js +43 -0
- package/dist/src/fixtures/cleanup.js.map +1 -0
- package/dist/src/fixtures/create.js +94 -0
- package/dist/src/fixtures/create.js.map +1 -0
- package/dist/src/fixtures/generated.js +181 -0
- package/dist/src/fixtures/generated.js.map +1 -0
- package/dist/src/fixtures/git-hooks.js +16 -0
- package/dist/src/fixtures/git-hooks.js.map +1 -0
- package/dist/src/fixtures/preparation.js +201 -0
- package/dist/src/fixtures/preparation.js.map +1 -0
- package/dist/src/fixtures/repository.js +255 -0
- package/dist/src/fixtures/repository.js.map +1 -0
- package/dist/src/fixtures/setup.js +175 -0
- package/dist/src/fixtures/setup.js.map +1 -0
- package/dist/src/fixtures/tools.js +57 -0
- package/dist/src/fixtures/tools.js.map +1 -0
- package/dist/src/fixtures/workspace-state.js +155 -0
- package/dist/src/fixtures/workspace-state.js.map +1 -0
- package/dist/src/generated/cli-result.cjs +2 -0
- package/dist/src/generated/extension.cjs +2 -0
- package/dist/src/generated/report.cjs +2 -0
- package/dist/src/generated/run-evidence.cjs +2 -0
- package/dist/src/generated/runtime.cjs +2 -0
- package/dist/src/git.js +72 -0
- package/dist/src/git.js.map +1 -0
- package/dist/src/graders/artifact.js +68 -0
- package/dist/src/graders/artifact.js.map +1 -0
- package/dist/src/graders/git-head.js +112 -0
- package/dist/src/graders/git-head.js.map +1 -0
- package/dist/src/graders/output.js +345 -0
- package/dist/src/graders/output.js.map +1 -0
- package/dist/src/graders/semantic.js +132 -0
- package/dist/src/graders/semantic.js.map +1 -0
- package/dist/src/graders/shell.js +321 -0
- package/dist/src/graders/shell.js.map +1 -0
- package/dist/src/host-diagnostic-redaction.js +52 -0
- package/dist/src/host-diagnostic-redaction.js.map +1 -0
- package/dist/src/host-diagnostics.js +248 -0
- package/dist/src/host-diagnostics.js.map +1 -0
- package/dist/src/hosts/claude-continuation.js +89 -0
- package/dist/src/hosts/claude-continuation.js.map +1 -0
- package/dist/src/hosts/claude-credential.js +121 -0
- package/dist/src/hosts/claude-credential.js.map +1 -0
- package/dist/src/hosts/claude-events.js +136 -0
- package/dist/src/hosts/claude-events.js.map +1 -0
- package/dist/src/hosts/claude-keychain.js +100 -0
- package/dist/src/hosts/claude-keychain.js.map +1 -0
- package/dist/src/hosts/claude-login-recovery.js +67 -0
- package/dist/src/hosts/claude-login-recovery.js.map +1 -0
- package/dist/src/hosts/claude-login-refresh.js +146 -0
- package/dist/src/hosts/claude-login-refresh.js.map +1 -0
- package/dist/src/hosts/claude-login-store.js +124 -0
- package/dist/src/hosts/claude-login-store.js.map +1 -0
- package/dist/src/hosts/claude-login.js +74 -0
- package/dist/src/hosts/claude-login.js.map +1 -0
- package/dist/src/hosts/claude-native-goal.js +138 -0
- package/dist/src/hosts/claude-native-goal.js.map +1 -0
- package/dist/src/hosts/claude-process.js +10 -0
- package/dist/src/hosts/claude-process.js.map +1 -0
- package/dist/src/hosts/claude-refresh-lock.js +76 -0
- package/dist/src/hosts/claude-refresh-lock.js.map +1 -0
- package/dist/src/hosts/claude-repository-invocation.js +229 -0
- package/dist/src/hosts/claude-repository-invocation.js.map +1 -0
- package/dist/src/hosts/claude-settings.js +156 -0
- package/dist/src/hosts/claude-settings.js.map +1 -0
- package/dist/src/hosts/claude-skill-activations.js +131 -0
- package/dist/src/hosts/claude-skill-activations.js.map +1 -0
- package/dist/src/hosts/claude-state.js +237 -0
- package/dist/src/hosts/claude-state.js.map +1 -0
- package/dist/src/hosts/claude-tool-calls.js +150 -0
- package/dist/src/hosts/claude-tool-calls.js.map +1 -0
- package/dist/src/hosts/claude.js +373 -0
- package/dist/src/hosts/claude.js.map +1 -0
- package/dist/src/hosts/codex-app-server.js +764 -0
- package/dist/src/hosts/codex-app-server.js.map +1 -0
- package/dist/src/hosts/codex-configuration.js +91 -0
- package/dist/src/hosts/codex-configuration.js.map +1 -0
- package/dist/src/hosts/codex-events.js +104 -0
- package/dist/src/hosts/codex-events.js.map +1 -0
- package/dist/src/hosts/codex-exec-controls.js +434 -0
- package/dist/src/hosts/codex-exec-controls.js.map +1 -0
- package/dist/src/hosts/codex-invocation.js +54 -0
- package/dist/src/hosts/codex-invocation.js.map +1 -0
- package/dist/src/hosts/codex-marketplace.js +185 -0
- package/dist/src/hosts/codex-marketplace.js.map +1 -0
- package/dist/src/hosts/codex-native-calls.js +516 -0
- package/dist/src/hosts/codex-native-calls.js.map +1 -0
- package/dist/src/hosts/codex-process.js +10 -0
- package/dist/src/hosts/codex-process.js.map +1 -0
- package/dist/src/hosts/codex-profile.js +206 -0
- package/dist/src/hosts/codex-profile.js.map +1 -0
- package/dist/src/hosts/codex-session-files.js +89 -0
- package/dist/src/hosts/codex-session-files.js.map +1 -0
- package/dist/src/hosts/codex-state.js +310 -0
- package/dist/src/hosts/codex-state.js.map +1 -0
- package/dist/src/hosts/codex.js +527 -0
- package/dist/src/hosts/codex.js.map +1 -0
- package/dist/src/hosts/isolation-common.js +43 -0
- package/dist/src/hosts/isolation-common.js.map +1 -0
- package/dist/src/hosts/isolation-roots.js +64 -0
- package/dist/src/hosts/isolation-roots.js.map +1 -0
- package/dist/src/hosts/isolation.js +12 -0
- package/dist/src/hosts/isolation.js.map +1 -0
- package/dist/src/hosts/linux-sandbox.js +127 -0
- package/dist/src/hosts/linux-sandbox.js.map +1 -0
- package/dist/src/hosts/mac-sandbox.js +137 -0
- package/dist/src/hosts/mac-sandbox.js.map +1 -0
- package/dist/src/hosts/native-controls.js +151 -0
- package/dist/src/hosts/native-controls.js.map +1 -0
- package/dist/src/hosts/native-request.js +33 -0
- package/dist/src/hosts/native-request.js.map +1 -0
- package/dist/src/hosts/process-lifecycle.js +167 -0
- package/dist/src/hosts/process-lifecycle.js.map +1 -0
- package/dist/src/hosts/protected-worktrees.js +81 -0
- package/dist/src/hosts/protected-worktrees.js.map +1 -0
- package/dist/src/hosts/skill-hook-catalog.js +100 -0
- package/dist/src/hosts/skill-hook-catalog.js.map +1 -0
- package/dist/src/hosts/skill-hook-handler.js +228 -0
- package/dist/src/hosts/skill-hook-handler.js.map +1 -0
- package/dist/src/hosts/skill-hooks.js +423 -0
- package/dist/src/hosts/skill-hooks.js.map +1 -0
- package/dist/src/hosts/workspace-fingerprint.js +72 -0
- package/dist/src/hosts/workspace-fingerprint.js.map +1 -0
- package/dist/src/identity.js +167 -0
- package/dist/src/identity.js.map +1 -0
- package/dist/src/instrumentation.js +83 -0
- package/dist/src/instrumentation.js.map +1 -0
- package/dist/src/native-transcript-state.js +85 -0
- package/dist/src/native-transcript-state.js.map +1 -0
- package/dist/src/native-transcript-view.js +65 -0
- package/dist/src/native-transcript-view.js.map +1 -0
- package/dist/src/native-transcripts.js +208 -0
- package/dist/src/native-transcripts.js.map +1 -0
- package/dist/src/paths.js +13 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/process-lifecycle.js +101 -0
- package/dist/src/process-lifecycle.js.map +1 -0
- package/dist/src/provenance.js +263 -0
- package/dist/src/provenance.js.map +1 -0
- package/dist/src/prune.js +228 -0
- package/dist/src/prune.js.map +1 -0
- package/dist/src/report.js +276 -0
- package/dist/src/report.js.map +1 -0
- package/dist/src/resolved-case.js +29 -0
- package/dist/src/resolved-case.js.map +1 -0
- package/dist/src/results-lock.js +40 -0
- package/dist/src/results-lock.js.map +1 -0
- package/dist/src/results.js +127 -0
- package/dist/src/results.js.map +1 -0
- package/dist/src/run-owner.js +283 -0
- package/dist/src/run-owner.js.map +1 -0
- package/dist/src/runner-paths.js +11 -0
- package/dist/src/runner-paths.js.map +1 -0
- package/dist/src/runtime/config.js +323 -0
- package/dist/src/runtime/config.js.map +1 -0
- package/dist/src/runtime/discovery-apple.js +65 -0
- package/dist/src/runtime/discovery-apple.js.map +1 -0
- package/dist/src/runtime/discovery-providers.js +37 -0
- package/dist/src/runtime/discovery-providers.js.map +1 -0
- package/dist/src/runtime/discovery.js +40 -0
- package/dist/src/runtime/discovery.js.map +1 -0
- package/dist/src/runtime/hook-processes.js +81 -0
- package/dist/src/runtime/hook-processes.js.map +1 -0
- package/dist/src/runtime/hooks.js +304 -0
- package/dist/src/runtime/hooks.js.map +1 -0
- package/dist/src/runtime/paths.js +244 -0
- package/dist/src/runtime/paths.js.map +1 -0
- package/dist/src/runtime/query.js +76 -0
- package/dist/src/runtime/query.js.map +1 -0
- package/dist/src/runtime/seeds.js +98 -0
- package/dist/src/runtime/seeds.js.map +1 -0
- package/dist/src/runtime/shared-cache.js +81 -0
- package/dist/src/runtime/shared-cache.js.map +1 -0
- package/dist/src/runtime/state.js +106 -0
- package/dist/src/runtime/state.js.map +1 -0
- package/dist/src/runtime-process.js +148 -0
- package/dist/src/runtime-process.js.map +1 -0
- package/dist/src/schema-types.js +2 -0
- package/dist/src/schema-types.js.map +1 -0
- package/dist/src/schema.js +16 -0
- package/dist/src/schema.js.map +1 -0
- package/dist/src/shell.js +5 -0
- package/dist/src/shell.js.map +1 -0
- package/dist/src/sqlite-lock.js +18 -0
- package/dist/src/sqlite-lock.js.map +1 -0
- package/dist/src/storage.js +21 -0
- package/dist/src/storage.js.map +1 -0
- package/dist/src/transcript-retention.js +109 -0
- package/dist/src/transcript-retention.js.map +1 -0
- package/dist/src/value-guards.js +26 -0
- package/dist/src/value-guards.js.map +1 -0
- package/docs/architecture.md +5 -2
- package/docs/creating-cases.md +2 -3
- package/docs/development-cli.md +12 -7
- package/docs/documentation-quality.md +4 -3
- package/docs/evaluation-workflow.md +8 -8
- package/docs/getting-started.md +7 -6
- package/docs/guide-evaluation.md +1 -1
- package/docs/identity-v1.md +4 -1
- package/docs/installing.md +31 -13
- package/docs/licensing.md +2 -2
- package/docs/native-hosts.md +1 -1
- package/docs/recipes.md +41 -40
- package/docs/releases.md +20 -4
- package/docs/run-settings-v1.md +3 -3
- package/docs/specs/repository-guide.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/docs/typescript-quality.md +18 -1
- package/examples/recipes/executable.ts +19 -0
- package/examples/recipes/extension-artifacts.ts +1 -1
- package/examples/recipes/extension.ts +2 -1
- package/examples/recipes/modules.ts +9 -0
- package/examples/recipes/run-inputs.ts +14 -19
- package/examples/recipes/run-options.ts +9 -8
- package/examples/recipes/run.ts +21 -7
- package/examples/templates/repository-skill/extension-data.ts +1 -1
- package/examples/templates/repository-skill/extension.ts +2 -1
- package/package.json +14 -6
- package/src/cli/demo.ts +3 -2
- package/src/cli/help.ts +4 -3
- package/src/cli/init-settings.ts +5 -4
- package/src/cli/init.ts +9 -8
- package/src/cli/invocation.ts +2 -1
- package/src/cli/preparation.ts +2 -2
- package/src/cli.ts +1 -1
- package/src/executable.ts +19 -0
- package/src/extension-client.ts +6 -12
- package/src/fixtures/setup.ts +3 -2
- package/src/git.ts +2 -1
- package/src/graders/git-head.ts +3 -2
- package/src/graders/shell.ts +4 -3
- package/src/hosts/claude-keychain.ts +3 -2
- package/src/hosts/claude-login-refresh.ts +3 -2
- package/src/hosts/claude-refresh-lock.ts +2 -1
- package/src/hosts/isolation-roots.ts +3 -2
- package/src/hosts/process-lifecycle.ts +4 -6
- package/src/hosts/protected-worktrees.ts +2 -1
- package/src/hosts/skill-hook-handler.ts +1 -1
- package/src/hosts/skill-hooks.ts +10 -2
- package/src/provenance.ts +7 -6
- package/src/results-lock.ts +4 -4
- package/src/run-owner.ts +15 -9
- package/src/runner-paths.ts +21 -0
- package/src/runtime/hook-processes.ts +2 -1
- package/src/runtime/hooks.ts +9 -7
- package/src/runtime-process.ts +194 -0
- package/src/sqlite-lock.ts +25 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { runnerRoot } from "../runner-paths.js";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { configurationRoot } from "../hosts/codex-configuration.js";
|
|
4
|
+
import { InvocationError, parseInvocation, nativeRoutes, } from "./invocation.js";
|
|
5
|
+
import { loadRuntimeConfiguration, runtimeNativeGoalEnabled, } from "../runtime/config.js";
|
|
6
|
+
import { canonicalRuntimeRoot, requireRuntimeReadRoots, } from "../runtime/paths.js";
|
|
7
|
+
import { loadCase, loadPreparationSources } from "./loading.js";
|
|
8
|
+
import { candidateHost, secondaryHost, selectedConcurrency } from "./hosts.js";
|
|
9
|
+
function protectMappedSources(invocation, preparationSources) {
|
|
10
|
+
const sourceRoots = mappedSourceRoots(preparationSources);
|
|
11
|
+
for (const native of nativeRoutes(invocation)) {
|
|
12
|
+
native.additionalProtectedRoots = [
|
|
13
|
+
...native.additionalProtectedRoots,
|
|
14
|
+
...sourceRoots,
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
invocation.shellIsolation?.protectedRoots.push(...sourceRoots);
|
|
18
|
+
}
|
|
19
|
+
export async function prepareRunInvocation(argv) {
|
|
20
|
+
const invocation = await parseInvocation(argv);
|
|
21
|
+
warnDeprecatedRuntimeOptions(invocation);
|
|
22
|
+
const preparationSources = await loadPreparationSources(invocation);
|
|
23
|
+
protectMappedSources(invocation, preparationSources);
|
|
24
|
+
const protectedRoots = await invocationProtectedRuntimeRoots(invocation);
|
|
25
|
+
const runtimePolicy = await loadRuntimeConfiguration(invocation.projectRoot, invocation.runtimeConfigFile, protectedRoots);
|
|
26
|
+
requireRuntimeOptionCompatibility(invocation, runtimePolicy);
|
|
27
|
+
selectRuntimeTransport(invocation, runtimePolicy);
|
|
28
|
+
const configRoot = await configurationRoot(invocation.configRoot);
|
|
29
|
+
validateInvocationRuntime(protectedRoots, runtimePolicy);
|
|
30
|
+
const agentConcurrencyLimit = await selectedConcurrency(invocation, configRoot);
|
|
31
|
+
const caseData = invocation.caseFile
|
|
32
|
+
? await loadCase(invocation.caseFile)
|
|
33
|
+
: undefined;
|
|
34
|
+
const host = await candidateHost(invocation, agentConcurrencyLimit);
|
|
35
|
+
const semanticHost = await secondaryHost(invocation.semanticAdapterModule, invocation.semanticCodex, agentConcurrencyLimit);
|
|
36
|
+
const advisoryHost = await secondaryHost(invocation.advisoryAdapterModule, invocation.advisoryCodex, agentConcurrencyLimit);
|
|
37
|
+
return {
|
|
38
|
+
invocation,
|
|
39
|
+
runtimePolicy,
|
|
40
|
+
preparationSources,
|
|
41
|
+
caseData,
|
|
42
|
+
host,
|
|
43
|
+
semanticHost,
|
|
44
|
+
advisoryHost,
|
|
45
|
+
agentConcurrencyLimit,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function selectRuntimeTransport(invocation, policy) {
|
|
49
|
+
if (!runtimeNativeGoalEnabled(policy))
|
|
50
|
+
return;
|
|
51
|
+
if (invocation.codex)
|
|
52
|
+
selectCodexGoalTransport(invocation.codex);
|
|
53
|
+
}
|
|
54
|
+
function selectCodexGoalTransport(codex) {
|
|
55
|
+
if (codex.entrypoint === "exec")
|
|
56
|
+
throw new InvocationError("native-goal runtime policy requires Codex app-server");
|
|
57
|
+
codex.entrypoint = "app-server";
|
|
58
|
+
}
|
|
59
|
+
function warnDeprecatedRuntimeOptions(invocation) {
|
|
60
|
+
for (const option of invocation.deprecatedRuntimeOptions)
|
|
61
|
+
console.warn(`--${option} is deprecated; declare the runtime in sevro.json or --runtime-config-file instead`);
|
|
62
|
+
}
|
|
63
|
+
function requireRuntimeOptionCompatibility(invocation, policy) {
|
|
64
|
+
if (policy && invocation.deprecatedRuntimeOptions.length)
|
|
65
|
+
throw new InvocationError("runtime configuration cannot be combined with deprecated runtime options");
|
|
66
|
+
}
|
|
67
|
+
function validateInvocationRuntime(protectedRoots, policy) {
|
|
68
|
+
if (!policy)
|
|
69
|
+
return;
|
|
70
|
+
requireRuntimeReadRoots(policy.readOnlyRoots, protectedRoots);
|
|
71
|
+
requireRuntimeReadRoots((policy.seeds ?? []).map((seed) => seed.source), protectedRoots);
|
|
72
|
+
}
|
|
73
|
+
async function invocationProtectedRuntimeRoots(invocation) {
|
|
74
|
+
const protectedRoots = [
|
|
75
|
+
runnerRoot,
|
|
76
|
+
invocation.projectRoot,
|
|
77
|
+
invocation.configRoot,
|
|
78
|
+
invocation.resultsRoot,
|
|
79
|
+
invocation.runStateRoot,
|
|
80
|
+
...nativeRoutes(invocation).flatMap((host) => host.additionalProtectedRoots),
|
|
81
|
+
...(invocation.shellIsolation?.protectedRoots ?? []),
|
|
82
|
+
];
|
|
83
|
+
return Promise.all(protectedRoots.map(canonicalRuntimeRoot));
|
|
84
|
+
}
|
|
85
|
+
function mappedSourceRoots(preparationSources) {
|
|
86
|
+
return Object.values(preparationSources?.refs ?? {}).map((url) => fileURLToPath(url));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=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,CAAC,kBAAsC;IAC/D,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAC/D,aAAa,CAAC,GAAG,CAAC,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import { runnerRoot } from \"../runner-paths\";\nimport { fileURLToPath } from \"node:url\";\nimport { configurationRoot } from \"../hosts/codex-configuration\";\nimport {\n InvocationError,\n parseInvocation,\n nativeRoutes,\n type Invocation,\n} from \"./invocation\";\nimport {\n loadRuntimeConfiguration,\n runtimeNativeGoalEnabled,\n} from \"../runtime/config\";\nimport {\n canonicalRuntimeRoot,\n requireRuntimeReadRoots,\n} from \"../runtime/paths\";\nimport { loadCase, loadPreparationSources } from \"./loading\";\nimport { candidateHost, secondaryHost, selectedConcurrency } from \"./hosts\";\n\ntype PreparationSources = Awaited<ReturnType<typeof loadPreparationSources>>;\n\nfunction protectMappedSources(\n invocation: Invocation,\n preparationSources: PreparationSources,\n): void {\n const sourceRoots = mappedSourceRoots(preparationSources);\n for (const native of nativeRoutes(invocation)) {\n native.additionalProtectedRoots = [\n ...native.additionalProtectedRoots,\n ...sourceRoots,\n ];\n }\n invocation.shellIsolation?.protectedRoots.push(...sourceRoots);\n}\n\nexport async function prepareRunInvocation(argv: string[]) {\n const invocation = await parseInvocation(argv);\n warnDeprecatedRuntimeOptions(invocation);\n const preparationSources = await loadPreparationSources(invocation);\n protectMappedSources(invocation, preparationSources);\n const protectedRoots = await invocationProtectedRuntimeRoots(invocation);\n const runtimePolicy = await loadRuntimeConfiguration(\n invocation.projectRoot,\n invocation.runtimeConfigFile,\n protectedRoots,\n );\n requireRuntimeOptionCompatibility(invocation, runtimePolicy);\n selectRuntimeTransport(invocation, runtimePolicy);\n const configRoot = await configurationRoot(invocation.configRoot);\n validateInvocationRuntime(protectedRoots, runtimePolicy);\n const agentConcurrencyLimit = await selectedConcurrency(\n invocation,\n configRoot,\n );\n const caseData = invocation.caseFile\n ? await loadCase(invocation.caseFile)\n : undefined;\n const host = await candidateHost(invocation, agentConcurrencyLimit);\n const semanticHost = await secondaryHost(\n invocation.semanticAdapterModule,\n invocation.semanticCodex,\n agentConcurrencyLimit,\n );\n const advisoryHost = await secondaryHost(\n invocation.advisoryAdapterModule,\n invocation.advisoryCodex,\n agentConcurrencyLimit,\n );\n return {\n invocation,\n runtimePolicy,\n preparationSources,\n caseData,\n host,\n semanticHost,\n advisoryHost,\n agentConcurrencyLimit,\n };\n}\n\nfunction selectRuntimeTransport(\n invocation: Invocation,\n policy: Awaited<ReturnType<typeof loadRuntimeConfiguration>>,\n): void {\n if (!runtimeNativeGoalEnabled(policy)) return;\n if (invocation.codex) selectCodexGoalTransport(invocation.codex);\n}\n\nfunction selectCodexGoalTransport(\n codex: NonNullable<Invocation[\"codex\"]>,\n): void {\n if (codex.entrypoint === \"exec\")\n throw new InvocationError(\n \"native-goal runtime policy requires Codex app-server\",\n );\n codex.entrypoint = \"app-server\";\n}\n\nfunction warnDeprecatedRuntimeOptions(invocation: Invocation): void {\n for (const option of invocation.deprecatedRuntimeOptions)\n console.warn(\n `--${option} is deprecated; declare the runtime in sevro.json or --runtime-config-file instead`,\n );\n}\n\nfunction requireRuntimeOptionCompatibility(\n invocation: Invocation,\n policy: Awaited<ReturnType<typeof loadRuntimeConfiguration>>,\n): void {\n if (policy && invocation.deprecatedRuntimeOptions.length)\n throw new InvocationError(\n \"runtime configuration cannot be combined with deprecated runtime options\",\n );\n}\n\nexport type PreparedInvocation = Awaited<\n ReturnType<typeof prepareRunInvocation>\n>;\n\nfunction validateInvocationRuntime(\n protectedRoots: string[],\n policy: Awaited<ReturnType<typeof loadRuntimeConfiguration>>,\n): void {\n if (!policy) return;\n requireRuntimeReadRoots(policy.readOnlyRoots, protectedRoots);\n requireRuntimeReadRoots(\n (policy.seeds ?? []).map((seed) => seed.source),\n protectedRoots,\n );\n}\n\nasync function invocationProtectedRuntimeRoots(\n invocation: Invocation,\n): Promise<string[]> {\n const protectedRoots = [\n runnerRoot,\n invocation.projectRoot,\n invocation.configRoot,\n invocation.resultsRoot,\n invocation.runStateRoot,\n ...nativeRoutes(invocation).flatMap(\n (host) => host.additionalProtectedRoots,\n ),\n ...(invocation.shellIsolation?.protectedRoots ?? []),\n ];\n return Promise.all(protectedRoots.map(canonicalRuntimeRoot));\n}\n\nfunction mappedSourceRoots(preparationSources: PreparationSources): string[] {\n return Object.values(preparationSources?.refs ?? {}).map((url) =>\n fileURLToPath(url),\n );\n}\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { EvaluationConfigurationError } from "../engine.js";
|
|
2
|
+
import { InvocationError } from "./invocation.js";
|
|
3
|
+
import { assertCliResult } from "../schema.js";
|
|
4
|
+
import { displayMeasurements, displayTrialSummary } from "./summary.js";
|
|
5
|
+
function failure(code, message) {
|
|
6
|
+
const result = {
|
|
7
|
+
format: "sevro.cli-result.v1",
|
|
8
|
+
runId: null,
|
|
9
|
+
execution: { status: "not_run" },
|
|
10
|
+
grading: { status: "not_requested" },
|
|
11
|
+
task: { verdict: "not_assessed" },
|
|
12
|
+
exitCode: code,
|
|
13
|
+
evidencePath: null,
|
|
14
|
+
cases: [],
|
|
15
|
+
diagnostic: {
|
|
16
|
+
code: code === 64 ? "sevro.invocation.invalid" : "sevro.runner.error",
|
|
17
|
+
message: message.slice(0, 4096),
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
assertCliResult(result);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
export function display(result, json, completion) {
|
|
24
|
+
assertCliResult(result);
|
|
25
|
+
if (result.diagnostic)
|
|
26
|
+
process.stderr.write(`sevro: ${result.diagnostic.message}\n`);
|
|
27
|
+
if (json) {
|
|
28
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
process.stdout.write(`execution=${result.execution.status} grading=${result.grading.status} task=${result.task.verdict}\n`);
|
|
32
|
+
displayTrialSummary(result);
|
|
33
|
+
displayDomainOutcomes(result.cases);
|
|
34
|
+
if (completion) {
|
|
35
|
+
displayMeasurements(completion.report);
|
|
36
|
+
process.stdout.write(`result=${completion.resultFile}\n`);
|
|
37
|
+
}
|
|
38
|
+
if (result.evidencePath)
|
|
39
|
+
process.stdout.write(`evidence=${result.evidencePath}\n`);
|
|
40
|
+
}
|
|
41
|
+
function displayDomainOutcomes(cases) {
|
|
42
|
+
for (const selected of cases)
|
|
43
|
+
for (const trial of selected.trials)
|
|
44
|
+
for (const outcome of trial.domainOutcomes ?? [])
|
|
45
|
+
process.stdout.write(`domain case=${selected.caseId} trial=${trial.trial} outcome=${outcome.id} status=${outcome.status}\n`);
|
|
46
|
+
}
|
|
47
|
+
export function runnerFailureCategory(error) {
|
|
48
|
+
return error instanceof EvaluationConfigurationError ||
|
|
49
|
+
error instanceof InvocationError
|
|
50
|
+
? 64
|
|
51
|
+
: 70;
|
|
52
|
+
}
|
|
53
|
+
export function displayFailure(error, json, code, fallback, helpCommand = "run") {
|
|
54
|
+
display(failure(code, error instanceof Error ? error.message : fallback), json);
|
|
55
|
+
const help = helpCommand ? `sevro ${helpCommand} --help` : "sevro --help";
|
|
56
|
+
process.stderr.write(code === 64
|
|
57
|
+
? `Correct the named option or input and retry. Run ${help} for examples and required options.\n`
|
|
58
|
+
: "Check the reported path and ensure --results-root and --run-state-root are writable directories, then retry.\n");
|
|
59
|
+
process.exitCode = code;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=presentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation.js","sourceRoot":"","sources":["presentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,qBAAkB;AACzD,OAAO,EAAE,eAAe,EAAE,wBAAqB;AAC/C,OAAO,EAAE,eAAe,EAAE,qBAAkB;AAE5C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAkB;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AI,uCAAuC;QACjG,CAAC,CAAC,gHAAgH,CACrH,CAAC;IACF,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC1B,CAAC","sourcesContent":["import { EvaluationConfigurationError } from \"../engine\";\nimport { InvocationError } from \"./invocation\";\nimport { assertCliResult } from \"../schema\";\nimport type { ReportData } from \"../schema-types\";\nimport { displayMeasurements, displayTrialSummary } from \"./summary\";\n\nfunction failure(code: 64 | 70, message: string) {\n const result = {\n format: \"sevro.cli-result.v1\",\n runId: null,\n execution: { status: \"not_run\" },\n grading: { status: \"not_requested\" },\n task: { verdict: \"not_assessed\" },\n exitCode: code,\n evidencePath: null,\n cases: [],\n diagnostic: {\n code: code === 64 ? \"sevro.invocation.invalid\" : \"sevro.runner.error\",\n message: message.slice(0, 4096),\n },\n };\n assertCliResult(result);\n return result;\n}\n\nexport function display(\n result: unknown,\n json: boolean,\n completion?: { resultFile: string; report: ReportData },\n): void {\n assertCliResult(result);\n if (result.diagnostic)\n process.stderr.write(`sevro: ${result.diagnostic.message}\\n`);\n if (json) {\n process.stdout.write(`${JSON.stringify(result)}\\n`);\n return;\n }\n process.stdout.write(\n `execution=${result.execution.status} grading=${result.grading.status} task=${result.task.verdict}\\n`,\n );\n displayTrialSummary(result);\n displayDomainOutcomes(result.cases);\n if (completion) {\n displayMeasurements(completion.report);\n process.stdout.write(`result=${completion.resultFile}\\n`);\n }\n if (result.evidencePath)\n process.stdout.write(`evidence=${result.evidencePath}\\n`);\n}\n\nfunction displayDomainOutcomes(\n cases: Array<{\n caseId: string;\n trials: Array<{\n trial: number;\n domainOutcomes?: Array<{ id: string; status: string }>;\n }>;\n }>,\n): void {\n for (const selected of cases)\n for (const trial of selected.trials)\n for (const outcome of trial.domainOutcomes ?? [])\n process.stdout.write(\n `domain case=${selected.caseId} trial=${trial.trial} outcome=${outcome.id} status=${outcome.status}\\n`,\n );\n}\n\nexport function runnerFailureCategory(error: unknown): 64 | 70 {\n return error instanceof EvaluationConfigurationError ||\n error instanceof InvocationError\n ? 64\n : 70;\n}\n\nexport function displayFailure(\n error: unknown,\n json: boolean,\n code: 64 | 70,\n fallback: string,\n helpCommand = \"run\",\n): void {\n display(\n failure(code, error instanceof Error ? error.message : fallback),\n json,\n );\n const help = helpCommand ? `sevro ${helpCommand} --help` : \"sevro --help\";\n process.stderr.write(\n code === 64\n ? `Correct the named option or input and retry. Run ${help} for examples and required options.\\n`\n : \"Check the reported path and ensure --results-root and --run-state-root are writable directories, then retry.\\n\",\n );\n process.exitCode = code;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["progress.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,KAAyB;IACvD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,KAAK,EAAE,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,IAAI,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import type { EvaluationProgress } from \"../evaluation/types\";\n\nexport function displayProgress(event: EvaluationProgress): void {\n const trial = event.trial === undefined ? \"\" : ` trial=${event.trial}`;\n process.stderr.write(`sevro: ${event.stage} ${event.status}${trial}\\n`);\n}\n"]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { lstat, readFile, realpath } from "node:fs/promises";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { isRecord, isStringArray } from "../value-guards.js";
|
|
4
|
+
import { CLI_ONLY, LIST_OPTIONS, NUMBER_OPTIONS, PATH_OPTIONS, PATH_LIST_OPTIONS, RUN_OPTIONS, } from "./run-options.js";
|
|
5
|
+
import { overrideRunSelections } from "./run-overrides.js";
|
|
6
|
+
const FILE_LIMIT = 64 * 1024;
|
|
7
|
+
function fieldError(field, requirement) {
|
|
8
|
+
throw new Error(`run manifest ${field}: ${requirement}`);
|
|
9
|
+
}
|
|
10
|
+
function manifestSettings(value) {
|
|
11
|
+
if (!isRecord(value))
|
|
12
|
+
fieldError("$", "expected an object");
|
|
13
|
+
validateManifestFields(value);
|
|
14
|
+
if (value.format !== "sevro.run.v1")
|
|
15
|
+
fieldError("format", 'expected "sevro.run.v1"');
|
|
16
|
+
if (!isRecord(value.settings))
|
|
17
|
+
fieldError("settings", "expected an object of run options");
|
|
18
|
+
return value.settings;
|
|
19
|
+
}
|
|
20
|
+
function validateManifestFields(value) {
|
|
21
|
+
for (const key of Object.keys(value))
|
|
22
|
+
if (!["format", "settings"].includes(key))
|
|
23
|
+
fieldError(key, "unknown field; use format and settings");
|
|
24
|
+
}
|
|
25
|
+
function finiteNumber(value) {
|
|
26
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
27
|
+
}
|
|
28
|
+
function nonemptyString(value) {
|
|
29
|
+
return typeof value === "string" && Boolean(value.trim());
|
|
30
|
+
}
|
|
31
|
+
function nonemptyStringList(value) {
|
|
32
|
+
return isStringArray(value) && value.every(nonemptyString);
|
|
33
|
+
}
|
|
34
|
+
function validateSetting(name, value) {
|
|
35
|
+
if (!Object.hasOwn(RUN_OPTIONS, name) || CLI_ONLY.has(name))
|
|
36
|
+
fieldError(`settings.${name}`, "unknown saved option; see sevro run --help");
|
|
37
|
+
if (NUMBER_OPTIONS.has(name)) {
|
|
38
|
+
if (!finiteNumber(value))
|
|
39
|
+
fieldError(`settings.${name}`, "expected a finite number");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
validateOrdinarySetting(name, value);
|
|
43
|
+
}
|
|
44
|
+
function validateOrdinarySetting(name, value) {
|
|
45
|
+
if (LIST_OPTIONS.has(name)) {
|
|
46
|
+
if (!nonemptyStringList(value))
|
|
47
|
+
fieldError(`settings.${name}`, "expected an array of nonempty strings");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const option = RUN_OPTIONS[name];
|
|
51
|
+
validateScalar(name, value, option.type);
|
|
52
|
+
}
|
|
53
|
+
function validateScalar(name, value, type) {
|
|
54
|
+
if (type === "boolean") {
|
|
55
|
+
if (typeof value !== "boolean")
|
|
56
|
+
fieldError(`settings.${name}`, "expected a boolean");
|
|
57
|
+
}
|
|
58
|
+
else if (!nonemptyString(value))
|
|
59
|
+
fieldError(`settings.${name}`, "expected a nonempty string");
|
|
60
|
+
}
|
|
61
|
+
function resolvedSetting(name, value, base) {
|
|
62
|
+
const pathOption = PATH_OPTIONS.includes(name);
|
|
63
|
+
if (pathOption)
|
|
64
|
+
return resolve(base, value);
|
|
65
|
+
if (PATH_LIST_OPTIONS.includes(name))
|
|
66
|
+
return value.map((path) => resolve(base, path));
|
|
67
|
+
return NUMBER_OPTIONS.has(name) ? String(value) : value;
|
|
68
|
+
}
|
|
69
|
+
async function readManifest(path) {
|
|
70
|
+
const stat = await lstat(path);
|
|
71
|
+
if (!stat.isFile() || stat.size > FILE_LIMIT)
|
|
72
|
+
fieldError("$", "use a regular, non-symlink JSON file of at most 64 KiB");
|
|
73
|
+
const source = await readFile(path, "utf8");
|
|
74
|
+
let value;
|
|
75
|
+
try {
|
|
76
|
+
value = JSON.parse(source);
|
|
77
|
+
}
|
|
78
|
+
catch (cause) {
|
|
79
|
+
throw new Error("run manifest $: invalid JSON; check the JSON syntax", {
|
|
80
|
+
cause,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const settings = manifestSettings(value);
|
|
84
|
+
const base = dirname(await realpath(path));
|
|
85
|
+
const resolved = {};
|
|
86
|
+
for (const [name, setting] of Object.entries(settings)) {
|
|
87
|
+
validateSetting(name, setting);
|
|
88
|
+
resolved[name] = resolvedSetting(name, setting, base);
|
|
89
|
+
}
|
|
90
|
+
return resolved;
|
|
91
|
+
}
|
|
92
|
+
/** Explicit flags replace saved selections and lists; defaults are applied later. */
|
|
93
|
+
export async function savedRunValues(explicit) {
|
|
94
|
+
const file = explicit["run-manifest-file"];
|
|
95
|
+
if (!file)
|
|
96
|
+
return explicit;
|
|
97
|
+
const path = resolve(file);
|
|
98
|
+
try {
|
|
99
|
+
const saved = await readManifest(path);
|
|
100
|
+
overrideRunSelections(saved, explicit);
|
|
101
|
+
return { ...saved, ...explicit };
|
|
102
|
+
}
|
|
103
|
+
catch (cause) {
|
|
104
|
+
const detail = cause instanceof Error ? cause.message : "cannot read file";
|
|
105
|
+
throw new Error(`--run-manifest-file ${path}: ${detail}; correct the named field or select a readable manifest`, { cause });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=run-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-manifest.js","sourceRoot":"","sources":["run-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,yBAAyB;AAC7D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB;AAC7C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,2BAAwB;AAC1D,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,WAAW,GAEZ,yBAAsB;AACvB,OAAO,EAAE,qBAAqB,EAAE,2BAAwB;AAExD,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7B,SAAS,UAAU,CAAC,KAAa,EAAE,WAAmB;IACpD,MAAM,IAAI,KAAK,CAAC,gBAAgB,KAAK,KAAK,WAAW,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,UAAU,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;IAC5D,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,cAAc;QACjC,UAAU,CAAC,QAAQ,EAAE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,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;QACvC,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACvC,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC;QAC3E,MAAM,IAAI,KAAK,CACb,uBAAuB,IAAI,KAAK,MAAM,yDAAyD,EAC/F,EAAE,KAAK,EAAE,CACV,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { lstat, readFile, realpath } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport { isRecord, isStringArray } from \"../value-guards\";\nimport {\n CLI_ONLY,\n LIST_OPTIONS,\n NUMBER_OPTIONS,\n PATH_OPTIONS,\n PATH_LIST_OPTIONS,\n RUN_OPTIONS,\n type RunValues,\n} from \"./run-options\";\nimport { overrideRunSelections } from \"./run-overrides\";\n\nconst FILE_LIMIT = 64 * 1024;\n\nfunction fieldError(field: string, requirement: string): never {\n throw new Error(`run manifest ${field}: ${requirement}`);\n}\n\nfunction manifestSettings(value: unknown): Record<string, unknown> {\n if (!isRecord(value)) fieldError(\"$\", \"expected an object\");\n validateManifestFields(value);\n if (value.format !== \"sevro.run.v1\")\n fieldError(\"format\", 'expected \"sevro.run.v1\"');\n if (!isRecord(value.settings))\n fieldError(\"settings\", \"expected an object of run options\");\n return value.settings;\n}\n\nfunction validateManifestFields(value: Record<string, unknown>): void {\n for (const key of Object.keys(value))\n if (![\"format\", \"settings\"].includes(key))\n fieldError(key, \"unknown field; use format and settings\");\n}\n\nfunction finiteNumber(value: unknown): boolean {\n return typeof value === \"number\" && Number.isFinite(value);\n}\n\nfunction nonemptyString(value: unknown): boolean {\n return typeof value === \"string\" && Boolean(value.trim());\n}\n\nfunction nonemptyStringList(value: unknown): boolean {\n return isStringArray(value) && value.every(nonemptyString);\n}\n\nfunction validateSetting(name: string, value: unknown): void {\n if (!Object.hasOwn(RUN_OPTIONS, name) || CLI_ONLY.has(name))\n fieldError(\n `settings.${name}`,\n \"unknown saved option; see sevro run --help\",\n );\n if (NUMBER_OPTIONS.has(name)) {\n if (!finiteNumber(value))\n fieldError(`settings.${name}`, \"expected a finite number\");\n return;\n }\n validateOrdinarySetting(name, value);\n}\n\nfunction validateOrdinarySetting(name: string, value: unknown): void {\n if (LIST_OPTIONS.has(name)) {\n if (!nonemptyStringList(value))\n fieldError(`settings.${name}`, \"expected an array of nonempty strings\");\n return;\n }\n const option = RUN_OPTIONS[name as keyof typeof RUN_OPTIONS];\n validateScalar(name, value, option.type);\n}\n\nfunction validateScalar(name: string, value: unknown, type: string): void {\n if (type === \"boolean\") {\n if (typeof value !== \"boolean\")\n fieldError(`settings.${name}`, \"expected a boolean\");\n } else if (!nonemptyString(value))\n fieldError(`settings.${name}`, \"expected a nonempty string\");\n}\n\nfunction resolvedSetting(name: string, value: unknown, base: string) {\n const pathOption = (PATH_OPTIONS as readonly string[]).includes(name);\n if (pathOption) return resolve(base, value as string);\n if ((PATH_LIST_OPTIONS as readonly string[]).includes(name))\n return (value as string[]).map((path) => resolve(base, path));\n return NUMBER_OPTIONS.has(name) ? String(value) : value;\n}\n\nasync function readManifest(path: string): Promise<RunValues> {\n const stat = await lstat(path);\n if (!stat.isFile() || stat.size > FILE_LIMIT)\n fieldError(\"$\", \"use a regular, non-symlink JSON file of at most 64 KiB\");\n const source = await readFile(path, \"utf8\");\n let value: unknown;\n try {\n value = JSON.parse(source);\n } catch (cause) {\n throw new Error(\"run manifest $: invalid JSON; check the JSON syntax\", {\n cause,\n });\n }\n const settings = manifestSettings(value);\n const base = dirname(await realpath(path));\n const resolved: Record<string, unknown> = {};\n for (const [name, setting] of Object.entries(settings)) {\n validateSetting(name, setting);\n resolved[name] = resolvedSetting(name, setting, base);\n }\n return resolved;\n}\n\n/** Explicit flags replace saved selections and lists; defaults are applied later. */\nexport async function savedRunValues(explicit: RunValues): Promise<RunValues> {\n const file = explicit[\"run-manifest-file\"];\n if (!file) return explicit;\n const path = resolve(file);\n try {\n const saved = await readManifest(path);\n overrideRunSelections(saved, explicit);\n return { ...saved, ...explicit };\n } catch (cause) {\n const detail = cause instanceof Error ? cause.message : \"cannot read file\";\n throw new Error(\n `--run-manifest-file ${path}: ${detail}; correct the named field or select a readable manifest`,\n { cause },\n );\n }\n}\n"]}
|