firedrill-run 2.2.5 → 3.0.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/README.md +178 -22
- package/bin/firedrill.mjs +29 -5
- package/dist/assembly.json +13 -0
- package/dist/cli/runtime/candidate_copy.py +395 -0
- package/dist/cli/runtime/source_snapshot.py +391 -0
- package/dist/cli/src/administration.js +295 -0
- package/dist/cli/src/agent-changes.js +496 -0
- package/dist/cli/src/assessment-requests.js +67 -0
- package/dist/cli/src/auth.js +465 -0
- package/dist/cli/src/billing-commerce-contracts.js +1 -0
- package/dist/cli/src/billing-usage.js +227 -0
- package/dist/cli/src/billing-wallet-contracts.js +1 -0
- package/dist/cli/src/billing.js +170 -0
- package/dist/cli/src/bootstrap-process-lock.js +136 -0
- package/dist/cli/src/browser-links.js +14 -0
- package/dist/cli/src/campaign-controls.js +122 -0
- package/dist/cli/src/campaign-diagnoses.js +118 -0
- package/dist/cli/src/campaign-reports.js +1215 -0
- package/dist/cli/src/campaign-world.js +156 -0
- package/dist/cli/src/candidate-copy.js +376 -0
- package/dist/cli/src/catalog-contracts.js +1 -0
- package/dist/cli/src/ci-access-contracts.js +1 -0
- package/dist/cli/src/ci-configuration-contracts.js +1 -0
- package/dist/cli/src/ci-coverage.js +64 -0
- package/dist/cli/src/ci-delivery-contracts.js +1 -0
- package/dist/cli/src/ci-result-contracts.js +1 -0
- package/dist/cli/src/ci-run-contracts.js +1 -0
- package/dist/cli/src/ci-setup-proposals.js +52 -0
- package/dist/cli/src/company-policies.js +229 -0
- package/dist/cli/src/completion.js +79 -0
- package/dist/cli/src/configuration-intents.js +277 -0
- package/dist/cli/src/configuration.js +369 -0
- package/dist/cli/src/continuous-simulation.js +277 -0
- package/dist/cli/src/coordinated-checkpoints.js +133 -0
- package/dist/cli/src/credential-mode.js +139 -0
- package/dist/cli/src/credentials.js +331 -0
- package/dist/cli/src/credit-format.js +8 -0
- package/dist/cli/src/dataset-contracts.js +1 -0
- package/dist/cli/src/dataset-export.js +154 -0
- package/dist/cli/src/dataset-reads.js +37 -0
- package/dist/cli/src/dependency-preparation.js +239 -0
- package/dist/cli/src/director-tool-setup.js +104 -0
- package/dist/cli/src/driver-review.js +225 -0
- package/dist/cli/src/evaluation-authoring.js +315 -0
- package/dist/cli/src/evidence-bundles.js +367 -0
- package/dist/cli/src/execution-proposals.js +36 -0
- package/dist/cli/src/http.js +302 -0
- package/dist/cli/src/local-container-boundary.js +38 -0
- package/dist/cli/src/local-container-policy.js +201 -0
- package/dist/cli/src/local-execution-setup.js +81 -0
- package/dist/cli/src/local-source-basis.js +73 -0
- package/dist/cli/src/local-source.js +66 -0
- package/dist/cli/src/local-value-store.js +91 -0
- package/dist/cli/src/local-values.js +163 -0
- package/dist/cli/src/login-organizations.js +70 -0
- package/dist/cli/src/main.js +1622 -0
- package/dist/cli/src/mcp-connection.js +109 -0
- package/dist/cli/src/native/bindings.js +137 -0
- package/dist/cli/src/native/canonical.js +370 -0
- package/dist/cli/src/native/cloud-resources.js +942 -0
- package/dist/cli/src/native/companion-channel.js +421 -0
- package/dist/cli/src/native/companion-ipc.js +473 -0
- package/dist/cli/src/native/contracts.js +218 -0
- package/dist/cli/src/native/control-plane.js +1354 -0
- package/dist/cli/src/native/credit-approval.js +15 -0
- package/dist/cli/src/native/dependency-proxy.js +1006 -0
- package/dist/cli/src/native/drill-cleanup.js +115 -0
- package/dist/cli/src/native/drill-runner.js +1562 -0
- package/dist/cli/src/native/drivers/action-trace.js +210 -0
- package/dist/cli/src/native/drivers/function-wrapper.js +152 -0
- package/dist/cli/src/native/drivers/http.js +442 -0
- package/dist/cli/src/native/drivers/index.js +47 -0
- package/dist/cli/src/native/drivers/jsonl-process.js +538 -0
- package/dist/cli/src/native/drivers/playwright.js +600 -0
- package/dist/cli/src/native/drivers/signed-event.js +244 -0
- package/dist/cli/src/native/drivers/types.js +578 -0
- package/dist/cli/src/native/evidence-filter.js +255 -0
- package/dist/cli/src/native/isolated-access.js +241 -0
- package/dist/cli/src/native/library-sharing.js +220 -0
- package/dist/cli/src/native/local-run.js +667 -0
- package/dist/cli/src/native/local-secrets.js +19 -0
- package/dist/cli/src/native/mcp-config.js +123 -0
- package/dist/cli/src/native/metadata-requests.js +120 -0
- package/dist/cli/src/native/observations.js +1159 -0
- package/dist/cli/src/native/owned-groups.js +46 -0
- package/dist/cli/src/native/plan.js +594 -0
- package/dist/cli/src/native/png.js +159 -0
- package/dist/cli/src/native/ports.js +43 -0
- package/dist/cli/src/native/readiness.js +139 -0
- package/dist/cli/src/native/reassessments.js +206 -0
- package/dist/cli/src/native/redaction.js +235 -0
- package/dist/cli/src/native/registration.js +155 -0
- package/dist/cli/src/native/roots.js +110 -0
- package/dist/cli/src/native/run-cleanup.js +199 -0
- package/dist/cli/src/native/scratch.js +117 -0
- package/dist/cli/src/native/screenshots.js +60 -0
- package/dist/cli/src/native/session.js +556 -0
- package/dist/cli/src/native/standalone-proxy.js +580 -0
- package/dist/cli/src/native/standalone-renewals.js +183 -0
- package/dist/cli/src/native/standalone-state.js +193 -0
- package/dist/cli/src/native/standalone-tools.js +187 -0
- package/dist/cli/src/native/supervisor.js +831 -0
- package/dist/cli/src/native/target-auth.js +161 -0
- package/dist/cli/src/native/target-state.js +330 -0
- package/dist/cli/src/native/tool-reuse.js +364 -0
- package/dist/cli/src/native/tool-setups.js +336 -0
- package/dist/cli/src/native/world-reuse.js +288 -0
- package/dist/cli/src/onboarding.js +23 -0
- package/dist/cli/src/priority-requests.js +70 -0
- package/dist/cli/src/priority.js +223 -0
- package/dist/cli/src/prompts.js +184 -0
- package/dist/cli/src/real-operations.js +221 -0
- package/dist/cli/src/recipe-intents.js +58 -0
- package/dist/cli/src/recorded-context-intents.js +59 -0
- package/dist/cli/src/recorded-context.js +248 -0
- package/dist/cli/src/recordings.js +69 -0
- package/dist/cli/src/registration-guide.js +39 -0
- package/dist/cli/src/report-exports.js +213 -0
- package/dist/cli/src/request-input.js +47 -0
- package/dist/cli/src/resource-lifecycle.js +141 -0
- package/dist/cli/src/revision-requests.js +55 -0
- package/dist/cli/src/runner-abandon.js +53 -0
- package/dist/cli/src/runner-campaign-controls.js +262 -0
- package/dist/cli/src/runner-claim-reads.js +36 -0
- package/dist/cli/src/runner-completion.js +65 -0
- package/dist/cli/src/runner-configuration.js +546 -0
- package/dist/cli/src/runner-container.js +794 -0
- package/dist/cli/src/runner-evidence-erasure.js +351 -0
- package/dist/cli/src/runner-evidence-privacy.js +37 -0
- package/dist/cli/src/runner-evidence-retention.js +161 -0
- package/dist/cli/src/runner-evidence.js +326 -0
- package/dist/cli/src/runner-execute.js +92 -0
- package/dist/cli/src/runner-execution-deadline.js +25 -0
- package/dist/cli/src/runner-grants.js +307 -0
- package/dist/cli/src/runner-identity.js +615 -0
- package/dist/cli/src/runner-inputs.js +308 -0
- package/dist/cli/src/runner-jobs.js +49 -0
- package/dist/cli/src/runner-model-transport.js +392 -0
- package/dist/cli/src/runner-ownership.js +332 -0
- package/dist/cli/src/runner-process-lock.js +175 -0
- package/dist/cli/src/runner-runtime.js +396 -0
- package/dist/cli/src/runner-session-channel.js +377 -0
- package/dist/cli/src/runner-trial-completion.js +34 -0
- package/dist/cli/src/runner-trial-journal.js +358 -0
- package/dist/cli/src/runner-trial-live.js +393 -0
- package/dist/cli/src/runner-trial-protocol.js +289 -0
- package/dist/cli/src/runner-trial-sync.js +110 -0
- package/dist/cli/src/runner-trial-transfer.js +107 -0
- package/dist/cli/src/runner-voice.js +40 -0
- package/dist/cli/src/runner-world-claim.js +21 -0
- package/dist/cli/src/runner-world-collector.js +159 -0
- package/dist/cli/src/runner-world-command-evidence.js +487 -0
- package/dist/cli/src/runner-world-commands.js +268 -0
- package/dist/cli/src/runner-world-completion.js +76 -0
- package/dist/cli/src/runner-world-erasure.js +95 -0
- package/dist/cli/src/runner-world-evidence-sync.js +91 -0
- package/dist/cli/src/runner-world-journal.js +510 -0
- package/dist/cli/src/runner-world-native-filters.js +134 -0
- package/dist/cli/src/runner-world-observations.js +50 -0
- package/dist/cli/src/runner-world-session-protocol.js +134 -0
- package/dist/cli/src/saved-records.js +40 -0
- package/dist/cli/src/scenario-authoring.js +212 -0
- package/dist/cli/src/scenario-discovery.js +216 -0
- package/dist/cli/src/scenario-paths.js +68 -0
- package/dist/cli/src/scenario-requests.js +4 -0
- package/dist/cli/src/service-receipts.js +105 -0
- package/dist/cli/src/simple/authoring.js +270 -0
- package/dist/cli/src/simple/credit-approval.js +16 -0
- package/dist/cli/src/simple/help.js +98 -0
- package/dist/cli/src/simple/init.js +61 -0
- package/dist/cli/src/simple/library-sharing.js +414 -0
- package/dist/cli/src/simple/metadata-requests.js +46 -0
- package/dist/cli/src/simple/native-report.js +841 -0
- package/dist/cli/src/simple/native-tools.js +780 -0
- package/dist/cli/src/simple/plan-apply.js +506 -0
- package/dist/cli/src/simple/reassessment.js +323 -0
- package/dist/cli/src/simple/register.js +123 -0
- package/dist/cli/src/simple/run.js +122 -0
- package/dist/cli/src/simple/status.js +49 -0
- package/dist/cli/src/simple/tool-renewal.js +308 -0
- package/dist/cli/src/simple/tool-reuse.js +526 -0
- package/dist/cli/src/simple/tool-start-catalog.js +100 -0
- package/dist/cli/src/simple/tool-state.js +426 -0
- package/dist/cli/src/simple/tools-author.js +222 -0
- package/dist/cli/src/simple/watch.js +28 -0
- package/dist/cli/src/simple/world-reuse.js +586 -0
- package/dist/cli/src/simulation-intents.js +406 -0
- package/dist/cli/src/simulation-run.js +1058 -0
- package/dist/cli/src/source-batch.js +322 -0
- package/dist/cli/src/source-connection.js +451 -0
- package/dist/cli/src/source-runtime.js +346 -0
- package/dist/cli/src/source-selection-intents.js +75 -0
- package/dist/cli/src/source-sets.js +214 -0
- package/dist/cli/src/target-models.js +109 -0
- package/dist/cli/src/tool-catalog.js +224 -0
- package/dist/cli/src/tool-command-contracts.js +1 -0
- package/dist/cli/src/tool-command-export.js +245 -0
- package/dist/cli/src/tool-connection-contracts.js +1 -0
- package/dist/cli/src/tool-connection-reads.js +23 -0
- package/dist/cli/src/tool-contributions.js +58 -0
- package/dist/cli/src/tool-data.js +116 -0
- package/dist/cli/src/tool-datasets.js +176 -0
- package/dist/cli/src/tool-group-contracts.js +1 -0
- package/dist/cli/src/tool-group-reads.js +26 -0
- package/dist/cli/src/tool-group-state.js +147 -0
- package/dist/cli/src/tool-groups.js +311 -0
- package/dist/cli/src/tool-instances.js +186 -0
- package/dist/cli/src/tool-lifecycle-contracts.js +1 -0
- package/dist/cli/src/tool-lifecycle-reads.js +30 -0
- package/dist/cli/src/tool-lifecycle.js +323 -0
- package/dist/cli/src/tool-package-contracts.js +1 -0
- package/dist/cli/src/tool-package-reads.js +41 -0
- package/dist/cli/src/tool-records.js +53 -0
- package/dist/cli/src/tool-runtime.js +96 -0
- package/dist/cli/src/tool-state-contracts.js +1 -0
- package/dist/cli/src/tool-state-reads.js +31 -0
- package/dist/cli/src/tools.js +306 -0
- package/dist/cli/src/trial-actions.js +93 -0
- package/dist/cli/src/trial-checkpoints.js +133 -0
- package/dist/cli/src/trial-checks.js +70 -0
- package/dist/cli/src/trial-state.js +197 -0
- package/dist/cli/src/vault.js +266 -0
- package/dist/cli/src/workspace-registration.js +383 -0
- package/dist/cli/src/workspace-team-contracts.js +1 -0
- package/dist/cli/src/world-access.js +231 -0
- package/dist/cli/src/world-agent.js +4 -0
- package/dist/cli/src/world-checkpoint-scopes.js +15 -0
- package/dist/cli/src/world-contracts.js +6 -0
- package/dist/cli/src/world-creation.js +201 -0
- package/dist/cli/src/world-datasets.js +207 -0
- package/dist/cli/src/world-inspection.js +257 -0
- package/dist/cli/src/world-recipes.js +103 -0
- package/dist/cli/src/world-requests.js +241 -0
- package/dist/cli/src/world-session-checkpoints.js +196 -0
- package/dist/cli/src/world-session-lifecycle.js +207 -0
- package/dist/cli/src/world-session-requests.js +215 -0
- package/dist/cli/src/world-session-state.js +145 -0
- package/dist/cli/src/world-session-voice.js +66 -0
- package/dist/cli/src/world-sessions.js +288 -0
- package/dist/cli/src/world-stream.js +99 -0
- package/dist/cli/src/world-time-report.js +58 -0
- package/dist/contracts/agent-change-contracts.js +75 -0
- package/dist/contracts/agent-execution-contracts.js +38 -0
- package/dist/contracts/application-state-contracts.js +26 -0
- package/dist/contracts/assessment-aggregate-contracts.js +15 -0
- package/dist/contracts/assessment-contracts.js +74 -0
- package/dist/contracts/billing-commerce-contracts.js +107 -0
- package/dist/contracts/billing-wallet-contracts.js +43 -0
- package/dist/contracts/campaign-lifecycle.js +1 -0
- package/dist/contracts/campaign-world-contracts.js +80 -0
- package/dist/contracts/catalog-contracts.js +73 -0
- package/dist/contracts/ci-access-contracts.js +68 -0
- package/dist/contracts/ci-configuration-contracts.js +88 -0
- package/dist/contracts/ci-coverage-contracts.js +65 -0
- package/dist/contracts/ci-coverage-labels.js +25 -0
- package/dist/contracts/ci-delivery-contracts.js +61 -0
- package/dist/contracts/ci-result-contracts.js +103 -0
- package/dist/contracts/ci-run-contracts.js +51 -0
- package/dist/contracts/ci-setup-contracts.js +88 -0
- package/dist/contracts/clip-contracts.js +32 -0
- package/dist/contracts/comparison-contracts.js +53 -0
- package/dist/contracts/composite-contracts.js +34 -0
- package/dist/contracts/context-contracts.js +76 -0
- package/dist/contracts/continuation-report-contracts.js +1 -0
- package/dist/contracts/continuity-requirements.js +8 -0
- package/dist/contracts/coordinated-checkpoint-contracts.js +34 -0
- package/dist/contracts/dataset-contracts.js +88 -0
- package/dist/contracts/dependency-decision-contracts.js +36 -0
- package/dist/contracts/dependency-protocol-contracts.js +43 -0
- package/dist/contracts/director-execution.js +51 -0
- package/dist/contracts/driver-review-contracts.js +99 -0
- package/dist/contracts/evidence-contracts.js +65 -0
- package/dist/contracts/evidence-coverage-contracts.js +10 -0
- package/dist/contracts/export-contracts.js +44 -0
- package/dist/contracts/github-directory-contracts.js +96 -0
- package/dist/contracts/insight-contracts.js +11 -0
- package/dist/contracts/inspection-contracts.js +1 -0
- package/dist/contracts/local-claim-contracts.js +39 -0
- package/dist/contracts/local-configuration-contracts.js +7 -0
- package/dist/contracts/local-evidence-contracts.js +32 -0
- package/dist/contracts/local-grant-contracts.js +83 -0
- package/dist/contracts/local-input-contracts.js +19 -0
- package/dist/contracts/local-runner-contracts.js +42 -0
- package/dist/contracts/local-trial-live-contracts.js +16 -0
- package/dist/contracts/local-value-source-contracts.js +92 -0
- package/dist/contracts/local-world-native-contracts.js +8 -0
- package/dist/contracts/mcp-contracts.js +42 -0
- package/dist/contracts/media-contracts.js +28 -0
- package/dist/contracts/native-check-contracts.js +31 -0
- package/dist/contracts/native-identity-contracts.js +52 -0
- package/dist/contracts/onboarding-contracts.js +32 -0
- package/dist/contracts/performance-contracts.js +85 -0
- package/dist/contracts/planning-contracts.js +81 -0
- package/dist/contracts/real-operation-contracts.js +30 -0
- package/dist/contracts/recommendation-contracts.js +54 -0
- package/dist/contracts/report-contracts.js +1 -0
- package/dist/contracts/resource-lifecycle-contracts.js +57 -0
- package/dist/contracts/revision-contracts.js +12 -0
- package/dist/contracts/revision-request-contracts.js +39 -0
- package/dist/contracts/saved-record-contracts.js +76 -0
- package/dist/contracts/scenario-draft-comparison.js +91 -0
- package/dist/contracts/scenario-world-contracts.js +14 -0
- package/dist/contracts/service-contracts.js +1 -0
- package/dist/contracts/session-command-contracts.js +56 -0
- package/dist/contracts/session-contracts.js +65 -0
- package/dist/contracts/session-state-contracts.js +67 -0
- package/dist/contracts/session-voice-contracts.js +45 -0
- package/dist/contracts/source-set-contracts.js +26 -0
- package/dist/contracts/source-upload-contracts.js +22 -0
- package/dist/contracts/tool-command-contracts.js +57 -0
- package/dist/contracts/tool-connection-contracts.js +87 -0
- package/dist/contracts/tool-contribution-contracts.js +35 -0
- package/dist/contracts/tool-group-contracts.js +53 -0
- package/dist/contracts/tool-group-state-contracts.js +63 -0
- package/dist/contracts/tool-lifecycle-contracts.js +94 -0
- package/dist/contracts/tool-package-contracts.js +91 -0
- package/dist/contracts/tool-protocol-contracts.js +71 -0
- package/dist/contracts/tool-runtime-billing-contracts.js +28 -0
- package/dist/contracts/tool-setup-proposal.js +59 -0
- package/dist/contracts/tool-state-contracts.js +79 -0
- package/dist/contracts/trial-state-contracts.js +30 -0
- package/dist/contracts/typescript/agent-change.js +1 -0
- package/dist/contracts/typescript/assessment-aggregate.js +1 -0
- package/dist/contracts/typescript/assessment.js +1 -0
- package/dist/contracts/typescript/billing-commerce.js +1 -0
- package/dist/contracts/typescript/campaigns.js +1 -0
- package/dist/contracts/typescript/catalog.js +1 -0
- package/dist/contracts/typescript/ci-access.js +1 -0
- package/dist/contracts/typescript/ci-configuration.js +1 -0
- package/dist/contracts/typescript/ci-delivery.js +1 -0
- package/dist/contracts/typescript/ci-result.js +1 -0
- package/dist/contracts/typescript/ci-runs.js +1 -0
- package/dist/contracts/typescript/clips.js +1 -0
- package/dist/contracts/typescript/comparison.js +1 -0
- package/dist/contracts/typescript/composite.js +1 -0
- package/dist/contracts/typescript/connections.js +1 -0
- package/dist/contracts/typescript/context.js +1 -0
- package/dist/contracts/typescript/datasets.js +1 -0
- package/dist/contracts/typescript/evidence-coverage.js +1 -0
- package/dist/contracts/typescript/export.js +1 -0
- package/dist/contracts/typescript/github-directory.js +1 -0
- package/dist/contracts/typescript/insight.js +1 -0
- package/dist/contracts/typescript/inspection.js +1 -0
- package/dist/contracts/typescript/intake.js +1 -0
- package/dist/contracts/typescript/local-claim.js +1 -0
- package/dist/contracts/typescript/local-configuration.js +1 -0
- package/dist/contracts/typescript/local-evidence.js +1 -0
- package/dist/contracts/typescript/local-grant.js +1 -0
- package/dist/contracts/typescript/local-input.js +1 -0
- package/dist/contracts/typescript/local-runner.js +1 -0
- package/dist/contracts/typescript/local-trial-live.js +1 -0
- package/dist/contracts/typescript/local-value-source.js +1 -0
- package/dist/contracts/typescript/local-world-native.js +1 -0
- package/dist/contracts/typescript/mcp.js +1 -0
- package/dist/contracts/typescript/media.js +1 -0
- package/dist/contracts/typescript/native-check.js +1 -0
- package/dist/contracts/typescript/native-identity.js +1 -0
- package/dist/contracts/typescript/onboarding.js +1 -0
- package/dist/contracts/typescript/performance.js +1 -0
- package/dist/contracts/typescript/planning.js +1 -0
- package/dist/contracts/typescript/preparation.js +1 -0
- package/dist/contracts/typescript/real-operation.js +1 -0
- package/dist/contracts/typescript/recommendation.js +1 -0
- package/dist/contracts/typescript/reports.js +1 -0
- package/dist/contracts/typescript/resource-lifecycle.js +1 -0
- package/dist/contracts/typescript/saved-record.js +1 -0
- package/dist/contracts/typescript/scenarios.js +1 -0
- package/dist/contracts/typescript/services.js +1 -0
- package/dist/contracts/typescript/session-command.js +1 -0
- package/dist/contracts/typescript/session-state.js +1 -0
- package/dist/contracts/typescript/session-voice.js +1 -0
- package/dist/contracts/typescript/session.js +1 -0
- package/dist/contracts/typescript/tool-command.js +1 -0
- package/dist/contracts/typescript/tool-connection.js +1 -0
- package/dist/contracts/typescript/tool-contribution.js +1 -0
- package/dist/contracts/typescript/tool-groups.js +1 -0
- package/dist/contracts/typescript/tool-lifecycle.js +1 -0
- package/dist/contracts/typescript/tool-package.js +1 -0
- package/dist/contracts/typescript/tool-state.js +1 -0
- package/dist/contracts/typescript/trial-state.js +1 -0
- package/dist/contracts/typescript/vault.js +1 -0
- package/dist/contracts/typescript/workspace-team.js +1 -0
- package/dist/contracts/typescript/world-stream.js +1 -0
- package/dist/contracts/workspace-team-contracts.js +55 -0
- package/dist/contracts/world-command.js +65 -0
- package/dist/contracts/world-lifetime-contracts.js +74 -0
- package/dist/contracts/world-recipe-contracts.js +27 -0
- package/dist/contracts/world-stream-contracts.js +27 -0
- package/dist/package.json +1 -0
- package/package.json +16 -16
- package/LICENSE.md +0 -23
- package/PACKAGING.json +0 -50
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const hex = (value) => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value);
|
|
2
|
+
const integer = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
|
|
3
|
+
/** Exact original acceptance only. A new current authentication session may read
|
|
4
|
+
* old metadata; this does not restore the original native write authority. */
|
|
5
|
+
export function localTrialLiveReceiptMatches(value, selected, original) {
|
|
6
|
+
return !!value && value.schema === 'firedrill.local-trial-live-receipt.v1'
|
|
7
|
+
&& value.actor_id === selected.owner && value.workspace_id === selected.workspace && value.device_key === selected.device
|
|
8
|
+
&& value.request_key === selected.request && value.job_id === selected.job && value.lease_id === selected.lease
|
|
9
|
+
&& value.attempt_id === selected.attempt && hex(value.manifest_sha256) && value.manifest_sha256 === original.manifestSha256
|
|
10
|
+
&& value.execution_id === original.executionId && hex(value.event_id) && value.event_id === original.eventId
|
|
11
|
+
&& integer(value.sequence) && value.sequence === original.sequence && value.provenance === 'customer_device'
|
|
12
|
+
&& value.cloud_completion_recorded === false && typeof value.server_time === 'string' && Number.isFinite(Date.parse(value.server_time))
|
|
13
|
+
&& (value.state === 'retained' ? hex(value.body_sha256) && value.body_sha256 === original.bodySha256
|
|
14
|
+
&& integer(value.body_size) && value.body_size > 0 && value.body_size <= 256 * 1024 && value.body_size === original.bodySize
|
|
15
|
+
: value.state === 'not_retained' && value.body_sha256 === null && value.body_size === null);
|
|
16
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { rawSourceUploadMatches } from './source-upload-contracts.js';
|
|
2
|
+
const uuid = (v) => typeof v === 'string' && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(v);
|
|
3
|
+
const hex = (v) => typeof v === 'string' && /^[a-f0-9]{64}$/.test(v);
|
|
4
|
+
const date = (v) => typeof v === 'string' && Number.isFinite(Date.parse(v));
|
|
5
|
+
const integer = (v, minimum = 0) => typeof v === 'number' && Number.isSafeInteger(v) && v >= minimum;
|
|
6
|
+
const archive = (v) => !!v && Object.keys(v).sort().join(',') === 'sha256,size' && integer(v.size, 1) && hex(v.sha256);
|
|
7
|
+
const capture = (v) => !!v && v.schema === 'firedrill.local-source.v1'
|
|
8
|
+
&& Object.keys(v).sort().join(',') === 'base_commit,content_digest,expanded_bytes,file_count,project_root,schema'
|
|
9
|
+
&& hex(v.content_digest) && (v.base_commit === null || typeof v.base_commit === 'string' && /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(v.base_commit))
|
|
10
|
+
&& typeof v.project_root === 'string' && v.project_root.length <= 1024 && integer(v.file_count, 1) && integer(v.expanded_bytes);
|
|
11
|
+
/** Canonical non-secret original request metadata only. Never pass private values. */
|
|
12
|
+
export function nativeMetadataCanonical(v) {
|
|
13
|
+
if (Array.isArray(v))
|
|
14
|
+
return '[' + v.map(nativeMetadataCanonical).join(',') + ']';
|
|
15
|
+
if (v && typeof v === 'object') {
|
|
16
|
+
const row = v;
|
|
17
|
+
return '{' + Object.keys(row).sort().map(key => JSON.stringify(key) + ':' + nativeMetadataCanonical(row[key])).join(',') + '}';
|
|
18
|
+
}
|
|
19
|
+
const encoded = JSON.stringify(v);
|
|
20
|
+
if (encoded === undefined)
|
|
21
|
+
throw new Error('The original native metadata is incomplete.');
|
|
22
|
+
return encoded;
|
|
23
|
+
}
|
|
24
|
+
export function localValueRegistrationMatches(v, scope, id) {
|
|
25
|
+
return !!v && v.schema === 'firedrill.local-value-reference.v1' && uuid(v.id) && (!id || v.id === id)
|
|
26
|
+
&& v.actor_id === scope.owner && v.workspace_id === scope.workspace && v.world_id === scope.world
|
|
27
|
+
&& uuid(v.device_key) && typeof v.device_label === 'string' && v.device_label.length <= 80
|
|
28
|
+
&& typeof v.name === 'string' && /^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(v.name)
|
|
29
|
+
&& ['build', 'runtime', 'both'].includes(v.phase) && ['revoked', 'available', 'device_unavailable'].includes(v.state)
|
|
30
|
+
&& hex(v.request_digest) && date(v.created_at) && (v.revoked_at === null ? v.state !== 'revoked' : date(v.revoked_at) && v.state === 'revoked')
|
|
31
|
+
&& v.value_uploaded === false;
|
|
32
|
+
}
|
|
33
|
+
export function localValueLookupMatches(v, scope, id) {
|
|
34
|
+
return !!v && v.id === id && v.actor_id === scope.owner && v.workspace_id === scope.workspace && v.world_id === scope.world
|
|
35
|
+
&& v.value_uploaded === false && (v.state === 'not_retained' || localValueRegistrationMatches(v, scope, id));
|
|
36
|
+
}
|
|
37
|
+
export function localValuePageMatches(v, scope, query = '', page = 1) {
|
|
38
|
+
return !!v && v.actor_id === scope.owner && v.workspace_id === scope.workspace && v.world_id === scope.world
|
|
39
|
+
&& v.query === query.trim() && v.page === page && integer(v.count) && integer(v.page_size, 1) && v.page_size <= 100
|
|
40
|
+
&& Array.isArray(v.results) && v.results.length <= v.page_size && new Set(v.results.map(one => one.id)).size === v.results.length
|
|
41
|
+
&& v.results.every(one => localValueRegistrationMatches(one, scope));
|
|
42
|
+
}
|
|
43
|
+
export function localValueOriginalMatches(v, scope, id, body, digest) {
|
|
44
|
+
return localValueRegistrationMatches(v, scope, id) && v.request_digest === digest && v.device_key === body.device_key
|
|
45
|
+
&& v.name === body.name && v.phase === body.phase;
|
|
46
|
+
}
|
|
47
|
+
export function localSourceConnectionMatches(v, scope, key) {
|
|
48
|
+
if (!v || v.request_key !== key || v.actor_id !== scope.owner || v.workspace_id !== scope.workspace || !uuid(v.native_session_id)
|
|
49
|
+
|| typeof v.defer_world !== 'boolean' || v.component_agent_id !== null && (!uuid(v.component_agent_id) || !v.defer_world)
|
|
50
|
+
|| !['awaiting_upload', 'verifying', 'upload_missing', 'connected', 'withdrawn', 'refused', 'rejected'].includes(v.state)
|
|
51
|
+
|| typeof v.name !== 'string' || v.name.length > 120 || !date(v.expires_at)
|
|
52
|
+
|| !(v.problem === null || typeof v.problem === 'string') || ![v.agent_id, v.source_id, v.world_id].every(one => one === null || uuid(one)))
|
|
53
|
+
return false;
|
|
54
|
+
if (v.request_digest === null)
|
|
55
|
+
return v.state === 'withdrawn' && v.name === '' && v.capture === null && v.archive === null
|
|
56
|
+
&& v.consent_policy === null && v.consented_at === null && v.agent_id === null && v.source_id === null && v.world_id === null;
|
|
57
|
+
return hex(v.request_digest) && !!v.name && archive(v.archive) && capture(v.capture)
|
|
58
|
+
&& v.consent_policy === 'firedrill.local-source-transfer.v1' && date(v.consented_at)
|
|
59
|
+
&& (v.state !== 'connected' || uuid(v.agent_id) && uuid(v.source_id) && (v.defer_world ? v.world_id === null : uuid(v.world_id)))
|
|
60
|
+
&& (v.agent_id === null || v.component_agent_id === null || v.agent_id === v.component_agent_id);
|
|
61
|
+
}
|
|
62
|
+
export function localSourceLookupMatches(v, scope, key) {
|
|
63
|
+
return !!v && v.request_key === key && v.actor_id === scope.owner && v.workspace_id === scope.workspace
|
|
64
|
+
&& (v.state === 'not_retained' || localSourceConnectionMatches(v, scope, key));
|
|
65
|
+
}
|
|
66
|
+
export function localSourcePageMatches(v, scope, filters) {
|
|
67
|
+
const fields = ['schema', 'actor_id', 'workspace_id', 'query', 'state_filter', 'after', 'next_after', 'page_size', 'results'];
|
|
68
|
+
const rowFields = ['request_key', 'actor_id', 'workspace_id', 'native_session_id', 'request_digest', 'state', 'name', 'capture',
|
|
69
|
+
'archive', 'agent_id', 'source_id', 'world_id', 'component_agent_id', 'defer_world', 'problem', 'consent_policy', 'consented_at', 'expires_at', 'created_at'];
|
|
70
|
+
const exact = (value, allowed) => Object.keys(value).length === allowed.length && Object.keys(value).every(key => allowed.includes(key));
|
|
71
|
+
const cursor = (value) => value === null || typeof value === 'string' && value.length > 0 && value.length <= 2048 && /^[A-Za-z0-9_.:-]+$/.test(value);
|
|
72
|
+
return !!v && exact(v, fields) && v.schema === 'firedrill.local-source-history.v1'
|
|
73
|
+
&& v.actor_id === scope.owner && v.workspace_id === scope.workspace
|
|
74
|
+
&& v.query === filters.query.trim() && v.state_filter === filters.state && v.after === (filters.after || null)
|
|
75
|
+
&& v.page_size === 20 && cursor(v.after) && cursor(v.next_after) && (v.next_after === null || v.next_after !== v.after)
|
|
76
|
+
&& Array.isArray(v.results) && v.results.length <= 20
|
|
77
|
+
&& (v.next_after === null || v.results.length === 20)
|
|
78
|
+
&& new Set(v.results.map(one => one.request_key)).size === v.results.length
|
|
79
|
+
&& v.results.every(one => !!one && exact(one, rowFields) && uuid(one.request_key) && date(one.created_at)
|
|
80
|
+
&& localSourceConnectionMatches(one, scope, one.request_key) && (filters.state === 'all' || one.state === filters.state));
|
|
81
|
+
}
|
|
82
|
+
export function localSourceOriginalMatches(v, scope, key, body, digest) {
|
|
83
|
+
return localSourceConnectionMatches(v, scope, key) && v.request_digest === digest && v.name === body.name
|
|
84
|
+
&& v.component_agent_id === (body.component_agent_id ?? null) && v.defer_world === (body.defer_world ?? false)
|
|
85
|
+
&& nativeMetadataCanonical(v.capture) === nativeMetadataCanonical(body.capture)
|
|
86
|
+
&& nativeMetadataCanonical(v.archive) === nativeMetadataCanonical(body.archive);
|
|
87
|
+
}
|
|
88
|
+
export function localSourceUploadMatches(v, scope, key, body, digest) {
|
|
89
|
+
return !!v && v.request_key === key && v.actor_id === scope.owner && v.workspace_id === scope.workspace && v.request_digest === digest
|
|
90
|
+
&& archive(v.archive) && nativeMetadataCanonical(v.archive) === nativeMetadataCanonical(body.archive)
|
|
91
|
+
&& rawSourceUploadMatches(v, scope.workspace);
|
|
92
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const LOCAL_WORLD_IDENTITY_KEYS = ['actor_id', 'workspace_id', 'device_key', 'request_key', 'job_id', 'attempt_id', 'manifest_sha256'];
|
|
2
|
+
/** Original scope only, not proof of current execution or independent attestation. */
|
|
3
|
+
export function localWorldIdentityMatches(value, owner, manifest) {
|
|
4
|
+
return !!value && value.actor_id === owner.owner && value.workspace_id === owner.workspace && value.device_key === owner.device
|
|
5
|
+
&& value.job_id === owner.job && value.request_key === owner.request && value.attempt_id === owner.attempt
|
|
6
|
+
&& value.lease_id === owner.lease && value.manifest_sha256 === manifest && value.provenance === 'customer_device'
|
|
7
|
+
&& typeof value.server_time === 'string' && Number.isFinite(Date.parse(value.server_time));
|
|
8
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export function mcpReauthorizationRead(value, actor, session) {
|
|
2
|
+
if (!value || value.user_id !== actor || value.session_id !== session || value.new_authorization_allowed !== true)
|
|
3
|
+
throw new Error('The connection approval could not be confirmed. Check its current state before another action.');
|
|
4
|
+
return value;
|
|
5
|
+
}
|
|
6
|
+
export function mcpConnectionRead(value, actor, workspace, expectedAppOrigin) {
|
|
7
|
+
const httpsRoot = (raw) => {
|
|
8
|
+
if (typeof raw !== 'string' || raw.length > 2048)
|
|
9
|
+
return false;
|
|
10
|
+
try {
|
|
11
|
+
const url = new URL(raw);
|
|
12
|
+
return url.protocol === 'https:' && !url.username && !url.password
|
|
13
|
+
&& !url.hash && !url.search && url.pathname === '/' && raw === url.origin
|
|
14
|
+
&& !url.hostname.endsWith('.') && (!url.port || url.port === '443')
|
|
15
|
+
&& (expectedAppOrigin === undefined || url.origin !== expectedAppOrigin);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const app = (raw, path) => {
|
|
22
|
+
if (typeof raw !== 'string')
|
|
23
|
+
return false;
|
|
24
|
+
try {
|
|
25
|
+
const url = new URL(raw);
|
|
26
|
+
return (url.protocol === 'https:' || ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname) && url.protocol === 'http:')
|
|
27
|
+
&& url.pathname === path && !url.username && !url.password && !url.hash
|
|
28
|
+
&& (expectedAppOrigin === undefined || url.origin === expectedAppOrigin)
|
|
29
|
+
&& (path === '/signin' ? [...url.searchParams.keys()].join(',') === 'screen_hint' && url.searchParams.get('screen_hint') === 'sign-up' : !url.search);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
if (!value || value.schema !== 'firedrill.mcp-connection.v1' || value.actor_id !== actor || value.workspace_id !== workspace
|
|
36
|
+
|| typeof value.enabled !== 'boolean' || value.authentication !== 'oauth'
|
|
37
|
+
|| (value.enabled ? !httpsRoot(value.url) : value.url !== null)
|
|
38
|
+
|| !app(value.signup_url, '/signin') || !app(value.auth_guide_url, '/auth.md')) {
|
|
39
|
+
throw new Error('The MCP connection details changed. Reload this workspace before continuing.');
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Corroborate the selected trial's paths without issuing a media request. */
|
|
2
|
+
export function captureMatchesTrial(row, prefix, desktop) {
|
|
3
|
+
const kind = row.session_origin === 'source_desktop_session' ? 'desktop-captures' : 'captures';
|
|
4
|
+
if (desktop !== undefined && (kind === 'desktop-captures') !== desktop)
|
|
5
|
+
return false;
|
|
6
|
+
if (row.state === 'unavailable')
|
|
7
|
+
return row.image_path === null && row.download_path === null;
|
|
8
|
+
const image = `${prefix}/${kind}/${row.id}/image`;
|
|
9
|
+
return row.state === 'captured' && row.image_path === image && row.download_path === `${image}?download=1`;
|
|
10
|
+
}
|
|
11
|
+
export function fileMatchesTrial(row, prefix) {
|
|
12
|
+
const path = `${prefix}/files/${row.id}`;
|
|
13
|
+
if (row.preview !== null && (row.kind !== 'browser_capture' && row.kind !== 'desktop_capture' || row.audio !== null))
|
|
14
|
+
return false;
|
|
15
|
+
if (row.preview !== null && (row.preview.evidence_id !== row.id || !captureMatchesTrial(row.preview, prefix)
|
|
16
|
+
|| row.preview.state !== 'captured' || row.download_path !== row.preview.download_path
|
|
17
|
+
|| row.download_content_type !== 'image/png'))
|
|
18
|
+
return false;
|
|
19
|
+
if (row.preview === null && row.download_path !== `${path}/download`)
|
|
20
|
+
return false;
|
|
21
|
+
if (row.audio !== null && (row.audio.evidence_id !== row.id || row.audio.origin !== row.origin
|
|
22
|
+
|| row.audio.audio_path !== `${path}/audio` || row.audio.download_path !== `${path}/download`
|
|
23
|
+
|| row.download_content_type !== 'audio/wav' || row.content_type !== 'audio/wav'))
|
|
24
|
+
return false;
|
|
25
|
+
if (row.audio !== null && (row.kind === 'recording_segment' ? row.audio.partial !== true : !row.kind.startsWith('recording_') || row.audio.partial === true))
|
|
26
|
+
return false;
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function nativeCheckObservationMatches(value, selected) {
|
|
2
|
+
const uuid = (one) => typeof one === 'string' && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(one);
|
|
3
|
+
return !!value && value.workspace_id === selected.workspace && value.campaign_id === selected.campaign
|
|
4
|
+
&& value.execution_id === selected.execution && value.id === selected.observation
|
|
5
|
+
&& [value.workspace_id, value.campaign_id, value.execution_id, value.id, value.evidence_id].every(uuid)
|
|
6
|
+
&& typeof value.name === 'string' && value.name.length > 0 && value.name.length <= 255
|
|
7
|
+
&& ['exact', 'semantic', 'both', 'unknown'].includes(value.method) && typeof value.definition_known === 'boolean'
|
|
8
|
+
&& value.definition_known === (value.method !== 'unknown') && typeof value.reported === 'boolean'
|
|
9
|
+
&& ['met', 'unmet', 'unconfirmed'].includes(value.status) && (value.judged === null || typeof value.judged === 'boolean')
|
|
10
|
+
&& (value.reason === null || typeof value.reason === 'string') && typeof value.reason_truncated === 'boolean'
|
|
11
|
+
&& (!value.reason_truncated || value.reason === null)
|
|
12
|
+
&& (value.reported || value.status === 'unconfirmed' && value.judged === null && value.reason === null && !value.reason_truncated)
|
|
13
|
+
&& value.download_path === `/api/workspaces/${selected.workspace}/campaigns/${selected.campaign}/trials/${selected.execution}/evidence/${value.evidence_id}/bytes`;
|
|
14
|
+
}
|
|
15
|
+
function selectedRunsMatch(value, current, baseline) {
|
|
16
|
+
return value.current.id === current && (baseline ? value.baseline?.id === baseline && baseline !== current && value.context !== null
|
|
17
|
+
: value.baseline === null && value.context === null);
|
|
18
|
+
}
|
|
19
|
+
export function checkGroupsMatch(value, current, baseline, method) {
|
|
20
|
+
return selectedRunsMatch(value, current, baseline) && value.results.every(row => (!method || row.check.method === method)
|
|
21
|
+
&& (baseline ? row.baseline !== null : row.baseline === null));
|
|
22
|
+
}
|
|
23
|
+
export function checkObservationsMatch(value, selected) {
|
|
24
|
+
return selectedRunsMatch(value, selected.current, selected.baseline) && value.check.id === selected.check
|
|
25
|
+
&& (!selected.definition || value.check.identity === selected.definition.identity)
|
|
26
|
+
&& (selected.baseline ? value.summary.baseline !== null : value.summary.baseline === null)
|
|
27
|
+
&& value.results.every(row => (selected.side === 'both' || row.side === selected.side)
|
|
28
|
+
&& (!selected.status || row.status === selected.status)
|
|
29
|
+
&& (row.side === 'current' ? row.campaign_id === selected.current : row.side === 'baseline'
|
|
30
|
+
&& !!selected.baseline && row.campaign_id === selected.baseline));
|
|
31
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const record = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
2
|
+
const uuid = (v) => typeof v === 'string' && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(v);
|
|
3
|
+
const date = (v) => typeof v === 'string' && Number.isFinite(Date.parse(v));
|
|
4
|
+
const integer = (v) => typeof v === 'number' && Number.isSafeInteger(v) && v >= 0;
|
|
5
|
+
export function nativeIdentityRead(v, matches) {
|
|
6
|
+
if (!matches)
|
|
7
|
+
throw new Error('Terminal identity or selected access could not be confirmed. No additional action was sent.');
|
|
8
|
+
return v;
|
|
9
|
+
}
|
|
10
|
+
export function nativeMembershipSyncMatches(v) {
|
|
11
|
+
return record(v) && typeof v.state === 'string' && ['not_requested', 'running', 'completed', 'attention_required'].includes(v.state);
|
|
12
|
+
}
|
|
13
|
+
export function nativeWorkspaceMatches(v) {
|
|
14
|
+
return record(v) && uuid(v.id) && uuid(v.organization_id) && typeof v.name === 'string' && typeof v.role === 'string'
|
|
15
|
+
&& typeof v.can_manage === 'boolean' && typeof v.can_write === 'boolean';
|
|
16
|
+
}
|
|
17
|
+
export function nativeSessionMatches(v, selected = {}) {
|
|
18
|
+
return record(v) && uuid(v.id) && (!selected.session || v.id === selected.session) && typeof v.label === 'string'
|
|
19
|
+
&& v.label.length >= 1 && v.label.length <= 80 && record(v.user) && uuid(v.user.id) && (!selected.actor || v.user.id === selected.actor)
|
|
20
|
+
&& typeof v.user.name === 'string' && typeof v.user.email === 'string' && v.user.email.includes('@') && date(v.expires_at)
|
|
21
|
+
&& nativeMembershipSyncMatches(v.membership_sync) && (v.workspace === null || nativeWorkspaceMatches(v.workspace))
|
|
22
|
+
&& (!selected.workspace || record(v.workspace) && v.workspace.id === selected.workspace);
|
|
23
|
+
}
|
|
24
|
+
function page(v, user, number) {
|
|
25
|
+
return record(v) && uuid(v.user_id) && (!user || v.user_id === user) && v.page === number && integer(v.count)
|
|
26
|
+
&& typeof v.page_size === 'number' && Number.isSafeInteger(v.page_size) && v.page_size >= 1 && v.page_size <= 100
|
|
27
|
+
&& Array.isArray(v.results) && v.results.length <= v.page_size;
|
|
28
|
+
}
|
|
29
|
+
export function nativeWorkspacesMatch(v, user, query, number = 1) {
|
|
30
|
+
return page(v, user, number) && uuid(v.native_session_id) && v.query === query.trim() && nativeMembershipSyncMatches(v.membership_sync)
|
|
31
|
+
&& v.results.every(nativeWorkspaceMatches) && new Set(v.results.map(one => record(one) ? one.id : null)).size === v.results.length;
|
|
32
|
+
}
|
|
33
|
+
export function nativeOrganizationsMatch(v, subject, query = '', number = 1, selected = '', user) {
|
|
34
|
+
return page(v, user, number) && v.schema === 'firedrill.native-organizations.v1'
|
|
35
|
+
&& typeof v.workos_user_id === 'string' && /^user_[A-Za-z0-9]{1,120}$/.test(v.workos_user_id) && v.workos_user_id === subject
|
|
36
|
+
&& v.query === query.trim() && v.organization_id === selected && nativeMembershipSyncMatches(v.membership_sync)
|
|
37
|
+
&& (v.grant_organization_id === null || typeof v.grant_organization_id === 'string' && /^org_[A-Za-z0-9]{1,120}$/.test(v.grant_organization_id))
|
|
38
|
+
&& v.results.every(one => record(one) && uuid(one.id) && typeof one.name === 'string'
|
|
39
|
+
&& typeof one.workos_organization_id === 'string' && /^org_[A-Za-z0-9]{1,120}$/.test(one.workos_organization_id))
|
|
40
|
+
&& new Set(v.results.map(one => record(one) ? one.id : null)).size === v.results.length
|
|
41
|
+
&& new Set(v.results.map(one => record(one) ? one.workos_organization_id : null)).size === v.results.length;
|
|
42
|
+
}
|
|
43
|
+
export function nativeDevicesMatch(v, user, query, number = 1) {
|
|
44
|
+
return page(v, user, number) && v.query === query.trim() && v.results.every(one => record(one) && uuid(one.id) && typeof one.label === 'string'
|
|
45
|
+
&& date(one.created_at) && date(one.last_seen_at) && typeof one.state === 'string' && ['active', 'revoked', 'expired'].includes(one.state)
|
|
46
|
+
&& ['terminal', 'mcp'].includes(String(one.kind)) && typeof one.can_reauthorize === 'boolean'
|
|
47
|
+
&& (!one.can_reauthorize || one.kind === 'mcp' && one.state === 'revoked'))
|
|
48
|
+
&& new Set(v.results.map(one => record(one) ? one.id : null)).size === v.results.length;
|
|
49
|
+
}
|
|
50
|
+
export function nativeRevokedMatches(v, user, session) {
|
|
51
|
+
return record(v) && v.revoked === true && uuid(v.user_id) && uuid(v.session_id) && (!user || v.user_id === user) && (!session || v.session_id === session);
|
|
52
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const uuid = (value) => typeof value === 'string' && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(value);
|
|
2
|
+
const text = (value, max) => typeof value === 'string' && value.length <= max && !/[\x00-\x1f\x7f]/.test(value);
|
|
3
|
+
const date = (value) => value === null || typeof value === 'string' && value.length <= 64 && Number.isFinite(Date.parse(value));
|
|
4
|
+
export function onboardingMatches(value, actor) {
|
|
5
|
+
if (!value || !uuid(value.user_id) || actor && value.user_id !== actor || !Number.isSafeInteger(value.revision) || value.revision < 0
|
|
6
|
+
|| !['new', 'in_progress', 'skipped', 'completed'].includes(value.state) || ![1, 2].includes(value.step)
|
|
7
|
+
|| !date(value.skipped_at) || !date(value.completed_at) || !value.values || !value.catalog)
|
|
8
|
+
return false;
|
|
9
|
+
const catalog = value.catalog;
|
|
10
|
+
const choices = (rows) => Array.isArray(rows) && rows.length > 0 && rows.length <= 40
|
|
11
|
+
&& rows.every(row => row && text(row.value, 32) && /^[a-z][a-z_]*$/.test(row.value) && text(row.label, 80) && row.label.length > 0)
|
|
12
|
+
&& new Set(rows.map(row => row.value)).size === rows.length;
|
|
13
|
+
if (!choices(catalog.roles) || !choices(catalog.industries) || !Array.isArray(catalog.country_codes) || catalog.country_codes.length > 250
|
|
14
|
+
|| catalog.country_codes.length < 1 || !catalog.country_codes.every(code => typeof code === 'string' && /^[A-Z]{2}$/.test(code))
|
|
15
|
+
|| new Set(catalog.country_codes).size !== catalog.country_codes.length)
|
|
16
|
+
return false;
|
|
17
|
+
const profile = value.values;
|
|
18
|
+
if (!text(profile.display_name, 255) || !text(profile.organization_name, 120) || !text(profile.website, 253)
|
|
19
|
+
|| !text(profile.role, 32) || profile.role !== '' && !catalog.roles.some(row => row.value === profile.role)
|
|
20
|
+
|| !text(profile.industry, 32) || profile.industry !== '' && !catalog.industries.some(row => row.value === profile.industry)
|
|
21
|
+
|| !text(profile.country_code, 2) || profile.country_code !== '' && !catalog.country_codes.includes(profile.country_code))
|
|
22
|
+
return false;
|
|
23
|
+
const request = value.workspace_request;
|
|
24
|
+
return request === null || !!request && uuid(request.request_key) && text(request.name, 120) && request.name.length > 0
|
|
25
|
+
&& ['pending', 'creating', 'uncertain', 'completed'].includes(request.state) && (request.workspace_id === null || uuid(request.workspace_id))
|
|
26
|
+
&& typeof request.workspace_available === 'boolean' && (!request.workspace_available || request.workspace_id !== null);
|
|
27
|
+
}
|
|
28
|
+
export function onboardingRead(value, actor) {
|
|
29
|
+
if (!onboardingMatches(value, actor))
|
|
30
|
+
throw new Error('The optional setup response did not match this account. Reload saved details before continuing.');
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export function targetUsageMatches(value, campaign, execution, model) {
|
|
2
|
+
return value.campaign_id === campaign && value.execution_id === (execution ?? null) && value.model_filter === model
|
|
3
|
+
&& value.results.every(row => (!execution || row.execution_id === execution)
|
|
4
|
+
&& completionMatches(row.response_metadata) && (row.failure_category === null || Object.hasOwn(failures, row.failure_category)));
|
|
5
|
+
}
|
|
6
|
+
const stops = new Set(['end_turn', 'tool_use', 'max_tokens', 'stop_sequence', 'pause_turn', 'refusal', 'model_context_window_exceeded']);
|
|
7
|
+
const finishes = new Set(['stop', 'length', 'tool_calls', 'function_call', 'content_filter']);
|
|
8
|
+
const statuses = new Set(['queued', 'in_progress', 'completed', 'incomplete', 'failed', 'cancelled']);
|
|
9
|
+
const incomplete = new Set(['max_output_tokens', 'content_filter']);
|
|
10
|
+
const nullableEnum = (value, choices) => value === null || typeof value === 'string' && choices.has(value);
|
|
11
|
+
function completionMatches(value) {
|
|
12
|
+
if (value === null)
|
|
13
|
+
return true;
|
|
14
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
15
|
+
return false;
|
|
16
|
+
const one = value;
|
|
17
|
+
return Object.keys(one).length === 9 && one.schema === 'firedrill.target-model-completion.v1'
|
|
18
|
+
&& (one.transport === 'json' || one.transport === 'sse') && typeof one.response_observed === 'boolean'
|
|
19
|
+
&& (one.stream_complete === null || typeof one.stream_complete === 'boolean') && (one.transport !== 'json' || one.stream_complete === null)
|
|
20
|
+
&& nullableEnum(one.stop_reason, stops) && nullableEnum(one.response_status, statuses) && nullableEnum(one.incomplete_reason, incomplete)
|
|
21
|
+
&& Array.isArray(one.finish_reasons) && one.finish_reasons.length <= 16 && new Set(one.finish_reasons).size === one.finish_reasons.length
|
|
22
|
+
&& one.finish_reasons.every(reason => typeof reason === 'string' && finishes.has(reason)) && typeof one.unrecognized_reason === 'boolean';
|
|
23
|
+
}
|
|
24
|
+
const failures = {
|
|
25
|
+
request_rejected: 'The provider rejected the model request.', credential_rejected: 'The provider rejected the saved model credential.',
|
|
26
|
+
account_rejected: 'The model account did not allow this request.', model_unavailable: 'The requested model was unavailable to this account.',
|
|
27
|
+
rate_limited: 'The model account reached a provider rate limit.', access_removed: 'Model access ended or could not be confirmed.',
|
|
28
|
+
connection_interrupted: 'The model connection was interrupted.', transport_unavailable: 'The model transport did not finish this request.',
|
|
29
|
+
stream_unavailable: 'The model response stream did not finish.', unclassified: 'The model request failed without a classified completion reason.',
|
|
30
|
+
};
|
|
31
|
+
export function targetCompletionAttention(row) {
|
|
32
|
+
const value = row.response_metadata;
|
|
33
|
+
return row.failure_category !== null || !!value && (value.stream_complete === false || value.stop_reason === 'max_tokens'
|
|
34
|
+
|| value.stop_reason === 'model_context_window_exceeded' || value.stop_reason === 'refusal' || value.finish_reasons.includes('length')
|
|
35
|
+
|| value.finish_reasons.includes('content_filter') || value.response_status === 'incomplete' || value.response_status === 'failed'
|
|
36
|
+
|| value.response_status === 'cancelled');
|
|
37
|
+
}
|
|
38
|
+
export function targetCompletionNotes(row) {
|
|
39
|
+
const notes = row.failure_category ? [failures[row.failure_category]] : [];
|
|
40
|
+
const value = row.response_metadata;
|
|
41
|
+
if (!value)
|
|
42
|
+
return notes;
|
|
43
|
+
if (!value.response_observed)
|
|
44
|
+
return [...notes, 'No structured provider response was observed.'];
|
|
45
|
+
if (value.transport === 'sse' && value.stream_complete === false)
|
|
46
|
+
notes.push('The provider stream did not reach its completion marker.');
|
|
47
|
+
if (value.stop_reason === 'max_tokens' || value.finish_reasons.includes('length') || value.incomplete_reason === 'max_output_tokens')
|
|
48
|
+
notes.push('The provider stopped at the output limit.');
|
|
49
|
+
else if (value.stop_reason === 'model_context_window_exceeded')
|
|
50
|
+
notes.push('The provider stopped at its context-window limit.');
|
|
51
|
+
else if (value.stop_reason === 'refusal' || value.finish_reasons.includes('content_filter') || value.incomplete_reason === 'content_filter')
|
|
52
|
+
notes.push('The provider reported a refusal or content restriction.');
|
|
53
|
+
else if (value.response_status === 'failed')
|
|
54
|
+
notes.push('The provider reported a failed response.');
|
|
55
|
+
else if (value.response_status === 'cancelled')
|
|
56
|
+
notes.push('The provider reported a canceled response.');
|
|
57
|
+
else if (value.response_status === 'incomplete')
|
|
58
|
+
notes.push('The provider reported an incomplete response.');
|
|
59
|
+
else if (value.stop_reason === 'pause_turn')
|
|
60
|
+
notes.push('The provider paused this turn.');
|
|
61
|
+
else if (value.stop_reason === 'tool_use' || value.finish_reasons.some(reason => reason === 'tool_calls' || reason === 'function_call'))
|
|
62
|
+
notes.push('The provider returned a tool request.');
|
|
63
|
+
else if (value.stop_reason || value.finish_reasons.length || value.response_status === 'completed')
|
|
64
|
+
notes.push('The provider ended this response.');
|
|
65
|
+
else
|
|
66
|
+
notes.push('The provider did not report a recognized completion reason.');
|
|
67
|
+
return notes;
|
|
68
|
+
}
|
|
69
|
+
function selectedRunsMatch(value, current, baseline, kind) {
|
|
70
|
+
return current !== baseline && value.current.id === current && value.baseline.id === baseline && value.kind === kind;
|
|
71
|
+
}
|
|
72
|
+
function cohortMatches(value, kind) {
|
|
73
|
+
return kind === 'model' ? value.requested_model !== null && value.operation !== null
|
|
74
|
+
: value.requested_model === null && value.operation === null && value.provider === null;
|
|
75
|
+
}
|
|
76
|
+
export function performanceGroupsMatch(value, current, baseline, kind) {
|
|
77
|
+
return selectedRunsMatch(value, current, baseline, kind) && value.results.every(row => cohortMatches(row.cohort, kind));
|
|
78
|
+
}
|
|
79
|
+
export function performanceObservationsMatch(value, selected) {
|
|
80
|
+
return selectedRunsMatch(value, selected.current, selected.baseline, selected.kind) && cohortMatches(value.cohort, selected.kind)
|
|
81
|
+
&& value.cohort.id === selected.cohort && (!selected.identity || value.cohort.identity === selected.identity)
|
|
82
|
+
&& value.results.every(row => (selected.side === 'both' || row.side === selected.side)
|
|
83
|
+
&& (row.side === 'current' ? row.campaign_id === selected.current
|
|
84
|
+
: row.side === 'baseline' && row.campaign_id === selected.baseline));
|
|
85
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { executionDriverMatches } from './agent-execution-contracts.js';
|
|
2
|
+
export function planningDriverMatches(value) {
|
|
3
|
+
return Boolean(value && typeof value === 'object' && !Array.isArray(value) && 'execution_driver' in value
|
|
4
|
+
&& (value.execution_driver === null || executionDriverMatches(value.execution_driver)));
|
|
5
|
+
}
|
|
6
|
+
export function planningDefaultsMatch(value) {
|
|
7
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
8
|
+
return false;
|
|
9
|
+
const row = value;
|
|
10
|
+
const object = (one) => Boolean(one && typeof one === 'object' && !Array.isArray(one));
|
|
11
|
+
const positive = (one) => typeof one === 'number' && Number.isSafeInteger(one) && one >= 1;
|
|
12
|
+
if (!object(row.defaults) || !object(row.capacity) || row.plan !== null && !object(row.plan))
|
|
13
|
+
return false;
|
|
14
|
+
const defaults = row.defaults, capacity = row.capacity, plan = row.plan;
|
|
15
|
+
if (object(plan) && typeof plan.current !== 'boolean')
|
|
16
|
+
return false;
|
|
17
|
+
const fields = ['repetitions', 'parallelism', 'trial_seconds'];
|
|
18
|
+
if (Object.keys(defaults).sort().join(',') !== [...fields].sort().join(',')
|
|
19
|
+
|| !['max_trials', ...fields.map(key => `max_${key}`)].every(key => positive(capacity[key])))
|
|
20
|
+
return false;
|
|
21
|
+
for (const key of fields) {
|
|
22
|
+
const amount = defaults[key];
|
|
23
|
+
if (!positive(amount))
|
|
24
|
+
return false;
|
|
25
|
+
if (object(plan) && plan.current === true) {
|
|
26
|
+
if (amount !== plan[key])
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
else if (amount > Number(capacity[`max_${key}`]))
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
export function isNativeSetupReceipt(value) {
|
|
35
|
+
return Boolean(value && typeof value === 'object' && 'schema' in value && value.schema === 'firedrill.native-simulation-setup.v1');
|
|
36
|
+
}
|
|
37
|
+
export function planMatchesRequest(plan, request) {
|
|
38
|
+
if (!plan || !plan.selector || !plan.execution || !Array.isArray(plan.selector.ids)
|
|
39
|
+
|| !Array.isArray(plan.selector.excluded) || typeof plan.selector.query !== 'string')
|
|
40
|
+
return false;
|
|
41
|
+
const ids = (values) => [...new Set(values ?? [])].map(value => value.toLowerCase()).sort().join(',');
|
|
42
|
+
const execution = request.execution ?? { location: 'managed' };
|
|
43
|
+
return /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(plan.id)
|
|
44
|
+
&& /^[a-f0-9]{64}$/.test(plan.recipe_sha256) && Number.isSafeInteger(plan.revision) && plan.revision >= 1
|
|
45
|
+
&& Number.isSafeInteger(plan.scenario_count) && plan.scenario_count >= 1
|
|
46
|
+
&& Number.isSafeInteger(plan.planned_trials) && plan.planned_trials === plan.scenario_count * request.repetitions
|
|
47
|
+
&& plan.selector.mode === request.selector.mode && plan.selector.query === (request.selector.query ?? '').trim()
|
|
48
|
+
&& ids(plan.selector.ids) === ids(request.selector.ids) && ids(plan.selector.excluded) === ids(request.selector.excluded)
|
|
49
|
+
&& plan.repetitions === request.repetitions && plan.parallelism === request.parallelism && plan.trial_seconds === request.trial_seconds
|
|
50
|
+
&& plan.execution.location === execution.location
|
|
51
|
+
&& (execution.location === 'managed' || plan.execution.location === 'local' && plan.execution.grant_id === execution.grant_id)
|
|
52
|
+
&& plan.run_saved_criteria === (request.run_saved_criteria ?? true)
|
|
53
|
+
&& plan.share_evaluation_explanation === (Boolean(request.share_evaluation_explanation) && plan.automatic_criteria > 0)
|
|
54
|
+
&& plan.record_browser === (request.record_browser ?? false) && plan.record_voice === (request.record_voice ?? false)
|
|
55
|
+
&& plan.record_desktop === (request.record_desktop ?? false)
|
|
56
|
+
&& plan.acknowledge_desktop_screen_content === (request.acknowledge_desktop_screen_content ?? false)
|
|
57
|
+
&& plan.driver_input_authorized === (request.driver_input_authorized ?? false)
|
|
58
|
+
&& plan.driver_contract_sha256 === (request.driver_input_authorized ? request.driver_contract_sha256 : null)
|
|
59
|
+
&& plan.mask_browser_form_values === request.mask_browser_form_values
|
|
60
|
+
&& (request.dataset_id === undefined || plan.dataset_id === request.dataset_id)
|
|
61
|
+
&& (!request.share_dataset_with_device || plan.dataset_download_approved_for_actor)
|
|
62
|
+
&& plan.application_checkpoint_id === (request.application_checkpoint_id ?? null)
|
|
63
|
+
&& plan.acknowledge_fresh_world_state === (request.acknowledge_fresh_world_state ?? false)
|
|
64
|
+
&& (!request.share_application_checkpoint_with_device || plan.application_checkpoint_download_approved_for_actor)
|
|
65
|
+
&& plan.coordinated_checkpoint_id === (request.coordinated_checkpoint_id ?? null)
|
|
66
|
+
&& plan.acknowledge_supported_checkpoint_scope === (request.acknowledge_supported_checkpoint_scope ?? false)
|
|
67
|
+
&& (!request.share_coordinated_checkpoint_with_device || plan.coordinated_checkpoint_download_approved_for_actor)
|
|
68
|
+
&& (plan.coordinated_checkpoint_id !== null ? plan.application_checkpoint_id === null && !plan.acknowledge_fresh_world_state
|
|
69
|
+
&& plan.application_continuation?.checkpoint_id === plan.coordinated_checkpoint_id
|
|
70
|
+
&& plan.application_continuation.controlled_services_included === true && plan.application_continuation.dependencies === 'coordinated_native_checkpoint'
|
|
71
|
+
&& ['owned_postgres_rows_sequences_and_sql_clock', 'declared_sqlite_files', 'owned_postgres_and_declared_sqlite_files'].includes(plan.application_continuation.native_scope)
|
|
72
|
+
&& ['wall', 'not_configured'].includes(plan.application_continuation.clock_mode)
|
|
73
|
+
&& plan.acknowledge_supported_checkpoint_scope && !plan.dataset_id && plan.mode !== 'external_shared'
|
|
74
|
+
: plan.application_checkpoint_id === null ? plan.application_continuation === null
|
|
75
|
+
: plan.application_continuation?.checkpoint_id === plan.application_checkpoint_id
|
|
76
|
+
&& plan.application_continuation.controlled_services_included === false
|
|
77
|
+
&& plan.application_continuation.continuity === 'application_supported_new_process'
|
|
78
|
+
&& plan.application_continuation.dependencies === 'fresh_prepared_state'
|
|
79
|
+
&& plan.acknowledge_fresh_world_state && !plan.dataset_id && plan.mode !== 'external_shared')
|
|
80
|
+
&& (!request.external_effects || plan.real_access_approved_for_actor && plan.mode === 'external_shared');
|
|
81
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const uuid = (v) => typeof v === 'string' && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(v);
|
|
2
|
+
const date = (v) => typeof v === 'string' && Number.isFinite(Date.parse(v));
|
|
3
|
+
const integer = (v) => typeof v === 'number' && Number.isSafeInteger(v) && v >= 0;
|
|
4
|
+
const scope = (v, s) => !!v && v.viewer_id === s.viewer && v.workspace_id === s.workspace && v.world_id === s.world;
|
|
5
|
+
export function realOperationMatches(value, selected, operation, reviewKey) {
|
|
6
|
+
if (!scope(value, selected) || !uuid(value.id) || operation !== undefined && value.id !== operation || !uuid(value.request_key)
|
|
7
|
+
|| typeof value.operation !== 'string' || typeof value.service_name !== 'string' || value.service_id !== null && !uuid(value.service_id)
|
|
8
|
+
|| !['simulation', 'manual_session', 'agent_startup', 'other'].includes(value.activity) || !['read', 'write'].includes(value.effect)
|
|
9
|
+
|| !['admitted', 'dispatching', 'response', 'not_sent', 'uncertain'].includes(value.outcome)
|
|
10
|
+
|| value.http_status !== null && (!integer(value.http_status) || value.http_status < 100 || value.http_status > 599)
|
|
11
|
+
|| !integer(value.request_bytes) || value.response_bytes !== null && !integer(value.response_bytes)
|
|
12
|
+
|| !integer(value.configuration_revision) || value.configuration_revision < 1 || value.service_revision !== null && (!integer(value.service_revision) || value.service_revision < 1)
|
|
13
|
+
|| !date(value.created_at) || [value.dispatch_started_at, value.finished_at, value.review_available_at, value.reviewed_at, value.response_delivery_confirmed_at].some(v => v !== null && !date(v))
|
|
14
|
+
|| typeof value.can_review !== 'boolean' || typeof value.requires_review !== 'boolean' || typeof value.review_available !== 'boolean'
|
|
15
|
+
|| value.review_available && (!value.can_review || !value.requires_review) || value.requires_review !== (value.review_available_at !== null)
|
|
16
|
+
|| value.external_state_resettable !== false || value.business_outcome !== (value.outcome === 'not_sent' ? 'not_dispatched' : 'not_established'))
|
|
17
|
+
return false;
|
|
18
|
+
const receipt = value.review_receipt;
|
|
19
|
+
return reviewKey ? !!receipt && receipt.request_key === reviewKey && receipt.operation_id === value.id
|
|
20
|
+
&& ['accepted', 'not_received', 'reviewed_by_another_request'].includes(receipt.state)
|
|
21
|
+
&& (receipt.state === 'not_received' ? value.reviewed_at === null : value.reviewed_at !== null) : receipt === null;
|
|
22
|
+
}
|
|
23
|
+
export function realOperationsMatch(value, selected, filters = {}) {
|
|
24
|
+
return scope(value, selected) && value.query === (filters.query ?? '').trim() && value.outcome === (filters.outcome ?? '').trim()
|
|
25
|
+
&& value.service_id === (filters.service ?? null) && value.request_key === (filters.request ?? null) && value.review === (filters.review ?? '')
|
|
26
|
+
&& value.page === (filters.page ?? 1) && integer(value.count) && integer(value.page_size) && value.page_size >= 1 && value.page_size <= 100
|
|
27
|
+
&& Array.isArray(value.results) && value.results.length <= value.page_size && new Set(value.results.map(row => row.id)).size === value.results.length
|
|
28
|
+
&& value.results.every(row => realOperationMatches(row, selected) && (!filters.outcome || row.outcome === filters.outcome)
|
|
29
|
+
&& (!filters.request || row.request_key === filters.request) && (filters.review !== 'required' || row.requires_review));
|
|
30
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const uuid = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
2
|
+
const requestKey = /^[A-Za-z0-9][A-Za-z0-9:._-]{0,127}$/;
|
|
3
|
+
const states = new Set(['queued', 'preparing', 'submitted', 'succeeded', 'not_assessable', 'failed', 'unknown', 'unavailable']);
|
|
4
|
+
export function recommendationBatchMatches(value, scope, id) {
|
|
5
|
+
return !!value && uuid.test(value.id) && (!id || value.id === id) && value.workspace_id === scope.workspace
|
|
6
|
+
&& value.world_id === scope.world && (!scope.turn || value.turn_id === scope.turn) && (!scope.actor || value.actor_id === scope.actor)
|
|
7
|
+
&& uuid.test(value.turn_id) && uuid.test(value.actor_id) && Number.isSafeInteger(value.proposal_count)
|
|
8
|
+
&& value.proposal_count >= 1 && value.proposal_count <= 64 && !!value.states && typeof value.states === 'object' && !Array.isArray(value.states)
|
|
9
|
+
&& Object.entries(value.states).every(([key, count]) => states.has(key) && Number.isSafeInteger(count) && count >= 0)
|
|
10
|
+
&& Object.values(value.states).reduce((sum, count) => sum + count, 0) <= value.proposal_count
|
|
11
|
+
&& value.pending === ['queued', 'preparing', 'submitted'].some(key => (value.states[key] ?? 0) > 0);
|
|
12
|
+
}
|
|
13
|
+
export function recommendationBatchesMatch(value, scope) {
|
|
14
|
+
return value.workspace_id === scope.workspace && value.world_id === scope.world && value.turn_id === scope.turn
|
|
15
|
+
&& value.results.every(row => recommendationBatchMatches(row, scope));
|
|
16
|
+
}
|
|
17
|
+
export function recommendationTurnsMatch(value, scope, turn) {
|
|
18
|
+
return value.workspace_id === scope.workspace && value.world_id === scope.world && value.turn_filter === (turn ?? null)
|
|
19
|
+
&& value.results.every(row => uuid.test(row.id) && uuid.test(row.response_id) && (!turn || row.id === turn)
|
|
20
|
+
&& Number.isSafeInteger(row.proposal_count) && row.proposal_count >= 0);
|
|
21
|
+
}
|
|
22
|
+
export function recommendationDetailMatches(value, scope, id) {
|
|
23
|
+
return recommendationBatchMatches(value, scope, id) && value.results.length <= value.proposal_count
|
|
24
|
+
&& new Set(value.results.map(row => row.proposal_id)).size === value.results.length
|
|
25
|
+
&& value.results.every(row => uuid.test(row.id) && uuid.test(row.proposal_id) && states.has(row.state)
|
|
26
|
+
&& row.requested_model === value.model && row.provider === 'Firedrill'
|
|
27
|
+
&& (row.state !== 'unavailable' || row.result === null && row.evidence_refs.length === 0)
|
|
28
|
+
&& (row.result === null || !!row.model && ['succeeded', 'not_assessable'].includes(row.state)
|
|
29
|
+
&& row.result.levels.length === value.rubric.levels.length && row.result.levels.every((level, index) => level === value.rubric.levels[index])
|
|
30
|
+
&& (row.state === 'succeeded' ? row.result.status === 'assessable' && row.result.score !== null
|
|
31
|
+
&& Number.isFinite(row.result.score) && row.result.score >= 0 && row.result.score <= row.result.levels.length - 1
|
|
32
|
+
: row.result.score === null)));
|
|
33
|
+
}
|
|
34
|
+
export function recommendationReceiptMatches(value, scope, key) {
|
|
35
|
+
return !!value && value.schema === 'firedrill.recommendation-request-receipt.v1' && value.workspace_id === scope.workspace
|
|
36
|
+
&& value.world_id === scope.world && value.turn_id === scope.turn && value.actor_id === scope.actor
|
|
37
|
+
&& requestKey.test(value.request_key) && (key === undefined || value.request_key === key)
|
|
38
|
+
&& ['accepted', 'withdrawn', 'not_received'].includes(value.state) && typeof value.resource_available === 'boolean'
|
|
39
|
+
&& (value.resource_available ? value.state === 'accepted' && value.batch_id !== null && uuid.test(value.batch_id) : value.batch_id === null);
|
|
40
|
+
}
|
|
41
|
+
export function recommendationAcceptanceMatches(value, batch, scope, key) {
|
|
42
|
+
return recommendationReceiptMatches(value, scope, key) && recommendationBatchMatches(batch, scope)
|
|
43
|
+
&& value.state === 'accepted' && value.resource_available && value.batch_id === batch.id;
|
|
44
|
+
}
|
|
45
|
+
export function recommendationRequestsMatch(value, selected) {
|
|
46
|
+
return value.workspace_id === selected.workspace && value.world_id === selected.world && value.turn_id === selected.turn
|
|
47
|
+
&& value.actor_id === selected.actor && value.filters.q === selected.query.trim() && value.filters.status === selected.status
|
|
48
|
+
&& value.results.every(row => recommendationReceiptMatches(row, selected) && row.state !== 'not_received'
|
|
49
|
+
&& (!selected.status || row.state === selected.status));
|
|
50
|
+
}
|
|
51
|
+
export function recommendationRecoveryMatches(value, scope, batch, key) {
|
|
52
|
+
return value.workspace_id === scope.workspace && value.world_id === scope.world && value.actor_id === scope.actor
|
|
53
|
+
&& value.batch_id === batch && value.request_key === key && Number.isSafeInteger(value.requested) && value.requested >= 0 && value.requested <= 64;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|