atena-cli 0.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 (475) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +210 -0
  3. package/dist/agent.d.ts +44 -0
  4. package/dist/agent.d.ts.map +1 -0
  5. package/dist/agent.js +731 -0
  6. package/dist/agent.js.map +1 -0
  7. package/dist/agents.d.ts +33 -0
  8. package/dist/agents.d.ts.map +1 -0
  9. package/dist/agents.js +162 -0
  10. package/dist/agents.js.map +1 -0
  11. package/dist/autocomplete.d.ts +4 -0
  12. package/dist/autocomplete.d.ts.map +1 -0
  13. package/dist/autocomplete.js +96 -0
  14. package/dist/autocomplete.js.map +1 -0
  15. package/dist/cli/commands/connect.d.ts +3 -0
  16. package/dist/cli/commands/connect.d.ts.map +1 -0
  17. package/dist/cli/commands/connect.js +31 -0
  18. package/dist/cli/commands/connect.js.map +1 -0
  19. package/dist/cli/commands/deploy.d.ts +3 -0
  20. package/dist/cli/commands/deploy.d.ts.map +1 -0
  21. package/dist/cli/commands/deploy.js +26 -0
  22. package/dist/cli/commands/deploy.js.map +1 -0
  23. package/dist/cli/commands/login.d.ts +3 -0
  24. package/dist/cli/commands/login.d.ts.map +1 -0
  25. package/dist/cli/commands/login.js +46 -0
  26. package/dist/cli/commands/login.js.map +1 -0
  27. package/dist/cli/commands/vault.d.ts +3 -0
  28. package/dist/cli/commands/vault.d.ts.map +1 -0
  29. package/dist/cli/commands/vault.js +73 -0
  30. package/dist/cli/commands/vault.js.map +1 -0
  31. package/dist/cli/index.d.ts +3 -0
  32. package/dist/cli/index.d.ts.map +1 -0
  33. package/dist/cli/index.js +309 -0
  34. package/dist/cli/index.js.map +1 -0
  35. package/dist/cli/init/setup.d.ts +3 -0
  36. package/dist/cli/init/setup.d.ts.map +1 -0
  37. package/dist/cli/init/setup.js +74 -0
  38. package/dist/cli/init/setup.js.map +1 -0
  39. package/dist/cli/menus.d.ts +2 -0
  40. package/dist/cli/menus.d.ts.map +1 -0
  41. package/dist/cli/menus.js +111 -0
  42. package/dist/cli/menus.js.map +1 -0
  43. package/dist/cli/postinstall.d.ts +9 -0
  44. package/dist/cli/postinstall.d.ts.map +1 -0
  45. package/dist/cli/postinstall.js +81 -0
  46. package/dist/cli/postinstall.js.map +1 -0
  47. package/dist/cli/realtime-input.d.ts +4 -0
  48. package/dist/cli/realtime-input.d.ts.map +1 -0
  49. package/dist/cli/realtime-input.js +268 -0
  50. package/dist/cli/realtime-input.js.map +1 -0
  51. package/dist/cli/setup.d.ts +26 -0
  52. package/dist/cli/setup.d.ts.map +1 -0
  53. package/dist/cli/setup.js +202 -0
  54. package/dist/cli/setup.js.map +1 -0
  55. package/dist/cli/themes.d.ts +30 -0
  56. package/dist/cli/themes.d.ts.map +1 -0
  57. package/dist/cli/themes.js +225 -0
  58. package/dist/cli/themes.js.map +1 -0
  59. package/dist/cli/ui.d.ts +70 -0
  60. package/dist/cli/ui.d.ts.map +1 -0
  61. package/dist/cli/ui.js +455 -0
  62. package/dist/cli/ui.js.map +1 -0
  63. package/dist/commands.d.ts +16 -0
  64. package/dist/commands.d.ts.map +1 -0
  65. package/dist/commands.js +230 -0
  66. package/dist/commands.js.map +1 -0
  67. package/dist/config.d.ts +42 -0
  68. package/dist/config.d.ts.map +1 -0
  69. package/dist/config.js +140 -0
  70. package/dist/config.js.map +1 -0
  71. package/dist/context.d.ts +23 -0
  72. package/dist/context.d.ts.map +1 -0
  73. package/dist/context.js +80 -0
  74. package/dist/context.js.map +1 -0
  75. package/dist/core/agent.d.ts +94 -0
  76. package/dist/core/agent.d.ts.map +1 -0
  77. package/dist/core/agent.js +1280 -0
  78. package/dist/core/agent.js.map +1 -0
  79. package/dist/core/agents/enterprise/backend.d.ts +3 -0
  80. package/dist/core/agents/enterprise/backend.d.ts.map +1 -0
  81. package/dist/core/agents/enterprise/backend.js +35 -0
  82. package/dist/core/agents/enterprise/backend.js.map +1 -0
  83. package/dist/core/agents/enterprise/cloud.d.ts +3 -0
  84. package/dist/core/agents/enterprise/cloud.d.ts.map +1 -0
  85. package/dist/core/agents/enterprise/cloud.js +35 -0
  86. package/dist/core/agents/enterprise/cloud.js.map +1 -0
  87. package/dist/core/agents/enterprise/datascience.d.ts +3 -0
  88. package/dist/core/agents/enterprise/datascience.d.ts.map +1 -0
  89. package/dist/core/agents/enterprise/datascience.js +35 -0
  90. package/dist/core/agents/enterprise/datascience.js.map +1 -0
  91. package/dist/core/agents/enterprise/design.d.ts +3 -0
  92. package/dist/core/agents/enterprise/design.d.ts.map +1 -0
  93. package/dist/core/agents/enterprise/design.js +35 -0
  94. package/dist/core/agents/enterprise/design.js.map +1 -0
  95. package/dist/core/agents/enterprise/devops.d.ts +3 -0
  96. package/dist/core/agents/enterprise/devops.d.ts.map +1 -0
  97. package/dist/core/agents/enterprise/devops.js +35 -0
  98. package/dist/core/agents/enterprise/devops.js.map +1 -0
  99. package/dist/core/agents/enterprise/finance.d.ts +3 -0
  100. package/dist/core/agents/enterprise/finance.d.ts.map +1 -0
  101. package/dist/core/agents/enterprise/finance.js +35 -0
  102. package/dist/core/agents/enterprise/finance.js.map +1 -0
  103. package/dist/core/agents/enterprise/frontend.d.ts +3 -0
  104. package/dist/core/agents/enterprise/frontend.d.ts.map +1 -0
  105. package/dist/core/agents/enterprise/frontend.js +35 -0
  106. package/dist/core/agents/enterprise/frontend.js.map +1 -0
  107. package/dist/core/agents/enterprise/hr.d.ts +3 -0
  108. package/dist/core/agents/enterprise/hr.d.ts.map +1 -0
  109. package/dist/core/agents/enterprise/hr.js +35 -0
  110. package/dist/core/agents/enterprise/hr.js.map +1 -0
  111. package/dist/core/agents/enterprise/index.d.ts +4 -0
  112. package/dist/core/agents/enterprise/index.d.ts.map +1 -0
  113. package/dist/core/agents/enterprise/index.js +44 -0
  114. package/dist/core/agents/enterprise/index.js.map +1 -0
  115. package/dist/core/agents/enterprise/legal.d.ts +3 -0
  116. package/dist/core/agents/enterprise/legal.d.ts.map +1 -0
  117. package/dist/core/agents/enterprise/legal.js +35 -0
  118. package/dist/core/agents/enterprise/legal.js.map +1 -0
  119. package/dist/core/agents/enterprise/marketing.d.ts +3 -0
  120. package/dist/core/agents/enterprise/marketing.d.ts.map +1 -0
  121. package/dist/core/agents/enterprise/marketing.js +35 -0
  122. package/dist/core/agents/enterprise/marketing.js.map +1 -0
  123. package/dist/core/agents/enterprise/pm.d.ts +3 -0
  124. package/dist/core/agents/enterprise/pm.d.ts.map +1 -0
  125. package/dist/core/agents/enterprise/pm.js +35 -0
  126. package/dist/core/agents/enterprise/pm.js.map +1 -0
  127. package/dist/core/agents/enterprise/product.d.ts +3 -0
  128. package/dist/core/agents/enterprise/product.d.ts.map +1 -0
  129. package/dist/core/agents/enterprise/product.js +35 -0
  130. package/dist/core/agents/enterprise/product.js.map +1 -0
  131. package/dist/core/agents/enterprise/qa.d.ts +3 -0
  132. package/dist/core/agents/enterprise/qa.d.ts.map +1 -0
  133. package/dist/core/agents/enterprise/qa.js +35 -0
  134. package/dist/core/agents/enterprise/qa.js.map +1 -0
  135. package/dist/core/agents/enterprise/sales.d.ts +3 -0
  136. package/dist/core/agents/enterprise/sales.d.ts.map +1 -0
  137. package/dist/core/agents/enterprise/sales.js +35 -0
  138. package/dist/core/agents/enterprise/sales.js.map +1 -0
  139. package/dist/core/agents/enterprise/security.d.ts +3 -0
  140. package/dist/core/agents/enterprise/security.d.ts.map +1 -0
  141. package/dist/core/agents/enterprise/security.js +36 -0
  142. package/dist/core/agents/enterprise/security.js.map +1 -0
  143. package/dist/core/agents/enterprise/support.d.ts +3 -0
  144. package/dist/core/agents/enterprise/support.d.ts.map +1 -0
  145. package/dist/core/agents/enterprise/support.js +35 -0
  146. package/dist/core/agents/enterprise/support.js.map +1 -0
  147. package/dist/core/agents.d.ts +84 -0
  148. package/dist/core/agents.d.ts.map +1 -0
  149. package/dist/core/agents.js +266 -0
  150. package/dist/core/agents.js.map +1 -0
  151. package/dist/core/analytics.d.ts +21 -0
  152. package/dist/core/analytics.d.ts.map +1 -0
  153. package/dist/core/analytics.js +57 -0
  154. package/dist/core/analytics.js.map +1 -0
  155. package/dist/core/auth.d.ts +43 -0
  156. package/dist/core/auth.d.ts.map +1 -0
  157. package/dist/core/auth.js +110 -0
  158. package/dist/core/auth.js.map +1 -0
  159. package/dist/core/code_indexer.d.ts +14 -0
  160. package/dist/core/code_indexer.d.ts.map +1 -0
  161. package/dist/core/code_indexer.js +52 -0
  162. package/dist/core/code_indexer.js.map +1 -0
  163. package/dist/core/commands.d.ts +16 -0
  164. package/dist/core/commands.d.ts.map +1 -0
  165. package/dist/core/commands.js +285 -0
  166. package/dist/core/commands.js.map +1 -0
  167. package/dist/core/consensus.d.ts +25 -0
  168. package/dist/core/consensus.d.ts.map +1 -0
  169. package/dist/core/consensus.js +49 -0
  170. package/dist/core/consensus.js.map +1 -0
  171. package/dist/core/context.d.ts +23 -0
  172. package/dist/core/context.d.ts.map +1 -0
  173. package/dist/core/context.js +82 -0
  174. package/dist/core/context.js.map +1 -0
  175. package/dist/core/eden-ai-sdk.d.ts +11 -0
  176. package/dist/core/eden-ai-sdk.d.ts.map +1 -0
  177. package/dist/core/eden-ai-sdk.js +158 -0
  178. package/dist/core/eden-ai-sdk.js.map +1 -0
  179. package/dist/core/events.d.ts +64 -0
  180. package/dist/core/events.d.ts.map +1 -0
  181. package/dist/core/events.js +18 -0
  182. package/dist/core/events.js.map +1 -0
  183. package/dist/core/groq-client.d.ts +7 -0
  184. package/dist/core/groq-client.d.ts.map +1 -0
  185. package/dist/core/groq-client.js +112 -0
  186. package/dist/core/groq-client.js.map +1 -0
  187. package/dist/core/mcp.d.ts +51 -0
  188. package/dist/core/mcp.d.ts.map +1 -0
  189. package/dist/core/mcp.js +201 -0
  190. package/dist/core/mcp.js.map +1 -0
  191. package/dist/core/memory.d.ts +20 -0
  192. package/dist/core/memory.d.ts.map +1 -0
  193. package/dist/core/memory.js +61 -0
  194. package/dist/core/memory.js.map +1 -0
  195. package/dist/core/model-profiles.d.ts +62 -0
  196. package/dist/core/model-profiles.d.ts.map +1 -0
  197. package/dist/core/model-profiles.js +841 -0
  198. package/dist/core/model-profiles.js.map +1 -0
  199. package/dist/core/moonshot-client.d.ts +7 -0
  200. package/dist/core/moonshot-client.d.ts.map +1 -0
  201. package/dist/core/moonshot-client.js +102 -0
  202. package/dist/core/moonshot-client.js.map +1 -0
  203. package/dist/core/nexus.d.ts +16 -0
  204. package/dist/core/nexus.d.ts.map +1 -0
  205. package/dist/core/nexus.js +31 -0
  206. package/dist/core/nexus.js.map +1 -0
  207. package/dist/core/notifications.d.ts +16 -0
  208. package/dist/core/notifications.d.ts.map +1 -0
  209. package/dist/core/notifications.js +26 -0
  210. package/dist/core/notifications.js.map +1 -0
  211. package/dist/core/ollama-client.d.ts +16 -0
  212. package/dist/core/ollama-client.d.ts.map +1 -0
  213. package/dist/core/ollama-client.js +138 -0
  214. package/dist/core/ollama-client.js.map +1 -0
  215. package/dist/core/orchestrator.d.ts +96 -0
  216. package/dist/core/orchestrator.d.ts.map +1 -0
  217. package/dist/core/orchestrator.js +801 -0
  218. package/dist/core/orchestrator.js.map +1 -0
  219. package/dist/core/permissions.d.ts +34 -0
  220. package/dist/core/permissions.d.ts.map +1 -0
  221. package/dist/core/permissions.js +224 -0
  222. package/dist/core/permissions.js.map +1 -0
  223. package/dist/core/providers.d.ts +22 -0
  224. package/dist/core/providers.d.ts.map +1 -0
  225. package/dist/core/providers.js +81 -0
  226. package/dist/core/providers.js.map +1 -0
  227. package/dist/core/researcher.d.ts +24 -0
  228. package/dist/core/researcher.d.ts.map +1 -0
  229. package/dist/core/researcher.js +97 -0
  230. package/dist/core/researcher.js.map +1 -0
  231. package/dist/core/sandbox.d.ts +22 -0
  232. package/dist/core/sandbox.d.ts.map +1 -0
  233. package/dist/core/sandbox.js +79 -0
  234. package/dist/core/sandbox.js.map +1 -0
  235. package/dist/core/scavenger.d.ts +5 -0
  236. package/dist/core/scavenger.d.ts.map +1 -0
  237. package/dist/core/scavenger.js +51 -0
  238. package/dist/core/scavenger.js.map +1 -0
  239. package/dist/core/server.d.ts +21 -0
  240. package/dist/core/server.d.ts.map +1 -0
  241. package/dist/core/server.js +776 -0
  242. package/dist/core/server.js.map +1 -0
  243. package/dist/core/sessions.d.ts +54 -0
  244. package/dist/core/sessions.d.ts.map +1 -0
  245. package/dist/core/sessions.js +182 -0
  246. package/dist/core/sessions.js.map +1 -0
  247. package/dist/core/setup.d.ts +12 -0
  248. package/dist/core/setup.d.ts.map +1 -0
  249. package/dist/core/setup.js +70 -0
  250. package/dist/core/setup.js.map +1 -0
  251. package/dist/core/skills.d.ts +17 -0
  252. package/dist/core/skills.d.ts.map +1 -0
  253. package/dist/core/skills.js +123 -0
  254. package/dist/core/skills.js.map +1 -0
  255. package/dist/core/stats.d.ts +54 -0
  256. package/dist/core/stats.d.ts.map +1 -0
  257. package/dist/core/stats.js +221 -0
  258. package/dist/core/stats.js.map +1 -0
  259. package/dist/core/swarm_manager.d.ts +20 -0
  260. package/dist/core/swarm_manager.d.ts.map +1 -0
  261. package/dist/core/swarm_manager.js +48 -0
  262. package/dist/core/swarm_manager.js.map +1 -0
  263. package/dist/core/system.d.ts +39 -0
  264. package/dist/core/system.d.ts.map +1 -0
  265. package/dist/core/system.js +129 -0
  266. package/dist/core/system.js.map +1 -0
  267. package/dist/core/tasks.d.ts +24 -0
  268. package/dist/core/tasks.d.ts.map +1 -0
  269. package/dist/core/tasks.js +66 -0
  270. package/dist/core/tasks.js.map +1 -0
  271. package/dist/core/telegram.d.ts +9 -0
  272. package/dist/core/telegram.d.ts.map +1 -0
  273. package/dist/core/telegram.js +49 -0
  274. package/dist/core/telegram.js.map +1 -0
  275. package/dist/core/tools/acquire_skill.d.ts +3 -0
  276. package/dist/core/tools/acquire_skill.d.ts.map +1 -0
  277. package/dist/core/tools/acquire_skill.js +30 -0
  278. package/dist/core/tools/acquire_skill.js.map +1 -0
  279. package/dist/core/tools/agent_tools.d.ts +4 -0
  280. package/dist/core/tools/agent_tools.d.ts.map +1 -0
  281. package/dist/core/tools/agent_tools.js +117 -0
  282. package/dist/core/tools/agent_tools.js.map +1 -0
  283. package/dist/core/tools/code_search.d.ts +3 -0
  284. package/dist/core/tools/code_search.d.ts.map +1 -0
  285. package/dist/core/tools/code_search.js +43 -0
  286. package/dist/core/tools/code_search.js.map +1 -0
  287. package/dist/core/tools/craft_tool.d.ts +3 -0
  288. package/dist/core/tools/craft_tool.d.ts.map +1 -0
  289. package/dist/core/tools/craft_tool.js +32 -0
  290. package/dist/core/tools/craft_tool.js.map +1 -0
  291. package/dist/core/tools/discord.d.ts +3 -0
  292. package/dist/core/tools/discord.d.ts.map +1 -0
  293. package/dist/core/tools/discord.js +206 -0
  294. package/dist/core/tools/discord.js.map +1 -0
  295. package/dist/core/tools/dynamic/registry.d.ts +15 -0
  296. package/dist/core/tools/dynamic/registry.d.ts.map +1 -0
  297. package/dist/core/tools/dynamic/registry.js +59 -0
  298. package/dist/core/tools/dynamic/registry.js.map +1 -0
  299. package/dist/core/tools/github.d.ts +3 -0
  300. package/dist/core/tools/github.d.ts.map +1 -0
  301. package/dist/core/tools/github.js +357 -0
  302. package/dist/core/tools/github.js.map +1 -0
  303. package/dist/core/tools/google.d.ts +3 -0
  304. package/dist/core/tools/google.d.ts.map +1 -0
  305. package/dist/core/tools/google.js +409 -0
  306. package/dist/core/tools/google.js.map +1 -0
  307. package/dist/core/tools/index.d.ts +4 -0
  308. package/dist/core/tools/index.d.ts.map +1 -0
  309. package/dist/core/tools/index.js +2338 -0
  310. package/dist/core/tools/index.js.map +1 -0
  311. package/dist/core/tools/optimize_prompt.d.ts +3 -0
  312. package/dist/core/tools/optimize_prompt.d.ts.map +1 -0
  313. package/dist/core/tools/optimize_prompt.js +43 -0
  314. package/dist/core/tools/optimize_prompt.js.map +1 -0
  315. package/dist/core/tools/predict_healing.d.ts +3 -0
  316. package/dist/core/tools/predict_healing.d.ts.map +1 -0
  317. package/dist/core/tools/predict_healing.js +34 -0
  318. package/dist/core/tools/predict_healing.js.map +1 -0
  319. package/dist/core/tools/sage_memory.d.ts +3 -0
  320. package/dist/core/tools/sage_memory.d.ts.map +1 -0
  321. package/dist/core/tools/sage_memory.js +29 -0
  322. package/dist/core/tools/sage_memory.js.map +1 -0
  323. package/dist/core/tools/self_heal.d.ts +3 -0
  324. package/dist/core/tools/self_heal.d.ts.map +1 -0
  325. package/dist/core/tools/self_heal.js +46 -0
  326. package/dist/core/tools/self_heal.js.map +1 -0
  327. package/dist/core/tools/send_briefing.d.ts +3 -0
  328. package/dist/core/tools/send_briefing.d.ts.map +1 -0
  329. package/dist/core/tools/send_briefing.js +31 -0
  330. package/dist/core/tools/send_briefing.js.map +1 -0
  331. package/dist/core/tools/slack.d.ts +3 -0
  332. package/dist/core/tools/slack.d.ts.map +1 -0
  333. package/dist/core/tools/slack.js +256 -0
  334. package/dist/core/tools/slack.js.map +1 -0
  335. package/dist/core/tools/telegram.d.ts +3 -0
  336. package/dist/core/tools/telegram.d.ts.map +1 -0
  337. package/dist/core/tools/telegram.js +211 -0
  338. package/dist/core/tools/telegram.js.map +1 -0
  339. package/dist/core/tools/vox.d.ts +3 -0
  340. package/dist/core/tools/vox.d.ts.map +1 -0
  341. package/dist/core/tools/vox.js +29 -0
  342. package/dist/core/tools/vox.js.map +1 -0
  343. package/dist/core/types/index.d.ts +164 -0
  344. package/dist/core/types/index.d.ts.map +1 -0
  345. package/dist/core/types/index.js +3 -0
  346. package/dist/core/types/index.js.map +1 -0
  347. package/dist/core/vault.d.ts +20 -0
  348. package/dist/core/vault.d.ts.map +1 -0
  349. package/dist/core/vault.js +91 -0
  350. package/dist/core/vault.js.map +1 -0
  351. package/dist/core/verify_v3.d.ts +2 -0
  352. package/dist/core/verify_v3.d.ts.map +1 -0
  353. package/dist/core/verify_v3.js +38 -0
  354. package/dist/core/verify_v3.js.map +1 -0
  355. package/dist/core/verify_v3_5.d.ts +2 -0
  356. package/dist/core/verify_v3_5.d.ts.map +1 -0
  357. package/dist/core/verify_v3_5.js +56 -0
  358. package/dist/core/verify_v3_5.js.map +1 -0
  359. package/dist/core/verify_v4.d.ts +2 -0
  360. package/dist/core/verify_v4.d.ts.map +1 -0
  361. package/dist/core/verify_v4.js +42 -0
  362. package/dist/core/verify_v4.js.map +1 -0
  363. package/dist/core/verify_v5.d.ts +2 -0
  364. package/dist/core/verify_v5.d.ts.map +1 -0
  365. package/dist/core/verify_v5.js +53 -0
  366. package/dist/core/verify_v5.js.map +1 -0
  367. package/dist/core/verify_v6.d.ts +2 -0
  368. package/dist/core/verify_v6.d.ts.map +1 -0
  369. package/dist/core/verify_v6.js +42 -0
  370. package/dist/core/verify_v6.js.map +1 -0
  371. package/dist/core/verify_v7.d.ts +2 -0
  372. package/dist/core/verify_v7.d.ts.map +1 -0
  373. package/dist/core/verify_v7.js +29 -0
  374. package/dist/core/verify_v7.js.map +1 -0
  375. package/dist/core/verify_v8.d.ts +2 -0
  376. package/dist/core/verify_v8.d.ts.map +1 -0
  377. package/dist/core/verify_v8.js +32 -0
  378. package/dist/core/verify_v8.js.map +1 -0
  379. package/dist/core/workflows.d.ts +24 -0
  380. package/dist/core/workflows.d.ts.map +1 -0
  381. package/dist/core/workflows.js +47 -0
  382. package/dist/core/workflows.js.map +1 -0
  383. package/dist/core/workspaces.d.ts +13 -0
  384. package/dist/core/workspaces.d.ts.map +1 -0
  385. package/dist/core/workspaces.js +45 -0
  386. package/dist/core/workspaces.js.map +1 -0
  387. package/dist/enquirer-input.d.ts +3 -0
  388. package/dist/enquirer-input.d.ts.map +1 -0
  389. package/dist/enquirer-input.js +112 -0
  390. package/dist/enquirer-input.js.map +1 -0
  391. package/dist/index.d.ts +3 -0
  392. package/dist/index.d.ts.map +1 -0
  393. package/dist/index.js +241 -0
  394. package/dist/index.js.map +1 -0
  395. package/dist/mcp.d.ts +51 -0
  396. package/dist/mcp.d.ts.map +1 -0
  397. package/dist/mcp.js +201 -0
  398. package/dist/mcp.js.map +1 -0
  399. package/dist/ollama-client.d.ts +15 -0
  400. package/dist/ollama-client.d.ts.map +1 -0
  401. package/dist/ollama-client.js +95 -0
  402. package/dist/ollama-client.js.map +1 -0
  403. package/dist/permissions.d.ts +34 -0
  404. package/dist/permissions.d.ts.map +1 -0
  405. package/dist/permissions.js +224 -0
  406. package/dist/permissions.js.map +1 -0
  407. package/dist/realtime-input.d.ts +2 -0
  408. package/dist/realtime-input.d.ts.map +1 -0
  409. package/dist/realtime-input.js +308 -0
  410. package/dist/realtime-input.js.map +1 -0
  411. package/dist/server.d.ts +20 -0
  412. package/dist/server.d.ts.map +1 -0
  413. package/dist/server.js +203 -0
  414. package/dist/server.js.map +1 -0
  415. package/dist/sessions.d.ts +50 -0
  416. package/dist/sessions.d.ts.map +1 -0
  417. package/dist/sessions.js +181 -0
  418. package/dist/sessions.js.map +1 -0
  419. package/dist/simple-input.d.ts +2 -0
  420. package/dist/simple-input.d.ts.map +1 -0
  421. package/dist/simple-input.js +83 -0
  422. package/dist/simple-input.js.map +1 -0
  423. package/dist/skills.d.ts +17 -0
  424. package/dist/skills.d.ts.map +1 -0
  425. package/dist/skills.js +194 -0
  426. package/dist/skills.js.map +1 -0
  427. package/dist/stats.d.ts +54 -0
  428. package/dist/stats.d.ts.map +1 -0
  429. package/dist/stats.js +220 -0
  430. package/dist/stats.js.map +1 -0
  431. package/dist/tools/discord.d.ts +3 -0
  432. package/dist/tools/discord.d.ts.map +1 -0
  433. package/dist/tools/discord.js +206 -0
  434. package/dist/tools/discord.js.map +1 -0
  435. package/dist/tools/github.d.ts +3 -0
  436. package/dist/tools/github.d.ts.map +1 -0
  437. package/dist/tools/github.js +357 -0
  438. package/dist/tools/github.js.map +1 -0
  439. package/dist/tools/google.d.ts +3 -0
  440. package/dist/tools/google.d.ts.map +1 -0
  441. package/dist/tools/google.js +409 -0
  442. package/dist/tools/google.js.map +1 -0
  443. package/dist/tools/index.d.ts +4 -0
  444. package/dist/tools/index.d.ts.map +1 -0
  445. package/dist/tools/index.js +2139 -0
  446. package/dist/tools/index.js.map +1 -0
  447. package/dist/tools/slack.d.ts +3 -0
  448. package/dist/tools/slack.d.ts.map +1 -0
  449. package/dist/tools/slack.js +256 -0
  450. package/dist/tools/slack.js.map +1 -0
  451. package/dist/tools/telegram.d.ts +3 -0
  452. package/dist/tools/telegram.d.ts.map +1 -0
  453. package/dist/tools/telegram.js +211 -0
  454. package/dist/tools/telegram.js.map +1 -0
  455. package/dist/types/index.d.ts +152 -0
  456. package/dist/types/index.d.ts.map +1 -0
  457. package/dist/types/index.js +3 -0
  458. package/dist/types/index.js.map +1 -0
  459. package/dist/ui.d.ts +101 -0
  460. package/dist/ui.d.ts.map +1 -0
  461. package/dist/ui.js +317 -0
  462. package/dist/ui.js.map +1 -0
  463. package/dist/web/src/lib/utils.d.ts +3 -0
  464. package/dist/web/src/lib/utils.d.ts.map +1 -0
  465. package/dist/web/src/lib/utils.js +6 -0
  466. package/dist/web/src/lib/utils.js.map +1 -0
  467. package/dist/web/src/main.d.ts +2 -0
  468. package/dist/web/src/main.d.ts.map +1 -0
  469. package/dist/web/src/main.js +5 -0
  470. package/dist/web/src/main.js.map +1 -0
  471. package/dist/web/vite.config.d.ts +3 -0
  472. package/dist/web/vite.config.d.ts.map +1 -0
  473. package/dist/web/vite.config.js +12 -0
  474. package/dist/web/vite.config.js.map +1 -0
  475. package/package.json +83 -0
@@ -0,0 +1,776 @@
1
+ // Server Mode for Eden CLI
2
+ // Uses only native Node.js http module — zero extra dependencies
3
+ import { createServer as createHttpServer } from 'node:http';
4
+ import { URL } from 'node:url';
5
+ import { promises as fs } from 'node:fs';
6
+ import path from 'node:path';
7
+ import os from 'node:os';
8
+ import { analyticsEngine } from './analytics.js';
9
+ import { authManager } from './auth.js';
10
+ import { eventHub } from './events.js';
11
+ // ── helpers ──────────────────────────────────────────────────────────
12
+ function json(res, status, body) {
13
+ const payload = JSON.stringify(body);
14
+ res.writeHead(status, {
15
+ 'Content-Type': 'application/json',
16
+ 'Content-Length': Buffer.byteLength(payload),
17
+ });
18
+ res.end(payload);
19
+ }
20
+ function readBody(req) {
21
+ return new Promise((resolve, reject) => {
22
+ const chunks = [];
23
+ req.on('data', (c) => chunks.push(c));
24
+ req.on('end', () => resolve(Buffer.concat(chunks).toString()));
25
+ req.on('error', reject);
26
+ });
27
+ }
28
+ function parseBasicAuth(req) {
29
+ const header = req.headers.authorization;
30
+ if (!header || !header.startsWith('Basic '))
31
+ return null;
32
+ const decoded = Buffer.from(header.slice(6), 'base64').toString();
33
+ const idx = decoded.indexOf(':');
34
+ if (idx < 0)
35
+ return null;
36
+ return { name: decoded.slice(0, idx), pass: decoded.slice(idx + 1) };
37
+ }
38
+ function parseBearerToken(req) {
39
+ const header = req.headers.authorization;
40
+ if (!header || !header.startsWith('Bearer '))
41
+ return null;
42
+ return header.slice(7);
43
+ }
44
+ function addCorsHeaders(res) {
45
+ res.setHeader('Access-Control-Allow-Origin', '*');
46
+ res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
47
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
48
+ }
49
+ // SSE helper for streaming
50
+ function sse(res, data) {
51
+ res.write(`data: ${JSON.stringify(data)}\n\n`);
52
+ }
53
+ function startSse(res) {
54
+ res.writeHead(200, {
55
+ 'Content-Type': 'text/event-stream',
56
+ 'Cache-Control': 'no-cache',
57
+ 'Connection': 'keep-alive',
58
+ 'Access-Control-Allow-Origin': '*',
59
+ });
60
+ }
61
+ // ── server class ─────────────────────────────────────────────────────
62
+ export class EdenServer {
63
+ httpServer;
64
+ agent;
65
+ options;
66
+ sessions = new Map();
67
+ constructor(agent, options) {
68
+ this.agent = agent;
69
+ this.options = options;
70
+ this.httpServer = createHttpServer((req, res) => this.handleRequest(req, res));
71
+ }
72
+ // ── request router ─────────────────────────────────────────────────
73
+ async handleRequest(req, res) {
74
+ // CORS preflight
75
+ if (this.options.enableCors)
76
+ addCorsHeaders(res);
77
+ if (req.method === 'OPTIONS') {
78
+ json(res, 204, null);
79
+ return;
80
+ }
81
+ const url = new URL(req.url || '/', `http://${this.options.hostname}`);
82
+ // Parse path first
83
+ let reqPath = url.pathname;
84
+ if (reqPath !== '/' && reqPath.endsWith('/')) {
85
+ reqPath = reqPath.slice(0, -1);
86
+ }
87
+ const method = req.method ?? 'GET';
88
+ const normalizedPath = reqPath.startsWith('/api') ? reqPath.slice(4) : reqPath;
89
+ // Check auth token for protected routes (header or query param for SSE)
90
+ let token = parseBearerToken(req);
91
+ if (!token) {
92
+ token = url.searchParams.get('token');
93
+ }
94
+ const isAuthenticated = token ? authManager.validateToken(token).valid : false;
95
+ // Public routes that don't require auth
96
+ const publicRoutes = ['/health', '/login', '/register', '/auth/status'];
97
+ const isPublicRoute = publicRoutes.some(route => normalizedPath === route || normalizedPath.startsWith(route));
98
+ // Auth guard for protected routes
99
+ if (!isPublicRoute && !isAuthenticated) {
100
+ json(res, 401, { error: 'Unauthorized', message: 'Please login first' });
101
+ return;
102
+ }
103
+ if (!this.options.quiet) {
104
+ console.log(`[${new Date().toLocaleTimeString()}] ${method} ${reqPath}`);
105
+ }
106
+ try {
107
+ // POST /register
108
+ if (method === 'POST' && normalizedPath === '/register') {
109
+ const body = JSON.parse(await readBody(req));
110
+ if (!body.username || !body.password) {
111
+ json(res, 400, { error: 'Username and password required' });
112
+ return;
113
+ }
114
+ const result = await authManager.register(body.username, body.password);
115
+ if (result.success) {
116
+ json(res, 201, { success: true, message: 'User registered successfully' });
117
+ }
118
+ else {
119
+ json(res, 400, { error: result.error });
120
+ }
121
+ return;
122
+ }
123
+ // POST /login
124
+ if (method === 'POST' && normalizedPath === '/login') {
125
+ const body = JSON.parse(await readBody(req));
126
+ if (!body.username || !body.password) {
127
+ json(res, 400, { error: 'Username and password required' });
128
+ return;
129
+ }
130
+ const result = await authManager.login(body.username, body.password);
131
+ if (result.success) {
132
+ json(res, 200, { success: true, token: result.token });
133
+ }
134
+ else {
135
+ json(res, 401, { error: result.error });
136
+ }
137
+ return;
138
+ }
139
+ // POST /logout
140
+ if (method === 'POST' && normalizedPath === '/logout') {
141
+ if (token) {
142
+ await authManager.logout(token);
143
+ }
144
+ json(res, 200, { success: true, message: 'Logged out successfully' });
145
+ return;
146
+ }
147
+ // GET /auth/status
148
+ if (method === 'GET' && normalizedPath === '/auth/status') {
149
+ const validation = token ? authManager.validateToken(token) : { valid: false };
150
+ json(res, 200, {
151
+ authenticated: validation.valid,
152
+ user: validation.user ? { username: validation.user.username } : null,
153
+ hasUsers: authManager.hasUsers()
154
+ });
155
+ return;
156
+ }
157
+ // GET /agents
158
+ if (method === 'GET' && normalizedPath === '/agents') {
159
+ const agentList = this.agent.getAgentManager().listAgents();
160
+ json(res, 200, { agents: agentList });
161
+ return;
162
+ }
163
+ // POST /agents
164
+ if (method === 'POST' && normalizedPath === '/agents') {
165
+ const body = JSON.parse(await readBody(req));
166
+ if (!body.id || !body.name || !body.systemPrompt) {
167
+ json(res, 400, { error: 'id, name, and systemPrompt are required' });
168
+ return;
169
+ }
170
+ // Check if agent already exists
171
+ if (this.agent.getAgentManager().hasAgent(body.id)) {
172
+ json(res, 200, { status: 'exists', message: 'Agent already exists', agent: this.agent.getAgentManager().getAgent(body.id) });
173
+ return;
174
+ }
175
+ await this.agent.getAgentManager().registerAgent(body);
176
+ json(res, 201, { status: 'registered', agent: body });
177
+ return;
178
+ }
179
+ // GET /model-profiles - List all available model profiles
180
+ if (method === 'GET' && normalizedPath === '/model-profiles') {
181
+ const { listAllProfiles } = await import('./model-profiles.js');
182
+ json(res, 200, { profiles: listAllProfiles() });
183
+ return;
184
+ }
185
+ // GET /agents/:id/model-profile - Get agent's model profile
186
+ const agentModelMatch = normalizedPath.match(/^\/agents\/([^/]+)\/model-profile$/);
187
+ if (method === 'GET' && agentModelMatch) {
188
+ const agentId = agentModelMatch[1];
189
+ const profileInfo = this.agent.getAgentManager().getAgentModelProfile(agentId);
190
+ if (!profileInfo) {
191
+ json(res, 404, { error: 'Agent not found' });
192
+ return;
193
+ }
194
+ json(res, 200, profileInfo);
195
+ return;
196
+ }
197
+ // POST /agents/:id/model-profile - Set agent's model profile
198
+ if (method === 'POST' && agentModelMatch) {
199
+ const agentId = agentModelMatch[1];
200
+ const body = JSON.parse(await readBody(req));
201
+ if (!body.profileId) {
202
+ json(res, 400, { error: 'profileId is required' });
203
+ return;
204
+ }
205
+ const success = this.agent.getAgentManager().setAgentModelProfile(agentId, body.profileId);
206
+ if (!success) {
207
+ json(res, 404, { error: 'Agent not found' });
208
+ return;
209
+ }
210
+ json(res, 200, { success: true, profileId: body.profileId });
211
+ return;
212
+ }
213
+ // GET /agents/:id/rag-config - Get agent's RAG config
214
+ const agentRagMatch = normalizedPath.match(/^\/agents\/([^/]+)\/rag-config$/);
215
+ if (method === 'GET' && agentRagMatch) {
216
+ const agentId = agentRagMatch[1];
217
+ const agent = this.agent.getAgentManager().getAgent(agentId);
218
+ if (!agent) {
219
+ json(res, 404, { error: 'Agent not found' });
220
+ return;
221
+ }
222
+ json(res, 200, {
223
+ enabled: agent.ragConfig?.enabled ?? true,
224
+ customInstructions: agent.ragConfig?.customInstructions || null
225
+ });
226
+ return;
227
+ }
228
+ // POST /agents/:id/rag-config - Update agent's RAG config
229
+ if (method === 'POST' && agentRagMatch) {
230
+ const agentId = agentRagMatch[1];
231
+ const body = JSON.parse(await readBody(req));
232
+ const success = this.agent.getAgentManager().updateAgentRagConfig(agentId, body);
233
+ if (!success) {
234
+ json(res, 404, { error: 'Agent not found' });
235
+ return;
236
+ }
237
+ json(res, 200, { success: true });
238
+ return;
239
+ }
240
+ // GET /notifications
241
+ if (method === 'GET' && normalizedPath === '/notifications') {
242
+ json(res, 200, { notifications: this.agent.getNotifications() });
243
+ return;
244
+ }
245
+ // POST /approve
246
+ if (method === 'POST' && normalizedPath === '/approve') {
247
+ const body = JSON.parse(await readBody(req));
248
+ const { id, approved } = body;
249
+ const success = this.agent.resolveApproval(id, approved);
250
+ json(res, 200, { success });
251
+ return;
252
+ }
253
+ // GET /health
254
+ if (method === 'GET' && (normalizedPath === '/health' || normalizedPath === '')) {
255
+ json(res, 200, {
256
+ status: 'ok',
257
+ version: '3.0.0',
258
+ uptime: process.uptime(),
259
+ features: ['agents', 'sessions', 'permissions', 'mcp', 'orchestration', 'sandbox'],
260
+ });
261
+ return;
262
+ }
263
+ // GET /workspaces
264
+ if (method === 'GET' && normalizedPath === '/workspaces') {
265
+ try {
266
+ const wFile = path.join(os.homedir(), '.eden', 'workspaces.json');
267
+ const data = await fs.readFile(wFile, 'utf8');
268
+ json(res, 200, { workspaces: JSON.parse(data) });
269
+ }
270
+ catch {
271
+ json(res, 200, { workspaces: [] });
272
+ }
273
+ return;
274
+ }
275
+ // GET /fs/home
276
+ if (method === 'GET' && normalizedPath === '/fs/home') {
277
+ json(res, 200, { home: os.homedir() });
278
+ return;
279
+ }
280
+ // GET /files - Universal File Hub
281
+ if (method === 'GET' && normalizedPath === '/files') {
282
+ const root = url.searchParams.get('root') || this.agent.getCwd();
283
+ try {
284
+ const entries = await fs.readdir(root, { withFileTypes: true });
285
+ const list = entries.map(e => ({
286
+ name: e.name,
287
+ type: e.isDirectory() ? 'directory' : 'file',
288
+ path: path.join(root, e.name)
289
+ }));
290
+ json(res, 200, { currentPath: root, files: list });
291
+ }
292
+ catch (e) {
293
+ json(res, 500, { error: 'Failed to list files' });
294
+ }
295
+ return;
296
+ }
297
+ // GET /fs/list
298
+ if (method === 'GET' && normalizedPath === '/fs/list') {
299
+ const p = url.searchParams.get('path') || os.homedir();
300
+ try {
301
+ const entries = await fs.readdir(p, { withFileTypes: true });
302
+ const dirs = entries
303
+ .filter(e => e.isDirectory() && !e.name.startsWith('.'))
304
+ .map(e => ({ name: e.name, path: path.join(p, e.name) }));
305
+ json(res, 200, { currentPath: p, directories: dirs });
306
+ }
307
+ catch (e) {
308
+ json(res, 500, { error: 'Could not read directory' });
309
+ }
310
+ return;
311
+ }
312
+ // POST /workspaces
313
+ if (method === 'POST' && normalizedPath === '/workspaces') {
314
+ const body = JSON.parse(await readBody(req));
315
+ if (!body.path) {
316
+ json(res, 400, { error: 'path required' });
317
+ return;
318
+ }
319
+ const wfile = path.join(os.homedir(), '.eden', 'workspaces.json');
320
+ let current = [];
321
+ try {
322
+ current = JSON.parse(await fs.readFile(wfile, 'utf8'));
323
+ }
324
+ catch { }
325
+ if (!current.includes(body.path)) {
326
+ current.unshift(body.path);
327
+ await fs.mkdir(path.join(os.homedir(), '.eden'), { recursive: true });
328
+ await fs.writeFile(wfile, JSON.stringify(current, null, 2));
329
+ }
330
+ json(res, 200, { status: 'added', workspaces: current });
331
+ return;
332
+ }
333
+ // POST /files/upload - Simple File Placement
334
+ if (method === 'POST' && normalizedPath === '/files/upload') {
335
+ const body = JSON.parse(await readBody(req));
336
+ if (!body.filename || !body.content) {
337
+ json(res, 400, { error: 'filename and content required' });
338
+ return;
339
+ }
340
+ const filePath = path.join(this.agent.getCwd(), body.filename);
341
+ await fs.writeFile(filePath, body.content);
342
+ json(res, 201, { status: 'uploaded', path: filePath });
343
+ return;
344
+ }
345
+ // GET /workflows
346
+ if (method === 'GET' && normalizedPath === '/workflows') {
347
+ try {
348
+ const flowDir = path.join(process.cwd(), '.eden', 'workflows');
349
+ const files = await fs.readdir(flowDir);
350
+ const flows = files.filter(f => f.endsWith('.md')).map(f => f.replace('.md', ''));
351
+ json(res, 200, { workflows: flows });
352
+ }
353
+ catch {
354
+ json(res, 200, { workflows: [] });
355
+ }
356
+ return;
357
+ }
358
+ // POST /workflows - Create new workflow
359
+ if (method === 'POST' && normalizedPath === '/workflows') {
360
+ const body = JSON.parse(await readBody(req));
361
+ if (!body.name || !body.content) {
362
+ json(res, 400, { error: 'name and content required' });
363
+ return;
364
+ }
365
+ try {
366
+ const filePath = path.join(process.cwd(), '.eden', 'workflows', `${body.name.replace(/\s+/g, '_')}.md`);
367
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
368
+ await fs.writeFile(filePath, body.content);
369
+ json(res, 201, { status: 'created', name: body.name });
370
+ }
371
+ catch (e) {
372
+ json(res, 500, { error: 'Failed to save workflow' });
373
+ }
374
+ return;
375
+ }
376
+ // POST /workflows/execute
377
+ if (method === 'POST' && normalizedPath === '/workflows/execute') {
378
+ const body = JSON.parse(await readBody(req));
379
+ if (!body.name) {
380
+ json(res, 400, { error: 'workflow name required' });
381
+ return;
382
+ }
383
+ // Execute in background
384
+ // We use a fixed or session-based ID if possible, but the agent is a singleton.
385
+ // We ensure it logs to its own transcript.
386
+ this.agent.runWorkflow(body.name).catch(e => console.error('Workflow execution error:', e));
387
+ json(res, 202, { status: 'triggered', workflow: body.name, sessionId: 'eden_session' });
388
+ return;
389
+ }
390
+ // DELETE /workspaces
391
+ if (method === 'DELETE' && normalizedPath === '/workspaces') {
392
+ const body = JSON.parse(await readBody(req));
393
+ if (!body.path) {
394
+ json(res, 400, { error: 'path required' });
395
+ return;
396
+ }
397
+ const wfile = path.join(os.homedir(), '.eden', 'workspaces.json');
398
+ let current = [];
399
+ try {
400
+ current = JSON.parse(await fs.readFile(wfile, 'utf8'));
401
+ }
402
+ catch { }
403
+ current = current.filter(p => p !== body.path);
404
+ await fs.writeFile(wfile, JSON.stringify(current, null, 2));
405
+ json(res, 200, { status: 'removed', workspaces: current });
406
+ return;
407
+ }
408
+ // POST /orchestrate
409
+ if (method === 'POST' && normalizedPath === '/orchestrate') {
410
+ const body = JSON.parse(await readBody(req));
411
+ if (!body.tasks || !Array.isArray(body.tasks)) {
412
+ json(res, 400, { error: 'tasks array required' });
413
+ return;
414
+ }
415
+ json(res, 202, { status: 'orchestrating', tasksCount: body.tasks.length });
416
+ (async () => {
417
+ const { tools } = await import('./tools/index.js');
418
+ const orchestrateTool = tools.find((t) => t.definition.name === 'delegate_tasks');
419
+ if (orchestrateTool) {
420
+ try {
421
+ await orchestrateTool.handler({ tasks: body.tasks });
422
+ }
423
+ catch (e) {
424
+ console.error('Orchestration error:', e);
425
+ }
426
+ }
427
+ })();
428
+ return;
429
+ }
430
+ // POST /orchestrator/plan - Create a new orchestrated task
431
+ if (method === 'POST' && normalizedPath === '/orchestrator/plan') {
432
+ try {
433
+ const body = JSON.parse(await readBody(req));
434
+ if (!body.prompt) {
435
+ json(res, 400, { error: 'prompt is required' });
436
+ return;
437
+ }
438
+ const { TaskOrchestrator } = await import('./orchestrator.js');
439
+ const orchestrator = new TaskOrchestrator(this.agent, this.agent['options'].cwd);
440
+ await orchestrator.initialize();
441
+ const task = await orchestrator.planTask(body.prompt);
442
+ json(res, 200, {
443
+ success: true,
444
+ task,
445
+ message: `Created task with ${task.subtasks.length} subtasks`
446
+ });
447
+ }
448
+ catch (error) {
449
+ json(res, 500, { error: String(error) });
450
+ }
451
+ return;
452
+ }
453
+ // POST /orchestrator/execute - Execute a planned task
454
+ if (method === 'POST' && normalizedPath === '/orchestrator/execute') {
455
+ try {
456
+ const body = JSON.parse(await readBody(req));
457
+ if (!body.taskId) {
458
+ json(res, 400, { error: 'taskId is required' });
459
+ return;
460
+ }
461
+ const { TaskOrchestrator } = await import('./orchestrator.js');
462
+ const orchestrator = new TaskOrchestrator(this.agent, this.agent['options'].cwd);
463
+ await orchestrator.initialize();
464
+ const task = await orchestrator.loadTask(body.taskId);
465
+ if (!task) {
466
+ json(res, 404, { error: 'Task not found' });
467
+ return;
468
+ }
469
+ // Execute in background
470
+ json(res, 202, { status: 'executing', taskId: body.taskId });
471
+ (async () => {
472
+ try {
473
+ await orchestrator.executeAll();
474
+ }
475
+ catch (e) {
476
+ console.error('Orchestrator execution error:', e);
477
+ }
478
+ })();
479
+ }
480
+ catch (error) {
481
+ json(res, 500, { error: String(error) });
482
+ }
483
+ return;
484
+ }
485
+ // GET /orchestrator/progress - Get task progress
486
+ if (method === 'GET' && normalizedPath === '/orchestrator/progress') {
487
+ try {
488
+ const url = new URL(req.url || '/', `http://${req.headers.host}`);
489
+ const taskId = url.searchParams.get('taskId');
490
+ if (!taskId) {
491
+ json(res, 400, { error: 'taskId query parameter is required' });
492
+ return;
493
+ }
494
+ const { TaskOrchestrator } = await import('./orchestrator.js');
495
+ const orchestrator = new TaskOrchestrator(this.agent, this.agent['options'].cwd);
496
+ const task = await orchestrator.loadTask(taskId);
497
+ if (!task) {
498
+ json(res, 404, { error: 'Task not found' });
499
+ return;
500
+ }
501
+ const progress = orchestrator.getProgress();
502
+ json(res, 200, {
503
+ task,
504
+ progress,
505
+ logs: [] // TODO: Implement log streaming
506
+ });
507
+ }
508
+ catch (error) {
509
+ json(res, 500, { error: String(error) });
510
+ }
511
+ return;
512
+ }
513
+ // GET /permissions
514
+ if (method === 'GET' && normalizedPath === '/permissions') {
515
+ const perms = this.agent['permissionManager'].getPermissions();
516
+ json(res, 200, perms);
517
+ return;
518
+ }
519
+ // POST /permissions
520
+ if (method === 'POST' && normalizedPath === '/permissions') {
521
+ const body = JSON.parse(await readBody(req));
522
+ this.agent['permissionManager'].setPermissions(body);
523
+ json(res, 200, { status: 'updated', permissions: body });
524
+ return;
525
+ }
526
+ // GET /config
527
+ if (method === 'GET' && normalizedPath === '/config') {
528
+ json(res, 200, {
529
+ ollamaUrl: this.agent['options'].ollamaUrl,
530
+ model: this.agent['options'].model,
531
+ cwd: this.agent['options'].cwd,
532
+ telegramToken: this.agent['options'].telegramToken,
533
+ dryRun: this.agent['sandboxManager']['options'].dryRun,
534
+ useDocker: this.agent['sandboxManager']['options'].useDocker
535
+ });
536
+ return;
537
+ }
538
+ // POST /config
539
+ if (method === 'POST' && normalizedPath === '/config') {
540
+ const body = JSON.parse(await readBody(req));
541
+ if (body.model)
542
+ this.agent['options'].model = body.model;
543
+ if (body.ollamaUrl)
544
+ this.agent['options'].ollamaUrl = body.ollamaUrl;
545
+ if (body.telegramToken !== undefined) {
546
+ this.agent['options'].telegramToken = body.telegramToken;
547
+ if (body.telegramToken) {
548
+ this.agent.getTelegramManager().start(body.telegramToken);
549
+ }
550
+ else {
551
+ this.agent.getTelegramManager().stop();
552
+ }
553
+ }
554
+ if (body.dryRun !== undefined) {
555
+ this.agent.getSandboxManager().setDryRun(body.dryRun);
556
+ }
557
+ if (body.useDocker !== undefined) {
558
+ this.agent.getSandboxManager().setUseDocker(body.useDocker);
559
+ }
560
+ json(res, 200, { status: 'updated', config: body });
561
+ return;
562
+ }
563
+ // POST /chat — create session OR send message (compatible with web client)
564
+ if (method === 'POST' && normalizedPath === '/chat') {
565
+ const body = JSON.parse(await readBody(req));
566
+ // If message is provided, treat as direct message send (web client style)
567
+ if (body.message) {
568
+ const sid = body.sessionId || 'eden_session';
569
+ // Ensure session exists
570
+ if (!this.sessions.has(sid)) {
571
+ this.sessions.set(sid, { id: sid, messages: [], createdAt: new Date().toISOString() });
572
+ }
573
+ // Change agent CWD if workspace provided
574
+ if (body.workspace) {
575
+ this.agent.setCwd(body.workspace);
576
+ }
577
+ // Trigger agent workflow asynchronously (fire and forget for streaming)
578
+ (async () => {
579
+ try {
580
+ await this.agent.runSingleTurn(body.message);
581
+ }
582
+ catch (err) {
583
+ console.error('Agent error:', err);
584
+ }
585
+ })();
586
+ // Return immediately with session info
587
+ json(res, 200, {
588
+ sessionId: sid,
589
+ status: 'processing',
590
+ timestamp: new Date().toISOString()
591
+ });
592
+ return;
593
+ }
594
+ // Otherwise create new session
595
+ const sid = body.sessionId || `http_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
596
+ this.sessions.set(sid, { id: sid, messages: [], createdAt: new Date().toISOString() });
597
+ json(res, 200, { sessionId: sid, status: 'created' });
598
+ return;
599
+ }
600
+ // POST /chat/:id/message
601
+ const msgMatch = normalizedPath.match(/^\/chat\/([^/]+)\/message$/);
602
+ if (method === 'POST' && msgMatch) {
603
+ const sid = msgMatch[1];
604
+ const session = this.sessions.get(sid);
605
+ if (!session) {
606
+ json(res, 404, { error: 'Session not found' });
607
+ return;
608
+ }
609
+ const body = JSON.parse(await readBody(req));
610
+ if (!body.message) {
611
+ json(res, 400, { error: 'message is required' });
612
+ return;
613
+ }
614
+ // Change agent CWD if workspace provided
615
+ if (body.workspace) {
616
+ this.agent.setCwd(body.workspace);
617
+ }
618
+ // Trigger agent workflow
619
+ await this.agent.runSingleTurn(body.message);
620
+ // Grab transcript
621
+ const transcript = this.agent.getTranscript();
622
+ json(res, 200, {
623
+ sessionId: sid,
624
+ transcript: transcript, // Returns the full conversation history blocks
625
+ timestamp: new Date().toISOString()
626
+ });
627
+ return;
628
+ }
629
+ // GET /chat/:id/history
630
+ const histMatch = normalizedPath.match(/^\/chat\/([^/]+)\/history$/);
631
+ if (method === 'GET' && histMatch) {
632
+ const sid = histMatch[1];
633
+ // Auto-create session if it doesn't exist (for web client compatibility)
634
+ if (!this.sessions.has(sid)) {
635
+ this.sessions.set(sid, { id: sid, messages: [], createdAt: new Date().toISOString() });
636
+ }
637
+ const session = this.sessions.get(sid);
638
+ // Return the agent's transcript (shared across all sessions)
639
+ json(res, 200, { sessionId: session.id, transcript: this.agent.getTranscript() });
640
+ return;
641
+ }
642
+ // GET /chat/:id/stream - SSE streaming endpoint
643
+ const streamMatch = normalizedPath.match(/^\/chat\/([^/]+)\/stream$/);
644
+ if (method === 'GET' && streamMatch) {
645
+ const sid = streamMatch[1];
646
+ startSse(res);
647
+ // Send initial connection message
648
+ sse(res, { type: 'connected', sessionId: sid });
649
+ // Listen for real-time events from EventHub
650
+ const eventHandler = (event) => {
651
+ if (event.type === 'transcript_entry') {
652
+ sse(res, { type: 'message', data: event.data });
653
+ }
654
+ else if (event.type === 'tool_call' || event.type === 'tool_result') {
655
+ sse(res, { type: 'message', data: event.data });
656
+ }
657
+ else if (event.type === 'stream_start' || event.type === 'stream_chunk' || event.type === 'stream_end') {
658
+ // Forward streaming events for real-time character display
659
+ sse(res, { type: event.type, data: event.data });
660
+ }
661
+ };
662
+ eventHub.onEvent(eventHandler);
663
+ // Clean up on client disconnect
664
+ res.on('close', () => {
665
+ eventHub.removeListener('eden_event', eventHandler);
666
+ });
667
+ return;
668
+ }
669
+ // DELETE /chat/:id
670
+ const delMatch = normalizedPath.match(/^\/chat\/([^/]+)$/);
671
+ if (method === 'DELETE' && delMatch) {
672
+ this.sessions.delete(delMatch[1]);
673
+ json(res, 200, { status: 'deleted', sessionId: delMatch[1] });
674
+ return;
675
+ }
676
+ // GET /stats
677
+ if (method === 'GET' && normalizedPath === '/stats') {
678
+ const days = Number(url.searchParams.get('days') || 7);
679
+ json(res, 200, { days, totalSessions: this.sessions.size, totalTokens: 0, totalCost: 0 });
680
+ return;
681
+ }
682
+ // GET /analytics
683
+ if (method === 'GET' && normalizedPath === '/analytics') {
684
+ json(res, 200, analyticsEngine.getStats());
685
+ return;
686
+ }
687
+ // GET /sessions
688
+ if (method === 'GET' && normalizedPath === '/sessions') {
689
+ const list = Array.from(this.sessions.values()).map(s => ({
690
+ id: s.id, messageCount: s.messages.length, createdAt: s.createdAt,
691
+ }));
692
+ json(res, 200, { sessions: list });
693
+ return;
694
+ }
695
+ // POST /sessions - Save session
696
+ if (method === 'POST' && normalizedPath === '/sessions') {
697
+ const body = JSON.parse(await readBody(req));
698
+ this.sessions.set(body.id, {
699
+ id: body.id,
700
+ messages: body.messages || [],
701
+ createdAt: body.createdAt || new Date().toISOString()
702
+ });
703
+ json(res, 200, { status: 'saved', sessionId: body.id });
704
+ return;
705
+ }
706
+ // GET /sessions/all (Persistent)
707
+ if (method === 'GET' && normalizedPath === '/sessions/all') {
708
+ const list = await this.agent.listPersistentSessions();
709
+ json(res, 200, { sessions: list });
710
+ return;
711
+ }
712
+ // GET /tasks
713
+ if (method === 'GET' && normalizedPath === '/tasks') {
714
+ json(res, 200, { tasks: this.agent.getActiveTasks() });
715
+ return;
716
+ }
717
+ // GET /search?q=...
718
+ if (method === 'GET' && normalizedPath === '/search') {
719
+ const query = url.searchParams.get('q') || '';
720
+ const results = this.agent.getCodeIndexer().search(query);
721
+ json(res, 200, results);
722
+ return;
723
+ }
724
+ // GET /swarm/workers
725
+ if (method === 'GET' && normalizedPath === '/swarm/workers') {
726
+ json(res, 200, { workers: this.agent['swarmManager'].listWorkers() });
727
+ return;
728
+ }
729
+ // 404
730
+ json(res, 404, { error: 'Not found', method, path: reqPath });
731
+ }
732
+ catch (err) {
733
+ const message = err instanceof Error ? err.message : String(err);
734
+ json(res, 500, { error: message });
735
+ }
736
+ }
737
+ // ── lifecycle ──────────────────────────────────────────────────────
738
+ async start() {
739
+ return new Promise((resolve, reject) => {
740
+ this.httpServer.listen(this.options.port, this.options.hostname, () => {
741
+ const base = `http://${this.options.hostname}:${this.options.port}`;
742
+ console.log(`\n🚀 Eden Server v3.0.0`);
743
+ console.log(` ${base}`);
744
+ console.log(this.options.password
745
+ ? ` Auth: Enabled (user: ${this.options.username || 'eden'})`
746
+ : ` Auth: Disabled`);
747
+ console.log(`\n Endpoints:`);
748
+ console.log(` GET /health Health check`);
749
+ console.log(` GET /agents List agents`);
750
+ console.log(` GET /permissions Current permissions`);
751
+ console.log(` POST /chat Create session`);
752
+ console.log(` POST /chat/:id/message Send message`);
753
+ console.log(` GET /chat/:id/history Session history`);
754
+ console.log(` DEL /chat/:id Delete session`);
755
+ console.log(` GET /sessions List sessions`);
756
+ console.log(` GET /stats Usage stats`);
757
+ console.log('');
758
+ resolve();
759
+ });
760
+ this.httpServer.on('error', reject);
761
+ });
762
+ }
763
+ async stop() {
764
+ return new Promise((resolve) => {
765
+ this.sessions.clear();
766
+ this.httpServer.close(() => {
767
+ console.log('Server stopped');
768
+ resolve();
769
+ });
770
+ });
771
+ }
772
+ }
773
+ export function createEdenServer(agent, options) {
774
+ return new EdenServer(agent, options);
775
+ }
776
+ //# sourceMappingURL=server.js.map