@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,16 +0,0 @@
1
- export interface UserInfoResult {
2
- user: Record<string, any>;
3
- enableCredit: boolean;
4
- creditBalance: {
5
- balance: string;
6
- total: string;
7
- grantCount: number;
8
- pendingCredit: string;
9
- } | null;
10
- paymentLink: string | null;
11
- profileLink: string;
12
- }
13
- export declare function getUserInfo({ baseUrl, apiKey, }: {
14
- baseUrl: string;
15
- apiKey: string;
16
- }): Promise<UserInfoResult>;
@@ -1,10 +0,0 @@
1
- import { fetch } from "@aigne/core/utils/fetch.js";
2
- import { joinURL } from "ufo";
3
- export async function getUserInfo({ baseUrl, apiKey, }) {
4
- const secureBaseUrl = baseUrl.replace(/^http:/, "https:");
5
- const response = await fetch(joinURL(secureBaseUrl, "/api/user/info"), {
6
- headers: { Authorization: `Bearer ${apiKey}` },
7
- });
8
- const data = await response.json();
9
- return data;
10
- }
@@ -1 +0,0 @@
1
- export declare const asciiLogo: string;
@@ -1,3 +0,0 @@
1
- export declare function downloadAndExtract(url: string, dir: string, options?: {
2
- strip?: number;
3
- }): Promise<void>;
@@ -1,19 +0,0 @@
1
- import { mkdir } from "node:fs/promises";
2
- import { Readable } from "node:stream";
3
- import { finished } from "node:stream/promises";
4
- import { fetch } from "@aigne/core/utils/fetch.js";
5
- import { x } from "tar";
6
- export async function downloadAndExtract(url, dir, options = {}) {
7
- const response = await fetch(url);
8
- if (!response.body) {
9
- throw new Error(`Failed to download package from ${url}: Unexpected to get empty response`);
10
- }
11
- try {
12
- await mkdir(dir, { recursive: true });
13
- await finished(Readable.fromWeb(response.body).pipe(x({ C: dir, ...options })));
14
- }
15
- catch (error) {
16
- error.message = `Failed to extract package from ${url}: ${error.message}`;
17
- throw error;
18
- }
19
- }
@@ -1,8 +0,0 @@
1
- import type { Dataset, Evaluator, Reporter, Runner, RunOptions } from "./type.js";
2
- export declare function runEvaluationPipeline(params: {
3
- dataset: Dataset;
4
- runner: Runner;
5
- evaluators: Evaluator[];
6
- reporters?: Reporter[];
7
- options?: RunOptions;
8
- }): Promise<void>;
@@ -1,83 +0,0 @@
1
- import { Listr } from "@aigne/listr2";
2
- import { ConsoleReporter } from "./reporter.js";
3
- function aggregateSummary(results, duration) {
4
- const total = results.length;
5
- const scores = results.flatMap((r) => r.evaluations.map((e) => e.score));
6
- const successRate = Number((scores.length > 0 ? scores.reduce((a, b) => a + b, 0) / scores.length : 0).toFixed(2));
7
- const latencies = results.map((r) => r.latency || 0);
8
- const totalTokens = results.reduce((a, r) => a + (r.usage?.inputTokens || 0) + (r.usage?.outputTokens || 0), 0);
9
- const errors = results.filter((r) => r.error).length;
10
- return {
11
- total,
12
- successRate,
13
- duration: Number(duration.toFixed(3)),
14
- avgLatency: latencies.reduce((a, b) => a + b, 0) / (latencies.length || 1),
15
- maxLatency: Math.max(...latencies, 0),
16
- minLatency: Math.min(...latencies, 0),
17
- totalTokens,
18
- errorCount: errors,
19
- scoreDistribution: {
20
- min: Math.min(...scores, 0),
21
- max: Math.max(...scores, 0),
22
- mean: successRate,
23
- median: scores.length ? scores.sort((a, b) => a - b)[Math.floor(scores.length / 2)] : 0,
24
- variance: scores.length > 1
25
- ? scores.reduce((a, b) => a + (b - successRate) ** 2, 0) / scores.length
26
- : 0,
27
- },
28
- };
29
- }
30
- export async function runEvaluationPipeline(params) {
31
- const now = Date.now();
32
- const { dataset, runner, evaluators, reporters = [new ConsoleReporter()], options } = params;
33
- const results = [];
34
- const task1 = new Listr([
35
- {
36
- title: "Load dataset",
37
- task: async (ctx, _task) => {
38
- ctx.items = await dataset.loadWithOptions();
39
- },
40
- },
41
- ], {
42
- registerSignalListeners: false,
43
- });
44
- const { items } = await task1.run();
45
- const task2 = new Listr(items.map((item) => {
46
- const input = JSON.stringify(item.input);
47
- return {
48
- title: `Run evaluations with input: ${input.length > 100 ? `${input.slice(0, 100)}...` : input}`,
49
- task: async (ctx, task) => {
50
- task.output = `Start running agent with input: ${JSON.stringify(item.input, null, 2)}`;
51
- const runnerResults = await runner.run([item], options);
52
- for await (const result of runnerResults) {
53
- task.output = `Start running evaluation with: ${JSON.stringify({
54
- input: result.input,
55
- output: result.output,
56
- expected: result.expected,
57
- }, null, 2)}`;
58
- const evaluations = [];
59
- for (const evaluator of evaluators) {
60
- const evals = await evaluator.evaluate(result);
61
- evaluations.push(...evals);
62
- }
63
- results.push({ ...result, evaluations });
64
- task.output = `Finish running evaluation`;
65
- }
66
- ctx.results = results;
67
- },
68
- };
69
- }), {
70
- concurrent: options?.concurrency ? Math.min(items.length, options?.concurrency) : false,
71
- exitOnError: true,
72
- rendererOptions: {
73
- collapseSubtasks: false,
74
- },
75
- registerSignalListeners: false,
76
- });
77
- await task2.run();
78
- const summary = aggregateSummary(results, (Date.now() - now) / 1000);
79
- const report = { dataset: dataset.name, results, summary };
80
- for (const reporter of reporters) {
81
- await reporter.report(report);
82
- }
83
- }
@@ -1,15 +0,0 @@
1
- import type { Dataset, DatasetItem } from "./type.js";
2
- export declare class FileDataset implements Dataset {
3
- name: string;
4
- private filePath;
5
- constructor(filePath: string);
6
- load(): Promise<DatasetItem[]>;
7
- loadWithOptions(): Promise<DatasetItem[]>;
8
- }
9
- export declare class JsonDataset implements Dataset {
10
- name: string;
11
- private data;
12
- constructor(data: DatasetItem[]);
13
- load(): Promise<DatasetItem[]>;
14
- loadWithOptions(): Promise<DatasetItem[]>;
15
- }
@@ -1,61 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import { z } from "zod";
3
- const recordSchema = z.record(z.any());
4
- const datasetItemSchema = z.object({
5
- id: z.union([z.string(), z.number()]),
6
- input: recordSchema,
7
- output: recordSchema.optional(),
8
- expected: recordSchema.optional(),
9
- metadata: recordSchema.optional(),
10
- tags: z.array(z.string()).optional(),
11
- selected: z.boolean().optional(),
12
- });
13
- const datasetSchema = z.array(datasetItemSchema);
14
- export class FileDataset {
15
- name = "file-dataset";
16
- filePath;
17
- constructor(filePath) {
18
- this.filePath = filePath;
19
- }
20
- async load() {
21
- let list;
22
- try {
23
- list = await fs.readFile(this.filePath, "utf-8");
24
- }
25
- catch (err) {
26
- throw new Error(`Failed to read dataset file: ${err.message}`);
27
- }
28
- let parsed;
29
- try {
30
- parsed = JSON.parse(list);
31
- }
32
- catch (err) {
33
- throw new Error(`Invalid JSON in dataset file: ${err.message}`);
34
- }
35
- const result = await datasetSchema.safeParseAsync(parsed);
36
- if (!result.success) {
37
- throw new Error(`Invalid dataset file: ${JSON.stringify(result.error.format())}`);
38
- }
39
- return result.data;
40
- }
41
- async loadWithOptions() {
42
- return this.load();
43
- }
44
- }
45
- export class JsonDataset {
46
- name = "json-dataset";
47
- data;
48
- constructor(data) {
49
- this.data = data;
50
- }
51
- async load() {
52
- const result = await datasetSchema.safeParseAsync(this.data);
53
- if (!result.success) {
54
- throw new Error(`Invalid dataset file: ${JSON.stringify(result.error.format())}`);
55
- }
56
- return result.data;
57
- }
58
- async loadWithOptions() {
59
- return this.load();
60
- }
61
- }
@@ -1,9 +0,0 @@
1
- import { type Agent, AIGNE } from "@aigne/core";
2
- import type { DatasetItem, Evaluation, Evaluator } from "./type.js";
3
- export declare class LLMEvaluator implements Evaluator {
4
- private readonly aigne;
5
- private readonly agent;
6
- name: string;
7
- constructor(aigne?: AIGNE, agent?: Agent);
8
- evaluate(dataset: DatasetItem): Promise<Evaluation[]>;
9
- }
@@ -1,28 +0,0 @@
1
- import type { Report, Reporter } from "./type.js";
2
- export declare class BaseReporter implements Reporter {
3
- name: string;
4
- report(_report: Report): Promise<void>;
5
- protected formatReport(report: Report): {
6
- header: string;
7
- key: string;
8
- width: number;
9
- value: string | number;
10
- }[][];
11
- protected formatSummary(summary: Report["summary"]): {
12
- header: string;
13
- key: string;
14
- width: number;
15
- value: string | number;
16
- }[];
17
- }
18
- export declare class ConsoleReporter extends BaseReporter {
19
- name: string;
20
- report(report: Report): Promise<void>;
21
- }
22
- export declare class CsvReporter extends BaseReporter {
23
- private filePath;
24
- name: string;
25
- constructor(filePath: string);
26
- private writeCsv;
27
- report(report: Report): Promise<void>;
28
- }
@@ -1,221 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { format } from "@fast-csv/format";
4
- import chalk from "chalk";
5
- import Table from "cli-table3";
6
- const borderColor = chalk.green;
7
- const chars = {
8
- top: borderColor("─"),
9
- "top-mid": borderColor("┬"),
10
- "top-left": borderColor("┌"),
11
- "top-right": borderColor("┐"),
12
- bottom: borderColor("─"),
13
- "bottom-mid": borderColor("┴"),
14
- "bottom-left": borderColor("└"),
15
- "bottom-right": borderColor("┘"),
16
- left: borderColor("│"),
17
- "left-mid": borderColor("├"),
18
- mid: borderColor("─"),
19
- "mid-mid": borderColor("┼"),
20
- right: borderColor("│"),
21
- "right-mid": borderColor("┤"),
22
- middle: borderColor("│"),
23
- };
24
- const MAX_CELL_LENGTH = 300;
25
- function renderPagedTable(list, { maxCols = 6, chars }) {
26
- if (!list.length)
27
- return [];
28
- const tables = [];
29
- const head = list[0]?.map((h) => h.header) ?? [];
30
- const widths = list[0]?.map((h) => h.width ?? 20) ?? [];
31
- for (let i = 0; i < head.length; i += maxCols) {
32
- const subHead = head.slice(i, i + maxCols);
33
- const subWidths = widths.slice(i, i + maxCols);
34
- const table = new Table({
35
- head: subHead,
36
- colWidths: subWidths,
37
- wordWrap: true,
38
- chars,
39
- });
40
- for (const row of list) {
41
- table.push(row
42
- .slice(i, i + maxCols)
43
- .map((h) => String(h.value).length > MAX_CELL_LENGTH
44
- ? `${String(h.value).slice(0, MAX_CELL_LENGTH)}...`
45
- : h.value));
46
- }
47
- tables.push(table.toString());
48
- }
49
- return tables;
50
- }
51
- export class BaseReporter {
52
- name = "base";
53
- async report(_report) {
54
- throw new Error("Not implemented");
55
- }
56
- formatReport(report) {
57
- return report.results.map((r) => {
58
- return [
59
- { header: "ID", key: "ID", width: 10, value: r.id },
60
- { header: "Input", key: "Input", width: 40, value: JSON.stringify(r.input) },
61
- {
62
- header: "Output",
63
- key: "Output",
64
- width: 40,
65
- value: r.output ? JSON.stringify(r.output) : "-",
66
- },
67
- {
68
- header: "Expected",
69
- key: "Expected",
70
- width: 40,
71
- value: r.expected ? JSON.stringify(r.expected) : "-",
72
- },
73
- {
74
- header: "Evaluations",
75
- key: "Evaluations",
76
- width: 30,
77
- value: r.evaluations.map((e) => `${e.name}:${e.score}`).join(", "),
78
- },
79
- {
80
- header: "Rating",
81
- key: "Rating",
82
- width: 20,
83
- value: r.evaluations.map((e) => `${e.rating}`).join(", "),
84
- },
85
- { header: "Error", key: "Error", width: 20, value: r.error ?? "-" },
86
- {
87
- header: "Reason",
88
- key: "Reason",
89
- width: 50,
90
- value: r.evaluations
91
- .map((e) => e.reason ?? "")
92
- .filter(Boolean)
93
- .join(" | "),
94
- },
95
- {
96
- header: "Latency",
97
- key: "Latency",
98
- width: 15,
99
- value: r.latency ? `${r.latency.toFixed(2)}s` : "-",
100
- },
101
- {
102
- header: "Tokens",
103
- key: "Tokens",
104
- width: 40,
105
- value: r.usage
106
- ? `${(r.usage.inputTokens || 0) + (r.usage.outputTokens || 0)} (input:${r.usage.inputTokens || 0}, output:${r.usage.outputTokens || 0})`
107
- : "-",
108
- },
109
- ];
110
- });
111
- }
112
- formatSummary(summary) {
113
- return [
114
- {
115
- header: "Total",
116
- key: "Total",
117
- width: 10,
118
- value: summary.total,
119
- },
120
- {
121
- header: "Success Rate",
122
- key: "SuccessRate",
123
- width: 15,
124
- value: summary.successRate,
125
- },
126
- {
127
- header: "Total Duration",
128
- key: "Duration",
129
- width: 15,
130
- value: summary.duration ? `${summary.duration.toFixed(3)}s` : "-",
131
- },
132
- {
133
- header: "Avg Latency",
134
- key: "AvgLatency",
135
- width: 15,
136
- value: summary.avgLatency ? `${summary.avgLatency.toFixed(3)}s` : "-",
137
- },
138
- {
139
- header: "Total Tokens",
140
- key: "TotalTokens",
141
- width: 15,
142
- value: summary.totalTokens ?? "-",
143
- },
144
- {
145
- header: "Errors",
146
- key: "Errors",
147
- width: 8,
148
- value: summary.errorCount ?? 0,
149
- },
150
- ];
151
- }
152
- }
153
- export class ConsoleReporter extends BaseReporter {
154
- name = "console";
155
- async report(report) {
156
- const summary = report.summary;
157
- console.log("\n=== 📊 Evaluation Summary ===");
158
- const summaryList = this.formatSummary(summary);
159
- const summaryTable = new Table({
160
- head: summaryList.map((h) => h.header),
161
- colWidths: summaryList.map((h) => h.width),
162
- chars,
163
- });
164
- summaryTable.push(summaryList.map((h) => h.value));
165
- console.log(summaryTable.toString());
166
- const list = this.formatReport(report);
167
- if (!list.length)
168
- return;
169
- console.log("\n=== 📋 Detailed Results ===");
170
- const pages = renderPagedTable(list, { maxCols: 5, chars });
171
- for (const page of pages) {
172
- console.log(page);
173
- }
174
- const failed = report.results.filter((r) => r.error);
175
- if (failed.length) {
176
- console.log(chalk.red("\n=== ❌ Failed Cases ==="));
177
- for (const f of failed) {
178
- console.log(`#${f.id} Input: ${JSON.stringify(f.input)}\n Expected: ${f.expected ? JSON.stringify(f.expected) : "-"}\n Output: ${f.output ? JSON.stringify(f.output) : "-"}\n Error: ${f.error ?? "-"}\n`);
179
- }
180
- }
181
- }
182
- }
183
- export class CsvReporter extends BaseReporter {
184
- filePath;
185
- name = "csv";
186
- constructor(filePath) {
187
- super();
188
- this.filePath = filePath;
189
- }
190
- async writeCsv(filePath, data, headers) {
191
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
192
- const stream = format({ headers });
193
- const writeStream = fs.createWriteStream(filePath);
194
- stream.pipe(writeStream);
195
- for (const row of data) {
196
- stream.write(row);
197
- }
198
- stream.end();
199
- await new Promise((resolve, reject) => {
200
- writeStream.on("finish", resolve);
201
- writeStream.on("error", reject);
202
- });
203
- }
204
- async report(report) {
205
- const list = this.formatReport(report);
206
- if (list.length > 0) {
207
- const resultsHeaders = list[0]?.map((h) => h.header) ?? [];
208
- const resultsRows = list.map((row) => {
209
- const record = {};
210
- for (const item of row) {
211
- record[item.header] = item.value;
212
- }
213
- return record;
214
- });
215
- const ext = path.extname(this.filePath).toLowerCase();
216
- const outputFile = ext ? this.filePath : `${this.filePath}.csv`;
217
- await this.writeCsv(outputFile, resultsRows, resultsHeaders);
218
- console.log(`✅ Results CSV saved to ${outputFile}`);
219
- }
220
- }
221
- }
@@ -1,16 +0,0 @@
1
- import { type Agent, AIGNE } from "@aigne/core";
2
- import type { DatasetItem, Runner, RunOptions, RunResult } from "./type.js";
3
- export declare class DefaultRunner implements Runner {
4
- private agent;
5
- private aigne;
6
- name: string;
7
- constructor(agent: Agent, aigne?: AIGNE);
8
- run(dataset: DatasetItem[], options?: RunOptions): AsyncGenerator<RunResult>;
9
- }
10
- export declare class DefaultRunnerWithConcurrency implements Runner {
11
- private agent;
12
- private aigne;
13
- name: string;
14
- constructor(agent: Agent, aigne?: AIGNE);
15
- run(dataset: DatasetItem[], options?: RunOptions): AsyncGenerator<RunResult>;
16
- }
@@ -1,129 +0,0 @@
1
- import { AIGNE } from "@aigne/core";
2
- export class DefaultRunner {
3
- agent;
4
- aigne;
5
- name = "default-runner";
6
- constructor(agent, aigne = new AIGNE()) {
7
- this.agent = agent;
8
- this.aigne = aigne;
9
- }
10
- async *run(dataset, options) {
11
- const timeoutMs = options?.timeoutMs ?? 0;
12
- const runTask = async (item) => {
13
- const start = Date.now();
14
- options?.hooks?.onBeforeRun?.(item);
15
- try {
16
- const execPromise = this.aigne.invoke(this.agent, item.input, { returnMetadata: true });
17
- const result = timeoutMs > 0 ? await withTimeout(execPromise, timeoutMs, item.id) : await execPromise;
18
- const { $meta, ...output } = result;
19
- options?.hooks?.onAfterRun?.(result);
20
- return {
21
- ...item,
22
- output,
23
- latency: (Date.now() - start) / 1000,
24
- usage: $meta?.usage || {},
25
- };
26
- }
27
- catch (err) {
28
- options?.hooks?.onError?.(err);
29
- return {
30
- ...item,
31
- error: err.message,
32
- };
33
- }
34
- };
35
- for (const item of dataset) {
36
- yield await runTask(item);
37
- }
38
- }
39
- }
40
- function withTimeout(promise, ms, id) {
41
- return new Promise((resolve, reject) => {
42
- const timer = setTimeout(() => {
43
- reject(new Error(`Task ${id} timed out after ${ms}ms`));
44
- }, ms);
45
- promise
46
- .then((res) => {
47
- clearTimeout(timer);
48
- resolve(res);
49
- })
50
- .catch((err) => {
51
- clearTimeout(timer);
52
- reject(err);
53
- });
54
- });
55
- }
56
- export class DefaultRunnerWithConcurrency {
57
- agent;
58
- aigne;
59
- name = "default-runner-with-concurrency";
60
- constructor(agent, aigne = new AIGNE()) {
61
- this.agent = agent;
62
- this.aigne = aigne;
63
- }
64
- async *run(dataset, options) {
65
- const concurrency = options?.concurrency ?? 1;
66
- const timeoutMs = options?.timeoutMs ?? 0;
67
- let index = 0;
68
- const yieldQueue = [];
69
- let waitingResolve = null;
70
- let activeWorkers = 0;
71
- const runTask = async (item) => {
72
- const start = Date.now();
73
- options?.hooks?.onBeforeRun?.(item);
74
- try {
75
- const execPromise = this.aigne.invoke(this.agent, item.input, { returnMetadata: true });
76
- const result = timeoutMs > 0 ? await withTimeout(execPromise, timeoutMs, item.id) : await execPromise;
77
- const { $meta, ...output } = result;
78
- options?.hooks?.onAfterRun?.(result);
79
- return {
80
- ...item,
81
- output,
82
- latency: (Date.now() - start) / 1000,
83
- usage: $meta?.usage || {},
84
- };
85
- }
86
- catch (err) {
87
- options?.hooks?.onError?.(err);
88
- return {
89
- ...item,
90
- error: err.message,
91
- };
92
- }
93
- };
94
- const worker = async () => {
95
- activeWorkers++;
96
- try {
97
- while (true) {
98
- const currentIndex = index++;
99
- if (currentIndex >= dataset.length)
100
- break;
101
- const item = dataset[currentIndex];
102
- if (!item)
103
- continue;
104
- const res = await runTask(item);
105
- yieldQueue.push(res);
106
- waitingResolve?.();
107
- }
108
- }
109
- finally {
110
- activeWorkers--;
111
- waitingResolve?.();
112
- }
113
- };
114
- Array.from({ length: Math.min(concurrency, dataset.length) }, () => worker());
115
- while (yieldQueue.length > 0 || activeWorkers > 0) {
116
- if (yieldQueue.length > 0) {
117
- const result = yieldQueue.shift();
118
- if (result)
119
- yield result;
120
- }
121
- else {
122
- await new Promise((resolve) => {
123
- waitingResolve = resolve;
124
- });
125
- waitingResolve = null;
126
- }
127
- }
128
- }
129
- }