@aigne/core 1.72.0 → 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 (827) hide show
  1. package/README.md +11 -11
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  3. package/dist/agents/agent.cjs +874 -0
  4. package/dist/agents/agent.d.cts +967 -0
  5. package/dist/agents/agent.d.cts.map +1 -0
  6. package/dist/agents/agent.d.mts +967 -0
  7. package/dist/agents/agent.d.mts.map +1 -0
  8. package/dist/agents/agent.mjs +863 -0
  9. package/dist/agents/agent.mjs.map +1 -0
  10. package/dist/agents/ai-agent.cjs +524 -0
  11. package/dist/agents/ai-agent.d.cts +401 -0
  12. package/dist/agents/ai-agent.d.cts.map +1 -0
  13. package/dist/agents/ai-agent.d.mts +401 -0
  14. package/dist/agents/ai-agent.d.mts.map +1 -0
  15. package/dist/agents/ai-agent.mjs +519 -0
  16. package/dist/agents/ai-agent.mjs.map +1 -0
  17. package/dist/agents/chat-model.cjs +397 -0
  18. package/dist/agents/chat-model.d.cts +674 -0
  19. package/dist/agents/chat-model.d.cts.map +1 -0
  20. package/dist/agents/chat-model.d.mts +674 -0
  21. package/dist/agents/chat-model.d.mts.map +1 -0
  22. package/dist/agents/chat-model.mjs +391 -0
  23. package/dist/agents/chat-model.mjs.map +1 -0
  24. package/dist/agents/guide-rail-agent.cjs +17 -0
  25. package/dist/agents/guide-rail-agent.d.cts +67 -0
  26. package/dist/agents/guide-rail-agent.d.cts.map +1 -0
  27. package/dist/agents/guide-rail-agent.d.mts +67 -0
  28. package/dist/agents/guide-rail-agent.d.mts.map +1 -0
  29. package/dist/agents/guide-rail-agent.mjs +17 -0
  30. package/dist/agents/guide-rail-agent.mjs.map +1 -0
  31. package/dist/agents/image-agent.cjs +74 -0
  32. package/dist/agents/image-agent.d.cts +44 -0
  33. package/dist/agents/image-agent.d.cts.map +1 -0
  34. package/dist/agents/image-agent.d.mts +44 -0
  35. package/dist/agents/image-agent.d.mts.map +1 -0
  36. package/dist/agents/image-agent.mjs +72 -0
  37. package/dist/agents/image-agent.mjs.map +1 -0
  38. package/dist/agents/image-model.cjs +83 -0
  39. package/dist/agents/image-model.d.cts +276 -0
  40. package/dist/agents/image-model.d.cts.map +1 -0
  41. package/dist/agents/image-model.d.mts +276 -0
  42. package/dist/agents/image-model.d.mts.map +1 -0
  43. package/dist/agents/image-model.mjs +81 -0
  44. package/dist/agents/image-model.mjs.map +1 -0
  45. package/dist/agents/mcp-agent.cjs +307 -0
  46. package/dist/agents/mcp-agent.d.cts +235 -0
  47. package/dist/agents/mcp-agent.d.cts.map +1 -0
  48. package/dist/agents/mcp-agent.d.mts +235 -0
  49. package/dist/agents/mcp-agent.d.mts.map +1 -0
  50. package/dist/agents/mcp-agent.mjs +303 -0
  51. package/dist/agents/mcp-agent.mjs.map +1 -0
  52. package/dist/agents/model.cjs +143 -0
  53. package/dist/agents/model.d.cts +257 -0
  54. package/dist/agents/model.d.cts.map +1 -0
  55. package/dist/agents/model.d.mts +257 -0
  56. package/dist/agents/model.d.mts.map +1 -0
  57. package/dist/agents/model.mjs +136 -0
  58. package/dist/agents/model.mjs.map +1 -0
  59. package/dist/agents/team-agent.cjs +342 -0
  60. package/dist/agents/team-agent.d.cts +390 -0
  61. package/dist/agents/team-agent.d.cts.map +1 -0
  62. package/dist/agents/team-agent.d.mts +390 -0
  63. package/dist/agents/team-agent.d.mts.map +1 -0
  64. package/dist/agents/team-agent.mjs +339 -0
  65. package/dist/agents/team-agent.mjs.map +1 -0
  66. package/dist/agents/transform-agent.cjs +77 -0
  67. package/dist/agents/transform-agent.d.cts +99 -0
  68. package/dist/agents/transform-agent.d.cts.map +1 -0
  69. package/dist/agents/transform-agent.d.mts +99 -0
  70. package/dist/agents/transform-agent.d.mts.map +1 -0
  71. package/dist/agents/transform-agent.mjs +76 -0
  72. package/dist/agents/transform-agent.mjs.map +1 -0
  73. package/dist/agents/types.cjs +30 -0
  74. package/dist/agents/types.d.cts +34 -0
  75. package/dist/agents/types.d.cts.map +1 -0
  76. package/dist/agents/types.d.mts +34 -0
  77. package/dist/agents/types.d.mts.map +1 -0
  78. package/dist/agents/types.mjs +25 -0
  79. package/dist/agents/types.mjs.map +1 -0
  80. package/dist/agents/user-agent.cjs +87 -0
  81. package/dist/agents/user-agent.d.cts +32 -0
  82. package/dist/agents/user-agent.d.cts.map +1 -0
  83. package/dist/agents/user-agent.d.mts +32 -0
  84. package/dist/agents/user-agent.d.mts.map +1 -0
  85. package/dist/agents/user-agent.mjs +88 -0
  86. package/dist/agents/user-agent.mjs.map +1 -0
  87. package/dist/agents/video-model.cjs +66 -0
  88. package/dist/agents/video-model.d.cts +286 -0
  89. package/dist/agents/video-model.d.cts.map +1 -0
  90. package/dist/agents/video-model.d.mts +286 -0
  91. package/dist/agents/video-model.d.mts.map +1 -0
  92. package/dist/agents/video-model.mjs +64 -0
  93. package/dist/agents/video-model.mjs.map +1 -0
  94. package/dist/aigne/aigne.cjs +235 -0
  95. package/dist/aigne/aigne.d.cts +340 -0
  96. package/dist/aigne/aigne.d.cts.map +1 -0
  97. package/dist/aigne/aigne.d.mts +340 -0
  98. package/dist/aigne/aigne.d.mts.map +1 -0
  99. package/dist/aigne/aigne.mjs +235 -0
  100. package/dist/aigne/aigne.mjs.map +1 -0
  101. package/dist/aigne/context.cjs +377 -0
  102. package/dist/aigne/context.d.cts +226 -0
  103. package/dist/aigne/context.d.cts.map +1 -0
  104. package/dist/aigne/context.d.mts +226 -0
  105. package/dist/aigne/context.d.mts.map +1 -0
  106. package/dist/aigne/context.mjs +376 -0
  107. package/dist/aigne/context.mjs.map +1 -0
  108. package/dist/aigne/index.cjs +4 -0
  109. package/dist/aigne/index.d.mts +5 -0
  110. package/dist/aigne/index.mjs +6 -0
  111. package/dist/aigne/message-queue.cjs +102 -0
  112. package/dist/aigne/message-queue.d.cts +52 -0
  113. package/dist/aigne/message-queue.d.cts.map +1 -0
  114. package/dist/aigne/message-queue.d.mts +52 -0
  115. package/dist/aigne/message-queue.d.mts.map +1 -0
  116. package/dist/aigne/message-queue.mjs +99 -0
  117. package/dist/aigne/message-queue.mjs.map +1 -0
  118. package/dist/aigne/type.d.cts +32 -0
  119. package/dist/aigne/type.d.cts.map +1 -0
  120. package/dist/aigne/type.d.mts +32 -0
  121. package/dist/aigne/type.d.mts.map +1 -0
  122. package/dist/aigne/usage.cjs +29 -0
  123. package/dist/aigne/usage.d.cts +32 -0
  124. package/dist/aigne/usage.d.cts.map +1 -0
  125. package/dist/aigne/usage.d.mts +32 -0
  126. package/dist/aigne/usage.d.mts.map +1 -0
  127. package/dist/aigne/usage.mjs +28 -0
  128. package/dist/aigne/usage.mjs.map +1 -0
  129. package/dist/index.cjs +142 -0
  130. package/dist/index.d.cts +29 -0
  131. package/dist/index.d.mts +31 -0
  132. package/dist/index.mjs +31 -0
  133. package/dist/loader/agent-js.cjs +23 -0
  134. package/dist/loader/agent-js.d.cts +9 -0
  135. package/dist/loader/agent-js.d.cts.map +1 -0
  136. package/dist/loader/agent-js.d.mts +10 -0
  137. package/dist/loader/agent-js.d.mts.map +1 -0
  138. package/dist/loader/agent-js.mjs +23 -0
  139. package/dist/loader/agent-js.mjs.map +1 -0
  140. package/dist/loader/agent-yaml.cjs +109 -0
  141. package/dist/loader/agent-yaml.d.cts +87 -0
  142. package/dist/loader/agent-yaml.d.cts.map +1 -0
  143. package/dist/loader/agent-yaml.d.mts +87 -0
  144. package/dist/loader/agent-yaml.d.mts.map +1 -0
  145. package/dist/loader/agent-yaml.mjs +106 -0
  146. package/dist/loader/agent-yaml.mjs.map +1 -0
  147. package/dist/loader/agents.cjs +19 -0
  148. package/dist/loader/agents.d.cts +9 -0
  149. package/dist/loader/agents.d.cts.map +1 -0
  150. package/dist/loader/agents.d.mts +9 -0
  151. package/dist/loader/agents.d.mts.map +1 -0
  152. package/dist/loader/agents.mjs +20 -0
  153. package/dist/loader/agents.mjs.map +1 -0
  154. package/dist/loader/error.cjs +6 -0
  155. package/dist/loader/error.d.cts +5 -0
  156. package/dist/loader/error.d.cts.map +1 -0
  157. package/dist/loader/error.d.mts +5 -0
  158. package/dist/loader/error.d.mts.map +1 -0
  159. package/dist/loader/error.mjs +6 -0
  160. package/dist/loader/error.mjs.map +1 -0
  161. package/dist/loader/function-agent.cjs +9 -0
  162. package/dist/loader/function-agent.d.cts +7 -0
  163. package/dist/loader/function-agent.d.cts.map +1 -0
  164. package/dist/loader/function-agent.d.mts +7 -0
  165. package/dist/loader/function-agent.d.mts.map +1 -0
  166. package/dist/loader/function-agent.mjs +9 -0
  167. package/dist/loader/function-agent.mjs.map +1 -0
  168. package/dist/loader/index.cjs +233 -0
  169. package/dist/loader/index.d.cts +255 -0
  170. package/dist/loader/index.d.cts.map +1 -0
  171. package/dist/loader/index.d.mts +255 -0
  172. package/dist/loader/index.d.mts.map +1 -0
  173. package/dist/loader/index.mjs +228 -0
  174. package/dist/loader/index.mjs.map +1 -0
  175. package/dist/loader/schema.cjs +135 -0
  176. package/dist/loader/schema.d.cts +177 -0
  177. package/dist/loader/schema.d.cts.map +1 -0
  178. package/dist/loader/schema.d.mts +177 -0
  179. package/dist/loader/schema.d.mts.map +1 -0
  180. package/dist/loader/schema.mjs +127 -0
  181. package/dist/loader/schema.mjs.map +1 -0
  182. package/dist/memory/index.cjs +3 -0
  183. package/dist/memory/index.d.mts +3 -0
  184. package/dist/memory/index.mjs +5 -0
  185. package/dist/memory/memory.cjs +134 -0
  186. package/dist/memory/memory.d.cts +103 -0
  187. package/dist/memory/memory.d.cts.map +1 -0
  188. package/dist/memory/memory.d.mts +103 -0
  189. package/dist/memory/memory.d.mts.map +1 -0
  190. package/dist/memory/memory.mjs +133 -0
  191. package/dist/memory/memory.mjs.map +1 -0
  192. package/dist/memory/recorder.cjs +61 -0
  193. package/dist/memory/recorder.d.cts +98 -0
  194. package/dist/memory/recorder.d.cts.map +1 -0
  195. package/dist/memory/recorder.d.mts +98 -0
  196. package/dist/memory/recorder.d.mts.map +1 -0
  197. package/dist/memory/recorder.mjs +59 -0
  198. package/dist/memory/recorder.mjs.map +1 -0
  199. package/dist/memory/retriever.cjs +60 -0
  200. package/dist/memory/retriever.d.cts +111 -0
  201. package/dist/memory/retriever.d.cts.map +1 -0
  202. package/dist/memory/retriever.d.mts +111 -0
  203. package/dist/memory/retriever.d.mts.map +1 -0
  204. package/dist/memory/retriever.mjs +58 -0
  205. package/dist/memory/retriever.mjs.map +1 -0
  206. package/dist/prompt/agent-session.cjs +700 -0
  207. package/dist/prompt/agent-session.d.cts +167 -0
  208. package/dist/prompt/agent-session.d.cts.map +1 -0
  209. package/dist/prompt/agent-session.d.mts +167 -0
  210. package/dist/prompt/agent-session.d.mts.map +1 -0
  211. package/dist/prompt/agent-session.mjs +700 -0
  212. package/dist/prompt/agent-session.mjs.map +1 -0
  213. package/dist/prompt/compact/compactor.cjs +50 -0
  214. package/dist/prompt/compact/compactor.mjs +50 -0
  215. package/dist/prompt/compact/compactor.mjs.map +1 -0
  216. package/dist/prompt/compact/session-memory-extractor.cjs +137 -0
  217. package/dist/prompt/compact/session-memory-extractor.mjs +137 -0
  218. package/dist/prompt/compact/session-memory-extractor.mjs.map +1 -0
  219. package/dist/prompt/compact/types.cjs +59 -0
  220. package/dist/prompt/compact/types.d.cts +341 -0
  221. package/dist/prompt/compact/types.d.cts.map +1 -0
  222. package/dist/prompt/compact/types.d.mts +341 -0
  223. package/dist/prompt/compact/types.d.mts.map +1 -0
  224. package/dist/prompt/compact/types.mjs +49 -0
  225. package/dist/prompt/compact/types.mjs.map +1 -0
  226. package/dist/prompt/compact/user-memory-extractor.cjs +118 -0
  227. package/dist/prompt/compact/user-memory-extractor.mjs +118 -0
  228. package/dist/prompt/compact/user-memory-extractor.mjs.map +1 -0
  229. package/dist/prompt/context/afs/history.cjs +30 -0
  230. package/dist/prompt/context/afs/history.mjs +30 -0
  231. package/dist/prompt/context/afs/history.mjs.map +1 -0
  232. package/dist/prompt/context/afs/index.cjs +60 -0
  233. package/dist/prompt/context/afs/index.mjs +61 -0
  234. package/dist/prompt/context/afs/index.mjs.map +1 -0
  235. package/dist/prompt/context/index.cjs +18 -0
  236. package/dist/prompt/context/index.mjs +19 -0
  237. package/dist/prompt/context/index.mjs.map +1 -0
  238. package/dist/prompt/filters/index.cjs +22 -0
  239. package/dist/prompt/filters/index.mjs +21 -0
  240. package/dist/prompt/filters/index.mjs.map +1 -0
  241. package/dist/prompt/prompt-builder.cjs +291 -0
  242. package/dist/prompt/prompt-builder.d.cts +57 -0
  243. package/dist/prompt/prompt-builder.d.cts.map +1 -0
  244. package/dist/prompt/prompt-builder.d.mts +57 -0
  245. package/dist/prompt/prompt-builder.d.mts.map +1 -0
  246. package/dist/prompt/prompt-builder.mjs +291 -0
  247. package/dist/prompt/prompt-builder.mjs.map +1 -0
  248. package/dist/prompt/prompts/afs-builtin-prompt.cjs +12 -0
  249. package/dist/prompt/prompts/afs-builtin-prompt.mjs +13 -0
  250. package/dist/prompt/prompts/afs-builtin-prompt.mjs.map +1 -0
  251. package/dist/prompt/prompts/memory-message-template.cjs +10 -0
  252. package/dist/prompt/prompts/memory-message-template.mjs +10 -0
  253. package/dist/prompt/prompts/memory-message-template.mjs.map +1 -0
  254. package/dist/prompt/prompts/structured-stream-instructions.cjs +30 -0
  255. package/dist/prompt/prompts/structured-stream-instructions.mjs +30 -0
  256. package/dist/prompt/prompts/structured-stream-instructions.mjs.map +1 -0
  257. package/dist/prompt/skills/afs/agent-skill/agent-skill.cjs +66 -0
  258. package/dist/prompt/skills/afs/agent-skill/agent-skill.mjs +66 -0
  259. package/dist/prompt/skills/afs/agent-skill/agent-skill.mjs.map +1 -0
  260. package/dist/prompt/skills/afs/agent-skill/skill-loader.cjs +42 -0
  261. package/dist/prompt/skills/afs/agent-skill/skill-loader.mjs +41 -0
  262. package/dist/prompt/skills/afs/agent-skill/skill-loader.mjs.map +1 -0
  263. package/dist/prompt/skills/afs/base.cjs +9 -0
  264. package/dist/prompt/skills/afs/base.mjs +10 -0
  265. package/dist/prompt/skills/afs/base.mjs.map +1 -0
  266. package/dist/prompt/skills/afs/delete.cjs +50 -0
  267. package/dist/prompt/skills/afs/delete.mjs +50 -0
  268. package/dist/prompt/skills/afs/delete.mjs.map +1 -0
  269. package/dist/prompt/skills/afs/edit.cjs +92 -0
  270. package/dist/prompt/skills/afs/edit.mjs +92 -0
  271. package/dist/prompt/skills/afs/edit.mjs.map +1 -0
  272. package/dist/prompt/skills/afs/exec.cjs +36 -0
  273. package/dist/prompt/skills/afs/exec.mjs +36 -0
  274. package/dist/prompt/skills/afs/exec.mjs.map +1 -0
  275. package/dist/prompt/skills/afs/index.cjs +28 -0
  276. package/dist/prompt/skills/afs/index.mjs +29 -0
  277. package/dist/prompt/skills/afs/index.mjs.map +1 -0
  278. package/dist/prompt/skills/afs/list.cjs +69 -0
  279. package/dist/prompt/skills/afs/list.mjs +69 -0
  280. package/dist/prompt/skills/afs/list.mjs.map +1 -0
  281. package/dist/prompt/skills/afs/read.cjs +86 -0
  282. package/dist/prompt/skills/afs/read.mjs +86 -0
  283. package/dist/prompt/skills/afs/read.mjs.map +1 -0
  284. package/dist/prompt/skills/afs/rename.cjs +53 -0
  285. package/dist/prompt/skills/afs/rename.mjs +53 -0
  286. package/dist/prompt/skills/afs/rename.mjs.map +1 -0
  287. package/dist/prompt/skills/afs/search.cjs +63 -0
  288. package/dist/prompt/skills/afs/search.mjs +63 -0
  289. package/dist/prompt/skills/afs/search.mjs.map +1 -0
  290. package/dist/prompt/skills/afs/write.cjs +51 -0
  291. package/dist/prompt/skills/afs/write.mjs +51 -0
  292. package/dist/prompt/skills/afs/write.mjs.map +1 -0
  293. package/dist/prompt/template.cjs +229 -0
  294. package/dist/prompt/template.d.cts +247 -0
  295. package/dist/prompt/template.d.cts.map +1 -0
  296. package/dist/prompt/template.d.mts +247 -0
  297. package/dist/prompt/template.d.mts.map +1 -0
  298. package/dist/prompt/template.mjs +219 -0
  299. package/dist/prompt/template.mjs.map +1 -0
  300. package/dist/utils/agent-utils.cjs +49 -0
  301. package/dist/utils/agent-utils.d.cts +22 -0
  302. package/dist/utils/agent-utils.d.cts.map +1 -0
  303. package/dist/utils/agent-utils.d.mts +22 -0
  304. package/dist/utils/agent-utils.d.mts.map +1 -0
  305. package/dist/utils/agent-utils.mjs +46 -0
  306. package/dist/utils/agent-utils.mjs.map +1 -0
  307. package/dist/utils/camelize.cjs +34 -0
  308. package/dist/utils/camelize.d.cts +9 -0
  309. package/dist/utils/camelize.d.cts.map +1 -0
  310. package/dist/utils/camelize.d.mts +9 -0
  311. package/dist/utils/camelize.d.mts.map +1 -0
  312. package/dist/utils/camelize.mjs +33 -0
  313. package/dist/utils/camelize.mjs.map +1 -0
  314. package/dist/utils/event-stream.cjs +136 -0
  315. package/dist/utils/event-stream.d.cts +20 -0
  316. package/dist/utils/event-stream.d.cts.map +1 -0
  317. package/dist/utils/event-stream.d.mts +20 -0
  318. package/dist/utils/event-stream.d.mts.map +1 -0
  319. package/dist/utils/event-stream.mjs +133 -0
  320. package/dist/utils/event-stream.mjs.map +1 -0
  321. package/dist/utils/fetch.cjs +32 -0
  322. package/dist/utils/fetch.d.cts +8 -0
  323. package/dist/utils/fetch.d.cts.map +1 -0
  324. package/dist/utils/fetch.d.mts +8 -0
  325. package/dist/utils/fetch.d.mts.map +1 -0
  326. package/dist/utils/fetch.mjs +32 -0
  327. package/dist/utils/fetch.mjs.map +1 -0
  328. package/dist/utils/json-schema.cjs +107 -0
  329. package/dist/utils/json-schema.d.cts +20 -0
  330. package/dist/utils/json-schema.d.cts.map +1 -0
  331. package/dist/utils/json-schema.d.mts +20 -0
  332. package/dist/utils/json-schema.d.mts.map +1 -0
  333. package/dist/utils/json-schema.mjs +102 -0
  334. package/dist/utils/json-schema.mjs.map +1 -0
  335. package/dist/utils/json-utils.cjs +46 -0
  336. package/dist/utils/json-utils.d.cts +28 -0
  337. package/dist/utils/json-utils.d.cts.map +1 -0
  338. package/dist/utils/json-utils.d.mts +28 -0
  339. package/dist/utils/json-utils.d.mts.map +1 -0
  340. package/dist/utils/json-utils.mjs +44 -0
  341. package/dist/utils/json-utils.mjs.map +1 -0
  342. package/dist/utils/logger.cjs +72 -0
  343. package/dist/utils/logger.d.cts +41 -0
  344. package/dist/utils/logger.d.cts.map +1 -0
  345. package/dist/utils/logger.d.mts +41 -0
  346. package/dist/utils/logger.d.mts.map +1 -0
  347. package/dist/utils/logger.mjs +68 -0
  348. package/dist/utils/logger.mjs.map +1 -0
  349. package/dist/utils/mcp-utils.cjs +53 -0
  350. package/dist/utils/mcp-utils.d.cts +10 -0
  351. package/dist/utils/mcp-utils.d.cts.map +1 -0
  352. package/dist/utils/mcp-utils.d.mts +10 -0
  353. package/dist/utils/mcp-utils.d.mts.map +1 -0
  354. package/dist/utils/mcp-utils.mjs +51 -0
  355. package/dist/utils/mcp-utils.mjs.map +1 -0
  356. package/dist/utils/model-utils.cjs +12 -0
  357. package/dist/utils/model-utils.d.cts +8 -0
  358. package/dist/utils/model-utils.d.cts.map +1 -0
  359. package/dist/utils/model-utils.d.mts +8 -0
  360. package/dist/utils/model-utils.d.mts.map +1 -0
  361. package/dist/utils/model-utils.mjs +12 -0
  362. package/dist/utils/model-utils.mjs.map +1 -0
  363. package/dist/utils/promise.cjs +17 -0
  364. package/dist/utils/promise.d.cts +10 -0
  365. package/dist/utils/promise.d.cts.map +1 -0
  366. package/dist/utils/promise.d.mts +10 -0
  367. package/dist/utils/promise.d.mts.map +1 -0
  368. package/dist/utils/promise.mjs +17 -0
  369. package/dist/utils/promise.mjs.map +1 -0
  370. package/dist/utils/prompts.cjs +19 -0
  371. package/dist/utils/prompts.d.cts +6 -0
  372. package/dist/utils/prompts.d.cts.map +1 -0
  373. package/dist/utils/prompts.d.mts +6 -0
  374. package/dist/utils/prompts.d.mts.map +1 -0
  375. package/dist/utils/prompts.mjs +18 -0
  376. package/dist/utils/prompts.mjs.map +1 -0
  377. package/dist/utils/queue.cjs +273 -0
  378. package/dist/utils/queue.d.cts +60 -0
  379. package/dist/utils/queue.d.cts.map +1 -0
  380. package/dist/utils/queue.d.mts +60 -0
  381. package/dist/utils/queue.d.mts.map +1 -0
  382. package/dist/utils/queue.mjs +271 -0
  383. package/dist/utils/queue.mjs.map +1 -0
  384. package/dist/utils/role-utils.cjs +40 -0
  385. package/dist/utils/role-utils.d.cts +32 -0
  386. package/dist/utils/role-utils.d.cts.map +1 -0
  387. package/dist/utils/role-utils.d.mts +32 -0
  388. package/dist/utils/role-utils.d.mts.map +1 -0
  389. package/dist/utils/role-utils.mjs +38 -0
  390. package/dist/utils/role-utils.mjs.map +1 -0
  391. package/dist/utils/stream-polyfill.cjs +37 -0
  392. package/dist/utils/stream-polyfill.d.cts +1 -0
  393. package/dist/utils/stream-polyfill.d.mts +1 -0
  394. package/dist/utils/stream-polyfill.mjs +38 -0
  395. package/dist/utils/stream-polyfill.mjs.map +1 -0
  396. package/dist/utils/stream-utils.cjs +187 -0
  397. package/dist/utils/stream-utils.d.cts +30 -0
  398. package/dist/utils/stream-utils.d.cts.map +1 -0
  399. package/dist/utils/stream-utils.d.mts +30 -0
  400. package/dist/utils/stream-utils.d.mts.map +1 -0
  401. package/dist/utils/stream-utils.mjs +174 -0
  402. package/dist/utils/stream-utils.mjs.map +1 -0
  403. package/dist/utils/structured-stream-extractor.cjs +63 -0
  404. package/dist/utils/structured-stream-extractor.d.cts +23 -0
  405. package/dist/utils/structured-stream-extractor.d.cts.map +1 -0
  406. package/dist/utils/structured-stream-extractor.d.mts +23 -0
  407. package/dist/utils/structured-stream-extractor.d.mts.map +1 -0
  408. package/dist/utils/structured-stream-extractor.mjs +64 -0
  409. package/dist/utils/structured-stream-extractor.mjs.map +1 -0
  410. package/dist/utils/test/agent-response.cjs +16 -0
  411. package/dist/utils/test/agent-response.d.cts +12 -0
  412. package/dist/utils/test/agent-response.d.cts.map +1 -0
  413. package/dist/utils/test/agent-response.d.mts +13 -0
  414. package/dist/utils/test/agent-response.d.mts.map +1 -0
  415. package/dist/utils/test/agent-response.mjs +17 -0
  416. package/dist/utils/test/agent-response.mjs.map +1 -0
  417. package/dist/utils/test/openai-like-utils.cjs +73 -0
  418. package/dist/utils/test/openai-like-utils.d.cts +13 -0
  419. package/dist/utils/test/openai-like-utils.d.cts.map +1 -0
  420. package/dist/utils/test/openai-like-utils.d.mts +14 -0
  421. package/dist/utils/test/openai-like-utils.d.mts.map +1 -0
  422. package/dist/utils/test/openai-like-utils.mjs +68 -0
  423. package/dist/utils/test/openai-like-utils.mjs.map +1 -0
  424. package/dist/utils/token-estimator.cjs +57 -0
  425. package/dist/utils/token-estimator.d.cts +13 -0
  426. package/dist/utils/token-estimator.d.cts.map +1 -0
  427. package/dist/utils/token-estimator.d.mts +13 -0
  428. package/dist/utils/token-estimator.d.mts.map +1 -0
  429. package/dist/utils/token-estimator.mjs +57 -0
  430. package/dist/utils/token-estimator.mjs.map +1 -0
  431. package/dist/utils/type-utils.cjs +159 -0
  432. package/dist/utils/type-utils.d.cts +32 -0
  433. package/dist/utils/type-utils.d.cts.map +1 -0
  434. package/dist/utils/type-utils.d.mts +32 -0
  435. package/dist/utils/type-utils.d.mts.map +1 -0
  436. package/dist/utils/type-utils.mjs +141 -0
  437. package/dist/utils/type-utils.mjs.map +1 -0
  438. package/dist/utils/typed-event-emitter.cjs +0 -0
  439. package/dist/utils/typed-event-emitter.d.cts +13 -0
  440. package/dist/utils/typed-event-emitter.d.cts.map +1 -0
  441. package/dist/utils/typed-event-emitter.d.mts +13 -0
  442. package/dist/utils/typed-event-emitter.d.mts.map +1 -0
  443. package/dist/utils/typed-event-emitter.mjs +1 -0
  444. package/package.json +143 -62
  445. package/CHANGELOG.md +0 -2584
  446. package/lib/cjs/agents/agent.d.ts +0 -961
  447. package/lib/cjs/agents/agent.js +0 -961
  448. package/lib/cjs/agents/ai-agent.d.ts +0 -395
  449. package/lib/cjs/agents/ai-agent.js +0 -572
  450. package/lib/cjs/agents/chat-model.d.ts +0 -672
  451. package/lib/cjs/agents/chat-model.js +0 -457
  452. package/lib/cjs/agents/guide-rail-agent.d.ts +0 -62
  453. package/lib/cjs/agents/guide-rail-agent.js +0 -14
  454. package/lib/cjs/agents/image-agent.d.ts +0 -38
  455. package/lib/cjs/agents/image-agent.js +0 -71
  456. package/lib/cjs/agents/image-model.d.ts +0 -270
  457. package/lib/cjs/agents/image-model.js +0 -91
  458. package/lib/cjs/agents/mcp-agent.d.ts +0 -231
  459. package/lib/cjs/agents/mcp-agent.js +0 -366
  460. package/lib/cjs/agents/model.d.ts +0 -252
  461. package/lib/cjs/agents/model.js +0 -180
  462. package/lib/cjs/agents/team-agent.d.ts +0 -382
  463. package/lib/cjs/agents/team-agent.js +0 -386
  464. package/lib/cjs/agents/transform-agent.d.ts +0 -94
  465. package/lib/cjs/agents/transform-agent.js +0 -80
  466. package/lib/cjs/agents/types.d.ts +0 -31
  467. package/lib/cjs/agents/types.js +0 -40
  468. package/lib/cjs/agents/user-agent.d.ts +0 -27
  469. package/lib/cjs/agents/user-agent.js +0 -90
  470. package/lib/cjs/agents/video-model.d.ts +0 -280
  471. package/lib/cjs/agents/video-model.js +0 -67
  472. package/lib/cjs/aigne/aigne.d.ts +0 -335
  473. package/lib/cjs/aigne/aigne.js +0 -248
  474. package/lib/cjs/aigne/context.d.ts +0 -220
  475. package/lib/cjs/aigne/context.js +0 -423
  476. package/lib/cjs/aigne/index.d.ts +0 -4
  477. package/lib/cjs/aigne/index.js +0 -20
  478. package/lib/cjs/aigne/message-queue.d.ts +0 -48
  479. package/lib/cjs/aigne/message-queue.js +0 -109
  480. package/lib/cjs/aigne/type.d.ts +0 -26
  481. package/lib/cjs/aigne/type.js +0 -2
  482. package/lib/cjs/aigne/usage.d.ts +0 -28
  483. package/lib/cjs/aigne/usage.js +0 -34
  484. package/lib/cjs/index.d.ts +0 -21
  485. package/lib/cjs/index.js +0 -37
  486. package/lib/cjs/loader/agent-js.d.ts +0 -2
  487. package/lib/cjs/loader/agent-js.js +0 -21
  488. package/lib/cjs/loader/agent-yaml.d.ts +0 -78
  489. package/lib/cjs/loader/agent-yaml.js +0 -120
  490. package/lib/cjs/loader/agents.d.ts +0 -4
  491. package/lib/cjs/loader/agents.js +0 -17
  492. package/lib/cjs/loader/error.d.ts +0 -2
  493. package/lib/cjs/loader/error.js +0 -6
  494. package/lib/cjs/loader/function-agent.d.ts +0 -2
  495. package/lib/cjs/loader/function-agent.js +0 -7
  496. package/lib/cjs/loader/index.d.ts +0 -247
  497. package/lib/cjs/loader/index.js +0 -266
  498. package/lib/cjs/loader/schema.d.ts +0 -167
  499. package/lib/cjs/loader/schema.js +0 -162
  500. package/lib/cjs/memory/index.d.ts +0 -3
  501. package/lib/cjs/memory/index.js +0 -19
  502. package/lib/cjs/memory/memory.d.ts +0 -93
  503. package/lib/cjs/memory/memory.js +0 -147
  504. package/lib/cjs/memory/recorder.d.ts +0 -93
  505. package/lib/cjs/memory/recorder.js +0 -63
  506. package/lib/cjs/memory/retriever.d.ts +0 -106
  507. package/lib/cjs/memory/retriever.js +0 -60
  508. package/lib/cjs/package.json +0 -3
  509. package/lib/cjs/prompt/agent-session.d.ts +0 -163
  510. package/lib/cjs/prompt/agent-session.js +0 -1008
  511. package/lib/cjs/prompt/compact/compactor.d.ts +0 -7
  512. package/lib/cjs/prompt/compact/compactor.js +0 -52
  513. package/lib/cjs/prompt/compact/session-memory-extractor.d.ts +0 -7
  514. package/lib/cjs/prompt/compact/session-memory-extractor.js +0 -143
  515. package/lib/cjs/prompt/compact/types.d.ts +0 -336
  516. package/lib/cjs/prompt/compact/types.js +0 -53
  517. package/lib/cjs/prompt/compact/user-memory-extractor.d.ts +0 -7
  518. package/lib/cjs/prompt/compact/user-memory-extractor.js +0 -124
  519. package/lib/cjs/prompt/context/afs/history.d.ts +0 -9
  520. package/lib/cjs/prompt/context/afs/history.js +0 -33
  521. package/lib/cjs/prompt/context/afs/index.d.ts +0 -20
  522. package/lib/cjs/prompt/context/afs/index.js +0 -54
  523. package/lib/cjs/prompt/context/index.d.ts +0 -31
  524. package/lib/cjs/prompt/context/index.js +0 -18
  525. package/lib/cjs/prompt/filters/index.d.ts +0 -2
  526. package/lib/cjs/prompt/filters/index.js +0 -51
  527. package/lib/cjs/prompt/prompt-builder.d.ts +0 -50
  528. package/lib/cjs/prompt/prompt-builder.js +0 -352
  529. package/lib/cjs/prompt/prompts/afs-builtin-prompt.d.ts +0 -4
  530. package/lib/cjs/prompt/prompts/afs-builtin-prompt.js +0 -36
  531. package/lib/cjs/prompt/prompts/memory-message-template.d.ts +0 -1
  532. package/lib/cjs/prompt/prompts/memory-message-template.js +0 -8
  533. package/lib/cjs/prompt/prompts/structured-stream-instructions.d.ts +0 -7
  534. package/lib/cjs/prompt/prompts/structured-stream-instructions.js +0 -27
  535. package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.d.ts +0 -19
  536. package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.js +0 -69
  537. package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.d.ts +0 -12
  538. package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.js +0 -50
  539. package/lib/cjs/prompt/skills/afs/base.d.ts +0 -4
  540. package/lib/cjs/prompt/skills/afs/base.js +0 -8
  541. package/lib/cjs/prompt/skills/afs/delete.d.ts +0 -19
  542. package/lib/cjs/prompt/skills/afs/delete.js +0 -54
  543. package/lib/cjs/prompt/skills/afs/edit.d.ts +0 -24
  544. package/lib/cjs/prompt/skills/afs/edit.js +0 -124
  545. package/lib/cjs/prompt/skills/afs/exec.d.ts +0 -16
  546. package/lib/cjs/prompt/skills/afs/exec.js +0 -43
  547. package/lib/cjs/prompt/skills/afs/index.d.ts +0 -3
  548. package/lib/cjs/prompt/skills/afs/index.js +0 -26
  549. package/lib/cjs/prompt/skills/afs/list.d.ts +0 -24
  550. package/lib/cjs/prompt/skills/afs/list.js +0 -81
  551. package/lib/cjs/prompt/skills/afs/read.d.ts +0 -28
  552. package/lib/cjs/prompt/skills/afs/read.js +0 -105
  553. package/lib/cjs/prompt/skills/afs/rename.d.ts +0 -21
  554. package/lib/cjs/prompt/skills/afs/rename.js +0 -59
  555. package/lib/cjs/prompt/skills/afs/search.d.ts +0 -24
  556. package/lib/cjs/prompt/skills/afs/search.js +0 -71
  557. package/lib/cjs/prompt/skills/afs/write.d.ts +0 -20
  558. package/lib/cjs/prompt/skills/afs/write.js +0 -59
  559. package/lib/cjs/prompt/template.d.ts +0 -243
  560. package/lib/cjs/prompt/template.js +0 -265
  561. package/lib/cjs/utils/agent-utils.d.ts +0 -13
  562. package/lib/cjs/utils/agent-utils.js +0 -60
  563. package/lib/cjs/utils/camelize.d.ts +0 -7
  564. package/lib/cjs/utils/camelize.js +0 -38
  565. package/lib/cjs/utils/event-stream.d.ts +0 -15
  566. package/lib/cjs/utils/event-stream.js +0 -158
  567. package/lib/cjs/utils/fetch.d.ts +0 -4
  568. package/lib/cjs/utils/fetch.js +0 -36
  569. package/lib/cjs/utils/json-schema.d.ts +0 -15
  570. package/lib/cjs/utils/json-schema.js +0 -123
  571. package/lib/cjs/utils/json-utils.d.ts +0 -24
  572. package/lib/cjs/utils/json-utils.js +0 -48
  573. package/lib/cjs/utils/logger.d.ts +0 -39
  574. package/lib/cjs/utils/logger.js +0 -81
  575. package/lib/cjs/utils/mcp-utils.d.ts +0 -5
  576. package/lib/cjs/utils/mcp-utils.js +0 -52
  577. package/lib/cjs/utils/model-utils.d.ts +0 -3
  578. package/lib/cjs/utils/model-utils.js +0 -10
  579. package/lib/cjs/utils/promise.d.ts +0 -6
  580. package/lib/cjs/utils/promise.js +0 -12
  581. package/lib/cjs/utils/prompts.d.ts +0 -2
  582. package/lib/cjs/utils/prompts.js +0 -22
  583. package/lib/cjs/utils/queue.d.ts +0 -57
  584. package/lib/cjs/utils/queue.js +0 -318
  585. package/lib/cjs/utils/role-utils.d.ts +0 -31
  586. package/lib/cjs/utils/role-utils.js +0 -37
  587. package/lib/cjs/utils/stream-polyfill.d.ts +0 -1
  588. package/lib/cjs/utils/stream-polyfill.js +0 -38
  589. package/lib/cjs/utils/stream-utils.d.ts +0 -26
  590. package/lib/cjs/utils/stream-utils.js +0 -235
  591. package/lib/cjs/utils/structured-stream-extractor.d.ts +0 -14
  592. package/lib/cjs/utils/structured-stream-extractor.js +0 -68
  593. package/lib/cjs/utils/token-estimator.d.ts +0 -9
  594. package/lib/cjs/utils/token-estimator.js +0 -66
  595. package/lib/cjs/utils/type-utils.d.ts +0 -31
  596. package/lib/cjs/utils/type-utils.js +0 -202
  597. package/lib/cjs/utils/typed-event-emitter.d.ts +0 -10
  598. package/lib/cjs/utils/typed-event-emitter.js +0 -2
  599. package/lib/dts/agents/agent.d.ts +0 -961
  600. package/lib/dts/agents/ai-agent.d.ts +0 -395
  601. package/lib/dts/agents/chat-model.d.ts +0 -672
  602. package/lib/dts/agents/guide-rail-agent.d.ts +0 -62
  603. package/lib/dts/agents/image-agent.d.ts +0 -38
  604. package/lib/dts/agents/image-model.d.ts +0 -270
  605. package/lib/dts/agents/mcp-agent.d.ts +0 -231
  606. package/lib/dts/agents/model.d.ts +0 -252
  607. package/lib/dts/agents/team-agent.d.ts +0 -382
  608. package/lib/dts/agents/transform-agent.d.ts +0 -94
  609. package/lib/dts/agents/types.d.ts +0 -31
  610. package/lib/dts/agents/user-agent.d.ts +0 -27
  611. package/lib/dts/agents/video-model.d.ts +0 -280
  612. package/lib/dts/aigne/aigne.d.ts +0 -335
  613. package/lib/dts/aigne/context.d.ts +0 -220
  614. package/lib/dts/aigne/index.d.ts +0 -4
  615. package/lib/dts/aigne/message-queue.d.ts +0 -48
  616. package/lib/dts/aigne/type.d.ts +0 -26
  617. package/lib/dts/aigne/usage.d.ts +0 -28
  618. package/lib/dts/index.d.ts +0 -21
  619. package/lib/dts/loader/agent-js.d.ts +0 -2
  620. package/lib/dts/loader/agent-yaml.d.ts +0 -78
  621. package/lib/dts/loader/agents.d.ts +0 -4
  622. package/lib/dts/loader/error.d.ts +0 -2
  623. package/lib/dts/loader/function-agent.d.ts +0 -2
  624. package/lib/dts/loader/index.d.ts +0 -247
  625. package/lib/dts/loader/schema.d.ts +0 -167
  626. package/lib/dts/memory/index.d.ts +0 -3
  627. package/lib/dts/memory/memory.d.ts +0 -93
  628. package/lib/dts/memory/recorder.d.ts +0 -93
  629. package/lib/dts/memory/retriever.d.ts +0 -106
  630. package/lib/dts/prompt/agent-session.d.ts +0 -163
  631. package/lib/dts/prompt/compact/compactor.d.ts +0 -7
  632. package/lib/dts/prompt/compact/session-memory-extractor.d.ts +0 -7
  633. package/lib/dts/prompt/compact/types.d.ts +0 -336
  634. package/lib/dts/prompt/compact/user-memory-extractor.d.ts +0 -7
  635. package/lib/dts/prompt/context/afs/history.d.ts +0 -9
  636. package/lib/dts/prompt/context/afs/index.d.ts +0 -20
  637. package/lib/dts/prompt/context/index.d.ts +0 -31
  638. package/lib/dts/prompt/filters/index.d.ts +0 -2
  639. package/lib/dts/prompt/prompt-builder.d.ts +0 -50
  640. package/lib/dts/prompt/prompts/afs-builtin-prompt.d.ts +0 -4
  641. package/lib/dts/prompt/prompts/memory-message-template.d.ts +0 -1
  642. package/lib/dts/prompt/prompts/structured-stream-instructions.d.ts +0 -7
  643. package/lib/dts/prompt/skills/afs/agent-skill/agent-skill.d.ts +0 -19
  644. package/lib/dts/prompt/skills/afs/agent-skill/skill-loader.d.ts +0 -12
  645. package/lib/dts/prompt/skills/afs/base.d.ts +0 -4
  646. package/lib/dts/prompt/skills/afs/delete.d.ts +0 -19
  647. package/lib/dts/prompt/skills/afs/edit.d.ts +0 -24
  648. package/lib/dts/prompt/skills/afs/exec.d.ts +0 -16
  649. package/lib/dts/prompt/skills/afs/index.d.ts +0 -3
  650. package/lib/dts/prompt/skills/afs/list.d.ts +0 -24
  651. package/lib/dts/prompt/skills/afs/read.d.ts +0 -28
  652. package/lib/dts/prompt/skills/afs/rename.d.ts +0 -21
  653. package/lib/dts/prompt/skills/afs/search.d.ts +0 -24
  654. package/lib/dts/prompt/skills/afs/write.d.ts +0 -20
  655. package/lib/dts/prompt/template.d.ts +0 -243
  656. package/lib/dts/utils/agent-utils.d.ts +0 -13
  657. package/lib/dts/utils/camelize.d.ts +0 -7
  658. package/lib/dts/utils/event-stream.d.ts +0 -15
  659. package/lib/dts/utils/fetch.d.ts +0 -4
  660. package/lib/dts/utils/json-schema.d.ts +0 -15
  661. package/lib/dts/utils/json-utils.d.ts +0 -24
  662. package/lib/dts/utils/logger.d.ts +0 -39
  663. package/lib/dts/utils/mcp-utils.d.ts +0 -5
  664. package/lib/dts/utils/model-utils.d.ts +0 -3
  665. package/lib/dts/utils/promise.d.ts +0 -6
  666. package/lib/dts/utils/prompts.d.ts +0 -2
  667. package/lib/dts/utils/queue.d.ts +0 -57
  668. package/lib/dts/utils/role-utils.d.ts +0 -31
  669. package/lib/dts/utils/stream-polyfill.d.ts +0 -1
  670. package/lib/dts/utils/stream-utils.d.ts +0 -26
  671. package/lib/dts/utils/structured-stream-extractor.d.ts +0 -14
  672. package/lib/dts/utils/token-estimator.d.ts +0 -9
  673. package/lib/dts/utils/type-utils.d.ts +0 -31
  674. package/lib/dts/utils/typed-event-emitter.d.ts +0 -10
  675. package/lib/esm/agents/agent.d.ts +0 -961
  676. package/lib/esm/agents/agent.js +0 -911
  677. package/lib/esm/agents/ai-agent.d.ts +0 -395
  678. package/lib/esm/agents/ai-agent.js +0 -535
  679. package/lib/esm/agents/chat-model.d.ts +0 -672
  680. package/lib/esm/agents/chat-model.js +0 -419
  681. package/lib/esm/agents/guide-rail-agent.d.ts +0 -62
  682. package/lib/esm/agents/guide-rail-agent.js +0 -11
  683. package/lib/esm/agents/image-agent.d.ts +0 -38
  684. package/lib/esm/agents/image-agent.js +0 -64
  685. package/lib/esm/agents/image-model.d.ts +0 -270
  686. package/lib/esm/agents/image-model.js +0 -87
  687. package/lib/esm/agents/mcp-agent.d.ts +0 -231
  688. package/lib/esm/agents/mcp-agent.js +0 -325
  689. package/lib/esm/agents/model.d.ts +0 -252
  690. package/lib/esm/agents/model.js +0 -143
  691. package/lib/esm/agents/team-agent.d.ts +0 -382
  692. package/lib/esm/agents/team-agent.js +0 -346
  693. package/lib/esm/agents/transform-agent.d.ts +0 -94
  694. package/lib/esm/agents/transform-agent.js +0 -73
  695. package/lib/esm/agents/types.d.ts +0 -31
  696. package/lib/esm/agents/types.js +0 -30
  697. package/lib/esm/agents/user-agent.d.ts +0 -27
  698. package/lib/esm/agents/user-agent.js +0 -86
  699. package/lib/esm/agents/video-model.d.ts +0 -280
  700. package/lib/esm/agents/video-model.js +0 -63
  701. package/lib/esm/aigne/aigne.d.ts +0 -335
  702. package/lib/esm/aigne/aigne.js +0 -244
  703. package/lib/esm/aigne/context.d.ts +0 -220
  704. package/lib/esm/aigne/context.js +0 -416
  705. package/lib/esm/aigne/index.d.ts +0 -4
  706. package/lib/esm/aigne/index.js +0 -4
  707. package/lib/esm/aigne/message-queue.d.ts +0 -48
  708. package/lib/esm/aigne/message-queue.js +0 -104
  709. package/lib/esm/aigne/type.d.ts +0 -26
  710. package/lib/esm/aigne/type.js +0 -1
  711. package/lib/esm/aigne/usage.d.ts +0 -28
  712. package/lib/esm/aigne/usage.js +0 -30
  713. package/lib/esm/index.d.ts +0 -21
  714. package/lib/esm/index.js +0 -21
  715. package/lib/esm/loader/agent-js.d.ts +0 -2
  716. package/lib/esm/loader/agent-js.js +0 -18
  717. package/lib/esm/loader/agent-yaml.d.ts +0 -78
  718. package/lib/esm/loader/agent-yaml.js +0 -113
  719. package/lib/esm/loader/agents.d.ts +0 -4
  720. package/lib/esm/loader/agents.js +0 -14
  721. package/lib/esm/loader/error.d.ts +0 -2
  722. package/lib/esm/loader/error.js +0 -2
  723. package/lib/esm/loader/function-agent.d.ts +0 -2
  724. package/lib/esm/loader/function-agent.js +0 -4
  725. package/lib/esm/loader/index.d.ts +0 -247
  726. package/lib/esm/loader/index.js +0 -258
  727. package/lib/esm/loader/schema.d.ts +0 -167
  728. package/lib/esm/loader/schema.js +0 -153
  729. package/lib/esm/memory/index.d.ts +0 -3
  730. package/lib/esm/memory/index.js +0 -3
  731. package/lib/esm/memory/memory.d.ts +0 -93
  732. package/lib/esm/memory/memory.js +0 -142
  733. package/lib/esm/memory/recorder.d.ts +0 -93
  734. package/lib/esm/memory/recorder.js +0 -59
  735. package/lib/esm/memory/retriever.d.ts +0 -106
  736. package/lib/esm/memory/retriever.js +0 -56
  737. package/lib/esm/package.json +0 -3
  738. package/lib/esm/prompt/agent-session.d.ts +0 -163
  739. package/lib/esm/prompt/agent-session.js +0 -968
  740. package/lib/esm/prompt/compact/compactor.d.ts +0 -7
  741. package/lib/esm/prompt/compact/compactor.js +0 -48
  742. package/lib/esm/prompt/compact/session-memory-extractor.d.ts +0 -7
  743. package/lib/esm/prompt/compact/session-memory-extractor.js +0 -139
  744. package/lib/esm/prompt/compact/types.d.ts +0 -336
  745. package/lib/esm/prompt/compact/types.js +0 -50
  746. package/lib/esm/prompt/compact/user-memory-extractor.d.ts +0 -7
  747. package/lib/esm/prompt/compact/user-memory-extractor.js +0 -120
  748. package/lib/esm/prompt/context/afs/history.d.ts +0 -9
  749. package/lib/esm/prompt/context/afs/history.js +0 -30
  750. package/lib/esm/prompt/context/afs/index.d.ts +0 -20
  751. package/lib/esm/prompt/context/afs/index.js +0 -51
  752. package/lib/esm/prompt/context/index.d.ts +0 -31
  753. package/lib/esm/prompt/context/index.js +0 -15
  754. package/lib/esm/prompt/filters/index.d.ts +0 -2
  755. package/lib/esm/prompt/filters/index.js +0 -15
  756. package/lib/esm/prompt/prompt-builder.d.ts +0 -50
  757. package/lib/esm/prompt/prompt-builder.js +0 -348
  758. package/lib/esm/prompt/prompts/afs-builtin-prompt.d.ts +0 -4
  759. package/lib/esm/prompt/prompts/afs-builtin-prompt.js +0 -32
  760. package/lib/esm/prompt/prompts/memory-message-template.d.ts +0 -1
  761. package/lib/esm/prompt/prompts/memory-message-template.js +0 -5
  762. package/lib/esm/prompt/prompts/structured-stream-instructions.d.ts +0 -7
  763. package/lib/esm/prompt/prompts/structured-stream-instructions.js +0 -24
  764. package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.d.ts +0 -19
  765. package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.js +0 -65
  766. package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.d.ts +0 -12
  767. package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.js +0 -43
  768. package/lib/esm/prompt/skills/afs/base.d.ts +0 -4
  769. package/lib/esm/prompt/skills/afs/base.js +0 -4
  770. package/lib/esm/prompt/skills/afs/delete.d.ts +0 -19
  771. package/lib/esm/prompt/skills/afs/delete.js +0 -50
  772. package/lib/esm/prompt/skills/afs/edit.d.ts +0 -24
  773. package/lib/esm/prompt/skills/afs/edit.js +0 -120
  774. package/lib/esm/prompt/skills/afs/exec.d.ts +0 -16
  775. package/lib/esm/prompt/skills/afs/exec.js +0 -39
  776. package/lib/esm/prompt/skills/afs/index.d.ts +0 -3
  777. package/lib/esm/prompt/skills/afs/index.js +0 -23
  778. package/lib/esm/prompt/skills/afs/list.d.ts +0 -24
  779. package/lib/esm/prompt/skills/afs/list.js +0 -77
  780. package/lib/esm/prompt/skills/afs/read.d.ts +0 -28
  781. package/lib/esm/prompt/skills/afs/read.js +0 -101
  782. package/lib/esm/prompt/skills/afs/rename.d.ts +0 -21
  783. package/lib/esm/prompt/skills/afs/rename.js +0 -55
  784. package/lib/esm/prompt/skills/afs/search.d.ts +0 -24
  785. package/lib/esm/prompt/skills/afs/search.js +0 -67
  786. package/lib/esm/prompt/skills/afs/write.d.ts +0 -20
  787. package/lib/esm/prompt/skills/afs/write.js +0 -55
  788. package/lib/esm/prompt/template.d.ts +0 -243
  789. package/lib/esm/prompt/template.js +0 -249
  790. package/lib/esm/utils/agent-utils.d.ts +0 -13
  791. package/lib/esm/utils/agent-utils.js +0 -54
  792. package/lib/esm/utils/camelize.d.ts +0 -7
  793. package/lib/esm/utils/camelize.js +0 -34
  794. package/lib/esm/utils/event-stream.d.ts +0 -15
  795. package/lib/esm/utils/event-stream.js +0 -151
  796. package/lib/esm/utils/fetch.d.ts +0 -4
  797. package/lib/esm/utils/fetch.js +0 -33
  798. package/lib/esm/utils/json-schema.d.ts +0 -15
  799. package/lib/esm/utils/json-schema.js +0 -114
  800. package/lib/esm/utils/json-utils.d.ts +0 -24
  801. package/lib/esm/utils/json-utils.js +0 -41
  802. package/lib/esm/utils/logger.d.ts +0 -39
  803. package/lib/esm/utils/logger.js +0 -73
  804. package/lib/esm/utils/mcp-utils.d.ts +0 -5
  805. package/lib/esm/utils/mcp-utils.js +0 -47
  806. package/lib/esm/utils/model-utils.d.ts +0 -3
  807. package/lib/esm/utils/model-utils.js +0 -7
  808. package/lib/esm/utils/promise.d.ts +0 -6
  809. package/lib/esm/utils/promise.js +0 -9
  810. package/lib/esm/utils/prompts.d.ts +0 -2
  811. package/lib/esm/utils/prompts.js +0 -18
  812. package/lib/esm/utils/queue.d.ts +0 -57
  813. package/lib/esm/utils/queue.js +0 -315
  814. package/lib/esm/utils/role-utils.d.ts +0 -31
  815. package/lib/esm/utils/role-utils.js +0 -33
  816. package/lib/esm/utils/stream-polyfill.d.ts +0 -1
  817. package/lib/esm/utils/stream-polyfill.js +0 -37
  818. package/lib/esm/utils/stream-utils.d.ts +0 -26
  819. package/lib/esm/utils/stream-utils.js +0 -217
  820. package/lib/esm/utils/structured-stream-extractor.d.ts +0 -14
  821. package/lib/esm/utils/structured-stream-extractor.js +0 -64
  822. package/lib/esm/utils/token-estimator.d.ts +0 -9
  823. package/lib/esm/utils/token-estimator.js +0 -63
  824. package/lib/esm/utils/type-utils.d.ts +0 -31
  825. package/lib/esm/utils/type-utils.js +0 -181
  826. package/lib/esm/utils/typed-event-emitter.d.ts +0 -10
  827. package/lib/esm/utils/typed-event-emitter.js +0 -1
@@ -0,0 +1,340 @@
1
+ import { ChatModel } from "../agents/chat-model.mjs";
2
+ import { ImageModel } from "../agents/image-model.mjs";
3
+ import { MessagePayload, MessageQueue, MessageQueueListener, Unsubscribe } from "./message-queue.mjs";
4
+ import { UserAgent } from "../agents/user-agent.mjs";
5
+ import { AIGNECLIAgents, AIGNEMetadata } from "./type.mjs";
6
+ import { ContextLimits } from "./usage.mjs";
7
+ import { AIGNEContext, Context, InvokeOptions, UserContext } from "./context.mjs";
8
+ import { Agent, AgentResponse, AgentResponseStream, Message } from "../agents/agent.mjs";
9
+ import { LoadOptions } from "../loader/index.mjs";
10
+ import { AIGNEObserver } from "@aigne/observability-api";
11
+
12
+ //#region src/aigne/aigne.d.ts
13
+ /**
14
+ * Options for the AIGNE class.
15
+ */
16
+ interface AIGNEOptions {
17
+ /**
18
+ * Optional root directory for this AIGNE instance.
19
+ * This is used to resolve relative paths for agents and skills.
20
+ */
21
+ rootDir?: string;
22
+ /**
23
+ * The name of the AIGNE instance.
24
+ */
25
+ name?: string;
26
+ /**
27
+ * The description of the AIGNE instance.
28
+ */
29
+ description?: string;
30
+ /**
31
+ * Global model to use for all agents not specifying a model.
32
+ */
33
+ model?: ChatModel;
34
+ /**
35
+ * Optional image model to use for image processing tasks.
36
+ */
37
+ imageModel?: ImageModel;
38
+ /**
39
+ * Skills to use for the AIGNE instance.
40
+ */
41
+ skills?: Agent[];
42
+ /**
43
+ * Agents to use for the AIGNE instance.
44
+ */
45
+ agents?: Agent[];
46
+ mcpServer?: {
47
+ agents?: Agent[];
48
+ };
49
+ cli?: AIGNECLIAgents;
50
+ /**
51
+ * Limits for the AIGNE instance, such as timeout, max tokens, max invocations, etc.
52
+ */
53
+ limits?: ContextLimits;
54
+ /**
55
+ * Observer for the AIGNE instance.
56
+ */
57
+ observer?: AIGNEObserver;
58
+ metadata?: AIGNEMetadata;
59
+ }
60
+ /**
61
+ * AIGNE is a class that orchestrates multiple agents to build complex AI applications.
62
+ * It serves as the central coordination point for agent interactions, message passing, and execution flow.
63
+ *
64
+ * @example
65
+ * Here's a simple example of how to use AIGNE:
66
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-simple}
67
+ *
68
+ * @example
69
+ * Here's an example of how to use AIGNE with streaming response:
70
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-streaming}
71
+ */
72
+ declare class AIGNE<U extends UserContext = UserContext> {
73
+ /**
74
+ * Loads an AIGNE instance from a directory containing an aigne.yaml file and agent definitions.
75
+ * This static method provides a convenient way to initialize an AIGNE system from configuration files.
76
+ *
77
+ * @param path - Path to the directory containing the aigne.yaml file.
78
+ * @param options - Options to override the loaded configuration.
79
+ * @returns A fully initialized AIGNE instance with configured agents and skills.
80
+ */
81
+ static load(path: string, options?: Omit<AIGNEOptions, keyof LoadOptions> & LoadOptions): Promise<AIGNE>;
82
+ /**
83
+ * Creates a new AIGNE instance with the specified options.
84
+ *
85
+ * @param options - Configuration options for the AIGNE instance including name, description, model, and agents.
86
+ */
87
+ constructor(options?: AIGNEOptions);
88
+ /**
89
+ * Optional root directory for this AIGNE instance.
90
+ */
91
+ rootDir?: string;
92
+ /**
93
+ * Optional name identifier for this AIGNE instance.
94
+ */
95
+ name?: string;
96
+ /**
97
+ * Optional description of this AIGNE instance's purpose or functionality.
98
+ */
99
+ description?: string;
100
+ /**
101
+ * Global model to use for all agents that don't specify their own model.
102
+ */
103
+ model?: ChatModel;
104
+ /**
105
+ * Optional image model to use for image processing tasks.
106
+ */
107
+ imageModel?: ImageModel;
108
+ /**
109
+ * Usage limits applied to this AIGNE instance's execution.
110
+ */
111
+ limits?: ContextLimits;
112
+ /**
113
+ * Message queue for handling inter-agent communication.
114
+ *
115
+ * @hidden
116
+ */
117
+ readonly messageQueue: MessageQueue;
118
+ /**
119
+ * Collection of all context IDs created by this AIGNE instance.
120
+ */
121
+ readonly contextIds: Set<string>;
122
+ /**
123
+ * Collection of skill agents available to this AIGNE instance.
124
+ * Provides indexed access by skill name.
125
+ */
126
+ readonly skills: Agent<any, any>[] & {
127
+ [key: string]: Agent<any, any>;
128
+ };
129
+ /**
130
+ * Collection of primary agents managed by this AIGNE instance.
131
+ * Provides indexed access by agent name.
132
+ */
133
+ readonly agents: Agent<any, any>[] & {
134
+ [key: string]: Agent<any, any>;
135
+ };
136
+ readonly mcpServer: {
137
+ agents: Agent<any, any>[] & {
138
+ [key: string]: Agent<any, any>;
139
+ };
140
+ };
141
+ readonly cli: AIGNECLIAgents;
142
+ /**
143
+ * Observer for the AIGNE instance.
144
+ */
145
+ readonly observer?: AIGNEObserver;
146
+ /**
147
+ * Metadata for the AIGNE instance.
148
+ */
149
+ readonly metadata: AIGNEMetadata;
150
+ /**
151
+ * Adds one or more agents to this AIGNE instance.
152
+ * Each agent is attached to this AIGNE instance, allowing it to access the AIGNE's resources.
153
+ *
154
+ * @param agents - One or more Agent instances to add to this AIGNE.
155
+ */
156
+ addAgent(...agents: Agent[]): void;
157
+ /**
158
+ * Creates a new execution context for this AIGNE instance.
159
+ * Contexts isolate state for different flows or conversations.
160
+ *
161
+ * @returns A new AIGNEContext instance bound to this AIGNE.
162
+ */
163
+ newContext(options?: Partial<Pick<Context, "userContext" | "memories">>): AIGNEContext;
164
+ /**
165
+ * Creates a user agent for consistent interactions with a specified agent.
166
+ * This method allows you to create a wrapper around an agent for repeated invocations.
167
+ *
168
+ * @param agent - Target agent to be wrapped for consistent invocation
169
+ * @returns A user agent instance that provides a convenient interface for interacting with the target agent
170
+ *
171
+ * @example
172
+ * Here's an example of how to create a user agent and invoke it consistently:
173
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-user-agent}
174
+ */
175
+ invoke<I extends Message, O extends Message>(agent: Agent<I, O>): UserAgent<I, O>;
176
+ /**
177
+ * Invokes an agent with a message and returns both the output and the active agent.
178
+ * This overload is useful when you need to track which agent was ultimately responsible for generating the response.
179
+ *
180
+ * @param agent - Target agent to invoke
181
+ * @param message - Input message to send to the agent
182
+ * @param options.returnActiveAgent - Must be true to return the final active agent
183
+ * @param options.streaming - Must be false to return a response stream
184
+ * @returns A promise resolving to a tuple containing the agent's response and the final active agent
185
+ */
186
+ invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I & Message, options: InvokeOptions<U> & {
187
+ returnActiveAgent: true;
188
+ streaming?: false;
189
+ }): Promise<[O, Agent]>;
190
+ /**
191
+ * Invokes an agent with a message and returns both a stream of the response and the active agent.
192
+ * This overload is useful when you need streaming responses while also tracking which agent provided them.
193
+ *
194
+ * @param agent - Target agent to invoke
195
+ * @param message - Input message to send to the agent
196
+ * @param options.returnActiveAgent - Must be true to return the final active agent
197
+ * @param options.streaming - Must be true to return a response stream
198
+ * @returns A promise resolving to a tuple containing the agent's response stream and a promise for the final agent
199
+ */
200
+ invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I & Message, options: InvokeOptions<U> & {
201
+ returnActiveAgent: true;
202
+ streaming: true;
203
+ }): Promise<[AgentResponseStream<O>, Promise<Agent>]>;
204
+ /**
205
+ * Invokes an agent with a message and returns just the output.
206
+ * This is the standard way to invoke an agent when you only need the response.
207
+ *
208
+ * @param agent - Target agent to invoke
209
+ * @param message - Input message to send to the agent
210
+ * @param options - Optional configuration parameters for the invocation
211
+ * @returns A promise resolving to the agent's complete response
212
+ *
213
+ * @example
214
+ * Here's a simple example of how to invoke an agent:
215
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-simple}
216
+ */
217
+ invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I & Message, options?: InvokeOptions<U> & {
218
+ returnActiveAgent?: false;
219
+ streaming?: false;
220
+ }): Promise<O>;
221
+ /**
222
+ * Invokes an agent with a message and returns a stream of the response.
223
+ * This allows processing the response incrementally as it's being generated.
224
+ *
225
+ * @param agent - Target agent to invoke
226
+ * @param message - Input message to send to the agent
227
+ * @param options - Configuration with streaming enabled to receive incremental response chunks
228
+ * @returns A promise resolving to a stream of the agent's response that can be consumed incrementally
229
+ *
230
+ * @example
231
+ * Here's an example of how to invoke an agent with streaming response:
232
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-streaming}
233
+ */
234
+ invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I & Message, options: InvokeOptions<U> & {
235
+ returnActiveAgent?: false;
236
+ streaming: true;
237
+ }): Promise<AgentResponseStream<O>>;
238
+ /**
239
+ * General implementation signature that handles all overload cases.
240
+ * This unified signature supports all the different invocation patterns defined by the overloads.
241
+ *
242
+ * @param agent - Target agent to invoke or wrap
243
+ * @param message - Optional input message to send to the agent
244
+ * @param options - Optional configuration parameters for the invocation
245
+ * @returns Either a UserAgent (when no message provided) or a promise resolving to the agent's response
246
+ * with optional active agent information based on the provided options
247
+ */
248
+ invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message?: I & Message, options?: InvokeOptions<U>): UserAgent<I, O> | Promise<AgentResponse<O> | [AgentResponse<O>, Agent]>;
249
+ /**
250
+ * Publishes a message to the message queue for inter-agent communication.
251
+ * This method broadcasts a message to all subscribers of the specified topic(s).
252
+ * It creates a new context internally and delegates to the context's publish method.
253
+ *
254
+ * @param topic - The topic or array of topics to publish the message to
255
+ * @param payload - The message payload to be delivered to subscribers
256
+ * @param options - Optional configuration parameters for the publish operation
257
+ *
258
+ * @example
259
+ * Here's an example of how to publish a message:
260
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-publish-message}
261
+ */
262
+ publish(topic: string | string[], payload: Omit<MessagePayload, "context"> | Message, options?: InvokeOptions<U>): void;
263
+ /**
264
+ * Subscribes to receive the next message on a specific topic.
265
+ * This overload returns a Promise that resolves with the next message published to the topic.
266
+ * It's useful for one-time message handling or when using async/await patterns.
267
+ *
268
+ * @param topic - The topic to subscribe to
269
+ * @returns A Promise that resolves with the next message payload published to the specified topic
270
+ *
271
+ * @example
272
+ * Here's an example of how to subscribe to a topic and receive the next message:
273
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-publish-message}
274
+ */
275
+ subscribe(topic: string | string[], listener?: undefined): Promise<MessagePayload>;
276
+ /**
277
+ * Subscribes to messages on a specific topic with a listener callback.
278
+ * This overload registers a listener function that will be called for each message published to the topic.
279
+ * It's useful for continuous message handling or event-driven architectures.
280
+ *
281
+ * @param topic - The topic to subscribe to
282
+ * @param listener - Callback function that will be invoked when messages arrive on the specified topic
283
+ * @returns An Unsubscribe function that can be called to cancel the subscription
284
+ *
285
+ * @example
286
+ * Here's an example of how to subscribe to a topic with a listener:
287
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-subscribe-topic}
288
+ */
289
+ subscribe(topic: string | string[], listener: MessageQueueListener): Unsubscribe;
290
+ /**
291
+ * Generic subscribe signature that handles both Promise and listener patterns.
292
+ * This is the implementation signature that supports both overloaded behaviors.
293
+ *
294
+ * @param topic - The topic to subscribe to
295
+ * @param listener - Optional callback function
296
+ * @returns Either a Promise for the next message or an Unsubscribe function
297
+ */
298
+ subscribe(topic: string | string[], listener?: MessageQueueListener): Unsubscribe | Promise<MessagePayload>;
299
+ /**
300
+ * Unsubscribes a listener from a specific topic in the message queue.
301
+ * This method stops a previously registered listener from receiving further messages.
302
+ * It should be called when message processing is complete or when the component is no longer interested
303
+ * in messages published to the specified topic.
304
+ *
305
+ * @param topic - The topic to unsubscribe from
306
+ * @param listener - The listener function that was previously subscribed to the topic
307
+ *
308
+ * @example
309
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-subscribe-topic}
310
+ */
311
+ unsubscribe(topic: string | string[], listener: MessageQueueListener): void;
312
+ /**
313
+ * Gracefully shuts down the AIGNE instance and all its agents and skills.
314
+ * This ensures proper cleanup of resources before termination.
315
+ *
316
+ * @returns A promise that resolves when shutdown is complete.
317
+ *
318
+ * @example
319
+ * Here's an example of shutdown an AIGNE instance:
320
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-shutdown}
321
+ */
322
+ shutdown(): Promise<void>;
323
+ /**
324
+ * Asynchronous dispose method for the AIGNE instance.
325
+ *
326
+ * @example
327
+ * Here's an example of using async dispose:
328
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-shutdown-using}
329
+ */
330
+ [Symbol.asyncDispose](): Promise<void>;
331
+ /**
332
+ * Initializes handlers for process exit events to ensure clean shutdown.
333
+ * This registers handlers for SIGINT/SIGTERM to properly terminate all agents.
334
+ * Note: 'exit' event cannot run async code, so we handle cleanup in signal handlers.
335
+ */
336
+ private initProcessExitHandler;
337
+ }
338
+ //#endregion
339
+ export { AIGNE, AIGNEOptions };
340
+ //# sourceMappingURL=aigne.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aigne.d.mts","names":[],"sources":["../../src/aigne/aigne.ts"],"mappings":"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"}
@@ -0,0 +1,235 @@
1
+ import { checkArguments, createAccessorArray } from "../utils/type-utils.mjs";
2
+ import { MessageQueue } from "./message-queue.mjs";
3
+ import { load } from "../loader/index.mjs";
4
+ import { AIGNEContext } from "./context.mjs";
5
+ import { z as z$1 } from "zod";
6
+ import { AIGNEObserver } from "@aigne/observability-api";
7
+
8
+ //#region src/aigne/aigne.ts
9
+ /**
10
+ * AIGNE is a class that orchestrates multiple agents to build complex AI applications.
11
+ * It serves as the central coordination point for agent interactions, message passing, and execution flow.
12
+ *
13
+ * @example
14
+ * Here's a simple example of how to use AIGNE:
15
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-simple}
16
+ *
17
+ * @example
18
+ * Here's an example of how to use AIGNE with streaming response:
19
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-streaming}
20
+ */
21
+ var AIGNE = class AIGNE {
22
+ /**
23
+ * Loads an AIGNE instance from a directory containing an aigne.yaml file and agent definitions.
24
+ * This static method provides a convenient way to initialize an AIGNE system from configuration files.
25
+ *
26
+ * @param path - Path to the directory containing the aigne.yaml file.
27
+ * @param options - Options to override the loaded configuration.
28
+ * @returns A fully initialized AIGNE instance with configured agents and skills.
29
+ */
30
+ static async load(path, options = {}) {
31
+ const { agents = [], skills = [], model, imageModel, ...aigne } = await load(path, options);
32
+ return new AIGNE({
33
+ ...aigne,
34
+ ...options,
35
+ model,
36
+ imageModel,
37
+ agents: agents.concat(options?.agents ?? []),
38
+ skills: skills.concat(options?.skills ?? []),
39
+ metadata: options?.metadata
40
+ });
41
+ }
42
+ /**
43
+ * Creates a new AIGNE instance with the specified options.
44
+ *
45
+ * @param options - Configuration options for the AIGNE instance including name, description, model, and agents.
46
+ */
47
+ constructor(options) {
48
+ if (options) checkArguments("AIGNE", aigneOptionsSchema, options);
49
+ this.rootDir = options?.rootDir;
50
+ this.name = options?.name;
51
+ this.description = options?.description;
52
+ this.model = options?.model;
53
+ this.imageModel = options?.imageModel;
54
+ this.limits = options?.limits;
55
+ this.observer = process.env.AIGNE_OBSERVABILITY_DISABLED === "true" ? void 0 : options?.observer ?? new AIGNEObserver();
56
+ if (options?.skills?.length) this.skills.push(...options.skills);
57
+ if (options?.agents?.length) this.addAgent(...options.agents);
58
+ if (options?.mcpServer?.agents?.length) this.mcpServer.agents.push(...options.mcpServer.agents);
59
+ this.cli = options?.cli ?? {};
60
+ this.observer?.serve();
61
+ this.initProcessExitHandler();
62
+ this.metadata = options?.metadata ?? {};
63
+ }
64
+ /**
65
+ * Optional root directory for this AIGNE instance.
66
+ */
67
+ rootDir;
68
+ /**
69
+ * Optional name identifier for this AIGNE instance.
70
+ */
71
+ name;
72
+ /**
73
+ * Optional description of this AIGNE instance's purpose or functionality.
74
+ */
75
+ description;
76
+ /**
77
+ * Global model to use for all agents that don't specify their own model.
78
+ */
79
+ model;
80
+ /**
81
+ * Optional image model to use for image processing tasks.
82
+ */
83
+ imageModel;
84
+ /**
85
+ * Usage limits applied to this AIGNE instance's execution.
86
+ */
87
+ limits;
88
+ /**
89
+ * Message queue for handling inter-agent communication.
90
+ *
91
+ * @hidden
92
+ */
93
+ messageQueue = new MessageQueue();
94
+ /**
95
+ * Collection of all context IDs created by this AIGNE instance.
96
+ */
97
+ contextIds = /* @__PURE__ */ new Set();
98
+ /**
99
+ * Collection of skill agents available to this AIGNE instance.
100
+ * Provides indexed access by skill name.
101
+ */
102
+ skills = createAccessorArray([], (arr, name) => arr.find((i) => i.name === name));
103
+ /**
104
+ * Collection of primary agents managed by this AIGNE instance.
105
+ * Provides indexed access by agent name.
106
+ */
107
+ agents = createAccessorArray([], (arr, name) => arr.find((i) => i.name === name));
108
+ mcpServer = { agents: createAccessorArray([], (arr, name) => arr.find((i) => i.name === name)) };
109
+ cli = {};
110
+ /**
111
+ * Observer for the AIGNE instance.
112
+ */
113
+ observer;
114
+ /**
115
+ * Metadata for the AIGNE instance.
116
+ */
117
+ metadata = {};
118
+ /**
119
+ * Adds one or more agents to this AIGNE instance.
120
+ * Each agent is attached to this AIGNE instance, allowing it to access the AIGNE's resources.
121
+ *
122
+ * @param agents - One or more Agent instances to add to this AIGNE.
123
+ */
124
+ addAgent(...agents) {
125
+ checkArguments("AIGNE.addAgent", aigneAddAgentArgsSchema, agents);
126
+ for (const agent of agents) {
127
+ this.agents.push(agent);
128
+ agent.attach(this);
129
+ }
130
+ }
131
+ /**
132
+ * Creates a new execution context for this AIGNE instance.
133
+ * Contexts isolate state for different flows or conversations.
134
+ *
135
+ * @returns A new AIGNEContext instance bound to this AIGNE.
136
+ */
137
+ newContext(options) {
138
+ const context = new AIGNEContext(this);
139
+ if (options?.userContext) context.userContext = options.userContext;
140
+ if (options?.memories) context.memories = options.memories;
141
+ return context;
142
+ }
143
+ invoke(agent, message, options) {
144
+ this.observer?.serve();
145
+ return new AIGNEContext(this).invoke(agent, message, {
146
+ ...options,
147
+ newContext: false
148
+ });
149
+ }
150
+ /**
151
+ * Publishes a message to the message queue for inter-agent communication.
152
+ * This method broadcasts a message to all subscribers of the specified topic(s).
153
+ * It creates a new context internally and delegates to the context's publish method.
154
+ *
155
+ * @param topic - The topic or array of topics to publish the message to
156
+ * @param payload - The message payload to be delivered to subscribers
157
+ * @param options - Optional configuration parameters for the publish operation
158
+ *
159
+ * @example
160
+ * Here's an example of how to publish a message:
161
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-publish-message}
162
+ */
163
+ publish(topic, payload, options) {
164
+ this.observer?.serve();
165
+ return new AIGNEContext(this).publish(topic, payload, options);
166
+ }
167
+ subscribe(topic, listener) {
168
+ return this.messageQueue.subscribe(topic, listener);
169
+ }
170
+ /**
171
+ * Unsubscribes a listener from a specific topic in the message queue.
172
+ * This method stops a previously registered listener from receiving further messages.
173
+ * It should be called when message processing is complete or when the component is no longer interested
174
+ * in messages published to the specified topic.
175
+ *
176
+ * @param topic - The topic to unsubscribe from
177
+ * @param listener - The listener function that was previously subscribed to the topic
178
+ *
179
+ * @example
180
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-subscribe-topic}
181
+ */
182
+ unsubscribe(topic, listener) {
183
+ this.messageQueue.unsubscribe(topic, listener);
184
+ }
185
+ /**
186
+ * Gracefully shuts down the AIGNE instance and all its agents and skills.
187
+ * This ensures proper cleanup of resources before termination.
188
+ *
189
+ * @returns A promise that resolves when shutdown is complete.
190
+ *
191
+ * @example
192
+ * Here's an example of shutdown an AIGNE instance:
193
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-shutdown}
194
+ */
195
+ async shutdown() {
196
+ await this.observer?.close(Array.from(this.contextIds));
197
+ for (const tool of this.skills) await tool.shutdown();
198
+ for (const agent of this.agents) await agent.shutdown();
199
+ }
200
+ /**
201
+ * Asynchronous dispose method for the AIGNE instance.
202
+ *
203
+ * @example
204
+ * Here's an example of using async dispose:
205
+ * {@includeCode ../../test/aigne/aigne.test.ts#example-shutdown-using}
206
+ */
207
+ async [Symbol.asyncDispose]() {
208
+ await this.shutdown();
209
+ }
210
+ /**
211
+ * Initializes handlers for process exit events to ensure clean shutdown.
212
+ * This registers handlers for SIGINT/SIGTERM to properly terminate all agents.
213
+ * Note: 'exit' event cannot run async code, so we handle cleanup in signal handlers.
214
+ */
215
+ initProcessExitHandler() {
216
+ const originalExit = process.exit;
217
+ process.exit = (...args) => {
218
+ this.shutdown().finally(() => originalExit(...args));
219
+ };
220
+ const shutdownAndExit = () => this.shutdown().finally(() => originalExit(0));
221
+ process.on("SIGINT", shutdownAndExit);
222
+ }
223
+ };
224
+ const aigneOptionsSchema = z$1.object({
225
+ model: z$1.custom().optional(),
226
+ imageModel: z$1.custom().optional(),
227
+ skills: z$1.array(z$1.custom()).optional(),
228
+ agents: z$1.array(z$1.custom()).optional(),
229
+ observer: z$1.custom().optional()
230
+ });
231
+ const aigneAddAgentArgsSchema = z$1.array(z$1.custom());
232
+
233
+ //#endregion
234
+ export { AIGNE };
235
+ //# sourceMappingURL=aigne.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aigne.mjs","names":["z"],"sources":["../../src/aigne/aigne.ts"],"sourcesContent":["import { AIGNEObserver } from \"@aigne/observability-api\";\nimport { z } from \"zod\";\nimport type { Agent, AgentResponse, AgentResponseStream, Message } from \"../agents/agent.js\";\nimport type { ChatModel } from \"../agents/chat-model.js\";\nimport type { ImageModel } from \"../agents/image-model.js\";\nimport type { UserAgent } from \"../agents/user-agent.js\";\nimport { type LoadOptions, load } from \"../loader/index.js\";\nimport { checkArguments, createAccessorArray } from \"../utils/type-utils.js\";\nimport { AIGNEContext, type Context, type InvokeOptions, type UserContext } from \"./context.js\";\nimport {\n type MessagePayload,\n MessageQueue,\n type MessageQueueListener,\n type Unsubscribe,\n} from \"./message-queue.js\";\nimport type { AIGNECLIAgents, AIGNEMetadata } from \"./type.js\";\nimport type { ContextLimits } from \"./usage.js\";\n\n/**\n * Options for the AIGNE class.\n */\nexport interface AIGNEOptions {\n /**\n * Optional root directory for this AIGNE instance.\n * This is used to resolve relative paths for agents and skills.\n */\n rootDir?: string;\n\n /**\n * The name of the AIGNE instance.\n */\n name?: string;\n\n /**\n * The description of the AIGNE instance.\n */\n description?: string;\n\n /**\n * Global model to use for all agents not specifying a model.\n */\n model?: ChatModel;\n\n /**\n * Optional image model to use for image processing tasks.\n */\n imageModel?: ImageModel;\n\n /**\n * Skills to use for the AIGNE instance.\n */\n skills?: Agent[];\n\n /**\n * Agents to use for the AIGNE instance.\n */\n agents?: Agent[];\n\n mcpServer?: {\n agents?: Agent[];\n };\n\n cli?: AIGNECLIAgents;\n\n /**\n * Limits for the AIGNE instance, such as timeout, max tokens, max invocations, etc.\n */\n limits?: ContextLimits;\n\n /**\n * Observer for the AIGNE instance.\n */\n observer?: AIGNEObserver;\n\n metadata?: AIGNEMetadata;\n}\n\n/**\n * AIGNE is a class that orchestrates multiple agents to build complex AI applications.\n * It serves as the central coordination point for agent interactions, message passing, and execution flow.\n *\n * @example\n * Here's a simple example of how to use AIGNE:\n * {@includeCode ../../test/aigne/aigne.test.ts#example-simple}\n *\n * @example\n * Here's an example of how to use AIGNE with streaming response:\n * {@includeCode ../../test/aigne/aigne.test.ts#example-streaming}\n */\nexport class AIGNE<U extends UserContext = UserContext> {\n /**\n * Loads an AIGNE instance from a directory containing an aigne.yaml file and agent definitions.\n * This static method provides a convenient way to initialize an AIGNE system from configuration files.\n *\n * @param path - Path to the directory containing the aigne.yaml file.\n * @param options - Options to override the loaded configuration.\n * @returns A fully initialized AIGNE instance with configured agents and skills.\n */\n static async load(\n path: string,\n options: Omit<AIGNEOptions, keyof LoadOptions> & LoadOptions = {},\n ): Promise<AIGNE> {\n const { agents = [], skills = [], model, imageModel, ...aigne } = await load(path, options);\n return new AIGNE({\n ...aigne,\n ...options,\n model,\n imageModel,\n agents: agents.concat(options?.agents ?? []),\n skills: skills.concat(options?.skills ?? []),\n metadata: options?.metadata,\n });\n }\n\n /**\n * Creates a new AIGNE instance with the specified options.\n *\n * @param options - Configuration options for the AIGNE instance including name, description, model, and agents.\n */\n constructor(options?: AIGNEOptions) {\n if (options) checkArguments(\"AIGNE\", aigneOptionsSchema, options);\n\n this.rootDir = options?.rootDir;\n this.name = options?.name;\n this.description = options?.description;\n this.model = options?.model;\n this.imageModel = options?.imageModel;\n this.limits = options?.limits;\n this.observer =\n process.env.AIGNE_OBSERVABILITY_DISABLED === \"true\"\n ? undefined\n : (options?.observer ?? new AIGNEObserver());\n if (options?.skills?.length) this.skills.push(...options.skills);\n if (options?.agents?.length) this.addAgent(...options.agents);\n if (options?.mcpServer?.agents?.length) this.mcpServer.agents.push(...options.mcpServer.agents);\n this.cli = options?.cli ?? {};\n\n this.observer?.serve();\n this.initProcessExitHandler();\n this.metadata = options?.metadata ?? {};\n }\n\n /**\n * Optional root directory for this AIGNE instance.\n */\n rootDir?: string;\n\n /**\n * Optional name identifier for this AIGNE instance.\n */\n name?: string;\n\n /**\n * Optional description of this AIGNE instance's purpose or functionality.\n */\n description?: string;\n\n /**\n * Global model to use for all agents that don't specify their own model.\n */\n model?: ChatModel;\n\n /**\n * Optional image model to use for image processing tasks.\n */\n imageModel?: ImageModel;\n\n /**\n * Usage limits applied to this AIGNE instance's execution.\n */\n limits?: ContextLimits;\n\n /**\n * Message queue for handling inter-agent communication.\n *\n * @hidden\n */\n readonly messageQueue = new MessageQueue();\n\n /**\n * Collection of all context IDs created by this AIGNE instance.\n */\n readonly contextIds = new Set<string>();\n\n /**\n * Collection of skill agents available to this AIGNE instance.\n * Provides indexed access by skill name.\n */\n readonly skills = createAccessorArray<Agent>([], (arr, name) => arr.find((i) => i.name === name));\n\n /**\n * Collection of primary agents managed by this AIGNE instance.\n * Provides indexed access by agent name.\n */\n readonly agents = createAccessorArray<Agent>([], (arr, name) => arr.find((i) => i.name === name));\n\n readonly mcpServer = {\n agents: createAccessorArray<Agent>([], (arr, name) => arr.find((i) => i.name === name)),\n };\n\n readonly cli: AIGNECLIAgents = {};\n\n /**\n * Observer for the AIGNE instance.\n */\n readonly observer?: AIGNEObserver;\n\n /**\n * Metadata for the AIGNE instance.\n */\n readonly metadata: AIGNEMetadata = {};\n\n /**\n * Adds one or more agents to this AIGNE instance.\n * Each agent is attached to this AIGNE instance, allowing it to access the AIGNE's resources.\n *\n * @param agents - One or more Agent instances to add to this AIGNE.\n */\n addAgent(...agents: Agent[]) {\n checkArguments(\"AIGNE.addAgent\", aigneAddAgentArgsSchema, agents);\n\n for (const agent of agents) {\n this.agents.push(agent);\n\n agent.attach(this);\n }\n }\n\n /**\n * Creates a new execution context for this AIGNE instance.\n * Contexts isolate state for different flows or conversations.\n *\n * @returns A new AIGNEContext instance bound to this AIGNE.\n */\n newContext(options?: Partial<Pick<Context, \"userContext\" | \"memories\">>) {\n const context = new AIGNEContext(this);\n\n if (options?.userContext) context.userContext = options.userContext;\n if (options?.memories) context.memories = options.memories;\n\n return context;\n }\n\n /**\n * Creates a user agent for consistent interactions with a specified agent.\n * This method allows you to create a wrapper around an agent for repeated invocations.\n *\n * @param agent - Target agent to be wrapped for consistent invocation\n * @returns A user agent instance that provides a convenient interface for interacting with the target agent\n *\n * @example\n * Here's an example of how to create a user agent and invoke it consistently:\n * {@includeCode ../../test/aigne/aigne.test.ts#example-user-agent}\n */\n invoke<I extends Message, O extends Message>(agent: Agent<I, O>): UserAgent<I, O>;\n\n /**\n * Invokes an agent with a message and returns both the output and the active agent.\n * This overload is useful when you need to track which agent was ultimately responsible for generating the response.\n *\n * @param agent - Target agent to invoke\n * @param message - Input message to send to the agent\n * @param options.returnActiveAgent - Must be true to return the final active agent\n * @param options.streaming - Must be false to return a response stream\n * @returns A promise resolving to a tuple containing the agent's response and the final active agent\n */\n invoke<I extends Message, O extends Message>(\n agent: Agent<I, O>,\n message: I & Message,\n options: InvokeOptions<U> & { returnActiveAgent: true; streaming?: false },\n ): Promise<[O, Agent]>;\n\n /**\n * Invokes an agent with a message and returns both a stream of the response and the active agent.\n * This overload is useful when you need streaming responses while also tracking which agent provided them.\n *\n * @param agent - Target agent to invoke\n * @param message - Input message to send to the agent\n * @param options.returnActiveAgent - Must be true to return the final active agent\n * @param options.streaming - Must be true to return a response stream\n * @returns A promise resolving to a tuple containing the agent's response stream and a promise for the final agent\n */\n invoke<I extends Message, O extends Message>(\n agent: Agent<I, O>,\n message: I & Message,\n options: InvokeOptions<U> & { returnActiveAgent: true; streaming: true },\n ): Promise<[AgentResponseStream<O>, Promise<Agent>]>;\n\n /**\n * Invokes an agent with a message and returns just the output.\n * This is the standard way to invoke an agent when you only need the response.\n *\n * @param agent - Target agent to invoke\n * @param message - Input message to send to the agent\n * @param options - Optional configuration parameters for the invocation\n * @returns A promise resolving to the agent's complete response\n *\n * @example\n * Here's a simple example of how to invoke an agent:\n * {@includeCode ../../test/aigne/aigne.test.ts#example-simple}\n */\n invoke<I extends Message, O extends Message>(\n agent: Agent<I, O>,\n message: I & Message,\n options?: InvokeOptions<U> & { returnActiveAgent?: false; streaming?: false },\n ): Promise<O>;\n\n /**\n * Invokes an agent with a message and returns a stream of the response.\n * This allows processing the response incrementally as it's being generated.\n *\n * @param agent - Target agent to invoke\n * @param message - Input message to send to the agent\n * @param options - Configuration with streaming enabled to receive incremental response chunks\n * @returns A promise resolving to a stream of the agent's response that can be consumed incrementally\n *\n * @example\n * Here's an example of how to invoke an agent with streaming response:\n * {@includeCode ../../test/aigne/aigne.test.ts#example-streaming}\n */\n invoke<I extends Message, O extends Message>(\n agent: Agent<I, O>,\n message: I & Message,\n options: InvokeOptions<U> & { returnActiveAgent?: false; streaming: true },\n ): Promise<AgentResponseStream<O>>;\n\n /**\n * General implementation signature that handles all overload cases.\n * This unified signature supports all the different invocation patterns defined by the overloads.\n *\n * @param agent - Target agent to invoke or wrap\n * @param message - Optional input message to send to the agent\n * @param options - Optional configuration parameters for the invocation\n * @returns Either a UserAgent (when no message provided) or a promise resolving to the agent's response\n * with optional active agent information based on the provided options\n */\n invoke<I extends Message, O extends Message>(\n agent: Agent<I, O>,\n message?: I & Message,\n options?: InvokeOptions<U>,\n ): UserAgent<I, O> | Promise<AgentResponse<O> | [AgentResponse<O>, Agent]>;\n\n invoke<I extends Message, O extends Message>(\n agent: Agent<I, O>,\n message?: I & Message,\n options?: InvokeOptions<U>,\n ): UserAgent<I, O> | Promise<AgentResponse<O> | [AgentResponse<O>, Agent]> {\n this.observer?.serve();\n const context = new AIGNEContext(this);\n return context.invoke(agent, message, { ...options, newContext: false });\n }\n\n /**\n * Publishes a message to the message queue for inter-agent communication.\n * This method broadcasts a message to all subscribers of the specified topic(s).\n * It creates a new context internally and delegates to the context's publish method.\n *\n * @param topic - The topic or array of topics to publish the message to\n * @param payload - The message payload to be delivered to subscribers\n * @param options - Optional configuration parameters for the publish operation\n *\n * @example\n * Here's an example of how to publish a message:\n * {@includeCode ../../test/aigne/aigne.test.ts#example-publish-message}\n */\n publish(\n topic: string | string[],\n payload: Omit<MessagePayload, \"context\"> | Message,\n options?: InvokeOptions<U>,\n ) {\n this.observer?.serve();\n return new AIGNEContext(this).publish(topic, payload, options);\n }\n\n /**\n * Subscribes to receive the next message on a specific topic.\n * This overload returns a Promise that resolves with the next message published to the topic.\n * It's useful for one-time message handling or when using async/await patterns.\n *\n * @param topic - The topic to subscribe to\n * @returns A Promise that resolves with the next message payload published to the specified topic\n *\n * @example\n * Here's an example of how to subscribe to a topic and receive the next message:\n * {@includeCode ../../test/aigne/aigne.test.ts#example-publish-message}\n */\n subscribe(topic: string | string[], listener?: undefined): Promise<MessagePayload>;\n\n /**\n * Subscribes to messages on a specific topic with a listener callback.\n * This overload registers a listener function that will be called for each message published to the topic.\n * It's useful for continuous message handling or event-driven architectures.\n *\n * @param topic - The topic to subscribe to\n * @param listener - Callback function that will be invoked when messages arrive on the specified topic\n * @returns An Unsubscribe function that can be called to cancel the subscription\n *\n * @example\n * Here's an example of how to subscribe to a topic with a listener:\n * {@includeCode ../../test/aigne/aigne.test.ts#example-subscribe-topic}\n */\n subscribe(topic: string | string[], listener: MessageQueueListener): Unsubscribe;\n\n /**\n * Generic subscribe signature that handles both Promise and listener patterns.\n * This is the implementation signature that supports both overloaded behaviors.\n *\n * @param topic - The topic to subscribe to\n * @param listener - Optional callback function\n * @returns Either a Promise for the next message or an Unsubscribe function\n */\n subscribe(\n topic: string | string[],\n listener?: MessageQueueListener,\n ): Unsubscribe | Promise<MessagePayload>;\n subscribe(\n topic: string | string[],\n listener?: MessageQueueListener,\n ): Unsubscribe | Promise<MessagePayload> {\n return this.messageQueue.subscribe(topic, listener);\n }\n\n /**\n * Unsubscribes a listener from a specific topic in the message queue.\n * This method stops a previously registered listener from receiving further messages.\n * It should be called when message processing is complete or when the component is no longer interested\n * in messages published to the specified topic.\n *\n * @param topic - The topic to unsubscribe from\n * @param listener - The listener function that was previously subscribed to the topic\n *\n * @example\n * {@includeCode ../../test/aigne/aigne.test.ts#example-subscribe-topic}\n */\n unsubscribe(topic: string | string[], listener: MessageQueueListener) {\n this.messageQueue.unsubscribe(topic, listener);\n }\n\n /**\n * Gracefully shuts down the AIGNE instance and all its agents and skills.\n * This ensures proper cleanup of resources before termination.\n *\n * @returns A promise that resolves when shutdown is complete.\n *\n * @example\n * Here's an example of shutdown an AIGNE instance:\n * {@includeCode ../../test/aigne/aigne.test.ts#example-shutdown}\n */\n async shutdown() {\n // Close observer first to flush any pending traces\n await this.observer?.close(Array.from(this.contextIds));\n\n for (const tool of this.skills) {\n await tool.shutdown();\n }\n for (const agent of this.agents) {\n await agent.shutdown();\n }\n }\n\n /**\n * Asynchronous dispose method for the AIGNE instance.\n *\n * @example\n * Here's an example of using async dispose:\n * {@includeCode ../../test/aigne/aigne.test.ts#example-shutdown-using}\n */\n async [Symbol.asyncDispose]() {\n await this.shutdown();\n }\n\n /**\n * Initializes handlers for process exit events to ensure clean shutdown.\n * This registers handlers for SIGINT/SIGTERM to properly terminate all agents.\n * Note: 'exit' event cannot run async code, so we handle cleanup in signal handlers.\n */\n private initProcessExitHandler() {\n const originalExit = process.exit;\n\n // @ts-ignore\n process.exit = (...args) => {\n this.shutdown().finally(() => originalExit(...args));\n };\n\n const shutdownAndExit = () => this.shutdown().finally(() => originalExit(0));\n process.on(\"SIGINT\", shutdownAndExit);\n }\n}\n\nconst aigneOptionsSchema = z.object({\n model: z.custom<ChatModel>().optional(),\n imageModel: z.custom<ImageModel>().optional(),\n skills: z.array(z.custom<Agent>()).optional(),\n agents: z.array(z.custom<Agent>()).optional(),\n observer: z.custom<AIGNEObserver>().optional(),\n});\n\nconst aigneAddAgentArgsSchema = z.array(z.custom<Agent>());\n"],"mappings":"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"}