@holoscript/core 6.0.3 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +40 -40
  2. package/dist/codebase/index.d.ts +25 -0
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +4 -0
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/entries/interop.d.ts +9 -0
  7. package/dist/entries/scripting.d.ts +7 -0
  8. package/dist/index.d.ts +520 -19
  9. package/dist/paper-0c-spike/index.d.ts +29 -0
  10. package/dist/reconstruction/index.d.ts +78 -0
  11. package/dist/self-improvement/index.d.ts +0 -48
  12. package/dist/storage/index.d.ts +24 -0
  13. package/dist/tools/index.d.ts +33 -0
  14. package/dist/traitDocs/traitDocs.d.ts +69 -0
  15. package/dist/traits/index.d.ts +61 -0
  16. package/package.json +102 -19
  17. package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
  18. package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
  19. package/dist/HoloScriptPlusParser-BZR5DELQ.js +0 -692
  20. package/dist/HoloScriptPlusParser-SBMYDNXO.cjs +0 -697
  21. package/dist/USDZExporter-MHEHXZB4.cjs +0 -709
  22. package/dist/USDZExporter-YA55ZS35.js +0 -707
  23. package/dist/chunk-26TLYBFD.js +0 -309
  24. package/dist/chunk-27LWW5FU.cjs +0 -410
  25. package/dist/chunk-2UX5LRAP.cjs +0 -833
  26. package/dist/chunk-32TWR3HE.js +0 -70
  27. package/dist/chunk-3FXV5S25.cjs +0 -633
  28. package/dist/chunk-3FYZOR7S.cjs +0 -69
  29. package/dist/chunk-3KEU5QYY.cjs +0 -175
  30. package/dist/chunk-4FCZDTD5.js +0 -610
  31. package/dist/chunk-4KJ2R7VP.cjs +0 -507
  32. package/dist/chunk-4SMUJFHL.js +0 -1213
  33. package/dist/chunk-54FHG2MX.js +0 -655
  34. package/dist/chunk-56IF4NTA.js +0 -56
  35. package/dist/chunk-5GLCTO44.js +0 -161
  36. package/dist/chunk-5TOFIR6L.js +0 -407
  37. package/dist/chunk-65RFOWZI.js +0 -765
  38. package/dist/chunk-6OQBLABR.js +0 -5240
  39. package/dist/chunk-6WNCRE6F.js +0 -126
  40. package/dist/chunk-74YCHHTE.js +0 -1872
  41. package/dist/chunk-7H5UNJZD.cjs +0 -1973
  42. package/dist/chunk-7KPI4EKH.cjs +0 -701
  43. package/dist/chunk-7LCYLPW2.cjs +0 -663
  44. package/dist/chunk-7N3JIJMT.js +0 -1395
  45. package/dist/chunk-7X2IEJIE.cjs +0 -2526
  46. package/dist/chunk-A6GO3DPZ.cjs +0 -1002
  47. package/dist/chunk-AC4BSHFV.js +0 -765
  48. package/dist/chunk-AIUXRS74.cjs +0 -3681
  49. package/dist/chunk-ARNKA274.cjs +0 -130
  50. package/dist/chunk-AW7WAELW.js +0 -975
  51. package/dist/chunk-BKIGPPVM.js +0 -629
  52. package/dist/chunk-BO2OKHIY.js +0 -6055
  53. package/dist/chunk-BU5ZAFMC.js +0 -115
  54. package/dist/chunk-BY3B7ZYV.cjs +0 -457
  55. package/dist/chunk-C2QHVHZF.js +0 -4066
  56. package/dist/chunk-C7BNX4XJ.js +0 -1043
  57. package/dist/chunk-CLYEIWA5.cjs +0 -408
  58. package/dist/chunk-CMYAWUX3.js +0 -4455
  59. package/dist/chunk-CN4NOESF.cjs +0 -416
  60. package/dist/chunk-CNVM7J3M.js +0 -883
  61. package/dist/chunk-CO2VM2DK.js +0 -1965
  62. package/dist/chunk-CQDOF3G7.cjs +0 -1404
  63. package/dist/chunk-DH5G2JUA.cjs +0 -614
  64. package/dist/chunk-DIEDKX5B.cjs +0 -660
  65. package/dist/chunk-DN7UFU63.cjs +0 -172
  66. package/dist/chunk-DXVCEFZB.js +0 -2027
  67. package/dist/chunk-EGIZHYJP.cjs +0 -85
  68. package/dist/chunk-EJA7G2C4.cjs +0 -428
  69. package/dist/chunk-ELLQPFAF.js +0 -830
  70. package/dist/chunk-EMO7HAKJ.cjs +0 -1875
  71. package/dist/chunk-ENV7K6XA.js +0 -282
  72. package/dist/chunk-EPWRXL6S.js +0 -2522
  73. package/dist/chunk-EUFLX2PI.js +0 -56956
  74. package/dist/chunk-F5LVGHNT.js +0 -449
  75. package/dist/chunk-FEFHPUEM.cjs +0 -6122
  76. package/dist/chunk-FF3Q7ADR.js +0 -380
  77. package/dist/chunk-GC3YU46J.js +0 -762
  78. package/dist/chunk-H6WMMLQK.cjs +0 -4492
  79. package/dist/chunk-H7XMORZI.js +0 -2731
  80. package/dist/chunk-HAN4V3PF.cjs +0 -2037
  81. package/dist/chunk-HBZYCASG.js +0 -4208
  82. package/dist/chunk-HF4OFY25.cjs +0 -4097
  83. package/dist/chunk-HHS6FMOU.cjs +0 -3813
  84. package/dist/chunk-HJJLD366.js +0 -1169
  85. package/dist/chunk-HKCVM6OK.cjs +0 -2237
  86. package/dist/chunk-HUFNKFA6.js +0 -698
  87. package/dist/chunk-I3XGTIHM.cjs +0 -1505
  88. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  89. package/dist/chunk-IHOUYQIA.js +0 -406
  90. package/dist/chunk-ILRBGFVD.cjs +0 -72
  91. package/dist/chunk-KDB6BUMB.js +0 -3666
  92. package/dist/chunk-KUJRR4FJ.js +0 -657
  93. package/dist/chunk-KYM4XRFG.js +0 -421
  94. package/dist/chunk-L3Z2HIWJ.cjs +0 -793
  95. package/dist/chunk-LBPEZQAF.js +0 -2232
  96. package/dist/chunk-LER4WXW5.cjs +0 -286
  97. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  98. package/dist/chunk-M6FU6S22.js +0 -2911
  99. package/dist/chunk-MWEFR6YQ.js +0 -1857
  100. package/dist/chunk-N5FTS757.cjs +0 -415
  101. package/dist/chunk-NCUHGRTZ.js +0 -752
  102. package/dist/chunk-NKRKT6V2.js +0 -69
  103. package/dist/chunk-NLPSZT4C.js +0 -630
  104. package/dist/chunk-NRUB55IT.cjs +0 -771
  105. package/dist/chunk-NTMZSDXM.cjs +0 -633
  106. package/dist/chunk-ODGMVILH.js +0 -9662
  107. package/dist/chunk-PBA6NXCT.cjs +0 -1216
  108. package/dist/chunk-PHENW4MQ.js +0 -65
  109. package/dist/chunk-PJMOXFPR.cjs +0 -1861
  110. package/dist/chunk-PLMYCCA4.js +0 -504
  111. package/dist/chunk-PPULB4GG.cjs +0 -9728
  112. package/dist/chunk-PQLGZKMC.cjs +0 -755
  113. package/dist/chunk-Q56TT7IL.js +0 -483
  114. package/dist/chunk-QHVVVN47.cjs +0 -2033
  115. package/dist/chunk-QWKUKVRE.js +0 -2026
  116. package/dist/chunk-RE3OKSYF.cjs +0 -424
  117. package/dist/chunk-RT7LJRSF.cjs +0 -57378
  118. package/dist/chunk-SPDELRRV.cjs +0 -319
  119. package/dist/chunk-SUCBB66F.js +0 -229
  120. package/dist/chunk-TSWTWZ42.cjs +0 -4214
  121. package/dist/chunk-UITWA6DV.cjs +0 -2829
  122. package/dist/chunk-UQW6SLM5.js +0 -172
  123. package/dist/chunk-V2ILLPHK.cjs +0 -237
  124. package/dist/chunk-V42NTCFH.js +0 -3645
  125. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  126. package/dist/chunk-VJVCD5T5.cjs +0 -769
  127. package/dist/chunk-VK5AXKO3.js +0 -746
  128. package/dist/chunk-VSXOIUCF.cjs +0 -473
  129. package/dist/chunk-VZNKJZTT.cjs +0 -749
  130. package/dist/chunk-W76ETJTI.js +0 -678
  131. package/dist/chunk-WFJIDI2N.cjs +0 -424
  132. package/dist/chunk-WN3YF33G.cjs +0 -118
  133. package/dist/chunk-WUXIRGZP.cjs +0 -2915
  134. package/dist/chunk-WYH4GVZ5.js +0 -1488
  135. package/dist/chunk-X4YVN7H3.cjs +0 -888
  136. package/dist/chunk-X67XRI2T.js +0 -410
  137. package/dist/chunk-XDXZM3ZP.cjs +0 -1046
  138. package/dist/chunk-XH7SE4HH.cjs +0 -72
  139. package/dist/chunk-XNMEH2BI.js +0 -126
  140. package/dist/chunk-XSF76QRU.js +0 -468
  141. package/dist/chunk-XSUZMPVQ.cjs +0 -682
  142. package/dist/chunk-XUILI4KB.cjs +0 -430
  143. package/dist/chunk-Y5MUAYTO.js +0 -167
  144. package/dist/chunk-Y7VK5TH3.cjs +0 -129
  145. package/dist/chunk-YCMQQQ5U.cjs +0 -5244
  146. package/dist/chunk-YYXH45E2.js +0 -426
  147. package/dist/chunk-ZGTGVSTZ.js +0 -422
  148. package/dist/chunk-ZL6VJ6SN.js +0 -421
  149. package/dist/cli/holoscript-runner.cjs +0 -2258
  150. package/dist/cli/holoscript-runner.js +0 -2233
  151. package/dist/codebase/index.cjs +0 -336
  152. package/dist/codebase/index.js +0 -331
  153. package/dist/compiler/agent-inference.cjs +0 -29
  154. package/dist/compiler/agent-inference.js +0 -6
  155. package/dist/compiler/android-xr.cjs +0 -20
  156. package/dist/compiler/android-xr.js +0 -10
  157. package/dist/compiler/android.cjs +0 -21
  158. package/dist/compiler/android.js +0 -11
  159. package/dist/compiler/ar.cjs +0 -21
  160. package/dist/compiler/ar.js +0 -9
  161. package/dist/compiler/babylon.cjs +0 -18
  162. package/dist/compiler/babylon.js +0 -12
  163. package/dist/compiler/coco.cjs +0 -27
  164. package/dist/compiler/coco.js +0 -4
  165. package/dist/compiler/domain-block-utils.cjs +0 -595
  166. package/dist/compiler/domain-block-utils.js +0 -9
  167. package/dist/compiler/dtdl.cjs +0 -25
  168. package/dist/compiler/dtdl.js +0 -9
  169. package/dist/compiler/gltf-pipeline.cjs +0 -39
  170. package/dist/compiler/gltf-pipeline.js +0 -4
  171. package/dist/compiler/godot.cjs +0 -16
  172. package/dist/compiler/godot.js +0 -10
  173. package/dist/compiler/incremental.cjs +0 -30
  174. package/dist/compiler/incremental.js +0 -5
  175. package/dist/compiler/index.cjs +0 -1522
  176. package/dist/compiler/index.js +0 -1321
  177. package/dist/compiler/ios.cjs +0 -21
  178. package/dist/compiler/ios.js +0 -11
  179. package/dist/compiler/multi-layer.cjs +0 -27
  180. package/dist/compiler/multi-layer.js +0 -12
  181. package/dist/compiler/nodetoy.cjs +0 -23
  182. package/dist/compiler/nodetoy.js +0 -4
  183. package/dist/compiler/openxr.cjs +0 -16
  184. package/dist/compiler/openxr.js +0 -10
  185. package/dist/compiler/playcanvas.cjs +0 -17
  186. package/dist/compiler/playcanvas.js +0 -11
  187. package/dist/compiler/r3f.cjs +0 -35
  188. package/dist/compiler/r3f.js +0 -13
  189. package/dist/compiler/remotion.cjs +0 -23
  190. package/dist/compiler/remotion.js +0 -4
  191. package/dist/compiler/reproducibility.cjs +0 -39
  192. package/dist/compiler/reproducibility.js +0 -4
  193. package/dist/compiler/sdf.cjs +0 -22
  194. package/dist/compiler/sdf.js +0 -10
  195. package/dist/compiler/semantic-scene.cjs +0 -31
  196. package/dist/compiler/semantic-scene.js +0 -4
  197. package/dist/compiler/state.cjs +0 -18
  198. package/dist/compiler/state.js +0 -8
  199. package/dist/compiler/trait-composition.cjs +0 -27
  200. package/dist/compiler/trait-composition.js +0 -6
  201. package/dist/compiler/unity.cjs +0 -16
  202. package/dist/compiler/unity.js +0 -10
  203. package/dist/compiler/unreal.cjs +0 -20
  204. package/dist/compiler/unreal.js +0 -10
  205. package/dist/compiler/urdf.cjs +0 -46
  206. package/dist/compiler/urdf.js +0 -10
  207. package/dist/compiler/usd-physics.cjs +0 -24
  208. package/dist/compiler/usd-physics.js +0 -7
  209. package/dist/compiler/visionos.cjs +0 -16
  210. package/dist/compiler/visionos.js +0 -10
  211. package/dist/compiler/vrchat.cjs +0 -20
  212. package/dist/compiler/vrchat.js +0 -10
  213. package/dist/compiler/vrr.cjs +0 -22
  214. package/dist/compiler/vrr.js +0 -10
  215. package/dist/compiler/wasm.cjs +0 -34
  216. package/dist/compiler/wasm.js +0 -10
  217. package/dist/compiler/webgpu.cjs +0 -16
  218. package/dist/compiler/webgpu.js +0 -10
  219. package/dist/debugger.cjs +0 -21
  220. package/dist/debugger.js +0 -8
  221. package/dist/entries/interop.cjs +0 -62
  222. package/dist/entries/interop.js +0 -5
  223. package/dist/entries/scripting.cjs +0 -67
  224. package/dist/entries/scripting.js +0 -10
  225. package/dist/index.cjs +0 -61703
  226. package/dist/index.js +0 -58652
  227. package/dist/math/vec3.cjs +0 -57
  228. package/dist/math/vec3.js +0 -4
  229. package/dist/parser.cjs +0 -26
  230. package/dist/parser.js +0 -9
  231. package/dist/playwright-7DTEQCBD.cjs +0 -98673
  232. package/dist/playwright-BIZXMLD2.js +0 -98660
  233. package/dist/post-quantum-JTTAAGO3.cjs +0 -6
  234. package/dist/post-quantum-RVPVDEPI.js +0 -4
  235. package/dist/runtime.cjs +0 -16
  236. package/dist/runtime.js +0 -7
  237. package/dist/storage/index.cjs +0 -37
  238. package/dist/storage/index.js +0 -4
  239. package/dist/traits/index.cjs +0 -14331
  240. package/dist/traits/index.js +0 -12126
  241. package/dist/type-checker.cjs +0 -18
  242. package/dist/type-checker.js +0 -5
  243. package/dist/wot/index.cjs +0 -29
  244. package/dist/wot/index.js +0 -4
@@ -1,161 +0,0 @@
1
- // src/compiler/ReproducibilityMode.ts
2
- var DEFAULT_FIXED_TIMESTAMP = "2026-01-01T00:00:00.000Z";
3
- var DEFAULT_SEED = 42;
4
- var DEFAULT_GENERATOR = "holoscript-compiler";
5
- var COMPILER_VERSION = "6.0.0";
6
- function createSeededRNG(seed = DEFAULT_SEED) {
7
- let state = seed | 0;
8
- const initialSeed = state;
9
- function next() {
10
- state = state + 1831565813 | 0;
11
- let t = Math.imul(state ^ state >>> 15, 1 | state);
12
- t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
13
- return ((t ^ t >>> 14) >>> 0) / 4294967296;
14
- }
15
- function nextInt(min, max) {
16
- return Math.floor(next() * (max - min + 1)) + min;
17
- }
18
- function nextUUID() {
19
- const hex = (n, len) => Array.from({ length: len }, () => nextInt(0, 15).toString(16)).join("");
20
- return `${hex(0, 8)}-${hex(0, 4)}-4${hex(0, 3)}-${(8 + nextInt(0, 3)).toString(16)}${hex(0, 3)}-${hex(0, 12)}`;
21
- }
22
- function reset() {
23
- state = initialSeed;
24
- }
25
- function getState() {
26
- return state;
27
- }
28
- return { next, nextInt, nextUUID, reset, getState };
29
- }
30
- function sortKeysDeep(value) {
31
- if (value === null || value === void 0) return value;
32
- if (Array.isArray(value)) {
33
- return value.map((item) => sortKeysDeep(item));
34
- }
35
- if (typeof value === "object") {
36
- const sorted = {};
37
- const keys = Object.keys(value).sort();
38
- for (const key of keys) {
39
- sorted[key] = sortKeysDeep(value[key]);
40
- }
41
- return sorted;
42
- }
43
- return value;
44
- }
45
- function fnv1a32(input) {
46
- let hash = 2166136261;
47
- for (let i = 0; i < input.length; i++) {
48
- hash ^= input.charCodeAt(i);
49
- hash = Math.imul(hash, 16777619);
50
- }
51
- return (hash >>> 0).toString(16).padStart(8, "0");
52
- }
53
- function hashComposition(composition) {
54
- const sorted = sortKeysDeep(composition);
55
- const serialized = JSON.stringify(sorted);
56
- const h1 = fnv1a32(serialized);
57
- const h2 = fnv1a32(serialized + h1);
58
- const h3 = fnv1a32(serialized + h2);
59
- const h4 = fnv1a32(serialized + h3);
60
- const h5 = fnv1a32(serialized + h4);
61
- const h6 = fnv1a32(serialized + h5);
62
- const h7 = fnv1a32(serialized + h6);
63
- const h8 = fnv1a32(serialized + h7);
64
- return `${h1}${h2}${h3}${h4}${h5}${h6}${h7}${h8}`;
65
- }
66
- function createReproducibilityContext(config) {
67
- const fullConfig = {
68
- enabled: config.enabled,
69
- fixedTimestamp: config.fixedTimestamp ?? DEFAULT_FIXED_TIMESTAMP,
70
- randomSeed: config.randomSeed ?? DEFAULT_SEED,
71
- sortKeys: config.sortKeys ?? config.enabled,
72
- deterministicIds: config.deterministicIds ?? config.enabled,
73
- generatorString: config.generatorString ?? DEFAULT_GENERATOR,
74
- includeManifest: config.includeManifest ?? false
75
- };
76
- const rng = createSeededRNG(fullConfig.randomSeed);
77
- function random() {
78
- return fullConfig.enabled ? rng.next() : Math.random();
79
- }
80
- function randomInt(min, max) {
81
- return fullConfig.enabled ? rng.nextInt(min, max) : Math.floor(Math.random() * (max - min + 1)) + min;
82
- }
83
- function timestamp() {
84
- return fullConfig.enabled ? fullConfig.fixedTimestamp : (/* @__PURE__ */ new Date()).toISOString();
85
- }
86
- function timestampDate() {
87
- return fullConfig.enabled ? new Date(fullConfig.fixedTimestamp) : /* @__PURE__ */ new Date();
88
- }
89
- function uuid() {
90
- if (!fullConfig.enabled || !fullConfig.deterministicIds) {
91
- return crypto?.randomUUID?.() ?? rng.nextUUID();
92
- }
93
- return rng.nextUUID();
94
- }
95
- function generator() {
96
- return fullConfig.generatorString;
97
- }
98
- function stabilize(value) {
99
- if (!fullConfig.enabled || !fullConfig.sortKeys) return value;
100
- return sortKeysDeep(value);
101
- }
102
- function manifest(composition) {
103
- return {
104
- reproducible: true,
105
- seed: fullConfig.randomSeed,
106
- timestamp: fullConfig.fixedTimestamp,
107
- inputHash: hashComposition(composition),
108
- compilerVersion: COMPILER_VERSION
109
- };
110
- }
111
- function reset() {
112
- rng.reset();
113
- }
114
- function stringify(value, indent = 2) {
115
- const processed = fullConfig.enabled && fullConfig.sortKeys ? sortKeysDeep(value) : value;
116
- return JSON.stringify(processed, null, indent);
117
- }
118
- return {
119
- enabled: fullConfig.enabled,
120
- config: fullConfig,
121
- random,
122
- randomInt,
123
- timestamp,
124
- timestampDate,
125
- uuid,
126
- generator,
127
- stabilize,
128
- manifest,
129
- reset,
130
- stringify
131
- };
132
- }
133
- function parseReproducibilityFlags(args) {
134
- const config = { enabled: false };
135
- for (const arg of args) {
136
- if (arg === "--reproducible") {
137
- config.enabled = true;
138
- }
139
- if (arg === "--no-reproducible") {
140
- config.enabled = false;
141
- }
142
- if (arg.startsWith("--reproducible-seed=")) {
143
- config.enabled = true;
144
- config.randomSeed = parseInt(arg.split("=")[1], 10);
145
- if (isNaN(config.randomSeed)) config.randomSeed = DEFAULT_SEED;
146
- }
147
- if (arg.startsWith("--reproducible-timestamp=")) {
148
- config.enabled = true;
149
- config.fixedTimestamp = arg.split("=")[1].replace(/"/g, "");
150
- }
151
- if (arg === "--reproducible-manifest") {
152
- config.includeManifest = true;
153
- }
154
- }
155
- return config;
156
- }
157
- var ReproducibilityMode_default = createReproducibilityContext;
158
-
159
- export { ReproducibilityMode_default, createReproducibilityContext, createSeededRNG, fnv1a32, hashComposition, parseReproducibilityFlags, sortKeysDeep };
160
- //# sourceMappingURL=chunk-5GLCTO44.js.map
161
- //# sourceMappingURL=chunk-5GLCTO44.js.map
@@ -1,407 +0,0 @@
1
- // src/interop/InteropBindingGenerator.ts
2
- var InteropBindingGenerator = class {
3
- /**
4
- * Extract exports from a HoloScript AST
5
- */
6
- extractExports(ast) {
7
- const exports$1 = [];
8
- if (!ast.body) return exports$1;
9
- for (const node of ast.body) {
10
- const nodeRecord = node;
11
- const nodeType = nodeRecord.type;
12
- const nodeName = nodeRecord.name;
13
- if (nodeType === "FunctionDeclaration" || nodeType === "function") {
14
- const params = nodeRecord.params || [];
15
- exports$1.push({
16
- name: nodeName || "anonymous",
17
- type: "function",
18
- parameters: params.map((p) => {
19
- if (typeof p === "string") {
20
- return { name: p, type: "any", optional: false };
21
- }
22
- return {
23
- name: p.name || "",
24
- type: p.type || "any",
25
- optional: p.optional || false
26
- };
27
- }),
28
- returnType: nodeRecord.returnType || "void"
29
- });
30
- }
31
- if (nodeType === "template" || nodeType === "ClassDeclaration") {
32
- exports$1.push({
33
- name: nodeName || "UnnamedTemplate",
34
- type: "class"
35
- });
36
- }
37
- if (nodeType === "composition") {
38
- exports$1.push({
39
- name: nodeName || "default",
40
- type: "module"
41
- });
42
- }
43
- if (nodeType === "VariableDeclaration" || nodeType === "state") {
44
- exports$1.push({
45
- name: nodeName || "unnamed",
46
- type: "constant",
47
- value: nodeRecord.value
48
- });
49
- }
50
- }
51
- return exports$1;
52
- }
53
- /**
54
- * Generate Python bindings from HoloScript AST
55
- */
56
- generatePythonBindings(ast, sourceFile) {
57
- const exports$1 = this.extractExports(ast);
58
- const lines = [
59
- '"""',
60
- `Auto-generated Python bindings for ${sourceFile}`,
61
- `Generated by HoloScript InteropBindingGenerator`,
62
- `Do not edit manually \u2014 regenerate with: holoscript compile ${sourceFile} --target python`,
63
- '"""',
64
- "",
65
- "from typing import Any, Optional, Dict, List",
66
- "import json",
67
- ""
68
- ];
69
- for (const exp of exports$1) {
70
- switch (exp.type) {
71
- case "function": {
72
- const params = (exp.parameters || []).map((p) => {
73
- const pyType = this.tsPyType(p.type);
74
- return p.optional ? `${p.name}: ${pyType} = None` : `${p.name}: ${pyType}`;
75
- }).join(", ");
76
- const retType = this.tsPyType(exp.returnType || "void");
77
- lines.push(`def ${exp.name}(${params}) -> ${retType}:`);
78
- lines.push(` """HoloScript function: ${exp.name}"""`);
79
- lines.push(` raise NotImplementedError("Bridge to HoloScript runtime required")`);
80
- lines.push("");
81
- break;
82
- }
83
- case "class": {
84
- lines.push(`class ${exp.name}:`);
85
- lines.push(` """HoloScript template: ${exp.name}"""`);
86
- lines.push(` def __init__(self, **kwargs: Any) -> None:`);
87
- lines.push(` self._props = kwargs`);
88
- lines.push("");
89
- break;
90
- }
91
- case "constant": {
92
- lines.push(`${exp.name} = ${JSON.stringify(exp.value ?? "None")}`);
93
- lines.push("");
94
- break;
95
- }
96
- case "module": {
97
- lines.push(`class ${exp.name}Module:`);
98
- lines.push(` """HoloScript composition: ${exp.name}"""`);
99
- lines.push(` pass`);
100
- lines.push("");
101
- break;
102
- }
103
- }
104
- }
105
- lines.push(`__all__ = [${exports$1.map((e) => `"${e.name}"`).join(", ")}]`);
106
- return {
107
- language: "python",
108
- code: lines.join("\n"),
109
- exports: exports$1.map((e) => e.name),
110
- metadata: {
111
- sourceFile,
112
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
113
- holoScriptVersion: "5.0.0"
114
- }
115
- };
116
- }
117
- /**
118
- * Generate JavaScript (ESM) bindings from HoloScript AST
119
- */
120
- generateJSBindings(ast, sourceFile) {
121
- const exports$1 = this.extractExports(ast);
122
- const lines = [
123
- `// Auto-generated JS bindings for ${sourceFile}`,
124
- `// Generated by HoloScript InteropBindingGenerator`,
125
- `// Do not edit manually`,
126
- ""
127
- ];
128
- for (const exp of exports$1) {
129
- switch (exp.type) {
130
- case "function": {
131
- const params = (exp.parameters || []).map((p) => p.name).join(", ");
132
- lines.push(`export function ${exp.name}(${params}) {`);
133
- lines.push(` throw new Error("Bridge to HoloScript runtime required");`);
134
- lines.push(`}`);
135
- lines.push("");
136
- break;
137
- }
138
- case "class": {
139
- lines.push(`export class ${exp.name} {`);
140
- lines.push(` constructor(props = {}) { this._props = props; }`);
141
- lines.push(`}`);
142
- lines.push("");
143
- break;
144
- }
145
- case "constant": {
146
- lines.push(`export const ${exp.name} = ${JSON.stringify(exp.value ?? null)};`);
147
- lines.push("");
148
- break;
149
- }
150
- case "module": {
151
- lines.push(`export const ${exp.name} = { /* HoloScript composition */ };`);
152
- lines.push("");
153
- break;
154
- }
155
- }
156
- }
157
- return {
158
- language: "javascript",
159
- code: lines.join("\n"),
160
- exports: exports$1.map((e) => e.name),
161
- metadata: {
162
- sourceFile,
163
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
164
- holoScriptVersion: "5.0.0"
165
- }
166
- };
167
- }
168
- /**
169
- * Map TypeScript types to Python types
170
- */
171
- tsPyType(tsType) {
172
- const mapping = {
173
- string: "str",
174
- number: "float",
175
- int: "int",
176
- boolean: "bool",
177
- void: "None",
178
- any: "Any",
179
- unknown: "Any",
180
- "string[]": "List[str]",
181
- "number[]": "List[float]"
182
- };
183
- return mapping[tsType] || "Any";
184
- }
185
- };
186
-
187
- // src/resilience/ResiliencePatterns.ts
188
- var CircuitBreakerState = /* @__PURE__ */ ((CircuitBreakerState2) => {
189
- CircuitBreakerState2["CLOSED"] = "CLOSED";
190
- CircuitBreakerState2["OPEN"] = "OPEN";
191
- CircuitBreakerState2["HALF_OPEN"] = "HALF_OPEN";
192
- return CircuitBreakerState2;
193
- })(CircuitBreakerState || {});
194
- var CircuitBreaker = class {
195
- constructor(config = {}) {
196
- this.state = "CLOSED" /* CLOSED */;
197
- this.failureCount = 0;
198
- this.successCount = 0;
199
- this.lastFailureTime = null;
200
- this.failures = [];
201
- this.config = {
202
- failureThreshold: 5,
203
- successThreshold: 2,
204
- resetTimeoutMs: 6e4,
205
- // 1 minute
206
- windowMs: 3e4,
207
- // 30 seconds
208
- isRetryable: (err) => err instanceof Error,
209
- ...config
210
- };
211
- }
212
- /**
213
- * Execute function with circuit breaker protection
214
- */
215
- async execute(fn) {
216
- if (this.state === "OPEN" /* OPEN */) {
217
- if (Date.now() - (this.lastFailureTime || 0) > this.config.resetTimeoutMs) {
218
- this.state = "HALF_OPEN" /* HALF_OPEN */;
219
- this.successCount = 0;
220
- } else {
221
- throw new Error(`Circuit breaker is OPEN. Retry after ${this.config.resetTimeoutMs}ms`);
222
- }
223
- }
224
- try {
225
- const result = await fn();
226
- this.onSuccess();
227
- return result;
228
- } catch (error) {
229
- this.onFailure(error);
230
- throw error;
231
- }
232
- }
233
- onSuccess() {
234
- this.failureCount = 0;
235
- this.failures = this.failures.filter((f) => Date.now() - f.timestamp < this.config.windowMs);
236
- if (this.state === "HALF_OPEN" /* HALF_OPEN */) {
237
- this.successCount++;
238
- if (this.successCount >= this.config.successThreshold) {
239
- this.state = "CLOSED" /* CLOSED */;
240
- }
241
- }
242
- }
243
- onFailure(error) {
244
- this.lastFailureTime = Date.now();
245
- this.failureCount++;
246
- this.failures.push({ timestamp: Date.now(), error });
247
- this.failures = this.failures.filter((f) => Date.now() - f.timestamp < this.config.windowMs);
248
- if (this.state === "HALF_OPEN" /* HALF_OPEN */) {
249
- this.state = "OPEN" /* OPEN */;
250
- } else if (this.failureCount >= this.config.failureThreshold) {
251
- this.state = "OPEN" /* OPEN */;
252
- console.error(`Circuit breaker OPEN after ${this.failureCount} failures: ${error.message}`);
253
- }
254
- }
255
- get currentState() {
256
- return this.state;
257
- }
258
- /**
259
- * Get current circuit breaker state (accessor method)
260
- */
261
- getState() {
262
- if (this.state === "OPEN" /* OPEN */ && Date.now() - (this.lastFailureTime || 0) > this.config.resetTimeoutMs) {
263
- return "HALF_OPEN" /* HALF_OPEN */;
264
- }
265
- return this.state;
266
- }
267
- /**
268
- * Get circuit breaker metrics
269
- */
270
- getMetrics() {
271
- return {
272
- state: this.state,
273
- totalFailures: this.failureCount,
274
- totalSuccesses: this.successCount,
275
- lastFailureTime: this.lastFailureTime,
276
- totalRequests: this.failureCount + this.successCount
277
- };
278
- }
279
- };
280
- async function retryWithBackoff(fn, config = {}) {
281
- const cfg = {
282
- maxAttempts: 3,
283
- initialBackoffMs: 100,
284
- maxBackoffMs: 1e4,
285
- multiplier: 2,
286
- jitter: true,
287
- isRetryable: (err, attempt) => attempt < cfg.maxAttempts,
288
- ...config
289
- };
290
- let lastError = null;
291
- for (let attempt = 1; attempt <= cfg.maxAttempts; attempt++) {
292
- try {
293
- return await fn();
294
- } catch (error) {
295
- lastError = error;
296
- if (!cfg.isRetryable(lastError, attempt)) {
297
- throw lastError;
298
- }
299
- if (attempt < cfg.maxAttempts) {
300
- const backoff = Math.min(
301
- cfg.initialBackoffMs * Math.pow(cfg.multiplier, attempt - 1),
302
- cfg.maxBackoffMs
303
- );
304
- const jitteredBackoff = cfg.jitter ? backoff * (0.5 + Math.random() * 0.5) : backoff;
305
- console.warn(
306
- `Attempt ${attempt} failed: ${lastError.message}. Retrying in ${Math.round(jitteredBackoff)}ms`
307
- );
308
- await sleep(jitteredBackoff);
309
- }
310
- }
311
- }
312
- throw lastError || new Error("Max retry attempts exceeded");
313
- }
314
- function sleep(ms) {
315
- return new Promise((resolve) => setTimeout(resolve, ms));
316
- }
317
- async function withTimeout(promise, timeoutMs) {
318
- return Promise.race([
319
- promise,
320
- new Promise(
321
- (_, reject) => setTimeout(() => reject(new Error(`Operation timeout after ${timeoutMs}ms`)), timeoutMs)
322
- )
323
- ]);
324
- }
325
-
326
- // src/mcp/MCPCircuitBreaker.ts
327
- var MCPCircuitBreaker = class {
328
- constructor(config = {}) {
329
- this.breaker = new CircuitBreaker({
330
- failureThreshold: config.failureThreshold ?? 5,
331
- successThreshold: config.successThreshold ?? 2,
332
- resetTimeoutMs: config.resetTimeoutMs ?? 3e4,
333
- windowMs: config.windowMs ?? 6e4
334
- });
335
- this.baseUrl = config.baseUrl ?? "http://localhost:3000";
336
- }
337
- /**
338
- * Call an MCP tool with circuit breaker protection + retry + timeout
339
- */
340
- async callTool(tool, args, timeoutMs = 15e3) {
341
- try {
342
- const result = await this.breaker.execute(async () => {
343
- return retryWithBackoff(
344
- async () => {
345
- const response = await withTimeout(
346
- fetch(`${this.baseUrl}/api/mcp/tools/${tool}`, {
347
- method: "POST",
348
- headers: { "Content-Type": "application/json" },
349
- body: JSON.stringify({ arguments: args })
350
- }),
351
- timeoutMs
352
- );
353
- if (!response.ok) {
354
- throw new Error(`MCP tool ${tool} failed: ${response.status} ${response.statusText}`);
355
- }
356
- return response.json();
357
- },
358
- {
359
- maxAttempts: 2,
360
- initialBackoffMs: 500,
361
- maxBackoffMs: 3e3
362
- }
363
- );
364
- });
365
- return {
366
- success: true,
367
- content: result,
368
- circuitState: this.breaker.getState()
369
- };
370
- } catch (error) {
371
- return {
372
- success: false,
373
- error: error instanceof Error ? error.message : String(error),
374
- circuitState: this.breaker.getState()
375
- };
376
- }
377
- }
378
- /**
379
- * Get current circuit breaker state
380
- */
381
- getState() {
382
- return this.breaker.getState();
383
- }
384
- /**
385
- * Get circuit breaker metrics
386
- */
387
- getMetrics() {
388
- return this.breaker.getMetrics();
389
- }
390
- /**
391
- * Check if MCP server is available (circuit not open)
392
- */
393
- isAvailable() {
394
- return this.breaker.getState() !== "OPEN" /* OPEN */;
395
- }
396
- };
397
- var defaultInstance = null;
398
- function getMCPCircuitBreaker(config) {
399
- if (!defaultInstance) {
400
- defaultInstance = new MCPCircuitBreaker(config);
401
- }
402
- return defaultInstance;
403
- }
404
-
405
- export { CircuitBreaker, CircuitBreakerState, InteropBindingGenerator, MCPCircuitBreaker, getMCPCircuitBreaker, retryWithBackoff, withTimeout };
406
- //# sourceMappingURL=chunk-5TOFIR6L.js.map
407
- //# sourceMappingURL=chunk-5TOFIR6L.js.map