@holoscript/core 6.0.4 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +3 -2
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/index.d.ts +501 -19
  7. package/dist/paper-0c-spike/index.d.ts +29 -0
  8. package/dist/reconstruction/index.d.ts +78 -0
  9. package/dist/tools/index.d.ts +22 -1
  10. package/dist/traitDocs/traitDocs.d.ts +69 -0
  11. package/dist/traits/index.d.ts +61 -0
  12. package/package.json +105 -57
  13. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  14. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  15. package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
  16. package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
  17. package/dist/USDZExporter-NTMBNTDB.js +0 -707
  18. package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
  19. package/dist/chunk-27LWW5FU.cjs +0 -410
  20. package/dist/chunk-2CWOLHTE.js +0 -69
  21. package/dist/chunk-33LSUQDD.cjs +0 -835
  22. package/dist/chunk-3FJCK5XA.js +0 -2232
  23. package/dist/chunk-3FXV5S25.cjs +0 -633
  24. package/dist/chunk-3FYZOR7S.cjs +0 -69
  25. package/dist/chunk-3SAK5KFL.cjs +0 -83
  26. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  27. package/dist/chunk-54FHG2MX.js +0 -655
  28. package/dist/chunk-56IF4NTA.js +0 -56
  29. package/dist/chunk-5BGSECRJ.cjs +0 -2237
  30. package/dist/chunk-5GLCTO44.js +0 -161
  31. package/dist/chunk-5O6TQC6M.cjs +0 -1871
  32. package/dist/chunk-5OEOHAAW.cjs +0 -682
  33. package/dist/chunk-5TOFIR6L.js +0 -407
  34. package/dist/chunk-5WUNN6ZN.cjs +0 -428
  35. package/dist/chunk-6TZPZCOJ.cjs +0 -1404
  36. package/dist/chunk-6UEHYZ7V.cjs +0 -773
  37. package/dist/chunk-6XSERL6L.js +0 -5678
  38. package/dist/chunk-72EQECGT.cjs +0 -908
  39. package/dist/chunk-7AGYRWKW.cjs +0 -507
  40. package/dist/chunk-7LCYLPW2.cjs +0 -663
  41. package/dist/chunk-A7PIMZGU.js +0 -263
  42. package/dist/chunk-ATSKSYVE.cjs +0 -51683
  43. package/dist/chunk-B5TCIAPQ.cjs +0 -117
  44. package/dist/chunk-BF2235SI.cjs +0 -5714
  45. package/dist/chunk-BKIGPPVM.js +0 -629
  46. package/dist/chunk-BND3ST2K.cjs +0 -662
  47. package/dist/chunk-BU7VWW2K.js +0 -2522
  48. package/dist/chunk-BWFJEM5A.js +0 -5419
  49. package/dist/chunk-CAUCGUEA.cjs +0 -130
  50. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  51. package/dist/chunk-CDPGV4DN.js +0 -114
  52. package/dist/chunk-CLYEIWA5.cjs +0 -408
  53. package/dist/chunk-CS2EMTGF.js +0 -1966
  54. package/dist/chunk-DMG7C4H2.js +0 -975
  55. package/dist/chunk-DXJQDCFL.js +0 -468
  56. package/dist/chunk-E3FWRT3Z.js +0 -608
  57. package/dist/chunk-E3UALNFA.js +0 -421
  58. package/dist/chunk-EONILVMF.js +0 -762
  59. package/dist/chunk-EQV4R3EV.cjs +0 -769
  60. package/dist/chunk-F3HH56EB.cjs +0 -5538
  61. package/dist/chunk-F4IULT7N.js +0 -1488
  62. package/dist/chunk-FF3Q7ADR.js +0 -380
  63. package/dist/chunk-FFKU7BTK.cjs +0 -1046
  64. package/dist/chunk-FHQVYCH2.js +0 -70
  65. package/dist/chunk-FSF7EQVA.cjs +0 -1974
  66. package/dist/chunk-G4VZTCIB.js +0 -659
  67. package/dist/chunk-G7CT3EMP.cjs +0 -1002
  68. package/dist/chunk-GGHSW2NN.js +0 -51334
  69. package/dist/chunk-GVUR45UF.cjs +0 -777
  70. package/dist/chunk-H5Z7NASB.js +0 -9662
  71. package/dist/chunk-HE7ULERA.cjs +0 -697
  72. package/dist/chunk-HJJLD366.js +0 -1169
  73. package/dist/chunk-HPS76H7Q.js +0 -309
  74. package/dist/chunk-HQUEA5R6.cjs +0 -424
  75. package/dist/chunk-HYNTS5CP.js +0 -422
  76. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  77. package/dist/chunk-IBDG74G2.cjs +0 -1219
  78. package/dist/chunk-IFNQFCTM.js +0 -3098
  79. package/dist/chunk-IHOUYQIA.js +0 -406
  80. package/dist/chunk-ILRBGFVD.cjs +0 -72
  81. package/dist/chunk-IWI6J7FX.js +0 -421
  82. package/dist/chunk-K3JDKWGI.cjs +0 -270
  83. package/dist/chunk-K6EKD26I.js +0 -630
  84. package/dist/chunk-KCQ5NDYC.cjs +0 -3172
  85. package/dist/chunk-KED34ILP.js +0 -832
  86. package/dist/chunk-KSGXLT74.cjs +0 -457
  87. package/dist/chunk-L4G4RLXX.js +0 -767
  88. package/dist/chunk-LDP5OK6G.js +0 -1216
  89. package/dist/chunk-LGGRPKTV.cjs +0 -735
  90. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  91. package/dist/chunk-LSW7P7ML.js +0 -3675
  92. package/dist/chunk-LXJ4667L.cjs +0 -3874
  93. package/dist/chunk-LZ266PCM.cjs +0 -4499
  94. package/dist/chunk-MD6KDHVE.cjs +0 -237
  95. package/dist/chunk-MEASWI2Y.js +0 -126
  96. package/dist/chunk-MPXBVFHQ.js +0 -768
  97. package/dist/chunk-N5FTS757.cjs +0 -415
  98. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  99. package/dist/chunk-NDQNIJEH.js +0 -1715
  100. package/dist/chunk-NOZZ46QU.js +0 -168
  101. package/dist/chunk-OFKWH2IP.js +0 -449
  102. package/dist/chunk-PHENW4MQ.js +0 -65
  103. package/dist/chunk-PMGODDJA.cjs +0 -319
  104. package/dist/chunk-Q4QX3AET.cjs +0 -1505
  105. package/dist/chunk-Q56TT7IL.js +0 -483
  106. package/dist/chunk-Q5JT3YML.cjs +0 -129
  107. package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
  108. package/dist/chunk-QGKNANZ3.js +0 -3071
  109. package/dist/chunk-QLEAOI3Q.cjs +0 -424
  110. package/dist/chunk-R7MA7QWV.js +0 -732
  111. package/dist/chunk-RVYPEYPX.js +0 -678
  112. package/dist/chunk-S2N5TNMA.js +0 -1855
  113. package/dist/chunk-S565K7NK.js +0 -752
  114. package/dist/chunk-SDAMZIRE.js +0 -765
  115. package/dist/chunk-T36DDXSF.js +0 -4250
  116. package/dist/chunk-T4NKMBDL.js +0 -5474
  117. package/dist/chunk-T7LEXZUZ.cjs +0 -2526
  118. package/dist/chunk-TEWCN33Y.js +0 -694
  119. package/dist/chunk-TQSZUOW5.cjs +0 -793
  120. package/dist/chunk-TSH3MSQU.cjs +0 -129
  121. package/dist/chunk-UERJ3YJV.js +0 -504
  122. package/dist/chunk-UPJBDCVF.js +0 -1395
  123. package/dist/chunk-V3NN3HPP.js +0 -4462
  124. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  125. package/dist/chunk-WB4Z63GG.js +0 -229
  126. package/dist/chunk-WDW67DZB.cjs +0 -9728
  127. package/dist/chunk-WGMEAYBG.js +0 -126
  128. package/dist/chunk-X4ZF6CNE.cjs +0 -473
  129. package/dist/chunk-X6SEAXAX.cjs +0 -3681
  130. package/dist/chunk-XCWFGZAA.js +0 -1043
  131. package/dist/chunk-XD6IYDUX.js +0 -903
  132. package/dist/chunk-XG23EUQX.cjs +0 -1717
  133. package/dist/chunk-XRKWN5PL.cjs +0 -173
  134. package/dist/chunk-XUILI4KB.cjs +0 -430
  135. package/dist/chunk-XUTX5CBW.js +0 -126
  136. package/dist/chunk-XWPNTWDN.cjs +0 -755
  137. package/dist/chunk-XXINBTZK.cjs +0 -633
  138. package/dist/chunk-YCXFCXDS.js +0 -1868
  139. package/dist/chunk-YQK5JNFK.js +0 -3725
  140. package/dist/chunk-YYXH45E2.js +0 -426
  141. package/dist/chunk-Z34RLXRA.cjs +0 -612
  142. package/dist/chunk-ZP4D3CSX.cjs +0 -72
  143. package/dist/cli/holoscript-runner.cjs +0 -2259
  144. package/dist/cli/holoscript-runner.js +0 -2234
  145. package/dist/codebase/index.cjs +0 -336
  146. package/dist/codebase/index.js +0 -331
  147. package/dist/compiler/agent-inference.cjs +0 -28
  148. package/dist/compiler/agent-inference.js +0 -5
  149. package/dist/compiler/android-xr.cjs +0 -19
  150. package/dist/compiler/android-xr.js +0 -9
  151. package/dist/compiler/android.cjs +0 -20
  152. package/dist/compiler/android.js +0 -10
  153. package/dist/compiler/ar.cjs +0 -20
  154. package/dist/compiler/ar.js +0 -8
  155. package/dist/compiler/babylon.cjs +0 -17
  156. package/dist/compiler/babylon.js +0 -11
  157. package/dist/compiler/coco.cjs +0 -27
  158. package/dist/compiler/coco.js +0 -4
  159. package/dist/compiler/domain-block-utils.cjs +0 -602
  160. package/dist/compiler/domain-block-utils.js +0 -8
  161. package/dist/compiler/dtdl.cjs +0 -24
  162. package/dist/compiler/dtdl.js +0 -8
  163. package/dist/compiler/gltf-pipeline.cjs +0 -39
  164. package/dist/compiler/gltf-pipeline.js +0 -4
  165. package/dist/compiler/godot.cjs +0 -15
  166. package/dist/compiler/godot.js +0 -9
  167. package/dist/compiler/incremental.cjs +0 -29
  168. package/dist/compiler/incremental.js +0 -4
  169. package/dist/compiler/index.cjs +0 -2578
  170. package/dist/compiler/index.js +0 -2383
  171. package/dist/compiler/ios.cjs +0 -20
  172. package/dist/compiler/ios.js +0 -10
  173. package/dist/compiler/multi-layer.cjs +0 -20
  174. package/dist/compiler/multi-layer.js +0 -11
  175. package/dist/compiler/nodetoy.cjs +0 -23
  176. package/dist/compiler/nodetoy.js +0 -4
  177. package/dist/compiler/openxr.cjs +0 -15
  178. package/dist/compiler/openxr.js +0 -9
  179. package/dist/compiler/playcanvas.cjs +0 -16
  180. package/dist/compiler/playcanvas.js +0 -10
  181. package/dist/compiler/r3f.cjs +0 -34
  182. package/dist/compiler/r3f.js +0 -12
  183. package/dist/compiler/remotion.cjs +0 -23
  184. package/dist/compiler/remotion.js +0 -4
  185. package/dist/compiler/reproducibility.cjs +0 -39
  186. package/dist/compiler/reproducibility.js +0 -4
  187. package/dist/compiler/sdf.cjs +0 -21
  188. package/dist/compiler/sdf.js +0 -9
  189. package/dist/compiler/semantic-scene.cjs +0 -31
  190. package/dist/compiler/semantic-scene.js +0 -4
  191. package/dist/compiler/state.cjs +0 -17
  192. package/dist/compiler/state.js +0 -7
  193. package/dist/compiler/trait-composition.cjs +0 -26
  194. package/dist/compiler/trait-composition.js +0 -5
  195. package/dist/compiler/unity.cjs +0 -15
  196. package/dist/compiler/unity.js +0 -9
  197. package/dist/compiler/unreal.cjs +0 -19
  198. package/dist/compiler/unreal.js +0 -9
  199. package/dist/compiler/urdf.cjs +0 -45
  200. package/dist/compiler/urdf.js +0 -9
  201. package/dist/compiler/usd-physics.cjs +0 -23
  202. package/dist/compiler/usd-physics.js +0 -6
  203. package/dist/compiler/visionos.cjs +0 -15
  204. package/dist/compiler/visionos.js +0 -9
  205. package/dist/compiler/vrchat.cjs +0 -19
  206. package/dist/compiler/vrchat.js +0 -9
  207. package/dist/compiler/vrr.cjs +0 -21
  208. package/dist/compiler/vrr.js +0 -9
  209. package/dist/compiler/wasm.cjs +0 -33
  210. package/dist/compiler/wasm.js +0 -9
  211. package/dist/compiler/webgpu.cjs +0 -15
  212. package/dist/compiler/webgpu.js +0 -9
  213. package/dist/debugger.cjs +0 -21
  214. package/dist/debugger.js +0 -8
  215. package/dist/entries/interop.cjs +0 -62
  216. package/dist/entries/interop.js +0 -5
  217. package/dist/entries/scripting.cjs +0 -68
  218. package/dist/entries/scripting.js +0 -11
  219. package/dist/index.cjs +0 -40921
  220. package/dist/index.js +0 -37763
  221. package/dist/math/vec3.cjs +0 -57
  222. package/dist/math/vec3.js +0 -4
  223. package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
  224. package/dist/ml-dsa-WYLJHJO6.js +0 -1178
  225. package/dist/parser.cjs +0 -27
  226. package/dist/parser.js +0 -10
  227. package/dist/playwright-5OSAPTNH.js +0 -98660
  228. package/dist/playwright-RL6GY4F7.cjs +0 -98673
  229. package/dist/runtime.cjs +0 -16
  230. package/dist/runtime.js +0 -7
  231. package/dist/storage/index.cjs +0 -37
  232. package/dist/storage/index.js +0 -4
  233. package/dist/traits/index.cjs +0 -14649
  234. package/dist/traits/index.js +0 -12243
  235. package/dist/type-checker.cjs +0 -18
  236. package/dist/type-checker.js +0 -5
@@ -1,168 +0,0 @@
1
- import { init_ProvenanceSemiring, authorityWeight, ProvenanceSemiring } from './chunk-A7PIMZGU.js';
2
- import { getRBAC, WorkflowStep, ResourceType } from '@holoscript/platform';
3
-
4
- // src/compiler/TraitCompositionCompiler.ts
5
- init_ProvenanceSemiring();
6
- var CompositionConflictError = class extends Error {
7
- constructor(traitA, traitB, conflictKey) {
8
- super(
9
- `Trait composition conflict: "${traitA}" and "${traitB}" both declare conflicting key "${conflictKey}".`
10
- );
11
- this.traitA = traitA;
12
- this.traitB = traitB;
13
- this.conflictKey = conflictKey;
14
- this.name = "CompositionConflictError";
15
- }
16
- };
17
- var MissingComponentError = class extends Error {
18
- constructor(composedName, missingComponent) {
19
- super(
20
- `Composition "${composedName}" references unknown component trait "${missingComponent}". Register it in TraitBinder before compiling.`
21
- );
22
- this.composedName = composedName;
23
- this.missingComponent = missingComponent;
24
- this.name = "MissingComponentError";
25
- }
26
- };
27
- var TraitCompositionCompiler = class {
28
- constructor(inheritanceResolver) {
29
- this.inheritanceResolver = inheritanceResolver;
30
- }
31
- /**
32
- * Set or replace the trait inheritance resolver.
33
- * Call this after constructing if the resolver becomes available later.
34
- */
35
- setInheritanceResolver(resolver) {
36
- this.inheritanceResolver = resolver;
37
- }
38
- /**
39
- * Compile a set of composition declarations.
40
- *
41
- * @param decls - Declarations to compile.
42
- * @param getHandler - Lookup a component handler by name.
43
- * @param traitGraph - Optional TraitDependencyGraph; if supplied, new
44
- * composed traits are registered there.
45
- * @param agentToken - JWT token proving agent identity (optional for backwards compatibility).
46
- * @returns Compiled ComposedTraitDef[], in declaration order.
47
- * @throws UnauthorizedTraitCompositionAccessError if token is provided but invalid.
48
- */
49
- compile(decls, getHandler, traitGraph, agentToken) {
50
- this.validateAccess(agentToken);
51
- return decls.map((decl) => this.compileOne(decl, getHandler, traitGraph));
52
- }
53
- // ---------------------------------------------------------------------------
54
- // RBAC enforcement
55
- // ---------------------------------------------------------------------------
56
- /**
57
- * Validate agent has permission to compile trait compositions.
58
- * Skips validation when no token is provided (backwards compatibility / testing).
59
- */
60
- validateAccess(agentToken) {
61
- if (!agentToken) return;
62
- const rbac = getRBAC();
63
- const decision = rbac.checkAccess({
64
- token: agentToken,
65
- resourceType: ResourceType.AST,
66
- operation: "read",
67
- expectedWorkflowStep: WorkflowStep.GENERATE_ASSEMBLY
68
- });
69
- if (!decision.allowed) {
70
- throw new UnauthorizedTraitCompositionAccessError(decision, "TraitCompositionCompiler");
71
- }
72
- }
73
- // ---------------------------------------------------------------------------
74
- // Private
75
- // ---------------------------------------------------------------------------
76
- compileOne(decl, getHandler, traitGraph) {
77
- const handlers = decl.components.map((name) => {
78
- const handler = getHandler(name);
79
- if (!handler) throw new MissingComponentError(decl.name, name);
80
- return { name, handler };
81
- });
82
- if (authorityWeight(
83
- decl.provenance?.context?.authorityLevel ?? 0
84
- ) < 100) {
85
- this.detectConflicts(handlers);
86
- }
87
- const semiring = new ProvenanceSemiring();
88
- const applications = [];
89
- for (const { name, handler } of handlers) {
90
- let configAccumulator = {};
91
- if (this.inheritanceResolver && this.inheritanceResolver.hasTrait(name)) {
92
- const resolvedProps = this.inheritanceResolver.getFlattenedProperties(name);
93
- configAccumulator = { ...resolvedProps };
94
- }
95
- if (handler.defaultConfig) {
96
- configAccumulator = { ...configAccumulator, ...handler.defaultConfig };
97
- }
98
- applications.push({ name, config: configAccumulator });
99
- }
100
- if (decl.overrides) {
101
- applications.push({
102
- name: `${decl.name}_overrides`,
103
- config: decl.overrides,
104
- context: { authorityLevel: Number.MAX_SAFE_INTEGER }
105
- // Overrides always win!
106
- });
107
- }
108
- const { config: merged, errors } = semiring.add(applications);
109
- if (errors.length > 0) {
110
- const match = errors[0].match(/Composition conflict: @(.+) and @(.+) both supply '(.+)'/);
111
- if (match) {
112
- throw new CompositionConflictError(match[1], match[2], match[3]);
113
- } else {
114
- throw new CompositionConflictError("Merge", "Failure", errors[0]);
115
- }
116
- }
117
- if (this.inheritanceResolver && decl.components.length > 1) {
118
- const diamonds = this.inheritanceResolver.detectDiamondInheritance(decl.components);
119
- for (const diamond of diamonds) {
120
- }
121
- }
122
- if (traitGraph) {
123
- traitGraph.registerTrait({
124
- name: decl.name,
125
- requires: decl.components,
126
- conflicts: []
127
- });
128
- }
129
- return {
130
- name: decl.name,
131
- components: decl.components,
132
- defaultConfig: merged
133
- };
134
- }
135
- /**
136
- * Naive conflict check: if handler A's `conflicts` array includes handler B's
137
- * name (or vice-versa), throw.
138
- */
139
- detectConflicts(handlers) {
140
- for (let i = 0; i < handlers.length; i++) {
141
- const a = handlers[i];
142
- const aConflicts = a.handler.conflicts ?? [];
143
- for (let j = i + 1; j < handlers.length; j++) {
144
- const b = handlers[j];
145
- const bConflicts = b.handler.conflicts ?? [];
146
- if (aConflicts.includes(b.name) || bConflicts.includes(a.name)) {
147
- throw new CompositionConflictError(a.name, b.name, b.name);
148
- }
149
- }
150
- }
151
- }
152
- };
153
- var UnauthorizedTraitCompositionAccessError = class extends Error {
154
- constructor(decision, compilerName) {
155
- super(
156
- `[${compilerName}] Unauthorized access: ${decision.reason || "Access denied"}
157
- Agent Role: ${decision.agentRole || "unknown"}
158
- Required Permission: ${decision.requiredPermission || "unknown"}`
159
- );
160
- this.decision = decision;
161
- this.compilerName = compilerName;
162
- this.name = "UnauthorizedTraitCompositionAccessError";
163
- }
164
- };
165
-
166
- export { CompositionConflictError, MissingComponentError, TraitCompositionCompiler, UnauthorizedTraitCompositionAccessError };
167
- //# sourceMappingURL=chunk-NOZZ46QU.js.map
168
- //# sourceMappingURL=chunk-NOZZ46QU.js.map
@@ -1,449 +0,0 @@
1
- // src/compiler/GLTFPipelineMCPTool.ts
2
- var GLTF_PIPELINE_TOOLS = [
3
- {
4
- name: "holoscript_gltf_export",
5
- description: "Export a HoloScript composition AST to glTF/GLB format. Supports PBR materials, mesh primitives, animations, and texture embedding.",
6
- inputSchema: {
7
- type: "object",
8
- properties: {
9
- composition: {
10
- type: "object",
11
- description: "HoloComposition AST (JSON serialized)"
12
- },
13
- format: {
14
- type: "string",
15
- description: "Output format",
16
- enum: ["glb", "gltf"],
17
- default: "glb"
18
- },
19
- dracoCompression: {
20
- type: "boolean",
21
- description: "Enable Draco mesh compression",
22
- default: false
23
- },
24
- quantize: {
25
- type: "boolean",
26
- description: "Enable vertex quantization for smaller file size",
27
- default: false
28
- },
29
- prune: {
30
- type: "boolean",
31
- description: "Remove unused resources",
32
- default: true
33
- },
34
- dedupe: {
35
- type: "boolean",
36
- description: "Deduplicate accessors and materials",
37
- default: true
38
- },
39
- embedTextures: {
40
- type: "boolean",
41
- description: "Embed textures as base64",
42
- default: true
43
- },
44
- agentToken: {
45
- type: "string",
46
- description: "Agent authentication token (JWT or empty for dev)",
47
- default: ""
48
- }
49
- },
50
- required: ["composition"]
51
- }
52
- },
53
- {
54
- name: "holoscript_gltf_inspect",
55
- description: "Inspect a glTF/GLB file and return metadata including node count, mesh count, material count, texture count, animation count, and file size.",
56
- inputSchema: {
57
- type: "object",
58
- properties: {
59
- composition: {
60
- type: "object",
61
- description: "HoloComposition AST to inspect (will be processed through GLTFPipeline)"
62
- },
63
- format: {
64
- type: "string",
65
- description: "Target format for size estimation",
66
- enum: ["glb", "gltf"],
67
- default: "glb"
68
- }
69
- },
70
- required: ["composition"]
71
- }
72
- },
73
- {
74
- name: "holoscript_gltf_validate",
75
- description: "Validate a HoloComposition AST for glTF export compatibility. Returns validation errors and warnings without performing the actual export.",
76
- inputSchema: {
77
- type: "object",
78
- properties: {
79
- composition: {
80
- type: "object",
81
- description: "HoloComposition AST to validate"
82
- }
83
- },
84
- required: ["composition"]
85
- }
86
- },
87
- {
88
- name: "holoscript_gltf_optimize",
89
- description: "Optimize a HoloComposition for efficient glTF export. Returns optimization recommendations and optionally applies them.",
90
- inputSchema: {
91
- type: "object",
92
- properties: {
93
- composition: {
94
- type: "object",
95
- description: "HoloComposition AST to optimize"
96
- },
97
- applyOptimizations: {
98
- type: "boolean",
99
- description: "Whether to apply optimizations to the AST (true) or just report (false)",
100
- default: false
101
- }
102
- },
103
- required: ["composition"]
104
- }
105
- },
106
- {
107
- name: "holoscript_gltf_material_list",
108
- description: "List all available HoloScript material presets that can be used in glTF export. Returns names and PBR properties for each preset.",
109
- inputSchema: {
110
- type: "object",
111
- properties: {
112
- filter: {
113
- type: "string",
114
- description: "Optional substring filter for preset names"
115
- }
116
- }
117
- }
118
- }
119
- ];
120
- async function handleGLTFToolCall(request) {
121
- try {
122
- switch (request.name) {
123
- case "holoscript_gltf_export":
124
- return await handleExport(request.arguments);
125
- case "holoscript_gltf_inspect":
126
- return await handleInspect(request.arguments);
127
- case "holoscript_gltf_validate":
128
- return await handleValidate(request.arguments);
129
- case "holoscript_gltf_optimize":
130
- return await handleOptimize(request.arguments);
131
- case "holoscript_gltf_material_list":
132
- return await handleMaterialList(request.arguments);
133
- default:
134
- return {
135
- isError: true,
136
- content: [{ type: "text", text: `Unknown tool: ${request.name}` }]
137
- };
138
- }
139
- } catch (error) {
140
- return {
141
- isError: true,
142
- content: [
143
- {
144
- type: "text",
145
- text: `Error: ${error instanceof Error ? error.message : String(error)}`
146
- }
147
- ]
148
- };
149
- }
150
- }
151
- async function handleExport(args) {
152
- const composition = args.composition;
153
- if (!composition || !composition.name) {
154
- return {
155
- isError: true,
156
- content: [{ type: "text", text: 'Invalid composition: missing "name" field' }]
157
- };
158
- }
159
- const format = args.format ?? "glb";
160
- const agentToken = args.agentToken ?? "";
161
- const { GLTFPipeline } = await importGLTFPipeline();
162
- const pipeline = new GLTFPipeline({
163
- format,
164
- dracoCompression: args.dracoCompression ?? false,
165
- quantize: args.quantize ?? false,
166
- prune: args.prune ?? true,
167
- dedupe: args.dedupe ?? true,
168
- embedTextures: args.embedTextures ?? true
169
- });
170
- const result = pipeline.compile(composition, agentToken);
171
- const content = [];
172
- content.push({
173
- type: "text",
174
- text: JSON.stringify(
175
- {
176
- success: true,
177
- format,
178
- stats: result.stats
179
- },
180
- null,
181
- 2
182
- )
183
- });
184
- if (result.binary) {
185
- content.push({
186
- type: "resource",
187
- uri: `holoscript://gltf/${composition.name}.${format}`,
188
- mimeType: format === "glb" ? "model/gltf-binary" : "model/gltf+json",
189
- data: uint8ArrayToBase64(result.binary)
190
- });
191
- }
192
- if (result.json) {
193
- content.push({
194
- type: "text",
195
- text: JSON.stringify(result.json, null, 2),
196
- mimeType: "application/json"
197
- });
198
- }
199
- return { isError: false, content };
200
- }
201
- async function handleInspect(args) {
202
- const composition = args.composition;
203
- if (!composition || !composition.name) {
204
- return {
205
- isError: true,
206
- content: [{ type: "text", text: 'Invalid composition: missing "name" field' }]
207
- };
208
- }
209
- const stats = inspectComposition(composition);
210
- return {
211
- isError: false,
212
- content: [
213
- {
214
- type: "text",
215
- text: JSON.stringify(
216
- {
217
- name: composition.name,
218
- stats,
219
- estimated_export_format: args.format ?? "glb"
220
- },
221
- null,
222
- 2
223
- )
224
- }
225
- ]
226
- };
227
- }
228
- async function handleValidate(args) {
229
- const composition = args.composition;
230
- if (!composition || !composition.name) {
231
- return {
232
- isError: true,
233
- content: [{ type: "text", text: 'Invalid composition: missing "name" field' }]
234
- };
235
- }
236
- const validation = validateForGLTF(composition);
237
- return {
238
- isError: false,
239
- content: [
240
- {
241
- type: "text",
242
- text: JSON.stringify(validation, null, 2)
243
- }
244
- ]
245
- };
246
- }
247
- async function handleOptimize(args) {
248
- const composition = args.composition;
249
- if (!composition || !composition.name) {
250
- return {
251
- isError: true,
252
- content: [{ type: "text", text: 'Invalid composition: missing "name" field' }]
253
- };
254
- }
255
- const recommendations = analyzeOptimizations(composition);
256
- return {
257
- isError: false,
258
- content: [
259
- {
260
- type: "text",
261
- text: JSON.stringify(
262
- {
263
- composition: composition.name,
264
- recommendations,
265
- total_recommendations: recommendations.length
266
- },
267
- null,
268
- 2
269
- )
270
- }
271
- ]
272
- };
273
- }
274
- async function handleMaterialList(args) {
275
- const filter = args.filter ?? "";
276
- let presets = {};
277
- try {
278
- const { MATERIAL_PRESETS } = await import('./compiler/r3f.js');
279
- presets = MATERIAL_PRESETS;
280
- } catch {
281
- presets = {
282
- default: { metalness: 0, roughness: 0.5 },
283
- metal: { metalness: 1, roughness: 0.2 },
284
- glass: { metalness: 0, roughness: 0, transmission: 1 },
285
- wood: { metalness: 0, roughness: 0.8 },
286
- plastic: { metalness: 0, roughness: 0.4 }
287
- };
288
- }
289
- let entries = Object.entries(presets);
290
- if (filter) {
291
- entries = entries.filter(([name]) => name.toLowerCase().includes(filter.toLowerCase()));
292
- }
293
- return {
294
- isError: false,
295
- content: [
296
- {
297
- type: "text",
298
- text: JSON.stringify(
299
- {
300
- total: entries.length,
301
- presets: Object.fromEntries(entries)
302
- },
303
- null,
304
- 2
305
- )
306
- }
307
- ]
308
- };
309
- }
310
- function inspectComposition(composition) {
311
- let traitCount = 0;
312
- let objectCount = 0;
313
- function countObjects(objects) {
314
- for (const obj of objects ?? []) {
315
- objectCount++;
316
- traitCount += obj.traits?.length ?? 0;
317
- if (obj.children) countObjects(obj.children);
318
- }
319
- }
320
- countObjects(composition.objects);
321
- for (const group of composition.spatialGroups ?? []) {
322
- countObjects(group.objects);
323
- }
324
- return {
325
- objectCount,
326
- spatialGroupCount: composition.spatialGroups?.length ?? 0,
327
- lightCount: composition.lights?.length ?? 0,
328
- hasCamera: !!composition.camera,
329
- timelineCount: composition.timelines?.length ?? 0,
330
- audioCount: composition.audio?.length ?? 0,
331
- npcCount: composition.npcs?.length ?? 0,
332
- shapeCount: composition.shapes?.length ?? 0,
333
- domainBlockCount: composition.domainBlocks?.length ?? 0,
334
- traitCount,
335
- estimatedNodeCount: objectCount + (composition.spatialGroups?.length ?? 0) + (composition.lights?.length ?? 0),
336
- estimatedMeshCount: objectCount
337
- };
338
- }
339
- function validateForGLTF(composition) {
340
- const errors = [];
341
- const warnings = [];
342
- if (!composition.name) {
343
- errors.push("Composition is missing a name");
344
- }
345
- if (!composition.objects?.length && !composition.spatialGroups?.length && !composition.shapes?.length) {
346
- warnings.push("Composition has no objects, spatial groups, or shapes to export");
347
- }
348
- if (composition.npcs?.length) {
349
- warnings.push(
350
- `${composition.npcs.length} NPC(s) will be exported as basic meshes (no behavior trees in glTF)`
351
- );
352
- }
353
- if (composition.stateMachines?.length) {
354
- warnings.push("State machines are not representable in glTF and will be omitted");
355
- }
356
- if (composition.quests?.length) {
357
- warnings.push("Quest definitions are not representable in glTF and will be omitted");
358
- }
359
- function checkObjects(objects) {
360
- for (const obj of objects ?? []) {
361
- const hasGeometry = obj.properties.some(
362
- (p) => p.key === "geometry" || p.key === "shape" || p.key === "model"
363
- ) || obj.traits?.some((t) => t.name === "geometry" || t.name === "mesh");
364
- if (!hasGeometry) {
365
- warnings.push(`Object "${obj.name}" has no explicit geometry; will default to cube`);
366
- }
367
- if (obj.children) checkObjects(obj.children);
368
- }
369
- }
370
- checkObjects(composition.objects);
371
- return {
372
- valid: errors.length === 0,
373
- errors,
374
- warnings
375
- };
376
- }
377
- function analyzeOptimizations(composition) {
378
- const recommendations = [];
379
- const stats = inspectComposition(composition);
380
- if (stats.objectCount > 100) {
381
- recommendations.push({
382
- category: "performance",
383
- severity: "warning",
384
- message: `Scene has ${stats.objectCount} objects. Consider using instancing or LOD for objects with shared geometry.`,
385
- action: "Enable dedupe and consider spatial grouping for draw call batching."
386
- });
387
- }
388
- if (stats.lightCount > 8) {
389
- recommendations.push({
390
- category: "performance",
391
- severity: "warning",
392
- message: `Scene has ${stats.lightCount} lights. Most real-time renderers support 4-8 dynamic lights.`,
393
- action: "Bake some lights into lightmaps or reduce dynamic light count."
394
- });
395
- }
396
- if (stats.objectCount > 50) {
397
- recommendations.push({
398
- category: "filesize",
399
- severity: "suggestion",
400
- message: "Consider enabling Draco compression for meshes to reduce file size by 40-90%.",
401
- action: "Set dracoCompression: true in GLTFPipelineOptions."
402
- });
403
- }
404
- recommendations.push({
405
- category: "filesize",
406
- severity: "info",
407
- message: "Enable vertex quantization to reduce vertex attribute precision and save ~30% on geometry data.",
408
- action: "Set quantize: true in GLTFPipelineOptions."
409
- });
410
- if (stats.domainBlockCount > 0) {
411
- recommendations.push({
412
- category: "compatibility",
413
- severity: "info",
414
- message: `${stats.domainBlockCount} domain block(s) detected. Domain-specific data will be stored in glTF extras for custom loader support.`
415
- });
416
- }
417
- if (stats.traitCount === 0 && stats.objectCount > 0) {
418
- recommendations.push({
419
- category: "quality",
420
- severity: "suggestion",
421
- message: "No traits found on objects. Add material/shader traits for richer visual output.",
422
- action: "Add @material, @shader, or @emissive traits to objects."
423
- });
424
- }
425
- return recommendations;
426
- }
427
- function uint8ArrayToBase64(data) {
428
- if (typeof Buffer !== "undefined") {
429
- return Buffer.from(data).toString("base64");
430
- }
431
- let binary = "";
432
- for (let i = 0; i < data.length; i++) {
433
- binary += String.fromCharCode(data[i]);
434
- }
435
- return btoa(binary);
436
- }
437
- async function importGLTFPipeline() {
438
- return import('./GLTFPipeline-DEN36VNK.js');
439
- }
440
- function registerGLTFTools(server) {
441
- for (const tool of GLTF_PIPELINE_TOOLS) {
442
- server.registerTool(tool, handleGLTFToolCall);
443
- }
444
- }
445
- var GLTFPipelineMCPTool_default = handleGLTFToolCall;
446
-
447
- export { GLTFPipelineMCPTool_default, GLTF_PIPELINE_TOOLS, analyzeOptimizations, handleGLTFToolCall, inspectComposition, registerGLTFTools, validateForGLTF };
448
- //# sourceMappingURL=chunk-OFKWH2IP.js.map
449
- //# sourceMappingURL=chunk-OFKWH2IP.js.map
@@ -1,65 +0,0 @@
1
- // src/logger.ts
2
- var NoOpLogger = class {
3
- /**
4
- * Debug-level logging (no-op implementation).
5
- * @param message - Debug message to discard
6
- * @param meta - Optional metadata to discard
7
- */
8
- debug(message, meta) {
9
- }
10
- /**
11
- * Info-level logging (no-op implementation).
12
- * @param message - Info message to discard
13
- * @param meta - Optional metadata to discard
14
- */
15
- info(message, meta) {
16
- }
17
- /**
18
- * Warning-level logging (no-op implementation).
19
- * @param message - Warning message to discard
20
- * @param meta - Optional metadata to discard
21
- */
22
- warn(message, meta) {
23
- }
24
- /**
25
- * Error-level logging (no-op implementation).
26
- * @param message - Error message to discard
27
- * @param meta - Optional metadata to discard
28
- */
29
- error(message, meta) {
30
- }
31
- };
32
- var ConsoleLogger = class {
33
- debug(message, meta) {
34
- console.debug(`[HoloScript:DEBUG] ${message}`, meta ?? "");
35
- }
36
- info(message, meta) {
37
- console.info(`[HoloScript:INFO] ${message}`, meta ?? "");
38
- }
39
- warn(message, meta) {
40
- console.warn(`[HoloScript:WARN] ${message}`, meta ?? "");
41
- }
42
- error(message, meta) {
43
- console.error(`[HoloScript:ERROR] ${message}`, meta ?? "");
44
- }
45
- };
46
- var currentLogger = new NoOpLogger();
47
- function setHoloScriptLogger(logger2) {
48
- currentLogger = logger2;
49
- }
50
- function enableConsoleLogging() {
51
- currentLogger = new ConsoleLogger();
52
- }
53
- function resetLogger() {
54
- currentLogger = new NoOpLogger();
55
- }
56
- var logger = {
57
- debug: (msg, meta) => currentLogger.debug(msg, meta),
58
- info: (msg, meta) => currentLogger.info(msg, meta),
59
- warn: (msg, meta) => currentLogger.warn(msg, meta),
60
- error: (msg, meta) => currentLogger.error(msg, meta)
61
- };
62
-
63
- export { ConsoleLogger, NoOpLogger, enableConsoleLogging, logger, resetLogger, setHoloScriptLogger };
64
- //# sourceMappingURL=chunk-PHENW4MQ.js.map
65
- //# sourceMappingURL=chunk-PHENW4MQ.js.map