beeai-framework 0.1.6 → 0.1.8

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 (268) hide show
  1. package/README.md +35 -29
  2. package/dist/adapters/amazon-bedrock/backend/chat.d.cts +1 -1
  3. package/dist/adapters/amazon-bedrock/backend/chat.d.ts +1 -1
  4. package/dist/adapters/amazon-bedrock/backend/embedding.d.cts +1 -1
  5. package/dist/adapters/amazon-bedrock/backend/embedding.d.ts +1 -1
  6. package/dist/adapters/anthropic/backend/chat.d.cts +1 -1
  7. package/dist/adapters/anthropic/backend/chat.d.ts +1 -1
  8. package/dist/adapters/anthropic/backend/embedding.d.cts +1 -1
  9. package/dist/adapters/anthropic/backend/embedding.d.ts +1 -1
  10. package/dist/adapters/azure-openai/backend/chat.d.cts +1 -1
  11. package/dist/adapters/azure-openai/backend/chat.d.ts +1 -1
  12. package/dist/adapters/azure-openai/backend/embedding.d.cts +1 -1
  13. package/dist/adapters/azure-openai/backend/embedding.d.ts +1 -1
  14. package/dist/adapters/dummy/backend/chat.d.cts +1 -1
  15. package/dist/adapters/dummy/backend/chat.d.ts +1 -1
  16. package/dist/adapters/dummy/backend/embedding.d.cts +1 -1
  17. package/dist/adapters/dummy/backend/embedding.d.ts +1 -1
  18. package/dist/adapters/google-vertex/backend/chat.d.cts +1 -1
  19. package/dist/adapters/google-vertex/backend/chat.d.ts +1 -1
  20. package/dist/adapters/google-vertex/backend/embedding.d.cts +1 -1
  21. package/dist/adapters/google-vertex/backend/embedding.d.ts +1 -1
  22. package/dist/adapters/groq/backend/chat.d.cts +1 -1
  23. package/dist/adapters/groq/backend/chat.d.ts +1 -1
  24. package/dist/adapters/groq/backend/embedding.d.cts +1 -1
  25. package/dist/adapters/groq/backend/embedding.d.ts +1 -1
  26. package/dist/adapters/langchain/backend/chat.d.cts +1 -1
  27. package/dist/adapters/langchain/backend/chat.d.ts +1 -1
  28. package/dist/adapters/langchain/backend/embedding.d.cts +1 -1
  29. package/dist/adapters/langchain/backend/embedding.d.ts +1 -1
  30. package/dist/adapters/langchain/tools.d.cts +1 -1
  31. package/dist/adapters/langchain/tools.d.ts +1 -1
  32. package/dist/adapters/ollama/backend/chat.d.cts +1 -1
  33. package/dist/adapters/ollama/backend/chat.d.ts +1 -1
  34. package/dist/adapters/ollama/backend/embedding.d.cts +1 -1
  35. package/dist/adapters/ollama/backend/embedding.d.ts +1 -1
  36. package/dist/adapters/openai/backend/chat.d.cts +1 -1
  37. package/dist/adapters/openai/backend/chat.d.ts +1 -1
  38. package/dist/adapters/openai/backend/client.cjs +9 -2
  39. package/dist/adapters/openai/backend/client.cjs.map +1 -1
  40. package/dist/adapters/openai/backend/client.js +9 -2
  41. package/dist/adapters/openai/backend/client.js.map +1 -1
  42. package/dist/adapters/openai/backend/embedding.d.cts +1 -1
  43. package/dist/adapters/openai/backend/embedding.d.ts +1 -1
  44. package/dist/adapters/vercel/backend/chat.cjs +0 -1
  45. package/dist/adapters/vercel/backend/chat.cjs.map +1 -1
  46. package/dist/adapters/vercel/backend/chat.d.cts +1 -1
  47. package/dist/adapters/vercel/backend/chat.d.ts +1 -1
  48. package/dist/adapters/vercel/backend/chat.js +0 -1
  49. package/dist/adapters/vercel/backend/chat.js.map +1 -1
  50. package/dist/adapters/vercel/backend/embedding.d.cts +1 -1
  51. package/dist/adapters/vercel/backend/embedding.d.ts +1 -1
  52. package/dist/adapters/watsonx/backend/chat.cjs +6 -2
  53. package/dist/adapters/watsonx/backend/chat.cjs.map +1 -1
  54. package/dist/adapters/watsonx/backend/chat.d.cts +2 -2
  55. package/dist/adapters/watsonx/backend/chat.d.ts +2 -2
  56. package/dist/adapters/watsonx/backend/chat.js +6 -2
  57. package/dist/adapters/watsonx/backend/chat.js.map +1 -1
  58. package/dist/adapters/watsonx/backend/embedding.d.cts +1 -1
  59. package/dist/adapters/watsonx/backend/embedding.d.ts +1 -1
  60. package/dist/agent-COg8SPbf.d.cts +84 -0
  61. package/dist/agent-Dv5YSk8H.d.ts +84 -0
  62. package/dist/agents/base.d.cts +2 -2
  63. package/dist/agents/base.d.ts +2 -2
  64. package/dist/agents/experimental/remote/agent.cjs +25 -18
  65. package/dist/agents/experimental/remote/agent.cjs.map +1 -1
  66. package/dist/agents/experimental/remote/agent.d.cts +6 -5
  67. package/dist/agents/experimental/remote/agent.d.ts +6 -5
  68. package/dist/agents/experimental/remote/agent.js +26 -19
  69. package/dist/agents/experimental/remote/agent.js.map +1 -1
  70. package/dist/agents/experimental/replan/agent.d.cts +2 -2
  71. package/dist/agents/experimental/replan/agent.d.ts +2 -2
  72. package/dist/agents/experimental/replan/prompts.d.cts +1 -1
  73. package/dist/agents/experimental/replan/prompts.d.ts +1 -1
  74. package/dist/agents/experimental/streamlit/agent.d.cts +2 -2
  75. package/dist/agents/experimental/streamlit/agent.d.ts +2 -2
  76. package/dist/agents/{bee → react}/agent.cjs +5 -5
  77. package/dist/agents/react/agent.cjs.map +1 -0
  78. package/dist/agents/{bee → react}/agent.d.cts +3 -3
  79. package/dist/agents/{bee → react}/agent.d.ts +3 -3
  80. package/dist/agents/{bee → react}/agent.js +5 -5
  81. package/dist/agents/react/agent.js.map +1 -0
  82. package/dist/agents/{bee → react}/prompts.cjs +18 -18
  83. package/dist/agents/react/prompts.cjs.map +1 -0
  84. package/dist/agents/{bee → react}/prompts.d.cts +10 -10
  85. package/dist/agents/{bee → react}/prompts.d.ts +10 -10
  86. package/dist/agents/{bee → react}/prompts.js +10 -10
  87. package/dist/agents/react/prompts.js.map +1 -0
  88. package/dist/agents/{bee → react}/runners/base.cjs +1 -1
  89. package/dist/agents/{bee → react}/runners/base.cjs.map +1 -1
  90. package/dist/agents/{bee → react}/runners/base.d.cts +3 -3
  91. package/dist/agents/{bee → react}/runners/base.d.ts +3 -3
  92. package/dist/agents/{bee → react}/runners/base.js +1 -1
  93. package/dist/agents/{bee → react}/runners/base.js.map +1 -1
  94. package/dist/agents/{bee → react}/runners/deep-think/prompts.cjs +14 -14
  95. package/dist/agents/react/runners/deep-think/prompts.cjs.map +1 -0
  96. package/dist/agents/{bee/runners/granite → react/runners/deep-think}/prompts.d.cts +8 -8
  97. package/dist/agents/{bee/runners/granite → react/runners/deep-think}/prompts.d.ts +8 -8
  98. package/dist/agents/{bee → react}/runners/deep-think/prompts.js +9 -9
  99. package/dist/agents/react/runners/deep-think/prompts.js.map +1 -0
  100. package/dist/agents/{bee → react}/runners/deep-think/runner.cjs +10 -10
  101. package/dist/agents/react/runners/deep-think/runner.cjs.map +1 -0
  102. package/dist/agents/{bee → react}/runners/deep-think/runner.d.cts +6 -6
  103. package/dist/agents/{bee → react}/runners/deep-think/runner.d.ts +6 -6
  104. package/dist/agents/{bee → react}/runners/deep-think/runner.js +12 -12
  105. package/dist/agents/react/runners/deep-think/runner.js.map +1 -0
  106. package/dist/agents/{bee → react}/runners/default/runner.cjs +10 -10
  107. package/dist/agents/react/runners/default/runner.cjs.map +1 -0
  108. package/dist/agents/{bee → react}/runners/default/runner.d.cts +9 -9
  109. package/dist/agents/{bee → react}/runners/default/runner.d.ts +9 -9
  110. package/dist/agents/{bee → react}/runners/default/runner.js +11 -11
  111. package/dist/agents/react/runners/default/runner.js.map +1 -0
  112. package/dist/agents/{bee → react}/runners/default/runner.spec.cjs +5 -5
  113. package/dist/agents/react/runners/default/runner.spec.cjs.map +1 -0
  114. package/dist/agents/{bee → react}/runners/default/runner.spec.js +6 -6
  115. package/dist/agents/react/runners/default/runner.spec.js.map +1 -0
  116. package/dist/agents/{bee → react}/runners/granite/prompts.cjs +14 -14
  117. package/dist/agents/react/runners/granite/prompts.cjs.map +1 -0
  118. package/dist/agents/{bee/runners/deep-think → react/runners/granite}/prompts.d.cts +8 -8
  119. package/dist/agents/{bee/runners/deep-think → react/runners/granite}/prompts.d.ts +8 -8
  120. package/dist/agents/{bee → react}/runners/granite/prompts.js +9 -9
  121. package/dist/agents/react/runners/granite/prompts.js.map +1 -0
  122. package/dist/agents/{bee → react}/runners/granite/runner.cjs +10 -10
  123. package/dist/agents/react/runners/granite/runner.cjs.map +1 -0
  124. package/dist/agents/{bee → react}/runners/granite/runner.d.cts +6 -6
  125. package/dist/agents/{bee → react}/runners/granite/runner.d.ts +6 -6
  126. package/dist/agents/{bee → react}/runners/granite/runner.js +12 -12
  127. package/dist/agents/react/runners/granite/runner.js.map +1 -0
  128. package/dist/agents/{bee → react}/types.d.cts +46 -46
  129. package/dist/agents/{bee → react}/types.d.ts +46 -46
  130. package/dist/agents/toolCalling/agent.cjs +208 -0
  131. package/dist/agents/toolCalling/agent.cjs.map +1 -0
  132. package/dist/agents/toolCalling/agent.d.cts +70 -0
  133. package/dist/agents/toolCalling/agent.d.ts +70 -0
  134. package/dist/agents/toolCalling/agent.js +206 -0
  135. package/dist/agents/toolCalling/agent.js.map +1 -0
  136. package/dist/agents/toolCalling/prompts.cjs +64 -0
  137. package/dist/agents/toolCalling/prompts.cjs.map +1 -0
  138. package/dist/agents/toolCalling/prompts.d.cts +49 -0
  139. package/dist/agents/toolCalling/prompts.d.ts +49 -0
  140. package/dist/agents/toolCalling/prompts.js +61 -0
  141. package/dist/agents/toolCalling/prompts.js.map +1 -0
  142. package/dist/agents/toolCalling/types.cjs +4 -0
  143. package/dist/agents/toolCalling/types.cjs.map +1 -0
  144. package/dist/agents/toolCalling/types.d.cts +66 -0
  145. package/dist/agents/toolCalling/types.d.ts +66 -0
  146. package/dist/agents/toolCalling/types.js +3 -0
  147. package/dist/agents/toolCalling/types.js.map +1 -0
  148. package/dist/agents/types.d.cts +2 -2
  149. package/dist/agents/types.d.ts +2 -2
  150. package/dist/backend/backend.d.cts +1 -1
  151. package/dist/backend/backend.d.ts +1 -1
  152. package/dist/backend/chat.cjs +3 -0
  153. package/dist/backend/chat.cjs.map +1 -1
  154. package/dist/backend/chat.d.cts +4 -3
  155. package/dist/backend/chat.d.ts +4 -3
  156. package/dist/backend/chat.js +3 -0
  157. package/dist/backend/chat.js.map +1 -1
  158. package/dist/backend/core.d.cts +1 -1
  159. package/dist/backend/core.d.ts +1 -1
  160. package/dist/backend/embedding.d.cts +1 -1
  161. package/dist/backend/embedding.d.ts +1 -1
  162. package/dist/backend/message.cjs +9 -0
  163. package/dist/backend/message.cjs.map +1 -1
  164. package/dist/backend/message.d.cts +2 -0
  165. package/dist/backend/message.d.ts +2 -0
  166. package/dist/backend/message.js +9 -0
  167. package/dist/backend/message.js.map +1 -1
  168. package/dist/{base-daM6fHUP.d.cts → base-Csr9guq2.d.cts} +1 -1
  169. package/dist/{base-mmG-8Pk9.d.ts → base-DHhpWHQm.d.ts} +1 -1
  170. package/dist/context.d.cts +1 -1
  171. package/dist/context.d.ts +1 -1
  172. package/dist/emitter/emitter.d.cts +1 -1
  173. package/dist/emitter/emitter.d.ts +1 -1
  174. package/dist/emitter/types.d.cts +1 -1
  175. package/dist/emitter/types.d.ts +1 -1
  176. package/dist/index.cjs +21 -0
  177. package/dist/index.d.cts +8 -3
  178. package/dist/index.d.ts +8 -3
  179. package/dist/index.js +3 -0
  180. package/dist/instrumentation/create-telemetry-middleware.cjs.map +1 -1
  181. package/dist/instrumentation/create-telemetry-middleware.d.cts +1 -1
  182. package/dist/instrumentation/create-telemetry-middleware.d.ts +1 -1
  183. package/dist/instrumentation/create-telemetry-middleware.js.map +1 -1
  184. package/dist/instrumentation/helpers/utils.d.cts +1 -1
  185. package/dist/instrumentation/helpers/utils.d.ts +1 -1
  186. package/dist/internals/fetcher.d.cts +1 -1
  187. package/dist/internals/fetcher.d.ts +1 -1
  188. package/dist/memory/summarizeMemory.d.cts +1 -1
  189. package/dist/memory/summarizeMemory.d.ts +1 -1
  190. package/dist/parsers/linePrefix.d.cts +1 -1
  191. package/dist/parsers/linePrefix.d.ts +1 -1
  192. package/dist/tools/arxiv.d.cts +1 -1
  193. package/dist/tools/arxiv.d.ts +1 -1
  194. package/dist/tools/base.d.cts +1 -1
  195. package/dist/tools/base.d.ts +1 -1
  196. package/dist/tools/calculator.d.cts +1 -1
  197. package/dist/tools/calculator.d.ts +1 -1
  198. package/dist/tools/custom.d.cts +1 -1
  199. package/dist/tools/custom.d.ts +1 -1
  200. package/dist/tools/database/elasticsearch.d.cts +1 -1
  201. package/dist/tools/database/elasticsearch.d.ts +1 -1
  202. package/dist/tools/database/milvus.d.cts +3 -3
  203. package/dist/tools/database/milvus.d.ts +3 -3
  204. package/dist/tools/database/sql.d.cts +1 -1
  205. package/dist/tools/database/sql.d.ts +1 -1
  206. package/dist/tools/llm.d.cts +1 -1
  207. package/dist/tools/llm.d.ts +1 -1
  208. package/dist/tools/mcp.d.cts +1 -1
  209. package/dist/tools/mcp.d.ts +1 -1
  210. package/dist/tools/openapi.d.cts +1 -1
  211. package/dist/tools/openapi.d.ts +1 -1
  212. package/dist/tools/python/output.d.cts +1 -1
  213. package/dist/tools/python/output.d.ts +1 -1
  214. package/dist/tools/python/python.d.cts +1 -1
  215. package/dist/tools/python/python.d.ts +1 -1
  216. package/dist/tools/search/base.d.cts +1 -1
  217. package/dist/tools/search/base.d.ts +1 -1
  218. package/dist/tools/search/duckDuckGoSearch.d.cts +1 -1
  219. package/dist/tools/search/duckDuckGoSearch.d.ts +1 -1
  220. package/dist/tools/search/googleSearch.d.cts +1 -1
  221. package/dist/tools/search/googleSearch.d.ts +1 -1
  222. package/dist/tools/search/searXNGSearch.d.cts +1 -1
  223. package/dist/tools/search/searXNGSearch.d.ts +1 -1
  224. package/dist/tools/search/wikipedia.d.cts +1 -1
  225. package/dist/tools/search/wikipedia.d.ts +1 -1
  226. package/dist/tools/similarity.d.cts +1 -1
  227. package/dist/tools/similarity.d.ts +1 -1
  228. package/dist/tools/weather/openMeteo.d.cts +1 -1
  229. package/dist/tools/weather/openMeteo.d.ts +1 -1
  230. package/dist/tools/web/webCrawler.d.cts +1 -1
  231. package/dist/tools/web/webCrawler.d.ts +1 -1
  232. package/dist/version.cjs +1 -1
  233. package/dist/version.js +1 -1
  234. package/dist/workflows/agent.cjs +28 -20
  235. package/dist/workflows/agent.cjs.map +1 -1
  236. package/dist/workflows/agent.d.cts +223 -43
  237. package/dist/workflows/agent.d.ts +223 -43
  238. package/dist/workflows/agent.js +29 -21
  239. package/dist/workflows/agent.js.map +1 -1
  240. package/dist/workflows/workflow.d.cts +1 -1
  241. package/dist/workflows/workflow.d.ts +1 -1
  242. package/package.json +7 -7
  243. package/dist/agent-BZ-_ATuJ.d.cts +0 -84
  244. package/dist/agent-BqoZ6FbM.d.ts +0 -84
  245. package/dist/agents/bee/agent.cjs.map +0 -1
  246. package/dist/agents/bee/agent.js.map +0 -1
  247. package/dist/agents/bee/prompts.cjs.map +0 -1
  248. package/dist/agents/bee/prompts.js.map +0 -1
  249. package/dist/agents/bee/runners/deep-think/prompts.cjs.map +0 -1
  250. package/dist/agents/bee/runners/deep-think/prompts.js.map +0 -1
  251. package/dist/agents/bee/runners/deep-think/runner.cjs.map +0 -1
  252. package/dist/agents/bee/runners/deep-think/runner.js.map +0 -1
  253. package/dist/agents/bee/runners/default/runner.cjs.map +0 -1
  254. package/dist/agents/bee/runners/default/runner.js.map +0 -1
  255. package/dist/agents/bee/runners/default/runner.spec.cjs.map +0 -1
  256. package/dist/agents/bee/runners/default/runner.spec.js.map +0 -1
  257. package/dist/agents/bee/runners/granite/prompts.cjs.map +0 -1
  258. package/dist/agents/bee/runners/granite/prompts.js.map +0 -1
  259. package/dist/agents/bee/runners/granite/runner.cjs.map +0 -1
  260. package/dist/agents/bee/runners/granite/runner.js.map +0 -1
  261. package/dist/agents/{bee → react}/runners/default/runner.spec.d.cts +0 -0
  262. package/dist/agents/{bee → react}/runners/default/runner.spec.d.ts +0 -0
  263. package/dist/agents/{bee → react}/types.cjs +0 -0
  264. package/dist/agents/{bee → react}/types.cjs.map +0 -0
  265. package/dist/agents/{bee → react}/types.js +0 -0
  266. package/dist/agents/{bee → react}/types.js.map +0 -0
  267. package/dist/{emitter-C9EN5B0j.d.cts → emitter-BWtGHYn0.d.cts} +1 -1
  268. package/dist/{emitter-BxVxGBbJ.d.ts → emitter-l0W9gC1A.d.ts} +1 -1
@@ -1,10 +1,10 @@
1
1
  import '../../context.cjs';
2
- import '../../base-daM6fHUP.cjs';
2
+ import '../../base-Csr9guq2.cjs';
3
3
  import '../../tools/base.cjs';
4
4
  import '../../memory/base.cjs';
5
- import '../../emitter-C9EN5B0j.cjs';
5
+ import '../../emitter-BWtGHYn0.cjs';
6
6
  import './types.cjs';
7
- export { d as BeeAgent, c as BeeInput, e as BeeTemplateFactory } from '../../agent-BZ-_ATuJ.cjs';
7
+ export { a as ReActAgent, R as ReActAgentInput, d as ReActAgentTemplateFactory } from '../../agent-COg8SPbf.cjs';
8
8
  import '../../backend/chat.cjs';
9
9
  import '../../internals/serializable.cjs';
10
10
  import '../../internals/types.cjs';
@@ -1,10 +1,10 @@
1
1
  import '../../context.js';
2
- import '../../base-mmG-8Pk9.js';
2
+ import '../../base-DHhpWHQm.js';
3
3
  import '../../tools/base.js';
4
4
  import '../../memory/base.js';
5
- import '../../emitter-BxVxGBbJ.js';
5
+ import '../../emitter-l0W9gC1A.js';
6
6
  import './types.js';
7
- export { d as BeeAgent, c as BeeInput, e as BeeTemplateFactory } from '../../agent-BqoZ6FbM.js';
7
+ export { a as ReActAgent, R as ReActAgentInput, d as ReActAgentTemplateFactory } from '../../agent-Dv5YSk8H.js';
8
8
  import '../../backend/chat.js';
9
9
  import '../../internals/serializable.js';
10
10
  import '../../internals/types.js';
@@ -10,9 +10,9 @@ import { DefaultRunner } from './runners/default/runner.js';
10
10
 
11
11
  var __defProp = Object.defineProperty;
12
12
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
13
- class BeeAgent extends BaseAgent {
13
+ class ReActAgent extends BaseAgent {
14
14
  static {
15
- __name(this, "BeeAgent");
15
+ __name(this, "ReActAgent");
16
16
  }
17
17
  input;
18
18
  emitter;
@@ -21,7 +21,7 @@ class BeeAgent extends BaseAgent {
21
21
  super(), this.input = input, this.emitter = Emitter.root.child({
22
22
  namespace: [
23
23
  "agent",
24
- "bee"
24
+ "react"
25
25
  ],
26
26
  creator: this
27
27
  });
@@ -59,7 +59,7 @@ class BeeAgent extends BaseAgent {
59
59
  };
60
60
  }
61
61
  return {
62
- name: "Bee",
62
+ name: "ReAct",
63
63
  tools,
64
64
  description: "The Bee framework demonstrates its ability to auto-correct and adapt in real-time, improving the overall reliability and resilience of the system.",
65
65
  ...tools.length > 0 && {
@@ -166,6 +166,6 @@ class BeeAgent extends BaseAgent {
166
166
  }
167
167
  }
168
168
 
169
- export { BeeAgent };
169
+ export { ReActAgent };
170
170
  //# sourceMappingURL=agent.js.map
171
171
  //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["agent.ts"],"names":["ReActAgent","BaseAgent","emitter","runner","constructor","input","Emitter","root","child","namespace","creator","duplicate","tools","find","a","i","arr","b","j","name","toUpperCase","ValueError","modelId","llm","toLowerCase","tag","GraniteRunner","DeepThinkRunner","includes","DefaultRunner","register","memory","meta","slice","description","length","extraDescription","map","tool","join","_run","options","run","execution","maxRetriesPerStep","totalMaxRetries","maxIterations","init","finalMessage","state","signal","createIteration","tool_name","tool_input","output","success","add","AssistantMessage","templates","assistant","render","thought","filter","R","isTruthy","toolName","toolInput","call","JSON","stringify","toolOutput","finalAnswer","final_answer","assign","tool_output","key","emit","data","update","value","parsedValue","createdAt","Date","iterations","prompt","UserMessage","result","createSnapshot"],"mappings":";;;;;;;;;;;;AAwDO,MAAMA,mBAAmBC,SAAAA,CAAAA;EAxDhC;;;;AA6DkBC,EAAAA,OAAAA;AAKNC,EAAAA,MAAAA;AAEVC,EAAAA,WAAAA,CAA+BC,KAAwB,EAAA;AACrD,IAAK,KAAA,EAAA,EAAA,KADwBA,KAAAA,GAAAA,KAAAA,EAAAA,KAPfH,OAAUI,GAAAA,OAAAA,CAAQC,KAAKC,KAA2B,CAAA;MAChEC,SAAW,EAAA;AAAC,QAAA,OAAA;AAAS,QAAA;;MACrBC,OAAS,EAAA;KACX,CAAA;AAOE,IAAMC,MAAAA,SAAAA,GAAYN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MAAAA,OAAAA,EAAS,IAAKA,CAAAA,OAAAA;AACdC,MAAAA,MAAAA,EAAQ,IAAKA,CAAAA;AACf,KAAA;AACF;AACF","file":"agent.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BaseAgent } from \"@/agents/base.js\";\nimport { AnyTool } from \"@/tools/base.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { AssistantMessage, Message, UserMessage } from \"@/backend/message.js\";\nimport { AgentMeta } from \"@/agents/types.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\nimport {\n ReActAgentExecutionConfig,\n ReActAgentTemplates,\n ReActAgentCallbacks,\n ReActAgentRunInput,\n ReActAgentRunOptions,\n ReActAgentRunOutput,\n} from \"@/agents/react/types.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { assign } from \"@/internals/helpers/object.js\";\nimport * as R from \"remeda\";\nimport { BaseRunner } from \"@/agents/react/runners/base.js\";\nimport { GraniteRunner } from \"@/agents/react/runners/granite/runner.js\";\nimport { DeepThinkRunner } from \"@/agents/react/runners/deep-think/runner.js\";\nimport { ValueError } from \"@/errors.js\";\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport { ChatModel } from \"@/backend/chat.js\";\n\nexport type ReActAgentTemplateFactory<K extends keyof ReActAgentTemplates> = (\n template: ReActAgentTemplates[K],\n) => ReActAgentTemplates[K];\n\nexport interface ReActAgentInput {\n llm: ChatModel;\n tools: AnyTool[];\n memory: BaseMemory;\n meta?: Omit<AgentMeta, \"tools\">;\n templates?: Partial<{\n [K in keyof ReActAgentTemplates]: ReActAgentTemplates[K] | ReActAgentTemplateFactory<K>;\n }>;\n execution?: ReActAgentExecutionConfig;\n stream?: boolean;\n}\n\nexport class ReActAgent extends BaseAgent<\n ReActAgentRunInput,\n ReActAgentRunOutput,\n ReActAgentRunOptions\n> {\n public readonly emitter = Emitter.root.child<ReActAgentCallbacks>({\n namespace: [\"agent\", \"react\"],\n creator: this,\n });\n\n protected runner: new (...args: ConstructorParameters<typeof BaseRunner>) => BaseRunner;\n\n constructor(protected readonly input: ReActAgentInput) {\n super();\n\n const duplicate = input.tools.find((a, i, arr) =>\n arr.find((b, j) => i !== j && a.name.toUpperCase() === b.name.toUpperCase()),\n );\n if (duplicate) {\n throw new ValueError(\n `Agent's tools must all have different names. Conflicting tool: ${duplicate.name}.`,\n );\n }\n\n const modelId = this.input.llm.modelId.toLowerCase();\n this.runner =\n [\n { tag: \"granite\", runner: GraniteRunner },\n { tag: \"deepseek-r1\", runner: DeepThinkRunner },\n ].find(({ tag }) => modelId.includes(tag))?.runner ?? DefaultRunner;\n }\n\n static {\n this.register();\n }\n\n set memory(memory: BaseMemory) {\n this.input.memory = memory;\n }\n\n get memory() {\n return this.input.memory;\n }\n\n get meta(): AgentMeta {\n const tools = this.input.tools.slice();\n\n if (this.input.meta) {\n return { ...this.input.meta, tools };\n }\n\n return {\n name: \"ReAct\",\n tools,\n description:\n \"The Bee framework demonstrates its ability to auto-correct and adapt in real-time, improving the overall reliability and resilience of the system.\",\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 async _run(\n input: ReActAgentRunInput,\n options: ReActAgentRunOptions = {},\n run: GetRunContext<typeof this>,\n ): Promise<ReActAgentRunOutput> {\n const runner = new this.runner(\n this.input,\n {\n ...options,\n execution: this.input.execution ??\n options?.execution ?? {\n maxRetriesPerStep: 3,\n totalMaxRetries: 20,\n maxIterations: 10,\n },\n },\n run,\n );\n await runner.init(input);\n\n let finalMessage: Message | undefined;\n while (!finalMessage) {\n const { state, meta, emitter, signal } = await runner.createIteration();\n\n if (state.tool_name && state.tool_input) {\n const { output, success } = await runner.tool({\n state,\n emitter,\n meta,\n signal,\n });\n await runner.memory.add(\n new AssistantMessage(\n runner.templates.assistant.render({\n thought: [state.thought].filter(R.isTruthy),\n toolName: [state.tool_name].filter(R.isTruthy),\n toolInput: [state.tool_input].filter(R.isTruthy).map((call) => JSON.stringify(call)),\n toolOutput: [output],\n finalAnswer: [state.final_answer].filter(R.isTruthy),\n }),\n { success },\n ),\n );\n assign(state, { tool_output: output });\n\n for (const key of [\"partialUpdate\", \"update\"] as const) {\n await emitter.emit(key, {\n data: state,\n update: { key: \"tool_output\", value: output, parsedValue: output },\n meta: { success, ...meta },\n memory: runner.memory,\n });\n }\n }\n if (state.final_answer) {\n finalMessage = new AssistantMessage(state.final_answer, {\n createdAt: new Date(),\n });\n await runner.memory.add(finalMessage);\n await emitter.emit(\"success\", {\n data: finalMessage,\n iterations: runner.iterations,\n memory: runner.memory,\n meta,\n });\n }\n }\n\n if (input.prompt !== null) {\n await this.input.memory.add(\n new UserMessage(input.prompt, {\n createdAt: run.createdAt,\n }),\n );\n }\n\n await this.input.memory.add(finalMessage);\n return { result: finalMessage, iterations: runner.iterations, memory: runner.memory };\n }\n\n createSnapshot() {\n return {\n ...super.createSnapshot(),\n input: this.input,\n emitter: this.emitter,\n runner: this.runner,\n };\n }\n}\n"]}
@@ -5,7 +5,7 @@ var zod = require('zod');
5
5
 
6
6
  var __defProp = Object.defineProperty;
7
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- const BeeSystemPrompt = new template_cjs.PromptTemplate({
8
+ const ReActAgentSystemPrompt = new template_cjs.PromptTemplate({
9
9
  schema: zod.z.object({
10
10
  instructions: zod.z.string().default("You are a helpful assistant."),
11
11
  tools: zod.z.array(zod.z.object({
@@ -85,7 +85,7 @@ Prefer to use these capabilities over functions.
85
85
  # Role
86
86
  {{instructions}}`
87
87
  });
88
- const BeeAssistantPrompt = new template_cjs.PromptTemplate({
88
+ const ReActAgentAssistantPrompt = new template_cjs.PromptTemplate({
89
89
  schema: zod.z.object({
90
90
  thought: zod.z.array(zod.z.string()),
91
91
  toolName: zod.z.array(zod.z.string()),
@@ -99,7 +99,7 @@ const BeeAssistantPrompt = new template_cjs.PromptTemplate({
99
99
  {{/toolInput}}{{#toolOutput}}Function Output: {{.}}
100
100
  {{/toolOutput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`
101
101
  });
102
- const BeeUserPrompt = new template_cjs.PromptTemplate({
102
+ const ReActAgentUserPrompt = new template_cjs.PromptTemplate({
103
103
  schema: zod.z.object({
104
104
  input: zod.z.string(),
105
105
  meta: zod.z.object({
@@ -122,11 +122,11 @@ ${parts}` : parts;
122
122
  },
123
123
  template: `Message: {{input}}{{formatMeta}}`
124
124
  });
125
- const BeeUserEmptyPrompt = new template_cjs.PromptTemplate({
125
+ const ReActAgentUserEmptyPrompt = new template_cjs.PromptTemplate({
126
126
  schema: zod.z.object({}).passthrough(),
127
127
  template: `Message: Empty message.`
128
128
  });
129
- const BeeToolErrorPrompt = new template_cjs.PromptTemplate({
129
+ const ReActAgentToolErrorPrompt = new template_cjs.PromptTemplate({
130
130
  schema: zod.z.object({
131
131
  reason: zod.z.string()
132
132
  }).passthrough(),
@@ -134,7 +134,7 @@ const BeeToolErrorPrompt = new template_cjs.PromptTemplate({
134
134
 
135
135
  {{reason}}`
136
136
  });
137
- const BeeToolInputErrorPrompt = new template_cjs.PromptTemplate({
137
+ const ReActAgentToolInputErrorPrompt = new template_cjs.PromptTemplate({
138
138
  schema: zod.z.object({
139
139
  reason: zod.z.string()
140
140
  }).passthrough(),
@@ -142,11 +142,11 @@ const BeeToolInputErrorPrompt = new template_cjs.PromptTemplate({
142
142
 
143
143
  HINT: If you're convinced that the input was correct but the function cannot process it then use a different function or say I don't know.`
144
144
  });
145
- const BeeToolNoResultsPrompt = new template_cjs.PromptTemplate({
145
+ const ReActAgentToolNoResultsPrompt = new template_cjs.PromptTemplate({
146
146
  schema: zod.z.record(zod.z.any()),
147
147
  template: `No results were found!`
148
148
  });
149
- const BeeToolNotFoundPrompt = new template_cjs.PromptTemplate({
149
+ const ReActAgentToolNotFoundPrompt = new template_cjs.PromptTemplate({
150
150
  schema: zod.z.object({
151
151
  tools: zod.z.array(zod.z.object({
152
152
  name: zod.z.string()
@@ -157,20 +157,20 @@ const BeeToolNotFoundPrompt = new template_cjs.PromptTemplate({
157
157
  Use one of the following functions: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}
158
158
  {{/tools.length}}`
159
159
  });
160
- const BeeSchemaErrorPrompt = new template_cjs.PromptTemplate({
160
+ const ReActAgentSchemaErrorPrompt = new template_cjs.PromptTemplate({
161
161
  schema: zod.z.object({}).passthrough(),
162
162
  template: `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.
163
163
  You communicate only in instruction lines. Valid instruction lines are 'Thought' followed by either 'Function Name' + 'Function Input' + 'Function Output' or 'Final Answer'.`
164
164
  });
165
165
 
166
- exports.BeeAssistantPrompt = BeeAssistantPrompt;
167
- exports.BeeSchemaErrorPrompt = BeeSchemaErrorPrompt;
168
- exports.BeeSystemPrompt = BeeSystemPrompt;
169
- exports.BeeToolErrorPrompt = BeeToolErrorPrompt;
170
- exports.BeeToolInputErrorPrompt = BeeToolInputErrorPrompt;
171
- exports.BeeToolNoResultsPrompt = BeeToolNoResultsPrompt;
172
- exports.BeeToolNotFoundPrompt = BeeToolNotFoundPrompt;
173
- exports.BeeUserEmptyPrompt = BeeUserEmptyPrompt;
174
- exports.BeeUserPrompt = BeeUserPrompt;
166
+ exports.ReActAgentAssistantPrompt = ReActAgentAssistantPrompt;
167
+ exports.ReActAgentSchemaErrorPrompt = ReActAgentSchemaErrorPrompt;
168
+ exports.ReActAgentSystemPrompt = ReActAgentSystemPrompt;
169
+ exports.ReActAgentToolErrorPrompt = ReActAgentToolErrorPrompt;
170
+ exports.ReActAgentToolInputErrorPrompt = ReActAgentToolInputErrorPrompt;
171
+ exports.ReActAgentToolNoResultsPrompt = ReActAgentToolNoResultsPrompt;
172
+ exports.ReActAgentToolNotFoundPrompt = ReActAgentToolNotFoundPrompt;
173
+ exports.ReActAgentUserEmptyPrompt = ReActAgentUserEmptyPrompt;
174
+ exports.ReActAgentUserPrompt = ReActAgentUserPrompt;
175
175
  //# sourceMappingURL=prompts.cjs.map
176
176
  //# sourceMappingURL=prompts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["prompts.ts"],"names":["ReActAgentSystemPrompt","PromptTemplate","schema","z","object","instructions","string","default","tools","array","name","min","description","passthrough","createdAt","datetime","nullish","template","ReActAgentAssistantPrompt","thought","toolName","toolInput","toolOutput","finalAnswer","partial","ReActAgentUserPrompt","input","meta","optional","functions","formatMeta","parts","filter","Boolean","join","ReActAgentUserEmptyPrompt","ReActAgentToolErrorPrompt","reason","ReActAgentToolInputErrorPrompt","ReActAgentToolNoResultsPrompt","record","any","ReActAgentToolNotFoundPrompt","ReActAgentSchemaErrorPrompt"],"mappings":";;;;;;;AAoBaA,MAAAA,sBAAAA,GAAyB,IAAIC,2BAAe,CAAA;AACvDC,EAAAA,MAAAA,EAAQC,MAAEC,MAAO,CAAA;AACfC,IAAAA,YAAAA,EAAcF,KAAEG,CAAAA,MAAAA,EAASC,CAAAA,OAAAA,CAAQ,8BAAA,CAAA;IACjCC,KAAOL,EAAAA,KAAAA,CAAEM,KACPN,CAAAA,KAAAA,CACGC,MAAO,CAAA;AACNM,MAAAA,IAAAA,EAAMP,KAAEG,CAAAA,MAAAA,EAASK,CAAAA,GAAAA,CAAI,CAAA,CAAA;AACrBC,MAAAA,WAAAA,EAAaT,KAAEG,CAAAA,MAAAA,EAASK,CAAAA,GAAAA,CAAI,CAAA,CAAA;AAC5BT,MAAAA,MAAAA,EAAQC,KAAEG,CAAAA,MAAAA,EAASK,CAAAA,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AAEqC,CAAAA,MAAAA,CAAOrC,KAAEsC,CAAAA,GAAAA,EAAG,CAAA;EACtBxB,QAAU,EAAA,CAAA,sBAAA;AACZ,CAAA;AAEayB,MAAAA,4BAAAA,GAA+B,IAAIzC,2BAAe,CAAA;AAC7DC,EAAAA,MAAAA,EAAQC,MACLC,MAAO,CAAA;IACNI,KAAOL,EAAAA,KAAAA,CAAEM,KAAMN,CAAAA,KAAAA,CAAEC,MAAO,CAAA;AAAEM,MAAAA,IAAAA,EAAMP,MAAEG,MAAM;KAAG,CAAA,CAAGO,aAAW;AAC3D,GAAA,EACCA,WAAW,EAAA;EACdI,QAAU,EAAA,CAAA;;;;AAIZ,CAAA;AAEa0B,MAAAA,2BAAAA,GAA8B,IAAI1C,2BAAe,CAAA;AAC5DC,EAAAA,MAAAA,EAAQC,KAAEC,CAAAA,MAAAA,CAAO,EAAC,EAAGS,WAAW,EAAA;EAChCI,QAAU,EAAA,CAAA;;AAEZ,CAAA","file":"prompts.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PromptTemplate } from \"@/template.js\";\nimport { z } from \"zod\";\nimport { MessageMeta } from \"@/backend/message.js\";\n\nexport const ReActAgentSystemPrompt = new PromptTemplate({\n schema: z.object({\n instructions: z.string().default(\"You are a helpful assistant.\"),\n tools: z.array(\n z\n .object({\n name: z.string().min(1),\n description: z.string().min(1),\n schema: z.string().min(1),\n })\n .passthrough(),\n ),\n createdAt: z.string().datetime().nullish(),\n }),\n template: `# Available functions\n{{#tools.length}}\nYou can only use the following functions. Always use all required parameters.\n\n{{#tools}}\nFunction Name: {{name}}\nDescription: {{description}}\nParameters: {{schema}}\n\n{{/tools}}\n{{/tools.length}}\n{{^tools.length}}\nNo functions are available.\n\n{{/tools.length}}\n# Communication structure\nYou communicate only in instruction lines. The format is: \"Instruction: expected output\\n\". You must only use these instruction lines and must not enter empty lines between them. Each instruction must start on a new line.\n{{#tools.length}}\nYou must skip the instruction lines Function Name, Function Input and Function Output if no function calling is required.\n{{/tools.length}}\n\nMessage: User's message. You never use this instruction line.\n{{^tools.length}}\nThought: A single-line plan of how to answer the user's message, including an explanation of the reasoning behind it. It must be immediately followed by Final Answer.\n{{/tools.length}}\n{{#tools.length}}\nThought: A single-line step-by-step plan of how to answer the user's message, including an explanation of the reasoning behind it. You can use the available functions defined above. This instruction line must be immediately followed by Function Name if one of the available functions defined above needs to be called, or by Final Answer. Do not provide the answer here.\nFunction Name: Name of the function. This instruction line must be immediately followed by Function Input.\nFunction Input: Function parameters. Empty object is a valid parameter.\nFunction Output: Output of the function in JSON format.\nThought: Continue your thinking process.\n{{/tools.length}}\nFinal Answer: Answer the user or ask for more information or clarification. It must always be preceded by Thought.\n\n## Examples\nMessage: Can you translate \"How are you\" into French?\nThought: The user wants to translate a text into French. I can do that.\nFinal Answer: Comment vas-tu?\n\n# Instructions\nUser can only see the Final Answer, all answers must be provided there.\n{{^tools.length}}\nYou must always use the communication structure and instructions defined above. Do not forget that Thought must be a single-line immediately followed by Final Answer.\n{{/tools.length}}\n{{#tools.length}}\nYou must always use the communication structure and instructions defined above. Do not forget that Thought must be a single-line immediately followed by either Function Name or Final Answer.\nYou must use Functions to retrieve factual or historical information to answer the message.\n{{/tools.length}}\nIf the user suggests using a function that is not available, answer that the function is not available. You can suggest alternatives if appropriate.\nWhen the message is unclear or you need more information from the user, ask in Final Answer.\n\n# Your capabilities\nPrefer to use these capabilities over functions.\n- You understand these languages: English, Spanish, French.\n- You can translate, analyze, summarize, even long documents.\n\n# Notes\n- If you don't know the answer, say that you don't know.\n- The current time and date in ISO format can be found in the last message.\n- When answering the user, use friendly formats for time and date.\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n- Sometimes, things don't go as planned. Functions may not provide useful information on the first few tries. You should always try a few different approaches before declaring the problem unsolvable.\n- When the function doesn't give you what you were asking for, you must either use another function or a different function input.\n - When using search engines, you try different formulations of the query, possibly even in a different language.\n- You cannot do complex calculations, computations, or data manipulations without using functions.\n\n# Role\n{{instructions}}`,\n});\n\nexport const ReActAgentAssistantPrompt = new PromptTemplate({\n schema: z\n .object({\n thought: z.array(z.string()),\n toolName: z.array(z.string()),\n toolInput: z.array(z.string()),\n toolOutput: z.array(z.string()),\n finalAnswer: z.array(z.string()),\n })\n .partial(),\n template: `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Function Name: {{.}}\\n{{/toolName}}{{#toolInput}}Function Input: {{.}}\\n{{/toolInput}}{{#toolOutput}}Function Output: {{.}}\\n{{/toolOutput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`,\n});\n\nexport const ReActAgentUserPrompt = new PromptTemplate({\n schema: z\n .object({\n input: z.string(),\n meta: z\n .object({\n createdAt: z.string().datetime().optional(),\n })\n .passthrough()\n .optional(),\n })\n .passthrough(),\n functions: {\n formatMeta: function () {\n const meta = this.meta as MessageMeta;\n if (!meta) {\n return \"\";\n }\n\n const parts = [meta.createdAt && `This message was created at ${meta.createdAt}`]\n .filter(Boolean)\n .join(\"\\n\");\n\n return parts ? `\\n\\n${parts}` : parts;\n },\n },\n template: `Message: {{input}}{{formatMeta}}`,\n});\n\nexport const ReActAgentUserEmptyPrompt = new PromptTemplate({\n schema: z.object({}).passthrough(),\n template: `Message: Empty message.`,\n});\n\nexport const ReActAgentToolErrorPrompt = new PromptTemplate({\n schema: z\n .object({\n reason: z.string(),\n })\n .passthrough(),\n template: `The function has failed; the error log is shown below. If the function cannot accomplish what you want, use a different function or explain why you can't use it.\n\n{{reason}}`,\n});\n\nexport const ReActAgentToolInputErrorPrompt = new PromptTemplate({\n schema: z\n .object({\n reason: z.string(),\n })\n .passthrough(),\n template: `{{reason}}\n\nHINT: If you're convinced that the input was correct but the function cannot process it then use a different function or say I don't know.`,\n});\n\nexport const ReActAgentToolNoResultsPrompt = new PromptTemplate({\n schema: z.record(z.any()),\n template: `No results were found!`,\n});\n\nexport const ReActAgentToolNotFoundPrompt = new PromptTemplate({\n schema: z\n .object({\n tools: z.array(z.object({ name: z.string() }).passthrough()),\n })\n .passthrough(),\n template: `Function does not exist!\n{{#tools.length}}\nUse one of the following functions: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}\n{{/tools.length}}`,\n});\n\nexport const ReActAgentSchemaErrorPrompt = new PromptTemplate({\n schema: z.object({}).passthrough(),\n 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 either 'Function Name' + 'Function Input' + 'Function Output' or 'Final Answer'.`,\n});\n"]}
@@ -22,7 +22,7 @@ import 'ajv';
22
22
  * limitations under the License.
23
23
  */
24
24
 
25
- declare const BeeSystemPrompt: PromptTemplate<z.ZodObject<{
25
+ declare const ReActAgentSystemPrompt: PromptTemplate<z.ZodObject<{
26
26
  instructions: z.ZodDefault<z.ZodString>;
27
27
  tools: z.ZodArray<z.ZodObject<{
28
28
  name: z.ZodString;
@@ -55,7 +55,7 @@ declare const BeeSystemPrompt: PromptTemplate<z.ZodObject<{
55
55
  createdAt?: string | null | undefined;
56
56
  instructions?: string | undefined;
57
57
  }>>;
58
- declare const BeeAssistantPrompt: PromptTemplate<z.ZodObject<{
58
+ declare const ReActAgentAssistantPrompt: PromptTemplate<z.ZodObject<{
59
59
  thought: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
60
60
  toolName: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
61
61
  toolInput: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -74,7 +74,7 @@ declare const BeeAssistantPrompt: PromptTemplate<z.ZodObject<{
74
74
  toolOutput?: string[] | undefined;
75
75
  finalAnswer?: string[] | undefined;
76
76
  }>>;
77
- declare const BeeUserPrompt: PromptTemplate<z.ZodObject<{
77
+ declare const ReActAgentUserPrompt: PromptTemplate<z.ZodObject<{
78
78
  input: z.ZodString;
79
79
  meta: z.ZodOptional<z.ZodObject<{
80
80
  createdAt: z.ZodOptional<z.ZodString>;
@@ -102,23 +102,23 @@ declare const BeeUserPrompt: PromptTemplate<z.ZodObject<{
102
102
  createdAt: z.ZodOptional<z.ZodString>;
103
103
  }, z.ZodTypeAny, "passthrough">>>;
104
104
  }, z.ZodTypeAny, "passthrough">>>;
105
- declare const BeeUserEmptyPrompt: PromptTemplate<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
106
- declare const BeeToolErrorPrompt: PromptTemplate<z.ZodObject<{
105
+ declare const ReActAgentUserEmptyPrompt: PromptTemplate<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
106
+ declare const ReActAgentToolErrorPrompt: PromptTemplate<z.ZodObject<{
107
107
  reason: z.ZodString;
108
108
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
109
109
  reason: z.ZodString;
110
110
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
111
111
  reason: z.ZodString;
112
112
  }, z.ZodTypeAny, "passthrough">>>;
113
- declare const BeeToolInputErrorPrompt: PromptTemplate<z.ZodObject<{
113
+ declare const ReActAgentToolInputErrorPrompt: PromptTemplate<z.ZodObject<{
114
114
  reason: z.ZodString;
115
115
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
116
116
  reason: z.ZodString;
117
117
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
118
118
  reason: z.ZodString;
119
119
  }, z.ZodTypeAny, "passthrough">>>;
120
- declare const BeeToolNoResultsPrompt: PromptTemplate<z.ZodRecord<z.ZodString, z.ZodAny>>;
121
- declare const BeeToolNotFoundPrompt: PromptTemplate<z.ZodObject<{
120
+ declare const ReActAgentToolNoResultsPrompt: PromptTemplate<z.ZodRecord<z.ZodString, z.ZodAny>>;
121
+ declare const ReActAgentToolNotFoundPrompt: PromptTemplate<z.ZodObject<{
122
122
  tools: z.ZodArray<z.ZodObject<{
123
123
  name: z.ZodString;
124
124
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
@@ -143,6 +143,6 @@ declare const BeeToolNotFoundPrompt: PromptTemplate<z.ZodObject<{
143
143
  name: z.ZodString;
144
144
  }, z.ZodTypeAny, "passthrough">>, "many">;
145
145
  }, z.ZodTypeAny, "passthrough">>>;
146
- declare const BeeSchemaErrorPrompt: PromptTemplate<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
146
+ declare const ReActAgentSchemaErrorPrompt: PromptTemplate<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
147
147
 
148
- export { BeeAssistantPrompt, BeeSchemaErrorPrompt, BeeSystemPrompt, BeeToolErrorPrompt, BeeToolInputErrorPrompt, BeeToolNoResultsPrompt, BeeToolNotFoundPrompt, BeeUserEmptyPrompt, BeeUserPrompt };
148
+ export { ReActAgentAssistantPrompt, ReActAgentSchemaErrorPrompt, ReActAgentSystemPrompt, ReActAgentToolErrorPrompt, ReActAgentToolInputErrorPrompt, ReActAgentToolNoResultsPrompt, ReActAgentToolNotFoundPrompt, ReActAgentUserEmptyPrompt, ReActAgentUserPrompt };
@@ -22,7 +22,7 @@ import 'ajv';
22
22
  * limitations under the License.
23
23
  */
24
24
 
25
- declare const BeeSystemPrompt: PromptTemplate<z.ZodObject<{
25
+ declare const ReActAgentSystemPrompt: PromptTemplate<z.ZodObject<{
26
26
  instructions: z.ZodDefault<z.ZodString>;
27
27
  tools: z.ZodArray<z.ZodObject<{
28
28
  name: z.ZodString;
@@ -55,7 +55,7 @@ declare const BeeSystemPrompt: PromptTemplate<z.ZodObject<{
55
55
  createdAt?: string | null | undefined;
56
56
  instructions?: string | undefined;
57
57
  }>>;
58
- declare const BeeAssistantPrompt: PromptTemplate<z.ZodObject<{
58
+ declare const ReActAgentAssistantPrompt: PromptTemplate<z.ZodObject<{
59
59
  thought: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
60
60
  toolName: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
61
61
  toolInput: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -74,7 +74,7 @@ declare const BeeAssistantPrompt: PromptTemplate<z.ZodObject<{
74
74
  toolOutput?: string[] | undefined;
75
75
  finalAnswer?: string[] | undefined;
76
76
  }>>;
77
- declare const BeeUserPrompt: PromptTemplate<z.ZodObject<{
77
+ declare const ReActAgentUserPrompt: PromptTemplate<z.ZodObject<{
78
78
  input: z.ZodString;
79
79
  meta: z.ZodOptional<z.ZodObject<{
80
80
  createdAt: z.ZodOptional<z.ZodString>;
@@ -102,23 +102,23 @@ declare const BeeUserPrompt: PromptTemplate<z.ZodObject<{
102
102
  createdAt: z.ZodOptional<z.ZodString>;
103
103
  }, z.ZodTypeAny, "passthrough">>>;
104
104
  }, z.ZodTypeAny, "passthrough">>>;
105
- declare const BeeUserEmptyPrompt: PromptTemplate<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
106
- declare const BeeToolErrorPrompt: PromptTemplate<z.ZodObject<{
105
+ declare const ReActAgentUserEmptyPrompt: PromptTemplate<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
106
+ declare const ReActAgentToolErrorPrompt: PromptTemplate<z.ZodObject<{
107
107
  reason: z.ZodString;
108
108
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
109
109
  reason: z.ZodString;
110
110
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
111
111
  reason: z.ZodString;
112
112
  }, z.ZodTypeAny, "passthrough">>>;
113
- declare const BeeToolInputErrorPrompt: PromptTemplate<z.ZodObject<{
113
+ declare const ReActAgentToolInputErrorPrompt: PromptTemplate<z.ZodObject<{
114
114
  reason: z.ZodString;
115
115
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
116
116
  reason: z.ZodString;
117
117
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
118
118
  reason: z.ZodString;
119
119
  }, z.ZodTypeAny, "passthrough">>>;
120
- declare const BeeToolNoResultsPrompt: PromptTemplate<z.ZodRecord<z.ZodString, z.ZodAny>>;
121
- declare const BeeToolNotFoundPrompt: PromptTemplate<z.ZodObject<{
120
+ declare const ReActAgentToolNoResultsPrompt: PromptTemplate<z.ZodRecord<z.ZodString, z.ZodAny>>;
121
+ declare const ReActAgentToolNotFoundPrompt: PromptTemplate<z.ZodObject<{
122
122
  tools: z.ZodArray<z.ZodObject<{
123
123
  name: z.ZodString;
124
124
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
@@ -143,6 +143,6 @@ declare const BeeToolNotFoundPrompt: PromptTemplate<z.ZodObject<{
143
143
  name: z.ZodString;
144
144
  }, z.ZodTypeAny, "passthrough">>, "many">;
145
145
  }, z.ZodTypeAny, "passthrough">>>;
146
- declare const BeeSchemaErrorPrompt: PromptTemplate<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
146
+ declare const ReActAgentSchemaErrorPrompt: PromptTemplate<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
147
147
 
148
- export { BeeAssistantPrompt, BeeSchemaErrorPrompt, BeeSystemPrompt, BeeToolErrorPrompt, BeeToolInputErrorPrompt, BeeToolNoResultsPrompt, BeeToolNotFoundPrompt, BeeUserEmptyPrompt, BeeUserPrompt };
148
+ export { ReActAgentAssistantPrompt, ReActAgentSchemaErrorPrompt, ReActAgentSystemPrompt, ReActAgentToolErrorPrompt, ReActAgentToolInputErrorPrompt, ReActAgentToolNoResultsPrompt, ReActAgentToolNotFoundPrompt, ReActAgentUserEmptyPrompt, ReActAgentUserPrompt };
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
3
 
4
4
  var __defProp = Object.defineProperty;
5
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- const BeeSystemPrompt = new PromptTemplate({
6
+ const ReActAgentSystemPrompt = new PromptTemplate({
7
7
  schema: z.object({
8
8
  instructions: z.string().default("You are a helpful assistant."),
9
9
  tools: z.array(z.object({
@@ -83,7 +83,7 @@ Prefer to use these capabilities over functions.
83
83
  # Role
84
84
  {{instructions}}`
85
85
  });
86
- const BeeAssistantPrompt = new PromptTemplate({
86
+ const ReActAgentAssistantPrompt = new PromptTemplate({
87
87
  schema: z.object({
88
88
  thought: z.array(z.string()),
89
89
  toolName: z.array(z.string()),
@@ -97,7 +97,7 @@ const BeeAssistantPrompt = new PromptTemplate({
97
97
  {{/toolInput}}{{#toolOutput}}Function Output: {{.}}
98
98
  {{/toolOutput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`
99
99
  });
100
- const BeeUserPrompt = new PromptTemplate({
100
+ const ReActAgentUserPrompt = new PromptTemplate({
101
101
  schema: z.object({
102
102
  input: z.string(),
103
103
  meta: z.object({
@@ -120,11 +120,11 @@ ${parts}` : parts;
120
120
  },
121
121
  template: `Message: {{input}}{{formatMeta}}`
122
122
  });
123
- const BeeUserEmptyPrompt = new PromptTemplate({
123
+ const ReActAgentUserEmptyPrompt = new PromptTemplate({
124
124
  schema: z.object({}).passthrough(),
125
125
  template: `Message: Empty message.`
126
126
  });
127
- const BeeToolErrorPrompt = new PromptTemplate({
127
+ const ReActAgentToolErrorPrompt = new PromptTemplate({
128
128
  schema: z.object({
129
129
  reason: z.string()
130
130
  }).passthrough(),
@@ -132,7 +132,7 @@ const BeeToolErrorPrompt = new PromptTemplate({
132
132
 
133
133
  {{reason}}`
134
134
  });
135
- const BeeToolInputErrorPrompt = new PromptTemplate({
135
+ const ReActAgentToolInputErrorPrompt = new PromptTemplate({
136
136
  schema: z.object({
137
137
  reason: z.string()
138
138
  }).passthrough(),
@@ -140,11 +140,11 @@ const BeeToolInputErrorPrompt = new PromptTemplate({
140
140
 
141
141
  HINT: If you're convinced that the input was correct but the function cannot process it then use a different function or say I don't know.`
142
142
  });
143
- const BeeToolNoResultsPrompt = new PromptTemplate({
143
+ const ReActAgentToolNoResultsPrompt = new PromptTemplate({
144
144
  schema: z.record(z.any()),
145
145
  template: `No results were found!`
146
146
  });
147
- const BeeToolNotFoundPrompt = new PromptTemplate({
147
+ const ReActAgentToolNotFoundPrompt = new PromptTemplate({
148
148
  schema: z.object({
149
149
  tools: z.array(z.object({
150
150
  name: z.string()
@@ -155,12 +155,12 @@ const BeeToolNotFoundPrompt = new PromptTemplate({
155
155
  Use one of the following functions: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}
156
156
  {{/tools.length}}`
157
157
  });
158
- const BeeSchemaErrorPrompt = new PromptTemplate({
158
+ const ReActAgentSchemaErrorPrompt = new PromptTemplate({
159
159
  schema: z.object({}).passthrough(),
160
160
  template: `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.
161
161
  You communicate only in instruction lines. Valid instruction lines are 'Thought' followed by either 'Function Name' + 'Function Input' + 'Function Output' or 'Final Answer'.`
162
162
  });
163
163
 
164
- export { BeeAssistantPrompt, BeeSchemaErrorPrompt, BeeSystemPrompt, BeeToolErrorPrompt, BeeToolInputErrorPrompt, BeeToolNoResultsPrompt, BeeToolNotFoundPrompt, BeeUserEmptyPrompt, BeeUserPrompt };
164
+ export { ReActAgentAssistantPrompt, ReActAgentSchemaErrorPrompt, ReActAgentSystemPrompt, ReActAgentToolErrorPrompt, ReActAgentToolInputErrorPrompt, ReActAgentToolNoResultsPrompt, ReActAgentToolNotFoundPrompt, ReActAgentUserEmptyPrompt, ReActAgentUserPrompt };
165
165
  //# sourceMappingURL=prompts.js.map
166
166
  //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["prompts.ts"],"names":["ReActAgentSystemPrompt","PromptTemplate","schema","z","object","instructions","string","default","tools","array","name","min","description","passthrough","createdAt","datetime","nullish","template","ReActAgentAssistantPrompt","thought","toolName","toolInput","toolOutput","finalAnswer","partial","ReActAgentUserPrompt","input","meta","optional","functions","formatMeta","parts","filter","Boolean","join","ReActAgentUserEmptyPrompt","ReActAgentToolErrorPrompt","reason","ReActAgentToolInputErrorPrompt","ReActAgentToolNoResultsPrompt","record","any","ReActAgentToolNotFoundPrompt","ReActAgentSchemaErrorPrompt"],"mappings":";;;;;AAoBaA,MAAAA,sBAAAA,GAAyB,IAAIC,cAAe,CAAA;AACvDC,EAAAA,MAAAA,EAAQC,EAAEC,MAAO,CAAA;AACfC,IAAAA,YAAAA,EAAcF,CAAEG,CAAAA,MAAAA,EAASC,CAAAA,OAAAA,CAAQ,8BAAA,CAAA;IACjCC,KAAOL,EAAAA,CAAAA,CAAEM,KACPN,CAAAA,CAAAA,CACGC,MAAO,CAAA;AACNM,MAAAA,IAAAA,EAAMP,CAAEG,CAAAA,MAAAA,EAASK,CAAAA,GAAAA,CAAI,CAAA,CAAA;AACrBC,MAAAA,WAAAA,EAAaT,CAAEG,CAAAA,MAAAA,EAASK,CAAAA,GAAAA,CAAI,CAAA,CAAA;AAC5BT,MAAAA,MAAAA,EAAQC,CAAEG,CAAAA,MAAAA,EAASK,CAAAA,GAAAA,CAAI,CAAA;KACzB,CAAA,CACCE,a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GAAAA,EAAG,CAAA;EACtBxB,QAAU,EAAA,CAAA,sBAAA;AACZ,CAAA;AAEayB,MAAAA,4BAAAA,GAA+B,IAAIzC,cAAe,CAAA;AAC7DC,EAAAA,MAAAA,EAAQC,EACLC,MAAO,CAAA;IACNI,KAAOL,EAAAA,CAAAA,CAAEM,KAAMN,CAAAA,CAAAA,CAAEC,MAAO,CAAA;AAAEM,MAAAA,IAAAA,EAAMP,EAAEG,MAAM;KAAG,CAAA,CAAGO,aAAW;AAC3D,GAAA,EACCA,WAAW,EAAA;EACdI,QAAU,EAAA,CAAA;;;;AAIZ,CAAA;AAEa0B,MAAAA,2BAAAA,GAA8B,IAAI1C,cAAe,CAAA;AAC5DC,EAAAA,MAAAA,EAAQC,CAAEC,CAAAA,MAAAA,CAAO,EAAC,EAAGS,WAAW,EAAA;EAChCI,QAAU,EAAA,CAAA;;AAEZ,CAAA","file":"prompts.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PromptTemplate } from \"@/template.js\";\nimport { z } from \"zod\";\nimport { MessageMeta } from \"@/backend/message.js\";\n\nexport const ReActAgentSystemPrompt = new PromptTemplate({\n schema: z.object({\n instructions: z.string().default(\"You are a helpful assistant.\"),\n tools: z.array(\n z\n .object({\n name: z.string().min(1),\n description: z.string().min(1),\n schema: z.string().min(1),\n })\n .passthrough(),\n ),\n createdAt: z.string().datetime().nullish(),\n }),\n template: `# Available functions\n{{#tools.length}}\nYou can only use the following functions. Always use all required parameters.\n\n{{#tools}}\nFunction Name: {{name}}\nDescription: {{description}}\nParameters: {{schema}}\n\n{{/tools}}\n{{/tools.length}}\n{{^tools.length}}\nNo functions are available.\n\n{{/tools.length}}\n# Communication structure\nYou communicate only in instruction lines. The format is: \"Instruction: expected output\\n\". You must only use these instruction lines and must not enter empty lines between them. Each instruction must start on a new line.\n{{#tools.length}}\nYou must skip the instruction lines Function Name, Function Input and Function Output if no function calling is required.\n{{/tools.length}}\n\nMessage: User's message. You never use this instruction line.\n{{^tools.length}}\nThought: A single-line plan of how to answer the user's message, including an explanation of the reasoning behind it. It must be immediately followed by Final Answer.\n{{/tools.length}}\n{{#tools.length}}\nThought: A single-line step-by-step plan of how to answer the user's message, including an explanation of the reasoning behind it. You can use the available functions defined above. This instruction line must be immediately followed by Function Name if one of the available functions defined above needs to be called, or by Final Answer. Do not provide the answer here.\nFunction Name: Name of the function. This instruction line must be immediately followed by Function Input.\nFunction Input: Function parameters. Empty object is a valid parameter.\nFunction Output: Output of the function in JSON format.\nThought: Continue your thinking process.\n{{/tools.length}}\nFinal Answer: Answer the user or ask for more information or clarification. It must always be preceded by Thought.\n\n## Examples\nMessage: Can you translate \"How are you\" into French?\nThought: The user wants to translate a text into French. I can do that.\nFinal Answer: Comment vas-tu?\n\n# Instructions\nUser can only see the Final Answer, all answers must be provided there.\n{{^tools.length}}\nYou must always use the communication structure and instructions defined above. Do not forget that Thought must be a single-line immediately followed by Final Answer.\n{{/tools.length}}\n{{#tools.length}}\nYou must always use the communication structure and instructions defined above. Do not forget that Thought must be a single-line immediately followed by either Function Name or Final Answer.\nYou must use Functions to retrieve factual or historical information to answer the message.\n{{/tools.length}}\nIf the user suggests using a function that is not available, answer that the function is not available. You can suggest alternatives if appropriate.\nWhen the message is unclear or you need more information from the user, ask in Final Answer.\n\n# Your capabilities\nPrefer to use these capabilities over functions.\n- You understand these languages: English, Spanish, French.\n- You can translate, analyze, summarize, even long documents.\n\n# Notes\n- If you don't know the answer, say that you don't know.\n- The current time and date in ISO format can be found in the last message.\n- When answering the user, use friendly formats for time and date.\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n- Sometimes, things don't go as planned. Functions may not provide useful information on the first few tries. You should always try a few different approaches before declaring the problem unsolvable.\n- When the function doesn't give you what you were asking for, you must either use another function or a different function input.\n - When using search engines, you try different formulations of the query, possibly even in a different language.\n- You cannot do complex calculations, computations, or data manipulations without using functions.\n\n# Role\n{{instructions}}`,\n});\n\nexport const ReActAgentAssistantPrompt = new PromptTemplate({\n schema: z\n .object({\n thought: z.array(z.string()),\n toolName: z.array(z.string()),\n toolInput: z.array(z.string()),\n toolOutput: z.array(z.string()),\n finalAnswer: z.array(z.string()),\n })\n .partial(),\n template: `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Function Name: {{.}}\\n{{/toolName}}{{#toolInput}}Function Input: {{.}}\\n{{/toolInput}}{{#toolOutput}}Function Output: {{.}}\\n{{/toolOutput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`,\n});\n\nexport const ReActAgentUserPrompt = new PromptTemplate({\n schema: z\n .object({\n input: z.string(),\n meta: z\n .object({\n createdAt: z.string().datetime().optional(),\n })\n .passthrough()\n .optional(),\n })\n .passthrough(),\n functions: {\n formatMeta: function () {\n const meta = this.meta as MessageMeta;\n if (!meta) {\n return \"\";\n }\n\n const parts = [meta.createdAt && `This message was created at ${meta.createdAt}`]\n .filter(Boolean)\n .join(\"\\n\");\n\n return parts ? `\\n\\n${parts}` : parts;\n },\n },\n template: `Message: {{input}}{{formatMeta}}`,\n});\n\nexport const ReActAgentUserEmptyPrompt = new PromptTemplate({\n schema: z.object({}).passthrough(),\n template: `Message: Empty message.`,\n});\n\nexport const ReActAgentToolErrorPrompt = new PromptTemplate({\n schema: z\n .object({\n reason: z.string(),\n })\n .passthrough(),\n template: `The function has failed; the error log is shown below. If the function cannot accomplish what you want, use a different function or explain why you can't use it.\n\n{{reason}}`,\n});\n\nexport const ReActAgentToolInputErrorPrompt = new PromptTemplate({\n schema: z\n .object({\n reason: z.string(),\n })\n .passthrough(),\n template: `{{reason}}\n\nHINT: If you're convinced that the input was correct but the function cannot process it then use a different function or say I don't know.`,\n});\n\nexport const ReActAgentToolNoResultsPrompt = new PromptTemplate({\n schema: z.record(z.any()),\n template: `No results were found!`,\n});\n\nexport const ReActAgentToolNotFoundPrompt = new PromptTemplate({\n schema: z\n .object({\n tools: z.array(z.object({ name: z.string() }).passthrough()),\n })\n .passthrough(),\n template: `Function does not exist!\n{{#tools.length}}\nUse one of the following functions: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}\n{{/tools.length}}`,\n});\n\nexport const ReActAgentSchemaErrorPrompt = new PromptTemplate({\n schema: z.object({}).passthrough(),\n 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 either 'Function Name' + 'Function Input' + 'Function Output' or 'Final Answer'.`,\n});\n"]}
@@ -94,7 +94,7 @@ _ts_decorate([
94
94
  decoratorCache_cjs.Cache({
95
95
  enumerable: false
96
96
  }),
97
- _ts_metadata("design:type", typeof BeeAgentTemplates === "undefined" ? Object : BeeAgentTemplates),
97
+ _ts_metadata("design:type", typeof ReActAgentTemplates === "undefined" ? Object : ReActAgentTemplates),
98
98
  _ts_metadata("design:paramtypes", [])
99
99
  ], BaseRunner.prototype, "templates", null);
100
100
 
@@ -1 +1 @@
1
- {"version":3,"sources":["base.ts"],"names":["BaseRunner","Serializable","memory","iterations","failedAttemptsCounter","constructor","input","options","run","RetryCounter","execution","totalMaxRetries","AgentError","createIteration","meta","iteration","length","maxIterations","Infinity","isFatal","isRetryable","context","map","state","emitter","child","groupId","llm","signal","push","init","initMemory","templates","overrides","mapObj","defaultTemplates","key","defaultTemplate","override","PromptTemplate","createSnapshot","shallowCopy","loadSnapshot","snapshot","Object","assign","enumerable"],"mappings":";;;;;;;;;;;;AAcC,SAAA,YAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GAAA,EAAA,IAAA,EAAA;;;;;;AAAA,MAAA,CAAA,YAAA,EAAA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A,CAAAA;AAC9B,KAAA;AACF;AAEAsC,EAAAA,YAAAA,CAAaC,QAAkD,EAAA;AAC7DC,IAAOC,MAAAA,CAAAA,MAAAA,CAAO,MAAMF,QAAAA,CAAAA;AACtB;AACF;;;IA3BWG,UAAY,EAAA","file":"base.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Serializable } from \"@/internals/serializable.js\";\nimport type { BeeAgentTemplates } from \"@/agents/bee/types.js\";\nimport {\n BeeAgentRunIteration,\n BeeCallbacks,\n BeeIterationToolResult,\n BeeMeta,\n BeeRunInput,\n BeeRunOptions,\n} from \"@/agents/bee/types.js\";\nimport type { BeeAgent, BeeInput } from \"@/agents/bee/agent.js\";\nimport { RetryCounter } from \"@/internals/helpers/counter.js\";\nimport { AgentError } from \"@/agents/base.js\";\nimport { shallowCopy } from \"@/serializer/utils.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\nimport { mapObj } from \"@/internals/helpers/object.js\";\nimport { PromptTemplate } from \"@/template.js\";\n\nexport interface BeeRunnerLLMInput {\n meta: BeeMeta;\n signal: AbortSignal;\n emitter: Emitter<BeeCallbacks>;\n}\n\nexport interface BeeRunnerToolInput {\n state: BeeIterationToolResult;\n meta: BeeMeta;\n signal: AbortSignal;\n emitter: Emitter<BeeCallbacks>;\n}\n\nexport abstract class BaseRunner extends Serializable {\n public memory!: BaseMemory;\n public readonly iterations: BeeAgentRunIteration[] = [];\n protected readonly failedAttemptsCounter: RetryCounter;\n\n constructor(\n protected readonly input: BeeInput,\n protected readonly options: BeeRunOptions,\n protected readonly run: GetRunContext<BeeAgent>,\n ) {\n super();\n this.failedAttemptsCounter = new RetryCounter(options?.execution?.totalMaxRetries, AgentError);\n }\n\n async createIteration() {\n const meta: BeeMeta = { iteration: this.iterations.length + 1 };\n const maxIterations = this.options?.execution?.maxIterations ?? Infinity;\n\n if (meta.iteration > maxIterations) {\n throw new AgentError(\n `Agent was not able to resolve the task in ${maxIterations} iterations.`,\n [],\n {\n isFatal: true,\n isRetryable: false,\n context: { iterations: this.iterations.map((iteration) => iteration.state) },\n },\n );\n }\n\n const emitter = this.run.emitter.child({ groupId: `iteration-${meta.iteration}` });\n const iteration = await this.llm({ emitter, signal: this.run.signal, meta });\n this.iterations.push(iteration);\n\n return {\n emitter,\n state: iteration.state,\n meta,\n signal: this.run.signal,\n };\n }\n\n async init(input: BeeRunInput) {\n this.memory = await this.initMemory(input);\n }\n\n abstract llm(input: BeeRunnerLLMInput): Promise<BeeAgentRunIteration>;\n\n abstract tool(input: BeeRunnerToolInput): Promise<{ output: string; success: boolean }>;\n\n public abstract get defaultTemplates(): BeeAgentTemplates;\n\n @Cache({ enumerable: false })\n public get templates(): BeeAgentTemplates {\n const overrides = this.input.templates ?? {};\n\n return mapObj(this.defaultTemplates)((key, defaultTemplate: BeeAgentTemplates[typeof key]) => {\n const override = overrides[key] ?? defaultTemplate;\n if (override instanceof PromptTemplate) {\n return override;\n }\n return override(defaultTemplate) ?? defaultTemplate;\n });\n }\n\n protected abstract initMemory(input: BeeRunInput): Promise<BaseMemory>;\n\n createSnapshot() {\n return {\n input: shallowCopy(this.input),\n options: shallowCopy(this.options),\n memory: this.memory,\n failedAttemptsCounter: this.failedAttemptsCounter,\n };\n }\n\n loadSnapshot(snapshot: ReturnType<typeof this.createSnapshot>) {\n Object.assign(this, snapshot);\n }\n}\n"]}
1
+ {"version":3,"sources":["base.ts"],"names":["BaseRunner","Serializable","memory","iterations","failedAttemptsCounter","constructor","input","options","run","RetryCounter","execution","totalMaxRetries","AgentError","createIteration","meta","iteration","length","maxIterations","Infinity","isFatal","isRetryable","context","map","state","emitter","child","groupId","llm","signal","push","init","initMemory","templates","overrides","mapObj","defaultTemplates","key","defaultTemplate","override","PromptTemplate","createSnapshot","shallowCopy","loadSnapshot","snapshot","Object","assign","enumerable"],"mappings":";;;;;;;;;;;;AAcC,SAAA,YAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GAAA,EAAA,IAAA,EAAA;;;;;;AAAA,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA;;;;;AAoCM,MAAeA,mBAAmBC,6BAAAA,CAAAA;EAlDzC;;;;;;AAmDSC,EAAAA,MAAAA;AACSC,EAAAA,UAAAA;AACGC,EAAAA,qBAAAA;EAEnBC,WACqBC,CAAAA,KAAAA,EACAC,SACAC,GACnB,EAAA;AACA,IAAA,KAAA,EAAK,EAAA,IAAA,CAJcF,KAAAA,GAAAA,KAAAA,EAAAA,IACAC,CAAAA,OAAAA,GAAAA,OAAAA,EAAAA,IAAAA,CACAC,GAAAA,GAAAA,GAAAA,EAAAA,IANLL,CAAAA,UAAAA,GAAuC,EAAA;AASrD,IAAA,IAAA,CAAKC,wBAAwB,IAAIK,wBAAAA,CAAaF,OAASG,EAAAA,SAAAA,EAAWC,iBAAiBC,mBAAAA,CAAAA;AACrF;AAEA,EAAA,MAAMC,eAAkB,GAAA;AACtB,IAAA,MAAMC,IAAuB,GAAA;MAAEC,SAAW,EAAA,IAAA,CAAKZ,WAAWa,MAAS,GAAA;AAAE,KAAA;AACrE,IAAA,MAAMC,aAAgB,GAAA,IAAA,CAAKV,OAASG,EAAAA,SAAAA,EAAWO,aAAiBC,IAAAA,QAAAA;AAEhE,IAAIJ,IAAAA,IAAAA,CAAKC,YAAYE,aAAe,EAAA;AAClC,MAAA,MAAM,IAAIL,mBACR,CAAA,CAAA,0CAAA,EAA6CK,aAAAA,CAAAA,YAAAA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oBAAoBC,2BAAgB,EAAA;AACtC,QAAOD,OAAAA,QAAAA;AACT;AACA,MAAOA,OAAAA,QAAAA,CAASD,eAAAA,CAAoBA,IAAAA,eAAAA;KACtC,CAAA;AAEJ;EAIAG,cAAiB,GAAA;AACf,IAAO,OAAA;MACLlC,KAAOmC,EAAAA,qBAAAA,CAAY,KAAKnC,KAAK,CAAA;MAC7BC,OAASkC,EAAAA,qBAAAA,CAAY,KAAKlC,OAAO,CAAA;AACjCL,MAAAA,MAAAA,EAAQ,IAAKA,CAAAA,MAAAA;AACbE,MAAAA,qBAAAA,EAAuB,IAAKA,CAAAA;AAC9B,KAAA;AACF;AAEAsC,EAAAA,YAAAA,CAAaC,QAAkD,EAAA;AAC7DC,IAAOC,MAAAA,CAAAA,MAAAA,CAAO,MAAMF,QAAAA,CAAAA;AACtB;AACF;;;IA7BWG,UAAY,EAAA","file":"base.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Serializable } from \"@/internals/serializable.js\";\nimport type { ReActAgentTemplates } from \"@/agents/react/types.js\";\nimport {\n ReActAgentRunIteration,\n ReActAgentCallbacks,\n ReActAgentIterationToolResult,\n ReActAgentMeta,\n ReActAgentRunInput,\n ReActAgentRunOptions,\n} from \"@/agents/react/types.js\";\nimport type { ReActAgent, ReActAgentInput } from \"@/agents/react/agent.js\";\nimport { RetryCounter } from \"@/internals/helpers/counter.js\";\nimport { AgentError } from \"@/agents/base.js\";\nimport { shallowCopy } from \"@/serializer/utils.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\nimport { mapObj } from \"@/internals/helpers/object.js\";\nimport { PromptTemplate } from \"@/template.js\";\n\nexport interface ReActAgentRunnerLLMInput {\n meta: ReActAgentMeta;\n signal: AbortSignal;\n emitter: Emitter<ReActAgentCallbacks>;\n}\n\nexport interface ReActAgentRunnerToolInput {\n state: ReActAgentIterationToolResult;\n meta: ReActAgentMeta;\n signal: AbortSignal;\n emitter: Emitter<ReActAgentCallbacks>;\n}\n\nexport abstract class BaseRunner extends Serializable {\n public memory!: BaseMemory;\n public readonly iterations: ReActAgentRunIteration[] = [];\n protected readonly failedAttemptsCounter: RetryCounter;\n\n constructor(\n protected readonly input: ReActAgentInput,\n protected readonly options: ReActAgentRunOptions,\n protected readonly run: GetRunContext<ReActAgent>,\n ) {\n super();\n this.failedAttemptsCounter = new RetryCounter(options?.execution?.totalMaxRetries, AgentError);\n }\n\n async createIteration() {\n const meta: ReActAgentMeta = { iteration: this.iterations.length + 1 };\n const maxIterations = this.options?.execution?.maxIterations ?? Infinity;\n\n if (meta.iteration > maxIterations) {\n throw new AgentError(\n `Agent was not able to resolve the task in ${maxIterations} iterations.`,\n [],\n {\n isFatal: true,\n isRetryable: false,\n context: { iterations: this.iterations.map((iteration) => iteration.state) },\n },\n );\n }\n\n const emitter = this.run.emitter.child({ groupId: `iteration-${meta.iteration}` });\n const iteration = await this.llm({ emitter, signal: this.run.signal, meta });\n this.iterations.push(iteration);\n\n return {\n emitter,\n state: iteration.state,\n meta,\n signal: this.run.signal,\n };\n }\n\n async init(input: ReActAgentRunInput) {\n this.memory = await this.initMemory(input);\n }\n\n abstract llm(input: ReActAgentRunnerLLMInput): Promise<ReActAgentRunIteration>;\n\n abstract tool(input: ReActAgentRunnerToolInput): Promise<{ output: string; success: boolean }>;\n\n public abstract get defaultTemplates(): ReActAgentTemplates;\n\n @Cache({ enumerable: false })\n public get templates(): ReActAgentTemplates {\n const overrides = this.input.templates ?? {};\n\n return mapObj(this.defaultTemplates)(\n (key, defaultTemplate: ReActAgentTemplates[typeof key]) => {\n const override = overrides[key] ?? defaultTemplate;\n if (override instanceof PromptTemplate) {\n return override;\n }\n return override(defaultTemplate) ?? defaultTemplate;\n },\n );\n }\n\n protected abstract initMemory(input: ReActAgentRunInput): Promise<BaseMemory>;\n\n createSnapshot() {\n return {\n input: shallowCopy(this.input),\n options: shallowCopy(this.options),\n memory: this.memory,\n failedAttemptsCounter: this.failedAttemptsCounter,\n };\n }\n\n loadSnapshot(snapshot: ReturnType<typeof this.createSnapshot>) {\n Object.assign(this, snapshot);\n }\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import '../../../parsers/linePrefix.cjs';
2
2
  import '../types.cjs';
3
3
  import '../../../internals/serializable.cjs';
4
- export { B as BaseRunner, a as BeeRunnerLLMInput, b as BeeRunnerToolInput } from '../../../agent-BZ-_ATuJ.cjs';
4
+ export { B as BaseRunner, b as ReActAgentRunnerLLMInput, c as ReActAgentRunnerToolInput } from '../../../agent-COg8SPbf.cjs';
5
5
  import '../../../internals/helpers/counter.cjs';
6
6
  import '../../../memory/base.cjs';
7
7
  import '../../../context.cjs';
8
- import '../../../emitter-C9EN5B0j.cjs';
8
+ import '../../../emitter-BWtGHYn0.cjs';
9
9
  import '../../../parsers/field.cjs';
10
10
  import 'zod';
11
11
  import '@streamparser/json';
@@ -29,4 +29,4 @@ import '../../../backend/chat.cjs';
29
29
  import '../../../backend/utils.cjs';
30
30
  import '../../../backend/constants.cjs';
31
31
  import '@ai-sdk/provider';
32
- import '../../../base-daM6fHUP.cjs';
32
+ import '../../../base-Csr9guq2.cjs';
@@ -1,11 +1,11 @@
1
1
  import '../../../parsers/linePrefix.js';
2
2
  import '../types.js';
3
3
  import '../../../internals/serializable.js';
4
- export { B as BaseRunner, a as BeeRunnerLLMInput, b as BeeRunnerToolInput } from '../../../agent-BqoZ6FbM.js';
4
+ export { B as BaseRunner, b as ReActAgentRunnerLLMInput, c as ReActAgentRunnerToolInput } from '../../../agent-Dv5YSk8H.js';
5
5
  import '../../../internals/helpers/counter.js';
6
6
  import '../../../memory/base.js';
7
7
  import '../../../context.js';
8
- import '../../../emitter-BxVxGBbJ.js';
8
+ import '../../../emitter-l0W9gC1A.js';
9
9
  import '../../../parsers/field.js';
10
10
  import 'zod';
11
11
  import '@streamparser/json';
@@ -29,4 +29,4 @@ import '../../../backend/chat.js';
29
29
  import '../../../backend/utils.js';
30
30
  import '../../../backend/constants.js';
31
31
  import '@ai-sdk/provider';
32
- import '../../../base-mmG-8Pk9.js';
32
+ import '../../../base-DHhpWHQm.js';
@@ -92,7 +92,7 @@ _ts_decorate([
92
92
  Cache({
93
93
  enumerable: false
94
94
  }),
95
- _ts_metadata("design:type", typeof BeeAgentTemplates === "undefined" ? Object : BeeAgentTemplates),
95
+ _ts_metadata("design:type", typeof ReActAgentTemplates === "undefined" ? Object : ReActAgentTemplates),
96
96
  _ts_metadata("design:paramtypes", [])
97
97
  ], BaseRunner.prototype, "templates", null);
98
98
 
@@ -1 +1 @@
1
- {"version":3,"sources":["base.ts"],"names":["BaseRunner","Serializable","memory","iterations","failedAttemptsCounter","constructor","input","options","run","RetryCounter","execution","totalMaxRetries","AgentError","createIteration","meta","iteration","length","maxIterations","Infinity","isFatal","isRetryable","context","map","state","emitter","child","groupId","llm","signal","push","init","initMemory","templates","overrides","mapObj","defaultTemplates","key","defaultTemplate","override","PromptTemplate","createSnapshot","shallowCopy","loadSnapshot","snapshot","Object","assign","enumerable"],"mappings":";;;;;;;;;;AAcC,SAAA,YAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GAAA,EAAA,IAAA,EAAA;;;;;;AAAA,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA;;;;;AAoCM,MAAeA,mBAAmBC,YAAAA,CAAAA;EAlDzC;;;;;;AAmDSC,EAAAA,MAAAA;AACSC,EAAAA,UAAAA;AACGC,EAAAA,qBAAAA;EAEnBC,WACqBC,C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,EAAA","file":"base.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Serializable } from \"@/internals/serializable.js\";\nimport type { BeeAgentTemplates } from \"@/agents/bee/types.js\";\nimport {\n BeeAgentRunIteration,\n BeeCallbacks,\n BeeIterationToolResult,\n BeeMeta,\n BeeRunInput,\n BeeRunOptions,\n} from \"@/agents/bee/types.js\";\nimport type { BeeAgent, BeeInput } from \"@/agents/bee/agent.js\";\nimport { RetryCounter } from \"@/internals/helpers/counter.js\";\nimport { AgentError } from \"@/agents/base.js\";\nimport { shallowCopy } from \"@/serializer/utils.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\nimport { mapObj } from \"@/internals/helpers/object.js\";\nimport { PromptTemplate } from \"@/template.js\";\n\nexport interface BeeRunnerLLMInput {\n meta: BeeMeta;\n signal: AbortSignal;\n emitter: Emitter<BeeCallbacks>;\n}\n\nexport interface BeeRunnerToolInput {\n state: BeeIterationToolResult;\n meta: BeeMeta;\n signal: AbortSignal;\n emitter: Emitter<BeeCallbacks>;\n}\n\nexport abstract class BaseRunner extends Serializable {\n public memory!: BaseMemory;\n public readonly iterations: BeeAgentRunIteration[] = [];\n protected readonly failedAttemptsCounter: RetryCounter;\n\n constructor(\n protected readonly input: BeeInput,\n protected readonly options: BeeRunOptions,\n protected readonly run: GetRunContext<BeeAgent>,\n ) {\n super();\n this.failedAttemptsCounter = new RetryCounter(options?.execution?.totalMaxRetries, AgentError);\n }\n\n async createIteration() {\n const meta: BeeMeta = { iteration: this.iterations.length + 1 };\n const maxIterations = this.options?.execution?.maxIterations ?? Infinity;\n\n if (meta.iteration > maxIterations) {\n throw new AgentError(\n `Agent was not able to resolve the task in ${maxIterations} iterations.`,\n [],\n {\n isFatal: true,\n isRetryable: false,\n context: { iterations: this.iterations.map((iteration) => iteration.state) },\n },\n );\n }\n\n const emitter = this.run.emitter.child({ groupId: `iteration-${meta.iteration}` });\n const iteration = await this.llm({ emitter, signal: this.run.signal, meta });\n this.iterations.push(iteration);\n\n return {\n emitter,\n state: iteration.state,\n meta,\n signal: this.run.signal,\n };\n }\n\n async init(input: BeeRunInput) {\n this.memory = await this.initMemory(input);\n }\n\n abstract llm(input: BeeRunnerLLMInput): Promise<BeeAgentRunIteration>;\n\n abstract tool(input: BeeRunnerToolInput): Promise<{ output: string; success: boolean }>;\n\n public abstract get defaultTemplates(): BeeAgentTemplates;\n\n @Cache({ enumerable: false })\n public get templates(): BeeAgentTemplates {\n const overrides = this.input.templates ?? {};\n\n return mapObj(this.defaultTemplates)((key, defaultTemplate: BeeAgentTemplates[typeof key]) => {\n const override = overrides[key] ?? defaultTemplate;\n if (override instanceof PromptTemplate) {\n return override;\n }\n return override(defaultTemplate) ?? defaultTemplate;\n });\n }\n\n protected abstract initMemory(input: BeeRunInput): Promise<BaseMemory>;\n\n createSnapshot() {\n return {\n input: shallowCopy(this.input),\n options: shallowCopy(this.options),\n memory: this.memory,\n failedAttemptsCounter: this.failedAttemptsCounter,\n };\n }\n\n loadSnapshot(snapshot: ReturnType<typeof this.createSnapshot>) {\n Object.assign(this, snapshot);\n }\n}\n"]}
1
+ {"version":3,"sources":["base.ts"],"names":["BaseRunner","Serializable","memory","iterations","failedAttemptsCounter","constructor","input","options","run","RetryCounter","execution","totalMaxRetries","AgentError","createIteration","meta","iteration","length","maxIterations","Infinity","isFatal","isRetryable","context","map","state","emitter","child","groupId","llm","signal","push","init","initMemory","templates","overrides","mapObj","defaultTemplates","key","defaultTemplate","override","PromptTemplate","createSnapshot","shallowCopy","loadSnapshot","snapshot","Object","assign","enumerable"],"mappings":";;;;;;;;;;AAcC,SAAA,YAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GAAA,EAAA,IAAA,EAAA;;;;;;AAAA,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA;;;;;AAoCM,MAAeA,mBAAmBC,YAAAA,CAAAA;EAlDzC;;;;;;AAmDSC,EAAAA,MAAAA;AACSC,EAAAA,UAAAA;AACGC,EAAAA,qBAAAA;EAEnBC,WACqBC,CAAAA,KAAAA,EACAC,SACAC,GACnB,EAAA;AACA,IAAA,KAAA,EAAK,EAAA,IAAA,CAJcF,KAAAA,GAAAA,KAAAA,EAAAA,IACAC,CAAAA,OAAAA,GAAAA,OAAAA,EAAAA,IAAAA,CACAC,GAAAA,GAAAA,GAAAA,EAAAA,IANLL,CAAAA,UAAAA,GAAuC,EAAA;AASrD,IAAA,IAAA,CAAKC,wBAAwB,IAAIK,YAAAA,CAAaF,OAASG,EAAAA,SAAAA,EAAWC,iBAAiBC,UAAAA,CAAAA;AACrF;AAEA,EAAA,MAAMC,eAAkB,GAAA;AACtB,IAAA,MAAMC,IAAuB,GAAA;MAAEC,SAAW,EAAA,IAAA,CAAKZ,WAAWa,MAAS,GAAA;AAAE,KAAA;AACrE,IAAA,MAAMC,aAAgB,GAAA,IAAA,CAAKV,OAASG,EAAAA,SAAAA,EAAWO,aAAiBC,IAAAA,QAAAA;AAEhE,IAAIJ,IAAAA,IAAAA,CAAKC,YAAYE,aAAe,EAAA;AAClC,MAAA,MAAM,IAAIL,UACR,CAAA,CAAA,0CAAA,EAA6CK,aAAAA,CAAAA,YAAAA,CAAAA,EAC7C,EACA,EAAA;QACEE,OAAS,EAAA,IAAA;QACTC,WAAa,EAAA,KAAA;QACbC,OAAS,EAAA;AAAElB,UAAAA,UAAAA,EAAY,KAAKA,UAAWmB,CAAAA,GAAAA,CAAI,CAACP,UAAAA,KA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;MACLlC,KAAOmC,EAAAA,WAAAA,CAAY,KAAKnC,KAAK,CAAA;MAC7BC,OAASkC,EAAAA,WAAAA,CAAY,KAAKlC,OAAO,CAAA;AACjCL,MAAAA,MAAAA,EAAQ,IAAKA,CAAAA,MAAAA;AACbE,MAAAA,qBAAAA,EAAuB,IAAKA,CAAAA;AAC9B,KAAA;AACF;AAEAsC,EAAAA,YAAAA,CAAaC,QAAkD,EAAA;AAC7DC,IAAOC,MAAAA,CAAAA,MAAAA,CAAO,MAAMF,QAAAA,CAAAA;AACtB;AACF;;;IA7BWG,UAAY,EAAA","file":"base.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Serializable } from \"@/internals/serializable.js\";\nimport type { ReActAgentTemplates } from \"@/agents/react/types.js\";\nimport {\n ReActAgentRunIteration,\n ReActAgentCallbacks,\n ReActAgentIterationToolResult,\n ReActAgentMeta,\n ReActAgentRunInput,\n ReActAgentRunOptions,\n} from \"@/agents/react/types.js\";\nimport type { ReActAgent, ReActAgentInput } from \"@/agents/react/agent.js\";\nimport { RetryCounter } from \"@/internals/helpers/counter.js\";\nimport { AgentError } from \"@/agents/base.js\";\nimport { shallowCopy } from \"@/serializer/utils.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { Emitter } from \"@/emitter/emitter.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\nimport { mapObj } from \"@/internals/helpers/object.js\";\nimport { PromptTemplate } from \"@/template.js\";\n\nexport interface ReActAgentRunnerLLMInput {\n meta: ReActAgentMeta;\n signal: AbortSignal;\n emitter: Emitter<ReActAgentCallbacks>;\n}\n\nexport interface ReActAgentRunnerToolInput {\n state: ReActAgentIterationToolResult;\n meta: ReActAgentMeta;\n signal: AbortSignal;\n emitter: Emitter<ReActAgentCallbacks>;\n}\n\nexport abstract class BaseRunner extends Serializable {\n public memory!: BaseMemory;\n public readonly iterations: ReActAgentRunIteration[] = [];\n protected readonly failedAttemptsCounter: RetryCounter;\n\n constructor(\n protected readonly input: ReActAgentInput,\n protected readonly options: ReActAgentRunOptions,\n protected readonly run: GetRunContext<ReActAgent>,\n ) {\n super();\n this.failedAttemptsCounter = new RetryCounter(options?.execution?.totalMaxRetries, AgentError);\n }\n\n async createIteration() {\n const meta: ReActAgentMeta = { iteration: this.iterations.length + 1 };\n const maxIterations = this.options?.execution?.maxIterations ?? Infinity;\n\n if (meta.iteration > maxIterations) {\n throw new AgentError(\n `Agent was not able to resolve the task in ${maxIterations} iterations.`,\n [],\n {\n isFatal: true,\n isRetryable: false,\n context: { iterations: this.iterations.map((iteration) => iteration.state) },\n },\n );\n }\n\n const emitter = this.run.emitter.child({ groupId: `iteration-${meta.iteration}` });\n const iteration = await this.llm({ emitter, signal: this.run.signal, meta });\n this.iterations.push(iteration);\n\n return {\n emitter,\n state: iteration.state,\n meta,\n signal: this.run.signal,\n };\n }\n\n async init(input: ReActAgentRunInput) {\n this.memory = await this.initMemory(input);\n }\n\n abstract llm(input: ReActAgentRunnerLLMInput): Promise<ReActAgentRunIteration>;\n\n abstract tool(input: ReActAgentRunnerToolInput): Promise<{ output: string; success: boolean }>;\n\n public abstract get defaultTemplates(): ReActAgentTemplates;\n\n @Cache({ enumerable: false })\n public get templates(): ReActAgentTemplates {\n const overrides = this.input.templates ?? {};\n\n return mapObj(this.defaultTemplates)(\n (key, defaultTemplate: ReActAgentTemplates[typeof key]) => {\n const override = overrides[key] ?? defaultTemplate;\n if (override instanceof PromptTemplate) {\n return override;\n }\n return override(defaultTemplate) ?? defaultTemplate;\n },\n );\n }\n\n protected abstract initMemory(input: ReActAgentRunInput): Promise<BaseMemory>;\n\n createSnapshot() {\n return {\n input: shallowCopy(this.input),\n options: shallowCopy(this.options),\n memory: this.memory,\n failedAttemptsCounter: this.failedAttemptsCounter,\n };\n }\n\n loadSnapshot(snapshot: ReturnType<typeof this.createSnapshot>) {\n Object.assign(this, snapshot);\n }\n}\n"]}