@hypit/hypit 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +26 -0
- package/README.md +142 -0
- package/bin/hypit.mjs +46 -0
- package/dist/public/artifact.d.ts +75 -0
- package/dist/public/author-kit.d.ts +559 -0
- package/dist/public/browser-capture.d.ts +56 -0
- package/dist/public/caption.d.ts +751 -0
- package/dist/public/composition.d.ts +672 -0
- package/dist/public/endpoint-kit.d.ts +366 -0
- package/dist/public/generation.d.ts +591 -0
- package/dist/public/hyperframes.d.ts +774 -0
- package/dist/public/media.d.ts +708 -0
- package/dist/public/model-kit.d.ts +523 -0
- package/dist/public/narrative.d.ts +315 -0
- package/dist/public/program-space.d.ts +193 -0
- package/dist/public/runtime-kit.d.ts +427 -0
- package/dist/public/semantic-track.d.ts +418 -0
- package/dist/public/spatial.d.ts +1193 -0
- package/dist/public/speech.d.ts +391 -0
- package/dist/public/studio-adapter.d.ts +686 -0
- package/dist/public/svs.d.ts +311 -0
- package/dist/public/temporal-markup.d.ts +343 -0
- package/dist/public/temporal.d.ts +497 -0
- package/dist/public/text.d.ts +817 -0
- package/dist/public/visual-ir.d.ts +98 -0
- package/docs/public/hypit-logo-dark.svg +36 -0
- package/docs/public/hypit-logo-light.svg +38 -0
- package/examples/README.md +24 -0
- package/examples/minimal-author-package/README.md +18 -0
- package/examples/minimal-author-package/packages/example-component/README.md +44 -0
- package/examples/minimal-author-package/packages/example-component/package.json +27 -0
- package/examples/minimal-author-package/packages/example-component/preview/Box.png +0 -0
- package/examples/minimal-author-package/packages/example-component/preview/build.svrun +6 -0
- package/examples/minimal-author-package/packages/example-component/preview/preview.svml +47 -0
- package/examples/minimal-author-package/packages/example-component/preview/recipes.svs +8 -0
- package/examples/minimal-author-package/packages/example-component/src/activation.ts +10 -0
- package/examples/minimal-author-package/packages/example-component/src/component.ts +44 -0
- package/examples/minimal-author-package/packages/example-component/src/fragment.ts +32 -0
- package/examples/minimal-author-package/packages/example-component/src/index.ts +6 -0
- package/examples/minimal-author-package/packages/example-component/src/manifest.ts +82 -0
- package/examples/minimal-author-package/packages/example-component/src/style.ts +13 -0
- package/examples/minimal-author-package/packages/example-component/src/surface.ts +41 -0
- package/examples/minimal-author-package/packages/example-component/src/temporal.ts +6 -0
- package/examples/minimal-author-package/packages/example-component/tsconfig.json +18 -0
- package/examples/semantic-composition/README.md +35 -0
- package/examples/semantic-composition/chat.svml +25 -0
- package/examples/semantic-composition/chat.svrun +6 -0
- package/examples/semantic-composition/chat.svs +4 -0
- package/examples/semantic-composition/hypit.runtime.json +8 -0
- package/examples/semantic-composition/packages/chat-scene/README.md +29 -0
- package/examples/semantic-composition/packages/chat-scene/package.json +11 -0
- package/examples/semantic-composition/packages/chat-scene/src/activation.ts +112 -0
- package/examples/semantic-composition/packages/chat-scene/src/render.ts +64 -0
- package/examples/semantic-composition/packages/chat-scene/tsconfig.json +18 -0
- package/examples/semantic-composition/packages/responsive-explainer/README.md +45 -0
- package/examples/semantic-composition/packages/responsive-explainer/package.json +11 -0
- package/examples/semantic-composition/packages/responsive-explainer/src/activation.ts +90 -0
- package/examples/semantic-composition/packages/responsive-explainer/src/render.ts +68 -0
- package/examples/semantic-composition/packages/responsive-explainer/tsconfig.json +18 -0
- package/package.json +263 -5
- package/packages/artifact/README.md +10 -0
- package/packages/artifact/package.json +16 -0
- package/packages/artifact/src/activation.ts +8 -0
- package/packages/artifact/src/index.ts +24 -0
- package/packages/audio-track/README.md +43 -0
- package/packages/audio-track/package.json +36 -0
- package/packages/audio-track/src/activation.ts +20 -0
- package/packages/audio-track/src/component.ts +40 -0
- package/packages/audio-track/src/fragment.ts +63 -0
- package/packages/audio-track/src/index.ts +7 -0
- package/packages/audio-track/src/manifest.ts +151 -0
- package/packages/audio-track/src/program.ts +254 -0
- package/packages/audio-track/src/surface.ts +187 -0
- package/packages/audio-track/src/types.ts +62 -0
- package/packages/audio-track-studio/README.md +3 -0
- package/packages/audio-track-studio/package.json +14 -0
- package/packages/audio-track-studio/src/activation.ts +7 -0
- package/packages/audio-track-studio/src/index.ts +72 -0
- package/packages/author-kit/README.md +31 -0
- package/packages/author-kit/package.json +16 -0
- package/packages/author-kit/src/index.ts +59 -0
- package/packages/background-removal/README.md +29 -0
- package/packages/background-removal/package.json +16 -0
- package/packages/background-removal/src/activation.ts +18 -0
- package/packages/background-removal/src/component.ts +32 -0
- package/packages/background-removal/src/fragment.ts +18 -0
- package/packages/background-removal/src/index.ts +6 -0
- package/packages/background-removal/src/manifest.ts +45 -0
- package/packages/background-removal/src/program.ts +19 -0
- package/packages/background-removal/src/surface.ts +27 -0
- package/packages/background-removal/src/types.ts +5 -0
- package/packages/browser-capture/README.md +82 -0
- package/packages/browser-capture/package.json +15 -0
- package/packages/browser-capture/src/browser.ts +19 -0
- package/packages/browser-capture/src/index.ts +198 -0
- package/packages/build-result/package.json +13 -0
- package/packages/build-result/src/decode.ts +286 -0
- package/packages/build-result/src/index.ts +25 -0
- package/packages/build-result/src/store.ts +505 -0
- package/packages/build-result/src/types.ts +354 -0
- package/packages/build-result/src/writer.ts +184 -0
- package/packages/build-result-fs/README.md +29 -0
- package/packages/build-result-fs/package.json +17 -0
- package/packages/build-result-fs/src/activation.ts +62 -0
- package/packages/build-result-fs/src/index.ts +1 -0
- package/packages/build-result-kit/README.md +10 -0
- package/packages/build-result-kit/package.json +15 -0
- package/packages/build-result-kit/src/index.ts +144 -0
- package/packages/build-result-s3/README.md +49 -0
- package/packages/build-result-s3/package.json +19 -0
- package/packages/build-result-s3/src/activation.ts +71 -0
- package/packages/build-result-s3/src/client.ts +254 -0
- package/packages/build-result-s3/src/index.ts +4 -0
- package/packages/build-result-s3/src/repository.ts +361 -0
- package/packages/caption/README.md +77 -0
- package/packages/caption/package.json +28 -0
- package/packages/caption/src/activation.ts +17 -0
- package/packages/caption/src/component.ts +38 -0
- package/packages/caption/src/display.ts +111 -0
- package/packages/caption/src/error.ts +9 -0
- package/packages/caption/src/fragment.ts +26 -0
- package/packages/caption/src/index.ts +33 -0
- package/packages/caption/src/manifest.ts +97 -0
- package/packages/caption/src/style.ts +170 -0
- package/packages/caption/src/surface.ts +96 -0
- package/packages/caption/src/temporalize.ts +124 -0
- package/packages/caption/src/types.ts +71 -0
- package/packages/caption-fine/README.md +108 -0
- package/packages/caption-fine/package.json +30 -0
- package/packages/caption-fine/preview/Track.png +0 -0
- package/packages/caption-fine/src/activation.ts +32 -0
- package/packages/caption-fine/src/component.ts +58 -0
- package/packages/caption-fine/src/fragment.ts +112 -0
- package/packages/caption-fine/src/index.ts +19 -0
- package/packages/caption-fine/src/manifest.ts +383 -0
- package/packages/caption-fine/src/recipe.ts +120 -0
- package/packages/caption-fine/src/render.ts +1133 -0
- package/packages/caption-fine/src/schedule.ts +126 -0
- package/packages/caption-fine/src/spacing.ts +69 -0
- package/packages/caption-fine/src/style.ts +370 -0
- package/packages/caption-fine/src/surface.ts +152 -0
- package/packages/caption-fine/src/types.ts +191 -0
- package/packages/caption-fine-studio/README.md +3 -0
- package/packages/caption-fine-studio/package.json +15 -0
- package/packages/caption-fine-studio/src/activation.ts +7 -0
- package/packages/caption-fine-studio/src/index.ts +163 -0
- package/packages/cli/README.md +51 -0
- package/packages/cli/package.json +33 -0
- package/packages/cli/src/arguments.ts +605 -0
- package/packages/cli/src/build-planning.ts +460 -0
- package/packages/cli/src/command.ts +202 -0
- package/packages/cli/src/commands/environment.ts +391 -0
- package/packages/cli/src/commands/execution.ts +321 -0
- package/packages/cli/src/commands/results.ts +187 -0
- package/packages/cli/src/commands/types.ts +9 -0
- package/packages/cli/src/distribution.ts +74 -0
- package/packages/cli/src/index.ts +30 -0
- package/packages/cli/src/machine-view.ts +28 -0
- package/packages/cli/src/main.ts +654 -0
- package/packages/cli/src/oauth.ts +228 -0
- package/packages/cli/src/observation.ts +203 -0
- package/packages/cli/src/output.ts +1007 -0
- package/packages/cli/src/paths.ts +7 -0
- package/packages/cli/src/project-context.ts +38 -0
- package/packages/cli/src/reachability.ts +91 -0
- package/packages/cli/src/result-export.ts +148 -0
- package/packages/cli/src/result-query.ts +46 -0
- package/packages/cli/src/run-file.ts +186 -0
- package/packages/cli/src/runtime-port.ts +13 -0
- package/packages/cli/src/runtime-selection.ts +94 -0
- package/packages/cli/src/runtime-view.ts +15 -0
- package/packages/cli/src/source-discovery.ts +150 -0
- package/packages/cli/src/source-packages.ts +91 -0
- package/packages/cli/src/view.ts +228 -0
- package/packages/comment-sticker/README.md +41 -0
- package/packages/comment-sticker/package.json +29 -0
- package/packages/comment-sticker/preview/Track.png +0 -0
- package/packages/comment-sticker/src/activation.ts +32 -0
- package/packages/comment-sticker/src/author.ts +148 -0
- package/packages/comment-sticker/src/component.ts +97 -0
- package/packages/comment-sticker/src/fragment.ts +124 -0
- package/packages/comment-sticker/src/index.ts +8 -0
- package/packages/comment-sticker/src/manifest.ts +373 -0
- package/packages/comment-sticker/src/program.ts +610 -0
- package/packages/comment-sticker/src/surface.ts +172 -0
- package/packages/comment-sticker/src/types.ts +109 -0
- package/packages/comment-sticker-studio/README.md +3 -0
- package/packages/comment-sticker-studio/package.json +14 -0
- package/packages/comment-sticker-studio/src/activation.ts +7 -0
- package/packages/comment-sticker-studio/src/index.ts +132 -0
- package/packages/compiler-markup-node/README.md +12 -0
- package/packages/compiler-markup-node/package.json +22 -0
- package/packages/compiler-markup-node/src/index.ts +59 -0
- package/packages/compiler-node/README.md +60 -0
- package/packages/compiler-node/package.json +25 -0
- package/packages/compiler-node/src/compiler.ts +207 -0
- package/packages/compiler-node/src/error.ts +11 -0
- package/packages/compiler-node/src/graph-query.ts +51 -0
- package/packages/compiler-node/src/index.ts +27 -0
- package/packages/compiler-node/src/modules.ts +107 -0
- package/packages/compiler-node/src/run.ts +355 -0
- package/packages/component-kit/README.md +97 -0
- package/packages/component-kit/package.json +13 -0
- package/packages/component-kit/src/index.ts +155 -0
- package/packages/composition/README.md +53 -0
- package/packages/composition/package.json +29 -0
- package/packages/composition/src/activation.ts +3 -0
- package/packages/composition/src/component.ts +10 -0
- package/packages/composition/src/index.ts +18 -0
- package/packages/composition/src/manifest.ts +13 -0
- package/packages/composition/src/schema.ts +194 -0
- package/packages/composition/src/track.ts +1403 -0
- package/packages/core/README.md +22 -0
- package/packages/core/package.json +13 -0
- package/packages/core/src/error.ts +12 -0
- package/packages/core/src/graph.ts +341 -0
- package/packages/core/src/index.ts +32 -0
- package/packages/core/src/link.ts +240 -0
- package/packages/core/src/machine.ts +60 -0
- package/packages/core/src/plan.ts +504 -0
- package/packages/core/src/reducer.ts +428 -0
- package/packages/core/src/reference.ts +25 -0
- package/packages/core/src/slice.ts +108 -0
- package/packages/credential-store-env/README.md +11 -0
- package/packages/credential-store-env/package.json +17 -0
- package/packages/credential-store-env/src/activation.ts +25 -0
- package/packages/credential-store-env/src/index.ts +23 -0
- package/packages/credential-store-os/README.md +13 -0
- package/packages/credential-store-os/package.json +22 -0
- package/packages/credential-store-os/runtime/windows-credential.ps1 +59 -0
- package/packages/credential-store-os/src/activation.ts +32 -0
- package/packages/credential-store-os/src/index.ts +2 -0
- package/packages/credential-store-os/src/store.ts +196 -0
- package/packages/deck-track/README.md +52 -0
- package/packages/deck-track/package.json +35 -0
- package/packages/deck-track/preview/DepthStack.png +0 -0
- package/packages/deck-track/src/activation.ts +32 -0
- package/packages/deck-track/src/author.ts +217 -0
- package/packages/deck-track/src/component.ts +86 -0
- package/packages/deck-track/src/fragment.ts +148 -0
- package/packages/deck-track/src/index.ts +16 -0
- package/packages/deck-track/src/lower.ts +370 -0
- package/packages/deck-track/src/manifest.ts +438 -0
- package/packages/deck-track/src/program.ts +367 -0
- package/packages/deck-track/src/surface.ts +286 -0
- package/packages/deck-track/src/types.ts +119 -0
- package/packages/deck-track-studio/README.md +3 -0
- package/packages/deck-track-studio/package.json +14 -0
- package/packages/deck-track-studio/src/activation.ts +7 -0
- package/packages/deck-track-studio/src/index.ts +134 -0
- package/packages/driver-node/README.md +23 -0
- package/packages/driver-node/package.json +18 -0
- package/packages/driver-node/src/driver.ts +616 -0
- package/packages/driver-node/src/index.ts +10 -0
- package/packages/driver-node/src/planning.ts +67 -0
- package/packages/driver-node/src/registry.ts +234 -0
- package/packages/driver-node/src/resources.ts +36 -0
- package/packages/driver-node/src/types.ts +69 -0
- package/packages/elaborator/README.md +74 -0
- package/packages/elaborator/package.json +16 -0
- package/packages/elaborator/src/author.ts +308 -0
- package/packages/elaborator/src/fragment.ts +505 -0
- package/packages/elaborator/src/frontend-facet.ts +30 -0
- package/packages/elaborator/src/index.ts +78 -0
- package/packages/elaborator/src/source.ts +608 -0
- package/packages/endpoint-kit/README.md +111 -0
- package/packages/endpoint-kit/package.json +14 -0
- package/packages/endpoint-kit/src/index.ts +488 -0
- package/packages/estimate/README.md +32 -0
- package/packages/estimate/package.json +20 -0
- package/packages/estimate/src/activation.ts +11 -0
- package/packages/estimate/src/index.ts +16 -0
- package/packages/estimate/src/manifest.ts +34 -0
- package/packages/estimate/src/policy.ts +70 -0
- package/packages/estimate/src/program.ts +196 -0
- package/packages/estimate/src/types.ts +15 -0
- package/packages/film/README.md +49 -0
- package/packages/film/package.json +34 -0
- package/packages/film/src/activation.ts +16 -0
- package/packages/film/src/component.ts +61 -0
- package/packages/film/src/fragment.ts +83 -0
- package/packages/film/src/index.ts +11 -0
- package/packages/film/src/manifest.ts +152 -0
- package/packages/film/src/program.ts +110 -0
- package/packages/film/src/recipe.ts +24 -0
- package/packages/film/src/surface.ts +146 -0
- package/packages/film/src/types.ts +26 -0
- package/packages/film-studio/package.json +16 -0
- package/packages/film-studio/src/activation.ts +8 -0
- package/packages/film-studio/src/index.ts +17 -0
- package/packages/fonts-open/README.md +77 -0
- package/packages/fonts-open/package.json +130 -0
- package/packages/fonts-open/src/activation.ts +30 -0
- package/packages/fonts-open/src/catalog.ts +317 -0
- package/packages/fonts-open/src/index.ts +13 -0
- package/packages/fonts-open/src/manifest.ts +83 -0
- package/packages/fonts-open/src/surface.ts +239 -0
- package/packages/generation/README.md +19 -0
- package/packages/generation/package.json +23 -0
- package/packages/generation/src/activation.ts +9 -0
- package/packages/generation/src/component.ts +77 -0
- package/packages/generation/src/identity.ts +80 -0
- package/packages/generation/src/index.ts +79 -0
- package/packages/generation/src/manifest.ts +65 -0
- package/packages/generation/src/mapping.ts +231 -0
- package/packages/generation/src/ports.ts +222 -0
- package/packages/generation/src/request.ts +427 -0
- package/packages/generation/src/schema.ts +62 -0
- package/packages/generation/src/types.ts +17 -0
- package/packages/gpt-image/README.md +54 -0
- package/packages/gpt-image/package.json +34 -0
- package/packages/gpt-image/src/activation.ts +39 -0
- package/packages/gpt-image/src/fragment.ts +101 -0
- package/packages/gpt-image/src/index.ts +203 -0
- package/packages/gpt-image/src/surface.ts +194 -0
- package/packages/gpt-image-kits/README.md +44 -0
- package/packages/gpt-image-kits/kits/phone-ugc-v1.svs +34 -0
- package/packages/gpt-image-kits/package.json +15 -0
- package/packages/grok-imagine/README.md +21 -0
- package/packages/grok-imagine/package.json +21 -0
- package/packages/grok-imagine/src/activation.ts +29 -0
- package/packages/grok-imagine/src/index.ts +174 -0
- package/packages/grok-imagine/src/surface.ts +149 -0
- package/packages/host/README.md +5 -0
- package/packages/host/package.json +10 -0
- package/packages/host/src/facet.ts +6 -0
- package/packages/host/src/frontend.ts +56 -0
- package/packages/host/src/index.ts +9 -0
- package/packages/hyperframes/README.md +69 -0
- package/packages/hyperframes/package.json +36 -0
- package/packages/hyperframes/src/activation.ts +8 -0
- package/packages/hyperframes/src/browser-program.ts +79 -0
- package/packages/hyperframes/src/component.ts +32 -0
- package/packages/hyperframes/src/document.ts +827 -0
- package/packages/hyperframes/src/fragment.ts +32 -0
- package/packages/hyperframes/src/index.ts +13 -0
- package/packages/hyperframes/src/manifest.ts +67 -0
- package/packages/hyperframes/src/project.ts +118 -0
- package/packages/hyperframes/src/text.ts +1179 -0
- package/packages/hyperframes/src/types.ts +38 -0
- package/packages/image-compose/README.md +25 -0
- package/packages/image-compose/package.json +18 -0
- package/packages/image-compose/src/activation.ts +21 -0
- package/packages/image-compose/src/component.ts +100 -0
- package/packages/image-compose/src/fragment.ts +54 -0
- package/packages/image-compose/src/index.ts +10 -0
- package/packages/image-compose/src/manifest.ts +119 -0
- package/packages/image-compose/src/program.ts +75 -0
- package/packages/image-compose/src/surface.ts +83 -0
- package/packages/image-compose/src/types.ts +22 -0
- package/packages/image-transform/README.md +29 -0
- package/packages/image-transform/package.json +21 -0
- package/packages/image-transform/src/activation.ts +33 -0
- package/packages/image-transform/src/component.ts +67 -0
- package/packages/image-transform/src/fragment.ts +25 -0
- package/packages/image-transform/src/index.ts +13 -0
- package/packages/image-transform/src/manifest.ts +209 -0
- package/packages/image-transform/src/program.ts +23 -0
- package/packages/image-transform/src/surface.ts +216 -0
- package/packages/image-transform/src/types.ts +20 -0
- package/packages/interview-emoji-reveal/README.md +39 -0
- package/packages/interview-emoji-reveal/package.json +23 -0
- package/packages/interview-emoji-reveal/preview/Track.png +0 -0
- package/packages/interview-emoji-reveal/src/activation.ts +14 -0
- package/packages/interview-emoji-reveal/src/component.ts +45 -0
- package/packages/interview-emoji-reveal/src/fragment.ts +62 -0
- package/packages/interview-emoji-reveal/src/index.ts +16 -0
- package/packages/interview-emoji-reveal/src/manifest.ts +174 -0
- package/packages/interview-emoji-reveal/src/program.ts +242 -0
- package/packages/interview-emoji-reveal/src/style.ts +47 -0
- package/packages/interview-emoji-reveal/src/surface.ts +110 -0
- package/packages/interview-emoji-reveal/src/types.ts +52 -0
- package/packages/markup/README.md +81 -0
- package/packages/markup/package.json +16 -0
- package/packages/markup/src/element.ts +39 -0
- package/packages/markup/src/error.ts +20 -0
- package/packages/markup/src/frontend.ts +518 -0
- package/packages/markup/src/host-facet.ts +115 -0
- package/packages/markup/src/index.ts +25 -0
- package/packages/markup/src/registry.ts +83 -0
- package/packages/markup/src/syntax.ts +271 -0
- package/packages/markup/src/types.ts +246 -0
- package/packages/media/README.md +37 -0
- package/packages/media/package.json +19 -0
- package/packages/media/src/activation.ts +38 -0
- package/packages/media/src/component.ts +16 -0
- package/packages/media/src/frame-range.ts +33 -0
- package/packages/media/src/identity.ts +227 -0
- package/packages/media/src/index.ts +15 -0
- package/packages/media/src/manifest.ts +122 -0
- package/packages/media/src/render.ts +140 -0
- package/packages/media/src/schema.ts +69 -0
- package/packages/media/src/surface.ts +150 -0
- package/packages/media/src/types.ts +121 -0
- package/packages/media-execution/README.md +28 -0
- package/packages/media-execution/package.json +17 -0
- package/packages/media-execution/src/execute.ts +1322 -0
- package/packages/media-execution/src/index.ts +16 -0
- package/packages/media-execution/src/probe.ts +315 -0
- package/packages/media-execution/src/surface.ts +286 -0
- package/packages/media-execution/src/toolchain.ts +81 -0
- package/packages/media-execution/src/webp.ts +200 -0
- package/packages/media-pipeline/README.md +113 -0
- package/packages/media-pipeline/package.json +27 -0
- package/packages/media-pipeline/src/activation.ts +47 -0
- package/packages/media-pipeline/src/audio-plan.ts +113 -0
- package/packages/media-pipeline/src/component.ts +373 -0
- package/packages/media-pipeline/src/fragment.ts +167 -0
- package/packages/media-pipeline/src/index.ts +46 -0
- package/packages/media-pipeline/src/manifest.ts +653 -0
- package/packages/media-pipeline/src/operations.ts +248 -0
- package/packages/media-pipeline/src/selection.ts +110 -0
- package/packages/media-pipeline/src/surface.ts +389 -0
- package/packages/media-pipeline/src/types.ts +175 -0
- package/packages/media-track/README.md +197 -0
- package/packages/media-track/package.json +29 -0
- package/packages/media-track/preview/Track.png +0 -0
- package/packages/media-track/preview/build.svrun +5 -0
- package/packages/media-track/preview/flush.png +0 -0
- package/packages/media-track/preview/preview.svml +47 -0
- package/packages/media-track/preview/recipes.svs +23 -0
- package/packages/media-track/preview/rounded.png +0 -0
- package/packages/media-track/src/activation.ts +20 -0
- package/packages/media-track/src/author.ts +317 -0
- package/packages/media-track/src/component.ts +162 -0
- package/packages/media-track/src/fragment.ts +57 -0
- package/packages/media-track/src/index.ts +65 -0
- package/packages/media-track/src/layers.ts +308 -0
- package/packages/media-track/src/lower.ts +335 -0
- package/packages/media-track/src/manifest.ts +624 -0
- package/packages/media-track/src/motion.ts +387 -0
- package/packages/media-track/src/performance.ts +37 -0
- package/packages/media-track/src/presentation.ts +35 -0
- package/packages/media-track/src/program.ts +565 -0
- package/packages/media-track/src/sampling.ts +118 -0
- package/packages/media-track/src/sequence.ts +403 -0
- package/packages/media-track/src/sounds.ts +71 -0
- package/packages/media-track/src/surface.ts +668 -0
- package/packages/media-track/src/types.ts +311 -0
- package/packages/media-track-studio/README.md +3 -0
- package/packages/media-track-studio/package.json +15 -0
- package/packages/media-track-studio/src/activation.ts +7 -0
- package/packages/media-track-studio/src/index.ts +235 -0
- package/packages/mimo-speech/README.md +33 -0
- package/packages/mimo-speech/package.json +21 -0
- package/packages/mimo-speech/src/activation.ts +32 -0
- package/packages/mimo-speech/src/fragment.ts +11 -0
- package/packages/mimo-speech/src/index.ts +160 -0
- package/packages/mimo-speech/src/surface.ts +193 -0
- package/packages/minimax-h3/README.md +21 -0
- package/packages/minimax-h3/package.json +21 -0
- package/packages/minimax-h3/src/activation.ts +14 -0
- package/packages/minimax-h3/src/index.ts +188 -0
- package/packages/minimax-h3/src/surface.ts +87 -0
- package/packages/model-kit/README.md +52 -0
- package/packages/model-kit/package.json +19 -0
- package/packages/model-kit/src/index.ts +728 -0
- package/packages/nano-banana/README.md +23 -0
- package/packages/nano-banana/package.json +21 -0
- package/packages/nano-banana/src/activation.ts +14 -0
- package/packages/nano-banana/src/index.ts +172 -0
- package/packages/nano-banana/src/surface.ts +120 -0
- package/packages/narrative/README.md +7 -0
- package/packages/narrative/package.json +17 -0
- package/packages/narrative/src/activation.ts +7 -0
- package/packages/narrative/src/component.ts +33 -0
- package/packages/narrative/src/identity.ts +131 -0
- package/packages/narrative/src/index.ts +11 -0
- package/packages/narrative/src/manifest.ts +30 -0
- package/packages/narrative/src/schema.ts +89 -0
- package/packages/narrative/src/types.ts +141 -0
- package/packages/package-loader-node/README.md +23 -0
- package/packages/package-loader-node/package.json +15 -0
- package/packages/package-loader-node/src/contribution.ts +97 -0
- package/packages/package-loader-node/src/distribution-resolution.ts +146 -0
- package/packages/package-loader-node/src/index.ts +27 -0
- package/packages/package-loader-node/src/loader.ts +301 -0
- package/packages/package-loader-node/src/location.ts +279 -0
- package/packages/package-loader-node/src/types.ts +60 -0
- package/packages/program-space/README.md +20 -0
- package/packages/program-space/package.json +17 -0
- package/packages/program-space/src/activation.ts +19 -0
- package/packages/program-space/src/index.ts +107 -0
- package/packages/program-space/src/surface.ts +55 -0
- package/packages/protocol/README.md +11 -0
- package/packages/protocol/package.json +10 -0
- package/packages/protocol/src/build-id.ts +52 -0
- package/packages/protocol/src/build.ts +265 -0
- package/packages/protocol/src/canonical.ts +37 -0
- package/packages/protocol/src/error.ts +11 -0
- package/packages/protocol/src/identity.ts +59 -0
- package/packages/protocol/src/index.ts +9 -0
- package/packages/protocol/src/module.ts +67 -0
- package/packages/protocol/src/value.ts +88 -0
- package/packages/provider-hyperframes-aws-lambda/README.md +30 -0
- package/packages/provider-hyperframes-aws-lambda/package.json +30 -0
- package/packages/provider-hyperframes-aws-lambda/src/activation.ts +97 -0
- package/packages/provider-hyperframes-aws-lambda/src/client.ts +114 -0
- package/packages/provider-hyperframes-aws-lambda/src/index.ts +21 -0
- package/packages/provider-hyperframes-aws-lambda/src/provider.ts +522 -0
- package/packages/provider-hyperframes-local/README.md +129 -0
- package/packages/provider-hyperframes-local/package.json +34 -0
- package/packages/provider-hyperframes-local/src/activation.ts +107 -0
- package/packages/provider-hyperframes-local/src/capture-process.ts +110 -0
- package/packages/provider-hyperframes-local/src/capture-worker.ts +17 -0
- package/packages/provider-hyperframes-local/src/capture.ts +184 -0
- package/packages/provider-hyperframes-local/src/index.ts +10 -0
- package/packages/provider-hyperframes-local/src/options.ts +19 -0
- package/packages/provider-hyperframes-local/src/output.ts +73 -0
- package/packages/provider-hyperframes-local/src/process.ts +83 -0
- package/packages/provider-hyperframes-local/src/program.ts +58 -0
- package/packages/provider-hyperframes-local/src/provider.ts +62 -0
- package/packages/provider-hyperframes-local/src/render.ts +114 -0
- package/packages/provider-hyperframes-local/src/sampling.ts +89 -0
- package/packages/provider-hypihub/README.md +143 -0
- package/packages/provider-hypihub/package.json +26 -0
- package/packages/provider-hypihub/src/activation.ts +91 -0
- package/packages/provider-hypihub/src/index.ts +2 -0
- package/packages/provider-hypihub/src/mapping.ts +145 -0
- package/packages/provider-hypihub/src/oauth.ts +113 -0
- package/packages/provider-hypihub/src/provider.ts +566 -0
- package/packages/provider-hypihub/src/routes.ts +134 -0
- package/packages/provider-hypihub/src/upload.ts +402 -0
- package/packages/provider-image-opencv-local/README.md +16 -0
- package/packages/provider-image-opencv-local/package.json +27 -0
- package/packages/provider-image-opencv-local/runtime/raster_execute.py +299 -0
- package/packages/provider-image-opencv-local/src/activation.ts +61 -0
- package/packages/provider-image-opencv-local/src/deployment.ts +68 -0
- package/packages/provider-image-opencv-local/src/index.ts +2 -0
- package/packages/provider-image-opencv-local/src/program.ts +60 -0
- package/packages/provider-image-opencv-local/src/provider.ts +155 -0
- package/packages/provider-kie/README.md +134 -0
- package/packages/provider-kie/package.json +43 -0
- package/packages/provider-kie/src/activation.ts +71 -0
- package/packages/provider-kie/src/index.ts +10 -0
- package/packages/provider-kie/src/mapping.ts +182 -0
- package/packages/provider-kie/src/provider.ts +657 -0
- package/packages/provider-kie/src/routes.ts +150 -0
- package/packages/provider-media-local/README.md +58 -0
- package/packages/provider-media-local/package.json +28 -0
- package/packages/provider-media-local/src/activation.ts +65 -0
- package/packages/provider-media-local/src/index.ts +2 -0
- package/packages/provider-media-local/src/program.ts +19 -0
- package/packages/provider-media-local/src/provider.ts +150 -0
- package/packages/provider-whisperx-local/README.md +44 -0
- package/packages/provider-whisperx-local/package.json +27 -0
- package/packages/provider-whisperx-local/src/activation.ts +93 -0
- package/packages/provider-whisperx-local/src/index.ts +5 -0
- package/packages/provider-whisperx-local/src/program.ts +157 -0
- package/packages/provider-whisperx-local/src/provider.ts +191 -0
- package/packages/provider-xiaomi-mimo/README.md +32 -0
- package/packages/provider-xiaomi-mimo/package.json +24 -0
- package/packages/provider-xiaomi-mimo/src/activation.ts +57 -0
- package/packages/provider-xiaomi-mimo/src/index.ts +5 -0
- package/packages/provider-xiaomi-mimo/src/provider.ts +214 -0
- package/packages/ranking/README.md +67 -0
- package/packages/ranking/package.json +33 -0
- package/packages/ranking/preview/Column.svg +29 -0
- package/packages/ranking/preview/TierBoard.png +0 -0
- package/packages/ranking/preview/TierBoard.svg +36 -0
- package/packages/ranking/preview/TopThree.png +0 -0
- package/packages/ranking/src/activation.ts +38 -0
- package/packages/ranking/src/component.ts +271 -0
- package/packages/ranking/src/fragment.ts +206 -0
- package/packages/ranking/src/index.ts +26 -0
- package/packages/ranking/src/manifest.ts +807 -0
- package/packages/ranking/src/render.ts +698 -0
- package/packages/ranking/src/schedule.ts +895 -0
- package/packages/ranking/src/style.ts +272 -0
- package/packages/ranking/src/surface.ts +322 -0
- package/packages/ranking/src/tier.ts +176 -0
- package/packages/ranking/src/types.ts +277 -0
- package/packages/ranking-studio/README.md +3 -0
- package/packages/ranking-studio/package.json +14 -0
- package/packages/ranking-studio/src/activation.ts +7 -0
- package/packages/ranking-studio/src/index.ts +255 -0
- package/packages/raster/README.md +7 -0
- package/packages/raster/package.json +14 -0
- package/packages/raster/src/activation.ts +7 -0
- package/packages/raster/src/index.ts +7 -0
- package/packages/raster/src/manifest.ts +14 -0
- package/packages/raster/src/program.ts +128 -0
- package/packages/raster/src/schema.ts +53 -0
- package/packages/raster/src/types.ts +61 -0
- package/packages/render-hyperframes/README.md +58 -0
- package/packages/render-hyperframes/package.json +33 -0
- package/packages/render-hyperframes/src/activation.ts +18 -0
- package/packages/render-hyperframes/src/component.ts +37 -0
- package/packages/render-hyperframes/src/fragment.ts +73 -0
- package/packages/render-hyperframes/src/index.ts +6 -0
- package/packages/render-hyperframes/src/manifest.ts +100 -0
- package/packages/render-hyperframes/src/product.ts +29 -0
- package/packages/render-hyperframes/src/surface.ts +65 -0
- package/packages/resource-store-fs/README.md +13 -0
- package/packages/resource-store-fs/package.json +14 -0
- package/packages/resource-store-fs/src/index.ts +2 -0
- package/packages/resource-store-fs/src/store.ts +154 -0
- package/packages/resource-store-s3/README.md +15 -0
- package/packages/resource-store-s3/package.json +15 -0
- package/packages/resource-store-s3/src/client.ts +138 -0
- package/packages/resource-store-s3/src/index.ts +10 -0
- package/packages/resource-store-s3/src/store.ts +258 -0
- package/packages/run/README.md +23 -0
- package/packages/run/package.json +16 -0
- package/packages/run/src/candidate.ts +33 -0
- package/packages/run/src/facet.ts +59 -0
- package/packages/run/src/frontend-facet.ts +23 -0
- package/packages/run/src/frontend.ts +62 -0
- package/packages/run/src/graph.ts +65 -0
- package/packages/run/src/index.ts +33 -0
- package/packages/run/src/registry.ts +24 -0
- package/packages/run/src/resolve.ts +213 -0
- package/packages/run/src/types.ts +147 -0
- package/packages/run-markup/README.md +60 -0
- package/packages/run-markup/package.json +22 -0
- package/packages/run-markup/src/activation.ts +10 -0
- package/packages/run-markup/src/frontend.ts +16 -0
- package/packages/run-markup/src/index.ts +5 -0
- package/packages/run-markup/src/syntax.ts +304 -0
- package/packages/runtime/README.md +39 -0
- package/packages/runtime/package.json +15 -0
- package/packages/runtime/src/capacity.ts +51 -0
- package/packages/runtime/src/catalog.ts +30 -0
- package/packages/runtime/src/credentials.ts +124 -0
- package/packages/runtime/src/environment.ts +6 -0
- package/packages/runtime/src/execution.ts +125 -0
- package/packages/runtime/src/index.ts +24 -0
- package/packages/runtime/src/operations.ts +99 -0
- package/packages/runtime/src/scheduler.ts +281 -0
- package/packages/runtime/src/submission.ts +24 -0
- package/packages/runtime/src/types.ts +157 -0
- package/packages/runtime-host-node/README.md +25 -0
- package/packages/runtime-host-node/package.json +19 -0
- package/packages/runtime-host-node/src/index.ts +421 -0
- package/packages/runtime-host-node/src/packages.ts +158 -0
- package/packages/runtime-kit/README.md +42 -0
- package/packages/runtime-kit/package.json +16 -0
- package/packages/runtime-kit/src/index.ts +307 -0
- package/packages/runtime-kit/src/request-deadline.ts +17 -0
- package/packages/runtime-local/README.md +119 -0
- package/packages/runtime-local/package.json +33 -0
- package/packages/runtime-local/src/actions.ts +20 -0
- package/packages/runtime-local/src/config.ts +1229 -0
- package/packages/runtime-local/src/control.ts +120 -0
- package/packages/runtime-local/src/credentials.ts +61 -0
- package/packages/runtime-local/src/host.ts +174 -0
- package/packages/runtime-local/src/index.ts +36 -0
- package/packages/runtime-local/src/process-control.ts +59 -0
- package/packages/runtime-local/src/process-logs.ts +33 -0
- package/packages/runtime-local/src/programs.ts +441 -0
- package/packages/runtime-local/src/result-writer.ts +246 -0
- package/packages/runtime-local/src/runtime.ts +342 -0
- package/packages/runtime-local/src/types.ts +100 -0
- package/packages/runtime-local/src/worker-process.ts +343 -0
- package/packages/runtime-local/src/worker.ts +449 -0
- package/packages/screen-overlay/README.md +17 -0
- package/packages/screen-overlay/package.json +31 -0
- package/packages/screen-overlay/preview/Track.png +0 -0
- package/packages/screen-overlay/src/activation.ts +15 -0
- package/packages/screen-overlay/src/component.ts +20 -0
- package/packages/screen-overlay/src/fragment.ts +40 -0
- package/packages/screen-overlay/src/index.ts +7 -0
- package/packages/screen-overlay/src/manifest.ts +305 -0
- package/packages/screen-overlay/src/program.ts +321 -0
- package/packages/screen-overlay/src/surface.ts +90 -0
- package/packages/screen-overlay/src/types.ts +69 -0
- package/packages/screen-overlay-studio/README.md +3 -0
- package/packages/screen-overlay-studio/package.json +14 -0
- package/packages/screen-overlay-studio/src/activation.ts +7 -0
- package/packages/screen-overlay-studio/src/index.ts +80 -0
- package/packages/script/README.md +137 -0
- package/packages/script/package.json +22 -0
- package/packages/script/src/activation.ts +20 -0
- package/packages/script/src/edit.ts +174 -0
- package/packages/script/src/error.ts +13 -0
- package/packages/script/src/format.ts +83 -0
- package/packages/script/src/index.ts +20 -0
- package/packages/script/src/lexical.ts +133 -0
- package/packages/script/src/manifest.ts +95 -0
- package/packages/script/src/narrative.ts +232 -0
- package/packages/script/src/parser.ts +850 -0
- package/packages/script/src/surface.ts +132 -0
- package/packages/script/src/types.ts +125 -0
- package/packages/script-studio/package.json +13 -0
- package/packages/script-studio/src/activation.ts +8 -0
- package/packages/script-studio/src/index.ts +61 -0
- package/packages/seedance/README.md +19 -0
- package/packages/seedance/package.json +22 -0
- package/packages/seedance/src/activation.ts +38 -0
- package/packages/seedance/src/fragment.ts +46 -0
- package/packages/seedance/src/index.ts +329 -0
- package/packages/seedance/src/surface.ts +355 -0
- package/packages/seedance-kits/README.md +153 -0
- package/packages/seedance-kits/kits/broll-v1.svs +52 -0
- package/packages/seedance-kits/kits/call-v1.svs +55 -0
- package/packages/seedance-kits/kits/camera-reference-v1.svs +9 -0
- package/packages/seedance-kits/kits/motion-reference-v1.svs +9 -0
- package/packages/seedance-kits/kits/podcast-v1.svs +55 -0
- package/packages/seedance-kits/kits/speaker-v1.svs +136 -0
- package/packages/seedance-kits/kits/street-interview-v1.svs +49 -0
- package/packages/seedance-kits/package.json +24 -0
- package/packages/seedream/README.md +21 -0
- package/packages/seedream/package.json +21 -0
- package/packages/seedream/src/activation.ts +12 -0
- package/packages/seedream/src/index.ts +162 -0
- package/packages/seedream/src/surface.ts +84 -0
- package/packages/semantic-take-adjust/package.json +21 -0
- package/packages/semantic-take-adjust/src/activation.ts +22 -0
- package/packages/semantic-take-adjust/src/component.ts +31 -0
- package/packages/semantic-take-adjust/src/fragment.ts +24 -0
- package/packages/semantic-take-adjust/src/index.ts +12 -0
- package/packages/semantic-take-adjust/src/manifest.ts +57 -0
- package/packages/semantic-take-adjust/src/program.ts +49 -0
- package/packages/semantic-take-adjust/src/surface.ts +96 -0
- package/packages/semantic-take-adjust/src/types.ts +9 -0
- package/packages/semantic-track/README.md +21 -0
- package/packages/semantic-track/package.json +22 -0
- package/packages/semantic-track/src/activation.ts +8 -0
- package/packages/semantic-track/src/component.ts +24 -0
- package/packages/semantic-track/src/identity.ts +58 -0
- package/packages/semantic-track/src/index.ts +6 -0
- package/packages/semantic-track/src/location.ts +81 -0
- package/packages/semantic-track/src/manifest.ts +38 -0
- package/packages/semantic-track/src/projection.ts +71 -0
- package/packages/semantic-track/src/types.ts +26 -0
- package/packages/source/README.md +13 -0
- package/packages/source/package.json +13 -0
- package/packages/source/src/header.ts +80 -0
- package/packages/source/src/index.ts +17 -0
- package/packages/source/src/unit.ts +38 -0
- package/packages/spatial/README.md +77 -0
- package/packages/spatial/package.json +24 -0
- package/packages/spatial/src/activation.ts +43 -0
- package/packages/spatial/src/author.ts +59 -0
- package/packages/spatial/src/component.ts +45 -0
- package/packages/spatial/src/fragment.ts +36 -0
- package/packages/spatial/src/geometry.ts +238 -0
- package/packages/spatial/src/index.ts +37 -0
- package/packages/spatial/src/manifest.ts +341 -0
- package/packages/spatial/src/region-timeline.ts +69 -0
- package/packages/spatial/src/schema.ts +47 -0
- package/packages/spatial/src/surface.ts +319 -0
- package/packages/spatial/src/types.ts +101 -0
- package/packages/speech/README.md +16 -0
- package/packages/speech/package.json +19 -0
- package/packages/speech/src/activation.ts +7 -0
- package/packages/speech/src/component.ts +43 -0
- package/packages/speech/src/identity.ts +73 -0
- package/packages/speech/src/index.ts +6 -0
- package/packages/speech/src/manifest.ts +30 -0
- package/packages/speech/src/materialize.ts +103 -0
- package/packages/speech/src/schema.ts +42 -0
- package/packages/speech/src/types.ts +54 -0
- package/packages/speech-alignment/README.md +29 -0
- package/packages/speech-alignment/package.json +25 -0
- package/packages/speech-alignment/src/activation.ts +8 -0
- package/packages/speech-alignment/src/align.ts +235 -0
- package/packages/speech-alignment/src/component.ts +37 -0
- package/packages/speech-alignment/src/error.ts +9 -0
- package/packages/speech-alignment/src/index.ts +7 -0
- package/packages/speech-alignment/src/local.ts +64 -0
- package/packages/speech-alignment/src/locate.ts +473 -0
- package/packages/speech-alignment/src/manifest.ts +37 -0
- package/packages/speech-alignment/src/normalize.ts +79 -0
- package/packages/speech-alignment/src/types.ts +30 -0
- package/packages/speech-evidence/README.md +3 -0
- package/packages/speech-evidence/package.json +16 -0
- package/packages/speech-evidence/src/activation.ts +3 -0
- package/packages/speech-evidence/src/index.ts +102 -0
- package/packages/speech-track/README.md +51 -0
- package/packages/speech-track/package.json +28 -0
- package/packages/speech-track/preview/Track.png +0 -0
- package/packages/speech-track/src/activation.ts +19 -0
- package/packages/speech-track/src/component.ts +45 -0
- package/packages/speech-track/src/fragment.ts +74 -0
- package/packages/speech-track/src/index.ts +7 -0
- package/packages/speech-track/src/manifest.ts +73 -0
- package/packages/speech-track/src/program.ts +64 -0
- package/packages/speech-track/src/surface.ts +35 -0
- package/packages/speech-track/src/types.ts +6 -0
- package/packages/speech-track-studio/README.md +3 -0
- package/packages/speech-track-studio/package.json +14 -0
- package/packages/speech-track-studio/src/activation.ts +7 -0
- package/packages/speech-track-studio/src/index.ts +40 -0
- package/packages/store-sqlite/README.md +14 -0
- package/packages/store-sqlite/package.json +18 -0
- package/packages/store-sqlite/src/index.ts +2 -0
- package/packages/store-sqlite/src/store.ts +1101 -0
- package/packages/studio/README.md +125 -0
- package/packages/studio/index.html +10 -0
- package/packages/studio/package.json +50 -0
- package/packages/studio/src/build-library.ts +281 -0
- package/packages/studio/src/companion-assembly.ts +39 -0
- package/packages/studio/src/compile.ts +166 -0
- package/packages/studio/src/domain.ts +139 -0
- package/packages/studio/src/execute.ts +57 -0
- package/packages/studio/src/fallback-companions.ts +98 -0
- package/packages/studio/src/observe.ts +202 -0
- package/packages/studio/src/parameter-values.ts +81 -0
- package/packages/studio/src/parameters.ts +550 -0
- package/packages/studio/src/preview/render.ts +51 -0
- package/packages/studio/src/preview/runtime-shim.ts +184 -0
- package/packages/studio/src/programme.ts +276 -0
- package/packages/studio/src/run.ts +85 -0
- package/packages/studio/src/server.ts +725 -0
- package/packages/studio/src/session.ts +111 -0
- package/packages/studio/src/shared.ts +315 -0
- package/packages/studio/src/snapshot.ts +454 -0
- package/packages/studio/src/source-transaction.ts +57 -0
- package/packages/studio/src/storyboard.ts +133 -0
- package/packages/studio/src/studio-preflight.ts +198 -0
- package/packages/studio/src/studio-registry.ts +406 -0
- package/packages/studio/src/studio-trace.ts +136 -0
- package/packages/studio/src/style.css +1525 -0
- package/packages/studio/src/surface-preview.ts +35 -0
- package/packages/studio/src/temporal-graph.ts +227 -0
- package/packages/studio/src/ui/code.ts +450 -0
- package/packages/studio/src/ui/icons.ts +51 -0
- package/packages/studio/src/ui/library.ts +378 -0
- package/packages/studio/src/ui/main.ts +1001 -0
- package/packages/studio/src/ui/markers.ts +152 -0
- package/packages/studio/src/ui/material-preview.ts +176 -0
- package/packages/studio/src/ui/overlay.ts +144 -0
- package/packages/studio/src/ui/resize.ts +74 -0
- package/packages/studio/src/ui/selection.ts +178 -0
- package/packages/studio/src/ui/stage.ts +231 -0
- package/packages/studio/src/ui/syntax.ts +195 -0
- package/packages/studio/src/ui/timeline.ts +1041 -0
- package/packages/studio/src/ui/writeback.ts +10 -0
- package/packages/studio/src/ui/zoom.ts +129 -0
- package/packages/studio/start.ts +143 -0
- package/packages/studio-adapter/README.md +186 -0
- package/packages/studio-adapter/package.json +14 -0
- package/packages/studio-adapter/src/index.ts +850 -0
- package/packages/svs/README.md +37 -0
- package/packages/svs/package.json +21 -0
- package/packages/svs/src/activation.ts +11 -0
- package/packages/svs/src/format.ts +16 -0
- package/packages/svs/src/frontend.ts +33 -0
- package/packages/svs/src/index.ts +5 -0
- package/packages/svs/src/manifest.ts +17 -0
- package/packages/svs/src/parser.ts +279 -0
- package/packages/svs/src/types.ts +26 -0
- package/packages/temporal/README.md +31 -0
- package/packages/temporal/package.json +20 -0
- package/packages/temporal/src/activation.ts +9 -0
- package/packages/temporal/src/component.ts +68 -0
- package/packages/temporal/src/index.ts +110 -0
- package/packages/temporal/src/location.ts +67 -0
- package/packages/temporal/src/projection.ts +280 -0
- package/packages/temporal/src/rational.ts +80 -0
- package/packages/temporal/src/sample.ts +43 -0
- package/packages/temporal/src/schedule.ts +52 -0
- package/packages/temporal/src/types.ts +124 -0
- package/packages/temporal-markup/README.md +75 -0
- package/packages/temporal-markup/package.json +18 -0
- package/packages/temporal-markup/src/index.ts +537 -0
- package/packages/temporal-markup/src/space.ts +59 -0
- package/packages/text/README.md +59 -0
- package/packages/text/package.json +21 -0
- package/packages/text/src/activation.ts +33 -0
- package/packages/text/src/component.ts +72 -0
- package/packages/text/src/fragment.ts +57 -0
- package/packages/text/src/frontend.ts +39 -0
- package/packages/text/src/index.ts +27 -0
- package/packages/text/src/manifest.ts +170 -0
- package/packages/text/src/program.ts +418 -0
- package/packages/text/src/surface.ts +212 -0
- package/packages/text/src/svs.ts +189 -0
- package/packages/text/src/types.ts +82 -0
- package/packages/transport-aws-lambda/README.md +20 -0
- package/packages/transport-aws-lambda/package.json +14 -0
- package/packages/transport-aws-lambda/src/index.ts +131 -0
- package/packages/typography-track/README.md +50 -0
- package/packages/typography-track/package.json +34 -0
- package/packages/typography-track/preview/Mask.png +0 -0
- package/packages/typography-track/preview/Track.png +0 -0
- package/packages/typography-track/src/activation.ts +36 -0
- package/packages/typography-track/src/component.ts +93 -0
- package/packages/typography-track/src/fragment.ts +30 -0
- package/packages/typography-track/src/index.ts +11 -0
- package/packages/typography-track/src/manifest.ts +556 -0
- package/packages/typography-track/src/program.ts +622 -0
- package/packages/typography-track/src/surface.ts +842 -0
- package/packages/typography-track/src/types.ts +109 -0
- package/packages/typography-track-studio/README.md +3 -0
- package/packages/typography-track-studio/package.json +14 -0
- package/packages/typography-track-studio/src/activation.ts +7 -0
- package/packages/typography-track-studio/src/index.ts +116 -0
- package/packages/validation/README.md +11 -0
- package/packages/validation/package.json +15 -0
- package/packages/validation/src/index.ts +100 -0
- package/packages/video-cli/README.md +181 -0
- package/packages/video-cli/package.json +37 -0
- package/packages/video-cli/src/capture.ts +174 -0
- package/packages/video-cli/src/cli.ts +109 -0
- package/packages/video-cli/src/compiler.ts +32 -0
- package/packages/video-cli/src/creation.ts +449 -0
- package/packages/video-cli/src/distribution.ts +88 -0
- package/packages/video-cli/src/index.ts +50 -0
- package/packages/video-cli/src/media.ts +701 -0
- package/packages/video-cli/src/package-selection.ts +34 -0
- package/packages/video-cli/src/process.ts +71 -0
- package/packages/video-cli/src/studio-distribution.ts +19 -0
- package/packages/video-cli/src/transcript.ts +71 -0
- package/packages/video-cli/src/vocabulary.ts +386 -0
- package/packages/visual-ir/README.md +36 -0
- package/packages/visual-ir/package.json +16 -0
- package/packages/visual-ir/src/activation.ts +3 -0
- package/packages/visual-ir/src/index.ts +7 -0
- package/packages/visual-ir/src/style.ts +222 -0
- package/packages/volcengine-matting/README.md +89 -0
- package/packages/volcengine-matting/package.json +16 -0
- package/packages/volcengine-matting/src/activation.ts +13 -0
- package/packages/volcengine-matting/src/index.ts +45 -0
- package/packages/volcengine-matting/src/surface.ts +48 -0
- package/packages/whisperx/README.md +34 -0
- package/packages/whisperx/package.json +28 -0
- package/packages/whisperx/src/activation.ts +18 -0
- package/packages/whisperx/src/component.ts +64 -0
- package/packages/whisperx/src/evidence.ts +69 -0
- package/packages/whisperx/src/fragment.ts +76 -0
- package/packages/whisperx/src/index.ts +14 -0
- package/packages/whisperx/src/manifest.ts +92 -0
- package/packages/whisperx/src/surface.ts +90 -0
- package/packages/whisperx/src/transcript.ts +97 -0
- package/packages/whisperx/src/types.ts +9 -0
- package/packages/workspace/README.md +4 -0
- package/packages/workspace/package.json +14 -0
- package/packages/workspace/src/index.ts +38 -0
- package/packages/workspace-fs-node/README.md +13 -0
- package/packages/workspace-fs-node/package.json +15 -0
- package/packages/workspace-fs-node/src/index.ts +6 -0
- package/packages/workspace-fs-node/src/workspace.ts +226 -0
- package/packages/yt-dlp/README.md +31 -0
- package/packages/yt-dlp/package.json +10 -0
- package/packages/yt-dlp/src/download.ts +104 -0
- package/packages/yt-dlp/src/index.ts +1 -0
- package/services/image-opencv/README.md +33 -0
- package/services/image-opencv/package.json +14 -0
- package/services/image-opencv/pyproject.toml +13 -0
- package/services/image-opencv/uv.lock +56 -0
- package/services/whisperx/README.md +82 -0
- package/services/whisperx/package.json +15 -0
- package/services/whisperx/pyproject.toml +26 -0
- package/services/whisperx/src/hypit_whisperx_service/__init__.py +6 -0
- package/services/whisperx/src/hypit_whisperx_service/__main__.py +29 -0
- package/services/whisperx/src/hypit_whisperx_service/application.py +88 -0
- package/services/whisperx/src/hypit_whisperx_service/audio.py +66 -0
- package/services/whisperx/src/hypit_whisperx_service/check.py +35 -0
- package/services/whisperx/src/hypit_whisperx_service/config.py +81 -0
- package/services/whisperx/src/hypit_whisperx_service/engine.py +173 -0
- package/services/whisperx/src/hypit_whisperx_service/prepare.py +19 -0
- package/services/whisperx/src/hypit_whisperx_service/resources.py +41 -0
- package/services/whisperx/src/hypit_whisperx_service/server.py +101 -0
- package/services/whisperx/uv.lock +3381 -0
- package/services/yt-dlp/README.md +19 -0
- package/services/yt-dlp/package.json +14 -0
- package/services/yt-dlp/pyproject.toml +13 -0
- package/services/yt-dlp/uv.lock +23 -0
- package/index.js +0 -1
|
@@ -0,0 +1,1101 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { DatabaseSync } from "node:sqlite";
|
|
4
|
+
|
|
5
|
+
import { materializeBuild } from "@hypit/core";
|
|
6
|
+
import type {
|
|
7
|
+
BuildDefinition,
|
|
8
|
+
BuildFact,
|
|
9
|
+
CommandResult,
|
|
10
|
+
} from "@hypit/protocol";
|
|
11
|
+
import { assertBuildId } from "@hypit/protocol";
|
|
12
|
+
import { capacityUnits } from "@hypit/runtime";
|
|
13
|
+
import type {
|
|
14
|
+
PendingBuildCommit,
|
|
15
|
+
PendingBuildSubmission,
|
|
16
|
+
PendingBuildStore,
|
|
17
|
+
BuildExecutionRequest,
|
|
18
|
+
BuildExecutionSnapshot,
|
|
19
|
+
BuildExecutionStop,
|
|
20
|
+
BuildExecutionStore,
|
|
21
|
+
BuildCatalog,
|
|
22
|
+
BuildCatalogDescriptor,
|
|
23
|
+
BuildCatalogEntry,
|
|
24
|
+
BuildSnapshot,
|
|
25
|
+
BuildStore,
|
|
26
|
+
CapacityAcquire,
|
|
27
|
+
CapacityResourceClaim,
|
|
28
|
+
CapacityAcquireRequest,
|
|
29
|
+
CapacityReservation,
|
|
30
|
+
CommandExecutionBegin,
|
|
31
|
+
CommandExecutionReceipt,
|
|
32
|
+
CommandExecutionStore,
|
|
33
|
+
OperationIdentity,
|
|
34
|
+
OperationQuery,
|
|
35
|
+
OperationSnapshot,
|
|
36
|
+
OperationStore,
|
|
37
|
+
OperationUpdate,
|
|
38
|
+
RuntimeEnvironmentStore,
|
|
39
|
+
} from "@hypit/runtime";
|
|
40
|
+
|
|
41
|
+
export type SqliteRuntimeStateOptions = {
|
|
42
|
+
readonly busyTimeoutMs?: number;
|
|
43
|
+
/** Open an existing Runtime database without creating files or schema. */
|
|
44
|
+
readonly readOnly?: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type Row = Record<string, unknown>;
|
|
48
|
+
|
|
49
|
+
function assert(condition: unknown, message: string): asserts condition {
|
|
50
|
+
if (!condition) throw new Error(message);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function positiveInteger(value: number, subject: string): number {
|
|
54
|
+
assert(Number.isSafeInteger(value) && value > 0, `${subject} must be a positive safe integer`);
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function nonNegativeInteger(value: number, subject: string): number {
|
|
59
|
+
assert(Number.isSafeInteger(value) && value >= 0, `${subject} must be a non-negative safe integer`);
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function transaction<T>(database: DatabaseSync, body: () => T): T {
|
|
64
|
+
database.exec("BEGIN IMMEDIATE");
|
|
65
|
+
try {
|
|
66
|
+
const result = body();
|
|
67
|
+
database.exec("COMMIT");
|
|
68
|
+
return result;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
database.exec("ROLLBACK");
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function parseBuildSnapshot(row: Row, factRows: readonly Row[]): BuildSnapshot {
|
|
76
|
+
assert(typeof row.build_id === "string", "SQLite Build row has no build id");
|
|
77
|
+
assert(typeof row.definition_json === "string", "SQLite Build row has no Definition");
|
|
78
|
+
const definition = JSON.parse(row.definition_json) as BuildDefinition;
|
|
79
|
+
const facts = factRows.map((factRow) => {
|
|
80
|
+
assert(typeof factRow.fact_json === "string", "SQLite Build Fact row has no Fact");
|
|
81
|
+
return JSON.parse(factRow.fact_json) as BuildFact;
|
|
82
|
+
});
|
|
83
|
+
const state = materializeBuild(definition, facts);
|
|
84
|
+
return { build: row.build_id, definition, facts, state };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function operationIdentityFrom(snapshot: OperationSnapshot): OperationIdentity {
|
|
88
|
+
return {
|
|
89
|
+
id: snapshot.id,
|
|
90
|
+
build: snapshot.build,
|
|
91
|
+
command: snapshot.command,
|
|
92
|
+
endpoint: snapshot.endpoint,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function parseOperationSnapshot(row: Row): OperationSnapshot {
|
|
97
|
+
for (const field of ["operation_id", "build_id", "command_id", "endpoint_id"] as const) {
|
|
98
|
+
assert(typeof row[field] === "string", `SQLite Operation row has no ${field}`);
|
|
99
|
+
}
|
|
100
|
+
assert(typeof row.status === "string", "SQLite Operation row has no status");
|
|
101
|
+
const payload = typeof row.payload_json === "string" ? JSON.parse(row.payload_json) as unknown : undefined;
|
|
102
|
+
return {
|
|
103
|
+
id: row.operation_id, build: row.build_id, command: row.command_id,
|
|
104
|
+
endpoint: row.endpoint_id, status: row.status,
|
|
105
|
+
...(payload as object ?? {}),
|
|
106
|
+
} as OperationSnapshot;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function operationPayload(operation: OperationSnapshot): string {
|
|
110
|
+
const { id: _id, build: _build, command: _command, endpoint: _endpoint, status: _status, ...facts } = operation;
|
|
111
|
+
return JSON.stringify(facts);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function copy<T>(value: T): T {
|
|
115
|
+
return structuredClone(value);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
class SqliteBuildStore implements BuildStore {
|
|
119
|
+
readonly #database: DatabaseSync;
|
|
120
|
+
|
|
121
|
+
constructor(database: DatabaseSync) {
|
|
122
|
+
this.#database = database;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
#facts(build: string): Row[] {
|
|
126
|
+
return this.#database.prepare(`
|
|
127
|
+
SELECT fact_json
|
|
128
|
+
FROM hypit_build_facts
|
|
129
|
+
WHERE build_id = ?
|
|
130
|
+
ORDER BY sequence ASC
|
|
131
|
+
`).all(build) as Row[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async create(build: string, definition: BuildDefinition): Promise<BuildSnapshot> {
|
|
135
|
+
assertBuildId(build);
|
|
136
|
+
const result = this.#database.prepare(`
|
|
137
|
+
INSERT OR IGNORE INTO hypit_builds (build_id, definition_json)
|
|
138
|
+
VALUES (?, ?)
|
|
139
|
+
`).run(build, JSON.stringify(definition));
|
|
140
|
+
if (result.changes !== 1) throw new Error(`build ${build} already exists`);
|
|
141
|
+
const storedDefinition = copy(definition);
|
|
142
|
+
const facts: readonly BuildFact[] = [];
|
|
143
|
+
const state = materializeBuild(storedDefinition, facts);
|
|
144
|
+
return { build, definition: storedDefinition, facts, state };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async read(build: string): Promise<BuildSnapshot | undefined> {
|
|
148
|
+
const row = this.#database.prepare(`
|
|
149
|
+
SELECT build_id, definition_json
|
|
150
|
+
FROM hypit_builds
|
|
151
|
+
WHERE build_id = ?
|
|
152
|
+
`).get(build) as Row | undefined;
|
|
153
|
+
return row === undefined ? undefined : parseBuildSnapshot(row, this.#facts(build));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async append(build: string, fact: BuildFact): Promise<void> {
|
|
157
|
+
const result = this.#database.prepare(`
|
|
158
|
+
INSERT INTO hypit_build_facts (
|
|
159
|
+
build_id, command_id, fact_json
|
|
160
|
+
) VALUES (?, ?, ?)
|
|
161
|
+
`).run(build, fact.command, JSON.stringify(fact));
|
|
162
|
+
if (result.changes !== 1) throw new Error(`Build ${build} Fact was not stored`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async remove(build: string): Promise<void> {
|
|
166
|
+
transaction(this.#database, () => {
|
|
167
|
+
this.#database.prepare("DELETE FROM hypit_build_facts WHERE build_id = ?").run(build);
|
|
168
|
+
this.#database.prepare("DELETE FROM hypit_builds WHERE build_id = ?").run(build);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function parseCatalogEntry(row: Row): BuildCatalogEntry {
|
|
174
|
+
assert(typeof row.build_id === "string", "SQLite Build Catalog row has no build id");
|
|
175
|
+
assert(typeof row.descriptor_json === "string", "SQLite Build Catalog row has no descriptor");
|
|
176
|
+
const descriptor = JSON.parse(row.descriptor_json) as BuildCatalogDescriptor;
|
|
177
|
+
return {
|
|
178
|
+
...descriptor,
|
|
179
|
+
build: row.build_id,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
class SqliteBuildCatalog implements BuildCatalog {
|
|
184
|
+
readonly #database: DatabaseSync;
|
|
185
|
+
|
|
186
|
+
constructor(database: DatabaseSync) {
|
|
187
|
+
this.#database = database;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async record(build: string, descriptor: BuildCatalogDescriptor): Promise<BuildCatalogEntry> {
|
|
191
|
+
assertBuildId(build);
|
|
192
|
+
const now = Date.now();
|
|
193
|
+
this.#database.prepare(`
|
|
194
|
+
INSERT INTO hypit_build_catalog (
|
|
195
|
+
build_id, created_at, descriptor_json
|
|
196
|
+
) VALUES (?, ?, ?)
|
|
197
|
+
`).run(build, now, JSON.stringify(descriptor));
|
|
198
|
+
return { ...copy(descriptor), build };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async read(build: string): Promise<BuildCatalogEntry | undefined> {
|
|
202
|
+
const row = this.#database.prepare(`
|
|
203
|
+
SELECT build_id, created_at, descriptor_json
|
|
204
|
+
FROM hypit_build_catalog
|
|
205
|
+
WHERE build_id = ?
|
|
206
|
+
`).get(build) as Row | undefined;
|
|
207
|
+
return row === undefined ? undefined : parseCatalogEntry(row);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async remove(build: string): Promise<void> {
|
|
211
|
+
this.#database.prepare("DELETE FROM hypit_build_catalog WHERE build_id = ?").run(build);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function parseExecutionRequest(row: Row, subject: string): BuildExecutionRequest {
|
|
216
|
+
assert(typeof row.build_id === "string", `SQLite ${subject} row has no Build id`);
|
|
217
|
+
assert(typeof row.component_packages_json === "string", `SQLite ${subject} row has no component packages`);
|
|
218
|
+
assert(typeof row.result_location_json === "string", `SQLite ${subject} row has no Result location`);
|
|
219
|
+
const componentPackages = JSON.parse(row.component_packages_json) as unknown;
|
|
220
|
+
assert(Array.isArray(componentPackages) && componentPackages.every((item) => typeof item === "string"),
|
|
221
|
+
`SQLite ${subject} component packages are invalid`);
|
|
222
|
+
const result = JSON.parse(row.result_location_json) as Partial<BuildExecutionRequest["result"]>;
|
|
223
|
+
assert(typeof result.root === "string" && typeof result.selection?.use === "string",
|
|
224
|
+
`SQLite ${subject} Result location is invalid`);
|
|
225
|
+
return {
|
|
226
|
+
build: row.build_id,
|
|
227
|
+
componentPackages,
|
|
228
|
+
result: result as BuildExecutionRequest["result"],
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function parsePendingBuildSubmission(row: Row): PendingBuildSubmission {
|
|
233
|
+
assert(typeof row.created_at === "number", "SQLite pending-submission creation time is invalid");
|
|
234
|
+
return { ...parseExecutionRequest(row, "pending submission"), createdAt: row.created_at };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
class SqlitePendingBuildStore implements PendingBuildStore {
|
|
238
|
+
readonly #database: DatabaseSync;
|
|
239
|
+
|
|
240
|
+
constructor(database: DatabaseSync) {
|
|
241
|
+
this.#database = database;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
async prepare(
|
|
245
|
+
request: BuildExecutionRequest,
|
|
246
|
+
options: { readonly now?: number } = {},
|
|
247
|
+
): Promise<PendingBuildSubmission> {
|
|
248
|
+
assertBuildId(request.build);
|
|
249
|
+
const now = options.now ?? Date.now();
|
|
250
|
+
nonNegativeInteger(now, "Build submission preparation time");
|
|
251
|
+
return transaction(this.#database, () => {
|
|
252
|
+
const occupied = this.#database.prepare(`
|
|
253
|
+
SELECT 1 AS occupied FROM hypit_submissions WHERE build_id = ?
|
|
254
|
+
UNION ALL SELECT 1 FROM hypit_executions WHERE build_id = ?
|
|
255
|
+
UNION ALL SELECT 1 FROM hypit_builds WHERE build_id = ?
|
|
256
|
+
UNION ALL SELECT 1 FROM hypit_build_catalog WHERE build_id = ?
|
|
257
|
+
UNION ALL SELECT 1 FROM hypit_operations WHERE build_id = ?
|
|
258
|
+
UNION ALL SELECT 1 FROM hypit_command_executions WHERE build_id = ?
|
|
259
|
+
UNION ALL SELECT 1 FROM hypit_build_facts WHERE build_id = ?
|
|
260
|
+
UNION ALL SELECT 1 FROM hypit_capacity WHERE build_id = ?
|
|
261
|
+
LIMIT 1
|
|
262
|
+
`).get(request.build, request.build, request.build, request.build, request.build, request.build, request.build, request.build);
|
|
263
|
+
assert(occupied === undefined, `Build ${request.build} already has Runtime state`);
|
|
264
|
+
this.#database.prepare(`
|
|
265
|
+
INSERT INTO hypit_submissions (
|
|
266
|
+
build_id, component_packages_json, result_location_json, created_at
|
|
267
|
+
) VALUES (?, ?, ?, ?)
|
|
268
|
+
`).run(
|
|
269
|
+
request.build,
|
|
270
|
+
JSON.stringify(request.componentPackages),
|
|
271
|
+
JSON.stringify(request.result),
|
|
272
|
+
now,
|
|
273
|
+
);
|
|
274
|
+
return parsePendingBuildSubmission(
|
|
275
|
+
this.#database.prepare("SELECT * FROM hypit_submissions WHERE build_id = ?").get(request.build) as Row,
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async read(build: string): Promise<PendingBuildSubmission | undefined> {
|
|
281
|
+
const row = this.#database.prepare("SELECT * FROM hypit_submissions WHERE build_id = ?").get(build) as Row | undefined;
|
|
282
|
+
return row === undefined ? undefined : parsePendingBuildSubmission(row);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async list(): Promise<readonly PendingBuildSubmission[]> {
|
|
286
|
+
return (this.#database.prepare(
|
|
287
|
+
"SELECT * FROM hypit_submissions ORDER BY created_at ASC, build_id ASC",
|
|
288
|
+
).all() as Row[]).map(parsePendingBuildSubmission);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
async commit(request: PendingBuildCommit): Promise<BuildExecutionSnapshot> {
|
|
292
|
+
assertBuildId(request.build);
|
|
293
|
+
return transaction(this.#database, () => {
|
|
294
|
+
const row = this.#database.prepare("SELECT * FROM hypit_submissions WHERE build_id = ?").get(request.build) as Row | undefined;
|
|
295
|
+
if (row === undefined) throw new Error(`Build submission ${request.build} was not prepared`);
|
|
296
|
+
const submission = parsePendingBuildSubmission(row);
|
|
297
|
+
assert(JSON.stringify(submission.componentPackages) === JSON.stringify(request.componentPackages)
|
|
298
|
+
&& JSON.stringify(submission.result) === JSON.stringify(request.result),
|
|
299
|
+
`Build submission ${request.build} does not match its prepared state`);
|
|
300
|
+
this.#database.prepare(`
|
|
301
|
+
INSERT INTO hypit_builds (build_id, definition_json) VALUES (?, ?)
|
|
302
|
+
`).run(request.build, JSON.stringify(request.definition));
|
|
303
|
+
this.#database.prepare(`
|
|
304
|
+
INSERT INTO hypit_build_catalog (build_id, created_at, descriptor_json) VALUES (?, ?, ?)
|
|
305
|
+
`).run(request.build, Date.now(), JSON.stringify(request.catalog));
|
|
306
|
+
this.#database.prepare(`
|
|
307
|
+
INSERT INTO hypit_executions (
|
|
308
|
+
build_id, component_packages_json, result_location_json, created_at, wake_at,
|
|
309
|
+
turn_owner, turn_acquired_at, result_writer_owner, result_writer_acquired_at,
|
|
310
|
+
stop_cause, stop_reason,
|
|
311
|
+
decision_outcome, decision_reason, attention_step, attention_error
|
|
312
|
+
) VALUES (?, ?, ?, ?, ?, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
|
|
313
|
+
`).run(
|
|
314
|
+
request.build,
|
|
315
|
+
JSON.stringify(request.componentPackages),
|
|
316
|
+
JSON.stringify(request.result),
|
|
317
|
+
submission.createdAt,
|
|
318
|
+
Date.now(),
|
|
319
|
+
);
|
|
320
|
+
this.#database.prepare("DELETE FROM hypit_submissions WHERE build_id = ?").run(request.build);
|
|
321
|
+
return parseExecutionSnapshot(
|
|
322
|
+
this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(request.build) as Row,
|
|
323
|
+
);
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async discard(build: string): Promise<void> {
|
|
328
|
+
assertBuildId(build);
|
|
329
|
+
transaction(this.#database, () => {
|
|
330
|
+
const row = this.#database.prepare("SELECT build_id FROM hypit_submissions WHERE build_id = ?").get(build) as Row | undefined;
|
|
331
|
+
if (row === undefined) return;
|
|
332
|
+
this.#database.prepare("DELETE FROM hypit_submissions WHERE build_id = ?").run(build);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
class SqliteOperationStore implements OperationStore {
|
|
338
|
+
readonly #database: DatabaseSync;
|
|
339
|
+
|
|
340
|
+
constructor(database: DatabaseSync) {
|
|
341
|
+
this.#database = database;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
async create(operation: OperationSnapshot): Promise<OperationSnapshot> {
|
|
345
|
+
const identity = operationIdentityFrom(operation);
|
|
346
|
+
const payload = operationPayload(operation);
|
|
347
|
+
const result = this.#database.prepare(`
|
|
348
|
+
INSERT INTO hypit_operations (
|
|
349
|
+
operation_id, build_id, command_id, endpoint_id, status,
|
|
350
|
+
payload_json
|
|
351
|
+
) VALUES (?, ?, ?, ?, ?, ?)
|
|
352
|
+
`).run(identity.id, identity.build, identity.command, identity.endpoint, operation.status, payload);
|
|
353
|
+
if (result.changes !== 1) throw new Error(`Operation ${identity.id} was not created`);
|
|
354
|
+
return copy(operation);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
async read(id: string): Promise<OperationSnapshot | undefined> {
|
|
358
|
+
const row = this.#database.prepare(`
|
|
359
|
+
SELECT operation_id, build_id, command_id, endpoint_id,
|
|
360
|
+
status, payload_json
|
|
361
|
+
FROM hypit_operations
|
|
362
|
+
WHERE operation_id = ?
|
|
363
|
+
`).get(id) as Row | undefined;
|
|
364
|
+
return row === undefined ? undefined : parseOperationSnapshot(row);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
async removeBuild(build: string): Promise<void> {
|
|
368
|
+
this.#database.prepare("DELETE FROM hypit_operations WHERE build_id = ?").run(build);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
async list(query: OperationQuery): Promise<readonly OperationSnapshot[]> {
|
|
372
|
+
const predicates: string[] = [];
|
|
373
|
+
const values: string[] = [];
|
|
374
|
+
for (const [field, value] of [
|
|
375
|
+
["build_id", query.build],
|
|
376
|
+
["command_id", query.command],
|
|
377
|
+
["endpoint_id", query.endpoint],
|
|
378
|
+
] as const) {
|
|
379
|
+
if (value === undefined) continue;
|
|
380
|
+
predicates.push(`${field} = ?`);
|
|
381
|
+
values.push(value);
|
|
382
|
+
}
|
|
383
|
+
const rows = this.#database.prepare(`
|
|
384
|
+
SELECT operation_id, build_id, command_id, endpoint_id,
|
|
385
|
+
status, payload_json
|
|
386
|
+
FROM hypit_operations
|
|
387
|
+
${predicates.length === 0 ? "" : `WHERE ${predicates.join(" AND ")}`}
|
|
388
|
+
ORDER BY operation_id ASC
|
|
389
|
+
`).all(...values) as Row[];
|
|
390
|
+
return rows.map(parseOperationSnapshot)
|
|
391
|
+
.sort((left, right) => left.id.localeCompare(right.id));
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
async update(id: string, update: OperationUpdate): Promise<OperationSnapshot> {
|
|
395
|
+
const current = await this.read(id);
|
|
396
|
+
if (current === undefined) throw new Error(`Operation ${id} does not exist`);
|
|
397
|
+
if (current.status === "completed" || current.status === "failed" || current.status === "cancelled") return current;
|
|
398
|
+
const next = { ...current, ...copy(update) } as OperationSnapshot;
|
|
399
|
+
// Progress and timers describe the next action; acknowledgement and request
|
|
400
|
+
// facts survive success/failure until the Result has saved the receipt.
|
|
401
|
+
if (update.status !== "pending" || update.wakeAt === undefined) delete (next as { wakeAt?: number }).wakeAt;
|
|
402
|
+
const result = this.#database.prepare(`
|
|
403
|
+
UPDATE hypit_operations SET status = ?, payload_json = ? WHERE operation_id = ?
|
|
404
|
+
`).run(next.status, operationPayload(next), id);
|
|
405
|
+
if (result.changes !== 1) throw new Error(`Operation ${id} disappeared during update`);
|
|
406
|
+
return next;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function parseCommandExecution(row: Row): CommandExecutionReceipt {
|
|
412
|
+
assert(typeof row.build_id === "string" && typeof row.command_id === "string",
|
|
413
|
+
"SQLite Command execution has no identity");
|
|
414
|
+
assert(row.status === "started" || row.status === "completed",
|
|
415
|
+
"SQLite Command execution has an invalid status");
|
|
416
|
+
const event = typeof row.event_json === "string"
|
|
417
|
+
? JSON.parse(row.event_json) as CommandResult
|
|
418
|
+
: undefined;
|
|
419
|
+
if (row.status === "completed") {
|
|
420
|
+
assert(event !== undefined, `SQLite Command execution ${row.command_id} has no result`);
|
|
421
|
+
}
|
|
422
|
+
return {
|
|
423
|
+
build: row.build_id,
|
|
424
|
+
command: row.command_id,
|
|
425
|
+
status: row.status,
|
|
426
|
+
...(event === undefined ? {} : { event }),
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
class SqliteCommandExecutionStore implements CommandExecutionStore {
|
|
431
|
+
readonly #database: DatabaseSync;
|
|
432
|
+
|
|
433
|
+
constructor(database: DatabaseSync) {
|
|
434
|
+
this.#database = database;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
async begin(build: string, command: string): Promise<CommandExecutionBegin> {
|
|
438
|
+
return transaction(this.#database, () => {
|
|
439
|
+
const inserted = this.#database.prepare(`
|
|
440
|
+
INSERT OR IGNORE INTO hypit_command_executions (build_id, command_id, status, event_json)
|
|
441
|
+
VALUES (?, ?, 'started', NULL)
|
|
442
|
+
`).run(build, command);
|
|
443
|
+
const row = this.#database.prepare(`
|
|
444
|
+
SELECT * FROM hypit_command_executions WHERE build_id = ? AND command_id = ?
|
|
445
|
+
`).get(build, command) as Row;
|
|
446
|
+
return { created: inserted.changes === 1, receipt: parseCommandExecution(row) };
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
async complete(build: string, command: string, event: CommandResult): Promise<CommandExecutionReceipt> {
|
|
451
|
+
return transaction(this.#database, () => {
|
|
452
|
+
const row = this.#database.prepare(`
|
|
453
|
+
SELECT * FROM hypit_command_executions WHERE build_id = ? AND command_id = ?
|
|
454
|
+
`).get(build, command) as Row | undefined;
|
|
455
|
+
if (row === undefined) throw new Error(`Command execution ${build}/${command} was not started`);
|
|
456
|
+
const current = parseCommandExecution(row);
|
|
457
|
+
if (current.status === "completed") return current;
|
|
458
|
+
this.#database.prepare(`
|
|
459
|
+
UPDATE hypit_command_executions SET status = 'completed', event_json = ?
|
|
460
|
+
WHERE build_id = ? AND command_id = ? AND status = 'started'
|
|
461
|
+
`).run(JSON.stringify(event), build, command);
|
|
462
|
+
return parseCommandExecution(this.#database.prepare(`
|
|
463
|
+
SELECT * FROM hypit_command_executions WHERE build_id = ? AND command_id = ?
|
|
464
|
+
`).get(build, command) as Row);
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
async list(build: string): Promise<readonly CommandExecutionReceipt[]> {
|
|
469
|
+
return (this.#database.prepare(`
|
|
470
|
+
SELECT * FROM hypit_command_executions WHERE build_id = ? ORDER BY command_id ASC
|
|
471
|
+
`).all(build) as Row[]).map(parseCommandExecution);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
async removeBuild(build: string): Promise<void> {
|
|
475
|
+
this.#database.prepare("DELETE FROM hypit_command_executions WHERE build_id = ?").run(build);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
class SqliteRuntimeEnvironmentStore implements RuntimeEnvironmentStore {
|
|
480
|
+
readonly #database: DatabaseSync;
|
|
481
|
+
|
|
482
|
+
constructor(database: DatabaseSync) {
|
|
483
|
+
this.#database = database;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
async use(config: string): Promise<void> {
|
|
487
|
+
assert(config.length > 0, "Runtime environment configuration is empty");
|
|
488
|
+
transaction(this.#database, () => {
|
|
489
|
+
const active = this.#database.prepare(
|
|
490
|
+
`SELECT
|
|
491
|
+
(SELECT COUNT(*) FROM hypit_submissions)
|
|
492
|
+
+ (SELECT COUNT(*) FROM hypit_executions) AS count`,
|
|
493
|
+
).get() as Row;
|
|
494
|
+
assert(typeof active.count === "number", "SQLite active Runtime work count is invalid");
|
|
495
|
+
const row = this.#database.prepare(
|
|
496
|
+
"SELECT config_json FROM hypit_runtime_environment WHERE singleton = 1",
|
|
497
|
+
).get() as Row | undefined;
|
|
498
|
+
if (active.count > 0) {
|
|
499
|
+
assert(typeof row?.config_json === "string",
|
|
500
|
+
"Active Runtime work has no recorded environment; use its original Profile or resolve it explicitly");
|
|
501
|
+
assert(row.config_json === config,
|
|
502
|
+
"Runtime Profile differs from the environment pinned by active Builds");
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
this.#database.prepare(`
|
|
506
|
+
INSERT INTO hypit_runtime_environment (singleton, config_json) VALUES (1, ?)
|
|
507
|
+
ON CONFLICT(singleton) DO UPDATE SET config_json = excluded.config_json
|
|
508
|
+
`).run(config);
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
async assert(config: string): Promise<void> {
|
|
513
|
+
const row = this.#database.prepare(
|
|
514
|
+
"SELECT config_json FROM hypit_runtime_environment WHERE singleton = 1",
|
|
515
|
+
).get() as Row | undefined;
|
|
516
|
+
assert(typeof row?.config_json === "string" && row.config_json === config,
|
|
517
|
+
"Runtime Profile no longer matches this Worker's active environment");
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
function parseExecutionSnapshot(row: Row): BuildExecutionSnapshot {
|
|
523
|
+
assert(typeof row.created_at === "number", "SQLite Execution creation time is invalid");
|
|
524
|
+
assert(row.wake_at === null || typeof row.wake_at === "number", "SQLite Execution wake time is invalid");
|
|
525
|
+
assert((row.turn_owner === null && row.turn_acquired_at === null)
|
|
526
|
+
|| (typeof row.turn_owner === "string" && typeof row.turn_acquired_at === "number"),
|
|
527
|
+
"SQLite Execution turn is invalid");
|
|
528
|
+
assert((row.result_writer_owner === null && row.result_writer_acquired_at === null)
|
|
529
|
+
|| (typeof row.result_writer_owner === "string" && typeof row.result_writer_acquired_at === "number"),
|
|
530
|
+
"SQLite Result-writer lease is invalid");
|
|
531
|
+
assert((row.decision_outcome === null && row.decision_reason === null)
|
|
532
|
+
|| (row.decision_outcome === "complete" || row.decision_outcome === "failed" || row.decision_outcome === "cancelled"),
|
|
533
|
+
"SQLite Execution decision is invalid");
|
|
534
|
+
assert((row.attention_step === null && row.attention_error === null)
|
|
535
|
+
|| ((row.attention_step === "result" || row.attention_step === "cleanup")
|
|
536
|
+
&& typeof row.attention_error === "string"),
|
|
537
|
+
"SQLite Execution attention is invalid");
|
|
538
|
+
return {
|
|
539
|
+
...parseExecutionRequest(row, "Execution"),
|
|
540
|
+
createdAt: row.created_at,
|
|
541
|
+
...(typeof row.wake_at === "number" ? { wakeAt: row.wake_at } : {}),
|
|
542
|
+
...(typeof row.operation_wait_json === "string" ? { operationWait: JSON.parse(row.operation_wait_json) as string[] } : {}),
|
|
543
|
+
...(typeof row.turn_owner === "string" ? {
|
|
544
|
+
turn: { owner: row.turn_owner, acquiredAt: row.turn_acquired_at as number },
|
|
545
|
+
} : {}),
|
|
546
|
+
...(typeof row.result_writer_owner === "string" ? {
|
|
547
|
+
resultWrite: { owner: row.result_writer_owner, acquiredAt: row.result_writer_acquired_at as number },
|
|
548
|
+
} : {}),
|
|
549
|
+
...(row.stop_cause === "user-cancelled" || row.stop_cause === "execution-failed" ? {
|
|
550
|
+
stop: {
|
|
551
|
+
cause: row.stop_cause,
|
|
552
|
+
...(typeof row.stop_reason === "string" ? { reason: row.stop_reason } : {}),
|
|
553
|
+
},
|
|
554
|
+
} : {}),
|
|
555
|
+
...(typeof row.decision_outcome === "string" ? {
|
|
556
|
+
decision: {
|
|
557
|
+
outcome: row.decision_outcome as "complete" | "failed" | "cancelled",
|
|
558
|
+
...(typeof row.decision_reason === "string" ? { reason: row.decision_reason } : {}),
|
|
559
|
+
},
|
|
560
|
+
} : {}),
|
|
561
|
+
...(typeof row.attention_step === "string" ? {
|
|
562
|
+
attention: {
|
|
563
|
+
step: row.attention_step as "result" | "cleanup",
|
|
564
|
+
error: row.attention_error as string,
|
|
565
|
+
},
|
|
566
|
+
} : {}),
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
class SqliteBuildExecutionStore implements BuildExecutionStore {
|
|
571
|
+
readonly #database: DatabaseSync;
|
|
572
|
+
|
|
573
|
+
constructor(database: DatabaseSync) {
|
|
574
|
+
this.#database = database;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
async create(
|
|
578
|
+
request: BuildExecutionRequest,
|
|
579
|
+
options: { readonly now?: number } = {},
|
|
580
|
+
): Promise<BuildExecutionSnapshot> {
|
|
581
|
+
const now = options.now ?? Date.now();
|
|
582
|
+
nonNegativeInteger(now, "Execution creation time");
|
|
583
|
+
this.#database.prepare(`
|
|
584
|
+
INSERT INTO hypit_executions (
|
|
585
|
+
build_id, component_packages_json, result_location_json, created_at, wake_at,
|
|
586
|
+
turn_owner, turn_acquired_at, result_writer_owner, result_writer_acquired_at,
|
|
587
|
+
stop_cause, stop_reason,
|
|
588
|
+
decision_outcome, decision_reason, attention_step, attention_error
|
|
589
|
+
) VALUES (?, ?, ?, ?, ?, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
|
|
590
|
+
`).run(request.build, JSON.stringify(request.componentPackages), JSON.stringify(request.result), now, now);
|
|
591
|
+
return {
|
|
592
|
+
...copy(request),
|
|
593
|
+
createdAt: now,
|
|
594
|
+
wakeAt: now,
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
async read(build: string): Promise<BuildExecutionSnapshot | undefined> {
|
|
599
|
+
const row = this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row | undefined;
|
|
600
|
+
return row === undefined ? undefined : parseExecutionSnapshot(row);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
async list(): Promise<readonly BuildExecutionSnapshot[]> {
|
|
604
|
+
const rows = this.#database.prepare(`
|
|
605
|
+
SELECT * FROM hypit_executions
|
|
606
|
+
ORDER BY created_at ASC, build_id ASC
|
|
607
|
+
`).all() as Row[];
|
|
608
|
+
return rows.map(parseExecutionSnapshot);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
async claim(owner: string, now = Date.now()): Promise<BuildExecutionSnapshot | undefined> {
|
|
612
|
+
assert(owner.trim().length > 0, "Execution turn owner is empty");
|
|
613
|
+
nonNegativeInteger(now, "Execution claim time");
|
|
614
|
+
return transaction(this.#database, () => {
|
|
615
|
+
const row = this.#database.prepare(`
|
|
616
|
+
SELECT execution.build_id FROM hypit_executions AS execution
|
|
617
|
+
WHERE decision_outcome IS NULL AND turn_owner IS NULL AND wake_at <= ?
|
|
618
|
+
ORDER BY EXISTS (
|
|
619
|
+
SELECT 1 FROM hypit_capacity AS capacity
|
|
620
|
+
WHERE capacity.build_id = execution.build_id
|
|
621
|
+
) DESC, wake_at ASC, created_at ASC, execution.build_id ASC
|
|
622
|
+
LIMIT 1
|
|
623
|
+
`).get(now) as Row | undefined;
|
|
624
|
+
if (row === undefined) return undefined;
|
|
625
|
+
assert(typeof row.build_id === "string", "SQLite ready Execution has no Build id");
|
|
626
|
+
const updated = this.#database.prepare(`
|
|
627
|
+
UPDATE hypit_executions
|
|
628
|
+
SET turn_owner = ?, turn_acquired_at = ?
|
|
629
|
+
WHERE build_id = ? AND decision_outcome IS NULL AND turn_owner IS NULL AND wake_at <= ?
|
|
630
|
+
`).run(owner, now, row.build_id, now);
|
|
631
|
+
if (updated.changes !== 1) return undefined;
|
|
632
|
+
return parseExecutionSnapshot(
|
|
633
|
+
this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(row.build_id) as Row,
|
|
634
|
+
);
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
async releaseTurn(build: string, owner: string, wakeAt: number | undefined, operationWait?: readonly string[]): Promise<BuildExecutionSnapshot> {
|
|
639
|
+
if (wakeAt !== undefined) nonNegativeInteger(wakeAt, "Execution wakeAt");
|
|
640
|
+
return transaction(this.#database, () => {
|
|
641
|
+
const row = this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row | undefined;
|
|
642
|
+
if (row === undefined) throw new Error(`Execution ${build} does not exist`);
|
|
643
|
+
const current = parseExecutionSnapshot(row);
|
|
644
|
+
assert(current.decision === undefined, `Execution ${build} already has a decision`);
|
|
645
|
+
assert(current.turn?.owner === owner, `Execution ${build} is not owned by ${owner}`);
|
|
646
|
+
// A release can race this turn. Recheck parked claims in this transaction so
|
|
647
|
+
// that a notification received before releaseTurn is not lost.
|
|
648
|
+
const now = Date.now();
|
|
649
|
+
const readyWait = current.stop === undefined && (this.#database.prepare(
|
|
650
|
+
"SELECT resources_json FROM hypit_resource_waits WHERE build_id = ?",
|
|
651
|
+
).all(build) as Row[]).some((wait) => this.#blocked(JSON.parse(wait.resources_json as string), now) === undefined);
|
|
652
|
+
const next = current.stop !== undefined || readyWait
|
|
653
|
+
? Math.min(wakeAt ?? now, now) : wakeAt;
|
|
654
|
+
this.#database.prepare(`
|
|
655
|
+
UPDATE hypit_executions
|
|
656
|
+
SET turn_owner = NULL, turn_acquired_at = NULL, wake_at = ?, operation_wait_json = ?
|
|
657
|
+
WHERE build_id = ? AND turn_owner = ?
|
|
658
|
+
`).run(next ?? null, readyWait || operationWait === undefined ? null : JSON.stringify(operationWait), build, owner);
|
|
659
|
+
return parseExecutionSnapshot(
|
|
660
|
+
this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row,
|
|
661
|
+
);
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
async decide(
|
|
666
|
+
build: string,
|
|
667
|
+
owner: string,
|
|
668
|
+
outcome: "complete" | "failed" | "cancelled",
|
|
669
|
+
reason?: string,
|
|
670
|
+
): Promise<BuildExecutionSnapshot> {
|
|
671
|
+
return transaction(this.#database, () => {
|
|
672
|
+
const row = this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row | undefined;
|
|
673
|
+
if (row === undefined) throw new Error(`Execution ${build} does not exist`);
|
|
674
|
+
const current = parseExecutionSnapshot(row);
|
|
675
|
+
const effective = current.stop === undefined ? outcome
|
|
676
|
+
: current.stop.cause === "user-cancelled" ? "cancelled" : "failed";
|
|
677
|
+
const effectiveReason = current.stop === undefined ? reason : current.stop.reason;
|
|
678
|
+
if (current.decision !== undefined) {
|
|
679
|
+
assert(current.decision.outcome === effective && current.decision.reason === effectiveReason,
|
|
680
|
+
`Execution ${build} already has a different decision`);
|
|
681
|
+
return current;
|
|
682
|
+
}
|
|
683
|
+
assert(current.turn?.owner === owner, `Execution ${build} is not owned by ${owner}`);
|
|
684
|
+
this.#database.prepare(`
|
|
685
|
+
UPDATE hypit_executions
|
|
686
|
+
SET decision_outcome = ?, decision_reason = ?, turn_owner = NULL, turn_acquired_at = NULL,
|
|
687
|
+
attention_step = NULL, attention_error = NULL
|
|
688
|
+
WHERE build_id = ? AND turn_owner = ? AND decision_outcome IS NULL
|
|
689
|
+
`).run(effective, effectiveReason ?? null, build, owner);
|
|
690
|
+
return parseExecutionSnapshot(
|
|
691
|
+
this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row,
|
|
692
|
+
);
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
async setAttention(
|
|
697
|
+
build: string,
|
|
698
|
+
attention: BuildExecutionSnapshot["attention"],
|
|
699
|
+
): Promise<BuildExecutionSnapshot> {
|
|
700
|
+
return transaction(this.#database, () => {
|
|
701
|
+
const row = this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row | undefined;
|
|
702
|
+
if (row === undefined) throw new Error(`Execution ${build} does not exist`);
|
|
703
|
+
const current = parseExecutionSnapshot(row);
|
|
704
|
+
assert(current.decision !== undefined, `Execution ${build} has no decision`);
|
|
705
|
+
this.#database.prepare(`
|
|
706
|
+
UPDATE hypit_executions
|
|
707
|
+
SET attention_step = ?, attention_error = ?
|
|
708
|
+
WHERE build_id = ?
|
|
709
|
+
`).run(attention?.step ?? null, attention?.error ?? null, build);
|
|
710
|
+
return parseExecutionSnapshot(
|
|
711
|
+
this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row,
|
|
712
|
+
);
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
async claimResultWrite(
|
|
717
|
+
build: string,
|
|
718
|
+
owner: string,
|
|
719
|
+
now = Date.now(),
|
|
720
|
+
): Promise<BuildExecutionSnapshot | undefined> {
|
|
721
|
+
assert(owner.trim().length > 0, "Result-writer owner is empty");
|
|
722
|
+
nonNegativeInteger(now, "Result-writer acquisition time");
|
|
723
|
+
return transaction(this.#database, () => {
|
|
724
|
+
const updated = this.#database.prepare(`
|
|
725
|
+
UPDATE hypit_executions
|
|
726
|
+
SET result_writer_owner = ?, result_writer_acquired_at = ?,
|
|
727
|
+
attention_step = NULL, attention_error = NULL
|
|
728
|
+
WHERE build_id = ? AND decision_outcome IS NOT NULL AND result_writer_owner IS NULL
|
|
729
|
+
`).run(owner, now, build);
|
|
730
|
+
if (updated.changes !== 1) return undefined;
|
|
731
|
+
return parseExecutionSnapshot(
|
|
732
|
+
this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row,
|
|
733
|
+
);
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
async releaseResultWrite(build: string, owner: string): Promise<BuildExecutionSnapshot> {
|
|
738
|
+
return transaction(this.#database, () => {
|
|
739
|
+
const updated = this.#database.prepare(`
|
|
740
|
+
UPDATE hypit_executions
|
|
741
|
+
SET result_writer_owner = NULL, result_writer_acquired_at = NULL
|
|
742
|
+
WHERE build_id = ? AND result_writer_owner = ?
|
|
743
|
+
`).run(build, owner);
|
|
744
|
+
assert(updated.changes === 1, `Execution ${build} Result writer is not owned by ${owner}`);
|
|
745
|
+
return parseExecutionSnapshot(
|
|
746
|
+
this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row,
|
|
747
|
+
);
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
async reclaimResultWrites(): Promise<readonly string[]> {
|
|
752
|
+
return transaction(this.#database, () => {
|
|
753
|
+
const rows = this.#database.prepare(
|
|
754
|
+
"SELECT build_id FROM hypit_executions WHERE result_writer_owner IS NOT NULL",
|
|
755
|
+
).all() as Row[];
|
|
756
|
+
const builds = rows.map((row) => {
|
|
757
|
+
assert(typeof row.build_id === "string", "SQLite Result-writer lease has no Build id");
|
|
758
|
+
return row.build_id;
|
|
759
|
+
});
|
|
760
|
+
for (const build of builds) {
|
|
761
|
+
this.#database.prepare(`
|
|
762
|
+
UPDATE hypit_executions
|
|
763
|
+
SET result_writer_owner = NULL, result_writer_acquired_at = NULL,
|
|
764
|
+
attention_step = 'result',
|
|
765
|
+
attention_error = 'Result writing was interrupted; run hypit result finish <build-id>'
|
|
766
|
+
WHERE build_id = ? AND result_writer_owner IS NOT NULL
|
|
767
|
+
`).run(build);
|
|
768
|
+
}
|
|
769
|
+
return builds;
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
async requestStop(build: string, stop: BuildExecutionStop): Promise<BuildExecutionSnapshot> {
|
|
774
|
+
const now = Date.now();
|
|
775
|
+
return transaction(this.#database, () => {
|
|
776
|
+
const row = this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row | undefined;
|
|
777
|
+
if (row === undefined) throw new Error(`Execution ${build} does not exist`);
|
|
778
|
+
const current = parseExecutionSnapshot(row);
|
|
779
|
+
if (current.stop !== undefined) return current;
|
|
780
|
+
if (current.decision !== undefined) return current;
|
|
781
|
+
this.#database.prepare(`
|
|
782
|
+
UPDATE hypit_executions
|
|
783
|
+
SET wake_at = CASE WHEN turn_owner IS NULL THEN ? ELSE wake_at END,
|
|
784
|
+
stop_reason = ?, stop_cause = ?
|
|
785
|
+
WHERE build_id = ?
|
|
786
|
+
`).run(now, stop.reason ?? null, stop.cause, build);
|
|
787
|
+
return parseExecutionSnapshot(
|
|
788
|
+
this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row,
|
|
789
|
+
);
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
#rate(resource: CapacityResourceClaim, now: number): number {
|
|
794
|
+
const row = this.#database.prepare("SELECT * FROM hypit_rates WHERE resource_id = ?").get(resource.id) as Row | undefined;
|
|
795
|
+
if (row === undefined) return resource.limit;
|
|
796
|
+
assert(row.limit_units === resource.limit && row.period_ms === resource.periodMs,
|
|
797
|
+
`Shared rate ${resource.id} has conflicting limit or periodMs`);
|
|
798
|
+
return Math.min(resource.limit, (row.tokens as number)
|
|
799
|
+
+ Math.max(0, now - (row.updated_at as number)) * resource.limit / resource.periodMs!);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
#blocked(resources: readonly CapacityResourceClaim[], now: number): Extract<CapacityAcquire, { status: "blocked" }> | undefined {
|
|
803
|
+
for (const resource of resources) {
|
|
804
|
+
const units = capacityUnits(resource);
|
|
805
|
+
if (resource.periodMs !== undefined) {
|
|
806
|
+
const tokens = this.#rate(resource, now);
|
|
807
|
+
if (tokens + 1e-9 < units) return {
|
|
808
|
+
status: "blocked", availableAt: now + Math.ceil((units - tokens) * resource.periodMs / resource.limit),
|
|
809
|
+
reason: "rate-limit", resource: resource.id,
|
|
810
|
+
};
|
|
811
|
+
} else {
|
|
812
|
+
const count = this.#database.prepare(`
|
|
813
|
+
SELECT COALESCE(SUM(COALESCE(json_extract(claim.value, '$.units'), 1)), 0) AS count
|
|
814
|
+
FROM hypit_capacity AS capacity, json_each(capacity.resources_json) AS claim
|
|
815
|
+
WHERE json_extract(claim.value, '$.id') = ?
|
|
816
|
+
`).get(resource.id) as Row;
|
|
817
|
+
if ((count.count as number) + units > resource.limit) return {
|
|
818
|
+
status: "blocked", reason: "resource-in-flight", resource: resource.id,
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
return undefined;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
async acquireCapacity(request: CapacityAcquireRequest): Promise<CapacityAcquire> {
|
|
826
|
+
nonNegativeInteger(request.now, "Resource acquisition time");
|
|
827
|
+
assert(request.resources.length > 0, "Resources are empty");
|
|
828
|
+
const resources = [...request.resources].sort((left, right) => left.id.localeCompare(right.id));
|
|
829
|
+
assert(new Set(resources.map((resource) => resource.id)).size === resources.length, "Resources repeat an id");
|
|
830
|
+
for (const resource of resources) capacityUnits(resource);
|
|
831
|
+
return transaction(this.#database, () => {
|
|
832
|
+
const existing = this.#database.prepare(
|
|
833
|
+
"SELECT * FROM hypit_capacity WHERE build_id = ? AND command_id = ?",
|
|
834
|
+
).get(request.build, request.command) as Row | undefined;
|
|
835
|
+
if (existing !== undefined) return { status: "acquired", reservation: parseCapacityReservation(existing) };
|
|
836
|
+
const blocked = this.#blocked(resources, request.now);
|
|
837
|
+
if (blocked !== undefined) {
|
|
838
|
+
this.#database.prepare(`
|
|
839
|
+
INSERT INTO hypit_resource_waits (build_id, command_id, resource_id, resources_json) VALUES (?, ?, ?, ?)
|
|
840
|
+
ON CONFLICT(build_id, command_id) DO UPDATE SET resource_id = excluded.resource_id, resources_json = excluded.resources_json
|
|
841
|
+
`).run(request.build, request.command, blocked.resource, JSON.stringify(resources));
|
|
842
|
+
return blocked;
|
|
843
|
+
}
|
|
844
|
+
for (const resource of resources) {
|
|
845
|
+
if (resource.periodMs === undefined) continue;
|
|
846
|
+
this.#database.prepare(`
|
|
847
|
+
INSERT INTO hypit_rates (resource_id, limit_units, period_ms, tokens, updated_at) VALUES (?, ?, ?, ?, ?)
|
|
848
|
+
ON CONFLICT(resource_id) DO UPDATE SET tokens = excluded.tokens, updated_at = excluded.updated_at
|
|
849
|
+
`).run(resource.id, resource.limit, resource.periodMs, this.#rate(resource, request.now) - capacityUnits(resource), request.now);
|
|
850
|
+
}
|
|
851
|
+
const reservation: CapacityReservation = {
|
|
852
|
+
build: request.build, command: request.command, createdAt: request.now,
|
|
853
|
+
resources: resources.filter((resource) => resource.periodMs === undefined),
|
|
854
|
+
lifetime: request.lifetime ?? "operation",
|
|
855
|
+
};
|
|
856
|
+
if (reservation.resources.length > 0) this.#database.prepare(`
|
|
857
|
+
INSERT INTO hypit_capacity (build_id, command_id, resources_json, created_at, lifetime) VALUES (?, ?, ?, ?, ?)
|
|
858
|
+
`).run(request.build, request.command, JSON.stringify(reservation.resources), request.now, reservation.lifetime!);
|
|
859
|
+
this.#database.prepare("DELETE FROM hypit_resource_waits WHERE build_id = ? AND command_id = ?").run(request.build, request.command);
|
|
860
|
+
this.#wakeAvailableWaiter();
|
|
861
|
+
return { status: "acquired", reservation };
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
#release(build: string, command?: string): void {
|
|
866
|
+
const where = command === undefined ? "build_id = ?" : "build_id = ? AND command_id = ?";
|
|
867
|
+
const args = command === undefined ? [build] : [build, command];
|
|
868
|
+
this.#database.prepare(`DELETE FROM hypit_capacity WHERE ${where}`).run(...args);
|
|
869
|
+
if (command === undefined) this.#database.prepare("DELETE FROM hypit_resource_waits WHERE build_id = ?").run(build);
|
|
870
|
+
this.#wakeAvailableWaiter();
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
#wakeAvailableWaiter(): void {
|
|
874
|
+
const now = Date.now();
|
|
875
|
+
const waits = this.#database.prepare(`
|
|
876
|
+
SELECT waits.build_id, waits.resources_json FROM hypit_resource_waits AS waits
|
|
877
|
+
JOIN hypit_executions AS execution ON execution.build_id = waits.build_id
|
|
878
|
+
WHERE execution.decision_outcome IS NULL AND execution.stop_cause IS NULL
|
|
879
|
+
AND execution.turn_owner IS NULL AND (execution.wake_at IS NULL OR execution.wake_at > ?)
|
|
880
|
+
ORDER BY execution.created_at, waits.rowid
|
|
881
|
+
`).all(now) as Row[];
|
|
882
|
+
for (const wait of waits) {
|
|
883
|
+
if (this.#blocked(JSON.parse(wait.resources_json as string), now) !== undefined) continue;
|
|
884
|
+
this.#database.prepare("UPDATE hypit_executions SET wake_at = ?, operation_wait_json = NULL WHERE build_id = ?")
|
|
885
|
+
.run(now, wait.build_id as string);
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
async releaseCapacity(build: string, command: string): Promise<void> {
|
|
891
|
+
transaction(this.#database, () => this.#release(build, command));
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
async reclaimActionCapacity(): Promise<void> {
|
|
895
|
+
transaction(this.#database, () => {
|
|
896
|
+
const rows = this.#database.prepare("SELECT build_id, command_id FROM hypit_capacity WHERE lifetime = 'action'").all() as Row[];
|
|
897
|
+
for (const row of rows) this.#release(row.build_id as string, row.command_id as string);
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
async releaseBuildCapacity(build: string): Promise<void> {
|
|
902
|
+
transaction(this.#database, () => this.#release(build));
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
async reclaimTurns(now = Date.now()): Promise<readonly string[]> {
|
|
906
|
+
nonNegativeInteger(now, "Execution turn reclaim time");
|
|
907
|
+
return transaction(this.#database, () => {
|
|
908
|
+
const rows = this.#database.prepare(
|
|
909
|
+
"SELECT build_id FROM hypit_executions WHERE turn_owner IS NOT NULL AND decision_outcome IS NULL",
|
|
910
|
+
).all() as Row[];
|
|
911
|
+
const builds = rows.map((row) => {
|
|
912
|
+
assert(typeof row.build_id === "string", "SQLite owned Execution has no Build id");
|
|
913
|
+
return row.build_id;
|
|
914
|
+
});
|
|
915
|
+
for (const row of rows) {
|
|
916
|
+
assert(typeof row.build_id === "string", "SQLite active Execution is invalid");
|
|
917
|
+
this.#database.prepare(`
|
|
918
|
+
UPDATE hypit_executions
|
|
919
|
+
SET turn_owner = NULL, turn_acquired_at = NULL, wake_at = ?
|
|
920
|
+
WHERE build_id = ? AND decision_outcome IS NULL
|
|
921
|
+
`).run(now, row.build_id);
|
|
922
|
+
}
|
|
923
|
+
return builds;
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
async listCapacity(): Promise<readonly CapacityReservation[]> {
|
|
928
|
+
return (this.#database.prepare(
|
|
929
|
+
"SELECT * FROM hypit_capacity ORDER BY created_at ASC, build_id ASC, command_id ASC",
|
|
930
|
+
).all() as Row[]).map(parseCapacityReservation);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function parseCapacityReservation(row: Row): CapacityReservation {
|
|
935
|
+
assert(typeof row.build_id === "string" && typeof row.command_id === "string"
|
|
936
|
+
&& typeof row.resources_json === "string"
|
|
937
|
+
&& typeof row.created_at === "number", "SQLite Capacity row is invalid");
|
|
938
|
+
const storedResources = JSON.parse(row.resources_json) as readonly Readonly<Record<string, unknown>>[];
|
|
939
|
+
const resources = storedResources.map((resource) => {
|
|
940
|
+
assert(typeof resource.id === "string", "SQLite Capacity resource has no id");
|
|
941
|
+
assert(typeof resource.limit === "number", `SQLite Capacity resource ${resource.id} has no limit`);
|
|
942
|
+
const claim = { id: resource.id, limit: positiveInteger(resource.limit, `resource ${resource.id} limit`),
|
|
943
|
+
...(resource.units === undefined ? {} : { units: positiveInteger(resource.units as number, `resource ${resource.id} units`) }) };
|
|
944
|
+
capacityUnits(claim);
|
|
945
|
+
return claim;
|
|
946
|
+
});
|
|
947
|
+
const value = {
|
|
948
|
+
build: row.build_id,
|
|
949
|
+
command: row.command_id,
|
|
950
|
+
resources,
|
|
951
|
+
lifetime: row.lifetime as "action" | "operation",
|
|
952
|
+
createdAt: row.created_at,
|
|
953
|
+
};
|
|
954
|
+
return value;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
export class SqliteRuntimeState {
|
|
958
|
+
readonly path: string;
|
|
959
|
+
readonly builds: BuildStore;
|
|
960
|
+
readonly operations: OperationStore;
|
|
961
|
+
readonly commandExecutions: CommandExecutionStore;
|
|
962
|
+
readonly execution: BuildExecutionStore;
|
|
963
|
+
readonly catalog: BuildCatalog;
|
|
964
|
+
readonly environment: RuntimeEnvironmentStore;
|
|
965
|
+
readonly submissions: PendingBuildStore;
|
|
966
|
+
readonly #database: DatabaseSync;
|
|
967
|
+
|
|
968
|
+
constructor(path: string, options: SqliteRuntimeStateOptions = {}) {
|
|
969
|
+
assert(path.trim().length > 0, "SQLite path must not be empty");
|
|
970
|
+
const absolute = resolve(path);
|
|
971
|
+
const emptyReadOnly = options.readOnly === true && !existsSync(absolute);
|
|
972
|
+
if (!options.readOnly) mkdirSync(dirname(absolute), { recursive: true });
|
|
973
|
+
const database = emptyReadOnly
|
|
974
|
+
? new DatabaseSync(":memory:")
|
|
975
|
+
: options.readOnly
|
|
976
|
+
? new DatabaseSync(absolute, { readOnly: true })
|
|
977
|
+
: new DatabaseSync(absolute);
|
|
978
|
+
this.path = absolute;
|
|
979
|
+
this.#database = database;
|
|
980
|
+
this.#database.exec(`PRAGMA busy_timeout = ${positiveInteger(options.busyTimeoutMs ?? 5_000, "busyTimeoutMs")}`);
|
|
981
|
+
if (!options.readOnly || emptyReadOnly) {
|
|
982
|
+
this.#database.exec("PRAGMA journal_mode = WAL");
|
|
983
|
+
this.#database.exec("PRAGMA synchronous = NORMAL");
|
|
984
|
+
}
|
|
985
|
+
if (!options.readOnly || emptyReadOnly) this.#database.exec(`
|
|
986
|
+
CREATE TABLE IF NOT EXISTS hypit_builds (
|
|
987
|
+
build_id TEXT PRIMARY KEY,
|
|
988
|
+
definition_json TEXT NOT NULL
|
|
989
|
+
) STRICT;
|
|
990
|
+
CREATE TABLE IF NOT EXISTS hypit_build_facts (
|
|
991
|
+
sequence INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
992
|
+
build_id TEXT NOT NULL,
|
|
993
|
+
command_id TEXT NOT NULL,
|
|
994
|
+
fact_json TEXT NOT NULL,
|
|
995
|
+
UNIQUE (build_id, command_id)
|
|
996
|
+
) STRICT;
|
|
997
|
+
CREATE TABLE IF NOT EXISTS hypit_operations (
|
|
998
|
+
operation_id TEXT PRIMARY KEY,
|
|
999
|
+
build_id TEXT NOT NULL,
|
|
1000
|
+
command_id TEXT NOT NULL,
|
|
1001
|
+
endpoint_id TEXT NOT NULL,
|
|
1002
|
+
status TEXT NOT NULL CHECK (status IN ('pending', 'completed', 'failed', 'cancelled')),
|
|
1003
|
+
payload_json TEXT
|
|
1004
|
+
) STRICT;
|
|
1005
|
+
CREATE TABLE IF NOT EXISTS hypit_command_executions (
|
|
1006
|
+
build_id TEXT NOT NULL,
|
|
1007
|
+
command_id TEXT NOT NULL,
|
|
1008
|
+
status TEXT NOT NULL CHECK (status IN ('started', 'completed')),
|
|
1009
|
+
event_json TEXT,
|
|
1010
|
+
PRIMARY KEY (build_id, command_id)
|
|
1011
|
+
) STRICT;
|
|
1012
|
+
CREATE TABLE IF NOT EXISTS hypit_build_catalog (
|
|
1013
|
+
build_id TEXT PRIMARY KEY,
|
|
1014
|
+
created_at INTEGER NOT NULL,
|
|
1015
|
+
descriptor_json TEXT NOT NULL
|
|
1016
|
+
) STRICT;
|
|
1017
|
+
CREATE TABLE IF NOT EXISTS hypit_submissions (
|
|
1018
|
+
build_id TEXT PRIMARY KEY,
|
|
1019
|
+
component_packages_json TEXT NOT NULL,
|
|
1020
|
+
result_location_json TEXT NOT NULL,
|
|
1021
|
+
created_at INTEGER NOT NULL
|
|
1022
|
+
) STRICT;
|
|
1023
|
+
CREATE TABLE IF NOT EXISTS hypit_executions (
|
|
1024
|
+
build_id TEXT PRIMARY KEY,
|
|
1025
|
+
component_packages_json TEXT NOT NULL,
|
|
1026
|
+
result_location_json TEXT NOT NULL,
|
|
1027
|
+
created_at INTEGER NOT NULL,
|
|
1028
|
+
wake_at INTEGER,
|
|
1029
|
+
operation_wait_json TEXT,
|
|
1030
|
+
turn_owner TEXT,
|
|
1031
|
+
turn_acquired_at INTEGER,
|
|
1032
|
+
result_writer_owner TEXT,
|
|
1033
|
+
result_writer_acquired_at INTEGER,
|
|
1034
|
+
stop_cause TEXT CHECK (stop_cause IS NULL OR stop_cause IN ('user-cancelled', 'execution-failed')),
|
|
1035
|
+
stop_reason TEXT,
|
|
1036
|
+
decision_outcome TEXT CHECK (
|
|
1037
|
+
decision_outcome IS NULL OR decision_outcome IN ('complete', 'failed', 'cancelled')
|
|
1038
|
+
),
|
|
1039
|
+
decision_reason TEXT,
|
|
1040
|
+
attention_step TEXT CHECK (attention_step IS NULL OR attention_step IN ('result', 'cleanup')),
|
|
1041
|
+
attention_error TEXT,
|
|
1042
|
+
CHECK ((turn_owner IS NULL) = (turn_acquired_at IS NULL)),
|
|
1043
|
+
CHECK ((result_writer_owner IS NULL) = (result_writer_acquired_at IS NULL)),
|
|
1044
|
+
CHECK ((attention_step IS NULL) = (attention_error IS NULL))
|
|
1045
|
+
) STRICT;
|
|
1046
|
+
CREATE INDEX IF NOT EXISTS hypit_execution_ready
|
|
1047
|
+
ON hypit_executions (decision_outcome, turn_owner, wake_at);
|
|
1048
|
+
CREATE TABLE IF NOT EXISTS hypit_capacity (
|
|
1049
|
+
build_id TEXT NOT NULL,
|
|
1050
|
+
command_id TEXT NOT NULL,
|
|
1051
|
+
resources_json TEXT NOT NULL,
|
|
1052
|
+
created_at INTEGER NOT NULL,
|
|
1053
|
+
lifetime TEXT NOT NULL CHECK (lifetime IN ('action', 'operation')),
|
|
1054
|
+
PRIMARY KEY (build_id, command_id)
|
|
1055
|
+
) STRICT;
|
|
1056
|
+
CREATE TABLE IF NOT EXISTS hypit_resource_waits (
|
|
1057
|
+
build_id TEXT NOT NULL, command_id TEXT NOT NULL, resource_id TEXT NOT NULL,
|
|
1058
|
+
resources_json TEXT NOT NULL, PRIMARY KEY (build_id, command_id)
|
|
1059
|
+
) STRICT;
|
|
1060
|
+
CREATE INDEX IF NOT EXISTS hypit_resource_waiters ON hypit_resource_waits (resource_id);
|
|
1061
|
+
CREATE TABLE IF NOT EXISTS hypit_rates (
|
|
1062
|
+
resource_id TEXT PRIMARY KEY, limit_units INTEGER NOT NULL, period_ms INTEGER NOT NULL,
|
|
1063
|
+
tokens REAL NOT NULL, updated_at INTEGER NOT NULL
|
|
1064
|
+
) STRICT;
|
|
1065
|
+
CREATE TABLE IF NOT EXISTS hypit_runtime_environment (
|
|
1066
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
1067
|
+
config_json TEXT NOT NULL
|
|
1068
|
+
) STRICT;
|
|
1069
|
+
`);
|
|
1070
|
+
this.builds = new SqliteBuildStore(database);
|
|
1071
|
+
this.operations = new SqliteOperationStore(database);
|
|
1072
|
+
this.commandExecutions = new SqliteCommandExecutionStore(database);
|
|
1073
|
+
this.execution = new SqliteBuildExecutionStore(database);
|
|
1074
|
+
this.catalog = new SqliteBuildCatalog(database);
|
|
1075
|
+
this.environment = new SqliteRuntimeEnvironmentStore(database);
|
|
1076
|
+
this.submissions = new SqlitePendingBuildStore(database);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/** Remove the complete active Runtime aggregate in one transaction, deleting its root last. */
|
|
1080
|
+
async removeActiveBuild(build: string): Promise<import("@hypit/runtime").BuildCompletion> {
|
|
1081
|
+
return transaction(this.#database, () => {
|
|
1082
|
+
const row = this.#database.prepare("SELECT * FROM hypit_executions WHERE build_id = ?").get(build) as Row | undefined;
|
|
1083
|
+
if (row === undefined) throw new Error(`Execution ${build} does not exist`);
|
|
1084
|
+
const current = parseExecutionSnapshot(row);
|
|
1085
|
+
assert(current.decision !== undefined, `Execution ${build} has no decision`);
|
|
1086
|
+
this.#database.prepare("DELETE FROM hypit_capacity WHERE build_id = ?").run(build);
|
|
1087
|
+
this.#database.prepare("DELETE FROM hypit_resource_waits WHERE build_id = ?").run(build);
|
|
1088
|
+
this.#database.prepare("DELETE FROM hypit_operations WHERE build_id = ?").run(build);
|
|
1089
|
+
this.#database.prepare("DELETE FROM hypit_command_executions WHERE build_id = ?").run(build);
|
|
1090
|
+
this.#database.prepare("DELETE FROM hypit_build_facts WHERE build_id = ?").run(build);
|
|
1091
|
+
this.#database.prepare("DELETE FROM hypit_build_catalog WHERE build_id = ?").run(build);
|
|
1092
|
+
this.#database.prepare("DELETE FROM hypit_builds WHERE build_id = ?").run(build);
|
|
1093
|
+
this.#database.prepare("DELETE FROM hypit_executions WHERE build_id = ?").run(build);
|
|
1094
|
+
return { build, ...current.decision };
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
close(): void {
|
|
1099
|
+
this.#database.close();
|
|
1100
|
+
}
|
|
1101
|
+
}
|