@clockgrove/assetgrove 0.0.0-stage → 0.3.2
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 +21 -0
- package/README.md +277 -2
- package/dist/animation/commands.d.ts +180 -0
- package/dist/animation/commands.js +515 -0
- package/dist/animation/facing.d.ts +44 -0
- package/dist/animation/facing.js +100 -0
- package/dist/animation/fix.d.ts +136 -0
- package/dist/animation/fix.js +529 -0
- package/dist/animation/flicker.d.ts +44 -0
- package/dist/animation/flicker.js +117 -0
- package/dist/animation/halo.d.ts +72 -0
- package/dist/animation/halo.js +253 -0
- package/dist/animation/holes.d.ts +122 -0
- package/dist/animation/holes.js +262 -0
- package/dist/animation/preview.d.ts +38 -0
- package/dist/animation/preview.js +161 -0
- package/dist/animation/qa.d.ts +57 -0
- package/dist/animation/qa.js +418 -0
- package/dist/animation/run.d.ts +109 -0
- package/dist/animation/run.js +182 -0
- package/dist/animation/strip.d.ts +13 -0
- package/dist/animation/strip.js +41 -0
- package/dist/animation/template-choice.d.ts +75 -0
- package/dist/animation/template-choice.js +153 -0
- package/dist/animation/templates.d.ts +39 -0
- package/dist/animation/templates.js +333 -0
- package/dist/animation/types.d.ts +257 -0
- package/dist/animation/types.js +1 -0
- package/dist/approvals.d.ts +156 -0
- package/dist/approvals.js +369 -0
- package/dist/audio/aac.d.ts +61 -0
- package/dist/audio/aac.js +152 -0
- package/dist/audio/checks.d.ts +38 -0
- package/dist/audio/checks.js +254 -0
- package/dist/audio/delivery.d.ts +52 -0
- package/dist/audio/delivery.js +105 -0
- package/dist/audio/engine.d.ts +65 -0
- package/dist/audio/engine.js +164 -0
- package/dist/audio/handoff.d.ts +75 -0
- package/dist/audio/handoff.js +185 -0
- package/dist/audio/kinds.d.ts +6 -0
- package/dist/audio/kinds.js +315 -0
- package/dist/audio/loudness.d.ts +22 -0
- package/dist/audio/loudness.js +72 -0
- package/dist/audio/ogg.d.ts +27 -0
- package/dist/audio/ogg.js +65 -0
- package/dist/audio/operations.d.ts +20 -0
- package/dist/audio/operations.js +335 -0
- package/dist/audio/opus.d.ts +40 -0
- package/dist/audio/opus.js +108 -0
- package/dist/audio/profile.d.ts +200 -0
- package/dist/audio/profile.js +126 -0
- package/dist/audio/run.d.ts +83 -0
- package/dist/audio/run.js +192 -0
- package/dist/audio/vorbis-comments.d.ts +25 -0
- package/dist/audio/vorbis-comments.js +243 -0
- package/dist/audio/waveform.d.ts +13 -0
- package/dist/audio/waveform.js +52 -0
- package/dist/audio-parameters.d.ts +17 -0
- package/dist/audio-parameters.js +45 -0
- package/dist/audit/bar.d.ts +65 -0
- package/dist/audit/bar.js +97 -0
- package/dist/audit/members.d.ts +40 -0
- package/dist/audit/members.js +119 -0
- package/dist/bible-view.d.ts +10 -0
- package/dist/bible-view.js +122 -0
- package/dist/bible.d.ts +272 -0
- package/dist/bible.js +641 -0
- package/dist/budget.d.ts +119 -0
- package/dist/budget.js +227 -0
- package/dist/call-parameters.d.ts +71 -0
- package/dist/call-parameters.js +90 -0
- package/dist/calls.d.ts +145 -0
- package/dist/calls.js +788 -0
- package/dist/cli/main.d.ts +22 -0
- package/dist/cli/main.js +137 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +5 -0
- package/dist/commands/animation-qa.d.ts +1 -0
- package/dist/commands/animation-qa.js +240 -0
- package/dist/commands/apply.d.ts +12 -0
- package/dist/commands/apply.js +181 -0
- package/dist/commands/audit.d.ts +92 -0
- package/dist/commands/audit.js +555 -0
- package/dist/commands/bible.d.ts +1 -0
- package/dist/commands/bible.js +39 -0
- package/dist/commands/browse.d.ts +12 -0
- package/dist/commands/browse.js +113 -0
- package/dist/commands/card.d.ts +3 -0
- package/dist/commands/card.js +445 -0
- package/dist/commands/compare.d.ts +1 -0
- package/dist/commands/compare.js +90 -0
- package/dist/commands/confirm.d.ts +1 -0
- package/dist/commands/confirm.js +267 -0
- package/dist/commands/context.d.ts +43 -0
- package/dist/commands/context.js +115 -0
- package/dist/commands/deliver.d.ts +1 -0
- package/dist/commands/deliver.js +99 -0
- package/dist/commands/disclosure.d.ts +1 -0
- package/dist/commands/disclosure.js +80 -0
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.js +112 -0
- package/dist/commands/estimate.d.ts +2 -0
- package/dist/commands/estimate.js +80 -0
- package/dist/commands/extensions.d.ts +2 -0
- package/dist/commands/extensions.js +70 -0
- package/dist/commands/fix-frame.d.ts +1 -0
- package/dist/commands/fix-frame.js +206 -0
- package/dist/commands/generate-sheet.d.ts +1 -0
- package/dist/commands/generate-sheet.js +245 -0
- package/dist/commands/identity-check.d.ts +1 -0
- package/dist/commands/identity-check.js +110 -0
- package/dist/commands/identity-eval.d.ts +1 -0
- package/dist/commands/identity-eval.js +197 -0
- package/dist/commands/import.d.ts +7 -0
- package/dist/commands/import.js +472 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +117 -0
- package/dist/commands/intake.d.ts +1 -0
- package/dist/commands/intake.js +56 -0
- package/dist/commands/labels.d.ts +1 -0
- package/dist/commands/labels.js +101 -0
- package/dist/commands/library.d.ts +9 -0
- package/dist/commands/library.js +711 -0
- package/dist/commands/lod.d.ts +1 -0
- package/dist/commands/lod.js +93 -0
- package/dist/commands/look-dev.d.ts +1 -0
- package/dist/commands/look-dev.js +148 -0
- package/dist/commands/materials.d.ts +1 -0
- package/dist/commands/materials.js +223 -0
- package/dist/commands/mcp.d.ts +1 -0
- package/dist/commands/mcp.js +53 -0
- package/dist/commands/migrate.d.ts +1 -0
- package/dist/commands/migrate.js +123 -0
- package/dist/commands/op.d.ts +5 -0
- package/dist/commands/op.js +114 -0
- package/dist/commands/ops.d.ts +1 -0
- package/dist/commands/ops.js +17 -0
- package/dist/commands/pick-batch.d.ts +24 -0
- package/dist/commands/pick-batch.js +343 -0
- package/dist/commands/pick.d.ts +48 -0
- package/dist/commands/pick.js +469 -0
- package/dist/commands/plan.d.ts +3 -0
- package/dist/commands/plan.js +156 -0
- package/dist/commands/recipe.d.ts +1 -0
- package/dist/commands/recipe.js +52 -0
- package/dist/commands/registry.d.ts +5 -0
- package/dist/commands/registry.js +121 -0
- package/dist/commands/render-sprite.d.ts +1 -0
- package/dist/commands/render-sprite.js +67 -0
- package/dist/commands/rendition.d.ts +1 -0
- package/dist/commands/rendition.js +56 -0
- package/dist/commands/request-change.d.ts +2 -0
- package/dist/commands/request-change.js +950 -0
- package/dist/commands/result.d.ts +34 -0
- package/dist/commands/result.js +237 -0
- package/dist/commands/review.d.ts +28 -0
- package/dist/commands/review.js +444 -0
- package/dist/commands/rig.d.ts +1 -0
- package/dist/commands/rig.js +74 -0
- package/dist/commands/runner.d.ts +45 -0
- package/dist/commands/runner.js +297 -0
- package/dist/commands/runs.d.ts +22 -0
- package/dist/commands/runs.js +159 -0
- package/dist/commands/search.d.ts +69 -0
- package/dist/commands/search.js +638 -0
- package/dist/commands/settings.d.ts +2 -0
- package/dist/commands/settings.js +284 -0
- package/dist/commands/spend.d.ts +2 -0
- package/dist/commands/spend.js +159 -0
- package/dist/commands/stage-source.d.ts +1 -0
- package/dist/commands/stage-source.js +58 -0
- package/dist/commands/stage.d.ts +9 -0
- package/dist/commands/stage.js +229 -0
- package/dist/commands/storage.d.ts +3 -0
- package/dist/commands/storage.js +200 -0
- package/dist/commands/turnaround.d.ts +1 -0
- package/dist/commands/turnaround.js +171 -0
- package/dist/commands/types.d.ts +195 -0
- package/dist/commands/types.js +7 -0
- package/dist/commands/vary.d.ts +2 -0
- package/dist/commands/vary.js +222 -0
- package/dist/commands/write-families.d.ts +14 -0
- package/dist/commands/write-families.js +158 -0
- package/dist/compare.d.ts +87 -0
- package/dist/compare.js +306 -0
- package/dist/confirm/delegation.d.ts +30 -0
- package/dist/confirm/delegation.js +31 -0
- package/dist/confirm/index.d.ts +84 -0
- package/dist/confirm/index.js +176 -0
- package/dist/confirm/mcp.d.ts +60 -0
- package/dist/confirm/mcp.js +253 -0
- package/dist/confirm/pending.d.ts +11 -0
- package/dist/confirm/pending.js +40 -0
- package/dist/confirm/prompt.d.ts +65 -0
- package/dist/confirm/prompt.js +68 -0
- package/dist/confirm/records.d.ts +17 -0
- package/dist/confirm/records.js +63 -0
- package/dist/contact.d.ts +80 -0
- package/dist/contact.js +224 -0
- package/dist/credentials.d.ts +170 -0
- package/dist/credentials.js +598 -0
- package/dist/dataflows.d.ts +32 -0
- package/dist/dataflows.js +42 -0
- package/dist/delivery.d.ts +89 -0
- package/dist/delivery.js +355 -0
- package/dist/disclosure.d.ts +84 -0
- package/dist/disclosure.js +397 -0
- package/dist/env.d.ts +90 -0
- package/dist/env.js +236 -0
- package/dist/errors.d.ts +90 -0
- package/dist/errors.js +105 -0
- package/dist/extension/api.d.ts +389 -0
- package/dist/extension/api.js +20 -0
- package/dist/extension/context.d.ts +9 -0
- package/dist/extension/context.js +60 -0
- package/dist/extension/helpers.d.ts +75 -0
- package/dist/extension/helpers.js +107 -0
- package/dist/extension/http.d.ts +32 -0
- package/dist/extension/http.js +104 -0
- package/dist/extension/setup.d.ts +53 -0
- package/dist/extension/setup.js +162 -0
- package/dist/extension/tools.d.ts +97 -0
- package/dist/extension/tools.js +235 -0
- package/dist/extensions/core.d.ts +7 -0
- package/dist/extensions/core.js +18 -0
- package/dist/extensions/errors.d.ts +22 -0
- package/dist/extensions/errors.js +34 -0
- package/dist/extensions/registry.d.ts +119 -0
- package/dist/extensions/registry.js +535 -0
- package/dist/extensions/version.d.ts +9 -0
- package/dist/extensions/version.js +57 -0
- package/dist/formats.d.ts +46 -0
- package/dist/formats.js +81 -0
- package/dist/frames.d.ts +58 -0
- package/dist/frames.js +80 -0
- package/dist/gateway/anthropic.d.ts +22 -0
- package/dist/gateway/anthropic.js +65 -0
- package/dist/gateway/elevenlabs.d.ts +36 -0
- package/dist/gateway/elevenlabs.js +192 -0
- package/dist/gateway/failure.d.ts +29 -0
- package/dist/gateway/failure.js +70 -0
- package/dist/gateway/openai-compatible.d.ts +20 -0
- package/dist/gateway/openai-compatible.js +76 -0
- package/dist/gateway/openai.d.ts +28 -0
- package/dist/gateway/openai.js +101 -0
- package/dist/gateway/provider.d.ts +380 -0
- package/dist/gateway/provider.js +5 -0
- package/dist/gateway/scripted.d.ts +252 -0
- package/dist/gateway/scripted.js +244 -0
- package/dist/gateway/stability.d.ts +38 -0
- package/dist/gateway/stability.js +232 -0
- package/dist/gateway/structured.d.ts +31 -0
- package/dist/gateway/structured.js +83 -0
- package/dist/gateway/tripo.d.ts +48 -0
- package/dist/gateway/tripo.js +374 -0
- package/dist/gateway/vercel.d.ts +52 -0
- package/dist/gateway/vercel.js +298 -0
- package/dist/generators/generator.d.ts +236 -0
- package/dist/generators/generator.js +12 -0
- package/dist/generators/image.d.ts +21 -0
- package/dist/generators/image.js +286 -0
- package/dist/generators/spec-schema.d.ts +29 -0
- package/dist/generators/spec-schema.js +21 -0
- package/dist/git-marker.d.ts +3 -0
- package/dist/git-marker.js +13 -0
- package/dist/gitlfs.d.ts +38 -0
- package/dist/gitlfs.js +171 -0
- package/dist/guard.d.ts +55 -0
- package/dist/guard.js +323 -0
- package/dist/handoff/current-profile.d.ts +48 -0
- package/dist/handoff/current-profile.js +127 -0
- package/dist/handoff/doctor.d.ts +26 -0
- package/dist/handoff/doctor.js +249 -0
- package/dist/handoff/mark-check.d.ts +17 -0
- package/dist/handoff/mark-check.js +66 -0
- package/dist/handoff/presets/aseprite-json.d.ts +5 -0
- package/dist/handoff/presets/aseprite-json.js +45 -0
- package/dist/handoff/presets/atlas-json.d.ts +44 -0
- package/dist/handoff/presets/atlas-json.js +195 -0
- package/dist/handoff/presets/atlas-pack.d.ts +14 -0
- package/dist/handoff/presets/atlas-pack.js +431 -0
- package/dist/handoff/presets/index.d.ts +273 -0
- package/dist/handoff/presets/index.js +58 -0
- package/dist/handoff/presets/manifest.d.ts +2 -0
- package/dist/handoff/presets/manifest.js +49 -0
- package/dist/handoff/usage.d.ts +27 -0
- package/dist/handoff/usage.js +159 -0
- package/dist/handoff.d.ts +345 -0
- package/dist/handoff.js +1221 -0
- package/dist/identity-eval.d.ts +156 -0
- package/dist/identity-eval.js +321 -0
- package/dist/identity.d.ts +293 -0
- package/dist/identity.js +675 -0
- package/dist/image/apply-style.d.ts +4 -0
- package/dist/image/apply-style.js +37 -0
- package/dist/image/digits.d.ts +5 -0
- package/dist/image/digits.js +40 -0
- package/dist/image/ktx2.d.ts +83 -0
- package/dist/image/ktx2.js +196 -0
- package/dist/image/raster.d.ts +23 -0
- package/dist/image/raster.js +77 -0
- package/dist/image/resample.d.ts +10 -0
- package/dist/image/resample.js +82 -0
- package/dist/image/webp.d.ts +17 -0
- package/dist/image/webp.js +323 -0
- package/dist/init.d.ts +132 -0
- package/dist/init.js +425 -0
- package/dist/inputs.d.ts +67 -0
- package/dist/inputs.js +151 -0
- package/dist/json.d.ts +7 -0
- package/dist/json.js +27 -0
- package/dist/keys.d.ts +34 -0
- package/dist/keys.js +198 -0
- package/dist/kind-schemas.d.ts +17 -0
- package/dist/kind-schemas.js +205 -0
- package/dist/library/actions.d.ts +76 -0
- package/dist/library/actions.js +212 -0
- package/dist/library/adopt.d.ts +177 -0
- package/dist/library/adopt.js +624 -0
- package/dist/library/canonical.d.ts +7 -0
- package/dist/library/canonical.js +29 -0
- package/dist/library/card.d.ts +138 -0
- package/dist/library/card.js +532 -0
- package/dist/library/credits.d.ts +70 -0
- package/dist/library/credits.js +222 -0
- package/dist/library/describe.d.ts +48 -0
- package/dist/library/describe.js +199 -0
- package/dist/library/diff.d.ts +26 -0
- package/dist/library/diff.js +208 -0
- package/dist/library/exact.d.ts +15 -0
- package/dist/library/exact.js +47 -0
- package/dist/library/extent.d.ts +56 -0
- package/dist/library/extent.js +205 -0
- package/dist/library/folder.d.ts +85 -0
- package/dist/library/folder.js +291 -0
- package/dist/library/labels.d.ts +29 -0
- package/dist/library/labels.js +112 -0
- package/dist/library/lfs.d.ts +42 -0
- package/dist/library/lfs.js +140 -0
- package/dist/library/maintain.d.ts +100 -0
- package/dist/library/maintain.js +750 -0
- package/dist/library/media-metadata.d.ts +19 -0
- package/dist/library/media-metadata.js +92 -0
- package/dist/library/paths.d.ts +7 -0
- package/dist/library/paths.js +65 -0
- package/dist/library/relations.d.ts +59 -0
- package/dist/library/relations.js +176 -0
- package/dist/library/review.d.ts +204 -0
- package/dist/library/review.js +545 -0
- package/dist/library/stale.d.ts +88 -0
- package/dist/library/stale.js +229 -0
- package/dist/library/suggestions.d.ts +37 -0
- package/dist/library/suggestions.js +146 -0
- package/dist/library/summary.d.ts +65 -0
- package/dist/library/summary.js +138 -0
- package/dist/library/undo.d.ts +18 -0
- package/dist/library/undo.js +141 -0
- package/dist/library/worklist.d.ts +42 -0
- package/dist/library/worklist.js +91 -0
- package/dist/library/write.d.ts +282 -0
- package/dist/library/write.js +790 -0
- package/dist/license.d.ts +67 -0
- package/dist/license.js +205 -0
- package/dist/limits.d.ts +51 -0
- package/dist/limits.js +100 -0
- package/dist/loop.d.ts +244 -0
- package/dist/loop.js +377 -0
- package/dist/material/core.d.ts +70 -0
- package/dist/material/core.js +238 -0
- package/dist/material/engine.d.ts +15 -0
- package/dist/material/engine.js +141 -0
- package/dist/material/flicker.d.ts +26 -0
- package/dist/material/flicker.js +71 -0
- package/dist/material/operations.d.ts +2 -0
- package/dist/material/operations.js +48 -0
- package/dist/material/pipeline.d.ts +51 -0
- package/dist/material/pipeline.js +431 -0
- package/dist/material/profile.d.ts +29 -0
- package/dist/material/profile.js +97 -0
- package/dist/material/rendition.d.ts +5 -0
- package/dist/material/rendition.js +76 -0
- package/dist/mcp.d.ts +72 -0
- package/dist/mcp.js +514 -0
- package/dist/media.d.ts +36 -0
- package/dist/media.js +46 -0
- package/dist/metadata.d.ts +61 -0
- package/dist/metadata.js +748 -0
- package/dist/model-declarations.d.ts +28 -0
- package/dist/model-declarations.js +14 -0
- package/dist/model3d/clip-map.d.ts +49 -0
- package/dist/model3d/clip-map.js +129 -0
- package/dist/model3d/core-checks.d.ts +61 -0
- package/dist/model3d/core-checks.js +278 -0
- package/dist/model3d/facing.d.ts +49 -0
- package/dist/model3d/facing.js +125 -0
- package/dist/model3d/generator.d.ts +19 -0
- package/dist/model3d/generator.js +482 -0
- package/dist/model3d/glb.d.ts +120 -0
- package/dist/model3d/glb.js +155 -0
- package/dist/model3d/handoff.d.ts +37 -0
- package/dist/model3d/handoff.js +131 -0
- package/dist/model3d/lod/chain.d.ts +50 -0
- package/dist/model3d/lod/chain.js +447 -0
- package/dist/model3d/lod/command.d.ts +38 -0
- package/dist/model3d/lod/command.js +377 -0
- package/dist/model3d/lod/qa.d.ts +36 -0
- package/dist/model3d/lod/qa.js +189 -0
- package/dist/model3d/lod/settings.d.ts +36 -0
- package/dist/model3d/lod/settings.js +137 -0
- package/dist/model3d/lod/simplify.d.ts +35 -0
- package/dist/model3d/lod/simplify.js +337 -0
- package/dist/model3d/lod/textures.d.ts +46 -0
- package/dist/model3d/lod/textures.js +190 -0
- package/dist/model3d/lookdev/command.d.ts +219 -0
- package/dist/model3d/lookdev/command.js +1795 -0
- package/dist/model3d/lookdev/edit.d.ts +44 -0
- package/dist/model3d/lookdev/edit.js +241 -0
- package/dist/model3d/lookdev/groom.d.ts +86 -0
- package/dist/model3d/lookdev/groom.js +462 -0
- package/dist/model3d/lookdev/markings.d.ts +98 -0
- package/dist/model3d/lookdev/markings.js +319 -0
- package/dist/model3d/lookdev/project.d.ts +100 -0
- package/dist/model3d/lookdev/project.js +721 -0
- package/dist/model3d/lookdev/settings.d.ts +65 -0
- package/dist/model3d/lookdev/settings.js +103 -0
- package/dist/model3d/lookdev/texels.d.ts +32 -0
- package/dist/model3d/lookdev/texels.js +192 -0
- package/dist/model3d/profile.d.ts +101 -0
- package/dist/model3d/profile.js +132 -0
- package/dist/model3d/prop.d.ts +29 -0
- package/dist/model3d/prop.js +317 -0
- package/dist/model3d/qa.d.ts +27 -0
- package/dist/model3d/qa.js +105 -0
- package/dist/model3d/render.d.ts +172 -0
- package/dist/model3d/render.js +791 -0
- package/dist/model3d/rig/build.d.ts +14 -0
- package/dist/model3d/rig/build.js +210 -0
- package/dist/model3d/rig/candidate.d.ts +50 -0
- package/dist/model3d/rig/candidate.js +132 -0
- package/dist/model3d/rig/command.d.ts +50 -0
- package/dist/model3d/rig/command.js +229 -0
- package/dist/model3d/rig/fit.d.ts +88 -0
- package/dist/model3d/rig/fit.js +568 -0
- package/dist/model3d/rig/gait.d.ts +105 -0
- package/dist/model3d/rig/gait.js +334 -0
- package/dist/model3d/rig/math.d.ts +27 -0
- package/dist/model3d/rig/math.js +92 -0
- package/dist/model3d/rig/motion.d.ts +26 -0
- package/dist/model3d/rig/motion.js +223 -0
- package/dist/model3d/rig/qa.d.ts +76 -0
- package/dist/model3d/rig/qa.js +357 -0
- package/dist/model3d/rig/rig.d.ts +55 -0
- package/dist/model3d/rig/rig.js +213 -0
- package/dist/model3d/rig/template.d.ts +195 -0
- package/dist/model3d/rig/template.js +456 -0
- package/dist/model3d/scene.d.ts +115 -0
- package/dist/model3d/scene.js +684 -0
- package/dist/model3d/views.d.ts +77 -0
- package/dist/model3d/views.js +190 -0
- package/dist/origin.d.ts +162 -0
- package/dist/origin.js +134 -0
- package/dist/paths.d.ts +53 -0
- package/dist/paths.js +240 -0
- package/dist/planning.d.ts +261 -0
- package/dist/planning.js +1470 -0
- package/dist/policy/blocklist.d.ts +28 -0
- package/dist/policy/blocklist.js +58 -0
- package/dist/policy/brief.d.ts +67 -0
- package/dist/policy/brief.js +110 -0
- package/dist/policy/cuts.d.ts +26 -0
- package/dist/policy/cuts.js +80 -0
- package/dist/policy/model.d.ts +69 -0
- package/dist/policy/model.js +202 -0
- package/dist/policy/text.d.ts +183 -0
- package/dist/policy/text.js +285 -0
- package/dist/postprocess.d.ts +68 -0
- package/dist/postprocess.js +302 -0
- package/dist/profile.d.ts +5 -0
- package/dist/profile.js +98 -0
- package/dist/project-rules.d.ts +54 -0
- package/dist/project-rules.js +105 -0
- package/dist/provenance-binding.d.ts +55 -0
- package/dist/provenance-binding.js +352 -0
- package/dist/providers/adapter.d.ts +176 -0
- package/dist/providers/adapter.js +418 -0
- package/dist/providers/index.d.ts +33 -0
- package/dist/providers/index.js +49 -0
- package/dist/providers/script.d.ts +13 -0
- package/dist/providers/script.js +65 -0
- package/dist/providers/set.d.ts +76 -0
- package/dist/providers/set.js +134 -0
- package/dist/pure-cbor.d.ts +1 -0
- package/dist/pure-cbor.js +8 -0
- package/dist/qa/stability.d.ts +215 -0
- package/dist/qa/stability.js +393 -0
- package/dist/qa/stability.json +32 -0
- package/dist/qa.d.ts +36 -0
- package/dist/qa.js +148 -0
- package/dist/reconcile.d.ts +111 -0
- package/dist/reconcile.js +416 -0
- package/dist/redact.d.ts +29 -0
- package/dist/redact.js +74 -0
- package/dist/regions.d.ts +49 -0
- package/dist/regions.js +113 -0
- package/dist/release-policy.d.ts +99 -0
- package/dist/release-policy.js +266 -0
- package/dist/request.d.ts +74 -0
- package/dist/request.js +249 -0
- package/dist/routes.d.ts +327 -0
- package/dist/routes.js +1166 -0
- package/dist/runs/dir.d.ts +33 -0
- package/dist/runs/dir.js +30 -0
- package/dist/runs/execute.d.ts +86 -0
- package/dist/runs/execute.js +422 -0
- package/dist/runs/journal.d.ts +150 -0
- package/dist/runs/journal.js +216 -0
- package/dist/runs/lock.d.ts +57 -0
- package/dist/runs/lock.js +322 -0
- package/dist/runs/plan.d.ts +261 -0
- package/dist/runs/plan.js +404 -0
- package/dist/search/near-match.d.ts +32 -0
- package/dist/search/near-match.js +86 -0
- package/dist/search/reader.d.ts +17 -0
- package/dist/search/reader.js +334 -0
- package/dist/search/sheet.d.ts +4 -0
- package/dist/search/sheet.js +28 -0
- package/dist/search/style-outliers.d.ts +77 -0
- package/dist/search/style-outliers.js +166 -0
- package/dist/settings-write.d.ts +78 -0
- package/dist/settings-write.js +374 -0
- package/dist/settings.d.ts +436 -0
- package/dist/settings.js +622 -0
- package/dist/shared-settings.d.ts +4 -0
- package/dist/shared-settings.js +24 -0
- package/dist/sheet/blobs.d.ts +33 -0
- package/dist/sheet/blobs.js +145 -0
- package/dist/sheet/generate.d.ts +71 -0
- package/dist/sheet/generate.js +278 -0
- package/dist/sheet/group.d.ts +20 -0
- package/dist/sheet/group.js +191 -0
- package/dist/sheet/import.d.ts +315 -0
- package/dist/sheet/import.js +832 -0
- package/dist/sheet/matte.d.ts +25 -0
- package/dist/sheet/matte.js +508 -0
- package/dist/sheet/media-import.d.ts +41 -0
- package/dist/sheet/media-import.js +118 -0
- package/dist/sheet/register.d.ts +17 -0
- package/dist/sheet/register.js +176 -0
- package/dist/sheet/slice.d.ts +73 -0
- package/dist/sheet/slice.js +912 -0
- package/dist/sheet/types.d.ts +225 -0
- package/dist/sheet/types.js +1 -0
- package/dist/source/aseprite.d.ts +14 -0
- package/dist/source/aseprite.js +124 -0
- package/dist/source/stage.d.ts +24 -0
- package/dist/source/stage.js +172 -0
- package/dist/spend.d.ts +220 -0
- package/dist/spend.js +436 -0
- package/dist/sprite/render.d.ts +22 -0
- package/dist/sprite/render.js +272 -0
- package/dist/storage.d.ts +135 -0
- package/dist/storage.js +405 -0
- package/dist/style.d.ts +19 -0
- package/dist/style.js +26 -0
- package/dist/template.d.ts +29 -0
- package/dist/template.js +98 -0
- package/dist/testing/aseprite.d.ts +54 -0
- package/dist/testing/aseprite.js +191 -0
- package/dist/testing/cli.d.ts +24 -0
- package/dist/testing/cli.js +91 -0
- package/dist/testing/conformance.d.ts +61 -0
- package/dist/testing/conformance.js +455 -0
- package/dist/testing/index.d.ts +23 -0
- package/dist/testing/index.js +15 -0
- package/dist/testing/mcp.d.ts +25 -0
- package/dist/testing/mcp.js +80 -0
- package/dist/testing/project.d.ts +81 -0
- package/dist/testing/project.js +215 -0
- package/dist/testing/samples.d.ts +42 -0
- package/dist/testing/samples.js +122 -0
- package/dist/transform/operations.d.ts +5 -0
- package/dist/transform/operations.js +320 -0
- package/dist/transform/raster-engine.d.ts +9 -0
- package/dist/transform/raster-engine.js +329 -0
- package/dist/transform/rendition.d.ts +65 -0
- package/dist/transform/rendition.js +317 -0
- package/dist/transform/run.d.ts +138 -0
- package/dist/transform/run.js +442 -0
- package/dist/transform/schema.d.ts +33 -0
- package/dist/transform/schema.js +73 -0
- package/dist/transform/types.d.ts +101 -0
- package/dist/transform/types.js +1 -0
- package/dist/tree/address.d.ts +18 -0
- package/dist/tree/address.js +59 -0
- package/dist/tree/list.d.ts +18 -0
- package/dist/tree/list.js +101 -0
- package/dist/tree/project.d.ts +61 -0
- package/dist/tree/project.js +145 -0
- package/dist/tree/read.d.ts +43 -0
- package/dist/tree/read.js +715 -0
- package/dist/tree/search.d.ts +20 -0
- package/dist/tree/search.js +44 -0
- package/dist/tree/serve.d.ts +79 -0
- package/dist/tree/serve.js +415 -0
- package/dist/tree/thumbs.d.ts +26 -0
- package/dist/tree/thumbs.js +134 -0
- package/dist/turnaround.d.ts +195 -0
- package/dist/turnaround.js +622 -0
- package/dist/types.d.ts +595 -0
- package/dist/types.js +1 -0
- package/package.json +112 -3
- package/policy/blocklist.json +47 -0
- package/policy/prompt-policy-cuts.json +15 -0
- package/skills/art-direction/SKILL.md +16 -0
- package/skills/art-direction/default.md +14 -0
- package/skills/art-direction/presets/cozy-storybook.md +121 -0
- package/skills/art-direction/presets/dark-gritty-isometric.md +121 -0
- package/skills/art-direction/presets/flat-cartoon-kids.md +121 -0
- package/skills/art-direction/references/bible-format.md +47 -0
- package/skills/assetgrove/SKILL.md +109 -0
- package/skills/assetgrove/references/commands.md +723 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { ConfiguredProvider } from "./providers/adapter.ts";
|
|
2
|
+
import type { Settings } from "./settings.ts";
|
|
3
|
+
export declare const RECONCILE_FILE = "reconcile.jsonl";
|
|
4
|
+
/** In the run directory: what the run's attempts have reconciled, and the open attempt's start. */
|
|
5
|
+
export declare const RUN_RECONCILE_STATE_FILE = "reconcile-state.json";
|
|
6
|
+
/** A pending lookup still unanswered this many hours after its run resolves as `failed`, unless `reconcile.pendingMaxAgeHours` says otherwise. */
|
|
7
|
+
export declare const DEFAULT_PENDING_MAX_AGE_HOURS = 24;
|
|
8
|
+
export declare const PENDING_MAX_AGE_MS: number;
|
|
9
|
+
export type ReconcileStatus = "unavailable" | "reconciled" | "pending" | "held" | "failed";
|
|
10
|
+
/** One provider's reconcile in a run record (`run.json` `reconcile`) or a `spend reconcile` result. */
|
|
11
|
+
export interface ReconcileEntry {
|
|
12
|
+
provider: string;
|
|
13
|
+
status: ReconcileStatus;
|
|
14
|
+
/** How the provider reports usage; absent when it reports none. */
|
|
15
|
+
method?: "per-call-cost";
|
|
16
|
+
runId?: string;
|
|
17
|
+
ledgerUsd?: number;
|
|
18
|
+
providerUsd?: number;
|
|
19
|
+
gapUsd?: number;
|
|
20
|
+
marginUsd?: number;
|
|
21
|
+
/** The hold appended, when the gap is above the margin. */
|
|
22
|
+
holdId?: string;
|
|
23
|
+
/** The pending lookup's id, while the provider has not reported every call. */
|
|
24
|
+
pendingId?: string;
|
|
25
|
+
/** Paid calls that cannot be looked up (no journaled request ID from the provider). */
|
|
26
|
+
unmatched?: number;
|
|
27
|
+
/** Estimate-sourced calls settled to the provider's looked-up cost instead of compared. */
|
|
28
|
+
settled?: number;
|
|
29
|
+
note?: string;
|
|
30
|
+
}
|
|
31
|
+
/** What reconciling reads: the settings and the providers they make. */
|
|
32
|
+
export interface ReconcileContext {
|
|
33
|
+
settings: Pick<Settings, "stateDir" | "caps" | "reconcile" | "spend">;
|
|
34
|
+
providers: readonly ConfiguredProvider[];
|
|
35
|
+
now?: () => Date;
|
|
36
|
+
}
|
|
37
|
+
/** One call of a pending lookup: its request ID and what the ledger counts for it. */
|
|
38
|
+
interface PendingCall {
|
|
39
|
+
requestId: string;
|
|
40
|
+
ledgerUsd: number;
|
|
41
|
+
/** The ledger reservation; absent in older pending records. */
|
|
42
|
+
id?: string;
|
|
43
|
+
/** Where the ledger's cost came from; absent (older records) counts as the provider's. */
|
|
44
|
+
costSource?: "provider" | "estimate";
|
|
45
|
+
/** The call's route and its estimate, the most it may cost; absent in older pending records. */
|
|
46
|
+
route?: string;
|
|
47
|
+
ceilingUsd?: number;
|
|
48
|
+
}
|
|
49
|
+
interface PendingRecord {
|
|
50
|
+
op: "pending";
|
|
51
|
+
id: string;
|
|
52
|
+
at: string;
|
|
53
|
+
provider: string;
|
|
54
|
+
runId: string;
|
|
55
|
+
calls: PendingCall[];
|
|
56
|
+
unmatched: number;
|
|
57
|
+
}
|
|
58
|
+
/** What a run took at its start for reconciling at its end. */
|
|
59
|
+
export interface RunReconcile {
|
|
60
|
+
runId: string;
|
|
61
|
+
runDir: string;
|
|
62
|
+
/** The paid providers the plan names, by settings id. */
|
|
63
|
+
providers: string[];
|
|
64
|
+
}
|
|
65
|
+
/** The margin a gap must pass: max(marginUsd, marginPct% of the ledger spend); both default to 0. */
|
|
66
|
+
export declare function marginFor(settings: Pick<Settings, "reconcile">, ledgerUsd: number): number;
|
|
67
|
+
/**
|
|
68
|
+
* The start of a paid run: retries every pending lookup, refuses the run while a hold is not
|
|
69
|
+
* acknowledged (`SpendHoldError`, exit 3 `spend_hold`).
|
|
70
|
+
*/
|
|
71
|
+
export declare function startRunReconcile(ctx: ReconcileContext, run: {
|
|
72
|
+
runId: string;
|
|
73
|
+
runDir: string;
|
|
74
|
+
providers: readonly string[];
|
|
75
|
+
}): Promise<RunReconcile>;
|
|
76
|
+
/**
|
|
77
|
+
* The reconcile of a paid run, with no hold check: a run let in past a spend hold to collect its
|
|
78
|
+
* submitted jobs still compares what it settled with the provider when it ends.
|
|
79
|
+
*/
|
|
80
|
+
export declare function runReconcileOf(ctx: ReconcileContext, run: {
|
|
81
|
+
runId: string;
|
|
82
|
+
runDir: string;
|
|
83
|
+
providers: readonly string[];
|
|
84
|
+
}): RunReconcile;
|
|
85
|
+
/** The end of a paid run: one entry per paid provider the plan names. */
|
|
86
|
+
export declare function finishRunReconcile(ctx: ReconcileContext, run: RunReconcile): Promise<ReconcileEntry[]>;
|
|
87
|
+
/**
|
|
88
|
+
* The pending lookups not yet resolved, oldest first. A retry that settled an estimate appends the
|
|
89
|
+
* lookup again under its id; the last record of an id is the one that holds.
|
|
90
|
+
*/
|
|
91
|
+
export declare function pendingLookups(stateDir: string): PendingRecord[];
|
|
92
|
+
/** An expired lookup: the provider never reported its calls in time, so nothing was compared. */
|
|
93
|
+
export interface ExpiredLookup {
|
|
94
|
+
id: string;
|
|
95
|
+
provider: string;
|
|
96
|
+
runId: string;
|
|
97
|
+
at: string;
|
|
98
|
+
resolvedAt: string;
|
|
99
|
+
}
|
|
100
|
+
/** The lookups that expired unanswered, oldest first. */
|
|
101
|
+
export declare function expiredLookups(stateDir: string): ExpiredLookup[];
|
|
102
|
+
/**
|
|
103
|
+
* Retries every pending lookup: one whose calls are all reported now is compared (and may append a
|
|
104
|
+
* hold) and marked resolved; one whose provider is no longer configured or still has a call to
|
|
105
|
+
* report stays pending, until `reconcile.pendingMaxAgeHours` after its run, when it resolves as
|
|
106
|
+
* `failed`.
|
|
107
|
+
*/
|
|
108
|
+
export declare function retryPending(ctx: ReconcileContext): Promise<ReconcileEntry[]>;
|
|
109
|
+
/** Adds the run's reconcile entries to its `run.json`, whoever wrote it. */
|
|
110
|
+
export declare function recordReconcile(runDir: string, entries: ReconcileEntry[]): Promise<void>;
|
|
111
|
+
export {};
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reconcile (design section 3): the spend ledger is an estimate, so where a provider reports its
|
|
3
|
+
* own usage to an ordinary key, a run's ledger spend is compared with it when the run ends. The
|
|
4
|
+
* gateway and Tripo can look up each call's cost (billing `reconcile: "lookup"`, method
|
|
5
|
+
* `per-call-cost`, by the request ID the journal holds: the generation ID, the Tripo task ID), so another run on the same key or a credit
|
|
6
|
+
* top-up changes nothing. Other providers record `unavailable`. Only calls whose ledger cost came
|
|
7
|
+
* from the provider (`costSource` "provider") are compared; a call the ledger settled at the
|
|
8
|
+
* route's estimate is settled to the looked-up cost instead, and is on neither side; a looked-up cost
|
|
9
|
+
* above the route's estimate (the reservation's `ceilingUsd`) appends a `settle-above-ceiling` hold,
|
|
10
|
+
* as a settle above it at the call does (src/budget.ts). A gap above
|
|
11
|
+
* max(`reconcile.marginUsd`, `reconcile.marginPct`% of the ledger spend; both default to 0, a
|
|
12
|
+
* person's policy) appends a hold (src/spend.ts), and every paid run is refused until a person
|
|
13
|
+
* acknowledges it. A per-call lookup the provider cannot answer yet is recorded as pending in
|
|
14
|
+
* `<stateDir>/reconcile.jsonl` and retried at the next paid run's start and by `spend reconcile`;
|
|
15
|
+
* one still unanswered `reconcile.pendingMaxAgeHours` (default 24) after the run resolves as
|
|
16
|
+
* `failed`, is marked expired, and `spend status` lists it.
|
|
17
|
+
*
|
|
18
|
+
* The run directory keeps `reconcile-state.json`: the ledger reservations already reconciled. An
|
|
19
|
+
* attempt that stops before its end leaves its reservations unreconciled, so its resume compares
|
|
20
|
+
* that attempt's spend too.
|
|
21
|
+
*
|
|
22
|
+
* Reconciling reads the provider's usage and spends nothing.
|
|
23
|
+
*/
|
|
24
|
+
import { randomBytes } from "node:crypto";
|
|
25
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
26
|
+
import { writeFile } from "node:fs/promises";
|
|
27
|
+
import { join } from "node:path";
|
|
28
|
+
import { CALLS_DIR } from "./runs/journal.js";
|
|
29
|
+
import { RUN_RECORD_FILE } from "./runs/dir.js";
|
|
30
|
+
import { SpendLedger, appendHold, appendJsonLine, assertNoOpenHold, readJsonLines, } from "./spend.js";
|
|
31
|
+
const EPSILON = 1e-9;
|
|
32
|
+
export const RECONCILE_FILE = "reconcile.jsonl";
|
|
33
|
+
/** In the run directory: what the run's attempts have reconciled, and the open attempt's start. */
|
|
34
|
+
export const RUN_RECONCILE_STATE_FILE = "reconcile-state.json";
|
|
35
|
+
/** A pending lookup still unanswered this many hours after its run resolves as `failed`, unless `reconcile.pendingMaxAgeHours` says otherwise. */
|
|
36
|
+
export const DEFAULT_PENDING_MAX_AGE_HOURS = 24;
|
|
37
|
+
export const PENDING_MAX_AGE_MS = DEFAULT_PENDING_MAX_AGE_HOURS * 60 * 60 * 1000;
|
|
38
|
+
function readRunState(runDir) {
|
|
39
|
+
try {
|
|
40
|
+
const raw = JSON.parse(readFileSync(join(runDir, RUN_RECONCILE_STATE_FILE), "utf8"));
|
|
41
|
+
const reconciled = Array.isArray(raw.reconciled)
|
|
42
|
+
? raw.reconciled.filter((v) => typeof v === "string")
|
|
43
|
+
: [];
|
|
44
|
+
return { reconciled };
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return { reconciled: [] };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function writeRunState(runDir, state) {
|
|
51
|
+
writeFileSync(join(runDir, RUN_RECONCILE_STATE_FILE), `${JSON.stringify(state, null, 2)}\n`);
|
|
52
|
+
}
|
|
53
|
+
function reconcilePath(stateDir) {
|
|
54
|
+
return join(stateDir, RECONCILE_FILE);
|
|
55
|
+
}
|
|
56
|
+
function nowOf(ctx) {
|
|
57
|
+
return ctx.now?.() ?? new Date();
|
|
58
|
+
}
|
|
59
|
+
function billingOfId(ctx, id) {
|
|
60
|
+
return ctx.providers.find((c) => c.id === id)?.provider.billing;
|
|
61
|
+
}
|
|
62
|
+
/** The margin a gap must pass: max(marginUsd, marginPct% of the ledger spend); both default to 0. */
|
|
63
|
+
export function marginFor(settings, ledgerUsd) {
|
|
64
|
+
const usd = settings.reconcile.marginUsd ?? 0;
|
|
65
|
+
const pct = settings.reconcile.marginPct ?? 0;
|
|
66
|
+
return Math.max(usd, (pct / 100) * Math.abs(ledgerUsd));
|
|
67
|
+
}
|
|
68
|
+
/** Compares the two sides and appends a hold when the gap passes the margin. */
|
|
69
|
+
function compare(ctx, base, ledgerUsd, providerUsd) {
|
|
70
|
+
const gapUsd = Math.abs(providerUsd - ledgerUsd);
|
|
71
|
+
const marginUsd = marginFor(ctx.settings, ledgerUsd);
|
|
72
|
+
const entry = {
|
|
73
|
+
...base,
|
|
74
|
+
status: "reconciled",
|
|
75
|
+
ledgerUsd,
|
|
76
|
+
providerUsd,
|
|
77
|
+
gapUsd,
|
|
78
|
+
marginUsd,
|
|
79
|
+
};
|
|
80
|
+
if (gapUsd <= marginUsd + EPSILON)
|
|
81
|
+
return entry;
|
|
82
|
+
const hold = appendHold(ctx.settings.stateDir, { provider: base.provider, runId: base.runId, ledgerUsd, providerUsd, gapUsd }, nowOf(ctx));
|
|
83
|
+
return { ...entry, status: "held", holdId: hold.id };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The start of a paid run: retries every pending lookup, refuses the run while a hold is not
|
|
87
|
+
* acknowledged (`SpendHoldError`, exit 3 `spend_hold`).
|
|
88
|
+
*/
|
|
89
|
+
export async function startRunReconcile(ctx, run) {
|
|
90
|
+
await retryPending(ctx);
|
|
91
|
+
assertNoOpenHold(ctx.settings);
|
|
92
|
+
return runReconcileOf(ctx, run);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The reconcile of a paid run, with no hold check: a run let in past a spend hold to collect its
|
|
96
|
+
* submitted jobs still compares what it settled with the provider when it ends.
|
|
97
|
+
*/
|
|
98
|
+
export function runReconcileOf(ctx, run) {
|
|
99
|
+
const providers = [...new Set(run.providers)].filter((id) => id !== "" && billingOfId(ctx, id)?.paid === true);
|
|
100
|
+
return { runId: run.runId, runDir: run.runDir, providers };
|
|
101
|
+
}
|
|
102
|
+
/** The request ID the journal holds for a call, when the provider gave it, and its cost source. */
|
|
103
|
+
function journaledCall(runDir, callKey) {
|
|
104
|
+
if (callKey === undefined)
|
|
105
|
+
return undefined;
|
|
106
|
+
const path = join(runDir, CALLS_DIR, `${callKey}.json`);
|
|
107
|
+
if (!existsSync(path))
|
|
108
|
+
return undefined;
|
|
109
|
+
try {
|
|
110
|
+
const entry = JSON.parse(readFileSync(path, "utf8"));
|
|
111
|
+
const id = entry.record?.requestId;
|
|
112
|
+
if (typeof id !== "string" || entry.record?.requestIdSource === "local")
|
|
113
|
+
return undefined;
|
|
114
|
+
return {
|
|
115
|
+
requestId: id,
|
|
116
|
+
costSource: entry.record?.costSource === "estimate" ? "estimate" : "provider",
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** The end of a paid run: one entry per paid provider the plan names. */
|
|
124
|
+
export async function finishRunReconcile(ctx, run) {
|
|
125
|
+
const ledger = SpendLedger.fromSettings(ctx.settings, { env: {} });
|
|
126
|
+
const state = readRunState(run.runDir);
|
|
127
|
+
const done = new Set(state.reconciled);
|
|
128
|
+
// Every reservation of the run no earlier attempt's end reconciled: an interrupted attempt's too.
|
|
129
|
+
const calls = ledger.runCalls(run.runId).filter((c) => !done.has(c.id));
|
|
130
|
+
const entries = [];
|
|
131
|
+
for (const provider of run.providers) {
|
|
132
|
+
const billing = billingOfId(ctx, provider);
|
|
133
|
+
const mine = calls.filter((c) => c.provider === provider);
|
|
134
|
+
const ledgerUsd = mine.reduce((sum, c) => sum + c.costUsd, 0);
|
|
135
|
+
try {
|
|
136
|
+
if (billing === undefined || billing.reconcile === "unavailable") {
|
|
137
|
+
entries.push({ provider, status: "unavailable", runId: run.runId, ledgerUsd });
|
|
138
|
+
}
|
|
139
|
+
else if (billing.callCost === undefined) {
|
|
140
|
+
entries.push({
|
|
141
|
+
provider,
|
|
142
|
+
status: "unavailable",
|
|
143
|
+
runId: run.runId,
|
|
144
|
+
ledgerUsd,
|
|
145
|
+
note: "the provider gives no per-call cost reading",
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const lookups = [];
|
|
150
|
+
const seen = new Set();
|
|
151
|
+
let unmatched = 0;
|
|
152
|
+
// The journal holds one request ID per call key: a reservation an interrupted attempt made
|
|
153
|
+
// for a call a later attempt paid again has no request ID of its own.
|
|
154
|
+
for (const call of mine.toReversed()) {
|
|
155
|
+
const journaled = journaledCall(run.runDir, call.callKey);
|
|
156
|
+
if (journaled === undefined || seen.has(call.callKey))
|
|
157
|
+
unmatched++;
|
|
158
|
+
else {
|
|
159
|
+
seen.add(call.callKey);
|
|
160
|
+
lookups.unshift({
|
|
161
|
+
requestId: journaled.requestId,
|
|
162
|
+
ledgerUsd: call.costUsd,
|
|
163
|
+
id: call.id,
|
|
164
|
+
costSource: journaled.costSource,
|
|
165
|
+
route: call.route,
|
|
166
|
+
ceilingUsd: call.ceilingUsd,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
entries.push(await perCall(ctx, provider, run.runId, billing, lookups, unmatched));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
entries.push({
|
|
175
|
+
provider,
|
|
176
|
+
status: "failed",
|
|
177
|
+
runId: run.runId,
|
|
178
|
+
ledgerUsd,
|
|
179
|
+
note: error.message,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
writeRunState(run.runDir, {
|
|
184
|
+
reconciled: [...state.reconciled, ...calls.map((c) => c.id)],
|
|
185
|
+
});
|
|
186
|
+
return entries;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Looks up each call's cost; with every one reported, compares, else records the lookup as
|
|
190
|
+
* pending. A call the provider can never look up (null) joins the unmatched ones. A run none of
|
|
191
|
+
* whose paid calls could be looked up records `failed`: nothing was compared. A retry stops at the
|
|
192
|
+
* first call still unreported, so a pending lookup costs one provider call per retry while it waits.
|
|
193
|
+
*/
|
|
194
|
+
async function perCall(ctx, provider, runId, billing, lookups, unmatchedBefore, pending) {
|
|
195
|
+
const pendingId = pending?.id;
|
|
196
|
+
const retry = pendingId !== undefined;
|
|
197
|
+
let unmatched = unmatchedBefore;
|
|
198
|
+
let ledgerUsd = 0;
|
|
199
|
+
let providerUsd = 0;
|
|
200
|
+
let settled = 0;
|
|
201
|
+
const ledger = SpendLedger.fromSettings(ctx.settings, { env: {} });
|
|
202
|
+
const waiting = [];
|
|
203
|
+
const looked = [];
|
|
204
|
+
// The calls this pass settled, so a retry's updated pending record carries their settled cost.
|
|
205
|
+
const settledNow = new Map();
|
|
206
|
+
// The holds of estimate-sourced calls whose looked-up cost is above their route's estimate.
|
|
207
|
+
const ceilingHolds = [];
|
|
208
|
+
for (const call of lookups) {
|
|
209
|
+
const cost = await billing.callCost(call.requestId);
|
|
210
|
+
if (cost === null) {
|
|
211
|
+
unmatched++;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (cost === undefined) {
|
|
215
|
+
looked.push(call);
|
|
216
|
+
waiting.push(call);
|
|
217
|
+
if (retry)
|
|
218
|
+
break;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (call.costSource === "estimate" && call.id !== undefined) {
|
|
222
|
+
if (Math.abs(call.ledgerUsd - cost) > EPSILON) {
|
|
223
|
+
ledger.settle(call.id, cost, call.requestId);
|
|
224
|
+
// Settled above its route's estimate: held as a settle at the call would be (src/budget.ts).
|
|
225
|
+
const ceilingUsd = call.ceilingUsd ?? call.ledgerUsd;
|
|
226
|
+
if (cost > ceilingUsd + EPSILON)
|
|
227
|
+
ceilingHolds.push(appendHold(ctx.settings.stateDir, {
|
|
228
|
+
provider,
|
|
229
|
+
runId,
|
|
230
|
+
ledgerUsd: ceilingUsd,
|
|
231
|
+
providerUsd: cost,
|
|
232
|
+
gapUsd: cost - ceilingUsd,
|
|
233
|
+
reason: "settle-above-ceiling",
|
|
234
|
+
...(call.route !== undefined && { route: call.route }),
|
|
235
|
+
}, nowOf(ctx)).id);
|
|
236
|
+
}
|
|
237
|
+
settled++;
|
|
238
|
+
// The pending record keeps the settled cost, so a retry finds nothing left to settle.
|
|
239
|
+
const after = { ...call, ledgerUsd: cost };
|
|
240
|
+
if (Math.abs(call.ledgerUsd - cost) > EPSILON)
|
|
241
|
+
settledNow.set(call, after);
|
|
242
|
+
looked.push(after);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
looked.push(call);
|
|
246
|
+
ledgerUsd += call.ledgerUsd;
|
|
247
|
+
providerUsd += cost;
|
|
248
|
+
}
|
|
249
|
+
const base = {
|
|
250
|
+
provider,
|
|
251
|
+
method: "per-call-cost",
|
|
252
|
+
runId,
|
|
253
|
+
...(unmatched > 0 && { unmatched }),
|
|
254
|
+
...(settled > 0 && { settled }),
|
|
255
|
+
// A looked-up cost above its route's estimate held the next paid runs: the entry names the hold.
|
|
256
|
+
...(ceilingHolds.length > 0 && { holdId: ceilingHolds[0] }),
|
|
257
|
+
};
|
|
258
|
+
if (waiting.length > 0) {
|
|
259
|
+
const id = pendingId ?? randomBytes(8).toString("hex");
|
|
260
|
+
if (pendingId === undefined) {
|
|
261
|
+
const record = {
|
|
262
|
+
op: "pending",
|
|
263
|
+
id,
|
|
264
|
+
at: nowOf(ctx).toISOString(),
|
|
265
|
+
provider,
|
|
266
|
+
runId,
|
|
267
|
+
calls: looked,
|
|
268
|
+
unmatched,
|
|
269
|
+
};
|
|
270
|
+
appendJsonLine(reconcilePath(ctx.settings.stateDir), record, "reconcile record");
|
|
271
|
+
}
|
|
272
|
+
else if (settledNow.size > 0 && pending !== undefined) {
|
|
273
|
+
// A retry that settled an estimate rewrites the lookup (same id and age), so the next retry
|
|
274
|
+
// finds that call's ledger cost equal to the provider's and settles it no second time.
|
|
275
|
+
const record = {
|
|
276
|
+
...pending,
|
|
277
|
+
calls: lookups.map((c) => settledNow.get(c) ?? c),
|
|
278
|
+
};
|
|
279
|
+
appendJsonLine(reconcilePath(ctx.settings.stateDir), record, "reconcile record");
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
...base,
|
|
283
|
+
status: "pending",
|
|
284
|
+
ledgerUsd: looked.reduce((sum, c) => sum + c.ledgerUsd, 0),
|
|
285
|
+
pendingId: id,
|
|
286
|
+
note: retry
|
|
287
|
+
? "a call cost is not reported yet"
|
|
288
|
+
: `${waiting.length} of ${looked.length} call cost(s) not reported yet`,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
if (looked.length === 0 && unmatched > 0)
|
|
292
|
+
return {
|
|
293
|
+
...base,
|
|
294
|
+
status: "failed",
|
|
295
|
+
note: `none of the ${unmatched} paid call(s) could be looked up with the provider; nothing was compared`,
|
|
296
|
+
};
|
|
297
|
+
const notes = [
|
|
298
|
+
...(unmatched > 0
|
|
299
|
+
? [`${unmatched} paid call(s) could not be looked up and are left out of both sides`]
|
|
300
|
+
: []),
|
|
301
|
+
...(settled > 0 ? [`${settled} estimate-sourced call(s) settled to the provider's cost`] : []),
|
|
302
|
+
];
|
|
303
|
+
if (ceilingHolds.length > 0)
|
|
304
|
+
notes.push(`${ceilingHolds.length} call(s) cost more than their route's estimate: spend hold ${ceilingHolds.join(", ")}`);
|
|
305
|
+
const entry = compare(ctx, {
|
|
306
|
+
...base,
|
|
307
|
+
...(notes.length > 0 && { note: notes.join("; ") }),
|
|
308
|
+
}, ledgerUsd, providerUsd);
|
|
309
|
+
if (ceilingHolds.length === 0 || entry.status === "held")
|
|
310
|
+
return entry;
|
|
311
|
+
return { ...entry, status: "held", holdId: ceilingHolds[0] };
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* The pending lookups not yet resolved, oldest first. A retry that settled an estimate appends the
|
|
315
|
+
* lookup again under its id; the last record of an id is the one that holds.
|
|
316
|
+
*/
|
|
317
|
+
export function pendingLookups(stateDir) {
|
|
318
|
+
const values = readJsonLines(reconcilePath(stateDir), "reconcile record");
|
|
319
|
+
const resolved = new Set(values.filter((v) => v.op === "resolved").map((v) => v.id));
|
|
320
|
+
const latest = new Map();
|
|
321
|
+
for (const v of values)
|
|
322
|
+
if (v.op === "pending" &&
|
|
323
|
+
typeof v.id === "string" &&
|
|
324
|
+
typeof v.provider === "string" &&
|
|
325
|
+
typeof v.runId === "string" &&
|
|
326
|
+
Array.isArray(v.calls) &&
|
|
327
|
+
!resolved.has(v.id))
|
|
328
|
+
latest.set(v.id, v);
|
|
329
|
+
return [...latest.values()];
|
|
330
|
+
}
|
|
331
|
+
/** The lookups that expired unanswered, oldest first. */
|
|
332
|
+
export function expiredLookups(stateDir) {
|
|
333
|
+
const values = readJsonLines(reconcilePath(stateDir), "reconcile record");
|
|
334
|
+
const out = [];
|
|
335
|
+
for (const r of values) {
|
|
336
|
+
if (r.op !== "resolved" || r.expired !== true)
|
|
337
|
+
continue;
|
|
338
|
+
const p = values.find((v) => v.op === "pending" && v.id === r.id);
|
|
339
|
+
if (p === undefined)
|
|
340
|
+
continue;
|
|
341
|
+
out.push({ id: r.id, provider: p.provider, runId: p.runId, at: p.at, resolvedAt: r.at });
|
|
342
|
+
}
|
|
343
|
+
return out;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Retries every pending lookup: one whose calls are all reported now is compared (and may append a
|
|
347
|
+
* hold) and marked resolved; one whose provider is no longer configured or still has a call to
|
|
348
|
+
* report stays pending, until `reconcile.pendingMaxAgeHours` after its run, when it resolves as
|
|
349
|
+
* `failed`.
|
|
350
|
+
*/
|
|
351
|
+
export async function retryPending(ctx) {
|
|
352
|
+
const results = [];
|
|
353
|
+
for (const pending of pendingLookups(ctx.settings.stateDir)) {
|
|
354
|
+
const billing = billingOfId(ctx, pending.provider);
|
|
355
|
+
if (billing?.callCost === undefined) {
|
|
356
|
+
results.push({
|
|
357
|
+
provider: pending.provider,
|
|
358
|
+
status: "pending",
|
|
359
|
+
method: "per-call-cost",
|
|
360
|
+
runId: pending.runId,
|
|
361
|
+
pendingId: pending.id,
|
|
362
|
+
note: `provider "${pending.provider}" is not configured with a per-call cost reading`,
|
|
363
|
+
});
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
let entry;
|
|
367
|
+
try {
|
|
368
|
+
entry = await perCall(ctx, pending.provider, pending.runId, billing, pending.calls, typeof pending.unmatched === "number" ? pending.unmatched : 0, pending);
|
|
369
|
+
}
|
|
370
|
+
catch (error) {
|
|
371
|
+
entry = {
|
|
372
|
+
provider: pending.provider,
|
|
373
|
+
status: "pending",
|
|
374
|
+
method: "per-call-cost",
|
|
375
|
+
runId: pending.runId,
|
|
376
|
+
pendingId: pending.id,
|
|
377
|
+
note: error.message,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
const age = nowOf(ctx).getTime() - Date.parse(pending.at);
|
|
381
|
+
const maxHours = ctx.settings.reconcile.pendingMaxAgeHours ?? DEFAULT_PENDING_MAX_AGE_HOURS;
|
|
382
|
+
const expired = entry.status === "pending" && age > maxHours * 60 * 60 * 1000;
|
|
383
|
+
if (expired)
|
|
384
|
+
entry = {
|
|
385
|
+
...entry,
|
|
386
|
+
status: "failed",
|
|
387
|
+
note: `the provider has not reported every call cost within ${maxHours} hour(s); nothing was compared: ${entry.note ?? ""}`.trim(),
|
|
388
|
+
};
|
|
389
|
+
if (entry.status !== "pending") {
|
|
390
|
+
const resolved = {
|
|
391
|
+
op: "resolved",
|
|
392
|
+
id: pending.id,
|
|
393
|
+
at: nowOf(ctx).toISOString(),
|
|
394
|
+
status: entry.status,
|
|
395
|
+
...(entry.holdId !== undefined && { holdId: entry.holdId }),
|
|
396
|
+
...(expired && { expired: true }),
|
|
397
|
+
};
|
|
398
|
+
appendJsonLine(reconcilePath(ctx.settings.stateDir), resolved, "reconcile record");
|
|
399
|
+
entry = { ...entry, pendingId: pending.id };
|
|
400
|
+
}
|
|
401
|
+
results.push(entry);
|
|
402
|
+
}
|
|
403
|
+
return results;
|
|
404
|
+
}
|
|
405
|
+
/** Adds the run's reconcile entries to its `run.json`, whoever wrote it. */
|
|
406
|
+
export async function recordReconcile(runDir, entries) {
|
|
407
|
+
const path = join(runDir, RUN_RECORD_FILE);
|
|
408
|
+
let record = {};
|
|
409
|
+
try {
|
|
410
|
+
record = JSON.parse(readFileSync(path, "utf8"));
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
// No record, or an unreadable one: the reconcile entries alone are written.
|
|
414
|
+
}
|
|
415
|
+
await writeFile(path, `${JSON.stringify({ ...record, reconcile: entries }, null, 2)}\n`);
|
|
416
|
+
}
|
package/dist/redact.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction (design section 4): key values and credential header values never reach a message
|
|
3
|
+
* Assetgrove writes. `redact` runs in ProviderError, the one result builder and the log.
|
|
4
|
+
*/
|
|
5
|
+
import { DEFAULT_KEY_ENV, type Env } from "./env.ts";
|
|
6
|
+
export { DEFAULT_KEY_ENV };
|
|
7
|
+
/**
|
|
8
|
+
* Adds key variable names to those redacted: each provider's `keyEnv` and each adapter's default,
|
|
9
|
+
* registered when the run context is made (src/commands/context.ts).
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerKeyEnv(names: Iterable<string>): void;
|
|
12
|
+
/**
|
|
13
|
+
* Marks the names registered so far; the function returned forgets every name registered since.
|
|
14
|
+
* A test that runs several CLI commands in one process (`cli()` in src/testing) scopes each, as
|
|
15
|
+
* each CLI process starts with none registered.
|
|
16
|
+
*/
|
|
17
|
+
export declare function keyEnvScope(): () => void;
|
|
18
|
+
/** Every key variable name redaction knows: the defaults and those registered from settings. */
|
|
19
|
+
export declare function keyEnvNames(): string[];
|
|
20
|
+
/**
|
|
21
|
+
* The environment a command a developer wrote runs in (a validator, a material command): this
|
|
22
|
+
* process's, without any key variable redaction knows.
|
|
23
|
+
*/
|
|
24
|
+
export declare function keyFreeEnv(env?: Env): Env;
|
|
25
|
+
/**
|
|
26
|
+
* The text with each configured key variable's value replaced by `[redacted:<ENV>]` and the
|
|
27
|
+
* values of Authorization, Bearer, Key and x-api-key masked.
|
|
28
|
+
*/
|
|
29
|
+
export declare function redact(text: string, env?: Env): string;
|
package/dist/redact.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction (design section 4): key values and credential header values never reach a message
|
|
3
|
+
* Assetgrove writes. `redact` runs in ProviderError, the one result builder and the log.
|
|
4
|
+
*/
|
|
5
|
+
import { DEFAULT_KEY_ENV, keyValue, withoutVariables } from "./env.js";
|
|
6
|
+
export { DEFAULT_KEY_ENV };
|
|
7
|
+
/** Values shorter than this are not redacted: they would mangle ordinary text. */
|
|
8
|
+
const MIN_REDACTED_LENGTH = 8;
|
|
9
|
+
const registered = new Set();
|
|
10
|
+
/**
|
|
11
|
+
* Adds key variable names to those redacted: each provider's `keyEnv` and each adapter's default,
|
|
12
|
+
* registered when the run context is made (src/commands/context.ts).
|
|
13
|
+
*/
|
|
14
|
+
export function registerKeyEnv(names) {
|
|
15
|
+
for (const name of names)
|
|
16
|
+
registered.add(name);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Marks the names registered so far; the function returned forgets every name registered since.
|
|
20
|
+
* A test that runs several CLI commands in one process (`cli()` in src/testing) scopes each, as
|
|
21
|
+
* each CLI process starts with none registered.
|
|
22
|
+
*/
|
|
23
|
+
export function keyEnvScope() {
|
|
24
|
+
const before = new Set(registered);
|
|
25
|
+
return () => {
|
|
26
|
+
for (const name of registered)
|
|
27
|
+
if (!before.has(name))
|
|
28
|
+
registered.delete(name);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Every key variable name redaction knows: the defaults and those registered from settings. */
|
|
32
|
+
export function keyEnvNames() {
|
|
33
|
+
return [...new Set([...DEFAULT_KEY_ENV, ...registered])];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The environment a command a developer wrote runs in (a validator, a material command): this
|
|
37
|
+
* process's, without any key variable redaction knows.
|
|
38
|
+
*/
|
|
39
|
+
export function keyFreeEnv(env) {
|
|
40
|
+
return withoutVariables(keyEnvNames(), env);
|
|
41
|
+
}
|
|
42
|
+
const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
43
|
+
/** Credential header values, each masked whole. */
|
|
44
|
+
const HEADER_PATTERNS = [
|
|
45
|
+
// Authorization: <scheme> <value>, or a bare value; as a header, JSON member or assignment.
|
|
46
|
+
[
|
|
47
|
+
/(\bauthorization["']?\s*[:=]\s*["']?)(?:(?:Bearer|Basic|Key|Token)\s+)?[^\s"',;]+/gi,
|
|
48
|
+
"$1[redacted:authorization]",
|
|
49
|
+
],
|
|
50
|
+
[/(\bx-api-key["']?\s*[:=]\s*["']?)[^\s"',;]+/gi, "$1[redacted:x-api-key]"],
|
|
51
|
+
[/(\bBearer\s+)(?!\[redacted:)[A-Za-z0-9._~+/=-]+/gi, "$1[redacted:bearer]"],
|
|
52
|
+
[/(\bKey\s+)(?!\[redacted:)[A-Za-z0-9._~+/:=-]{16,}/g, "$1[redacted:key]"],
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* The text with each configured key variable's value replaced by `[redacted:<ENV>]` and the
|
|
56
|
+
* values of Authorization, Bearer, Key and x-api-key masked.
|
|
57
|
+
*/
|
|
58
|
+
export function redact(text, env) {
|
|
59
|
+
let out = text;
|
|
60
|
+
const values = keyEnvNames()
|
|
61
|
+
.map((name) => [name, keyValue(name, env)])
|
|
62
|
+
.filter((entry) => {
|
|
63
|
+
const value = entry[1];
|
|
64
|
+
return value !== undefined && value.trim().length >= MIN_REDACTED_LENGTH;
|
|
65
|
+
})
|
|
66
|
+
// Longer values first, so a value that contains another is replaced whole.
|
|
67
|
+
.sort((a, b) => b[1].length - a[1].length);
|
|
68
|
+
for (const [name, value] of values) {
|
|
69
|
+
out = out.replace(new RegExp(escape(value), "g"), `[redacted:${name}]`);
|
|
70
|
+
}
|
|
71
|
+
for (const [pattern, replacement] of HEADER_PATTERNS)
|
|
72
|
+
out = out.replace(pattern, replacement);
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Raster } from "./image/raster.ts";
|
|
2
|
+
/** A box in pixels or in percent of the image. */
|
|
3
|
+
export interface RegionBox {
|
|
4
|
+
kind: "box";
|
|
5
|
+
unit: "px" | "percent";
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
/** A mask image: its opaque, light pixels are the region. */
|
|
12
|
+
export interface RegionMask {
|
|
13
|
+
kind: "mask";
|
|
14
|
+
/** Absolute path, inside the project root. */
|
|
15
|
+
path: string;
|
|
16
|
+
}
|
|
17
|
+
/** A span of an audio asset in seconds, `t=<start>,<end>`. */
|
|
18
|
+
export interface RegionTime {
|
|
19
|
+
kind: "time";
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
}
|
|
23
|
+
export interface Region {
|
|
24
|
+
shape: RegionBox | RegionMask | RegionTime;
|
|
25
|
+
frame?: number;
|
|
26
|
+
view?: number;
|
|
27
|
+
/** Absolute reference image paths, inside the project root. */
|
|
28
|
+
refs: string[];
|
|
29
|
+
note: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ParseRegionOptions {
|
|
32
|
+
/** Directory relative paths resolve against; the working directory by default. */
|
|
33
|
+
base?: string;
|
|
34
|
+
/** Whether the `: <note>` part is required; true by default. */
|
|
35
|
+
requireNote?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Parses one region text; a malformed one or a path outside the project root is an InputError (exit 2). */
|
|
38
|
+
export declare function parseRegion(text: string, options?: ParseRegionOptions): Region;
|
|
39
|
+
/** Parses each region text. */
|
|
40
|
+
export declare function parseRegions(texts: readonly string[], options?: ParseRegionOptions): Region[];
|
|
41
|
+
/** The pixel rectangle of a box on an image of the given size, clamped to the image. */
|
|
42
|
+
export declare function boxRect(box: RegionBox, width: number, height: number): {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
};
|
|
48
|
+
/** Whether a mask pixel is inside the region: opaque and light. */
|
|
49
|
+
export declare function maskInside(mask: Raster, x: number, y: number): boolean;
|