@aigne/cli 1.60.0-beta → 1.74.0-beta

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 (360) hide show
  1. package/README.md +12 -12
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  3. package/dist/bunwrapper.cjs +22 -0
  4. package/dist/bunwrapper.d.cts +1 -0
  5. package/dist/bunwrapper.d.mts +1 -0
  6. package/dist/bunwrapper.mjs +23 -0
  7. package/dist/bunwrapper.mjs.map +1 -0
  8. package/dist/cli.cjs +42 -0
  9. package/dist/cli.d.cts +9 -0
  10. package/dist/cli.d.cts.map +1 -0
  11. package/dist/cli.d.mts +10 -0
  12. package/dist/cli.d.mts.map +1 -0
  13. package/dist/cli.mjs +41 -0
  14. package/dist/cli.mjs.map +1 -0
  15. package/dist/commands/aigne.cjs +23 -0
  16. package/dist/commands/aigne.mjs +22 -0
  17. package/dist/commands/aigne.mjs.map +1 -0
  18. package/dist/commands/app/agent.cjs +117 -0
  19. package/dist/commands/app/agent.mjs +113 -0
  20. package/dist/commands/app/agent.mjs.map +1 -0
  21. package/dist/commands/app/app.cjs +92 -0
  22. package/dist/commands/app/app.mjs +90 -0
  23. package/dist/commands/app/app.mjs.map +1 -0
  24. package/dist/commands/app/cli.cjs +6 -0
  25. package/dist/commands/app/cli.d.cts +1 -0
  26. package/dist/commands/app/cli.d.mts +1 -0
  27. package/dist/commands/app/cli.mjs +8 -0
  28. package/dist/commands/app/cli.mjs.map +1 -0
  29. package/dist/commands/app/upgrade.cjs +243 -0
  30. package/dist/commands/app/upgrade.mjs +240 -0
  31. package/dist/commands/app/upgrade.mjs.map +1 -0
  32. package/dist/commands/app.cjs +53 -0
  33. package/dist/commands/app.mjs +53 -0
  34. package/dist/commands/app.mjs.map +1 -0
  35. package/dist/commands/create.cjs +66 -0
  36. package/dist/commands/create.mjs +65 -0
  37. package/dist/commands/create.mjs.map +1 -0
  38. package/dist/commands/deploy.cjs +237 -0
  39. package/dist/commands/deploy.mjs +237 -0
  40. package/dist/commands/deploy.mjs.map +1 -0
  41. package/dist/commands/eval.cjs +88 -0
  42. package/dist/commands/eval.mjs +88 -0
  43. package/dist/commands/eval.mjs.map +1 -0
  44. package/dist/commands/hub.cjs +297 -0
  45. package/dist/commands/hub.mjs +294 -0
  46. package/dist/commands/hub.mjs.map +1 -0
  47. package/dist/commands/observe.cjs +49 -0
  48. package/dist/commands/observe.mjs +46 -0
  49. package/dist/commands/observe.mjs.map +1 -0
  50. package/dist/commands/run-skill.cjs +84 -0
  51. package/dist/commands/run-skill.mjs +81 -0
  52. package/dist/commands/run-skill.mjs.map +1 -0
  53. package/dist/commands/run.cjs +172 -0
  54. package/dist/commands/run.mjs +171 -0
  55. package/dist/commands/run.mjs.map +1 -0
  56. package/dist/commands/serve-mcp.cjs +68 -0
  57. package/dist/commands/serve-mcp.mjs +67 -0
  58. package/dist/commands/serve-mcp.mjs.map +1 -0
  59. package/dist/commands/test.cjs +40 -0
  60. package/dist/commands/test.mjs +39 -0
  61. package/dist/commands/test.mjs.map +1 -0
  62. package/dist/constants.cjs +28 -0
  63. package/dist/constants.d.cts +9 -0
  64. package/dist/constants.d.cts.map +1 -0
  65. package/dist/constants.d.mts +9 -0
  66. package/dist/constants.d.mts.map +1 -0
  67. package/dist/constants.mjs +24 -0
  68. package/dist/constants.mjs.map +1 -0
  69. package/dist/global.d.cjs +0 -0
  70. package/dist/global.d.cts +6 -0
  71. package/dist/global.d.cts.map +1 -0
  72. package/dist/global.d.mts +6 -0
  73. package/dist/global.d.mts.map +1 -0
  74. package/dist/index.cjs +0 -0
  75. package/dist/index.d.cts +2 -0
  76. package/dist/index.d.mts +2 -0
  77. package/dist/index.mjs +1 -0
  78. package/dist/tracer/terminal.cjs +336 -0
  79. package/dist/tracer/terminal.mjs +332 -0
  80. package/dist/tracer/terminal.mjs.map +1 -0
  81. package/dist/type.cjs +0 -0
  82. package/dist/type.d.cts +10 -0
  83. package/dist/type.d.cts.map +1 -0
  84. package/dist/type.d.mts +10 -0
  85. package/dist/type.d.mts.map +1 -0
  86. package/dist/type.mjs +1 -0
  87. package/dist/ui/utils/terminal-input.cjs +145 -0
  88. package/dist/ui/utils/terminal-input.mjs +144 -0
  89. package/dist/ui/utils/terminal-input.mjs.map +1 -0
  90. package/dist/ui/utils/text-buffer.cjs +865 -0
  91. package/dist/ui/utils/text-buffer.mjs +865 -0
  92. package/dist/ui/utils/text-buffer.mjs.map +1 -0
  93. package/dist/ui/utils/text-utils.cjs +85 -0
  94. package/dist/ui/utils/text-utils.mjs +78 -0
  95. package/dist/ui/utils/text-utils.mjs.map +1 -0
  96. package/dist/utils/agent-v1.cjs +180 -0
  97. package/dist/utils/agent-v1.d.cts +138 -0
  98. package/dist/utils/agent-v1.d.cts.map +1 -0
  99. package/dist/utils/agent-v1.d.mts +138 -0
  100. package/dist/utils/agent-v1.d.mts.map +1 -0
  101. package/dist/utils/agent-v1.mjs +179 -0
  102. package/dist/utils/agent-v1.mjs.map +1 -0
  103. package/dist/utils/aigne-hub/constants.cjs +22 -0
  104. package/dist/utils/aigne-hub/constants.mjs +18 -0
  105. package/dist/utils/aigne-hub/constants.mjs.map +1 -0
  106. package/dist/utils/aigne-hub/credential.cjs +179 -0
  107. package/dist/utils/aigne-hub/credential.mjs +175 -0
  108. package/dist/utils/aigne-hub/credential.mjs.map +1 -0
  109. package/dist/utils/aigne-hub/crypto.cjs +41 -0
  110. package/dist/utils/aigne-hub/crypto.mjs +33 -0
  111. package/dist/utils/aigne-hub/crypto.mjs.map +1 -0
  112. package/dist/utils/aigne-hub/model.cjs +112 -0
  113. package/dist/utils/aigne-hub/model.d.cts +19 -0
  114. package/dist/utils/aigne-hub/model.d.cts.map +1 -0
  115. package/dist/utils/aigne-hub/model.d.mts +19 -0
  116. package/dist/utils/aigne-hub/model.d.mts.map +1 -0
  117. package/dist/utils/aigne-hub/model.mjs +106 -0
  118. package/dist/utils/aigne-hub/model.mjs.map +1 -0
  119. package/dist/utils/aigne-hub/store/file.cjs +64 -0
  120. package/dist/utils/aigne-hub/store/file.mjs +64 -0
  121. package/dist/utils/aigne-hub/store/file.mjs.map +1 -0
  122. package/dist/utils/aigne-hub/store/index.cjs +37 -0
  123. package/dist/utils/aigne-hub/store/index.mjs +37 -0
  124. package/dist/utils/aigne-hub/store/index.mjs.map +1 -0
  125. package/dist/utils/aigne-hub/store/keytar.cjs +61 -0
  126. package/dist/utils/aigne-hub/store/keytar.mjs +61 -0
  127. package/dist/utils/aigne-hub/store/keytar.mjs.map +1 -0
  128. package/dist/utils/aigne-hub/store/migrate.cjs +46 -0
  129. package/dist/utils/aigne-hub/store/migrate.mjs +45 -0
  130. package/dist/utils/aigne-hub/store/migrate.mjs.map +1 -0
  131. package/dist/utils/aigne-hub/type.d.cts +18 -0
  132. package/dist/utils/aigne-hub/type.d.cts.map +1 -0
  133. package/dist/utils/aigne-hub/type.d.mts +18 -0
  134. package/dist/utils/aigne-hub/type.d.mts.map +1 -0
  135. package/dist/utils/aigne-hub-user.cjs +11 -0
  136. package/dist/utils/aigne-hub-user.d.cts +23 -0
  137. package/dist/utils/aigne-hub-user.d.cts.map +1 -0
  138. package/dist/utils/aigne-hub-user.d.mts +23 -0
  139. package/dist/utils/aigne-hub-user.d.mts.map +1 -0
  140. package/dist/utils/aigne-hub-user.mjs +11 -0
  141. package/dist/utils/aigne-hub-user.mjs.map +1 -0
  142. package/dist/utils/ascii-logo.cjs +30 -0
  143. package/dist/utils/ascii-logo.d.cts +5 -0
  144. package/dist/utils/ascii-logo.d.cts.map +1 -0
  145. package/dist/utils/ascii-logo.d.mts +5 -0
  146. package/dist/utils/ascii-logo.d.mts.map +1 -0
  147. package/dist/utils/{ascii-logo.js → ascii-logo.mjs} +13 -3
  148. package/dist/utils/ascii-logo.mjs.map +1 -0
  149. package/dist/utils/download.cjs +25 -0
  150. package/dist/utils/download.d.cts +7 -0
  151. package/dist/utils/download.d.cts.map +1 -0
  152. package/dist/utils/download.d.mts +7 -0
  153. package/dist/utils/download.d.mts.map +1 -0
  154. package/dist/utils/download.mjs +25 -0
  155. package/dist/utils/download.mjs.map +1 -0
  156. package/dist/utils/evaluation/core.cjs +84 -0
  157. package/dist/utils/evaluation/core.mjs +84 -0
  158. package/dist/utils/evaluation/core.mjs.map +1 -0
  159. package/dist/utils/evaluation/dataset.cjs +47 -0
  160. package/dist/utils/evaluation/dataset.mjs +46 -0
  161. package/dist/utils/evaluation/dataset.mjs.map +1 -0
  162. package/dist/utils/evaluation/evaluator.cjs +109 -0
  163. package/dist/utils/evaluation/{evaluator.js → evaluator.mjs} +48 -45
  164. package/dist/utils/evaluation/evaluator.mjs.map +1 -0
  165. package/dist/utils/evaluation/reporter.cjs +225 -0
  166. package/dist/utils/evaluation/reporter.mjs +220 -0
  167. package/dist/utils/evaluation/reporter.mjs.map +1 -0
  168. package/dist/utils/evaluation/runner.cjs +85 -0
  169. package/dist/utils/evaluation/runner.mjs +85 -0
  170. package/dist/utils/evaluation/runner.mjs.map +1 -0
  171. package/dist/utils/get-url-origin.cjs +12 -0
  172. package/dist/utils/get-url-origin.d.cts +5 -0
  173. package/dist/utils/get-url-origin.d.cts.map +1 -0
  174. package/dist/utils/get-url-origin.d.mts +5 -0
  175. package/dist/utils/get-url-origin.d.mts.map +1 -0
  176. package/dist/utils/get-url-origin.mjs +12 -0
  177. package/dist/utils/get-url-origin.mjs.map +1 -0
  178. package/dist/utils/inquirer/checkbox.cjs +265 -0
  179. package/dist/utils/inquirer/checkbox.mjs +262 -0
  180. package/dist/utils/inquirer/checkbox.mjs.map +1 -0
  181. package/dist/utils/listr.cjs +226 -0
  182. package/dist/utils/listr.d.cts +71 -0
  183. package/dist/utils/listr.d.cts.map +1 -0
  184. package/dist/utils/listr.d.mts +71 -0
  185. package/dist/utils/listr.d.mts.map +1 -0
  186. package/dist/utils/listr.mjs +222 -0
  187. package/dist/utils/listr.mjs.map +1 -0
  188. package/dist/utils/load-aigne.cjs +77 -0
  189. package/dist/utils/load-aigne.d.cts +29 -0
  190. package/dist/utils/load-aigne.d.cts.map +1 -0
  191. package/dist/utils/load-aigne.d.mts +29 -0
  192. package/dist/utils/load-aigne.d.mts.map +1 -0
  193. package/dist/utils/load-aigne.mjs +74 -0
  194. package/dist/utils/load-aigne.mjs.map +1 -0
  195. package/dist/utils/run-chat-loop.cjs +90 -0
  196. package/dist/utils/run-chat-loop.d.cts +20 -0
  197. package/dist/utils/run-chat-loop.d.cts.map +1 -0
  198. package/dist/utils/run-chat-loop.d.mts +20 -0
  199. package/dist/utils/run-chat-loop.d.mts.map +1 -0
  200. package/dist/utils/run-chat-loop.mjs +89 -0
  201. package/dist/utils/run-chat-loop.mjs.map +1 -0
  202. package/dist/utils/run-with-aigne.cjs +131 -0
  203. package/dist/utils/run-with-aigne.d.cts +46 -0
  204. package/dist/utils/run-with-aigne.d.cts.map +1 -0
  205. package/dist/utils/run-with-aigne.d.mts +46 -0
  206. package/dist/utils/run-with-aigne.d.mts.map +1 -0
  207. package/dist/utils/run-with-aigne.mjs +126 -0
  208. package/dist/utils/run-with-aigne.mjs.map +1 -0
  209. package/dist/utils/serve-mcp.cjs +91 -0
  210. package/dist/utils/serve-mcp.d.cts +20 -0
  211. package/dist/utils/serve-mcp.d.cts.map +1 -0
  212. package/dist/utils/serve-mcp.d.mts +20 -0
  213. package/dist/utils/serve-mcp.d.mts.map +1 -0
  214. package/dist/utils/serve-mcp.mjs +89 -0
  215. package/dist/utils/serve-mcp.mjs.map +1 -0
  216. package/dist/utils/spinner.cjs +19 -0
  217. package/dist/utils/spinner.d.cts +5 -0
  218. package/dist/utils/spinner.d.cts.map +1 -0
  219. package/dist/utils/spinner.d.mts +5 -0
  220. package/dist/utils/spinner.d.mts.map +1 -0
  221. package/dist/utils/spinner.mjs +19 -0
  222. package/dist/utils/spinner.mjs.map +1 -0
  223. package/dist/utils/string-utils.cjs +11 -0
  224. package/dist/utils/string-utils.d.cts +5 -0
  225. package/dist/utils/string-utils.d.cts.map +1 -0
  226. package/dist/utils/string-utils.d.mts +5 -0
  227. package/dist/utils/string-utils.d.mts.map +1 -0
  228. package/dist/utils/string-utils.mjs +10 -0
  229. package/dist/utils/string-utils.mjs.map +1 -0
  230. package/dist/utils/time.cjs +14 -0
  231. package/dist/utils/time.d.cts +5 -0
  232. package/dist/utils/time.d.cts.map +1 -0
  233. package/dist/utils/time.d.mts +5 -0
  234. package/dist/utils/time.d.mts.map +1 -0
  235. package/dist/utils/time.mjs +14 -0
  236. package/dist/utils/time.mjs.map +1 -0
  237. package/dist/utils/url.cjs +8 -0
  238. package/dist/utils/url.d.cts +5 -0
  239. package/dist/utils/url.d.cts.map +1 -0
  240. package/dist/utils/url.d.mts +5 -0
  241. package/dist/utils/url.d.mts.map +1 -0
  242. package/dist/utils/url.mjs +8 -0
  243. package/dist/utils/url.mjs.map +1 -0
  244. package/dist/utils/yargs.cjs +191 -0
  245. package/dist/utils/yargs.d.cts +96 -0
  246. package/dist/utils/yargs.d.cts.map +1 -0
  247. package/dist/utils/yargs.d.mts +96 -0
  248. package/dist/utils/yargs.d.mts.map +1 -0
  249. package/dist/utils/yargs.mjs +186 -0
  250. package/dist/utils/yargs.mjs.map +1 -0
  251. package/package.json +122 -45
  252. package/CHANGELOG.md +0 -5019
  253. package/dist/bunwrapper.d.ts +0 -2
  254. package/dist/bunwrapper.js +0 -18
  255. package/dist/cli.d.ts +0 -7
  256. package/dist/cli.js +0 -42
  257. package/dist/commands/aigne.d.ts +0 -4
  258. package/dist/commands/aigne.js +0 -35
  259. package/dist/commands/app/agent.d.ts +0 -26
  260. package/dist/commands/app/agent.js +0 -122
  261. package/dist/commands/app/app.d.ts +0 -7
  262. package/dist/commands/app/app.js +0 -92
  263. package/dist/commands/app/cli.d.ts +0 -1
  264. package/dist/commands/app/cli.js +0 -2
  265. package/dist/commands/app/upgrade.d.ts +0 -54
  266. package/dist/commands/app/upgrade.js +0 -236
  267. package/dist/commands/app.d.ts +0 -4
  268. package/dist/commands/app.js +0 -54
  269. package/dist/commands/create.d.ts +0 -6
  270. package/dist/commands/create.js +0 -74
  271. package/dist/commands/deploy.d.ts +0 -11
  272. package/dist/commands/deploy.js +0 -255
  273. package/dist/commands/eval.d.ts +0 -11
  274. package/dist/commands/eval.js +0 -110
  275. package/dist/commands/hub.d.ts +0 -3
  276. package/dist/commands/hub.js +0 -323
  277. package/dist/commands/observe.d.ts +0 -7
  278. package/dist/commands/observe.js +0 -41
  279. package/dist/commands/run-skill.d.ts +0 -6
  280. package/dist/commands/run-skill.js +0 -102
  281. package/dist/commands/run.d.ts +0 -9
  282. package/dist/commands/run.js +0 -187
  283. package/dist/commands/serve-mcp.d.ts +0 -20
  284. package/dist/commands/serve-mcp.js +0 -67
  285. package/dist/commands/test.d.ts +0 -9
  286. package/dist/commands/test.js +0 -33
  287. package/dist/constants.d.ts +0 -7
  288. package/dist/constants.js +0 -21
  289. package/dist/index.d.ts +0 -1
  290. package/dist/index.js +0 -1
  291. package/dist/tracer/terminal.d.ts +0 -62
  292. package/dist/tracer/terminal.js +0 -404
  293. package/dist/type.d.ts +0 -5
  294. package/dist/type.js +0 -1
  295. package/dist/ui/utils/terminal-input.d.ts +0 -19
  296. package/dist/ui/utils/terminal-input.js +0 -123
  297. package/dist/ui/utils/text-buffer.d.ts +0 -87
  298. package/dist/ui/utils/text-buffer.js +0 -1059
  299. package/dist/ui/utils/text-utils.d.ts +0 -37
  300. package/dist/ui/utils/text-utils.js +0 -185
  301. package/dist/utils/agent-v1.d.ts +0 -134
  302. package/dist/utils/agent-v1.js +0 -213
  303. package/dist/utils/aigne-hub/constants.d.ts +0 -6
  304. package/dist/utils/aigne-hub/constants.js +0 -12
  305. package/dist/utils/aigne-hub/credential.d.ts +0 -20
  306. package/dist/utils/aigne-hub/credential.js +0 -182
  307. package/dist/utils/aigne-hub/crypto.d.ts +0 -4
  308. package/dist/utils/aigne-hub/crypto.js +0 -30
  309. package/dist/utils/aigne-hub/model.d.ts +0 -13
  310. package/dist/utils/aigne-hub/model.js +0 -122
  311. package/dist/utils/aigne-hub/store/file.d.ts +0 -15
  312. package/dist/utils/aigne-hub/store/file.js +0 -69
  313. package/dist/utils/aigne-hub/store/index.d.ts +0 -5
  314. package/dist/utils/aigne-hub/store/index.js +0 -43
  315. package/dist/utils/aigne-hub/store/keytar.d.ts +0 -15
  316. package/dist/utils/aigne-hub/store/keytar.js +0 -67
  317. package/dist/utils/aigne-hub/store/migrate.d.ts +0 -2
  318. package/dist/utils/aigne-hub/store/migrate.js +0 -57
  319. package/dist/utils/aigne-hub/type.d.ts +0 -38
  320. package/dist/utils/aigne-hub/type.js +0 -1
  321. package/dist/utils/aigne-hub-user.d.ts +0 -16
  322. package/dist/utils/aigne-hub-user.js +0 -10
  323. package/dist/utils/ascii-logo.d.ts +0 -1
  324. package/dist/utils/download.d.ts +0 -3
  325. package/dist/utils/download.js +0 -19
  326. package/dist/utils/evaluation/core.d.ts +0 -8
  327. package/dist/utils/evaluation/core.js +0 -83
  328. package/dist/utils/evaluation/dataset.d.ts +0 -15
  329. package/dist/utils/evaluation/dataset.js +0 -61
  330. package/dist/utils/evaluation/evaluator.d.ts +0 -9
  331. package/dist/utils/evaluation/reporter.d.ts +0 -28
  332. package/dist/utils/evaluation/reporter.js +0 -221
  333. package/dist/utils/evaluation/runner.d.ts +0 -16
  334. package/dist/utils/evaluation/runner.js +0 -129
  335. package/dist/utils/evaluation/type.d.ts +0 -69
  336. package/dist/utils/evaluation/type.js +0 -1
  337. package/dist/utils/get-url-origin.d.ts +0 -1
  338. package/dist/utils/get-url-origin.js +0 -8
  339. package/dist/utils/inquirer/checkbox.d.ts +0 -55
  340. package/dist/utils/inquirer/checkbox.js +0 -319
  341. package/dist/utils/listr.d.ts +0 -64
  342. package/dist/utils/listr.js +0 -265
  343. package/dist/utils/load-aigne.d.ts +0 -18
  344. package/dist/utils/load-aigne.js +0 -80
  345. package/dist/utils/run-chat-loop.d.ts +0 -15
  346. package/dist/utils/run-chat-loop.js +0 -87
  347. package/dist/utils/run-with-aigne.d.ts +0 -27
  348. package/dist/utils/run-with-aigne.js +0 -157
  349. package/dist/utils/serve-mcp.d.ts +0 -9
  350. package/dist/utils/serve-mcp.js +0 -93
  351. package/dist/utils/spinner.d.ts +0 -1
  352. package/dist/utils/spinner.js +0 -14
  353. package/dist/utils/string-utils.d.ts +0 -1
  354. package/dist/utils/string-utils.js +0 -4
  355. package/dist/utils/time.d.ts +0 -1
  356. package/dist/utils/time.js +0 -12
  357. package/dist/utils/url.d.ts +0 -1
  358. package/dist/utils/url.js +0 -3
  359. package/dist/utils/yargs.d.ts +0 -94
  360. package/dist/utils/yargs.js +0 -210
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawnSync } from "node:child_process";
3
- import { argv } from "node:process";
4
- if (!getBunVersion()) {
5
- spawnSync("npx", ["-y", "bun", ...argv.slice(2)], { stdio: "inherit" });
6
- }
7
- else {
8
- spawnSync("bun", argv.slice(2), { stdio: "inherit" });
9
- }
10
- function getBunVersion() {
11
- try {
12
- const { stdout } = spawnSync("bun", ["--version"], { stdio: "pipe" });
13
- return stdout.toString().trim() || undefined;
14
- }
15
- catch {
16
- return false;
17
- }
18
- }
package/dist/cli.d.ts DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- declare const _default: Promise<{
3
- [x: string]: unknown;
4
- _: (string | number)[];
5
- $0: string;
6
- }>;
7
- export default _default;
package/dist/cli.js DELETED
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env node
2
- import { existsSync, realpathSync, statSync } from "node:fs";
3
- import { LogLevel, logger } from "@aigne/core/utils/logger.js";
4
- import chalk from "chalk";
5
- import { config } from "dotenv-flow";
6
- import { createAIGNECommand } from "./commands/aigne.js";
7
- import { highlightUrl } from "./utils/string-utils.js";
8
- config({ silent: true });
9
- function getAIGNEFilePath() {
10
- let file = process.argv[2];
11
- if (file) {
12
- if (!existsSync(file))
13
- return;
14
- file = realpathSync(file);
15
- if (statSync(file).isFile())
16
- return file;
17
- }
18
- }
19
- const aigneFilePath = getAIGNEFilePath();
20
- const argv = process.argv.slice(aigneFilePath ? 3 : 2);
21
- export default createAIGNECommand({ argv, aigneFilePath })
22
- .fail((message, error, yargs) => {
23
- // We catch all errors below, here just print the help message non-error case like demandCommand
24
- if (!error) {
25
- yargs.showHelp();
26
- console.error(`\n${message}`);
27
- process.exit(1);
28
- }
29
- })
30
- .parseAsync(argv)
31
- .catch((error) => {
32
- if (error.name !== "ExitPromptError") {
33
- console.log(""); // Add an empty line for better readability
34
- if (logger.enabled(LogLevel.ERROR)) {
35
- console.error(chalk.red(error.stack));
36
- }
37
- else {
38
- console.error(`${chalk.red("Error:")} ${highlightUrl(error.message)}`);
39
- }
40
- }
41
- process.exit(1);
42
- });
@@ -1,4 +0,0 @@
1
- export declare function createAIGNECommand(options?: {
2
- argv?: string[];
3
- aigneFilePath?: string;
4
- }): import("yargs").Argv<{}>;
@@ -1,35 +0,0 @@
1
- import yargs from "yargs";
2
- import { AIGNE_CLI_VERSION } from "../constants.js";
3
- import { asciiLogo } from "../utils/ascii-logo.js";
4
- import { createAppCommands } from "./app.js";
5
- import { createCreateCommand } from "./create.js";
6
- import { createDeployCommands } from "./deploy.js";
7
- import { createEvalCommand } from "./eval.js";
8
- import { createHubCommand } from "./hub.js";
9
- import { createObservabilityCommand } from "./observe.js";
10
- import { createRunCommand } from "./run.js";
11
- import { createRunSkillCommand } from "./run-skill.js";
12
- import { createServeMCPCommand } from "./serve-mcp.js";
13
- import { createTestCommand } from "./test.js";
14
- export function createAIGNECommand(options) {
15
- return (yargs()
16
- .scriptName("aigne")
17
- .usage(`${asciiLogo}\n$0 <command> [options]`)
18
- .version(AIGNE_CLI_VERSION)
19
- // default command: when user runs `aigne` without subcommand, behave like `aigne run`
20
- .command(createRunCommand(options))
21
- .command(createRunSkillCommand())
22
- .command(createEvalCommand(options))
23
- .command(createTestCommand(options))
24
- .command(createCreateCommand())
25
- .command(createServeMCPCommand(options))
26
- .command(createObservabilityCommand())
27
- .command(createAppCommands(options))
28
- .command(createHubCommand())
29
- .command(createDeployCommands())
30
- .demandCommand()
31
- .version(false)
32
- .alias("help", "h")
33
- .wrap(null)
34
- .strict());
35
- }
@@ -1,26 +0,0 @@
1
- import type { Agent, AIGNE, Message } from "@aigne/core";
2
- import type { CLIAgent } from "@aigne/core/utils/agent-utils.js";
3
- import type { CommandModule } from "yargs";
4
- import { type AgentRunCommonOptions } from "../../utils/yargs.js";
5
- export declare const serveMcpCommandModule: ({ aigne, name, }: {
6
- aigne: AIGNE;
7
- name: string;
8
- }) => CommandModule<unknown, {
9
- host: string;
10
- port?: number;
11
- pathname: string;
12
- }>;
13
- export declare const agentCommandModule: ({ aigne, agent, interactive, }: {
14
- aigne: AIGNE;
15
- agent: Agent;
16
- interactive?: boolean;
17
- }) => CommandModule<unknown, AgentRunCommonOptions>;
18
- export declare const cliAgentCommandModule: ({ aigne, cliAgent, }: {
19
- aigne: AIGNE;
20
- cliAgent: CLIAgent<Agent>;
21
- }) => CommandModule<unknown, AgentRunCommonOptions>;
22
- export declare function invokeAgent(options: {
23
- aigne: AIGNE;
24
- agent: Agent;
25
- input: Message & AgentRunCommonOptions;
26
- }): Promise<void>;
@@ -1,122 +0,0 @@
1
- import assert from "node:assert";
2
- import { DEFAULT_USER_ID } from "@aigne/cli/constants.js";
3
- import { logger } from "@aigne/core/utils/logger.js";
4
- import { v7 } from "@aigne/uuid";
5
- import { runAgentWithAIGNE } from "../../utils/run-with-aigne.js";
6
- import { parseAgentInput, withAgentInputSchema, } from "../../utils/yargs.js";
7
- import { serveMCPServerFromDir } from "../serve-mcp.js";
8
- export const serveMcpCommandModule = ({ aigne, name, }) => ({
9
- command: "serve-mcp",
10
- describe: `Serve ${name} a MCP server (streamable http)`,
11
- builder: (yargs) => {
12
- return yargs
13
- .option("host", {
14
- describe: "Host to run the MCP server on, use 0.0.0.0 to publicly expose the server",
15
- type: "string",
16
- default: "localhost",
17
- })
18
- .option("port", {
19
- describe: "Port to run the MCP server on",
20
- type: "number",
21
- })
22
- .option("pathname", {
23
- describe: "Pathname to the service",
24
- type: "string",
25
- default: "/mcp",
26
- });
27
- },
28
- handler: async (options) => {
29
- await serveMCPServerFromDir({
30
- ...options,
31
- aigne,
32
- });
33
- },
34
- });
35
- export const agentCommandModule = ({ aigne, agent, interactive, }) => {
36
- return {
37
- command: agent.name,
38
- aliases: agent.alias || [],
39
- describe: agent.description || "",
40
- builder: async (yargs) => {
41
- return withAgentInputSchema(yargs, {
42
- inputSchema: agent.inputSchema,
43
- optionalInputs: interactive && "inputKey" in agent && typeof agent.inputKey === "string"
44
- ? [agent.inputKey]
45
- : [],
46
- });
47
- },
48
- handler: async (options) => {
49
- if (options.logLevel)
50
- logger.level = options.logLevel;
51
- await invokeAgent({
52
- aigne,
53
- agent,
54
- input: { ...options, interactive: interactive ?? options.interactive },
55
- });
56
- },
57
- };
58
- };
59
- export const cliAgentCommandModule = ({ aigne, cliAgent, }) => {
60
- const { agent, agents } = cliAgent;
61
- const name = cliAgent.name || agent?.name;
62
- assert(name, "CLI agent must have a name");
63
- return {
64
- command: name,
65
- aliases: cliAgent.alias || agent?.alias || [],
66
- describe: cliAgent.description || agent?.description || "",
67
- builder: async (yargs) => {
68
- if (agent) {
69
- withAgentInputSchema(yargs, { inputSchema: agent.inputSchema });
70
- }
71
- if (agents?.length) {
72
- for (const cmd of agents) {
73
- yargs.command(cliAgentCommandModule({
74
- aigne,
75
- cliAgent: cmd,
76
- }));
77
- }
78
- }
79
- if (!agent)
80
- yargs.demandCommand();
81
- return yargs;
82
- },
83
- handler: async (options) => {
84
- if (!agent)
85
- throw new Error("CLI agent is not defined");
86
- if (options.logLevel)
87
- logger.level = options.logLevel;
88
- await invokeAgent({
89
- aigne,
90
- agent,
91
- input: options,
92
- });
93
- },
94
- };
95
- };
96
- export async function invokeAgent(options) {
97
- const { agent, aigne } = options;
98
- try {
99
- const input = await parseAgentInput(options.input, agent);
100
- const sessionId = options.input.sessionId || v7();
101
- const userId = DEFAULT_USER_ID;
102
- if (aigne.cli.init) {
103
- await runAgentWithAIGNE(aigne, aigne.cli.init, {
104
- ...options.input,
105
- input,
106
- interactive: false,
107
- sessionId,
108
- userId,
109
- });
110
- }
111
- await runAgentWithAIGNE(aigne, agent, {
112
- ...options.input,
113
- input,
114
- interactive: options.input.interactive,
115
- sessionId,
116
- userId,
117
- });
118
- }
119
- finally {
120
- await aigne.shutdown();
121
- }
122
- }
@@ -1,7 +0,0 @@
1
- export declare function runAppCLI({ appName, appPackageName, appDescription, appUseBetaVersion, ...options }?: {
2
- argv?: string[];
3
- appName?: string;
4
- appPackageName?: string;
5
- appDescription?: string;
6
- appUseBetaVersion?: boolean;
7
- }): Promise<void>;
@@ -1,92 +0,0 @@
1
- import { homedir } from "node:os";
2
- import { join } from "node:path";
3
- import { CHAT_MODEL_OPTIONS } from "@aigne/cli/constants.js";
4
- import { LogLevel, logger } from "@aigne/core/utils/logger.js";
5
- import { pick } from "@aigne/core/utils/type-utils.js";
6
- import chalk from "chalk";
7
- import yargs from "yargs";
8
- import { hideBin } from "yargs/helpers";
9
- import { highlightUrl } from "../../utils/string-utils.js";
10
- import { withRunAgentCommonOptions } from "../../utils/yargs.js";
11
- import { agentCommandModule, cliAgentCommandModule, serveMcpCommandModule } from "./agent.js";
12
- import { loadApplication, NeedReinstallBetaError, NeedReinstallError, upgradeCommandModule, } from "./upgrade.js";
13
- export async function runAppCLI({ appName = process.env.AIGNE_APP_NAME, appPackageName = process.env.AIGNE_APP_PACKAGE_NAME, appDescription = process.env.AIGNE_APP_DESCRIPTION, appUseBetaVersion = process.env.AIGNE_APP_USE_BETA_APPS === "1" ? true : undefined, ...options } = {}) {
14
- const [scriptName, ...argv] = options.argv || hideBin(process.argv);
15
- if (!appName || !appPackageName)
16
- throw new Error("AIGNE_APP_NAME or AIGNE_APP_PACKAGE_NAME is not defined");
17
- try {
18
- // Parse model options for loading application
19
- const options = withRunAgentCommonOptions(yargs(argv).help(false).version(false).strict(false)).parseSync();
20
- logger.level = options.logLevel;
21
- const dir = join(homedir(), ".aigne", "registry.npmjs.org", appPackageName);
22
- const y = yargs()
23
- .scriptName(`aigne ${scriptName}`)
24
- .usage(`aigne ${scriptName}\n\n${appDescription || ""}`)
25
- .command(upgradeCommandModule({ packageName: appPackageName, dir }));
26
- if (!isUpgradeCommand(argv)) {
27
- const { aigne, version } = await loadApplication({
28
- packageName: appPackageName,
29
- beta: appUseBetaVersion,
30
- dir,
31
- install: true,
32
- modelOptions: pick(options, CHAT_MODEL_OPTIONS),
33
- imageModelOptions: { model: options.imageModel },
34
- skipModelLoading: (options.help || options.h || options.version || options.v) === true,
35
- });
36
- if (aigne.cli?.chat) {
37
- y.command({
38
- ...agentCommandModule({
39
- aigne,
40
- agent: aigne.cli.chat,
41
- interactive: true,
42
- }),
43
- command: "$0",
44
- });
45
- }
46
- for (const cliAgent of aigne.cli?.agents ?? []) {
47
- y.command(cliAgentCommandModule({ aigne, cliAgent }));
48
- }
49
- y.option("model", {
50
- type: "string",
51
- description: "Model to use for the application, example: openai:gpt-4.1 or google:gemini-2.5-flash",
52
- }).command(serveMcpCommandModule({ aigne, name: appName }));
53
- y.version(`${appName} v${version}`);
54
- }
55
- await y
56
- .alias("v", "version")
57
- .alias("h", "help")
58
- .demandCommand()
59
- .fail((message, error, yargs) => {
60
- // We catch all errors below, here just print the help message non-error case like demandCommand
61
- if (!error) {
62
- yargs.showHelp();
63
- console.error(`\n${message}`);
64
- process.exit(1);
65
- }
66
- })
67
- .parseAsync(argv);
68
- process.exit(0);
69
- }
70
- catch (error) {
71
- if (error instanceof NeedReinstallError || error instanceof NeedReinstallBetaError) {
72
- logger.warn(error.message);
73
- process.exit(error instanceof NeedReinstallBetaError
74
- ? NeedReinstallBetaError.code
75
- : NeedReinstallError.code);
76
- }
77
- if (error.name !== "ExitPromptError") {
78
- console.log(""); // Add an empty line for better readability
79
- if (logger.enabled(LogLevel.ERROR)) {
80
- console.error(chalk.red(error.stack));
81
- }
82
- else {
83
- console.error(`${chalk.red("Error:")} ${highlightUrl(error.message)}`);
84
- }
85
- }
86
- process.exit(1);
87
- }
88
- }
89
- function isUpgradeCommand(argv) {
90
- const skipGlobalOptions = ["-v", "--version", "-h", "--help"];
91
- return argv[0] === "upgrade" && !argv.some((arg) => skipGlobalOptions.includes(arg));
92
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import { runAppCLI } from "./app.js";
2
- await runAppCLI();
@@ -1,54 +0,0 @@
1
- import type { LoadCredentialOptions } from "@aigne/cli/utils/aigne-hub/type.js";
2
- import type { AIGNE, ChatModelInputOptions, ImageModelInputOptions } from "@aigne/core";
3
- import type { CommandModule } from "yargs";
4
- export declare const upgradeCommandModule: ({ packageName, dir, }: {
5
- packageName: string;
6
- dir: string;
7
- }) => CommandModule<unknown, {
8
- beta?: boolean;
9
- targetVersion?: string;
10
- force?: boolean;
11
- }>;
12
- interface LoadApplicationOptions {
13
- packageName: string;
14
- dir: string;
15
- install?: boolean;
16
- skipModelLoading?: boolean;
17
- modelOptions?: ChatModelInputOptions & LoadCredentialOptions;
18
- imageModelOptions?: ImageModelInputOptions & LoadCredentialOptions;
19
- beta?: boolean;
20
- }
21
- interface LoadApplicationResult {
22
- aigne: AIGNE;
23
- version: string;
24
- isCache?: boolean;
25
- }
26
- export declare class NeedReinstallError extends Error {
27
- static code: number;
28
- }
29
- export declare class NeedReinstallBetaError extends Error {
30
- static code: number;
31
- }
32
- export declare function loadApplication(options: LoadApplicationOptions & {
33
- install: true;
34
- }): Promise<LoadApplicationResult>;
35
- export declare function loadApplication(options: LoadApplicationOptions & {
36
- install?: false;
37
- }): Promise<LoadApplicationResult | null>;
38
- export declare function getNpmTgzInfo(name: string, { version, beta }?: {
39
- version?: string;
40
- beta?: boolean;
41
- }): Promise<{
42
- version: string;
43
- url: string;
44
- }>;
45
- export declare function installApp({ dir, packageName, beta, version, }: {
46
- dir: string;
47
- packageName: string;
48
- beta?: boolean;
49
- version?: string;
50
- }): Promise<{
51
- url: string;
52
- version: string;
53
- }>;
54
- export {};
@@ -1,236 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import { mkdir, readFile, rm, stat, writeFile } from "node:fs/promises";
3
- import { join } from "node:path";
4
- import { LoadJsAgentError } from "@aigne/core/loader/error.js";
5
- import { fetch } from "@aigne/core/utils/fetch.js";
6
- import { Listr, PRESET_TIMER } from "@aigne/listr2";
7
- import { joinURL } from "ufo";
8
- import { downloadAndExtract } from "../../utils/download.js";
9
- import { loadAIGNE } from "../../utils/load-aigne.js";
10
- import { withSpinner } from "../../utils/spinner.js";
11
- const NPM_PACKAGE_CACHE_TIME_MS = 1000 * 60 * 60 * 24; // 1 day
12
- /**
13
- * Check if beta applications should be used based on environment variables
14
- */
15
- function shouldUseBetaApps() {
16
- const envVar = process.env.AIGNE_USE_BETA_APPS;
17
- return envVar === "true" || envVar === "1";
18
- }
19
- export const upgradeCommandModule = ({ packageName, dir, }) => ({
20
- command: "upgrade",
21
- describe: `Upgrade ${packageName} to the latest version`,
22
- builder: (yargs) => {
23
- return yargs
24
- .option("beta", {
25
- type: "boolean",
26
- describe: "Use beta versions if available",
27
- })
28
- .option("target-version", {
29
- type: "string",
30
- describe: "Specify a version to upgrade to (default is latest)",
31
- alias: ["to", "target"],
32
- })
33
- .option("force", {
34
- type: "boolean",
35
- describe: "Force upgrade even if already at latest version",
36
- default: false,
37
- });
38
- },
39
- handler: async ({ beta, targetVersion, force }) => {
40
- beta ??= shouldUseBetaApps();
41
- const npm = await withSpinner("", async () => {
42
- if (force)
43
- await rm(dir, { force: true, recursive: true });
44
- return await getNpmTgzInfo(packageName, { beta, version: targetVersion });
45
- });
46
- const check = await checkInstallation(dir);
47
- if (force || !check || npm.version !== check.version) {
48
- await installApp({ packageName, dir, beta, version: targetVersion });
49
- }
50
- const app = await loadApplication({ dir, packageName, install: true, skipModelLoading: true });
51
- if (force || check?.version !== app.version) {
52
- console.log(`\n✅ Upgraded ${packageName} to version ${app.version}`);
53
- }
54
- else {
55
- console.log(`\n✅ ${packageName} is already at the latest version (${app.version})`);
56
- }
57
- },
58
- });
59
- export class NeedReinstallError extends Error {
60
- static code = 244;
61
- }
62
- export class NeedReinstallBetaError extends Error {
63
- static code = 245;
64
- }
65
- export async function loadApplication(options) {
66
- const { dir, packageName } = options;
67
- const check = await checkInstallation(dir);
68
- const beta = options.beta ?? check?.version?.includes("beta");
69
- if (check) {
70
- let needUpdate = check.expired;
71
- if (check.expired) {
72
- await withSpinner("Checking updates...", async () => {
73
- const tgz = await getNpmTgzInfo(packageName, { beta });
74
- if (tgz.version === check.version) {
75
- await writeInstallationMetadata(dir, { installedAt: Date.now() });
76
- needUpdate = false;
77
- }
78
- });
79
- }
80
- if (!needUpdate) {
81
- const aigne = await loadAIGNE({
82
- ...options,
83
- path: dir,
84
- metadata: {
85
- appName: packageName,
86
- appVersion: check?.version,
87
- },
88
- }).catch(async (error) => {
89
- if (error instanceof LoadJsAgentError) {
90
- await withSpinner("", async () => {
91
- await rm(options.dir, { recursive: true, force: true });
92
- await mkdir(options.dir, { recursive: true });
93
- });
94
- const message = `⚠️ Failed to load ${packageName}, trying to reinstall: ${error.message}`;
95
- throw beta ? new NeedReinstallBetaError(message) : new NeedReinstallError(message);
96
- }
97
- throw error;
98
- });
99
- if (aigne) {
100
- return { aigne, version: check.version, isCache: true };
101
- }
102
- }
103
- }
104
- if (!options.install)
105
- return null;
106
- const result = await installApp({ dir, packageName, beta });
107
- return {
108
- aigne: await loadAIGNE({
109
- ...options,
110
- path: dir,
111
- metadata: {
112
- appName: packageName,
113
- appVersion: result.version,
114
- },
115
- }),
116
- version: result.version,
117
- };
118
- }
119
- export async function getNpmTgzInfo(name, { version, beta } = {}) {
120
- const res = await fetch(joinURL("https://registry.npmjs.org", name));
121
- const data = await res.json();
122
- let targetVersion;
123
- if (version) {
124
- if (!data.versions[version]) {
125
- throw new Error(`Version ${version} of package ${name} not found`);
126
- }
127
- targetVersion = version;
128
- }
129
- else if (beta && data["dist-tags"].beta) {
130
- // Use beta version if available and beta flag is set
131
- targetVersion = data["dist-tags"].beta;
132
- }
133
- else {
134
- // Fall back to latest version
135
- targetVersion = data["dist-tags"].latest;
136
- }
137
- const url = data.versions[targetVersion].dist.tarball;
138
- return {
139
- version: targetVersion,
140
- url,
141
- };
142
- }
143
- async function readInstallationMetadata(dir) {
144
- return safeParseJSON(await readFile(join(dir, ".aigne-cli.json"), "utf-8").catch(() => "{}"));
145
- }
146
- async function writeInstallationMetadata(dir, metadata) {
147
- await writeFile(join(dir, ".aigne-cli.json"), JSON.stringify(metadata, null, 2));
148
- }
149
- async function checkInstallation(dir, { cacheTimeMs = NPM_PACKAGE_CACHE_TIME_MS } = {}) {
150
- const s = await stat(join(dir, "package.json")).catch(() => null);
151
- if (!s)
152
- return null;
153
- const version = safeParseJSON(await readFile(join(dir, "package.json"), "utf-8"))?.version;
154
- if (!version)
155
- return null;
156
- const installedAt = (await readInstallationMetadata(dir))?.installedAt;
157
- if (!installedAt)
158
- return null;
159
- const now = Date.now();
160
- const expired = now - installedAt > cacheTimeMs;
161
- return { version, expired };
162
- }
163
- export async function installApp({ dir, packageName, beta, version, }) {
164
- return await new Listr([
165
- {
166
- title: `Fetching ${packageName} metadata`,
167
- task: async (ctx, task) => {
168
- if (beta) {
169
- task.title = `Fetching ${packageName} metadata (using beta version)`;
170
- }
171
- const info = await getNpmTgzInfo(packageName, { beta, version });
172
- Object.assign(ctx, info);
173
- },
174
- },
175
- {
176
- title: `Downloading ${packageName}`,
177
- task: async (ctx, task) => {
178
- task.title = `Downloading ${packageName} (v${ctx.version})`;
179
- await mkdir(dir, { recursive: true });
180
- await downloadAndExtract(ctx.url, dir, { strip: 1 });
181
- },
182
- },
183
- {
184
- title: "Installing dependencies",
185
- task: async (_, task) => {
186
- await installDependencies(dir, {
187
- log: (log) => {
188
- const last = log.split("\n").findLast((i) => !!i);
189
- if (last)
190
- task.output = last;
191
- },
192
- });
193
- await writeInstallationMetadata(dir, { installedAt: Date.now() });
194
- },
195
- },
196
- ], {
197
- rendererOptions: {
198
- collapseSubtasks: false,
199
- showErrorMessage: false,
200
- timer: PRESET_TIMER,
201
- },
202
- }).run();
203
- }
204
- async function installDependencies(dir, { log } = {}) {
205
- await new Promise((resolve, reject) => {
206
- const child = spawn("npm", ["install", "--omit", "dev", "--verbose", "--legacy-peer-deps"], {
207
- cwd: dir,
208
- stdio: "pipe",
209
- shell: process.platform === "win32",
210
- });
211
- child.stdout.on("data", (data) => {
212
- log?.(data.toString());
213
- });
214
- let stderr = "";
215
- child.stderr.on("data", (data) => {
216
- const str = data.toString();
217
- log?.(str);
218
- stderr += str;
219
- });
220
- child.on("error", (error) => reject(error));
221
- child.on("exit", (code) => {
222
- if (code === 0)
223
- resolve();
224
- else {
225
- console.error(stderr);
226
- reject(new Error(`npm install failed with code ${code}`));
227
- }
228
- });
229
- });
230
- }
231
- function safeParseJSON(raw) {
232
- try {
233
- return JSON.parse(raw);
234
- }
235
- catch { }
236
- }
@@ -1,4 +0,0 @@
1
- import type { CommandModule } from "yargs";
2
- export declare function createAppCommands({ argv }?: {
3
- argv?: string[];
4
- }): CommandModule[];