@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/chunk-X6SEAXAX.cjs
DELETED
|
@@ -1,3681 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkT7LEXZUZ_cjs = require('./chunk-T7LEXZUZ.cjs');
|
|
4
|
-
var chunkTSH3MSQU_cjs = require('./chunk-TSH3MSQU.cjs');
|
|
5
|
-
var chunkILRBGFVD_cjs = require('./chunk-ILRBGFVD.cjs');
|
|
6
|
-
var chunk3SAK5KFL_cjs = require('./chunk-3SAK5KFL.cjs');
|
|
7
|
-
var ws = require('ws');
|
|
8
|
-
var orbital = require('@holoscript/engine/orbital');
|
|
9
|
-
var mesh = require('@holoscript/mesh');
|
|
10
|
-
var StateMachineInterpreter = require('@holoscript/engine/runtime/StateMachineInterpreter');
|
|
11
|
-
var learning = require('@holoscript/framework/learning');
|
|
12
|
-
var BaseVoiceSynthesizer = require('@holoscript/engine/runtime/BaseVoiceSynthesizer');
|
|
13
|
-
var VoiceSynthesizer = require('@holoscript/engine/runtime/VoiceSynthesizer');
|
|
14
|
-
var LocalEmotionDetector = require('@holoscript/engine/runtime/LocalEmotionDetector');
|
|
15
|
-
var EmotionDetector = require('@holoscript/engine/runtime/EmotionDetector');
|
|
16
|
-
var MockSpeechRecognizer = require('@holoscript/engine/runtime/MockSpeechRecognizer');
|
|
17
|
-
var SpeechRecognizer = require('@holoscript/engine/runtime/SpeechRecognizer');
|
|
18
|
-
var RuntimeOptimization = require('@holoscript/engine/runtime/RuntimeOptimization');
|
|
19
|
-
|
|
20
|
-
// src/ReactiveState.ts
|
|
21
|
-
var ReactiveState = class {
|
|
22
|
-
constructor(initialState = {}) {
|
|
23
|
-
this.subscribers = /* @__PURE__ */ new Set();
|
|
24
|
-
this.state = { ...initialState };
|
|
25
|
-
this.proxy = this.createReactiveProxy(this.state);
|
|
26
|
-
}
|
|
27
|
-
createReactiveProxy(target) {
|
|
28
|
-
const self = this;
|
|
29
|
-
return new Proxy(target, {
|
|
30
|
-
get(obj, key) {
|
|
31
|
-
const val = obj[key];
|
|
32
|
-
if (val && typeof val === "object" && !Array.isArray(val)) {
|
|
33
|
-
return self.createReactiveProxy(val);
|
|
34
|
-
}
|
|
35
|
-
return val;
|
|
36
|
-
},
|
|
37
|
-
set(obj, key, value) {
|
|
38
|
-
const oldVal = obj[key];
|
|
39
|
-
obj[key] = value;
|
|
40
|
-
if (oldVal !== value) {
|
|
41
|
-
self.notify();
|
|
42
|
-
}
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
get(key) {
|
|
48
|
-
return this.proxy[key];
|
|
49
|
-
}
|
|
50
|
-
set(key, value) {
|
|
51
|
-
this.proxy[key] = value;
|
|
52
|
-
}
|
|
53
|
-
has(key) {
|
|
54
|
-
return this.proxy[key] !== void 0;
|
|
55
|
-
}
|
|
56
|
-
update(updates) {
|
|
57
|
-
Object.assign(this.proxy, updates);
|
|
58
|
-
}
|
|
59
|
-
subscribe(callback) {
|
|
60
|
-
this.subscribers.add(callback);
|
|
61
|
-
return () => this.subscribers.delete(callback);
|
|
62
|
-
}
|
|
63
|
-
getSnapshot() {
|
|
64
|
-
return { ...this.state };
|
|
65
|
-
}
|
|
66
|
-
getProxy() {
|
|
67
|
-
return this.proxy;
|
|
68
|
-
}
|
|
69
|
-
notify() {
|
|
70
|
-
this.subscribers.forEach((cb) => cb(this.getSnapshot()));
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
var ExpressionEvaluator = class {
|
|
74
|
-
constructor(context = {}) {
|
|
75
|
-
this.context = context;
|
|
76
|
-
}
|
|
77
|
-
evaluate(expression) {
|
|
78
|
-
if (typeof expression !== "string") return expression;
|
|
79
|
-
const dangerousPatterns = [
|
|
80
|
-
/\beval\s*\(/,
|
|
81
|
-
/\brequire\s*\(/,
|
|
82
|
-
/\bimport\s*\(/,
|
|
83
|
-
/\bprocess\b/,
|
|
84
|
-
/\bglobalThis?\b/,
|
|
85
|
-
/\b__dirname\b/,
|
|
86
|
-
/\b__filename\b/,
|
|
87
|
-
/\bfs\b/,
|
|
88
|
-
/\bchild_process\b/,
|
|
89
|
-
// Prototype chain / constructor escape
|
|
90
|
-
/\bconstructor\b/,
|
|
91
|
-
/\b__proto__\b/,
|
|
92
|
-
/\bprototype\b/,
|
|
93
|
-
/\bObject\s*\.\s*(create|definePropert|getProto|assign|setProto)/,
|
|
94
|
-
/\bReflect\b/,
|
|
95
|
-
/\bProxy\b/,
|
|
96
|
-
/\bFunction\b/,
|
|
97
|
-
/\barguments\b/
|
|
98
|
-
];
|
|
99
|
-
for (const pattern of dangerousPatterns) {
|
|
100
|
-
if (pattern.test(expression)) {
|
|
101
|
-
return void 0;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (expression.includes("${")) {
|
|
105
|
-
const trimmed = expression.trim();
|
|
106
|
-
const match = trimmed.match(/^\$\{([^}]+)\}$/);
|
|
107
|
-
if (match) {
|
|
108
|
-
return this.evaluate(match[1]);
|
|
109
|
-
}
|
|
110
|
-
return this.interpolate(expression);
|
|
111
|
-
}
|
|
112
|
-
const keys = Object.keys(this.context);
|
|
113
|
-
const values = Object.values(this.context);
|
|
114
|
-
try {
|
|
115
|
-
const fn = new Function(...keys, `"use strict"; return (${expression});`);
|
|
116
|
-
return fn.call(null, ...values);
|
|
117
|
-
} catch (_e) {
|
|
118
|
-
return expression;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
interpolate(str) {
|
|
122
|
-
return str.replace(/\$\{([^}]+)\}/g, (_, expr) => {
|
|
123
|
-
const val = this.evaluate(expr);
|
|
124
|
-
return val !== void 0 ? String(val) : "";
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
updateContext(updates) {
|
|
128
|
-
Object.assign(this.context, updates);
|
|
129
|
-
}
|
|
130
|
-
setContext(context) {
|
|
131
|
-
this.context = { ...context };
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
function createState(initial = {}) {
|
|
135
|
-
return new ReactiveState(initial);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/events/EventBus.ts
|
|
139
|
-
var EventBus = class {
|
|
140
|
-
constructor() {
|
|
141
|
-
this.listeners = /* @__PURE__ */ new Map();
|
|
142
|
-
this.history = [];
|
|
143
|
-
this.maxHistory = 100;
|
|
144
|
-
this.nextId = 0;
|
|
145
|
-
this.paused = false;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Subscribe to an event.
|
|
149
|
-
*/
|
|
150
|
-
on(event, callback, priority = 0) {
|
|
151
|
-
const id = this.nextId++;
|
|
152
|
-
const list = this.listeners.get(event) || [];
|
|
153
|
-
list.push({ callback, priority, once: false, id });
|
|
154
|
-
list.sort((a, b) => b.priority - a.priority);
|
|
155
|
-
this.listeners.set(event, list);
|
|
156
|
-
return id;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Subscribe to an event once (auto-removes after first fire).
|
|
160
|
-
*/
|
|
161
|
-
once(event, callback, priority = 0) {
|
|
162
|
-
const id = this.nextId++;
|
|
163
|
-
const list = this.listeners.get(event) || [];
|
|
164
|
-
list.push({ callback, priority, once: true, id });
|
|
165
|
-
list.sort((a, b) => b.priority - a.priority);
|
|
166
|
-
this.listeners.set(event, list);
|
|
167
|
-
return id;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Unsubscribe by listener ID.
|
|
171
|
-
*/
|
|
172
|
-
off(listenerId) {
|
|
173
|
-
for (const [event, list] of this.listeners) {
|
|
174
|
-
const idx = list.findIndex((l) => l.id === listenerId);
|
|
175
|
-
if (idx !== -1) {
|
|
176
|
-
list.splice(idx, 1);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Unsubscribe all listeners for an event.
|
|
183
|
-
*/
|
|
184
|
-
offAll(event) {
|
|
185
|
-
this.listeners.delete(event);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Emit an event to all subscribers.
|
|
189
|
-
*/
|
|
190
|
-
emit(event, data) {
|
|
191
|
-
if (this.paused) return;
|
|
192
|
-
this.history.push({ event, data, timestamp: Date.now() });
|
|
193
|
-
if (this.history.length > this.maxHistory) this.history.shift();
|
|
194
|
-
const list = this.listeners.get(event);
|
|
195
|
-
if (list) {
|
|
196
|
-
const toRemove = [];
|
|
197
|
-
for (const listener of list) {
|
|
198
|
-
listener.callback(data);
|
|
199
|
-
if (listener.once) toRemove.push(listener.id);
|
|
200
|
-
}
|
|
201
|
-
for (const id of toRemove) {
|
|
202
|
-
const idx = list.findIndex((l) => l.id === id);
|
|
203
|
-
if (idx !== -1) list.splice(idx, 1);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (event !== "*") {
|
|
207
|
-
const wildcardList = this.listeners.get("*");
|
|
208
|
-
if (wildcardList) {
|
|
209
|
-
for (const listener of wildcardList) {
|
|
210
|
-
listener.callback({ event, data });
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Get event history.
|
|
217
|
-
*/
|
|
218
|
-
getHistory() {
|
|
219
|
-
return [...this.history];
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Get listener count for an event.
|
|
223
|
-
*/
|
|
224
|
-
listenerCount(event) {
|
|
225
|
-
return this.listeners.get(event)?.length || 0;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Pause/resume event emission.
|
|
229
|
-
*/
|
|
230
|
-
setPaused(paused) {
|
|
231
|
-
this.paused = paused;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Clear all listeners and history.
|
|
235
|
-
*/
|
|
236
|
-
clear() {
|
|
237
|
-
this.listeners.clear();
|
|
238
|
-
this.history = [];
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
var sharedBus = null;
|
|
242
|
-
function getSharedEventBus() {
|
|
243
|
-
if (!sharedBus) sharedBus = new EventBus();
|
|
244
|
-
return sharedBus;
|
|
245
|
-
}
|
|
246
|
-
function setSharedEventBus(bus) {
|
|
247
|
-
sharedBus = bus;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// src/monitoring/telemetry.ts
|
|
251
|
-
var TelemetryRegistry = class {
|
|
252
|
-
constructor() {
|
|
253
|
-
this.measurements = [];
|
|
254
|
-
this.maxHistory = 1e4;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Increments a monotonic counter (e.g., total_nodes_executed)
|
|
258
|
-
*/
|
|
259
|
-
incrementCounter(name, value = 1, labels) {
|
|
260
|
-
this.measurements.push({
|
|
261
|
-
name,
|
|
262
|
-
type: "counter",
|
|
263
|
-
value,
|
|
264
|
-
labels,
|
|
265
|
-
timestamp: Date.now()
|
|
266
|
-
});
|
|
267
|
-
if (this.measurements.length > this.maxHistory) this.measurements.shift();
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Records an instantaneous value (e.g., active_agents)
|
|
271
|
-
*/
|
|
272
|
-
setGauge(name, value, labels) {
|
|
273
|
-
this.measurements.push({
|
|
274
|
-
name,
|
|
275
|
-
type: "gauge",
|
|
276
|
-
value,
|
|
277
|
-
labels,
|
|
278
|
-
timestamp: Date.now()
|
|
279
|
-
});
|
|
280
|
-
if (this.measurements.length > this.maxHistory) this.measurements.shift();
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Wraps an async function and records its execution latency into a histogram.
|
|
284
|
-
*/
|
|
285
|
-
async measureLatency(name, fn, labels) {
|
|
286
|
-
const start = performance.now();
|
|
287
|
-
try {
|
|
288
|
-
return await fn();
|
|
289
|
-
} finally {
|
|
290
|
-
const duration = performance.now() - start;
|
|
291
|
-
this.measurements.push({
|
|
292
|
-
name,
|
|
293
|
-
type: "histogram",
|
|
294
|
-
value: duration,
|
|
295
|
-
labels,
|
|
296
|
-
timestamp: Date.now()
|
|
297
|
-
});
|
|
298
|
-
if (this.measurements.length > this.maxHistory) this.measurements.shift();
|
|
299
|
-
if (duration > 500) {
|
|
300
|
-
this.measurements.push({
|
|
301
|
-
name: "slo_violation_count",
|
|
302
|
-
type: "counter",
|
|
303
|
-
value: 1,
|
|
304
|
-
labels: { ...labels, metric_name: name, threshold: "500ms" },
|
|
305
|
-
timestamp: Date.now()
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Snapshots current aggregations for dashboard export.
|
|
312
|
-
*/
|
|
313
|
-
getSnapshot() {
|
|
314
|
-
const snapshot = { counters: {}, histograms: {}, gauges: {} };
|
|
315
|
-
const histAggregations = {};
|
|
316
|
-
for (const m of this.measurements) {
|
|
317
|
-
const key = m.labels ? `${m.name}{${JSON.stringify(m.labels)}}` : m.name;
|
|
318
|
-
if (m.type === "counter") {
|
|
319
|
-
snapshot.counters[key] = (snapshot.counters[key] || 0) + m.value;
|
|
320
|
-
} else if (m.type === "gauge") {
|
|
321
|
-
snapshot.gauges[key] = m.value;
|
|
322
|
-
} else if (m.type === "histogram") {
|
|
323
|
-
if (!histAggregations[key]) histAggregations[key] = { count: 0, sum: 0, max: 0 };
|
|
324
|
-
histAggregations[key].count++;
|
|
325
|
-
histAggregations[key].sum += m.value;
|
|
326
|
-
if (m.value > histAggregations[key].max) histAggregations[key].max = m.value;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
for (const [key, agg] of Object.entries(histAggregations)) {
|
|
330
|
-
snapshot.histograms[key] = {
|
|
331
|
-
count: agg.count,
|
|
332
|
-
sum: agg.sum,
|
|
333
|
-
avg: agg.count > 0 ? agg.sum / agg.count : 0,
|
|
334
|
-
max: agg.max
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
return snapshot;
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
var telemetry = new TelemetryRegistry();
|
|
341
|
-
var HoloScriptAgentRuntime = class {
|
|
342
|
-
/**
|
|
343
|
-
* Creates a new HoloScript agent runtime instance.
|
|
344
|
-
*
|
|
345
|
-
* @param agentNode - The OrbNode representing the agent template
|
|
346
|
-
* @param parentRuntime - The parent runtime providing global context
|
|
347
|
-
*
|
|
348
|
-
* @example
|
|
349
|
-
* ```typescript
|
|
350
|
-
* const runtime = new HoloScriptAgentRuntime(miningAgentNode, mainRuntime);
|
|
351
|
-
* ```
|
|
352
|
-
*/
|
|
353
|
-
constructor(agentNode, parentRuntime) {
|
|
354
|
-
this.runningActions = /* @__PURE__ */ new Map();
|
|
355
|
-
this.isDestroyed = false;
|
|
356
|
-
// Episodic Memory & Semantic Extraction (Phase 7)
|
|
357
|
-
this.rawEpisodes = [];
|
|
358
|
-
this.semanticFacts = [];
|
|
359
|
-
this.consolidationInterval = null;
|
|
360
|
-
if (!agentNode || !parentRuntime) {
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
this.agentNode = agentNode;
|
|
364
|
-
this.parentRuntime = parentRuntime;
|
|
365
|
-
this.localState = new ReactiveState(agentNode.properties || {});
|
|
366
|
-
this.initializeAgentContext();
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Reset the runtime for pooling reuse with new agent configuration.
|
|
370
|
-
*
|
|
371
|
-
* @param agentNode - New agent node to bind to this runtime
|
|
372
|
-
* @param parentRuntime - Parent runtime for global context
|
|
373
|
-
*/
|
|
374
|
-
reset(agentNode, parentRuntime) {
|
|
375
|
-
this.agentNode = agentNode;
|
|
376
|
-
this.parentRuntime = parentRuntime;
|
|
377
|
-
this.localState = new ReactiveState(agentNode.properties || {});
|
|
378
|
-
this.runningActions.clear();
|
|
379
|
-
this.isDestroyed = false;
|
|
380
|
-
this.initializeAgentContext();
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Initialize the agent's execution context and memory consolidation.
|
|
384
|
-
*/
|
|
385
|
-
initializeAgentContext() {
|
|
386
|
-
({
|
|
387
|
-
id: this.agentNode.id || this.agentNode.name,
|
|
388
|
-
type: this.agentNode.type,
|
|
389
|
-
state: this.localState.getSnapshot(),
|
|
390
|
-
properties: this.agentNode.properties});
|
|
391
|
-
if (!this.consolidationInterval) {
|
|
392
|
-
this.consolidationInterval = setInterval(() => this.consolidateMemory(), 3e4);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Records a raw episodic event into the agent's short-term history queue.
|
|
397
|
-
*
|
|
398
|
-
* @param action - The action that was performed
|
|
399
|
-
* @param outcome - The result or outcome of the action
|
|
400
|
-
* @param entitiesInvolved - List of entity IDs that were involved in the episode
|
|
401
|
-
*
|
|
402
|
-
* @example
|
|
403
|
-
* ```typescript
|
|
404
|
-
* agentRuntime.recordEpisode('mine_ore', 'collected 5 iron ore', ['ore_deposit_1', 'inventory']);
|
|
405
|
-
* ```
|
|
406
|
-
*/
|
|
407
|
-
recordEpisode(action, outcome, entitiesInvolved) {
|
|
408
|
-
this.rawEpisodes.push({
|
|
409
|
-
id: `ep_${Date.now()}_${Math.random().toString(36).substring(7)}`,
|
|
410
|
-
timestamp: Date.now(),
|
|
411
|
-
action,
|
|
412
|
-
outcome,
|
|
413
|
-
entitiesInvolved
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Internal idle tick leveraging the MemoryConsolidator subsystem to offload processing constraints.
|
|
418
|
-
*/
|
|
419
|
-
consolidateMemory() {
|
|
420
|
-
if (this.isDestroyed || this.rawEpisodes.length < 5) return;
|
|
421
|
-
const { newFacts, prunedEpisodes } = learning.MemoryConsolidator.compressEpisodes(this.rawEpisodes);
|
|
422
|
-
if (newFacts.length > 0) {
|
|
423
|
-
this.semanticFacts.push(...newFacts);
|
|
424
|
-
this.rawEpisodes = this.rawEpisodes.filter((e) => !prunedEpisodes.includes(e.id));
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Execute an action (method) defined on the agent template.
|
|
429
|
-
*
|
|
430
|
-
* @param actionName - Name of the action/method to execute
|
|
431
|
-
* @param args - Arguments to pass to the action method
|
|
432
|
-
* @returns Promise resolving to execution result
|
|
433
|
-
* @throws {Error} When agent is destroyed or action execution fails
|
|
434
|
-
*
|
|
435
|
-
* @example
|
|
436
|
-
* ```typescript
|
|
437
|
-
* const result = await agentRuntime.executeAction('patrol', ['north_sector']);
|
|
438
|
-
* if (result.success) {
|
|
439
|
-
* console.log('Patrol completed:', result.output);
|
|
440
|
-
* }
|
|
441
|
-
* ```
|
|
442
|
-
*/
|
|
443
|
-
async executeAction(actionName, args = []) {
|
|
444
|
-
if (this.isDestroyed) return { success: false, error: "Agent destroyed" };
|
|
445
|
-
const directives = this.agentNode.directives;
|
|
446
|
-
const action = directives?.find((d) => d.type === "method" && d.name === actionName);
|
|
447
|
-
if (!action) {
|
|
448
|
-
return this.parentRuntime.callFunction(actionName, args);
|
|
449
|
-
}
|
|
450
|
-
chunkILRBGFVD_cjs.logger.info(`[Agent:${this.agentNode.name}] Executing action: ${actionName}`);
|
|
451
|
-
const agentScope = {
|
|
452
|
-
variables: /* @__PURE__ */ new Map(),
|
|
453
|
-
parent: this.parentRuntime.getRootScope()
|
|
454
|
-
};
|
|
455
|
-
const agentData = this.parentRuntime.getVariable(this.agentNode.name);
|
|
456
|
-
if (agentData && !agentData.state) {
|
|
457
|
-
agentData.state = this.localState.getProxy();
|
|
458
|
-
}
|
|
459
|
-
agentScope.variables.set(
|
|
460
|
-
"this",
|
|
461
|
-
agentData || {
|
|
462
|
-
id: this.agentNode.name,
|
|
463
|
-
state: this.localState.getProxy(),
|
|
464
|
-
properties: this.agentNode.properties
|
|
465
|
-
}
|
|
466
|
-
);
|
|
467
|
-
if (action.parameters && args) {
|
|
468
|
-
action.parameters.forEach((param, i) => {
|
|
469
|
-
agentScope.variables.set(param.name, args[i]);
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
try {
|
|
473
|
-
if (Array.isArray(action.body)) {
|
|
474
|
-
const results = await this.parentRuntime.executeHoloProgram(action.body, agentScope);
|
|
475
|
-
const success = results.every((r) => r.success);
|
|
476
|
-
return {
|
|
477
|
-
success,
|
|
478
|
-
output: results[results.length - 1]?.output,
|
|
479
|
-
error: results.find((r) => !r.success)?.error
|
|
480
|
-
};
|
|
481
|
-
} else {
|
|
482
|
-
const results = await this.parentRuntime.executeProgram(action.body, 1);
|
|
483
|
-
const success = results.every((r) => r.success);
|
|
484
|
-
return {
|
|
485
|
-
success,
|
|
486
|
-
output: results[results.length - 1]?.output,
|
|
487
|
-
// @ts-expect-error During migration
|
|
488
|
-
error: results.find((r) => !r.success)?.error
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
} finally {
|
|
492
|
-
this.runningActions.delete(actionName);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Autonomous 'thinking' cycle using LLM for decision making.
|
|
497
|
-
*
|
|
498
|
-
* @param prompt - Optional specific prompt for the LLM, defaults to general decision prompt
|
|
499
|
-
* @returns Promise resolving to the LLM's decision as a string
|
|
500
|
-
*
|
|
501
|
-
* @example
|
|
502
|
-
* ```typescript
|
|
503
|
-
* const decision = await agentRuntime.think('Should I retreat or continue attacking?');
|
|
504
|
-
* console.log('Agent decision:', decision);
|
|
505
|
-
* ```
|
|
506
|
-
*/
|
|
507
|
-
async think(prompt) {
|
|
508
|
-
chunkILRBGFVD_cjs.logger.info(`[Agent:${this.agentNode.name}] Thinking...`);
|
|
509
|
-
const result = await this.parentRuntime.emit("agent_think", {
|
|
510
|
-
agentId: this.agentNode.name,
|
|
511
|
-
context: this.localState.getSnapshot(),
|
|
512
|
-
prompt: prompt || "Decide the next best action based on current state."
|
|
513
|
-
});
|
|
514
|
-
return result?.decision || "No clear decision made.";
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Handle lifecycle events for this specific agent.
|
|
518
|
-
*
|
|
519
|
-
* @param eventType - The type of event being handled
|
|
520
|
-
* @param data - Event data to bind to the execution scope
|
|
521
|
-
*
|
|
522
|
-
* @example
|
|
523
|
-
* ```typescript
|
|
524
|
-
* await agentRuntime.onEvent('enemy_spotted', {
|
|
525
|
-
* enemy: 'orc_warrior',
|
|
526
|
-
* distance: 50
|
|
527
|
-
* });
|
|
528
|
-
* ```
|
|
529
|
-
*/
|
|
530
|
-
async onEvent(eventType, data) {
|
|
531
|
-
if (this.isDestroyed) return;
|
|
532
|
-
const directives = this.agentNode.directives;
|
|
533
|
-
const handler = directives?.find((d) => d.type === "lifecycle" && d.hook === eventType);
|
|
534
|
-
if (handler) {
|
|
535
|
-
const eventScope = {
|
|
536
|
-
variables: /* @__PURE__ */ new Map(),
|
|
537
|
-
parent: this.parentRuntime.getRootScope()
|
|
538
|
-
};
|
|
539
|
-
if (data && typeof data === "object") {
|
|
540
|
-
for (const [key, val] of Object.entries(data)) {
|
|
541
|
-
eventScope.variables.set(key, val);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
eventScope.variables.set("eventData", data);
|
|
545
|
-
directives?.forEach((d) => {
|
|
546
|
-
if (d.type === "method" && d.name) {
|
|
547
|
-
eventScope.variables.set(d.name, ((...args) => this.executeAction(d.name, args)));
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
const params = handler.parameters;
|
|
551
|
-
if (params && Array.isArray(params) && data && typeof data === "object") {
|
|
552
|
-
const dataRecord = data;
|
|
553
|
-
params.forEach((param) => {
|
|
554
|
-
if (dataRecord[param.name] !== void 0) {
|
|
555
|
-
eventScope.variables.set(param.name, dataRecord[param.name]);
|
|
556
|
-
}
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
const agentData = this.parentRuntime.getVariable(this.agentNode.name);
|
|
560
|
-
if (agentData && !agentData.state) {
|
|
561
|
-
agentData.state = this.localState.getProxy();
|
|
562
|
-
}
|
|
563
|
-
eventScope.variables.set(
|
|
564
|
-
"this",
|
|
565
|
-
agentData || {
|
|
566
|
-
id: this.agentNode.name,
|
|
567
|
-
state: this.localState.getProxy(),
|
|
568
|
-
properties: this.agentNode.properties
|
|
569
|
-
}
|
|
570
|
-
);
|
|
571
|
-
try {
|
|
572
|
-
if (Array.isArray(handler.body)) {
|
|
573
|
-
await this.parentRuntime.executeHoloProgram(handler.body, eventScope);
|
|
574
|
-
} else {
|
|
575
|
-
this.parentRuntime.evaluateExpression(handler.body);
|
|
576
|
-
}
|
|
577
|
-
} finally {
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
/**
|
|
582
|
-
* Clean up the agent runtime, stopping all running processes and timers.
|
|
583
|
-
*/
|
|
584
|
-
destroy() {
|
|
585
|
-
this.isDestroyed = true;
|
|
586
|
-
this.runningActions.clear();
|
|
587
|
-
if (this.consolidationInterval) {
|
|
588
|
-
clearInterval(this.consolidationInterval);
|
|
589
|
-
this.consolidationInterval = null;
|
|
590
|
-
}
|
|
591
|
-
chunkILRBGFVD_cjs.logger.info(`[Agent:${this.agentNode.name}] Runtime destroyed.`);
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* Get the agent's unique identifier.
|
|
595
|
-
*
|
|
596
|
-
* @returns The agent's ID or name
|
|
597
|
-
*/
|
|
598
|
-
get id() {
|
|
599
|
-
return this.agentNode.id || this.agentNode.name;
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Get the agent's current reactive state proxy.
|
|
603
|
-
*
|
|
604
|
-
* @returns Proxy object for the agent's state
|
|
605
|
-
*/
|
|
606
|
-
get state() {
|
|
607
|
-
return this.localState.getProxy();
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* Get the agent's current reactive state proxy.
|
|
611
|
-
*
|
|
612
|
-
* @returns Proxy object for the agent's state
|
|
613
|
-
*/
|
|
614
|
-
getState() {
|
|
615
|
-
return this.localState.getProxy();
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
// src/extensions/ExtensionRegistry.ts
|
|
620
|
-
var ExtensionRegistry = class {
|
|
621
|
-
constructor(runtime) {
|
|
622
|
-
this.extensions = /* @__PURE__ */ new Map();
|
|
623
|
-
this.runtime = runtime;
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* Load an extension into the runtime
|
|
627
|
-
*/
|
|
628
|
-
loadExtension(extension) {
|
|
629
|
-
if (this.extensions.has(extension.id)) {
|
|
630
|
-
chunkILRBGFVD_cjs.logger.warn(`Extension ${extension.id} is already loaded.`);
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
const context = {
|
|
634
|
-
registerTrait: (name, handler) => {
|
|
635
|
-
chunkILRBGFVD_cjs.logger.info(`[Extension:${extension.id}] Registering trait: ${name}`);
|
|
636
|
-
this.runtime.registerTrait(name, handler);
|
|
637
|
-
},
|
|
638
|
-
registerFunction: (name, fn) => {
|
|
639
|
-
chunkILRBGFVD_cjs.logger.info(`[Extension:${extension.id}] Registering function: ${name}`);
|
|
640
|
-
this.runtime.registerGlobalFunction(name, fn);
|
|
641
|
-
},
|
|
642
|
-
logger: chunkILRBGFVD_cjs.logger
|
|
643
|
-
};
|
|
644
|
-
try {
|
|
645
|
-
extension.onLoad(context);
|
|
646
|
-
this.extensions.set(extension.id, extension);
|
|
647
|
-
chunkILRBGFVD_cjs.logger.info(`Extension loaded: ${extension.id} v${extension.version}`);
|
|
648
|
-
} catch (error) {
|
|
649
|
-
chunkILRBGFVD_cjs.logger.error(`Failed to load extension ${extension.id}:`, {
|
|
650
|
-
error: error instanceof Error ? error.message : String(error)
|
|
651
|
-
});
|
|
652
|
-
throw error;
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Unload an extension
|
|
657
|
-
*/
|
|
658
|
-
unloadingExtension(id) {
|
|
659
|
-
const extension = this.extensions.get(id);
|
|
660
|
-
if (!extension) return;
|
|
661
|
-
try {
|
|
662
|
-
const context = {
|
|
663
|
-
registerTrait: () => {
|
|
664
|
-
},
|
|
665
|
-
registerFunction: () => {
|
|
666
|
-
},
|
|
667
|
-
logger: chunkILRBGFVD_cjs.logger
|
|
668
|
-
};
|
|
669
|
-
extension.onUnload(context);
|
|
670
|
-
} catch (e) {
|
|
671
|
-
chunkILRBGFVD_cjs.logger.error(`Error unloading extension ${id}`, {
|
|
672
|
-
error: e instanceof Error ? e.message : String(e)
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
this.extensions.delete(id);
|
|
676
|
-
chunkILRBGFVD_cjs.logger.info(`Extension unloaded: ${id}`);
|
|
677
|
-
}
|
|
678
|
-
getExtension(id) {
|
|
679
|
-
return this.extensions.get(id);
|
|
680
|
-
}
|
|
681
|
-
};
|
|
682
|
-
var RUNTIME_SECURITY_LIMITS = {
|
|
683
|
-
maxExecutionDepth: 50,
|
|
684
|
-
maxTotalNodes: 1e3,
|
|
685
|
-
maxExecutionTimeMs: 5e3,
|
|
686
|
-
maxParticlesPerSystem: 1e3,
|
|
687
|
-
maxCallStackDepth: 100
|
|
688
|
-
};
|
|
689
|
-
function isOrbData(v) {
|
|
690
|
-
return v !== null && typeof v === "object" && v.__type === "orb";
|
|
691
|
-
}
|
|
692
|
-
var HoloScriptRuntime = class {
|
|
693
|
-
constructor(_importLoader, customFunctions) {
|
|
694
|
-
this.particleSystems = /* @__PURE__ */ new Map();
|
|
695
|
-
this.executionHistory = [];
|
|
696
|
-
this.agentRuntimes = /* @__PURE__ */ new Map();
|
|
697
|
-
this.startTime = 0;
|
|
698
|
-
this.nodeCount = 0;
|
|
699
|
-
this.callStack = [];
|
|
700
|
-
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
701
|
-
this.animations = /* @__PURE__ */ new Map();
|
|
702
|
-
this.uiElements = /* @__PURE__ */ new Map();
|
|
703
|
-
this.proceduralSkills = /* @__PURE__ */ new Map();
|
|
704
|
-
this.traitHandlers = /* @__PURE__ */ new Map();
|
|
705
|
-
this.context = this.createEmptyContext();
|
|
706
|
-
this.currentScope = { variables: this.context.variables };
|
|
707
|
-
this.builtinFunctions = this.initBuiltins(customFunctions);
|
|
708
|
-
this.agentPool = new RuntimeOptimization.ObjectPool(
|
|
709
|
-
() => new HoloScriptAgentRuntime(),
|
|
710
|
-
// Preallocation mode (optional args)
|
|
711
|
-
(agent) => agent.destroy(),
|
|
712
|
-
50
|
|
713
|
-
);
|
|
714
|
-
VoiceSynthesizer.registerVoiceSynthesizer("default", new BaseVoiceSynthesizer.BaseVoiceSynthesizer());
|
|
715
|
-
EmotionDetector.registerEmotionDetector("default", new LocalEmotionDetector.LocalEmotionDetector());
|
|
716
|
-
SpeechRecognizer.registerSpeechRecognizer("default", new MockSpeechRecognizer.MockSpeechRecognizer());
|
|
717
|
-
for (const [name, fn] of this.builtinFunctions) {
|
|
718
|
-
this.context.functions.set(name, ((...spreadArgs) => fn(spreadArgs)));
|
|
719
|
-
}
|
|
720
|
-
this.registerFunction("get_attended_entities", (args) => {
|
|
721
|
-
const topK = typeof args[0] === "number" ? args[0] : 10;
|
|
722
|
-
const selfRaw = this.context.variables.get("self");
|
|
723
|
-
const selfNode = isOrbData(selfRaw) ? selfRaw : void 0;
|
|
724
|
-
const observerPos = selfNode?.position ?? { x: 0, y: 0, z: 0 };
|
|
725
|
-
const entities = [];
|
|
726
|
-
this.context.spatialMemory.forEach((pos, id) => {
|
|
727
|
-
if (id !== selfNode?.name) {
|
|
728
|
-
const entityRaw = this.context.variables.get(id);
|
|
729
|
-
const entityOrb = isOrbData(entityRaw) ? entityRaw : void 0;
|
|
730
|
-
entities.push({
|
|
731
|
-
id,
|
|
732
|
-
position: pos,
|
|
733
|
-
velocity: entityOrb?.velocity,
|
|
734
|
-
saliencyBase: typeof entityOrb?.saliency === "number" ? entityOrb.saliency : void 0
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
});
|
|
738
|
-
return orbital.AttentionEngine.getTopKEntities(observerPos, entities, topK);
|
|
739
|
-
});
|
|
740
|
-
this.traitHandlers.set("mitosis", chunkTSH3MSQU_cjs.mitosisHandler);
|
|
741
|
-
this.traitHandlers.set("orbital", chunkTSH3MSQU_cjs.orbitalHandler);
|
|
742
|
-
this.extensionRegistry = new ExtensionRegistry(this);
|
|
743
|
-
StateMachineInterpreter.stateMachineInterpreter.setHookExecutor(
|
|
744
|
-
(code, context) => {
|
|
745
|
-
for (const [key, value] of Object.entries(context)) {
|
|
746
|
-
this.context.variables.set(key, value);
|
|
747
|
-
}
|
|
748
|
-
return this.evaluateExpression(code);
|
|
749
|
-
}
|
|
750
|
-
);
|
|
751
|
-
}
|
|
752
|
-
/**
|
|
753
|
-
* Initialize built-in functions
|
|
754
|
-
*/
|
|
755
|
-
initBuiltins(customFunctions) {
|
|
756
|
-
const builtins = /* @__PURE__ */ new Map();
|
|
757
|
-
if (customFunctions) {
|
|
758
|
-
for (const [name, func] of Object.entries(customFunctions)) {
|
|
759
|
-
builtins.set(name, func);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
builtins.set("show", (args) => {
|
|
763
|
-
const target = String(args[0]);
|
|
764
|
-
const element = this.uiElements.get(target);
|
|
765
|
-
if (element) element.visible = true;
|
|
766
|
-
const hologram = this.context.hologramState.get(target);
|
|
767
|
-
if (hologram) {
|
|
768
|
-
this.createParticleEffect(`${target}_show`, { x: 0, y: 0, z: 0 }, hologram.color, 15);
|
|
769
|
-
}
|
|
770
|
-
chunkILRBGFVD_cjs.logger.info("show", { target });
|
|
771
|
-
return { shown: target };
|
|
772
|
-
});
|
|
773
|
-
builtins.set("hide", (args) => {
|
|
774
|
-
const target = String(args[0]);
|
|
775
|
-
const element = this.uiElements.get(target);
|
|
776
|
-
if (element) element.visible = false;
|
|
777
|
-
chunkILRBGFVD_cjs.logger.info("hide", { target });
|
|
778
|
-
return { hidden: target };
|
|
779
|
-
});
|
|
780
|
-
builtins.set("pulsate", (args) => {
|
|
781
|
-
const target = String(args[0]);
|
|
782
|
-
const options = args[1] || {};
|
|
783
|
-
const duration = Number(options.duration) || 1e3;
|
|
784
|
-
const color = String(options.color || "#ffffff");
|
|
785
|
-
const position = this.context.spatialMemory.get(target) || { x: 0, y: 0, z: 0 };
|
|
786
|
-
this.createParticleEffect(`${target}_pulse`, position, color, 30);
|
|
787
|
-
return { pulsing: target, duration };
|
|
788
|
-
});
|
|
789
|
-
builtins.set("animate", (args) => {
|
|
790
|
-
const target = String(args[0]);
|
|
791
|
-
const options = args[1] || {};
|
|
792
|
-
const animation = {
|
|
793
|
-
target,
|
|
794
|
-
property: String(options.property || "position.y"),
|
|
795
|
-
from: Number(options.from || 0),
|
|
796
|
-
to: Number(options.to || 1),
|
|
797
|
-
duration: Number(options.duration || 1e3),
|
|
798
|
-
startTime: Date.now(),
|
|
799
|
-
easing: String(options.easing || "linear"),
|
|
800
|
-
loop: Boolean(options.loop),
|
|
801
|
-
yoyo: Boolean(options.yoyo)
|
|
802
|
-
};
|
|
803
|
-
this.animations.set(`${target}_${animation.property}`, animation);
|
|
804
|
-
return { animating: target, animation };
|
|
805
|
-
});
|
|
806
|
-
builtins.set("spawn", async (args) => {
|
|
807
|
-
const config = args[0];
|
|
808
|
-
if (typeof config === "string") {
|
|
809
|
-
const target = config;
|
|
810
|
-
const position2 = args[1] || { x: 0, y: 0, z: 0 };
|
|
811
|
-
this.context.spatialMemory.set(target, position2);
|
|
812
|
-
this.createParticleEffect(`${target}_spawn`, position2, "#00ff00", 25);
|
|
813
|
-
return { spawned: target, at: position2 };
|
|
814
|
-
}
|
|
815
|
-
const spawnConfig = config;
|
|
816
|
-
const templateName = String(spawnConfig.template);
|
|
817
|
-
const id = String(spawnConfig.id || `${templateName}_${Date.now()}`);
|
|
818
|
-
const position = spawnConfig.position || { x: 0, y: 0, z: 0 };
|
|
819
|
-
const template = this.context.templates.get(templateName);
|
|
820
|
-
if (!template) {
|
|
821
|
-
chunkILRBGFVD_cjs.logger.error(`[Mitosis] Template ${templateName} not found`);
|
|
822
|
-
return { error: `Template ${templateName} not found` };
|
|
823
|
-
}
|
|
824
|
-
const spawnNode = {
|
|
825
|
-
type: "orb",
|
|
826
|
-
name: id,
|
|
827
|
-
position,
|
|
828
|
-
properties: { ...spawnConfig.config || {} },
|
|
829
|
-
// Initial state from config
|
|
830
|
-
children: template.children,
|
|
831
|
-
traits: template.traits,
|
|
832
|
-
directives: template.directives
|
|
833
|
-
};
|
|
834
|
-
const holoTpl = template;
|
|
835
|
-
if (holoTpl.state) {
|
|
836
|
-
for (const prop of holoTpl.state.properties) {
|
|
837
|
-
if (spawnNode.properties[prop.key] === void 0) {
|
|
838
|
-
spawnNode.properties[prop.key] = this.resolveHoloValue(prop.value);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
for (const prop of holoTpl.properties) {
|
|
843
|
-
if (spawnNode.properties[prop.key] === void 0) {
|
|
844
|
-
spawnNode.properties[prop.key] = this.resolveHoloValue(prop.value);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
await this.executeOrb(spawnNode);
|
|
848
|
-
if (spawnConfig.parentId || spawnConfig.parent_id) {
|
|
849
|
-
const parentId = String(spawnConfig.parentId || spawnConfig.parent_id);
|
|
850
|
-
await this.emit(`mitosis_spawned`, { parentId, childId: id });
|
|
851
|
-
await this.emit(`${parentId}.mitosis_spawned`, { childId: id });
|
|
852
|
-
}
|
|
853
|
-
return { spawned: id, template: templateName };
|
|
854
|
-
});
|
|
855
|
-
builtins.set("notifyParent", async (args) => {
|
|
856
|
-
const parentId = String(args[0]);
|
|
857
|
-
const data = args[1];
|
|
858
|
-
await this.emit(`mitosis_child_complete`, {
|
|
859
|
-
parentId,
|
|
860
|
-
childId: args[2] || "unknown",
|
|
861
|
-
result: data
|
|
862
|
-
});
|
|
863
|
-
await this.emit(`${parentId}.mitosis_child_complete`, {
|
|
864
|
-
childId: args[2] || "unknown",
|
|
865
|
-
result: data
|
|
866
|
-
});
|
|
867
|
-
return { notified: parentId };
|
|
868
|
-
});
|
|
869
|
-
builtins.set("despawn", (args) => {
|
|
870
|
-
const target = String(args[0]);
|
|
871
|
-
if (this.context.hologramState.has(target)) {
|
|
872
|
-
const pos = this.context.spatialMemory.get(target) || { x: 0, y: 0, z: 0 };
|
|
873
|
-
this.createParticleEffect(`${target}_despawn`, pos, "#ff0000", 30);
|
|
874
|
-
this.context.hologramState.delete(target);
|
|
875
|
-
this.context.variables.delete(target);
|
|
876
|
-
this.context.spatialMemory.delete(target);
|
|
877
|
-
chunkILRBGFVD_cjs.logger.info("despawn", { target });
|
|
878
|
-
return { despawned: target };
|
|
879
|
-
}
|
|
880
|
-
return { msg: "Target not found", target };
|
|
881
|
-
});
|
|
882
|
-
builtins.set("move", (args) => {
|
|
883
|
-
const target = String(args[0]);
|
|
884
|
-
const position = args[1] || { x: 0, y: 0, z: 0 };
|
|
885
|
-
const current = this.context.spatialMemory.get(target);
|
|
886
|
-
if (current) {
|
|
887
|
-
this.context.spatialMemory.set(target, position);
|
|
888
|
-
this.createConnectionStream(target, `${target}_dest`, current, position, "move");
|
|
889
|
-
}
|
|
890
|
-
return { moved: target, to: position };
|
|
891
|
-
});
|
|
892
|
-
builtins.set("set", (args) => {
|
|
893
|
-
const target = String(args[0]);
|
|
894
|
-
const value = args[1];
|
|
895
|
-
this.setVariable(target, value);
|
|
896
|
-
return { set: target, value };
|
|
897
|
-
});
|
|
898
|
-
builtins.set("get", (args) => {
|
|
899
|
-
const target = String(args[0]);
|
|
900
|
-
return this.getVariable(target);
|
|
901
|
-
});
|
|
902
|
-
builtins.set("add", (args) => Number(args[0]) + Number(args[1]));
|
|
903
|
-
builtins.set("subtract", (args) => Number(args[0]) - Number(args[1]));
|
|
904
|
-
builtins.set("multiply", (args) => Number(args[0]) * Number(args[1]));
|
|
905
|
-
builtins.set(
|
|
906
|
-
"divide",
|
|
907
|
-
(args) => Number(args[1]) !== 0 ? Number(args[0]) / Number(args[1]) : 0
|
|
908
|
-
);
|
|
909
|
-
builtins.set("mod", (args) => Number(args[0]) % Number(args[1]));
|
|
910
|
-
builtins.set("abs", (args) => Math.abs(Number(args[0])));
|
|
911
|
-
builtins.set("floor", (args) => Math.floor(Number(args[0])));
|
|
912
|
-
builtins.set("ceil", (args) => Math.ceil(Number(args[0])));
|
|
913
|
-
builtins.set("round", (args) => Math.round(Number(args[0])));
|
|
914
|
-
builtins.set("min", (args) => Math.min(...args.map(Number)));
|
|
915
|
-
builtins.set("max", (args) => Math.max(...args.map(Number)));
|
|
916
|
-
builtins.set("random", () => Math.random());
|
|
917
|
-
builtins.set("concat", (args) => args.map(String).join(""));
|
|
918
|
-
builtins.set("length", (args) => {
|
|
919
|
-
const val = args[0];
|
|
920
|
-
if (typeof val === "string") return val.length;
|
|
921
|
-
if (Array.isArray(val)) return val.length;
|
|
922
|
-
return 0;
|
|
923
|
-
});
|
|
924
|
-
builtins.set(
|
|
925
|
-
"substring",
|
|
926
|
-
(args) => String(args[0]).substring(Number(args[1]), Number(args[2]))
|
|
927
|
-
);
|
|
928
|
-
builtins.set("wait", async (args) => {
|
|
929
|
-
const ms = Number(args[0]) || 0;
|
|
930
|
-
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
931
|
-
return { waited: ms };
|
|
932
|
-
});
|
|
933
|
-
builtins.set("print", (args) => {
|
|
934
|
-
console.log(`[HoloScript]`, ...args);
|
|
935
|
-
return { printed: args.join(" ") };
|
|
936
|
-
});
|
|
937
|
-
builtins.set("uppercase", (args) => String(args[0]).toUpperCase());
|
|
938
|
-
builtins.set("lowercase", (args) => String(args[0]).toLowerCase());
|
|
939
|
-
builtins.set("push", (args) => {
|
|
940
|
-
const arr = args[0];
|
|
941
|
-
if (Array.isArray(arr)) {
|
|
942
|
-
arr.push(args[1]);
|
|
943
|
-
return arr;
|
|
944
|
-
}
|
|
945
|
-
return [args[0], args[1]];
|
|
946
|
-
});
|
|
947
|
-
builtins.set("pop", (args) => {
|
|
948
|
-
const arr = args[0];
|
|
949
|
-
if (Array.isArray(arr)) return arr.pop();
|
|
950
|
-
return void 0;
|
|
951
|
-
});
|
|
952
|
-
builtins.set("at", (args) => {
|
|
953
|
-
const arr = args[0];
|
|
954
|
-
const index = Number(args[1]);
|
|
955
|
-
if (Array.isArray(arr)) return arr[index];
|
|
956
|
-
return void 0;
|
|
957
|
-
});
|
|
958
|
-
builtins.set("showSettings", () => {
|
|
959
|
-
this.emit("show-settings");
|
|
960
|
-
return true;
|
|
961
|
-
});
|
|
962
|
-
builtins.set("openChat", (args) => {
|
|
963
|
-
const config = args[0] || {};
|
|
964
|
-
this.emit("show-chat", config);
|
|
965
|
-
return true;
|
|
966
|
-
});
|
|
967
|
-
builtins.set("log", (args) => {
|
|
968
|
-
chunkILRBGFVD_cjs.logger.info("HoloScript log", { args });
|
|
969
|
-
return args[0];
|
|
970
|
-
});
|
|
971
|
-
builtins.set("print", (args) => {
|
|
972
|
-
const message = args.map(String).join(" ");
|
|
973
|
-
chunkILRBGFVD_cjs.logger.info("print", { message });
|
|
974
|
-
return message;
|
|
975
|
-
});
|
|
976
|
-
builtins.set("typeof", (args) => typeof args[0]);
|
|
977
|
-
builtins.set("isArray", (args) => Array.isArray(args[0]));
|
|
978
|
-
builtins.set(
|
|
979
|
-
"isNumber",
|
|
980
|
-
(args) => typeof args[0] === "number" && !isNaN(args[0])
|
|
981
|
-
);
|
|
982
|
-
builtins.set("isString", (args) => typeof args[0] === "string");
|
|
983
|
-
builtins.set("shop", (args) => this.handleShop(args));
|
|
984
|
-
builtins.set("inventory", (args) => this.handleInventory(args));
|
|
985
|
-
builtins.set("purchase", (args) => this.handlePurchase(args));
|
|
986
|
-
builtins.set("presence", (args) => this.handlePresence(args));
|
|
987
|
-
builtins.set("invite", (args) => this.handleInvite(args));
|
|
988
|
-
builtins.set("share", (args) => this.handleShare(args));
|
|
989
|
-
builtins.set("physics", (args) => this.handlePhysics(args));
|
|
990
|
-
builtins.set("gravity", (args) => this.handleGravity(args));
|
|
991
|
-
builtins.set("collide", (args) => this.handleCollide(args));
|
|
992
|
-
builtins.set("animate", (args) => this.handleAnimate(args));
|
|
993
|
-
builtins.set("calculate_arc", (args) => this.handleCalculateArc(args));
|
|
994
|
-
builtins.set(
|
|
995
|
-
"sleep",
|
|
996
|
-
(args) => new Promise((resolve) => setTimeout(resolve, Number(args[0]) || 0))
|
|
997
|
-
);
|
|
998
|
-
builtins.set("think", async (args) => {
|
|
999
|
-
const activeNode = this.context.executionStack[this.context.executionStack.length - 1];
|
|
1000
|
-
if (!activeNode) return "No context";
|
|
1001
|
-
const agentId = activeNode.name;
|
|
1002
|
-
const agentRuntime = this.agentRuntimes.get(agentId);
|
|
1003
|
-
if (agentRuntime) {
|
|
1004
|
-
return await agentRuntime.think(String(args[0] || ""));
|
|
1005
|
-
}
|
|
1006
|
-
return "Thinking only available for agents.";
|
|
1007
|
-
});
|
|
1008
|
-
return builtins;
|
|
1009
|
-
}
|
|
1010
|
-
/**
|
|
1011
|
-
* Register a global function from an extension
|
|
1012
|
-
*/
|
|
1013
|
-
registerGlobalFunction(name, fn) {
|
|
1014
|
-
this.context.functions.set(name, ((...spreadArgs) => fn(spreadArgs)));
|
|
1015
|
-
}
|
|
1016
|
-
/**
|
|
1017
|
-
* Register a custom trait from an extension
|
|
1018
|
-
*/
|
|
1019
|
-
registerTrait(name, handler) {
|
|
1020
|
-
const vrName = name;
|
|
1021
|
-
this.traitHandlers.set(vrName, handler);
|
|
1022
|
-
chunkILRBGFVD_cjs.logger.info(`Registered trait: ${name}`);
|
|
1023
|
-
}
|
|
1024
|
-
/**
|
|
1025
|
-
* Get the extension registry
|
|
1026
|
-
*/
|
|
1027
|
-
getExtensionRegistry() {
|
|
1028
|
-
return this.extensionRegistry;
|
|
1029
|
-
}
|
|
1030
|
-
/**
|
|
1031
|
-
* Execute a single AST node
|
|
1032
|
-
*/
|
|
1033
|
-
async executeNode(node) {
|
|
1034
|
-
const startTime = Date.now();
|
|
1035
|
-
try {
|
|
1036
|
-
this.context.executionStack.push(node);
|
|
1037
|
-
let result;
|
|
1038
|
-
const nodeType = node.type;
|
|
1039
|
-
switch (nodeType) {
|
|
1040
|
-
case "orb":
|
|
1041
|
-
case "object":
|
|
1042
|
-
result = await this.executeOrb(node);
|
|
1043
|
-
break;
|
|
1044
|
-
case "narrative":
|
|
1045
|
-
result = await this.executeNarrative(node);
|
|
1046
|
-
break;
|
|
1047
|
-
case "quest":
|
|
1048
|
-
result = await this.executeQuest(node);
|
|
1049
|
-
break;
|
|
1050
|
-
case "dialogue":
|
|
1051
|
-
result = await this.executeDialogue(node);
|
|
1052
|
-
break;
|
|
1053
|
-
case "visual_metadata":
|
|
1054
|
-
result = await this.executeVisualMetadata(node);
|
|
1055
|
-
break;
|
|
1056
|
-
case "method":
|
|
1057
|
-
case "function":
|
|
1058
|
-
result = await this.executeFunction(node);
|
|
1059
|
-
break;
|
|
1060
|
-
case "connection":
|
|
1061
|
-
result = await this.executeConnection(node);
|
|
1062
|
-
break;
|
|
1063
|
-
case "gate":
|
|
1064
|
-
result = await this.executeGate(node);
|
|
1065
|
-
break;
|
|
1066
|
-
case "stream":
|
|
1067
|
-
result = await this.executeStream(node);
|
|
1068
|
-
break;
|
|
1069
|
-
case "call":
|
|
1070
|
-
result = await this.executeCall(node);
|
|
1071
|
-
break;
|
|
1072
|
-
case "debug":
|
|
1073
|
-
result = await this.executeDebug(node);
|
|
1074
|
-
break;
|
|
1075
|
-
case "visualize":
|
|
1076
|
-
result = await this.executeVisualize(node);
|
|
1077
|
-
break;
|
|
1078
|
-
case "2d-element":
|
|
1079
|
-
result = await this.executeUIElement(node);
|
|
1080
|
-
break;
|
|
1081
|
-
case "nexus":
|
|
1082
|
-
case "building":
|
|
1083
|
-
result = await this.executeStructure(node);
|
|
1084
|
-
break;
|
|
1085
|
-
case "assignment":
|
|
1086
|
-
result = await this.executeAssignment(node);
|
|
1087
|
-
break;
|
|
1088
|
-
case "return":
|
|
1089
|
-
result = await this.executeReturn(node);
|
|
1090
|
-
break;
|
|
1091
|
-
case "memory":
|
|
1092
|
-
result = await this.executeMemory(node);
|
|
1093
|
-
break;
|
|
1094
|
-
case "semantic-memory":
|
|
1095
|
-
case "episodic-memory":
|
|
1096
|
-
case "procedural-memory":
|
|
1097
|
-
result = await this.executeMemoryDefinition(
|
|
1098
|
-
node
|
|
1099
|
-
);
|
|
1100
|
-
break;
|
|
1101
|
-
case "generic":
|
|
1102
|
-
result = await this.executeGeneric(node);
|
|
1103
|
-
break;
|
|
1104
|
-
case "expression-statement":
|
|
1105
|
-
result = await this.executeExpressionStatement(node);
|
|
1106
|
-
break;
|
|
1107
|
-
case "scale":
|
|
1108
|
-
result = await this.executeScale(node);
|
|
1109
|
-
break;
|
|
1110
|
-
case "focus":
|
|
1111
|
-
result = await this.executeFocus(node);
|
|
1112
|
-
break;
|
|
1113
|
-
case "environment":
|
|
1114
|
-
result = await this.executeEnvironment(node);
|
|
1115
|
-
break;
|
|
1116
|
-
case "composition":
|
|
1117
|
-
case "Composition":
|
|
1118
|
-
if (node.type === "Composition") {
|
|
1119
|
-
result = await this.executeHoloComposition(node);
|
|
1120
|
-
} else {
|
|
1121
|
-
result = await this.executeComposition(node);
|
|
1122
|
-
}
|
|
1123
|
-
break;
|
|
1124
|
-
case "template":
|
|
1125
|
-
case "Template":
|
|
1126
|
-
if (node.type === "Template") {
|
|
1127
|
-
result = await this.executeHoloTemplate(node);
|
|
1128
|
-
} else {
|
|
1129
|
-
result = await this.executeTemplate(node);
|
|
1130
|
-
}
|
|
1131
|
-
break;
|
|
1132
|
-
case "migration":
|
|
1133
|
-
result = { success: true, output: "Migration block registered" };
|
|
1134
|
-
break;
|
|
1135
|
-
case "server":
|
|
1136
|
-
result = await this.executeServerNode(node);
|
|
1137
|
-
break;
|
|
1138
|
-
case "database":
|
|
1139
|
-
result = await this.executeDatabaseNode(node);
|
|
1140
|
-
break;
|
|
1141
|
-
case "fetch":
|
|
1142
|
-
result = await this.executeFetchNode(node);
|
|
1143
|
-
break;
|
|
1144
|
-
case "execute":
|
|
1145
|
-
result = await this.executeTarget(node);
|
|
1146
|
-
break;
|
|
1147
|
-
case "state-declaration":
|
|
1148
|
-
result = await this.executeStateDeclaration(
|
|
1149
|
-
node
|
|
1150
|
-
);
|
|
1151
|
-
break;
|
|
1152
|
-
case "state-machine":
|
|
1153
|
-
result = await this.executeStateMachine(node);
|
|
1154
|
-
break;
|
|
1155
|
-
case "system":
|
|
1156
|
-
result = await this.executeSystem(node);
|
|
1157
|
-
break;
|
|
1158
|
-
case "core_config":
|
|
1159
|
-
result = await this.executeCoreConfig(node);
|
|
1160
|
-
break;
|
|
1161
|
-
case "for":
|
|
1162
|
-
result = await this.executeForLoop(
|
|
1163
|
-
node
|
|
1164
|
-
);
|
|
1165
|
-
break;
|
|
1166
|
-
case "forEach":
|
|
1167
|
-
result = await this.executeForEachLoop(
|
|
1168
|
-
node
|
|
1169
|
-
);
|
|
1170
|
-
break;
|
|
1171
|
-
case "while":
|
|
1172
|
-
result = await this.executeWhileLoop(
|
|
1173
|
-
node
|
|
1174
|
-
);
|
|
1175
|
-
break;
|
|
1176
|
-
case "if":
|
|
1177
|
-
result = await this.executeIfStatement(
|
|
1178
|
-
node
|
|
1179
|
-
);
|
|
1180
|
-
break;
|
|
1181
|
-
case "match":
|
|
1182
|
-
result = await this.executeMatch(
|
|
1183
|
-
node
|
|
1184
|
-
);
|
|
1185
|
-
break;
|
|
1186
|
-
default:
|
|
1187
|
-
result = {
|
|
1188
|
-
success: false,
|
|
1189
|
-
error: `Unknown node type: ${node.type}`,
|
|
1190
|
-
executionTime: Date.now() - startTime
|
|
1191
|
-
};
|
|
1192
|
-
}
|
|
1193
|
-
result.executionTime = Date.now() - startTime;
|
|
1194
|
-
this.executionHistory.push(result);
|
|
1195
|
-
this.context.executionStack.pop();
|
|
1196
|
-
return result;
|
|
1197
|
-
} catch (error) {
|
|
1198
|
-
const execTime = Date.now() - startTime;
|
|
1199
|
-
const errorResult = {
|
|
1200
|
-
success: false,
|
|
1201
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1202
|
-
executionTime: execTime
|
|
1203
|
-
};
|
|
1204
|
-
this.executionHistory.push(errorResult);
|
|
1205
|
-
this.context.executionStack.pop();
|
|
1206
|
-
return errorResult;
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
/**
|
|
1210
|
-
* Execute multiple nodes or a single node (unified entry point)
|
|
1211
|
-
*/
|
|
1212
|
-
async execute(nodes) {
|
|
1213
|
-
this.startTime = Date.now();
|
|
1214
|
-
this.nodeCount = 0;
|
|
1215
|
-
if (Array.isArray(nodes)) {
|
|
1216
|
-
const results = await this.executeProgram(nodes);
|
|
1217
|
-
const success = results.every((r) => r.success);
|
|
1218
|
-
const lastResult = results[results.length - 1];
|
|
1219
|
-
let output = success ? `Program executed (${results.length} nodes)` : "Program failed";
|
|
1220
|
-
if (lastResult && lastResult.success && lastResult.output !== void 0) {
|
|
1221
|
-
output = lastResult.output;
|
|
1222
|
-
}
|
|
1223
|
-
return {
|
|
1224
|
-
success,
|
|
1225
|
-
output,
|
|
1226
|
-
error: results.find((r) => !r.success)?.error
|
|
1227
|
-
};
|
|
1228
|
-
} else {
|
|
1229
|
-
return this.executeNode(nodes);
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
/**
|
|
1233
|
-
* Execute multiple nodes in sequence
|
|
1234
|
-
*/
|
|
1235
|
-
async executeProgram(nodes, depth = 0) {
|
|
1236
|
-
if (depth === 0) {
|
|
1237
|
-
this.startTime = Date.now();
|
|
1238
|
-
this.nodeCount = 0;
|
|
1239
|
-
}
|
|
1240
|
-
if (depth > RUNTIME_SECURITY_LIMITS.maxExecutionDepth) {
|
|
1241
|
-
chunkILRBGFVD_cjs.logger.error("Max execution depth exceeded", { depth });
|
|
1242
|
-
return [
|
|
1243
|
-
{
|
|
1244
|
-
success: false,
|
|
1245
|
-
error: `Max execution depth exceeded (${RUNTIME_SECURITY_LIMITS.maxExecutionDepth})`,
|
|
1246
|
-
executionTime: 0
|
|
1247
|
-
}
|
|
1248
|
-
];
|
|
1249
|
-
}
|
|
1250
|
-
const results = [];
|
|
1251
|
-
for (const node of nodes) {
|
|
1252
|
-
this.nodeCount++;
|
|
1253
|
-
if (this.nodeCount > RUNTIME_SECURITY_LIMITS.maxTotalNodes) {
|
|
1254
|
-
chunkILRBGFVD_cjs.logger.error("Max total nodes exceeded", { count: this.nodeCount });
|
|
1255
|
-
results.push({
|
|
1256
|
-
success: false,
|
|
1257
|
-
error: "Max total nodes exceeded",
|
|
1258
|
-
executionTime: Date.now() - this.startTime
|
|
1259
|
-
});
|
|
1260
|
-
break;
|
|
1261
|
-
}
|
|
1262
|
-
if (Date.now() - this.startTime > RUNTIME_SECURITY_LIMITS.maxExecutionTimeMs) {
|
|
1263
|
-
chunkILRBGFVD_cjs.logger.error("Execution timeout", { duration: Date.now() - this.startTime });
|
|
1264
|
-
results.push({
|
|
1265
|
-
success: false,
|
|
1266
|
-
error: "Execution timeout",
|
|
1267
|
-
executionTime: Date.now() - this.startTime
|
|
1268
|
-
});
|
|
1269
|
-
break;
|
|
1270
|
-
}
|
|
1271
|
-
const result = await this.executeNode(node);
|
|
1272
|
-
results.push(result);
|
|
1273
|
-
if (!result.success && node.type !== "visualize") {
|
|
1274
|
-
break;
|
|
1275
|
-
}
|
|
1276
|
-
if (node.type === "return") {
|
|
1277
|
-
break;
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
return results;
|
|
1281
|
-
}
|
|
1282
|
-
/**
|
|
1283
|
-
* Call a function with arguments
|
|
1284
|
-
*/
|
|
1285
|
-
async callFunction(name, args = []) {
|
|
1286
|
-
const builtin = this.builtinFunctions.get(name);
|
|
1287
|
-
if (builtin) {
|
|
1288
|
-
try {
|
|
1289
|
-
const result = await builtin(args);
|
|
1290
|
-
return {
|
|
1291
|
-
success: true,
|
|
1292
|
-
output: result
|
|
1293
|
-
};
|
|
1294
|
-
} catch (error) {
|
|
1295
|
-
return {
|
|
1296
|
-
success: false,
|
|
1297
|
-
error: `Built-in function ${name} failed: ${error}`
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
const func = this.context.functions.get(name);
|
|
1302
|
-
if (!func) {
|
|
1303
|
-
return {
|
|
1304
|
-
success: false,
|
|
1305
|
-
error: `Function '${name}' not found`
|
|
1306
|
-
};
|
|
1307
|
-
}
|
|
1308
|
-
if (typeof func === "function") {
|
|
1309
|
-
try {
|
|
1310
|
-
const result = await func(...args);
|
|
1311
|
-
return {
|
|
1312
|
-
success: true,
|
|
1313
|
-
output: result
|
|
1314
|
-
};
|
|
1315
|
-
} catch (error) {
|
|
1316
|
-
return {
|
|
1317
|
-
success: false,
|
|
1318
|
-
error: `Extension function ${name} failed: ${error}`
|
|
1319
|
-
};
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
if (this.callStack.length >= RUNTIME_SECURITY_LIMITS.maxCallStackDepth) {
|
|
1323
|
-
return {
|
|
1324
|
-
success: false,
|
|
1325
|
-
error: `Max call stack depth exceeded (${RUNTIME_SECURITY_LIMITS.maxCallStackDepth})`
|
|
1326
|
-
};
|
|
1327
|
-
}
|
|
1328
|
-
const parentScope = this.currentScope;
|
|
1329
|
-
this.currentScope = {
|
|
1330
|
-
variables: /* @__PURE__ */ new Map(),
|
|
1331
|
-
parent: parentScope
|
|
1332
|
-
};
|
|
1333
|
-
func.parameters.forEach((param, index) => {
|
|
1334
|
-
const value = index < args.length ? args[index] : param.defaultValue;
|
|
1335
|
-
this.currentScope.variables.set(param.name, value);
|
|
1336
|
-
});
|
|
1337
|
-
this.callStack.push(name);
|
|
1338
|
-
let returnValue = void 0;
|
|
1339
|
-
try {
|
|
1340
|
-
const results = await this.executeProgram(func.body, this.callStack.length);
|
|
1341
|
-
const lastResult = results[results.length - 1];
|
|
1342
|
-
if (lastResult?.output !== void 0) {
|
|
1343
|
-
returnValue = lastResult.output;
|
|
1344
|
-
}
|
|
1345
|
-
this.createExecutionEffect(name, func.position || { x: 0, y: 0, z: 0 });
|
|
1346
|
-
return {
|
|
1347
|
-
success: results.every((r) => r.success),
|
|
1348
|
-
output: returnValue,
|
|
1349
|
-
hologram: func.hologram,
|
|
1350
|
-
spatialPosition: func.position
|
|
1351
|
-
};
|
|
1352
|
-
} finally {
|
|
1353
|
-
this.currentScope = parentScope;
|
|
1354
|
-
this.callStack.pop();
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
/**
|
|
1358
|
-
* Set a variable in current scope
|
|
1359
|
-
*/
|
|
1360
|
-
setVariable(name, value, scopeOverride) {
|
|
1361
|
-
if (name.includes(".")) {
|
|
1362
|
-
const parts = name.split(".");
|
|
1363
|
-
const objName = parts[0];
|
|
1364
|
-
const propPath = parts.slice(1);
|
|
1365
|
-
let obj = this.getVariable(objName, scopeOverride);
|
|
1366
|
-
if (obj === void 0 || typeof obj !== "object" || obj === null) {
|
|
1367
|
-
obj = {};
|
|
1368
|
-
const scope = scopeOverride || this.currentScope;
|
|
1369
|
-
scope.variables.set(objName, obj);
|
|
1370
|
-
}
|
|
1371
|
-
let current = obj;
|
|
1372
|
-
for (let i = 0; i < propPath.length - 1; i++) {
|
|
1373
|
-
if (current[propPath[i]] === void 0 || typeof current[propPath[i]] !== "object") {
|
|
1374
|
-
current[propPath[i]] = {};
|
|
1375
|
-
}
|
|
1376
|
-
current = current[propPath[i]];
|
|
1377
|
-
}
|
|
1378
|
-
current[propPath[propPath.length - 1]] = value;
|
|
1379
|
-
} else {
|
|
1380
|
-
const scope = scopeOverride || this.currentScope;
|
|
1381
|
-
scope.variables.set(name, value);
|
|
1382
|
-
}
|
|
1383
|
-
if (this.wss && typeof value === "object" && value !== null && value.__type === "orb") {
|
|
1384
|
-
this.broadcast("orb_update", { orb: value });
|
|
1385
|
-
} else if (this.wss && name.includes(".")) {
|
|
1386
|
-
const root = name.split(".")[0];
|
|
1387
|
-
const rootVar = this.getVariable(root, scopeOverride);
|
|
1388
|
-
if (rootVar && typeof rootVar === "object" && rootVar.__type === "orb") {
|
|
1389
|
-
this.broadcast("orb_update", { orb: rootVar });
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
/**
|
|
1394
|
-
* Get a variable from scope chain
|
|
1395
|
-
*/
|
|
1396
|
-
getVariable(name, scopeOverride) {
|
|
1397
|
-
if (name.includes(".")) {
|
|
1398
|
-
const parts = name.split(".");
|
|
1399
|
-
let value = this.getVariable(parts[0], scopeOverride);
|
|
1400
|
-
for (let i = 1; i < parts.length && value !== void 0; i++) {
|
|
1401
|
-
if (typeof value === "object" && value !== null) {
|
|
1402
|
-
value = value[parts[i]];
|
|
1403
|
-
} else {
|
|
1404
|
-
return void 0;
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
return value;
|
|
1408
|
-
}
|
|
1409
|
-
let scope = scopeOverride || this.currentScope;
|
|
1410
|
-
while (scope) {
|
|
1411
|
-
if (scope.variables.has(name)) {
|
|
1412
|
-
return scope.variables.get(name);
|
|
1413
|
-
}
|
|
1414
|
-
scope = scope.parent;
|
|
1415
|
-
}
|
|
1416
|
-
if (this.context.variables.has(name)) {
|
|
1417
|
-
return this.context.variables.get(name);
|
|
1418
|
-
}
|
|
1419
|
-
if (this.context.functions.has(name)) {
|
|
1420
|
-
return this.context.functions.get(name);
|
|
1421
|
-
}
|
|
1422
|
-
return void 0;
|
|
1423
|
-
}
|
|
1424
|
-
/**
|
|
1425
|
-
* Evaluate an expression in current context
|
|
1426
|
-
*/
|
|
1427
|
-
evaluateExpression(expr) {
|
|
1428
|
-
if (!expr || typeof expr !== "string") return expr;
|
|
1429
|
-
const evaluator = new ExpressionEvaluator(this.context.state.getSnapshot());
|
|
1430
|
-
const varContext = {};
|
|
1431
|
-
this.context.variables.forEach((v, k) => varContext[k] = v);
|
|
1432
|
-
evaluator.updateContext(varContext);
|
|
1433
|
-
return evaluator.evaluate(expr);
|
|
1434
|
-
}
|
|
1435
|
-
// ============================================================================
|
|
1436
|
-
// Node Executors
|
|
1437
|
-
// ============================================================================
|
|
1438
|
-
async executeOrb(node) {
|
|
1439
|
-
const scale = this.context.currentScale || 1;
|
|
1440
|
-
const existingRaw = this.context.variables.get(node.name);
|
|
1441
|
-
const existingOrb = isOrbData(existingRaw) ? existingRaw : void 0;
|
|
1442
|
-
const isUpdate = !!existingOrb;
|
|
1443
|
-
let pos = { x: 0, y: 0, z: 0 };
|
|
1444
|
-
if (Array.isArray(node.position)) {
|
|
1445
|
-
pos = {
|
|
1446
|
-
x: Number(node.position[0]) || 0,
|
|
1447
|
-
y: Number(node.position[1]) || 0,
|
|
1448
|
-
z: Number(node.position[2]) || 0
|
|
1449
|
-
};
|
|
1450
|
-
} else if (node.position) {
|
|
1451
|
-
pos = {
|
|
1452
|
-
x: Number(node.position.x) || 0,
|
|
1453
|
-
y: Number(node.position.y) || 0,
|
|
1454
|
-
z: Number(node.position.z) || 0
|
|
1455
|
-
};
|
|
1456
|
-
}
|
|
1457
|
-
const adjustedPos = {
|
|
1458
|
-
x: pos.x * scale,
|
|
1459
|
-
y: pos.y * scale,
|
|
1460
|
-
z: pos.z * scale
|
|
1461
|
-
};
|
|
1462
|
-
if (node.position) {
|
|
1463
|
-
this.context.spatialMemory.set(node.name, adjustedPos);
|
|
1464
|
-
}
|
|
1465
|
-
const evaluatedProperties = {};
|
|
1466
|
-
if (Array.isArray(node.properties)) {
|
|
1467
|
-
for (const prop of node.properties) {
|
|
1468
|
-
const key = prop.key;
|
|
1469
|
-
const val = prop.value;
|
|
1470
|
-
if (typeof val === "string") {
|
|
1471
|
-
evaluatedProperties[key] = this.evaluateExpression(val);
|
|
1472
|
-
} else {
|
|
1473
|
-
evaluatedProperties[key] = val;
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
} else if (node.properties) {
|
|
1477
|
-
for (const [key, val] of Object.entries(node.properties)) {
|
|
1478
|
-
if (typeof val === "string") {
|
|
1479
|
-
evaluatedProperties[key] = this.evaluateExpression(val);
|
|
1480
|
-
} else {
|
|
1481
|
-
evaluatedProperties[key] = val;
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
const orbNodeExt = node;
|
|
1486
|
-
if (orbNodeExt.template) {
|
|
1487
|
-
const tpl = this.context.templates.get(orbNodeExt.template);
|
|
1488
|
-
if (tpl) {
|
|
1489
|
-
if (tpl.properties) {
|
|
1490
|
-
for (const [key, val] of Object.entries(tpl.properties)) {
|
|
1491
|
-
if (evaluatedProperties[key] === void 0) {
|
|
1492
|
-
if (typeof val === "string") {
|
|
1493
|
-
evaluatedProperties[key] = this.evaluateExpression(val);
|
|
1494
|
-
} else {
|
|
1495
|
-
evaluatedProperties[key] = val;
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
if (tpl.directives) {
|
|
1501
|
-
const existingDirectives = node.directives || [];
|
|
1502
|
-
node.directives = [...tpl.directives, ...existingDirectives];
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
const hologram = node.hologram ? {
|
|
1507
|
-
...node.hologram,
|
|
1508
|
-
size: (node.hologram.size || Number(evaluatedProperties.size) || Number(evaluatedProperties.scale) || 1) * scale
|
|
1509
|
-
} : {
|
|
1510
|
-
color: evaluatedProperties.color || "#ffffff",
|
|
1511
|
-
size: (Number(evaluatedProperties.size) || Number(evaluatedProperties.scale) || 1) * scale,
|
|
1512
|
-
shape: evaluatedProperties.geometry || "sphere",
|
|
1513
|
-
glow: !!evaluatedProperties.glow,
|
|
1514
|
-
interactive: !!evaluatedProperties.interactive
|
|
1515
|
-
};
|
|
1516
|
-
if (isUpdate && node.template) {
|
|
1517
|
-
const tpl = this.context.templates.get(node.template);
|
|
1518
|
-
const oldTpl = existingOrb?._templateRef;
|
|
1519
|
-
if (tpl && oldTpl && tpl.version !== void 0 && oldTpl.version !== void 0) {
|
|
1520
|
-
if (Number(tpl.version) > Number(oldTpl.version)) {
|
|
1521
|
-
chunkILRBGFVD_cjs.logger.info(
|
|
1522
|
-
`Template version increase detected for ${node.name}: ${oldTpl.version} -> ${tpl.version}`
|
|
1523
|
-
);
|
|
1524
|
-
const migrations = tpl.migrations || [];
|
|
1525
|
-
const migration = migrations.find((m) => m.fromVersion === Number(oldTpl.version));
|
|
1526
|
-
if (migration) {
|
|
1527
|
-
chunkILRBGFVD_cjs.logger.info(`Executing migration from version ${oldTpl.version} for ${node.name}`);
|
|
1528
|
-
await this.executeMigrationBlock(existingOrb, migration);
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
const orbData = isUpdate ? existingOrb : {
|
|
1534
|
-
__type: "orb",
|
|
1535
|
-
id: node.name,
|
|
1536
|
-
name: node.name,
|
|
1537
|
-
created: Date.now(),
|
|
1538
|
-
// Methods bound to this orb
|
|
1539
|
-
show: () => this.builtinFunctions.get("show")([node.name]),
|
|
1540
|
-
hide: () => this.builtinFunctions.get("hide")([node.name]),
|
|
1541
|
-
pulse: (opts) => this.builtinFunctions.get("pulse")([node.name, opts])
|
|
1542
|
-
};
|
|
1543
|
-
if (isUpdate) {
|
|
1544
|
-
orbData.properties = {
|
|
1545
|
-
// @ts-expect-error During migration
|
|
1546
|
-
...orbData.properties,
|
|
1547
|
-
...evaluatedProperties
|
|
1548
|
-
};
|
|
1549
|
-
} else {
|
|
1550
|
-
orbData.properties = evaluatedProperties;
|
|
1551
|
-
}
|
|
1552
|
-
orbData.directives = node.directives || [];
|
|
1553
|
-
orbData.position = adjustedPos;
|
|
1554
|
-
orbData.hologram = hologram;
|
|
1555
|
-
orbData._templateRef = node.template ? this.context.templates.get(node.template) : void 0;
|
|
1556
|
-
if (!isUpdate) {
|
|
1557
|
-
this.context.variables.set(node.name, orbData);
|
|
1558
|
-
}
|
|
1559
|
-
if (hologram) {
|
|
1560
|
-
this.context.hologramState.set(node.name, hologram);
|
|
1561
|
-
}
|
|
1562
|
-
if (node.directives) {
|
|
1563
|
-
this.applyDirectives(orbData);
|
|
1564
|
-
}
|
|
1565
|
-
if (!isUpdate) {
|
|
1566
|
-
this.createParticleEffect(`${node.name}_creation`, adjustedPos, "#00ffff", 20);
|
|
1567
|
-
}
|
|
1568
|
-
if (this.isAgent(node)) {
|
|
1569
|
-
if (!isUpdate || !this.agentRuntimes.has(node.name)) {
|
|
1570
|
-
const agentRuntime = this.agentPool.acquire();
|
|
1571
|
-
agentRuntime.reset(node, this);
|
|
1572
|
-
this.agentRuntimes.set(node.name, agentRuntime);
|
|
1573
|
-
orbData.state = agentRuntime.getState();
|
|
1574
|
-
node.directives?.filter((d) => d.type === "method").forEach((m) => {
|
|
1575
|
-
orbData[m.name] = (...args) => agentRuntime.executeAction(m.name, args);
|
|
1576
|
-
});
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
chunkILRBGFVD_cjs.logger.info(isUpdate ? "Orb updated" : "Orb created", {
|
|
1580
|
-
name: node.name,
|
|
1581
|
-
// @ts-expect-error During migration
|
|
1582
|
-
properties: Object.keys(orbData.properties),
|
|
1583
|
-
scale
|
|
1584
|
-
});
|
|
1585
|
-
this.broadcast(isUpdate ? "orb_updated" : "orb_created", {
|
|
1586
|
-
orb: {
|
|
1587
|
-
id: node.name,
|
|
1588
|
-
name: node.name,
|
|
1589
|
-
position: adjustedPos,
|
|
1590
|
-
// @ts-expect-error During migration
|
|
1591
|
-
properties: orbData.properties,
|
|
1592
|
-
hologram,
|
|
1593
|
-
traits: node.directives?.filter((d) => d.type === "trait").map((d) => d.name) || []
|
|
1594
|
-
}
|
|
1595
|
-
});
|
|
1596
|
-
return {
|
|
1597
|
-
success: true,
|
|
1598
|
-
output: orbData,
|
|
1599
|
-
hologram,
|
|
1600
|
-
spatialPosition: adjustedPos
|
|
1601
|
-
};
|
|
1602
|
-
}
|
|
1603
|
-
async executeFunction(node) {
|
|
1604
|
-
this.context.functions.set(node.name, node);
|
|
1605
|
-
const hologram = {
|
|
1606
|
-
shape: "cube",
|
|
1607
|
-
color: "#ff6b35",
|
|
1608
|
-
size: 1.5,
|
|
1609
|
-
glow: true,
|
|
1610
|
-
interactive: true,
|
|
1611
|
-
...node.hologram
|
|
1612
|
-
};
|
|
1613
|
-
this.context.hologramState.set(node.name, hologram);
|
|
1614
|
-
chunkILRBGFVD_cjs.logger.info("Function defined", {
|
|
1615
|
-
name: node.name,
|
|
1616
|
-
params: node.parameters.map((p) => p.name)
|
|
1617
|
-
});
|
|
1618
|
-
return {
|
|
1619
|
-
success: true,
|
|
1620
|
-
output: `Function '${node.name}' defined with ${node.parameters.length} parameter(s)`,
|
|
1621
|
-
hologram,
|
|
1622
|
-
spatialPosition: node.position
|
|
1623
|
-
};
|
|
1624
|
-
}
|
|
1625
|
-
async executeConnection(node) {
|
|
1626
|
-
this.context.connections.push(node);
|
|
1627
|
-
const fromPos = this.context.spatialMemory.get(node.from);
|
|
1628
|
-
const toPos = this.context.spatialMemory.get(node.to);
|
|
1629
|
-
if (fromPos && toPos) {
|
|
1630
|
-
this.createConnectionStream(node.from, node.to, fromPos, toPos, node.dataType);
|
|
1631
|
-
}
|
|
1632
|
-
if (node.bidirectional) {
|
|
1633
|
-
this.on(`${node.from}.changed`, async (data) => {
|
|
1634
|
-
this.setVariable(node.to, data);
|
|
1635
|
-
this.emit(`${node.to}.changed`, data);
|
|
1636
|
-
});
|
|
1637
|
-
this.on(`${node.to}.changed`, async (data) => {
|
|
1638
|
-
this.setVariable(node.from, data);
|
|
1639
|
-
this.emit(`${node.from}.changed`, data);
|
|
1640
|
-
});
|
|
1641
|
-
}
|
|
1642
|
-
chunkILRBGFVD_cjs.logger.info("Connection created", { from: node.from, to: node.to, dataType: node.dataType });
|
|
1643
|
-
return {
|
|
1644
|
-
success: true,
|
|
1645
|
-
output: `Connected '${node.from}' to '${node.to}' (${node.dataType})`,
|
|
1646
|
-
hologram: {
|
|
1647
|
-
shape: "cylinder",
|
|
1648
|
-
color: this.getDataTypeColor(node.dataType),
|
|
1649
|
-
size: 0.1,
|
|
1650
|
-
glow: true,
|
|
1651
|
-
interactive: false
|
|
1652
|
-
}
|
|
1653
|
-
};
|
|
1654
|
-
}
|
|
1655
|
-
async executeGate(node) {
|
|
1656
|
-
try {
|
|
1657
|
-
const condition = this.evaluateCondition(node.condition);
|
|
1658
|
-
const path = condition ? node.truePath : node.falsePath;
|
|
1659
|
-
chunkILRBGFVD_cjs.logger.info("Gate evaluation", { condition: node.condition, result: condition });
|
|
1660
|
-
if (path.length > 0) {
|
|
1661
|
-
const subResults = await this.executeProgram(path, this.callStack.length + 1);
|
|
1662
|
-
const lastResult = subResults[subResults.length - 1];
|
|
1663
|
-
if (lastResult && lastResult.success && lastResult.output !== void 0) {
|
|
1664
|
-
return lastResult;
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
return {
|
|
1668
|
-
success: true,
|
|
1669
|
-
output: `Gate: took ${condition ? "true" : "false"} path`,
|
|
1670
|
-
hologram: {
|
|
1671
|
-
shape: "pyramid",
|
|
1672
|
-
color: condition ? "#00ff00" : "#ff0000",
|
|
1673
|
-
size: 1,
|
|
1674
|
-
glow: true,
|
|
1675
|
-
interactive: true
|
|
1676
|
-
}
|
|
1677
|
-
};
|
|
1678
|
-
} catch (error) {
|
|
1679
|
-
return {
|
|
1680
|
-
success: false,
|
|
1681
|
-
error: `Gate execution failed: ${error}`
|
|
1682
|
-
};
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
async executeStream(node) {
|
|
1686
|
-
let data = this.getVariable(node.source);
|
|
1687
|
-
chunkILRBGFVD_cjs.logger.info("Stream processing", {
|
|
1688
|
-
name: node.name,
|
|
1689
|
-
source: node.source,
|
|
1690
|
-
transforms: node.transformations.length
|
|
1691
|
-
});
|
|
1692
|
-
for (const transform of node.transformations) {
|
|
1693
|
-
data = await this.applyTransformation(data, transform);
|
|
1694
|
-
}
|
|
1695
|
-
this.setVariable(`${node.name}_result`, data);
|
|
1696
|
-
this.createFlowingStream(node.name, node.position || { x: 0, y: 0, z: 0 }, data);
|
|
1697
|
-
return {
|
|
1698
|
-
success: true,
|
|
1699
|
-
output: `Stream '${node.name}' processed ${Array.isArray(data) ? data.length : 1} item(s)`,
|
|
1700
|
-
hologram: node.hologram,
|
|
1701
|
-
spatialPosition: node.position
|
|
1702
|
-
};
|
|
1703
|
-
}
|
|
1704
|
-
/**
|
|
1705
|
-
* Execute State Machine declaration (Phase 13)
|
|
1706
|
-
*/
|
|
1707
|
-
async executeStateMachine(node) {
|
|
1708
|
-
this.context.stateMachines.set(node.name, node);
|
|
1709
|
-
chunkILRBGFVD_cjs.logger.info(`State machine registered: ${node.name}`);
|
|
1710
|
-
return {
|
|
1711
|
-
success: true,
|
|
1712
|
-
output: { registered: node.name }
|
|
1713
|
-
};
|
|
1714
|
-
}
|
|
1715
|
-
async executeExpressionStatement(node) {
|
|
1716
|
-
const value = this.evaluateExpression(node.expression);
|
|
1717
|
-
return {
|
|
1718
|
-
success: true,
|
|
1719
|
-
output: value
|
|
1720
|
-
};
|
|
1721
|
-
}
|
|
1722
|
-
async executeCall(node) {
|
|
1723
|
-
const funcName = node.target || "";
|
|
1724
|
-
const args = node.args || [];
|
|
1725
|
-
return this.callFunction(funcName, args);
|
|
1726
|
-
}
|
|
1727
|
-
async executeDebug(node) {
|
|
1728
|
-
const debugInfo = {
|
|
1729
|
-
variables: Object.fromEntries(this.currentScope.variables),
|
|
1730
|
-
contextVariables: Object.fromEntries(this.context.variables),
|
|
1731
|
-
functions: Array.from(this.context.functions.keys()),
|
|
1732
|
-
connections: this.context.connections.length,
|
|
1733
|
-
callStack: [...this.callStack],
|
|
1734
|
-
uiElements: Array.from(this.uiElements.keys()),
|
|
1735
|
-
animations: Array.from(this.animations.keys()),
|
|
1736
|
-
executionHistory: this.executionHistory.slice(-10)
|
|
1737
|
-
};
|
|
1738
|
-
const debugOrb = {
|
|
1739
|
-
shape: "pyramid",
|
|
1740
|
-
color: "#ff1493",
|
|
1741
|
-
size: 0.8,
|
|
1742
|
-
glow: true,
|
|
1743
|
-
interactive: true
|
|
1744
|
-
};
|
|
1745
|
-
this.context.hologramState.set(`debug_${node.target || "program"}`, debugOrb);
|
|
1746
|
-
chunkILRBGFVD_cjs.logger.info("Debug info", debugInfo);
|
|
1747
|
-
return {
|
|
1748
|
-
success: true,
|
|
1749
|
-
output: debugInfo,
|
|
1750
|
-
hologram: debugOrb
|
|
1751
|
-
};
|
|
1752
|
-
}
|
|
1753
|
-
async executeVisualize(node) {
|
|
1754
|
-
const target = node.target || "";
|
|
1755
|
-
const data = this.getVariable(target);
|
|
1756
|
-
if (data === void 0) {
|
|
1757
|
-
return {
|
|
1758
|
-
success: false,
|
|
1759
|
-
error: `No data found for '${target}'`
|
|
1760
|
-
};
|
|
1761
|
-
}
|
|
1762
|
-
const visHologram = {
|
|
1763
|
-
shape: "cylinder",
|
|
1764
|
-
color: "#32cd32",
|
|
1765
|
-
size: 1.5,
|
|
1766
|
-
glow: true,
|
|
1767
|
-
interactive: true
|
|
1768
|
-
};
|
|
1769
|
-
this.createDataVisualization(target, data, node.position || { x: 0, y: 0, z: 0 });
|
|
1770
|
-
return {
|
|
1771
|
-
success: true,
|
|
1772
|
-
output: { visualizing: target, data },
|
|
1773
|
-
hologram: visHologram
|
|
1774
|
-
};
|
|
1775
|
-
}
|
|
1776
|
-
async executeUIElement(node) {
|
|
1777
|
-
const element = {
|
|
1778
|
-
type: node.elementType,
|
|
1779
|
-
name: node.name,
|
|
1780
|
-
properties: { ...node.properties },
|
|
1781
|
-
visible: true,
|
|
1782
|
-
enabled: true
|
|
1783
|
-
};
|
|
1784
|
-
if (node.elementType === "textinput") {
|
|
1785
|
-
element.value = node.properties.value || "";
|
|
1786
|
-
} else if (node.elementType === "slider") {
|
|
1787
|
-
element.value = node.properties.value || node.properties.min || 0;
|
|
1788
|
-
} else if (node.elementType === "toggle") {
|
|
1789
|
-
element.value = node.properties.checked || false;
|
|
1790
|
-
}
|
|
1791
|
-
this.uiElements.set(node.name, element);
|
|
1792
|
-
if (node.events) {
|
|
1793
|
-
for (const [eventName, handlerName] of Object.entries(node.events)) {
|
|
1794
|
-
this.on(`${node.name}.${eventName}`, async () => {
|
|
1795
|
-
await this.callFunction(handlerName);
|
|
1796
|
-
});
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
chunkILRBGFVD_cjs.logger.info("UI element created", { type: node.elementType, name: node.name });
|
|
1800
|
-
return {
|
|
1801
|
-
success: true,
|
|
1802
|
-
output: element
|
|
1803
|
-
};
|
|
1804
|
-
}
|
|
1805
|
-
/**
|
|
1806
|
-
* Execute generic voice commands
|
|
1807
|
-
* Handles commands like: show, hide, animate, pulse, create
|
|
1808
|
-
*/
|
|
1809
|
-
async executeGeneric(_node) {
|
|
1810
|
-
const genericNode = _node;
|
|
1811
|
-
const command = String(genericNode.command || "").trim().toLowerCase();
|
|
1812
|
-
const tokens = command.split(/\s+/);
|
|
1813
|
-
const action = tokens[0];
|
|
1814
|
-
const target = tokens[1];
|
|
1815
|
-
chunkILRBGFVD_cjs.logger.info("Executing generic command", { command, action, target });
|
|
1816
|
-
try {
|
|
1817
|
-
let result;
|
|
1818
|
-
switch (action) {
|
|
1819
|
-
case "show":
|
|
1820
|
-
result = await this.executeShowCommand(target, genericNode);
|
|
1821
|
-
break;
|
|
1822
|
-
case "hide":
|
|
1823
|
-
result = await this.executeHideCommand(target, genericNode);
|
|
1824
|
-
break;
|
|
1825
|
-
case "create":
|
|
1826
|
-
case "summon":
|
|
1827
|
-
result = await this.executeCreateCommand(tokens.slice(1), genericNode);
|
|
1828
|
-
break;
|
|
1829
|
-
case "animate":
|
|
1830
|
-
result = await this.executeAnimateCommand(target, tokens.slice(2), genericNode);
|
|
1831
|
-
break;
|
|
1832
|
-
case "pulse":
|
|
1833
|
-
result = await this.executePulseCommand(target, tokens.slice(2), genericNode);
|
|
1834
|
-
break;
|
|
1835
|
-
case "move":
|
|
1836
|
-
result = await this.executeMoveCommand(target, tokens.slice(2), genericNode);
|
|
1837
|
-
break;
|
|
1838
|
-
case "delete":
|
|
1839
|
-
case "remove":
|
|
1840
|
-
result = await this.executeDeleteCommand(target, genericNode);
|
|
1841
|
-
break;
|
|
1842
|
-
default:
|
|
1843
|
-
chunkILRBGFVD_cjs.logger.warn("Unknown voice command action", { action, command });
|
|
1844
|
-
result = {
|
|
1845
|
-
executed: false,
|
|
1846
|
-
message: `Unknown command: ${action}`
|
|
1847
|
-
};
|
|
1848
|
-
}
|
|
1849
|
-
return {
|
|
1850
|
-
success: true,
|
|
1851
|
-
output: result
|
|
1852
|
-
};
|
|
1853
|
-
} catch (error) {
|
|
1854
|
-
return {
|
|
1855
|
-
success: false,
|
|
1856
|
-
error: `Generic command execution failed: ${String(error)}`
|
|
1857
|
-
};
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
/**
|
|
1861
|
-
* Execute 'show' command
|
|
1862
|
-
*/
|
|
1863
|
-
async executeShowCommand(target, _node) {
|
|
1864
|
-
const hologram = _node.hologram || {
|
|
1865
|
-
shape: "orb",
|
|
1866
|
-
color: "#00ffff",
|
|
1867
|
-
size: 0.8,
|
|
1868
|
-
glow: true,
|
|
1869
|
-
interactive: true
|
|
1870
|
-
};
|
|
1871
|
-
const position = _node.position || { x: 0, y: 0, z: 0 };
|
|
1872
|
-
this.context.spatialMemory.set(target, position);
|
|
1873
|
-
this.createParticleEffect(`${target}_show`, position, hologram.color, 15);
|
|
1874
|
-
chunkILRBGFVD_cjs.logger.info("Show command executed", { target, position });
|
|
1875
|
-
return {
|
|
1876
|
-
showed: target,
|
|
1877
|
-
hologram,
|
|
1878
|
-
position
|
|
1879
|
-
};
|
|
1880
|
-
}
|
|
1881
|
-
/**
|
|
1882
|
-
* Execute 'hide' command
|
|
1883
|
-
*/
|
|
1884
|
-
async executeHideCommand(target, _node) {
|
|
1885
|
-
const position = this.context.spatialMemory.get(target) || { x: 0, y: 0, z: 0 };
|
|
1886
|
-
this.createParticleEffect(`${target}_hide`, position, "#ff0000", 10);
|
|
1887
|
-
chunkILRBGFVD_cjs.logger.info("Hide command executed", { target });
|
|
1888
|
-
return {
|
|
1889
|
-
hidden: target
|
|
1890
|
-
};
|
|
1891
|
-
}
|
|
1892
|
-
/**
|
|
1893
|
-
* Execute 'create' command
|
|
1894
|
-
*/
|
|
1895
|
-
async executeCreateCommand(tokens, _node) {
|
|
1896
|
-
if (tokens.length < 2) {
|
|
1897
|
-
return { error: "Create command requires shape and name" };
|
|
1898
|
-
}
|
|
1899
|
-
const shape = tokens[0];
|
|
1900
|
-
const name = tokens[1];
|
|
1901
|
-
const position = _node.position || { x: 0, y: 0, z: 0 };
|
|
1902
|
-
const hologram = {
|
|
1903
|
-
shape,
|
|
1904
|
-
color: _node.hologram?.color || "#00ffff",
|
|
1905
|
-
size: _node.hologram?.size || 1,
|
|
1906
|
-
glow: _node.hologram?.glow !== false,
|
|
1907
|
-
interactive: _node.hologram?.interactive !== false
|
|
1908
|
-
};
|
|
1909
|
-
this.context.spatialMemory.set(name, position);
|
|
1910
|
-
this.createParticleEffect(`${name}_create`, position, hologram.color, 20);
|
|
1911
|
-
chunkILRBGFVD_cjs.logger.info("Create command executed", { shape, name, position });
|
|
1912
|
-
return {
|
|
1913
|
-
created: name,
|
|
1914
|
-
shape,
|
|
1915
|
-
hologram,
|
|
1916
|
-
position
|
|
1917
|
-
};
|
|
1918
|
-
}
|
|
1919
|
-
/**
|
|
1920
|
-
* Execute 'animate' command
|
|
1921
|
-
*/
|
|
1922
|
-
async executeAnimateCommand(target, tokens, _node) {
|
|
1923
|
-
const property = tokens[0] || "position.y";
|
|
1924
|
-
const duration = parseInt(tokens[1] || "1000", 10);
|
|
1925
|
-
const animation = {
|
|
1926
|
-
target,
|
|
1927
|
-
property,
|
|
1928
|
-
from: 0,
|
|
1929
|
-
to: 1,
|
|
1930
|
-
duration,
|
|
1931
|
-
startTime: Date.now(),
|
|
1932
|
-
easing: "ease-in-out"
|
|
1933
|
-
};
|
|
1934
|
-
this.animations.set(`${target}_${property}`, animation);
|
|
1935
|
-
chunkILRBGFVD_cjs.logger.info("Animate command executed", { target, property, duration });
|
|
1936
|
-
return {
|
|
1937
|
-
animating: target,
|
|
1938
|
-
animation
|
|
1939
|
-
};
|
|
1940
|
-
}
|
|
1941
|
-
/**
|
|
1942
|
-
* Execute 'pulse' command
|
|
1943
|
-
*/
|
|
1944
|
-
async executePulseCommand(target, tokens, _node) {
|
|
1945
|
-
const duration = parseInt(tokens[0] || "500", 10);
|
|
1946
|
-
const position = this.context.spatialMemory.get(target) || { x: 0, y: 0, z: 0 };
|
|
1947
|
-
this.createParticleEffect(`${target}_pulse`, position, "#ffff00", 30);
|
|
1948
|
-
const animation = {
|
|
1949
|
-
target,
|
|
1950
|
-
property: "scale",
|
|
1951
|
-
from: 1,
|
|
1952
|
-
to: 1.5,
|
|
1953
|
-
duration,
|
|
1954
|
-
startTime: Date.now(),
|
|
1955
|
-
easing: "sine",
|
|
1956
|
-
yoyo: true,
|
|
1957
|
-
loop: true
|
|
1958
|
-
};
|
|
1959
|
-
this.animations.set(`${target}_pulse`, animation);
|
|
1960
|
-
chunkILRBGFVD_cjs.logger.info("Pulse command executed", { target, duration });
|
|
1961
|
-
return {
|
|
1962
|
-
pulsing: target,
|
|
1963
|
-
duration
|
|
1964
|
-
};
|
|
1965
|
-
}
|
|
1966
|
-
/**
|
|
1967
|
-
* Execute 'move' command
|
|
1968
|
-
*/
|
|
1969
|
-
async executeMoveCommand(target, tokens, _node) {
|
|
1970
|
-
const x = parseFloat(tokens[0] || "0");
|
|
1971
|
-
const y = parseFloat(tokens[1] || "0");
|
|
1972
|
-
const z = parseFloat(tokens[2] || "0");
|
|
1973
|
-
const position = { x, y, z };
|
|
1974
|
-
const current = this.context.spatialMemory.get(target);
|
|
1975
|
-
if (current) {
|
|
1976
|
-
this.context.spatialMemory.set(target, position);
|
|
1977
|
-
this.createConnectionStream(target, `${target}_move`, current, position, "movement");
|
|
1978
|
-
} else {
|
|
1979
|
-
this.context.spatialMemory.set(target, position);
|
|
1980
|
-
}
|
|
1981
|
-
chunkILRBGFVD_cjs.logger.info("Move command executed", { target, position });
|
|
1982
|
-
return {
|
|
1983
|
-
moved: target,
|
|
1984
|
-
to: position
|
|
1985
|
-
};
|
|
1986
|
-
}
|
|
1987
|
-
/**
|
|
1988
|
-
* Execute 'delete' command
|
|
1989
|
-
*/
|
|
1990
|
-
async executeDeleteCommand(target, _node) {
|
|
1991
|
-
const position = this.context.spatialMemory.get(target);
|
|
1992
|
-
if (position) {
|
|
1993
|
-
this.createParticleEffect(`${target}_delete`, position, "#ff0000", 15);
|
|
1994
|
-
this.context.spatialMemory.delete(target);
|
|
1995
|
-
}
|
|
1996
|
-
chunkILRBGFVD_cjs.logger.info("Delete command executed", { target });
|
|
1997
|
-
return {
|
|
1998
|
-
deleted: target
|
|
1999
|
-
};
|
|
2000
|
-
}
|
|
2001
|
-
async executeStructure(node) {
|
|
2002
|
-
const hologram = node.hologram || {
|
|
2003
|
-
shape: node.type === "nexus" ? "sphere" : "cube",
|
|
2004
|
-
color: node.type === "nexus" ? "#9b59b6" : "#e74c3c",
|
|
2005
|
-
size: node.type === "nexus" ? 3 : 4,
|
|
2006
|
-
glow: true,
|
|
2007
|
-
interactive: true
|
|
2008
|
-
};
|
|
2009
|
-
return {
|
|
2010
|
-
success: true,
|
|
2011
|
-
output: { type: node.type, created: true },
|
|
2012
|
-
hologram,
|
|
2013
|
-
spatialPosition: node.position
|
|
2014
|
-
};
|
|
2015
|
-
}
|
|
2016
|
-
async executeAssignment(node) {
|
|
2017
|
-
const value = this.evaluateExpression(String(node.value));
|
|
2018
|
-
this.setVariable(node.name, value);
|
|
2019
|
-
return {
|
|
2020
|
-
success: true,
|
|
2021
|
-
output: { assigned: node.name, value }
|
|
2022
|
-
};
|
|
2023
|
-
}
|
|
2024
|
-
async executeReturn(node) {
|
|
2025
|
-
const expr = String(node.value || node.expression || "");
|
|
2026
|
-
const value = this.evaluateExpression(expr);
|
|
2027
|
-
return {
|
|
2028
|
-
success: true,
|
|
2029
|
-
output: value
|
|
2030
|
-
};
|
|
2031
|
-
}
|
|
2032
|
-
// ============================================================================
|
|
2033
|
-
// Condition Evaluation
|
|
2034
|
-
// ============================================================================
|
|
2035
|
-
evaluateCondition(condition) {
|
|
2036
|
-
if (!condition) return false;
|
|
2037
|
-
const condStr = String(condition);
|
|
2038
|
-
const suspiciousKeywords = ["eval", "process", "require", "__proto__", "constructor"];
|
|
2039
|
-
if (suspiciousKeywords.some((kw) => condStr.toLowerCase().includes(kw))) {
|
|
2040
|
-
chunkILRBGFVD_cjs.logger.warn("Suspicious condition blocked", { condition });
|
|
2041
|
-
return false;
|
|
2042
|
-
}
|
|
2043
|
-
try {
|
|
2044
|
-
if (condStr.trim().toLowerCase() === "true") return true;
|
|
2045
|
-
if (condStr.trim().toLowerCase() === "false") return false;
|
|
2046
|
-
const comparisonPatterns = [
|
|
2047
|
-
{ regex: /^(.+?)\s*(===|!==)\s*(.+)$/ },
|
|
2048
|
-
{ regex: /^(.+?)\s*(==|!=|>=|<=|>|<)\s*(.+)$/ },
|
|
2049
|
-
{ regex: /^(.+?)\s*(&&)\s*(.+)$/, logical: "and" },
|
|
2050
|
-
{ regex: /^(.+?)\s*(\|\|)\s*(.+)$/, logical: "or" }
|
|
2051
|
-
];
|
|
2052
|
-
for (const { regex, logical } of comparisonPatterns) {
|
|
2053
|
-
const match = condStr.match(regex);
|
|
2054
|
-
if (match) {
|
|
2055
|
-
const [, leftExpr, operator, rightExpr] = match;
|
|
2056
|
-
const left = this.evaluateExpression(leftExpr.trim());
|
|
2057
|
-
const right = this.evaluateExpression(rightExpr.trim());
|
|
2058
|
-
if (logical === "and") return Boolean(left) && Boolean(right);
|
|
2059
|
-
if (logical === "or") return Boolean(left) || Boolean(right);
|
|
2060
|
-
switch (operator) {
|
|
2061
|
-
case "===":
|
|
2062
|
-
return left === right;
|
|
2063
|
-
case "!==":
|
|
2064
|
-
return left !== right;
|
|
2065
|
-
case "==":
|
|
2066
|
-
return left == right;
|
|
2067
|
-
case "!=":
|
|
2068
|
-
return left != right;
|
|
2069
|
-
case ">=":
|
|
2070
|
-
return Number(left) >= Number(right);
|
|
2071
|
-
case "<=":
|
|
2072
|
-
return Number(left) <= Number(right);
|
|
2073
|
-
case ">":
|
|
2074
|
-
return Number(left) > Number(right);
|
|
2075
|
-
case "<":
|
|
2076
|
-
return Number(left) < Number(right);
|
|
2077
|
-
}
|
|
2078
|
-
}
|
|
2079
|
-
}
|
|
2080
|
-
if (condStr.startsWith("!")) {
|
|
2081
|
-
return !this.evaluateCondition(condStr.slice(1).trim());
|
|
2082
|
-
}
|
|
2083
|
-
const value = this.evaluateExpression(condStr.trim());
|
|
2084
|
-
return Boolean(value);
|
|
2085
|
-
} catch (error) {
|
|
2086
|
-
chunkILRBGFVD_cjs.logger.error("Condition evaluation error", { condition, error });
|
|
2087
|
-
return false;
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
// ============================================================================
|
|
2091
|
-
// Transformation
|
|
2092
|
-
// ============================================================================
|
|
2093
|
-
async applyTransformation(data, transform) {
|
|
2094
|
-
const params = transform.parameters || {};
|
|
2095
|
-
switch (transform.operation) {
|
|
2096
|
-
case "filter": {
|
|
2097
|
-
if (!Array.isArray(data)) return data;
|
|
2098
|
-
const predicate = params.predicate;
|
|
2099
|
-
if (predicate) {
|
|
2100
|
-
return data.filter((item) => {
|
|
2101
|
-
this.setVariable("_item", item);
|
|
2102
|
-
return this.evaluateCondition(predicate);
|
|
2103
|
-
});
|
|
2104
|
-
}
|
|
2105
|
-
return data.filter((item) => item !== null && item !== void 0);
|
|
2106
|
-
}
|
|
2107
|
-
case "map": {
|
|
2108
|
-
if (!Array.isArray(data)) return data;
|
|
2109
|
-
const mapper = params.mapper;
|
|
2110
|
-
if (mapper) {
|
|
2111
|
-
return data.map((item) => {
|
|
2112
|
-
this.setVariable("_item", item);
|
|
2113
|
-
return this.evaluateExpression(mapper);
|
|
2114
|
-
});
|
|
2115
|
-
}
|
|
2116
|
-
return data.map((item) => ({ value: item, processed: true }));
|
|
2117
|
-
}
|
|
2118
|
-
case "reduce": {
|
|
2119
|
-
if (!Array.isArray(data)) return data;
|
|
2120
|
-
const initial = params.initial ?? 0;
|
|
2121
|
-
const reducer = params.reducer;
|
|
2122
|
-
if (reducer) {
|
|
2123
|
-
return data.reduce((acc, item) => {
|
|
2124
|
-
this.setVariable("_acc", acc);
|
|
2125
|
-
this.setVariable("_item", item);
|
|
2126
|
-
return this.evaluateExpression(reducer);
|
|
2127
|
-
}, initial);
|
|
2128
|
-
}
|
|
2129
|
-
return data.reduce((acc, item) => acc + (typeof item === "number" ? item : 0), 0);
|
|
2130
|
-
}
|
|
2131
|
-
case "sort": {
|
|
2132
|
-
if (!Array.isArray(data)) return data;
|
|
2133
|
-
const key = params.key;
|
|
2134
|
-
const desc = params.descending;
|
|
2135
|
-
const sorted = [...data].sort((a, b) => {
|
|
2136
|
-
const aVal = key ? a[key] : a;
|
|
2137
|
-
const bVal = key ? b[key] : b;
|
|
2138
|
-
if (aVal < bVal) return desc ? 1 : -1;
|
|
2139
|
-
if (aVal > bVal) return desc ? -1 : 1;
|
|
2140
|
-
return 0;
|
|
2141
|
-
});
|
|
2142
|
-
return sorted;
|
|
2143
|
-
}
|
|
2144
|
-
case "sum":
|
|
2145
|
-
return Array.isArray(data) ? data.reduce((sum, item) => sum + (typeof item === "number" ? item : 0), 0) : data;
|
|
2146
|
-
case "count":
|
|
2147
|
-
return Array.isArray(data) ? data.length : 1;
|
|
2148
|
-
case "unique":
|
|
2149
|
-
return Array.isArray(data) ? Array.from(new Set(data)) : data;
|
|
2150
|
-
case "flatten":
|
|
2151
|
-
return Array.isArray(data) ? data.flat() : data;
|
|
2152
|
-
case "reverse":
|
|
2153
|
-
return Array.isArray(data) ? [...data].reverse() : data;
|
|
2154
|
-
case "take": {
|
|
2155
|
-
if (!Array.isArray(data)) return data;
|
|
2156
|
-
const count = Number(params.count) || 10;
|
|
2157
|
-
return data.slice(0, count);
|
|
2158
|
-
}
|
|
2159
|
-
case "skip": {
|
|
2160
|
-
if (!Array.isArray(data)) return data;
|
|
2161
|
-
const count = Number(params.count) || 0;
|
|
2162
|
-
return data.slice(count);
|
|
2163
|
-
}
|
|
2164
|
-
default:
|
|
2165
|
-
chunkILRBGFVD_cjs.logger.warn("Unknown transformation", { operation: transform.operation });
|
|
2166
|
-
return data;
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
// ============================================================================
|
|
2170
|
-
// Event System
|
|
2171
|
-
// ============================================================================
|
|
2172
|
-
/**
|
|
2173
|
-
* Register event handler
|
|
2174
|
-
*/
|
|
2175
|
-
on(event, handler) {
|
|
2176
|
-
const handlers = this.eventHandlers.get(event) || [];
|
|
2177
|
-
handlers.push(handler);
|
|
2178
|
-
this.eventHandlers.set(event, handlers);
|
|
2179
|
-
}
|
|
2180
|
-
/**
|
|
2181
|
-
* Register host function
|
|
2182
|
-
*/
|
|
2183
|
-
registerFunction(name, handler) {
|
|
2184
|
-
this.builtinFunctions.set(name, handler);
|
|
2185
|
-
chunkILRBGFVD_cjs.logger.info(`Host function registered: ${name}`);
|
|
2186
|
-
}
|
|
2187
|
-
/**
|
|
2188
|
-
* Remove event handler
|
|
2189
|
-
*/
|
|
2190
|
-
off(event, handler) {
|
|
2191
|
-
if (!handler) {
|
|
2192
|
-
this.eventHandlers.delete(event);
|
|
2193
|
-
} else {
|
|
2194
|
-
const handlers = this.eventHandlers.get(event) || [];
|
|
2195
|
-
this.eventHandlers.set(
|
|
2196
|
-
event,
|
|
2197
|
-
handlers.filter((h) => h !== handler)
|
|
2198
|
-
);
|
|
2199
|
-
}
|
|
2200
|
-
}
|
|
2201
|
-
/**
|
|
2202
|
-
* Emit event
|
|
2203
|
-
*/
|
|
2204
|
-
async emit(event, data) {
|
|
2205
|
-
chunkILRBGFVD_cjs.logger.info(`[Runtime] Emitting event: ${event}`, data);
|
|
2206
|
-
if (event.includes(".")) {
|
|
2207
|
-
const [target, eventName] = event.split(".");
|
|
2208
|
-
const agent = this.agentRuntimes.get(target);
|
|
2209
|
-
if (agent) {
|
|
2210
|
-
await agent.onEvent(eventName, data);
|
|
2211
|
-
}
|
|
2212
|
-
const orb = this.context.variables.get(target);
|
|
2213
|
-
if (orb && typeof orb === "object" && orb.__type === "orb") {
|
|
2214
|
-
this.forwardToTraits(orb, eventName, data);
|
|
2215
|
-
}
|
|
2216
|
-
}
|
|
2217
|
-
const orbs = Array.from(this.context.variables.values()).filter(
|
|
2218
|
-
(v) => v && typeof v === "object" && v.__type === "orb"
|
|
2219
|
-
);
|
|
2220
|
-
for (const agent of this.agentRuntimes.values()) {
|
|
2221
|
-
await agent.onEvent(event, data);
|
|
2222
|
-
}
|
|
2223
|
-
for (const variable of orbs) {
|
|
2224
|
-
await this.forwardToTraits(variable, event, data);
|
|
2225
|
-
}
|
|
2226
|
-
const handlers = this.eventHandlers.get(event) || [];
|
|
2227
|
-
for (const handler of handlers) {
|
|
2228
|
-
try {
|
|
2229
|
-
await handler(data);
|
|
2230
|
-
} catch (error) {
|
|
2231
|
-
chunkILRBGFVD_cjs.logger.error("Event handler error", { event, error });
|
|
2232
|
-
}
|
|
2233
|
-
}
|
|
2234
|
-
await getSharedEventBus().emit(event, data);
|
|
2235
|
-
if (data && typeof data === "object" && data.id) {
|
|
2236
|
-
StateMachineInterpreter.stateMachineInterpreter.sendEvent(data.id, event);
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
async forwardToTraits(orb, event, data) {
|
|
2240
|
-
if (orb.directives) {
|
|
2241
|
-
for (const d of orb.directives) {
|
|
2242
|
-
if (d.type === "trait") {
|
|
2243
|
-
const handler = this.traitHandlers.get(d.name);
|
|
2244
|
-
if (handler && handler.onEvent) {
|
|
2245
|
-
const traitNode = orb;
|
|
2246
|
-
const eventPayload = {
|
|
2247
|
-
type: event,
|
|
2248
|
-
...data && typeof data === "object" ? data : {}
|
|
2249
|
-
};
|
|
2250
|
-
await handler.onEvent(
|
|
2251
|
-
traitNode,
|
|
2252
|
-
d.config || {},
|
|
2253
|
-
{
|
|
2254
|
-
emit: async (e, p) => await this.emit(e, p),
|
|
2255
|
-
getScaleMultiplier: () => this.context.currentScale || 1
|
|
2256
|
-
},
|
|
2257
|
-
eventPayload
|
|
2258
|
-
);
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
}
|
|
2264
|
-
/**
|
|
2265
|
-
* Trigger UI event
|
|
2266
|
-
*/
|
|
2267
|
-
async triggerUIEvent(elementName, eventType, data) {
|
|
2268
|
-
const element = this.uiElements.get(elementName);
|
|
2269
|
-
if (!element) {
|
|
2270
|
-
chunkILRBGFVD_cjs.logger.warn("UI element not found", { elementName });
|
|
2271
|
-
return;
|
|
2272
|
-
}
|
|
2273
|
-
if (eventType === "change" && data !== void 0) {
|
|
2274
|
-
element.value = data;
|
|
2275
|
-
}
|
|
2276
|
-
await this.emit(`${elementName}.${eventType}`, data);
|
|
2277
|
-
}
|
|
2278
|
-
// ============================================================================
|
|
2279
|
-
// Animation System
|
|
2280
|
-
// ============================================================================
|
|
2281
|
-
/**
|
|
2282
|
-
* Update all animations
|
|
2283
|
-
*/
|
|
2284
|
-
updateAnimations() {
|
|
2285
|
-
const now = Date.now();
|
|
2286
|
-
for (const [key, anim] of this.animations) {
|
|
2287
|
-
const elapsed = now - anim.startTime;
|
|
2288
|
-
let progress = Math.min(elapsed / anim.duration, 1);
|
|
2289
|
-
progress = this.applyEasing(progress, anim.easing);
|
|
2290
|
-
const currentValue = anim.from + (anim.to - anim.from) * progress;
|
|
2291
|
-
if (anim.yoyo && progress >= 1) {
|
|
2292
|
-
anim.startTime = now;
|
|
2293
|
-
[anim.from, anim.to] = [anim.to, anim.from];
|
|
2294
|
-
}
|
|
2295
|
-
this.setVariable(`${anim.target}.${anim.property}`, currentValue);
|
|
2296
|
-
if (progress >= 1 && !anim.loop && !anim.yoyo) {
|
|
2297
|
-
this.animations.delete(key);
|
|
2298
|
-
} else if (progress >= 1 && anim.loop) {
|
|
2299
|
-
anim.startTime = now;
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
this.updateSystemVariables();
|
|
2303
|
-
}
|
|
2304
|
-
/**
|
|
2305
|
-
* Update real-life and system variables ($time, $user, etc.)
|
|
2306
|
-
*/
|
|
2307
|
-
updateSystemVariables() {
|
|
2308
|
-
const now = /* @__PURE__ */ new Date();
|
|
2309
|
-
this.setVariable("$time", now.toLocaleTimeString());
|
|
2310
|
-
this.setVariable("$date", now.toLocaleDateString());
|
|
2311
|
-
this.setVariable("$timestamp", now.getTime());
|
|
2312
|
-
this.setVariable("$hour", now.getHours());
|
|
2313
|
-
this.setVariable("$minute", now.getMinutes());
|
|
2314
|
-
this.setVariable("$second", now.getSeconds());
|
|
2315
|
-
if (this.getVariable("$user") === void 0) {
|
|
2316
|
-
this.setVariable("$user", {
|
|
2317
|
-
id: "user_123",
|
|
2318
|
-
name: "Alpha Explorer",
|
|
2319
|
-
level: 42,
|
|
2320
|
-
rank: "Legendary",
|
|
2321
|
-
achievements: ["First World", "Spirit Guide"],
|
|
2322
|
-
preferences: { theme: "holographic", language: "en" }
|
|
2323
|
-
});
|
|
2324
|
-
}
|
|
2325
|
-
if (this.getVariable("$location") === void 0) {
|
|
2326
|
-
this.setVariable("$location", {
|
|
2327
|
-
city: "Neo Tokyo",
|
|
2328
|
-
region: "Holo-Sector 7",
|
|
2329
|
-
coordinates: { lat: 35.6895, lng: 139.6917 },
|
|
2330
|
-
altitude: 450
|
|
2331
|
-
});
|
|
2332
|
-
}
|
|
2333
|
-
if (this.getVariable("$weather") === void 0) {
|
|
2334
|
-
this.setVariable("$weather", {
|
|
2335
|
-
condition: "Neon Mist",
|
|
2336
|
-
temperature: 24,
|
|
2337
|
-
humidity: 65,
|
|
2338
|
-
windSpeed: 12,
|
|
2339
|
-
unit: "C"
|
|
2340
|
-
});
|
|
2341
|
-
}
|
|
2342
|
-
if (this.getVariable("$wallet") === void 0) {
|
|
2343
|
-
this.setVariable("$wallet", {
|
|
2344
|
-
address: "0xHolo...42ff",
|
|
2345
|
-
balance: 1337.5,
|
|
2346
|
-
currency: "HOLO",
|
|
2347
|
-
network: "MainNet"
|
|
2348
|
-
});
|
|
2349
|
-
}
|
|
2350
|
-
if (this.getVariable("$ai_config") === void 0) {
|
|
2351
|
-
const savedKeys = typeof localStorage !== "undefined" ? localStorage.getItem("brittney_api_keys") : null;
|
|
2352
|
-
let configuredCount = 0;
|
|
2353
|
-
if (savedKeys) {
|
|
2354
|
-
try {
|
|
2355
|
-
const keys = JSON.parse(savedKeys);
|
|
2356
|
-
configuredCount = Object.values(keys).filter((k) => !!k).length;
|
|
2357
|
-
} catch (_e) {
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
this.setVariable("$ai_config", {
|
|
2361
|
-
status: configuredCount > 0 ? "configured" : "pending",
|
|
2362
|
-
providerCount: configuredCount,
|
|
2363
|
-
lastUpdated: Date.now()
|
|
2364
|
-
});
|
|
2365
|
-
}
|
|
2366
|
-
if (this.getVariable("$chat_status") === void 0) {
|
|
2367
|
-
this.setVariable("$chat_status", {
|
|
2368
|
-
active: true,
|
|
2369
|
-
typing: false,
|
|
2370
|
-
version: "1.0.0-brittney"
|
|
2371
|
-
});
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
// ==========================================================================
|
|
2375
|
-
// COMMERCE PRIMITIVES
|
|
2376
|
-
// ==========================================================================
|
|
2377
|
-
handleShop(args) {
|
|
2378
|
-
const config = args[0] || {};
|
|
2379
|
-
this.emit("shop", config);
|
|
2380
|
-
return { success: true, type: "shop", config };
|
|
2381
|
-
}
|
|
2382
|
-
handleInventory(args) {
|
|
2383
|
-
const item = args[0];
|
|
2384
|
-
const action = args[1] || "add";
|
|
2385
|
-
this.emit("inventory", { item, action });
|
|
2386
|
-
return { success: true, item, action };
|
|
2387
|
-
}
|
|
2388
|
-
handlePurchase(args) {
|
|
2389
|
-
const productId = args[0];
|
|
2390
|
-
this.emit("purchase", { productId });
|
|
2391
|
-
return { success: true, productId, status: "pending" };
|
|
2392
|
-
}
|
|
2393
|
-
// ==========================================================================
|
|
2394
|
-
// SOCIAL PRIMITIVES
|
|
2395
|
-
// ==========================================================================
|
|
2396
|
-
handlePresence(args) {
|
|
2397
|
-
const config = args[0] || {};
|
|
2398
|
-
this.emit("presence", config);
|
|
2399
|
-
return { success: true, active: true };
|
|
2400
|
-
}
|
|
2401
|
-
handleInvite(args) {
|
|
2402
|
-
const userId = args[0];
|
|
2403
|
-
this.emit("invite", { userId });
|
|
2404
|
-
return { success: true, userId };
|
|
2405
|
-
}
|
|
2406
|
-
handleShare(args) {
|
|
2407
|
-
const scriptId = args[0];
|
|
2408
|
-
const targetUserId = args[1];
|
|
2409
|
-
this.emit("share", { scriptId, targetUserId });
|
|
2410
|
-
return { success: true, scriptId };
|
|
2411
|
-
}
|
|
2412
|
-
// ==========================================================================
|
|
2413
|
-
// PHYSICS PRIMITIVES
|
|
2414
|
-
// ==========================================================================
|
|
2415
|
-
handlePhysics(args) {
|
|
2416
|
-
const config = args[0] || {};
|
|
2417
|
-
this.emit("physics", config);
|
|
2418
|
-
return { success: true, enabled: config.enabled !== false };
|
|
2419
|
-
}
|
|
2420
|
-
handleGravity(args) {
|
|
2421
|
-
const value = args[0] ?? 9.81;
|
|
2422
|
-
this.emit("gravity", { value });
|
|
2423
|
-
return { success: true, value };
|
|
2424
|
-
}
|
|
2425
|
-
handleCollide(args) {
|
|
2426
|
-
const target = args[0];
|
|
2427
|
-
const handler = args[1];
|
|
2428
|
-
this.emit("collide", { target, handler });
|
|
2429
|
-
return { success: true, target };
|
|
2430
|
-
}
|
|
2431
|
-
/**
|
|
2432
|
-
* Handle calculate_arc(start, end, speed)
|
|
2433
|
-
*/
|
|
2434
|
-
handleCalculateArc(args) {
|
|
2435
|
-
if (args.length < 3) return { x: 0, y: 0, z: 0 };
|
|
2436
|
-
const start = args[0];
|
|
2437
|
-
const end = args[1];
|
|
2438
|
-
const speed = args[2];
|
|
2439
|
-
const dx = end.x - start.x;
|
|
2440
|
-
const dz = end.z - start.z;
|
|
2441
|
-
const dy = end.y - start.y;
|
|
2442
|
-
const dist = Math.sqrt(dx * dx + dz * dz);
|
|
2443
|
-
if (dist < 0.1) return { x: 0, y: speed, z: 0 };
|
|
2444
|
-
const t = dist / speed;
|
|
2445
|
-
const vx = dx / t;
|
|
2446
|
-
const vz = dz / t;
|
|
2447
|
-
const vy = dy / t + 0.5 * 9.81 * t;
|
|
2448
|
-
return { x: vx, y: vy, z: vz };
|
|
2449
|
-
}
|
|
2450
|
-
handleAnimate(args) {
|
|
2451
|
-
const options = args[0] || {};
|
|
2452
|
-
this.emit("animate", options);
|
|
2453
|
-
return { success: true, options };
|
|
2454
|
-
}
|
|
2455
|
-
applyEasing(t, easing) {
|
|
2456
|
-
switch (easing) {
|
|
2457
|
-
case "easeIn":
|
|
2458
|
-
return t * t;
|
|
2459
|
-
case "easeOut":
|
|
2460
|
-
return t * (2 - t);
|
|
2461
|
-
case "easeInOut":
|
|
2462
|
-
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
2463
|
-
case "easeInQuad":
|
|
2464
|
-
return t * t;
|
|
2465
|
-
case "easeOutQuad":
|
|
2466
|
-
return t * (2 - t);
|
|
2467
|
-
case "easeInOutQuad":
|
|
2468
|
-
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
2469
|
-
case "linear":
|
|
2470
|
-
default:
|
|
2471
|
-
return t;
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
|
-
// ============================================================================
|
|
2475
|
-
// Particle Effects
|
|
2476
|
-
// ============================================================================
|
|
2477
|
-
createParticleEffect(name, position, color, count) {
|
|
2478
|
-
const limitedCount = Math.min(count, RUNTIME_SECURITY_LIMITS.maxParticlesPerSystem);
|
|
2479
|
-
const particles = [];
|
|
2480
|
-
for (let i = 0; i < limitedCount; i++) {
|
|
2481
|
-
particles.push({
|
|
2482
|
-
x: position.x + (Math.random() - 0.5) * 2,
|
|
2483
|
-
y: position.y + (Math.random() - 0.5) * 2,
|
|
2484
|
-
z: position.z + (Math.random() - 0.5) * 2
|
|
2485
|
-
});
|
|
2486
|
-
}
|
|
2487
|
-
this.particleSystems.set(name, {
|
|
2488
|
-
particles,
|
|
2489
|
-
color,
|
|
2490
|
-
lifetime: 3e3,
|
|
2491
|
-
speed: 0.01
|
|
2492
|
-
});
|
|
2493
|
-
}
|
|
2494
|
-
createConnectionStream(from, to, fromPos, toPos, dataType) {
|
|
2495
|
-
const streamName = `connection_${from}_${to}`;
|
|
2496
|
-
const particles = [];
|
|
2497
|
-
const steps = 20;
|
|
2498
|
-
for (let i = 0; i <= steps; i++) {
|
|
2499
|
-
const t = i / steps;
|
|
2500
|
-
particles.push({
|
|
2501
|
-
x: fromPos.x + (toPos.x - fromPos.x) * t,
|
|
2502
|
-
y: fromPos.y + (toPos.y - fromPos.y) * t,
|
|
2503
|
-
z: fromPos.z + (toPos.z - fromPos.z) * t
|
|
2504
|
-
});
|
|
2505
|
-
}
|
|
2506
|
-
this.particleSystems.set(streamName, {
|
|
2507
|
-
particles,
|
|
2508
|
-
color: this.getDataTypeColor(dataType),
|
|
2509
|
-
lifetime: 5e3,
|
|
2510
|
-
speed: 0.02
|
|
2511
|
-
});
|
|
2512
|
-
}
|
|
2513
|
-
createFlowingStream(name, position, data) {
|
|
2514
|
-
const count = Array.isArray(data) ? Math.min(data.length, 50) : 10;
|
|
2515
|
-
this.createParticleEffect(`${name}_flow`, position, "#45b7d1", count);
|
|
2516
|
-
}
|
|
2517
|
-
createExecutionEffect(name, position) {
|
|
2518
|
-
this.createParticleEffect(`${name}_execution`, position, "#ff4500", 30);
|
|
2519
|
-
}
|
|
2520
|
-
createDataVisualization(name, data, position) {
|
|
2521
|
-
let count = 10;
|
|
2522
|
-
if (Array.isArray(data)) {
|
|
2523
|
-
count = Math.min(data.length, 100);
|
|
2524
|
-
} else if (typeof data === "object" && data !== null) {
|
|
2525
|
-
count = Math.min(Object.keys(data).length * 5, 50);
|
|
2526
|
-
}
|
|
2527
|
-
this.createParticleEffect(`${name}_visualization`, position, "#32cd32", count);
|
|
2528
|
-
}
|
|
2529
|
-
getDataTypeColor(dataType) {
|
|
2530
|
-
const colors = {
|
|
2531
|
-
string: "#ff6b35",
|
|
2532
|
-
number: "#4ecdc4",
|
|
2533
|
-
boolean: "#45b7d1",
|
|
2534
|
-
object: "#96ceb4",
|
|
2535
|
-
array: "#ffeaa7",
|
|
2536
|
-
any: "#dda0dd",
|
|
2537
|
-
move: "#ff69b4"
|
|
2538
|
-
};
|
|
2539
|
-
return colors[dataType] || "#ffffff";
|
|
2540
|
-
}
|
|
2541
|
-
// ============================================================================
|
|
2542
|
-
// Visualizer Server
|
|
2543
|
-
// ============================================================================
|
|
2544
|
-
startVisualizationServer(port = 8080) {
|
|
2545
|
-
try {
|
|
2546
|
-
this.wss = new ws.WebSocketServer({ port });
|
|
2547
|
-
chunkILRBGFVD_cjs.logger.info(`[Visualizer] WebSocket server started on port ${port}`);
|
|
2548
|
-
this.timeManager = new orbital.TimeManager(/* @__PURE__ */ new Date());
|
|
2549
|
-
this.timeManager.onUpdate((julianDate, date) => {
|
|
2550
|
-
this.updateTraits(julianDate);
|
|
2551
|
-
this.broadcast("time_update", {
|
|
2552
|
-
julianDate,
|
|
2553
|
-
date: date.toISOString(),
|
|
2554
|
-
timeScale: this.timeManager.getTimeScale(),
|
|
2555
|
-
isPaused: this.timeManager.getIsPaused()
|
|
2556
|
-
});
|
|
2557
|
-
});
|
|
2558
|
-
this.timeManager.start();
|
|
2559
|
-
this.updateTraits(this.timeManager.getJulianDate());
|
|
2560
|
-
this.wss.on("connection", (ws) => {
|
|
2561
|
-
chunkILRBGFVD_cjs.logger.info("[Visualizer] Client connected");
|
|
2562
|
-
const orbs = Array.from(this.context.variables.entries()).filter(
|
|
2563
|
-
([_, v]) => v && typeof v === "object" && v.__type === "orb"
|
|
2564
|
-
).map(([id, v]) => {
|
|
2565
|
-
const orbData = v;
|
|
2566
|
-
return {
|
|
2567
|
-
id,
|
|
2568
|
-
name: orbData.name || id,
|
|
2569
|
-
position: Array.isArray(orbData.position) ? { x: orbData.position[0], y: orbData.position[1], z: orbData.position[2] } : orbData.position,
|
|
2570
|
-
properties: orbData.properties || {},
|
|
2571
|
-
hologram: orbData.hologram || (() => {
|
|
2572
|
-
const props = orbData.properties;
|
|
2573
|
-
return {
|
|
2574
|
-
color: props?.color || "#ffffff",
|
|
2575
|
-
size: props?.size || props?.scale || 1,
|
|
2576
|
-
shape: props?.geometry || "sphere",
|
|
2577
|
-
glow: props?.glow || false
|
|
2578
|
-
};
|
|
2579
|
-
})(),
|
|
2580
|
-
traits: orbData.traits || []
|
|
2581
|
-
};
|
|
2582
|
-
});
|
|
2583
|
-
ws.send(
|
|
2584
|
-
JSON.stringify({
|
|
2585
|
-
type: "init",
|
|
2586
|
-
orbs,
|
|
2587
|
-
time: this.timeManager ? this.timeManager.getState() : null
|
|
2588
|
-
})
|
|
2589
|
-
);
|
|
2590
|
-
ws.on("message", (message) => {
|
|
2591
|
-
try {
|
|
2592
|
-
const data = JSON.parse(message.toString());
|
|
2593
|
-
if (data.type === "time_control") {
|
|
2594
|
-
this.handleTimeControl(data.command, data.value);
|
|
2595
|
-
}
|
|
2596
|
-
} catch (e) {
|
|
2597
|
-
chunkILRBGFVD_cjs.logger.error("[Visualizer] Failed to parse message", { error: String(e) });
|
|
2598
|
-
}
|
|
2599
|
-
});
|
|
2600
|
-
});
|
|
2601
|
-
} catch (error) {
|
|
2602
|
-
chunkILRBGFVD_cjs.logger.error("[Visualizer] Failed to start server", { error: String(error) });
|
|
2603
|
-
}
|
|
2604
|
-
}
|
|
2605
|
-
/**
|
|
2606
|
-
* Handle time control commands from visualizer
|
|
2607
|
-
*/
|
|
2608
|
-
handleTimeControl(command, value) {
|
|
2609
|
-
if (!this.timeManager) return;
|
|
2610
|
-
switch (command) {
|
|
2611
|
-
case "play":
|
|
2612
|
-
this.timeManager.play();
|
|
2613
|
-
break;
|
|
2614
|
-
case "pause":
|
|
2615
|
-
this.timeManager.pause();
|
|
2616
|
-
break;
|
|
2617
|
-
case "toggle":
|
|
2618
|
-
this.timeManager.togglePause();
|
|
2619
|
-
break;
|
|
2620
|
-
case "setSpeed":
|
|
2621
|
-
if (typeof value === "number") {
|
|
2622
|
-
this.timeManager.setTimeScale(value);
|
|
2623
|
-
}
|
|
2624
|
-
break;
|
|
2625
|
-
case "setDate":
|
|
2626
|
-
if (value) {
|
|
2627
|
-
this.timeManager.setDate(new Date(value));
|
|
2628
|
-
}
|
|
2629
|
-
break;
|
|
2630
|
-
case "syncRealTime":
|
|
2631
|
-
this.timeManager.setDate(/* @__PURE__ */ new Date());
|
|
2632
|
-
this.timeManager.setTimeScale(1);
|
|
2633
|
-
this.timeManager.play();
|
|
2634
|
-
break;
|
|
2635
|
-
}
|
|
2636
|
-
}
|
|
2637
|
-
broadcast(type, payload) {
|
|
2638
|
-
if (!this.wss) return;
|
|
2639
|
-
const message = JSON.stringify({ type, payload });
|
|
2640
|
-
this.wss.clients.forEach((client) => {
|
|
2641
|
-
if (client.readyState === ws.WebSocket.OPEN) {
|
|
2642
|
-
client.send(message);
|
|
2643
|
-
}
|
|
2644
|
-
});
|
|
2645
|
-
}
|
|
2646
|
-
// ============================================================================
|
|
2647
|
-
// Public API
|
|
2648
|
-
// ============================================================================
|
|
2649
|
-
getParticleSystems() {
|
|
2650
|
-
return new Map(this.particleSystems);
|
|
2651
|
-
}
|
|
2652
|
-
updateParticles(deltaTime) {
|
|
2653
|
-
for (const [name, system] of this.particleSystems) {
|
|
2654
|
-
system.lifetime -= deltaTime;
|
|
2655
|
-
system.particles.forEach((particle) => {
|
|
2656
|
-
particle.x += (Math.random() - 0.5) * system.speed;
|
|
2657
|
-
particle.y += (Math.random() - 0.5) * system.speed;
|
|
2658
|
-
particle.z += (Math.random() - 0.5) * system.speed;
|
|
2659
|
-
});
|
|
2660
|
-
if (system.lifetime <= 0) {
|
|
2661
|
-
this.particleSystems.delete(name);
|
|
2662
|
-
}
|
|
2663
|
-
}
|
|
2664
|
-
}
|
|
2665
|
-
getContext() {
|
|
2666
|
-
return { ...this.context };
|
|
2667
|
-
}
|
|
2668
|
-
getUIElements() {
|
|
2669
|
-
return new Map(this.uiElements);
|
|
2670
|
-
}
|
|
2671
|
-
getUIElement(name) {
|
|
2672
|
-
return this.uiElements.get(name);
|
|
2673
|
-
}
|
|
2674
|
-
getAnimations() {
|
|
2675
|
-
return new Map(this.animations);
|
|
2676
|
-
}
|
|
2677
|
-
reset() {
|
|
2678
|
-
this.context = this.createEmptyContext();
|
|
2679
|
-
this.currentScope = { variables: this.context.variables };
|
|
2680
|
-
this.callStack = [];
|
|
2681
|
-
this.particleSystems.clear();
|
|
2682
|
-
this.executionHistory = [];
|
|
2683
|
-
this.eventHandlers.clear();
|
|
2684
|
-
this.animations.clear();
|
|
2685
|
-
this.uiElements.clear();
|
|
2686
|
-
}
|
|
2687
|
-
createEmptyContext() {
|
|
2688
|
-
return {
|
|
2689
|
-
variables: /* @__PURE__ */ new Map(),
|
|
2690
|
-
functions: /* @__PURE__ */ new Map(),
|
|
2691
|
-
exports: /* @__PURE__ */ new Map(),
|
|
2692
|
-
connections: [],
|
|
2693
|
-
spatialMemory: /* @__PURE__ */ new Map(),
|
|
2694
|
-
hologramState: /* @__PURE__ */ new Map(),
|
|
2695
|
-
executionStack: [],
|
|
2696
|
-
currentScale: 1,
|
|
2697
|
-
scaleMagnitude: "standard",
|
|
2698
|
-
focusHistory: [],
|
|
2699
|
-
environment: {},
|
|
2700
|
-
templates: /* @__PURE__ */ new Map(),
|
|
2701
|
-
// HS+ State
|
|
2702
|
-
state: createState({}),
|
|
2703
|
-
// Phase 13: State Machines
|
|
2704
|
-
stateMachines: /* @__PURE__ */ new Map(),
|
|
2705
|
-
// Narrative & Story State
|
|
2706
|
-
quests: /* @__PURE__ */ new Map(),
|
|
2707
|
-
completedQuests: /* @__PURE__ */ new Set()
|
|
2708
|
-
};
|
|
2709
|
-
}
|
|
2710
|
-
async executeScale(node) {
|
|
2711
|
-
const parentScale = this.context.currentScale;
|
|
2712
|
-
this.context.currentScale *= node.multiplier;
|
|
2713
|
-
this.context.scaleMagnitude = node.magnitude;
|
|
2714
|
-
chunkILRBGFVD_cjs.logger.info("Scale context entering", {
|
|
2715
|
-
magnitude: node.magnitude,
|
|
2716
|
-
multiplier: this.context.currentScale
|
|
2717
|
-
});
|
|
2718
|
-
this.emit("scale:change", { multiplier: this.context.currentScale, magnitude: node.magnitude });
|
|
2719
|
-
const results = await this.executeProgram(node.body, this.context.executionStack.length);
|
|
2720
|
-
this.context.currentScale = parentScale;
|
|
2721
|
-
this.emit("scale:change", { multiplier: this.context.currentScale });
|
|
2722
|
-
return {
|
|
2723
|
-
success: results.every((r) => r.success),
|
|
2724
|
-
output: `Executed scale block: ${node.magnitude}`
|
|
2725
|
-
};
|
|
2726
|
-
}
|
|
2727
|
-
async executeFocus(node) {
|
|
2728
|
-
this.context.focusHistory.push(node.target);
|
|
2729
|
-
const results = await this.executeProgram(node.body, this.context.executionStack.length);
|
|
2730
|
-
return {
|
|
2731
|
-
success: results.every((r) => r.success),
|
|
2732
|
-
output: `Focused on ${node.target}`
|
|
2733
|
-
};
|
|
2734
|
-
}
|
|
2735
|
-
async executeEnvironment(node) {
|
|
2736
|
-
this.context.environment = { ...this.context.environment, ...node.settings };
|
|
2737
|
-
return { success: true, output: "Environment updated" };
|
|
2738
|
-
}
|
|
2739
|
-
async executeComposition(node) {
|
|
2740
|
-
if (node.body) {
|
|
2741
|
-
const systemResults = await this.executeProgram(
|
|
2742
|
-
node.body.systems,
|
|
2743
|
-
this.context.executionStack.length
|
|
2744
|
-
);
|
|
2745
|
-
const configResults = await this.executeProgram(
|
|
2746
|
-
node.body.configs,
|
|
2747
|
-
this.context.executionStack.length
|
|
2748
|
-
);
|
|
2749
|
-
const childrenResults = await this.executeProgram(
|
|
2750
|
-
node.body.children,
|
|
2751
|
-
this.context.executionStack.length
|
|
2752
|
-
);
|
|
2753
|
-
const allResults = [...systemResults, ...configResults, ...childrenResults];
|
|
2754
|
-
return {
|
|
2755
|
-
success: allResults.every((r) => r.success),
|
|
2756
|
-
output: `Composition ${node.name} executed with specialized blocks`
|
|
2757
|
-
};
|
|
2758
|
-
}
|
|
2759
|
-
return {
|
|
2760
|
-
success: (await this.executeProgram(node.children, this.context.executionStack.length)).every(
|
|
2761
|
-
(r) => r.success
|
|
2762
|
-
),
|
|
2763
|
-
output: `Composition ${node.name} executed`
|
|
2764
|
-
};
|
|
2765
|
-
}
|
|
2766
|
-
resolveHoloValue(value) {
|
|
2767
|
-
if (value === null) return null;
|
|
2768
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
2769
|
-
return value;
|
|
2770
|
-
}
|
|
2771
|
-
if (Array.isArray(value)) {
|
|
2772
|
-
return value.map((e) => this.resolveHoloValue(e));
|
|
2773
|
-
}
|
|
2774
|
-
if (value.__bind) {
|
|
2775
|
-
return value;
|
|
2776
|
-
}
|
|
2777
|
-
const obj = {};
|
|
2778
|
-
for (const k in value) {
|
|
2779
|
-
obj[k] = this.resolveHoloValue(value[k]);
|
|
2780
|
-
}
|
|
2781
|
-
return obj;
|
|
2782
|
-
}
|
|
2783
|
-
async executeHoloComposition(node) {
|
|
2784
|
-
for (const template of node.templates) {
|
|
2785
|
-
await this.executeHoloTemplate(template);
|
|
2786
|
-
}
|
|
2787
|
-
if (node.environment) {
|
|
2788
|
-
const envSettings = {};
|
|
2789
|
-
for (const prop of node.environment.properties) {
|
|
2790
|
-
envSettings[prop.key] = this.resolveHoloValue(prop.value);
|
|
2791
|
-
}
|
|
2792
|
-
this.context.environment = { ...this.context.environment, ...envSettings };
|
|
2793
|
-
}
|
|
2794
|
-
const results = [];
|
|
2795
|
-
for (const object of node.objects) {
|
|
2796
|
-
results.push(await this.executeHoloObject(object));
|
|
2797
|
-
}
|
|
2798
|
-
return {
|
|
2799
|
-
success: results.every((r) => r.success),
|
|
2800
|
-
output: `HoloComposition ${node.name} executed`
|
|
2801
|
-
};
|
|
2802
|
-
}
|
|
2803
|
-
async executeHoloTemplate(node) {
|
|
2804
|
-
this.context.templates.set(node.name, node);
|
|
2805
|
-
return { success: true, output: `Template ${node.name} registered` };
|
|
2806
|
-
}
|
|
2807
|
-
async executeHoloObject(node) {
|
|
2808
|
-
const properties = {};
|
|
2809
|
-
for (const prop of node.properties) {
|
|
2810
|
-
properties[prop.key] = this.resolveHoloValue(prop.value);
|
|
2811
|
-
}
|
|
2812
|
-
if (node.state) {
|
|
2813
|
-
for (const prop of node.state.properties) {
|
|
2814
|
-
properties[prop.key] = this.resolveHoloValue(prop.value);
|
|
2815
|
-
}
|
|
2816
|
-
}
|
|
2817
|
-
const position = properties.position;
|
|
2818
|
-
const hologram = {
|
|
2819
|
-
shape: properties.geometry || "sphere",
|
|
2820
|
-
color: properties.color || "#ffffff",
|
|
2821
|
-
size: properties.scale || properties.size || 1,
|
|
2822
|
-
glow: properties.glow || false,
|
|
2823
|
-
interactive: properties.interactive !== false
|
|
2824
|
-
};
|
|
2825
|
-
const orbNode = {
|
|
2826
|
-
type: "orb",
|
|
2827
|
-
name: node.name,
|
|
2828
|
-
position,
|
|
2829
|
-
// Direct property for executeOrb
|
|
2830
|
-
hologram,
|
|
2831
|
-
// Direct property for executeOrb
|
|
2832
|
-
properties,
|
|
2833
|
-
// @ts-expect-error
|
|
2834
|
-
directives: [
|
|
2835
|
-
...node.directives || [],
|
|
2836
|
-
...(node.traits || []).map((t) => ({ type: "trait", name: t.name, ...t.config })),
|
|
2837
|
-
...node.template ? this.context.templates.get(node.template)?.directives || [] : []
|
|
2838
|
-
// Inherit template directives/traits
|
|
2839
|
-
],
|
|
2840
|
-
traits: new Map((node.traits || []).map((t) => [t.name, t.config])),
|
|
2841
|
-
children: node.children || []
|
|
2842
|
-
};
|
|
2843
|
-
if (node.template) {
|
|
2844
|
-
const tpl = this.context.templates.get(node.template);
|
|
2845
|
-
if (tpl) {
|
|
2846
|
-
if (tpl.state) {
|
|
2847
|
-
for (const prop of tpl.state.properties) {
|
|
2848
|
-
if (properties[prop.key] === void 0) {
|
|
2849
|
-
properties[prop.key] = this.resolveHoloValue(prop.value);
|
|
2850
|
-
}
|
|
2851
|
-
}
|
|
2852
|
-
}
|
|
2853
|
-
for (const prop of tpl.properties) {
|
|
2854
|
-
if (properties[prop.key] === void 0) {
|
|
2855
|
-
properties[prop.key] = this.resolveHoloValue(prop.value);
|
|
2856
|
-
}
|
|
2857
|
-
}
|
|
2858
|
-
}
|
|
2859
|
-
}
|
|
2860
|
-
return this.executeOrb(orbNode);
|
|
2861
|
-
}
|
|
2862
|
-
/**
|
|
2863
|
-
* Execute a block of HoloStatements (HoloNode AST)
|
|
2864
|
-
*/
|
|
2865
|
-
async executeHoloProgram(statements, scopeOverride) {
|
|
2866
|
-
const results = [];
|
|
2867
|
-
telemetry.setGauge("execution_depth", this.context.executionStack.length);
|
|
2868
|
-
for (const stmt of statements) {
|
|
2869
|
-
telemetry.incrementCounter("statements_executed", 1, { type: stmt.type });
|
|
2870
|
-
const res = await telemetry.measureLatency(
|
|
2871
|
-
`execute_stmt_${stmt.type}`,
|
|
2872
|
-
() => this.executeHoloStatement(stmt, scopeOverride)
|
|
2873
|
-
);
|
|
2874
|
-
results.push(res);
|
|
2875
|
-
const last = results[results.length - 1];
|
|
2876
|
-
if (last.success && last.output !== void 0 && stmt.type === "ReturnStatement") {
|
|
2877
|
-
break;
|
|
2878
|
-
}
|
|
2879
|
-
}
|
|
2880
|
-
return results;
|
|
2881
|
-
}
|
|
2882
|
-
async executeHoloStatement(stmt, scopeOverride) {
|
|
2883
|
-
try {
|
|
2884
|
-
switch (stmt.type) {
|
|
2885
|
-
case "Assignment": {
|
|
2886
|
-
const value = await this.evaluateHoloExpression(stmt.value, scopeOverride);
|
|
2887
|
-
let finalValue = value;
|
|
2888
|
-
if (stmt.operator !== "=") {
|
|
2889
|
-
const current = this.getVariable(stmt.target, scopeOverride);
|
|
2890
|
-
if (stmt.operator === "+=")
|
|
2891
|
-
finalValue = Number(current) + Number(value);
|
|
2892
|
-
else if (stmt.operator === "-=")
|
|
2893
|
-
finalValue = Number(current) - Number(value);
|
|
2894
|
-
else if (stmt.operator === "*=")
|
|
2895
|
-
finalValue = Number(current) * Number(value);
|
|
2896
|
-
else if (stmt.operator === "/=")
|
|
2897
|
-
finalValue = Number(current) / Number(value);
|
|
2898
|
-
}
|
|
2899
|
-
this.setVariable(stmt.target, finalValue, scopeOverride);
|
|
2900
|
-
return { success: true };
|
|
2901
|
-
}
|
|
2902
|
-
case "IfStatement": {
|
|
2903
|
-
const condition = await this.evaluateHoloExpression(stmt.condition, scopeOverride);
|
|
2904
|
-
if (condition) {
|
|
2905
|
-
await this.executeHoloProgram(stmt.consequent, scopeOverride);
|
|
2906
|
-
} else if (stmt.alternate) {
|
|
2907
|
-
await this.executeHoloProgram(stmt.alternate, scopeOverride);
|
|
2908
|
-
}
|
|
2909
|
-
return { success: true };
|
|
2910
|
-
}
|
|
2911
|
-
case "WhileStatement": {
|
|
2912
|
-
const MAX_ITERATIONS = 1e3;
|
|
2913
|
-
let iter = 0;
|
|
2914
|
-
while (await this.evaluateHoloExpression(stmt.condition, scopeOverride)) {
|
|
2915
|
-
if (iter++ > MAX_ITERATIONS) return { success: false, error: "Infinite loop" };
|
|
2916
|
-
await this.executeHoloProgram(stmt.body, scopeOverride);
|
|
2917
|
-
}
|
|
2918
|
-
return { success: true };
|
|
2919
|
-
}
|
|
2920
|
-
case "ClassicForStatement": {
|
|
2921
|
-
if (stmt.init) await this.executeHoloStatement(stmt.init, scopeOverride);
|
|
2922
|
-
const MAX_ITERATIONS = 1e3;
|
|
2923
|
-
let iter = 0;
|
|
2924
|
-
while (!stmt.test || await this.evaluateHoloExpression(stmt.test, scopeOverride)) {
|
|
2925
|
-
if (iter++ > MAX_ITERATIONS) return { success: false, error: "Infinite loop" };
|
|
2926
|
-
await this.executeHoloProgram(stmt.body, scopeOverride);
|
|
2927
|
-
if (stmt.update) await this.executeHoloStatement(stmt.update, scopeOverride);
|
|
2928
|
-
}
|
|
2929
|
-
return { success: true };
|
|
2930
|
-
}
|
|
2931
|
-
case "VariableDeclaration": {
|
|
2932
|
-
const value = stmt.value ? await this.evaluateHoloExpression(stmt.value, scopeOverride) : void 0;
|
|
2933
|
-
const scope = scopeOverride || this.currentScope;
|
|
2934
|
-
scope.variables.set(stmt.name, value);
|
|
2935
|
-
return { success: true };
|
|
2936
|
-
}
|
|
2937
|
-
case "EmitStatement": {
|
|
2938
|
-
const data = stmt.data ? await this.evaluateHoloExpression(stmt.data, scopeOverride) : void 0;
|
|
2939
|
-
this.emit(stmt.event, data);
|
|
2940
|
-
return { success: true };
|
|
2941
|
-
}
|
|
2942
|
-
case "AwaitStatement": {
|
|
2943
|
-
const value = await this.evaluateHoloExpression(stmt.expression, scopeOverride);
|
|
2944
|
-
if (value instanceof Promise) await value;
|
|
2945
|
-
return { success: true };
|
|
2946
|
-
}
|
|
2947
|
-
case "ReturnStatement": {
|
|
2948
|
-
const value = stmt.value ? await this.evaluateHoloExpression(stmt.value, scopeOverride) : null;
|
|
2949
|
-
return { success: true, output: value };
|
|
2950
|
-
}
|
|
2951
|
-
case "ExpressionStatement": {
|
|
2952
|
-
const val = await this.evaluateHoloExpression(stmt.expression, scopeOverride);
|
|
2953
|
-
return { success: true, output: val };
|
|
2954
|
-
}
|
|
2955
|
-
default:
|
|
2956
|
-
return {
|
|
2957
|
-
success: false,
|
|
2958
|
-
error: `Unknown stmt type: ${stmt.type}`
|
|
2959
|
-
};
|
|
2960
|
-
}
|
|
2961
|
-
} catch (err) {
|
|
2962
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
2963
|
-
console.error(`[EXEC_ERROR] Statement ${stmt.type} failed:`, errMsg);
|
|
2964
|
-
return { success: false, error: errMsg };
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
|
-
async evaluateHoloExpression(expr, scopeOverride) {
|
|
2968
|
-
switch (expr.type) {
|
|
2969
|
-
case "Literal":
|
|
2970
|
-
return expr.value;
|
|
2971
|
-
case "Identifier":
|
|
2972
|
-
return this.getVariable(expr.name, scopeOverride);
|
|
2973
|
-
case "MemberExpression": {
|
|
2974
|
-
const obj = await this.evaluateHoloExpression(expr.object, scopeOverride);
|
|
2975
|
-
if (obj && typeof obj === "object") {
|
|
2976
|
-
return obj[expr.property];
|
|
2977
|
-
}
|
|
2978
|
-
return void 0;
|
|
2979
|
-
}
|
|
2980
|
-
case "CallExpression": {
|
|
2981
|
-
if (!Array.isArray(expr.arguments)) {
|
|
2982
|
-
console.error("[CRITICAL] arguments is not an array for", JSON.stringify(expr));
|
|
2983
|
-
return void 0;
|
|
2984
|
-
}
|
|
2985
|
-
const callee = await this.evaluateHoloExpression(expr.callee, scopeOverride);
|
|
2986
|
-
const args = await Promise.all(
|
|
2987
|
-
expr.arguments.map((a) => this.evaluateHoloExpression(a, scopeOverride))
|
|
2988
|
-
);
|
|
2989
|
-
if (typeof callee === "function") {
|
|
2990
|
-
return callee(...args);
|
|
2991
|
-
}
|
|
2992
|
-
if (expr.callee.type === "Identifier") {
|
|
2993
|
-
const result = await this.callFunction(expr.callee.name, args);
|
|
2994
|
-
return result.output;
|
|
2995
|
-
}
|
|
2996
|
-
return void 0;
|
|
2997
|
-
}
|
|
2998
|
-
case "BinaryExpression": {
|
|
2999
|
-
const left = await this.evaluateHoloExpression(expr.left, scopeOverride);
|
|
3000
|
-
const right = await this.evaluateHoloExpression(expr.right, scopeOverride);
|
|
3001
|
-
switch (expr.operator) {
|
|
3002
|
-
case "+":
|
|
3003
|
-
return Number(left) + Number(right);
|
|
3004
|
-
case "-":
|
|
3005
|
-
return Number(left) - Number(right);
|
|
3006
|
-
case "*":
|
|
3007
|
-
return Number(left) * Number(right);
|
|
3008
|
-
case "/":
|
|
3009
|
-
return Number(left) / Number(right);
|
|
3010
|
-
case "==":
|
|
3011
|
-
return left == right;
|
|
3012
|
-
case "===":
|
|
3013
|
-
return left === right;
|
|
3014
|
-
case "!=":
|
|
3015
|
-
return left != right;
|
|
3016
|
-
case "!==":
|
|
3017
|
-
return left !== right;
|
|
3018
|
-
case "<":
|
|
3019
|
-
return Number(left) < Number(right);
|
|
3020
|
-
case ">":
|
|
3021
|
-
return Number(left) > Number(right);
|
|
3022
|
-
case "<=":
|
|
3023
|
-
return Number(left) <= Number(right);
|
|
3024
|
-
case ">=":
|
|
3025
|
-
return Number(left) >= Number(right);
|
|
3026
|
-
case "&&":
|
|
3027
|
-
return left && right;
|
|
3028
|
-
case "||":
|
|
3029
|
-
return left || right;
|
|
3030
|
-
default:
|
|
3031
|
-
return void 0;
|
|
3032
|
-
}
|
|
3033
|
-
}
|
|
3034
|
-
case "ConditionalExpression": {
|
|
3035
|
-
const test = await this.evaluateHoloExpression(expr.test, scopeOverride);
|
|
3036
|
-
return test ? await this.evaluateHoloExpression(expr.consequent, scopeOverride) : await this.evaluateHoloExpression(expr.alternate, scopeOverride);
|
|
3037
|
-
}
|
|
3038
|
-
case "UpdateExpression": {
|
|
3039
|
-
const val = await this.evaluateHoloExpression(expr.argument, scopeOverride);
|
|
3040
|
-
const newVal = expr.operator === "++" ? val + 1 : val - 1;
|
|
3041
|
-
const path = this.getMemberPath(expr.argument);
|
|
3042
|
-
if (path) {
|
|
3043
|
-
this.setVariable(path, newVal, scopeOverride);
|
|
3044
|
-
}
|
|
3045
|
-
return expr.prefix ? newVal : val;
|
|
3046
|
-
}
|
|
3047
|
-
case "ArrayExpression": {
|
|
3048
|
-
return await Promise.all(
|
|
3049
|
-
expr.elements.map((e) => this.evaluateHoloExpression(e, scopeOverride))
|
|
3050
|
-
);
|
|
3051
|
-
}
|
|
3052
|
-
case "ObjectExpression": {
|
|
3053
|
-
const obj = {};
|
|
3054
|
-
for (const prop of expr.properties) {
|
|
3055
|
-
obj[prop.key] = await this.evaluateHoloExpression(prop.value, scopeOverride);
|
|
3056
|
-
}
|
|
3057
|
-
return obj;
|
|
3058
|
-
}
|
|
3059
|
-
default:
|
|
3060
|
-
return void 0;
|
|
3061
|
-
}
|
|
3062
|
-
}
|
|
3063
|
-
getMemberPath(expr) {
|
|
3064
|
-
if (expr.type === "Identifier") return expr.name;
|
|
3065
|
-
if (expr.type === "MemberExpression") {
|
|
3066
|
-
const parentPath = this.getMemberPath(expr.object);
|
|
3067
|
-
if (parentPath) return `${parentPath}.${expr.property}`;
|
|
3068
|
-
}
|
|
3069
|
-
return null;
|
|
3070
|
-
}
|
|
3071
|
-
async executeSystem(node) {
|
|
3072
|
-
const startTime = Date.now();
|
|
3073
|
-
const systemId = node.id;
|
|
3074
|
-
const properties = node.properties;
|
|
3075
|
-
chunkILRBGFVD_cjs.logger.info(`[Zero-Config] Provisioning system: ${systemId}`, properties);
|
|
3076
|
-
switch (systemId) {
|
|
3077
|
-
case "Networking":
|
|
3078
|
-
return this.setupNetworking(node);
|
|
3079
|
-
case "Physics":
|
|
3080
|
-
return this.setupPhysics(node);
|
|
3081
|
-
default:
|
|
3082
|
-
chunkILRBGFVD_cjs.logger.warn(`[Zero-Config] Unknown system: ${systemId}`);
|
|
3083
|
-
return {
|
|
3084
|
-
success: true,
|
|
3085
|
-
output: `System ${systemId} not recognized, skipping provisioning`,
|
|
3086
|
-
executionTime: Date.now() - startTime
|
|
3087
|
-
};
|
|
3088
|
-
}
|
|
3089
|
-
}
|
|
3090
|
-
async executeCoreConfig(node) {
|
|
3091
|
-
const startTime = Date.now();
|
|
3092
|
-
chunkILRBGFVD_cjs.logger.info("[Zero-Config] Applying core configuration", node.properties);
|
|
3093
|
-
for (const [key, value] of Object.entries(node.properties)) {
|
|
3094
|
-
this.context.environment[key] = value;
|
|
3095
|
-
}
|
|
3096
|
-
return {
|
|
3097
|
-
success: true,
|
|
3098
|
-
output: "Core configuration applied",
|
|
3099
|
-
executionTime: Date.now() - startTime
|
|
3100
|
-
};
|
|
3101
|
-
}
|
|
3102
|
-
// =========================================================================
|
|
3103
|
-
// Control Flow Execution
|
|
3104
|
-
// =========================================================================
|
|
3105
|
-
/**
|
|
3106
|
-
* Execute a for loop: @for item in collection { ... }
|
|
3107
|
-
*/
|
|
3108
|
-
async executeForLoop(node) {
|
|
3109
|
-
const startTime = Date.now();
|
|
3110
|
-
const { variable, iterable, body } = node;
|
|
3111
|
-
try {
|
|
3112
|
-
const collection = this.evaluateExpression(String(iterable));
|
|
3113
|
-
if (!Array.isArray(collection) && typeof collection !== "object") {
|
|
3114
|
-
return {
|
|
3115
|
-
success: false,
|
|
3116
|
-
error: `Cannot iterate over non-iterable: ${typeof collection}`,
|
|
3117
|
-
executionTime: Date.now() - startTime
|
|
3118
|
-
};
|
|
3119
|
-
}
|
|
3120
|
-
const items = Array.isArray(collection) ? collection : collection && typeof collection === "object" ? Object.entries(collection) : [];
|
|
3121
|
-
let lastResult = { success: true, output: null };
|
|
3122
|
-
for (const item of items) {
|
|
3123
|
-
this.context.variables.set(variable, item);
|
|
3124
|
-
for (const bodyNode of body) {
|
|
3125
|
-
lastResult = await this.executeNode(bodyNode);
|
|
3126
|
-
if (!lastResult.success) break;
|
|
3127
|
-
}
|
|
3128
|
-
if (!lastResult.success) break;
|
|
3129
|
-
}
|
|
3130
|
-
this.context.variables.delete(variable);
|
|
3131
|
-
return {
|
|
3132
|
-
success: true,
|
|
3133
|
-
output: lastResult.output,
|
|
3134
|
-
executionTime: Date.now() - startTime
|
|
3135
|
-
};
|
|
3136
|
-
} catch (error) {
|
|
3137
|
-
return {
|
|
3138
|
-
success: false,
|
|
3139
|
-
error: `For loop error: ${error instanceof Error ? error.message : String(error)}`,
|
|
3140
|
-
executionTime: Date.now() - startTime
|
|
3141
|
-
};
|
|
3142
|
-
}
|
|
3143
|
-
}
|
|
3144
|
-
/**
|
|
3145
|
-
* Execute a forEach loop: @forEach item in collection { ... }
|
|
3146
|
-
*/
|
|
3147
|
-
async executeForEachLoop(node) {
|
|
3148
|
-
return this.executeForLoop({
|
|
3149
|
-
variable: node.variable,
|
|
3150
|
-
iterable: node.collection,
|
|
3151
|
-
body: node.body
|
|
3152
|
-
});
|
|
3153
|
-
}
|
|
3154
|
-
/**
|
|
3155
|
-
* Execute a while loop: @while condition { ... }
|
|
3156
|
-
*/
|
|
3157
|
-
async executeWhileLoop(node) {
|
|
3158
|
-
const startTime = Date.now();
|
|
3159
|
-
const { condition, body } = node;
|
|
3160
|
-
const MAX_ITERATIONS = 1e4;
|
|
3161
|
-
try {
|
|
3162
|
-
let iterations = 0;
|
|
3163
|
-
let lastResult = { success: true, output: null };
|
|
3164
|
-
while (this.evaluateCondition(String(condition))) {
|
|
3165
|
-
iterations++;
|
|
3166
|
-
if (iterations > MAX_ITERATIONS) {
|
|
3167
|
-
return {
|
|
3168
|
-
success: false,
|
|
3169
|
-
error: `While loop exceeded maximum iterations (${MAX_ITERATIONS})`,
|
|
3170
|
-
executionTime: Date.now() - startTime
|
|
3171
|
-
};
|
|
3172
|
-
}
|
|
3173
|
-
for (const bodyNode of body) {
|
|
3174
|
-
lastResult = await this.executeNode(bodyNode);
|
|
3175
|
-
if (!lastResult.success) break;
|
|
3176
|
-
}
|
|
3177
|
-
if (!lastResult.success) break;
|
|
3178
|
-
}
|
|
3179
|
-
return {
|
|
3180
|
-
success: true,
|
|
3181
|
-
output: lastResult.output,
|
|
3182
|
-
executionTime: Date.now() - startTime
|
|
3183
|
-
};
|
|
3184
|
-
} catch (error) {
|
|
3185
|
-
return {
|
|
3186
|
-
success: false,
|
|
3187
|
-
error: `While loop error: ${error instanceof Error ? error.message : String(error)}`,
|
|
3188
|
-
executionTime: Date.now() - startTime
|
|
3189
|
-
};
|
|
3190
|
-
}
|
|
3191
|
-
}
|
|
3192
|
-
/**
|
|
3193
|
-
* Execute an if statement: @if condition { ... } @else { ... }
|
|
3194
|
-
*/
|
|
3195
|
-
async executeIfStatement(node) {
|
|
3196
|
-
const startTime = Date.now();
|
|
3197
|
-
const { condition, body, elseBody } = node;
|
|
3198
|
-
try {
|
|
3199
|
-
const conditionResult = this.evaluateCondition(String(condition));
|
|
3200
|
-
const branchToExecute = conditionResult ? body : elseBody || [];
|
|
3201
|
-
let lastResult = { success: true, output: null };
|
|
3202
|
-
for (const bodyNode of branchToExecute) {
|
|
3203
|
-
lastResult = await this.executeNode(bodyNode);
|
|
3204
|
-
if (!lastResult.success) break;
|
|
3205
|
-
}
|
|
3206
|
-
return {
|
|
3207
|
-
success: true,
|
|
3208
|
-
output: lastResult.output,
|
|
3209
|
-
executionTime: Date.now() - startTime
|
|
3210
|
-
};
|
|
3211
|
-
} catch (error) {
|
|
3212
|
-
return {
|
|
3213
|
-
success: false,
|
|
3214
|
-
error: `If statement error: ${error instanceof Error ? error.message : String(error)}`,
|
|
3215
|
-
executionTime: Date.now() - startTime
|
|
3216
|
-
};
|
|
3217
|
-
}
|
|
3218
|
-
}
|
|
3219
|
-
/**
|
|
3220
|
-
* Execute a match expression: @match subject { pattern => result, ... }
|
|
3221
|
-
*/
|
|
3222
|
-
async executeMatch(node) {
|
|
3223
|
-
const startTime = Date.now();
|
|
3224
|
-
const { subject, cases } = node;
|
|
3225
|
-
try {
|
|
3226
|
-
const subjectValue = this.evaluateExpression(String(subject));
|
|
3227
|
-
for (const matchCase of cases || []) {
|
|
3228
|
-
const patternValue = this.evaluateExpression(String(matchCase.pattern));
|
|
3229
|
-
if (this.patternMatches(patternValue, subjectValue)) {
|
|
3230
|
-
if (matchCase.guard && !this.evaluateCondition(String(matchCase.guard))) {
|
|
3231
|
-
continue;
|
|
3232
|
-
}
|
|
3233
|
-
if (Array.isArray(matchCase.body)) {
|
|
3234
|
-
let lastResult = { success: true, output: null };
|
|
3235
|
-
for (const bodyNode of matchCase.body) {
|
|
3236
|
-
lastResult = await this.executeNode(bodyNode);
|
|
3237
|
-
if (!lastResult.success) break;
|
|
3238
|
-
}
|
|
3239
|
-
return lastResult;
|
|
3240
|
-
} else {
|
|
3241
|
-
const result = this.evaluateExpression(String(matchCase.body));
|
|
3242
|
-
return { success: true, output: result, executionTime: Date.now() - startTime };
|
|
3243
|
-
}
|
|
3244
|
-
}
|
|
3245
|
-
}
|
|
3246
|
-
return {
|
|
3247
|
-
success: false,
|
|
3248
|
-
error: "No pattern matched",
|
|
3249
|
-
executionTime: Date.now() - startTime
|
|
3250
|
-
};
|
|
3251
|
-
} catch (error) {
|
|
3252
|
-
return {
|
|
3253
|
-
success: false,
|
|
3254
|
-
error: `Match expression error: ${error instanceof Error ? error.message : String(error)}`,
|
|
3255
|
-
executionTime: Date.now() - startTime
|
|
3256
|
-
};
|
|
3257
|
-
}
|
|
3258
|
-
}
|
|
3259
|
-
/**
|
|
3260
|
-
* Check if a pattern matches a value
|
|
3261
|
-
*/
|
|
3262
|
-
patternMatches(pattern, value) {
|
|
3263
|
-
if (pattern === "_" || pattern === "else" || pattern === "default") {
|
|
3264
|
-
return true;
|
|
3265
|
-
}
|
|
3266
|
-
if (pattern === value) {
|
|
3267
|
-
return true;
|
|
3268
|
-
}
|
|
3269
|
-
if (pattern === "string" && typeof value === "string") return true;
|
|
3270
|
-
if (pattern === "number" && typeof value === "number") return true;
|
|
3271
|
-
if (pattern === "boolean" && typeof value === "boolean") return true;
|
|
3272
|
-
if (pattern === "array" && Array.isArray(value)) return true;
|
|
3273
|
-
if (pattern === "object" && typeof value === "object" && value !== null) return true;
|
|
3274
|
-
if (Array.isArray(pattern) && pattern.length === 2) {
|
|
3275
|
-
const [min, max] = pattern;
|
|
3276
|
-
if (typeof value === "number" && typeof min === "number" && typeof max === "number" && value >= min && value <= max) {
|
|
3277
|
-
return true;
|
|
3278
|
-
}
|
|
3279
|
-
}
|
|
3280
|
-
return false;
|
|
3281
|
-
}
|
|
3282
|
-
async executeNarrative(node) {
|
|
3283
|
-
const startTime = Date.now();
|
|
3284
|
-
chunkILRBGFVD_cjs.logger.info(`[Narrative] Initializing narrative: ${node.id}`);
|
|
3285
|
-
for (const quest of node.quests) {
|
|
3286
|
-
this.context.quests.set(quest.id, quest);
|
|
3287
|
-
}
|
|
3288
|
-
if (node.startNode) {
|
|
3289
|
-
chunkILRBGFVD_cjs.logger.info(`[Narrative] Auto-starting at node: ${node.startNode}`);
|
|
3290
|
-
}
|
|
3291
|
-
return {
|
|
3292
|
-
success: true,
|
|
3293
|
-
output: `Narrative ${node.id} initialized with ${node.quests.length} quests`,
|
|
3294
|
-
executionTime: Date.now() - startTime
|
|
3295
|
-
};
|
|
3296
|
-
}
|
|
3297
|
-
async executeQuest(node) {
|
|
3298
|
-
const startTime = Date.now();
|
|
3299
|
-
chunkILRBGFVD_cjs.logger.info(`[Narrative] Starting quest: ${node.title}`, { questId: node.id });
|
|
3300
|
-
this.context.activeQuestId = node.id;
|
|
3301
|
-
this.context.quests.set(node.id, node);
|
|
3302
|
-
return {
|
|
3303
|
-
success: true,
|
|
3304
|
-
output: `Quest ${node.id} started`,
|
|
3305
|
-
executionTime: Date.now() - startTime
|
|
3306
|
-
};
|
|
3307
|
-
}
|
|
3308
|
-
async executeDialogue(node) {
|
|
3309
|
-
const startTime = Date.now();
|
|
3310
|
-
chunkILRBGFVD_cjs.logger.info(`[Narrative] Dialogue: ${node.speaker} says "${node.text}"`);
|
|
3311
|
-
this.context.dialogueState = {
|
|
3312
|
-
currentNodeId: node.id,
|
|
3313
|
-
speaker: node.speaker
|
|
3314
|
-
};
|
|
3315
|
-
return {
|
|
3316
|
-
success: true,
|
|
3317
|
-
output: `Dialogue node ${node.id} executed`,
|
|
3318
|
-
executionTime: Date.now() - startTime
|
|
3319
|
-
};
|
|
3320
|
-
}
|
|
3321
|
-
async executeVisualMetadata(node) {
|
|
3322
|
-
chunkILRBGFVD_cjs.logger.info(`[Metadata] Visual metadata processed`, node.properties);
|
|
3323
|
-
return { success: true, output: "Visual metadata applied" };
|
|
3324
|
-
}
|
|
3325
|
-
async setupNetworking(node) {
|
|
3326
|
-
const startTime = Date.now();
|
|
3327
|
-
chunkILRBGFVD_cjs.logger.info("[Networking] Initializing multiplayer fabric...", node.properties);
|
|
3328
|
-
return {
|
|
3329
|
-
success: true,
|
|
3330
|
-
output: "Networking system provisioned",
|
|
3331
|
-
executionTime: Date.now() - startTime
|
|
3332
|
-
};
|
|
3333
|
-
}
|
|
3334
|
-
async setupPhysics(node) {
|
|
3335
|
-
const startTime = Date.now();
|
|
3336
|
-
chunkILRBGFVD_cjs.logger.info("[Physics] Initializing spatial simulation engine...", node.properties);
|
|
3337
|
-
return {
|
|
3338
|
-
success: true,
|
|
3339
|
-
output: "Physics system provisioned",
|
|
3340
|
-
executionTime: Date.now() - startTime
|
|
3341
|
-
};
|
|
3342
|
-
}
|
|
3343
|
-
async executeTemplate(node) {
|
|
3344
|
-
const existing = this.context.templates.get(node.name);
|
|
3345
|
-
if (existing) {
|
|
3346
|
-
node._previousVersion = existing.version;
|
|
3347
|
-
}
|
|
3348
|
-
this.context.templates.set(node.name, node);
|
|
3349
|
-
return {
|
|
3350
|
-
success: true,
|
|
3351
|
-
output: `Template ${node.name} registered (v${node.version || "unknown"})`
|
|
3352
|
-
};
|
|
3353
|
-
}
|
|
3354
|
-
/**
|
|
3355
|
-
* Execute a migration script for an object
|
|
3356
|
-
*/
|
|
3357
|
-
async executeMigrationBlock(orb, migration) {
|
|
3358
|
-
chunkILRBGFVD_cjs.logger.info(`Running migration for ${orb.name}...`);
|
|
3359
|
-
const previousScope = this.currentScope;
|
|
3360
|
-
this.currentScope = {
|
|
3361
|
-
variables: /* @__PURE__ */ new Map([
|
|
3362
|
-
["this", orb],
|
|
3363
|
-
["self", orb]
|
|
3364
|
-
]),
|
|
3365
|
-
parent: previousScope
|
|
3366
|
-
};
|
|
3367
|
-
try {
|
|
3368
|
-
const parser = new chunkT7LEXZUZ_cjs.HoloScriptCodeParser();
|
|
3369
|
-
const result = parser.parse(migration.body);
|
|
3370
|
-
if (result.errors.length > 0) {
|
|
3371
|
-
chunkILRBGFVD_cjs.logger.error(`Migration parse errors for ${orb.name}:`, {
|
|
3372
|
-
errors: result.errors
|
|
3373
|
-
});
|
|
3374
|
-
return;
|
|
3375
|
-
}
|
|
3376
|
-
await this.executeProgram(result.ast, 0);
|
|
3377
|
-
} finally {
|
|
3378
|
-
this.currentScope = previousScope;
|
|
3379
|
-
}
|
|
3380
|
-
chunkILRBGFVD_cjs.logger.info(`Migration complete for ${orb.name}`);
|
|
3381
|
-
}
|
|
3382
|
-
async executeServerNode(node) {
|
|
3383
|
-
if (this.context.mode === "public") {
|
|
3384
|
-
return {
|
|
3385
|
-
success: false,
|
|
3386
|
-
error: "SecurityViolation: Server creation blocked in public mode.",
|
|
3387
|
-
executionTime: 0
|
|
3388
|
-
};
|
|
3389
|
-
}
|
|
3390
|
-
chunkILRBGFVD_cjs.logger.info(`Starting server on port ${node.port}`);
|
|
3391
|
-
return {
|
|
3392
|
-
success: true,
|
|
3393
|
-
output: `Server listening on port ${node.port}`,
|
|
3394
|
-
hologram: node.hologram,
|
|
3395
|
-
executionTime: 0
|
|
3396
|
-
};
|
|
3397
|
-
}
|
|
3398
|
-
async executeDatabaseNode(node) {
|
|
3399
|
-
if (this.context.mode === "public") {
|
|
3400
|
-
return {
|
|
3401
|
-
success: false,
|
|
3402
|
-
error: "SecurityViolation: DB access blocked in public mode.",
|
|
3403
|
-
executionTime: 0
|
|
3404
|
-
};
|
|
3405
|
-
}
|
|
3406
|
-
chunkILRBGFVD_cjs.logger.info(`Executing Query: ${node.query}`);
|
|
3407
|
-
return {
|
|
3408
|
-
success: true,
|
|
3409
|
-
output: `Query executed: ${node.query}`,
|
|
3410
|
-
hologram: node.hologram,
|
|
3411
|
-
executionTime: 0
|
|
3412
|
-
};
|
|
3413
|
-
}
|
|
3414
|
-
async executeFetchNode(node) {
|
|
3415
|
-
if (this.context.mode === "public") {
|
|
3416
|
-
return {
|
|
3417
|
-
success: false,
|
|
3418
|
-
error: "SecurityViolation: External fetch blocked in public mode.",
|
|
3419
|
-
executionTime: 0
|
|
3420
|
-
};
|
|
3421
|
-
}
|
|
3422
|
-
chunkILRBGFVD_cjs.logger.info(`Fetching: ${node.url}`);
|
|
3423
|
-
return {
|
|
3424
|
-
success: true,
|
|
3425
|
-
output: `Fetched data from ${node.url}`,
|
|
3426
|
-
hologram: node.hologram,
|
|
3427
|
-
executionTime: 0
|
|
3428
|
-
};
|
|
3429
|
-
}
|
|
3430
|
-
async executeTarget(node) {
|
|
3431
|
-
const target = this.context.functions.get(node.target);
|
|
3432
|
-
if (!target) {
|
|
3433
|
-
return {
|
|
3434
|
-
success: false,
|
|
3435
|
-
error: `Function ${node.target} not found`,
|
|
3436
|
-
executionTime: 0
|
|
3437
|
-
};
|
|
3438
|
-
}
|
|
3439
|
-
const result = await this.executeFunction(target);
|
|
3440
|
-
this.createExecutionEffect(node.target, target.position || { x: 0, y: 0, z: 0 });
|
|
3441
|
-
return {
|
|
3442
|
-
success: true,
|
|
3443
|
-
output: `Executed ${node.target}`,
|
|
3444
|
-
hologram: {
|
|
3445
|
-
shape: "sphere",
|
|
3446
|
-
color: "#ff4500",
|
|
3447
|
-
size: 1.2,
|
|
3448
|
-
glow: true,
|
|
3449
|
-
interactive: false
|
|
3450
|
-
},
|
|
3451
|
-
executionTime: result.executionTime
|
|
3452
|
-
};
|
|
3453
|
-
}
|
|
3454
|
-
async executeStateDeclaration(node) {
|
|
3455
|
-
const stateDirective = node.directives?.find((d) => d.type === "state");
|
|
3456
|
-
if (stateDirective) {
|
|
3457
|
-
this.context.state.update(stateDirective.body);
|
|
3458
|
-
}
|
|
3459
|
-
return { success: true, output: "State updated" };
|
|
3460
|
-
}
|
|
3461
|
-
// ============================================================================
|
|
3462
|
-
// Memory Syntactic Execution (Phase 7 / EVOLVE)
|
|
3463
|
-
// ============================================================================
|
|
3464
|
-
async executeMemory(node) {
|
|
3465
|
-
const startTime = Date.now();
|
|
3466
|
-
chunkILRBGFVD_cjs.logger.info(`[Memory] Initializing memory block: ${node.name}`);
|
|
3467
|
-
const memoryState = {
|
|
3468
|
-
id: node.name,
|
|
3469
|
-
type: "agent-memory"
|
|
3470
|
-
};
|
|
3471
|
-
if (node.semantic) {
|
|
3472
|
-
const semResult = await this.executeNode(node.semantic);
|
|
3473
|
-
if (semResult.success) memoryState.semantic = semResult.output;
|
|
3474
|
-
}
|
|
3475
|
-
if (node.episodic) {
|
|
3476
|
-
const epResult = await this.executeNode(node.episodic);
|
|
3477
|
-
if (epResult.success) memoryState.episodic = epResult.output;
|
|
3478
|
-
}
|
|
3479
|
-
if (node.procedural) {
|
|
3480
|
-
const procResult = await this.executeNode(node.procedural);
|
|
3481
|
-
if (procResult.success) memoryState.procedural = procResult.output;
|
|
3482
|
-
}
|
|
3483
|
-
this.context.variables.set(node.name, memoryState);
|
|
3484
|
-
this.emit("memory_initialized", { memoryId: node.name, config: memoryState });
|
|
3485
|
-
return {
|
|
3486
|
-
success: true,
|
|
3487
|
-
output: memoryState,
|
|
3488
|
-
executionTime: Date.now() - startTime
|
|
3489
|
-
};
|
|
3490
|
-
}
|
|
3491
|
-
loadSkill(skill) {
|
|
3492
|
-
chunkILRBGFVD_cjs.logger.info(`[Procedural] Loading skill: ${skill.name} (${skill.id})`);
|
|
3493
|
-
const existing = this.proceduralSkills.get(skill.id);
|
|
3494
|
-
if (existing) {
|
|
3495
|
-
skill.successRate = (existing.successRate + (skill.successRate || 0)) / 2;
|
|
3496
|
-
} else {
|
|
3497
|
-
skill.successRate = skill.successRate || 0;
|
|
3498
|
-
}
|
|
3499
|
-
this.proceduralSkills.set(skill.id, skill);
|
|
3500
|
-
mesh.StateSynchronizer.getInstance().broadcastSkill(skill);
|
|
3501
|
-
}
|
|
3502
|
-
async executeSkill(skillId, contextVariables = {}) {
|
|
3503
|
-
const skill = this.proceduralSkills.get(skillId);
|
|
3504
|
-
if (!skill) {
|
|
3505
|
-
throw new Error(`[Procedural] Skill '${skillId}' not found.`);
|
|
3506
|
-
}
|
|
3507
|
-
chunkILRBGFVD_cjs.logger.info(`[Procedural] Executing skill: ${skill.name}`);
|
|
3508
|
-
const startTime = Date.now();
|
|
3509
|
-
const previousScope = this.currentScope;
|
|
3510
|
-
this.currentScope = { variables: new Map(previousScope.variables), parent: previousScope };
|
|
3511
|
-
for (const [key, val] of Object.entries(contextVariables)) {
|
|
3512
|
-
this.currentScope.variables.set(key, val);
|
|
3513
|
-
}
|
|
3514
|
-
try {
|
|
3515
|
-
const result = await this.executeNode(skill.action);
|
|
3516
|
-
if (result.success) {
|
|
3517
|
-
skill.successRate = Math.min(100, skill.successRate + 1);
|
|
3518
|
-
} else {
|
|
3519
|
-
skill.successRate = Math.max(0, skill.successRate - 1);
|
|
3520
|
-
}
|
|
3521
|
-
mesh.StateSynchronizer.getInstance().broadcastSkill(skill);
|
|
3522
|
-
return {
|
|
3523
|
-
...result,
|
|
3524
|
-
executionTime: Date.now() - startTime
|
|
3525
|
-
};
|
|
3526
|
-
} finally {
|
|
3527
|
-
this.currentScope = previousScope;
|
|
3528
|
-
}
|
|
3529
|
-
}
|
|
3530
|
-
async executeMemoryDefinition(node) {
|
|
3531
|
-
const startTime = Date.now();
|
|
3532
|
-
const config = {};
|
|
3533
|
-
for (const [key, val] of Object.entries(node.properties || {})) {
|
|
3534
|
-
if (typeof val === "string") {
|
|
3535
|
-
config[key] = this.evaluateExpression(val);
|
|
3536
|
-
} else {
|
|
3537
|
-
config[key] = val;
|
|
3538
|
-
}
|
|
3539
|
-
}
|
|
3540
|
-
return {
|
|
3541
|
-
success: true,
|
|
3542
|
-
output: {
|
|
3543
|
-
type: node.type,
|
|
3544
|
-
config
|
|
3545
|
-
},
|
|
3546
|
-
executionTime: Date.now() - startTime
|
|
3547
|
-
};
|
|
3548
|
-
}
|
|
3549
|
-
applyDirectives(node) {
|
|
3550
|
-
if (!node.directives) return;
|
|
3551
|
-
for (const d of node.directives) {
|
|
3552
|
-
if (d.type === "trait") {
|
|
3553
|
-
chunkILRBGFVD_cjs.logger.info(`Applying trait ${d.name} to ${node.type}`);
|
|
3554
|
-
const handler = this.traitHandlers.get(d.name);
|
|
3555
|
-
if (handler) {
|
|
3556
|
-
handler.onAttach?.(node, d.config || {}, {
|
|
3557
|
-
emit: (event, payload) => this.emit(event, payload),
|
|
3558
|
-
getScaleMultiplier: () => this.context.currentScale || 1
|
|
3559
|
-
});
|
|
3560
|
-
}
|
|
3561
|
-
if (d.name === "chat") {
|
|
3562
|
-
this.emit("show-chat", d.config);
|
|
3563
|
-
}
|
|
3564
|
-
} else if (d.type === "state") {
|
|
3565
|
-
if (node && node.__type === "orb") {
|
|
3566
|
-
const stateBody = d.body;
|
|
3567
|
-
const existingProps = node.properties || {};
|
|
3568
|
-
for (const [key, val] of Object.entries(stateBody)) {
|
|
3569
|
-
if (existingProps[key] === void 0) {
|
|
3570
|
-
existingProps[key] = val;
|
|
3571
|
-
}
|
|
3572
|
-
}
|
|
3573
|
-
node.properties = existingProps;
|
|
3574
|
-
}
|
|
3575
|
-
this.context.state.update(d.body);
|
|
3576
|
-
} else if (d.type === "lifecycle") {
|
|
3577
|
-
if (d.hook === "on_mount" || d.hook === "mount") {
|
|
3578
|
-
this.evaluateExpression(d.body);
|
|
3579
|
-
}
|
|
3580
|
-
}
|
|
3581
|
-
}
|
|
3582
|
-
}
|
|
3583
|
-
getExecutionHistory() {
|
|
3584
|
-
return [...this.executionHistory];
|
|
3585
|
-
}
|
|
3586
|
-
getHologramStates() {
|
|
3587
|
-
return new Map(this.context.hologramState);
|
|
3588
|
-
}
|
|
3589
|
-
getCallStack() {
|
|
3590
|
-
return [...this.callStack];
|
|
3591
|
-
}
|
|
3592
|
-
getState() {
|
|
3593
|
-
return this.context.state.getSnapshot();
|
|
3594
|
-
}
|
|
3595
|
-
getRootScope() {
|
|
3596
|
-
return this.currentScope;
|
|
3597
|
-
}
|
|
3598
|
-
isAgent(node) {
|
|
3599
|
-
return !!node.directives?.some(
|
|
3600
|
-
(d) => d.type === "trait" && (d.name === "llm_agent" || d.name === "agent" || d.name === "companion")
|
|
3601
|
-
);
|
|
3602
|
-
}
|
|
3603
|
-
/**
|
|
3604
|
-
* Get current simulation time (Julian date) for orbital calculations
|
|
3605
|
-
*/
|
|
3606
|
-
getSimulationTime() {
|
|
3607
|
-
return this.timeManager?.getJulianDate() || 0;
|
|
3608
|
-
}
|
|
3609
|
-
/**
|
|
3610
|
-
* Set orb position and broadcast update
|
|
3611
|
-
*/
|
|
3612
|
-
setOrbPosition(orbName, position) {
|
|
3613
|
-
const orb = this.context.variables.get(orbName);
|
|
3614
|
-
if (orb && typeof orb === "object" && orb.__type === "orb") {
|
|
3615
|
-
orb.position = position;
|
|
3616
|
-
this.broadcast("orb_update", {
|
|
3617
|
-
orb: {
|
|
3618
|
-
id: orbName,
|
|
3619
|
-
name: orbName,
|
|
3620
|
-
position
|
|
3621
|
-
}
|
|
3622
|
-
});
|
|
3623
|
-
}
|
|
3624
|
-
}
|
|
3625
|
-
/**
|
|
3626
|
-
* Update all orbs that have traits with an onUpdate method
|
|
3627
|
-
*/
|
|
3628
|
-
updateTraits(julianDate) {
|
|
3629
|
-
const delta = 1 / 60;
|
|
3630
|
-
for (const [name, value] of this.context.variables.entries()) {
|
|
3631
|
-
if (value && typeof value === "object" && value.__type === "orb") {
|
|
3632
|
-
const orb = value;
|
|
3633
|
-
if (orb.directives) {
|
|
3634
|
-
for (const d of orb.directives || []) {
|
|
3635
|
-
if (d.type === "trait") {
|
|
3636
|
-
const handler = this.traitHandlers.get(d.name);
|
|
3637
|
-
if (handler && handler.onUpdate) {
|
|
3638
|
-
const traitNode = orb;
|
|
3639
|
-
handler.onUpdate(
|
|
3640
|
-
traitNode,
|
|
3641
|
-
d.config || {},
|
|
3642
|
-
{
|
|
3643
|
-
emit: (event, payload) => {
|
|
3644
|
-
if (event === "position_update") {
|
|
3645
|
-
const posPayload = payload;
|
|
3646
|
-
if (posPayload?.position) {
|
|
3647
|
-
this.setOrbPosition(
|
|
3648
|
-
name,
|
|
3649
|
-
posPayload.position
|
|
3650
|
-
);
|
|
3651
|
-
}
|
|
3652
|
-
}
|
|
3653
|
-
return this.emit(event, payload);
|
|
3654
|
-
},
|
|
3655
|
-
getScaleMultiplier: () => this.context.currentScale || 1,
|
|
3656
|
-
julianDate,
|
|
3657
|
-
getNode: (nodeName) => this.context.variables.get(nodeName),
|
|
3658
|
-
getState: () => this.getState(),
|
|
3659
|
-
setState: (updates) => this.context.state.update(updates)
|
|
3660
|
-
},
|
|
3661
|
-
delta
|
|
3662
|
-
);
|
|
3663
|
-
}
|
|
3664
|
-
}
|
|
3665
|
-
}
|
|
3666
|
-
}
|
|
3667
|
-
}
|
|
3668
|
-
}
|
|
3669
|
-
}
|
|
3670
|
-
};
|
|
3671
|
-
chunk3SAK5KFL_cjs.__decorateClass([
|
|
3672
|
-
RuntimeOptimization.MethodMemoize(500)
|
|
3673
|
-
], HoloScriptRuntime.prototype, "getMemberPath", 1);
|
|
3674
|
-
|
|
3675
|
-
exports.EventBus = EventBus;
|
|
3676
|
-
exports.HoloScriptRuntime = HoloScriptRuntime;
|
|
3677
|
-
exports.getSharedEventBus = getSharedEventBus;
|
|
3678
|
-
exports.setSharedEventBus = setSharedEventBus;
|
|
3679
|
-
exports.telemetry = telemetry;
|
|
3680
|
-
//# sourceMappingURL=chunk-X6SEAXAX.cjs.map
|
|
3681
|
-
//# sourceMappingURL=chunk-X6SEAXAX.cjs.map
|