kasaframe 0.0.0-stage → 0.1.3
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/NOTICE +148 -0
- package/README.md +92 -2
- package/app/package.json +12 -0
- package/app/server/engine.ts +533 -0
- package/app/server/main.ts +209 -0
- package/app/web/env.d.ts +2 -0
- package/app/web/icons.ts +31 -0
- package/app/web/index.html +21 -0
- package/app/web/main.ts +1195 -0
- package/app/web/style.css +463 -0
- package/bin/hooks.mjs +64 -0
- package/bin/kf.mjs +32 -0
- package/docs/AGENTS.md +286 -0
- package/music/README.md +37 -0
- package/package.json +44 -4
- package/packages/adapters/package.json +36 -0
- package/packages/adapters/src/css.ts +11 -0
- package/packages/adapters/src/gsap.ts +26 -0
- package/packages/adapters/src/index.ts +9 -0
- package/packages/adapters/src/lottie.ts +22 -0
- package/packages/adapters/src/media.ts +59 -0
- package/packages/adapters/src/page.ts +229 -0
- package/packages/adapters/src/project.ts +214 -0
- package/packages/adapters/src/react.ts +36 -0
- package/packages/adapters/src/svelte.ts +22 -0
- package/packages/adapters/src/three.ts +18 -0
- package/packages/adapters/src/vue.ts +27 -0
- package/packages/check/package.json +19 -0
- package/packages/check/src/check.ts +280 -0
- package/packages/check/src/cli.ts +70 -0
- package/packages/check/src/image.ts +146 -0
- package/packages/check/src/index.ts +9 -0
- package/packages/check/src/ocr.swift +37 -0
- package/packages/check/src/probe.ts +328 -0
- package/packages/check/src/report.ts +44 -0
- package/packages/check/src/rules/assets.ts +45 -0
- package/packages/check/src/rules/beats.ts +212 -0
- package/packages/check/src/rules/camera.ts +217 -0
- package/packages/check/src/rules/captions.ts +49 -0
- package/packages/check/src/rules/flash.ts +235 -0
- package/packages/check/src/rules/frames.ts +136 -0
- package/packages/check/src/rules/layout.ts +281 -0
- package/packages/check/src/rules/page.ts +87 -0
- package/packages/check/src/rules/runs.ts +20 -0
- package/packages/check/src/rules/text.ts +326 -0
- package/packages/check/src/scan.ts +240 -0
- package/packages/check/src/serve.ts +67 -0
- package/packages/check/src/types.ts +80 -0
- package/packages/check/src/video.ts +137 -0
- package/packages/cli/package.json +30 -0
- package/packages/cli/src/blur.ts +80 -0
- package/packages/cli/src/browser.ts +203 -0
- package/packages/cli/src/command.ts +44 -0
- package/packages/cli/src/commands/app.ts +25 -0
- package/packages/cli/src/commands/beats.ts +36 -0
- package/packages/cli/src/commands/bench.ts +123 -0
- package/packages/cli/src/commands/blender.ts +293 -0
- package/packages/cli/src/commands/check.ts +25 -0
- package/packages/cli/src/commands/direct.ts +210 -0
- package/packages/cli/src/commands/doctor.ts +30 -0
- package/packages/cli/src/commands/gen.ts +173 -0
- package/packages/cli/src/commands/look.ts +46 -0
- package/packages/cli/src/commands/lyrics.ts +157 -0
- package/packages/cli/src/commands/make.ts +1121 -0
- package/packages/cli/src/commands/music.ts +78 -0
- package/packages/cli/src/commands/narrate.ts +238 -0
- package/packages/cli/src/commands/new.ts +185 -0
- package/packages/cli/src/commands/preview.ts +43 -0
- package/packages/cli/src/commands/render.ts +250 -0
- package/packages/cli/src/commands/series.ts +110 -0
- package/packages/cli/src/commands/setup.ts +102 -0
- package/packages/cli/src/commands/sheet.ts +114 -0
- package/packages/cli/src/commands/skill.ts +43 -0
- package/packages/cli/src/commands/still.ts +40 -0
- package/packages/cli/src/commands/theme.ts +172 -0
- package/packages/cli/src/commands/transitions.ts +40 -0
- package/packages/cli/src/deps.ts +122 -0
- package/packages/cli/src/ffmpeg.ts +81 -0
- package/packages/cli/src/index.ts +8 -0
- package/packages/cli/src/kf.ts +64 -0
- package/packages/cli/src/lock.ts +72 -0
- package/packages/cli/src/mix.ts +131 -0
- package/packages/cli/src/out.ts +13 -0
- package/packages/cli/src/pool.ts +34 -0
- package/packages/cli/src/segments.ts +402 -0
- package/packages/cli/src/serve.ts +124 -0
- package/packages/clock/package.json +14 -0
- package/packages/clock/src/index.ts +25 -0
- package/packages/clock/src/install.ts +351 -0
- package/packages/clock/src/types.ts +45 -0
- package/packages/core/package.json +9 -0
- package/packages/core/src/beats.ts +283 -0
- package/packages/core/src/ease.ts +87 -0
- package/packages/core/src/frame.ts +99 -0
- package/packages/core/src/index.ts +27 -0
- package/packages/core/src/project.ts +157 -0
- package/packages/core/src/rand.ts +56 -0
- package/packages/core/src/spring.ts +52 -0
- package/packages/core/src/style.ts +100 -0
- package/packages/core/src/time.ts +88 -0
- package/packages/director/package.json +23 -0
- package/packages/director/src/assemble.ts +361 -0
- package/packages/director/src/brief.ts +122 -0
- package/packages/director/src/catalog.ts +49 -0
- package/packages/director/src/content.ts +343 -0
- package/packages/director/src/fallback.ts +58 -0
- package/packages/director/src/index.ts +13 -0
- package/packages/director/src/pattern.ts +90 -0
- package/packages/director/src/patterns/fill/cells.ts +115 -0
- package/packages/director/src/patterns/formula/stack.ts +93 -0
- package/packages/director/src/patterns/util.ts +58 -0
- package/packages/director/src/scene.ts +62 -0
- package/packages/director/src/select.ts +163 -0
- package/packages/director/src/transitions.ts +115 -0
- package/packages/gen/PROVIDERS.md +90 -0
- package/packages/gen/package.json +9 -0
- package/packages/gen/src/ask.ts +132 -0
- package/packages/gen/src/audio.ts +91 -0
- package/packages/gen/src/blender.ts +54 -0
- package/packages/gen/src/capabilities.ts +151 -0
- package/packages/gen/src/generate.ts +206 -0
- package/packages/gen/src/image/codex.ts +117 -0
- package/packages/gen/src/image/og.ts +133 -0
- package/packages/gen/src/index.ts +26 -0
- package/packages/gen/src/keys.ts +86 -0
- package/packages/gen/src/media.ts +150 -0
- package/packages/gen/src/music/elevenlabs.ts +41 -0
- package/packages/gen/src/music/index.ts +120 -0
- package/packages/gen/src/music/library.ts +73 -0
- package/packages/gen/src/music/lyria.ts +52 -0
- package/packages/gen/src/music/types.ts +28 -0
- package/packages/gen/src/plan.ts +106 -0
- package/packages/gen/src/registry.ts +54 -0
- package/packages/gen/src/seam.ts +103 -0
- package/packages/gen/src/tts/dashscope.ts +64 -0
- package/packages/gen/src/tts/elevenlabs.ts +84 -0
- package/packages/gen/src/tts/gemini.ts +73 -0
- package/packages/gen/src/tts/index.ts +241 -0
- package/packages/gen/src/tts/local.ts +42 -0
- package/packages/gen/src/tts/types.ts +44 -0
- package/packages/gen/src/types.ts +90 -0
- package/packages/gen/src/video/fal.ts +140 -0
- package/packages/gen/src/video/h3.ts +112 -0
- package/packages/gen/src/video/http.ts +44 -0
- package/packages/gen/src/video/ltx.ts +60 -0
- package/packages/gen/src/video/minimax.ts +55 -0
- package/packages/gen/src/video/veo.ts +71 -0
- package/packages/jizura/package.json +16 -0
- package/packages/jizura/src/deny.ts +73 -0
- package/packages/jizura/src/index.ts +7 -0
- package/packages/jizura/src/install.ts +269 -0
- package/packages/jizura/src/layer.ts +325 -0
- package/packages/jizura/src/lyrics.ts +81 -0
- package/packages/jizura/src/pin.ts +8 -0
- package/packages/jizura/src/vendor.ts +140 -0
- package/packages/jizura/src/vite.ts +63 -0
- package/packages/jizura/vendor/JIZURA_LICENSE.txt +21 -0
- package/packages/jizura/vendor/NOTICE +43 -0
- package/packages/jizura/vendor/engine.json +47 -0
- package/packages/jizura/vendor/fonts/BlackHanSans-Regular.woff2 +0 -0
- package/packages/jizura/vendor/fonts/DotGothic16-Regular.woff2 +0 -0
- package/packages/jizura/vendor/fonts/GowunBatang-Bold.woff2 +0 -0
- package/packages/jizura/vendor/fonts/IBMPlexMono-Medium.ttf +0 -0
- package/packages/jizura/vendor/fonts/IBMPlexMono-SemiBold.ttf +0 -0
- package/packages/jizura/vendor/fonts/NotoSansKR-VF.woff2 +0 -0
- package/packages/jizura/vendor/fonts/NotoSerifKR-VF.woff2 +0 -0
- package/packages/jizura/vendor/fonts/OFL-blackhansans.txt +93 -0
- package/packages/jizura/vendor/fonts/OFL-dotgothic16.txt +93 -0
- package/packages/jizura/vendor/fonts/OFL-gowunbatang.txt +94 -0
- package/packages/jizura/vendor/fonts/OFL-ibmplexmono.txt +93 -0
- package/packages/jizura/vendor/fonts/OFL-notosanskr.txt +93 -0
- package/packages/jizura/vendor/fonts/OFL-notoserifkr.txt +94 -0
- package/packages/jizura/vendor/fonts/fonts.json +52 -0
- package/packages/jizura/vendor/jizura_engine.js +35024 -0
- package/packages/motion/README.md +153 -0
- package/packages/motion/package.json +30 -0
- package/packages/motion/src/camera.ts +97 -0
- package/packages/motion/src/captions.ts +487 -0
- package/packages/motion/src/enter.ts +128 -0
- package/packages/motion/src/hangul.ts +129 -0
- package/packages/motion/src/impact.ts +100 -0
- package/packages/motion/src/index.ts +17 -0
- package/packages/motion/src/moves/brushWipe.ts +103 -0
- package/packages/motion/src/moves/cloneArray.ts +111 -0
- package/packages/motion/src/moves/curtains.ts +81 -0
- package/packages/motion/src/moves/dress.ts +191 -0
- package/packages/motion/src/moves/echoStack.ts +70 -0
- package/packages/motion/src/moves/fit.ts +70 -0
- package/packages/motion/src/moves/flood.ts +61 -0
- package/packages/motion/src/moves/ghostStack.ts +88 -0
- package/packages/motion/src/moves/gridFloor.ts +100 -0
- package/packages/motion/src/moves/imageSwarm.ts +113 -0
- package/packages/motion/src/moves/index.ts +38 -0
- package/packages/motion/src/moves/irisBlades.ts +113 -0
- package/packages/motion/src/moves/karaokeLine.ts +108 -0
- package/packages/motion/src/moves/ledBoard.ts +94 -0
- package/packages/motion/src/moves/liquidTab.ts +72 -0
- package/packages/motion/src/moves/markerWrite.ts +63 -0
- package/packages/motion/src/moves/menu.ts +138 -0
- package/packages/motion/src/moves/morphBox.ts +96 -0
- package/packages/motion/src/moves/neonSign.ts +78 -0
- package/packages/motion/src/moves/panelPop.ts +78 -0
- package/packages/motion/src/moves/paperTear.ts +75 -0
- package/packages/motion/src/moves/path.ts +64 -0
- package/packages/motion/src/moves/pathText.ts +107 -0
- package/packages/motion/src/moves/pointSphere.ts +109 -0
- package/packages/motion/src/moves/ransomLetters.ts +73 -0
- package/packages/motion/src/moves/shapeMorph.ts +143 -0
- package/packages/motion/src/moves/slamWords.ts +96 -0
- package/packages/motion/src/moves/sparkTrail.ts +130 -0
- package/packages/motion/src/moves/speedLines.ts +91 -0
- package/packages/motion/src/moves/splitFlap.ts +149 -0
- package/packages/motion/src/moves/stepWords.ts +128 -0
- package/packages/motion/src/moves/strikeOut.ts +98 -0
- package/packages/motion/src/moves/sunburst.ts +58 -0
- package/packages/motion/src/moves/tickerRows.ts +91 -0
- package/packages/motion/src/moves/tokenPicker.ts +115 -0
- package/packages/motion/src/moves/truchet.ts +85 -0
- package/packages/motion/src/moves/wordWall.ts +78 -0
- package/packages/motion/src/moves/worldRoll.ts +32 -0
- package/packages/motion/src/particles.ts +102 -0
- package/packages/motion/src/react/index.tsx +21 -0
- package/packages/motion/src/react/parts.tsx +431 -0
- package/packages/motion/src/react/time.tsx +97 -0
- package/packages/motion/src/text.ts +103 -0
- package/packages/motion/src/transition.ts +82 -0
- package/packages/motion/src/transition3d/cards.ts +65 -0
- package/packages/motion/src/transition3d/chain.ts +84 -0
- package/packages/motion/src/transition3d/dive.ts +181 -0
- package/packages/motion/src/transition3d/fold.ts +110 -0
- package/packages/motion/src/transition3d/gl.ts +219 -0
- package/packages/motion/src/transition3d/index.ts +235 -0
- package/packages/motion/src/transition3d/live.ts +70 -0
- package/packages/motion/src/transition3d/portal.ts +115 -0
- package/packages/motion/src/transition3d/react.tsx +29 -0
- package/packages/motion/src/transition3d/rig.ts +600 -0
- package/packages/motion/src/transition3d/shatter.ts +104 -0
- package/packages/motion/src/transition3d/space.ts +173 -0
- package/packages/motion/src/transition3d/whip.ts +78 -0
- package/packages/motion/src/transition3d/world.ts +737 -0
- package/packages/motion/src/transition3d/zoomOut.ts +114 -0
- package/packages/motion/src/transitions2d/catalog.ts +127 -0
- package/packages/motion/src/transitions2d/css.d.ts +2 -0
- package/packages/motion/src/transitions2d/cult-ui/LICENSE.md +9 -0
- package/packages/motion/src/transitions2d/cult-ui/RollingNumber.tsx +43 -0
- package/packages/motion/src/transitions2d/gl-transitions/LICENSE +25 -0
- package/packages/motion/src/transitions2d/gl-transitions/shaders.ts +1931 -0
- package/packages/motion/src/transitions2d/index.ts +2 -0
- package/packages/motion/src/transitions2d/kokonutui/LICENSE +21 -0
- package/packages/motion/src/transitions2d/kokonutui/MatrixText.css +16 -0
- package/packages/motion/src/transitions2d/kokonutui/MatrixText.tsx +94 -0
- package/packages/motion/src/transitions2d/magicui/HyperText.css +15 -0
- package/packages/motion/src/transitions2d/magicui/HyperText.tsx +115 -0
- package/packages/motion/src/transitions2d/magicui/LICENSE.md +21 -0
- package/packages/motion/src/transitions2d/magicui/MorphingText.css +25 -0
- package/packages/motion/src/transitions2d/magicui/MorphingText.tsx +130 -0
- package/packages/motion/src/transitions2d/magicui/WordRotate.tsx +42 -0
- package/packages/motion/src/transitions2d/react.ts +13 -0
- package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.css +39 -0
- package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.tsx +32 -0
- package/packages/motion/src/transitions2d/smoothui/LICENSE +21 -0
- package/packages/motion/src/transitions2d/smoothui/SharedAxisY.tsx +50 -0
- package/packages/motion/src/transitions2d/smoothui/TextMorph.tsx +90 -0
- package/packages/motion/src/transitions2d/smoothui/shaders.ts +223 -0
- package/packages/motion/src/transitions2d/unlumen/LICENSE +21 -0
- package/packages/motion/src/transitions2d/unlumen/ScrambleText.tsx +114 -0
- package/packages/motion/src/transitions2d/vengeance-ui/LICENSE +21 -0
- package/packages/motion/src/transitions2d/vengeance-ui/MorphText.css +69 -0
- package/packages/motion/src/transitions2d/vengeance-ui/MorphText.tsx +45 -0
- package/packages/motion/src/type.ts +131 -0
- package/packages/motion/src/ui.ts +172 -0
- package/packages/patterns/package.json +15 -0
- package/packages/patterns/src/bars/rank.ts +119 -0
- package/packages/patterns/src/before-after/shrink.ts +127 -0
- package/packages/patterns/src/before-after/strike.ts +125 -0
- package/packages/patterns/src/code/terminal.ts +133 -0
- package/packages/patterns/src/compare/bars.ts +142 -0
- package/packages/patterns/src/compare/duel.ts +103 -0
- package/packages/patterns/src/end/lockup.ts +85 -0
- package/packages/patterns/src/end/slam.ts +91 -0
- package/packages/patterns/src/flow/graph.ts +250 -0
- package/packages/patterns/src/hook-number/counter.ts +101 -0
- package/packages/patterns/src/hook-number/roll.ts +179 -0
- package/packages/patterns/src/hook-number/slam.ts +91 -0
- package/packages/patterns/src/index.ts +38 -0
- package/packages/patterns/src/kit.ts +449 -0
- package/packages/patterns/src/limit/gauge.ts +117 -0
- package/packages/patterns/src/list/cards.ts +131 -0
- package/packages/patterns/src/list/cycle.ts +22 -0
- package/packages/patterns/src/media/panels.ts +100 -0
- package/packages/patterns/src/objects.ts +234 -0
- package/packages/patterns/src/quote/karaoke.ts +126 -0
- package/packages/patterns/src/quote/slam.ts +22 -0
- package/packages/patterns/src/screen/focus.ts +85 -0
- package/packages/patterns/src/steps/path.ts +137 -0
- package/packages/patterns/src/steps/stack.ts +111 -0
- package/packages/patterns/src/term-reveal/chips.ts +92 -0
- package/packages/patterns/src/term-reveal/expand.ts +127 -0
- package/packages/patterns/src/timeline/axis.ts +144 -0
- package/packages/patterns/src/title/mask.ts +85 -0
- package/packages/patterns/src/title/slam.ts +23 -0
- package/packages/patterns/src/toggle-sim/switch.ts +92 -0
- package/packages/patterns/src/trend/columns.ts +108 -0
- package/packages/patterns/src/trend/draw.ts +140 -0
- package/packages/patterns/src/types.ts +67 -0
- package/packages/patterns/src/words/moves.ts +42 -0
- package/packages/patterns/src/words/slam.ts +4 -0
- package/packages/plan/package.json +15 -0
- package/packages/plan/src/asks.ts +256 -0
- package/packages/plan/src/brief.ts +383 -0
- package/packages/plan/src/captions.ts +78 -0
- package/packages/plan/src/detect.ts +93 -0
- package/packages/plan/src/index.ts +27 -0
- package/packages/plan/src/layout.ts +176 -0
- package/packages/plan/src/llm.ts +172 -0
- package/packages/plan/src/look.ts +222 -0
- package/packages/plan/src/plan.ts +179 -0
- package/packages/plan/src/request.ts +55 -0
- package/packages/plan/src/series.ts +76 -0
- package/packages/plan/src/studio.ts +53 -0
- package/packages/plan/src/templates.ts +42 -0
- package/packages/plan/src/themes.ts +48 -0
- package/packages/plan/src/types.ts +157 -0
- package/packages/studio/package.json +12 -0
- package/packages/studio/src/index.ts +1 -0
- package/packages/studio/src/plugin.ts +236 -0
- package/packages/studio/src/ui/main.ts +503 -0
- package/packages/studio/src/ui/studio.css +165 -0
- package/packages/studio/src/ui/timeline.ts +317 -0
- package/packages/themes/kit/THEME-MAKE.md +68 -0
- package/packages/themes/kit/THEME.md +30 -0
- package/packages/themes/kit/briefs/og-intro-15s/brief.json +16 -0
- package/packages/themes/kit/briefs/og-intro-15s/facts.ts +29 -0
- package/packages/themes/kit/briefs/og-intro-15s/logo.svg +12 -0
- package/packages/themes/kit/effects.ts +5 -0
- package/packages/themes/kit/sample/index.html +11 -0
- package/packages/themes/kit/sample/main.ts +9 -0
- package/packages/themes/kit/sample/scenes/scene.ts +15 -0
- package/packages/themes/package.json +19 -0
- package/packages/themes/src/factory.ts +296 -0
- package/packages/themes/src/fx.ts +14 -0
- package/packages/themes/src/index.ts +114 -0
- package/packages/themes/src/slotkit.ts +79 -0
- package/packages/themes/src/slots.ts +46 -0
- package/packages/themes/src/stage3d.ts +197 -0
- package/packages/themes/src/types.ts +58 -0
- package/presets/kawaii-pastel.json +94 -0
- package/presets/neutral-dark.json +82 -0
- package/presets/og.json +98 -0
- package/series/og-shorts.json +14 -0
- package/skills/kasaframe/SKILL.md +33 -0
- package/templates/_shared/project/index.html +11 -0
- package/templates/_shared/project/lib/react.ts +22 -0
- package/templates/_shared/project/lib/stage.ts +292 -0
- package/templates/_shared/project/main.ts +9 -0
- package/templates/_shared/scenes/default.ts +21 -0
- package/templates/_shared/scenes/drop.ts +33 -0
- package/templates/_shared/scenes/end.ts +26 -0
- package/templates/_shared/scenes/hook.ts +18 -0
- package/templates/_shared/scenes/seam.ts +41 -0
- package/templates/_shared/scenes/step.ts +49 -0
- package/templates/ad/preview.png +0 -0
- package/templates/ad/template.json +151 -0
- package/templates/demo/preview.png +0 -0
- package/templates/demo/template.json +141 -0
- package/templates/explainer/preview.png +0 -0
- package/templates/explainer/template.json +193 -0
- package/templates/launch/preview.png +0 -0
- package/templates/launch/template.json +163 -0
- package/templates/mv/preview.png +0 -0
- package/templates/mv/scenes/default.ts +98 -0
- package/templates/mv/template.json +178 -0
- package/templates/promo/preview.png +0 -0
- package/templates/promo/template.json +185 -0
- package/templates/shorts/preview.png +0 -0
- package/templates/shorts/scenes/hook.ts +37 -0
- package/templates/shorts/template.json +196 -0
- package/templates/square/preview.png +0 -0
- package/templates/square/template.json +133 -0
- package/themes/debug-hud/THEME.md +39 -0
- package/themes/debug-hud/effects.ts +389 -0
- package/themes/debug-hud/sample/assets/og/logo.svg +12 -0
- package/themes/debug-hud/sample/beats.json +1 -0
- package/themes/debug-hud/sample/index.html +11 -0
- package/themes/debug-hud/sample/kf.json +59 -0
- package/themes/debug-hud/sample/lib/hudkit.ts +49 -0
- package/themes/debug-hud/sample/lib/og.ts +29 -0
- package/themes/debug-hud/sample/main.ts +9 -0
- package/themes/debug-hud/sample/scenes/end.ts +62 -0
- package/themes/debug-hud/sample/scenes/gather.ts +67 -0
- package/themes/debug-hud/sample/scenes/models.ts +70 -0
- package/themes/debug-hud/sample/scenes/price.ts +79 -0
- package/themes/debug-hud/sample/style.json +91 -0
- package/themes/debug-hud/slots.ts +99 -0
- package/themes/debug-hud/still.png +0 -0
- package/themes/debug-hud/style.json +91 -0
- package/themes/debug-hud/theme.json +68 -0
- package/themes/og-measure/THEME.md +47 -0
- package/themes/og-measure/effects.ts +432 -0
- package/themes/og-measure/sample/assets/brand/og-logo-full.svg +12 -0
- package/themes/og-measure/sample/assets/brand/og-logo.svg +12 -0
- package/themes/og-measure/sample/assets/data/measure.json +353 -0
- package/themes/og-measure/sample/beats.json +1 -0
- package/themes/og-measure/sample/index.html +11 -0
- package/themes/og-measure/sample/kf.json +66 -0
- package/themes/og-measure/sample/lib/data.ts +62 -0
- package/themes/og-measure/sample/main.ts +9 -0
- package/themes/og-measure/sample/measure.ts +78 -0
- package/themes/og-measure/sample/scenes/end.ts +47 -0
- package/themes/og-measure/sample/scenes/gather.ts +51 -0
- package/themes/og-measure/sample/scenes/models.ts +34 -0
- package/themes/og-measure/sample/scenes/one.ts +39 -0
- package/themes/og-measure/sample/scenes/price.ts +56 -0
- package/themes/og-measure/sample/style.json +97 -0
- package/themes/og-measure/slots.ts +88 -0
- package/themes/og-measure/still.png +0 -0
- package/themes/og-measure/style.json +97 -0
- package/themes/og-measure/theme.json +79 -0
- package/themes/riso-zine/THEME.md +43 -0
- package/themes/riso-zine/effects.ts +321 -0
- package/themes/riso-zine/sample/assets/og/logo.svg +12 -0
- package/themes/riso-zine/sample/beats.json +1 -0
- package/themes/riso-zine/sample/index.html +11 -0
- package/themes/riso-zine/sample/kf.json +59 -0
- package/themes/riso-zine/sample/lib/og.ts +29 -0
- package/themes/riso-zine/sample/lib/shot.ts +86 -0
- package/themes/riso-zine/sample/lib/zine.ts +42 -0
- package/themes/riso-zine/sample/main.ts +9 -0
- package/themes/riso-zine/sample/scenes/end.ts +61 -0
- package/themes/riso-zine/sample/scenes/gather.ts +62 -0
- package/themes/riso-zine/sample/scenes/models.ts +52 -0
- package/themes/riso-zine/sample/scenes/price.ts +82 -0
- package/themes/riso-zine/sample/style.json +99 -0
- package/themes/riso-zine/slots.ts +81 -0
- package/themes/riso-zine/still.png +0 -0
- package/themes/riso-zine/style.json +99 -0
- package/themes/riso-zine/theme.json +75 -0
- package/tools/beats/beats.py +372 -0
- package/tools/beats/requirements.txt +3 -0
- package/tools/lyrics/align.py +164 -0
- package/tools/lyrics/requirements.txt +9 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync } from "node:fs";
|
|
3
|
+
import { homedir, tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { KEY_BG } from "../media.ts";
|
|
6
|
+
import type { ImageProvider, ImageRequest, RawResult } from "../types.ts";
|
|
7
|
+
|
|
8
|
+
// ChatGPT 로그인으로 도는 codex CLI 의 내장 imagegen — API 키·요금 없이 구독 안에서 그린다(한 장 1–2분).
|
|
9
|
+
// kasaterm pane 의 codex 는 pane 전용 홈을 세우는 래퍼라 PATH 에서 그 shim 을 빼고 순정 codex 를 찾는다
|
|
10
|
+
export function codexBin(): string | null {
|
|
11
|
+
if (process.env.KF_CODEX) return existsSync(process.env.KF_CODEX) ? process.env.KF_CODEX : null;
|
|
12
|
+
const path = (process.env.PATH ?? "").split(":").filter((p) => !p.includes("kasaterm-shim-")).join(":");
|
|
13
|
+
const r = spawnSync("sh", ["-c", "command -v codex"], { encoding: "utf8", env: { ...process.env, PATH: path } });
|
|
14
|
+
const bin = r.stdout?.trim();
|
|
15
|
+
return r.status === 0 && bin ? bin : null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function codexLoggedIn(bin = codexBin()): boolean {
|
|
19
|
+
if (!bin) return false;
|
|
20
|
+
const r = spawnSync(bin, ["login", "status"], { encoding: "utf8", timeout: 10_000 });
|
|
21
|
+
return r.status === 0 && /logged in/i.test(`${r.stdout}${r.stderr}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// imagegen 이 받는 세 꼴 — 요청 크기와 비율이 가장 가까운 것으로 그린 뒤 generate.ts 가 잘라 맞춘다
|
|
25
|
+
function orientation(size: string): string {
|
|
26
|
+
const [w, h] = size.split("x").map(Number);
|
|
27
|
+
const r = w / h;
|
|
28
|
+
return r > 1.2 ? "landscape 1536x1024" : r < 0.83 ? "portrait 1024x1536" : "square 1024x1024";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function run(bin: string, args: string[], cwd: string, timeoutMs: number): Promise<string> {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const p = spawn(bin, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
34
|
+
const out: Buffer[] = [];
|
|
35
|
+
p.stdout.on("data", (b: Buffer) => out.push(b));
|
|
36
|
+
p.stderr.on("data", (b: Buffer) => out.push(b));
|
|
37
|
+
// codex 가 가끔 멈춘다 — 끊고 실패로 돌린다
|
|
38
|
+
const timer = setTimeout(() => p.kill("SIGKILL"), timeoutMs);
|
|
39
|
+
p.on("error", (e) => {
|
|
40
|
+
clearTimeout(timer);
|
|
41
|
+
reject(e);
|
|
42
|
+
});
|
|
43
|
+
p.on("close", (code) => {
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
const log = Buffer.concat(out).toString();
|
|
46
|
+
if (code === 0) resolve(log);
|
|
47
|
+
else reject(new Error(`codex 실패(${code ?? "시간 초과"}): ${log.trim().split("\n").slice(-4).join(" / ").slice(0, 400)}`));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 저장 지시를 안 따르면 codex 가 늘 쓰는 자리에서 이번에 생긴 그림을 찾는다
|
|
53
|
+
function newestGenerated(since: number): string | null {
|
|
54
|
+
const root = join(homedir(), ".codex", "generated_images");
|
|
55
|
+
if (!existsSync(root)) return null;
|
|
56
|
+
let best: { p: string; t: number } | null = null;
|
|
57
|
+
const walk = (d: string) => {
|
|
58
|
+
for (const e of readdirSync(d, { withFileTypes: true })) {
|
|
59
|
+
const p = join(d, e.name);
|
|
60
|
+
if (e.isDirectory()) walk(p);
|
|
61
|
+
else if (/\.png$/i.test(e.name)) {
|
|
62
|
+
const t = statSync(p).mtimeMs;
|
|
63
|
+
if (t >= since && (!best || t > best.t)) best = { p, t };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
walk(root);
|
|
68
|
+
return (best as { p: string } | null)?.p ?? null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function codexImage(): ImageProvider {
|
|
72
|
+
return {
|
|
73
|
+
id: "codex-imagegen",
|
|
74
|
+
kind: "img",
|
|
75
|
+
model: "codex imagegen (gpt-image, ChatGPT 요금제)",
|
|
76
|
+
license: "OpenAI 이용약관 — 출력물 권리는 사용자에게, 상업 사용 가능(ChatGPT 요금제 안, 추가 요금 없음)",
|
|
77
|
+
region: "ChatGPT 로그인(codex CLI) — 한국 사용 가능",
|
|
78
|
+
keyName: "codex",
|
|
79
|
+
available: () => codexLoggedIn(),
|
|
80
|
+
estimateUsd: () => 0,
|
|
81
|
+
|
|
82
|
+
async generate(o: ImageRequest): Promise<RawResult> {
|
|
83
|
+
const bin = codexBin();
|
|
84
|
+
if (!bin) throw new Error("codex CLI 가 없다 — npm i -g @openai/codex 뒤 codex login(ChatGPT 계정)");
|
|
85
|
+
const work = mkdtempSync(join(tmpdir(), "kf-codex-img-"));
|
|
86
|
+
const started = Date.now();
|
|
87
|
+
try {
|
|
88
|
+
const keyed = !!o.transparent;
|
|
89
|
+
const prompt = [
|
|
90
|
+
`Use $imagegen to create exactly one image, ${orientation(o.size)}, and save it as ./image.png in the current directory.`,
|
|
91
|
+
o.refs?.length ? "Use the attached image(s) as the reference — keep the same character, shapes and colors." : "",
|
|
92
|
+
o.prompt,
|
|
93
|
+
keyed ? KEY_BG : "",
|
|
94
|
+
"No text, letters, watermarks or logos unless the description above asks for them. Do not ask for confirmation. Do not create any other file.",
|
|
95
|
+
].filter(Boolean).join("\n\n");
|
|
96
|
+
// -i 는 가변 인자라 프롬프트 앞에 두면 프롬프트까지 그림 파일로 먹는다 — 프롬프트 뒤에
|
|
97
|
+
const args = ["-c", "features.daemon_auto_start=false", "exec", "-s", "workspace-write", "--skip-git-repo-check", "-C", work, prompt];
|
|
98
|
+
if (o.refs?.length) args.push("-i", ...o.refs);
|
|
99
|
+
await run(bin, args, work, Number(process.env.KF_CODEX_TIMEOUT_MS ?? 420_000));
|
|
100
|
+
const file = existsSync(join(work, "image.png")) ? join(work, "image.png") : newestGenerated(started);
|
|
101
|
+
if (!file) throw new Error("codex 가 그림을 남기지 않았다(./image.png·~/.codex/generated_images 둘 다 없음)");
|
|
102
|
+
return {
|
|
103
|
+
bytes: readFileSync(file),
|
|
104
|
+
ext: "png",
|
|
105
|
+
model: "codex imagegen",
|
|
106
|
+
seed: null,
|
|
107
|
+
costUsd: 0,
|
|
108
|
+
costEstimated: false,
|
|
109
|
+
params: { size: orientation(o.size), refs: o.refs?.length ?? 0 },
|
|
110
|
+
notes: ["codex", ...(keyed ? ["chroma-key"] : [])],
|
|
111
|
+
};
|
|
112
|
+
} finally {
|
|
113
|
+
rmSync(work, { recursive: true, force: true });
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { readKey } from "../keys.ts";
|
|
2
|
+
import { KEY_BG, refJpeg } from "../media.ts";
|
|
3
|
+
import type { ImageProvider, ImageRequest, RawResult } from "../types.ts";
|
|
4
|
+
|
|
5
|
+
const HOST = process.env.KF_OG_HOST ?? "https://apis.opengateway.ai";
|
|
6
|
+
|
|
7
|
+
// 1M 토큰당 달러. OpenAI 단가표(2026-09) — gpt-image-2 와 2.5 둘 다 같은 값이다.
|
|
8
|
+
const PRICE = { textIn: 5, imageIn: 8, imageOut: 30 };
|
|
9
|
+
|
|
10
|
+
// 2.5 는 background:transparent 를 직접 받는다(2026-10-08 실측, 알파 61%). 나머지는 단색 바탕 + 키잉.
|
|
11
|
+
const TRANSPARENT_OK = /gpt-image-(2\.5|1\.5)/;
|
|
12
|
+
|
|
13
|
+
export function costFromUsage(usage: any): number | null {
|
|
14
|
+
if (!usage) return null;
|
|
15
|
+
const inD = usage.input_tokens_details ?? {};
|
|
16
|
+
const outD = usage.output_tokens_details ?? {};
|
|
17
|
+
const imageIn = inD.image_tokens ?? 0;
|
|
18
|
+
const textIn = inD.text_tokens ?? Math.max(0, (usage.input_tokens ?? 0) - imageIn);
|
|
19
|
+
const imageOut = outD.image_tokens ?? usage.output_tokens ?? 0;
|
|
20
|
+
return (textIn * PRICE.textIn + imageIn * PRICE.imageIn + imageOut * PRICE.imageOut) / 1e6;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// gpt-image-2 계열이 받는 크기: 변이 16의 배수, 긴 변 3840 이하, 비율 3:1 이하, 픽셀 655,360..8,294,400.
|
|
24
|
+
export function apiSize(size: string): { w: number; h: number } {
|
|
25
|
+
const m = /^(\d+)x(\d+)$/.exec(size);
|
|
26
|
+
if (!m) throw new Error(`크기는 1536x1024 꼴이어야 한다: ${size}`);
|
|
27
|
+
let w = Number(m[1]);
|
|
28
|
+
let h = Number(m[2]);
|
|
29
|
+
const ratio = Math.max(w, h) / Math.min(w, h);
|
|
30
|
+
if (ratio > 3) throw new Error(`비율 3:1 을 넘는 크기는 못 만든다: ${size}`);
|
|
31
|
+
const px = w * h;
|
|
32
|
+
const k = px < 655_360 ? Math.sqrt(655_360 / px) : px > 8_294_400 ? Math.sqrt(8_294_400 / px) : 1;
|
|
33
|
+
w *= k;
|
|
34
|
+
h *= k;
|
|
35
|
+
const longEdge = Math.max(w, h);
|
|
36
|
+
if (longEdge > 3840) {
|
|
37
|
+
w *= 3840 / longEdge;
|
|
38
|
+
h *= 3840 / longEdge;
|
|
39
|
+
}
|
|
40
|
+
const r16 = (v: number, up: boolean) => (up ? Math.ceil(v / 16) : Math.floor(v / 16)) * 16;
|
|
41
|
+
// 키운 쪽은 올림, 줄인 쪽은 내림 — 반올림하면 픽셀 한도를 살짝 넘어 400 이 난다.
|
|
42
|
+
return { w: r16(w, k >= 1), h: r16(h, k >= 1) };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function call(path: string, init: RequestInit): Promise<any> {
|
|
46
|
+
const key = readKey("opengateway");
|
|
47
|
+
const r = await fetch(HOST + path, {
|
|
48
|
+
...init,
|
|
49
|
+
headers: { Authorization: `Bearer ${key}`, ...(init.headers ?? {}) },
|
|
50
|
+
});
|
|
51
|
+
const text = await r.text();
|
|
52
|
+
if (!r.ok) {
|
|
53
|
+
// 413 은 본문이 비어 온다 — 상태 코드가 곧 원인이다.
|
|
54
|
+
const hint = r.status === 413 ? " (업로드가 크다)" : r.status === 402 ? " (OG 잔액 부족 — 충전하면 키가 자동 복구된다)" : "";
|
|
55
|
+
throw new Error(`OG ${path} ${r.status}${hint}: ${text.slice(0, 300)}`);
|
|
56
|
+
}
|
|
57
|
+
return JSON.parse(text);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function toRaw(j: any, model: string, params: Record<string, unknown>): RawResult {
|
|
61
|
+
const b64 = j.data?.[0]?.b64_json;
|
|
62
|
+
if (!b64) throw new Error(`OG 응답에 그림이 없다: ${JSON.stringify(j).slice(0, 200)}`);
|
|
63
|
+
const cost = costFromUsage(j.usage);
|
|
64
|
+
return {
|
|
65
|
+
bytes: Buffer.from(b64, "base64"),
|
|
66
|
+
ext: "png",
|
|
67
|
+
model,
|
|
68
|
+
seed: null,
|
|
69
|
+
costUsd: cost ?? 0,
|
|
70
|
+
costEstimated: cost === null,
|
|
71
|
+
params: { ...params, usage: j.usage },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function ogImage(model = "openai/gpt-image-2.5-sunburst"): ImageProvider {
|
|
76
|
+
const nativeAlpha = TRANSPARENT_OK.test(model);
|
|
77
|
+
|
|
78
|
+
function body(o: ImageRequest) {
|
|
79
|
+
const { w, h } = apiSize(o.size);
|
|
80
|
+
const keyed = o.transparent && !nativeAlpha;
|
|
81
|
+
return {
|
|
82
|
+
keyed,
|
|
83
|
+
fields: {
|
|
84
|
+
model,
|
|
85
|
+
prompt: keyed ? `${o.prompt}\n\n${KEY_BG}` : o.prompt,
|
|
86
|
+
size: `${w}x${h}`,
|
|
87
|
+
quality: o.quality ?? "high",
|
|
88
|
+
output_format: "png",
|
|
89
|
+
n: 1,
|
|
90
|
+
...(o.transparent && nativeAlpha ? { background: "transparent" } : {}),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
id: `og-${model.replace(/^openai\//, "")}`,
|
|
97
|
+
kind: "img",
|
|
98
|
+
model,
|
|
99
|
+
license: "OpenAI 이용약관 — 출력물 권리는 사용자에게, 상업 사용 가능",
|
|
100
|
+
region: "OG live(apis.opengateway.ai) 전 세계, 한국 사용 가능",
|
|
101
|
+
keyName: "opengateway",
|
|
102
|
+
|
|
103
|
+
async generate(o) {
|
|
104
|
+
const { keyed, fields } = body(o);
|
|
105
|
+
const j = await call("/v1/images/generations", {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers: { "Content-Type": "application/json" },
|
|
108
|
+
body: JSON.stringify(fields),
|
|
109
|
+
});
|
|
110
|
+
const raw = toRaw(j, model, { ...fields, prompt: undefined });
|
|
111
|
+
if (keyed) raw.notes = ["chroma-key"];
|
|
112
|
+
return raw;
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
// 마스크 없는 참조 편집. 참조가 먹었는지는 usage.input_tokens_details.image_tokens 로만 알 수 있다.
|
|
116
|
+
async edit(o) {
|
|
117
|
+
if (!o.refs?.length) throw new Error("edit 에는 refs 가 필요하다");
|
|
118
|
+
const { keyed, fields } = body(o);
|
|
119
|
+
const form = new FormData();
|
|
120
|
+
for (const [k, v] of Object.entries(fields)) form.append(k, String(v));
|
|
121
|
+
const field = o.refs.length > 1 ? "image[]" : "image";
|
|
122
|
+
for (const [i, ref] of o.refs.entries()) {
|
|
123
|
+
const jpg = await refJpeg(ref);
|
|
124
|
+
form.append(field, new Blob([new Uint8Array(jpg)], { type: "image/jpeg" }), `ref${i}.jpg`);
|
|
125
|
+
}
|
|
126
|
+
const j = await call("/v1/images/edits", { method: "POST", body: form });
|
|
127
|
+
const raw = toRaw(j, model, { ...fields, prompt: undefined, refs: o.refs.length });
|
|
128
|
+
const used = j.usage?.input_tokens_details?.image_tokens ?? 0;
|
|
129
|
+
raw.notes = [...(keyed ? ["chroma-key"] : []), ...(used > 0 ? [] : ["refs-ignored"])];
|
|
130
|
+
return raw;
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type { Asset, AssetKind, AssetMeta, ImageProvider, ImageRequest, ProviderInfo, RawResult, VideoProvider, VideoRequest } from "./types.ts";
|
|
2
|
+
export { findKey, hasKey, howToGet, keyFile, MissingKeyError, readKey, whereToPut } from "./keys.ts";
|
|
3
|
+
export { DEFAULT_IMAGE, imageProviders, pickImage, pickVideo, providerReady, videoProviders } from "./registry.ts";
|
|
4
|
+
export { askTerminal, CAPABILITIES, parseAllow, WAIT, questionsMarkdown, questionsText, settle, type AnswerInput, type Capability, type Choice, type Question, type Settled } from "./ask.ts";
|
|
5
|
+
export { capabilities, type CapabilityProvider, type CapabilityReport } from "./capabilities.ts";
|
|
6
|
+
export { BLENDER_MIN, blenderLibDir, findBlender, hasBlenderLib } from "./blender.ts";
|
|
7
|
+
export { codexBin, codexLoggedIn } from "./image/codex.ts";
|
|
8
|
+
export { H3_RESTRICT } from "./video/h3.ts";
|
|
9
|
+
export {
|
|
10
|
+
cacheDir,
|
|
11
|
+
cacheKey,
|
|
12
|
+
DEFAULT_IMAGE_MAX_USD,
|
|
13
|
+
DEFAULT_MAX_USD,
|
|
14
|
+
estimateImageUsd,
|
|
15
|
+
genImage,
|
|
16
|
+
genVideo,
|
|
17
|
+
NeedsApproval,
|
|
18
|
+
planVideo,
|
|
19
|
+
type GenContext,
|
|
20
|
+
} from "./generate.ts";
|
|
21
|
+
export { aspectOf, seam, seamFrames, still, type SeamOptions } from "./seam.ts";
|
|
22
|
+
export { genSpecs, referencedIds, resolvePlan, type GenReport, type GenSpec } from "./plan.ts";
|
|
23
|
+
export { retime } from "./media.ts";
|
|
24
|
+
export { cutVoice, duration as audioDuration, findSilences, layVoices, voicedSpan } from "./audio.ts";
|
|
25
|
+
export { alignWords, DEFAULT_STYLE, parseVoice, pickTts, speak, ttsProviders, voiceCapabilities, voiceQuestion, type Speech, type SpeechRequest, type TtsProvider, type Voice, type Word } from "./tts/index.ts";
|
|
26
|
+
export { addToLibrary, byMood, genMusic, listLibrary, MOOD_PROMPT, MOOD_TAGS, musicDir, musicGenCapabilities, musicLength, musicProviders, musicQuestion, pickMusic, type MusicAsset, type MusicProvider, type Track } from "./music/index.ts";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
// 값은 이 모듈 밖으로 헤더에 실릴 때만 나간다. 오류 글에는 어디를 찾았는지만 적는다.
|
|
6
|
+
const SOURCES: Record<string, { env: string[]; files: string[] }> = {
|
|
7
|
+
opengateway: { env: ["OPENGATEWAY_API_KEY", "OG_API_KEY"], files: ["~/.config/opengateway.key"] },
|
|
8
|
+
fal: { env: ["FAL_KEY"], files: ["~/.config/fal.key", "~/.secrets/gcp-sm/fal-ai-api-key"] },
|
|
9
|
+
minimax: { env: ["MINIMAX_API_KEY"], files: ["~/.config/minimax.key"] },
|
|
10
|
+
gemini: { env: ["GEMINI_API_KEY", "GOOGLE_API_KEY"], files: ["~/.config/gemini.key"] },
|
|
11
|
+
ltx: { env: ["LTX_API_KEY"], files: ["~/.config/ltx.key"] },
|
|
12
|
+
h3: { env: ["KF_H3_URL"], files: [] },
|
|
13
|
+
elevenlabs: { env: ["ELEVENLABS_API_KEY", "XI_API_KEY"], files: ["~/.config/elevenlabs.key"] },
|
|
14
|
+
dashscope: { env: ["DASHSCOPE_API_KEY"], files: ["~/.config/dashscope.key"] },
|
|
15
|
+
"qwen3-tts": { env: ["KF_QWEN3_TTS_URL"], files: [] },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// 없는 키를 물을 때 「어디서 받아 어디에 넣나」를 같이 보인다 — 받는 곳은 공급자 콘솔, 넣기는 kf setup key 가 값을 숨겨 받아 파일로
|
|
19
|
+
const HELP: Record<string, { label: string; get: string }> = {
|
|
20
|
+
opengateway: { label: "OpenGateway 키", get: "OpenGateway 콘솔(opengateway.ai)에서 API 키" },
|
|
21
|
+
fal: { label: "fal 키", get: "fal.ai/dashboard/keys" },
|
|
22
|
+
minimax: { label: "MiniMax 키", get: "platform.minimax.io 의 API 키" },
|
|
23
|
+
gemini: { label: "Gemini 키", get: "aistudio.google.com/apikey" },
|
|
24
|
+
ltx: { label: "LTX 키", get: "ltx.io 콘솔의 API 키" },
|
|
25
|
+
h3: { label: "사내 H3 주소", get: "파드 운영자에게 SGLang 주소(닫힌 망이면 터널) — 걸음 수 KF_H3_STEPS(터보 LoRA 9·없으면 50)도 같이" },
|
|
26
|
+
elevenlabs: { label: "ElevenLabs 키", get: "elevenlabs.io/app/settings/api-keys" },
|
|
27
|
+
dashscope: { label: "DashScope 키", get: "Alibaba Cloud Model Studio(dashscope) 콘솔의 API 키" },
|
|
28
|
+
"qwen3-tts": { label: "로컬 Qwen3-TTS 서버 주소", get: "tools/tts 의 서버를 띄운 주소" },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// 주소(h3·로컬 서버)는 비밀이 아니라 환경 변수로, 나머지는 kf setup key 로
|
|
32
|
+
export function howToGet(name: string): string {
|
|
33
|
+
const h = HELP[name];
|
|
34
|
+
const env = sources(name).env;
|
|
35
|
+
const put = name === "h3" || name.endsWith("-tts") ? `${env.join("·")}=<주소>` : `kf setup key ${name}(값을 숨겨 받아 ~/.config/kasaframe/keys/${name} 에) 또는 ${whereToPut(name)}`;
|
|
36
|
+
return `${h?.label ?? name}: ${h?.get ?? "공급자 콘솔"} → ${put}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const keyFile = (name: string): string => expand(`~/.config/kasaframe/keys/${name}`);
|
|
40
|
+
|
|
41
|
+
export class MissingKeyError extends Error {
|
|
42
|
+
keyName: string;
|
|
43
|
+
constructor(keyName: string) {
|
|
44
|
+
super(`키 없음: ${keyName} — ${whereToPut(keyName)}`);
|
|
45
|
+
this.keyName = keyName;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function expand(p: string): string {
|
|
50
|
+
return p.startsWith("~/") ? join(homedir(), p.slice(2)) : p;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function sources(name: string): { env: string[]; files: string[] } {
|
|
54
|
+
const s = SOURCES[name] ?? { env: [], files: [] };
|
|
55
|
+
return { env: s.env, files: [...s.files, `~/.config/kasaframe/keys/${name}`] };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function whereToPut(name: string): string {
|
|
59
|
+
const s = sources(name);
|
|
60
|
+
return `환경 변수 ${s.env.join("·") || "(없음)"} 또는 파일 ${s.files.join("·")}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function findKey(name: string): string | null {
|
|
64
|
+
const s = sources(name);
|
|
65
|
+
for (const e of s.env) {
|
|
66
|
+
const v = process.env[e]?.trim();
|
|
67
|
+
if (v) return v;
|
|
68
|
+
}
|
|
69
|
+
for (const f of s.files) {
|
|
70
|
+
const p = expand(f);
|
|
71
|
+
if (!existsSync(p)) continue;
|
|
72
|
+
const v = readFileSync(p, "utf8").trim();
|
|
73
|
+
if (v) return v;
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function hasKey(name: string): boolean {
|
|
79
|
+
return findKey(name) !== null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function readKey(name: string): string {
|
|
83
|
+
const v = findKey(name);
|
|
84
|
+
if (!v) throw new MissingKeyError(name);
|
|
85
|
+
return v;
|
|
86
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { renameSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
export function run(cmd: string, args: string[], input?: Uint8Array): Promise<Buffer> {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const p = spawn(cmd, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
7
|
+
const out: Buffer[] = [];
|
|
8
|
+
const err: Buffer[] = [];
|
|
9
|
+
p.stdout.on("data", (b: Buffer) => out.push(b));
|
|
10
|
+
p.stderr.on("data", (b: Buffer) => err.push(b));
|
|
11
|
+
p.on("error", reject);
|
|
12
|
+
p.on("close", (code) => {
|
|
13
|
+
if (code === 0) return resolve(Buffer.concat(out));
|
|
14
|
+
const tail = Buffer.concat(err).toString().trim().split("\n").slice(-4).join("\n");
|
|
15
|
+
reject(new Error(`${cmd} 실패(${code}): ${tail}`));
|
|
16
|
+
});
|
|
17
|
+
if (input) p.stdin.end(input);
|
|
18
|
+
else p.stdin.end();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ff = (args: string[], input?: Uint8Array) => run("ffmpeg", ["-v", "error", "-y", ...args], input);
|
|
23
|
+
|
|
24
|
+
export interface Probe {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
duration?: number;
|
|
28
|
+
fps?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function probe(path: string): Promise<Probe> {
|
|
32
|
+
const out = await run("ffprobe", [
|
|
33
|
+
"-v", "error", "-select_streams", "v:0",
|
|
34
|
+
"-show_entries", "stream=width,height,r_frame_rate:format=duration",
|
|
35
|
+
"-of", "json", path,
|
|
36
|
+
]);
|
|
37
|
+
const j = JSON.parse(out.toString());
|
|
38
|
+
const s = j.streams?.[0] ?? {};
|
|
39
|
+
const [n, d] = String(s.r_frame_rate ?? "0/1").split("/").map(Number);
|
|
40
|
+
const duration = Number(j.format?.duration);
|
|
41
|
+
return {
|
|
42
|
+
width: s.width,
|
|
43
|
+
height: s.height,
|
|
44
|
+
duration: Number.isFinite(duration) ? duration : undefined,
|
|
45
|
+
fps: d ? n / d : undefined,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 64x64 로 줄인 알파에서 거의 투명한 칸의 비율. 0 이면 투명 배경이 안 먹은 것이다.
|
|
50
|
+
export async function transparentRatio(path: string): Promise<number> {
|
|
51
|
+
const raw = await ff(["-i", path, "-vf", "format=rgba,alphaextract,scale=64:64", "-f", "rawvideo", "-pix_fmt", "gray", "-"]);
|
|
52
|
+
let n = 0;
|
|
53
|
+
for (const v of raw) if (v < 250) n++;
|
|
54
|
+
return raw.length ? n / raw.length : 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// chromaKey 와 짝 — 투명 배경을 못 받는 모델에 이 문장을 붙여 그리게 한 뒤 키잉한다.
|
|
58
|
+
export const KEY_BG =
|
|
59
|
+
"Place the subject on a perfectly flat, uniform pure green (#00FF00) background with no shadow, gradient or texture.";
|
|
60
|
+
|
|
61
|
+
// ffmpeg 은 읽는 파일에 바로 쓰지 못한다 — 같은 경로면 옆 파일에 쓰고 바꿔 끼운다.
|
|
62
|
+
async function toFile(src: string, dst: string, args: (out: string) => string[]): Promise<void> {
|
|
63
|
+
const out = src === dst ? dst.replace(/(\.[a-z0-9]+)$/i, ".work$1") : dst;
|
|
64
|
+
await ff(args(out));
|
|
65
|
+
if (out !== dst) renameSync(out, dst);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function chromaKey(src: string, dst: string, color = "0x00FF00"): Promise<void> {
|
|
69
|
+
await toFile(src, dst, (out) => ["-i", src, "-vf", `colorkey=${color}:0.28:0.08,despill=type=green,format=rgba`, "-frames:v", "1", out]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 참조 그림은 실루엣만 전하면 되고 OG 는 큰 업로드를 413 으로 자른다 — 흰 바탕에 얹은 512px JPEG 로 보낸다.
|
|
73
|
+
export async function refJpeg(src: string, maxEdge = 512): Promise<Buffer> {
|
|
74
|
+
return ff([
|
|
75
|
+
"-i", src,
|
|
76
|
+
"-filter_complex",
|
|
77
|
+
`[0]format=rgba,scale='min(${maxEdge},iw)':'min(${maxEdge},ih)':force_original_aspect_ratio=decrease[fg];` +
|
|
78
|
+
`color=white:s=16x16[bg0];[bg0][fg]scale2ref[bg][fg2];[bg][fg2]overlay=format=auto,format=yuvj420p`,
|
|
79
|
+
"-frames:v", "1", "-q:v", "4", "-f", "image2", "-c:v", "mjpeg", "-",
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function fitImage(src: string, dst: string, w: number, h: number): Promise<void> {
|
|
84
|
+
await toFile(src, dst, (out) => [
|
|
85
|
+
"-i", src,
|
|
86
|
+
"-vf", `scale=${w}:${h}:force_original_aspect_ratio=increase:flags=lanczos,crop=${w}:${h}`,
|
|
87
|
+
"-frames:v", "1", out,
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 생성 클립(16·24fps, 5초 남짓)을 장면 틈 길이·프로젝트 fps 에 정확히 맞춘다. 미디어 어댑터는 seek 만 하면 된다.
|
|
92
|
+
// size 를 주면 비율을 무시하고 늘린다 — H3 는 16:9 입력을 1344x768(1.75:1)로 잘라 내지 않고 늘려 받으니,
|
|
93
|
+
// 되늘려야 첫·끝 프레임이 앞뒤 장면과 픽셀 자리까지 겹친다(2026-10-08 실측).
|
|
94
|
+
export async function retime(src: string, dst: string, dur: number, fps: number, o: { smooth?: boolean; size?: { w: number; h: number } } = {}): Promise<void> {
|
|
95
|
+
const p = await probe(src);
|
|
96
|
+
if (!p.duration) throw new Error(`길이를 못 읽음: ${src}`);
|
|
97
|
+
const factor = dur / p.duration;
|
|
98
|
+
const rate = o.smooth ? `minterpolate=fps=${fps}:mi_mode=mci` : `fps=${fps}`;
|
|
99
|
+
const scale = o.size && (o.size.w !== p.width || o.size.h !== p.height) ? `,scale=${o.size.w}:${o.size.h}:flags=lanczos,setsar=1` : "";
|
|
100
|
+
await toFile(src, dst, (out) => [
|
|
101
|
+
"-i", src, "-an",
|
|
102
|
+
"-vf", `setpts=${factor.toFixed(6)}*PTS,${rate}${scale}`,
|
|
103
|
+
"-t", dur.toFixed(4),
|
|
104
|
+
"-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "16", "-preset", "medium", "-movflags", "+faststart",
|
|
105
|
+
out,
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 모델은 첫 키프레임은 꽉 붙잡지만 끝 키프레임은 몇 픽셀 밀리고 빛이 달라진다(H3 실측 PSNR 37.8 대 24.6 dB).
|
|
110
|
+
// 양 끝 몇 프레임을 진짜 앞뒤 장면 프레임으로 녹여 넘겨 경계 프레임을 픽셀까지 같게 만든다.
|
|
111
|
+
export async function snapEnds(
|
|
112
|
+
src: string,
|
|
113
|
+
dst: string,
|
|
114
|
+
o: { first?: string; last?: string; frames: number; fps: number; dur: number; w: number; h: number },
|
|
115
|
+
): Promise<void> {
|
|
116
|
+
if (!o.first && !o.last) return;
|
|
117
|
+
const ramp = Math.max(1, o.frames - 1) / o.fps;
|
|
118
|
+
const inputs = ["-i", src];
|
|
119
|
+
const chains: string[] = [];
|
|
120
|
+
let cur = "[0]";
|
|
121
|
+
let n = 1;
|
|
122
|
+
if (o.first) {
|
|
123
|
+
inputs.push("-loop", "1", "-framerate", String(o.fps), "-t", o.dur.toFixed(4), "-i", o.first);
|
|
124
|
+
chains.push(`[${n}]scale=${o.w}:${o.h},format=rgba,fade=t=out:st=0:d=${ramp.toFixed(4)}:alpha=1[f]`, `${cur}[f]overlay=eof_action=pass[v${n}]`);
|
|
125
|
+
cur = `[v${n}]`;
|
|
126
|
+
n++;
|
|
127
|
+
}
|
|
128
|
+
if (o.last) {
|
|
129
|
+
inputs.push("-loop", "1", "-framerate", String(o.fps), "-t", o.dur.toFixed(4), "-i", o.last);
|
|
130
|
+
const st = o.dur - 1 / o.fps - ramp;
|
|
131
|
+
chains.push(`[${n}]scale=${o.w}:${o.h},format=rgba,fade=t=in:st=${st.toFixed(4)}:d=${ramp.toFixed(4)}:alpha=1[l]`, `${cur}[l]overlay=eof_action=pass[v${n}]`);
|
|
132
|
+
cur = `[v${n}]`;
|
|
133
|
+
}
|
|
134
|
+
await toFile(src, dst, (out) => [
|
|
135
|
+
...inputs,
|
|
136
|
+
"-filter_complex", chains.join(";"),
|
|
137
|
+
"-map", cur, "-r", String(o.fps), "-frames:v", String(Math.round(o.dur * o.fps)),
|
|
138
|
+
"-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "16", "-preset", "medium", "-movflags", "+faststart",
|
|
139
|
+
out,
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export async function dataUri(src: string, maxEdge = 1280): Promise<string> {
|
|
144
|
+
const jpg = await ff([
|
|
145
|
+
"-i", src,
|
|
146
|
+
"-vf", `scale='min(${maxEdge},iw)':'min(${maxEdge},ih)':force_original_aspect_ratio=decrease,format=yuvj420p`,
|
|
147
|
+
"-frames:v", "1", "-q:v", "3", "-f", "image2", "-c:v", "mjpeg", "-",
|
|
148
|
+
]);
|
|
149
|
+
return `data:image/jpeg;base64,${jpg.toString("base64")}`;
|
|
150
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { hasKey, readKey } from "../keys.ts";
|
|
2
|
+
import type { MusicProvider } from "./types.ts";
|
|
3
|
+
|
|
4
|
+
// 키가 없어 실호출로 검증하지 못했다 — 모양은 ElevenLabs API 문서(2026-10, music/compose) 그대로. 200 이면 소리 파일 날것이 온다
|
|
5
|
+
const BASE = process.env.KF_ELEVENLABS_BASE ?? "https://api.elevenlabs.io";
|
|
6
|
+
const MODEL = process.env.KF_ELEVENLABS_MUSIC_MODEL ?? "music_v2_5";
|
|
7
|
+
// 1분에 $0.15 (elevenlabs.io/pricing/api)
|
|
8
|
+
const PER_MIN = 0.15;
|
|
9
|
+
|
|
10
|
+
export function elevenlabsMusic(): MusicProvider {
|
|
11
|
+
return {
|
|
12
|
+
id: "elevenlabs-music",
|
|
13
|
+
label: "Eleven Music",
|
|
14
|
+
model: MODEL,
|
|
15
|
+
keyName: "elevenlabs",
|
|
16
|
+
license: "Eleven Music 약관 — 유료 요금제는 온·오프라인 상업 가능(영화·TV·라디오는 Enterprise Music 만), 무료는 출처 표기·내려받기 불가",
|
|
17
|
+
region: "전 세계 API(유료 요금제)",
|
|
18
|
+
verified: false,
|
|
19
|
+
maxSec: 300,
|
|
20
|
+
ready: () => hasKey("elevenlabs"),
|
|
21
|
+
estimateUsd: (sec) => (sec / 60) * PER_MIN,
|
|
22
|
+
|
|
23
|
+
async compose(o) {
|
|
24
|
+
const ms = Math.min(600_000, Math.max(3000, Math.ceil(o.duration * 1000)));
|
|
25
|
+
const r = await fetch(`${BASE}/v1/music?output_format=mp3_44100_128`, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
headers: { "xi-api-key": readKey("elevenlabs"), "Content-Type": "application/json" },
|
|
28
|
+
body: JSON.stringify({ prompt: o.prompt, music_length_ms: ms, model_id: MODEL, force_instrumental: true }),
|
|
29
|
+
});
|
|
30
|
+
if (!r.ok) throw new Error(`Eleven Music ${r.status}: ${(await r.text()).slice(0, 300)}`);
|
|
31
|
+
return {
|
|
32
|
+
bytes: new Uint8Array(await r.arrayBuffer()),
|
|
33
|
+
ext: "mp3",
|
|
34
|
+
model: MODEL,
|
|
35
|
+
costUsd: (ms / 60000) * PER_MIN,
|
|
36
|
+
costEstimated: true,
|
|
37
|
+
params: { music_length_ms: ms, force_instrumental: true },
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|