oda-engine 0.0.0-stage → 0.1.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.
Files changed (204) hide show
  1. package/README.md +151 -2
  2. package/bin/nowhere.mjs +352 -0
  3. package/lib/account.mjs +57 -0
  4. package/lib/agentModules.mjs +57 -0
  5. package/lib/devServer.mjs +351 -0
  6. package/lib/headless.mjs +231 -0
  7. package/lib/headlessPreview.mjs +212 -0
  8. package/lib/keys.mjs +517 -0
  9. package/lib/make.mjs +855 -0
  10. package/lib/mcp.mjs +537 -0
  11. package/lib/open.mjs +22 -0
  12. package/lib/preview.mjs +87 -0
  13. package/lib/previewRpc.mjs +134 -0
  14. package/lib/project.mjs +359 -0
  15. package/lib/publishFlow.mjs +90 -0
  16. package/lib/resources.mjs +50 -0
  17. package/lib/rules.mjs +60 -0
  18. package/lib/scaffold.mjs +42 -0
  19. package/lib/setup.mjs +59 -0
  20. package/lib/tools.mjs +668 -0
  21. package/package.json +51 -4
  22. package/template/game.config.json +9 -0
  23. package/template/scene.json +4 -0
  24. package/template/src/main.ts +11 -0
  25. package/vendor/DOCS.md +447 -0
  26. package/vendor/agent/appRun.mjs +520 -0
  27. package/vendor/agent/assets/brief.mjs +242 -0
  28. package/vendor/agent/assets/collider.mjs +531 -0
  29. package/vendor/agent/assets/environments/index.mjs +12 -0
  30. package/vendor/agent/assets/environments/worldlabs.mjs +161 -0
  31. package/vendor/agent/assets/fetch.mjs +168 -0
  32. package/vendor/agent/assets/footprint.mjs +13 -0
  33. package/vendor/agent/assets/gltf.mjs +547 -0
  34. package/vendor/agent/assets/hdr.mjs +269 -0
  35. package/vendor/agent/assets/imageOps.mjs +171 -0
  36. package/vendor/agent/assets/images/codex.mjs +307 -0
  37. package/vendor/agent/assets/images/fal.mjs +75 -0
  38. package/vendor/agent/assets/images/gemini.mjs +84 -0
  39. package/vendor/agent/assets/images/index.mjs +25 -0
  40. package/vendor/agent/assets/images/openai.mjs +75 -0
  41. package/vendor/agent/assets/images/stability.mjs +71 -0
  42. package/vendor/agent/assets/images/views.mjs +31 -0
  43. package/vendor/agent/assets/import.mjs +1352 -0
  44. package/vendor/agent/assets/inspect.mjs +465 -0
  45. package/vendor/agent/assets/jobs.mjs +196 -0
  46. package/vendor/agent/assets/ktx2.mjs +290 -0
  47. package/vendor/agent/assets/ledger.mjs +466 -0
  48. package/vendor/agent/assets/net.mjs +254 -0
  49. package/vendor/agent/assets/prices.json +39 -0
  50. package/vendor/agent/assets/providers/fal.mjs +115 -0
  51. package/vendor/agent/assets/providers/index.mjs +22 -0
  52. package/vendor/agent/assets/providers/meshy.mjs +119 -0
  53. package/vendor/agent/assets/providers/tripo.mjs +188 -0
  54. package/vendor/agent/assets/sources/ambientcg.mjs +129 -0
  55. package/vendor/agent/assets/sources/index.mjs +23 -0
  56. package/vendor/agent/assets/sources/polyhaven.mjs +237 -0
  57. package/vendor/agent/assets/sources/polypizza.mjs +121 -0
  58. package/vendor/agent/assets/splat.mjs +631 -0
  59. package/vendor/agent/assets/targets.mjs +122 -0
  60. package/vendor/agent/assets/tile.mjs +261 -0
  61. package/vendor/agent/assets/unzip.mjs +180 -0
  62. package/vendor/agent/blender/cleanup.py +360 -0
  63. package/vendor/agent/blender/convert.py +167 -0
  64. package/vendor/agent/blender/find.mjs +192 -0
  65. package/vendor/agent/blender/nw_export.py +104 -0
  66. package/vendor/agent/blender/nw_rubric.py +426 -0
  67. package/vendor/agent/blender/run.mjs +193 -0
  68. package/vendor/agent/blender/runner.py +252 -0
  69. package/vendor/agent/blender/sheet.py +743 -0
  70. package/vendor/agent/depth.mjs +134 -0
  71. package/vendor/agent/director/board.mjs +451 -0
  72. package/vendor/agent/director/contracts.mjs +663 -0
  73. package/vendor/agent/director/director.mjs +2365 -0
  74. package/vendor/agent/director/estimate.mjs +200 -0
  75. package/vendor/agent/director/gate.mjs +802 -0
  76. package/vendor/agent/director/limits.json +16 -0
  77. package/vendor/agent/director/methods.mjs +457 -0
  78. package/vendor/agent/director/policy.json +33 -0
  79. package/vendor/agent/director/prompts.mjs +244 -0
  80. package/vendor/agent/director/reading.mjs +341 -0
  81. package/vendor/agent/director/router.mjs +184 -0
  82. package/vendor/agent/director/seams.mjs +243 -0
  83. package/vendor/agent/director/session.mjs +643 -0
  84. package/vendor/agent/director/store.mjs +119 -0
  85. package/vendor/agent/director/taskGate.mjs +110 -0
  86. package/vendor/agent/director/teamLedger.mjs +118 -0
  87. package/vendor/agent/director/triage.mjs +63 -0
  88. package/vendor/agent/downloads.cjs +363 -0
  89. package/vendor/agent/flow.mjs +78 -0
  90. package/vendor/agent/guard.mjs +613 -0
  91. package/vendor/agent/host.mjs +1736 -0
  92. package/vendor/agent/language.mjs +58 -0
  93. package/vendor/agent/ledger.mjs +360 -0
  94. package/vendor/agent/locale.cjs +186 -0
  95. package/vendor/agent/loop/capacity.mjs +74 -0
  96. package/vendor/agent/loop/compose.mjs +127 -0
  97. package/vendor/agent/loop/gate.mjs +205 -0
  98. package/vendor/agent/loop/judge.mjs +189 -0
  99. package/vendor/agent/loop/levels.mjs +273 -0
  100. package/vendor/agent/loop/state.mjs +358 -0
  101. package/vendor/agent/notes.cjs +278 -0
  102. package/vendor/agent/pace.mjs +258 -0
  103. package/vendor/agent/panels.mjs +431 -0
  104. package/vendor/agent/prompt.mjs +342 -0
  105. package/vendor/agent/reference/board.mjs +410 -0
  106. package/vendor/agent/reference/compose.mjs +364 -0
  107. package/vendor/agent/reference/decode.mjs +56 -0
  108. package/vendor/agent/reference/facts.mjs +1874 -0
  109. package/vendor/agent/reference/png.mjs +107 -0
  110. package/vendor/agent/reference/records.mjs +63 -0
  111. package/vendor/agent/reference/web.mjs +252 -0
  112. package/vendor/agent/roles/artist.mjs +69 -0
  113. package/vendor/agent/roles/builder.mjs +79 -0
  114. package/vendor/agent/roles/checks.mjs +223 -0
  115. package/vendor/agent/roles/common.mjs +188 -0
  116. package/vendor/agent/roles/critic.mjs +171 -0
  117. package/vendor/agent/roles/index.mjs +39 -0
  118. package/vendor/agent/roles/modeller.mjs +142 -0
  119. package/vendor/agent/roles/qa.mjs +58 -0
  120. package/vendor/agent/roles/rubrics.mjs +79 -0
  121. package/vendor/agent/roles/sound.mjs +69 -0
  122. package/vendor/agent/rounds.cjs +333 -0
  123. package/vendor/agent/shared.mjs +284 -0
  124. package/vendor/agent/stopGate.mjs +574 -0
  125. package/vendor/agent/subagents.mjs +129 -0
  126. package/vendor/agent/tools/assets.mjs +499 -0
  127. package/vendor/agent/tools/blender.mjs +754 -0
  128. package/vendor/agent/tools/cards.mjs +479 -0
  129. package/vendor/agent/tools/choices.mjs +479 -0
  130. package/vendor/agent/tools/compose.mjs +74 -0
  131. package/vendor/agent/tools/environment.mjs +488 -0
  132. package/vendor/agent/tools/eyes.mjs +733 -0
  133. package/vendor/agent/tools/generate.mjs +338 -0
  134. package/vendor/agent/tools/guide.mjs +46 -0
  135. package/vendor/agent/tools/harness.mjs +193 -0
  136. package/vendor/agent/tools/image.mjs +643 -0
  137. package/vendor/agent/tools/index.mjs +162 -0
  138. package/vendor/agent/tools/look.mjs +578 -0
  139. package/vendor/agent/tools/loop.mjs +858 -0
  140. package/vendor/agent/tools/others.mjs +123 -0
  141. package/vendor/agent/tools/pictures.mjs +535 -0
  142. package/vendor/agent/tools/reference.mjs +366 -0
  143. package/vendor/agent/transcripts.mjs +118 -0
  144. package/vendor/agent-loop.mjs +602 -0
  145. package/vendor/agent-plugin/.claude-plugin/plugin.json +5 -0
  146. package/vendor/agent-plugin/skills/art-direction/SKILL.md +82 -0
  147. package/vendor/agent-plugin/skills/asset-legality/SKILL.md +101 -0
  148. package/vendor/agent-plugin/skills/asset-sources/SKILL.md +111 -0
  149. package/vendor/agent-plugin/skills/blender-modeling/SKILL.md +97 -0
  150. package/vendor/agent-plugin/skills/look-dev/SKILL.md +104 -0
  151. package/vendor/agent-plugin/skills/playtesting/SKILL.md +74 -0
  152. package/vendor/agent-plugin/skills/reference-loop/SKILL.md +102 -0
  153. package/vendor/agent-plugin/skills/sound-design/SKILL.md +60 -0
  154. package/vendor/agent-plugin/skills/style/SKILL.md +35 -0
  155. package/vendor/agent-plugin/skills/tsl-r185/SKILL.md +107 -0
  156. package/vendor/auth.cjs +570 -0
  157. package/vendor/build.cjs +953 -0
  158. package/vendor/catalog.json +455 -0
  159. package/vendor/connectors.cjs +688 -0
  160. package/vendor/eyes.mjs +733 -0
  161. package/vendor/gameExports.json +1390 -0
  162. package/vendor/git.cjs +222 -0
  163. package/vendor/models.json +57 -0
  164. package/vendor/publish.cjs +1018 -0
  165. package/vendor/refBoard.cjs +301 -0
  166. package/vendor/schema/dist/assets.d.ts +335 -0
  167. package/vendor/schema/dist/assets.js +439 -0
  168. package/vendor/schema/dist/brief.d.ts +357 -0
  169. package/vendor/schema/dist/brief.js +302 -0
  170. package/vendor/schema/dist/common.d.ts +9 -0
  171. package/vendor/schema/dist/common.js +13 -0
  172. package/vendor/schema/dist/config.d.ts +406 -0
  173. package/vendor/schema/dist/config.js +355 -0
  174. package/vendor/schema/dist/contract.d.ts +599 -0
  175. package/vendor/schema/dist/contract.js +1146 -0
  176. package/vendor/schema/dist/index.d.ts +14 -0
  177. package/vendor/schema/dist/index.js +21 -0
  178. package/vendor/schema/dist/look.d.ts +463 -0
  179. package/vendor/schema/dist/look.js +681 -0
  180. package/vendor/schema/dist/lookStats.d.ts +230 -0
  181. package/vendor/schema/dist/lookStats.js +768 -0
  182. package/vendor/schema/dist/pilot.d.ts +32 -0
  183. package/vendor/schema/dist/pilot.js +44 -0
  184. package/vendor/schema/dist/publish.d.ts +214 -0
  185. package/vendor/schema/dist/publish.js +291 -0
  186. package/vendor/schema/dist/scene.d.ts +75 -0
  187. package/vendor/schema/dist/scene.js +120 -0
  188. package/vendor/schema/dist/skyLight.d.ts +141 -0
  189. package/vendor/schema/dist/skyLight.js +436 -0
  190. package/vendor/schema/dist/style.d.ts +131 -0
  191. package/vendor/schema/dist/style.js +155 -0
  192. package/vendor/schema/package.json +1 -0
  193. package/vendor/selectionPrompt.mjs +51 -0
  194. package/vendor/useTools.mjs +195 -0
  195. package/vendor/userMessage.mjs +26 -0
  196. package/web-dist/assets/GaussianSplatUtils-CB77cP9U.js +1 -0
  197. package/web-dist/assets/KTX2Loader-6OIWUF7s.js +2 -0
  198. package/web-dist/assets/SPZLoader-zYj0Alfv.js +1 -0
  199. package/web-dist/assets/gaussianSplat-CJTI1sEh.js +1 -0
  200. package/web-dist/assets/index-CcjyyQco.css +1 -0
  201. package/web-dist/assets/index-DMyJcoZJ.js +693 -0
  202. package/web-dist/assets/meshopt_decoder.module-BvwdjiD3.js +1 -0
  203. package/web-dist/assets/zstddec.module-CfFeQW7d.js +1 -0
  204. package/web-dist/index.html +34 -0
@@ -0,0 +1,252 @@
1
+ # The export run of nw_blender: empties the factory scene, runs the agent's
2
+ # bpy script, lists what glTF will not carry, and exports the result as one
3
+ # GLB. run.mjs starts it as
4
+ # Blender -b --factory-startup --disable-autoexec --offline-mode
5
+ # --python-exit-code 3 --python runner.py -- <args.json>
6
+ # with args { project, script, out_tmp, collection, blend, result }. The
7
+ # answer goes to args.result as JSON; stdout belongs to the agent's prints.
8
+ # Written for Blender 4.2 to 5.1: anything newer than 4.2 is tried and
9
+ # dropped with a warning when the running Blender refuses it.
10
+ #
11
+ # The script is the agent's own bpy: nothing is put on its path but the
12
+ # folder it sits in. After it ran, the answer also says what it read from the
13
+ # project (`inputs`: the images and linked libraries under it, for the
14
+ # licence ledger), leaving out the files the run wrote itself (its bakes).
15
+
16
+ import json
17
+ import os
18
+ import sys
19
+ import time
20
+ import traceback
21
+
22
+ import bpy
23
+
24
+ # Compiled copies of the modules beside this file would land inside the
25
+ # app; nothing is gained, since every run starts a fresh Blender.
26
+ sys.dont_write_bytecode = True
27
+ HERE = os.path.dirname(os.path.realpath(__file__))
28
+ if HERE not in sys.path:
29
+ sys.path.append(HERE)
30
+
31
+ from nw_export import dropped_nodes, export # noqa: E402
32
+
33
+ ARGS = json.load(open(sys.argv[sys.argv.index('--') + 1], encoding='utf-8'))
34
+ STARTED = time.time()
35
+ WARNINGS = []
36
+
37
+ # What "every visible mesh, curve, text and empty" means in Blender's types.
38
+ # Armatures go along so a rigged model keeps its skeleton and animations.
39
+ EXPORT_TYPES = {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'EMPTY', 'ARMATURE'}
40
+
41
+
42
+ def write_result(doc):
43
+ doc['seconds'] = round(time.time() - STARTED, 2)
44
+ doc['warnings'] = WARNINGS
45
+ with open(ARGS['result'], 'w', encoding='utf-8') as f:
46
+ json.dump(doc, f)
47
+
48
+
49
+ def empty_scene():
50
+ # The factory scene's cube, camera and light would otherwise be exported
51
+ # along with the model; its world stays, for scripts that set a sky.
52
+ for obj in list(bpy.data.objects):
53
+ bpy.data.objects.remove(obj, do_unlink=True)
54
+ scene = bpy.context.scene
55
+ for coll in list(scene.collection.children):
56
+ bpy.data.collections.remove(coll)
57
+ try:
58
+ bpy.data.orphans_purge(do_recursive=True)
59
+ except Exception:
60
+ pass
61
+ scene.unit_settings.system = 'METRIC'
62
+ scene.unit_settings.scale_length = 1.0
63
+
64
+
65
+ def script_frame(error, script):
66
+ """The deepest traceback line inside the agent's own script."""
67
+ if isinstance(error, SyntaxError) and error.filename and os.path.realpath(error.filename) == script:
68
+ return {'line': error.lineno, 'text': (error.text or '').strip()}
69
+ found = None
70
+ for frame in traceback.extract_tb(error.__traceback__):
71
+ if os.path.realpath(frame.filename) == script:
72
+ found = {'line': frame.lineno, 'text': (frame.line or '').strip()}
73
+ return found
74
+
75
+
76
+ def script_traceback(error, script):
77
+ """The traceback from the agent's script down, without this runner's frames."""
78
+ tb = error.__traceback__
79
+ while tb is not None and os.path.realpath(tb.tb_frame.f_code.co_filename) != script:
80
+ tb = tb.tb_next
81
+ if tb is None:
82
+ return ''.join(traceback.format_exception_only(type(error), error))
83
+ return ''.join(traceback.format_exception(type(error), error, tb))
84
+
85
+
86
+ def run_script(script):
87
+ project = ARGS['project']
88
+ os.chdir(project)
89
+ # A script may keep helpers beside it (blender/lib.py) and import them;
90
+ # this runner's own folder is taken off the path, so the script sees
91
+ # only bpy, its own folder and Python's.
92
+ sys.path.insert(0, os.path.dirname(script))
93
+ if HERE in sys.path:
94
+ sys.path.remove(HERE)
95
+ # Old habits read the output path from sys.argv and export or reset the
96
+ # scene themselves; nw_blender does both, so the script gets no arguments.
97
+ sys.argv = [script]
98
+ with open(script, encoding='utf-8') as f:
99
+ source = f.read()
100
+ code = compile(source, script, 'exec')
101
+ scope = {'__name__': '__main__', '__file__': script, 'NW_PROJECT': project}
102
+ try:
103
+ exec(code, scope)
104
+ except SystemExit as e:
105
+ if e.code not in (None, 0):
106
+ raise RuntimeError(f'the script called sys.exit({e.code!r})') from None
107
+ WARNINGS.append('the script called sys.exit(); nw_blender carried on and exported (leave it out)')
108
+
109
+
110
+ def export_objects(scene, collection):
111
+ view_layer = bpy.context.view_layer
112
+ if collection:
113
+ coll = bpy.data.collections.get(collection)
114
+ if coll is None:
115
+ return None, [c.name for c in bpy.data.collections]
116
+ # A collection kept out of the default export (a lighter copy the
117
+ # script excluded from the view layer) is what this call asked for,
118
+ # so it is shown for the export.
119
+ show_collection(view_layer.layer_collection, coll)
120
+ pool = coll.all_objects
121
+ else:
122
+ pool = scene.objects
123
+ # Visibility and selectability live on the view layer's bases, which
124
+ # Blender refreshes only when the scene is evaluated; objects the script
125
+ # just made can read as hidden and refuse selection until then.
126
+ view_layer.update()
127
+ picked = []
128
+ for obj in pool:
129
+ if obj.type not in EXPORT_TYPES:
130
+ continue
131
+ try:
132
+ if not obj.visible_get(view_layer=view_layer):
133
+ continue
134
+ except Exception:
135
+ continue
136
+ picked.append(obj)
137
+ return picked, None
138
+
139
+
140
+ def show_collection(layer, coll):
141
+ """Includes coll (and the layer collections above it) in the view layer and unhides it."""
142
+ if layer.collection == coll:
143
+ layer.exclude = False
144
+ layer.hide_viewport = False
145
+ coll.hide_viewport = False
146
+ return True
147
+ for child in layer.children:
148
+ if show_collection(child, coll):
149
+ layer.exclude = False
150
+ layer.hide_viewport = False
151
+ return True
152
+ return False
153
+
154
+
155
+ def project_relative(path, project):
156
+ """The project-relative path of a file inside the project, else None."""
157
+ if not path:
158
+ return None
159
+ try:
160
+ full = os.path.realpath(bpy.path.abspath(path))
161
+ except Exception:
162
+ return None
163
+ root = os.path.realpath(project)
164
+ if not full.startswith(root + os.sep) or not os.path.isfile(full):
165
+ return None
166
+ return os.path.relpath(full, root).replace(os.sep, '/')
167
+
168
+
169
+ def written_this_run(full):
170
+ """Whether a file was written after this run started (a bake the script
171
+ saved), so it is the run's own output and not something it read."""
172
+ try:
173
+ return os.path.getmtime(full) >= STARTED - 0.05
174
+ except OSError:
175
+ return False
176
+
177
+
178
+ def read_inputs(project):
179
+ """The project's files the script read: images and linked libraries, not
180
+ the files the run wrote itself (its bakes)."""
181
+ found = []
182
+ for block in list(bpy.data.images) + list(bpy.data.libraries):
183
+ if getattr(block, 'source', 'FILE') not in ('FILE', 'SEQUENCE', 'TILED', 'MOVIE'):
184
+ continue
185
+ path = getattr(block, 'filepath', '')
186
+ rel = project_relative(path, project)
187
+ if not rel or rel in found:
188
+ continue
189
+ if written_this_run(os.path.join(os.path.realpath(project), rel)):
190
+ continue
191
+ found.append(rel)
192
+ return sorted(found)
193
+
194
+
195
+ def main():
196
+ script = os.path.realpath(ARGS['script'])
197
+ empty_scene()
198
+ try:
199
+ run_script(script)
200
+ except BaseException as e:
201
+ trace = script_traceback(e, script)
202
+ write_result({
203
+ 'ok': False,
204
+ 'stage': 'script',
205
+ 'error': f'{type(e).__name__}: {e}',
206
+ 'traceback': trace,
207
+ 'at': script_frame(e, script),
208
+ })
209
+ sys.stderr.write(trace)
210
+ sys.exit(3)
211
+
212
+ # A script that ends in edit mode has edits the mesh data does not have yet.
213
+ try:
214
+ if bpy.context.object is not None and bpy.context.object.mode != 'OBJECT':
215
+ bpy.ops.object.mode_set(mode='OBJECT')
216
+ except Exception:
217
+ pass
218
+
219
+ scene = bpy.context.scene
220
+ selected, collections = export_objects(scene, ARGS.get('collection'))
221
+ if selected is None:
222
+ write_result({'ok': False, 'stage': 'collection', 'collection': ARGS.get('collection'), 'collections': collections})
223
+ sys.exit(3)
224
+ if not selected:
225
+ write_result({'ok': False, 'stage': 'empty', 'collection': ARGS.get('collection')})
226
+ sys.exit(3)
227
+
228
+ meshes = sum(1 for o in selected if o.type == 'MESH')
229
+ dropped = dropped_nodes(selected)
230
+ try:
231
+ export(ARGS['out_tmp'], selected, WARNINGS)
232
+ except BaseException as e:
233
+ write_result({'ok': False, 'stage': 'export', 'error': f'{type(e).__name__}: {e}', 'traceback': traceback.format_exc()})
234
+ raise
235
+ if not os.path.isfile(ARGS['out_tmp']) or os.path.getsize(ARGS['out_tmp']) == 0:
236
+ write_result({'ok': False, 'stage': 'export', 'error': 'the glTF exporter wrote no file', 'traceback': ''})
237
+ sys.exit(3)
238
+
239
+ if ARGS.get('blend'):
240
+ try:
241
+ os.makedirs(os.path.dirname(ARGS['blend']), exist_ok=True)
242
+ bpy.ops.wm.save_as_mainfile(filepath=ARGS['blend'], compress=True)
243
+ except Exception as e:
244
+ WARNINGS.append(f'the .blend was not saved: {e}')
245
+
246
+ write_result({
247
+ 'ok': True, 'objects': len(selected), 'meshes': meshes, 'dropped': dropped, 'exported': ARGS['out_tmp'],
248
+ 'inputs': read_inputs(ARGS['project']),
249
+ })
250
+
251
+
252
+ main()