@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,33 @@
|
|
|
1
|
+
import type { PromptPolicyRecord } from "../policy/text.ts";
|
|
2
|
+
import type { WorkPlan } from "./plan.ts";
|
|
3
|
+
export declare const REQUEST_FILE = "request.json";
|
|
4
|
+
export declare const RUN_RECORD_FILE = "run.json";
|
|
5
|
+
/** The run id of a digest: `r-` and its first 16 hex digits. */
|
|
6
|
+
export declare function runIdOf(digest: string): string;
|
|
7
|
+
/** The run directory of a digest under a runs directory. */
|
|
8
|
+
export declare function runDirOf(runsDir: string, digest: string): string;
|
|
9
|
+
/** Creates the run directory and writes the WorkPlan to its `request.json`. */
|
|
10
|
+
export declare function openRunDir(plan: WorkPlan): Promise<string>;
|
|
11
|
+
/** The run record the runner writes for a command that writes none of its own. */
|
|
12
|
+
export interface CommandRunRecord {
|
|
13
|
+
runId: string;
|
|
14
|
+
runDir: string;
|
|
15
|
+
command: string;
|
|
16
|
+
digest: string;
|
|
17
|
+
startedAt: string;
|
|
18
|
+
finishedAt: string;
|
|
19
|
+
ok: boolean;
|
|
20
|
+
exitCode: number;
|
|
21
|
+
error?: string;
|
|
22
|
+
spentUsd?: number;
|
|
23
|
+
/** The numbered contact sheet in the run directory, when the command wrote one. */
|
|
24
|
+
contactSheet?: string;
|
|
25
|
+
/** The prompt policy's check of the request's prompt text. */
|
|
26
|
+
promptPolicy?: PromptPolicyRecord;
|
|
27
|
+
/** The person's confirmation of the request's spend (design section 7), when it needed one. */
|
|
28
|
+
confirmation?: import("../types.ts").ConfirmationRecord;
|
|
29
|
+
}
|
|
30
|
+
/** Writes a command's run record to `run.json` in its run directory. */
|
|
31
|
+
export declare function writeRunRecord(record: CommandRunRecord): Promise<void>;
|
|
32
|
+
/** The run id of a run directory: its base name. */
|
|
33
|
+
export declare function runIdOfDir(runDir: string): string;
|
package/dist/runs/dir.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A request's run directory (design section 6): `<runs>/r-<first 16 hex of the digest>/`, holding
|
|
3
|
+
* `request.json` (the WorkPlan) and `run.json` (the run record). Records are named by hex only.
|
|
4
|
+
*/
|
|
5
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
6
|
+
import { basename, join } from "node:path";
|
|
7
|
+
export const REQUEST_FILE = "request.json";
|
|
8
|
+
export const RUN_RECORD_FILE = "run.json";
|
|
9
|
+
/** The run id of a digest: `r-` and its first 16 hex digits. */
|
|
10
|
+
export function runIdOf(digest) {
|
|
11
|
+
return `r-${digest.slice(0, 16)}`;
|
|
12
|
+
}
|
|
13
|
+
/** The run directory of a digest under a runs directory. */
|
|
14
|
+
export function runDirOf(runsDir, digest) {
|
|
15
|
+
return join(runsDir, runIdOf(digest));
|
|
16
|
+
}
|
|
17
|
+
/** Creates the run directory and writes the WorkPlan to its `request.json`. */
|
|
18
|
+
export async function openRunDir(plan) {
|
|
19
|
+
await mkdir(plan.runDir, { recursive: true });
|
|
20
|
+
await writeFile(join(plan.runDir, REQUEST_FILE), `${JSON.stringify(plan, null, 2)}\n`);
|
|
21
|
+
return plan.runDir;
|
|
22
|
+
}
|
|
23
|
+
/** Writes a command's run record to `run.json` in its run directory. */
|
|
24
|
+
export async function writeRunRecord(record) {
|
|
25
|
+
await writeFile(join(record.runDir, RUN_RECORD_FILE), `${JSON.stringify(record, null, 2)}\n`);
|
|
26
|
+
}
|
|
27
|
+
/** The run id of a run directory: its base name. */
|
|
28
|
+
export function runIdOfDir(runDir) {
|
|
29
|
+
return basename(runDir);
|
|
30
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Outcome, RunContext } from "../commands/types.ts";
|
|
2
|
+
import type { PromptPolicyRecord } from "../policy/text.ts";
|
|
3
|
+
import type { KindRequest } from "../confirm/index.ts";
|
|
4
|
+
import type { ConfirmationRecord } from "../types.ts";
|
|
5
|
+
import type { WorkPlan } from "./plan.ts";
|
|
6
|
+
export declare const STATE_FILE = "state.json";
|
|
7
|
+
export type RunStatus = "running" | "finished" | "failed";
|
|
8
|
+
/** A run's state (`state.json`): where it is, who runs it and, once it ends, how it ended. */
|
|
9
|
+
export interface RunState {
|
|
10
|
+
runId: string;
|
|
11
|
+
command: string;
|
|
12
|
+
digest: string;
|
|
13
|
+
status: RunStatus;
|
|
14
|
+
pid: number;
|
|
15
|
+
startedAt: string;
|
|
16
|
+
finishedAt?: string;
|
|
17
|
+
exitCode?: number;
|
|
18
|
+
/** How many times the request has been executed in this directory, resumes included. */
|
|
19
|
+
attempts: number;
|
|
20
|
+
/** The outcome a finished run returns again when the request is repeated. */
|
|
21
|
+
outcome?: {
|
|
22
|
+
exitCode: number;
|
|
23
|
+
fields: Record<string, unknown>;
|
|
24
|
+
human: string;
|
|
25
|
+
error?: unknown;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** What a run tells a connected client: calls answered so far of the plan's total. */
|
|
29
|
+
export interface ProgressUpdate {
|
|
30
|
+
progress: number;
|
|
31
|
+
total: number;
|
|
32
|
+
message: string;
|
|
33
|
+
}
|
|
34
|
+
/** The state of a run directory, or undefined when it has none or it cannot be read. */
|
|
35
|
+
export declare function readRunState(runDir: string): RunState | undefined;
|
|
36
|
+
/** Whether a request needs a spend confirmation: all but a forecast of 0 on free providers. */
|
|
37
|
+
export declare function needsSpendConfirmation(plan: WorkPlan): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* What a person is shown for a spend request: its summary and flat fields, from the digest body's
|
|
40
|
+
* own fields (so `assetgrove confirm` can rebuild them from a verified body) plus, when the
|
|
41
|
+
* WorkPlan is at hand, its candidate count, which the digest does not cover.
|
|
42
|
+
*/
|
|
43
|
+
export declare function spendShown(id: string, body: {
|
|
44
|
+
command: string;
|
|
45
|
+
jobs: WorkPlan["jobs"];
|
|
46
|
+
forecastUsd: number;
|
|
47
|
+
capUsd: number;
|
|
48
|
+
options?: Record<string, unknown>;
|
|
49
|
+
}, candidates?: number, nearMatches?: readonly {
|
|
50
|
+
address: string;
|
|
51
|
+
rank: number;
|
|
52
|
+
sharedText?: {
|
|
53
|
+
title?: string;
|
|
54
|
+
};
|
|
55
|
+
}[], nearMatchSheet?: string): {
|
|
56
|
+
summary: string;
|
|
57
|
+
details: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
/** The spend request of a WorkPlan: its digest body, and what a person is shown. */
|
|
60
|
+
export declare function spendRequest(command: string, round: number, plan: WorkPlan): KindRequest;
|
|
61
|
+
/** The policy request of a borderline prompt-policy answer: what a person confirms to go on. */
|
|
62
|
+
export declare function policyRequest(command: string, plan: Pick<WorkPlan, "digest" | "policyTextSha256">, record: Pick<PromptPolicyRecord, "model" | "probability">): KindRequest;
|
|
63
|
+
/**
|
|
64
|
+
* Executes a paid command's request: `plan` is its free plan step, `run` its real run. A thrown
|
|
65
|
+
* error becomes an outcome through `toOutcome`. `prior` names an earlier confirmation that covers
|
|
66
|
+
* this request (apply's plan); `round` is the request's round, part of its digest.
|
|
67
|
+
*/
|
|
68
|
+
export declare function executeRun(options: {
|
|
69
|
+
command: string;
|
|
70
|
+
plan: WorkPlan;
|
|
71
|
+
ctx: RunContext;
|
|
72
|
+
run: (ctx: RunContext) => Promise<Outcome>;
|
|
73
|
+
toOutcome: (error: unknown) => Outcome;
|
|
74
|
+
/** The `--provider-script` module, which reconciling gives the scripted providers it makes. */
|
|
75
|
+
providerScript?: string;
|
|
76
|
+
round?: number;
|
|
77
|
+
/** The work item the spend ledger counts the run's own prompt-policy call against. */
|
|
78
|
+
workItem?: string;
|
|
79
|
+
prior?: () => Promise<ConfirmationRecord | undefined>;
|
|
80
|
+
/**
|
|
81
|
+
* False when a finished run is not returned as it ended but run again in its run directory: its
|
|
82
|
+
* effect can be lost (a deleted index) or its answer can age (a query over a changed index). The
|
|
83
|
+
* journal still answers every call it holds, so nothing is paid twice.
|
|
84
|
+
*/
|
|
85
|
+
replayFinished?: boolean;
|
|
86
|
+
}): Promise<Outcome>;
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The executor of a paid command (design section 9). For a real run it makes the free plan step,
|
|
3
|
+
* refuses a forecast over the cap, creates the run directory `<runs>/r-<16 hex>/` with
|
|
4
|
+
* `request.json`, takes its `lock`, and then either returns the finished run (`reused: true`) or
|
|
5
|
+
* runs the command inside the run's journal scope, so every provider call already answered is
|
|
6
|
+
* answered from `calls/` and only missing calls are paid for. It writes `state.json` as the run
|
|
7
|
+
* moves and `run.json` when it ends, and reports progress to a connected client.
|
|
8
|
+
*
|
|
9
|
+
* Checked where money is spent (design section 7): before the first reservation and on every
|
|
10
|
+
* resume, a request that can spend is confirmed (`requireConfirmation`: headless settings, the
|
|
11
|
+
* record of its digest, a prior confirmation the command names, the TTY, else exit 8), and the
|
|
12
|
+
* run's scope carries the clearance `Caller` requires for every paid call. The record is copied
|
|
13
|
+
* into `run.json`. A confirmation pays for one run: its first run binds it to the run directory,
|
|
14
|
+
* and the run finishing consumes it, so the same request in another directory asks again. A
|
|
15
|
+
* request whose forecast is 0 on free providers needs no confirmation.
|
|
16
|
+
*
|
|
17
|
+
* The run executes in the process that received the request: there is no detached process.
|
|
18
|
+
*/
|
|
19
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
20
|
+
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
21
|
+
import { join } from "node:path";
|
|
22
|
+
import { CONTACT_SHEET_FILE } from "../contact.js";
|
|
23
|
+
import { createProviders } from "../providers/adapter.js";
|
|
24
|
+
import { loadScript } from "../providers/script.js";
|
|
25
|
+
import { finishRunReconcile, recordReconcile, runReconcileOf, startRunReconcile, } from "../reconcile.js";
|
|
26
|
+
import { Budget, capFromClause } from "../budget.js";
|
|
27
|
+
import { Caller } from "../calls.js";
|
|
28
|
+
import { checkPromptModel } from "../policy/model.js";
|
|
29
|
+
import { providerSet, spendLedger } from "../providers/index.js";
|
|
30
|
+
import { SpendHoldError, ledgerFor } from "../spend.js";
|
|
31
|
+
import { bindConfirmation, digestOf, gateOf, requireConfirmation } from "../confirm/index.js";
|
|
32
|
+
import { DEFAULT_ROUND, policyPartsOf, promptPolicyCutOf } from "./plan.js";
|
|
33
|
+
import { RUN_RECORD_FILE, openRunDir, runIdOfDir, writeRunRecord } from "./dir.js";
|
|
34
|
+
import { Journal, withRunScope } from "./journal.js";
|
|
35
|
+
import { RunInProgressError, acquireRunLock } from "./lock.js";
|
|
36
|
+
export const STATE_FILE = "state.json";
|
|
37
|
+
/** The state of a run directory, or undefined when it has none or it cannot be read. */
|
|
38
|
+
export function readRunState(runDir) {
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(readFileSync(join(runDir, STATE_FILE), "utf8"));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function writeState(runDir, state) {
|
|
47
|
+
await writeFile(join(runDir, STATE_FILE), `${JSON.stringify(state, null, 2)}\n`);
|
|
48
|
+
}
|
|
49
|
+
/** The outcome of a refusal before the run starts. */
|
|
50
|
+
function refused(code, message, exitCode, fields = {}) {
|
|
51
|
+
return { exitCode, fields, human: "", error: { code, message } };
|
|
52
|
+
}
|
|
53
|
+
/** The fields every executed run adds to its command's result. */
|
|
54
|
+
function runFields(plan, reused) {
|
|
55
|
+
return { runId: runIdOfDir(plan.runDir), runDir: plan.runDir, digest: plan.digest, reused };
|
|
56
|
+
}
|
|
57
|
+
/** Whether a request needs a spend confirmation: all but a forecast of 0 on free providers. */
|
|
58
|
+
export function needsSpendConfirmation(plan) {
|
|
59
|
+
return plan.paid || plan.forecastUsd > 0;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* What a person is shown for a spend request: its summary and flat fields, from the digest body's
|
|
63
|
+
* own fields (so `assetgrove confirm` can rebuild them from a verified body) plus, when the
|
|
64
|
+
* WorkPlan is at hand, its candidate count, which the digest does not cover.
|
|
65
|
+
*/
|
|
66
|
+
export function spendShown(id, body, candidates, nearMatches, nearMatchSheet) {
|
|
67
|
+
const providers = [...new Set(body.jobs.map((j) => j.provider).filter(Boolean))];
|
|
68
|
+
const region = body.options?.["region"];
|
|
69
|
+
const regions = Array.isArray(region) && region.every((r) => typeof r === "string")
|
|
70
|
+
? region
|
|
71
|
+
: undefined;
|
|
72
|
+
const summary = `${body.command} would spend up to $${body.forecastUsd.toFixed(4)} (cap $${body.capUsd.toFixed(2)})`;
|
|
73
|
+
return {
|
|
74
|
+
summary: (regions
|
|
75
|
+
? `${summary}; regions: ${regions.map((r, i) => `${i + 1}) ${r}`).join("; ")}`
|
|
76
|
+
: summary) +
|
|
77
|
+
(nearMatches !== undefined && nearMatches.length > 0
|
|
78
|
+
? `; existing picked assets to look at before spending (ranked closest to the request, not checked as matches): ${nearMatches
|
|
79
|
+
.map((m, n) => `${n + 1}. ${m.address}${m.sharedText?.title ? ` "${m.sharedText.title}"` : ""}`)
|
|
80
|
+
.join(", ")}` +
|
|
81
|
+
(nearMatchSheet !== undefined ? `; contact sheet: ${nearMatchSheet}` : "")
|
|
82
|
+
: ""),
|
|
83
|
+
details: {
|
|
84
|
+
command: body.command,
|
|
85
|
+
jobs: body.jobs,
|
|
86
|
+
...(candidates !== undefined && { candidates }),
|
|
87
|
+
...(nearMatches !== undefined &&
|
|
88
|
+
nearMatches.length > 0 && {
|
|
89
|
+
nearMatches: nearMatches.map((m) => ({
|
|
90
|
+
rank: m.rank,
|
|
91
|
+
address: m.address,
|
|
92
|
+
...(m.sharedText?.title && { title: m.sharedText.title }),
|
|
93
|
+
})),
|
|
94
|
+
...(nearMatchSheet !== undefined && { nearMatchSheet }),
|
|
95
|
+
}),
|
|
96
|
+
...(regions && { regions }),
|
|
97
|
+
forecastUsd: body.forecastUsd,
|
|
98
|
+
capUsd: body.capUsd,
|
|
99
|
+
providers,
|
|
100
|
+
digest: id,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** The spend request of a WorkPlan: its digest body, and what a person is shown. */
|
|
105
|
+
export function spendRequest(command, round, plan) {
|
|
106
|
+
const body = {
|
|
107
|
+
command,
|
|
108
|
+
round,
|
|
109
|
+
inputs: plan.inputs,
|
|
110
|
+
options: plan.options,
|
|
111
|
+
jobs: plan.jobs,
|
|
112
|
+
forecastUsd: plan.forecastUsd,
|
|
113
|
+
capUsd: plan.capUsd,
|
|
114
|
+
policyTextSha256: plan.policyTextSha256,
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
kind: "spend",
|
|
118
|
+
id: plan.digest,
|
|
119
|
+
...spendShown(plan.digest, body, plan.candidates, plan.nearMatches, plan.nearMatchSheet),
|
|
120
|
+
body,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/** The policy request of a borderline prompt-policy answer: what a person confirms to go on. */
|
|
124
|
+
export function policyRequest(command, plan, record) {
|
|
125
|
+
const body = {
|
|
126
|
+
command,
|
|
127
|
+
digest: plan.digest,
|
|
128
|
+
policyTextSha256: plan.policyTextSha256,
|
|
129
|
+
model: record.model ?? "",
|
|
130
|
+
probability: record.probability ?? 0,
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
kind: "policy",
|
|
134
|
+
id: digestOf(body),
|
|
135
|
+
summary: `the ${command} request reads as borderline to the prompt-policy check (model ${body.model} gives ${body.probability.toFixed(2)}): confirm it asks for no copy of a protected style, work, character or person`,
|
|
136
|
+
details: { ...body },
|
|
137
|
+
body,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Asks a person to clear a borderline request (exit 8 `confirmation_required` when no one does;
|
|
142
|
+
* headless settings do not). The cleared record names the confirmation.
|
|
143
|
+
*/
|
|
144
|
+
async function clearBorderline(ctx, plan, command, record) {
|
|
145
|
+
const cleared = await requireConfirmation(policyRequest(command, plan, record), gateOf(ctx), {
|
|
146
|
+
person: true,
|
|
147
|
+
});
|
|
148
|
+
return { ...record, clearedBy: { id: cleared.digest, method: cleared.method } };
|
|
149
|
+
}
|
|
150
|
+
/** Adds the confirmation to the run's `run.json`, whoever wrote it. */
|
|
151
|
+
async function recordConfirmation(runDir, record) {
|
|
152
|
+
const path = join(runDir, RUN_RECORD_FILE);
|
|
153
|
+
let run;
|
|
154
|
+
try {
|
|
155
|
+
run = JSON.parse(await readFile(path, "utf8"));
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
await writeFile(path, `${JSON.stringify({ ...run, confirmation: record }, null, 2)}\n`);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Executes a paid command's request: `plan` is its free plan step, `run` its real run. A thrown
|
|
164
|
+
* error becomes an outcome through `toOutcome`. `prior` names an earlier confirmation that covers
|
|
165
|
+
* this request (apply's plan); `round` is the request's round, part of its digest.
|
|
166
|
+
*/
|
|
167
|
+
export async function executeRun(options) {
|
|
168
|
+
const { command, plan, ctx } = options;
|
|
169
|
+
if (plan.forecastUsd > plan.capUsd + 1e-9)
|
|
170
|
+
return refused("cap_refused", `refused: the forecast $${plan.forecastUsd.toFixed(4)} exceeds the $${plan.capUsd.toFixed(2)} cap${capFromClause(plan.capSource)}`, 3, {
|
|
171
|
+
forecastUsd: plan.forecastUsd,
|
|
172
|
+
capUsd: plan.capUsd,
|
|
173
|
+
...(plan.capSource && { capSource: plan.capSource }),
|
|
174
|
+
});
|
|
175
|
+
// A paid run first retries pending reconcile lookups, then is refused while a spend hold is not
|
|
176
|
+
// acknowledged (src/reconcile.ts), unless it had submitted jobs: it collects those, which spends
|
|
177
|
+
// nothing new, and its first new spend ends it with the same refusal (src/calls.ts).
|
|
178
|
+
let reconcileCtx;
|
|
179
|
+
let reconcile;
|
|
180
|
+
let spendHold;
|
|
181
|
+
if (plan.paid) {
|
|
182
|
+
reconcileCtx = await reconcileContext(ctx, options.providerScript);
|
|
183
|
+
const run = {
|
|
184
|
+
runId: runIdOfDir(plan.runDir),
|
|
185
|
+
runDir: plan.runDir,
|
|
186
|
+
providers: plan.jobs.map((j) => j.provider),
|
|
187
|
+
};
|
|
188
|
+
try {
|
|
189
|
+
reconcile = await startRunReconcile(reconcileCtx, run);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
if (!(error instanceof SpendHoldError))
|
|
193
|
+
throw error;
|
|
194
|
+
const journal = new Journal(plan.runDir, runIdOfDir(plan.runDir));
|
|
195
|
+
if (!journal.openJobs().some((job) => job.handle !== undefined))
|
|
196
|
+
return refused("spend_hold", error.message, 3);
|
|
197
|
+
spendHold = error;
|
|
198
|
+
// The jobs it collects settle in the ledger, and its end compares them with the provider.
|
|
199
|
+
reconcile = runReconcileOf(reconcileCtx, run);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
await openRunDir(plan);
|
|
203
|
+
let lock;
|
|
204
|
+
try {
|
|
205
|
+
lock = acquireRunLock(plan.runDir);
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
if (error instanceof RunInProgressError)
|
|
209
|
+
return refused("run_in_progress", error.message, 2);
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
const runId = runIdOfDir(plan.runDir);
|
|
214
|
+
const previous = readRunState(plan.runDir);
|
|
215
|
+
if (previous?.status === "finished" &&
|
|
216
|
+
previous.outcome !== undefined &&
|
|
217
|
+
options.replayFinished !== false) {
|
|
218
|
+
// A finished request is returned as it ended: no provider call, no ledger entry.
|
|
219
|
+
const stored = previous.outcome;
|
|
220
|
+
ctx.progress?.({ progress: 1, total: 1, message: `run ${runId} reused` });
|
|
221
|
+
return {
|
|
222
|
+
exitCode: stored.exitCode,
|
|
223
|
+
fields: { ...stored.fields, ...runFields(plan, true) },
|
|
224
|
+
human: stored.human,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
// Before the first reservation and on every resume: no confirmation, no run (exit 8).
|
|
228
|
+
let confirmation;
|
|
229
|
+
if (needsSpendConfirmation(plan)) {
|
|
230
|
+
try {
|
|
231
|
+
confirmation = await requireConfirmation(spendRequest(command, options.round ?? DEFAULT_ROUND, plan), gateOf(ctx), { ...(options.prior && { prior: options.prior }), runDir: plan.runDir });
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
return options.toOutcome(error);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const state = {
|
|
238
|
+
runId,
|
|
239
|
+
command,
|
|
240
|
+
digest: plan.digest,
|
|
241
|
+
status: "running",
|
|
242
|
+
pid: process.pid,
|
|
243
|
+
startedAt: new Date().toISOString(),
|
|
244
|
+
attempts: (previous?.attempts ?? 0) + 1,
|
|
245
|
+
};
|
|
246
|
+
await writeState(plan.runDir, state);
|
|
247
|
+
// A record left by an earlier attempt of the same request is replaced by this one's.
|
|
248
|
+
await rm(join(plan.runDir, RUN_RECORD_FILE), { force: true });
|
|
249
|
+
await rm(join(plan.runDir, CONTACT_SHEET_FILE), { force: true });
|
|
250
|
+
const progress = progressReporter(plan, ctx);
|
|
251
|
+
const journal = new Journal(plan.runDir, runId);
|
|
252
|
+
const scope = {
|
|
253
|
+
journal,
|
|
254
|
+
onCall: progress.onCall,
|
|
255
|
+
...(confirmation && { clearance: { digest: plan.digest, record: confirmation } }),
|
|
256
|
+
...(spendHold && { spendHold }),
|
|
257
|
+
};
|
|
258
|
+
let promptPolicy = plan.promptPolicy;
|
|
259
|
+
let outcome;
|
|
260
|
+
try {
|
|
261
|
+
outcome = await withRunScope(scope, async () => {
|
|
262
|
+
// The run's first job (design section 16): the prompt policy's model check, before any
|
|
263
|
+
// other call. A refusal exits 9; a check that cannot run exits 4 (fails closed). When it
|
|
264
|
+
// objects only to model-written text, the record's `fallback` tells the command to use
|
|
265
|
+
// the template's prompt in its place.
|
|
266
|
+
const text = policyPartsOf(plan);
|
|
267
|
+
if (text !== undefined && plan.promptPolicy !== undefined) {
|
|
268
|
+
try {
|
|
269
|
+
const checked = await promptPolicyCheck(ctx, options, plan, text, plan.promptPolicy);
|
|
270
|
+
scope.promptPolicy = checked.record;
|
|
271
|
+
scope.priorSpentUsd = checked.spentUsd;
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
const refusedRecord = error.policy;
|
|
275
|
+
if (refusedRecord !== undefined)
|
|
276
|
+
promptPolicy = refusedRecord;
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
// The record is the run's before a person is asked, so a run stopped for confirmation
|
|
280
|
+
// (exit 8) keeps the deciding answer's model, probability, cut and `borderline`.
|
|
281
|
+
promptPolicy = scope.promptPolicy;
|
|
282
|
+
if (scope.promptPolicy?.borderline)
|
|
283
|
+
scope.promptPolicy = await clearBorderline(ctx, plan, command, scope.promptPolicy);
|
|
284
|
+
promptPolicy = scope.promptPolicy;
|
|
285
|
+
}
|
|
286
|
+
return options.run({
|
|
287
|
+
...ctx,
|
|
288
|
+
run: { dir: plan.runDir, plan, ...(promptPolicy && { promptPolicy }) },
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
outcome = options.toOutcome(error);
|
|
294
|
+
}
|
|
295
|
+
progress.finish();
|
|
296
|
+
outcome = { ...outcome, fields: { ...outcome.fields, ...runFields(plan, false) } };
|
|
297
|
+
const finishedAt = new Date().toISOString();
|
|
298
|
+
if (!existsSync(join(plan.runDir, RUN_RECORD_FILE))) {
|
|
299
|
+
const spent = outcome.fields["spentUsd"];
|
|
300
|
+
await writeRunRecord({
|
|
301
|
+
runId,
|
|
302
|
+
runDir: plan.runDir,
|
|
303
|
+
command,
|
|
304
|
+
digest: plan.digest,
|
|
305
|
+
startedAt: state.startedAt,
|
|
306
|
+
finishedAt,
|
|
307
|
+
ok: outcome.exitCode === 0,
|
|
308
|
+
exitCode: outcome.exitCode,
|
|
309
|
+
...(outcome.error && { error: outcome.error.code }),
|
|
310
|
+
...(typeof spent === "number" && { spentUsd: spent }),
|
|
311
|
+
...(promptPolicy && { promptPolicy }),
|
|
312
|
+
...(existsSync(join(plan.runDir, CONTACT_SHEET_FILE)) && {
|
|
313
|
+
contactSheet: CONTACT_SHEET_FILE,
|
|
314
|
+
}),
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
if (reconcileCtx !== undefined && reconcile !== undefined) {
|
|
318
|
+
const entries = await reconciled(reconcileCtx, reconcile);
|
|
319
|
+
await recordReconcile(plan.runDir, entries);
|
|
320
|
+
for (const e of entries)
|
|
321
|
+
if (e.status === "held")
|
|
322
|
+
ctx.log(`spend hold ${e.holdId}: provider "${e.provider}" reports $${e.providerUsd?.toFixed(4)} against $${e.ledgerUsd?.toFixed(4)} in the ledger; paid runs are refused until it is acknowledged`);
|
|
323
|
+
}
|
|
324
|
+
if (confirmation)
|
|
325
|
+
await recordConfirmation(plan.runDir, confirmation);
|
|
326
|
+
const ok = outcome.exitCode === 0;
|
|
327
|
+
// A finished run consumes its confirmation: it pays for no further run.
|
|
328
|
+
if (ok && confirmation)
|
|
329
|
+
await bindConfirmation(ctx.settings.configDir, confirmation.digest, confirmation.digest === plan.digest ? "run" : "coveredRun", plan.runDir, true);
|
|
330
|
+
await writeState(plan.runDir, {
|
|
331
|
+
...state,
|
|
332
|
+
status: ok ? "finished" : "failed",
|
|
333
|
+
finishedAt,
|
|
334
|
+
exitCode: outcome.exitCode,
|
|
335
|
+
...(ok && {
|
|
336
|
+
outcome: { exitCode: outcome.exitCode, fields: outcome.fields, human: outcome.human },
|
|
337
|
+
}),
|
|
338
|
+
});
|
|
339
|
+
return outcome;
|
|
340
|
+
}
|
|
341
|
+
finally {
|
|
342
|
+
lock.release();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* The prompt policy's model check, on the providers and routes of the settings, under the run's
|
|
347
|
+
* cap and the spend ledger of the run's work item; journaled in the run like any other call.
|
|
348
|
+
*/
|
|
349
|
+
async function promptPolicyCheck(ctx, options, plan, text, record) {
|
|
350
|
+
const providers = await providerSet(options.providerScript, ctx);
|
|
351
|
+
const budget = new Budget(plan.capUsd, ledgerFor(spendLedger(ctx, options.workItem), providers));
|
|
352
|
+
// The whole request's forecast must fit the ledger before its first call, this one.
|
|
353
|
+
budget.check(plan.forecastUsd, `the ${plan.jobs.length > 1 ? "run" : "prompt-policy check"}`);
|
|
354
|
+
const caller = new Caller({
|
|
355
|
+
provider: providers,
|
|
356
|
+
budget,
|
|
357
|
+
routes: providers.routes,
|
|
358
|
+
log: ctx.log,
|
|
359
|
+
});
|
|
360
|
+
const checked = await checkPromptModel(caller, text, record, promptPolicyCutOf(providers));
|
|
361
|
+
// The command's budgets count this spend against the same cap (src/budget.ts), and each counts
|
|
362
|
+
// the run's unanswered ledger spend itself.
|
|
363
|
+
return { record: checked, spentUsd: budget.spentUsd - budget.unansweredUsd };
|
|
364
|
+
}
|
|
365
|
+
/** The settings and the providers they make, for reconciling; makes no call. */
|
|
366
|
+
async function reconcileContext(ctx, providerScript) {
|
|
367
|
+
const script = providerScript !== undefined ? await loadScript(providerScript, ctx) : undefined;
|
|
368
|
+
const providers = createProviders(ctx.settings, {
|
|
369
|
+
...(ctx.env && { env: ctx.env }),
|
|
370
|
+
...(script && { script }),
|
|
371
|
+
...(ctx.extensions && { adapters: ctx.extensions.adapters }),
|
|
372
|
+
});
|
|
373
|
+
return { settings: ctx.settings, providers };
|
|
374
|
+
}
|
|
375
|
+
/** The run's reconcile; an error reconciling never changes how the run ended. */
|
|
376
|
+
async function reconciled(rctx, run) {
|
|
377
|
+
try {
|
|
378
|
+
return await finishRunReconcile(rctx, run);
|
|
379
|
+
}
|
|
380
|
+
catch (error) {
|
|
381
|
+
return run.providers.map((provider) => ({
|
|
382
|
+
provider,
|
|
383
|
+
status: "failed",
|
|
384
|
+
runId: run.runId,
|
|
385
|
+
note: error.message,
|
|
386
|
+
}));
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Progress for a connected client: one update when the run starts, one per call answered, and
|
|
391
|
+
* one for each job that had none by the end, so every job is reported at least once.
|
|
392
|
+
*/
|
|
393
|
+
function progressReporter(plan, ctx) {
|
|
394
|
+
const send = ctx.progress;
|
|
395
|
+
const total = plan.jobs.reduce((sum, job) => sum + job.count, 0);
|
|
396
|
+
const reported = new Set();
|
|
397
|
+
let answered = 0;
|
|
398
|
+
send?.({ progress: 0, total, message: `run ${runIdOfDir(plan.runDir)}: ${total} call(s)` });
|
|
399
|
+
return {
|
|
400
|
+
onCall: send
|
|
401
|
+
? (call) => {
|
|
402
|
+
answered++;
|
|
403
|
+
reported.add(call.operation);
|
|
404
|
+
send({
|
|
405
|
+
progress: Math.min(answered, total),
|
|
406
|
+
total,
|
|
407
|
+
message: `${call.operation}${call.reused ? " (journal)" : ""}: ${answered} of ${total}`,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
: undefined,
|
|
411
|
+
finish() {
|
|
412
|
+
if (!send)
|
|
413
|
+
return;
|
|
414
|
+
for (const job of plan.jobs) {
|
|
415
|
+
if (reported.has(job.operation))
|
|
416
|
+
continue;
|
|
417
|
+
reported.add(job.operation);
|
|
418
|
+
send({ progress: total, total, message: `${job.operation}: done` });
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
}
|