firedrill-run 2.2.5 → 3.0.1
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 +176 -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 +506 -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 +1627 -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 +96 -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,277 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { lstat, open, unlink } from 'node:fs/promises';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
import { api } from './auth.js';
|
|
6
|
+
import { privateDirectory } from './credentials.js';
|
|
7
|
+
import { CliError } from './http.js';
|
|
8
|
+
import { identifier } from './world-contracts.js';
|
|
9
|
+
const MAX_BYTES = 256 * 1024, VARIABLE = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
10
|
+
const invalid = () => new CliError('configuration_input_invalid', 'Use the exact configuration metadata. Values and credentials belong in Vault, not this JSON file.', 2);
|
|
11
|
+
export const record = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
12
|
+
const fields = (value, required, optional = []) => required.every(key => Object.hasOwn(value, key))
|
|
13
|
+
&& Object.keys(value).every(key => required.includes(key) || optional.includes(key));
|
|
14
|
+
const revision = (value) => Number.isSafeInteger(value) && Number(value) >= 0;
|
|
15
|
+
const text = (value, maximum) => typeof value === 'string' && value.length <= maximum && !/[\u0000-\u001f\u007f]/.test(value)
|
|
16
|
+
&& Buffer.from(value).toString('utf8') === value;
|
|
17
|
+
const scopedKind = (kind, resource) => (resource !== null) === ['dependency', 'model_remove'].includes(kind);
|
|
18
|
+
function canonical(value) {
|
|
19
|
+
if (value === null || typeof value === 'boolean')
|
|
20
|
+
return JSON.stringify(value);
|
|
21
|
+
if (typeof value === 'string' && Buffer.from(value).toString('utf8') === value)
|
|
22
|
+
return JSON.stringify(value);
|
|
23
|
+
if (typeof value === 'number' && Number.isSafeInteger(value))
|
|
24
|
+
return JSON.stringify(value);
|
|
25
|
+
if (Array.isArray(value))
|
|
26
|
+
return '[' + value.map(canonical).join(',') + ']';
|
|
27
|
+
if (record(value))
|
|
28
|
+
return '{' + Object.keys(value).sort().map(key => JSON.stringify(key) + ':' + canonical(value[key])).join(',') + '}';
|
|
29
|
+
throw invalid();
|
|
30
|
+
}
|
|
31
|
+
const fingerprint = (kind, service_id, body) => createHash('sha256').update(canonical({ kind, service_id, body })).digest('hex');
|
|
32
|
+
export function inputSchema(kind) {
|
|
33
|
+
const variable = { type: 'string', pattern: '^[A-Za-z_][A-Za-z0-9_]{0,127}$' };
|
|
34
|
+
const version = { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER };
|
|
35
|
+
const schema = (properties, required, rest = {}) => ({ type: 'object', additionalProperties: false, properties, required, ...rest });
|
|
36
|
+
if (kind === 'model_remove')
|
|
37
|
+
return { $schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
38
|
+
...schema({ configuration_revision: version }, ['configuration_revision']) };
|
|
39
|
+
if (kind === 'model')
|
|
40
|
+
return { $schema: 'https://json-schema.org/draft/2020-12/schema', ...schema({
|
|
41
|
+
configuration_revision: version, mapping_id: { type: 'string', format: 'uuid' }, provider: { enum: ['anthropic', 'openai'] },
|
|
42
|
+
base_url_variable: variable, models: { type: 'array', minItems: 1, maxItems: 1000, uniqueItems: true,
|
|
43
|
+
items: { type: 'string', pattern: '^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$' } }, authorize_target_model_usage: { const: true }
|
|
44
|
+
}, ['configuration_revision', 'mapping_id', 'provider', 'base_url_variable', 'models', 'authorize_target_model_usage']) };
|
|
45
|
+
if (kind === 'mappings')
|
|
46
|
+
return { $schema: 'https://json-schema.org/draft/2020-12/schema', ...schema({ revision: version,
|
|
47
|
+
mappings: { type: 'array', minItems: 1, items: schema({ name: variable, phase: { enum: ['build', 'runtime', 'both'] },
|
|
48
|
+
source: { enum: ['unset', 'vault', 'default', 'world', 'local', 'remove'] }, vault_entry_id: { type: ['string', 'null'], format: 'uuid' },
|
|
49
|
+
binding_key: { type: 'string', maxLength: 255 }, dependency_key: { type: 'string', maxLength: 255 } }, ['name', 'phase', 'source']) } }, ['revision', 'mappings']) };
|
|
50
|
+
const versions = { configuration_revision: version, service_revision: { ...version, minimum: 1 } };
|
|
51
|
+
return { $schema: 'https://json-schema.org/draft/2020-12/schema', oneOf: [schema({ ...versions, mode: { const: 'unselected' } }, ['mode', 'configuration_revision', 'service_revision']), schema({ ...versions, mode: { const: 'simulated' },
|
|
52
|
+
catalog: schema({ implementation_id: { type: 'string', format: 'uuid' }, package_service_key: { type: 'string', pattern: '^[a-z][a-z0-9_-]{0,79}$' } }, ['implementation_id', 'package_service_key']) }, ['mode', 'configuration_revision', 'service_revision']), schema({ ...versions, mode: { const: 'real' },
|
|
53
|
+
allowed_hosts: { type: 'array', minItems: 1, items: { type: 'string', minLength: 1, maxLength: 253 } },
|
|
54
|
+
allow_all_operations: { type: 'boolean' }, operation_names: { type: 'array', items: { type: 'string', minLength: 1, maxLength: 255 } },
|
|
55
|
+
acknowledge_external_effects: { const: true }, allow_write_effects: { type: 'boolean' },
|
|
56
|
+
http_binding: schema({ base_url: { type: 'string', format: 'uri', maxLength: 2048 }, endpoint_variable: variable,
|
|
57
|
+
authentication: { type: 'array', maxItems: 16, items: schema({ variable, header: { type: 'string', pattern: '^[A-Za-z][A-Za-z0-9-]{0,63}$' },
|
|
58
|
+
prefix: { type: 'string', pattern: '^(?:[A-Za-z][A-Za-z0-9_-]{0,31} )?$' } }, ['variable', 'header', 'prefix']) } }, ['base_url', 'endpoint_variable', 'authentication']) }, ['mode', 'configuration_revision', 'service_revision', 'allowed_hosts', 'acknowledge_external_effects', 'http_binding'], { anyOf: [{ required: ['allow_all_operations'], properties: { allow_all_operations: { const: true } } },
|
|
59
|
+
{ required: ['operation_names'], properties: { operation_names: { minItems: 1 } } }] })] };
|
|
60
|
+
}
|
|
61
|
+
/** Metadata allowlist before any local recovery record is written. */
|
|
62
|
+
export function validateBody(kind, body) {
|
|
63
|
+
if (kind === 'model_remove') {
|
|
64
|
+
if (!fields(body, ['configuration_revision']) || !revision(body.configuration_revision))
|
|
65
|
+
throw invalid();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (kind === 'model') {
|
|
69
|
+
if (!fields(body, ['configuration_revision', 'mapping_id', 'provider', 'base_url_variable', 'models', 'authorize_target_model_usage'])
|
|
70
|
+
|| !revision(body.configuration_revision) || typeof body.mapping_id !== 'string'
|
|
71
|
+
|| typeof body.provider !== 'string' || !['anthropic', 'openai'].includes(body.provider)
|
|
72
|
+
|| typeof body.base_url_variable !== 'string' || !VARIABLE.test(body.base_url_variable)
|
|
73
|
+
|| !Array.isArray(body.models) || !body.models.length || body.models.length > 1000 || new Set(body.models).size !== body.models.length
|
|
74
|
+
|| body.models.some(one => typeof one !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(one))
|
|
75
|
+
|| body.authorize_target_model_usage !== true)
|
|
76
|
+
throw invalid();
|
|
77
|
+
identifier(body.mapping_id);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (kind === 'mappings') {
|
|
81
|
+
if (!fields(body, ['revision', 'mappings']) || !revision(body.revision) || !Array.isArray(body.mappings) || !body.mappings.length)
|
|
82
|
+
throw invalid();
|
|
83
|
+
const seen = new Set();
|
|
84
|
+
for (const row of body.mappings) {
|
|
85
|
+
if (!record(row) || !fields(row, ['name', 'phase', 'source'], ['vault_entry_id', 'binding_key', 'dependency_key'])
|
|
86
|
+
|| typeof row.name !== 'string' || !VARIABLE.test(row.name) || typeof row.phase !== 'string' || !['build', 'runtime', 'both'].includes(row.phase)
|
|
87
|
+
|| typeof row.source !== 'string' || !['unset', 'vault', 'default', 'world', 'local', 'remove'].includes(row.source)
|
|
88
|
+
|| ['binding_key', 'dependency_key'].some(key => row[key] !== undefined && !text(row[key], 255)))
|
|
89
|
+
throw invalid();
|
|
90
|
+
if (row.vault_entry_id !== undefined && row.vault_entry_id !== null)
|
|
91
|
+
identifier(String(row.vault_entry_id));
|
|
92
|
+
if (row.source === 'vault' && typeof row.vault_entry_id !== 'string' || row.source === 'world' && !row.binding_key)
|
|
93
|
+
throw invalid();
|
|
94
|
+
if (row.source === 'local')
|
|
95
|
+
identifier(String(row.binding_key));
|
|
96
|
+
const key = row.name + ':' + row.phase;
|
|
97
|
+
if (seen.has(key))
|
|
98
|
+
throw invalid();
|
|
99
|
+
seen.add(key);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (!fields(body, ['mode', 'configuration_revision', 'service_revision'], ['allowed_hosts', 'allow_all_operations', 'operation_names',
|
|
104
|
+
'acknowledge_external_effects', 'allow_write_effects', 'http_binding', 'catalog']) || !revision(body.configuration_revision)
|
|
105
|
+
|| !Number.isSafeInteger(body.service_revision) || Number(body.service_revision) < 1
|
|
106
|
+
|| typeof body.mode !== 'string' || !['simulated', 'real', 'unselected'].includes(body.mode))
|
|
107
|
+
throw invalid();
|
|
108
|
+
if (body.catalog !== undefined) {
|
|
109
|
+
if (body.mode !== 'simulated' || !record(body.catalog) || !fields(body.catalog, ['implementation_id', 'package_service_key'])
|
|
110
|
+
|| typeof body.catalog.implementation_id !== 'string' || typeof body.catalog.package_service_key !== 'string'
|
|
111
|
+
|| !/^[a-z][a-z0-9_-]{0,79}$/.test(body.catalog.package_service_key))
|
|
112
|
+
throw invalid();
|
|
113
|
+
identifier(body.catalog.implementation_id);
|
|
114
|
+
}
|
|
115
|
+
for (const key of ['allow_all_operations', 'acknowledge_external_effects', 'allow_write_effects'])
|
|
116
|
+
if (body[key] !== undefined && typeof body[key] !== 'boolean')
|
|
117
|
+
throw invalid();
|
|
118
|
+
if (body.operation_names !== undefined && (!Array.isArray(body.operation_names) || body.operation_names.some(one => !text(one, 255) || !one)))
|
|
119
|
+
throw invalid();
|
|
120
|
+
if (body.allowed_hosts !== undefined && (!Array.isArray(body.allowed_hosts) || body.allowed_hosts.some(one => !text(one, 253) || !one || /[\s/:?#@*\\]/.test(String(one)))))
|
|
121
|
+
throw invalid();
|
|
122
|
+
if (body.mode === 'real') {
|
|
123
|
+
const binding = body.http_binding;
|
|
124
|
+
if (!record(binding) || !fields(binding, ['base_url', 'endpoint_variable', 'authentication']) || !text(binding.base_url, 2048)
|
|
125
|
+
|| typeof binding.endpoint_variable !== 'string' || !VARIABLE.test(binding.endpoint_variable)
|
|
126
|
+
|| !Array.isArray(binding.authentication) || binding.authentication.length > 16
|
|
127
|
+
|| body.acknowledge_external_effects !== true || !Array.isArray(body.allowed_hosts) || !body.allowed_hosts.length
|
|
128
|
+
|| body.allow_all_operations !== true && (!Array.isArray(body.operation_names) || !body.operation_names.length))
|
|
129
|
+
throw invalid();
|
|
130
|
+
const url = new URL(String(binding.base_url));
|
|
131
|
+
if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash || url.port && url.port !== '443'
|
|
132
|
+
|| !body.allowed_hosts.includes(url.hostname) || !/^(?:\/[A-Za-z0-9_~.-]+)*\/?$/.test(url.pathname))
|
|
133
|
+
throw invalid();
|
|
134
|
+
const names = new Set([binding.endpoint_variable]), headers = new Set();
|
|
135
|
+
for (const row of binding.authentication) {
|
|
136
|
+
if (!record(row) || !fields(row, ['variable', 'header', 'prefix']) || typeof row.variable !== 'string' || !VARIABLE.test(row.variable)
|
|
137
|
+
|| names.has(row.variable) || typeof row.header !== 'string' || !/^[A-Za-z][A-Za-z0-9-]{0,63}$/.test(row.header)
|
|
138
|
+
|| headers.has(row.header.toLowerCase()) || typeof row.prefix !== 'string' || !/^(?:[A-Za-z][A-Za-z0-9_-]{0,31} )?$/.test(row.prefix))
|
|
139
|
+
throw invalid();
|
|
140
|
+
names.add(row.variable);
|
|
141
|
+
headers.add(row.header.toLowerCase());
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (body.http_binding !== undefined)
|
|
145
|
+
throw invalid();
|
|
146
|
+
}
|
|
147
|
+
export async function readMetadata(path, privateFile = false) {
|
|
148
|
+
const before = await lstat(resolve(path));
|
|
149
|
+
if (!before.isFile() || before.isSymbolicLink() || before.nlink !== 1 || before.size < 2 || before.size > MAX_BYTES
|
|
150
|
+
|| privateFile && (process.getuid && before.uid !== process.getuid() || process.platform !== 'win32' && !!(before.mode & 0o077)))
|
|
151
|
+
throw invalid();
|
|
152
|
+
const file = await open(resolve(path), constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
153
|
+
try {
|
|
154
|
+
const actual = await file.stat();
|
|
155
|
+
if (!actual.isFile() || actual.ino !== before.ino || actual.dev !== before.dev || actual.size !== before.size || actual.mtimeMs !== before.mtimeMs)
|
|
156
|
+
throw invalid();
|
|
157
|
+
const buffer = Buffer.alloc(actual.size);
|
|
158
|
+
let offset = 0;
|
|
159
|
+
while (offset < buffer.length) {
|
|
160
|
+
const part = await file.read(buffer, offset, buffer.length - offset, offset);
|
|
161
|
+
if (!part.bytesRead)
|
|
162
|
+
throw invalid();
|
|
163
|
+
offset += part.bytesRead;
|
|
164
|
+
}
|
|
165
|
+
const after = await file.stat();
|
|
166
|
+
if (after.size !== actual.size || after.mtimeMs !== actual.mtimeMs || after.ctimeMs !== actual.ctimeMs)
|
|
167
|
+
throw invalid();
|
|
168
|
+
const value = JSON.parse(new TextDecoder('utf8', { fatal: true }).decode(buffer));
|
|
169
|
+
if (!record(value))
|
|
170
|
+
throw invalid();
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
throw invalid();
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
await file.close();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const location = async (scope, key) => join(await privateDirectory(), `configuration-${identifier(scope.owner)}-${identifier(scope.workspace)}-${identifier(key)}.json`);
|
|
181
|
+
export async function retained(scope, key) {
|
|
182
|
+
const value = await readMetadata(await location(scope, key), true);
|
|
183
|
+
if (!fields(value, ['schema', 'owner', 'workspace', 'world', 'key', 'kind', 'service_id', 'body', 'digest'])
|
|
184
|
+
|| value.schema !== 'firedrill.local-configuration-intent.v1' || value.owner !== scope.owner || value.workspace !== scope.workspace
|
|
185
|
+
|| value.key !== identifier(key) || typeof value.world !== 'string' || !record(value.body)
|
|
186
|
+
|| typeof value.kind !== 'string' || !['mappings', 'dependency', 'model', 'model_remove'].includes(value.kind)
|
|
187
|
+
|| !scopedKind(value.kind, value.service_id))
|
|
188
|
+
throw invalid();
|
|
189
|
+
identifier(value.world);
|
|
190
|
+
if (value.service_id !== null && (typeof value.service_id !== 'string' || identifier(value.service_id) !== value.service_id))
|
|
191
|
+
throw invalid();
|
|
192
|
+
validateBody(value.kind, value.body);
|
|
193
|
+
if (value.digest !== fingerprint(value.kind, value.service_id, value.body))
|
|
194
|
+
throw invalid();
|
|
195
|
+
return value;
|
|
196
|
+
}
|
|
197
|
+
function verify(receipt, intent) {
|
|
198
|
+
if (receipt.schema !== 'firedrill.configuration-command.v1' || receipt.request_key !== intent.key || receipt.world_id !== intent.world
|
|
199
|
+
|| !['not_received', 'accepted', 'withdrawn'].includes(receipt.state)
|
|
200
|
+
|| receipt.state !== 'not_received' && (receipt.request_digest !== intent.digest || receipt.kind !== intent.kind || receipt.service_id !== intent.service_id)
|
|
201
|
+
|| receipt.state === 'accepted' && !revision(receipt.configuration_revision) || typeof receipt.current !== 'boolean')
|
|
202
|
+
throw invalid();
|
|
203
|
+
}
|
|
204
|
+
function show(receipt, output) {
|
|
205
|
+
output('result', receipt, receipt.state === 'accepted' ? `Configuration saved at revision ${receipt.configuration_revision}.${receipt.current ? '' : ' The world has changed since this request.'}`
|
|
206
|
+
: receipt.state === 'withdrawn' ? 'Configuration request withdrawn. It cannot change the world.'
|
|
207
|
+
: 'No accepted configuration receipt is visible. The original request may still arrive; withdraw it to prevent a late change.');
|
|
208
|
+
}
|
|
209
|
+
export async function submit(intent, context, signal, output) {
|
|
210
|
+
if (context.world !== intent.world || context.owner !== intent.owner || context.workspace !== intent.workspace)
|
|
211
|
+
throw invalid();
|
|
212
|
+
output('configuration_request', { request_key: intent.key, kind: intent.kind, request_digest: intent.digest }, `Request: ${intent.key}\nIf the reply is interrupted: firedrill configuration status --workspace ${intent.workspace} --request-key ${intent.key}`);
|
|
213
|
+
const resource = intent.kind === 'mappings' ? '/configuration' : intent.kind === 'model' ? '/model-connections'
|
|
214
|
+
: intent.kind === 'model_remove' ? '/model-connections/' + identifier(intent.service_id) : '/dependencies/' + identifier(intent.service_id);
|
|
215
|
+
const method = intent.kind === 'mappings' ? 'PATCH' : intent.kind === 'model' ? 'POST' : intent.kind === 'model_remove' ? 'DELETE' : 'PUT';
|
|
216
|
+
const result = await api(context.prefix + resource, { actor: context.owner, workspace: context.workspace, signal, method, idempotencyKey: intent.key, body: intent.body });
|
|
217
|
+
verify(result.configuration_receipt, intent);
|
|
218
|
+
if (result.configuration_receipt.state !== 'accepted')
|
|
219
|
+
throw invalid();
|
|
220
|
+
show(result.configuration_receipt, output);
|
|
221
|
+
}
|
|
222
|
+
export async function remember(context, kind, service, body, request, signal, output) {
|
|
223
|
+
validateBody(kind, body);
|
|
224
|
+
if (!scopedKind(kind, service))
|
|
225
|
+
throw invalid();
|
|
226
|
+
if (service !== null)
|
|
227
|
+
service = identifier(service);
|
|
228
|
+
const key = request ? identifier(request) : randomUUID();
|
|
229
|
+
const intent = { schema: 'firedrill.local-configuration-intent.v1', owner: context.owner, workspace: context.workspace,
|
|
230
|
+
world: context.world, key, kind, service_id: service, body, digest: fingerprint(kind, service, body) };
|
|
231
|
+
const encoded = JSON.stringify(intent);
|
|
232
|
+
if (Buffer.byteLength(encoded) > MAX_BYTES)
|
|
233
|
+
throw invalid();
|
|
234
|
+
try {
|
|
235
|
+
const file = await open(await location(context, key), 'wx', 0o600);
|
|
236
|
+
try {
|
|
237
|
+
await file.writeFile(encoded);
|
|
238
|
+
await file.sync();
|
|
239
|
+
}
|
|
240
|
+
finally {
|
|
241
|
+
await file.close();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
if (!error || typeof error !== 'object' || !('code' in error) || error.code !== 'EEXIST')
|
|
246
|
+
throw error;
|
|
247
|
+
const prior = await retained(context, key);
|
|
248
|
+
if (prior.world !== context.world || prior.digest !== intent.digest || prior.kind !== kind || prior.service_id !== service)
|
|
249
|
+
throw invalid();
|
|
250
|
+
}
|
|
251
|
+
return submit(intent, context, signal, output);
|
|
252
|
+
}
|
|
253
|
+
export async function requestAction(context, intent, action, signal, output) {
|
|
254
|
+
if (context.world !== intent.world || context.owner !== intent.owner || context.workspace !== intent.workspace)
|
|
255
|
+
throw invalid();
|
|
256
|
+
if (action === 'forget') {
|
|
257
|
+
await unlink(await location(context, intent.key));
|
|
258
|
+
output('result', { request_key: intent.key, local_copy_removed: true }, 'Local recovery copy removed. Any accepted or delayed server request is unchanged.');
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const receipt = await api(`${context.prefix}/configuration-requests/${identifier(intent.key)}`, { actor: context.owner,
|
|
262
|
+
workspace: context.workspace, signal, ...(action === 'withdraw' ? { method: 'DELETE', body: {
|
|
263
|
+
kind: intent.kind, service_id: intent.service_id, request_digest: intent.digest
|
|
264
|
+
} } : {}) });
|
|
265
|
+
verify(receipt, intent);
|
|
266
|
+
if (action === 'withdraw' && receipt.state === 'accepted') {
|
|
267
|
+
output('result', receipt, `This request was already accepted at configuration revision ${receipt.configuration_revision}. It was not undone.`);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (action !== 'resume' || receipt.state !== 'not_received') {
|
|
271
|
+
show(receipt, output);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
// Explicit resume repeats the SAME approved metadata request under the SAME
|
|
275
|
+
// transaction receipt. It never creates another revision or real operation.
|
|
276
|
+
return submit(intent, context, signal, output);
|
|
277
|
+
}
|