clodds 1.1.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 (1719) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +468 -0
  3. package/dist/acp/agreement.d.ts +110 -0
  4. package/dist/acp/agreement.js +514 -0
  5. package/dist/acp/agreement.js.map +1 -0
  6. package/dist/acp/discovery.d.ts +84 -0
  7. package/dist/acp/discovery.js +332 -0
  8. package/dist/acp/discovery.js.map +1 -0
  9. package/dist/acp/escrow.d.ts +139 -0
  10. package/dist/acp/escrow.js +880 -0
  11. package/dist/acp/escrow.js.map +1 -0
  12. package/dist/acp/identity.d.ts +135 -0
  13. package/dist/acp/identity.js +716 -0
  14. package/dist/acp/identity.js.map +1 -0
  15. package/dist/acp/index.d.ts +205 -0
  16. package/dist/acp/index.js +583 -0
  17. package/dist/acp/index.js.map +1 -0
  18. package/dist/acp/persistence.d.ts +59 -0
  19. package/dist/acp/persistence.js +590 -0
  20. package/dist/acp/persistence.js.map +1 -0
  21. package/dist/acp/predictions.d.ts +89 -0
  22. package/dist/acp/predictions.js +417 -0
  23. package/dist/acp/predictions.js.map +1 -0
  24. package/dist/acp/registry.d.ts +143 -0
  25. package/dist/acp/registry.js +584 -0
  26. package/dist/acp/registry.js.map +1 -0
  27. package/dist/agents/handlers/acp.d.ts +12 -0
  28. package/dist/agents/handlers/acp.js +987 -0
  29. package/dist/agents/handlers/acp.js.map +1 -0
  30. package/dist/agents/handlers/agentbets.d.ts +8 -0
  31. package/dist/agents/handlers/agentbets.js +63 -0
  32. package/dist/agents/handlers/agentbets.js.map +1 -0
  33. package/dist/agents/handlers/arbitrage.d.ts +16 -0
  34. package/dist/agents/handlers/arbitrage.js +187 -0
  35. package/dist/agents/handlers/arbitrage.js.map +1 -0
  36. package/dist/agents/handlers/betfair.d.ts +11 -0
  37. package/dist/agents/handlers/betfair.js +214 -0
  38. package/dist/agents/handlers/betfair.js.map +1 -0
  39. package/dist/agents/handlers/binance.d.ts +9 -0
  40. package/dist/agents/handlers/binance.js +227 -0
  41. package/dist/agents/handlers/binance.js.map +1 -0
  42. package/dist/agents/handlers/bittensor.d.ts +10 -0
  43. package/dist/agents/handlers/bittensor.js +90 -0
  44. package/dist/agents/handlers/bittensor.js.map +1 -0
  45. package/dist/agents/handlers/bybit.d.ts +9 -0
  46. package/dist/agents/handlers/bybit.js +226 -0
  47. package/dist/agents/handlers/bybit.js.map +1 -0
  48. package/dist/agents/handlers/credentials.d.ts +8 -0
  49. package/dist/agents/handlers/credentials.js +103 -0
  50. package/dist/agents/handlers/credentials.js.map +1 -0
  51. package/dist/agents/handlers/hyperliquid.d.ts +9 -0
  52. package/dist/agents/handlers/hyperliquid.js +326 -0
  53. package/dist/agents/handlers/hyperliquid.js.map +1 -0
  54. package/dist/agents/handlers/index.d.ts +82 -0
  55. package/dist/agents/handlers/index.js +143 -0
  56. package/dist/agents/handlers/index.js.map +1 -0
  57. package/dist/agents/handlers/kalshi.d.ts +10 -0
  58. package/dist/agents/handlers/kalshi.js +1377 -0
  59. package/dist/agents/handlers/kalshi.js.map +1 -0
  60. package/dist/agents/handlers/manifold.d.ts +9 -0
  61. package/dist/agents/handlers/manifold.js +1001 -0
  62. package/dist/agents/handlers/manifold.js.map +1 -0
  63. package/dist/agents/handlers/markets.d.ts +8 -0
  64. package/dist/agents/handlers/markets.js +321 -0
  65. package/dist/agents/handlers/markets.js.map +1 -0
  66. package/dist/agents/handlers/opinion.d.ts +11 -0
  67. package/dist/agents/handlers/opinion.js +374 -0
  68. package/dist/agents/handlers/opinion.js.map +1 -0
  69. package/dist/agents/handlers/paper-trading.d.ts +8 -0
  70. package/dist/agents/handlers/paper-trading.js +124 -0
  71. package/dist/agents/handlers/paper-trading.js.map +1 -0
  72. package/dist/agents/handlers/polymarket.d.ts +17 -0
  73. package/dist/agents/handlers/polymarket.js +455 -0
  74. package/dist/agents/handlers/polymarket.js.map +1 -0
  75. package/dist/agents/handlers/predictfun.d.ts +9 -0
  76. package/dist/agents/handlers/predictfun.js +488 -0
  77. package/dist/agents/handlers/predictfun.js.map +1 -0
  78. package/dist/agents/handlers/smarkets.d.ts +11 -0
  79. package/dist/agents/handlers/smarkets.js +205 -0
  80. package/dist/agents/handlers/smarkets.js.map +1 -0
  81. package/dist/agents/handlers/solana.d.ts +14 -0
  82. package/dist/agents/handlers/solana.js +1530 -0
  83. package/dist/agents/handlers/solana.js.map +1 -0
  84. package/dist/agents/handlers/types.d.ts +58 -0
  85. package/dist/agents/handlers/types.js +34 -0
  86. package/dist/agents/handlers/types.js.map +1 -0
  87. package/dist/agents/handlers/virtuals.d.ts +11 -0
  88. package/dist/agents/handlers/virtuals.js +135 -0
  89. package/dist/agents/handlers/virtuals.js.map +1 -0
  90. package/dist/agents/handlers/wallets.d.ts +9 -0
  91. package/dist/agents/handlers/wallets.js +222 -0
  92. package/dist/agents/handlers/wallets.js.map +1 -0
  93. package/dist/agents/index.d.ts +79 -0
  94. package/dist/agents/index.js +16690 -0
  95. package/dist/agents/index.js.map +1 -0
  96. package/dist/agents/subagents.d.ts +219 -0
  97. package/dist/agents/subagents.js +736 -0
  98. package/dist/agents/subagents.js.map +1 -0
  99. package/dist/alerts/index.d.ts +110 -0
  100. package/dist/alerts/index.js +421 -0
  101. package/dist/alerts/index.js.map +1 -0
  102. package/dist/alerts/realtime.d.ts +114 -0
  103. package/dist/alerts/realtime.js +262 -0
  104. package/dist/alerts/realtime.js.map +1 -0
  105. package/dist/api/apikeys.d.ts +74 -0
  106. package/dist/api/apikeys.js +319 -0
  107. package/dist/api/apikeys.js.map +1 -0
  108. package/dist/api/compute/code.d.ts +28 -0
  109. package/dist/api/compute/code.js +257 -0
  110. package/dist/api/compute/code.js.map +1 -0
  111. package/dist/api/compute/data.d.ts +72 -0
  112. package/dist/api/compute/data.js +264 -0
  113. package/dist/api/compute/data.js.map +1 -0
  114. package/dist/api/compute/gateway.d.ts +185 -0
  115. package/dist/api/compute/gateway.js +958 -0
  116. package/dist/api/compute/gateway.js.map +1 -0
  117. package/dist/api/compute/index.d.ts +21 -0
  118. package/dist/api/compute/index.js +46 -0
  119. package/dist/api/compute/index.js.map +1 -0
  120. package/dist/api/compute/llm.d.ts +64 -0
  121. package/dist/api/compute/llm.js +602 -0
  122. package/dist/api/compute/llm.js.map +1 -0
  123. package/dist/api/compute/persistence.d.ts +77 -0
  124. package/dist/api/compute/persistence.js +251 -0
  125. package/dist/api/compute/persistence.js.map +1 -0
  126. package/dist/api/compute/storage.d.ts +48 -0
  127. package/dist/api/compute/storage.js +283 -0
  128. package/dist/api/compute/storage.js.map +1 -0
  129. package/dist/api/compute/trade.d.ts +69 -0
  130. package/dist/api/compute/trade.js +460 -0
  131. package/dist/api/compute/trade.js.map +1 -0
  132. package/dist/api/compute/types.d.ts +271 -0
  133. package/dist/api/compute/types.js +87 -0
  134. package/dist/api/compute/types.js.map +1 -0
  135. package/dist/api/compute/web.d.ts +29 -0
  136. package/dist/api/compute/web.js +255 -0
  137. package/dist/api/compute/web.js.map +1 -0
  138. package/dist/api/custody.d.ts +48 -0
  139. package/dist/api/custody.js +272 -0
  140. package/dist/api/custody.js.map +1 -0
  141. package/dist/api/fees.d.ts +91 -0
  142. package/dist/api/fees.js +155 -0
  143. package/dist/api/fees.js.map +1 -0
  144. package/dist/api/gateway.d.ts +40 -0
  145. package/dist/api/gateway.js +569 -0
  146. package/dist/api/gateway.js.map +1 -0
  147. package/dist/api/index.d.ts +29 -0
  148. package/dist/api/index.js +55 -0
  149. package/dist/api/index.js.map +1 -0
  150. package/dist/api/jobs.d.ts +59 -0
  151. package/dist/api/jobs.js +362 -0
  152. package/dist/api/jobs.js.map +1 -0
  153. package/dist/api/middleware.d.ts +60 -0
  154. package/dist/api/middleware.js +315 -0
  155. package/dist/api/middleware.js.map +1 -0
  156. package/dist/api/prompt.d.ts +44 -0
  157. package/dist/api/prompt.js +345 -0
  158. package/dist/api/prompt.js.map +1 -0
  159. package/dist/api/sdk.d.ts +258 -0
  160. package/dist/api/sdk.js +341 -0
  161. package/dist/api/sdk.js.map +1 -0
  162. package/dist/api/server.d.ts +17 -0
  163. package/dist/api/server.js +852 -0
  164. package/dist/api/server.js.map +1 -0
  165. package/dist/api/types.d.ts +307 -0
  166. package/dist/api/types.js +64 -0
  167. package/dist/api/types.js.map +1 -0
  168. package/dist/arbitrage/index.d.ts +124 -0
  169. package/dist/arbitrage/index.js +482 -0
  170. package/dist/arbitrage/index.js.map +1 -0
  171. package/dist/auth/copilot.d.ts +87 -0
  172. package/dist/auth/copilot.js +328 -0
  173. package/dist/auth/copilot.js.map +1 -0
  174. package/dist/auth/google.d.ts +121 -0
  175. package/dist/auth/google.js +479 -0
  176. package/dist/auth/google.js.map +1 -0
  177. package/dist/auth/index.d.ts +8 -0
  178. package/dist/auth/index.js +25 -0
  179. package/dist/auth/index.js.map +1 -0
  180. package/dist/auth/oauth.d.ts +94 -0
  181. package/dist/auth/oauth.js +502 -0
  182. package/dist/auth/oauth.js.map +1 -0
  183. package/dist/auth/qwen.d.ts +110 -0
  184. package/dist/auth/qwen.js +351 -0
  185. package/dist/auth/qwen.js.map +1 -0
  186. package/dist/auto-reply/index.d.ts +143 -0
  187. package/dist/auto-reply/index.js +391 -0
  188. package/dist/auto-reply/index.js.map +1 -0
  189. package/dist/automation/cron.d.ts +66 -0
  190. package/dist/automation/cron.js +226 -0
  191. package/dist/automation/cron.js.map +1 -0
  192. package/dist/automation/heartbeats.d.ts +63 -0
  193. package/dist/automation/heartbeats.js +144 -0
  194. package/dist/automation/heartbeats.js.map +1 -0
  195. package/dist/automation/index.d.ts +9 -0
  196. package/dist/automation/index.js +15 -0
  197. package/dist/automation/index.js.map +1 -0
  198. package/dist/automation/webhooks.d.ts +60 -0
  199. package/dist/automation/webhooks.js +225 -0
  200. package/dist/automation/webhooks.js.map +1 -0
  201. package/dist/bankr/client.d.ts +86 -0
  202. package/dist/bankr/client.js +177 -0
  203. package/dist/bankr/client.js.map +1 -0
  204. package/dist/bankr/index.d.ts +6 -0
  205. package/dist/bankr/index.js +23 -0
  206. package/dist/bankr/index.js.map +1 -0
  207. package/dist/base/index.d.ts +6 -0
  208. package/dist/base/index.js +23 -0
  209. package/dist/base/index.js.map +1 -0
  210. package/dist/base/provider.d.ts +27 -0
  211. package/dist/base/provider.js +128 -0
  212. package/dist/base/provider.js.map +1 -0
  213. package/dist/bin/worker.d.ts +31 -0
  214. package/dist/bin/worker.js +127 -0
  215. package/dist/bin/worker.js.map +1 -0
  216. package/dist/bittensor/chutes.d.ts +14 -0
  217. package/dist/bittensor/chutes.js +141 -0
  218. package/dist/bittensor/chutes.js.map +1 -0
  219. package/dist/bittensor/index.d.ts +7 -0
  220. package/dist/bittensor/index.js +13 -0
  221. package/dist/bittensor/index.js.map +1 -0
  222. package/dist/bittensor/persistence.d.ts +8 -0
  223. package/dist/bittensor/persistence.js +188 -0
  224. package/dist/bittensor/persistence.js.map +1 -0
  225. package/dist/bittensor/plugin.d.ts +30 -0
  226. package/dist/bittensor/plugin.js +134 -0
  227. package/dist/bittensor/plugin.js.map +1 -0
  228. package/dist/bittensor/python-runner.d.ts +7 -0
  229. package/dist/bittensor/python-runner.js +83 -0
  230. package/dist/bittensor/python-runner.js.map +1 -0
  231. package/dist/bittensor/server.d.ts +7 -0
  232. package/dist/bittensor/server.js +110 -0
  233. package/dist/bittensor/server.js.map +1 -0
  234. package/dist/bittensor/service.d.ts +7 -0
  235. package/dist/bittensor/service.js +291 -0
  236. package/dist/bittensor/service.js.map +1 -0
  237. package/dist/bittensor/tool.d.ts +45 -0
  238. package/dist/bittensor/tool.js +147 -0
  239. package/dist/bittensor/tool.js.map +1 -0
  240. package/dist/bittensor/types.d.ts +188 -0
  241. package/dist/bittensor/types.js +6 -0
  242. package/dist/bittensor/types.js.map +1 -0
  243. package/dist/bittensor/wallet.d.ts +18 -0
  244. package/dist/bittensor/wallet.js +192 -0
  245. package/dist/bittensor/wallet.js.map +1 -0
  246. package/dist/bridge/wormhole.d.ts +239 -0
  247. package/dist/bridge/wormhole.js +404 -0
  248. package/dist/bridge/wormhole.js.map +1 -0
  249. package/dist/browser/index.d.ts +67 -0
  250. package/dist/browser/index.js +458 -0
  251. package/dist/browser/index.js.map +1 -0
  252. package/dist/cache/index.d.ts +105 -0
  253. package/dist/cache/index.js +306 -0
  254. package/dist/cache/index.js.map +1 -0
  255. package/dist/canvas/index.d.ts +66 -0
  256. package/dist/canvas/index.js +391 -0
  257. package/dist/canvas/index.js.map +1 -0
  258. package/dist/channels/base-adapter.d.ts +126 -0
  259. package/dist/channels/base-adapter.js +416 -0
  260. package/dist/channels/base-adapter.js.map +1 -0
  261. package/dist/channels/bluebubbles/index.d.ts +23 -0
  262. package/dist/channels/bluebubbles/index.js +182 -0
  263. package/dist/channels/bluebubbles/index.js.map +1 -0
  264. package/dist/channels/discord/index.d.ts +25 -0
  265. package/dist/channels/discord/index.js +419 -0
  266. package/dist/channels/discord/index.js.map +1 -0
  267. package/dist/channels/googlechat/index.d.ts +35 -0
  268. package/dist/channels/googlechat/index.js +223 -0
  269. package/dist/channels/googlechat/index.js.map +1 -0
  270. package/dist/channels/imessage/index.d.ts +28 -0
  271. package/dist/channels/imessage/index.js +340 -0
  272. package/dist/channels/imessage/index.js.map +1 -0
  273. package/dist/channels/index.d.ts +58 -0
  274. package/dist/channels/index.js +382 -0
  275. package/dist/channels/index.js.map +1 -0
  276. package/dist/channels/line/index.d.ts +307 -0
  277. package/dist/channels/line/index.js +760 -0
  278. package/dist/channels/line/index.js.map +1 -0
  279. package/dist/channels/matrix/index.d.ts +35 -0
  280. package/dist/channels/matrix/index.js +328 -0
  281. package/dist/channels/matrix/index.js.map +1 -0
  282. package/dist/channels/mattermost/index.d.ts +25 -0
  283. package/dist/channels/mattermost/index.js +239 -0
  284. package/dist/channels/mattermost/index.js.map +1 -0
  285. package/dist/channels/nextcloud-talk/index.d.ts +25 -0
  286. package/dist/channels/nextcloud-talk/index.js +175 -0
  287. package/dist/channels/nextcloud-talk/index.js.map +1 -0
  288. package/dist/channels/nostr/index.d.ts +21 -0
  289. package/dist/channels/nostr/index.js +278 -0
  290. package/dist/channels/nostr/index.js.map +1 -0
  291. package/dist/channels/signal/index.d.ts +33 -0
  292. package/dist/channels/signal/index.js +333 -0
  293. package/dist/channels/signal/index.js.map +1 -0
  294. package/dist/channels/slack/index.d.ts +26 -0
  295. package/dist/channels/slack/index.js +266 -0
  296. package/dist/channels/slack/index.js.map +1 -0
  297. package/dist/channels/teams/index.d.ts +42 -0
  298. package/dist/channels/teams/index.js +312 -0
  299. package/dist/channels/teams/index.js.map +1 -0
  300. package/dist/channels/telegram/index.d.ts +9 -0
  301. package/dist/channels/telegram/index.js +761 -0
  302. package/dist/channels/telegram/index.js.map +1 -0
  303. package/dist/channels/tlon/index.d.ts +25 -0
  304. package/dist/channels/tlon/index.js +236 -0
  305. package/dist/channels/tlon/index.js.map +1 -0
  306. package/dist/channels/twitch/index.d.ts +25 -0
  307. package/dist/channels/twitch/index.js +182 -0
  308. package/dist/channels/twitch/index.js.map +1 -0
  309. package/dist/channels/voice/index.d.ts +31 -0
  310. package/dist/channels/voice/index.js +208 -0
  311. package/dist/channels/voice/index.js.map +1 -0
  312. package/dist/channels/webchat/index.d.ts +29 -0
  313. package/dist/channels/webchat/index.js +366 -0
  314. package/dist/channels/webchat/index.js.map +1 -0
  315. package/dist/channels/whatsapp/index.d.ts +72 -0
  316. package/dist/channels/whatsapp/index.js +767 -0
  317. package/dist/channels/whatsapp/index.js.map +1 -0
  318. package/dist/channels/zalo/index.d.ts +45 -0
  319. package/dist/channels/zalo/index.js +285 -0
  320. package/dist/channels/zalo/index.js.map +1 -0
  321. package/dist/cli/commands/doctor.d.ts +23 -0
  322. package/dist/cli/commands/doctor.js +649 -0
  323. package/dist/cli/commands/doctor.js.map +1 -0
  324. package/dist/cli/commands/gateway.d.ts +6 -0
  325. package/dist/cli/commands/gateway.js +32 -0
  326. package/dist/cli/commands/gateway.js.map +1 -0
  327. package/dist/cli/commands/index.d.ts +31 -0
  328. package/dist/cli/commands/index.js +3743 -0
  329. package/dist/cli/commands/index.js.map +1 -0
  330. package/dist/cli/commands/onboard.d.ts +4 -0
  331. package/dist/cli/commands/onboard.js +334 -0
  332. package/dist/cli/commands/onboard.js.map +1 -0
  333. package/dist/cli/commands/repl.d.ts +11 -0
  334. package/dist/cli/commands/repl.js +185 -0
  335. package/dist/cli/commands/repl.js.map +1 -0
  336. package/dist/cli/commands/skills.d.ts +29 -0
  337. package/dist/cli/commands/skills.js +297 -0
  338. package/dist/cli/commands/skills.js.map +1 -0
  339. package/dist/cli/index.d.ts +12 -0
  340. package/dist/cli/index.js +449 -0
  341. package/dist/cli/index.js.map +1 -0
  342. package/dist/cli/secure.d.ts +14 -0
  343. package/dist/cli/secure.js +626 -0
  344. package/dist/cli/secure.js.map +1 -0
  345. package/dist/commands/index.d.ts +61 -0
  346. package/dist/commands/index.js +290 -0
  347. package/dist/commands/index.js.map +1 -0
  348. package/dist/commands/registry.d.ts +69 -0
  349. package/dist/commands/registry.js +3142 -0
  350. package/dist/commands/registry.js.map +1 -0
  351. package/dist/config/index.d.ts +465 -0
  352. package/dist/config/index.js +1451 -0
  353. package/dist/config/index.js.map +1 -0
  354. package/dist/credentials/index.d.ts +51 -0
  355. package/dist/credentials/index.js +270 -0
  356. package/dist/credentials/index.js.map +1 -0
  357. package/dist/cron/index.d.ts +151 -0
  358. package/dist/cron/index.js +1283 -0
  359. package/dist/cron/index.js.map +1 -0
  360. package/dist/cron/types.d.ts +102 -0
  361. package/dist/cron/types.js +6 -0
  362. package/dist/cron/types.js.map +1 -0
  363. package/dist/daemon/index.d.ts +23 -0
  364. package/dist/daemon/index.js +159 -0
  365. package/dist/daemon/index.js.map +1 -0
  366. package/dist/db/index.d.ts +825 -0
  367. package/dist/db/index.js +3382 -0
  368. package/dist/db/index.js.map +1 -0
  369. package/dist/db/migrations.d.ts +70 -0
  370. package/dist/db/migrations.js +1373 -0
  371. package/dist/db/migrations.js.map +1 -0
  372. package/dist/docker/index.d.ts +188 -0
  373. package/dist/docker/index.js +571 -0
  374. package/dist/docker/index.js.map +1 -0
  375. package/dist/doctor/index.d.ts +47 -0
  376. package/dist/doctor/index.js +379 -0
  377. package/dist/doctor/index.js.map +1 -0
  378. package/dist/embeddings/index.d.ts +65 -0
  379. package/dist/embeddings/index.js +399 -0
  380. package/dist/embeddings/index.js.map +1 -0
  381. package/dist/evm/contracts.d.ts +112 -0
  382. package/dist/evm/contracts.js +332 -0
  383. package/dist/evm/contracts.js.map +1 -0
  384. package/dist/evm/index.d.ts +21 -0
  385. package/dist/evm/index.js +45 -0
  386. package/dist/evm/index.js.map +1 -0
  387. package/dist/evm/multichain.d.ts +87 -0
  388. package/dist/evm/multichain.js +308 -0
  389. package/dist/evm/multichain.js.map +1 -0
  390. package/dist/evm/odos.d.ts +62 -0
  391. package/dist/evm/odos.js +261 -0
  392. package/dist/evm/odos.js.map +1 -0
  393. package/dist/evm/oneinch.d.ts +55 -0
  394. package/dist/evm/oneinch.js +324 -0
  395. package/dist/evm/oneinch.js.map +1 -0
  396. package/dist/evm/transfers.d.ts +83 -0
  397. package/dist/evm/transfers.js +393 -0
  398. package/dist/evm/transfers.js.map +1 -0
  399. package/dist/evm/uniswap.d.ts +56 -0
  400. package/dist/evm/uniswap.js +307 -0
  401. package/dist/evm/uniswap.js.map +1 -0
  402. package/dist/evm/virtuals.d.ts +220 -0
  403. package/dist/evm/virtuals.js +735 -0
  404. package/dist/evm/virtuals.js.map +1 -0
  405. package/dist/evm/wallet.d.ts +96 -0
  406. package/dist/evm/wallet.js +258 -0
  407. package/dist/evm/wallet.js.map +1 -0
  408. package/dist/exchanges/binance-futures/index.d.ts +83 -0
  409. package/dist/exchanges/binance-futures/index.js +394 -0
  410. package/dist/exchanges/binance-futures/index.js.map +1 -0
  411. package/dist/exchanges/bybit/index.d.ts +78 -0
  412. package/dist/exchanges/bybit/index.js +379 -0
  413. package/dist/exchanges/bybit/index.js.map +1 -0
  414. package/dist/exchanges/hyperliquid/index.d.ts +594 -0
  415. package/dist/exchanges/hyperliquid/index.js +1101 -0
  416. package/dist/exchanges/hyperliquid/index.js.map +1 -0
  417. package/dist/exchanges/mexc/index.d.ts +80 -0
  418. package/dist/exchanges/mexc/index.js +389 -0
  419. package/dist/exchanges/mexc/index.js.map +1 -0
  420. package/dist/exchanges/opinion/index.d.ts +128 -0
  421. package/dist/exchanges/opinion/index.js +443 -0
  422. package/dist/exchanges/opinion/index.js.map +1 -0
  423. package/dist/exchanges/predictfun/index.d.ts +107 -0
  424. package/dist/exchanges/predictfun/index.js +398 -0
  425. package/dist/exchanges/predictfun/index.js.map +1 -0
  426. package/dist/execution/auto-redeem.d.ts +55 -0
  427. package/dist/execution/auto-redeem.js +324 -0
  428. package/dist/execution/auto-redeem.js.map +1 -0
  429. package/dist/execution/bracket-orders.d.ts +84 -0
  430. package/dist/execution/bracket-orders.js +387 -0
  431. package/dist/execution/bracket-orders.js.map +1 -0
  432. package/dist/execution/circuit-breaker.d.ts +87 -0
  433. package/dist/execution/circuit-breaker.js +274 -0
  434. package/dist/execution/circuit-breaker.js.map +1 -0
  435. package/dist/execution/dca-persistence.d.ts +47 -0
  436. package/dist/execution/dca-persistence.js +159 -0
  437. package/dist/execution/dca-persistence.js.map +1 -0
  438. package/dist/execution/dca.d.ts +60 -0
  439. package/dist/execution/dca.js +273 -0
  440. package/dist/execution/dca.js.map +1 -0
  441. package/dist/execution/futures.d.ts +162 -0
  442. package/dist/execution/futures.js +1336 -0
  443. package/dist/execution/futures.js.map +1 -0
  444. package/dist/execution/index.d.ts +346 -0
  445. package/dist/execution/index.js +2532 -0
  446. package/dist/execution/index.js.map +1 -0
  447. package/dist/execution/mev-protection.d.ts +150 -0
  448. package/dist/execution/mev-protection.js +377 -0
  449. package/dist/execution/mev-protection.js.map +1 -0
  450. package/dist/execution/order-persistence.d.ts +81 -0
  451. package/dist/execution/order-persistence.js +350 -0
  452. package/dist/execution/order-persistence.js.map +1 -0
  453. package/dist/execution/position-manager.d.ts +142 -0
  454. package/dist/execution/position-manager.js +404 -0
  455. package/dist/execution/position-manager.js.map +1 -0
  456. package/dist/execution/smart-router.d.ts +90 -0
  457. package/dist/execution/smart-router.js +323 -0
  458. package/dist/execution/smart-router.js.map +1 -0
  459. package/dist/execution/trigger-orders.d.ts +81 -0
  460. package/dist/execution/trigger-orders.js +266 -0
  461. package/dist/execution/trigger-orders.js.map +1 -0
  462. package/dist/execution/twap.d.ts +87 -0
  463. package/dist/execution/twap.js +405 -0
  464. package/dist/execution/twap.js.map +1 -0
  465. package/dist/extensions/copilot-proxy/index.d.ts +49 -0
  466. package/dist/extensions/copilot-proxy/index.js +204 -0
  467. package/dist/extensions/copilot-proxy/index.js.map +1 -0
  468. package/dist/extensions/diagnostics-otel/index.d.ts +54 -0
  469. package/dist/extensions/diagnostics-otel/index.js +290 -0
  470. package/dist/extensions/diagnostics-otel/index.js.map +1 -0
  471. package/dist/extensions/google-auth/index.d.ts +71 -0
  472. package/dist/extensions/google-auth/index.js +350 -0
  473. package/dist/extensions/google-auth/index.js.map +1 -0
  474. package/dist/extensions/index.d.ts +11 -0
  475. package/dist/extensions/index.js +29 -0
  476. package/dist/extensions/index.js.map +1 -0
  477. package/dist/extensions/llm-task/index.d.ts +80 -0
  478. package/dist/extensions/llm-task/index.js +248 -0
  479. package/dist/extensions/llm-task/index.js.map +1 -0
  480. package/dist/extensions/lobster/index.d.ts +69 -0
  481. package/dist/extensions/lobster/index.js +178 -0
  482. package/dist/extensions/lobster/index.js.map +1 -0
  483. package/dist/extensions/memory-lancedb/index.d.ts +62 -0
  484. package/dist/extensions/memory-lancedb/index.js +343 -0
  485. package/dist/extensions/memory-lancedb/index.js.map +1 -0
  486. package/dist/extensions/open-prose/index.d.ts +82 -0
  487. package/dist/extensions/open-prose/index.js +565 -0
  488. package/dist/extensions/open-prose/index.js.map +1 -0
  489. package/dist/extensions/qwen-portal/index.d.ts +48 -0
  490. package/dist/extensions/qwen-portal/index.js +161 -0
  491. package/dist/extensions/qwen-portal/index.js.map +1 -0
  492. package/dist/extensions/task-runner/index.d.ts +121 -0
  493. package/dist/extensions/task-runner/index.js +640 -0
  494. package/dist/extensions/task-runner/index.js.map +1 -0
  495. package/dist/farcaster/client.d.ts +101 -0
  496. package/dist/farcaster/client.js +282 -0
  497. package/dist/farcaster/client.js.map +1 -0
  498. package/dist/farcaster/index.d.ts +4 -0
  499. package/dist/farcaster/index.js +21 -0
  500. package/dist/farcaster/index.js.map +1 -0
  501. package/dist/feeds/acled/index.d.ts +86 -0
  502. package/dist/feeds/acled/index.js +215 -0
  503. package/dist/feeds/acled/index.js.map +1 -0
  504. package/dist/feeds/agentbets/index.d.ts +17 -0
  505. package/dist/feeds/agentbets/index.js +137 -0
  506. package/dist/feeds/agentbets/index.js.map +1 -0
  507. package/dist/feeds/betfair/index.d.ts +132 -0
  508. package/dist/feeds/betfair/index.js +640 -0
  509. package/dist/feeds/betfair/index.js.map +1 -0
  510. package/dist/feeds/crypto/index.d.ts +101 -0
  511. package/dist/feeds/crypto/index.js +506 -0
  512. package/dist/feeds/crypto/index.js.map +1 -0
  513. package/dist/feeds/crypto/whale-tracker.d.ts +138 -0
  514. package/dist/feeds/crypto/whale-tracker.js +685 -0
  515. package/dist/feeds/crypto/whale-tracker.js.map +1 -0
  516. package/dist/feeds/descriptors.d.ts +14 -0
  517. package/dist/feeds/descriptors.js +582 -0
  518. package/dist/feeds/descriptors.js.map +1 -0
  519. package/dist/feeds/drift/index.d.ts +23 -0
  520. package/dist/feeds/drift/index.js +182 -0
  521. package/dist/feeds/drift/index.js.map +1 -0
  522. package/dist/feeds/drift/trading.d.ts +75 -0
  523. package/dist/feeds/drift/trading.js +457 -0
  524. package/dist/feeds/drift/trading.js.map +1 -0
  525. package/dist/feeds/external/index.d.ts +48 -0
  526. package/dist/feeds/external/index.js +575 -0
  527. package/dist/feeds/external/index.js.map +1 -0
  528. package/dist/feeds/fred/index.d.ts +134 -0
  529. package/dist/feeds/fred/index.js +263 -0
  530. package/dist/feeds/fred/index.js.map +1 -0
  531. package/dist/feeds/freshness.d.ts +79 -0
  532. package/dist/feeds/freshness.js +259 -0
  533. package/dist/feeds/freshness.js.map +1 -0
  534. package/dist/feeds/hedgehog/index.d.ts +24 -0
  535. package/dist/feeds/hedgehog/index.js +589 -0
  536. package/dist/feeds/hedgehog/index.js.map +1 -0
  537. package/dist/feeds/hedgehog/types.d.ts +215 -0
  538. package/dist/feeds/hedgehog/types.js +7 -0
  539. package/dist/feeds/hedgehog/types.js.map +1 -0
  540. package/dist/feeds/index.d.ts +38 -0
  541. package/dist/feeds/index.js +469 -0
  542. package/dist/feeds/index.js.map +1 -0
  543. package/dist/feeds/kalshi/index.d.ts +116 -0
  544. package/dist/feeds/kalshi/index.js +970 -0
  545. package/dist/feeds/kalshi/index.js.map +1 -0
  546. package/dist/feeds/manifold/index.d.ts +15 -0
  547. package/dist/feeds/manifold/index.js +269 -0
  548. package/dist/feeds/manifold/index.js.map +1 -0
  549. package/dist/feeds/metaculus/index.d.ts +22 -0
  550. package/dist/feeds/metaculus/index.js +149 -0
  551. package/dist/feeds/metaculus/index.js.map +1 -0
  552. package/dist/feeds/news/index.d.ts +20 -0
  553. package/dist/feeds/news/index.js +308 -0
  554. package/dist/feeds/news/index.js.map +1 -0
  555. package/dist/feeds/opinion/index.d.ts +31 -0
  556. package/dist/feeds/opinion/index.js +389 -0
  557. package/dist/feeds/opinion/index.js.map +1 -0
  558. package/dist/feeds/polymarket/index.d.ts +21 -0
  559. package/dist/feeds/polymarket/index.js +501 -0
  560. package/dist/feeds/polymarket/index.js.map +1 -0
  561. package/dist/feeds/polymarket/rtds.d.ts +40 -0
  562. package/dist/feeds/polymarket/rtds.js +159 -0
  563. package/dist/feeds/polymarket/rtds.js.map +1 -0
  564. package/dist/feeds/polymarket/user-ws.d.ts +64 -0
  565. package/dist/feeds/polymarket/user-ws.js +230 -0
  566. package/dist/feeds/polymarket/user-ws.js.map +1 -0
  567. package/dist/feeds/polymarket/whale-tracker.d.ts +152 -0
  568. package/dist/feeds/polymarket/whale-tracker.js +709 -0
  569. package/dist/feeds/polymarket/whale-tracker.js.map +1 -0
  570. package/dist/feeds/predictfun/index.d.ts +24 -0
  571. package/dist/feeds/predictfun/index.js +234 -0
  572. package/dist/feeds/predictfun/index.js.map +1 -0
  573. package/dist/feeds/predictit/index.d.ts +14 -0
  574. package/dist/feeds/predictit/index.js +88 -0
  575. package/dist/feeds/predictit/index.js.map +1 -0
  576. package/dist/feeds/registry.d.ts +148 -0
  577. package/dist/feeds/registry.js +197 -0
  578. package/dist/feeds/registry.js.map +1 -0
  579. package/dist/feeds/smarkets/index.d.ts +76 -0
  580. package/dist/feeds/smarkets/index.js +415 -0
  581. package/dist/feeds/smarkets/index.js.map +1 -0
  582. package/dist/feeds/virtuals/index.d.ts +92 -0
  583. package/dist/feeds/virtuals/index.js +341 -0
  584. package/dist/feeds/virtuals/index.js.map +1 -0
  585. package/dist/feeds/weather-nws/index.d.ts +73 -0
  586. package/dist/feeds/weather-nws/index.js +162 -0
  587. package/dist/feeds/weather-nws/index.js.map +1 -0
  588. package/dist/feeds/weather-openmeteo/index.d.ts +80 -0
  589. package/dist/feeds/weather-openmeteo/index.js +197 -0
  590. package/dist/feeds/weather-openmeteo/index.js.map +1 -0
  591. package/dist/gateway/alerts-routes.d.ts +15 -0
  592. package/dist/gateway/alerts-routes.js +188 -0
  593. package/dist/gateway/alerts-routes.js.map +1 -0
  594. package/dist/gateway/alt-data-routes.d.ts +15 -0
  595. package/dist/gateway/alt-data-routes.js +67 -0
  596. package/dist/gateway/alt-data-routes.js.map +1 -0
  597. package/dist/gateway/api-routes.d.ts +39 -0
  598. package/dist/gateway/api-routes.js +1028 -0
  599. package/dist/gateway/api-routes.js.map +1 -0
  600. package/dist/gateway/audit-routes.d.ts +8 -0
  601. package/dist/gateway/audit-routes.js +61 -0
  602. package/dist/gateway/audit-routes.js.map +1 -0
  603. package/dist/gateway/bracket-routes.d.ts +12 -0
  604. package/dist/gateway/bracket-routes.js +122 -0
  605. package/dist/gateway/bracket-routes.js.map +1 -0
  606. package/dist/gateway/control-ui.d.ts +45 -0
  607. package/dist/gateway/control-ui.js +301 -0
  608. package/dist/gateway/control-ui.js.map +1 -0
  609. package/dist/gateway/copy-trading-routes.d.ts +12 -0
  610. package/dist/gateway/copy-trading-routes.js +159 -0
  611. package/dist/gateway/copy-trading-routes.js.map +1 -0
  612. package/dist/gateway/cron-routes.d.ts +14 -0
  613. package/dist/gateway/cron-routes.js +132 -0
  614. package/dist/gateway/cron-routes.js.map +1 -0
  615. package/dist/gateway/dca-routes.d.ts +8 -0
  616. package/dist/gateway/dca-routes.js +179 -0
  617. package/dist/gateway/dca-routes.js.map +1 -0
  618. package/dist/gateway/embeddings-routes.d.ts +12 -0
  619. package/dist/gateway/embeddings-routes.js +102 -0
  620. package/dist/gateway/embeddings-routes.js.map +1 -0
  621. package/dist/gateway/feeds-routes.d.ts +34 -0
  622. package/dist/gateway/feeds-routes.js +167 -0
  623. package/dist/gateway/feeds-routes.js.map +1 -0
  624. package/dist/gateway/index.d.ts +100 -0
  625. package/dist/gateway/index.js +2321 -0
  626. package/dist/gateway/index.js.map +1 -0
  627. package/dist/gateway/monitoring-routes.d.ts +12 -0
  628. package/dist/gateway/monitoring-routes.js +73 -0
  629. package/dist/gateway/monitoring-routes.js.map +1 -0
  630. package/dist/gateway/opportunity-routes.d.ts +12 -0
  631. package/dist/gateway/opportunity-routes.js +238 -0
  632. package/dist/gateway/opportunity-routes.js.map +1 -0
  633. package/dist/gateway/payments-routes.d.ts +14 -0
  634. package/dist/gateway/payments-routes.js +82 -0
  635. package/dist/gateway/payments-routes.js.map +1 -0
  636. package/dist/gateway/percolator-routes.d.ts +16 -0
  637. package/dist/gateway/percolator-routes.js +139 -0
  638. package/dist/gateway/percolator-routes.js.map +1 -0
  639. package/dist/gateway/queue-routes.d.ts +12 -0
  640. package/dist/gateway/queue-routes.js +47 -0
  641. package/dist/gateway/queue-routes.js.map +1 -0
  642. package/dist/gateway/risk-routes.d.ts +12 -0
  643. package/dist/gateway/risk-routes.js +119 -0
  644. package/dist/gateway/risk-routes.js.map +1 -0
  645. package/dist/gateway/routing-routes.d.ts +12 -0
  646. package/dist/gateway/routing-routes.js +86 -0
  647. package/dist/gateway/routing-routes.js.map +1 -0
  648. package/dist/gateway/server.d.ts +215 -0
  649. package/dist/gateway/server.js +2287 -0
  650. package/dist/gateway/server.js.map +1 -0
  651. package/dist/gateway/shield-routes.d.ts +8 -0
  652. package/dist/gateway/shield-routes.js +88 -0
  653. package/dist/gateway/shield-routes.js.map +1 -0
  654. package/dist/gateway/signal-bus.d.ts +51 -0
  655. package/dist/gateway/signal-bus.js +64 -0
  656. package/dist/gateway/signal-bus.js.map +1 -0
  657. package/dist/gateway/trigger-routes.d.ts +12 -0
  658. package/dist/gateway/trigger-routes.js +127 -0
  659. package/dist/gateway/trigger-routes.js.map +1 -0
  660. package/dist/gateway/twap-routes.d.ts +12 -0
  661. package/dist/gateway/twap-routes.js +142 -0
  662. package/dist/gateway/twap-routes.js.map +1 -0
  663. package/dist/gateway/webhooks-routes.d.ts +31 -0
  664. package/dist/gateway/webhooks-routes.js +107 -0
  665. package/dist/gateway/webhooks-routes.js.map +1 -0
  666. package/dist/gateway/whale-routes.d.ts +12 -0
  667. package/dist/gateway/whale-routes.js +204 -0
  668. package/dist/gateway/whale-routes.js.map +1 -0
  669. package/dist/history/index.d.ts +81 -0
  670. package/dist/history/index.js +362 -0
  671. package/dist/history/index.js.map +1 -0
  672. package/dist/hooks/index.d.ts +279 -0
  673. package/dist/hooks/index.js +739 -0
  674. package/dist/hooks/index.js.map +1 -0
  675. package/dist/i18n/index.d.ts +65 -0
  676. package/dist/i18n/index.js +183 -0
  677. package/dist/i18n/index.js.map +1 -0
  678. package/dist/identity/erc8004.d.ts +104 -0
  679. package/dist/identity/erc8004.js +493 -0
  680. package/dist/identity/erc8004.js.map +1 -0
  681. package/dist/identity/index.d.ts +1 -0
  682. package/dist/identity/index.js +18 -0
  683. package/dist/identity/index.js.map +1 -0
  684. package/dist/index.d.ts +7 -0
  685. package/dist/index.js +240 -0
  686. package/dist/index.js.map +1 -0
  687. package/dist/infra/index.d.ts +133 -0
  688. package/dist/infra/index.js +481 -0
  689. package/dist/infra/index.js.map +1 -0
  690. package/dist/infra/retry.d.ts +132 -0
  691. package/dist/infra/retry.js +450 -0
  692. package/dist/infra/retry.js.map +1 -0
  693. package/dist/ledger/anchor.d.ts +45 -0
  694. package/dist/ledger/anchor.js +271 -0
  695. package/dist/ledger/anchor.js.map +1 -0
  696. package/dist/ledger/hash.d.ts +26 -0
  697. package/dist/ledger/hash.js +69 -0
  698. package/dist/ledger/hash.js.map +1 -0
  699. package/dist/ledger/hooks.d.ts +107 -0
  700. package/dist/ledger/hooks.js +314 -0
  701. package/dist/ledger/hooks.js.map +1 -0
  702. package/dist/ledger/index.d.ts +67 -0
  703. package/dist/ledger/index.js +221 -0
  704. package/dist/ledger/index.js.map +1 -0
  705. package/dist/ledger/storage.d.ts +57 -0
  706. package/dist/ledger/storage.js +368 -0
  707. package/dist/ledger/storage.js.map +1 -0
  708. package/dist/ledger/types.d.ts +138 -0
  709. package/dist/ledger/types.js +16 -0
  710. package/dist/ledger/types.js.map +1 -0
  711. package/dist/link-understanding/index.d.ts +61 -0
  712. package/dist/link-understanding/index.js +320 -0
  713. package/dist/link-understanding/index.js.map +1 -0
  714. package/dist/logging/index.d.ts +50 -0
  715. package/dist/logging/index.js +255 -0
  716. package/dist/logging/index.js.map +1 -0
  717. package/dist/macos/index.d.ts +143 -0
  718. package/dist/macos/index.js +587 -0
  719. package/dist/macos/index.js.map +1 -0
  720. package/dist/markdown/index.d.ts +43 -0
  721. package/dist/markdown/index.js +305 -0
  722. package/dist/markdown/index.js.map +1 -0
  723. package/dist/market-index/index.d.ts +51 -0
  724. package/dist/market-index/index.js +553 -0
  725. package/dist/market-index/index.js.map +1 -0
  726. package/dist/mcp/index.d.ts +263 -0
  727. package/dist/mcp/index.js +940 -0
  728. package/dist/mcp/index.js.map +1 -0
  729. package/dist/mcp/installer.d.ts +11 -0
  730. package/dist/mcp/installer.js +128 -0
  731. package/dist/mcp/installer.js.map +1 -0
  732. package/dist/mcp/server.d.ts +7 -0
  733. package/dist/mcp/server.js +172 -0
  734. package/dist/mcp/server.js.map +1 -0
  735. package/dist/media/index.d.ts +119 -0
  736. package/dist/media/index.js +740 -0
  737. package/dist/media/index.js.map +1 -0
  738. package/dist/memory/context.d.ts +189 -0
  739. package/dist/memory/context.js +541 -0
  740. package/dist/memory/context.js.map +1 -0
  741. package/dist/memory/index.d.ts +74 -0
  742. package/dist/memory/index.js +352 -0
  743. package/dist/memory/index.js.map +1 -0
  744. package/dist/memory/summarizer.d.ts +10 -0
  745. package/dist/memory/summarizer.js +51 -0
  746. package/dist/memory/summarizer.js.map +1 -0
  747. package/dist/memory/tokenizer.d.ts +4 -0
  748. package/dist/memory/tokenizer.js +61 -0
  749. package/dist/memory/tokenizer.js.map +1 -0
  750. package/dist/messages/unified.d.ts +7 -0
  751. package/dist/messages/unified.js +77 -0
  752. package/dist/messages/unified.js.map +1 -0
  753. package/dist/ml-pipeline/collector.d.ts +23 -0
  754. package/dist/ml-pipeline/collector.js +176 -0
  755. package/dist/ml-pipeline/collector.js.map +1 -0
  756. package/dist/ml-pipeline/index.d.ts +21 -0
  757. package/dist/ml-pipeline/index.js +72 -0
  758. package/dist/ml-pipeline/index.js.map +1 -0
  759. package/dist/ml-pipeline/trainer.d.ts +32 -0
  760. package/dist/ml-pipeline/trainer.js +228 -0
  761. package/dist/ml-pipeline/trainer.js.map +1 -0
  762. package/dist/ml-pipeline/types.d.ts +51 -0
  763. package/dist/ml-pipeline/types.js +23 -0
  764. package/dist/ml-pipeline/types.js.map +1 -0
  765. package/dist/models/adaptive.d.ts +11 -0
  766. package/dist/models/adaptive.js +64 -0
  767. package/dist/models/adaptive.js.map +1 -0
  768. package/dist/models/failover.d.ts +51 -0
  769. package/dist/models/failover.js +151 -0
  770. package/dist/models/failover.js.map +1 -0
  771. package/dist/models/index.d.ts +7 -0
  772. package/dist/models/index.js +13 -0
  773. package/dist/models/index.js.map +1 -0
  774. package/dist/monitoring/alerts.d.ts +185 -0
  775. package/dist/monitoring/alerts.js +565 -0
  776. package/dist/monitoring/alerts.js.map +1 -0
  777. package/dist/monitoring/health.d.ts +151 -0
  778. package/dist/monitoring/health.js +423 -0
  779. package/dist/monitoring/health.js.map +1 -0
  780. package/dist/monitoring/index.d.ts +25 -0
  781. package/dist/monitoring/index.js +258 -0
  782. package/dist/monitoring/index.js.map +1 -0
  783. package/dist/monitoring/metrics.d.ts +147 -0
  784. package/dist/monitoring/metrics.js +519 -0
  785. package/dist/monitoring/metrics.js.map +1 -0
  786. package/dist/nodes/index.d.ts +81 -0
  787. package/dist/nodes/index.js +475 -0
  788. package/dist/nodes/index.js.map +1 -0
  789. package/dist/opportunity/analytics.d.ts +221 -0
  790. package/dist/opportunity/analytics.js +678 -0
  791. package/dist/opportunity/analytics.js.map +1 -0
  792. package/dist/opportunity/combinatorial.d.ts +147 -0
  793. package/dist/opportunity/combinatorial.js +765 -0
  794. package/dist/opportunity/combinatorial.js.map +1 -0
  795. package/dist/opportunity/correlation.d.ts +107 -0
  796. package/dist/opportunity/correlation.js +410 -0
  797. package/dist/opportunity/correlation.js.map +1 -0
  798. package/dist/opportunity/executor.d.ts +108 -0
  799. package/dist/opportunity/executor.js +356 -0
  800. package/dist/opportunity/executor.js.map +1 -0
  801. package/dist/opportunity/index.d.ts +285 -0
  802. package/dist/opportunity/index.js +839 -0
  803. package/dist/opportunity/index.js.map +1 -0
  804. package/dist/opportunity/links.d.ts +87 -0
  805. package/dist/opportunity/links.js +344 -0
  806. package/dist/opportunity/links.js.map +1 -0
  807. package/dist/opportunity/matching.d.ts +101 -0
  808. package/dist/opportunity/matching.js +551 -0
  809. package/dist/opportunity/matching.js.map +1 -0
  810. package/dist/opportunity/outcomes.d.ts +74 -0
  811. package/dist/opportunity/outcomes.js +321 -0
  812. package/dist/opportunity/outcomes.js.map +1 -0
  813. package/dist/opportunity/risk.d.ts +128 -0
  814. package/dist/opportunity/risk.js +381 -0
  815. package/dist/opportunity/risk.js.map +1 -0
  816. package/dist/opportunity/scoring.d.ts +151 -0
  817. package/dist/opportunity/scoring.js +421 -0
  818. package/dist/opportunity/scoring.js.map +1 -0
  819. package/dist/pairing/index.d.ts +108 -0
  820. package/dist/pairing/index.js +431 -0
  821. package/dist/pairing/index.js.map +1 -0
  822. package/dist/payments/index.d.ts +12 -0
  823. package/dist/payments/index.js +34 -0
  824. package/dist/payments/index.js.map +1 -0
  825. package/dist/payments/x402/evm.d.ts +53 -0
  826. package/dist/payments/x402/evm.js +282 -0
  827. package/dist/payments/x402/evm.js.map +1 -0
  828. package/dist/payments/x402/index.d.ts +158 -0
  829. package/dist/payments/x402/index.js +531 -0
  830. package/dist/payments/x402/index.js.map +1 -0
  831. package/dist/payments/x402/solana.d.ts +51 -0
  832. package/dist/payments/x402/solana.js +397 -0
  833. package/dist/payments/x402/solana.js.map +1 -0
  834. package/dist/percolator/accounts.d.ts +21 -0
  835. package/dist/percolator/accounts.js +76 -0
  836. package/dist/percolator/accounts.js.map +1 -0
  837. package/dist/percolator/encode.d.ts +14 -0
  838. package/dist/percolator/encode.js +90 -0
  839. package/dist/percolator/encode.js.map +1 -0
  840. package/dist/percolator/execution.d.ts +29 -0
  841. package/dist/percolator/execution.js +239 -0
  842. package/dist/percolator/execution.js.map +1 -0
  843. package/dist/percolator/feed.d.ts +15 -0
  844. package/dist/percolator/feed.js +160 -0
  845. package/dist/percolator/feed.js.map +1 -0
  846. package/dist/percolator/index.d.ts +20 -0
  847. package/dist/percolator/index.js +24 -0
  848. package/dist/percolator/index.js.map +1 -0
  849. package/dist/percolator/instructions.d.ts +29 -0
  850. package/dist/percolator/instructions.js +52 -0
  851. package/dist/percolator/instructions.js.map +1 -0
  852. package/dist/percolator/keeper.d.ts +11 -0
  853. package/dist/percolator/keeper.js +83 -0
  854. package/dist/percolator/keeper.js.map +1 -0
  855. package/dist/percolator/pda.d.ts +15 -0
  856. package/dist/percolator/pda.js +26 -0
  857. package/dist/percolator/pda.js.map +1 -0
  858. package/dist/percolator/slab.d.ts +122 -0
  859. package/dist/percolator/slab.js +325 -0
  860. package/dist/percolator/slab.js.map +1 -0
  861. package/dist/percolator/tx.d.ts +27 -0
  862. package/dist/percolator/tx.js +77 -0
  863. package/dist/percolator/tx.js.map +1 -0
  864. package/dist/percolator/types.d.ts +51 -0
  865. package/dist/percolator/types.js +9 -0
  866. package/dist/percolator/types.js.map +1 -0
  867. package/dist/permissions/index.d.ts +262 -0
  868. package/dist/permissions/index.js +929 -0
  869. package/dist/permissions/index.js.map +1 -0
  870. package/dist/plugins/index.d.ts +158 -0
  871. package/dist/plugins/index.js +444 -0
  872. package/dist/plugins/index.js.map +1 -0
  873. package/dist/portfolio/index.d.ts +170 -0
  874. package/dist/portfolio/index.js +970 -0
  875. package/dist/portfolio/index.js.map +1 -0
  876. package/dist/presence/index.d.ts +34 -0
  877. package/dist/presence/index.js +124 -0
  878. package/dist/presence/index.js.map +1 -0
  879. package/dist/process/index.d.ts +82 -0
  880. package/dist/process/index.js +402 -0
  881. package/dist/process/index.js.map +1 -0
  882. package/dist/providers/discovery.d.ts +209 -0
  883. package/dist/providers/discovery.js +751 -0
  884. package/dist/providers/discovery.js.map +1 -0
  885. package/dist/providers/health.d.ts +27 -0
  886. package/dist/providers/health.js +80 -0
  887. package/dist/providers/health.js.map +1 -0
  888. package/dist/providers/index.d.ts +154 -0
  889. package/dist/providers/index.js +897 -0
  890. package/dist/providers/index.js.map +1 -0
  891. package/dist/queue/index.d.ts +36 -0
  892. package/dist/queue/index.js +146 -0
  893. package/dist/queue/index.js.map +1 -0
  894. package/dist/queue/jobs/index.d.ts +11 -0
  895. package/dist/queue/jobs/index.js +32 -0
  896. package/dist/queue/jobs/index.js.map +1 -0
  897. package/dist/queue/jobs/producer.d.ts +43 -0
  898. package/dist/queue/jobs/producer.js +233 -0
  899. package/dist/queue/jobs/producer.js.map +1 -0
  900. package/dist/queue/jobs/types.d.ts +128 -0
  901. package/dist/queue/jobs/types.js +14 -0
  902. package/dist/queue/jobs/types.js.map +1 -0
  903. package/dist/queue/jobs/worker.d.ts +22 -0
  904. package/dist/queue/jobs/worker.js +220 -0
  905. package/dist/queue/jobs/worker.js.map +1 -0
  906. package/dist/remote/index.d.ts +136 -0
  907. package/dist/remote/index.js +456 -0
  908. package/dist/remote/index.js.map +1 -0
  909. package/dist/risk/circuit-breaker.d.ts +99 -0
  910. package/dist/risk/circuit-breaker.js +300 -0
  911. package/dist/risk/circuit-breaker.js.map +1 -0
  912. package/dist/risk/dashboard.d.ts +69 -0
  913. package/dist/risk/dashboard.js +127 -0
  914. package/dist/risk/dashboard.js.map +1 -0
  915. package/dist/risk/engine.d.ts +128 -0
  916. package/dist/risk/engine.js +311 -0
  917. package/dist/risk/engine.js.map +1 -0
  918. package/dist/risk/index.d.ts +10 -0
  919. package/dist/risk/index.js +38 -0
  920. package/dist/risk/index.js.map +1 -0
  921. package/dist/risk/stress.d.ts +70 -0
  922. package/dist/risk/stress.js +215 -0
  923. package/dist/risk/stress.js.map +1 -0
  924. package/dist/risk/var.d.ts +72 -0
  925. package/dist/risk/var.js +173 -0
  926. package/dist/risk/var.js.map +1 -0
  927. package/dist/risk/volatility.d.ts +61 -0
  928. package/dist/risk/volatility.js +132 -0
  929. package/dist/risk/volatility.js.map +1 -0
  930. package/dist/routing/index.d.ts +116 -0
  931. package/dist/routing/index.js +371 -0
  932. package/dist/routing/index.js.map +1 -0
  933. package/dist/search/index.d.ts +30 -0
  934. package/dist/search/index.js +129 -0
  935. package/dist/search/index.js.map +1 -0
  936. package/dist/security/address-checker.d.ts +6 -0
  937. package/dist/security/address-checker.js +213 -0
  938. package/dist/security/address-checker.js.map +1 -0
  939. package/dist/security/code-scanner.d.ts +3 -0
  940. package/dist/security/code-scanner.js +190 -0
  941. package/dist/security/code-scanner.js.map +1 -0
  942. package/dist/security/index.d.ts +176 -0
  943. package/dist/security/index.js +498 -0
  944. package/dist/security/index.js.map +1 -0
  945. package/dist/security/sanitizer.d.ts +2 -0
  946. package/dist/security/sanitizer.js +135 -0
  947. package/dist/security/sanitizer.js.map +1 -0
  948. package/dist/security/scam-db.d.ts +5 -0
  949. package/dist/security/scam-db.js +116 -0
  950. package/dist/security/scam-db.js.map +1 -0
  951. package/dist/security/shield.d.ts +12 -0
  952. package/dist/security/shield.js +80 -0
  953. package/dist/security/shield.js.map +1 -0
  954. package/dist/security/tx-validator.d.ts +5 -0
  955. package/dist/security/tx-validator.js +115 -0
  956. package/dist/security/tx-validator.js.map +1 -0
  957. package/dist/security/types.d.ts +84 -0
  958. package/dist/security/types.js +6 -0
  959. package/dist/security/types.js.map +1 -0
  960. package/dist/services/alt-data/feeds/fear-greed.d.ts +14 -0
  961. package/dist/services/alt-data/feeds/fear-greed.js +81 -0
  962. package/dist/services/alt-data/feeds/fear-greed.js.map +1 -0
  963. package/dist/services/alt-data/feeds/funding-rates.d.ts +13 -0
  964. package/dist/services/alt-data/feeds/funding-rates.js +90 -0
  965. package/dist/services/alt-data/feeds/funding-rates.js.map +1 -0
  966. package/dist/services/alt-data/feeds/reddit.d.ts +13 -0
  967. package/dist/services/alt-data/feeds/reddit.js +112 -0
  968. package/dist/services/alt-data/feeds/reddit.js.map +1 -0
  969. package/dist/services/alt-data/index.d.ts +31 -0
  970. package/dist/services/alt-data/index.js +278 -0
  971. package/dist/services/alt-data/index.js.map +1 -0
  972. package/dist/services/alt-data/market-matcher.d.ts +29 -0
  973. package/dist/services/alt-data/market-matcher.js +157 -0
  974. package/dist/services/alt-data/market-matcher.js.map +1 -0
  975. package/dist/services/alt-data/sentiment.d.ts +11 -0
  976. package/dist/services/alt-data/sentiment.js +277 -0
  977. package/dist/services/alt-data/sentiment.js.map +1 -0
  978. package/dist/services/alt-data/types.d.ts +86 -0
  979. package/dist/services/alt-data/types.js +9 -0
  980. package/dist/services/alt-data/types.js.map +1 -0
  981. package/dist/services/feature-engineering/accessor.d.ts +19 -0
  982. package/dist/services/feature-engineering/accessor.js +31 -0
  983. package/dist/services/feature-engineering/accessor.js.map +1 -0
  984. package/dist/services/feature-engineering/index.d.ts +15 -0
  985. package/dist/services/feature-engineering/index.js +345 -0
  986. package/dist/services/feature-engineering/index.js.map +1 -0
  987. package/dist/services/feature-engineering/indicators.d.ts +90 -0
  988. package/dist/services/feature-engineering/indicators.js +254 -0
  989. package/dist/services/feature-engineering/indicators.js.map +1 -0
  990. package/dist/services/feature-engineering/rolling-window.d.ts +89 -0
  991. package/dist/services/feature-engineering/rolling-window.js +173 -0
  992. package/dist/services/feature-engineering/rolling-window.js.map +1 -0
  993. package/dist/services/feature-engineering/thresholds.d.ts +137 -0
  994. package/dist/services/feature-engineering/thresholds.js +280 -0
  995. package/dist/services/feature-engineering/thresholds.js.map +1 -0
  996. package/dist/services/feature-engineering/types.d.ts +138 -0
  997. package/dist/services/feature-engineering/types.js +6 -0
  998. package/dist/services/feature-engineering/types.js.map +1 -0
  999. package/dist/services/tick-recorder/index.d.ts +12 -0
  1000. package/dist/services/tick-recorder/index.js +200 -0
  1001. package/dist/services/tick-recorder/index.js.map +1 -0
  1002. package/dist/services/tick-recorder/queries.d.ts +46 -0
  1003. package/dist/services/tick-recorder/queries.js +291 -0
  1004. package/dist/services/tick-recorder/queries.js.map +1 -0
  1005. package/dist/services/tick-recorder/schema.d.ts +27 -0
  1006. package/dist/services/tick-recorder/schema.js +185 -0
  1007. package/dist/services/tick-recorder/schema.js.map +1 -0
  1008. package/dist/services/tick-recorder/timescale.d.ts +27 -0
  1009. package/dist/services/tick-recorder/timescale.js +105 -0
  1010. package/dist/services/tick-recorder/timescale.js.map +1 -0
  1011. package/dist/services/tick-recorder/types.d.ts +113 -0
  1012. package/dist/services/tick-recorder/types.js +7 -0
  1013. package/dist/services/tick-recorder/types.js.map +1 -0
  1014. package/dist/services/tick-streamer/index.d.ts +12 -0
  1015. package/dist/services/tick-streamer/index.js +317 -0
  1016. package/dist/services/tick-streamer/index.js.map +1 -0
  1017. package/dist/services/tick-streamer/types.d.ts +134 -0
  1018. package/dist/services/tick-streamer/types.js +6 -0
  1019. package/dist/services/tick-streamer/types.js.map +1 -0
  1020. package/dist/session/index.d.ts +147 -0
  1021. package/dist/session/index.js +429 -0
  1022. package/dist/session/index.js.map +1 -0
  1023. package/dist/sessions/index.d.ts +69 -0
  1024. package/dist/sessions/index.js +447 -0
  1025. package/dist/sessions/index.js.map +1 -0
  1026. package/dist/signal-router/index.d.ts +2 -0
  1027. package/dist/signal-router/index.js +6 -0
  1028. package/dist/signal-router/index.js.map +1 -0
  1029. package/dist/signal-router/router.d.ts +25 -0
  1030. package/dist/signal-router/router.js +391 -0
  1031. package/dist/signal-router/router.js.map +1 -0
  1032. package/dist/signal-router/types.d.ts +64 -0
  1033. package/dist/signal-router/types.js +9 -0
  1034. package/dist/signal-router/types.js.map +1 -0
  1035. package/dist/skills/bundled/acp/index.d.ts +25 -0
  1036. package/dist/skills/bundled/acp/index.js +472 -0
  1037. package/dist/skills/bundled/acp/index.js.map +1 -0
  1038. package/dist/skills/bundled/agentbets/index.d.ts +15 -0
  1039. package/dist/skills/bundled/agentbets/index.js +168 -0
  1040. package/dist/skills/bundled/agentbets/index.js.map +1 -0
  1041. package/dist/skills/bundled/ai-strategy/index.d.ts +21 -0
  1042. package/dist/skills/bundled/ai-strategy/index.js +647 -0
  1043. package/dist/skills/bundled/ai-strategy/index.js.map +1 -0
  1044. package/dist/skills/bundled/alerts/index.d.ts +20 -0
  1045. package/dist/skills/bundled/alerts/index.js +249 -0
  1046. package/dist/skills/bundled/alerts/index.js.map +1 -0
  1047. package/dist/skills/bundled/analytics/index.d.ts +17 -0
  1048. package/dist/skills/bundled/analytics/index.js +112 -0
  1049. package/dist/skills/bundled/analytics/index.js.map +1 -0
  1050. package/dist/skills/bundled/arbitrage/index.d.ts +24 -0
  1051. package/dist/skills/bundled/arbitrage/index.js +253 -0
  1052. package/dist/skills/bundled/arbitrage/index.js.map +1 -0
  1053. package/dist/skills/bundled/auto-reply/index.d.ts +18 -0
  1054. package/dist/skills/bundled/auto-reply/index.js +215 -0
  1055. package/dist/skills/bundled/auto-reply/index.js.map +1 -0
  1056. package/dist/skills/bundled/automation/index.d.ts +19 -0
  1057. package/dist/skills/bundled/automation/index.js +160 -0
  1058. package/dist/skills/bundled/automation/index.js.map +1 -0
  1059. package/dist/skills/bundled/backtest/index.d.ts +18 -0
  1060. package/dist/skills/bundled/backtest/index.js +250 -0
  1061. package/dist/skills/bundled/backtest/index.js.map +1 -0
  1062. package/dist/skills/bundled/bags/index.d.ts +49 -0
  1063. package/dist/skills/bundled/bags/index.js +1069 -0
  1064. package/dist/skills/bundled/bags/index.js.map +1 -0
  1065. package/dist/skills/bundled/bankr/index.d.ts +161 -0
  1066. package/dist/skills/bundled/bankr/index.js +271 -0
  1067. package/dist/skills/bundled/bankr/index.js.map +1 -0
  1068. package/dist/skills/bundled/betfair/index.d.ts +24 -0
  1069. package/dist/skills/bundled/betfair/index.js +511 -0
  1070. package/dist/skills/bundled/betfair/index.js.map +1 -0
  1071. package/dist/skills/bundled/binance-futures/index.d.ts +15 -0
  1072. package/dist/skills/bundled/binance-futures/index.js +485 -0
  1073. package/dist/skills/bundled/binance-futures/index.js.map +1 -0
  1074. package/dist/skills/bundled/botchan/index.d.ts +130 -0
  1075. package/dist/skills/bundled/botchan/index.js +427 -0
  1076. package/dist/skills/bundled/botchan/index.js.map +1 -0
  1077. package/dist/skills/bundled/bridge/index.d.ts +17 -0
  1078. package/dist/skills/bundled/bridge/index.js +297 -0
  1079. package/dist/skills/bundled/bridge/index.js.map +1 -0
  1080. package/dist/skills/bundled/bybit-futures/index.d.ts +15 -0
  1081. package/dist/skills/bundled/bybit-futures/index.js +380 -0
  1082. package/dist/skills/bundled/bybit-futures/index.js.map +1 -0
  1083. package/dist/skills/bundled/clanker/index.d.ts +236 -0
  1084. package/dist/skills/bundled/clanker/index.js +759 -0
  1085. package/dist/skills/bundled/clanker/index.js.map +1 -0
  1086. package/dist/skills/bundled/copy-trading/index.d.ts +20 -0
  1087. package/dist/skills/bundled/copy-trading/index.js +213 -0
  1088. package/dist/skills/bundled/copy-trading/index.js.map +1 -0
  1089. package/dist/skills/bundled/copy-trading-solana/index.d.ts +21 -0
  1090. package/dist/skills/bundled/copy-trading-solana/index.js +421 -0
  1091. package/dist/skills/bundled/copy-trading-solana/index.js.map +1 -0
  1092. package/dist/skills/bundled/credentials/index.d.ts +17 -0
  1093. package/dist/skills/bundled/credentials/index.js +137 -0
  1094. package/dist/skills/bundled/credentials/index.js.map +1 -0
  1095. package/dist/skills/bundled/crypto-hft/index.d.ts +26 -0
  1096. package/dist/skills/bundled/crypto-hft/index.js +361 -0
  1097. package/dist/skills/bundled/crypto-hft/index.js.map +1 -0
  1098. package/dist/skills/bundled/dca/index.d.ts +26 -0
  1099. package/dist/skills/bundled/dca/index.js +1342 -0
  1100. package/dist/skills/bundled/dca/index.js.map +1 -0
  1101. package/dist/skills/bundled/divergence/index.d.ts +19 -0
  1102. package/dist/skills/bundled/divergence/index.js +272 -0
  1103. package/dist/skills/bundled/divergence/index.js.map +1 -0
  1104. package/dist/skills/bundled/doctor/index.d.ts +18 -0
  1105. package/dist/skills/bundled/doctor/index.js +78 -0
  1106. package/dist/skills/bundled/doctor/index.js.map +1 -0
  1107. package/dist/skills/bundled/drift/index.d.ts +13 -0
  1108. package/dist/skills/bundled/drift/index.js +378 -0
  1109. package/dist/skills/bundled/drift/index.js.map +1 -0
  1110. package/dist/skills/bundled/drift-sdk/index.d.ts +17 -0
  1111. package/dist/skills/bundled/drift-sdk/index.js +501 -0
  1112. package/dist/skills/bundled/drift-sdk/index.js.map +1 -0
  1113. package/dist/skills/bundled/edge/index.d.ts +16 -0
  1114. package/dist/skills/bundled/edge/index.js +91 -0
  1115. package/dist/skills/bundled/edge/index.js.map +1 -0
  1116. package/dist/skills/bundled/embeddings/index.d.ts +19 -0
  1117. package/dist/skills/bundled/embeddings/index.js +215 -0
  1118. package/dist/skills/bundled/embeddings/index.js.map +1 -0
  1119. package/dist/skills/bundled/endaoment/index.d.ts +105 -0
  1120. package/dist/skills/bundled/endaoment/index.js +285 -0
  1121. package/dist/skills/bundled/endaoment/index.js.map +1 -0
  1122. package/dist/skills/bundled/ens/index.d.ts +151 -0
  1123. package/dist/skills/bundled/ens/index.js +278 -0
  1124. package/dist/skills/bundled/ens/index.js.map +1 -0
  1125. package/dist/skills/bundled/erc8004/index.d.ts +123 -0
  1126. package/dist/skills/bundled/erc8004/index.js +301 -0
  1127. package/dist/skills/bundled/erc8004/index.js.map +1 -0
  1128. package/dist/skills/bundled/execution/index.d.ts +18 -0
  1129. package/dist/skills/bundled/execution/index.js +358 -0
  1130. package/dist/skills/bundled/execution/index.js.map +1 -0
  1131. package/dist/skills/bundled/farcaster/index.d.ts +121 -0
  1132. package/dist/skills/bundled/farcaster/index.js +314 -0
  1133. package/dist/skills/bundled/farcaster/index.js.map +1 -0
  1134. package/dist/skills/bundled/features/index.d.ts +17 -0
  1135. package/dist/skills/bundled/features/index.js +305 -0
  1136. package/dist/skills/bundled/features/index.js.map +1 -0
  1137. package/dist/skills/bundled/feeds/index.d.ts +26 -0
  1138. package/dist/skills/bundled/feeds/index.js +462 -0
  1139. package/dist/skills/bundled/feeds/index.js.map +1 -0
  1140. package/dist/skills/bundled/harden/index.d.ts +55 -0
  1141. package/dist/skills/bundled/harden/index.js +510 -0
  1142. package/dist/skills/bundled/harden/index.js.map +1 -0
  1143. package/dist/skills/bundled/history/index.d.ts +21 -0
  1144. package/dist/skills/bundled/history/index.js +195 -0
  1145. package/dist/skills/bundled/history/index.js.map +1 -0
  1146. package/dist/skills/bundled/hyperliquid/index.d.ts +19 -0
  1147. package/dist/skills/bundled/hyperliquid/index.js +1280 -0
  1148. package/dist/skills/bundled/hyperliquid/index.js.map +1 -0
  1149. package/dist/skills/bundled/identity/index.d.ts +17 -0
  1150. package/dist/skills/bundled/identity/index.js +223 -0
  1151. package/dist/skills/bundled/identity/index.js.map +1 -0
  1152. package/dist/skills/bundled/integrations/index.d.ts +17 -0
  1153. package/dist/skills/bundled/integrations/index.js +138 -0
  1154. package/dist/skills/bundled/integrations/index.js.map +1 -0
  1155. package/dist/skills/bundled/jupiter/index.d.ts +41 -0
  1156. package/dist/skills/bundled/jupiter/index.js +872 -0
  1157. package/dist/skills/bundled/jupiter/index.js.map +1 -0
  1158. package/dist/skills/bundled/kamino/index.d.ts +33 -0
  1159. package/dist/skills/bundled/kamino/index.js +578 -0
  1160. package/dist/skills/bundled/kamino/index.js.map +1 -0
  1161. package/dist/skills/bundled/ledger/index.d.ts +14 -0
  1162. package/dist/skills/bundled/ledger/index.js +186 -0
  1163. package/dist/skills/bundled/ledger/index.js.map +1 -0
  1164. package/dist/skills/bundled/market-index/index.d.ts +18 -0
  1165. package/dist/skills/bundled/market-index/index.js +182 -0
  1166. package/dist/skills/bundled/market-index/index.js.map +1 -0
  1167. package/dist/skills/bundled/markets/index.d.ts +16 -0
  1168. package/dist/skills/bundled/markets/index.js +95 -0
  1169. package/dist/skills/bundled/markets/index.js.map +1 -0
  1170. package/dist/skills/bundled/mcp/index.d.ts +19 -0
  1171. package/dist/skills/bundled/mcp/index.js +212 -0
  1172. package/dist/skills/bundled/mcp/index.js.map +1 -0
  1173. package/dist/skills/bundled/memory/index.d.ts +20 -0
  1174. package/dist/skills/bundled/memory/index.js +210 -0
  1175. package/dist/skills/bundled/memory/index.js.map +1 -0
  1176. package/dist/skills/bundled/metaculus/index.d.ts +17 -0
  1177. package/dist/skills/bundled/metaculus/index.js +168 -0
  1178. package/dist/skills/bundled/metaculus/index.js.map +1 -0
  1179. package/dist/skills/bundled/meteora/index.d.ts +39 -0
  1180. package/dist/skills/bundled/meteora/index.js +837 -0
  1181. package/dist/skills/bundled/meteora/index.js.map +1 -0
  1182. package/dist/skills/bundled/meteora-dbc/index.d.ts +33 -0
  1183. package/dist/skills/bundled/meteora-dbc/index.js +993 -0
  1184. package/dist/skills/bundled/meteora-dbc/index.js.map +1 -0
  1185. package/dist/skills/bundled/metrics/index.d.ts +18 -0
  1186. package/dist/skills/bundled/metrics/index.js +91 -0
  1187. package/dist/skills/bundled/metrics/index.js.map +1 -0
  1188. package/dist/skills/bundled/mev/index.d.ts +17 -0
  1189. package/dist/skills/bundled/mev/index.js +108 -0
  1190. package/dist/skills/bundled/mev/index.js.map +1 -0
  1191. package/dist/skills/bundled/mexc-futures/index.d.ts +16 -0
  1192. package/dist/skills/bundled/mexc-futures/index.js +389 -0
  1193. package/dist/skills/bundled/mexc-futures/index.js.map +1 -0
  1194. package/dist/skills/bundled/mm/index.d.ts +18 -0
  1195. package/dist/skills/bundled/mm/index.js +315 -0
  1196. package/dist/skills/bundled/mm/index.js.map +1 -0
  1197. package/dist/skills/bundled/monitoring/index.d.ts +18 -0
  1198. package/dist/skills/bundled/monitoring/index.js +146 -0
  1199. package/dist/skills/bundled/monitoring/index.js.map +1 -0
  1200. package/dist/skills/bundled/news/index.d.ts +17 -0
  1201. package/dist/skills/bundled/news/index.js +161 -0
  1202. package/dist/skills/bundled/news/index.js.map +1 -0
  1203. package/dist/skills/bundled/onchainkit/index.d.ts +92 -0
  1204. package/dist/skills/bundled/onchainkit/index.js +429 -0
  1205. package/dist/skills/bundled/onchainkit/index.js.map +1 -0
  1206. package/dist/skills/bundled/opinion/index.d.ts +12 -0
  1207. package/dist/skills/bundled/opinion/index.js +429 -0
  1208. package/dist/skills/bundled/opinion/index.js.map +1 -0
  1209. package/dist/skills/bundled/opportunity/index.d.ts +25 -0
  1210. package/dist/skills/bundled/opportunity/index.js +289 -0
  1211. package/dist/skills/bundled/opportunity/index.js.map +1 -0
  1212. package/dist/skills/bundled/orca/index.d.ts +12 -0
  1213. package/dist/skills/bundled/orca/index.js +663 -0
  1214. package/dist/skills/bundled/orca/index.js.map +1 -0
  1215. package/dist/skills/bundled/pairing/index.d.ts +24 -0
  1216. package/dist/skills/bundled/pairing/index.js +228 -0
  1217. package/dist/skills/bundled/pairing/index.js.map +1 -0
  1218. package/dist/skills/bundled/percolator/index.d.ts +20 -0
  1219. package/dist/skills/bundled/percolator/index.js +229 -0
  1220. package/dist/skills/bundled/percolator/index.js.map +1 -0
  1221. package/dist/skills/bundled/permissions/index.d.ts +21 -0
  1222. package/dist/skills/bundled/permissions/index.js +204 -0
  1223. package/dist/skills/bundled/permissions/index.js.map +1 -0
  1224. package/dist/skills/bundled/plugins/index.d.ts +20 -0
  1225. package/dist/skills/bundled/plugins/index.js +209 -0
  1226. package/dist/skills/bundled/plugins/index.js.map +1 -0
  1227. package/dist/skills/bundled/portfolio/index.d.ts +20 -0
  1228. package/dist/skills/bundled/portfolio/index.js +367 -0
  1229. package/dist/skills/bundled/portfolio/index.js.map +1 -0
  1230. package/dist/skills/bundled/portfolio-sync/index.d.ts +17 -0
  1231. package/dist/skills/bundled/portfolio-sync/index.js +116 -0
  1232. package/dist/skills/bundled/portfolio-sync/index.js.map +1 -0
  1233. package/dist/skills/bundled/positions/index.d.ts +18 -0
  1234. package/dist/skills/bundled/positions/index.js +161 -0
  1235. package/dist/skills/bundled/positions/index.js.map +1 -0
  1236. package/dist/skills/bundled/predictfun/index.d.ts +13 -0
  1237. package/dist/skills/bundled/predictfun/index.js +612 -0
  1238. package/dist/skills/bundled/predictfun/index.js.map +1 -0
  1239. package/dist/skills/bundled/predictit/index.d.ts +16 -0
  1240. package/dist/skills/bundled/predictit/index.js +138 -0
  1241. package/dist/skills/bundled/predictit/index.js.map +1 -0
  1242. package/dist/skills/bundled/presence/index.d.ts +18 -0
  1243. package/dist/skills/bundled/presence/index.js +151 -0
  1244. package/dist/skills/bundled/presence/index.js.map +1 -0
  1245. package/dist/skills/bundled/processes/index.d.ts +17 -0
  1246. package/dist/skills/bundled/processes/index.js +121 -0
  1247. package/dist/skills/bundled/processes/index.js.map +1 -0
  1248. package/dist/skills/bundled/pump-swarm/index.d.ts +16 -0
  1249. package/dist/skills/bundled/pump-swarm/index.js +2235 -0
  1250. package/dist/skills/bundled/pump-swarm/index.js.map +1 -0
  1251. package/dist/skills/bundled/pumpfun/index.d.ts +47 -0
  1252. package/dist/skills/bundled/pumpfun/index.js +1400 -0
  1253. package/dist/skills/bundled/pumpfun/index.js.map +1 -0
  1254. package/dist/skills/bundled/qmd/index.d.ts +18 -0
  1255. package/dist/skills/bundled/qmd/index.js +116 -0
  1256. package/dist/skills/bundled/qmd/index.js.map +1 -0
  1257. package/dist/skills/bundled/qrcoin/index.d.ts +92 -0
  1258. package/dist/skills/bundled/qrcoin/index.js +328 -0
  1259. package/dist/skills/bundled/qrcoin/index.js.map +1 -0
  1260. package/dist/skills/bundled/raydium/index.d.ts +35 -0
  1261. package/dist/skills/bundled/raydium/index.js +695 -0
  1262. package/dist/skills/bundled/raydium/index.js.map +1 -0
  1263. package/dist/skills/bundled/remote/index.d.ts +19 -0
  1264. package/dist/skills/bundled/remote/index.js +186 -0
  1265. package/dist/skills/bundled/remote/index.js.map +1 -0
  1266. package/dist/skills/bundled/research/index.d.ts +17 -0
  1267. package/dist/skills/bundled/research/index.js +185 -0
  1268. package/dist/skills/bundled/research/index.js.map +1 -0
  1269. package/dist/skills/bundled/risk/index.d.ts +31 -0
  1270. package/dist/skills/bundled/risk/index.js +379 -0
  1271. package/dist/skills/bundled/risk/index.js.map +1 -0
  1272. package/dist/skills/bundled/router/index.d.ts +17 -0
  1273. package/dist/skills/bundled/router/index.js +160 -0
  1274. package/dist/skills/bundled/router/index.js.map +1 -0
  1275. package/dist/skills/bundled/routing/index.d.ts +23 -0
  1276. package/dist/skills/bundled/routing/index.js +257 -0
  1277. package/dist/skills/bundled/routing/index.js.map +1 -0
  1278. package/dist/skills/bundled/sandbox/index.d.ts +18 -0
  1279. package/dist/skills/bundled/sandbox/index.js +119 -0
  1280. package/dist/skills/bundled/sandbox/index.js.map +1 -0
  1281. package/dist/skills/bundled/search-config/index.d.ts +18 -0
  1282. package/dist/skills/bundled/search-config/index.js +170 -0
  1283. package/dist/skills/bundled/search-config/index.js.map +1 -0
  1284. package/dist/skills/bundled/sessions/index.d.ts +29 -0
  1285. package/dist/skills/bundled/sessions/index.js +193 -0
  1286. package/dist/skills/bundled/sessions/index.js.map +1 -0
  1287. package/dist/skills/bundled/shield/index.d.ts +22 -0
  1288. package/dist/skills/bundled/shield/index.js +245 -0
  1289. package/dist/skills/bundled/shield/index.js.map +1 -0
  1290. package/dist/skills/bundled/signals/index.d.ts +24 -0
  1291. package/dist/skills/bundled/signals/index.js +776 -0
  1292. package/dist/skills/bundled/signals/index.js.map +1 -0
  1293. package/dist/skills/bundled/sizing/index.d.ts +16 -0
  1294. package/dist/skills/bundled/sizing/index.js +168 -0
  1295. package/dist/skills/bundled/sizing/index.js.map +1 -0
  1296. package/dist/skills/bundled/slippage/index.d.ts +16 -0
  1297. package/dist/skills/bundled/slippage/index.js +111 -0
  1298. package/dist/skills/bundled/slippage/index.js.map +1 -0
  1299. package/dist/skills/bundled/smarkets/index.d.ts +23 -0
  1300. package/dist/skills/bundled/smarkets/index.js +473 -0
  1301. package/dist/skills/bundled/smarkets/index.js.map +1 -0
  1302. package/dist/skills/bundled/strategy/index.d.ts +18 -0
  1303. package/dist/skills/bundled/strategy/index.js +168 -0
  1304. package/dist/skills/bundled/strategy/index.js.map +1 -0
  1305. package/dist/skills/bundled/streaming/index.d.ts +19 -0
  1306. package/dist/skills/bundled/streaming/index.js +147 -0
  1307. package/dist/skills/bundled/streaming/index.js.map +1 -0
  1308. package/dist/skills/bundled/tailscale/index.d.ts +18 -0
  1309. package/dist/skills/bundled/tailscale/index.js +173 -0
  1310. package/dist/skills/bundled/tailscale/index.js.map +1 -0
  1311. package/dist/skills/bundled/ticks/index.d.ts +17 -0
  1312. package/dist/skills/bundled/ticks/index.js +287 -0
  1313. package/dist/skills/bundled/ticks/index.js.map +1 -0
  1314. package/dist/skills/bundled/token-security/index.d.ts +19 -0
  1315. package/dist/skills/bundled/token-security/index.js +138 -0
  1316. package/dist/skills/bundled/token-security/index.js.map +1 -0
  1317. package/dist/skills/bundled/trading-evm/index.d.ts +19 -0
  1318. package/dist/skills/bundled/trading-evm/index.js +302 -0
  1319. package/dist/skills/bundled/trading-evm/index.js.map +1 -0
  1320. package/dist/skills/bundled/trading-futures/index.d.ts +14 -0
  1321. package/dist/skills/bundled/trading-futures/index.js +874 -0
  1322. package/dist/skills/bundled/trading-futures/index.js.map +1 -0
  1323. package/dist/skills/bundled/trading-kalshi/index.d.ts +36 -0
  1324. package/dist/skills/bundled/trading-kalshi/index.js +1199 -0
  1325. package/dist/skills/bundled/trading-kalshi/index.js.map +1 -0
  1326. package/dist/skills/bundled/trading-manifold/index.d.ts +23 -0
  1327. package/dist/skills/bundled/trading-manifold/index.js +391 -0
  1328. package/dist/skills/bundled/trading-manifold/index.js.map +1 -0
  1329. package/dist/skills/bundled/trading-polymarket/index.d.ts +27 -0
  1330. package/dist/skills/bundled/trading-polymarket/index.js +1321 -0
  1331. package/dist/skills/bundled/trading-polymarket/index.js.map +1 -0
  1332. package/dist/skills/bundled/trading-solana/index.d.ts +19 -0
  1333. package/dist/skills/bundled/trading-solana/index.js +383 -0
  1334. package/dist/skills/bundled/trading-solana/index.js.map +1 -0
  1335. package/dist/skills/bundled/trading-system/index.d.ts +22 -0
  1336. package/dist/skills/bundled/trading-system/index.js +355 -0
  1337. package/dist/skills/bundled/trading-system/index.js.map +1 -0
  1338. package/dist/skills/bundled/triggers/index.d.ts +18 -0
  1339. package/dist/skills/bundled/triggers/index.js +172 -0
  1340. package/dist/skills/bundled/triggers/index.js.map +1 -0
  1341. package/dist/skills/bundled/tts/index.d.ts +16 -0
  1342. package/dist/skills/bundled/tts/index.js +150 -0
  1343. package/dist/skills/bundled/tts/index.js.map +1 -0
  1344. package/dist/skills/bundled/tweet-ideas/index.d.ts +20 -0
  1345. package/dist/skills/bundled/tweet-ideas/index.js +470 -0
  1346. package/dist/skills/bundled/tweet-ideas/index.js.map +1 -0
  1347. package/dist/skills/bundled/usage/index.d.ts +17 -0
  1348. package/dist/skills/bundled/usage/index.js +145 -0
  1349. package/dist/skills/bundled/usage/index.js.map +1 -0
  1350. package/dist/skills/bundled/veil/index.d.ts +79 -0
  1351. package/dist/skills/bundled/veil/index.js +322 -0
  1352. package/dist/skills/bundled/veil/index.js.map +1 -0
  1353. package/dist/skills/bundled/verify/index.d.ts +20 -0
  1354. package/dist/skills/bundled/verify/index.js +157 -0
  1355. package/dist/skills/bundled/verify/index.js.map +1 -0
  1356. package/dist/skills/bundled/virtuals/index.d.ts +20 -0
  1357. package/dist/skills/bundled/virtuals/index.js +255 -0
  1358. package/dist/skills/bundled/virtuals/index.js.map +1 -0
  1359. package/dist/skills/bundled/voice/index.d.ts +18 -0
  1360. package/dist/skills/bundled/voice/index.js +190 -0
  1361. package/dist/skills/bundled/voice/index.js.map +1 -0
  1362. package/dist/skills/bundled/weather/index.d.ts +20 -0
  1363. package/dist/skills/bundled/weather/index.js +475 -0
  1364. package/dist/skills/bundled/weather/index.js.map +1 -0
  1365. package/dist/skills/bundled/webhooks/index.d.ts +18 -0
  1366. package/dist/skills/bundled/webhooks/index.js +136 -0
  1367. package/dist/skills/bundled/webhooks/index.js.map +1 -0
  1368. package/dist/skills/bundled/whale-tracking/index.d.ts +18 -0
  1369. package/dist/skills/bundled/whale-tracking/index.js +441 -0
  1370. package/dist/skills/bundled/whale-tracking/index.js.map +1 -0
  1371. package/dist/skills/bundled/yoink/index.d.ts +78 -0
  1372. package/dist/skills/bundled/yoink/index.js +236 -0
  1373. package/dist/skills/bundled/yoink/index.js.map +1 -0
  1374. package/dist/skills/executor.d.ts +117 -0
  1375. package/dist/skills/executor.js +469 -0
  1376. package/dist/skills/executor.js.map +1 -0
  1377. package/dist/skills/frontmatter.d.ts +69 -0
  1378. package/dist/skills/frontmatter.js +187 -0
  1379. package/dist/skills/frontmatter.js.map +1 -0
  1380. package/dist/skills/index.d.ts +150 -0
  1381. package/dist/skills/index.js +531 -0
  1382. package/dist/skills/index.js.map +1 -0
  1383. package/dist/skills/loader.d.ts +48 -0
  1384. package/dist/skills/loader.js +594 -0
  1385. package/dist/skills/loader.js.map +1 -0
  1386. package/dist/skills/registry.d.ts +94 -0
  1387. package/dist/skills/registry.js +308 -0
  1388. package/dist/skills/registry.js.map +1 -0
  1389. package/dist/solana/copytrade.d.ts +116 -0
  1390. package/dist/solana/copytrade.js +493 -0
  1391. package/dist/solana/copytrade.js.map +1 -0
  1392. package/dist/solana/drift.d.ts +154 -0
  1393. package/dist/solana/drift.js +599 -0
  1394. package/dist/solana/drift.js.map +1 -0
  1395. package/dist/solana/jupiter.d.ts +283 -0
  1396. package/dist/solana/jupiter.js +553 -0
  1397. package/dist/solana/jupiter.js.map +1 -0
  1398. package/dist/solana/kamino.d.ts +206 -0
  1399. package/dist/solana/kamino.js +546 -0
  1400. package/dist/solana/kamino.js.map +1 -0
  1401. package/dist/solana/meteora-dbc.d.ts +430 -0
  1402. package/dist/solana/meteora-dbc.js +1105 -0
  1403. package/dist/solana/meteora-dbc.js.map +1 -0
  1404. package/dist/solana/meteora.d.ts +232 -0
  1405. package/dist/solana/meteora.js +682 -0
  1406. package/dist/solana/meteora.js.map +1 -0
  1407. package/dist/solana/orca.d.ts +163 -0
  1408. package/dist/solana/orca.js +378 -0
  1409. package/dist/solana/orca.js.map +1 -0
  1410. package/dist/solana/pools.d.ts +26 -0
  1411. package/dist/solana/pools.js +96 -0
  1412. package/dist/solana/pools.js.map +1 -0
  1413. package/dist/solana/pump-swarm.d.ts +349 -0
  1414. package/dist/solana/pump-swarm.js +1663 -0
  1415. package/dist/solana/pump-swarm.js.map +1 -0
  1416. package/dist/solana/pumpapi.d.ts +196 -0
  1417. package/dist/solana/pumpapi.js +462 -0
  1418. package/dist/solana/pumpapi.js.map +1 -0
  1419. package/dist/solana/raydium.d.ts +170 -0
  1420. package/dist/solana/raydium.js +673 -0
  1421. package/dist/solana/raydium.js.map +1 -0
  1422. package/dist/solana/swarm-ai-builder.d.ts +97 -0
  1423. package/dist/solana/swarm-ai-builder.js +571 -0
  1424. package/dist/solana/swarm-ai-builder.js.map +1 -0
  1425. package/dist/solana/swarm-arbitrage.d.ts +111 -0
  1426. package/dist/solana/swarm-arbitrage.js +437 -0
  1427. package/dist/solana/swarm-arbitrage.js.map +1 -0
  1428. package/dist/solana/swarm-builders.d.ts +71 -0
  1429. package/dist/solana/swarm-builders.js +402 -0
  1430. package/dist/solana/swarm-builders.js.map +1 -0
  1431. package/dist/solana/swarm-copytrade.d.ts +103 -0
  1432. package/dist/solana/swarm-copytrade.js +420 -0
  1433. package/dist/solana/swarm-copytrade.js.map +1 -0
  1434. package/dist/solana/swarm-presets.d.ts +49 -0
  1435. package/dist/solana/swarm-presets.js +282 -0
  1436. package/dist/solana/swarm-presets.js.map +1 -0
  1437. package/dist/solana/swarm-signals.d.ts +128 -0
  1438. package/dist/solana/swarm-signals.js +529 -0
  1439. package/dist/solana/swarm-signals.js.map +1 -0
  1440. package/dist/solana/swarm-strategies.d.ts +230 -0
  1441. package/dist/solana/swarm-strategies.js +611 -0
  1442. package/dist/solana/swarm-strategies.js.map +1 -0
  1443. package/dist/solana/tokenlist.d.ts +10 -0
  1444. package/dist/solana/tokenlist.js +54 -0
  1445. package/dist/solana/tokenlist.js.map +1 -0
  1446. package/dist/solana/wallet.d.ts +12 -0
  1447. package/dist/solana/wallet.js +90 -0
  1448. package/dist/solana/wallet.js.map +1 -0
  1449. package/dist/strategies/crypto-hft/index.d.ts +46 -0
  1450. package/dist/strategies/crypto-hft/index.js +469 -0
  1451. package/dist/strategies/crypto-hft/index.js.map +1 -0
  1452. package/dist/strategies/crypto-hft/market-scanner.d.ts +26 -0
  1453. package/dist/strategies/crypto-hft/market-scanner.js +177 -0
  1454. package/dist/strategies/crypto-hft/market-scanner.js.map +1 -0
  1455. package/dist/strategies/crypto-hft/orderbook.d.ts +37 -0
  1456. package/dist/strategies/crypto-hft/orderbook.js +184 -0
  1457. package/dist/strategies/crypto-hft/orderbook.js.map +1 -0
  1458. package/dist/strategies/crypto-hft/positions.d.ts +49 -0
  1459. package/dist/strategies/crypto-hft/positions.js +376 -0
  1460. package/dist/strategies/crypto-hft/positions.js.map +1 -0
  1461. package/dist/strategies/crypto-hft/presets.d.ts +11 -0
  1462. package/dist/strategies/crypto-hft/presets.js +164 -0
  1463. package/dist/strategies/crypto-hft/presets.js.map +1 -0
  1464. package/dist/strategies/crypto-hft/strategies.d.ts +96 -0
  1465. package/dist/strategies/crypto-hft/strategies.js +330 -0
  1466. package/dist/strategies/crypto-hft/strategies.js.map +1 -0
  1467. package/dist/strategies/crypto-hft/types.d.ts +196 -0
  1468. package/dist/strategies/crypto-hft/types.js +32 -0
  1469. package/dist/strategies/crypto-hft/types.js.map +1 -0
  1470. package/dist/strategies/hft-divergence/detector.d.ts +29 -0
  1471. package/dist/strategies/hft-divergence/detector.js +182 -0
  1472. package/dist/strategies/hft-divergence/detector.js.map +1 -0
  1473. package/dist/strategies/hft-divergence/index.d.ts +12 -0
  1474. package/dist/strategies/hft-divergence/index.js +19 -0
  1475. package/dist/strategies/hft-divergence/index.js.map +1 -0
  1476. package/dist/strategies/hft-divergence/market-rotator.d.ts +17 -0
  1477. package/dist/strategies/hft-divergence/market-rotator.js +128 -0
  1478. package/dist/strategies/hft-divergence/market-rotator.js.map +1 -0
  1479. package/dist/strategies/hft-divergence/position-manager.d.ts +35 -0
  1480. package/dist/strategies/hft-divergence/position-manager.js +188 -0
  1481. package/dist/strategies/hft-divergence/position-manager.js.map +1 -0
  1482. package/dist/strategies/hft-divergence/strategy.d.ts +31 -0
  1483. package/dist/strategies/hft-divergence/strategy.js +295 -0
  1484. package/dist/strategies/hft-divergence/strategy.js.map +1 -0
  1485. package/dist/strategies/hft-divergence/types.d.ts +114 -0
  1486. package/dist/strategies/hft-divergence/types.js +10 -0
  1487. package/dist/strategies/hft-divergence/types.js.map +1 -0
  1488. package/dist/streaming/index.d.ts +70 -0
  1489. package/dist/streaming/index.js +296 -0
  1490. package/dist/streaming/index.js.map +1 -0
  1491. package/dist/tailscale/index.d.ts +139 -0
  1492. package/dist/tailscale/index.js +345 -0
  1493. package/dist/tailscale/index.js.map +1 -0
  1494. package/dist/telemetry/index.d.ts +143 -0
  1495. package/dist/telemetry/index.js +535 -0
  1496. package/dist/telemetry/index.js.map +1 -0
  1497. package/dist/terminal/index.d.ts +121 -0
  1498. package/dist/terminal/index.js +548 -0
  1499. package/dist/terminal/index.js.map +1 -0
  1500. package/dist/token-security/index.d.ts +36 -0
  1501. package/dist/token-security/index.js +253 -0
  1502. package/dist/token-security/index.js.map +1 -0
  1503. package/dist/tools/browser.d.ts +128 -0
  1504. package/dist/tools/browser.js +459 -0
  1505. package/dist/tools/browser.js.map +1 -0
  1506. package/dist/tools/canvas.d.ts +93 -0
  1507. package/dist/tools/canvas.js +349 -0
  1508. package/dist/tools/canvas.js.map +1 -0
  1509. package/dist/tools/docker.d.ts +59 -0
  1510. package/dist/tools/docker.js +191 -0
  1511. package/dist/tools/docker.js.map +1 -0
  1512. package/dist/tools/email.d.ts +25 -0
  1513. package/dist/tools/email.js +131 -0
  1514. package/dist/tools/email.js.map +1 -0
  1515. package/dist/tools/exec.d.ts +81 -0
  1516. package/dist/tools/exec.js +373 -0
  1517. package/dist/tools/exec.js.map +1 -0
  1518. package/dist/tools/files.d.ts +46 -0
  1519. package/dist/tools/files.js +185 -0
  1520. package/dist/tools/files.js.map +1 -0
  1521. package/dist/tools/git.d.ts +29 -0
  1522. package/dist/tools/git.js +105 -0
  1523. package/dist/tools/git.js.map +1 -0
  1524. package/dist/tools/image.d.ts +57 -0
  1525. package/dist/tools/image.js +308 -0
  1526. package/dist/tools/image.js.map +1 -0
  1527. package/dist/tools/index.d.ts +39 -0
  1528. package/dist/tools/index.js +46 -0
  1529. package/dist/tools/index.js.map +1 -0
  1530. package/dist/tools/message.d.ts +99 -0
  1531. package/dist/tools/message.js +200 -0
  1532. package/dist/tools/message.js.map +1 -0
  1533. package/dist/tools/nodes.d.ts +134 -0
  1534. package/dist/tools/nodes.js +357 -0
  1535. package/dist/tools/nodes.js.map +1 -0
  1536. package/dist/tools/sessions.d.ts +60 -0
  1537. package/dist/tools/sessions.js +119 -0
  1538. package/dist/tools/sessions.js.map +1 -0
  1539. package/dist/tools/shell-history.d.ts +17 -0
  1540. package/dist/tools/shell-history.js +118 -0
  1541. package/dist/tools/shell-history.js.map +1 -0
  1542. package/dist/tools/sms.d.ts +18 -0
  1543. package/dist/tools/sms.js +66 -0
  1544. package/dist/tools/sms.js.map +1 -0
  1545. package/dist/tools/sql.d.ts +19 -0
  1546. package/dist/tools/sql.js +91 -0
  1547. package/dist/tools/sql.js.map +1 -0
  1548. package/dist/tools/transcription.d.ts +13 -0
  1549. package/dist/tools/transcription.js +99 -0
  1550. package/dist/tools/transcription.js.map +1 -0
  1551. package/dist/tools/web-fetch.d.ts +69 -0
  1552. package/dist/tools/web-fetch.js +251 -0
  1553. package/dist/tools/web-fetch.js.map +1 -0
  1554. package/dist/tools/web-search.d.ts +58 -0
  1555. package/dist/tools/web-search.js +204 -0
  1556. package/dist/tools/web-search.js.map +1 -0
  1557. package/dist/tools/webhooks.d.ts +74 -0
  1558. package/dist/tools/webhooks.js +165 -0
  1559. package/dist/tools/webhooks.js.map +1 -0
  1560. package/dist/trading/accounts.d.ts +167 -0
  1561. package/dist/trading/accounts.js +394 -0
  1562. package/dist/trading/accounts.js.map +1 -0
  1563. package/dist/trading/adapters/index.d.ts +27 -0
  1564. package/dist/trading/adapters/index.js +165 -0
  1565. package/dist/trading/adapters/index.js.map +1 -0
  1566. package/dist/trading/backtest.d.ts +161 -0
  1567. package/dist/trading/backtest.js +665 -0
  1568. package/dist/trading/backtest.js.map +1 -0
  1569. package/dist/trading/bots/index.d.ts +196 -0
  1570. package/dist/trading/bots/index.js +688 -0
  1571. package/dist/trading/bots/index.js.map +1 -0
  1572. package/dist/trading/bridge.d.ts +33 -0
  1573. package/dist/trading/bridge.js +121 -0
  1574. package/dist/trading/bridge.js.map +1 -0
  1575. package/dist/trading/builder.d.ts +102 -0
  1576. package/dist/trading/builder.js +430 -0
  1577. package/dist/trading/builder.js.map +1 -0
  1578. package/dist/trading/copy-trading.d.ts +125 -0
  1579. package/dist/trading/copy-trading.js +611 -0
  1580. package/dist/trading/copy-trading.js.map +1 -0
  1581. package/dist/trading/devtools.d.ts +172 -0
  1582. package/dist/trading/devtools.js +425 -0
  1583. package/dist/trading/devtools.js.map +1 -0
  1584. package/dist/trading/futures/index.d.ts +981 -0
  1585. package/dist/trading/futures/index.js +4011 -0
  1586. package/dist/trading/futures/index.js.map +1 -0
  1587. package/dist/trading/index.d.ts +102 -0
  1588. package/dist/trading/index.js +310 -0
  1589. package/dist/trading/index.js.map +1 -0
  1590. package/dist/trading/kelly.d.ts +137 -0
  1591. package/dist/trading/kelly.js +328 -0
  1592. package/dist/trading/kelly.js.map +1 -0
  1593. package/dist/trading/logger.d.ts +163 -0
  1594. package/dist/trading/logger.js +424 -0
  1595. package/dist/trading/logger.js.map +1 -0
  1596. package/dist/trading/market-making/engine.d.ts +44 -0
  1597. package/dist/trading/market-making/engine.js +165 -0
  1598. package/dist/trading/market-making/engine.js.map +1 -0
  1599. package/dist/trading/market-making/index.d.ts +10 -0
  1600. package/dist/trading/market-making/index.js +29 -0
  1601. package/dist/trading/market-making/index.js.map +1 -0
  1602. package/dist/trading/market-making/strategy.d.ts +25 -0
  1603. package/dist/trading/market-making/strategy.js +250 -0
  1604. package/dist/trading/market-making/strategy.js.map +1 -0
  1605. package/dist/trading/market-making/types.d.ts +92 -0
  1606. package/dist/trading/market-making/types.js +6 -0
  1607. package/dist/trading/market-making/types.js.map +1 -0
  1608. package/dist/trading/ml-signals.d.ts +175 -0
  1609. package/dist/trading/ml-signals.js +548 -0
  1610. package/dist/trading/ml-signals.js.map +1 -0
  1611. package/dist/trading/orchestrator.d.ts +59 -0
  1612. package/dist/trading/orchestrator.js +199 -0
  1613. package/dist/trading/orchestrator.js.map +1 -0
  1614. package/dist/trading/position-bridge.d.ts +41 -0
  1615. package/dist/trading/position-bridge.js +178 -0
  1616. package/dist/trading/position-bridge.js.map +1 -0
  1617. package/dist/trading/resilience.d.ts +81 -0
  1618. package/dist/trading/resilience.js +257 -0
  1619. package/dist/trading/resilience.js.map +1 -0
  1620. package/dist/trading/risk.d.ts +18 -0
  1621. package/dist/trading/risk.js +91 -0
  1622. package/dist/trading/risk.js.map +1 -0
  1623. package/dist/trading/safety.d.ts +114 -0
  1624. package/dist/trading/safety.js +372 -0
  1625. package/dist/trading/safety.js.map +1 -0
  1626. package/dist/trading/secrets.d.ts +48 -0
  1627. package/dist/trading/secrets.js +243 -0
  1628. package/dist/trading/secrets.js.map +1 -0
  1629. package/dist/trading/state.d.ts +88 -0
  1630. package/dist/trading/state.js +221 -0
  1631. package/dist/trading/state.js.map +1 -0
  1632. package/dist/trading/stream.d.ts +121 -0
  1633. package/dist/trading/stream.js +396 -0
  1634. package/dist/trading/stream.js.map +1 -0
  1635. package/dist/trading/tracking.d.ts +136 -0
  1636. package/dist/trading/tracking.js +512 -0
  1637. package/dist/trading/tracking.js.map +1 -0
  1638. package/dist/tts/index.d.ts +28 -0
  1639. package/dist/tts/index.js +64 -0
  1640. package/dist/tts/index.js.map +1 -0
  1641. package/dist/tui/index.d.ts +159 -0
  1642. package/dist/tui/index.js +580 -0
  1643. package/dist/tui/index.js.map +1 -0
  1644. package/dist/types.d.ts +1373 -0
  1645. package/dist/types.js +7 -0
  1646. package/dist/types.js.map +1 -0
  1647. package/dist/usage/index.d.ts +57 -0
  1648. package/dist/usage/index.js +191 -0
  1649. package/dist/usage/index.js.map +1 -0
  1650. package/dist/utils/attachments.d.ts +12 -0
  1651. package/dist/utils/attachments.js +104 -0
  1652. package/dist/utils/attachments.js.map +1 -0
  1653. package/dist/utils/config.d.ts +14 -0
  1654. package/dist/utils/config.js +474 -0
  1655. package/dist/utils/config.js.map +1 -0
  1656. package/dist/utils/http.d.ts +22 -0
  1657. package/dist/utils/http.js +191 -0
  1658. package/dist/utils/http.js.map +1 -0
  1659. package/dist/utils/id.d.ts +21 -0
  1660. package/dist/utils/id.js +41 -0
  1661. package/dist/utils/id.js.map +1 -0
  1662. package/dist/utils/json-utils.d.ts +201 -0
  1663. package/dist/utils/json-utils.js +151 -0
  1664. package/dist/utils/json-utils.js.map +1 -0
  1665. package/dist/utils/kalshi-auth.d.ts +10 -0
  1666. package/dist/utils/kalshi-auth.js +48 -0
  1667. package/dist/utils/kalshi-auth.js.map +1 -0
  1668. package/dist/utils/kelly.d.ts +153 -0
  1669. package/dist/utils/kelly.js +322 -0
  1670. package/dist/utils/kelly.js.map +1 -0
  1671. package/dist/utils/logger.d.ts +7 -0
  1672. package/dist/utils/logger.js +26 -0
  1673. package/dist/utils/logger.js.map +1 -0
  1674. package/dist/utils/opinion-auth.d.ts +17 -0
  1675. package/dist/utils/opinion-auth.js +25 -0
  1676. package/dist/utils/opinion-auth.js.map +1 -0
  1677. package/dist/utils/polymarket-auth.d.ts +11 -0
  1678. package/dist/utils/polymarket-auth.js +32 -0
  1679. package/dist/utils/polymarket-auth.js.map +1 -0
  1680. package/dist/utils/polymarket-order-signer.d.ts +118 -0
  1681. package/dist/utils/polymarket-order-signer.js +329 -0
  1682. package/dist/utils/polymarket-order-signer.js.map +1 -0
  1683. package/dist/utils/polymarket-setup.d.ts +70 -0
  1684. package/dist/utils/polymarket-setup.js +288 -0
  1685. package/dist/utils/polymarket-setup.js.map +1 -0
  1686. package/dist/utils/production.d.ts +112 -0
  1687. package/dist/utils/production.js +294 -0
  1688. package/dist/utils/production.js.map +1 -0
  1689. package/dist/utils/rate-limiter.d.ts +77 -0
  1690. package/dist/utils/rate-limiter.js +271 -0
  1691. package/dist/utils/rate-limiter.js.map +1 -0
  1692. package/dist/utils/webhook-security.d.ts +63 -0
  1693. package/dist/utils/webhook-security.js +183 -0
  1694. package/dist/utils/webhook-security.js.map +1 -0
  1695. package/dist/voice/index.d.ts +125 -0
  1696. package/dist/voice/index.js +557 -0
  1697. package/dist/voice/index.js.map +1 -0
  1698. package/dist/weather/edge.d.ts +70 -0
  1699. package/dist/weather/edge.js +281 -0
  1700. package/dist/weather/edge.js.map +1 -0
  1701. package/dist/weather/index.d.ts +6 -0
  1702. package/dist/weather/index.js +23 -0
  1703. package/dist/weather/index.js.map +1 -0
  1704. package/dist/weather/markets.d.ts +84 -0
  1705. package/dist/weather/markets.js +320 -0
  1706. package/dist/weather/markets.js.map +1 -0
  1707. package/dist/weather/noaa.d.ts +113 -0
  1708. package/dist/weather/noaa.js +287 -0
  1709. package/dist/weather/noaa.js.map +1 -0
  1710. package/dist/web/index.d.ts +112 -0
  1711. package/dist/web/index.js +639 -0
  1712. package/dist/web/index.js.map +1 -0
  1713. package/dist/wizard/index.d.ts +27 -0
  1714. package/dist/wizard/index.js +186 -0
  1715. package/dist/wizard/index.js.map +1 -0
  1716. package/dist/workspace/index.d.ts +73 -0
  1717. package/dist/workspace/index.js +403 -0
  1718. package/dist/workspace/index.js.map +1 -0
  1719. package/package.json +168 -0
@@ -0,0 +1,2287 @@
1
+ "use strict";
2
+ /**
3
+ * HTTP + WebSocket server
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.createServer = createServer;
10
+ const express_1 = __importDefault(require("express"));
11
+ const ws_1 = require("ws");
12
+ const http_1 = require("http");
13
+ const path_1 = require("path");
14
+ const logger_1 = require("../utils/logger");
15
+ const webhooks_1 = require("../automation/webhooks");
16
+ const x402_1 = require("../payments/x402");
17
+ const production_1 = require("../utils/production");
18
+ function createServer(config, webhooks, db) {
19
+ const app = (0, express_1.default)();
20
+ let httpServer = null;
21
+ let wss = null;
22
+ let ipCleanupInterval = null;
23
+ let channelWebhookHandler = null;
24
+ let marketIndexHandler = null;
25
+ let marketIndexStatsHandler = null;
26
+ let marketIndexSyncHandler = null;
27
+ let performanceDashboardHandler = null;
28
+ let backtestHandler = null;
29
+ let ticksHandler = null;
30
+ let ohlcHandler = null;
31
+ let orderbookHistoryHandler = null;
32
+ let tickRecorderStatsHandler = null;
33
+ let tickStreamer = null;
34
+ let featureEngineering = null;
35
+ let commandListHandler = null;
36
+ // Auth middleware for sensitive endpoints
37
+ const authToken = process.env.CLODDS_TOKEN;
38
+ const requireAuth = (req, res, next) => {
39
+ if (!authToken) {
40
+ // No token configured - allow access (for development)
41
+ return next();
42
+ }
43
+ const providedToken = req.headers.authorization?.replace('Bearer ', '') || req.query.token;
44
+ if (providedToken !== authToken) {
45
+ res.status(401).json({ error: 'Unauthorized - provide valid token via Authorization header or ?token= param' });
46
+ return;
47
+ }
48
+ next();
49
+ };
50
+ const corsConfig = config.cors ?? false;
51
+ app.use((req, res, next) => {
52
+ if (!corsConfig) {
53
+ return next();
54
+ }
55
+ const originHeader = req.headers.origin;
56
+ let origin = '';
57
+ let allowCredentials = false;
58
+ if (Array.isArray(corsConfig)) {
59
+ // Security: Only allow specific origins from allowlist
60
+ if (originHeader && corsConfig.includes(originHeader)) {
61
+ origin = originHeader;
62
+ allowCredentials = true; // Safe to allow credentials with specific origin
63
+ }
64
+ }
65
+ else if (corsConfig === true) {
66
+ // Security: Wildcard origin - do NOT allow credentials
67
+ origin = '*';
68
+ allowCredentials = false;
69
+ }
70
+ if (origin) {
71
+ res.setHeader('Access-Control-Allow-Origin', origin);
72
+ res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
73
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
74
+ // Security: Only allow credentials with specific origins, never with wildcard
75
+ if (allowCredentials) {
76
+ res.setHeader('Access-Control-Allow-Credentials', 'true');
77
+ }
78
+ }
79
+ if (req.method === 'OPTIONS') {
80
+ res.status(204).end();
81
+ return;
82
+ }
83
+ next();
84
+ });
85
+ // IP-based rate limiting
86
+ const ipRequestCounts = new Map();
87
+ const IP_RATE_LIMIT = parseInt(process.env.CLODDS_IP_RATE_LIMIT || '100', 10); // requests per minute
88
+ const IP_RATE_WINDOW_MS = 60 * 1000; // 1 minute
89
+ app.use((req, res, next) => {
90
+ // Skip rate limiting for health checks
91
+ if (req.path === '/health')
92
+ return next();
93
+ const ip = req.ip || req.socket.remoteAddress || 'unknown';
94
+ const now = Date.now();
95
+ let record = ipRequestCounts.get(ip);
96
+ if (!record || now > record.resetAt) {
97
+ record = { count: 0, resetAt: now + IP_RATE_WINDOW_MS };
98
+ ipRequestCounts.set(ip, record);
99
+ }
100
+ record.count++;
101
+ // Set rate limit headers
102
+ res.setHeader('X-RateLimit-Limit', IP_RATE_LIMIT);
103
+ res.setHeader('X-RateLimit-Remaining', Math.max(0, IP_RATE_LIMIT - record.count));
104
+ res.setHeader('X-RateLimit-Reset', Math.ceil(record.resetAt / 1000));
105
+ if (record.count > IP_RATE_LIMIT) {
106
+ logger_1.logger.warn({ ip, count: record.count }, 'Rate limit exceeded');
107
+ res.status(429).json({
108
+ error: 'Too many requests',
109
+ retryAfter: Math.ceil((record.resetAt - now) / 1000),
110
+ });
111
+ return;
112
+ }
113
+ next();
114
+ });
115
+ // Cleanup old IP records every 5 minutes
116
+ ipCleanupInterval = setInterval(() => {
117
+ const now = Date.now();
118
+ for (const [ip, record] of ipRequestCounts) {
119
+ if (now > record.resetAt + IP_RATE_WINDOW_MS) {
120
+ ipRequestCounts.delete(ip);
121
+ }
122
+ }
123
+ }, 5 * 60 * 1000);
124
+ // HTTPS enforcement & security headers
125
+ app.use((req, res, next) => {
126
+ // HSTS header (only send over HTTPS or if explicitly enabled)
127
+ const hstsEnabled = process.env.CLODDS_HSTS_ENABLED === 'true';
128
+ const isSecure = req.secure || req.headers['x-forwarded-proto'] === 'https';
129
+ if (hstsEnabled || isSecure) {
130
+ // 1 year HSTS with includeSubDomains
131
+ res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
132
+ }
133
+ // Additional security headers
134
+ res.setHeader('X-Content-Type-Options', 'nosniff');
135
+ res.setHeader('X-Frame-Options', 'DENY');
136
+ res.setHeader('X-XSS-Protection', '1; mode=block');
137
+ // Redirect HTTP to HTTPS if forced
138
+ const forceHttps = process.env.CLODDS_FORCE_HTTPS === 'true';
139
+ if (forceHttps && !isSecure) {
140
+ const host = req.headers.host || 'localhost';
141
+ res.redirect(301, `https://${host}${req.url}`);
142
+ return;
143
+ }
144
+ next();
145
+ });
146
+ app.use(express_1.default.json({
147
+ limit: '1mb',
148
+ verify: (req, _res, buf) => {
149
+ // Capture raw body for webhook signature verification
150
+ req.rawBody = buf.toString();
151
+ },
152
+ }));
153
+ // x402 payment middleware for premium endpoints
154
+ let x402 = null;
155
+ if (config.x402?.server?.payToAddress) {
156
+ x402 = (0, x402_1.createX402Server)({
157
+ payToAddress: config.x402.server.payToAddress,
158
+ network: config.x402.server.network || 'solana',
159
+ facilitatorUrl: config.x402.facilitatorUrl,
160
+ }, {
161
+ 'POST /api/compute': { priceUsd: 0.01, description: 'Compute request' },
162
+ 'POST /api/backtest': { priceUsd: 0.05, description: 'Strategy backtest' },
163
+ 'GET /api/features': { priceUsd: 0.002, description: 'Feature snapshot' },
164
+ });
165
+ logger_1.logger.info({ network: config.x402.server.network || 'solana' }, 'x402 payment middleware enabled');
166
+ // Apply x402 middleware to premium routes
167
+ app.use(['/api/compute', '/api/backtest', '/api/features'], x402.middleware);
168
+ }
169
+ // Health check endpoint (enhanced for production)
170
+ app.get('/health', async (req, res) => {
171
+ const deep = req.query.deep === 'true';
172
+ if (!db) {
173
+ // Simple health check if no DB provided
174
+ res.json({ status: 'healthy', timestamp: Date.now() });
175
+ return;
176
+ }
177
+ try {
178
+ const health = await (0, production_1.runHealthCheck)(db, {
179
+ checkExternalApis: deep,
180
+ });
181
+ const httpStatus = health.status === 'healthy' ? 200 :
182
+ health.status === 'degraded' ? 200 : 503;
183
+ res.status(httpStatus).json(health);
184
+ }
185
+ catch (err) {
186
+ logger_1.logger.error({ err }, 'Health check failed');
187
+ res.status(503).json({
188
+ status: 'unhealthy',
189
+ timestamp: Date.now(),
190
+ error: 'Health check failed',
191
+ });
192
+ }
193
+ });
194
+ // Metrics endpoint (for monitoring) - requires auth if CLODDS_TOKEN is set
195
+ app.get('/metrics', requireAuth, (_req, res) => {
196
+ const requestMetrics = (0, production_1.getRequestMetrics)();
197
+ const errorStats = (0, production_1.getErrorStats)();
198
+ const memUsage = process.memoryUsage();
199
+ res.json({
200
+ timestamp: Date.now(),
201
+ requests: requestMetrics,
202
+ errors: {
203
+ recentCount: errorStats.recentCount,
204
+ topErrors: errorStats.topErrors,
205
+ },
206
+ memory: {
207
+ heapUsedMB: Math.round(memUsage.heapUsed / 1024 / 1024),
208
+ heapTotalMB: Math.round(memUsage.heapTotal / 1024 / 1024),
209
+ rssMB: Math.round(memUsage.rss / 1024 / 1024),
210
+ },
211
+ });
212
+ });
213
+ // x402 payment stats endpoint
214
+ app.get('/api/x402/stats', requireAuth, (_req, res) => {
215
+ if (!x402) {
216
+ res.json({ enabled: false });
217
+ return;
218
+ }
219
+ res.json({ enabled: true, ...x402.getStats() });
220
+ });
221
+ // API info endpoint
222
+ app.get('/', (_req, res) => {
223
+ res.json({
224
+ name: 'clodds',
225
+ version: process.env.npm_package_version || '0.1.0',
226
+ description: 'AI assistant for prediction markets',
227
+ endpoints: {
228
+ websocket: '/ws',
229
+ webchat: '/chat',
230
+ tickStream: '/api/ticks/stream',
231
+ health: '/health',
232
+ healthDeep: '/health?deep=true',
233
+ metrics: '/metrics',
234
+ dashboard: '/dashboard',
235
+ tickStreamerStats: '/api/tick-streamer/stats',
236
+ features: '/api/features/:platform/:marketId',
237
+ featuresAll: '/api/features',
238
+ featuresStats: '/api/features/stats',
239
+ },
240
+ });
241
+ });
242
+ // Command list for slash command palette
243
+ app.get('/api/commands', (_req, res) => {
244
+ if (!commandListHandler) {
245
+ res.json({ commands: [] });
246
+ return;
247
+ }
248
+ res.json({ commands: commandListHandler() });
249
+ });
250
+ // ── Session REST API for webchat ──
251
+ // GET /api/chat/sessions — list sessions for a user
252
+ app.get('/api/chat/sessions', (req, res) => {
253
+ const userId = req.query.userId || '';
254
+ if (!userId || !db?.listWebchatSessions) {
255
+ res.json({ sessions: [] });
256
+ return;
257
+ }
258
+ try {
259
+ const sessions = db.listWebchatSessions(userId);
260
+ res.json({ sessions });
261
+ }
262
+ catch (error) {
263
+ logger_1.logger.error({ error }, 'Failed to list webchat sessions');
264
+ res.status(500).json({ error: 'Failed to list sessions' });
265
+ }
266
+ });
267
+ // GET /api/chat/sessions/:id — load session with messages
268
+ app.get('/api/chat/sessions/:id', (req, res) => {
269
+ if (!db?.getSessionById) {
270
+ res.status(404).json({ error: 'Not found' });
271
+ return;
272
+ }
273
+ try {
274
+ const session = db.getSessionById(req.params.id);
275
+ if (!session) {
276
+ res.status(404).json({ error: 'Session not found' });
277
+ return;
278
+ }
279
+ res.json({
280
+ id: session.id,
281
+ title: session.title,
282
+ messages: session.context.conversationHistory || [],
283
+ updatedAt: session.updatedAt.getTime(),
284
+ });
285
+ }
286
+ catch (error) {
287
+ logger_1.logger.error({ error }, 'Failed to get webchat session');
288
+ res.status(500).json({ error: 'Failed to get session' });
289
+ }
290
+ });
291
+ // POST /api/chat/sessions — create new session
292
+ app.post('/api/chat/sessions', (req, res) => {
293
+ if (!db?.createSession) {
294
+ res.status(500).json({ error: 'Database not available' });
295
+ return;
296
+ }
297
+ try {
298
+ const userId = req.body?.userId || 'web-anonymous';
299
+ const now = new Date();
300
+ const sessionId = crypto.randomUUID();
301
+ const session = {
302
+ id: sessionId,
303
+ key: `agent:main:webchat:dm:${sessionId}:${userId}`,
304
+ userId,
305
+ channel: 'webchat',
306
+ chatId: sessionId,
307
+ chatType: 'dm',
308
+ context: {
309
+ messageCount: 0,
310
+ lastMarkets: [],
311
+ preferences: {},
312
+ conversationHistory: [],
313
+ },
314
+ history: [],
315
+ lastActivity: now,
316
+ createdAt: now,
317
+ updatedAt: now,
318
+ };
319
+ db.createSession(session);
320
+ res.json({
321
+ session: {
322
+ id: session.id,
323
+ title: undefined,
324
+ updatedAt: now.getTime(),
325
+ messageCount: 0,
326
+ lastMessage: undefined,
327
+ },
328
+ });
329
+ }
330
+ catch (error) {
331
+ logger_1.logger.error({ error }, 'Failed to create webchat session');
332
+ res.status(500).json({ error: 'Failed to create session' });
333
+ }
334
+ });
335
+ // DELETE /api/chat/sessions/:id — delete a session
336
+ app.delete('/api/chat/sessions/:id', (req, res) => {
337
+ if (!db?.getSessionById || !db?.deleteSession) {
338
+ res.status(500).json({ error: 'Database not available' });
339
+ return;
340
+ }
341
+ try {
342
+ const session = db.getSessionById(req.params.id);
343
+ if (!session) {
344
+ res.status(404).json({ error: 'Session not found' });
345
+ return;
346
+ }
347
+ db.deleteSession(session.key);
348
+ res.json({ ok: true });
349
+ }
350
+ catch (error) {
351
+ logger_1.logger.error({ error }, 'Failed to delete webchat session');
352
+ res.status(500).json({ error: 'Failed to delete session' });
353
+ }
354
+ });
355
+ // PATCH /api/chat/sessions/:id — rename session
356
+ app.patch('/api/chat/sessions/:id', (req, res) => {
357
+ if (!db?.getSessionById || !db?.updateSessionTitle) {
358
+ res.status(500).json({ error: 'Database not available' });
359
+ return;
360
+ }
361
+ try {
362
+ const session = db.getSessionById(req.params.id);
363
+ if (!session) {
364
+ res.status(404).json({ error: 'Session not found' });
365
+ return;
366
+ }
367
+ const title = req.body?.title;
368
+ if (typeof title === 'string') {
369
+ db.updateSessionTitle(session.key, title);
370
+ }
371
+ res.json({ ok: true });
372
+ }
373
+ catch (error) {
374
+ logger_1.logger.error({ error }, 'Failed to update webchat session');
375
+ res.status(500).json({ error: 'Failed to update session' });
376
+ }
377
+ });
378
+ // ── Static webchat files (no-cache to ensure updates propagate immediately) ──
379
+ app.use('/webchat', express_1.default.static((0, path_1.join)(__dirname, '../../public/webchat'), {
380
+ setHeaders: (res) => {
381
+ res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
382
+ },
383
+ }));
384
+ // Legacy inline WebChat HTML client
385
+ app.get('/webchat/legacy', (_req, res) => {
386
+ res.send(`
387
+ <!DOCTYPE html>
388
+ <html>
389
+ <head>
390
+ <meta charset="UTF-8">
391
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
392
+ <title>Clodds</title>
393
+ <style>
394
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
395
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
396
+ :root {
397
+ --bg-primary: #0c0a1a;
398
+ --bg-secondary: #151228;
399
+ --bg-card: #1c1835;
400
+ --bg-input: #1c1835;
401
+ --border: #2d2755;
402
+ --border-hover: #4a3f8a;
403
+ --text-primary: #eee9ff;
404
+ --text-secondary: #9b8fc4;
405
+ --text-dim: #6b5f9e;
406
+ --accent: #a78bfa;
407
+ --accent-bright: #c4b5fd;
408
+ --accent-glow: rgba(167, 139, 250, 0.15);
409
+ --cyan: #22d3ee;
410
+ --cyan-dim: rgba(34, 211, 238, 0.12);
411
+ --orange: #f59e0b;
412
+ --orange-dim: rgba(245, 158, 11, 0.12);
413
+ --green: #34d399;
414
+ --red: #f87171;
415
+ --user-bg: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
416
+ --bot-bg: #1c1835;
417
+ --radius: 16px;
418
+ --radius-sm: 10px;
419
+ --radius-xs: 6px;
420
+ }
421
+ html, body { height: 100%; }
422
+ body {
423
+ font-family: 'Inter', system-ui, -apple-system, sans-serif;
424
+ background: var(--bg-primary);
425
+ color: var(--text-primary);
426
+ display: flex;
427
+ flex-direction: column;
428
+ overflow: hidden;
429
+ }
430
+
431
+ /* ── Header ── */
432
+ .header {
433
+ display: flex;
434
+ align-items: center;
435
+ gap: 14px;
436
+ padding: 16px 24px;
437
+ background: var(--bg-secondary);
438
+ border-bottom: 1px solid var(--border);
439
+ flex-shrink: 0;
440
+ }
441
+ .header-logo {
442
+ width: 42px; height: 42px;
443
+ border-radius: var(--radius-sm);
444
+ box-shadow: 0 0 20px rgba(167, 139, 250, 0.2);
445
+ }
446
+ .header-info { flex: 1; }
447
+ .header-title {
448
+ font-size: 18px;
449
+ font-weight: 700;
450
+ background: linear-gradient(135deg, #f5f3ff 0%, #c4b5fd 50%, #f59e0b 100%);
451
+ -webkit-background-clip: text;
452
+ -webkit-text-fill-color: transparent;
453
+ background-clip: text;
454
+ }
455
+ .header-subtitle {
456
+ font-size: 12px;
457
+ color: var(--text-dim);
458
+ margin-top: 1px;
459
+ }
460
+ .status-dot {
461
+ width: 8px; height: 8px;
462
+ border-radius: 50%;
463
+ background: var(--text-dim);
464
+ transition: background 0.3s;
465
+ flex-shrink: 0;
466
+ }
467
+ .status-dot.connected { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.5); }
468
+ .status-dot.error { background: var(--red); }
469
+
470
+ /* ── Messages ── */
471
+ #messages {
472
+ flex: 1;
473
+ overflow-y: auto;
474
+ padding: 20px 24px;
475
+ display: flex;
476
+ flex-direction: column;
477
+ gap: 6px;
478
+ scroll-behavior: smooth;
479
+ }
480
+ #messages::-webkit-scrollbar { width: 5px; }
481
+ #messages::-webkit-scrollbar-track { background: transparent; }
482
+ #messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
483
+ #messages::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
484
+
485
+ .msg-row { display: flex; align-items: flex-end; gap: 10px; animation: fadeUp 0.25s ease-out; }
486
+ .msg-row.user-row { flex-direction: row-reverse; }
487
+ @keyframes fadeUp {
488
+ from { opacity: 0; transform: translateY(8px); }
489
+ to { opacity: 1; transform: translateY(0); }
490
+ }
491
+
492
+ .msg-avatar {
493
+ width: 30px; height: 30px;
494
+ border-radius: 50%;
495
+ flex-shrink: 0;
496
+ display: flex; align-items: center; justify-content: center;
497
+ font-size: 14px;
498
+ margin-bottom: 2px;
499
+ }
500
+ .bot-avatar {
501
+ background: linear-gradient(135deg, #4c1d95, #6d28d9);
502
+ color: #f59e0b;
503
+ }
504
+ .user-avatar {
505
+ background: linear-gradient(135deg, #0891b2, #06b6d4);
506
+ color: #0c0a1a;
507
+ font-weight: 600;
508
+ }
509
+
510
+ .msg-bubble {
511
+ max-width: 75%;
512
+ padding: 12px 16px;
513
+ line-height: 1.6;
514
+ font-size: 14px;
515
+ word-wrap: break-word;
516
+ white-space: pre-wrap;
517
+ }
518
+ .msg-bubble.user-bubble {
519
+ background: var(--user-bg);
520
+ color: #f5f3ff;
521
+ border-radius: var(--radius) var(--radius) var(--radius-xs) var(--radius);
522
+ }
523
+ .msg-bubble.bot-bubble {
524
+ background: var(--bg-card);
525
+ color: var(--text-primary);
526
+ border: 1px solid var(--border);
527
+ border-radius: var(--radius) var(--radius) var(--radius) var(--radius-xs);
528
+ }
529
+ .msg-bubble.bot-bubble pre, .msg-bubble.bot-bubble code {
530
+ font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
531
+ font-size: 12.5px;
532
+ }
533
+ .msg-bubble.bot-bubble pre {
534
+ background: rgba(0,0,0,0.3);
535
+ padding: 10px 12px;
536
+ border-radius: var(--radius-xs);
537
+ margin: 8px 0;
538
+ overflow-x: auto;
539
+ border: 1px solid rgba(255,255,255,0.05);
540
+ }
541
+ .msg-bubble.bot-bubble code {
542
+ background: rgba(167, 139, 250, 0.12);
543
+ padding: 2px 6px;
544
+ border-radius: 4px;
545
+ color: var(--accent-bright);
546
+ }
547
+ .msg-bubble.bot-bubble a {
548
+ color: var(--cyan);
549
+ text-decoration: none;
550
+ }
551
+ .msg-bubble.bot-bubble a:hover { text-decoration: underline; }
552
+ .msg-bubble.bot-bubble img {
553
+ max-width: 100%;
554
+ border-radius: var(--radius-sm);
555
+ margin-top: 8px;
556
+ }
557
+
558
+ .msg-system {
559
+ text-align: center;
560
+ font-size: 12px;
561
+ color: var(--text-dim);
562
+ padding: 8px 16px;
563
+ animation: fadeUp 0.25s ease-out;
564
+ }
565
+ .msg-system .pill {
566
+ display: inline-block;
567
+ padding: 4px 14px;
568
+ background: var(--accent-glow);
569
+ border: 1px solid rgba(167, 139, 250, 0.15);
570
+ border-radius: 20px;
571
+ color: var(--text-secondary);
572
+ }
573
+
574
+ /* ── Typing indicator ── */
575
+ .typing { display: none; align-items: flex-end; gap: 10px; padding: 0 24px 6px; }
576
+ .typing.visible { display: flex; }
577
+ .typing-dots {
578
+ display: flex; gap: 4px;
579
+ padding: 14px 18px;
580
+ background: var(--bg-card);
581
+ border: 1px solid var(--border);
582
+ border-radius: var(--radius) var(--radius) var(--radius) var(--radius-xs);
583
+ }
584
+ .typing-dots span {
585
+ width: 7px; height: 7px;
586
+ border-radius: 50%;
587
+ background: var(--text-dim);
588
+ animation: bounce 1.4s infinite ease-in-out;
589
+ }
590
+ .typing-dots span:nth-child(2) { animation-delay: 0.16s; }
591
+ .typing-dots span:nth-child(3) { animation-delay: 0.32s; }
592
+ @keyframes bounce {
593
+ 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
594
+ 40% { transform: scale(1); opacity: 1; }
595
+ }
596
+
597
+ /* ── Input ── */
598
+ .input-area {
599
+ padding: 16px 24px 20px;
600
+ background: var(--bg-secondary);
601
+ border-top: 1px solid var(--border);
602
+ flex-shrink: 0;
603
+ }
604
+ .input-wrap {
605
+ display: flex;
606
+ align-items: center;
607
+ gap: 10px;
608
+ background: var(--bg-input);
609
+ border: 1px solid var(--border);
610
+ border-radius: var(--radius);
611
+ padding: 4px 4px 4px 18px;
612
+ transition: border-color 0.2s, box-shadow 0.2s;
613
+ }
614
+ .input-wrap:focus-within {
615
+ border-color: var(--accent);
616
+ box-shadow: 0 0 0 3px var(--accent-glow);
617
+ }
618
+ #input {
619
+ flex: 1;
620
+ border: none;
621
+ background: transparent;
622
+ color: var(--text-primary);
623
+ font-size: 14px;
624
+ font-family: inherit;
625
+ outline: none;
626
+ padding: 10px 0;
627
+ }
628
+ #input::placeholder { color: var(--text-dim); }
629
+ #send-btn {
630
+ width: 40px; height: 40px;
631
+ border: none;
632
+ border-radius: 12px;
633
+ background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
634
+ color: white;
635
+ cursor: pointer;
636
+ display: flex; align-items: center; justify-content: center;
637
+ flex-shrink: 0;
638
+ transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
639
+ opacity: 0.5;
640
+ }
641
+ #send-btn.active { opacity: 1; }
642
+ #send-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4); }
643
+ #send-btn:active { transform: scale(0.95); }
644
+ #send-btn svg { width: 18px; height: 18px; }
645
+
646
+ .input-hint {
647
+ display: flex;
648
+ justify-content: space-between;
649
+ margin-top: 8px;
650
+ font-size: 11px;
651
+ color: var(--text-dim);
652
+ padding: 0 4px;
653
+ }
654
+ .input-hint kbd {
655
+ background: rgba(255,255,255,0.06);
656
+ padding: 1px 6px;
657
+ border-radius: 4px;
658
+ font-family: inherit;
659
+ font-size: 11px;
660
+ }
661
+
662
+ /* ── Command Palette ── */
663
+ .cmd-palette {
664
+ display: none;
665
+ position: absolute;
666
+ bottom: 100%;
667
+ left: 0; right: 0;
668
+ max-height: 380px;
669
+ overflow-y: auto;
670
+ background: var(--bg-primary);
671
+ border: 1px solid var(--border);
672
+ border-bottom: none;
673
+ border-radius: var(--radius) var(--radius) 0 0;
674
+ z-index: 100;
675
+ box-shadow: 0 -12px 48px rgba(0,0,0,0.5);
676
+ scrollbar-width: thin;
677
+ scrollbar-color: var(--border) transparent;
678
+ }
679
+ .cmd-palette::-webkit-scrollbar { width: 6px; }
680
+ .cmd-palette::-webkit-scrollbar-track { background: transparent; }
681
+ .cmd-palette::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
682
+ .cmd-palette.visible { display: block; }
683
+ .cmd-palette-header {
684
+ padding: 12px 16px;
685
+ font-size: 11px;
686
+ font-weight: 600;
687
+ text-transform: uppercase;
688
+ letter-spacing: 0.8px;
689
+ color: var(--text-dim);
690
+ border-bottom: 1px solid var(--border);
691
+ position: sticky;
692
+ top: 0;
693
+ background: var(--bg-primary);
694
+ display: flex;
695
+ align-items: center;
696
+ justify-content: space-between;
697
+ z-index: 1;
698
+ backdrop-filter: blur(8px);
699
+ }
700
+ .cmd-palette-hint {
701
+ font-size: 10px;
702
+ color: var(--text-dim);
703
+ font-weight: 400;
704
+ letter-spacing: 0;
705
+ text-transform: none;
706
+ }
707
+ .cmd-palette-hint kbd {
708
+ background: rgba(255,255,255,0.06);
709
+ padding: 1px 5px;
710
+ border-radius: 3px;
711
+ font-family: inherit;
712
+ font-size: 10px;
713
+ margin: 0 1px;
714
+ }
715
+ .cmd-back {
716
+ padding: 8px 16px;
717
+ font-size: 11px;
718
+ color: var(--text-dim);
719
+ cursor: pointer;
720
+ border-bottom: 1px solid var(--border);
721
+ display: flex;
722
+ align-items: center;
723
+ gap: 6px;
724
+ }
725
+ .cmd-back:hover { color: var(--accent); }
726
+ .cmd-category {
727
+ border-bottom: 1px solid rgba(45,39,85,0.5);
728
+ }
729
+ .cmd-category:last-child { border-bottom: none; }
730
+ .cmd-category-label {
731
+ padding: 10px 16px 4px;
732
+ font-size: 10px;
733
+ font-weight: 700;
734
+ text-transform: uppercase;
735
+ letter-spacing: 0.8px;
736
+ color: var(--text-dim);
737
+ display: flex;
738
+ align-items: center;
739
+ gap: 6px;
740
+ }
741
+ .cmd-category-icon {
742
+ font-size: 12px;
743
+ opacity: 0.7;
744
+ }
745
+ .cmd-category-count {
746
+ margin-left: auto;
747
+ font-size: 9px;
748
+ font-weight: 500;
749
+ color: var(--text-dim);
750
+ background: rgba(255,255,255,0.04);
751
+ padding: 1px 6px;
752
+ border-radius: 8px;
753
+ }
754
+ .cmd-item {
755
+ display: flex;
756
+ align-items: center;
757
+ gap: 10px;
758
+ padding: 7px 16px 7px 28px;
759
+ cursor: pointer;
760
+ transition: background 0.1s;
761
+ }
762
+ .cmd-item:hover, .cmd-item.active {
763
+ background: var(--accent-glow);
764
+ }
765
+ .cmd-item.active {
766
+ border-left: 2px solid var(--accent);
767
+ padding-left: 26px;
768
+ }
769
+ .cmd-item-name {
770
+ font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
771
+ font-size: 13px;
772
+ font-weight: 600;
773
+ color: var(--accent-bright);
774
+ min-width: 140px;
775
+ flex-shrink: 0;
776
+ }
777
+ .cmd-item-desc {
778
+ font-size: 12px;
779
+ color: var(--text-secondary);
780
+ overflow: hidden;
781
+ text-overflow: ellipsis;
782
+ white-space: nowrap;
783
+ flex: 1;
784
+ }
785
+ .cmd-count {
786
+ font-size: 10px;
787
+ color: var(--text-dim);
788
+ background: rgba(255,255,255,0.04);
789
+ padding: 2px 8px;
790
+ border-radius: 8px;
791
+ }
792
+
793
+ /* ── Welcome ── */
794
+ .welcome {
795
+ display: flex;
796
+ flex-direction: column;
797
+ align-items: center;
798
+ justify-content: center;
799
+ flex: 1;
800
+ gap: 16px;
801
+ padding: 40px 24px;
802
+ text-align: center;
803
+ }
804
+ .welcome-logo {
805
+ width: 80px; height: 80px;
806
+ border-radius: 20px;
807
+ box-shadow: 0 0 40px rgba(167, 139, 250, 0.25);
808
+ }
809
+ .welcome h2 {
810
+ font-size: 20px;
811
+ font-weight: 600;
812
+ color: var(--text-primary);
813
+ }
814
+ .welcome p {
815
+ color: var(--text-secondary);
816
+ font-size: 14px;
817
+ max-width: 340px;
818
+ line-height: 1.6;
819
+ }
820
+ .welcome-chips {
821
+ display: flex;
822
+ flex-wrap: wrap;
823
+ gap: 8px;
824
+ justify-content: center;
825
+ margin-top: 4px;
826
+ }
827
+ .welcome-chip {
828
+ padding: 8px 16px;
829
+ background: var(--bg-card);
830
+ border: 1px solid var(--border);
831
+ border-radius: 20px;
832
+ color: var(--text-secondary);
833
+ font-size: 13px;
834
+ cursor: pointer;
835
+ transition: border-color 0.2s, color 0.2s, background 0.2s;
836
+ }
837
+ .welcome-chip:hover {
838
+ border-color: var(--accent);
839
+ color: var(--accent-bright);
840
+ background: var(--accent-glow);
841
+ }
842
+
843
+ /* ── Mobile ── */
844
+ @media (max-width: 600px) {
845
+ .header { padding: 12px 16px; }
846
+ #messages { padding: 16px; }
847
+ .input-area { padding: 12px 16px 16px; }
848
+ .msg-bubble { max-width: 85%; }
849
+ .msg-avatar { width: 26px; height: 26px; font-size: 12px; }
850
+ .welcome-chips { gap: 6px; }
851
+ .welcome-chip { font-size: 12px; padding: 6px 12px; }
852
+ .input-hint { display: none; }
853
+ }
854
+ </style>
855
+ </head>
856
+ <body>
857
+ <div class="header">
858
+ <img class="header-logo" src="https://cloddsbot.com/logo.png" alt="Clodds" onerror="this.textContent=''" />
859
+ <div class="header-info">
860
+ <div class="header-title">Clodds</div>
861
+ <div class="header-subtitle">AI Trading Terminal</div>
862
+ </div>
863
+ <div class="status-dot" id="status-dot" title="Connecting..."></div>
864
+ </div>
865
+
866
+ <div id="messages">
867
+ <div class="welcome" id="welcome">
868
+ <img class="welcome-logo" src="https://cloddsbot.com/logo.png" alt="" onerror="this.style.display='none'" />
869
+ <h2>What can I help you with?</h2>
870
+ <p>I can trade prediction markets, analyze odds, track positions, and more.</p>
871
+ <div class="welcome-chips">
872
+ <div class="welcome-chip" data-msg="What markets are trending right now?">Trending markets</div>
873
+ <div class="welcome-chip" data-msg="Show my current positions">My positions</div>
874
+ <div class="welcome-chip" data-msg="What skills do you have?">Your skills</div>
875
+ <div class="welcome-chip" data-msg="Help me get started">Get started</div>
876
+ </div>
877
+ </div>
878
+ </div>
879
+
880
+ <div class="typing" id="typing">
881
+ <div class="msg-avatar bot-avatar">C</div>
882
+ <div class="typing-dots"><span></span><span></span><span></span></div>
883
+ </div>
884
+
885
+ <div class="input-area" style="position:relative">
886
+ <div class="cmd-palette" id="cmd-palette"></div>
887
+ <div class="input-wrap">
888
+ <input type="text" id="input" placeholder="Ask anything... (type / for commands)" autocomplete="off" />
889
+ <button id="send-btn" onclick="send()" title="Send">
890
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
891
+ <line x1="22" y1="2" x2="11" y2="13"></line>
892
+ <polygon points="22 2 15 22 11 13 2 9 22 2"></polygon>
893
+ </svg>
894
+ </button>
895
+ </div>
896
+ <div class="input-hint">
897
+ <span>Try: <kbd>/help</kbd> <kbd>/markets</kbd> <kbd>/positions</kbd></span>
898
+ <span><kbd>Enter</kbd> to send</span>
899
+ </div>
900
+ </div>
901
+
902
+ <script>
903
+ const port = window.location.port || 80;
904
+ const ws = new WebSocket('ws://' + window.location.hostname + ':' + port + '/chat');
905
+ const messagesEl = document.getElementById('messages');
906
+ const input = document.getElementById('input');
907
+ const sendBtn = document.getElementById('send-btn');
908
+ const statusDot = document.getElementById('status-dot');
909
+ const typingEl = document.getElementById('typing');
910
+ const welcomeEl = document.getElementById('welcome');
911
+ let hasMessages = false;
912
+
913
+ function hideWelcome() {
914
+ if (welcomeEl && !hasMessages) {
915
+ welcomeEl.remove();
916
+ hasMessages = true;
917
+ }
918
+ }
919
+
920
+ // Welcome chip clicks
921
+ document.querySelectorAll('.welcome-chip').forEach(chip => {
922
+ chip.addEventListener('click', () => {
923
+ input.value = chip.dataset.msg;
924
+ send();
925
+ });
926
+ });
927
+
928
+ // ── Command Palette ──
929
+ let allCommands = [];
930
+ let filteredCommands = [];
931
+ let activeIndex = -1;
932
+ let paletteVisible = false;
933
+ const palette = document.getElementById('cmd-palette');
934
+
935
+ fetch('/api/commands')
936
+ .then(r => r.json())
937
+ .then(data => { allCommands = data.commands || []; })
938
+ .catch(() => {});
939
+
940
+ const CAT_ICONS = {
941
+ 'Core': '\u2699',
942
+ 'Market Data': '\uD83D\uDCCA',
943
+ 'Polymarket': '\uD83D\uDFE3',
944
+ 'Kalshi': '\uD83C\uDFAF',
945
+ 'Hyperliquid': '\uD83D\uDFE2',
946
+ 'CEX Futures': '\uD83D\uDCC8',
947
+ 'Sportsbooks': '\u26BD',
948
+ 'Manifold': '\uD83C\uDFB2',
949
+ 'Metaculus': '\uD83D\uDD2E',
950
+ 'PredictIt': '\uD83C\uDFDB\uFE0F',
951
+ 'Predict.fun': '\uD83C\uDFAE',
952
+ 'Opinion': '\uD83D\uDCAC',
953
+ 'Veil': '\uD83D\uDD12',
954
+ 'AgentBets': '\uD83E\uDD16',
955
+ 'Solana DeFi': '\uD83D\uDFE1',
956
+ 'EVM DeFi': '\uD83D\uDD37',
957
+ 'Virtuals & Agents': '\uD83E\uDD16',
958
+ 'Bots & Execution': '\u26A1',
959
+ 'Portfolio': '\uD83D\uDCBC',
960
+ 'Strategy': '\uD83E\uDDE0',
961
+ 'Wallet': '\uD83D\uDC5B',
962
+ 'Automation': '\uD83D\uDD04',
963
+ 'Config': '\uD83D\uDD27',
964
+ 'Tools': '\uD83E\uDDF0',
965
+ 'Bittensor': '\uD83E\uDDE0',
966
+ 'Other': '\uD83D\uDCE6',
967
+ };
968
+
969
+ let subcommandMode = false;
970
+
971
+ function showPalette(filter) {
972
+ const text = filter.slice(1); // strip leading /
973
+ const spaceIdx = text.indexOf(' ');
974
+
975
+ if (spaceIdx > 0) {
976
+ // SUBCOMMAND MODE: "/hl lo" → show /hl's subcommands filtered by "lo"
977
+ const parentCmd = '/' + text.slice(0, spaceIdx);
978
+ const subQuery = text.slice(spaceIdx + 1).toLowerCase();
979
+ const parent = allCommands.find(c => c.name === parentCmd);
980
+ if (!parent || !parent.subcommands || !parent.subcommands.length) { hidePalette(); return; }
981
+
982
+ const subs = subQuery
983
+ ? parent.subcommands.filter(s => s.name.toLowerCase().includes(subQuery) || s.description.toLowerCase().includes(subQuery) || (s.category || '').toLowerCase().includes(subQuery))
984
+ : parent.subcommands;
985
+
986
+ if (!subs.length) { hidePalette(); return; }
987
+ filteredCommands = subs.map(s => ({ name: s.name, description: s.description, category: s.category || 'General', fullName: parentCmd + ' ' + s.name }));
988
+ subcommandMode = true;
989
+
990
+ let html = '<div class="cmd-palette-header">'
991
+ + '<span>' + parentCmd + '</span>'
992
+ + '<span class="cmd-palette-hint"><kbd>\u2191\u2193</kbd> navigate <kbd>Tab</kbd> select <kbd>Esc</kbd> close</span>'
993
+ + '</div>';
994
+ html += '<div class="cmd-back" data-action="back">\u2190 All commands</div>';
995
+
996
+ // Group subcommands by category
997
+ const subGroups = {};
998
+ for (const cmd of filteredCommands) {
999
+ (subGroups[cmd.category] = subGroups[cmd.category] || []).push(cmd);
1000
+ }
1001
+
1002
+ let idx = 0;
1003
+ for (const [section, cmds] of Object.entries(subGroups)) {
1004
+ html += '<div class="cmd-category">'
1005
+ + '<div class="cmd-category-label">'
1006
+ + '<span>' + section + '</span>'
1007
+ + '<span class="cmd-category-count">' + cmds.length + '</span>'
1008
+ + '</div>';
1009
+ for (const cmd of cmds) {
1010
+ html += '<div class="cmd-item' + (idx === activeIndex ? ' active' : '') + '" data-index="' + idx + '" data-name="' + cmd.fullName + '">'
1011
+ + '<span class="cmd-item-name">' + cmd.name + '</span>'
1012
+ + '<span class="cmd-item-desc">' + cmd.description + '</span></div>';
1013
+ idx++;
1014
+ }
1015
+ html += '</div>';
1016
+ }
1017
+
1018
+ palette.innerHTML = html;
1019
+ palette.classList.add('visible');
1020
+ paletteVisible = true;
1021
+
1022
+ palette.querySelectorAll('.cmd-item').forEach(item => {
1023
+ item.addEventListener('click', () => {
1024
+ input.value = '/' + item.dataset.name + ' ';
1025
+ hidePalette();
1026
+ input.focus();
1027
+ sendBtn.classList.add('active');
1028
+ });
1029
+ });
1030
+ const backBtn = palette.querySelector('.cmd-back');
1031
+ if (backBtn) {
1032
+ backBtn.addEventListener('click', () => {
1033
+ input.value = '/';
1034
+ showPalette('/');
1035
+ input.focus();
1036
+ });
1037
+ }
1038
+ return;
1039
+ }
1040
+
1041
+ // TOP-LEVEL MODE (existing behavior)
1042
+ subcommandMode = false;
1043
+ const query = text.toLowerCase();
1044
+ filteredCommands = query
1045
+ ? allCommands.filter(c =>
1046
+ c.name.toLowerCase().includes(query) ||
1047
+ c.description.toLowerCase().includes(query) ||
1048
+ c.category.toLowerCase().includes(query))
1049
+ : allCommands;
1050
+
1051
+ if (filteredCommands.length === 0) {
1052
+ hidePalette();
1053
+ return;
1054
+ }
1055
+
1056
+ // Group by category, preserve order
1057
+ const groups = {};
1058
+ for (const cmd of filteredCommands) {
1059
+ (groups[cmd.category] = groups[cmd.category] || []).push(cmd);
1060
+ }
1061
+
1062
+ let html = '<div class="cmd-palette-header">'
1063
+ + '<span>Commands</span>'
1064
+ + '<span class="cmd-palette-hint"><kbd>\u2191\u2193</kbd> navigate <kbd>Tab</kbd> select <kbd>Esc</kbd> close</span>'
1065
+ + '</div>';
1066
+
1067
+ let idx = 0;
1068
+ for (const [category, cmds] of Object.entries(groups)) {
1069
+ const icon = CAT_ICONS[category] || '\uD83D\uDCE6';
1070
+ html += '<div class="cmd-category">'
1071
+ + '<div class="cmd-category-label">'
1072
+ + '<span class="cmd-category-icon">' + icon + '</span>'
1073
+ + '<span>' + category + '</span>'
1074
+ + '<span class="cmd-category-count">' + cmds.length + '</span>'
1075
+ + '</div>';
1076
+ for (const cmd of cmds) {
1077
+ const hasSubs = cmd.subcommands && cmd.subcommands.length > 0;
1078
+ html += '<div class="cmd-item' + (idx === activeIndex ? ' active' : '') + '" data-index="' + idx + '" data-name="' + cmd.name + '">'
1079
+ + '<span class="cmd-item-name">' + cmd.name + '</span>'
1080
+ + '<span class="cmd-item-desc">' + cmd.description + (hasSubs ? ' \u203A' : '') + '</span></div>';
1081
+ idx++;
1082
+ }
1083
+ html += '</div>';
1084
+ }
1085
+
1086
+ palette.innerHTML = html;
1087
+ palette.classList.add('visible');
1088
+ paletteVisible = true;
1089
+
1090
+ palette.querySelectorAll('.cmd-item').forEach(item => {
1091
+ item.addEventListener('click', () => {
1092
+ input.value = item.dataset.name + ' ';
1093
+ hidePalette();
1094
+ input.focus();
1095
+ sendBtn.classList.add('active');
1096
+ });
1097
+ });
1098
+ }
1099
+
1100
+ function hidePalette() {
1101
+ palette.classList.remove('visible');
1102
+ paletteVisible = false;
1103
+ activeIndex = -1;
1104
+ }
1105
+
1106
+ // Send button active state + palette trigger
1107
+ input.addEventListener('input', () => {
1108
+ const text = input.value;
1109
+ if (text.startsWith('/')) {
1110
+ const afterSlash = text.slice(1);
1111
+ const spaceIdx = afterSlash.indexOf(' ');
1112
+ if (spaceIdx === -1) {
1113
+ // Top-level: "/hl" — filter commands
1114
+ showPalette(text);
1115
+ } else {
1116
+ // Subcommand: "/hl " or "/hl lo" — show subcommands
1117
+ const parentCmd = '/' + afterSlash.slice(0, spaceIdx);
1118
+ const parent = allCommands.find(c => c.name === parentCmd);
1119
+ if (parent && parent.subcommands && parent.subcommands.length > 0) {
1120
+ activeIndex = -1;
1121
+ showPalette(text);
1122
+ } else {
1123
+ hidePalette();
1124
+ }
1125
+ }
1126
+ } else {
1127
+ hidePalette();
1128
+ }
1129
+ sendBtn.classList.toggle('active', text.trim().length > 0);
1130
+ });
1131
+
1132
+ document.addEventListener('click', (e) => {
1133
+ if (!palette.contains(e.target) && e.target !== input) hidePalette();
1134
+ });
1135
+
1136
+ function addMsg(text, cls, messageId) {
1137
+ hideWelcome();
1138
+ if (cls === 'system') {
1139
+ const row = document.createElement('div');
1140
+ row.className = 'msg-system';
1141
+ if (messageId) row.dataset.messageId = messageId;
1142
+ const pill = document.createElement('span');
1143
+ pill.className = 'pill';
1144
+ pill.textContent = text;
1145
+ row.appendChild(pill);
1146
+ messagesEl.appendChild(row);
1147
+ } else {
1148
+ const row = document.createElement('div');
1149
+ row.className = 'msg-row ' + (cls === 'user' ? 'user-row' : '');
1150
+ if (messageId) row.dataset.messageId = messageId;
1151
+
1152
+ const avatar = document.createElement('div');
1153
+ avatar.className = 'msg-avatar ' + (cls === 'user' ? 'user-avatar' : 'bot-avatar');
1154
+ avatar.textContent = cls === 'user' ? 'U' : 'C';
1155
+
1156
+ const bubble = document.createElement('div');
1157
+ bubble.className = 'msg-bubble ' + (cls === 'user' ? 'user-bubble' : 'bot-bubble');
1158
+ bubble.textContent = text;
1159
+
1160
+ row.appendChild(avatar);
1161
+ row.appendChild(bubble);
1162
+ messagesEl.appendChild(row);
1163
+ }
1164
+ messagesEl.scrollTop = messagesEl.scrollHeight;
1165
+ }
1166
+
1167
+ function showTyping() { typingEl.classList.add('visible'); messagesEl.scrollTop = messagesEl.scrollHeight; }
1168
+ function hideTyping() { typingEl.classList.remove('visible'); }
1169
+
1170
+ function getToken() {
1171
+ const params = new URLSearchParams(window.location.search);
1172
+ const queryToken = params.get('token');
1173
+ if (queryToken) {
1174
+ localStorage.setItem('webchat_token', queryToken);
1175
+ return queryToken;
1176
+ }
1177
+ return localStorage.getItem('webchat_token') || '';
1178
+ }
1179
+
1180
+ ws.onopen = () => {
1181
+ statusDot.className = 'status-dot connected';
1182
+ statusDot.title = 'Connected';
1183
+ const token = getToken();
1184
+ ws.send(JSON.stringify({ type: 'auth', token, userId: 'web-' + Date.now() }));
1185
+ };
1186
+
1187
+ function renderAttachments(attachments) {
1188
+ if (!Array.isArray(attachments) || attachments.length === 0) return [];
1189
+ const nodes = [];
1190
+ for (const attachment of attachments) {
1191
+ const resolvedUrl = attachment.url || (attachment.data && attachment.mimeType
1192
+ ? 'data:' + attachment.mimeType + ';base64,' + attachment.data
1193
+ : null);
1194
+ if (attachment.type === 'image' && resolvedUrl) {
1195
+ const img = document.createElement('img');
1196
+ img.src = resolvedUrl || '';
1197
+ img.style.maxWidth = '100%';
1198
+ img.style.display = 'block';
1199
+ img.style.marginTop = '8px';
1200
+ img.style.borderRadius = '10px';
1201
+ nodes.push(img);
1202
+ continue;
1203
+ }
1204
+ if ((attachment.type === 'video' || attachment.type === 'audio') && resolvedUrl) {
1205
+ const media = document.createElement(attachment.type === 'video' ? 'video' : 'audio');
1206
+ media.src = resolvedUrl;
1207
+ media.controls = true;
1208
+ media.style.width = '100%';
1209
+ media.style.marginTop = '8px';
1210
+ media.style.borderRadius = '10px';
1211
+ nodes.push(media);
1212
+ continue;
1213
+ }
1214
+ const link = document.createElement('a');
1215
+ link.href = resolvedUrl || '#';
1216
+ link.textContent = attachment.filename || attachment.mimeType || 'attachment';
1217
+ link.style.display = 'block';
1218
+ link.style.marginTop = '8px';
1219
+ link.target = '_blank';
1220
+ nodes.push(link);
1221
+ }
1222
+ return nodes;
1223
+ }
1224
+
1225
+ ws.onmessage = (e) => {
1226
+ const msg = JSON.parse(e.data);
1227
+ hideTyping();
1228
+ if (msg.type === 'authenticated') {
1229
+ // Silent auth — no system message needed
1230
+ } else if (msg.type === 'message') {
1231
+ hideWelcome();
1232
+ const row = document.createElement('div');
1233
+ row.className = 'msg-row';
1234
+ if (msg.messageId) row.dataset.messageId = msg.messageId;
1235
+
1236
+ const avatar = document.createElement('div');
1237
+ avatar.className = 'msg-avatar bot-avatar';
1238
+ avatar.textContent = 'C';
1239
+
1240
+ const bubble = document.createElement('div');
1241
+ bubble.className = 'msg-bubble bot-bubble';
1242
+ bubble.textContent = msg.text || '';
1243
+
1244
+ const nodes = renderAttachments(msg.attachments || []);
1245
+
1246
+ row.appendChild(avatar);
1247
+ row.appendChild(bubble);
1248
+ for (const node of nodes) bubble.appendChild(node);
1249
+ messagesEl.appendChild(row);
1250
+ messagesEl.scrollTop = messagesEl.scrollHeight;
1251
+ } else if (msg.type === 'edit') {
1252
+ const row = Array.from(messagesEl.children)
1253
+ .find(el => el.dataset && el.dataset.messageId === msg.messageId);
1254
+ if (row) {
1255
+ const bubble = row.querySelector('.msg-bubble') || row;
1256
+ bubble.textContent = msg.text || '';
1257
+ }
1258
+ } else if (msg.type === 'delete') {
1259
+ const row = Array.from(messagesEl.children)
1260
+ .find(el => el.dataset && el.dataset.messageId === msg.messageId);
1261
+ if (row) row.remove();
1262
+ } else if (msg.type === 'error') {
1263
+ if (msg.message === 'Invalid token') {
1264
+ const retry = window.prompt('Authentication required. Enter WebChat token:');
1265
+ if (retry) {
1266
+ localStorage.setItem('webchat_token', retry);
1267
+ ws.send(JSON.stringify({ type: 'auth', token: retry, userId: 'web-' + Date.now() }));
1268
+ } else {
1269
+ addMsg('Authentication failed. Set WEBCHAT_TOKEN or pass ?token= in URL.', 'system');
1270
+ }
1271
+ } else {
1272
+ addMsg(msg.message, 'system');
1273
+ }
1274
+ }
1275
+ };
1276
+
1277
+ ws.onclose = () => {
1278
+ statusDot.className = 'status-dot error';
1279
+ statusDot.title = 'Disconnected';
1280
+ addMsg('Connection lost. Refresh to reconnect.', 'system');
1281
+ };
1282
+
1283
+ function send() {
1284
+ const text = input.value.trim();
1285
+ if (text && ws.readyState === WebSocket.OPEN) {
1286
+ addMsg(text, 'user');
1287
+ ws.send(JSON.stringify({ type: 'message', text }));
1288
+ input.value = '';
1289
+ sendBtn.classList.remove('active');
1290
+ showTyping();
1291
+ }
1292
+ }
1293
+
1294
+ input.addEventListener('keydown', (e) => {
1295
+ if (paletteVisible) {
1296
+ if (e.key === 'ArrowDown') {
1297
+ e.preventDefault();
1298
+ activeIndex = Math.min(activeIndex + 1, filteredCommands.length - 1);
1299
+ showPalette(input.value);
1300
+ const active = palette.querySelector('.cmd-item.active');
1301
+ if (active) active.scrollIntoView({ block: 'nearest' });
1302
+ } else if (e.key === 'ArrowUp') {
1303
+ e.preventDefault();
1304
+ activeIndex = Math.max(activeIndex - 1, 0);
1305
+ showPalette(input.value);
1306
+ const active = palette.querySelector('.cmd-item.active');
1307
+ if (active) active.scrollIntoView({ block: 'nearest' });
1308
+ } else if (e.key === 'Tab') {
1309
+ e.preventDefault();
1310
+ if (activeIndex >= 0 && activeIndex < filteredCommands.length) {
1311
+ const sel = filteredCommands[activeIndex];
1312
+ if (subcommandMode) {
1313
+ input.value = '/' + sel.fullName + ' ';
1314
+ } else {
1315
+ input.value = sel.name + ' ';
1316
+ // If the selected command has subcommands, re-show palette
1317
+ const parent = allCommands.find(c => c.name === sel.name);
1318
+ if (parent && parent.subcommands && parent.subcommands.length > 0) {
1319
+ activeIndex = -1;
1320
+ showPalette(input.value);
1321
+ sendBtn.classList.add('active');
1322
+ return;
1323
+ }
1324
+ }
1325
+ hidePalette();
1326
+ sendBtn.classList.add('active');
1327
+ }
1328
+ } else if (e.key === 'Enter' && !e.shiftKey) {
1329
+ if (activeIndex >= 0 && activeIndex < filteredCommands.length) {
1330
+ e.preventDefault();
1331
+ const sel = filteredCommands[activeIndex];
1332
+ if (subcommandMode) {
1333
+ input.value = '/' + sel.fullName + ' ';
1334
+ } else {
1335
+ input.value = sel.name + ' ';
1336
+ }
1337
+ hidePalette();
1338
+ sendBtn.classList.add('active');
1339
+ return;
1340
+ }
1341
+ e.preventDefault();
1342
+ hidePalette();
1343
+ send();
1344
+ } else if (e.key === 'Escape') {
1345
+ hidePalette();
1346
+ }
1347
+ } else if (e.key === 'Enter' && !e.shiftKey) {
1348
+ e.preventDefault();
1349
+ send();
1350
+ }
1351
+ });
1352
+ input.focus();
1353
+ </script>
1354
+ </body>
1355
+ </html>
1356
+ `);
1357
+ });
1358
+ if (webhooks) {
1359
+ const webhookMiddleware = (0, webhooks_1.createWebhookMiddleware)(webhooks);
1360
+ app.post('/webhook/*', webhookMiddleware);
1361
+ app.post('/webhook', webhookMiddleware);
1362
+ }
1363
+ // Channel webhooks (Teams, Google Chat, etc.)
1364
+ app.post('/channels/:platform', async (req, res) => {
1365
+ if (!channelWebhookHandler) {
1366
+ res.status(404).json({ error: 'Channel webhooks not configured' });
1367
+ return;
1368
+ }
1369
+ const platform = req.params.platform;
1370
+ try {
1371
+ const result = await channelWebhookHandler(platform, req.body, req);
1372
+ if (result === null || result === undefined) {
1373
+ res.status(200).send();
1374
+ return;
1375
+ }
1376
+ if (typeof result === 'string') {
1377
+ res.json({ text: result });
1378
+ return;
1379
+ }
1380
+ res.json(result);
1381
+ }
1382
+ catch (error) {
1383
+ logger_1.logger.error({ error, platform }, 'Channel webhook handler failed');
1384
+ res.status(500).json({ error: 'Channel webhook error' });
1385
+ }
1386
+ });
1387
+ // Market index search endpoint
1388
+ app.get('/market-index/search', async (req, res) => {
1389
+ if (!marketIndexHandler) {
1390
+ res.status(404).json({ error: 'Market index handler not configured' });
1391
+ return;
1392
+ }
1393
+ try {
1394
+ const result = await marketIndexHandler(req);
1395
+ if ('error' in result) {
1396
+ res.status(result.status ?? 400).json({ error: result.error });
1397
+ return;
1398
+ }
1399
+ res.json(result);
1400
+ }
1401
+ catch (error) {
1402
+ logger_1.logger.error({ error }, 'Market index handler failed');
1403
+ res.status(500).json({ error: 'Market index error' });
1404
+ }
1405
+ });
1406
+ app.get('/market-index/stats', async (req, res) => {
1407
+ if (!marketIndexStatsHandler) {
1408
+ res.status(404).json({ error: 'Market index handler not configured' });
1409
+ return;
1410
+ }
1411
+ try {
1412
+ const result = await marketIndexStatsHandler(req);
1413
+ if ('error' in result) {
1414
+ res.status(result.status ?? 400).json({ error: result.error });
1415
+ return;
1416
+ }
1417
+ res.json(result);
1418
+ }
1419
+ catch (error) {
1420
+ logger_1.logger.error({ error }, 'Market index stats handler failed');
1421
+ res.status(500).json({ error: 'Market index error' });
1422
+ }
1423
+ });
1424
+ app.post('/market-index/sync', async (req, res) => {
1425
+ if (!marketIndexSyncHandler) {
1426
+ res.status(404).json({ error: 'Market index handler not configured' });
1427
+ return;
1428
+ }
1429
+ try {
1430
+ const result = await marketIndexSyncHandler(req);
1431
+ if ('error' in result) {
1432
+ res.status(result.status ?? 400).json({ error: result.error });
1433
+ return;
1434
+ }
1435
+ res.json(result);
1436
+ }
1437
+ catch (error) {
1438
+ logger_1.logger.error({ error }, 'Market index sync handler failed');
1439
+ res.status(500).json({ error: 'Market index error' });
1440
+ }
1441
+ });
1442
+ // Backtest API endpoint
1443
+ app.post('/api/backtest', async (req, res) => {
1444
+ if (!backtestHandler) {
1445
+ res.status(404).json({ error: 'Backtest handler not configured' });
1446
+ return;
1447
+ }
1448
+ try {
1449
+ const result = await backtestHandler(req);
1450
+ if ('error' in result) {
1451
+ res.status(result.status ?? 400).json({ error: result.error });
1452
+ return;
1453
+ }
1454
+ res.json(result);
1455
+ }
1456
+ catch (error) {
1457
+ logger_1.logger.error({ error }, 'Backtest handler failed');
1458
+ res.status(500).json({ error: 'Backtest error' });
1459
+ }
1460
+ });
1461
+ // Performance dashboard API endpoint
1462
+ app.get('/api/performance', async (req, res) => {
1463
+ if (!performanceDashboardHandler) {
1464
+ res.status(404).json({ error: 'Performance dashboard not configured' });
1465
+ return;
1466
+ }
1467
+ try {
1468
+ const result = await performanceDashboardHandler(req);
1469
+ if ('error' in result) {
1470
+ res.status(result.status ?? 400).json({ error: result.error });
1471
+ return;
1472
+ }
1473
+ res.json(result);
1474
+ }
1475
+ catch (error) {
1476
+ logger_1.logger.error({ error }, 'Performance dashboard handler failed');
1477
+ res.status(500).json({ error: 'Performance dashboard error' });
1478
+ }
1479
+ });
1480
+ // Tick recorder endpoints
1481
+ app.get('/api/ticks/:platform/:marketId', async (req, res) => {
1482
+ if (!ticksHandler) {
1483
+ res.status(404).json({ error: 'Tick recorder not enabled' });
1484
+ return;
1485
+ }
1486
+ try {
1487
+ const result = await ticksHandler(req);
1488
+ if ('error' in result) {
1489
+ res.status(result.status ?? 400).json({ error: result.error });
1490
+ return;
1491
+ }
1492
+ res.json(result);
1493
+ }
1494
+ catch (error) {
1495
+ logger_1.logger.error({ error }, 'Ticks handler failed');
1496
+ res.status(500).json({ error: 'Ticks query error' });
1497
+ }
1498
+ });
1499
+ app.get('/api/ohlc/:platform/:marketId', async (req, res) => {
1500
+ if (!ohlcHandler) {
1501
+ res.status(404).json({ error: 'Tick recorder not enabled' });
1502
+ return;
1503
+ }
1504
+ try {
1505
+ const result = await ohlcHandler(req);
1506
+ if ('error' in result) {
1507
+ res.status(result.status ?? 400).json({ error: result.error });
1508
+ return;
1509
+ }
1510
+ res.json(result);
1511
+ }
1512
+ catch (error) {
1513
+ logger_1.logger.error({ error }, 'OHLC handler failed');
1514
+ res.status(500).json({ error: 'OHLC query error' });
1515
+ }
1516
+ });
1517
+ app.get('/api/orderbook-history/:platform/:marketId', async (req, res) => {
1518
+ if (!orderbookHistoryHandler) {
1519
+ res.status(404).json({ error: 'Tick recorder not enabled' });
1520
+ return;
1521
+ }
1522
+ try {
1523
+ const result = await orderbookHistoryHandler(req);
1524
+ if ('error' in result) {
1525
+ res.status(result.status ?? 400).json({ error: result.error });
1526
+ return;
1527
+ }
1528
+ res.json(result);
1529
+ }
1530
+ catch (error) {
1531
+ logger_1.logger.error({ error }, 'Orderbook history handler failed');
1532
+ res.status(500).json({ error: 'Orderbook history query error' });
1533
+ }
1534
+ });
1535
+ app.get('/api/tick-recorder/stats', async (req, res) => {
1536
+ if (!tickRecorderStatsHandler) {
1537
+ res.status(404).json({ error: 'Tick recorder not enabled' });
1538
+ return;
1539
+ }
1540
+ try {
1541
+ const result = await tickRecorderStatsHandler(req);
1542
+ if ('error' in result) {
1543
+ res.status(result.status ?? 400).json({ error: result.error });
1544
+ return;
1545
+ }
1546
+ res.json(result);
1547
+ }
1548
+ catch (error) {
1549
+ logger_1.logger.error({ error }, 'Tick recorder stats handler failed');
1550
+ res.status(500).json({ error: 'Tick recorder stats error' });
1551
+ }
1552
+ });
1553
+ // Tick streamer stats endpoint
1554
+ app.get('/api/tick-streamer/stats', (_req, res) => {
1555
+ if (!tickStreamer) {
1556
+ res.status(404).json({ error: 'Tick streamer not enabled' });
1557
+ return;
1558
+ }
1559
+ const stats = tickStreamer.getStats();
1560
+ res.json({ stats });
1561
+ });
1562
+ // Feature engineering endpoints
1563
+ app.get('/api/features/:platform/:marketId', (req, res) => {
1564
+ if (!featureEngineering) {
1565
+ res.status(404).json({ error: 'Feature engineering not enabled' });
1566
+ return;
1567
+ }
1568
+ const { platform, marketId } = req.params;
1569
+ const outcomeId = typeof req.query.outcomeId === 'string' ? req.query.outcomeId : undefined;
1570
+ const features = featureEngineering.getFeatures(platform, marketId, outcomeId);
1571
+ if (!features) {
1572
+ res.status(404).json({ error: 'No features available for this market' });
1573
+ return;
1574
+ }
1575
+ res.json({ features });
1576
+ });
1577
+ app.get('/api/features', (_req, res) => {
1578
+ if (!featureEngineering) {
1579
+ res.status(404).json({ error: 'Feature engineering not enabled' });
1580
+ return;
1581
+ }
1582
+ const snapshots = featureEngineering.getAllFeatures();
1583
+ res.json({ snapshots, count: snapshots.length });
1584
+ });
1585
+ app.get('/api/features/stats', (_req, res) => {
1586
+ if (!featureEngineering) {
1587
+ res.status(404).json({ error: 'Feature engineering not enabled' });
1588
+ return;
1589
+ }
1590
+ const stats = featureEngineering.getStats();
1591
+ res.json({ stats });
1592
+ });
1593
+ // Telegram Mini App
1594
+ app.get('/miniapp', (_req, res) => {
1595
+ res.send(`<!DOCTYPE html>
1596
+ <html>
1597
+ <head>
1598
+ <meta charset="UTF-8">
1599
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
1600
+ <title>Clodds</title>
1601
+ <script src="https://telegram.org/js/telegram-web-app.js"></script>
1602
+ <style>
1603
+ * { box-sizing: border-box; margin: 0; padding: 0; }
1604
+ body {
1605
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1606
+ background: var(--tg-theme-bg-color, #0f1419);
1607
+ color: var(--tg-theme-text-color, #e7e9ea);
1608
+ min-height: 100vh;
1609
+ padding: 16px;
1610
+ }
1611
+ .header { text-align: center; margin-bottom: 24px; }
1612
+ .header h1 { font-size: 24px; font-weight: 600; }
1613
+ .header p { color: var(--tg-theme-hint-color, #71767b); margin-top: 4px; }
1614
+ .tabs {
1615
+ display: flex;
1616
+ gap: 8px;
1617
+ margin-bottom: 16px;
1618
+ padding: 4px;
1619
+ background: var(--tg-theme-secondary-bg-color, #16202a);
1620
+ border-radius: 12px;
1621
+ }
1622
+ .tab {
1623
+ flex: 1;
1624
+ padding: 10px;
1625
+ text-align: center;
1626
+ border-radius: 8px;
1627
+ cursor: pointer;
1628
+ font-size: 14px;
1629
+ font-weight: 500;
1630
+ transition: all 0.2s;
1631
+ }
1632
+ .tab.active {
1633
+ background: var(--tg-theme-button-color, #1d9bf0);
1634
+ color: var(--tg-theme-button-text-color, #fff);
1635
+ }
1636
+ .section { display: none; }
1637
+ .section.active { display: block; }
1638
+ .card {
1639
+ background: var(--tg-theme-secondary-bg-color, #16202a);
1640
+ border-radius: 16px;
1641
+ padding: 16px;
1642
+ margin-bottom: 12px;
1643
+ }
1644
+ .card-title { font-size: 14px; color: var(--tg-theme-hint-color, #71767b); margin-bottom: 8px; }
1645
+ .card-value { font-size: 28px; font-weight: 700; }
1646
+ .card-value.positive { color: #00ba7c; }
1647
+ .card-value.negative { color: #f91880; }
1648
+ .list-item {
1649
+ display: flex;
1650
+ justify-content: space-between;
1651
+ align-items: center;
1652
+ padding: 12px 0;
1653
+ border-bottom: 1px solid var(--tg-theme-secondary-bg-color, #2f3336);
1654
+ }
1655
+ .list-item:last-child { border-bottom: none; }
1656
+ .list-item .name { font-weight: 500; }
1657
+ .list-item .value { font-size: 14px; }
1658
+ .badge {
1659
+ display: inline-block;
1660
+ padding: 4px 8px;
1661
+ border-radius: 8px;
1662
+ font-size: 12px;
1663
+ font-weight: 600;
1664
+ }
1665
+ .badge.buy { background: rgba(0, 186, 124, 0.2); color: #00ba7c; }
1666
+ .badge.sell { background: rgba(249, 24, 128, 0.2); color: #f91880; }
1667
+ .badge.arb { background: rgba(29, 155, 240, 0.2); color: #1d9bf0; }
1668
+ .btn {
1669
+ width: 100%;
1670
+ padding: 14px;
1671
+ border-radius: 12px;
1672
+ border: none;
1673
+ background: var(--tg-theme-button-color, #1d9bf0);
1674
+ color: var(--tg-theme-button-text-color, #fff);
1675
+ font-size: 16px;
1676
+ font-weight: 600;
1677
+ cursor: pointer;
1678
+ margin-top: 16px;
1679
+ }
1680
+ .btn:hover { opacity: 0.9; }
1681
+ .loading { text-align: center; padding: 40px; color: var(--tg-theme-hint-color, #71767b); }
1682
+ .empty { text-align: center; padding: 40px; }
1683
+ .empty-icon { font-size: 48px; margin-bottom: 12px; }
1684
+ .empty-text { color: var(--tg-theme-hint-color, #71767b); }
1685
+ .search { width: 100%; padding: 12px 16px; border-radius: 12px; border: none; background: var(--tg-theme-secondary-bg-color, #16202a); color: var(--tg-theme-text-color, #e7e9ea); font-size: 16px; margin-bottom: 16px; }
1686
+ .search::placeholder { color: var(--tg-theme-hint-color, #71767b); }
1687
+ </style>
1688
+ </head>
1689
+ <body>
1690
+ <div class="header">
1691
+ <h1>Clodds</h1>
1692
+ <p>Prediction Markets AI</p>
1693
+ </div>
1694
+
1695
+ <div class="tabs">
1696
+ <div class="tab active" data-tab="portfolio">Portfolio</div>
1697
+ <div class="tab" data-tab="markets">Markets</div>
1698
+ <div class="tab" data-tab="arb">Arbitrage</div>
1699
+ </div>
1700
+
1701
+ <div id="portfolio" class="section active">
1702
+ <div class="card">
1703
+ <div class="card-title">Total Value</div>
1704
+ <div class="card-value" id="total-value">$0.00</div>
1705
+ </div>
1706
+ <div class="card">
1707
+ <div class="card-title">P&L</div>
1708
+ <div class="card-value" id="pnl">$0.00</div>
1709
+ </div>
1710
+ <div class="card">
1711
+ <div class="card-title">Positions</div>
1712
+ <div id="positions"><div class="loading">Loading...</div></div>
1713
+ </div>
1714
+ </div>
1715
+
1716
+ <div id="markets" class="section">
1717
+ <input type="text" class="search" placeholder="Search markets..." id="market-search">
1718
+ <div id="market-list"><div class="loading">Loading...</div></div>
1719
+ </div>
1720
+
1721
+ <div id="arb" class="section">
1722
+ <div class="card">
1723
+ <div class="card-title">Active Opportunities</div>
1724
+ <div id="arb-list"><div class="loading">Loading...</div></div>
1725
+ </div>
1726
+ <button class="btn" onclick="scanArb()">Scan Now</button>
1727
+ </div>
1728
+
1729
+ <script>
1730
+ const Telegram = window.Telegram.WebApp;
1731
+ Telegram.ready();
1732
+ Telegram.expand();
1733
+
1734
+ const baseUrl = window.location.origin;
1735
+
1736
+ // Tab switching
1737
+ document.querySelectorAll('.tab').forEach(tab => {
1738
+ tab.addEventListener('click', () => {
1739
+ document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
1740
+ document.querySelectorAll('.section').forEach(s => s.classList.remove('active'));
1741
+ tab.classList.add('active');
1742
+ document.getElementById(tab.dataset.tab).classList.add('active');
1743
+ });
1744
+ });
1745
+
1746
+ // Format helpers
1747
+ function formatUSD(val) {
1748
+ const sign = val >= 0 ? '' : '-';
1749
+ return sign + '$' + Math.abs(val).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
1750
+ }
1751
+
1752
+ function formatPct(val) {
1753
+ const sign = val >= 0 ? '+' : '';
1754
+ return sign + val.toFixed(1) + '%';
1755
+ }
1756
+
1757
+ // Load portfolio
1758
+ async function loadPortfolio() {
1759
+ try {
1760
+ const res = await fetch(baseUrl + '/api/performance');
1761
+ if (!res.ok) throw new Error('Failed to load');
1762
+ const data = await res.json();
1763
+
1764
+ document.getElementById('total-value').textContent = formatUSD(data.stats.totalPnl + 10000);
1765
+ const pnlEl = document.getElementById('pnl');
1766
+ pnlEl.textContent = formatUSD(data.stats.totalPnl) + ' (' + formatPct(data.stats.avgPnlPct) + ')';
1767
+ pnlEl.className = 'card-value ' + (data.stats.totalPnl >= 0 ? 'positive' : 'negative');
1768
+
1769
+ if (data.recentTrades.length === 0) {
1770
+ document.getElementById('positions').innerHTML = '<div class="empty"><div class="empty-icon">📊</div><div class="empty-text">No positions yet</div></div>';
1771
+ } else {
1772
+ document.getElementById('positions').innerHTML = data.recentTrades.slice(0, 5).map(t => \`
1773
+ <div class="list-item">
1774
+ <div>
1775
+ <div class="name">\${t.market.slice(0, 30)}\${t.market.length > 30 ? '...' : ''}</div>
1776
+ <div class="value">\${formatUSD(t.size)} @ \${(t.entryPrice * 100).toFixed(0)}%</div>
1777
+ </div>
1778
+ <span class="badge \${t.side.toLowerCase()}">\${t.side}</span>
1779
+ </div>
1780
+ \`).join('');
1781
+ }
1782
+ } catch (err) {
1783
+ document.getElementById('positions').innerHTML = '<div class="empty"><div class="empty-text">Failed to load portfolio</div></div>';
1784
+ }
1785
+ }
1786
+
1787
+ // Load markets
1788
+ async function loadMarkets(query = '') {
1789
+ try {
1790
+ const url = baseUrl + '/market-index/search?q=' + encodeURIComponent(query || 'election');
1791
+ const res = await fetch(url);
1792
+ if (!res.ok) throw new Error('Failed to load');
1793
+ const data = await res.json();
1794
+
1795
+ if (!data.results || data.results.length === 0) {
1796
+ document.getElementById('market-list').innerHTML = '<div class="empty"><div class="empty-icon">🔍</div><div class="empty-text">No markets found</div></div>';
1797
+ return;
1798
+ }
1799
+
1800
+ document.getElementById('market-list').innerHTML = data.results.slice(0, 10).map(m => \`
1801
+ <div class="list-item">
1802
+ <div>
1803
+ <div class="name">\${m.question?.slice(0, 40) || m.title?.slice(0, 40) || 'Market'}\${(m.question || m.title || '').length > 40 ? '...' : ''}</div>
1804
+ <div class="value">\${m.platform}</div>
1805
+ </div>
1806
+ <div>\${m.yesPrice ? ((m.yesPrice * 100).toFixed(0) + '%') : '-'}</div>
1807
+ </div>
1808
+ \`).join('');
1809
+ } catch (err) {
1810
+ document.getElementById('market-list').innerHTML = '<div class="empty"><div class="empty-text">Failed to load markets</div></div>';
1811
+ }
1812
+ }
1813
+
1814
+ // Load arbitrage opportunities
1815
+ async function loadArb() {
1816
+ document.getElementById('arb-list').innerHTML = '<div class="empty"><div class="empty-icon">⚡</div><div class="empty-text">Use the Scan button to find opportunities</div></div>';
1817
+ }
1818
+
1819
+ async function scanArb() {
1820
+ document.getElementById('arb-list').innerHTML = '<div class="loading">Scanning...</div>';
1821
+ Telegram.HapticFeedback.impactOccurred('medium');
1822
+
1823
+ // Simulate scan (would call real API)
1824
+ setTimeout(() => {
1825
+ document.getElementById('arb-list').innerHTML = '<div class="empty"><div class="empty-icon">✅</div><div class="empty-text">No opportunities found above 1% edge</div></div>';
1826
+ }, 1500);
1827
+ }
1828
+
1829
+ // Search handler
1830
+ let searchTimeout;
1831
+ document.getElementById('market-search').addEventListener('input', (e) => {
1832
+ clearTimeout(searchTimeout);
1833
+ searchTimeout = setTimeout(() => loadMarkets(e.target.value), 500);
1834
+ });
1835
+
1836
+ // Initialize
1837
+ loadPortfolio();
1838
+ loadMarkets();
1839
+ loadArb();
1840
+ </script>
1841
+ </body>
1842
+ </html>`);
1843
+ });
1844
+ // Performance dashboard HTML UI
1845
+ app.get('/dashboard', (_req, res) => {
1846
+ res.send(`<!DOCTYPE html>
1847
+ <html>
1848
+ <head>
1849
+ <title>Clodds Performance Dashboard</title>
1850
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
1851
+ <style>
1852
+ * { box-sizing: border-box; margin: 0; padding: 0; }
1853
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0f1419; color: #e7e9ea; }
1854
+ .header { background: #16202a; padding: 20px 30px; border-bottom: 1px solid #2f3336; display: flex; justify-content: space-between; align-items: center; }
1855
+ .header h1 { font-size: 24px; font-weight: 600; }
1856
+ .header .refresh { background: #1d9bf0; color: white; border: none; padding: 10px 20px; border-radius: 20px; cursor: pointer; font-weight: 600; }
1857
+ .header .refresh:hover { background: #1a8cd8; }
1858
+ .container { max-width: 1400px; margin: 0 auto; padding: 30px; }
1859
+ .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
1860
+ .stat-card { background: #16202a; border-radius: 16px; padding: 24px; border: 1px solid #2f3336; }
1861
+ .stat-card .label { color: #71767b; font-size: 14px; margin-bottom: 8px; }
1862
+ .stat-card .value { font-size: 32px; font-weight: 700; }
1863
+ .stat-card .value.positive { color: #00ba7c; }
1864
+ .stat-card .value.negative { color: #f91880; }
1865
+ .charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 30px; }
1866
+ .chart-card { background: #16202a; border-radius: 16px; padding: 24px; border: 1px solid #2f3336; }
1867
+ .chart-card h3 { margin-bottom: 20px; font-size: 18px; }
1868
+ .chart-container { position: relative; height: 300px; }
1869
+ .trades-table { width: 100%; border-collapse: collapse; }
1870
+ .trades-table th, .trades-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #2f3336; }
1871
+ .trades-table th { color: #71767b; font-weight: 500; font-size: 14px; }
1872
+ .trades-table tr:hover { background: #1c2732; }
1873
+ .badge { display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
1874
+ .badge.buy { background: rgba(0, 186, 124, 0.2); color: #00ba7c; }
1875
+ .badge.sell { background: rgba(249, 24, 128, 0.2); color: #f91880; }
1876
+ .badge.win { background: rgba(0, 186, 124, 0.2); color: #00ba7c; }
1877
+ .badge.loss { background: rgba(249, 24, 128, 0.2); color: #f91880; }
1878
+ .badge.open { background: rgba(29, 155, 240, 0.2); color: #1d9bf0; }
1879
+ .loading { text-align: center; padding: 60px; color: #71767b; }
1880
+ .error { text-align: center; padding: 60px; color: #f91880; }
1881
+ @media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }
1882
+ </style>
1883
+ </head>
1884
+ <body>
1885
+ <div class="header">
1886
+ <h1>Performance Dashboard</h1>
1887
+ <button class="refresh" onclick="loadData()">Refresh</button>
1888
+ </div>
1889
+ <div class="container">
1890
+ <div id="content" class="loading">Loading...</div>
1891
+ </div>
1892
+
1893
+ <script>
1894
+ let pnlChart = null;
1895
+ let strategyChart = null;
1896
+
1897
+ async function loadData() {
1898
+ const content = document.getElementById('content');
1899
+ content.innerHTML = '<div class="loading">Loading...</div>';
1900
+
1901
+ try {
1902
+ const res = await fetch('/api/performance');
1903
+ if (!res.ok) throw new Error('Failed to load data');
1904
+ const data = await res.json();
1905
+ render(data);
1906
+ } catch (err) {
1907
+ content.innerHTML = '<div class="error">Failed to load performance data. Make sure trading is enabled.</div>';
1908
+ }
1909
+ }
1910
+
1911
+ function formatCurrency(val) {
1912
+ const sign = val >= 0 ? '+' : '';
1913
+ return sign + '$' + Math.abs(val).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
1914
+ }
1915
+
1916
+ function formatPercent(val) {
1917
+ const sign = val >= 0 ? '+' : '';
1918
+ return sign + val.toFixed(2) + '%';
1919
+ }
1920
+
1921
+ function render(data) {
1922
+ const { stats, recentTrades, dailyPnl, byStrategy } = data;
1923
+
1924
+ const html = \`
1925
+ <div class="stats-grid">
1926
+ <div class="stat-card">
1927
+ <div class="label">Total Trades</div>
1928
+ <div class="value">\${stats.totalTrades}</div>
1929
+ </div>
1930
+ <div class="stat-card">
1931
+ <div class="label">Win Rate</div>
1932
+ <div class="value \${stats.winRate >= 50 ? 'positive' : 'negative'}">\${stats.winRate.toFixed(1)}%</div>
1933
+ </div>
1934
+ <div class="stat-card">
1935
+ <div class="label">Total P&L</div>
1936
+ <div class="value \${stats.totalPnl >= 0 ? 'positive' : 'negative'}">\${formatCurrency(stats.totalPnl)}</div>
1937
+ </div>
1938
+ <div class="stat-card">
1939
+ <div class="label">Avg P&L %</div>
1940
+ <div class="value \${stats.avgPnlPct >= 0 ? 'positive' : 'negative'}">\${formatPercent(stats.avgPnlPct)}</div>
1941
+ </div>
1942
+ <div class="stat-card">
1943
+ <div class="label">Sharpe Ratio</div>
1944
+ <div class="value \${stats.sharpeRatio >= 1 ? 'positive' : stats.sharpeRatio < 0 ? 'negative' : ''}">\${stats.sharpeRatio.toFixed(2)}</div>
1945
+ </div>
1946
+ <div class="stat-card">
1947
+ <div class="label">Max Drawdown</div>
1948
+ <div class="value negative">\${formatPercent(-stats.maxDrawdown)}</div>
1949
+ </div>
1950
+ </div>
1951
+
1952
+ <div class="charts-grid">
1953
+ <div class="chart-card">
1954
+ <h3>Cumulative P&L</h3>
1955
+ <div class="chart-container"><canvas id="pnlChart"></canvas></div>
1956
+ </div>
1957
+ <div class="chart-card">
1958
+ <h3>By Strategy</h3>
1959
+ <div class="chart-container"><canvas id="strategyChart"></canvas></div>
1960
+ </div>
1961
+ </div>
1962
+
1963
+ <div class="chart-card">
1964
+ <h3>Recent Trades</h3>
1965
+ <table class="trades-table">
1966
+ <thead>
1967
+ <tr>
1968
+ <th>Time</th>
1969
+ <th>Market</th>
1970
+ <th>Side</th>
1971
+ <th>Size</th>
1972
+ <th>Entry</th>
1973
+ <th>Exit</th>
1974
+ <th>P&L</th>
1975
+ <th>Status</th>
1976
+ </tr>
1977
+ </thead>
1978
+ <tbody>
1979
+ \${recentTrades.map(t => \`
1980
+ <tr>
1981
+ <td>\${new Date(t.timestamp).toLocaleString()}</td>
1982
+ <td>\${t.market.slice(0, 40)}\${t.market.length > 40 ? '...' : ''}</td>
1983
+ <td><span class="badge \${t.side.toLowerCase()}">\${t.side}</span></td>
1984
+ <td>$\${t.size.toLocaleString()}</td>
1985
+ <td>\${(t.entryPrice * 100).toFixed(1)}%</td>
1986
+ <td>\${t.exitPrice ? (t.exitPrice * 100).toFixed(1) + '%' : '-'}</td>
1987
+ <td class="\${(t.pnl || 0) >= 0 ? 'positive' : 'negative'}">\${t.pnl != null ? formatCurrency(t.pnl) : '-'}</td>
1988
+ <td><span class="badge \${t.status === 'win' ? 'win' : t.status === 'loss' ? 'loss' : 'open'}">\${t.status}</span></td>
1989
+ </tr>
1990
+ \`).join('')}
1991
+ </tbody>
1992
+ </table>
1993
+ </div>
1994
+ \`;
1995
+
1996
+ document.getElementById('content').innerHTML = html;
1997
+
1998
+ // Cumulative P&L chart
1999
+ if (pnlChart) pnlChart.destroy();
2000
+ const pnlCtx = document.getElementById('pnlChart').getContext('2d');
2001
+ pnlChart = new Chart(pnlCtx, {
2002
+ type: 'line',
2003
+ data: {
2004
+ labels: dailyPnl.map(d => d.date),
2005
+ datasets: [{
2006
+ label: 'Cumulative P&L',
2007
+ data: dailyPnl.map(d => d.cumulative),
2008
+ borderColor: '#1d9bf0',
2009
+ backgroundColor: 'rgba(29, 155, 240, 0.1)',
2010
+ fill: true,
2011
+ tension: 0.3,
2012
+ }]
2013
+ },
2014
+ options: {
2015
+ responsive: true,
2016
+ maintainAspectRatio: false,
2017
+ plugins: { legend: { display: false } },
2018
+ scales: {
2019
+ x: { grid: { color: '#2f3336' }, ticks: { color: '#71767b' } },
2020
+ y: { grid: { color: '#2f3336' }, ticks: { color: '#71767b', callback: v => '$' + v } }
2021
+ }
2022
+ }
2023
+ });
2024
+
2025
+ // Strategy breakdown chart
2026
+ if (strategyChart) strategyChart.destroy();
2027
+ const stratCtx = document.getElementById('strategyChart').getContext('2d');
2028
+ strategyChart = new Chart(stratCtx, {
2029
+ type: 'doughnut',
2030
+ data: {
2031
+ labels: byStrategy.map(s => s.strategy),
2032
+ datasets: [{
2033
+ data: byStrategy.map(s => s.trades),
2034
+ backgroundColor: ['#1d9bf0', '#00ba7c', '#f91880', '#ffd400', '#7856ff'],
2035
+ }]
2036
+ },
2037
+ options: {
2038
+ responsive: true,
2039
+ maintainAspectRatio: false,
2040
+ plugins: {
2041
+ legend: { position: 'bottom', labels: { color: '#e7e9ea' } }
2042
+ }
2043
+ }
2044
+ });
2045
+ }
2046
+
2047
+ loadData();
2048
+ </script>
2049
+ </body>
2050
+ </html>`);
2051
+ });
2052
+ return {
2053
+ async start() {
2054
+ return new Promise((resolve) => {
2055
+ httpServer = (0, http_1.createServer)(app);
2056
+ // WebSocket server - handles both /ws and /chat
2057
+ wss = new ws_1.WebSocketServer({ noServer: true, maxPayload: 1024 * 1024 });
2058
+ // Handle upgrade requests
2059
+ httpServer.on('upgrade', (request, socket, head) => {
2060
+ const pathname = request.url?.split('?')[0] || '';
2061
+ if (pathname === '/ws' || pathname === '/chat') {
2062
+ wss.handleUpgrade(request, socket, head, (ws) => {
2063
+ wss.emit('connection', ws, request);
2064
+ });
2065
+ }
2066
+ else if (pathname === '/api/ticks/stream') {
2067
+ // Tick streaming WebSocket endpoint
2068
+ if (!tickStreamer) {
2069
+ socket.write('HTTP/1.1 503 Service Unavailable\r\n\r\n');
2070
+ socket.destroy();
2071
+ return;
2072
+ }
2073
+ wss.handleUpgrade(request, socket, head, (ws) => {
2074
+ tickStreamer.handleConnection(ws);
2075
+ });
2076
+ }
2077
+ else {
2078
+ socket.destroy();
2079
+ }
2080
+ });
2081
+ // Default /ws handler (for API/control)
2082
+ wss.on('connection', (ws, request) => {
2083
+ // /chat connections are handled by WebChat channel via attachWebSocket
2084
+ const reqPath = (request.url || '').split('?')[0];
2085
+ if (reqPath === '/chat') {
2086
+ return; // Let WebChat handle it
2087
+ }
2088
+ logger_1.logger.info('WebSocket API client connected');
2089
+ ws.on('message', (data) => {
2090
+ try {
2091
+ const message = JSON.parse(data.toString());
2092
+ logger_1.logger.debug({ message }, 'WS API message received');
2093
+ ws.send(JSON.stringify({
2094
+ type: 'res',
2095
+ id: message.id,
2096
+ ok: true,
2097
+ payload: { echo: message },
2098
+ }));
2099
+ }
2100
+ catch (err) {
2101
+ logger_1.logger.error({ err }, 'Failed to parse WS message');
2102
+ }
2103
+ });
2104
+ ws.on('close', () => {
2105
+ logger_1.logger.info('WebSocket API client disconnected');
2106
+ });
2107
+ });
2108
+ httpServer.listen(config.port, () => {
2109
+ resolve();
2110
+ });
2111
+ });
2112
+ },
2113
+ async stop() {
2114
+ if (ipCleanupInterval) {
2115
+ clearInterval(ipCleanupInterval);
2116
+ ipCleanupInterval = null;
2117
+ }
2118
+ return new Promise((resolve) => {
2119
+ wss?.close();
2120
+ if (httpServer) {
2121
+ httpServer.close(() => resolve());
2122
+ }
2123
+ else {
2124
+ resolve();
2125
+ }
2126
+ });
2127
+ },
2128
+ getWebSocketServer() {
2129
+ return wss;
2130
+ },
2131
+ setChannelWebhookHandler(handler) {
2132
+ channelWebhookHandler = handler;
2133
+ },
2134
+ setMarketIndexHandler(handler) {
2135
+ marketIndexHandler = handler;
2136
+ },
2137
+ setMarketIndexStatsHandler(handler) {
2138
+ marketIndexStatsHandler = handler;
2139
+ },
2140
+ setMarketIndexSyncHandler(handler) {
2141
+ marketIndexSyncHandler = handler;
2142
+ },
2143
+ setPerformanceDashboardHandler(handler) {
2144
+ performanceDashboardHandler = handler;
2145
+ },
2146
+ setBacktestHandler(handler) {
2147
+ backtestHandler = handler;
2148
+ },
2149
+ setTicksHandler(handler) {
2150
+ ticksHandler = handler;
2151
+ },
2152
+ setOHLCHandler(handler) {
2153
+ ohlcHandler = handler;
2154
+ },
2155
+ setOrderbookHistoryHandler(handler) {
2156
+ orderbookHistoryHandler = handler;
2157
+ },
2158
+ setTickRecorderStatsHandler(handler) {
2159
+ tickRecorderStatsHandler = handler;
2160
+ },
2161
+ setTickStreamer(streamer) {
2162
+ tickStreamer = streamer;
2163
+ },
2164
+ setFeatureEngineering(service) {
2165
+ featureEngineering = service;
2166
+ },
2167
+ setBittensorRouter(router) {
2168
+ if (router) {
2169
+ app.use('/api/bittensor', requireAuth, router);
2170
+ }
2171
+ },
2172
+ setTradingApiRouter(router) {
2173
+ if (router) {
2174
+ app.use('/api', requireAuth, router);
2175
+ }
2176
+ },
2177
+ setPercolatorRouter(router) {
2178
+ if (router) {
2179
+ app.use('/api/percolator', requireAuth, router);
2180
+ }
2181
+ },
2182
+ setShieldRouter(router) {
2183
+ if (router) {
2184
+ app.use('/api/shield', requireAuth, router);
2185
+ }
2186
+ },
2187
+ setAuditRouter(router) {
2188
+ if (router) {
2189
+ app.use('/api/audit', requireAuth, router);
2190
+ }
2191
+ },
2192
+ setDCARouter(router) {
2193
+ if (router) {
2194
+ app.use('/api/dca', requireAuth, router);
2195
+ }
2196
+ },
2197
+ setTwapRouter(router) {
2198
+ if (router) {
2199
+ app.use('/api/twap', requireAuth, router);
2200
+ }
2201
+ },
2202
+ setBracketRouter(router) {
2203
+ if (router) {
2204
+ app.use('/api/bracket', requireAuth, router);
2205
+ }
2206
+ },
2207
+ setTriggerRouter(router) {
2208
+ if (router) {
2209
+ app.use('/api/triggers', requireAuth, router);
2210
+ }
2211
+ },
2212
+ setCopyTradingRouter(router) {
2213
+ if (router) {
2214
+ app.use('/api/copy-trading', requireAuth, router);
2215
+ }
2216
+ },
2217
+ setOpportunityRouter(router) {
2218
+ if (router) {
2219
+ app.use('/api/opportunities', requireAuth, router);
2220
+ }
2221
+ },
2222
+ setWhaleRouter(router) {
2223
+ if (router) {
2224
+ app.use('/api/whales', requireAuth, router);
2225
+ }
2226
+ },
2227
+ setRiskRouter(router) {
2228
+ if (router) {
2229
+ app.use('/api/risk', requireAuth, router);
2230
+ }
2231
+ },
2232
+ setRoutingRouter(router) {
2233
+ if (router) {
2234
+ app.use('/api/routing', requireAuth, router);
2235
+ }
2236
+ },
2237
+ setFeedsRouter(router) {
2238
+ if (router) {
2239
+ app.use('/api/feeds', requireAuth, router);
2240
+ }
2241
+ },
2242
+ setMonitoringRouter(router) {
2243
+ if (router) {
2244
+ app.use('/api/monitoring', requireAuth, router);
2245
+ }
2246
+ },
2247
+ setAltDataRouter(router) {
2248
+ if (router) {
2249
+ app.use('/api/alt-data', requireAuth, router);
2250
+ }
2251
+ },
2252
+ setAlertsRouter(router) {
2253
+ if (router) {
2254
+ app.use('/api/alerts', requireAuth, router);
2255
+ }
2256
+ },
2257
+ setQueueRouter(router) {
2258
+ if (router) {
2259
+ app.use('/api/queue', requireAuth, router);
2260
+ }
2261
+ },
2262
+ setWebhooksRouter(router) {
2263
+ if (router) {
2264
+ app.use('/api/webhooks', requireAuth, router);
2265
+ }
2266
+ },
2267
+ setPaymentsRouter(router) {
2268
+ if (router) {
2269
+ app.use('/api/payments', requireAuth, router);
2270
+ }
2271
+ },
2272
+ setEmbeddingsRouter(router) {
2273
+ if (router) {
2274
+ app.use('/api/embeddings', requireAuth, router);
2275
+ }
2276
+ },
2277
+ setCronRouter(router) {
2278
+ if (router) {
2279
+ app.use('/api/cron', requireAuth, router);
2280
+ }
2281
+ },
2282
+ setCommandListHandler(handler) {
2283
+ commandListHandler = handler;
2284
+ },
2285
+ };
2286
+ }
2287
+ //# sourceMappingURL=server.js.map