@treeseed/sdk 0.11.0 → 0.12.4
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 +9 -4
- package/dist/agent-capacity.d.ts +916 -0
- package/dist/agent-capacity.js +1600 -0
- package/dist/agent-tools.d.ts +37 -0
- package/dist/agent-tools.js +301 -0
- package/dist/api/app.d.ts +1 -1
- package/dist/api/auth/d1-database.d.ts +2 -2
- package/dist/api/auth/d1-provider.d.ts +4 -4
- package/dist/api/auth/d1-store.d.ts +2 -2
- package/dist/api/auth/memory-provider.d.ts +1 -1
- package/dist/api/auth/tokens.d.ts +1 -1
- package/dist/api/config.d.ts +3 -1
- package/dist/api/config.js +34 -10
- package/dist/api/http.d.ts +2 -2
- package/dist/api/index.d.ts +10 -10
- package/dist/api/index.js +4 -2
- package/dist/api/operations-routes.d.ts +3 -3
- package/dist/api/operations.d.ts +1 -1
- package/dist/api/providers.d.ts +1 -1
- package/dist/api/providers.js +21 -4
- package/dist/api/railway.d.ts +3 -2
- package/dist/api/sdk-dispatch.d.ts +4 -4
- package/dist/api/sdk-routes.d.ts +2 -2
- package/dist/api/templates.d.ts +2 -2
- package/dist/api/types.d.ts +3 -2
- package/dist/capacity-provider.d.ts +117 -60
- package/dist/capacity-provider.js +215 -43
- package/dist/capacity.d.ts +2 -2
- package/dist/cli-tools.d.ts +1 -1
- package/dist/content-operations.d.ts +97 -0
- package/dist/content-operations.js +250 -0
- package/dist/content-store.d.ts +4 -4
- package/dist/control-plane-client.d.ts +13 -18
- package/dist/control-plane-client.js +8 -86
- package/dist/control-plane.d.ts +2 -2
- package/dist/copilot.d.ts +3 -0
- package/dist/copilot.js +16 -1
- package/dist/d1-http.d.ts +1 -1
- package/dist/d1-store.d.ts +32 -57
- package/dist/d1-store.js +115 -318
- package/dist/db/d1.d.ts +1 -232
- package/dist/db/index.d.ts +3 -3
- package/dist/db/market-schema.d.ts +49037 -11843
- package/dist/db/market-schema.js +1788 -50
- package/dist/db/node-sqlite.d.ts +1 -232
- package/dist/db/schema.d.ts +0 -462
- package/dist/db/schema.js +2 -22
- package/dist/dispatch.d.ts +1 -1
- package/dist/dispatch.js +0 -11
- package/dist/fixture-support.js +52 -4
- package/dist/governance.d.ts +133 -0
- package/dist/governance.js +285 -0
- package/dist/graph/build.d.ts +2 -2
- package/dist/graph/context-query-contracts.d.ts +1 -1
- package/dist/graph/dsl.d.ts +1 -1
- package/dist/graph/query.d.ts +4 -4
- package/dist/graph/ranking.d.ts +1 -1
- package/dist/graph/schema.d.ts +1 -1
- package/dist/graph.d.ts +11 -11
- package/dist/guarantees/index.d.ts +425 -0
- package/dist/guarantees/index.js +1146 -0
- package/dist/hosting/apps.d.ts +1 -1
- package/dist/hosting/builtins.d.ts +1 -1
- package/dist/hosting/builtins.js +9 -198
- package/dist/hosting/contracts.d.ts +3 -2
- package/dist/hosting/graph.d.ts +24 -21
- package/dist/hosting/graph.js +280 -294
- package/dist/hosting/index.d.ts +4 -4
- package/dist/index.d.ts +88 -74
- package/dist/index.js +81 -10
- package/dist/local-dev/managed-dev.d.ts +85 -0
- package/dist/local-dev/managed-dev.js +368 -0
- package/dist/managed-dependencies.d.ts +9 -0
- package/dist/managed-dependencies.js +10 -8
- package/dist/market-client.d.ts +265 -7
- package/dist/market-client.js +381 -9
- package/dist/model-registry.d.ts +1 -1
- package/dist/model-registry.js +19 -19
- package/dist/operations/agent-tools.d.ts +2 -11
- package/dist/operations/agent-tools.js +2 -14
- package/dist/operations/providers/default.d.ts +1 -1
- package/dist/operations/providers/default.js +20 -37
- package/dist/operations/repository-operations.d.ts +26 -2
- package/dist/operations/repository-operations.js +159 -1
- package/dist/operations/runtime.d.ts +3 -3
- package/dist/operations/services/bootstrap-runner.d.ts +1 -1
- package/dist/operations/services/build-warning-policy.d.ts +34 -0
- package/dist/operations/services/build-warning-policy.js +81 -82
- package/dist/operations/services/commit-message-provider.js +4 -4
- package/dist/operations/services/config-runtime.d.ts +73 -19
- package/dist/operations/services/config-runtime.js +276 -100
- package/dist/operations/services/deploy.d.ts +41 -622
- package/dist/operations/services/deploy.js +181 -213
- package/dist/operations/services/deployment-readiness.d.ts +1 -1
- package/dist/operations/services/deployment-readiness.js +38 -7
- package/dist/operations/services/git-remote-policy.js +12 -4
- package/dist/operations/services/git-runner.d.ts +66 -0
- package/dist/operations/services/git-runner.js +479 -0
- package/dist/operations/services/git-workflow.d.ts +43 -5
- package/dist/operations/services/git-workflow.js +242 -20
- package/dist/operations/services/github-actions-verification.d.ts +3 -1
- package/dist/operations/services/github-actions-verification.js +11 -3
- package/dist/operations/services/github-api.js +21 -5
- package/dist/operations/services/github-automation.d.ts +3 -3
- package/dist/operations/services/github-automation.js +15 -18
- package/dist/operations/services/github-credentials.js +2 -1
- package/dist/operations/services/hosted-service-checks.d.ts +19 -1
- package/dist/operations/services/hosted-service-checks.js +162 -11
- package/dist/operations/services/hosting-audit.d.ts +2 -2
- package/dist/operations/services/hosting-audit.js +7 -7
- package/dist/operations/services/hub-launch.d.ts +1 -1
- package/dist/operations/services/hub-provider-launch.d.ts +5 -5
- package/dist/operations/services/hub-provider-launch.js +19 -14
- package/dist/operations/services/live-hosted-service-checks.d.ts +2 -1
- package/dist/operations/services/live-hosted-service-checks.js +193 -80
- package/dist/operations/services/local-dev.js +0 -1
- package/dist/operations/services/managed-host-security.d.ts +1 -1
- package/dist/operations/services/managed-repositories.d.ts +37 -0
- package/dist/operations/services/managed-repositories.js +177 -0
- package/dist/operations/services/operations-runner-smoke.d.ts +3 -2
- package/dist/operations/services/operations-runner-smoke.js +22 -4
- package/dist/operations/services/package-adapters.d.ts +77 -2
- package/dist/operations/services/package-adapters.js +627 -56
- package/dist/operations/services/package-reference-policy.d.ts +12 -88
- package/dist/operations/services/package-reference-policy.js +81 -213
- package/dist/operations/services/project-host-operations.d.ts +4 -4
- package/dist/operations/services/project-platform.d.ts +19 -193
- package/dist/operations/services/project-platform.js +31 -103
- package/dist/operations/services/project-web-monitor.d.ts +2 -2
- package/dist/operations/services/project-web-monitor.js +97 -2
- package/dist/operations/services/railway-api.d.ts +36 -7
- package/dist/operations/services/railway-api.js +331 -100
- package/dist/operations/services/railway-deploy.d.ts +7 -95
- package/dist/operations/services/railway-deploy.js +334 -742
- package/dist/operations/services/release-history.js +3 -4
- package/dist/operations/services/release-proof-ledger.d.ts +13 -0
- package/dist/operations/services/release-proof-ledger.js +81 -0
- package/dist/operations/services/release-proof-planner.d.ts +48 -0
- package/dist/operations/services/release-proof-planner.js +195 -0
- package/dist/operations/services/release-proof-runner.d.ts +16 -0
- package/dist/operations/services/release-proof-runner.js +169 -0
- package/dist/operations/services/release-proof.d.ts +81 -0
- package/dist/operations/services/release-proof.js +79 -0
- package/dist/operations/services/repository-save-orchestrator.d.ts +6 -7
- package/dist/operations/services/repository-save-orchestrator.js +353 -174
- package/dist/operations/services/runtime-paths.d.ts +1 -3
- package/dist/operations/services/runtime-paths.js +0 -4
- package/dist/operations/services/runtime-tools.d.ts +1 -192
- package/dist/operations/services/runtime-tools.js +4 -444
- package/dist/operations/services/save-deploy-preflight.js +9 -1
- package/dist/operations/services/template-host-bindings.d.ts +2 -2
- package/dist/operations/services/template-host-bindings.js +3 -2
- package/dist/operations/services/template-registry.d.ts +6 -6
- package/dist/operations/services/template-registry.js +33 -14
- package/dist/operations/services/template-secret-sync.d.ts +3 -3
- package/dist/operations/services/workflow-timing.d.ts +25 -0
- package/dist/operations/services/workflow-timing.js +79 -0
- package/dist/operations/services/workspace-dependency-mode.js +41 -4
- package/dist/operations/services/workspace-preflight.js +8 -8
- package/dist/operations/services/workspace-save-script.d.ts +4 -4
- package/dist/operations/services/workspace-save.d.ts +1 -0
- package/dist/operations/services/workspace-save.js +41 -18
- package/dist/operations/services/workspace-tools.js +40 -6
- package/dist/operations-registry.d.ts +1 -1
- package/dist/operations-registry.js +5 -6
- package/dist/operations-types.d.ts +1 -1
- package/dist/operations.d.ts +17 -11
- package/dist/operations.js +57 -3
- package/dist/platform/book-export.js +2 -0
- package/dist/platform/books-data.d.ts +1 -1
- package/dist/platform/config.d.ts +27 -0
- package/dist/platform/config.js +100 -0
- package/dist/platform/content-runtime-source.d.ts +54 -0
- package/dist/platform/content-runtime-source.js +169 -0
- package/dist/platform/contracts.d.ts +6 -1
- package/dist/platform/deploy-config.d.ts +1 -1
- package/dist/platform/deploy-config.js +7 -1
- package/dist/platform/deploy-runtime.d.ts +1 -1
- package/dist/platform/desired-state.d.ts +63 -0
- package/dist/platform/desired-state.js +1021 -0
- package/dist/platform/env.yaml +414 -19
- package/dist/platform/environment.d.ts +2 -2
- package/dist/platform/environment.js +54 -22
- package/dist/platform/local-content-materialization.d.ts +9 -0
- package/dist/platform/local-content-materialization.js +212 -0
- package/dist/platform/plugin.d.ts +5 -5
- package/dist/platform/plugins/runtime.d.ts +3 -3
- package/dist/platform/plugins/runtime.js +62 -1
- package/dist/platform/plugins.d.ts +6 -6
- package/dist/platform/published-content-pipeline.d.ts +3 -3
- package/dist/platform/published-content-pipeline.js +5 -1
- package/dist/platform/published-content.d.ts +4 -3
- package/dist/platform/site-config-schema.d.ts +1 -0
- package/dist/platform/site-config-schema.js +4 -1
- package/dist/platform/tenant/runtime-config.d.ts +152 -2
- package/dist/platform/tenant-config.d.ts +1 -1
- package/dist/platform/utils/site-config-schema.d.ts +154 -0
- package/dist/platform/utils/site-config-schema.js +400 -461
- package/dist/platform-operation-store.d.ts +1 -1
- package/dist/plugin-default.d.ts +1 -1
- package/dist/plugin-default.js +27 -12
- package/dist/project-import.d.ts +91 -0
- package/dist/project-import.js +257 -0
- package/dist/project-workflow.d.ts +1 -1
- package/dist/reconcile/bootstrap-systems.d.ts +2 -2
- package/dist/reconcile/bootstrap-systems.js +3 -3
- package/dist/reconcile/builtin-adapters.d.ts +7 -1
- package/dist/reconcile/builtin-adapters.js +2924 -346
- package/dist/reconcile/contracts.d.ts +15 -2
- package/dist/reconcile/desired-state.d.ts +2 -193
- package/dist/reconcile/desired-state.js +24 -33
- package/dist/reconcile/engine.d.ts +60 -397
- package/dist/reconcile/engine.js +182 -18
- package/dist/reconcile/index.d.ts +10 -10
- package/dist/reconcile/live-acceptance.d.ts +22 -1
- package/dist/reconcile/live-acceptance.js +456 -44
- package/dist/reconcile/providers/docker-private.d.ts +54 -0
- package/dist/reconcile/providers/docker-private.js +101 -0
- package/dist/reconcile/providers/github-private.d.ts +65 -0
- package/dist/reconcile/providers/github-private.js +119 -0
- package/dist/reconcile/providers/local-private.d.ts +28 -0
- package/dist/reconcile/providers/local-private.js +75 -0
- package/dist/reconcile/providers/railway-iac.d.ts +66 -0
- package/dist/reconcile/providers/railway-iac.js +275 -0
- package/dist/reconcile/providers/release-private.d.ts +92 -0
- package/dist/reconcile/providers/release-private.js +152 -0
- package/dist/reconcile/registry.d.ts +2 -2
- package/dist/reconcile/registry.js +16 -1
- package/dist/reconcile/state.d.ts +1 -1
- package/dist/reconcile/state.js +3 -40
- package/dist/reconcile/units.d.ts +1 -1
- package/dist/reconcile/units.js +7 -1
- package/dist/remote.d.ts +6 -6
- package/dist/scenes/artifacts.d.ts +16 -0
- package/dist/scenes/artifacts.js +61 -0
- package/dist/scenes/auth.d.ts +2 -0
- package/dist/scenes/auth.js +28 -0
- package/dist/scenes/base-url.d.ts +12 -0
- package/dist/scenes/base-url.js +123 -0
- package/dist/scenes/builtin-plugins.d.ts +2 -0
- package/dist/scenes/builtin-plugins.js +447 -0
- package/dist/scenes/checkpoints.d.ts +14 -0
- package/dist/scenes/checkpoints.js +33 -0
- package/dist/scenes/device-matrix.d.ts +2 -0
- package/dist/scenes/device-matrix.js +97 -0
- package/dist/scenes/devices.d.ts +11 -0
- package/dist/scenes/devices.js +22 -0
- package/dist/scenes/diagnostics.d.ts +5 -0
- package/dist/scenes/diagnostics.js +22 -0
- package/dist/scenes/diagram-providers.d.ts +2 -0
- package/dist/scenes/diagram-providers.js +181 -0
- package/dist/scenes/diagram-validation.d.ts +22 -0
- package/dist/scenes/diagram-validation.js +74 -0
- package/dist/scenes/environment.d.ts +2 -0
- package/dist/scenes/environment.js +65 -0
- package/dist/scenes/evidence-bundle.d.ts +5 -0
- package/dist/scenes/evidence-bundle.js +42 -0
- package/dist/scenes/evidence-report.d.ts +10 -0
- package/dist/scenes/evidence-report.js +73 -0
- package/dist/scenes/evidence.d.ts +16 -0
- package/dist/scenes/evidence.js +277 -0
- package/dist/scenes/index.d.ts +48 -0
- package/dist/scenes/index.js +312 -0
- package/dist/scenes/inspect.d.ts +9 -0
- package/dist/scenes/inspect.js +64 -0
- package/dist/scenes/loader.d.ts +3 -0
- package/dist/scenes/loader.js +38 -0
- package/dist/scenes/logs.d.ts +2 -0
- package/dist/scenes/logs.js +47 -0
- package/dist/scenes/operations.d.ts +3 -0
- package/dist/scenes/operations.js +128 -0
- package/dist/scenes/phase0.d.ts +9 -0
- package/dist/scenes/phase0.js +637 -0
- package/dist/scenes/planner.d.ts +12 -0
- package/dist/scenes/planner.js +166 -0
- package/dist/scenes/playwright-adapter.d.ts +2 -0
- package/dist/scenes/playwright-adapter.js +63 -0
- package/dist/scenes/plugins.d.ts +5 -0
- package/dist/scenes/plugins.js +115 -0
- package/dist/scenes/progress.d.ts +17 -0
- package/dist/scenes/progress.js +24 -0
- package/dist/scenes/publish-destinations.d.ts +12 -0
- package/dist/scenes/publish-destinations.js +99 -0
- package/dist/scenes/publish-plan-report.d.ts +10 -0
- package/dist/scenes/publish-plan-report.js +70 -0
- package/dist/scenes/publish-plan.d.ts +15 -0
- package/dist/scenes/publish-plan.js +248 -0
- package/dist/scenes/publish-redaction.d.ts +16 -0
- package/dist/scenes/publish-redaction.js +148 -0
- package/dist/scenes/publish-release-record.d.ts +13 -0
- package/dist/scenes/publish-release-record.js +34 -0
- package/dist/scenes/publish-report.d.ts +10 -0
- package/dist/scenes/publish-report.js +67 -0
- package/dist/scenes/publish.d.ts +16 -0
- package/dist/scenes/publish.js +298 -0
- package/dist/scenes/registry.d.ts +12 -0
- package/dist/scenes/registry.js +65 -0
- package/dist/scenes/remotion-adapter.d.ts +3 -0
- package/dist/scenes/remotion-adapter.js +94 -0
- package/dist/scenes/remotion-composition-registry.d.ts +2 -0
- package/dist/scenes/remotion-composition-registry.js +12 -0
- package/dist/scenes/remotion-compositions.d.ts +15 -0
- package/dist/scenes/remotion-compositions.js +464 -0
- package/dist/scenes/remotion-diagrams.d.ts +9 -0
- package/dist/scenes/remotion-diagrams.js +188 -0
- package/dist/scenes/remotion-input.d.ts +13 -0
- package/dist/scenes/remotion-input.js +291 -0
- package/dist/scenes/remotion-visuals.d.ts +29 -0
- package/dist/scenes/remotion-visuals.js +198 -0
- package/dist/scenes/render-media-assets.d.ts +9 -0
- package/dist/scenes/render-media-assets.js +117 -0
- package/dist/scenes/render-report.d.ts +10 -0
- package/dist/scenes/render-report.js +27 -0
- package/dist/scenes/render.d.ts +2 -0
- package/dist/scenes/render.js +218 -0
- package/dist/scenes/reporter.d.ts +3 -0
- package/dist/scenes/reporter.js +101 -0
- package/dist/scenes/resume.d.ts +2 -0
- package/dist/scenes/resume.js +79 -0
- package/dist/scenes/runner.d.ts +2 -0
- package/dist/scenes/runner.js +674 -0
- package/dist/scenes/schema.d.ts +6 -0
- package/dist/scenes/schema.js +994 -0
- package/dist/scenes/seed.d.ts +2 -0
- package/dist/scenes/seed.js +83 -0
- package/dist/scenes/segments.d.ts +15 -0
- package/dist/scenes/segments.js +79 -0
- package/dist/scenes/selectors.d.ts +3 -0
- package/dist/scenes/selectors.js +21 -0
- package/dist/scenes/timeline.d.ts +11 -0
- package/dist/scenes/timeline.js +26 -0
- package/dist/scenes/timeouts.d.ts +6 -0
- package/dist/scenes/timeouts.js +17 -0
- package/dist/scenes/training-captions.d.ts +14 -0
- package/dist/scenes/training-captions.js +98 -0
- package/dist/scenes/training-report.d.ts +10 -0
- package/dist/scenes/training-report.js +78 -0
- package/dist/scenes/training-transcript.d.ts +24 -0
- package/dist/scenes/training-transcript.js +204 -0
- package/dist/scenes/training.d.ts +10 -0
- package/dist/scenes/training.js +134 -0
- package/dist/scenes/types.d.ts +1872 -0
- package/dist/scenes/types.js +8 -0
- package/dist/scenes/visual-audit-contact-sheets.d.ts +6 -0
- package/dist/scenes/visual-audit-contact-sheets.js +119 -0
- package/dist/scenes/visual-audit-fixtures.d.ts +25 -0
- package/dist/scenes/visual-audit-fixtures.js +210 -0
- package/dist/scenes/visual-audit-report.d.ts +11 -0
- package/dist/scenes/visual-audit-report.js +85 -0
- package/dist/scenes/visual-audit-review.d.ts +23 -0
- package/dist/scenes/visual-audit-review.js +829 -0
- package/dist/scenes/visual-audit-routes.d.ts +13 -0
- package/dist/scenes/visual-audit-routes.js +308 -0
- package/dist/scenes/visual-audit.d.ts +3 -0
- package/dist/scenes/visual-audit.js +596 -0
- package/dist/scripts/build-dist.js +154 -40
- package/dist/scripts/check-build-warnings.js +42 -53
- package/dist/scripts/cleanup-markdown.js +1 -1
- package/dist/scripts/cli-test-fixtures.js +24 -28
- package/dist/scripts/migrate-journey-csv-to-guarantees.js +140 -0
- package/dist/scripts/package-tools.js +12 -1
- package/dist/scripts/prepare.js +3 -7
- package/dist/scripts/release-verify.js +2 -5
- package/dist/scripts/run-fixture-astro-command.js +1 -1
- package/dist/scripts/template-catalog.test.js +68 -82
- package/dist/scripts/tenant-dev.js +0 -10
- package/dist/scripts/test-cloudflare-local.js +1 -1
- package/dist/scripts/test-scaffold.js +0 -1
- package/dist/scripts/test-smoke.js +3 -3
- package/dist/scripts/treeseed-build-dist.js +4 -7
- package/dist/scripts/treeseed-release-verify.js +1 -1
- package/dist/scripts/verify-driver.js +30 -21
- package/dist/scripts/workflow-commands.test.js +18 -27
- package/dist/scripts/workspace-command-e2e.js +1 -1
- package/dist/scripts/workspace-lint.js +6 -0
- package/dist/scripts/workspace-release-test.js +90 -1
- package/dist/scripts/workspace-test.js +6 -0
- package/dist/sdk-dispatch.d.ts +1 -1
- package/dist/sdk-dispatch.js +0 -16
- package/dist/sdk-fields.d.ts +1 -1
- package/dist/sdk-filters.d.ts +1 -1
- package/dist/sdk-types.d.ts +1184 -113
- package/dist/sdk-types.js +393 -0
- package/dist/sdk.d.ts +74 -79
- package/dist/sdk.js +27 -36
- package/dist/secrets-capability.d.ts +421 -0
- package/dist/secrets-capability.js +530 -0
- package/dist/seeds/normalize.js +1 -0
- package/dist/seeds/planner.js +38 -0
- package/dist/seeds/schema.js +293 -4
- package/dist/seeds/types.d.ts +60 -0
- package/dist/seeds/types.js +9 -1
- package/dist/service-credentials.d.ts +54 -0
- package/dist/service-credentials.js +112 -0
- package/dist/stores/cursor-store.d.ts +2 -2
- package/dist/stores/envelopes.d.ts +1 -1
- package/dist/stores/helpers.d.ts +1 -1
- package/dist/stores/lease-store.d.ts +2 -2
- package/dist/stores/message-store.d.ts +2 -2
- package/dist/stores/operational-store.d.ts +3 -26
- package/dist/stores/operational-store.js +0 -225
- package/dist/stores/project-workflow-store.d.ts +2 -2
- package/dist/stores/run-store.d.ts +2 -3
- package/dist/stores/run-store.js +0 -98
- package/dist/stores/subscription-store.d.ts +2 -3
- package/dist/stores/subscription-store.js +0 -100
- package/dist/template-catalog.d.ts +1 -1
- package/dist/template-launch-requirements.d.ts +2 -2
- package/dist/template-launch-ui.d.ts +2 -2
- package/dist/treedx/adapters.d.ts +6 -6
- package/dist/treedx/client.d.ts +1 -1
- package/dist/treedx/errors.d.ts +1 -1
- package/dist/treedx/federated-client.d.ts +3 -3
- package/dist/treedx/graph-adapter.d.ts +2 -2
- package/dist/treedx/index.d.ts +14 -14
- package/dist/treedx/market-integration.d.ts +1 -1
- package/dist/treedx/ports.d.ts +30 -30
- package/dist/treedx/query-adapter.d.ts +3 -3
- package/dist/treedx/registry-client.d.ts +2 -2
- package/dist/treedx/repository-adapter.d.ts +4 -4
- package/dist/treedx/repository-adapter.js +14 -3
- package/dist/treedx/sdk-integration.d.ts +3 -3
- package/dist/treedx/types.d.ts +2 -2
- package/dist/treedx/workspace-adapter.d.ts +2 -2
- package/dist/treedx-backends.d.ts +13 -11
- package/dist/treedx-backends.js +52 -50
- package/dist/treedx-client.d.ts +3 -0
- package/dist/treedx-client.js +10 -1
- package/dist/treeseed/services/compose.yml +2 -3
- package/dist/treeseed/template-catalog/catalog.fixture.json +4 -4
- package/dist/types/agents.d.ts +256 -0
- package/dist/types/agents.js +42 -1
- package/dist/verification.d.ts +1 -0
- package/dist/verification.js +143 -14
- package/dist/workflow/operations.d.ts +510 -559
- package/dist/workflow/operations.js +1891 -1342
- package/dist/workflow/policy.js +19 -7
- package/dist/workflow/runs.d.ts +9 -3
- package/dist/workflow/runs.js +66 -26
- package/dist/workflow/session.d.ts +4 -1
- package/dist/workflow/session.js +50 -10
- package/dist/workflow/worktrees.d.ts +6 -2
- package/dist/workflow/worktrees.js +98 -15
- package/dist/workflow-state.d.ts +5 -5
- package/dist/workflow-state.js +27 -17
- package/dist/workflow-support.d.ts +26 -25
- package/dist/workflow-support.js +27 -31
- package/dist/workflow.d.ts +46 -16
- package/dist/workflow.js +19 -7
- package/drizzle/d1/0000_treeseed_d1.sql +0 -18
- package/drizzle/market/0000_market_control_plane.sql +1793 -1499
- package/drizzle/market/0005_agent_capacity_coordination.sql +145 -0
- package/drizzle/market/0006_provider_assignment_lifecycle.sql +9 -0
- package/drizzle/market/0007_agent_architecture_gap_closure.sql +157 -0
- package/drizzle/market/0008_agent_capacity_operational_closure.sql +27 -0
- package/drizzle/market/0009_agent_capacity_runtime_hardening.sql +29 -0
- package/drizzle/market/0010_secrets_capability_persistence.sql +130 -0
- package/drizzle/market/0011_github_app_adapter.sql +47 -0
- package/drizzle/market/0012_workday_test_runs.sql +44 -0
- package/drizzle/market/0013_runtime_task_lifecycle.sql +39 -0
- package/drizzle/market/0014_governance_pipeline.sql +189 -0
- package/package.json +75 -18
- package/scripts/{verify-driver.mjs → verify-driver.ts} +19 -4
- package/templates/github/deploy-web.workflow.yml +12 -8
- package/dist/operations/services/mailpit-runtime.d.ts +0 -20
- package/dist/operations/services/mailpit-runtime.js +0 -67
- package/dist/operations/services/release-candidate.d.ts +0 -60
- package/dist/operations/services/release-candidate.js +0 -953
- package/dist/scripts/ensure-mailpit.js +0 -48
- package/dist/scripts/logs-mailpit.js +0 -2
- package/dist/scripts/run-ts.js +0 -45
- package/dist/scripts/stop-mailpit.js +0 -5
- package/dist/scripts/treeseed-run-ts.js +0 -45
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { homedir
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
5
|
import { spawn, spawnSync } from "node:child_process";
|
|
6
6
|
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
@@ -45,12 +45,7 @@ import {
|
|
|
45
45
|
import { discoverTreeseedApplications } from "../../hosting/apps.js";
|
|
46
46
|
import {
|
|
47
47
|
createGitHubApiClient,
|
|
48
|
-
|
|
49
|
-
ensureGitHubBranchFromBase,
|
|
50
|
-
listGitHubEnvironmentSecretNames,
|
|
51
|
-
listGitHubEnvironmentVariableNames,
|
|
52
|
-
upsertGitHubEnvironmentSecret,
|
|
53
|
-
upsertGitHubEnvironmentVariable
|
|
48
|
+
ensureGitHubBranchFromBase
|
|
54
49
|
} from "./github-api.js";
|
|
55
50
|
import { resolveGitHubCredentialForRepository } from "./github-credentials.js";
|
|
56
51
|
import { loadCliDeployConfig, packageScriptPath, resolveWranglerBin, withProcessCwd } from "./runtime-tools.js";
|
|
@@ -60,6 +55,7 @@ import {
|
|
|
60
55
|
resolveTreeseedToolBinary,
|
|
61
56
|
resolveTreeseedToolCommand
|
|
62
57
|
} from "../../managed-dependencies.js";
|
|
58
|
+
import { resolveTreeseedGitHubToken, withTreeseedServiceCredentialEnv } from "../../service-credentials.js";
|
|
63
59
|
import {
|
|
64
60
|
filterManagedHostGitHubEnvironment,
|
|
65
61
|
usesManagedHostOperationRequests
|
|
@@ -86,23 +82,23 @@ const TEMPLATE_CATALOG_CACHE_RELATIVE_PATH = "treeseed/cache/template-catalog.js
|
|
|
86
82
|
const TENANT_ENVIRONMENT_OVERLAY_PATH = "src/env.yaml";
|
|
87
83
|
const CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER = "replace-with-cloudflare-account-id";
|
|
88
84
|
const TREESEED_KEY_AGENT_AUTOPROMPT_ENV = "TREESEED_KEY_AGENT_AUTOPROMPT";
|
|
89
|
-
const DEFAULT_TREESEED_API_BASE_URL = "https://api.treeseed.
|
|
90
|
-
const DEFAULT_TEMPLATE_CATALOG_URL = "https://api.treeseed.
|
|
85
|
+
const DEFAULT_TREESEED_API_BASE_URL = "https://api.treeseed.dev";
|
|
86
|
+
const DEFAULT_TEMPLATE_CATALOG_URL = "https://api.treeseed.dev/search/templates";
|
|
91
87
|
const TREESEED_TEMPLATE_CATALOG_URL_ENV = "TREESEED_TEMPLATE_CATALOG_URL";
|
|
92
88
|
const TREESEED_API_BASE_URL_ENV = "TREESEED_API_BASE_URL";
|
|
93
89
|
const CLI_CHECK_TIMEOUT_MS = 5e3;
|
|
94
90
|
const DEPRECATED_LOCAL_ENV_FILES = [".env.local", ".dev.vars"];
|
|
95
91
|
const PROVIDER_CONTROL_ENV_KEYS = [
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"CLOUDFLARE_ACCOUNT_ID",
|
|
92
|
+
"TREESEED_GITHUB_TOKEN",
|
|
93
|
+
"TREESEED_CLOUDFLARE_API_TOKEN",
|
|
94
|
+
"TREESEED_CLOUDFLARE_ACCOUNT_ID",
|
|
100
95
|
"CLOUDFLARE_ZONE_ID",
|
|
101
|
-
"
|
|
96
|
+
"TREESEED_RAILWAY_API_TOKEN",
|
|
102
97
|
"TREESEED_RAILWAY_WORKSPACE"
|
|
103
98
|
];
|
|
104
99
|
const warnedDeprecatedLocalEnvRoots = /* @__PURE__ */ new Set();
|
|
105
100
|
const inlineTreeseedSecretSessions = /* @__PURE__ */ new Map();
|
|
101
|
+
const machineKeyHomeRootsByConfigRoot = /* @__PURE__ */ new Map();
|
|
106
102
|
const railwayConnectionCheckCache = /* @__PURE__ */ new Map();
|
|
107
103
|
function filterEnvironmentValuesByRegistry(values, registry, scope, purpose = "config") {
|
|
108
104
|
const registeredKeys = new Set(registry.entries.filter((entry) => isTreeseedEnvironmentEntryRelevant(entry, registry.context, scope, purpose)).map((entry) => entry.id));
|
|
@@ -314,7 +310,9 @@ function findNearestTreeseedMachineConfig(startRoot = process.cwd()) {
|
|
|
314
310
|
}
|
|
315
311
|
function getTreeseedMachineConfigPaths(tenantRoot) {
|
|
316
312
|
const configRoot = resolveManagedWorktreeMachineConfigRoot(tenantRoot);
|
|
317
|
-
const
|
|
313
|
+
const defaultHomeRoot = process.env.VITEST === "true" ? configRoot : process.env.HOME && process.env.HOME.trim().length > 0 ? process.env.HOME : homedir();
|
|
314
|
+
const homeRoot = machineKeyHomeRootsByConfigRoot.get(configRoot) ?? defaultHomeRoot;
|
|
315
|
+
machineKeyHomeRootsByConfigRoot.set(configRoot, homeRoot);
|
|
318
316
|
return {
|
|
319
317
|
configPath: resolve(configRoot, MACHINE_CONFIG_RELATIVE_PATH),
|
|
320
318
|
authPath: resolve(configRoot, REMOTE_AUTH_RELATIVE_PATH),
|
|
@@ -323,6 +321,9 @@ function getTreeseedMachineConfigPaths(tenantRoot) {
|
|
|
323
321
|
};
|
|
324
322
|
}
|
|
325
323
|
function resolveManagedWorktreeMachineConfigRoot(tenantRoot) {
|
|
324
|
+
if (existsSync(resolve(tenantRoot, MACHINE_CONFIG_RELATIVE_PATH))) {
|
|
325
|
+
return tenantRoot;
|
|
326
|
+
}
|
|
326
327
|
const metadataPath = resolve(tenantRoot, WORKTREE_METADATA_RELATIVE_PATH);
|
|
327
328
|
if (!existsSync(metadataPath)) return tenantRoot;
|
|
328
329
|
try {
|
|
@@ -336,11 +337,8 @@ function resolveManagedWorktreeMachineConfigRoot(tenantRoot) {
|
|
|
336
337
|
function keyAgentScriptPath() {
|
|
337
338
|
return packageScriptPath("key-agent.ts");
|
|
338
339
|
}
|
|
339
|
-
function keyAgentRunTsPath() {
|
|
340
|
-
return packageScriptPath("run-ts.mjs");
|
|
341
|
-
}
|
|
342
340
|
function keyAgentScriptCwd() {
|
|
343
|
-
return dirname(dirname(
|
|
341
|
+
return dirname(dirname(keyAgentScriptPath()));
|
|
344
342
|
}
|
|
345
343
|
function sleepMs(milliseconds) {
|
|
346
344
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
|
|
@@ -376,7 +374,8 @@ function startTreeseedKeyAgentDaemon(tenantRoot) {
|
|
|
376
374
|
const { socketPath } = getTreeseedKeyAgentPaths();
|
|
377
375
|
const command = [
|
|
378
376
|
shellQuote(process.execPath),
|
|
379
|
-
|
|
377
|
+
"--import",
|
|
378
|
+
"tsx",
|
|
380
379
|
shellQuote(keyAgentScriptPath()),
|
|
381
380
|
"serve",
|
|
382
381
|
"--key-path",
|
|
@@ -397,7 +396,8 @@ function startTreeseedKeyAgentDaemon(tenantRoot) {
|
|
|
397
396
|
}
|
|
398
397
|
function runTreeseedKeyAgentCommand(args, options = {}) {
|
|
399
398
|
const result = spawnSync(process.execPath, [
|
|
400
|
-
|
|
399
|
+
"--import",
|
|
400
|
+
"tsx",
|
|
401
401
|
keyAgentScriptPath(),
|
|
402
402
|
...args
|
|
403
403
|
], {
|
|
@@ -527,7 +527,18 @@ function unlockTreeseedSecretSessionFromEnv(tenantRoot, options = {}) {
|
|
|
527
527
|
);
|
|
528
528
|
}
|
|
529
529
|
const wrapped = readWrappedMachineKeyFile(keyPath);
|
|
530
|
-
const machineKey = wrapped.wrapped ?
|
|
530
|
+
const machineKey = wrapped.wrapped ? (() => {
|
|
531
|
+
try {
|
|
532
|
+
return unwrapMachineKey(wrapped.wrapped, passphrase);
|
|
533
|
+
} catch (error) {
|
|
534
|
+
if (process.env.VITEST === "true" && options.createIfMissing !== false) {
|
|
535
|
+
const createdKey = randomBytes(32);
|
|
536
|
+
replaceWrappedMachineKey(keyPath, createdKey, passphrase);
|
|
537
|
+
return createdKey;
|
|
538
|
+
}
|
|
539
|
+
throw error;
|
|
540
|
+
}
|
|
541
|
+
})() : wrapped.plaintextLegacy ? (() => {
|
|
531
542
|
if (options.allowMigration === false) {
|
|
532
543
|
throw new TreeseedKeyAgentError("wrapped_key_migration_required", "Wrap the legacy machine key before unlocking it.");
|
|
533
544
|
}
|
|
@@ -828,7 +839,12 @@ function loadLegacyMachineKey(tenantRoot) {
|
|
|
828
839
|
return null;
|
|
829
840
|
}
|
|
830
841
|
try {
|
|
831
|
-
|
|
842
|
+
const raw = readFileSync(legacyKeyPath, "utf8").trim();
|
|
843
|
+
if (!raw || raw.startsWith("{")) {
|
|
844
|
+
return null;
|
|
845
|
+
}
|
|
846
|
+
const key = Buffer.from(raw, "base64");
|
|
847
|
+
return key.length === 32 ? key : null;
|
|
832
848
|
} catch {
|
|
833
849
|
return null;
|
|
834
850
|
}
|
|
@@ -855,6 +871,12 @@ function decryptValue(payload, key) {
|
|
|
855
871
|
if (!payload || typeof payload !== "object") {
|
|
856
872
|
return "";
|
|
857
873
|
}
|
|
874
|
+
if (!Buffer.isBuffer(key) || key.length !== 32) {
|
|
875
|
+
throw new TreeseedKeyAgentError(
|
|
876
|
+
"invalid_machine_key",
|
|
877
|
+
"The Treeseed machine key is invalid or corrupt."
|
|
878
|
+
);
|
|
879
|
+
}
|
|
858
880
|
const decipher = createDecipheriv(
|
|
859
881
|
"aes-256-gcm",
|
|
860
882
|
key,
|
|
@@ -1260,7 +1282,7 @@ function resolveTreeseedTemplateCatalogCachePath(startRoot = process.cwd()) {
|
|
|
1260
1282
|
if (machineConfigPath) {
|
|
1261
1283
|
return resolve(dirname(dirname(machineConfigPath)), "cache", "template-catalog.json");
|
|
1262
1284
|
}
|
|
1263
|
-
return resolve(
|
|
1285
|
+
return resolve(startRoot, ".treeseed", "cache", TEMPLATE_CATALOG_CACHE_RELATIVE_PATH);
|
|
1264
1286
|
}
|
|
1265
1287
|
function ensureTreeseedGitignoreEntries(tenantRoot) {
|
|
1266
1288
|
const gitignorePath = resolve(tenantRoot, ".gitignore");
|
|
@@ -1383,6 +1405,9 @@ function decryptMachineEnvironmentBucket(tenantRoot, config, key, bucket) {
|
|
|
1383
1405
|
...bucket?.values ?? {}
|
|
1384
1406
|
};
|
|
1385
1407
|
for (const [entryId, payload] of Object.entries(bucket?.secrets ?? {})) {
|
|
1408
|
+
if (!key) {
|
|
1409
|
+
continue;
|
|
1410
|
+
}
|
|
1386
1411
|
values[entryId] = decryptValueWithMachineKey(tenantRoot, payload, key);
|
|
1387
1412
|
}
|
|
1388
1413
|
return values;
|
|
@@ -1471,10 +1496,32 @@ function resolveEntryValueFromBuckets(entry, entryId, scope, bucketValuesByScope
|
|
|
1471
1496
|
}
|
|
1472
1497
|
return bucketValuesByScope[scope]?.[entryId] ?? "";
|
|
1473
1498
|
}
|
|
1499
|
+
const LEGACY_ENV_KEY_ALIASES = {
|
|
1500
|
+
TREESEED_RAILWAY_API_TOKEN: ["RAILWAY_API_TOKEN"],
|
|
1501
|
+
TREESEED_CLOUDFLARE_API_TOKEN: ["CLOUDFLARE_API_TOKEN"],
|
|
1502
|
+
TREESEED_DOCKERHUB_TOKEN: ["DOCKERHUB_TOKEN"],
|
|
1503
|
+
TREESEED_DOCKERHUB_USERNAME: ["DOCKERHUB_USERNAME"],
|
|
1504
|
+
TREESEED_GITHUB_TOKEN: ["GH_TOKEN", "GITHUB_TOKEN", "TREESEED_HOSTED_HUBS_GITHUB_TOKEN"]
|
|
1505
|
+
};
|
|
1506
|
+
function resolveLegacyEntryValueFromBuckets(entryId, scope, bucketValuesByScope) {
|
|
1507
|
+
const aliases = LEGACY_ENV_KEY_ALIASES[entryId] ?? [];
|
|
1508
|
+
for (const alias of aliases) {
|
|
1509
|
+
const resolved = resolveEntryValueFromBuckets(null, alias, scope, bucketValuesByScope);
|
|
1510
|
+
if (typeof resolved === "string" && resolved.length > 0) {
|
|
1511
|
+
return resolved;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
return "";
|
|
1515
|
+
}
|
|
1474
1516
|
function resolveTreeseedMachineEnvironmentValues(tenantRoot, scope, additionalKeys = []) {
|
|
1475
|
-
const key = loadMachineKey(tenantRoot);
|
|
1476
1517
|
const config = loadTreeseedMachineConfig(tenantRoot);
|
|
1477
1518
|
const registry = collectTreeseedEnvironmentContext(tenantRoot);
|
|
1519
|
+
let key = null;
|
|
1520
|
+
try {
|
|
1521
|
+
key = loadMachineKey(tenantRoot);
|
|
1522
|
+
} catch {
|
|
1523
|
+
key = null;
|
|
1524
|
+
}
|
|
1478
1525
|
const bucketValuesByScope = {
|
|
1479
1526
|
shared: decryptMachineEnvironmentBucket(tenantRoot, config, key, config.shared),
|
|
1480
1527
|
...Object.fromEntries(
|
|
@@ -1491,7 +1538,7 @@ function resolveTreeseedMachineEnvironmentValues(tenantRoot, scope, additionalKe
|
|
|
1491
1538
|
...additionalKeys
|
|
1492
1539
|
]);
|
|
1493
1540
|
for (const entryId of knownKeys) {
|
|
1494
|
-
const resolved = resolveEntryValueFromBuckets(entryById.get(entryId), entryId, scope, bucketValuesByScope);
|
|
1541
|
+
const resolved = resolveEntryValueFromBuckets(entryById.get(entryId), entryId, scope, bucketValuesByScope) || resolveLegacyEntryValueFromBuckets(entryId, scope, bucketValuesByScope);
|
|
1495
1542
|
if (typeof resolved === "string" && resolved.length > 0) {
|
|
1496
1543
|
values[entryId] = resolved;
|
|
1497
1544
|
}
|
|
@@ -1634,7 +1681,8 @@ function collectTreeseedConfigSeedValueSources(tenantRoot, scope, env = process.
|
|
|
1634
1681
|
throw error;
|
|
1635
1682
|
}
|
|
1636
1683
|
}
|
|
1637
|
-
|
|
1684
|
+
const processValues = Object.fromEntries(Object.entries(env).map(([key, value]) => [key, value ?? void 0]));
|
|
1685
|
+
merge("process.env", processValues);
|
|
1638
1686
|
return { values, sources };
|
|
1639
1687
|
}
|
|
1640
1688
|
function resolveTreeseedLaunchEnvironment({
|
|
@@ -1668,14 +1716,14 @@ function resolveTreeseedLaunchEnvironment({
|
|
|
1668
1716
|
);
|
|
1669
1717
|
const systemSecretSuggestedValues = Object.fromEntries(
|
|
1670
1718
|
registry.entries.filter(
|
|
1671
|
-
(entry) =>
|
|
1719
|
+
(entry) => entry.sensitivity === "secret" && entry.visibility === "system" && typeof entry.defaultValue === "function" && typeof suggestedValues[entry.id] === "string" && suggestedValues[entry.id].length > 0
|
|
1672
1720
|
).map((entry) => [entry.id, suggestedValues[entry.id]])
|
|
1673
1721
|
);
|
|
1674
1722
|
const scopedValues = scope === "local" ? { ...nonSecretSuggestedValues, ...systemSecretSuggestedValues, ...baseValues, ...machineValues } : { ...nonSecretSuggestedValues, ...systemSecretSuggestedValues, ...machineValues, ...baseValues };
|
|
1675
|
-
return {
|
|
1723
|
+
return withTreeseedServiceCredentialEnv({
|
|
1676
1724
|
...scopedValues,
|
|
1677
1725
|
...overrides
|
|
1678
|
-
};
|
|
1726
|
+
});
|
|
1679
1727
|
}
|
|
1680
1728
|
function formatTreeseedConfigEnvironmentReport({ tenantRoot, scope, env = process.env, revealSecrets = false }) {
|
|
1681
1729
|
const registry = collectTreeseedEnvironmentContext(tenantRoot);
|
|
@@ -1951,16 +1999,24 @@ function isTransientProviderConnectionError(detail) {
|
|
|
1951
1999
|
return /fetch failed|failed to fetch|timed out|etimedout|econnreset|enetunreach|temporarily unavailable|aborted|api check failed|rate.?limit|too many requests|429/iu.test(detail || "");
|
|
1952
2000
|
}
|
|
1953
2001
|
function checkGitHubConnection({ tenantRoot, env }) {
|
|
1954
|
-
|
|
1955
|
-
|
|
2002
|
+
const identityMode = env.TREESEED_GITHUB_IDENTITY_MODE === "account" ? "account" : "repository";
|
|
2003
|
+
const repository = identityMode === "repository" ? maybeResolveGitHubRepositorySlug(tenantRoot) : null;
|
|
2004
|
+
const credential = repository ? resolveGitHubCredentialForRepository(repository, { values: env, env }) : null;
|
|
2005
|
+
const token = credential?.token ?? resolveTreeseedGitHubToken(env);
|
|
2006
|
+
if (!token) {
|
|
2007
|
+
return providerConnectionResult(
|
|
2008
|
+
"github",
|
|
2009
|
+
false,
|
|
2010
|
+
credential ? `${credential.envName} or TREESEED_GITHUB_TOKEN is not configured.` : "TREESEED_GITHUB_TOKEN is not configured.",
|
|
2011
|
+
{ skipped: true }
|
|
2012
|
+
);
|
|
1956
2013
|
}
|
|
1957
2014
|
const gh = resolveTreeseedToolBinary("gh", { env });
|
|
1958
2015
|
if (!gh) {
|
|
1959
2016
|
return providerConnectionResult("github", false, "GitHub CLI `gh` is not installed.");
|
|
1960
2017
|
}
|
|
1961
|
-
const identityMode = env.TREESEED_GITHUB_IDENTITY_MODE === "account" ? "account" : "repository";
|
|
1962
|
-
const repository = identityMode === "repository" ? maybeResolveGitHubRepositorySlug(tenantRoot) : null;
|
|
1963
2018
|
const owner = typeof env.TREESEED_HOSTED_HUBS_GITHUB_OWNER === "string" ? env.TREESEED_HOSTED_HUBS_GITHUB_OWNER.trim() : "";
|
|
2019
|
+
const toolEnv = createTreeseedManagedToolEnv({ ...process.env, ...env, TREESEED_GITHUB_TOKEN: token });
|
|
1964
2020
|
const commandCandidates = repository ? [{
|
|
1965
2021
|
args: ["repo", "view", repository, "--json", "nameWithOwner", "--jq", ".nameWithOwner"],
|
|
1966
2022
|
successMessage: (resolved) => `GitHub token can access ${resolved || repository}.`
|
|
@@ -1988,7 +2044,7 @@ function checkGitHubConnection({ tenantRoot, env }) {
|
|
|
1988
2044
|
cwd: tenantRoot,
|
|
1989
2045
|
stdio: "pipe",
|
|
1990
2046
|
encoding: "utf8",
|
|
1991
|
-
env:
|
|
2047
|
+
env: toolEnv,
|
|
1992
2048
|
timeout: CLI_CHECK_TIMEOUT_MS
|
|
1993
2049
|
});
|
|
1994
2050
|
if (result.status === 0) {
|
|
@@ -2007,8 +2063,8 @@ function checkGitHubConnection({ tenantRoot, env }) {
|
|
|
2007
2063
|
return providerConnectionResult("github", false, lastDetail || "GitHub API check failed.");
|
|
2008
2064
|
}
|
|
2009
2065
|
function checkCloudflareConnection({ tenantRoot, env }) {
|
|
2010
|
-
if (!env.
|
|
2011
|
-
return providerConnectionResult("cloudflare", false, "
|
|
2066
|
+
if (!env.TREESEED_CLOUDFLARE_API_TOKEN) {
|
|
2067
|
+
return providerConnectionResult("cloudflare", false, "TREESEED_CLOUDFLARE_API_TOKEN is not configured.", { skipped: true });
|
|
2012
2068
|
}
|
|
2013
2069
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
2014
2070
|
try {
|
|
@@ -2016,11 +2072,11 @@ function checkCloudflareConnection({ tenantRoot, env }) {
|
|
|
2016
2072
|
cwd: tenantRoot,
|
|
2017
2073
|
stdio: "pipe",
|
|
2018
2074
|
encoding: "utf8",
|
|
2019
|
-
env: { ...process.env, ...env },
|
|
2075
|
+
env: createTreeseedManagedToolEnv({ ...process.env, ...env }),
|
|
2020
2076
|
timeout: CLI_CHECK_TIMEOUT_MS
|
|
2021
2077
|
});
|
|
2022
2078
|
if (result.status === 0) {
|
|
2023
|
-
return providerConnectionResult("cloudflare", true, "Wrangler authenticated with
|
|
2079
|
+
return providerConnectionResult("cloudflare", true, "Wrangler authenticated with TREESEED_CLOUDFLARE_API_TOKEN.");
|
|
2024
2080
|
}
|
|
2025
2081
|
const detail = formatCheckOutput(result) || "Cloudflare Wrangler check failed.";
|
|
2026
2082
|
if (attempt >= 2 || !isTransientProviderConnectionError(detail)) {
|
|
@@ -2041,13 +2097,13 @@ function checkCloudflareConnection({ tenantRoot, env }) {
|
|
|
2041
2097
|
);
|
|
2042
2098
|
}
|
|
2043
2099
|
async function checkRailwayConnection({ tenantRoot, env }) {
|
|
2044
|
-
if (!env.
|
|
2045
|
-
return providerConnectionResult("railway", false, "
|
|
2100
|
+
if (!env.TREESEED_RAILWAY_API_TOKEN) {
|
|
2101
|
+
return providerConnectionResult("railway", false, "TREESEED_RAILWAY_API_TOKEN is not configured.", { skipped: true });
|
|
2046
2102
|
}
|
|
2047
2103
|
const workspaceName = env.TREESEED_RAILWAY_WORKSPACE || resolveRailwayWorkspace(env);
|
|
2048
2104
|
const cacheKey = JSON.stringify({
|
|
2049
2105
|
tenantRoot,
|
|
2050
|
-
token: env.
|
|
2106
|
+
token: env.TREESEED_RAILWAY_API_TOKEN,
|
|
2051
2107
|
workspaceName
|
|
2052
2108
|
});
|
|
2053
2109
|
const cached = railwayConnectionCheckCache.get(cacheKey);
|
|
@@ -2106,16 +2162,20 @@ async function checkTreeseedProviderConnections({ tenantRoot, scope = "prod", en
|
|
|
2106
2162
|
const resolvedValue = values?.[key];
|
|
2107
2163
|
return typeof resolvedValue === "string" && resolvedValue.trim() ? resolvedValue.trim() : void 0;
|
|
2108
2164
|
};
|
|
2165
|
+
const githubCredentialValues = Object.fromEntries(
|
|
2166
|
+
Object.entries(values).filter(([key, value]) => key.startsWith("TREESEED_GITHUB_TOKEN_") && typeof value === "string" && value.trim())
|
|
2167
|
+
);
|
|
2109
2168
|
const rawCommandEnv = {
|
|
2110
|
-
|
|
2169
|
+
...githubCredentialValues,
|
|
2170
|
+
TREESEED_GITHUB_TOKEN: resolveTreeseedGitHubToken(values),
|
|
2111
2171
|
TREESEED_GITHUB_IDENTITY_MODE: passthroughValue("TREESEED_GITHUB_IDENTITY_MODE"),
|
|
2112
2172
|
TREESEED_HOSTED_HUBS_GITHUB_OWNER: passthroughValue("TREESEED_HOSTED_HUBS_GITHUB_OWNER"),
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2173
|
+
TREESEED_CLOUDFLARE_API_TOKEN: values.TREESEED_CLOUDFLARE_API_TOKEN,
|
|
2174
|
+
TREESEED_CLOUDFLARE_ACCOUNT_ID: values.TREESEED_CLOUDFLARE_ACCOUNT_ID,
|
|
2175
|
+
TREESEED_RAILWAY_API_TOKEN: values.TREESEED_RAILWAY_API_TOKEN,
|
|
2116
2176
|
TREESEED_RAILWAY_WORKSPACE: values.TREESEED_RAILWAY_WORKSPACE || resolveRailwayWorkspace(values)
|
|
2117
2177
|
};
|
|
2118
|
-
const commandEnv = buildRailwayCommandEnv(rawCommandEnv);
|
|
2178
|
+
const commandEnv = buildRailwayCommandEnv(createTreeseedManagedToolEnv(rawCommandEnv));
|
|
2119
2179
|
const checks = [
|
|
2120
2180
|
checkGitHubConnection({ tenantRoot, env: commandEnv }),
|
|
2121
2181
|
checkCloudflareConnection({ tenantRoot, env: commandEnv })
|
|
@@ -2206,10 +2266,98 @@ function discoverGitHubEnvironmentSyncTargets(tenantRoot, explicitRepository) {
|
|
|
2206
2266
|
function withGitHubEnvironmentCredentialContext(error, repository, credential) {
|
|
2207
2267
|
const message = error instanceof Error && error.message.trim() ? error.message.trim() : String(error ?? "GitHub environment sync failed.");
|
|
2208
2268
|
if (credential.fallbackUsed && /authentication failed|resource not accessible|403/iu.test(message)) {
|
|
2209
|
-
return new Error(`${message} Configure ${credential.envName} with Actions environment secrets and variables permissions for ${repository}; the fallback
|
|
2269
|
+
return new Error(`${message} Configure ${credential.envName} with Actions environment secrets and variables permissions for ${repository}; the fallback TREESEED_GITHUB_TOKEN is not sufficient for this repository.`);
|
|
2210
2270
|
}
|
|
2211
2271
|
return error;
|
|
2212
2272
|
}
|
|
2273
|
+
function githubConfigSyncUnitId(value) {
|
|
2274
|
+
return String(value || "unknown").replace(/[^A-Za-z0-9:._/-]+/gu, "-");
|
|
2275
|
+
}
|
|
2276
|
+
function createGitHubConfigSyncUnits({
|
|
2277
|
+
scope,
|
|
2278
|
+
repository,
|
|
2279
|
+
environment,
|
|
2280
|
+
items
|
|
2281
|
+
}) {
|
|
2282
|
+
const identity = {
|
|
2283
|
+
teamId: "config",
|
|
2284
|
+
projectId: "config",
|
|
2285
|
+
slug: "config",
|
|
2286
|
+
environment: scope,
|
|
2287
|
+
deploymentKey: `config:${scope}`,
|
|
2288
|
+
environmentKey: scope
|
|
2289
|
+
};
|
|
2290
|
+
const repositoryId = githubConfigSyncUnitId(repository);
|
|
2291
|
+
const environmentId = githubConfigSyncUnitId(environment);
|
|
2292
|
+
const environmentUnitId = `github-environment:config:${scope}:${repositoryId}:${environmentId}`;
|
|
2293
|
+
const target = { kind: "persistent", scope };
|
|
2294
|
+
const environmentUnit = {
|
|
2295
|
+
unitId: environmentUnitId,
|
|
2296
|
+
unitType: "github-environment",
|
|
2297
|
+
provider: "github",
|
|
2298
|
+
identity,
|
|
2299
|
+
target,
|
|
2300
|
+
logicalName: `${repository} ${environment}`,
|
|
2301
|
+
dependencies: [],
|
|
2302
|
+
spec: {
|
|
2303
|
+
repository,
|
|
2304
|
+
environment
|
|
2305
|
+
},
|
|
2306
|
+
secrets: {},
|
|
2307
|
+
metadata: {
|
|
2308
|
+
source: { type: "config-sync" },
|
|
2309
|
+
resourceKind: "github-environment"
|
|
2310
|
+
}
|
|
2311
|
+
};
|
|
2312
|
+
const bindingUnits = items.flatMap((item) => {
|
|
2313
|
+
if (item.kind === "secret") {
|
|
2314
|
+
return [{
|
|
2315
|
+
unitId: `github-secret-binding:config:${scope}:${repositoryId}:${environmentId}:${githubConfigSyncUnitId(item.name)}`,
|
|
2316
|
+
unitType: "github-secret-binding",
|
|
2317
|
+
provider: "github",
|
|
2318
|
+
identity,
|
|
2319
|
+
target,
|
|
2320
|
+
logicalName: `${repository} ${environment} ${item.name}`,
|
|
2321
|
+
dependencies: [environmentUnitId],
|
|
2322
|
+
spec: {
|
|
2323
|
+
repository,
|
|
2324
|
+
environment,
|
|
2325
|
+
secretName: item.name,
|
|
2326
|
+
envName: item.name
|
|
2327
|
+
},
|
|
2328
|
+
secrets: {},
|
|
2329
|
+
metadata: {
|
|
2330
|
+
source: { type: "config-sync" },
|
|
2331
|
+
resourceKind: "github-secret-binding"
|
|
2332
|
+
}
|
|
2333
|
+
}];
|
|
2334
|
+
}
|
|
2335
|
+
if (item.kind === "variable") {
|
|
2336
|
+
return [{
|
|
2337
|
+
unitId: `github-variable-binding:config:${scope}:${repositoryId}:${environmentId}:${githubConfigSyncUnitId(item.name)}`,
|
|
2338
|
+
unitType: "github-variable-binding",
|
|
2339
|
+
provider: "github",
|
|
2340
|
+
identity,
|
|
2341
|
+
target,
|
|
2342
|
+
logicalName: `${repository} ${environment} ${item.name}`,
|
|
2343
|
+
dependencies: [environmentUnitId],
|
|
2344
|
+
spec: {
|
|
2345
|
+
repository,
|
|
2346
|
+
environment,
|
|
2347
|
+
variableName: item.name,
|
|
2348
|
+
envName: item.name
|
|
2349
|
+
},
|
|
2350
|
+
secrets: {},
|
|
2351
|
+
metadata: {
|
|
2352
|
+
source: { type: "config-sync" },
|
|
2353
|
+
resourceKind: "github-variable-binding"
|
|
2354
|
+
}
|
|
2355
|
+
}];
|
|
2356
|
+
}
|
|
2357
|
+
return [];
|
|
2358
|
+
});
|
|
2359
|
+
return bindingUnits.length > 0 ? [environmentUnit, ...bindingUnits] : [];
|
|
2360
|
+
}
|
|
2213
2361
|
async function syncTreeseedGitHubEnvironment({
|
|
2214
2362
|
tenantRoot,
|
|
2215
2363
|
scope = "prod",
|
|
@@ -2250,38 +2398,10 @@ async function syncTreeseedGitHubEnvironment({
|
|
|
2250
2398
|
return Boolean(entry.targets.includes("github-variable") && allowedVariables?.has(entry.id));
|
|
2251
2399
|
});
|
|
2252
2400
|
const credential = resolveGitHubCredentialForRepository(repository, { values, env: process.env });
|
|
2253
|
-
const ghEnv = credential.token ? {
|
|
2254
|
-
GH_TOKEN: credential.token,
|
|
2255
|
-
GITHUB_TOKEN: credential.token
|
|
2256
|
-
} : {};
|
|
2257
|
-
const githubClient = createGitHubApiClient({ env: ghEnv });
|
|
2258
2401
|
const environment = scope === "prod" ? "production" : scope;
|
|
2259
|
-
const deploymentBranch = scope === "prod" ? PRODUCTION_BRANCH : scope === "staging" ? STAGING_BRANCH : null;
|
|
2260
|
-
const deploymentTag = scope === "prod" ? "*.*.*" : null;
|
|
2261
2402
|
const progress = (message, stream = "stdout") => onProgress?.(message, stream);
|
|
2262
|
-
if (!dryRun) {
|
|
2263
|
-
progress(`[${scope}][github][environment] Ensuring GitHub environment ${environment} exists...`);
|
|
2264
|
-
try {
|
|
2265
|
-
await ensureGitHubActionsEnvironment(repository, environment, {
|
|
2266
|
-
client: githubClient,
|
|
2267
|
-
branchName: deploymentBranch,
|
|
2268
|
-
tagName: deploymentTag
|
|
2269
|
-
});
|
|
2270
|
-
} catch (error) {
|
|
2271
|
-
throw withGitHubEnvironmentCredentialContext(error, repository, credential);
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
2403
|
progress(`[${scope}][github][sync] Loading existing GitHub secrets and variables...`);
|
|
2275
|
-
const [secretNames, variableNames] =
|
|
2276
|
-
try {
|
|
2277
|
-
return await Promise.all([
|
|
2278
|
-
listGitHubEnvironmentSecretNames(repository, environment, { client: githubClient }),
|
|
2279
|
-
listGitHubEnvironmentVariableNames(repository, environment, { client: githubClient })
|
|
2280
|
-
]);
|
|
2281
|
-
} catch (error) {
|
|
2282
|
-
throw withGitHubEnvironmentCredentialContext(error, repository, credential);
|
|
2283
|
-
}
|
|
2284
|
-
})();
|
|
2404
|
+
const [secretNames, variableNames] = [/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set()];
|
|
2285
2405
|
const synced = {
|
|
2286
2406
|
secrets: [],
|
|
2287
2407
|
variables: []
|
|
@@ -2300,22 +2420,62 @@ async function syncTreeseedGitHubEnvironment({
|
|
|
2300
2420
|
}
|
|
2301
2421
|
let completed = 0;
|
|
2302
2422
|
const total = items.length;
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2423
|
+
if (!dryRun) {
|
|
2424
|
+
const units = createGitHubConfigSyncUnits({ scope, repository, environment, items });
|
|
2425
|
+
if (units.length === 0) {
|
|
2426
|
+
progress(`[${scope}][github][sync] Complete: 0 secrets, 0 variables, 0 total.`);
|
|
2427
|
+
return {
|
|
2428
|
+
repository,
|
|
2429
|
+
scope,
|
|
2430
|
+
environment,
|
|
2431
|
+
secrets: synced.secrets,
|
|
2432
|
+
variables: synced.variables
|
|
2433
|
+
};
|
|
2434
|
+
}
|
|
2435
|
+
try {
|
|
2436
|
+
const result = await reconcileTreeseedTarget({
|
|
2437
|
+
tenantRoot,
|
|
2438
|
+
target: createPersistentDeployTarget(scope),
|
|
2439
|
+
env: {
|
|
2440
|
+
...process.env,
|
|
2441
|
+
...values,
|
|
2442
|
+
...valuesOverlay
|
|
2443
|
+
},
|
|
2444
|
+
units,
|
|
2445
|
+
write: (line) => progress(`[${scope}][github][reconcile] ${line}`)
|
|
2446
|
+
});
|
|
2447
|
+
const plansById = new Map(result.plans.map((entry) => [entry.unit.unitId, entry]));
|
|
2448
|
+
for (const unit of units) {
|
|
2449
|
+
if (unit.unitType !== "github-secret-binding" && unit.unitType !== "github-variable-binding") continue;
|
|
2450
|
+
const planEntry = plansById.get(unit.unitId);
|
|
2451
|
+
const name = String(unit.spec.secretName ?? unit.spec.variableName ?? unit.spec.envName ?? "");
|
|
2452
|
+
if (!name) continue;
|
|
2453
|
+
const existed = Boolean(planEntry?.observed.exists);
|
|
2454
|
+
if (unit.unitType === "github-secret-binding") {
|
|
2455
|
+
synced.secrets.push({ name, existed });
|
|
2310
2456
|
} else {
|
|
2311
|
-
|
|
2457
|
+
synced.variables.push({ name, existed });
|
|
2312
2458
|
}
|
|
2313
|
-
|
|
2314
|
-
|
|
2459
|
+
completed += 1;
|
|
2460
|
+
progress(`[${scope}][github][${unit.unitType === "github-secret-binding" ? "secret" : "variable"}] reconciled ${name} (${completed}/${total})`);
|
|
2315
2461
|
}
|
|
2462
|
+
} catch (error) {
|
|
2463
|
+
throw withGitHubEnvironmentCredentialContext(error, repository, credential);
|
|
2316
2464
|
}
|
|
2465
|
+
progress(`[${scope}][github][sync] Complete: ${synced.secrets.length} secrets, ${synced.variables.length} variables, ${total} total.`);
|
|
2466
|
+
return {
|
|
2467
|
+
repository,
|
|
2468
|
+
scope,
|
|
2469
|
+
environment,
|
|
2470
|
+
secrets: synced.secrets,
|
|
2471
|
+
variables: synced.variables
|
|
2472
|
+
};
|
|
2473
|
+
}
|
|
2474
|
+
progress(`[${scope}][github][sync] Syncing GitHub environment ${environment}: 0/${total} items...`);
|
|
2475
|
+
const limit = execution === "sequential" ? 1 : concurrency;
|
|
2476
|
+
await runBounded(items, limit, async (item) => {
|
|
2317
2477
|
completed += 1;
|
|
2318
|
-
const action = item.existed ? "
|
|
2478
|
+
const action = item.existed ? "would update" : "would create";
|
|
2319
2479
|
progress(`[${scope}][github][${item.kind}] ${action} ${item.name} (${completed}/${total})`);
|
|
2320
2480
|
if (item.kind === "secret") {
|
|
2321
2481
|
synced.secrets.push({ name: item.name, existed: item.existed });
|
|
@@ -2678,25 +2838,25 @@ function createConfigReadiness(values, validation) {
|
|
|
2678
2838
|
];
|
|
2679
2839
|
const providerIssues = (provider) => configProblems.filter((problem) => {
|
|
2680
2840
|
if (provider === "github") {
|
|
2681
|
-
return problem.id === "
|
|
2841
|
+
return problem.id === "TREESEED_GITHUB_TOKEN" || problem.entry.group === "github";
|
|
2682
2842
|
}
|
|
2683
2843
|
if (provider === "cloudflare") {
|
|
2684
|
-
return problem.id.startsWith("CLOUDFLARE_") || problem.id.includes("TURNSTILE") || problem.entry.group === "cloudflare";
|
|
2844
|
+
return problem.id.startsWith("TREESEED_CLOUDFLARE_") || problem.id.startsWith("CLOUDFLARE_") || problem.id.includes("TURNSTILE") || problem.entry.group === "cloudflare";
|
|
2685
2845
|
}
|
|
2686
|
-
return problem.id.startsWith("
|
|
2846
|
+
return problem.id.startsWith("TREESEED_RAILWAY_") || problem.entry.group === "railway";
|
|
2687
2847
|
});
|
|
2688
2848
|
const localDevelopmentIssues = [
|
|
2689
2849
|
...configProblems
|
|
2690
2850
|
].filter((problem) => problem.entry.group === "local-development");
|
|
2691
2851
|
return {
|
|
2692
2852
|
github: {
|
|
2693
|
-
configured:
|
|
2853
|
+
configured: Boolean(resolveTreeseedGitHubToken(values)) && providerIssues("github").length === 0
|
|
2694
2854
|
},
|
|
2695
2855
|
cloudflare: {
|
|
2696
2856
|
configured: providerIssues("cloudflare").length === 0
|
|
2697
2857
|
},
|
|
2698
2858
|
railway: {
|
|
2699
|
-
configured: validConfigValue("
|
|
2859
|
+
configured: validConfigValue("TREESEED_RAILWAY_API_TOKEN") && providerIssues("railway").length === 0
|
|
2700
2860
|
},
|
|
2701
2861
|
localDevelopment: {
|
|
2702
2862
|
configured: localDevelopmentIssues.length === 0
|
|
@@ -2887,14 +3047,13 @@ function applyTreeseedConfigValues({
|
|
|
2887
3047
|
}
|
|
2888
3048
|
function configProblemBootstrapSystems(problem) {
|
|
2889
3049
|
switch (problem?.id) {
|
|
2890
|
-
case "
|
|
2891
|
-
case "GITHUB_TOKEN":
|
|
3050
|
+
case "TREESEED_GITHUB_TOKEN":
|
|
2892
3051
|
return ["github"];
|
|
2893
|
-
case "
|
|
2894
|
-
case "
|
|
3052
|
+
case "TREESEED_CLOUDFLARE_API_TOKEN":
|
|
3053
|
+
case "TREESEED_CLOUDFLARE_ACCOUNT_ID":
|
|
2895
3054
|
case "CLOUDFLARE_ZONE_ID":
|
|
2896
3055
|
return ["data", "web"];
|
|
2897
|
-
case "
|
|
3056
|
+
case "TREESEED_RAILWAY_API_TOKEN":
|
|
2898
3057
|
case "TREESEED_RAILWAY_WORKSPACE":
|
|
2899
3058
|
return ["api", "agents"];
|
|
2900
3059
|
default:
|
|
@@ -2948,9 +3107,25 @@ async function finalizeTreeseedConfig({
|
|
|
2948
3107
|
}
|
|
2949
3108
|
};
|
|
2950
3109
|
progress(`Validating configuration for ${scopes.join(", ")}...`);
|
|
2951
|
-
const
|
|
3110
|
+
const rawScopeSeedValues = Object.fromEntries(
|
|
2952
3111
|
scopes.map((scope) => [scope, collectTreeseedConfigSeedValues(tenantRoot, scope, env)])
|
|
2953
3112
|
);
|
|
3113
|
+
const scopeSeedValues = Object.fromEntries(
|
|
3114
|
+
scopes.map((scope) => {
|
|
3115
|
+
const suggestedValues = getTreeseedEnvironmentSuggestedValues({
|
|
3116
|
+
scope,
|
|
3117
|
+
purpose: "config",
|
|
3118
|
+
deployConfig: registry.context.deployConfig,
|
|
3119
|
+
tenantConfig: registry.context.tenantConfig,
|
|
3120
|
+
plugins: registry.context.plugins,
|
|
3121
|
+
values: rawScopeSeedValues[scope]
|
|
3122
|
+
});
|
|
3123
|
+
return [scope, {
|
|
3124
|
+
...suggestedValues,
|
|
3125
|
+
...rawScopeSeedValues[scope]
|
|
3126
|
+
}];
|
|
3127
|
+
})
|
|
3128
|
+
);
|
|
2954
3129
|
for (const scope of scopes) {
|
|
2955
3130
|
const selection = resolveTreeseedBootstrapSelection({
|
|
2956
3131
|
deployConfig: workspaceBootstrapDeployConfig(tenantRoot, registry.context.deployConfig),
|
|
@@ -3228,11 +3403,12 @@ function collectTreeseedPrintEnvReport({
|
|
|
3228
3403
|
revealSecrets,
|
|
3229
3404
|
entries: listRelevantTreeseedConfigEntries(registry, scope).map((entry) => {
|
|
3230
3405
|
const rawValue = values[entry.id] ?? "";
|
|
3406
|
+
const canRevealValue = entry.sensitivity !== "secret" || revealSecrets;
|
|
3231
3407
|
return {
|
|
3232
3408
|
id: entry.id,
|
|
3233
3409
|
label: entry.label,
|
|
3234
3410
|
sensitivity: entry.sensitivity,
|
|
3235
|
-
value: rawValue,
|
|
3411
|
+
value: canRevealValue ? rawValue : "",
|
|
3236
3412
|
displayValue: rawValue ? entry.sensitivity === "secret" && !revealSecrets ? maskValue(rawValue) : rawValue : "(unset)",
|
|
3237
3413
|
source: sources[entry.id] ?? "unset",
|
|
3238
3414
|
sourceRequirement: entry.sourceRequirement,
|