@holoscript/core 6.0.4 → 6.1.2

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 (351) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -3
  3. package/bin/holoscript.cjs +3 -0
  4. package/dist/GLTFPipeline-SFIORFJU.js +16 -0
  5. package/dist/GLTFPipeline-VNNDPONV.cjs +37 -0
  6. package/dist/{HoloScriptPlusParser-BN6KVRCM.js → HoloScriptPlusParser-7FBIFUFC.js} +6 -5
  7. package/dist/{HoloScriptPlusParser-NC5FE6AL.cjs → HoloScriptPlusParser-A2W7OCN2.cjs} +17 -16
  8. package/dist/HoloScriptPlusParser-F2Z56FJR.js +10 -0
  9. package/dist/HoloScriptPlusParser-WKHRIH6T.cjs +27 -0
  10. package/dist/{USDZExporter-UWGWNMMD.cjs → USDZExporter-3FWJ25JI.cjs} +344 -16
  11. package/dist/{USDZExporter-NTMBNTDB.js → USDZExporter-D2HQLQYK.js} +344 -16
  12. package/dist/agents/index.cjs +19 -0
  13. package/dist/agents/index.d.ts +100 -0
  14. package/dist/agents/index.js +17 -0
  15. package/dist/chunk-22W6NGYN.js +725 -0
  16. package/dist/{chunk-5OEOHAAW.cjs → chunk-27MPVJVZ.cjs} +64 -28
  17. package/dist/{chunk-RVYPEYPX.js → chunk-2A7FURVO.js} +44 -8
  18. package/dist/{chunk-XCWFGZAA.js → chunk-2B7WVIDZ.js} +11 -8
  19. package/dist/{chunk-NDQNIJEH.js → chunk-2BSMSUCE.js} +250 -24
  20. package/dist/chunk-2HLIGOKU.cjs +5546 -0
  21. package/dist/{chunk-EONILVMF.js → chunk-2M2DPHKB.js} +4 -4
  22. package/dist/{chunk-G7CT3EMP.cjs → chunk-2YSNA2F2.cjs} +319 -47
  23. package/dist/{chunk-IWI6J7FX.js → chunk-33XCOVE3.js} +5 -5
  24. package/dist/chunk-3FOKASKO.cjs +348 -0
  25. package/dist/{chunk-DXJQDCFL.js → chunk-4C57PR42.js} +3 -3
  26. package/dist/{chunk-MPXBVFHQ.js → chunk-4N4SXXWF.js} +4 -3
  27. package/dist/chunk-4PDEPEQW.cjs +41 -0
  28. package/dist/chunk-4R6HPSHJ.js +2176 -0
  29. package/dist/chunk-4R6SBXDB.js +45 -0
  30. package/dist/chunk-4SY77NA4.cjs +413 -0
  31. package/dist/{chunk-YCXFCXDS.js → chunk-4UUKPCY4.js} +668 -110
  32. package/dist/{chunk-LGGRPKTV.cjs → chunk-52ULD552.cjs} +114 -35
  33. package/dist/{chunk-L4G4RLXX.js → chunk-5CKA5SXU.js} +438 -22
  34. package/dist/chunk-5FSKKMR7.cjs +2092 -0
  35. package/dist/{chunk-FF3Q7ADR.js → chunk-5JEU52DW.js} +5 -3
  36. package/dist/chunk-5N54COB6.cjs +327 -0
  37. package/dist/chunk-5S7RKFGR.cjs +446 -0
  38. package/dist/{chunk-KED34ILP.js → chunk-6ASWLXXN.js} +21 -9
  39. package/dist/chunk-6CTRH7HT.cjs +1985 -0
  40. package/dist/{chunk-CAUCGUEA.cjs → chunk-6EX3I5P4.cjs} +6 -6
  41. package/dist/chunk-6FGQNDR4.js +5731 -0
  42. package/dist/{chunk-72EQECGT.cjs → chunk-6KMK2UXT.cjs} +122 -46
  43. package/dist/{chunk-G4VZTCIB.js → chunk-6L4VE27M.js} +33 -23
  44. package/dist/{chunk-ATSKSYVE.cjs → chunk-6S6TKNEA.cjs} +6478 -1738
  45. package/dist/chunk-77V4GTCA.js +596 -0
  46. package/dist/{chunk-ZP4D3CSX.cjs → chunk-7AD52FRS.cjs} +16 -16
  47. package/dist/chunk-A6KINLZJ.js +236 -0
  48. package/dist/chunk-AIA52I7T.cjs +543 -0
  49. package/dist/chunk-AIX25INK.cjs +602 -0
  50. package/dist/{chunk-B5TCIAPQ.cjs → chunk-AO4I2Z7M.cjs} +17 -18
  51. package/dist/{chunk-Q5SJOGHQ.cjs → chunk-BPICAGBV.cjs} +324 -199
  52. package/dist/chunk-BRQJKJGT.cjs +20 -0
  53. package/dist/{chunk-3FXV5S25.cjs → chunk-C37BHB7N.cjs} +6 -3
  54. package/dist/{chunk-XUTX5CBW.js → chunk-CBJY23VL.js} +3 -3
  55. package/dist/chunk-CIWWXYHZ.cjs +50 -0
  56. package/dist/{chunk-XXINBTZK.cjs → chunk-DIL6DDDN.cjs} +101 -45
  57. package/dist/chunk-DMXC24WV.js +404 -0
  58. package/dist/{chunk-PMGODDJA.cjs → chunk-DTGBOSEM.cjs} +12 -12
  59. package/dist/chunk-E7JP3BS3.cjs +61 -0
  60. package/dist/{chunk-HJJLD366.js → chunk-EKBKLK7P.js} +3 -3
  61. package/dist/chunk-EKYL4PE3.cjs +404 -0
  62. package/dist/{chunk-UPJBDCVF.js → chunk-EMMC5CSQ.js} +12 -8
  63. package/dist/{chunk-GGHSW2NN.js → chunk-EOBB6A4B.js} +6389 -1718
  64. package/dist/chunk-EOFNVCM6.js +325 -0
  65. package/dist/{chunk-FHQVYCH2.js → chunk-ER4GATIU.js} +7 -7
  66. package/dist/{chunk-N5FTS757.cjs → chunk-EXKSFGSX.cjs} +7 -148
  67. package/dist/{chunk-LK5IAVH6.cjs → chunk-EXUP2BUM.cjs} +27 -27
  68. package/dist/chunk-FDSGHPAK.js +130 -0
  69. package/dist/chunk-FEWUHQNM.cjs +144 -0
  70. package/dist/{chunk-5TOFIR6L.js → chunk-FGGJQRLZ.js} +5 -142
  71. package/dist/chunk-FHP6LXJS.js +415 -0
  72. package/dist/{chunk-7LCYLPW2.cjs → chunk-FJPADH77.cjs} +7 -4
  73. package/dist/{chunk-T36DDXSF.js → chunk-FXKTYFYA.js} +150 -25
  74. package/dist/chunk-G2LS3RFO.js +623 -0
  75. package/dist/chunk-GCMWDSBZ.cjs +729 -0
  76. package/dist/chunk-GJNCFRJU.cjs +125 -0
  77. package/dist/{chunk-Q4QX3AET.cjs → chunk-GMP623FG.cjs} +16 -13
  78. package/dist/{chunk-XD6IYDUX.js → chunk-GN3KDX4W.js} +119 -43
  79. package/dist/{chunk-QLEAOI3Q.cjs → chunk-GQYKQSTC.cjs} +10 -10
  80. package/dist/chunk-GTU2Z2WW.cjs +262 -0
  81. package/dist/chunk-GZG4KA4E.js +529 -0
  82. package/dist/{chunk-BND3ST2K.cjs → chunk-H3MGK7TX.cjs} +42 -32
  83. package/dist/{chunk-XRKWN5PL.cjs → chunk-H5DZIHJP.cjs} +14 -18
  84. package/dist/{chunk-Z34RLXRA.cjs → chunk-HANL7K2Q.cjs} +65 -50
  85. package/dist/{chunk-3SAK5KFL.cjs → chunk-HCCQLAA4.cjs} +2 -11
  86. package/dist/{chunk-LXJ4667L.cjs → chunk-HGVXZDSK.cjs} +108 -20
  87. package/dist/{chunk-3FJCK5XA.js → chunk-HRODTEEO.js} +30 -10
  88. package/dist/{chunk-HQUEA5R6.cjs → chunk-HZCQO4JM.cjs} +6 -6
  89. package/dist/{chunk-S565K7NK.js → chunk-I2O7TW6B.js} +12 -8
  90. package/dist/chunk-IHESJZSW.js +4490 -0
  91. package/dist/{chunk-FSF7EQVA.cjs → chunk-IRWWS72C.cjs} +63 -22
  92. package/dist/{chunk-5O6TQC6M.cjs → chunk-IVIA7K75.cjs} +689 -127
  93. package/dist/chunk-IVY74O6C.js +247 -0
  94. package/dist/chunk-J32ZJZJH.js +554 -0
  95. package/dist/chunk-J56PTA46.cjs +639 -0
  96. package/dist/chunk-JD7CIZ33.js +1949 -0
  97. package/dist/{chunk-T7LEXZUZ.cjs → chunk-JIYN45TV.cjs} +14 -15
  98. package/dist/{chunk-FFKU7BTK.cjs → chunk-KHPCJRI3.cjs} +24 -21
  99. package/dist/chunk-KKFZ3B6J.cjs +557 -0
  100. package/dist/chunk-KPJL34Y7.cjs +186 -0
  101. package/dist/{chunk-HE7ULERA.cjs → chunk-KQTPCYTG.cjs} +128 -44
  102. package/dist/{chunk-OFKWH2IP.js → chunk-KX76JUQY.js} +3 -3
  103. package/dist/{chunk-33LSUQDD.cjs → chunk-L63H3SQ4.cjs} +43 -31
  104. package/dist/{chunk-K6EKD26I.js → chunk-LAOCQJ2M.js} +64 -8
  105. package/dist/chunk-LM2VU56C.cjs +37 -0
  106. package/dist/chunk-M56JSP4A.js +400 -0
  107. package/dist/chunk-MBOOR7X4.js +18 -0
  108. package/dist/{chunk-XWPNTWDN.cjs → chunk-MJVIRCUV.cjs} +31 -27
  109. package/dist/{chunk-SDAMZIRE.js → chunk-MSMIFMBL.js} +135 -18
  110. package/dist/{chunk-56IF4NTA.js → chunk-MXFUTKCO.js} +18 -18
  111. package/dist/{chunk-6UEHYZ7V.cjs → chunk-MXJ5SS53.cjs} +447 -31
  112. package/dist/chunk-MYY4PMWX.cjs +264 -0
  113. package/dist/chunk-N75IH2HY.js +258 -0
  114. package/dist/{chunk-GVUR45UF.cjs → chunk-NG77ATEW.cjs} +7 -6
  115. package/dist/chunk-NW5G5FBQ.js +215 -0
  116. package/dist/{chunk-E3FWRT3Z.js → chunk-OEFY723R.js} +28 -13
  117. package/dist/chunk-OEV5RMZO.cjs +3042 -0
  118. package/dist/{chunk-X4ZF6CNE.cjs → chunk-OIQYIIO3.cjs} +7 -7
  119. package/dist/{chunk-2CWOLHTE.js → chunk-OL46QLBJ.js} +3 -11
  120. package/dist/chunk-OPZ7XDDI.js +487 -0
  121. package/dist/chunk-OSYNRVOV.cjs +243 -0
  122. package/dist/{chunk-TEWCN33Y.js → chunk-P7YIA5LN.js} +91 -7
  123. package/dist/chunk-PGANYCAG.cjs +220 -0
  124. package/dist/{chunk-CS2EMTGF.js → chunk-QAVXL2IH.js} +62 -21
  125. package/dist/{chunk-T4NKMBDL.js → chunk-QCCBXSCE.js} +1666 -756
  126. package/dist/{chunk-F4IULT7N.js → chunk-QPOQ7VPI.js} +16 -13
  127. package/dist/{chunk-6XSERL6L.js → chunk-QTPMJRGS.js} +3108 -2827
  128. package/dist/{chunk-F3HH56EB.cjs → chunk-QWNQ523V.cjs} +1730 -823
  129. package/dist/{chunk-R7MA7QWV.js → chunk-R3IVNY6P.js} +102 -23
  130. package/dist/chunk-R75BSDH7.cjs +50 -0
  131. package/dist/chunk-RAXUF5DF.cjs +2196 -0
  132. package/dist/{chunk-BF2235SI.cjs → chunk-RMHC2VG7.cjs} +2876 -2592
  133. package/dist/chunk-RUXGBKPS.cjs +4517 -0
  134. package/dist/{chunk-UERJ3YJV.js → chunk-S5IFXW6E.js} +113 -9
  135. package/dist/{chunk-27LWW5FU.cjs → chunk-S6YWHCKV.cjs} +5 -5
  136. package/dist/{chunk-WB4Z63GG.js → chunk-SIEXCILW.js} +3 -3
  137. package/dist/{chunk-CLYEIWA5.cjs → chunk-SLU6UPJI.cjs} +5 -3
  138. package/dist/{chunk-LZ266PCM.cjs → chunk-T5J7ZKP3.cjs} +446 -60
  139. package/dist/chunk-TDCNJHWO.js +341 -0
  140. package/dist/{chunk-IHOUYQIA.js → chunk-TG7O4WBC.js} +5 -5
  141. package/dist/chunk-THCK6ECW.js +2085 -0
  142. package/dist/chunk-TJHVSBP2.js +439 -0
  143. package/dist/chunk-TK74TR4H.js +5541 -0
  144. package/dist/{chunk-CDPGV4DN.js → chunk-U4NBQJBY.js} +14 -15
  145. package/dist/{chunk-NOZZ46QU.js → chunk-UD3DSHZM.js} +10 -14
  146. package/dist/chunk-UDMYRFDZ.js +3038 -0
  147. package/dist/{chunk-WDW67DZB.cjs → chunk-UOIGFQXC.cjs} +90 -68
  148. package/dist/{chunk-BU7VWW2K.js → chunk-URG2SJLK.js} +14 -15
  149. package/dist/{chunk-EQV4R3EV.cjs → chunk-V73NPPTM.cjs} +152 -35
  150. package/dist/chunk-VECQYRXL.js +474 -0
  151. package/dist/chunk-VEXPG4WN.js +1989 -0
  152. package/dist/{chunk-LDP5OK6G.js → chunk-VMLKSV26.js} +5 -5
  153. package/dist/{chunk-5BGSECRJ.cjs → chunk-VSK7W3O5.cjs} +47 -27
  154. package/dist/chunk-VVKVQZI6.js +55 -0
  155. package/dist/{chunk-YQK5JNFK.js → chunk-W55Z7QIX.js} +103 -15
  156. package/dist/{chunk-KSGXLT74.cjs → chunk-W6P2GBHH.cjs} +3 -3
  157. package/dist/{chunk-IBDG74G2.cjs → chunk-W6RW64BB.cjs} +7 -7
  158. package/dist/chunk-WDT3JTGM.cjs +483 -0
  159. package/dist/{chunk-HPS76H7Q.js → chunk-WKX5AMOY.js} +3 -3
  160. package/dist/chunk-WNNE3PO3.js +34 -0
  161. package/dist/{chunk-XG23EUQX.cjs → chunk-WRLUBRKS.cjs} +538 -312
  162. package/dist/{chunk-IFNQFCTM.js → chunk-WRNEH5MO.js} +79 -8
  163. package/dist/{chunk-54FHG2MX.js → chunk-WRWEX5ZF.js} +7 -4
  164. package/dist/{chunk-KCQ5NDYC.cjs → chunk-X3GJPRVK.cjs} +154 -80
  165. package/dist/{chunk-7AGYRWKW.cjs → chunk-XFXGA5IW.cjs} +126 -22
  166. package/dist/{chunk-TQSZUOW5.cjs → chunk-XHIV6326.cjs} +4 -4
  167. package/dist/chunk-XJAN7CZG.cjs +432 -0
  168. package/dist/chunk-XL6INWKT.js +121 -0
  169. package/dist/{chunk-E3UALNFA.js → chunk-XMWZG36H.js} +4 -4
  170. package/dist/{chunk-BKIGPPVM.js → chunk-XSFNHP2E.js} +6 -3
  171. package/dist/{chunk-H5Z7NASB.js → chunk-XT6JY5W5.js} +25 -3
  172. package/dist/chunk-XXZJEFKW.cjs +490 -0
  173. package/dist/chunk-Y3MWXQSB.cjs +5737 -0
  174. package/dist/chunk-YF2I3MV3.js +46 -0
  175. package/dist/{chunk-V3NN3HPP.js → chunk-YIMN575O.js} +437 -52
  176. package/dist/chunk-YIVFJNYV.js +176 -0
  177. package/dist/{chunk-MD6KDHVE.cjs → chunk-YKGPCZEE.cjs} +10 -10
  178. package/dist/chunk-YQELFNJV.js +39 -0
  179. package/dist/chunk-Z5XMPRNC.cjs +5390 -0
  180. package/dist/{chunk-3FYZOR7S.cjs → chunk-ZDSYWBIE.cjs} +18 -18
  181. package/dist/{chunk-6TZPZCOJ.cjs → chunk-ZKSS47EV.cjs} +24 -19
  182. package/dist/chunk-ZUL5AVTX.cjs +1993 -0
  183. package/dist/chunk-ZXBZVXDW.js +5386 -0
  184. package/dist/{chunk-DMG7C4H2.js → chunk-ZZ7RO2UQ.js} +312 -44
  185. package/dist/cli/holoscript-runner.cjs +200 -204
  186. package/dist/cli/holoscript-runner.js +144 -148
  187. package/dist/codebase/index.cjs +1 -1
  188. package/dist/codebase/index.js +1 -1
  189. package/dist/compiler/agent-inference.cjs +10 -7
  190. package/dist/compiler/agent-inference.js +6 -3
  191. package/dist/compiler/android-xr.cjs +12 -7
  192. package/dist/compiler/android-xr.js +10 -5
  193. package/dist/compiler/android.cjs +12 -8
  194. package/dist/compiler/android.js +10 -6
  195. package/dist/compiler/ar.cjs +9 -6
  196. package/dist/compiler/ar.js +7 -4
  197. package/dist/compiler/babylon.cjs +12 -8
  198. package/dist/compiler/babylon.js +11 -7
  199. package/dist/compiler/business-quest.cjs +43 -0
  200. package/dist/compiler/business-quest.js +4 -0
  201. package/dist/compiler/coco.cjs +1 -1
  202. package/dist/compiler/coco.js +1 -1
  203. package/dist/compiler/context.cjs +25 -0
  204. package/dist/compiler/context.d.ts +28 -0
  205. package/dist/compiler/context.js +8 -0
  206. package/dist/compiler/domain-block-utils.cjs +155 -152
  207. package/dist/compiler/domain-block-utils.js +7 -4
  208. package/dist/compiler/dtdl.cjs +10 -7
  209. package/dist/compiler/dtdl.js +7 -4
  210. package/dist/compiler/gltf-pipeline.cjs +9 -9
  211. package/dist/compiler/gltf-pipeline.js +2 -2
  212. package/dist/compiler/godot.cjs +9 -6
  213. package/dist/compiler/godot.js +8 -5
  214. package/dist/compiler/incremental.cjs +12 -7
  215. package/dist/compiler/incremental.js +7 -2
  216. package/dist/compiler/index.cjs +3550 -268
  217. package/dist/compiler/index.d.ts +404 -21
  218. package/dist/compiler/index.js +3280 -138
  219. package/dist/compiler/ios.cjs +11 -8
  220. package/dist/compiler/ios.js +9 -6
  221. package/dist/compiler/llm-provider-capabilities.cjs +25 -0
  222. package/dist/compiler/llm-provider-capabilities.d.ts +43 -0
  223. package/dist/compiler/llm-provider-capabilities.js +8 -0
  224. package/dist/compiler/multi-layer.cjs +14 -10
  225. package/dist/compiler/multi-layer.js +13 -9
  226. package/dist/compiler/nodetoy.cjs +5 -5
  227. package/dist/compiler/nodetoy.js +2 -2
  228. package/dist/compiler/openxr.cjs +10 -6
  229. package/dist/compiler/openxr.js +9 -5
  230. package/dist/compiler/playcanvas.cjs +10 -7
  231. package/dist/compiler/playcanvas.js +9 -6
  232. package/dist/compiler/r3f.cjs +17 -13
  233. package/dist/compiler/r3f.d.ts +22 -0
  234. package/dist/compiler/r3f.js +12 -8
  235. package/dist/compiler/remotion.cjs +1 -1
  236. package/dist/compiler/remotion.js +1 -1
  237. package/dist/compiler/reproducibility.cjs +1 -1
  238. package/dist/compiler/reproducibility.js +1 -1
  239. package/dist/compiler/sdf.cjs +10 -7
  240. package/dist/compiler/sdf.js +8 -5
  241. package/dist/compiler/semantic-scene.cjs +1 -1
  242. package/dist/compiler/semantic-scene.js +1 -1
  243. package/dist/compiler/state.cjs +9 -5
  244. package/dist/compiler/state.js +7 -3
  245. package/dist/compiler/trait-composition.cjs +11 -7
  246. package/dist/compiler/trait-composition.js +7 -3
  247. package/dist/compiler/unity.cjs +10 -6
  248. package/dist/compiler/unity.js +9 -5
  249. package/dist/compiler/unreal.cjs +11 -7
  250. package/dist/compiler/unreal.js +9 -5
  251. package/dist/compiler/urdf.cjs +20 -13
  252. package/dist/compiler/urdf.js +8 -5
  253. package/dist/compiler/usd-physics.cjs +10 -7
  254. package/dist/compiler/usd-physics.js +7 -4
  255. package/dist/compiler/visionos.cjs +10 -6
  256. package/dist/compiler/visionos.js +9 -5
  257. package/dist/compiler/vrchat.cjs +10 -7
  258. package/dist/compiler/vrchat.js +8 -5
  259. package/dist/compiler/vrr.cjs +10 -7
  260. package/dist/compiler/vrr.js +8 -5
  261. package/dist/compiler/wasm.cjs +13 -10
  262. package/dist/compiler/wasm.js +8 -5
  263. package/dist/compiler/webgpu.cjs +9 -6
  264. package/dist/compiler/webgpu.js +8 -5
  265. package/dist/constants.d.ts +3 -2
  266. package/dist/coordinators/index.cjs +1266 -0
  267. package/dist/coordinators/index.d.ts +260 -0
  268. package/dist/coordinators/index.js +1259 -0
  269. package/dist/debugger.cjs +9 -7
  270. package/dist/debugger.js +7 -5
  271. package/dist/entries/interop.cjs +23 -21
  272. package/dist/entries/interop.js +5 -3
  273. package/dist/entries/scripting.cjs +18 -18
  274. package/dist/entries/scripting.js +8 -8
  275. package/dist/hololand/index.cjs +146 -0
  276. package/dist/hololand/index.d.ts +70 -0
  277. package/dist/hololand/index.js +5 -0
  278. package/dist/index.cjs +20332 -18121
  279. package/dist/index.d.ts +1477 -40
  280. package/dist/index.js +19451 -17638
  281. package/dist/math/tropical-spmv.cjs +45 -0
  282. package/dist/math/tropical-spmv.js +4 -0
  283. package/dist/math/vec3.cjs +14 -14
  284. package/dist/math/vec3.js +2 -2
  285. package/dist/{ml-dsa-PHCWUBPX.cjs → ml-dsa-FSKBTE3W.cjs} +177 -90
  286. package/dist/{ml-dsa-WYLJHJO6.js → ml-dsa-Z7JDKW4L.js} +158 -71
  287. package/dist/paper-0c-spike/index.cjs +150 -0
  288. package/dist/paper-0c-spike/index.d.ts +29 -0
  289. package/dist/paper-0c-spike/index.js +141 -0
  290. package/dist/parser.cjs +45 -11
  291. package/dist/parser.d.ts +11 -0
  292. package/dist/parser.js +10 -8
  293. package/dist/{playwright-RL6GY4F7.cjs → playwright-3AT3AKTV.cjs} +1985 -1985
  294. package/dist/{playwright-5OSAPTNH.js → playwright-VZPDVUEQ.js} +3 -3
  295. package/dist/reconstruction/index.cjs +153 -0
  296. package/dist/reconstruction/index.d.ts +105 -0
  297. package/dist/reconstruction/index.js +8 -0
  298. package/dist/runtime.cjs +7 -5
  299. package/dist/runtime.js +6 -4
  300. package/dist/self-improvement/index.cjs +563 -0
  301. package/dist/self-improvement/index.js +545 -0
  302. package/dist/storage/index.cjs +10 -9
  303. package/dist/storage/index.js +3 -2
  304. package/dist/testing.cjs +25 -0
  305. package/dist/testing.d.ts +70 -0
  306. package/dist/testing.js +4 -0
  307. package/dist/tools/index.d.ts +22 -1
  308. package/dist/traitDocs/traitDocs.cjs +33 -0
  309. package/dist/traitDocs/traitDocs.d.ts +69 -0
  310. package/dist/traitDocs/traitDocs.js +7 -0
  311. package/dist/traits/botanical-lotus.cjs +41 -0
  312. package/dist/traits/botanical-lotus.d.ts +172 -0
  313. package/dist/traits/botanical-lotus.js +4 -0
  314. package/dist/traits/engines/index.cjs +520 -0
  315. package/dist/traits/engines/index.js +380 -0
  316. package/dist/traits/index.cjs +17630 -7881
  317. package/dist/traits/index.d.ts +197 -0
  318. package/dist/traits/index.js +16573 -7193
  319. package/dist/traits/simulation-solver-factory.cjs +13 -0
  320. package/dist/traits/simulation-solver-factory.d.ts +23 -0
  321. package/dist/traits/simulation-solver-factory.js +4 -0
  322. package/dist/traits/webcam-gaze.cjs +35 -0
  323. package/dist/traits/webcam-gaze.d.ts +17 -0
  324. package/dist/traits/webcam-gaze.js +4 -0
  325. package/dist/type-checker.cjs +6 -5
  326. package/dist/type-checker.js +4 -3
  327. package/dist/world/index.cjs +947 -0
  328. package/dist/world/index.d.ts +147 -0
  329. package/dist/world/index.js +939 -0
  330. package/dist/world-model/index.cjs +1446 -0
  331. package/dist/world-model/index.d.ts +119 -0
  332. package/dist/world-model/index.js +1414 -0
  333. package/dist/wot/index.cjs +29 -0
  334. package/dist/wot/index.js +4 -0
  335. package/package.json +153 -61
  336. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  337. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  338. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  339. package/dist/chunk-A7PIMZGU.js +0 -263
  340. package/dist/chunk-BWFJEM5A.js +0 -5419
  341. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  342. package/dist/chunk-K3JDKWGI.cjs +0 -270
  343. package/dist/chunk-LSW7P7ML.js +0 -3675
  344. package/dist/chunk-MEASWI2Y.js +0 -126
  345. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  346. package/dist/chunk-Q5JT3YML.cjs +0 -129
  347. package/dist/chunk-QGKNANZ3.js +0 -3071
  348. package/dist/chunk-S2N5TNMA.js +0 -1855
  349. package/dist/chunk-TSH3MSQU.cjs +0 -129
  350. package/dist/chunk-WGMEAYBG.js +0 -126
  351. package/dist/chunk-X6SEAXAX.cjs +0 -3681
@@ -0,0 +1,1949 @@
1
+ import { init_AgentRiskRegistry, getAgentRiskRegistry } from './chunk-N75IH2HY.js';
2
+ import { __export } from './chunk-OL46QLBJ.js';
3
+
4
+ // src/hololand/index.ts
5
+ var hololand_exports = {};
6
+ __export(hololand_exports, {
7
+ CrossValidationRegistry: () => CrossValidationRegistry,
8
+ DEFAULT_ENVELOPES: () => DEFAULT_ENVELOPES,
9
+ DEFAULT_ITEM_AUTONOMOUS_AGENDA: () => DEFAULT_ITEM_AUTONOMOUS_AGENDA,
10
+ DEFAULT_ITEM_REPUTATION_LEDGER: () => DEFAULT_ITEM_REPUTATION_LEDGER,
11
+ DEFAULT_ITEM_VERBAL_FINGERPRINT: () => DEFAULT_ITEM_VERBAL_FINGERPRINT,
12
+ DEFAULT_ITEM_VOCABULARY_REGISTER: () => DEFAULT_ITEM_VOCABULARY_REGISTER,
13
+ HEARTBEAT_INTERVAL: () => HEARTBEAT_INTERVAL,
14
+ HololandClient: () => HololandClient,
15
+ ITEM_DEFAULT_TICK_INTERVAL_MS: () => ITEM_DEFAULT_TICK_INTERVAL_MS,
16
+ MAX_CHUNK_SIZE: () => MAX_CHUNK_SIZE,
17
+ MAX_MESSAGE_SIZE: () => MAX_MESSAGE_SIZE,
18
+ PROTOCOL_VERSION: () => PROTOCOL_VERSION,
19
+ PhysicsBoundsRegistry: () => PhysicsBoundsRegistry,
20
+ StreamProtocol: () => StreamProtocol,
21
+ TIMEOUT_INTERVAL: () => TIMEOUT_INTERVAL,
22
+ computeConsensus: () => computeConsensus,
23
+ connectToHololand: () => connectToHololand,
24
+ createHoloLandItem: () => createHoloLandItem,
25
+ createStreamMessage: () => createMessage,
26
+ createWorldConfig: () => createWorldConfig,
27
+ createWorldDefinition: () => createWorldDefinition,
28
+ createWorldEnvironment: () => createWorldEnvironment,
29
+ createWorldMetadata: () => createWorldMetadata,
30
+ disconnectFromHololand: () => disconnectFromHololand,
31
+ getCrossValidationRegistry: () => getCrossValidationRegistry,
32
+ getHololandClient: () => getHololandClient,
33
+ getItemChain: () => getItemChain,
34
+ getPhysicsBoundsRegistry: () => getPhysicsBoundsRegistry,
35
+ getStreamProtocol: () => getStreamProtocol,
36
+ linkItems: () => linkItems,
37
+ resetCrossValidationRegistry: () => resetCrossValidationRegistry,
38
+ resetPhysicsBoundsRegistry: () => resetPhysicsBoundsRegistry,
39
+ suggestedQuorum: () => suggestedQuorum,
40
+ wrapPhysicsService: () => wrapPhysicsService
41
+ });
42
+
43
+ // src/hololand/WorldDefinitionSchema.ts
44
+ function createWorldMetadata(id, name, options = {}) {
45
+ return {
46
+ id,
47
+ name,
48
+ displayName: options.displayName ?? name,
49
+ description: options.description,
50
+ version: options.version ?? "1.0.0",
51
+ author: options.author,
52
+ license: options.license,
53
+ tags: options.tags ?? [],
54
+ thumbnailUrl: options.thumbnailUrl,
55
+ previewImages: options.previewImages ?? [],
56
+ platforms: options.platforms ?? ["web"],
57
+ ageRating: options.ageRating ?? "everyone",
58
+ category: options.category ?? "experience",
59
+ createdAt: options.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
60
+ modifiedAt: (/* @__PURE__ */ new Date()).toISOString(),
61
+ status: options.status ?? "draft",
62
+ metadata: options.metadata ?? {}
63
+ };
64
+ }
65
+ function createWorldConfig(options = {}) {
66
+ return {
67
+ maxUsers: options.maxUsers ?? 50,
68
+ bounds: options.bounds ?? {
69
+ minX: -1e3,
70
+ maxX: 1e3,
71
+ minY: -100,
72
+ maxY: 500,
73
+ minZ: -1e3,
74
+ maxZ: 1e3,
75
+ wrap: false,
76
+ outOfBoundsAction: "teleport"
77
+ },
78
+ physics: options.physics ?? {
79
+ engine: "rapier",
80
+ gravity: [0, -9.81, 0],
81
+ fixedTimestep: 1 / 60,
82
+ maxSubsteps: 4,
83
+ collisionDetection: "continuous",
84
+ sleepThreshold: 0.01
85
+ },
86
+ rendering: options.rendering ?? {
87
+ targetFPS: 72,
88
+ shadows: true,
89
+ shadowQuality: "medium",
90
+ antiAliasing: "fxaa",
91
+ msaaSamples: 4,
92
+ bloom: true,
93
+ ambientOcclusion: true,
94
+ aoQuality: "medium",
95
+ toneMapping: "aces",
96
+ exposure: 1,
97
+ fog: false
98
+ },
99
+ audio: options.audio ?? {
100
+ masterVolume: 1,
101
+ spatialAudio: true,
102
+ hrtfProfile: "default",
103
+ reverbPreset: "room",
104
+ maxSources: 32,
105
+ distanceModel: "inverse",
106
+ rolloffFactor: 1
107
+ },
108
+ networking: options.networking ?? {
109
+ region: "auto",
110
+ tickRate: 20,
111
+ interpolationDelay: 100,
112
+ prediction: true,
113
+ protocol: "websocket",
114
+ compression: "lz4",
115
+ syncStrategy: "delta",
116
+ interestRadius: 100
117
+ },
118
+ performance: options.performance ?? {
119
+ maxDrawCalls: 1e3,
120
+ maxTriangles: 2e6,
121
+ maxTextureMemory: 512,
122
+ maxAudioSources: 32,
123
+ maxPhysicsBodies: 1e3,
124
+ maxNetworkedEntities: 500,
125
+ cpuBudgetMs: 11
126
+ },
127
+ accessibility: options.accessibility ?? {
128
+ subtitles: true,
129
+ audioDescriptions: false,
130
+ colorblindMode: "none",
131
+ reduceMotion: false,
132
+ highContrast: false,
133
+ screenReader: true,
134
+ hapticIntensity: 1
135
+ }
136
+ };
137
+ }
138
+ function createWorldEnvironment(options = {}) {
139
+ return {
140
+ skybox: options.skybox ?? {
141
+ type: "procedural",
142
+ procedural: {
143
+ turbidity: 10,
144
+ rayleigh: 2,
145
+ mieCoefficient: 5e-3,
146
+ mieDirectionalG: 0.8,
147
+ sunPosition: [0, 1, 0]
148
+ }
149
+ },
150
+ ambientLight: options.ambientLight ?? {
151
+ color: "#ffffff",
152
+ intensity: 0.4,
153
+ groundColor: "#444444"
154
+ },
155
+ directionalLights: options.directionalLights ?? [
156
+ {
157
+ id: "sun",
158
+ color: "#fffaf0",
159
+ intensity: 1,
160
+ direction: [-0.5, -1, -0.5],
161
+ castShadow: true,
162
+ shadowMapSize: 2048,
163
+ shadowBias: -1e-4
164
+ }
165
+ ],
166
+ environmentMap: options.environmentMap,
167
+ timeOfDay: options.timeOfDay,
168
+ weather: options.weather,
169
+ postProcessing: options.postProcessing ?? {
170
+ enabled: true,
171
+ effects: []
172
+ }
173
+ };
174
+ }
175
+ function createWorldDefinition(id, name, options = {}) {
176
+ return {
177
+ schemaVersion: "1.0.0",
178
+ metadata: createWorldMetadata(id, name),
179
+ config: createWorldConfig(),
180
+ environment: createWorldEnvironment(),
181
+ zones: options.zones ?? [],
182
+ spawnPoints: options.spawnPoints ?? [
183
+ {
184
+ id: "default-spawn",
185
+ name: "Default Spawn",
186
+ position: [0, 0, 0],
187
+ rotation: [0, 0, 0],
188
+ type: "default",
189
+ priority: 10,
190
+ capacity: 100,
191
+ tags: ["default"]
192
+ }
193
+ ],
194
+ assetManifest: options.assetManifest ?? "",
195
+ prefabs: options.prefabs ?? [],
196
+ sceneGraph: options.sceneGraph ?? {
197
+ id: "root",
198
+ name: "Root",
199
+ type: "group",
200
+ transform: {
201
+ position: [0, 0, 0],
202
+ rotation: [0, 0, 0],
203
+ scale: [1, 1, 1]
204
+ },
205
+ components: [],
206
+ children: [],
207
+ active: true,
208
+ tags: [],
209
+ layers: 1
210
+ },
211
+ scripts: options.scripts ?? [],
212
+ events: options.events ?? [],
213
+ lod: options.lod ?? {
214
+ enabled: true,
215
+ distances: [25, 50, 100, 200],
216
+ chunkSize: 64,
217
+ maxLoadedChunks: 9,
218
+ unloadDelay: 5
219
+ }
220
+ };
221
+ }
222
+
223
+ // src/hololand/HololandIntegration.ts
224
+ var _HololandClient = class _HololandClient {
225
+ constructor(config) {
226
+ this.services = null;
227
+ this.world = null;
228
+ this.eventHandlers = /* @__PURE__ */ new Map();
229
+ this.config = {
230
+ serverUrl: config.serverUrl ?? "wss://api.hololand.io",
231
+ apiKey: config.apiKey,
232
+ debug: config.debug ?? false,
233
+ autoReconnect: config.autoReconnect ?? true,
234
+ reconnectDelay: config.reconnectDelay ?? 1e3,
235
+ maxReconnectAttempts: config.maxReconnectAttempts ?? 10,
236
+ connectionTimeout: config.connectionTimeout ?? 3e4
237
+ };
238
+ this.connectionInfo = {
239
+ state: "disconnected",
240
+ serverUrl: this.config.serverUrl,
241
+ latency: 0,
242
+ bytesSent: 0,
243
+ bytesReceived: 0
244
+ };
245
+ }
246
+ static getInstance(config) {
247
+ if (!_HololandClient.instance) {
248
+ _HololandClient.instance = new _HololandClient(config ?? {});
249
+ }
250
+ return _HololandClient.instance;
251
+ }
252
+ static resetInstance() {
253
+ _HololandClient.instance?.disconnect();
254
+ _HololandClient.instance = null;
255
+ }
256
+ // ─── Connection Management ────────────────────────────────────────────────
257
+ /**
258
+ * Connect to Hololand server
259
+ */
260
+ async connect(worldId) {
261
+ if (this.connectionInfo.state === "connected") {
262
+ return;
263
+ }
264
+ this.setConnectionState("connecting");
265
+ try {
266
+ await this.simulateConnection();
267
+ if (worldId) {
268
+ await this.joinWorld(worldId);
269
+ }
270
+ this.setConnectionState("connected");
271
+ this.emit("connected", { sessionId: this.connectionInfo.sessionId });
272
+ } catch (error) {
273
+ this.connectionInfo.lastError = error.message;
274
+ this.setConnectionState("error");
275
+ throw error;
276
+ }
277
+ }
278
+ /**
279
+ * Disconnect from server
280
+ */
281
+ disconnect() {
282
+ if (this.connectionInfo.state === "disconnected") {
283
+ return;
284
+ }
285
+ this.setConnectionState("disconnected");
286
+ this.services = null;
287
+ this.world = null;
288
+ this.emit("disconnected", {});
289
+ }
290
+ /**
291
+ * Get connection info
292
+ */
293
+ getConnectionInfo() {
294
+ return { ...this.connectionInfo };
295
+ }
296
+ // ─── World Management ─────────────────────────────────────────────────────
297
+ /**
298
+ * Join a world
299
+ */
300
+ async joinWorld(worldId) {
301
+ if (this.connectionInfo.state !== "connected") {
302
+ throw new Error("Not connected to server");
303
+ }
304
+ const world = await this.fetchWorldDefinition(worldId);
305
+ this.world = world;
306
+ this.emit("worldJoined", { worldId, world });
307
+ return world;
308
+ }
309
+ /**
310
+ * Leave current world
311
+ */
312
+ async leaveWorld() {
313
+ if (!this.world) return;
314
+ const worldId = this.world.metadata.id;
315
+ this.world = null;
316
+ this.emit("worldLeft", { worldId });
317
+ }
318
+ /**
319
+ * Get current world
320
+ */
321
+ getCurrentWorld() {
322
+ return this.world;
323
+ }
324
+ /**
325
+ * Register a world definition
326
+ */
327
+ async registerWorld(world) {
328
+ if (this.connectionInfo.state !== "connected") {
329
+ throw new Error("Not connected to server");
330
+ }
331
+ const worldId = world.metadata.id;
332
+ this.emit("worldRegistered", { worldId });
333
+ return worldId;
334
+ }
335
+ /**
336
+ * Update world definition
337
+ */
338
+ async updateWorld(worldId, updates) {
339
+ if (this.connectionInfo.state !== "connected") {
340
+ throw new Error("Not connected to server");
341
+ }
342
+ this.emit("worldUpdated", { worldId, updates });
343
+ }
344
+ // ─── Runtime Services ─────────────────────────────────────────────────────
345
+ /**
346
+ * Get runtime services
347
+ */
348
+ getServices() {
349
+ if (!this.services) {
350
+ this.services = this.createServices();
351
+ }
352
+ return this.services;
353
+ }
354
+ /**
355
+ * Create runtime services (stub implementations)
356
+ */
357
+ createServices() {
358
+ return {
359
+ assets: this.createAssetService(),
360
+ networking: this.createNetworkingService(),
361
+ audio: this.createAudioService(),
362
+ physics: this.createPhysicsService(),
363
+ input: this.createInputService(),
364
+ analytics: this.createAnalyticsService(),
365
+ voice: this.createVoiceService(),
366
+ storage: this.createStorageService()
367
+ };
368
+ }
369
+ // ─── Service Factory Methods ──────────────────────────────────────────────
370
+ createAssetService() {
371
+ return {
372
+ requestAsset: async (assetId, _priority) => {
373
+ this.log(`Requesting asset: ${assetId}`);
374
+ return null;
375
+ },
376
+ prefetch: async (assetIds) => {
377
+ this.log(`Prefetching ${assetIds.length} assets`);
378
+ },
379
+ cancelLoad: (assetId) => {
380
+ this.log(`Cancelling load: ${assetId}`);
381
+ },
382
+ getProgress: (_assetId) => 0,
383
+ clearCache: () => {
384
+ this.log("Clearing asset cache");
385
+ },
386
+ getCacheStats: () => ({ size: 0, maxSize: 256 * 1024 * 1024, hitRate: 0 })
387
+ };
388
+ }
389
+ createNetworkingService() {
390
+ const subscriptions = /* @__PURE__ */ new Map();
391
+ return {
392
+ send: (channel, data) => {
393
+ this.log(`Send to ${channel}:`, data);
394
+ },
395
+ subscribe: (channel, handler) => {
396
+ if (!subscriptions.has(channel)) {
397
+ subscriptions.set(channel, /* @__PURE__ */ new Set());
398
+ }
399
+ subscriptions.get(channel).add(handler);
400
+ return () => subscriptions.get(channel)?.delete(handler);
401
+ },
402
+ rpc: async (_method, _params) => {
403
+ return null;
404
+ },
405
+ getConnectionInfo: () => this.connectionInfo,
406
+ setPlayerData: (_key, _value) => {
407
+ },
408
+ getPlayerData: (_key) => null
409
+ };
410
+ }
411
+ createAudioService() {
412
+ let handleId = 0;
413
+ return {
414
+ play: (soundId, _options) => {
415
+ const id = `audio_${handleId++}`;
416
+ this.log(`Playing sound: ${soundId}`);
417
+ return {
418
+ id,
419
+ stop: () => {
420
+ },
421
+ setVolume: () => {
422
+ },
423
+ setPitch: () => {
424
+ },
425
+ isPlaying: () => false
426
+ };
427
+ },
428
+ stop: (_handle) => {
429
+ },
430
+ setListenerPosition: (_position) => {
431
+ },
432
+ setListenerOrientation: (_forward, _up) => {
433
+ },
434
+ setMasterVolume: (_volume) => {
435
+ },
436
+ createSource: (soundId, _position) => {
437
+ const id = `source_${handleId++}`;
438
+ this.log(`Creating audio source: ${soundId}`);
439
+ return {
440
+ id,
441
+ play: () => {
442
+ },
443
+ stop: () => {
444
+ },
445
+ setPosition: () => {
446
+ },
447
+ setVolume: () => {
448
+ },
449
+ destroy: () => {
450
+ }
451
+ };
452
+ }
453
+ };
454
+ }
455
+ createPhysicsService() {
456
+ let bodyId = 0;
457
+ return {
458
+ createBody: (config) => {
459
+ const id = `body_${bodyId++}`;
460
+ this.log(`Creating physics body: ${config.type}`);
461
+ return {
462
+ id,
463
+ setPosition: () => {
464
+ },
465
+ setRotation: () => {
466
+ },
467
+ setVelocity: () => {
468
+ },
469
+ applyForce: () => {
470
+ },
471
+ applyImpulse: () => {
472
+ },
473
+ getPosition: () => [config.position[0], config.position[1], config.position[2]],
474
+ getVelocity: () => [0, 0, 0],
475
+ destroy: () => {
476
+ }
477
+ };
478
+ },
479
+ raycast: (_origin, _direction, _maxDistance) => null,
480
+ overlap: (_shape, _position) => [],
481
+ setGravity: (_gravity) => {
482
+ },
483
+ step: (_deltaTime) => {
484
+ }
485
+ };
486
+ }
487
+ createInputService() {
488
+ const bindings = /* @__PURE__ */ new Map();
489
+ return {
490
+ getValue: (_action) => 0,
491
+ isPressed: (_action) => false,
492
+ isJustPressed: (_action) => false,
493
+ isJustReleased: (_action) => false,
494
+ getPointerPosition: () => ({ x: 0, y: 0 }),
495
+ getXRController: (_hand) => null,
496
+ bindAction: (action, binding) => {
497
+ bindings.set(action, binding);
498
+ },
499
+ setVibration: (_hand, _intensity, _duration) => {
500
+ }
501
+ };
502
+ }
503
+ createAnalyticsService() {
504
+ const timings = /* @__PURE__ */ new Map();
505
+ return {
506
+ track: (event, properties) => {
507
+ this.log(`Analytics: ${event}`, properties);
508
+ },
509
+ setUserProperty: (_key, _value) => {
510
+ },
511
+ startTiming: (label) => {
512
+ timings.set(label, performance.now());
513
+ },
514
+ endTiming: (label) => {
515
+ const start = timings.get(label);
516
+ if (!start) return 0;
517
+ const duration = performance.now() - start;
518
+ timings.delete(label);
519
+ return duration;
520
+ },
521
+ getMetrics: () => ({
522
+ fps: 60,
523
+ frameTime: 16.67,
524
+ drawCalls: 0,
525
+ triangles: 0,
526
+ textureMemory: 0,
527
+ geometryMemory: 0,
528
+ physicsTime: 0,
529
+ networkLatency: this.connectionInfo.latency
530
+ })
531
+ };
532
+ }
533
+ createVoiceService() {
534
+ return {
535
+ startVoiceChat: async () => {
536
+ },
537
+ stopVoiceChat: () => {
538
+ },
539
+ setMuted: (_muted) => {
540
+ },
541
+ setVolume: (_userId, _volume) => {
542
+ },
543
+ getSpeakingUsers: () => [],
544
+ speak: async (_text, _options) => {
545
+ },
546
+ startListening: async () => {
547
+ },
548
+ stopListening: async () => ""
549
+ };
550
+ }
551
+ createStorageService() {
552
+ const storage = /* @__PURE__ */ new Map();
553
+ return {
554
+ get: async (key) => storage.get(key) ?? null,
555
+ set: async (key, value) => {
556
+ storage.set(key, value);
557
+ },
558
+ delete: async (key) => {
559
+ storage.delete(key);
560
+ },
561
+ keys: async () => Array.from(storage.keys()),
562
+ clear: async () => {
563
+ storage.clear();
564
+ },
565
+ getQuota: async () => ({ used: 0, total: 50 * 1024 * 1024 })
566
+ };
567
+ }
568
+ // ─── Event System ─────────────────────────────────────────────────────────
569
+ /**
570
+ * Subscribe to events
571
+ */
572
+ on(event, handler) {
573
+ if (!this.eventHandlers.has(event)) {
574
+ this.eventHandlers.set(event, /* @__PURE__ */ new Set());
575
+ }
576
+ this.eventHandlers.get(event).add(handler);
577
+ return () => this.eventHandlers.get(event)?.delete(handler);
578
+ }
579
+ /**
580
+ * Emit event
581
+ */
582
+ emit(event, data) {
583
+ const handlers = this.eventHandlers.get(event);
584
+ if (handlers) {
585
+ for (const handler of handlers) {
586
+ try {
587
+ handler(data);
588
+ } catch (error) {
589
+ console.error(`Event handler error for ${event}:`, error);
590
+ }
591
+ }
592
+ }
593
+ }
594
+ // ─── Internal Helpers ─────────────────────────────────────────────────────
595
+ setConnectionState(state) {
596
+ this.connectionInfo.state = state;
597
+ this.emit("connectionStateChanged", { state });
598
+ }
599
+ async simulateConnection() {
600
+ await new Promise((resolve) => setTimeout(resolve, 100));
601
+ this.connectionInfo.sessionId = `session_${Date.now()}`;
602
+ this.connectionInfo.connectedAt = (/* @__PURE__ */ new Date()).toISOString();
603
+ this.connectionInfo.latency = 50;
604
+ }
605
+ async fetchWorldDefinition(worldId) {
606
+ const httpBaseUrl = this.config.serverUrl.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://");
607
+ const url = `${httpBaseUrl}/api/worlds/${encodeURIComponent(worldId)}`;
608
+ const headers = {
609
+ Accept: "application/json"
610
+ };
611
+ if (this.config.apiKey) {
612
+ headers["Authorization"] = `Bearer ${this.config.apiKey}`;
613
+ }
614
+ const controller = new AbortController();
615
+ const timeoutId = setTimeout(() => controller.abort(), this.config.connectionTimeout);
616
+ try {
617
+ const response = await fetch(url, {
618
+ method: "GET",
619
+ headers,
620
+ signal: controller.signal
621
+ });
622
+ if (!response.ok) {
623
+ throw new Error(`Failed to fetch world "${worldId}": ${response.status} ${response.statusText}`);
624
+ }
625
+ return await response.json();
626
+ } finally {
627
+ clearTimeout(timeoutId);
628
+ }
629
+ }
630
+ log(...args) {
631
+ if (this.config.debug) {
632
+ console.log("[Hololand]", ...args);
633
+ }
634
+ }
635
+ };
636
+ _HololandClient.instance = null;
637
+ var HololandClient = _HololandClient;
638
+ function getHololandClient(config) {
639
+ return HololandClient.getInstance(config);
640
+ }
641
+ async function connectToHololand(config, worldId) {
642
+ const client = getHololandClient(config);
643
+ await client.connect(worldId);
644
+ return client;
645
+ }
646
+ function disconnectFromHololand() {
647
+ HololandClient.resetInstance();
648
+ }
649
+
650
+ // src/hololand/PhysicsBoundsRegistry.ts
651
+ init_AgentRiskRegistry();
652
+ var DEFAULT_ENVELOPES = {
653
+ ["low" /* LOW */]: {
654
+ maxForceN: 1e3,
655
+ maxImpulseNs: 200,
656
+ maxVelocityMps: 50,
657
+ maxGravityMps2: 30,
658
+ allowSetGravity: true,
659
+ allowDynamicMutation: true
660
+ },
661
+ ["medium" /* MEDIUM */]: {
662
+ maxForceN: 500,
663
+ maxImpulseNs: 100,
664
+ maxVelocityMps: 20,
665
+ maxGravityMps2: 15,
666
+ allowSetGravity: true,
667
+ allowDynamicMutation: true
668
+ },
669
+ ["high" /* HIGH */]: {
670
+ maxForceN: 100,
671
+ maxImpulseNs: 25,
672
+ maxVelocityMps: 5,
673
+ maxGravityMps2: 10,
674
+ // High-risk agents can't reshape gravity — that's a global effect that
675
+ // would propagate confabulation risk to every body in the world.
676
+ allowSetGravity: false,
677
+ allowDynamicMutation: true
678
+ },
679
+ ["quarantined" /* QUARANTINED */]: {
680
+ maxForceN: 0,
681
+ maxImpulseNs: 0,
682
+ maxVelocityMps: 0,
683
+ maxGravityMps2: 0,
684
+ allowSetGravity: false,
685
+ allowDynamicMutation: false
686
+ }
687
+ };
688
+ var PhysicsBoundsRegistry = class {
689
+ constructor(config = {}) {
690
+ const overrides = config.envelopeOverrides ?? {};
691
+ const merged = {
692
+ ["low" /* LOW */]: { ...DEFAULT_ENVELOPES["low" /* LOW */] },
693
+ ["medium" /* MEDIUM */]: { ...DEFAULT_ENVELOPES["medium" /* MEDIUM */] },
694
+ ["high" /* HIGH */]: { ...DEFAULT_ENVELOPES["high" /* HIGH */] },
695
+ ["quarantined" /* QUARANTINED */]: { ...DEFAULT_ENVELOPES["quarantined" /* QUARANTINED */] }
696
+ };
697
+ for (const tier of Object.keys(overrides)) {
698
+ const partial = overrides[tier];
699
+ if (!partial) continue;
700
+ merged[tier] = { ...merged[tier], ...partial };
701
+ }
702
+ this.envelopes = merged;
703
+ }
704
+ /**
705
+ * Look up the envelope for a risk tier (read-only view).
706
+ */
707
+ getEnvelope(tier) {
708
+ return { ...this.envelopes[tier] };
709
+ }
710
+ };
711
+ var globalBoundsRegistry = null;
712
+ function getPhysicsBoundsRegistry(config) {
713
+ if (!globalBoundsRegistry) {
714
+ globalBoundsRegistry = new PhysicsBoundsRegistry(config);
715
+ }
716
+ return globalBoundsRegistry;
717
+ }
718
+ function resetPhysicsBoundsRegistry() {
719
+ globalBoundsRegistry = null;
720
+ }
721
+ function wrapPhysicsService(service, agentId, options = {}) {
722
+ const riskRegistry = options.riskRegistry ?? getAgentRiskRegistry();
723
+ const boundsRegistry = options.boundsRegistry ?? getPhysicsBoundsRegistry();
724
+ const onViolation = options.onViolation;
725
+ function currentEnvelope() {
726
+ const tier = riskRegistry.getTier(agentId);
727
+ return { tier, env: boundsRegistry.getEnvelope(tier) };
728
+ }
729
+ function emit(v) {
730
+ if (onViolation) {
731
+ try {
732
+ onViolation(v);
733
+ } catch {
734
+ }
735
+ }
736
+ }
737
+ function wrapBody(body) {
738
+ return {
739
+ get id() {
740
+ return body.id;
741
+ },
742
+ setPosition(position) {
743
+ const { tier, env } = currentEnvelope();
744
+ if (!env.allowDynamicMutation) {
745
+ emit({
746
+ agentId,
747
+ tier,
748
+ kind: "rejected",
749
+ operation: "setPosition",
750
+ requestedMagnitude: vectorMagnitude(position),
751
+ allowedMagnitude: 0,
752
+ bodyId: body.id
753
+ });
754
+ return;
755
+ }
756
+ body.setPosition(position);
757
+ },
758
+ setRotation(rotation) {
759
+ const { tier, env } = currentEnvelope();
760
+ if (!env.allowDynamicMutation) {
761
+ emit({
762
+ agentId,
763
+ tier,
764
+ kind: "rejected",
765
+ operation: "setRotation",
766
+ requestedMagnitude: 0,
767
+ allowedMagnitude: 0,
768
+ bodyId: body.id
769
+ });
770
+ return;
771
+ }
772
+ body.setRotation(rotation);
773
+ },
774
+ setVelocity(velocity) {
775
+ const { tier, env } = currentEnvelope();
776
+ if (!env.allowDynamicMutation) {
777
+ emit({
778
+ agentId,
779
+ tier,
780
+ kind: "rejected",
781
+ operation: "setVelocity",
782
+ requestedMagnitude: vectorMagnitude(velocity),
783
+ allowedMagnitude: 0,
784
+ bodyId: body.id
785
+ });
786
+ return;
787
+ }
788
+ const { value, clamped, requested } = clampVector(velocity, env.maxVelocityMps);
789
+ if (clamped) {
790
+ emit({
791
+ agentId,
792
+ tier,
793
+ kind: "clamped",
794
+ operation: "setVelocity",
795
+ requestedMagnitude: requested,
796
+ allowedMagnitude: env.maxVelocityMps,
797
+ bodyId: body.id
798
+ });
799
+ }
800
+ body.setVelocity(value);
801
+ },
802
+ applyForce(force) {
803
+ const { tier, env } = currentEnvelope();
804
+ if (!env.allowDynamicMutation) {
805
+ emit({
806
+ agentId,
807
+ tier,
808
+ kind: "rejected",
809
+ operation: "applyForce",
810
+ requestedMagnitude: vectorMagnitude(force),
811
+ allowedMagnitude: 0,
812
+ bodyId: body.id
813
+ });
814
+ return;
815
+ }
816
+ const { value, clamped, requested } = clampVector(force, env.maxForceN);
817
+ if (clamped) {
818
+ emit({
819
+ agentId,
820
+ tier,
821
+ kind: "clamped",
822
+ operation: "applyForce",
823
+ requestedMagnitude: requested,
824
+ allowedMagnitude: env.maxForceN,
825
+ bodyId: body.id
826
+ });
827
+ }
828
+ body.applyForce(value);
829
+ },
830
+ applyImpulse(impulse) {
831
+ const { tier, env } = currentEnvelope();
832
+ if (!env.allowDynamicMutation) {
833
+ emit({
834
+ agentId,
835
+ tier,
836
+ kind: "rejected",
837
+ operation: "applyImpulse",
838
+ requestedMagnitude: vectorMagnitude(impulse),
839
+ allowedMagnitude: 0,
840
+ bodyId: body.id
841
+ });
842
+ return;
843
+ }
844
+ const { value, clamped, requested } = clampVector(impulse, env.maxImpulseNs);
845
+ if (clamped) {
846
+ emit({
847
+ agentId,
848
+ tier,
849
+ kind: "clamped",
850
+ operation: "applyImpulse",
851
+ requestedMagnitude: requested,
852
+ allowedMagnitude: env.maxImpulseNs,
853
+ bodyId: body.id
854
+ });
855
+ }
856
+ body.applyImpulse(value);
857
+ },
858
+ // Reads pass through unchanged — confabulation doesn't propagate via
859
+ // queries.
860
+ getPosition() {
861
+ return body.getPosition();
862
+ },
863
+ getVelocity() {
864
+ return body.getVelocity();
865
+ },
866
+ destroy() {
867
+ body.destroy();
868
+ }
869
+ };
870
+ }
871
+ return {
872
+ createBody(config) {
873
+ const body = service.createBody(config);
874
+ return wrapBody(body);
875
+ },
876
+ raycast(origin, direction, maxDistance) {
877
+ const result = service.raycast(origin, direction, maxDistance);
878
+ if (!result) return null;
879
+ return { ...result, body: wrapBody(result.body) };
880
+ },
881
+ overlap(shape, position) {
882
+ return service.overlap(shape, position).map(wrapBody);
883
+ },
884
+ setGravity(gravity) {
885
+ const { tier, env } = currentEnvelope();
886
+ const requested = vectorMagnitude(gravity);
887
+ if (!env.allowSetGravity) {
888
+ emit({
889
+ agentId,
890
+ tier,
891
+ kind: "rejected",
892
+ operation: "setGravity",
893
+ requestedMagnitude: requested,
894
+ allowedMagnitude: 0,
895
+ bodyId: null
896
+ });
897
+ return;
898
+ }
899
+ const { value, clamped } = clampVector(gravity, env.maxGravityMps2);
900
+ if (clamped) {
901
+ emit({
902
+ agentId,
903
+ tier,
904
+ kind: "clamped",
905
+ operation: "setGravity",
906
+ requestedMagnitude: requested,
907
+ allowedMagnitude: env.maxGravityMps2,
908
+ bodyId: null
909
+ });
910
+ }
911
+ service.setGravity(value);
912
+ },
913
+ step(deltaTime) {
914
+ service.step(deltaTime);
915
+ }
916
+ };
917
+ }
918
+ function vectorMagnitude(v) {
919
+ return Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
920
+ }
921
+ function clampVector(v, maxMagnitude) {
922
+ const requested = vectorMagnitude(v);
923
+ if (maxMagnitude <= 0) {
924
+ return { value: [0, 0, 0], clamped: requested > 0, requested };
925
+ }
926
+ if (requested <= maxMagnitude) {
927
+ return { value: [v[0], v[1], v[2]], clamped: false, requested };
928
+ }
929
+ const scale = maxMagnitude / requested;
930
+ return {
931
+ value: [v[0] * scale, v[1] * scale, v[2] * scale],
932
+ clamped: true,
933
+ requested
934
+ };
935
+ }
936
+
937
+ // src/hololand/CrossValidationRegistry.ts
938
+ init_AgentRiskRegistry();
939
+ var DEFAULT_MIN_OBSERVERS = 3;
940
+ var DEFAULT_NUMERIC_TOLERANCE = 1;
941
+ var DEFAULT_AGREEMENT_SEVERITY = 15;
942
+ var DEFAULT_MAX_ROUNDS = 1024;
943
+ var CrossValidationRegistry = class {
944
+ constructor(config = {}) {
945
+ /** eventId -> round state. Insertion order = age order (Map preserves it). */
946
+ this.rounds = /* @__PURE__ */ new Map();
947
+ /**
948
+ * Per-round set of agentIds we have ALREADY emitted feedback for, so a
949
+ * late submission after `resolved=true` doesn't double-count.
950
+ */
951
+ this.emittedFor = /* @__PURE__ */ new Map();
952
+ this.defaultMinObservers = config.defaultMinObservers ?? DEFAULT_MIN_OBSERVERS;
953
+ this.tolerance = {
954
+ defaultNumericTolerance: config.tolerance?.defaultNumericTolerance ?? DEFAULT_NUMERIC_TOLERANCE,
955
+ perField: config.tolerance?.perField
956
+ };
957
+ this.agreementSeverityThreshold = config.agreementSeverityThreshold ?? DEFAULT_AGREEMENT_SEVERITY;
958
+ this.riskRegistry = config.riskRegistry ?? getAgentRiskRegistry();
959
+ this.maxRounds = config.maxRounds ?? DEFAULT_MAX_ROUNDS;
960
+ this.now = config.now ?? (() => Date.now());
961
+ if (this.defaultMinObservers < 2) {
962
+ throw new Error(
963
+ "CrossValidationRegistry: defaultMinObservers must be >= 2 (consensus requires at least two observers)"
964
+ );
965
+ }
966
+ if (this.agreementSeverityThreshold < 0 || this.agreementSeverityThreshold > 100) {
967
+ throw new Error(
968
+ "CrossValidationRegistry: agreementSeverityThreshold must be in [0,100]"
969
+ );
970
+ }
971
+ if (this.tolerance.defaultNumericTolerance <= 0) {
972
+ throw new Error(
973
+ "CrossValidationRegistry: defaultNumericTolerance must be > 0"
974
+ );
975
+ }
976
+ if (this.maxRounds < 1) {
977
+ throw new Error("CrossValidationRegistry: maxRounds must be >= 1");
978
+ }
979
+ }
980
+ // ---------------------------------------------------------------------------
981
+ // ROUND LIFECYCLE
982
+ // ---------------------------------------------------------------------------
983
+ /**
984
+ * Open a new validation round for a world-state event.
985
+ *
986
+ * Idempotent: if a round with `eventId` already exists, this is a no-op
987
+ * (returns the existing snapshot). This matters for CRDT correctness: two
988
+ * peers may both call `openRound` on the same event before any
989
+ * observations arrive.
990
+ */
991
+ openRound(eventId, minObservers) {
992
+ const existing = this.rounds.get(eventId);
993
+ if (existing) return existing;
994
+ const round = {
995
+ eventId,
996
+ openedAt: this.now(),
997
+ minObservers: minObservers ?? this.defaultMinObservers,
998
+ observations: {},
999
+ resolved: false
1000
+ };
1001
+ this.rounds.set(eventId, round);
1002
+ this.evictIfNeeded();
1003
+ return round;
1004
+ }
1005
+ /**
1006
+ * Submit an observation. Implicitly opens the round if it doesn't exist.
1007
+ *
1008
+ * Returns a `SubmissionResult` describing whether quorum was reached
1009
+ * (and therefore whether risk feedback was emitted).
1010
+ */
1011
+ submitObservation(observation) {
1012
+ const submittedAt = observation.submittedAt ?? this.now();
1013
+ const round = this.openRound(observation.eventId);
1014
+ const existing = round.observations[observation.agentId];
1015
+ if (existing && existing.submittedAt > submittedAt) {
1016
+ return {
1017
+ resolved: round.resolved,
1018
+ observerCount: Object.keys(round.observations).length,
1019
+ consensus: null,
1020
+ emittedRiskEvents: []
1021
+ };
1022
+ }
1023
+ const merged = {
1024
+ eventId: observation.eventId,
1025
+ agentId: observation.agentId,
1026
+ claim: observation.claim,
1027
+ submittedAt
1028
+ };
1029
+ const next = {
1030
+ ...round,
1031
+ observations: { ...round.observations, [observation.agentId]: merged }
1032
+ };
1033
+ this.rounds.set(observation.eventId, next);
1034
+ return this.maybeResolve(observation.eventId);
1035
+ }
1036
+ /**
1037
+ * Merge a remote round snapshot into the local registry.
1038
+ *
1039
+ * CRDT semantics:
1040
+ * - Per-agent observations merge by LWW on `submittedAt`.
1041
+ * - The local `resolved` flag is sticky once true (don't un-resolve a
1042
+ * round just because a peer hadn't seen the resolution yet).
1043
+ * - `minObservers` and `openedAt` from the EARLIEST `openedAt` win
1044
+ * (deterministic across peers).
1045
+ * - After merging, attempts to resolve in case the merged observations
1046
+ * just crossed quorum.
1047
+ */
1048
+ mergeRound(remote) {
1049
+ const local = this.rounds.get(remote.eventId);
1050
+ const mergedObservations = {};
1051
+ const allAgents = /* @__PURE__ */ new Set([
1052
+ ...Object.keys(local?.observations ?? {}),
1053
+ ...Object.keys(remote.observations)
1054
+ ]);
1055
+ for (const agentId of allAgents) {
1056
+ const l = local?.observations[agentId];
1057
+ const r = remote.observations[agentId];
1058
+ if (l && r) {
1059
+ mergedObservations[agentId] = l.submittedAt >= r.submittedAt ? l : r;
1060
+ } else {
1061
+ mergedObservations[agentId] = l ?? r;
1062
+ }
1063
+ }
1064
+ const openedAt = local ? Math.min(local.openedAt, remote.openedAt) : remote.openedAt;
1065
+ const minObservers = local ? Math.min(local.minObservers, remote.minObservers) : remote.minObservers;
1066
+ const resolved = (local?.resolved ?? false) || remote.resolved;
1067
+ const merged = {
1068
+ eventId: remote.eventId,
1069
+ openedAt,
1070
+ minObservers,
1071
+ observations: mergedObservations,
1072
+ resolved
1073
+ };
1074
+ this.rounds.set(remote.eventId, merged);
1075
+ this.evictIfNeeded();
1076
+ return this.maybeResolve(remote.eventId);
1077
+ }
1078
+ /**
1079
+ * Force-resolve a round even if the quorum hasn't been met. Used by
1080
+ * orchestrators that want to close a round on a deadline. The consensus
1081
+ * is computed over whatever observations are present (>=1 required).
1082
+ */
1083
+ forceResolve(eventId) {
1084
+ const round = this.rounds.get(eventId);
1085
+ if (!round) return null;
1086
+ if (Object.keys(round.observations).length === 0) return null;
1087
+ const result = this.resolveNow(eventId);
1088
+ return result.consensus;
1089
+ }
1090
+ /**
1091
+ * Read-only snapshot of a round (for diagnostics, exports, CRDT sync).
1092
+ */
1093
+ exportRound(eventId) {
1094
+ const r = this.rounds.get(eventId);
1095
+ if (!r) return null;
1096
+ return {
1097
+ eventId: r.eventId,
1098
+ openedAt: r.openedAt,
1099
+ minObservers: r.minObservers,
1100
+ observations: { ...r.observations },
1101
+ resolved: r.resolved
1102
+ };
1103
+ }
1104
+ /**
1105
+ * List active rounds (for diagnostics).
1106
+ */
1107
+ listRounds() {
1108
+ return Array.from(this.rounds.keys());
1109
+ }
1110
+ /**
1111
+ * Compute a consensus result without mutating the round or emitting
1112
+ * feedback. Useful for dashboards and tests.
1113
+ *
1114
+ * Returns null if the round doesn't exist or has no observations.
1115
+ */
1116
+ previewConsensus(eventId) {
1117
+ const round = this.rounds.get(eventId);
1118
+ if (!round) return null;
1119
+ const observations = Object.values(round.observations);
1120
+ if (observations.length === 0) return null;
1121
+ return computeConsensus(eventId, observations, this.tolerance);
1122
+ }
1123
+ /**
1124
+ * Drop a round from memory. Idempotent.
1125
+ */
1126
+ clearRound(eventId) {
1127
+ this.rounds.delete(eventId);
1128
+ this.emittedFor.delete(eventId);
1129
+ }
1130
+ /**
1131
+ * Drop all state (tests).
1132
+ */
1133
+ clearAll() {
1134
+ this.rounds.clear();
1135
+ this.emittedFor.clear();
1136
+ }
1137
+ // ---------------------------------------------------------------------------
1138
+ // INTERNAL — RESOLUTION + FEEDBACK
1139
+ // ---------------------------------------------------------------------------
1140
+ maybeResolve(eventId) {
1141
+ const round = this.rounds.get(eventId);
1142
+ const observerCount = Object.keys(round.observations).length;
1143
+ if (round.resolved) {
1144
+ const events = this.emitForLateAgents(eventId);
1145
+ return {
1146
+ resolved: true,
1147
+ observerCount,
1148
+ consensus: null,
1149
+ emittedRiskEvents: events
1150
+ };
1151
+ }
1152
+ if (observerCount < round.minObservers) {
1153
+ return {
1154
+ resolved: false,
1155
+ observerCount,
1156
+ consensus: null,
1157
+ emittedRiskEvents: []
1158
+ };
1159
+ }
1160
+ return this.resolveNow(eventId);
1161
+ }
1162
+ resolveNow(eventId) {
1163
+ const round = this.rounds.get(eventId);
1164
+ const observations = Object.values(round.observations);
1165
+ const consensus = computeConsensus(eventId, observations, this.tolerance);
1166
+ const emitted = [];
1167
+ const emittedSet = this.getEmittedSet(eventId);
1168
+ for (const div of consensus.divergence) {
1169
+ if (emittedSet.has(div.agentId)) continue;
1170
+ emittedSet.add(div.agentId);
1171
+ const ev = this.emitForObserver(eventId, div.agentId, div.severity);
1172
+ if (ev) emitted.push(ev);
1173
+ }
1174
+ const resolvedRound = { ...round, resolved: true };
1175
+ this.rounds.set(eventId, resolvedRound);
1176
+ return {
1177
+ resolved: true,
1178
+ observerCount: observations.length,
1179
+ consensus,
1180
+ emittedRiskEvents: emitted
1181
+ };
1182
+ }
1183
+ emitForLateAgents(eventId) {
1184
+ const round = this.rounds.get(eventId);
1185
+ const observations = Object.values(round.observations);
1186
+ const consensus = computeConsensus(eventId, observations, this.tolerance);
1187
+ const emitted = [];
1188
+ const emittedSet = this.getEmittedSet(eventId);
1189
+ for (const div of consensus.divergence) {
1190
+ if (emittedSet.has(div.agentId)) continue;
1191
+ emittedSet.add(div.agentId);
1192
+ const ev = this.emitForObserver(eventId, div.agentId, div.severity);
1193
+ if (ev) emitted.push(ev);
1194
+ }
1195
+ return emitted;
1196
+ }
1197
+ emitForObserver(eventId, agentId, severity) {
1198
+ if (severity < this.agreementSeverityThreshold) {
1199
+ this.riskRegistry.recordSuccess(agentId);
1200
+ return null;
1201
+ }
1202
+ const event = {
1203
+ agentId,
1204
+ severity: Math.round(severity),
1205
+ reason: `cross-validation-divergence:${eventId}`,
1206
+ timestamp: this.now()
1207
+ };
1208
+ this.riskRegistry.recordEvent(event);
1209
+ return event;
1210
+ }
1211
+ getEmittedSet(eventId) {
1212
+ let set = this.emittedFor.get(eventId);
1213
+ if (!set) {
1214
+ set = /* @__PURE__ */ new Set();
1215
+ this.emittedFor.set(eventId, set);
1216
+ }
1217
+ return set;
1218
+ }
1219
+ evictIfNeeded() {
1220
+ while (this.rounds.size > this.maxRounds) {
1221
+ const oldest = this.rounds.keys().next().value;
1222
+ if (!oldest) break;
1223
+ this.rounds.delete(oldest);
1224
+ this.emittedFor.delete(oldest);
1225
+ }
1226
+ }
1227
+ };
1228
+ function computeConsensus(eventId, observations, tolerance) {
1229
+ if (observations.length === 0) {
1230
+ return {
1231
+ eventId,
1232
+ observerCount: 0,
1233
+ consensus: {},
1234
+ divergence: []
1235
+ };
1236
+ }
1237
+ const sorted = [...observations].sort(
1238
+ (a, b) => a.agentId < b.agentId ? -1 : a.agentId > b.agentId ? 1 : 0
1239
+ );
1240
+ const numericFields = /* @__PURE__ */ new Set();
1241
+ const enumFields = /* @__PURE__ */ new Set();
1242
+ for (const obs of sorted) {
1243
+ if (obs.claim.numeric) {
1244
+ for (const f of Object.keys(obs.claim.numeric)) numericFields.add(f);
1245
+ }
1246
+ if (obs.claim.enum) {
1247
+ for (const f of Object.keys(obs.claim.enum)) enumFields.add(f);
1248
+ }
1249
+ }
1250
+ const consensusNumeric = {};
1251
+ for (const field of numericFields) {
1252
+ const samples = [];
1253
+ let dim = 0;
1254
+ for (const obs of sorted) {
1255
+ const v = obs.claim.numeric?.[field];
1256
+ if (!v) continue;
1257
+ samples.push([...v]);
1258
+ dim = Math.max(dim, v.length);
1259
+ }
1260
+ if (samples.length === 0 || dim === 0) continue;
1261
+ const median = [];
1262
+ for (let i = 0; i < dim; i++) {
1263
+ const col = [];
1264
+ for (const s of samples) {
1265
+ if (i < s.length) col.push(s[i]);
1266
+ }
1267
+ median.push(medianOf(col));
1268
+ }
1269
+ consensusNumeric[field] = median;
1270
+ }
1271
+ const consensusEnum = {};
1272
+ for (const field of enumFields) {
1273
+ const counts = /* @__PURE__ */ new Map();
1274
+ for (const obs of sorted) {
1275
+ const v = obs.claim.enum?.[field];
1276
+ if (v === void 0) continue;
1277
+ counts.set(v, (counts.get(v) ?? 0) + 1);
1278
+ }
1279
+ if (counts.size === 0) continue;
1280
+ const sortedByCount = Array.from(counts.entries()).sort((a, b) => {
1281
+ if (b[1] !== a[1]) return b[1] - a[1];
1282
+ return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
1283
+ });
1284
+ consensusEnum[field] = sortedByCount[0][0];
1285
+ }
1286
+ const divergence = sorted.map((obs) => {
1287
+ const breakdown = [];
1288
+ let maxSeverity = 0;
1289
+ if (obs.claim.numeric) {
1290
+ for (const [field, v] of Object.entries(obs.claim.numeric)) {
1291
+ const cons = consensusNumeric[field];
1292
+ if (!cons) continue;
1293
+ const tol = tolerance.perField?.[field] ?? tolerance.defaultNumericTolerance;
1294
+ let lInf = 0;
1295
+ const dim = Math.min(v.length, cons.length);
1296
+ for (let i = 0; i < dim; i++) {
1297
+ const d = Math.abs(v[i] - cons[i]);
1298
+ if (d > lInf) lInf = d;
1299
+ }
1300
+ const sev = numericSeverity(lInf, tol);
1301
+ breakdown.push({ field, kind: "numeric", delta: lInf, severity: sev });
1302
+ if (sev > maxSeverity) maxSeverity = sev;
1303
+ }
1304
+ }
1305
+ if (obs.claim.enum) {
1306
+ for (const [field, v] of Object.entries(obs.claim.enum)) {
1307
+ const cons = consensusEnum[field];
1308
+ if (cons === void 0) continue;
1309
+ const matches = v === cons;
1310
+ const sev = matches ? 0 : 100;
1311
+ breakdown.push({
1312
+ field,
1313
+ kind: "enum",
1314
+ delta: matches ? 0 : 1,
1315
+ severity: sev
1316
+ });
1317
+ if (sev > maxSeverity) maxSeverity = sev;
1318
+ }
1319
+ }
1320
+ return {
1321
+ agentId: obs.agentId,
1322
+ severity: maxSeverity,
1323
+ breakdown
1324
+ };
1325
+ });
1326
+ const consensusClaim = {};
1327
+ if (Object.keys(consensusNumeric).length > 0) {
1328
+ consensusClaim.numeric = consensusNumeric;
1329
+ }
1330
+ if (Object.keys(consensusEnum).length > 0) {
1331
+ consensusClaim.enum = consensusEnum;
1332
+ }
1333
+ return {
1334
+ eventId,
1335
+ observerCount: sorted.length,
1336
+ consensus: consensusClaim,
1337
+ divergence
1338
+ };
1339
+ }
1340
+ function numericSeverity(delta, tol) {
1341
+ if (delta <= tol) return 0;
1342
+ if (delta >= 2 * tol) return 100;
1343
+ return (delta - tol) / tol * 100;
1344
+ }
1345
+ function medianOf(xs) {
1346
+ if (xs.length === 0) return 0;
1347
+ const sorted = [...xs].sort((a, b) => a - b);
1348
+ const mid = Math.floor(sorted.length / 2);
1349
+ if (sorted.length % 2 === 1) return sorted[mid];
1350
+ return (sorted[mid - 1] + sorted[mid]) / 2;
1351
+ }
1352
+ var globalCrossValidationRegistry = null;
1353
+ function getCrossValidationRegistry(config) {
1354
+ if (!globalCrossValidationRegistry) {
1355
+ globalCrossValidationRegistry = new CrossValidationRegistry(config);
1356
+ }
1357
+ return globalCrossValidationRegistry;
1358
+ }
1359
+ function resetCrossValidationRegistry() {
1360
+ globalCrossValidationRegistry = null;
1361
+ }
1362
+ function suggestedQuorum(observerTiers, options = {}) {
1363
+ const base = options.base ?? 3;
1364
+ const maxObservers = options.maxObservers ?? 9;
1365
+ let bonus = 0;
1366
+ for (const tier of observerTiers) {
1367
+ switch (tier) {
1368
+ case "low" /* LOW */:
1369
+ break;
1370
+ case "medium" /* MEDIUM */:
1371
+ bonus += 1;
1372
+ break;
1373
+ case "high" /* HIGH */:
1374
+ bonus += 2;
1375
+ break;
1376
+ case "quarantined" /* QUARANTINED */:
1377
+ bonus += 3;
1378
+ break;
1379
+ }
1380
+ }
1381
+ return Math.min(maxObservers, base + bonus);
1382
+ }
1383
+
1384
+ // src/hololand/ItemManifest.ts
1385
+ var ITEM_DEFAULT_TICK_INTERVAL_MS = 864e5;
1386
+ var DEFAULT_ITEM_VERBAL_FINGERPRINT = {
1387
+ fingerprint_key: "item_default",
1388
+ style: {
1389
+ label: "item_neutral",
1390
+ minSentenceLength: 5,
1391
+ maxSentenceLength: 40,
1392
+ forbiddenPhrases: [],
1393
+ requiredPhrases: [],
1394
+ tone: "neutral"
1395
+ },
1396
+ enforce: false,
1397
+ rolling_window: 50
1398
+ };
1399
+ var DEFAULT_ITEM_AUTONOMOUS_AGENDA = {
1400
+ agent_class: "item",
1401
+ tick_interval_ms: ITEM_DEFAULT_TICK_INTERVAL_MS,
1402
+ daily_budget_usd: 0.05,
1403
+ max_actions_per_tick: 1,
1404
+ max_actions_per_day: 5,
1405
+ pause_on_ceiling: true
1406
+ };
1407
+ var DEFAULT_ITEM_REPUTATION_LEDGER = {
1408
+ world_id: "",
1409
+ subject_id: "",
1410
+ initial_trust: 50,
1411
+ max_behavior_facts: 20,
1412
+ world_ttl_days: 90,
1413
+ emit_world_entry_disclosure: true,
1414
+ disclosure_text: "",
1415
+ deletion_modes: ["npc", "global"],
1416
+ ttl_breach_alert_rule: "behavior_fact_ttl_breach"
1417
+ };
1418
+ var DEFAULT_ITEM_VOCABULARY_REGISTER = {
1419
+ active_register: "medieval-fantasy",
1420
+ max_injected_entries: 20,
1421
+ prepend_tone_hint: true
1422
+ };
1423
+ function createHoloLandItem(id, name, options = {}) {
1424
+ const ancestry = {
1425
+ originType: options.ancestry?.originType ?? "world_spawn",
1426
+ originId: options.ancestry?.originId ?? "world",
1427
+ originName: options.ancestry?.originName ?? "World Spawn",
1428
+ loreEvent: options.ancestry?.loreEvent,
1429
+ crafterNpcId: options.ancestry?.crafterNpcId,
1430
+ materialSourceItemId: options.ancestry?.materialSourceItemId
1431
+ };
1432
+ const state = {
1433
+ durability: options.state?.durability ?? 1,
1434
+ corrosion: options.state?.corrosion ?? 0,
1435
+ curseDepth: options.state?.curseDepth ?? 0,
1436
+ restorationProgress: options.state?.restorationProgress ?? 0,
1437
+ awakened: options.state?.awakened ?? false,
1438
+ equippedDurationSeconds: options.state?.equippedDurationSeconds ?? 0,
1439
+ boundToPlayerId: options.state?.boundToPlayerId
1440
+ };
1441
+ const trajectory = {
1442
+ type: options.trajectory?.type ?? "none",
1443
+ conditionDescription: options.trajectory?.conditionDescription ?? "",
1444
+ targetState: options.trajectory?.targetState ?? {},
1445
+ requiredNpcId: options.trajectory?.requiredNpcId,
1446
+ requiredLocationId: options.trajectory?.requiredLocationId,
1447
+ requiredItemId: options.trajectory?.requiredItemId
1448
+ };
1449
+ const constraint = {
1450
+ description: options.constraint?.description ?? "",
1451
+ affectedEquipmentSlots: options.constraint?.affectedEquipmentSlots,
1452
+ maxEquipDurationSeconds: options.constraint?.maxEquipDurationSeconds,
1453
+ playstyleImpact: options.constraint?.playstyleImpact ?? ""
1454
+ };
1455
+ const verbalFingerprint = {
1456
+ ...DEFAULT_ITEM_VERBAL_FINGERPRINT,
1457
+ ...options.verbalFingerprint,
1458
+ style: {
1459
+ ...DEFAULT_ITEM_VERBAL_FINGERPRINT.style,
1460
+ ...options.verbalFingerprint?.style
1461
+ }
1462
+ };
1463
+ const autonomousAgenda = {
1464
+ ...DEFAULT_ITEM_AUTONOMOUS_AGENDA,
1465
+ ...options.autonomousAgenda
1466
+ };
1467
+ const reputationLedger = {
1468
+ ...DEFAULT_ITEM_REPUTATION_LEDGER,
1469
+ subject_id: id,
1470
+ ...options.reputationLedger
1471
+ };
1472
+ const vocabularyRegister = {
1473
+ ...DEFAULT_ITEM_VOCABULARY_REGISTER,
1474
+ ...options.vocabularyRegister
1475
+ };
1476
+ return {
1477
+ id,
1478
+ name,
1479
+ displayName: options.displayName ?? name,
1480
+ description: options.description ?? "",
1481
+ ancestry,
1482
+ state,
1483
+ trajectory,
1484
+ constraint,
1485
+ verbalFingerprint,
1486
+ autonomousAgenda,
1487
+ reputationLedger,
1488
+ vocabularyRegister,
1489
+ speechAwareEncounter: options.speechAwareEncounter,
1490
+ previousItemId: options.previousItemId,
1491
+ nextItemId: options.nextItemId,
1492
+ chainDepth: options.chainDepth ?? 0,
1493
+ traits: options.traits ?? [],
1494
+ tags: options.tags ?? []
1495
+ };
1496
+ }
1497
+ function linkItems(source, derivative) {
1498
+ source.nextItemId = derivative.id;
1499
+ derivative.previousItemId = source.id;
1500
+ derivative.chainDepth = source.chainDepth + 1;
1501
+ derivative.ancestry.materialSourceItemId = source.id;
1502
+ }
1503
+ function getItemChain(item, itemIndex) {
1504
+ const chain = [item];
1505
+ let current = item.previousItemId;
1506
+ while (current) {
1507
+ const prev = itemIndex.get(current);
1508
+ if (!prev) break;
1509
+ chain.unshift(prev);
1510
+ current = prev.previousItemId;
1511
+ }
1512
+ return chain;
1513
+ }
1514
+
1515
+ // src/hololand/StreamingProtocol.ts
1516
+ var PROTOCOL_VERSION = "1.0.0";
1517
+ var MAX_MESSAGE_SIZE = 64 * 1024;
1518
+ var MAX_CHUNK_SIZE = 16 * 1024;
1519
+ var HEARTBEAT_INTERVAL = 5e3;
1520
+ var TIMEOUT_INTERVAL = 15e3;
1521
+ var _StreamProtocol = class _StreamProtocol {
1522
+ constructor() {
1523
+ this.connection = null;
1524
+ this.handlers = /* @__PURE__ */ new Map();
1525
+ this.pendingAcks = /* @__PURE__ */ new Map();
1526
+ this.sequenceNumber = 0;
1527
+ this.lastAckSeq = 0;
1528
+ this.heartbeatTimer = null;
1529
+ this.connectionState = "disconnected";
1530
+ }
1531
+ static getInstance() {
1532
+ if (!_StreamProtocol.instance) {
1533
+ _StreamProtocol.instance = new _StreamProtocol();
1534
+ }
1535
+ return _StreamProtocol.instance;
1536
+ }
1537
+ static resetInstance() {
1538
+ _StreamProtocol.instance?.close();
1539
+ _StreamProtocol.instance = null;
1540
+ }
1541
+ // ─── Connection Management ────────────────────────────────────────────────
1542
+ /**
1543
+ * Connect to streaming server
1544
+ */
1545
+ async connect(url, options) {
1546
+ if (this.connectionState !== "disconnected") {
1547
+ throw new Error("Already connected or connecting");
1548
+ }
1549
+ this.connectionState = "connecting";
1550
+ return new Promise((resolve, reject) => {
1551
+ try {
1552
+ this.connection = new WebSocket(url);
1553
+ this.connection.binaryType = "arraybuffer";
1554
+ this.connection.onopen = () => {
1555
+ this.sendHandshake(options);
1556
+ };
1557
+ this.connection.onmessage = (event) => {
1558
+ const message = this.deserialize(event.data);
1559
+ if (!message) return;
1560
+ this.handleMessage(message);
1561
+ if (message.type === "handshake_ack") {
1562
+ this.connectionState = "connected";
1563
+ this.startHeartbeat();
1564
+ resolve();
1565
+ }
1566
+ };
1567
+ this.connection.onerror = (_event) => {
1568
+ const error = new Error("WebSocket error");
1569
+ if (this.connectionState === "connecting") {
1570
+ reject(error);
1571
+ }
1572
+ this.emit("error", {
1573
+ type: "error",
1574
+ seq: 0,
1575
+ timestamp: Date.now(),
1576
+ reliable: false,
1577
+ priority: 0,
1578
+ payload: { error }
1579
+ });
1580
+ };
1581
+ this.connection.onclose = (event) => {
1582
+ this.connectionState = "disconnected";
1583
+ this.stopHeartbeat();
1584
+ this.emit("close", {
1585
+ type: "close",
1586
+ seq: 0,
1587
+ timestamp: Date.now(),
1588
+ reliable: false,
1589
+ priority: 0,
1590
+ payload: { code: event.code, reason: event.reason }
1591
+ });
1592
+ };
1593
+ } catch (error) {
1594
+ this.connectionState = "disconnected";
1595
+ reject(error);
1596
+ }
1597
+ });
1598
+ }
1599
+ /**
1600
+ * Close connection
1601
+ */
1602
+ close() {
1603
+ this.stopHeartbeat();
1604
+ if (this.connection) {
1605
+ this.connection.close(1e3, "Client disconnect");
1606
+ this.connection = null;
1607
+ }
1608
+ this.connectionState = "disconnected";
1609
+ }
1610
+ /**
1611
+ * Check if connected
1612
+ */
1613
+ isConnected() {
1614
+ return this.connectionState === "connected";
1615
+ }
1616
+ // ─── Message Handling ─────────────────────────────────────────────────────
1617
+ /**
1618
+ * Subscribe to message type
1619
+ */
1620
+ on(type, handler) {
1621
+ if (!this.handlers.has(type)) {
1622
+ this.handlers.set(type, /* @__PURE__ */ new Set());
1623
+ }
1624
+ const h = handler;
1625
+ this.handlers.get(type).add(h);
1626
+ return () => this.handlers.get(type)?.delete(h);
1627
+ }
1628
+ /**
1629
+ * Emit message to handlers
1630
+ */
1631
+ emit(type, message) {
1632
+ const handlers = this.handlers.get(type);
1633
+ if (handlers) {
1634
+ for (const handler of handlers) {
1635
+ try {
1636
+ handler(message);
1637
+ } catch (error) {
1638
+ console.error(`Handler error for ${type}:`, error);
1639
+ }
1640
+ }
1641
+ }
1642
+ }
1643
+ /**
1644
+ * Handle incoming message
1645
+ */
1646
+ handleMessage(message) {
1647
+ this.lastAckSeq = Math.max(this.lastAckSeq, message.seq);
1648
+ const msgExt = message;
1649
+ if (message.type === "heartbeat_ack" || msgExt.ack) {
1650
+ const ackKey = msgExt.ackSeq || message.seq;
1651
+ const pending = this.pendingAcks.get(ackKey);
1652
+ if (pending) {
1653
+ clearTimeout(pending.timeout);
1654
+ pending.resolve();
1655
+ this.pendingAcks.delete(ackKey);
1656
+ }
1657
+ }
1658
+ this.emit(message.type, message);
1659
+ }
1660
+ // ─── Message Sending ──────────────────────────────────────────────────────
1661
+ /**
1662
+ * Send message
1663
+ */
1664
+ send(message) {
1665
+ if (!this.connection || this.connectionState !== "connected") {
1666
+ throw new Error("Not connected");
1667
+ }
1668
+ const fullMessage = {
1669
+ ...message,
1670
+ seq: this.sequenceNumber++,
1671
+ timestamp: Date.now()
1672
+ };
1673
+ const data = this.serialize(fullMessage);
1674
+ this.connection.send(data);
1675
+ }
1676
+ /**
1677
+ * Send message and wait for acknowledgment
1678
+ */
1679
+ async sendReliable(message, timeout = 5e3) {
1680
+ const fullMessage = {
1681
+ ...message,
1682
+ seq: this.sequenceNumber++,
1683
+ timestamp: Date.now(),
1684
+ reliable: true
1685
+ };
1686
+ return new Promise((resolve, reject) => {
1687
+ const timeoutId = setTimeout(() => {
1688
+ this.pendingAcks.delete(fullMessage.seq);
1689
+ reject(new Error("Message timeout"));
1690
+ }, timeout);
1691
+ this.pendingAcks.set(fullMessage.seq, { resolve, reject, timeout: timeoutId });
1692
+ const data = this.serialize(fullMessage);
1693
+ this.connection.send(data);
1694
+ });
1695
+ }
1696
+ // ─── Specific Message Senders ─────────────────────────────────────────────
1697
+ /**
1698
+ * Send handshake
1699
+ */
1700
+ sendHandshake(options) {
1701
+ const message = {
1702
+ type: "handshake",
1703
+ reliable: true,
1704
+ priority: 255,
1705
+ payload: {
1706
+ protocolVersion: PROTOCOL_VERSION,
1707
+ clientId: options.clientId,
1708
+ clientVersion: options.clientVersion,
1709
+ capabilities: options.capabilities ?? ["entity_sync", "asset_streaming"],
1710
+ compression: "lz4",
1711
+ encryption: "none"
1712
+ }
1713
+ };
1714
+ const fullMessage = {
1715
+ ...message,
1716
+ seq: this.sequenceNumber++,
1717
+ timestamp: Date.now()
1718
+ };
1719
+ const data = this.serialize(fullMessage);
1720
+ this.connection.send(data);
1721
+ }
1722
+ /**
1723
+ * Send heartbeat
1724
+ */
1725
+ sendHeartbeat() {
1726
+ if (!this.isConnected()) return;
1727
+ this.send({
1728
+ type: "heartbeat",
1729
+ reliable: false,
1730
+ priority: 128,
1731
+ payload: {
1732
+ clientTime: Date.now(),
1733
+ lastAckSeq: this.lastAckSeq
1734
+ }
1735
+ });
1736
+ }
1737
+ /**
1738
+ * Join world
1739
+ */
1740
+ async joinWorld(worldId, spawnPoint) {
1741
+ await this.sendReliable({
1742
+ type: "world_join",
1743
+ priority: 200,
1744
+ payload: {
1745
+ worldId,
1746
+ spawnPoint
1747
+ }
1748
+ });
1749
+ }
1750
+ /**
1751
+ * Leave world
1752
+ */
1753
+ async leaveWorld() {
1754
+ await this.sendReliable({
1755
+ type: "world_leave",
1756
+ priority: 200,
1757
+ payload: {}
1758
+ });
1759
+ }
1760
+ /**
1761
+ * Send entity update
1762
+ */
1763
+ sendEntityUpdate(entityId, changes) {
1764
+ this.send({
1765
+ type: "entity_update",
1766
+ reliable: false,
1767
+ priority: 128,
1768
+ payload: {
1769
+ id: entityId,
1770
+ changes,
1771
+ timestamp: Date.now()
1772
+ }
1773
+ });
1774
+ }
1775
+ /**
1776
+ * Send entity RPC
1777
+ */
1778
+ async sendEntityRPC(entityId, method, args) {
1779
+ const callId = `rpc_${Date.now()}_${Math.random().toString(36).slice(2)}`;
1780
+ await this.sendReliable({
1781
+ type: "entity_rpc",
1782
+ priority: 192,
1783
+ payload: {
1784
+ entityId,
1785
+ method,
1786
+ args,
1787
+ callId
1788
+ }
1789
+ });
1790
+ }
1791
+ /**
1792
+ * Request asset
1793
+ */
1794
+ async requestAsset(assetId, options = {}) {
1795
+ await this.sendReliable({
1796
+ type: "asset_request",
1797
+ priority: options.priority ?? 128,
1798
+ payload: {
1799
+ assetId,
1800
+ priority: options.priority ?? 128,
1801
+ acceptedFormats: options.acceptedFormats ?? ["gltf", "glb"],
1802
+ maxQuality: options.maxQuality ?? "high"
1803
+ }
1804
+ });
1805
+ }
1806
+ /**
1807
+ * Send player input
1808
+ */
1809
+ sendPlayerInput(inputs) {
1810
+ this.send({
1811
+ type: "player_input",
1812
+ reliable: false,
1813
+ priority: 192,
1814
+ payload: {
1815
+ playerId: "",
1816
+ // Set by server
1817
+ inputs,
1818
+ timestamp: Date.now()
1819
+ }
1820
+ });
1821
+ }
1822
+ /**
1823
+ * Send chat message
1824
+ */
1825
+ async sendChat(content, channel = "world", targetId) {
1826
+ await this.sendReliable({
1827
+ type: "chat_message",
1828
+ priority: 160,
1829
+ payload: {
1830
+ senderId: "",
1831
+ // Set by server
1832
+ senderName: "",
1833
+ // Set by server
1834
+ content,
1835
+ channel,
1836
+ targetId
1837
+ }
1838
+ });
1839
+ }
1840
+ /**
1841
+ * Send voice data
1842
+ */
1843
+ sendVoiceData(data, codec = "opus") {
1844
+ this.send({
1845
+ type: "voice_data",
1846
+ reliable: false,
1847
+ priority: 224,
1848
+ payload: {
1849
+ playerId: "",
1850
+ // Set by server
1851
+ data,
1852
+ codec,
1853
+ sampleRate: 48e3
1854
+ }
1855
+ });
1856
+ }
1857
+ // ─── Serialization ────────────────────────────────────────────────────────
1858
+ /**
1859
+ * Serialize message to binary
1860
+ */
1861
+ serialize(message) {
1862
+ const json = JSON.stringify(message, (key, value) => {
1863
+ if (value instanceof ArrayBuffer) {
1864
+ return { __type: "ArrayBuffer", data: Array.from(new Uint8Array(value)) };
1865
+ }
1866
+ return value;
1867
+ });
1868
+ const encoder = new TextEncoder();
1869
+ return encoder.encode(json).buffer;
1870
+ }
1871
+ /**
1872
+ * Deserialize binary to message. Returns null on malformed payloads so the
1873
+ * WebSocket onmessage handler does not crash the connection (W2-T1).
1874
+ *
1875
+ * Note: uses raw JSON.parse with a reviver because safeJsonParse does not
1876
+ * expose the reviver hook. The outer try/catch restores crash-safety.
1877
+ */
1878
+ deserialize(data) {
1879
+ let json;
1880
+ if (data instanceof ArrayBuffer) {
1881
+ const decoder = new TextDecoder();
1882
+ json = decoder.decode(data);
1883
+ } else {
1884
+ json = data;
1885
+ }
1886
+ try {
1887
+ return JSON.parse(json, (_key, value) => {
1888
+ if (value && value.__type === "ArrayBuffer") {
1889
+ return new Uint8Array(value.data).buffer;
1890
+ }
1891
+ return value;
1892
+ });
1893
+ } catch (err) {
1894
+ console.error(
1895
+ `[StreamingProtocol] Malformed JSON payload (${err instanceof Error ? err.message : String(err)})`
1896
+ );
1897
+ return null;
1898
+ }
1899
+ }
1900
+ // ─── Heartbeat ────────────────────────────────────────────────────────────
1901
+ /**
1902
+ * Start heartbeat timer
1903
+ */
1904
+ startHeartbeat() {
1905
+ this.stopHeartbeat();
1906
+ this.heartbeatTimer = setInterval(() => {
1907
+ this.sendHeartbeat();
1908
+ }, HEARTBEAT_INTERVAL);
1909
+ }
1910
+ /**
1911
+ * Stop heartbeat timer
1912
+ */
1913
+ stopHeartbeat() {
1914
+ if (this.heartbeatTimer) {
1915
+ clearInterval(this.heartbeatTimer);
1916
+ this.heartbeatTimer = null;
1917
+ }
1918
+ }
1919
+ // ─── Statistics ───────────────────────────────────────────────────────────
1920
+ /**
1921
+ * Get protocol statistics
1922
+ */
1923
+ getStats() {
1924
+ return {
1925
+ messagesSent: this.sequenceNumber,
1926
+ messagesReceived: this.lastAckSeq,
1927
+ pendingAcks: this.pendingAcks.size,
1928
+ connectionState: this.connectionState
1929
+ };
1930
+ }
1931
+ };
1932
+ _StreamProtocol.instance = null;
1933
+ var StreamProtocol = _StreamProtocol;
1934
+ function getStreamProtocol() {
1935
+ return StreamProtocol.getInstance();
1936
+ }
1937
+ function createMessage(type, payload, options = {}) {
1938
+ return {
1939
+ type,
1940
+ payload,
1941
+ reliable: options.reliable ?? (type.includes("_rpc") || type.includes("request")),
1942
+ priority: options.priority ?? 128,
1943
+ channel: options.channel
1944
+ };
1945
+ }
1946
+
1947
+ export { CrossValidationRegistry, DEFAULT_ENVELOPES, DEFAULT_ITEM_AUTONOMOUS_AGENDA, DEFAULT_ITEM_REPUTATION_LEDGER, DEFAULT_ITEM_VERBAL_FINGERPRINT, DEFAULT_ITEM_VOCABULARY_REGISTER, HEARTBEAT_INTERVAL, HololandClient, ITEM_DEFAULT_TICK_INTERVAL_MS, MAX_CHUNK_SIZE, MAX_MESSAGE_SIZE, PROTOCOL_VERSION, PhysicsBoundsRegistry, StreamProtocol, TIMEOUT_INTERVAL, computeConsensus, connectToHololand, createHoloLandItem, createMessage, createWorldConfig, createWorldDefinition, createWorldEnvironment, createWorldMetadata, disconnectFromHololand, getCrossValidationRegistry, getHololandClient, getItemChain, getPhysicsBoundsRegistry, getStreamProtocol, hololand_exports, linkItems, resetCrossValidationRegistry, resetPhysicsBoundsRegistry, suggestedQuorum, wrapPhysicsService };
1948
+ //# sourceMappingURL=chunk-JD7CIZ33.js.map
1949
+ //# sourceMappingURL=chunk-JD7CIZ33.js.map