@call-me-sensei/toonlab 0.3.0 → 0.4.19

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 (736) hide show
  1. package/README.md +549 -184
  2. package/agents/README.md +59 -0
  3. package/agents/references/anime-art-direction.md +24 -0
  4. package/agents/references/asset-sourcing-policy.md +23 -0
  5. package/agents/references/custom-gap-report.md +16 -0
  6. package/agents/references/geology-playbook.md +118 -0
  7. package/agents/references/mcp-asset-discovery.md +104 -0
  8. package/agents/references/runtime-entry-points.md +174 -0
  9. package/agents/references/style-bundles.md +71 -0
  10. package/agents/skills/claude/asset-sourcing/SKILL.md +275 -0
  11. package/agents/skills/claude/environment/SKILL.md +59 -0
  12. package/agents/skills/claude/game-dev/SKILL.md +100 -0
  13. package/agents/skills/claude/karst-cliff-construction/SKILL.md +258 -0
  14. package/agents/skills/claude/outdoor-world/SKILL.md +492 -0
  15. package/agents/skills/claude/outdoor-world/references/coastal-landform-formation.md +100 -0
  16. package/agents/skills/claude/post-processing/SKILL.md +44 -0
  17. package/agents/skills/claude/rock-ground-shaders/SKILL.md +118 -0
  18. package/agents/skills/claude/rockgen/SKILL.md +30 -0
  19. package/agents/skills/claude/scene-style-application/SKILL.md +74 -0
  20. package/agents/skills/claude/style-presets/SKILL.md +101 -0
  21. package/agents/skills/claude/toon-shading/SKILL.md +44 -0
  22. package/agents/skills/claude/vegetation-sky/SKILL.md +167 -0
  23. package/agents/skills/claude/visual-verification/SKILL.md +136 -0
  24. package/agents/skills/claude/water/SKILL.md +105 -0
  25. package/agents/skills/codex/asset-sourcing/SKILL.md +275 -0
  26. package/agents/skills/codex/environment/SKILL.md +59 -0
  27. package/agents/skills/codex/game-dev/SKILL.md +100 -0
  28. package/agents/skills/codex/karst-cliff-construction/SKILL.md +258 -0
  29. package/agents/skills/codex/outdoor-world/SKILL.md +492 -0
  30. package/agents/skills/codex/outdoor-world/references/coastal-landform-formation.md +100 -0
  31. package/agents/skills/codex/post-processing/SKILL.md +44 -0
  32. package/agents/skills/codex/rock-ground-shaders/SKILL.md +118 -0
  33. package/agents/skills/codex/rockgen/SKILL.md +30 -0
  34. package/agents/skills/codex/scene-style-application/SKILL.md +74 -0
  35. package/agents/skills/codex/style-presets/SKILL.md +101 -0
  36. package/agents/skills/codex/toon-shading/SKILL.md +44 -0
  37. package/agents/skills/codex/vegetation-sky/SKILL.md +167 -0
  38. package/agents/skills/codex/visual-verification/SKILL.md +136 -0
  39. package/agents/skills/codex/water/SKILL.md +105 -0
  40. package/cli/toonlab.mjs +52 -0
  41. package/compose.yaml +20 -0
  42. package/database/apply-sql.mjs +141 -0
  43. package/database/client.mjs +39 -0
  44. package/database/creation-tags.mjs +23 -0
  45. package/database/env.mjs +16 -0
  46. package/database/generation-service.mjs +314 -0
  47. package/database/migrations/0001_local_workspace.sql +120 -0
  48. package/database/migrations/0002_file_ownership.sql +11 -0
  49. package/database/migrations/0003_remove_autosaves_from_library.sql +7 -0
  50. package/database/migrations/0004_catalog_asset_packs.sql +39 -0
  51. package/database/migrations/0005_creation_tag_discovery.sql +1 -0
  52. package/database/migrations/0006_normalize_creation_tags.sql +28 -0
  53. package/database/providers.mjs +465 -0
  54. package/database/repository.mjs +625 -0
  55. package/database/seeds/catalog/0001_empty_official_catalog.sql +4 -0
  56. package/database/seeds/catalog/0002_2026-08.sql +19454 -0
  57. package/mcp/lab-management.mjs +629 -0
  58. package/mcp/public-catalog.mjs +168 -0
  59. package/mcp/server.mjs +1026 -63
  60. package/mcp/vite-plugin.mjs +443 -26
  61. package/mcp/workspace.mjs +26 -1
  62. package/package.json +312 -45
  63. package/scripts/generate-catalog-seed.mjs +297 -0
  64. package/scripts/setup-local.mjs +128 -0
  65. package/src/agents/index.js +7 -0
  66. package/src/agents/sceneStyleOperations.js +169 -0
  67. package/src/asset-policy/catalogLicenses.js +44 -0
  68. package/src/asset-policy/index.js +315 -0
  69. package/src/assetlib/assetRef.js +1 -1
  70. package/src/assetlib/galleryMaterialFamily.js +165 -0
  71. package/src/assetlib/index.js +6 -2
  72. package/src/assetlib/plateau.js +188 -0
  73. package/src/assetlib/plateauLandmarks.js +144 -0
  74. package/src/assetlib/plateauViewer.js +348 -0
  75. package/src/assetlib/sources.js +16 -2
  76. package/src/catalog/manifest.js +11 -1
  77. package/src/catalog/officialCatalog.js +4 -0
  78. package/src/catalog/officialCatalogAssetRuntime.js +313 -0
  79. package/src/catalog/officialCatalogLod.js +150 -0
  80. package/src/catalog/officialCatalogPlacement.js +228 -0
  81. package/src/catalog/officialCatalogProvider.js +334 -0
  82. package/src/character/animationRetarget.js +1082 -0
  83. package/src/character/characterRuntime.js +376 -0
  84. package/src/character/groundStabilizer.js +137 -0
  85. package/src/character/index.js +8 -0
  86. package/src/character/locomotionActions.js +74 -0
  87. package/src/character/locomotionStateMachine.js +241 -0
  88. package/src/character/mannequinAsset.js +15 -0
  89. package/src/character/mannequinAssetUrl.browser.js +4 -0
  90. package/src/character/mannequinAssetUrl.node.js +3 -0
  91. package/src/character/modelLoader.js +92 -12
  92. package/src/character/walkableCharacterRuntime.js +284 -0
  93. package/src/character/waterInteractionController.js +217 -0
  94. package/src/cloud/ambientSkyBaker.js +248 -0
  95. package/src/cloud/cloudLighting.js +1114 -0
  96. package/src/cloud/cloudParams.js +819 -0
  97. package/src/cloud/cloudReprojection.js +563 -0
  98. package/src/cloud/cloudStyle.js +780 -0
  99. package/src/cloud/cloudStyleSnapshots.js +387 -0
  100. package/src/cloud/cloudVolume.js +1903 -0
  101. package/src/cloud/heroCloudRecipe.js +404 -0
  102. package/src/cloud/index.js +42 -0
  103. package/src/cloud/noise/baseShapeVolume.js +331 -0
  104. package/src/cloud/noise/cirrusMap.js +131 -0
  105. package/src/cloud/noise/curlNoise.js +289 -0
  106. package/src/cloud/noise/erosionVolume.js +188 -0
  107. package/src/cloud/noise/noiseVolume.js +202 -0
  108. package/src/cloud/noise/periodicNoise3.js +295 -0
  109. package/src/cloud/noise/weatherMap.js +470 -0
  110. package/src/cloud/paramSchema.js +458 -0
  111. package/src/collisionMetadata.js +320 -0
  112. package/src/core/systemStylePolicy.js +32 -0
  113. package/src/environment/dayCurves.js +146 -0
  114. package/src/environment/environmentGroundFieldPass.js +354 -0
  115. package/src/environment/environmentMaterialAdapter.js +114 -6
  116. package/src/environment/environmentPresets.js +396 -90
  117. package/src/environment/environmentRigs.js +17 -2
  118. package/src/environment/environmentSettings.js +37 -1
  119. package/src/environment/environmentShaderMaterials.js +37 -6
  120. package/src/environment/environmentState.js +133 -0
  121. package/src/environment/environmentSunShadowPass.js +357 -6
  122. package/src/environment/environmentTextureResolver.js +7 -0
  123. package/src/environment/index.js +51 -0
  124. package/src/environment/manufacturedMaterialContract.js +837 -0
  125. package/src/environment/manufacturedReflectionProvider.js +114 -0
  126. package/src/environment/scanAssetStylize.js +4 -4
  127. package/src/environment/surfaceMaterialModes.js +71 -0
  128. package/src/environment/toonLabEnvironmentMaterials.js +353 -0
  129. package/src/environment/toonLabMaterialPassCoupling.js +347 -0
  130. package/src/environment/toonLabNormalIntegration.js +171 -0
  131. package/src/environment/toonLabRockMaterialResolver.js +592 -0
  132. package/src/environment/toonLabSourceDefaultLit.js +444 -0
  133. package/src/environment/toonLabSourceLibrary.js +762 -0
  134. package/src/environment/toonLabSourceMaterials.js +3718 -0
  135. package/src/environment/toonLabSourceSubsurfaceLighting.js +415 -0
  136. package/src/environment/toonLabSourceTemporal.js +717 -0
  137. package/src/environment/toonLabSurfaceLighting.js +364 -0
  138. package/src/environment/toonLabTextureReadiness.js +105 -0
  139. package/src/environment/toonLabTreeMaterials.js +450 -0
  140. package/src/environment/transparentMaterialProfile.js +87 -0
  141. package/src/environment/urbanPropMaterial.js +2874 -0
  142. package/src/ground-shader/groundPrintLayer.js +375 -0
  143. package/src/ground-shader/groundShaderMaterial.js +851 -0
  144. package/src/ground-shader/groundShaderSettings.js +468 -0
  145. package/src/ground-shader/index.js +3 -0
  146. package/src/index.js +52 -22
  147. package/src/lighting/callMeSenseiLightingContract.js +163 -0
  148. package/src/lighting/index.js +14 -7
  149. package/src/lighting/lightingCapabilities.js +2 -2
  150. package/src/lighting/lightingPresets.js +6 -3
  151. package/src/lighting/lightingStyle.js +41 -6
  152. package/src/lighting/lightingSystem.js +140 -1
  153. package/src/lighting/{unrealExport.js → toonLabExport.js} +40 -41
  154. package/src/post/postProcessing.js +71 -12
  155. package/src/react/index.js +66 -0
  156. package/src/renderer/index.js +9 -0
  157. package/src/renderer/rendererConfiguration.js +250 -0
  158. package/src/rock-shader/index.js +3 -0
  159. package/src/rock-shader/rockMaterial.js +1843 -0
  160. package/src/rock-shader/rockShaderRuntime.js +494 -0
  161. package/src/rock-shader/rockShaderSettings.js +869 -0
  162. package/src/rockgen/export/glbExport.js +104 -14
  163. package/src/rockgen/index.js +4 -3
  164. package/src/rockgen/lod/index.js +6 -0
  165. package/src/rockgen/lod/rockLodMetrics.js +168 -0
  166. package/src/rockgen/lod/rockLodPlanner.js +372 -0
  167. package/src/rockgen/lod/rockLodPolicy.js +235 -0
  168. package/src/rockgen/lod/rockLodRuntime.js +124 -0
  169. package/src/rockgen/lod/rockLodSimplifier.js +173 -0
  170. package/src/rockgen/lod/rockLodValidation.js +113 -0
  171. package/src/rockgen/mesh/meshAttributes.js +17 -0
  172. package/src/rockgen/mesh/meshDocument.js +6 -0
  173. package/src/rockgen/rockDocument.js +352 -9
  174. package/src/rockgen/rockgenPresets.js +114 -13
  175. package/src/rockgen/rockgenSettings.js +62 -11
  176. package/src/runtime/index.js +14 -0
  177. package/src/runtime/sceneCollisionRuntime.js +317 -0
  178. package/src/runtime/sceneSurfaceRuntime.js +451 -0
  179. package/src/runtime/sceneUpdateScheduler.js +203 -0
  180. package/src/shaders-tsl/anime.js +9 -2
  181. package/src/shaders-tsl/chunks/environment-ground-field.js +174 -0
  182. package/src/shaders-tsl/chunks/environment-state.js +79 -0
  183. package/src/shaders-tsl/chunks/environment-sun-shadow.js +99 -32
  184. package/src/shaders-tsl/chunks/normalized-hue.js +41 -0
  185. package/src/shaders-tsl/chunks/pass-depth-color.js +4 -2
  186. package/src/shaders-tsl/chunks/scene-depth-color-pass.js +273 -0
  187. package/src/shaders-tsl/chunks/vegetation-style.js +116 -8
  188. package/src/shaders-tsl/chunks/water-color.js +19 -5
  189. package/src/shaders-tsl/chunks/water-shore-state.js +8 -1
  190. package/src/shaders-tsl/chunks/world-noise.js +30 -0
  191. package/src/shaders-tsl/environment.js +123 -17
  192. package/src/shaders-tsl/flower.js +51 -8
  193. package/src/shaders-tsl/grass.js +194 -29
  194. package/src/shaders-tsl/post-composite.js +83 -2
  195. package/src/shaders-tsl/tree-leaf.js +107 -16
  196. package/src/shaders-tsl/water-breaker.js +18 -4
  197. package/src/shaders-tsl/water.js +43 -3
  198. package/src/shaders-tsl/woody-surface.js +59 -7
  199. package/src/sky/atmosphereDome.js +193 -0
  200. package/src/sky/atmosphereParams.js +396 -0
  201. package/src/sky/atmosphereScattering.js +593 -0
  202. package/src/sky/atmosphereSky.js +371 -0
  203. package/src/sky/cloudShadow.js +355 -0
  204. package/src/sky/godRays.js +257 -0
  205. package/src/sky/index.js +55 -1
  206. package/src/sky/nightSky.js +1190 -0
  207. package/src/sky/renderLayers.js +120 -0
  208. package/src/sky/skyColor.js +582 -0
  209. package/src/sky/skyDayCycle.js +244 -0
  210. package/src/sky/skyParams.js +661 -0
  211. package/src/sky/skyPresets.js +772 -0
  212. package/src/sky/skyQualityTiers.js +383 -0
  213. package/src/sky/skyShaderSettings.js +699 -0
  214. package/src/sky/skyStyleSnapshots.js +211 -0
  215. package/src/sky/skySystem.js +1438 -0
  216. package/src/sky/skyTimeKeyframes.js +361 -0
  217. package/src/sky/stylizedSky.js +405 -116
  218. package/src/sky/sunDriver.js +499 -0
  219. package/src/sky/timeOfDay.js +335 -0
  220. package/src/styles/animeGameProfile.js +44 -0
  221. package/src/styles/index.js +134 -0
  222. package/src/styles/manufacturedStyleLabeling.js +204 -0
  223. package/src/styles/sceneLayerDocuments.js +185 -0
  224. package/src/styles/sceneLookComposition.js +156 -0
  225. package/src/styles/sceneQualityApplication.js +152 -0
  226. package/src/styles/sceneQualityProfiles.js +268 -0
  227. package/src/styles/sceneStyleAudit.js +512 -0
  228. package/src/styles/sceneStyleRuntime.js +876 -0
  229. package/src/styles/styleAdapters.js +166 -0
  230. package/src/styles/styleApplication.js +369 -0
  231. package/src/styles/styleBundle.js +444 -91
  232. package/src/styles/styleBundleProvider.js +83 -0
  233. package/src/styles/styleDomains.js +21 -0
  234. package/src/styles/styleInspector.js +262 -0
  235. package/src/styles/styleMaterialContract.js +375 -0
  236. package/src/styles/styleMetadata.js +73 -0
  237. package/src/styles/styleTargetDiscovery.js +162 -0
  238. package/src/styles/styleTargetLabels.js +206 -0
  239. package/src/styles/styleTargetMaterialCoverage.js +137 -0
  240. package/src/styles/styleTransaction.js +272 -0
  241. package/src/texgen/textureGenerators.js +21 -5
  242. package/src/toon/toonSettings.js +4 -0
  243. package/src/vegetation/branchTree.js +302 -0
  244. package/src/vegetation/callMeSenseiGrass.js +183 -0
  245. package/src/vegetation/compiledTree.js +506 -0
  246. package/src/vegetation/contactShadowField.js +107 -0
  247. package/src/vegetation/flowerSpecies.js +10 -2
  248. package/src/vegetation/grass.js +13 -0
  249. package/src/vegetation/grassClump.js +1179 -0
  250. package/src/vegetation/importedVegetationMaterial.js +183 -0
  251. package/src/vegetation/index.js +15 -1
  252. package/src/vegetation/legacyTreePresets.js +120 -0
  253. package/src/vegetation/scatter.js +322 -3
  254. package/src/vegetation/stylizedBush.js +14 -0
  255. package/src/vegetation/stylizedFlower.js +31 -0
  256. package/src/vegetation/stylizedFlowers.js +59 -7
  257. package/src/vegetation/stylizedForest.js +455 -147
  258. package/src/vegetation/stylizedGrass.js +188 -24
  259. package/src/vegetation/stylizedTree.js +378 -46
  260. package/src/vegetation/stylizedTreeFoliage.js +889 -38
  261. package/src/vegetation/stylizedUnderstory.js +230 -0
  262. package/src/vegetation/treeExport.js +262 -47
  263. package/src/vegetation/treeSurfaceTextures.js +337 -0
  264. package/src/vegetation/vegetationShaders.js +617 -28
  265. package/src/version.js +3 -0
  266. package/src/water/water.js +2 -0
  267. package/src/water/waterBreakerSystem.js +2 -0
  268. package/src/water/waterCurrentField.js +1 -0
  269. package/src/water/waterMaterial.js +3 -0
  270. package/src/water/waterRain.js +2 -0
  271. package/src/water/waterScenePasses.js +170 -7
  272. package/src/water/waterSettings.js +235 -43
  273. package/src/water/waterShoreMaterial.js +16 -2
  274. package/src/water/waterShoreStateField.js +1 -1
  275. package/src/water/waterSplashSystem.js +2 -0
  276. package/src/water/waterStageSettings.js +60 -0
  277. package/src/water/waterSurface.js +144 -4
  278. package/src/water/waterUnderwaterAtmosphere.js +288 -0
  279. package/src/water/waterVegetation.js +20 -4
  280. package/src/worldCollision.js +64 -9
  281. package/types/agents/index.d.ts +1 -0
  282. package/types/agents/sceneStyleOperations.d.ts +484 -0
  283. package/types/asset-policy/catalogLicenses.d.ts +5 -0
  284. package/types/asset-policy/index.d.ts +18 -0
  285. package/types/assetlib/ambientcg.d.ts +81 -0
  286. package/types/assetlib/assetRef.d.ts +26 -0
  287. package/types/assetlib/galleryMaterialFamily.d.ts +13 -0
  288. package/types/assetlib/importedEntry.d.ts +18 -0
  289. package/types/assetlib/index.d.ts +16 -0
  290. package/types/assetlib/kaykit.d.ts +112 -0
  291. package/types/assetlib/kaykitStaticIndex.d.ts +38 -0
  292. package/types/assetlib/loadImported.d.ts +54 -0
  293. package/types/assetlib/opensource3d.d.ts +55 -0
  294. package/types/assetlib/plateau.d.ts +67 -0
  295. package/types/assetlib/plateauLandmarks.d.ts +238 -0
  296. package/types/assetlib/plateauViewer.d.ts +3 -0
  297. package/types/assetlib/polyhaven.d.ts +90 -0
  298. package/types/assetlib/polypizza.d.ts +10 -0
  299. package/types/assetlib/smithsonian.d.ts +9 -0
  300. package/types/assetlib/sources.d.ts +22 -0
  301. package/types/assetlib/zip.d.ts +8 -0
  302. package/types/catalog/manifest.d.ts +26 -0
  303. package/types/catalog/officialCatalog.d.ts +4 -0
  304. package/types/catalog/officialCatalogAssetRuntime.d.ts +2 -0
  305. package/types/catalog/officialCatalogLod.d.ts +5 -0
  306. package/types/catalog/officialCatalogPlacement.d.ts +49 -0
  307. package/types/catalog/officialCatalogProvider.d.ts +7 -0
  308. package/types/character/animationRetarget.d.ts +20 -0
  309. package/types/character/characterRig.d.ts +28 -0
  310. package/types/character/characterRuntime.d.ts +4 -0
  311. package/types/character/freestyleSwimClip.d.ts +5 -0
  312. package/types/character/groundStabilizer.d.ts +55 -0
  313. package/types/character/index.d.ts +10 -0
  314. package/types/character/locomotionActions.d.ts +4 -0
  315. package/types/character/locomotionStateMachine.d.ts +62 -0
  316. package/types/character/mannequinAsset.d.ts +12 -0
  317. package/types/character/mannequinAssetUrl.node.d.ts +1 -0
  318. package/types/character/modelLoader.d.ts +7 -0
  319. package/types/character/walkableCharacterRuntime.d.ts +343 -0
  320. package/types/character/waterInteractionController.d.ts +114 -0
  321. package/types/cloud/ambientSkyBaker.d.ts +18 -0
  322. package/types/cloud/cloudLighting.d.ts +38 -0
  323. package/types/cloud/cloudParams.d.ts +18 -0
  324. package/types/cloud/cloudReprojection.d.ts +15 -0
  325. package/types/cloud/cloudStyle.d.ts +1380 -0
  326. package/types/cloud/cloudStyleSnapshots.d.ts +10 -0
  327. package/types/cloud/cloudVolume.d.ts +43 -0
  328. package/types/cloud/heroCloudRecipe.d.ts +167 -0
  329. package/types/cloud/index.d.ts +12 -0
  330. package/types/cloud/noise/baseShapeVolume.d.ts +86 -0
  331. package/types/cloud/noise/cirrusMap.d.ts +24 -0
  332. package/types/cloud/noise/curlNoise.d.ts +106 -0
  333. package/types/cloud/noise/erosionVolume.d.ts +58 -0
  334. package/types/cloud/noise/noiseVolume.d.ts +63 -0
  335. package/types/cloud/noise/periodicNoise3.d.ts +75 -0
  336. package/types/cloud/noise/weatherMap.d.ts +227 -0
  337. package/types/cloud/paramSchema.d.ts +142 -0
  338. package/types/collisionMetadata.d.ts +11 -0
  339. package/types/core/generation.d.ts +95 -0
  340. package/types/core/materialRoles.d.ts +102 -0
  341. package/types/core/presetDocuments.d.ts +25 -0
  342. package/types/core/systemStylePolicy.d.ts +4 -0
  343. package/types/environment/dayCurves.d.ts +47 -0
  344. package/types/environment/environmentAmbientProbe.d.ts +2 -0
  345. package/types/environment/environmentGroundFieldPass.d.ts +2 -0
  346. package/types/environment/environmentMaterialAdapter.d.ts +42 -0
  347. package/types/environment/environmentMaterialClassifier.d.ts +26 -0
  348. package/types/environment/environmentPlanarReflection.d.ts +3 -0
  349. package/types/environment/environmentPresets.d.ts +171 -0
  350. package/types/environment/environmentRigs.d.ts +13 -0
  351. package/types/environment/environmentSettings.d.ts +161 -0
  352. package/types/environment/environmentShaderMaterials.d.ts +14 -0
  353. package/types/environment/environmentState.d.ts +6 -0
  354. package/types/environment/environmentSunShadowPass.d.ts +2 -0
  355. package/types/environment/environmentTextureResolver.d.ts +30 -0
  356. package/types/environment/environmentTimeOfDay.d.ts +25 -0
  357. package/types/environment/environmentVertexAo.d.ts +18 -0
  358. package/types/environment/index.d.ts +27 -0
  359. package/types/environment/manufacturedMaterialContract.d.ts +129 -0
  360. package/types/environment/manufacturedReflectionProvider.d.ts +3 -0
  361. package/types/environment/scanAssetStylize.d.ts +43 -0
  362. package/types/environment/surfaceMaterialModes.d.ts +14 -0
  363. package/types/environment/toonLabEnvironmentMaterials.d.ts +139 -0
  364. package/types/environment/toonLabMaterialPassCoupling.d.ts +7 -0
  365. package/types/environment/toonLabNormalIntegration.d.ts +29 -0
  366. package/types/environment/toonLabRockMaterialResolver.d.ts +270 -0
  367. package/types/environment/toonLabSourceDefaultLit.d.ts +136 -0
  368. package/types/environment/toonLabSourceLibrary.d.ts +19 -0
  369. package/types/environment/toonLabSourceMaterials.d.ts +14 -0
  370. package/types/environment/toonLabSourceSubsurfaceLighting.d.ts +85 -0
  371. package/types/environment/toonLabSourceTemporal.d.ts +20 -0
  372. package/types/environment/toonLabSurfaceLighting.d.ts +136 -0
  373. package/types/environment/toonLabTextureReadiness.d.ts +8 -0
  374. package/types/environment/toonLabTreeMaterials.d.ts +7 -0
  375. package/types/environment/transparentMaterialProfile.d.ts +76 -0
  376. package/types/environment/urbanPropMaterial.d.ts +25 -0
  377. package/types/ground-shader/groundPrintLayer.d.ts +4 -0
  378. package/types/ground-shader/groundShaderMaterial.d.ts +11 -0
  379. package/types/ground-shader/groundShaderSettings.d.ts +90 -0
  380. package/types/ground-shader/index.d.ts +3 -0
  381. package/types/index.d.ts +1502 -0
  382. package/types/lighting/callMeSenseiLightingContract.d.ts +14 -0
  383. package/types/lighting/colorIntensity.d.ts +44 -0
  384. package/types/lighting/index.d.ts +12 -0
  385. package/types/lighting/lightDescriptors.d.ts +803 -0
  386. package/types/lighting/lightingCapabilities.d.ts +85 -0
  387. package/types/lighting/lightingDocuments.d.ts +140 -0
  388. package/types/lighting/lightingFixtures.d.ts +171 -0
  389. package/types/lighting/lightingGenerator.d.ts +403 -0
  390. package/types/lighting/lightingPresets.d.ts +264 -0
  391. package/types/lighting/lightingRuntime.d.ts +401 -0
  392. package/types/lighting/lightingStyle.d.ts +156 -0
  393. package/types/lighting/lightingSystem.d.ts +433 -0
  394. package/types/lighting/toonLabExport.d.ts +46 -0
  395. package/types/lighting/utils.d.ts +18 -0
  396. package/types/loaders/index.d.ts +1 -0
  397. package/types/post/index.d.ts +2 -0
  398. package/types/post/postGenerator.d.ts +282 -0
  399. package/types/post/postProcessing.d.ts +16 -0
  400. package/types/react/index.d.ts +1765 -0
  401. package/types/renderer/index.d.ts +1 -0
  402. package/types/renderer/rendererConfiguration.d.ts +8 -0
  403. package/types/rock-shader/index.d.ts +3 -0
  404. package/types/rock-shader/rockMaterial.d.ts +18 -0
  405. package/types/rock-shader/rockShaderRuntime.d.ts +8 -0
  406. package/types/rock-shader/rockShaderSettings.d.ts +170 -0
  407. package/types/rockgen/export/glbExport.d.ts +58 -0
  408. package/types/rockgen/heightfield/heightfieldErosion.d.ts +10 -0
  409. package/types/rockgen/heightfield/heightfieldPatch.d.ts +15 -0
  410. package/types/rockgen/heightfield/stylizedErosionSim.d.ts +41 -0
  411. package/types/rockgen/index.d.ts +11 -0
  412. package/types/rockgen/lod/index.d.ts +6 -0
  413. package/types/rockgen/lod/rockLodMetrics.d.ts +62 -0
  414. package/types/rockgen/lod/rockLodPlanner.d.ts +86 -0
  415. package/types/rockgen/lod/rockLodPolicy.d.ts +76 -0
  416. package/types/rockgen/lod/rockLodRuntime.d.ts +95 -0
  417. package/types/rockgen/lod/rockLodSimplifier.d.ts +15 -0
  418. package/types/rockgen/lod/rockLodValidation.d.ts +16 -0
  419. package/types/rockgen/mesh/meshAttributes.d.ts +32 -0
  420. package/types/rockgen/mesh/meshDocument.d.ts +40 -0
  421. package/types/rockgen/mesh/surfaceNets.d.ts +42 -0
  422. package/types/rockgen/noise/cellularNoise3.d.ts +24 -0
  423. package/types/rockgen/noise/prng.d.ts +16 -0
  424. package/types/rockgen/noise/simplexNoise3.d.ts +2 -0
  425. package/types/rockgen/noise/valueNoise3.d.ts +12 -0
  426. package/types/rockgen/rockDocument.d.ts +215 -0
  427. package/types/rockgen/rockHelpers.d.ts +2 -0
  428. package/types/rockgen/rockgenPresets.d.ts +10 -0
  429. package/types/rockgen/rockgenSettings.d.ts +531 -0
  430. package/types/rockgen/sdf/fieldCompiler.d.ts +20 -0
  431. package/types/rockgen/sdf/sculptEdits.d.ts +30 -0
  432. package/types/rockgen/sdf/sdfModifiers.d.ts +19 -0
  433. package/types/rockgen/sdf/sdfOps.d.ts +8 -0
  434. package/types/rockgen/sdf/sdfPrimitives.d.ts +22 -0
  435. package/types/runtime/index.d.ts +3 -0
  436. package/types/runtime/sceneCollisionRuntime.d.ts +94 -0
  437. package/types/runtime/sceneSurfaceRuntime.d.ts +90 -0
  438. package/types/runtime/sceneUpdateScheduler.d.ts +28 -0
  439. package/types/shaders-tsl/anime.d.ts +9 -0
  440. package/types/shaders-tsl/chunks/character-color.d.ts +6 -0
  441. package/types/shaders-tsl/chunks/character-highlights.d.ts +12 -0
  442. package/types/shaders-tsl/chunks/character-lighting.d.ts +20 -0
  443. package/types/shaders-tsl/chunks/character-material-maps.d.ts +18 -0
  444. package/types/shaders-tsl/chunks/character-roles.d.ts +21 -0
  445. package/types/shaders-tsl/chunks/character-scene-lights.d.ts +48 -0
  446. package/types/shaders-tsl/chunks/character-shadow-color.d.ts +5 -0
  447. package/types/shaders-tsl/chunks/character-skinning.d.ts +23 -0
  448. package/types/shaders-tsl/chunks/environment-color.d.ts +9 -0
  449. package/types/shaders-tsl/chunks/environment-debug.d.ts +24 -0
  450. package/types/shaders-tsl/chunks/environment-ground-field.d.ts +40 -0
  451. package/types/shaders-tsl/chunks/environment-lighting.d.ts +22 -0
  452. package/types/shaders-tsl/chunks/environment-state.d.ts +42 -0
  453. package/types/shaders-tsl/chunks/environment-sun-shadow.d.ts +19 -0
  454. package/types/shaders-tsl/chunks/foliage-fog.d.ts +21 -0
  455. package/types/shaders-tsl/chunks/normalized-hue.d.ts +1 -0
  456. package/types/shaders-tsl/chunks/pass-depth-color.d.ts +20 -0
  457. package/types/shaders-tsl/chunks/projected-water-caustics.d.ts +24 -0
  458. package/types/shaders-tsl/chunks/scene-depth-color-pass.d.ts +39 -0
  459. package/types/shaders-tsl/chunks/stylized-cloud-shadow.d.ts +9 -0
  460. package/types/shaders-tsl/chunks/vegetation-style.d.ts +60 -0
  461. package/types/shaders-tsl/chunks/water-color.d.ts +15 -0
  462. package/types/shaders-tsl/chunks/water-common.d.ts +9 -0
  463. package/types/shaders-tsl/chunks/water-foam.d.ts +8 -0
  464. package/types/shaders-tsl/chunks/water-lighting.d.ts +9 -0
  465. package/types/shaders-tsl/chunks/water-ripple.d.ts +8 -0
  466. package/types/shaders-tsl/chunks/water-shore-state.d.ts +7 -0
  467. package/types/shaders-tsl/chunks/water-waves.d.ts +18 -0
  468. package/types/shaders-tsl/chunks/world-noise.d.ts +4 -0
  469. package/types/shaders-tsl/environment-ao-overlay.d.ts +5 -0
  470. package/types/shaders-tsl/environment.d.ts +34 -0
  471. package/types/shaders-tsl/flower.d.ts +6 -0
  472. package/types/shaders-tsl/grass.d.ts +4 -0
  473. package/types/shaders-tsl/post-composite.d.ts +25 -0
  474. package/types/shaders-tsl/sky.d.ts +4 -0
  475. package/types/shaders-tsl/tree-leaf.d.ts +2 -0
  476. package/types/shaders-tsl/water-breaker.d.ts +15 -0
  477. package/types/shaders-tsl/water-kelp.d.ts +5 -0
  478. package/types/shaders-tsl/water-rain.d.ts +10 -0
  479. package/types/shaders-tsl/water-shore-state-simulation.d.ts +12 -0
  480. package/types/shaders-tsl/water-simulation.d.ts +5 -0
  481. package/types/shaders-tsl/water-splash.d.ts +12 -0
  482. package/types/shaders-tsl/water.d.ts +22 -0
  483. package/types/shaders-tsl/woody-surface.d.ts +3 -0
  484. package/types/sky/atmosphereDome.d.ts +2 -0
  485. package/types/sky/atmosphereParams.d.ts +185 -0
  486. package/types/sky/atmosphereScattering.d.ts +11 -0
  487. package/types/sky/atmosphereSky.d.ts +2 -0
  488. package/types/sky/cloudShadow.d.ts +68 -0
  489. package/types/sky/godRays.d.ts +5 -0
  490. package/types/sky/index.d.ts +18 -0
  491. package/types/sky/nightSky.d.ts +22 -0
  492. package/types/sky/renderLayers.d.ts +59 -0
  493. package/types/sky/sceneOverrideLayers.d.ts +10 -0
  494. package/types/sky/skyColor.d.ts +704 -0
  495. package/types/sky/skyDayCycle.d.ts +86 -0
  496. package/types/sky/skyParams.d.ts +3407 -0
  497. package/types/sky/skyPresets.d.ts +160 -0
  498. package/types/sky/skyQuality.d.ts +21 -0
  499. package/types/sky/skyQualityTiers.d.ts +223 -0
  500. package/types/sky/skyShaderSettings.d.ts +152 -0
  501. package/types/sky/skyStyleSnapshots.d.ts +11 -0
  502. package/types/sky/skySystem.d.ts +3 -0
  503. package/types/sky/skyTimeKeyframes.d.ts +230 -0
  504. package/types/sky/stylizedSky.d.ts +341 -0
  505. package/types/sky/sunDriver.d.ts +15 -0
  506. package/types/sky/timeOfDay.d.ts +145 -0
  507. package/types/styles/animeGameProfile.d.ts +27 -0
  508. package/types/styles/index.d.ts +17 -0
  509. package/types/styles/manufacturedStyleLabeling.d.ts +119 -0
  510. package/types/styles/sceneLayerDocuments.d.ts +145 -0
  511. package/types/styles/sceneLookComposition.d.ts +53 -0
  512. package/types/styles/sceneQualityApplication.d.ts +34 -0
  513. package/types/styles/sceneQualityProfiles.d.ts +13 -0
  514. package/types/styles/sceneStyleAudit.d.ts +80 -0
  515. package/types/styles/sceneStyleRuntime.d.ts +1782 -0
  516. package/types/styles/styleAdapters.d.ts +14 -0
  517. package/types/styles/styleApplication.d.ts +47 -0
  518. package/types/styles/styleBundle.d.ts +19 -0
  519. package/types/styles/styleBundleProvider.d.ts +44 -0
  520. package/types/styles/styleDomains.d.ts +18 -0
  521. package/types/styles/styleInspector.d.ts +59 -0
  522. package/types/styles/styleMaterialContract.d.ts +46 -0
  523. package/types/styles/styleMetadata.d.ts +11 -0
  524. package/types/styles/styleTargetDiscovery.d.ts +48 -0
  525. package/types/styles/styleTargetLabels.d.ts +32 -0
  526. package/types/styles/styleTargetMaterialCoverage.d.ts +20 -0
  527. package/types/styles/styleTransaction.d.ts +10 -0
  528. package/types/styles/styleTypes.d.ts +66 -0
  529. package/types/texgen/evaluateTexture.d.ts +40 -0
  530. package/types/texgen/index.d.ts +7 -0
  531. package/types/texgen/noise2.d.ts +46 -0
  532. package/types/texgen/textureAi.d.ts +6 -0
  533. package/types/texgen/textureGenerators.d.ts +261 -0
  534. package/types/texgen/texturePresets.d.ts +45 -0
  535. package/types/texgen/textureSettings.d.ts +121 -0
  536. package/types/texgen/textureThree.d.ts +13 -0
  537. package/types/toon/characterRenderPasses.d.ts +3 -0
  538. package/types/toon/index.d.ts +3 -0
  539. package/types/toon/settings/alphaSettings.d.ts +125 -0
  540. package/types/toon/settings/averageShadowSettings.d.ts +39 -0
  541. package/types/toon/settings/baseTextureSettings.d.ts +39 -0
  542. package/types/toon/settings/celShadeSettings.d.ts +37 -0
  543. package/types/toon/settings/contactShadowSettings.d.ts +30 -0
  544. package/types/toon/settings/eyeHighlightSettings.d.ts +55 -0
  545. package/types/toon/settings/faceLightingSettings.d.ts +32 -0
  546. package/types/toon/settings/furSettings.d.ts +23 -0
  547. package/types/toon/settings/glitterSettings.d.ts +43 -0
  548. package/types/toon/settings/hairHighlightSettings.d.ts +89 -0
  549. package/types/toon/settings/indirectLightSettings.d.ts +43 -0
  550. package/types/toon/settings/localLightSettings.d.ts +46 -0
  551. package/types/toon/settings/materialMapSettings.d.ts +86 -0
  552. package/types/toon/settings/outlineSettings.d.ts +125 -0
  553. package/types/toon/settings/perspectiveRemovalSettings.d.ts +14 -0
  554. package/types/toon/settings/rimLightSettings.d.ts +79 -0
  555. package/types/toon/settings/sceneShadowSettings.d.ts +32 -0
  556. package/types/toon/settings/selfShadowSettings.d.ts +44 -0
  557. package/types/toon/settings/shadowColorSettings.d.ts +77 -0
  558. package/types/toon/settings/skinToneSettings.d.ts +30 -0
  559. package/types/toon/settings/specularSettings.d.ts +96 -0
  560. package/types/toon/settings/stickerSettings.d.ts +40 -0
  561. package/types/toon/toonMaterialAdapter.d.ts +883 -0
  562. package/types/toon/toonSettings.d.ts +1182 -0
  563. package/types/vegetation/branchTree.d.ts +10 -0
  564. package/types/vegetation/callMeSenseiGrass.d.ts +8 -0
  565. package/types/vegetation/compiledTree.d.ts +75 -0
  566. package/types/vegetation/contactShadowField.d.ts +26 -0
  567. package/types/vegetation/flowerSpecies.d.ts +107 -0
  568. package/types/vegetation/grass.d.ts +4 -0
  569. package/types/vegetation/grassClump.d.ts +7 -0
  570. package/types/vegetation/grassPalettes.d.ts +29 -0
  571. package/types/vegetation/importedVegetationMaterial.d.ts +13 -0
  572. package/types/vegetation/index.d.ts +216 -0
  573. package/types/vegetation/legacyTreePresets.d.ts +22 -0
  574. package/types/vegetation/scatter.d.ts +12 -0
  575. package/types/vegetation/stylizedBush.d.ts +2 -0
  576. package/types/vegetation/stylizedFlower.d.ts +2 -0
  577. package/types/vegetation/stylizedFlowers.d.ts +8 -0
  578. package/types/vegetation/stylizedForest.d.ts +3 -0
  579. package/types/vegetation/stylizedGrass.d.ts +21 -0
  580. package/types/vegetation/stylizedTree.d.ts +19 -0
  581. package/types/vegetation/stylizedTreeFoliage.d.ts +18 -0
  582. package/types/vegetation/stylizedUnderstory.d.ts +50 -0
  583. package/types/vegetation/treeExport.d.ts +6 -0
  584. package/types/vegetation/treeSurfaceTextures.d.ts +72 -0
  585. package/types/vegetation/vegetationShaders.d.ts +74 -0
  586. package/types/version.d.ts +1 -0
  587. package/types/water/index.d.ts +1 -0
  588. package/types/water/sceneOverrideLayers.d.ts +16 -0
  589. package/types/water/water.d.ts +17 -0
  590. package/types/water/waterBreakerSystem.d.ts +46 -0
  591. package/types/water/waterCurrentField.d.ts +115 -0
  592. package/types/water/waterInteraction.d.ts +21 -0
  593. package/types/water/waterMaterial.d.ts +60 -0
  594. package/types/water/waterNearshorePhase.d.ts +5 -0
  595. package/types/water/waterRain.d.ts +17 -0
  596. package/types/water/waterRippleSimulation.d.ts +52 -0
  597. package/types/water/waterScenePasses.d.ts +70 -0
  598. package/types/water/waterSettings.d.ts +648 -0
  599. package/types/water/waterShoreMaterial.d.ts +3 -0
  600. package/types/water/waterShoreStateField.d.ts +2 -0
  601. package/types/water/waterSplashSystem.d.ts +2 -0
  602. package/types/water/waterStageSettings.d.ts +9 -0
  603. package/types/water/waterSurface.d.ts +2 -0
  604. package/types/water/waterUnderwaterAtmosphere.d.ts +103 -0
  605. package/types/water/waterVegetation.d.ts +16 -0
  606. package/types/worldCollision.d.ts +22 -0
  607. package/AGENTS.md +0 -254
  608. package/ATTRIBUTION.md +0 -78
  609. package/docs/characters.md +0 -144
  610. package/docs/debug-panel.md +0 -126
  611. package/docs/docs.css +0 -589
  612. package/docs/environment.md +0 -186
  613. package/docs/getting-started.md +0 -180
  614. package/docs/index.html +0 -14
  615. package/docs/lab-architecture.md +0 -100
  616. package/docs/lighting.md +0 -825
  617. package/docs/main.jsx +0 -739
  618. package/docs/mcp.md +0 -97
  619. package/docs/post-processing.md +0 -98
  620. package/docs/settings-reference.md +0 -1878
  621. package/docs/shader-constants.md +0 -77
  622. package/docs/sky.md +0 -182
  623. package/docs/style-labs.md +0 -309
  624. package/docs/texture-lab.md +0 -135
  625. package/docs/toon-shading.md +0 -183
  626. package/docs/tsl-conventions.md +0 -167
  627. package/docs/vegetation-sky.md +0 -275
  628. package/docs/water.md +0 -430
  629. package/docs/weather.md +0 -200
  630. package/docs/world-scale.md +0 -111
  631. package/mcp/style-lab-tools.mjs +0 -371
  632. package/src/ambientfx/INTEGRATION.md +0 -164
  633. package/src/ambientfx/ambientFxPresets.js +0 -83
  634. package/src/ambientfx/ambientFxSettings.js +0 -368
  635. package/src/ambientfx/emitters.js +0 -169
  636. package/src/ambientfx/index.js +0 -5
  637. package/src/ambientfx/particleBackbone.js +0 -493
  638. package/src/ambientfx/stylizedAmbientFx.js +0 -450
  639. package/src/biome/biomeGenerator.js +0 -385
  640. package/src/biome/biomeRuntime.js +0 -299
  641. package/src/biome/index.js +0 -2
  642. package/src/buildinggen/buildingAsset.js +0 -44
  643. package/src/buildinggen/buildingGrammar.js +0 -311
  644. package/src/buildinggen/buildingMesh.js +0 -451
  645. package/src/buildinggen/buildingPresets.js +0 -46
  646. package/src/buildinggen/buildingRecipe.js +0 -100
  647. package/src/buildinggen/buildingSettings.js +0 -238
  648. package/src/buildinggen/index.js +0 -6
  649. package/src/camera/cameraDirector.js +0 -157
  650. package/src/camera/cameraGenerator.js +0 -367
  651. package/src/camera/cameraRig.js +0 -570
  652. package/src/camera/cameraSettings.js +0 -236
  653. package/src/camera/index.js +0 -7
  654. package/src/catalog/builtinEntries.js +0 -245
  655. package/src/catalog/catalog.js +0 -210
  656. package/src/catalog/index.js +0 -3
  657. package/src/core/shaderBackend.js +0 -24
  658. package/src/debrisgen/debrisFields.js +0 -544
  659. package/src/debrisgen/debrisGenerator.js +0 -1929
  660. package/src/debrisgen/debrisPalettes.js +0 -71
  661. package/src/debrisgen/debrisPhysics.js +0 -198
  662. package/src/debrisgen/debrisPresets.js +0 -162
  663. package/src/debrisgen/debrisSettings.js +0 -333
  664. package/src/debrisgen/debrisTextures.js +0 -380
  665. package/src/debrisgen/index.js +0 -5
  666. package/src/debug/fieldValues.js +0 -95
  667. package/src/debug/index.js +0 -7
  668. package/src/debug/settingsPanel.js +0 -170
  669. package/src/fauna/INTEGRATION.md +0 -174
  670. package/src/fauna/boids.js +0 -861
  671. package/src/fauna/faunaBodies.js +0 -492
  672. package/src/fauna/faunaPresets.js +0 -52
  673. package/src/fauna/faunaSettings.js +0 -525
  674. package/src/fauna/index.js +0 -5
  675. package/src/fauna/stylizedFauna.js +0 -395
  676. package/src/game-feel/gameFeelGenerator.js +0 -402
  677. package/src/game-feel/gameFeelRuntime.js +0 -549
  678. package/src/game-feel/index.js +0 -2
  679. package/src/motion/index.js +0 -5
  680. package/src/motion/motionClip.js +0 -441
  681. package/src/motion/motionController.js +0 -628
  682. package/src/motion/motionDocuments.js +0 -225
  683. package/src/motion/motionGraph.js +0 -307
  684. package/src/motion/motionSettings.js +0 -222
  685. package/src/pathgen/index.js +0 -7
  686. package/src/pathgen/pathBridge.js +0 -232
  687. package/src/pathgen/pathPresets.js +0 -35
  688. package/src/pathgen/pathRibbon.js +0 -410
  689. package/src/pathgen/pathRouter.js +0 -380
  690. package/src/pathgen/pathSettings.js +0 -335
  691. package/src/pathgen/pathTextures.js +0 -123
  692. package/src/pathgen/stylizedPaths.js +0 -453
  693. package/src/propgen/generatorsWave1.js +0 -379
  694. package/src/propgen/generatorsWave2.js +0 -462
  695. package/src/propgen/index.js +0 -5
  696. package/src/propgen/propAsset.js +0 -323
  697. package/src/propgen/propParts.js +0 -170
  698. package/src/propgen/propPlacement.js +0 -459
  699. package/src/propgen/propPresets.js +0 -82
  700. package/src/propgen/propSettings.js +0 -395
  701. package/src/soundscape/index.js +0 -4
  702. package/src/soundscape/soundscapeGenerator.js +0 -179
  703. package/src/soundscape/soundscapeRuntime.js +0 -806
  704. package/src/soundscape/soundscapeSettings.js +0 -292
  705. package/src/stylizedTerrain.js +0 -631
  706. package/src/stylizedWorld.js +0 -903
  707. package/src/vegetation/treeRecipe.js +0 -647
  708. package/src/vfxgen/INTEGRATION.md +0 -145
  709. package/src/vfxgen/core/burstBackbone.js +0 -380
  710. package/src/vfxgen/core/projectileCore.js +0 -92
  711. package/src/vfxgen/core/spriteShapes.js +0 -98
  712. package/src/vfxgen/core/trailRibbon.js +0 -272
  713. package/src/vfxgen/core/vfxRandom.js +0 -29
  714. package/src/vfxgen/effects/emitHelpers.js +0 -37
  715. package/src/vfxgen/effects/magicEffects.js +0 -162
  716. package/src/vfxgen/effects/movementEffects.js +0 -87
  717. package/src/vfxgen/effects/weaponEffects.js +0 -118
  718. package/src/vfxgen/index.js +0 -18
  719. package/src/vfxgen/moves/moveController.js +0 -146
  720. package/src/vfxgen/moves/moveLibrary.js +0 -335
  721. package/src/vfxgen/vfxPresets.js +0 -98
  722. package/src/vfxgen/vfxSettings.js +0 -384
  723. package/src/vfxgen/vfxSystem.js +0 -449
  724. package/src/vfxgen/weapons/stylizedWeapons.js +0 -137
  725. package/src/villagegen/index.js +0 -4
  726. package/src/villagegen/stylizedVillage.js +0 -490
  727. package/src/villagegen/villageArchetypes.js +0 -160
  728. package/src/villagegen/villageNames.js +0 -40
  729. package/src/villagegen/villageSites.js +0 -105
  730. package/src/weather/index.js +0 -6
  731. package/src/weather/weatherPrecipitation.js +0 -221
  732. package/src/weather/weatherPresets.js +0 -258
  733. package/src/weather/weatherSettings.js +0 -269
  734. package/src/weather/weatherSystem.js +0 -871
  735. package/src/worldMinimap.js +0 -214
  736. package/src/worldPresets.js +0 -125
package/mcp/server.mjs CHANGED
@@ -1,35 +1,87 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { basename, extname } from 'node:path';
4
- import { builtinCatalogEntries } from '../src/catalog/builtinEntries.js';
3
+ import { readFileSync } from 'node:fs';
4
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
5
+ import { basename, dirname, extname, join } from 'node:path';
6
+ import { publicMcpCatalogEntries } from './public-catalog.mjs';
5
7
  import {
6
8
  fetchPolyhavenFiles,
7
9
  fetchPolyhavenIndex,
8
- filterAssetRefs,
9
10
  resolvePolyhavenModelDownload,
10
11
  resolvePolyhavenTextureDownload,
11
- searchAmbientcg,
12
+ } from '../src/assetlib/polyhaven.js';
13
+ import { filterAssetRefs } from '../src/assetlib/assetRef.js';
14
+ import {
12
15
  resolveAmbientcgDownload,
13
- } from '../src/assetlib/index.js';
16
+ searchAmbientcg,
17
+ } from '../src/assetlib/ambientcg.js';
14
18
  import {
15
- getWorkspaceInfo,
16
- listLibraryEntries,
17
- listStorageDocuments,
18
- listWorkspaceFiles,
19
+ getWorkspaceInfo as getLegacyWorkspaceInfo,
20
+ isPersistableStorageKey,
21
+ listLibraryEntries as listLegacyLibraryEntries,
22
+ listStorageDocuments as listLegacyStorageDocuments,
23
+ listWorkspaceFiles as listLegacyWorkspaceFiles,
19
24
  matchesText,
20
- readWorkspaceFile,
25
+ deleteBrowserStorageValue as deleteLegacyBrowserStorageValue,
26
+ deleteLibraryEntry as deleteLegacyLibraryEntry,
27
+ deleteWorkspaceFile as deleteLegacyWorkspaceFile,
28
+ readBrowserStorage as readLegacyBrowserStorage,
29
+ readWorkspaceFile as readLegacyWorkspaceFile,
21
30
  resolveWorkspacePath,
22
- saveCreation,
23
- writeWorkspaceFile,
31
+ saveCreation as saveLegacyCreation,
32
+ saveLibraryEntry as saveLegacyLibraryEntry,
33
+ setBrowserStorageValue as setLegacyBrowserStorageValue,
34
+ writeWorkspaceFile as writeLegacyWorkspaceFile,
24
35
  } from './workspace.mjs';
25
36
  import {
26
- STYLE_LAB_TOOLS,
27
- callStyleLabTool,
28
- isStyleLabTool,
29
- } from './style-lab-tools.mjs';
37
+ databaseInfo,
38
+ deleteLabState,
39
+ deleteLibraryEntry as deleteDatabaseLibraryEntry,
40
+ getCatalogAsset as getDatabaseCatalogAsset,
41
+ listCatalogAssets as listDatabaseCatalogAssets,
42
+ listLibraryEntries as listDatabaseLibraryEntries,
43
+ listObjects,
44
+ normalizeCreationTags,
45
+ providerConfiguration,
46
+ readLabState,
47
+ readObject,
48
+ saveLibraryEntry as saveDatabaseLibraryEntry,
49
+ saveCreationDocument,
50
+ saveObject,
51
+ setLabState,
52
+ } from '../database/repository.mjs';
53
+ import {
54
+ getManagedGeneration,
55
+ listManagedGenerations,
56
+ saveManagedGeneration,
57
+ startManagedGeneration,
58
+ } from '../database/generation-service.mjs';
59
+ import {
60
+ LIVE_LAB_IDS,
61
+ applyLabDocumentOperation,
62
+ createLabDocument,
63
+ getLabFeatures,
64
+ listLiveLabs,
65
+ } from './lab-management.mjs';
66
+ import {
67
+ ASSET_POLICY_MODES,
68
+ ASSET_SOURCE_CLASSES,
69
+ createAssetGapRecord,
70
+ evaluateAssetCandidate,
71
+ renderAssetGapReport,
72
+ validateAssetSourcingPolicy,
73
+ } from '../src/asset-policy/index.js';
74
+ import {
75
+ CALL_ME_SENSEI_STYLE_BUNDLE,
76
+ STYLE_DOMAIN_SLOT_ROUTES,
77
+ TOONLAB_ANIME_GAME_PROFILE,
78
+ } from '../src/styles/index.js';
79
+ import { runSceneStyleOperation } from '../src/agents/index.js';
30
80
 
31
81
  const SERVER_NAME = 'toonlab-oss';
32
- const SERVER_VERSION = '0.2.0';
82
+ const SERVER_VERSION = JSON.parse(
83
+ readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
84
+ ).version;
33
85
  const LATEST_PROTOCOL_VERSION = '2025-11-25';
34
86
  const SUPPORTED_PROTOCOL_VERSIONS = new Set([
35
87
  LATEST_PROTOCOL_VERSION,
@@ -51,6 +103,120 @@ function parseArguments(argv) {
51
103
  }
52
104
 
53
105
  const { workspace } = parseArguments(process.argv.slice(2));
106
+ const legacyWorkspace = process.env.TOONLAB_LEGACY_WORKSPACE === '1';
107
+
108
+ async function getWorkspaceInfo() {
109
+ if (legacyWorkspace) return getLegacyWorkspaceInfo(workspace);
110
+ return {
111
+ database: await databaseInfo(),
112
+ mode: 'postgres',
113
+ path: workspace,
114
+ };
115
+ }
116
+
117
+ async function listLibraryEntries() {
118
+ if (legacyWorkspace) return listLegacyLibraryEntries(workspace);
119
+ return listDatabaseLibraryEntries();
120
+ }
121
+
122
+ async function listStorageDocuments() {
123
+ if (legacyWorkspace) return listLegacyStorageDocuments(workspace);
124
+ const entries = await readLabStateEntries();
125
+ const documents = [];
126
+ for (const [key, raw] of Object.entries(entries)) {
127
+ let parsed;
128
+ try { parsed = JSON.parse(raw); } catch { continue; }
129
+ const values = Array.isArray(parsed) ? parsed : [parsed];
130
+ values.forEach((document, index) => {
131
+ if (!document || typeof document !== 'object') return;
132
+ documents.push({
133
+ cluster: key.match(/^toonlab\.([a-z0-9-]+)/i)?.[1] ?? 'lab',
134
+ document,
135
+ id: `state:${key}:${document.id ?? document.presetId ?? index}`,
136
+ key,
137
+ kind: Array.isArray(parsed) ? 'preset' : 'document',
138
+ label: String(document.label ?? document.name ?? document.id ?? `Document ${index + 1}`),
139
+ source: 'workspace-storage',
140
+ });
141
+ });
142
+ }
143
+ return documents;
144
+ }
145
+
146
+ async function readLabStateEntries() {
147
+ if (legacyWorkspace) return (await readLegacyBrowserStorage(workspace)).entries;
148
+ const entries = await readLabState();
149
+ return Object.fromEntries(
150
+ Object.entries(entries).filter(([key, value]) => isPersistableStorageKey(key) && typeof value === 'string'),
151
+ );
152
+ }
153
+
154
+ async function setLabStateEntry(key, value) {
155
+ if (legacyWorkspace) return setLegacyBrowserStorageValue(workspace, key, value);
156
+ await setLabState(key, value);
157
+ return readLabState();
158
+ }
159
+
160
+ async function deleteLabStateEntry(key) {
161
+ if (legacyWorkspace) return deleteLegacyBrowserStorageValue(workspace, key);
162
+ await deleteLabState(key);
163
+ return readLabState();
164
+ }
165
+
166
+ async function saveLibraryEntry(entry) {
167
+ if (legacyWorkspace) return saveLegacyLibraryEntry(workspace, entry);
168
+ return saveDatabaseLibraryEntry(entry);
169
+ }
170
+
171
+ async function deleteLibraryEntry(asset, type = null) {
172
+ if (legacyWorkspace) return deleteLegacyLibraryEntry(workspace, asset.id);
173
+ return deleteDatabaseLibraryEntry({
174
+ creationId: asset._local?.creationId,
175
+ docKey: asset.id,
176
+ type: type ?? asset.type,
177
+ });
178
+ }
179
+
180
+ async function deleteWorkspaceFile(relativePath) {
181
+ if (!legacyWorkspace) throw new Error('Database-backed workspace objects are not editable creations.');
182
+ return deleteLegacyWorkspaceFile(workspace, relativePath);
183
+ }
184
+
185
+ async function listWorkspaceFiles() {
186
+ if (legacyWorkspace) return listLegacyWorkspaceFiles(workspace);
187
+ return listObjects(workspace);
188
+ }
189
+
190
+ async function readWorkspaceFile(_workspace, relativePath) {
191
+ if (legacyWorkspace) return readLegacyWorkspaceFile(workspace, relativePath);
192
+ return readObject(workspace, relativePath);
193
+ }
194
+
195
+ async function saveCreation(_workspace, options) {
196
+ if (legacyWorkspace) return saveLegacyCreation(workspace, options);
197
+ return saveCreationDocument(options);
198
+ }
199
+
200
+ const MIME_BY_EXTENSION = {
201
+ '.bin': 'application/octet-stream',
202
+ '.glb': 'model/gltf-binary',
203
+ '.gltf': 'model/gltf+json',
204
+ '.jpeg': 'image/jpeg',
205
+ '.jpg': 'image/jpeg',
206
+ '.json': 'application/json',
207
+ '.png': 'image/png',
208
+ '.webp': 'image/webp',
209
+ '.zip': 'application/zip',
210
+ };
211
+
212
+ async function writeWorkspaceFile(_workspace, relativePath, data) {
213
+ if (legacyWorkspace) return writeLegacyWorkspaceFile(workspace, relativePath, data);
214
+ const bytes = typeof data === 'string' ? Buffer.from(data) : data;
215
+ return saveObject(workspace, bytes, {
216
+ contentType: MIME_BY_EXTENSION[extname(relativePath).toLowerCase()] ?? 'application/octet-stream',
217
+ name: basename(relativePath),
218
+ });
219
+ }
54
220
 
55
221
  function jsonContent(value) {
56
222
  return {
@@ -84,16 +250,68 @@ function withSeed(recipe, seed) {
84
250
  return next;
85
251
  }
86
252
 
253
+ const SOURCE_CLASS_BY_SOURCE = Object.freeze({
254
+ builtin: 'procedural',
255
+ library: 'toonlab-library',
256
+ official: 'toonlab-library',
257
+ workspace: 'project-library',
258
+ 'workspace-storage': 'project-library',
259
+ });
260
+
261
+ function sourceClassFor(entry) {
262
+ return entry.sourceClass
263
+ ?? SOURCE_CLASS_BY_SOURCE[entry.source]
264
+ ?? 'project-library';
265
+ }
266
+
267
+ function animeStyleSupport(entry) {
268
+ const tags = normalizeCreationTags(entry.tags);
269
+ const explicit = entry.animeStyleSupport ?? entry.supportLevel;
270
+ if (explicit) return explicit;
271
+ if (tags.some((tag) => ['anime', 'cel-shaded', 'toon', 'stylized'].includes(tag))) {
272
+ return 'reviewed-candidate';
273
+ }
274
+ return 'needs-in-scene-review';
275
+ }
276
+
277
+ function normalizeDiscovery(entry, summary, { domain = '', policy = null } = {}) {
278
+ const sourceClass = sourceClassFor(entry);
279
+ return {
280
+ ...summary,
281
+ animeStyleSupport: animeStyleSupport(entry),
282
+ assetKind: entry.kind ?? entry.assetKind ?? null,
283
+ license: entry.license ?? entry.attribution?.license ?? null,
284
+ policyDecision: evaluateAssetCandidate(policy, { domain, sourceClass }),
285
+ provenance: entry.provenance ?? entry.attribution ?? null,
286
+ sourceClass,
287
+ };
288
+ }
289
+
87
290
  function summarizeCatalogEntry(entry) {
291
+ const metadata = entry.metadata && typeof entry.metadata === 'object' && !Array.isArray(entry.metadata)
292
+ ? entry.metadata
293
+ : {};
294
+ const searchableMetadata = Object.fromEntries([
295
+ 'catalog',
296
+ 'dimensionsMeters',
297
+ 'familyId',
298
+ 'profileId',
299
+ 'taxonomy',
300
+ 'releaseWave',
301
+ 'revision',
302
+ 'recipeHash',
303
+ ].flatMap((key) => metadata[key] == null ? [] : [[key, metadata[key]]]));
88
304
  return {
89
305
  cluster: entry.cluster,
90
306
  description: entry.description ?? null,
91
307
  id: entry.id,
92
308
  kind: entry.kind,
93
309
  label: entry.label,
310
+ managementId: entry._local?.creationId ?? entry.id,
94
311
  source: entry.source ?? 'builtin',
95
312
  tags: entry.tags ?? [],
96
313
  thumbnail: entry.thumbnail ?? null,
314
+ ...(Object.keys(searchableMetadata).length > 0 ? { metadata: searchableMetadata } : {}),
97
315
  };
98
316
  }
99
317
 
@@ -105,59 +323,152 @@ function summarizeStorageDocument(entry) {
105
323
  label: entry.label,
106
324
  source: entry.source,
107
325
  storageKey: entry.key,
326
+ tags: Array.isArray(entry.document?.tags) ? entry.document.tags : [],
108
327
  };
109
328
  }
110
329
 
111
- async function allAssets() {
112
- const [library, storage, files] = await Promise.all([
113
- listLibraryEntries(workspace),
114
- listStorageDocuments(workspace),
115
- listWorkspaceFiles(workspace),
330
+ function normalizeOfficialCatalogAsset(asset) {
331
+ const metadata = asset.metadata && typeof asset.metadata === 'object' && !Array.isArray(asset.metadata)
332
+ ? asset.metadata
333
+ : {};
334
+ return {
335
+ catalogProvider: asset.source,
336
+ cluster: metadata.catalog ?? 'official',
337
+ description: asset.description ?? null,
338
+ downloadUrl: asset.download_url ?? null,
339
+ files: asset.files ?? [],
340
+ id: asset.id,
341
+ kind: asset.kind,
342
+ label: asset.name,
343
+ license: asset.license,
344
+ metadata,
345
+ provenance: {
346
+ attribution: asset.attribution ?? null,
347
+ provider: asset.source,
348
+ sourceId: asset.source_id ?? null,
349
+ sourceUrl: asset.source_url ?? null,
350
+ },
351
+ source: 'official',
352
+ sourceClass: 'toonlab-library',
353
+ tags: asset.tags ?? [],
354
+ thumbnail: asset.thumbnail_url ?? null,
355
+ };
356
+ }
357
+
358
+ function withOfficialLabStart(asset) {
359
+ const catalog = String(asset.metadata?.catalog ?? asset.cluster ?? '').toLowerCase();
360
+ const isRock = catalog === 'rock' || catalog === 'rocks' || Boolean(asset.metadata?.variation?.id);
361
+ return isRock
362
+ ? { ...asset, labStart: createLabDocument('rock', { source: asset }) }
363
+ : asset;
364
+ }
365
+
366
+ async function listOfficialCatalogEntries() {
367
+ if (legacyWorkspace) return [];
368
+ const entries = [];
369
+ let offset = 0;
370
+ let total = 1;
371
+ while (offset < total) {
372
+ const page = await listDatabaseCatalogAssets({ limit: 100, offset });
373
+ entries.push(...page.items.map(normalizeOfficialCatalogAsset));
374
+ total = page.total;
375
+ offset += page.items.length;
376
+ if (page.items.length === 0) break;
377
+ }
378
+ return entries;
379
+ }
380
+
381
+ async function allAssets(source = null) {
382
+ const includes = (candidate) => source == null || source === candidate;
383
+ const [library, official, storage, files] = await Promise.all([
384
+ includes('library') ? listLibraryEntries(workspace) : [],
385
+ includes('official') ? listOfficialCatalogEntries() : [],
386
+ includes('workspace-storage') ? listStorageDocuments(workspace) : [],
387
+ includes('workspace') ? listWorkspaceFiles(workspace) : [],
116
388
  ]);
117
389
  return [
118
- ...builtinCatalogEntries().map((entry) => ({ ...entry, source: 'builtin' })),
390
+ ...(includes('builtin') ? publicMcpCatalogEntries().map((entry) => ({ ...entry, source: 'builtin' })) : []),
119
391
  ...library.map((entry) => ({ ...entry, source: 'library' })),
392
+ ...official,
120
393
  ...storage,
121
394
  ...files,
122
395
  ];
123
396
  }
124
397
 
125
398
  async function findAsset(id, source = null) {
126
- const assets = await allAssets();
127
- return assets.find((entry) => entry.id === id && (!source || entry.source === source)) ?? null;
399
+ const assets = await allAssets(source);
400
+ return assets.find((entry) => (
401
+ (entry.id === id || entry._local?.creationId === id)
402
+ && (!source || entry.source === source)
403
+ )) ?? null;
404
+ }
405
+
406
+ async function findEditableAsset(id, type = null) {
407
+ const library = (await listLibraryEntries(workspace)).filter((entry) => (
408
+ (entry.id === id || entry._local?.creationId === id)
409
+ && (!type || entry.type === type)
410
+ ));
411
+ if (library.length > 1) {
412
+ throw new Error(
413
+ `Creation document key "${id}" is ambiguous across types (${library.map((entry) => entry.type).join(', ')}). Use the managementId returned by list_my_creations, or pass type.`,
414
+ );
415
+ }
416
+ if (library.length === 1) return { ...library[0], source: 'library' };
417
+ const files = await listWorkspaceFiles(workspace);
418
+ return files.find((entry) => entry.id === id) ?? null;
128
419
  }
129
420
 
130
421
  function matchesTags(entry, tags) {
131
422
  if (!Array.isArray(tags) || tags.length === 0) return true;
132
- const actual = new Set((entry.tags ?? []).map((tag) => String(tag).toLowerCase()));
133
- return tags.every((tag) => actual.has(String(tag).toLowerCase()));
423
+ const actual = new Set(normalizeCreationTags(entry.tags));
424
+ return normalizeCreationTags(tags).every((tag) => actual.has(tag));
134
425
  }
135
426
 
136
427
  async function searchAssets(args) {
137
- const assets = await allAssets();
138
- const results = assets.filter((entry) => {
428
+ const assets = await allAssets(args.source ?? null);
429
+ const matched = assets.filter((entry) => {
139
430
  if (args.source && entry.source !== args.source) return false;
140
431
  if (args.cluster && entry.cluster !== args.cluster) return false;
141
432
  if (args.kind && entry.kind !== args.kind) return false;
142
433
  if (!matchesTags(entry, args.tags)) return false;
143
434
  return matchesText(entry, args.query);
144
- }).slice(0, limitValue(args.limit));
435
+ });
436
+ const offset = Math.max(0, Math.floor(Number(args.offset) || 0));
437
+ const limit = limitValue(args.limit);
438
+ const results = matched.slice(offset, offset + limit);
145
439
  return {
146
440
  count: results.length,
441
+ total: matched.length,
442
+ offset,
443
+ limit,
444
+ nextOffset: offset + limit < matched.length ? offset + limit : null,
147
445
  items: results.map((entry) => {
148
- if (entry.source === 'workspace') return entry;
149
- if (entry.source === 'workspace-storage') return summarizeStorageDocument(entry);
150
- return summarizeCatalogEntry(entry);
446
+ const summary = entry.source === 'workspace'
447
+ ? entry
448
+ : entry.source === 'workspace-storage'
449
+ ? summarizeStorageDocument(entry)
450
+ : summarizeCatalogEntry(entry);
451
+ return normalizeDiscovery(entry, summary, args);
151
452
  }),
152
453
  };
153
454
  }
154
455
 
155
456
  async function getAsset(args) {
457
+ if (args.source === 'official' && !legacyWorkspace) {
458
+ const complete = await getDatabaseCatalogAsset(args.id);
459
+ if (!complete) throw new Error(`Official asset "${args.id}" was not found.`);
460
+ const normalized = withOfficialLabStart(normalizeOfficialCatalogAsset(complete));
461
+ return normalizeDiscovery(normalized, normalized, args);
462
+ }
156
463
  const asset = await findAsset(args.id, args.source);
157
464
  if (!asset) throw new Error(`Asset "${args.id}" was not found.`);
158
- if (asset.source === 'workspace') return asset;
159
- if (asset.source === 'workspace-storage') return asset;
160
- return asset;
465
+ if (asset.source === 'official' && !legacyWorkspace) {
466
+ const complete = await getDatabaseCatalogAsset(asset.id);
467
+ if (!complete) throw new Error(`Official asset "${args.id}" was not found.`);
468
+ const normalized = withOfficialLabStart(normalizeOfficialCatalogAsset(complete));
469
+ return normalizeDiscovery(normalized, normalized, args);
470
+ }
471
+ return normalizeDiscovery(asset, asset, args);
161
472
  }
162
473
 
163
474
  async function listMyCreations(args) {
@@ -167,16 +478,33 @@ async function listMyCreations(args) {
167
478
  listWorkspaceFiles(workspace, { roots: ['assets', 'creations', 'exports', 'imports', 'presets'] }),
168
479
  ]);
169
480
  const query = args.query ?? null;
170
- const items = [
481
+ const matched = [
171
482
  ...library.map((entry) => summarizeCatalogEntry({ ...entry, source: 'library' })),
172
483
  ...storage.map(summarizeStorageDocument),
173
484
  ...files,
174
- ].filter((entry) => matchesText(entry, query)).slice(0, limitValue(args.limit, 50, 200));
175
- return { count: items.length, items, workspace };
485
+ ].filter((entry) => (
486
+ matchesText(entry, query)
487
+ && matchesTags(entry, args.tags)
488
+ && (!args.kind || entry.kind === args.kind || entry.type === args.kind)
489
+ ));
490
+ const offset = Math.max(0, Math.floor(Number(args.offset) || 0));
491
+ const limit = limitValue(args.limit, 50, 200);
492
+ const items = matched.slice(offset, offset + limit);
493
+ return {
494
+ count: items.length,
495
+ items,
496
+ limit,
497
+ nextOffset: offset + limit < matched.length ? offset + limit : null,
498
+ offset,
499
+ total: matched.length,
500
+ workspace,
501
+ };
176
502
  }
177
503
 
178
504
  async function getMyCreation(args) {
179
- const asset = await findAsset(args.id);
505
+ const id = String(args.id ?? '').trim();
506
+ const asset = await findEditableAsset(id, args.type ?? null)
507
+ ?? await findAsset(id, 'workspace-storage');
180
508
  if (!asset || asset.source === 'builtin') throw new Error(`Workspace creation "${args.id}" was not found.`);
181
509
  if (asset.source !== 'workspace') return asset;
182
510
  const file = await readWorkspaceFile(workspace, asset.relativePath);
@@ -189,9 +517,192 @@ async function getMyCreation(args) {
189
517
  return { ...asset, base64: file.data.toString('base64'), encoding: 'base64' };
190
518
  }
191
519
 
520
+ function mergePatch(target, patch) {
521
+ if (!patch || typeof patch !== 'object' || Array.isArray(patch)) return clone(patch);
522
+ const next = target && typeof target === 'object' && !Array.isArray(target) ? clone(target) : {};
523
+ for (const [key, value] of Object.entries(patch)) {
524
+ if (value === null) delete next[key];
525
+ else next[key] = mergePatch(next[key], value);
526
+ }
527
+ return next;
528
+ }
529
+
530
+ async function updateCreation(args) {
531
+ const id = String(args.id ?? '').trim();
532
+ const asset = await findEditableAsset(id, args.type ?? null);
533
+ if (!asset) throw new Error(`Editable creation "${id}" was not found.`);
534
+ const hasDocument = args.document && typeof args.document === 'object' && !Array.isArray(args.document);
535
+ const hasPatch = args.patch && typeof args.patch === 'object' && !Array.isArray(args.patch);
536
+ if (hasDocument && hasPatch) throw new Error('Pass document or patch, not both.');
537
+ if (args.document !== undefined && !hasDocument) throw new Error('document must be a JSON object.');
538
+ if (args.patch !== undefined && !hasPatch) throw new Error('patch must be a JSON object.');
539
+ const hasMetadata = args.label !== undefined || args.description !== undefined || args.tags !== undefined;
540
+ if (!hasDocument && !hasPatch && !hasMetadata) throw new Error('No creation changes were provided.');
541
+ if (args.label !== undefined && !String(args.label).trim()) throw new Error('label cannot be empty.');
542
+ if (args.tags !== undefined && !Array.isArray(args.tags)) throw new Error('tags must be an array.');
543
+ if (asset.source === 'workspace') {
544
+ if (!asset.relativePath?.startsWith('creations/')) {
545
+ throw new Error('Only files below .toonlab/creations are editable through update_creation.');
546
+ }
547
+ const currentFile = await readWorkspaceFile(workspace, asset.relativePath);
548
+ let currentDocument;
549
+ try { currentDocument = JSON.parse(currentFile.data.toString('utf8')); } catch {
550
+ throw new Error('Workspace creation is not a JSON document; replace it with save_creation instead.');
551
+ }
552
+ const document = hasDocument
553
+ ? clone(args.document)
554
+ : hasPatch ? mergePatch(currentDocument, args.patch) : clone(currentDocument);
555
+ if (args.label !== undefined && document && typeof document === 'object') {
556
+ document.label = String(args.label).trim().slice(0, 120);
557
+ }
558
+ if (args.description !== undefined && document && typeof document === 'object') {
559
+ document.description = args.description === null ? null : String(args.description).slice(0, 2000);
560
+ }
561
+ if (args.tags !== undefined && document && typeof document === 'object') {
562
+ document.tags = normalizeCreationTags(args.tags);
563
+ }
564
+ const file = await writeWorkspaceFile(workspace, asset.relativePath, `${JSON.stringify(document, null, 2)}\n`);
565
+ return { creation: { ...file, document } };
566
+ }
567
+ const documentField = asset.document && typeof asset.document === 'object' && !Array.isArray(asset.document)
568
+ ? 'document'
569
+ : asset.recipe && typeof asset.recipe === 'object' && !Array.isArray(asset.recipe)
570
+ ? 'recipe'
571
+ : null;
572
+ const currentDocument = documentField ? asset[documentField] : asset;
573
+ const document = hasDocument
574
+ ? clone(args.document)
575
+ : hasPatch ? mergePatch(currentDocument, args.patch) : clone(currentDocument);
576
+ const label = String(args.label ?? asset.label ?? document.label ?? document.name ?? id).trim().slice(0, 120);
577
+ if (!label) throw new Error('label cannot be empty.');
578
+ const next = documentField
579
+ ? { ...asset, [documentField]: document, label }
580
+ : { ...document, id: asset.id, label, type: asset.type ?? document.type ?? asset.kind };
581
+ if (args.description !== undefined) next.description = String(args.description ?? '').slice(0, 2000);
582
+ if (args.tags !== undefined) next.tags = normalizeCreationTags(args.tags);
583
+ delete next._local;
584
+ delete next.source;
585
+ delete next.sourceClass;
586
+ delete next.policyDecision;
587
+ return { creation: await saveLibraryEntry(next) };
588
+ }
589
+
590
+ async function createLabDocumentTool(args) {
591
+ let source = args.source;
592
+ if (args.source_id) {
593
+ source = await getAsset({ id: args.source_id, source: args.source_kind ?? 'official' });
594
+ }
595
+ return createLabDocument(args.lab, {
596
+ docKey: args.doc_key,
597
+ label: args.label,
598
+ preset: args.preset,
599
+ seed: args.seed,
600
+ source,
601
+ strength: args.strength,
602
+ style: args.style,
603
+ variation: args.variation,
604
+ });
605
+ }
606
+
607
+ async function mutateLabCreation(args) {
608
+ const id = String(args.id ?? '').trim();
609
+ const asset = await findEditableAsset(id, args.type ?? null);
610
+ if (!asset) throw new Error(`Editable creation "${id}" was not found.`);
611
+ const expectedType = getLabFeatures(args.lab).documentContract.creationType;
612
+ if (asset.type && asset.type !== expectedType && asset.kind !== expectedType) {
613
+ throw new Error(`The ${args.lab} lab requires creation type "${expectedType}", not "${asset.type ?? asset.kind}".`);
614
+ }
615
+ let document;
616
+ if (asset.source === 'workspace') {
617
+ if (!asset.relativePath?.startsWith('creations/')) {
618
+ throw new Error('Only JSON files below .toonlab/creations support semantic Lab mutation.');
619
+ }
620
+ const currentFile = await readWorkspaceFile(workspace, asset.relativePath);
621
+ try { document = JSON.parse(currentFile.data.toString('utf8')); } catch {
622
+ throw new Error('Workspace creation is not a JSON document.');
623
+ }
624
+ } else {
625
+ document = asset.document && typeof asset.document === 'object'
626
+ ? asset.document
627
+ : asset.recipe && typeof asset.recipe === 'object'
628
+ ? asset.recipe
629
+ : asset;
630
+ }
631
+ const next = applyLabDocumentOperation(args.lab, document, args.operation, args);
632
+ return updateCreation({ id, type: args.type ?? expectedType, document: next });
633
+ }
634
+
635
+ async function removeCreation(args) {
636
+ if (args.confirm !== true) throw new Error('confirm must be true to delete a creation.');
637
+ const id = String(args.id ?? '').trim();
638
+ const asset = await findEditableAsset(id, args.type ?? null);
639
+ if (!asset) throw new Error(`Editable creation "${id}" was not found.`);
640
+ if (asset.source === 'workspace') {
641
+ if (!asset.relativePath?.startsWith('creations/')) {
642
+ throw new Error('Only files below .toonlab/creations can be deleted as creations.');
643
+ }
644
+ return { deleted: await deleteWorkspaceFile(asset.relativePath), id };
645
+ }
646
+ return { deleted: await deleteLibraryEntry(asset, args.type ?? null), id };
647
+ }
648
+
649
+ function validLabStateKey(value) {
650
+ const key = String(value ?? '').trim();
651
+ if (!/^(?:toonlab|threejs-toon-shader)\.[a-z0-9._-]{1,240}$/i.test(key) || !isPersistableStorageKey(key)) {
652
+ throw new Error('Lab-state keys must be a non-secret ToonLab browser key using the "toonlab." or "threejs-toon-shader." prefix.');
653
+ }
654
+ return key;
655
+ }
656
+
657
+ function parseLabStateValue(value) {
658
+ try { return JSON.parse(value); } catch { return value; }
659
+ }
660
+
661
+ async function listLabState(args) {
662
+ const entries = await readLabStateEntries();
663
+ const query = String(args.query ?? '').trim().toLowerCase();
664
+ const items = Object.entries(entries)
665
+ .filter(([key]) => isPersistableStorageKey(key))
666
+ .filter(([key]) => !query || key.toLowerCase().includes(query))
667
+ .map(([key, value]) => ({ key, value: parseLabStateValue(value) }));
668
+ return { count: items.length, items };
669
+ }
670
+
671
+ async function getLabState(args) {
672
+ const key = validLabStateKey(args.key);
673
+ const entries = await readLabStateEntries();
674
+ if (!(key in entries)) throw new Error(`Lab-state entry "${key}" was not found.`);
675
+ return { key, value: parseLabStateValue(entries[key]) };
676
+ }
677
+
678
+ async function putLabState(args) {
679
+ const key = validLabStateKey(args.key);
680
+ if (args.value === undefined) throw new Error('value is required.');
681
+ const serialized = typeof args.value === 'string' ? args.value : JSON.stringify(args.value);
682
+ if (Buffer.byteLength(serialized, 'utf8') > 4 * 1024 * 1024) {
683
+ throw new Error('Lab-state value exceeds the 4 MB limit.');
684
+ }
685
+ await setLabStateEntry(key, serialized);
686
+ return { key, value: parseLabStateValue(serialized) };
687
+ }
688
+
689
+ async function removeLabState(args) {
690
+ if (args.confirm !== true) throw new Error('confirm must be true to delete lab state.');
691
+ const key = validLabStateKey(args.key);
692
+ const entries = await readLabStateEntries();
693
+ if (!(key in entries)) return { deleted: false, key };
694
+ await deleteLabStateEntry(key);
695
+ return { deleted: true, key };
696
+ }
697
+
192
698
  async function generateAsset(args) {
193
- const entry = builtinCatalogEntries().find((item) => item.id === args.catalog_id);
699
+ const entry = publicMcpCatalogEntries().find((item) => item.id === args.catalog_id);
194
700
  if (!entry) throw new Error(`Unknown built-in catalog asset "${args.catalog_id}".`);
701
+ const policyDecision = evaluateAssetCandidate(args.policy ?? null, {
702
+ domain: args.domain ?? entry.domain ?? entry.cluster ?? '',
703
+ sourceClass: 'procedural',
704
+ });
705
+ if (!policyDecision.allowed) throw new Error(policyDecision.reason);
195
706
  const seed = Number.isFinite(Number(args.seed)) ? Number(args.seed) : Math.floor(Math.random() * 1_000_000);
196
707
  const name = String(args.name ?? `${entry.label} ${seed}`);
197
708
  const document = {
@@ -216,6 +727,7 @@ async function generateAsset(args) {
216
727
  return {
217
728
  document,
218
729
  file,
730
+ policyDecision,
219
731
  next: entry.cluster === 'water' || entry.cluster === 'sky' || entry.cluster === 'post' || entry.cluster === 'toon'
220
732
  ? 'Use the spawn snippet in your project; this is a settings preset.'
221
733
  : 'Open the matching ToonLab lab to preview or export this recipe as GLB.',
@@ -234,6 +746,11 @@ function compactCc0Ref(ref) {
234
746
  source: ref.source,
235
747
  tags: ref.tags,
236
748
  thumbnailUrl: ref.thumbnailUrl,
749
+ animeStyleSupport: 'needs-in-scene-review',
750
+ assetKind: ref.kind,
751
+ license: ref.attribution?.license ?? 'CC0',
752
+ provenance: ref.attribution ?? null,
753
+ sourceClass: 'external-cc0',
237
754
  };
238
755
  }
239
756
 
@@ -267,15 +784,37 @@ async function searchCc0Assets(args) {
267
784
  const settled = await Promise.allSettled(searches);
268
785
  const results = settled.flatMap((result) => result.status === 'fulfilled' ? result.value : []);
269
786
  const errors = settled.flatMap((result) => result.status === 'rejected' ? [result.reason?.message ?? String(result.reason)] : []);
270
- return { count: Math.min(results.length, limit), errors, items: results.slice(0, limit).map(compactCc0Ref) };
787
+ return {
788
+ count: Math.min(results.length, limit),
789
+ errors,
790
+ items: results.slice(0, limit).map((ref) => ({
791
+ ...compactCc0Ref(ref),
792
+ policyDecision: evaluateAssetCandidate(args.policy ?? null, {
793
+ domain: args.domain ?? '',
794
+ sourceClass: 'external-cc0',
795
+ }),
796
+ })),
797
+ };
271
798
  }
272
799
 
273
- async function getCc0AssetDetails({ id, kind = 'model', provider, resolution = '1k' }) {
800
+ async function getCc0AssetDetails(args) {
801
+ const {
802
+ domain = '',
803
+ id,
804
+ kind = 'model',
805
+ policy = null,
806
+ provider,
807
+ resolution = '1k',
808
+ } = args;
809
+ const policyDecision = evaluateAssetCandidate(policy, {
810
+ domain,
811
+ sourceClass: 'external-cc0',
812
+ });
274
813
  if (provider === 'ambientcg') {
275
814
  const [ref] = await searchAmbientcg({ id });
276
815
  if (!ref) throw new Error(`ambientCG asset "${id}" was not found.`);
277
816
  const download = resolveAmbientcgDownload(ref, { resolution: resolution.toUpperCase() });
278
- return { download, ref: compactCc0Ref(ref) };
817
+ return { download, policyDecision, ref: compactCc0Ref(ref) };
279
818
  }
280
819
  if (provider === 'polyhaven') {
281
820
  const refs = await fetchPolyhavenIndex({ type: polyhavenType(kind) });
@@ -287,7 +826,7 @@ async function getCc0AssetDetails({ id, kind = 'model', provider, resolution = '
287
826
  : kind === 'texture'
288
827
  ? resolvePolyhavenTextureDownload(files, { resolution })
289
828
  : null;
290
- return { download, ref: compactCc0Ref(ref) };
829
+ return { download, policyDecision, ref: compactCc0Ref(ref) };
291
830
  }
292
831
  throw new Error('provider must be polyhaven or ambientcg.');
293
832
  }
@@ -307,6 +846,11 @@ function filenameFromUrl(url, fallback) {
307
846
  }
308
847
 
309
848
  async function importCc0Asset(args) {
849
+ const policyDecision = evaluateAssetCandidate(args.policy ?? null, {
850
+ domain: args.domain ?? '',
851
+ sourceClass: 'external-cc0',
852
+ });
853
+ if (!policyDecision.allowed) throw new Error(policyDecision.reason);
310
854
  const details = await getCc0AssetDetails(args);
311
855
  if (!details.download) {
312
856
  throw new Error('This asset kind does not yet expose a direct downloadable bundle. Use get_cc0_asset for its source page.');
@@ -332,10 +876,65 @@ async function importCc0Asset(args) {
332
876
  importedAt: new Date().toISOString(),
333
877
  ...details,
334
878
  }, null, 2)}\n`);
335
- return { ...details, files: [...files, manifest], workspace };
879
+ return { ...details, files: [...files, manifest], policyDecision, workspace };
880
+ }
881
+
882
+ async function recordAssetGap(args) {
883
+ const record = createAssetGapRecord(args);
884
+ const reportsDirectory = join(workspace, 'reports');
885
+ const jsonPath = join(reportsDirectory, 'style-asset-gaps.json');
886
+ const projectDirectory = basename(workspace) === '.toonlab'
887
+ ? dirname(workspace)
888
+ : workspace;
889
+ const markdownPath = join(projectDirectory, 'TOONLAB_ASSET_GAPS.md');
890
+ let records = [];
891
+ try {
892
+ const existing = JSON.parse(await readFile(jsonPath, 'utf8'));
893
+ records = Array.isArray(existing.records) ? existing.records : [];
894
+ } catch {
895
+ records = [];
896
+ }
897
+ const next = records.filter((entry) => entry.id !== record.id);
898
+ next.push(record);
899
+ next.sort((left, right) => left.id.localeCompare(right.id));
900
+ await mkdir(reportsDirectory, { recursive: true });
901
+ await writeFile(jsonPath, `${JSON.stringify({
902
+ records: next,
903
+ schema: 'toonlab/asset-gap-report',
904
+ version: 1,
905
+ }, null, 2)}\n`, 'utf8');
906
+ await writeFile(markdownPath, renderAssetGapReport(next), 'utf8');
907
+ return { jsonPath, markdownPath, record, total: next.length };
336
908
  }
337
909
 
338
910
  const TOOLS = [
911
+ ...['inspect', 'audit', 'plan', 'apply', 'verify'].map((operation) => ({
912
+ annotations: {
913
+ destructiveHint: false,
914
+ idempotentHint: true,
915
+ readOnlyHint: operation !== 'apply',
916
+ },
917
+ description: `${operation[0].toUpperCase()}${operation.slice(1)} a portable ToonLab scene-style manifest with the same contract used by the toonlab CLI.`,
918
+ inputSchema: {
919
+ additionalProperties: false,
920
+ properties: {
921
+ bundle: { default: 'call-me-sensei', type: ['string', 'object'] },
922
+ manifest: { type: 'object' },
923
+ mode: { default: 'advisory', enum: ['strict', 'advisory'], type: 'string' },
924
+ },
925
+ required: ['manifest'],
926
+ type: 'object',
927
+ },
928
+ name: `${operation}_scene_style`,
929
+ title: `${operation[0].toUpperCase()}${operation.slice(1)} scene style`,
930
+ })),
931
+ {
932
+ annotations: { readOnlyHint: true },
933
+ description: 'Return ToonLab\'s anime-game art direction, canonical Call Me Sensei bundle, and explicit shader-routing table.',
934
+ inputSchema: { additionalProperties: false, properties: {}, type: 'object' },
935
+ name: 'get_anime_game_profile',
936
+ title: 'Get ToonLab anime-game profile',
937
+ },
339
938
  {
340
939
  annotations: { readOnlyHint: true },
341
940
  description: 'Show the local .toonlab workspace path, migration status, and item counts.',
@@ -345,15 +944,61 @@ const TOOLS = [
345
944
  },
346
945
  {
347
946
  annotations: { readOnlyHint: true },
348
- description: 'Search built-in procedural assets, saved library entries, lab presets, and files on disk.',
947
+ description: 'List every public Beta Lab going live, its portable creation types, runtime package, management operations, and editable feature count.',
948
+ inputSchema: { additionalProperties: false, properties: {}, type: 'object' },
949
+ name: 'list_live_labs',
950
+ title: 'List live ToonLab labs',
951
+ },
952
+ {
953
+ annotations: { readOnlyHint: true },
954
+ description: 'Return the complete machine-readable feature/settings schema plus the portable document discriminator, version, identity paths, JSON envelope, and a valid starter document for one live lab.',
955
+ inputSchema: {
956
+ additionalProperties: false,
957
+ properties: { lab: { enum: LIVE_LAB_IDS, type: 'string' } },
958
+ required: ['lab'],
959
+ type: 'object',
960
+ },
961
+ name: 'get_lab_features',
962
+ title: 'Get all editable lab features',
963
+ },
964
+ {
965
+ annotations: { destructiveHint: false, idempotentHint: true, readOnlyHint: true },
966
+ description: 'Build a validated portable starter document for any live Lab. A Rock source_id returned by official asset search loads that GLB template as the editable starting mesh instead of generating unrelated geometry.',
967
+ inputSchema: {
968
+ additionalProperties: false,
969
+ properties: {
970
+ doc_key: { type: 'string' },
971
+ lab: { enum: LIVE_LAB_IDS, type: 'string' },
972
+ label: { type: 'string' },
973
+ preset: { type: 'string' },
974
+ seed: { type: 'integer' },
975
+ source: { type: 'object' },
976
+ source_id: { type: 'string' },
977
+ source_kind: { enum: ['official', 'library'], type: 'string' },
978
+ strength: { maximum: 1, minimum: 0, type: 'number' },
979
+ style: { type: 'string' },
980
+ variation: { minimum: 0, type: 'integer' },
981
+ },
982
+ required: ['lab'],
983
+ type: 'object',
984
+ },
985
+ name: 'create_lab_document',
986
+ title: 'Create a Lab starter document',
987
+ },
988
+ {
989
+ annotations: { readOnlyHint: true },
990
+ description: 'Search built-in procedural assets, the paginated complete official Gallery catalog, saved library entries, lab presets, and files on disk. Official rock summaries include compact dimensions and taxonomy metadata; follow nextOffset until null.',
349
991
  inputSchema: {
350
992
  additionalProperties: false,
351
993
  properties: {
352
994
  cluster: { type: 'string' },
995
+ domain: { type: 'string' },
353
996
  kind: { type: 'string' },
354
997
  limit: { maximum: 100, minimum: 1, type: 'integer' },
998
+ offset: { minimum: 0, type: 'integer' },
999
+ policy: { type: 'object' },
355
1000
  query: { type: 'string' },
356
- source: { enum: ['builtin', 'library', 'workspace', 'workspace-storage'], type: 'string' },
1001
+ source: { enum: ['builtin', 'official', 'library', 'workspace', 'workspace-storage'], type: 'string' },
357
1002
  tags: { items: { type: 'string' }, type: 'array' },
358
1003
  },
359
1004
  type: 'object',
@@ -366,7 +1011,12 @@ const TOOLS = [
366
1011
  description: 'Get a complete asset, recipe, preset, library entry, or workspace file descriptor by id.',
367
1012
  inputSchema: {
368
1013
  additionalProperties: false,
369
- properties: { id: { type: 'string' }, source: { type: 'string' } },
1014
+ properties: {
1015
+ domain: { type: 'string' },
1016
+ id: { type: 'string' },
1017
+ policy: { type: 'object' },
1018
+ source: { type: 'string' },
1019
+ },
370
1020
  required: ['id'],
371
1021
  type: 'object',
372
1022
  },
@@ -375,10 +1025,16 @@ const TOOLS = [
375
1025
  },
376
1026
  {
377
1027
  annotations: { readOnlyHint: true },
378
- description: 'List the developer\'s disk-backed library, saved lab documents, presets, imports, and exports.',
1028
+ description: 'Search the developer\'s saved library, lab documents, presets, imports, and exports by text, exact tags, or kind. Paginate with nextOffset.',
379
1029
  inputSchema: {
380
1030
  additionalProperties: false,
381
- properties: { limit: { type: 'integer' }, query: { type: 'string' } },
1031
+ properties: {
1032
+ kind: { type: 'string' },
1033
+ limit: { maximum: 200, minimum: 1, type: 'integer' },
1034
+ offset: { minimum: 0, type: 'integer' },
1035
+ query: { type: 'string' },
1036
+ tags: { items: { type: 'string' }, maxItems: 10, type: 'array' },
1037
+ },
382
1038
  type: 'object',
383
1039
  },
384
1040
  name: 'list_my_creations',
@@ -386,8 +1042,13 @@ const TOOLS = [
386
1042
  },
387
1043
  {
388
1044
  annotations: { readOnlyHint: true },
389
- description: 'Read a saved creation or small workspace file. Binary files are returned as base64 and always include a direct absolute path.',
390
- inputSchema: { additionalProperties: false, properties: { id: { type: 'string' } }, required: ['id'], type: 'object' },
1045
+ description: 'Read a saved creation or small workspace file. Prefer the immutable managementId returned by list_my_creations; type disambiguates legacy document keys. Binary files are returned as base64 and always include a direct absolute path.',
1046
+ inputSchema: {
1047
+ additionalProperties: false,
1048
+ properties: { id: { type: 'string' }, type: { type: 'string' } },
1049
+ required: ['id'],
1050
+ type: 'object',
1051
+ },
391
1052
  name: 'get_my_creation',
392
1053
  title: 'Get my ToonLab creation',
393
1054
  },
@@ -398,9 +1059,11 @@ const TOOLS = [
398
1059
  additionalProperties: false,
399
1060
  properties: {
400
1061
  document: {},
1062
+ description: { type: ['string', 'null'] },
401
1063
  filename: { type: 'string' },
402
1064
  kind: { type: 'string' },
403
1065
  name: { type: 'string' },
1066
+ tags: { items: { maxLength: 32, type: 'string' }, maxItems: 10, type: 'array' },
404
1067
  },
405
1068
  required: ['document', 'name'],
406
1069
  type: 'object',
@@ -408,6 +1071,116 @@ const TOOLS = [
408
1071
  name: 'save_creation',
409
1072
  title: 'Save a ToonLab creation',
410
1073
  },
1074
+ {
1075
+ annotations: { destructiveHint: false, idempotentHint: true },
1076
+ description: 'Replace or JSON-merge-patch any editable creation in the local OSS library. Local workspaces have no ownership boundary.',
1077
+ inputSchema: {
1078
+ additionalProperties: false,
1079
+ properties: {
1080
+ description: { type: ['string', 'null'] },
1081
+ document: { type: 'object' },
1082
+ id: { description: 'Immutable managementId from list_my_creations, or an unambiguous document key.', type: 'string' },
1083
+ label: { type: 'string' },
1084
+ patch: { description: 'RFC 7396 JSON merge patch applied to the portable document.', type: 'object' },
1085
+ tags: { items: { maxLength: 32, type: 'string' }, maxItems: 10, type: 'array' },
1086
+ type: { description: 'Creation type used to disambiguate a legacy document key.', type: 'string' },
1087
+ },
1088
+ required: ['id'],
1089
+ type: 'object',
1090
+ },
1091
+ name: 'update_creation',
1092
+ title: 'Update any local creation',
1093
+ },
1094
+ {
1095
+ annotations: { destructiveHint: false, idempotentHint: false },
1096
+ description: 'Apply one validated Lab operation to a saved portable creation. Supports set_feature for all 15 Labs and structural Rock operations advertised by get_lab_features.',
1097
+ inputSchema: {
1098
+ additionalProperties: false,
1099
+ properties: {
1100
+ edit: { type: 'object' },
1101
+ finish: { type: 'string' },
1102
+ id: { type: 'string' },
1103
+ lab: { enum: LIVE_LAB_IDS, type: 'string' },
1104
+ operation: { type: 'string' },
1105
+ path: { type: 'string' },
1106
+ piece: {},
1107
+ pieceId: { type: 'string' },
1108
+ pieceIndex: { minimum: 0, type: 'integer' },
1109
+ settings: { type: 'object' },
1110
+ source: { type: 'object' },
1111
+ toIndex: { minimum: 0, type: 'integer' },
1112
+ type: { type: 'string' },
1113
+ value: {},
1114
+ },
1115
+ required: ['id', 'lab', 'operation'],
1116
+ type: 'object',
1117
+ },
1118
+ name: 'mutate_lab_creation',
1119
+ title: 'Apply a semantic Lab edit',
1120
+ },
1121
+ {
1122
+ annotations: { destructiveHint: true, idempotentHint: true },
1123
+ description: 'Delete any editable creation from the local OSS library. Requires confirm=true.',
1124
+ inputSchema: {
1125
+ additionalProperties: false,
1126
+ properties: {
1127
+ confirm: { const: true, type: 'boolean' },
1128
+ id: { description: 'Immutable managementId from list_my_creations, or an unambiguous document key.', type: 'string' },
1129
+ type: { description: 'Creation type used to disambiguate a legacy document key.', type: 'string' },
1130
+ },
1131
+ required: ['id', 'confirm'],
1132
+ type: 'object',
1133
+ },
1134
+ name: 'delete_creation',
1135
+ title: 'Delete any local creation',
1136
+ },
1137
+ {
1138
+ annotations: { readOnlyHint: true },
1139
+ description: 'List raw persisted lab-state entries. This OSS-only surface covers drafts and lab collections that are not yet normalized creations.',
1140
+ inputSchema: {
1141
+ additionalProperties: false,
1142
+ properties: { query: { type: 'string' } },
1143
+ type: 'object',
1144
+ },
1145
+ name: 'list_lab_state',
1146
+ title: 'List local lab state',
1147
+ },
1148
+ {
1149
+ annotations: { readOnlyHint: true },
1150
+ description: 'Read one raw persisted ToonLab lab-state entry by its localStorage-compatible key.',
1151
+ inputSchema: {
1152
+ additionalProperties: false,
1153
+ properties: { key: { type: 'string' } },
1154
+ required: ['key'],
1155
+ type: 'object',
1156
+ },
1157
+ name: 'get_lab_state',
1158
+ title: 'Get local lab state',
1159
+ },
1160
+ {
1161
+ annotations: { destructiveHint: false, idempotentHint: true },
1162
+ description: 'Create or replace any non-secret ToonLab lab-state entry in the local OSS workspace.',
1163
+ inputSchema: {
1164
+ additionalProperties: false,
1165
+ properties: { key: { type: 'string' }, value: {} },
1166
+ required: ['key', 'value'],
1167
+ type: 'object',
1168
+ },
1169
+ name: 'set_lab_state',
1170
+ title: 'Set local lab state',
1171
+ },
1172
+ {
1173
+ annotations: { destructiveHint: true, idempotentHint: true },
1174
+ description: 'Delete one raw lab-state entry from the local OSS workspace. Requires confirm=true.',
1175
+ inputSchema: {
1176
+ additionalProperties: false,
1177
+ properties: { confirm: { const: true, type: 'boolean' }, key: { type: 'string' } },
1178
+ required: ['key', 'confirm'],
1179
+ type: 'object',
1180
+ },
1181
+ name: 'delete_lab_state',
1182
+ title: 'Delete local lab state',
1183
+ },
411
1184
  {
412
1185
  annotations: { destructiveHint: false, idempotentHint: false },
413
1186
  description: 'Generate a deterministic editable asset recipe from a built-in ToonLab catalog entry and optionally save it to disk.',
@@ -415,7 +1188,9 @@ const TOOLS = [
415
1188
  additionalProperties: false,
416
1189
  properties: {
417
1190
  catalog_id: { type: 'string' },
1191
+ domain: { type: 'string' },
418
1192
  name: { type: 'string' },
1193
+ policy: { type: 'object' },
419
1194
  save: { default: true, type: 'boolean' },
420
1195
  seed: { type: 'integer' },
421
1196
  },
@@ -425,14 +1200,83 @@ const TOOLS = [
425
1200
  name: 'generate_asset',
426
1201
  title: 'Generate a procedural ToonLab asset',
427
1202
  },
1203
+ {
1204
+ annotations: { destructiveHint: false, idempotentHint: false, openWorldHint: true },
1205
+ description: 'Start local managed image/3D generation with user-configured provider keys. Meshy 7 supports image/multiview-to-3D; text_to_model + Meshy first creates a concept image with image_model, then submits that PNG/JPEG to Meshy as one trackable job.',
1206
+ inputSchema: {
1207
+ additionalProperties: false,
1208
+ properties: {
1209
+ aspect_ratio: { default: '1:1', enum: ['1:1', '16:9', '9:16', '4:3', '3:4'], type: 'string' },
1210
+ domain: { maxLength: 120, minLength: 1, type: 'string' },
1211
+ gap_id: { description: 'ID returned by record_asset_gap.', minLength: 1, type: 'string' },
1212
+ image_model: { enum: ['nano-banana-2-lite', 'nano-banana-2', 'nano-banana-pro'], type: 'string' },
1213
+ kind: { enum: ['image', 'texture_image', 'concept_image', 'text_to_model', 'image_to_model', 'multiview_to_model', 'model_segment'], type: 'string' },
1214
+ model_provider: { default: 'meshy', enum: ['meshy', 'tripo'], type: 'string' },
1215
+ policy: { description: 'Developer-approved asset-sourcing policy.', type: 'object' },
1216
+ prompt: { maxLength: 600, type: 'string' },
1217
+ reference_paths: { items: { type: 'string' }, maxItems: 6, type: 'array' },
1218
+ resolution: { default: '1k', enum: ['1k', '2k', '4k'], type: 'string' },
1219
+ source_image_path: { description: 'Workspace object path for image_to_model.', type: 'string' },
1220
+ source_job_id: { description: 'Succeeded image job for image_to_model, or Tripo model job for model_segment.', type: 'string' },
1221
+ style: { default: 'stylized', enum: ['stylized', 'cartoon', 'raw'], type: 'string' },
1222
+ view_paths: { description: 'multiview_to_model only: [front, left, back, right]. Front plus at least one other view is required.', items: { type: ['string', 'null'] }, maxItems: 4, type: 'array' },
1223
+ },
1224
+ required: ['kind', 'domain', 'policy', 'gap_id'],
1225
+ type: 'object',
1226
+ },
1227
+ name: 'generate_ai_asset',
1228
+ title: 'Generate an image or 3D asset with local provider keys',
1229
+ },
1230
+ {
1231
+ annotations: { readOnlyHint: true, openWorldHint: true },
1232
+ description: 'Poll one local managed generation job. Async Meshy/Tripo tasks are advanced and completed provider files are downloaded into the local workspace.',
1233
+ inputSchema: {
1234
+ additionalProperties: false,
1235
+ properties: { job_id: { type: 'string' } },
1236
+ required: ['job_id'],
1237
+ type: 'object',
1238
+ },
1239
+ name: 'get_generation_job',
1240
+ title: 'Get a local generation job',
1241
+ },
1242
+ {
1243
+ annotations: { readOnlyHint: true, openWorldHint: true },
1244
+ description: 'Poll up to 20 known local generation jobs, or list recent jobs when job_ids is omitted.',
1245
+ inputSchema: {
1246
+ additionalProperties: false,
1247
+ properties: {
1248
+ job_ids: { items: { type: 'string' }, maxItems: 20, minItems: 1, type: 'array' },
1249
+ kind: { type: 'string' },
1250
+ limit: { maximum: 100, minimum: 1, type: 'integer' },
1251
+ query: { type: 'string' },
1252
+ },
1253
+ type: 'object',
1254
+ },
1255
+ name: 'get_generation_jobs',
1256
+ title: 'Get local generation jobs',
1257
+ },
1258
+ {
1259
+ annotations: { destructiveHint: false, idempotentHint: true },
1260
+ description: 'Save a succeeded local 3D generation job into the editable ToonLab library with its provider provenance and local model file.',
1261
+ inputSchema: {
1262
+ additionalProperties: false,
1263
+ properties: { job_id: { type: 'string' }, label: { maxLength: 120, type: 'string' } },
1264
+ required: ['job_id'],
1265
+ type: 'object',
1266
+ },
1267
+ name: 'save_generated_asset',
1268
+ title: 'Save a generated 3D asset',
1269
+ },
428
1270
  {
429
1271
  annotations: { openWorldHint: true, readOnlyHint: true },
430
1272
  description: 'Search CC0 models, textures, or HDRIs from Poly Haven and ambientCG.',
431
1273
  inputSchema: {
432
1274
  additionalProperties: false,
433
1275
  properties: {
1276
+ domain: { type: 'string' },
434
1277
  kind: { enum: ['model', 'texture', 'hdri'], type: 'string' },
435
1278
  limit: { maximum: 50, minimum: 1, type: 'integer' },
1279
+ policy: { type: 'object' },
436
1280
  provider: { enum: ['all', 'polyhaven', 'ambientcg'], type: 'string' },
437
1281
  query: { type: 'string' },
438
1282
  },
@@ -447,8 +1291,10 @@ const TOOLS = [
447
1291
  inputSchema: {
448
1292
  additionalProperties: false,
449
1293
  properties: {
1294
+ domain: { type: 'string' },
450
1295
  id: { type: 'string' },
451
1296
  kind: { enum: ['model', 'texture', 'hdri'], type: 'string' },
1297
+ policy: { type: 'object' },
452
1298
  provider: { enum: ['polyhaven', 'ambientcg'], type: 'string' },
453
1299
  resolution: { default: '1k', type: 'string' },
454
1300
  },
@@ -464,8 +1310,10 @@ const TOOLS = [
464
1310
  inputSchema: {
465
1311
  additionalProperties: false,
466
1312
  properties: {
1313
+ domain: { type: 'string' },
467
1314
  id: { type: 'string' },
468
1315
  kind: { enum: ['model', 'texture', 'hdri'], type: 'string' },
1316
+ policy: { type: 'object' },
469
1317
  provider: { enum: ['polyhaven', 'ambientcg'], type: 'string' },
470
1318
  resolution: { default: '1k', type: 'string' },
471
1319
  },
@@ -475,6 +1323,54 @@ const TOOLS = [
475
1323
  name: 'import_cc0_asset',
476
1324
  title: 'Import a public CC0 asset',
477
1325
  },
1326
+ {
1327
+ annotations: { readOnlyHint: true },
1328
+ description: 'Validate a strict, advisory, or open sourcing policy and evaluate whether one candidate may be selected.',
1329
+ inputSchema: {
1330
+ additionalProperties: false,
1331
+ properties: {
1332
+ candidate: {
1333
+ additionalProperties: false,
1334
+ properties: {
1335
+ domain: { type: 'string' },
1336
+ sourceClass: { enum: ASSET_SOURCE_CLASSES, type: 'string' },
1337
+ },
1338
+ required: ['domain', 'sourceClass'],
1339
+ type: 'object',
1340
+ },
1341
+ policy: { type: 'object' },
1342
+ },
1343
+ required: ['candidate'],
1344
+ type: 'object',
1345
+ },
1346
+ name: 'validate_asset_candidate',
1347
+ title: 'Validate an asset candidate',
1348
+ },
1349
+ {
1350
+ annotations: { destructiveHint: false, idempotentHint: true },
1351
+ description: 'Record why a custom shader or asset was required and regenerate JSON plus Markdown feedback reports.',
1352
+ inputSchema: {
1353
+ additionalProperties: false,
1354
+ properties: {
1355
+ approvedBy: { type: ['string', 'null'] },
1356
+ attempts: { items: { type: 'object' }, type: 'array' },
1357
+ bundleSlot: { type: ['string', 'null'] },
1358
+ customImplementation: {},
1359
+ domain: { type: 'string' },
1360
+ feedbackNeeded: { type: 'string' },
1361
+ id: { type: 'string' },
1362
+ kind: { type: 'string' },
1363
+ provenance: {},
1364
+ reason: { type: 'string' },
1365
+ status: { type: 'string' },
1366
+ targetId: { type: ['string', 'null'] },
1367
+ },
1368
+ required: ['id', 'domain', 'kind', 'reason'],
1369
+ type: 'object',
1370
+ },
1371
+ name: 'record_asset_gap',
1372
+ title: 'Record a custom asset or shader gap',
1373
+ },
478
1374
  {
479
1375
  annotations: { readOnlyHint: true },
480
1376
  description: 'Explain what asset generation is available in the open-source local server.',
@@ -482,41 +1378,108 @@ const TOOLS = [
482
1378
  name: 'get_generation_capabilities',
483
1379
  title: 'Get local generation capabilities',
484
1380
  },
485
- ...STYLE_LAB_TOOLS,
486
1381
  ];
487
1382
 
488
1383
  async function callTool(name, args = {}) {
489
1384
  switch (name) {
1385
+ case 'inspect_scene_style': return runSceneStyleOperation('inspect', args.manifest, args);
1386
+ case 'audit_scene_style': return runSceneStyleOperation('audit', args.manifest, args);
1387
+ case 'plan_scene_style': return runSceneStyleOperation('plan', args.manifest, args);
1388
+ case 'apply_scene_style': return runSceneStyleOperation('apply', args.manifest, args);
1389
+ case 'verify_scene_style': return runSceneStyleOperation('verify', args.manifest, args);
1390
+ case 'get_anime_game_profile': return {
1391
+ artDirection: TOONLAB_ANIME_GAME_PROFILE,
1392
+ defaultStyleBundle: CALL_ME_SENSEI_STYLE_BUNDLE,
1393
+ product: 'Anime-style game, character, and environment development for Three.js',
1394
+ routing: STYLE_DOMAIN_SLOT_ROUTES,
1395
+ };
490
1396
  case 'get_workspace_info': return getWorkspaceInfo(workspace);
1397
+ case 'list_live_labs': return listLiveLabs();
1398
+ case 'get_lab_features': return getLabFeatures(args.lab);
1399
+ case 'create_lab_document': return createLabDocumentTool(args);
491
1400
  case 'search_assets': return searchAssets(args);
492
1401
  case 'get_asset': return getAsset(args);
493
1402
  case 'list_my_creations': return listMyCreations(args);
494
1403
  case 'get_my_creation': return getMyCreation(args);
495
1404
  case 'save_creation': return saveCreation(workspace, args);
1405
+ case 'update_creation': return updateCreation(args);
1406
+ case 'mutate_lab_creation': return mutateLabCreation(args);
1407
+ case 'delete_creation': return removeCreation(args);
1408
+ case 'list_lab_state': return listLabState(args);
1409
+ case 'get_lab_state': return getLabState(args);
1410
+ case 'set_lab_state': return putLabState(args);
1411
+ case 'delete_lab_state': return removeLabState(args);
496
1412
  case 'generate_asset': return generateAsset(args);
1413
+ case 'generate_ai_asset': {
1414
+ if (!String(args.gap_id ?? '').trim()) throw new Error('record_asset_gap is required before managed generation.');
1415
+ const policyDecision = evaluateAssetCandidate(args.policy ?? null, {
1416
+ domain: args.domain ?? '',
1417
+ sourceClass: 'custom',
1418
+ });
1419
+ if (!policyDecision.allowed) throw new Error(policyDecision.reason);
1420
+ const job = await startManagedGeneration(workspace, args);
1421
+ return {
1422
+ job,
1423
+ policyDecision,
1424
+ pollAfterMs: 5_000,
1425
+ next: job.status === 'running'
1426
+ ? 'Poll get_generation_job until succeeded, failed, or cancelled; then pass a succeeded 3D job to save_generated_asset.'
1427
+ : 'The provider completed inline. Save a succeeded 3D job with save_generated_asset.',
1428
+ };
1429
+ }
1430
+ case 'get_generation_job': {
1431
+ const job = await getManagedGeneration(workspace, String(args.job_id ?? ''));
1432
+ if (!job) throw new Error('Generation job not found.');
1433
+ return { job, pollAfterMs: job.status === 'running' ? 5_000 : null };
1434
+ }
1435
+ case 'get_generation_jobs': {
1436
+ const ids = Array.isArray(args.job_ids) ? [...new Set(args.job_ids.map(String))].slice(0, 20) : [];
1437
+ const jobs = ids.length
1438
+ ? (await Promise.all(ids.map((id) => getManagedGeneration(workspace, id)))).filter(Boolean)
1439
+ : await listManagedGenerations({ kind: args.kind ?? '', limit: args.limit ?? 60, q: args.query ?? '' });
1440
+ return { jobs, pollAfterMs: jobs.some((job) => job.status === 'running') ? 5_000 : null };
1441
+ }
1442
+ case 'save_generated_asset': return {
1443
+ creation: await saveManagedGeneration(String(args.job_id ?? ''), { label: args.label }),
1444
+ };
497
1445
  case 'search_cc0_assets': return searchCc0Assets(args);
498
1446
  case 'get_cc0_asset': return getCc0AssetDetails(args);
499
1447
  case 'import_cc0_asset': return importCc0Asset(args);
1448
+ case 'validate_asset_candidate': {
1449
+ const policyValidation = args.policy
1450
+ ? validateAssetSourcingPolicy(args.policy)
1451
+ : { ok: true, value: null };
1452
+ return {
1453
+ availableModes: ASSET_POLICY_MODES,
1454
+ policyValidation,
1455
+ result: policyValidation.ok
1456
+ ? evaluateAssetCandidate(policyValidation.value, args.candidate)
1457
+ : { allowed: false, decision: 'deny', reason: policyValidation.errors.join(' ') },
1458
+ };
1459
+ }
1460
+ case 'record_asset_gap': return recordAssetGap(args);
500
1461
  case 'get_generation_capabilities': return {
1462
+ managedLocal: {
1463
+ ...providerConfiguration(),
1464
+ kinds: ['image', 'texture_image', 'concept_image', 'text_to_model', 'image_to_model', 'multiview_to_model', 'model_segment'],
1465
+ meshyTextFlow: 'selected image_model concept_image -> meshy-7 image_to_model',
1466
+ tools: ['generate_ai_asset', 'get_generation_job', 'get_generation_jobs', 'save_generated_asset'],
1467
+ },
501
1468
  available: [
502
- 'Generate deterministic recipes from every built-in ToonLab catalog entry.',
503
- 'Author, validate, and batch-resolve open-domain recipes for the generative style domains (post, camera, game feel, lighting styles, light fixtures).',
1469
+ 'Generate deterministic recipes from the stable public ToonLab catalog entries.',
504
1470
  'Save and retrieve editable lab documents through the shared .toonlab workspace.',
505
1471
  'Search and import CC0 assets from Poly Haven and ambientCG.',
506
1472
  'Use each recipe\'s spawn snippet to integrate it into a Three.js project.',
507
1473
  ],
1474
+ unsupportedStyleDomains: ['lighting', 'vfx', 'renderer'],
508
1475
  hostedProAdds: [
509
- 'Managed image and 3D model generation providers',
1476
+ 'Hosted provider keys, credit billing, and durable background workers',
510
1477
  'Cloud library and cross-device sync',
511
1478
  'Remote Streamable HTTP transport with OAuth',
512
1479
  ],
513
1480
  mode: 'open-source-local',
514
1481
  };
515
- default:
516
- if (isStyleLabTool(name)) {
517
- return callStyleLabTool(name, args, { saveCreation, workspace });
518
- }
519
- throw new Error(`Unknown tool "${name}".`);
1482
+ default: throw new Error(`Unknown tool "${name}".`);
520
1483
  }
521
1484
  }
522
1485
 
@@ -555,7 +1518,7 @@ async function handleRequest(message) {
555
1518
  jsonrpc: '2.0',
556
1519
  result: {
557
1520
  capabilities: { resources: {}, tools: {} },
558
- instructions: 'Use ToonLab to search public and private assets, create deterministic recipes, import CC0 files, and work with the local .toonlab workspace.',
1521
+ instructions: 'ToonLab builds anime-style games, characters, and environments for Three.js. Call list_live_labs and get_lab_features when authoring a Lab artifact, use create_lab_document for a valid starter, and prefer mutate_lab_creation over hand-editing structural arrays. Official Rock details include a source-GLB starter. This OSS server may edit any non-secret creation or lab-state entry in its local workspace; deletions require explicit confirmation. Load the selected style bundle first. If no asset-sourcing policy exists, ask the developer, then continue with library-first advisory discovery while recording the unresolved decision. Search the project and ToonLab libraries before public sources; generate or hand-author only when policy permits. Validate every candidate, preserve provenance, evaluate anime-fit in scene, and record a gap before adding a custom shader, texture, model, or adapter. When local provider keys are configured, generate_ai_asset exposes image generation, Meshy 7 image/multiview-to-3D, and Text -> selected image model -> Meshy 7 through MCP.',
559
1522
  protocolVersion: SUPPORTED_PROTOCOL_VERSIONS.has(requested) ? requested : LATEST_PROTOCOL_VERSION,
560
1523
  serverInfo: { name: SERVER_NAME, version: SERVER_VERSION },
561
1524
  },