@gpustack/loopwright 0.0.0-stage → 0.0.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/LICENSE +191 -0
- package/README.md +356 -2
- package/bin/loopwright.js +3 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter-v2.d.ts +9 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter-v2.js +122 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter.d.ts +30 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter.js +340 -0
- package/node_modules/@loopwright/agent-pi/dist/admission.d.ts +25 -0
- package/node_modules/@loopwright/agent-pi/dist/admission.js +65 -0
- package/node_modules/@loopwright/agent-pi/dist/artifacts.d.ts +15 -0
- package/node_modules/@loopwright/agent-pi/dist/artifacts.js +76 -0
- package/node_modules/@loopwright/agent-pi/dist/boundary.d.ts +18 -0
- package/node_modules/@loopwright/agent-pi/dist/boundary.js +113 -0
- package/node_modules/@loopwright/agent-pi/dist/broker-channel.d.ts +4 -0
- package/node_modules/@loopwright/agent-pi/dist/broker-channel.js +121 -0
- package/node_modules/@loopwright/agent-pi/dist/candidate.d.ts +96 -0
- package/node_modules/@loopwright/agent-pi/dist/candidate.js +1712 -0
- package/node_modules/@loopwright/agent-pi/dist/capture.d.ts +39 -0
- package/node_modules/@loopwright/agent-pi/dist/capture.js +146 -0
- package/node_modules/@loopwright/agent-pi/dist/cas.d.ts +51 -0
- package/node_modules/@loopwright/agent-pi/dist/cas.js +836 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog-api.d.ts +3 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog-api.js +2 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog.d.ts +39 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog.js +280 -0
- package/node_modules/@loopwright/agent-pi/dist/circuit-breaker-limits.d.ts +9 -0
- package/node_modules/@loopwright/agent-pi/dist/circuit-breaker-limits.js +12 -0
- package/node_modules/@loopwright/agent-pi/dist/containers.d.ts +29 -0
- package/node_modules/@loopwright/agent-pi/dist/containers.js +160 -0
- package/node_modules/@loopwright/agent-pi/dist/context.d.ts +56 -0
- package/node_modules/@loopwright/agent-pi/dist/context.js +351 -0
- package/node_modules/@loopwright/agent-pi/dist/daemon.d.ts +8 -0
- package/node_modules/@loopwright/agent-pi/dist/daemon.js +52 -0
- package/node_modules/@loopwright/agent-pi/dist/deadline.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/deadline.js +18 -0
- package/node_modules/@loopwright/agent-pi/dist/decode-capture.d.ts +39 -0
- package/node_modules/@loopwright/agent-pi/dist/decode-capture.js +287 -0
- package/node_modules/@loopwright/agent-pi/dist/descriptor.d.ts +12 -0
- package/node_modules/@loopwright/agent-pi/dist/descriptor.js +17 -0
- package/node_modules/@loopwright/agent-pi/dist/docker-absence.d.ts +2 -0
- package/node_modules/@loopwright/agent-pi/dist/docker-absence.js +9 -0
- package/node_modules/@loopwright/agent-pi/dist/errors.d.ts +7 -0
- package/node_modules/@loopwright/agent-pi/dist/errors.js +19 -0
- package/node_modules/@loopwright/agent-pi/dist/event-sequence.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/event-sequence.js +64 -0
- package/node_modules/@loopwright/agent-pi/dist/events.d.ts +19 -0
- package/node_modules/@loopwright/agent-pi/dist/events.js +132 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-guard.d.ts +9 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-guard.js +25 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-lease.d.ts +24 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-lease.js +316 -0
- package/node_modules/@loopwright/agent-pi/dist/execution.d.ts +32 -0
- package/node_modules/@loopwright/agent-pi/dist/execution.js +476 -0
- package/node_modules/@loopwright/agent-pi/dist/external-mcp.d.ts +87 -0
- package/node_modules/@loopwright/agent-pi/dist/external-mcp.js +526 -0
- package/node_modules/@loopwright/agent-pi/dist/factory-bootstrap.d.ts +15 -0
- package/node_modules/@loopwright/agent-pi/dist/factory-bootstrap.js +74 -0
- package/node_modules/@loopwright/agent-pi/dist/host-session.d.ts +51 -0
- package/node_modules/@loopwright/agent-pi/dist/host-session.js +2083 -0
- package/node_modules/@loopwright/agent-pi/dist/http-mcp.d.ts +32 -0
- package/node_modules/@loopwright/agent-pi/dist/http-mcp.js +353 -0
- package/node_modules/@loopwright/agent-pi/dist/index.d.ts +7 -0
- package/node_modules/@loopwright/agent-pi/dist/index.js +4 -0
- package/node_modules/@loopwright/agent-pi/dist/lifecycle.d.ts +13 -0
- package/node_modules/@loopwright/agent-pi/dist/lifecycle.js +11 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-process.d.ts +35 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-process.js +92 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-transport.d.ts +25 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-transport.js +63 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp.d.ts +23 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp.js +212 -0
- package/node_modules/@loopwright/agent-pi/dist/operation.d.ts +5 -0
- package/node_modules/@loopwright/agent-pi/dist/operation.js +28 -0
- package/node_modules/@loopwright/agent-pi/dist/policy-v2.d.ts +10 -0
- package/node_modules/@loopwright/agent-pi/dist/policy-v2.js +64 -0
- package/node_modules/@loopwright/agent-pi/dist/policy.d.ts +13 -0
- package/node_modules/@loopwright/agent-pi/dist/policy.js +260 -0
- package/node_modules/@loopwright/agent-pi/dist/preflight.d.ts +60 -0
- package/node_modules/@loopwright/agent-pi/dist/preflight.js +700 -0
- package/node_modules/@loopwright/agent-pi/dist/progress-summary.d.ts +1 -0
- package/node_modules/@loopwright/agent-pi/dist/progress-summary.js +119 -0
- package/node_modules/@loopwright/agent-pi/dist/protocol.d.ts +17 -0
- package/node_modules/@loopwright/agent-pi/dist/protocol.js +131 -0
- package/node_modules/@loopwright/agent-pi/dist/provider.d.ts +62 -0
- package/node_modules/@loopwright/agent-pi/dist/provider.js +217 -0
- package/node_modules/@loopwright/agent-pi/dist/receipt.d.ts +3 -0
- package/node_modules/@loopwright/agent-pi/dist/receipt.js +64 -0
- package/node_modules/@loopwright/agent-pi/dist/recovery.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/recovery.js +188 -0
- package/node_modules/@loopwright/agent-pi/dist/resources.d.ts +13 -0
- package/node_modules/@loopwright/agent-pi/dist/resources.js +81 -0
- package/node_modules/@loopwright/agent-pi/dist/response.d.ts +20 -0
- package/node_modules/@loopwright/agent-pi/dist/response.js +259 -0
- package/node_modules/@loopwright/agent-pi/dist/runtime-profile.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/runtime-profile.js +37 -0
- package/node_modules/@loopwright/agent-pi/dist/sdk-worker.d.ts +14 -0
- package/node_modules/@loopwright/agent-pi/dist/sdk-worker.js +633 -0
- package/node_modules/@loopwright/agent-pi/dist/sender.d.ts +46 -0
- package/node_modules/@loopwright/agent-pi/dist/sender.js +553 -0
- package/node_modules/@loopwright/agent-pi/dist/session-host.d.ts +21 -0
- package/node_modules/@loopwright/agent-pi/dist/session-host.js +315 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot-transfer.d.ts +14 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot-transfer.js +102 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot.d.ts +19 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot.js +121 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-process.d.ts +32 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-process.js +85 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-worker.d.ts +2 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-worker.js +105 -0
- package/node_modules/@loopwright/agent-pi/dist/tools.d.ts +36 -0
- package/node_modules/@loopwright/agent-pi/dist/tools.js +128 -0
- package/node_modules/@loopwright/agent-pi/dist/types-v2.d.ts +71 -0
- package/node_modules/@loopwright/agent-pi/dist/types-v2.js +1 -0
- package/node_modules/@loopwright/agent-pi/dist/types.d.ts +314 -0
- package/node_modules/@loopwright/agent-pi/dist/types.js +1 -0
- package/node_modules/@loopwright/agent-pi/dist/usage.d.ts +18 -0
- package/node_modules/@loopwright/agent-pi/dist/usage.js +314 -0
- package/node_modules/@loopwright/agent-pi/dist/workspace-mcp.d.ts +27 -0
- package/node_modules/@loopwright/agent-pi/dist/workspace-mcp.js +142 -0
- package/node_modules/@loopwright/agent-pi/package.json +24 -0
- package/node_modules/@loopwright/agent-pi/runtime/Dockerfile +8 -0
- package/node_modules/@loopwright/agent-pi/runtime/seccomp.json +1 -0
- package/node_modules/@loopwright/cli/dist/arguments.d.ts +19 -0
- package/node_modules/@loopwright/cli/dist/arguments.js +358 -0
- package/node_modules/@loopwright/cli/dist/closure.d.ts +93 -0
- package/node_modules/@loopwright/cli/dist/closure.js +230 -0
- package/node_modules/@loopwright/cli/dist/draft.d.ts +9 -0
- package/node_modules/@loopwright/cli/dist/draft.js +106 -0
- package/node_modules/@loopwright/cli/dist/failure-matrix.d.ts +9 -0
- package/node_modules/@loopwright/cli/dist/failure-matrix.js +701 -0
- package/node_modules/@loopwright/cli/dist/index.d.ts +6 -0
- package/node_modules/@loopwright/cli/dist/index.js +5 -0
- package/node_modules/@loopwright/cli/dist/main.d.ts +22 -0
- package/node_modules/@loopwright/cli/dist/main.js +1855 -0
- package/node_modules/@loopwright/cli/package.json +16 -0
- package/node_modules/@loopwright/controller/dist/acceptance.d.ts +43 -0
- package/node_modules/@loopwright/controller/dist/acceptance.js +446 -0
- package/node_modules/@loopwright/controller/dist/benchmark-gate.d.ts +273 -0
- package/node_modules/@loopwright/controller/dist/benchmark-gate.js +3147 -0
- package/node_modules/@loopwright/controller/dist/budget-observations.d.ts +25 -0
- package/node_modules/@loopwright/controller/dist/budget-observations.js +139 -0
- package/node_modules/@loopwright/controller/dist/bundle.d.ts +26 -0
- package/node_modules/@loopwright/controller/dist/bundle.js +64 -0
- package/node_modules/@loopwright/controller/dist/capture.d.ts +89 -0
- package/node_modules/@loopwright/controller/dist/capture.js +587 -0
- package/node_modules/@loopwright/controller/dist/compile.d.ts +3 -0
- package/node_modules/@loopwright/controller/dist/compile.js +402 -0
- package/node_modules/@loopwright/controller/dist/config.d.ts +22 -0
- package/node_modules/@loopwright/controller/dist/config.js +255 -0
- package/node_modules/@loopwright/controller/dist/controller.d.ts +177 -0
- package/node_modules/@loopwright/controller/dist/controller.js +2135 -0
- package/node_modules/@loopwright/controller/dist/credentials.d.ts +29 -0
- package/node_modules/@loopwright/controller/dist/credentials.js +189 -0
- package/node_modules/@loopwright/controller/dist/deadlines.d.ts +18 -0
- package/node_modules/@loopwright/controller/dist/deadlines.js +71 -0
- package/node_modules/@loopwright/controller/dist/errors.d.ts +27 -0
- package/node_modules/@loopwright/controller/dist/errors.js +41 -0
- package/node_modules/@loopwright/controller/dist/events.d.ts +52 -0
- package/node_modules/@loopwright/controller/dist/events.js +228 -0
- package/node_modules/@loopwright/controller/dist/files.d.ts +51 -0
- package/node_modules/@loopwright/controller/dist/files.js +386 -0
- package/node_modules/@loopwright/controller/dist/finalize.d.ts +25 -0
- package/node_modules/@loopwright/controller/dist/finalize.js +32 -0
- package/node_modules/@loopwright/controller/dist/gate.d.ts +84 -0
- package/node_modules/@loopwright/controller/dist/gate.js +640 -0
- package/node_modules/@loopwright/controller/dist/git-objects.d.ts +11 -0
- package/node_modules/@loopwright/controller/dist/git-objects.js +59 -0
- package/node_modules/@loopwright/controller/dist/git-reader.d.ts +17 -0
- package/node_modules/@loopwright/controller/dist/git-reader.js +40 -0
- package/node_modules/@loopwright/controller/dist/handlers.d.ts +6 -0
- package/node_modules/@loopwright/controller/dist/handlers.js +45 -0
- package/node_modules/@loopwright/controller/dist/handoff.d.ts +71 -0
- package/node_modules/@loopwright/controller/dist/handoff.js +554 -0
- package/node_modules/@loopwright/controller/dist/index.d.ts +41 -0
- package/node_modules/@loopwright/controller/dist/index.js +21 -0
- package/node_modules/@loopwright/controller/dist/inspect.d.ts +30 -0
- package/node_modules/@loopwright/controller/dist/inspect.js +372 -0
- package/node_modules/@loopwright/controller/dist/interpolation.d.ts +9 -0
- package/node_modules/@loopwright/controller/dist/interpolation.js +79 -0
- package/node_modules/@loopwright/controller/dist/ownership.d.ts +41 -0
- package/node_modules/@loopwright/controller/dist/ownership.js +666 -0
- package/node_modules/@loopwright/controller/dist/parser.d.ts +5 -0
- package/node_modules/@loopwright/controller/dist/parser.js +200 -0
- package/node_modules/@loopwright/controller/dist/progress.d.ts +41 -0
- package/node_modules/@loopwright/controller/dist/progress.js +904 -0
- package/node_modules/@loopwright/controller/dist/publication.d.ts +60 -0
- package/node_modules/@loopwright/controller/dist/publication.js +329 -0
- package/node_modules/@loopwright/controller/dist/reconcile.d.ts +26 -0
- package/node_modules/@loopwright/controller/dist/reconcile.js +1378 -0
- package/node_modules/@loopwright/controller/dist/recovery.d.ts +10 -0
- package/node_modules/@loopwright/controller/dist/recovery.js +315 -0
- package/node_modules/@loopwright/controller/dist/refusal-record.d.ts +43 -0
- package/node_modules/@loopwright/controller/dist/refusal-record.js +150 -0
- package/node_modules/@loopwright/controller/dist/registry.d.ts +6 -0
- package/node_modules/@loopwright/controller/dist/registry.js +374 -0
- package/node_modules/@loopwright/controller/dist/repair.d.ts +31 -0
- package/node_modules/@loopwright/controller/dist/repair.js +102 -0
- package/node_modules/@loopwright/controller/dist/report.d.ts +64 -0
- package/node_modules/@loopwright/controller/dist/report.js +596 -0
- package/node_modules/@loopwright/controller/dist/retained.d.ts +284 -0
- package/node_modules/@loopwright/controller/dist/retained.js +193 -0
- package/node_modules/@loopwright/controller/dist/rules.d.ts +31 -0
- package/node_modules/@loopwright/controller/dist/rules.js +110 -0
- package/node_modules/@loopwright/controller/dist/run-eval.d.ts +115 -0
- package/node_modules/@loopwright/controller/dist/run-eval.js +959 -0
- package/node_modules/@loopwright/controller/dist/scheduler.d.ts +10 -0
- package/node_modules/@loopwright/controller/dist/scheduler.js +41 -0
- package/node_modules/@loopwright/controller/dist/schema.d.ts +17 -0
- package/node_modules/@loopwright/controller/dist/schema.js +78 -0
- package/node_modules/@loopwright/controller/dist/source.d.ts +69 -0
- package/node_modules/@loopwright/controller/dist/source.js +872 -0
- package/node_modules/@loopwright/controller/dist/step.d.ts +38 -0
- package/node_modules/@loopwright/controller/dist/step.js +1776 -0
- package/node_modules/@loopwright/controller/dist/storage.d.ts +90 -0
- package/node_modules/@loopwright/controller/dist/storage.js +1345 -0
- package/node_modules/@loopwright/controller/dist/submission.d.ts +51 -0
- package/node_modules/@loopwright/controller/dist/submission.js +292 -0
- package/node_modules/@loopwright/controller/dist/types.d.ts +585 -0
- package/node_modules/@loopwright/controller/dist/types.js +9 -0
- package/node_modules/@loopwright/controller/dist/verification.d.ts +124 -0
- package/node_modules/@loopwright/controller/dist/verification.js +1308 -0
- package/node_modules/@loopwright/controller/dist/verifier-protocol.d.ts +105 -0
- package/node_modules/@loopwright/controller/dist/verifier-protocol.js +1312 -0
- package/node_modules/@loopwright/controller/dist/verifier-worker.d.ts +1 -0
- package/node_modules/@loopwright/controller/dist/verifier-worker.js +33 -0
- package/node_modules/@loopwright/controller/package.json +12 -0
- package/node_modules/@loopwright/core/dist/acceptance.d.ts +108 -0
- package/node_modules/@loopwright/core/dist/acceptance.js +327 -0
- package/node_modules/@loopwright/core/dist/artifacts.d.ts +63 -0
- package/node_modules/@loopwright/core/dist/artifacts.js +356 -0
- package/node_modules/@loopwright/core/dist/boundary.d.ts +21 -0
- package/node_modules/@loopwright/core/dist/boundary.js +484 -0
- package/node_modules/@loopwright/core/dist/contracts.d.ts +287 -0
- package/node_modules/@loopwright/core/dist/contracts.js +694 -0
- package/node_modules/@loopwright/core/dist/diagnostics.d.ts +21 -0
- package/node_modules/@loopwright/core/dist/diagnostics.js +51 -0
- package/node_modules/@loopwright/core/dist/evidence.d.ts +92 -0
- package/node_modules/@loopwright/core/dist/evidence.js +85 -0
- package/node_modules/@loopwright/core/dist/graph.d.ts +8 -0
- package/node_modules/@loopwright/core/dist/graph.js +44 -0
- package/node_modules/@loopwright/core/dist/identity.d.ts +162 -0
- package/node_modules/@loopwright/core/dist/identity.js +80 -0
- package/node_modules/@loopwright/core/dist/index.d.ts +30 -0
- package/node_modules/@loopwright/core/dist/index.js +39 -0
- package/node_modules/@loopwright/core/dist/limits.d.ts +99 -0
- package/node_modules/@loopwright/core/dist/limits.js +59 -0
- package/node_modules/@loopwright/core/dist/results.d.ts +161 -0
- package/node_modules/@loopwright/core/dist/results.js +98 -0
- package/node_modules/@loopwright/core/dist/scope.d.ts +13 -0
- package/node_modules/@loopwright/core/dist/scope.js +154 -0
- package/node_modules/@loopwright/core/dist/scrubber.d.ts +13 -0
- package/node_modules/@loopwright/core/dist/scrubber.js +63 -0
- package/node_modules/@loopwright/core/dist/usage.d.ts +68 -0
- package/node_modules/@loopwright/core/dist/usage.js +56 -0
- package/node_modules/@loopwright/core/package.json +12 -0
- package/node_modules/@loopwright/decisions/dist/benchmark.d.ts +23 -0
- package/node_modules/@loopwright/decisions/dist/benchmark.js +337 -0
- package/node_modules/@loopwright/decisions/dist/client.d.ts +74 -0
- package/node_modules/@loopwright/decisions/dist/client.js +292 -0
- package/node_modules/@loopwright/decisions/dist/index.d.ts +15 -0
- package/node_modules/@loopwright/decisions/dist/index.js +8 -0
- package/node_modules/@loopwright/decisions/dist/nodes.d.ts +63 -0
- package/node_modules/@loopwright/decisions/dist/nodes.js +282 -0
- package/node_modules/@loopwright/decisions/dist/primitives.d.ts +36 -0
- package/node_modules/@loopwright/decisions/dist/primitives.js +300 -0
- package/node_modules/@loopwright/decisions/dist/redaction.d.ts +23 -0
- package/node_modules/@loopwright/decisions/dist/redaction.js +146 -0
- package/node_modules/@loopwright/decisions/dist/router.d.ts +55 -0
- package/node_modules/@loopwright/decisions/dist/router.js +248 -0
- package/node_modules/@loopwright/decisions/dist/schema.d.ts +25 -0
- package/node_modules/@loopwright/decisions/dist/schema.js +536 -0
- package/node_modules/@loopwright/decisions/dist/types.d.ts +394 -0
- package/node_modules/@loopwright/decisions/dist/types.js +80 -0
- package/node_modules/@loopwright/decisions/package.json +12 -0
- package/node_modules/@loopwright/github-app/dist/action.d.ts +90 -0
- package/node_modules/@loopwright/github-app/dist/action.js +2429 -0
- package/node_modules/@loopwright/github-app/dist/config.d.ts +23 -0
- package/node_modules/@loopwright/github-app/dist/config.js +297 -0
- package/node_modules/@loopwright/github-app/dist/digests.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/digests.js +1 -0
- package/node_modules/@loopwright/github-app/dist/index.d.ts +14 -0
- package/node_modules/@loopwright/github-app/dist/index.js +13 -0
- package/node_modules/@loopwright/github-app/dist/models-config.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/models-config.js +1 -0
- package/node_modules/@loopwright/github-app/dist/output-format.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/output-format.js +1 -0
- package/node_modules/@loopwright/github-app/dist/preflight.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/preflight.js +1 -0
- package/node_modules/@loopwright/github-app/dist/publisher.d.ts +58 -0
- package/node_modules/@loopwright/github-app/dist/publisher.js +1368 -0
- package/node_modules/@loopwright/github-app/dist/qualification.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/qualification.js +1 -0
- package/node_modules/@loopwright/github-app/dist/sandbox.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/sandbox.js +1 -0
- package/node_modules/@loopwright/github-app/dist/schema.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/schema.js +1 -0
- package/node_modules/@loopwright/github-app/dist/service.d.ts +52 -0
- package/node_modules/@loopwright/github-app/dist/service.js +1658 -0
- package/node_modules/@loopwright/github-app/dist/suite-pr-lookup.d.ts +90 -0
- package/node_modules/@loopwright/github-app/dist/suite-pr-lookup.js +392 -0
- package/node_modules/@loopwright/github-app/dist/taskpack.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/taskpack.js +1 -0
- package/node_modules/@loopwright/github-app/dist/tenant-queue.d.ts +44 -0
- package/node_modules/@loopwright/github-app/dist/tenant-queue.js +423 -0
- package/node_modules/@loopwright/github-app/dist/token-broker.d.ts +50 -0
- package/node_modules/@loopwright/github-app/dist/token-broker.js +262 -0
- package/node_modules/@loopwright/github-app/dist/turnkey-memory.d.ts +35 -0
- package/node_modules/@loopwright/github-app/dist/turnkey-memory.js +1654 -0
- package/node_modules/@loopwright/github-app/dist/turnkey.d.ts +16 -0
- package/node_modules/@loopwright/github-app/dist/turnkey.js +34 -0
- package/node_modules/@loopwright/github-app/dist/types.d.ts +220 -0
- package/node_modules/@loopwright/github-app/dist/types.js +14 -0
- package/node_modules/@loopwright/github-app/dist/upstreams.d.ts +13 -0
- package/node_modules/@loopwright/github-app/dist/upstreams.js +65 -0
- package/node_modules/@loopwright/github-app/dist/webhook.d.ts +34 -0
- package/node_modules/@loopwright/github-app/dist/webhook.js +241 -0
- package/node_modules/@loopwright/github-app/dist/yaml.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/yaml.js +1 -0
- package/node_modules/@loopwright/github-app/package.json +12 -0
- package/node_modules/@loopwright/hardware-runner/dist/config.d.ts +48 -0
- package/node_modules/@loopwright/hardware-runner/dist/config.js +719 -0
- package/node_modules/@loopwright/hardware-runner/dist/evaluator.d.ts +230 -0
- package/node_modules/@loopwright/hardware-runner/dist/evaluator.js +3178 -0
- package/node_modules/@loopwright/hardware-runner/dist/index.d.ts +13 -0
- package/node_modules/@loopwright/hardware-runner/dist/index.js +9 -0
- package/node_modules/@loopwright/hardware-runner/dist/provenance.d.ts +128 -0
- package/node_modules/@loopwright/hardware-runner/dist/provenance.js +1500 -0
- package/node_modules/@loopwright/hardware-runner/dist/queue.d.ts +81 -0
- package/node_modules/@loopwright/hardware-runner/dist/queue.js +1081 -0
- package/node_modules/@loopwright/hardware-runner/dist/relay-server.d.ts +13 -0
- package/node_modules/@loopwright/hardware-runner/dist/relay-server.js +2997 -0
- package/node_modules/@loopwright/hardware-runner/dist/types.d.ts +239 -0
- package/node_modules/@loopwright/hardware-runner/dist/types.js +12 -0
- package/node_modules/@loopwright/hardware-runner/dist/worker.d.ts +49 -0
- package/node_modules/@loopwright/hardware-runner/dist/worker.js +1646 -0
- package/node_modules/@loopwright/hardware-runner/package.json +12 -0
- package/node_modules/@loopwright/memory/dist/cas.d.ts +21 -0
- package/node_modules/@loopwright/memory/dist/cas.js +510 -0
- package/node_modules/@loopwright/memory/dist/compaction.d.ts +18 -0
- package/node_modules/@loopwright/memory/dist/compaction.js +110 -0
- package/node_modules/@loopwright/memory/dist/finalizer.d.ts +23 -0
- package/node_modules/@loopwright/memory/dist/finalizer.js +538 -0
- package/node_modules/@loopwright/memory/dist/index.d.ts +9 -0
- package/node_modules/@loopwright/memory/dist/index.js +8 -0
- package/node_modules/@loopwright/memory/dist/schema.d.ts +36 -0
- package/node_modules/@loopwright/memory/dist/schema.js +510 -0
- package/node_modules/@loopwright/memory/dist/selector.d.ts +7 -0
- package/node_modules/@loopwright/memory/dist/selector.js +157 -0
- package/node_modules/@loopwright/memory/dist/store.d.ts +51 -0
- package/node_modules/@loopwright/memory/dist/store.js +554 -0
- package/node_modules/@loopwright/memory/dist/types.d.ts +442 -0
- package/node_modules/@loopwright/memory/dist/types.js +8 -0
- package/node_modules/@loopwright/memory/dist/verifier.d.ts +5 -0
- package/node_modules/@loopwright/memory/dist/verifier.js +328 -0
- package/node_modules/@loopwright/memory/package.json +12 -0
- package/node_modules/@loopwright/state/dist/admission.d.ts +321 -0
- package/node_modules/@loopwright/state/dist/admission.js +199 -0
- package/node_modules/@loopwright/state/dist/boundary.d.ts +53 -0
- package/node_modules/@loopwright/state/dist/boundary.js +194 -0
- package/node_modules/@loopwright/state/dist/checkpoint.d.ts +16 -0
- package/node_modules/@loopwright/state/dist/checkpoint.js +84 -0
- package/node_modules/@loopwright/state/dist/clock.d.ts +8 -0
- package/node_modules/@loopwright/state/dist/clock.js +27 -0
- package/node_modules/@loopwright/state/dist/connection.d.ts +55 -0
- package/node_modules/@loopwright/state/dist/connection.js +391 -0
- package/node_modules/@loopwright/state/dist/errors.d.ts +13 -0
- package/node_modules/@loopwright/state/dist/errors.js +34 -0
- package/node_modules/@loopwright/state/dist/index.d.ts +3 -0
- package/node_modules/@loopwright/state/dist/index.js +1 -0
- package/node_modules/@loopwright/state/dist/journal.d.ts +119 -0
- package/node_modules/@loopwright/state/dist/journal.js +72 -0
- package/node_modules/@loopwright/state/dist/model.d.ts +40 -0
- package/node_modules/@loopwright/state/dist/model.js +58 -0
- package/node_modules/@loopwright/state/dist/ownership.d.ts +14 -0
- package/node_modules/@loopwright/state/dist/ownership.js +45 -0
- package/node_modules/@loopwright/state/dist/pages.d.ts +11 -0
- package/node_modules/@loopwright/state/dist/pages.js +41 -0
- package/node_modules/@loopwright/state/dist/receipts.d.ts +33 -0
- package/node_modules/@loopwright/state/dist/receipts.js +97 -0
- package/node_modules/@loopwright/state/dist/schema.d.ts +28 -0
- package/node_modules/@loopwright/state/dist/schema.js +41 -0
- package/node_modules/@loopwright/state/dist/settlement.d.ts +10 -0
- package/node_modules/@loopwright/state/dist/settlement.js +129 -0
- package/node_modules/@loopwright/state/dist/store.d.ts +52 -0
- package/node_modules/@loopwright/state/dist/store.js +100 -0
- package/node_modules/@loopwright/state/dist/types.d.ts +315 -0
- package/node_modules/@loopwright/state/dist/types.js +1 -0
- package/node_modules/@loopwright/state/package.json +12 -0
- package/node_modules/@loopwright/taskpack/dist/baseline-align.d.ts +195 -0
- package/node_modules/@loopwright/taskpack/dist/baseline-align.js +1847 -0
- package/node_modules/@loopwright/taskpack/dist/digests.d.ts +61 -0
- package/node_modules/@loopwright/taskpack/dist/digests.js +715 -0
- package/node_modules/@loopwright/taskpack/dist/index.d.ts +18 -0
- package/node_modules/@loopwright/taskpack/dist/index.js +17 -0
- package/node_modules/@loopwright/taskpack/dist/models-config.d.ts +112 -0
- package/node_modules/@loopwright/taskpack/dist/models-config.js +1026 -0
- package/node_modules/@loopwright/taskpack/dist/output-format.d.ts +28 -0
- package/node_modules/@loopwright/taskpack/dist/output-format.js +157 -0
- package/node_modules/@loopwright/taskpack/dist/preflight.d.ts +130 -0
- package/node_modules/@loopwright/taskpack/dist/preflight.js +1497 -0
- package/node_modules/@loopwright/taskpack/dist/qualification.d.ts +23 -0
- package/node_modules/@loopwright/taskpack/dist/qualification.js +120 -0
- package/node_modules/@loopwright/taskpack/dist/sandbox.d.ts +121 -0
- package/node_modules/@loopwright/taskpack/dist/sandbox.js +2605 -0
- package/node_modules/@loopwright/taskpack/dist/schema.d.ts +197 -0
- package/node_modules/@loopwright/taskpack/dist/schema.js +4189 -0
- package/node_modules/@loopwright/taskpack/dist/scrubber.d.ts +47 -0
- package/node_modules/@loopwright/taskpack/dist/scrubber.js +283 -0
- package/node_modules/@loopwright/taskpack/dist/suite.d.ts +124 -0
- package/node_modules/@loopwright/taskpack/dist/suite.js +3256 -0
- package/node_modules/@loopwright/taskpack/dist/taskpack.d.ts +154 -0
- package/node_modules/@loopwright/taskpack/dist/taskpack.js +3634 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey-memory.d.ts +122 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey-memory.js +483 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey.d.ts +437 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey.js +7313 -0
- package/node_modules/@loopwright/taskpack/dist/types.d.ts +1274 -0
- package/node_modules/@loopwright/taskpack/dist/types.js +99 -0
- package/node_modules/@loopwright/taskpack/dist/upstreams.d.ts +261 -0
- package/node_modules/@loopwright/taskpack/dist/upstreams.js +2242 -0
- package/node_modules/@loopwright/taskpack/dist/yaml.d.ts +18 -0
- package/node_modules/@loopwright/taskpack/dist/yaml.js +167 -0
- package/node_modules/@loopwright/taskpack/package.json +12 -0
- package/node_modules/@loopwright/taskpack-runner/dist/compile-taskpack.d.ts +137 -0
- package/node_modules/@loopwright/taskpack-runner/dist/compile-taskpack.js +474 -0
- package/node_modules/@loopwright/taskpack-runner/dist/corpus.d.ts +8 -0
- package/node_modules/@loopwright/taskpack-runner/dist/corpus.js +129 -0
- package/node_modules/@loopwright/taskpack-runner/dist/index.d.ts +13 -0
- package/node_modules/@loopwright/taskpack-runner/dist/index.js +7 -0
- package/node_modules/@loopwright/taskpack-runner/dist/intake.d.ts +149 -0
- package/node_modules/@loopwright/taskpack-runner/dist/intake.js +135 -0
- package/node_modules/@loopwright/taskpack-runner/dist/parity.d.ts +130 -0
- package/node_modules/@loopwright/taskpack-runner/dist/parity.js +927 -0
- package/node_modules/@loopwright/taskpack-runner/dist/python-bridge.d.ts +68 -0
- package/node_modules/@loopwright/taskpack-runner/dist/python-bridge.js +517 -0
- package/node_modules/@loopwright/taskpack-runner/dist/service.d.ts +149 -0
- package/node_modules/@loopwright/taskpack-runner/dist/service.js +1796 -0
- package/node_modules/@loopwright/taskpack-runner/dist/types.d.ts +29 -0
- package/node_modules/@loopwright/taskpack-runner/dist/types.js +11 -0
- package/node_modules/@loopwright/taskpack-runner/package.json +12 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/README.md +77 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/docs/support-records.md +57 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/docs/supported-runners.md +98 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/manifest.json +205 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/expand_matrix.sh +273 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/matrix.yaml +280 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/resolve_dockerfile.sh +24 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pyproject.toml +46 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/runtime_runner/runner.py.json +5270 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/discovery/legacy-support.md +86 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/github/service.py +401 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/proposals/analysis.json +95 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/proposals/ready.json +109 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_assemble.py +263 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_check_draft.py +333 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_checks.py +1099 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_discovery.py +817 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_proposal.py +658 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_publish.py +987 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_summary.py +107 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/agent.py +610 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/assemble.py +84 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/check_draft.py +94 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/checks.py +1002 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/discovery.py +789 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/model.py +557 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/progress.py +174 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/analysis.md +40 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/proposal.md +65 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/repair.md +17 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/proposal.py +903 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/publish.py +997 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/summary.py +131 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/tool-versions.json +133 -0
- package/node_modules/package-lock.json +3021 -0
- package/package-lock.json +3021 -0
- package/package.json +52 -4
|
@@ -0,0 +1,700 @@
|
|
|
1
|
+
import { lstatSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { lstat, realpath } from 'node:fs/promises';
|
|
3
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
4
|
+
import { types } from 'node:util';
|
|
5
|
+
import { LIMITS, OVERLAY_LIMITS, validateDocument, digestArtifact, digestArtifactFromMetadata } from '@loopwright/core';
|
|
6
|
+
import { canonical, freeze, id, integer, list, object, snapshot, text } from './boundary.js';
|
|
7
|
+
import { gitBlobOid, resolveCandidateOverlayLimits } from './candidate.js';
|
|
8
|
+
import { checkOwnerAndMode, RAW_AGGREGATE_MAX_BYTES, RAW_ARTIFACT_MAX_BYTES, verifyRegularFileAsync, verifyRegularFileSync } from './cas.js';
|
|
9
|
+
import { PiFailure, refuse } from './errors.js';
|
|
10
|
+
import { sameIdentity, validateDigest, validatePolicy } from './policy.js';
|
|
11
|
+
import { PREAMBLE_IDENTITY, decodePromptResourceUtf8, systemPrompt } from './resources.js';
|
|
12
|
+
function toResourceIdentity(resource) {
|
|
13
|
+
return {
|
|
14
|
+
id: resource.id,
|
|
15
|
+
kind: resource.kind,
|
|
16
|
+
path: resource.path,
|
|
17
|
+
digest: resource.digest,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const typedArray = Object.getPrototypeOf(Uint8Array.prototype);
|
|
21
|
+
const intrinsic = (name) => Object.getOwnPropertyDescriptor(typedArray, name).get;
|
|
22
|
+
function byteView(input, path) {
|
|
23
|
+
if (!ArrayBuffer.isView(input) || types.isProxy(input))
|
|
24
|
+
refuse('INPUT_INVALID', path);
|
|
25
|
+
const prototype = Object.getPrototypeOf(input);
|
|
26
|
+
if (prototype !== Uint8Array.prototype && prototype !== Buffer.prototype)
|
|
27
|
+
refuse('INPUT_INVALID', path);
|
|
28
|
+
const buffer = intrinsic('buffer').call(input);
|
|
29
|
+
if (types.isSharedArrayBuffer(buffer))
|
|
30
|
+
refuse('INPUT_INVALID', path);
|
|
31
|
+
const length = intrinsic('byteLength').call(input);
|
|
32
|
+
if (length > RAW_ARTIFACT_MAX_BYTES)
|
|
33
|
+
refuse('OUTPUT_LIMIT', path);
|
|
34
|
+
return new Uint8Array(buffer, intrinsic('byteOffset').call(input), length);
|
|
35
|
+
}
|
|
36
|
+
function parseCandidateArtifactRaw(item, path) {
|
|
37
|
+
if (!item || typeof item !== 'object' || types.isProxy(item))
|
|
38
|
+
refuse('INPUT_INVALID', path);
|
|
39
|
+
const proto = Object.getPrototypeOf(item);
|
|
40
|
+
if (proto !== Object.prototype && proto !== null)
|
|
41
|
+
refuse('INPUT_INVALID', path);
|
|
42
|
+
const keys = Reflect.ownKeys(item);
|
|
43
|
+
if (keys.some(key => typeof key !== 'string'))
|
|
44
|
+
refuse('INPUT_INVALID', path);
|
|
45
|
+
const hasBytes = keys.includes('bytes');
|
|
46
|
+
const hasBlobPath = keys.includes('blobPath');
|
|
47
|
+
if (hasBytes && hasBlobPath)
|
|
48
|
+
refuse('INPUT_INVALID', path);
|
|
49
|
+
if (hasBytes) {
|
|
50
|
+
return { kind: 'raw', raw: object(item, ['name', 'bytes'], path) };
|
|
51
|
+
}
|
|
52
|
+
if (hasBlobPath) {
|
|
53
|
+
return { kind: 'blob', raw: object(item, ['name', 'byteLength', 'digest', 'blobPath'], path) };
|
|
54
|
+
}
|
|
55
|
+
refuse('INPUT_INVALID', path);
|
|
56
|
+
}
|
|
57
|
+
function snapshotRawBaseline(rawBaselineInput) {
|
|
58
|
+
const rawBaseline = object(rawBaselineInput, ['directory', 'entries'], '/candidate/baseline');
|
|
59
|
+
const directory = text(rawBaseline.directory, '/candidate/baseline/directory', 1024);
|
|
60
|
+
if (!isAbsolute(directory) || /[\0\r\n]/.test(directory))
|
|
61
|
+
refuse('INPUT_INVALID', '/candidate/baseline/directory');
|
|
62
|
+
const rawEntries = rawBaseline.entries;
|
|
63
|
+
if (!Array.isArray(rawEntries) || types.isProxy(rawEntries) || Object.getPrototypeOf(rawEntries) !== Array.prototype) {
|
|
64
|
+
refuse('INPUT_INVALID', '/candidate/baseline/entries');
|
|
65
|
+
}
|
|
66
|
+
const entryCount = Object.getOwnPropertyDescriptor(rawEntries, 'length').value;
|
|
67
|
+
if (entryCount > LIMITS.baselineEntries || Reflect.ownKeys(rawEntries).length !== entryCount + 1) {
|
|
68
|
+
refuse('INPUT_INVALID', '/candidate/baseline/entries');
|
|
69
|
+
}
|
|
70
|
+
const entries = [];
|
|
71
|
+
for (let i = 0; i < entryCount; i++) {
|
|
72
|
+
const entryPath = '/candidate/baseline/entries/' + i;
|
|
73
|
+
const descriptor = Object.getOwnPropertyDescriptor(rawEntries, String(i));
|
|
74
|
+
if (!descriptor || !descriptor.enumerable || !('value' in descriptor))
|
|
75
|
+
refuse('INPUT_INVALID', entryPath);
|
|
76
|
+
const item = object(descriptor.value, ['name', 'mode', 'oid', 'byteLength'], entryPath);
|
|
77
|
+
if (typeof item.name !== 'string')
|
|
78
|
+
refuse('INPUT_INVALID', entryPath + '/name');
|
|
79
|
+
if (typeof item.mode !== 'string')
|
|
80
|
+
refuse('INPUT_INVALID', entryPath + '/mode');
|
|
81
|
+
if (typeof item.oid !== 'string')
|
|
82
|
+
refuse('INPUT_INVALID', entryPath + '/oid');
|
|
83
|
+
if (typeof item.byteLength !== 'number')
|
|
84
|
+
refuse('INPUT_INVALID', entryPath + '/byteLength');
|
|
85
|
+
entries.push(Object.freeze({ name: item.name, mode: item.mode, oid: item.oid, byteLength: item.byteLength }));
|
|
86
|
+
}
|
|
87
|
+
return Object.freeze({ directory, entries: Object.freeze(entries) });
|
|
88
|
+
}
|
|
89
|
+
function validateSnapshottedBaselineStructure(snapshotted, baseTree, manifestDeleted) {
|
|
90
|
+
const oidPattern = baseTree.objectFormat === 'sha1' ? /^[0-9a-f]{40}$/ : /^[0-9a-f]{64}$/;
|
|
91
|
+
const deletedNormSet = new Set(manifestDeleted.map(name => name.normalize('NFC').toLowerCase()));
|
|
92
|
+
const baselineNormSet = new Set();
|
|
93
|
+
const remainingBaselineDirSet = new Set();
|
|
94
|
+
const baselineMap = new Map();
|
|
95
|
+
const frozenEntries = [];
|
|
96
|
+
let prevName = null;
|
|
97
|
+
for (let i = 0; i < snapshotted.entries.length; i++) {
|
|
98
|
+
const entryPath = '/candidate/baseline/entries/' + i;
|
|
99
|
+
const item = snapshotted.entries[i];
|
|
100
|
+
if (!digestArtifact(item.name, new Uint8Array()).ok) {
|
|
101
|
+
refuse('INPUT_INVALID', entryPath + '/name');
|
|
102
|
+
}
|
|
103
|
+
for (const segment of item.name.split('/')) {
|
|
104
|
+
if (segment.toLowerCase() === '.git' || Buffer.byteLength(segment, 'utf8') > 255) {
|
|
105
|
+
refuse('INPUT_INVALID', entryPath + '/name');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (prevName !== null && prevName >= item.name)
|
|
109
|
+
refuse('INPUT_INVALID', entryPath + '/name');
|
|
110
|
+
prevName = item.name;
|
|
111
|
+
const norm = item.name.normalize('NFC').toLowerCase();
|
|
112
|
+
if (baselineNormSet.has(norm))
|
|
113
|
+
refuse('INPUT_INVALID', entryPath + '/name');
|
|
114
|
+
baselineNormSet.add(norm);
|
|
115
|
+
if (item.mode !== '100644' && item.mode !== '100755')
|
|
116
|
+
refuse('INPUT_INVALID', entryPath + '/mode');
|
|
117
|
+
if (!oidPattern.test(item.oid))
|
|
118
|
+
refuse('INPUT_INVALID', entryPath + '/oid');
|
|
119
|
+
const byteLength = integer(item.byteLength, 0, Number.MAX_SAFE_INTEGER, entryPath + '/byteLength');
|
|
120
|
+
const frozenEntry = Object.freeze({ name: item.name, mode: item.mode, oid: item.oid, byteLength });
|
|
121
|
+
frozenEntries.push(frozenEntry);
|
|
122
|
+
baselineMap.set(item.name, frozenEntry);
|
|
123
|
+
if (!deletedNormSet.has(norm)) {
|
|
124
|
+
let slash = norm.indexOf('/');
|
|
125
|
+
while (slash !== -1) {
|
|
126
|
+
remainingBaselineDirSet.add(norm.slice(0, slash));
|
|
127
|
+
slash = norm.indexOf('/', slash + 1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
for (const norm of baselineNormSet) {
|
|
132
|
+
let slash = norm.indexOf('/');
|
|
133
|
+
while (slash !== -1) {
|
|
134
|
+
if (baselineNormSet.has(norm.slice(0, slash)))
|
|
135
|
+
refuse('INPUT_INVALID', '/candidate/baseline/entries');
|
|
136
|
+
slash = norm.indexOf('/', slash + 1);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
frozenBaseline: Object.freeze({ directory: snapshotted.directory, entries: Object.freeze(frozenEntries) }),
|
|
141
|
+
baselineMap,
|
|
142
|
+
baselineNormSet,
|
|
143
|
+
remainingBaselineDirSet,
|
|
144
|
+
deletedNormSet,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function verifyBaselineCrossChecks(baselineCtx, baseTree, manifestEntries, manifestDeleted, artifacts, verifiedBlobOids) {
|
|
148
|
+
const { frozenBaseline, baselineMap, baselineNormSet, remainingBaselineDirSet, deletedNormSet } = baselineCtx;
|
|
149
|
+
for (const deletedPath of manifestDeleted) {
|
|
150
|
+
if (!baselineMap.has(deletedPath))
|
|
151
|
+
refuse('RESOURCE_MISMATCH', '/candidate/manifest/spec/deleted');
|
|
152
|
+
}
|
|
153
|
+
const artifactByName = new Map(artifacts.map(item => [item.name, item]));
|
|
154
|
+
for (const entry of manifestEntries) {
|
|
155
|
+
const baseEntry = baselineMap.get(entry.name);
|
|
156
|
+
if (baseEntry !== undefined) {
|
|
157
|
+
const artifact = artifactByName.get(entry.name);
|
|
158
|
+
if (!artifact)
|
|
159
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts');
|
|
160
|
+
const oid = 'bytes' in artifact
|
|
161
|
+
? gitBlobOid(baseTree.objectFormat, artifact.bytes)
|
|
162
|
+
: verifiedBlobOids.get(entry.name);
|
|
163
|
+
if (!oid || oid === baseEntry.oid) {
|
|
164
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
const entryNorm = entry.name.normalize('NFC').toLowerCase();
|
|
169
|
+
if (baselineNormSet.has(entryNorm) && !deletedNormSet.has(entryNorm)) {
|
|
170
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts');
|
|
171
|
+
}
|
|
172
|
+
if (remainingBaselineDirSet.has(entryNorm)) {
|
|
173
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts');
|
|
174
|
+
}
|
|
175
|
+
let slash = entryNorm.indexOf('/');
|
|
176
|
+
while (slash !== -1) {
|
|
177
|
+
const prefix = entryNorm.slice(0, slash);
|
|
178
|
+
if (baselineNormSet.has(prefix) && !deletedNormSet.has(prefix)) {
|
|
179
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts');
|
|
180
|
+
}
|
|
181
|
+
slash = entryNorm.indexOf('/', slash + 1);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return frozenBaseline;
|
|
186
|
+
}
|
|
187
|
+
function resolveAuthoritativeCasSha256DirSync(hostArtifactsDirectory) {
|
|
188
|
+
if (typeof hostArtifactsDirectory !== 'string' || hostArtifactsDirectory.length === 0 || !isAbsolute(hostArtifactsDirectory) || /[,\r\n\0]/.test(hostArtifactsDirectory)) {
|
|
189
|
+
refuse('INPUT_INVALID', '/host/artifactsDirectory');
|
|
190
|
+
}
|
|
191
|
+
let rootCanonical;
|
|
192
|
+
try {
|
|
193
|
+
const rootStat = lstatSync(hostArtifactsDirectory);
|
|
194
|
+
if (!rootStat.isDirectory() && !rootStat.isSymbolicLink()) {
|
|
195
|
+
refuse('CONTAINMENT_UNAVAILABLE', '/host/artifactsDirectory');
|
|
196
|
+
}
|
|
197
|
+
rootCanonical = realpathSync(hostArtifactsDirectory);
|
|
198
|
+
const canonicalStat = lstatSync(rootCanonical);
|
|
199
|
+
if (!canonicalStat.isDirectory() || canonicalStat.isSymbolicLink() || !checkOwnerAndMode(canonicalStat.uid, canonicalStat.mode, 0o022)) {
|
|
200
|
+
refuse('CONTAINMENT_UNAVAILABLE', '/host/artifactsDirectory');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
if (error instanceof PiFailure)
|
|
205
|
+
throw error;
|
|
206
|
+
refuse('CONTAINMENT_UNAVAILABLE', '/host/artifactsDirectory');
|
|
207
|
+
}
|
|
208
|
+
const blobsDir = join(rootCanonical, 'blobs');
|
|
209
|
+
const sha256Dir = join(blobsDir, 'sha256');
|
|
210
|
+
for (const dir of [blobsDir, sha256Dir]) {
|
|
211
|
+
let dirStat;
|
|
212
|
+
try {
|
|
213
|
+
dirStat = lstatSync(dir);
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts/blobPath');
|
|
217
|
+
}
|
|
218
|
+
if (!dirStat.isDirectory() || dirStat.isSymbolicLink() || !checkOwnerAndMode(dirStat.uid, dirStat.mode, 0o077)) {
|
|
219
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts/blobPath');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return sha256Dir;
|
|
223
|
+
}
|
|
224
|
+
async function resolveAuthoritativeCasSha256DirAsync(hostArtifactsDirectory) {
|
|
225
|
+
if (typeof hostArtifactsDirectory !== 'string' || hostArtifactsDirectory.length === 0 || !isAbsolute(hostArtifactsDirectory) || /[,\r\n\0]/.test(hostArtifactsDirectory)) {
|
|
226
|
+
refuse('INPUT_INVALID', '/host/artifactsDirectory');
|
|
227
|
+
}
|
|
228
|
+
let rootCanonical;
|
|
229
|
+
try {
|
|
230
|
+
const rootStat = await lstat(hostArtifactsDirectory);
|
|
231
|
+
if (!rootStat.isDirectory() && !rootStat.isSymbolicLink()) {
|
|
232
|
+
refuse('CONTAINMENT_UNAVAILABLE', '/host/artifactsDirectory');
|
|
233
|
+
}
|
|
234
|
+
rootCanonical = await realpath(hostArtifactsDirectory);
|
|
235
|
+
const canonicalStat = await lstat(rootCanonical);
|
|
236
|
+
if (!canonicalStat.isDirectory() || canonicalStat.isSymbolicLink() || !checkOwnerAndMode(canonicalStat.uid, canonicalStat.mode, 0o022)) {
|
|
237
|
+
refuse('CONTAINMENT_UNAVAILABLE', '/host/artifactsDirectory');
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
if (error instanceof PiFailure)
|
|
242
|
+
throw error;
|
|
243
|
+
refuse('CONTAINMENT_UNAVAILABLE', '/host/artifactsDirectory');
|
|
244
|
+
}
|
|
245
|
+
const blobsDir = join(rootCanonical, 'blobs');
|
|
246
|
+
const sha256Dir = join(blobsDir, 'sha256');
|
|
247
|
+
for (const dir of [blobsDir, sha256Dir]) {
|
|
248
|
+
let dirStat;
|
|
249
|
+
try {
|
|
250
|
+
dirStat = await lstat(dir);
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts/blobPath');
|
|
254
|
+
}
|
|
255
|
+
if (!dirStat.isDirectory() || dirStat.isSymbolicLink() || !checkOwnerAndMode(dirStat.uid, dirStat.mode, 0o077)) {
|
|
256
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts/blobPath');
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return sha256Dir;
|
|
260
|
+
}
|
|
261
|
+
export function snapshotOpenInputSync(input, expectedVersion = 1) {
|
|
262
|
+
const top = object(input, ['version', 'lock', 'roleId', 'stepId', 'sessionId', 'policy', 'candidate', 'resources', 'restore']);
|
|
263
|
+
const hasBaselineKey = top.candidate !== null && typeof top.candidate === 'object' && !types.isProxy(top.candidate) && Object.hasOwn(top.candidate, 'baseline');
|
|
264
|
+
const candidate = object(top.candidate, hasBaselineKey ? ['manifest', 'baseRevision', 'sourceRevision', 'artifacts', 'baseline'] : ['manifest', 'baseRevision', 'sourceRevision', 'artifacts'], '/candidate');
|
|
265
|
+
const parsedArtifacts = list(candidate.artifacts, 16_384, '/candidate/artifacts').map((item, index) => parseCandidateArtifactRaw(item, '/candidate/artifacts/' + index));
|
|
266
|
+
const resources = list(top.resources, 128, '/resources').map((item, index) => object(item, ['id', 'kind', 'ref', 'bytes'], '/resources/' + index));
|
|
267
|
+
const restore = top.restore === null ? null : object(top.restore, ['checkpointId', 'workspace', 'session'], '/restore');
|
|
268
|
+
const workspace = restore ? object(restore.workspace, ['ref', 'bytes'], '/restore/workspace') : null;
|
|
269
|
+
const session = restore ? object(restore.session, ['ref', 'bytes'], '/restore/session') : null;
|
|
270
|
+
const rawArtifactViews = new Map();
|
|
271
|
+
let rawBytesSum = 0;
|
|
272
|
+
parsedArtifacts.forEach((entry, index) => {
|
|
273
|
+
if (entry.kind === 'raw') {
|
|
274
|
+
const view = byteView(entry.raw.bytes, '/artifacts/' + index);
|
|
275
|
+
rawBytesSum += view.byteLength;
|
|
276
|
+
if (rawBytesSum > RAW_AGGREGATE_MAX_BYTES)
|
|
277
|
+
refuse('OUTPUT_LIMIT', '/artifacts');
|
|
278
|
+
rawArtifactViews.set(index, view);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
const resourceViews = resources.map((item, index) => {
|
|
282
|
+
const view = byteView(item.bytes, '/resources/' + index);
|
|
283
|
+
rawBytesSum += view.byteLength;
|
|
284
|
+
if (rawBytesSum > RAW_AGGREGATE_MAX_BYTES)
|
|
285
|
+
refuse('OUTPUT_LIMIT', '/artifacts');
|
|
286
|
+
return view;
|
|
287
|
+
});
|
|
288
|
+
const workspaceView = workspace ? byteView(workspace.bytes, '/restore/workspace') : null;
|
|
289
|
+
if (workspaceView) {
|
|
290
|
+
rawBytesSum += workspaceView.byteLength;
|
|
291
|
+
if (rawBytesSum > RAW_AGGREGATE_MAX_BYTES)
|
|
292
|
+
refuse('OUTPUT_LIMIT', '/artifacts');
|
|
293
|
+
}
|
|
294
|
+
const sessionView = session ? byteView(session.bytes, '/restore/session') : null;
|
|
295
|
+
if (sessionView) {
|
|
296
|
+
rawBytesSum += sessionView.byteLength;
|
|
297
|
+
if (rawBytesSum > RAW_AGGREGATE_MAX_BYTES)
|
|
298
|
+
refuse('OUTPUT_LIMIT', '/artifacts');
|
|
299
|
+
}
|
|
300
|
+
const baseMeta = snapshot({ version: top.version, lock: top.lock, roleId: top.roleId, stepId: top.stepId, sessionId: top.sessionId, policy: top.policy,
|
|
301
|
+
baseRevision: candidate.baseRevision, sourceRevision: candidate.sourceRevision,
|
|
302
|
+
resources: resources.map(item => ({ id: item.id, kind: item.kind, ref: item.ref })), restore: restore ? { checkpointId: restore.checkpointId, workspace: { ref: workspace.ref }, session: { ref: session.ref } } : null });
|
|
303
|
+
if (baseMeta.version !== expectedVersion)
|
|
304
|
+
refuse('INPUT_INVALID', '/version');
|
|
305
|
+
const checkedLock = validateDocument(baseMeta.lock, 'TaskLock');
|
|
306
|
+
if (!checkedLock.ok)
|
|
307
|
+
refuse('INPUT_INVALID', '/lock');
|
|
308
|
+
const lock = checkedLock.value, contract = lock.spec.contract.spec;
|
|
309
|
+
const overlayLimits = resolveCandidateOverlayLimits(contract.budgets.overlay);
|
|
310
|
+
const hasBlobArtifacts = parsedArtifacts.some(entry => entry.kind === 'blob');
|
|
311
|
+
const candidateSnapshotBounds = overlayLimits.maxFiles > OVERLAY_LIMITS.defaultMaxFiles || hasBlobArtifacts
|
|
312
|
+
? {
|
|
313
|
+
maxArray: Math.max(1024, overlayLimits.maxFiles),
|
|
314
|
+
maxNodes: Math.max(65536, 65536 + overlayLimits.maxFiles * 24),
|
|
315
|
+
maxBytes: Math.max(1048576, overlayLimits.manifestMaxBytes * 2 + parsedArtifacts.length * 1024),
|
|
316
|
+
}
|
|
317
|
+
: undefined;
|
|
318
|
+
const snapshottedManifest = snapshot(candidate.manifest, candidateSnapshotBounds);
|
|
319
|
+
const snapshottedArtifacts = parsedArtifacts.map(entry => snapshot(entry.kind === 'raw'
|
|
320
|
+
? { name: entry.raw.name }
|
|
321
|
+
: {
|
|
322
|
+
name: entry.raw.name,
|
|
323
|
+
byteLength: entry.raw.byteLength,
|
|
324
|
+
digest: entry.raw.digest,
|
|
325
|
+
blobPath: entry.raw.blobPath,
|
|
326
|
+
}));
|
|
327
|
+
const rawArtifactCopies = new Map();
|
|
328
|
+
for (const [index, view] of rawArtifactViews.entries()) {
|
|
329
|
+
const copy = new Uint8Array(view.byteLength);
|
|
330
|
+
copy.set(view);
|
|
331
|
+
rawArtifactCopies.set(index, copy);
|
|
332
|
+
}
|
|
333
|
+
const resourceCopies = resourceViews.map(view => {
|
|
334
|
+
const copy = new Uint8Array(view.byteLength);
|
|
335
|
+
copy.set(view);
|
|
336
|
+
return copy;
|
|
337
|
+
});
|
|
338
|
+
let workspaceCopy = null;
|
|
339
|
+
if (workspaceView) {
|
|
340
|
+
workspaceCopy = new Uint8Array(workspaceView.byteLength);
|
|
341
|
+
workspaceCopy.set(workspaceView);
|
|
342
|
+
}
|
|
343
|
+
let sessionCopy = null;
|
|
344
|
+
if (sessionView) {
|
|
345
|
+
sessionCopy = new Uint8Array(sessionView.byteLength);
|
|
346
|
+
sessionCopy.set(sessionView);
|
|
347
|
+
}
|
|
348
|
+
const snapshottedBaseline = candidate.baseline !== undefined
|
|
349
|
+
? snapshotRawBaseline(candidate.baseline)
|
|
350
|
+
: undefined;
|
|
351
|
+
return {
|
|
352
|
+
baseMeta,
|
|
353
|
+
rawPolicy: baseMeta.policy,
|
|
354
|
+
lock,
|
|
355
|
+
overlayLimits,
|
|
356
|
+
snapshottedManifest,
|
|
357
|
+
snapshottedArtifacts,
|
|
358
|
+
artifactCount: parsedArtifacts.length,
|
|
359
|
+
rawArtifactCopies,
|
|
360
|
+
resourceCopies,
|
|
361
|
+
workspaceCopy,
|
|
362
|
+
sessionCopy,
|
|
363
|
+
snapshottedBaseline,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
export function validateStructuralInputWithPolicy(snapshotted, policyInput) {
|
|
367
|
+
const { baseMeta, lock, overlayLimits, snapshottedManifest, snapshottedArtifacts, artifactCount, rawArtifactCopies, resourceCopies, workspaceCopy, sessionCopy, snapshottedBaseline, } = snapshotted;
|
|
368
|
+
const contract = lock.spec.contract.spec;
|
|
369
|
+
const owned = {
|
|
370
|
+
version: 1,
|
|
371
|
+
lock: baseMeta.lock,
|
|
372
|
+
roleId: baseMeta.roleId,
|
|
373
|
+
stepId: baseMeta.stepId,
|
|
374
|
+
sessionId: baseMeta.sessionId,
|
|
375
|
+
policy: policyInput,
|
|
376
|
+
candidate: {
|
|
377
|
+
manifest: snapshottedManifest,
|
|
378
|
+
baseRevision: baseMeta.baseRevision,
|
|
379
|
+
sourceRevision: baseMeta.sourceRevision,
|
|
380
|
+
artifacts: snapshottedArtifacts,
|
|
381
|
+
},
|
|
382
|
+
resources: baseMeta.resources,
|
|
383
|
+
restore: baseMeta.restore,
|
|
384
|
+
};
|
|
385
|
+
id(owned.roleId, '/roleId');
|
|
386
|
+
id(owned.stepId, '/stepId');
|
|
387
|
+
id(owned.sessionId, '/sessionId');
|
|
388
|
+
const role = contract.roles.find(item => item.id === owned.roleId), step = contract.steps.find(item => item.id === owned.stepId);
|
|
389
|
+
if (!role || !step || step.kind !== 'agent' || step.roleId !== role.id || role.adapter !== 'pi')
|
|
390
|
+
refuse('BINDING_MISMATCH', '/roleId');
|
|
391
|
+
if (contract.budgets.enforcement.tokens === 'hard_admission')
|
|
392
|
+
refuse('CAPABILITY_UNSUPPORTED', '/lock/spec/contract/spec/budgets/enforcement/tokens');
|
|
393
|
+
const policy = validatePolicy(policyInput);
|
|
394
|
+
if (policy.selection.provider !== role.provider || policy.selection.model !== role.model || policy.selection.thinking !== role.thinking)
|
|
395
|
+
refuse('BINDING_MISMATCH', '/policy/selection');
|
|
396
|
+
if (policy.tools.some(name => !role.tools.includes(name)))
|
|
397
|
+
refuse('TOOL_DENIED', '/policy/tools');
|
|
398
|
+
const manifest = validateDocument(owned.candidate.manifest, 'ArtifactManifest', {
|
|
399
|
+
overlay: { maxFiles: overlayLimits.maxFiles, maxBytes: overlayLimits.maxBytes },
|
|
400
|
+
});
|
|
401
|
+
if (!manifest.ok)
|
|
402
|
+
refuse('INPUT_INVALID', '/candidate/manifest');
|
|
403
|
+
if (owned.candidate.baseRevision !== contract.target.baseRevision || owned.candidate.sourceRevision !== contract.target.sourceRevision)
|
|
404
|
+
refuse('BINDING_MISMATCH', '/candidate');
|
|
405
|
+
if (owned.candidate.artifacts.length !== manifest.value.spec.entries.length || artifactCount > policy.limits.candidateEntries)
|
|
406
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts');
|
|
407
|
+
for (let i = 0; i < owned.candidate.artifacts.length; i++) {
|
|
408
|
+
const copy = rawArtifactCopies.get(i);
|
|
409
|
+
if (copy) {
|
|
410
|
+
owned.candidate.artifacts[i].bytes = copy;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
owned.resources.forEach((item, index) => {
|
|
414
|
+
item.bytes = resourceCopies[index];
|
|
415
|
+
});
|
|
416
|
+
if (owned.restore && workspaceCopy && sessionCopy) {
|
|
417
|
+
owned.restore.workspace.bytes = workspaceCopy;
|
|
418
|
+
owned.restore.session.bytes = sessionCopy;
|
|
419
|
+
}
|
|
420
|
+
let admittedResources;
|
|
421
|
+
if (role.resourceIds === undefined) {
|
|
422
|
+
const contractResourceIdentities = contract.trustedContext.resources.map(toResourceIdentity);
|
|
423
|
+
const expected = [PREAMBLE_IDENTITY, ...contractResourceIdentities];
|
|
424
|
+
if (!sameIdentity(policy.resources, expected) || owned.resources.length > contractResourceIdentities.length) {
|
|
425
|
+
refuse('RESOURCE_MISMATCH', '/resources');
|
|
426
|
+
}
|
|
427
|
+
admittedResources = contractResourceIdentities;
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
const allowedIds = new Set(role.resourceIds);
|
|
431
|
+
const byId = new Map(contract.trustedContext.resources.map(item => [item.id, toResourceIdentity(item)]));
|
|
432
|
+
if (policy.resources.length !== 1 + allowedIds.size || !sameIdentity(policy.resources[0], PREAMBLE_IDENTITY)) {
|
|
433
|
+
refuse('RESOURCE_MISMATCH', '/resources');
|
|
434
|
+
}
|
|
435
|
+
const seenResourceIds = new Set();
|
|
436
|
+
const resolvedRoleResources = [];
|
|
437
|
+
for (const entry of policy.resources.slice(1)) {
|
|
438
|
+
if (!allowedIds.has(entry.id) || seenResourceIds.has(entry.id))
|
|
439
|
+
refuse('RESOURCE_MISMATCH', '/resources');
|
|
440
|
+
const admitted = byId.get(entry.id);
|
|
441
|
+
if (!admitted || !sameIdentity(entry, admitted))
|
|
442
|
+
refuse('RESOURCE_MISMATCH', '/resources');
|
|
443
|
+
seenResourceIds.add(entry.id);
|
|
444
|
+
resolvedRoleResources.push(admitted);
|
|
445
|
+
}
|
|
446
|
+
if (owned.resources.length > resolvedRoleResources.length)
|
|
447
|
+
refuse('RESOURCE_MISMATCH', '/resources');
|
|
448
|
+
admittedResources = resolvedRoleResources;
|
|
449
|
+
}
|
|
450
|
+
const unconditionalIds = new Set(contract.trustedContext.resources
|
|
451
|
+
.filter(item => item.when === undefined)
|
|
452
|
+
.map(item => item.id));
|
|
453
|
+
const requiredResourceIds = new Set(admittedResources
|
|
454
|
+
.filter(item => unconditionalIds.has(item.id))
|
|
455
|
+
.map(item => item.id));
|
|
456
|
+
const validateBytes = (ref, bytes, path) => {
|
|
457
|
+
const actual = digestArtifact(ref.name, bytes);
|
|
458
|
+
if (!actual.ok || !sameIdentity(actual.value, ref))
|
|
459
|
+
refuse('RESOURCE_MISMATCH', path);
|
|
460
|
+
if (bytes.byteLength > policy.limits.fileBytes)
|
|
461
|
+
refuse('OUTPUT_LIMIT', path);
|
|
462
|
+
};
|
|
463
|
+
const manifestByName = new Map(manifest.value.spec.entries.map(entry => [entry.name, entry]));
|
|
464
|
+
const baseTreeFormat = manifest.value.spec.baseTree?.objectFormat;
|
|
465
|
+
const paths = new Set(), prefixes = new Map();
|
|
466
|
+
const blobChecks = [];
|
|
467
|
+
let candidateLogicalBytes = 0;
|
|
468
|
+
for (const artifact of owned.candidate.artifacts) {
|
|
469
|
+
text(artifact.name, '/candidate/artifacts/name', 1024);
|
|
470
|
+
const ref = manifestByName.get(artifact.name);
|
|
471
|
+
if (!ref || paths.has(artifact.name.toLowerCase()))
|
|
472
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts');
|
|
473
|
+
paths.add(artifact.name.toLowerCase());
|
|
474
|
+
let prefix = '';
|
|
475
|
+
for (const segment of artifact.name.split('/')) {
|
|
476
|
+
if (segment.length > 255)
|
|
477
|
+
refuse('INPUT_INVALID', '/candidate/artifacts/name');
|
|
478
|
+
prefix = prefix ? prefix + '/' + segment : segment;
|
|
479
|
+
const key = prefix.toLowerCase(), previous = prefixes.get(key);
|
|
480
|
+
if (previous !== undefined && previous !== prefix)
|
|
481
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts');
|
|
482
|
+
prefixes.set(key, prefix);
|
|
483
|
+
}
|
|
484
|
+
if ('bytes' in artifact) {
|
|
485
|
+
validateBytes(ref, artifact.bytes, '/candidate/artifacts');
|
|
486
|
+
candidateLogicalBytes += artifact.bytes.byteLength;
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
const byteLength = integer(artifact.byteLength, 0, Number.MAX_SAFE_INTEGER, '/candidate/artifacts/byteLength');
|
|
490
|
+
validateDigest(artifact.digest, '/candidate/artifacts/digest');
|
|
491
|
+
const blobPath = text(artifact.blobPath, '/candidate/artifacts/blobPath', 4096);
|
|
492
|
+
if (!isAbsolute(blobPath) || /[\0\r\n]/.test(blobPath))
|
|
493
|
+
refuse('INPUT_INVALID', '/candidate/artifacts/blobPath');
|
|
494
|
+
if (byteLength > policy.limits.fileBytes)
|
|
495
|
+
refuse('OUTPUT_LIMIT', '/candidate/artifacts');
|
|
496
|
+
const actualMeta = digestArtifactFromMetadata(artifact.name, { digest: artifact.digest, byteLength });
|
|
497
|
+
if (!actualMeta.ok || !sameIdentity(actualMeta.value, ref))
|
|
498
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts');
|
|
499
|
+
blobChecks.push({ artifact, byteLength, blobPath });
|
|
500
|
+
candidateLogicalBytes += byteLength;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
let baselineCtx;
|
|
504
|
+
if (manifest.value.spec.baseTree === undefined) {
|
|
505
|
+
if (snapshottedBaseline !== undefined)
|
|
506
|
+
refuse('INPUT_INVALID', '/candidate/baseline');
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
const overlayBytes = manifest.value.spec.entries.reduce((sum, entry) => sum + entry.byteLength, 0);
|
|
510
|
+
if (overlayBytes > overlayLimits.maxBytes || Buffer.byteLength(canonical(manifest.value)) > overlayLimits.manifestMaxBytes) {
|
|
511
|
+
refuse('OUTPUT_LIMIT', '/candidate/manifest');
|
|
512
|
+
}
|
|
513
|
+
if (snapshottedBaseline === undefined)
|
|
514
|
+
refuse('INPUT_INVALID', '/candidate/baseline');
|
|
515
|
+
baselineCtx = validateSnapshottedBaselineStructure(snapshottedBaseline, manifest.value.spec.baseTree, manifest.value.spec.deleted);
|
|
516
|
+
}
|
|
517
|
+
return {
|
|
518
|
+
owned,
|
|
519
|
+
lock,
|
|
520
|
+
policy,
|
|
521
|
+
manifest: manifest.value,
|
|
522
|
+
overlayLimits,
|
|
523
|
+
admittedResources,
|
|
524
|
+
requiredResourceIds,
|
|
525
|
+
baselineCtx,
|
|
526
|
+
baseTreeFormat,
|
|
527
|
+
blobChecks,
|
|
528
|
+
candidateLogicalBytes,
|
|
529
|
+
validateBytes,
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
export function parseAndValidateStructuralInput(input) {
|
|
533
|
+
const snapshotted = snapshotOpenInputSync(input, 1);
|
|
534
|
+
return validateStructuralInputWithPolicy(snapshotted, snapshotted.rawPolicy);
|
|
535
|
+
}
|
|
536
|
+
function finalizePreparedInput(ctx, verifiedBlobOids) {
|
|
537
|
+
const { owned, lock, policy, manifest, admittedResources, requiredResourceIds, baselineCtx, candidateLogicalBytes, validateBytes } = ctx;
|
|
538
|
+
let frozenBaseline;
|
|
539
|
+
if (manifest.spec.baseTree !== undefined) {
|
|
540
|
+
if (baselineCtx === undefined)
|
|
541
|
+
refuse('INPUT_INVALID', '/candidate/baseline');
|
|
542
|
+
frozenBaseline = verifyBaselineCrossChecks(baselineCtx, manifest.spec.baseTree, manifest.spec.entries, manifest.spec.deleted, owned.candidate.artifacts, verifiedBlobOids);
|
|
543
|
+
}
|
|
544
|
+
const admittedIndexById = new Map();
|
|
545
|
+
admittedResources.forEach((admitted, index) => {
|
|
546
|
+
admittedIndexById.set(admitted.id, index);
|
|
547
|
+
});
|
|
548
|
+
const mountedIds = new Set();
|
|
549
|
+
let lastAdmittedIndex = -1;
|
|
550
|
+
owned.resources.forEach((resource, offset) => {
|
|
551
|
+
if (typeof resource.id !== 'string')
|
|
552
|
+
refuse('RESOURCE_MISMATCH', '/resources/' + offset);
|
|
553
|
+
const admittedIndex = admittedIndexById.get(resource.id);
|
|
554
|
+
if (admittedIndex === undefined || admittedIndex <= lastAdmittedIndex) {
|
|
555
|
+
refuse('RESOURCE_MISMATCH', '/resources/' + offset);
|
|
556
|
+
}
|
|
557
|
+
const admitted = admittedResources[admittedIndex];
|
|
558
|
+
if (!resource.ref
|
|
559
|
+
|| typeof resource.ref !== 'object'
|
|
560
|
+
|| Array.isArray(resource.ref)
|
|
561
|
+
|| resource.kind !== admitted.kind
|
|
562
|
+
|| resource.ref.name !== admitted.path
|
|
563
|
+
|| !sameIdentity(resource.ref.digest, admitted.digest)) {
|
|
564
|
+
refuse('RESOURCE_MISMATCH', '/resources/' + offset);
|
|
565
|
+
}
|
|
566
|
+
lastAdmittedIndex = admittedIndex;
|
|
567
|
+
mountedIds.add(resource.id);
|
|
568
|
+
validateBytes(resource.ref, resource.bytes, '/resources/' + offset);
|
|
569
|
+
decodePromptResourceUtf8(resource.bytes, '/resources/' + offset);
|
|
570
|
+
});
|
|
571
|
+
for (const requiredId of requiredResourceIds) {
|
|
572
|
+
if (!mountedIds.has(requiredId))
|
|
573
|
+
refuse('RESOURCE_MISMATCH', '/resources');
|
|
574
|
+
}
|
|
575
|
+
if (owned.restore) {
|
|
576
|
+
id(owned.restore.checkpointId, '/restore/checkpointId');
|
|
577
|
+
validateBytes(owned.restore.workspace.ref, owned.restore.workspace.bytes, '/restore/workspace');
|
|
578
|
+
validateBytes(owned.restore.session.ref, owned.restore.session.bytes, '/restore/session');
|
|
579
|
+
}
|
|
580
|
+
const resourcesBytes = owned.resources.reduce((sum, resource) => sum + resource.bytes.byteLength, 0);
|
|
581
|
+
const restoreBytes = owned.restore ? owned.restore.workspace.bytes.byteLength + owned.restore.session.bytes.byteLength : 0;
|
|
582
|
+
const aggregate = candidateLogicalBytes + resourcesBytes + restoreBytes;
|
|
583
|
+
if (aggregate > policy.limits.artifactBytes || (!owned.restore && aggregate + policy.limits.sessionBytes > policy.limits.artifactBytes))
|
|
584
|
+
refuse('OUTPUT_LIMIT', '/artifacts');
|
|
585
|
+
if (Buffer.byteLength(systemPrompt(owned)) > policy.context.maxRequestBytes)
|
|
586
|
+
refuse('CONTEXT_UNSAFE', '/resources');
|
|
587
|
+
const frozenCandidate = frozenBaseline
|
|
588
|
+
? Object.freeze({
|
|
589
|
+
manifest: freeze(manifest),
|
|
590
|
+
baseRevision: owned.candidate.baseRevision,
|
|
591
|
+
sourceRevision: owned.candidate.sourceRevision,
|
|
592
|
+
artifacts: freeze(owned.candidate.artifacts),
|
|
593
|
+
baseline: frozenBaseline,
|
|
594
|
+
})
|
|
595
|
+
: freeze({
|
|
596
|
+
manifest,
|
|
597
|
+
baseRevision: owned.candidate.baseRevision,
|
|
598
|
+
sourceRevision: owned.candidate.sourceRevision,
|
|
599
|
+
artifacts: owned.candidate.artifacts,
|
|
600
|
+
});
|
|
601
|
+
return Object.freeze({
|
|
602
|
+
...owned,
|
|
603
|
+
lock: freeze(lock),
|
|
604
|
+
policy: freeze(policy),
|
|
605
|
+
candidate: frozenCandidate,
|
|
606
|
+
resources: freeze(owned.resources),
|
|
607
|
+
restore: freeze(owned.restore),
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
export async function finalizePreparedInputAsync(ctx, hostArtifactsDirectory) {
|
|
611
|
+
const verifiedBlobOids = new Map();
|
|
612
|
+
let authoritativeCasSha256Dir = null;
|
|
613
|
+
for (const { artifact, byteLength, blobPath } of ctx.blobChecks) {
|
|
614
|
+
let effectiveBlobPath = blobPath;
|
|
615
|
+
if (hostArtifactsDirectory !== undefined) {
|
|
616
|
+
if (authoritativeCasSha256Dir === null) {
|
|
617
|
+
authoritativeCasSha256Dir = await resolveAuthoritativeCasSha256DirAsync(hostArtifactsDirectory);
|
|
618
|
+
}
|
|
619
|
+
const expectedBlobPath = join(authoritativeCasSha256Dir, artifact.digest.hex);
|
|
620
|
+
const expectedUnresolvedBlobPath = join(resolve(hostArtifactsDirectory), 'blobs', 'sha256', artifact.digest.hex);
|
|
621
|
+
const normalizedSuppliedPath = resolve(blobPath);
|
|
622
|
+
if (normalizedSuppliedPath !== expectedBlobPath && normalizedSuppliedPath !== expectedUnresolvedBlobPath) {
|
|
623
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts/blobPath');
|
|
624
|
+
}
|
|
625
|
+
let actualRealBlobPath;
|
|
626
|
+
try {
|
|
627
|
+
actualRealBlobPath = await realpath(blobPath);
|
|
628
|
+
}
|
|
629
|
+
catch {
|
|
630
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts/blobPath');
|
|
631
|
+
}
|
|
632
|
+
if (actualRealBlobPath !== expectedBlobPath) {
|
|
633
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts/blobPath');
|
|
634
|
+
}
|
|
635
|
+
effectiveBlobPath = expectedBlobPath;
|
|
636
|
+
artifact.blobPath = expectedBlobPath;
|
|
637
|
+
}
|
|
638
|
+
const verified = await verifyRegularFileAsync(effectiveBlobPath, {
|
|
639
|
+
byteLength,
|
|
640
|
+
sha256Hex: artifact.digest.hex,
|
|
641
|
+
requireReadOnly: true,
|
|
642
|
+
gitObjectFormat: ctx.baseTreeFormat,
|
|
643
|
+
structuralCode: 'RESOURCE_MISMATCH',
|
|
644
|
+
contentCode: 'RESOURCE_MISMATCH',
|
|
645
|
+
errorPath: '/candidate/artifacts',
|
|
646
|
+
});
|
|
647
|
+
if (verified.gitOid !== null) {
|
|
648
|
+
verifiedBlobOids.set(artifact.name, verified.gitOid);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return finalizePreparedInput(ctx, verifiedBlobOids);
|
|
652
|
+
}
|
|
653
|
+
export async function prepareInputAsync(input, hostArtifactsDirectory) {
|
|
654
|
+
const ctx = parseAndValidateStructuralInput(input);
|
|
655
|
+
return finalizePreparedInputAsync(ctx, hostArtifactsDirectory);
|
|
656
|
+
}
|
|
657
|
+
export function prepareInput(input, hostArtifactsDirectory) {
|
|
658
|
+
const ctx = parseAndValidateStructuralInput(input);
|
|
659
|
+
const verifiedBlobOids = new Map();
|
|
660
|
+
let authoritativeCasSha256Dir = null;
|
|
661
|
+
for (const { artifact, byteLength, blobPath } of ctx.blobChecks) {
|
|
662
|
+
let effectiveBlobPath = blobPath;
|
|
663
|
+
if (hostArtifactsDirectory !== undefined) {
|
|
664
|
+
if (authoritativeCasSha256Dir === null) {
|
|
665
|
+
authoritativeCasSha256Dir = resolveAuthoritativeCasSha256DirSync(hostArtifactsDirectory);
|
|
666
|
+
}
|
|
667
|
+
const expectedBlobPath = join(authoritativeCasSha256Dir, artifact.digest.hex);
|
|
668
|
+
const expectedUnresolvedBlobPath = join(resolve(hostArtifactsDirectory), 'blobs', 'sha256', artifact.digest.hex);
|
|
669
|
+
const normalizedSuppliedPath = resolve(blobPath);
|
|
670
|
+
if (normalizedSuppliedPath !== expectedBlobPath && normalizedSuppliedPath !== expectedUnresolvedBlobPath) {
|
|
671
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts/blobPath');
|
|
672
|
+
}
|
|
673
|
+
let actualRealBlobPath;
|
|
674
|
+
try {
|
|
675
|
+
actualRealBlobPath = realpathSync(blobPath);
|
|
676
|
+
}
|
|
677
|
+
catch {
|
|
678
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts/blobPath');
|
|
679
|
+
}
|
|
680
|
+
if (actualRealBlobPath !== expectedBlobPath) {
|
|
681
|
+
refuse('RESOURCE_MISMATCH', '/candidate/artifacts/blobPath');
|
|
682
|
+
}
|
|
683
|
+
effectiveBlobPath = expectedBlobPath;
|
|
684
|
+
artifact.blobPath = expectedBlobPath;
|
|
685
|
+
}
|
|
686
|
+
const verified = verifyRegularFileSync(effectiveBlobPath, {
|
|
687
|
+
byteLength,
|
|
688
|
+
sha256Hex: artifact.digest.hex,
|
|
689
|
+
requireReadOnly: true,
|
|
690
|
+
gitObjectFormat: ctx.baseTreeFormat,
|
|
691
|
+
structuralCode: 'RESOURCE_MISMATCH',
|
|
692
|
+
contentCode: 'RESOURCE_MISMATCH',
|
|
693
|
+
errorPath: '/candidate/artifacts',
|
|
694
|
+
});
|
|
695
|
+
if (verified.gitOid !== null) {
|
|
696
|
+
verifiedBlobOids.set(artifact.name, verified.gitOid);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
return finalizePreparedInput(ctx, verifiedBlobOids);
|
|
700
|
+
}
|