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