beeai-framework 0.1.29 → 0.1.30

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 (558) hide show
  1. package/dist/adapters/a2a/agents/agent.cjs.map +1 -1
  2. package/dist/adapters/a2a/agents/agent.d.cts +2 -2
  3. package/dist/adapters/a2a/agents/agent.d.ts +2 -2
  4. package/dist/adapters/a2a/agents/agent.js.map +1 -1
  5. package/dist/adapters/a2a/agents/events.d.cts +1 -1
  6. package/dist/adapters/a2a/agents/events.d.ts +1 -1
  7. package/dist/adapters/a2a/agents/types.d.cts +2 -2
  8. package/dist/adapters/a2a/agents/types.d.ts +2 -2
  9. package/dist/adapters/a2a/agents/utils.cjs +52 -11
  10. package/dist/adapters/a2a/agents/utils.cjs.map +1 -1
  11. package/dist/adapters/a2a/agents/utils.js +52 -11
  12. package/dist/adapters/a2a/agents/utils.js.map +1 -1
  13. package/dist/adapters/a2a/serve/agent_executor.cjs.map +1 -1
  14. package/dist/adapters/a2a/serve/agent_executor.d.cts +3 -3
  15. package/dist/adapters/a2a/serve/agent_executor.d.ts +3 -3
  16. package/dist/adapters/a2a/serve/agent_executor.js.map +1 -1
  17. package/dist/adapters/a2a/serve/server.cjs.map +1 -1
  18. package/dist/adapters/a2a/serve/server.d.cts +2 -2
  19. package/dist/adapters/a2a/serve/server.d.ts +2 -2
  20. package/dist/adapters/a2a/serve/server.js.map +1 -1
  21. package/dist/adapters/acp/agents/agent.cjs.map +1 -1
  22. package/dist/adapters/acp/agents/agent.d.cts +2 -2
  23. package/dist/adapters/acp/agents/agent.d.ts +2 -2
  24. package/dist/adapters/acp/agents/agent.js.map +1 -1
  25. package/dist/adapters/acp/agents/events.d.cts +1 -1
  26. package/dist/adapters/acp/agents/events.d.ts +1 -1
  27. package/dist/adapters/agentstack/agents/agent.cjs.map +1 -1
  28. package/dist/adapters/agentstack/agents/agent.d.cts +2 -2
  29. package/dist/adapters/agentstack/agents/agent.d.ts +2 -2
  30. package/dist/adapters/agentstack/agents/agent.js.map +1 -1
  31. package/dist/adapters/agentstack/agents/events.d.cts +1 -1
  32. package/dist/adapters/agentstack/agents/events.d.ts +1 -1
  33. package/dist/adapters/amazon-bedrock/backend/chat.cjs.map +1 -1
  34. package/dist/adapters/amazon-bedrock/backend/chat.d.cts +2 -2
  35. package/dist/adapters/amazon-bedrock/backend/chat.d.ts +2 -2
  36. package/dist/adapters/amazon-bedrock/backend/chat.js.map +1 -1
  37. package/dist/adapters/amazon-bedrock/backend/client.cjs.map +1 -1
  38. package/dist/adapters/amazon-bedrock/backend/client.js.map +1 -1
  39. package/dist/adapters/amazon-bedrock/backend/embedding.cjs.map +1 -1
  40. package/dist/adapters/amazon-bedrock/backend/embedding.d.cts +2 -2
  41. package/dist/adapters/amazon-bedrock/backend/embedding.d.ts +2 -2
  42. package/dist/adapters/amazon-bedrock/backend/embedding.js.map +1 -1
  43. package/dist/adapters/anthropic/backend/chat.cjs.map +1 -1
  44. package/dist/adapters/anthropic/backend/chat.d.cts +2 -2
  45. package/dist/adapters/anthropic/backend/chat.d.ts +2 -2
  46. package/dist/adapters/anthropic/backend/chat.js.map +1 -1
  47. package/dist/adapters/anthropic/backend/client.cjs.map +1 -1
  48. package/dist/adapters/anthropic/backend/client.js.map +1 -1
  49. package/dist/adapters/anthropic/backend/embedding.cjs.map +1 -1
  50. package/dist/adapters/anthropic/backend/embedding.d.cts +2 -2
  51. package/dist/adapters/anthropic/backend/embedding.d.ts +2 -2
  52. package/dist/adapters/anthropic/backend/embedding.js.map +1 -1
  53. package/dist/adapters/azure-openai/backend/chat.cjs.map +1 -1
  54. package/dist/adapters/azure-openai/backend/chat.d.cts +3 -3
  55. package/dist/adapters/azure-openai/backend/chat.d.ts +3 -3
  56. package/dist/adapters/azure-openai/backend/chat.js.map +1 -1
  57. package/dist/adapters/azure-openai/backend/client.cjs.map +1 -1
  58. package/dist/adapters/azure-openai/backend/client.js.map +1 -1
  59. package/dist/adapters/azure-openai/backend/embedding.cjs.map +1 -1
  60. package/dist/adapters/azure-openai/backend/embedding.d.cts +2 -2
  61. package/dist/adapters/azure-openai/backend/embedding.d.ts +2 -2
  62. package/dist/adapters/azure-openai/backend/embedding.js.map +1 -1
  63. package/dist/adapters/dummy/backend/chat.cjs.map +1 -1
  64. package/dist/adapters/dummy/backend/chat.d.cts +2 -2
  65. package/dist/adapters/dummy/backend/chat.d.ts +2 -2
  66. package/dist/adapters/dummy/backend/chat.js.map +1 -1
  67. package/dist/adapters/dummy/backend/embedding.cjs.map +1 -1
  68. package/dist/adapters/dummy/backend/embedding.d.cts +2 -2
  69. package/dist/adapters/dummy/backend/embedding.d.ts +2 -2
  70. package/dist/adapters/dummy/backend/embedding.js.map +1 -1
  71. package/dist/adapters/google-vertex/backend/chat.cjs.map +1 -1
  72. package/dist/adapters/google-vertex/backend/chat.d.cts +3 -3
  73. package/dist/adapters/google-vertex/backend/chat.d.ts +3 -3
  74. package/dist/adapters/google-vertex/backend/chat.js.map +1 -1
  75. package/dist/adapters/google-vertex/backend/client.cjs.map +1 -1
  76. package/dist/adapters/google-vertex/backend/client.js.map +1 -1
  77. package/dist/adapters/google-vertex/backend/embedding.cjs.map +1 -1
  78. package/dist/adapters/google-vertex/backend/embedding.d.cts +2 -2
  79. package/dist/adapters/google-vertex/backend/embedding.d.ts +2 -2
  80. package/dist/adapters/google-vertex/backend/embedding.js.map +1 -1
  81. package/dist/adapters/groq/backend/chat.cjs.map +1 -1
  82. package/dist/adapters/groq/backend/chat.d.cts +3 -3
  83. package/dist/adapters/groq/backend/chat.d.ts +3 -3
  84. package/dist/adapters/groq/backend/chat.js.map +1 -1
  85. package/dist/adapters/groq/backend/client.cjs.map +1 -1
  86. package/dist/adapters/groq/backend/client.js.map +1 -1
  87. package/dist/adapters/groq/backend/embedding.cjs.map +1 -1
  88. package/dist/adapters/groq/backend/embedding.d.cts +2 -2
  89. package/dist/adapters/groq/backend/embedding.d.ts +2 -2
  90. package/dist/adapters/groq/backend/embedding.js.map +1 -1
  91. package/dist/adapters/langchain/backend/chat.cjs +6 -28
  92. package/dist/adapters/langchain/backend/chat.cjs.map +1 -1
  93. package/dist/adapters/langchain/backend/chat.d.cts +6 -5
  94. package/dist/adapters/langchain/backend/chat.d.ts +6 -5
  95. package/dist/adapters/langchain/backend/chat.js +6 -28
  96. package/dist/adapters/langchain/backend/chat.js.map +1 -1
  97. package/dist/adapters/langchain/backend/embedding.cjs +3 -2
  98. package/dist/adapters/langchain/backend/embedding.cjs.map +1 -1
  99. package/dist/adapters/langchain/backend/embedding.d.cts +3 -3
  100. package/dist/adapters/langchain/backend/embedding.d.ts +3 -3
  101. package/dist/adapters/langchain/backend/embedding.js +3 -2
  102. package/dist/adapters/langchain/backend/embedding.js.map +1 -1
  103. package/dist/adapters/langchain/backend/utils.cjs +328 -0
  104. package/dist/adapters/langchain/backend/utils.cjs.map +1 -0
  105. package/dist/adapters/langchain/backend/utils.d.cts +39 -0
  106. package/dist/adapters/langchain/backend/utils.d.ts +39 -0
  107. package/dist/adapters/langchain/backend/utils.js +324 -0
  108. package/dist/adapters/langchain/backend/utils.js.map +1 -0
  109. package/dist/adapters/langchain/tools.cjs.map +1 -1
  110. package/dist/adapters/langchain/tools.d.cts +2 -2
  111. package/dist/adapters/langchain/tools.d.ts +2 -2
  112. package/dist/adapters/langchain/tools.js.map +1 -1
  113. package/dist/adapters/mcp/serve/http_server.cjs.map +1 -1
  114. package/dist/adapters/mcp/serve/http_server.js.map +1 -1
  115. package/dist/adapters/mcp/serve/in_memory_store.cjs.map +1 -1
  116. package/dist/adapters/mcp/serve/in_memory_store.js.map +1 -1
  117. package/dist/adapters/mcp/serve/server.cjs.map +1 -1
  118. package/dist/adapters/mcp/serve/server.js.map +1 -1
  119. package/dist/adapters/minimax/backend/chat.cjs +25 -0
  120. package/dist/adapters/minimax/backend/chat.cjs.map +1 -0
  121. package/dist/adapters/minimax/backend/chat.d.cts +38 -0
  122. package/dist/adapters/minimax/backend/chat.d.ts +38 -0
  123. package/dist/adapters/minimax/backend/chat.js +23 -0
  124. package/dist/adapters/minimax/backend/chat.js.map +1 -0
  125. package/dist/adapters/minimax/backend/client.cjs +31 -0
  126. package/dist/adapters/minimax/backend/client.cjs.map +1 -0
  127. package/dist/adapters/minimax/backend/client.d.cts +17 -0
  128. package/dist/adapters/minimax/backend/client.d.ts +17 -0
  129. package/dist/adapters/minimax/backend/client.js +29 -0
  130. package/dist/adapters/minimax/backend/client.js.map +1 -0
  131. package/dist/adapters/ollama/backend/chat.cjs.map +1 -1
  132. package/dist/adapters/ollama/backend/chat.d.cts +2 -2
  133. package/dist/adapters/ollama/backend/chat.d.ts +2 -2
  134. package/dist/adapters/ollama/backend/chat.js.map +1 -1
  135. package/dist/adapters/ollama/backend/client.cjs.map +1 -1
  136. package/dist/adapters/ollama/backend/client.js.map +1 -1
  137. package/dist/adapters/ollama/backend/embedding.cjs.map +1 -1
  138. package/dist/adapters/ollama/backend/embedding.d.cts +2 -2
  139. package/dist/adapters/ollama/backend/embedding.d.ts +2 -2
  140. package/dist/adapters/ollama/backend/embedding.js.map +1 -1
  141. package/dist/adapters/openai/backend/chat.cjs.map +1 -1
  142. package/dist/adapters/openai/backend/chat.d.cts +2 -2
  143. package/dist/adapters/openai/backend/chat.d.ts +2 -2
  144. package/dist/adapters/openai/backend/chat.js.map +1 -1
  145. package/dist/adapters/openai/backend/client.cjs.map +1 -1
  146. package/dist/adapters/openai/backend/client.js.map +1 -1
  147. package/dist/adapters/openai/backend/embedding.cjs.map +1 -1
  148. package/dist/adapters/openai/backend/embedding.d.cts +2 -2
  149. package/dist/adapters/openai/backend/embedding.d.ts +2 -2
  150. package/dist/adapters/openai/backend/embedding.js.map +1 -1
  151. package/dist/adapters/vercel/backend/chat.cjs.map +1 -1
  152. package/dist/adapters/vercel/backend/chat.d.cts +2 -2
  153. package/dist/adapters/vercel/backend/chat.d.ts +2 -2
  154. package/dist/adapters/vercel/backend/chat.js.map +1 -1
  155. package/dist/adapters/vercel/backend/embedding.cjs.map +1 -1
  156. package/dist/adapters/vercel/backend/embedding.d.cts +2 -2
  157. package/dist/adapters/vercel/backend/embedding.d.ts +2 -2
  158. package/dist/adapters/vercel/backend/embedding.js.map +1 -1
  159. package/dist/adapters/vercel/backend/utils.cjs.map +1 -1
  160. package/dist/adapters/vercel/backend/utils.d.cts +2 -2
  161. package/dist/adapters/vercel/backend/utils.d.ts +2 -2
  162. package/dist/adapters/vercel/backend/utils.js.map +1 -1
  163. package/dist/adapters/watsonx/backend/chat.cjs.map +1 -1
  164. package/dist/adapters/watsonx/backend/chat.d.cts +2 -2
  165. package/dist/adapters/watsonx/backend/chat.d.ts +2 -2
  166. package/dist/adapters/watsonx/backend/chat.js +1 -1
  167. package/dist/adapters/watsonx/backend/chat.js.map +1 -1
  168. package/dist/adapters/watsonx/backend/client.cjs.map +1 -1
  169. package/dist/adapters/watsonx/backend/client.js.map +1 -1
  170. package/dist/adapters/watsonx/backend/embedding.cjs.map +1 -1
  171. package/dist/adapters/watsonx/backend/embedding.d.cts +2 -2
  172. package/dist/adapters/watsonx/backend/embedding.d.ts +2 -2
  173. package/dist/adapters/watsonx/backend/embedding.js.map +1 -1
  174. package/dist/adapters/xai/backend/chat.cjs.map +1 -1
  175. package/dist/adapters/xai/backend/chat.d.cts +2 -2
  176. package/dist/adapters/xai/backend/chat.d.ts +2 -2
  177. package/dist/adapters/xai/backend/chat.js.map +1 -1
  178. package/dist/adapters/xai/backend/client.cjs.map +1 -1
  179. package/dist/adapters/xai/backend/client.js.map +1 -1
  180. package/dist/{agent-CZGWXO-X.d.ts → agent-s3uhvAba.d.ts} +4 -4
  181. package/dist/{agent-PRlGoawI.d.cts → agent-zfT__iq9.d.cts} +4 -4
  182. package/dist/agents/base.cjs.map +1 -1
  183. package/dist/agents/base.d.cts +2 -2
  184. package/dist/agents/base.d.ts +2 -2
  185. package/dist/agents/base.js.map +1 -1
  186. package/dist/agents/experimental/replan/agent.cjs.map +1 -1
  187. package/dist/agents/experimental/replan/agent.d.cts +3 -3
  188. package/dist/agents/experimental/replan/agent.d.ts +3 -3
  189. package/dist/agents/experimental/replan/agent.js.map +1 -1
  190. package/dist/agents/experimental/replan/prompts.cjs.map +1 -1
  191. package/dist/agents/experimental/replan/prompts.d.cts +1 -1
  192. package/dist/agents/experimental/replan/prompts.d.ts +1 -1
  193. package/dist/agents/experimental/replan/prompts.js.map +1 -1
  194. package/dist/agents/experimental/streamlit/agent.cjs.map +1 -1
  195. package/dist/agents/experimental/streamlit/agent.d.cts +3 -3
  196. package/dist/agents/experimental/streamlit/agent.d.ts +3 -3
  197. package/dist/agents/experimental/streamlit/agent.js.map +1 -1
  198. package/dist/agents/experimental/streamlit/prompts.cjs +2 -2
  199. package/dist/agents/experimental/streamlit/prompts.cjs.map +1 -1
  200. package/dist/agents/experimental/streamlit/prompts.js +2 -2
  201. package/dist/agents/experimental/streamlit/prompts.js.map +1 -1
  202. package/dist/agents/react/agent.cjs +6 -6
  203. package/dist/agents/react/agent.cjs.map +1 -1
  204. package/dist/agents/react/agent.d.cts +4 -4
  205. package/dist/agents/react/agent.d.ts +4 -4
  206. package/dist/agents/react/agent.js.map +1 -1
  207. package/dist/agents/react/prompts.cjs.map +1 -1
  208. package/dist/agents/react/prompts.js.map +1 -1
  209. package/dist/agents/react/runners/base.cjs.map +1 -1
  210. package/dist/agents/react/runners/base.d.cts +4 -4
  211. package/dist/agents/react/runners/base.d.ts +4 -4
  212. package/dist/agents/react/runners/base.js.map +1 -1
  213. package/dist/agents/react/runners/deep-think/prompts.cjs.map +1 -1
  214. package/dist/agents/react/runners/deep-think/prompts.js.map +1 -1
  215. package/dist/agents/react/runners/deep-think/runner.cjs.map +1 -1
  216. package/dist/agents/react/runners/deep-think/runner.d.cts +4 -4
  217. package/dist/agents/react/runners/deep-think/runner.d.ts +4 -4
  218. package/dist/agents/react/runners/deep-think/runner.js.map +1 -1
  219. package/dist/agents/react/runners/default/runner.cjs.map +1 -1
  220. package/dist/agents/react/runners/default/runner.d.cts +4 -4
  221. package/dist/agents/react/runners/default/runner.d.ts +4 -4
  222. package/dist/agents/react/runners/default/runner.js.map +1 -1
  223. package/dist/agents/react/runners/default/runner.spec.cjs.map +1 -1
  224. package/dist/agents/react/runners/default/runner.spec.js.map +1 -1
  225. package/dist/agents/react/runners/granite/prompts.cjs.map +1 -1
  226. package/dist/agents/react/runners/granite/prompts.js.map +1 -1
  227. package/dist/agents/react/runners/granite/runner.cjs.map +1 -1
  228. package/dist/agents/react/runners/granite/runner.d.cts +4 -4
  229. package/dist/agents/react/runners/granite/runner.d.ts +4 -4
  230. package/dist/agents/react/runners/granite/runner.js.map +1 -1
  231. package/dist/agents/react/types.d.cts +2 -2
  232. package/dist/agents/react/types.d.ts +2 -2
  233. package/dist/agents/requirement/agent.cjs.map +1 -1
  234. package/dist/agents/requirement/agent.d.cts +5 -5
  235. package/dist/agents/requirement/agent.d.ts +5 -5
  236. package/dist/agents/requirement/agent.js.map +1 -1
  237. package/dist/agents/requirement/prompts.d.cts +8 -8
  238. package/dist/agents/requirement/prompts.d.ts +8 -8
  239. package/dist/agents/requirement/requirements/conditional.cjs.map +1 -1
  240. package/dist/agents/requirement/requirements/conditional.d.cts +5 -5
  241. package/dist/agents/requirement/requirements/conditional.d.ts +5 -5
  242. package/dist/agents/requirement/requirements/conditional.js.map +1 -1
  243. package/dist/agents/requirement/requirements/requirement.cjs.map +1 -1
  244. package/dist/agents/requirement/requirements/requirement.d.cts +4 -4
  245. package/dist/agents/requirement/requirements/requirement.d.ts +4 -4
  246. package/dist/agents/requirement/requirements/requirement.js.map +1 -1
  247. package/dist/agents/requirement/requirements/utils.cjs.map +1 -1
  248. package/dist/agents/requirement/requirements/utils.d.cts +1 -1
  249. package/dist/agents/requirement/requirements/utils.d.ts +1 -1
  250. package/dist/agents/requirement/requirements/utils.js.map +1 -1
  251. package/dist/agents/requirement/runner.cjs.map +1 -1
  252. package/dist/agents/requirement/runner.d.cts +5 -5
  253. package/dist/agents/requirement/runner.d.ts +5 -5
  254. package/dist/agents/requirement/runner.js.map +1 -1
  255. package/dist/agents/requirement/types.d.cts +4 -4
  256. package/dist/agents/requirement/types.d.ts +4 -4
  257. package/dist/agents/requirement/utils/llm.cjs.map +1 -1
  258. package/dist/agents/requirement/utils/llm.d.cts +4 -4
  259. package/dist/agents/requirement/utils/llm.d.ts +4 -4
  260. package/dist/agents/requirement/utils/llm.js.map +1 -1
  261. package/dist/agents/requirement/utils/tool.cjs.map +1 -1
  262. package/dist/agents/requirement/utils/tool.d.cts +4 -4
  263. package/dist/agents/requirement/utils/tool.d.ts +4 -4
  264. package/dist/agents/requirement/utils/tool.js.map +1 -1
  265. package/dist/agents/requirement/utils/toolCallChecker.cjs.map +1 -1
  266. package/dist/agents/requirement/utils/toolCallChecker.js.map +1 -1
  267. package/dist/agents/toolCalling/agent.cjs.map +1 -1
  268. package/dist/agents/toolCalling/agent.d.cts +4 -4
  269. package/dist/agents/toolCalling/agent.d.ts +4 -4
  270. package/dist/agents/toolCalling/agent.js.map +1 -1
  271. package/dist/agents/toolCalling/prompts.cjs.map +1 -1
  272. package/dist/agents/toolCalling/prompts.js.map +1 -1
  273. package/dist/agents/toolCalling/types.d.cts +1 -1
  274. package/dist/agents/toolCalling/types.d.ts +1 -1
  275. package/dist/agents/types.d.cts +2 -2
  276. package/dist/agents/types.d.ts +2 -2
  277. package/dist/backend/backend.cjs.map +1 -1
  278. package/dist/backend/backend.d.cts +3 -3
  279. package/dist/backend/backend.d.ts +3 -3
  280. package/dist/backend/backend.js.map +1 -1
  281. package/dist/backend/chat.cjs.map +1 -1
  282. package/dist/backend/chat.d.cts +2 -2
  283. package/dist/backend/chat.d.ts +2 -2
  284. package/dist/backend/chat.js.map +1 -1
  285. package/dist/backend/client.cjs.map +1 -1
  286. package/dist/backend/client.js.map +1 -1
  287. package/dist/backend/constants.cjs +7 -0
  288. package/dist/backend/constants.cjs.map +1 -1
  289. package/dist/backend/constants.d.cts +5 -0
  290. package/dist/backend/constants.d.ts +5 -0
  291. package/dist/backend/constants.js +7 -0
  292. package/dist/backend/constants.js.map +1 -1
  293. package/dist/backend/core.d.cts +2 -2
  294. package/dist/backend/core.d.ts +2 -2
  295. package/dist/backend/embedding.cjs.map +1 -1
  296. package/dist/backend/embedding.d.cts +2 -2
  297. package/dist/backend/embedding.d.ts +2 -2
  298. package/dist/backend/embedding.js.map +1 -1
  299. package/dist/backend/errors.cjs.map +1 -1
  300. package/dist/backend/errors.d.cts +2 -2
  301. package/dist/backend/errors.d.ts +2 -2
  302. package/dist/backend/errors.js.map +1 -1
  303. package/dist/backend/message.cjs.map +1 -1
  304. package/dist/backend/message.js.map +1 -1
  305. package/dist/backend/utils.cjs.map +1 -1
  306. package/dist/backend/utils.d.cts +2 -2
  307. package/dist/backend/utils.d.ts +2 -2
  308. package/dist/backend/utils.js.map +1 -1
  309. package/dist/{base-CyFx7BRL.d.ts → base-BjzyQ8k6.d.ts} +2 -2
  310. package/dist/{base-XfWeXQ-S.d.cts → base-s3ioVIE9.d.cts} +2 -2
  311. package/dist/cache/decoratorCache.cjs.map +1 -1
  312. package/dist/cache/decoratorCache.js.map +1 -1
  313. package/dist/cache/fileCache.cjs.map +1 -1
  314. package/dist/cache/fileCache.js.map +1 -1
  315. package/dist/cache/nullCache.cjs.map +1 -1
  316. package/dist/cache/nullCache.js.map +1 -1
  317. package/dist/cache/slidingCache.cjs.map +1 -1
  318. package/dist/cache/slidingCache.js.map +1 -1
  319. package/dist/cache/unconstrainedCache.cjs.map +1 -1
  320. package/dist/cache/unconstrainedCache.js.map +1 -1
  321. package/dist/{chat-BFl85cqt.d.cts → chat-C20nYj46.d.cts} +3 -3
  322. package/dist/{chat-BRuyDeKR.d.ts → chat-CfTNfR60.d.ts} +3 -3
  323. package/dist/context.cjs.map +1 -1
  324. package/dist/context.d.cts +1 -1
  325. package/dist/context.d.ts +1 -1
  326. package/dist/context.js.map +1 -1
  327. package/dist/emitter/emitter.cjs.map +1 -1
  328. package/dist/emitter/emitter.d.cts +1 -1
  329. package/dist/emitter/emitter.d.ts +1 -1
  330. package/dist/emitter/emitter.js.map +1 -1
  331. package/dist/emitter/types.d.cts +1 -1
  332. package/dist/emitter/types.d.ts +1 -1
  333. package/dist/emitter/utils.cjs.map +1 -1
  334. package/dist/emitter/utils.js.map +1 -1
  335. package/dist/{emitter-jN55XZZq.d.cts → emitter-D4OcelZ9.d.cts} +1 -1
  336. package/dist/{emitter-36-9MnvA.d.ts → emitter-kHxkUxco.d.ts} +1 -1
  337. package/dist/errors.cjs.map +1 -1
  338. package/dist/errors.js.map +1 -1
  339. package/dist/index.d.cts +4 -4
  340. package/dist/index.d.ts +4 -4
  341. package/dist/internals/env.cjs.map +1 -1
  342. package/dist/internals/env.js.map +1 -1
  343. package/dist/internals/fetcher.cjs.map +1 -1
  344. package/dist/internals/fetcher.d.cts +1 -1
  345. package/dist/internals/fetcher.d.ts +1 -1
  346. package/dist/internals/fetcher.js.map +1 -1
  347. package/dist/internals/helpers/array.cjs.map +1 -1
  348. package/dist/internals/helpers/array.js.map +1 -1
  349. package/dist/internals/helpers/cancellation.cjs.map +1 -1
  350. package/dist/internals/helpers/cancellation.js.map +1 -1
  351. package/dist/internals/helpers/counter.cjs.map +1 -1
  352. package/dist/internals/helpers/counter.js.map +1 -1
  353. package/dist/internals/helpers/general.cjs.map +1 -1
  354. package/dist/internals/helpers/general.js.map +1 -1
  355. package/dist/internals/helpers/hash.cjs.map +1 -1
  356. package/dist/internals/helpers/hash.js.map +1 -1
  357. package/dist/internals/helpers/map.cjs.map +1 -1
  358. package/dist/internals/helpers/map.js.map +1 -1
  359. package/dist/internals/helpers/math.cjs.map +1 -1
  360. package/dist/internals/helpers/math.js.map +1 -1
  361. package/dist/internals/helpers/object.cjs +7 -1
  362. package/dist/internals/helpers/object.cjs.map +1 -1
  363. package/dist/internals/helpers/object.js +7 -1
  364. package/dist/internals/helpers/object.js.map +1 -1
  365. package/dist/internals/helpers/paginate.cjs.map +1 -1
  366. package/dist/internals/helpers/paginate.js.map +1 -1
  367. package/dist/internals/helpers/promise.cjs.map +1 -1
  368. package/dist/internals/helpers/promise.js.map +1 -1
  369. package/dist/internals/helpers/prototype.cjs.map +1 -1
  370. package/dist/internals/helpers/prototype.js.map +1 -1
  371. package/dist/internals/helpers/retry.cjs.map +1 -1
  372. package/dist/internals/helpers/retry.js.map +1 -1
  373. package/dist/internals/helpers/retryable.cjs.map +1 -1
  374. package/dist/internals/helpers/retryable.js.map +1 -1
  375. package/dist/internals/helpers/schema.cjs.map +1 -1
  376. package/dist/internals/helpers/schema.d.cts +4 -4
  377. package/dist/internals/helpers/schema.d.ts +4 -4
  378. package/dist/internals/helpers/schema.js.map +1 -1
  379. package/dist/internals/helpers/stream.cjs.map +1 -1
  380. package/dist/internals/helpers/stream.js.map +1 -1
  381. package/dist/internals/helpers/string.cjs.map +1 -1
  382. package/dist/internals/helpers/string.js.map +1 -1
  383. package/dist/internals/helpers/weakRef.cjs.map +1 -1
  384. package/dist/internals/helpers/weakRef.js.map +1 -1
  385. package/dist/internals/serializable.cjs +3 -1
  386. package/dist/internals/serializable.cjs.map +1 -1
  387. package/dist/internals/serializable.d.cts +6 -0
  388. package/dist/internals/serializable.d.ts +6 -0
  389. package/dist/internals/serializable.js +3 -1
  390. package/dist/internals/serializable.js.map +1 -1
  391. package/dist/internals/types.cjs.map +1 -1
  392. package/dist/internals/types.js.map +1 -1
  393. package/dist/logger/logger.cjs.map +1 -1
  394. package/dist/logger/logger.d.cts +2 -2
  395. package/dist/logger/logger.d.ts +2 -2
  396. package/dist/logger/logger.js +2 -2
  397. package/dist/logger/logger.js.map +1 -1
  398. package/dist/logger/pretty.cjs.map +1 -1
  399. package/dist/logger/pretty.js.map +1 -1
  400. package/dist/memory/base.cjs.map +1 -1
  401. package/dist/memory/base.js.map +1 -1
  402. package/dist/memory/slidingMemory.cjs.map +1 -1
  403. package/dist/memory/slidingMemory.js.map +1 -1
  404. package/dist/memory/summarizeMemory.cjs.map +1 -1
  405. package/dist/memory/summarizeMemory.d.cts +2 -2
  406. package/dist/memory/summarizeMemory.d.ts +2 -2
  407. package/dist/memory/summarizeMemory.js.map +1 -1
  408. package/dist/memory/tokenMemory.cjs.map +1 -1
  409. package/dist/memory/tokenMemory.js.map +1 -1
  410. package/dist/memory/unconstrainedMemory.cjs.map +1 -1
  411. package/dist/memory/unconstrainedMemory.js.map +1 -1
  412. package/dist/middleware/streamToolCall.cjs.map +1 -1
  413. package/dist/middleware/streamToolCall.d.cts +2 -2
  414. package/dist/middleware/streamToolCall.d.ts +2 -2
  415. package/dist/middleware/streamToolCall.js.map +1 -1
  416. package/dist/middleware/trajectory.cjs.map +1 -1
  417. package/dist/middleware/trajectory.d.cts +2 -2
  418. package/dist/middleware/trajectory.d.ts +2 -2
  419. package/dist/middleware/trajectory.js.map +1 -1
  420. package/dist/parsers/errors.cjs.map +1 -1
  421. package/dist/parsers/errors.js.map +1 -1
  422. package/dist/parsers/field.cjs.map +1 -1
  423. package/dist/parsers/field.js.map +1 -1
  424. package/dist/parsers/linePrefix.cjs.map +1 -1
  425. package/dist/parsers/linePrefix.d.cts +1 -1
  426. package/dist/parsers/linePrefix.d.ts +1 -1
  427. package/dist/parsers/linePrefix.js.map +1 -1
  428. package/dist/serializer/error.cjs.map +1 -1
  429. package/dist/serializer/error.js.map +1 -1
  430. package/dist/serializer/serializer.cjs +16 -3
  431. package/dist/serializer/serializer.cjs.map +1 -1
  432. package/dist/serializer/serializer.d.cts +1 -1
  433. package/dist/serializer/serializer.d.ts +1 -1
  434. package/dist/serializer/serializer.js +16 -4
  435. package/dist/serializer/serializer.js.map +1 -1
  436. package/dist/serializer/utils.cjs.map +1 -1
  437. package/dist/serializer/utils.d.cts +1 -1
  438. package/dist/serializer/utils.d.ts +1 -1
  439. package/dist/serializer/utils.js.map +1 -1
  440. package/dist/{serializer-53t8gGQa.d.ts → serializer-BafOT48s.d.ts} +10 -4
  441. package/dist/{serializer-c51B2z6d.d.cts → serializer-CFDWYUco.d.cts} +10 -4
  442. package/dist/serve/server.cjs.map +1 -1
  443. package/dist/serve/server.js.map +1 -1
  444. package/dist/template.cjs.map +1 -1
  445. package/dist/template.js.map +1 -1
  446. package/dist/tools/arxiv.cjs.map +1 -1
  447. package/dist/tools/arxiv.d.cts +2 -2
  448. package/dist/tools/arxiv.d.ts +2 -2
  449. package/dist/tools/arxiv.js.map +1 -1
  450. package/dist/tools/base.cjs.map +1 -1
  451. package/dist/tools/base.d.cts +1 -1
  452. package/dist/tools/base.d.ts +1 -1
  453. package/dist/tools/base.js.map +1 -1
  454. package/dist/tools/calculator.cjs.map +1 -1
  455. package/dist/tools/calculator.d.cts +3 -3
  456. package/dist/tools/calculator.d.ts +3 -3
  457. package/dist/tools/calculator.js.map +1 -1
  458. package/dist/tools/custom.cjs.map +1 -1
  459. package/dist/tools/custom.d.cts +3 -3
  460. package/dist/tools/custom.d.ts +3 -3
  461. package/dist/tools/custom.js.map +1 -1
  462. package/dist/tools/database/elasticsearch.cjs.map +1 -1
  463. package/dist/tools/database/elasticsearch.d.cts +3 -3
  464. package/dist/tools/database/elasticsearch.d.ts +3 -3
  465. package/dist/tools/database/elasticsearch.js.map +1 -1
  466. package/dist/tools/database/metadata.cjs.map +1 -1
  467. package/dist/tools/database/metadata.js.map +1 -1
  468. package/dist/tools/database/milvus.cjs.map +1 -1
  469. package/dist/tools/database/milvus.d.cts +5 -5
  470. package/dist/tools/database/milvus.d.ts +5 -5
  471. package/dist/tools/database/milvus.js.map +1 -1
  472. package/dist/tools/database/qdrant.cjs.map +1 -1
  473. package/dist/tools/database/qdrant.d.cts +2 -2
  474. package/dist/tools/database/qdrant.d.ts +2 -2
  475. package/dist/tools/database/qdrant.js.map +1 -1
  476. package/dist/tools/database/sql.cjs.map +1 -1
  477. package/dist/tools/database/sql.d.cts +2 -2
  478. package/dist/tools/database/sql.d.ts +2 -2
  479. package/dist/tools/database/sql.js.map +1 -1
  480. package/dist/tools/handoff.cjs.map +1 -1
  481. package/dist/tools/handoff.d.cts +2 -2
  482. package/dist/tools/handoff.d.ts +2 -2
  483. package/dist/tools/handoff.js.map +1 -1
  484. package/dist/tools/llm.cjs +1 -1
  485. package/dist/tools/llm.cjs.map +1 -1
  486. package/dist/tools/llm.d.cts +3 -3
  487. package/dist/tools/llm.d.ts +3 -3
  488. package/dist/tools/llm.js +1 -1
  489. package/dist/tools/llm.js.map +1 -1
  490. package/dist/tools/mcp.cjs.map +1 -1
  491. package/dist/tools/mcp.d.cts +2 -2
  492. package/dist/tools/mcp.d.ts +2 -2
  493. package/dist/tools/mcp.js.map +1 -1
  494. package/dist/tools/openapi.cjs.map +1 -1
  495. package/dist/tools/openapi.d.cts +2 -2
  496. package/dist/tools/openapi.d.ts +2 -2
  497. package/dist/tools/openapi.js.map +1 -1
  498. package/dist/tools/python/output.cjs.map +1 -1
  499. package/dist/tools/python/output.d.cts +1 -1
  500. package/dist/tools/python/output.d.ts +1 -1
  501. package/dist/tools/python/output.js.map +1 -1
  502. package/dist/tools/python/python.cjs +5 -2
  503. package/dist/tools/python/python.cjs.map +1 -1
  504. package/dist/tools/python/python.d.cts +3 -3
  505. package/dist/tools/python/python.d.ts +3 -3
  506. package/dist/tools/python/python.js +5 -2
  507. package/dist/tools/python/python.js.map +1 -1
  508. package/dist/tools/python/storage.cjs.map +1 -1
  509. package/dist/tools/python/storage.js.map +1 -1
  510. package/dist/tools/search/base.cjs.map +1 -1
  511. package/dist/tools/search/base.d.cts +2 -2
  512. package/dist/tools/search/base.d.ts +2 -2
  513. package/dist/tools/search/base.js.map +1 -1
  514. package/dist/tools/search/duckDuckGoSearch.cjs.map +1 -1
  515. package/dist/tools/search/duckDuckGoSearch.d.cts +2 -2
  516. package/dist/tools/search/duckDuckGoSearch.d.ts +2 -2
  517. package/dist/tools/search/duckDuckGoSearch.js.map +1 -1
  518. package/dist/tools/search/googleSearch.cjs.map +1 -1
  519. package/dist/tools/search/googleSearch.d.cts +2 -2
  520. package/dist/tools/search/googleSearch.d.ts +2 -2
  521. package/dist/tools/search/googleSearch.js.map +1 -1
  522. package/dist/tools/search/searXNGSearch.cjs.map +1 -1
  523. package/dist/tools/search/searXNGSearch.d.cts +2 -2
  524. package/dist/tools/search/searXNGSearch.d.ts +2 -2
  525. package/dist/tools/search/searXNGSearch.js.map +1 -1
  526. package/dist/tools/search/wikipedia.cjs.map +1 -1
  527. package/dist/tools/search/wikipedia.d.cts +3 -3
  528. package/dist/tools/search/wikipedia.d.ts +3 -3
  529. package/dist/tools/search/wikipedia.js.map +1 -1
  530. package/dist/tools/similarity.cjs.map +1 -1
  531. package/dist/tools/similarity.d.cts +2 -2
  532. package/dist/tools/similarity.d.ts +2 -2
  533. package/dist/tools/similarity.js.map +1 -1
  534. package/dist/tools/think.cjs.map +1 -1
  535. package/dist/tools/think.d.cts +2 -2
  536. package/dist/tools/think.d.ts +2 -2
  537. package/dist/tools/think.js.map +1 -1
  538. package/dist/tools/weather/openMeteo.cjs.map +1 -1
  539. package/dist/tools/weather/openMeteo.d.cts +2 -2
  540. package/dist/tools/weather/openMeteo.d.ts +2 -2
  541. package/dist/tools/weather/openMeteo.js.map +1 -1
  542. package/dist/tools/web/webCrawler.cjs.map +1 -1
  543. package/dist/tools/web/webCrawler.d.cts +2 -2
  544. package/dist/tools/web/webCrawler.d.ts +2 -2
  545. package/dist/tools/web/webCrawler.js.map +1 -1
  546. package/dist/{types-CkEtV8R9.d.cts → types-BNsa3W7Z.d.cts} +4 -4
  547. package/dist/{types-BQ-3LdkE.d.ts → types-DYtzF6ya.d.ts} +4 -4
  548. package/dist/version.cjs +1 -1
  549. package/dist/version.js +1 -1
  550. package/dist/workflows/agent.cjs.map +1 -1
  551. package/dist/workflows/agent.d.cts +40 -40
  552. package/dist/workflows/agent.d.ts +40 -40
  553. package/dist/workflows/agent.js.map +1 -1
  554. package/dist/workflows/workflow.cjs.map +1 -1
  555. package/dist/workflows/workflow.d.cts +1 -1
  556. package/dist/workflows/workflow.d.ts +1 -1
  557. package/dist/workflows/workflow.js.map +1 -1
  558. package/package.json +33 -10
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/agents/react/runners/default/runner.spec.ts"],"names":["vi","mock","UnconstrainedMemory","TokenMemory","describe","beforeEach","useRealTimers","it","useFakeTimers","setSystemTime","Date","createMemory","memory","addMany","UserMessage","AssistantMessage","createInstance","prompt","instance","DefaultRunner","llm","expect","any","Function","tools","templates","RunContext","init","memory2","add","createdAt","instance2","messages","toEqual","each","ReActAgentUserPrompt","fork","old","functions","formatMeta","template","user","a","b","zip","filter","msg","role","Role","USER","render","input","text","meta","undefined","toStrictEqual"],"mappings":";;;;;;;;;AAcAA,EAAAA,CAAGC,IAAAA,CAAK,2BAA2B,YAAA;AACjC,EAAA,MAAM,EAAEC,mBAAAA,EAAAA,oBAAAA,EAAmB,GAAK,MAAM,OAAO,2CAAA,CAAA;AAC7C,EAAA,IAAMC,WAAAA,GAAN,MAAMA,WAAAA,SAAoBD,oBAAAA,CAAAA;IAhB5B;;;AAgBiD,GAAA;AAC/C,EAAA,OAAO;AAAEC,IAAAA;AAAY,GAAA;AACvB,CAAA,CAAA;AAEAH,EAAAA,CAAGC,KAAK,cAAA,CAAA;AAERG,QAAAA,CAAS,sBAAsB,MAAA;AAC7BC,EAAAA,UAAAA,CAAW,MAAA;AACTL,IAAAA,EAAAA,CAAGM,aAAAA,EAAa;GAClB,CAAA;AAEAC,EAAAA,EAAAA,CAAG,yCAAyC,YAAA;AAC1CP,IAAAA,EAAAA,CAAGQ,aAAAA,EAAa;AAChBR,IAAAA,EAAAA,CAAGS,aAAAA,iBAAc,IAAIC,IAAAA,CAAK,0BAAA,CAAA,CAAA;AAE1B,IAAA,MAAMC,+BAAe,MAAA,CAAA,YAAA;AACnB,MAAA,MAAMC,OAAAA,GAAS,IAAIV,mBAAAA,EAAAA;AACnB,MAAA,MAAMU,QAAOC,OAAAA,CAAQ;AACnB,QAAA,IAAIC,YAAY,oBAAA,CAAA;AAChB,QAAA,IAAIC,iBAAiB,UAAA;AACtB,OAAA,CAAA;AACD,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AAAA,EAAGC,CAAAA,CAAAA,IAAMC,GAAAA,CACnB;AAAIhC,MAAAA,GAAAA,MAAAA,CAAOoB,SAASa,MAAAA,CAAO,CAACC,QAAQA,GAAAA,CAAIC,IAAAA,KAASC,KAAKC,IAAI,CAAA;AAAG,MAAA,IAAInC,YAAYG,MAAAA;OAC7EC,QAAAA,CAASN,MAAAA,CAAOoB,QAAAA,CAASa,MAAAA,CAAO,CAACC,GAAAA,KAAQA,IAAIC,IAAAA,KAASC,IAAAA,CAAKC,IAAI,CAAA,CAAA,EAC9D;AACD5B,MAAAA,MAAAA,CAAOmB,SAASU,MAAAA,CAAO;AAAEC,QAAAA,KAAAA,EAAOT,CAAAA,CAAEU,IAAAA;QAAMC,IAAAA,EAAMC;AAAU,OAAA,CAAA,CAAA,CAAIC,aAAAA,CAAcZ,CAAAA,CAAES,IAAI,CAAA;AAClF;GACF,CAAA;AACF,CAAA,CAAA","file":"runner.spec.js","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { AssistantMessage, Role, UserMessage } from \"@/backend/message.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { ReActAgentUserPrompt } from \"@/agents/react/prompts.js\";\nimport { zip } from \"remeda\";\nimport { RunContext } from \"@/context.js\";\nimport { ReActAgent } from \"@/agents/react/agent.js\";\n\nvi.mock(\"@/memory/tokenMemory.js\", async () => {\n const { UnconstrainedMemory } = await import(\"@/memory/unconstrainedMemory.js\");\n class TokenMemory extends UnconstrainedMemory {}\n return { TokenMemory };\n});\n\nvi.mock(\"@/context.js\");\n\ndescribe(\"ReAct Agent Runner\", () => {\n beforeEach(() => {\n vi.useRealTimers();\n });\n\n it(\"Handles different prompt input source\", async () => {\n vi.useFakeTimers();\n vi.setSystemTime(new Date(\"2024-09-10T19:51:46.954Z\"));\n\n const createMemory = async () => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([\n new UserMessage(\"What is your name?\"),\n new AssistantMessage(\"I am Bee\"),\n ]);\n return memory;\n };\n\n const createInstance = async (memory: BaseMemory, prompt: string | null) => {\n const instance = new DefaultRunner(\n {\n llm: expect.any(Function),\n memory,\n tools: [],\n templates: {},\n },\n {},\n new RunContext<ReActAgent, any>({} as any, {} as any),\n );\n await instance.init({ prompt });\n return instance;\n };\n\n const memory = await createMemory();\n const prompt = \"What can you do for me?\";\n const instance = await createInstance(memory, prompt);\n\n const memory2 = await createMemory();\n await memory2.add(new UserMessage(prompt, { createdAt: new Date() }));\n const instance2 = await createInstance(memory2, null);\n expect(instance.memory.messages).toEqual(instance2.memory.messages);\n });\n\n it.each([\n ReActAgentUserPrompt.fork((old) => ({\n ...old,\n functions: { ...old.functions, formatMeta: () => \"\" },\n })),\n ReActAgentUserPrompt.fork((old) => ({ ...old, template: `{{input}}` })),\n ReActAgentUserPrompt.fork((old) => ({ ...old, template: `User: {{input}}` })),\n ReActAgentUserPrompt.fork((old) => ({ ...old, template: `` })),\n ])(\"Correctly formats user input\", async (template: typeof ReActAgentUserPrompt) => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([\n new UserMessage(\"What is your name?\"),\n new AssistantMessage(\"Bee\"),\n new UserMessage(\"Who are you?\"),\n new AssistantMessage(\"I am a helpful assistant.\"),\n ]);\n\n const prompt = \"What can you do for me?\";\n const instance = new DefaultRunner(\n {\n llm: expect.any(Function),\n memory,\n tools: [],\n templates: {\n user: template,\n },\n },\n {},\n new RunContext<ReActAgent, any>({} as any, {} as any),\n );\n await instance.init({ prompt });\n\n for (const [a, b] of zip(\n [...memory.messages.filter((msg) => msg.role === Role.USER), new UserMessage(prompt)],\n instance.memory.messages.filter((msg) => msg.role === Role.USER),\n )) {\n expect(template.render({ input: a.text, meta: undefined })).toStrictEqual(b.text);\n }\n });\n});\n"]}
1
+ {"version":3,"sources":["../../../../../src/agents/react/runners/default/runner.spec.ts"],"names":["vi","mock","UnconstrainedMemory","TokenMemory","describe","beforeEach","useRealTimers","it","useFakeTimers","setSystemTime","Date","createMemory","memory","addMany","UserMessage","AssistantMessage","createInstance","prompt","instance","DefaultRunner","llm","expect","any","Function","tools","templates","RunContext","init","memory2","add","createdAt","instance2","messages","toEqual","each","ReActAgentUserPrompt","fork","old","functions","formatMeta","template","user","a","b","zip","filter","msg","role","Role","USER","render","input","text","meta","undefined","toStrictEqual"],"mappings":";;;;;;;;;AAcAA,EAAAA,CAAGC,IAAAA,CAAK,2BAA2B,YAAA;AACjC,EAAA,MAAM,EAAEC,mBAAAA,EAAAA,oBAAAA,EAAmB,GAAK,MAAM,OAAO,2CAAA,CAAA;AAC7C,EAAA,IAAMC,WAAAA,GAAN,MAAMA,WAAAA,SAAoBD,oBAAAA,CAAAA;IAhB5B;;;AAgBiD,GAAA;AAC/C,EAAA,OAAO;AAAEC,IAAAA;AAAY,GAAA;AACvB,CAAA,CAAA;AAEAH,EAAAA,CAAGC,KAAK,cAAA,CAAA;AAERG,QAAAA,CAAS,sBAAsB,MAAA;AAC7BC,EAAAA,UAAAA,CAAW,MAAA;AACTL,IAAAA,EAAAA,CAAGM,aAAAA,EAAa;EAClB,CAAA,CAAA;AAEAC,EAAAA,EAAAA,CAAG,yCAAyC,YAAA;AAC1CP,IAAAA,EAAAA,CAAGQ,aAAAA,EAAa;AAChBR,IAAAA,EAAAA,CAAGS,aAAAA,iBAAc,IAAIC,IAAAA,CAAK,0BAAA,CAAA,CAAA;AAE1B,IAAA,MAAMC,+BAAe,MAAA,CAAA,YAAA;AACnB,MAAA,MAAMC,OAAAA,GAAS,IAAIV,mBAAAA,EAAAA;AACnB,MAAA,MAAMU,QAAOC,OAAAA,CAAQ;AACnB,QAAA,IAAIC,YAAY,oBAAA,CAAA;AAChB,QAAA,IAAIC,iBAAiB,UAAA;AACtB,OAAA,CAAA;AACD,MAAA,OAAOH,OAAAA;IACT,CAAA,EAPqB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,CAAAA,IAAMC,GAAAA,CACnB;AAAIhC,MAAAA,GAAAA,MAAAA,CAAOoB,SAASa,MAAAA,CAAO,CAACC,QAAQA,GAAAA,CAAIC,IAAAA,KAASC,KAAKC,IAAI,CAAA;AAAG,MAAA,IAAInC,YAAYG,MAAAA;OAC7EC,QAAAA,CAASN,MAAAA,CAAOoB,QAAAA,CAASa,MAAAA,CAAO,CAACC,GAAAA,KAAQA,IAAIC,IAAAA,KAASC,IAAAA,CAAKC,IAAI,CAAA,CAAA,EAC9D;AACD5B,MAAAA,MAAAA,CAAOmB,SAASU,MAAAA,CAAO;AAAEC,QAAAA,KAAAA,EAAOT,CAAAA,CAAEU,IAAAA;QAAMC,IAAAA,EAAMC;AAAU,OAAA,CAAA,CAAA,CAAIC,aAAAA,CAAcZ,CAAAA,CAAES,IAAI,CAAA;AAClF,IAAA;EACF,CAAA,CAAA;AACF,CAAA,CAAA","file":"runner.spec.js","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { AssistantMessage, Role, UserMessage } from \"@/backend/message.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { ReActAgentUserPrompt } from \"@/agents/react/prompts.js\";\nimport { zip } from \"remeda\";\nimport { RunContext } from \"@/context.js\";\nimport { ReActAgent } from \"@/agents/react/agent.js\";\n\nvi.mock(\"@/memory/tokenMemory.js\", async () => {\n const { UnconstrainedMemory } = await import(\"@/memory/unconstrainedMemory.js\");\n class TokenMemory extends UnconstrainedMemory {}\n return { TokenMemory };\n});\n\nvi.mock(\"@/context.js\");\n\ndescribe(\"ReAct Agent Runner\", () => {\n beforeEach(() => {\n vi.useRealTimers();\n });\n\n it(\"Handles different prompt input source\", async () => {\n vi.useFakeTimers();\n vi.setSystemTime(new Date(\"2024-09-10T19:51:46.954Z\"));\n\n const createMemory = async () => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([\n new UserMessage(\"What is your name?\"),\n new AssistantMessage(\"I am Bee\"),\n ]);\n return memory;\n };\n\n const createInstance = async (memory: BaseMemory, prompt: string | null) => {\n const instance = new DefaultRunner(\n {\n llm: expect.any(Function),\n memory,\n tools: [],\n templates: {},\n },\n {},\n new RunContext<ReActAgent, any>({} as any, {} as any),\n );\n await instance.init({ prompt });\n return instance;\n };\n\n const memory = await createMemory();\n const prompt = \"What can you do for me?\";\n const instance = await createInstance(memory, prompt);\n\n const memory2 = await createMemory();\n await memory2.add(new UserMessage(prompt, { createdAt: new Date() }));\n const instance2 = await createInstance(memory2, null);\n expect(instance.memory.messages).toEqual(instance2.memory.messages);\n });\n\n it.each([\n ReActAgentUserPrompt.fork((old) => ({\n ...old,\n functions: { ...old.functions, formatMeta: () => \"\" },\n })),\n ReActAgentUserPrompt.fork((old) => ({ ...old, template: `{{input}}` })),\n ReActAgentUserPrompt.fork((old) => ({ ...old, template: `User: {{input}}` })),\n ReActAgentUserPrompt.fork((old) => ({ ...old, template: `` })),\n ])(\"Correctly formats user input\", async (template: typeof ReActAgentUserPrompt) => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([\n new UserMessage(\"What is your name?\"),\n new AssistantMessage(\"Bee\"),\n new UserMessage(\"Who are you?\"),\n new AssistantMessage(\"I am a helpful assistant.\"),\n ]);\n\n const prompt = \"What can you do for me?\";\n const instance = new DefaultRunner(\n {\n llm: expect.any(Function),\n memory,\n tools: [],\n templates: {\n user: template,\n },\n },\n {},\n new RunContext<ReActAgent, any>({} as any, {} as any),\n );\n await instance.init({ prompt });\n\n for (const [a, b] of zip(\n [...memory.messages.filter((msg) => msg.role === Role.USER), new UserMessage(prompt)],\n instance.memory.messages.filter((msg) => msg.role === Role.USER),\n )) {\n expect(template.render({ input: a.text, meta: undefined })).toStrictEqual(b.text);\n }\n });\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/agents/react/runners/granite/prompts.ts"],"names":["GraniteReActAgentAssistantPrompt","ReActAgentAssistantPrompt","fork","config","template","GraniteReActAgentSystemPrompt","ReActAgentSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","GraniteReActAgentSchemaErrorPrompt","ReActAgentSchemaErrorPrompt","GraniteReActAgentUserPrompt","ReActAgentUserPrompt","GraniteReActAgentToolNotFoundPrompt","ReActAgentToolNotFoundPrompt","GraniteReActAgentToolErrorPrompt","ReActAgentToolErrorPrompt","GraniteReActAgentToolInputErrorPrompt","ReActAgentToolInputErrorPrompt"],"mappings":";;;;AAeO,MAAMA,gCAAAA,GAAmCC,qCAAAA,CAA0BC,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AAC9EA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;;AACpB,CAAA;AAEO,MAAMC,6BAAAA,GAAgCC,kCAAAA,CAAuBJ,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AACxEA,EAAAA,MAAAA,CAAOI,SAASC,YAAAA,GAAe,EAAA;AAC/BL,EAAAA,MAAAA,CAAOM,SAAAA,CAAUC,aAAa,WAAA;AAC5B,IAAA,MAAMC,IAAAA,GAAO,KAAKC,SAAAA,GAAY,IAAIC,KAAK,IAAA,CAAKD,SAAS,CAAA,mBAAI,IAAIC,IAAAA,EAAAA;AAC7D,IAAA,OAAO,IAAIC,IAAAA,CAAKC,cAAAA,CAAe,OAAA,EAAS;MACtCC,SAAAA,EAAW,MAAA;MACXC,SAAAA,EAAW;KACb,CAAA,CAAGC,OAAOP,IAAAA,CAAAA;AACZ,GAAA;AACAR,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCpB,CAAA;AAEO,MAAMe,kCAAAA,GAAqCC,uCAAAA,CAA4BlB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AAClFA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;AAEpB,CAAA;AAEO,MAAMiB,2BAAAA,GAA8BC,gCAAAA,CAAqBpB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AACpEA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA,SAAA,CAAA;AACpB,CAAA;AAEO,MAAMmB,mCAAAA,GAAsCC,wCAAAA,CAA6BtB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AACpFA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;;AAIpB,CAAA;AAEO,MAAMqB,gCAAAA,GAAmCC,qCAAAA,CAA0BxB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AAC9EA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;AAGpB,CAAA;AAEO,MAAMuB,qCAAAA,GAAwCC,0CAAAA,CAA+B1B,IAAAA,CAClF,CAACC,MAAAA,KAAAA;AACCA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;AAGpB,CAAA","file":"prompts.cjs","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n ReActAgentAssistantPrompt,\n ReActAgentSchemaErrorPrompt,\n ReActAgentSystemPrompt,\n ReActAgentToolErrorPrompt,\n ReActAgentToolInputErrorPrompt,\n ReActAgentToolNotFoundPrompt,\n ReActAgentUserPrompt,\n} from \"@/agents/react/prompts.js\";\n\nexport const GraniteReActAgentAssistantPrompt = ReActAgentAssistantPrompt.fork((config) => {\n config.template = `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Tool Name: {{.}}\\n{{/toolName}}{{#toolInput}}Tool Input: {{.}}\\n{{/toolInput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`;\n});\n\nexport const GraniteReActAgentSystemPrompt = ReActAgentSystemPrompt.fork((config) => {\n config.defaults.instructions = \"\";\n config.functions.formatDate = function () {\n const date = this.createdAt ? new Date(this.createdAt) : new Date();\n return new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"full\",\n timeStyle: \"medium\",\n }).format(date);\n };\n config.template = `You are an AI assistant.\nWhen the user sends a message figure out a solution and provide a final answer.\n{{#tools.length}}\nYou have access to a set of tools that can be used to retrieve information and perform actions.\nPay close attention to the tool description to determine if a tool is useful in a particular context.\n{{/tools.length}}\n\n# Communication structure\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input', or 'Thought' followed by 'Final Answer'\n\nLine starting 'Thought: ' The assistant's response always starts with a thought, this is a single line where the assistant thinks about the user's message and describes in detail what it should do next.\n{{#tools.length}}\nIn a 'Thought: ', the assistant should determine if a Tool Call is necessary to get more information or perform an action, or if the available information is sufficient to provide the Final Answer.\nIf a tool needs to be called and is available, the assistant will produce a tool call:\nLine starting 'Tool Name: ' name of the tool that you want to use.\nLine starting 'Tool Input: ' JSON formatted tool arguments adhering to the selected tool parameters schema i.e. {\"arg1\":\"value1\", \"arg2\":\"value2\"}.\nAfter a 'Tool Input: ' the next message will contain a tool response. The next output should be a 'Thought: ' where the assistant thinks about the all the information it has available, and what it should do next (e.g. try the same tool with a different input, try a different tool, or proceed with answering the original user question).\n{{/tools.length}}\nOnce enough information is available to provide the Final Answer, the last line in the message needs to be:\nLine starting 'Final Answer: ' followed by a concise and clear answer to the original message.\n\n# Best practices\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n{{#tools.length}}\n- Do not attempt to use a tool that is not listed in available tools. This will cause an error.\n- Make sure that tool input is in the correct format and contains the correct arguments.\n{{/tools.length}}\n- When the message is unclear, respond with a line starting with 'Final Answer:' followed by a request for additional information needed to solve the problem.\n- When the user wants to chitchat instead, always respond politely.\n\n# Date and Time\nThe current date and time is: {{formatDate}}\n{{#tools.length}}\nYou do not need a tool to get the current Date and Time. Use the information available here.\n{{/tools.length}}\n\n{{#instructions}} \n# Additional instructions\n{{.}} \n{{/instructions}}\n`;\n});\n\nexport const GraniteReActAgentSchemaErrorPrompt = ReActAgentSchemaErrorPrompt.fork((config) => {\n config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input' or 'Thought' followed by 'Final Answer'.`;\n});\n\nexport const GraniteReActAgentUserPrompt = ReActAgentUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const GraniteReActAgentToolNotFoundPrompt = ReActAgentToolNotFoundPrompt.fork((config) => {\n config.template = `Tool does not exist!\n{{#tools.length}}\nUse one of the following tools: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}\n{{/tools.length}}`;\n});\n\nexport const GraniteReActAgentToolErrorPrompt = ReActAgentToolErrorPrompt.fork((config) => {\n config.template = `The tool has failed; the error log is shown below. If the tool cannot accomplish what you want, use a different tool or explain why you can't use it.\n\n{{reason}}`;\n});\n\nexport const GraniteReActAgentToolInputErrorPrompt = ReActAgentToolInputErrorPrompt.fork(\n (config) => {\n config.template = `{{reason}}\n\nHINT: If you're convinced that the input was correct but the tool cannot process it then use a different tool or say I don't know.`;\n },\n);\n"]}
1
+ {"version":3,"sources":["../../../../../src/agents/react/runners/granite/prompts.ts"],"names":["GraniteReActAgentAssistantPrompt","ReActAgentAssistantPrompt","fork","config","template","GraniteReActAgentSystemPrompt","ReActAgentSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","GraniteReActAgentSchemaErrorPrompt","ReActAgentSchemaErrorPrompt","GraniteReActAgentUserPrompt","ReActAgentUserPrompt","GraniteReActAgentToolNotFoundPrompt","ReActAgentToolNotFoundPrompt","GraniteReActAgentToolErrorPrompt","ReActAgentToolErrorPrompt","GraniteReActAgentToolInputErrorPrompt","ReActAgentToolInputErrorPrompt"],"mappings":";;;;AAeO,MAAMA,gCAAAA,GAAmCC,qCAAAA,CAA0BC,IAAAA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MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;AAGpB,CAAA;AAEO,MAAMuB,qCAAAA,GAAwCC,0CAAAA,CAA+B1B,IAAAA,CAClF,CAACC,MAAAA,KAAAA;AACCA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;AAGpB,CAAA","file":"prompts.cjs","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n ReActAgentAssistantPrompt,\n ReActAgentSchemaErrorPrompt,\n ReActAgentSystemPrompt,\n ReActAgentToolErrorPrompt,\n ReActAgentToolInputErrorPrompt,\n ReActAgentToolNotFoundPrompt,\n ReActAgentUserPrompt,\n} from \"@/agents/react/prompts.js\";\n\nexport const GraniteReActAgentAssistantPrompt = ReActAgentAssistantPrompt.fork((config) => {\n config.template = `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Tool Name: {{.}}\\n{{/toolName}}{{#toolInput}}Tool Input: {{.}}\\n{{/toolInput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`;\n});\n\nexport const GraniteReActAgentSystemPrompt = ReActAgentSystemPrompt.fork((config) => {\n config.defaults.instructions = \"\";\n config.functions.formatDate = function () {\n const date = this.createdAt ? new Date(this.createdAt) : new Date();\n return new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"full\",\n timeStyle: \"medium\",\n }).format(date);\n };\n config.template = `You are an AI assistant.\nWhen the user sends a message figure out a solution and provide a final answer.\n{{#tools.length}}\nYou have access to a set of tools that can be used to retrieve information and perform actions.\nPay close attention to the tool description to determine if a tool is useful in a particular context.\n{{/tools.length}}\n\n# Communication structure\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input', or 'Thought' followed by 'Final Answer'\n\nLine starting 'Thought: ' The assistant's response always starts with a thought, this is a single line where the assistant thinks about the user's message and describes in detail what it should do next.\n{{#tools.length}}\nIn a 'Thought: ', the assistant should determine if a Tool Call is necessary to get more information or perform an action, or if the available information is sufficient to provide the Final Answer.\nIf a tool needs to be called and is available, the assistant will produce a tool call:\nLine starting 'Tool Name: ' name of the tool that you want to use.\nLine starting 'Tool Input: ' JSON formatted tool arguments adhering to the selected tool parameters schema i.e. {\"arg1\":\"value1\", \"arg2\":\"value2\"}.\nAfter a 'Tool Input: ' the next message will contain a tool response. The next output should be a 'Thought: ' where the assistant thinks about the all the information it has available, and what it should do next (e.g. try the same tool with a different input, try a different tool, or proceed with answering the original user question).\n{{/tools.length}}\nOnce enough information is available to provide the Final Answer, the last line in the message needs to be:\nLine starting 'Final Answer: ' followed by a concise and clear answer to the original message.\n\n# Best practices\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n{{#tools.length}}\n- Do not attempt to use a tool that is not listed in available tools. This will cause an error.\n- Make sure that tool input is in the correct format and contains the correct arguments.\n{{/tools.length}}\n- When the message is unclear, respond with a line starting with 'Final Answer:' followed by a request for additional information needed to solve the problem.\n- When the user wants to chitchat instead, always respond politely.\n\n# Date and Time\nThe current date and time is: {{formatDate}}\n{{#tools.length}}\nYou do not need a tool to get the current Date and Time. Use the information available here.\n{{/tools.length}}\n\n{{#instructions}} \n# Additional instructions\n{{.}} \n{{/instructions}}\n`;\n});\n\nexport const GraniteReActAgentSchemaErrorPrompt = ReActAgentSchemaErrorPrompt.fork((config) => {\n config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input' or 'Thought' followed by 'Final Answer'.`;\n});\n\nexport const GraniteReActAgentUserPrompt = ReActAgentUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const GraniteReActAgentToolNotFoundPrompt = ReActAgentToolNotFoundPrompt.fork((config) => {\n config.template = `Tool does not exist!\n{{#tools.length}}\nUse one of the following tools: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}\n{{/tools.length}}`;\n});\n\nexport const GraniteReActAgentToolErrorPrompt = ReActAgentToolErrorPrompt.fork((config) => {\n config.template = `The tool has failed; the error log is shown below. If the tool cannot accomplish what you want, use a different tool or explain why you can't use it.\n\n{{reason}}`;\n});\n\nexport const GraniteReActAgentToolInputErrorPrompt = ReActAgentToolInputErrorPrompt.fork(\n (config) => {\n config.template = `{{reason}}\n\nHINT: If you're convinced that the input was correct but the tool cannot process it then use a different tool or say I don't know.`;\n },\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/agents/react/runners/granite/prompts.ts"],"names":["GraniteReActAgentAssistantPrompt","ReActAgentAssistantPrompt","fork","config","template","GraniteReActAgentSystemPrompt","ReActAgentSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","GraniteReActAgentSchemaErrorPrompt","ReActAgentSchemaErrorPrompt","GraniteReActAgentUserPrompt","ReActAgentUserPrompt","GraniteReActAgentToolNotFoundPrompt","ReActAgentToolNotFoundPrompt","GraniteReActAgentToolErrorPrompt","ReActAgentToolErrorPrompt","GraniteReActAgentToolInputErrorPrompt","ReActAgentToolInputErrorPrompt"],"mappings":";;AAeO,MAAMA,gCAAAA,GAAmCC,yBAAAA,CAA0BC,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AAC9EA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;;AACpB,CAAA;AAEO,MAAMC,6BAAAA,GAAgCC,sBAAAA,CAAuBJ,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AACxEA,EAAAA,MAAAA,CAAOI,SAASC,YAAAA,GAAe,EAAA;AAC/BL,EAAAA,MAAAA,CAAOM,SAAAA,CAAUC,aAAa,WAAA;AAC5B,IAAA,MAAMC,IAAAA,GAAO,KAAKC,SAAAA,GAAY,IAAIC,KAAK,IAAA,CAAKD,SAAS,CAAA,mBAAI,IAAIC,IAAAA,EAAAA;AAC7D,IAAA,OAAO,IAAIC,IAAAA,CAAKC,cAAAA,CAAe,OAAA,EAAS;MACtCC,SAAAA,EAAW,MAAA;MACXC,SAAAA,EAAW;KACb,CAAA,CAAGC,OAAOP,IAAAA,CAAAA;AACZ,GAAA;AACAR,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCpB,CAAA;AAEO,MAAMe,kCAAAA,GAAqCC,2BAAAA,CAA4BlB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AAClFA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;AAEpB,CAAA;AAEO,MAAMiB,2BAAAA,GAA8BC,oBAAAA,CAAqBpB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AACpEA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA,SAAA,CAAA;AACpB,CAAA;AAEO,MAAMmB,mCAAAA,GAAsCC,4BAAAA,CAA6BtB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AACpFA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;;AAIpB,CAAA;AAEO,MAAMqB,gCAAAA,GAAmCC,yBAAAA,CAA0BxB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AAC9EA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;AAGpB,CAAA;AAEO,MAAMuB,qCAAAA,GAAwCC,8BAAAA,CAA+B1B,IAAAA,CAClF,CAACC,MAAAA,KAAAA;AACCA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;AAGpB,CAAA","file":"prompts.js","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n ReActAgentAssistantPrompt,\n ReActAgentSchemaErrorPrompt,\n ReActAgentSystemPrompt,\n ReActAgentToolErrorPrompt,\n ReActAgentToolInputErrorPrompt,\n ReActAgentToolNotFoundPrompt,\n ReActAgentUserPrompt,\n} from \"@/agents/react/prompts.js\";\n\nexport const GraniteReActAgentAssistantPrompt = ReActAgentAssistantPrompt.fork((config) => {\n config.template = `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Tool Name: {{.}}\\n{{/toolName}}{{#toolInput}}Tool Input: {{.}}\\n{{/toolInput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`;\n});\n\nexport const GraniteReActAgentSystemPrompt = ReActAgentSystemPrompt.fork((config) => {\n config.defaults.instructions = \"\";\n config.functions.formatDate = function () {\n const date = this.createdAt ? new Date(this.createdAt) : new Date();\n return new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"full\",\n timeStyle: \"medium\",\n }).format(date);\n };\n config.template = `You are an AI assistant.\nWhen the user sends a message figure out a solution and provide a final answer.\n{{#tools.length}}\nYou have access to a set of tools that can be used to retrieve information and perform actions.\nPay close attention to the tool description to determine if a tool is useful in a particular context.\n{{/tools.length}}\n\n# Communication structure\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input', or 'Thought' followed by 'Final Answer'\n\nLine starting 'Thought: ' The assistant's response always starts with a thought, this is a single line where the assistant thinks about the user's message and describes in detail what it should do next.\n{{#tools.length}}\nIn a 'Thought: ', the assistant should determine if a Tool Call is necessary to get more information or perform an action, or if the available information is sufficient to provide the Final Answer.\nIf a tool needs to be called and is available, the assistant will produce a tool call:\nLine starting 'Tool Name: ' name of the tool that you want to use.\nLine starting 'Tool Input: ' JSON formatted tool arguments adhering to the selected tool parameters schema i.e. {\"arg1\":\"value1\", \"arg2\":\"value2\"}.\nAfter a 'Tool Input: ' the next message will contain a tool response. The next output should be a 'Thought: ' where the assistant thinks about the all the information it has available, and what it should do next (e.g. try the same tool with a different input, try a different tool, or proceed with answering the original user question).\n{{/tools.length}}\nOnce enough information is available to provide the Final Answer, the last line in the message needs to be:\nLine starting 'Final Answer: ' followed by a concise and clear answer to the original message.\n\n# Best practices\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n{{#tools.length}}\n- Do not attempt to use a tool that is not listed in available tools. This will cause an error.\n- Make sure that tool input is in the correct format and contains the correct arguments.\n{{/tools.length}}\n- When the message is unclear, respond with a line starting with 'Final Answer:' followed by a request for additional information needed to solve the problem.\n- When the user wants to chitchat instead, always respond politely.\n\n# Date and Time\nThe current date and time is: {{formatDate}}\n{{#tools.length}}\nYou do not need a tool to get the current Date and Time. Use the information available here.\n{{/tools.length}}\n\n{{#instructions}} \n# Additional instructions\n{{.}} \n{{/instructions}}\n`;\n});\n\nexport const GraniteReActAgentSchemaErrorPrompt = ReActAgentSchemaErrorPrompt.fork((config) => {\n config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input' or 'Thought' followed by 'Final Answer'.`;\n});\n\nexport const GraniteReActAgentUserPrompt = ReActAgentUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const GraniteReActAgentToolNotFoundPrompt = ReActAgentToolNotFoundPrompt.fork((config) => {\n config.template = `Tool does not exist!\n{{#tools.length}}\nUse one of the following tools: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}\n{{/tools.length}}`;\n});\n\nexport const GraniteReActAgentToolErrorPrompt = ReActAgentToolErrorPrompt.fork((config) => {\n config.template = `The tool has failed; the error log is shown below. If the tool cannot accomplish what you want, use a different tool or explain why you can't use it.\n\n{{reason}}`;\n});\n\nexport const GraniteReActAgentToolInputErrorPrompt = ReActAgentToolInputErrorPrompt.fork(\n (config) => {\n config.template = `{{reason}}\n\nHINT: If you're convinced that the input was correct but the tool cannot process it then use a different tool or say I don't know.`;\n },\n);\n"]}
1
+ {"version":3,"sources":["../../../../../src/agents/react/runners/granite/prompts.ts"],"names":["GraniteReActAgentAssistantPrompt","ReActAgentAssistantPrompt","fork","config","template","GraniteReActAgentSystemPrompt","ReActAgentSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","GraniteReActAgentSchemaErrorPrompt","ReActAgentSchemaErrorPrompt","GraniteReActAgentUserPrompt","ReActAgentUserPrompt","GraniteReActAgentToolNotFoundPrompt","ReActAgentToolNotFoundPrompt","GraniteReActAgentToolErrorPrompt","ReActAgentToolErrorPrompt","GraniteReActAgentToolInputErrorPrompt","ReActAgentToolInputErrorPrompt"],"mappings":";;AAeO,MAAMA,gCAAAA,GAAmCC,yBAAAA,CAA0BC,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AAC9EA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;;AACpB,CAAA;AAEO,MAAMC,6BAAAA,GAAgCC,sBAAAA,CAAuBJ,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AACxEA,EAAAA,MAAAA,CAAOI,SAASC,YAAAA,GAAe,EAAA;AAC/BL,EAAAA,MAAAA,CAAOM,SAAAA,CAAUC,aAAa,WAAA;AAC5B,IAAA,MAAMC,IAAAA,GAAO,KAAKC,SAAAA,GAAY,IAAIC,KAAK,IAAA,CAAKD,SAAS,CAAA,mBAAI,IAAIC,IAAAA,EAAAA;AAC7D,IAAA,OAAO,IAAIC,IAAAA,CAAKC,cAAAA,CAAe,OAAA,EAAS;MACtCC,SAAAA,EAAW,MAAA;MACXC,SAAAA,EAAW;KACb,CAAA,CAAGC,OAAOP,IAAAA,CAAAA;AACZ,EAAA,CAAA;AACAR,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCpB,CAAA;AAEO,MAAMe,kCAAAA,GAAqCC,2BAAAA,CAA4BlB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AAClFA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;AAEpB,CAAA;AAEO,MAAMiB,2BAAAA,GAA8BC,oBAAAA,CAAqBpB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AACpEA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA,SAAA,CAAA;AACpB,CAAA;AAEO,MAAMmB,mCAAAA,GAAsCC,4BAAAA,CAA6BtB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AACpFA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;;AAIpB,CAAA;AAEO,MAAMqB,gCAAAA,GAAmCC,yBAAAA,CAA0BxB,IAAAA,CAAK,CAACC,MAAAA,KAAAA;AAC9EA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;AAGpB,CAAA;AAEO,MAAMuB,qCAAAA,GAAwCC,8BAAAA,CAA+B1B,IAAAA,CAClF,CAACC,MAAAA,KAAAA;AACCA,EAAAA,MAAAA,CAAOC,QAAAA,GAAW,CAAA;;;AAGpB,CAAA","file":"prompts.js","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n ReActAgentAssistantPrompt,\n ReActAgentSchemaErrorPrompt,\n ReActAgentSystemPrompt,\n ReActAgentToolErrorPrompt,\n ReActAgentToolInputErrorPrompt,\n ReActAgentToolNotFoundPrompt,\n ReActAgentUserPrompt,\n} from \"@/agents/react/prompts.js\";\n\nexport const GraniteReActAgentAssistantPrompt = ReActAgentAssistantPrompt.fork((config) => {\n config.template = `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Tool Name: {{.}}\\n{{/toolName}}{{#toolInput}}Tool Input: {{.}}\\n{{/toolInput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`;\n});\n\nexport const GraniteReActAgentSystemPrompt = ReActAgentSystemPrompt.fork((config) => {\n config.defaults.instructions = \"\";\n config.functions.formatDate = function () {\n const date = this.createdAt ? new Date(this.createdAt) : new Date();\n return new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"full\",\n timeStyle: \"medium\",\n }).format(date);\n };\n config.template = `You are an AI assistant.\nWhen the user sends a message figure out a solution and provide a final answer.\n{{#tools.length}}\nYou have access to a set of tools that can be used to retrieve information and perform actions.\nPay close attention to the tool description to determine if a tool is useful in a particular context.\n{{/tools.length}}\n\n# Communication structure\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input', or 'Thought' followed by 'Final Answer'\n\nLine starting 'Thought: ' The assistant's response always starts with a thought, this is a single line where the assistant thinks about the user's message and describes in detail what it should do next.\n{{#tools.length}}\nIn a 'Thought: ', the assistant should determine if a Tool Call is necessary to get more information or perform an action, or if the available information is sufficient to provide the Final Answer.\nIf a tool needs to be called and is available, the assistant will produce a tool call:\nLine starting 'Tool Name: ' name of the tool that you want to use.\nLine starting 'Tool Input: ' JSON formatted tool arguments adhering to the selected tool parameters schema i.e. {\"arg1\":\"value1\", \"arg2\":\"value2\"}.\nAfter a 'Tool Input: ' the next message will contain a tool response. The next output should be a 'Thought: ' where the assistant thinks about the all the information it has available, and what it should do next (e.g. try the same tool with a different input, try a different tool, or proceed with answering the original user question).\n{{/tools.length}}\nOnce enough information is available to provide the Final Answer, the last line in the message needs to be:\nLine starting 'Final Answer: ' followed by a concise and clear answer to the original message.\n\n# Best practices\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n{{#tools.length}}\n- Do not attempt to use a tool that is not listed in available tools. This will cause an error.\n- Make sure that tool input is in the correct format and contains the correct arguments.\n{{/tools.length}}\n- When the message is unclear, respond with a line starting with 'Final Answer:' followed by a request for additional information needed to solve the problem.\n- When the user wants to chitchat instead, always respond politely.\n\n# Date and Time\nThe current date and time is: {{formatDate}}\n{{#tools.length}}\nYou do not need a tool to get the current Date and Time. Use the information available here.\n{{/tools.length}}\n\n{{#instructions}} \n# Additional instructions\n{{.}} \n{{/instructions}}\n`;\n});\n\nexport const GraniteReActAgentSchemaErrorPrompt = ReActAgentSchemaErrorPrompt.fork((config) => {\n config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input' or 'Thought' followed by 'Final Answer'.`;\n});\n\nexport const GraniteReActAgentUserPrompt = ReActAgentUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const GraniteReActAgentToolNotFoundPrompt = ReActAgentToolNotFoundPrompt.fork((config) => {\n config.template = `Tool does not exist!\n{{#tools.length}}\nUse one of the following tools: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}\n{{/tools.length}}`;\n});\n\nexport const GraniteReActAgentToolErrorPrompt = ReActAgentToolErrorPrompt.fork((config) => {\n config.template = `The tool has failed; the error log is shown below. If the tool cannot accomplish what you want, use a different tool or explain why you can't use it.\n\n{{reason}}`;\n});\n\nexport const GraniteReActAgentToolInputErrorPrompt = ReActAgentToolInputErrorPrompt.fork(\n (config) => {\n config.template = `{{reason}}\n\nHINT: If you're convinced that the input was correct but the tool cannot process it then use a different tool or say I don't know.`;\n },\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/agents/react/runners/granite/runner.ts"],"names":["GraniteRunner","DefaultRunner","useNativeToolCalling","defaultTemplates","system","GraniteReActAgentSystemPrompt","assistant","GraniteReActAgentAssistantPrompt","user","GraniteReActAgentUserPrompt","schemaError","GraniteReActAgentSchemaErrorPrompt","toolNotFoundError","GraniteReActAgentToolNotFoundPrompt","toolError","GraniteReActAgentToolErrorPrompt","toolInputError","GraniteReActAgentToolInputErrorPrompt","userEmpty","ReActAgentUserEmptyPrompt","toolNoResultError","ReActAgentToolNoResultsPrompt","register","input","options","run","emitter","on","update","meta","memory","data","key","add","ToolMessage","type","output","success","value","toolName","tool_name","toolCallId","isBlocking","createParser","tools","parser","fork","nodes","thought","prefix","tool_input","isEnd","next","final_answer","enumerable"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BO,MAAMA,sBAAsBC,wBAAAA,CAAAA;AAAAA,EAAAA;;;EACvBC,oBAAAA,GAAuB,IAAA;AAEjC,EAAA,IACWC,gBAA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LC,MAAAA,MAAAA,EAAQA,MAAAA,CAAOC,IAAAA,CAA4B,CAACC,KAAAA,EAAOvB,OAAAA,MAAa;AAC9DA,QAAAA,OAAAA;QACAuB,KAAAA,EAAO;UACL,GAAGA,KAAAA;UACHC,OAAAA,EAAS;AAAE,YAAA,GAAGD,KAAAA,CAAMC,OAAAA;YAASC,MAAAA,EAAQ;AAAW,WAAA;UAChDT,SAAAA,EAAW;AAAE,YAAA,GAAGO,KAAAA,CAAMP,SAAAA;YAAWS,MAAAA,EAAQ;AAAa,WAAA;UACtDC,UAAAA,EAAY;AAAE,YAAA,GAAGH,KAAAA,CAAMG,UAAAA;YAAYD,MAAAA,EAAQ,aAAA;YAAeE,KAAAA,EAAO,IAAA;AAAMC,YAAAA,IAAAA,EAAM;AAAG,WAAA;UAChFC,YAAAA,EAAc;AAAE,YAAA,GAAGN,KAAAA,CAAMM,YAAAA;YAAcJ,MAAAA,EAAQ;AAAgB;AACjE;OACF,CAAA;AACF,KAAA;AACF;AACF;;;IAlEWK,UAAAA,EAAY","file":"runner.cjs","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ToolMessage } from \"@/backend/message.js\";\nimport type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport type { ReActAgentParserInput, ReActAgentRunOptions } from \"@/agents/react/types.js\";\nimport { ReActAgent, ReActAgentInput } from \"@/agents/react/agent.js\";\nimport type { GetRunContext } from \"@/context.js\";\nimport {\n GraniteReActAgentAssistantPrompt,\n GraniteReActAgentSchemaErrorPrompt,\n GraniteReActAgentSystemPrompt,\n GraniteReActAgentToolErrorPrompt,\n GraniteReActAgentToolInputErrorPrompt,\n GraniteReActAgentToolNotFoundPrompt,\n GraniteReActAgentUserPrompt,\n} from \"@/agents/react/runners/granite/prompts.js\";\nimport {\n ReActAgentToolNoResultsPrompt,\n ReActAgentUserEmptyPrompt,\n} from \"@/agents/react/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\n\nexport class GraniteRunner extends DefaultRunner {\n protected useNativeToolCalling = true;\n\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: GraniteReActAgentSystemPrompt,\n assistant: GraniteReActAgentAssistantPrompt,\n user: GraniteReActAgentUserPrompt,\n schemaError: GraniteReActAgentSchemaErrorPrompt,\n toolNotFoundError: GraniteReActAgentToolNotFoundPrompt,\n toolError: GraniteReActAgentToolErrorPrompt,\n toolInputError: GraniteReActAgentToolInputErrorPrompt,\n // Note: These are from ReAct\n userEmpty: ReActAgentUserEmptyPrompt,\n toolNoResultError: ReActAgentToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n constructor(\n input: ReActAgentInput,\n options: ReActAgentRunOptions,\n run: GetRunContext<ReActAgent>,\n ) {\n super(input, options, run);\n\n run.emitter.on(\n \"update\",\n async ({ update, meta, memory, data }) => {\n if (update.key === \"tool_output\") {\n await memory.add(\n new ToolMessage(\n {\n type: \"tool-result\",\n output: { type: meta.success ? \"text\" : \"error-text\", value: update.value },\n toolName: data.tool_name!,\n toolCallId: \"DUMMY_ID\",\n },\n { success: meta.success },\n ),\n );\n }\n },\n {\n isBlocking: true,\n },\n );\n }\n\n protected createParser(tools: AnyTool[]) {\n const { parser } = super.createParser(tools);\n\n return {\n parser: parser.fork<ReActAgentParserInput>((nodes, options) => ({\n options,\n nodes: {\n ...nodes,\n thought: { ...nodes.thought, prefix: \"Thought:\" },\n tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n tool_input: { ...nodes.tool_input, prefix: \"Tool Input:\", isEnd: true, next: [] },\n final_answer: { ...nodes.final_answer, prefix: \"Final Answer:\" },\n },\n })),\n };\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../../../src/agents/react/runners/granite/runner.ts"],"names":["GraniteRunner","DefaultRunner","useNativeToolCalling","defaultTemplates","system","GraniteReActAgentSystemPrompt","assistant","GraniteReActAgentAssistantPrompt","user","GraniteReActAgentUserPrompt","schemaError","GraniteReActAgentSchemaErrorPrompt","toolNotFoundError","GraniteReActAgentToolNotFoundPrompt","toolError","GraniteReActAgentToolErrorPrompt","toolInputError","GraniteReActAgentToolInputErrorPrompt","userEmpty","ReActAgentUserEmptyPrompt","toolNoResultError","ReActAgentToolNoResultsPrompt","register","input","options","run","emitter","on","update","meta","memory","data","key","add","ToolMessage","type","output","success","value","toolName","tool_name","toolCallId","isBlocking","createParser","tools","parser","fork","nodes","thought","prefix","tool_input","isEnd","next","final_answer","enumerable"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BO,MAAMA,sBAAsBC,wBAAAA,CAAAA;AAAAA,EAAAA;;;EACvBC,oBAAAA,GAAuB,IAAA;AAEjC,EAAA,IACWC,gBAAAA,GAAmB;AAC5B,IAAA,OAAO;MACLC,MAAAA,EAAQC,2CAAAA;MACRC,SAAAA,EAAWC,8CAAAA;MACXC,IAAAA,EAAMC,yCAAAA;MACNC,WAAAA,EAAaC,gDAAAA;MACbC,iBAAAA,EAAmBC,iDAAAA;MACnBC,SAAAA,EAAWC,8CAAAA;MACXC,cAAAA,EAAgBC,mDAAAA;;MAEhBC,SAAAA,EAAWC,qCAAAA;MACXC,iBAAAA,EAAmBC;AACrB,KAAA;AACF,EAAA;EAEA;AACE,IAAA,IAAA,CAAKC,QAAAA,EAAQ;AACf;EAEA,WAAA,CACEC,KAAAA,EACAC,SACAC,GAAAA,EACA;AACA,IAAA,KAAA,CAAMF,KAAAA,EAAOC,SAASC,GAAAA,CAAAA;AAEtBA,IAAAA,GAAAA,CAAIC,OAAAA,CAAQC,GACV,QAAA,EACA,OAAO,EAAEC,MAAAA,EAAQC,IAAAA,EAAMC,MAAAA,EAAQC,IAAAA,EAAI,KAAE;AACnC,MAAA,IAAIH,MAAAA,CAAOI,QAAQ,aAAA,EAAe;AAChC,QAAA,MAAMF,MAAAA,CAAOG,GAAAA,CACX,IAAIC,uBAAAA,CACF;UACE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ects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ToolMessage } from \"@/backend/message.js\";\nimport type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport type { ReActAgentParserInput, ReActAgentRunOptions } from \"@/agents/react/types.js\";\nimport { ReActAgent, ReActAgentInput } from \"@/agents/react/agent.js\";\nimport type { GetRunContext } from \"@/context.js\";\nimport {\n GraniteReActAgentAssistantPrompt,\n GraniteReActAgentSchemaErrorPrompt,\n GraniteReActAgentSystemPrompt,\n GraniteReActAgentToolErrorPrompt,\n GraniteReActAgentToolInputErrorPrompt,\n GraniteReActAgentToolNotFoundPrompt,\n GraniteReActAgentUserPrompt,\n} from \"@/agents/react/runners/granite/prompts.js\";\nimport {\n ReActAgentToolNoResultsPrompt,\n ReActAgentUserEmptyPrompt,\n} from \"@/agents/react/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\n\nexport class GraniteRunner extends DefaultRunner {\n protected useNativeToolCalling = true;\n\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: GraniteReActAgentSystemPrompt,\n assistant: GraniteReActAgentAssistantPrompt,\n user: GraniteReActAgentUserPrompt,\n schemaError: GraniteReActAgentSchemaErrorPrompt,\n toolNotFoundError: GraniteReActAgentToolNotFoundPrompt,\n toolError: GraniteReActAgentToolErrorPrompt,\n toolInputError: GraniteReActAgentToolInputErrorPrompt,\n // Note: These are from ReAct\n userEmpty: ReActAgentUserEmptyPrompt,\n toolNoResultError: ReActAgentToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n constructor(\n input: ReActAgentInput,\n options: ReActAgentRunOptions,\n run: GetRunContext<ReActAgent>,\n ) {\n super(input, options, run);\n\n run.emitter.on(\n \"update\",\n async ({ update, meta, memory, data }) => {\n if (update.key === \"tool_output\") {\n await memory.add(\n new ToolMessage(\n {\n type: \"tool-result\",\n output: { type: meta.success ? \"text\" : \"error-text\", value: update.value },\n toolName: data.tool_name!,\n toolCallId: \"DUMMY_ID\",\n },\n { success: meta.success },\n ),\n );\n }\n },\n {\n isBlocking: true,\n },\n );\n }\n\n protected createParser(tools: AnyTool[]) {\n const { parser } = super.createParser(tools);\n\n return {\n parser: parser.fork<ReActAgentParserInput>((nodes, options) => ({\n options,\n nodes: {\n ...nodes,\n thought: { ...nodes.thought, prefix: \"Thought:\" },\n tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n tool_input: { ...nodes.tool_input, prefix: \"Tool Input:\", isEnd: true, next: [] },\n final_answer: { ...nodes.final_answer, prefix: \"Final Answer:\" },\n },\n })),\n };\n }\n}\n"]}
@@ -4,10 +4,10 @@ import * as zod from 'zod';
4
4
  import { AnyTool } from '../../../../tools/base.cjs';
5
5
  import { DefaultRunner } from '../default/runner.cjs';
6
6
  import { ReActAgentRunOptions, ReActAgentParserInput } from '../../types.cjs';
7
- import { R as ReActAgentInput, a as ReActAgent } from '../../../../agent-PRlGoawI.cjs';
7
+ import { R as ReActAgentInput, a as ReActAgent } from '../../../../agent-zfT__iq9.cjs';
8
8
  import { GetRunContext } from '../../../../context.cjs';
9
9
  import 'node_modules/remeda/dist/ToString-DKW-jYvM.js';
10
- import '../../../../emitter-jN55XZZq.cjs';
10
+ import '../../../../emitter-D4OcelZ9.cjs';
11
11
  import '../../../../internals/types.cjs';
12
12
  import '../../../../internals/helpers/guards.cjs';
13
13
  import '../../../../internals/serializable.cjs';
@@ -25,8 +25,8 @@ import '../../../../internals/helpers/promise.cjs';
25
25
  import '../../../../backend/message.cjs';
26
26
  import 'ai';
27
27
  import '../../../../memory/base.cjs';
28
- import '../../../../base-XfWeXQ-S.cjs';
29
- import '../../../../chat-BFl85cqt.cjs';
28
+ import '../../../../base-s3ioVIE9.cjs';
29
+ import '../../../../chat-C20nYj46.cjs';
30
30
  import '../../../../backend/constants.cjs';
31
31
  import '../../../../logger/logger.cjs';
32
32
  import 'pino';
@@ -4,10 +4,10 @@ import * as zod from 'zod';
4
4
  import { AnyTool } from '../../../../tools/base.js';
5
5
  import { DefaultRunner } from '../default/runner.js';
6
6
  import { ReActAgentRunOptions, ReActAgentParserInput } from '../../types.js';
7
- import { R as ReActAgentInput, a as ReActAgent } from '../../../../agent-CZGWXO-X.js';
7
+ import { R as ReActAgentInput, a as ReActAgent } from '../../../../agent-s3uhvAba.js';
8
8
  import { GetRunContext } from '../../../../context.js';
9
9
  import 'node_modules/remeda/dist/ToString-DKW-jYvM.js';
10
- import '../../../../emitter-36-9MnvA.js';
10
+ import '../../../../emitter-kHxkUxco.js';
11
11
  import '../../../../internals/types.js';
12
12
  import '../../../../internals/helpers/guards.js';
13
13
  import '../../../../internals/serializable.js';
@@ -25,8 +25,8 @@ import '../../../../internals/helpers/promise.js';
25
25
  import '../../../../backend/message.js';
26
26
  import 'ai';
27
27
  import '../../../../memory/base.js';
28
- import '../../../../base-CyFx7BRL.js';
29
- import '../../../../chat-BRuyDeKR.js';
28
+ import '../../../../base-BjzyQ8k6.js';
29
+ import '../../../../chat-CfTNfR60.js';
30
30
  import '../../../../backend/constants.js';
31
31
  import '../../../../logger/logger.js';
32
32
  import 'pino';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/agents/react/runners/granite/runner.ts"],"names":["GraniteRunner","DefaultRunner","useNativeToolCalling","defaultTemplates","system","GraniteReActAgentSystemPrompt","assistant","GraniteReActAgentAssistantPrompt","user","GraniteReActAgentUserPrompt","schemaError","GraniteReActAgentSchemaErrorPrompt","toolNotFoundError","GraniteReActAgentToolNotFoundPrompt","toolError","GraniteReActAgentToolErrorPrompt","toolInputError","GraniteReActAgentToolInputErrorPrompt","userEmpty","ReActAgentUserEmptyPrompt","toolNoResultError","ReActAgentToolNoResultsPrompt","register","input","options","run","emitter","on","update","meta","memory","data","key","add","ToolMessage","type","output","success","value","toolName","tool_name","toolCallId","isBlocking","createParser","tools","parser","fork","nodes","thought","prefix","tool_input","isEnd","next","final_answer","enumerable"],"mappings":";;;;;;;;;;;;;;;;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A,EAAkB;AACvC,IAAA,MAAM,EAAEC,MAAAA,EAAM,GAAK,KAAA,CAAMF,aAAaC,KAAAA,CAAAA;AAEtC,IAAA,OAAO;AACLC,MAAAA,MAAAA,EAAQA,MAAAA,CAAOC,IAAAA,CAA4B,CAACC,KAAAA,EAAOvB,OAAAA,MAAa;AAC9DA,QAAAA,OAAAA;QACAuB,KAAAA,EAAO;UACL,GAAGA,KAAAA;UACHC,OAAAA,EAAS;AAAE,YAAA,GAAGD,KAAAA,CAAMC,OAAAA;YAASC,MAAAA,EAAQ;AAAW,WAAA;UAChDT,SAAAA,EAAW;AAAE,YAAA,GAAGO,KAAAA,CAAMP,SAAAA;YAAWS,MAAAA,EAAQ;AAAa,WAAA;UACtDC,UAAAA,EAAY;AAAE,YAAA,GAAGH,KAAAA,CAAMG,UAAAA;YAAYD,MAAAA,EAAQ,aAAA;YAAeE,KAAAA,EAAO,IAAA;AAAMC,YAAAA,IAAAA,EAAM;AAAG,WAAA;UAChFC,YAAAA,EAAc;AAAE,YAAA,GAAGN,KAAAA,CAAMM,YAAAA;YAAcJ,MAAAA,EAAQ;AAAgB;AACjE;OACF,CAAA;AACF,KAAA;AACF;AACF;;;IAlEWK,UAAAA,EAAY","file":"runner.js","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ToolMessage } from \"@/backend/message.js\";\nimport type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport type { ReActAgentParserInput, ReActAgentRunOptions } from \"@/agents/react/types.js\";\nimport { ReActAgent, ReActAgentInput } from \"@/agents/react/agent.js\";\nimport type { GetRunContext } from \"@/context.js\";\nimport {\n GraniteReActAgentAssistantPrompt,\n GraniteReActAgentSchemaErrorPrompt,\n GraniteReActAgentSystemPrompt,\n GraniteReActAgentToolErrorPrompt,\n GraniteReActAgentToolInputErrorPrompt,\n GraniteReActAgentToolNotFoundPrompt,\n GraniteReActAgentUserPrompt,\n} from \"@/agents/react/runners/granite/prompts.js\";\nimport {\n ReActAgentToolNoResultsPrompt,\n ReActAgentUserEmptyPrompt,\n} from \"@/agents/react/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\n\nexport class GraniteRunner extends DefaultRunner {\n protected useNativeToolCalling = true;\n\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: GraniteReActAgentSystemPrompt,\n assistant: GraniteReActAgentAssistantPrompt,\n user: GraniteReActAgentUserPrompt,\n schemaError: GraniteReActAgentSchemaErrorPrompt,\n toolNotFoundError: GraniteReActAgentToolNotFoundPrompt,\n toolError: GraniteReActAgentToolErrorPrompt,\n toolInputError: GraniteReActAgentToolInputErrorPrompt,\n // Note: These are from ReAct\n userEmpty: ReActAgentUserEmptyPrompt,\n toolNoResultError: ReActAgentToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n constructor(\n input: ReActAgentInput,\n options: ReActAgentRunOptions,\n run: GetRunContext<ReActAgent>,\n ) {\n super(input, options, run);\n\n run.emitter.on(\n \"update\",\n async ({ update, meta, memory, data }) => {\n if (update.key === \"tool_output\") {\n await memory.add(\n new ToolMessage(\n {\n type: \"tool-result\",\n output: { type: meta.success ? \"text\" : \"error-text\", value: update.value },\n toolName: data.tool_name!,\n toolCallId: \"DUMMY_ID\",\n },\n { success: meta.success },\n ),\n );\n }\n },\n {\n isBlocking: true,\n },\n );\n }\n\n protected createParser(tools: AnyTool[]) {\n const { parser } = super.createParser(tools);\n\n return {\n parser: parser.fork<ReActAgentParserInput>((nodes, options) => ({\n options,\n nodes: {\n ...nodes,\n thought: { ...nodes.thought, prefix: \"Thought:\" },\n tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n tool_input: { ...nodes.tool_input, prefix: \"Tool Input:\", isEnd: true, next: [] },\n final_answer: { ...nodes.final_answer, prefix: \"Final Answer:\" },\n },\n })),\n };\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../../../src/agents/react/runners/granite/runner.ts"],"names":["GraniteRunner","DefaultRunner","useNativeToolCalling","defaultTemplates","system","GraniteReActAgentSystemPrompt","assistant","GraniteReActAgentAssistantPrompt","user","GraniteReActAgentUserPrompt","schemaError","GraniteReActAgentSchemaErrorPrompt","toolNotFoundError","GraniteReActAgentToolNotFoundPrompt","toolError","GraniteReActAgentToolErrorPrompt","toolInputError","GraniteReActAgentToolInputErrorPrompt","userEmpty","ReActAgentUserEmptyPrompt","toolNoResultError","ReActAgentToolNoResultsPrompt","register","input","options","run","emitter","on","update","meta","memory","data","key","add","ToolMessage","type","output","success","value","toolName","tool_name","toolCallId","isBlocking","createParser","tools","parser","fork","nodes","thought","prefix","tool_input","isEnd","next","final_answer","enumerable"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BO,MAAMA,sBAAsBC,aAAAA,CAAAA;AAAAA,EAAAA;;;EACvBC,oBAAAA,GAAuB,IAAA;AAEjC,EAAA,IACWC,gBAAAA,GAAmB;AAC5B,IAAA,OAAO;MACLC,MAAAA,EAAQC,6BAAAA;MACRC,SAAAA,EAAWC,gCAAAA;MACXC,IAAAA,EAAMC,2BAAAA;MACNC,WAAAA,EAAaC,kCAAAA;MACbC,iBAAAA,EAAmBC,mCAAAA;MACnBC,SAAAA,EAAWC,gCAAAA;MACXC,cAAAA,EAAgBC,qCAAAA;;MAEhBC,SAAAA,EAAWC,yBAAAA;MACXC,iBAAAA,EAAmBC;AACrB,KAAA;AACF,EAAA;EAEA;AACE,IAAA,IAAA,CAAKC,QAAAA,EAAQ;AACf;EAEA,WAAA,CACEC,KAAAA,EACAC,SACAC,GAAAA,EACA;AACA,IAAA,KAAA,CAAMF,KAAAA,EAAOC,SAASC,GAAAA,CAAAA;AAEtBA,IAAAA,GAAAA,CAAIC,OAAAA,CAAQC,GACV,QAAA,EACA,OAAO,EAAEC,MAAAA,EAAQC,IAAAA,EAAMC,MAAAA,EAAQC,IAAAA,EAAI,KAAE;AACnC,MAAA,IAAIH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ACF,KAAA;AACF,EAAA;AACF;;;IAlEWK,UAAAA,EAAY","file":"runner.js","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ToolMessage } from \"@/backend/message.js\";\nimport type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport type { ReActAgentParserInput, ReActAgentRunOptions } from \"@/agents/react/types.js\";\nimport { ReActAgent, ReActAgentInput } from \"@/agents/react/agent.js\";\nimport type { GetRunContext } from \"@/context.js\";\nimport {\n GraniteReActAgentAssistantPrompt,\n GraniteReActAgentSchemaErrorPrompt,\n GraniteReActAgentSystemPrompt,\n GraniteReActAgentToolErrorPrompt,\n GraniteReActAgentToolInputErrorPrompt,\n GraniteReActAgentToolNotFoundPrompt,\n GraniteReActAgentUserPrompt,\n} from \"@/agents/react/runners/granite/prompts.js\";\nimport {\n ReActAgentToolNoResultsPrompt,\n ReActAgentUserEmptyPrompt,\n} from \"@/agents/react/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\n\nexport class GraniteRunner extends DefaultRunner {\n protected useNativeToolCalling = true;\n\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: GraniteReActAgentSystemPrompt,\n assistant: GraniteReActAgentAssistantPrompt,\n user: GraniteReActAgentUserPrompt,\n schemaError: GraniteReActAgentSchemaErrorPrompt,\n toolNotFoundError: GraniteReActAgentToolNotFoundPrompt,\n toolError: GraniteReActAgentToolErrorPrompt,\n toolInputError: GraniteReActAgentToolInputErrorPrompt,\n // Note: These are from ReAct\n userEmpty: ReActAgentUserEmptyPrompt,\n toolNoResultError: ReActAgentToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n constructor(\n input: ReActAgentInput,\n options: ReActAgentRunOptions,\n run: GetRunContext<ReActAgent>,\n ) {\n super(input, options, run);\n\n run.emitter.on(\n \"update\",\n async ({ update, meta, memory, data }) => {\n if (update.key === \"tool_output\") {\n await memory.add(\n new ToolMessage(\n {\n type: \"tool-result\",\n output: { type: meta.success ? \"text\" : \"error-text\", value: update.value },\n toolName: data.tool_name!,\n toolCallId: \"DUMMY_ID\",\n },\n { success: meta.success },\n ),\n );\n }\n },\n {\n isBlocking: true,\n },\n );\n }\n\n protected createParser(tools: AnyTool[]) {\n const { parser } = super.createParser(tools);\n\n return {\n parser: parser.fork<ReActAgentParserInput>((nodes, options) => ({\n options,\n nodes: {\n ...nodes,\n thought: { ...nodes.thought, prefix: \"Thought:\" },\n tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n tool_input: { ...nodes.tool_input, prefix: \"Tool Input:\", isEnd: true, next: [] },\n final_answer: { ...nodes.final_answer, prefix: \"Final Answer:\" },\n },\n })),\n };\n }\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  import { BaseMemory } from '../../memory/base.cjs';
2
2
  import { Message } from '../../backend/message.cjs';
3
- import { C as Callback } from '../../emitter-jN55XZZq.cjs';
3
+ import { C as Callback } from '../../emitter-D4OcelZ9.cjs';
4
4
  import { AnyTool, BaseToolRunOptions, ToolOutput, ToolError } from '../../tools/base.cjs';
5
5
  import { ReActAgentSystemPrompt, ReActAgentAssistantPrompt, ReActAgentUserPrompt, ReActAgentUserEmptyPrompt, ReActAgentToolErrorPrompt, ReActAgentToolInputErrorPrompt, ReActAgentToolNoResultsPrompt, ReActAgentToolNotFoundPrompt, ReActAgentSchemaErrorPrompt } from './prompts.cjs';
6
6
  import { LinePrefixParser } from '../../parsers/linePrefix.cjs';
7
7
  import { ZodParserField, JSONParserField } from '../../parsers/field.cjs';
8
8
  import { NonUndefined } from '../../internals/types.cjs';
9
- import { n as ChatModelOutput } from '../../chat-BFl85cqt.cjs';
9
+ import { i as ChatModelOutput } from '../../chat-C20nYj46.cjs';
10
10
  import '../../errors.cjs';
11
11
  import '../../internals/helpers/guards.cjs';
12
12
  import '../../internals/serializable.cjs';
@@ -1,12 +1,12 @@
1
1
  import { BaseMemory } from '../../memory/base.js';
2
2
  import { Message } from '../../backend/message.js';
3
- import { C as Callback } from '../../emitter-36-9MnvA.js';
3
+ import { C as Callback } from '../../emitter-kHxkUxco.js';
4
4
  import { AnyTool, BaseToolRunOptions, ToolOutput, ToolError } from '../../tools/base.js';
5
5
  import { ReActAgentSystemPrompt, ReActAgentAssistantPrompt, ReActAgentUserPrompt, ReActAgentUserEmptyPrompt, ReActAgentToolErrorPrompt, ReActAgentToolInputErrorPrompt, ReActAgentToolNoResultsPrompt, ReActAgentToolNotFoundPrompt, ReActAgentSchemaErrorPrompt } from './prompts.js';
6
6
  import { LinePrefixParser } from '../../parsers/linePrefix.js';
7
7
  import { ZodParserField, JSONParserField } from '../../parsers/field.js';
8
8
  import { NonUndefined } from '../../internals/types.js';
9
- import { n as ChatModelOutput } from '../../chat-BRuyDeKR.js';
9
+ import { i as ChatModelOutput } from '../../chat-CfTNfR60.js';
10
10
  import '../../errors.js';
11
11
  import '../../internals/helpers/guards.js';
12
12
  import '../../internals/serializable.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/agents/requirement/agent.ts"],"names":["RequirementAgent","BaseAgent","emitter","Emitter","root","child","namespace","creator","input","runner","RequirementAgentRunner","memory","UnconstrainedMemory","tools","requirements","saveIntermediateSteps","finalAnswerAsTool","toolCallChecker","middlewares","push","register","_run","options","run","execution","maxRetriesPerStep","totalMaxRetries","maxIterations","createToolCallChecker","llm","expectedOutput","templates","newMessages","processInput","addMessages","messages","finalState","reset","addMany","lastPair","slice","answer","Error","result","state","prompt","userMessage","UserMessage","task","render","context","undefined","config","Object","assign","checker","ToolCallChecker","enabled","meta","name","description","length","extraDescription","map","tool","join","overrides","finalized","mapObj","system","RequirementAgentSystemPrompt","RequirementAgentTaskPrompt","toolError","RequirementAgentToolErrorPrompt","toolNoResult","RequirementAgentToolNoResultPrompt","key","defaultTemplate","override","PromptTemplate","role","instructions","notes","update","defaults","pickBy","isEmptyish","castArray","v","isDefined","createSnapshot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/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BaseAgent } from \"@/agents/base.js\";\nimport { AnyTool } from \"@/tools/base.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { AgentMeta } from \"@/agents/types.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\nimport { ChatModel } from \"@/backend/chat.js\";\nimport type { GetRunContext, MiddlewareType } from \"@/context.js\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { Message, UserMessage } from \"@/backend/message.js\";\nimport { shallowCopy } from \"@/serializer/utils.js\";\nimport { mapObj } from \"@/internals/helpers/object.js\";\nimport { PromptTemplate } from \"@/template.js\";\nimport {\n RequirementAgentCallbacks,\n RequirementAgentExecutionConfig,\n RequirementAgentOutput,\n RequirementAgentRunInput,\n RequirementAgentRunOptions,\n RequirementAgentTemplates,\n} from \"./types.js\";\nimport {\n RequirementAgentSystemPrompt,\n RequirementAgentTaskPrompt,\n RequirementAgentToolErrorPrompt,\n RequirementAgentToolNoResultPrompt,\n} from \"./prompts.js\";\nimport { Requirement } from \"./requirements/requirement.js\";\nimport { RequirementAgentRunner } from \"./runner.js\";\nimport { ToolCallChecker, ToolCallCheckerConfig } from \"./utils/toolCallChecker.js\";\nimport { isDefined, isEmptyish, pickBy } from \"remeda\";\nimport { castArray } from \"@/internals/helpers/array.js\";\nimport type { RequiredExcept } from \"@/internals/types.js\";\n\nexport type RequirementAgentTemplateFactory<K extends keyof RequirementAgentTemplates> = (\n template: RequirementAgentTemplates[K],\n) => RequirementAgentTemplates[K];\n\nexport interface RequirementAgentInput {\n llm: ChatModel;\n memory?: BaseMemory;\n tools?: AnyTool[];\n requirements?: Requirement[];\n name?: string;\n description?: string;\n role?: string;\n instructions?: string | string[];\n notes?: string | string[];\n toolCallChecker?: boolean | ToolCallCheckerConfig;\n finalAnswerAsTool?: boolean;\n saveIntermediateSteps?: boolean;\n execution?: RequirementAgentExecutionConfig;\n templates?: Partial<{\n [K in keyof RequirementAgentTemplates]:\n | RequirementAgentTemplates[K]\n | RequirementAgentTemplateFactory<K>;\n }>;\n middlewares?: MiddlewareType<RequirementAgent>[];\n}\n\ntype InternalRequirementAgentInput = RequiredExcept<\n RequirementAgentInput,\n | \"role\"\n | \"instructions\"\n | \"name\"\n | \"description\"\n | \"templates\"\n | \"notes\"\n | \"execution\"\n | \"middlewares\"\n>;\n\n/**\n * RequirementAgent - A declarative AI agent with rule-based constraints\n *\n * The RequirementAgent provides predictable, controlled execution behavior across\n * different language models through rule-based constraints (Requirements).\n * Requirements can be configured as strict or flexible as necessary, adapting to\n * task requirements while ensuring consistent execution regardless of the underlying\n * model's reasoning or tool-calling capabilities.\n */\nexport class RequirementAgent extends BaseAgent<\n RequirementAgentRunInput,\n RequirementAgentOutput,\n RequirementAgentRunOptions\n> {\n public readonly emitter = Emitter.root.child<RequirementAgentCallbacks>({\n namespace: [\"agent\", \"requirement\"],\n creator: this,\n });\n\n protected readonly input: InternalRequirementAgentInput;\n\n protected runner: new (\n ...args: ConstructorParameters<typeof RequirementAgentRunner>\n ) => RequirementAgentRunner = RequirementAgentRunner;\n\n constructor(input: RequirementAgentInput) {\n super();\n this.input = {\n ...input,\n memory: input.memory || new UnconstrainedMemory(),\n tools: input.tools || [],\n requirements: input.requirements || [],\n saveIntermediateSteps: input.saveIntermediateSteps ?? true,\n finalAnswerAsTool: input.finalAnswerAsTool ?? true,\n toolCallChecker: input.toolCallChecker ?? true,\n };\n if (input.middlewares) {\n this.middlewares.push(...input.middlewares);\n }\n }\n\n static {\n this.register();\n }\n\n protected async _run(\n input: RequirementAgentRunInput,\n options: RequirementAgentRunOptions = {},\n run: GetRunContext<typeof this>,\n ): Promise<RequirementAgentOutput> {\n const execution: RequirementAgentExecutionConfig = {\n maxRetriesPerStep: 3,\n totalMaxRetries: 20,\n maxIterations: 20,\n ...this.input.execution,\n ...options.execution,\n };\n\n const toolCallChecker = this.createToolCallChecker();\n\n const runner = new this.runner(\n this.input.llm,\n execution,\n this.input.tools || [],\n this.input.requirements || [],\n input.expectedOutput || null,\n toolCallChecker,\n run,\n this.input.finalAnswerAsTool,\n this.templates,\n );\n\n // Process input messages\n const newMessages = this.processInput(input);\n await runner.addMessages([...this.memory.messages]);\n await runner.addMessages(newMessages);\n\n // Run the agent\n const finalState = await runner.run();\n\n // Update memory\n if (this.input.saveIntermediateSteps) {\n this.memory.reset();\n await this.memory.addMany(finalState.memory.messages);\n } else {\n await this.memory.addMany(newMessages);\n // Add last tool call pair\n const messages = finalState.memory.messages;\n const lastPair = messages.slice(-2);\n await this.memory.addMany(lastPair);\n }\n\n if (!finalState.answer) {\n throw new Error(\"Agent did not produce a final answer\");\n }\n\n return {\n result: finalState.answer,\n memory: finalState.memory,\n state: finalState,\n };\n }\n\n protected processInput(input: RequirementAgentRunInput): Message[] {\n if (!input.prompt) {\n return [];\n }\n\n const userMessage = new UserMessage(\n this.templates.task.render({\n prompt: input.prompt,\n context: input.context,\n expectedOutput: typeof input.expectedOutput === \"string\" ? input.expectedOutput : undefined,\n }),\n );\n\n return [userMessage];\n }\n\n protected createToolCallChecker(): ToolCallChecker {\n const config: ToolCallCheckerConfig = {};\n\n if (typeof this.input.toolCallChecker === \"object\") {\n Object.assign(config, this.input.toolCallChecker);\n }\n\n const checker = new ToolCallChecker(config);\n checker.enabled = this.input.toolCallChecker !== false;\n return checker;\n }\n\n get meta(): AgentMeta {\n const tools = this.input.tools || [];\n\n return {\n name: this.input.name ?? \"Requirement\",\n tools,\n description:\n this.input.description ??\n \"The RequirementAgent is a declarative AI agent implementation that provides predictable, \" +\n \"controlled execution behavior across different language models through rule-based constraints.\",\n ...(tools.length > 0 && {\n extraDescription: [\n `Tools that I can use to accomplish given task.`,\n ...tools.map((tool) => `Tool '${tool.name}': ${tool.description}.`),\n ].join(\"\\n\"),\n }),\n };\n }\n\n protected get templates(): RequirementAgentTemplates {\n const overrides = this.input.templates || {};\n const finalized = mapObj({\n system: RequirementAgentSystemPrompt,\n task: RequirementAgentTaskPrompt,\n toolError: RequirementAgentToolErrorPrompt,\n toolNoResult: RequirementAgentToolNoResultPrompt,\n } as RequirementAgentTemplates)((\n key,\n defaultTemplate: RequirementAgentTemplates[typeof key],\n ) => {\n const override = overrides[key] ?? defaultTemplate;\n if (override instanceof PromptTemplate) {\n return override;\n }\n return override(defaultTemplate) ?? defaultTemplate;\n });\n\n if (this.input.role || this.input.instructions || this.input.notes) {\n finalized.system.update({\n defaults: pickBy(\n {\n role: this.input.role,\n instructions: isEmptyish(this.input.instructions)\n ? undefined\n : castArray(this.input.instructions)\n .map((v) => `- ${v}`)\n .join(\"\\n\"),\n notes: isEmptyish(this.input.notes)\n ? undefined\n : castArray(this.input.notes)\n .map((v) => `- ${v}`)\n .join(\"\\n\"),\n },\n isDefined,\n ),\n });\n }\n\n return finalized;\n }\n\n createSnapshot() {\n return {\n ...super.createSnapshot(),\n input: shallowCopy(this.input),\n emitter: this.emitter,\n runner: this.runner,\n };\n }\n\n set memory(memory: BaseMemory) {\n this.input.memory = memory;\n }\n\n get memory(): BaseMemory {\n return this.input.memory!;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../src/agents/requirement/agent.ts"],"names":["RequirementAgent","BaseAgent","emitter","Emitter","root","child","namespace","creator","input","runner","RequirementAgentRunner","memory","UnconstrainedMemory","tools","requirements","saveIntermediateSteps","finalAnswerAsTool","toolCallChecker","middlewares","push","register","_run","options","run","execution","maxRetriesPerStep","totalMaxRetries","maxIterations","createToolCallChecker","llm","expectedOutput","templates","newMessages","processInput","addMessages","messages","finalState","reset","addMany","lastPair","slice","answer","Error","result","state","prompt","userMessage","UserMessage","task","render","context","undefined","config","Object","assign","checker","ToolCallChecker","enabled","meta","name","description","length","extraDescription","map","tool","join","overrides","finalized","mapObj","system","RequirementAgentSystemPrompt","RequirementAgentTaskPrompt","toolError","RequirementAgentToolErrorPrompt","toolNoResult","RequirementAgentToolNoResultPrompt","key","defaultTemplate","override","PromptTemplate","role","instructions","notes","update","defaults","pickBy","isEmptyish","castArray","v","isDefined","createSnapshot","shallowCopy"],"mappings":";;;;;;;;;;;;;;;;;AAqFO,MAAMA,yBAAyBC,kBAAAA,CAAAA;EArFtC;;;EA0FkBC,OAAAA,GAAUC,mBAAAA,CAAQC,KAAKC,KAAAA,CAAiC;IACtEC,SAAAA,EAAW;AAAC,MAAA,OAAA;AAAS,MAAA;;IACrBC,OAAAA,EAAS;GACX,CAAA;AAEmBC,EAAAA,KAAAA;EAETC,MAAAA,GAEoBC,iCAAAA;AAE9B,EAAA,WAAA,CAAYF,KAAAA,EAA8B;AACxC,IAAA,KAAA,EAAK;AACL,IAAA,IAAA,CAAKA,KAAAA,GAAQ;MACX,GAAGA,KAAAA;MACHG,MAAAA,EAAQH,KAAAA,CAAMG,MAAAA,IAAU,IAAIC,2CAAAA,EAAAA;MAC5BC,KAAAA,EAAOL,KAAAA,CAAMK,SAAS,EAAA;MACtBC,YAAAA,EAAcN,KAAAA,CAAMM,gBAAgB,EAAA;AACpCC,MAAAA,qBAAAA,EAAuBP,MAAMO,qBAAAA,IAAyB,IAAA;AACtDC,MAAAA,iBAAAA,EAAmBR,MAAMQ,iBAAAA,IAAqB,IAAA;AAC9CC,MAAAA,eAAAA,EAAiBT,MAAMS,eAAAA,IAAmB;AAC5C,KAAA;AACA,IAAA,IAAIT,MAAMU,WAAAA,EAAa;AACrB,MAAA,IAAA,CAAKA,WAAAA,CAAYC,IAAAA,CAAI,GAAIX,KAAAA,CAAMU,WAAW,CAAA;AAC5C,IAAA;AACF,EAAA;EAEA;AACE,IAAA,IAAA,CAAKE,QAAAA,EAAQ;AACf;AAEA,EAAA,MAAgBC,IAAAA,CACdb,KAAAA,EACAc,OAAAA,GAAsC,IACtCC,GAAAA,EACiC;AACjC,IAAA,MAAMC,SAAAA,GAA6C;MACjDC,iBAAAA,EAAmB,CAAA;MACnBC,eAAAA,EAAiB,EAAA;MACjBC,aAAAA,EAAe,EAAA;AACf,MAAA,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,CAAKH,MAAMG,MAAAA,GAASA,MAAAA;AACtB,EAAA;AAEA,EAAA,IAAIA,MAAAA,GAAqB;AACvB,IAAA,OAAO,KAAKH,KAAAA,CAAMG,MAAAA;AACpB,EAAA;AACF","file":"agent.cjs","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BaseAgent } from \"@/agents/base.js\";\nimport { AnyTool } from \"@/tools/base.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { AgentMeta } from \"@/agents/types.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\nimport { ChatModel } from \"@/backend/chat.js\";\nimport type { GetRunContext, MiddlewareType } from \"@/context.js\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { Message, UserMessage } from \"@/backend/message.js\";\nimport { shallowCopy } from \"@/serializer/utils.js\";\nimport { mapObj } from \"@/internals/helpers/object.js\";\nimport { PromptTemplate } from \"@/template.js\";\nimport {\n RequirementAgentCallbacks,\n RequirementAgentExecutionConfig,\n RequirementAgentOutput,\n RequirementAgentRunInput,\n RequirementAgentRunOptions,\n RequirementAgentTemplates,\n} from \"./types.js\";\nimport {\n RequirementAgentSystemPrompt,\n RequirementAgentTaskPrompt,\n RequirementAgentToolErrorPrompt,\n RequirementAgentToolNoResultPrompt,\n} from \"./prompts.js\";\nimport { Requirement } from \"./requirements/requirement.js\";\nimport { RequirementAgentRunner } from \"./runner.js\";\nimport { ToolCallChecker, ToolCallCheckerConfig } from \"./utils/toolCallChecker.js\";\nimport { isDefined, isEmptyish, pickBy } from \"remeda\";\nimport { castArray } from \"@/internals/helpers/array.js\";\nimport type { RequiredExcept } from \"@/internals/types.js\";\n\nexport type RequirementAgentTemplateFactory<K extends keyof RequirementAgentTemplates> = (\n template: RequirementAgentTemplates[K],\n) => RequirementAgentTemplates[K];\n\nexport interface RequirementAgentInput {\n llm: ChatModel;\n memory?: BaseMemory;\n tools?: AnyTool[];\n requirements?: Requirement[];\n name?: string;\n description?: string;\n role?: string;\n instructions?: string | string[];\n notes?: string | string[];\n toolCallChecker?: boolean | ToolCallCheckerConfig;\n finalAnswerAsTool?: boolean;\n saveIntermediateSteps?: boolean;\n execution?: RequirementAgentExecutionConfig;\n templates?: Partial<{\n [K in keyof RequirementAgentTemplates]:\n | RequirementAgentTemplates[K]\n | RequirementAgentTemplateFactory<K>;\n }>;\n middlewares?: MiddlewareType<RequirementAgent>[];\n}\n\ntype InternalRequirementAgentInput = RequiredExcept<\n RequirementAgentInput,\n | \"role\"\n | \"instructions\"\n | \"name\"\n | \"description\"\n | \"templates\"\n | \"notes\"\n | \"execution\"\n | \"middlewares\"\n>;\n\n/**\n * RequirementAgent - A declarative AI agent with rule-based constraints\n *\n * The RequirementAgent provides predictable, controlled execution behavior across\n * different language models through rule-based constraints (Requirements).\n * Requirements can be configured as strict or flexible as necessary, adapting to\n * task requirements while ensuring consistent execution regardless of the underlying\n * model's reasoning or tool-calling capabilities.\n */\nexport class RequirementAgent extends BaseAgent<\n RequirementAgentRunInput,\n RequirementAgentOutput,\n RequirementAgentRunOptions\n> {\n public readonly emitter = Emitter.root.child<RequirementAgentCallbacks>({\n namespace: [\"agent\", \"requirement\"],\n creator: this,\n });\n\n protected readonly input: InternalRequirementAgentInput;\n\n protected runner: new (\n ...args: ConstructorParameters<typeof RequirementAgentRunner>\n ) => RequirementAgentRunner = RequirementAgentRunner;\n\n constructor(input: RequirementAgentInput) {\n super();\n this.input = {\n ...input,\n memory: input.memory || new UnconstrainedMemory(),\n tools: input.tools || [],\n requirements: input.requirements || [],\n saveIntermediateSteps: input.saveIntermediateSteps ?? true,\n finalAnswerAsTool: input.finalAnswerAsTool ?? true,\n toolCallChecker: input.toolCallChecker ?? true,\n };\n if (input.middlewares) {\n this.middlewares.push(...input.middlewares);\n }\n }\n\n static {\n this.register();\n }\n\n protected async _run(\n input: RequirementAgentRunInput,\n options: RequirementAgentRunOptions = {},\n run: GetRunContext<typeof this>,\n ): Promise<RequirementAgentOutput> {\n const execution: RequirementAgentExecutionConfig = {\n maxRetriesPerStep: 3,\n totalMaxRetries: 20,\n maxIterations: 20,\n ...this.input.execution,\n ...options.execution,\n };\n\n const toolCallChecker = this.createToolCallChecker();\n\n const runner = new this.runner(\n this.input.llm,\n execution,\n this.input.tools || [],\n this.input.requirements || [],\n input.expectedOutput || null,\n toolCallChecker,\n run,\n this.input.finalAnswerAsTool,\n this.templates,\n );\n\n // Process input messages\n const newMessages = this.processInput(input);\n await runner.addMessages([...this.memory.messages]);\n await runner.addMessages(newMessages);\n\n // Run the agent\n const finalState = await runner.run();\n\n // Update memory\n if (this.input.saveIntermediateSteps) {\n this.memory.reset();\n await this.memory.addMany(finalState.memory.messages);\n } else {\n await this.memory.addMany(newMessages);\n // Add last tool call pair\n const messages = finalState.memory.messages;\n const lastPair = messages.slice(-2);\n await this.memory.addMany(lastPair);\n }\n\n if (!finalState.answer) {\n throw new Error(\"Agent did not produce a final answer\");\n }\n\n return {\n result: finalState.answer,\n memory: finalState.memory,\n state: finalState,\n };\n }\n\n protected processInput(input: RequirementAgentRunInput): Message[] {\n if (!input.prompt) {\n return [];\n }\n\n const userMessage = new UserMessage(\n this.templates.task.render({\n prompt: input.prompt,\n context: input.context,\n expectedOutput: typeof input.expectedOutput === \"string\" ? input.expectedOutput : undefined,\n }),\n );\n\n return [userMessage];\n }\n\n protected createToolCallChecker(): ToolCallChecker {\n const config: ToolCallCheckerConfig = {};\n\n if (typeof this.input.toolCallChecker === \"object\") {\n Object.assign(config, this.input.toolCallChecker);\n }\n\n const checker = new ToolCallChecker(config);\n checker.enabled = this.input.toolCallChecker !== false;\n return checker;\n }\n\n get meta(): AgentMeta {\n const tools = this.input.tools || [];\n\n return {\n name: this.input.name ?? \"Requirement\",\n tools,\n description:\n this.input.description ??\n \"The RequirementAgent is a declarative AI agent implementation that provides predictable, \" +\n \"controlled execution behavior across different language models through rule-based constraints.\",\n ...(tools.length > 0 && {\n extraDescription: [\n `Tools that I can use to accomplish given task.`,\n ...tools.map((tool) => `Tool '${tool.name}': ${tool.description}.`),\n ].join(\"\\n\"),\n }),\n };\n }\n\n protected get templates(): RequirementAgentTemplates {\n const overrides = this.input.templates || {};\n const finalized = mapObj({\n system: RequirementAgentSystemPrompt,\n task: RequirementAgentTaskPrompt,\n toolError: RequirementAgentToolErrorPrompt,\n toolNoResult: RequirementAgentToolNoResultPrompt,\n } as RequirementAgentTemplates)((\n key,\n defaultTemplate: RequirementAgentTemplates[typeof key],\n ) => {\n const override = overrides[key] ?? defaultTemplate;\n if (override instanceof PromptTemplate) {\n return override;\n }\n return override(defaultTemplate) ?? defaultTemplate;\n });\n\n if (this.input.role || this.input.instructions || this.input.notes) {\n finalized.system.update({\n defaults: pickBy(\n {\n role: this.input.role,\n instructions: isEmptyish(this.input.instructions)\n ? undefined\n : castArray(this.input.instructions)\n .map((v) => `- ${v}`)\n .join(\"\\n\"),\n notes: isEmptyish(this.input.notes)\n ? undefined\n : castArray(this.input.notes)\n .map((v) => `- ${v}`)\n .join(\"\\n\"),\n },\n isDefined,\n ),\n });\n }\n\n return finalized;\n }\n\n createSnapshot() {\n return {\n ...super.createSnapshot(),\n input: shallowCopy(this.input),\n emitter: this.emitter,\n runner: this.runner,\n };\n }\n\n set memory(memory: BaseMemory) {\n this.input.memory = memory;\n }\n\n get memory(): BaseMemory {\n return this.input.memory!;\n }\n}\n"]}
@@ -1,14 +1,14 @@
1
1
  import '../../context.cjs';
2
2
  import 'zod';
3
- import '../../base-XfWeXQ-S.cjs';
3
+ import '../../base-s3ioVIE9.cjs';
4
4
  import '../../tools/base.cjs';
5
5
  import '../../memory/base.cjs';
6
- import '../../emitter-jN55XZZq.cjs';
7
- import '../../chat-BFl85cqt.cjs';
6
+ import '../../emitter-D4OcelZ9.cjs';
7
+ import '../../chat-C20nYj46.cjs';
8
8
  import '../../backend/message.cjs';
9
- import '../../types-CkEtV8R9.cjs';
9
+ import '../../types-BNsa3W7Z.cjs';
10
10
  import './requirements/requirement.cjs';
11
- export { b as RequirementAgent, a as RequirementAgentInput, R as RequirementAgentTemplateFactory } from './runner.cjs';
11
+ export { R as RequirementAgent, a as RequirementAgentInput, b as RequirementAgentTemplateFactory } from './runner.cjs';
12
12
  import './utils/toolCallChecker.cjs';
13
13
  import '../../internals/types.cjs';
14
14
  import '../../internals/serializable.cjs';
@@ -1,14 +1,14 @@
1
1
  import '../../context.js';
2
2
  import 'zod';
3
- import '../../base-CyFx7BRL.js';
3
+ import '../../base-BjzyQ8k6.js';
4
4
  import '../../tools/base.js';
5
5
  import '../../memory/base.js';
6
- import '../../emitter-36-9MnvA.js';
7
- import '../../chat-BRuyDeKR.js';
6
+ import '../../emitter-kHxkUxco.js';
7
+ import '../../chat-CfTNfR60.js';
8
8
  import '../../backend/message.js';
9
- import '../../types-BQ-3LdkE.js';
9
+ import '../../types-DYtzF6ya.js';
10
10
  import './requirements/requirement.js';
11
- export { b as RequirementAgent, a as RequirementAgentInput, R as RequirementAgentTemplateFactory } from './runner.js';
11
+ export { R as RequirementAgent, a as RequirementAgentInput, b as RequirementAgentTemplateFactory } from './runner.js';
12
12
  import './utils/toolCallChecker.js';
13
13
  import '../../internals/types.js';
14
14
  import '../../internals/serializable.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/agents/requirement/agent.ts"],"names":["RequirementAgent","BaseAgent","emitter","Emitter","root","child","namespace","creator","input","runner","RequirementAgentRunner","memory","UnconstrainedMemory","tools","requirements","saveIntermediateSteps","finalAnswerAsTool","toolCallChecker","middlewares","push","register","_run","options","run","execution","maxRetriesPerStep","totalMaxRetries","maxIterations","createToolCallChecker","llm","expectedOutput","templates","newMessages","processInput","addMessages","messages","finalState","reset","addMany","lastPair","slice","answer","Error","result","state","prompt","userMessage","UserMessage","task","render","context","undefined","config","Object","assign","checker","ToolCallChecker","enabled","meta","name","description","length","extraDescription","map","tool","join","overrides","finalized","mapObj","system","RequirementAgentSystemPrompt","RequirementAgentTaskPrompt","toolError","RequirementAgentToolErrorPrompt","toolNoResult","RequirementAgentToolNoResultPrompt","key","defaultTemplate","override","PromptTemplate","role","instructions","notes","update","defaults","pickBy","isEmptyish","castArray","v","isDefined","createSnapshot","shallowCopy"],"mappings":";;;;;;;;;;;;;;;AAqFO,MAAMA,yBAAyBC,SAAAA,CAAAA;EArFtC;;;EA0FkBC,OAAAA,GAAUC,OAAAA,CAAQC,KAAKC,KAAAA,CAAiC;IACtEC,SAAAA,EAAW;AAAC,MAAA,OAAA;AAAS,MAAA;;IACrBC,OAAAA,EAAS;GACX,CAAA;AAEmBC,EAAAA,KAAAA;EAETC,MAAAA,GAEoBC,sBAAAA;AAE9B,EAAA,WAAA,CAAYF,KAAAA,EAA8B;AACxC,IAAA,KAAA,EAAK;AACL,IAAA,IAAA,CAAKA,KAAAA,GAAQ;MACX,GAAGA,KAAAA;MACHG,MAAAA,EAAQH,KAAAA,CAAMG,MAAAA,IAAU,IAAIC,mBAAAA,EAAAA;MAC5BC,KAAAA,EAAOL,KAAAA,CAAMK,SAAS,EAAA;MACtBC,YAAAA,EAAcN,KAAAA,CAAMM,gBAAgB,EAAA;AACpCC,MAAAA,qBAAAA,EAAuBP,MAAMO,qBAAAA,IAAyB,IAAA;AACtDC,MAAAA,iBAAAA,EAAmBR,MAAMQ,iBAAAA,IAAqB,IAAA;AAC9CC,MAAAA,eAAAA,EAAiBT,MAAMS,eAAAA,IAAmB;AAC5C,KAAA;AACA,IAAA,IAAIT,MAAMU,WAAAA,EAAa;AACrB,MAAA,IAAA,CAAKA,WAAAA,CAAYC,IAAAA,CAAI,GAAIX,KAAAA,CAAMU,WAAW,CAAA;AAC5C;AACF;EAEA;AACE,IAAA,IAAA,CAAKE,QAAAA,EAAQ;AACf;AAEA,EAAA,MAAgBC,IAAAA,CACdb,KAAAA,EACAc,OAAAA,GAAsC,IACtCC,GAAAA,EACiC;AACjC,IAAA,MAAMC,SAAAA,GAA6C;MACjDC,iBAAAA,EAAmB,CAAA;MACnBC,e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B;AAEA,EAAA,IAAIA,MAAAA,GAAqB;AACvB,IAAA,OAAO,KAAKH,KAAAA,CAAMG,MAAAA;AACpB;AACF","file":"agent.js","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BaseAgent } from \"@/agents/base.js\";\nimport { AnyTool } from \"@/tools/base.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { AgentMeta } from \"@/agents/types.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\nimport { ChatModel } from \"@/backend/chat.js\";\nimport type { GetRunContext, MiddlewareType } from \"@/context.js\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { Message, UserMessage } from \"@/backend/message.js\";\nimport { shallowCopy } from \"@/serializer/utils.js\";\nimport { mapObj } from \"@/internals/helpers/object.js\";\nimport { PromptTemplate } from \"@/template.js\";\nimport {\n RequirementAgentCallbacks,\n RequirementAgentExecutionConfig,\n RequirementAgentOutput,\n RequirementAgentRunInput,\n RequirementAgentRunOptions,\n RequirementAgentTemplates,\n} from \"./types.js\";\nimport {\n RequirementAgentSystemPrompt,\n RequirementAgentTaskPrompt,\n RequirementAgentToolErrorPrompt,\n RequirementAgentToolNoResultPrompt,\n} from \"./prompts.js\";\nimport { Requirement } from \"./requirements/requirement.js\";\nimport { RequirementAgentRunner } from \"./runner.js\";\nimport { ToolCallChecker, ToolCallCheckerConfig } from \"./utils/toolCallChecker.js\";\nimport { isDefined, isEmptyish, pickBy } from \"remeda\";\nimport { castArray } from \"@/internals/helpers/array.js\";\nimport type { RequiredExcept } from \"@/internals/types.js\";\n\nexport type RequirementAgentTemplateFactory<K extends keyof RequirementAgentTemplates> = (\n template: RequirementAgentTemplates[K],\n) => RequirementAgentTemplates[K];\n\nexport interface RequirementAgentInput {\n llm: ChatModel;\n memory?: BaseMemory;\n tools?: AnyTool[];\n requirements?: Requirement[];\n name?: string;\n description?: string;\n role?: string;\n instructions?: string | string[];\n notes?: string | string[];\n toolCallChecker?: boolean | ToolCallCheckerConfig;\n finalAnswerAsTool?: boolean;\n saveIntermediateSteps?: boolean;\n execution?: RequirementAgentExecutionConfig;\n templates?: Partial<{\n [K in keyof RequirementAgentTemplates]:\n | RequirementAgentTemplates[K]\n | RequirementAgentTemplateFactory<K>;\n }>;\n middlewares?: MiddlewareType<RequirementAgent>[];\n}\n\ntype InternalRequirementAgentInput = RequiredExcept<\n RequirementAgentInput,\n | \"role\"\n | \"instructions\"\n | \"name\"\n | \"description\"\n | \"templates\"\n | \"notes\"\n | \"execution\"\n | \"middlewares\"\n>;\n\n/**\n * RequirementAgent - A declarative AI agent with rule-based constraints\n *\n * The RequirementAgent provides predictable, controlled execution behavior across\n * different language models through rule-based constraints (Requirements).\n * Requirements can be configured as strict or flexible as necessary, adapting to\n * task requirements while ensuring consistent execution regardless of the underlying\n * model's reasoning or tool-calling capabilities.\n */\nexport class RequirementAgent extends BaseAgent<\n RequirementAgentRunInput,\n RequirementAgentOutput,\n RequirementAgentRunOptions\n> {\n public readonly emitter = Emitter.root.child<RequirementAgentCallbacks>({\n namespace: [\"agent\", \"requirement\"],\n creator: this,\n });\n\n protected readonly input: InternalRequirementAgentInput;\n\n protected runner: new (\n ...args: ConstructorParameters<typeof RequirementAgentRunner>\n ) => RequirementAgentRunner = RequirementAgentRunner;\n\n constructor(input: RequirementAgentInput) {\n super();\n this.input = {\n ...input,\n memory: input.memory || new UnconstrainedMemory(),\n tools: input.tools || [],\n requirements: input.requirements || [],\n saveIntermediateSteps: input.saveIntermediateSteps ?? true,\n finalAnswerAsTool: input.finalAnswerAsTool ?? true,\n toolCallChecker: input.toolCallChecker ?? true,\n };\n if (input.middlewares) {\n this.middlewares.push(...input.middlewares);\n }\n }\n\n static {\n this.register();\n }\n\n protected async _run(\n input: RequirementAgentRunInput,\n options: RequirementAgentRunOptions = {},\n run: GetRunContext<typeof this>,\n ): Promise<RequirementAgentOutput> {\n const execution: RequirementAgentExecutionConfig = {\n maxRetriesPerStep: 3,\n totalMaxRetries: 20,\n maxIterations: 20,\n ...this.input.execution,\n ...options.execution,\n };\n\n const toolCallChecker = this.createToolCallChecker();\n\n const runner = new this.runner(\n this.input.llm,\n execution,\n this.input.tools || [],\n this.input.requirements || [],\n input.expectedOutput || null,\n toolCallChecker,\n run,\n this.input.finalAnswerAsTool,\n this.templates,\n );\n\n // Process input messages\n const newMessages = this.processInput(input);\n await runner.addMessages([...this.memory.messages]);\n await runner.addMessages(newMessages);\n\n // Run the agent\n const finalState = await runner.run();\n\n // Update memory\n if (this.input.saveIntermediateSteps) {\n this.memory.reset();\n await this.memory.addMany(finalState.memory.messages);\n } else {\n await this.memory.addMany(newMessages);\n // Add last tool call pair\n const messages = finalState.memory.messages;\n const lastPair = messages.slice(-2);\n await this.memory.addMany(lastPair);\n }\n\n if (!finalState.answer) {\n throw new Error(\"Agent did not produce a final answer\");\n }\n\n return {\n result: finalState.answer,\n memory: finalState.memory,\n state: finalState,\n };\n }\n\n protected processInput(input: RequirementAgentRunInput): Message[] {\n if (!input.prompt) {\n return [];\n }\n\n const userMessage = new UserMessage(\n this.templates.task.render({\n prompt: input.prompt,\n context: input.context,\n expectedOutput: typeof input.expectedOutput === \"string\" ? input.expectedOutput : undefined,\n }),\n );\n\n return [userMessage];\n }\n\n protected createToolCallChecker(): ToolCallChecker {\n const config: ToolCallCheckerConfig = {};\n\n if (typeof this.input.toolCallChecker === \"object\") {\n Object.assign(config, this.input.toolCallChecker);\n }\n\n const checker = new ToolCallChecker(config);\n checker.enabled = this.input.toolCallChecker !== false;\n return checker;\n }\n\n get meta(): AgentMeta {\n const tools = this.input.tools || [];\n\n return {\n name: this.input.name ?? \"Requirement\",\n tools,\n description:\n this.input.description ??\n \"The RequirementAgent is a declarative AI agent implementation that provides predictable, \" +\n \"controlled execution behavior across different language models through rule-based constraints.\",\n ...(tools.length > 0 && {\n extraDescription: [\n `Tools that I can use to accomplish given task.`,\n ...tools.map((tool) => `Tool '${tool.name}': ${tool.description}.`),\n ].join(\"\\n\"),\n }),\n };\n }\n\n protected get templates(): RequirementAgentTemplates {\n const overrides = this.input.templates || {};\n const finalized = mapObj({\n system: RequirementAgentSystemPrompt,\n task: RequirementAgentTaskPrompt,\n toolError: RequirementAgentToolErrorPrompt,\n toolNoResult: RequirementAgentToolNoResultPrompt,\n } as RequirementAgentTemplates)((\n key,\n defaultTemplate: RequirementAgentTemplates[typeof key],\n ) => {\n const override = overrides[key] ?? defaultTemplate;\n if (override instanceof PromptTemplate) {\n return override;\n }\n return override(defaultTemplate) ?? defaultTemplate;\n });\n\n if (this.input.role || this.input.instructions || this.input.notes) {\n finalized.system.update({\n defaults: pickBy(\n {\n role: this.input.role,\n instructions: isEmptyish(this.input.instructions)\n ? undefined\n : castArray(this.input.instructions)\n .map((v) => `- ${v}`)\n .join(\"\\n\"),\n notes: isEmptyish(this.input.notes)\n ? undefined\n : castArray(this.input.notes)\n .map((v) => `- ${v}`)\n .join(\"\\n\"),\n },\n isDefined,\n ),\n });\n }\n\n return finalized;\n }\n\n createSnapshot() {\n return {\n ...super.createSnapshot(),\n input: shallowCopy(this.input),\n emitter: this.emitter,\n runner: this.runner,\n };\n }\n\n set memory(memory: BaseMemory) {\n this.input.memory = memory;\n }\n\n get memory(): BaseMemory {\n return this.input.memory!;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../src/agents/requirement/agent.ts"],"names":["RequirementAgent","BaseAgent","emitter","Emitter","root","child","namespace","creator","input","runner","RequirementAgentRunner","memory","UnconstrainedMemory","tools","requirements","saveIntermediateSteps","finalAnswerAsTool","toolCallChecker","middlewares","push","register","_run","options","run","execution","maxRetriesPerStep","totalMaxRetries","maxIterations","createToolCallChecker","llm","expectedOutput","templates","newMessages","processInput","addMessages","messages","finalState","reset","addMany","lastPair","slice","answer","Error","result","state","prompt","userMessage","UserMessage","task","render","context","undefined","config","Object","assign","checker","ToolCallChecker","enabled","meta","name","description","length","extraDescription","map","tool","join","overrides","finalized","mapObj","system","RequirementAgentSystemPrompt","RequirementAgentTaskPrompt","toolError","RequirementAgentToolErrorPrompt","toolNoResult","RequirementAgentToolNoResultPrompt","key","defaultTemplate","override","PromptTemplate","role","instructions","notes","update","defaults","pickBy","isEmptyish","castArray","v","isDefined","createSnapshot","shallowCopy"],"mappings":";;;;;;;;;;;;;;;AAqFO,MAAMA,yBAAyBC,SAAAA,CAAAA;EArFtC;;;EA0FkBC,OAAAA,GAAUC,OAAAA,CAAQC,KAAKC,KAAAA,CAAiC;IACtEC,SAAAA,EAAW;AAAC,MAAA,OAAA;AAAS,MAAA;;IACrBC,OAAAA,EAAS;GACX,CAAA;AAEmBC,EAAAA,KAAAA;EAETC,MAAAA,GAEoBC,sBAAAA;AAE9B,EAAA,WAAA,CAAYF,KAAAA,EAA8B;AACxC,IAAA,KAAA,EAAK;AACL,IAAA,IAAA,CAAKA,KAAAA,GAAQ;MACX,GAAGA,KAAAA;MACHG,MAAAA,EAAQH,KAAAA,CAAMG,MAAAA,IAAU,IAAIC,mBAAAA,EAAAA;MAC5BC,KAAAA,EAAOL,KAAAA,CAAMK,SAAS,EAAA;MACtBC,YAAAA,EAAcN,KAAAA,CAAMM,gBAAgB,EAAA;AACpCC,MAAAA,qBAAAA,EAAuBP,MAAMO,qBAAAA,IAAyB,IAAA;AACtDC,MAAAA,iBAAAA,EAAmBR,MAAMQ,iBAAAA,IAAqB,IAAA;AAC9CC,MAAAA,eAAAA,EAAiBT,MAAMS,eAAAA,IAAmB;AAC5C,KAAA;AACA,IAAA,IAAIT,MAAMU,WAAAA,EAAa;AACrB,MAAA,IAAA,CAAKA,WAAAA,CAAYC,IAAAA,CAAI,GAAIX,KAAAA,CAAMU,WAAW,CAAA;AAC5C,IAAA;AACF,EAAA;EAEA;AACE,IAAA,IAAA,CAAKE,QAAAA,EAAQ;AACf;AAEA,EAAA,MAAgBC,IAAAA,CACdb,KAAAA,EACAc,OAAAA,GAAsC,IACtCC,GAAAA,EACiC;AACjC,IAAA,MAAMC,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,IAAA,CAAKA;AACf,KAAA;AACF,EAAA;AAEA,EAAA,IAAIE,OAAOA,MAAAA,EAAoB;AAC7B,IAAA,IAAA,CAAKH,MAAMG,MAAAA,GAASA,MAAAA;AACtB,EAAA;AAEA,EAAA,IAAIA,MAAAA,GAAqB;AACvB,IAAA,OAAO,KAAKH,KAAAA,CAAMG,MAAAA;AACpB,EAAA;AACF","file":"agent.js","sourcesContent":["/**\n * Copyright 2025 © BeeAI a Series of LF Projects, LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BaseAgent } from \"@/agents/base.js\";\nimport { AnyTool } from \"@/tools/base.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { AgentMeta } from \"@/agents/types.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\nimport { ChatModel } from \"@/backend/chat.js\";\nimport type { GetRunContext, MiddlewareType } from \"@/context.js\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { Message, UserMessage } from \"@/backend/message.js\";\nimport { shallowCopy } from \"@/serializer/utils.js\";\nimport { mapObj } from \"@/internals/helpers/object.js\";\nimport { PromptTemplate } from \"@/template.js\";\nimport {\n RequirementAgentCallbacks,\n RequirementAgentExecutionConfig,\n RequirementAgentOutput,\n RequirementAgentRunInput,\n RequirementAgentRunOptions,\n RequirementAgentTemplates,\n} from \"./types.js\";\nimport {\n RequirementAgentSystemPrompt,\n RequirementAgentTaskPrompt,\n RequirementAgentToolErrorPrompt,\n RequirementAgentToolNoResultPrompt,\n} from \"./prompts.js\";\nimport { Requirement } from \"./requirements/requirement.js\";\nimport { RequirementAgentRunner } from \"./runner.js\";\nimport { ToolCallChecker, ToolCallCheckerConfig } from \"./utils/toolCallChecker.js\";\nimport { isDefined, isEmptyish, pickBy } from \"remeda\";\nimport { castArray } from \"@/internals/helpers/array.js\";\nimport type { RequiredExcept } from \"@/internals/types.js\";\n\nexport type RequirementAgentTemplateFactory<K extends keyof RequirementAgentTemplates> = (\n template: RequirementAgentTemplates[K],\n) => RequirementAgentTemplates[K];\n\nexport interface RequirementAgentInput {\n llm: ChatModel;\n memory?: BaseMemory;\n tools?: AnyTool[];\n requirements?: Requirement[];\n name?: string;\n description?: string;\n role?: string;\n instructions?: string | string[];\n notes?: string | string[];\n toolCallChecker?: boolean | ToolCallCheckerConfig;\n finalAnswerAsTool?: boolean;\n saveIntermediateSteps?: boolean;\n execution?: RequirementAgentExecutionConfig;\n templates?: Partial<{\n [K in keyof RequirementAgentTemplates]:\n | RequirementAgentTemplates[K]\n | RequirementAgentTemplateFactory<K>;\n }>;\n middlewares?: MiddlewareType<RequirementAgent>[];\n}\n\ntype InternalRequirementAgentInput = RequiredExcept<\n RequirementAgentInput,\n | \"role\"\n | \"instructions\"\n | \"name\"\n | \"description\"\n | \"templates\"\n | \"notes\"\n | \"execution\"\n | \"middlewares\"\n>;\n\n/**\n * RequirementAgent - A declarative AI agent with rule-based constraints\n *\n * The RequirementAgent provides predictable, controlled execution behavior across\n * different language models through rule-based constraints (Requirements).\n * Requirements can be configured as strict or flexible as necessary, adapting to\n * task requirements while ensuring consistent execution regardless of the underlying\n * model's reasoning or tool-calling capabilities.\n */\nexport class RequirementAgent extends BaseAgent<\n RequirementAgentRunInput,\n RequirementAgentOutput,\n RequirementAgentRunOptions\n> {\n public readonly emitter = Emitter.root.child<RequirementAgentCallbacks>({\n namespace: [\"agent\", \"requirement\"],\n creator: this,\n });\n\n protected readonly input: InternalRequirementAgentInput;\n\n protected runner: new (\n ...args: ConstructorParameters<typeof RequirementAgentRunner>\n ) => RequirementAgentRunner = RequirementAgentRunner;\n\n constructor(input: RequirementAgentInput) {\n super();\n this.input = {\n ...input,\n memory: input.memory || new UnconstrainedMemory(),\n tools: input.tools || [],\n requirements: input.requirements || [],\n saveIntermediateSteps: input.saveIntermediateSteps ?? true,\n finalAnswerAsTool: input.finalAnswerAsTool ?? true,\n toolCallChecker: input.toolCallChecker ?? true,\n };\n if (input.middlewares) {\n this.middlewares.push(...input.middlewares);\n }\n }\n\n static {\n this.register();\n }\n\n protected async _run(\n input: RequirementAgentRunInput,\n options: RequirementAgentRunOptions = {},\n run: GetRunContext<typeof this>,\n ): Promise<RequirementAgentOutput> {\n const execution: RequirementAgentExecutionConfig = {\n maxRetriesPerStep: 3,\n totalMaxRetries: 20,\n maxIterations: 20,\n ...this.input.execution,\n ...options.execution,\n };\n\n const toolCallChecker = this.createToolCallChecker();\n\n const runner = new this.runner(\n this.input.llm,\n execution,\n this.input.tools || [],\n this.input.requirements || [],\n input.expectedOutput || null,\n toolCallChecker,\n run,\n this.input.finalAnswerAsTool,\n this.templates,\n );\n\n // Process input messages\n const newMessages = this.processInput(input);\n await runner.addMessages([...this.memory.messages]);\n await runner.addMessages(newMessages);\n\n // Run the agent\n const finalState = await runner.run();\n\n // Update memory\n if (this.input.saveIntermediateSteps) {\n this.memory.reset();\n await this.memory.addMany(finalState.memory.messages);\n } else {\n await this.memory.addMany(newMessages);\n // Add last tool call pair\n const messages = finalState.memory.messages;\n const lastPair = messages.slice(-2);\n await this.memory.addMany(lastPair);\n }\n\n if (!finalState.answer) {\n throw new Error(\"Agent did not produce a final answer\");\n }\n\n return {\n result: finalState.answer,\n memory: finalState.memory,\n state: finalState,\n };\n }\n\n protected processInput(input: RequirementAgentRunInput): Message[] {\n if (!input.prompt) {\n return [];\n }\n\n const userMessage = new UserMessage(\n this.templates.task.render({\n prompt: input.prompt,\n context: input.context,\n expectedOutput: typeof input.expectedOutput === \"string\" ? input.expectedOutput : undefined,\n }),\n );\n\n return [userMessage];\n }\n\n protected createToolCallChecker(): ToolCallChecker {\n const config: ToolCallCheckerConfig = {};\n\n if (typeof this.input.toolCallChecker === \"object\") {\n Object.assign(config, this.input.toolCallChecker);\n }\n\n const checker = new ToolCallChecker(config);\n checker.enabled = this.input.toolCallChecker !== false;\n return checker;\n }\n\n get meta(): AgentMeta {\n const tools = this.input.tools || [];\n\n return {\n name: this.input.name ?? \"Requirement\",\n tools,\n description:\n this.input.description ??\n \"The RequirementAgent is a declarative AI agent implementation that provides predictable, \" +\n \"controlled execution behavior across different language models through rule-based constraints.\",\n ...(tools.length > 0 && {\n extraDescription: [\n `Tools that I can use to accomplish given task.`,\n ...tools.map((tool) => `Tool '${tool.name}': ${tool.description}.`),\n ].join(\"\\n\"),\n }),\n };\n }\n\n protected get templates(): RequirementAgentTemplates {\n const overrides = this.input.templates || {};\n const finalized = mapObj({\n system: RequirementAgentSystemPrompt,\n task: RequirementAgentTaskPrompt,\n toolError: RequirementAgentToolErrorPrompt,\n toolNoResult: RequirementAgentToolNoResultPrompt,\n } as RequirementAgentTemplates)((\n key,\n defaultTemplate: RequirementAgentTemplates[typeof key],\n ) => {\n const override = overrides[key] ?? defaultTemplate;\n if (override instanceof PromptTemplate) {\n return override;\n }\n return override(defaultTemplate) ?? defaultTemplate;\n });\n\n if (this.input.role || this.input.instructions || this.input.notes) {\n finalized.system.update({\n defaults: pickBy(\n {\n role: this.input.role,\n instructions: isEmptyish(this.input.instructions)\n ? undefined\n : castArray(this.input.instructions)\n .map((v) => `- ${v}`)\n .join(\"\\n\"),\n notes: isEmptyish(this.input.notes)\n ? undefined\n : castArray(this.input.notes)\n .map((v) => `- ${v}`)\n .join(\"\\n\"),\n },\n isDefined,\n ),\n });\n }\n\n return finalized;\n }\n\n createSnapshot() {\n return {\n ...super.createSnapshot(),\n input: shallowCopy(this.input),\n emitter: this.emitter,\n runner: this.runner,\n };\n }\n\n set memory(memory: BaseMemory) {\n this.input.memory = memory;\n }\n\n get memory(): BaseMemory {\n return this.input.memory!;\n }\n}\n"]}
@@ -20,24 +20,24 @@ declare const RequirementAgentSystemPrompt: PromptTemplate<zod.ZodObject<{
20
20
  allowed: zod.ZodString;
21
21
  reason: zod.ZodOptional<zod.ZodString>;
22
22
  }, "strip", zod.ZodTypeAny, {
23
- inputSchema: string;
24
- description: string;
25
23
  name: string;
24
+ description: string;
25
+ inputSchema: string;
26
26
  allowed: string;
27
27
  reason?: string | undefined;
28
28
  }, {
29
- inputSchema: string;
30
- description: string;
31
29
  name: string;
30
+ description: string;
31
+ inputSchema: string;
32
32
  allowed: string;
33
33
  reason?: string | undefined;
34
34
  }>, "many">;
35
35
  }, "strip", zod.ZodTypeAny, {
36
36
  finalAnswerName: string;
37
37
  tools: {
38
- inputSchema: string;
39
- description: string;
40
38
  name: string;
39
+ description: string;
40
+ inputSchema: string;
41
41
  allowed: string;
42
42
  reason?: string | undefined;
43
43
  }[];
@@ -49,9 +49,9 @@ declare const RequirementAgentSystemPrompt: PromptTemplate<zod.ZodObject<{
49
49
  }, {
50
50
  finalAnswerName: string;
51
51
  tools: {
52
- inputSchema: string;
53
- description: string;
54
52
  name: string;
53
+ description: string;
54
+ inputSchema: string;
55
55
  allowed: string;
56
56
  reason?: string | undefined;
57
57
  }[];
@@ -20,24 +20,24 @@ declare const RequirementAgentSystemPrompt: PromptTemplate<zod.ZodObject<{
20
20
  allowed: zod.ZodString;
21
21
  reason: zod.ZodOptional<zod.ZodString>;
22
22
  }, "strip", zod.ZodTypeAny, {
23
- inputSchema: string;
24
- description: string;
25
23
  name: string;
24
+ description: string;
25
+ inputSchema: string;
26
26
  allowed: string;
27
27
  reason?: string | undefined;
28
28
  }, {
29
- inputSchema: string;
30
- description: string;
31
29
  name: string;
30
+ description: string;
31
+ inputSchema: string;
32
32
  allowed: string;
33
33
  reason?: string | undefined;
34
34
  }>, "many">;
35
35
  }, "strip", zod.ZodTypeAny, {
36
36
  finalAnswerName: string;
37
37
  tools: {
38
- inputSchema: string;
39
- description: string;
40
38
  name: string;
39
+ description: string;
40
+ inputSchema: string;
41
41
  allowed: string;
42
42
  reason?: string | undefined;
43
43
  }[];
@@ -49,9 +49,9 @@ declare const RequirementAgentSystemPrompt: PromptTemplate<zod.ZodObject<{
49
49
  }, {
50
50
  finalAnswerName: string;
51
51
  tools: {
52
- inputSchema: string;
53
- description: string;
54
52
  name: string;
53
+ description: string;
54
+ inputSchema: string;
55
55
  allowed: string;
56
56
  reason?: string | undefined;
57
57
  }[];