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