@mindexec/cli 0.2.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 (232) hide show
  1. package/README.md +275 -0
  2. package/codex-runtime.js +960 -0
  3. package/launch-bridge.cjs +162 -0
  4. package/package.json +61 -0
  5. package/port-guard.cjs +232 -0
  6. package/scripts/setup-tree-sitter-grammars.mjs +59 -0
  7. package/server.js +8422 -0
  8. package/start-bridge.bat +32 -0
  9. package/start-bridge.sh +81 -0
  10. package/tree-sitter-grammars/README.md +18 -0
  11. package/tree-sitter-grammars/tree-sitter-c_sharp.wasm +0 -0
  12. package/tree-sitter-grammars/tree-sitter-go.wasm +0 -0
  13. package/tree-sitter-grammars/tree-sitter-java.wasm +0 -0
  14. package/tree-sitter-grammars/tree-sitter-javascript.wasm +0 -0
  15. package/tree-sitter-grammars/tree-sitter-python.wasm +0 -0
  16. package/tree-sitter-grammars/tree-sitter-rust.wasm +0 -0
  17. package/tree-sitter-grammars/tree-sitter-tsx.wasm +0 -0
  18. package/tree-sitter-grammars/tree-sitter-typescript.wasm +0 -0
  19. package/wwwroot/MindExecution.Web.styles.css +3 -0
  20. package/wwwroot/_content/MindExecution.Plugins.Admin/css/admin-dashboard.css +546 -0
  21. package/wwwroot/_content/MindExecution.Plugins.Directory/MindExecution.Plugins.Directory.u7utcng611.bundle.scp.css +7 -0
  22. package/wwwroot/_content/MindExecution.Plugins.Directory/background.png +0 -0
  23. package/wwwroot/_content/MindExecution.Plugins.Directory/directory-manager.js +202 -0
  24. package/wwwroot/_content/MindExecution.Plugins.Directory/exampleJsInterop.js +6 -0
  25. package/wwwroot/_content/MindExecution.Plugins.YouTube/css/youtube-search.css +251 -0
  26. package/wwwroot/_content/MindExecution.Shared/MindExecution.Shared.wsano1j4wp.bundle.scp.css +4 -0
  27. package/wwwroot/_content/MindExecution.Shared/css/admin-dashboard.css +559 -0
  28. package/wwwroot/_content/MindExecution.Shared/css/app.css +1 -0
  29. package/wwwroot/_content/MindExecution.Shared/css/mind-map-overrides.css +2936 -0
  30. package/wwwroot/_content/MindExecution.Shared/fonts/NotoSansKR-Bold.ttf +0 -0
  31. package/wwwroot/_content/MindExecution.Shared/fonts/NotoSansKR-Regular.ttf +0 -0
  32. package/wwwroot/_content/MindExecution.Shared/js/agent-visualization.js +359 -0
  33. package/wwwroot/_content/MindExecution.Shared/js/background-themes.js +1721 -0
  34. package/wwwroot/_content/MindExecution.Shared/js/code-master.js +8316 -0
  35. package/wwwroot/_content/MindExecution.Shared/js/file-system-helper.js +639 -0
  36. package/wwwroot/_content/MindExecution.Shared/js/helpers/InfiniteGridHelper.js +109 -0
  37. package/wwwroot/_content/MindExecution.Shared/js/marked.min.js +69 -0
  38. package/wwwroot/_content/MindExecution.Shared/js/mind-map-core.js +7982 -0
  39. package/wwwroot/_content/MindExecution.Shared/js/mind-map-core.js.backup +1059 -0
  40. package/wwwroot/_content/MindExecution.Shared/js/mind-map-css3d-manager.js +15803 -0
  41. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dev-guards.js +325 -0
  42. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dnd.js +1430 -0
  43. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dnd.js.bak +434 -0
  44. package/wwwroot/_content/MindExecution.Shared/js/mind-map-glow-shader.js +260 -0
  45. package/wwwroot/_content/MindExecution.Shared/js/mind-map-interactions.js +7640 -0
  46. package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-plan-worker.js +160 -0
  47. package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-renderer.js +9923 -0
  48. package/wwwroot/_content/MindExecution.Shared/js/mind-map-logic-workers.js +977 -0
  49. package/wwwroot/_content/MindExecution.Shared/js/mind-map-menu-manager.js +1431 -0
  50. package/wwwroot/_content/MindExecution.Shared/js/mind-map-multi-select.js +1716 -0
  51. package/wwwroot/_content/MindExecution.Shared/js/mind-map-node-search-worker.js +553 -0
  52. package/wwwroot/_content/MindExecution.Shared/js/mind-map-nodes.js +4541 -0
  53. package/wwwroot/_content/MindExecution.Shared/js/mind-map-object-manager.js +489 -0
  54. package/wwwroot/_content/MindExecution.Shared/js/mind-map-object-manager.js.backup +372 -0
  55. package/wwwroot/_content/MindExecution.Shared/js/mind-map-pipeline.js +2075 -0
  56. package/wwwroot/_content/MindExecution.Shared/js/mind-map-text-lod-system.js +646 -0
  57. package/wwwroot/_content/MindExecution.Shared/js/mind-map-text-overlay-v2.js +4323 -0
  58. package/wwwroot/_content/MindExecution.Shared/js/mind-map-texture-factory.js +2260 -0
  59. package/wwwroot/_content/MindExecution.Shared/js/mind-map-texture-factory.js.backup +1258 -0
  60. package/wwwroot/_content/MindExecution.Shared/js/mind-map-visibility-worker.js +890 -0
  61. package/wwwroot/_content/MindExecution.Shared/js/mindmap-toolbar.js +594 -0
  62. package/wwwroot/_content/MindExecution.Shared/js/native-drop-handler.js +170 -0
  63. package/wwwroot/_content/MindExecution.Shared/js/plan-master.js +788 -0
  64. package/wwwroot/_content/MindExecution.Shared/js/renderers/CSS3DRenderer.js +50 -0
  65. package/wwwroot/_content/MindExecution.Shared/js/texture-worker-manager.js +188 -0
  66. package/wwwroot/_content/MindExecution.Shared/js/texture-worker.js +208 -0
  67. package/wwwroot/_content/MindExecution.Shared/js/three.min.js +6 -0
  68. package/wwwroot/_content/MindExecution.Shared/js/titlebar-handler.js +191 -0
  69. package/wwwroot/_content/MindExecution.Shared/js/token-manager.js +37 -0
  70. package/wwwroot/_content/MindExecution.Shared/js/token-worker.js +28 -0
  71. package/wwwroot/_content/MindExecution.Shared/js/troika-bundle.js +5626 -0
  72. package/wwwroot/_content/MindExecution.Shared/js/troika-bundle.js.map +7 -0
  73. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/css/all.min.css +9 -0
  74. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-brands-400.ttf +0 -0
  75. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-brands-400.woff2 +0 -0
  76. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-regular-400.ttf +0 -0
  77. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-regular-400.woff2 +0 -0
  78. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-solid-900.ttf +0 -0
  79. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-solid-900.woff2 +0 -0
  80. package/wwwroot/_content/MindExecution.Shared/models/all-MiniLM-L6-v2-quantized.onnx +0 -0
  81. package/wwwroot/_content/MindExecution.Shared/models/vocab.txt +30522 -0
  82. package/wwwroot/_framework/Google.Protobuf.9h59ukbel7.dll +0 -0
  83. package/wwwroot/_framework/Markdig.d1j7v41cl1.dll +0 -0
  84. package/wwwroot/_framework/MessagePack.Annotations.l6qv48kgpt.dll +0 -0
  85. package/wwwroot/_framework/MessagePack.eqoptzx9d5.dll +0 -0
  86. package/wwwroot/_framework/Microsoft.AspNetCore.Authorization.k7dsih5y5g.dll +0 -0
  87. package/wwwroot/_framework/Microsoft.AspNetCore.Components.6nyje9sa0g.dll +0 -0
  88. package/wwwroot/_framework/Microsoft.AspNetCore.Components.Authorization.iycd6unprw.dll +0 -0
  89. package/wwwroot/_framework/Microsoft.AspNetCore.Components.Web.487u3twia4.dll +0 -0
  90. package/wwwroot/_framework/Microsoft.AspNetCore.Components.WebAssembly.d0gcnmlxxz.dll +0 -0
  91. package/wwwroot/_framework/Microsoft.AspNetCore.Metadata.h4yevl9adi.dll +0 -0
  92. package/wwwroot/_framework/Microsoft.CSharp.qrvp77qmhs.dll +0 -0
  93. package/wwwroot/_framework/Microsoft.Data.Sqlite.jdlxgv2jtg.dll +0 -0
  94. package/wwwroot/_framework/Microsoft.EntityFrameworkCore.4gjazp7kjf.dll +0 -0
  95. package/wwwroot/_framework/Microsoft.EntityFrameworkCore.Abstractions.gocudnvz7b.dll +0 -0
  96. package/wwwroot/_framework/Microsoft.EntityFrameworkCore.Relational.lt4rsvinuo.dll +0 -0
  97. package/wwwroot/_framework/Microsoft.EntityFrameworkCore.Sqlite.69luj0fa9r.dll +0 -0
  98. package/wwwroot/_framework/Microsoft.Extensions.Caching.Abstractions.364t4jh3zz.dll +0 -0
  99. package/wwwroot/_framework/Microsoft.Extensions.Caching.Memory.izlxhpzosu.dll +0 -0
  100. package/wwwroot/_framework/Microsoft.Extensions.Configuration.8zq7hh41o7.dll +0 -0
  101. package/wwwroot/_framework/Microsoft.Extensions.Configuration.Abstractions.8if74zs6ea.dll +0 -0
  102. package/wwwroot/_framework/Microsoft.Extensions.Configuration.Json.duvlngw8i0.dll +0 -0
  103. package/wwwroot/_framework/Microsoft.Extensions.DependencyInjection.Abstractions.t2hh9kvx0o.dll +0 -0
  104. package/wwwroot/_framework/Microsoft.Extensions.DependencyInjection.n4tg99oy8l.dll +0 -0
  105. package/wwwroot/_framework/Microsoft.Extensions.DependencyModel.h0d06ixk3e.dll +0 -0
  106. package/wwwroot/_framework/Microsoft.Extensions.Logging.Abstractions.rl32bkx2sd.dll +0 -0
  107. package/wwwroot/_framework/Microsoft.Extensions.Logging.dlht1xei0t.dll +0 -0
  108. package/wwwroot/_framework/Microsoft.Extensions.Options.qeunebioml.dll +0 -0
  109. package/wwwroot/_framework/Microsoft.Extensions.Primitives.18cr6vnuuz.dll +0 -0
  110. package/wwwroot/_framework/Microsoft.IO.RecyclableMemoryStream.r915vovvw4.dll +0 -0
  111. package/wwwroot/_framework/Microsoft.IdentityModel.Abstractions.1ejljk3erv.dll +0 -0
  112. package/wwwroot/_framework/Microsoft.IdentityModel.JsonWebTokens.1596zr8gne.dll +0 -0
  113. package/wwwroot/_framework/Microsoft.IdentityModel.Logging.229uyvpgio.dll +0 -0
  114. package/wwwroot/_framework/Microsoft.IdentityModel.Tokens.9sibtajc9f.dll +0 -0
  115. package/wwwroot/_framework/Microsoft.JSInterop.17lq4j1j7g.dll +0 -0
  116. package/wwwroot/_framework/Microsoft.JSInterop.WebAssembly.ryia5gxiad.dll +0 -0
  117. package/wwwroot/_framework/Microsoft.ML.OnnxRuntime.w9deo1m5ss.dll +0 -0
  118. package/wwwroot/_framework/Microsoft.ML.Tokenizers.cm2vuv2z61.dll +0 -0
  119. package/wwwroot/_framework/Microsoft.NET.StringTools.3qbrf4v2ki.dll +0 -0
  120. package/wwwroot/_framework/MimeMapping.og9ys58ylm.dll +0 -0
  121. package/wwwroot/_framework/MindExecution.Core.1q1trifbuu.dll +0 -0
  122. package/wwwroot/_framework/MindExecution.Kernel.gwwc40sc45.dll +0 -0
  123. package/wwwroot/_framework/MindExecution.Plugins.Admin.0jgrn1sckv.dll +0 -0
  124. package/wwwroot/_framework/MindExecution.Plugins.Business.13mme2qcag.dll +0 -0
  125. package/wwwroot/_framework/MindExecution.Plugins.Concept.dfp2mdt45q.dll +0 -0
  126. package/wwwroot/_framework/MindExecution.Plugins.Directory.3w4t6n3se0.dll +0 -0
  127. package/wwwroot/_framework/MindExecution.Plugins.PlanMaster.s0qpntz420.dll +0 -0
  128. package/wwwroot/_framework/MindExecution.Plugins.YouTube.iu11fq8d16.dll +0 -0
  129. package/wwwroot/_framework/MindExecution.Shared.7j27dcqnrc.dll +0 -0
  130. package/wwwroot/_framework/MindExecution.Web.pq1ty8ov2v.dll +0 -0
  131. package/wwwroot/_framework/Newtonsoft.Json.a56zs13vug.dll +0 -0
  132. package/wwwroot/_framework/SQLitePCLRaw.batteries_v2.rrd1nzawpp.dll +0 -0
  133. package/wwwroot/_framework/SQLitePCLRaw.core.1dxloztpfz.dll +0 -0
  134. package/wwwroot/_framework/SQLitePCLRaw.provider.e_sqlite3.oekyzl53i1.dll +0 -0
  135. package/wwwroot/_framework/Supabase.Core.s1pkj4aj0l.dll +0 -0
  136. package/wwwroot/_framework/Supabase.Functions.qz4nu782sg.dll +0 -0
  137. package/wwwroot/_framework/Supabase.Gotrue.twah27pkik.dll +0 -0
  138. package/wwwroot/_framework/Supabase.Postgrest.gmuuv369ih.dll +0 -0
  139. package/wwwroot/_framework/Supabase.Realtime.ox3kchdy3w.dll +0 -0
  140. package/wwwroot/_framework/Supabase.Storage.fnjnepaowr.dll +0 -0
  141. package/wwwroot/_framework/Supabase.azmaw5pgcz.dll +0 -0
  142. package/wwwroot/_framework/System.Collections.Concurrent.y1zmvuyipi.dll +0 -0
  143. package/wwwroot/_framework/System.Collections.Immutable.ug3j698qms.dll +0 -0
  144. package/wwwroot/_framework/System.Collections.NonGeneric.h66hj3863h.dll +0 -0
  145. package/wwwroot/_framework/System.Collections.Specialized.umr3y27ntj.dll +0 -0
  146. package/wwwroot/_framework/System.Collections.x53e19vfsj.dll +0 -0
  147. package/wwwroot/_framework/System.ComponentModel.Annotations.tz6gnt4ebt.dll +0 -0
  148. package/wwwroot/_framework/System.ComponentModel.Primitives.j7tiphu4rg.dll +0 -0
  149. package/wwwroot/_framework/System.ComponentModel.TypeConverter.ujlztox1gx.dll +0 -0
  150. package/wwwroot/_framework/System.ComponentModel.x9xz0ojfb6.dll +0 -0
  151. package/wwwroot/_framework/System.Console.ijzpqmj7ne.dll +0 -0
  152. package/wwwroot/_framework/System.Data.Common.1r0sqffq1p.dll +0 -0
  153. package/wwwroot/_framework/System.Diagnostics.DiagnosticSource.9upoqwq09o.dll +0 -0
  154. package/wwwroot/_framework/System.Diagnostics.Process.m99azzntjm.dll +0 -0
  155. package/wwwroot/_framework/System.Diagnostics.TraceSource.pl7wv26myr.dll +0 -0
  156. package/wwwroot/_framework/System.Diagnostics.Tracing.crlhfx6tut.dll +0 -0
  157. package/wwwroot/_framework/System.Drawing.Primitives.22e4y9ikq9.dll +0 -0
  158. package/wwwroot/_framework/System.Drawing.mi7d8hwowb.dll +0 -0
  159. package/wwwroot/_framework/System.Formats.Asn1.jx23sjiqnn.dll +0 -0
  160. package/wwwroot/_framework/System.IO.Compression.6fyoii3uej.dll +0 -0
  161. package/wwwroot/_framework/System.IO.Pipelines.vg77t4cd4d.dll +0 -0
  162. package/wwwroot/_framework/System.IdentityModel.Tokens.Jwt.t67es60z5b.dll +0 -0
  163. package/wwwroot/_framework/System.Linq.1bkoxlqgmq.dll +0 -0
  164. package/wwwroot/_framework/System.Linq.Expressions.24xqiypwdt.dll +0 -0
  165. package/wwwroot/_framework/System.Linq.Queryable.hvd01d6rsa.dll +0 -0
  166. package/wwwroot/_framework/System.Memory.8dx3lwgym4.dll +0 -0
  167. package/wwwroot/_framework/System.Net.Http.Json.3mhdm9l1rf.dll +0 -0
  168. package/wwwroot/_framework/System.Net.Http.eitrz660my.dll +0 -0
  169. package/wwwroot/_framework/System.Net.NetworkInformation.3pkuofcv9r.dll +0 -0
  170. package/wwwroot/_framework/System.Net.Ping.8clj5pklrp.dll +0 -0
  171. package/wwwroot/_framework/System.Net.Primitives.qrp4wcjz1p.dll +0 -0
  172. package/wwwroot/_framework/System.Net.WebSockets.Client.2u6pv01g69.dll +0 -0
  173. package/wwwroot/_framework/System.Net.WebSockets.qp6u31zvm5.dll +0 -0
  174. package/wwwroot/_framework/System.Numerics.Tensors.0c7z4mt3on.dll +0 -0
  175. package/wwwroot/_framework/System.Numerics.Vectors.kc7ufp2j4l.dll +0 -0
  176. package/wwwroot/_framework/System.ObjectModel.qv82fot1ib.dll +0 -0
  177. package/wwwroot/_framework/System.Private.CoreLib.rkafq04oma.dll +0 -0
  178. package/wwwroot/_framework/System.Private.Uri.t9542hmr6j.dll +0 -0
  179. package/wwwroot/_framework/System.Private.Xml.Linq.n8n3ptrbwu.dll +0 -0
  180. package/wwwroot/_framework/System.Private.Xml.rxd3tytisn.dll +0 -0
  181. package/wwwroot/_framework/System.Reactive.t3fuon548l.dll +0 -0
  182. package/wwwroot/_framework/System.Reflection.Emit.9tjhp6y0j3.dll +0 -0
  183. package/wwwroot/_framework/System.Reflection.Emit.ILGeneration.stxyk8zoo1.dll +0 -0
  184. package/wwwroot/_framework/System.Reflection.Emit.Lightweight.6xrd5v8vg0.dll +0 -0
  185. package/wwwroot/_framework/System.Reflection.Primitives.wgn8fpwwvv.dll +0 -0
  186. package/wwwroot/_framework/System.Runtime.InteropServices.JavaScript.sliym526xh.dll +0 -0
  187. package/wwwroot/_framework/System.Runtime.InteropServices.RuntimeInformation.oji7zut14z.dll +0 -0
  188. package/wwwroot/_framework/System.Runtime.InteropServices.te07xr2we9.dll +0 -0
  189. package/wwwroot/_framework/System.Runtime.Intrinsics.507y4h8nzq.dll +0 -0
  190. package/wwwroot/_framework/System.Runtime.Loader.v7gk4bse0k.dll +0 -0
  191. package/wwwroot/_framework/System.Runtime.Numerics.eqy5xjv3nd.dll +0 -0
  192. package/wwwroot/_framework/System.Runtime.Serialization.Formatters.zpkrub8lab.dll +0 -0
  193. package/wwwroot/_framework/System.Runtime.Serialization.Primitives.vhkpnbxjip.dll +0 -0
  194. package/wwwroot/_framework/System.Runtime.jn319d5nyg.dll +0 -0
  195. package/wwwroot/_framework/System.Security.Claims.0ztig1q9vo.dll +0 -0
  196. package/wwwroot/_framework/System.Security.Cryptography.vttizqc9ho.dll +0 -0
  197. package/wwwroot/_framework/System.Text.Encoding.Extensions.utdd47ny8f.dll +0 -0
  198. package/wwwroot/_framework/System.Text.Encodings.Web.wah8r1zoe0.dll +0 -0
  199. package/wwwroot/_framework/System.Text.Json.kxlfxj0wrs.dll +0 -0
  200. package/wwwroot/_framework/System.Text.RegularExpressions.dbqn58klox.dll +0 -0
  201. package/wwwroot/_framework/System.Threading.42ao9vi047.dll +0 -0
  202. package/wwwroot/_framework/System.Threading.Channels.hfa7j0uv2w.dll +0 -0
  203. package/wwwroot/_framework/System.Threading.Thread.caul0pdqul.dll +0 -0
  204. package/wwwroot/_framework/System.Transactions.Local.fimi2hamzo.dll +0 -0
  205. package/wwwroot/_framework/System.Web.HttpUtility.gq8yz50p2e.dll +0 -0
  206. package/wwwroot/_framework/System.Xml.Linq.kitin4zjoj.dll +0 -0
  207. package/wwwroot/_framework/System.Xml.ReaderWriter.kzvw3qgxb0.dll +0 -0
  208. package/wwwroot/_framework/System.Xml.XDocument.c539ki6cuq.dll +0 -0
  209. package/wwwroot/_framework/System.m05i39uvk9.dll +0 -0
  210. package/wwwroot/_framework/Websocket.Client.vapounvmnl.dll +0 -0
  211. package/wwwroot/_framework/blazor.boot.json +305 -0
  212. package/wwwroot/_framework/blazor.webassembly.js +1 -0
  213. package/wwwroot/_framework/dotnet.js +4 -0
  214. package/wwwroot/_framework/dotnet.native.vz0adxojrz.wasm +0 -0
  215. package/wwwroot/_framework/dotnet.native.xsn1d6x2kd.js +16 -0
  216. package/wwwroot/_framework/dotnet.runtime.dstopyvqzi.js +4 -0
  217. package/wwwroot/_framework/icudt_CJK.tjcz0u77k5.dat +0 -0
  218. package/wwwroot/_framework/icudt_EFIGS.tptq2av103.dat +0 -0
  219. package/wwwroot/_framework/icudt_no_CJK.lfu7j35m59.dat +0 -0
  220. package/wwwroot/_framework/netstandard.0xet7jg7ky.dll +0 -0
  221. package/wwwroot/_headers +40 -0
  222. package/wwwroot/_redirects +1 -0
  223. package/wwwroot/appsettings.json +71 -0
  224. package/wwwroot/icon-192.png +0 -0
  225. package/wwwroot/icon-512.png +0 -0
  226. package/wwwroot/index.html +710 -0
  227. package/wwwroot/js/marketing-tool.js +180 -0
  228. package/wwwroot/manifest.webmanifest +22 -0
  229. package/wwwroot/robots.txt +4 -0
  230. package/wwwroot/service-worker-assets.js +857 -0
  231. package/wwwroot/service-worker.js +33 -0
  232. package/wwwroot/sitemap.xml +27 -0
@@ -0,0 +1,553 @@
1
+ 'use strict';
2
+
3
+ const MAX_PROMPT_CHARS = 2048;
4
+ const MAX_RESPONSE_CHARS = 16000;
5
+ const MAX_METADATA_TEXT_CHARS = 8192;
6
+ const MAX_SOURCE_PATH_CHARS = 2048;
7
+ const NGRAM_SIZE = 3;
8
+ const SEARCH_VIEWPORT_FOV_DEGREES = 45;
9
+ const SEARCH_VIEWPORT_ASPECT_RATIO_FALLBACK = 1.6;
10
+ const SEARCH_VIEWPORT_IN_VIEW_BONUS = 4;
11
+ const SEARCH_VIEWPORT_CENTER_BOOST_MAX = 8;
12
+ const SEARCH_VIEWPORT_NEAR_MARGIN = 1.35;
13
+ const TOKEN_REGEX = /[\p{L}\p{M}\p{N}]{2,}/gu;
14
+
15
+ function createState() {
16
+ return {
17
+ boardId: '',
18
+ documents: new Map(),
19
+ tokenIndex: new Map(),
20
+ prefixIndex: new Map(),
21
+ ngramIndex: new Map()
22
+ };
23
+ }
24
+
25
+ let runtime = createState();
26
+
27
+ function normalizeBoardId(boardId) {
28
+ return String(boardId ?? '').trim();
29
+ }
30
+
31
+ function limitText(value, maxLength) {
32
+ const text = String(value ?? '');
33
+ if (!text) {
34
+ return '';
35
+ }
36
+
37
+ return text.length <= maxLength
38
+ ? text
39
+ : text.slice(0, maxLength);
40
+ }
41
+
42
+ function shouldIndexResponse(contentType) {
43
+ return contentType === 'text'
44
+ || contentType === 'note'
45
+ || contentType === 'memo'
46
+ || contentType === 'markdown'
47
+ || contentType === 'code'
48
+ || contentType === 'directory';
49
+ }
50
+
51
+ function buildMetadataText(metadata) {
52
+ if (!metadata) {
53
+ return '';
54
+ }
55
+
56
+ if (typeof metadata === 'string') {
57
+ return limitText(metadata, MAX_METADATA_TEXT_CHARS);
58
+ }
59
+
60
+ const values = [];
61
+ const entries = Array.isArray(metadata)
62
+ ? metadata
63
+ : Object.entries(metadata);
64
+ for (let i = 0; i < entries.length; i++) {
65
+ const entry = entries[i];
66
+ if (Array.isArray(entry)) {
67
+ const key = limitText(entry[0], 128).trim();
68
+ const value = limitText(entry[1], 1024).trim();
69
+ if (key) values.push(key);
70
+ if (value) values.push(value);
71
+ } else if (entry) {
72
+ const value = limitText(entry, 1024).trim();
73
+ if (value) values.push(value);
74
+ }
75
+
76
+ if (values.join(' ').length >= MAX_METADATA_TEXT_CHARS) {
77
+ break;
78
+ }
79
+ }
80
+
81
+ return limitText(values.join(' '), MAX_METADATA_TEXT_CHARS);
82
+ }
83
+
84
+ function normalizeText(value) {
85
+ if (value === null || value === undefined) {
86
+ return '';
87
+ }
88
+
89
+ let normalized = String(value);
90
+ if (!normalized.trim()) {
91
+ return '';
92
+ }
93
+
94
+ try {
95
+ normalized = normalized.normalize('NFKC');
96
+ } catch {
97
+ }
98
+
99
+ normalized = normalized.toLowerCase();
100
+
101
+ let result = '';
102
+ let wroteWhitespace = false;
103
+ for (let i = 0; i < normalized.length; i++) {
104
+ const ch = normalized[i];
105
+ if (/\s/u.test(ch)) {
106
+ if (!wroteWhitespace) {
107
+ result += ' ';
108
+ wroteWhitespace = true;
109
+ }
110
+ continue;
111
+ }
112
+
113
+ const code = ch.codePointAt(0);
114
+ if (typeof code === 'number' && code <= 31) {
115
+ continue;
116
+ }
117
+
118
+ result += ch;
119
+ wroteWhitespace = false;
120
+ }
121
+
122
+ return result.trim();
123
+ }
124
+
125
+ function removeWhitespace(value) {
126
+ return String(value ?? '').replace(/\s+/gu, '');
127
+ }
128
+
129
+ function extractTokens(normalizedText) {
130
+ if (!normalizedText) {
131
+ return [];
132
+ }
133
+
134
+ const matches = normalizedText.match(TOKEN_REGEX);
135
+ if (!matches || matches.length === 0) {
136
+ return [];
137
+ }
138
+
139
+ return matches.filter((token) => token.length >= 2);
140
+ }
141
+
142
+ function buildPrefixes(tokens) {
143
+ const prefixes = [];
144
+ for (let i = 0; i < tokens.length; i++) {
145
+ const token = tokens[i];
146
+ if (!token) {
147
+ continue;
148
+ }
149
+
150
+ const maxLength = Math.min(8, token.length);
151
+ for (let length = 2; length <= maxLength; length++) {
152
+ prefixes.push(token.slice(0, length));
153
+ }
154
+ }
155
+
156
+ return prefixes;
157
+ }
158
+
159
+ function buildNGrams(normalizedCompactText) {
160
+ if (!normalizedCompactText) {
161
+ return [];
162
+ }
163
+
164
+ if (normalizedCompactText.length <= NGRAM_SIZE) {
165
+ return [normalizedCompactText];
166
+ }
167
+
168
+ const ngrams = [];
169
+ for (let i = 0; i <= normalizedCompactText.length - NGRAM_SIZE; i++) {
170
+ ngrams.push(normalizedCompactText.slice(i, i + NGRAM_SIZE));
171
+ }
172
+ return ngrams;
173
+ }
174
+
175
+ function addPosting(index, key, nodeId) {
176
+ if (!key) {
177
+ return;
178
+ }
179
+
180
+ let postings = index.get(key);
181
+ if (!postings) {
182
+ postings = new Set();
183
+ index.set(key, postings);
184
+ }
185
+ postings.add(nodeId);
186
+ }
187
+
188
+ function removePosting(index, key, nodeId) {
189
+ const postings = index.get(key);
190
+ if (!postings) {
191
+ return;
192
+ }
193
+
194
+ postings.delete(nodeId);
195
+ if (postings.size === 0) {
196
+ index.delete(key);
197
+ }
198
+ }
199
+
200
+ function addPostingMatches(index, key, candidateScores, weight) {
201
+ const postings = index.get(key);
202
+ if (!postings) {
203
+ return;
204
+ }
205
+
206
+ postings.forEach((nodeId) => {
207
+ candidateScores.set(
208
+ nodeId,
209
+ Number(candidateScores.get(nodeId) || 0) + weight
210
+ );
211
+ });
212
+ }
213
+
214
+ function clearState(boardId) {
215
+ runtime = createState();
216
+ runtime.boardId = normalizeBoardId(boardId);
217
+ }
218
+
219
+ function normalizeNodeSnapshot(node) {
220
+ if (!node || typeof node !== 'object') {
221
+ return null;
222
+ }
223
+
224
+ const nodeId = String(node.id ?? node.Id ?? '').trim();
225
+ if (!nodeId) {
226
+ return null;
227
+ }
228
+
229
+ const contentType = String(node.contentType ?? node.ContentType ?? '').trim().toLowerCase();
230
+
231
+ return {
232
+ id: nodeId,
233
+ contentType,
234
+ prompt: limitText(node.prompt ?? node.Prompt, MAX_PROMPT_CHARS),
235
+ response: limitText(node.response ?? node.Response, MAX_RESPONSE_CHARS),
236
+ metadataText: buildMetadataText(node.metadataText ?? node.MetadataText ?? node.metadata ?? node.Metadata),
237
+ sourcePath: limitText(node.sourcePath ?? node.SourcePath ?? node.sourceFilePath ?? node.SourceFilePath, MAX_SOURCE_PATH_CHARS),
238
+ positionX: Number(node.positionX ?? node.PositionX ?? node.x ?? 0),
239
+ positionY: Number(node.positionY ?? node.PositionY ?? node.y ?? 0),
240
+ width: Math.max(1, Number(node.width ?? node.Width ?? 1)),
241
+ height: Math.max(1, Number(node.height ?? node.Height ?? 1))
242
+ };
243
+ }
244
+
245
+ function buildDocument(node) {
246
+ const prompt = normalizeText(node.prompt);
247
+ const response = normalizeText(shouldIndexResponse(node.contentType) ? node.response : '');
248
+ const metadataText = normalizeText(node.metadataText);
249
+ const sourcePath = normalizeText(node.sourcePath);
250
+ const normalizedContentType = normalizeText(node.contentType);
251
+
252
+ const combined = [prompt, metadataText, sourcePath, response, normalizedContentType]
253
+ .filter(Boolean)
254
+ .join(' ');
255
+ const tokens = new Set(extractTokens(combined));
256
+ const prefixes = new Set(buildPrefixes(Array.from(tokens)));
257
+ const ngrams = new Set(buildNGrams(removeWhitespace(combined)));
258
+
259
+ return {
260
+ nodeId: node.id,
261
+ contentType: node.contentType,
262
+ positionX: node.positionX,
263
+ positionY: node.positionY,
264
+ width: node.width,
265
+ height: node.height,
266
+ normalizedPrompt: prompt,
267
+ normalizedResponse: response,
268
+ normalizedMetadata: metadataText,
269
+ normalizedSourcePath: sourcePath,
270
+ normalizedContentType,
271
+ tokens,
272
+ prefixes,
273
+ ngrams
274
+ };
275
+ }
276
+
277
+ function removeDocument(nodeId) {
278
+ const existing = runtime.documents.get(nodeId);
279
+ if (!existing) {
280
+ return;
281
+ }
282
+
283
+ existing.tokens.forEach((token) => removePosting(runtime.tokenIndex, token, nodeId));
284
+ existing.prefixes.forEach((prefix) => removePosting(runtime.prefixIndex, prefix, nodeId));
285
+ existing.ngrams.forEach((ngram) => removePosting(runtime.ngramIndex, ngram, nodeId));
286
+ runtime.documents.delete(nodeId);
287
+ }
288
+
289
+ function upsertNode(node) {
290
+ const normalizedNode = normalizeNodeSnapshot(node);
291
+ if (!normalizedNode) {
292
+ return;
293
+ }
294
+
295
+ removeDocument(normalizedNode.id);
296
+
297
+ const document = buildDocument(normalizedNode);
298
+ runtime.documents.set(document.nodeId, document);
299
+
300
+ document.tokens.forEach((token) => addPosting(runtime.tokenIndex, token, document.nodeId));
301
+ document.prefixes.forEach((prefix) => addPosting(runtime.prefixIndex, prefix, document.nodeId));
302
+ document.ngrams.forEach((ngram) => addPosting(runtime.ngramIndex, ngram, document.nodeId));
303
+ }
304
+
305
+ function rebuildBoard(boardId, nodes) {
306
+ clearState(boardId);
307
+ const sourceNodes = Array.isArray(nodes) ? nodes : [];
308
+ for (let i = 0; i < sourceNodes.length; i++) {
309
+ upsertNode(sourceNodes[i]);
310
+ }
311
+ }
312
+
313
+ function scoreDocument(document, normalizedQuery, queryTokens, queryNGrams) {
314
+ let score = 0;
315
+
316
+ if (document.normalizedPrompt === normalizedQuery) {
317
+ score += 120;
318
+ } else if (document.normalizedPrompt.includes(normalizedQuery)) {
319
+ score += 54;
320
+ }
321
+
322
+ if (document.normalizedMetadata.includes(normalizedQuery)) {
323
+ score += 26;
324
+ }
325
+
326
+ if (document.normalizedSourcePath.includes(normalizedQuery)) {
327
+ score += 18;
328
+ }
329
+
330
+ if (document.normalizedResponse.includes(normalizedQuery)) {
331
+ score += 14;
332
+ }
333
+
334
+ if (document.normalizedContentType.includes(normalizedQuery)) {
335
+ score += 8;
336
+ }
337
+
338
+ for (let i = 0; i < queryTokens.length; i++) {
339
+ const token = queryTokens[i];
340
+ if (document.tokens.has(token)) {
341
+ score += 7;
342
+ }
343
+
344
+ if (document.normalizedPrompt.startsWith(token)) {
345
+ score += 10;
346
+ }
347
+ }
348
+
349
+ for (let i = 0; i < queryNGrams.length; i++) {
350
+ if (document.ngrams.has(queryNGrams[i])) {
351
+ score += 0.85;
352
+ }
353
+ }
354
+
355
+ return score;
356
+ }
357
+
358
+ function calculateViewportBoost(document, camera) {
359
+ if (!camera) {
360
+ return 0;
361
+ }
362
+
363
+ const cameraZ = Math.max(400, Number(camera.z || 0) || 1200);
364
+ const aspect = Math.max(0.1, Number(camera.aspect || SEARCH_VIEWPORT_ASPECT_RATIO_FALLBACK));
365
+ const halfViewHeight = Math.max(
366
+ 480,
367
+ cameraZ * Math.tan((SEARCH_VIEWPORT_FOV_DEGREES * Math.PI / 180) / 2)
368
+ );
369
+ const halfViewWidth = halfViewHeight * aspect;
370
+
371
+ const nodeWidth = Math.max(1, Number(document.width || 1));
372
+ const nodeHeight = Math.max(1, Number(document.height || 1));
373
+ const centerX = Number(document.positionX || 0) + (nodeWidth / 2);
374
+ const centerY = Number(document.positionY || 0) - (nodeHeight / 2);
375
+ const normalizedX = Math.abs(centerX - Number(camera.x || 0)) / Math.max(1, halfViewWidth);
376
+ const normalizedY = Math.abs(centerY - Number(camera.y || 0)) / Math.max(1, halfViewHeight);
377
+ const radialDistance = Math.sqrt((normalizedX * normalizedX) + (normalizedY * normalizedY));
378
+
379
+ if (radialDistance <= 1) {
380
+ return SEARCH_VIEWPORT_IN_VIEW_BONUS + ((1 - radialDistance) * SEARCH_VIEWPORT_CENTER_BOOST_MAX);
381
+ }
382
+
383
+ if (radialDistance <= SEARCH_VIEWPORT_NEAR_MARGIN) {
384
+ const falloff = 1 - ((radialDistance - 1) / Math.max(0.001, SEARCH_VIEWPORT_NEAR_MARGIN - 1));
385
+ return Math.max(0, falloff) * (SEARCH_VIEWPORT_IN_VIEW_BONUS * 0.75);
386
+ }
387
+
388
+ return 0;
389
+ }
390
+
391
+ function handleSearchQuery(message) {
392
+ const boardId = normalizeBoardId(message.boardId);
393
+ if (!boardId || boardId !== runtime.boardId) {
394
+ self.postMessage({
395
+ type: 'SEARCH_RESULT',
396
+ boardId,
397
+ seq: Number(message.seq || 0),
398
+ query: String(message.query || ''),
399
+ hits: []
400
+ });
401
+ return;
402
+ }
403
+
404
+ const startedAt = (typeof performance !== 'undefined' && typeof performance.now === 'function')
405
+ ? performance.now()
406
+ : Date.now();
407
+ const normalizedLimit = Math.max(1, Number(message.limit || 30));
408
+ const normalizedQuery = normalizeText(message.query);
409
+ if (!normalizedQuery) {
410
+ self.postMessage({
411
+ type: 'SEARCH_RESULT',
412
+ boardId,
413
+ seq: Number(message.seq || 0),
414
+ query: String(message.query || ''),
415
+ hits: []
416
+ });
417
+ return;
418
+ }
419
+
420
+ const allowedContentTypes = Array.isArray(message.contentTypes) && message.contentTypes.length > 0
421
+ ? new Set(
422
+ message.contentTypes
423
+ .map((value) => String(value || '').trim().toLowerCase())
424
+ .filter(Boolean)
425
+ )
426
+ : null;
427
+ const queryTokens = extractTokens(normalizedQuery);
428
+ const queryPrefixes = buildPrefixes(queryTokens);
429
+ const queryNGrams = buildNGrams(removeWhitespace(normalizedQuery));
430
+ const candidateScores = new Map();
431
+
432
+ for (let i = 0; i < queryTokens.length; i++) {
433
+ addPostingMatches(runtime.tokenIndex, queryTokens[i], candidateScores, 8);
434
+ }
435
+
436
+ for (let i = 0; i < queryPrefixes.length; i++) {
437
+ const prefix = queryPrefixes[i];
438
+ addPostingMatches(runtime.prefixIndex, prefix, candidateScores, prefix.length <= 3 ? 4 : 2);
439
+ }
440
+
441
+ for (let i = 0; i < queryNGrams.length; i++) {
442
+ addPostingMatches(runtime.ngramIndex, queryNGrams[i], candidateScores, 1.15);
443
+ }
444
+
445
+ let candidateIds = [];
446
+ if (candidateScores.size > 0) {
447
+ candidateIds = Array.from(candidateScores.entries())
448
+ .sort((a, b) => {
449
+ if (b[1] !== a[1]) {
450
+ return b[1] - a[1];
451
+ }
452
+ return String(a[0]).localeCompare(String(b[0]));
453
+ })
454
+ .slice(0, Math.max(normalizedLimit * 16, 256))
455
+ .map((entry) => entry[0]);
456
+ } else {
457
+ candidateIds = Array.from(runtime.documents.keys());
458
+ }
459
+
460
+ const ranked = [];
461
+ for (let i = 0; i < candidateIds.length; i++) {
462
+ const document = runtime.documents.get(candidateIds[i]);
463
+ if (!document) {
464
+ continue;
465
+ }
466
+
467
+ if (allowedContentTypes && allowedContentTypes.size > 0 && !allowedContentTypes.has(document.contentType)) {
468
+ continue;
469
+ }
470
+
471
+ const score = scoreDocument(document, normalizedQuery, queryTokens, queryNGrams);
472
+ if (score <= 0) {
473
+ continue;
474
+ }
475
+
476
+ ranked.push({
477
+ nodeId: document.nodeId,
478
+ score: score + calculateViewportBoost(document, message.camera || null)
479
+ });
480
+ }
481
+
482
+ ranked.sort((a, b) => {
483
+ if (b.score !== a.score) {
484
+ return b.score - a.score;
485
+ }
486
+ return String(a.nodeId).localeCompare(String(b.nodeId));
487
+ });
488
+
489
+ const completedAt = (typeof performance !== 'undefined' && typeof performance.now === 'function')
490
+ ? performance.now()
491
+ : Date.now();
492
+
493
+ self.postMessage({
494
+ type: 'SEARCH_RESULT',
495
+ boardId,
496
+ seq: Number(message.seq || 0),
497
+ query: String(message.query || ''),
498
+ hits: ranked.slice(0, normalizedLimit),
499
+ profile: {
500
+ durationMs: Number(Math.max(0, completedAt - startedAt).toFixed(2)),
501
+ candidateCount: candidateIds.length,
502
+ rankedCount: ranked.length
503
+ }
504
+ });
505
+ }
506
+
507
+ self.onmessage = function (event) {
508
+ const message = event?.data || null;
509
+ if (!message || typeof message !== 'object') {
510
+ return;
511
+ }
512
+
513
+ switch (message.type) {
514
+ case 'RESET_BOARD':
515
+ clearState(message.boardId);
516
+ break;
517
+ case 'REBUILD_BOARD':
518
+ rebuildBoard(message.boardId, message.nodes);
519
+ break;
520
+ case 'UPSERT_NODE':
521
+ if (normalizeBoardId(message.boardId) === runtime.boardId) {
522
+ upsertNode(message.node);
523
+ }
524
+ break;
525
+ case 'REMOVE_NODE':
526
+ if (normalizeBoardId(message.boardId) === runtime.boardId) {
527
+ removeDocument(String(message.nodeId || '').trim());
528
+ }
529
+ break;
530
+ case 'BATCH_SYNC':
531
+ if (normalizeBoardId(message.boardId) === runtime.boardId) {
532
+ const removedIds = Array.isArray(message.removedIds) ? message.removedIds : [];
533
+ for (let i = 0; i < removedIds.length; i++) {
534
+ removeDocument(String(removedIds[i] || '').trim());
535
+ }
536
+
537
+ const nodes = Array.isArray(message.nodes) ? message.nodes : [];
538
+ for (let i = 0; i < nodes.length; i++) {
539
+ upsertNode(nodes[i]);
540
+ }
541
+ }
542
+ break;
543
+ case 'SEARCH_QUERY':
544
+ handleSearchQuery(message);
545
+ break;
546
+ default:
547
+ break;
548
+ }
549
+ };
550
+
551
+ self.postMessage({
552
+ type: 'READY'
553
+ });