@holoscript/core 6.0.3 → 6.0.4

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 (229) hide show
  1. package/README.md +38 -38
  2. package/dist/GLTFPipeline-DEN36VNK.js +12 -0
  3. package/dist/GLTFPipeline-YPCAK236.cjs +33 -0
  4. package/dist/{HoloScriptPlusParser-BZR5DELQ.js → HoloScriptPlusParser-BN6KVRCM.js} +5 -5
  5. package/dist/{HoloScriptPlusParser-SBMYDNXO.cjs → HoloScriptPlusParser-NC5FE6AL.cjs} +16 -16
  6. package/dist/{USDZExporter-YA55ZS35.js → USDZExporter-NTMBNTDB.js} +3 -3
  7. package/dist/{USDZExporter-MHEHXZB4.cjs → USDZExporter-UWGWNMMD.cjs} +3 -3
  8. package/dist/{chunk-32TWR3HE.js → chunk-2CWOLHTE.js} +3 -4
  9. package/dist/{chunk-2UX5LRAP.cjs → chunk-33LSUQDD.cjs} +33 -31
  10. package/dist/{chunk-LBPEZQAF.js → chunk-3FJCK5XA.js} +7 -7
  11. package/dist/{chunk-EGIZHYJP.cjs → chunk-3SAK5KFL.cjs} +2 -4
  12. package/dist/{chunk-PJMOXFPR.cjs → chunk-4XSNJCLC.cjs} +25 -27
  13. package/dist/{chunk-HKCVM6OK.cjs → chunk-5BGSECRJ.cjs} +21 -21
  14. package/dist/{chunk-EMO7HAKJ.cjs → chunk-5O6TQC6M.cjs} +26 -30
  15. package/dist/{chunk-XSUZMPVQ.cjs → chunk-5OEOHAAW.cjs} +26 -26
  16. package/dist/{chunk-EJA7G2C4.cjs → chunk-5WUNN6ZN.cjs} +2 -2
  17. package/dist/{chunk-CQDOF3G7.cjs → chunk-6TZPZCOJ.cjs} +18 -18
  18. package/dist/{chunk-NRUB55IT.cjs → chunk-6UEHYZ7V.cjs} +18 -16
  19. package/dist/{chunk-V42NTCFH.js → chunk-6XSERL6L.js} +4230 -2197
  20. package/dist/{chunk-X4YVN7H3.cjs → chunk-72EQECGT.cjs} +37 -17
  21. package/dist/{chunk-4KJ2R7VP.cjs → chunk-7AGYRWKW.cjs} +19 -19
  22. package/dist/{chunk-UQW6SLM5.js → chunk-A7PIMZGU.js} +110 -19
  23. package/dist/{chunk-RT7LJRSF.cjs → chunk-ATSKSYVE.cjs} +1013 -6708
  24. package/dist/{chunk-WN3YF33G.cjs → chunk-B5TCIAPQ.cjs} +9 -10
  25. package/dist/{chunk-AIUXRS74.cjs → chunk-BF2235SI.cjs} +4275 -2242
  26. package/dist/{chunk-DIEDKX5B.cjs → chunk-BND3ST2K.cjs} +18 -16
  27. package/dist/{chunk-EPWRXL6S.js → chunk-BU7VWW2K.js} +29 -29
  28. package/dist/{chunk-6OQBLABR.js → chunk-BWFJEM5A.js} +368 -189
  29. package/dist/{chunk-ARNKA274.cjs → chunk-CAUCGUEA.cjs} +6 -6
  30. package/dist/{chunk-YCMQQQ5U.cjs → chunk-CBJSLA2E.cjs} +398 -219
  31. package/dist/{chunk-BU5ZAFMC.js → chunk-CDPGV4DN.js} +6 -7
  32. package/dist/{chunk-CO2VM2DK.js → chunk-CS2EMTGF.js} +10 -9
  33. package/dist/{chunk-AW7WAELW.js → chunk-DMG7C4H2.js} +4 -4
  34. package/dist/{chunk-XSF76QRU.js → chunk-DXJQDCFL.js} +3 -3
  35. package/dist/{chunk-4FCZDTD5.js → chunk-E3FWRT3Z.js} +7 -9
  36. package/dist/{chunk-KYM4XRFG.js → chunk-E3UALNFA.js} +4 -4
  37. package/dist/{chunk-GC3YU46J.js → chunk-EONILVMF.js} +2 -2
  38. package/dist/{chunk-VJVCD5T5.cjs → chunk-EQV4R3EV.cjs} +22 -22
  39. package/dist/{chunk-FEFHPUEM.cjs → chunk-F3HH56EB.cjs} +74 -658
  40. package/dist/{chunk-WYH4GVZ5.js → chunk-F4IULT7N.js} +2 -2
  41. package/dist/{chunk-XDXZM3ZP.cjs → chunk-FFKU7BTK.cjs} +19 -19
  42. package/dist/{chunk-NKRKT6V2.js → chunk-FHQVYCH2.js} +11 -10
  43. package/dist/{chunk-7H5UNJZD.cjs → chunk-FSF7EQVA.cjs} +11 -10
  44. package/dist/{chunk-KUJRR4FJ.js → chunk-G4VZTCIB.js} +9 -7
  45. package/dist/{chunk-A6GO3DPZ.cjs → chunk-G7CT3EMP.cjs} +4 -4
  46. package/dist/{chunk-EUFLX2PI.js → chunk-GGHSW2NN.js} +989 -6611
  47. package/dist/chunk-GVUR45UF.cjs +777 -0
  48. package/dist/{chunk-ODGMVILH.js → chunk-H5Z7NASB.js} +3 -3
  49. package/dist/{chunk-7KPI4EKH.cjs → chunk-HE7ULERA.cjs} +45 -49
  50. package/dist/{chunk-26TLYBFD.js → chunk-HPS76H7Q.js} +3 -3
  51. package/dist/{chunk-RE3OKSYF.cjs → chunk-HQUEA5R6.cjs} +6 -6
  52. package/dist/{chunk-ZGTGVSTZ.js → chunk-HYNTS5CP.js} +2 -2
  53. package/dist/{chunk-PBA6NXCT.cjs → chunk-IBDG74G2.cjs} +6 -3
  54. package/dist/chunk-IFNQFCTM.js +3098 -0
  55. package/dist/{chunk-ZL6VJ6SN.js → chunk-IWI6J7FX.js} +5 -5
  56. package/dist/{chunk-3KEU5QYY.cjs → chunk-K3JDKWGI.cjs} +118 -23
  57. package/dist/{chunk-NLPSZT4C.js → chunk-K6EKD26I.js} +6 -6
  58. package/dist/chunk-KCQ5NDYC.cjs +3172 -0
  59. package/dist/{chunk-ELLQPFAF.js → chunk-KED34ILP.js} +11 -9
  60. package/dist/{chunk-BY3B7ZYV.cjs → chunk-KSGXLT74.cjs} +3 -3
  61. package/dist/{chunk-65RFOWZI.js → chunk-L4G4RLXX.js} +9 -7
  62. package/dist/{chunk-4SMUJFHL.js → chunk-LDP5OK6G.js} +6 -3
  63. package/dist/{chunk-VZNKJZTT.cjs → chunk-LGGRPKTV.cjs} +82 -96
  64. package/dist/{chunk-C2QHVHZF.js → chunk-LSW7P7ML.js} +23 -414
  65. package/dist/{chunk-HHS6FMOU.cjs → chunk-LXJ4667L.cjs} +83 -22
  66. package/dist/{chunk-H6WMMLQK.cjs → chunk-LZ266PCM.cjs} +20 -13
  67. package/dist/{chunk-V2ILLPHK.cjs → chunk-MD6KDHVE.cjs} +10 -10
  68. package/dist/{chunk-6WNCRE6F.js → chunk-MEASWI2Y.js} +5 -5
  69. package/dist/chunk-MPXBVFHQ.js +768 -0
  70. package/dist/{chunk-WUXIRGZP.cjs → chunk-NCUKG4SK.cjs} +304 -144
  71. package/dist/chunk-NDQNIJEH.js +1715 -0
  72. package/dist/{chunk-Y5MUAYTO.js → chunk-NOZZ46QU.js} +9 -8
  73. package/dist/{chunk-F5LVGHNT.js → chunk-OFKWH2IP.js} +3 -3
  74. package/dist/{chunk-SPDELRRV.cjs → chunk-PMGODDJA.cjs} +12 -12
  75. package/dist/{chunk-I3XGTIHM.cjs → chunk-Q4QX3AET.cjs} +2 -2
  76. package/dist/{chunk-Y7VK5TH3.cjs → chunk-Q5JT3YML.cjs} +10 -10
  77. package/dist/{chunk-TSWTWZ42.cjs → chunk-Q5SJOGHQ.cjs} +247 -205
  78. package/dist/{chunk-M6FU6S22.js → chunk-QGKNANZ3.js} +251 -91
  79. package/dist/{chunk-WFJIDI2N.cjs → chunk-QLEAOI3Q.cjs} +10 -10
  80. package/dist/{chunk-VK5AXKO3.js → chunk-R7MA7QWV.js} +70 -84
  81. package/dist/{chunk-W76ETJTI.js → chunk-RVYPEYPX.js} +6 -6
  82. package/dist/{chunk-MWEFR6YQ.js → chunk-S2N5TNMA.js} +7 -9
  83. package/dist/{chunk-NCUHGRTZ.js → chunk-S565K7NK.js} +7 -7
  84. package/dist/{chunk-AC4BSHFV.js → chunk-SDAMZIRE.js} +5 -5
  85. package/dist/{chunk-HBZYCASG.js → chunk-T36DDXSF.js} +75 -33
  86. package/dist/{chunk-BO2OKHIY.js → chunk-T4NKMBDL.js} +30 -611
  87. package/dist/{chunk-7X2IEJIE.cjs → chunk-T7LEXZUZ.cjs} +29 -29
  88. package/dist/{chunk-HUFNKFA6.js → chunk-TEWCN33Y.js} +8 -12
  89. package/dist/{chunk-L3Z2HIWJ.cjs → chunk-TQSZUOW5.cjs} +2 -2
  90. package/dist/chunk-TSH3MSQU.cjs +129 -0
  91. package/dist/{chunk-PLMYCCA4.js → chunk-UERJ3YJV.js} +6 -6
  92. package/dist/{chunk-7N3JIJMT.js → chunk-UPJBDCVF.js} +6 -6
  93. package/dist/{chunk-CMYAWUX3.js → chunk-V3NN3HPP.js} +12 -5
  94. package/dist/{chunk-SUCBB66F.js → chunk-WB4Z63GG.js} +3 -3
  95. package/dist/{chunk-PPULB4GG.cjs → chunk-WDW67DZB.cjs} +68 -68
  96. package/dist/chunk-WGMEAYBG.js +126 -0
  97. package/dist/{chunk-VSXOIUCF.cjs → chunk-X4ZF6CNE.cjs} +7 -7
  98. package/dist/{chunk-HF4OFY25.cjs → chunk-X6SEAXAX.cjs} +29 -445
  99. package/dist/{chunk-C7BNX4XJ.js → chunk-XCWFGZAA.js} +6 -6
  100. package/dist/{chunk-CNVM7J3M.js → chunk-XD6IYDUX.js} +34 -14
  101. package/dist/chunk-XG23EUQX.cjs +1717 -0
  102. package/dist/{chunk-DN7UFU63.cjs → chunk-XRKWN5PL.cjs} +12 -11
  103. package/dist/{chunk-XNMEH2BI.js → chunk-XUTX5CBW.js} +3 -3
  104. package/dist/{chunk-PQLGZKMC.cjs → chunk-XWPNTWDN.cjs} +26 -26
  105. package/dist/{chunk-NTMZSDXM.cjs → chunk-XXINBTZK.cjs} +43 -43
  106. package/dist/{chunk-74YCHHTE.js → chunk-YCXFCXDS.js} +8 -12
  107. package/dist/{chunk-KDB6BUMB.js → chunk-YQK5JNFK.js} +77 -18
  108. package/dist/{chunk-DH5G2JUA.cjs → chunk-Z34RLXRA.cjs} +44 -46
  109. package/dist/{chunk-XH7SE4HH.cjs → chunk-ZP4D3CSX.cjs} +19 -19
  110. package/dist/cli/holoscript-runner.cjs +33 -32
  111. package/dist/cli/holoscript-runner.js +13 -12
  112. package/dist/codebase/index.cjs +1 -1
  113. package/dist/codebase/index.d.ts +25 -0
  114. package/dist/codebase/index.js +1 -1
  115. package/dist/compiler/agent-inference.cjs +7 -8
  116. package/dist/compiler/agent-inference.js +3 -4
  117. package/dist/compiler/android-xr.cjs +7 -8
  118. package/dist/compiler/android-xr.js +5 -6
  119. package/dist/compiler/android.cjs +8 -9
  120. package/dist/compiler/android.js +6 -7
  121. package/dist/compiler/ar.cjs +6 -7
  122. package/dist/compiler/ar.js +4 -5
  123. package/dist/compiler/babylon.cjs +8 -9
  124. package/dist/compiler/babylon.js +7 -8
  125. package/dist/compiler/coco.cjs +1 -1
  126. package/dist/compiler/coco.js +1 -1
  127. package/dist/compiler/domain-block-utils.cjs +158 -151
  128. package/dist/compiler/domain-block-utils.js +4 -5
  129. package/dist/compiler/dtdl.cjs +7 -8
  130. package/dist/compiler/dtdl.js +4 -5
  131. package/dist/compiler/gltf-pipeline.cjs +9 -9
  132. package/dist/compiler/gltf-pipeline.js +2 -2
  133. package/dist/compiler/godot.cjs +6 -7
  134. package/dist/compiler/godot.js +5 -6
  135. package/dist/compiler/incremental.cjs +7 -8
  136. package/dist/compiler/incremental.js +2 -3
  137. package/dist/compiler/index.cjs +1934 -878
  138. package/dist/compiler/index.js +1904 -842
  139. package/dist/compiler/ios.cjs +8 -9
  140. package/dist/compiler/ios.js +6 -7
  141. package/dist/compiler/multi-layer.cjs +10 -17
  142. package/dist/compiler/multi-layer.js +9 -10
  143. package/dist/compiler/nodetoy.cjs +1 -1
  144. package/dist/compiler/nodetoy.js +1 -1
  145. package/dist/compiler/openxr.cjs +6 -7
  146. package/dist/compiler/openxr.js +5 -6
  147. package/dist/compiler/playcanvas.cjs +7 -8
  148. package/dist/compiler/playcanvas.js +6 -7
  149. package/dist/compiler/r3f.cjs +13 -14
  150. package/dist/compiler/r3f.js +8 -9
  151. package/dist/compiler/remotion.cjs +1 -1
  152. package/dist/compiler/remotion.js +1 -1
  153. package/dist/compiler/reproducibility.cjs +1 -1
  154. package/dist/compiler/reproducibility.js +1 -1
  155. package/dist/compiler/sdf.cjs +7 -8
  156. package/dist/compiler/sdf.js +5 -6
  157. package/dist/compiler/semantic-scene.cjs +7 -7
  158. package/dist/compiler/semantic-scene.js +2 -2
  159. package/dist/compiler/state.cjs +5 -6
  160. package/dist/compiler/state.js +3 -4
  161. package/dist/compiler/trait-composition.cjs +7 -8
  162. package/dist/compiler/trait-composition.js +3 -4
  163. package/dist/compiler/unity.cjs +6 -7
  164. package/dist/compiler/unity.js +5 -6
  165. package/dist/compiler/unreal.cjs +7 -8
  166. package/dist/compiler/unreal.js +5 -6
  167. package/dist/compiler/urdf.cjs +13 -14
  168. package/dist/compiler/urdf.js +5 -6
  169. package/dist/compiler/usd-physics.cjs +7 -8
  170. package/dist/compiler/usd-physics.js +4 -5
  171. package/dist/compiler/visionos.cjs +6 -7
  172. package/dist/compiler/visionos.js +5 -6
  173. package/dist/compiler/vrchat.cjs +7 -8
  174. package/dist/compiler/vrchat.js +5 -6
  175. package/dist/compiler/vrr.cjs +7 -8
  176. package/dist/compiler/vrr.js +5 -6
  177. package/dist/compiler/wasm.cjs +10 -11
  178. package/dist/compiler/wasm.js +5 -6
  179. package/dist/compiler/webgpu.cjs +6 -7
  180. package/dist/compiler/webgpu.js +5 -6
  181. package/dist/constants.d.ts +3 -0
  182. package/dist/debugger.cjs +7 -7
  183. package/dist/debugger.js +5 -5
  184. package/dist/entries/interop.cjs +1 -1
  185. package/dist/entries/interop.d.ts +9 -0
  186. package/dist/entries/interop.js +1 -1
  187. package/dist/entries/scripting.cjs +18 -17
  188. package/dist/entries/scripting.d.ts +7 -0
  189. package/dist/entries/scripting.js +8 -7
  190. package/dist/index.cjs +6773 -27555
  191. package/dist/index.d.ts +19 -0
  192. package/dist/index.js +5212 -26101
  193. package/dist/math/vec3.cjs +1 -1
  194. package/dist/math/vec3.js +1 -1
  195. package/dist/ml-dsa-PHCWUBPX.cjs +1178 -0
  196. package/dist/ml-dsa-WYLJHJO6.js +1178 -0
  197. package/dist/parser.cjs +11 -10
  198. package/dist/parser.js +8 -7
  199. package/dist/{playwright-BIZXMLD2.js → playwright-5OSAPTNH.js} +3 -3
  200. package/dist/{playwright-7DTEQCBD.cjs → playwright-RL6GY4F7.cjs} +1985 -1985
  201. package/dist/runtime.cjs +5 -5
  202. package/dist/runtime.js +4 -4
  203. package/dist/self-improvement/index.d.ts +0 -48
  204. package/dist/storage/index.cjs +1 -1
  205. package/dist/storage/index.d.ts +24 -0
  206. package/dist/storage/index.js +1 -1
  207. package/dist/tools/index.d.ts +12 -0
  208. package/dist/traits/index.cjs +925 -607
  209. package/dist/traits/index.js +137 -20
  210. package/dist/type-checker.cjs +4 -4
  211. package/dist/type-checker.js +2 -2
  212. package/package.json +56 -21
  213. package/LICENSE +0 -21
  214. package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
  215. package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
  216. package/dist/chunk-CN4NOESF.cjs +0 -416
  217. package/dist/chunk-DXVCEFZB.js +0 -2027
  218. package/dist/chunk-ENV7K6XA.js +0 -282
  219. package/dist/chunk-H7XMORZI.js +0 -2731
  220. package/dist/chunk-HAN4V3PF.cjs +0 -2037
  221. package/dist/chunk-LER4WXW5.cjs +0 -286
  222. package/dist/chunk-QHVVVN47.cjs +0 -2033
  223. package/dist/chunk-QWKUKVRE.js +0 -2026
  224. package/dist/chunk-UITWA6DV.cjs +0 -2829
  225. package/dist/chunk-X67XRI2T.js +0 -410
  226. package/dist/post-quantum-JTTAAGO3.cjs +0 -6
  227. package/dist/post-quantum-RVPVDEPI.js +0 -4
  228. package/dist/wot/index.cjs +0 -29
  229. package/dist/wot/index.js +0 -4
@@ -1,2026 +0,0 @@
1
- import { init_AgentRBAC, init_CapabilityToken, init_CapabilityTokenIssuer, init_AgentTokenIssuer, getRBAC, getCapabilityTokenIssuer, HoloScriptCapabilitySemantics, getTokenIssuer, HOLOSCRIPT_RESOURCE_SCHEME } from './chunk-V42NTCFH.js';
2
- import { __esm } from './chunk-32TWR3HE.js';
3
-
4
- // src/compiler/identity/ANSNamespace.ts
5
- function isValidCompilerName(name) {
6
- return ALL_COMPILER_NAMES.includes(name);
7
- }
8
- var ANSDomain, RiskTier, ANSCapabilityPath, COMPILER_DOMAIN_MAP, COMPILER_ANS_MAP, ALL_COMPILER_NAMES;
9
- var init_ANSNamespace = __esm({
10
- "src/compiler/identity/ANSNamespace.ts"() {
11
- ANSDomain = {
12
- GAMEDEV: "gamedev",
13
- SOCIAL_VR: "social-vr",
14
- XR: "xr",
15
- MOBILE: "mobile",
16
- WEB3D: "web3d",
17
- RUNTIME: "runtime",
18
- SHADER: "shader",
19
- ROBOTICS: "robotics",
20
- INTERCHANGE: "interchange",
21
- IOT: "iot",
22
- WEB3: "web3",
23
- AI: "ai",
24
- NEUROMORPHIC: "neuromorphic",
25
- META: "meta",
26
- MIXIN: "mixin"
27
- };
28
- RiskTier = {
29
- STANDARD: "STANDARD",
30
- HIGH: "HIGH",
31
- CRITICAL: "CRITICAL"
32
- };
33
- ({
34
- [ANSDomain.GAMEDEV]: RiskTier.STANDARD,
35
- [ANSDomain.SOCIAL_VR]: RiskTier.HIGH,
36
- [ANSDomain.XR]: RiskTier.HIGH,
37
- [ANSDomain.MOBILE]: RiskTier.HIGH,
38
- [ANSDomain.WEB3D]: RiskTier.STANDARD,
39
- [ANSDomain.RUNTIME]: RiskTier.HIGH,
40
- [ANSDomain.SHADER]: RiskTier.STANDARD,
41
- [ANSDomain.ROBOTICS]: RiskTier.CRITICAL,
42
- [ANSDomain.INTERCHANGE]: RiskTier.STANDARD,
43
- [ANSDomain.IOT]: RiskTier.HIGH,
44
- [ANSDomain.WEB3]: RiskTier.CRITICAL,
45
- [ANSDomain.AI]: RiskTier.HIGH,
46
- [ANSDomain.NEUROMORPHIC]: RiskTier.HIGH,
47
- [ANSDomain.META]: RiskTier.STANDARD,
48
- [ANSDomain.MIXIN]: RiskTier.STANDARD
49
- });
50
- ANSCapabilityPath = {
51
- // ── gamedev ──────────────────────────────────────────────────────────
52
- UNITY: "/compile/gamedev/unity",
53
- UNREAL: "/compile/gamedev/unreal",
54
- GODOT: "/compile/gamedev/godot",
55
- // ── social-vr ────────────────────────────────────────────────────────
56
- VRCHAT: "/compile/social-vr/vrchat",
57
- // ── xr ───────────────────────────────────────────────────────────────
58
- OPENXR: "/compile/xr/openxr",
59
- OPENXR_SPATIAL_ENTITIES: "/compile/xr/openxr-spatial-entities",
60
- VISIONOS: "/compile/xr/visionos",
61
- AR: "/compile/xr/ar",
62
- ANDROID_XR: "/compile/xr/android-xr",
63
- AI_GLASSES: "/compile/xr/ai-glasses",
64
- QUILT: "/compile/xr/quilt",
65
- MV_HEVC: "/compile/xr/mv-hevc",
66
- // ── mobile ───────────────────────────────────────────────────────────
67
- ANDROID: "/compile/mobile/android",
68
- IOS: "/compile/mobile/ios",
69
- // ── web3d ────────────────────────────────────────────────────────────
70
- BABYLON: "/compile/web3d/babylon",
71
- WEBGPU: "/compile/web3d/webgpu",
72
- R3F: "/compile/web3d/r3f",
73
- PLAYCANVAS: "/compile/web3d/playcanvas",
74
- // ── runtime ──────────────────────────────────────────────────────────
75
- WASM: "/compile/runtime/wasm",
76
- NODE_SERVICE: "/compile/runtime/node-service",
77
- // ── shader ───────────────────────────────────────────────────────────
78
- TSL: "/compile/shader/tsl",
79
- // ── robotics ─────────────────────────────────────────────────────────
80
- URDF: "/compile/robotics/urdf",
81
- SDF: "/compile/robotics/sdf",
82
- // ── interchange ──────────────────────────────────────────────────────
83
- USD: "/compile/interchange/usd",
84
- GLTF: "/compile/interchange/gltf",
85
- // ── iot ──────────────────────────────────────────────────────────────
86
- DTDL: "/compile/iot/dtdl",
87
- // ── web3 ─────────────────────────────────────────────────────────────
88
- NFT_MARKETPLACE: "/compile/web3/nft-marketplace",
89
- // ── ai ───────────────────────────────────────────────────────────────
90
- SCM: "/compile/ai/scm",
91
- VRR: "/compile/ai/vrr",
92
- A2A_AGENT_CARD: "/compile/ai/a2a-agent-card",
93
- AGENT_INFERENCE: "/compile/ai/agent-inference",
94
- // ── neuromorphic ─────────────────────────────────────────────────────
95
- NIR: "/compile/neuromorphic/nir",
96
- // ── meta ─────────────────────────────────────────────────────────────
97
- MULTI_LAYER: "/compile/meta/multi-layer",
98
- INCREMENTAL: "/compile/meta/incremental",
99
- STATE: "/compile/meta/state",
100
- TRAIT_COMPOSITION: "/compile/meta/trait-composition",
101
- // ── mixin ────────────────────────────────────────────────────────────
102
- DOMAIN_BLOCK: "/compile/mixin/domain-block"
103
- };
104
- COMPILER_DOMAIN_MAP = {
105
- // gamedev
106
- unity: ANSDomain.GAMEDEV,
107
- unreal: ANSDomain.GAMEDEV,
108
- godot: ANSDomain.GAMEDEV,
109
- // social-vr
110
- vrchat: ANSDomain.SOCIAL_VR,
111
- // xr
112
- openxr: ANSDomain.XR,
113
- "openxr-spatial-entities": ANSDomain.XR,
114
- visionos: ANSDomain.XR,
115
- ar: ANSDomain.XR,
116
- "android-xr": ANSDomain.XR,
117
- "ai-glasses": ANSDomain.XR,
118
- quilt: ANSDomain.XR,
119
- "mv-hevc": ANSDomain.XR,
120
- // mobile
121
- android: ANSDomain.MOBILE,
122
- ios: ANSDomain.MOBILE,
123
- // web3d
124
- babylon: ANSDomain.WEB3D,
125
- webgpu: ANSDomain.WEB3D,
126
- r3f: ANSDomain.WEB3D,
127
- playcanvas: ANSDomain.WEB3D,
128
- // runtime
129
- wasm: ANSDomain.RUNTIME,
130
- "node-service": ANSDomain.RUNTIME,
131
- // shader
132
- tsl: ANSDomain.SHADER,
133
- // robotics
134
- urdf: ANSDomain.ROBOTICS,
135
- sdf: ANSDomain.ROBOTICS,
136
- // interchange
137
- usd: ANSDomain.INTERCHANGE,
138
- gltf: ANSDomain.INTERCHANGE,
139
- // iot
140
- dtdl: ANSDomain.IOT,
141
- // web3
142
- "nft-marketplace": ANSDomain.WEB3,
143
- // ai
144
- scm: ANSDomain.AI,
145
- vrr: ANSDomain.AI,
146
- "a2a-agent-card": ANSDomain.AI,
147
- "agent-inference": ANSDomain.AI,
148
- // neuromorphic
149
- nir: ANSDomain.NEUROMORPHIC,
150
- // meta
151
- "multi-layer": ANSDomain.META,
152
- incremental: ANSDomain.META,
153
- state: ANSDomain.META,
154
- "trait-composition": ANSDomain.META,
155
- // mixin
156
- "domain-block": ANSDomain.MIXIN
157
- };
158
- COMPILER_ANS_MAP = {
159
- unity: ANSCapabilityPath.UNITY,
160
- unreal: ANSCapabilityPath.UNREAL,
161
- godot: ANSCapabilityPath.GODOT,
162
- vrchat: ANSCapabilityPath.VRCHAT,
163
- openxr: ANSCapabilityPath.OPENXR,
164
- "openxr-spatial-entities": ANSCapabilityPath.OPENXR_SPATIAL_ENTITIES,
165
- visionos: ANSCapabilityPath.VISIONOS,
166
- ar: ANSCapabilityPath.AR,
167
- "android-xr": ANSCapabilityPath.ANDROID_XR,
168
- "ai-glasses": ANSCapabilityPath.AI_GLASSES,
169
- quilt: ANSCapabilityPath.QUILT,
170
- "mv-hevc": ANSCapabilityPath.MV_HEVC,
171
- android: ANSCapabilityPath.ANDROID,
172
- ios: ANSCapabilityPath.IOS,
173
- babylon: ANSCapabilityPath.BABYLON,
174
- webgpu: ANSCapabilityPath.WEBGPU,
175
- r3f: ANSCapabilityPath.R3F,
176
- playcanvas: ANSCapabilityPath.PLAYCANVAS,
177
- wasm: ANSCapabilityPath.WASM,
178
- "node-service": ANSCapabilityPath.NODE_SERVICE,
179
- tsl: ANSCapabilityPath.TSL,
180
- urdf: ANSCapabilityPath.URDF,
181
- sdf: ANSCapabilityPath.SDF,
182
- usd: ANSCapabilityPath.USD,
183
- gltf: ANSCapabilityPath.GLTF,
184
- dtdl: ANSCapabilityPath.DTDL,
185
- "nft-marketplace": ANSCapabilityPath.NFT_MARKETPLACE,
186
- scm: ANSCapabilityPath.SCM,
187
- vrr: ANSCapabilityPath.VRR,
188
- "a2a-agent-card": ANSCapabilityPath.A2A_AGENT_CARD,
189
- "agent-inference": ANSCapabilityPath.AGENT_INFERENCE,
190
- nir: ANSCapabilityPath.NIR,
191
- "multi-layer": ANSCapabilityPath.MULTI_LAYER,
192
- incremental: ANSCapabilityPath.INCREMENTAL,
193
- state: ANSCapabilityPath.STATE,
194
- "trait-composition": ANSCapabilityPath.TRAIT_COMPOSITION,
195
- "domain-block": ANSCapabilityPath.DOMAIN_BLOCK
196
- };
197
- ALL_COMPILER_NAMES = Object.keys(
198
- COMPILER_DOMAIN_MAP
199
- );
200
- Object.values(ANSDomain);
201
- }
202
- });
203
-
204
- // src/compiler/CompilerDocumentationGenerator.ts
205
- var CompilerDocumentationGenerator;
206
- var init_CompilerDocumentationGenerator = __esm({
207
- "src/compiler/CompilerDocumentationGenerator.ts"() {
208
- CompilerDocumentationGenerator = class {
209
- constructor(options = {}) {
210
- this.options = {
211
- serviceUrl: options.serviceUrl ?? "http://localhost:3000",
212
- serviceVersion: options.serviceVersion ?? "1.0.0",
213
- maxLlmsTxtTokens: options.maxLlmsTxtTokens ?? 800,
214
- includeTraitDocs: options.includeTraitDocs ?? true,
215
- includeExamples: options.includeExamples ?? true,
216
- mcpTransportType: options.mcpTransportType ?? "streamable-http",
217
- contactRepository: options.contactRepository ?? "",
218
- contactDocumentation: options.contactDocumentation ?? ""
219
- };
220
- }
221
- getObjectType(obj) {
222
- const typeProperty = obj.properties?.find(
223
- (property) => property.key === "geometry" || property.key === "shape" || property.key === "type"
224
- )?.value;
225
- return typeof typeProperty === "string" ? typeProperty : "Object";
226
- }
227
- /**
228
- * Generate all three documentation outputs for a compilation
229
- *
230
- * @param composition - Parsed HoloScript composition AST
231
- * @param targetName - Compiler target (e.g., 'r3f', 'unity', 'unreal')
232
- * @param compiledCode - The compiled output code
233
- * @returns Triple-output documentation bundle
234
- */
235
- generate(composition, targetName, compiledCode) {
236
- return {
237
- llmsTxt: this.generateLlmsTxt(composition, targetName, compiledCode),
238
- wellKnownMcp: this.generateMCPServerCard(composition, targetName),
239
- markdownDocs: this.generateMarkdownDocs(composition, targetName, compiledCode)
240
- };
241
- }
242
- // ===========================================================================
243
- // LLMS.TXT GENERATION
244
- // ===========================================================================
245
- /**
246
- * Generate llms.txt format documentation (max 800 tokens)
247
- *
248
- * llms.txt is a standardized format for AI-readable project documentation.
249
- * It provides a concise overview optimized for LLM context windows.
250
- *
251
- * Includes: scene description, trait list, export targets, API surface,
252
- * MCP tool manifest summary, and state management.
253
- *
254
- * @see https://llmstxt.org/
255
- */
256
- generateLlmsTxt(composition, targetName, compiledCode) {
257
- const sections = [];
258
- sections.push(`# ${composition.name || "HoloScript Composition"}`);
259
- sections.push("");
260
- sections.push("## Scene Description");
261
- sections.push(`Compiled for: ${targetName}`);
262
- sections.push(`Objects: ${composition.objects?.length || 0}`);
263
- sections.push(`Lights: ${composition.lights?.length || 0}`);
264
- sections.push(`Spatial Groups: ${composition.spatialGroups?.length || 0}`);
265
- sections.push(`Templates: ${composition.templates?.length || 0}`);
266
- sections.push("");
267
- const traits = this.extractTraits(composition);
268
- if (traits.length > 0) {
269
- sections.push("## Traits Used");
270
- const traitsByCategory = this.groupTraitsByCategory(traits);
271
- for (const [category, categoryTraits] of Object.entries(traitsByCategory)) {
272
- sections.push(`- ${category}: ${categoryTraits.join(", ")}`);
273
- }
274
- sections.push("");
275
- }
276
- sections.push("## Export Capabilities");
277
- sections.push(`Primary target: ${targetName}`);
278
- sections.push(
279
- "Compatible targets: unity, unreal, godot, r3f, webgpu, babylon, openxr, vrchat, wasm, gltf, usd"
280
- );
281
- sections.push("");
282
- if (typeof compiledCode === "object") {
283
- sections.push("## API Surface");
284
- const files = Object.keys(compiledCode);
285
- sections.push(`Generated files: ${files.length}`);
286
- sections.push(`- ${files.slice(0, 5).join("\n- ")}`);
287
- if (files.length > 5) {
288
- sections.push(`- ... and ${files.length - 5} more`);
289
- }
290
- sections.push("");
291
- }
292
- const mcpTools = this.extractMCPTools(composition, targetName);
293
- if (mcpTools.length > 0) {
294
- sections.push("## MCP Tools");
295
- sections.push(`Available tools: ${mcpTools.length}`);
296
- for (const tool of mcpTools.slice(0, 8)) {
297
- sections.push(`- ${tool.name}: ${tool.description}`);
298
- }
299
- if (mcpTools.length > 8) {
300
- sections.push(`- ... and ${mcpTools.length - 8} more`);
301
- }
302
- sections.push("");
303
- }
304
- if (composition.state) {
305
- const stateObj = composition.state;
306
- let stateProps = [];
307
- if (stateObj.properties && Array.isArray(stateObj.properties)) {
308
- stateProps = stateObj.properties.map((p) => p.key);
309
- } else {
310
- stateProps = Object.keys(stateObj);
311
- }
312
- if (stateProps.length > 0) {
313
- sections.push("## State Management");
314
- sections.push(`State properties: ${stateProps.length}`);
315
- sections.push(`- ${stateProps.slice(0, 5).join(", ")}`);
316
- if (stateProps.length > 5) {
317
- sections.push(` ... and ${stateProps.length - 5} more`);
318
- }
319
- sections.push("");
320
- }
321
- }
322
- if (composition.environment) {
323
- const env = composition.environment;
324
- sections.push("## Environment");
325
- sections.push(`Background: ${env.background || "default"}`);
326
- if (env.fog) {
327
- sections.push("Fog: enabled");
328
- }
329
- sections.push("");
330
- }
331
- const fullText = sections.join("\n");
332
- const maxChars = this.options.maxLlmsTxtTokens * 4;
333
- if (fullText.length > maxChars) {
334
- return fullText.substring(0, maxChars) + "\n\n... (truncated to fit token limit)";
335
- }
336
- return fullText;
337
- }
338
- // ===========================================================================
339
- // .WELL-KNOWN/MCP GENERATION
340
- // ===========================================================================
341
- /**
342
- * Generate MCP server card conforming to SEP-1649 and SEP-1960
343
- *
344
- * Produces a server card that satisfies both specification proposals:
345
- * - SEP-1649: serverInfo nested object, transport with endpoint, protocolVersion
346
- * - SEP-1960: endpoints object, authentication, capabilities as booleans
347
- *
348
- * The card includes legacy compatibility fields (name, version at root)
349
- * for backward compatibility with v1.0.0 consumers.
350
- */
351
- generateMCPServerCard(composition, targetName) {
352
- const tools = this.extractMCPTools(composition, targetName);
353
- const sanitizedName = this.sanitizeServiceName(composition.name || "holoscript-composition");
354
- const compositionTitle = composition.name || "Untitled";
355
- const traitCount = this.extractTraits(composition).length;
356
- const objectCount = composition.objects?.length || 0;
357
- const endpoints = {};
358
- const transportType = this.options.mcpTransportType;
359
- const mcpUrl = `${this.options.serviceUrl}/mcp`;
360
- if (transportType === "streamable-http" || transportType === "http") {
361
- endpoints.streamable_http = mcpUrl;
362
- } else if (transportType === "sse") {
363
- endpoints.sse = mcpUrl;
364
- } else if (transportType === "websocket" || transportType === "ws") {
365
- endpoints.websocket = mcpUrl;
366
- } else {
367
- endpoints.streamable_http = mcpUrl;
368
- }
369
- endpoints.health = `${this.options.serviceUrl}/health`;
370
- endpoints.render = `${this.options.serviceUrl}/api/render`;
371
- return {
372
- // SEP-1960 fields
373
- mcpVersion: "2025-03-26",
374
- // SEP-1649 fields
375
- protocolVersion: "2025-06-18",
376
- serverInfo: {
377
- name: sanitizedName,
378
- title: `HoloScript: ${compositionTitle}`,
379
- version: this.options.serviceVersion
380
- },
381
- description: `HoloScript composition "${compositionTitle}" compiled for ${targetName} \u2014 ${objectCount} objects, ${traitCount} unique traits`,
382
- transport: {
383
- type: transportType,
384
- endpoint: mcpUrl,
385
- authentication: null
386
- },
387
- capabilities: {
388
- tools: {
389
- count: tools.length
390
- },
391
- resources: false,
392
- prompts: false,
393
- sampling: false,
394
- roots: false
395
- },
396
- tools,
397
- endpoints,
398
- authentication: {
399
- required: false,
400
- methods: ["none"]
401
- },
402
- contact: {
403
- repository: this.options.contactRepository || void 0,
404
- documentation: this.options.contactDocumentation || void 0
405
- },
406
- documentation: this.options.contactDocumentation || void 0,
407
- // Legacy compatibility (v1.0.0)
408
- name: sanitizedName,
409
- version: this.options.serviceVersion
410
- };
411
- }
412
- /**
413
- * Extract MCP tool manifest from composition
414
- */
415
- extractMCPTools(composition, targetName) {
416
- const tools = [];
417
- tools.push({
418
- name: "compile_composition",
419
- description: `Compile this HoloScript composition to ${targetName} format`,
420
- inputSchema: {
421
- type: "object",
422
- properties: {
423
- options: {
424
- type: "object",
425
- description: "Compiler options"
426
- }
427
- }
428
- }
429
- });
430
- tools.push({
431
- name: "render_preview",
432
- description: `Render a preview of this composition as PNG/JPEG`,
433
- inputSchema: {
434
- type: "object",
435
- properties: {
436
- width: { type: "number", description: "Image width in pixels" },
437
- height: { type: "number", description: "Image height in pixels" },
438
- format: { type: "string", enum: ["png", "jpeg", "webp"] }
439
- }
440
- }
441
- });
442
- if (composition.templates && composition.templates.length > 0) {
443
- for (const template of composition.templates.slice(0, 10)) {
444
- tools.push({
445
- name: `instantiate_${this.sanitizeToolName(template.name)}`,
446
- description: `Instantiate the "${template.name}" template with custom properties`,
447
- inputSchema: {
448
- type: "object",
449
- properties: {
450
- properties: {
451
- type: "object",
452
- description: "Template properties to override"
453
- },
454
- position: {
455
- type: "object",
456
- description: "Spatial position",
457
- properties: {
458
- x: { type: "number" },
459
- y: { type: "number" },
460
- z: { type: "number" }
461
- }
462
- }
463
- }
464
- }
465
- });
466
- }
467
- }
468
- if (composition.state) {
469
- tools.push({
470
- name: "update_state",
471
- description: "Update composition state properties",
472
- inputSchema: {
473
- type: "object",
474
- properties: {
475
- updates: {
476
- type: "object",
477
- description: "State property updates"
478
- }
479
- }
480
- }
481
- });
482
- }
483
- tools.push({
484
- name: "list_traits",
485
- description: "List all traits used in this composition with their configurations",
486
- inputSchema: {
487
- type: "object",
488
- properties: {
489
- category: {
490
- type: "string",
491
- description: "Filter by trait category (visual, physics, audio, etc.)"
492
- }
493
- }
494
- }
495
- });
496
- if (composition.objects && composition.objects.length > 0) {
497
- tools.push({
498
- name: "query_objects",
499
- description: `Query scene objects by name, type, or trait (${composition.objects.length} objects available)`,
500
- inputSchema: {
501
- type: "object",
502
- properties: {
503
- name: { type: "string", description: "Filter by object name (glob pattern)" },
504
- trait: { type: "string", description: "Filter by trait name" }
505
- }
506
- }
507
- });
508
- }
509
- return tools;
510
- }
511
- // ===========================================================================
512
- // MARKDOWN DOCUMENTATION GENERATION
513
- // ===========================================================================
514
- /**
515
- * Generate comprehensive markdown documentation bundle
516
- *
517
- * Includes: composition metadata, scene graph, trait documentation,
518
- * state management, logic handlers, MCP tool manifests, and compilation output.
519
- */
520
- generateMarkdownDocs(composition, targetName, compiledCode) {
521
- const sections = [];
522
- sections.push(`# ${composition.name || "HoloScript Composition"}`);
523
- sections.push("");
524
- sections.push(`**Target:** ${targetName}`);
525
- sections.push(`**Generated:** ${(/* @__PURE__ */ new Date()).toISOString()}`);
526
- sections.push(`**Version:** ${this.options.serviceVersion}`);
527
- sections.push("");
528
- sections.push("## Table of Contents");
529
- sections.push("");
530
- sections.push("- [Overview](#overview)");
531
- sections.push("- [Scene Graph](#scene-graph)");
532
- sections.push("- [Traits](#traits)");
533
- if (composition.state) {
534
- sections.push("- [State Management](#state-management)");
535
- }
536
- if (composition.logic) {
537
- sections.push("- [Logic Handlers](#logic-handlers)");
538
- }
539
- sections.push("- [MCP Tool Manifest](#mcp-tool-manifest)");
540
- sections.push("- [Compilation Output](#compilation-output)");
541
- sections.push("");
542
- sections.push("## Overview");
543
- sections.push("");
544
- sections.push(
545
- `This composition contains ${composition.objects?.length || 0} objects, ${composition.lights?.length || 0} lights, and ${composition.spatialGroups?.length || 0} spatial groups.`
546
- );
547
- sections.push("");
548
- if (composition.templates && composition.templates.length > 0) {
549
- sections.push(`**Templates:** ${composition.templates.length}`);
550
- }
551
- if (composition.imports && composition.imports.length > 0) {
552
- sections.push(`**Imports:** ${composition.imports.length}`);
553
- }
554
- if (composition.traitDefinitions && composition.traitDefinitions.length > 0) {
555
- sections.push(`**Custom Traits:** ${composition.traitDefinitions.length}`);
556
- }
557
- sections.push("");
558
- sections.push("## Scene Graph");
559
- sections.push("");
560
- if (composition.objects && composition.objects.length > 0) {
561
- sections.push("### Objects");
562
- sections.push("");
563
- sections.push("| Name | Type | Position | Traits |");
564
- sections.push("|------|------|----------|--------|");
565
- for (const obj of composition.objects.slice(0, 20)) {
566
- const objRec = obj;
567
- const transform = objRec.transform;
568
- const pos = objRec.position || transform?.position;
569
- const posStr = pos ? `(${pos.x}, ${pos.y}, ${pos.z})` : "N/A";
570
- const traitNames = obj.traits ? this.extractTraitNames(obj.traits).join(", ") || "none" : "none";
571
- sections.push(`| ${obj.name} | ${this.getObjectType(obj)} | ${posStr} | ${traitNames} |`);
572
- }
573
- if (composition.objects.length > 20) {
574
- sections.push(`| ... | ... | ... | *${composition.objects.length - 20} more objects* |`);
575
- }
576
- sections.push("");
577
- }
578
- if (composition.lights && composition.lights.length > 0) {
579
- sections.push("### Lights");
580
- sections.push("");
581
- sections.push("| Name | Type |");
582
- sections.push("|------|------|");
583
- for (const light of composition.lights) {
584
- const lightRec = light;
585
- sections.push(`| ${light.name || "unnamed"} | ${lightRec.lightType || "unknown"} |`);
586
- }
587
- sections.push("");
588
- }
589
- const traits = this.extractTraits(composition);
590
- if (traits.length > 0) {
591
- sections.push("## Traits");
592
- sections.push("");
593
- sections.push(`This composition uses ${traits.length} unique traits:`);
594
- sections.push("");
595
- const traitsByCategory = this.groupTraitsByCategory(traits);
596
- for (const [category, categoryTraits] of Object.entries(traitsByCategory)) {
597
- sections.push(`### ${category}`);
598
- sections.push("");
599
- for (const trait of categoryTraits) {
600
- sections.push(`- **${trait}**`);
601
- if (this.options.includeTraitDocs) {
602
- const doc = this.getTraitDocumentation(trait);
603
- if (doc) {
604
- sections.push(` ${doc}`);
605
- }
606
- }
607
- }
608
- sections.push("");
609
- }
610
- }
611
- if (composition.traitDefinitions && composition.traitDefinitions.length > 0) {
612
- sections.push("### Custom Trait Definitions");
613
- sections.push("");
614
- for (const traitDef of composition.traitDefinitions) {
615
- const traitDefRec = traitDef;
616
- const extendsClause = traitDefRec.extends ? ` extends ${traitDefRec.extends}` : "";
617
- sections.push(`- **${traitDef.name}**${extendsClause}`);
618
- }
619
- sections.push("");
620
- }
621
- if (composition.state) {
622
- sections.push("## State Management");
623
- sections.push("");
624
- sections.push("### State Properties");
625
- sections.push("");
626
- sections.push("| Property | Type | Default Value |");
627
- sections.push("|----------|------|---------------|");
628
- const stateObj = composition.state;
629
- if (stateObj.properties) {
630
- for (const prop of stateObj.properties) {
631
- const typeOf = typeof prop.value;
632
- const defaultValue = JSON.stringify(prop.value).substring(0, 50);
633
- sections.push(`| ${prop.key} | ${typeOf} | ${defaultValue} |`);
634
- }
635
- } else {
636
- for (const [key, value] of Object.entries(stateObj)) {
637
- const typeOf = typeof value;
638
- const defaultValue = JSON.stringify(value).substring(0, 50);
639
- sections.push(`| ${key} | ${typeOf} | ${defaultValue} |`);
640
- }
641
- }
642
- sections.push("");
643
- }
644
- if (composition.logic) {
645
- sections.push("## Logic Handlers");
646
- sections.push("");
647
- const logic = composition.logic;
648
- if (logic.on_start) {
649
- sections.push("### on_start");
650
- sections.push("");
651
- sections.push("Executed when the composition initializes.");
652
- sections.push("");
653
- }
654
- if (logic.on_update) {
655
- sections.push("### on_update");
656
- sections.push("");
657
- sections.push("Executed every frame.");
658
- sections.push("");
659
- }
660
- }
661
- const mcpTools = this.extractMCPTools(composition, targetName);
662
- sections.push("## MCP Tool Manifest");
663
- sections.push("");
664
- sections.push(
665
- `This compilation exposes ${mcpTools.length} MCP tools for programmatic interaction:`
666
- );
667
- sections.push("");
668
- sections.push("| Tool | Description | Input Schema |");
669
- sections.push("|------|-------------|-------------|");
670
- for (const tool of mcpTools) {
671
- const schemaStr = tool.inputSchema ? "`" + JSON.stringify(Object.keys(tool.inputSchema.properties || {})) + "`" : "none";
672
- sections.push(`| \`${tool.name}\` | ${tool.description} | ${schemaStr} |`);
673
- }
674
- sections.push("");
675
- sections.push("### Discovery");
676
- sections.push("");
677
- sections.push(`Server card available at: \`${this.options.serviceUrl}/.well-known/mcp\``);
678
- sections.push("");
679
- sections.push("```json");
680
- sections.push(`{`);
681
- sections.push(` "mcpVersion": "2025-03-26",`);
682
- sections.push(` "protocolVersion": "2025-06-18",`);
683
- sections.push(` "serverInfo": {`);
684
- sections.push(
685
- ` "name": "${this.sanitizeServiceName(composition.name || "holoscript-composition")}",`
686
- );
687
- sections.push(` "version": "${this.options.serviceVersion}"`);
688
- sections.push(` }`);
689
- sections.push(`}`);
690
- sections.push("```");
691
- sections.push("");
692
- sections.push("## Compilation Output");
693
- sections.push("");
694
- if (typeof compiledCode === "string") {
695
- const lineCount = compiledCode.split("\n").length;
696
- sections.push(`Generated ${lineCount} lines of ${targetName} code.`);
697
- } else {
698
- sections.push(`Generated ${Object.keys(compiledCode).length} files:`);
699
- sections.push("");
700
- for (const [filename, content] of Object.entries(compiledCode)) {
701
- const lineCount = content.split("\n").length;
702
- sections.push(`- **${filename}** (${lineCount} lines)`);
703
- }
704
- }
705
- sections.push("");
706
- sections.push("---");
707
- sections.push("");
708
- sections.push("*Generated by HoloScript Compiler Documentation Generator v2.0.0*");
709
- sections.push("");
710
- return sections.join("\n");
711
- }
712
- // ===========================================================================
713
- // HELPER METHODS
714
- // ===========================================================================
715
- /**
716
- * Extract trait names from a traits field.
717
- *
718
- * Handles both formats:
719
- * - HoloObjectTrait[] (canonical parser output: array of { name, config })
720
- * - Map<string, unknown> (R3F compiler output: Map with trait names as keys)
721
- */
722
- extractTraitNames(traits) {
723
- if (!traits) return [];
724
- if (traits instanceof Map) {
725
- return Array.from(traits.keys());
726
- }
727
- if (Array.isArray(traits)) {
728
- return traits.map((t) => typeof t === "string" ? t : t?.name).filter((name) => typeof name === "string");
729
- }
730
- return [];
731
- }
732
- /**
733
- * Extract all unique traits from a composition
734
- */
735
- extractTraits(composition) {
736
- const traitSet = /* @__PURE__ */ new Set();
737
- if (composition.objects) {
738
- for (const obj of composition.objects) {
739
- for (const name of this.extractTraitNames(obj.traits)) {
740
- traitSet.add(name);
741
- }
742
- }
743
- }
744
- if (composition.templates) {
745
- for (const template of composition.templates) {
746
- for (const name of this.extractTraitNames(template.traits)) {
747
- traitSet.add(name);
748
- }
749
- }
750
- }
751
- return Array.from(traitSet).sort();
752
- }
753
- /**
754
- * Group traits by category (visual, physics, audio, etc.)
755
- */
756
- groupTraitsByCategory(traits) {
757
- const categories = {
758
- Visual: [],
759
- Physics: [],
760
- Audio: [],
761
- Interaction: [],
762
- AI: [],
763
- Animation: [],
764
- Network: [],
765
- Other: []
766
- };
767
- for (const trait of traits) {
768
- const category = this.categorizeTrait(trait);
769
- categories[category].push(trait);
770
- }
771
- return Object.fromEntries(
772
- Object.entries(categories).filter(([_, traits2]) => traits2.length > 0)
773
- );
774
- }
775
- /**
776
- * Categorize a trait by name pattern
777
- */
778
- categorizeTrait(trait) {
779
- if (!trait) return "Other";
780
- const lower = trait.toLowerCase();
781
- if (lower.includes("material") || lower.includes("color") || lower.includes("texture") || lower.includes("glow") || lower.includes("emissive") || lower.includes("shader") || lower.includes("pbr") || lower.includes("light") || lower.includes("shadow") || lower.includes("fog") || lower.includes("transparency") || lower.includes("opacity")) {
782
- return "Visual";
783
- }
784
- if (lower.includes("physics") || lower.includes("collider") || lower.includes("rigidbody") || lower.includes("gravity") || lower.includes("fluid") || lower.includes("constraint") || lower.includes("joint")) {
785
- return "Physics";
786
- }
787
- if (lower.includes("audio") || lower.includes("sound") || lower.includes("music") || lower.includes("spatial_audio")) {
788
- return "Audio";
789
- }
790
- if (lower.includes("clickable") || lower.includes("draggable") || lower.includes("interactive") || lower.includes("hover") || lower.includes("grab") || lower.includes("pointer") || lower.includes("selectable")) {
791
- return "Interaction";
792
- }
793
- if (lower.includes("ai") || lower.includes("npc") || lower.includes("behavior") || lower.includes("pathfinding") || lower.includes("agent") || lower.includes("decision")) {
794
- return "AI";
795
- }
796
- if (lower.includes("anim") || lower.includes("rotate") || lower.includes("move") || lower.includes("orbit") || lower.includes("keyframe") || lower.includes("tween") || lower.includes("spring")) {
797
- return "Animation";
798
- }
799
- if (lower.includes("network") || lower.includes("sync") || lower.includes("multiplayer") || lower.includes("replicated") || lower.includes("authority") || lower.includes("lobby")) {
800
- return "Network";
801
- }
802
- return "Other";
803
- }
804
- /**
805
- * Get documentation string for a trait (stub - can be extended with trait metadata)
806
- */
807
- getTraitDocumentation(_trait) {
808
- return null;
809
- }
810
- /**
811
- * Sanitize composition name for use as a service name
812
- */
813
- sanitizeServiceName(name) {
814
- return name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
815
- }
816
- /**
817
- * Sanitize template name for use as a tool name
818
- */
819
- sanitizeToolName(name) {
820
- return name.toLowerCase().replace(/[^a-z0-9_]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
821
- }
822
- };
823
- }
824
- });
825
-
826
- // src/compiler/identity/CapabilityRBAC.ts
827
- function getCapabilityRBAC(config) {
828
- if (!globalCapabilityRBAC) {
829
- globalCapabilityRBAC = new CapabilityRBAC(config);
830
- }
831
- return globalCapabilityRBAC;
832
- }
833
- var RESOURCE_TYPE_TO_URI, OPERATION_TO_ACTION_SUFFIX, CapabilityRBAC, globalCapabilityRBAC;
834
- var init_CapabilityRBAC = __esm({
835
- "src/compiler/identity/CapabilityRBAC.ts"() {
836
- init_AgentRBAC();
837
- init_CapabilityToken();
838
- init_CapabilityTokenIssuer();
839
- RESOURCE_TYPE_TO_URI = {
840
- ["source_file" /* SOURCE_FILE */]: `${HOLOSCRIPT_RESOURCE_SCHEME}source`,
841
- ["ast" /* AST */]: `${HOLOSCRIPT_RESOURCE_SCHEME}ast`,
842
- ["ir" /* IR */]: `${HOLOSCRIPT_RESOURCE_SCHEME}ir`,
843
- ["code" /* CODE */]: `${HOLOSCRIPT_RESOURCE_SCHEME}code`,
844
- ["output" /* OUTPUT */]: `${HOLOSCRIPT_RESOURCE_SCHEME}output`,
845
- ["config" /* CONFIG */]: `${HOLOSCRIPT_RESOURCE_SCHEME}config`
846
- };
847
- OPERATION_TO_ACTION_SUFFIX = {
848
- read: "read",
849
- write: "write",
850
- execute: "execute",
851
- transform: "transform"
852
- };
853
- CapabilityRBAC = class {
854
- constructor(config = {}) {
855
- this.denialCounter = 0;
856
- this.rbac = config.rbac ?? getRBAC();
857
- this.capabilityIssuer = config.capabilityIssuer ?? getCapabilityTokenIssuer();
858
- this.strategy = config.strategy ?? "capability-first";
859
- this.semantics = new HoloScriptCapabilitySemantics();
860
- }
861
- buildDenialReceipt(request, deniedBy, opts) {
862
- const resourceUri = request.resourceType ? this.buildResourceUri(request.resourceType, request.resourcePath) : "unknown";
863
- const action = request.resourceType && request.operation ? this.buildAction(request.resourceType, request.operation) : request.operation || "unknown";
864
- return {
865
- auditId: `deny-${++this.denialCounter}-${Date.now()}`,
866
- deniedAction: action,
867
- requestedResource: resourceUri,
868
- deniedBy,
869
- requiredCapability: opts?.requiredCapability,
870
- suggestedFix: opts?.suggestedFix,
871
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
872
- };
873
- }
874
- // -----------------------------------------------------------------------
875
- // Core access check
876
- // -----------------------------------------------------------------------
877
- /**
878
- * Check access using dual-mode resolution.
879
- *
880
- * Depending on the configured strategy, this will try JWT and/or UCAN
881
- * verification and return the result.
882
- */
883
- checkAccess(request) {
884
- const hasCapability = !!request.capabilityToken && !!request.issuerPublicKey;
885
- const hasJwt = !!request.token;
886
- switch (this.strategy) {
887
- case "capability-only":
888
- if (!hasCapability) {
889
- return {
890
- allowed: false,
891
- reason: "Capability token required (strategy: capability-only)",
892
- mode: "capability",
893
- denial: this.buildDenialReceipt(request, "no-token", {
894
- suggestedFix: "Provide a UCAN capability token with issuerPublicKey"
895
- })
896
- };
897
- }
898
- return this.checkCapability(request);
899
- case "rbac-only":
900
- if (!hasJwt) {
901
- return {
902
- allowed: false,
903
- reason: "JWT token required (strategy: rbac-only)",
904
- mode: "rbac",
905
- denial: this.buildDenialReceipt(request, "no-token", {
906
- suggestedFix: "Provide a JWT RBAC token"
907
- })
908
- };
909
- }
910
- return this.checkRBAC(request);
911
- case "rbac-first":
912
- if (hasJwt) {
913
- const rbacResult = this.checkRBAC(request);
914
- if (rbacResult.allowed) return rbacResult;
915
- }
916
- if (hasCapability) {
917
- return this.checkCapability(request);
918
- }
919
- return {
920
- allowed: false,
921
- reason: "No valid token provided",
922
- mode: "rbac",
923
- denial: this.buildDenialReceipt(request, "no-token", {
924
- suggestedFix: "Provide a JWT token or UCAN capability token"
925
- })
926
- };
927
- case "capability-first":
928
- default:
929
- if (hasCapability) {
930
- const capResult = this.checkCapability(request);
931
- if (capResult.allowed) return capResult;
932
- }
933
- if (hasJwt) {
934
- return this.checkRBAC(request);
935
- }
936
- return {
937
- allowed: false,
938
- reason: "No valid token provided",
939
- mode: "capability",
940
- denial: this.buildDenialReceipt(request, "no-token", {
941
- suggestedFix: "Provide a UCAN capability token or JWT token"
942
- })
943
- };
944
- }
945
- }
946
- // -----------------------------------------------------------------------
947
- // UCAN capability check
948
- // -----------------------------------------------------------------------
949
- /**
950
- * Verify access using a UCAN capability token.
951
- */
952
- checkCapability(request) {
953
- const { capabilityToken, issuerPublicKey, resourceType, operation, resourcePath } = request;
954
- if (!capabilityToken || !issuerPublicKey) {
955
- return {
956
- allowed: false,
957
- reason: "Missing capability token or issuer public key",
958
- mode: "capability",
959
- denial: this.buildDenialReceipt(request, "capability", {
960
- suggestedFix: "Provide both capabilityToken and issuerPublicKey"
961
- })
962
- };
963
- }
964
- const verification = this.capabilityIssuer.verify(capabilityToken, issuerPublicKey);
965
- if (!verification.valid) {
966
- return {
967
- allowed: false,
968
- reason: `Capability token verification failed: ${verification.error}`,
969
- mode: "capability",
970
- capabilityVerification: verification,
971
- denial: this.buildDenialReceipt(request, "capability", {
972
- requiredCapability: "valid-signature",
973
- suggestedFix: `Re-issue capability token: ${verification.error}`
974
- })
975
- };
976
- }
977
- if (verification.chain && !verification.chain.verified) {
978
- return {
979
- allowed: false,
980
- reason: "Capability token chain verification failed (attenuation invariant violation)",
981
- mode: "capability",
982
- capabilityVerification: verification,
983
- errorCode: "ATTENUATION_VIOLATION",
984
- denial: this.buildDenialReceipt(request, "capability", {
985
- requiredCapability: "valid-attenuation-chain",
986
- suggestedFix: "Ensure delegated capabilities do not exceed parent scope"
987
- })
988
- };
989
- }
990
- const resourceUri = this.buildResourceUri(resourceType, resourcePath);
991
- const action = this.buildAction(resourceType, operation);
992
- const matchedCapability = capabilityToken.payload.att.find(
993
- (cap) => this.semantics.canAccess(cap, resourceUri, action)
994
- );
995
- if (!matchedCapability) {
996
- return {
997
- allowed: false,
998
- reason: `No capability grants access to resource "${resourceUri}" with action "${action}"`,
999
- mode: "capability",
1000
- capabilityVerification: verification,
1001
- denial: this.buildDenialReceipt(request, "capability", {
1002
- requiredCapability: `${resourceUri}#${action}`,
1003
- suggestedFix: `Add capability { with: "${resourceUri}", can: "${action}" } to token`
1004
- })
1005
- };
1006
- }
1007
- return {
1008
- allowed: true,
1009
- mode: "capability",
1010
- matchedCapability,
1011
- capabilityVerification: verification
1012
- };
1013
- }
1014
- // -----------------------------------------------------------------------
1015
- // Legacy JWT RBAC check (delegates to existing AgentRBAC)
1016
- // -----------------------------------------------------------------------
1017
- /**
1018
- * Verify access using the legacy JWT RBAC system.
1019
- */
1020
- checkRBAC(request) {
1021
- const decision = this.rbac.checkAccess(request);
1022
- const result = {
1023
- ...decision,
1024
- mode: "rbac"
1025
- };
1026
- if (!decision.allowed) {
1027
- result.denial = this.buildDenialReceipt(request, "rbac", {
1028
- requiredCapability: `${request.resourceType}/${request.operation}`,
1029
- suggestedFix: decision.reason ? `RBAC denied: ${decision.reason}` : "Ensure JWT token grants the required role/permission"
1030
- });
1031
- }
1032
- return result;
1033
- }
1034
- // -----------------------------------------------------------------------
1035
- // URI / action building
1036
- // -----------------------------------------------------------------------
1037
- /**
1038
- * Build a UCAN resource URI from a ResourceType and optional path.
1039
- */
1040
- buildResourceUri(resourceType, resourcePath) {
1041
- const base = RESOURCE_TYPE_TO_URI[resourceType];
1042
- if (resourcePath) {
1043
- return `${base}/${resourcePath}`;
1044
- }
1045
- return base;
1046
- }
1047
- /**
1048
- * Build a UCAN action string from a ResourceType and operation.
1049
- */
1050
- buildAction(resourceType, operation) {
1051
- const prefixMap = {
1052
- ["source_file" /* SOURCE_FILE */]: "source",
1053
- ["ast" /* AST */]: "ast",
1054
- ["ir" /* IR */]: "ir",
1055
- ["code" /* CODE */]: "code",
1056
- ["output" /* OUTPUT */]: "output",
1057
- ["config" /* CONFIG */]: "config"
1058
- };
1059
- const prefix = prefixMap[resourceType];
1060
- const suffix = OPERATION_TO_ACTION_SUFFIX[operation] ?? operation;
1061
- return `${prefix}/${suffix}`;
1062
- }
1063
- // -----------------------------------------------------------------------
1064
- // Convenience methods (matching AgentRBAC API)
1065
- // -----------------------------------------------------------------------
1066
- /**
1067
- * Check if agent can read source (dual-mode).
1068
- */
1069
- canReadSource(tokenOrCapability, filePath) {
1070
- if (typeof tokenOrCapability === "string") {
1071
- return this.checkAccess({
1072
- token: tokenOrCapability,
1073
- resourceType: "source_file" /* SOURCE_FILE */,
1074
- operation: "read",
1075
- resourcePath: filePath
1076
- });
1077
- }
1078
- return this.checkAccess({
1079
- token: "",
1080
- capabilityToken: tokenOrCapability.token,
1081
- issuerPublicKey: tokenOrCapability.publicKey,
1082
- resourceType: "source_file" /* SOURCE_FILE */,
1083
- operation: "read",
1084
- resourcePath: filePath
1085
- });
1086
- }
1087
- /**
1088
- * Check if agent can modify AST (dual-mode).
1089
- */
1090
- canModifyAST(tokenOrCapability) {
1091
- if (typeof tokenOrCapability === "string") {
1092
- return this.checkAccess({
1093
- token: tokenOrCapability,
1094
- resourceType: "ast" /* AST */,
1095
- operation: "write"
1096
- });
1097
- }
1098
- return this.checkAccess({
1099
- token: "",
1100
- capabilityToken: tokenOrCapability.token,
1101
- issuerPublicKey: tokenOrCapability.publicKey,
1102
- resourceType: "ast" /* AST */,
1103
- operation: "write"
1104
- });
1105
- }
1106
- /**
1107
- * Check if agent can generate code (dual-mode).
1108
- */
1109
- canGenerateCode(tokenOrCapability) {
1110
- if (typeof tokenOrCapability === "string") {
1111
- return this.checkAccess({
1112
- token: tokenOrCapability,
1113
- resourceType: "code" /* CODE */,
1114
- operation: "write"
1115
- });
1116
- }
1117
- return this.checkAccess({
1118
- token: "",
1119
- capabilityToken: tokenOrCapability.token,
1120
- issuerPublicKey: tokenOrCapability.publicKey,
1121
- resourceType: "code" /* CODE */,
1122
- operation: "write"
1123
- });
1124
- }
1125
- /**
1126
- * Check if agent can export output (dual-mode).
1127
- */
1128
- canExport(tokenOrCapability, outputPath) {
1129
- if (typeof tokenOrCapability === "string") {
1130
- return this.checkAccess({
1131
- token: tokenOrCapability,
1132
- resourceType: "output" /* OUTPUT */,
1133
- operation: "write",
1134
- resourcePath: outputPath
1135
- });
1136
- }
1137
- return this.checkAccess({
1138
- token: "",
1139
- capabilityToken: tokenOrCapability.token,
1140
- issuerPublicKey: tokenOrCapability.publicKey,
1141
- resourceType: "output" /* OUTPUT */,
1142
- operation: "write",
1143
- resourcePath: outputPath
1144
- });
1145
- }
1146
- // -----------------------------------------------------------------------
1147
- // Accessors
1148
- // -----------------------------------------------------------------------
1149
- /**
1150
- * Get the underlying AgentRBAC instance.
1151
- */
1152
- getRBAC() {
1153
- return this.rbac;
1154
- }
1155
- /**
1156
- * Get the CapabilityTokenIssuer instance.
1157
- */
1158
- getCapabilityIssuer() {
1159
- return this.capabilityIssuer;
1160
- }
1161
- /**
1162
- * Get the current resolution strategy.
1163
- */
1164
- getStrategy() {
1165
- return this.strategy;
1166
- }
1167
- };
1168
- globalCapabilityRBAC = null;
1169
- }
1170
- });
1171
-
1172
- // src/compiler/identity/SpatialMemoryZones.ts
1173
- function getSpatialZoneEnforcer(config) {
1174
- if (!globalSpatialZoneEnforcer) {
1175
- globalSpatialZoneEnforcer = new SpatialZoneEnforcer(config);
1176
- }
1177
- return globalSpatialZoneEnforcer;
1178
- }
1179
- var SpatialZoneEnforcer, globalSpatialZoneEnforcer;
1180
- var init_SpatialMemoryZones = __esm({
1181
- "src/compiler/identity/SpatialMemoryZones.ts"() {
1182
- init_AgentTokenIssuer();
1183
- SpatialZoneEnforcer = class {
1184
- constructor(config = {}) {
1185
- this.zones = /* @__PURE__ */ new Map();
1186
- this.policies = /* @__PURE__ */ new Map();
1187
- this.auditLog = [];
1188
- this.tokenIssuer = config.tokenIssuer ?? getTokenIssuer();
1189
- this.maxAuditEntries = config.maxAuditEntries ?? 1e4;
1190
- }
1191
- // -----------------------------------------------------------------------
1192
- // Zone Management
1193
- // -----------------------------------------------------------------------
1194
- /**
1195
- * Register a spatial zone.
1196
- */
1197
- registerZone(zone) {
1198
- this.zones.set(zone.id, zone);
1199
- }
1200
- /**
1201
- * Get a registered zone by ID.
1202
- */
1203
- getZone(zoneId) {
1204
- return this.zones.get(zoneId);
1205
- }
1206
- /**
1207
- * Remove a registered zone and its policy.
1208
- */
1209
- removeZone(zoneId) {
1210
- this.policies.delete(zoneId);
1211
- return this.zones.delete(zoneId);
1212
- }
1213
- /**
1214
- * Get all registered zone IDs.
1215
- */
1216
- getRegisteredZoneIds() {
1217
- return Array.from(this.zones.keys());
1218
- }
1219
- // -----------------------------------------------------------------------
1220
- // Policy Management
1221
- // -----------------------------------------------------------------------
1222
- /**
1223
- * Set the access policy for a zone.
1224
- */
1225
- setPolicy(policy) {
1226
- if (!this.zones.has(policy.zoneId)) {
1227
- throw new Error(`Cannot set policy for unregistered zone: ${policy.zoneId}`);
1228
- }
1229
- this.policies.set(policy.zoneId, policy);
1230
- }
1231
- /**
1232
- * Get the policy for a zone.
1233
- */
1234
- getPolicy(zoneId) {
1235
- return this.policies.get(zoneId);
1236
- }
1237
- // -----------------------------------------------------------------------
1238
- // Access Checks
1239
- // -----------------------------------------------------------------------
1240
- /**
1241
- * Check if an agent (identified by JWT token) can perform a spatial
1242
- * operation in a given zone.
1243
- *
1244
- * @param agentToken JWT token issued by `AgentTokenIssuer`
1245
- * @param zoneId Target zone identifier
1246
- * @param operation The spatial permission required
1247
- * @returns Access decision with reason
1248
- */
1249
- checkZoneAccess(agentToken, zoneId, operation) {
1250
- const verificationResult = this.tokenIssuer.verifyToken(agentToken);
1251
- if (!verificationResult.valid || !verificationResult.payload) {
1252
- const decision2 = {
1253
- allowed: false,
1254
- reason: `Token verification failed: ${verificationResult.error ?? "unknown error"}`
1255
- };
1256
- this.recordAudit("unknown", "unknown", zoneId, operation, false, decision2.reason);
1257
- return decision2;
1258
- }
1259
- const payload = verificationResult.payload;
1260
- const agentId = payload.sub;
1261
- const agentRole = payload.agent_role;
1262
- const zone = this.zones.get(zoneId);
1263
- if (!zone) {
1264
- const decision2 = {
1265
- allowed: false,
1266
- reason: `Zone not found: ${zoneId}`,
1267
- agentRole,
1268
- agentId
1269
- };
1270
- this.recordAudit(agentId, agentRole, zoneId, operation, false, decision2.reason);
1271
- return decision2;
1272
- }
1273
- const grantedPermissions = this.resolvePermissions(agentId, agentRole, zoneId, zone);
1274
- const allowed = grantedPermissions.includes(operation);
1275
- const reason = allowed ? `Access granted: agent ${agentId} has ${operation} in zone ${zoneId}` : `Access denied: agent ${agentId} lacks ${operation} in zone ${zoneId}`;
1276
- const decision = {
1277
- allowed,
1278
- reason,
1279
- agentRole,
1280
- agentId
1281
- };
1282
- this.recordAudit(agentId, agentRole, zoneId, operation, allowed, reason);
1283
- return decision;
1284
- }
1285
- /**
1286
- * Get all zone IDs that an agent can access (for at least one operation).
1287
- *
1288
- * @param agentToken JWT token
1289
- * @returns Array of accessible zone IDs
1290
- */
1291
- getAccessibleZones(agentToken) {
1292
- const verificationResult = this.tokenIssuer.verifyToken(agentToken);
1293
- if (!verificationResult.valid || !verificationResult.payload) {
1294
- return [];
1295
- }
1296
- const payload = verificationResult.payload;
1297
- const agentId = payload.sub;
1298
- const agentRole = payload.agent_role;
1299
- const accessibleZones = [];
1300
- for (const [zoneId, zone] of this.zones) {
1301
- const permissions = this.resolvePermissions(agentId, agentRole, zoneId, zone);
1302
- if (permissions.length > 0) {
1303
- accessibleZones.push(zoneId);
1304
- }
1305
- }
1306
- return accessibleZones;
1307
- }
1308
- /**
1309
- * Validate whether an agent can perform a spatial operation at a
1310
- * specific 3D position. The position is checked against all registered
1311
- * zones to find the enclosing zone(s), then permissions are evaluated.
1312
- *
1313
- * @param agentToken JWT token
1314
- * @param position 3D position to check
1315
- * @param operation Required spatial permission
1316
- * @returns Access decision (aggregated across matching zones)
1317
- */
1318
- validateSpatialOperation(agentToken, position, operation) {
1319
- const verificationResult = this.tokenIssuer.verifyToken(agentToken);
1320
- if (!verificationResult.valid || !verificationResult.payload) {
1321
- const decision2 = {
1322
- allowed: false,
1323
- reason: `Token verification failed: ${verificationResult.error ?? "unknown error"}`
1324
- };
1325
- this.recordAudit("unknown", "unknown", "*position*", operation, false, decision2.reason);
1326
- return decision2;
1327
- }
1328
- const payload = verificationResult.payload;
1329
- const agentId = payload.sub;
1330
- const agentRole = payload.agent_role;
1331
- const containingZones = this.findZonesContainingPosition(position);
1332
- if (containingZones.length === 0) {
1333
- const decision2 = {
1334
- allowed: false,
1335
- reason: `No registered zone contains position (${position.x}, ${position.y}, ${position.z})`,
1336
- agentRole,
1337
- agentId
1338
- };
1339
- this.recordAudit(agentId, agentRole, "*no-zone*", operation, false, decision2.reason);
1340
- return decision2;
1341
- }
1342
- for (const zone of containingZones) {
1343
- const permissions = this.resolvePermissions(agentId, agentRole, zone.id, zone);
1344
- if (permissions.includes(operation)) {
1345
- const decision2 = {
1346
- allowed: true,
1347
- reason: `Access granted via zone ${zone.id} at position (${position.x}, ${position.y}, ${position.z})`,
1348
- agentRole,
1349
- agentId
1350
- };
1351
- this.recordAudit(agentId, agentRole, zone.id, operation, true, decision2.reason);
1352
- return decision2;
1353
- }
1354
- }
1355
- const zoneIds = containingZones.map((z) => z.id).join(", ");
1356
- const decision = {
1357
- allowed: false,
1358
- reason: `Access denied in all containing zones [${zoneIds}] at position (${position.x}, ${position.y}, ${position.z})`,
1359
- agentRole,
1360
- agentId
1361
- };
1362
- this.recordAudit(agentId, agentRole, containingZones[0].id, operation, false, decision.reason);
1363
- return decision;
1364
- }
1365
- // -----------------------------------------------------------------------
1366
- // Audit Trail
1367
- // -----------------------------------------------------------------------
1368
- /**
1369
- * Get the full GDPR audit trail.
1370
- */
1371
- getAuditLog() {
1372
- return this.auditLog;
1373
- }
1374
- /**
1375
- * Get audit entries for a specific agent (GDPR data subject access).
1376
- */
1377
- getAuditEntriesForAgent(agentId) {
1378
- return this.auditLog.filter((entry) => entry.agentId === agentId);
1379
- }
1380
- /**
1381
- * Get audit entries for a specific zone.
1382
- */
1383
- getAuditEntriesForZone(zoneId) {
1384
- return this.auditLog.filter((entry) => entry.zoneId === zoneId);
1385
- }
1386
- /**
1387
- * Clear audit entries for a specific agent (GDPR right-to-erasure).
1388
- *
1389
- * @returns Number of entries removed
1390
- */
1391
- eraseAuditEntriesForAgent(agentId) {
1392
- const before = this.auditLog.length;
1393
- this.auditLog = this.auditLog.filter((entry) => entry.agentId !== agentId);
1394
- return before - this.auditLog.length;
1395
- }
1396
- /**
1397
- * Clear all audit entries.
1398
- */
1399
- clearAuditLog() {
1400
- this.auditLog = [];
1401
- }
1402
- // -----------------------------------------------------------------------
1403
- // Internal Helpers
1404
- // -----------------------------------------------------------------------
1405
- /**
1406
- * Resolve the effective spatial permissions for an agent in a zone.
1407
- *
1408
- * Resolution order:
1409
- * 1. Agent-specific overrides (highest priority)
1410
- * 2. Role-based permissions from policy
1411
- * 3. Policy default permissions
1412
- * 4. Classification-based fallback (if no policy exists)
1413
- */
1414
- resolvePermissions(agentId, agentRole, zoneId, zone) {
1415
- const policy = this.policies.get(zoneId);
1416
- if (policy) {
1417
- if (policy.agentOverrides[agentId]) {
1418
- return policy.agentOverrides[agentId];
1419
- }
1420
- if (policy.rolePermissions[agentRole]) {
1421
- return policy.rolePermissions[agentRole];
1422
- }
1423
- return policy.defaultPermissions;
1424
- }
1425
- return this.getClassificationDefaults(zone.classification);
1426
- }
1427
- /**
1428
- * Get default permissions based on zone classification.
1429
- */
1430
- getClassificationDefaults(classification) {
1431
- switch (classification) {
1432
- case "public":
1433
- return ["spatial:read" /* SPATIAL_READ */];
1434
- case "restricted":
1435
- return ["spatial:read" /* SPATIAL_READ */];
1436
- case "private":
1437
- return [];
1438
- case "sensitive":
1439
- return [];
1440
- default:
1441
- return [];
1442
- }
1443
- }
1444
- /**
1445
- * Find all zones whose bounds contain the given position.
1446
- *
1447
- * Named zones (no explicit bounds) are NOT included in positional
1448
- * lookups because their bounds are resolved at runtime.
1449
- */
1450
- findZonesContainingPosition(position) {
1451
- const result = [];
1452
- for (const zone of this.zones.values()) {
1453
- if (!zone.bounds) continue;
1454
- if (this.isPositionInBounds(position, zone.bounds)) {
1455
- result.push(zone);
1456
- }
1457
- }
1458
- return result;
1459
- }
1460
- /**
1461
- * Check if a 3D position is within the given bounds.
1462
- *
1463
- * For geospatial bounds: x=lat, y=lon, z=alt
1464
- * For local bounds: x=X, y=Y, z=Z
1465
- * Named bounds always return false (resolved at runtime).
1466
- */
1467
- isPositionInBounds(position, bounds) {
1468
- switch (bounds.type) {
1469
- case "geospatial": {
1470
- const inLat = position.x >= bounds.minLat && position.x <= bounds.maxLat;
1471
- const inLon = position.y >= bounds.minLon && position.y <= bounds.maxLon;
1472
- let inAlt = true;
1473
- if (bounds.minAlt !== void 0 && bounds.maxAlt !== void 0) {
1474
- inAlt = position.z >= bounds.minAlt && position.z <= bounds.maxAlt;
1475
- }
1476
- return inLat && inLon && inAlt;
1477
- }
1478
- case "local": {
1479
- return position.x >= bounds.minX && position.x <= bounds.maxX && position.y >= bounds.minY && position.y <= bounds.maxY && position.z >= bounds.minZ && position.z <= bounds.maxZ;
1480
- }
1481
- case "named":
1482
- return false;
1483
- default:
1484
- return false;
1485
- }
1486
- }
1487
- /**
1488
- * Record a GDPR audit entry.
1489
- */
1490
- recordAudit(agentId, agentRole, zoneId, operation, allowed, reason) {
1491
- const entry = {
1492
- timestamp: Date.now(),
1493
- agentId,
1494
- agentRole,
1495
- zoneId,
1496
- operation,
1497
- allowed,
1498
- reason
1499
- };
1500
- this.auditLog.push(entry);
1501
- if (this.auditLog.length > this.maxAuditEntries) {
1502
- this.auditLog = this.auditLog.slice(-this.maxAuditEntries);
1503
- }
1504
- }
1505
- };
1506
- globalSpatialZoneEnforcer = null;
1507
- }
1508
- });
1509
-
1510
- // src/compiler/CompilerBase.ts
1511
- function isCapabilityTokenCredential(token) {
1512
- if (!token || typeof token === "string") return false;
1513
- return typeof token === "object" && "capabilityToken" in token && "issuerPublicKey" in token && token.capabilityToken != null && typeof token.issuerPublicKey === "string";
1514
- }
1515
- function escapeCStyle(value) {
1516
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\0/g, "\\0");
1517
- }
1518
- function escapeGDScript(value) {
1519
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\t/g, "\\t").replace(/\0/g, "");
1520
- }
1521
- function escapeJSX(value) {
1522
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/\{/g, "&#123;").replace(/\}/g, "&#125;");
1523
- }
1524
- function escapeXML(value) {
1525
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
1526
- }
1527
- function escapeShader(value) {
1528
- return value.replace(/\\/g, "").replace(/\*/g, "").replace(/\//g, "").replace(/#/g, "").replace(/\n/g, " ").replace(/\r/g, "");
1529
- }
1530
- function escapePython(value) {
1531
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\0/g, "\\x00");
1532
- }
1533
- function escapeLua(value) {
1534
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\0/g, "\\0");
1535
- }
1536
- function escapeUSD(value) {
1537
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r");
1538
- }
1539
- function escapeJSON(value) {
1540
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/[\x00-\x1f]/g, (ch) => "\\u" + ch.charCodeAt(0).toString(16).padStart(4, "0"));
1541
- }
1542
- function escapeStringValue(value, target) {
1543
- if (!value) return value;
1544
- switch (target) {
1545
- case "Solidity":
1546
- case "CSharp":
1547
- case "Swift":
1548
- case "Kotlin":
1549
- case "TypeScript":
1550
- case "Rust":
1551
- return escapeCStyle(value);
1552
- case "GDScript":
1553
- return escapeGDScript(value);
1554
- case "JSX":
1555
- return escapeJSX(value);
1556
- case "XML":
1557
- return escapeXML(value);
1558
- case "GLSL":
1559
- case "HLSL":
1560
- case "WGSL":
1561
- return escapeShader(value);
1562
- case "Python":
1563
- return escapePython(value);
1564
- case "Lua":
1565
- return escapeLua(value);
1566
- case "USD":
1567
- return escapeUSD(value);
1568
- case "JSON":
1569
- return escapeJSON(value);
1570
- default:
1571
- return value;
1572
- }
1573
- }
1574
- function createTestCompilerToken() {
1575
- return "";
1576
- }
1577
- var COMPILER_CLASS_TO_ANS_NAME, UnauthorizedCompilerAccessError, CompilerBase;
1578
- var init_CompilerBase = __esm({
1579
- "src/compiler/CompilerBase.ts"() {
1580
- init_AgentRBAC();
1581
- init_CapabilityRBAC();
1582
- init_ANSNamespace();
1583
- init_SpatialMemoryZones();
1584
- init_CompilerDocumentationGenerator();
1585
- COMPILER_CLASS_TO_ANS_NAME = {
1586
- UnityCompiler: "unity",
1587
- UnrealCompiler: "unreal",
1588
- GodotCompiler: "godot",
1589
- VRChatCompiler: "vrchat",
1590
- OpenXRCompiler: "openxr",
1591
- OpenXRSpatialEntitiesCompiler: "openxr-spatial-entities",
1592
- VisionOSCompiler: "visionos",
1593
- ARCompiler: "ar",
1594
- AndroidXRCompiler: "android-xr",
1595
- AIGlassesCompiler: "ai-glasses",
1596
- AndroidCompiler: "android",
1597
- IOSCompiler: "ios",
1598
- BabylonCompiler: "babylon",
1599
- WebGPUCompiler: "webgpu",
1600
- R3FCompiler: "r3f",
1601
- PlayCanvasCompiler: "playcanvas",
1602
- WASMCompiler: "wasm",
1603
- TSLCompiler: "tsl",
1604
- URDFCompiler: "urdf",
1605
- SDFCompiler: "sdf",
1606
- USDPhysicsCompiler: "usd",
1607
- GLTFPipeline: "gltf",
1608
- DTDLCompiler: "dtdl",
1609
- NFTMarketplaceCompiler: "nft-marketplace",
1610
- SCMCompiler: "scm",
1611
- VRRCompiler: "vrr",
1612
- A2AAgentCardCompiler: "a2a-agent-card",
1613
- MultiLayerCompiler: "multi-layer",
1614
- IncrementalCompiler: "incremental",
1615
- StateCompiler: "state",
1616
- TraitCompositionCompiler: "trait-composition",
1617
- DomainBlockCompilerMixin: "domain-block",
1618
- NIRCompiler: "nir",
1619
- URDFToUSDZConverter: "urdf",
1620
- QuiltCompiler: "quilt",
1621
- MVHEVCCompiler: "mv-hevc",
1622
- NodeServiceCompiler: "node-service",
1623
- AgentInferenceCompiler: "agent-inference"
1624
- };
1625
- UnauthorizedCompilerAccessError = class extends Error {
1626
- constructor(decision, operation, compilerName) {
1627
- super(
1628
- `[${compilerName}] Unauthorized ${operation}: ${decision.reason || "Access denied"}
1629
- Agent Role: ${decision.agentRole || "unknown"}
1630
- Required Permission: ${decision.requiredPermission || "unknown"}`
1631
- );
1632
- this.decision = decision;
1633
- this.operation = operation;
1634
- this.compilerName = compilerName;
1635
- this.name = "UnauthorizedCompilerAccessError";
1636
- }
1637
- };
1638
- CompilerBase = class {
1639
- constructor() {
1640
- this.rbac = getRBAC();
1641
- /**
1642
- * Lazy-initialized CapabilityRBAC adapter for UCAN token verification.
1643
- * Only created when a UCAN capability token is first encountered.
1644
- */
1645
- this._capabilityRBAC = null;
1646
- /**
1647
- * Lazy-initialized SpatialZoneEnforcer for compile-time spatial zone checks.
1648
- * Only created when spatial zone validation is first invoked.
1649
- */
1650
- this._spatialZoneEnforcer = null;
1651
- /**
1652
- * Lazy-initialized documentation generator for triple-output compilation.
1653
- * Only created when generateDocs option is enabled.
1654
- */
1655
- this._documentationGenerator = null;
1656
- }
1657
- /**
1658
- * Sanitizes a string value for injection into a specific compiler target language.
1659
- * Mitigates Cross-Agent Compilation Injection attacks (e.g. CWE-94).
1660
- *
1661
- * @param value The raw string value from the AST
1662
- * @param target The compilation target language
1663
- * @returns The escaped/sanitized string safe for interpolation
1664
- */
1665
- escapeStringValue(value, target) {
1666
- return escapeStringValue(value, target);
1667
- }
1668
- // =========================================================================
1669
- // P3 Migration Bridge: Dual-mode token support
1670
- // =========================================================================
1671
- /**
1672
- * Get or create the CapabilityRBAC adapter instance.
1673
- *
1674
- * Lazily initialized to avoid overhead when only JWT tokens are used.
1675
- */
1676
- getCapabilityRBAC() {
1677
- if (!this._capabilityRBAC) {
1678
- this._capabilityRBAC = getCapabilityRBAC();
1679
- }
1680
- return this._capabilityRBAC;
1681
- }
1682
- /**
1683
- * Get or create the SpatialZoneEnforcer instance.
1684
- *
1685
- * Lazily initialized to avoid overhead when spatial zones are not in use.
1686
- */
1687
- getSpatialZoneEnforcer() {
1688
- if (!this._spatialZoneEnforcer) {
1689
- this._spatialZoneEnforcer = getSpatialZoneEnforcer();
1690
- }
1691
- return this._spatialZoneEnforcer;
1692
- }
1693
- /**
1694
- * Get or create the CompilerDocumentationGenerator instance.
1695
- *
1696
- * Lazily initialized to avoid overhead when documentation generation is disabled.
1697
- *
1698
- * @param options - Documentation generator options
1699
- */
1700
- getDocumentationGenerator(options) {
1701
- if (!this._documentationGenerator) {
1702
- this._documentationGenerator = new CompilerDocumentationGenerator(options);
1703
- }
1704
- return this._documentationGenerator;
1705
- }
1706
- /**
1707
- * Generate triple-output documentation for a compilation result.
1708
- *
1709
- * This is a utility method that subclasses can call after successful compilation
1710
- * to generate llms.txt, .well-known/mcp, and markdown documentation.
1711
- *
1712
- * @param composition - Parsed HoloScript composition AST
1713
- * @param compiledCode - The compiled output code
1714
- * @param options - Documentation generator options
1715
- * @returns Triple-output documentation bundle
1716
- *
1717
- * @example
1718
- * ```typescript
1719
- * compile(composition: HoloComposition, agentToken: string, options?: MyCompilerOptions): CompilationResult {
1720
- * this.validateCompilerAccess(agentToken);
1721
- * const code = this.performCompilation(composition);
1722
- *
1723
- * if (options?.generateDocs) {
1724
- * const docs = this.generateDocumentation(composition, code, options.docsOptions);
1725
- * return { output: code, documentation: docs };
1726
- * }
1727
- *
1728
- * return { output: code };
1729
- * }
1730
- * ```
1731
- */
1732
- generateDocumentation(composition, compiledCode, options) {
1733
- const generator = this.getDocumentationGenerator(options);
1734
- return generator.generate(composition, this.compilerName, compiledCode);
1735
- }
1736
- /**
1737
- * Get the ANS capability namespace path for this compiler.
1738
- *
1739
- * Subclasses MAY override this to specify their exact ANS namespace.
1740
- * The default implementation derives it from `compilerName` using the
1741
- * `COMPILER_CLASS_TO_ANS_NAME` lookup table.
1742
- *
1743
- * @returns The ANS capability path (e.g., "/compile/web3d/r3f"), or
1744
- * `undefined` if the compiler has no registered ANS namespace.
1745
- *
1746
- * @example
1747
- * ```typescript
1748
- * // Default: derives from compilerName
1749
- * class R3FCompiler extends CompilerBase {
1750
- * protected readonly compilerName = 'R3FCompiler';
1751
- * // getRequiredCapability() returns '/compile/web3d/r3f' automatically
1752
- * }
1753
- *
1754
- * // Override: explicit namespace
1755
- * class CustomCompiler extends CompilerBase {
1756
- * protected readonly compilerName = 'CustomCompiler';
1757
- * protected getRequiredCapability(): string | undefined {
1758
- * return '/compile/web3d/r3f';
1759
- * }
1760
- * }
1761
- * ```
1762
- */
1763
- getRequiredCapability() {
1764
- const ansName = COMPILER_CLASS_TO_ANS_NAME[this.compilerName];
1765
- if (ansName && isValidCompilerName(ansName)) {
1766
- return COMPILER_ANS_MAP[ansName];
1767
- }
1768
- if (process.env["NODE_ENV"] !== "test") {
1769
- console.warn(
1770
- `[CompilerBase] Compiler '${this.compilerName}' has no ANS namespace entry. Add it to COMPILER_CLASS_TO_ANS_NAME to enable UCAN capability enforcement.`
1771
- );
1772
- }
1773
- return void 0;
1774
- }
1775
- // =========================================================================
1776
- // Legacy JWT RBAC validation (unchanged from v1.0.0)
1777
- // =========================================================================
1778
- /**
1779
- * Validate agent can read AST
1780
- * Skips validation when no token is provided.
1781
- * In production (`NODE_ENV=production`) a warning is emitted when no token is
1782
- * supplied — callers should always authenticate compiler access in production.
1783
- *
1784
- * @param agentToken - Agent JWT token (optional)
1785
- * @throws UnauthorizedCompilerAccessError if token is provided but invalid
1786
- */
1787
- validateASTAccess(agentToken) {
1788
- if (!agentToken) {
1789
- if (process.env["NODE_ENV"] === "production") {
1790
- console.warn(
1791
- `[${this.compilerName}] validateASTAccess called without a token in production. All compiler calls should be authenticated. Pass an agent token to enforce RBAC.`
1792
- );
1793
- }
1794
- return;
1795
- }
1796
- const decision = this.rbac.checkAccess({
1797
- token: agentToken,
1798
- resourceType: "ast" /* AST */,
1799
- operation: "read",
1800
- expectedWorkflowStep: "generate_assembly" /* GENERATE_ASSEMBLY */
1801
- });
1802
- if (!decision.allowed) {
1803
- throw new UnauthorizedCompilerAccessError(decision, "AST access", this.compilerName);
1804
- }
1805
- }
1806
- /**
1807
- * Validate agent can generate code
1808
- * Skips validation when no token is provided.
1809
- * In production (`NODE_ENV=production`) a warning is emitted when no token is
1810
- * supplied — callers should always authenticate compiler access in production.
1811
- *
1812
- * @param agentToken - Agent JWT token (optional)
1813
- * @throws UnauthorizedCompilerAccessError if token is provided but invalid
1814
- */
1815
- validateCodeGeneration(agentToken) {
1816
- if (!agentToken) {
1817
- if (process.env["NODE_ENV"] === "production") {
1818
- console.warn(
1819
- `[${this.compilerName}] validateCodeGeneration called without a token in production. All compiler calls should be authenticated. Pass an agent token to enforce RBAC.`
1820
- );
1821
- }
1822
- return;
1823
- }
1824
- const decision = this.rbac.checkAccess({
1825
- token: agentToken,
1826
- resourceType: "code" /* CODE */,
1827
- operation: "write",
1828
- expectedWorkflowStep: "generate_assembly" /* GENERATE_ASSEMBLY */
1829
- });
1830
- if (!decision.allowed) {
1831
- throw new UnauthorizedCompilerAccessError(decision, "code generation", this.compilerName);
1832
- }
1833
- }
1834
- /**
1835
- * Validate agent can write to output path
1836
- * Skips validation when no token is provided.
1837
- * In production (`NODE_ENV=production`) a warning is emitted when no token is
1838
- * supplied — callers should always authenticate compiler access in production.
1839
- *
1840
- * @param agentToken - Agent JWT token (optional)
1841
- * @param outputPath - Target output file path
1842
- * @throws UnauthorizedCompilerAccessError if token is provided but invalid
1843
- */
1844
- validateOutputPath(agentToken, outputPath) {
1845
- if (!agentToken) {
1846
- if (process.env["NODE_ENV"] === "production") {
1847
- console.warn(
1848
- `[${this.compilerName}] validateOutputPath called without a token in production. All compiler calls should be authenticated. Pass an agent token to enforce RBAC.`
1849
- );
1850
- }
1851
- return;
1852
- }
1853
- const decision = this.rbac.checkAccess({
1854
- token: agentToken,
1855
- resourceType: "output" /* OUTPUT */,
1856
- operation: "write",
1857
- resourcePath: outputPath,
1858
- expectedWorkflowStep: "serialize" /* SERIALIZE */
1859
- });
1860
- if (!decision.allowed) {
1861
- throw new UnauthorizedCompilerAccessError(
1862
- decision,
1863
- `output write to '${outputPath}'`,
1864
- this.compilerName
1865
- );
1866
- }
1867
- }
1868
- // =========================================================================
1869
- // UCAN Capability Token validation (P3 Migration Bridge)
1870
- // =========================================================================
1871
- /**
1872
- * Validate compiler access using a UCAN capability token.
1873
- *
1874
- * Checks that the capability token grants access to the required resources
1875
- * (AST read, CODE write, and optionally OUTPUT write) using the
1876
- * CapabilityRBAC adapter.
1877
- *
1878
- * @param credential - UCAN capability token credential
1879
- * @param outputPath - Optional output path for scope validation
1880
- * @throws UnauthorizedCompilerAccessError if any capability check fails
1881
- */
1882
- validateCapabilityAccess(credential, outputPath) {
1883
- const capRBAC = this.getCapabilityRBAC();
1884
- const astDecision = capRBAC.checkAccess({
1885
- token: "",
1886
- capabilityToken: credential.capabilityToken,
1887
- issuerPublicKey: credential.issuerPublicKey,
1888
- resourceType: "ast" /* AST */,
1889
- operation: "read"
1890
- });
1891
- if (!astDecision.allowed) {
1892
- throw new UnauthorizedCompilerAccessError(astDecision, "AST access", this.compilerName);
1893
- }
1894
- const codeDecision = capRBAC.checkAccess({
1895
- token: "",
1896
- capabilityToken: credential.capabilityToken,
1897
- issuerPublicKey: credential.issuerPublicKey,
1898
- resourceType: "code" /* CODE */,
1899
- operation: "write"
1900
- });
1901
- if (!codeDecision.allowed) {
1902
- throw new UnauthorizedCompilerAccessError(codeDecision, "code generation", this.compilerName);
1903
- }
1904
- if (outputPath) {
1905
- const outputDecision = capRBAC.checkAccess({
1906
- token: "",
1907
- capabilityToken: credential.capabilityToken,
1908
- issuerPublicKey: credential.issuerPublicKey,
1909
- resourceType: "output" /* OUTPUT */,
1910
- operation: "write",
1911
- resourcePath: outputPath
1912
- });
1913
- if (!outputDecision.allowed) {
1914
- throw new UnauthorizedCompilerAccessError(
1915
- outputDecision,
1916
- `output write to '${outputPath}'`,
1917
- this.compilerName
1918
- );
1919
- }
1920
- }
1921
- }
1922
- // =========================================================================
1923
- // Spatial Memory Zone validation
1924
- // =========================================================================
1925
- /**
1926
- * Validate spatial zone access for the current compilation.
1927
- *
1928
- * This step runs **after** RBAC/UCAN token verification and enforces
1929
- * compile-time spatial zone permissions when zones are registered.
1930
- *
1931
- * **Backward compatible**: When no zones are registered in the global
1932
- * SpatialZoneEnforcer, this method is a no-op.
1933
- *
1934
- * **Non-blocking**: Zone enforcement failures are logged as warnings
1935
- * but do NOT throw or block compilation. This allows gradual rollout
1936
- * of spatial zone policies without breaking existing pipelines.
1937
- *
1938
- * @param agentToken - JWT token string (spatial zones use JWT verification)
1939
- */
1940
- validateSpatialZoneAccess(agentToken) {
1941
- if (!agentToken) return;
1942
- const enforcer = this.getSpatialZoneEnforcer();
1943
- const zoneIds = enforcer.getRegisteredZoneIds();
1944
- if (zoneIds.length === 0) return;
1945
- for (const zoneId of zoneIds) {
1946
- const decision = enforcer.checkZoneAccess(
1947
- agentToken,
1948
- zoneId,
1949
- "spatial:read" /* SPATIAL_READ */
1950
- );
1951
- if (!decision.allowed) {
1952
- console.warn(
1953
- `[${this.compilerName}] Spatial zone access warning: agent ${decision.agentId ?? "unknown"} denied SPATIAL_READ in zone "${zoneId}": ${decision.reason}`
1954
- );
1955
- }
1956
- }
1957
- }
1958
- // =========================================================================
1959
- // Dual-mode access validation (P3 Migration Bridge)
1960
- // =========================================================================
1961
- /**
1962
- * Validate all compiler permissions in single call (dual-mode).
1963
- *
1964
- * **P3 Migration Bridge**: This method now accepts both JWT RBAC tokens
1965
- * (string) and UCAN capability tokens (CapabilityTokenCredential).
1966
- *
1967
- * Token routing:
1968
- * - `undefined` / `null` / empty string: Skip all validation (backwards compatibility)
1969
- * - `string` (non-empty): Route to legacy JWT RBAC via AgentRBAC.checkAccess()
1970
- * - `CapabilityTokenCredential`: Route to UCAN via CapabilityRBAC.checkAccess()
1971
- *
1972
- * Convenience method combining AST access + code generation + optional output validation.
1973
- * Skips ALL validation when no token is provided (backwards compatibility / testing).
1974
- *
1975
- * @param agentToken - JWT token string OR UCAN CapabilityTokenCredential (optional)
1976
- * @param outputPath - Optional output path
1977
- * @throws UnauthorizedCompilerAccessError if any validation fails
1978
- */
1979
- validateCompilerAccess(agentToken, outputPath) {
1980
- if (!agentToken) return;
1981
- if (isCapabilityTokenCredential(agentToken)) {
1982
- this.validateCapabilityAccess(agentToken, outputPath);
1983
- return;
1984
- }
1985
- this.validateASTAccess(agentToken);
1986
- this.validateCodeGeneration(agentToken);
1987
- if (outputPath) {
1988
- this.validateOutputPath(agentToken, outputPath);
1989
- }
1990
- this.validateSpatialZoneAccess(agentToken);
1991
- }
1992
- // =========================================================================
1993
- // Cultural compatibility validation
1994
- // =========================================================================
1995
- /**
1996
- * Extract cultural profile from an agent token.
1997
- *
1998
- * @param agentToken - JWT token string (capability tokens do not carry cultural profiles)
1999
- * @returns The cultural profile if present, or null
2000
- */
2001
- extractCulturalProfile(agentToken) {
2002
- if (!agentToken) return null;
2003
- return this.rbac.extractCulturalProfile(agentToken);
2004
- }
2005
- /**
2006
- * Validate cultural compatibility across multiple agent tokens.
2007
- *
2008
- * Subclasses can call this during multi-agent compilation to ensure
2009
- * all participating agents have compatible cultural profiles before
2010
- * proceeding with code generation.
2011
- *
2012
- * @param agentTokens - Map of agent name to JWT token
2013
- * @param normSets - Optional map of agent name to norm_set arrays
2014
- * @returns Cultural compatibility result, or null if fewer than 2 agents
2015
- * have cultural profiles
2016
- */
2017
- validateCulturalCompatibility(agentTokens, normSets) {
2018
- return this.rbac.validateCulturalCompatibility(agentTokens, normSets);
2019
- }
2020
- };
2021
- }
2022
- });
2023
-
2024
- export { ANSCapabilityPath, CompilerBase, CompilerDocumentationGenerator, UnauthorizedCompilerAccessError, createTestCompilerToken, escapeStringValue, init_ANSNamespace, init_CompilerBase, init_CompilerDocumentationGenerator, isCapabilityTokenCredential };
2025
- //# sourceMappingURL=chunk-QWKUKVRE.js.map
2026
- //# sourceMappingURL=chunk-QWKUKVRE.js.map