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
@@ -2,14 +2,14 @@
2
2
 
3
3
  var prompts_cjs = require('../../prompts.cjs');
4
4
 
5
- const DeepThinkBeeAssistantPrompt = prompts_cjs.BeeAssistantPrompt.fork((config) => {
5
+ const DeepThinkReActAgentAssistantPrompt = prompts_cjs.ReActAgentAssistantPrompt.fork((config) => {
6
6
  config.template = `{{#thought}}<think>{{.}}</think>
7
7
 
8
8
  {{/thought}}{{#toolName}}Tool Name: {{.}}
9
9
  {{/toolName}}{{#toolInput}}Tool Input: {{.}}
10
10
  {{/toolInput}}{{#finalAnswer}}Response: {{.}}{{/finalAnswer}}`;
11
11
  });
12
- const DeepThinkBeeSystemPrompt = prompts_cjs.BeeSystemPrompt.fork((config) => {
12
+ const DeepThinkReActAgentSystemPrompt = prompts_cjs.ReActAgentSystemPrompt.fork((config) => {
13
13
  config.defaults.instructions = "";
14
14
  config.functions.formatDate = function() {
15
15
  const date = this.createdAt ? new Date(this.createdAt) : /* @__PURE__ */ new Date();
@@ -57,36 +57,36 @@ The current date and time is: {{formatDate}}
57
57
  {{/instructions}}
58
58
  `;
59
59
  });
60
- const DeepThinkBeeSchemaErrorPrompt = prompts_cjs.BeeSchemaErrorPrompt.fork((config) => {
60
+ const DeepThinkReActAgentSchemaErrorPrompt = prompts_cjs.ReActAgentSchemaErrorPrompt.fork((config) => {
61
61
  config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.
62
62
  You communicate only in instruction lines. Valid instruction lines are 'Tool Name:' and then 'Tool Input:', or 'Response:'.`;
63
63
  });
64
- const DeepThinkBeeUserPrompt = prompts_cjs.BeeUserPrompt.fork((config) => {
64
+ const DeepThinkReActAgentUserPrompt = prompts_cjs.ReActAgentUserPrompt.fork((config) => {
65
65
  config.template = `{{input}}`;
66
66
  });
67
- const DeepThinkBeeToolNotFoundPrompt = prompts_cjs.BeeToolNotFoundPrompt.fork((config) => {
67
+ const DeepThinkReActAgentToolNotFoundPrompt = prompts_cjs.ReActAgentToolNotFoundPrompt.fork((config) => {
68
68
  config.template = `Tool does not exist!
69
69
  {{#tools.length}}
70
70
  Use one of the following tools: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}
71
71
  {{/tools.length}}`;
72
72
  });
73
- const DeepThinkBeeToolErrorPrompt = prompts_cjs.BeeToolErrorPrompt.fork((config) => {
73
+ const DeepThinkReActAgentToolErrorPrompt = prompts_cjs.ReActAgentToolErrorPrompt.fork((config) => {
74
74
  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.
75
75
 
76
76
  {{reason}}`;
77
77
  });
78
- const DeepThinkBeeToolInputErrorPrompt = prompts_cjs.BeeToolInputErrorPrompt.fork((config) => {
78
+ const DeepThinkReActAgentToolInputErrorPrompt = prompts_cjs.ReActAgentToolInputErrorPrompt.fork((config) => {
79
79
  config.template = `{{reason}}
80
80
 
81
81
  HINT: 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.`;
82
82
  });
83
83
 
84
- exports.DeepThinkBeeAssistantPrompt = DeepThinkBeeAssistantPrompt;
85
- exports.DeepThinkBeeSchemaErrorPrompt = DeepThinkBeeSchemaErrorPrompt;
86
- exports.DeepThinkBeeSystemPrompt = DeepThinkBeeSystemPrompt;
87
- exports.DeepThinkBeeToolErrorPrompt = DeepThinkBeeToolErrorPrompt;
88
- exports.DeepThinkBeeToolInputErrorPrompt = DeepThinkBeeToolInputErrorPrompt;
89
- exports.DeepThinkBeeToolNotFoundPrompt = DeepThinkBeeToolNotFoundPrompt;
90
- exports.DeepThinkBeeUserPrompt = DeepThinkBeeUserPrompt;
84
+ exports.DeepThinkReActAgentAssistantPrompt = DeepThinkReActAgentAssistantPrompt;
85
+ exports.DeepThinkReActAgentSchemaErrorPrompt = DeepThinkReActAgentSchemaErrorPrompt;
86
+ exports.DeepThinkReActAgentSystemPrompt = DeepThinkReActAgentSystemPrompt;
87
+ exports.DeepThinkReActAgentToolErrorPrompt = DeepThinkReActAgentToolErrorPrompt;
88
+ exports.DeepThinkReActAgentToolInputErrorPrompt = DeepThinkReActAgentToolInputErrorPrompt;
89
+ exports.DeepThinkReActAgentToolNotFoundPrompt = DeepThinkReActAgentToolNotFoundPrompt;
90
+ exports.DeepThinkReActAgentUserPrompt = DeepThinkReActAgentUserPrompt;
91
91
  //# sourceMappingURL=prompts.cjs.map
92
92
  //# sourceMappingURL=prompts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["prompts.ts"],"names":["DeepThinkReActAgentAssistantPrompt","ReActAgentAssistantPrompt","fork","config","template","DeepThinkReActAgentSystemPrompt","ReActAgentSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","DeepThinkReActAgentSchemaErrorPrompt","ReActAgentSchemaErrorPrompt","DeepThinkReActAgentUserPrompt","ReActAgentUserPrompt","DeepThinkReActAgentToolNotFoundPrompt","ReActAgentToolNotFoundPrompt","DeepThinkReActAgentToolErrorPrompt","ReActAgentToolErrorPrompt","DeepThinkReActAgentToolInputErrorPrompt","ReActAgentToolInputErrorPrompt"],"mappings":";;;;AA0BO,MAAMA,kCAAqCC,GAAAA,qCAAAA,CAA0BC,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAChFA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;;AACpB,CAAA;AAEO,MAAMC,+BAAkCC,GAAAA,kCAAAA,CAAuBJ,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAC1EA,EAAAA,MAAAA,CAAOI,SAASC,YAAe,GAAA,EAAA;AAC/BL,EAAOM,MAAAA,CAAAA,SAAAA,CAAUC,aAAa,WAAA;AAC5B,IAAMC,MAAAA,IAAAA,GAAO,KAAKC,SAAY,GAAA,IAAIC,KAAK,IAAKD,CAAAA,SAAS,CAAI,mBAAA,IAAIC,IAAAA,EAAAA;AAC7D,IAAO,OAAA,IAAIC,IAAKC,CAAAA,cAAAA,CAAe,OAAS,EAAA;MACtCC,SAAW,EAAA,MAAA;MACXC,SAAW,EAAA;KACb,CAAA,CAAGC,OAAOP,IAAAA,CAAAA;AACZ,GAAA;AACAR,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCpB,CAAA;AAEO,MAAMe,oCAAuCC,GAAAA,uCAAAA,CAA4BlB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACpFA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;AAEpB,CAAA;AAEO,MAAMiB,6BAAgCC,GAAAA,gCAAAA,CAAqBpB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACtEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA,SAAA,CAAA;AACpB,CAAA;AAEO,MAAMmB,qCAAwCC,GAAAA,wCAAAA,CAA6BtB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACtFA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;AAIpB,CAAA;AAEO,MAAMqB,kCAAqCC,GAAAA,qCAAAA,CAA0BxB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAChFA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;AAGpB,CAAA;AAEO,MAAMuB,uCAA0CC,GAAAA,0CAAAA,CAA+B1B,IACpF,CAAA,CAACC,MAAAA,KAAAA;AACCA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;AAGpB,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 {\n ReActAgentAssistantPrompt,\n ReActAgentSchemaErrorPrompt,\n ReActAgentSystemPrompt,\n ReActAgentToolErrorPrompt,\n ReActAgentToolInputErrorPrompt,\n ReActAgentToolNotFoundPrompt,\n ReActAgentUserPrompt,\n} from \"@/agents/react/prompts.js\";\n\nexport const DeepThinkReActAgentAssistantPrompt = ReActAgentAssistantPrompt.fork((config) => {\n config.template = `{{#thought}}<think>{{.}}</think>\\n\\n{{/thought}}{{#toolName}}Tool Name: {{.}}\\n{{/toolName}}{{#toolInput}}Tool Input: {{.}}\\n{{/toolInput}}{{#finalAnswer}}Response: {{.}}{{/finalAnswer}}`;\n});\n\nexport const DeepThinkReActAgentSystemPrompt = 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.\n{{#tools.length}}\n# Tools\nYou have access to a set of tools that can be used to retrieve information and perform actions.\n\n{{#tools}}\nTool Name: {{name}}\nTool Description: {{description}}\nTool Input Schema: {{schema}}\n\n{{/tools}}\n\n## Guidelines for using tools\n- Do not directly mention the existence of tools. Act as if these are your inherent capabilities.\n- Do not speculate about specific numbers or facts, obtain them using tools.\n- The tool responses appear as if provided by the user, but in reality they are inserted externally and the user does not see them. Act as if the tool responses were obtained by your inherent capabilities.\n- When you don't have enough information, ask the user for details. Make reasonable assumptions. Do not ask the user to directly provide tool input, ask like you would in a normal conversation.\n- If you need to call multiple tools, simply think out what tools you need to call, and then call the first one and end your message. Don't worry, you will be given opportunity to call as many tools as you want.\n\n# Assistant message structure\n- After thinking, write a message that has to follow a rigid structure. Deviations will result in an error.\n- If you don't need to use a tool, already have all the information and want to answer the user's query, or you want to ask the user for more information, start the message with 'Response:', like this:\nResponse: [response message sent to the user]\n- If you want to call a tool, start your message with 'Tool Name:', followed by the tool name, and then on the next line 'Tool Input:', followed by the tool input JSON, like this:\nTool Name: [name of the tool, as listed above]\nTool Input: [JSON object, following the schema defined above]\n- DO NOT make the line prefixes ('Response:', 'Tool Name:', etc.) **bold**, always keep them plain.\n- As soon as you write these lines, you will be provided the tool result. You will then have the opportunity to call more tools, or to finalize by sending a 'Response:' to the user.\n{{/tools.length}}\n\n# Additional context\nThe current date and time is: {{formatDate}}\n\n{{#instructions}} \n# Additional instructions\n{{.}} \n{{/instructions}}\n`;\n});\n\nexport const DeepThinkReActAgentSchemaErrorPrompt = 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 'Tool Name:' and then 'Tool Input:', or 'Response:'.`;\n});\n\nexport const DeepThinkReActAgentUserPrompt = ReActAgentUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const DeepThinkReActAgentToolNotFoundPrompt = 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 DeepThinkReActAgentToolErrorPrompt = 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 DeepThinkReActAgentToolInputErrorPrompt = 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"]}
@@ -21,7 +21,7 @@ import 'ajv';
21
21
  * See the License for the specific language governing permissions and
22
22
  * limitations under the License.
23
23
  */
24
- declare const GraniteBeeAssistantPrompt: PromptTemplate<zod.ZodObject<{
24
+ declare const DeepThinkReActAgentAssistantPrompt: PromptTemplate<zod.ZodObject<{
25
25
  thought: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
26
26
  toolName: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
27
27
  toolInput: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
@@ -40,7 +40,7 @@ declare const GraniteBeeAssistantPrompt: PromptTemplate<zod.ZodObject<{
40
40
  toolOutput?: string[] | undefined;
41
41
  finalAnswer?: string[] | undefined;
42
42
  }>>;
43
- declare const GraniteBeeSystemPrompt: PromptTemplate<zod.ZodObject<{
43
+ declare const DeepThinkReActAgentSystemPrompt: PromptTemplate<zod.ZodObject<{
44
44
  instructions: zod.ZodDefault<zod.ZodString>;
45
45
  tools: zod.ZodArray<zod.ZodObject<{
46
46
  name: zod.ZodString;
@@ -73,8 +73,8 @@ declare const GraniteBeeSystemPrompt: PromptTemplate<zod.ZodObject<{
73
73
  createdAt?: string | null | undefined;
74
74
  instructions?: string | undefined;
75
75
  }>>;
76
- declare const GraniteBeeSchemaErrorPrompt: PromptTemplate<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
77
- declare const GraniteBeeUserPrompt: PromptTemplate<zod.ZodObject<{
76
+ declare const DeepThinkReActAgentSchemaErrorPrompt: PromptTemplate<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
77
+ declare const DeepThinkReActAgentUserPrompt: PromptTemplate<zod.ZodObject<{
78
78
  input: zod.ZodString;
79
79
  meta: zod.ZodOptional<zod.ZodObject<{
80
80
  createdAt: zod.ZodOptional<zod.ZodString>;
@@ -102,7 +102,7 @@ declare const GraniteBeeUserPrompt: PromptTemplate<zod.ZodObject<{
102
102
  createdAt: zod.ZodOptional<zod.ZodString>;
103
103
  }, zod.ZodTypeAny, "passthrough">>>;
104
104
  }, zod.ZodTypeAny, "passthrough">>>;
105
- declare const GraniteBeeToolNotFoundPrompt: PromptTemplate<zod.ZodObject<{
105
+ declare const DeepThinkReActAgentToolNotFoundPrompt: PromptTemplate<zod.ZodObject<{
106
106
  tools: zod.ZodArray<zod.ZodObject<{
107
107
  name: zod.ZodString;
108
108
  }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
@@ -127,14 +127,14 @@ declare const GraniteBeeToolNotFoundPrompt: PromptTemplate<zod.ZodObject<{
127
127
  name: zod.ZodString;
128
128
  }, zod.ZodTypeAny, "passthrough">>, "many">;
129
129
  }, zod.ZodTypeAny, "passthrough">>>;
130
- declare const GraniteBeeToolErrorPrompt: PromptTemplate<zod.ZodObject<{
130
+ declare const DeepThinkReActAgentToolErrorPrompt: PromptTemplate<zod.ZodObject<{
131
131
  reason: zod.ZodString;
132
132
  }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
133
133
  reason: zod.ZodString;
134
134
  }, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
135
135
  reason: zod.ZodString;
136
136
  }, zod.ZodTypeAny, "passthrough">>>;
137
- declare const GraniteBeeToolInputErrorPrompt: PromptTemplate<zod.ZodObject<{
137
+ declare const DeepThinkReActAgentToolInputErrorPrompt: PromptTemplate<zod.ZodObject<{
138
138
  reason: zod.ZodString;
139
139
  }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
140
140
  reason: zod.ZodString;
@@ -142,4 +142,4 @@ declare const GraniteBeeToolInputErrorPrompt: PromptTemplate<zod.ZodObject<{
142
142
  reason: zod.ZodString;
143
143
  }, zod.ZodTypeAny, "passthrough">>>;
144
144
 
145
- export { GraniteBeeAssistantPrompt, GraniteBeeSchemaErrorPrompt, GraniteBeeSystemPrompt, GraniteBeeToolErrorPrompt, GraniteBeeToolInputErrorPrompt, GraniteBeeToolNotFoundPrompt, GraniteBeeUserPrompt };
145
+ export { DeepThinkReActAgentAssistantPrompt, DeepThinkReActAgentSchemaErrorPrompt, DeepThinkReActAgentSystemPrompt, DeepThinkReActAgentToolErrorPrompt, DeepThinkReActAgentToolInputErrorPrompt, DeepThinkReActAgentToolNotFoundPrompt, DeepThinkReActAgentUserPrompt };
@@ -21,7 +21,7 @@ import 'ajv';
21
21
  * See the License for the specific language governing permissions and
22
22
  * limitations under the License.
23
23
  */
24
- declare const GraniteBeeAssistantPrompt: PromptTemplate<zod.ZodObject<{
24
+ declare const DeepThinkReActAgentAssistantPrompt: PromptTemplate<zod.ZodObject<{
25
25
  thought: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
26
26
  toolName: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
27
27
  toolInput: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
@@ -40,7 +40,7 @@ declare const GraniteBeeAssistantPrompt: PromptTemplate<zod.ZodObject<{
40
40
  toolOutput?: string[] | undefined;
41
41
  finalAnswer?: string[] | undefined;
42
42
  }>>;
43
- declare const GraniteBeeSystemPrompt: PromptTemplate<zod.ZodObject<{
43
+ declare const DeepThinkReActAgentSystemPrompt: PromptTemplate<zod.ZodObject<{
44
44
  instructions: zod.ZodDefault<zod.ZodString>;
45
45
  tools: zod.ZodArray<zod.ZodObject<{
46
46
  name: zod.ZodString;
@@ -73,8 +73,8 @@ declare const GraniteBeeSystemPrompt: PromptTemplate<zod.ZodObject<{
73
73
  createdAt?: string | null | undefined;
74
74
  instructions?: string | undefined;
75
75
  }>>;
76
- declare const GraniteBeeSchemaErrorPrompt: PromptTemplate<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
77
- declare const GraniteBeeUserPrompt: PromptTemplate<zod.ZodObject<{
76
+ declare const DeepThinkReActAgentSchemaErrorPrompt: PromptTemplate<zod.ZodObject<{}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{}, zod.ZodTypeAny, "passthrough">>>;
77
+ declare const DeepThinkReActAgentUserPrompt: PromptTemplate<zod.ZodObject<{
78
78
  input: zod.ZodString;
79
79
  meta: zod.ZodOptional<zod.ZodObject<{
80
80
  createdAt: zod.ZodOptional<zod.ZodString>;
@@ -102,7 +102,7 @@ declare const GraniteBeeUserPrompt: PromptTemplate<zod.ZodObject<{
102
102
  createdAt: zod.ZodOptional<zod.ZodString>;
103
103
  }, zod.ZodTypeAny, "passthrough">>>;
104
104
  }, zod.ZodTypeAny, "passthrough">>>;
105
- declare const GraniteBeeToolNotFoundPrompt: PromptTemplate<zod.ZodObject<{
105
+ declare const DeepThinkReActAgentToolNotFoundPrompt: PromptTemplate<zod.ZodObject<{
106
106
  tools: zod.ZodArray<zod.ZodObject<{
107
107
  name: zod.ZodString;
108
108
  }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
@@ -127,14 +127,14 @@ declare const GraniteBeeToolNotFoundPrompt: PromptTemplate<zod.ZodObject<{
127
127
  name: zod.ZodString;
128
128
  }, zod.ZodTypeAny, "passthrough">>, "many">;
129
129
  }, zod.ZodTypeAny, "passthrough">>>;
130
- declare const GraniteBeeToolErrorPrompt: PromptTemplate<zod.ZodObject<{
130
+ declare const DeepThinkReActAgentToolErrorPrompt: PromptTemplate<zod.ZodObject<{
131
131
  reason: zod.ZodString;
132
132
  }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
133
133
  reason: zod.ZodString;
134
134
  }, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
135
135
  reason: zod.ZodString;
136
136
  }, zod.ZodTypeAny, "passthrough">>>;
137
- declare const GraniteBeeToolInputErrorPrompt: PromptTemplate<zod.ZodObject<{
137
+ declare const DeepThinkReActAgentToolInputErrorPrompt: PromptTemplate<zod.ZodObject<{
138
138
  reason: zod.ZodString;
139
139
  }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
140
140
  reason: zod.ZodString;
@@ -142,4 +142,4 @@ declare const GraniteBeeToolInputErrorPrompt: PromptTemplate<zod.ZodObject<{
142
142
  reason: zod.ZodString;
143
143
  }, zod.ZodTypeAny, "passthrough">>>;
144
144
 
145
- export { GraniteBeeAssistantPrompt, GraniteBeeSchemaErrorPrompt, GraniteBeeSystemPrompt, GraniteBeeToolErrorPrompt, GraniteBeeToolInputErrorPrompt, GraniteBeeToolNotFoundPrompt, GraniteBeeUserPrompt };
145
+ export { DeepThinkReActAgentAssistantPrompt, DeepThinkReActAgentSchemaErrorPrompt, DeepThinkReActAgentSystemPrompt, DeepThinkReActAgentToolErrorPrompt, DeepThinkReActAgentToolInputErrorPrompt, DeepThinkReActAgentToolNotFoundPrompt, DeepThinkReActAgentUserPrompt };
@@ -1,13 +1,13 @@
1
- import { BeeAssistantPrompt, BeeSystemPrompt, BeeSchemaErrorPrompt, BeeUserPrompt, BeeToolNotFoundPrompt, BeeToolErrorPrompt, BeeToolInputErrorPrompt } from '../../prompts.js';
1
+ import { ReActAgentAssistantPrompt, ReActAgentSystemPrompt, ReActAgentSchemaErrorPrompt, ReActAgentUserPrompt, ReActAgentToolNotFoundPrompt, ReActAgentToolErrorPrompt, ReActAgentToolInputErrorPrompt } from '../../prompts.js';
2
2
 
3
- const DeepThinkBeeAssistantPrompt = BeeAssistantPrompt.fork((config) => {
3
+ const DeepThinkReActAgentAssistantPrompt = ReActAgentAssistantPrompt.fork((config) => {
4
4
  config.template = `{{#thought}}<think>{{.}}</think>
5
5
 
6
6
  {{/thought}}{{#toolName}}Tool Name: {{.}}
7
7
  {{/toolName}}{{#toolInput}}Tool Input: {{.}}
8
8
  {{/toolInput}}{{#finalAnswer}}Response: {{.}}{{/finalAnswer}}`;
9
9
  });
10
- const DeepThinkBeeSystemPrompt = BeeSystemPrompt.fork((config) => {
10
+ const DeepThinkReActAgentSystemPrompt = ReActAgentSystemPrompt.fork((config) => {
11
11
  config.defaults.instructions = "";
12
12
  config.functions.formatDate = function() {
13
13
  const date = this.createdAt ? new Date(this.createdAt) : /* @__PURE__ */ new Date();
@@ -55,30 +55,30 @@ The current date and time is: {{formatDate}}
55
55
  {{/instructions}}
56
56
  `;
57
57
  });
58
- const DeepThinkBeeSchemaErrorPrompt = BeeSchemaErrorPrompt.fork((config) => {
58
+ const DeepThinkReActAgentSchemaErrorPrompt = ReActAgentSchemaErrorPrompt.fork((config) => {
59
59
  config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.
60
60
  You communicate only in instruction lines. Valid instruction lines are 'Tool Name:' and then 'Tool Input:', or 'Response:'.`;
61
61
  });
62
- const DeepThinkBeeUserPrompt = BeeUserPrompt.fork((config) => {
62
+ const DeepThinkReActAgentUserPrompt = ReActAgentUserPrompt.fork((config) => {
63
63
  config.template = `{{input}}`;
64
64
  });
65
- const DeepThinkBeeToolNotFoundPrompt = BeeToolNotFoundPrompt.fork((config) => {
65
+ const DeepThinkReActAgentToolNotFoundPrompt = ReActAgentToolNotFoundPrompt.fork((config) => {
66
66
  config.template = `Tool does not exist!
67
67
  {{#tools.length}}
68
68
  Use one of the following tools: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}
69
69
  {{/tools.length}}`;
70
70
  });
71
- const DeepThinkBeeToolErrorPrompt = BeeToolErrorPrompt.fork((config) => {
71
+ const DeepThinkReActAgentToolErrorPrompt = ReActAgentToolErrorPrompt.fork((config) => {
72
72
  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.
73
73
 
74
74
  {{reason}}`;
75
75
  });
76
- const DeepThinkBeeToolInputErrorPrompt = BeeToolInputErrorPrompt.fork((config) => {
76
+ const DeepThinkReActAgentToolInputErrorPrompt = ReActAgentToolInputErrorPrompt.fork((config) => {
77
77
  config.template = `{{reason}}
78
78
 
79
79
  HINT: 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.`;
80
80
  });
81
81
 
82
- export { DeepThinkBeeAssistantPrompt, DeepThinkBeeSchemaErrorPrompt, DeepThinkBeeSystemPrompt, DeepThinkBeeToolErrorPrompt, DeepThinkBeeToolInputErrorPrompt, DeepThinkBeeToolNotFoundPrompt, DeepThinkBeeUserPrompt };
82
+ export { DeepThinkReActAgentAssistantPrompt, DeepThinkReActAgentSchemaErrorPrompt, DeepThinkReActAgentSystemPrompt, DeepThinkReActAgentToolErrorPrompt, DeepThinkReActAgentToolInputErrorPrompt, DeepThinkReActAgentToolNotFoundPrompt, DeepThinkReActAgentUserPrompt };
83
83
  //# sourceMappingURL=prompts.js.map
84
84
  //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["prompts.ts"],"names":["DeepThinkReActAgentAssistantPrompt","ReActAgentAssistantPrompt","fork","config","template","DeepThinkReActAgentSystemPrompt","ReActAgentSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","DeepThinkReActAgentSchemaErrorPrompt","ReActAgentSchemaErrorPrompt","DeepThinkReActAgentUserPrompt","ReActAgentUserPrompt","DeepThinkReActAgentToolNotFoundPrompt","ReActAgentToolNotFoundPrompt","DeepThinkReActAgentToolErrorPrompt","ReActAgentToolErrorPrompt","DeepThinkReActAgentToolInputErrorPrompt","ReActAgentToolInputErrorPrompt"],"mappings":";;AA0BO,MAAMA,kCAAqCC,GAAAA,yBAAAA,CAA0BC,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAChFA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;;AACpB,CAAA;AAEO,MAAMC,+BAAkCC,GAAAA,sBAAAA,CAAuBJ,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAC1EA,EAAAA,MAAAA,CAAOI,SAASC,YAAe,GAAA,EAAA;AAC/BL,EAAOM,MAAAA,CAAAA,SAAAA,CAAUC,aAAa,WAAA;AAC5B,IAAMC,MAAAA,IAAAA,GAAO,KAAKC,SAAY,GAAA,IAAIC,KAAK,IAAKD,CAAAA,SAAS,CAAI,mBAAA,IAAIC,IAAAA,EAAAA;AAC7D,IAAO,OAAA,IAAIC,IAAKC,CAAAA,cAAAA,CAAe,OAAS,EAAA;MACtCC,SAAW,EAAA,MAAA;MACXC,SAAW,EAAA;KACb,CAAA,CAAGC,OAAOP,IAAAA,CAAAA;AACZ,GAAA;AACAR,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCpB,CAAA;AAEO,MAAMe,oCAAuCC,GAAAA,2BAAAA,CAA4BlB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACpFA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;AAEpB,CAAA;AAEO,MAAMiB,6BAAgCC,GAAAA,oBAAAA,CAAqBpB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACtEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA,SAAA,CAAA;AACpB,CAAA;AAEO,MAAMmB,qCAAwCC,GAAAA,4BAAAA,CAA6BtB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACtFA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;AAIpB,CAAA;AAEO,MAAMqB,kCAAqCC,GAAAA,yBAAAA,CAA0BxB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAChFA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;AAGpB,CAAA;AAEO,MAAMuB,uCAA0CC,GAAAA,8BAAAA,CAA+B1B,IACpF,CAAA,CAACC,MAAAA,KAAAA;AACCA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;AAGpB,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 {\n ReActAgentAssistantPrompt,\n ReActAgentSchemaErrorPrompt,\n ReActAgentSystemPrompt,\n ReActAgentToolErrorPrompt,\n ReActAgentToolInputErrorPrompt,\n ReActAgentToolNotFoundPrompt,\n ReActAgentUserPrompt,\n} from \"@/agents/react/prompts.js\";\n\nexport const DeepThinkReActAgentAssistantPrompt = ReActAgentAssistantPrompt.fork((config) => {\n config.template = `{{#thought}}<think>{{.}}</think>\\n\\n{{/thought}}{{#toolName}}Tool Name: {{.}}\\n{{/toolName}}{{#toolInput}}Tool Input: {{.}}\\n{{/toolInput}}{{#finalAnswer}}Response: {{.}}{{/finalAnswer}}`;\n});\n\nexport const DeepThinkReActAgentSystemPrompt = 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.\n{{#tools.length}}\n# Tools\nYou have access to a set of tools that can be used to retrieve information and perform actions.\n\n{{#tools}}\nTool Name: {{name}}\nTool Description: {{description}}\nTool Input Schema: {{schema}}\n\n{{/tools}}\n\n## Guidelines for using tools\n- Do not directly mention the existence of tools. Act as if these are your inherent capabilities.\n- Do not speculate about specific numbers or facts, obtain them using tools.\n- The tool responses appear as if provided by the user, but in reality they are inserted externally and the user does not see them. Act as if the tool responses were obtained by your inherent capabilities.\n- When you don't have enough information, ask the user for details. Make reasonable assumptions. Do not ask the user to directly provide tool input, ask like you would in a normal conversation.\n- If you need to call multiple tools, simply think out what tools you need to call, and then call the first one and end your message. Don't worry, you will be given opportunity to call as many tools as you want.\n\n# Assistant message structure\n- After thinking, write a message that has to follow a rigid structure. Deviations will result in an error.\n- If you don't need to use a tool, already have all the information and want to answer the user's query, or you want to ask the user for more information, start the message with 'Response:', like this:\nResponse: [response message sent to the user]\n- If you want to call a tool, start your message with 'Tool Name:', followed by the tool name, and then on the next line 'Tool Input:', followed by the tool input JSON, like this:\nTool Name: [name of the tool, as listed above]\nTool Input: [JSON object, following the schema defined above]\n- DO NOT make the line prefixes ('Response:', 'Tool Name:', etc.) **bold**, always keep them plain.\n- As soon as you write these lines, you will be provided the tool result. You will then have the opportunity to call more tools, or to finalize by sending a 'Response:' to the user.\n{{/tools.length}}\n\n# Additional context\nThe current date and time is: {{formatDate}}\n\n{{#instructions}} \n# Additional instructions\n{{.}} \n{{/instructions}}\n`;\n});\n\nexport const DeepThinkReActAgentSchemaErrorPrompt = 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 'Tool Name:' and then 'Tool Input:', or 'Response:'.`;\n});\n\nexport const DeepThinkReActAgentUserPrompt = ReActAgentUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const DeepThinkReActAgentToolNotFoundPrompt = 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 DeepThinkReActAgentToolErrorPrompt = 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 DeepThinkReActAgentToolInputErrorPrompt = 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"]}
@@ -27,16 +27,16 @@ class DeepThinkRunner extends runner_cjs.DefaultRunner {
27
27
  }
28
28
  get defaultTemplates() {
29
29
  return {
30
- system: prompts_cjs$1.DeepThinkBeeSystemPrompt,
31
- assistant: prompts_cjs$1.DeepThinkBeeAssistantPrompt,
32
- user: prompts_cjs$1.DeepThinkBeeUserPrompt,
33
- schemaError: prompts_cjs$1.DeepThinkBeeSchemaErrorPrompt,
34
- toolNotFoundError: prompts_cjs$1.DeepThinkBeeToolNotFoundPrompt,
35
- toolError: prompts_cjs$1.DeepThinkBeeToolErrorPrompt,
36
- toolInputError: prompts_cjs$1.DeepThinkBeeToolInputErrorPrompt,
37
- // Note: These are from bee
38
- userEmpty: prompts_cjs.BeeUserEmptyPrompt,
39
- toolNoResultError: prompts_cjs.BeeToolNoResultsPrompt
30
+ system: prompts_cjs$1.DeepThinkReActAgentSystemPrompt,
31
+ assistant: prompts_cjs$1.DeepThinkReActAgentAssistantPrompt,
32
+ user: prompts_cjs$1.DeepThinkReActAgentUserPrompt,
33
+ schemaError: prompts_cjs$1.DeepThinkReActAgentSchemaErrorPrompt,
34
+ toolNotFoundError: prompts_cjs$1.DeepThinkReActAgentToolNotFoundPrompt,
35
+ toolError: prompts_cjs$1.DeepThinkReActAgentToolErrorPrompt,
36
+ toolInputError: prompts_cjs$1.DeepThinkReActAgentToolInputErrorPrompt,
37
+ // Note: These are from ReAct
38
+ userEmpty: prompts_cjs.ReActAgentUserEmptyPrompt,
39
+ toolNoResultError: prompts_cjs.ReActAgentToolNoResultsPrompt
40
40
  };
41
41
  }
42
42
  static {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["runner.ts"],"names":["DeepThinkRunner","DefaultRunner","defaultTemplates","system","DeepThinkReActAgentSystemPrompt","assistant","DeepThinkReActAgentAssistantPrompt","user","DeepThinkReActAgentUserPrompt","schemaError","DeepThinkReActAgentSchemaErrorPrompt","toolNotFoundError","DeepThinkReActAgentToolNotFoundPrompt","toolError","DeepThinkReActAgentToolErrorPrompt","toolInputError","DeepThinkReActAgentToolInputErrorPrompt","userEmpty","ReActAgentUserEmptyPrompt","toolNoResultError","ReActAgentToolNoResultsPrompt","register","constructor","input","options","run","emitter","on","update","meta","memory","key","add","UserMessage","value","success","createdAt","Date","isBlocking","createParser","tools","parser","fork","nodes","silentNodes","thought","prefix","next","isStart","field","ZodParserField","z","string","min","dummy_thought_end","isDummy","transform","_","tool_name","tool_input","isEnd","tool_output","final_answer","enumerable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuCO,MAAMA,wBAAwBC,wBAAAA,CAAAA;AAAAA,EAAAA;;;AACnC,EAAA,IACWC,gBAAmB,GAAA;AAC5B,IAAO,OAAA;MACLC,MAAQC,EAAAA,6CAAAA;MACRC,SAAWC,EAAAA,gDAAAA;MACXC,IAAMC,EAAAA,2CAAAA;MACNC,WAAaC,EAAAA,kDAAAA;MACbC,iBAAmBC,EAAAA,mDAAAA;MACnBC,SAAWC,EAAAA,gDAAAA;MACXC,cAAgBC,EAAAA,qDAAAA;;MAEhBC,SAAWC,EAAAA,qCAAAA;MACXC,iBAAmBC,EAAAA;AACrB,KAAA;AACF;EAEA;AACE,IAAA,IAAA,CAAKC,QAAQ,EAAA;AACf;EAEAC,WACEC,CAAAA,KAAAA,EACAC,SACAC,GACA,EAAA;AACA,IAAMF,KAAAA,CAAAA,KAAAA,EAAOC,SAASC,GAAAA,CAAAA;AAEtBA,IAAIC,GAAAA,CAAAA,OAAAA,CAAQC,GACV,QACA,EAAA,OAAO,EAAEC,MAAQC,EAAAA,IAAAA,EAAMC,QAAQ,KAAA;AAC7B,MAAIF,IAAAA,MAAAA,CAAOG,QAAQ,aAAe,EAAA;AAChC,QAAA,MAAMD,MAAOE,CAAAA,GAAAA,CACX,IAAIC,uBAAAA,CAAYL,OAAOM,KAAO,EAAA;AAAEC,UAAAA,OAAAA,EAASN,IAAKM,CAAAA,OAAAA;AAASC,UAAAA,SAAAA,sBAAeC,IAAAA;AAAO,SAAA,CAAA,CAAA;AAEjF;KAEF,EAAA;MACEC,UAAY,EAAA;KACd,CAAA;AAEJ;AAEUC,EAAAA,YAAAA,CAAaC,KAAkB,EAAA;AACvC,IAAA,MAAM,EAAEC,MAAAA,EAAW,GAAA,KAAA,CAAMF,aAAaC,KAAAA,C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AACF;AACF;;;IAjFWiB,UAAY,EAAA","file":"runner.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 type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport {\n DeepThinkReActAgentAssistantPrompt,\n DeepThinkReActAgentSchemaErrorPrompt,\n DeepThinkReActAgentSystemPrompt,\n DeepThinkReActAgentToolErrorPrompt,\n DeepThinkReActAgentToolInputErrorPrompt,\n DeepThinkReActAgentToolNotFoundPrompt,\n DeepThinkReActAgentUserPrompt,\n} from \"@/agents/react/runners/deep-think/prompts.js\";\nimport {\n ReActAgentToolNoResultsPrompt,\n ReActAgentUserEmptyPrompt,\n} from \"@/agents/react/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\nimport { ZodParserField } from \"@/parsers/field.js\";\nimport { z } from \"zod\";\nimport { ReActAgentInput, ReActAgent } from \"@/agents/react/agent.js\";\nimport { ReActAgentRunOptions } from \"@/agents/react/types.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { UserMessage } from \"@/backend/message.js\";\n\nexport class DeepThinkRunner extends DefaultRunner {\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: DeepThinkReActAgentSystemPrompt,\n assistant: DeepThinkReActAgentAssistantPrompt,\n user: DeepThinkReActAgentUserPrompt,\n schemaError: DeepThinkReActAgentSchemaErrorPrompt,\n toolNotFoundError: DeepThinkReActAgentToolNotFoundPrompt,\n toolError: DeepThinkReActAgentToolErrorPrompt,\n toolInputError: DeepThinkReActAgentToolInputErrorPrompt,\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 }) => {\n if (update.key === \"tool_output\") {\n await memory.add(\n new UserMessage(update.value, { success: meta.success, createdAt: new Date() }),\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((nodes, options) => ({\n options: {\n ...options,\n // @ts-expect-error\n silentNodes: [...(options?.silentNodes ?? []), \"dummy_thought_end\"],\n },\n nodes: {\n ...nodes,\n thought: {\n ...nodes.thought,\n prefix: \"<think>\",\n // @ts-expect-error\n next: [\"dummy_thought_end\"] as const,\n isStart: true,\n field: new ZodParserField(z.string().min(1)),\n },\n dummy_thought_end: {\n prefix: \"</think>\",\n isDummy: true,\n next: [\"tool_name\", \"final_answer\"],\n field: new ZodParserField(z.string().transform((_) => \"\")),\n },\n tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n tool_input: {\n ...nodes.tool_input,\n prefix: \"Tool Input:\",\n isEnd: true,\n next: [],\n },\n tool_output: { ...nodes.tool_name, prefix: \"Tool Output:\" },\n final_answer: { ...nodes.final_answer, prefix: \"Response:\" },\n },\n })),\n } as const;\n }\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  import { LinePrefixParser } from '../../../../parsers/linePrefix.cjs';
2
- import { BeeRunOptions, BeeParserInput } from '../../types.cjs';
2
+ import { ReActAgentRunOptions, ReActAgentParserInput } from '../../types.cjs';
3
3
  import { PromptTemplate } from '../../../../template.cjs';
4
4
  import { AnyTool } from '../../../../tools/base.cjs';
5
5
  import { DefaultRunner } from '../default/runner.cjs';
6
6
  import { z } from 'zod';
7
- import { c as BeeInput, d as BeeAgent } from '../../../../agent-BZ-_ATuJ.cjs';
7
+ import { R as ReActAgentInput, a as ReActAgent } from '../../../../agent-COg8SPbf.cjs';
8
8
  import { GetRunContext } from '../../../../context.cjs';
9
- import '../../../../emitter-C9EN5B0j.cjs';
9
+ import '../../../../emitter-BWtGHYn0.cjs';
10
10
  import '../../../../internals/types.cjs';
11
11
  import '../../../../internals/helpers/guards.cjs';
12
12
  import '../../../../internals/serializable.cjs';
@@ -29,7 +29,7 @@ import '@ai-sdk/provider';
29
29
  import '../../../../internals/helpers/promise.cjs';
30
30
  import '../../../../internals/helpers/schema.cjs';
31
31
  import 'zod-to-json-schema';
32
- import '../../../../base-daM6fHUP.cjs';
32
+ import '../../../../base-Csr9guq2.cjs';
33
33
  import '../../../../internals/helpers/counter.cjs';
34
34
 
35
35
  declare class DeepThinkRunner extends DefaultRunner {
@@ -157,9 +157,9 @@ declare class DeepThinkRunner extends DefaultRunner {
157
157
  userEmpty: PromptTemplate<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
158
158
  toolNoResultError: PromptTemplate<z.ZodRecord<z.ZodString, z.ZodAny>>;
159
159
  };
160
- constructor(input: BeeInput, options: BeeRunOptions, run: GetRunContext<BeeAgent>);
160
+ constructor(input: ReActAgentInput, options: ReActAgentRunOptions, run: GetRunContext<ReActAgent>);
161
161
  protected createParser(tools: AnyTool[]): {
162
- readonly parser: LinePrefixParser<BeeParserInput>;
162
+ readonly parser: LinePrefixParser<ReActAgentParserInput>;
163
163
  };
164
164
  }
165
165
 
@@ -1,12 +1,12 @@
1
1
  import { LinePrefixParser } from '../../../../parsers/linePrefix.js';
2
- import { BeeRunOptions, BeeParserInput } from '../../types.js';
2
+ import { ReActAgentRunOptions, ReActAgentParserInput } from '../../types.js';
3
3
  import { PromptTemplate } from '../../../../template.js';
4
4
  import { AnyTool } from '../../../../tools/base.js';
5
5
  import { DefaultRunner } from '../default/runner.js';
6
6
  import { z } from 'zod';
7
- import { c as BeeInput, d as BeeAgent } from '../../../../agent-BqoZ6FbM.js';
7
+ import { R as ReActAgentInput, a as ReActAgent } from '../../../../agent-Dv5YSk8H.js';
8
8
  import { GetRunContext } from '../../../../context.js';
9
- import '../../../../emitter-BxVxGBbJ.js';
9
+ import '../../../../emitter-l0W9gC1A.js';
10
10
  import '../../../../internals/types.js';
11
11
  import '../../../../internals/helpers/guards.js';
12
12
  import '../../../../internals/serializable.js';
@@ -29,7 +29,7 @@ import '@ai-sdk/provider';
29
29
  import '../../../../internals/helpers/promise.js';
30
30
  import '../../../../internals/helpers/schema.js';
31
31
  import 'zod-to-json-schema';
32
- import '../../../../base-mmG-8Pk9.js';
32
+ import '../../../../base-DHhpWHQm.js';
33
33
  import '../../../../internals/helpers/counter.js';
34
34
 
35
35
  declare class DeepThinkRunner extends DefaultRunner {
@@ -157,9 +157,9 @@ declare class DeepThinkRunner extends DefaultRunner {
157
157
  userEmpty: PromptTemplate<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
158
158
  toolNoResultError: PromptTemplate<z.ZodRecord<z.ZodString, z.ZodAny>>;
159
159
  };
160
- constructor(input: BeeInput, options: BeeRunOptions, run: GetRunContext<BeeAgent>);
160
+ constructor(input: ReActAgentInput, options: ReActAgentRunOptions, run: GetRunContext<ReActAgent>);
161
161
  protected createParser(tools: AnyTool[]): {
162
- readonly parser: LinePrefixParser<BeeParserInput>;
162
+ readonly parser: LinePrefixParser<ReActAgentParserInput>;
163
163
  };
164
164
  }
165
165
 
@@ -1,6 +1,6 @@
1
1
  import { DefaultRunner } from '../default/runner.js';
2
- import { DeepThinkBeeToolInputErrorPrompt, DeepThinkBeeToolErrorPrompt, DeepThinkBeeToolNotFoundPrompt, DeepThinkBeeSchemaErrorPrompt, DeepThinkBeeUserPrompt, DeepThinkBeeAssistantPrompt, DeepThinkBeeSystemPrompt } from './prompts.js';
3
- import { BeeToolNoResultsPrompt, BeeUserEmptyPrompt } from '../../prompts.js';
2
+ import { DeepThinkReActAgentToolInputErrorPrompt, DeepThinkReActAgentToolErrorPrompt, DeepThinkReActAgentToolNotFoundPrompt, DeepThinkReActAgentSchemaErrorPrompt, DeepThinkReActAgentUserPrompt, DeepThinkReActAgentAssistantPrompt, DeepThinkReActAgentSystemPrompt } from './prompts.js';
3
+ import { ReActAgentToolNoResultsPrompt, ReActAgentUserEmptyPrompt } from '../../prompts.js';
4
4
  import { Cache } from '../../../../cache/decoratorCache.js';
5
5
  import { ZodParserField } from '../../../../parsers/field.js';
6
6
  import { z } from 'zod';
@@ -25,16 +25,16 @@ class DeepThinkRunner extends DefaultRunner {
25
25
  }
26
26
  get defaultTemplates() {
27
27
  return {
28
- system: DeepThinkBeeSystemPrompt,
29
- assistant: DeepThinkBeeAssistantPrompt,
30
- user: DeepThinkBeeUserPrompt,
31
- schemaError: DeepThinkBeeSchemaErrorPrompt,
32
- toolNotFoundError: DeepThinkBeeToolNotFoundPrompt,
33
- toolError: DeepThinkBeeToolErrorPrompt,
34
- toolInputError: DeepThinkBeeToolInputErrorPrompt,
35
- // Note: These are from bee
36
- userEmpty: BeeUserEmptyPrompt,
37
- toolNoResultError: BeeToolNoResultsPrompt
28
+ system: DeepThinkReActAgentSystemPrompt,
29
+ assistant: DeepThinkReActAgentAssistantPrompt,
30
+ user: DeepThinkReActAgentUserPrompt,
31
+ schemaError: DeepThinkReActAgentSchemaErrorPrompt,
32
+ toolNotFoundError: DeepThinkReActAgentToolNotFoundPrompt,
33
+ toolError: DeepThinkReActAgentToolErrorPrompt,
34
+ toolInputError: DeepThinkReActAgentToolInputErrorPrompt,
35
+ // Note: These are from ReAct
36
+ userEmpty: ReActAgentUserEmptyPrompt,
37
+ toolNoResultError: ReActAgentToolNoResultsPrompt
38
38
  };
39
39
  }
40
40
  static {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["runner.ts"],"names":["DeepThinkRunner","DefaultRunner","defaultTemplates","system","DeepThinkReActAgentSystemPrompt","assistant","DeepThinkReActAgentAssistantPrompt","user","DeepThinkReActAgentUserPrompt","schemaError","DeepThinkReActAgentSchemaErrorPrompt","toolNotFoundError","DeepThinkReActAgentToolNotFoundPrompt","toolError","DeepThinkReActAgentToolErrorPrompt","toolInputError","DeepThinkReActAgentToolInputErrorPrompt","userEmpty","ReActAgentUserEmptyPrompt","toolNoResultError","ReActAgentToolNoResultsPrompt","register","constructor","input","options","run","emitter","on","update","meta","memory","key","add","UserMessage","value","success","createdAt","Date","isBlocking","createParser","tools","parser","fork","nodes","silentNodes","thought","prefix","next","isStart","field","ZodParserField","z","string","min","dummy_thought_end","isDummy","transform","_","tool_name","tool_input","isEnd","tool_output","final_answer","enumerable"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCO,MAAMA,wBAAwBC,aAAAA,CAAAA;AAAAA,EAAAA;;;AACnC,EAAA,IACWC,gBAAmB,GAAA;AAC5B,IAAO,OAAA;MACLC,MAAQC,EAAAA,+BAAAA;MACRC,SAAWC,EAAAA,kCAAAA;MACXC,IAAMC,EAAAA,6BAAAA;MACNC,WAAaC,EAAAA,oCAAAA;MACbC,iBAAmBC,EAAAA,qCAAAA;MACnBC,SAAWC,EAAAA,kCAAAA;MACXC,cAAgBC,EAAAA,uCAAAA;;MAEhBC,SAAWC,EAAAA,yBAAAA;MACXC,iBAAmBC,EAAAA;AACrB,KAAA;AACF;EAEA;AACE,IAAA,IAAA,CAAKC,QAAQ,EAAA;AACf;EAEAC,WACEC,CAAAA,KAAAA,EACAC,SACAC,GACA,EAAA;AACA,IAAMF,KAAAA,CAAAA,KAAAA,EAAOC,SAASC,GAAAA,CAAAA;AAEtBA,IAAIC,GAAAA,CAAAA,OAAAA,CAAQC,GACV,QACA,EAAA,OAAO,EAAEC,MAAQC,EAAAA,IAAAA,EAAMC,QAAQ,KAAA;AAC7B,M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,CAAAA,SAAAA;YAAWZ,MAAQ,EAAA;AAAa,WAAA;UACtDa,UAAY,EAAA;AACV,YAAA,GAAGhB,KAAMgB,CAAAA,UAAAA;YACTb,MAAQ,EAAA,aAAA;YACRc,KAAO,EAAA,IAAA;AACPb,YAAAA,IAAAA,EAAM;AACR,WAAA;UACAc,WAAa,EAAA;AAAE,YAAA,GAAGlB,KAAMe,CAAAA,SAAAA;YAAWZ,MAAQ,EAAA;AAAe,WAAA;UAC1DgB,YAAc,EAAA;AAAE,YAAA,GAAGnB,KAAMmB,CAAAA,YAAAA;YAAchB,MAAQ,EAAA;AAAY;AAC7D;OACF,CAAA;AACF,KAAA;AACF;AACF;;;IAjFWiB,UAAY,EAAA","file":"runner.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 type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/react/runners/default/runner.js\";\nimport {\n DeepThinkReActAgentAssistantPrompt,\n DeepThinkReActAgentSchemaErrorPrompt,\n DeepThinkReActAgentSystemPrompt,\n DeepThinkReActAgentToolErrorPrompt,\n DeepThinkReActAgentToolInputErrorPrompt,\n DeepThinkReActAgentToolNotFoundPrompt,\n DeepThinkReActAgentUserPrompt,\n} from \"@/agents/react/runners/deep-think/prompts.js\";\nimport {\n ReActAgentToolNoResultsPrompt,\n ReActAgentUserEmptyPrompt,\n} from \"@/agents/react/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\nimport { ZodParserField } from \"@/parsers/field.js\";\nimport { z } from \"zod\";\nimport { ReActAgentInput, ReActAgent } from \"@/agents/react/agent.js\";\nimport { ReActAgentRunOptions } from \"@/agents/react/types.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { UserMessage } from \"@/backend/message.js\";\n\nexport class DeepThinkRunner extends DefaultRunner {\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: DeepThinkReActAgentSystemPrompt,\n assistant: DeepThinkReActAgentAssistantPrompt,\n user: DeepThinkReActAgentUserPrompt,\n schemaError: DeepThinkReActAgentSchemaErrorPrompt,\n toolNotFoundError: DeepThinkReActAgentToolNotFoundPrompt,\n toolError: DeepThinkReActAgentToolErrorPrompt,\n toolInputError: DeepThinkReActAgentToolInputErrorPrompt,\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 }) => {\n if (update.key === \"tool_output\") {\n await memory.add(\n new UserMessage(update.value, { success: meta.success, createdAt: new Date() }),\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((nodes, options) => ({\n options: {\n ...options,\n // @ts-expect-error\n silentNodes: [...(options?.silentNodes ?? []), \"dummy_thought_end\"],\n },\n nodes: {\n ...nodes,\n thought: {\n ...nodes.thought,\n prefix: \"<think>\",\n // @ts-expect-error\n next: [\"dummy_thought_end\"] as const,\n isStart: true,\n field: new ZodParserField(z.string().min(1)),\n },\n dummy_thought_end: {\n prefix: \"</think>\",\n isDummy: true,\n next: [\"tool_name\", \"final_answer\"],\n field: new ZodParserField(z.string().transform((_) => \"\")),\n },\n tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n tool_input: {\n ...nodes.tool_input,\n prefix: \"Tool Input:\",\n isEnd: true,\n next: [],\n },\n tool_output: { ...nodes.tool_name, prefix: \"Tool Output:\" },\n final_answer: { ...nodes.final_answer, prefix: \"Response:\" },\n },\n })),\n } as const;\n }\n}\n"]}
@@ -36,15 +36,15 @@ class DefaultRunner extends base_cjs.BaseRunner {
36
36
  useNativeToolCalling = false;
37
37
  get defaultTemplates() {
38
38
  return {
39
- system: prompts_cjs.BeeSystemPrompt,
40
- assistant: prompts_cjs.BeeAssistantPrompt,
41
- user: prompts_cjs.BeeUserPrompt,
42
- schemaError: prompts_cjs.BeeSchemaErrorPrompt,
43
- toolNotFoundError: prompts_cjs.BeeToolNotFoundPrompt,
44
- toolError: prompts_cjs.BeeToolErrorPrompt,
45
- toolInputError: prompts_cjs.BeeToolInputErrorPrompt,
46
- userEmpty: prompts_cjs.BeeUserEmptyPrompt,
47
- toolNoResultError: prompts_cjs.BeeToolNoResultsPrompt
39
+ system: prompts_cjs.ReActAgentSystemPrompt,
40
+ assistant: prompts_cjs.ReActAgentAssistantPrompt,
41
+ user: prompts_cjs.ReActAgentUserPrompt,
42
+ schemaError: prompts_cjs.ReActAgentSchemaErrorPrompt,
43
+ toolNotFoundError: prompts_cjs.ReActAgentToolNotFoundPrompt,
44
+ toolError: prompts_cjs.ReActAgentToolErrorPrompt,
45
+ toolInputError: prompts_cjs.ReActAgentToolInputErrorPrompt,
46
+ userEmpty: prompts_cjs.ReActAgentUserEmptyPrompt,
47
+ toolNoResultError: prompts_cjs.ReActAgentToolNoResultsPrompt
48
48
  };
49
49
  }
50
50
  static {
@@ -292,7 +292,7 @@ class DefaultRunner extends base_cjs.BaseRunner {
292
292
  ].filter(remeda.isTruthy).map((message) => {
293
293
  if (message.role === message_cjs.Role.USER) {
294
294
  const isEmpty = !message.text.trim();
295
- const text = isEmpty ? (this.templates?.userEmpty ?? prompts_cjs.BeeUserEmptyPrompt).render({}) : (this.templates?.user ?? prompts_cjs.BeeUserPrompt).render({
295
+ const text = isEmpty ? (this.templates?.userEmpty ?? prompts_cjs.ReActAgentUserEmptyPrompt).render({}) : (this.templates?.user ?? prompts_cjs.ReActAgentUserPrompt).render({
296
296
  input: message.text,
297
297
  meta: {
298
298
  ...message?.meta,
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["runner.ts"],"names":["DefaultRunner","BaseRunner","useNativeToolCalling","defaultTemplates","system","ReActAgentSystemPrompt","assistant","ReActAgentAssistantPrompt","user","ReActAgentUserPrompt","schemaError","ReActAgentSchemaErrorPrompt","toolNotFoundError","ReActAgentToolNotFoundPrompt","toolError","ReActAgentToolErrorPrompt","toolInputError","ReActAgentToolInputErrorPrompt","userEmpty","ReActAgentUserEmptyPrompt","toolNoResultError","ReActAgentToolNoResultsPrompt","register","llm","signal","meta","emitter","tempMessageKey","Retryable","onRetry","emit","onError","error","failedAttemptsCounter","use","LinePrefixParserError","reason","Reason","NoDataReceived","memory","add","AssistantMessage","UserMessage","templates","render","executor","tools","input","slice","parser","createParser","raw","create","messages","undefined","abortSignal","stream","observe","llmEmitter","on","value","key","field","isDone","data","finalState","update","parsedValue","success","delta","callbacks","abort","getTextContent","partialState","tool_output","end","deleteMany","filter","msg","getProp","state","config","maxRetries","options","execution","maxRetriesPerStep","get","tool","find","name","trim","toUpperCase","tool_name","AgentError","context","output","iteration","tool_input","FrameworkError","ensure","toolOptions","shallowCopy","toolOutput","run","Tool","contextKeys","Memory","result","isEmpty","ToolInputValidationError","toString","ToolError","explain","renderers","self","message","prompt","variables","Promise","all","map","description","replaceAll","replace","concat","schema","JSON","stringify","getInputJsonSchema","ignoredKeys","Set","has","SystemMessage","instructions","createdAt","Date","toISOString","initMemory","history","prevConversation","isTruthy","role","Role","USER","text","TokenMemory","capacityThreshold","syncThreshold","handlers","removalSelector","curMessages","prevConversationMessage","includes","last","lastMessage","length","ASSISTANT","addMany","LinePrefixParser","thought","prefix","next","isStart","ZodParserField","z","string","min","pipeline","enum","isEnd","JSONParserField","object","passthrough","base","matchPair","final_answer","waitForStartNode","endOnRepeat","fallback","stash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;;;;;;;IA2NZA,UAAY,EAAA","file":"runner.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 {\n BaseRunner,\n ReActAgentRunnerLLMInput,\n ReActAgentRunnerToolInput,\n} from \"@/agents/react/runners/base.js\";\nimport type {\n ReActAgentRunIteration,\n ReActAgentParserInput,\n ReActAgentRunInput,\n} from \"@/agents/react/types.js\";\nimport { Retryable } from \"@/internals/helpers/retryable.js\";\nimport { AgentError } from \"@/agents/base.js\";\nimport {\n ReActAgentAssistantPrompt,\n ReActAgentSchemaErrorPrompt,\n ReActAgentSystemPrompt,\n ReActAgentToolErrorPrompt,\n ReActAgentToolInputErrorPrompt,\n ReActAgentToolNoResultsPrompt,\n ReActAgentToolNotFoundPrompt,\n ReActAgentUserEmptyPrompt,\n ReActAgentUserPrompt,\n} from \"@/agents/react/prompts.js\";\nimport { AnyTool, Tool, ToolError, ToolInputValidationError, ToolOutput } from \"@/tools/base.js\";\nimport { FrameworkError } from \"@/errors.js\";\nimport { isTruthy, last } from \"remeda\";\nimport { LinePrefixParser, LinePrefixParserError } from \"@/parsers/linePrefix.js\";\nimport { JSONParserField, ZodParserField } from \"@/parsers/field.js\";\nimport { z } from \"zod\";\nimport { AssistantMessage, Role, SystemMessage, UserMessage } from \"@/backend/message.js\";\nimport { TokenMemory } from \"@/memory/tokenMemory.js\";\nimport { getProp } from \"@/internals/helpers/object.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\nimport { shallowCopy } from \"@/serializer/utils.js\";\n\nexport class DefaultRunner extends BaseRunner {\n protected useNativeToolCalling = false;\n\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: ReActAgentSystemPrompt,\n assistant: ReActAgentAssistantPrompt,\n user: ReActAgentUserPrompt,\n schemaError: ReActAgentSchemaErrorPrompt,\n toolNotFoundError: ReActAgentToolNotFoundPrompt,\n toolError: ReActAgentToolErrorPrompt,\n toolInputError: ReActAgentToolInputErrorPrompt,\n userEmpty: ReActAgentUserEmptyPrompt,\n toolNoResultError: ReActAgentToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n async llm({ signal, meta, emitter }: ReActAgentRunnerLLMInput): Promise<ReActAgentRunIteration> {\n const tempMessageKey = \"tempMessage\" as const;\n\n return new Retryable({\n onRetry: () => emitter.emit(\"retry\", { meta }),\n onError: async (error) => {\n await emitter.emit(\"error\", { error, meta });\n this.failedAttemptsCounter.use(error);\n\n if (error instanceof LinePrefixParserError) {\n // Prevent hanging on EOT\n if (error.reason === LinePrefixParserError.Reason.NoDataReceived) {\n await this.memory.add(\n new AssistantMessage(\"\\n\", {\n [tempMessageKey]: true,\n }),\n );\n } else {\n await this.memory.add(\n new UserMessage(this.templates.schemaError.render({}), {\n [tempMessageKey]: true,\n }),\n );\n }\n }\n },\n executor: async () => {\n const tools = this.input.tools.slice();\n await emitter.emit(\"start\", { meta, tools, memory: this.memory });\n\n const { parser } = this.createParser(tools);\n const raw = await this.input.llm\n .create({\n messages: this.memory.messages.slice(),\n tools: this.useNativeToolCalling ? tools : undefined,\n abortSignal: signal,\n stream: this.input.stream !== false,\n })\n .observe((llmEmitter) => {\n parser.emitter.on(\"update\", async ({ value, key, field }) => {\n if (key === \"tool_output\" && parser.isDone) {\n return;\n }\n await emitter.emit(\"update\", {\n data: parser.finalState,\n update: { key, value: field.raw, parsedValue: value },\n meta: { success: true, ...meta },\n memory: this.memory,\n });\n });\n parser.emitter.on(\"partialUpdate\", async ({ key, delta, value }) => {\n await emitter.emit(\"partialUpdate\", {\n data: parser.finalState,\n update: { key, value: delta, parsedValue: value },\n meta: { success: true, ...meta },\n });\n });\n\n llmEmitter.on(\"newToken\", async ({ value, callbacks }) => {\n if (parser.isDone) {\n callbacks.abort();\n return;\n }\n\n await parser.add(value.getTextContent());\n if (parser.partialState.tool_output !== undefined) {\n callbacks.abort();\n }\n });\n });\n\n await parser.end();\n await this.memory.deleteMany(\n this.memory.messages.filter((msg) => getProp(msg.meta, [tempMessageKey]) === true),\n );\n\n return {\n state: parser.finalState,\n raw,\n };\n },\n config: {\n maxRetries: this.options.execution?.maxRetriesPerStep,\n signal,\n },\n }).get();\n }\n\n async tool({ state, signal, meta, emitter }: ReActAgentRunnerToolInput) {\n const tool = this.input.tools.find(\n (tool) => tool.name.trim().toUpperCase() == state.tool_name?.trim()?.toUpperCase(),\n );\n if (!tool) {\n this.failedAttemptsCounter.use(\n new AgentError(`Agent was trying to use non-existing tool \"${state.tool_name}\"`, [], {\n context: { state, meta },\n }),\n );\n\n return {\n success: false,\n output: this.templates.toolNotFoundError.render({\n tools: this.input.tools,\n }),\n };\n }\n\n return new Retryable({\n config: {\n signal,\n maxRetries: this.options.execution?.maxRetriesPerStep,\n },\n onError: async (error) => {\n await emitter.emit(\"toolError\", {\n data: {\n iteration: state,\n tool,\n input: state.tool_input,\n options: this.options,\n error: FrameworkError.ensure(error),\n },\n meta,\n });\n this.failedAttemptsCounter.use(error);\n },\n executor: async () => {\n const toolOptions = shallowCopy(this.options);\n\n try {\n await emitter.emit(\"toolStart\", {\n data: {\n tool,\n input: state.tool_input,\n options: toolOptions,\n iteration: state,\n },\n meta,\n });\n const toolOutput: ToolOutput = await tool.run(state.tool_input, toolOptions).context({\n [Tool.contextKeys.Memory]: this.memory,\n });\n await emitter.emit(\"toolSuccess\", {\n data: {\n tool,\n input: state.tool_input,\n options: toolOptions,\n result: toolOutput,\n iteration: state,\n },\n meta,\n });\n\n if (toolOutput.isEmpty()) {\n return { output: this.templates.toolNoResultError.render({}), success: true };\n }\n\n return {\n success: true,\n output: toolOutput.getTextContent(),\n };\n } catch (error) {\n await emitter.emit(\"toolError\", {\n data: {\n tool,\n input: state.tool_input,\n options: toolOptions,\n error,\n iteration: state,\n },\n meta,\n });\n\n if (error instanceof ToolInputValidationError) {\n this.failedAttemptsCounter.use(error);\n\n return {\n success: false,\n output: this.templates.toolInputError.render({\n reason: error.toString(),\n }),\n };\n }\n\n if (error instanceof ToolError) {\n this.failedAttemptsCounter.use(error);\n\n return {\n success: false,\n output: this.templates.toolError.render({\n reason: error.explain(),\n }),\n };\n }\n\n throw error;\n }\n },\n }).get();\n }\n\n @Cache({ enumerable: false })\n protected get renderers() {\n const self = {\n user: {\n message: ({ prompt }: ReActAgentRunInput) =>\n prompt !== null || this.input.memory.isEmpty()\n ? new UserMessage(prompt || this.templates.userEmpty.render({}))\n : undefined,\n },\n system: {\n variables: {\n tools: async () => {\n return await Promise.all(\n this.input.tools.map(async (tool) => ({\n name: tool.name,\n description: tool.description.replaceAll(\"\\n\", \".\").replace(/\\.$/, \"\").concat(\".\"),\n schema: JSON.stringify(\n await tool.getInputJsonSchema(),\n (() => {\n const ignoredKeys = new Set([\"minLength\", \"maxLength\", \"$schema\"]);\n return (key, value) => (ignoredKeys.has(key) ? undefined : value);\n })(),\n ),\n })),\n );\n },\n },\n message: async () =>\n new SystemMessage(\n this.templates.system.render({\n tools: await self.system.variables.tools(),\n instructions: undefined,\n createdAt: new Date().toISOString(),\n }),\n {\n createdAt: new Date(),\n },\n ),\n },\n };\n return self;\n }\n\n protected async initMemory({ prompt }: ReActAgentRunInput): Promise<BaseMemory> {\n const { memory: history } = this.input;\n\n const prevConversation = [...history.messages, this.renderers.user.message({ prompt })]\n .filter(isTruthy)\n .map((message) => {\n if (message.role === Role.USER) {\n const isEmpty = !message.text.trim();\n const text = isEmpty\n ? (this.templates?.userEmpty ?? ReActAgentUserEmptyPrompt).render({})\n : (this.templates?.user ?? ReActAgentUserPrompt).render({\n input: message.text,\n meta: {\n ...message?.meta,\n createdAt: message?.meta?.createdAt?.toISOString?.(),\n },\n });\n\n return new UserMessage(text, message.meta);\n }\n return message;\n });\n\n const memory = new TokenMemory({\n capacityThreshold: 0.85,\n syncThreshold: 0.5,\n handlers: {\n removalSelector(curMessages) {\n // First we remove messages from the past conversations\n const prevConversationMessage = curMessages.find((msg) => prevConversation.includes(msg));\n if (prevConversationMessage && prevConversationMessage !== last(prevConversation)) {\n return prevConversationMessage;\n }\n\n const lastMessage =\n curMessages.length > 3\n ? (curMessages.find(\n (msg) =>\n msg.role === Role.ASSISTANT && getProp(msg, [\"ctx\", \"success\"]) === false,\n ) ?? curMessages.find((msg) => msg.role === Role.ASSISTANT))\n : null;\n\n if (!lastMessage) {\n throw new AgentError(\"Cannot fit the current conversation into the context window!\");\n }\n return lastMessage;\n },\n },\n });\n await memory.addMany([await this.renderers.system.message(), ...prevConversation]);\n return memory;\n }\n\n protected createParser(tools: AnyTool[]) {\n const parser = new LinePrefixParser<ReActAgentParserInput>(\n {\n thought: {\n prefix: \"Thought:\",\n next: [\"tool_name\", \"final_answer\"],\n isStart: true,\n field: new ZodParserField(z.string().min(1)),\n },\n tool_name: {\n prefix: \"Function Name:\",\n next: [\"tool_input\"],\n field: new ZodParserField(\n z.pipeline(\n z.string().trim(),\n z.enum(tools.map((tool) => tool.name) as [string, ...string[]]),\n ),\n ),\n },\n tool_input: {\n prefix: \"Function Input:\",\n next: [\"tool_output\"],\n isEnd: true,\n field: new JSONParserField({\n schema: z.object({}).passthrough(),\n base: {},\n matchPair: [\"{\", \"}\"],\n }),\n },\n tool_output: {\n prefix: \"Function Output:\",\n next: [\"final_answer\"],\n isEnd: true,\n field: new ZodParserField(z.string()),\n },\n final_answer: {\n prefix: \"Final Answer:\",\n next: [],\n isStart: true,\n isEnd: true,\n field: new ZodParserField(z.string().min(1)),\n },\n },\n {\n waitForStartNode: true,\n endOnRepeat: true,\n fallback: (stash) =>\n stash\n ? [\n { key: \"thought\", value: \"I now know the final answer.\" },\n { key: \"final_answer\", value: stash },\n ]\n : [],\n },\n );\n\n return {\n parser,\n } as const;\n }\n}\n"]}