@holoscript/core 6.0.3 → 6.1.1
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/README.md +40 -40
- package/bin/holoscript.cjs +3 -0
- package/dist/GLTFPipeline-SFIORFJU.js +16 -0
- package/dist/GLTFPipeline-VNNDPONV.cjs +37 -0
- package/dist/{HoloScriptPlusParser-BZR5DELQ.js → HoloScriptPlusParser-7FBIFUFC.js} +6 -5
- package/dist/{HoloScriptPlusParser-SBMYDNXO.cjs → HoloScriptPlusParser-A2W7OCN2.cjs} +17 -16
- package/dist/HoloScriptPlusParser-F2Z56FJR.js +10 -0
- package/dist/HoloScriptPlusParser-WKHRIH6T.cjs +27 -0
- package/dist/{USDZExporter-MHEHXZB4.cjs → USDZExporter-3FWJ25JI.cjs} +344 -16
- package/dist/{USDZExporter-YA55ZS35.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-XSUZMPVQ.cjs → chunk-27MPVJVZ.cjs} +64 -28
- package/dist/{chunk-W76ETJTI.js → chunk-2A7FURVO.js} +44 -8
- package/dist/{chunk-C7BNX4XJ.js → chunk-2B7WVIDZ.js} +11 -8
- package/dist/chunk-2BSMSUCE.js +1941 -0
- package/dist/chunk-2HLIGOKU.cjs +5546 -0
- package/dist/{chunk-GC3YU46J.js → chunk-2M2DPHKB.js} +4 -4
- package/dist/{chunk-A6GO3DPZ.cjs → chunk-2YSNA2F2.cjs} +321 -49
- package/dist/{chunk-ZL6VJ6SN.js → chunk-33XCOVE3.js} +5 -5
- package/dist/chunk-3FOKASKO.cjs +348 -0
- package/dist/{chunk-XSF76QRU.js → chunk-4C57PR42.js} +3 -3
- package/dist/chunk-4N4SXXWF.js +769 -0
- package/dist/chunk-4PDEPEQW.cjs +41 -0
- package/dist/chunk-4R6SBXDB.js +45 -0
- package/dist/chunk-4SY77NA4.cjs +413 -0
- package/dist/{chunk-74YCHHTE.js → chunk-4UUKPCY4.js} +670 -116
- package/dist/{chunk-VZNKJZTT.cjs → chunk-52ULD552.cjs} +178 -113
- package/dist/{chunk-65RFOWZI.js → chunk-5CKA5SXU.js} +441 -23
- 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-EJA7G2C4.cjs → chunk-5WUNN6ZN.cjs} +2 -2
- package/dist/{chunk-ELLQPFAF.js → chunk-6ASWLXXN.js} +24 -10
- package/dist/chunk-6CTRH7HT.cjs +1985 -0
- package/dist/{chunk-ARNKA274.cjs → chunk-6EX3I5P4.cjs} +6 -6
- package/dist/chunk-6FGQNDR4.js +5731 -0
- package/dist/{chunk-X4YVN7H3.cjs → chunk-6KMK2UXT.cjs} +152 -56
- package/dist/{chunk-KUJRR4FJ.js → chunk-6L4VE27M.js} +36 -24
- package/dist/{chunk-RT7LJRSF.cjs → chunk-6S6TKNEA.cjs} +7357 -8312
- package/dist/chunk-77V4GTCA.js +596 -0
- package/dist/{chunk-XH7SE4HH.cjs → chunk-7AD52FRS.cjs} +19 -19
- package/dist/chunk-7OPW2KO7.cjs +639 -0
- package/dist/chunk-A6KINLZJ.js +236 -0
- package/dist/chunk-AIA52I7T.cjs +543 -0
- package/dist/chunk-AIX25INK.cjs +602 -0
- package/dist/{chunk-WN3YF33G.cjs → chunk-AO4I2Z7M.cjs} +15 -17
- package/dist/{chunk-TSWTWZ42.cjs → chunk-BPICAGBV.cjs} +376 -209
- package/dist/chunk-BRQJKJGT.cjs +20 -0
- package/dist/{chunk-3FXV5S25.cjs → chunk-C37BHB7N.cjs} +6 -3
- package/dist/{chunk-XNMEH2BI.js → chunk-CBJY23VL.js} +3 -3
- package/dist/chunk-CIWWXYHZ.cjs +50 -0
- package/dist/{chunk-NTMZSDXM.cjs → chunk-DIL6DDDN.cjs} +101 -45
- package/dist/chunk-DMXC24WV.js +404 -0
- package/dist/{chunk-SPDELRRV.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-7N3JIJMT.js → chunk-EMMC5CSQ.js} +12 -8
- package/dist/{chunk-EUFLX2PI.js → chunk-EOBB6A4B.js} +7263 -8214
- package/dist/chunk-EOFNVCM6.js +325 -0
- package/dist/{chunk-NKRKT6V2.js → chunk-ER4GATIU.js} +11 -10
- 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-HBZYCASG.js → chunk-FXKTYFYA.js} +203 -36
- package/dist/chunk-GCMWDSBZ.cjs +729 -0
- package/dist/chunk-GJNCFRJU.cjs +125 -0
- package/dist/{chunk-I3XGTIHM.cjs → chunk-GMP623FG.cjs} +16 -13
- package/dist/{chunk-CNVM7J3M.js → chunk-GN3KDX4W.js} +149 -53
- package/dist/{chunk-WFJIDI2N.cjs → chunk-GQYKQSTC.cjs} +10 -10
- package/dist/chunk-GTU2Z2WW.cjs +262 -0
- package/dist/chunk-GZG4KA4E.js +529 -0
- package/dist/{chunk-DIEDKX5B.cjs → chunk-H3MGK7TX.cjs} +45 -33
- package/dist/{chunk-DN7UFU63.cjs → chunk-H5DZIHJP.cjs} +14 -17
- package/dist/{chunk-DH5G2JUA.cjs → chunk-HANL7K2Q.cjs} +66 -53
- package/dist/{chunk-EGIZHYJP.cjs → chunk-HCCQLAA4.cjs} +2 -13
- package/dist/{chunk-HHS6FMOU.cjs → chunk-HGVXZDSK.cjs} +178 -29
- package/dist/{chunk-LBPEZQAF.js → chunk-HRODTEEO.js} +30 -10
- package/dist/{chunk-ZGTGVSTZ.js → chunk-HYNTS5CP.js} +2 -2
- package/dist/{chunk-RE3OKSYF.cjs → chunk-HZCQO4JM.cjs} +6 -6
- package/dist/{chunk-NCUHGRTZ.js → chunk-I2O7TW6B.js} +12 -8
- package/dist/chunk-IHESJZSW.js +4490 -0
- package/dist/{chunk-7H5UNJZD.cjs → chunk-IRWWS72C.cjs} +64 -22
- package/dist/{chunk-EMO7HAKJ.cjs → chunk-IVIA7K75.cjs} +691 -133
- package/dist/chunk-IVY74O6C.js +247 -0
- package/dist/chunk-J32ZJZJH.js +554 -0
- package/dist/chunk-JD7CIZ33.js +1949 -0
- package/dist/{chunk-7X2IEJIE.cjs → chunk-JIYN45TV.cjs} +41 -42
- package/dist/{chunk-XDXZM3ZP.cjs → chunk-KHPCJRI3.cjs} +24 -21
- package/dist/chunk-KKFZ3B6J.cjs +557 -0
- package/dist/chunk-KPJL34Y7.cjs +186 -0
- package/dist/{chunk-7KPI4EKH.cjs → chunk-KQTPCYTG.cjs} +130 -50
- package/dist/{chunk-F5LVGHNT.js → chunk-KX76JUQY.js} +3 -3
- package/dist/chunk-L4LFINPO.js +623 -0
- package/dist/{chunk-2UX5LRAP.cjs → chunk-L63H3SQ4.cjs} +46 -32
- package/dist/{chunk-NLPSZT4C.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-PQLGZKMC.cjs → chunk-MJVIRCUV.cjs} +31 -27
- package/dist/{chunk-AC4BSHFV.js → chunk-MSMIFMBL.js} +135 -18
- package/dist/{chunk-56IF4NTA.js → chunk-MXFUTKCO.js} +18 -18
- package/dist/{chunk-NRUB55IT.cjs → chunk-MXJ5SS53.cjs} +450 -32
- package/dist/chunk-MXWNGCRS.js +2176 -0
- package/dist/chunk-MYY4PMWX.cjs +264 -0
- package/dist/chunk-N75IH2HY.js +258 -0
- package/dist/chunk-NG77ATEW.cjs +778 -0
- package/dist/chunk-NW5G5FBQ.js +215 -0
- package/dist/{chunk-4FCZDTD5.js → chunk-OEFY723R.js} +29 -16
- package/dist/chunk-OEV5RMZO.cjs +3042 -0
- package/dist/{chunk-VSXOIUCF.cjs → chunk-OIQYIIO3.cjs} +7 -7
- package/dist/{chunk-32TWR3HE.js → chunk-OL46QLBJ.js} +3 -12
- package/dist/chunk-OPZ7XDDI.js +487 -0
- package/dist/chunk-OSYNRVOV.cjs +243 -0
- package/dist/{chunk-HUFNKFA6.js → chunk-P7YIA5LN.js} +93 -13
- package/dist/chunk-PGANYCAG.cjs +220 -0
- package/dist/{chunk-CO2VM2DK.js → chunk-QAVXL2IH.js} +62 -20
- package/dist/{chunk-BO2OKHIY.js → chunk-QCCBXSCE.js} +1640 -1311
- package/dist/{chunk-WYH4GVZ5.js → chunk-QPOQ7VPI.js} +16 -13
- package/dist/{chunk-V42NTCFH.js → chunk-QTPMJRGS.js} +2331 -17
- package/dist/{chunk-FEFHPUEM.cjs → chunk-QWNQ523V.cjs} +1705 -1382
- package/dist/{chunk-VK5AXKO3.js → chunk-R3IVNY6P.js} +166 -101
- package/dist/chunk-R75BSDH7.cjs +50 -0
- package/dist/{chunk-AIUXRS74.cjs → chunk-RMHC2VG7.cjs} +2358 -41
- package/dist/chunk-RUXGBKPS.cjs +4517 -0
- package/dist/{chunk-PLMYCCA4.js → chunk-S5IFXW6E.js} +113 -9
- package/dist/{chunk-27LWW5FU.cjs → chunk-S6YWHCKV.cjs} +5 -5
- package/dist/{chunk-SUCBB66F.js → chunk-SIEXCILW.js} +3 -3
- package/dist/{chunk-CLYEIWA5.cjs → chunk-SLU6UPJI.cjs} +5 -3
- package/dist/{chunk-H6WMMLQK.cjs → chunk-T5J7ZKP3.cjs} +454 -61
- 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-BU5ZAFMC.js → chunk-U4NBQJBY.js} +11 -13
- package/dist/{chunk-Y5MUAYTO.js → chunk-UD3DSHZM.js} +10 -13
- package/dist/chunk-UDMYRFDZ.js +3038 -0
- package/dist/{chunk-PPULB4GG.cjs → chunk-UOIGFQXC.cjs} +90 -68
- package/dist/{chunk-EPWRXL6S.js → chunk-URG2SJLK.js} +41 -42
- package/dist/{chunk-VJVCD5T5.cjs → chunk-V73NPPTM.cjs} +152 -35
- package/dist/chunk-VECQYRXL.js +474 -0
- package/dist/chunk-VEXPG4WN.js +1989 -0
- package/dist/{chunk-4SMUJFHL.js → chunk-VMLKSV26.js} +9 -6
- package/dist/{chunk-HKCVM6OK.cjs → chunk-VSK7W3O5.cjs} +47 -27
- package/dist/chunk-VVKVQZI6.js +55 -0
- package/dist/{chunk-KDB6BUMB.js → chunk-W55Z7QIX.js} +172 -25
- package/dist/{chunk-BY3B7ZYV.cjs → chunk-W6P2GBHH.cjs} +3 -3
- package/dist/{chunk-PBA6NXCT.cjs → chunk-W6RW64BB.cjs} +11 -8
- package/dist/chunk-WDT3JTGM.cjs +483 -0
- package/dist/{chunk-26TLYBFD.js → chunk-WKX5AMOY.js} +3 -3
- package/dist/chunk-WNNE3PO3.js +34 -0
- package/dist/chunk-WRLUBRKS.cjs +1943 -0
- package/dist/chunk-WRNEH5MO.js +3169 -0
- package/dist/{chunk-54FHG2MX.js → chunk-WRWEX5ZF.js} +7 -4
- package/dist/chunk-X3GJPRVK.cjs +3246 -0
- package/dist/{chunk-4KJ2R7VP.cjs → chunk-XFXGA5IW.cjs} +126 -22
- package/dist/{chunk-L3Z2HIWJ.cjs → chunk-XHIV6326.cjs} +4 -4
- package/dist/chunk-XJAN7CZG.cjs +432 -0
- package/dist/chunk-XL6INWKT.js +121 -0
- package/dist/{chunk-KYM4XRFG.js → chunk-XMWZG36H.js} +4 -4
- package/dist/{chunk-BKIGPPVM.js → chunk-XSFNHP2E.js} +6 -3
- package/dist/{chunk-ODGMVILH.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-CMYAWUX3.js → chunk-YIMN575O.js} +445 -53
- package/dist/chunk-YIVFJNYV.js +176 -0
- package/dist/{chunk-V2ILLPHK.cjs → chunk-YKGPCZEE.cjs} +10 -10
- package/dist/chunk-YQELFNJV.js +39 -0
- package/dist/chunk-YSCKYJOB.cjs +2196 -0
- package/dist/chunk-Z5XMPRNC.cjs +5390 -0
- package/dist/{chunk-3FYZOR7S.cjs → chunk-ZDSYWBIE.cjs} +18 -18
- package/dist/{chunk-CQDOF3G7.cjs → chunk-ZKSS47EV.cjs} +24 -19
- package/dist/chunk-ZUL5AVTX.cjs +1993 -0
- package/dist/chunk-ZXBZVXDW.js +5386 -0
- package/dist/{chunk-AW7WAELW.js → chunk-ZZ7RO2UQ.js} +314 -46
- package/dist/cli/holoscript-runner.cjs +203 -206
- package/dist/cli/holoscript-runner.js +147 -150
- package/dist/codebase/index.cjs +1 -1
- package/dist/codebase/index.d.ts +25 -0
- package/dist/codebase/index.js +1 -1
- package/dist/compiler/agent-inference.cjs +10 -8
- package/dist/compiler/agent-inference.js +6 -4
- package/dist/compiler/android-xr.cjs +12 -8
- package/dist/compiler/android-xr.js +10 -6
- package/dist/compiler/android.cjs +12 -9
- package/dist/compiler/android.js +10 -7
- package/dist/compiler/ar.cjs +9 -7
- package/dist/compiler/ar.js +7 -5
- package/dist/compiler/babylon.cjs +12 -9
- package/dist/compiler/babylon.js +11 -8
- 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 +161 -151
- package/dist/compiler/domain-block-utils.js +7 -5
- package/dist/compiler/dtdl.cjs +10 -8
- package/dist/compiler/dtdl.js +7 -5
- package/dist/compiler/gltf-pipeline.cjs +9 -9
- package/dist/compiler/gltf-pipeline.js +2 -2
- package/dist/compiler/godot.cjs +9 -7
- package/dist/compiler/godot.js +8 -6
- package/dist/compiler/incremental.cjs +12 -8
- package/dist/compiler/incremental.js +7 -3
- package/dist/compiler/index.cjs +5152 -814
- package/dist/compiler/index.d.ts +404 -21
- package/dist/compiler/index.js +5063 -859
- package/dist/compiler/ios.cjs +11 -9
- package/dist/compiler/ios.js +9 -7
- 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 -17
- package/dist/compiler/multi-layer.js +13 -10
- package/dist/compiler/nodetoy.cjs +5 -5
- package/dist/compiler/nodetoy.js +2 -2
- package/dist/compiler/openxr.cjs +10 -7
- package/dist/compiler/openxr.js +9 -6
- package/dist/compiler/playcanvas.cjs +10 -8
- package/dist/compiler/playcanvas.js +9 -7
- package/dist/compiler/r3f.cjs +17 -14
- package/dist/compiler/r3f.d.ts +22 -0
- package/dist/compiler/r3f.js +12 -9
- 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 -8
- package/dist/compiler/sdf.js +8 -6
- package/dist/compiler/semantic-scene.cjs +7 -7
- package/dist/compiler/semantic-scene.js +2 -2
- package/dist/compiler/state.cjs +9 -6
- package/dist/compiler/state.js +7 -4
- package/dist/compiler/trait-composition.cjs +11 -8
- package/dist/compiler/trait-composition.js +7 -4
- package/dist/compiler/unity.cjs +10 -7
- package/dist/compiler/unity.js +9 -6
- package/dist/compiler/unreal.cjs +11 -8
- package/dist/compiler/unreal.js +9 -6
- package/dist/compiler/urdf.cjs +20 -14
- package/dist/compiler/urdf.js +8 -6
- package/dist/compiler/usd-physics.cjs +10 -8
- package/dist/compiler/usd-physics.js +7 -5
- package/dist/compiler/visionos.cjs +10 -7
- package/dist/compiler/visionos.js +9 -6
- package/dist/compiler/vrchat.cjs +10 -8
- package/dist/compiler/vrchat.js +8 -6
- package/dist/compiler/vrr.cjs +10 -8
- package/dist/compiler/vrr.js +8 -6
- package/dist/compiler/wasm.cjs +13 -11
- package/dist/compiler/wasm.js +8 -6
- package/dist/compiler/webgpu.cjs +9 -7
- package/dist/compiler/webgpu.js +8 -6
- package/dist/constants.d.ts +4 -0
- 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.d.ts +9 -0
- package/dist/entries/interop.js +5 -3
- package/dist/entries/scripting.cjs +18 -17
- package/dist/entries/scripting.d.ts +7 -0
- package/dist/entries/scripting.js +8 -7
- 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 +21396 -39967
- package/dist/index.d.ts +1496 -40
- package/dist/index.js +21066 -40142
- 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-FSKBTE3W.cjs +1265 -0
- package/dist/ml-dsa-Z7JDKW4L.js +1265 -0
- 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 -10
- package/dist/parser.d.ts +11 -0
- package/dist/parser.js +10 -7
- package/dist/{playwright-7DTEQCBD.cjs → playwright-3AT3AKTV.cjs} +1985 -1985
- package/dist/{playwright-BIZXMLD2.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.d.ts +0 -48
- package/dist/self-improvement/index.js +545 -0
- package/dist/storage/index.cjs +10 -9
- package/dist/storage/index.d.ts +24 -0
- 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 +33 -0
- 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.d.ts +111 -0
- package/dist/traits/engines/index.js +380 -0
- package/dist/traits/index.cjs +14387 -4320
- package/dist/traits/index.d.ts +197 -0
- package/dist/traits/index.js +16455 -6958
- 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 +7 -7
- package/dist/wot/index.js +2 -2
- package/package.json +150 -23
- package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
- package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
- package/dist/chunk-3KEU5QYY.cjs +0 -175
- package/dist/chunk-6OQBLABR.js +0 -5240
- package/dist/chunk-6WNCRE6F.js +0 -126
- package/dist/chunk-C2QHVHZF.js +0 -4066
- package/dist/chunk-CN4NOESF.cjs +0 -416
- package/dist/chunk-DXVCEFZB.js +0 -2027
- package/dist/chunk-ENV7K6XA.js +0 -282
- package/dist/chunk-H7XMORZI.js +0 -2731
- package/dist/chunk-HAN4V3PF.cjs +0 -2037
- package/dist/chunk-HF4OFY25.cjs +0 -4097
- package/dist/chunk-LER4WXW5.cjs +0 -286
- package/dist/chunk-M6FU6S22.js +0 -2911
- package/dist/chunk-MWEFR6YQ.js +0 -1857
- package/dist/chunk-PJMOXFPR.cjs +0 -1861
- package/dist/chunk-QHVVVN47.cjs +0 -2033
- package/dist/chunk-QWKUKVRE.js +0 -2026
- package/dist/chunk-UITWA6DV.cjs +0 -2829
- package/dist/chunk-UQW6SLM5.js +0 -172
- package/dist/chunk-WUXIRGZP.cjs +0 -2915
- package/dist/chunk-X67XRI2T.js +0 -410
- package/dist/chunk-Y7VK5TH3.cjs +0 -129
- package/dist/chunk-YCMQQQ5U.cjs +0 -5244
- package/dist/post-quantum-JTTAAGO3.cjs +0 -6
- package/dist/post-quantum-RVPVDEPI.js +0 -4
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk5FSKKMR7_cjs = require('./chunk-5FSKKMR7.cjs');
|
|
4
|
+
var chunkGTU2Z2WW_cjs = require('./chunk-GTU2Z2WW.cjs');
|
|
5
|
+
var chunkE7JP3BS3_cjs = require('./chunk-E7JP3BS3.cjs');
|
|
6
|
+
var chunkHCCQLAA4_cjs = require('./chunk-HCCQLAA4.cjs');
|
|
4
7
|
var crypto3 = require('crypto');
|
|
5
8
|
var util = require('util');
|
|
9
|
+
var zod = require('zod');
|
|
6
10
|
var jwt = require('jsonwebtoken');
|
|
7
11
|
var path = require('path');
|
|
8
12
|
|
|
@@ -69,7 +73,7 @@ function buildCanonicalJwk(jwk) {
|
|
|
69
73
|
throw new Error(`Unsupported JWK key type: ${kty ?? "(undefined)"}`);
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
|
-
var init_JwkThumbprint =
|
|
76
|
+
var init_JwkThumbprint = chunkHCCQLAA4_cjs.__esm({
|
|
73
77
|
"src/compiler/identity/JwkThumbprint.ts"() {
|
|
74
78
|
}
|
|
75
79
|
});
|
|
@@ -127,7 +131,7 @@ function getDefaultPermissions(role) {
|
|
|
127
131
|
return [...ROLE_PERMISSIONS[role]];
|
|
128
132
|
}
|
|
129
133
|
var generateKeyPairAsync, AgentPermission, WorkflowStep, ROLE_PERMISSIONS, WORKFLOW_SEQUENCES;
|
|
130
|
-
var init_AgentIdentity =
|
|
134
|
+
var init_AgentIdentity = chunkHCCQLAA4_cjs.__esm({
|
|
131
135
|
"src/compiler/identity/AgentIdentity.ts"() {
|
|
132
136
|
init_JwkThumbprint();
|
|
133
137
|
generateKeyPairAsync = typeof crypto3__namespace.generateKeyPair === "function" ? util.promisify(crypto3__namespace.generateKeyPair) : null;
|
|
@@ -207,6 +211,60 @@ var init_AgentIdentity = chunkEGIZHYJP_cjs.__esm({
|
|
|
207
211
|
});
|
|
208
212
|
|
|
209
213
|
// src/traits/CultureTraits.ts
|
|
214
|
+
function normalizeNormProvenance(value) {
|
|
215
|
+
if (!value) return { ...exports.UNKNOWN_NORM_PROVENANCE };
|
|
216
|
+
return {
|
|
217
|
+
source: value.source ?? "unknown",
|
|
218
|
+
...value.sourceAgentId !== void 0 && { sourceAgentId: value.sourceAgentId },
|
|
219
|
+
...value.sourceCorpus !== void 0 && { sourceCorpus: value.sourceCorpus },
|
|
220
|
+
...value.declarationSite !== void 0 && { declarationSite: value.declarationSite },
|
|
221
|
+
...value.originInteractionId !== void 0 && {
|
|
222
|
+
originInteractionId: value.originInteractionId
|
|
223
|
+
},
|
|
224
|
+
...value.confidenceClassification !== void 0 && {
|
|
225
|
+
confidenceClassification: value.confidenceClassification
|
|
226
|
+
},
|
|
227
|
+
...value.recordedAtIso !== void 0 && { recordedAtIso: value.recordedAtIso }
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function serializeNormProvenance(value) {
|
|
231
|
+
return normalizeNormProvenance(value);
|
|
232
|
+
}
|
|
233
|
+
function deserializeNormProvenance(value) {
|
|
234
|
+
if (!value || typeof value !== "object") return { ...exports.UNKNOWN_NORM_PROVENANCE };
|
|
235
|
+
const obj = value;
|
|
236
|
+
const knownSources = [
|
|
237
|
+
"agent",
|
|
238
|
+
"corpus",
|
|
239
|
+
"declaration_site",
|
|
240
|
+
"builtin",
|
|
241
|
+
"observation",
|
|
242
|
+
"unknown"
|
|
243
|
+
];
|
|
244
|
+
const rawSource = obj.source;
|
|
245
|
+
const source = typeof rawSource === "string" && knownSources.includes(rawSource) ? rawSource : "unknown";
|
|
246
|
+
const result = { source };
|
|
247
|
+
if (typeof obj.sourceAgentId === "string") result.sourceAgentId = obj.sourceAgentId;
|
|
248
|
+
if (typeof obj.sourceCorpus === "string") result.sourceCorpus = obj.sourceCorpus;
|
|
249
|
+
if (obj.declarationSite && typeof obj.declarationSite === "object") {
|
|
250
|
+
const site = obj.declarationSite;
|
|
251
|
+
if (typeof site.file === "string") {
|
|
252
|
+
result.declarationSite = {
|
|
253
|
+
file: site.file,
|
|
254
|
+
...typeof site.line === "number" && { line: site.line },
|
|
255
|
+
...typeof site.column === "number" && { column: site.column }
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (typeof obj.originInteractionId === "string") {
|
|
260
|
+
result.originInteractionId = obj.originInteractionId;
|
|
261
|
+
}
|
|
262
|
+
if (obj.confidenceClassification === "genuine" || obj.confidenceClassification === "confabulated" || obj.confidenceClassification === "bullshitted") {
|
|
263
|
+
result.confidenceClassification = obj.confidenceClassification;
|
|
264
|
+
}
|
|
265
|
+
if (typeof obj.recordedAtIso === "string") result.recordedAtIso = obj.recordedAtIso;
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
210
268
|
function getBuiltinNorm(id) {
|
|
211
269
|
return exports.BUILTIN_NORMS.find((n) => n.id === id);
|
|
212
270
|
}
|
|
@@ -231,9 +289,17 @@ function getFamilyCompatibility(familyA, familyB) {
|
|
|
231
289
|
}
|
|
232
290
|
return { rating: "compatible", reason: "No known incompatibility between these families." };
|
|
233
291
|
}
|
|
234
|
-
exports.BUILTIN_NORMS = void 0; var CULTURAL_FAMILY_COMPATIBILITY, CONTRADICTORY_NORM_PAIRS, customContradictoryNorms;
|
|
235
|
-
var init_CultureTraits =
|
|
292
|
+
exports.UNKNOWN_NORM_PROVENANCE = void 0; exports.BUILTIN_NORM_PROVENANCE = void 0; exports.BUILTIN_NORMS = void 0; var CULTURAL_FAMILY_COMPATIBILITY, CONTRADICTORY_NORM_PAIRS, customContradictoryNorms;
|
|
293
|
+
var init_CultureTraits = chunkHCCQLAA4_cjs.__esm({
|
|
236
294
|
"src/traits/CultureTraits.ts"() {
|
|
295
|
+
exports.UNKNOWN_NORM_PROVENANCE = Object.freeze({
|
|
296
|
+
source: "unknown"
|
|
297
|
+
});
|
|
298
|
+
exports.BUILTIN_NORM_PROVENANCE = Object.freeze({
|
|
299
|
+
source: "builtin",
|
|
300
|
+
sourceCorpus: "@holoscript/core/BUILTIN_NORMS",
|
|
301
|
+
confidenceClassification: "genuine"
|
|
302
|
+
});
|
|
237
303
|
exports.BUILTIN_NORMS = [
|
|
238
304
|
// Safety norms
|
|
239
305
|
{
|
|
@@ -245,7 +311,8 @@ var init_CultureTraits = chunkEGIZHYJP_cjs.__esm({
|
|
|
245
311
|
scope: "world",
|
|
246
312
|
activationThreshold: 0,
|
|
247
313
|
strength: "strong",
|
|
248
|
-
forbiddenEffects: ["agent:kill", "inventory:destroy", "physics:teleport"]
|
|
314
|
+
forbiddenEffects: ["agent:kill", "inventory:destroy", "physics:teleport"],
|
|
315
|
+
provenance: exports.BUILTIN_NORM_PROVENANCE
|
|
249
316
|
},
|
|
250
317
|
{
|
|
251
318
|
id: "resource_sharing",
|
|
@@ -256,7 +323,8 @@ var init_CultureTraits = chunkEGIZHYJP_cjs.__esm({
|
|
|
256
323
|
scope: "zone",
|
|
257
324
|
activationThreshold: 0.5,
|
|
258
325
|
strength: "moderate",
|
|
259
|
-
requiredEffects: ["inventory:give"]
|
|
326
|
+
requiredEffects: ["inventory:give"],
|
|
327
|
+
provenance: exports.BUILTIN_NORM_PROVENANCE
|
|
260
328
|
},
|
|
261
329
|
{
|
|
262
330
|
id: "zone_respect",
|
|
@@ -268,7 +336,8 @@ var init_CultureTraits = chunkEGIZHYJP_cjs.__esm({
|
|
|
268
336
|
activationThreshold: 0.3,
|
|
269
337
|
strength: "moderate",
|
|
270
338
|
requiredEffects: ["agent:communicate"],
|
|
271
|
-
forbiddenEffects: ["authority:zone"]
|
|
339
|
+
forbiddenEffects: ["authority:zone"],
|
|
340
|
+
provenance: exports.BUILTIN_NORM_PROVENANCE
|
|
272
341
|
},
|
|
273
342
|
{
|
|
274
343
|
id: "fair_trade",
|
|
@@ -279,7 +348,8 @@ var init_CultureTraits = chunkEGIZHYJP_cjs.__esm({
|
|
|
279
348
|
scope: "world",
|
|
280
349
|
activationThreshold: 0,
|
|
281
350
|
strength: "strong",
|
|
282
|
-
requiredEffects: ["inventory:trade", "agent:communicate"]
|
|
351
|
+
requiredEffects: ["inventory:trade", "agent:communicate"],
|
|
352
|
+
provenance: exports.BUILTIN_NORM_PROVENANCE
|
|
283
353
|
},
|
|
284
354
|
{
|
|
285
355
|
id: "greeting_convention",
|
|
@@ -290,7 +360,8 @@ var init_CultureTraits = chunkEGIZHYJP_cjs.__esm({
|
|
|
290
360
|
scope: "session",
|
|
291
361
|
activationThreshold: 0.6,
|
|
292
362
|
strength: "weak",
|
|
293
|
-
requiredEffects: ["agent:communicate"]
|
|
363
|
+
requiredEffects: ["agent:communicate"],
|
|
364
|
+
provenance: exports.BUILTIN_NORM_PROVENANCE
|
|
294
365
|
},
|
|
295
366
|
{
|
|
296
367
|
id: "noise_courtesy",
|
|
@@ -301,7 +372,8 @@ var init_CultureTraits = chunkEGIZHYJP_cjs.__esm({
|
|
|
301
372
|
scope: "zone",
|
|
302
373
|
activationThreshold: 0.4,
|
|
303
374
|
strength: "moderate",
|
|
304
|
-
forbiddenEffects: ["audio:global"]
|
|
375
|
+
forbiddenEffects: ["audio:global"],
|
|
376
|
+
provenance: exports.BUILTIN_NORM_PROVENANCE
|
|
305
377
|
},
|
|
306
378
|
{
|
|
307
379
|
id: "spawn_limits",
|
|
@@ -312,8 +384,9 @@ var init_CultureTraits = chunkEGIZHYJP_cjs.__esm({
|
|
|
312
384
|
scope: "zone",
|
|
313
385
|
activationThreshold: 0,
|
|
314
386
|
strength: "strong",
|
|
315
|
-
forbiddenEffects: ["render:spawn"]
|
|
387
|
+
forbiddenEffects: ["render:spawn"],
|
|
316
388
|
// Catches excessive spawning via budget
|
|
389
|
+
provenance: exports.BUILTIN_NORM_PROVENANCE
|
|
317
390
|
},
|
|
318
391
|
{
|
|
319
392
|
id: "metanorm_enforcement",
|
|
@@ -324,7 +397,8 @@ var init_CultureTraits = chunkEGIZHYJP_cjs.__esm({
|
|
|
324
397
|
scope: "world",
|
|
325
398
|
activationThreshold: 0.7,
|
|
326
399
|
strength: "weak",
|
|
327
|
-
requiredEffects: ["agent:communicate", "agent:observe"]
|
|
400
|
+
requiredEffects: ["agent:communicate", "agent:observe"],
|
|
401
|
+
provenance: exports.BUILTIN_NORM_PROVENANCE
|
|
328
402
|
}
|
|
329
403
|
];
|
|
330
404
|
CULTURAL_FAMILY_COMPATIBILITY = [
|
|
@@ -401,10 +475,18 @@ function getKeystore(config) {
|
|
|
401
475
|
}
|
|
402
476
|
return globalKeystore;
|
|
403
477
|
}
|
|
404
|
-
var DEFAULT_TOKEN_LIFETIME, ENCRYPTION_ALGORITHM, KEY_LENGTH, IV_LENGTH, SALT_LENGTH, AgentKeystore, globalKeystore;
|
|
405
|
-
var init_AgentKeystore =
|
|
478
|
+
var SerializedCredentialSchema, DEFAULT_TOKEN_LIFETIME, ENCRYPTION_ALGORITHM, KEY_LENGTH, IV_LENGTH, SALT_LENGTH, AgentKeystore, globalKeystore;
|
|
479
|
+
var init_AgentKeystore = chunkHCCQLAA4_cjs.__esm({
|
|
406
480
|
"src/compiler/identity/AgentKeystore.ts"() {
|
|
407
481
|
init_AgentIdentity();
|
|
482
|
+
chunkE7JP3BS3_cjs.init_safeJsonParse();
|
|
483
|
+
SerializedCredentialSchema = zod.z.object({
|
|
484
|
+
role: zod.z.string(),
|
|
485
|
+
token: zod.z.string(),
|
|
486
|
+
keyPair: zod.z.unknown(),
|
|
487
|
+
createdAt: zod.z.string(),
|
|
488
|
+
expiresAt: zod.z.string()
|
|
489
|
+
});
|
|
408
490
|
DEFAULT_TOKEN_LIFETIME = 24 * 60 * 60 * 1e3;
|
|
409
491
|
ENCRYPTION_ALGORITHM = "aes-256-gcm";
|
|
410
492
|
KEY_LENGTH = 32;
|
|
@@ -535,7 +617,21 @@ var init_AgentKeystore = chunkEGIZHYJP_cjs.__esm({
|
|
|
535
617
|
return this.getCredential(role);
|
|
536
618
|
}
|
|
537
619
|
const decrypted = this.decrypt(encrypted);
|
|
538
|
-
const
|
|
620
|
+
const parseResult = chunkE7JP3BS3_cjs.safeJsonParse(decrypted, SerializedCredentialSchema);
|
|
621
|
+
if (!parseResult.ok) {
|
|
622
|
+
this.logAudit({
|
|
623
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
624
|
+
event: "key_parse_failed",
|
|
625
|
+
agentRole: role,
|
|
626
|
+
details: {
|
|
627
|
+
source: "storage",
|
|
628
|
+
error: parseResult.error.message,
|
|
629
|
+
kind: parseResult.error.kind
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
const parsed = parseResult.value;
|
|
539
635
|
const credential = {
|
|
540
636
|
role: parsed.role,
|
|
541
637
|
token: parsed.token,
|
|
@@ -659,10 +755,10 @@ var init_AgentKeystore = chunkEGIZHYJP_cjs.__esm({
|
|
|
659
755
|
});
|
|
660
756
|
|
|
661
757
|
// src/compiler/identity/CapabilityToken.ts
|
|
662
|
-
|
|
663
|
-
var init_CapabilityToken =
|
|
758
|
+
var HOLOSCRIPT_RESOURCE_SCHEME, HOLOSCRIPT_RESOURCE_ALL, CapabilityActions, PERMISSION_TO_ACTION;
|
|
759
|
+
var init_CapabilityToken = chunkHCCQLAA4_cjs.__esm({
|
|
664
760
|
"src/compiler/identity/CapabilityToken.ts"() {
|
|
665
|
-
|
|
761
|
+
HOLOSCRIPT_RESOURCE_SCHEME = "holoscript://";
|
|
666
762
|
HOLOSCRIPT_RESOURCE_ALL = "holoscript://*";
|
|
667
763
|
CapabilityActions = {
|
|
668
764
|
// Source
|
|
@@ -727,12 +823,13 @@ function getCapabilityTokenIssuer(config) {
|
|
|
727
823
|
}
|
|
728
824
|
return globalCapabilityIssuer;
|
|
729
825
|
}
|
|
730
|
-
|
|
731
|
-
var init_CapabilityTokenIssuer =
|
|
826
|
+
var HoloScriptCapabilitySemantics, CapabilityTokenIssuer, globalCapabilityIssuer;
|
|
827
|
+
var init_CapabilityTokenIssuer = chunkHCCQLAA4_cjs.__esm({
|
|
732
828
|
"src/compiler/identity/CapabilityTokenIssuer.ts"() {
|
|
829
|
+
chunkE7JP3BS3_cjs.init_safeJsonParse();
|
|
733
830
|
init_AgentIdentity();
|
|
734
831
|
init_CapabilityToken();
|
|
735
|
-
|
|
832
|
+
HoloScriptCapabilitySemantics = class {
|
|
736
833
|
/**
|
|
737
834
|
* Check whether `child` is a valid attenuation (subset) of `parent`.
|
|
738
835
|
*/
|
|
@@ -741,7 +838,7 @@ var init_CapabilityTokenIssuer = chunkEGIZHYJP_cjs.__esm({
|
|
|
741
838
|
return false;
|
|
742
839
|
}
|
|
743
840
|
if (parent.with === HOLOSCRIPT_RESOURCE_ALL) {
|
|
744
|
-
return child.with.startsWith(
|
|
841
|
+
return child.with.startsWith(HOLOSCRIPT_RESOURCE_SCHEME);
|
|
745
842
|
}
|
|
746
843
|
if (child.with === parent.with) {
|
|
747
844
|
return true;
|
|
@@ -760,7 +857,7 @@ var init_CapabilityTokenIssuer = chunkEGIZHYJP_cjs.__esm({
|
|
|
760
857
|
return false;
|
|
761
858
|
}
|
|
762
859
|
if (capability.with === HOLOSCRIPT_RESOURCE_ALL) {
|
|
763
|
-
return resource.startsWith(
|
|
860
|
+
return resource.startsWith(HOLOSCRIPT_RESOURCE_SCHEME);
|
|
764
861
|
}
|
|
765
862
|
if (capability.with === resource) {
|
|
766
863
|
return true;
|
|
@@ -773,7 +870,7 @@ var init_CapabilityTokenIssuer = chunkEGIZHYJP_cjs.__esm({
|
|
|
773
870
|
*/
|
|
774
871
|
fromPermission(permission, scope) {
|
|
775
872
|
const action = PERMISSION_TO_ACTION[permission] || permission;
|
|
776
|
-
const resource = scope ? `${
|
|
873
|
+
const resource = scope ? `${HOLOSCRIPT_RESOURCE_SCHEME}${scope}` : HOLOSCRIPT_RESOURCE_ALL;
|
|
777
874
|
return {
|
|
778
875
|
with: resource,
|
|
779
876
|
can: action
|
|
@@ -788,7 +885,7 @@ var init_CapabilityTokenIssuer = chunkEGIZHYJP_cjs.__esm({
|
|
|
788
885
|
this.usedNonces = /* @__PURE__ */ new Set();
|
|
789
886
|
this.defaultLifetimeSec = config.defaultLifetimeSec ?? 86400;
|
|
790
887
|
this.maxDelegationDepth = config.maxDelegationDepth ?? 10;
|
|
791
|
-
this.semantics = config.semantics ?? new
|
|
888
|
+
this.semantics = config.semantics ?? new HoloScriptCapabilitySemantics();
|
|
792
889
|
this.strictExpiration = config.strictExpiration ?? true;
|
|
793
890
|
}
|
|
794
891
|
// -----------------------------------------------------------------------
|
|
@@ -854,7 +951,8 @@ var init_CapabilityTokenIssuer = chunkEGIZHYJP_cjs.__esm({
|
|
|
854
951
|
}
|
|
855
952
|
}
|
|
856
953
|
const now = Math.floor(Date.now() / 1e3);
|
|
857
|
-
const
|
|
954
|
+
const parentRemainingLifetime = Math.max(0, parentPayload.exp - now);
|
|
955
|
+
const requestedLifetime = lifetimeSec ?? Math.min(this.defaultLifetimeSec, parentRemainingLifetime);
|
|
858
956
|
const childExp = now + requestedLifetime;
|
|
859
957
|
if (this.strictExpiration && childExp > parentPayload.exp) {
|
|
860
958
|
throw new Error(
|
|
@@ -967,7 +1065,7 @@ var init_CapabilityTokenIssuer = chunkEGIZHYJP_cjs.__esm({
|
|
|
967
1065
|
}
|
|
968
1066
|
let payload;
|
|
969
1067
|
try {
|
|
970
|
-
payload =
|
|
1068
|
+
payload = chunkE7JP3BS3_cjs.readJson(base64urlDecode(payloadB64).toString("utf-8"));
|
|
971
1069
|
} catch {
|
|
972
1070
|
return {
|
|
973
1071
|
valid: false,
|
|
@@ -1174,7 +1272,7 @@ function getTokenIssuer(config) {
|
|
|
1174
1272
|
return globalIssuer;
|
|
1175
1273
|
}
|
|
1176
1274
|
var DEFAULT_ISSUER, DEFAULT_JWT_SECRET, DEFAULT_TOKEN_EXPIRATION, AgentTokenIssuer, globalIssuer;
|
|
1177
|
-
var init_AgentTokenIssuer =
|
|
1275
|
+
var init_AgentTokenIssuer = chunkHCCQLAA4_cjs.__esm({
|
|
1178
1276
|
"src/compiler/identity/AgentTokenIssuer.ts"() {
|
|
1179
1277
|
init_AgentIdentity();
|
|
1180
1278
|
init_AgentKeystore();
|
|
@@ -1381,7 +1479,7 @@ var init_AgentTokenIssuer = chunkEGIZHYJP_cjs.__esm({
|
|
|
1381
1479
|
const permissions = getDefaultPermissions(agentConfig.role);
|
|
1382
1480
|
const capabilities = permissions.map((perm) => {
|
|
1383
1481
|
const action = PERMISSION_TO_ACTION[perm] || perm;
|
|
1384
|
-
const resource = scope ? `${
|
|
1482
|
+
const resource = scope ? `${HOLOSCRIPT_RESOURCE_SCHEME}${scope}` : HOLOSCRIPT_RESOURCE_ALL;
|
|
1385
1483
|
return { with: resource, can: action };
|
|
1386
1484
|
});
|
|
1387
1485
|
const issuer = `agent:${agentConfig.role}:${agentConfig.name}`;
|
|
@@ -1433,7 +1531,7 @@ var init_AgentTokenIssuer = chunkEGIZHYJP_cjs.__esm({
|
|
|
1433
1531
|
const scope = capabilityOptions?.scope ?? request.agentConfig.scope;
|
|
1434
1532
|
const capabilities = permissions.map((perm) => {
|
|
1435
1533
|
const action = PERMISSION_TO_ACTION[perm] || perm;
|
|
1436
|
-
const resource = scope ? `${
|
|
1534
|
+
const resource = scope ? `${HOLOSCRIPT_RESOURCE_SCHEME}${scope}` : HOLOSCRIPT_RESOURCE_ALL;
|
|
1437
1535
|
return { with: resource, can: action };
|
|
1438
1536
|
});
|
|
1439
1537
|
return {
|
|
@@ -1532,7 +1630,7 @@ var init_AgentTokenIssuer = chunkEGIZHYJP_cjs.__esm({
|
|
|
1532
1630
|
|
|
1533
1631
|
// src/compiler/CulturalCompatibilityChecker.ts
|
|
1534
1632
|
var DEFAULT_CONFIG, CODES, CulturalCompatibilityChecker;
|
|
1535
|
-
var init_CulturalCompatibilityChecker =
|
|
1633
|
+
var init_CulturalCompatibilityChecker = chunkHCCQLAA4_cjs.__esm({
|
|
1536
1634
|
"src/compiler/CulturalCompatibilityChecker.ts"() {
|
|
1537
1635
|
init_CultureTraits();
|
|
1538
1636
|
DEFAULT_CONFIG = {
|
|
@@ -1783,7 +1881,7 @@ function getConfabulationValidator(config) {
|
|
|
1783
1881
|
return globalConfabulationValidator;
|
|
1784
1882
|
}
|
|
1785
1883
|
var BUILT_IN_TRAIT_SCHEMAS, ConfabulationValidator, globalConfabulationValidator;
|
|
1786
|
-
var init_ConfabulationValidator =
|
|
1884
|
+
var init_ConfabulationValidator = chunkHCCQLAA4_cjs.__esm({
|
|
1787
1885
|
"src/compiler/identity/ConfabulationValidator.ts"() {
|
|
1788
1886
|
BUILT_IN_TRAIT_SCHEMAS = [
|
|
1789
1887
|
// =========================================================================
|
|
@@ -3345,12 +3443,13 @@ function getRBAC(tokenIssuer) {
|
|
|
3345
3443
|
return globalRBAC;
|
|
3346
3444
|
}
|
|
3347
3445
|
var RESOURCE_PERMISSION_MAP, AgentRBAC, globalRBAC;
|
|
3348
|
-
var init_AgentRBAC =
|
|
3446
|
+
var init_AgentRBAC = chunkHCCQLAA4_cjs.__esm({
|
|
3349
3447
|
"src/compiler/identity/AgentRBAC.ts"() {
|
|
3350
3448
|
init_AgentIdentity();
|
|
3351
3449
|
init_AgentTokenIssuer();
|
|
3352
3450
|
init_CulturalCompatibilityChecker();
|
|
3353
3451
|
init_ConfabulationValidator();
|
|
3452
|
+
chunkGTU2Z2WW_cjs.init_AgentRiskRegistry();
|
|
3354
3453
|
RESOURCE_PERMISSION_MAP = {
|
|
3355
3454
|
["source_file" /* SOURCE_FILE */]: {
|
|
3356
3455
|
read: "read:source" /* READ_SOURCE */,
|
|
@@ -3615,6 +3714,122 @@ var init_AgentRBAC = chunkEGIZHYJP_cjs.__esm({
|
|
|
3615
3714
|
return validator.validateComposition(composition);
|
|
3616
3715
|
}
|
|
3617
3716
|
// ===========================================================================
|
|
3717
|
+
// CONFABULATION RISK TIER GATE (v1.2.0)
|
|
3718
|
+
//
|
|
3719
|
+
// Sibling of the per-composition schema gate. Where the schema gate asks
|
|
3720
|
+
// "is THIS composition structurally valid?", the risk-tier gate asks
|
|
3721
|
+
// "given this AGENT's history, should we tighten the per-composition
|
|
3722
|
+
// threshold or block dangerous ops outright?"
|
|
3723
|
+
//
|
|
3724
|
+
// Pipeline:
|
|
3725
|
+
// 1. Standard RBAC check (token, role, scope, workflow).
|
|
3726
|
+
// 2. Confabulation schema validation against the supplied composition.
|
|
3727
|
+
// 3. Look up the agent's current risk tier in the AgentRiskRegistry.
|
|
3728
|
+
// 4. If the op is dangerous (write/transform/execute), apply the tier's
|
|
3729
|
+
// composition risk cap. Quarantined agents are blocked outright.
|
|
3730
|
+
// 5. Record the validation outcome back into the registry so the agent's
|
|
3731
|
+
// tier evolves with their behavior.
|
|
3732
|
+
// ===========================================================================
|
|
3733
|
+
/**
|
|
3734
|
+
* Check access with both the schema gate AND the per-agent risk tier gate.
|
|
3735
|
+
*
|
|
3736
|
+
* Use this as the primary enforcement point for any AI-generated content
|
|
3737
|
+
* that will land in a downstream compiler target.
|
|
3738
|
+
*
|
|
3739
|
+
* @param request - Standard resource access request.
|
|
3740
|
+
* @param composition - Composition the agent wants to commit/transform.
|
|
3741
|
+
* @param options - Optional registry override + per-call confabulation config.
|
|
3742
|
+
* @returns Extended access decision including risk tier and applied cap.
|
|
3743
|
+
*/
|
|
3744
|
+
checkAccessWithRiskGate(request, composition, options) {
|
|
3745
|
+
const registry = options?.registry ?? chunkGTU2Z2WW_cjs.getAgentRiskRegistry();
|
|
3746
|
+
const dryRun = options?.dryRun ?? false;
|
|
3747
|
+
const rbacDecision = this.checkAccess(request);
|
|
3748
|
+
if (!rbacDecision.allowed) {
|
|
3749
|
+
return rbacDecision;
|
|
3750
|
+
}
|
|
3751
|
+
const verification = this.tokenIssuer.verifyToken(request.token);
|
|
3752
|
+
const agentId = verification.valid && verification.payload ? verification.payload.sub : void 0;
|
|
3753
|
+
if (!agentId) {
|
|
3754
|
+
return {
|
|
3755
|
+
allowed: false,
|
|
3756
|
+
reason: "Risk gate cannot identify agent (missing sub claim)",
|
|
3757
|
+
agentRole: rbacDecision.agentRole
|
|
3758
|
+
};
|
|
3759
|
+
}
|
|
3760
|
+
const validator = options?.confabConfig ? new ConfabulationValidator(options.confabConfig) : getConfabulationValidator();
|
|
3761
|
+
const confabResult = validator.validateComposition(composition);
|
|
3762
|
+
const tier = registry.getTier(agentId);
|
|
3763
|
+
const riskScore = registry.getScore(agentId);
|
|
3764
|
+
const cap = chunkGTU2Z2WW_cjs.TIER_COMPOSITION_RISK_CAP[tier];
|
|
3765
|
+
if (chunkGTU2Z2WW_cjs.isDangerousOperation(request.operation)) {
|
|
3766
|
+
if (tier === "quarantined" /* QUARANTINED */) {
|
|
3767
|
+
return {
|
|
3768
|
+
allowed: false,
|
|
3769
|
+
reason: `Agent ${agentId} is quarantined (risk score: ${riskScore.toFixed(1)}). Dangerous operation '${request.operation}' on '${request.resourceType}' blocked.`,
|
|
3770
|
+
agentRole: rbacDecision.agentRole,
|
|
3771
|
+
confabulation: confabResult,
|
|
3772
|
+
agentId,
|
|
3773
|
+
riskTier: tier,
|
|
3774
|
+
riskScore,
|
|
3775
|
+
appliedRiskCap: cap
|
|
3776
|
+
};
|
|
3777
|
+
}
|
|
3778
|
+
if (confabResult.riskScore > cap) {
|
|
3779
|
+
if (!dryRun) {
|
|
3780
|
+
registry.recordValidation(agentId, confabResult);
|
|
3781
|
+
}
|
|
3782
|
+
return {
|
|
3783
|
+
allowed: false,
|
|
3784
|
+
reason: `Composition risk ${confabResult.riskScore} exceeds tier ${tier} cap ${cap} for dangerous operation '${request.operation}' on '${request.resourceType}'. Agent ${agentId} (score: ${riskScore.toFixed(1)}). ${confabResult.errors.length} confabulation error(s).`,
|
|
3785
|
+
agentRole: rbacDecision.agentRole,
|
|
3786
|
+
confabulation: confabResult,
|
|
3787
|
+
agentId,
|
|
3788
|
+
riskTier: tier,
|
|
3789
|
+
riskScore,
|
|
3790
|
+
appliedRiskCap: cap
|
|
3791
|
+
};
|
|
3792
|
+
}
|
|
3793
|
+
} else {
|
|
3794
|
+
if (!confabResult.valid) {
|
|
3795
|
+
if (!dryRun) {
|
|
3796
|
+
registry.recordValidation(agentId, confabResult);
|
|
3797
|
+
}
|
|
3798
|
+
return {
|
|
3799
|
+
allowed: false,
|
|
3800
|
+
reason: `Confabulation detected (risk score: ${confabResult.riskScore}/100, ${confabResult.errors.length} error(s)): ` + confabResult.errors.map((e) => e.message).join("; "),
|
|
3801
|
+
agentRole: rbacDecision.agentRole,
|
|
3802
|
+
confabulation: confabResult,
|
|
3803
|
+
agentId,
|
|
3804
|
+
riskTier: tier,
|
|
3805
|
+
riskScore,
|
|
3806
|
+
appliedRiskCap: cap
|
|
3807
|
+
};
|
|
3808
|
+
}
|
|
3809
|
+
}
|
|
3810
|
+
if (!dryRun) {
|
|
3811
|
+
registry.recordValidation(agentId, confabResult);
|
|
3812
|
+
}
|
|
3813
|
+
return {
|
|
3814
|
+
...rbacDecision,
|
|
3815
|
+
confabulation: confabResult,
|
|
3816
|
+
agentId,
|
|
3817
|
+
riskTier: tier,
|
|
3818
|
+
riskScore,
|
|
3819
|
+
appliedRiskCap: cap
|
|
3820
|
+
};
|
|
3821
|
+
}
|
|
3822
|
+
/**
|
|
3823
|
+
* Look up an agent's current risk tier without performing an access check.
|
|
3824
|
+
* Useful for dashboards and pre-flight checks.
|
|
3825
|
+
*/
|
|
3826
|
+
getAgentRiskTier(token, registry) {
|
|
3827
|
+
const verification = this.tokenIssuer.verifyToken(token);
|
|
3828
|
+
if (!verification.valid || !verification.payload) return null;
|
|
3829
|
+
const reg = registry ?? chunkGTU2Z2WW_cjs.getAgentRiskRegistry();
|
|
3830
|
+
return reg.getTier(verification.payload.sub);
|
|
3831
|
+
}
|
|
3832
|
+
// ===========================================================================
|
|
3618
3833
|
// CULTURAL PROFILE INTEGRATION
|
|
3619
3834
|
// ===========================================================================
|
|
3620
3835
|
/**
|
|
@@ -3666,16 +3881,2118 @@ var init_AgentRBAC = chunkEGIZHYJP_cjs.__esm({
|
|
|
3666
3881
|
}
|
|
3667
3882
|
});
|
|
3668
3883
|
|
|
3884
|
+
// src/compiler/identity/ANSNamespace.ts
|
|
3885
|
+
function isValidCompilerName(name) {
|
|
3886
|
+
return ALL_COMPILER_NAMES.includes(name);
|
|
3887
|
+
}
|
|
3888
|
+
var ANSDomain, ANSRiskTier; exports.ANSCapabilityPath = void 0; var COMPILER_DOMAIN_MAP, COMPILER_ANS_MAP, ALL_COMPILER_NAMES;
|
|
3889
|
+
var init_ANSNamespace = chunkHCCQLAA4_cjs.__esm({
|
|
3890
|
+
"src/compiler/identity/ANSNamespace.ts"() {
|
|
3891
|
+
ANSDomain = {
|
|
3892
|
+
GAMEDEV: "gamedev",
|
|
3893
|
+
SOCIAL_VR: "social-vr",
|
|
3894
|
+
XR: "xr",
|
|
3895
|
+
MOBILE: "mobile",
|
|
3896
|
+
WEB3D: "web3d",
|
|
3897
|
+
RUNTIME: "runtime",
|
|
3898
|
+
SHADER: "shader",
|
|
3899
|
+
ROBOTICS: "robotics",
|
|
3900
|
+
INTERCHANGE: "interchange",
|
|
3901
|
+
IOT: "iot",
|
|
3902
|
+
WEB3: "web3",
|
|
3903
|
+
AI: "ai",
|
|
3904
|
+
NEUROMORPHIC: "neuromorphic",
|
|
3905
|
+
META: "meta",
|
|
3906
|
+
MIXIN: "mixin"
|
|
3907
|
+
};
|
|
3908
|
+
ANSRiskTier = {
|
|
3909
|
+
STANDARD: "STANDARD",
|
|
3910
|
+
HIGH: "HIGH",
|
|
3911
|
+
CRITICAL: "CRITICAL"
|
|
3912
|
+
};
|
|
3913
|
+
({
|
|
3914
|
+
[ANSDomain.GAMEDEV]: ANSRiskTier.STANDARD,
|
|
3915
|
+
[ANSDomain.SOCIAL_VR]: ANSRiskTier.HIGH,
|
|
3916
|
+
[ANSDomain.XR]: ANSRiskTier.HIGH,
|
|
3917
|
+
[ANSDomain.MOBILE]: ANSRiskTier.HIGH,
|
|
3918
|
+
[ANSDomain.WEB3D]: ANSRiskTier.STANDARD,
|
|
3919
|
+
[ANSDomain.RUNTIME]: ANSRiskTier.HIGH,
|
|
3920
|
+
[ANSDomain.SHADER]: ANSRiskTier.STANDARD,
|
|
3921
|
+
[ANSDomain.ROBOTICS]: ANSRiskTier.CRITICAL,
|
|
3922
|
+
[ANSDomain.INTERCHANGE]: ANSRiskTier.STANDARD,
|
|
3923
|
+
[ANSDomain.IOT]: ANSRiskTier.HIGH,
|
|
3924
|
+
[ANSDomain.WEB3]: ANSRiskTier.CRITICAL,
|
|
3925
|
+
[ANSDomain.AI]: ANSRiskTier.HIGH,
|
|
3926
|
+
[ANSDomain.NEUROMORPHIC]: ANSRiskTier.HIGH,
|
|
3927
|
+
[ANSDomain.META]: ANSRiskTier.STANDARD,
|
|
3928
|
+
[ANSDomain.MIXIN]: ANSRiskTier.STANDARD
|
|
3929
|
+
});
|
|
3930
|
+
exports.ANSCapabilityPath = {
|
|
3931
|
+
// ── gamedev ──────────────────────────────────────────────────────────
|
|
3932
|
+
UNITY: "/compile/gamedev/unity",
|
|
3933
|
+
UNREAL: "/compile/gamedev/unreal",
|
|
3934
|
+
GODOT: "/compile/gamedev/godot",
|
|
3935
|
+
// ── social-vr ────────────────────────────────────────────────────────
|
|
3936
|
+
VRCHAT: "/compile/social-vr/vrchat",
|
|
3937
|
+
// ── xr ───────────────────────────────────────────────────────────────
|
|
3938
|
+
OPENXR: "/compile/xr/openxr",
|
|
3939
|
+
OPENXR_SPATIAL_ENTITIES: "/compile/xr/openxr-spatial-entities",
|
|
3940
|
+
VISIONOS: "/compile/xr/visionos",
|
|
3941
|
+
AR: "/compile/xr/ar",
|
|
3942
|
+
ANDROID_XR: "/compile/xr/android-xr",
|
|
3943
|
+
AI_GLASSES: "/compile/xr/ai-glasses",
|
|
3944
|
+
QUILT: "/compile/xr/quilt",
|
|
3945
|
+
MV_HEVC: "/compile/xr/mv-hevc",
|
|
3946
|
+
// ── mobile ───────────────────────────────────────────────────────────
|
|
3947
|
+
ANDROID: "/compile/mobile/android",
|
|
3948
|
+
IOS: "/compile/mobile/ios",
|
|
3949
|
+
// ── web3d ────────────────────────────────────────────────────────────
|
|
3950
|
+
BABYLON: "/compile/web3d/babylon",
|
|
3951
|
+
WEBGPU: "/compile/web3d/webgpu",
|
|
3952
|
+
R3F: "/compile/web3d/r3f",
|
|
3953
|
+
PLAYCANVAS: "/compile/web3d/playcanvas",
|
|
3954
|
+
THREEJS: "/compile/web3d/threejs",
|
|
3955
|
+
// ── runtime ──────────────────────────────────────────────────────────
|
|
3956
|
+
WASM: "/compile/runtime/wasm",
|
|
3957
|
+
NODE_SERVICE: "/compile/runtime/node-service",
|
|
3958
|
+
NEXTJS_API: "/compile/runtime/nextjs-api",
|
|
3959
|
+
// ── shader ───────────────────────────────────────────────────────────
|
|
3960
|
+
TSL: "/compile/shader/tsl",
|
|
3961
|
+
// ── robotics ─────────────────────────────────────────────────────────
|
|
3962
|
+
URDF: "/compile/robotics/urdf",
|
|
3963
|
+
SDF: "/compile/robotics/sdf",
|
|
3964
|
+
// ── interchange ──────────────────────────────────────────────────────
|
|
3965
|
+
USD: "/compile/interchange/usd",
|
|
3966
|
+
GLTF: "/compile/interchange/gltf",
|
|
3967
|
+
GAUSSIAN_SPLATTING: "/compile/interchange/3dgs",
|
|
3968
|
+
// ── iot ──────────────────────────────────────────────────────────────
|
|
3969
|
+
DTDL: "/compile/iot/dtdl",
|
|
3970
|
+
// ── web3 ─────────────────────────────────────────────────────────────
|
|
3971
|
+
NFT_MARKETPLACE: "/compile/web3/nft-marketplace",
|
|
3972
|
+
// ── ai ───────────────────────────────────────────────────────────────
|
|
3973
|
+
SCM: "/compile/ai/scm",
|
|
3974
|
+
VRR: "/compile/ai/vrr",
|
|
3975
|
+
A2A_AGENT_CARD: "/compile/ai/a2a-agent-card",
|
|
3976
|
+
AGENT_INFERENCE: "/compile/ai/agent-inference",
|
|
3977
|
+
// ── neuromorphic ─────────────────────────────────────────────────────
|
|
3978
|
+
NIR: "/compile/neuromorphic/nir",
|
|
3979
|
+
// ── meta ─────────────────────────────────────────────────────────────
|
|
3980
|
+
MULTI_LAYER: "/compile/meta/multi-layer",
|
|
3981
|
+
INCREMENTAL: "/compile/meta/incremental",
|
|
3982
|
+
STATE: "/compile/meta/state",
|
|
3983
|
+
TRAIT_COMPOSITION: "/compile/meta/trait-composition",
|
|
3984
|
+
// ── mixin ────────────────────────────────────────────────────────────
|
|
3985
|
+
DOMAIN_BLOCK: "/compile/mixin/domain-block"
|
|
3986
|
+
};
|
|
3987
|
+
COMPILER_DOMAIN_MAP = {
|
|
3988
|
+
// gamedev
|
|
3989
|
+
unity: ANSDomain.GAMEDEV,
|
|
3990
|
+
unreal: ANSDomain.GAMEDEV,
|
|
3991
|
+
godot: ANSDomain.GAMEDEV,
|
|
3992
|
+
// social-vr
|
|
3993
|
+
vrchat: ANSDomain.SOCIAL_VR,
|
|
3994
|
+
// xr
|
|
3995
|
+
openxr: ANSDomain.XR,
|
|
3996
|
+
"openxr-spatial-entities": ANSDomain.XR,
|
|
3997
|
+
visionos: ANSDomain.XR,
|
|
3998
|
+
ar: ANSDomain.XR,
|
|
3999
|
+
"android-xr": ANSDomain.XR,
|
|
4000
|
+
"ai-glasses": ANSDomain.XR,
|
|
4001
|
+
quilt: ANSDomain.XR,
|
|
4002
|
+
"mv-hevc": ANSDomain.XR,
|
|
4003
|
+
// mobile
|
|
4004
|
+
android: ANSDomain.MOBILE,
|
|
4005
|
+
ios: ANSDomain.MOBILE,
|
|
4006
|
+
// web3d
|
|
4007
|
+
babylon: ANSDomain.WEB3D,
|
|
4008
|
+
webgpu: ANSDomain.WEB3D,
|
|
4009
|
+
r3f: ANSDomain.WEB3D,
|
|
4010
|
+
playcanvas: ANSDomain.WEB3D,
|
|
4011
|
+
threejs: ANSDomain.WEB3D,
|
|
4012
|
+
// runtime
|
|
4013
|
+
wasm: ANSDomain.RUNTIME,
|
|
4014
|
+
"node-service": ANSDomain.RUNTIME,
|
|
4015
|
+
"nextjs-api": ANSDomain.RUNTIME,
|
|
4016
|
+
// shader
|
|
4017
|
+
tsl: ANSDomain.SHADER,
|
|
4018
|
+
// robotics
|
|
4019
|
+
urdf: ANSDomain.ROBOTICS,
|
|
4020
|
+
sdf: ANSDomain.ROBOTICS,
|
|
4021
|
+
// interchange
|
|
4022
|
+
usd: ANSDomain.INTERCHANGE,
|
|
4023
|
+
gltf: ANSDomain.INTERCHANGE,
|
|
4024
|
+
"3dgs": ANSDomain.INTERCHANGE,
|
|
4025
|
+
// iot
|
|
4026
|
+
dtdl: ANSDomain.IOT,
|
|
4027
|
+
// web3
|
|
4028
|
+
"nft-marketplace": ANSDomain.WEB3,
|
|
4029
|
+
// ai
|
|
4030
|
+
scm: ANSDomain.AI,
|
|
4031
|
+
vrr: ANSDomain.AI,
|
|
4032
|
+
"a2a-agent-card": ANSDomain.AI,
|
|
4033
|
+
"agent-inference": ANSDomain.AI,
|
|
4034
|
+
// neuromorphic
|
|
4035
|
+
nir: ANSDomain.NEUROMORPHIC,
|
|
4036
|
+
// meta
|
|
4037
|
+
"multi-layer": ANSDomain.META,
|
|
4038
|
+
incremental: ANSDomain.META,
|
|
4039
|
+
state: ANSDomain.META,
|
|
4040
|
+
"trait-composition": ANSDomain.META,
|
|
4041
|
+
// mixin
|
|
4042
|
+
"domain-block": ANSDomain.MIXIN
|
|
4043
|
+
};
|
|
4044
|
+
COMPILER_ANS_MAP = {
|
|
4045
|
+
unity: exports.ANSCapabilityPath.UNITY,
|
|
4046
|
+
unreal: exports.ANSCapabilityPath.UNREAL,
|
|
4047
|
+
godot: exports.ANSCapabilityPath.GODOT,
|
|
4048
|
+
vrchat: exports.ANSCapabilityPath.VRCHAT,
|
|
4049
|
+
openxr: exports.ANSCapabilityPath.OPENXR,
|
|
4050
|
+
"openxr-spatial-entities": exports.ANSCapabilityPath.OPENXR_SPATIAL_ENTITIES,
|
|
4051
|
+
visionos: exports.ANSCapabilityPath.VISIONOS,
|
|
4052
|
+
ar: exports.ANSCapabilityPath.AR,
|
|
4053
|
+
"android-xr": exports.ANSCapabilityPath.ANDROID_XR,
|
|
4054
|
+
"ai-glasses": exports.ANSCapabilityPath.AI_GLASSES,
|
|
4055
|
+
quilt: exports.ANSCapabilityPath.QUILT,
|
|
4056
|
+
"mv-hevc": exports.ANSCapabilityPath.MV_HEVC,
|
|
4057
|
+
android: exports.ANSCapabilityPath.ANDROID,
|
|
4058
|
+
ios: exports.ANSCapabilityPath.IOS,
|
|
4059
|
+
babylon: exports.ANSCapabilityPath.BABYLON,
|
|
4060
|
+
webgpu: exports.ANSCapabilityPath.WEBGPU,
|
|
4061
|
+
r3f: exports.ANSCapabilityPath.R3F,
|
|
4062
|
+
playcanvas: exports.ANSCapabilityPath.PLAYCANVAS,
|
|
4063
|
+
threejs: exports.ANSCapabilityPath.THREEJS,
|
|
4064
|
+
wasm: exports.ANSCapabilityPath.WASM,
|
|
4065
|
+
"node-service": exports.ANSCapabilityPath.NODE_SERVICE,
|
|
4066
|
+
"nextjs-api": exports.ANSCapabilityPath.NEXTJS_API,
|
|
4067
|
+
tsl: exports.ANSCapabilityPath.TSL,
|
|
4068
|
+
urdf: exports.ANSCapabilityPath.URDF,
|
|
4069
|
+
sdf: exports.ANSCapabilityPath.SDF,
|
|
4070
|
+
usd: exports.ANSCapabilityPath.USD,
|
|
4071
|
+
gltf: exports.ANSCapabilityPath.GLTF,
|
|
4072
|
+
"3dgs": exports.ANSCapabilityPath.GAUSSIAN_SPLATTING,
|
|
4073
|
+
dtdl: exports.ANSCapabilityPath.DTDL,
|
|
4074
|
+
"nft-marketplace": exports.ANSCapabilityPath.NFT_MARKETPLACE,
|
|
4075
|
+
scm: exports.ANSCapabilityPath.SCM,
|
|
4076
|
+
vrr: exports.ANSCapabilityPath.VRR,
|
|
4077
|
+
"a2a-agent-card": exports.ANSCapabilityPath.A2A_AGENT_CARD,
|
|
4078
|
+
"agent-inference": exports.ANSCapabilityPath.AGENT_INFERENCE,
|
|
4079
|
+
nir: exports.ANSCapabilityPath.NIR,
|
|
4080
|
+
"multi-layer": exports.ANSCapabilityPath.MULTI_LAYER,
|
|
4081
|
+
incremental: exports.ANSCapabilityPath.INCREMENTAL,
|
|
4082
|
+
state: exports.ANSCapabilityPath.STATE,
|
|
4083
|
+
"trait-composition": exports.ANSCapabilityPath.TRAIT_COMPOSITION,
|
|
4084
|
+
"domain-block": exports.ANSCapabilityPath.DOMAIN_BLOCK
|
|
4085
|
+
};
|
|
4086
|
+
ALL_COMPILER_NAMES = Object.keys(
|
|
4087
|
+
COMPILER_DOMAIN_MAP
|
|
4088
|
+
);
|
|
4089
|
+
Object.values(ANSDomain);
|
|
4090
|
+
}
|
|
4091
|
+
});
|
|
4092
|
+
|
|
4093
|
+
// src/compiler/CompilerDocumentationGenerator.ts
|
|
4094
|
+
exports.CompilerDocumentationGenerator = void 0;
|
|
4095
|
+
var init_CompilerDocumentationGenerator = chunkHCCQLAA4_cjs.__esm({
|
|
4096
|
+
"src/compiler/CompilerDocumentationGenerator.ts"() {
|
|
4097
|
+
chunk5FSKKMR7_cjs.init_traitDocs();
|
|
4098
|
+
exports.CompilerDocumentationGenerator = class {
|
|
4099
|
+
constructor(options = {}) {
|
|
4100
|
+
this.options = {
|
|
4101
|
+
serviceUrl: options.serviceUrl ?? "http://localhost:3000",
|
|
4102
|
+
serviceVersion: options.serviceVersion ?? "1.0.0",
|
|
4103
|
+
maxLlmsTxtTokens: options.maxLlmsTxtTokens ?? 800,
|
|
4104
|
+
includeTraitDocs: options.includeTraitDocs ?? true,
|
|
4105
|
+
includeExamples: options.includeExamples ?? true,
|
|
4106
|
+
mcpTransportType: options.mcpTransportType ?? "streamable-http",
|
|
4107
|
+
contactRepository: options.contactRepository ?? "",
|
|
4108
|
+
contactDocumentation: options.contactDocumentation ?? ""
|
|
4109
|
+
};
|
|
4110
|
+
}
|
|
4111
|
+
getObjectType(obj) {
|
|
4112
|
+
const typeProperty = obj.properties?.find(
|
|
4113
|
+
(property) => property.key === "geometry" || property.key === "shape" || property.key === "type"
|
|
4114
|
+
)?.value;
|
|
4115
|
+
return typeof typeProperty === "string" ? typeProperty : "Object";
|
|
4116
|
+
}
|
|
4117
|
+
/**
|
|
4118
|
+
* Generate all three documentation outputs for a compilation
|
|
4119
|
+
*
|
|
4120
|
+
* @param composition - Parsed HoloScript composition AST
|
|
4121
|
+
* @param targetName - Compiler target (e.g., 'r3f', 'unity', 'unreal')
|
|
4122
|
+
* @param compiledCode - The compiled output code
|
|
4123
|
+
* @returns Triple-output documentation bundle
|
|
4124
|
+
*/
|
|
4125
|
+
generate(composition, targetName, compiledCode, generationMeta) {
|
|
4126
|
+
return {
|
|
4127
|
+
llmsTxt: this.generateLlmsTxt(composition, targetName, compiledCode),
|
|
4128
|
+
wellKnownMcp: this.generateMCPServerCard(composition, targetName, generationMeta),
|
|
4129
|
+
markdownDocs: this.generateMarkdownDocs(composition, targetName, compiledCode)
|
|
4130
|
+
};
|
|
4131
|
+
}
|
|
4132
|
+
// ===========================================================================
|
|
4133
|
+
// LLMS.TXT GENERATION
|
|
4134
|
+
// ===========================================================================
|
|
4135
|
+
/**
|
|
4136
|
+
* Generate llms.txt format documentation (max 800 tokens)
|
|
4137
|
+
*
|
|
4138
|
+
* llms.txt is a standardized format for AI-readable project documentation.
|
|
4139
|
+
* It provides a concise overview optimized for LLM context windows.
|
|
4140
|
+
*
|
|
4141
|
+
* Includes: scene description, trait list, export targets, API surface,
|
|
4142
|
+
* MCP tool manifest summary, and state management.
|
|
4143
|
+
*
|
|
4144
|
+
* @see https://llmstxt.org/
|
|
4145
|
+
*/
|
|
4146
|
+
generateLlmsTxt(composition, targetName, compiledCode) {
|
|
4147
|
+
const sections = [];
|
|
4148
|
+
sections.push(`# ${composition.name || "HoloScript Composition"}`);
|
|
4149
|
+
sections.push("");
|
|
4150
|
+
sections.push("## Scene Description");
|
|
4151
|
+
sections.push(`Compiled for: ${targetName}`);
|
|
4152
|
+
sections.push(`Objects: ${composition.objects?.length || 0}`);
|
|
4153
|
+
sections.push(`Lights: ${composition.lights?.length || 0}`);
|
|
4154
|
+
sections.push(`Spatial Groups: ${composition.spatialGroups?.length || 0}`);
|
|
4155
|
+
sections.push(`Templates: ${composition.templates?.length || 0}`);
|
|
4156
|
+
sections.push("");
|
|
4157
|
+
const traits = this.extractTraits(composition);
|
|
4158
|
+
if (traits.length > 0) {
|
|
4159
|
+
sections.push("## Traits Used");
|
|
4160
|
+
const traitsByCategory = this.groupTraitsByCategory(traits);
|
|
4161
|
+
for (const [category, categoryTraits] of Object.entries(traitsByCategory)) {
|
|
4162
|
+
sections.push(`- ${category}: ${categoryTraits.join(", ")}`);
|
|
4163
|
+
}
|
|
4164
|
+
sections.push("");
|
|
4165
|
+
}
|
|
4166
|
+
sections.push("## Export Capabilities");
|
|
4167
|
+
sections.push(`Primary target: ${targetName}`);
|
|
4168
|
+
sections.push(
|
|
4169
|
+
"Compatible targets: unity, unreal, godot, r3f, webgpu, babylon, openxr, vrchat, wasm, gltf, usd"
|
|
4170
|
+
);
|
|
4171
|
+
sections.push("");
|
|
4172
|
+
if (typeof compiledCode === "object") {
|
|
4173
|
+
sections.push("## API Surface");
|
|
4174
|
+
const files = Object.keys(compiledCode);
|
|
4175
|
+
sections.push(`Generated files: ${files.length}`);
|
|
4176
|
+
sections.push(`- ${files.slice(0, 5).join("\n- ")}`);
|
|
4177
|
+
if (files.length > 5) {
|
|
4178
|
+
sections.push(`- ... and ${files.length - 5} more`);
|
|
4179
|
+
}
|
|
4180
|
+
sections.push("");
|
|
4181
|
+
}
|
|
4182
|
+
const mcpTools = this.extractMCPTools(composition, targetName);
|
|
4183
|
+
if (mcpTools.length > 0) {
|
|
4184
|
+
sections.push("## MCP Tools");
|
|
4185
|
+
sections.push(`Available tools: ${mcpTools.length}`);
|
|
4186
|
+
for (const tool of mcpTools.slice(0, 8)) {
|
|
4187
|
+
sections.push(`- ${tool.name}: ${tool.description}`);
|
|
4188
|
+
}
|
|
4189
|
+
if (mcpTools.length > 8) {
|
|
4190
|
+
sections.push(`- ... and ${mcpTools.length - 8} more`);
|
|
4191
|
+
}
|
|
4192
|
+
sections.push("");
|
|
4193
|
+
}
|
|
4194
|
+
if (composition.state) {
|
|
4195
|
+
const stateObj = composition.state;
|
|
4196
|
+
let stateProps = [];
|
|
4197
|
+
if (stateObj.properties && Array.isArray(stateObj.properties)) {
|
|
4198
|
+
stateProps = stateObj.properties.map((p) => p.key);
|
|
4199
|
+
} else {
|
|
4200
|
+
stateProps = Object.keys(stateObj);
|
|
4201
|
+
}
|
|
4202
|
+
if (stateProps.length > 0) {
|
|
4203
|
+
sections.push("## State Management");
|
|
4204
|
+
sections.push(`State properties: ${stateProps.length}`);
|
|
4205
|
+
sections.push(`- ${stateProps.slice(0, 5).join(", ")}`);
|
|
4206
|
+
if (stateProps.length > 5) {
|
|
4207
|
+
sections.push(` ... and ${stateProps.length - 5} more`);
|
|
4208
|
+
}
|
|
4209
|
+
sections.push("");
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
if (composition.environment) {
|
|
4213
|
+
const env = composition.environment;
|
|
4214
|
+
sections.push("## Environment");
|
|
4215
|
+
sections.push(`Background: ${env.background || "default"}`);
|
|
4216
|
+
if (env.fog) {
|
|
4217
|
+
sections.push("Fog: enabled");
|
|
4218
|
+
}
|
|
4219
|
+
sections.push("");
|
|
4220
|
+
}
|
|
4221
|
+
const fullText = sections.join("\n");
|
|
4222
|
+
const maxChars = this.options.maxLlmsTxtTokens * 4;
|
|
4223
|
+
if (fullText.length > maxChars) {
|
|
4224
|
+
return fullText.substring(0, maxChars) + "\n\n... (truncated to fit token limit)";
|
|
4225
|
+
}
|
|
4226
|
+
return fullText;
|
|
4227
|
+
}
|
|
4228
|
+
// ===========================================================================
|
|
4229
|
+
// .WELL-KNOWN/MCP GENERATION
|
|
4230
|
+
// ===========================================================================
|
|
4231
|
+
/**
|
|
4232
|
+
* Generate MCP server card conforming to SEP-1649 and SEP-1960
|
|
4233
|
+
*
|
|
4234
|
+
* Produces a server card that satisfies both specification proposals:
|
|
4235
|
+
* - SEP-1649: serverInfo nested object, transport with endpoint, protocolVersion
|
|
4236
|
+
* - SEP-1960: endpoints object, authentication, capabilities as booleans
|
|
4237
|
+
*
|
|
4238
|
+
* The card includes legacy compatibility fields (name, version at root)
|
|
4239
|
+
* for backward compatibility with v1.0.0 consumers.
|
|
4240
|
+
*/
|
|
4241
|
+
generateMCPServerCard(composition, targetName, generationMeta) {
|
|
4242
|
+
const tools = this.extractMCPTools(composition, targetName);
|
|
4243
|
+
const sanitizedName = this.sanitizeServiceName(composition.name || "holoscript-composition");
|
|
4244
|
+
const compositionTitle = composition.name || "Untitled";
|
|
4245
|
+
const traitCount = this.extractTraits(composition).length;
|
|
4246
|
+
const objectCount = composition.objects?.length || 0;
|
|
4247
|
+
const endpoints = {};
|
|
4248
|
+
const transportType = this.options.mcpTransportType;
|
|
4249
|
+
const mcpUrl = `${this.options.serviceUrl}/mcp`;
|
|
4250
|
+
if (transportType === "streamable-http" || transportType === "http") {
|
|
4251
|
+
endpoints.streamable_http = mcpUrl;
|
|
4252
|
+
} else if (transportType === "sse") {
|
|
4253
|
+
endpoints.sse = mcpUrl;
|
|
4254
|
+
} else if (transportType === "websocket" || transportType === "ws") {
|
|
4255
|
+
endpoints.websocket = mcpUrl;
|
|
4256
|
+
} else {
|
|
4257
|
+
endpoints.streamable_http = mcpUrl;
|
|
4258
|
+
}
|
|
4259
|
+
endpoints.health = `${this.options.serviceUrl}/health`;
|
|
4260
|
+
endpoints.render = `${this.options.serviceUrl}/api/render`;
|
|
4261
|
+
const holoscriptMeta = {
|
|
4262
|
+
compiler_target: targetName,
|
|
4263
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4264
|
+
};
|
|
4265
|
+
if (generationMeta?.compilationDigest) {
|
|
4266
|
+
holoscriptMeta.compilation_digest = generationMeta.compilationDigest;
|
|
4267
|
+
}
|
|
4268
|
+
return {
|
|
4269
|
+
// SEP-1960 fields
|
|
4270
|
+
mcpVersion: "2025-03-26",
|
|
4271
|
+
// SEP-1649 fields
|
|
4272
|
+
protocolVersion: "2025-06-18",
|
|
4273
|
+
serverInfo: {
|
|
4274
|
+
name: sanitizedName,
|
|
4275
|
+
title: `HoloScript: ${compositionTitle}`,
|
|
4276
|
+
version: this.options.serviceVersion
|
|
4277
|
+
},
|
|
4278
|
+
description: `HoloScript composition "${compositionTitle}" compiled for ${targetName} \u2014 ${objectCount} objects, ${traitCount} unique traits`,
|
|
4279
|
+
transport: {
|
|
4280
|
+
type: transportType,
|
|
4281
|
+
endpoint: mcpUrl,
|
|
4282
|
+
authentication: null
|
|
4283
|
+
},
|
|
4284
|
+
capabilities: {
|
|
4285
|
+
tools: {
|
|
4286
|
+
count: tools.length
|
|
4287
|
+
},
|
|
4288
|
+
resources: false,
|
|
4289
|
+
prompts: false,
|
|
4290
|
+
sampling: false,
|
|
4291
|
+
roots: false
|
|
4292
|
+
},
|
|
4293
|
+
tools,
|
|
4294
|
+
endpoints,
|
|
4295
|
+
authentication: {
|
|
4296
|
+
required: false,
|
|
4297
|
+
methods: ["none"]
|
|
4298
|
+
},
|
|
4299
|
+
contact: {
|
|
4300
|
+
repository: this.options.contactRepository || void 0,
|
|
4301
|
+
documentation: this.options.contactDocumentation || void 0
|
|
4302
|
+
},
|
|
4303
|
+
documentation: this.options.contactDocumentation || void 0,
|
|
4304
|
+
_meta: {
|
|
4305
|
+
holoscript: holoscriptMeta
|
|
4306
|
+
},
|
|
4307
|
+
// Legacy compatibility (v1.0.0)
|
|
4308
|
+
name: sanitizedName,
|
|
4309
|
+
version: this.options.serviceVersion
|
|
4310
|
+
};
|
|
4311
|
+
}
|
|
4312
|
+
/**
|
|
4313
|
+
* Extract MCP tool manifest from composition
|
|
4314
|
+
*/
|
|
4315
|
+
extractMCPTools(composition, targetName) {
|
|
4316
|
+
const tools = [];
|
|
4317
|
+
tools.push({
|
|
4318
|
+
name: "compile_composition",
|
|
4319
|
+
description: `Compile this HoloScript composition to ${targetName} format`,
|
|
4320
|
+
inputSchema: {
|
|
4321
|
+
type: "object",
|
|
4322
|
+
properties: {
|
|
4323
|
+
options: {
|
|
4324
|
+
type: "object",
|
|
4325
|
+
description: "Compiler options"
|
|
4326
|
+
}
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4329
|
+
});
|
|
4330
|
+
tools.push({
|
|
4331
|
+
name: "render_preview",
|
|
4332
|
+
description: `Render a preview of this composition as PNG/JPEG`,
|
|
4333
|
+
inputSchema: {
|
|
4334
|
+
type: "object",
|
|
4335
|
+
properties: {
|
|
4336
|
+
width: { type: "number", description: "Image width in pixels" },
|
|
4337
|
+
height: { type: "number", description: "Image height in pixels" },
|
|
4338
|
+
format: { type: "string", enum: ["png", "jpeg", "webp"] }
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
});
|
|
4342
|
+
if (composition.templates && composition.templates.length > 0) {
|
|
4343
|
+
for (const template of composition.templates.slice(0, 10)) {
|
|
4344
|
+
tools.push({
|
|
4345
|
+
name: `instantiate_${this.sanitizeToolName(template.name)}`,
|
|
4346
|
+
description: `Instantiate the "${template.name}" template with custom properties`,
|
|
4347
|
+
inputSchema: {
|
|
4348
|
+
type: "object",
|
|
4349
|
+
properties: {
|
|
4350
|
+
properties: {
|
|
4351
|
+
type: "object",
|
|
4352
|
+
description: "Template properties to override"
|
|
4353
|
+
},
|
|
4354
|
+
position: {
|
|
4355
|
+
type: "object",
|
|
4356
|
+
description: "Spatial position",
|
|
4357
|
+
properties: [{ type: "number" }, { type: "number" }, { type: "number" }]
|
|
4358
|
+
}
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
});
|
|
4362
|
+
}
|
|
4363
|
+
}
|
|
4364
|
+
if (composition.state) {
|
|
4365
|
+
tools.push({
|
|
4366
|
+
name: "update_state",
|
|
4367
|
+
description: "Update composition state properties",
|
|
4368
|
+
inputSchema: {
|
|
4369
|
+
type: "object",
|
|
4370
|
+
properties: {
|
|
4371
|
+
updates: {
|
|
4372
|
+
type: "object",
|
|
4373
|
+
description: "State property updates"
|
|
4374
|
+
}
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4377
|
+
});
|
|
4378
|
+
}
|
|
4379
|
+
tools.push({
|
|
4380
|
+
name: "list_traits",
|
|
4381
|
+
description: "List all traits used in this composition with their configurations",
|
|
4382
|
+
inputSchema: {
|
|
4383
|
+
type: "object",
|
|
4384
|
+
properties: {
|
|
4385
|
+
category: {
|
|
4386
|
+
type: "string",
|
|
4387
|
+
description: "Filter by trait category (visual, physics, audio, etc.)"
|
|
4388
|
+
}
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
});
|
|
4392
|
+
if (composition.objects && composition.objects.length > 0) {
|
|
4393
|
+
tools.push({
|
|
4394
|
+
name: "query_objects",
|
|
4395
|
+
description: `Query scene objects by name, type, or trait (${composition.objects.length} objects available)`,
|
|
4396
|
+
inputSchema: {
|
|
4397
|
+
type: "object",
|
|
4398
|
+
properties: {
|
|
4399
|
+
name: { type: "string", description: "Filter by object name (glob pattern)" },
|
|
4400
|
+
trait: { type: "string", description: "Filter by trait name" }
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4403
|
+
});
|
|
4404
|
+
}
|
|
4405
|
+
return tools;
|
|
4406
|
+
}
|
|
4407
|
+
// ===========================================================================
|
|
4408
|
+
// MARKDOWN DOCUMENTATION GENERATION
|
|
4409
|
+
// ===========================================================================
|
|
4410
|
+
/**
|
|
4411
|
+
* Generate comprehensive markdown documentation bundle
|
|
4412
|
+
*
|
|
4413
|
+
* Includes: composition metadata, scene graph, trait documentation,
|
|
4414
|
+
* state management, logic handlers, MCP tool manifests, and compilation output.
|
|
4415
|
+
*/
|
|
4416
|
+
generateMarkdownDocs(composition, targetName, compiledCode) {
|
|
4417
|
+
const sections = [];
|
|
4418
|
+
sections.push(`# ${composition.name || "HoloScript Composition"}`);
|
|
4419
|
+
sections.push("");
|
|
4420
|
+
sections.push(`**Target:** ${targetName}`);
|
|
4421
|
+
sections.push(`**Generated:** ${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
4422
|
+
sections.push(`**Version:** ${this.options.serviceVersion}`);
|
|
4423
|
+
sections.push("");
|
|
4424
|
+
sections.push("## Table of Contents");
|
|
4425
|
+
sections.push("");
|
|
4426
|
+
sections.push("- [Overview](#overview)");
|
|
4427
|
+
sections.push("- [Scene Graph](#scene-graph)");
|
|
4428
|
+
sections.push("- [Traits](#traits)");
|
|
4429
|
+
if (composition.state) {
|
|
4430
|
+
sections.push("- [State Management](#state-management)");
|
|
4431
|
+
}
|
|
4432
|
+
if (composition.logic) {
|
|
4433
|
+
sections.push("- [Logic Handlers](#logic-handlers)");
|
|
4434
|
+
}
|
|
4435
|
+
sections.push("- [MCP Tool Manifest](#mcp-tool-manifest)");
|
|
4436
|
+
sections.push("- [Compilation Output](#compilation-output)");
|
|
4437
|
+
sections.push("");
|
|
4438
|
+
sections.push("## Overview");
|
|
4439
|
+
sections.push("");
|
|
4440
|
+
sections.push(
|
|
4441
|
+
`This composition contains ${composition.objects?.length || 0} objects, ${composition.lights?.length || 0} lights, and ${composition.spatialGroups?.length || 0} spatial groups.`
|
|
4442
|
+
);
|
|
4443
|
+
sections.push("");
|
|
4444
|
+
if (composition.templates && composition.templates.length > 0) {
|
|
4445
|
+
sections.push(`**Templates:** ${composition.templates.length}`);
|
|
4446
|
+
}
|
|
4447
|
+
if (composition.imports && composition.imports.length > 0) {
|
|
4448
|
+
sections.push(`**Imports:** ${composition.imports.length}`);
|
|
4449
|
+
}
|
|
4450
|
+
if (composition.traitDefinitions && composition.traitDefinitions.length > 0) {
|
|
4451
|
+
sections.push(`**Custom Traits:** ${composition.traitDefinitions.length}`);
|
|
4452
|
+
}
|
|
4453
|
+
sections.push("");
|
|
4454
|
+
sections.push("## Scene Graph");
|
|
4455
|
+
sections.push("");
|
|
4456
|
+
if (composition.objects && composition.objects.length > 0) {
|
|
4457
|
+
sections.push("### Objects");
|
|
4458
|
+
sections.push("");
|
|
4459
|
+
sections.push("| Name | Type | Position | Traits |");
|
|
4460
|
+
sections.push("|------|------|----------|--------|");
|
|
4461
|
+
for (const obj of composition.objects.slice(0, 20)) {
|
|
4462
|
+
const objRec = obj;
|
|
4463
|
+
const transform = objRec.transform;
|
|
4464
|
+
const pos = objRec.position || transform?.position;
|
|
4465
|
+
const posStr = pos ? `(${pos[0]}, ${pos[1]}, ${pos[2]})` : "N/A";
|
|
4466
|
+
const traitNames = obj.traits ? this.extractTraitNames(obj.traits).join(", ") || "none" : "none";
|
|
4467
|
+
sections.push(`| ${obj.name} | ${this.getObjectType(obj)} | ${posStr} | ${traitNames} |`);
|
|
4468
|
+
}
|
|
4469
|
+
if (composition.objects.length > 20) {
|
|
4470
|
+
sections.push(`| ... | ... | ... | *${composition.objects.length - 20} more objects* |`);
|
|
4471
|
+
}
|
|
4472
|
+
sections.push("");
|
|
4473
|
+
}
|
|
4474
|
+
if (composition.lights && composition.lights.length > 0) {
|
|
4475
|
+
sections.push("### Lights");
|
|
4476
|
+
sections.push("");
|
|
4477
|
+
sections.push("| Name | Type |");
|
|
4478
|
+
sections.push("|------|------|");
|
|
4479
|
+
for (const light of composition.lights) {
|
|
4480
|
+
const lightRec = light;
|
|
4481
|
+
sections.push(
|
|
4482
|
+
`| ${light.name || "unnamed"} | ${lightRec.lightType || "unknown"} |`
|
|
4483
|
+
);
|
|
4484
|
+
}
|
|
4485
|
+
sections.push("");
|
|
4486
|
+
}
|
|
4487
|
+
const traits = this.extractTraits(composition);
|
|
4488
|
+
if (traits.length > 0) {
|
|
4489
|
+
sections.push("## Traits");
|
|
4490
|
+
sections.push("");
|
|
4491
|
+
sections.push(`This composition uses ${traits.length} unique traits:`);
|
|
4492
|
+
sections.push("");
|
|
4493
|
+
const traitsByCategory = this.groupTraitsByCategory(traits);
|
|
4494
|
+
for (const [category, categoryTraits] of Object.entries(traitsByCategory)) {
|
|
4495
|
+
sections.push(`### ${category}`);
|
|
4496
|
+
sections.push("");
|
|
4497
|
+
for (const trait of categoryTraits) {
|
|
4498
|
+
sections.push(`- **${trait}**`);
|
|
4499
|
+
if (this.options.includeTraitDocs) {
|
|
4500
|
+
const doc = this.getTraitDocumentation(trait);
|
|
4501
|
+
if (doc) {
|
|
4502
|
+
for (const line of doc.split("\n")) {
|
|
4503
|
+
sections.push(line === "" ? "" : ` ${line}`);
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
sections.push("");
|
|
4509
|
+
}
|
|
4510
|
+
}
|
|
4511
|
+
if (composition.traitDefinitions && composition.traitDefinitions.length > 0) {
|
|
4512
|
+
sections.push("### Custom Trait Definitions");
|
|
4513
|
+
sections.push("");
|
|
4514
|
+
for (const traitDef of composition.traitDefinitions) {
|
|
4515
|
+
const traitDefRec = traitDef;
|
|
4516
|
+
const extendsClause = traitDefRec.extends ? ` extends ${traitDefRec.extends}` : "";
|
|
4517
|
+
sections.push(`- **${traitDef.name}**${extendsClause}`);
|
|
4518
|
+
}
|
|
4519
|
+
sections.push("");
|
|
4520
|
+
}
|
|
4521
|
+
if (composition.state) {
|
|
4522
|
+
sections.push("## State Management");
|
|
4523
|
+
sections.push("");
|
|
4524
|
+
sections.push("### State Properties");
|
|
4525
|
+
sections.push("");
|
|
4526
|
+
sections.push("| Property | Type | Default Value |");
|
|
4527
|
+
sections.push("|----------|------|---------------|");
|
|
4528
|
+
const stateObj = composition.state;
|
|
4529
|
+
if (stateObj.properties) {
|
|
4530
|
+
for (const prop of stateObj.properties) {
|
|
4531
|
+
const typeOf = typeof prop.value;
|
|
4532
|
+
const defaultValue = JSON.stringify(prop.value).substring(0, 50);
|
|
4533
|
+
sections.push(`| ${prop.key} | ${typeOf} | ${defaultValue} |`);
|
|
4534
|
+
}
|
|
4535
|
+
} else {
|
|
4536
|
+
for (const [key, value] of Object.entries(stateObj)) {
|
|
4537
|
+
const typeOf = typeof value;
|
|
4538
|
+
const defaultValue = JSON.stringify(value).substring(0, 50);
|
|
4539
|
+
sections.push(`| ${key} | ${typeOf} | ${defaultValue} |`);
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
sections.push("");
|
|
4543
|
+
}
|
|
4544
|
+
if (composition.logic) {
|
|
4545
|
+
sections.push("## Logic Handlers");
|
|
4546
|
+
sections.push("");
|
|
4547
|
+
const logic = composition.logic;
|
|
4548
|
+
if (logic.on_start) {
|
|
4549
|
+
sections.push("### on_start");
|
|
4550
|
+
sections.push("");
|
|
4551
|
+
sections.push("Executed when the composition initializes.");
|
|
4552
|
+
sections.push("");
|
|
4553
|
+
}
|
|
4554
|
+
if (logic.on_update) {
|
|
4555
|
+
sections.push("### on_update");
|
|
4556
|
+
sections.push("");
|
|
4557
|
+
sections.push("Executed every frame.");
|
|
4558
|
+
sections.push("");
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4561
|
+
const mcpTools = this.extractMCPTools(composition, targetName);
|
|
4562
|
+
sections.push("## MCP Tool Manifest");
|
|
4563
|
+
sections.push("");
|
|
4564
|
+
sections.push(
|
|
4565
|
+
`This compilation exposes ${mcpTools.length} MCP tools for programmatic interaction:`
|
|
4566
|
+
);
|
|
4567
|
+
sections.push("");
|
|
4568
|
+
sections.push("| Tool | Description | Input Schema |");
|
|
4569
|
+
sections.push("|------|-------------|-------------|");
|
|
4570
|
+
for (const tool of mcpTools) {
|
|
4571
|
+
const schemaStr = tool.inputSchema ? "`" + JSON.stringify(
|
|
4572
|
+
Object.keys(
|
|
4573
|
+
tool.inputSchema.properties || {}
|
|
4574
|
+
)
|
|
4575
|
+
) + "`" : "none";
|
|
4576
|
+
sections.push(`| \`${tool.name}\` | ${tool.description} | ${schemaStr} |`);
|
|
4577
|
+
}
|
|
4578
|
+
sections.push("");
|
|
4579
|
+
sections.push("### Discovery");
|
|
4580
|
+
sections.push("");
|
|
4581
|
+
sections.push(`Server card available at: \`${this.options.serviceUrl}/.well-known/mcp\``);
|
|
4582
|
+
sections.push("");
|
|
4583
|
+
sections.push("```json");
|
|
4584
|
+
sections.push(`{`);
|
|
4585
|
+
sections.push(` "mcpVersion": "2025-03-26",`);
|
|
4586
|
+
sections.push(` "protocolVersion": "2025-06-18",`);
|
|
4587
|
+
sections.push(` "serverInfo": {`);
|
|
4588
|
+
sections.push(
|
|
4589
|
+
` "name": "${this.sanitizeServiceName(composition.name || "holoscript-composition")}",`
|
|
4590
|
+
);
|
|
4591
|
+
sections.push(` "version": "${this.options.serviceVersion}"`);
|
|
4592
|
+
sections.push(` }`);
|
|
4593
|
+
sections.push(`}`);
|
|
4594
|
+
sections.push("```");
|
|
4595
|
+
sections.push("");
|
|
4596
|
+
sections.push("## Compilation Output");
|
|
4597
|
+
sections.push("");
|
|
4598
|
+
if (typeof compiledCode === "string") {
|
|
4599
|
+
const lineCount = compiledCode.split("\n").length;
|
|
4600
|
+
sections.push(`Generated ${lineCount} lines of ${targetName} code.`);
|
|
4601
|
+
} else {
|
|
4602
|
+
sections.push(`Generated ${Object.keys(compiledCode).length} files:`);
|
|
4603
|
+
sections.push("");
|
|
4604
|
+
for (const [filename, content] of Object.entries(compiledCode)) {
|
|
4605
|
+
const lineCount = content.split("\n").length;
|
|
4606
|
+
sections.push(`- **${filename}** (${lineCount} lines)`);
|
|
4607
|
+
}
|
|
4608
|
+
}
|
|
4609
|
+
sections.push("");
|
|
4610
|
+
sections.push("---");
|
|
4611
|
+
sections.push("");
|
|
4612
|
+
sections.push("*Generated by HoloScript Compiler Documentation Generator v2.0.0*");
|
|
4613
|
+
sections.push("");
|
|
4614
|
+
return sections.join("\n");
|
|
4615
|
+
}
|
|
4616
|
+
// ===========================================================================
|
|
4617
|
+
// HELPER METHODS
|
|
4618
|
+
// ===========================================================================
|
|
4619
|
+
/**
|
|
4620
|
+
* Extract trait names from a traits field.
|
|
4621
|
+
*
|
|
4622
|
+
* Handles both formats:
|
|
4623
|
+
* - HoloObjectTrait[] (canonical parser output: array of { name, config })
|
|
4624
|
+
* - Map<string, unknown> (R3F compiler output: Map with trait names as keys)
|
|
4625
|
+
*/
|
|
4626
|
+
extractTraitNames(traits) {
|
|
4627
|
+
if (!traits) return [];
|
|
4628
|
+
if (traits instanceof Map) {
|
|
4629
|
+
return Array.from(traits.keys());
|
|
4630
|
+
}
|
|
4631
|
+
if (Array.isArray(traits)) {
|
|
4632
|
+
return traits.map((t) => typeof t === "string" ? t : t?.name).filter((name) => typeof name === "string");
|
|
4633
|
+
}
|
|
4634
|
+
return [];
|
|
4635
|
+
}
|
|
4636
|
+
/**
|
|
4637
|
+
* Extract all unique traits from a composition
|
|
4638
|
+
*/
|
|
4639
|
+
extractTraits(composition) {
|
|
4640
|
+
const traitSet = /* @__PURE__ */ new Set();
|
|
4641
|
+
if (composition.objects) {
|
|
4642
|
+
for (const obj of composition.objects) {
|
|
4643
|
+
for (const name of this.extractTraitNames(obj.traits)) {
|
|
4644
|
+
traitSet.add(name);
|
|
4645
|
+
}
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
if (composition.templates) {
|
|
4649
|
+
for (const template of composition.templates) {
|
|
4650
|
+
for (const name of this.extractTraitNames(template.traits)) {
|
|
4651
|
+
traitSet.add(name);
|
|
4652
|
+
}
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4655
|
+
return Array.from(traitSet).sort();
|
|
4656
|
+
}
|
|
4657
|
+
/**
|
|
4658
|
+
* Group traits by category (visual, physics, audio, etc.)
|
|
4659
|
+
*/
|
|
4660
|
+
groupTraitsByCategory(traits) {
|
|
4661
|
+
const categories = {
|
|
4662
|
+
Visual: [],
|
|
4663
|
+
Physics: [],
|
|
4664
|
+
Audio: [],
|
|
4665
|
+
Interaction: [],
|
|
4666
|
+
AI: [],
|
|
4667
|
+
Animation: [],
|
|
4668
|
+
Network: [],
|
|
4669
|
+
Other: []
|
|
4670
|
+
};
|
|
4671
|
+
for (const trait of traits) {
|
|
4672
|
+
const category = this.categorizeTrait(trait);
|
|
4673
|
+
categories[category].push(trait);
|
|
4674
|
+
}
|
|
4675
|
+
return Object.fromEntries(
|
|
4676
|
+
Object.entries(categories).filter(([_, traits2]) => traits2.length > 0)
|
|
4677
|
+
);
|
|
4678
|
+
}
|
|
4679
|
+
/**
|
|
4680
|
+
* Categorize a trait by name pattern
|
|
4681
|
+
*/
|
|
4682
|
+
categorizeTrait(trait) {
|
|
4683
|
+
if (!trait) return "Other";
|
|
4684
|
+
const lower = trait.toLowerCase();
|
|
4685
|
+
if (lower.includes("material") || lower.includes("color") || lower.includes("texture") || lower.includes("glow") || lower.includes("emissive") || lower.includes("shader") || lower.includes("pbr") || lower.includes("light") || lower.includes("shadow") || lower.includes("fog") || lower.includes("transparency") || lower.includes("opacity")) {
|
|
4686
|
+
return "Visual";
|
|
4687
|
+
}
|
|
4688
|
+
if (lower.includes("physics") || lower.includes("collider") || lower.includes("rigidbody") || lower.includes("gravity") || lower.includes("fluid") || lower.includes("constraint") || lower.includes("joint")) {
|
|
4689
|
+
return "Physics";
|
|
4690
|
+
}
|
|
4691
|
+
if (lower.includes("audio") || lower.includes("sound") || lower.includes("music") || lower.includes("spatial_audio")) {
|
|
4692
|
+
return "Audio";
|
|
4693
|
+
}
|
|
4694
|
+
if (lower.includes("clickable") || lower.includes("draggable") || lower.includes("interactive") || lower.includes("hover") || lower.includes("grab") || lower.includes("pointer") || lower.includes("selectable")) {
|
|
4695
|
+
return "Interaction";
|
|
4696
|
+
}
|
|
4697
|
+
if (lower.includes("ai") || lower.includes("npc") || lower.includes("behavior") || lower.includes("pathfinding") || lower.includes("agent") || lower.includes("decision")) {
|
|
4698
|
+
return "AI";
|
|
4699
|
+
}
|
|
4700
|
+
if (lower.includes("anim") || lower.includes("rotate") || lower.includes("move") || lower.includes("orbit") || lower.includes("keyframe") || lower.includes("tween") || lower.includes("spring")) {
|
|
4701
|
+
return "Animation";
|
|
4702
|
+
}
|
|
4703
|
+
if (lower.includes("network") || lower.includes("sync") || lower.includes("multiplayer") || lower.includes("replicated") || lower.includes("authority") || lower.includes("lobby")) {
|
|
4704
|
+
return "Network";
|
|
4705
|
+
}
|
|
4706
|
+
return "Other";
|
|
4707
|
+
}
|
|
4708
|
+
/** Resolve trait docs from the shared LSP trait database (now in @holoscript/core). */
|
|
4709
|
+
getTraitDocumentation(trait) {
|
|
4710
|
+
const doc = chunk5FSKKMR7_cjs.getTraitDoc(trait);
|
|
4711
|
+
if (!doc) return null;
|
|
4712
|
+
return chunk5FSKKMR7_cjs.formatTraitDocCompact(doc);
|
|
4713
|
+
}
|
|
4714
|
+
/**
|
|
4715
|
+
* Sanitize composition name for use as a service name
|
|
4716
|
+
*/
|
|
4717
|
+
sanitizeServiceName(name) {
|
|
4718
|
+
return name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
4719
|
+
}
|
|
4720
|
+
/**
|
|
4721
|
+
* Sanitize template name for use as a tool name
|
|
4722
|
+
*/
|
|
4723
|
+
sanitizeToolName(name) {
|
|
4724
|
+
return name.toLowerCase().replace(/[^a-z0-9_]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
4725
|
+
}
|
|
4726
|
+
};
|
|
4727
|
+
}
|
|
4728
|
+
});
|
|
4729
|
+
|
|
4730
|
+
// src/compiler/identity/CapabilityRBAC.ts
|
|
4731
|
+
function getCapabilityRBAC(config) {
|
|
4732
|
+
if (!globalCapabilityRBAC) {
|
|
4733
|
+
globalCapabilityRBAC = new CapabilityRBAC(config);
|
|
4734
|
+
}
|
|
4735
|
+
return globalCapabilityRBAC;
|
|
4736
|
+
}
|
|
4737
|
+
var RESOURCE_TYPE_TO_URI, OPERATION_TO_ACTION_SUFFIX, CapabilityRBAC, globalCapabilityRBAC;
|
|
4738
|
+
var init_CapabilityRBAC = chunkHCCQLAA4_cjs.__esm({
|
|
4739
|
+
"src/compiler/identity/CapabilityRBAC.ts"() {
|
|
4740
|
+
init_AgentRBAC();
|
|
4741
|
+
init_CapabilityToken();
|
|
4742
|
+
init_CapabilityTokenIssuer();
|
|
4743
|
+
RESOURCE_TYPE_TO_URI = {
|
|
4744
|
+
["source_file" /* SOURCE_FILE */]: `${HOLOSCRIPT_RESOURCE_SCHEME}source`,
|
|
4745
|
+
["ast" /* AST */]: `${HOLOSCRIPT_RESOURCE_SCHEME}ast`,
|
|
4746
|
+
["ir" /* IR */]: `${HOLOSCRIPT_RESOURCE_SCHEME}ir`,
|
|
4747
|
+
["code" /* CODE */]: `${HOLOSCRIPT_RESOURCE_SCHEME}code`,
|
|
4748
|
+
["output" /* OUTPUT */]: `${HOLOSCRIPT_RESOURCE_SCHEME}output`,
|
|
4749
|
+
["config" /* CONFIG */]: `${HOLOSCRIPT_RESOURCE_SCHEME}config`
|
|
4750
|
+
};
|
|
4751
|
+
OPERATION_TO_ACTION_SUFFIX = {
|
|
4752
|
+
read: "read",
|
|
4753
|
+
write: "write",
|
|
4754
|
+
execute: "execute",
|
|
4755
|
+
transform: "transform"
|
|
4756
|
+
};
|
|
4757
|
+
CapabilityRBAC = class {
|
|
4758
|
+
constructor(config = {}) {
|
|
4759
|
+
this.denialCounter = 0;
|
|
4760
|
+
this.rbac = config.rbac ?? getRBAC();
|
|
4761
|
+
this.capabilityIssuer = config.capabilityIssuer ?? getCapabilityTokenIssuer();
|
|
4762
|
+
this.strategy = config.strategy ?? "capability-first";
|
|
4763
|
+
this.semantics = new HoloScriptCapabilitySemantics();
|
|
4764
|
+
}
|
|
4765
|
+
buildDenialReceipt(request, deniedBy, opts) {
|
|
4766
|
+
const resourceUri = request.resourceType ? this.buildResourceUri(request.resourceType, request.resourcePath) : "unknown";
|
|
4767
|
+
const action = request.resourceType && request.operation ? this.buildAction(request.resourceType, request.operation) : request.operation || "unknown";
|
|
4768
|
+
return {
|
|
4769
|
+
auditId: `deny-${++this.denialCounter}-${Date.now()}`,
|
|
4770
|
+
deniedAction: action,
|
|
4771
|
+
requestedResource: resourceUri,
|
|
4772
|
+
deniedBy,
|
|
4773
|
+
requiredCapability: opts?.requiredCapability,
|
|
4774
|
+
suggestedFix: opts?.suggestedFix,
|
|
4775
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
4776
|
+
};
|
|
4777
|
+
}
|
|
4778
|
+
// -----------------------------------------------------------------------
|
|
4779
|
+
// Core access check
|
|
4780
|
+
// -----------------------------------------------------------------------
|
|
4781
|
+
/**
|
|
4782
|
+
* Check access using dual-mode resolution.
|
|
4783
|
+
*
|
|
4784
|
+
* Depending on the configured strategy, this will try JWT and/or UCAN
|
|
4785
|
+
* verification and return the result.
|
|
4786
|
+
*/
|
|
4787
|
+
checkAccess(request) {
|
|
4788
|
+
const hasCapability = !!request.capabilityToken && !!request.issuerPublicKey;
|
|
4789
|
+
const hasJwt = !!request.token;
|
|
4790
|
+
switch (this.strategy) {
|
|
4791
|
+
case "capability-only":
|
|
4792
|
+
if (!hasCapability) {
|
|
4793
|
+
return {
|
|
4794
|
+
allowed: false,
|
|
4795
|
+
reason: "Capability token required (strategy: capability-only)",
|
|
4796
|
+
mode: "capability",
|
|
4797
|
+
denial: this.buildDenialReceipt(request, "no-token", {
|
|
4798
|
+
suggestedFix: "Provide a UCAN capability token with issuerPublicKey"
|
|
4799
|
+
})
|
|
4800
|
+
};
|
|
4801
|
+
}
|
|
4802
|
+
return this.checkCapability(request);
|
|
4803
|
+
case "rbac-only":
|
|
4804
|
+
if (!hasJwt) {
|
|
4805
|
+
return {
|
|
4806
|
+
allowed: false,
|
|
4807
|
+
reason: "JWT token required (strategy: rbac-only)",
|
|
4808
|
+
mode: "rbac",
|
|
4809
|
+
denial: this.buildDenialReceipt(request, "no-token", {
|
|
4810
|
+
suggestedFix: "Provide a JWT RBAC token"
|
|
4811
|
+
})
|
|
4812
|
+
};
|
|
4813
|
+
}
|
|
4814
|
+
return this.checkRBAC(request);
|
|
4815
|
+
case "rbac-first":
|
|
4816
|
+
if (hasJwt) {
|
|
4817
|
+
const rbacResult = this.checkRBAC(request);
|
|
4818
|
+
if (rbacResult.allowed) return rbacResult;
|
|
4819
|
+
}
|
|
4820
|
+
if (hasCapability) {
|
|
4821
|
+
return this.checkCapability(request);
|
|
4822
|
+
}
|
|
4823
|
+
return {
|
|
4824
|
+
allowed: false,
|
|
4825
|
+
reason: "No valid token provided",
|
|
4826
|
+
mode: "rbac",
|
|
4827
|
+
denial: this.buildDenialReceipt(request, "no-token", {
|
|
4828
|
+
suggestedFix: "Provide a JWT token or UCAN capability token"
|
|
4829
|
+
})
|
|
4830
|
+
};
|
|
4831
|
+
case "capability-first":
|
|
4832
|
+
default:
|
|
4833
|
+
if (hasCapability) {
|
|
4834
|
+
const capResult = this.checkCapability(request);
|
|
4835
|
+
if (capResult.allowed) return capResult;
|
|
4836
|
+
}
|
|
4837
|
+
if (hasJwt) {
|
|
4838
|
+
return this.checkRBAC(request);
|
|
4839
|
+
}
|
|
4840
|
+
return {
|
|
4841
|
+
allowed: false,
|
|
4842
|
+
reason: "No valid token provided",
|
|
4843
|
+
mode: "capability",
|
|
4844
|
+
denial: this.buildDenialReceipt(request, "no-token", {
|
|
4845
|
+
suggestedFix: "Provide a UCAN capability token or JWT token"
|
|
4846
|
+
})
|
|
4847
|
+
};
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
// -----------------------------------------------------------------------
|
|
4851
|
+
// UCAN capability check
|
|
4852
|
+
// -----------------------------------------------------------------------
|
|
4853
|
+
/**
|
|
4854
|
+
* Verify access using a UCAN capability token.
|
|
4855
|
+
*/
|
|
4856
|
+
checkCapability(request) {
|
|
4857
|
+
const { capabilityToken, issuerPublicKey, resourceType, operation, resourcePath } = request;
|
|
4858
|
+
if (!capabilityToken || !issuerPublicKey) {
|
|
4859
|
+
return {
|
|
4860
|
+
allowed: false,
|
|
4861
|
+
reason: "Missing capability token or issuer public key",
|
|
4862
|
+
mode: "capability",
|
|
4863
|
+
denial: this.buildDenialReceipt(request, "capability", {
|
|
4864
|
+
suggestedFix: "Provide both capabilityToken and issuerPublicKey"
|
|
4865
|
+
})
|
|
4866
|
+
};
|
|
4867
|
+
}
|
|
4868
|
+
const verification = this.capabilityIssuer.verify(capabilityToken, issuerPublicKey);
|
|
4869
|
+
if (!verification.valid) {
|
|
4870
|
+
return {
|
|
4871
|
+
allowed: false,
|
|
4872
|
+
reason: `Capability token verification failed: ${verification.error}`,
|
|
4873
|
+
mode: "capability",
|
|
4874
|
+
capabilityVerification: verification,
|
|
4875
|
+
denial: this.buildDenialReceipt(request, "capability", {
|
|
4876
|
+
requiredCapability: "valid-signature",
|
|
4877
|
+
suggestedFix: `Re-issue capability token: ${verification.error}`
|
|
4878
|
+
})
|
|
4879
|
+
};
|
|
4880
|
+
}
|
|
4881
|
+
if (verification.chain && !verification.chain.verified) {
|
|
4882
|
+
return {
|
|
4883
|
+
allowed: false,
|
|
4884
|
+
reason: "Capability token chain verification failed (attenuation invariant violation)",
|
|
4885
|
+
mode: "capability",
|
|
4886
|
+
capabilityVerification: verification,
|
|
4887
|
+
errorCode: "ATTENUATION_VIOLATION",
|
|
4888
|
+
denial: this.buildDenialReceipt(request, "capability", {
|
|
4889
|
+
requiredCapability: "valid-attenuation-chain",
|
|
4890
|
+
suggestedFix: "Ensure delegated capabilities do not exceed parent scope"
|
|
4891
|
+
})
|
|
4892
|
+
};
|
|
4893
|
+
}
|
|
4894
|
+
const resourceUri = this.buildResourceUri(resourceType, resourcePath);
|
|
4895
|
+
const action = this.buildAction(resourceType, operation);
|
|
4896
|
+
const matchedCapability = capabilityToken.payload.att.find(
|
|
4897
|
+
(cap) => this.semantics.canAccess(cap, resourceUri, action)
|
|
4898
|
+
);
|
|
4899
|
+
if (!matchedCapability) {
|
|
4900
|
+
return {
|
|
4901
|
+
allowed: false,
|
|
4902
|
+
reason: `No capability grants access to resource "${resourceUri}" with action "${action}"`,
|
|
4903
|
+
mode: "capability",
|
|
4904
|
+
capabilityVerification: verification,
|
|
4905
|
+
denial: this.buildDenialReceipt(request, "capability", {
|
|
4906
|
+
requiredCapability: `${resourceUri}#${action}`,
|
|
4907
|
+
suggestedFix: `Add capability { with: "${resourceUri}", can: "${action}" } to token`
|
|
4908
|
+
})
|
|
4909
|
+
};
|
|
4910
|
+
}
|
|
4911
|
+
return {
|
|
4912
|
+
allowed: true,
|
|
4913
|
+
mode: "capability",
|
|
4914
|
+
matchedCapability,
|
|
4915
|
+
capabilityVerification: verification
|
|
4916
|
+
};
|
|
4917
|
+
}
|
|
4918
|
+
// -----------------------------------------------------------------------
|
|
4919
|
+
// Legacy JWT RBAC check (delegates to existing AgentRBAC)
|
|
4920
|
+
// -----------------------------------------------------------------------
|
|
4921
|
+
/**
|
|
4922
|
+
* Verify access using the legacy JWT RBAC system.
|
|
4923
|
+
*/
|
|
4924
|
+
checkRBAC(request) {
|
|
4925
|
+
const decision = this.rbac.checkAccess(request);
|
|
4926
|
+
const result = {
|
|
4927
|
+
...decision,
|
|
4928
|
+
mode: "rbac"
|
|
4929
|
+
};
|
|
4930
|
+
if (!decision.allowed) {
|
|
4931
|
+
result.denial = this.buildDenialReceipt(request, "rbac", {
|
|
4932
|
+
requiredCapability: `${request.resourceType}/${request.operation}`,
|
|
4933
|
+
suggestedFix: decision.reason ? `RBAC denied: ${decision.reason}` : "Ensure JWT token grants the required role/permission"
|
|
4934
|
+
});
|
|
4935
|
+
}
|
|
4936
|
+
return result;
|
|
4937
|
+
}
|
|
4938
|
+
// -----------------------------------------------------------------------
|
|
4939
|
+
// URI / action building
|
|
4940
|
+
// -----------------------------------------------------------------------
|
|
4941
|
+
/**
|
|
4942
|
+
* Build a UCAN resource URI from a ResourceType and optional path.
|
|
4943
|
+
*/
|
|
4944
|
+
buildResourceUri(resourceType, resourcePath) {
|
|
4945
|
+
const base = RESOURCE_TYPE_TO_URI[resourceType];
|
|
4946
|
+
if (resourcePath) {
|
|
4947
|
+
return `${base}/${resourcePath}`;
|
|
4948
|
+
}
|
|
4949
|
+
return base;
|
|
4950
|
+
}
|
|
4951
|
+
/**
|
|
4952
|
+
* Build a UCAN action string from a ResourceType and operation.
|
|
4953
|
+
*/
|
|
4954
|
+
buildAction(resourceType, operation) {
|
|
4955
|
+
const prefixMap = {
|
|
4956
|
+
["source_file" /* SOURCE_FILE */]: "source",
|
|
4957
|
+
["ast" /* AST */]: "ast",
|
|
4958
|
+
["ir" /* IR */]: "ir",
|
|
4959
|
+
["code" /* CODE */]: "code",
|
|
4960
|
+
["output" /* OUTPUT */]: "output",
|
|
4961
|
+
["config" /* CONFIG */]: "config"
|
|
4962
|
+
};
|
|
4963
|
+
const prefix = prefixMap[resourceType];
|
|
4964
|
+
const suffix = OPERATION_TO_ACTION_SUFFIX[operation] ?? operation;
|
|
4965
|
+
return `${prefix}/${suffix}`;
|
|
4966
|
+
}
|
|
4967
|
+
// -----------------------------------------------------------------------
|
|
4968
|
+
// Convenience methods (matching AgentRBAC API)
|
|
4969
|
+
// -----------------------------------------------------------------------
|
|
4970
|
+
/**
|
|
4971
|
+
* Check if agent can read source (dual-mode).
|
|
4972
|
+
*/
|
|
4973
|
+
canReadSource(tokenOrCapability, filePath) {
|
|
4974
|
+
if (typeof tokenOrCapability === "string") {
|
|
4975
|
+
return this.checkAccess({
|
|
4976
|
+
token: tokenOrCapability,
|
|
4977
|
+
resourceType: "source_file" /* SOURCE_FILE */,
|
|
4978
|
+
operation: "read",
|
|
4979
|
+
resourcePath: filePath
|
|
4980
|
+
});
|
|
4981
|
+
}
|
|
4982
|
+
return this.checkAccess({
|
|
4983
|
+
token: "",
|
|
4984
|
+
capabilityToken: tokenOrCapability.token,
|
|
4985
|
+
issuerPublicKey: tokenOrCapability.publicKey,
|
|
4986
|
+
resourceType: "source_file" /* SOURCE_FILE */,
|
|
4987
|
+
operation: "read",
|
|
4988
|
+
resourcePath: filePath
|
|
4989
|
+
});
|
|
4990
|
+
}
|
|
4991
|
+
/**
|
|
4992
|
+
* Check if agent can modify AST (dual-mode).
|
|
4993
|
+
*/
|
|
4994
|
+
canModifyAST(tokenOrCapability) {
|
|
4995
|
+
if (typeof tokenOrCapability === "string") {
|
|
4996
|
+
return this.checkAccess({
|
|
4997
|
+
token: tokenOrCapability,
|
|
4998
|
+
resourceType: "ast" /* AST */,
|
|
4999
|
+
operation: "write"
|
|
5000
|
+
});
|
|
5001
|
+
}
|
|
5002
|
+
return this.checkAccess({
|
|
5003
|
+
token: "",
|
|
5004
|
+
capabilityToken: tokenOrCapability.token,
|
|
5005
|
+
issuerPublicKey: tokenOrCapability.publicKey,
|
|
5006
|
+
resourceType: "ast" /* AST */,
|
|
5007
|
+
operation: "write"
|
|
5008
|
+
});
|
|
5009
|
+
}
|
|
5010
|
+
/**
|
|
5011
|
+
* Check if agent can generate code (dual-mode).
|
|
5012
|
+
*/
|
|
5013
|
+
canGenerateCode(tokenOrCapability) {
|
|
5014
|
+
if (typeof tokenOrCapability === "string") {
|
|
5015
|
+
return this.checkAccess({
|
|
5016
|
+
token: tokenOrCapability,
|
|
5017
|
+
resourceType: "code" /* CODE */,
|
|
5018
|
+
operation: "write"
|
|
5019
|
+
});
|
|
5020
|
+
}
|
|
5021
|
+
return this.checkAccess({
|
|
5022
|
+
token: "",
|
|
5023
|
+
capabilityToken: tokenOrCapability.token,
|
|
5024
|
+
issuerPublicKey: tokenOrCapability.publicKey,
|
|
5025
|
+
resourceType: "code" /* CODE */,
|
|
5026
|
+
operation: "write"
|
|
5027
|
+
});
|
|
5028
|
+
}
|
|
5029
|
+
/**
|
|
5030
|
+
* Check if agent can export output (dual-mode).
|
|
5031
|
+
*/
|
|
5032
|
+
canExport(tokenOrCapability, outputPath) {
|
|
5033
|
+
if (typeof tokenOrCapability === "string") {
|
|
5034
|
+
return this.checkAccess({
|
|
5035
|
+
token: tokenOrCapability,
|
|
5036
|
+
resourceType: "output" /* OUTPUT */,
|
|
5037
|
+
operation: "write",
|
|
5038
|
+
resourcePath: outputPath
|
|
5039
|
+
});
|
|
5040
|
+
}
|
|
5041
|
+
return this.checkAccess({
|
|
5042
|
+
token: "",
|
|
5043
|
+
capabilityToken: tokenOrCapability.token,
|
|
5044
|
+
issuerPublicKey: tokenOrCapability.publicKey,
|
|
5045
|
+
resourceType: "output" /* OUTPUT */,
|
|
5046
|
+
operation: "write",
|
|
5047
|
+
resourcePath: outputPath
|
|
5048
|
+
});
|
|
5049
|
+
}
|
|
5050
|
+
// -----------------------------------------------------------------------
|
|
5051
|
+
// Accessors
|
|
5052
|
+
// -----------------------------------------------------------------------
|
|
5053
|
+
/**
|
|
5054
|
+
* Get the underlying AgentRBAC instance.
|
|
5055
|
+
*/
|
|
5056
|
+
getRBAC() {
|
|
5057
|
+
return this.rbac;
|
|
5058
|
+
}
|
|
5059
|
+
/**
|
|
5060
|
+
* Get the CapabilityTokenIssuer instance.
|
|
5061
|
+
*/
|
|
5062
|
+
getCapabilityIssuer() {
|
|
5063
|
+
return this.capabilityIssuer;
|
|
5064
|
+
}
|
|
5065
|
+
/**
|
|
5066
|
+
* Get the current resolution strategy.
|
|
5067
|
+
*/
|
|
5068
|
+
getStrategy() {
|
|
5069
|
+
return this.strategy;
|
|
5070
|
+
}
|
|
5071
|
+
};
|
|
5072
|
+
globalCapabilityRBAC = null;
|
|
5073
|
+
}
|
|
5074
|
+
});
|
|
5075
|
+
|
|
5076
|
+
// src/compiler/identity/SpatialMemoryZones.ts
|
|
5077
|
+
function getSpatialZoneEnforcer(config) {
|
|
5078
|
+
if (!globalSpatialZoneEnforcer) {
|
|
5079
|
+
globalSpatialZoneEnforcer = new SpatialZoneEnforcer(config);
|
|
5080
|
+
}
|
|
5081
|
+
return globalSpatialZoneEnforcer;
|
|
5082
|
+
}
|
|
5083
|
+
var SpatialZoneEnforcer, globalSpatialZoneEnforcer;
|
|
5084
|
+
var init_SpatialMemoryZones = chunkHCCQLAA4_cjs.__esm({
|
|
5085
|
+
"src/compiler/identity/SpatialMemoryZones.ts"() {
|
|
5086
|
+
init_AgentTokenIssuer();
|
|
5087
|
+
SpatialZoneEnforcer = class {
|
|
5088
|
+
constructor(config = {}) {
|
|
5089
|
+
this.zones = /* @__PURE__ */ new Map();
|
|
5090
|
+
this.policies = /* @__PURE__ */ new Map();
|
|
5091
|
+
this.auditLog = [];
|
|
5092
|
+
this.tokenIssuer = config.tokenIssuer ?? getTokenIssuer();
|
|
5093
|
+
this.maxAuditEntries = config.maxAuditEntries ?? 1e4;
|
|
5094
|
+
}
|
|
5095
|
+
// -----------------------------------------------------------------------
|
|
5096
|
+
// Zone Management
|
|
5097
|
+
// -----------------------------------------------------------------------
|
|
5098
|
+
/**
|
|
5099
|
+
* Register a spatial zone.
|
|
5100
|
+
*/
|
|
5101
|
+
registerZone(zone) {
|
|
5102
|
+
this.zones.set(zone.id, zone);
|
|
5103
|
+
}
|
|
5104
|
+
/**
|
|
5105
|
+
* Get a registered zone by ID.
|
|
5106
|
+
*/
|
|
5107
|
+
getZone(zoneId) {
|
|
5108
|
+
return this.zones.get(zoneId);
|
|
5109
|
+
}
|
|
5110
|
+
/**
|
|
5111
|
+
* Remove a registered zone and its policy.
|
|
5112
|
+
*/
|
|
5113
|
+
removeZone(zoneId) {
|
|
5114
|
+
this.policies.delete(zoneId);
|
|
5115
|
+
return this.zones.delete(zoneId);
|
|
5116
|
+
}
|
|
5117
|
+
/**
|
|
5118
|
+
* Get all registered zone IDs.
|
|
5119
|
+
*/
|
|
5120
|
+
getRegisteredZoneIds() {
|
|
5121
|
+
return Array.from(this.zones.keys());
|
|
5122
|
+
}
|
|
5123
|
+
// -----------------------------------------------------------------------
|
|
5124
|
+
// Policy Management
|
|
5125
|
+
// -----------------------------------------------------------------------
|
|
5126
|
+
/**
|
|
5127
|
+
* Set the access policy for a zone.
|
|
5128
|
+
*/
|
|
5129
|
+
setPolicy(policy) {
|
|
5130
|
+
if (!this.zones.has(policy.zoneId)) {
|
|
5131
|
+
throw new Error(`Cannot set policy for unregistered zone: ${policy.zoneId}`);
|
|
5132
|
+
}
|
|
5133
|
+
this.policies.set(policy.zoneId, policy);
|
|
5134
|
+
}
|
|
5135
|
+
/**
|
|
5136
|
+
* Get the policy for a zone.
|
|
5137
|
+
*/
|
|
5138
|
+
getPolicy(zoneId) {
|
|
5139
|
+
return this.policies.get(zoneId);
|
|
5140
|
+
}
|
|
5141
|
+
// -----------------------------------------------------------------------
|
|
5142
|
+
// Access Checks
|
|
5143
|
+
// -----------------------------------------------------------------------
|
|
5144
|
+
/**
|
|
5145
|
+
* Check if an agent (identified by JWT token) can perform a spatial
|
|
5146
|
+
* operation in a given zone.
|
|
5147
|
+
*
|
|
5148
|
+
* @param agentToken JWT token issued by `AgentTokenIssuer`
|
|
5149
|
+
* @param zoneId Target zone identifier
|
|
5150
|
+
* @param operation The spatial permission required
|
|
5151
|
+
* @returns Access decision with reason
|
|
5152
|
+
*/
|
|
5153
|
+
checkZoneAccess(agentToken, zoneId, operation) {
|
|
5154
|
+
const verificationResult = this.tokenIssuer.verifyToken(agentToken);
|
|
5155
|
+
if (!verificationResult.valid || !verificationResult.payload) {
|
|
5156
|
+
const decision2 = {
|
|
5157
|
+
allowed: false,
|
|
5158
|
+
reason: `Token verification failed: ${verificationResult.error ?? "unknown error"}`
|
|
5159
|
+
};
|
|
5160
|
+
this.recordAudit("unknown", "unknown", zoneId, operation, false, decision2.reason);
|
|
5161
|
+
return decision2;
|
|
5162
|
+
}
|
|
5163
|
+
const payload = verificationResult.payload;
|
|
5164
|
+
const agentId = payload.sub;
|
|
5165
|
+
const agentRole = payload.agent_role;
|
|
5166
|
+
const zone = this.zones.get(zoneId);
|
|
5167
|
+
if (!zone) {
|
|
5168
|
+
const decision2 = {
|
|
5169
|
+
allowed: false,
|
|
5170
|
+
reason: `Zone not found: ${zoneId}`,
|
|
5171
|
+
agentRole,
|
|
5172
|
+
agentId
|
|
5173
|
+
};
|
|
5174
|
+
this.recordAudit(agentId, agentRole, zoneId, operation, false, decision2.reason);
|
|
5175
|
+
return decision2;
|
|
5176
|
+
}
|
|
5177
|
+
const grantedPermissions = this.resolvePermissions(agentId, agentRole, zoneId, zone);
|
|
5178
|
+
const allowed = grantedPermissions.includes(operation);
|
|
5179
|
+
const reason = allowed ? `Access granted: agent ${agentId} has ${operation} in zone ${zoneId}` : `Access denied: agent ${agentId} lacks ${operation} in zone ${zoneId}`;
|
|
5180
|
+
const decision = {
|
|
5181
|
+
allowed,
|
|
5182
|
+
reason,
|
|
5183
|
+
agentRole,
|
|
5184
|
+
agentId
|
|
5185
|
+
};
|
|
5186
|
+
this.recordAudit(agentId, agentRole, zoneId, operation, allowed, reason);
|
|
5187
|
+
return decision;
|
|
5188
|
+
}
|
|
5189
|
+
/**
|
|
5190
|
+
* Get all zone IDs that an agent can access (for at least one operation).
|
|
5191
|
+
*
|
|
5192
|
+
* @param agentToken JWT token
|
|
5193
|
+
* @returns Array of accessible zone IDs
|
|
5194
|
+
*/
|
|
5195
|
+
getAccessibleZones(agentToken) {
|
|
5196
|
+
const verificationResult = this.tokenIssuer.verifyToken(agentToken);
|
|
5197
|
+
if (!verificationResult.valid || !verificationResult.payload) {
|
|
5198
|
+
return [];
|
|
5199
|
+
}
|
|
5200
|
+
const payload = verificationResult.payload;
|
|
5201
|
+
const agentId = payload.sub;
|
|
5202
|
+
const agentRole = payload.agent_role;
|
|
5203
|
+
const accessibleZones = [];
|
|
5204
|
+
for (const [zoneId, zone] of this.zones) {
|
|
5205
|
+
const permissions = this.resolvePermissions(agentId, agentRole, zoneId, zone);
|
|
5206
|
+
if (permissions.length > 0) {
|
|
5207
|
+
accessibleZones.push(zoneId);
|
|
5208
|
+
}
|
|
5209
|
+
}
|
|
5210
|
+
return accessibleZones;
|
|
5211
|
+
}
|
|
5212
|
+
/**
|
|
5213
|
+
* Validate whether an agent can perform a spatial operation at a
|
|
5214
|
+
* specific 3D position. The position is checked against all registered
|
|
5215
|
+
* zones to find the enclosing zone(s), then permissions are evaluated.
|
|
5216
|
+
*
|
|
5217
|
+
* @param agentToken JWT token
|
|
5218
|
+
* @param position 3D position to check
|
|
5219
|
+
* @param operation Required spatial permission
|
|
5220
|
+
* @returns Access decision (aggregated across matching zones)
|
|
5221
|
+
*/
|
|
5222
|
+
validateSpatialOperation(agentToken, position, operation) {
|
|
5223
|
+
const verificationResult = this.tokenIssuer.verifyToken(agentToken);
|
|
5224
|
+
if (!verificationResult.valid || !verificationResult.payload) {
|
|
5225
|
+
const decision2 = {
|
|
5226
|
+
allowed: false,
|
|
5227
|
+
reason: `Token verification failed: ${verificationResult.error ?? "unknown error"}`
|
|
5228
|
+
};
|
|
5229
|
+
this.recordAudit("unknown", "unknown", "*position*", operation, false, decision2.reason);
|
|
5230
|
+
return decision2;
|
|
5231
|
+
}
|
|
5232
|
+
const payload = verificationResult.payload;
|
|
5233
|
+
const agentId = payload.sub;
|
|
5234
|
+
const agentRole = payload.agent_role;
|
|
5235
|
+
const containingZones = this.findZonesContainingPosition(position);
|
|
5236
|
+
if (containingZones.length === 0) {
|
|
5237
|
+
const decision2 = {
|
|
5238
|
+
allowed: false,
|
|
5239
|
+
reason: `No registered zone contains position (${position[0]}, ${position[1]}, ${position[2]})`,
|
|
5240
|
+
agentRole,
|
|
5241
|
+
agentId
|
|
5242
|
+
};
|
|
5243
|
+
this.recordAudit(agentId, agentRole, "*no-zone*", operation, false, decision2.reason);
|
|
5244
|
+
return decision2;
|
|
5245
|
+
}
|
|
5246
|
+
for (const zone of containingZones) {
|
|
5247
|
+
const permissions = this.resolvePermissions(agentId, agentRole, zone.id, zone);
|
|
5248
|
+
if (permissions.includes(operation)) {
|
|
5249
|
+
const decision2 = {
|
|
5250
|
+
allowed: true,
|
|
5251
|
+
reason: `Access granted via zone ${zone.id} at position (${position[0]}, ${position[1]}, ${position[2]})`,
|
|
5252
|
+
agentRole,
|
|
5253
|
+
agentId
|
|
5254
|
+
};
|
|
5255
|
+
this.recordAudit(agentId, agentRole, zone.id, operation, true, decision2.reason);
|
|
5256
|
+
return decision2;
|
|
5257
|
+
}
|
|
5258
|
+
}
|
|
5259
|
+
const zoneIds = containingZones.map((z2) => z2.id).join(", ");
|
|
5260
|
+
const decision = {
|
|
5261
|
+
allowed: false,
|
|
5262
|
+
reason: `Access denied in all containing zones [${zoneIds}] at position (${position[0]}, ${position[1]}, ${position[2]})`,
|
|
5263
|
+
agentRole,
|
|
5264
|
+
agentId
|
|
5265
|
+
};
|
|
5266
|
+
this.recordAudit(agentId, agentRole, containingZones[0].id, operation, false, decision.reason);
|
|
5267
|
+
return decision;
|
|
5268
|
+
}
|
|
5269
|
+
// -----------------------------------------------------------------------
|
|
5270
|
+
// Audit Trail
|
|
5271
|
+
// -----------------------------------------------------------------------
|
|
5272
|
+
/**
|
|
5273
|
+
* Get the full GDPR audit trail.
|
|
5274
|
+
*/
|
|
5275
|
+
getAuditLog() {
|
|
5276
|
+
return this.auditLog;
|
|
5277
|
+
}
|
|
5278
|
+
/**
|
|
5279
|
+
* Get audit entries for a specific agent (GDPR data subject access).
|
|
5280
|
+
*/
|
|
5281
|
+
getAuditEntriesForAgent(agentId) {
|
|
5282
|
+
return this.auditLog.filter((entry) => entry.agentId === agentId);
|
|
5283
|
+
}
|
|
5284
|
+
/**
|
|
5285
|
+
* Get audit entries for a specific zone.
|
|
5286
|
+
*/
|
|
5287
|
+
getAuditEntriesForZone(zoneId) {
|
|
5288
|
+
return this.auditLog.filter((entry) => entry.zoneId === zoneId);
|
|
5289
|
+
}
|
|
5290
|
+
/**
|
|
5291
|
+
* Clear audit entries for a specific agent (GDPR right-to-erasure).
|
|
5292
|
+
*
|
|
5293
|
+
* @returns Number of entries removed
|
|
5294
|
+
*/
|
|
5295
|
+
eraseAuditEntriesForAgent(agentId) {
|
|
5296
|
+
const before = this.auditLog.length;
|
|
5297
|
+
this.auditLog = this.auditLog.filter((entry) => entry.agentId !== agentId);
|
|
5298
|
+
return before - this.auditLog.length;
|
|
5299
|
+
}
|
|
5300
|
+
/**
|
|
5301
|
+
* Clear all audit entries.
|
|
5302
|
+
*/
|
|
5303
|
+
clearAuditLog() {
|
|
5304
|
+
this.auditLog = [];
|
|
5305
|
+
}
|
|
5306
|
+
// -----------------------------------------------------------------------
|
|
5307
|
+
// Internal Helpers
|
|
5308
|
+
// -----------------------------------------------------------------------
|
|
5309
|
+
/**
|
|
5310
|
+
* Resolve the effective spatial permissions for an agent in a zone.
|
|
5311
|
+
*
|
|
5312
|
+
* Resolution order:
|
|
5313
|
+
* 1. Agent-specific overrides (highest priority)
|
|
5314
|
+
* 2. Role-based permissions from policy
|
|
5315
|
+
* 3. Policy default permissions
|
|
5316
|
+
* 4. Classification-based fallback (if no policy exists)
|
|
5317
|
+
*/
|
|
5318
|
+
resolvePermissions(agentId, agentRole, zoneId, zone) {
|
|
5319
|
+
const policy = this.policies.get(zoneId);
|
|
5320
|
+
if (policy) {
|
|
5321
|
+
if (policy.agentOverrides[agentId]) {
|
|
5322
|
+
return policy.agentOverrides[agentId];
|
|
5323
|
+
}
|
|
5324
|
+
if (policy.rolePermissions[agentRole]) {
|
|
5325
|
+
return policy.rolePermissions[agentRole];
|
|
5326
|
+
}
|
|
5327
|
+
return policy.defaultPermissions;
|
|
5328
|
+
}
|
|
5329
|
+
return this.getClassificationDefaults(zone.classification);
|
|
5330
|
+
}
|
|
5331
|
+
/**
|
|
5332
|
+
* Get default permissions based on zone classification.
|
|
5333
|
+
*/
|
|
5334
|
+
getClassificationDefaults(classification) {
|
|
5335
|
+
switch (classification) {
|
|
5336
|
+
case "public":
|
|
5337
|
+
return ["spatial:read" /* SPATIAL_READ */];
|
|
5338
|
+
case "restricted":
|
|
5339
|
+
return ["spatial:read" /* SPATIAL_READ */];
|
|
5340
|
+
case "private":
|
|
5341
|
+
return [];
|
|
5342
|
+
case "sensitive":
|
|
5343
|
+
return [];
|
|
5344
|
+
default:
|
|
5345
|
+
return [];
|
|
5346
|
+
}
|
|
5347
|
+
}
|
|
5348
|
+
/**
|
|
5349
|
+
* Find all zones whose bounds contain the given position.
|
|
5350
|
+
*
|
|
5351
|
+
* Named zones (no explicit bounds) are NOT included in positional
|
|
5352
|
+
* lookups because their bounds are resolved at runtime.
|
|
5353
|
+
*/
|
|
5354
|
+
findZonesContainingPosition(position) {
|
|
5355
|
+
const result = [];
|
|
5356
|
+
for (const zone of this.zones.values()) {
|
|
5357
|
+
if (!zone.bounds) continue;
|
|
5358
|
+
if (this.isPositionInBounds(position, zone.bounds)) {
|
|
5359
|
+
result.push(zone);
|
|
5360
|
+
}
|
|
5361
|
+
}
|
|
5362
|
+
return result;
|
|
5363
|
+
}
|
|
5364
|
+
/**
|
|
5365
|
+
* Check if a 3D position is within the given bounds.
|
|
5366
|
+
*
|
|
5367
|
+
* For geospatial bounds: x=lat, y=lon, z=alt
|
|
5368
|
+
* For local bounds: x=X, y=Y, z=Z
|
|
5369
|
+
* Named bounds always return false (resolved at runtime).
|
|
5370
|
+
*/
|
|
5371
|
+
isPositionInBounds(position, bounds) {
|
|
5372
|
+
switch (bounds.type) {
|
|
5373
|
+
case "geospatial": {
|
|
5374
|
+
const inLat = position[0] >= bounds.minLat && position[0] <= bounds.maxLat;
|
|
5375
|
+
const inLon = position[1] >= bounds.minLon && position[1] <= bounds.maxLon;
|
|
5376
|
+
let inAlt = true;
|
|
5377
|
+
if (bounds.minAlt !== void 0 && bounds.maxAlt !== void 0) {
|
|
5378
|
+
inAlt = position[2] >= bounds.minAlt && position[2] <= bounds.maxAlt;
|
|
5379
|
+
}
|
|
5380
|
+
return inLat && inLon && inAlt;
|
|
5381
|
+
}
|
|
5382
|
+
case "local": {
|
|
5383
|
+
return position[0] >= bounds.minX && position[0] <= bounds.maxX && position[1] >= bounds.minY && position[1] <= bounds.maxY && position[2] >= bounds.minZ && position[2] <= bounds.maxZ;
|
|
5384
|
+
}
|
|
5385
|
+
case "named":
|
|
5386
|
+
return false;
|
|
5387
|
+
default:
|
|
5388
|
+
return false;
|
|
5389
|
+
}
|
|
5390
|
+
}
|
|
5391
|
+
/**
|
|
5392
|
+
* Record a GDPR audit entry.
|
|
5393
|
+
*/
|
|
5394
|
+
recordAudit(agentId, agentRole, zoneId, operation, allowed, reason) {
|
|
5395
|
+
const entry = {
|
|
5396
|
+
timestamp: Date.now(),
|
|
5397
|
+
agentId,
|
|
5398
|
+
agentRole,
|
|
5399
|
+
zoneId,
|
|
5400
|
+
operation,
|
|
5401
|
+
allowed,
|
|
5402
|
+
reason
|
|
5403
|
+
};
|
|
5404
|
+
this.auditLog.push(entry);
|
|
5405
|
+
if (this.auditLog.length > this.maxAuditEntries) {
|
|
5406
|
+
this.auditLog = this.auditLog.slice(-this.maxAuditEntries);
|
|
5407
|
+
}
|
|
5408
|
+
}
|
|
5409
|
+
};
|
|
5410
|
+
globalSpatialZoneEnforcer = null;
|
|
5411
|
+
}
|
|
5412
|
+
});
|
|
5413
|
+
function isCapabilityTokenCredential(token) {
|
|
5414
|
+
if (!token || typeof token === "string") return false;
|
|
5415
|
+
return typeof token === "object" && "capabilityToken" in token && "issuerPublicKey" in token && token.capabilityToken != null && typeof token.issuerPublicKey === "string";
|
|
5416
|
+
}
|
|
5417
|
+
function escapeCStyle(value) {
|
|
5418
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\0/g, "\\0");
|
|
5419
|
+
}
|
|
5420
|
+
function escapeGDScript(value) {
|
|
5421
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\t/g, "\\t").replace(/\0/g, "");
|
|
5422
|
+
}
|
|
5423
|
+
function escapeJSX(value) {
|
|
5424
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/\{/g, "{").replace(/\}/g, "}");
|
|
5425
|
+
}
|
|
5426
|
+
function escapeXML(value) {
|
|
5427
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5428
|
+
}
|
|
5429
|
+
function escapeShader(value) {
|
|
5430
|
+
return value.replace(/\\/g, "").replace(/\*/g, "").replace(/\//g, "").replace(/#/g, "").replace(/\n/g, " ").replace(/\r/g, "");
|
|
5431
|
+
}
|
|
5432
|
+
function escapePython(value) {
|
|
5433
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\0/g, "\\x00");
|
|
5434
|
+
}
|
|
5435
|
+
function escapeLua(value) {
|
|
5436
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\0/g, "\\0");
|
|
5437
|
+
}
|
|
5438
|
+
function escapeUSD(value) {
|
|
5439
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
5440
|
+
}
|
|
5441
|
+
function escapeJSON(value) {
|
|
5442
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/[\x00-\x1f]/g, (ch) => "\\u" + ch.charCodeAt(0).toString(16).padStart(4, "0"));
|
|
5443
|
+
}
|
|
5444
|
+
function escapeStringValue(value, target) {
|
|
5445
|
+
if (!value) return value;
|
|
5446
|
+
switch (target) {
|
|
5447
|
+
case "Solidity":
|
|
5448
|
+
case "CSharp":
|
|
5449
|
+
case "Swift":
|
|
5450
|
+
case "Kotlin":
|
|
5451
|
+
case "TypeScript":
|
|
5452
|
+
case "Rust":
|
|
5453
|
+
return escapeCStyle(value);
|
|
5454
|
+
case "GDScript":
|
|
5455
|
+
return escapeGDScript(value);
|
|
5456
|
+
case "JSX":
|
|
5457
|
+
return escapeJSX(value);
|
|
5458
|
+
case "XML":
|
|
5459
|
+
return escapeXML(value);
|
|
5460
|
+
case "GLSL":
|
|
5461
|
+
case "HLSL":
|
|
5462
|
+
case "WGSL":
|
|
5463
|
+
return escapeShader(value);
|
|
5464
|
+
case "Python":
|
|
5465
|
+
return escapePython(value);
|
|
5466
|
+
case "Lua":
|
|
5467
|
+
return escapeLua(value);
|
|
5468
|
+
case "USD":
|
|
5469
|
+
return escapeUSD(value);
|
|
5470
|
+
case "JSON":
|
|
5471
|
+
return escapeJSON(value);
|
|
5472
|
+
default:
|
|
5473
|
+
return value;
|
|
5474
|
+
}
|
|
5475
|
+
}
|
|
5476
|
+
function createTestCompilerToken() {
|
|
5477
|
+
return "";
|
|
5478
|
+
}
|
|
5479
|
+
var COMPILER_CLASS_TO_ANS_NAME; exports.UnauthorizedCompilerAccessError = void 0; exports.CompilerBase = void 0;
|
|
5480
|
+
var init_CompilerBase = chunkHCCQLAA4_cjs.__esm({
|
|
5481
|
+
"src/compiler/CompilerBase.ts"() {
|
|
5482
|
+
init_AgentRBAC();
|
|
5483
|
+
init_CapabilityRBAC();
|
|
5484
|
+
init_ANSNamespace();
|
|
5485
|
+
init_SpatialMemoryZones();
|
|
5486
|
+
init_CompilerDocumentationGenerator();
|
|
5487
|
+
COMPILER_CLASS_TO_ANS_NAME = {
|
|
5488
|
+
UnityCompiler: "unity",
|
|
5489
|
+
UnrealCompiler: "unreal",
|
|
5490
|
+
GodotCompiler: "godot",
|
|
5491
|
+
VRChatCompiler: "vrchat",
|
|
5492
|
+
OpenXRCompiler: "openxr",
|
|
5493
|
+
OpenXRSpatialEntitiesCompiler: "openxr-spatial-entities",
|
|
5494
|
+
VisionOSCompiler: "visionos",
|
|
5495
|
+
ARCompiler: "ar",
|
|
5496
|
+
AndroidXRCompiler: "android-xr",
|
|
5497
|
+
AIGlassesCompiler: "ai-glasses",
|
|
5498
|
+
AndroidCompiler: "android",
|
|
5499
|
+
IOSCompiler: "ios",
|
|
5500
|
+
BabylonCompiler: "babylon",
|
|
5501
|
+
WebGPUCompiler: "webgpu",
|
|
5502
|
+
R3FCompiler: "r3f",
|
|
5503
|
+
PlayCanvasCompiler: "playcanvas",
|
|
5504
|
+
ThreeJSCompiler: "threejs",
|
|
5505
|
+
WASMCompiler: "wasm",
|
|
5506
|
+
TSLCompiler: "tsl",
|
|
5507
|
+
URDFCompiler: "urdf",
|
|
5508
|
+
SDFCompiler: "sdf",
|
|
5509
|
+
USDPhysicsCompiler: "usd",
|
|
5510
|
+
GLTFPipeline: "gltf",
|
|
5511
|
+
GaussianSplattingCompiler: "3dgs",
|
|
5512
|
+
DTDLCompiler: "dtdl",
|
|
5513
|
+
NFTMarketplaceCompiler: "nft-marketplace",
|
|
5514
|
+
SCMCompiler: "scm",
|
|
5515
|
+
VRRCompiler: "vrr",
|
|
5516
|
+
A2AAgentCardCompiler: "a2a-agent-card",
|
|
5517
|
+
MultiLayerCompiler: "multi-layer",
|
|
5518
|
+
IncrementalCompiler: "incremental",
|
|
5519
|
+
StateCompiler: "state",
|
|
5520
|
+
TraitCompositionCompiler: "trait-composition",
|
|
5521
|
+
DomainBlockCompilerMixin: "domain-block",
|
|
5522
|
+
NIRCompiler: "nir",
|
|
5523
|
+
URDFToUSDZConverter: "urdf",
|
|
5524
|
+
QuiltCompiler: "quilt",
|
|
5525
|
+
MVHEVCCompiler: "mv-hevc",
|
|
5526
|
+
NodeServiceCompiler: "node-service",
|
|
5527
|
+
NextJSAPICompiler: "nextjs-api",
|
|
5528
|
+
MCPConfigCompiler: "domain-block",
|
|
5529
|
+
AgentInferenceCompiler: "agent-inference"
|
|
5530
|
+
};
|
|
5531
|
+
exports.UnauthorizedCompilerAccessError = class extends Error {
|
|
5532
|
+
constructor(decision, operation, compilerName) {
|
|
5533
|
+
super(
|
|
5534
|
+
`[${compilerName}] Unauthorized ${operation}: ${decision.reason || "Access denied"}
|
|
5535
|
+
Required Permission: ${decision.requiredPermission || "unknown"}`
|
|
5536
|
+
);
|
|
5537
|
+
this.decision = decision;
|
|
5538
|
+
this.operation = operation;
|
|
5539
|
+
this.compilerName = compilerName;
|
|
5540
|
+
this.name = "UnauthorizedCompilerAccessError";
|
|
5541
|
+
}
|
|
5542
|
+
};
|
|
5543
|
+
exports.CompilerBase = class {
|
|
5544
|
+
constructor() {
|
|
5545
|
+
this.rbac = getRBAC();
|
|
5546
|
+
/**
|
|
5547
|
+
* Lazy-initialized CapabilityRBAC adapter for UCAN token verification.
|
|
5548
|
+
* Only created when a UCAN capability token is first encountered.
|
|
5549
|
+
*/
|
|
5550
|
+
this._capabilityRBAC = null;
|
|
5551
|
+
/**
|
|
5552
|
+
* Lazy-initialized SpatialZoneEnforcer for compile-time spatial zone checks.
|
|
5553
|
+
* Only created when spatial zone validation is first invoked.
|
|
5554
|
+
*/
|
|
5555
|
+
this._spatialZoneEnforcer = null;
|
|
5556
|
+
/**
|
|
5557
|
+
* Lazy-initialized documentation generator for triple-output compilation.
|
|
5558
|
+
* Only created when generateDocs option is enabled.
|
|
5559
|
+
*/
|
|
5560
|
+
this._documentationGenerator = null;
|
|
5561
|
+
}
|
|
5562
|
+
/**
|
|
5563
|
+
* Sanitizes a string value for injection into a specific compiler target language.
|
|
5564
|
+
* Mitigates Cross-Agent Compilation Injection attacks (e.g. CWE-94).
|
|
5565
|
+
*
|
|
5566
|
+
* @param value The raw string value from the AST
|
|
5567
|
+
* @param target The compilation target language
|
|
5568
|
+
* @returns The escaped/sanitized string safe for interpolation
|
|
5569
|
+
*/
|
|
5570
|
+
escapeStringValue(value, target) {
|
|
5571
|
+
return escapeStringValue(value, target);
|
|
5572
|
+
}
|
|
5573
|
+
// =========================================================================
|
|
5574
|
+
// P3 Migration Bridge: Dual-mode token support
|
|
5575
|
+
// =========================================================================
|
|
5576
|
+
/**
|
|
5577
|
+
* Get or create the CapabilityRBAC adapter instance.
|
|
5578
|
+
*
|
|
5579
|
+
* Lazily initialized to avoid overhead when only JWT tokens are used.
|
|
5580
|
+
*/
|
|
5581
|
+
getCapabilityRBAC() {
|
|
5582
|
+
if (!this._capabilityRBAC) {
|
|
5583
|
+
this._capabilityRBAC = getCapabilityRBAC();
|
|
5584
|
+
}
|
|
5585
|
+
return this._capabilityRBAC;
|
|
5586
|
+
}
|
|
5587
|
+
/**
|
|
5588
|
+
* Get or create the SpatialZoneEnforcer instance.
|
|
5589
|
+
*
|
|
5590
|
+
* Lazily initialized to avoid overhead when spatial zones are not in use.
|
|
5591
|
+
*/
|
|
5592
|
+
getSpatialZoneEnforcer() {
|
|
5593
|
+
if (!this._spatialZoneEnforcer) {
|
|
5594
|
+
this._spatialZoneEnforcer = getSpatialZoneEnforcer();
|
|
5595
|
+
}
|
|
5596
|
+
return this._spatialZoneEnforcer;
|
|
5597
|
+
}
|
|
5598
|
+
/**
|
|
5599
|
+
* Get or create the CompilerDocumentationGenerator instance.
|
|
5600
|
+
*
|
|
5601
|
+
* Lazily initialized to avoid overhead when documentation generation is disabled.
|
|
5602
|
+
*
|
|
5603
|
+
* @param options - Documentation generator options
|
|
5604
|
+
*/
|
|
5605
|
+
getDocumentationGenerator(options) {
|
|
5606
|
+
if (!this._documentationGenerator) {
|
|
5607
|
+
this._documentationGenerator = new exports.CompilerDocumentationGenerator(options);
|
|
5608
|
+
}
|
|
5609
|
+
return this._documentationGenerator;
|
|
5610
|
+
}
|
|
5611
|
+
/**
|
|
5612
|
+
* Generate triple-output documentation for a compilation result.
|
|
5613
|
+
*
|
|
5614
|
+
* This is a utility method that subclasses can call after successful compilation
|
|
5615
|
+
* to generate llms.txt, .well-known/mcp, and markdown documentation.
|
|
5616
|
+
*
|
|
5617
|
+
* @param composition - Parsed HoloScript composition AST
|
|
5618
|
+
* @param compiledCode - The compiled output code
|
|
5619
|
+
* @param options - Documentation generator options
|
|
5620
|
+
* @returns Triple-output documentation bundle
|
|
5621
|
+
*
|
|
5622
|
+
* @example
|
|
5623
|
+
* ```typescript
|
|
5624
|
+
* compile(composition: HoloComposition, agentToken: string, options?: MyCompilerOptions): CompilationResult {
|
|
5625
|
+
* this.validateCompilerAccess(agentToken);
|
|
5626
|
+
* const code = this.performCompilation(composition);
|
|
5627
|
+
*
|
|
5628
|
+
* if (options?.generateDocs) {
|
|
5629
|
+
* const docs = this.generateDocumentation(composition, code, options.docsOptions);
|
|
5630
|
+
* return { output: code, documentation: docs };
|
|
5631
|
+
* }
|
|
5632
|
+
*
|
|
5633
|
+
* return { output: code };
|
|
5634
|
+
* }
|
|
5635
|
+
* ```
|
|
5636
|
+
*/
|
|
5637
|
+
generateDocumentation(composition, compiledCode, options, generationMeta) {
|
|
5638
|
+
const generator = this.getDocumentationGenerator(options);
|
|
5639
|
+
return generator.generate(composition, this.compilerName, compiledCode, generationMeta);
|
|
5640
|
+
}
|
|
5641
|
+
/**
|
|
5642
|
+
* Normalize primary compiler output for llms.txt / markdown (avoid huge/binary payloads).
|
|
5643
|
+
*/
|
|
5644
|
+
serializeOutputForDocumentation(output) {
|
|
5645
|
+
if (typeof output === "string") {
|
|
5646
|
+
return output.length > 2e5 ? output.slice(0, 2e5) : output;
|
|
5647
|
+
}
|
|
5648
|
+
if (output && typeof output === "object") {
|
|
5649
|
+
const rec = output;
|
|
5650
|
+
if ("gltf" in rec || "buffers" in rec) {
|
|
5651
|
+
return {
|
|
5652
|
+
_kind: "binary_or_gltf_bundle",
|
|
5653
|
+
keys: Object.keys(rec).join(",")
|
|
5654
|
+
};
|
|
5655
|
+
}
|
|
5656
|
+
const vals = Object.values(rec);
|
|
5657
|
+
if (vals.length > 0 && vals.every((v) => typeof v === "string")) {
|
|
5658
|
+
return rec;
|
|
5659
|
+
}
|
|
5660
|
+
try {
|
|
5661
|
+
const json = JSON.stringify(output);
|
|
5662
|
+
return json.length > 2e5 ? json.slice(0, 2e5) : json;
|
|
5663
|
+
} catch {
|
|
5664
|
+
return { _kind: "non_serializable", keys: Object.keys(rec).join(",") };
|
|
5665
|
+
}
|
|
5666
|
+
}
|
|
5667
|
+
return String(output);
|
|
5668
|
+
}
|
|
5669
|
+
/** Short digest for MCP card `_meta.holoscript.compilation_digest`. */
|
|
5670
|
+
digestForDocumentation(docPayload) {
|
|
5671
|
+
const payload = typeof docPayload === "string" ? docPayload : JSON.stringify(docPayload);
|
|
5672
|
+
return crypto3.createHash("sha256").update(payload).digest("hex").slice(0, 16);
|
|
5673
|
+
}
|
|
5674
|
+
/**
|
|
5675
|
+
* When `generateDocs` is set on {@link BaseCompilerOptions}, returns a {@link CompilationResult}
|
|
5676
|
+
* with `documentation` (llms.txt, .well-known/mcp, markdown); otherwise returns `output` unchanged.
|
|
5677
|
+
*/
|
|
5678
|
+
withTripleOutputIfRequested(composition, output, opts) {
|
|
5679
|
+
if (!opts?.generateDocs) {
|
|
5680
|
+
return output;
|
|
5681
|
+
}
|
|
5682
|
+
const docPayload = this.serializeOutputForDocumentation(output);
|
|
5683
|
+
const generationMeta = {
|
|
5684
|
+
compilationDigest: this.digestForDocumentation(docPayload)
|
|
5685
|
+
};
|
|
5686
|
+
const documentation = this.generateDocumentation(
|
|
5687
|
+
composition,
|
|
5688
|
+
docPayload,
|
|
5689
|
+
opts.docsOptions,
|
|
5690
|
+
generationMeta
|
|
5691
|
+
);
|
|
5692
|
+
return { output, documentation };
|
|
5693
|
+
}
|
|
5694
|
+
/**
|
|
5695
|
+
* Get the ANS capability namespace path for this compiler.
|
|
5696
|
+
*
|
|
5697
|
+
* Subclasses MAY override this to specify their exact ANS namespace.
|
|
5698
|
+
* The default implementation derives it from `compilerName` using the
|
|
5699
|
+
* `COMPILER_CLASS_TO_ANS_NAME` lookup table.
|
|
5700
|
+
*
|
|
5701
|
+
* @returns The ANS capability path (e.g., "/compile/web3d/r3f"), or
|
|
5702
|
+
* `undefined` if the compiler has no registered ANS namespace.
|
|
5703
|
+
*
|
|
5704
|
+
* @example
|
|
5705
|
+
* ```typescript
|
|
5706
|
+
* // Default: derives from compilerName
|
|
5707
|
+
* class R3FCompiler extends CompilerBase {
|
|
5708
|
+
* protected readonly compilerName = 'R3FCompiler';
|
|
5709
|
+
* // getRequiredCapability() returns '/compile/web3d/r3f' automatically
|
|
5710
|
+
* }
|
|
5711
|
+
*
|
|
5712
|
+
* // Override: explicit namespace
|
|
5713
|
+
* class CustomCompiler extends CompilerBase {
|
|
5714
|
+
* protected readonly compilerName = 'CustomCompiler';
|
|
5715
|
+
* protected getRequiredCapability(): string | undefined {
|
|
5716
|
+
* return '/compile/web3d/r3f';
|
|
5717
|
+
* }
|
|
5718
|
+
* }
|
|
5719
|
+
* ```
|
|
5720
|
+
*/
|
|
5721
|
+
getRequiredCapability() {
|
|
5722
|
+
const ansName = COMPILER_CLASS_TO_ANS_NAME[this.compilerName];
|
|
5723
|
+
if (ansName && isValidCompilerName(ansName)) {
|
|
5724
|
+
return COMPILER_ANS_MAP[ansName];
|
|
5725
|
+
}
|
|
5726
|
+
if (process.env["NODE_ENV"] !== "test") {
|
|
5727
|
+
console.warn(
|
|
5728
|
+
`[CompilerBase] Compiler '${this.compilerName}' has no ANS namespace entry. Add it to COMPILER_CLASS_TO_ANS_NAME to enable UCAN capability enforcement.`
|
|
5729
|
+
);
|
|
5730
|
+
}
|
|
5731
|
+
return void 0;
|
|
5732
|
+
}
|
|
5733
|
+
// =========================================================================
|
|
5734
|
+
// Legacy JWT RBAC validation (unchanged from v1.0.0)
|
|
5735
|
+
// =========================================================================
|
|
5736
|
+
/**
|
|
5737
|
+
* Validate agent can read AST
|
|
5738
|
+
* Skips validation when no token is provided.
|
|
5739
|
+
* In production (`NODE_ENV=production`) a warning is emitted when no token is
|
|
5740
|
+
* supplied — callers should always authenticate compiler access in production.
|
|
5741
|
+
*
|
|
5742
|
+
* @param agentToken - Agent JWT token (optional)
|
|
5743
|
+
* @throws UnauthorizedCompilerAccessError if token is provided but invalid
|
|
5744
|
+
*/
|
|
5745
|
+
validateASTAccess(agentToken) {
|
|
5746
|
+
if (!agentToken) {
|
|
5747
|
+
if (process.env["NODE_ENV"] === "production") {
|
|
5748
|
+
console.warn(
|
|
5749
|
+
`[${this.compilerName}] validateASTAccess called without a token in production. All compiler calls should be authenticated. Pass an agent token to enforce RBAC.`
|
|
5750
|
+
);
|
|
5751
|
+
}
|
|
5752
|
+
return;
|
|
5753
|
+
}
|
|
5754
|
+
const decision = this.rbac.checkAccess({
|
|
5755
|
+
token: agentToken,
|
|
5756
|
+
resourceType: "ast" /* AST */,
|
|
5757
|
+
operation: "read",
|
|
5758
|
+
expectedWorkflowStep: "generate_assembly" /* GENERATE_ASSEMBLY */
|
|
5759
|
+
});
|
|
5760
|
+
if (!decision.allowed) {
|
|
5761
|
+
throw new exports.UnauthorizedCompilerAccessError(decision, "AST access", this.compilerName);
|
|
5762
|
+
}
|
|
5763
|
+
}
|
|
5764
|
+
/**
|
|
5765
|
+
* Validate agent can generate code
|
|
5766
|
+
* Skips validation when no token is provided.
|
|
5767
|
+
* In production (`NODE_ENV=production`) a warning is emitted when no token is
|
|
5768
|
+
* supplied — callers should always authenticate compiler access in production.
|
|
5769
|
+
*
|
|
5770
|
+
* @param agentToken - Agent JWT token (optional)
|
|
5771
|
+
* @throws UnauthorizedCompilerAccessError if token is provided but invalid
|
|
5772
|
+
*/
|
|
5773
|
+
validateCodeGeneration(agentToken) {
|
|
5774
|
+
if (!agentToken) {
|
|
5775
|
+
if (process.env["NODE_ENV"] === "production") {
|
|
5776
|
+
console.warn(
|
|
5777
|
+
`[${this.compilerName}] validateCodeGeneration called without a token in production. All compiler calls should be authenticated. Pass an agent token to enforce RBAC.`
|
|
5778
|
+
);
|
|
5779
|
+
}
|
|
5780
|
+
return;
|
|
5781
|
+
}
|
|
5782
|
+
const decision = this.rbac.checkAccess({
|
|
5783
|
+
token: agentToken,
|
|
5784
|
+
resourceType: "code" /* CODE */,
|
|
5785
|
+
operation: "write",
|
|
5786
|
+
expectedWorkflowStep: "generate_assembly" /* GENERATE_ASSEMBLY */
|
|
5787
|
+
});
|
|
5788
|
+
if (!decision.allowed) {
|
|
5789
|
+
throw new exports.UnauthorizedCompilerAccessError(decision, "code generation", this.compilerName);
|
|
5790
|
+
}
|
|
5791
|
+
}
|
|
5792
|
+
/**
|
|
5793
|
+
* Validate agent can write to output path
|
|
5794
|
+
* Skips validation when no token is provided.
|
|
5795
|
+
* In production (`NODE_ENV=production`) a warning is emitted when no token is
|
|
5796
|
+
* supplied — callers should always authenticate compiler access in production.
|
|
5797
|
+
*
|
|
5798
|
+
* @param agentToken - Agent JWT token (optional)
|
|
5799
|
+
* @param outputPath - Target output file path
|
|
5800
|
+
* @throws UnauthorizedCompilerAccessError if token is provided but invalid
|
|
5801
|
+
*/
|
|
5802
|
+
validateOutputPath(agentToken, outputPath) {
|
|
5803
|
+
if (!agentToken) {
|
|
5804
|
+
if (process.env["NODE_ENV"] === "production") {
|
|
5805
|
+
console.warn(
|
|
5806
|
+
`[${this.compilerName}] validateOutputPath called without a token in production. All compiler calls should be authenticated. Pass an agent token to enforce RBAC.`
|
|
5807
|
+
);
|
|
5808
|
+
}
|
|
5809
|
+
return;
|
|
5810
|
+
}
|
|
5811
|
+
const decision = this.rbac.checkAccess({
|
|
5812
|
+
token: agentToken,
|
|
5813
|
+
resourceType: "output" /* OUTPUT */,
|
|
5814
|
+
operation: "write",
|
|
5815
|
+
resourcePath: outputPath,
|
|
5816
|
+
expectedWorkflowStep: "serialize" /* SERIALIZE */
|
|
5817
|
+
});
|
|
5818
|
+
if (!decision.allowed) {
|
|
5819
|
+
throw new exports.UnauthorizedCompilerAccessError(
|
|
5820
|
+
decision,
|
|
5821
|
+
`output write to '${outputPath}'`,
|
|
5822
|
+
this.compilerName
|
|
5823
|
+
);
|
|
5824
|
+
}
|
|
5825
|
+
}
|
|
5826
|
+
// =========================================================================
|
|
5827
|
+
// UCAN Capability Token validation (P3 Migration Bridge)
|
|
5828
|
+
// =========================================================================
|
|
5829
|
+
/**
|
|
5830
|
+
* Validate compiler access using a UCAN capability token.
|
|
5831
|
+
*
|
|
5832
|
+
* Checks that the capability token grants access to the required resources
|
|
5833
|
+
* (AST read, CODE write, and optionally OUTPUT write) using the
|
|
5834
|
+
* CapabilityRBAC adapter.
|
|
5835
|
+
*
|
|
5836
|
+
* @param credential - UCAN capability token credential
|
|
5837
|
+
* @param outputPath - Optional output path for scope validation
|
|
5838
|
+
* @throws UnauthorizedCompilerAccessError if any capability check fails
|
|
5839
|
+
*/
|
|
5840
|
+
validateCapabilityAccess(credential, outputPath) {
|
|
5841
|
+
const capRBAC = this.getCapabilityRBAC();
|
|
5842
|
+
const astDecision = capRBAC.checkAccess({
|
|
5843
|
+
token: "",
|
|
5844
|
+
capabilityToken: credential.capabilityToken,
|
|
5845
|
+
issuerPublicKey: credential.issuerPublicKey,
|
|
5846
|
+
resourceType: "ast" /* AST */,
|
|
5847
|
+
operation: "read"
|
|
5848
|
+
});
|
|
5849
|
+
if (!astDecision.allowed) {
|
|
5850
|
+
throw new exports.UnauthorizedCompilerAccessError(astDecision, "AST access", this.compilerName);
|
|
5851
|
+
}
|
|
5852
|
+
const codeDecision = capRBAC.checkAccess({
|
|
5853
|
+
token: "",
|
|
5854
|
+
capabilityToken: credential.capabilityToken,
|
|
5855
|
+
issuerPublicKey: credential.issuerPublicKey,
|
|
5856
|
+
resourceType: "code" /* CODE */,
|
|
5857
|
+
operation: "write"
|
|
5858
|
+
});
|
|
5859
|
+
if (!codeDecision.allowed) {
|
|
5860
|
+
throw new exports.UnauthorizedCompilerAccessError(codeDecision, "code generation", this.compilerName);
|
|
5861
|
+
}
|
|
5862
|
+
if (outputPath) {
|
|
5863
|
+
const outputDecision = capRBAC.checkAccess({
|
|
5864
|
+
token: "",
|
|
5865
|
+
capabilityToken: credential.capabilityToken,
|
|
5866
|
+
issuerPublicKey: credential.issuerPublicKey,
|
|
5867
|
+
resourceType: "output" /* OUTPUT */,
|
|
5868
|
+
operation: "write",
|
|
5869
|
+
resourcePath: outputPath
|
|
5870
|
+
});
|
|
5871
|
+
if (!outputDecision.allowed) {
|
|
5872
|
+
throw new exports.UnauthorizedCompilerAccessError(
|
|
5873
|
+
outputDecision,
|
|
5874
|
+
`output write to '${outputPath}'`,
|
|
5875
|
+
this.compilerName
|
|
5876
|
+
);
|
|
5877
|
+
}
|
|
5878
|
+
}
|
|
5879
|
+
}
|
|
5880
|
+
// =========================================================================
|
|
5881
|
+
// Spatial Memory Zone validation
|
|
5882
|
+
// =========================================================================
|
|
5883
|
+
/**
|
|
5884
|
+
* Validate spatial zone access for the current compilation.
|
|
5885
|
+
*
|
|
5886
|
+
* This step runs **after** RBAC/UCAN token verification and enforces
|
|
5887
|
+
* compile-time spatial zone permissions when zones are registered.
|
|
5888
|
+
*
|
|
5889
|
+
* **Backward compatible**: When no zones are registered in the global
|
|
5890
|
+
* SpatialZoneEnforcer, this method is a no-op.
|
|
5891
|
+
*
|
|
5892
|
+
* **Non-blocking**: Zone enforcement failures are logged as warnings
|
|
5893
|
+
* but do NOT throw or block compilation. This allows gradual rollout
|
|
5894
|
+
* of spatial zone policies without breaking existing pipelines.
|
|
5895
|
+
*
|
|
5896
|
+
* @param agentToken - JWT token string (spatial zones use JWT verification)
|
|
5897
|
+
*/
|
|
5898
|
+
validateSpatialZoneAccess(agentToken) {
|
|
5899
|
+
if (!agentToken) return;
|
|
5900
|
+
const enforcer = this.getSpatialZoneEnforcer();
|
|
5901
|
+
const zoneIds = enforcer.getRegisteredZoneIds();
|
|
5902
|
+
if (zoneIds.length === 0) return;
|
|
5903
|
+
for (const zoneId of zoneIds) {
|
|
5904
|
+
const decision = enforcer.checkZoneAccess(
|
|
5905
|
+
agentToken,
|
|
5906
|
+
zoneId,
|
|
5907
|
+
"spatial:read" /* SPATIAL_READ */
|
|
5908
|
+
);
|
|
5909
|
+
if (!decision.allowed) {
|
|
5910
|
+
console.warn(
|
|
5911
|
+
`[${this.compilerName}] Spatial zone access warning: agent ${decision.agentId ?? "unknown"} denied SPATIAL_READ in zone "${zoneId}": ${decision.reason}`
|
|
5912
|
+
);
|
|
5913
|
+
}
|
|
5914
|
+
}
|
|
5915
|
+
}
|
|
5916
|
+
// =========================================================================
|
|
5917
|
+
// Dual-mode access validation (P3 Migration Bridge)
|
|
5918
|
+
// =========================================================================
|
|
5919
|
+
/**
|
|
5920
|
+
* Validate all compiler permissions in single call (dual-mode).
|
|
5921
|
+
*
|
|
5922
|
+
* **P3 Migration Bridge**: This method now accepts both JWT RBAC tokens
|
|
5923
|
+
* (string) and UCAN capability tokens (CapabilityTokenCredential).
|
|
5924
|
+
*
|
|
5925
|
+
* Token routing:
|
|
5926
|
+
* - `undefined` / `null` / empty string: Skip all validation (backwards compatibility)
|
|
5927
|
+
* - `string` (non-empty): Route to legacy JWT RBAC via AgentRBAC.checkAccess()
|
|
5928
|
+
* - `CapabilityTokenCredential`: Route to UCAN via CapabilityRBAC.checkAccess()
|
|
5929
|
+
*
|
|
5930
|
+
* Convenience method combining AST access + code generation + optional output validation.
|
|
5931
|
+
* Skips ALL validation when no token is provided (backwards compatibility / testing).
|
|
5932
|
+
*
|
|
5933
|
+
* @param agentToken - JWT token string OR UCAN CapabilityTokenCredential (optional)
|
|
5934
|
+
* @param outputPath - Optional output path
|
|
5935
|
+
* @throws UnauthorizedCompilerAccessError if any validation fails
|
|
5936
|
+
*/
|
|
5937
|
+
validateCompilerAccess(agentToken, outputPath) {
|
|
5938
|
+
if (!agentToken) return;
|
|
5939
|
+
if (isCapabilityTokenCredential(agentToken)) {
|
|
5940
|
+
this.validateCapabilityAccess(agentToken, outputPath);
|
|
5941
|
+
return;
|
|
5942
|
+
}
|
|
5943
|
+
this.validateASTAccess(agentToken);
|
|
5944
|
+
this.validateCodeGeneration(agentToken);
|
|
5945
|
+
if (outputPath) {
|
|
5946
|
+
this.validateOutputPath(agentToken, outputPath);
|
|
5947
|
+
}
|
|
5948
|
+
this.validateSpatialZoneAccess(agentToken);
|
|
5949
|
+
}
|
|
5950
|
+
// =========================================================================
|
|
5951
|
+
// Cultural compatibility validation
|
|
5952
|
+
// =========================================================================
|
|
5953
|
+
/**
|
|
5954
|
+
* Extract cultural profile from an agent token.
|
|
5955
|
+
*
|
|
5956
|
+
* @param agentToken - JWT token string (capability tokens do not carry cultural profiles)
|
|
5957
|
+
* @returns The cultural profile if present, or null
|
|
5958
|
+
*/
|
|
5959
|
+
extractCulturalProfile(agentToken) {
|
|
5960
|
+
if (!agentToken) return null;
|
|
5961
|
+
return this.rbac.extractCulturalProfile(agentToken);
|
|
5962
|
+
}
|
|
5963
|
+
/**
|
|
5964
|
+
* Validate cultural compatibility across multiple agent tokens.
|
|
5965
|
+
*
|
|
5966
|
+
* Subclasses can call this during multi-agent compilation to ensure
|
|
5967
|
+
* all participating agents have compatible cultural profiles before
|
|
5968
|
+
* proceeding with code generation.
|
|
5969
|
+
*
|
|
5970
|
+
* @param agentTokens - Map of agent name to JWT token
|
|
5971
|
+
* @param normSets - Optional map of agent name to norm_set arrays
|
|
5972
|
+
* @returns Cultural compatibility result, or null if fewer than 2 agents
|
|
5973
|
+
* have cultural profiles
|
|
5974
|
+
*/
|
|
5975
|
+
validateCulturalCompatibility(agentTokens, normSets) {
|
|
5976
|
+
return this.rbac.validateCulturalCompatibility(agentTokens, normSets);
|
|
5977
|
+
}
|
|
5978
|
+
};
|
|
5979
|
+
}
|
|
5980
|
+
});
|
|
5981
|
+
|
|
5982
|
+
exports.createTestCompilerToken = createTestCompilerToken;
|
|
3669
5983
|
exports.criticalMassForChange = criticalMassForChange;
|
|
5984
|
+
exports.deserializeNormProvenance = deserializeNormProvenance;
|
|
5985
|
+
exports.escapeStringValue = escapeStringValue;
|
|
3670
5986
|
exports.getBuiltinNorm = getBuiltinNorm;
|
|
3671
|
-
exports.getCapabilityTokenIssuer = getCapabilityTokenIssuer;
|
|
3672
5987
|
exports.getRBAC = getRBAC;
|
|
3673
|
-
exports.
|
|
5988
|
+
exports.init_ANSNamespace = init_ANSNamespace;
|
|
3674
5989
|
exports.init_AgentRBAC = init_AgentRBAC;
|
|
3675
|
-
exports.
|
|
3676
|
-
exports.
|
|
3677
|
-
exports.init_CapabilityTokenIssuer = init_CapabilityTokenIssuer;
|
|
5990
|
+
exports.init_CompilerBase = init_CompilerBase;
|
|
5991
|
+
exports.init_CompilerDocumentationGenerator = init_CompilerDocumentationGenerator;
|
|
3678
5992
|
exports.init_CultureTraits = init_CultureTraits;
|
|
5993
|
+
exports.isCapabilityTokenCredential = isCapabilityTokenCredential;
|
|
5994
|
+
exports.normalizeNormProvenance = normalizeNormProvenance;
|
|
3679
5995
|
exports.normsByCategory = normsByCategory;
|
|
3680
|
-
|
|
3681
|
-
//# sourceMappingURL=chunk-
|
|
5996
|
+
exports.serializeNormProvenance = serializeNormProvenance;
|
|
5997
|
+
//# sourceMappingURL=chunk-RMHC2VG7.cjs.map
|
|
5998
|
+
//# sourceMappingURL=chunk-RMHC2VG7.cjs.map
|