@treeseed/sdk 0.10.28 → 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 +213 -7
- 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 +118 -59
- package/dist/capacity-provider.js +235 -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 +3 -2
- package/dist/control-plane.js +38 -13
- 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 +50900 -11018
- package/dist/db/market-schema.js +2313 -467
- package/dist/db/node-sqlite.d.ts +1 -232
- package/dist/db/node-sqlite.js +7 -2
- 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 +12 -0
- package/dist/hosting/apps.js +107 -0
- package/dist/hosting/builtins.d.ts +25 -0
- package/dist/hosting/builtins.js +602 -0
- package/dist/hosting/contracts.d.ts +208 -0
- package/dist/hosting/contracts.js +0 -0
- package/dist/hosting/graph.d.ts +195 -0
- package/dist/hosting/graph.js +1092 -0
- package/dist/hosting/index.d.ts +4 -0
- package/dist/hosting/index.js +4 -0
- package/dist/index.d.ts +88 -67
- package/dist/index.js +142 -14
- 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 -9
- package/dist/market-client.d.ts +327 -9
- package/dist/market-client.js +464 -20
- 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 +4 -2
- package/dist/operations/services/bootstrap-runner.js +22 -2
- 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 +83 -24
- package/dist/operations/services/config-runtime.js +449 -130
- package/dist/operations/services/deploy.d.ts +106 -624
- package/dist/operations/services/deploy.js +746 -263
- package/dist/operations/services/deployment-readiness.d.ts +30 -0
- package/dist/operations/services/deployment-readiness.js +206 -0
- 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 +45 -6
- package/dist/operations/services/git-workflow.js +251 -23
- package/dist/operations/services/github-actions-verification.d.ts +4 -1
- package/dist/operations/services/github-actions-verification.js +12 -3
- package/dist/operations/services/github-api.js +22 -6
- package/dist/operations/services/github-automation.d.ts +4 -4
- package/dist/operations/services/github-automation.js +19 -21
- package/dist/operations/services/github-credentials.d.ts +13 -0
- package/dist/operations/services/github-credentials.js +59 -0
- package/dist/operations/services/hosted-service-checks.d.ts +81 -0
- package/dist/operations/services/hosted-service-checks.js +478 -0
- 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 +22 -17
- package/dist/operations/services/live-hosted-service-checks.d.ts +26 -0
- package/dist/operations/services/live-hosted-service-checks.js +463 -0
- 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-host-security.js +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 +31 -0
- package/dist/operations/services/operations-runner-smoke.js +198 -0
- package/dist/operations/services/package-adapters.d.ts +170 -0
- package/dist/operations/services/package-adapters.js +859 -0
- package/dist/operations/services/package-reference-policy.d.ts +13 -88
- package/dist/operations/services/package-reference-policy.js +96 -215
- package/dist/operations/services/project-host-operations.d.ts +4 -4
- package/dist/operations/services/project-platform.d.ts +57 -173
- package/dist/operations/services/project-platform.js +80 -111
- package/dist/operations/services/project-web-monitor.d.ts +2 -2
- package/dist/operations/services/project-web-monitor.js +122 -5
- package/dist/operations/services/railway-api.d.ts +117 -5
- package/dist/operations/services/railway-api.js +915 -93
- package/dist/operations/services/railway-deploy.d.ts +30 -112
- package/dist/operations/services/railway-deploy.js +521 -961
- 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 +8 -7
- package/dist/operations/services/repository-save-orchestrator.js +604 -212
- 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 -191
- package/dist/operations/services/runtime-tools.js +4 -443
- 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/verification-cache.d.ts +25 -0
- package/dist/operations/services/verification-cache.js +71 -0
- 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 +50 -5
- 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 +42 -19
- package/dist/operations/services/workspace-tools.js +42 -7
- 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 +38 -2
- package/dist/platform/deploy-config.d.ts +1 -1
- package/dist/platform/deploy-config.js +80 -9
- 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 +568 -45
- package/dist/platform/environment.d.ts +3 -2
- package/dist/platform/environment.js +122 -21
- 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 +13 -4
- 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/platform-operation-store.js +2 -2
- package/dist/platform-operations.js +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 +5 -5
- package/dist/reconcile/builtin-adapters.d.ts +7 -1
- package/dist/reconcile/builtin-adapters.js +3190 -429
- package/dist/reconcile/contracts.d.ts +23 -6
- package/dist/reconcile/desired-state.d.ts +2 -192
- package/dist/reconcile/desired-state.js +29 -38
- package/dist/reconcile/engine.d.ts +61 -395
- package/dist/reconcile/engine.js +229 -44
- package/dist/reconcile/index.d.ts +10 -8
- package/dist/reconcile/index.js +2 -0
- package/dist/reconcile/live-acceptance.d.ts +100 -0
- package/dist/reconcile/live-acceptance.js +2027 -0
- package/dist/reconcile/platform.d.ts +104 -0
- package/dist/reconcile/platform.js +100 -0
- 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 +7 -44
- package/dist/reconcile/units.d.ts +1 -1
- package/dist/reconcile/units.js +9 -3
- 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/deployment-readiness.js +20 -0
- package/dist/scripts/generate-treedx-openapi-types.js +186 -0
- package/dist/scripts/migrate-journey-csv-to-guarantees.js +140 -0
- package/dist/scripts/operations-runner-smoke.js +16 -0
- package/dist/scripts/package-tools.js +12 -1
- package/dist/scripts/prepare.js +3 -7
- package/dist/scripts/release-verify.js +6 -6
- 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/tenant-workflow-action.js +10 -1
- 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 +1352 -116
- package/dist/sdk-types.js +413 -2
- package/dist/sdk.d.ts +106 -100
- package/dist/sdk.js +211 -51
- 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-requirements.js +9 -0
- package/dist/template-launch-ui.d.ts +2 -2
- package/dist/treedx/adapters.d.ts +6 -0
- package/dist/treedx/adapters.js +36 -0
- package/dist/treedx/client.d.ts +222 -0
- package/dist/treedx/client.js +871 -0
- package/dist/treedx/errors.d.ts +13 -0
- package/dist/treedx/errors.js +17 -0
- package/dist/treedx/federated-client.d.ts +27 -0
- package/dist/treedx/federated-client.js +158 -0
- package/dist/treedx/generated/openapi-types.d.ts +3558 -0
- package/dist/treedx/generated/openapi-types.js +0 -0
- package/dist/treedx/graph-adapter.d.ts +33 -0
- package/dist/treedx/graph-adapter.js +156 -0
- package/dist/treedx/index.d.ts +14 -0
- package/dist/treedx/index.js +48 -0
- package/dist/treedx/market-integration.d.ts +27 -0
- package/dist/treedx/market-integration.js +131 -0
- package/dist/treedx/ports.d.ts +166 -0
- package/dist/treedx/ports.js +231 -0
- package/dist/treedx/query-adapter.d.ts +19 -0
- package/dist/treedx/query-adapter.js +62 -0
- package/dist/treedx/registry-client.d.ts +11 -0
- package/dist/treedx/registry-client.js +19 -0
- package/dist/treedx/repository-adapter.d.ts +45 -0
- package/dist/treedx/repository-adapter.js +319 -0
- package/dist/treedx/sdk-integration.d.ts +27 -0
- package/dist/treedx/sdk-integration.js +63 -0
- package/dist/treedx/types.d.ts +1084 -0
- package/dist/treedx/types.js +8 -0
- package/dist/treedx/workspace-adapter.d.ts +27 -0
- package/dist/treedx/workspace-adapter.js +65 -0
- package/dist/treedx-backends.d.ts +220 -0
- package/dist/treedx-backends.js +634 -0
- package/dist/treedx-client.d.ts +89 -0
- package/dist/treedx-client.js +184 -0
- package/dist/treeseed/services/compose.yml +2 -3
- package/dist/treeseed/template-catalog/catalog.fixture.json +27 -27
- 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 +580 -523
- package/dist/workflow/operations.js +2084 -1279
- 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 +17 -4
- package/dist/workflow-state.js +68 -41
- package/dist/workflow-support.d.ts +26 -17
- package/dist/workflow-support.js +84 -24
- package/dist/workflow.d.ts +51 -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/0004_treedx_market_integration.sql +99 -0
- 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 +106 -18
- package/scripts/{verify-driver.mjs → verify-driver.ts} +19 -4
- package/templates/github/deploy-web.workflow.yml +49 -12
- 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 -41
- package/dist/operations/services/release-candidate.js +0 -616
- 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,4 +1,4 @@
|
|
|
1
|
-
import type { SdkCursorEntity, SdkLeaseEntity, SdkMessageEntity, SdkRunEntity, SdkSubscriptionEntity, TreeseedAgentRunMeta, TreeseedAgentRunPayload, TreeseedContactSubmissionMeta, TreeseedContactSubmissionPayload, TreeseedCursorMeta, TreeseedCursorPayload, TreeseedLeaseMeta, TreeseedLeasePayload, TreeseedMessageMeta, TreeseedMessagePayload, TreeseedRecordEnvelope, TreeseedSubscriptionMeta, TreeseedSubscriptionPayload } from '../sdk-types.
|
|
1
|
+
import type { SdkCursorEntity, SdkLeaseEntity, SdkMessageEntity, SdkRunEntity, SdkSubscriptionEntity, TreeseedAgentRunMeta, TreeseedAgentRunPayload, TreeseedContactSubmissionMeta, TreeseedContactSubmissionPayload, TreeseedCursorMeta, TreeseedCursorPayload, TreeseedLeaseMeta, TreeseedLeasePayload, TreeseedMessageMeta, TreeseedMessagePayload, TreeseedRecordEnvelope, TreeseedSubscriptionMeta, TreeseedSubscriptionPayload } from '../sdk-types.js';
|
|
2
2
|
export declare const TRESEED_ENVELOPE_SCHEMA_VERSION = 1;
|
|
3
3
|
export interface RuntimeRecordRow {
|
|
4
4
|
id?: number;
|
package/dist/stores/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { D1DatabaseLike } from '../types/cloudflare.
|
|
1
|
+
import type { D1DatabaseLike } from '../types/cloudflare.js';
|
|
2
2
|
export type DatabaseRow = Record<string, unknown>;
|
|
3
3
|
export declare function nowIso(): string;
|
|
4
4
|
export declare function toSqlValue(value: unknown): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SdkLeaseEntity, SdkLeaseReleaseRequest, SdkSearchRequest, SdkUpdateRequest } from '../sdk-types.
|
|
2
|
-
import { SqliteStoreBase } from './helpers.
|
|
1
|
+
import type { SdkLeaseEntity, SdkLeaseReleaseRequest, SdkSearchRequest, SdkUpdateRequest } from '../sdk-types.js';
|
|
2
|
+
import { SqliteStoreBase } from './helpers.js';
|
|
3
3
|
export interface LeaseClaimInput {
|
|
4
4
|
model: string;
|
|
5
5
|
itemKey: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SdkAckMessageRequest, SdkClaimMessageRequest, SdkCreateMessageRequest, SdkMessageEntity, SdkSearchRequest, SdkUpdateRequest } from '../sdk-types.
|
|
2
|
-
import { SqliteStoreBase, type DatabaseRow } from './helpers.
|
|
1
|
+
import type { SdkAckMessageRequest, SdkClaimMessageRequest, SdkCreateMessageRequest, SdkMessageEntity, SdkSearchRequest, SdkUpdateRequest } from '../sdk-types.js';
|
|
2
|
+
import { SqliteStoreBase, type DatabaseRow } from './helpers.js';
|
|
3
3
|
export declare function messageFromRow(row: DatabaseRow): SdkMessageEntity;
|
|
4
4
|
export declare class MessageStore extends SqliteStoreBase {
|
|
5
5
|
private usesEnvelopeTable;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ApprovalRequest, CreateApprovalRequestRequest, DecideApprovalRequestRequest, PrioritySnapshot, ListApprovalRequestsRequest, SdkCreatePrioritySnapshotRequest,
|
|
2
|
-
import type { InboxItem } from '../project-workflow.
|
|
3
|
-
import { SqliteStoreBase, type DatabaseRow } from './helpers.
|
|
1
|
+
import type { ApprovalRequest, CreateApprovalRequestRequest, DecideApprovalRequestRequest, PrioritySnapshot, ListApprovalRequestsRequest, SdkCreatePrioritySnapshotRequest, SdkCloseWorkDayRequest, SdkCreateReportRequest, SdkGraphRunEntity, SdkClaimWorkdayManagerLeaseRequest, SdkCreateWorkdayRequest, SdkPriorityOverrideRequest, SdkRecordRepositoryClaimRequest, SdkRecordRunnerScaleDecisionRequest, SdkReportEntity, SdkRecordScaleDecisionRequest, SdkRecordWorkerRunnerRequest, SdkRecordTaskCreditsRequest, SdkReleaseWorkdayManagerLeaseRequest, SdkStartWorkDayRequest, SdkUpsertWorkPolicyRequest, SdkUpdateWorkDayGraphRequest, SdkWorkDayEntity, RepositoryClaim, RunnerScaleDecision, ScaleDecision, TaskCreditLedgerEntry, UpsertTeamInboxItemRequest, WorkdayPolicy, WorkdayManagerLease, WorkdayRequest, WorkerRunner } from '../sdk-types.js';
|
|
2
|
+
import type { InboxItem } from '../project-workflow.js';
|
|
3
|
+
import { SqliteStoreBase, type DatabaseRow } from './helpers.js';
|
|
4
4
|
export declare class OperationalStore extends SqliteStoreBase {
|
|
5
5
|
private governanceInitialized;
|
|
6
6
|
private runnerInitialized;
|
|
@@ -10,29 +10,6 @@ export declare class OperationalStore extends SqliteStoreBase {
|
|
|
10
10
|
searchWorkDays(limit?: number): Promise<SdkWorkDayEntity[]>;
|
|
11
11
|
startWorkDay(request: SdkStartWorkDayRequest): Promise<SdkWorkDayEntity | null>;
|
|
12
12
|
closeWorkDay(request: SdkCloseWorkDayRequest): Promise<SdkWorkDayEntity | null>;
|
|
13
|
-
getTask(id: string): Promise<SdkTaskEntity | null>;
|
|
14
|
-
searchTasks(request?: SdkTaskSearchRequest): Promise<SdkTaskEntity[]>;
|
|
15
|
-
createTask(request: SdkCreateTaskRequest): Promise<SdkTaskEntity | null>;
|
|
16
|
-
claimTask(request: SdkClaimTaskRequest): Promise<SdkTaskEntity | null>;
|
|
17
|
-
recordTaskProgress(request: SdkTaskProgressRequest): Promise<SdkTaskEntity | null>;
|
|
18
|
-
completeTask(request: SdkCompleteTaskRequest): Promise<SdkTaskEntity | null>;
|
|
19
|
-
failTask(request: SdkFailTaskRequest): Promise<SdkTaskEntity | null>;
|
|
20
|
-
appendTaskEvent(request: SdkAppendTaskEventRequest): Promise<SdkTaskEventEntity | null>;
|
|
21
|
-
listTaskEvents(taskId: string): Promise<SdkTaskEventEntity[]>;
|
|
22
|
-
getTaskEvent(id: string): Promise<SdkTaskEventEntity | null>;
|
|
23
|
-
searchTaskEvents(request?: {
|
|
24
|
-
id?: string | string[];
|
|
25
|
-
taskId?: string | string[];
|
|
26
|
-
kind?: string | string[];
|
|
27
|
-
limit?: number;
|
|
28
|
-
}): Promise<SdkTaskEventEntity[]>;
|
|
29
|
-
listTaskOutputs(taskId: string): Promise<SdkTaskOutputEntity[]>;
|
|
30
|
-
getTaskOutput(id: string): Promise<SdkTaskOutputEntity | null>;
|
|
31
|
-
searchTaskOutputs(request?: {
|
|
32
|
-
id?: string | string[];
|
|
33
|
-
taskId?: string | string[];
|
|
34
|
-
limit?: number;
|
|
35
|
-
}): Promise<SdkTaskOutputEntity[]>;
|
|
36
13
|
createGraphRun(input: Omit<SdkGraphRunEntity, 'createdAt'> & {
|
|
37
14
|
createdAt?: string;
|
|
38
15
|
}): Promise<SdkGraphRunEntity | null>;
|
|
@@ -18,51 +18,6 @@ function workDayFromRow(row) {
|
|
|
18
18
|
updatedAt: String(row.updated_at ?? row.updatedAt ?? nowIso())
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
function taskFromRow(row) {
|
|
22
|
-
return {
|
|
23
|
-
id: String(row.id ?? ""),
|
|
24
|
-
workDayId: String(row.work_day_id ?? row.workDayId ?? ""),
|
|
25
|
-
agentId: String(row.agent_id ?? row.agentId ?? ""),
|
|
26
|
-
type: String(row.type ?? ""),
|
|
27
|
-
state: String(row.state ?? "pending"),
|
|
28
|
-
priority: Number(row.priority ?? 0),
|
|
29
|
-
idempotencyKey: String(row.idempotency_key ?? row.idempotencyKey ?? ""),
|
|
30
|
-
payloadJson: String(row.payload_json ?? row.payloadJson ?? "{}"),
|
|
31
|
-
payloadHash: row.payload_hash !== void 0 && row.payload_hash !== null ? String(row.payload_hash) : row.payloadHash !== void 0 && row.payloadHash !== null ? String(row.payloadHash) : null,
|
|
32
|
-
attemptCount: Number(row.attempt_count ?? row.attemptCount ?? 0),
|
|
33
|
-
maxAttempts: Number(row.max_attempts ?? row.maxAttempts ?? 3),
|
|
34
|
-
claimedBy: row.claimed_by !== void 0 && row.claimed_by !== null ? String(row.claimed_by) : row.claimedBy !== void 0 && row.claimedBy !== null ? String(row.claimedBy) : null,
|
|
35
|
-
leaseExpiresAt: row.lease_expires_at !== void 0 && row.lease_expires_at !== null ? String(row.lease_expires_at) : row.leaseExpiresAt !== void 0 && row.leaseExpiresAt !== null ? String(row.leaseExpiresAt) : null,
|
|
36
|
-
availableAt: String(row.available_at ?? row.availableAt ?? nowIso()),
|
|
37
|
-
lastErrorCode: row.last_error_code !== void 0 && row.last_error_code !== null ? String(row.last_error_code) : row.lastErrorCode !== void 0 && row.lastErrorCode !== null ? String(row.lastErrorCode) : null,
|
|
38
|
-
lastErrorMessage: row.last_error_message !== void 0 && row.last_error_message !== null ? String(row.last_error_message) : row.lastErrorMessage !== void 0 && row.lastErrorMessage !== null ? String(row.lastErrorMessage) : null,
|
|
39
|
-
graphVersion: row.graph_version !== void 0 && row.graph_version !== null ? String(row.graph_version) : row.graphVersion !== void 0 && row.graphVersion !== null ? String(row.graphVersion) : null,
|
|
40
|
-
parentTaskId: row.parent_task_id !== void 0 && row.parent_task_id !== null ? String(row.parent_task_id) : row.parentTaskId !== void 0 && row.parentTaskId !== null ? String(row.parentTaskId) : null,
|
|
41
|
-
createdAt: String(row.created_at ?? row.createdAt ?? nowIso()),
|
|
42
|
-
startedAt: row.started_at !== void 0 && row.started_at !== null ? String(row.started_at) : row.startedAt !== void 0 && row.startedAt !== null ? String(row.startedAt) : null,
|
|
43
|
-
completedAt: row.completed_at !== void 0 && row.completed_at !== null ? String(row.completed_at) : row.completedAt !== void 0 && row.completedAt !== null ? String(row.completedAt) : null,
|
|
44
|
-
updatedAt: String(row.updated_at ?? row.updatedAt ?? nowIso())
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function taskEventFromRow(row) {
|
|
48
|
-
return {
|
|
49
|
-
id: String(row.id ?? ""),
|
|
50
|
-
taskId: String(row.task_id ?? row.taskId ?? ""),
|
|
51
|
-
seq: Number(row.seq ?? 0),
|
|
52
|
-
kind: String(row.kind ?? ""),
|
|
53
|
-
dataJson: String(row.data_json ?? row.dataJson ?? "{}"),
|
|
54
|
-
createdAt: String(row.created_at ?? row.createdAt ?? nowIso())
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
function taskOutputFromRow(row) {
|
|
58
|
-
return {
|
|
59
|
-
id: String(row.id ?? ""),
|
|
60
|
-
taskId: String(row.task_id ?? row.taskId ?? ""),
|
|
61
|
-
outputJson: String(row.output_json ?? row.outputJson ?? "{}"),
|
|
62
|
-
outputRef: row.output_ref !== void 0 && row.output_ref !== null ? String(row.output_ref) : row.outputRef !== void 0 && row.outputRef !== null ? String(row.outputRef) : null,
|
|
63
|
-
createdAt: String(row.created_at ?? row.createdAt ?? nowIso())
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
21
|
function graphRunFromRow(row) {
|
|
67
22
|
return {
|
|
68
23
|
id: String(row.id ?? ""),
|
|
@@ -406,186 +361,6 @@ class OperationalStore extends SqliteStoreBase {
|
|
|
406
361
|
);
|
|
407
362
|
return this.getWorkDay(request.id);
|
|
408
363
|
}
|
|
409
|
-
async getTask(id) {
|
|
410
|
-
const row = await this.selectFirst(`SELECT * FROM tasks WHERE id = ${toSqlValue(id)} LIMIT 1`);
|
|
411
|
-
return row ? taskFromRow(row) : null;
|
|
412
|
-
}
|
|
413
|
-
async searchTasks(request = {}) {
|
|
414
|
-
const clauses = [];
|
|
415
|
-
if (request.workDayId) clauses.push(`work_day_id = ${toSqlValue(request.workDayId)}`);
|
|
416
|
-
if (request.agentId) clauses.push(`agent_id = ${toSqlValue(request.agentId)}`);
|
|
417
|
-
if (request.state) {
|
|
418
|
-
const states = Array.isArray(request.state) ? request.state : [request.state];
|
|
419
|
-
clauses.push(`state IN (${states.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
420
|
-
}
|
|
421
|
-
const sql = [
|
|
422
|
-
"SELECT * FROM tasks",
|
|
423
|
-
clauses.length ? `WHERE ${clauses.join(" AND ")}` : "",
|
|
424
|
-
"ORDER BY priority DESC, available_at ASC, created_at ASC",
|
|
425
|
-
`LIMIT ${request.limit ?? 50}`
|
|
426
|
-
].filter(Boolean).join(" ");
|
|
427
|
-
const rows = await this.selectAll(sql);
|
|
428
|
-
return rows.map(taskFromRow);
|
|
429
|
-
}
|
|
430
|
-
async createTask(request) {
|
|
431
|
-
const id = request.id ?? crypto.randomUUID();
|
|
432
|
-
const timestamp = nowIso();
|
|
433
|
-
await this.execute(
|
|
434
|
-
`INSERT OR REPLACE INTO tasks (id, work_day_id, agent_id, type, state, priority, idempotency_key, payload_json, payload_hash, attempt_count, max_attempts, claimed_by, lease_expires_at, available_at, last_error_code, last_error_message, graph_version, parent_task_id, created_at, started_at, completed_at, updated_at) VALUES (${toSqlValue(id)}, ${toSqlValue(request.workDayId)}, ${toSqlValue(request.agentId)}, ${toSqlValue(request.type)}, ${toSqlValue(request.state ?? "pending")}, ${Number(request.priority ?? 0)}, ${toSqlValue(request.idempotencyKey)}, ${toSqlValue(json(request.payload))}, ${toSqlValue(request.payloadHash ?? null)}, 0, ${Number(request.maxAttempts ?? 3)}, NULL, NULL, ${toSqlValue(request.availableAt ?? timestamp)}, NULL, NULL, ${toSqlValue(request.graphVersion ?? null)}, ${toSqlValue(request.parentTaskId ?? null)}, COALESCE((SELECT created_at FROM tasks WHERE id = ${toSqlValue(id)}), ${toSqlValue(timestamp)}), NULL, NULL, ${toSqlValue(timestamp)})`
|
|
435
|
-
);
|
|
436
|
-
return this.getTask(id);
|
|
437
|
-
}
|
|
438
|
-
async claimTask(request) {
|
|
439
|
-
const existing = await this.getTask(request.id);
|
|
440
|
-
if (!existing) {
|
|
441
|
-
return null;
|
|
442
|
-
}
|
|
443
|
-
const timestamp = nowIso();
|
|
444
|
-
const leaseExpiresAt = new Date(Date.now() + request.leaseSeconds * 1e3).toISOString();
|
|
445
|
-
await this.execute(
|
|
446
|
-
`UPDATE tasks SET state = 'claimed', claimed_by = ${toSqlValue(request.workerId)}, lease_expires_at = ${toSqlValue(leaseExpiresAt)}, attempt_count = attempt_count + 1, started_at = COALESCE(started_at, ${toSqlValue(timestamp)}), updated_at = ${toSqlValue(timestamp)} WHERE id = ${toSqlValue(request.id)}`
|
|
447
|
-
);
|
|
448
|
-
return this.getTask(request.id);
|
|
449
|
-
}
|
|
450
|
-
async recordTaskProgress(request) {
|
|
451
|
-
const existing = await this.getTask(request.id);
|
|
452
|
-
if (!existing) {
|
|
453
|
-
return null;
|
|
454
|
-
}
|
|
455
|
-
const patch = request.patch ?? {};
|
|
456
|
-
const currentPayload = JSON.parse(existing.payloadJson);
|
|
457
|
-
const nextPayload = { ...currentPayload, ...patch };
|
|
458
|
-
const timestamp = nowIso();
|
|
459
|
-
await this.execute(
|
|
460
|
-
`UPDATE tasks SET state = ${toSqlValue(request.state ?? existing.state)}, payload_json = ${toSqlValue(json(nextPayload))}, claimed_by = ${toSqlValue(request.workerId ?? existing.claimedBy)}, updated_at = ${toSqlValue(timestamp)} WHERE id = ${toSqlValue(request.id)}`
|
|
461
|
-
);
|
|
462
|
-
if (request.appendEvent?.kind) {
|
|
463
|
-
await this.appendTaskEvent({
|
|
464
|
-
taskId: request.id,
|
|
465
|
-
kind: request.appendEvent.kind,
|
|
466
|
-
data: request.appendEvent.data,
|
|
467
|
-
actor: request.actor
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
return this.getTask(request.id);
|
|
471
|
-
}
|
|
472
|
-
async completeTask(request) {
|
|
473
|
-
const existing = await this.getTask(request.id);
|
|
474
|
-
if (!existing) {
|
|
475
|
-
return null;
|
|
476
|
-
}
|
|
477
|
-
const timestamp = nowIso();
|
|
478
|
-
await this.execute(
|
|
479
|
-
`UPDATE tasks SET state = 'completed', completed_at = ${toSqlValue(timestamp)}, lease_expires_at = NULL, updated_at = ${toSqlValue(timestamp)} WHERE id = ${toSqlValue(request.id)}`
|
|
480
|
-
);
|
|
481
|
-
if (request.output) {
|
|
482
|
-
await this.execute(
|
|
483
|
-
`INSERT INTO task_outputs (id, task_id, output_json, output_ref, created_at) VALUES (${toSqlValue(crypto.randomUUID())}, ${toSqlValue(request.id)}, ${toSqlValue(json(request.output))}, ${toSqlValue(request.outputRef ?? null)}, ${toSqlValue(timestamp)})`
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
if (request.summary) {
|
|
487
|
-
await this.appendTaskEvent({
|
|
488
|
-
taskId: request.id,
|
|
489
|
-
kind: "completed",
|
|
490
|
-
data: request.summary,
|
|
491
|
-
actor: request.actor
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
return this.getTask(request.id);
|
|
495
|
-
}
|
|
496
|
-
async failTask(request) {
|
|
497
|
-
const existing = await this.getTask(request.id);
|
|
498
|
-
if (!existing) {
|
|
499
|
-
return null;
|
|
500
|
-
}
|
|
501
|
-
const timestamp = nowIso();
|
|
502
|
-
const nextState = request.retryable ? "pending" : "failed";
|
|
503
|
-
await this.execute(
|
|
504
|
-
`UPDATE tasks SET state = ${toSqlValue(nextState)}, available_at = ${toSqlValue(request.nextVisibleAt ?? existing.availableAt)}, last_error_code = ${toSqlValue(request.errorCode ?? null)}, last_error_message = ${toSqlValue(request.errorMessage)}, lease_expires_at = NULL, updated_at = ${toSqlValue(timestamp)} WHERE id = ${toSqlValue(request.id)}`
|
|
505
|
-
);
|
|
506
|
-
await this.appendTaskEvent({
|
|
507
|
-
taskId: request.id,
|
|
508
|
-
kind: nextState === "pending" ? "retry_scheduled" : "failed",
|
|
509
|
-
data: { errorCode: request.errorCode ?? null, errorMessage: request.errorMessage },
|
|
510
|
-
actor: request.actor
|
|
511
|
-
});
|
|
512
|
-
return this.getTask(request.id);
|
|
513
|
-
}
|
|
514
|
-
async appendTaskEvent(request) {
|
|
515
|
-
const seqRow = await this.selectFirst(
|
|
516
|
-
`SELECT COALESCE(MAX(seq), 0) + 1 AS next_seq FROM task_events WHERE task_id = ${toSqlValue(request.taskId)}`
|
|
517
|
-
);
|
|
518
|
-
const seq = Number(seqRow?.next_seq ?? 1);
|
|
519
|
-
const id = crypto.randomUUID();
|
|
520
|
-
const timestamp = nowIso();
|
|
521
|
-
await this.execute(
|
|
522
|
-
`INSERT INTO task_events (id, task_id, seq, kind, data_json, created_at) VALUES (${toSqlValue(id)}, ${toSqlValue(request.taskId)}, ${seq}, ${toSqlValue(request.kind)}, ${toSqlValue(json({ ...request.data ?? {}, actor: request.actor }))}, ${toSqlValue(timestamp)})`
|
|
523
|
-
);
|
|
524
|
-
const row = await this.selectFirst(`SELECT * FROM task_events WHERE id = ${toSqlValue(id)} LIMIT 1`);
|
|
525
|
-
return row ? taskEventFromRow(row) : null;
|
|
526
|
-
}
|
|
527
|
-
async listTaskEvents(taskId) {
|
|
528
|
-
const rows = await this.selectAll(
|
|
529
|
-
`SELECT * FROM task_events WHERE task_id = ${toSqlValue(taskId)} ORDER BY seq ASC`
|
|
530
|
-
);
|
|
531
|
-
return rows.map(taskEventFromRow);
|
|
532
|
-
}
|
|
533
|
-
async getTaskEvent(id) {
|
|
534
|
-
const row = await this.selectFirst(`SELECT * FROM task_events WHERE id = ${toSqlValue(id)} LIMIT 1`);
|
|
535
|
-
return row ? taskEventFromRow(row) : null;
|
|
536
|
-
}
|
|
537
|
-
async searchTaskEvents(request = {}) {
|
|
538
|
-
const clauses = [];
|
|
539
|
-
if (request.id) {
|
|
540
|
-
const ids = Array.isArray(request.id) ? request.id : [request.id];
|
|
541
|
-
clauses.push(`id IN (${ids.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
542
|
-
}
|
|
543
|
-
if (request.taskId) {
|
|
544
|
-
const taskIds = Array.isArray(request.taskId) ? request.taskId : [request.taskId];
|
|
545
|
-
clauses.push(`task_id IN (${taskIds.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
546
|
-
}
|
|
547
|
-
if (request.kind) {
|
|
548
|
-
const kinds = Array.isArray(request.kind) ? request.kind : [request.kind];
|
|
549
|
-
clauses.push(`kind IN (${kinds.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
550
|
-
}
|
|
551
|
-
const sql = [
|
|
552
|
-
"SELECT * FROM task_events",
|
|
553
|
-
clauses.length ? `WHERE ${clauses.join(" AND ")}` : "",
|
|
554
|
-
"ORDER BY created_at DESC, seq DESC",
|
|
555
|
-
`LIMIT ${request.limit ?? 50}`
|
|
556
|
-
].filter(Boolean).join(" ");
|
|
557
|
-
const rows = await this.selectAll(sql);
|
|
558
|
-
return rows.map(taskEventFromRow);
|
|
559
|
-
}
|
|
560
|
-
async listTaskOutputs(taskId) {
|
|
561
|
-
const rows = await this.selectAll(
|
|
562
|
-
`SELECT * FROM task_outputs WHERE task_id = ${toSqlValue(taskId)} ORDER BY created_at ASC`
|
|
563
|
-
);
|
|
564
|
-
return rows.map(taskOutputFromRow);
|
|
565
|
-
}
|
|
566
|
-
async getTaskOutput(id) {
|
|
567
|
-
const row = await this.selectFirst(`SELECT * FROM task_outputs WHERE id = ${toSqlValue(id)} LIMIT 1`);
|
|
568
|
-
return row ? taskOutputFromRow(row) : null;
|
|
569
|
-
}
|
|
570
|
-
async searchTaskOutputs(request = {}) {
|
|
571
|
-
const clauses = [];
|
|
572
|
-
if (request.id) {
|
|
573
|
-
const ids = Array.isArray(request.id) ? request.id : [request.id];
|
|
574
|
-
clauses.push(`id IN (${ids.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
575
|
-
}
|
|
576
|
-
if (request.taskId) {
|
|
577
|
-
const taskIds = Array.isArray(request.taskId) ? request.taskId : [request.taskId];
|
|
578
|
-
clauses.push(`task_id IN (${taskIds.map((entry) => toSqlValue(entry)).join(", ")})`);
|
|
579
|
-
}
|
|
580
|
-
const sql = [
|
|
581
|
-
"SELECT * FROM task_outputs",
|
|
582
|
-
clauses.length ? `WHERE ${clauses.join(" AND ")}` : "",
|
|
583
|
-
"ORDER BY created_at DESC",
|
|
584
|
-
`LIMIT ${request.limit ?? 50}`
|
|
585
|
-
].filter(Boolean).join(" ");
|
|
586
|
-
const rows = await this.selectAll(sql);
|
|
587
|
-
return rows.map(taskOutputFromRow);
|
|
588
|
-
}
|
|
589
364
|
async createGraphRun(input) {
|
|
590
365
|
const timestamp = input.createdAt ?? nowIso();
|
|
591
366
|
await this.execute(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ReleaseDetail, ReleaseSummary, SharePackageStatus, WorkstreamDetail, WorkstreamEvent, WorkstreamState, WorkstreamSummary, LinkedProjectRecordRef } from '../project-workflow.
|
|
2
|
-
import { SqliteStoreBase } from './helpers.
|
|
1
|
+
import type { ReleaseDetail, ReleaseSummary, SharePackageStatus, WorkstreamDetail, WorkstreamEvent, WorkstreamState, WorkstreamSummary, LinkedProjectRecordRef } from '../project-workflow.js';
|
|
2
|
+
import { SqliteStoreBase } from './helpers.js';
|
|
3
3
|
export declare class MemoryProjectWorkflowStore {
|
|
4
4
|
private readonly workstreams;
|
|
5
5
|
private readonly workstreamEvents;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { SdkRecordRunRequest, SdkRunEntity, SdkSearchRequest, SdkUpdateRequest } from '../sdk-types.
|
|
2
|
-
import { SqliteStoreBase } from './helpers.
|
|
1
|
+
import type { SdkRecordRunRequest, SdkRunEntity, SdkSearchRequest, SdkUpdateRequest } from '../sdk-types.js';
|
|
2
|
+
import { SqliteStoreBase } from './helpers.js';
|
|
3
3
|
export declare function runFromRecord(row: Record<string, unknown>): SdkRunEntity;
|
|
4
4
|
export declare class RunStore extends SqliteStoreBase {
|
|
5
|
-
private usesEnvelopeTable;
|
|
6
5
|
getByKey(key: string): Promise<SdkRunEntity | null>;
|
|
7
6
|
search(request: SdkSearchRequest): Promise<SdkRunEntity[]>;
|
|
8
7
|
record(request: SdkRecordRunRequest): Promise<SdkRunEntity>;
|
package/dist/stores/run-store.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assertExpectedVersion } from "../sdk-version.js";
|
|
2
2
|
import { SqliteStoreBase, nowIso, toSqlValue } from "./helpers.js";
|
|
3
|
-
import { createRunEnvelope, runEntityFromEnvelope, TRESEED_ENVELOPE_SCHEMA_VERSION } from "./envelopes.js";
|
|
4
3
|
function runFromRecord(row) {
|
|
5
4
|
return {
|
|
6
5
|
runId: String(row.runId ?? row.run_id ?? ""),
|
|
@@ -24,41 +23,13 @@ function runFromRecord(row) {
|
|
|
24
23
|
};
|
|
25
24
|
}
|
|
26
25
|
class RunStore extends SqliteStoreBase {
|
|
27
|
-
async usesEnvelopeTable() {
|
|
28
|
-
return this.tableExists("runtime_records");
|
|
29
|
-
}
|
|
30
26
|
async getByKey(key) {
|
|
31
|
-
if (await this.usesEnvelopeTable()) {
|
|
32
|
-
const row2 = await this.selectFirst(
|
|
33
|
-
`SELECT * FROM runtime_records WHERE record_type = 'agent_run' AND record_key = ${toSqlValue(key)} LIMIT 1`
|
|
34
|
-
);
|
|
35
|
-
return row2 ? runEntityFromEnvelope(row2) : null;
|
|
36
|
-
}
|
|
37
27
|
const row = await this.selectFirst(
|
|
38
28
|
`SELECT * FROM agent_runs WHERE run_id = ${toSqlValue(key)} LIMIT 1`
|
|
39
29
|
);
|
|
40
30
|
return row ? runFromRecord(row) : null;
|
|
41
31
|
}
|
|
42
32
|
async search(request) {
|
|
43
|
-
if (await this.usesEnvelopeTable()) {
|
|
44
|
-
const where2 = request.filters?.length ? `AND ${request.filters.map((filter) => {
|
|
45
|
-
const field = runFilterColumn(filter.field);
|
|
46
|
-
switch (filter.op) {
|
|
47
|
-
case "eq":
|
|
48
|
-
return `${field} = ${toSqlValue(filter.value)}`;
|
|
49
|
-
case "in":
|
|
50
|
-
return `${field} IN (${(Array.isArray(filter.value) ? filter.value : [filter.value]).map(toSqlValue).join(", ")})`;
|
|
51
|
-
case "updated_since":
|
|
52
|
-
return `created_at >= ${toSqlValue(filter.value)}`;
|
|
53
|
-
default:
|
|
54
|
-
return `${field} LIKE ${toSqlValue(`%${String(filter.value ?? "")}%`)}`;
|
|
55
|
-
}
|
|
56
|
-
}).join(" AND ")}` : "";
|
|
57
|
-
const order2 = request.sort?.length ? `ORDER BY ${request.sort.map((entry) => `${runSortColumn(entry.field)} ${entry.direction === "asc" ? "ASC" : "DESC"}`).join(", ")}` : "";
|
|
58
|
-
const limit2 = request.limit ? `LIMIT ${request.limit}` : "";
|
|
59
|
-
const rows2 = await this.selectAll(["SELECT * FROM runtime_records WHERE record_type = 'agent_run'", where2, order2, limit2].filter(Boolean).join(" "));
|
|
60
|
-
return rows2.map(runEntityFromEnvelope);
|
|
61
|
-
}
|
|
62
33
|
const where = request.filters?.length ? `WHERE ${request.filters.map((filter) => {
|
|
63
34
|
switch (filter.op) {
|
|
64
35
|
case "eq":
|
|
@@ -78,32 +49,6 @@ class RunStore extends SqliteStoreBase {
|
|
|
78
49
|
}
|
|
79
50
|
async record(request) {
|
|
80
51
|
const run = runFromRecord(request.run);
|
|
81
|
-
if (await this.usesEnvelopeTable()) {
|
|
82
|
-
const envelope = createRunEnvelope({
|
|
83
|
-
runId: run.runId,
|
|
84
|
-
agentSlug: run.agentSlug,
|
|
85
|
-
status: run.status,
|
|
86
|
-
triggerSource: run.triggerSource,
|
|
87
|
-
startedAt: run.startedAt,
|
|
88
|
-
handlerKind: run.handlerKind ?? null,
|
|
89
|
-
triggerKind: run.triggerKind ?? null,
|
|
90
|
-
selectedItemKey: run.selectedItemKey ?? null,
|
|
91
|
-
selectedMessageId: run.selectedMessageId ?? null,
|
|
92
|
-
claimedMessageId: run.claimedMessageId ?? null,
|
|
93
|
-
branchName: run.branchName ?? null,
|
|
94
|
-
prUrl: run.prUrl ?? null,
|
|
95
|
-
summary: run.summary ?? null,
|
|
96
|
-
error: run.error ?? null,
|
|
97
|
-
errorCategory: run.errorCategory ?? null,
|
|
98
|
-
commitSha: run.commitSha ?? null,
|
|
99
|
-
changedPaths: run.changedPaths ?? [],
|
|
100
|
-
finishedAt: run.finishedAt ?? null
|
|
101
|
-
});
|
|
102
|
-
await this.execute(
|
|
103
|
-
`INSERT OR REPLACE INTO runtime_records (record_type, record_key, lookup_key, secondary_key, status, schema_version, created_at, updated_at, payload_json, meta_json) VALUES ('agent_run', ${toSqlValue(run.runId)}, ${toSqlValue(run.agentSlug)}, ${toSqlValue(run.commitSha ?? null)}, ${toSqlValue(run.status)}, ${TRESEED_ENVELOPE_SCHEMA_VERSION}, ${toSqlValue(run.startedAt)}, ${toSqlValue(run.finishedAt ?? run.startedAt)}, ${toSqlValue(JSON.stringify(envelope.payload))}, ${toSqlValue(JSON.stringify(envelope.meta))})`
|
|
104
|
-
);
|
|
105
|
-
return this.getByKey(run.runId);
|
|
106
|
-
}
|
|
107
52
|
await this.execute(
|
|
108
53
|
`INSERT OR REPLACE INTO agent_runs (run_id, agent_slug, handler_kind, trigger_kind, trigger_source, claimed_message_id, status, selected_item_key, selected_message_id, branch_name, pr_url, summary, error, error_category, commit_sha, changed_paths, started_at, finished_at) VALUES (${toSqlValue(run.runId)}, ${toSqlValue(run.agentSlug)}, ${toSqlValue(run.handlerKind ?? null)}, ${toSqlValue(run.triggerKind ?? null)}, ${toSqlValue(run.triggerSource)}, ${toSqlValue(run.claimedMessageId ?? null)}, ${toSqlValue(run.status)}, ${toSqlValue(run.selectedItemKey)}, ${toSqlValue(run.selectedMessageId)}, ${toSqlValue(run.branchName)}, ${toSqlValue(run.prUrl)}, ${toSqlValue(run.summary)}, ${toSqlValue(run.error)}, ${toSqlValue(run.errorCategory ?? null)}, ${toSqlValue(run.commitSha ?? null)}, ${toSqlValue(JSON.stringify(run.changedPaths ?? []))}, ${toSqlValue(run.startedAt)}, ${toSqlValue(run.finishedAt)})`
|
|
109
54
|
);
|
|
@@ -124,49 +69,6 @@ class RunStore extends SqliteStoreBase {
|
|
|
124
69
|
});
|
|
125
70
|
}
|
|
126
71
|
}
|
|
127
|
-
function runFilterColumn(field) {
|
|
128
|
-
switch (field) {
|
|
129
|
-
case "runId":
|
|
130
|
-
case "run_id":
|
|
131
|
-
return "record_key";
|
|
132
|
-
case "agentSlug":
|
|
133
|
-
case "agent_slug":
|
|
134
|
-
return "lookup_key";
|
|
135
|
-
case "status":
|
|
136
|
-
return "status";
|
|
137
|
-
case "commitSha":
|
|
138
|
-
case "commit_sha":
|
|
139
|
-
return "secondary_key";
|
|
140
|
-
case "startedAt":
|
|
141
|
-
case "started_at":
|
|
142
|
-
return "created_at";
|
|
143
|
-
case "finishedAt":
|
|
144
|
-
case "finished_at":
|
|
145
|
-
return "json_extract(payload_json, '$.finishedAt')";
|
|
146
|
-
default:
|
|
147
|
-
return `json_extract(payload_json, '$.${field}')`;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function runSortColumn(field) {
|
|
151
|
-
switch (field) {
|
|
152
|
-
case "runId":
|
|
153
|
-
case "run_id":
|
|
154
|
-
return "record_key";
|
|
155
|
-
case "agentSlug":
|
|
156
|
-
case "agent_slug":
|
|
157
|
-
return "lookup_key";
|
|
158
|
-
case "startedAt":
|
|
159
|
-
case "started_at":
|
|
160
|
-
return "created_at";
|
|
161
|
-
case "commitSha":
|
|
162
|
-
case "commit_sha":
|
|
163
|
-
return "secondary_key";
|
|
164
|
-
case "status":
|
|
165
|
-
return "status";
|
|
166
|
-
default:
|
|
167
|
-
return "created_at";
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
72
|
export {
|
|
171
73
|
RunStore,
|
|
172
74
|
runFromRecord
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { SdkMutationRequest, SdkSearchRequest, SdkSubscriptionEntity, SdkUpdateRequest } from '../sdk-types.
|
|
2
|
-
import { SqliteStoreBase } from './helpers.
|
|
1
|
+
import type { SdkMutationRequest, SdkSearchRequest, SdkSubscriptionEntity, SdkUpdateRequest } from '../sdk-types.js';
|
|
2
|
+
import { SqliteStoreBase } from './helpers.js';
|
|
3
3
|
export declare class SubscriptionStore extends SqliteStoreBase {
|
|
4
|
-
private usesEnvelopeTable;
|
|
5
4
|
getByKey(key: string): Promise<SdkSubscriptionEntity | null>;
|
|
6
5
|
search(request: SdkSearchRequest): Promise<SdkSubscriptionEntity[]>;
|
|
7
6
|
create(request: SdkMutationRequest): Promise<SdkSubscriptionEntity | null>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assertExpectedVersion } from "../sdk-version.js";
|
|
2
2
|
import { SqliteStoreBase, toSqlValue } from "./helpers.js";
|
|
3
|
-
import { createSubscriptionEnvelope, subscriptionEntityFromEnvelope, TRESEED_ENVELOPE_SCHEMA_VERSION } from "./envelopes.js";
|
|
4
3
|
function subscriptionFromRow(row) {
|
|
5
4
|
return {
|
|
6
5
|
id: row.id !== void 0 ? Number(row.id) : void 0,
|
|
@@ -29,33 +28,12 @@ function buildFilterSql(filters = []) {
|
|
|
29
28
|
}).join(" AND ")}` : "";
|
|
30
29
|
}
|
|
31
30
|
class SubscriptionStore extends SqliteStoreBase {
|
|
32
|
-
async usesEnvelopeTable() {
|
|
33
|
-
return this.tableExists("runtime_records");
|
|
34
|
-
}
|
|
35
31
|
async getByKey(key) {
|
|
36
|
-
if (await this.usesEnvelopeTable()) {
|
|
37
|
-
const row2 = await this.selectFirst(
|
|
38
|
-
`SELECT * FROM runtime_records WHERE record_type = 'subscription' AND (record_key = ${toSqlValue(key)} OR lookup_key = ${toSqlValue(key)} OR id = ${toSqlValue(key)}) LIMIT 1`
|
|
39
|
-
);
|
|
40
|
-
if (row2) {
|
|
41
|
-
return subscriptionEntityFromEnvelope(row2);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
32
|
const field = key.includes("@") ? "email" : "id";
|
|
45
33
|
const row = await this.selectFirst(`SELECT * FROM subscriptions WHERE ${field} = ${toSqlValue(key)} LIMIT 1`);
|
|
46
34
|
return row ? subscriptionFromRow(row) : null;
|
|
47
35
|
}
|
|
48
36
|
async search(request) {
|
|
49
|
-
if (await this.usesEnvelopeTable()) {
|
|
50
|
-
const sql2 = [
|
|
51
|
-
"SELECT * FROM runtime_records WHERE record_type = 'subscription'",
|
|
52
|
-
buildEnvelopeFilterSql(request.filters),
|
|
53
|
-
request.sort?.length ? `ORDER BY ${request.sort.map((entry) => `${subscriptionSortColumn(entry.field)} ${entry.direction === "asc" ? "ASC" : "DESC"}`).join(", ")}` : "ORDER BY updated_at DESC",
|
|
54
|
-
request.limit ? `LIMIT ${request.limit}` : ""
|
|
55
|
-
].filter(Boolean).join(" ");
|
|
56
|
-
const rows2 = await this.selectAll(sql2);
|
|
57
|
-
return rows2.map(subscriptionEntityFromEnvelope);
|
|
58
|
-
}
|
|
59
37
|
const sql = [
|
|
60
38
|
"SELECT * FROM subscriptions",
|
|
61
39
|
buildFilterSql(request.filters),
|
|
@@ -67,21 +45,6 @@ class SubscriptionStore extends SqliteStoreBase {
|
|
|
67
45
|
}
|
|
68
46
|
async create(request) {
|
|
69
47
|
const data = request.data;
|
|
70
|
-
if (await this.usesEnvelopeTable()) {
|
|
71
|
-
const envelope = createSubscriptionEnvelope({
|
|
72
|
-
email: String(data.email ?? ""),
|
|
73
|
-
name: data.name !== void 0 && data.name !== null ? String(data.name) : null,
|
|
74
|
-
status: typeof data.status === "string" ? data.status : "active",
|
|
75
|
-
source: typeof data.source === "string" ? data.source : "sdk",
|
|
76
|
-
consentAt: typeof (data.consent_at ?? data.consentAt) === "string" ? String(data.consent_at ?? data.consentAt) : (/* @__PURE__ */ new Date()).toISOString(),
|
|
77
|
-
ipHash: typeof (data.ip_hash ?? data.ipHash) === "string" ? String(data.ip_hash ?? data.ipHash) : ""
|
|
78
|
-
});
|
|
79
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
80
|
-
await this.execute(
|
|
81
|
-
`INSERT INTO runtime_records (record_type, record_key, lookup_key, status, schema_version, created_at, updated_at, payload_json, meta_json) VALUES ('subscription', ${toSqlValue(envelope.payload.email)}, ${toSqlValue(envelope.payload.email)}, ${toSqlValue(envelope.status)}, ${TRESEED_ENVELOPE_SCHEMA_VERSION}, ${toSqlValue(now)}, ${toSqlValue(now)}, ${toSqlValue(JSON.stringify(envelope.payload))}, ${toSqlValue(JSON.stringify(envelope.meta))})`
|
|
82
|
-
);
|
|
83
|
-
return this.getByKey(envelope.payload.email);
|
|
84
|
-
}
|
|
85
48
|
await this.execute(
|
|
86
49
|
`INSERT INTO subscriptions (email, name, status, source, consent_at, created_at, updated_at, ip_hash) VALUES (${toSqlValue(data.email)}, ${toSqlValue(data.name ?? null)}, ${toSqlValue(data.status ?? "active")}, ${toSqlValue(data.source ?? "sdk")}, ${toSqlValue(data.consent_at ?? data.consentAt ?? (/* @__PURE__ */ new Date()).toISOString())}, ${toSqlValue(data.created_at ?? data.createdAt ?? (/* @__PURE__ */ new Date()).toISOString())}, ${toSqlValue(data.updated_at ?? data.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString())}, ${toSqlValue(data.ip_hash ?? data.ipHash ?? "")})`
|
|
87
50
|
);
|
|
@@ -99,75 +62,12 @@ class SubscriptionStore extends SqliteStoreBase {
|
|
|
99
62
|
...request.data,
|
|
100
63
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
101
64
|
};
|
|
102
|
-
if (await this.usesEnvelopeTable()) {
|
|
103
|
-
const envelope = createSubscriptionEnvelope({
|
|
104
|
-
email: existing.email,
|
|
105
|
-
name: next.name ?? null,
|
|
106
|
-
status: String(next.status ?? "active"),
|
|
107
|
-
source: typeof next.source === "string" ? next.source : "sdk",
|
|
108
|
-
consentAt: typeof (next.consent_at ?? next.consentAt) === "string" ? String(next.consent_at ?? next.consentAt) : null,
|
|
109
|
-
ipHash: typeof (next.ip_hash ?? next.ipHash) === "string" ? String(next.ip_hash ?? next.ipHash) : "",
|
|
110
|
-
meta: { legacyId: existing.id }
|
|
111
|
-
});
|
|
112
|
-
await this.execute(
|
|
113
|
-
`UPDATE runtime_records SET status = ${toSqlValue(envelope.status)}, updated_at = ${toSqlValue(String(next.updated_at))}, payload_json = ${toSqlValue(JSON.stringify(envelope.payload))}, meta_json = ${toSqlValue(JSON.stringify(envelope.meta))} WHERE record_type = 'subscription' AND record_key = ${toSqlValue(existing.email)}`
|
|
114
|
-
);
|
|
115
|
-
return this.getByKey(existing.email);
|
|
116
|
-
}
|
|
117
65
|
await this.execute(
|
|
118
66
|
`UPDATE subscriptions SET name = ${toSqlValue(next.name ?? null)}, status = ${toSqlValue(next.status)}, source = ${toSqlValue(next.source ?? "sdk")}, consent_at = ${toSqlValue(next.consent_at ?? null)}, updated_at = ${toSqlValue(next.updated_at ?? (/* @__PURE__ */ new Date()).toISOString())}, ip_hash = ${toSqlValue(next.ip_hash ?? "")} WHERE email = ${toSqlValue(existing.email)}`
|
|
119
67
|
);
|
|
120
68
|
return this.getByKey(existing.email);
|
|
121
69
|
}
|
|
122
70
|
}
|
|
123
|
-
function buildEnvelopeFilterSql(filters = []) {
|
|
124
|
-
if (!filters?.length) return "";
|
|
125
|
-
const clauses = filters.map((filter) => {
|
|
126
|
-
const field = subscriptionFilterColumn(filter.field);
|
|
127
|
-
switch (filter.op) {
|
|
128
|
-
case "eq":
|
|
129
|
-
return `${field} = ${toSqlValue(filter.value)}`;
|
|
130
|
-
case "in":
|
|
131
|
-
return `${field} IN (${(Array.isArray(filter.value) ? filter.value : [filter.value]).map(toSqlValue).join(", ")})`;
|
|
132
|
-
case "updated_since":
|
|
133
|
-
return `updated_at >= ${toSqlValue(filter.value)}`;
|
|
134
|
-
default:
|
|
135
|
-
return `${field} LIKE ${toSqlValue(`%${String(filter.value ?? "")}%`)}`;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
return clauses.length > 0 ? `AND ${clauses.join(" AND ")}` : "";
|
|
139
|
-
}
|
|
140
|
-
function subscriptionFilterColumn(field) {
|
|
141
|
-
switch (field) {
|
|
142
|
-
case "email":
|
|
143
|
-
return "lookup_key";
|
|
144
|
-
case "status":
|
|
145
|
-
return "status";
|
|
146
|
-
case "updated_at":
|
|
147
|
-
case "updatedAt":
|
|
148
|
-
return "updated_at";
|
|
149
|
-
case "created_at":
|
|
150
|
-
case "createdAt":
|
|
151
|
-
return "created_at";
|
|
152
|
-
default:
|
|
153
|
-
return `json_extract(payload_json, '$.${field}')`;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function subscriptionSortColumn(field) {
|
|
157
|
-
switch (field) {
|
|
158
|
-
case "email":
|
|
159
|
-
return "lookup_key";
|
|
160
|
-
case "status":
|
|
161
|
-
return "status";
|
|
162
|
-
case "created_at":
|
|
163
|
-
case "createdAt":
|
|
164
|
-
return "created_at";
|
|
165
|
-
case "updated_at":
|
|
166
|
-
case "updatedAt":
|
|
167
|
-
default:
|
|
168
|
-
return "updated_at";
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
71
|
export {
|
|
172
72
|
SubscriptionStore
|
|
173
73
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SdkTemplateCatalogEntry, SdkTemplateCatalogResponse } from './sdk-types.
|
|
1
|
+
import type { SdkTemplateCatalogEntry, SdkTemplateCatalogResponse } from './sdk-types.js';
|
|
2
2
|
export interface RemoteTemplateCatalogClientOptions {
|
|
3
3
|
endpoint: string;
|
|
4
4
|
fetchImpl?: typeof fetch;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type ProjectEnvironmentName, type ProjectLaunchHostBindingInput, type ProjectLaunchRequirementKind, type TemplateConfigWrite, type TemplateLaunchRequirements } from './sdk-types.
|
|
1
|
+
import { type ProjectEnvironmentName, type ProjectLaunchHostBindingInput, type ProjectLaunchRequirementKind, type TemplateConfigWrite, type TemplateLaunchRequirements } from './sdk-types.js';
|
|
2
2
|
type Mutable<T> = {
|
|
3
3
|
-readonly [P in keyof T]: T[P];
|
|
4
4
|
};
|
|
5
|
-
export type { TemplateLaunchRequirements } from './sdk-types.
|
|
5
|
+
export type { TemplateLaunchRequirements } from './sdk-types.js';
|
|
6
6
|
export interface ProjectLaunchHostInventoryRecord {
|
|
7
7
|
id: string;
|
|
8
8
|
type?: string | null;
|