@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.
- package/LICENSE +21 -0
- package/README.md +3 -3
- package/bin/holoscript.cjs +3 -0
- package/dist/GLTFPipeline-SFIORFJU.js +16 -0
- package/dist/GLTFPipeline-VNNDPONV.cjs +37 -0
- package/dist/{HoloScriptPlusParser-BN6KVRCM.js → HoloScriptPlusParser-7FBIFUFC.js} +6 -5
- package/dist/{HoloScriptPlusParser-NC5FE6AL.cjs → HoloScriptPlusParser-A2W7OCN2.cjs} +17 -16
- package/dist/HoloScriptPlusParser-F2Z56FJR.js +10 -0
- package/dist/HoloScriptPlusParser-WKHRIH6T.cjs +27 -0
- package/dist/{USDZExporter-UWGWNMMD.cjs → USDZExporter-3FWJ25JI.cjs} +344 -16
- package/dist/{USDZExporter-NTMBNTDB.js → USDZExporter-D2HQLQYK.js} +344 -16
- package/dist/agents/index.cjs +19 -0
- package/dist/agents/index.d.ts +100 -0
- package/dist/agents/index.js +17 -0
- package/dist/chunk-22W6NGYN.js +725 -0
- package/dist/{chunk-5OEOHAAW.cjs → chunk-27MPVJVZ.cjs} +64 -28
- package/dist/{chunk-RVYPEYPX.js → chunk-2A7FURVO.js} +44 -8
- package/dist/{chunk-XCWFGZAA.js → chunk-2B7WVIDZ.js} +11 -8
- package/dist/{chunk-NDQNIJEH.js → chunk-2BSMSUCE.js} +250 -24
- package/dist/chunk-2HLIGOKU.cjs +5546 -0
- package/dist/{chunk-EONILVMF.js → chunk-2M2DPHKB.js} +4 -4
- package/dist/{chunk-G7CT3EMP.cjs → chunk-2YSNA2F2.cjs} +319 -47
- package/dist/{chunk-IWI6J7FX.js → chunk-33XCOVE3.js} +5 -5
- package/dist/chunk-3FOKASKO.cjs +348 -0
- package/dist/{chunk-DXJQDCFL.js → chunk-4C57PR42.js} +3 -3
- package/dist/{chunk-MPXBVFHQ.js → chunk-4N4SXXWF.js} +4 -3
- package/dist/chunk-4PDEPEQW.cjs +41 -0
- package/dist/chunk-4R6HPSHJ.js +2176 -0
- package/dist/chunk-4R6SBXDB.js +45 -0
- package/dist/chunk-4SY77NA4.cjs +413 -0
- package/dist/{chunk-YCXFCXDS.js → chunk-4UUKPCY4.js} +668 -110
- package/dist/{chunk-LGGRPKTV.cjs → chunk-52ULD552.cjs} +114 -35
- package/dist/{chunk-L4G4RLXX.js → chunk-5CKA5SXU.js} +438 -22
- package/dist/chunk-5FSKKMR7.cjs +2092 -0
- package/dist/{chunk-FF3Q7ADR.js → chunk-5JEU52DW.js} +5 -3
- package/dist/chunk-5N54COB6.cjs +327 -0
- package/dist/chunk-5S7RKFGR.cjs +446 -0
- package/dist/{chunk-KED34ILP.js → chunk-6ASWLXXN.js} +21 -9
- package/dist/chunk-6CTRH7HT.cjs +1985 -0
- package/dist/{chunk-CAUCGUEA.cjs → chunk-6EX3I5P4.cjs} +6 -6
- package/dist/chunk-6FGQNDR4.js +5731 -0
- package/dist/{chunk-72EQECGT.cjs → chunk-6KMK2UXT.cjs} +122 -46
- package/dist/{chunk-G4VZTCIB.js → chunk-6L4VE27M.js} +33 -23
- package/dist/{chunk-ATSKSYVE.cjs → chunk-6S6TKNEA.cjs} +6478 -1738
- package/dist/chunk-77V4GTCA.js +596 -0
- package/dist/{chunk-ZP4D3CSX.cjs → chunk-7AD52FRS.cjs} +16 -16
- package/dist/chunk-A6KINLZJ.js +236 -0
- package/dist/chunk-AIA52I7T.cjs +543 -0
- package/dist/chunk-AIX25INK.cjs +602 -0
- package/dist/{chunk-B5TCIAPQ.cjs → chunk-AO4I2Z7M.cjs} +17 -18
- package/dist/{chunk-Q5SJOGHQ.cjs → chunk-BPICAGBV.cjs} +324 -199
- package/dist/chunk-BRQJKJGT.cjs +20 -0
- package/dist/{chunk-3FXV5S25.cjs → chunk-C37BHB7N.cjs} +6 -3
- package/dist/{chunk-XUTX5CBW.js → chunk-CBJY23VL.js} +3 -3
- package/dist/chunk-CIWWXYHZ.cjs +50 -0
- package/dist/{chunk-XXINBTZK.cjs → chunk-DIL6DDDN.cjs} +101 -45
- package/dist/chunk-DMXC24WV.js +404 -0
- package/dist/{chunk-PMGODDJA.cjs → chunk-DTGBOSEM.cjs} +12 -12
- package/dist/chunk-E7JP3BS3.cjs +61 -0
- package/dist/{chunk-HJJLD366.js → chunk-EKBKLK7P.js} +3 -3
- package/dist/chunk-EKYL4PE3.cjs +404 -0
- package/dist/{chunk-UPJBDCVF.js → chunk-EMMC5CSQ.js} +12 -8
- package/dist/{chunk-GGHSW2NN.js → chunk-EOBB6A4B.js} +6389 -1718
- package/dist/chunk-EOFNVCM6.js +325 -0
- package/dist/{chunk-FHQVYCH2.js → chunk-ER4GATIU.js} +7 -7
- package/dist/{chunk-N5FTS757.cjs → chunk-EXKSFGSX.cjs} +7 -148
- package/dist/{chunk-LK5IAVH6.cjs → chunk-EXUP2BUM.cjs} +27 -27
- package/dist/chunk-FDSGHPAK.js +130 -0
- package/dist/chunk-FEWUHQNM.cjs +144 -0
- package/dist/{chunk-5TOFIR6L.js → chunk-FGGJQRLZ.js} +5 -142
- package/dist/chunk-FHP6LXJS.js +415 -0
- package/dist/{chunk-7LCYLPW2.cjs → chunk-FJPADH77.cjs} +7 -4
- package/dist/{chunk-T36DDXSF.js → chunk-FXKTYFYA.js} +150 -25
- package/dist/chunk-G2LS3RFO.js +623 -0
- package/dist/chunk-GCMWDSBZ.cjs +729 -0
- package/dist/chunk-GJNCFRJU.cjs +125 -0
- package/dist/{chunk-Q4QX3AET.cjs → chunk-GMP623FG.cjs} +16 -13
- package/dist/{chunk-XD6IYDUX.js → chunk-GN3KDX4W.js} +119 -43
- package/dist/{chunk-QLEAOI3Q.cjs → chunk-GQYKQSTC.cjs} +10 -10
- package/dist/chunk-GTU2Z2WW.cjs +262 -0
- package/dist/chunk-GZG4KA4E.js +529 -0
- package/dist/{chunk-BND3ST2K.cjs → chunk-H3MGK7TX.cjs} +42 -32
- package/dist/{chunk-XRKWN5PL.cjs → chunk-H5DZIHJP.cjs} +14 -18
- package/dist/{chunk-Z34RLXRA.cjs → chunk-HANL7K2Q.cjs} +65 -50
- package/dist/{chunk-3SAK5KFL.cjs → chunk-HCCQLAA4.cjs} +2 -11
- package/dist/{chunk-LXJ4667L.cjs → chunk-HGVXZDSK.cjs} +108 -20
- package/dist/{chunk-3FJCK5XA.js → chunk-HRODTEEO.js} +30 -10
- package/dist/{chunk-HQUEA5R6.cjs → chunk-HZCQO4JM.cjs} +6 -6
- package/dist/{chunk-S565K7NK.js → chunk-I2O7TW6B.js} +12 -8
- package/dist/chunk-IHESJZSW.js +4490 -0
- package/dist/{chunk-FSF7EQVA.cjs → chunk-IRWWS72C.cjs} +63 -22
- package/dist/{chunk-5O6TQC6M.cjs → chunk-IVIA7K75.cjs} +689 -127
- package/dist/chunk-IVY74O6C.js +247 -0
- package/dist/chunk-J32ZJZJH.js +554 -0
- package/dist/chunk-J56PTA46.cjs +639 -0
- package/dist/chunk-JD7CIZ33.js +1949 -0
- package/dist/{chunk-T7LEXZUZ.cjs → chunk-JIYN45TV.cjs} +14 -15
- package/dist/{chunk-FFKU7BTK.cjs → chunk-KHPCJRI3.cjs} +24 -21
- package/dist/chunk-KKFZ3B6J.cjs +557 -0
- package/dist/chunk-KPJL34Y7.cjs +186 -0
- package/dist/{chunk-HE7ULERA.cjs → chunk-KQTPCYTG.cjs} +128 -44
- package/dist/{chunk-OFKWH2IP.js → chunk-KX76JUQY.js} +3 -3
- package/dist/{chunk-33LSUQDD.cjs → chunk-L63H3SQ4.cjs} +43 -31
- package/dist/{chunk-K6EKD26I.js → chunk-LAOCQJ2M.js} +64 -8
- package/dist/chunk-LM2VU56C.cjs +37 -0
- package/dist/chunk-M56JSP4A.js +400 -0
- package/dist/chunk-MBOOR7X4.js +18 -0
- package/dist/{chunk-XWPNTWDN.cjs → chunk-MJVIRCUV.cjs} +31 -27
- package/dist/{chunk-SDAMZIRE.js → chunk-MSMIFMBL.js} +135 -18
- package/dist/{chunk-56IF4NTA.js → chunk-MXFUTKCO.js} +18 -18
- package/dist/{chunk-6UEHYZ7V.cjs → chunk-MXJ5SS53.cjs} +447 -31
- package/dist/chunk-MYY4PMWX.cjs +264 -0
- package/dist/chunk-N75IH2HY.js +258 -0
- package/dist/{chunk-GVUR45UF.cjs → chunk-NG77ATEW.cjs} +7 -6
- package/dist/chunk-NW5G5FBQ.js +215 -0
- package/dist/{chunk-E3FWRT3Z.js → chunk-OEFY723R.js} +28 -13
- package/dist/chunk-OEV5RMZO.cjs +3042 -0
- package/dist/{chunk-X4ZF6CNE.cjs → chunk-OIQYIIO3.cjs} +7 -7
- package/dist/{chunk-2CWOLHTE.js → chunk-OL46QLBJ.js} +3 -11
- package/dist/chunk-OPZ7XDDI.js +487 -0
- package/dist/chunk-OSYNRVOV.cjs +243 -0
- package/dist/{chunk-TEWCN33Y.js → chunk-P7YIA5LN.js} +91 -7
- package/dist/chunk-PGANYCAG.cjs +220 -0
- package/dist/{chunk-CS2EMTGF.js → chunk-QAVXL2IH.js} +62 -21
- package/dist/{chunk-T4NKMBDL.js → chunk-QCCBXSCE.js} +1666 -756
- package/dist/{chunk-F4IULT7N.js → chunk-QPOQ7VPI.js} +16 -13
- package/dist/{chunk-6XSERL6L.js → chunk-QTPMJRGS.js} +3108 -2827
- package/dist/{chunk-F3HH56EB.cjs → chunk-QWNQ523V.cjs} +1730 -823
- package/dist/{chunk-R7MA7QWV.js → chunk-R3IVNY6P.js} +102 -23
- package/dist/chunk-R75BSDH7.cjs +50 -0
- package/dist/chunk-RAXUF5DF.cjs +2196 -0
- package/dist/{chunk-BF2235SI.cjs → chunk-RMHC2VG7.cjs} +2876 -2592
- package/dist/chunk-RUXGBKPS.cjs +4517 -0
- package/dist/{chunk-UERJ3YJV.js → chunk-S5IFXW6E.js} +113 -9
- package/dist/{chunk-27LWW5FU.cjs → chunk-S6YWHCKV.cjs} +5 -5
- package/dist/{chunk-WB4Z63GG.js → chunk-SIEXCILW.js} +3 -3
- package/dist/{chunk-CLYEIWA5.cjs → chunk-SLU6UPJI.cjs} +5 -3
- package/dist/{chunk-LZ266PCM.cjs → chunk-T5J7ZKP3.cjs} +446 -60
- package/dist/chunk-TDCNJHWO.js +341 -0
- package/dist/{chunk-IHOUYQIA.js → chunk-TG7O4WBC.js} +5 -5
- package/dist/chunk-THCK6ECW.js +2085 -0
- package/dist/chunk-TJHVSBP2.js +439 -0
- package/dist/chunk-TK74TR4H.js +5541 -0
- package/dist/{chunk-CDPGV4DN.js → chunk-U4NBQJBY.js} +14 -15
- package/dist/{chunk-NOZZ46QU.js → chunk-UD3DSHZM.js} +10 -14
- package/dist/chunk-UDMYRFDZ.js +3038 -0
- package/dist/{chunk-WDW67DZB.cjs → chunk-UOIGFQXC.cjs} +90 -68
- package/dist/{chunk-BU7VWW2K.js → chunk-URG2SJLK.js} +14 -15
- package/dist/{chunk-EQV4R3EV.cjs → chunk-V73NPPTM.cjs} +152 -35
- package/dist/chunk-VECQYRXL.js +474 -0
- package/dist/chunk-VEXPG4WN.js +1989 -0
- package/dist/{chunk-LDP5OK6G.js → chunk-VMLKSV26.js} +5 -5
- package/dist/{chunk-5BGSECRJ.cjs → chunk-VSK7W3O5.cjs} +47 -27
- package/dist/chunk-VVKVQZI6.js +55 -0
- package/dist/{chunk-YQK5JNFK.js → chunk-W55Z7QIX.js} +103 -15
- package/dist/{chunk-KSGXLT74.cjs → chunk-W6P2GBHH.cjs} +3 -3
- package/dist/{chunk-IBDG74G2.cjs → chunk-W6RW64BB.cjs} +7 -7
- package/dist/chunk-WDT3JTGM.cjs +483 -0
- package/dist/{chunk-HPS76H7Q.js → chunk-WKX5AMOY.js} +3 -3
- package/dist/chunk-WNNE3PO3.js +34 -0
- package/dist/{chunk-XG23EUQX.cjs → chunk-WRLUBRKS.cjs} +538 -312
- package/dist/{chunk-IFNQFCTM.js → chunk-WRNEH5MO.js} +79 -8
- package/dist/{chunk-54FHG2MX.js → chunk-WRWEX5ZF.js} +7 -4
- package/dist/{chunk-KCQ5NDYC.cjs → chunk-X3GJPRVK.cjs} +154 -80
- package/dist/{chunk-7AGYRWKW.cjs → chunk-XFXGA5IW.cjs} +126 -22
- package/dist/{chunk-TQSZUOW5.cjs → chunk-XHIV6326.cjs} +4 -4
- package/dist/chunk-XJAN7CZG.cjs +432 -0
- package/dist/chunk-XL6INWKT.js +121 -0
- package/dist/{chunk-E3UALNFA.js → chunk-XMWZG36H.js} +4 -4
- package/dist/{chunk-BKIGPPVM.js → chunk-XSFNHP2E.js} +6 -3
- package/dist/{chunk-H5Z7NASB.js → chunk-XT6JY5W5.js} +25 -3
- package/dist/chunk-XXZJEFKW.cjs +490 -0
- package/dist/chunk-Y3MWXQSB.cjs +5737 -0
- package/dist/chunk-YF2I3MV3.js +46 -0
- package/dist/{chunk-V3NN3HPP.js → chunk-YIMN575O.js} +437 -52
- package/dist/chunk-YIVFJNYV.js +176 -0
- package/dist/{chunk-MD6KDHVE.cjs → chunk-YKGPCZEE.cjs} +10 -10
- package/dist/chunk-YQELFNJV.js +39 -0
- package/dist/chunk-Z5XMPRNC.cjs +5390 -0
- package/dist/{chunk-3FYZOR7S.cjs → chunk-ZDSYWBIE.cjs} +18 -18
- package/dist/{chunk-6TZPZCOJ.cjs → chunk-ZKSS47EV.cjs} +24 -19
- package/dist/chunk-ZUL5AVTX.cjs +1993 -0
- package/dist/chunk-ZXBZVXDW.js +5386 -0
- package/dist/{chunk-DMG7C4H2.js → chunk-ZZ7RO2UQ.js} +312 -44
- package/dist/cli/holoscript-runner.cjs +200 -204
- package/dist/cli/holoscript-runner.js +144 -148
- package/dist/codebase/index.cjs +1 -1
- package/dist/codebase/index.js +1 -1
- package/dist/compiler/agent-inference.cjs +10 -7
- package/dist/compiler/agent-inference.js +6 -3
- package/dist/compiler/android-xr.cjs +12 -7
- package/dist/compiler/android-xr.js +10 -5
- package/dist/compiler/android.cjs +12 -8
- package/dist/compiler/android.js +10 -6
- package/dist/compiler/ar.cjs +9 -6
- package/dist/compiler/ar.js +7 -4
- package/dist/compiler/babylon.cjs +12 -8
- package/dist/compiler/babylon.js +11 -7
- package/dist/compiler/business-quest.cjs +43 -0
- package/dist/compiler/business-quest.js +4 -0
- package/dist/compiler/coco.cjs +1 -1
- package/dist/compiler/coco.js +1 -1
- package/dist/compiler/context.cjs +25 -0
- package/dist/compiler/context.d.ts +28 -0
- package/dist/compiler/context.js +8 -0
- package/dist/compiler/domain-block-utils.cjs +155 -152
- package/dist/compiler/domain-block-utils.js +7 -4
- package/dist/compiler/dtdl.cjs +10 -7
- package/dist/compiler/dtdl.js +7 -4
- package/dist/compiler/gltf-pipeline.cjs +9 -9
- package/dist/compiler/gltf-pipeline.js +2 -2
- package/dist/compiler/godot.cjs +9 -6
- package/dist/compiler/godot.js +8 -5
- package/dist/compiler/incremental.cjs +12 -7
- package/dist/compiler/incremental.js +7 -2
- package/dist/compiler/index.cjs +3550 -268
- package/dist/compiler/index.d.ts +404 -21
- package/dist/compiler/index.js +3280 -138
- package/dist/compiler/ios.cjs +11 -8
- package/dist/compiler/ios.js +9 -6
- package/dist/compiler/llm-provider-capabilities.cjs +25 -0
- package/dist/compiler/llm-provider-capabilities.d.ts +43 -0
- package/dist/compiler/llm-provider-capabilities.js +8 -0
- package/dist/compiler/multi-layer.cjs +14 -10
- package/dist/compiler/multi-layer.js +13 -9
- package/dist/compiler/nodetoy.cjs +5 -5
- package/dist/compiler/nodetoy.js +2 -2
- package/dist/compiler/openxr.cjs +10 -6
- package/dist/compiler/openxr.js +9 -5
- package/dist/compiler/playcanvas.cjs +10 -7
- package/dist/compiler/playcanvas.js +9 -6
- package/dist/compiler/r3f.cjs +17 -13
- package/dist/compiler/r3f.d.ts +22 -0
- package/dist/compiler/r3f.js +12 -8
- package/dist/compiler/remotion.cjs +1 -1
- package/dist/compiler/remotion.js +1 -1
- package/dist/compiler/reproducibility.cjs +1 -1
- package/dist/compiler/reproducibility.js +1 -1
- package/dist/compiler/sdf.cjs +10 -7
- package/dist/compiler/sdf.js +8 -5
- package/dist/compiler/semantic-scene.cjs +1 -1
- package/dist/compiler/semantic-scene.js +1 -1
- package/dist/compiler/state.cjs +9 -5
- package/dist/compiler/state.js +7 -3
- package/dist/compiler/trait-composition.cjs +11 -7
- package/dist/compiler/trait-composition.js +7 -3
- package/dist/compiler/unity.cjs +10 -6
- package/dist/compiler/unity.js +9 -5
- package/dist/compiler/unreal.cjs +11 -7
- package/dist/compiler/unreal.js +9 -5
- package/dist/compiler/urdf.cjs +20 -13
- package/dist/compiler/urdf.js +8 -5
- package/dist/compiler/usd-physics.cjs +10 -7
- package/dist/compiler/usd-physics.js +7 -4
- package/dist/compiler/visionos.cjs +10 -6
- package/dist/compiler/visionos.js +9 -5
- package/dist/compiler/vrchat.cjs +10 -7
- package/dist/compiler/vrchat.js +8 -5
- package/dist/compiler/vrr.cjs +10 -7
- package/dist/compiler/vrr.js +8 -5
- package/dist/compiler/wasm.cjs +13 -10
- package/dist/compiler/wasm.js +8 -5
- package/dist/compiler/webgpu.cjs +9 -6
- package/dist/compiler/webgpu.js +8 -5
- package/dist/constants.d.ts +3 -2
- package/dist/coordinators/index.cjs +1266 -0
- package/dist/coordinators/index.d.ts +260 -0
- package/dist/coordinators/index.js +1259 -0
- package/dist/debugger.cjs +9 -7
- package/dist/debugger.js +7 -5
- package/dist/entries/interop.cjs +23 -21
- package/dist/entries/interop.js +5 -3
- package/dist/entries/scripting.cjs +18 -18
- package/dist/entries/scripting.js +8 -8
- package/dist/hololand/index.cjs +146 -0
- package/dist/hololand/index.d.ts +70 -0
- package/dist/hololand/index.js +5 -0
- package/dist/index.cjs +20332 -18121
- package/dist/index.d.ts +1477 -40
- package/dist/index.js +19451 -17638
- package/dist/math/tropical-spmv.cjs +45 -0
- package/dist/math/tropical-spmv.js +4 -0
- package/dist/math/vec3.cjs +14 -14
- package/dist/math/vec3.js +2 -2
- package/dist/{ml-dsa-PHCWUBPX.cjs → ml-dsa-FSKBTE3W.cjs} +177 -90
- package/dist/{ml-dsa-WYLJHJO6.js → ml-dsa-Z7JDKW4L.js} +158 -71
- package/dist/paper-0c-spike/index.cjs +150 -0
- package/dist/paper-0c-spike/index.d.ts +29 -0
- package/dist/paper-0c-spike/index.js +141 -0
- package/dist/parser.cjs +45 -11
- package/dist/parser.d.ts +11 -0
- package/dist/parser.js +10 -8
- package/dist/{playwright-RL6GY4F7.cjs → playwright-3AT3AKTV.cjs} +1985 -1985
- package/dist/{playwright-5OSAPTNH.js → playwright-VZPDVUEQ.js} +3 -3
- package/dist/reconstruction/index.cjs +153 -0
- package/dist/reconstruction/index.d.ts +105 -0
- package/dist/reconstruction/index.js +8 -0
- package/dist/runtime.cjs +7 -5
- package/dist/runtime.js +6 -4
- package/dist/self-improvement/index.cjs +563 -0
- package/dist/self-improvement/index.js +545 -0
- package/dist/storage/index.cjs +10 -9
- package/dist/storage/index.js +3 -2
- package/dist/testing.cjs +25 -0
- package/dist/testing.d.ts +70 -0
- package/dist/testing.js +4 -0
- package/dist/tools/index.d.ts +22 -1
- package/dist/traitDocs/traitDocs.cjs +33 -0
- package/dist/traitDocs/traitDocs.d.ts +69 -0
- package/dist/traitDocs/traitDocs.js +7 -0
- package/dist/traits/botanical-lotus.cjs +41 -0
- package/dist/traits/botanical-lotus.d.ts +172 -0
- package/dist/traits/botanical-lotus.js +4 -0
- package/dist/traits/engines/index.cjs +520 -0
- package/dist/traits/engines/index.js +380 -0
- package/dist/traits/index.cjs +17630 -7881
- package/dist/traits/index.d.ts +197 -0
- package/dist/traits/index.js +16573 -7193
- package/dist/traits/simulation-solver-factory.cjs +13 -0
- package/dist/traits/simulation-solver-factory.d.ts +23 -0
- package/dist/traits/simulation-solver-factory.js +4 -0
- package/dist/traits/webcam-gaze.cjs +35 -0
- package/dist/traits/webcam-gaze.d.ts +17 -0
- package/dist/traits/webcam-gaze.js +4 -0
- package/dist/type-checker.cjs +6 -5
- package/dist/type-checker.js +4 -3
- package/dist/world/index.cjs +947 -0
- package/dist/world/index.d.ts +147 -0
- package/dist/world/index.js +939 -0
- package/dist/world-model/index.cjs +1446 -0
- package/dist/world-model/index.d.ts +119 -0
- package/dist/world-model/index.js +1414 -0
- package/dist/wot/index.cjs +29 -0
- package/dist/wot/index.js +4 -0
- package/package.json +153 -61
- package/dist/GLTFPipeline-DEN36VNK.js +0 -12
- package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
- package/dist/chunk-4XSNJCLC.cjs +0 -1859
- package/dist/chunk-A7PIMZGU.js +0 -263
- package/dist/chunk-BWFJEM5A.js +0 -5419
- package/dist/chunk-CBJSLA2E.cjs +0 -5423
- package/dist/chunk-K3JDKWGI.cjs +0 -270
- package/dist/chunk-LSW7P7ML.js +0 -3675
- package/dist/chunk-MEASWI2Y.js +0 -126
- package/dist/chunk-NCUKG4SK.cjs +0 -3075
- package/dist/chunk-Q5JT3YML.cjs +0 -129
- package/dist/chunk-QGKNANZ3.js +0 -3071
- package/dist/chunk-S2N5TNMA.js +0 -1855
- package/dist/chunk-TSH3MSQU.cjs +0 -129
- package/dist/chunk-WGMEAYBG.js +0 -126
- package/dist/chunk-X6SEAXAX.cjs +0 -3681
package/dist/compiler/index.js
CHANGED
|
@@ -1,68 +1,94 @@
|
|
|
1
1
|
export { createReproducibilityContext, parseReproducibilityFlags } from '../chunk-5GLCTO44.js';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
2
|
+
export { ContextCompileError, ContextCompiler, createContextCompiler } from '../chunk-VEXPG4WN.js';
|
|
3
|
+
export { LLMCapabilityCompileError, LLMProviderCapabilitiesCompiler, createLLMProviderCapabilitiesCompiler } from '../chunk-22W6NGYN.js';
|
|
4
|
+
export { GLTF_PIPELINE_TOOLS, registerGLTFTools } from '../chunk-KX76JUQY.js';
|
|
5
|
+
export { BUSINESS_QUEST_TOOLS, buildVRRCompositionFromDraft, businessVRRDraftSchema, draftToHoloPreview, handleBusinessQuestToolCall, registerBusinessQuestTools, validateBusinessVRRDraft } from '../chunk-DMXC24WV.js';
|
|
6
|
+
export { NodeToyMapper, mapNodeToyToShader } from '../chunk-TG7O4WBC.js';
|
|
7
|
+
export { QuantumCircuitCompiler } from '../chunk-EOFNVCM6.js';
|
|
8
|
+
import { init_ThreeJSCompiler, ThreeJSCompiler_exports, init_A2AAgentCardCompiler, A2AAgentCardCompiler_exports, init_NIRCompiler, NIRCompiler_exports } from '../chunk-QCCBXSCE.js';
|
|
9
|
+
export { CompilerBridge, GaussianSplattingCompiler, SHARED_SORT_SHADER_PATH, SpatialPartitionPass, USDZPipeline, bestCategoryForTraits, compilePipelineSource, compilePipelineSourceToNode, compilePipelineSourceToPython, compilePipelineToNode, compilePipelineToPython, createGaussianSplattingCompiler, detectMultiUserSharedSort, quickSafetyCheck, runSafetyPass, selectModality, selectModalityForAll, spatialPartition } from '../chunk-QCCBXSCE.js';
|
|
10
|
+
export { generateHullGeometry, generateMembraneGeometry, generateSplineGeometry } from '../chunk-EKBKLK7P.js';
|
|
8
11
|
export { SemanticSceneGraph } from '../chunk-HYNTS5CP.js';
|
|
9
|
-
import '../chunk-
|
|
12
|
+
import '../chunk-GN3KDX4W.js';
|
|
13
|
+
import { assertHoloMapManifestContract } from '../chunk-MBOOR7X4.js';
|
|
10
14
|
export { COCOExporterImpl as COCOExporter } from '../chunk-Q56TT7IL.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
import
|
|
19
|
-
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import {
|
|
23
|
-
export {
|
|
24
|
-
import '../chunk-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export {
|
|
31
|
-
import {
|
|
32
|
-
export {
|
|
33
|
-
import {
|
|
34
|
-
export {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import {
|
|
38
|
-
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
import {
|
|
43
|
-
export {
|
|
44
|
-
import {
|
|
45
|
-
export {
|
|
46
|
-
import {
|
|
47
|
-
export {
|
|
48
|
-
import '../chunk-
|
|
49
|
-
import '../chunk-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
import {
|
|
57
|
-
|
|
58
|
-
import '../chunk-
|
|
59
|
-
|
|
60
|
-
import '../chunk-
|
|
61
|
-
|
|
62
|
-
import '../chunk-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
import
|
|
15
|
+
export { RemotionBridgeImpl as RemotionBridge } from '../chunk-YYXH45E2.js';
|
|
16
|
+
import { vrTraitRegistry } from '../chunk-EOBB6A4B.js';
|
|
17
|
+
import '../chunk-QPOQ7VPI.js';
|
|
18
|
+
import { isWebGpuEnvironmentPresent } from '../chunk-YF2I3MV3.js';
|
|
19
|
+
import '../chunk-TDCNJHWO.js';
|
|
20
|
+
import '../chunk-VECQYRXL.js';
|
|
21
|
+
import '../chunk-YQELFNJV.js';
|
|
22
|
+
import '../chunk-FHP6LXJS.js';
|
|
23
|
+
export { IncrementalCompiler, createIncrementalCompiler } from '../chunk-QAVXL2IH.js';
|
|
24
|
+
import '../chunk-2M2DPHKB.js';
|
|
25
|
+
import '../chunk-4R6SBXDB.js';
|
|
26
|
+
import { init_WASMCompiler, WASMCompiler_exports } from '../chunk-5CKA5SXU.js';
|
|
27
|
+
export { WASMCompiler } from '../chunk-5CKA5SXU.js';
|
|
28
|
+
import { init_WebGPUCompiler, WebGPUCompiler_exports, WebGPUCompiler } from '../chunk-6L4VE27M.js';
|
|
29
|
+
export { WebGPUCompiler } from '../chunk-6L4VE27M.js';
|
|
30
|
+
import { init_DTDLCompiler, DTDLCompiler_exports } from '../chunk-33XCOVE3.js';
|
|
31
|
+
export { DTDLCompiler } from '../chunk-33XCOVE3.js';
|
|
32
|
+
import { init_URDFCompiler, URDFCompiler_exports } from '../chunk-EMMC5CSQ.js';
|
|
33
|
+
export { URDFCompiler, createURDFCompiler } from '../chunk-EMMC5CSQ.js';
|
|
34
|
+
export { USDPhysicsCompiler } from '../chunk-MSMIFMBL.js';
|
|
35
|
+
import { init_SDFCompiler, SDFCompiler_exports } from '../chunk-S5IFXW6E.js';
|
|
36
|
+
export { SDFCompiler } from '../chunk-S5IFXW6E.js';
|
|
37
|
+
import { init_StateCompiler, StateCompiler_exports } from '../chunk-U4NBQJBY.js';
|
|
38
|
+
export { StateCompiler } from '../chunk-U4NBQJBY.js';
|
|
39
|
+
export { TraitCompositionCompiler } from '../chunk-UD3DSHZM.js';
|
|
40
|
+
import { init_UnrealCompiler, UnrealCompiler_exports } from '../chunk-2A7FURVO.js';
|
|
41
|
+
import { init_GodotCompiler, GodotCompiler_exports } from '../chunk-LAOCQJ2M.js';
|
|
42
|
+
export { GodotCompiler } from '../chunk-LAOCQJ2M.js';
|
|
43
|
+
import { init_R3FCompiler, R3FCompiler_exports } from '../chunk-FXKTYFYA.js';
|
|
44
|
+
export { ENVIRONMENT_PRESETS, R3FCompiler } from '../chunk-FXKTYFYA.js';
|
|
45
|
+
import '../chunk-XT6JY5W5.js';
|
|
46
|
+
import { init_PlayCanvasCompiler, PlayCanvasCompiler_exports } from '../chunk-I2O7TW6B.js';
|
|
47
|
+
export { PlayCanvasCompiler } from '../chunk-I2O7TW6B.js';
|
|
48
|
+
import { init_AndroidCompiler, AndroidCompiler_exports } from '../chunk-UDMYRFDZ.js';
|
|
49
|
+
export { AndroidCompiler } from '../chunk-UDMYRFDZ.js';
|
|
50
|
+
import { init_AndroidXRCompiler, init_AndroidXRTraitMap, AndroidXRCompiler_exports, AndroidXRCompiler, getTraitMapping, ANDROIDXR_TRAIT_MAP } from '../chunk-6FGQNDR4.js';
|
|
51
|
+
export { AndroidXRCompiler } from '../chunk-6FGQNDR4.js';
|
|
52
|
+
import '../chunk-FDSGHPAK.js';
|
|
53
|
+
import { init_IOSCompiler, IOSCompiler_exports } from '../chunk-ZXBZVXDW.js';
|
|
54
|
+
export { IOSCompiler } from '../chunk-ZXBZVXDW.js';
|
|
55
|
+
import { init_VisionOSCompiler, init_VisionOSTraitMap, VisionOSCompiler_exports, getTraitMapping as getTraitMapping$1, listAllTraits, generateTraitCode } from '../chunk-4UUKPCY4.js';
|
|
56
|
+
export { VisionOSCompiler } from '../chunk-4UUKPCY4.js';
|
|
57
|
+
export { MultiLayerCompiler } from '../chunk-ER4GATIU.js';
|
|
58
|
+
import { init_VRRCompiler, VRRCompiler_exports } from '../chunk-R3IVNY6P.js';
|
|
59
|
+
export { VRRCompiler } from '../chunk-R3IVNY6P.js';
|
|
60
|
+
import { init_ARCompiler, ARCompiler_exports } from '../chunk-OPZ7XDDI.js';
|
|
61
|
+
export { ARCompiler } from '../chunk-OPZ7XDDI.js';
|
|
62
|
+
import { init_OpenXRCompiler, OpenXRCompiler_exports } from '../chunk-2B7WVIDZ.js';
|
|
63
|
+
export { OpenXRCompiler } from '../chunk-2B7WVIDZ.js';
|
|
64
|
+
import { init_VRChatCompiler, VRChatCompiler_exports } from '../chunk-OEFY723R.js';
|
|
65
|
+
export { VRChatCompiler } from '../chunk-OEFY723R.js';
|
|
66
|
+
import { init_BabylonCompiler, BabylonCompiler_exports } from '../chunk-6ASWLXXN.js';
|
|
67
|
+
export { BabylonCompiler } from '../chunk-6ASWLXXN.js';
|
|
68
|
+
import '../chunk-TJHVSBP2.js';
|
|
69
|
+
import '../chunk-4C57PR42.js';
|
|
70
|
+
import { init_UnityCompiler, UnityCompiler_exports } from '../chunk-P7YIA5LN.js';
|
|
71
|
+
export { UnityCompiler } from '../chunk-P7YIA5LN.js';
|
|
72
|
+
import { init_PlatformConditionalCompilerMixin } from '../chunk-GZG4KA4E.js';
|
|
73
|
+
export { PlatformConditionalCompilerMixin, createPlatformTarget, filterCompositionForPlatform, matchesPlatformConstraint, normalizePlatformName } from '../chunk-GZG4KA4E.js';
|
|
74
|
+
import '../chunk-W55Z7QIX.js';
|
|
75
|
+
import { init_CompilerBase, CompilerBase, init_ANSNamespace, ANSCapabilityPath, init_CompilerDocumentationGenerator } from '../chunk-QTPMJRGS.js';
|
|
76
|
+
export { CompilerBase, CompilerDocumentationGenerator, UnauthorizedCompilerAccessError, createTestCompilerToken, isCapabilityTokenCredential } from '../chunk-QTPMJRGS.js';
|
|
77
|
+
import { init_traitDocs, getTraitDoc, getAllTraitNames } from '../chunk-THCK6ECW.js';
|
|
78
|
+
import '../chunk-N75IH2HY.js';
|
|
79
|
+
import '../chunk-MXFUTKCO.js';
|
|
80
|
+
import '../chunk-J32ZJZJH.js';
|
|
81
|
+
import { init_constants, CONNECTOR_PACKAGES, CONNECTOR_ENV_REQUIREMENTS, KNOWN_CONNECTORS } from '../chunk-2BSMSUCE.js';
|
|
82
|
+
import '../chunk-WRNEH5MO.js';
|
|
83
|
+
import '../chunk-WKX5AMOY.js';
|
|
84
|
+
import '../chunk-SIEXCILW.js';
|
|
85
|
+
import '../chunk-CBJY23VL.js';
|
|
86
|
+
import { ExpressionEvaluator } from '../chunk-XL6INWKT.js';
|
|
87
|
+
import '../chunk-77V4GTCA.js';
|
|
88
|
+
import '../chunk-PHENW4MQ.js';
|
|
89
|
+
import { init_safeJsonParse, readJson } from '../chunk-VVKVQZI6.js';
|
|
90
|
+
import { __export, __esm, __toCommonJS } from '../chunk-OL46QLBJ.js';
|
|
91
|
+
import { ANSCapabilityPath as ANSCapabilityPath$1 } from '@holoscript/core-types/ans';
|
|
66
92
|
|
|
67
93
|
// src/compiler/Native2DCompiler.ts
|
|
68
94
|
var Native2DCompiler_exports = {};
|
|
@@ -73,6 +99,7 @@ var Native2DCompiler;
|
|
|
73
99
|
var init_Native2DCompiler = __esm({
|
|
74
100
|
"src/compiler/Native2DCompiler.ts"() {
|
|
75
101
|
init_CompilerBase();
|
|
102
|
+
init_safeJsonParse();
|
|
76
103
|
Native2DCompiler = class extends CompilerBase {
|
|
77
104
|
constructor() {
|
|
78
105
|
super(...arguments);
|
|
@@ -93,24 +120,11 @@ var init_Native2DCompiler = __esm({
|
|
|
93
120
|
const isReact = options?.format === "react";
|
|
94
121
|
const elements = composition.ui?.elements || composition.objects || [];
|
|
95
122
|
if (isReact) {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
output: code,
|
|
100
|
-
documentation: this.generateDocumentation(composition, code, options.docsOptions)
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
return code;
|
|
104
|
-
} else {
|
|
105
|
-
const code = this.generateHTMLPage(composition.name, elements, composition);
|
|
106
|
-
if (options?.generateDocs) {
|
|
107
|
-
return {
|
|
108
|
-
output: code,
|
|
109
|
-
documentation: this.generateDocumentation(composition, code, options.docsOptions)
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
return code;
|
|
123
|
+
const code2 = this.generateReactComponent(composition.name, elements, composition, options);
|
|
124
|
+
return this.withTripleOutputIfRequested(composition, code2, options);
|
|
113
125
|
}
|
|
126
|
+
const code = this.generateHTMLPage(composition.name, elements, composition);
|
|
127
|
+
return this.withTripleOutputIfRequested(composition, code, options);
|
|
114
128
|
}
|
|
115
129
|
generateReactComponent(name, objects, composition, options) {
|
|
116
130
|
this._slotImports.clear();
|
|
@@ -250,7 +264,7 @@ export default ${safeName}Component;
|
|
|
250
264
|
}
|
|
251
265
|
if (traits.theme?.attributes) {
|
|
252
266
|
try {
|
|
253
|
-
const parsedAttrs =
|
|
267
|
+
const parsedAttrs = readJson(traits.theme.attributes);
|
|
254
268
|
for (const [key, value] of Object.entries(parsedAttrs)) {
|
|
255
269
|
props += ` ${key}="${value}"`;
|
|
256
270
|
}
|
|
@@ -391,7 +405,7 @@ export default ${safeName}Component;
|
|
|
391
405
|
}
|
|
392
406
|
if (traits.theme?.attributes) {
|
|
393
407
|
try {
|
|
394
|
-
const parsedAttrs =
|
|
408
|
+
const parsedAttrs = readJson(traits.theme.attributes);
|
|
395
409
|
for (const [key, value] of Object.entries(parsedAttrs)) {
|
|
396
410
|
props += ` ${key}="${value}"`;
|
|
397
411
|
}
|
|
@@ -560,6 +574,19 @@ function buildPropMap(obj) {
|
|
|
560
574
|
}
|
|
561
575
|
return map;
|
|
562
576
|
}
|
|
577
|
+
function toStringArray(val) {
|
|
578
|
+
if (val === void 0 || val === null) return void 0;
|
|
579
|
+
if (!Array.isArray(val)) return void 0;
|
|
580
|
+
const out = [];
|
|
581
|
+
for (const item of val) {
|
|
582
|
+
if (typeof item === "string") out.push(item);
|
|
583
|
+
}
|
|
584
|
+
return out.length ? out : void 0;
|
|
585
|
+
}
|
|
586
|
+
function parseResponseMode(raw) {
|
|
587
|
+
if (raw === "echo" || raw === "message") return raw;
|
|
588
|
+
return void 0;
|
|
589
|
+
}
|
|
563
590
|
function toApiRouteSegment(name, override) {
|
|
564
591
|
if (override) {
|
|
565
592
|
return override.replace(/^\/+api\/+/, "").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
@@ -580,7 +607,9 @@ function extractHandlers(composition) {
|
|
|
580
607
|
byMethod.set(method, {
|
|
581
608
|
method,
|
|
582
609
|
statusCode: Number(toScalar(rootHttp["statusCode"]) ?? toScalar(rootHttp["status"]) ?? 200),
|
|
583
|
-
description: String(toScalar(rootHttp["description"]) ?? "")
|
|
610
|
+
description: String(toScalar(rootHttp["description"]) ?? ""),
|
|
611
|
+
requiredBodyKeys: toStringArray(rootHttp["requiredBodyKeys"]),
|
|
612
|
+
responseMode: parseResponseMode(String(toScalar(rootHttp["responseMode"]) ?? "")) ?? (rootHttp["echoBody"] === true ? "echo" : void 0)
|
|
584
613
|
});
|
|
585
614
|
}
|
|
586
615
|
}
|
|
@@ -594,21 +623,28 @@ function extractHandlers(composition) {
|
|
|
594
623
|
if (!method) continue;
|
|
595
624
|
const traitStatus = toScalar(traitConfig["statusCode"] ?? traitConfig["status"]);
|
|
596
625
|
const propStatus = props.get("statusCode") ?? props.get("status");
|
|
626
|
+
const objRequired = toStringArray(traitConfig["requiredBodyKeys"]);
|
|
627
|
+
const mode = parseResponseMode(String(toScalar(traitConfig["responseMode"]) ?? "")) ?? (traitConfig["echoBody"] === true ? "echo" : void 0);
|
|
597
628
|
byMethod.set(method, {
|
|
598
629
|
method,
|
|
599
630
|
statusCode: Number(traitStatus ?? propStatus ?? 200),
|
|
600
631
|
description: String(
|
|
601
632
|
props.get("description") ?? toScalar(traitConfig["description"]) ?? obj.name ?? ""
|
|
602
|
-
)
|
|
633
|
+
),
|
|
634
|
+
requiredBodyKeys: objRequired,
|
|
635
|
+
responseMode: mode
|
|
603
636
|
});
|
|
604
637
|
}
|
|
605
638
|
return [...byMethod.values()];
|
|
606
639
|
}
|
|
607
|
-
function emitHandler(handler) {
|
|
608
|
-
const { method, statusCode, description } = handler;
|
|
640
|
+
function emitHandler(handler, meta, opts) {
|
|
641
|
+
const { method, statusCode, description, requiredBodyKeys = [], responseMode } = handler;
|
|
609
642
|
const lines = [];
|
|
610
643
|
const hasBody = BODY_METHODS.has(method);
|
|
611
644
|
const isPassthrough = PASSTHROUGH_METHODS.has(method);
|
|
645
|
+
const mode = responseMode ?? (requiredBodyKeys.length > 0 ? "message" : "echo");
|
|
646
|
+
const keysJson = JSON.stringify(requiredBodyKeys);
|
|
647
|
+
const useEcho = mode === "echo";
|
|
612
648
|
if (description) {
|
|
613
649
|
lines.push(`/** ${description} */`);
|
|
614
650
|
}
|
|
@@ -624,18 +660,48 @@ function emitHandler(handler) {
|
|
|
624
660
|
lines.push(` try {`);
|
|
625
661
|
lines.push(` body = await _request.json();`);
|
|
626
662
|
lines.push(` } catch {`);
|
|
627
|
-
lines.push(` return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 });`);
|
|
663
|
+
lines.push(` return NextResponse.json({ ok: false, error: 'Invalid JSON body' }, { status: 400 });`);
|
|
628
664
|
lines.push(` }`);
|
|
629
|
-
lines.push(
|
|
630
|
-
lines.push(`
|
|
631
|
-
lines.push(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
lines.push(`
|
|
635
|
-
|
|
665
|
+
lines.push(` const record = typeof body === 'object' && body !== null ? (body as Record<string, unknown>) : null;`);
|
|
666
|
+
lines.push(` if (!record) {`);
|
|
667
|
+
lines.push(
|
|
668
|
+
` return NextResponse.json({ ok: false, error: 'JSON body must be an object' }, { status: 400 });`
|
|
669
|
+
);
|
|
670
|
+
lines.push(` }`);
|
|
671
|
+
if (opts.includeValidation) {
|
|
672
|
+
lines.push(` const spatialValidation = validateSpatialRequestBody(record);`);
|
|
673
|
+
lines.push(` if (!spatialValidation.valid) {`);
|
|
674
|
+
lines.push(
|
|
675
|
+
` return NextResponse.json({ ok: false, error: spatialValidation.error, field: spatialValidation.field }, { status: 400 });`
|
|
676
|
+
);
|
|
677
|
+
lines.push(` }`);
|
|
678
|
+
}
|
|
679
|
+
lines.push(` const requiredKeys = ${keysJson} as const;`);
|
|
680
|
+
lines.push(` for (const key of requiredKeys) {`);
|
|
681
|
+
lines.push(` if (!(key in record)) {`);
|
|
682
|
+
lines.push(
|
|
683
|
+
` return NextResponse.json({ ok: false, error: 'Missing required field', field: key }, { status: 400 });`
|
|
684
|
+
);
|
|
685
|
+
lines.push(` }`);
|
|
686
|
+
lines.push(` }`);
|
|
687
|
+
if (useEcho) {
|
|
688
|
+
lines.push(` return NextResponse.json(`);
|
|
689
|
+
lines.push(` { ok: true, route: ${JSON.stringify(meta.routeSegment)}, data: record },`);
|
|
690
|
+
lines.push(` { status: ${statusCode} }`);
|
|
691
|
+
lines.push(` );`);
|
|
692
|
+
} else {
|
|
693
|
+
lines.push(` return NextResponse.json(`);
|
|
694
|
+
lines.push(
|
|
695
|
+
` { ok: true, route: ${JSON.stringify(meta.routeSegment)}, composition: ${JSON.stringify(meta.compositionName)}, message: ${JSON.stringify(description || "Accepted")}, receivedKeys: Object.keys(record) },`
|
|
696
|
+
);
|
|
697
|
+
lines.push(` { status: ${statusCode} }`);
|
|
698
|
+
lines.push(` );`);
|
|
699
|
+
}
|
|
636
700
|
} else {
|
|
637
701
|
lines.push(` return NextResponse.json(`);
|
|
638
|
-
lines.push(
|
|
702
|
+
lines.push(
|
|
703
|
+
` { ok: true, route: ${JSON.stringify(meta.routeSegment)}, composition: ${JSON.stringify(meta.compositionName)}, message: ${JSON.stringify(description || "OK")} },`
|
|
704
|
+
);
|
|
639
705
|
lines.push(` { status: ${statusCode} }`);
|
|
640
706
|
lines.push(` );`);
|
|
641
707
|
}
|
|
@@ -656,6 +722,9 @@ function compileToNextJSAPI(composition, options = {}) {
|
|
|
656
722
|
const routeSegment = toApiRouteSegment(composition.name, options.apiRoute);
|
|
657
723
|
const outputBase = options.outputDir ? options.outputDir.replace(/\/$/, "") : "api";
|
|
658
724
|
const filePath = `${outputBase}/${routeSegment}/route.ts`;
|
|
725
|
+
const meta = { routeSegment, compositionName: composition.name };
|
|
726
|
+
const includeValidation = options.includeValidation !== false;
|
|
727
|
+
const hasBodyHandlers = handlers.some((h) => BODY_METHODS.has(h.method));
|
|
659
728
|
const lines = [];
|
|
660
729
|
if (options.includeJsDoc !== false) {
|
|
661
730
|
lines.push(`// @generated by HoloScript NextJSAPICompiler \u2014 DO NOT EDIT`);
|
|
@@ -670,8 +739,40 @@ function compileToNextJSAPI(composition, options = {}) {
|
|
|
670
739
|
lines.push(`import { NextResponse } from 'next/server';`);
|
|
671
740
|
}
|
|
672
741
|
lines.push(``);
|
|
742
|
+
if (includeValidation && hasBodyHandlers) {
|
|
743
|
+
lines.push(`function isTuple3(value: unknown): value is [number, number, number] {`);
|
|
744
|
+
lines.push(` return Array.isArray(value) && value.length === 3 && value.every((n) => typeof n === 'number');`);
|
|
745
|
+
lines.push(`}`);
|
|
746
|
+
lines.push(``);
|
|
747
|
+
lines.push(`function isTuple4(value: unknown): value is [number, number, number, number] {`);
|
|
748
|
+
lines.push(` return Array.isArray(value) && value.length === 4 && value.every((n) => typeof n === 'number');`);
|
|
749
|
+
lines.push(`}`);
|
|
750
|
+
lines.push(``);
|
|
751
|
+
lines.push(
|
|
752
|
+
`function validateSpatialRequestBody(record: Record<string, unknown>): { valid: true } | { valid: false; error: string; field: string } {`
|
|
753
|
+
);
|
|
754
|
+
lines.push(` if ('position' in record && !isTuple3(record.position)) {`);
|
|
755
|
+
lines.push(` return { valid: false, error: 'position must be [x, y, z] numeric tuple', field: 'position' };`);
|
|
756
|
+
lines.push(` }`);
|
|
757
|
+
lines.push(` if ('scale' in record && !isTuple3(record.scale)) {`);
|
|
758
|
+
lines.push(` return { valid: false, error: 'scale must be [x, y, z] numeric tuple', field: 'scale' };`);
|
|
759
|
+
lines.push(` }`);
|
|
760
|
+
lines.push(` if ('rotation' in record) {`);
|
|
761
|
+
lines.push(` const rotation = record.rotation;`);
|
|
762
|
+
lines.push(` const isEuler = isTuple3(rotation);`);
|
|
763
|
+
lines.push(` const isQuat = isTuple4(rotation);`);
|
|
764
|
+
lines.push(` if (!isEuler && !isQuat) {`);
|
|
765
|
+
lines.push(
|
|
766
|
+
` return { valid: false, error: 'rotation must be [x, y, z] or [x, y, z, w] numeric tuple', field: 'rotation' };`
|
|
767
|
+
);
|
|
768
|
+
lines.push(` }`);
|
|
769
|
+
lines.push(` }`);
|
|
770
|
+
lines.push(` return { valid: true };`);
|
|
771
|
+
lines.push(`}`);
|
|
772
|
+
lines.push(``);
|
|
773
|
+
}
|
|
673
774
|
for (let i = 0; i < handlers.length; i++) {
|
|
674
|
-
lines.push(...emitHandler(handlers[i]));
|
|
775
|
+
lines.push(...emitHandler(handlers[i], meta, { includeValidation }));
|
|
675
776
|
if (i < handlers.length - 1) {
|
|
676
777
|
lines.push(``);
|
|
677
778
|
}
|
|
@@ -703,26 +804,33 @@ var init_NextJSAPICompiler = __esm({
|
|
|
703
804
|
constructor(options = {}) {
|
|
704
805
|
super();
|
|
705
806
|
this.options = options;
|
|
807
|
+
this.compilerName = "NextJSAPICompiler";
|
|
706
808
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
const comp = composition;
|
|
712
|
-
const result = compileAllToNextJSAPI(comp);
|
|
713
|
-
return {
|
|
714
|
-
code: result.map((r) => r.code).join("\n\n"),
|
|
715
|
-
files: result.map((r) => ({ path: r.routePath, content: r.code }))
|
|
716
|
-
};
|
|
809
|
+
compile(composition, agentToken, outputPath, _sceneGraph) {
|
|
810
|
+
this.validateCompilerAccess(agentToken, outputPath);
|
|
811
|
+
const result = compileToNextJSAPI(composition, this.options);
|
|
812
|
+
return { [result.path]: result.code };
|
|
717
813
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
814
|
+
/** Multi-composition helper (not used by CompilerBase). */
|
|
815
|
+
compileAll(compositions, agentToken, outputPath) {
|
|
816
|
+
this.validateCompilerAccess(agentToken, outputPath);
|
|
817
|
+
const files = {};
|
|
818
|
+
for (const row of compileAllToNextJSAPI(compositions, this.options)) {
|
|
819
|
+
files[row.path] = row.code;
|
|
820
|
+
}
|
|
821
|
+
return files;
|
|
721
822
|
}
|
|
722
823
|
};
|
|
723
824
|
}
|
|
724
825
|
});
|
|
725
826
|
|
|
827
|
+
// src/compiler/identity/index.ts
|
|
828
|
+
var init_identity = __esm({
|
|
829
|
+
"src/compiler/identity/index.ts"() {
|
|
830
|
+
init_ANSNamespace();
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
|
|
726
834
|
// src/compiler/NodeServiceCompiler.ts
|
|
727
835
|
var NodeServiceCompiler_exports = {};
|
|
728
836
|
__export(NodeServiceCompiler_exports, {
|
|
@@ -753,7 +861,6 @@ var init_NodeServiceCompiler = __esm({
|
|
|
753
861
|
return ANSCapabilityPath.NODE_SERVICE;
|
|
754
862
|
}
|
|
755
863
|
compile(composition, agentToken, outputPath) {
|
|
756
|
-
console.log("DEBUG: Composition:", JSON.stringify(composition, null, 2));
|
|
757
864
|
this.validateCompilerAccess(agentToken, outputPath);
|
|
758
865
|
this.services = [];
|
|
759
866
|
this.extractServices(composition);
|
|
@@ -820,7 +927,16 @@ var init_NodeServiceCompiler = __esm({
|
|
|
820
927
|
}
|
|
821
928
|
hasServiceTraits(obj) {
|
|
822
929
|
if (!obj.traits) return false;
|
|
823
|
-
const serviceTraits = [
|
|
930
|
+
const serviceTraits = [
|
|
931
|
+
"service",
|
|
932
|
+
"endpoint",
|
|
933
|
+
"http",
|
|
934
|
+
"handler",
|
|
935
|
+
"route",
|
|
936
|
+
"connector",
|
|
937
|
+
"env",
|
|
938
|
+
"deploy"
|
|
939
|
+
];
|
|
824
940
|
return obj.traits.some((t) => serviceTraits.includes(t.name));
|
|
825
941
|
}
|
|
826
942
|
parseServiceBlock(block) {
|
|
@@ -860,7 +976,10 @@ var init_NodeServiceCompiler = __esm({
|
|
|
860
976
|
if (obj.traits) {
|
|
861
977
|
const traitNames = obj.traits.map((t) => t.name);
|
|
862
978
|
service.middleware = this.extractMiddlewareFromTraits(traitNames);
|
|
863
|
-
service.connectors = this.extractConnectors(
|
|
979
|
+
service.connectors = this.extractConnectors(
|
|
980
|
+
traitNames,
|
|
981
|
+
this.objectPropsToMap(obj.properties)
|
|
982
|
+
);
|
|
864
983
|
service.envVars = this.extractEnvVars(traitNames, this.objectPropsToMap(obj.properties));
|
|
865
984
|
service.deploy = this.extractDeploy(traitNames, this.objectPropsToMap(obj.properties));
|
|
866
985
|
}
|
|
@@ -870,16 +989,20 @@ var init_NodeServiceCompiler = __esm({
|
|
|
870
989
|
}
|
|
871
990
|
extractRoute(obj, serviceName) {
|
|
872
991
|
const propMap = this.objectPropsToMap(obj.properties);
|
|
873
|
-
const
|
|
992
|
+
const traitObjects = obj.traits || [];
|
|
993
|
+
const traits = traitObjects.map((t) => t.name);
|
|
994
|
+
const handlerTrait = this.findTrait(traitObjects, "handler");
|
|
874
995
|
const method = this.resolveString(propMap.get("method"))?.toUpperCase() || "GET";
|
|
875
996
|
const path = this.resolveString(propMap.get("path")) || `/${this.toKebab(obj.name)}`;
|
|
876
|
-
const handlerName = this.resolveString(propMap.get("handler")) || this.toCamelCase(obj.name);
|
|
997
|
+
const handlerName = this.resolveString(propMap.get("handler")) || this.resolveString(this.readTraitConfig(handlerTrait, "name", "handler")) || this.resolveString(this.readTraitConfig(handlerTrait, "_arg0")) || this.toCamelCase(obj.name);
|
|
877
998
|
const hasHttpInfo = propMap.has("method") || propMap.has("path") || traits.includes("http") || traits.includes("route");
|
|
878
999
|
if (!hasHttpInfo) return null;
|
|
879
1000
|
return {
|
|
880
1001
|
method,
|
|
881
1002
|
path,
|
|
882
1003
|
handlerName,
|
|
1004
|
+
handlerBody: this.extractRouteHandlerBody(obj, propMap, handlerName),
|
|
1005
|
+
handlerState: this.extractRouteState(obj),
|
|
883
1006
|
middleware: this.extractMiddlewareFromTraits(traits),
|
|
884
1007
|
serviceName
|
|
885
1008
|
};
|
|
@@ -887,14 +1010,111 @@ var init_NodeServiceCompiler = __esm({
|
|
|
887
1010
|
extractInlineRoute(block) {
|
|
888
1011
|
const props = block.properties;
|
|
889
1012
|
if (!props["method"] && !props["path"]) return null;
|
|
1013
|
+
const handlerName = this.resolveString(props["handler"]) || this.toCamelCase(block.name);
|
|
890
1014
|
return {
|
|
891
1015
|
method: this.resolveString(props["method"])?.toUpperCase() || "GET",
|
|
892
1016
|
path: this.resolveString(props["path"]) || `/${this.toKebab(block.name)}`,
|
|
893
|
-
handlerName
|
|
1017
|
+
handlerName,
|
|
1018
|
+
handlerBody: this.extractBlockHandlerBody(block, handlerName),
|
|
894
1019
|
middleware: [],
|
|
895
1020
|
serviceName: block.name
|
|
896
1021
|
};
|
|
897
1022
|
}
|
|
1023
|
+
extractRouteHandlerBody(obj, propMap, handlerName) {
|
|
1024
|
+
const directBody = this.handlerBodyFromValue(
|
|
1025
|
+
this.readMapValue(propMap, "handlerBody", "handler_body", "body")
|
|
1026
|
+
);
|
|
1027
|
+
if (directBody) return directBody;
|
|
1028
|
+
const handlerTrait = this.findTrait(obj.traits || [], "handler");
|
|
1029
|
+
const traitBody = this.handlerBodyFromValue(
|
|
1030
|
+
this.readTraitConfig(handlerTrait, "body", "code", "implementation")
|
|
1031
|
+
);
|
|
1032
|
+
if (traitBody) return traitBody;
|
|
1033
|
+
for (const directive of obj.directives ?? []) {
|
|
1034
|
+
const body = this.handlerBodyFromDirective(directive, handlerName);
|
|
1035
|
+
if (body) return body;
|
|
1036
|
+
}
|
|
1037
|
+
return this.handlerBodyFromEventHandlers(
|
|
1038
|
+
obj.eventHandlers,
|
|
1039
|
+
handlerName
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
extractBlockHandlerBody(block, handlerName) {
|
|
1043
|
+
const directBody = this.handlerBodyFromValue(
|
|
1044
|
+
this.readRecordValue(block.properties, "handlerBody", "handler_body", "body")
|
|
1045
|
+
);
|
|
1046
|
+
if (directBody) return directBody;
|
|
1047
|
+
return this.handlerBodyFromEventHandlers(block.eventHandlers, handlerName);
|
|
1048
|
+
}
|
|
1049
|
+
handlerBodyFromDirective(directive, handlerName) {
|
|
1050
|
+
if (!directive || typeof directive !== "object") return void 0;
|
|
1051
|
+
const record = directive;
|
|
1052
|
+
const name = String(record["name"] ?? record["handlerName"] ?? "");
|
|
1053
|
+
const type = String(record["type"] ?? "");
|
|
1054
|
+
if (type === "method" && name === handlerName) {
|
|
1055
|
+
return this.handlerBodyFromValue(record["body"]);
|
|
1056
|
+
}
|
|
1057
|
+
if (type === "trait" && name === "handler") {
|
|
1058
|
+
return this.handlerBodyFromValue(
|
|
1059
|
+
this.readRecordValue(record["config"] ?? {}, "body", "code")
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
return void 0;
|
|
1063
|
+
}
|
|
1064
|
+
handlerBodyFromEventHandlers(handlers, handlerName) {
|
|
1065
|
+
for (const handler of handlers ?? []) {
|
|
1066
|
+
if (handler.event === handlerName || handler.name === handlerName) {
|
|
1067
|
+
const body = this.handlerBodyFromValue(handler.body);
|
|
1068
|
+
if (body) return body;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return void 0;
|
|
1072
|
+
}
|
|
1073
|
+
handlerBodyFromValue(value) {
|
|
1074
|
+
if (value === void 0 || value === null) return void 0;
|
|
1075
|
+
if (typeof value === "string") {
|
|
1076
|
+
const trimmed = value.trim();
|
|
1077
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
1078
|
+
}
|
|
1079
|
+
if (Array.isArray(value)) {
|
|
1080
|
+
const lines = value.map((statement) => this.emitHoloStatement(statement)).filter((line) => Boolean(line));
|
|
1081
|
+
return lines.length > 0 ? lines.join("\n") : void 0;
|
|
1082
|
+
}
|
|
1083
|
+
if (typeof value === "object") {
|
|
1084
|
+
const record = value;
|
|
1085
|
+
return this.handlerBodyFromValue(
|
|
1086
|
+
record["body"] ?? record["code"] ?? record["implementation"] ?? record["value"]
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
return void 0;
|
|
1090
|
+
}
|
|
1091
|
+
extractRouteState(obj) {
|
|
1092
|
+
if (!obj.state?.properties?.length) return void 0;
|
|
1093
|
+
const state = {};
|
|
1094
|
+
for (const prop of obj.state.properties) {
|
|
1095
|
+
state[prop.key] = prop.value;
|
|
1096
|
+
}
|
|
1097
|
+
return state;
|
|
1098
|
+
}
|
|
1099
|
+
findTrait(traits, name) {
|
|
1100
|
+
return traits.find((trait) => trait.name.replace(/^@/, "") === name);
|
|
1101
|
+
}
|
|
1102
|
+
readTraitConfig(trait, ...keys) {
|
|
1103
|
+
if (!trait?.config) return void 0;
|
|
1104
|
+
return this.readRecordValue(trait.config, ...keys);
|
|
1105
|
+
}
|
|
1106
|
+
readMapValue(map, ...keys) {
|
|
1107
|
+
for (const key of keys) {
|
|
1108
|
+
if (map.has(key)) return map.get(key);
|
|
1109
|
+
}
|
|
1110
|
+
return void 0;
|
|
1111
|
+
}
|
|
1112
|
+
readRecordValue(record, ...keys) {
|
|
1113
|
+
for (const key of keys) {
|
|
1114
|
+
if (Object.prototype.hasOwnProperty.call(record, key)) return record[key];
|
|
1115
|
+
}
|
|
1116
|
+
return void 0;
|
|
1117
|
+
}
|
|
898
1118
|
extractMiddlewareFromTraits(traits) {
|
|
899
1119
|
const mw = [];
|
|
900
1120
|
for (const t of traits) {
|
|
@@ -1065,10 +1285,7 @@ var init_NodeServiceCompiler = __esm({
|
|
|
1065
1285
|
`router.${methodLower}('${this.escapeStringValue(route.path, "TypeScript")}', ${mwArgs}(req, res) => {`
|
|
1066
1286
|
);
|
|
1067
1287
|
}
|
|
1068
|
-
lines.push(
|
|
1069
|
-
lines.push(
|
|
1070
|
-
` res.json({ message: '${this.escapeStringValue(route.handlerName, "TypeScript")} not implemented' });`
|
|
1071
|
-
);
|
|
1288
|
+
lines.push(...this.emitExpressRouteBody(route));
|
|
1072
1289
|
lines.push(`});`);
|
|
1073
1290
|
lines.push("");
|
|
1074
1291
|
}
|
|
@@ -1096,10 +1313,7 @@ var init_NodeServiceCompiler = __esm({
|
|
|
1096
1313
|
lines.push(
|
|
1097
1314
|
` app.${methodLower}('${this.escapeStringValue(route.path, "TypeScript")}', async (request, reply) => {`
|
|
1098
1315
|
);
|
|
1099
|
-
lines.push(
|
|
1100
|
-
lines.push(
|
|
1101
|
-
` return { message: '${this.escapeStringValue(route.handlerName, "TypeScript")} not implemented' };`
|
|
1102
|
-
);
|
|
1316
|
+
lines.push(...this.emitFastifyRouteBody(route));
|
|
1103
1317
|
lines.push(` });`);
|
|
1104
1318
|
lines.push("");
|
|
1105
1319
|
}
|
|
@@ -1116,6 +1330,90 @@ var init_NodeServiceCompiler = __esm({
|
|
|
1116
1330
|
}
|
|
1117
1331
|
return lines.join("\n");
|
|
1118
1332
|
}
|
|
1333
|
+
emitExpressRouteBody(route) {
|
|
1334
|
+
if (route.handlerBody) {
|
|
1335
|
+
return [
|
|
1336
|
+
` // Handler: ${route.handlerName}`,
|
|
1337
|
+
...this.emitHandlerState(route, " "),
|
|
1338
|
+
...this.indentHandlerBody(route.handlerBody, " ")
|
|
1339
|
+
];
|
|
1340
|
+
}
|
|
1341
|
+
return [
|
|
1342
|
+
` // Placeholder \u2014 replace with ${route.handlerName} logic`,
|
|
1343
|
+
` res.status(501).json({ error: 'not_implemented', handler: '${this.escapeStringValue(route.handlerName, "TypeScript")}' });`
|
|
1344
|
+
];
|
|
1345
|
+
}
|
|
1346
|
+
emitFastifyRouteBody(route) {
|
|
1347
|
+
if (route.handlerBody) {
|
|
1348
|
+
return [
|
|
1349
|
+
` // Handler: ${route.handlerName}`,
|
|
1350
|
+
...this.emitHandlerState(route, " "),
|
|
1351
|
+
...this.indentHandlerBody(route.handlerBody, " ")
|
|
1352
|
+
];
|
|
1353
|
+
}
|
|
1354
|
+
return [
|
|
1355
|
+
` // Placeholder \u2014 replace with ${route.handlerName} logic`,
|
|
1356
|
+
` return reply.code(501).send({ error: 'not_implemented', handler: '${this.escapeStringValue(route.handlerName, "TypeScript")}' });`
|
|
1357
|
+
];
|
|
1358
|
+
}
|
|
1359
|
+
indentHandlerBody(body, indent) {
|
|
1360
|
+
return body.split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.length > 0).map((line) => `${indent}${line}`);
|
|
1361
|
+
}
|
|
1362
|
+
emitHandlerState(route, indent) {
|
|
1363
|
+
if (!route.handlerState || Object.keys(route.handlerState).length === 0) return [];
|
|
1364
|
+
return [
|
|
1365
|
+
`${indent}const state = ${JSON.stringify(route.handlerState, null, 2).replace(/\n/g, `
|
|
1366
|
+
${indent}`)};`
|
|
1367
|
+
];
|
|
1368
|
+
}
|
|
1369
|
+
emitHoloStatement(statement) {
|
|
1370
|
+
switch (statement.type) {
|
|
1371
|
+
case "Assignment":
|
|
1372
|
+
return `${statement.target} ${statement.operator} ${this.emitHoloExpression(statement.value)};`;
|
|
1373
|
+
case "VariableDeclaration":
|
|
1374
|
+
return `${statement.kind} ${statement.name}${statement.value ? ` = ${this.emitHoloExpression(statement.value)}` : ""};`;
|
|
1375
|
+
case "ReturnStatement":
|
|
1376
|
+
return `return ${statement.value ? this.emitHoloExpression(statement.value) : ""};`;
|
|
1377
|
+
case "EmitStatement":
|
|
1378
|
+
return `emit(${JSON.stringify(statement.event)}, ${statement.data ? this.emitHoloExpression(statement.data) : "undefined"});`;
|
|
1379
|
+
case "ExpressionStatement":
|
|
1380
|
+
return `${this.emitHoloExpression(statement.expression)};`;
|
|
1381
|
+
case "MethodCall": {
|
|
1382
|
+
const target = statement.object ? `${statement.object}.` : "";
|
|
1383
|
+
return `${target}${statement.method}(${statement.arguments.map((arg) => this.emitHoloExpression(arg)).join(", ")});`;
|
|
1384
|
+
}
|
|
1385
|
+
default:
|
|
1386
|
+
return `// Unsupported handler statement: ${statement.type}`;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
emitHoloExpression(expression) {
|
|
1390
|
+
switch (expression.type) {
|
|
1391
|
+
case "Literal":
|
|
1392
|
+
return JSON.stringify(expression.value);
|
|
1393
|
+
case "Identifier":
|
|
1394
|
+
return expression.name;
|
|
1395
|
+
case "BinaryExpression":
|
|
1396
|
+
return `(${this.emitHoloExpression(expression.left)} ${expression.operator} ${this.emitHoloExpression(expression.right)})`;
|
|
1397
|
+
case "UnaryExpression":
|
|
1398
|
+
return `(${expression.operator}${this.emitHoloExpression(expression.argument)})`;
|
|
1399
|
+
case "MemberExpression":
|
|
1400
|
+
return expression.computed ? `${this.emitHoloExpression(expression.object)}[${JSON.stringify(expression.property)}]` : `${this.emitHoloExpression(expression.object)}.${expression.property}`;
|
|
1401
|
+
case "CallExpression":
|
|
1402
|
+
return `${this.emitHoloExpression(expression.callee)}(${expression.arguments.map((arg) => this.emitHoloExpression(arg)).join(", ")})`;
|
|
1403
|
+
case "ArrayExpression":
|
|
1404
|
+
return `[${expression.elements.map((element) => this.emitHoloExpression(element)).join(", ")}]`;
|
|
1405
|
+
case "ObjectExpression":
|
|
1406
|
+
return `{ ${expression.properties.map((prop) => `${JSON.stringify(prop.key)}: ${this.emitHoloExpression(prop.value)}`).join(", ")} }`;
|
|
1407
|
+
case "ConditionalExpression":
|
|
1408
|
+
return `(${this.emitHoloExpression(expression.test)} ? ${this.emitHoloExpression(expression.consequent)} : ${this.emitHoloExpression(expression.alternate)})`;
|
|
1409
|
+
case "UpdateExpression":
|
|
1410
|
+
return expression.prefix ? `${expression.operator}${this.emitHoloExpression(expression.argument)}` : `${this.emitHoloExpression(expression.argument)}${expression.operator}`;
|
|
1411
|
+
case "BindExpression":
|
|
1412
|
+
return expression.source;
|
|
1413
|
+
default:
|
|
1414
|
+
return "undefined";
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1119
1417
|
emitMiddlewareIndex(middleware) {
|
|
1120
1418
|
const lines = [];
|
|
1121
1419
|
lines.push(`/**`);
|
|
@@ -1129,7 +1427,7 @@ var init_NodeServiceCompiler = __esm({
|
|
|
1129
1427
|
for (const mw of middleware) {
|
|
1130
1428
|
const fnName = this.toCamelCase(mw) + "Middleware";
|
|
1131
1429
|
lines.push(`export function ${fnName}(req: Request, _res: Response, next: NextFunction) {`);
|
|
1132
|
-
lines.push(` //
|
|
1430
|
+
lines.push(` // Pass-through placeholder for ${mw} \u2014 add auth/limits here`);
|
|
1133
1431
|
lines.push(` next();`);
|
|
1134
1432
|
lines.push(`}`);
|
|
1135
1433
|
lines.push("");
|
|
@@ -1144,7 +1442,7 @@ var init_NodeServiceCompiler = __esm({
|
|
|
1144
1442
|
lines.push(
|
|
1145
1443
|
`export function ${fnName}(request: FastifyRequest, _reply: FastifyReply, done: HookHandlerDoneFunction) {`
|
|
1146
1444
|
);
|
|
1147
|
-
lines.push(` //
|
|
1445
|
+
lines.push(` // Pass-through placeholder for ${mw} \u2014 add auth/limits here`);
|
|
1148
1446
|
lines.push(` done();`);
|
|
1149
1447
|
lines.push(`}`);
|
|
1150
1448
|
lines.push("");
|
|
@@ -1392,7 +1690,9 @@ var init_NodeServiceCompiler = __esm({
|
|
|
1392
1690
|
const envMap = new Map(envVars.map((ev) => [ev.name, ev]));
|
|
1393
1691
|
for (const conn of connectors) {
|
|
1394
1692
|
if (!KNOWN_CONNECTORS.includes(conn.name)) {
|
|
1395
|
-
console.warn(
|
|
1693
|
+
console.warn(
|
|
1694
|
+
`[NodeServiceCompiler] Warning: Unknown connector '${conn.name}'. Package dependency will not be added.`
|
|
1695
|
+
);
|
|
1396
1696
|
} else {
|
|
1397
1697
|
const requirements = CONNECTOR_ENV_REQUIREMENTS[conn.name] || [];
|
|
1398
1698
|
for (const req of requirements) {
|
|
@@ -1586,6 +1886,28 @@ function registerBuiltinDialects() {
|
|
|
1586
1886
|
},
|
|
1587
1887
|
outputExtensions: [".js"]
|
|
1588
1888
|
},
|
|
1889
|
+
{
|
|
1890
|
+
name: "threejs",
|
|
1891
|
+
domain: "web3d",
|
|
1892
|
+
description: "Compiles to vanilla Three.js TypeScript (bypasses R3F for bundle-critical deployments)",
|
|
1893
|
+
supportedTraits: [
|
|
1894
|
+
"physics",
|
|
1895
|
+
"collidable",
|
|
1896
|
+
"grabbable",
|
|
1897
|
+
"hoverable",
|
|
1898
|
+
"audio",
|
|
1899
|
+
"animation",
|
|
1900
|
+
"particles",
|
|
1901
|
+
"material",
|
|
1902
|
+
"shadow"
|
|
1903
|
+
],
|
|
1904
|
+
riskTier: "standard",
|
|
1905
|
+
factory: (opts) => {
|
|
1906
|
+
const { ThreeJSCompiler } = (init_ThreeJSCompiler(), __toCommonJS(ThreeJSCompiler_exports));
|
|
1907
|
+
return new ThreeJSCompiler(opts);
|
|
1908
|
+
},
|
|
1909
|
+
outputExtensions: [".ts"]
|
|
1910
|
+
},
|
|
1589
1911
|
// ── VR/XR ─────────────────────────────────────────────────────────────
|
|
1590
1912
|
{
|
|
1591
1913
|
name: "openxr",
|
|
@@ -1609,7 +1931,7 @@ function registerBuiltinDialects() {
|
|
|
1609
1931
|
{
|
|
1610
1932
|
name: "vrchat",
|
|
1611
1933
|
domain: "social-vr",
|
|
1612
|
-
description: "Compiles to VRChat UdonSharp
|
|
1934
|
+
description: "Compiles to VRChat SDK3. Current implementation emits legacy UdonSharp C#; Byte/Udon output is gated on the artifact contract.",
|
|
1613
1935
|
supportedTraits: [
|
|
1614
1936
|
"physics",
|
|
1615
1937
|
"collidable",
|
|
@@ -1801,8 +2123,8 @@ function registerBuiltinDialects() {
|
|
|
1801
2123
|
supportedTraits: ["physics", "material", "lod", "rendering"],
|
|
1802
2124
|
riskTier: "standard",
|
|
1803
2125
|
factory: (opts) => {
|
|
1804
|
-
const { VRRCompiler } = (init_VRRCompiler(), __toCommonJS(VRRCompiler_exports));
|
|
1805
|
-
return new
|
|
2126
|
+
const { VRRCompiler: VRRCompiler2 } = (init_VRRCompiler(), __toCommonJS(VRRCompiler_exports));
|
|
2127
|
+
return new VRRCompiler2(opts);
|
|
1806
2128
|
},
|
|
1807
2129
|
outputExtensions: [".ts"]
|
|
1808
2130
|
},
|
|
@@ -1825,11 +2147,9 @@ function registerBuiltinDialects() {
|
|
|
1825
2147
|
description: "Compiles @http traits to Next.js App Router API route handlers (route.ts)",
|
|
1826
2148
|
supportedTraits: ["http", "handler", "middleware", "auth", "rate_limit", "cors"],
|
|
1827
2149
|
riskTier: "standard",
|
|
1828
|
-
factory: () => {
|
|
1829
|
-
const {
|
|
1830
|
-
return
|
|
1831
|
-
compile: (composition, _token) => compileToNextJSAPI2(composition)
|
|
1832
|
-
};
|
|
2150
|
+
factory: (opts) => {
|
|
2151
|
+
const { NextJSAPICompiler: NextJSAPICompiler2 } = (init_NextJSAPICompiler(), __toCommonJS(NextJSAPICompiler_exports));
|
|
2152
|
+
return new NextJSAPICompiler2(opts);
|
|
1833
2153
|
},
|
|
1834
2154
|
outputExtensions: [".ts"],
|
|
1835
2155
|
experimental: true
|
|
@@ -2044,12 +2364,14 @@ init_PlayCanvasCompiler();
|
|
|
2044
2364
|
init_ARCompiler();
|
|
2045
2365
|
init_OpenXRCompiler();
|
|
2046
2366
|
init_VRChatCompiler();
|
|
2367
|
+
init_VRRCompiler();
|
|
2047
2368
|
init_VisionOSCompiler();
|
|
2048
2369
|
init_AndroidCompiler();
|
|
2049
2370
|
init_AndroidXRCompiler();
|
|
2050
2371
|
init_IOSCompiler();
|
|
2051
2372
|
init_WASMCompiler();
|
|
2052
2373
|
init_WebGPUCompiler();
|
|
2374
|
+
init_PlatformConditionalCompilerMixin();
|
|
2053
2375
|
init_SDFCompiler();
|
|
2054
2376
|
init_DTDLCompiler();
|
|
2055
2377
|
init_URDFCompiler();
|
|
@@ -2209,7 +2531,7 @@ var MCPConfigCompiler = class extends CompilerBase {
|
|
|
2209
2531
|
extractServersFromBlock(block) {
|
|
2210
2532
|
if (!block.children) return;
|
|
2211
2533
|
for (const child of block.children) {
|
|
2212
|
-
if ("type" in child && child.type === "
|
|
2534
|
+
if ("type" in child && child.type === "Object") {
|
|
2213
2535
|
const obj = child;
|
|
2214
2536
|
this.servers.push(this.extractServerFromObject(obj));
|
|
2215
2537
|
}
|
|
@@ -2256,6 +2578,11 @@ var MCPConfigCompiler = class extends CompilerBase {
|
|
|
2256
2578
|
}
|
|
2257
2579
|
const config = {
|
|
2258
2580
|
_generated: "HoloScript MCPConfigCompiler",
|
|
2581
|
+
_configKind: "mcp-client-connection-config",
|
|
2582
|
+
_limitations: [
|
|
2583
|
+
"emits IDE client mcpServers connection entries only",
|
|
2584
|
+
"does not emit MCP server manifests, tools, input schemas, or resources"
|
|
2585
|
+
],
|
|
2259
2586
|
_target: this.options.target,
|
|
2260
2587
|
_updated: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
2261
2588
|
mcpServers
|
|
@@ -2365,19 +2692,2834 @@ var MCPConfigCompiler = class extends CompilerBase {
|
|
|
2365
2692
|
DialectRegistry.register({
|
|
2366
2693
|
name: "mcp-config",
|
|
2367
2694
|
domain: "configuration",
|
|
2368
|
-
description: "Compiles .holo server definitions to IDE-specific
|
|
2695
|
+
description: "Compiles .holo MCP server connection definitions to IDE-specific client config JSON",
|
|
2369
2696
|
supportedTraits: ["connector", "env"],
|
|
2697
|
+
riskTier: "standard",
|
|
2370
2698
|
factory: (options) => new MCPConfigCompiler(options),
|
|
2371
|
-
|
|
2372
|
-
outputFormat: ".json"
|
|
2699
|
+
outputExtensions: [".json"]
|
|
2373
2700
|
});
|
|
2374
2701
|
|
|
2375
2702
|
// src/compiler/index.ts
|
|
2703
|
+
init_PlatformConditionalCompilerMixin();
|
|
2376
2704
|
init_Native2DCompiler();
|
|
2705
|
+
|
|
2706
|
+
// src/compiler/SCMCompiler.ts
|
|
2707
|
+
init_CompilerBase();
|
|
2708
|
+
var SCMCompiler = class extends CompilerBase {
|
|
2709
|
+
constructor(options = {}) {
|
|
2710
|
+
super();
|
|
2711
|
+
this.compilerName = "SCMCompiler";
|
|
2712
|
+
this.nodes = [];
|
|
2713
|
+
this.edges = [];
|
|
2714
|
+
this.options = {
|
|
2715
|
+
modelName: options.modelName || "HoloScript_SCM_DAG",
|
|
2716
|
+
affectiveContext: options.affectiveContext || {
|
|
2717
|
+
valence: 0,
|
|
2718
|
+
arousal: 0,
|
|
2719
|
+
dominantEmotion: "calm"
|
|
2720
|
+
},
|
|
2721
|
+
privacyMask: options.privacyMask || false
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
getRequiredCapability() {
|
|
2725
|
+
return ANSCapabilityPath$1.SCM;
|
|
2726
|
+
}
|
|
2727
|
+
// Helper to extract traits consistently
|
|
2728
|
+
getTraitName(trait) {
|
|
2729
|
+
return typeof trait === "string" ? trait : trait.name;
|
|
2730
|
+
}
|
|
2731
|
+
hasTrait(obj, traitName) {
|
|
2732
|
+
return obj.traits?.some((t) => this.getTraitName(t) === traitName) ?? false;
|
|
2733
|
+
}
|
|
2734
|
+
compile(composition, agentToken, outputPath) {
|
|
2735
|
+
this.validateCompilerAccess(agentToken, outputPath);
|
|
2736
|
+
this.nodes = [];
|
|
2737
|
+
this.edges = [];
|
|
2738
|
+
this.extractNodes(composition);
|
|
2739
|
+
this.extractEdges(composition);
|
|
2740
|
+
this.applyAffectivePruning();
|
|
2741
|
+
this.applyPrivacyMask();
|
|
2742
|
+
const dag = {
|
|
2743
|
+
metadata: {
|
|
2744
|
+
model_name: this.options.modelName,
|
|
2745
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2746
|
+
affective_context: this.options.affectiveContext
|
|
2747
|
+
},
|
|
2748
|
+
nodes: this.nodes,
|
|
2749
|
+
edges: this.edges
|
|
2750
|
+
};
|
|
2751
|
+
return JSON.stringify(dag, null, 2);
|
|
2752
|
+
}
|
|
2753
|
+
applyAffectivePruning() {
|
|
2754
|
+
const state = this.options.affectiveContext;
|
|
2755
|
+
if (state.dominantEmotion === "frustrated" || state.dominantEmotion === "anxious") {
|
|
2756
|
+
this.nodes = this.nodes.filter(
|
|
2757
|
+
(n) => n.do_capable || n.properties.context_group === "global"
|
|
2758
|
+
);
|
|
2759
|
+
this.edges = this.edges.filter((e) => {
|
|
2760
|
+
const targetNode = this.nodes.find((n) => n.id === e.target);
|
|
2761
|
+
return targetNode && (targetNode.do_capable === true || e.weight > 1);
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
if (state.dominantEmotion === "engaged") {
|
|
2765
|
+
this.edges = this.edges.map((e) => ({
|
|
2766
|
+
...e,
|
|
2767
|
+
weight: e.weight * 1.5
|
|
2768
|
+
// Engaged awareness strengthens correlations
|
|
2769
|
+
}));
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
applyPrivacyMask() {
|
|
2773
|
+
if (!this.options.privacyMask) return;
|
|
2774
|
+
const idMap = /* @__PURE__ */ new Map();
|
|
2775
|
+
let counter = 0;
|
|
2776
|
+
for (const node of this.nodes) {
|
|
2777
|
+
if (!idMap.has(node.id)) {
|
|
2778
|
+
idMap.set(node.id, `NODE_${counter++}`);
|
|
2779
|
+
}
|
|
2780
|
+
node.id = idMap.get(node.id);
|
|
2781
|
+
node.properties = {};
|
|
2782
|
+
}
|
|
2783
|
+
for (const edge of this.edges) {
|
|
2784
|
+
edge.source = idMap.get(edge.source) || `UNKNOWN_${counter++}`;
|
|
2785
|
+
edge.target = idMap.get(edge.target) || `UNKNOWN_${counter++}`;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
extractNodes(composition) {
|
|
2789
|
+
if (composition.objects) {
|
|
2790
|
+
for (const obj of composition.objects) {
|
|
2791
|
+
this.processNode(obj, "global");
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
if (composition.spatialGroups) {
|
|
2795
|
+
for (const group of composition.spatialGroups) {
|
|
2796
|
+
if (group.objects) {
|
|
2797
|
+
for (const obj of group.objects) {
|
|
2798
|
+
this.processNode(obj, group.name);
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
processNode(obj, contextGroup) {
|
|
2805
|
+
const isInterventionCapable = this.hasTrait(obj, "ai_agent") || this.hasTrait(obj, "interactive") || this.hasTrait(obj, "causal");
|
|
2806
|
+
const node = {
|
|
2807
|
+
id: obj.name,
|
|
2808
|
+
type: isInterventionCapable ? "mechanism_variable" : "static_variable",
|
|
2809
|
+
do_capable: isInterventionCapable,
|
|
2810
|
+
properties: {
|
|
2811
|
+
context_group: contextGroup
|
|
2812
|
+
}
|
|
2813
|
+
};
|
|
2814
|
+
for (const prop of obj.properties) {
|
|
2815
|
+
if (typeof prop.value === "number" || typeof prop.value === "string" || typeof prop.value === "boolean") {
|
|
2816
|
+
node.properties[prop.key] = prop.value;
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
this.nodes.push(node);
|
|
2820
|
+
}
|
|
2821
|
+
extractEdges(composition) {
|
|
2822
|
+
if (composition.spatialGroups) {
|
|
2823
|
+
for (const group of composition.spatialGroups) {
|
|
2824
|
+
if (group.objects) {
|
|
2825
|
+
for (const childObj of group.objects) {
|
|
2826
|
+
this.edges.push({
|
|
2827
|
+
source: group.name,
|
|
2828
|
+
target: childObj.name,
|
|
2829
|
+
relation: "dictates_context",
|
|
2830
|
+
weight: 1
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
|
|
2839
|
+
// src/compiler/social-causality.ts
|
|
2840
|
+
var DEFAULT_THRESHOLD = 0.5;
|
|
2841
|
+
var EDGE_KEY = (e) => `${e.source}\0${e.target}\0${e.relation}`;
|
|
2842
|
+
function mergeSocialCausalModels(agentDags, options = {}) {
|
|
2843
|
+
const threshold = options.consensusThreshold ?? DEFAULT_THRESHOLD;
|
|
2844
|
+
if (threshold <= 0 || threshold > 1) {
|
|
2845
|
+
throw new RangeError(
|
|
2846
|
+
`consensusThreshold must be in (0, 1]; got ${threshold}`
|
|
2847
|
+
);
|
|
2848
|
+
}
|
|
2849
|
+
const agentCount = agentDags.length;
|
|
2850
|
+
const minObservers = Math.min(
|
|
2851
|
+
agentCount,
|
|
2852
|
+
Math.floor(threshold * agentCount) + 1
|
|
2853
|
+
);
|
|
2854
|
+
if (agentCount === 0) {
|
|
2855
|
+
return {
|
|
2856
|
+
dag: emptyDag(options.modelName),
|
|
2857
|
+
report: {
|
|
2858
|
+
agents: 0,
|
|
2859
|
+
threshold,
|
|
2860
|
+
nodes: { kept: 0, dropped: 0 },
|
|
2861
|
+
edges: { kept: 0, dropped: 0, smoothed: 0 }
|
|
2862
|
+
}
|
|
2863
|
+
};
|
|
2864
|
+
}
|
|
2865
|
+
const nodeObservers = /* @__PURE__ */ new Map();
|
|
2866
|
+
const nodeRepresentative = /* @__PURE__ */ new Map();
|
|
2867
|
+
for (const dag of agentDags) {
|
|
2868
|
+
const seenInThisAgent = /* @__PURE__ */ new Set();
|
|
2869
|
+
for (const node of dag.nodes) {
|
|
2870
|
+
if (seenInThisAgent.has(node.id)) continue;
|
|
2871
|
+
seenInThisAgent.add(node.id);
|
|
2872
|
+
nodeObservers.set(node.id, (nodeObservers.get(node.id) ?? 0) + 1);
|
|
2873
|
+
if (!nodeRepresentative.has(node.id)) {
|
|
2874
|
+
nodeRepresentative.set(node.id, node);
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
const consensusNodes = [];
|
|
2879
|
+
let nodesDropped = 0;
|
|
2880
|
+
for (const [id, count] of nodeObservers) {
|
|
2881
|
+
if (count >= minObservers) {
|
|
2882
|
+
consensusNodes.push(cloneNode(nodeRepresentative.get(id)));
|
|
2883
|
+
} else {
|
|
2884
|
+
nodesDropped += 1;
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
const consensusNodeIds = new Set(consensusNodes.map((n) => n.id));
|
|
2888
|
+
const edgeAccumulators = /* @__PURE__ */ new Map();
|
|
2889
|
+
for (const dag of agentDags) {
|
|
2890
|
+
const seenInThisAgent = /* @__PURE__ */ new Set();
|
|
2891
|
+
for (const edge of dag.edges) {
|
|
2892
|
+
const key = EDGE_KEY(edge);
|
|
2893
|
+
if (seenInThisAgent.has(key)) continue;
|
|
2894
|
+
seenInThisAgent.add(key);
|
|
2895
|
+
let acc = edgeAccumulators.get(key);
|
|
2896
|
+
if (!acc) {
|
|
2897
|
+
acc = {
|
|
2898
|
+
template: edge,
|
|
2899
|
+
weights: [],
|
|
2900
|
+
observers: 0,
|
|
2901
|
+
distinctWeights: /* @__PURE__ */ new Set()
|
|
2902
|
+
};
|
|
2903
|
+
edgeAccumulators.set(key, acc);
|
|
2904
|
+
}
|
|
2905
|
+
acc.weights.push(edge.weight);
|
|
2906
|
+
acc.distinctWeights.add(edge.weight);
|
|
2907
|
+
acc.observers += 1;
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
const consensusEdges = [];
|
|
2911
|
+
let edgesDropped = 0;
|
|
2912
|
+
let edgesSmoothed = 0;
|
|
2913
|
+
for (const [, acc] of edgeAccumulators) {
|
|
2914
|
+
if (acc.observers < minObservers) {
|
|
2915
|
+
edgesDropped += 1;
|
|
2916
|
+
continue;
|
|
2917
|
+
}
|
|
2918
|
+
if (!consensusNodeIds.has(acc.template.source) || !consensusNodeIds.has(acc.template.target)) {
|
|
2919
|
+
edgesDropped += 1;
|
|
2920
|
+
continue;
|
|
2921
|
+
}
|
|
2922
|
+
const smoothed = acc.distinctWeights.size > 1;
|
|
2923
|
+
if (smoothed) edgesSmoothed += 1;
|
|
2924
|
+
consensusEdges.push({
|
|
2925
|
+
source: acc.template.source,
|
|
2926
|
+
target: acc.template.target,
|
|
2927
|
+
relation: acc.template.relation,
|
|
2928
|
+
weight: average(acc.weights)
|
|
2929
|
+
});
|
|
2930
|
+
}
|
|
2931
|
+
return {
|
|
2932
|
+
dag: {
|
|
2933
|
+
metadata: {
|
|
2934
|
+
model_name: options.modelName ?? "Social_Consensus_DAG",
|
|
2935
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2936
|
+
},
|
|
2937
|
+
nodes: consensusNodes,
|
|
2938
|
+
edges: consensusEdges
|
|
2939
|
+
},
|
|
2940
|
+
report: {
|
|
2941
|
+
agents: agentCount,
|
|
2942
|
+
threshold,
|
|
2943
|
+
nodes: { kept: consensusNodes.length, dropped: nodesDropped },
|
|
2944
|
+
edges: {
|
|
2945
|
+
kept: consensusEdges.length,
|
|
2946
|
+
dropped: edgesDropped,
|
|
2947
|
+
smoothed: edgesSmoothed
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
};
|
|
2951
|
+
}
|
|
2952
|
+
function average(xs) {
|
|
2953
|
+
let sum = 0;
|
|
2954
|
+
for (const x of xs) sum += x;
|
|
2955
|
+
return sum / xs.length;
|
|
2956
|
+
}
|
|
2957
|
+
function cloneNode(node) {
|
|
2958
|
+
return {
|
|
2959
|
+
id: node.id,
|
|
2960
|
+
type: node.type,
|
|
2961
|
+
do_capable: node.do_capable,
|
|
2962
|
+
properties: { ...node.properties }
|
|
2963
|
+
};
|
|
2964
|
+
}
|
|
2965
|
+
function emptyDag(modelName) {
|
|
2966
|
+
return {
|
|
2967
|
+
metadata: {
|
|
2968
|
+
model_name: modelName ?? "Social_Consensus_DAG",
|
|
2969
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2970
|
+
},
|
|
2971
|
+
nodes: [],
|
|
2972
|
+
edges: []
|
|
2973
|
+
};
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
// src/compiler/social-causality-byzantine.ts
|
|
2977
|
+
var DEFAULT_OUTLIER_SIGMA = 1.5;
|
|
2978
|
+
var DEFAULT_DECAY = 0.1;
|
|
2979
|
+
var DEFAULT_DROP_THRESHOLD = 0.3;
|
|
2980
|
+
var DEFAULT_MIN_CLUSTER = 3;
|
|
2981
|
+
var EDGE_KEY2 = (e) => `${e.source} ${e.target} ${e.relation}`;
|
|
2982
|
+
var AgentTrustLedger = class {
|
|
2983
|
+
constructor() {
|
|
2984
|
+
this.entries = /* @__PURE__ */ new Map();
|
|
2985
|
+
}
|
|
2986
|
+
/**
|
|
2987
|
+
* Get a snapshot of an agent's trust state. Returns undefined if the
|
|
2988
|
+
* agent has never been observed.
|
|
2989
|
+
*/
|
|
2990
|
+
get(agentId) {
|
|
2991
|
+
const e = this.entries.get(agentId);
|
|
2992
|
+
return e ? { ...e } : void 0;
|
|
2993
|
+
}
|
|
2994
|
+
/**
|
|
2995
|
+
* Get a snapshot of every agent's trust state. Mutating the returned
|
|
2996
|
+
* object does NOT mutate the ledger.
|
|
2997
|
+
*/
|
|
2998
|
+
snapshot() {
|
|
2999
|
+
const out = {};
|
|
3000
|
+
for (const [id, e] of this.entries) out[id] = { ...e };
|
|
3001
|
+
return out;
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* Forget an agent's history entirely. Use to pardon an agent that was
|
|
3005
|
+
* dropped — see "Recovery semantics" in the file header.
|
|
3006
|
+
*/
|
|
3007
|
+
reset(agentId) {
|
|
3008
|
+
this.entries.delete(agentId);
|
|
3009
|
+
}
|
|
3010
|
+
/** Forget every agent. */
|
|
3011
|
+
resetAll() {
|
|
3012
|
+
this.entries.clear();
|
|
3013
|
+
}
|
|
3014
|
+
/** @internal — used by {@link byzantineResilientMerge}. */
|
|
3015
|
+
observe(agentId, hostileThisEpoch, decay) {
|
|
3016
|
+
let e = this.entries.get(agentId);
|
|
3017
|
+
if (!e) {
|
|
3018
|
+
e = { score: 1, epochs: 0, hostileEpochs: 0 };
|
|
3019
|
+
this.entries.set(agentId, e);
|
|
3020
|
+
}
|
|
3021
|
+
e.epochs += 1;
|
|
3022
|
+
if (hostileThisEpoch) {
|
|
3023
|
+
e.hostileEpochs += 1;
|
|
3024
|
+
e.score = Math.max(0, e.score - decay);
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
/** @internal — used by {@link byzantineResilientMerge}. */
|
|
3028
|
+
isTrusted(agentId, threshold) {
|
|
3029
|
+
const e = this.entries.get(agentId);
|
|
3030
|
+
if (!e) return true;
|
|
3031
|
+
return e.score >= threshold;
|
|
3032
|
+
}
|
|
3033
|
+
};
|
|
3034
|
+
function byzantineResilientMerge(agentDags, ledger, options = {}) {
|
|
3035
|
+
const sigma = options.outlierSigma ?? DEFAULT_OUTLIER_SIGMA;
|
|
3036
|
+
const decay = options.decayPerEpoch ?? DEFAULT_DECAY;
|
|
3037
|
+
const dropThreshold = options.dropThreshold ?? DEFAULT_DROP_THRESHOLD;
|
|
3038
|
+
const minCluster = options.minClusterAgents ?? DEFAULT_MIN_CLUSTER;
|
|
3039
|
+
if (sigma <= 0) {
|
|
3040
|
+
throw new RangeError(`outlierSigma must be > 0; got ${sigma}`);
|
|
3041
|
+
}
|
|
3042
|
+
if (decay < 0 || decay > 1) {
|
|
3043
|
+
throw new RangeError(`decayPerEpoch must be in [0, 1]; got ${decay}`);
|
|
3044
|
+
}
|
|
3045
|
+
if (dropThreshold < 0 || dropThreshold > 1) {
|
|
3046
|
+
throw new RangeError(
|
|
3047
|
+
`dropThreshold must be in [0, 1]; got ${dropThreshold}`
|
|
3048
|
+
);
|
|
3049
|
+
}
|
|
3050
|
+
if (minCluster < 2 || !Number.isInteger(minCluster)) {
|
|
3051
|
+
throw new RangeError(
|
|
3052
|
+
`minClusterAgents must be an integer >= 2; got ${minCluster}`
|
|
3053
|
+
);
|
|
3054
|
+
}
|
|
3055
|
+
const agentIds = /* @__PURE__ */ new Map();
|
|
3056
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
3057
|
+
agentDags.forEach((dag, idx) => {
|
|
3058
|
+
let id = dag.metadata.model_name?.trim();
|
|
3059
|
+
if (!id || seenIds.has(id)) {
|
|
3060
|
+
id = `agent#${idx}`;
|
|
3061
|
+
}
|
|
3062
|
+
seenIds.add(id);
|
|
3063
|
+
agentIds.set(dag, id);
|
|
3064
|
+
});
|
|
3065
|
+
const edgeObservations = /* @__PURE__ */ new Map();
|
|
3066
|
+
for (const dag of agentDags) {
|
|
3067
|
+
const agentId = agentIds.get(dag);
|
|
3068
|
+
const seenInThisAgent = /* @__PURE__ */ new Set();
|
|
3069
|
+
for (const edge of dag.edges) {
|
|
3070
|
+
const key = EDGE_KEY2(edge);
|
|
3071
|
+
if (seenInThisAgent.has(key)) continue;
|
|
3072
|
+
seenInThisAgent.add(key);
|
|
3073
|
+
const obs = edgeObservations.get(key) ?? [];
|
|
3074
|
+
obs.push({ agentId, weight: edge.weight });
|
|
3075
|
+
edgeObservations.set(key, obs);
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3078
|
+
const outliersByEdge = {};
|
|
3079
|
+
const hostileThisEpoch = /* @__PURE__ */ new Set();
|
|
3080
|
+
for (const [edgeKey, obs] of edgeObservations) {
|
|
3081
|
+
if (obs.length < minCluster) continue;
|
|
3082
|
+
const mean2 = obs.reduce((s, o) => s + o.weight, 0) / obs.length;
|
|
3083
|
+
const variance = obs.reduce((s, o) => s + (o.weight - mean2) ** 2, 0) / obs.length;
|
|
3084
|
+
const std = Math.sqrt(variance);
|
|
3085
|
+
if (std === 0) continue;
|
|
3086
|
+
const cutoff = sigma * std;
|
|
3087
|
+
const outliers = [];
|
|
3088
|
+
for (const o of obs) {
|
|
3089
|
+
if (Math.abs(o.weight - mean2) > cutoff) {
|
|
3090
|
+
outliers.push(o.agentId);
|
|
3091
|
+
hostileThisEpoch.add(o.agentId);
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
if (outliers.length > 0) outliersByEdge[edgeKey] = outliers;
|
|
3095
|
+
}
|
|
3096
|
+
const seenThisEpoch = /* @__PURE__ */ new Set();
|
|
3097
|
+
for (const dag of agentDags) {
|
|
3098
|
+
const agentId = agentIds.get(dag);
|
|
3099
|
+
if (seenThisEpoch.has(agentId)) continue;
|
|
3100
|
+
seenThisEpoch.add(agentId);
|
|
3101
|
+
ledger.observe(agentId, hostileThisEpoch.has(agentId), decay);
|
|
3102
|
+
}
|
|
3103
|
+
const dropped = [];
|
|
3104
|
+
const survivors = [];
|
|
3105
|
+
for (const dag of agentDags) {
|
|
3106
|
+
const agentId = agentIds.get(dag);
|
|
3107
|
+
if (ledger.isTrusted(agentId, dropThreshold)) {
|
|
3108
|
+
survivors.push(dag);
|
|
3109
|
+
} else {
|
|
3110
|
+
dropped.push(agentId);
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
const merged = mergeSocialCausalModels(survivors, options);
|
|
3114
|
+
return {
|
|
3115
|
+
dag: merged.dag,
|
|
3116
|
+
report: {
|
|
3117
|
+
ledger: ledger.snapshot(),
|
|
3118
|
+
dropped: Array.from(new Set(dropped)),
|
|
3119
|
+
flaggedThisEpoch: Array.from(hostileThisEpoch),
|
|
3120
|
+
outliersByEdge,
|
|
3121
|
+
consensus: merged.report
|
|
3122
|
+
}
|
|
3123
|
+
};
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
// src/compiler/index.ts
|
|
2377
3127
|
init_NodeServiceCompiler();
|
|
2378
3128
|
init_DialectRegistry();
|
|
2379
3129
|
init_registerBuiltinDialects();
|
|
2380
3130
|
|
|
2381
|
-
|
|
3131
|
+
// src/compiler/FlatSemanticCompiler.ts
|
|
3132
|
+
init_CompilerBase();
|
|
3133
|
+
function isFlatSemanticCompilerOptions(value) {
|
|
3134
|
+
if (!value || typeof value !== "object") return false;
|
|
3135
|
+
return "format" in value || "generateDocs" in value || "docsOptions" in value || "provenanceHash" in value;
|
|
3136
|
+
}
|
|
3137
|
+
var FlatSemanticCompiler = class extends CompilerBase {
|
|
3138
|
+
constructor() {
|
|
3139
|
+
super(...arguments);
|
|
3140
|
+
this.compilerName = "FlatSemanticCompiler";
|
|
3141
|
+
}
|
|
3142
|
+
compile(composition, agentToken, outputPath, sceneGraphOrOptions, options) {
|
|
3143
|
+
this.validateCompilerAccess(agentToken, outputPath);
|
|
3144
|
+
const compileOptions = options ?? (isFlatSemanticCompilerOptions(sceneGraphOrOptions) ? sceneGraphOrOptions : void 0);
|
|
3145
|
+
const elements = composition.ui?.elements || composition.objects || [];
|
|
3146
|
+
const traits = this.extractTraits(composition);
|
|
3147
|
+
const canvasConfig = traits["2d_canvas"] || {};
|
|
3148
|
+
const code = this.generateReactComponent(composition.name, elements, canvasConfig);
|
|
3149
|
+
if (compileOptions?.generateDocs) {
|
|
3150
|
+
return {
|
|
3151
|
+
output: code,
|
|
3152
|
+
documentation: this.generateDocumentation(composition, code, compileOptions.docsOptions)
|
|
3153
|
+
};
|
|
3154
|
+
}
|
|
3155
|
+
return code;
|
|
3156
|
+
}
|
|
3157
|
+
extractTraits(obj) {
|
|
3158
|
+
const map = {};
|
|
3159
|
+
if (!obj.traits) return map;
|
|
3160
|
+
for (const t of obj.traits) {
|
|
3161
|
+
map[t.name] = t.config || {};
|
|
3162
|
+
}
|
|
3163
|
+
return map;
|
|
3164
|
+
}
|
|
3165
|
+
// ============================================================================
|
|
3166
|
+
// CODE GENERATION
|
|
3167
|
+
// ============================================================================
|
|
3168
|
+
generateReactComponent(name, objects, _canvasConfig) {
|
|
3169
|
+
const safeName = name.replace(/[^a-zA-Z0-9]/g, "");
|
|
3170
|
+
const semanticNodes = objects.map((obj) => this.generateSemanticNode(obj)).join("\n ");
|
|
3171
|
+
return `import React, { useRef, useState, useEffect } from 'react';
|
|
3172
|
+
import { Canvas, useFrame } from '@react-three/fiber';
|
|
3173
|
+
import { Html, Float, Sparkles, MeshDistortMaterial } from '@react-three/drei';
|
|
3174
|
+
|
|
3175
|
+
/**
|
|
3176
|
+
* HoloScript V6 2D UI Revolution
|
|
3177
|
+
* Flat-Semantic Projection of: ${name}
|
|
3178
|
+
*
|
|
3179
|
+
* Auto-generated by FlatSemanticCompiler
|
|
3180
|
+
*/
|
|
3181
|
+
|
|
3182
|
+
// Procedural Field Background Component
|
|
3183
|
+
function ProceduralField({ turbulence = 0.3, intensity = 1.0 }) {
|
|
3184
|
+
const meshRef = useRef<any>(null);
|
|
3185
|
+
useFrame((state) => {
|
|
3186
|
+
if (meshRef.current) {
|
|
3187
|
+
meshRef.current.rotation.x = state.clock.getElapsedTime() * 0.1 * turbulence;
|
|
3188
|
+
meshRef.current.rotation.y = state.clock.getElapsedTime() * 0.15 * turbulence;
|
|
3189
|
+
}
|
|
3190
|
+
});
|
|
3191
|
+
|
|
3192
|
+
return (
|
|
3193
|
+
<mesh ref={meshRef} scale={[15, 15, 1]} position={[0, 0, -5]}>
|
|
3194
|
+
<planeGeometry args={[2, 2, 32, 32]} />
|
|
3195
|
+
<MeshDistortMaterial
|
|
3196
|
+
color="#1a0b2e"
|
|
3197
|
+
emissive="#0a0515"
|
|
3198
|
+
distort={turbulence}
|
|
3199
|
+
speed={intensity * 2}
|
|
3200
|
+
roughness={0.2}
|
|
3201
|
+
/>
|
|
3202
|
+
<Sparkles count={100} scale={20} size={2} color="#8b5cf6" speed={0.4} opacity={0.5} />
|
|
3203
|
+
</mesh>
|
|
3204
|
+
);
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
export function ${safeName}Component() {
|
|
3208
|
+
const [bountyPools, setBountyPools] = useState<Record<string, number>>({});
|
|
3209
|
+
|
|
3210
|
+
return (
|
|
3211
|
+
<div className="holoscript-v6-root w-full h-screen bg-[#050505] overflow-hidden text-white font-sans">
|
|
3212
|
+
<Canvas orthographic camera={{ zoom: 100, position: [0, 0, 100] }}>
|
|
3213
|
+
<ambientLight intensity={0.5} />
|
|
3214
|
+
<directionalLight position={[10, 10, 5]} intensity={1} />
|
|
3215
|
+
|
|
3216
|
+
{/* Simulation Layer */}
|
|
3217
|
+
<ProceduralField turbulence={0.3} intensity={1.0} />
|
|
3218
|
+
|
|
3219
|
+
{/* Semantic 2D Projection Layer */}
|
|
3220
|
+
<Html fullscreen zIndexRange={[100, 0]} className="pointer-events-none">
|
|
3221
|
+
<div className="w-full h-full relative pointer-events-auto overflow-y-auto">
|
|
3222
|
+
${semanticNodes}
|
|
3223
|
+
</div>
|
|
3224
|
+
</Html>
|
|
3225
|
+
</Canvas>
|
|
3226
|
+
</div>
|
|
3227
|
+
);
|
|
3228
|
+
}
|
|
3229
|
+
|
|
3230
|
+
export default ${safeName}Component;
|
|
3231
|
+
`;
|
|
3232
|
+
}
|
|
3233
|
+
generateSemanticNode(obj) {
|
|
3234
|
+
const traits = this.extractTraits(obj);
|
|
3235
|
+
!!traits["semantic_entity"];
|
|
3236
|
+
const type = traits["semantic_entity"]?.type || "generic";
|
|
3237
|
+
let classes = "relative ";
|
|
3238
|
+
if (traits.tailwind?.classes) classes += traits.tailwind.classes + " ";
|
|
3239
|
+
const layout = traits["semantic_layout"];
|
|
3240
|
+
if (layout) {
|
|
3241
|
+
const flow = layout.flow || "semantic";
|
|
3242
|
+
if (flow === "cluster") classes += "flex flex-wrap gap-4 justify-center items-center ";
|
|
3243
|
+
else if (flow === "priority") classes += "flex flex-col gap-3 ";
|
|
3244
|
+
else if (flow === "radial")
|
|
3245
|
+
classes += "grid place-items-center gap-4 p-8 rounded-full border border-white/10 ";
|
|
3246
|
+
else classes += "flex flex-row gap-4 items-start ";
|
|
3247
|
+
const spacing = layout.spacing || 12;
|
|
3248
|
+
classes += `p-[${spacing}px] `;
|
|
3249
|
+
}
|
|
3250
|
+
const hasSwarm = !!traits["agent_attention"];
|
|
3251
|
+
let rawChildren = obj.children || obj.objects || [];
|
|
3252
|
+
if (rawChildren.length === 0 && traits["semantic_entity"]?.children) {
|
|
3253
|
+
rawChildren = traits["semantic_entity"].children;
|
|
3254
|
+
}
|
|
3255
|
+
const childrenMarkup = rawChildren.map((child) => this.generateSemanticNode(child)).join("\n");
|
|
3256
|
+
let content = traits.text?.content || "";
|
|
3257
|
+
if (content)
|
|
3258
|
+
content = "{`" + content.replace(new RegExp("`", "g"), "\\`").replace(/\\$/g, "\\\\$") + "`}";
|
|
3259
|
+
if (type === "data-cluster" || type === "section") {
|
|
3260
|
+
return '<section className="' + classes + '">\n' + content + "\n" + childrenMarkup + "\n</section>";
|
|
3261
|
+
}
|
|
3262
|
+
if (type === "metric-card") {
|
|
3263
|
+
return '<div className="lift-card p-6 bg-white/5 border border-white/10 rounded-xl hover:bg-white/10 transition-all ' + classes + '">\n' + content + "\n" + childrenMarkup + "\n</div>";
|
|
3264
|
+
}
|
|
3265
|
+
let interactionProps = "";
|
|
3266
|
+
if (traits["agent_attention"] && traits["agent_attention"].bounty_threshold) {
|
|
3267
|
+
interactionProps = " onClick={() => alert('Bounty Negotiated: " + traits["agent_attention"].bounty_threshold + " credits')} ";
|
|
3268
|
+
} else if (traits["intent_driven"]) {
|
|
3269
|
+
interactionProps = " onClick={() => console.log('Intent Emitted: " + (traits["intent_driven"].intents?.[0] || "action") + "')} ";
|
|
3270
|
+
}
|
|
3271
|
+
if (traits.link || type === "link") {
|
|
3272
|
+
return '<a href="' + (traits.link?.href || "#") + '" className="' + classes + '"' + interactionProps + ">\n" + content + "\n" + childrenMarkup + "\n</a>";
|
|
3273
|
+
}
|
|
3274
|
+
if (traits.image) {
|
|
3275
|
+
return '<img src="' + traits.image.src + '" className="' + classes + '" alt="' + (traits.image.alt || "") + '" />';
|
|
3276
|
+
}
|
|
3277
|
+
const swarmHtml = hasSwarm ? '<div className="text-xs text-purple-400 mt-2 font-mono flex items-center gap-2"><span className="w-2 h-2 rounded-full bg-purple-500 animate-pulse"></span> Agent Swarm Active</div>' : "";
|
|
3278
|
+
return '<div className="' + classes + '"' + interactionProps + ">\n" + content + "\n" + swarmHtml + "\n" + childrenMarkup + "\n</div>";
|
|
3279
|
+
}
|
|
3280
|
+
};
|
|
3281
|
+
|
|
3282
|
+
// src/compiler/dispatch/DispatchPolicy.ts
|
|
3283
|
+
var DispatchTier = /* @__PURE__ */ ((DispatchTier2) => {
|
|
3284
|
+
DispatchTier2["TIER_1_NEUROMORPHIC"] = "tier-1-neuromorphic";
|
|
3285
|
+
DispatchTier2["TIER_1_BROWSER"] = "tier-1-browser";
|
|
3286
|
+
DispatchTier2["TIER_1_WASM"] = "tier-1-wasm";
|
|
3287
|
+
DispatchTier2["TIER_2_SPECULATIVE"] = "tier-2-speculative";
|
|
3288
|
+
DispatchTier2["TIER_3_CPU_DIRECT"] = "tier-3-cpu-direct";
|
|
3289
|
+
return DispatchTier2;
|
|
3290
|
+
})(DispatchTier || {});
|
|
3291
|
+
var AlphaTracker = class {
|
|
3292
|
+
constructor(size = 50) {
|
|
3293
|
+
this.window = [];
|
|
3294
|
+
this.size = size;
|
|
3295
|
+
}
|
|
3296
|
+
recordAttempt(success) {
|
|
3297
|
+
this.window.push(success);
|
|
3298
|
+
if (this.window.length > this.size) {
|
|
3299
|
+
this.window.shift();
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
getAlpha() {
|
|
3303
|
+
if (this.window.length === 0) return 0;
|
|
3304
|
+
const successes = this.window.filter((s) => s).length;
|
|
3305
|
+
return successes / this.window.length;
|
|
3306
|
+
}
|
|
3307
|
+
get windowLength() {
|
|
3308
|
+
return this.window.length;
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
var DispatchPolicy = class {
|
|
3312
|
+
constructor(config = {}) {
|
|
3313
|
+
this.config = {
|
|
3314
|
+
tier1BrowserEnabled: false,
|
|
3315
|
+
tier1WasmEnabled: false,
|
|
3316
|
+
tier1NeuromorphicEnabled: false,
|
|
3317
|
+
tier2Enabled: false,
|
|
3318
|
+
tier2AlphaThreshold: 0.85,
|
|
3319
|
+
alphaWindowSize: 50,
|
|
3320
|
+
...config
|
|
3321
|
+
};
|
|
3322
|
+
this.alphaTracker = new AlphaTracker(this.config.alphaWindowSize);
|
|
3323
|
+
}
|
|
3324
|
+
/**
|
|
3325
|
+
* Route an operation to the highest viable tier, falling back as needed.
|
|
3326
|
+
*/
|
|
3327
|
+
async route(op) {
|
|
3328
|
+
const start = performance.now();
|
|
3329
|
+
let lastRejectionReason;
|
|
3330
|
+
let lastRejectionMetrics;
|
|
3331
|
+
if (this.config.tier1NeuromorphicEnabled) {
|
|
3332
|
+
const decision2 = await this.tryTier1Neuromorphic(op);
|
|
3333
|
+
if (decision2.accepted) {
|
|
3334
|
+
decision2.metrics.latencyEstimateMs = performance.now() - start;
|
|
3335
|
+
return decision2;
|
|
3336
|
+
}
|
|
3337
|
+
lastRejectionReason = decision2.metrics.fallbackReason;
|
|
3338
|
+
lastRejectionMetrics = {
|
|
3339
|
+
neuromorphicProbe: decision2.metrics.neuromorphicProbe
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3342
|
+
if (this.config.tier1BrowserEnabled) {
|
|
3343
|
+
const decision2 = await this.tryTier1Browser(op);
|
|
3344
|
+
if (decision2.accepted) {
|
|
3345
|
+
decision2.metrics.latencyEstimateMs = performance.now() - start;
|
|
3346
|
+
return decision2;
|
|
3347
|
+
}
|
|
3348
|
+
lastRejectionReason = decision2.metrics.fallbackReason;
|
|
3349
|
+
lastRejectionMetrics = void 0;
|
|
3350
|
+
}
|
|
3351
|
+
if (this.config.tier1WasmEnabled) {
|
|
3352
|
+
const decision2 = await this.tryTier1Wasm(op);
|
|
3353
|
+
if (decision2.accepted) {
|
|
3354
|
+
decision2.metrics.latencyEstimateMs = performance.now() - start;
|
|
3355
|
+
return decision2;
|
|
3356
|
+
}
|
|
3357
|
+
lastRejectionReason = decision2.metrics.fallbackReason;
|
|
3358
|
+
lastRejectionMetrics = {
|
|
3359
|
+
wasmProbe: decision2.metrics.wasmProbe,
|
|
3360
|
+
wasmEmulator: decision2.metrics.wasmEmulator
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3363
|
+
if (this.config.tier2Enabled) {
|
|
3364
|
+
const decision2 = await this.tryTier2(op);
|
|
3365
|
+
if (decision2.accepted) {
|
|
3366
|
+
decision2.metrics.latencyEstimateMs = performance.now() - start;
|
|
3367
|
+
return decision2;
|
|
3368
|
+
}
|
|
3369
|
+
lastRejectionReason = decision2.metrics.fallbackReason;
|
|
3370
|
+
lastRejectionMetrics = {
|
|
3371
|
+
alpha: decision2.metrics.alpha,
|
|
3372
|
+
verifierPassed: decision2.metrics.verifierPassed,
|
|
3373
|
+
traitEquivalence: decision2.metrics.traitEquivalence
|
|
3374
|
+
};
|
|
3375
|
+
}
|
|
3376
|
+
const decision = await this.fallbackTier3(
|
|
3377
|
+
op,
|
|
3378
|
+
lastRejectionReason ?? "No higher tier accepted or enabled",
|
|
3379
|
+
lastRejectionMetrics
|
|
3380
|
+
);
|
|
3381
|
+
decision.metrics.latencyEstimateMs = performance.now() - start;
|
|
3382
|
+
return decision;
|
|
3383
|
+
}
|
|
3384
|
+
/** Current speculative-decoding alpha (Tier-2 acceptance rate). */
|
|
3385
|
+
getAlpha() {
|
|
3386
|
+
return this.alphaTracker.getAlpha();
|
|
3387
|
+
}
|
|
3388
|
+
// ---------------------------------------------------------------------------
|
|
3389
|
+
// TIER ATTEMPTERS
|
|
3390
|
+
// ---------------------------------------------------------------------------
|
|
3391
|
+
async tryTier1Neuromorphic(op) {
|
|
3392
|
+
const probe = await this.probeNeuromorphicRuntime();
|
|
3393
|
+
const deviceMatches = probe.available && (!this.config.tier1NeuromorphicDevice || probe.device === this.config.tier1NeuromorphicDevice);
|
|
3394
|
+
const traitCompatible = this.isTraitSnnCompatible(op.trait);
|
|
3395
|
+
const accepted = deviceMatches && traitCompatible;
|
|
3396
|
+
const reason = accepted ? void 0 : this.describeNeuromorphicRejection(probe, traitCompatible);
|
|
3397
|
+
return this.buildDecision("tier-1-neuromorphic" /* TIER_1_NEUROMORPHIC */, accepted, op, reason, void 0, {
|
|
3398
|
+
neuromorphicProbe: probe
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
async tryTier1Browser(op) {
|
|
3402
|
+
const available = isWebGpuEnvironmentPresent();
|
|
3403
|
+
const traitCompatible = this.isTraitSnnCompatible(op.trait);
|
|
3404
|
+
if (!available || !traitCompatible) {
|
|
3405
|
+
const reason = !available ? "WebGPU not available" : "Trait is not mapped to the SNN/WebGPU hot path";
|
|
3406
|
+
return this.buildDecision("tier-1-browser" /* TIER_1_BROWSER */, false, op, reason);
|
|
3407
|
+
}
|
|
3408
|
+
const executor = this.config.tier1BrowserExecutor ?? runTier1BrowserSnn;
|
|
3409
|
+
try {
|
|
3410
|
+
const result = await executor(op);
|
|
3411
|
+
const reason = result.accepted ? void 0 : result.reason ?? "Tier-1 browser executor rejected dispatch";
|
|
3412
|
+
return this.buildDecision(
|
|
3413
|
+
"tier-1-browser" /* TIER_1_BROWSER */,
|
|
3414
|
+
result.accepted,
|
|
3415
|
+
op,
|
|
3416
|
+
reason,
|
|
3417
|
+
void 0,
|
|
3418
|
+
{ browserExecutor: result }
|
|
3419
|
+
);
|
|
3420
|
+
} catch (error) {
|
|
3421
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3422
|
+
return this.buildDecision("tier-1-browser" /* TIER_1_BROWSER */, false, op, message, void 0, {
|
|
3423
|
+
browserExecutor: { accepted: false, source: "tier-1-browser-error", reason: message }
|
|
3424
|
+
});
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
async tryTier1Wasm(op) {
|
|
3428
|
+
const runtime = await this.probeWasmRuntime();
|
|
3429
|
+
const traitCompatible = this.isTraitSnnCompatible(op.trait);
|
|
3430
|
+
if (!runtime.available || !traitCompatible) {
|
|
3431
|
+
const reason2 = this.describeWasmRejection(runtime, traitCompatible);
|
|
3432
|
+
return this.buildDecision("tier-1-wasm" /* TIER_1_WASM */, false, op, reason2, void 0, {
|
|
3433
|
+
wasmProbe: runtime
|
|
3434
|
+
});
|
|
3435
|
+
}
|
|
3436
|
+
const emulator = await this.runTier1WasmEmulator(op, runtime);
|
|
3437
|
+
const reason = emulator.accepted ? void 0 : emulator.reason ?? "compiler-wasm SNN emulator rejected dispatch";
|
|
3438
|
+
return this.buildDecision(
|
|
3439
|
+
"tier-1-wasm" /* TIER_1_WASM */,
|
|
3440
|
+
emulator.accepted,
|
|
3441
|
+
op,
|
|
3442
|
+
reason,
|
|
3443
|
+
void 0,
|
|
3444
|
+
{
|
|
3445
|
+
wasmProbe: runtime,
|
|
3446
|
+
wasmEmulator: emulator
|
|
3447
|
+
}
|
|
3448
|
+
);
|
|
3449
|
+
}
|
|
3450
|
+
async tryTier2(op) {
|
|
3451
|
+
const provider = this.config.llmProposalProvider;
|
|
3452
|
+
const proposal = provider ? await provider(op) ?? null : null;
|
|
3453
|
+
if (!proposal) {
|
|
3454
|
+
this.alphaTracker.recordAttempt(false);
|
|
3455
|
+
const alpha2 = this.alphaTracker.getAlpha();
|
|
3456
|
+
return this.buildDecision(
|
|
3457
|
+
"tier-2-speculative" /* TIER_2_SPECULATIVE */,
|
|
3458
|
+
false,
|
|
3459
|
+
op,
|
|
3460
|
+
`LLM proposal failed; alpha ${alpha2.toFixed(2)} < threshold ${this.config.tier2AlphaThreshold}`,
|
|
3461
|
+
alpha2,
|
|
3462
|
+
{
|
|
3463
|
+
verifierPassed: false,
|
|
3464
|
+
traitEquivalence: {
|
|
3465
|
+
equivalent: false,
|
|
3466
|
+
source: "dispatch-policy",
|
|
3467
|
+
reason: "LLM proposal provider returned no output",
|
|
3468
|
+
score: 0
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
);
|
|
3472
|
+
}
|
|
3473
|
+
const verifierPassed = await this.runCpuVerifier(op, proposal);
|
|
3474
|
+
const tier3Output = await this.runTier3CpuDirect(op);
|
|
3475
|
+
const traitEquivalence = await this.evaluateTraitEquivalence(op, proposal, tier3Output);
|
|
3476
|
+
this.alphaTracker.recordAttempt(traitEquivalence.equivalent);
|
|
3477
|
+
const alpha = this.alphaTracker.getAlpha();
|
|
3478
|
+
const accepted = verifierPassed && traitEquivalence.equivalent && alpha >= this.config.tier2AlphaThreshold;
|
|
3479
|
+
const reason = accepted ? void 0 : this.describeTier2Rejection(verifierPassed, traitEquivalence, alpha);
|
|
3480
|
+
return this.buildDecision("tier-2-speculative" /* TIER_2_SPECULATIVE */, accepted, op, reason, alpha, {
|
|
3481
|
+
verifierPassed,
|
|
3482
|
+
traitEquivalence
|
|
3483
|
+
});
|
|
3484
|
+
}
|
|
3485
|
+
async fallbackTier3(op, reason, extraMetrics = {}) {
|
|
3486
|
+
return this.buildDecision(
|
|
3487
|
+
"tier-3-cpu-direct" /* TIER_3_CPU_DIRECT */,
|
|
3488
|
+
true,
|
|
3489
|
+
op,
|
|
3490
|
+
reason,
|
|
3491
|
+
void 0,
|
|
3492
|
+
extraMetrics
|
|
3493
|
+
);
|
|
3494
|
+
}
|
|
3495
|
+
// ---------------------------------------------------------------------------
|
|
3496
|
+
// VERIFIERS & HELPERS
|
|
3497
|
+
// ---------------------------------------------------------------------------
|
|
3498
|
+
async probeNeuromorphicRuntime() {
|
|
3499
|
+
const probe = this.config.neuromorphicRuntimeProbe ?? detectNeuromorphicRuntime;
|
|
3500
|
+
return probe(this.config.tier1NeuromorphicDevice);
|
|
3501
|
+
}
|
|
3502
|
+
async probeWasmRuntime() {
|
|
3503
|
+
const probe = this.config.tier1WasmRuntimeProbe ?? detectWasmRuntime;
|
|
3504
|
+
return probe();
|
|
3505
|
+
}
|
|
3506
|
+
async runTier1WasmEmulator(op, runtime) {
|
|
3507
|
+
const executor = this.config.tier1WasmExecutor ?? runCompilerWasmSnnEmulator;
|
|
3508
|
+
try {
|
|
3509
|
+
return await executor(op, runtime);
|
|
3510
|
+
} catch (error) {
|
|
3511
|
+
return {
|
|
3512
|
+
accepted: false,
|
|
3513
|
+
source: "compiler-wasm-snn-emulator",
|
|
3514
|
+
runtime,
|
|
3515
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
describeNeuromorphicRejection(probe, traitCompatible) {
|
|
3520
|
+
if (!probe.available) {
|
|
3521
|
+
return probe.reason ?? "Neuromorphic runtime device not discovered";
|
|
3522
|
+
}
|
|
3523
|
+
if (this.config.tier1NeuromorphicDevice && probe.device !== this.config.tier1NeuromorphicDevice) {
|
|
3524
|
+
return `NIR runtime discovered ${probe.device ?? "unknown"} but requires ${this.config.tier1NeuromorphicDevice}`;
|
|
3525
|
+
}
|
|
3526
|
+
if (!traitCompatible) {
|
|
3527
|
+
return "Trait is not mapped to the SNN/NIR hot path";
|
|
3528
|
+
}
|
|
3529
|
+
return "Neuromorphic runtime probe did not accept dispatch";
|
|
3530
|
+
}
|
|
3531
|
+
describeWasmRejection(runtime, traitCompatible) {
|
|
3532
|
+
if (!runtime.available) {
|
|
3533
|
+
return runtime.reason ?? "WebAssembly runtime unavailable for Tier-1 WASM fallback";
|
|
3534
|
+
}
|
|
3535
|
+
if (!traitCompatible) {
|
|
3536
|
+
return "Trait is not mapped to the SNN/WASM hot path";
|
|
3537
|
+
}
|
|
3538
|
+
return "compiler-wasm SNN emulator did not accept dispatch";
|
|
3539
|
+
}
|
|
3540
|
+
isTraitSnnCompatible(trait) {
|
|
3541
|
+
const snnTraits = /* @__PURE__ */ new Set(["grabbable", "hoverable", "clickable", "draggable", "throwable"]);
|
|
3542
|
+
return snnTraits.has(trait);
|
|
3543
|
+
}
|
|
3544
|
+
async runCpuVerifier(op, _proposal) {
|
|
3545
|
+
let anyVerifierWired = false;
|
|
3546
|
+
if (this.config.effectVerifier) {
|
|
3547
|
+
anyVerifierWired = true;
|
|
3548
|
+
const effectResult = await this.config.effectVerifier([op.trait]);
|
|
3549
|
+
if (!effectResult || !effectResult.passed) return false;
|
|
3550
|
+
}
|
|
3551
|
+
if (op.manifest && this.config.simulationContractVerifier) {
|
|
3552
|
+
anyVerifierWired = true;
|
|
3553
|
+
const scPassed = await this.config.simulationContractVerifier(op.manifest);
|
|
3554
|
+
if (!scPassed) return false;
|
|
3555
|
+
} else if (op.manifest) {
|
|
3556
|
+
anyVerifierWired = true;
|
|
3557
|
+
try {
|
|
3558
|
+
assertHoloMapManifestContract(op.manifest);
|
|
3559
|
+
} catch {
|
|
3560
|
+
return false;
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3563
|
+
return anyVerifierWired;
|
|
3564
|
+
}
|
|
3565
|
+
async runTier3CpuDirect(op) {
|
|
3566
|
+
const executor = this.config.tier3CpuExecutor ?? runTier3CpuDirectExecutor;
|
|
3567
|
+
return executor(op);
|
|
3568
|
+
}
|
|
3569
|
+
async evaluateTraitEquivalence(op, proposal, tier3Output) {
|
|
3570
|
+
const oracle = this.config.traitEquivalenceOracle ?? defaultTraitEquivalenceOracle;
|
|
3571
|
+
try {
|
|
3572
|
+
return await oracle({ operation: op, proposal, tier3Output });
|
|
3573
|
+
} catch (error) {
|
|
3574
|
+
return {
|
|
3575
|
+
equivalent: false,
|
|
3576
|
+
source: "trait-equivalence-oracle",
|
|
3577
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
3578
|
+
score: 0
|
|
3579
|
+
};
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
describeTier2Rejection(verifierPassed, equivalence, alpha) {
|
|
3583
|
+
const parts = [
|
|
3584
|
+
`Verifier ${verifierPassed ? "passed" : "rejected"}`,
|
|
3585
|
+
`equivalence ${equivalence.equivalent ? "passed" : "failed"}`,
|
|
3586
|
+
`alpha ${alpha.toFixed(2)} < threshold ${this.config.tier2AlphaThreshold}`
|
|
3587
|
+
];
|
|
3588
|
+
if (equivalence.reason) {
|
|
3589
|
+
parts.push(equivalence.reason);
|
|
3590
|
+
}
|
|
3591
|
+
return parts.join("; ");
|
|
3592
|
+
}
|
|
3593
|
+
// ---------------------------------------------------------------------------
|
|
3594
|
+
// PROVENANCE BUILDER
|
|
3595
|
+
// ---------------------------------------------------------------------------
|
|
3596
|
+
async buildDecision(tier, accepted, op, fallbackReason, alpha, extraMetrics = {}) {
|
|
3597
|
+
const metrics = {
|
|
3598
|
+
tierAttempted: tier,
|
|
3599
|
+
tierAccepted: accepted,
|
|
3600
|
+
fallbackReason,
|
|
3601
|
+
latencyEstimateMs: 0,
|
|
3602
|
+
alpha,
|
|
3603
|
+
...extraMetrics
|
|
3604
|
+
};
|
|
3605
|
+
const provenanceContext = op.provenanceContext ?? {
|
|
3606
|
+
authorityLevel: 50,
|
|
3607
|
+
// AGENT default
|
|
3608
|
+
sourceType: "system"
|
|
3609
|
+
};
|
|
3610
|
+
const provenance = {
|
|
3611
|
+
value: { tier, accepted, nodeId: op.nodeId, trait: op.trait },
|
|
3612
|
+
source: "dispatch-policy",
|
|
3613
|
+
context: provenanceContext
|
|
3614
|
+
};
|
|
3615
|
+
const replayFingerprint = await this.hashDecision(provenance);
|
|
3616
|
+
return {
|
|
3617
|
+
tier,
|
|
3618
|
+
accepted,
|
|
3619
|
+
provenance,
|
|
3620
|
+
metrics,
|
|
3621
|
+
replayFingerprint
|
|
3622
|
+
};
|
|
3623
|
+
}
|
|
3624
|
+
async hashDecision(provenance) {
|
|
3625
|
+
const value = provenance.value;
|
|
3626
|
+
const canonical = stableStringify(value);
|
|
3627
|
+
return `sha256:${await sha256Hex(canonical)}`;
|
|
3628
|
+
}
|
|
3629
|
+
};
|
|
3630
|
+
function createTier3CpuDirectOutput(op) {
|
|
3631
|
+
return {
|
|
3632
|
+
trait: op.trait,
|
|
3633
|
+
nodeId: op.nodeId,
|
|
3634
|
+
config: op.config ?? {}
|
|
3635
|
+
};
|
|
3636
|
+
}
|
|
3637
|
+
async function runTier3CpuDirectExecutor(op) {
|
|
3638
|
+
const evaluator = new ExpressionEvaluator(op.config ?? {});
|
|
3639
|
+
const evaluatedConfig = {};
|
|
3640
|
+
for (const [key, value] of Object.entries(op.config ?? {})) {
|
|
3641
|
+
if (typeof value === "string") {
|
|
3642
|
+
evaluatedConfig[key] = evaluator.evaluate(value);
|
|
3643
|
+
} else {
|
|
3644
|
+
evaluatedConfig[key] = value;
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
return {
|
|
3648
|
+
trait: op.trait,
|
|
3649
|
+
nodeId: op.nodeId,
|
|
3650
|
+
config: evaluatedConfig
|
|
3651
|
+
};
|
|
3652
|
+
}
|
|
3653
|
+
async function runTier1BrowserSnn(op) {
|
|
3654
|
+
try {
|
|
3655
|
+
const snnWebgpu = await import('@holoscript/snn-webgpu');
|
|
3656
|
+
const { GPUContext, LIFSimulator, DEFAULT_LIF_PARAMS } = snnWebgpu;
|
|
3657
|
+
const ctx = new GPUContext();
|
|
3658
|
+
await ctx.initialize();
|
|
3659
|
+
const simulator = new LIFSimulator(ctx, 1, DEFAULT_LIF_PARAMS);
|
|
3660
|
+
await simulator.initialize();
|
|
3661
|
+
const input = stableStringify({ trait: op.trait, nodeId: op.nodeId, config: op.config });
|
|
3662
|
+
const steps = Math.max(1, Math.min(64, input.length));
|
|
3663
|
+
await simulator.stepN(steps);
|
|
3664
|
+
return { accepted: true, source: "snn-webgpu", steps };
|
|
3665
|
+
} catch (error) {
|
|
3666
|
+
return {
|
|
3667
|
+
accepted: false,
|
|
3668
|
+
source: "snn-webgpu",
|
|
3669
|
+
reason: normalizeTier1BrowserReason(error)
|
|
3670
|
+
};
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
function normalizeTier1BrowserReason(error) {
|
|
3674
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3675
|
+
if (message.includes("@holoscript/snn-webgpu") && message.includes("Cannot find package")) {
|
|
3676
|
+
return `WebGPU SNN runtime unavailable: ${message}`;
|
|
3677
|
+
}
|
|
3678
|
+
return message;
|
|
3679
|
+
}
|
|
3680
|
+
function detectWasmRuntime() {
|
|
3681
|
+
const runtime = globalThis;
|
|
3682
|
+
const validate = runtime.WebAssembly?.validate;
|
|
3683
|
+
if (typeof validate !== "function") {
|
|
3684
|
+
return {
|
|
3685
|
+
available: false,
|
|
3686
|
+
source: "global-webassembly",
|
|
3687
|
+
reason: "WebAssembly.validate is unavailable"
|
|
3688
|
+
};
|
|
3689
|
+
}
|
|
3690
|
+
const moduleValidated = validate(MINIMAL_WASM_MODULE);
|
|
3691
|
+
return {
|
|
3692
|
+
available: moduleValidated,
|
|
3693
|
+
source: "global-webassembly",
|
|
3694
|
+
moduleValidated,
|
|
3695
|
+
reason: moduleValidated ? void 0 : "Minimal WebAssembly module failed validation"
|
|
3696
|
+
};
|
|
3697
|
+
}
|
|
3698
|
+
function runCompilerWasmSnnEmulator(op, runtime) {
|
|
3699
|
+
if (!runtime.available) {
|
|
3700
|
+
return {
|
|
3701
|
+
accepted: false,
|
|
3702
|
+
source: "compiler-wasm-snn-emulator",
|
|
3703
|
+
runtime,
|
|
3704
|
+
reason: runtime.reason ?? "WebAssembly runtime unavailable"
|
|
3705
|
+
};
|
|
3706
|
+
}
|
|
3707
|
+
const input = stableStringify({
|
|
3708
|
+
trait: op.trait,
|
|
3709
|
+
nodeId: op.nodeId,
|
|
3710
|
+
config: op.config ?? {}
|
|
3711
|
+
});
|
|
3712
|
+
const steps = Math.max(1, Math.min(64, input.length));
|
|
3713
|
+
const state = emulateLifSteps(input, steps);
|
|
3714
|
+
return {
|
|
3715
|
+
accepted: true,
|
|
3716
|
+
source: "compiler-wasm-snn-emulator",
|
|
3717
|
+
runtime,
|
|
3718
|
+
steps,
|
|
3719
|
+
spikeCount: state.spikeCount,
|
|
3720
|
+
membranePotential: state.membranePotential,
|
|
3721
|
+
inputChecksum: state.inputChecksum
|
|
3722
|
+
};
|
|
3723
|
+
}
|
|
3724
|
+
async function defaultTraitEquivalenceOracle(input) {
|
|
3725
|
+
const proposalCanonical = stableStringify(input.proposal);
|
|
3726
|
+
const tier3Canonical = stableStringify(input.tier3Output);
|
|
3727
|
+
const equivalent = proposalCanonical === tier3Canonical;
|
|
3728
|
+
return {
|
|
3729
|
+
equivalent,
|
|
3730
|
+
source: "canonical-json",
|
|
3731
|
+
reason: equivalent ? "canonical outputs match" : "canonical outputs differ",
|
|
3732
|
+
score: equivalent ? 1 : 0,
|
|
3733
|
+
proposalFingerprint: `sha256:${await sha256Hex(proposalCanonical)}`,
|
|
3734
|
+
tier3Fingerprint: `sha256:${await sha256Hex(tier3Canonical)}`
|
|
3735
|
+
};
|
|
3736
|
+
}
|
|
3737
|
+
function stableStringify(value) {
|
|
3738
|
+
return JSON.stringify(canonicalize(value)) ?? "undefined";
|
|
3739
|
+
}
|
|
3740
|
+
function canonicalize(value) {
|
|
3741
|
+
if (Array.isArray(value)) {
|
|
3742
|
+
return value.map((entry) => canonicalize(entry));
|
|
3743
|
+
}
|
|
3744
|
+
if (!value || typeof value !== "object") {
|
|
3745
|
+
return value;
|
|
3746
|
+
}
|
|
3747
|
+
const record = value;
|
|
3748
|
+
const sorted = {};
|
|
3749
|
+
for (const key of Object.keys(record).sort()) {
|
|
3750
|
+
sorted[key] = canonicalize(record[key]);
|
|
3751
|
+
}
|
|
3752
|
+
return sorted;
|
|
3753
|
+
}
|
|
3754
|
+
async function sha256Hex(input) {
|
|
3755
|
+
const subtle = globalThis.crypto?.subtle;
|
|
3756
|
+
if (subtle) {
|
|
3757
|
+
const digest = await subtle.digest("SHA-256", new TextEncoder().encode(input));
|
|
3758
|
+
return bytesToHex(new Uint8Array(digest));
|
|
3759
|
+
}
|
|
3760
|
+
const { createHash } = await import('crypto');
|
|
3761
|
+
return createHash("sha256").update(input).digest("hex");
|
|
3762
|
+
}
|
|
3763
|
+
function bytesToHex(bytes) {
|
|
3764
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3765
|
+
}
|
|
3766
|
+
var MINIMAL_WASM_MODULE = new Uint8Array([
|
|
3767
|
+
0,
|
|
3768
|
+
97,
|
|
3769
|
+
115,
|
|
3770
|
+
109,
|
|
3771
|
+
1,
|
|
3772
|
+
0,
|
|
3773
|
+
0,
|
|
3774
|
+
0
|
|
3775
|
+
]);
|
|
3776
|
+
function emulateLifSteps(input, steps) {
|
|
3777
|
+
const vRest = -65;
|
|
3778
|
+
const vReset = -65;
|
|
3779
|
+
const vThreshold = -50;
|
|
3780
|
+
const tau = 12;
|
|
3781
|
+
let membranePotential = vRest;
|
|
3782
|
+
let spikeCount = 0;
|
|
3783
|
+
let inputChecksum = 2166136261;
|
|
3784
|
+
for (let i = 0; i < steps; i += 1) {
|
|
3785
|
+
const code = input.charCodeAt(i % input.length);
|
|
3786
|
+
inputChecksum ^= code;
|
|
3787
|
+
inputChecksum = Math.imul(inputChecksum, 16777619) >>> 0;
|
|
3788
|
+
const inputCurrent = 12 + code % 17;
|
|
3789
|
+
membranePotential += (vRest - membranePotential + inputCurrent) / tau;
|
|
3790
|
+
if (membranePotential >= vThreshold) {
|
|
3791
|
+
spikeCount += 1;
|
|
3792
|
+
membranePotential = vReset;
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
return {
|
|
3796
|
+
spikeCount,
|
|
3797
|
+
membranePotential: Number(membranePotential.toFixed(6)),
|
|
3798
|
+
inputChecksum
|
|
3799
|
+
};
|
|
3800
|
+
}
|
|
3801
|
+
function detectNeuromorphicRuntime(preferredDevice) {
|
|
3802
|
+
const globalDevices = readGlobalNeuromorphicDevices();
|
|
3803
|
+
const envDevices = readEnvNeuromorphicDevices();
|
|
3804
|
+
const devices = [...globalDevices, ...envDevices].filter((device) => device.available !== false).sort((a, b) => deviceRank(a.target) - deviceRank(b.target));
|
|
3805
|
+
const selected = preferredDevice ? devices.find((device) => device.target === preferredDevice) : devices[0];
|
|
3806
|
+
if (selected) {
|
|
3807
|
+
return {
|
|
3808
|
+
available: true,
|
|
3809
|
+
device: selected.target,
|
|
3810
|
+
source: selected.source ?? "runtime",
|
|
3811
|
+
devices
|
|
3812
|
+
};
|
|
3813
|
+
}
|
|
3814
|
+
return {
|
|
3815
|
+
available: false,
|
|
3816
|
+
source: devices.length ? "runtime" : "none",
|
|
3817
|
+
reason: preferredDevice ? `No ${preferredDevice} NIR runtime device discovered` : "No NIR runtime device discovered",
|
|
3818
|
+
devices
|
|
3819
|
+
};
|
|
3820
|
+
}
|
|
3821
|
+
function readGlobalNeuromorphicDevices() {
|
|
3822
|
+
const runtime = globalThis;
|
|
3823
|
+
return parseNeuromorphicDevices(runtime.__HOLOSCRIPT_NIR_DEVICES__, "global");
|
|
3824
|
+
}
|
|
3825
|
+
function readEnvNeuromorphicDevices() {
|
|
3826
|
+
const env = typeof process !== "undefined" ? process.env : void 0;
|
|
3827
|
+
if (!env) return [];
|
|
3828
|
+
const configured = parseNeuromorphicDevices(env.HOLOSCRIPT_NIR_DEVICE ?? env.NIR_DEVICE, "env");
|
|
3829
|
+
const detected = [...configured];
|
|
3830
|
+
if (env.LOIHI2_HOST) {
|
|
3831
|
+
detected.push({ target: "loihi", id: env.LOIHI2_HOST, available: true, source: "env" });
|
|
3832
|
+
}
|
|
3833
|
+
if (env.SPINNAKER_BOARD) {
|
|
3834
|
+
detected.push({ target: "spinnaker", id: env.SPINNAKER_BOARD, available: true, source: "env" });
|
|
3835
|
+
}
|
|
3836
|
+
if (env.SYNSENSE_DEVICE) {
|
|
3837
|
+
detected.push({ target: "synsense", id: env.SYNSENSE_DEVICE, available: true, source: "env" });
|
|
3838
|
+
}
|
|
3839
|
+
if (env.AKIDA_DEVICE) {
|
|
3840
|
+
detected.push({ target: "akida", id: env.AKIDA_DEVICE, available: true, source: "env" });
|
|
3841
|
+
}
|
|
3842
|
+
return detected;
|
|
3843
|
+
}
|
|
3844
|
+
function parseNeuromorphicDevices(value, source) {
|
|
3845
|
+
if (!value) return [];
|
|
3846
|
+
if (typeof value === "string") {
|
|
3847
|
+
return value.split(",").map((entry) => toNeuromorphicDevice(entry.trim(), source)).filter((device) => Boolean(device));
|
|
3848
|
+
}
|
|
3849
|
+
if (Array.isArray(value)) {
|
|
3850
|
+
return value.map((entry) => toNeuromorphicDevice(entry, source)).filter((device) => Boolean(device));
|
|
3851
|
+
}
|
|
3852
|
+
return [];
|
|
3853
|
+
}
|
|
3854
|
+
function toNeuromorphicDevice(value, source) {
|
|
3855
|
+
if (typeof value === "string") {
|
|
3856
|
+
const target2 = normalizeNeuromorphicTarget(value);
|
|
3857
|
+
return target2 ? { target: target2, available: true, source } : null;
|
|
3858
|
+
}
|
|
3859
|
+
if (!value || typeof value !== "object") return null;
|
|
3860
|
+
const record = value;
|
|
3861
|
+
const target = normalizeNeuromorphicTarget(record.target ?? record.device ?? record.kind);
|
|
3862
|
+
if (!target) return null;
|
|
3863
|
+
return {
|
|
3864
|
+
target,
|
|
3865
|
+
id: typeof record.id === "string" ? record.id : void 0,
|
|
3866
|
+
available: record.available === false ? false : true,
|
|
3867
|
+
source: typeof record.source === "string" ? record.source : source
|
|
3868
|
+
};
|
|
3869
|
+
}
|
|
3870
|
+
function normalizeNeuromorphicTarget(value) {
|
|
3871
|
+
if (typeof value !== "string") return null;
|
|
3872
|
+
const normalized = value.toLowerCase().replace(/[\s_-]+/g, "");
|
|
3873
|
+
if (normalized === "loihi" || normalized === "loihi2") return "loihi";
|
|
3874
|
+
if (normalized === "spinnaker" || normalized === "spinnaker2") return "spinnaker";
|
|
3875
|
+
if (normalized === "synsense" || normalized === "synsensespeck" || normalized === "synsensexylo") {
|
|
3876
|
+
return "synsense";
|
|
3877
|
+
}
|
|
3878
|
+
if (normalized === "akida") return "akida";
|
|
3879
|
+
return null;
|
|
3880
|
+
}
|
|
3881
|
+
function deviceRank(device) {
|
|
3882
|
+
return ["loihi", "spinnaker", "synsense", "akida"].indexOf(device);
|
|
3883
|
+
}
|
|
3884
|
+
|
|
3885
|
+
// src/compiler/dispatch/DispatchPolicyBenchmark.ts
|
|
3886
|
+
var DEFAULT_ITERATIONS = 100;
|
|
3887
|
+
var DEFAULT_WARMUP_ITERATIONS = 10;
|
|
3888
|
+
var DEFAULT_DISPATCH_LATENCY_OPERATION = {
|
|
3889
|
+
trait: "grabbable",
|
|
3890
|
+
nodeId: "dispatch-policy-latency-benchmark"
|
|
3891
|
+
};
|
|
3892
|
+
function createDefaultDispatchLatencyScenarios(options = {}) {
|
|
3893
|
+
const alphaWindowSize = (options.iterations ?? DEFAULT_ITERATIONS) + (options.warmupIterations ?? DEFAULT_WARMUP_ITERATIONS);
|
|
3894
|
+
return [
|
|
3895
|
+
{
|
|
3896
|
+
id: "tier-1-neuromorphic-synsense",
|
|
3897
|
+
tier: "tier-1-neuromorphic" /* TIER_1_NEUROMORPHIC */,
|
|
3898
|
+
config: {
|
|
3899
|
+
tier1NeuromorphicEnabled: true,
|
|
3900
|
+
tier1NeuromorphicDevice: "synsense",
|
|
3901
|
+
neuromorphicRuntimeProbe: async () => ({
|
|
3902
|
+
available: true,
|
|
3903
|
+
device: "synsense",
|
|
3904
|
+
source: "dispatch-latency-benchmark",
|
|
3905
|
+
devices: [{ target: "synsense", id: "benchmark-synsense", source: "benchmark" }]
|
|
3906
|
+
})
|
|
3907
|
+
}
|
|
3908
|
+
},
|
|
3909
|
+
{
|
|
3910
|
+
id: "tier-1-browser-webgpu",
|
|
3911
|
+
tier: "tier-1-browser" /* TIER_1_BROWSER */,
|
|
3912
|
+
config: {
|
|
3913
|
+
tier1BrowserEnabled: true
|
|
3914
|
+
}
|
|
3915
|
+
},
|
|
3916
|
+
{
|
|
3917
|
+
id: "tier-1-wasm-fallback",
|
|
3918
|
+
tier: "tier-1-wasm" /* TIER_1_WASM */,
|
|
3919
|
+
config: {
|
|
3920
|
+
tier1WasmEnabled: true
|
|
3921
|
+
}
|
|
3922
|
+
},
|
|
3923
|
+
{
|
|
3924
|
+
id: "tier-2-speculative",
|
|
3925
|
+
tier: "tier-2-speculative" /* TIER_2_SPECULATIVE */,
|
|
3926
|
+
config: {
|
|
3927
|
+
tier2Enabled: true,
|
|
3928
|
+
llmProposalProvider: (op) => createTier3CpuDirectOutput(op),
|
|
3929
|
+
tier2AlphaThreshold: 0,
|
|
3930
|
+
alphaWindowSize,
|
|
3931
|
+
effectVerifier: async () => ({ passed: true })
|
|
3932
|
+
}
|
|
3933
|
+
},
|
|
3934
|
+
{
|
|
3935
|
+
id: "tier-3-cpu-direct",
|
|
3936
|
+
tier: "tier-3-cpu-direct" /* TIER_3_CPU_DIRECT */,
|
|
3937
|
+
config: {
|
|
3938
|
+
tier1BrowserEnabled: false,
|
|
3939
|
+
tier1NeuromorphicEnabled: false,
|
|
3940
|
+
tier2Enabled: false
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
];
|
|
3944
|
+
}
|
|
3945
|
+
async function runDispatchPolicyLatencyBenchmark(options = {}) {
|
|
3946
|
+
const iterations = options.iterations ?? DEFAULT_ITERATIONS;
|
|
3947
|
+
const warmupIterations = options.warmupIterations ?? DEFAULT_WARMUP_ITERATIONS;
|
|
3948
|
+
const operation = options.operation ?? DEFAULT_DISPATCH_LATENCY_OPERATION;
|
|
3949
|
+
const scenarios = options.scenarios ?? createDefaultDispatchLatencyScenarios({ iterations, warmupIterations });
|
|
3950
|
+
const summaries = [];
|
|
3951
|
+
for (const scenario of scenarios) {
|
|
3952
|
+
const policy = new DispatchPolicy(scenario.config);
|
|
3953
|
+
const scenarioOperation = scenario.operation ?? operation;
|
|
3954
|
+
for (let i = 0; i < warmupIterations; i += 1) {
|
|
3955
|
+
await policy.route(scenarioOperation);
|
|
3956
|
+
}
|
|
3957
|
+
const samples = [];
|
|
3958
|
+
for (let i = 0; i < iterations; i += 1) {
|
|
3959
|
+
samples.push(await measureDispatchSample(policy, scenario, scenarioOperation, i, options.now));
|
|
3960
|
+
}
|
|
3961
|
+
summaries.push(summarizeDispatchSamples(scenario, samples));
|
|
3962
|
+
}
|
|
3963
|
+
return {
|
|
3964
|
+
operationTrait: operation.trait,
|
|
3965
|
+
iterations,
|
|
3966
|
+
warmupIterations,
|
|
3967
|
+
summaries,
|
|
3968
|
+
recommendation: recommendDispatchPolicyDefaults(summaries)
|
|
3969
|
+
};
|
|
3970
|
+
}
|
|
3971
|
+
function recommendDispatchPolicyDefaults(summaries) {
|
|
3972
|
+
const tier2 = summaries.find((summary) => summary.requestedTier === "tier-2-speculative" /* TIER_2_SPECULATIVE */);
|
|
3973
|
+
const tier3 = summaries.find((summary) => summary.requestedTier === "tier-3-cpu-direct" /* TIER_3_CPU_DIRECT */);
|
|
3974
|
+
if (!tier2) {
|
|
3975
|
+
return {
|
|
3976
|
+
tier2DefaultEnabled: false,
|
|
3977
|
+
reason: "Tier 2 benchmark summary missing; keep speculative dispatch disabled by default."
|
|
3978
|
+
};
|
|
3979
|
+
}
|
|
3980
|
+
if (!tier3) {
|
|
3981
|
+
return {
|
|
3982
|
+
tier2DefaultEnabled: false,
|
|
3983
|
+
reason: "Tier 3 CPU-direct baseline missing; keep speculative dispatch disabled by default."
|
|
3984
|
+
};
|
|
3985
|
+
}
|
|
3986
|
+
const tier2Comparable = tier2.acceptedSamples > 0;
|
|
3987
|
+
const tier3Comparable = tier3.acceptedSamples > 0;
|
|
3988
|
+
if (!tier2Comparable || !tier3Comparable) {
|
|
3989
|
+
return {
|
|
3990
|
+
tier2DefaultEnabled: false,
|
|
3991
|
+
reason: "Tier 2 or Tier 3 did not accept benchmark samples; keep speculative dispatch disabled by default.",
|
|
3992
|
+
tier2MeanLatencyMs: tier2.meanLatencyMs,
|
|
3993
|
+
tier3MeanLatencyMs: tier3.meanLatencyMs,
|
|
3994
|
+
tier2P95LatencyMs: tier2.p95LatencyMs,
|
|
3995
|
+
tier3P95LatencyMs: tier3.p95LatencyMs
|
|
3996
|
+
};
|
|
3997
|
+
}
|
|
3998
|
+
const tier2Faster = tier2.meanLatencyMs < tier3.meanLatencyMs && tier2.p95LatencyMs < tier3.p95LatencyMs;
|
|
3999
|
+
if (!tier2Faster) {
|
|
4000
|
+
return {
|
|
4001
|
+
tier2DefaultEnabled: false,
|
|
4002
|
+
reason: "Tier 2 speculative dispatch is not faster than Tier 3 CPU direct on mean and p95 latency; keep Tier 2 disabled by default.",
|
|
4003
|
+
tier2MeanLatencyMs: tier2.meanLatencyMs,
|
|
4004
|
+
tier3MeanLatencyMs: tier3.meanLatencyMs,
|
|
4005
|
+
tier2P95LatencyMs: tier2.p95LatencyMs,
|
|
4006
|
+
tier3P95LatencyMs: tier3.p95LatencyMs
|
|
4007
|
+
};
|
|
4008
|
+
}
|
|
4009
|
+
return {
|
|
4010
|
+
tier2DefaultEnabled: true,
|
|
4011
|
+
reason: "Tier 2 speculative dispatch beat Tier 3 CPU direct on mean and p95 latency.",
|
|
4012
|
+
tier2MeanLatencyMs: tier2.meanLatencyMs,
|
|
4013
|
+
tier3MeanLatencyMs: tier3.meanLatencyMs,
|
|
4014
|
+
tier2P95LatencyMs: tier2.p95LatencyMs,
|
|
4015
|
+
tier3P95LatencyMs: tier3.p95LatencyMs
|
|
4016
|
+
};
|
|
4017
|
+
}
|
|
4018
|
+
function formatDispatchLatencyBenchmarkReport(report) {
|
|
4019
|
+
const lines = [
|
|
4020
|
+
`DispatchPolicy @${report.operationTrait} latency benchmark`,
|
|
4021
|
+
`iterations=${report.iterations} warmup=${report.warmupIterations}`,
|
|
4022
|
+
"",
|
|
4023
|
+
"requested tier | accepted samples | mean ms | p50 ms | p95 ms | max ms | accepted tiers"
|
|
4024
|
+
];
|
|
4025
|
+
for (const summary of report.summaries) {
|
|
4026
|
+
lines.push(
|
|
4027
|
+
[
|
|
4028
|
+
summary.requestedTier,
|
|
4029
|
+
`${summary.acceptedSamples}/${summary.samples}`,
|
|
4030
|
+
formatMs(summary.meanLatencyMs),
|
|
4031
|
+
formatMs(summary.p50LatencyMs),
|
|
4032
|
+
formatMs(summary.p95LatencyMs),
|
|
4033
|
+
formatMs(summary.maxLatencyMs),
|
|
4034
|
+
formatTierCounts(summary.acceptedTierCounts)
|
|
4035
|
+
].join(" | ")
|
|
4036
|
+
);
|
|
4037
|
+
}
|
|
4038
|
+
lines.push("");
|
|
4039
|
+
lines.push(
|
|
4040
|
+
`Tier 2 default: ${report.recommendation.tier2DefaultEnabled ? "enabled" : "disabled"}`
|
|
4041
|
+
);
|
|
4042
|
+
lines.push(report.recommendation.reason);
|
|
4043
|
+
return lines.join("\n");
|
|
4044
|
+
}
|
|
4045
|
+
async function measureDispatchSample(policy, scenario, operation, iteration, now) {
|
|
4046
|
+
const clock = now ?? (() => performance.now());
|
|
4047
|
+
const started = clock();
|
|
4048
|
+
const decision = await policy.route(operation);
|
|
4049
|
+
const latencyMs = Math.max(0, clock() - started);
|
|
4050
|
+
return toLatencySample(iteration, scenario.tier, decision, latencyMs);
|
|
4051
|
+
}
|
|
4052
|
+
function toLatencySample(iteration, requestedTier, decision, latencyMs) {
|
|
4053
|
+
return {
|
|
4054
|
+
iteration,
|
|
4055
|
+
requestedTier,
|
|
4056
|
+
acceptedTier: decision.tier,
|
|
4057
|
+
accepted: decision.accepted,
|
|
4058
|
+
latencyMs,
|
|
4059
|
+
decisionLatencyMs: decision.metrics.latencyEstimateMs,
|
|
4060
|
+
fallbackReason: decision.metrics.fallbackReason,
|
|
4061
|
+
alpha: decision.metrics.alpha,
|
|
4062
|
+
replayFingerprint: decision.replayFingerprint
|
|
4063
|
+
};
|
|
4064
|
+
}
|
|
4065
|
+
function summarizeDispatchSamples(scenario, samples) {
|
|
4066
|
+
const latencies = samples.map((sample) => sample.latencyMs).sort((a, b) => a - b);
|
|
4067
|
+
const acceptedTierCounts = {};
|
|
4068
|
+
const fallbackReasons = {};
|
|
4069
|
+
let acceptedSamples = 0;
|
|
4070
|
+
for (const sample of samples) {
|
|
4071
|
+
acceptedTierCounts[sample.acceptedTier] = (acceptedTierCounts[sample.acceptedTier] ?? 0) + 1;
|
|
4072
|
+
if (sample.accepted) acceptedSamples += 1;
|
|
4073
|
+
if (sample.fallbackReason) {
|
|
4074
|
+
fallbackReasons[sample.fallbackReason] = (fallbackReasons[sample.fallbackReason] ?? 0) + 1;
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
return {
|
|
4078
|
+
id: scenario.id,
|
|
4079
|
+
requestedTier: scenario.tier,
|
|
4080
|
+
samples: samples.length,
|
|
4081
|
+
acceptedSamples,
|
|
4082
|
+
acceptedTierCounts,
|
|
4083
|
+
fallbackReasons,
|
|
4084
|
+
minLatencyMs: latencies[0] ?? 0,
|
|
4085
|
+
meanLatencyMs: mean(latencies),
|
|
4086
|
+
p50LatencyMs: percentile(latencies, 0.5),
|
|
4087
|
+
p95LatencyMs: percentile(latencies, 0.95),
|
|
4088
|
+
maxLatencyMs: latencies[latencies.length - 1] ?? 0
|
|
4089
|
+
};
|
|
4090
|
+
}
|
|
4091
|
+
function mean(values) {
|
|
4092
|
+
if (values.length === 0) return 0;
|
|
4093
|
+
return values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
4094
|
+
}
|
|
4095
|
+
function percentile(sortedValues, percentileValue) {
|
|
4096
|
+
if (sortedValues.length === 0) return 0;
|
|
4097
|
+
const index = Math.min(
|
|
4098
|
+
sortedValues.length - 1,
|
|
4099
|
+
Math.max(0, Math.ceil(sortedValues.length * percentileValue) - 1)
|
|
4100
|
+
);
|
|
4101
|
+
return sortedValues[index] ?? 0;
|
|
4102
|
+
}
|
|
4103
|
+
function formatMs(value) {
|
|
4104
|
+
return value.toFixed(3);
|
|
4105
|
+
}
|
|
4106
|
+
function formatTierCounts(counts) {
|
|
4107
|
+
return Object.entries(counts).map(([tier, count]) => `${tier}:${count}`).join(",");
|
|
4108
|
+
}
|
|
4109
|
+
|
|
4110
|
+
// src/compiler/MatterpakCompiler.ts
|
|
4111
|
+
init_CompilerBase();
|
|
4112
|
+
function parseOBJExtended(text) {
|
|
4113
|
+
const allVertices = [];
|
|
4114
|
+
const allNormals = [];
|
|
4115
|
+
const allUVs = [];
|
|
4116
|
+
const groups = [];
|
|
4117
|
+
let currentGroup = null;
|
|
4118
|
+
let currentMaterial;
|
|
4119
|
+
function flushGroup() {
|
|
4120
|
+
if (currentGroup && (currentGroup.triangles.length > 0 || currentGroup.vertices.length > 0)) {
|
|
4121
|
+
groups.push(currentGroup);
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
function startGroup(name) {
|
|
4125
|
+
flushGroup();
|
|
4126
|
+
currentGroup = {
|
|
4127
|
+
name,
|
|
4128
|
+
vertices: new Float64Array(0),
|
|
4129
|
+
normals: new Float64Array(0),
|
|
4130
|
+
uvs: new Float64Array(0),
|
|
4131
|
+
triangles: new Uint32Array(0),
|
|
4132
|
+
materialName: currentMaterial
|
|
4133
|
+
};
|
|
4134
|
+
}
|
|
4135
|
+
const lines = text.split("\n");
|
|
4136
|
+
for (let i = 0; i < lines.length; i++) {
|
|
4137
|
+
const line = lines[i].trim();
|
|
4138
|
+
if (line.length === 0 || line.startsWith("#")) continue;
|
|
4139
|
+
const parts = line.split(/\s+/);
|
|
4140
|
+
const cmd = parts[0];
|
|
4141
|
+
if (cmd === "v" && parts.length >= 4) {
|
|
4142
|
+
allVertices.push(
|
|
4143
|
+
parseFloat(parts[1]),
|
|
4144
|
+
parseFloat(parts[2]),
|
|
4145
|
+
parseFloat(parts[3])
|
|
4146
|
+
);
|
|
4147
|
+
} else if (cmd === "vn" && parts.length >= 4) {
|
|
4148
|
+
allNormals.push(
|
|
4149
|
+
parseFloat(parts[1]),
|
|
4150
|
+
parseFloat(parts[2]),
|
|
4151
|
+
parseFloat(parts[3])
|
|
4152
|
+
);
|
|
4153
|
+
} else if (cmd === "vt" && parts.length >= 3) {
|
|
4154
|
+
allUVs.push(
|
|
4155
|
+
parseFloat(parts[1]),
|
|
4156
|
+
parseFloat(parts[2])
|
|
4157
|
+
);
|
|
4158
|
+
} else if (cmd === "g" || cmd === "o") {
|
|
4159
|
+
const name = parts.slice(1).join(" ") || `group_${groups.length}`;
|
|
4160
|
+
startGroup(name);
|
|
4161
|
+
} else if (cmd === "usemtl" && parts.length >= 2) {
|
|
4162
|
+
currentMaterial = parts[1];
|
|
4163
|
+
const grp = currentGroup;
|
|
4164
|
+
if (grp !== null) {
|
|
4165
|
+
grp.materialName = currentMaterial;
|
|
4166
|
+
}
|
|
4167
|
+
} else if (cmd === "f" && parts.length >= 4) {
|
|
4168
|
+
if (!currentGroup) {
|
|
4169
|
+
startGroup("default");
|
|
4170
|
+
}
|
|
4171
|
+
const indices = parts.slice(1).map((p) => {
|
|
4172
|
+
const vStr = p.split("/")[0];
|
|
4173
|
+
const vIdx = parseInt(vStr, 10);
|
|
4174
|
+
return vIdx > 0 ? vIdx - 1 : allVertices.length / 3 + vIdx;
|
|
4175
|
+
});
|
|
4176
|
+
for (let t = 1; t < indices.length - 1; t++) {
|
|
4177
|
+
currentGroup.triangles = appendTri(currentGroup.triangles, indices[0], indices[t], indices[t + 1]);
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4181
|
+
flushGroup();
|
|
4182
|
+
for (const g of groups) {
|
|
4183
|
+
const usedVerts = /* @__PURE__ */ new Set();
|
|
4184
|
+
for (let i = 0; i < g.triangles.length; i++) {
|
|
4185
|
+
usedVerts.add(g.triangles[i]);
|
|
4186
|
+
}
|
|
4187
|
+
const remap = /* @__PURE__ */ new Map();
|
|
4188
|
+
let next = 0;
|
|
4189
|
+
const verts = [];
|
|
4190
|
+
for (const idx of usedVerts) {
|
|
4191
|
+
remap.set(idx, next++);
|
|
4192
|
+
verts.push(
|
|
4193
|
+
allVertices[idx * 3],
|
|
4194
|
+
allVertices[idx * 3 + 1],
|
|
4195
|
+
allVertices[idx * 3 + 2]
|
|
4196
|
+
);
|
|
4197
|
+
}
|
|
4198
|
+
g.vertices = new Float64Array(verts);
|
|
4199
|
+
for (let i = 0; i < g.triangles.length; i++) {
|
|
4200
|
+
g.triangles[i] = remap.get(g.triangles[i]);
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
return groups.length > 0 ? groups : [{
|
|
4204
|
+
name: "default",
|
|
4205
|
+
vertices: new Float64Array(allVertices),
|
|
4206
|
+
normals: new Float64Array(allNormals),
|
|
4207
|
+
uvs: new Float64Array(allUVs),
|
|
4208
|
+
triangles: new Uint32Array(0),
|
|
4209
|
+
materialName: currentMaterial
|
|
4210
|
+
}];
|
|
4211
|
+
}
|
|
4212
|
+
function appendTri(arr, a, b, c) {
|
|
4213
|
+
const next = new Uint32Array(arr.length + 3);
|
|
4214
|
+
next.set(arr);
|
|
4215
|
+
next[arr.length] = a;
|
|
4216
|
+
next[arr.length + 1] = b;
|
|
4217
|
+
next[arr.length + 2] = c;
|
|
4218
|
+
return next;
|
|
4219
|
+
}
|
|
4220
|
+
function parseMTL(text) {
|
|
4221
|
+
const materials = /* @__PURE__ */ new Map();
|
|
4222
|
+
let current = null;
|
|
4223
|
+
const lines = text.split("\n");
|
|
4224
|
+
for (const raw of lines) {
|
|
4225
|
+
const line = raw.trim();
|
|
4226
|
+
if (line.length === 0 || line.startsWith("#")) continue;
|
|
4227
|
+
const parts = line.split(/\s+/);
|
|
4228
|
+
const cmd = parts[0];
|
|
4229
|
+
if (cmd === "newmtl" && parts.length >= 2) {
|
|
4230
|
+
current = parts[1];
|
|
4231
|
+
materials.set(current, {
|
|
4232
|
+
baseColor: [0.8, 0.8, 0.8],
|
|
4233
|
+
metallic: 0,
|
|
4234
|
+
roughness: 0.5
|
|
4235
|
+
});
|
|
4236
|
+
} else if (current) {
|
|
4237
|
+
const mat = materials.get(current);
|
|
4238
|
+
if (cmd === "Kd" && parts.length >= 4) {
|
|
4239
|
+
mat.baseColor = [
|
|
4240
|
+
parseFloat(parts[1]),
|
|
4241
|
+
parseFloat(parts[2]),
|
|
4242
|
+
parseFloat(parts[3])
|
|
4243
|
+
];
|
|
4244
|
+
} else if (cmd === "map_Kd" && parts.length >= 2) {
|
|
4245
|
+
mat.textureMap = parts.slice(1).join(" ");
|
|
4246
|
+
} else if (cmd === "map_Bump" && parts.length >= 2) {
|
|
4247
|
+
mat.normalMap = parts.slice(1).join(" ");
|
|
4248
|
+
}
|
|
4249
|
+
if (cmd === "Ns" && parts.length >= 2) {
|
|
4250
|
+
const ns = parseFloat(parts[1]);
|
|
4251
|
+
mat.roughness = Math.max(0, 1 - ns / 1e3);
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
}
|
|
4255
|
+
return { materials };
|
|
4256
|
+
}
|
|
4257
|
+
function parseXYZ(text) {
|
|
4258
|
+
const points = [];
|
|
4259
|
+
const colors = [];
|
|
4260
|
+
let hasColor = true;
|
|
4261
|
+
const lines = text.split("\n");
|
|
4262
|
+
for (const raw of lines) {
|
|
4263
|
+
const line = raw.trim();
|
|
4264
|
+
if (line.length === 0 || line.startsWith("#")) continue;
|
|
4265
|
+
const parts = line.split(/\s+/);
|
|
4266
|
+
if (parts.length < 3) continue;
|
|
4267
|
+
points.push(
|
|
4268
|
+
parseFloat(parts[0]),
|
|
4269
|
+
parseFloat(parts[1]),
|
|
4270
|
+
parseFloat(parts[2])
|
|
4271
|
+
);
|
|
4272
|
+
if (parts.length >= 6) {
|
|
4273
|
+
colors.push(
|
|
4274
|
+
parseInt(parts[3], 10),
|
|
4275
|
+
parseInt(parts[4], 10),
|
|
4276
|
+
parseInt(parts[5], 10)
|
|
4277
|
+
);
|
|
4278
|
+
} else {
|
|
4279
|
+
hasColor = false;
|
|
4280
|
+
}
|
|
4281
|
+
}
|
|
4282
|
+
return {
|
|
4283
|
+
points: new Float64Array(points),
|
|
4284
|
+
colors: hasColor ? new Uint8Array(colors) : void 0,
|
|
4285
|
+
count: points.length / 3
|
|
4286
|
+
};
|
|
4287
|
+
}
|
|
4288
|
+
function parseE57(buffer) {
|
|
4289
|
+
const view = new DataView(buffer);
|
|
4290
|
+
const bytes = new Uint8Array(buffer);
|
|
4291
|
+
const text = new TextDecoder().decode(bytes.slice(0, Math.min(1024, buffer.byteLength)));
|
|
4292
|
+
if (!text.includes("e57")) {
|
|
4293
|
+
return { points: new Float64Array(0), count: 0 };
|
|
4294
|
+
}
|
|
4295
|
+
const points = [];
|
|
4296
|
+
const len = Math.min(buffer.byteLength, 5e7);
|
|
4297
|
+
for (let off = 0; off <= len - 24; off += 8) {
|
|
4298
|
+
const x = view.getFloat64(off, true);
|
|
4299
|
+
const y = view.getFloat64(off + 8, true);
|
|
4300
|
+
const z = view.getFloat64(off + 16, true);
|
|
4301
|
+
if (isFinite(x) && isFinite(y) && isFinite(z) && Math.abs(x) < 1e6 && Math.abs(y) < 1e6 && Math.abs(z) < 1e6 && (x !== 0 || y !== 0 || z !== 0)) {
|
|
4302
|
+
points.push(x, y, z);
|
|
4303
|
+
off += 16;
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
4306
|
+
return {
|
|
4307
|
+
points: new Float64Array(points),
|
|
4308
|
+
count: points.length / 3
|
|
4309
|
+
};
|
|
4310
|
+
}
|
|
4311
|
+
var MatterpakCompiler = class extends CompilerBase {
|
|
4312
|
+
constructor(options = {}) {
|
|
4313
|
+
super();
|
|
4314
|
+
this.compilerName = "matterpak";
|
|
4315
|
+
this.version = "1.0.0";
|
|
4316
|
+
this.options = {
|
|
4317
|
+
scale: 1,
|
|
4318
|
+
rotationY: 0,
|
|
4319
|
+
centerOrigin: true,
|
|
4320
|
+
groupAsRooms: true,
|
|
4321
|
+
pointCloudAsParticles: true,
|
|
4322
|
+
maxPointsPerSystem: 1e5,
|
|
4323
|
+
downsampleLargeClouds: true,
|
|
4324
|
+
...options
|
|
4325
|
+
};
|
|
4326
|
+
}
|
|
4327
|
+
/**
|
|
4328
|
+
* Satisfy CompilerBase abstract method — MatterpakCompiler is a format-ingest
|
|
4329
|
+
* compiler (bundle → HoloComposition) rather than a target compiler
|
|
4330
|
+
* (HoloComposition → output). Use compileBundle() for ingestion.
|
|
4331
|
+
*/
|
|
4332
|
+
compile(..._args) {
|
|
4333
|
+
throw new Error(
|
|
4334
|
+
"MatterpakCompiler.compile() is not supported. Use compileBundle(bundle: MatterpakBundle) to ingest a Matterpak bundle into a HoloComposition AST."
|
|
4335
|
+
);
|
|
4336
|
+
}
|
|
4337
|
+
/**
|
|
4338
|
+
* Compile a Matterpak bundle into a HoloComposition AST.
|
|
4339
|
+
*/
|
|
4340
|
+
compileBundle(bundle) {
|
|
4341
|
+
const warnings = [];
|
|
4342
|
+
const errors = [];
|
|
4343
|
+
const stats = {
|
|
4344
|
+
meshGroups: 0,
|
|
4345
|
+
vertices: 0,
|
|
4346
|
+
triangles: 0,
|
|
4347
|
+
pointCount: 0,
|
|
4348
|
+
materials: 0,
|
|
4349
|
+
rooms: 0
|
|
4350
|
+
};
|
|
4351
|
+
const objGroups = parseOBJExtended(bundle.obj);
|
|
4352
|
+
stats.meshGroups = objGroups.length;
|
|
4353
|
+
stats.vertices = objGroups.reduce((sum, g) => sum + g.vertices.length / 3, 0);
|
|
4354
|
+
stats.triangles = objGroups.reduce((sum, g) => sum + g.triangles.length / 3, 0);
|
|
4355
|
+
const mtl = bundle.mtl ? parseMTL(bundle.mtl) : { materials: /* @__PURE__ */ new Map() };
|
|
4356
|
+
stats.materials = mtl.materials.size;
|
|
4357
|
+
let xyzCloud;
|
|
4358
|
+
let e57Cloud;
|
|
4359
|
+
if (bundle.xyz) {
|
|
4360
|
+
xyzCloud = parseXYZ(bundle.xyz);
|
|
4361
|
+
stats.pointCount += xyzCloud.count;
|
|
4362
|
+
}
|
|
4363
|
+
if (bundle.e57) {
|
|
4364
|
+
e57Cloud = parseE57(bundle.e57);
|
|
4365
|
+
if (e57Cloud.count > 0) {
|
|
4366
|
+
stats.pointCount += e57Cloud.count;
|
|
4367
|
+
} else {
|
|
4368
|
+
warnings.push("E57 parsing produced zero points (header-only or unsupported format variant)");
|
|
4369
|
+
}
|
|
4370
|
+
}
|
|
4371
|
+
const objects = [];
|
|
4372
|
+
const spatialGroups = [];
|
|
4373
|
+
const lights = [];
|
|
4374
|
+
let minX = Infinity, minY = Infinity, minZ = Infinity;
|
|
4375
|
+
let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
|
4376
|
+
for (const g of objGroups) {
|
|
4377
|
+
for (let i = 0; i < g.vertices.length; i += 3) {
|
|
4378
|
+
const x = g.vertices[i];
|
|
4379
|
+
const y = g.vertices[i + 1];
|
|
4380
|
+
const z = g.vertices[i + 2];
|
|
4381
|
+
if (x < minX) minX = x;
|
|
4382
|
+
if (x > maxX) maxX = x;
|
|
4383
|
+
if (y < minY) minY = y;
|
|
4384
|
+
if (y > maxY) maxY = y;
|
|
4385
|
+
if (z < minZ) minZ = z;
|
|
4386
|
+
if (z > maxZ) maxZ = z;
|
|
4387
|
+
}
|
|
4388
|
+
}
|
|
4389
|
+
const cx = (minX + maxX) / 2;
|
|
4390
|
+
const cy = minY;
|
|
4391
|
+
const cz = (minZ + maxZ) / 2;
|
|
4392
|
+
const scale = this.options.scale ?? 1;
|
|
4393
|
+
const rotY = this.options.rotationY ?? 0;
|
|
4394
|
+
if (this.options.groupAsRooms) {
|
|
4395
|
+
for (const g of objGroups) {
|
|
4396
|
+
const traits = [];
|
|
4397
|
+
const matName = g.materialName;
|
|
4398
|
+
if (matName && mtl.materials.has(matName)) {
|
|
4399
|
+
const mat = mtl.materials.get(matName);
|
|
4400
|
+
const matConfig = {
|
|
4401
|
+
baseColor: mat.baseColor,
|
|
4402
|
+
metallic: mat.metallic,
|
|
4403
|
+
roughness: mat.roughness
|
|
4404
|
+
};
|
|
4405
|
+
if (mat.textureMap !== void 0) matConfig.textureMap = mat.textureMap;
|
|
4406
|
+
if (mat.normalMap !== void 0) matConfig.normalMap = mat.normalMap;
|
|
4407
|
+
traits.push({
|
|
4408
|
+
type: "ObjectTrait",
|
|
4409
|
+
name: "material",
|
|
4410
|
+
config: matConfig
|
|
4411
|
+
});
|
|
4412
|
+
}
|
|
4413
|
+
traits.push({
|
|
4414
|
+
type: "ObjectTrait",
|
|
4415
|
+
name: "geometry",
|
|
4416
|
+
config: {
|
|
4417
|
+
primitive: "mesh",
|
|
4418
|
+
vertices: Array.from(g.vertices),
|
|
4419
|
+
indices: Array.from(g.triangles)
|
|
4420
|
+
}
|
|
4421
|
+
});
|
|
4422
|
+
let gx = 0, gy = 0, gz = 0;
|
|
4423
|
+
for (let i = 0; i < g.vertices.length; i += 3) {
|
|
4424
|
+
gx += g.vertices[i];
|
|
4425
|
+
gy += g.vertices[i + 1];
|
|
4426
|
+
gz += g.vertices[i + 2];
|
|
4427
|
+
}
|
|
4428
|
+
const vc = g.vertices.length / 3;
|
|
4429
|
+
gx /= vc;
|
|
4430
|
+
gy /= vc;
|
|
4431
|
+
gz /= vc;
|
|
4432
|
+
const obj = {
|
|
4433
|
+
type: "ObjectDecl",
|
|
4434
|
+
id: `obj_${g.name}`,
|
|
4435
|
+
name: g.name,
|
|
4436
|
+
properties: [],
|
|
4437
|
+
position: {
|
|
4438
|
+
x: (gx - cx) * scale,
|
|
4439
|
+
y: (gy - cy) * scale,
|
|
4440
|
+
z: (gz - cz) * scale
|
|
4441
|
+
},
|
|
4442
|
+
scale: { x: scale, y: scale, z: scale },
|
|
4443
|
+
rotation: { x: 0, y: rotY, z: 0 },
|
|
4444
|
+
traits
|
|
4445
|
+
};
|
|
4446
|
+
objects.push(obj);
|
|
4447
|
+
spatialGroups.push({
|
|
4448
|
+
type: "SpatialGroup",
|
|
4449
|
+
id: `room_${g.name}`,
|
|
4450
|
+
name: g.name,
|
|
4451
|
+
properties: [],
|
|
4452
|
+
objects: [obj]
|
|
4453
|
+
});
|
|
4454
|
+
}
|
|
4455
|
+
stats.rooms = spatialGroups.length;
|
|
4456
|
+
} else {
|
|
4457
|
+
for (const g of objGroups) {
|
|
4458
|
+
const traits = [{
|
|
4459
|
+
type: "ObjectTrait",
|
|
4460
|
+
name: "geometry",
|
|
4461
|
+
config: {
|
|
4462
|
+
primitive: "mesh",
|
|
4463
|
+
vertices: Array.from(g.vertices),
|
|
4464
|
+
indices: Array.from(g.triangles)
|
|
4465
|
+
}
|
|
4466
|
+
}];
|
|
4467
|
+
const matName = g.materialName;
|
|
4468
|
+
if (matName && mtl.materials.has(matName)) {
|
|
4469
|
+
const mat = mtl.materials.get(matName);
|
|
4470
|
+
const matConfig = {
|
|
4471
|
+
baseColor: mat.baseColor,
|
|
4472
|
+
metallic: mat.metallic,
|
|
4473
|
+
roughness: mat.roughness
|
|
4474
|
+
};
|
|
4475
|
+
if (mat.textureMap !== void 0) matConfig.textureMap = mat.textureMap;
|
|
4476
|
+
if (mat.normalMap !== void 0) matConfig.normalMap = mat.normalMap;
|
|
4477
|
+
traits.push({
|
|
4478
|
+
type: "ObjectTrait",
|
|
4479
|
+
name: "material",
|
|
4480
|
+
config: matConfig
|
|
4481
|
+
});
|
|
4482
|
+
}
|
|
4483
|
+
objects.push({
|
|
4484
|
+
type: "ObjectDecl",
|
|
4485
|
+
id: `obj_${g.name}`,
|
|
4486
|
+
name: g.name,
|
|
4487
|
+
properties: [],
|
|
4488
|
+
position: { x: 0, y: 0, z: 0 },
|
|
4489
|
+
scale: { x: scale, y: scale, z: scale },
|
|
4490
|
+
rotation: { x: 0, y: rotY, z: 0 },
|
|
4491
|
+
traits
|
|
4492
|
+
});
|
|
4493
|
+
}
|
|
4494
|
+
spatialGroups.push({
|
|
4495
|
+
type: "SpatialGroup",
|
|
4496
|
+
id: "room_all",
|
|
4497
|
+
name: "Full Property",
|
|
4498
|
+
properties: [],
|
|
4499
|
+
objects: [...objects]
|
|
4500
|
+
});
|
|
4501
|
+
stats.rooms = 1;
|
|
4502
|
+
}
|
|
4503
|
+
const pointClouds = [];
|
|
4504
|
+
if (xyzCloud && xyzCloud.count > 0) pointClouds.push(xyzCloud);
|
|
4505
|
+
if (e57Cloud && e57Cloud.count > 0) pointClouds.push(e57Cloud);
|
|
4506
|
+
if (this.options.pointCloudAsParticles && pointClouds.length > 0) {
|
|
4507
|
+
let systemIndex = 0;
|
|
4508
|
+
for (const pc of pointClouds) {
|
|
4509
|
+
const maxPts = this.options.maxPointsPerSystem ?? 1e5;
|
|
4510
|
+
let stride = 1;
|
|
4511
|
+
if (this.options.downsampleLargeClouds && pc.count > maxPts) {
|
|
4512
|
+
stride = Math.ceil(pc.count / maxPts);
|
|
4513
|
+
}
|
|
4514
|
+
const particles = [];
|
|
4515
|
+
const particleColors = [];
|
|
4516
|
+
for (let i = 0; i < pc.count; i += stride) {
|
|
4517
|
+
const x = pc.points[i * 3];
|
|
4518
|
+
const y = pc.points[i * 3 + 1];
|
|
4519
|
+
const z = pc.points[i * 3 + 2];
|
|
4520
|
+
particles.push(
|
|
4521
|
+
(x - cx) * scale,
|
|
4522
|
+
(y - cy) * scale,
|
|
4523
|
+
(z - cz) * scale
|
|
4524
|
+
);
|
|
4525
|
+
if (pc.colors) {
|
|
4526
|
+
particleColors.push(
|
|
4527
|
+
pc.colors[i * 3] / 255,
|
|
4528
|
+
pc.colors[i * 3 + 1] / 255,
|
|
4529
|
+
pc.colors[i * 3 + 2] / 255
|
|
4530
|
+
);
|
|
4531
|
+
}
|
|
4532
|
+
}
|
|
4533
|
+
objects.push({
|
|
4534
|
+
type: "ObjectDecl",
|
|
4535
|
+
id: `pointcloud_${systemIndex}`,
|
|
4536
|
+
name: `Point Cloud ${systemIndex}`,
|
|
4537
|
+
properties: [],
|
|
4538
|
+
position: { x: 0, y: 0, z: 0 },
|
|
4539
|
+
scale: { x: 1, y: 1, z: 1 },
|
|
4540
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
4541
|
+
traits: [{
|
|
4542
|
+
type: "ObjectTrait",
|
|
4543
|
+
name: "particleSystem",
|
|
4544
|
+
config: {
|
|
4545
|
+
count: particles.length / 3,
|
|
4546
|
+
positions: particles,
|
|
4547
|
+
...particleColors.length > 0 ? { colors: particleColors } : {},
|
|
4548
|
+
size: 0.02 * scale,
|
|
4549
|
+
billboard: true
|
|
4550
|
+
}
|
|
4551
|
+
}]
|
|
4552
|
+
});
|
|
4553
|
+
systemIndex++;
|
|
4554
|
+
}
|
|
4555
|
+
}
|
|
4556
|
+
const camera = {
|
|
4557
|
+
type: "Camera",
|
|
4558
|
+
cameraType: "perspective",
|
|
4559
|
+
properties: [],
|
|
4560
|
+
position: { x: 0, y: 1.6 * scale, z: 3 * scale },
|
|
4561
|
+
target: { x: 0, y: 0.5 * scale, z: 0 },
|
|
4562
|
+
fov: 70,
|
|
4563
|
+
near: 0.01,
|
|
4564
|
+
far: 1e3
|
|
4565
|
+
};
|
|
4566
|
+
lights.push({
|
|
4567
|
+
type: "Light",
|
|
4568
|
+
id: "ambient_main",
|
|
4569
|
+
name: "ambient_main",
|
|
4570
|
+
lightType: "ambient",
|
|
4571
|
+
properties: [
|
|
4572
|
+
{ type: "LightProperty", key: "color", value: "#ffffff" },
|
|
4573
|
+
{ type: "LightProperty", key: "intensity", value: 0.6 }
|
|
4574
|
+
]
|
|
4575
|
+
});
|
|
4576
|
+
lights.push({
|
|
4577
|
+
type: "Light",
|
|
4578
|
+
id: "directional_main",
|
|
4579
|
+
name: "directional_main",
|
|
4580
|
+
lightType: "directional",
|
|
4581
|
+
properties: [
|
|
4582
|
+
{ type: "LightProperty", key: "color", value: "#ffffff" },
|
|
4583
|
+
{ type: "LightProperty", key: "intensity", value: 0.8 },
|
|
4584
|
+
{ type: "LightProperty", key: "position", value: [5 * scale, 10 * scale, 5 * scale] }
|
|
4585
|
+
]
|
|
4586
|
+
});
|
|
4587
|
+
const composition = {
|
|
4588
|
+
type: "Composition",
|
|
4589
|
+
name: "Matterpak Import",
|
|
4590
|
+
environment: {
|
|
4591
|
+
type: "Environment",
|
|
4592
|
+
properties: [
|
|
4593
|
+
{ type: "EnvironmentProperty", key: "background", value: "#202020" },
|
|
4594
|
+
{ type: "EnvironmentProperty", key: "fogColor", value: "#202020" },
|
|
4595
|
+
{ type: "EnvironmentProperty", key: "fogNear", value: 10 * scale },
|
|
4596
|
+
{ type: "EnvironmentProperty", key: "fogFar", value: 50 * scale }
|
|
4597
|
+
]
|
|
4598
|
+
},
|
|
4599
|
+
templates: [],
|
|
4600
|
+
objects,
|
|
4601
|
+
spatialGroups,
|
|
4602
|
+
lights,
|
|
4603
|
+
camera,
|
|
4604
|
+
effects: {
|
|
4605
|
+
type: "Effects",
|
|
4606
|
+
effects: [
|
|
4607
|
+
{ type: "Effect", effectType: "shadows", properties: { enabled: true } },
|
|
4608
|
+
{ type: "Effect", effectType: "ambientOcclusion", properties: { enabled: true } }
|
|
4609
|
+
]
|
|
4610
|
+
},
|
|
4611
|
+
imports: [],
|
|
4612
|
+
timelines: [],
|
|
4613
|
+
audio: [],
|
|
4614
|
+
zones: [],
|
|
4615
|
+
worlds: [{
|
|
4616
|
+
type: "World",
|
|
4617
|
+
id: "property_world",
|
|
4618
|
+
name: "Imported Property",
|
|
4619
|
+
properties: [
|
|
4620
|
+
{ type: "WorldProperty", key: "gravityX", value: 0 },
|
|
4621
|
+
{ type: "WorldProperty", key: "gravityY", value: -9.81 },
|
|
4622
|
+
{ type: "WorldProperty", key: "gravityZ", value: 0 },
|
|
4623
|
+
{ type: "WorldProperty", key: "boundsMinX", value: (minX - cx) * scale },
|
|
4624
|
+
{ type: "WorldProperty", key: "boundsMinY", value: (minY - cy) * scale },
|
|
4625
|
+
{ type: "WorldProperty", key: "boundsMinZ", value: (minZ - cz) * scale },
|
|
4626
|
+
{ type: "WorldProperty", key: "boundsMaxX", value: (maxX - cx) * scale },
|
|
4627
|
+
{ type: "WorldProperty", key: "boundsMaxY", value: (maxY - cy) * scale },
|
|
4628
|
+
{ type: "WorldProperty", key: "boundsMaxZ", value: (maxZ - cz) * scale }
|
|
4629
|
+
]
|
|
4630
|
+
}],
|
|
4631
|
+
ui: {
|
|
4632
|
+
type: "UI",
|
|
4633
|
+
elements: []
|
|
4634
|
+
},
|
|
4635
|
+
transitions: [],
|
|
4636
|
+
conditionals: [],
|
|
4637
|
+
iterators: [],
|
|
4638
|
+
npcs: [],
|
|
4639
|
+
quests: [],
|
|
4640
|
+
abilities: [],
|
|
4641
|
+
dialogues: [],
|
|
4642
|
+
stateMachines: [],
|
|
4643
|
+
achievements: [],
|
|
4644
|
+
talentTrees: [],
|
|
4645
|
+
shapes: []
|
|
4646
|
+
};
|
|
4647
|
+
return {
|
|
4648
|
+
success: errors.length === 0,
|
|
4649
|
+
composition,
|
|
4650
|
+
stats,
|
|
4651
|
+
warnings,
|
|
4652
|
+
errors
|
|
4653
|
+
};
|
|
4654
|
+
}
|
|
4655
|
+
};
|
|
4656
|
+
function createMatterpakCompiler(options) {
|
|
4657
|
+
return new MatterpakCompiler(options);
|
|
4658
|
+
}
|
|
4659
|
+
|
|
4660
|
+
// src/compiler/HoloGramMLSCompiler.ts
|
|
4661
|
+
init_CompilerBase();
|
|
4662
|
+
function groupPhotosByRoom(photos) {
|
|
4663
|
+
const groups = /* @__PURE__ */ new Map();
|
|
4664
|
+
for (const p of photos) {
|
|
4665
|
+
const room = p.room?.trim() || "Uncategorized";
|
|
4666
|
+
if (!groups.has(room)) groups.set(room, []);
|
|
4667
|
+
groups.get(room).push(p);
|
|
4668
|
+
}
|
|
4669
|
+
return groups;
|
|
4670
|
+
}
|
|
4671
|
+
function computeRoomGrid(rooms, spacing) {
|
|
4672
|
+
const positions = /* @__PURE__ */ new Map();
|
|
4673
|
+
const cols = Math.ceil(Math.sqrt(rooms.length));
|
|
4674
|
+
const offsetX = (cols - 1) * spacing / 2;
|
|
4675
|
+
const offsetZ = (Math.ceil(rooms.length / cols) - 1) * spacing / 2;
|
|
4676
|
+
for (let i = 0; i < rooms.length; i++) {
|
|
4677
|
+
const col = i % cols;
|
|
4678
|
+
const row = Math.floor(i / cols);
|
|
4679
|
+
positions.set(rooms[i], {
|
|
4680
|
+
x: col * spacing - offsetX,
|
|
4681
|
+
z: row * spacing - offsetZ
|
|
4682
|
+
});
|
|
4683
|
+
}
|
|
4684
|
+
return positions;
|
|
4685
|
+
}
|
|
4686
|
+
function aspectScale(photo) {
|
|
4687
|
+
const w = photo.width ?? 1024;
|
|
4688
|
+
const h = photo.height ?? 768;
|
|
4689
|
+
const base = 2;
|
|
4690
|
+
if (w >= h) {
|
|
4691
|
+
return { x: base, y: base * h / w };
|
|
4692
|
+
}
|
|
4693
|
+
return { x: base * w / h, y: base };
|
|
4694
|
+
}
|
|
4695
|
+
function placePhotosInRoom(photos, roomSize) {
|
|
4696
|
+
const placements = [];
|
|
4697
|
+
const half = roomSize / 2 - 0.5;
|
|
4698
|
+
const wallHeight = 1.6;
|
|
4699
|
+
if (photos.length === 1) {
|
|
4700
|
+
placements.push({
|
|
4701
|
+
photo: photos[0],
|
|
4702
|
+
position: { x: 0, y: wallHeight, z: -half },
|
|
4703
|
+
rotation: { x: 0, y: 0, z: 0 }
|
|
4704
|
+
});
|
|
4705
|
+
} else if (photos.length === 2) {
|
|
4706
|
+
placements.push({
|
|
4707
|
+
photo: photos[0],
|
|
4708
|
+
position: { x: -half, y: wallHeight, z: 0 },
|
|
4709
|
+
rotation: { x: 0, y: 90, z: 0 }
|
|
4710
|
+
});
|
|
4711
|
+
placements.push({
|
|
4712
|
+
photo: photos[1],
|
|
4713
|
+
position: { x: half, y: wallHeight, z: 0 },
|
|
4714
|
+
rotation: { x: 0, y: -90, z: 0 }
|
|
4715
|
+
});
|
|
4716
|
+
} else {
|
|
4717
|
+
const wallOrder = [
|
|
4718
|
+
{ x: 0, z: -half, ry: 0 },
|
|
4719
|
+
{ x: -half, z: 0, ry: 90 },
|
|
4720
|
+
{ x: half, z: 0, ry: -90 },
|
|
4721
|
+
{ x: 0, z: half, ry: 180 }
|
|
4722
|
+
];
|
|
4723
|
+
for (let i = 0; i < photos.length; i++) {
|
|
4724
|
+
const wall = wallOrder[i % wallOrder.length];
|
|
4725
|
+
const offsetIndex = Math.floor(i / wallOrder.length);
|
|
4726
|
+
const offset = (offsetIndex % 2 === 0 ? -1 : 1) * (0.6 + offsetIndex * 0.3);
|
|
4727
|
+
placements.push({
|
|
4728
|
+
photo: photos[i],
|
|
4729
|
+
position: {
|
|
4730
|
+
x: wall.x === 0 ? offset : wall.x,
|
|
4731
|
+
y: wallHeight + offsetIndex * 0.3,
|
|
4732
|
+
z: wall.z === 0 ? offset : wall.z
|
|
4733
|
+
},
|
|
4734
|
+
rotation: { x: 0, y: wall.ry, z: 0 }
|
|
4735
|
+
});
|
|
4736
|
+
}
|
|
4737
|
+
}
|
|
4738
|
+
return placements;
|
|
4739
|
+
}
|
|
4740
|
+
var HoloGramMLSCompiler = class extends CompilerBase {
|
|
4741
|
+
constructor(options = {}) {
|
|
4742
|
+
super();
|
|
4743
|
+
this.compilerName = "hologram_mls";
|
|
4744
|
+
this.version = "1.0.0";
|
|
4745
|
+
this.options = {
|
|
4746
|
+
photoScale: 1,
|
|
4747
|
+
roomSpacing: 8,
|
|
4748
|
+
depthModel: "depth-anything-v2-small",
|
|
4749
|
+
depthBackend: "webgpu",
|
|
4750
|
+
displacementScale: 0.3,
|
|
4751
|
+
displacementSegments: 128,
|
|
4752
|
+
walkable: true,
|
|
4753
|
+
ambientLight: 0.4,
|
|
4754
|
+
spotLighting: true,
|
|
4755
|
+
floorColor: "#1a1a2e",
|
|
4756
|
+
environment: "night",
|
|
4757
|
+
...options
|
|
4758
|
+
};
|
|
4759
|
+
}
|
|
4760
|
+
/**
|
|
4761
|
+
* Satisfy CompilerBase abstract method — HoloGramMLSCompiler is a format-ingest
|
|
4762
|
+
* compiler (bundle → HoloComposition). Use compileBundle() for ingestion.
|
|
4763
|
+
*/
|
|
4764
|
+
compile(..._args) {
|
|
4765
|
+
throw new Error(
|
|
4766
|
+
"HoloGramMLSCompiler.compile() is not supported. Use compileBundle(bundle: HoloGramMLSBundle) to ingest an MLS bundle."
|
|
4767
|
+
);
|
|
4768
|
+
}
|
|
4769
|
+
compileBundle(bundle) {
|
|
4770
|
+
const warnings = [];
|
|
4771
|
+
const errors = [];
|
|
4772
|
+
const stats = { photos: 0, rooms: 0, waypoints: 0, lights: 0 };
|
|
4773
|
+
if (!bundle.photos || bundle.photos.length === 0) {
|
|
4774
|
+
warnings.push("No photos provided; returning empty gallery");
|
|
4775
|
+
return {
|
|
4776
|
+
success: true,
|
|
4777
|
+
composition: this.buildEmptyComposition(),
|
|
4778
|
+
stats,
|
|
4779
|
+
warnings,
|
|
4780
|
+
errors
|
|
4781
|
+
};
|
|
4782
|
+
}
|
|
4783
|
+
const roomGroups = groupPhotosByRoom(bundle.photos);
|
|
4784
|
+
const roomNames = Array.from(roomGroups.keys());
|
|
4785
|
+
stats.photos = bundle.photos.length;
|
|
4786
|
+
stats.rooms = roomNames.length;
|
|
4787
|
+
const roomPositions = computeRoomGrid(roomNames, this.options.roomSpacing);
|
|
4788
|
+
const objects = [];
|
|
4789
|
+
const spatialGroups = [];
|
|
4790
|
+
const lights = [];
|
|
4791
|
+
const waypoints = [];
|
|
4792
|
+
const wpPoints = [];
|
|
4793
|
+
for (const roomName of roomNames) {
|
|
4794
|
+
const photos = roomGroups.get(roomName);
|
|
4795
|
+
const pos = roomPositions.get(roomName);
|
|
4796
|
+
const roomSize = Math.min(this.options.roomSpacing * 0.8, 6);
|
|
4797
|
+
objects.push({
|
|
4798
|
+
type: "ObjectDecl",
|
|
4799
|
+
id: `floor_${roomName.replace(/\s+/g, "_")}`,
|
|
4800
|
+
name: `${roomName} Floor`,
|
|
4801
|
+
position: { x: pos.x, y: 0, z: pos.z },
|
|
4802
|
+
scale: { x: roomSize, y: 1, z: roomSize },
|
|
4803
|
+
rotation: { x: -90, y: 0, z: 0 },
|
|
4804
|
+
properties: [],
|
|
4805
|
+
traits: [
|
|
4806
|
+
{ type: "ObjectTrait", name: "collidable", config: {}, params: {} },
|
|
4807
|
+
{ type: "ObjectTrait", name: "static", config: {}, params: {} },
|
|
4808
|
+
{
|
|
4809
|
+
type: "ObjectTrait",
|
|
4810
|
+
name: "geometry",
|
|
4811
|
+
config: {},
|
|
4812
|
+
params: { primitive: "plane" }
|
|
4813
|
+
},
|
|
4814
|
+
{
|
|
4815
|
+
type: "ObjectTrait",
|
|
4816
|
+
name: "material",
|
|
4817
|
+
config: {},
|
|
4818
|
+
params: {
|
|
4819
|
+
color: this.options.floorColor,
|
|
4820
|
+
roughness: 0.1,
|
|
4821
|
+
metalness: 0.6
|
|
4822
|
+
}
|
|
4823
|
+
}
|
|
4824
|
+
]
|
|
4825
|
+
});
|
|
4826
|
+
const placements = placePhotosInRoom(photos, roomSize);
|
|
4827
|
+
for (const placement of placements) {
|
|
4828
|
+
const scale = aspectScale(placement.photo);
|
|
4829
|
+
const traits = [
|
|
4830
|
+
{
|
|
4831
|
+
type: "ObjectTrait",
|
|
4832
|
+
name: "image",
|
|
4833
|
+
config: {},
|
|
4834
|
+
params: { src: placement.photo.url }
|
|
4835
|
+
},
|
|
4836
|
+
{
|
|
4837
|
+
type: "ObjectTrait",
|
|
4838
|
+
name: "depth_estimation",
|
|
4839
|
+
config: {},
|
|
4840
|
+
params: {
|
|
4841
|
+
model: this.options.depthModel,
|
|
4842
|
+
backend: this.options.depthBackend
|
|
4843
|
+
}
|
|
4844
|
+
},
|
|
4845
|
+
{
|
|
4846
|
+
type: "ObjectTrait",
|
|
4847
|
+
name: "displacement",
|
|
4848
|
+
config: {},
|
|
4849
|
+
params: {
|
|
4850
|
+
scale: this.options.displacementScale,
|
|
4851
|
+
segments: this.options.displacementSegments
|
|
4852
|
+
}
|
|
4853
|
+
},
|
|
4854
|
+
{
|
|
4855
|
+
type: "ObjectTrait",
|
|
4856
|
+
name: "depth_to_normal",
|
|
4857
|
+
config: {},
|
|
4858
|
+
params: {}
|
|
4859
|
+
},
|
|
4860
|
+
{
|
|
4861
|
+
type: "ObjectTrait",
|
|
4862
|
+
name: "geometry",
|
|
4863
|
+
config: {},
|
|
4864
|
+
params: { primitive: "plane" }
|
|
4865
|
+
}
|
|
4866
|
+
];
|
|
4867
|
+
if (placement.photo.caption) {
|
|
4868
|
+
traits.push({
|
|
4869
|
+
type: "ObjectTrait",
|
|
4870
|
+
name: "billboard",
|
|
4871
|
+
config: {},
|
|
4872
|
+
params: { label: placement.photo.caption }
|
|
4873
|
+
});
|
|
4874
|
+
}
|
|
4875
|
+
objects.push({
|
|
4876
|
+
type: "ObjectDecl",
|
|
4877
|
+
id: `photo_${objects.length}`,
|
|
4878
|
+
name: placement.photo.caption || `Photo ${objects.length}`,
|
|
4879
|
+
position: {
|
|
4880
|
+
x: pos.x + placement.position.x,
|
|
4881
|
+
y: placement.position.y,
|
|
4882
|
+
z: pos.z + placement.position.z
|
|
4883
|
+
},
|
|
4884
|
+
scale: {
|
|
4885
|
+
x: scale.x * this.options.photoScale,
|
|
4886
|
+
y: scale.y * this.options.photoScale,
|
|
4887
|
+
z: 1
|
|
4888
|
+
},
|
|
4889
|
+
rotation: placement.rotation,
|
|
4890
|
+
properties: [],
|
|
4891
|
+
traits
|
|
4892
|
+
});
|
|
4893
|
+
}
|
|
4894
|
+
objects.push({
|
|
4895
|
+
type: "ObjectDecl",
|
|
4896
|
+
id: `label_${roomName.replace(/\s+/g, "_")}`,
|
|
4897
|
+
name: `${roomName} Label`,
|
|
4898
|
+
position: { x: pos.x, y: 2.8, z: pos.z },
|
|
4899
|
+
scale: { x: 2, y: 0.4, z: 0.01 },
|
|
4900
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
4901
|
+
properties: [],
|
|
4902
|
+
traits: [
|
|
4903
|
+
{ type: "ObjectTrait", name: "billboard", config: {}, params: {} },
|
|
4904
|
+
{
|
|
4905
|
+
type: "ObjectTrait",
|
|
4906
|
+
name: "material",
|
|
4907
|
+
config: {},
|
|
4908
|
+
params: { color: "#0a0a20", emissive: "#4422cc", emissiveIntensity: 1.2 }
|
|
4909
|
+
}
|
|
4910
|
+
]
|
|
4911
|
+
});
|
|
4912
|
+
if (this.options.spotLighting) {
|
|
4913
|
+
lights.push({
|
|
4914
|
+
type: "Light",
|
|
4915
|
+
id: `spot_${roomName.replace(/\s+/g, "_")}`,
|
|
4916
|
+
lightType: "spot",
|
|
4917
|
+
name: `${roomName} Spot`,
|
|
4918
|
+
properties: [
|
|
4919
|
+
{ type: "LightProperty", key: "position", value: [pos.x, 4, pos.z] },
|
|
4920
|
+
{ type: "LightProperty", key: "target", value: [pos.x, 0, pos.z] },
|
|
4921
|
+
{ type: "LightProperty", key: "color", value: "#ffffff" },
|
|
4922
|
+
{ type: "LightProperty", key: "intensity", value: 1.2 },
|
|
4923
|
+
{ type: "LightProperty", key: "angle", value: Math.PI / 3 },
|
|
4924
|
+
{ type: "LightProperty", key: "penumbra", value: 0.3 }
|
|
4925
|
+
]
|
|
4926
|
+
});
|
|
4927
|
+
stats.lights++;
|
|
4928
|
+
}
|
|
4929
|
+
spatialGroups.push({
|
|
4930
|
+
type: "SpatialGroup",
|
|
4931
|
+
id: `room_${roomName.replace(/\s+/g, "_")}`,
|
|
4932
|
+
name: roomName,
|
|
4933
|
+
objects: objects.filter((o) => o.id?.startsWith(`floor_${roomName.replace(/\s+/g, "_")}`) || o.id?.startsWith(`label_${roomName.replace(/\s+/g, "_")}`) || o.traits?.some((t) => t.name === "image") && Math.abs((o.position?.x ?? 0) - pos.x) < roomSize && Math.abs((o.position?.z ?? 0) - pos.z) < roomSize),
|
|
4934
|
+
properties: []
|
|
4935
|
+
});
|
|
4936
|
+
wpPoints.push([pos.x, 0.1, pos.z]);
|
|
4937
|
+
}
|
|
4938
|
+
if (this.options.walkable && wpPoints.length > 1) {
|
|
4939
|
+
waypoints.push({
|
|
4940
|
+
type: "Waypoints",
|
|
4941
|
+
name: "room_navigation",
|
|
4942
|
+
points: wpPoints
|
|
4943
|
+
});
|
|
4944
|
+
stats.waypoints = wpPoints.length;
|
|
4945
|
+
}
|
|
4946
|
+
lights.push({
|
|
4947
|
+
type: "Light",
|
|
4948
|
+
id: "ambient_main",
|
|
4949
|
+
lightType: "ambient",
|
|
4950
|
+
name: "Ambient",
|
|
4951
|
+
properties: [
|
|
4952
|
+
{ type: "LightProperty", key: "color", value: "#ffffff" },
|
|
4953
|
+
{ type: "LightProperty", key: "intensity", value: this.options.ambientLight }
|
|
4954
|
+
]
|
|
4955
|
+
});
|
|
4956
|
+
stats.lights++;
|
|
4957
|
+
lights.push({
|
|
4958
|
+
type: "Light",
|
|
4959
|
+
id: "directional_main",
|
|
4960
|
+
lightType: "directional",
|
|
4961
|
+
name: "Directional",
|
|
4962
|
+
properties: [
|
|
4963
|
+
{ type: "LightProperty", key: "color", value: "#ffffff" },
|
|
4964
|
+
{ type: "LightProperty", key: "intensity", value: 0.8 },
|
|
4965
|
+
{ type: "LightProperty", key: "position", value: [5, 10, 5] }
|
|
4966
|
+
]
|
|
4967
|
+
});
|
|
4968
|
+
stats.lights++;
|
|
4969
|
+
const firstRoom = roomPositions.get(roomNames[0]);
|
|
4970
|
+
const camera = {
|
|
4971
|
+
type: "Camera",
|
|
4972
|
+
cameraType: "perspective",
|
|
4973
|
+
position: { x: firstRoom.x, y: 1.6, z: firstRoom.z + this.options.roomSpacing * 0.4 },
|
|
4974
|
+
target: { x: firstRoom.x, y: 1.2, z: firstRoom.z },
|
|
4975
|
+
fov: 70,
|
|
4976
|
+
near: 0.01,
|
|
4977
|
+
far: 1e3,
|
|
4978
|
+
properties: []
|
|
4979
|
+
};
|
|
4980
|
+
const composition = {
|
|
4981
|
+
type: "Composition",
|
|
4982
|
+
name: "HoloGram MLS Gallery",
|
|
4983
|
+
objects,
|
|
4984
|
+
spatialGroups,
|
|
4985
|
+
lights,
|
|
4986
|
+
camera,
|
|
4987
|
+
waypointSets: waypoints,
|
|
4988
|
+
worlds: [{
|
|
4989
|
+
type: "World",
|
|
4990
|
+
name: "gallery_world",
|
|
4991
|
+
bounds: {
|
|
4992
|
+
minX: -this.options.roomSpacing * 2,
|
|
4993
|
+
minY: 0,
|
|
4994
|
+
minZ: -this.options.roomSpacing * 2,
|
|
4995
|
+
maxX: this.options.roomSpacing * 2,
|
|
4996
|
+
maxY: 10,
|
|
4997
|
+
maxZ: this.options.roomSpacing * 2
|
|
4998
|
+
}
|
|
4999
|
+
}],
|
|
5000
|
+
templates: [],
|
|
5001
|
+
imports: [],
|
|
5002
|
+
transitions: [],
|
|
5003
|
+
conditionals: [],
|
|
5004
|
+
iterators: [],
|
|
5005
|
+
timelines: [],
|
|
5006
|
+
audio: [],
|
|
5007
|
+
zones: [],
|
|
5008
|
+
npcs: [],
|
|
5009
|
+
quests: [],
|
|
5010
|
+
abilities: [],
|
|
5011
|
+
dialogues: [],
|
|
5012
|
+
stateMachines: [],
|
|
5013
|
+
achievements: [],
|
|
5014
|
+
talentTrees: [],
|
|
5015
|
+
shapes: [],
|
|
5016
|
+
metadata: {
|
|
5017
|
+
...bundle.propertyMetadata,
|
|
5018
|
+
compiler: "hologram_mls",
|
|
5019
|
+
version: "1.0.0"
|
|
5020
|
+
}
|
|
5021
|
+
};
|
|
5022
|
+
return {
|
|
5023
|
+
success: true,
|
|
5024
|
+
composition,
|
|
5025
|
+
stats,
|
|
5026
|
+
warnings,
|
|
5027
|
+
errors
|
|
5028
|
+
};
|
|
5029
|
+
}
|
|
5030
|
+
buildEmptyComposition() {
|
|
5031
|
+
return {
|
|
5032
|
+
type: "Composition",
|
|
5033
|
+
name: "HoloGram MLS Gallery (Empty)",
|
|
5034
|
+
objects: [],
|
|
5035
|
+
spatialGroups: [],
|
|
5036
|
+
lights: [],
|
|
5037
|
+
templates: [],
|
|
5038
|
+
imports: [],
|
|
5039
|
+
transitions: [],
|
|
5040
|
+
conditionals: [],
|
|
5041
|
+
iterators: [],
|
|
5042
|
+
timelines: [],
|
|
5043
|
+
audio: [],
|
|
5044
|
+
zones: [],
|
|
5045
|
+
npcs: [],
|
|
5046
|
+
quests: [],
|
|
5047
|
+
abilities: [],
|
|
5048
|
+
dialogues: [],
|
|
5049
|
+
stateMachines: [],
|
|
5050
|
+
achievements: [],
|
|
5051
|
+
talentTrees: [],
|
|
5052
|
+
shapes: []
|
|
5053
|
+
};
|
|
5054
|
+
}
|
|
5055
|
+
};
|
|
5056
|
+
function createHoloGramMLSCompiler(options) {
|
|
5057
|
+
return new HoloGramMLSCompiler(options);
|
|
5058
|
+
}
|
|
5059
|
+
|
|
5060
|
+
// src/compiler/TraitRegistryBridge.ts
|
|
5061
|
+
init_AndroidXRTraitMap();
|
|
5062
|
+
init_VisionOSTraitMap();
|
|
5063
|
+
init_traitDocs();
|
|
5064
|
+
function normaliseTraitName(name) {
|
|
5065
|
+
return name.toLowerCase().replace(/^@/, "").replace(/trait$/i, "").replace(/_/g, "-").trim();
|
|
5066
|
+
}
|
|
5067
|
+
function queryTrait(name, opts = {}) {
|
|
5068
|
+
const target = opts.target || "core";
|
|
5069
|
+
if (target === "android-xr") {
|
|
5070
|
+
const map = getTraitMapping(name);
|
|
5071
|
+
if (map) {
|
|
5072
|
+
return {
|
|
5073
|
+
name,
|
|
5074
|
+
exists: true,
|
|
5075
|
+
level: map.level,
|
|
5076
|
+
codegen: opts.includeCodegen ? map.generate?.(name, {}) : void 0,
|
|
5077
|
+
sourceMap: "AndroidXRTraitMap"
|
|
5078
|
+
};
|
|
5079
|
+
}
|
|
5080
|
+
}
|
|
5081
|
+
if (target === "visionos") {
|
|
5082
|
+
const map = getTraitMapping$1(name);
|
|
5083
|
+
if (map) {
|
|
5084
|
+
return {
|
|
5085
|
+
name,
|
|
5086
|
+
exists: true,
|
|
5087
|
+
level: map.level,
|
|
5088
|
+
codegen: opts.includeCodegen ? map.generate?.(name, {}) : void 0,
|
|
5089
|
+
sourceMap: "VisionOSTraitMap"
|
|
5090
|
+
};
|
|
5091
|
+
}
|
|
5092
|
+
return { name, exists: false, sourceMap: "VisionOSTraitMap" };
|
|
5093
|
+
}
|
|
5094
|
+
const normalised = normaliseTraitName(name);
|
|
5095
|
+
if (vrTraitRegistry.has(normalised)) {
|
|
5096
|
+
const handler = vrTraitRegistry.getHandler(normalised);
|
|
5097
|
+
const doc2 = getTraitDoc(name);
|
|
5098
|
+
return {
|
|
5099
|
+
name,
|
|
5100
|
+
exists: true,
|
|
5101
|
+
sourceMap: "VRTraitRegistry",
|
|
5102
|
+
level: handler?.defaultConfig ? String(handler.defaultConfig.level ?? "core") : "core",
|
|
5103
|
+
description: doc2?.description,
|
|
5104
|
+
category: doc2?.category,
|
|
5105
|
+
annotation: doc2?.annotation
|
|
5106
|
+
};
|
|
5107
|
+
}
|
|
5108
|
+
const doc = getTraitDoc(name);
|
|
5109
|
+
if (doc) {
|
|
5110
|
+
return {
|
|
5111
|
+
name,
|
|
5112
|
+
exists: true,
|
|
5113
|
+
sourceMap: "traitDocs",
|
|
5114
|
+
description: doc.description,
|
|
5115
|
+
category: doc.category,
|
|
5116
|
+
annotation: doc.annotation
|
|
5117
|
+
};
|
|
5118
|
+
}
|
|
5119
|
+
return {
|
|
5120
|
+
name,
|
|
5121
|
+
exists: false,
|
|
5122
|
+
sourceMap: "core-traits (not found in any registry)"
|
|
5123
|
+
};
|
|
5124
|
+
}
|
|
5125
|
+
function generateTraitForTarget(name, target, config = {}) {
|
|
5126
|
+
if (target === "android-xr" || target === "android") {
|
|
5127
|
+
return getTraitMapping(name)?.generate?.(name, config) ?? [
|
|
5128
|
+
`// @${name} not yet mapped for android-xr (see AndroidXRTraitMap)`
|
|
5129
|
+
];
|
|
5130
|
+
}
|
|
5131
|
+
if (target === "visionos") {
|
|
5132
|
+
return generateTraitCode(name, name, config) ?? [
|
|
5133
|
+
`// @${name} not yet mapped for visionos (see VisionOSTraitMap)`
|
|
5134
|
+
];
|
|
5135
|
+
}
|
|
5136
|
+
const info = queryTrait(name, { target: "core" });
|
|
5137
|
+
if (info.exists) {
|
|
5138
|
+
return [
|
|
5139
|
+
`// @${name} \u2014 core trait (registered in ${info.sourceMap}), no platform-specific codegen for "${target}"`,
|
|
5140
|
+
`// trait level: ${info.level ?? "unknown"}, category: ${info.category ?? "unknown"}`
|
|
5141
|
+
];
|
|
5142
|
+
}
|
|
5143
|
+
return [`// @${name} \u2014 no codegen path registered for target "${target}" yet`];
|
|
5144
|
+
}
|
|
5145
|
+
function listTraitsForTarget(target) {
|
|
5146
|
+
if (target === "android-xr") {
|
|
5147
|
+
return Object.keys(ANDROIDXR_TRAIT_MAP);
|
|
5148
|
+
}
|
|
5149
|
+
if (target === "visionos") {
|
|
5150
|
+
return listAllTraits ? listAllTraits() : [];
|
|
5151
|
+
}
|
|
5152
|
+
if (target === "core") {
|
|
5153
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5154
|
+
const result = [];
|
|
5155
|
+
for (const name of vrTraitRegistry.getRegisteredTraits()) {
|
|
5156
|
+
const norm = normaliseTraitName(name);
|
|
5157
|
+
if (!seen.has(norm)) {
|
|
5158
|
+
seen.add(norm);
|
|
5159
|
+
result.push(name);
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
5162
|
+
for (const annotation of getAllTraitNames()) {
|
|
5163
|
+
const norm = normaliseTraitName(annotation);
|
|
5164
|
+
if (!seen.has(norm)) {
|
|
5165
|
+
seen.add(norm);
|
|
5166
|
+
result.push(annotation);
|
|
5167
|
+
}
|
|
5168
|
+
}
|
|
5169
|
+
return result;
|
|
5170
|
+
}
|
|
5171
|
+
return [];
|
|
5172
|
+
}
|
|
5173
|
+
function traitExists(name) {
|
|
5174
|
+
const normalised = normaliseTraitName(name);
|
|
5175
|
+
if (vrTraitRegistry.has(normalised)) {
|
|
5176
|
+
return true;
|
|
5177
|
+
}
|
|
5178
|
+
const doc = getTraitDoc(name);
|
|
5179
|
+
if (doc) {
|
|
5180
|
+
return true;
|
|
5181
|
+
}
|
|
5182
|
+
if (getTraitMapping(name)) {
|
|
5183
|
+
return true;
|
|
5184
|
+
}
|
|
5185
|
+
if (getTraitMapping$1(name)) {
|
|
5186
|
+
return true;
|
|
5187
|
+
}
|
|
5188
|
+
return false;
|
|
5189
|
+
}
|
|
5190
|
+
function getTraitInfo(name) {
|
|
5191
|
+
const info = queryTrait(name, { target: "core" });
|
|
5192
|
+
if (!info.exists) return void 0;
|
|
5193
|
+
return info;
|
|
5194
|
+
}
|
|
5195
|
+
|
|
5196
|
+
// src/compiler/platform/PlatformCompilerPlugin.ts
|
|
5197
|
+
var PlatformPluginRegistry = class {
|
|
5198
|
+
constructor() {
|
|
5199
|
+
this.plugins = /* @__PURE__ */ new Map();
|
|
5200
|
+
this.targetIndex = /* @__PURE__ */ new Map();
|
|
5201
|
+
}
|
|
5202
|
+
/**
|
|
5203
|
+
* Register a plugin. Indexes by name and by each target.
|
|
5204
|
+
* Overwrites any existing plugin with the same name.
|
|
5205
|
+
*/
|
|
5206
|
+
register(plugin) {
|
|
5207
|
+
const { name } = plugin.metadata;
|
|
5208
|
+
const existing = this.plugins.get(name);
|
|
5209
|
+
if (existing) {
|
|
5210
|
+
for (const target of existing.metadata.targets) {
|
|
5211
|
+
this.targetIndex.delete(target);
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
this.plugins.set(name, plugin);
|
|
5215
|
+
for (const target of plugin.metadata.targets) {
|
|
5216
|
+
this.targetIndex.set(target, plugin);
|
|
5217
|
+
}
|
|
5218
|
+
}
|
|
5219
|
+
/** Get a plugin by its unique name */
|
|
5220
|
+
getByName(name) {
|
|
5221
|
+
return this.plugins.get(name);
|
|
5222
|
+
}
|
|
5223
|
+
/** Get the plugin that handles a given target */
|
|
5224
|
+
getPluginForTarget(target) {
|
|
5225
|
+
return this.targetIndex.get(target);
|
|
5226
|
+
}
|
|
5227
|
+
/** List all registered plugin names */
|
|
5228
|
+
listPluginNames() {
|
|
5229
|
+
return [...this.plugins.keys()];
|
|
5230
|
+
}
|
|
5231
|
+
/** Get all registered plugins */
|
|
5232
|
+
listPlugins() {
|
|
5233
|
+
return [...this.plugins.values()];
|
|
5234
|
+
}
|
|
5235
|
+
/** Get all supported targets across all plugins */
|
|
5236
|
+
listAllTargets() {
|
|
5237
|
+
return [...this.targetIndex.keys()];
|
|
5238
|
+
}
|
|
5239
|
+
/** Unregister a plugin by name, cleaning up target index */
|
|
5240
|
+
unregister(name) {
|
|
5241
|
+
const plugin = this.plugins.get(name);
|
|
5242
|
+
if (plugin) {
|
|
5243
|
+
for (const target of plugin.metadata.targets) {
|
|
5244
|
+
this.targetIndex.delete(target);
|
|
5245
|
+
}
|
|
5246
|
+
this.plugins.delete(name);
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
/** Unregister all plugins */
|
|
5250
|
+
clear() {
|
|
5251
|
+
this.plugins.clear();
|
|
5252
|
+
this.targetIndex.clear();
|
|
5253
|
+
}
|
|
5254
|
+
};
|
|
5255
|
+
var platformPluginRegistry = new PlatformPluginRegistry();
|
|
5256
|
+
function manifestFromPlugin(plugin) {
|
|
5257
|
+
const { name, version, targets, sizeKB, integrity } = plugin.metadata;
|
|
5258
|
+
const shortName = name.replace(/^holoscript-plugin-/, "");
|
|
5259
|
+
return {
|
|
5260
|
+
name,
|
|
5261
|
+
version,
|
|
5262
|
+
targets,
|
|
5263
|
+
wasmUrl: `plugins/holoscript-plugin-${shortName}.component.wasm`,
|
|
5264
|
+
sizeKB,
|
|
5265
|
+
integrity
|
|
5266
|
+
};
|
|
5267
|
+
}
|
|
5268
|
+
function getAllManifests() {
|
|
5269
|
+
return platformPluginRegistry.listPlugins().map(manifestFromPlugin);
|
|
5270
|
+
}
|
|
5271
|
+
|
|
5272
|
+
// src/compiler/platform/plugins/WebGPUWGSLPlugin.ts
|
|
5273
|
+
init_WebGPUCompiler();
|
|
5274
|
+
var WEBGPU_WGSL_METADATA = {
|
|
5275
|
+
name: "holoscript-plugin-webgpu-wgsl",
|
|
5276
|
+
version: "1.0.0",
|
|
5277
|
+
targets: ["web"],
|
|
5278
|
+
// webgpu-wgsl maps to 'web' in PlatformTarget
|
|
5279
|
+
sizeKB: 220,
|
|
5280
|
+
minCoreVersion: "6.0.0"
|
|
5281
|
+
};
|
|
5282
|
+
var WebGPUWGSLPlugin = class {
|
|
5283
|
+
constructor() {
|
|
5284
|
+
this.metadata = WEBGPU_WGSL_METADATA;
|
|
5285
|
+
}
|
|
5286
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5287
|
+
// Core compilation
|
|
5288
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5289
|
+
compile(astJson, target) {
|
|
5290
|
+
let ast;
|
|
5291
|
+
try {
|
|
5292
|
+
ast = JSON.parse(astJson);
|
|
5293
|
+
} catch {
|
|
5294
|
+
return {
|
|
5295
|
+
type: "error",
|
|
5296
|
+
diagnostics: [{ severity: "error", message: "WebGPU plugin: invalid AST JSON input" }]
|
|
5297
|
+
};
|
|
5298
|
+
}
|
|
5299
|
+
switch (target) {
|
|
5300
|
+
case "web": {
|
|
5301
|
+
try {
|
|
5302
|
+
const compiler = new WebGPUCompiler({ enableCompute: true });
|
|
5303
|
+
const result = compiler.compile(ast, "");
|
|
5304
|
+
return { type: "text", data: result };
|
|
5305
|
+
} catch (err) {
|
|
5306
|
+
return {
|
|
5307
|
+
type: "error",
|
|
5308
|
+
diagnostics: [
|
|
5309
|
+
{
|
|
5310
|
+
severity: "error",
|
|
5311
|
+
message: `WebGPU compilation failed: ${err instanceof Error ? err.message : String(err)}`
|
|
5312
|
+
}
|
|
5313
|
+
]
|
|
5314
|
+
};
|
|
5315
|
+
}
|
|
5316
|
+
}
|
|
5317
|
+
default:
|
|
5318
|
+
return {
|
|
5319
|
+
type: "error",
|
|
5320
|
+
diagnostics: [
|
|
5321
|
+
{
|
|
5322
|
+
severity: "error",
|
|
5323
|
+
message: `WebGPU plugin: unsupported target '${target}'. Supported: web`
|
|
5324
|
+
}
|
|
5325
|
+
]
|
|
5326
|
+
};
|
|
5327
|
+
}
|
|
5328
|
+
}
|
|
5329
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5330
|
+
// Trait evaluation (delegates to TraitRegistryBridge)
|
|
5331
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5332
|
+
traitExists(name) {
|
|
5333
|
+
return traitExists(name);
|
|
5334
|
+
}
|
|
5335
|
+
traitQuery(name, opts) {
|
|
5336
|
+
return queryTrait(name, { target: "webgpu", ...opts });
|
|
5337
|
+
}
|
|
5338
|
+
traitList() {
|
|
5339
|
+
return listTraitsForTarget("core");
|
|
5340
|
+
}
|
|
5341
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5342
|
+
// Trait codegen (WGSL-specific)
|
|
5343
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5344
|
+
traitCodegen(traitName, context) {
|
|
5345
|
+
const { target, config, format } = context;
|
|
5346
|
+
if (!this.traitExists(traitName)) {
|
|
5347
|
+
return {
|
|
5348
|
+
code: [`// @${traitName} \u2014 trait not found in any registry`],
|
|
5349
|
+
language: "wgsl",
|
|
5350
|
+
fidelity: "stub",
|
|
5351
|
+
sourceMap: "WebGPUWGSLPlugin"
|
|
5352
|
+
};
|
|
5353
|
+
}
|
|
5354
|
+
const webgpuCode = generateTraitForTarget(traitName, "webgpu-wgsl", config);
|
|
5355
|
+
if (webgpuCode.length > 0 && !webgpuCode[0].startsWith("//")) {
|
|
5356
|
+
return {
|
|
5357
|
+
code: webgpuCode,
|
|
5358
|
+
language: "wgsl",
|
|
5359
|
+
fidelity: "full",
|
|
5360
|
+
sourceMap: "TraitRegistryBridge/webgpu-wgsl",
|
|
5361
|
+
...context.includeProvenance && {
|
|
5362
|
+
provenance: {
|
|
5363
|
+
pluginName: this.metadata.name,
|
|
5364
|
+
pluginVersion: this.metadata.version,
|
|
5365
|
+
traitName,
|
|
5366
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
5367
|
+
}
|
|
5368
|
+
}
|
|
5369
|
+
};
|
|
5370
|
+
}
|
|
5371
|
+
const coreCode = generateTraitForTarget(traitName, "core", config);
|
|
5372
|
+
return {
|
|
5373
|
+
code: coreCode,
|
|
5374
|
+
language: "wgsl",
|
|
5375
|
+
fidelity: coreCode[0]?.startsWith("//") ? "stub" : "partial",
|
|
5376
|
+
sourceMap: "TraitRegistryBridge/core",
|
|
5377
|
+
...context.includeProvenance && {
|
|
5378
|
+
provenance: {
|
|
5379
|
+
pluginName: this.metadata.name,
|
|
5380
|
+
pluginVersion: this.metadata.version,
|
|
5381
|
+
traitName,
|
|
5382
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
5383
|
+
}
|
|
5384
|
+
}
|
|
5385
|
+
};
|
|
5386
|
+
}
|
|
5387
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5388
|
+
// Lifecycle
|
|
5389
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5390
|
+
unload() {
|
|
5391
|
+
}
|
|
5392
|
+
};
|
|
5393
|
+
platformPluginRegistry.register(new WebGPUWGSLPlugin());
|
|
5394
|
+
|
|
5395
|
+
// src/compiler/platform/plugins/AndroidARCorePlugin.ts
|
|
5396
|
+
init_AndroidXRCompiler();
|
|
5397
|
+
var ANDROID_ARCORE_METADATA = {
|
|
5398
|
+
name: "holoscript-plugin-android-arcore",
|
|
5399
|
+
version: "1.0.0",
|
|
5400
|
+
targets: ["android-xr", "android-xr-ar"],
|
|
5401
|
+
sizeKB: 300,
|
|
5402
|
+
minCoreVersion: "6.0.0"
|
|
5403
|
+
};
|
|
5404
|
+
var AndroidARCorePlugin = class {
|
|
5405
|
+
constructor() {
|
|
5406
|
+
this.metadata = ANDROID_ARCORE_METADATA;
|
|
5407
|
+
}
|
|
5408
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5409
|
+
// Core compilation
|
|
5410
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5411
|
+
compile(astJson, target) {
|
|
5412
|
+
let ast;
|
|
5413
|
+
try {
|
|
5414
|
+
ast = JSON.parse(astJson);
|
|
5415
|
+
} catch {
|
|
5416
|
+
return {
|
|
5417
|
+
type: "error",
|
|
5418
|
+
diagnostics: [
|
|
5419
|
+
{ severity: "error", message: "Android/ARCore plugin: invalid AST JSON input" }
|
|
5420
|
+
]
|
|
5421
|
+
};
|
|
5422
|
+
}
|
|
5423
|
+
switch (target) {
|
|
5424
|
+
case "android-xr":
|
|
5425
|
+
case "android-xr-ar": {
|
|
5426
|
+
try {
|
|
5427
|
+
const compiler = new AndroidXRCompiler({
|
|
5428
|
+
formFactor: target === "android-xr-ar" ? "glasses" : "headset"
|
|
5429
|
+
});
|
|
5430
|
+
const result = compiler.compile(ast, "apl-plugin-token");
|
|
5431
|
+
const output = typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
5432
|
+
return { type: "text", data: output };
|
|
5433
|
+
} catch (err) {
|
|
5434
|
+
return {
|
|
5435
|
+
type: "error",
|
|
5436
|
+
diagnostics: [
|
|
5437
|
+
{
|
|
5438
|
+
severity: "error",
|
|
5439
|
+
message: `Android/ARCore compilation failed: ${err instanceof Error ? err.message : String(err)}`
|
|
5440
|
+
}
|
|
5441
|
+
]
|
|
5442
|
+
};
|
|
5443
|
+
}
|
|
5444
|
+
}
|
|
5445
|
+
default:
|
|
5446
|
+
return {
|
|
5447
|
+
type: "error",
|
|
5448
|
+
diagnostics: [
|
|
5449
|
+
{
|
|
5450
|
+
severity: "error",
|
|
5451
|
+
message: `Android/ARCore plugin: unsupported target '${target}'. Supported: android-xr, android-xr-ar`
|
|
5452
|
+
}
|
|
5453
|
+
]
|
|
5454
|
+
};
|
|
5455
|
+
}
|
|
5456
|
+
}
|
|
5457
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5458
|
+
// Trait evaluation (delegates to TraitRegistryBridge)
|
|
5459
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5460
|
+
traitExists(name) {
|
|
5461
|
+
return traitExists(name);
|
|
5462
|
+
}
|
|
5463
|
+
traitQuery(name, opts) {
|
|
5464
|
+
return queryTrait(name, { target: "android-xr", ...opts });
|
|
5465
|
+
}
|
|
5466
|
+
traitList() {
|
|
5467
|
+
return listTraitsForTarget("android-xr");
|
|
5468
|
+
}
|
|
5469
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5470
|
+
// Trait codegen (Kotlin/ARCore-specific)
|
|
5471
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5472
|
+
traitCodegen(traitName, context) {
|
|
5473
|
+
const { target, config, format } = context;
|
|
5474
|
+
if (!this.traitExists(traitName)) {
|
|
5475
|
+
return {
|
|
5476
|
+
code: [`// @${traitName} \u2014 trait not found in any registry`],
|
|
5477
|
+
language: "kotlin",
|
|
5478
|
+
fidelity: "stub",
|
|
5479
|
+
sourceMap: "AndroidARCorePlugin"
|
|
5480
|
+
};
|
|
5481
|
+
}
|
|
5482
|
+
const androidCode = generateTraitForTarget(traitName, "android-xr", config);
|
|
5483
|
+
if (androidCode.length > 0 && !androidCode[0].startsWith("//")) {
|
|
5484
|
+
return {
|
|
5485
|
+
code: androidCode,
|
|
5486
|
+
language: "kotlin",
|
|
5487
|
+
fidelity: "full",
|
|
5488
|
+
sourceMap: "AndroidXRTraitMap",
|
|
5489
|
+
...context.includeProvenance && {
|
|
5490
|
+
provenance: {
|
|
5491
|
+
pluginName: this.metadata.name,
|
|
5492
|
+
pluginVersion: this.metadata.version,
|
|
5493
|
+
traitName,
|
|
5494
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
5495
|
+
}
|
|
5496
|
+
}
|
|
5497
|
+
};
|
|
5498
|
+
}
|
|
5499
|
+
const coreCode = generateTraitForTarget(traitName, "core", config);
|
|
5500
|
+
return {
|
|
5501
|
+
code: coreCode,
|
|
5502
|
+
language: "kotlin",
|
|
5503
|
+
fidelity: coreCode[0]?.startsWith("//") ? "stub" : "partial",
|
|
5504
|
+
sourceMap: "TraitRegistryBridge/core",
|
|
5505
|
+
...context.includeProvenance && {
|
|
5506
|
+
provenance: {
|
|
5507
|
+
pluginName: this.metadata.name,
|
|
5508
|
+
pluginVersion: this.metadata.version,
|
|
5509
|
+
traitName,
|
|
5510
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
5511
|
+
}
|
|
5512
|
+
}
|
|
5513
|
+
};
|
|
5514
|
+
}
|
|
5515
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5516
|
+
// Lifecycle
|
|
5517
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
5518
|
+
unload() {
|
|
5519
|
+
}
|
|
5520
|
+
};
|
|
5521
|
+
platformPluginRegistry.register(new AndroidARCorePlugin());
|
|
5522
|
+
|
|
5523
|
+
export { AgentTrustLedger, AlphaTracker, AndroidARCorePlugin, DEFAULT_DISPATCH_LATENCY_OPERATION, DialectRegistry, DispatchPolicy, DispatchTier, FlatSemanticCompiler, HoloGramMLSCompiler, MCPConfigCompiler, MatterpakCompiler, Native2DCompiler, NextJSAPICompiler, NextJSCompiler, NodeServiceCompiler, SCMCompiler, WebGPUWGSLPlugin, byzantineResilientMerge, compileAllToNextJSAPI, compileToNextJSAPI, createDefaultDispatchLatencyScenarios, createHoloGramMLSCompiler, createMatterpakCompiler, createTier3CpuDirectOutput, detectWasmRuntime, ensureDialectsBooted, formatDispatchLatencyBenchmarkReport, generateTraitForTarget, getAllManifests, getTraitInfo, listTraitsForTarget, manifestFromPlugin, mergeSocialCausalModels, platformPluginRegistry, queryTrait, recommendDispatchPolicyDefaults, registerBuiltinDialects, runCompilerWasmSnnEmulator, runDispatchPolicyLatencyBenchmark, traitExists };
|
|
2382
5524
|
//# sourceMappingURL=index.js.map
|
|
2383
5525
|
//# sourceMappingURL=index.js.map
|