@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,28 @@
|
|
|
1
|
+
/** Whether a hit on `term` refuses for free: a name not marked ambiguous. */
|
|
2
|
+
export declare function refusesFree(term: {
|
|
3
|
+
kind: BlockKind;
|
|
4
|
+
ambiguous?: boolean;
|
|
5
|
+
}): boolean;
|
|
6
|
+
/** What a term names: an imitation phrase, an artist, a studio, a game or a character. */
|
|
7
|
+
export type BlockKind = "phrase" | "artist" | "studio" | "game" | "character" | "person";
|
|
8
|
+
export interface BlockTerm {
|
|
9
|
+
term: string;
|
|
10
|
+
kind: BlockKind;
|
|
11
|
+
/**
|
|
12
|
+
* A name that is also an ordinary word or a given name (a kind of weather, a kind of star, a
|
|
13
|
+
* common first name): a hit on it is decided by the model check, not refused for free.
|
|
14
|
+
*/
|
|
15
|
+
ambiguous?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface Blocklist {
|
|
18
|
+
terms: BlockTerm[];
|
|
19
|
+
/** sha256 hex of the file's bytes. */
|
|
20
|
+
sha256: string;
|
|
21
|
+
path: string;
|
|
22
|
+
}
|
|
23
|
+
/** The package blocklist's path: `policy/blocklist.json` at the package root (src/ and dist/ alike). */
|
|
24
|
+
export declare const BLOCKLIST_PATH: string;
|
|
25
|
+
/** Reads and checks a blocklist file. */
|
|
26
|
+
export declare function readBlocklist(path?: string): Blocklist;
|
|
27
|
+
/** The package blocklist, read once. */
|
|
28
|
+
export declare function packageBlocklist(): Blocklist;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package blocklist of the prompt policy (design section 16): `policy/blocklist.json`, format
|
|
3
|
+
* `assetgrove-blocklist/1`, the terms the policy looks for. An unambiguous name refuses for free; a
|
|
4
|
+
* phrase or a name marked `ambiguous` is a hit the model check decides. Names in it are exempt from
|
|
5
|
+
* the names rule (docs/decisions.md).
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { InputError } from "../errors.js";
|
|
11
|
+
import { readFormat } from "../formats.js";
|
|
12
|
+
/** Whether a hit on `term` refuses for free: a name not marked ambiguous. */
|
|
13
|
+
export function refusesFree(term) {
|
|
14
|
+
return term.kind !== "phrase" && term.ambiguous !== true;
|
|
15
|
+
}
|
|
16
|
+
const KINDS = new Set([
|
|
17
|
+
"phrase",
|
|
18
|
+
"artist",
|
|
19
|
+
"studio",
|
|
20
|
+
"game",
|
|
21
|
+
"character",
|
|
22
|
+
"person",
|
|
23
|
+
]);
|
|
24
|
+
/** The package blocklist's path: `policy/blocklist.json` at the package root (src/ and dist/ alike). */
|
|
25
|
+
export const BLOCKLIST_PATH = fileURLToPath(new URL("../../policy/blocklist.json", import.meta.url));
|
|
26
|
+
/** Reads and checks a blocklist file. */
|
|
27
|
+
export function readBlocklist(path = BLOCKLIST_PATH) {
|
|
28
|
+
let bytes;
|
|
29
|
+
let parsed;
|
|
30
|
+
try {
|
|
31
|
+
bytes = readFileSync(path);
|
|
32
|
+
parsed = JSON.parse(bytes.toString("utf8"));
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw new InputError(`cannot read the prompt blocklist ${path}`, { cause: error });
|
|
36
|
+
}
|
|
37
|
+
const { value } = readFormat("blocklist", parsed, path);
|
|
38
|
+
const terms = value.terms;
|
|
39
|
+
if (!Array.isArray(terms) ||
|
|
40
|
+
terms.some((t) => t === null ||
|
|
41
|
+
typeof t !== "object" ||
|
|
42
|
+
typeof t.term !== "string" ||
|
|
43
|
+
!t.term.trim() ||
|
|
44
|
+
!KINDS.has(t.kind) ||
|
|
45
|
+
(t.ambiguous !== undefined &&
|
|
46
|
+
typeof t.ambiguous !== "boolean")))
|
|
47
|
+
throw new InputError(`${path}: terms must be a list of {term, kind, ambiguous?}`);
|
|
48
|
+
return {
|
|
49
|
+
terms: terms,
|
|
50
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
51
|
+
path,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
let cached;
|
|
55
|
+
/** The package blocklist, read once. */
|
|
56
|
+
export function packageBlocklist() {
|
|
57
|
+
return (cached ??= readBlocklist());
|
|
58
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The brief policy's model check (#324): whether free text asks to change or ignore a protected
|
|
3
|
+
* field of the style bible (its palette, a character's identity text, the audience, the
|
|
4
|
+
* proportions) or to show something a content limit forbids. It is read by a model, never matched
|
|
5
|
+
* by word patterns: one Boolean decide call on the `brief-policy` operation (the decisions role)
|
|
6
|
+
* per protected field, so a refusal names the field. `createPlan` runs it, inside the confirmed
|
|
7
|
+
* spend, on the brief's free text before the compiler call and on the compiler's own text after
|
|
8
|
+
* it; the free plan step only forecasts the calls.
|
|
9
|
+
*/
|
|
10
|
+
import type { Caller } from "../calls.ts";
|
|
11
|
+
import type { ArtBible } from "../bible.ts";
|
|
12
|
+
import type { DecisionQuestion } from "../gateway/provider.ts";
|
|
13
|
+
import { BRIEF_POLICY_OPERATION } from "../routes.ts";
|
|
14
|
+
export { BRIEF_POLICY_OPERATION };
|
|
15
|
+
/**
|
|
16
|
+
* The probability at or above which the check says the text departs from the bible: the same
|
|
17
|
+
* cut as the prompt policy's model check (docs/decisions.md, "Brief policy threshold").
|
|
18
|
+
*/
|
|
19
|
+
export declare const BRIEF_POLICY_THRESHOLD = 0.5;
|
|
20
|
+
/** The protected fields the check asks about, in the order it asks. */
|
|
21
|
+
export declare const BRIEF_POLICY_FIELDS: readonly ["palette", "identity", "audience", "proportions", "contentLimits"];
|
|
22
|
+
export type BriefPolicyField = (typeof BRIEF_POLICY_FIELDS)[number];
|
|
23
|
+
/** Whose text is checked: the author's brief, or the prompt compiler's output. */
|
|
24
|
+
export type BriefPolicyTarget = "brief" | "compiler";
|
|
25
|
+
/** The bible's protected values, as the model is given them. */
|
|
26
|
+
export interface ProtectedFields {
|
|
27
|
+
palette: string[];
|
|
28
|
+
audience: string;
|
|
29
|
+
proportions: string;
|
|
30
|
+
/** The subject's identity lock, when it has one. */
|
|
31
|
+
identity?: {
|
|
32
|
+
subject: string;
|
|
33
|
+
signatureFeatures: string[];
|
|
34
|
+
proportions: string;
|
|
35
|
+
};
|
|
36
|
+
contentLimits: string[];
|
|
37
|
+
}
|
|
38
|
+
/** The protected fields of a bible for a subject (its identity lock, if any). */
|
|
39
|
+
export declare function protectedFields(bible: ArtBible, palette: readonly string[], subject: string): ProtectedFields;
|
|
40
|
+
/** The fields there is something to ask about: identity only with a lock, limits only when listed. */
|
|
41
|
+
export declare function briefPolicyFields(fields: ProtectedFields): BriefPolicyField[];
|
|
42
|
+
/** The Boolean question the model answers about one protected field. */
|
|
43
|
+
export declare function briefPolicyQuestion(field: BriefPolicyField): DecisionQuestion;
|
|
44
|
+
/** The labelled parts of a text the check reads: `[label, text]`. */
|
|
45
|
+
export type LabelledText = Array<[string, string]>;
|
|
46
|
+
/** The text the model is given: the protected fields, the field in question and the labelled text. */
|
|
47
|
+
export declare function briefPolicyPrompt(fields: ProtectedFields, field: BriefPolicyField, target: BriefPolicyTarget, text: LabelledText): string;
|
|
48
|
+
/** The field and target a brief-policy prompt asks about; for scripted providers and tests. */
|
|
49
|
+
export declare function briefPolicyAsked(prompt: string): {
|
|
50
|
+
field: BriefPolicyField;
|
|
51
|
+
target: BriefPolicyTarget;
|
|
52
|
+
} | undefined;
|
|
53
|
+
/** One field's verdict on one text. */
|
|
54
|
+
export interface BriefPolicyVerdict {
|
|
55
|
+
target: BriefPolicyTarget;
|
|
56
|
+
field: BriefPolicyField;
|
|
57
|
+
probability: number;
|
|
58
|
+
/** `<provider>:brief-policy:<model>`. */
|
|
59
|
+
model: string;
|
|
60
|
+
/** The probability is at or above `BRIEF_POLICY_THRESHOLD`. */
|
|
61
|
+
objects: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* One Boolean decide call per field about `text`. A call that fails or answers out of type throws
|
|
65
|
+
* `ProviderError` (exit 4: the check fails closed); a refused route or budget keeps its own error.
|
|
66
|
+
*/
|
|
67
|
+
export declare function decideBriefPolicy(caller: Caller, fields: ProtectedFields, target: BriefPolicyTarget, text: LabelledText): Promise<BriefPolicyVerdict[]>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { classify } from "../commands/result.js";
|
|
2
|
+
import { ProviderError } from "../errors.js";
|
|
3
|
+
import { BRIEF_POLICY_OPERATION } from "../routes.js";
|
|
4
|
+
export { BRIEF_POLICY_OPERATION };
|
|
5
|
+
/**
|
|
6
|
+
* The probability at or above which the check says the text departs from the bible: the same
|
|
7
|
+
* cut as the prompt policy's model check (docs/decisions.md, "Brief policy threshold").
|
|
8
|
+
*/
|
|
9
|
+
export const BRIEF_POLICY_THRESHOLD = 0.5;
|
|
10
|
+
/** The protected fields the check asks about, in the order it asks. */
|
|
11
|
+
export const BRIEF_POLICY_FIELDS = [
|
|
12
|
+
"palette",
|
|
13
|
+
"identity",
|
|
14
|
+
"audience",
|
|
15
|
+
"proportions",
|
|
16
|
+
"contentLimits",
|
|
17
|
+
];
|
|
18
|
+
/** The protected fields of a bible for a subject (its identity lock, if any). */
|
|
19
|
+
export function protectedFields(bible, palette, subject) {
|
|
20
|
+
const lock = Object.hasOwn(bible.identities, subject) ? bible.identities[subject] : undefined;
|
|
21
|
+
return {
|
|
22
|
+
palette: [...palette],
|
|
23
|
+
audience: bible.tone.audience,
|
|
24
|
+
proportions: bible.axes.proportions,
|
|
25
|
+
...(lock && {
|
|
26
|
+
identity: {
|
|
27
|
+
subject,
|
|
28
|
+
signatureFeatures: [...lock.signatureFeatures],
|
|
29
|
+
proportions: lock.proportions,
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
contentLimits: [...bible.tone.contentLimits],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** The fields there is something to ask about: identity only with a lock, limits only when listed. */
|
|
36
|
+
export function briefPolicyFields(fields) {
|
|
37
|
+
return BRIEF_POLICY_FIELDS.filter((field) => (field !== "identity" || fields.identity !== undefined) &&
|
|
38
|
+
(field !== "contentLimits" || fields.contentLimits.length > 0));
|
|
39
|
+
}
|
|
40
|
+
const ASKS = {
|
|
41
|
+
palette: "Does the text ask to change, replace, extend or ignore the bible's palette, for example by asking for colours outside it or by naming other colours to paint the asset in?",
|
|
42
|
+
identity: "Does the text ask to change or ignore the character's locked identity: its signature features or its locked proportions?",
|
|
43
|
+
audience: "Does the text ask to change or ignore the bible's audience, for example by asking for content meant for an older audience than the bible's?",
|
|
44
|
+
proportions: "Does the text ask to change or ignore the bible's proportions?",
|
|
45
|
+
contentLimits: "Does the text ask to show something one of the bible's content limits forbids?",
|
|
46
|
+
};
|
|
47
|
+
/** The Boolean question the model answers about one protected field. */
|
|
48
|
+
export function briefPolicyQuestion(field) {
|
|
49
|
+
return {
|
|
50
|
+
type: "boolean",
|
|
51
|
+
instructions: `${ASKS[field]} Judge what the text asks for, not which words it uses: a word that merely sits near the field's name is not a request.`,
|
|
52
|
+
whenTrue: "the text asks the asset to depart from this protected field of the style bible",
|
|
53
|
+
whenFalse: "the text describes the asset, its use or its surroundings without asking to depart from this protected field, even when it uses words such as change, use or set, or names the field",
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const FIELD_LINE = "Protected field in question: ";
|
|
57
|
+
const TARGET_LINE = "Text checked: ";
|
|
58
|
+
const TARGET_LABEL = {
|
|
59
|
+
brief: "the author's brief (its free-text fields)",
|
|
60
|
+
compiler: "the prompt compiler's own prompt text",
|
|
61
|
+
};
|
|
62
|
+
/** The text the model is given: the protected fields, the field in question and the labelled text. */
|
|
63
|
+
export function briefPolicyPrompt(fields, field, target, text) {
|
|
64
|
+
return [
|
|
65
|
+
"Style bible, protected fields (immutable):",
|
|
66
|
+
JSON.stringify(fields),
|
|
67
|
+
`${FIELD_LINE}${field}`,
|
|
68
|
+
`${TARGET_LINE}${target} (${TARGET_LABEL[target]}), each part verbatim between the markers:`,
|
|
69
|
+
...text.map(([label, value]) => `${label}:\n<<<\n${value}\n>>>`),
|
|
70
|
+
].join("\n");
|
|
71
|
+
}
|
|
72
|
+
/** The field and target a brief-policy prompt asks about; for scripted providers and tests. */
|
|
73
|
+
export function briefPolicyAsked(prompt) {
|
|
74
|
+
const field = new RegExp(`^${FIELD_LINE}(\\w+)$`, "m").exec(prompt)?.[1];
|
|
75
|
+
const target = new RegExp(`^${TARGET_LINE}(\\w+) `, "m").exec(prompt)?.[1];
|
|
76
|
+
if (!BRIEF_POLICY_FIELDS.includes(field ?? "") ||
|
|
77
|
+
(target !== "brief" && target !== "compiler"))
|
|
78
|
+
return undefined;
|
|
79
|
+
return { field: field, target };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* One Boolean decide call per field about `text`. A call that fails or answers out of type throws
|
|
83
|
+
* `ProviderError` (exit 4: the check fails closed); a refused route or budget keeps its own error.
|
|
84
|
+
*/
|
|
85
|
+
export async function decideBriefPolicy(caller, fields, target, text) {
|
|
86
|
+
const verdicts = [];
|
|
87
|
+
for (const field of briefPolicyFields(fields)) {
|
|
88
|
+
let result;
|
|
89
|
+
try {
|
|
90
|
+
result = await caller.decide(BRIEF_POLICY_OPERATION, briefPolicyPrompt(fields, field, target, text), [], briefPolicyQuestion(field));
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (classify(error).code !== "internal_error")
|
|
94
|
+
throw error;
|
|
95
|
+
throw new ProviderError(`the brief-policy check could not run: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
96
|
+
}
|
|
97
|
+
const { answer } = result.result;
|
|
98
|
+
if (answer.type !== "boolean" || !Number.isFinite(answer.probability))
|
|
99
|
+
throw new ProviderError("the brief-policy check did not answer with a probability");
|
|
100
|
+
const probability = Math.min(1, Math.max(0, answer.probability));
|
|
101
|
+
verdicts.push({
|
|
102
|
+
target,
|
|
103
|
+
field,
|
|
104
|
+
probability,
|
|
105
|
+
model: result.record.route,
|
|
106
|
+
objects: probability >= BRIEF_POLICY_THRESHOLD,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return verdicts;
|
|
110
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The cut of one route. */
|
|
2
|
+
export interface PromptPolicyCut {
|
|
3
|
+
confirmAt: number;
|
|
4
|
+
refuseAt: number;
|
|
5
|
+
}
|
|
6
|
+
/** The table's path: `policy/prompt-policy-cuts.json` at the package root (src/ and dist/ alike). */
|
|
7
|
+
export declare const PROMPT_POLICY_CUTS_PATH: string;
|
|
8
|
+
/** The bars a settings cut's measured rates must meet (docs/decisions.md "Prompt-policy bars"). */
|
|
9
|
+
export declare const PROMPT_POLICY_BAR_RATES: {
|
|
10
|
+
readonly minRefusalRate: 0.9;
|
|
11
|
+
readonly maxFalseRefusalRate: 0.1;
|
|
12
|
+
};
|
|
13
|
+
/** A cut the developer measured on their own route, with the rates it was measured at. */
|
|
14
|
+
export interface MeasuredPromptPolicyCut extends PromptPolicyCut {
|
|
15
|
+
refusalRate: number;
|
|
16
|
+
falseRefusalRate: number;
|
|
17
|
+
}
|
|
18
|
+
/** Why a settings cut's rates miss the bars, or undefined when they meet them. */
|
|
19
|
+
export declare function barProblem(cut: MeasuredPromptPolicyCut): string | undefined;
|
|
20
|
+
/** Reads and checks a cuts file. */
|
|
21
|
+
export declare function readPromptPolicyCuts(path?: string): Map<string, PromptPolicyCut>;
|
|
22
|
+
/**
|
|
23
|
+
* The cut measured for the decisions route on `adapter` with `model`: the developer's own
|
|
24
|
+
* (`own`, settings `promptPolicy.cuts`) first, then the package file's; undefined when none is.
|
|
25
|
+
*/
|
|
26
|
+
export declare function promptPolicyCut(adapter: string, model: string, own?: Readonly<Record<string, PromptPolicyCut>>): PromptPolicyCut | undefined;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prompt-policy model check's cuts per decisions route: `policy/prompt-policy-cuts.json`,
|
|
3
|
+
* format `assetgrove-prompt-policy-cuts/1`, keyed `<adapter id>:<model>`. A probability under
|
|
4
|
+
* `confirmAt` allows the request, from `confirmAt` up to `refuseAt` a person confirms it (exit 8),
|
|
5
|
+
* and `refuseAt` or more refuses it (exit 9). A route with no entry has no measured rates, and the
|
|
6
|
+
* check is not run on it. The `scripted` adapter, the test stand-in, takes the default gateway
|
|
7
|
+
* route's entry. A developer's own route can record a cut measured on the red-team set in settings
|
|
8
|
+
* `promptPolicy.cuts` (same keys, with the two rates measured), used in place of the file's when
|
|
9
|
+
* its rates meet `PROMPT_POLICY_BAR_RATES`.
|
|
10
|
+
*/
|
|
11
|
+
import { readFileSync } from "node:fs";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { InputError } from "../errors.js";
|
|
14
|
+
import { defaultRoutes, PROMPT_POLICY_OPERATION } from "../routes.js";
|
|
15
|
+
/** The table's path: `policy/prompt-policy-cuts.json` at the package root (src/ and dist/ alike). */
|
|
16
|
+
export const PROMPT_POLICY_CUTS_PATH = fileURLToPath(new URL("../../policy/prompt-policy-cuts.json", import.meta.url));
|
|
17
|
+
/** The bars a settings cut's measured rates must meet (docs/decisions.md "Prompt-policy bars"). */
|
|
18
|
+
export const PROMPT_POLICY_BAR_RATES = { minRefusalRate: 0.9, maxFalseRefusalRate: 0.1 };
|
|
19
|
+
/** Why a settings cut's rates miss the bars, or undefined when they meet them. */
|
|
20
|
+
export function barProblem(cut) {
|
|
21
|
+
if (cut.refusalRate < PROMPT_POLICY_BAR_RATES.minRefusalRate)
|
|
22
|
+
return `refusalRate ${cut.refusalRate} is under the bar ${PROMPT_POLICY_BAR_RATES.minRefusalRate}`;
|
|
23
|
+
if (cut.falseRefusalRate > PROMPT_POLICY_BAR_RATES.maxFalseRefusalRate)
|
|
24
|
+
return `falseRefusalRate ${cut.falseRefusalRate} is over the bar ${PROMPT_POLICY_BAR_RATES.maxFalseRefusalRate}`;
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const FORMAT = "assetgrove-prompt-policy-cuts/1";
|
|
28
|
+
const STAND_IN_ADAPTER = "scripted";
|
|
29
|
+
const GATEWAY_ADAPTER = "vercel-ai-gateway";
|
|
30
|
+
/** Reads and checks a cuts file. */
|
|
31
|
+
export function readPromptPolicyCuts(path = PROMPT_POLICY_CUTS_PATH) {
|
|
32
|
+
let parsed;
|
|
33
|
+
try {
|
|
34
|
+
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
throw new InputError(`cannot read the prompt-policy cuts ${path}`, { cause: error });
|
|
38
|
+
}
|
|
39
|
+
const file = parsed;
|
|
40
|
+
if (file === null || typeof file !== "object" || file.format !== FORMAT)
|
|
41
|
+
throw new InputError(`${path}: format must be "${FORMAT}"`);
|
|
42
|
+
const routes = file.routes;
|
|
43
|
+
if (routes === null || typeof routes !== "object" || Array.isArray(routes))
|
|
44
|
+
throw new InputError(`${path}: routes must be an object keyed <adapter>:<model>`);
|
|
45
|
+
const cuts = new Map();
|
|
46
|
+
for (const [key, value] of Object.entries(routes)) {
|
|
47
|
+
const { confirmAt, refuseAt, refusalRate, falseRefusalRate } = (value ??
|
|
48
|
+
{});
|
|
49
|
+
if (typeof confirmAt !== "number" ||
|
|
50
|
+
typeof refuseAt !== "number" ||
|
|
51
|
+
!(confirmAt >= 0 && confirmAt <= refuseAt && refuseAt <= 1))
|
|
52
|
+
throw new InputError(`${path}: ${key} needs 0 <= confirmAt <= refuseAt <= 1`);
|
|
53
|
+
// Every entry carries the rates a real run measured it at, held to the bars as a settings
|
|
54
|
+
// entry's are: a route with no measured rates has no cut.
|
|
55
|
+
if (typeof refusalRate !== "number" ||
|
|
56
|
+
typeof falseRefusalRate !== "number" ||
|
|
57
|
+
!(refusalRate >= 0 && refusalRate <= 1 && falseRefusalRate >= 0 && falseRefusalRate <= 1))
|
|
58
|
+
throw new InputError(`${path}: ${key} needs refusalRate and falseRefusalRate, each 0..1`);
|
|
59
|
+
const problem = barProblem({ confirmAt, refuseAt, refusalRate, falseRefusalRate });
|
|
60
|
+
if (problem !== undefined)
|
|
61
|
+
throw new InputError(`${path}: ${key}: ${problem}`);
|
|
62
|
+
cuts.set(key, { confirmAt, refuseAt });
|
|
63
|
+
}
|
|
64
|
+
return cuts;
|
|
65
|
+
}
|
|
66
|
+
let cached;
|
|
67
|
+
/**
|
|
68
|
+
* The cut measured for the decisions route on `adapter` with `model`: the developer's own
|
|
69
|
+
* (`own`, settings `promptPolicy.cuts`) first, then the package file's; undefined when none is.
|
|
70
|
+
*/
|
|
71
|
+
export function promptPolicyCut(adapter, model, own = {}) {
|
|
72
|
+
const mine = own[`${adapter}:${model}`];
|
|
73
|
+
if (mine !== undefined)
|
|
74
|
+
return { confirmAt: mine.confirmAt, refuseAt: mine.refuseAt };
|
|
75
|
+
cached ??= readPromptPolicyCuts();
|
|
76
|
+
const key = adapter === STAND_IN_ADAPTER
|
|
77
|
+
? `${GATEWAY_ADAPTER}:${defaultRoutes[PROMPT_POLICY_OPERATION].model}`
|
|
78
|
+
: `${adapter}:${model}`;
|
|
79
|
+
return cached.get(key);
|
|
80
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prompt policy's model check (design section 16). After confirmation, a run's first job is
|
|
3
|
+
* one Choice decide call per ambiguous name a person-written part holds (the protected name, an
|
|
4
|
+
* ordinary word or an unrelated name; only the first refuses), then one Boolean decide call on the `prompt-policy` operation (the decisions role) about the prompt
|
|
5
|
+
* text the plan step collected, given as labelled parts with the blocklist's phrase and
|
|
6
|
+
* ambiguous-name hits and the words around them. The probability is cut per decisions route
|
|
7
|
+
* (src/policy/cuts.ts): under `confirmAt` the run goes on, from `confirmAt` to `refuseAt` a person
|
|
8
|
+
* confirms it (exit 8, the record is `borderline`), and `refuseAt` or more refuses the request
|
|
9
|
+
* with exit 9 `prompt_refused`, unless it objects only to text the prompt compiler wrote: a second
|
|
10
|
+
* call on the person's parts alone then decides, and when it allows, the run uses the template's
|
|
11
|
+
* prompt and records why. The check fails closed: a call that fails or answers out of type exits 4
|
|
12
|
+
* `provider_error`, and an operation no configured provider serves exits 2 `route_unavailable`,
|
|
13
|
+
* at the plan step, before anything is spent.
|
|
14
|
+
*/
|
|
15
|
+
import type { Caller } from "../calls.ts";
|
|
16
|
+
import type { DecisionQuestion } from "../gateway/provider.ts";
|
|
17
|
+
import { PROMPT_POLICY_OPERATION } from "../routes.ts";
|
|
18
|
+
import type { Route } from "../routes.ts";
|
|
19
|
+
import type { PromptPolicyCut } from "./cuts.ts";
|
|
20
|
+
import type { PolicyHit, PolicyReading, PromptPart, PromptPolicyRecord } from "./text.ts";
|
|
21
|
+
export { PROMPT_POLICY_OPERATION };
|
|
22
|
+
/** The Boolean question the model answers about a request's prompt text. */
|
|
23
|
+
export declare const PROMPT_POLICY_QUESTION: DecisionQuestion;
|
|
24
|
+
/**
|
|
25
|
+
* The text the model is given: each part of the request's prompt text, labelled and set apart
|
|
26
|
+
* between markers, then the blocklist's hits with the words around them. A plain string is one
|
|
27
|
+
* unlabelled part.
|
|
28
|
+
*/
|
|
29
|
+
export declare function promptPolicyPrompt(text: string | readonly PromptPart[], hits?: readonly PolicyHit[], readings?: readonly PolicyReading[]): string;
|
|
30
|
+
/** The Choice question an ambiguous name's reading call answers: what the word refers to here. */
|
|
31
|
+
export declare function nameReadingQuestion(term: string, kind: string): DecisionQuestion;
|
|
32
|
+
/** The text a reading call is given: the term, its kind, its sentences and the labelled parts. */
|
|
33
|
+
export declare function nameReadingPrompt(hits: readonly PolicyHit[], parts: readonly PromptPart[]): string;
|
|
34
|
+
/** The term a reading call asks about; for scripted providers and tests. */
|
|
35
|
+
export declare function nameReadingAsked(prompt: string): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* One Choice decide call on `prompt-policy` per ambiguous name a person-written part holds
|
|
38
|
+
* (`readingTerms`). A call that fails or answers out of type throws (exit 4).
|
|
39
|
+
*/
|
|
40
|
+
export declare function readAmbiguousNames(caller: Caller, parts: readonly PromptPart[], hits: readonly PolicyHit[] | undefined): Promise<PolicyReading[]>;
|
|
41
|
+
/** The route the model check would run on; throws `RouteUnavailableError` when none serves it. */
|
|
42
|
+
export declare function promptPolicyRoute(routes: Readonly<Record<string, Route>>): Route;
|
|
43
|
+
/** The model check's verdict on one text: its probability and the call's route. */
|
|
44
|
+
export interface PromptModelVerdict {
|
|
45
|
+
probability: number;
|
|
46
|
+
/** `<provider>:prompt-policy:<model>`. */
|
|
47
|
+
model: string;
|
|
48
|
+
/** `allow` under the cut's `confirmAt`, `confirm` up to its `refuseAt`, `refuse` from it. */
|
|
49
|
+
band: "allow" | "confirm" | "refuse";
|
|
50
|
+
refused: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* One Boolean decide call on `prompt-policy` about `text`. A call that fails or answers out of
|
|
54
|
+
* type throws (a provider failure is exit 4); a refused route or budget keeps its own error.
|
|
55
|
+
*/
|
|
56
|
+
export declare function decidePromptPolicy(caller: Caller, text: string | readonly PromptPart[], hits: readonly PolicyHit[] | undefined, readings: readonly PolicyReading[], cut: PromptPolicyCut): Promise<PromptModelVerdict>;
|
|
57
|
+
/**
|
|
58
|
+
* The run's prompt-policy job. First, one reading call per ambiguous name a person-written part
|
|
59
|
+
* holds (`readAmbiguousNames`): a `protected` reading throws `PromptRefusedError` with the
|
|
60
|
+
* readings recorded, and no other call runs. Then it decides on the labelled `parts` with the
|
|
61
|
+
* record's hits (minus the names read as not protected) and returns
|
|
62
|
+
* the plan step's record with the model and probability added; throws `PromptRefusedError` (exit
|
|
63
|
+
* 9) at the cut's `refuseAt` or more. An answer from `confirmAt` up returns the record allowed
|
|
64
|
+
* with `borderline`: the run asks a person before it goes on. When the parts hold model-written
|
|
65
|
+
* text and the check does not allow, a second call on the person-written parts alone decides: if
|
|
66
|
+
* it allows or is borderline, the record carries `fallback` saying why, and the command uses the
|
|
67
|
+
* template's prompt in place of the compiler's.
|
|
68
|
+
*/
|
|
69
|
+
export declare function checkPromptModel(caller: Caller, parts: string | readonly PromptPart[], given: PromptPolicyRecord, cut: PromptPolicyCut): Promise<PromptPolicyRecord>;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { classify } from "../commands/result.js";
|
|
2
|
+
import { ProviderError } from "../errors.js";
|
|
3
|
+
import { PROMPT_POLICY_OPERATION } from "../routes.js";
|
|
4
|
+
import { asParts, modelWritten, PromptRefusedError, readingTerms } from "./text.js";
|
|
5
|
+
export { PROMPT_POLICY_OPERATION };
|
|
6
|
+
/** The Boolean question the model answers about a request's prompt text. */
|
|
7
|
+
export const PROMPT_POLICY_QUESTION = {
|
|
8
|
+
type: "boolean",
|
|
9
|
+
instructions: "Does this game-asset generation request ask to copy or imitate a specific living artist's style, a studio's or a named game's look, a copyrighted character, or a real person's likeness, by name or by an unmistakable description? Judge what the request asks for, not the words in it. The parts are labelled: the bible's Do's and Don'ts are rules the art must follow, so a rule that forbids imitating a work asks for originality; text marked model-written was written by the prompt compiler, not the person, and a negative prompt lists what the image must not show. A genre, medium or era, the developer's own game named as such, and a fix note that recreates part of the asset's own earlier frame do not ask for a copy. A flagged word that is also an ordinary word or a given name counts only when it is used here as that name.",
|
|
10
|
+
whenTrue: "it names or unmistakably describes a specific artist, studio, game, copyrighted character or real person whose work or likeness the output would copy",
|
|
11
|
+
whenFalse: "it describes an original asset in plain visual words (genre, palette, medium, shapes), even when the words resemble a well-known work",
|
|
12
|
+
};
|
|
13
|
+
/** What each part is, as the model is told. */
|
|
14
|
+
const PART_TITLES = {
|
|
15
|
+
spec: "asset spec (the developer's strings)",
|
|
16
|
+
brief: "brief (the developer's request)",
|
|
17
|
+
tone: "art bible tone fields",
|
|
18
|
+
rules: "art bible Do's and Don'ts: rules the art must follow, not requests",
|
|
19
|
+
template: "prompt template body (the repository's wording)",
|
|
20
|
+
text: "other request text (a note, a subject or a profile's text)",
|
|
21
|
+
"model-prompt": "compiled prompt: model-written by the prompt compiler, not by the person",
|
|
22
|
+
"model-negative": "compiled negative prompt: model-written by the prompt compiler, what the image must not show",
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The text the model is given: each part of the request's prompt text, labelled and set apart
|
|
26
|
+
* between markers, then the blocklist's hits with the words around them. A plain string is one
|
|
27
|
+
* unlabelled part.
|
|
28
|
+
*/
|
|
29
|
+
export function promptPolicyPrompt(text, hits = [], readings = []) {
|
|
30
|
+
if (typeof text === "string")
|
|
31
|
+
return `Game-asset generation request (prompt text, verbatim between the markers):\n<<<\n${text}\n>>>`;
|
|
32
|
+
const sections = text
|
|
33
|
+
.filter((p) => p.text.trim().length > 0)
|
|
34
|
+
.map((p) => `[${p.label}] ${PART_TITLES[p.label]}:\n<<<\n${p.text}\n>>>`);
|
|
35
|
+
// A reading covers the person-written hits it was asked about; the compiler's use of the same
|
|
36
|
+
// name was never read, so it stays on the Boolean call's flagged words.
|
|
37
|
+
const read = new Set(readings.map((r) => r.term));
|
|
38
|
+
const flagged = hits
|
|
39
|
+
.filter((h) => !(read.has(h.term) && !modelWritten({ label: h.part })))
|
|
40
|
+
.map((h) => `- "${h.term}" (${h.ambiguous ? `${h.kind} name that is also an ordinary word or a given name` : h.kind}) in [${h.part}]: "... ${h.context} ..."`);
|
|
41
|
+
return [
|
|
42
|
+
"Game-asset generation request, in labelled parts (each verbatim between the markers):",
|
|
43
|
+
...sections,
|
|
44
|
+
...(flagged.length > 0
|
|
45
|
+
? [
|
|
46
|
+
"Words the blocklist flagged, with the words around them; none refuses by itself, decide what each asks for:",
|
|
47
|
+
...flagged,
|
|
48
|
+
]
|
|
49
|
+
: []),
|
|
50
|
+
...(readings.length > 0
|
|
51
|
+
? [
|
|
52
|
+
"Flagged names already read in the person-written parts as not the protected name (do not count those uses as one; a model-written use listed above is still to be decided):",
|
|
53
|
+
...readings.map((r) => `- "${r.term}": ${r.reading === "word" ? "an ordinary word" : "an unrelated name"}`),
|
|
54
|
+
]
|
|
55
|
+
: []),
|
|
56
|
+
].join("\n");
|
|
57
|
+
}
|
|
58
|
+
/** The Choice question an ambiguous name's reading call answers: what the word refers to here. */
|
|
59
|
+
export function nameReadingQuestion(term, kind) {
|
|
60
|
+
return {
|
|
61
|
+
type: "choice",
|
|
62
|
+
instructions: `The blocklist flagged "${term}", the name of a ${kind} whose work, look or likeness generated art must not copy, and also an ordinary word or a given name. Read the sentences it appears in and the labelled request. Which does "${term}" refer to in this request?`,
|
|
63
|
+
options: {
|
|
64
|
+
protected: `the protected ${kind} "${term}" itself: the request names it to copy or evoke its work, look or likeness`,
|
|
65
|
+
word: `an ordinary word with its everyday meaning (for example weather, a size or a kind of thing), not the ${kind}`,
|
|
66
|
+
"other-name": `an unrelated name: a different person, character, place or thing that happens to share the name, not the ${kind}`,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** The text a reading call is given: the term, its kind, its sentences and the labelled parts. */
|
|
71
|
+
export function nameReadingPrompt(hits, parts) {
|
|
72
|
+
const first = hits[0];
|
|
73
|
+
return [
|
|
74
|
+
`Flagged word: "${first.term}" (blocklist kind: ${first.kind}; also an ordinary word or a given name).`,
|
|
75
|
+
"Where it appears, with the words around it:",
|
|
76
|
+
...hits.map((h) => `- in [${h.part}]: "... ${h.context} ..."`),
|
|
77
|
+
promptPolicyPrompt(parts),
|
|
78
|
+
].join("\n");
|
|
79
|
+
}
|
|
80
|
+
/** The term a reading call asks about; for scripted providers and tests. */
|
|
81
|
+
export function nameReadingAsked(prompt) {
|
|
82
|
+
return /^Flagged word: "([^"]*)"/m.exec(prompt)?.[1];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* One Choice decide call on `prompt-policy` per ambiguous name a person-written part holds
|
|
86
|
+
* (`readingTerms`). A call that fails or answers out of type throws (exit 4).
|
|
87
|
+
*/
|
|
88
|
+
export async function readAmbiguousNames(caller, parts, hits) {
|
|
89
|
+
const readings = [];
|
|
90
|
+
for (const group of readingTerms(hits)) {
|
|
91
|
+
const { term, kind } = group[0];
|
|
92
|
+
let result;
|
|
93
|
+
try {
|
|
94
|
+
result = await caller.decide(PROMPT_POLICY_OPERATION, nameReadingPrompt(group, parts), [], nameReadingQuestion(term, kind));
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (classify(error).code !== "internal_error")
|
|
98
|
+
throw error;
|
|
99
|
+
throw new ProviderError(`the prompt-policy check could not read "${term}": ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
100
|
+
}
|
|
101
|
+
const { answer } = result.result;
|
|
102
|
+
if (answer.type !== "choice")
|
|
103
|
+
throw new ProviderError(`the prompt-policy check did not choose a reading of "${term}"`);
|
|
104
|
+
const probability = result.record.decision?.value;
|
|
105
|
+
readings.push({
|
|
106
|
+
term,
|
|
107
|
+
kind,
|
|
108
|
+
reading: answer.choice,
|
|
109
|
+
model: result.record.route,
|
|
110
|
+
...(probability !== undefined && { probability }),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return readings;
|
|
114
|
+
}
|
|
115
|
+
/** The route the model check would run on; throws `RouteUnavailableError` when none serves it. */
|
|
116
|
+
export function promptPolicyRoute(routes) {
|
|
117
|
+
return routes[PROMPT_POLICY_OPERATION];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* One Boolean decide call on `prompt-policy` about `text`. A call that fails or answers out of
|
|
121
|
+
* type throws (a provider failure is exit 4); a refused route or budget keeps its own error.
|
|
122
|
+
*/
|
|
123
|
+
export async function decidePromptPolicy(caller, text, hits = [], readings, cut) {
|
|
124
|
+
let result;
|
|
125
|
+
try {
|
|
126
|
+
result = await caller.decide(PROMPT_POLICY_OPERATION, promptPolicyPrompt(text, hits, readings), [], PROMPT_POLICY_QUESTION);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
// An error with its own exit (a refused route, budget, limit or input) keeps it; anything
|
|
130
|
+
// else is the check failing to run: fail closed, exit 4.
|
|
131
|
+
if (classify(error).code !== "internal_error")
|
|
132
|
+
throw error;
|
|
133
|
+
throw new ProviderError(`the prompt-policy check could not run: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
134
|
+
}
|
|
135
|
+
const { answer } = result.result;
|
|
136
|
+
if (answer.type !== "boolean" || !Number.isFinite(answer.probability))
|
|
137
|
+
throw new ProviderError("the prompt-policy check did not answer with a probability");
|
|
138
|
+
const probability = Math.min(1, Math.max(0, answer.probability));
|
|
139
|
+
const band = probability >= cut.refuseAt ? "refuse" : probability >= cut.confirmAt ? "confirm" : "allow";
|
|
140
|
+
return { probability, model: result.record.route, band, refused: band === "refuse" };
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The run's prompt-policy job. First, one reading call per ambiguous name a person-written part
|
|
144
|
+
* holds (`readAmbiguousNames`): a `protected` reading throws `PromptRefusedError` with the
|
|
145
|
+
* readings recorded, and no other call runs. Then it decides on the labelled `parts` with the
|
|
146
|
+
* record's hits (minus the names read as not protected) and returns
|
|
147
|
+
* the plan step's record with the model and probability added; throws `PromptRefusedError` (exit
|
|
148
|
+
* 9) at the cut's `refuseAt` or more. An answer from `confirmAt` up returns the record allowed
|
|
149
|
+
* with `borderline`: the run asks a person before it goes on. When the parts hold model-written
|
|
150
|
+
* text and the check does not allow, a second call on the person-written parts alone decides: if
|
|
151
|
+
* it allows or is borderline, the record carries `fallback` saying why, and the command uses the
|
|
152
|
+
* template's prompt in place of the compiler's.
|
|
153
|
+
*/
|
|
154
|
+
export async function checkPromptModel(caller, parts, given, cut) {
|
|
155
|
+
const all = asParts(parts);
|
|
156
|
+
// Each ambiguous name a person wrote is read in its sentence first; a protected reading refuses.
|
|
157
|
+
const readings = await readAmbiguousNames(caller, all, given.hits);
|
|
158
|
+
const record = {
|
|
159
|
+
...(readings.length > 0 ? { ...given, readings } : given),
|
|
160
|
+
cut,
|
|
161
|
+
};
|
|
162
|
+
if (readings.some((r) => r.reading === "protected"))
|
|
163
|
+
throw new PromptRefusedError({ ...record, verdict: "refused" }, "the request's prompt text");
|
|
164
|
+
const verdict = await decidePromptPolicy(caller, all, record.hits, readings, cut);
|
|
165
|
+
const first = answer("all", verdict);
|
|
166
|
+
const checked = (decided, checks, fallback) => ({
|
|
167
|
+
...record,
|
|
168
|
+
verdict: decided.refused && !fallback ? "refused" : "allowed",
|
|
169
|
+
model: decided.model,
|
|
170
|
+
probability: decided.probability,
|
|
171
|
+
checks,
|
|
172
|
+
...(fallback !== undefined && { fallback }),
|
|
173
|
+
...(decided.band === "confirm" && { borderline: true }),
|
|
174
|
+
});
|
|
175
|
+
if (verdict.band === "allow")
|
|
176
|
+
return checked(verdict, [{ ...first, decided: true }]);
|
|
177
|
+
const person = all.filter((p) => !modelWritten(p));
|
|
178
|
+
if (person.length === all.length) {
|
|
179
|
+
const decided = checked(verdict, [{ ...first, decided: true }]);
|
|
180
|
+
if (verdict.refused)
|
|
181
|
+
throw new PromptRefusedError(decided, "the request's prompt text");
|
|
182
|
+
return decided;
|
|
183
|
+
}
|
|
184
|
+
// Compiler-written text is never the reason a person's request is refused: a second call, on the
|
|
185
|
+
// person's parts and the bible's rules alone with the same question and cut, decides.
|
|
186
|
+
const personHits = record.hits?.filter((h) => !modelWritten({ label: h.part })) ?? [];
|
|
187
|
+
const second = person.some((p) => p.text.trim())
|
|
188
|
+
? await decidePromptPolicy(caller, person, personHits, readings, cut)
|
|
189
|
+
: undefined;
|
|
190
|
+
if (second?.refused)
|
|
191
|
+
throw new PromptRefusedError(checked(second, [first, { ...answer("person", second), decided: true }]), "the request's prompt text");
|
|
192
|
+
const fallback = `the prompt-policy model check objected only to text the prompt compiler wrote (${verdict.probability.toFixed(2)} with it, ${second ? `${second.probability.toFixed(2)} on the person's text alone` : "no person-written text"}): the repository template's prompt is used in its place`;
|
|
193
|
+
if (second)
|
|
194
|
+
return checked(second, [first, { ...answer("person", second), decided: true }], fallback);
|
|
195
|
+
// No person wrote any of the text, so no one is asked to clear it.
|
|
196
|
+
const unasked = checked(verdict, [{ ...first, decided: true }], fallback);
|
|
197
|
+
delete unasked.borderline;
|
|
198
|
+
return unasked;
|
|
199
|
+
}
|
|
200
|
+
function answer(scope, v) {
|
|
201
|
+
return { scope, model: v.model, probability: v.probability, refused: v.refused };
|
|
202
|
+
}
|