@gtanczyk/diorama 0.0.0-stage → 0.2.0
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 +202 -0
- package/README.md +157 -2
- package/app/bin/diorama.mjs +13 -0
- package/app/src/actions/budget.ts +160 -0
- package/app/src/actions/build.ts +158 -0
- package/app/src/actions/cast.ts +267 -0
- package/app/src/actions/depth.ts +95 -0
- package/app/src/actions/extend.ts +36 -0
- package/app/src/actions/faces.ts +160 -0
- package/app/src/actions/feedback.ts +87 -0
- package/app/src/actions/fix.ts +382 -0
- package/app/src/actions/history.ts +93 -0
- package/app/src/actions/idea-preview.ts +65 -0
- package/app/src/actions/idea-review.ts +102 -0
- package/app/src/actions/idea-sketch.ts +172 -0
- package/app/src/actions/index.ts +32 -0
- package/app/src/actions/items.ts +94 -0
- package/app/src/actions/kids.ts +215 -0
- package/app/src/actions/language.ts +52 -0
- package/app/src/actions/models.ts +64 -0
- package/app/src/actions/motion.ts +119 -0
- package/app/src/actions/pictures.ts +49 -0
- package/app/src/actions/reactions.ts +36 -0
- package/app/src/actions/registry.ts +101 -0
- package/app/src/actions/share.ts +32 -0
- package/app/src/actions/sound.ts +73 -0
- package/app/src/actions/start.ts +154 -0
- package/app/src/actions/step-work.ts +150 -0
- package/app/src/actions/story.ts +101 -0
- package/app/src/actions/studio.ts +133 -0
- package/app/src/actions/style.ts +72 -0
- package/app/src/actions/video.ts +46 -0
- package/app/src/actions/view.ts +109 -0
- package/app/src/actions/weather.ts +38 -0
- package/app/src/actions/world.ts +290 -0
- package/app/src/commands/action.ts +39 -0
- package/app/src/commands/backdrop.ts +188 -0
- package/app/src/commands/browsers.ts +21 -0
- package/app/src/commands/build.ts +503 -0
- package/app/src/commands/cast.ts +161 -0
- package/app/src/commands/clip.ts +431 -0
- package/app/src/commands/derive.ts +167 -0
- package/app/src/commands/doctor.ts +74 -0
- package/app/src/commands/explore.ts +123 -0
- package/app/src/commands/export.ts +158 -0
- package/app/src/commands/extend.ts +75 -0
- package/app/src/commands/faces.ts +80 -0
- package/app/src/commands/icons.ts +69 -0
- package/app/src/commands/index.ts +37 -0
- package/app/src/commands/language.ts +87 -0
- package/app/src/commands/layout.ts +31 -0
- package/app/src/commands/masks.ts +117 -0
- package/app/src/commands/mcp.ts +52 -0
- package/app/src/commands/model.ts +284 -0
- package/app/src/commands/paint.ts +182 -0
- package/app/src/commands/plates.ts +97 -0
- package/app/src/commands/play.ts +195 -0
- package/app/src/commands/playthrough.ts +111 -0
- package/app/src/commands/publish.ts +78 -0
- package/app/src/commands/reactions.ts +40 -0
- package/app/src/commands/reel.ts +46 -0
- package/app/src/commands/setup.ts +85 -0
- package/app/src/commands/sound.ts +100 -0
- package/app/src/commands/sprites.ts +232 -0
- package/app/src/commands/story.ts +37 -0
- package/app/src/commands/studio.ts +65 -0
- package/app/src/commands/style.ts +87 -0
- package/app/src/commands/verify.ts +45 -0
- package/app/src/commands/voice-retry.ts +14 -0
- package/app/src/commands/voices.ts +145 -0
- package/app/src/commands/weather.ts +52 -0
- package/app/src/commands/world.ts +104 -0
- package/app/src/film/clip.ts +386 -0
- package/app/src/film/reel.ts +126 -0
- package/app/src/film/screencast.ts +123 -0
- package/app/src/image/mask.ts +29 -0
- package/app/src/image/overlay.ts +38 -0
- package/app/src/image/raster.ts +224 -0
- package/app/src/main.ts +28 -0
- package/app/src/meta/choice.ts +27 -0
- package/app/src/meta/http.ts +99 -0
- package/app/src/meta/memo.ts +105 -0
- package/app/src/meta/muse.ts +70 -0
- package/app/src/meta/openrouter.ts +93 -0
- package/app/src/meta/prices.ts +25 -0
- package/app/src/meta/sam.ts +83 -0
- package/app/src/meta/schema.ts +63 -0
- package/app/src/meta/spark.ts +220 -0
- package/app/src/meta/step.ts +14 -0
- package/app/src/meta/voice-file.ts +78 -0
- package/app/src/meta/voice.ts +103 -0
- package/app/src/model/animation.ts +38 -0
- package/app/src/model/blender/relax.py +284 -0
- package/app/src/model/blender.ts +115 -0
- package/app/src/model/build.ts +50 -0
- package/app/src/model/face.ts +21 -0
- package/app/src/model/fit.ts +181 -0
- package/app/src/model/glb.ts +241 -0
- package/app/src/model/plan.ts +151 -0
- package/app/src/model/quality.ts +48 -0
- package/app/src/model/space.ts +168 -0
- package/app/src/model/sprites.ts +293 -0
- package/app/src/model/views.ts +163 -0
- package/app/src/play/creature.ts +43 -0
- package/app/src/play/depth-occlusion.ts +150 -0
- package/app/src/play/exit-outline.ts +48 -0
- package/app/src/play/face3d.ts +34 -0
- package/app/src/play/focus.ts +78 -0
- package/app/src/play/geometry.ts +272 -0
- package/app/src/play/gestures.ts +23 -0
- package/app/src/play/glow.ts +187 -0
- package/app/src/play/lipsync.ts +69 -0
- package/app/src/play/living.ts +83 -0
- package/app/src/play/outline-path.ts +130 -0
- package/app/src/play/parallax.ts +200 -0
- package/app/src/play/path.ts +262 -0
- package/app/src/play/preview.ts +71 -0
- package/app/src/play/reactions.ts +92 -0
- package/app/src/play/rig.ts +172 -0
- package/app/src/play/shadow.ts +253 -0
- package/app/src/play/sound.ts +51 -0
- package/app/src/play/weather.ts +58 -0
- package/app/src/qa/explore.ts +136 -0
- package/app/src/qa/probe.ts +139 -0
- package/app/src/qa/route.ts +118 -0
- package/app/src/registry.ts +23 -0
- package/app/src/scene/animation-source.ts +36 -0
- package/app/src/scene/assets.ts +37 -0
- package/app/src/scene/autofix.ts +133 -0
- package/app/src/scene/backdrop.ts +326 -0
- package/app/src/scene/blockin.ts +189 -0
- package/app/src/scene/brief.ts +74 -0
- package/app/src/scene/carry.ts +177 -0
- package/app/src/scene/cast-fixes.ts +33 -0
- package/app/src/scene/cast.ts +199 -0
- package/app/src/scene/corrections.ts +164 -0
- package/app/src/scene/critic.ts +169 -0
- package/app/src/scene/depthmap.ts +149 -0
- package/app/src/scene/derive.ts +475 -0
- package/app/src/scene/diagnose.ts +132 -0
- package/app/src/scene/face-calibration.ts +65 -0
- package/app/src/scene/face-registration.ts +21 -0
- package/app/src/scene/face-work.ts +71 -0
- package/app/src/scene/faces-data.ts +48 -0
- package/app/src/scene/faces-settings.ts +20 -0
- package/app/src/scene/faces.ts +435 -0
- package/app/src/scene/glows.ts +153 -0
- package/app/src/scene/held.ts +109 -0
- package/app/src/scene/icons.ts +185 -0
- package/app/src/scene/layers.ts +822 -0
- package/app/src/scene/layout.ts +216 -0
- package/app/src/scene/locate.ts +118 -0
- package/app/src/scene/maskcheck.ts +43 -0
- package/app/src/scene/masks.ts +392 -0
- package/app/src/scene/occluders.ts +123 -0
- package/app/src/scene/occlusion-check.ts +138 -0
- package/app/src/scene/paint-layout.ts +135 -0
- package/app/src/scene/paint.ts +81 -0
- package/app/src/scene/photo.ts +123 -0
- package/app/src/scene/plates.ts +256 -0
- package/app/src/scene/playbook.ts +121 -0
- package/app/src/scene/preview.ts +23 -0
- package/app/src/scene/reactions.ts +118 -0
- package/app/src/scene/restyle.ts +53 -0
- package/app/src/scene/rig-check.ts +68 -0
- package/app/src/scene/rig.ts +379 -0
- package/app/src/scene/scale.ts +148 -0
- package/app/src/scene/shadows.ts +215 -0
- package/app/src/scene/stairs.ts +183 -0
- package/app/src/scene/status.ts +32 -0
- package/app/src/scene/verify.ts +156 -0
- package/app/src/scene/walk.ts +326 -0
- package/app/src/scene/warp.ts +419 -0
- package/app/src/scene/weather.ts +118 -0
- package/app/src/scene/words.ts +65 -0
- package/app/src/secrets.ts +219 -0
- package/app/src/setup/checks.ts +110 -0
- package/app/src/sound/cost.ts +74 -0
- package/app/src/sound/data.ts +89 -0
- package/app/src/sound/fixes.ts +23 -0
- package/app/src/sound/issues.ts +21 -0
- package/app/src/sound/language.ts +11 -0
- package/app/src/sound/lipsync-make.ts +98 -0
- package/app/src/sound/lipsync.ts +24 -0
- package/app/src/sound/make.ts +229 -0
- package/app/src/sound/musicgen.py +20 -0
- package/app/src/sound/pcm.ts +280 -0
- package/app/src/sound/plan.ts +154 -0
- package/app/src/sound/retry.ts +43 -0
- package/app/src/sound/settings.ts +28 -0
- package/app/src/sound/sources.ts +81 -0
- package/app/src/sound/spoken.ts +70 -0
- package/app/src/sound/voices.ts +579 -0
- package/app/src/speech/transcribe.ts +38 -0
- package/app/src/speech/types.ts +18 -0
- package/app/src/story/check.ts +230 -0
- package/app/src/story/design.ts +108 -0
- package/app/src/story/engine.ts +233 -0
- package/app/src/story/fixes.ts +54 -0
- package/app/src/story/npc-guidance.ts +7 -0
- package/app/src/story/phrases.ts +4 -0
- package/app/src/story/schema.ts +92 -0
- package/app/src/studio/agent.ts +555 -0
- package/app/src/studio/discovery.ts +28 -0
- package/app/src/studio/events.ts +48 -0
- package/app/src/studio/history.ts +124 -0
- package/app/src/studio/jobs.ts +291 -0
- package/app/src/studio/locks.ts +33 -0
- package/app/src/studio/mcp.ts +86 -0
- package/app/src/studio/operation.ts +18 -0
- package/app/src/studio/repair.ts +31 -0
- package/app/src/studio/server.ts +423 -0
- package/app/src/studio/trouble.ts +48 -0
- package/app/src/world/design.ts +72 -0
- package/app/src/world/drawings.ts +198 -0
- package/app/src/world/extend-stage.ts +109 -0
- package/app/src/world/extend.ts +123 -0
- package/app/src/world/extension-progress.ts +10 -0
- package/app/src/world/files.ts +62 -0
- package/app/src/world/idea-review.ts +32 -0
- package/app/src/world/language.ts +116 -0
- package/app/src/world/photo-limits.ts +2 -0
- package/app/src/world/pool.ts +41 -0
- package/app/src/world/schedule.ts +64 -0
- package/app/src/world/schema.ts +74 -0
- package/app/src/world/sketch.ts +81 -0
- package/app/src/world/style-plan.ts +90 -0
- package/app/src/world/style-reference.ts +16 -0
- package/app/src/world/styled.ts +51 -0
- package/app/src/world/told.ts +105 -0
- package/app/src/world/video-limits.ts +3 -0
- package/app/src/world/video.ts +98 -0
- package/app/studio/activity.tsx +124 -0
- package/app/studio/agent.tsx +384 -0
- package/app/studio/api.ts +111 -0
- package/app/studio/atelier.tsx +234 -0
- package/app/studio/audio-missing.tsx +25 -0
- package/app/studio/audio-setup.tsx +33 -0
- package/app/studio/blender-setup.tsx +30 -0
- package/app/studio/build.tsx +679 -0
- package/app/studio/camera.tsx +59 -0
- package/app/studio/cast-work.tsx +207 -0
- package/app/studio/cast.tsx +178 -0
- package/app/studio/concept-edit.tsx +47 -0
- package/app/studio/creator-idea.tsx +46 -0
- package/app/studio/custom-look.tsx +36 -0
- package/app/studio/faces-setup.tsx +28 -0
- package/app/studio/favicon.svg +11 -0
- package/app/studio/figure.tsx +314 -0
- package/app/studio/fonts/OFL.txt +93 -0
- package/app/studio/fonts/fonts.css +7 -0
- package/app/studio/fonts/fraunces-italic-latin-ext.woff2 +0 -0
- package/app/studio/fonts/fraunces-italic-latin.woff2 +0 -0
- package/app/studio/fonts/fraunces-normal-latin-ext.woff2 +0 -0
- package/app/studio/fonts/fraunces-normal-latin.woff2 +0 -0
- package/app/studio/fonts/instrument-sans-normal-latin-ext.woff2 +0 -0
- package/app/studio/fonts/instrument-sans-normal-latin.woff2 +0 -0
- package/app/studio/icons.tsx +42 -0
- package/app/studio/idea-card.tsx +42 -0
- package/app/studio/idea-review.tsx +181 -0
- package/app/studio/idea-storyboard.tsx +134 -0
- package/app/studio/index.html +15 -0
- package/app/studio/job-words.ts +33 -0
- package/app/studio/lightbox.tsx +49 -0
- package/app/studio/main.tsx +1329 -0
- package/app/studio/nav.ts +14 -0
- package/app/studio/place.tsx +264 -0
- package/app/studio/review-sketch.tsx +47 -0
- package/app/studio/say-it.tsx +49 -0
- package/app/studio/step-work.tsx +134 -0
- package/app/studio/story.tsx +394 -0
- package/app/studio/style-menu.tsx +81 -0
- package/app/studio/style.css +1390 -0
- package/app/studio/sure.tsx +54 -0
- package/app/studio/tip.tsx +74 -0
- package/app/studio/tsconfig.json +5 -0
- package/app/studio/video.tsx +73 -0
- package/app/studio/world.tsx +188 -0
- package/app/tsconfig.json +13 -0
- package/app/web/audio.ts +315 -0
- package/app/web/face.ts +131 -0
- package/app/web/face3d.ts +35 -0
- package/app/web/glows.ts +387 -0
- package/app/web/hero3d.ts +728 -0
- package/app/web/index.html +118 -0
- package/app/web/living.ts +404 -0
- package/app/web/main.ts +3769 -0
- package/app/web/pad.ts +174 -0
- package/app/web/reactions.ts +79 -0
- package/app/web/sheet.ts +36 -0
- package/app/web/synth.ts +140 -0
- package/app/web/tsconfig.json +5 -0
- package/app/web/ui.ts +263 -0
- package/app/web/weather.ts +306 -0
- package/app/web/words.ts +12 -0
- package/docs/characters.md +58 -0
- package/docs/npc-motion.md +69 -0
- package/docs/scenes.md +75 -0
- package/docs/setup.md +60 -0
- package/docs/sound.md +23 -0
- package/docs/studio.md +62 -0
- package/package.json +70 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Grzegorz Tańczyk
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,158 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/images/play.gif" width="720" alt="Playing a Diorama world: a girl with a candle lantern walks through a moonlit garden at a click, and says a line about the boat by the shore">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
# Diorama
|
|
6
|
+
|
|
7
|
+
**Type one sentence. Walk around in the painted game it becomes.**
|
|
8
|
+
|
|
9
|
+
Diorama is a local tool that turns a story idea into a small point-and-click adventure: painted places, a hero and characters who walk and talk, things to pick up and use, sound and voices, and endings that are checked to be reachable. Meta's models do the creative work; code measures and checks every result, so what comes out is playable, not only pretty. Every step writes plain files, and every fix you make survives the next rebuild.
|
|
10
|
+
|
|
11
|
+
**[See it on grzegorz.tanczyk.pl/diorama](https://grzegorz.tanczyk.pl/diorama/)**: the one-pager, and [Paper Boat Storm](https://grzegorz.tanczyk.pl/diorama/paper-boat-storm/), a world built from three sketches that you can play in the browser.
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
You need Node 22+, `ffmpeg` and a Meta Model API key. Make an empty folder and run Diorama there with `npx`. Nothing to clone; your worlds are saved in `./worlds`.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
mkdir my-worlds && cd my-worlds
|
|
19
|
+
npx -y @gtanczyk/diorama setup # checks this machine, asks for your keys (typed hidden, stored encrypted)
|
|
20
|
+
npx -y @gtanczyk/diorama studio # opens the GUI on 127.0.0.1: describe a world, watch it build, play it
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Prefer a terminal? Install it once and the command is just `diorama`:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install -g @gtanczyk/diorama
|
|
27
|
+
diorama build lanterns "A girl with a candle lantern looks for her lost cat at a night market by a canal."
|
|
28
|
+
diorama play lanterns # http://localhost:4173
|
|
29
|
+
diorama browsers # once, for playthrough videos and sprites (Chromium)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
To update: `npm install -g @gtanczyk/diorama@latest`, or add `@latest` to the `npx` line (`npx -y @gtanczyk/diorama@latest studio`).
|
|
33
|
+
|
|
34
|
+
From a checkout, for working on Diorama itself:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
git clone https://github.com/gtanczyk/diorama && cd diorama && npm install
|
|
38
|
+
npm run setup
|
|
39
|
+
npm run studio
|
|
40
|
+
npm run diorama -- <command> # any command, e.g. npm run diorama -- play lanterns
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
More in [docs/setup.md](docs/setup.md): optional keys (ElevenLabs for sound, Hugging Face for 3D), sharing a world on GitHub Pages or itch.io.
|
|
44
|
+
|
|
45
|
+
## Made with Diorama
|
|
46
|
+
|
|
47
|
+
<table>
|
|
48
|
+
<tr>
|
|
49
|
+
<td width="33%"><img src="docs/images/lantern-market.jpg" alt="Lantern market at night"></td>
|
|
50
|
+
<td width="33%"><img src="docs/images/little-bridge.jpg" alt="A little bridge under a street lamp"></td>
|
|
51
|
+
<td width="33%"><img src="docs/images/quiet-garden.jpg" alt="A quiet garden with a boat"></td>
|
|
52
|
+
</tr>
|
|
53
|
+
<tr><td colspan="3"><b>The Night of Small Lanterns</b>: <i>"A small night market by a canal: a lantern seller's stall lit by hanging oil lanterns, a street lamp by a little bridge. A girl carrying a candle lantern must find her lost cat before the lanterns go out."</i></td></tr>
|
|
54
|
+
<tr>
|
|
55
|
+
<td><img src="docs/images/old-river-mill.jpg" alt="An old river mill"></td>
|
|
56
|
+
<td><img src="docs/images/sleepy-cobble-lane.jpg" alt="A sleepy cobbled lane"></td>
|
|
57
|
+
<td><img src="docs/images/last-tram-depot.jpg" alt="The last tram depot"></td>
|
|
58
|
+
</tr>
|
|
59
|
+
<tr><td colspan="3"><b>Midnight Crust</b>: <i>"A night-shift baker in a tiny Kraków bakery must find the lost sourdough starter before the morning rush, helped by a grumpy tram driver."</i></td></tr>
|
|
60
|
+
</table>
|
|
61
|
+
|
|
62
|
+
Each is a four-place world built from that one sentence: about 17 minutes of steps and some 200 Meta model calls, with no hand edits.
|
|
63
|
+
|
|
64
|
+
## Meta models at work
|
|
65
|
+
|
|
66
|
+
| Model | What it does in Diorama |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| **Muse Spark** | Designs the world and the story, lays out each place as a shaded plan sketch (a perspective floor, a silhouette per thing, lights and shadows), critiques paintings, names what to cut out, plans the sound, judges playthroughs |
|
|
69
|
+
| **Muse Image** | Paints each place over its plan sketch, keeping every shape where it stands, repaints only the regions the critic flags, paints the cast, their walk and talk sheets and inventory icons |
|
|
70
|
+
| **SAM 3.1** | Cuts every thing, floor, stair, puddle and patch of water out of the painting; the masks become the walk grid, occlusion and pick-ups |
|
|
71
|
+
| **Muse Voice Transcribe** | Hears an idea you say aloud, and listens to every voiced line to catch a take that does not say it |
|
|
72
|
+
| **Muse Code** | The Studio's agent: it fixes a world with you through the same actions as the GUI |
|
|
73
|
+
|
|
74
|
+
Also used: Depth Anything V2 (ONNX, on the CPU) for shadows and parallax, ElevenLabs for voices and effects, MusicGen (open weights, run locally) for music, and TRELLIS with Make-It-Animatable on Hugging Face for the characters' 3D models.
|
|
75
|
+
|
|
76
|
+
## How a place is made
|
|
77
|
+
|
|
78
|
+
<p align="center"><img src="docs/images/how-a-place-is-made.gif" width="720" alt="One place being made: Muse Spark's block-in, Muse Image's painting, SAM 3.1's cut-outs, the depth map, the measured walk grid, and the hero walking in it"></p>
|
|
79
|
+
|
|
80
|
+
1. **world, story**: Spark turns the sentence into places, a cast, items, locks and endings, and checks every ending can be reached. NPC progress uses simple story flags and conditional dialogue; optional walks and event-triggered travel follow that progress.
|
|
81
|
+
2. **layout, paint**: Spark lays out each place and names each thing's silhouette; the layout becomes a shaded sketch (`blockin.png`, what Muse sees) and a named plan (`plan.png`, what Studio shows); Muse paints over the sketch; a Spark critic marks what is wrong and Muse repaints only those regions.
|
|
82
|
+
3. **masks, plates**: SAM 3.1 cuts out every thing and floor; Muse paints the place without the things the hero can take.
|
|
83
|
+
4. **derive, backdrop, weather, reactions**: code measures floor, scale, occlusion, stairs and light from the masks and the depth map; the place becomes a little stage with cards, far flats, moving water, rain and drips. The planner chooses subtle material-specific reactions, triggered by footsteps, entering floor regions and physical object interactions.
|
|
84
|
+
5. **cast, model, sprites**: the hero and characters are painted, cut out, turned into 3D models and drawn back as sprite sheets in the world's style.
|
|
85
|
+
6. **sound, voices**: ambience, loops, footsteps and music; a fitting voice for every character.
|
|
86
|
+
7. **verify**: every place is walked and used by code; places that fail are repaired automatically, or handed to the agent with what is wrong.
|
|
87
|
+
|
|
88
|
+
Model answers are memoised by a hash of their inputs, so running a step again with the same inputs is free.
|
|
89
|
+
|
|
90
|
+
## Studio
|
|
91
|
+
|
|
92
|
+
`npm run studio` opens the GUI on 127.0.0.1: describe a world (type it, say it, or add a photo of a real room or person), watch it build place by place, play it, and fix it by talking to the agent that looks after the world: click a thing on the stage and say what should change. Everything it does is an action that the page, the terminal (`diorama action`) and the agent (`diorama mcp`) share. See [docs/studio.md](docs/studio.md).
|
|
93
|
+
|
|
94
|
+
<p align="center"><img src="docs/images/studio-world.jpg" width="720" alt="Diorama Studio: a world as a conversation with its agent on the left, the place on a stage on the right; clicking the fish buns puts them into the message"></p>
|
|
95
|
+
|
|
96
|
+
## Commands
|
|
97
|
+
|
|
98
|
+
| | |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `diorama build <slug> "<idea>"` | every step, world to verify (`--from`, `--to`, `--place`, `--photo`, `--hero-photo`) |
|
|
101
|
+
| `diorama play <slug>` | serve the game on localhost |
|
|
102
|
+
| `diorama studio [slug]` | the GUI |
|
|
103
|
+
| `diorama style <slug> "<style>"` | repaint a finished world in another style |
|
|
104
|
+
| `diorama playthrough <slug> --video` | play every ending in the browser and record it |
|
|
105
|
+
| `diorama publish <slug>` / `export <slug> --zip` | GitHub Pages link / a zip for itch.io |
|
|
106
|
+
| `diorama` | all commands; each step also runs alone |
|
|
107
|
+
|
|
108
|
+
## Docs
|
|
109
|
+
|
|
110
|
+
- [Setup and sharing](docs/setup.md)
|
|
111
|
+
- [Studio](docs/studio.md)
|
|
112
|
+
- [Places: depth, weather and the play page](docs/scenes.md)
|
|
113
|
+
- [Characters, style and icons](docs/characters.md)
|
|
114
|
+
- [NPC story stages, optional walks and travel](docs/npc-motion.md)
|
|
115
|
+
- [Sound and voices](docs/sound.md)
|
|
116
|
+
|
|
117
|
+
## Built at the Meta AI Global Hackathon
|
|
118
|
+
|
|
119
|
+
Everything in this repository was written during the hackathon, from the kickoff on 26 October 2026; the commit log is the history. Earlier work is used only as declared dependencies in `package.json`, including [genaicode](https://github.com/gtanczyk/genaicode), the author's own open-source package that gives the Studio its agent chat panel.
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
Apache-2.0
|
|
124
|
+
|
|
125
|
+
### Per-character UV animation
|
|
126
|
+
|
|
127
|
+
Studio and the normal build choose animation settings automatically. A new
|
|
128
|
+
character with a self-contained base-colour texture and UV coordinates uses
|
|
129
|
+
16 walking frames plus a separate standing pose. Models without usable UV use
|
|
130
|
+
the painted eight-frame workflow. Existing painted sheets and explicit saved
|
|
131
|
+
choices are preserved. The Animate action builds the required sprites too.
|
|
132
|
+
|
|
133
|
+
Optional developer overrides (not needed in Studio):
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
npm run diorama -- sprites foggy-ferry-cat mara --texture model --frames 16
|
|
137
|
+
# Subsequent generation keeps the choice:
|
|
138
|
+
npm run diorama -- sprites foggy-ferry-cat mara
|
|
139
|
+
# Optional denser cycle:
|
|
140
|
+
npm run diorama -- sprites foggy-ferry-cat mara --frames 32
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Choices are stored in `cast/<key>/animation.json`, outside the generated `model/`
|
|
144
|
+
and `sprites/` directories. Automatic choices are rechecked against replacement models; explicit choices persist.
|
|
145
|
+
`diorama model <slug> <key> --texture model` can set it before building a model.
|
|
146
|
+
UV sheets support 8, 16 or 32 walk frames, followed by a separate standing cell.
|
|
147
|
+
Talking sheets use the same grid and preserve the story's gesture mapping. The
|
|
148
|
+
GLB must contain a base-colour texture and UV coordinates. Rendering UV sheets
|
|
149
|
+
does not call Muse; existing line/gesture assignments are reused. New dialogue lines still use Spark
|
|
150
|
+
for gesture planning.
|
|
151
|
+
For trousers, pass `--coat-correction off` to `model` or `sprites` to preserve
|
|
152
|
+
the original thigh skin weights. This choice also persists per character;
|
|
153
|
+
new automatic UV characters keep their original rig weights; existing characters
|
|
154
|
+
retain their previous correction. New humanoid model views
|
|
155
|
+
use an A-pose with hands separated from the thighs to avoid fused geometry.
|
|
156
|
+
|
|
157
|
+
Use `--texture views` to return that character to painted 8-frame sheets.
|
|
158
|
+
`--plan` reports the selected mode without saving animation choices or sheets.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Loads the TypeScript sources through tsx, so the CLI runs straight from a git checkout.
|
|
3
|
+
import { register } from 'tsx/esm/api';
|
|
4
|
+
|
|
5
|
+
// Node 22 brings fetch-era globals the CLI relies on (WebSocket for Muse Voice Transcribe); older Node fails late and oddly.
|
|
6
|
+
const major = Number(process.versions.node.split('.')[0]);
|
|
7
|
+
if (major < 22) {
|
|
8
|
+
console.error(`diorama needs Node 22 or newer, this is ${process.version} (nvm install 22 && nvm alias default 22)`);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
register();
|
|
13
|
+
await import('../src/main.ts');
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// Budget: what the models were asked for real (memo hits are free), across every world, and what that
|
|
2
|
+
// cost when prices are known. Prices and the limit live in ~/.config/diorama/budget.json; they are not
|
|
3
|
+
// secrets, only numbers from the Meta and ElevenLabs billing pages.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { callVia, MUSE_VOICE, type ModelName } from '../meta/memo.ts';
|
|
8
|
+
import { imageVia } from '../meta/muse.ts';
|
|
9
|
+
import { sparkTier, sparkVia } from '../meta/spark.ts';
|
|
10
|
+
import { configDir } from '../secrets.ts';
|
|
11
|
+
import { Slug } from '../world/schema.ts';
|
|
12
|
+
import { defineAction } from './registry.ts';
|
|
13
|
+
|
|
14
|
+
const MODELS = ['spark', 'muse', 'sam', 'sound', 'music', 'voice', 'space'] as const satisfies readonly ModelName[];
|
|
15
|
+
|
|
16
|
+
export const BudgetConfig = z.object({
|
|
17
|
+
/** US dollars per call sent, per model. A model without a price is counted, not priced. */
|
|
18
|
+
prices: z.record(z.enum(MODELS), z.number().min(0)).default({}),
|
|
19
|
+
/** Dollars the Studio warns at; the hackathon gives $150 of Meta credits. */
|
|
20
|
+
limitUsd: z.number().min(0).optional(),
|
|
21
|
+
/** Meta credits left as the billing page showed them at `creditsAt` (an ISO time); spend since then is taken off. */
|
|
22
|
+
creditsUsd: z.number().min(0).optional(),
|
|
23
|
+
creditsAt: z.string().optional(),
|
|
24
|
+
/** A build that leaves places unplayable wakes the Studio agent to repair them. */
|
|
25
|
+
autoRepair: z.boolean().default(true),
|
|
26
|
+
});
|
|
27
|
+
type BudgetConfig = z.infer<typeof BudgetConfig>;
|
|
28
|
+
|
|
29
|
+
const file = () => path.join(configDir(), 'budget.json');
|
|
30
|
+
|
|
31
|
+
export function readBudget(): BudgetConfig {
|
|
32
|
+
try {
|
|
33
|
+
return BudgetConfig.parse(JSON.parse(fs.readFileSync(file(), 'utf8')));
|
|
34
|
+
} catch {
|
|
35
|
+
return BudgetConfig.parse({});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type Tally = Partial<Record<ModelName, number>>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* List prices for calls logged before calls carried their own cost (memo/calls.jsonl "usd"). Spark's is the
|
|
43
|
+
* average a standard-tier build call cost (about 5k tokens in, 4k out); newer calls log their real token cost.
|
|
44
|
+
*/
|
|
45
|
+
const LIST: Partial<Record<ModelName, number>> = { muse: 0.01, sam: 0.0025, spark: 0.03 };
|
|
46
|
+
|
|
47
|
+
/** Calls sent per model in one world, all time and since `since` (an ISO time), and the Meta dollars they cost. */
|
|
48
|
+
function tally(dir: string, since: string, credits?: string) {
|
|
49
|
+
const all: Tally = {};
|
|
50
|
+
const recent: Tally = {};
|
|
51
|
+
const usd = { all: 0, recent: 0, sinceCredits: 0, elsewhereCalls: 0, elsewhereUsd: 0 };
|
|
52
|
+
const log = path.join(dir, 'memo', 'calls.jsonl');
|
|
53
|
+
if (!fs.existsSync(log)) return { all, recent, usd };
|
|
54
|
+
for (const line of fs.readFileSync(log, 'utf8').split('\n')) {
|
|
55
|
+
if (!line) continue;
|
|
56
|
+
try {
|
|
57
|
+
const c = JSON.parse(line) as { at: string; model: ModelName; hit: boolean; hash?: string; usd?: number; via?: string };
|
|
58
|
+
if (c.hit) continue;
|
|
59
|
+
const via = callVia(dir, c);
|
|
60
|
+
// Muse Voice transcribing a take: Meta's, not an ElevenLabs call, so the ElevenLabs price is not put on it.
|
|
61
|
+
if (via === MUSE_VOICE) {
|
|
62
|
+
usd.all += c.usd ?? 0;
|
|
63
|
+
if (c.at >= since) usd.recent += c.usd ?? 0;
|
|
64
|
+
if (credits && c.at >= credits) usd.sinceCredits += c.usd ?? 0;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
// Answered by another model (Claude, Gemini through OpenRouter): not on Meta's bill, counted apart.
|
|
68
|
+
if (via && via !== 'contributor') {
|
|
69
|
+
usd.elsewhereCalls++;
|
|
70
|
+
usd.elsewhereUsd += c.usd ?? 0;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
all[c.model] = (all[c.model] ?? 0) + 1;
|
|
74
|
+
const cost = c.usd ?? LIST[c.model] ?? 0;
|
|
75
|
+
usd.all += cost;
|
|
76
|
+
if (c.at >= since) (recent[c.model] = (recent[c.model] ?? 0) + 1), (usd.recent += cost);
|
|
77
|
+
if (credits && c.at >= credits) usd.sinceCredits += cost;
|
|
78
|
+
} catch {}
|
|
79
|
+
}
|
|
80
|
+
return { all, recent, usd };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Meta models are priced from the calls themselves; others (ElevenLabs, Spaces) only when a price is set. */
|
|
84
|
+
const cost = (t: Tally, meta: number, prices: BudgetConfig['prices']) => {
|
|
85
|
+
let sum = meta;
|
|
86
|
+
let priced = true;
|
|
87
|
+
for (const [m, n] of Object.entries(t) as [ModelName, number][]) {
|
|
88
|
+
if (m in LIST) continue;
|
|
89
|
+
const p = prices[m as (typeof MODELS)[number]];
|
|
90
|
+
if (p === undefined) priced = false;
|
|
91
|
+
else sum += p * n;
|
|
92
|
+
}
|
|
93
|
+
return { usd: Math.round(sum * 100) / 100, priced };
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const add = (a: Tally, b: Tally) => {
|
|
97
|
+
for (const [m, n] of Object.entries(b) as [ModelName, number][]) a[m] = (a[m] ?? 0) + n;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
defineAction({
|
|
101
|
+
name: 'budget',
|
|
102
|
+
reads: true,
|
|
103
|
+
description: 'Model calls actually sent (memo hits cost nothing) per model, today and in total, across every world or for one, '
|
|
104
|
+
+ 'and their cost in dollars where prices are set; plus the limit to warn at.',
|
|
105
|
+
input: z.object({ slug: Slug.optional() }),
|
|
106
|
+
async run({ slug }, ctx) {
|
|
107
|
+
const config = readBudget();
|
|
108
|
+
const today = `${new Date().toISOString().slice(0, 10)}T00:00:00`;
|
|
109
|
+
// Calls made before a world had a folder (world_new reading the idea) are in .start/ and count too.
|
|
110
|
+
const slugs = slug ? [slug] : fs.existsSync(ctx.root) ? fs.readdirSync(ctx.root, { withFileTypes: true }).filter((d) => d.isDirectory() && (Slug.safeParse(d.name).success || d.name === '.start')).map((d) => d.name) : [];
|
|
111
|
+
const total: Tally = {};
|
|
112
|
+
const day: Tally = {};
|
|
113
|
+
const meta = { all: 0, recent: 0, sinceCredits: 0, elsewhereCalls: 0, elsewhereUsd: 0 };
|
|
114
|
+
const worlds = slugs.map((s) => {
|
|
115
|
+
const t = tally(path.join(ctx.root, s), today, config.creditsAt);
|
|
116
|
+
add(total, t.all);
|
|
117
|
+
add(day, t.recent);
|
|
118
|
+
for (const k of Object.keys(meta) as (keyof typeof meta)[]) meta[k] += t.usd[k];
|
|
119
|
+
return { slug: s, calls: t.all, ...cost(t.all, t.usd.all, config.prices) };
|
|
120
|
+
}).filter((w) => Object.keys(w.calls).length > 0).sort((a, b) => b.usd - a.usd);
|
|
121
|
+
const spent = cost(total, meta.all, config.prices);
|
|
122
|
+
const creditsLeft = config.creditsUsd === undefined ? null : Math.round((config.creditsUsd - meta.sinceCredits) * 100) / 100;
|
|
123
|
+
return {
|
|
124
|
+
total: { calls: total, ...spent },
|
|
125
|
+
today: { calls: day, ...cost(day, meta.recent, config.prices) },
|
|
126
|
+
worlds,
|
|
127
|
+
prices: config.prices,
|
|
128
|
+
limitUsd: config.limitUsd ?? null,
|
|
129
|
+
// Meta credits left by the last balance typed in, minus what was sent since. Agent turns (Muse Code) are not counted.
|
|
130
|
+
creditsLeft,
|
|
131
|
+
sparkTier: sparkTier(),
|
|
132
|
+
sparkVia: sparkVia(),
|
|
133
|
+
imageVia: imageVia(),
|
|
134
|
+
elsewhere: { calls: meta.elsewhereCalls, usd: Math.round(meta.elsewhereUsd * 100) / 100 },
|
|
135
|
+
autoRepair: config.autoRepair,
|
|
136
|
+
over: (config.limitUsd !== undefined && spent.usd >= config.limitUsd) || (creditsLeft !== null && creditsLeft <= 5),
|
|
137
|
+
file: file(),
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
defineAction({
|
|
143
|
+
name: 'budget_set',
|
|
144
|
+
description: 'Set the dollars per call of a non-Meta model, the dollar limit the Studio warns at, the Meta credits left as the billing page shows them now, and whether a build that '
|
|
145
|
+
+ 'leaves places unplayable wakes the agent to repair them (autoRepair, on by default).',
|
|
146
|
+
input: z.object({
|
|
147
|
+
prices: z.record(z.enum(MODELS), z.number().min(0)).optional(),
|
|
148
|
+
limitUsd: z.number().min(0).optional(),
|
|
149
|
+
creditsUsd: z.number().min(0).optional().describe('Meta credits left as the billing page shows them now'),
|
|
150
|
+
autoRepair: z.boolean().optional(),
|
|
151
|
+
}),
|
|
152
|
+
async run({ prices, limitUsd, creditsUsd, autoRepair }) {
|
|
153
|
+
const was = readBudget();
|
|
154
|
+
const credits = creditsUsd === undefined ? { creditsUsd: was.creditsUsd, creditsAt: was.creditsAt } : { creditsUsd, creditsAt: new Date().toISOString() };
|
|
155
|
+
const next = BudgetConfig.parse({ prices: { ...was.prices, ...prices }, limitUsd: limitUsd ?? was.limitUsd, ...credits, autoRepair: autoRepair ?? was.autoRepair });
|
|
156
|
+
fs.mkdirSync(path.dirname(file()), { recursive: true, mode: 0o700 });
|
|
157
|
+
fs.writeFileSync(file(), `${JSON.stringify(next, null, 2)}\n`);
|
|
158
|
+
return next;
|
|
159
|
+
},
|
|
160
|
+
});
|