@fleox/agent3d 0.0.0-stage → 0.2.1

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 (455) hide show
  1. package/LICENSE +143 -0
  2. package/README.md +396 -2
  3. package/changelog.json +68 -0
  4. package/dist/agent/agent3d.mjs +11242 -0
  5. package/dist/agent/chunks/assets-BUUM9TUB.mjs +2448 -0
  6. package/dist/agent/chunks/browser-t_JL_B82.mjs +226 -0
  7. package/dist/agent/chunks/cdp-Bdtm4fBN.mjs +178 -0
  8. package/dist/agent/chunks/check-CBO3Ekx1.mjs +971 -0
  9. package/dist/agent/chunks/export-BCI8vKw8.mjs +1130 -0
  10. package/dist/agent/chunks/gif-DQznzHTL.mjs +319 -0
  11. package/dist/agent/chunks/gltf-f_f0-OiV.mjs +207 -0
  12. package/dist/agent/chunks/imageCodec-Dz9PFxi9.mjs +101 -0
  13. package/dist/agent/chunks/jsonPath-DUCe1JpS.mjs +155 -0
  14. package/dist/agent/chunks/meshoptimizer-C-tN9jn5.mjs +1165 -0
  15. package/dist/agent/chunks/mp4-aOALfp3s.mjs +130 -0
  16. package/dist/agent/chunks/objects-DBAws7uf.mjs +53 -0
  17. package/dist/agent/chunks/optimizeSizing-CkZ3fZRp.mjs +540 -0
  18. package/dist/agent/chunks/package-BOIyp_2B.mjs +75 -0
  19. package/dist/agent/chunks/png-DXfSGJZt.mjs +91 -0
  20. package/dist/agent/chunks/render-CN4mgGLQ.mjs +1511 -0
  21. package/dist/agent/chunks/rolldown-runtime-ebOQtxsr.mjs +18 -0
  22. package/dist/agent/chunks/scene-BgajNvBf.mjs +444 -0
  23. package/dist/agent/chunks/server-CACCerkZ.mjs +237 -0
  24. package/dist/agent/chunks/suggest-Cpcgv1RP.mjs +46 -0
  25. package/dist/agent/chunks/tools-DT2tetIK.mjs +1412 -0
  26. package/dist/agent/chunks/tree-BrNYGui2.mjs +75 -0
  27. package/dist/agent/chunks/webpAnim-qaq9YgKl.mjs +132 -0
  28. package/dist/runtime/agent3d-runtime.js +373 -0
  29. package/dist/runtime/agent3d-runtime.single.js +7360 -0
  30. package/dist/runtime/chunks/BufferGeometryUtils-XmME4f7Z.js +1 -0
  31. package/dist/runtime/chunks/EXRLoader-CBdIpBMT.js +1 -0
  32. package/dist/runtime/chunks/FontLoader-dVu9WH2X.js +2 -0
  33. package/dist/runtime/chunks/GLTFLoader-Z9Inv-Xm.js +1 -0
  34. package/dist/runtime/chunks/GroundedSkybox-g1ASZWNu.js +1 -0
  35. package/dist/runtime/chunks/HDRLoader-DBOMWa7O.js +5 -0
  36. package/dist/runtime/chunks/OrbitControls-BIpWXK4x.js +1 -0
  37. package/dist/runtime/chunks/RectAreaLightUniformsLib-4ZzgX9vp.js +1 -0
  38. package/dist/runtime/chunks/RoomEnvironment-CXgfLJdO.js +1 -0
  39. package/dist/runtime/chunks/RoundedBoxGeometry-BViRogcJ.js +1 -0
  40. package/dist/runtime/chunks/SVGLoader-CV0U1EIF.js +1 -0
  41. package/dist/runtime/chunks/SkeletonUtils-DHlReJx3.js +1 -0
  42. package/dist/runtime/chunks/Sky-DGJXlPb_.js +243 -0
  43. package/dist/runtime/chunks/audio-DbVNbf-r.js +1 -0
  44. package/dist/runtime/chunks/catalog-DL6sgPay.js +1 -0
  45. package/dist/runtime/chunks/easing-CXSz2e6P.js +1 -0
  46. package/dist/runtime/chunks/extrude-D6WnITQq.js +1 -0
  47. package/dist/runtime/chunks/game-BoEiyZrL.js +20 -0
  48. package/dist/runtime/chunks/generators-D5JUo0jp.js +331 -0
  49. package/dist/runtime/chunks/materials-Dn-bYrZd.js +107 -0
  50. package/dist/runtime/chunks/meshGradient.glsl-BMatplLA.js +88 -0
  51. package/dist/runtime/chunks/meshopt_decoder.module-DXTYc6wn.js +1 -0
  52. package/dist/runtime/chunks/model-BCVF3QzB.js +1 -0
  53. package/dist/runtime/chunks/params-C2uoUDJ0.js +1 -0
  54. package/dist/runtime/chunks/physicsHost-ChPgysMQ.js +1 -0
  55. package/dist/runtime/chunks/postfx-UgKCbmZs.js +1527 -0
  56. package/dist/runtime/chunks/postfx-i_J5Vf-l.js +1 -0
  57. package/dist/runtime/chunks/random-eeej60NW.js +1 -0
  58. package/dist/runtime/chunks/shaders-Dw6zHdu_.js +443 -0
  59. package/dist/runtime/chunks/svg-CmlFY_8O.js +1 -0
  60. package/dist/runtime/chunks/text-D1EQpdSU.js +2 -0
  61. package/dist/runtime/chunks/three.module-DnaBiDAJ.js +4225 -0
  62. package/dist/runtime/chunks/toon-BsvVk_nK.js +6 -0
  63. package/dist/runtime/chunks/util-CyaW1fcW.js +1 -0
  64. package/dist/studio/assets/BufferGeometryUtils-CAlXAboW.js +1 -0
  65. package/dist/studio/assets/EXRLoader-BKkzlNd8.js +1 -0
  66. package/dist/studio/assets/FontLoader-Bzjx8mXt.js +2 -0
  67. package/dist/studio/assets/GLTFLoader-1Zd9N406.js +1 -0
  68. package/dist/studio/assets/GroundedSkybox-BEMqNCBD.js +1 -0
  69. package/dist/studio/assets/HDRLoader-DxB0kxPH.js +5 -0
  70. package/dist/studio/assets/OrbitControls-MlE9XiCg.js +1 -0
  71. package/dist/studio/assets/RectAreaLightUniformsLib-ClHrtYY6.js +1 -0
  72. package/dist/studio/assets/RoomEnvironment-MJ-jIEC8.js +1 -0
  73. package/dist/studio/assets/SVGLoader-CIYl0nEy.js +1 -0
  74. package/dist/studio/assets/SkeletonUtils-CG5akqME.js +1 -0
  75. package/dist/studio/assets/Sky-DNMfpp92.js +243 -0
  76. package/dist/studio/assets/audio-JD1kyX0A.js +1 -0
  77. package/dist/studio/assets/camera-7sEn13L-.js +2 -0
  78. package/dist/studio/assets/editor-CnbvVkhU.js +53 -0
  79. package/dist/studio/assets/extrude-9bG8hr2C.js +1 -0
  80. package/dist/studio/assets/game-B04KGAK0.js +19 -0
  81. package/dist/studio/assets/generators-LSni1Yfc.js +331 -0
  82. package/dist/studio/assets/index-3LL5NEIH.js +479 -0
  83. package/dist/studio/assets/index-BQT0otii.css +1 -0
  84. package/dist/studio/assets/meshopt_decoder.module-DXTYc6wn.js +1 -0
  85. package/dist/studio/assets/meshoptimizer-BCSwHBL3.js +1 -0
  86. package/dist/studio/assets/model-CNddhwmA.js +2 -0
  87. package/dist/studio/assets/physicsHost-hMU_SDiX.js +1 -0
  88. package/dist/studio/assets/postfx-BcCZS0Bq.js +1527 -0
  89. package/dist/studio/assets/runtime-DY_KqD1x.js +572 -0
  90. package/dist/studio/assets/shaders-BhMCstyv.js +443 -0
  91. package/dist/studio/assets/svg-CNKK-h7H.js +2 -0
  92. package/dist/studio/assets/text-BSPI7dk1.js +3 -0
  93. package/dist/studio/assets/three.module-CnI50X0U.js +4225 -0
  94. package/dist/studio/index.html +16 -0
  95. package/library/LICENSES.md +77 -0
  96. package/library/fonts/LICENSES.md +42 -0
  97. package/library/fonts/anton.typeface.json +1 -0
  98. package/library/fonts/bebas-neue.typeface.json +1 -0
  99. package/library/fonts/display.typeface.json +1 -0
  100. package/library/fonts/inter-black.typeface.json +1 -0
  101. package/library/fonts/lobster.typeface.json +1 -0
  102. package/library/fonts/mono.typeface.json +1 -0
  103. package/library/fonts/montserrat-extrabold.typeface.json +1 -0
  104. package/library/fonts/pacifico.typeface.json +1 -0
  105. package/library/fonts/sans-bold.typeface.json +1 -0
  106. package/library/fonts/sans.typeface.json +1 -0
  107. package/library/fonts/serif-bold.typeface.json +1 -0
  108. package/library/fonts/serif.typeface.json +1 -0
  109. package/library/fonts/space-grotesk-bold.typeface.json +1 -0
  110. package/library/hdri/beach.hdr +0 -0
  111. package/library/hdri/beach.jpg +0 -0
  112. package/library/hdri/city.hdr +0 -0
  113. package/library/hdri/city.jpg +0 -0
  114. package/library/hdri/forest.hdr +0 -0
  115. package/library/hdri/forest.jpg +0 -0
  116. package/library/hdri/night-city.hdr +0 -0
  117. package/library/hdri/night-city.jpg +0 -0
  118. package/library/hdri/night.hdr +0 -0
  119. package/library/hdri/night.jpg +0 -0
  120. package/library/hdri/sky.hdr +0 -0
  121. package/library/hdri/sky.jpg +0 -0
  122. package/library/hdri/softbox.hdr +0 -0
  123. package/library/hdri/softbox.jpg +0 -0
  124. package/library/hdri/studio.hdr +0 -0
  125. package/library/hdri/studio.jpg +0 -0
  126. package/library/hdri/sunset.hdr +0 -0
  127. package/library/hdri/sunset.jpg +0 -0
  128. package/library/hdri/warehouse.hdr +0 -0
  129. package/library/hdri/warehouse.jpg +0 -0
  130. package/library/index.json +5510 -0
  131. package/library/models/animals/fish.glb +0 -0
  132. package/library/models/animals/fox.glb +0 -0
  133. package/library/models/buildings/castle.glb +0 -0
  134. package/library/models/buildings/house.glb +0 -0
  135. package/library/models/buildings/market.glb +0 -0
  136. package/library/models/buildings/tavern.glb +0 -0
  137. package/library/models/buildings/tower.glb +0 -0
  138. package/library/models/buildings/windmill.glb +0 -0
  139. package/library/models/characters/barbarian.glb +0 -0
  140. package/library/models/characters/knight.glb +0 -0
  141. package/library/models/characters/mage.glb +0 -0
  142. package/library/models/characters/mini-soldier.glb +0 -0
  143. package/library/models/characters/platformer-hero.glb +0 -0
  144. package/library/models/characters/robot.glb +0 -0
  145. package/library/models/characters/rogue.glb +0 -0
  146. package/library/models/characters/skeleton.glb +0 -0
  147. package/library/models/city/building-a.glb +0 -0
  148. package/library/models/city/building-b.glb +0 -0
  149. package/library/models/city/building-tall.glb +0 -0
  150. package/library/models/city/fire-hydrant.glb +0 -0
  151. package/library/models/city/road-corner.glb +0 -0
  152. package/library/models/city/road-crossing.glb +0 -0
  153. package/library/models/city/road-junction.glb +0 -0
  154. package/library/models/city/road-straight.glb +0 -0
  155. package/library/models/city/streetlight.glb +0 -0
  156. package/library/models/city/suburban-house.glb +0 -0
  157. package/library/models/city/traffic-light.glb +0 -0
  158. package/library/models/city/water-tower.glb +0 -0
  159. package/library/models/food/apple.glb +0 -0
  160. package/library/models/food/avocado.glb +0 -0
  161. package/library/models/food/baguette.glb +0 -0
  162. package/library/models/food/bread-loaf.glb +0 -0
  163. package/library/models/food/burger.glb +0 -0
  164. package/library/models/food/carrot.glb +0 -0
  165. package/library/models/food/cheese.glb +0 -0
  166. package/library/models/food/cookie.glb +0 -0
  167. package/library/models/food/croissant.glb +0 -0
  168. package/library/models/food/cupcake.glb +0 -0
  169. package/library/models/food/dinner-plate.glb +0 -0
  170. package/library/models/food/donut.glb +0 -0
  171. package/library/models/food/ketchup.glb +0 -0
  172. package/library/models/food/mug.glb +0 -0
  173. package/library/models/food/pain-au-chocolat.glb +0 -0
  174. package/library/models/food/stew.glb +0 -0
  175. package/library/models/food/tomato.glb +0 -0
  176. package/library/models/food/veggie-burger.glb +0 -0
  177. package/library/models/nature/bush.glb +0 -0
  178. package/library/models/nature/cactus.glb +0 -0
  179. package/library/models/nature/cloud.glb +0 -0
  180. package/library/models/nature/fir-tree.glb +0 -0
  181. package/library/models/nature/forest-patch.glb +0 -0
  182. package/library/models/nature/grass-small.glb +0 -0
  183. package/library/models/nature/grass.glb +0 -0
  184. package/library/models/nature/hex-grass.glb +0 -0
  185. package/library/models/nature/hex-water.glb +0 -0
  186. package/library/models/nature/hills.glb +0 -0
  187. package/library/models/nature/mountain.glb +0 -0
  188. package/library/models/nature/pine-autumn.glb +0 -0
  189. package/library/models/nature/pine-tree.glb +0 -0
  190. package/library/models/nature/pumpkin.glb +0 -0
  191. package/library/models/nature/rock-flat.glb +0 -0
  192. package/library/models/nature/rock.glb +0 -0
  193. package/library/models/nature/tree-dead.glb +0 -0
  194. package/library/models/nature/tree-slim.glb +0 -0
  195. package/library/models/nature/trees-cluster.glb +0 -0
  196. package/library/models/nature/waterlily.glb +0 -0
  197. package/library/models/platformer/blaster.glb +0 -0
  198. package/library/models/platformer/block-coin.glb +0 -0
  199. package/library/models/platformer/brick.glb +0 -0
  200. package/library/models/platformer/coin.glb +0 -0
  201. package/library/models/platformer/enemy-flying.glb +0 -0
  202. package/library/models/platformer/flag.glb +0 -0
  203. package/library/models/platformer/platform-falling.glb +0 -0
  204. package/library/models/platformer/platform-grass-round.glb +0 -0
  205. package/library/models/platformer/platform-large.glb +0 -0
  206. package/library/models/platformer/platform-medium.glb +0 -0
  207. package/library/models/platformer/platform.glb +0 -0
  208. package/library/models/platformer/target.glb +0 -0
  209. package/library/models/platformer/track-corner.glb +0 -0
  210. package/library/models/platformer/track-straight.glb +0 -0
  211. package/library/models/platformer/wall-low.glb +0 -0
  212. package/library/models/products/boombox.glb +0 -0
  213. package/library/models/products/iridescent-lamp.glb +0 -0
  214. package/library/models/products/lantern.glb +0 -0
  215. package/library/models/products/lounge-chair.glb +0 -0
  216. package/library/models/products/sneaker.glb +0 -0
  217. package/library/models/products/velvet-sofa.glb +0 -0
  218. package/library/models/products/water-bottle.glb +0 -0
  219. package/library/models/props/alarm-clock.glb +0 -0
  220. package/library/models/props/armchair.glb +0 -0
  221. package/library/models/props/barrel.glb +0 -0
  222. package/library/models/props/bench.glb +0 -0
  223. package/library/models/props/brass-vase.glb +0 -0
  224. package/library/models/props/chest.glb +0 -0
  225. package/library/models/props/coffee-table.glb +0 -0
  226. package/library/models/props/coin-stack.glb +0 -0
  227. package/library/models/props/coin.glb +0 -0
  228. package/library/models/props/couch.glb +0 -0
  229. package/library/models/props/crate.glb +0 -0
  230. package/library/models/props/flag.glb +0 -0
  231. package/library/models/props/gravestone.glb +0 -0
  232. package/library/models/props/key.glb +0 -0
  233. package/library/models/props/lamp.glb +0 -0
  234. package/library/models/props/lantern.glb +0 -0
  235. package/library/models/props/marble-bust.glb +0 -0
  236. package/library/models/props/modern-armchair.glb +0 -0
  237. package/library/models/props/potted-succulent.glb +0 -0
  238. package/library/models/props/rubber-duck.glb +0 -0
  239. package/library/models/props/shield.glb +0 -0
  240. package/library/models/props/sword-shield.glb +0 -0
  241. package/library/models/props/sword.glb +0 -0
  242. package/library/models/props/table.glb +0 -0
  243. package/library/models/props/tent.glb +0 -0
  244. package/library/models/props/torch.glb +0 -0
  245. package/library/models/props/trophy.glb +0 -0
  246. package/library/models/space/base-module.glb +0 -0
  247. package/library/models/space/lander.glb +0 -0
  248. package/library/models/space/landing-pad.glb +0 -0
  249. package/library/models/space/rocks.glb +0 -0
  250. package/library/models/space/solar-panel.glb +0 -0
  251. package/library/models/space/space-truck.glb +0 -0
  252. package/library/models/space/wind-turbine.glb +0 -0
  253. package/library/models/vehicles/car.glb +0 -0
  254. package/library/models/vehicles/hatchback.glb +0 -0
  255. package/library/models/vehicles/motorcycle.glb +0 -0
  256. package/library/models/vehicles/police-car.glb +0 -0
  257. package/library/models/vehicles/taxi.glb +0 -0
  258. package/library/models/vehicles/truck.glb +0 -0
  259. package/library/sources.json +2856 -0
  260. package/library/textures/brick-color.jpg +0 -0
  261. package/library/textures/brick-normal.jpg +0 -0
  262. package/library/textures/brick-roughness.jpg +0 -0
  263. package/library/textures/concrete-color.jpg +0 -0
  264. package/library/textures/concrete-normal.jpg +0 -0
  265. package/library/textures/concrete-roughness.jpg +0 -0
  266. package/library/textures/fabric-color.jpg +0 -0
  267. package/library/textures/fabric-normal.jpg +0 -0
  268. package/library/textures/fabric-roughness.jpg +0 -0
  269. package/library/textures/grass-ground-color.jpg +0 -0
  270. package/library/textures/grass-ground-normal.jpg +0 -0
  271. package/library/textures/grass-ground-roughness.jpg +0 -0
  272. package/library/textures/rusty-metal-color.jpg +0 -0
  273. package/library/textures/rusty-metal-normal.jpg +0 -0
  274. package/library/textures/rusty-metal-roughness.jpg +0 -0
  275. package/library/textures/wood-planks-color.jpg +0 -0
  276. package/library/textures/wood-planks-normal.jpg +0 -0
  277. package/library/textures/wood-planks-roughness.jpg +0 -0
  278. package/package.json +67 -4
  279. package/plugin/.claude-plugin/plugin.json +19 -0
  280. package/plugin/skills/agent3d-assets/SKILL.md +140 -0
  281. package/plugin/skills/agent3d-assets/references/sources.md +33 -0
  282. package/plugin/skills/agent3d-create/SKILL.md +141 -0
  283. package/plugin/skills/agent3d-create/references/art-direction.md +144 -0
  284. package/plugin/skills/agent3d-create/references/recipes.md +1357 -0
  285. package/plugin/skills/agent3d-edit/SKILL.md +121 -0
  286. package/plugin/skills/agent3d-edit/references/patch-ops.md +278 -0
  287. package/plugin/skills/agent3d-game/SKILL.md +111 -0
  288. package/plugin/skills/agent3d-game/references/game-patterns.md +262 -0
  289. package/plugin/skills/agent3d-game/references/script-api.md +211 -0
  290. package/plugin/skills/agent3d-publish/SKILL.md +161 -0
  291. package/plugin/skills/agent3d-publish/references/integrations.md +221 -0
  292. package/templates/banner-aurora-night/README.md +15 -0
  293. package/templates/banner-aurora-night/agent3d.json +8 -0
  294. package/templates/banner-aurora-night/preview.png +0 -0
  295. package/templates/banner-aurora-night/scene.json +327 -0
  296. package/templates/banner-aurora-night/template.json +24 -0
  297. package/templates/banner-data-bars/README.md +15 -0
  298. package/templates/banner-data-bars/agent3d.json +8 -0
  299. package/templates/banner-data-bars/preview.png +0 -0
  300. package/templates/banner-data-bars/scene.json +222 -0
  301. package/templates/banner-data-bars/template.json +25 -0
  302. package/templates/banner-floating-shapes/README.md +15 -0
  303. package/templates/banner-floating-shapes/agent3d.json +8 -0
  304. package/templates/banner-floating-shapes/preview.png +0 -0
  305. package/templates/banner-floating-shapes/scene.json +703 -0
  306. package/templates/banner-floating-shapes/template.json +24 -0
  307. package/templates/banner-gradient-blob/README.md +16 -0
  308. package/templates/banner-gradient-blob/agent3d.json +8 -0
  309. package/templates/banner-gradient-blob/preview.png +0 -0
  310. package/templates/banner-gradient-blob/scene.json +330 -0
  311. package/templates/banner-gradient-blob/template.json +21 -0
  312. package/templates/banner-liquid-chrome/README.md +16 -0
  313. package/templates/banner-liquid-chrome/agent3d.json +8 -0
  314. package/templates/banner-liquid-chrome/preview.png +0 -0
  315. package/templates/banner-liquid-chrome/scene.json +290 -0
  316. package/templates/banner-liquid-chrome/template.json +24 -0
  317. package/templates/banner-logo-extrude/README.md +24 -0
  318. package/templates/banner-logo-extrude/agent3d.json +8 -0
  319. package/templates/banner-logo-extrude/assets/logo.svg +6 -0
  320. package/templates/banner-logo-extrude/assets/manifest.json +13 -0
  321. package/templates/banner-logo-extrude/preview.png +0 -0
  322. package/templates/banner-logo-extrude/scene.json +332 -0
  323. package/templates/banner-logo-extrude/template.json +22 -0
  324. package/templates/banner-neon-title/README.md +18 -0
  325. package/templates/banner-neon-title/agent3d.json +8 -0
  326. package/templates/banner-neon-title/preview.png +0 -0
  327. package/templates/banner-neon-title/scene.json +494 -0
  328. package/templates/banner-neon-title/template.json +25 -0
  329. package/templates/banner-wave-grid/README.md +18 -0
  330. package/templates/banner-wave-grid/agent3d.json +8 -0
  331. package/templates/banner-wave-grid/preview.png +0 -0
  332. package/templates/banner-wave-grid/scene.json +217 -0
  333. package/templates/banner-wave-grid/template.json +23 -0
  334. package/templates/card-hover-3d/README.md +16 -0
  335. package/templates/card-hover-3d/agent3d.json +8 -0
  336. package/templates/card-hover-3d/preview.png +0 -0
  337. package/templates/card-hover-3d/scene.json +359 -0
  338. package/templates/card-hover-3d/template.json +21 -0
  339. package/templates/card-product-tilt/README.md +14 -0
  340. package/templates/card-product-tilt/agent3d.json +8 -0
  341. package/templates/card-product-tilt/preview.png +0 -0
  342. package/templates/card-product-tilt/scene.json +296 -0
  343. package/templates/card-product-tilt/template.json +23 -0
  344. package/templates/character-mascot-hero/README.md +19 -0
  345. package/templates/character-mascot-hero/agent3d.json +8 -0
  346. package/templates/character-mascot-hero/preview.png +0 -0
  347. package/templates/character-mascot-hero/scene.json +512 -0
  348. package/templates/character-mascot-hero/template.json +8 -0
  349. package/templates/character-showcase/README.md +27 -0
  350. package/templates/character-showcase/agent3d.json +8 -0
  351. package/templates/character-showcase/preview.png +0 -0
  352. package/templates/character-showcase/scene.json +440 -0
  353. package/templates/character-showcase/template.json +24 -0
  354. package/templates/diorama-city/README.md +21 -0
  355. package/templates/diorama-city/agent3d.json +8 -0
  356. package/templates/diorama-city/preview.png +0 -0
  357. package/templates/diorama-city/scene.json +432 -0
  358. package/templates/diorama-city/template.json +21 -0
  359. package/templates/game-basket/README.md +25 -0
  360. package/templates/game-basket/agent3d.json +8 -0
  361. package/templates/game-basket/preview.png +0 -0
  362. package/templates/game-basket/scene.json +640 -0
  363. package/templates/game-basket/scripts/basket.js +176 -0
  364. package/templates/game-basket/template.json +8 -0
  365. package/templates/game-coin-collector/README.md +28 -0
  366. package/templates/game-coin-collector/agent3d.json +8 -0
  367. package/templates/game-coin-collector/preview.png +0 -0
  368. package/templates/game-coin-collector/scene.json +900 -0
  369. package/templates/game-coin-collector/scripts/collector.js +210 -0
  370. package/templates/game-coin-collector/template.json +19 -0
  371. package/templates/game-maze/README.md +24 -0
  372. package/templates/game-maze/agent3d.json +8 -0
  373. package/templates/game-maze/preview.png +0 -0
  374. package/templates/game-maze/scene.json +315 -0
  375. package/templates/game-maze/scripts/maze.js +168 -0
  376. package/templates/game-maze/template.json +18 -0
  377. package/templates/game-physics-playground/README.md +30 -0
  378. package/templates/game-physics-playground/agent3d.json +8 -0
  379. package/templates/game-physics-playground/preview.png +0 -0
  380. package/templates/game-physics-playground/scene.json +1712 -0
  381. package/templates/game-physics-playground/scripts/playground.js +151 -0
  382. package/templates/game-physics-playground/template.json +19 -0
  383. package/templates/game-platformer/README.md +26 -0
  384. package/templates/game-platformer/agent3d.json +8 -0
  385. package/templates/game-platformer/preview.png +0 -0
  386. package/templates/game-platformer/scene.json +1063 -0
  387. package/templates/game-platformer/scripts/platformer.js +222 -0
  388. package/templates/game-platformer/template.json +8 -0
  389. package/templates/game-runner/README.md +30 -0
  390. package/templates/game-runner/agent3d.json +8 -0
  391. package/templates/game-runner/preview.png +0 -0
  392. package/templates/game-runner/scene.json +1317 -0
  393. package/templates/game-runner/scripts/runner.js +263 -0
  394. package/templates/game-runner/template.json +18 -0
  395. package/templates/game-tap-targets/README.md +21 -0
  396. package/templates/game-tap-targets/agent3d.json +8 -0
  397. package/templates/game-tap-targets/preview.png +0 -0
  398. package/templates/game-tap-targets/scene.json +924 -0
  399. package/templates/game-tap-targets/scripts/targets.js +159 -0
  400. package/templates/game-tap-targets/template.json +19 -0
  401. package/templates/hero-floating-island/README.md +18 -0
  402. package/templates/hero-floating-island/agent3d.json +8 -0
  403. package/templates/hero-floating-island/preview.png +0 -0
  404. package/templates/hero-floating-island/scene.json +658 -0
  405. package/templates/hero-floating-island/template.json +8 -0
  406. package/templates/hero-perfume-luxury/README.md +18 -0
  407. package/templates/hero-perfume-luxury/agent3d.json +8 -0
  408. package/templates/hero-perfume-luxury/preview.png +0 -0
  409. package/templates/hero-perfume-luxury/scene.json +529 -0
  410. package/templates/hero-perfume-luxury/template.json +27 -0
  411. package/templates/hero-product-turntable/README.md +16 -0
  412. package/templates/hero-product-turntable/agent3d.json +8 -0
  413. package/templates/hero-product-turntable/preview.png +0 -0
  414. package/templates/hero-product-turntable/scene.json +225 -0
  415. package/templates/hero-product-turntable/template.json +21 -0
  416. package/templates/hero-saas-globe/README.md +16 -0
  417. package/templates/hero-saas-globe/agent3d.json +8 -0
  418. package/templates/hero-saas-globe/preview.png +0 -0
  419. package/templates/hero-saas-globe/scene.json +318 -0
  420. package/templates/hero-saas-globe/template.json +24 -0
  421. package/templates/hero-scroll-story/README.md +26 -0
  422. package/templates/hero-scroll-story/agent3d.json +8 -0
  423. package/templates/hero-scroll-story/preview.png +0 -0
  424. package/templates/hero-scroll-story/scene.json +642 -0
  425. package/templates/hero-scroll-story/template.json +22 -0
  426. package/templates/hero-sneaker-showcase/README.md +19 -0
  427. package/templates/hero-sneaker-showcase/agent3d.json +8 -0
  428. package/templates/hero-sneaker-showcase/preview.png +0 -0
  429. package/templates/hero-sneaker-showcase/scene.json +523 -0
  430. package/templates/hero-sneaker-showcase/template.json +23 -0
  431. package/templates/hero-space-planet/README.md +17 -0
  432. package/templates/hero-space-planet/agent3d.json +8 -0
  433. package/templates/hero-space-planet/preview.png +0 -0
  434. package/templates/hero-space-planet/scene.json +330 -0
  435. package/templates/hero-space-planet/template.json +21 -0
  436. package/templates/landscape-island/README.md +21 -0
  437. package/templates/landscape-island/agent3d.json +8 -0
  438. package/templates/landscape-island/preview.png +0 -0
  439. package/templates/landscape-island/scene.json +716 -0
  440. package/templates/landscape-island/template.json +24 -0
  441. package/templates/landscape-night-galaxy/README.md +25 -0
  442. package/templates/landscape-night-galaxy/agent3d.json +8 -0
  443. package/templates/landscape-night-galaxy/preview.png +0 -0
  444. package/templates/landscape-night-galaxy/scene.json +403 -0
  445. package/templates/landscape-night-galaxy/template.json +8 -0
  446. package/templates/landscape-valley-sunset/README.md +20 -0
  447. package/templates/landscape-valley-sunset/agent3d.json +8 -0
  448. package/templates/landscape-valley-sunset/preview.png +0 -0
  449. package/templates/landscape-valley-sunset/scene.json +265 -0
  450. package/templates/landscape-valley-sunset/template.json +22 -0
  451. package/templates/scene-cozy-room/README.md +21 -0
  452. package/templates/scene-cozy-room/agent3d.json +8 -0
  453. package/templates/scene-cozy-room/preview.png +0 -0
  454. package/templates/scene-cozy-room/scene.json +728 -0
  455. package/templates/scene-cozy-room/template.json +8 -0
@@ -0,0 +1,1412 @@
1
+ import { createRequire as __a3dRequire } from "node:module";
2
+ import { fileURLToPath as __a3dPath } from "node:url";
3
+ import { dirname as __a3dDirname } from "node:path";
4
+ __a3dRequire(import.meta.url);
5
+ const __filename = __a3dPath(import.meta.url);
6
+ __a3dDirname(__filename);
7
+ import { S as CATALOG, c as createProject, f as DEFAULT_ASPECT, g as validateScene, h as TARGET_KINDS, i as listTemplates, k as OpsError, l as loadProject, r as findTemplate, u as readSceneFile } from "../agent3d.mjs";
8
+ import { t as closest } from "./suggest-Cpcgv1RP.mjs";
9
+ import { a as listAssets, f as optimizedExportSources, i as importAssetZip, l as searchAssetsDetailed, o as listLibrary, p as SOURCE_IDS, r as downloadAsset, s as parseResolution, t as addAsset, u as optimizeAssets } from "./assets-BUUM9TUB.mjs";
10
+ import { r as modelFileBounds } from "./gltf-f_f0-OiV.mjs";
11
+ import { r as prefixFiles, t as buildExport } from "./export-BCI8vKw8.mjs";
12
+ import { i as getAt, t as PathError } from "./jsonPath-DUCe1JpS.mjs";
13
+ import { n as checkProject } from "./check-CBO3Ekx1.mjs";
14
+ import { a as updateObject, i as removeObject, n as listObjects, t as addObject } from "./objects-DBAws7uf.mjs";
15
+ import { i as patchScene, n as applyScene, o as summarizeScene, r as getScene, t as PATCH_OPS } from "./scene-BgajNvBf.mjs";
16
+ // src/ai/shared.ts
17
+ function str(input, key, required = true) {
18
+ const v = input[key];
19
+ if (typeof v === "string" && v.trim()) return v.trim();
20
+ if (required) throw new OpsError("invalid", `Missing "${key}" (string).`);
21
+ return "";
22
+ }
23
+ function optStr(input, key) {
24
+ const v = input[key];
25
+ return typeof v === "string" && v.trim() ? v.trim() : void 0;
26
+ }
27
+ function bool(input, key, fallback = false) {
28
+ const v = input[key];
29
+ return typeof v === "boolean" ? v : fallback;
30
+ }
31
+ function num(input, key) {
32
+ const v = input[key];
33
+ return typeof v === "number" && Number.isFinite(v) ? v : void 0;
34
+ }
35
+ function compactIssues(issues, max = 40) {
36
+ const order = {
37
+ error: 0,
38
+ warning: 1,
39
+ info: 2
40
+ };
41
+ const sorted = [...issues].sort((a, b) => order[a.severity] - order[b.severity]);
42
+ const shown = sorted.slice(0, max);
43
+ return sorted.length > max ? {
44
+ issues: shown,
45
+ omitted: sorted.length - max
46
+ } : { issues: shown };
47
+ }
48
+ function issueCounts(issues) {
49
+ const c = {
50
+ errors: 0,
51
+ warnings: 0,
52
+ infos: 0
53
+ };
54
+ for (const i of issues) c[i.severity === "error" ? "errors" : i.severity === "warning" ? "warnings" : "infos"]++;
55
+ return c;
56
+ }
57
+ function mutationResult(r, dryRun) {
58
+ const counts = issueCounts(r.issues);
59
+ const status = counts.errors ? "refused" : r.plan.empty ? "unchanged" : dryRun ? "dry-run" : "applied";
60
+ return {
61
+ status,
62
+ applied: r.applied,
63
+ plan: r.plan.empty ? { summary: r.plan.summary } : r.plan,
64
+ counts,
65
+ ...compactIssues(r.issues.filter((i) => counts.errors === 0 || i.severity !== "info")),
66
+ hint: status === "refused" ? "Nothing was written: fix the errors (each issue has a hint) and call again." : status === "applied" ? "Saved. Call render_preview (when available) and look at the image to verify, or check for budget / framing issues." : status === "dry-run" ? "Dry run: call again without dryRun to write." : "The scene already matches: nothing to do."
67
+ };
68
+ }
69
+ function checkInput(schema, input, tool) {
70
+ if (input === void 0 || input === null) input = {};
71
+ if (typeof input !== "object" || Array.isArray(input)) throw new OpsError("invalid", `${tool}: input must be a JSON object.`);
72
+ const obj = input;
73
+ for (const k of schema.required ?? []) if (obj[k] === void 0 || obj[k] === null || obj[k] === "") throw new OpsError("invalid", `${tool}: missing required input "${k}".`, schema.properties?.[k]?.description);
74
+ for (const [k, v] of Object.entries(obj)) {
75
+ const p = schema.properties?.[k];
76
+ if (!p || v === void 0 || v === null || !p.type) continue;
77
+ const types = Array.isArray(p.type) ? p.type : [p.type];
78
+ const actual = Array.isArray(v) ? "array" : typeof v === "number" ? Number.isInteger(v) ? "integer" : "number" : typeof v;
79
+ if (!types.some((t) => t === actual || t === "number" && actual === "integer")) throw new OpsError("invalid", `${tool}: "${k}" must be ${types.join(" or ")}, got ${actual}.`, p.description);
80
+ if (p.enum && !p.enum.includes(v)) throw new OpsError("invalid", `${tool}: "${k}" must be one of ${p.enum.map((x) => JSON.stringify(x)).join(", ")}.`);
81
+ }
82
+ return obj;
83
+ }
84
+ // src/ops/timeline.ts
85
+ async function setTimeline(fs, timeline, opts = {}) {
86
+ if (timeline === null) {
87
+ const has = (await readSceneFile(fs)).timeline !== void 0;
88
+ return patchScene(fs, has ? [{
89
+ op: "remove",
90
+ path: "timeline"
91
+ }] : [], opts);
92
+ }
93
+ return patchScene(fs, [{
94
+ op: "set",
95
+ path: "timeline",
96
+ value: normalizeTimeline(timeline)
97
+ }], opts);
98
+ }
99
+ async function editTimeline(fs, edit, opts = {}) {
100
+ const ops = [];
101
+ for (const t of edit.addTracks ?? []) ops.push({
102
+ op: "addTrack",
103
+ track: t
104
+ });
105
+ for (const t of edit.removeTargets ?? []) ops.push({
106
+ op: "removeTrack",
107
+ target: t
108
+ });
109
+ const settings = { ...edit.settings ?? {} };
110
+ if (edit.markers && Object.keys(edit.markers).length) settings.markers = {
111
+ ...settings.markers ?? {},
112
+ ...edit.markers
113
+ };
114
+ if (edit.segments && Object.keys(edit.segments).length) settings.segments = {
115
+ ...settings.segments ?? {},
116
+ ...edit.segments
117
+ };
118
+ if (Object.keys(settings).length) {
119
+ if (!ops.length && (await readSceneFile(fs)).timeline === void 0) ops.push({
120
+ op: "set",
121
+ path: "timeline",
122
+ value: {
123
+ duration: 4,
124
+ tracks: []
125
+ }
126
+ });
127
+ ops.push({
128
+ op: "merge",
129
+ path: "timeline",
130
+ value: settings
131
+ });
132
+ }
133
+ return patchScene(fs, ops, opts);
134
+ }
135
+ async function setInteractions(fs, edit, opts = {}) {
136
+ const current = (await readSceneFile(fs)).interactions;
137
+ let next = edit.interactions === void 0 ? current ?? [] : edit.interactions;
138
+ if (edit.add?.length) next = [...next ?? [], ...edit.add];
139
+ if (!next || !next.length) return patchScene(fs, current !== void 0 ? [{
140
+ op: "remove",
141
+ path: "interactions"
142
+ }] : [], opts);
143
+ return patchScene(fs, [{
144
+ op: "set",
145
+ path: "interactions",
146
+ value: next
147
+ }], opts);
148
+ }
149
+ function normalizeTimeline(t) {
150
+ return {
151
+ ...t,
152
+ tracks: (t.tracks ?? []).map((tr) => ({
153
+ ...tr,
154
+ keys: Array.isArray(tr.keys) ? [...tr.keys].sort((a, b) => (a?.[0] ?? 0) - (b?.[0] ?? 0)) : tr.keys
155
+ }))
156
+ };
157
+ }
158
+ // src/ai/sceneTools.ts
159
+ var dryRunProp = {
160
+ type: "boolean",
161
+ description: "Preview the plan and issues without writing (default false)."
162
+ };
163
+ var objectSchema = {
164
+ type: "object",
165
+ description: "An ObjectDef: { \"id\": \"logo\", \"kind\": \"mesh|text|model|group|generator|particles|instances|svg\", \"position\": [x,y,z], \"rotation\": [x,y,z] (DEGREES), \"scale\": n | [x,y,z], \"behaviours\": [{ \"type\": \"rotate\", \"speed\": 30 }], \"children\": [...] } + kind fields: mesh { geometry: { type, …params }, material }, text { text, font, size, depth }, model { src: \"assets/…glb\" | \"library:<id>\", fit }, generator { generator, params, seed }, particles { preset, count, area, size, color }, instances { geometry, material, layout }, svg { src, depth }. Units ≈ metres, Y up. Look ids/params up with catalog_get first.",
166
+ additionalProperties: true
167
+ };
168
+ var SECTION_NAMES = Object.keys(CATALOG);
169
+ function catalogCompact(section, id) {
170
+ if (!section) return {
171
+ sections: Object.fromEntries(SECTION_NAMES.map((s) => [s, CATALOG[s].map((e) => `${e.id} — ${e.description}`)])),
172
+ hint: "Call catalog_get { section, id } for the full parameter list of one entry (types, defaults, ranges). Sections: " + SECTION_NAMES.join(", ") + "."
173
+ };
174
+ const sec = SECTION_NAMES.find((s) => s.toLowerCase() === section.toLowerCase()) ?? SECTION_NAMES.find((s) => s.toLowerCase().startsWith(section.toLowerCase()));
175
+ if (!sec) {
176
+ const s = closest(section, SECTION_NAMES);
177
+ throw new OpsError("notFound", `Unknown catalog section "${section}".`, `${s ? `Did you mean "${s}"? ` : ""}Sections: ${SECTION_NAMES.join(", ")}.`);
178
+ }
179
+ const list = CATALOG[sec];
180
+ if (!id) return {
181
+ section: sec,
182
+ entries: list.map((e) => "props" in e ? {
183
+ id: e.id,
184
+ description: e.description,
185
+ sets: e.props
186
+ } : {
187
+ id: e.id,
188
+ description: e.description,
189
+ params: e.params.map((p) => p.name)
190
+ }),
191
+ hint: sec === "materialPresets" ? "Use as material { \"preset\": \"<id>\", …overrides }." : `catalog_get { section: "${sec}", id } for parameter details.`
192
+ };
193
+ const entry = list.find((e) => e.id === id) ?? list.find((e) => e.id.toLowerCase() === id.toLowerCase());
194
+ if (!entry) {
195
+ const s = closest(id, list.map((e) => e.id));
196
+ throw new OpsError("notFound", `No "${id}" in ${sec}.`, `${s ? `Did you mean "${s}"? ` : ""}Valid ids: ${list.map((e) => e.id).join(", ")}.`);
197
+ }
198
+ return {
199
+ section: sec,
200
+ ...entry
201
+ };
202
+ }
203
+ var SCENE_TOOLS = [
204
+ {
205
+ name: "project_info",
206
+ description: "Overview of the current Agent3D project: manifest, target (kind/aspect), compact scene outline (objects tree, lights, camera, timeline), asset count and validation status. Call this first to orient yourself.",
207
+ inputSchema: {
208
+ type: "object",
209
+ properties: {}
210
+ },
211
+ mutating: false,
212
+ async handler(ctx) {
213
+ const { manifest, scene } = await loadProject(ctx.fs);
214
+ const issues = validateScene(scene);
215
+ const assets = await listAssets(ctx.fs);
216
+ return {
217
+ manifest,
218
+ summary: summarizeScene(scene),
219
+ assets: {
220
+ count: assets.assets.length,
221
+ totalKb: assets.totalKb
222
+ },
223
+ validation: issueCounts(issues),
224
+ hint: "Edit with scene_patch / object_add / object_update (small changes) or scene_apply (full document). Look up ids and params with catalog_get."
225
+ };
226
+ }
227
+ },
228
+ {
229
+ name: "scene_get",
230
+ description: "Return the scene document (scene.json), or one part of it with `path`: \"camera\", \"lights[0]\", \"objects#logo\", \"objects#logo.material\", \"timeline.tracks\". Use scene_summary for a compact outline of big scenes.",
231
+ inputSchema: {
232
+ type: "object",
233
+ properties: { path: {
234
+ type: "string",
235
+ description: "Optional JSON path, e.g. \"objects#logo.material\" or \"environment.background\"."
236
+ } }
237
+ },
238
+ mutating: false,
239
+ async handler(ctx, input) {
240
+ const scene = await getScene(ctx.fs);
241
+ const path = optStr(input, "path");
242
+ if (!path) return scene;
243
+ try {
244
+ return {
245
+ path,
246
+ value: getAt(scene, path)
247
+ };
248
+ } catch (e) {
249
+ if (e instanceof PathError) throw new OpsError("notFound", e.message, e.hint ?? "Use scene_summary to see the structure.");
250
+ throw e;
251
+ }
252
+ }
253
+ },
254
+ {
255
+ name: "scene_summary",
256
+ description: "Compact outline of the scene: objects tree (id, kind, geometry/generator/preset, position, behaviours), lights, camera, background, timeline tracks, post effects, scripts, HUD ids.",
257
+ inputSchema: {
258
+ type: "object",
259
+ properties: {}
260
+ },
261
+ mutating: false,
262
+ async handler(ctx) {
263
+ return summarizeScene(await getScene(ctx.fs));
264
+ }
265
+ },
266
+ {
267
+ name: "scene_apply",
268
+ description: "Replace the whole scene with a full SceneDoc (version 1, id, title, target, camera, environment, lights, objects, optional timeline/postfx/physics/scripts/ui/audio). Validated first: a scene with errors is refused and nothing is written. Returns a diff plan (objects added/removed/changed by id, sections changed); applying the same document twice is a no-op. Prefer scene_patch for small edits. Angles are degrees, units ≈ metres, colours CSS strings.",
269
+ inputSchema: {
270
+ type: "object",
271
+ properties: {
272
+ scene: {
273
+ type: "object",
274
+ description: "The complete SceneDoc.",
275
+ additionalProperties: true
276
+ },
277
+ dryRun: dryRunProp
278
+ },
279
+ required: ["scene"]
280
+ },
281
+ mutating: true,
282
+ async handler(ctx, input) {
283
+ const dryRun = bool(input, "dryRun");
284
+ return mutationResult(await applyScene(ctx.fs, input.scene, { dryRun }), dryRun);
285
+ }
286
+ },
287
+ {
288
+ name: "scene_patch",
289
+ description: "Apply several edits atomically (all or nothing; the result is validated and refused on errors). Ops: {op:\"set\", path, value} · {op:\"merge\", path, value} (deep merge, null deletes a key) · {op:\"remove\", path} · {op:\"addObject\", object, parent?, index?} · {op:\"updateObject\", id, set} (deep merge) · {op:\"removeObject\", id} (also drops its tracks) · {op:\"moveObject\", id, parent? (null = root), index?} · {op:\"addBehaviour\", id, behaviour} · {op:\"addTrack\", track} (replaces a track with the same target) · {op:\"removeTrack\", target}. Paths: \"camera.position\", \"lights[1].intensity\", \"objects#logo.material.color\" (object by id anywhere in the tree), \"objects#logo.position[1]\". Example: [{\"op\":\"set\",\"path\":\"objects#logo.material.color\",\"value\":\"#ff3366\"},{\"op\":\"addBehaviour\",\"id\":\"logo\",\"behaviour\":{\"type\":\"float\",\"amplitude\":0.2}}].",
290
+ inputSchema: {
291
+ type: "object",
292
+ properties: {
293
+ ops: {
294
+ type: "array",
295
+ minItems: 1,
296
+ description: "Patch operations, applied in order.",
297
+ items: {
298
+ type: "object",
299
+ properties: {
300
+ op: {
301
+ type: "string",
302
+ enum: PATCH_OPS
303
+ },
304
+ path: { type: "string" },
305
+ value: { description: "Value for set / merge." },
306
+ object: objectSchema,
307
+ parent: { type: ["string", "null"] },
308
+ index: { type: "integer" },
309
+ id: { type: "string" },
310
+ set: {
311
+ type: "object",
312
+ additionalProperties: true
313
+ },
314
+ behaviour: {
315
+ type: "object",
316
+ additionalProperties: true
317
+ },
318
+ track: {
319
+ type: "object",
320
+ additionalProperties: true
321
+ },
322
+ target: { type: "string" }
323
+ },
324
+ required: ["op"]
325
+ }
326
+ },
327
+ dryRun: dryRunProp
328
+ },
329
+ required: ["ops"]
330
+ },
331
+ mutating: true,
332
+ async handler(ctx, input) {
333
+ const dryRun = bool(input, "dryRun");
334
+ return mutationResult(await patchScene(ctx.fs, input.ops, { dryRun }), dryRun);
335
+ }
336
+ },
337
+ {
338
+ name: "scene_validate",
339
+ description: "Validate a scene document (or the current scene.json when `scene` is omitted) against the format and the catalog. Returns issues with readable paths (objects#logo.material.roughness), messages and hints that say exactly what to change. Errors block saving; warnings are ignored fields or likely mistakes.",
340
+ inputSchema: {
341
+ type: "object",
342
+ properties: { scene: {
343
+ type: "object",
344
+ description: "A SceneDoc to validate (default: the project's scene).",
345
+ additionalProperties: true
346
+ } }
347
+ },
348
+ mutating: false,
349
+ async handler(ctx, input) {
350
+ const scene = input.scene ?? await getScene(ctx.fs);
351
+ const issues = validateScene(scene);
352
+ const counts = issueCounts(issues);
353
+ return {
354
+ ok: counts.errors === 0,
355
+ counts,
356
+ ...compactIssues(issues, 60)
357
+ };
358
+ }
359
+ },
360
+ {
361
+ name: "object_add",
362
+ description: "Add an object to the scene (at the root or under `parent`). Ids must be unique across the whole tree and the lights. Example: { \"object\": { \"id\": \"planet\", \"kind\": \"generator\", \"generator\": \"planet\", \"params\": { \"radius\": 1.5, \"rings\": true }, \"position\": [3, 0, 0], \"behaviours\": [{ \"type\": \"rotate\", \"speed\": 10 }] } }. Check generator / geometry params with catalog_get first.",
363
+ inputSchema: {
364
+ type: "object",
365
+ properties: {
366
+ object: objectSchema,
367
+ parent: {
368
+ type: "string",
369
+ description: "Parent object id (default: scene root)."
370
+ },
371
+ index: {
372
+ type: "integer",
373
+ description: "Position among siblings (default: last)."
374
+ },
375
+ dryRun: dryRunProp
376
+ },
377
+ required: ["object"]
378
+ },
379
+ mutating: true,
380
+ async handler(ctx, input) {
381
+ const dryRun = bool(input, "dryRun");
382
+ return mutationResult(await addObject(ctx.fs, input.object, {
383
+ parent: optStr(input, "parent"),
384
+ index: typeof input.index === "number" ? input.index : void 0,
385
+ dryRun
386
+ }), dryRun);
387
+ }
388
+ },
389
+ {
390
+ name: "object_update",
391
+ description: "Change fields of an object by id. `set` is deep-merged: { \"material\": { \"color\": \"#ff0000\" } } keeps the other material fields; null deletes a field; arrays (position, behaviours, colors) are replaced. Rotation in degrees. Example: { \"id\": \"logo\", \"set\": { \"position\": [0, 1.2, 0], \"scale\": 1.5 } }.",
392
+ inputSchema: {
393
+ type: "object",
394
+ properties: {
395
+ id: {
396
+ type: "string",
397
+ description: "Object id."
398
+ },
399
+ set: {
400
+ type: "object",
401
+ description: "Fields to merge into the object.",
402
+ additionalProperties: true
403
+ },
404
+ dryRun: dryRunProp
405
+ },
406
+ required: ["id", "set"]
407
+ },
408
+ mutating: true,
409
+ async handler(ctx, input) {
410
+ const dryRun = bool(input, "dryRun");
411
+ return mutationResult(await updateObject(ctx.fs, str(input, "id"), input.set, { dryRun }), dryRun);
412
+ }
413
+ },
414
+ {
415
+ name: "object_remove",
416
+ description: "Remove an object (and its children) by id. Timeline tracks animating it are removed too. Check camera.follow if it followed this object.",
417
+ inputSchema: {
418
+ type: "object",
419
+ properties: {
420
+ id: {
421
+ type: "string",
422
+ description: "Object id."
423
+ },
424
+ dryRun: dryRunProp
425
+ },
426
+ required: ["id"]
427
+ },
428
+ mutating: true,
429
+ async handler(ctx, input) {
430
+ const dryRun = bool(input, "dryRun");
431
+ return mutationResult(await removeObject(ctx.fs, str(input, "id"), { dryRun }), dryRun);
432
+ }
433
+ },
434
+ {
435
+ name: "object_list",
436
+ description: "Flat list of every object: id, kind, detail (geometry / generator / preset / text), parent id, depth, position, behaviours.",
437
+ inputSchema: {
438
+ type: "object",
439
+ properties: {}
440
+ },
441
+ mutating: false,
442
+ async handler(ctx) {
443
+ const objects = await listObjects(ctx.fs);
444
+ return {
445
+ count: objects.length,
446
+ objects
447
+ };
448
+ }
449
+ },
450
+ {
451
+ name: "timeline_set",
452
+ description: "Edit the keyframe timeline. Replace it with `timeline` ({ \"duration\": 6, \"loop\": true | \"pingpong\", \"trigger\": \"visible|load|hover|click|scroll|manual\", \"speed\", \"autoplay\": true | false | \"<segment>\", \"markers\": { \"name\": seconds }, \"segments\": { \"name\": { \"from\", \"to\" } | [from, to] }, \"scroll\": { \"start\": \"top bottom\", \"end\": \"bottom top\", \"smoothing\": 0.8 }, \"tracks\": [...] }, null removes it), or edit incrementally: `addTracks` (replaces tracks with the same target), `removeTargets`, `settings` (duration, loop, trigger, speed, autoplay, scroll), `markers` / `segments` (merged by name, null removes). A track: { \"target\": \"<selector>.<property>\", \"keys\": [[time_s, value], [time_s, value, \"ease\"]…], \"ease\": \"outCubic\", \"stagger\": 0.06, \"staggerFrom\": \"start|end|center|edges|random\" }. Selector: an id, \"a,b,c\", \"tag:<tag>\", \"children:<id>\" (text letters too), \"camera\", \"environment\", \"postfx\". Properties: position | rotation | scale (vec3, rotation in DEGREES) or .x/.y/.z, visible, material.<opacity|color|emissive|emissiveIntensity|metalness|roughness|…>, material.uniforms.<name>, morph.<name>, animation.<clip>.weight|speed|time (models), light intensity/color/angle/penumbra, camera.position|target|fov|zoom|focus, environment.fog.color|near|far|density, environment.lightingIntensity|exposure|background, postfx.<type>.<param>. Values may be relative: \"+=1\", \"-=0.5\", \"*=1.2\". Easings: in/out/inOut × Quad Cubic Quart Quint Sine Expo Circ Back Elastic Bounce, linear, step, \"cubicBezier(x1,y1,x2,y2)\", \"spring(stiffness,damping)\", \"steps(n)\". Keys are sorted for you.",
453
+ inputSchema: {
454
+ type: "object",
455
+ properties: {
456
+ timeline: {
457
+ type: ["object", "null"],
458
+ description: "Full replacement (null removes the timeline).",
459
+ additionalProperties: true
460
+ },
461
+ addTracks: {
462
+ type: "array",
463
+ items: {
464
+ type: "object",
465
+ additionalProperties: true
466
+ },
467
+ description: "Tracks to add or replace (by target)."
468
+ },
469
+ removeTargets: {
470
+ type: "array",
471
+ items: { type: "string" },
472
+ description: "Targets of tracks to remove."
473
+ },
474
+ settings: {
475
+ type: "object",
476
+ description: "Timeline settings to merge: duration, loop, trigger, speed, autoplay, scroll.",
477
+ additionalProperties: true
478
+ },
479
+ markers: {
480
+ type: "object",
481
+ description: "Markers to add / move ({ \"reveal\": 1.2 }); null removes one.",
482
+ additionalProperties: true
483
+ },
484
+ segments: {
485
+ type: "object",
486
+ description: "Segments to add / change ({ \"hover-in\": { \"from\": 0, \"to\": 0.6 } }); null removes one.",
487
+ additionalProperties: true
488
+ },
489
+ dryRun: dryRunProp
490
+ }
491
+ },
492
+ mutating: true,
493
+ async handler(ctx, input) {
494
+ const dryRun = bool(input, "dryRun");
495
+ if ("timeline" in input && input.timeline !== void 0) return mutationResult(await setTimeline(ctx.fs, input.timeline, { dryRun }), dryRun);
496
+ if (!input.addTracks && !input.removeTargets && !input.settings && !input.markers && !input.segments) throw new OpsError("invalid", "timeline_set needs `timeline`, `addTracks`, `removeTargets`, `settings`, `markers` or `segments`.");
497
+ return mutationResult(await editTimeline(ctx.fs, {
498
+ addTracks: input.addTracks,
499
+ removeTargets: input.removeTargets,
500
+ settings: input.settings,
501
+ markers: input.markers,
502
+ segments: input.segments
503
+ }, { dryRun }), dryRun);
504
+ }
505
+ },
506
+ {
507
+ name: "interactions_set",
508
+ description: "Edit scene.interactions — no-code triggers. Replace the list with `interactions` (null or [] removes them) or append with `add`. An interaction: { \"on\": \"click\" | \"hover\" | \"hoverEnd\" | \"visible\" | \"scroll\" | \"key\" | \"event\", \"target\"?: \"<objectId>\" (click/hover/hoverEnd; omitted = whole canvas), \"key\"?: \"Space\" (on key), \"event\"?: \"<marker or emitted name>\" (on event), \"at\"?: 0.5 (on scroll: progress crossed downward), \"once\"?: true, \"do\": [actions] }. Actions: { \"play\": \"<segment>\" | \"timeline\", \"reverse\"?: true }, { \"toggle\": \"<segment>\" } (forward, then backward), { \"seek\": seconds | \"<marker>\" }, { \"set\": { \"path\": \"<id>.<property>\", \"value\": … }, \"duration\"?: 0.4, \"ease\"?: \"outCubic\" } (tweened from the current value), { \"emit\": \"<event>\", \"payload\"? }, { \"openUrl\": \"https://…\" | \"/path\", \"newTab\"? } (click / key only — the only way a scene navigates), { \"playClip\": \"Wave\", \"target\": \"<modelId>\", \"loop\"?, \"speed\"?, \"crossfade\"? }. Hover / click targets get a pointer cursor. Check hover / click states with render_preview `input` (pointer / click events).",
509
+ inputSchema: {
510
+ type: "object",
511
+ properties: {
512
+ interactions: {
513
+ type: ["array", "null"],
514
+ items: {
515
+ type: "object",
516
+ additionalProperties: true
517
+ },
518
+ description: "Full replacement (null or [] removes them)."
519
+ },
520
+ add: {
521
+ type: "array",
522
+ items: {
523
+ type: "object",
524
+ additionalProperties: true
525
+ },
526
+ description: "Interactions to append."
527
+ },
528
+ dryRun: dryRunProp
529
+ }
530
+ },
531
+ mutating: true,
532
+ async handler(ctx, input) {
533
+ const dryRun = bool(input, "dryRun");
534
+ if (input.interactions === void 0 && !input.add) throw new OpsError("invalid", "interactions_set needs `interactions` or `add`.");
535
+ return mutationResult(await setInteractions(ctx.fs, {
536
+ interactions: input.interactions,
537
+ add: input.add
538
+ }, { dryRun }), dryRun);
539
+ }
540
+ },
541
+ {
542
+ name: "catalog_get",
543
+ description: "Look up what scenes can reference: geometries, materialPresets, shaders, behaviours, generators, particlePresets, postfx, fonts, sounds. No input → every section with ids and one-line descriptions. { section } → entries with param names. { section, id } → the full entry (param types, defaults, min/max, enum options, triangle cost). Always check here before using an id or a param — validation rejects unknown ids.",
544
+ inputSchema: {
545
+ type: "object",
546
+ properties: {
547
+ section: {
548
+ type: "string",
549
+ enum: SECTION_NAMES,
550
+ description: "Catalog section."
551
+ },
552
+ id: {
553
+ type: "string",
554
+ description: "Entry id within the section."
555
+ }
556
+ }
557
+ },
558
+ mutating: false,
559
+ handler(_ctx, input) {
560
+ return catalogCompact(optStr(input, "section"), optStr(input, "id"));
561
+ }
562
+ },
563
+ {
564
+ name: "templates_list",
565
+ description: "List starter templates (id, title, description, kind, aspect, tags) to start a project from with project_create { template }. Filter by kind (banner, hero, card, square, fullscreen, inline, game) or words.",
566
+ inputSchema: {
567
+ type: "object",
568
+ properties: {
569
+ kind: {
570
+ type: "string",
571
+ enum: TARGET_KINDS
572
+ },
573
+ query: {
574
+ type: "string",
575
+ description: "Words to match in title / description / tags."
576
+ }
577
+ }
578
+ },
579
+ mutating: false,
580
+ handler(ctx, input) {
581
+ const index = ctx.host?.templates?.index ?? [];
582
+ const list = listTemplates(index, {
583
+ kind: optStr(input, "kind"),
584
+ query: optStr(input, "query")
585
+ });
586
+ return {
587
+ count: list.length,
588
+ templates: list,
589
+ ...index.length ? {} : { hint: "No templates available in this host; project_create without a template makes a good-looking starter scene for the target kind." }
590
+ };
591
+ }
592
+ },
593
+ {
594
+ name: "project_create",
595
+ description: "Create a new project in the current folder: agent3d.json, scene.json, assets/manifest.json (+ scripts for games). Without a template you get an attractive starter for the target kind (banner: gradient background, studio lighting, floating 3D title; hero: blob + title; card: product on a pedestal; square: holographic gem; fullscreen: island landscape; game: coin collector with a script). Then edit it with scene_patch and verify with render_preview. Default aspects: banner 4:1, hero 16:9, card 4:5, square 1:1.",
596
+ inputSchema: {
597
+ type: "object",
598
+ properties: {
599
+ name: {
600
+ type: "string",
601
+ description: "Project slug, e.g. \"spring-sale-banner\"."
602
+ },
603
+ title: {
604
+ type: "string",
605
+ description: "Human title (also the starter's 3D text)."
606
+ },
607
+ template: {
608
+ type: "string",
609
+ description: "Template id from templates_list."
610
+ },
611
+ kind: {
612
+ type: "string",
613
+ enum: TARGET_KINDS,
614
+ description: "Target kind (default banner)."
615
+ },
616
+ aspect: {
617
+ type: "string",
618
+ description: "\"W:H\", e.g. \"4:1\", \"16:9\", \"1:1\"."
619
+ },
620
+ force: {
621
+ type: "boolean",
622
+ description: "Overwrite an existing project in this folder."
623
+ }
624
+ },
625
+ required: ["name"]
626
+ },
627
+ mutating: true,
628
+ async handler(ctx, input) {
629
+ const template = optStr(input, "template");
630
+ let templateFiles;
631
+ if (template) {
632
+ if (!ctx.host?.templates) throw new OpsError("invalid", "Templates are not available in this host.", "Create the project without a template (a starter scene is generated for the target kind).");
633
+ findTemplate(ctx.host.templates.index, template);
634
+ templateFiles = await ctx.host.templates.files(template);
635
+ }
636
+ const kind = optStr(input, "kind");
637
+ const aspect = optStr(input, "aspect");
638
+ const target = kind || aspect ? {
639
+ ...kind ? { kind } : {},
640
+ ...aspect ? { aspect } : kind ? { aspect: DEFAULT_ASPECT[kind] } : {}
641
+ } : void 0;
642
+ const r = await createProject(ctx.fs, {
643
+ name: str(input, "name"),
644
+ title: optStr(input, "title"),
645
+ template,
646
+ templateFiles,
647
+ target,
648
+ force: bool(input, "force")
649
+ });
650
+ return {
651
+ manifest: r.manifest,
652
+ files: r.files,
653
+ summary: summarizeScene(r.scene),
654
+ ...compactIssues(r.issues),
655
+ hint: "Next: render_preview to see it, then scene_patch to make it yours."
656
+ };
657
+ }
658
+ },
659
+ {
660
+ name: "check",
661
+ description: "Pre-publish check: validation, missing asset / script files, script sandbox lint (no fetch, DOM, eval, storage… — scripts only get `api`), triangle + bundle-size budget for the target kind, licences that need attribution, accessibility (ariaLabel, reduced motion). With render data from render_preview it also reports framing (objects out of view, clipped, camera inside an object, scene too small) and runtime performance (draw calls, triangles). Every issue has a hint saying what to change.",
662
+ inputSchema: {
663
+ type: "object",
664
+ properties: { useLastRender: {
665
+ type: "boolean",
666
+ description: "Include stats/inspect from the last render_preview of this session (default true)."
667
+ } }
668
+ },
669
+ mutating: false,
670
+ async handler(ctx, input) {
671
+ const last = bool(input, "useLastRender", true) ? lastRender.get(ctx.fs) : void 0;
672
+ const report = await checkProject(ctx.fs, {
673
+ library: ctx.host?.library?.index,
674
+ runtimeStats: last?.stats,
675
+ inspect: last?.inspect
676
+ });
677
+ return {
678
+ ok: report.ok,
679
+ counts: report.counts,
680
+ budget: report.budget,
681
+ licences: report.licences,
682
+ ...compactIssues(report.issues, 50)
683
+ };
684
+ }
685
+ }
686
+ ];
687
+ var lastRender = /* @__PURE__ */ new WeakMap();
688
+ // src/ai/assetTools.ts
689
+ var KINDS = [
690
+ "model",
691
+ "texture",
692
+ "hdri",
693
+ "audio",
694
+ "font",
695
+ "svg",
696
+ "other"
697
+ ];
698
+ var ASSET_TOOLS = [
699
+ {
700
+ name: "assets_list",
701
+ description: "List the project's assets (assets/manifest.json + unregistered files): path, kind, size on disk, source, licence, author, and which scene paths use each one (read-only; `stale` lists entries whose manifest size differs from the file — assets_optimize / assets_add rewrite it).",
702
+ inputSchema: {
703
+ type: "object",
704
+ properties: {}
705
+ },
706
+ mutating: false,
707
+ async handler(ctx) {
708
+ const r = await listAssets(ctx.fs);
709
+ return {
710
+ count: r.assets.length,
711
+ totalKb: r.totalKb,
712
+ ...r.stale ? { stale: r.stale } : {},
713
+ assets: r.assets.map((a) => ({
714
+ path: a.path,
715
+ kind: a.kind,
716
+ kb: Math.round(a.bytes / 102.4) / 10,
717
+ source: a.source,
718
+ license: a.license,
719
+ ...a.author ? { author: a.author } : {},
720
+ ...a.exists ? {} : { missing: true },
721
+ usedBy: a.usedBy
722
+ }))
723
+ };
724
+ }
725
+ },
726
+ {
727
+ name: "library_list",
728
+ description: "Search the built-in asset library (shipped with Agent3D, works offline): models, textures, HDRIs. Use an asset directly in the scene as \"library:<id>\" (e.g. model src \"library:models/nature/pine-tree.glb\") — no download, the export copies it. Returns { assets: [{ id, ref, kind, license, tags, description, kb, triangles?, animations?, size? (w × h × d, Y-up) }], total, offset, more } (the list is `assets`, not `hits` as in assets_search). Models list their animation clip names (`animations`, play one with the model object animation { clip }) and triangles. 50 results per page: when `more` is true, call again with `offset`, or `limit: 0` for all. Prefer catalog generators / geometries (zero bytes) and the library before downloading assets.",
729
+ inputSchema: {
730
+ type: "object",
731
+ properties: {
732
+ query: {
733
+ type: "string",
734
+ description: "Words, e.g. \"tree\", \"rock moss\"."
735
+ },
736
+ kind: {
737
+ type: "string",
738
+ enum: KINDS
739
+ },
740
+ limit: {
741
+ type: "integer",
742
+ minimum: 0,
743
+ maximum: 500,
744
+ description: "Results per page (default 50; 0 = all)."
745
+ },
746
+ offset: {
747
+ type: "integer",
748
+ minimum: 0,
749
+ description: "Skip the first N results (when the previous page returned more: true)."
750
+ }
751
+ }
752
+ },
753
+ mutating: false,
754
+ handler(ctx, input) {
755
+ const index = ctx.host?.library?.index;
756
+ if (!index) return {
757
+ total: 0,
758
+ assets: [],
759
+ hint: "The built-in library is not available in this host."
760
+ };
761
+ return listLibrary(index, {
762
+ query: optStr(input, "query"),
763
+ kind: optStr(input, "kind"),
764
+ limit: num(input, "limit"),
765
+ offset: num(input, "offset")
766
+ });
767
+ }
768
+ },
769
+ {
770
+ name: "assets_search",
771
+ description: `Search free, account-less sources for CC0 / CC-BY assets: polyhaven (HDRIs, PBR textures, models), ambientcg (PBR materials, HDRIs), khronos (glTF sample models; CC0 / CC-BY only), kenney and quaternius (curated CC0 3D packs — no direct download: the user downloads the zip and assets_add imports it with { file }). Returns hits { source, id, title, kind, license, author, previewUrl, downloads }. Pass a hit to assets_add to download it into the project. Needs network.`,
772
+ inputSchema: {
773
+ type: "object",
774
+ properties: {
775
+ query: {
776
+ type: "string",
777
+ description: "Words, e.g. \"sunset sky\", \"wood planks\", \"fox\"."
778
+ },
779
+ kind: {
780
+ type: "string",
781
+ enum: KINDS
782
+ },
783
+ source: {
784
+ type: "string",
785
+ enum: SOURCE_IDS
786
+ },
787
+ limit: {
788
+ type: "integer",
789
+ minimum: 1,
790
+ maximum: 50
791
+ }
792
+ },
793
+ required: ["query"]
794
+ },
795
+ mutating: false,
796
+ async handler(ctx, input) {
797
+ if (!ctx.fetch) throw new OpsError("io", "Network access is not available to this tool host.", "Use library_list (offline) or catalog generators instead.");
798
+ const r = await searchAssetsDetailed({
799
+ query: str(input, "query"),
800
+ kind: optStr(input, "kind"),
801
+ source: optStr(input, "source"),
802
+ limit: num(input, "limit") ?? 8
803
+ }, ctx.fetch);
804
+ return {
805
+ count: r.hits.length,
806
+ hits: r.hits,
807
+ ...r.errors.length ? { sourceErrors: r.errors } : {},
808
+ hint: "Download with assets_add { \"hit\": <hit>, \"resolution\": \"1k\" } (pass the hit object as returned; resolutions are the keys of `downloads`). 1k is plenty for web embeds; \"512\" downloads 1k and downscales it. Models come back with `bounds` (size + up-axis guess)."
809
+ };
810
+ }
811
+ },
812
+ {
813
+ name: "assets_add",
814
+ description: "Add an asset to the project (written under assets/, licence recorded in assets/manifest.json). Either { \"hit\": <an assets_search hit>, \"resolution\": \"1k\", \"name\"?: \"wood\" } to download it, or { \"file\": \"/path/on/disk/pack.zip\" | \"/path/model.glb\", \"source\": \"kenney\", \"license\": \"CC0-1.0\", \"author\"?, \"filter\"?: [\"tree\"] } to import a local file / pack zip (extracts .glb/.gltf + textures). Returns the project path(s) to use in the scene, plus a ready-made `suggestion` (e.g. a material using a texture set).",
815
+ inputSchema: {
816
+ type: "object",
817
+ properties: {
818
+ hit: {
819
+ type: "object",
820
+ description: "A hit from assets_search (source, id, kind, license, downloads…).",
821
+ additionalProperties: true
822
+ },
823
+ resolution: {
824
+ type: "string",
825
+ description: "Download key, e.g. \"1k\", \"2k\", \"1K-JPG\", \"glb\" (default 1k). Below the source minimum (\"512\", \"256\"): downloads 1k, then downscales (needs a host with headless Chrome)."
826
+ },
827
+ maxSize: {
828
+ type: "integer",
829
+ minimum: 16,
830
+ maximum: 8192,
831
+ description: "Downscale the downloaded textures (also inside .glb) to this longest side in pixels."
832
+ },
833
+ name: {
834
+ type: "string",
835
+ description: "File / folder name in the project (default: the asset id)."
836
+ },
837
+ file: {
838
+ type: "string",
839
+ description: "Local file to import (needs a CLI/MCP host)."
840
+ },
841
+ source: {
842
+ type: "string",
843
+ description: "Where the local file comes from: \"kenney\", \"quaternius\", \"local\", a URL…"
844
+ },
845
+ license: {
846
+ type: "string",
847
+ description: "\"CC0-1.0\", \"CC-BY-4.0\", …"
848
+ },
849
+ author: { type: "string" },
850
+ filter: {
851
+ type: "array",
852
+ items: { type: "string" },
853
+ description: "Zip import: only models whose path contains one of these words."
854
+ }
855
+ }
856
+ },
857
+ mutating: true,
858
+ async handler(ctx, input) {
859
+ if (input.hit) {
860
+ if (!ctx.fetch) throw new OpsError("io", "Network access is not available to this tool host.");
861
+ const hit = input.hit;
862
+ const resolution = optStr(input, "resolution");
863
+ const maxSize = num(input, "maxSize") ?? parseResolution(resolution).maxSize;
864
+ const dl = (codec) => downloadAsset(ctx.fs, hit, ctx.fetch, {
865
+ resolution,
866
+ maxSize,
867
+ codec,
868
+ name: optStr(input, "name"),
869
+ inflate: ctx.host?.inflate
870
+ });
871
+ const r = maxSize && ctx.host?.withImageCodec ? await ctx.host.withImageCodec((codec) => dl(codec)) : await dl();
872
+ return {
873
+ path: r.path,
874
+ files: r.files,
875
+ kind: r.kind,
876
+ license: r.license,
877
+ kb: Math.round(r.bytes / 102.4) / 10,
878
+ ...r.bounds ? { bounds: r.bounds } : {},
879
+ ...r.optimized ? { optimized: {
880
+ maxSize: r.optimized.maxSize,
881
+ savedKb: r.optimized.savedKb,
882
+ afterKb: r.optimized.afterKb
883
+ } } : {},
884
+ ...r.note ? { note: r.note } : {},
885
+ ...r.attribution ? { attribution: r.attribution } : {},
886
+ ...r.suggestion ? { suggestion: r.suggestion } : {},
887
+ hint: r.kind === "model" ? `Use it: object_add { "object": { "id": "…", "kind": "model", "src": "${r.path}", "fit": 2 } }.` : "Reference the path(s) in the scene (see suggestion)."
888
+ };
889
+ }
890
+ const file = optStr(input, "file");
891
+ if (!file) throw new OpsError("invalid", "assets_add needs \"hit\" (from assets_search) or \"file\" (a local file to import).");
892
+ if (!ctx.host?.readLocalFile) throw new OpsError("invalid", "This host cannot read local files.", "Use the CLI: agent3d assets add <file> --license CC0-1.0.");
893
+ const license = str(input, "license");
894
+ const source = optStr(input, "source") ?? "local";
895
+ const bytes = await ctx.host.readLocalFile(file);
896
+ const base = file.split(/[\\/]/).pop() ?? "asset";
897
+ if (bytes[0] === 80 && bytes[1] === 75) {
898
+ const r = await importAssetZip(ctx.fs, bytes, {
899
+ name: optStr(input, "name") ?? base.replace(/\.zip$/i, ""),
900
+ source,
901
+ license,
902
+ author: optStr(input, "author"),
903
+ filter: Array.isArray(input.filter) ? input.filter : void 0,
904
+ inflate: ctx.host?.inflate
905
+ });
906
+ return {
907
+ imported: r.assets.length,
908
+ models: r.models.slice(0, 60),
909
+ ...r.models.length > 60 ? { moreModels: r.models.length - 60 } : {},
910
+ skipped: r.skipped,
911
+ hint: "Use a model: object_add { \"object\": { \"id\": \"…\", \"kind\": \"model\", \"src\": \"<one of models>\", \"fit\": 2 } }."
912
+ };
913
+ }
914
+ const entry = await addAsset(ctx.fs, {
915
+ path: optStr(input, "name") ?? base,
916
+ bytes,
917
+ source,
918
+ license,
919
+ author: optStr(input, "author")
920
+ });
921
+ const bounds = entry.kind === "model" ? await modelFileBounds(ctx.fs, entry.path) : null;
922
+ return {
923
+ path: entry.path,
924
+ kind: entry.kind,
925
+ license: entry.license,
926
+ ...bounds ? { bounds } : {}
927
+ };
928
+ }
929
+ },
930
+ {
931
+ name: "assets_optimize",
932
+ description: "Make project textures and .glb models lighter (run it when `check` reports the KB budget is exceeded, or before export). Textures (.jpg / .png / .webp files and images inside .glb) get the size the scene needs — a smart per-texture size from the target kind, the object's size on screen, the camera distance and the role (colour / normal / roughness, background) unless `maxSize` forces one — and are re-encoded as WebP by default (`format`; standalone files are renamed and scene references rewritten; models use EXT_texture_webp). .glb geometry is welded, reordered and meshopt-compressed (`compress`, default true; the runtime decodes it), optionally simplified (`simplify` ratio). A file only changes when it gets smaller; each file reports the size chosen and why. Lossy: call with `dryRun: true` first to show the user the savings, then without it once they agree. Pass `paths` (files or folders) or `all: true`. Textures need a host with headless Chrome (CLI / MCP); geometry does not.",
933
+ inputSchema: {
934
+ type: "object",
935
+ properties: {
936
+ paths: {
937
+ type: "array",
938
+ items: { type: "string" },
939
+ description: "Project paths, e.g. [\"assets/textures/wood/wood_diff_1k.jpg\", \"assets/models/fox.glb\"] (folders: every image / .glb inside)."
940
+ },
941
+ all: {
942
+ type: "boolean",
943
+ description: "Every texture and .glb under assets/."
944
+ },
945
+ maxSize: {
946
+ type: "integer",
947
+ minimum: 16,
948
+ maximum: 8192,
949
+ description: "Force this longest side in pixels for every texture (default: smart size per texture from the scene; never upscales)."
950
+ },
951
+ quality: {
952
+ type: "integer",
953
+ minimum: 1,
954
+ maximum: 100,
955
+ description: "WebP / JPEG quality (default 80; normal maps use at least 90)."
956
+ },
957
+ format: {
958
+ type: "string",
959
+ enum: [
960
+ "auto",
961
+ "webp",
962
+ "jpeg",
963
+ "png",
964
+ "keep"
965
+ ],
966
+ description: "Texture output format (default auto = WebP; jpeg keeps images with alpha in their format)."
967
+ },
968
+ compress: {
969
+ type: "boolean",
970
+ description: "Meshopt-compress .glb geometry (default true)."
971
+ },
972
+ simplify: {
973
+ type: "number",
974
+ minimum: .01,
975
+ maximum: 1,
976
+ description: "Keep this fraction of each .glb mesh's triangles (e.g. 0.5), within simplifyError."
977
+ },
978
+ simplifyError: {
979
+ type: "number",
980
+ minimum: 1e-4,
981
+ maximum: 1,
982
+ description: "Max deviation for simplify, as a fraction of the mesh size (default 0.01)."
983
+ },
984
+ dryRun: {
985
+ type: "boolean",
986
+ description: "Encode everything and report the savings, write nothing."
987
+ }
988
+ }
989
+ },
990
+ mutating: true,
991
+ async handler(ctx, input) {
992
+ const raw = Array.isArray(input.paths) ? input.paths : [];
993
+ const paths = [];
994
+ for (const p of raw) {
995
+ const clean = p.replace(/^\.\//, "").replace(/\/+$/, "");
996
+ if (await ctx.fs.exists(clean)) paths.push(clean);
997
+ else {
998
+ const inside = (await ctx.fs.list(`${clean}/`)).filter((f) => /\.(png|jpe?g|webp|glb)$/i.test(f));
999
+ paths.push(...inside.length ? inside : [clean]);
1000
+ }
1001
+ }
1002
+ const opts = {
1003
+ paths,
1004
+ all: input.all === true,
1005
+ maxSize: num(input, "maxSize"),
1006
+ quality: num(input, "quality"),
1007
+ format: optStr(input, "format"),
1008
+ compress: input.compress !== false,
1009
+ simplify: num(input, "simplify"),
1010
+ simplifyError: num(input, "simplifyError"),
1011
+ dryRun: input.dryRun === true,
1012
+ library: ctx.host?.library?.index
1013
+ };
1014
+ const r = ctx.host?.withImageCodec ? await ctx.host.withImageCodec((codec) => optimizeAssets(ctx.fs, opts, codec)) : await optimizeAssets(ctx.fs, opts);
1015
+ return {
1016
+ ...r,
1017
+ hint: r.dryRun ? "Nothing written: show the user the savings, then call again without dryRun." : `Run check again to see the new budget.${ctx.host?.withImageCodec ? "" : " Textures were skipped (this host has no headless Chrome): use the CLI `agent3d assets optimize` for them."}`
1018
+ };
1019
+ }
1020
+ },
1021
+ {
1022
+ name: "export",
1023
+ description: "Build the self-contained embed and write it into the project (default dist/<format>/). \"embed\": a folder for any static site — agent3d-runtime/ (shared), <name>/scene.json + assets + scripts, index.html (demo page), snippet.html (paste into the page), EMBED.md and frameworks/ (React / Vue / Svelte wrappers). \"zip\": the same folder as one <name>-embed.zip. \"single-html\": one <name>.html with everything inline. Library assets are copied; nothing is hotlinked. Options: `baseUrl` (where the folder is served, so the snippet works from any page), `cacheBust` (versioned runtime folder + ?v= hash for long-term caching), `integrity` (SRI hash on the runtime script, default true), `optimize` (export lighter copies of the assets — the project is not modified), `og` (render a 1200×630 og-image.png social preview). Run check first; returns the snippet, sizes and budget warnings. When the host can render (CLI / MCP / Studio with Chrome): \"poster\" writes a still image (dist/poster.webp; `time`, `image`), \"video\" an MP4 / WebM (dist/video.webm; `codec`, `duration`, `fps`, `size`), \"gif\" / \"animated-webp\" an animated image (dist/animation.gif / .webp), returning { path } — `quality` supersamples, `transparent` keeps the alpha (poster, gif, animated-webp).",
1024
+ inputSchema: {
1025
+ type: "object",
1026
+ properties: {
1027
+ format: {
1028
+ type: "string",
1029
+ enum: [
1030
+ "embed",
1031
+ "zip",
1032
+ "single-html",
1033
+ "poster",
1034
+ "video",
1035
+ "gif",
1036
+ "animated-webp"
1037
+ ],
1038
+ description: "Default embed. poster / video / gif / animated-webp need a host that can render (Chrome)."
1039
+ },
1040
+ name: {
1041
+ type: "string",
1042
+ description: "Folder / file name of the scene in the export (default: project name)."
1043
+ },
1044
+ outDir: {
1045
+ type: "string",
1046
+ description: "embed / zip / single-html: project-relative output folder (default \"dist/<format>\")."
1047
+ },
1048
+ poster: {
1049
+ type: "string",
1050
+ description: "Project path of a PNG/WebP still to use as poster (e.g. a frame from renders/)."
1051
+ },
1052
+ baseUrl: {
1053
+ type: "string",
1054
+ description: "embed / zip: URL of the export folder as seen from the pages (default \"./\"), e.g. \"/static/3d/\" or \"https://cdn.example.com/3d/\"."
1055
+ },
1056
+ cacheBust: {
1057
+ type: "boolean",
1058
+ description: "embed / zip: versioned runtime folder (agent3d-runtime-<hash>/) and ?v=<hash> on the scene URL, for year-long caching (default false)."
1059
+ },
1060
+ integrity: {
1061
+ type: "boolean",
1062
+ description: "embed / zip: Subresource Integrity (sha384) on the runtime <script> (default true)."
1063
+ },
1064
+ extras: {
1065
+ type: "boolean",
1066
+ description: "embed / zip: EMBED.md and framework wrappers (default true)."
1067
+ },
1068
+ optimize: {
1069
+ type: "boolean",
1070
+ description: "embed / zip / single-html: export optimised copies of the assets — textures at the size the scene needs, .glb geometry meshopt-compressed (textures need a host with headless Chrome). The project is not modified (default false)."
1071
+ },
1072
+ og: {
1073
+ type: "boolean",
1074
+ description: "embed / zip: render a 1200×630 og-image.png social preview (needs a host that can render; default false)."
1075
+ },
1076
+ out: {
1077
+ type: "string",
1078
+ description: "poster / video / gif / animated-webp: project-relative output file under dist/ or renders/ (default \"dist/poster.webp\", \"dist/video.webm\" (.mp4 with codec mp4), \"dist/animation.gif\", \"dist/animation.webp\")."
1079
+ },
1080
+ time: {
1081
+ type: "number",
1082
+ minimum: 0,
1083
+ description: "poster: time in seconds (default target.posterTime)."
1084
+ },
1085
+ image: {
1086
+ type: "string",
1087
+ enum: ["webp", "png"],
1088
+ description: "poster: image format (default webp)."
1089
+ },
1090
+ codec: {
1091
+ type: "string",
1092
+ enum: ["webm", "mp4"],
1093
+ description: "video: WebM VP9 (default) or MP4 H.264 (needs Google Chrome); an .mp4 `out` implies mp4."
1094
+ },
1095
+ duration: {
1096
+ type: "number",
1097
+ minimum: .1,
1098
+ maximum: 120,
1099
+ description: "video / gif / animated-webp: seconds (default the timeline duration, else 5)."
1100
+ },
1101
+ fps: {
1102
+ type: "integer",
1103
+ minimum: 1,
1104
+ maximum: 60,
1105
+ description: "video / gif / animated-webp: frames per second (default 30 / 15 / 20)."
1106
+ },
1107
+ size: {
1108
+ type: "string",
1109
+ description: "poster / video / gif / animated-webp: pixel size \"WxH\" (default from the target aspect)."
1110
+ },
1111
+ quality: {
1112
+ type: "string",
1113
+ enum: [
1114
+ "draft",
1115
+ "standard",
1116
+ "high",
1117
+ "ultra"
1118
+ ],
1119
+ description: "poster / video / gif / animated-webp: supersampling — draft / standard (1×, default), high (2×), ultra (3×)."
1120
+ },
1121
+ transparent: {
1122
+ type: "boolean",
1123
+ description: "poster / gif / animated-webp: transparent background (alpha)."
1124
+ }
1125
+ }
1126
+ },
1127
+ mutating: true,
1128
+ async handler(ctx, input) {
1129
+ const requested = optStr(input, "format") ?? "embed";
1130
+ if (MEDIA_FORMATS.includes(requested)) return mediaExport(ctx, requested, input);
1131
+ const format = requested;
1132
+ if (format !== "embed" && format !== "single-html" && format !== "zip") throw new OpsError("invalid", `Unknown export format "${requested}".`, `Use ${[
1133
+ "embed",
1134
+ "zip",
1135
+ "single-html",
1136
+ ...MEDIA_FORMATS
1137
+ ].join(", ")}.`);
1138
+ if (!ctx.host?.runtimeFiles) throw new OpsError("invalid", "This host cannot provide the runtime files.", "Export with the CLI: agent3d export --format " + format);
1139
+ const quality = optStr(input, "quality");
1140
+ if (quality !== void 0 && !QUALITIES.includes(quality)) throw new OpsError("invalid", `Unknown quality "${quality}".`, `Use ${QUALITIES.join(", ")}.`);
1141
+ const outDir = (optStr(input, "outDir") ?? `dist/${format}`).replace(/^\.?\//, "");
1142
+ if (!outDir.startsWith("dist/") && outDir !== "dist") throw new OpsError("invalid", `outDir must be under dist/ (got "${outDir}").`, "Use e.g. \"dist/embed\".");
1143
+ const wantsOg = input.og === true && format !== "single-html";
1144
+ if (wantsOg && !ctx.host.media) throw new OpsError("invalid", "This host cannot render the og image.", "Export without og, or with the CLI: agent3d export (renders the poster and og-image.png with Chrome).");
1145
+ const runtime = { files: await ctx.host.runtimeFiles(format) };
1146
+ let library = ctx.host.library ?? {
1147
+ index: { assets: [] },
1148
+ read: async (id) => Promise.reject(new OpsError("notFound", `Library asset ${id} unavailable`))
1149
+ };
1150
+ const posterPath = optStr(input, "poster");
1151
+ const poster = posterPath ? await ctx.fs.readBytes(posterPath) : void 0;
1152
+ const ogImage = wantsOg ? (await ctx.host.media({ format: "og" })).bytes : void 0;
1153
+ const build = async (fs, lib) => buildExport(fs, {
1154
+ format,
1155
+ name: optStr(input, "name"),
1156
+ runtime,
1157
+ library: lib,
1158
+ poster,
1159
+ ogImage,
1160
+ baseUrl: optStr(input, "baseUrl"),
1161
+ cacheBust: input.cacheBust === true,
1162
+ integrity: input.integrity !== false,
1163
+ extras: input.extras !== false
1164
+ });
1165
+ let optimized;
1166
+ let r;
1167
+ if (input.optimize === true) {
1168
+ const run = async (codec) => {
1169
+ const o = await optimizedExportSources(ctx.fs, library, { codec });
1170
+ library = o.library;
1171
+ const res = await build(o.fs, o.library);
1172
+ optimized = o.report();
1173
+ return res;
1174
+ };
1175
+ r = ctx.host.withImageCodec ? await ctx.host.withImageCodec((codec) => run(codec)) : await run();
1176
+ } else r = await build(ctx.fs, library);
1177
+ for (const [path, content] of Object.entries(prefixFiles(r.files, outDir))) if (typeof content === "string") await ctx.fs.writeText(path, content);
1178
+ else await ctx.fs.writeBytes(path, content);
1179
+ return {
1180
+ format,
1181
+ outDir,
1182
+ entry: `${outDir}/${r.entry}`,
1183
+ files: Object.keys(r.files).length,
1184
+ pageKb: r.pageKb,
1185
+ ...r.pageKbGzip !== void 0 ? { pageKbGzip: r.pageKbGzip } : {},
1186
+ folderKb: r.folderKb,
1187
+ totalKb: r.totalKb,
1188
+ sizes: r.sizes,
1189
+ page: {
1190
+ runtimeKb: r.page.runtimeKb,
1191
+ skippedChunks: r.page.skippedChunks.length,
1192
+ ...r.page.pruned ? { pruned: true } : {}
1193
+ },
1194
+ snippet: format === "single-html" ? `(single file) ${outDir}/${r.entry}` : r.snippet,
1195
+ ...r.head ? { head: r.head } : {},
1196
+ ...r.runtimeDir ? { runtimeDir: r.runtimeDir } : {},
1197
+ ...ogImage ? { ogImage: true } : {},
1198
+ ...optimized ? { optimized } : {},
1199
+ credits: r.credits,
1200
+ ...compactIssues(r.issues),
1201
+ ...input.optimize === true && !ctx.host.withImageCodec ? { hint: "Textures were not resized (this host has no headless Chrome); geometry was compressed." } : {}
1202
+ };
1203
+ }
1204
+ }
1205
+ ];
1206
+ var MEDIA_FORMATS = [
1207
+ "poster",
1208
+ "video",
1209
+ "gif",
1210
+ "animated-webp"
1211
+ ];
1212
+ var QUALITIES = [
1213
+ "draft",
1214
+ "standard",
1215
+ "high",
1216
+ "ultra"
1217
+ ];
1218
+ async function mediaExport(ctx, requested, input) {
1219
+ if (!ctx.host?.media) throw new OpsError("invalid", `This host cannot render a ${requested}.`, `Export it with the CLI: agent3d export --format ${requested === "animated-webp" ? "gif" : requested} (needs Chrome / Chromium).`);
1220
+ const quality = optStr(input, "quality");
1221
+ if (quality !== void 0 && !QUALITIES.includes(quality)) throw new OpsError("invalid", `Unknown quality "${quality}".`, `Use ${QUALITIES.join(", ")}.`);
1222
+ const outIn = optStr(input, "out")?.replace(/^\.?\//, "");
1223
+ const image = optStr(input, "image") ?? (outIn?.endsWith(".png") ? "png" : "webp");
1224
+ const codec = optStr(input, "codec") ?? (outIn?.toLowerCase().endsWith(".mp4") ? "mp4" : "webm");
1225
+ if (codec !== "webm" && codec !== "mp4") throw new OpsError("invalid", `Unknown codec "${codec}".`, "Use webm or mp4.");
1226
+ const def = requested === "poster" ? `dist/poster.${image}` : requested === "video" ? `dist/video.${codec}` : requested === "gif" ? "dist/animation.gif" : "dist/animation.webp";
1227
+ const out = outIn ?? def;
1228
+ if (!out.startsWith("dist/") && !out.startsWith("renders/")) throw new OpsError("invalid", `out must be under dist/ or renders/ (got "${out}").`, `Use e.g. "${def}".`);
1229
+ const ext = out.split(".").pop()?.toLowerCase();
1230
+ const wantExt = requested === "poster" ? ["webp", "png"] : requested === "video" ? [codec] : requested === "gif" ? ["gif"] : ["webp"];
1231
+ if (!ext || !wantExt.includes(ext)) throw new OpsError("invalid", `out "${out}" does not match the ${requested} format (expected .${wantExt.join(" / .")}).`, `Use e.g. "${def}".`);
1232
+ const r = await ctx.host.media({
1233
+ format: requested === "animated-webp" ? "webp" : requested,
1234
+ image,
1235
+ time: num(input, "time"),
1236
+ duration: num(input, "duration"),
1237
+ fps: num(input, "fps"),
1238
+ size: optStr(input, "size"),
1239
+ ...requested === "video" ? { video: codec } : {},
1240
+ ...quality ? { quality } : {},
1241
+ ...input.transparent === true ? { transparent: true } : {}
1242
+ });
1243
+ await ctx.fs.writeBytes(out, r.bytes);
1244
+ return {
1245
+ format: requested,
1246
+ path: out,
1247
+ kb: Math.round(r.bytes.byteLength / 102.4) / 10,
1248
+ size: r.size,
1249
+ ...r.codec ? { codec: r.codec } : {},
1250
+ ...r.t !== void 0 ? { t: r.t } : {},
1251
+ ...r.frames !== void 0 ? {
1252
+ frames: r.frames,
1253
+ fps: r.fps,
1254
+ duration: r.duration
1255
+ } : {}
1256
+ };
1257
+ }
1258
+ var RENDER_TOOL = {
1259
+ name: "render_preview",
1260
+ description: "Render the scene headless (deterministic) and save PNG frames + a contact sheet into renders/. ALWAYS look at the returned image (sheet) after changes: check composition, framing (nothing cut at the edges of a wide banner), readability of text, colours and lighting, then fix with scene_patch and render again. Returns frame paths (relative to the project folder `dir`), render stats (triangles, draw calls), per-object inspect data (in view / clipped / screen coverage), the game `state` (api.state, e.g. the score), runtime issues and console errors. Games: `input` plays simulated keys / clicks / drags / swipes while seeking, to test them headlessly. check reuses this data for framing / performance issues.",
1261
+ inputSchema: {
1262
+ type: "object",
1263
+ properties: {
1264
+ frames: {
1265
+ type: "array",
1266
+ items: { type: "number" },
1267
+ description: "Times in seconds, e.g. [0, 1.5, 3]."
1268
+ },
1269
+ count: {
1270
+ type: "integer",
1271
+ minimum: 1,
1272
+ maximum: 16,
1273
+ description: "Or N evenly spaced frames over the timeline."
1274
+ },
1275
+ size: {
1276
+ type: "string",
1277
+ description: "Pixel size \"WxH\" (default 1200 wide at the target aspect)."
1278
+ },
1279
+ sheet: {
1280
+ type: "boolean",
1281
+ description: "Compose a contact sheet (default true)."
1282
+ },
1283
+ isolate: {
1284
+ type: "string",
1285
+ description: "Render only this object id, auto-framed from the front (+Z) three-quarter view on a neutral background — check a model's orientation / size after assets_add."
1286
+ },
1287
+ bg: {
1288
+ type: "string",
1289
+ description: "Background under the frames: \"checker\", a CSS colour or \"none\" (default: checkerboard under the sheet of transparent scenes)."
1290
+ },
1291
+ maxWidth: {
1292
+ type: "integer",
1293
+ minimum: 0,
1294
+ maximum: 4096,
1295
+ description: "Width in pixels of the image returned to the client (MCP image block): the sheet / first frame is scaled down to it to save context (default 800; 0 = full size). Full-size PNGs stay on disk (sheet, frames)."
1296
+ },
1297
+ input: {
1298
+ type: "array",
1299
+ description: "Games: simulated input applied while seeking (frames render in time order). Events: {\"t\": 0.5, \"key\": \"ArrowRight\", \"down\": true} (down false = release), {\"t\": 0.5, \"key\": \"Space\", \"hold\": 0.3}, {\"t\": 1, \"click\": [0, 0]}, {\"t\": 1, \"pointer\": [0.5, -0.2], \"down\"?: true|false}, {\"t\": 1, \"pointerDown\": [0, 0]}, {\"t\": 2, \"pointerUp\": [0.4, 0] | true}, {\"t\": 1, \"drag\": {\"from\": [-0.5, 0], \"to\": [0.5, 0], \"duration\": 0.4}}, {\"t\": 1, \"swipe\": \"left\"|\"right\"|\"up\"|\"down\"}, {\"t\": 1, \"scroll\": 0.5}, {\"t\": 3, \"emit\": \"retry\"} (emit an event, like a HUD button action), {\"t\": 3, \"ui\": \"<HUD button id>\"} (click that button), {\"t\": 0, \"segment\": \"<timeline segment>\"}. key = KeyboardEvent.code; coordinates are -1..1 (y up). Unknown fields are rejected.",
1300
+ items: {
1301
+ type: "object",
1302
+ additionalProperties: true
1303
+ }
1304
+ },
1305
+ scroll: {
1306
+ type: "number",
1307
+ minimum: 0,
1308
+ maximum: 1,
1309
+ description: "Scroll progress 0..1 for scroll-driven scenes (one frame unless frames / count are given); frames carry `scroll`."
1310
+ },
1311
+ reducedMotion: {
1312
+ type: "boolean",
1313
+ description: "Render as visitors with prefers-reduced-motion see the scene (static pose / poster time)."
1314
+ },
1315
+ segment: {
1316
+ type: "string",
1317
+ description: "Play this timeline segment (timeline.segments, or \"timeline\") from t = 0 — for scenes whose timeline waits for a click / interaction."
1318
+ }
1319
+ }
1320
+ },
1321
+ mutating: false,
1322
+ async handler(ctx, input) {
1323
+ if (!ctx.host?.render) throw new OpsError("invalid", "Rendering is not available in this host.", "Use the CLI (agent3d render) — it needs Chrome / Chromium installed.");
1324
+ const r = await ctx.host.render({
1325
+ frames: Array.isArray(input.frames) ? input.frames : void 0,
1326
+ count: num(input, "count"),
1327
+ size: optStr(input, "size"),
1328
+ sheet: typeof input.sheet === "boolean" ? input.sheet : true,
1329
+ previewWidth: num(input, "maxWidth") ?? 800,
1330
+ ...optStr(input, "isolate") ? { isolate: optStr(input, "isolate") } : {},
1331
+ ...optStr(input, "bg") ? { bg: optStr(input, "bg") } : {},
1332
+ ...Array.isArray(input.input) ? { input: input.input } : {},
1333
+ ...num(input, "scroll") !== void 0 ? { scroll: num(input, "scroll") } : {},
1334
+ ...input.reducedMotion === true ? { reducedMotion: true } : {},
1335
+ ...optStr(input, "segment") ? { segment: optStr(input, "segment") } : {}
1336
+ });
1337
+ lastRender.set(ctx.fs, {
1338
+ stats: r.stats,
1339
+ inspect: r.inspect
1340
+ });
1341
+ return {
1342
+ ...r.dir ? { dir: r.dir } : {},
1343
+ sheet: r.sheet,
1344
+ ...r.preview ? { preview: r.preview } : {},
1345
+ ...r.isolated ? { isolated: r.isolated } : {},
1346
+ frames: r.frames,
1347
+ ...r.state && Object.keys(r.state).length ? { state: r.state } : {},
1348
+ ...r.inputWarnings?.length ? { inputWarnings: r.inputWarnings } : {},
1349
+ stats: r.stats,
1350
+ ...r.inspect ? { inspect: {
1351
+ camera: r.inspect.camera,
1352
+ objects: r.inspect.objects.map((o) => ({
1353
+ id: o.id,
1354
+ inView: o.inView,
1355
+ coverage: Math.round(o.screenCoverage * 1e3) / 1e3
1356
+ }))
1357
+ } } : {},
1358
+ ...compactIssues(r.issues, 30),
1359
+ consoleErrors: r.consoleErrors.slice(0, 20),
1360
+ hint: r.sheet ? `Open ${r.sheet} and look at it before the next change.` : "Open the frame images and look at them before the next change."
1361
+ };
1362
+ }
1363
+ };
1364
+ // src/ai/tools.ts
1365
+ var ORDER = [
1366
+ "project_info",
1367
+ "scene_get",
1368
+ "scene_summary",
1369
+ "scene_apply",
1370
+ "scene_patch",
1371
+ "scene_validate",
1372
+ "object_add",
1373
+ "object_update",
1374
+ "object_remove",
1375
+ "object_list",
1376
+ "timeline_set",
1377
+ "interactions_set",
1378
+ "catalog_get",
1379
+ "templates_list",
1380
+ "project_create",
1381
+ "check",
1382
+ "assets_list",
1383
+ "assets_search",
1384
+ "assets_add",
1385
+ "assets_optimize",
1386
+ "library_list",
1387
+ "export"
1388
+ ];
1389
+ var BY_NAME = new Map([...SCENE_TOOLS, ...ASSET_TOOLS].map((t) => [t.name, t]));
1390
+ var AI_TOOLS = ORDER.map((n) => {
1391
+ const t = BY_NAME.get(n);
1392
+ if (!t) throw new Error(`AI tool ${n} is not implemented`);
1393
+ return t;
1394
+ });
1395
+ function listAiTools(host, opts = {}) {
1396
+ const list = host?.render ? [...AI_TOOLS, RENDER_TOOL] : [...AI_TOOLS];
1397
+ return opts.readOnly ? list.filter((t) => !t.mutating) : list;
1398
+ }
1399
+ function findAiTool(name, host) {
1400
+ const tools = listAiTools(host);
1401
+ const t = tools.find((x) => x.name === name);
1402
+ if (!t) {
1403
+ const s = closest(name, tools.map((x) => x.name));
1404
+ throw new OpsError("notFound", `Unknown tool "${name}".`, `${s ? `Did you mean "${s}"? ` : ""}Tools: ${tools.map((x) => x.name).join(", ")}.`);
1405
+ }
1406
+ return t;
1407
+ }
1408
+ async function callAiTool(ctx, name, input) {
1409
+ const tool = findAiTool(name, ctx.host);
1410
+ return tool.handler(ctx, checkInput(tool.inputSchema, input, name));
1411
+ }
1412
+ export { callAiTool, listAiTools };