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,3743 @@
1
+ "use strict";
2
+ /**
3
+ * CLI Commands Module - Clawdbot-style comprehensive CLI commands
4
+ *
5
+ * Additional commands for full feature parity
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.createConfigCommands = createConfigCommands;
42
+ exports.createModelCommands = createModelCommands;
43
+ exports.createSessionCommands = createSessionCommands;
44
+ exports.createCronCommands = createCronCommands;
45
+ exports.createQmdCommands = createQmdCommands;
46
+ exports.createUserCommands = createUserCommands;
47
+ exports.createMemoryCommands = createMemoryCommands;
48
+ exports.createHookCommands = createHookCommands;
49
+ exports.createMcpCommands = createMcpCommands;
50
+ exports.createMarketIndexCommands = createMarketIndexCommands;
51
+ exports.createPermissionCommands = createPermissionCommands;
52
+ exports.createUsageCommands = createUsageCommands;
53
+ exports.createInitCommand = createInitCommand;
54
+ exports.createUpgradeCommand = createUpgradeCommand;
55
+ exports.createLoginCommand = createLoginCommand;
56
+ exports.createLogoutCommand = createLogoutCommand;
57
+ exports.createVersionCommand = createVersionCommand;
58
+ exports.createWhatsAppCommands = createWhatsAppCommands;
59
+ exports.createCredsCommands = createCredsCommands;
60
+ exports.createLocaleCommands = createLocaleCommands;
61
+ exports.createLedgerCommands = createLedgerCommands;
62
+ exports.createBittensorCommands = createBittensorCommands;
63
+ exports.createDoctorCommand = createDoctorCommand;
64
+ exports.createOnboardCommand = createOnboardCommand;
65
+ exports.addAllCommands = addAllCommands;
66
+ const child_process_1 = require("child_process");
67
+ const fs_1 = require("fs");
68
+ const path_1 = require("path");
69
+ const os_1 = require("os");
70
+ const hooks_1 = require("../../hooks");
71
+ const db_1 = require("../../db");
72
+ const migrations_1 = require("../../db/migrations");
73
+ const permissions_1 = require("../../permissions");
74
+ const config_1 = require("../../utils/config");
75
+ const index_1 = require("../../channels/whatsapp/index");
76
+ // =============================================================================
77
+ // CONFIG COMMANDS
78
+ // =============================================================================
79
+ function createConfigCommands(program) {
80
+ const config = program
81
+ .command('config')
82
+ .description('Manage configuration');
83
+ config
84
+ .command('get [key]')
85
+ .description('Get config value or show all')
86
+ .action(async (key) => {
87
+ const configPath = (0, path_1.join)((0, os_1.homedir)(), '.clodds', 'config.json');
88
+ if (!(0, fs_1.existsSync)(configPath)) {
89
+ console.log('No configuration file found');
90
+ return;
91
+ }
92
+ const data = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
93
+ if (key) {
94
+ const value = key.split('.').reduce((obj, k) => obj?.[k], data);
95
+ console.log(value !== undefined ? JSON.stringify(value, null, 2) : 'Key not found');
96
+ }
97
+ else {
98
+ console.log(JSON.stringify(data, null, 2));
99
+ }
100
+ });
101
+ config
102
+ .command('set <key> <value>')
103
+ .description('Set a config value')
104
+ .action(async (key, value) => {
105
+ const configDir = (0, path_1.join)((0, os_1.homedir)(), '.clodds');
106
+ const configPath = (0, path_1.join)(configDir, 'config.json');
107
+ if (!(0, fs_1.existsSync)(configDir)) {
108
+ (0, fs_1.mkdirSync)(configDir, { recursive: true });
109
+ }
110
+ let data = {};
111
+ if ((0, fs_1.existsSync)(configPath)) {
112
+ data = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
113
+ }
114
+ // Handle nested keys
115
+ const keys = key.split('.');
116
+ let obj = data;
117
+ for (let i = 0; i < keys.length - 1; i++) {
118
+ if (!obj[keys[i]])
119
+ obj[keys[i]] = {};
120
+ obj = obj[keys[i]];
121
+ }
122
+ // Try to parse value as JSON, otherwise use as string
123
+ try {
124
+ obj[keys[keys.length - 1]] = JSON.parse(value);
125
+ }
126
+ catch {
127
+ obj[keys[keys.length - 1]] = value;
128
+ }
129
+ (0, fs_1.writeFileSync)(configPath, JSON.stringify(data, null, 2));
130
+ console.log(`Set ${key} = ${value}`);
131
+ });
132
+ config
133
+ .command('unset <key>')
134
+ .description('Remove a config value')
135
+ .action(async (key) => {
136
+ const configPath = (0, path_1.join)((0, os_1.homedir)(), '.clodds', 'config.json');
137
+ if (!(0, fs_1.existsSync)(configPath)) {
138
+ console.log('No configuration file found');
139
+ return;
140
+ }
141
+ const data = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
142
+ const keys = key.split('.');
143
+ let obj = data;
144
+ for (let i = 0; i < keys.length - 1; i++) {
145
+ if (!obj[keys[i]])
146
+ return;
147
+ obj = obj[keys[i]];
148
+ }
149
+ delete obj[keys[keys.length - 1]];
150
+ (0, fs_1.writeFileSync)(configPath, JSON.stringify(data, null, 2));
151
+ console.log(`Removed ${key}`);
152
+ });
153
+ config
154
+ .command('path')
155
+ .description('Show config file path')
156
+ .action(() => {
157
+ console.log((0, path_1.join)((0, os_1.homedir)(), '.clodds', 'config.json'));
158
+ });
159
+ }
160
+ // =============================================================================
161
+ // MODEL COMMANDS
162
+ // =============================================================================
163
+ function createModelCommands(program) {
164
+ const model = program
165
+ .command('model')
166
+ .description('Manage AI models');
167
+ model
168
+ .command('list')
169
+ .description('List available models')
170
+ .option('-p, --provider <provider>', 'Filter by provider')
171
+ .action(async (options) => {
172
+ console.log('Available models:');
173
+ console.log('');
174
+ const models = [
175
+ { id: 'claude-3-5-sonnet-20241022', provider: 'anthropic', context: '200K' },
176
+ { id: 'claude-3-opus-20240229', provider: 'anthropic', context: '200K' },
177
+ { id: 'claude-3-5-haiku-20241022', provider: 'anthropic', context: '200K' },
178
+ { id: 'gpt-4o', provider: 'openai', context: '128K' },
179
+ { id: 'gpt-4-turbo', provider: 'openai', context: '128K' },
180
+ { id: 'gpt-3.5-turbo', provider: 'openai', context: '16K' },
181
+ { id: 'llama3', provider: 'ollama', context: '8K' },
182
+ ];
183
+ const filtered = options.provider
184
+ ? models.filter(m => m.provider === options.provider)
185
+ : models;
186
+ for (const m of filtered) {
187
+ console.log(` ${m.id.padEnd(35)} ${m.provider.padEnd(12)} ${m.context}`);
188
+ }
189
+ });
190
+ model
191
+ .command('default [model]')
192
+ .description('Get or set default model')
193
+ .action(async (model) => {
194
+ const configPath = (0, path_1.join)((0, os_1.homedir)(), '.clodds', 'config.json');
195
+ let data = {};
196
+ if ((0, fs_1.existsSync)(configPath)) {
197
+ data = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
198
+ }
199
+ if (model) {
200
+ data.defaultModel = model;
201
+ (0, fs_1.writeFileSync)(configPath, JSON.stringify(data, null, 2));
202
+ console.log(`Default model set to: ${model}`);
203
+ }
204
+ else {
205
+ console.log(`Default model: ${data.defaultModel || 'claude-3-5-sonnet-20241022'}`);
206
+ }
207
+ });
208
+ }
209
+ // =============================================================================
210
+ // SESSION COMMANDS
211
+ // =============================================================================
212
+ function createSessionCommands(program) {
213
+ const session = program
214
+ .command('session')
215
+ .description('Manage sessions');
216
+ session
217
+ .command('list')
218
+ .description('List active sessions')
219
+ .action(async () => {
220
+ const sessionsDir = (0, path_1.join)((0, os_1.homedir)(), '.clodds', 'sessions');
221
+ if (!(0, fs_1.existsSync)(sessionsDir)) {
222
+ console.log('No sessions found');
223
+ return;
224
+ }
225
+ const sessions = (0, fs_1.readdirSync)(sessionsDir).filter(f => f.endsWith('.json'));
226
+ console.log(`\nActive sessions (${sessions.length}):\n`);
227
+ for (const file of sessions.slice(0, 20)) {
228
+ const sessionPath = (0, path_1.join)(sessionsDir, file);
229
+ try {
230
+ const data = JSON.parse((0, fs_1.readFileSync)(sessionPath, 'utf-8'));
231
+ const id = file.replace('.json', '');
232
+ console.log(` ${id.slice(0, 8)} ${data.userId || '-'} ${data.createdAt || '-'}`);
233
+ }
234
+ catch { }
235
+ }
236
+ });
237
+ session
238
+ .command('clear [sessionId]')
239
+ .description('Clear a session or all sessions')
240
+ .option('-a, --all', 'Clear all sessions')
241
+ .action(async (sessionId, options) => {
242
+ const sessionsDir = (0, path_1.join)((0, os_1.homedir)(), '.clodds', 'sessions');
243
+ if (options?.all) {
244
+ if ((0, fs_1.existsSync)(sessionsDir)) {
245
+ const { rmSync } = require('fs');
246
+ rmSync(sessionsDir, { recursive: true });
247
+ (0, fs_1.mkdirSync)(sessionsDir, { recursive: true });
248
+ }
249
+ console.log('Cleared all sessions');
250
+ }
251
+ else if (sessionId) {
252
+ const sessionPath = (0, path_1.join)(sessionsDir, `${sessionId}.json`);
253
+ if ((0, fs_1.existsSync)(sessionPath)) {
254
+ const { unlinkSync } = require('fs');
255
+ unlinkSync(sessionPath);
256
+ console.log(`Cleared session: ${sessionId}`);
257
+ }
258
+ else {
259
+ console.log('Session not found');
260
+ }
261
+ }
262
+ else {
263
+ console.log('Specify a session ID or use --all');
264
+ }
265
+ });
266
+ }
267
+ // =============================================================================
268
+ // CRON COMMANDS
269
+ // =============================================================================
270
+ function createCronCommands(program) {
271
+ const cron = program
272
+ .command('cron')
273
+ .description('Manage scheduled cron jobs');
274
+ const withDb = async (fn) => {
275
+ const db = (0, db_1.createDatabase)();
276
+ (0, migrations_1.createMigrationRunner)(db).migrate();
277
+ try {
278
+ return await fn(db);
279
+ }
280
+ finally {
281
+ db.close();
282
+ }
283
+ };
284
+ const formatSchedule = (schedule) => {
285
+ if (!schedule)
286
+ return 'n/a';
287
+ if (schedule.kind === 'every') {
288
+ const ms = schedule.everyMs;
289
+ if (!ms || ms <= 0)
290
+ return 'every ?';
291
+ const mins = Math.round(ms / 60000);
292
+ return mins >= 60 ? `every ${Math.round(mins / 60)}h` : `every ${mins}m`;
293
+ }
294
+ if (schedule.kind === 'cron') {
295
+ return `cron ${String(schedule.expr ?? '')}`;
296
+ }
297
+ if (schedule.kind === 'at') {
298
+ const atMs = schedule.atMs;
299
+ return atMs ? `at ${new Date(atMs).toLocaleString()}` : 'at ?';
300
+ }
301
+ return String(schedule.kind);
302
+ };
303
+ const parseJob = (record) => {
304
+ try {
305
+ const job = JSON.parse(record.data);
306
+ return {
307
+ ...record,
308
+ job,
309
+ };
310
+ }
311
+ catch {
312
+ return { ...record, job: {} };
313
+ }
314
+ };
315
+ cron
316
+ .command('list')
317
+ .description('List cron jobs')
318
+ .option('-a, --all', 'Include disabled jobs')
319
+ .action(async (options) => {
320
+ await withDb(async (db) => {
321
+ const records = db.listCronJobs();
322
+ if (records.length === 0) {
323
+ console.log('No cron jobs found.');
324
+ return;
325
+ }
326
+ const entries = records.map(parseJob)
327
+ .filter((entry) => options.all || entry.enabled);
328
+ if (entries.length === 0) {
329
+ console.log('No enabled cron jobs found.');
330
+ return;
331
+ }
332
+ console.log('\nCron Jobs:\n');
333
+ console.log('ID Enabled Schedule Next Run Name');
334
+ console.log('─'.repeat(90));
335
+ for (const entry of entries) {
336
+ const schedule = formatSchedule(entry.job.schedule);
337
+ const nextRun = entry.job.state?.nextRunAtMs
338
+ ? new Date(entry.job.state.nextRunAtMs).toLocaleString()
339
+ : '-';
340
+ const name = entry.job.name || '-';
341
+ console.log(`${entry.id} ${entry.enabled ? 'yes' : 'no '} ${schedule} ${nextRun} ${name}`);
342
+ }
343
+ });
344
+ });
345
+ cron
346
+ .command('show <id>')
347
+ .description('Show a cron job detail')
348
+ .action(async (id) => {
349
+ await withDb(async (db) => {
350
+ const record = db.getCronJob(id);
351
+ if (!record) {
352
+ console.log(`Cron job not found: ${id}`);
353
+ return;
354
+ }
355
+ let parsed;
356
+ try {
357
+ parsed = JSON.parse(record.data);
358
+ }
359
+ catch {
360
+ parsed = record.data;
361
+ }
362
+ console.log(JSON.stringify({
363
+ id: record.id,
364
+ enabled: record.enabled,
365
+ createdAt: new Date(record.createdAtMs).toISOString(),
366
+ updatedAt: new Date(record.updatedAtMs).toISOString(),
367
+ job: parsed,
368
+ }, null, 2));
369
+ });
370
+ });
371
+ const setEnabled = async (id, enabled) => {
372
+ await withDb(async (db) => {
373
+ const record = db.getCronJob(id);
374
+ if (!record) {
375
+ console.log(`Cron job not found: ${id}`);
376
+ return;
377
+ }
378
+ let job = null;
379
+ try {
380
+ job = JSON.parse(record.data);
381
+ }
382
+ catch {
383
+ job = null;
384
+ }
385
+ if (job && typeof job === 'object') {
386
+ job.enabled = enabled;
387
+ }
388
+ const data = job ? JSON.stringify(job) : record.data;
389
+ db.upsertCronJob({
390
+ id: record.id,
391
+ data,
392
+ enabled,
393
+ createdAtMs: record.createdAtMs,
394
+ updatedAtMs: Date.now(),
395
+ });
396
+ console.log(`Cron job ${enabled ? 'enabled' : 'disabled'}: ${id}`);
397
+ console.log('Restart the gateway if it is already running to apply changes.');
398
+ });
399
+ };
400
+ cron
401
+ .command('enable <id>')
402
+ .description('Enable a cron job')
403
+ .action(async (id) => setEnabled(id, true));
404
+ cron
405
+ .command('disable <id>')
406
+ .description('Disable a cron job')
407
+ .action(async (id) => setEnabled(id, false));
408
+ cron
409
+ .command('delete <id>')
410
+ .description('Delete a cron job')
411
+ .action(async (id) => {
412
+ await withDb(async (db) => {
413
+ const record = db.getCronJob(id);
414
+ if (!record) {
415
+ console.log(`Cron job not found: ${id}`);
416
+ return;
417
+ }
418
+ db.deleteCronJob(id);
419
+ console.log(`Cron job deleted: ${id}`);
420
+ console.log('Restart the gateway if it is already running to apply changes.');
421
+ });
422
+ });
423
+ }
424
+ // =============================================================================
425
+ // QMD COMMANDS
426
+ // =============================================================================
427
+ function createQmdCommands(program) {
428
+ const qmd = program
429
+ .command('qmd')
430
+ .description('Local markdown search powered by qmd');
431
+ const runQmd = (args, timeoutMs) => {
432
+ const env = { ...process.env };
433
+ const bunBin = (0, path_1.join)((0, os_1.homedir)(), '.bun', 'bin');
434
+ env.PATH = [bunBin, env.PATH || ''].filter(Boolean).join(':');
435
+ const result = (0, child_process_1.spawnSync)('qmd', args, {
436
+ stdio: 'inherit',
437
+ env,
438
+ timeout: timeoutMs,
439
+ });
440
+ if (result.error) {
441
+ const err = result.error;
442
+ if (err.code === 'ENOENT') {
443
+ console.error('qmd not found. Install with: bun install -g https://github.com/tobi/qmd');
444
+ }
445
+ else {
446
+ console.error(err.message || 'Failed to run qmd');
447
+ }
448
+ process.exitCode = 1;
449
+ return;
450
+ }
451
+ if (typeof result.status === 'number' && result.status !== 0) {
452
+ process.exitCode = result.status;
453
+ }
454
+ };
455
+ const buildSearchArgs = (mode, query, options) => {
456
+ const args = [mode, query];
457
+ if (options.collection)
458
+ args.push('-c', options.collection);
459
+ if (options.limit)
460
+ args.push('-n', options.limit);
461
+ if (options.json)
462
+ args.push('--json');
463
+ if (options.files)
464
+ args.push('--files');
465
+ if (options.all)
466
+ args.push('--all');
467
+ if (options.full)
468
+ args.push('--full');
469
+ if (options.minScore)
470
+ args.push('--min-score', options.minScore);
471
+ return args;
472
+ };
473
+ const addSearchCommand = (mode, description, timeoutMs) => {
474
+ qmd
475
+ .command(`${mode} <query>`)
476
+ .description(description)
477
+ .option('-c, --collection <name>', 'Restrict to a collection')
478
+ .option('-n, --limit <n>', 'Number of results')
479
+ .option('--json', 'JSON output')
480
+ .option('--files', 'File-only output (JSON)')
481
+ .option('--all', 'Return all matches above threshold')
482
+ .option('--full', 'Return full document content')
483
+ .option('--min-score <score>', 'Minimum score threshold')
484
+ .action((query, options) => {
485
+ runQmd(buildSearchArgs(mode, query, options), timeoutMs);
486
+ });
487
+ };
488
+ addSearchCommand('search', 'Keyword search (BM25)', 30_000);
489
+ addSearchCommand('vsearch', 'Semantic search (slow)', 180_000);
490
+ addSearchCommand('query', 'Hybrid search + rerank (slow)', 180_000);
491
+ qmd
492
+ .command('get <target>')
493
+ .description('Retrieve a document by path or #docid')
494
+ .option('--json', 'JSON output')
495
+ .option('--full', 'Return full document content')
496
+ .action((target, options) => {
497
+ const args = ['get', target];
498
+ if (options.json)
499
+ args.push('--json');
500
+ if (options.full)
501
+ args.push('--full');
502
+ runQmd(args, 30_000);
503
+ });
504
+ qmd
505
+ .command('multi-get <targets>')
506
+ .description('Retrieve multiple documents (comma-separated list)')
507
+ .option('--json', 'JSON output')
508
+ .action((targets, options) => {
509
+ const args = ['multi-get', targets];
510
+ if (options.json)
511
+ args.push('--json');
512
+ runQmd(args, 60_000);
513
+ });
514
+ qmd
515
+ .command('status')
516
+ .description('Show index status')
517
+ .action(() => runQmd(['status'], 30_000));
518
+ qmd
519
+ .command('update')
520
+ .description('Incrementally update the index')
521
+ .action(() => runQmd(['update'], 120_000));
522
+ qmd
523
+ .command('embed')
524
+ .description('Update embeddings (slow)')
525
+ .action(() => runQmd(['embed'], 300_000));
526
+ const collection = qmd
527
+ .command('collection')
528
+ .description('Manage collections');
529
+ collection
530
+ .command('add <path>')
531
+ .description('Add a markdown collection')
532
+ .requiredOption('-n, --name <name>', 'Collection name')
533
+ .option('-m, --mask <glob>', 'Glob mask (default "**/*.md")')
534
+ .action((path, options) => {
535
+ const args = ['collection', 'add', path, '--name', options.name];
536
+ if (options.mask)
537
+ args.push('--mask', options.mask);
538
+ runQmd(args, 60_000);
539
+ });
540
+ const contextCmd = qmd
541
+ .command('context')
542
+ .description('Manage collection context');
543
+ contextCmd
544
+ .command('add <collection> <description>')
545
+ .description('Attach a description to a collection')
546
+ .action((collectionName, description) => {
547
+ runQmd(['context', 'add', collectionName, description], 30_000);
548
+ });
549
+ }
550
+ // =============================================================================
551
+ // USER COMMANDS
552
+ // =============================================================================
553
+ function createUserCommands(program) {
554
+ const users = program
555
+ .command('users')
556
+ .description('Manage users and per-user settings');
557
+ const withDb = async (fn) => {
558
+ const db = (0, db_1.createDatabase)();
559
+ (0, migrations_1.createMigrationRunner)(db).migrate();
560
+ try {
561
+ return await fn(db);
562
+ }
563
+ finally {
564
+ db.close();
565
+ }
566
+ };
567
+ users
568
+ .command('list')
569
+ .description('List known users')
570
+ .action(async () => {
571
+ await withDb((db) => {
572
+ const rows = db.listUsers();
573
+ if (rows.length === 0) {
574
+ console.log('No users found.');
575
+ return;
576
+ }
577
+ console.log('\nUsers:\n');
578
+ console.log('ID\t\tPlatform\tPlatformUserId\tUsername');
579
+ console.log('─'.repeat(80));
580
+ for (const user of rows) {
581
+ console.log(`${user.id}\t${user.platform}\t${user.platformUserId}\t${user.username || '-'}`);
582
+ }
583
+ });
584
+ });
585
+ users
586
+ .command('settings <platform> <platformUserId>')
587
+ .description('Show settings for a user')
588
+ .action(async (platform, platformUserId) => {
589
+ await withDb((db) => {
590
+ const user = db.getUserByPlatformId(platform, platformUserId);
591
+ if (!user) {
592
+ console.log('User not found.');
593
+ return;
594
+ }
595
+ console.log(JSON.stringify(user.settings || {}, null, 2));
596
+ });
597
+ });
598
+ users
599
+ .command('settings-by-id <userId>')
600
+ .description('Show settings for a user by internal ID')
601
+ .action(async (userId) => {
602
+ await withDb((db) => {
603
+ const user = db.getUser(userId);
604
+ if (!user) {
605
+ console.log('User not found.');
606
+ return;
607
+ }
608
+ console.log(JSON.stringify(user.settings || {}, null, 2));
609
+ });
610
+ });
611
+ const applySettings = async (db, userId, patch) => {
612
+ return db.updateUserSettings(userId, patch);
613
+ };
614
+ const parseNumber = (value) => {
615
+ if (value === undefined)
616
+ return undefined;
617
+ const num = Number(value);
618
+ if (!Number.isFinite(num))
619
+ return undefined;
620
+ return num;
621
+ };
622
+ const parseDigestTime = (value) => {
623
+ if (!value)
624
+ return undefined;
625
+ const match = value.match(/^(\d{1,2}):(\d{2})$/);
626
+ if (!match)
627
+ return undefined;
628
+ const hour = Number.parseInt(match[1], 10);
629
+ const minute = Number.parseInt(match[2], 10);
630
+ if (!Number.isFinite(hour) || hour < 0 || hour > 23)
631
+ return undefined;
632
+ if (!Number.isFinite(minute) || minute < 0 || minute > 59)
633
+ return undefined;
634
+ return `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
635
+ };
636
+ users
637
+ .command('set-settings <platform> <platformUserId>')
638
+ .description('Update settings for a user')
639
+ .option('--max-order-size <usd>', 'Max single order size (USD)')
640
+ .option('--max-position-value <usd>', 'Max exposure per position (USD)')
641
+ .option('--max-total-exposure <usd>', 'Max total exposure (USD)')
642
+ .option('--stop-loss-pct <pct>', 'Stop-loss trigger percent (e.g., 0.2 or 20)')
643
+ .option('--digest-enable', 'Enable daily digest notifications')
644
+ .option('--digest-disable', 'Disable daily digest notifications')
645
+ .option('--digest-time <HH:MM>', 'Set daily digest time (24h, local)')
646
+ .option('--digest-reset', 'Disable digest and clear time')
647
+ .option('--reset', 'Clear risk limits')
648
+ .option('--disable', 'Disable risk limits (set to 0)')
649
+ .action(async (platform, platformUserId, options) => {
650
+ await withDb(async (db) => {
651
+ const user = db.getUserByPlatformId(platform, platformUserId);
652
+ if (!user) {
653
+ console.log('User not found.');
654
+ return;
655
+ }
656
+ const patch = {};
657
+ if (options.reset) {
658
+ patch.maxOrderSize = undefined;
659
+ patch.maxPositionValue = undefined;
660
+ patch.maxTotalExposure = undefined;
661
+ patch.stopLossPct = undefined;
662
+ }
663
+ else if (options.disable) {
664
+ patch.maxOrderSize = 0;
665
+ patch.maxPositionValue = 0;
666
+ patch.maxTotalExposure = 0;
667
+ patch.stopLossPct = 0;
668
+ }
669
+ else {
670
+ const maxOrderSize = parseNumber(options.maxOrderSize);
671
+ const maxPositionValue = parseNumber(options.maxPositionValue);
672
+ const maxTotalExposure = parseNumber(options.maxTotalExposure);
673
+ const stopLossPct = parseNumber(options.stopLossPct);
674
+ if (maxOrderSize !== undefined)
675
+ patch.maxOrderSize = maxOrderSize;
676
+ if (maxPositionValue !== undefined)
677
+ patch.maxPositionValue = maxPositionValue;
678
+ if (maxTotalExposure !== undefined)
679
+ patch.maxTotalExposure = maxTotalExposure;
680
+ if (stopLossPct !== undefined)
681
+ patch.stopLossPct = stopLossPct;
682
+ }
683
+ if (options.digestReset) {
684
+ patch.digestEnabled = false;
685
+ patch.digestTime = undefined;
686
+ }
687
+ else {
688
+ if (options.digestEnable)
689
+ patch.digestEnabled = true;
690
+ if (options.digestDisable)
691
+ patch.digestEnabled = false;
692
+ if (options.digestTime) {
693
+ const time = parseDigestTime(options.digestTime);
694
+ if (!time) {
695
+ console.log('Invalid --digest-time. Use HH:MM (24h).');
696
+ return;
697
+ }
698
+ patch.digestTime = time;
699
+ patch.digestEnabled = true;
700
+ }
701
+ }
702
+ if (Object.keys(patch).length === 0) {
703
+ console.log('No settings provided.');
704
+ return;
705
+ }
706
+ const ok = await applySettings(db, user.id, patch);
707
+ console.log(ok ? 'Updated settings.' : 'Failed to update settings.');
708
+ });
709
+ });
710
+ users
711
+ .command('set-settings-by-id <userId>')
712
+ .description('Update settings by internal user ID')
713
+ .option('--max-order-size <usd>', 'Max single order size (USD)')
714
+ .option('--max-position-value <usd>', 'Max exposure per position (USD)')
715
+ .option('--max-total-exposure <usd>', 'Max total exposure (USD)')
716
+ .option('--stop-loss-pct <pct>', 'Stop-loss trigger percent (e.g., 0.2 or 20)')
717
+ .option('--digest-enable', 'Enable daily digest notifications')
718
+ .option('--digest-disable', 'Disable daily digest notifications')
719
+ .option('--digest-time <HH:MM>', 'Set daily digest time (24h, local)')
720
+ .option('--digest-reset', 'Disable digest and clear time')
721
+ .option('--reset', 'Clear risk limits')
722
+ .option('--disable', 'Disable risk limits (set to 0)')
723
+ .action(async (userId, options) => {
724
+ await withDb(async (db) => {
725
+ const patch = {};
726
+ if (options.reset) {
727
+ patch.maxOrderSize = undefined;
728
+ patch.maxPositionValue = undefined;
729
+ patch.maxTotalExposure = undefined;
730
+ patch.stopLossPct = undefined;
731
+ }
732
+ else if (options.disable) {
733
+ patch.maxOrderSize = 0;
734
+ patch.maxPositionValue = 0;
735
+ patch.maxTotalExposure = 0;
736
+ patch.stopLossPct = 0;
737
+ }
738
+ else {
739
+ const maxOrderSize = parseNumber(options.maxOrderSize);
740
+ const maxPositionValue = parseNumber(options.maxPositionValue);
741
+ const maxTotalExposure = parseNumber(options.maxTotalExposure);
742
+ const stopLossPct = parseNumber(options.stopLossPct);
743
+ if (maxOrderSize !== undefined)
744
+ patch.maxOrderSize = maxOrderSize;
745
+ if (maxPositionValue !== undefined)
746
+ patch.maxPositionValue = maxPositionValue;
747
+ if (maxTotalExposure !== undefined)
748
+ patch.maxTotalExposure = maxTotalExposure;
749
+ if (stopLossPct !== undefined)
750
+ patch.stopLossPct = stopLossPct;
751
+ }
752
+ if (options.digestReset) {
753
+ patch.digestEnabled = false;
754
+ patch.digestTime = undefined;
755
+ }
756
+ else {
757
+ if (options.digestEnable)
758
+ patch.digestEnabled = true;
759
+ if (options.digestDisable)
760
+ patch.digestEnabled = false;
761
+ if (options.digestTime) {
762
+ const time = parseDigestTime(options.digestTime);
763
+ if (!time) {
764
+ console.log('Invalid --digest-time. Use HH:MM (24h).');
765
+ return;
766
+ }
767
+ patch.digestTime = time;
768
+ patch.digestEnabled = true;
769
+ }
770
+ }
771
+ if (Object.keys(patch).length === 0) {
772
+ console.log('No settings provided.');
773
+ return;
774
+ }
775
+ const ok = await applySettings(db, userId, patch);
776
+ console.log(ok ? 'Updated settings.' : 'User not found.');
777
+ });
778
+ });
779
+ }
780
+ // =============================================================================
781
+ // MEMORY COMMANDS
782
+ // =============================================================================
783
+ function createMemoryCommands(program) {
784
+ const memory = program
785
+ .command('memory')
786
+ .description('Manage memory');
787
+ const withDb = async (fn) => {
788
+ const db = (0, db_1.createDatabase)();
789
+ (0, migrations_1.createMigrationRunner)(db).migrate();
790
+ try {
791
+ return await fn(db);
792
+ }
793
+ finally {
794
+ db.close();
795
+ }
796
+ };
797
+ memory
798
+ .command('list <userId>')
799
+ .description('List memories for a user')
800
+ .option('-t, --type <type>', 'Filter by type (fact, preference, note, summary, context, profile)')
801
+ .option('-c, --channel <channel>', 'Filter by channel', 'cli')
802
+ .option('-l, --limit <n>', 'Limit results', '50')
803
+ .action(async (userId, options) => {
804
+ await withDb((db) => {
805
+ const limit = parseInt(options.limit || '50', 10);
806
+ let query = 'SELECT * FROM user_memory WHERE userId = ?';
807
+ const params = [userId];
808
+ if (options.channel) {
809
+ query += ' AND channel = ?';
810
+ params.push(options.channel);
811
+ }
812
+ if (options.type) {
813
+ query += ' AND type = ?';
814
+ params.push(options.type);
815
+ }
816
+ query += ' ORDER BY updatedAt DESC LIMIT ?';
817
+ params.push(limit);
818
+ try {
819
+ const rows = db.query(query, params);
820
+ if (rows.length === 0) {
821
+ console.log(`\nNo memories found for user: ${userId}`);
822
+ if (options.type)
823
+ console.log(` (filtered by type: ${options.type})`);
824
+ return;
825
+ }
826
+ console.log(`\nMemories for ${userId} (${rows.length}):\n`);
827
+ console.log('Type\t\tKey\t\t\tValue\t\t\t\tUpdated');
828
+ console.log('─'.repeat(90));
829
+ for (const row of rows) {
830
+ const key = row.key.length > 20 ? row.key.slice(0, 17) + '...' : row.key.padEnd(20);
831
+ const value = row.value.length > 30 ? row.value.slice(0, 27) + '...' : row.value.padEnd(30);
832
+ const updated = row.updatedAt.slice(0, 16).replace('T', ' ');
833
+ console.log(`${row.type.padEnd(12)}\t${key}\t${value}\t${updated}`);
834
+ }
835
+ }
836
+ catch (e) {
837
+ // Table might not exist yet
838
+ console.log(`\nNo memories found for user: ${userId}`);
839
+ console.log('(Memory table not initialized - run the gateway first)');
840
+ }
841
+ });
842
+ });
843
+ memory
844
+ .command('clear <userId>')
845
+ .description('Clear all memories for a user')
846
+ .option('-c, --channel <channel>', 'Clear only for specific channel')
847
+ .option('-t, --type <type>', 'Clear only specific type')
848
+ .option('-y, --yes', 'Skip confirmation')
849
+ .action(async (userId, options) => {
850
+ await withDb((db) => {
851
+ let query = 'DELETE FROM user_memory WHERE userId = ?';
852
+ const params = [userId];
853
+ let desc = `all memories for ${userId}`;
854
+ if (options.channel) {
855
+ query += ' AND channel = ?';
856
+ params.push(options.channel);
857
+ desc += ` in channel ${options.channel}`;
858
+ }
859
+ if (options.type) {
860
+ query += ' AND type = ?';
861
+ params.push(options.type);
862
+ desc += ` of type ${options.type}`;
863
+ }
864
+ if (!options.yes) {
865
+ console.log(`About to delete ${desc}`);
866
+ console.log('Run with --yes to confirm');
867
+ return;
868
+ }
869
+ try {
870
+ // Count before delete
871
+ const countBefore = db.query('SELECT COUNT(*) as count FROM user_memory WHERE userId = ?', [userId]);
872
+ db.run(query, params);
873
+ const countAfter = db.query('SELECT COUNT(*) as count FROM user_memory WHERE userId = ?', [userId]);
874
+ const deleted = (countBefore[0]?.count || 0) - (countAfter[0]?.count || 0);
875
+ console.log(`Cleared ${deleted} memories for ${userId}`);
876
+ }
877
+ catch (e) {
878
+ console.log('No memories to clear (table not initialized)');
879
+ }
880
+ });
881
+ });
882
+ memory
883
+ .command('export <userId>')
884
+ .description('Export memories to JSON')
885
+ .option('-o, --output <file>', 'Output file')
886
+ .option('-c, --channel <channel>', 'Export only for specific channel')
887
+ .action(async (userId, options) => {
888
+ await withDb((db) => {
889
+ let query = 'SELECT * FROM user_memory WHERE userId = ?';
890
+ const params = [userId];
891
+ if (options.channel) {
892
+ query += ' AND channel = ?';
893
+ params.push(options.channel);
894
+ }
895
+ query += ' ORDER BY type, key';
896
+ try {
897
+ const rows = db.query(query, params);
898
+ const output = options.output || `${userId}-memories.json`;
899
+ if (rows.length === 0) {
900
+ console.log(`No memories to export for ${userId}`);
901
+ return;
902
+ }
903
+ (0, fs_1.writeFileSync)(output, JSON.stringify(rows, null, 2));
904
+ console.log(`Exported ${rows.length} memories to ${output}`);
905
+ }
906
+ catch (e) {
907
+ console.log('No memories to export (table not initialized)');
908
+ }
909
+ });
910
+ });
911
+ memory
912
+ .command('search <userId> <query>')
913
+ .description('Search memories by content')
914
+ .option('-c, --channel <channel>', 'Search only in specific channel')
915
+ .action(async (userId, query, options) => {
916
+ await withDb((db) => {
917
+ let sql = 'SELECT * FROM user_memory WHERE userId = ? AND (key LIKE ? OR value LIKE ?)';
918
+ const searchPattern = `%${query}%`;
919
+ const params = [userId, searchPattern, searchPattern];
920
+ if (options.channel) {
921
+ sql += ' AND channel = ?';
922
+ params.push(options.channel);
923
+ }
924
+ sql += ' ORDER BY updatedAt DESC LIMIT 20';
925
+ try {
926
+ const rows = db.query(sql, params);
927
+ if (rows.length === 0) {
928
+ console.log(`\nNo memories matching "${query}" for ${userId}`);
929
+ return;
930
+ }
931
+ console.log(`\nSearch results for "${query}" (${rows.length}):\n`);
932
+ for (const row of rows) {
933
+ console.log(`[${row.type}] ${row.key}: ${row.value.slice(0, 60)}${row.value.length > 60 ? '...' : ''}`);
934
+ }
935
+ }
936
+ catch (e) {
937
+ console.log('Memory table not initialized');
938
+ }
939
+ });
940
+ });
941
+ }
942
+ // =============================================================================
943
+ // HOOK COMMANDS
944
+ // =============================================================================
945
+ function createHookCommands(program) {
946
+ const hooks = program
947
+ .command('hooks')
948
+ .description('Manage hooks');
949
+ hooks
950
+ .command('list')
951
+ .description('List installed hooks')
952
+ .action(async () => {
953
+ const hooksDir = (0, hooks_1.getHooksDir)();
954
+ if (!(0, fs_1.existsSync)(hooksDir)) {
955
+ console.log('No hooks installed');
956
+ return;
957
+ }
958
+ const entries = (0, fs_1.readdirSync)(hooksDir, { withFileTypes: true }).filter((entry) => entry.isDirectory());
959
+ if (entries.length === 0) {
960
+ console.log('No hooks installed');
961
+ return;
962
+ }
963
+ const state = (0, hooks_1.loadHooksState)();
964
+ console.log(`\nInstalled hooks (${entries.length}):\n`);
965
+ for (const entry of entries) {
966
+ const hookPath = (0, path_1.join)(hooksDir, entry.name);
967
+ const enabled = state.sources[hookPath]?.enabled ?? true;
968
+ console.log(` ${entry.name} (${enabled ? 'enabled' : 'disabled'})`);
969
+ }
970
+ });
971
+ hooks
972
+ .command('install <path>')
973
+ .description('Install a hook')
974
+ .action(async (path) => {
975
+ const hooksDir = (0, hooks_1.getHooksDir)();
976
+ if (!(0, fs_1.existsSync)(hooksDir)) {
977
+ (0, fs_1.mkdirSync)(hooksDir, { recursive: true });
978
+ }
979
+ const resolved = path.trim();
980
+ if (!resolved) {
981
+ console.error('Missing hook path');
982
+ return;
983
+ }
984
+ const stats = (0, fs_1.statSync)(resolved);
985
+ const hookName = resolved.split('/').filter(Boolean).pop();
986
+ const destDir = (0, path_1.join)(hooksDir, hookName);
987
+ if (!(0, fs_1.existsSync)(destDir)) {
988
+ (0, fs_1.mkdirSync)(destDir, { recursive: true });
989
+ }
990
+ if (stats.isDirectory()) {
991
+ (0, fs_1.cpSync)(resolved, destDir, { recursive: true });
992
+ }
993
+ else {
994
+ const content = (0, fs_1.readFileSync)(resolved, 'utf-8');
995
+ (0, fs_1.writeFileSync)((0, path_1.join)(destDir, 'index.js'), content);
996
+ }
997
+ (0, hooks_1.setHookSourceEnabled)(destDir, true);
998
+ console.log(`Installed hook: ${hookName}`);
999
+ });
1000
+ hooks
1001
+ .command('uninstall <name>')
1002
+ .description('Uninstall a hook')
1003
+ .action(async (name) => {
1004
+ const hooksDir = (0, hooks_1.getHooksDir)();
1005
+ const target = (0, path_1.join)(hooksDir, name);
1006
+ if (!(0, fs_1.existsSync)(target)) {
1007
+ console.log(`Hook not found: ${name}`);
1008
+ return;
1009
+ }
1010
+ (0, fs_1.rmSync)(target, { recursive: true, force: true });
1011
+ (0, hooks_1.removeHookSourceState)(target);
1012
+ console.log(`Uninstalled hook: ${name}`);
1013
+ });
1014
+ hooks
1015
+ .command('enable <name>')
1016
+ .description('Enable a hook')
1017
+ .action(async (name) => {
1018
+ const hooksDir = (0, hooks_1.getHooksDir)();
1019
+ const target = (0, path_1.join)(hooksDir, name);
1020
+ if (!(0, fs_1.existsSync)(target)) {
1021
+ console.log(`Hook not found: ${name}`);
1022
+ return;
1023
+ }
1024
+ (0, hooks_1.setHookSourceEnabled)(target, true);
1025
+ console.log(`Enabled hook: ${name}`);
1026
+ });
1027
+ hooks
1028
+ .command('disable <name>')
1029
+ .description('Disable a hook')
1030
+ .action(async (name) => {
1031
+ const hooksDir = (0, hooks_1.getHooksDir)();
1032
+ const target = (0, path_1.join)(hooksDir, name);
1033
+ if (!(0, fs_1.existsSync)(target)) {
1034
+ console.log(`Hook not found: ${name}`);
1035
+ return;
1036
+ }
1037
+ (0, hooks_1.setHookSourceEnabled)(target, false);
1038
+ console.log(`Disabled hook: ${name}`);
1039
+ });
1040
+ hooks
1041
+ .command('trace')
1042
+ .description('Show recent hook traces')
1043
+ .option('-n, --limit <n>', 'Number of trace entries to show', '50')
1044
+ .option('--clear', 'Clear trace log')
1045
+ .action(async (options) => {
1046
+ const hooksDir = (0, hooks_1.getHooksDir)();
1047
+ const tracePath = (0, path_1.join)(hooksDir, 'trace.log');
1048
+ if (options.clear) {
1049
+ if ((0, fs_1.existsSync)(tracePath)) {
1050
+ (0, fs_1.truncateSync)(tracePath, 0);
1051
+ }
1052
+ console.log('Hook trace log cleared');
1053
+ return;
1054
+ }
1055
+ if (!(0, fs_1.existsSync)(tracePath)) {
1056
+ console.log('No hook trace log found');
1057
+ return;
1058
+ }
1059
+ const limit = Math.max(1, Number.parseInt(options.limit, 10) || 50);
1060
+ const content = (0, fs_1.readFileSync)(tracePath, 'utf-8').trim();
1061
+ if (!content) {
1062
+ console.log('Hook trace log is empty');
1063
+ return;
1064
+ }
1065
+ const lines = content.split('\n').filter(Boolean);
1066
+ const slice = lines.slice(Math.max(0, lines.length - limit));
1067
+ console.log(`\nHook traces (last ${slice.length}):\n`);
1068
+ for (const line of slice) {
1069
+ try {
1070
+ const entry = JSON.parse(line);
1071
+ const name = entry.hookName || entry.hookId || 'unknown';
1072
+ const status = entry.status || 'ok';
1073
+ const duration = typeof entry.durationMs === 'number' ? `${entry.durationMs}ms` : '';
1074
+ const error = entry.error ? ` - ${entry.error}` : '';
1075
+ console.log(` ${entry.event} :: ${name} :: ${status} ${duration}${error}`);
1076
+ }
1077
+ catch {
1078
+ console.log(` ${line}`);
1079
+ }
1080
+ }
1081
+ });
1082
+ const hookState = hooks
1083
+ .command('state')
1084
+ .description('Manage hook state storage');
1085
+ hookState
1086
+ .command('get <name> [key]')
1087
+ .description('Get hook state (whole or key)')
1088
+ .action(async (name, key) => {
1089
+ const hookKey = (0, hooks_1.resolveHookStateKey)(name);
1090
+ const store = (0, hooks_1.loadHookStateStore)();
1091
+ const data = store.data[hookKey];
1092
+ if (!data) {
1093
+ console.log('No state found for hook');
1094
+ return;
1095
+ }
1096
+ if (key) {
1097
+ console.log(JSON.stringify(data[key], null, 2));
1098
+ return;
1099
+ }
1100
+ console.log(JSON.stringify(data, null, 2));
1101
+ });
1102
+ hookState
1103
+ .command('set <name> <key> <value>')
1104
+ .description('Set hook state (value can be JSON)')
1105
+ .action(async (name, key, value) => {
1106
+ const hookKey = (0, hooks_1.resolveHookStateKey)(name);
1107
+ const store = (0, hooks_1.loadHookStateStore)();
1108
+ let parsed = value;
1109
+ try {
1110
+ parsed = JSON.parse(value);
1111
+ }
1112
+ catch {
1113
+ // keep as string
1114
+ }
1115
+ if (!store.data[hookKey]) {
1116
+ store.data[hookKey] = {};
1117
+ }
1118
+ store.data[hookKey][key] = parsed;
1119
+ store.updatedAt = new Date().toISOString();
1120
+ (0, hooks_1.saveHookStateStore)(undefined, store);
1121
+ console.log('Hook state updated');
1122
+ });
1123
+ hookState
1124
+ .command('clear <name> [key]')
1125
+ .description('Clear hook state (entire hook or single key)')
1126
+ .action(async (name, key) => {
1127
+ const hookKey = (0, hooks_1.resolveHookStateKey)(name);
1128
+ const store = (0, hooks_1.loadHookStateStore)();
1129
+ if (!store.data[hookKey]) {
1130
+ console.log('No state found for hook');
1131
+ return;
1132
+ }
1133
+ if (key) {
1134
+ delete store.data[hookKey][key];
1135
+ }
1136
+ else {
1137
+ delete store.data[hookKey];
1138
+ }
1139
+ store.updatedAt = new Date().toISOString();
1140
+ (0, hooks_1.saveHookStateStore)(undefined, store);
1141
+ console.log('Hook state cleared');
1142
+ });
1143
+ }
1144
+ // =============================================================================
1145
+ // MCP COMMANDS
1146
+ // =============================================================================
1147
+ function createMcpCommands(program) {
1148
+ const mcp = program
1149
+ .command('mcp')
1150
+ .description('Manage MCP servers');
1151
+ mcp
1152
+ .command('list')
1153
+ .description('List configured MCP servers')
1154
+ .action(async () => {
1155
+ const mcpConfigPaths = [
1156
+ (0, path_1.join)(process.cwd(), '.mcp.json'),
1157
+ (0, path_1.join)((0, os_1.homedir)(), '.config', 'clodds', 'mcp.json'),
1158
+ ];
1159
+ for (const path of mcpConfigPaths) {
1160
+ if ((0, fs_1.existsSync)(path)) {
1161
+ const config = JSON.parse((0, fs_1.readFileSync)(path, 'utf-8'));
1162
+ console.log(`\nMCP servers from ${path}:\n`);
1163
+ if (config.mcpServers) {
1164
+ for (const [name, server] of Object.entries(config.mcpServers)) {
1165
+ const s = server;
1166
+ if (s.transport === 'sse') {
1167
+ console.log(` ${name}: sse ${s.sseEndpoint || ''}`.trim());
1168
+ if (s.messageEndpoint) {
1169
+ console.log(` message: ${s.messageEndpoint}`);
1170
+ }
1171
+ }
1172
+ else {
1173
+ console.log(` ${name}: ${s.command || '(missing command)'}`);
1174
+ }
1175
+ }
1176
+ }
1177
+ return;
1178
+ }
1179
+ }
1180
+ console.log('No MCP configuration found');
1181
+ });
1182
+ mcp
1183
+ .command('add <name> <command>')
1184
+ .description('Add an MCP server')
1185
+ .option('-a, --args <args>', 'Command arguments (comma-separated)')
1186
+ .option('-e, --env <env>', 'Environment variables (KEY=VALUE,KEY2=VALUE2)')
1187
+ .option('--global', 'Add to global config instead of project')
1188
+ .action(async (name, command, options) => {
1189
+ const configPath = options.global
1190
+ ? (0, path_1.join)((0, os_1.homedir)(), '.config', 'clodds', 'mcp.json')
1191
+ : (0, path_1.join)(process.cwd(), '.mcp.json');
1192
+ // Ensure directory exists for global config
1193
+ if (options.global) {
1194
+ const configDir = (0, path_1.join)((0, os_1.homedir)(), '.config', 'clodds');
1195
+ if (!(0, fs_1.existsSync)(configDir)) {
1196
+ (0, fs_1.mkdirSync)(configDir, { recursive: true });
1197
+ }
1198
+ }
1199
+ // Load or create config
1200
+ let config = { mcpServers: {} };
1201
+ if ((0, fs_1.existsSync)(configPath)) {
1202
+ try {
1203
+ config = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
1204
+ }
1205
+ catch (e) {
1206
+ console.error(`Error reading ${configPath}: ${e}`);
1207
+ return;
1208
+ }
1209
+ }
1210
+ if (!config.mcpServers) {
1211
+ config.mcpServers = {};
1212
+ }
1213
+ // Check if already exists
1214
+ if (config.mcpServers[name]) {
1215
+ console.log(`MCP server "${name}" already exists. Use 'mcp remove' first to replace.`);
1216
+ return;
1217
+ }
1218
+ // Build server config
1219
+ const serverConfig = { command };
1220
+ if (options.args) {
1221
+ serverConfig.args = options.args.split(',').map(a => a.trim());
1222
+ }
1223
+ if (options.env) {
1224
+ serverConfig.env = {};
1225
+ for (const pair of options.env.split(',')) {
1226
+ const [key, ...valueParts] = pair.split('=');
1227
+ if (key && valueParts.length > 0) {
1228
+ serverConfig.env[key.trim()] = valueParts.join('=').trim();
1229
+ }
1230
+ }
1231
+ }
1232
+ config.mcpServers[name] = serverConfig;
1233
+ // Write config
1234
+ (0, fs_1.writeFileSync)(configPath, JSON.stringify(config, null, 2));
1235
+ console.log(`Added MCP server "${name}" to ${configPath}`);
1236
+ console.log(` Command: ${command}`);
1237
+ if (serverConfig.args)
1238
+ console.log(` Args: ${serverConfig.args.join(' ')}`);
1239
+ if (serverConfig.env)
1240
+ console.log(` Env: ${Object.keys(serverConfig.env).join(', ')}`);
1241
+ });
1242
+ mcp
1243
+ .command('remove <name>')
1244
+ .description('Remove an MCP server')
1245
+ .option('--global', 'Remove from global config instead of project')
1246
+ .action(async (name, options) => {
1247
+ const configPath = options.global
1248
+ ? (0, path_1.join)((0, os_1.homedir)(), '.config', 'clodds', 'mcp.json')
1249
+ : (0, path_1.join)(process.cwd(), '.mcp.json');
1250
+ if (!(0, fs_1.existsSync)(configPath)) {
1251
+ console.log(`No MCP config found at ${configPath}`);
1252
+ return;
1253
+ }
1254
+ let config;
1255
+ try {
1256
+ config = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
1257
+ }
1258
+ catch (e) {
1259
+ console.error(`Error reading ${configPath}: ${e}`);
1260
+ return;
1261
+ }
1262
+ if (!config.mcpServers || !config.mcpServers[name]) {
1263
+ console.log(`MCP server "${name}" not found in ${configPath}`);
1264
+ return;
1265
+ }
1266
+ delete config.mcpServers[name];
1267
+ (0, fs_1.writeFileSync)(configPath, JSON.stringify(config, null, 2));
1268
+ console.log(`Removed MCP server "${name}" from ${configPath}`);
1269
+ });
1270
+ mcp
1271
+ .command('test <name>')
1272
+ .description('Test connection to MCP server')
1273
+ .option('--global', 'Look in global config instead of project')
1274
+ .option('--timeout <ms>', 'Timeout in milliseconds', '5000')
1275
+ .action(async (name, options) => {
1276
+ const configPaths = options.global
1277
+ ? [(0, path_1.join)((0, os_1.homedir)(), '.config', 'clodds', 'mcp.json')]
1278
+ : [(0, path_1.join)(process.cwd(), '.mcp.json'), (0, path_1.join)((0, os_1.homedir)(), '.config', 'clodds', 'mcp.json')];
1279
+ let serverConfig = null;
1280
+ let foundPath = '';
1281
+ for (const configPath of configPaths) {
1282
+ if ((0, fs_1.existsSync)(configPath)) {
1283
+ try {
1284
+ const config = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
1285
+ if (config.mcpServers?.[name]) {
1286
+ serverConfig = config.mcpServers[name];
1287
+ foundPath = configPath;
1288
+ break;
1289
+ }
1290
+ }
1291
+ catch { }
1292
+ }
1293
+ }
1294
+ if (!serverConfig || !serverConfig.command) {
1295
+ console.log(`MCP server "${name}" not found`);
1296
+ return;
1297
+ }
1298
+ console.log(`Testing MCP server "${name}" from ${foundPath}...`);
1299
+ console.log(` Command: ${serverConfig.command} ${(serverConfig.args || []).join(' ')}`);
1300
+ // Try to spawn the process and check if it starts
1301
+ const { spawn } = require('child_process');
1302
+ const timeout = parseInt(options.timeout || '5000', 10);
1303
+ try {
1304
+ const proc = spawn(serverConfig.command, serverConfig.args || [], {
1305
+ env: { ...process.env, ...serverConfig.env },
1306
+ stdio: ['pipe', 'pipe', 'pipe'],
1307
+ });
1308
+ let output = '';
1309
+ let errorOutput = '';
1310
+ proc.stdout.on('data', (data) => {
1311
+ output += data.toString();
1312
+ });
1313
+ proc.stderr.on('data', (data) => {
1314
+ errorOutput += data.toString();
1315
+ });
1316
+ const result = await Promise.race([
1317
+ new Promise((resolve) => {
1318
+ // If process emits any data or stays alive for a bit, consider it started
1319
+ setTimeout(() => resolve('started'), 1000);
1320
+ }),
1321
+ new Promise((_, reject) => {
1322
+ proc.on('error', (err) => reject(err));
1323
+ }),
1324
+ new Promise((resolve) => {
1325
+ proc.on('exit', (code) => {
1326
+ if (code !== 0)
1327
+ resolve('exited');
1328
+ });
1329
+ }),
1330
+ new Promise((resolve) => {
1331
+ setTimeout(() => resolve('timeout'), timeout);
1332
+ }),
1333
+ ]);
1334
+ // Kill the process after test
1335
+ proc.kill();
1336
+ if (result === 'started' || result === 'timeout') {
1337
+ console.log(`\n✅ MCP server "${name}" started successfully`);
1338
+ if (output)
1339
+ console.log(` Output: ${output.slice(0, 200)}`);
1340
+ }
1341
+ else {
1342
+ console.log(`\n❌ MCP server "${name}" failed to start`);
1343
+ if (errorOutput)
1344
+ console.log(` Error: ${errorOutput.slice(0, 200)}`);
1345
+ }
1346
+ }
1347
+ catch (e) {
1348
+ const err = e;
1349
+ console.log(`\n❌ Failed to start MCP server "${name}"`);
1350
+ console.log(` Error: ${err.message}`);
1351
+ if (err.code === 'ENOENT') {
1352
+ console.log(` Command not found: ${serverConfig.command}`);
1353
+ }
1354
+ }
1355
+ });
1356
+ }
1357
+ // =============================================================================
1358
+ // MARKET INDEX COMMANDS
1359
+ // =============================================================================
1360
+ function createMarketIndexCommands(program) {
1361
+ const marketIndex = program
1362
+ .command('market-index')
1363
+ .description('Market index maintenance');
1364
+ marketIndex
1365
+ .command('stats')
1366
+ .description('Show market index stats (counts by platform)')
1367
+ .option('-p, --platforms <platforms>', 'Comma-separated platforms')
1368
+ .action(async (options) => {
1369
+ const { initDatabase } = await Promise.resolve().then(() => __importStar(require('../../db')));
1370
+ const { createEmbeddingsService } = await Promise.resolve().then(() => __importStar(require('../../embeddings')));
1371
+ const { createMarketIndexService } = await Promise.resolve().then(() => __importStar(require('../../market-index')));
1372
+ const db = await initDatabase();
1373
+ const embeddings = createEmbeddingsService(db);
1374
+ const marketIndexService = createMarketIndexService(db, embeddings);
1375
+ const platforms = options.platforms
1376
+ ? options.platforms.split(',').map((p) => p.trim()).filter(Boolean)
1377
+ : undefined;
1378
+ const stats = marketIndexService.stats(platforms);
1379
+ console.log('\nMarket Index Stats:');
1380
+ console.log(` Total: ${stats.total}`);
1381
+ for (const [platform, count] of Object.entries(stats.byPlatform)) {
1382
+ console.log(` ${platform}: ${count}`);
1383
+ }
1384
+ if (stats.lastSyncAt) {
1385
+ console.log(`\nLast Sync: ${stats.lastSyncAt.toISOString()}`);
1386
+ if (stats.lastSyncIndexed !== undefined) {
1387
+ console.log(` Indexed: ${stats.lastSyncIndexed}`);
1388
+ }
1389
+ if (stats.lastSyncDurationMs !== undefined) {
1390
+ console.log(` Duration: ${stats.lastSyncDurationMs}ms`);
1391
+ }
1392
+ if (stats.lastPruned !== undefined) {
1393
+ console.log(` Pruned: ${stats.lastPruned}`);
1394
+ }
1395
+ }
1396
+ });
1397
+ marketIndex
1398
+ .command('sync')
1399
+ .description('Run a market index sync now')
1400
+ .option('-p, --platforms <platforms>', 'Comma-separated platforms')
1401
+ .option('-l, --limit <limit>', 'Limit per platform', (v) => Number.parseInt(v, 10))
1402
+ .option('-s, --status <status>', 'Status: open|closed|settled|all')
1403
+ .option('--include-sports', 'Include sports markets')
1404
+ .option('--min-volume-24h <num>', 'Minimum 24h volume', (v) => Number.parseFloat(v))
1405
+ .option('--min-liquidity <num>', 'Minimum liquidity', (v) => Number.parseFloat(v))
1406
+ .option('--min-open-interest <num>', 'Minimum open interest', (v) => Number.parseFloat(v))
1407
+ .option('--min-predictions <num>', 'Minimum predictions', (v) => Number.parseInt(v, 10))
1408
+ .option('--exclude-resolved', 'Exclude resolved markets')
1409
+ .option('--prune', 'Prune stale entries during sync')
1410
+ .option('--stale-after-ms <ms>', 'Stale age threshold (ms)', (v) => Number.parseInt(v, 10))
1411
+ .action(async (options) => {
1412
+ const { initDatabase } = await Promise.resolve().then(() => __importStar(require('../../db')));
1413
+ const { createEmbeddingsService } = await Promise.resolve().then(() => __importStar(require('../../embeddings')));
1414
+ const { createMarketIndexService } = await Promise.resolve().then(() => __importStar(require('../../market-index')));
1415
+ const db = await initDatabase();
1416
+ const embeddings = createEmbeddingsService(db);
1417
+ const marketIndexService = createMarketIndexService(db, embeddings);
1418
+ const platforms = options.platforms
1419
+ ? options.platforms.split(',').map((p) => p.trim()).filter(Boolean)
1420
+ : undefined;
1421
+ const result = await marketIndexService.sync({
1422
+ platforms: platforms,
1423
+ limitPerPlatform: options.limit,
1424
+ status: options.status,
1425
+ excludeSports: options.includeSports ? false : undefined,
1426
+ minVolume24h: options.minVolume24h,
1427
+ minLiquidity: options.minLiquidity,
1428
+ minOpenInterest: options.minOpenInterest,
1429
+ minPredictions: options.minPredictions,
1430
+ excludeResolved: options.excludeResolved,
1431
+ prune: options.prune,
1432
+ staleAfterMs: options.staleAfterMs,
1433
+ });
1434
+ console.log('\nMarket Index Sync:');
1435
+ console.log(` Indexed: ${result.indexed}`);
1436
+ for (const [platform, count] of Object.entries(result.byPlatform)) {
1437
+ console.log(` ${platform}: ${count}`);
1438
+ }
1439
+ });
1440
+ }
1441
+ // =============================================================================
1442
+ // PERMISSIONS COMMANDS
1443
+ // =============================================================================
1444
+ function createPermissionCommands(program) {
1445
+ const permissions = program
1446
+ .command('permissions')
1447
+ .description('Manage permissions');
1448
+ permissions
1449
+ .command('list')
1450
+ .description('List permission settings')
1451
+ .option('-a, --agent <agentId>', 'Agent ID', 'default')
1452
+ .action(async (options) => {
1453
+ const agentId = options.agent || 'default';
1454
+ const security = permissions_1.execApprovals.getSecurityConfig(agentId);
1455
+ const allowlist = permissions_1.execApprovals.getAllowlist(agentId);
1456
+ console.log('\nPermission settings:');
1457
+ console.log(` Agent: ${agentId}`);
1458
+ console.log(` Exec mode: ${security.mode}`);
1459
+ console.log(` Ask mode: ${security.ask}`);
1460
+ console.log(` Approval timeout: ${security.approvalTimeout ?? 60000}ms`);
1461
+ console.log(` Fallback mode: ${security.fallbackMode ?? 'deny'}`);
1462
+ console.log('\nAllowlist:');
1463
+ if (allowlist.length === 0) {
1464
+ console.log(' (empty)');
1465
+ }
1466
+ else {
1467
+ for (const entry of allowlist) {
1468
+ const when = entry.addedAt ? new Date(entry.addedAt).toLocaleString() : '-';
1469
+ console.log(` ${entry.id} ${entry.type} ${entry.pattern} (${when})`);
1470
+ }
1471
+ }
1472
+ });
1473
+ permissions
1474
+ .command('allow <pattern>')
1475
+ .description('Add command to allowlist')
1476
+ .option('-a, --agent <agentId>', 'Agent ID', 'default')
1477
+ .option('-t, --type <type>', 'Match type: prefix|glob|regex', 'prefix')
1478
+ .option('-d, --description <desc>', 'Description/reason')
1479
+ .option('--by <name>', 'Added by')
1480
+ .action(async (pattern, options) => {
1481
+ const entry = permissions_1.execApprovals.addToAllowlist(options.agent || 'default', pattern, options.type || 'prefix', {
1482
+ description: options.description,
1483
+ addedBy: options.by,
1484
+ });
1485
+ console.log(`Added to allowlist: ${entry.id} (${entry.type}) ${entry.pattern}`);
1486
+ });
1487
+ permissions
1488
+ .command('remove <entryId>')
1489
+ .description('Remove allowlist entry')
1490
+ .option('-a, --agent <agentId>', 'Agent ID', 'default')
1491
+ .action(async (entryId, options) => {
1492
+ const removed = permissions_1.execApprovals.removeFromAllowlist(options.agent || 'default', entryId);
1493
+ if (removed) {
1494
+ console.log(`Removed allowlist entry: ${entryId}`);
1495
+ }
1496
+ else {
1497
+ console.log(`Entry not found: ${entryId}`);
1498
+ }
1499
+ });
1500
+ permissions
1501
+ .command('mode <mode>')
1502
+ .description('Set exec security mode (deny|allowlist|full)')
1503
+ .option('-a, --agent <agentId>', 'Agent ID', 'default')
1504
+ .action(async (mode, options) => {
1505
+ if (!['deny', 'allowlist', 'full'].includes(mode)) {
1506
+ console.error('Invalid mode. Use: deny, allowlist, full');
1507
+ process.exitCode = 1;
1508
+ return;
1509
+ }
1510
+ permissions_1.execApprovals.setSecurityConfig(options.agent || 'default', { mode: mode });
1511
+ console.log(`Set exec mode to ${mode}`);
1512
+ });
1513
+ permissions
1514
+ .command('ask <mode>')
1515
+ .description('Set approval ask mode (off|on-miss|always)')
1516
+ .option('-a, --agent <agentId>', 'Agent ID', 'default')
1517
+ .action(async (mode, options) => {
1518
+ if (!['off', 'on-miss', 'always'].includes(mode)) {
1519
+ console.error('Invalid ask mode. Use: off, on-miss, always');
1520
+ process.exitCode = 1;
1521
+ return;
1522
+ }
1523
+ permissions_1.execApprovals.setSecurityConfig(options.agent || 'default', { ask: mode });
1524
+ console.log(`Set ask mode to ${mode}`);
1525
+ });
1526
+ permissions
1527
+ .command('pending')
1528
+ .description('List pending approval requests')
1529
+ .action(async () => {
1530
+ const pending = permissions_1.execApprovals.getPendingApprovalsFromDisk();
1531
+ if (pending.length === 0) {
1532
+ console.log('No pending approvals.');
1533
+ return;
1534
+ }
1535
+ console.log('\nPending approvals:\n');
1536
+ console.log('ID\t\tCommand\t\tAgent\t\tExpires');
1537
+ console.log('─'.repeat(80));
1538
+ for (const req of pending) {
1539
+ const expires = req.expiresAt ? req.expiresAt.toLocaleString() : '-';
1540
+ console.log(`${req.id}\t${req.command}\t${req.agentId}\t${expires}`);
1541
+ if (req.requester) {
1542
+ console.log(` requested by ${req.requester.userId} (${req.requester.channel})`);
1543
+ }
1544
+ }
1545
+ });
1546
+ permissions
1547
+ .command('approve <requestId>')
1548
+ .description('Approve a pending request')
1549
+ .option('--always', 'Allow always (adds to allowlist)')
1550
+ .option('--by <name>', 'Approver name')
1551
+ .action(async (requestId, options) => {
1552
+ const decision = options.always ? 'allow-always' : 'allow-once';
1553
+ const ok = permissions_1.execApprovals.recordDecision(requestId, decision, options.by);
1554
+ if (!ok) {
1555
+ console.log(`Request not found: ${requestId}`);
1556
+ process.exitCode = 1;
1557
+ return;
1558
+ }
1559
+ console.log(`Approved ${requestId} (${decision})`);
1560
+ });
1561
+ permissions
1562
+ .command('deny <requestId>')
1563
+ .description('Deny a pending request')
1564
+ .option('--by <name>', 'Approver name')
1565
+ .action(async (requestId, options) => {
1566
+ const ok = permissions_1.execApprovals.recordDecision(requestId, 'deny', options.by);
1567
+ if (!ok) {
1568
+ console.log(`Request not found: ${requestId}`);
1569
+ process.exitCode = 1;
1570
+ return;
1571
+ }
1572
+ console.log(`Denied ${requestId}`);
1573
+ });
1574
+ }
1575
+ // =============================================================================
1576
+ // USAGE COMMANDS
1577
+ // =============================================================================
1578
+ function createUsageCommands(program) {
1579
+ const usage = program
1580
+ .command('usage')
1581
+ .description('View usage statistics');
1582
+ const withDb = async (fn) => {
1583
+ const db = (0, db_1.createDatabase)();
1584
+ (0, migrations_1.createMigrationRunner)(db).migrate();
1585
+ try {
1586
+ return await fn(db);
1587
+ }
1588
+ finally {
1589
+ db.close();
1590
+ }
1591
+ };
1592
+ const formatCost = (cost) => cost < 0.01 ? `$${cost.toFixed(6)}` : `$${cost.toFixed(4)}`;
1593
+ usage
1594
+ .command('summary')
1595
+ .description('Show usage summary')
1596
+ .option('-d, --days <days>', 'Number of days', '7')
1597
+ .action(async (options) => {
1598
+ await withDb((db) => {
1599
+ const days = parseInt(options.days || '7', 10);
1600
+ const since = new Date();
1601
+ since.setDate(since.getDate() - days);
1602
+ const sinceStr = since.toISOString();
1603
+ try {
1604
+ const results = db.query(`
1605
+ SELECT
1606
+ COUNT(*) as requests,
1607
+ COALESCE(SUM(input_tokens), 0) as input_tokens,
1608
+ COALESCE(SUM(output_tokens), 0) as output_tokens,
1609
+ COALESCE(SUM(estimated_cost), 0) as cost
1610
+ FROM usage_records
1611
+ WHERE timestamp >= ?
1612
+ `, [sinceStr]);
1613
+ const result = results[0];
1614
+ if (!result || result.requests === 0) {
1615
+ console.log(`\nUsage summary (last ${days} days):\n`);
1616
+ console.log(' No usage data recorded');
1617
+ console.log('\n Usage is tracked when the gateway is running.');
1618
+ return;
1619
+ }
1620
+ const totalTokens = result.input_tokens + result.output_tokens;
1621
+ console.log(`\nUsage summary (last ${days} days):\n`);
1622
+ console.log(` Total requests: ${result.requests.toLocaleString()}`);
1623
+ console.log(` Input tokens: ${result.input_tokens.toLocaleString()}`);
1624
+ console.log(` Output tokens: ${result.output_tokens.toLocaleString()}`);
1625
+ console.log(` Total tokens: ${totalTokens.toLocaleString()}`);
1626
+ console.log(` Estimated cost: ${formatCost(result.cost)}`);
1627
+ }
1628
+ catch (e) {
1629
+ console.log('\nUsage table not initialized - run the gateway first');
1630
+ }
1631
+ });
1632
+ });
1633
+ usage
1634
+ .command('by-model')
1635
+ .description('Show usage by model')
1636
+ .option('-d, --days <days>', 'Number of days', '7')
1637
+ .action(async (options) => {
1638
+ await withDb((db) => {
1639
+ const days = parseInt(options.days || '7', 10);
1640
+ const since = new Date();
1641
+ since.setDate(since.getDate() - days);
1642
+ const sinceStr = since.toISOString();
1643
+ try {
1644
+ const rows = db.query(`
1645
+ SELECT
1646
+ model,
1647
+ COUNT(*) as requests,
1648
+ SUM(input_tokens) as input_tokens,
1649
+ SUM(output_tokens) as output_tokens,
1650
+ SUM(estimated_cost) as cost
1651
+ FROM usage_records
1652
+ WHERE timestamp >= ?
1653
+ GROUP BY model
1654
+ ORDER BY cost DESC
1655
+ `, [sinceStr]);
1656
+ if (rows.length === 0) {
1657
+ console.log('\nUsage by model:\n');
1658
+ console.log(' No usage data recorded');
1659
+ return;
1660
+ }
1661
+ console.log(`\nUsage by model (last ${days} days):\n`);
1662
+ console.log('Model\t\t\t\t\tRequests\tTokens\t\tCost');
1663
+ console.log('─'.repeat(85));
1664
+ for (const row of rows) {
1665
+ const model = row.model.length > 30 ? row.model.slice(0, 27) + '...' : row.model.padEnd(30);
1666
+ const tokens = (row.input_tokens + row.output_tokens).toLocaleString();
1667
+ console.log(`${model}\t${row.requests}\t\t${tokens.padEnd(12)}\t${formatCost(row.cost)}`);
1668
+ }
1669
+ }
1670
+ catch (e) {
1671
+ console.log('\nUsage table not initialized - run the gateway first');
1672
+ }
1673
+ });
1674
+ });
1675
+ usage
1676
+ .command('by-user')
1677
+ .description('Show usage by user')
1678
+ .option('-d, --days <days>', 'Number of days', '7')
1679
+ .option('-l, --limit <n>', 'Limit results', '20')
1680
+ .action(async (options) => {
1681
+ await withDb((db) => {
1682
+ const days = parseInt(options.days || '7', 10);
1683
+ const limit = parseInt(options.limit || '20', 10);
1684
+ const since = new Date();
1685
+ since.setDate(since.getDate() - days);
1686
+ const sinceStr = since.toISOString();
1687
+ try {
1688
+ const rows = db.query(`
1689
+ SELECT
1690
+ user_id,
1691
+ COUNT(*) as requests,
1692
+ SUM(input_tokens) as input_tokens,
1693
+ SUM(output_tokens) as output_tokens,
1694
+ SUM(estimated_cost) as cost
1695
+ FROM usage_records
1696
+ WHERE timestamp >= ?
1697
+ GROUP BY user_id
1698
+ ORDER BY cost DESC
1699
+ LIMIT ?
1700
+ `, [sinceStr, limit]);
1701
+ if (rows.length === 0) {
1702
+ console.log('\nUsage by user:\n');
1703
+ console.log(' No usage data recorded');
1704
+ return;
1705
+ }
1706
+ console.log(`\nUsage by user (last ${days} days, top ${limit}):\n`);
1707
+ console.log('User ID\t\t\t\t\tRequests\tTokens\t\tCost');
1708
+ console.log('─'.repeat(85));
1709
+ for (const row of rows) {
1710
+ const userId = row.user_id.length > 28 ? row.user_id.slice(0, 25) + '...' : row.user_id.padEnd(28);
1711
+ const tokens = (row.input_tokens + row.output_tokens).toLocaleString();
1712
+ console.log(`${userId}\t${row.requests}\t\t${tokens.padEnd(12)}\t${formatCost(row.cost)}`);
1713
+ }
1714
+ }
1715
+ catch (e) {
1716
+ console.log('\nUsage table not initialized - run the gateway first');
1717
+ }
1718
+ });
1719
+ });
1720
+ usage
1721
+ .command('export')
1722
+ .description('Export usage data')
1723
+ .option('-o, --output <file>', 'Output file')
1724
+ .option('-d, --days <days>', 'Number of days to export', '30')
1725
+ .option('--csv', 'Export as CSV instead of JSON')
1726
+ .action(async (options) => {
1727
+ await withDb((db) => {
1728
+ const days = parseInt(options.days || '30', 10);
1729
+ const since = new Date();
1730
+ since.setDate(since.getDate() - days);
1731
+ const sinceStr = since.toISOString();
1732
+ try {
1733
+ const rows = db.query(`
1734
+ SELECT
1735
+ id, session_id, user_id, model,
1736
+ input_tokens, output_tokens, total_tokens,
1737
+ estimated_cost, timestamp
1738
+ FROM usage_records
1739
+ WHERE timestamp >= ?
1740
+ ORDER BY timestamp DESC
1741
+ `, [sinceStr]);
1742
+ if (rows.length === 0) {
1743
+ console.log('No usage data to export');
1744
+ return;
1745
+ }
1746
+ const ext = options.csv ? 'csv' : 'json';
1747
+ const output = options.output || `usage-export-${new Date().toISOString().slice(0, 10)}.${ext}`;
1748
+ if (options.csv) {
1749
+ const headers = ['id', 'session_id', 'user_id', 'model', 'input_tokens', 'output_tokens', 'total_tokens', 'estimated_cost', 'timestamp'];
1750
+ const csvContent = [
1751
+ headers.join(','),
1752
+ ...rows.map(row => headers.map(h => {
1753
+ const val = row[h];
1754
+ if (typeof val === 'string' && val.includes(','))
1755
+ return `"${val}"`;
1756
+ return val;
1757
+ }).join(','))
1758
+ ].join('\n');
1759
+ (0, fs_1.writeFileSync)(output, csvContent);
1760
+ }
1761
+ else {
1762
+ (0, fs_1.writeFileSync)(output, JSON.stringify(rows, null, 2));
1763
+ }
1764
+ console.log(`Exported ${rows.length} usage records to ${output}`);
1765
+ }
1766
+ catch (e) {
1767
+ console.log('Usage table not initialized - run the gateway first');
1768
+ }
1769
+ });
1770
+ });
1771
+ usage
1772
+ .command('today')
1773
+ .description('Show today\'s usage')
1774
+ .action(async () => {
1775
+ await withDb((db) => {
1776
+ const today = new Date().toISOString().slice(0, 10);
1777
+ try {
1778
+ const results = db.query(`
1779
+ SELECT
1780
+ COUNT(*) as requests,
1781
+ COALESCE(SUM(input_tokens), 0) as input_tokens,
1782
+ COALESCE(SUM(output_tokens), 0) as output_tokens,
1783
+ COALESCE(SUM(estimated_cost), 0) as cost
1784
+ FROM usage_records
1785
+ WHERE timestamp >= ?
1786
+ `, [today]);
1787
+ const result = results[0];
1788
+ if (!result || result.requests === 0) {
1789
+ console.log(`\nToday's usage (${today}):\n`);
1790
+ console.log(' No usage yet today');
1791
+ return;
1792
+ }
1793
+ console.log(`\nToday's usage (${today}):\n`);
1794
+ console.log(` Requests: ${result.requests.toLocaleString()}`);
1795
+ console.log(` Input tokens: ${result.input_tokens.toLocaleString()}`);
1796
+ console.log(` Output tokens: ${result.output_tokens.toLocaleString()}`);
1797
+ console.log(` Total tokens: ${(result.input_tokens + result.output_tokens).toLocaleString()}`);
1798
+ console.log(` Cost: ${formatCost(result.cost)}`);
1799
+ }
1800
+ catch (e) {
1801
+ console.log('Usage table not initialized - run the gateway first');
1802
+ }
1803
+ });
1804
+ });
1805
+ }
1806
+ // =============================================================================
1807
+ // INIT COMMAND
1808
+ // =============================================================================
1809
+ function createInitCommand(program) {
1810
+ program
1811
+ .command('init')
1812
+ .description('Initialize Clodds in current directory')
1813
+ .option('-f, --force', 'Overwrite existing config')
1814
+ .action(async (options) => {
1815
+ const configPath = (0, path_1.join)(process.cwd(), '.clodds.json');
1816
+ if ((0, fs_1.existsSync)(configPath) && !options.force) {
1817
+ console.log('Clodds already initialized. Use --force to overwrite.');
1818
+ return;
1819
+ }
1820
+ const defaultConfig = {
1821
+ name: 'clodds-project',
1822
+ version: '0.1.0',
1823
+ model: 'claude-3-5-sonnet-20241022',
1824
+ features: {
1825
+ memory: true,
1826
+ tools: true,
1827
+ hooks: true,
1828
+ },
1829
+ };
1830
+ (0, fs_1.writeFileSync)(configPath, JSON.stringify(defaultConfig, null, 2));
1831
+ console.log('Initialized Clodds project.');
1832
+ console.log(`Config written to ${configPath}`);
1833
+ });
1834
+ }
1835
+ // =============================================================================
1836
+ // UPGRADE COMMAND
1837
+ // =============================================================================
1838
+ function createUpgradeCommand(program) {
1839
+ program
1840
+ .command('upgrade')
1841
+ .description('Upgrade Clodds to latest version')
1842
+ .option('--check', 'Check for updates only')
1843
+ .action(async (options) => {
1844
+ console.log('Checking for updates...');
1845
+ if (options.check) {
1846
+ console.log('Current version: 0.1.0');
1847
+ console.log('Latest version: 0.1.0');
1848
+ console.log('You are up to date!');
1849
+ }
1850
+ else {
1851
+ console.log('To upgrade, run: npm install -g clodds@latest');
1852
+ }
1853
+ });
1854
+ }
1855
+ // =============================================================================
1856
+ // LOGIN COMMAND
1857
+ // =============================================================================
1858
+ function createLoginCommand(program) {
1859
+ program
1860
+ .command('login')
1861
+ .description('Login to Clodds services')
1862
+ .option('-p, --provider <provider>', 'Provider (anthropic, openai)')
1863
+ .action(async (options) => {
1864
+ const provider = options.provider || 'anthropic';
1865
+ console.log(`\nTo configure ${provider}:`);
1866
+ console.log(` clodds config set ${provider}.apiKey YOUR_API_KEY`);
1867
+ });
1868
+ }
1869
+ // =============================================================================
1870
+ // LOGOUT COMMAND
1871
+ // =============================================================================
1872
+ function createLogoutCommand(program) {
1873
+ program
1874
+ .command('logout')
1875
+ .description('Logout from Clodds services')
1876
+ .option('-a, --all', 'Logout from all providers')
1877
+ .action(async (options) => {
1878
+ console.log('Logged out from Clodds services');
1879
+ });
1880
+ }
1881
+ // =============================================================================
1882
+ // VERSION INFO
1883
+ // =============================================================================
1884
+ function createVersionCommand(program) {
1885
+ program
1886
+ .command('version')
1887
+ .description('Show detailed version info')
1888
+ .action(async () => {
1889
+ console.log('\nClodds Version Info\n');
1890
+ console.log(' Version: 0.1.0');
1891
+ console.log(' Node.js: ' + process.version);
1892
+ console.log(' Platform: ' + process.platform);
1893
+ console.log(' Arch: ' + process.arch);
1894
+ });
1895
+ }
1896
+ // =============================================================================
1897
+ // WHATSAPP COMMANDS
1898
+ // =============================================================================
1899
+ function createWhatsAppCommands(program) {
1900
+ const whatsapp = program
1901
+ .command('whatsapp')
1902
+ .description('WhatsApp channel utilities');
1903
+ whatsapp
1904
+ .command('login')
1905
+ .description('Link a WhatsApp account via QR code')
1906
+ .option('-a, --account <id>', 'Account ID from channels.whatsapp.accounts')
1907
+ .option('--auth-dir <path>', 'Override auth directory')
1908
+ .option('--timeout <ms>', 'Timeout in milliseconds', (value) => Number.parseInt(value, 10))
1909
+ .action(async (options) => {
1910
+ const config = await (0, config_1.loadConfig)();
1911
+ const whatsappConfig = config.channels?.whatsapp;
1912
+ if (!whatsappConfig) {
1913
+ console.log('WhatsApp is not configured in your config file.');
1914
+ return;
1915
+ }
1916
+ const resolved = (0, index_1.resolveWhatsAppAuthDir)(whatsappConfig, {
1917
+ accountId: options.account,
1918
+ authDirOverride: options.authDir,
1919
+ });
1920
+ const timeoutMs = Number.isFinite(options.timeout) ? options.timeout : undefined;
1921
+ console.log(`Starting WhatsApp login for account "${resolved.accountId}"...`);
1922
+ console.log(`Auth dir: ${resolved.authDir}`);
1923
+ const result = await (0, index_1.loginWhatsAppWithQr)(resolved.authDir, timeoutMs);
1924
+ if (result.connected) {
1925
+ console.log(`WhatsApp linked${result.jid ? ` (${result.jid})` : ''}.`);
1926
+ }
1927
+ else {
1928
+ console.log('WhatsApp login timed out or failed.');
1929
+ }
1930
+ });
1931
+ }
1932
+ // =============================================================================
1933
+ // CREDS TEST COMMAND
1934
+ // =============================================================================
1935
+ function createCredsCommands(program) {
1936
+ const creds = program
1937
+ .command('creds')
1938
+ .description('Test and validate API credentials');
1939
+ creds
1940
+ .command('test [platform]')
1941
+ .description('Test API credentials for a platform')
1942
+ .action(async (platform) => {
1943
+ console.log('\n🔑 Credential Validation\n');
1944
+ const results = [];
1945
+ // Test Anthropic
1946
+ const anthropicKey = process.env.ANTHROPIC_API_KEY;
1947
+ if (!platform || platform === 'anthropic') {
1948
+ if (!anthropicKey) {
1949
+ results.push({
1950
+ name: 'Anthropic API',
1951
+ status: 'fail',
1952
+ message: 'ANTHROPIC_API_KEY not set',
1953
+ fix: 'Get key from: https://console.anthropic.com',
1954
+ });
1955
+ }
1956
+ else if (!anthropicKey.startsWith('sk-ant-')) {
1957
+ results.push({
1958
+ name: 'Anthropic API',
1959
+ status: 'warn',
1960
+ message: 'Key format looks wrong (should start with sk-ant-)',
1961
+ fix: 'Verify key at: https://console.anthropic.com',
1962
+ });
1963
+ }
1964
+ else {
1965
+ // Test the key
1966
+ try {
1967
+ const response = await fetch('https://api.anthropic.com/v1/messages', {
1968
+ method: 'POST',
1969
+ headers: {
1970
+ 'Content-Type': 'application/json',
1971
+ 'x-api-key': anthropicKey,
1972
+ 'anthropic-version': '2023-06-01',
1973
+ },
1974
+ body: JSON.stringify({
1975
+ model: 'claude-3-haiku-20240307',
1976
+ max_tokens: 1,
1977
+ messages: [{ role: 'user', content: 'hi' }],
1978
+ }),
1979
+ });
1980
+ if (response.ok) {
1981
+ results.push({
1982
+ name: 'Anthropic API',
1983
+ status: 'pass',
1984
+ message: 'Key valid and working',
1985
+ });
1986
+ }
1987
+ else if (response.status === 401) {
1988
+ results.push({
1989
+ name: 'Anthropic API',
1990
+ status: 'fail',
1991
+ message: 'Invalid API key',
1992
+ fix: 'Check key at: https://console.anthropic.com',
1993
+ });
1994
+ }
1995
+ else if (response.status === 429) {
1996
+ results.push({
1997
+ name: 'Anthropic API',
1998
+ status: 'warn',
1999
+ message: 'Rate limited (but key is valid)',
2000
+ });
2001
+ }
2002
+ else {
2003
+ results.push({
2004
+ name: 'Anthropic API',
2005
+ status: 'warn',
2006
+ message: `Unexpected response: ${response.status}`,
2007
+ });
2008
+ }
2009
+ }
2010
+ catch (e) {
2011
+ results.push({
2012
+ name: 'Anthropic API',
2013
+ status: 'warn',
2014
+ message: `Network error: ${e.message}`,
2015
+ fix: 'Check internet connection',
2016
+ });
2017
+ }
2018
+ }
2019
+ }
2020
+ // Test Polymarket
2021
+ if (!platform || platform === 'polymarket') {
2022
+ const polyKey = process.env.POLY_API_KEY;
2023
+ const polySecret = process.env.POLY_API_SECRET;
2024
+ const polyPass = process.env.POLY_API_PASSPHRASE;
2025
+ const polyPrivate = process.env.POLY_PRIVATE_KEY;
2026
+ if (!polyKey && !polySecret && !polyPass) {
2027
+ results.push({
2028
+ name: 'Polymarket',
2029
+ status: 'warn',
2030
+ message: 'Not configured (optional)',
2031
+ fix: 'Get keys from: https://polymarket.com/settings/api',
2032
+ });
2033
+ }
2034
+ else if (!polyKey || !polySecret || !polyPass) {
2035
+ results.push({
2036
+ name: 'Polymarket',
2037
+ status: 'fail',
2038
+ message: 'Incomplete credentials (need API key, secret, and passphrase)',
2039
+ fix: 'Set all: POLY_API_KEY, POLY_API_SECRET, POLY_API_PASSPHRASE',
2040
+ });
2041
+ }
2042
+ else {
2043
+ // Test fetch markets (read-only, no auth needed)
2044
+ try {
2045
+ const response = await fetch('https://clob.polymarket.com/markets?limit=1');
2046
+ if (response.ok) {
2047
+ results.push({
2048
+ name: 'Polymarket (read)',
2049
+ status: 'pass',
2050
+ message: 'Can fetch markets',
2051
+ });
2052
+ }
2053
+ else {
2054
+ results.push({
2055
+ name: 'Polymarket (read)',
2056
+ status: 'warn',
2057
+ message: `API returned ${response.status}`,
2058
+ });
2059
+ }
2060
+ }
2061
+ catch {
2062
+ results.push({
2063
+ name: 'Polymarket (read)',
2064
+ status: 'warn',
2065
+ message: 'Network error',
2066
+ });
2067
+ }
2068
+ // Check for trading capability
2069
+ if (!polyPrivate) {
2070
+ results.push({
2071
+ name: 'Polymarket (trade)',
2072
+ status: 'warn',
2073
+ message: 'POLY_PRIVATE_KEY not set (cannot trade)',
2074
+ fix: 'Add your wallet private key to enable trading',
2075
+ });
2076
+ }
2077
+ else {
2078
+ results.push({
2079
+ name: 'Polymarket (trade)',
2080
+ status: 'pass',
2081
+ message: 'Trading credentials configured',
2082
+ });
2083
+ }
2084
+ }
2085
+ }
2086
+ // Test Kalshi
2087
+ if (!platform || platform === 'kalshi') {
2088
+ const kalshiKey = process.env.KALSHI_API_KEY;
2089
+ const kalshiSecret = process.env.KALSHI_API_SECRET;
2090
+ const kalshiEmail = process.env.KALSHI_EMAIL;
2091
+ if (!kalshiKey && !kalshiEmail) {
2092
+ results.push({
2093
+ name: 'Kalshi',
2094
+ status: 'warn',
2095
+ message: 'Not configured (optional)',
2096
+ fix: 'Get keys from: https://kalshi.com/account/api',
2097
+ });
2098
+ }
2099
+ else if (kalshiKey && !kalshiSecret) {
2100
+ results.push({
2101
+ name: 'Kalshi',
2102
+ status: 'fail',
2103
+ message: 'API key set but missing secret',
2104
+ fix: 'Set KALSHI_API_SECRET',
2105
+ });
2106
+ }
2107
+ else if (kalshiKey) {
2108
+ results.push({
2109
+ name: 'Kalshi',
2110
+ status: 'pass',
2111
+ message: 'API key credentials configured',
2112
+ });
2113
+ }
2114
+ else if (kalshiEmail) {
2115
+ results.push({
2116
+ name: 'Kalshi',
2117
+ status: 'warn',
2118
+ message: 'Using legacy email auth (API keys recommended)',
2119
+ fix: 'Switch to API keys: https://kalshi.com/account/api',
2120
+ });
2121
+ }
2122
+ }
2123
+ // Test Telegram
2124
+ if (!platform || platform === 'telegram') {
2125
+ const telegramToken = process.env.TELEGRAM_BOT_TOKEN;
2126
+ if (!telegramToken) {
2127
+ results.push({
2128
+ name: 'Telegram',
2129
+ status: 'warn',
2130
+ message: 'Not configured',
2131
+ fix: 'Get token from: https://t.me/BotFather',
2132
+ });
2133
+ }
2134
+ else {
2135
+ try {
2136
+ const response = await fetch(`https://api.telegram.org/bot${telegramToken}/getMe`);
2137
+ const data = await response.json();
2138
+ if (data.ok) {
2139
+ results.push({
2140
+ name: 'Telegram',
2141
+ status: 'pass',
2142
+ message: `Bot: @${data.result?.username}`,
2143
+ });
2144
+ }
2145
+ else {
2146
+ results.push({
2147
+ name: 'Telegram',
2148
+ status: 'fail',
2149
+ message: 'Invalid bot token',
2150
+ fix: 'Check token with @BotFather',
2151
+ });
2152
+ }
2153
+ }
2154
+ catch {
2155
+ results.push({
2156
+ name: 'Telegram',
2157
+ status: 'warn',
2158
+ message: 'Network error testing token',
2159
+ });
2160
+ }
2161
+ }
2162
+ }
2163
+ // Test Discord
2164
+ if (!platform || platform === 'discord') {
2165
+ const discordToken = process.env.DISCORD_BOT_TOKEN;
2166
+ if (!discordToken) {
2167
+ results.push({
2168
+ name: 'Discord',
2169
+ status: 'warn',
2170
+ message: 'Not configured',
2171
+ fix: 'Get token from: https://discord.com/developers/applications',
2172
+ });
2173
+ }
2174
+ else {
2175
+ try {
2176
+ const response = await fetch('https://discord.com/api/v10/users/@me', {
2177
+ headers: { Authorization: `Bot ${discordToken}` },
2178
+ });
2179
+ if (response.ok) {
2180
+ const data = await response.json();
2181
+ results.push({
2182
+ name: 'Discord',
2183
+ status: 'pass',
2184
+ message: `Bot: ${data.username}`,
2185
+ });
2186
+ }
2187
+ else if (response.status === 401) {
2188
+ results.push({
2189
+ name: 'Discord',
2190
+ status: 'fail',
2191
+ message: 'Invalid bot token',
2192
+ fix: 'Check token at: https://discord.com/developers/applications',
2193
+ });
2194
+ }
2195
+ else {
2196
+ results.push({
2197
+ name: 'Discord',
2198
+ status: 'warn',
2199
+ message: `API returned ${response.status}`,
2200
+ });
2201
+ }
2202
+ }
2203
+ catch {
2204
+ results.push({
2205
+ name: 'Discord',
2206
+ status: 'warn',
2207
+ message: 'Network error testing token',
2208
+ });
2209
+ }
2210
+ }
2211
+ }
2212
+ // Test OpenAI
2213
+ if (!platform || platform === 'openai') {
2214
+ const openaiKey = process.env.OPENAI_API_KEY;
2215
+ if (!openaiKey) {
2216
+ results.push({
2217
+ name: 'OpenAI',
2218
+ status: 'warn',
2219
+ message: 'Not configured (optional)',
2220
+ fix: 'Get key from: https://platform.openai.com/api-keys',
2221
+ });
2222
+ }
2223
+ else {
2224
+ try {
2225
+ const response = await fetch('https://api.openai.com/v1/models', {
2226
+ headers: { Authorization: `Bearer ${openaiKey}` },
2227
+ });
2228
+ if (response.ok) {
2229
+ results.push({ name: 'OpenAI', status: 'pass', message: 'Key valid' });
2230
+ }
2231
+ else if (response.status === 401) {
2232
+ results.push({ name: 'OpenAI', status: 'fail', message: 'Invalid API key', fix: 'Check at platform.openai.com' });
2233
+ }
2234
+ else {
2235
+ results.push({ name: 'OpenAI', status: 'warn', message: `HTTP ${response.status}` });
2236
+ }
2237
+ }
2238
+ catch {
2239
+ results.push({ name: 'OpenAI', status: 'warn', message: 'Network error' });
2240
+ }
2241
+ }
2242
+ }
2243
+ // Test Slack
2244
+ if (!platform || platform === 'slack') {
2245
+ const slackToken = process.env.SLACK_BOT_TOKEN;
2246
+ if (!slackToken) {
2247
+ results.push({
2248
+ name: 'Slack',
2249
+ status: 'warn',
2250
+ message: 'Not configured (optional)',
2251
+ fix: 'Get token from: https://api.slack.com/apps',
2252
+ });
2253
+ }
2254
+ else {
2255
+ try {
2256
+ const response = await fetch('https://slack.com/api/auth.test', {
2257
+ headers: { Authorization: `Bearer ${slackToken}` },
2258
+ });
2259
+ const data = await response.json();
2260
+ if (data.ok) {
2261
+ results.push({ name: 'Slack', status: 'pass', message: `${data.user} @ ${data.team}` });
2262
+ }
2263
+ else {
2264
+ results.push({ name: 'Slack', status: 'fail', message: data.error ?? 'Invalid token', fix: 'Check at api.slack.com/apps' });
2265
+ }
2266
+ }
2267
+ catch {
2268
+ results.push({ name: 'Slack', status: 'warn', message: 'Network error' });
2269
+ }
2270
+ }
2271
+ }
2272
+ // Display results
2273
+ const icons = { pass: '✅', warn: '⚠️ ', fail: '❌' };
2274
+ for (const result of results) {
2275
+ console.log(`${icons[result.status]} ${result.name}: ${result.message}`);
2276
+ if (result.fix) {
2277
+ console.log(` Fix: ${result.fix}`);
2278
+ }
2279
+ }
2280
+ const passed = results.filter(r => r.status === 'pass').length;
2281
+ const warned = results.filter(r => r.status === 'warn').length;
2282
+ const failed = results.filter(r => r.status === 'fail').length;
2283
+ console.log(`\nSummary: ${passed} passed, ${warned} warnings, ${failed} failed`);
2284
+ if (failed > 0) {
2285
+ console.log('\n💡 Run `clodds doctor` for full system diagnostics');
2286
+ process.exitCode = 1;
2287
+ }
2288
+ });
2289
+ }
2290
+ // =============================================================================
2291
+ // LOCALE COMMANDS
2292
+ // =============================================================================
2293
+ function createLocaleCommands(program) {
2294
+ const locale = program
2295
+ .command('locale')
2296
+ .description('Manage language/locale settings');
2297
+ locale
2298
+ .command('list')
2299
+ .description('List supported languages')
2300
+ .action(async () => {
2301
+ const { getSupportedLocales, getLocale } = await Promise.resolve().then(() => __importStar(require('../../i18n/index')));
2302
+ const current = getLocale();
2303
+ const locales = getSupportedLocales();
2304
+ console.log('\n📍 Supported Languages\n');
2305
+ for (const loc of locales) {
2306
+ const marker = loc.code === current ? ' ← current' : '';
2307
+ console.log(` ${loc.code} ${loc.nativeName.padEnd(10)} (${loc.name})${marker}`);
2308
+ }
2309
+ console.log('\nSet with: clodds locale set <code>');
2310
+ console.log('Or: CLODDS_LOCALE=<code> in .env\n');
2311
+ });
2312
+ locale
2313
+ .command('get')
2314
+ .description('Show current locale')
2315
+ .action(async () => {
2316
+ const { getLocale, getSupportedLocales } = await Promise.resolve().then(() => __importStar(require('../../i18n/index')));
2317
+ const current = getLocale();
2318
+ const info = getSupportedLocales().find(l => l.code === current);
2319
+ console.log(`\nCurrent locale: ${current} (${info?.nativeName || current})\n`);
2320
+ });
2321
+ locale
2322
+ .command('set <code>')
2323
+ .description('Set locale (e.g., en, zh, es, ja)')
2324
+ .action(async (code) => {
2325
+ const { setLocale, isLocaleSupported, getSupportedLocales } = await Promise.resolve().then(() => __importStar(require('../../i18n/index')));
2326
+ if (!isLocaleSupported(code)) {
2327
+ console.error(`\n❌ Unsupported locale: ${code}`);
2328
+ console.log('\nSupported locales:');
2329
+ for (const loc of getSupportedLocales()) {
2330
+ console.log(` ${loc.code} ${loc.nativeName}`);
2331
+ }
2332
+ process.exit(1);
2333
+ }
2334
+ // Save to config
2335
+ const configPath = (0, path_1.join)((0, os_1.homedir)(), '.clodds', 'config.json');
2336
+ let config = {};
2337
+ if ((0, fs_1.existsSync)(configPath)) {
2338
+ config = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
2339
+ }
2340
+ config.locale = code.toLowerCase();
2341
+ const configDir = (0, path_1.join)((0, os_1.homedir)(), '.clodds');
2342
+ if (!(0, fs_1.existsSync)(configDir)) {
2343
+ (0, fs_1.mkdirSync)(configDir, { recursive: true });
2344
+ }
2345
+ (0, fs_1.writeFileSync)(configPath, JSON.stringify(config, null, 2));
2346
+ setLocale(code);
2347
+ const info = getSupportedLocales().find(l => l.code === code.toLowerCase());
2348
+ console.log(`\n✅ Locale set to: ${code} (${info?.nativeName || code})\n`);
2349
+ });
2350
+ locale
2351
+ .command('test [key]')
2352
+ .description('Test translation (default: welcome.message)')
2353
+ .action(async (key) => {
2354
+ const { t, getLocale } = await Promise.resolve().then(() => __importStar(require('../../i18n/index')));
2355
+ const testKey = key || 'welcome.message';
2356
+ const result = t(testKey);
2357
+ console.log(`\nLocale: ${getLocale()}`);
2358
+ console.log(`Key: ${testKey}`);
2359
+ console.log(`Result: ${result}\n`);
2360
+ });
2361
+ }
2362
+ // =============================================================================
2363
+ // LEDGER COMMANDS
2364
+ // =============================================================================
2365
+ function createLedgerCommands(program) {
2366
+ const ledger = program
2367
+ .command('ledger')
2368
+ .description('Trade ledger - decision audit trail');
2369
+ const withDb = async (fn) => {
2370
+ const db = (0, db_1.createDatabase)();
2371
+ (0, migrations_1.createMigrationRunner)(db).migrate();
2372
+ try {
2373
+ return await fn(db);
2374
+ }
2375
+ finally {
2376
+ db.close();
2377
+ }
2378
+ };
2379
+ ledger
2380
+ .command('list [userId]')
2381
+ .description('List recent decisions')
2382
+ .option('-n, --limit <n>', 'Number of records', '20')
2383
+ .option('-c, --category <cat>', 'Filter by category (trade/copy/arbitrage/risk)')
2384
+ .option('-d, --decision <dec>', 'Filter by decision (approved/rejected/blocked)')
2385
+ .option('-p, --platform <plt>', 'Filter by platform')
2386
+ .action(async (userId, options) => {
2387
+ await withDb(async (db) => {
2388
+ const { LedgerStorage } = await Promise.resolve().then(() => __importStar(require('../../ledger/storage')));
2389
+ const storage = new LedgerStorage(db);
2390
+ storage.init();
2391
+ const uid = userId || 'default';
2392
+ const records = storage.list(uid, {
2393
+ limit: parseInt(options?.limit || '20', 10),
2394
+ category: options?.category,
2395
+ decision: options?.decision,
2396
+ platform: options?.platform,
2397
+ });
2398
+ if (records.length === 0) {
2399
+ console.log('\nNo decisions found\n');
2400
+ return;
2401
+ }
2402
+ console.log(`\n📒 Trade Ledger (${records.length} decisions)\n`);
2403
+ const { formatDecision } = await Promise.resolve().then(() => __importStar(require('../../ledger/index')));
2404
+ for (const record of records) {
2405
+ console.log(formatDecision(record));
2406
+ }
2407
+ });
2408
+ });
2409
+ ledger
2410
+ .command('stats [userId]')
2411
+ .description('Show decision statistics')
2412
+ .option('-p, --period <p>', 'Period (24h/7d/30d/90d/all)', '7d')
2413
+ .option('-c, --category <cat>', 'Filter by category')
2414
+ .action(async (userId, options) => {
2415
+ await withDb(async (db) => {
2416
+ const { LedgerStorage } = await Promise.resolve().then(() => __importStar(require('../../ledger/storage')));
2417
+ const storage = new LedgerStorage(db);
2418
+ storage.init();
2419
+ const uid = userId || 'default';
2420
+ const stats = storage.stats(uid, {
2421
+ period: options?.period,
2422
+ category: options?.category,
2423
+ });
2424
+ const { formatStats } = await Promise.resolve().then(() => __importStar(require('../../ledger/index')));
2425
+ console.log('\n' + formatStats(stats));
2426
+ });
2427
+ });
2428
+ ledger
2429
+ .command('calibration [userId]')
2430
+ .description('Show confidence calibration')
2431
+ .action(async (userId) => {
2432
+ await withDb(async (db) => {
2433
+ const { LedgerStorage } = await Promise.resolve().then(() => __importStar(require('../../ledger/storage')));
2434
+ const storage = new LedgerStorage(db);
2435
+ storage.init();
2436
+ const uid = userId || 'default';
2437
+ const cal = storage.calibration(uid);
2438
+ console.log('\n📊 Confidence Calibration\n');
2439
+ console.log(`Overall accuracy: ${cal.overallAccuracy.toFixed(1)}% (${cal.totalWithOutcome} decisions with outcome)\n`);
2440
+ if (cal.totalWithOutcome > 0) {
2441
+ console.log('By confidence bucket:');
2442
+ for (const bucket of cal.buckets) {
2443
+ if (bucket.count > 0) {
2444
+ const bar = '█'.repeat(Math.round(bucket.accuracyRate / 10));
2445
+ console.log(` ${bucket.range.padEnd(8)} ${bucket.accuracyRate.toFixed(0).padStart(3)}% ${bar} (${bucket.count} decisions)`);
2446
+ }
2447
+ }
2448
+ }
2449
+ console.log('');
2450
+ });
2451
+ });
2452
+ ledger
2453
+ .command('export [userId]')
2454
+ .description('Export decisions to file')
2455
+ .option('-f, --format <fmt>', 'Format (json/csv)', 'json')
2456
+ .option('-o, --output <file>', 'Output file')
2457
+ .action(async (userId, options) => {
2458
+ await withDb(async (db) => {
2459
+ const { LedgerStorage } = await Promise.resolve().then(() => __importStar(require('../../ledger/storage')));
2460
+ const storage = new LedgerStorage(db);
2461
+ storage.init();
2462
+ const uid = userId || 'default';
2463
+ const format = (options?.format || 'json');
2464
+ const data = storage.export(uid, format);
2465
+ const output = options?.output || `ledger-${uid}-${Date.now()}.${format}`;
2466
+ (0, fs_1.writeFileSync)(output, data);
2467
+ console.log(`\n✅ Exported to ${output}\n`);
2468
+ });
2469
+ });
2470
+ ledger
2471
+ .command('prune')
2472
+ .description('Delete old decisions')
2473
+ .option('-d, --days <n>', 'Retention days', '90')
2474
+ .option('-y, --yes', 'Skip confirmation')
2475
+ .action(async (options) => {
2476
+ const days = parseInt(options.days || '90', 10);
2477
+ if (!options.yes) {
2478
+ console.log(`\n⚠️ This will delete decisions older than ${days} days.`);
2479
+ console.log('Run with --yes to confirm\n');
2480
+ return;
2481
+ }
2482
+ await withDb(async (db) => {
2483
+ const { LedgerStorage } = await Promise.resolve().then(() => __importStar(require('../../ledger/storage')));
2484
+ const storage = new LedgerStorage(db);
2485
+ storage.init();
2486
+ const count = storage.prune(days);
2487
+ console.log(`\n🗑️ Pruned ${count} old decisions\n`);
2488
+ });
2489
+ });
2490
+ ledger
2491
+ .command('verify <id>')
2492
+ .description('Verify decision hash integrity')
2493
+ .action(async (id) => {
2494
+ await withDb(async (db) => {
2495
+ const { LedgerStorage } = await Promise.resolve().then(() => __importStar(require('../../ledger/storage')));
2496
+ const { verifyHash } = await Promise.resolve().then(() => __importStar(require('../../ledger/hash')));
2497
+ const storage = new LedgerStorage(db);
2498
+ storage.init();
2499
+ const record = storage.get(id);
2500
+ if (!record) {
2501
+ console.log(`\n❌ Decision not found: ${id}\n`);
2502
+ process.exitCode = 1;
2503
+ return;
2504
+ }
2505
+ if (!record.hash) {
2506
+ console.log(`\n⚠️ No hash stored for decision ${id.slice(0, 8)}\n`);
2507
+ console.log('Enable hashIntegrity in ledger config to store hashes.\n');
2508
+ return;
2509
+ }
2510
+ const valid = verifyHash(record, record.hash);
2511
+ if (valid) {
2512
+ console.log(`\n✅ Hash verified: ${record.hash.slice(0, 16)}...\n`);
2513
+ }
2514
+ else {
2515
+ console.log(`\n❌ Hash mismatch - record may have been tampered with\n`);
2516
+ process.exitCode = 1;
2517
+ }
2518
+ });
2519
+ });
2520
+ ledger
2521
+ .command('config')
2522
+ .description('Show ledger configuration')
2523
+ .action(async () => {
2524
+ const configPath = (0, path_1.join)((0, os_1.homedir)(), '.clodds', 'config.json');
2525
+ let ledgerConfig = {
2526
+ enabled: false,
2527
+ captureAll: false,
2528
+ hashIntegrity: false,
2529
+ retentionDays: 90,
2530
+ onchainAnchor: false,
2531
+ };
2532
+ if ((0, fs_1.existsSync)(configPath)) {
2533
+ const data = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
2534
+ ledgerConfig = { ...ledgerConfig, ...data.ledger };
2535
+ }
2536
+ console.log('\n📒 Trade Ledger Configuration\n');
2537
+ console.log(` enabled: ${ledgerConfig.enabled ? '✅' : '❌'}`);
2538
+ console.log(` captureAll: ${ledgerConfig.captureAll ? 'All tools' : 'Trading tools only'}`);
2539
+ console.log(` hashIntegrity: ${ledgerConfig.hashIntegrity ? 'SHA-256 enabled' : 'Disabled'}`);
2540
+ console.log(` retentionDays: ${ledgerConfig.retentionDays}`);
2541
+ console.log(` onchainAnchor: ${ledgerConfig.onchainAnchor ? 'Enabled' : 'Disabled'}`);
2542
+ console.log('\nEnable with: clodds config set ledger.enabled true\n');
2543
+ });
2544
+ ledger
2545
+ .command('anchor <id>')
2546
+ .description('Anchor decision hash to blockchain')
2547
+ .option('-c, --chain <chain>', 'Chain to use (solana/polygon/base)', 'solana')
2548
+ .action(async (id, options) => {
2549
+ await withDb(async (db) => {
2550
+ const { LedgerStorage } = await Promise.resolve().then(() => __importStar(require('../../ledger/storage')));
2551
+ const { createAnchorService } = await Promise.resolve().then(() => __importStar(require('../../ledger/anchor')));
2552
+ const storage = new LedgerStorage(db);
2553
+ storage.init();
2554
+ const record = storage.get(id);
2555
+ if (!record) {
2556
+ console.log(`\n❌ Decision not found: ${id}\n`);
2557
+ process.exitCode = 1;
2558
+ return;
2559
+ }
2560
+ if (!record.hash) {
2561
+ console.log(`\n⚠️ No hash stored for decision ${id.slice(0, 8)}`);
2562
+ console.log('Enable hashIntegrity in ledger config first.\n');
2563
+ return;
2564
+ }
2565
+ const chain = (options.chain || 'solana');
2566
+ console.log(`\n⏳ Anchoring to ${chain}...`);
2567
+ const anchor = createAnchorService({ chain });
2568
+ const result = await anchor.anchor(record.hash);
2569
+ if (result.success) {
2570
+ console.log(`\n✅ Anchored to ${chain}`);
2571
+ console.log(` Hash: ${record.hash.slice(0, 16)}...`);
2572
+ console.log(` Tx: ${result.txHash}\n`);
2573
+ }
2574
+ else {
2575
+ console.log(`\n❌ Anchor failed: ${result.error}\n`);
2576
+ process.exitCode = 1;
2577
+ }
2578
+ });
2579
+ });
2580
+ ledger
2581
+ .command('verify-anchor <txHash> <hash>')
2582
+ .description('Verify an onchain anchor')
2583
+ .option('-c, --chain <chain>', 'Chain to check (solana/polygon/base)', 'solana')
2584
+ .action(async (txHash, hash, options) => {
2585
+ const { verifyAnchor } = await Promise.resolve().then(() => __importStar(require('../../ledger/anchor')));
2586
+ const chain = (options.chain || 'solana');
2587
+ console.log(`\n⏳ Verifying on ${chain}...`);
2588
+ const result = await verifyAnchor(txHash, hash, chain);
2589
+ if (result.verified) {
2590
+ console.log(`\n✅ Anchor verified on ${chain}`);
2591
+ console.log(` Tx: ${txHash}`);
2592
+ console.log(` Hash: ${hash.slice(0, 16)}...\n`);
2593
+ }
2594
+ else {
2595
+ console.log(`\n❌ Verification failed: ${result.error}\n`);
2596
+ process.exitCode = 1;
2597
+ }
2598
+ });
2599
+ }
2600
+ // =============================================================================
2601
+ // BITTENSOR COMMANDS
2602
+ // =============================================================================
2603
+ function btcliExec(pythonPath, args, timeoutMs = 30_000) {
2604
+ const result = (0, child_process_1.spawnSync)(pythonPath, ['-m', 'bittensor', ...args], {
2605
+ encoding: 'utf-8',
2606
+ timeout: timeoutMs,
2607
+ });
2608
+ return {
2609
+ ok: result.status === 0,
2610
+ stdout: (result.stdout ?? '').trim(),
2611
+ stderr: (result.stderr ?? '').trim(),
2612
+ };
2613
+ }
2614
+ function detectPython() {
2615
+ for (const cmd of ['python3', 'python']) {
2616
+ const r = (0, child_process_1.spawnSync)(cmd, ['--version'], { encoding: 'utf-8', timeout: 5_000 });
2617
+ if (r.status === 0)
2618
+ return cmd;
2619
+ }
2620
+ return null;
2621
+ }
2622
+ function hasBtcli(pythonPath) {
2623
+ const r = (0, child_process_1.spawnSync)(pythonPath, ['-c', 'import bittensor; print(bittensor.__version__)'], {
2624
+ encoding: 'utf-8',
2625
+ timeout: 10_000,
2626
+ });
2627
+ return r.status === 0;
2628
+ }
2629
+ function createBittensorCommands(program) {
2630
+ const bittensor = program
2631
+ .command('bittensor')
2632
+ .alias('tao')
2633
+ .description('Bittensor subnet mining management');
2634
+ // ── setup: full onboarding wizard ──────────────────────────────────────────
2635
+ bittensor
2636
+ .command('setup')
2637
+ .description('One-command setup: installs btcli, creates wallet, configures Clodds')
2638
+ .option('--wallet-name <name>', 'Wallet name', 'default')
2639
+ .option('--skip-install', 'Skip btcli installation')
2640
+ .action(async (options) => {
2641
+ const walletName = options.walletName ?? 'default';
2642
+ const pythonEnv = process.env.BITTENSOR_PYTHON_PATH;
2643
+ console.log('\n=== Bittensor Mining Setup ===\n');
2644
+ // Step 0: Choose network
2645
+ const { createInterface } = await Promise.resolve().then(() => __importStar(require('readline')));
2646
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
2647
+ const ask = (prompt) => new Promise((resolve) => rl.question(prompt, (a) => resolve(a.trim())));
2648
+ let network;
2649
+ while (true) {
2650
+ const choice = await ask('Network? (1) mainnet - real TAO, real earnings (2) testnet - free to experiment\nChoose [1/2]: ');
2651
+ if (choice === '1' || choice.toLowerCase() === 'mainnet') {
2652
+ network = 'mainnet';
2653
+ break;
2654
+ }
2655
+ else if (choice === '2' || choice.toLowerCase() === 'testnet') {
2656
+ network = 'testnet';
2657
+ break;
2658
+ }
2659
+ console.log(' Please enter 1 or 2.\n');
2660
+ }
2661
+ rl.close();
2662
+ console.log(`\n Selected: ${network}\n`);
2663
+ // Step 1: Find Python
2664
+ console.log('[1/5] Checking Python...');
2665
+ const pythonPath = pythonEnv || detectPython();
2666
+ if (!pythonPath) {
2667
+ console.log(' Python 3 not found. Install it first:');
2668
+ console.log(' macOS: brew install python3');
2669
+ console.log(' Ubuntu: sudo apt install python3 python3-pip');
2670
+ console.log(' Windows: https://python.org/downloads\n');
2671
+ process.exitCode = 1;
2672
+ return;
2673
+ }
2674
+ const pyVer = (0, child_process_1.spawnSync)(pythonPath, ['--version'], { encoding: 'utf-8' });
2675
+ console.log(` Found: ${pyVer.stdout?.trim() || pythonPath}`);
2676
+ // Step 2: Install btcli
2677
+ console.log('\n[2/5] Checking btcli...');
2678
+ if (hasBtcli(pythonPath)) {
2679
+ const ver = (0, child_process_1.spawnSync)(pythonPath, ['-c', 'import bittensor; print(bittensor.__version__)'], { encoding: 'utf-8' });
2680
+ console.log(` Already installed: bittensor ${ver.stdout?.trim()}`);
2681
+ }
2682
+ else if (options.skipInstall) {
2683
+ console.log(' btcli not found (skipped install)');
2684
+ }
2685
+ else {
2686
+ console.log(' Installing bittensor (this takes 1-2 minutes)...');
2687
+ const install = (0, child_process_1.spawnSync)(pythonPath, ['-m', 'pip', 'install', 'bittensor', '--quiet'], {
2688
+ encoding: 'utf-8',
2689
+ timeout: 180_000,
2690
+ stdio: ['pipe', 'pipe', 'pipe'],
2691
+ });
2692
+ if (install.status === 0) {
2693
+ console.log(' Installed successfully');
2694
+ }
2695
+ else {
2696
+ console.log(` Installation failed: ${install.stderr?.slice(0, 200)}`);
2697
+ console.log(' Try manually: pip install bittensor\n');
2698
+ process.exitCode = 1;
2699
+ return;
2700
+ }
2701
+ }
2702
+ // Step 3: Create wallet
2703
+ console.log('\n[3/5] Setting up wallet...');
2704
+ const walletDir = (0, path_1.join)((0, os_1.homedir)(), '.bittensor', 'wallets', walletName);
2705
+ const coldkeyPath = (0, path_1.join)(walletDir, 'coldkey');
2706
+ if ((0, fs_1.existsSync)(coldkeyPath)) {
2707
+ console.log(` Wallet "${walletName}" already exists at ${walletDir}`);
2708
+ }
2709
+ else {
2710
+ console.log(` Creating wallet "${walletName}"...`);
2711
+ // Create coldkey
2712
+ const coldkey = btcliExec(pythonPath, [
2713
+ 'wallet', 'create',
2714
+ '--wallet.name', walletName,
2715
+ '--no_prompt',
2716
+ ], 30_000);
2717
+ if (coldkey.ok || (0, fs_1.existsSync)(coldkeyPath)) {
2718
+ console.log(' Wallet created');
2719
+ }
2720
+ else {
2721
+ // Try the newer btcli syntax
2722
+ const coldkey2 = (0, child_process_1.spawnSync)(pythonPath, ['-m', 'bittensor.cli', 'wallet', 'create', '--wallet.name', walletName, '--no_prompt'], {
2723
+ encoding: 'utf-8',
2724
+ timeout: 30_000,
2725
+ });
2726
+ if (coldkey2.status === 0 || (0, fs_1.existsSync)(coldkeyPath)) {
2727
+ console.log(' Wallet created');
2728
+ }
2729
+ else {
2730
+ console.log(' Auto-create failed. Create manually:');
2731
+ console.log(` btcli wallet create --wallet.name ${walletName}`);
2732
+ }
2733
+ }
2734
+ }
2735
+ // Show wallet address
2736
+ const overview = btcliExec(pythonPath, [
2737
+ 'wallet', 'overview',
2738
+ '--wallet.name', walletName,
2739
+ '--no_prompt',
2740
+ ], 15_000);
2741
+ const addrMatch = overview.stdout.match(/coldkey[:\s]+(\w{48})/i)
2742
+ || overview.stdout.match(/(5[A-Za-z0-9]{47})/);
2743
+ if (addrMatch) {
2744
+ console.log(` Address: ${addrMatch[1]}`);
2745
+ }
2746
+ // Step 4: Write config
2747
+ console.log('\n[4/5] Configuring Clodds...');
2748
+ const cloddsDir = (0, path_1.join)((0, os_1.homedir)(), '.clodds');
2749
+ const configPath = (0, path_1.join)(cloddsDir, 'clodds.json');
2750
+ let existingConfig = {};
2751
+ if ((0, fs_1.existsSync)(configPath)) {
2752
+ try {
2753
+ existingConfig = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
2754
+ }
2755
+ catch {
2756
+ // fresh config
2757
+ }
2758
+ }
2759
+ else {
2760
+ (0, fs_1.mkdirSync)(cloddsDir, { recursive: true });
2761
+ }
2762
+ existingConfig.bittensor = {
2763
+ enabled: true,
2764
+ network,
2765
+ coldkeyPath: (0, path_1.join)((0, os_1.homedir)(), '.bittensor', 'wallets', walletName, 'coldkey'),
2766
+ pythonPath,
2767
+ };
2768
+ (0, fs_1.writeFileSync)(configPath, JSON.stringify(existingConfig, null, 2));
2769
+ console.log(` Written to ${configPath}`);
2770
+ console.log(` Network: ${network}`);
2771
+ // Step 5: Summary
2772
+ console.log('\n[5/5] Next steps:\n');
2773
+ if (network === 'testnet') {
2774
+ console.log(' You\'re on TESTNET - free to experiment, no real TAO needed.\n');
2775
+ console.log(' Get testnet TAO:');
2776
+ console.log(' btcli wallet faucet --wallet.name default --subtensor.network test\n');
2777
+ }
2778
+ else {
2779
+ console.log(' You\'re on MAINNET - you need real TAO to register.\n');
2780
+ if (addrMatch) {
2781
+ console.log(` Fund your wallet: send TAO to ${addrMatch[1]}`);
2782
+ console.log(' Buy TAO: Binance, KuCoin, Gate.io, or MEXC\n');
2783
+ }
2784
+ }
2785
+ console.log(' Register on a subnet (Chutes SN64 recommended):');
2786
+ console.log(' clodds bittensor register 64\n');
2787
+ console.log(' Then start Clodds:');
2788
+ console.log(' clodds start\n');
2789
+ console.log(' Monitor in chat:');
2790
+ console.log(' /tao status');
2791
+ console.log(' /tao earnings\n');
2792
+ });
2793
+ // ── wallet: show / create ──────────────────────────────────────────────────
2794
+ const wallet = bittensor
2795
+ .command('wallet')
2796
+ .description('Wallet management');
2797
+ wallet
2798
+ .command('show')
2799
+ .description('Show wallet address and balance')
2800
+ .option('--name <name>', 'Wallet name', 'default')
2801
+ .action(async (options) => {
2802
+ const pythonPath = process.env.BITTENSOR_PYTHON_PATH || detectPython();
2803
+ if (!pythonPath) {
2804
+ console.log('\nPython not found. Run: clodds bittensor setup\n');
2805
+ return;
2806
+ }
2807
+ const name = options.name ?? 'default';
2808
+ console.log(`\nWallet: ${name}`);
2809
+ const overview = btcliExec(pythonPath, [
2810
+ 'wallet', 'overview',
2811
+ '--wallet.name', name,
2812
+ '--no_prompt',
2813
+ ], 15_000);
2814
+ if (overview.ok) {
2815
+ console.log(overview.stdout);
2816
+ }
2817
+ else {
2818
+ console.log(` Not found. Create: clodds bittensor setup\n`);
2819
+ }
2820
+ });
2821
+ wallet
2822
+ .command('create')
2823
+ .description('Create a new Bittensor wallet')
2824
+ .option('--name <name>', 'Wallet name', 'default')
2825
+ .action(async (options) => {
2826
+ const pythonPath = process.env.BITTENSOR_PYTHON_PATH || detectPython();
2827
+ if (!pythonPath || !hasBtcli(pythonPath)) {
2828
+ console.log('\nbtcli not found. Run: clodds bittensor setup\n');
2829
+ return;
2830
+ }
2831
+ const name = options.name ?? 'default';
2832
+ console.log(`\nCreating wallet "${name}"...`);
2833
+ const result = btcliExec(pythonPath, [
2834
+ 'wallet', 'create',
2835
+ '--wallet.name', name,
2836
+ '--no_prompt',
2837
+ ], 30_000);
2838
+ if (result.ok) {
2839
+ console.log('Wallet created successfully.');
2840
+ console.log(result.stdout);
2841
+ }
2842
+ else {
2843
+ console.log(`Failed: ${result.stderr || result.stdout}`);
2844
+ }
2845
+ console.log('');
2846
+ });
2847
+ wallet
2848
+ .command('balance')
2849
+ .description('Check TAO balance')
2850
+ .option('--name <name>', 'Wallet name', 'default')
2851
+ .action(async (options) => {
2852
+ const pythonPath = process.env.BITTENSOR_PYTHON_PATH || detectPython();
2853
+ if (!pythonPath || !hasBtcli(pythonPath)) {
2854
+ console.log('\nbtcli not found. Run: clodds bittensor setup\n');
2855
+ return;
2856
+ }
2857
+ const result = btcliExec(pythonPath, [
2858
+ 'wallet', 'balance',
2859
+ '--wallet.name', options.name ?? 'default',
2860
+ '--no_prompt',
2861
+ ], 15_000);
2862
+ console.log(result.ok ? `\n${result.stdout}\n` : `\nFailed: ${result.stderr}\n`);
2863
+ });
2864
+ // ── register: join a subnet ────────────────────────────────────────────────
2865
+ bittensor
2866
+ .command('register <subnetId>')
2867
+ .description('Register on a subnet (e.g. 64 for Chutes)')
2868
+ .option('--name <name>', 'Wallet name', 'default')
2869
+ .action(async (subnetId, options) => {
2870
+ const pythonPath = process.env.BITTENSOR_PYTHON_PATH || detectPython();
2871
+ if (!pythonPath || !hasBtcli(pythonPath)) {
2872
+ console.log('\nbtcli not found. Run: clodds bittensor setup\n');
2873
+ return;
2874
+ }
2875
+ const id = parseInt(subnetId, 10);
2876
+ if (isNaN(id)) {
2877
+ console.log('\nInvalid subnet ID. Example: clodds bittensor register 64\n');
2878
+ return;
2879
+ }
2880
+ // Read network from config
2881
+ let network = 'mainnet';
2882
+ const cfgPath = (0, path_1.join)((0, os_1.homedir)(), '.clodds', 'clodds.json');
2883
+ if ((0, fs_1.existsSync)(cfgPath)) {
2884
+ try {
2885
+ const cfg = JSON.parse((0, fs_1.readFileSync)(cfgPath, 'utf-8'));
2886
+ if (cfg.bittensor?.network)
2887
+ network = cfg.bittensor.network;
2888
+ }
2889
+ catch { }
2890
+ }
2891
+ console.log(`\nRegistering on subnet ${id} (${network})...`);
2892
+ console.log('This may cost TAO. Check your balance first: clodds bittensor wallet balance\n');
2893
+ const args = [
2894
+ 'subnet', 'register',
2895
+ '--netuid', String(id),
2896
+ '--wallet.name', options.name ?? 'default',
2897
+ '--no_prompt',
2898
+ ];
2899
+ if (network === 'testnet') {
2900
+ args.push('--subtensor.network', 'test');
2901
+ }
2902
+ const result = btcliExec(pythonPath, args, 120_000);
2903
+ if (result.ok) {
2904
+ console.log('Registered successfully!');
2905
+ console.log(result.stdout);
2906
+ }
2907
+ else {
2908
+ console.log(`Registration failed: ${result.stderr || result.stdout}`);
2909
+ }
2910
+ console.log('');
2911
+ });
2912
+ // ── status ─────────────────────────────────────────────────────────────────
2913
+ bittensor
2914
+ .command('status')
2915
+ .description('Show Bittensor mining status')
2916
+ .action(async () => {
2917
+ const { loadConfig } = await Promise.resolve().then(() => __importStar(require('../../utils/config')));
2918
+ const config = await loadConfig();
2919
+ if (!config.bittensor?.enabled) {
2920
+ console.log('\nBittensor is not enabled. Run: clodds bittensor setup\n');
2921
+ return;
2922
+ }
2923
+ console.log('\nBittensor Configuration:');
2924
+ console.log(` Network: ${config.bittensor.network ?? 'mainnet'}`);
2925
+ console.log(` Coldkey: ${config.bittensor.coldkeyPath ?? '(not set)'}`);
2926
+ console.log(` Python: ${config.bittensor.pythonPath ?? 'python3'}`);
2927
+ const subnets = config.bittensor.subnets ?? [];
2928
+ if (subnets.length > 0) {
2929
+ console.log(' Subnets:');
2930
+ for (const s of subnets) {
2931
+ console.log(` SN${s.subnetId} [${s.type}]: ${s.enabled ? 'enabled' : 'disabled'}`);
2932
+ }
2933
+ }
2934
+ else {
2935
+ console.log(' Subnets: none configured');
2936
+ }
2937
+ console.log('\nLive status (requires running gateway):');
2938
+ console.log(' curl localhost:18789/api/bittensor/status\n');
2939
+ });
2940
+ // ── earnings: query from running gateway ─────────────────────────────────
2941
+ bittensor
2942
+ .command('earnings')
2943
+ .description('Show TAO earnings (queries running gateway)')
2944
+ .option('-p, --period <period>', 'Period: hourly, daily, weekly, monthly, all', 'daily')
2945
+ .option('--port <port>', 'Gateway port', '18789')
2946
+ .action(async (options) => {
2947
+ const port = options.port ?? '18789';
2948
+ const period = options.period ?? 'daily';
2949
+ try {
2950
+ const token = process.env.CLODDS_TOKEN;
2951
+ const headers = {};
2952
+ if (token)
2953
+ headers['Authorization'] = `Bearer ${token}`;
2954
+ const r = await fetch(`http://127.0.0.1:${port}/api/bittensor/earnings?period=${period}`, { headers });
2955
+ if (!r.ok) {
2956
+ console.log(`\nGateway returned ${r.status}. Is Clodds running? (clodds start)\n`);
2957
+ return;
2958
+ }
2959
+ const body = await r.json();
2960
+ const data = body.data ?? [];
2961
+ if (data.length === 0) {
2962
+ console.log(`\nNo ${period} earnings recorded yet.\n`);
2963
+ return;
2964
+ }
2965
+ const totalTao = data.reduce((s, e) => s + e.taoEarned, 0);
2966
+ const totalUsd = data.reduce((s, e) => s + e.usdEarned, 0);
2967
+ console.log(`\n${period.charAt(0).toUpperCase() + period.slice(1)} Earnings:`);
2968
+ console.log(` TAO: ${totalTao.toFixed(4)}`);
2969
+ console.log(` USD: $${totalUsd.toFixed(2)}`);
2970
+ console.log(` Records: ${data.length}\n`);
2971
+ }
2972
+ catch {
2973
+ console.log('\nCould not reach gateway. Is Clodds running? (clodds start)\n');
2974
+ }
2975
+ });
2976
+ // ── miners: query from running gateway ───────────────────────────────────
2977
+ bittensor
2978
+ .command('miners')
2979
+ .description('Show registered miner statuses (queries running gateway)')
2980
+ .option('--port <port>', 'Gateway port', '18789')
2981
+ .action(async (options) => {
2982
+ const port = options.port ?? '18789';
2983
+ try {
2984
+ const token = process.env.CLODDS_TOKEN;
2985
+ const headers = {};
2986
+ if (token)
2987
+ headers['Authorization'] = `Bearer ${token}`;
2988
+ const r = await fetch(`http://127.0.0.1:${port}/api/bittensor/miners`, { headers });
2989
+ if (!r.ok) {
2990
+ console.log(`\nGateway returned ${r.status}. Is Clodds running? (clodds start)\n`);
2991
+ return;
2992
+ }
2993
+ const body = await r.json();
2994
+ const data = body.data ?? [];
2995
+ if (data.length === 0) {
2996
+ console.log('\nNo miners registered.\n');
2997
+ return;
2998
+ }
2999
+ console.log('\nRegistered Miners:');
3000
+ for (const m of data) {
3001
+ console.log(` SN${m.subnetId} UID${m.uid}: trust=${m.trust.toFixed(3)} incentive=${m.incentive.toFixed(3)} emission=${m.emission.toFixed(6)} rank=${m.rank} ${m.active ? 'ACTIVE' : 'OFFLINE'}`);
3002
+ }
3003
+ console.log('');
3004
+ }
3005
+ catch {
3006
+ console.log('\nCould not reach gateway. Is Clodds running? (clodds start)\n');
3007
+ }
3008
+ });
3009
+ // ── subnets: query from running gateway ──────────────────────────────────
3010
+ bittensor
3011
+ .command('subnets')
3012
+ .description('List available Bittensor subnets (queries running gateway)')
3013
+ .option('--port <port>', 'Gateway port', '18789')
3014
+ .action(async (options) => {
3015
+ const port = options.port ?? '18789';
3016
+ try {
3017
+ const token = process.env.CLODDS_TOKEN;
3018
+ const headers = {};
3019
+ if (token)
3020
+ headers['Authorization'] = `Bearer ${token}`;
3021
+ const r = await fetch(`http://127.0.0.1:${port}/api/bittensor/subnets`, { headers });
3022
+ if (!r.ok) {
3023
+ console.log(`\nGateway returned ${r.status}. Is Clodds running? (clodds start)\n`);
3024
+ return;
3025
+ }
3026
+ const body = await r.json();
3027
+ const data = body.data ?? [];
3028
+ if (data.length === 0) {
3029
+ console.log('\nCould not fetch subnets. Check connection.\n');
3030
+ return;
3031
+ }
3032
+ console.log('\nAvailable Subnets:');
3033
+ for (const s of data.slice(0, 30)) {
3034
+ console.log(` SN${s.netuid} (${s.name}): ${s.minerCount} miners, reg: ${s.registrationCost.toFixed(4)} TAO`);
3035
+ }
3036
+ if (data.length > 30)
3037
+ console.log(` ... and ${data.length - 30} more`);
3038
+ console.log('');
3039
+ }
3040
+ catch {
3041
+ console.log('\nCould not reach gateway. Is Clodds running? (clodds start)\n');
3042
+ }
3043
+ });
3044
+ // ── check: dependency verification ─────────────────────────────────────────
3045
+ bittensor
3046
+ .command('check')
3047
+ .description('Verify all dependencies are installed')
3048
+ .action(() => {
3049
+ console.log('\n=== Bittensor Dependency Check ===\n');
3050
+ // Python
3051
+ const pythonPath = process.env.BITTENSOR_PYTHON_PATH || detectPython();
3052
+ if (pythonPath) {
3053
+ const ver = (0, child_process_1.spawnSync)(pythonPath, ['--version'], { encoding: 'utf-8' });
3054
+ console.log(` Python: ${ver.stdout?.trim()} (${pythonPath})`);
3055
+ }
3056
+ else {
3057
+ console.log(' Python: NOT FOUND');
3058
+ }
3059
+ // btcli
3060
+ if (pythonPath && hasBtcli(pythonPath)) {
3061
+ const ver = (0, child_process_1.spawnSync)(pythonPath, ['-c', 'import bittensor; print(bittensor.__version__)'], { encoding: 'utf-8' });
3062
+ console.log(` bittensor: ${ver.stdout?.trim()}`);
3063
+ }
3064
+ else {
3065
+ console.log(' bittensor: NOT INSTALLED');
3066
+ }
3067
+ // Wallet
3068
+ const walletDir = (0, path_1.join)((0, os_1.homedir)(), '.bittensor', 'wallets', 'default');
3069
+ console.log(` Wallet: ${(0, fs_1.existsSync)(walletDir) ? 'found' : 'not found'} (${walletDir})`);
3070
+ // @polkadot/api
3071
+ try {
3072
+ require.resolve('@polkadot/api');
3073
+ console.log(' @polkadot/api: installed');
3074
+ }
3075
+ catch {
3076
+ console.log(' @polkadot/api: NOT INSTALLED');
3077
+ }
3078
+ // Config
3079
+ const configPath = (0, path_1.join)((0, os_1.homedir)(), '.clodds', 'clodds.json');
3080
+ if ((0, fs_1.existsSync)(configPath)) {
3081
+ try {
3082
+ const cfg = JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8'));
3083
+ console.log(` Config: ${cfg.bittensor?.enabled ? 'enabled' : 'disabled'} (${configPath})`);
3084
+ }
3085
+ catch {
3086
+ console.log(` Config: error reading (${configPath})`);
3087
+ }
3088
+ }
3089
+ else {
3090
+ console.log(' Config: not found');
3091
+ }
3092
+ console.log('\nIf anything is missing, run: clodds bittensor setup\n');
3093
+ });
3094
+ }
3095
+ // =============================================================================
3096
+ // DOCTOR COMMAND - comprehensive system health check
3097
+ // =============================================================================
3098
+ function createDoctorCommand(program) {
3099
+ program
3100
+ .command('doctor')
3101
+ .description('Run comprehensive system health checks')
3102
+ .option('--verbose', 'Show detailed output')
3103
+ .action(async (options) => {
3104
+ const verbose = !!options.verbose;
3105
+ console.log('\n=== Clodds System Doctor ===\n');
3106
+ const results = [];
3107
+ // ── 1. Core: Config + DB ─────────────────────────────────────────────
3108
+ console.log('Checking core...');
3109
+ const configPath = (0, path_1.join)((0, os_1.homedir)(), '.clodds', 'clodds.json');
3110
+ if ((0, fs_1.existsSync)(configPath)) {
3111
+ results.push({ name: 'Config file', status: 'pass', message: configPath });
3112
+ }
3113
+ else {
3114
+ results.push({ name: 'Config file', status: 'warn', message: 'Not found', fix: 'Run: clodds onboard' });
3115
+ }
3116
+ const envPath = (0, path_1.join)((0, os_1.homedir)(), '.clodds', '.env');
3117
+ if ((0, fs_1.existsSync)(envPath)) {
3118
+ results.push({ name: '.env file', status: 'pass', message: envPath });
3119
+ }
3120
+ else {
3121
+ results.push({ name: '.env file', status: 'warn', message: 'Not found (using env vars only)' });
3122
+ }
3123
+ try {
3124
+ const db = (0, db_1.createDatabase)();
3125
+ const runner = (0, migrations_1.createMigrationRunner)(db);
3126
+ runner.migrate();
3127
+ results.push({ name: 'Database', status: 'pass', message: 'SQLite OK, migrations applied' });
3128
+ }
3129
+ catch (e) {
3130
+ results.push({ name: 'Database', status: 'fail', message: `Error: ${e.message}` });
3131
+ }
3132
+ // ── 2. AI Providers ──────────────────────────────────────────────────
3133
+ console.log('Checking AI providers...');
3134
+ const anthropicKey = process.env.ANTHROPIC_API_KEY;
3135
+ if (!anthropicKey) {
3136
+ results.push({ name: 'Anthropic', status: 'fail', message: 'ANTHROPIC_API_KEY not set', fix: 'https://console.anthropic.com' });
3137
+ }
3138
+ else {
3139
+ try {
3140
+ const r = await fetch('https://api.anthropic.com/v1/messages', {
3141
+ method: 'POST',
3142
+ headers: { 'Content-Type': 'application/json', 'x-api-key': anthropicKey, 'anthropic-version': '2023-06-01' },
3143
+ body: JSON.stringify({ model: 'claude-3-haiku-20240307', max_tokens: 1, messages: [{ role: 'user', content: 'hi' }] }),
3144
+ });
3145
+ if (r.ok || r.status === 429) {
3146
+ results.push({ name: 'Anthropic', status: 'pass', message: r.ok ? 'Key valid' : 'Key valid (rate limited)' });
3147
+ }
3148
+ else {
3149
+ results.push({ name: 'Anthropic', status: 'fail', message: `HTTP ${r.status}`, fix: 'Check key at console.anthropic.com' });
3150
+ }
3151
+ }
3152
+ catch (e) {
3153
+ results.push({ name: 'Anthropic', status: 'warn', message: `Network error: ${e.message}` });
3154
+ }
3155
+ }
3156
+ const openaiKey = process.env.OPENAI_API_KEY;
3157
+ if (openaiKey) {
3158
+ try {
3159
+ const r = await fetch('https://api.openai.com/v1/models', {
3160
+ headers: { Authorization: `Bearer ${openaiKey}` },
3161
+ });
3162
+ results.push({
3163
+ name: 'OpenAI',
3164
+ status: r.ok || r.status === 429 ? 'pass' : 'fail',
3165
+ message: r.ok ? 'Key valid' : `HTTP ${r.status}`,
3166
+ fix: r.ok ? undefined : 'Check key at platform.openai.com',
3167
+ });
3168
+ }
3169
+ catch (e) {
3170
+ results.push({ name: 'OpenAI', status: 'warn', message: `Network error: ${e.message}` });
3171
+ }
3172
+ }
3173
+ else if (verbose) {
3174
+ results.push({ name: 'OpenAI', status: 'warn', message: 'Not configured (optional)' });
3175
+ }
3176
+ // ── 3. Messaging Channels ────────────────────────────────────────────
3177
+ console.log('Checking channels...');
3178
+ // Telegram
3179
+ const tgToken = process.env.TELEGRAM_BOT_TOKEN;
3180
+ if (tgToken) {
3181
+ try {
3182
+ const r = await fetch(`https://api.telegram.org/bot${tgToken}/getMe`);
3183
+ const d = await r.json();
3184
+ results.push({
3185
+ name: 'Telegram',
3186
+ status: d.ok ? 'pass' : 'fail',
3187
+ message: d.ok ? `@${d.result?.username}` : 'Invalid token',
3188
+ fix: d.ok ? undefined : 'Get token from @BotFather',
3189
+ });
3190
+ }
3191
+ catch {
3192
+ results.push({ name: 'Telegram', status: 'warn', message: 'Network error' });
3193
+ }
3194
+ }
3195
+ else if (verbose) {
3196
+ results.push({ name: 'Telegram', status: 'warn', message: 'Not configured' });
3197
+ }
3198
+ // Discord
3199
+ const dcToken = process.env.DISCORD_BOT_TOKEN;
3200
+ if (dcToken) {
3201
+ try {
3202
+ const r = await fetch('https://discord.com/api/v10/users/@me', {
3203
+ headers: { Authorization: `Bot ${dcToken}` },
3204
+ });
3205
+ if (r.ok) {
3206
+ const d = await r.json();
3207
+ results.push({ name: 'Discord', status: 'pass', message: `Bot: ${d.username}` });
3208
+ }
3209
+ else {
3210
+ results.push({ name: 'Discord', status: 'fail', message: `HTTP ${r.status}`, fix: 'Check token at discord.com/developers' });
3211
+ }
3212
+ }
3213
+ catch {
3214
+ results.push({ name: 'Discord', status: 'warn', message: 'Network error' });
3215
+ }
3216
+ }
3217
+ else if (verbose) {
3218
+ results.push({ name: 'Discord', status: 'warn', message: 'Not configured' });
3219
+ }
3220
+ // Slack
3221
+ const slackToken = process.env.SLACK_BOT_TOKEN;
3222
+ if (slackToken) {
3223
+ try {
3224
+ const r = await fetch('https://slack.com/api/auth.test', {
3225
+ headers: { Authorization: `Bearer ${slackToken}` },
3226
+ });
3227
+ const d = await r.json();
3228
+ results.push({
3229
+ name: 'Slack',
3230
+ status: d.ok ? 'pass' : 'fail',
3231
+ message: d.ok ? `${d.user} @ ${d.team}` : (d.error ?? 'Invalid token'),
3232
+ fix: d.ok ? undefined : 'Check token at api.slack.com/apps',
3233
+ });
3234
+ }
3235
+ catch {
3236
+ results.push({ name: 'Slack', status: 'warn', message: 'Network error' });
3237
+ }
3238
+ }
3239
+ else if (verbose) {
3240
+ results.push({ name: 'Slack', status: 'warn', message: 'Not configured' });
3241
+ }
3242
+ // WhatsApp - check auth dir exists
3243
+ const waAuthDir = (0, path_1.join)(process.cwd(), '.whatsapp-auth');
3244
+ const waConfigAuthDir = (() => {
3245
+ try {
3246
+ const cfg = (0, fs_1.existsSync)(configPath) ? JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8')) : {};
3247
+ return cfg.channels?.whatsapp?.authDir;
3248
+ }
3249
+ catch {
3250
+ return undefined;
3251
+ }
3252
+ })();
3253
+ const waDir = waConfigAuthDir || waAuthDir;
3254
+ if ((0, fs_1.existsSync)(waDir)) {
3255
+ results.push({ name: 'WhatsApp', status: 'pass', message: `Auth at ${waDir}` });
3256
+ }
3257
+ else if (verbose) {
3258
+ results.push({ name: 'WhatsApp', status: 'warn', message: 'No auth session', fix: 'Run: clodds whatsapp setup' });
3259
+ }
3260
+ // ── 4. Trading Platforms ─────────────────────────────────────────────
3261
+ console.log('Checking trading platforms...');
3262
+ const polyKey = process.env.POLY_API_KEY;
3263
+ const polySecret = process.env.POLY_API_SECRET;
3264
+ const polyPass = process.env.POLY_API_PASSPHRASE;
3265
+ if (polyKey && polySecret && polyPass) {
3266
+ try {
3267
+ const r = await fetch('https://clob.polymarket.com/markets?limit=1');
3268
+ results.push({
3269
+ name: 'Polymarket',
3270
+ status: r.ok ? 'pass' : 'warn',
3271
+ message: r.ok ? 'API reachable, credentials configured' : `API returned ${r.status}`,
3272
+ });
3273
+ }
3274
+ catch {
3275
+ results.push({ name: 'Polymarket', status: 'warn', message: 'Network error' });
3276
+ }
3277
+ if (!process.env.POLY_PRIVATE_KEY) {
3278
+ results.push({ name: 'Polymarket (trade)', status: 'warn', message: 'POLY_PRIVATE_KEY not set — read-only mode' });
3279
+ }
3280
+ }
3281
+ else if (verbose) {
3282
+ results.push({ name: 'Polymarket', status: 'warn', message: 'Not configured' });
3283
+ }
3284
+ const kalshiKey = process.env.KALSHI_API_KEY;
3285
+ if (kalshiKey) {
3286
+ results.push({
3287
+ name: 'Kalshi',
3288
+ status: process.env.KALSHI_API_SECRET ? 'pass' : 'fail',
3289
+ message: process.env.KALSHI_API_SECRET ? 'API key + secret configured' : 'Missing KALSHI_API_SECRET',
3290
+ });
3291
+ }
3292
+ else if (verbose) {
3293
+ results.push({ name: 'Kalshi', status: 'warn', message: 'Not configured' });
3294
+ }
3295
+ // ── 5. External Services ─────────────────────────────────────────────
3296
+ console.log('Checking services...');
3297
+ const redisHost = process.env.REDIS_HOST;
3298
+ if (redisHost) {
3299
+ results.push({ name: 'Redis', status: 'warn', message: `Configured: ${redisHost} (not tested — requires connection)` });
3300
+ }
3301
+ else if (verbose) {
3302
+ results.push({ name: 'Redis', status: 'warn', message: 'Not configured (optional — used for execution queue)' });
3303
+ }
3304
+ const pgUrl = process.env.DATABASE_URL;
3305
+ if (pgUrl) {
3306
+ results.push({ name: 'PostgreSQL', status: 'warn', message: 'DATABASE_URL set (not tested — requires connection)' });
3307
+ }
3308
+ else if (verbose) {
3309
+ results.push({ name: 'PostgreSQL', status: 'warn', message: 'Not configured (optional — for tick recording)' });
3310
+ }
3311
+ // ── 6. Bittensor ────────────────────────────────────────────────────
3312
+ let btEnabled = false;
3313
+ try {
3314
+ const cfg = (0, fs_1.existsSync)(configPath) ? JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8')) : {};
3315
+ btEnabled = cfg.bittensor?.enabled === true;
3316
+ }
3317
+ catch { }
3318
+ if (btEnabled || process.env.BITTENSOR_ENABLED === 'true') {
3319
+ console.log('Checking Bittensor...');
3320
+ const py = process.env.BITTENSOR_PYTHON_PATH || detectPython();
3321
+ if (py) {
3322
+ results.push({ name: 'Python', status: 'pass', message: py });
3323
+ if (hasBtcli(py)) {
3324
+ results.push({ name: 'btcli', status: 'pass', message: 'Installed' });
3325
+ }
3326
+ else {
3327
+ results.push({ name: 'btcli', status: 'fail', message: 'Not installed', fix: 'Run: clodds bittensor setup' });
3328
+ }
3329
+ }
3330
+ else {
3331
+ results.push({ name: 'Python', status: 'fail', message: 'Not found', fix: 'Install Python 3' });
3332
+ }
3333
+ const walletDir = (0, path_1.join)((0, os_1.homedir)(), '.bittensor', 'wallets', 'default');
3334
+ results.push({
3335
+ name: 'Bittensor wallet',
3336
+ status: (0, fs_1.existsSync)(walletDir) ? 'pass' : 'fail',
3337
+ message: (0, fs_1.existsSync)(walletDir) ? walletDir : 'Not found',
3338
+ fix: (0, fs_1.existsSync)(walletDir) ? undefined : 'Run: clodds bittensor setup',
3339
+ });
3340
+ }
3341
+ else if (verbose) {
3342
+ results.push({ name: 'Bittensor', status: 'warn', message: 'Not enabled' });
3343
+ }
3344
+ // ── 7. Features Summary ──────────────────────────────────────────────
3345
+ if (verbose) {
3346
+ console.log('Checking features...');
3347
+ const features = [
3348
+ { name: 'Paper Trading', enabled: process.env.PAPER_TRADING === 'true', envVar: 'PAPER_TRADING' },
3349
+ { name: 'Tick Recording', enabled: !!process.env.TICK_DB_URL, envVar: 'TICK_DB_URL' },
3350
+ { name: 'x402 Payments', enabled: process.env.X402_ENABLED === 'true', envVar: 'X402_ENABLED' },
3351
+ { name: 'Copy Trading', enabled: !!process.env.WHALE_TRACKER_WALLETS, envVar: 'WHALE_TRACKER_WALLETS' },
3352
+ { name: 'News Feed', enabled: !!process.env.TWITTER_BEARER_TOKEN, envVar: 'TWITTER_BEARER_TOKEN' },
3353
+ { name: 'Execution Queue', enabled: !!process.env.REDIS_HOST, envVar: 'REDIS_HOST' },
3354
+ { name: 'Cron Jobs', enabled: process.env.CRON_ENABLED === 'true', envVar: 'CRON_ENABLED' },
3355
+ { name: 'Bittensor Mining', enabled: btEnabled || process.env.BITTENSOR_ENABLED === 'true', envVar: 'BITTENSOR_ENABLED' },
3356
+ ];
3357
+ for (const f of features) {
3358
+ results.push({
3359
+ name: f.name,
3360
+ status: f.enabled ? 'pass' : 'warn',
3361
+ message: f.enabled ? 'Enabled' : `Disabled (set ${f.envVar} to enable)`,
3362
+ });
3363
+ }
3364
+ }
3365
+ // ── Display ──────────────────────────────────────────────────────────
3366
+ console.log('');
3367
+ const icons = { pass: '\x1b[32m✓\x1b[0m', warn: '\x1b[33m!\x1b[0m', fail: '\x1b[31m✗\x1b[0m' };
3368
+ for (const r of results) {
3369
+ console.log(` ${icons[r.status]} ${r.name}: ${r.message}`);
3370
+ if (r.fix) {
3371
+ console.log(` Fix: ${r.fix}`);
3372
+ }
3373
+ }
3374
+ const passed = results.filter(r => r.status === 'pass').length;
3375
+ const warned = results.filter(r => r.status === 'warn').length;
3376
+ const failed = results.filter(r => r.status === 'fail').length;
3377
+ console.log(`\n ${passed} passed, ${warned} warnings, ${failed} failed`);
3378
+ if (failed > 0) {
3379
+ console.log('\n Fix the failures above and run `clodds doctor` again.');
3380
+ process.exitCode = 1;
3381
+ }
3382
+ else if (warned > 0) {
3383
+ console.log('\n Warnings are optional — fix them if you need those features.');
3384
+ }
3385
+ else {
3386
+ console.log('\n Everything looks good!');
3387
+ }
3388
+ console.log(`\n Tip: Run \`clodds doctor --verbose\` to see all features and optional services.\n`);
3389
+ });
3390
+ }
3391
+ // =============================================================================
3392
+ // ONBOARD COMMAND - interactive setup wizard
3393
+ // =============================================================================
3394
+ function createOnboardCommand(program) {
3395
+ program
3396
+ .command('onboard')
3397
+ .alias('setup')
3398
+ .description('Interactive setup wizard — get running in 60 seconds')
3399
+ .option('--api-key <key>', 'Anthropic API key (skip prompt)')
3400
+ .option('--channel <name>', 'Channel to configure (telegram, discord, slack, webchat)')
3401
+ .option('--no-start', 'Skip the "start now?" prompt')
3402
+ .action(async (options) => {
3403
+ const { createInterface } = await Promise.resolve().then(() => __importStar(require('readline')));
3404
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
3405
+ const ask = (prompt) => new Promise((resolve) => rl.question(prompt, (a) => resolve(a.trim())));
3406
+ // ANSI helpers
3407
+ const bold = (s) => `\x1b[1m${s}\x1b[0m`;
3408
+ const dim = (s) => `\x1b[2m${s}\x1b[0m`;
3409
+ const green = (s) => `\x1b[32m${s}\x1b[0m`;
3410
+ const cyan = (s) => `\x1b[36m${s}\x1b[0m`;
3411
+ const yellow = (s) => `\x1b[33m${s}\x1b[0m`;
3412
+ const red = (s) => `\x1b[31m${s}\x1b[0m`;
3413
+ const magenta = (s) => `\x1b[35m${s}\x1b[0m`;
3414
+ const bgCyan = (s) => `\x1b[46m\x1b[30m${s}\x1b[0m`;
3415
+ const cloddsDir = (0, path_1.join)((0, os_1.homedir)(), '.clodds');
3416
+ const envPath = (0, path_1.join)(cloddsDir, '.env');
3417
+ const configPath = (0, path_1.join)(cloddsDir, 'clodds.json');
3418
+ // Track what we'll write
3419
+ const envVars = {};
3420
+ const configObj = {};
3421
+ // Load existing config if present
3422
+ if ((0, fs_1.existsSync)(configPath)) {
3423
+ try {
3424
+ Object.assign(configObj, JSON.parse((0, fs_1.readFileSync)(configPath, 'utf-8')));
3425
+ }
3426
+ catch { /* fresh */ }
3427
+ }
3428
+ // Load existing .env if present
3429
+ if ((0, fs_1.existsSync)(envPath)) {
3430
+ try {
3431
+ const lines = (0, fs_1.readFileSync)(envPath, 'utf-8').split('\n');
3432
+ for (const line of lines) {
3433
+ const match = line.match(/^([A-Z_]+)=(.+)$/);
3434
+ if (match)
3435
+ envVars[match[1]] = match[2];
3436
+ }
3437
+ }
3438
+ catch { /* fresh */ }
3439
+ }
3440
+ // ═══════════════════════════════════════════════════════════════════
3441
+ // WELCOME
3442
+ // ═══════════════════════════════════════════════════════════════════
3443
+ const figlet = await Promise.resolve().then(() => __importStar(require('figlet')));
3444
+ const banner = figlet.default.textSync('Clodds', { font: 'ANSI Shadow' });
3445
+ console.log('');
3446
+ console.log(` ${cyan('\u2584\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584')}`);
3447
+ console.log(` ${cyan('\u2584\u2588\u2588')}${magenta('\u2580')} ${magenta('\u2580')}${cyan('\u2588\u2588\u2584')}`);
3448
+ console.log(` ${cyan('\u2588\u2588\u2588')} ${magenta('\u2726')} ${magenta('\u2726')} ${cyan('\u2588\u2588\u2588')}`);
3449
+ console.log(` ${cyan('\u2588\u2588\u2588')} ${magenta('\u25c8')} ${cyan('\u2588\u2588\u2588')}`);
3450
+ console.log(` ${cyan('\u2580\u2588\u2588')}${magenta('\u2584')} ${magenta('\u2584')}${cyan('\u2588\u2588\u2580')}`);
3451
+ console.log(` ${cyan('\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580')}`);
3452
+ console.log(` ${yellow('\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557')}`);
3453
+ console.log(` ${yellow('\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D')}`);
3454
+ console.log('');
3455
+ for (const line of banner.split('\n')) {
3456
+ if (line.trim())
3457
+ console.log(` ${magenta(line)}`);
3458
+ }
3459
+ console.log('');
3460
+ console.log(` ${bold('AI Trading Terminal')} ${dim('for prediction markets, crypto & futures')}`);
3461
+ console.log(` ${dim('10 markets \u00b7 22 channels \u00b7 110 skills')}`);
3462
+ console.log('');
3463
+ console.log(` ${dim('='.repeat(56))}`);
3464
+ console.log('');
3465
+ // ═══════════════════════════════════════════════════════════════════
3466
+ // STEP 1: API KEY
3467
+ // ═══════════════════════════════════════════════════════════════════
3468
+ console.log(` ${bgCyan(' 1 ')} ${bold('Anthropic API Key')}`);
3469
+ console.log(` ${dim('Powers the Claude AI brain. Get one free at:')}`);
3470
+ console.log(` ${cyan('https://console.anthropic.com')}`);
3471
+ console.log('');
3472
+ let apiKey = options.apiKey || envVars.ANTHROPIC_API_KEY || process.env.ANTHROPIC_API_KEY || '';
3473
+ const isPlaceholder = !apiKey || apiKey === 'sk-ant-...' || apiKey.length < 20;
3474
+ if (isPlaceholder) {
3475
+ apiKey = await ask(` ${bold('Paste API key:')} `);
3476
+ if (!apiKey || apiKey.length < 10) {
3477
+ console.log('');
3478
+ console.log(` ${red('No key provided.')} Add it later:`);
3479
+ console.log(` ${dim('echo "ANTHROPIC_API_KEY=sk-ant-..." >> ~/.clodds/.env')}`);
3480
+ console.log('');
3481
+ rl.close();
3482
+ return;
3483
+ }
3484
+ }
3485
+ else {
3486
+ const masked = apiKey.slice(0, 10) + '...' + apiKey.slice(-4);
3487
+ console.log(` ${dim('Found:')} ${masked}`);
3488
+ const reuse = await ask(` ${bold('Use this key?')} ${dim('[Y/n]')} `);
3489
+ if (reuse.toLowerCase() === 'n') {
3490
+ apiKey = await ask(` ${bold('Paste new key:')} `);
3491
+ }
3492
+ }
3493
+ envVars.ANTHROPIC_API_KEY = apiKey;
3494
+ // Validate
3495
+ process.stdout.write(` ${dim('Validating...')}`);
3496
+ try {
3497
+ const r = await fetch('https://api.anthropic.com/v1/messages', {
3498
+ method: 'POST',
3499
+ headers: {
3500
+ 'Content-Type': 'application/json',
3501
+ 'x-api-key': apiKey,
3502
+ 'anthropic-version': '2023-06-01',
3503
+ },
3504
+ body: '{}',
3505
+ });
3506
+ // 401 = bad key. Anything else (400, 429, etc.) = key authenticated fine.
3507
+ if (r.status === 401) {
3508
+ console.log(`\r ${yellow('Invalid key')} — continuing anyway `);
3509
+ }
3510
+ else {
3511
+ console.log(`\r ${green('Valid')} `);
3512
+ }
3513
+ }
3514
+ catch {
3515
+ console.log(`\r ${yellow('Offline')} — skipped validation `);
3516
+ }
3517
+ console.log('');
3518
+ // ═══════════════════════════════════════════════════════════════════
3519
+ // STEP 2: CHANNEL
3520
+ // ═══════════════════════════════════════════════════════════════════
3521
+ console.log(` ${bgCyan(' 2 ')} ${bold('Messaging Channel')}`);
3522
+ console.log(` ${dim('WebChat is built-in at')} ${cyan('http://localhost:18789/webchat')}`);
3523
+ console.log(` ${dim('Optionally connect a platform:')}`);
3524
+ console.log('');
3525
+ console.log(` ${bold('1')} WebChat only ${dim('zero config, works immediately')}`);
3526
+ console.log(` ${bold('2')} Telegram ${green('recommended')} ${dim('— easiest setup')}`);
3527
+ console.log(` ${bold('3')} Discord ${dim('bot token from discord.com/developers')}`);
3528
+ console.log(` ${bold('4')} Slack ${dim('bot + app tokens from api.slack.com')}`);
3529
+ console.log('');
3530
+ let channelChoice = options.channel || '';
3531
+ if (!channelChoice) {
3532
+ const choice = await ask(` ${bold('Choose')} ${dim('[1-4, default 1]:')} `);
3533
+ const map = { '1': 'webchat', '2': 'telegram', '3': 'discord', '4': 'slack', '': 'webchat' };
3534
+ channelChoice = map[choice] || choice.toLowerCase();
3535
+ }
3536
+ console.log('');
3537
+ // ═══════════════════════════════════════════════════════════════════
3538
+ // STEP 3: CHANNEL TOKEN
3539
+ // ═══════════════════════════════════════════════════════════════════
3540
+ if (channelChoice === 'telegram') {
3541
+ console.log(` ${bgCyan(' 3 ')} ${bold('Telegram Setup')}`);
3542
+ console.log(` ${dim('1.')} Open Telegram, message ${cyan('@BotFather')}`);
3543
+ console.log(` ${dim('2.')} Send ${bold('/newbot')} and follow the prompts`);
3544
+ console.log(` ${dim('3.')} Copy the token it gives you`);
3545
+ console.log('');
3546
+ let token = envVars.TELEGRAM_BOT_TOKEN || process.env.TELEGRAM_BOT_TOKEN || '';
3547
+ if (token) {
3548
+ console.log(` ${dim('Found:')} ${token.slice(0, 8)}...`);
3549
+ const reuse = await ask(` ${bold('Use this token?')} ${dim('[Y/n]')} `);
3550
+ if (reuse.toLowerCase() === 'n')
3551
+ token = '';
3552
+ }
3553
+ if (!token) {
3554
+ token = await ask(` ${bold('Bot token:')} `);
3555
+ }
3556
+ if (token) {
3557
+ envVars.TELEGRAM_BOT_TOKEN = token;
3558
+ configObj.channels = { ...(configObj.channels || {}), telegram: { enabled: true } };
3559
+ // Validate token
3560
+ process.stdout.write(` ${dim('Validating...')}`);
3561
+ try {
3562
+ const r = await fetch(`https://api.telegram.org/bot${token}/getMe`);
3563
+ const d = await r.json();
3564
+ if (d.ok) {
3565
+ console.log(`\r ${green(`@${d.result?.username}`)} connected `);
3566
+ }
3567
+ else {
3568
+ console.log(`\r ${yellow('Token may be invalid')} — continuing `);
3569
+ }
3570
+ }
3571
+ catch {
3572
+ console.log(`\r ${yellow('Offline')} — skipped validation `);
3573
+ }
3574
+ }
3575
+ else {
3576
+ console.log(` ${dim('Skipped. Add later: TELEGRAM_BOT_TOKEN=... in ~/.clodds/.env')}`);
3577
+ }
3578
+ }
3579
+ else if (channelChoice === 'discord') {
3580
+ console.log(` ${bgCyan(' 3 ')} ${bold('Discord Setup')}`);
3581
+ console.log(` ${dim('1.')} Go to ${cyan('https://discord.com/developers/applications')}`);
3582
+ console.log(` ${dim('2.')} Create app > Bot > Reset Token > Copy`);
3583
+ console.log('');
3584
+ let token = envVars.DISCORD_BOT_TOKEN || process.env.DISCORD_BOT_TOKEN || '';
3585
+ if (token) {
3586
+ console.log(` ${dim('Found:')} ${token.slice(0, 8)}...`);
3587
+ const reuse = await ask(` ${bold('Use this token?')} ${dim('[Y/n]')} `);
3588
+ if (reuse.toLowerCase() === 'n')
3589
+ token = '';
3590
+ }
3591
+ if (!token) {
3592
+ token = await ask(` ${bold('Bot token:')} `);
3593
+ }
3594
+ if (token) {
3595
+ envVars.DISCORD_BOT_TOKEN = token;
3596
+ const appId = await ask(` ${bold('Application ID')} ${dim('(optional, Enter to skip):')} `);
3597
+ if (appId)
3598
+ envVars.DISCORD_APP_ID = appId;
3599
+ configObj.channels = { ...(configObj.channels || {}), discord: { enabled: true } };
3600
+ console.log(` ${green('Discord configured')}`);
3601
+ }
3602
+ else {
3603
+ console.log(` ${dim('Skipped. Add later: DISCORD_BOT_TOKEN=... in ~/.clodds/.env')}`);
3604
+ }
3605
+ }
3606
+ else if (channelChoice === 'slack') {
3607
+ console.log(` ${bgCyan(' 3 ')} ${bold('Slack Setup')}`);
3608
+ console.log(` ${dim('1.')} Go to ${cyan('https://api.slack.com/apps')} > Create App`);
3609
+ console.log(` ${dim('2.')} OAuth > Bot Token (xoxb-...) and App Token (xapp-...)`);
3610
+ console.log('');
3611
+ let botToken = envVars.SLACK_BOT_TOKEN || process.env.SLACK_BOT_TOKEN || '';
3612
+ if (!botToken) {
3613
+ botToken = await ask(` ${bold('Bot token')} ${dim('(xoxb-...):')} `);
3614
+ }
3615
+ let appToken = envVars.SLACK_APP_TOKEN || process.env.SLACK_APP_TOKEN || '';
3616
+ if (!appToken) {
3617
+ appToken = await ask(` ${bold('App token')} ${dim('(xapp-...):')} `);
3618
+ }
3619
+ if (botToken && appToken) {
3620
+ envVars.SLACK_BOT_TOKEN = botToken;
3621
+ envVars.SLACK_APP_TOKEN = appToken;
3622
+ configObj.channels = { ...(configObj.channels || {}), slack: { enabled: true } };
3623
+ console.log(` ${green('Slack configured')}`);
3624
+ }
3625
+ else {
3626
+ console.log(` ${dim('Incomplete. Add tokens later in ~/.clodds/.env')}`);
3627
+ }
3628
+ }
3629
+ else {
3630
+ console.log(` ${bgCyan(' 3 ')} ${bold('WebChat')} ${dim('— no extra setup needed')}`);
3631
+ }
3632
+ console.log('');
3633
+ // ═══════════════════════════════════════════════════════════════════
3634
+ // STEP 4: WRITE CONFIG
3635
+ // ═══════════════════════════════════════════════════════════════════
3636
+ console.log(` ${bgCyan(' 4 ')} ${bold('Saving')}`);
3637
+ if (!(0, fs_1.existsSync)(cloddsDir)) {
3638
+ (0, fs_1.mkdirSync)(cloddsDir, { recursive: true });
3639
+ }
3640
+ // Auto-generate credential encryption key if not set
3641
+ if (!envVars.CLODDS_CREDENTIAL_KEY && !process.env.CLODDS_CREDENTIAL_KEY) {
3642
+ const { randomBytes } = await Promise.resolve().then(() => __importStar(require('crypto')));
3643
+ envVars.CLODDS_CREDENTIAL_KEY = randomBytes(32).toString('hex');
3644
+ }
3645
+ // Write .env
3646
+ const envContent = Object.entries(envVars)
3647
+ .filter(([_, v]) => v && v !== 'sk-ant-...')
3648
+ .map(([k, v]) => `${k}=${v}`)
3649
+ .join('\n') + '\n';
3650
+ (0, fs_1.writeFileSync)(envPath, envContent, { mode: 0o600 });
3651
+ console.log(` ${green('wrote')} ${dim(envPath)}`);
3652
+ // Write config
3653
+ if (!configObj.gateway) {
3654
+ configObj.gateway = { port: 18789 };
3655
+ }
3656
+ (0, fs_1.writeFileSync)(configPath, JSON.stringify(configObj, null, 2));
3657
+ console.log(` ${green('wrote')} ${dim(configPath)}`);
3658
+ // ═══════════════════════════════════════════════════════════════════
3659
+ // DONE
3660
+ // ═══════════════════════════════════════════════════════════════════
3661
+ console.log('');
3662
+ console.log(` ${green(bold('Setup complete.'))} Everything you need is ready.`);
3663
+ console.log('');
3664
+ console.log(` ${dim('Quick reference:')}`);
3665
+ console.log(` ${bold('clodds start')} ${dim('launch the gateway')}`);
3666
+ console.log(` ${bold('clodds doctor')} ${dim('run diagnostics')}`);
3667
+ console.log(` ${bold('clodds repl')} ${dim('local test shell')}`);
3668
+ console.log('');
3669
+ console.log(` ${dim('WebChat:')} ${cyan('http://localhost:18789/webchat')}`);
3670
+ if (channelChoice === 'telegram' && envVars.TELEGRAM_BOT_TOKEN) {
3671
+ console.log(` ${dim('Telegram:')} message your bot to start chatting`);
3672
+ }
3673
+ else if (channelChoice === 'discord' && envVars.DISCORD_BOT_TOKEN) {
3674
+ console.log(` ${dim('Discord:')} invite your bot, then mention it`);
3675
+ }
3676
+ console.log('');
3677
+ if (options.start !== false) {
3678
+ const startNow = await ask(` ${bold('Start Clodds now?')} ${dim('[Y/n]')} `);
3679
+ rl.close();
3680
+ if (!startNow || startNow.toLowerCase() === 'y' || startNow.toLowerCase() === 'yes') {
3681
+ for (const [k, v] of Object.entries(envVars)) {
3682
+ process.env[k] = v;
3683
+ }
3684
+ console.log('');
3685
+ const config = await (0, config_1.loadConfig)();
3686
+ const { configureHttpClient } = await Promise.resolve().then(() => __importStar(require('../../utils/http.js')));
3687
+ configureHttpClient(config.http);
3688
+ const { createGateway } = await Promise.resolve().then(() => __importStar(require('../../gateway/index.js')));
3689
+ process.stdout.write(` ${dim('Starting...')}`);
3690
+ const gateway = await createGateway(config);
3691
+ await gateway.start();
3692
+ // Restore logging now that the gateway is running
3693
+ const { logger: rootLog } = await Promise.resolve().then(() => __importStar(require('../../utils/logger.js')));
3694
+ rootLog.level = 'info';
3695
+ console.log(`\r ${green(bold('Clodds is running'))} `);
3696
+ console.log('');
3697
+ console.log(` ${cyan(`http://localhost:${config.gateway.port}/webchat`)}`);
3698
+ console.log(` ${dim('Press Ctrl+C to stop')}`);
3699
+ console.log('');
3700
+ const shutdown = async () => {
3701
+ console.log(`\n ${dim('Shutting down...')}`);
3702
+ await gateway.stop();
3703
+ process.exit(0);
3704
+ };
3705
+ process.on('SIGINT', shutdown);
3706
+ process.on('SIGTERM', shutdown);
3707
+ }
3708
+ }
3709
+ else {
3710
+ rl.close();
3711
+ }
3712
+ });
3713
+ }
3714
+ // =============================================================================
3715
+ // MAIN EXPORT
3716
+ // =============================================================================
3717
+ function addAllCommands(program) {
3718
+ createConfigCommands(program);
3719
+ createModelCommands(program);
3720
+ createSessionCommands(program);
3721
+ createCronCommands(program);
3722
+ createQmdCommands(program);
3723
+ createUserCommands(program);
3724
+ createMemoryCommands(program);
3725
+ createHookCommands(program);
3726
+ createMcpCommands(program);
3727
+ createMarketIndexCommands(program);
3728
+ createPermissionCommands(program);
3729
+ createUsageCommands(program);
3730
+ createCredsCommands(program);
3731
+ createLocaleCommands(program);
3732
+ createLedgerCommands(program);
3733
+ createInitCommand(program);
3734
+ createUpgradeCommand(program);
3735
+ createLoginCommand(program);
3736
+ createLogoutCommand(program);
3737
+ createWhatsAppCommands(program);
3738
+ createBittensorCommands(program);
3739
+ createOnboardCommand(program);
3740
+ createDoctorCommand(program);
3741
+ createVersionCommand(program);
3742
+ }
3743
+ //# sourceMappingURL=index.js.map