beeai-framework 0.1.5 → 0.1.7

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 (266) hide show
  1. package/README.md +1 -1
  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.cjs.map +1 -1
  27. package/dist/adapters/langchain/backend/chat.d.cts +1 -1
  28. package/dist/adapters/langchain/backend/chat.d.ts +1 -1
  29. package/dist/adapters/langchain/backend/chat.js.map +1 -1
  30. package/dist/adapters/langchain/backend/embedding.d.cts +1 -1
  31. package/dist/adapters/langchain/backend/embedding.d.ts +1 -1
  32. package/dist/adapters/langchain/tools.cjs.map +1 -1
  33. package/dist/adapters/langchain/tools.d.cts +1 -1
  34. package/dist/adapters/langchain/tools.d.ts +1 -1
  35. package/dist/adapters/langchain/tools.js.map +1 -1
  36. package/dist/adapters/ollama/backend/chat.d.cts +1 -1
  37. package/dist/adapters/ollama/backend/chat.d.ts +1 -1
  38. package/dist/adapters/ollama/backend/embedding.d.cts +1 -1
  39. package/dist/adapters/ollama/backend/embedding.d.ts +1 -1
  40. package/dist/adapters/openai/backend/chat.d.cts +1 -1
  41. package/dist/adapters/openai/backend/chat.d.ts +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 +4 -2
  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 +4 -2
  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-Bf2FaCKy.d.ts +84 -0
  61. package/dist/agent-Bpt7IFa_.d.cts +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 +110 -0
  65. package/dist/agents/experimental/remote/agent.cjs.map +1 -0
  66. package/dist/agents/experimental/remote/agent.d.cts +78 -0
  67. package/dist/agents/experimental/remote/agent.d.ts +78 -0
  68. package/dist/agents/experimental/remote/agent.js +108 -0
  69. package/dist/agents/experimental/remote/agent.js.map +1 -0
  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 +65 -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 +62 -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 +3 -2
  155. package/dist/backend/chat.d.ts +3 -2
  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-Csr9guq2.d.cts → base-daM6fHUP.d.cts} +1 -1
  169. package/dist/{base-DHhpWHQm.d.ts → base-mmG-8Pk9.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.d.cts +2 -2
  177. package/dist/index.d.ts +2 -2
  178. package/dist/instrumentation/create-telemetry-middleware.cjs.map +1 -1
  179. package/dist/instrumentation/create-telemetry-middleware.d.cts +1 -1
  180. package/dist/instrumentation/create-telemetry-middleware.d.ts +1 -1
  181. package/dist/instrumentation/create-telemetry-middleware.js.map +1 -1
  182. package/dist/instrumentation/helpers/utils.d.cts +1 -1
  183. package/dist/instrumentation/helpers/utils.d.ts +1 -1
  184. package/dist/internals/fetcher.d.cts +1 -1
  185. package/dist/internals/fetcher.d.ts +1 -1
  186. package/dist/memory/summarizeMemory.d.cts +1 -1
  187. package/dist/memory/summarizeMemory.d.ts +1 -1
  188. package/dist/parsers/linePrefix.d.cts +1 -1
  189. package/dist/parsers/linePrefix.d.ts +1 -1
  190. package/dist/tools/arxiv.d.cts +1 -1
  191. package/dist/tools/arxiv.d.ts +1 -1
  192. package/dist/tools/base.d.cts +1 -1
  193. package/dist/tools/base.d.ts +1 -1
  194. package/dist/tools/calculator.d.cts +1 -1
  195. package/dist/tools/calculator.d.ts +1 -1
  196. package/dist/tools/custom.d.cts +1 -1
  197. package/dist/tools/custom.d.ts +1 -1
  198. package/dist/tools/database/elasticsearch.d.cts +1 -1
  199. package/dist/tools/database/elasticsearch.d.ts +1 -1
  200. package/dist/tools/database/milvus.d.cts +1 -1
  201. package/dist/tools/database/milvus.d.ts +1 -1
  202. package/dist/tools/database/sql.d.cts +1 -1
  203. package/dist/tools/database/sql.d.ts +1 -1
  204. package/dist/tools/llm.d.cts +1 -1
  205. package/dist/tools/llm.d.ts +1 -1
  206. package/dist/tools/mcp.d.cts +1 -1
  207. package/dist/tools/mcp.d.ts +1 -1
  208. package/dist/tools/openapi.d.cts +1 -1
  209. package/dist/tools/openapi.d.ts +1 -1
  210. package/dist/tools/python/output.d.cts +1 -1
  211. package/dist/tools/python/output.d.ts +1 -1
  212. package/dist/tools/python/python.d.cts +1 -1
  213. package/dist/tools/python/python.d.ts +1 -1
  214. package/dist/tools/search/base.d.cts +1 -1
  215. package/dist/tools/search/base.d.ts +1 -1
  216. package/dist/tools/search/duckDuckGoSearch.d.cts +1 -1
  217. package/dist/tools/search/duckDuckGoSearch.d.ts +1 -1
  218. package/dist/tools/search/googleSearch.d.cts +1 -1
  219. package/dist/tools/search/googleSearch.d.ts +1 -1
  220. package/dist/tools/search/searXNGSearch.d.cts +1 -1
  221. package/dist/tools/search/searXNGSearch.d.ts +1 -1
  222. package/dist/tools/search/wikipedia.d.cts +1 -1
  223. package/dist/tools/search/wikipedia.d.ts +1 -1
  224. package/dist/tools/similarity.d.cts +1 -1
  225. package/dist/tools/similarity.d.ts +1 -1
  226. package/dist/tools/weather/openMeteo.d.cts +1 -1
  227. package/dist/tools/weather/openMeteo.d.ts +1 -1
  228. package/dist/tools/web/webCrawler.d.cts +1 -1
  229. package/dist/tools/web/webCrawler.d.ts +1 -1
  230. package/dist/version.cjs +1 -1
  231. package/dist/version.js +1 -1
  232. package/dist/workflows/agent.cjs +2 -2
  233. package/dist/workflows/agent.cjs.map +1 -1
  234. package/dist/workflows/agent.d.cts +6 -6
  235. package/dist/workflows/agent.d.ts +6 -6
  236. package/dist/workflows/agent.js +2 -2
  237. package/dist/workflows/agent.js.map +1 -1
  238. package/dist/workflows/workflow.d.cts +1 -1
  239. package/dist/workflows/workflow.d.ts +1 -1
  240. package/package.json +20 -12
  241. package/dist/agent-DNfflu8t.d.ts +0 -84
  242. package/dist/agent-wkCuP7e1.d.cts +0 -84
  243. package/dist/agents/bee/agent.cjs.map +0 -1
  244. package/dist/agents/bee/agent.js.map +0 -1
  245. package/dist/agents/bee/prompts.cjs.map +0 -1
  246. package/dist/agents/bee/prompts.js.map +0 -1
  247. package/dist/agents/bee/runners/deep-think/prompts.cjs.map +0 -1
  248. package/dist/agents/bee/runners/deep-think/prompts.js.map +0 -1
  249. package/dist/agents/bee/runners/deep-think/runner.cjs.map +0 -1
  250. package/dist/agents/bee/runners/deep-think/runner.js.map +0 -1
  251. package/dist/agents/bee/runners/default/runner.cjs.map +0 -1
  252. package/dist/agents/bee/runners/default/runner.js.map +0 -1
  253. package/dist/agents/bee/runners/default/runner.spec.cjs.map +0 -1
  254. package/dist/agents/bee/runners/default/runner.spec.js.map +0 -1
  255. package/dist/agents/bee/runners/granite/prompts.cjs.map +0 -1
  256. package/dist/agents/bee/runners/granite/prompts.js.map +0 -1
  257. package/dist/agents/bee/runners/granite/runner.cjs.map +0 -1
  258. package/dist/agents/bee/runners/granite/runner.js.map +0 -1
  259. package/dist/agents/{bee → react}/runners/default/runner.spec.d.cts +0 -0
  260. package/dist/agents/{bee → react}/runners/default/runner.spec.d.ts +0 -0
  261. package/dist/agents/{bee → react}/types.cjs +0 -0
  262. package/dist/agents/{bee → react}/types.cjs.map +0 -0
  263. package/dist/agents/{bee → react}/types.js +0 -0
  264. package/dist/agents/{bee → react}/types.js.map +0 -0
  265. package/dist/{emitter-l0W9gC1A.d.ts → emitter-BxVxGBbJ.d.ts} +1 -1
  266. package/dist/{emitter-BWtGHYn0.d.cts → emitter-C9EN5B0j.d.cts} +1 -1
@@ -1,84 +0,0 @@
1
- import { GetRunContext, RunContext } from './context.cjs';
2
- import { b as AgentMeta, a as BaseAgent } from './base-Csr9guq2.cjs';
3
- import { AnyTool } from './tools/base.cjs';
4
- import { BaseMemory } from './memory/base.cjs';
5
- import { E as Emitter } from './emitter-BWtGHYn0.cjs';
6
- import { BeeRunOptions, BeeAgentRunIteration, BeeCallbacks, BeeParserInput, BeeMeta, BeeRunInput, BeeIterationToolResult, BeeAgentTemplates, BeeAgentExecutionConfig, BeeRunOutput } from './agents/bee/types.cjs';
7
- import { LinePrefixParser } from './parsers/linePrefix.cjs';
8
- import { Serializable } from './internals/serializable.cjs';
9
- import { ChatModel } from './backend/chat.cjs';
10
- import { RetryCounter } from './internals/helpers/counter.cjs';
11
-
12
- interface BeeRunnerLLMInput {
13
- meta: BeeMeta;
14
- signal: AbortSignal;
15
- emitter: Emitter<BeeCallbacks>;
16
- }
17
- interface BeeRunnerToolInput {
18
- state: BeeIterationToolResult;
19
- meta: BeeMeta;
20
- signal: AbortSignal;
21
- emitter: Emitter<BeeCallbacks>;
22
- }
23
- declare abstract class BaseRunner extends Serializable {
24
- protected readonly input: BeeInput;
25
- protected readonly options: BeeRunOptions;
26
- protected readonly run: GetRunContext<BeeAgent>;
27
- memory: BaseMemory;
28
- readonly iterations: BeeAgentRunIteration[];
29
- protected readonly failedAttemptsCounter: RetryCounter;
30
- constructor(input: BeeInput, options: BeeRunOptions, run: GetRunContext<BeeAgent>);
31
- createIteration(): Promise<{
32
- emitter: Emitter<BeeCallbacks>;
33
- state: LinePrefixParser.infer<BeeParserInput>;
34
- meta: BeeMeta;
35
- signal: AbortSignal;
36
- }>;
37
- init(input: BeeRunInput): Promise<void>;
38
- abstract llm(input: BeeRunnerLLMInput): Promise<BeeAgentRunIteration>;
39
- abstract tool(input: BeeRunnerToolInput): Promise<{
40
- output: string;
41
- success: boolean;
42
- }>;
43
- abstract get defaultTemplates(): BeeAgentTemplates;
44
- get templates(): BeeAgentTemplates;
45
- protected abstract initMemory(input: BeeRunInput): Promise<BaseMemory>;
46
- createSnapshot(): {
47
- input: BeeInput;
48
- options: BeeRunOptions;
49
- memory: BaseMemory<unknown>;
50
- failedAttemptsCounter: RetryCounter;
51
- };
52
- loadSnapshot(snapshot: ReturnType<typeof this.createSnapshot>): void;
53
- }
54
-
55
- type BeeTemplateFactory<K extends keyof BeeAgentTemplates> = (template: BeeAgentTemplates[K]) => BeeAgentTemplates[K];
56
- interface BeeInput {
57
- llm: ChatModel;
58
- tools: AnyTool[];
59
- memory: BaseMemory;
60
- meta?: Omit<AgentMeta, "tools">;
61
- templates?: Partial<{
62
- [K in keyof BeeAgentTemplates]: BeeAgentTemplates[K] | BeeTemplateFactory<K>;
63
- }>;
64
- execution?: BeeAgentExecutionConfig;
65
- stream?: boolean;
66
- }
67
- declare class BeeAgent extends BaseAgent<BeeRunInput, BeeRunOutput, BeeRunOptions> {
68
- protected readonly input: BeeInput;
69
- readonly emitter: Emitter<BeeCallbacks>;
70
- protected runner: new (...args: ConstructorParameters<typeof BaseRunner>) => BaseRunner;
71
- constructor(input: BeeInput);
72
- set memory(memory: BaseMemory);
73
- get memory(): BaseMemory;
74
- get meta(): AgentMeta;
75
- protected _run(input: BeeRunInput, options: BeeRunOptions | undefined, run: GetRunContext<typeof this>): Promise<BeeRunOutput>;
76
- createSnapshot(): {
77
- input: BeeInput;
78
- emitter: Emitter<BeeCallbacks>;
79
- runner: new (input: BeeInput, options: BeeRunOptions, run: RunContext<BeeAgent, any>) => BaseRunner;
80
- isRunning: boolean;
81
- };
82
- }
83
-
84
- export { BaseRunner as B, type BeeRunnerLLMInput as a, type BeeRunnerToolInput as b, type BeeInput as c, BeeAgent as d, type BeeTemplateFactory as e };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["agent.ts"],"names":["BeeAgent","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,iBAAiBC,kBAAAA,CAAAA;EAxD9B;;;;AAyDkBC,EAAAA,OAAAA;AAKNC,EAAAA,MAAAA;AAEVC,EAAAA,WAAAA,CAA+BC,KAAiB,EAAA;AAC9C,IAAK,KAAA,EAAA,EAAA,KADwBA,KAAAA,GAAAA,KAAAA,EAAAA,KAPfH,OAAUI,GAAAA,mBAAAA,CAAQC,KAAKC,KAAoB,CAAA;MACzDC,SAAW,EAAA;AAAC,QAAA,OAAA;AAAS,QAAA;;MACrBC,OAAS,EAAA;KACX,CAAA;AAOE,IAAMC,MAAAA,SAAAA,GAAYN,MAAMO,KAAMC,CAAAA,IAAAA,CAAK,CAACC,CAAGC,EAAAA,CAAAA,EAAGC,GACxCA,KAAAA,GAAAA,CAAIH,IAAK,CAAA,CAACI,GAAGC,CAAMH,KAAAA,CAAAA,KAAMG,CAAKJ,IAAAA,CAAAA,CAAEK,IAAKC,CAAAA,WAAAA,OAAkBH,CAAEE,CAAAA,IAAAA,CAAKC,WAAW,EAAA,CAAA,CAAA;AAE3E,IAAA,IAAIT,SAAW,EAAA;AACb,MAAA,MAAM,IAAIU,qBAAAA,CACR,CAAkEV,+DAAAA,EAAAA,SAAAA,CAAUQ,IAAI,CAAG,CAAA,CAAA,CAAA;AAEvF;AAEA,IAAA,MAAMG,OAAU,GAAA,IAAA,CAAKjB,KAAMkB,CAAAA,GAAAA,CAAID,QAAQE,WAAW,EAAA;AAClD,IAAA,IAAA,CAAKrB,M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,MAAO4B,CAAAA,MAAAA;AACfC,UAAAA;SACF,CAAA;AACF;AACF;AAEA,IAAI3B,IAAAA,KAAAA,CAAM+E,WAAW,IAAM,EAAA;AACzB,MAAA,MAAM,KAAK/E,KAAM0B,CAAAA,MAAAA,CAAOyB,IACtB,IAAI6B,uBAAAA,CAAYhF,MAAM+E,MAAQ,EAAA;AAC5BH,QAAAA,SAAAA,EAAWvC,GAAIuC,CAAAA;AACjB,OAAA,CAAA,CAAA;AAEJ;AAEA,IAAA,MAAM,IAAK5E,CAAAA,KAAAA,CAAM0B,MAAOyB,CAAAA,GAAAA,CAAIR,YAAAA,CAAAA;AAC5B,IAAO,OAAA;MAAEsC,MAAQtC,EAAAA,YAAAA;AAAcmC,MAAAA,UAAAA,EAAYhF,MAAOgF,CAAAA,UAAAA;AAAYpD,MAAAA,MAAAA,EAAQ5B,MAAO4B,CAAAA;AAAO,KAAA;AACtF;EAEAwD,cAAiB,GAAA;AACf,IAAO,OAAA;AACL,MAAA,GAAG,MAAMA,cAAAA,EAAAA;AACTlF,MAAAA,KAAAA,EAAO,IAAKA,CAAAA,KAAAA;AACZH,MAAAA,OAAAA,EAAS,IAAKA,CAAAA,OAAAA;AACdC,MAAAA,MAAAA,EAAQ,IAAKA,CAAAA;AACf,KAAA;AACF;AACF","file":"agent.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 { 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 BeeAgentExecutionConfig,\n BeeAgentTemplates,\n BeeCallbacks,\n BeeRunInput,\n BeeRunOptions,\n BeeRunOutput,\n} from \"@/agents/bee/types.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { assign } from \"@/internals/helpers/object.js\";\nimport * as R from \"remeda\";\nimport { BaseRunner } from \"@/agents/bee/runners/base.js\";\nimport { GraniteRunner } from \"@/agents/bee/runners/granite/runner.js\";\nimport { DeepThinkRunner } from \"@/agents/bee/runners/deep-think/runner.js\";\nimport { ValueError } from \"@/errors.js\";\nimport { DefaultRunner } from \"@/agents/bee/runners/default/runner.js\";\nimport { ChatModel } from \"@/backend/chat.js\";\n\nexport type BeeTemplateFactory<K extends keyof BeeAgentTemplates> = (\n template: BeeAgentTemplates[K],\n) => BeeAgentTemplates[K];\n\nexport interface BeeInput {\n llm: ChatModel;\n tools: AnyTool[];\n memory: BaseMemory;\n meta?: Omit<AgentMeta, \"tools\">;\n templates?: Partial<{\n [K in keyof BeeAgentTemplates]: BeeAgentTemplates[K] | BeeTemplateFactory<K>;\n }>;\n execution?: BeeAgentExecutionConfig;\n stream?: boolean;\n}\n\nexport class BeeAgent extends BaseAgent<BeeRunInput, BeeRunOutput, BeeRunOptions> {\n public readonly emitter = Emitter.root.child<BeeCallbacks>({\n namespace: [\"agent\", \"bee\"],\n creator: this,\n });\n\n protected runner: new (...args: ConstructorParameters<typeof BaseRunner>) => BaseRunner;\n\n constructor(protected readonly input: BeeInput) {\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: \"Bee\",\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: BeeRunInput,\n options: BeeRunOptions = {},\n run: GetRunContext<typeof this>,\n ): Promise<BeeRunOutput> {\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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["agent.ts"],"names":["BeeAgent","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,iBAAiBC,SAAAA,CAAAA;EAxD9B;;;;AAyDkBC,EAAAA,OAAAA;AAKNC,EAAAA,MAAAA;AAEVC,EAAAA,WAAAA,CAA+BC,KAAiB,EAAA;AAC9C,IAAK,KAAA,EAAA,EAAA,KADwBA,KAAAA,GAAAA,KAAAA,EAAAA,KAPfH,OAAUI,GAAAA,OAAAA,CAAQC,KAAKC,KAAoB,CAAA;MACzDC,SAAW,EAAA;AAAC,QAAA,OAAA;AAAS,QAAA;;MACrBC,OAAS,EAAA;KACX,CAAA;AAOE,IAAMC,MAAAA,SAAAA,GAAYN,MAAMO,KAAMC,CAAA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AKA,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 BeeAgentExecutionConfig,\n BeeAgentTemplates,\n BeeCallbacks,\n BeeRunInput,\n BeeRunOptions,\n BeeRunOutput,\n} from \"@/agents/bee/types.js\";\nimport { GetRunContext } from \"@/context.js\";\nimport { assign } from \"@/internals/helpers/object.js\";\nimport * as R from \"remeda\";\nimport { BaseRunner } from \"@/agents/bee/runners/base.js\";\nimport { GraniteRunner } from \"@/agents/bee/runners/granite/runner.js\";\nimport { DeepThinkRunner } from \"@/agents/bee/runners/deep-think/runner.js\";\nimport { ValueError } from \"@/errors.js\";\nimport { DefaultRunner } from \"@/agents/bee/runners/default/runner.js\";\nimport { ChatModel } from \"@/backend/chat.js\";\n\nexport type BeeTemplateFactory<K extends keyof BeeAgentTemplates> = (\n template: BeeAgentTemplates[K],\n) => BeeAgentTemplates[K];\n\nexport interface BeeInput {\n llm: ChatModel;\n tools: AnyTool[];\n memory: BaseMemory;\n meta?: Omit<AgentMeta, \"tools\">;\n templates?: Partial<{\n [K in keyof BeeAgentTemplates]: BeeAgentTemplates[K] | BeeTemplateFactory<K>;\n }>;\n execution?: BeeAgentExecutionConfig;\n stream?: boolean;\n}\n\nexport class BeeAgent extends BaseAgent<BeeRunInput, BeeRunOutput, BeeRunOptions> {\n public readonly emitter = Emitter.root.child<BeeCallbacks>({\n namespace: [\"agent\", \"bee\"],\n creator: this,\n });\n\n protected runner: new (...args: ConstructorParameters<typeof BaseRunner>) => BaseRunner;\n\n constructor(protected readonly input: BeeInput) {\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: \"Bee\",\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: BeeRunInput,\n options: BeeRunOptions = {},\n run: GetRunContext<typeof this>,\n ): Promise<BeeRunOutput> {\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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["prompts.ts"],"names":["BeeSystemPrompt","PromptTemplate","schema","z","object","instructions","string","default","tools","array","name","min","description","passthrough","createdAt","datetime","nullish","template","BeeAssistantPrompt","thought","toolName","toolInput","toolOutput","finalAnswer","partial","BeeUserPrompt","input","meta","optional","functions","formatMeta","parts","filter","Boolean","join","BeeUserEmptyPrompt","BeeToolErrorPrompt","reason","BeeToolInputErrorPrompt","BeeToolNoResultsPrompt","record","any","BeeToolNotFoundPrompt","BeeSchemaErrorPrompt"],"mappings":";;;;;;;AAoBaA,MAAAA,eAAAA,G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,IAAInC,2BAAe,CAAA;AACnDC,EAAAA,MAAAA,EAAQC,MACLC,MAAO,CAAA;AACNiC,IAAAA,MAAAA,EAAQlC,MAAEG,MAAM;AAClB,GAAA,EACCO,WAAW,EAAA;EACdI,QAAU,EAAA,CAAA;;;AAGZ,CAAA;AAEaqB,MAAAA,uBAAAA,GAA0B,IAAIrC,2BAAe,CAAA;AACxDC,EAAAA,MAAAA,EAAQC,MACLC,MAAO,CAAA;AACNiC,IAAAA,MAAAA,EAAQlC,MAAEG,MAAM;AAClB,GAAA,EACCO,WAAW,EAAA;EACdI,QAAU,EAAA,CAAA;;;AAGZ,CAAA;AAEasB,MAAAA,sBAAAA,GAAyB,IAAItC,2BAAe,CAAA;AACvDC,EAAAA,MAAAA,EAAQC,KAAEqC,CAAAA,MAAAA,CAAOrC,KAAEsC,CAAAA,GAAAA,EAAG,CAAA;EACtBxB,QAAU,EAAA,CAAA,sBAAA;AACZ,CAAA;AAEayB,MAAAA,qBAAAA,GAAwB,IAAIzC,2BAAe,CAAA;AACtDC,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,oBAAAA,GAAuB,IAAI1C,2BAAe,CAAA;AACrDC,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 BeeSystemPrompt = 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 BeeAssistantPrompt = 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 BeeUserPrompt = 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 BeeUserEmptyPrompt = new PromptTemplate({\n schema: z.object({}).passthrough(),\n template: `Message: Empty message.`,\n});\n\nexport const BeeToolErrorPrompt = 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 BeeToolInputErrorPrompt = 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 BeeToolNoResultsPrompt = new PromptTemplate({\n schema: z.record(z.any()),\n template: `No results were found!`,\n});\n\nexport const BeeToolNotFoundPrompt = 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 BeeSchemaErrorPrompt = 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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["prompts.ts"],"names":["BeeSystemPrompt","PromptTemplate","schema","z","object","instructions","string","default","tools","array","name","min","description","passthrough","createdAt","datetime","nullish","template","BeeAssistantPrompt","thought","toolName","toolInput","toolOutput","finalAnswer","partial","BeeUserPrompt","input","meta","optional","functions","formatMeta","parts","filter","Boolean","join","BeeUserEmptyPrompt","BeeToolErrorPrompt","reason","BeeToolInputErrorPrompt","BeeToolNoResultsPrompt","record","any","BeeToolNotFoundPrompt","BeeSchemaErrorPrompt"],"mappings":";;;;;AAoBaA,MAAAA,eAAAA,GAAkB,IAAIC,cAAe,CAAA;AAChDC,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,aAAW,CAAA;AAEhBC,IAAAA,SAAAA,EAAWX,CAAEG,CAAAA,MAAAA,EAASS,CAAAA,QAAAA,GAAWC,OAAO;GAC1C,CAAA;EACAC,QAAU,EAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEZ,CAAA;AAEaC,MAAAA,kBAAAA,GAAqB,IAAIjB,cAAe,CAAA;AACnDC,EAAAA,MAAAA,EAAQC,EACLC,MAAO,CAAA;AACNe,IAAAA,OAAAA,EAAShB,CAAEM,CAAAA,KAAAA,CAAMN,CAAEG,CAAAA,MAAAA,EAAM,CAAA;AACzBc,IAAAA,QAAAA,EAAUjB,CAAEM,CAAAA,KAAAA,CAAMN,CAAEG,CAAAA,MAAAA,EAAM,CAAA;AAC1Be,IAAAA,SAAAA,EAAWlB,C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A","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 BeeSystemPrompt = 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 BeeAssistantPrompt = 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 BeeUserPrompt = 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 BeeUserEmptyPrompt = new PromptTemplate({\n schema: z.object({}).passthrough(),\n template: `Message: Empty message.`,\n});\n\nexport const BeeToolErrorPrompt = 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 BeeToolInputErrorPrompt = 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 BeeToolNoResultsPrompt = new PromptTemplate({\n schema: z.record(z.any()),\n template: `No results were found!`,\n});\n\nexport const BeeToolNotFoundPrompt = 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 BeeSchemaErrorPrompt = 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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["prompts.ts"],"names":["DeepThinkBeeAssistantPrompt","BeeAssistantPrompt","fork","config","template","DeepThinkBeeSystemPrompt","BeeSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","DeepThinkBeeSchemaErrorPrompt","BeeSchemaErrorPrompt","DeepThinkBeeUserPrompt","BeeUserPrompt","DeepThinkBeeToolNotFoundPrompt","BeeToolNotFoundPrompt","DeepThinkBeeToolErrorPrompt","BeeToolErrorPrompt","DeepThinkBeeToolInputErrorPrompt","BeeToolInputErrorPrompt"],"mappings":";;;;AA0BO,MAAMA,2BAA8BC,GAAAA,8BAAAA,CAAmBC,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAClEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;;AACpB,CAAA;AAEO,MAAMC,wBAA2BC,GAAAA,2BAAAA,CAAgBJ,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAC5DA,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,6BAAgCC,GAAAA,gCAAAA,CAAqBlB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACtEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;AAEpB,CAAA;AAEO,MAAMiB,sBAAyBC,GAAAA,yBAAAA,CAAcpB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACxDA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA,SAAA,CAAA;AACpB,CAAA;AAEO,MAAMmB,8BAAiCC,GAAAA,iCAAAA,CAAsBtB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACxEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;AAIpB,CAAA;AAEO,MAAMqB,2BAA8BC,GAAAA,8BAAAA,CAAmBxB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAClEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;AAGpB,CAAA;AAEO,MAAMuB,gCAAmCC,GAAAA,mCAAAA,CAAwB1B,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAC5EA,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 BeeAssistantPrompt,\n BeeSchemaErrorPrompt,\n BeeSystemPrompt,\n BeeToolErrorPrompt,\n BeeToolInputErrorPrompt,\n BeeToolNotFoundPrompt,\n BeeUserPrompt,\n} from \"@/agents/bee/prompts.js\";\n\nexport const DeepThinkBeeAssistantPrompt = BeeAssistantPrompt.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 DeepThinkBeeSystemPrompt = BeeSystemPrompt.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 DeepThinkBeeSchemaErrorPrompt = BeeSchemaErrorPrompt.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 DeepThinkBeeUserPrompt = BeeUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const DeepThinkBeeToolNotFoundPrompt = BeeToolNotFoundPrompt.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 DeepThinkBeeToolErrorPrompt = BeeToolErrorPrompt.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 DeepThinkBeeToolInputErrorPrompt = BeeToolInputErrorPrompt.fork((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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["prompts.ts"],"names":["DeepThinkBeeAssistantPrompt","BeeAssistantPrompt","fork","config","template","DeepThinkBeeSystemPrompt","BeeSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","DeepThinkBeeSchemaErrorPrompt","BeeSchemaErrorPrompt","DeepThinkBeeUserPrompt","BeeUserPrompt","DeepThinkBeeToolNotFoundPrompt","BeeToolNotFoundPrompt","DeepThinkBeeToolErrorPrompt","BeeToolErrorPrompt","DeepThinkBeeToolInputErrorPrompt","BeeToolInputErrorPrompt"],"mappings":";;AA0BO,MAAMA,2BAA8BC,GAAAA,kBAAAA,CAAmBC,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAClEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;;AACpB,CAAA;AAEO,MAAMC,wBAA2BC,GAAAA,eAAAA,CAAgBJ,IAAK,CAAA,CAACC,MAAAA,KAAAA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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 BeeAssistantPrompt,\n BeeSchemaErrorPrompt,\n BeeSystemPrompt,\n BeeToolErrorPrompt,\n BeeToolInputErrorPrompt,\n BeeToolNotFoundPrompt,\n BeeUserPrompt,\n} from \"@/agents/bee/prompts.js\";\n\nexport const DeepThinkBeeAssistantPrompt = BeeAssistantPrompt.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 DeepThinkBeeSystemPrompt = BeeSystemPrompt.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 DeepThinkBeeSchemaErrorPrompt = BeeSchemaErrorPrompt.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 DeepThinkBeeUserPrompt = BeeUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const DeepThinkBeeToolNotFoundPrompt = BeeToolNotFoundPrompt.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 DeepThinkBeeToolErrorPrompt = BeeToolErrorPrompt.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 DeepThinkBeeToolInputErrorPrompt = BeeToolInputErrorPrompt.fork((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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["runner.ts"],"names":["DeepThinkRunner","DefaultRunner","defaultTemplates","system","DeepThinkBeeSystemPrompt","assistant","DeepThinkBeeAssistantPrompt","user","DeepThinkBeeUserPrompt","schemaError","DeepThinkBeeSchemaErrorPrompt","toolNotFoundError","DeepThinkBeeToolNotFoundPrompt","toolError","DeepThinkBeeToolErrorPrompt","toolInputError","DeepThinkBeeToolInputErrorPrompt","userEmpty","BeeUserEmptyPrompt","toolNoResultError","BeeToolNoResultsPrompt","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":";;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAMA,wBAAwBC,wBAAAA,CAAAA;AAAAA,EAAAA;;;AACnC,EAAA,IACWC,gBAAmB,GAAA;AAC5B,IAAO,OAAA;MACLC,MAAQC,EAAAA,sCAAAA;MACRC,SAAWC,EAAAA,yCAAAA;MACXC,IAAMC,EAAAA,oCAAAA;MACNC,WAAaC,EAAAA,2CAAAA;MACbC,iBAAmBC,EAAAA,4CAAAA;MACnBC,SAAWC,EAAAA,yCAAAA;MACXC,cAAgBC,EAAAA,8CAAAA;;MAEhBC,SAAWC,EAAAA,8BAAAA;MACXC,iBAAmBC,EAAAA;AACrB,KAAA;AACF;EAEA;AACE,IAAA,IAAA,CAAKC,QAAQ,EAAA;AACf;EAEAC,WAAYC,CAAAA,KAAAA,EAAiBC,SAAwBC,GAA8B,EAAA;AACjF,IAAMF,KAAAA,CAAAA,KAAAA,EAAOC,SAASC,GAAAA,CAAAA;AAEtBA,IAAIC,GAAAA,CAAAA,OAAAA,CAAQC,GACV,QACA,EAAA,OAAO,EAAEC,MAAQC,EAAAA,IAAAA,EAAMC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;AAAE,YAAA,GAAGf,KAAMe,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;;;IA7EWiB,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/bee/runners/default/runner.js\";\nimport {\n DeepThinkBeeAssistantPrompt,\n DeepThinkBeeSchemaErrorPrompt,\n DeepThinkBeeSystemPrompt,\n DeepThinkBeeToolErrorPrompt,\n DeepThinkBeeToolInputErrorPrompt,\n DeepThinkBeeToolNotFoundPrompt,\n DeepThinkBeeUserPrompt,\n} from \"@/agents/bee/runners/deep-think/prompts.js\";\nimport { BeeToolNoResultsPrompt, BeeUserEmptyPrompt } from \"@/agents/bee/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\nimport { ZodParserField } from \"@/parsers/field.js\";\nimport { z } from \"zod\";\nimport { BeeInput, BeeAgent } from \"@/agents/bee/agent.js\";\nimport { BeeRunOptions } from \"@/agents/bee/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: DeepThinkBeeSystemPrompt,\n assistant: DeepThinkBeeAssistantPrompt,\n user: DeepThinkBeeUserPrompt,\n schemaError: DeepThinkBeeSchemaErrorPrompt,\n toolNotFoundError: DeepThinkBeeToolNotFoundPrompt,\n toolError: DeepThinkBeeToolErrorPrompt,\n toolInputError: DeepThinkBeeToolInputErrorPrompt,\n // Note: These are from bee\n userEmpty: BeeUserEmptyPrompt,\n toolNoResultError: BeeToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n constructor(input: BeeInput, options: BeeRunOptions, run: GetRunContext<BeeAgent>) {\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 +0,0 @@
1
- {"version":3,"sources":["runner.ts"],"names":["DeepThinkRunner","DefaultRunner","defaultTemplates","system","DeepThinkBeeSystemPrompt","assistant","DeepThinkBeeAssistantPrompt","user","DeepThinkBeeUserPrompt","schemaError","DeepThinkBeeSchemaErrorPrompt","toolNotFoundError","DeepThinkBeeToolNotFoundPrompt","toolError","DeepThinkBeeToolErrorPrompt","toolInputError","DeepThinkBeeToolInputErrorPrompt","userEmpty","BeeUserEmptyPrompt","toolNoResultError","BeeToolNoResultsPrompt","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":";;;;;;;;;;;;;;;;;;;;;AAoCO,MAAMA,wBAAwBC,aAAAA,CAAAA;AAAAA,EAAAA;;;AACnC,EAAA,IACWC,gBAAmB,GAAA;AAC5B,IAAO,OAAA;MACLC,MAAQC,EAAAA,wBAAAA;MACRC,SAAWC,EAAAA,2BAAAA;MACXC,IAAMC,EAAAA,sBAAAA;MACNC,WAAaC,EAAAA,6BAAAA;MACbC,iBAAmBC,EAAAA,8BAAAA;MACnBC,SAAWC,EAAAA,2BAAAA;MACXC,cAAgBC,EAAAA,gCAAAA;;MAEhBC,SAAWC,EAAAA,kBAAAA;MACXC,iBAAmBC,EAAAA;AACrB,KAAA;AACF;EAEA;AACE,IAAA,IAAA,CAAKC,QAAQ,EAAA;AACf;EAEAC,WAAYC,CAAAA,KAAAA,EAAiBC,SAAwBC,GAA8B,EAAA;AACjF,IAAMF,KAAAA,CAAAA,KAAAA,EAAOC,SAASC,GAAAA,CAAAA;AAEtBA,IAAIC,GAAAA,CAAAA,OAAAA,CAAQC,GACV,Q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KAAA,EAAA,CAAA;AACxD,WAAA;UACAC,SAAW,EAAA;AAAE,YAAA,GAAGf,KAAMe,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;;;IA7EWiB,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/bee/runners/default/runner.js\";\nimport {\n DeepThinkBeeAssistantPrompt,\n DeepThinkBeeSchemaErrorPrompt,\n DeepThinkBeeSystemPrompt,\n DeepThinkBeeToolErrorPrompt,\n DeepThinkBeeToolInputErrorPrompt,\n DeepThinkBeeToolNotFoundPrompt,\n DeepThinkBeeUserPrompt,\n} from \"@/agents/bee/runners/deep-think/prompts.js\";\nimport { BeeToolNoResultsPrompt, BeeUserEmptyPrompt } from \"@/agents/bee/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\nimport { ZodParserField } from \"@/parsers/field.js\";\nimport { z } from \"zod\";\nimport { BeeInput, BeeAgent } from \"@/agents/bee/agent.js\";\nimport { BeeRunOptions } from \"@/agents/bee/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: DeepThinkBeeSystemPrompt,\n assistant: DeepThinkBeeAssistantPrompt,\n user: DeepThinkBeeUserPrompt,\n schemaError: DeepThinkBeeSchemaErrorPrompt,\n toolNotFoundError: DeepThinkBeeToolNotFoundPrompt,\n toolError: DeepThinkBeeToolErrorPrompt,\n toolInputError: DeepThinkBeeToolInputErrorPrompt,\n // Note: These are from bee\n userEmpty: BeeUserEmptyPrompt,\n toolNoResultError: BeeToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n constructor(input: BeeInput, options: BeeRunOptions, run: GetRunContext<BeeAgent>) {\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 +0,0 @@
1
- {"version":3,"sources":["runner.ts"],"names":["DefaultRunner","BaseRunner","useNativeToolCalling","defaultTemplates","system","BeeSystemPrompt","assistant","BeeAssistantPrompt","user","BeeUserPrompt","schemaError","BeeSchemaErrorPrompt","toolNotFoundError","BeeToolNotFoundPrompt","toolError","BeeToolErrorPrompt","toolInputError","BeeToolInputErrorPrompt","userEmpty","BeeUserEmptyPrompt","toolNoResultError","BeeToolNoResultsPrompt","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","enumerable"],"mappings":";;;;;;;;;;;;;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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 { BaseRunner, BeeRunnerLLMInput, BeeRunnerToolInput } from \"@/agents/bee/runners/base.js\";\nimport type { BeeAgentRunIteration, BeeParserInput, BeeRunInput } from \"@/agents/bee/types.js\";\nimport { Retryable } from \"@/internals/helpers/retryable.js\";\nimport { AgentError } from \"@/agents/base.js\";\nimport {\n BeeAssistantPrompt,\n BeeSchemaErrorPrompt,\n BeeSystemPrompt,\n BeeToolErrorPrompt,\n BeeToolInputErrorPrompt,\n BeeToolNoResultsPrompt,\n BeeToolNotFoundPrompt,\n BeeUserEmptyPrompt,\n BeeUserPrompt,\n} from \"@/agents/bee/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: BeeSystemPrompt,\n assistant: BeeAssistantPrompt,\n user: BeeUserPrompt,\n schemaError: BeeSchemaErrorPrompt,\n toolNotFoundError: BeeToolNotFoundPrompt,\n toolError: BeeToolErrorPrompt,\n toolInputError: BeeToolInputErrorPrompt,\n userEmpty: BeeUserEmptyPrompt,\n toolNoResultError: BeeToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n async llm({ signal, meta, emitter }: BeeRunnerLLMInput): Promise<BeeAgentRunIteration> {\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 }: BeeRunnerToolInput) {\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 }: BeeRunInput) =>\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 }: BeeRunInput): 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 ?? BeeUserEmptyPrompt).render({})\n : (this.templates?.user ?? BeeUserPrompt).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<BeeParserInput>(\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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["runner.ts"],"names":["DefaultRunner","BaseRunner","useNativeToolCalling","defaultTemplates","system","BeeSystemPrompt","assistant","BeeAssistantPrompt","user","BeeUserPrompt","schemaError","BeeSchemaErrorPrompt","toolNotFoundError","BeeToolNotFoundPrompt","toolError","BeeToolErrorPrompt","toolInputError","BeeToolInputErrorPrompt","userEmpty","BeeUserEmptyPrompt","toolNoResultError","BeeToolNoResultsPrompt","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","enumerable"],"mappings":";;;;;;;;;;;;;;;;;;AAcC,SAAA,YAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GAAA,EAAA,IAAA,EAAA;;;;;;AAAA,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA;;;;;AA8BM,MAAMA,sBAAsBC,UAAAA,CAAAA;EA5CnC;;;EA6CYC,oBAAuB,GAAA,KAAA;AAEjC,EAA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MAAAA,CAAO,EAAC,EAAGC,WAAW,EAAA;AAChCC,UAAAA,IAAAA,EAAM,EAAC;UACPC,SAAW,EAAA;AAAC,YAAA,GAAA;AAAK,YAAA;;SACnB;AACF,OAAA;MACApG,WAAa,EAAA;QACXsF,MAAQ,EAAA,kBAAA;QACRC,IAAM,EAAA;AAAC,UAAA;;QACPQ,KAAO,EAAA,IAAA;AACP3G,QAAAA,KAAAA,EAAO,IAAIqG,cAAAA,CAAeC,CAAEC,CAAAA,MAAAA,EAAM;AACpC,OAAA;MACAU,YAAc,EAAA;QACZf,MAAQ,EAAA,eAAA;AACRC,QAAAA,IAAAA,EAAM,EAAA;QACNC,OAAS,EAAA,IAAA;QACTO,KAAO,EAAA,IAAA;AACP3G,QAAAA,KAAAA,EAAO,IAAIqG,cAAeC,CAAAA,CAAAA,CAAEC,QAASC,CAAAA,GAAAA,CAAI,CAAA,CAAA;AAC3C;KAEF,EAAA;MACEU,gBAAkB,EAAA,IAAA;MAClBC,WAAa,EAAA,IAAA;MACbC,QAAU,kBAAA,MAAA,CAAA,CAACC,UACTA,KACI,GAAA;AACE,QAAA;UAAEtH,GAAK,EAAA,SAAA;UAAWD,KAAO,EAAA;AAA+B,SAAA;AACxD,QAAA;UAAEC,GAAK,EAAA,cAAA;UAAgBD,KAAOuH,EAAAA;AAAM;AAEtC,OAAA,GAAA,EANI,EAAA,UAAA;KAOZ,CAAA;AAGF,IAAO,OAAA;AACLlI,MAAAA;AACF,KAAA;AACF;AACF;;;IAvXWmI,UAAY,EAAA;;;;;;;IA2NZA,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 { BaseRunner, BeeRunnerLLMInput, BeeRunnerToolInput } from \"@/agents/bee/runners/base.js\";\nimport type { BeeAgentRunIteration, BeeParserInput, BeeRunInput } from \"@/agents/bee/types.js\";\nimport { Retryable } from \"@/internals/helpers/retryable.js\";\nimport { AgentError } from \"@/agents/base.js\";\nimport {\n BeeAssistantPrompt,\n BeeSchemaErrorPrompt,\n BeeSystemPrompt,\n BeeToolErrorPrompt,\n BeeToolInputErrorPrompt,\n BeeToolNoResultsPrompt,\n BeeToolNotFoundPrompt,\n BeeUserEmptyPrompt,\n BeeUserPrompt,\n} from \"@/agents/bee/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: BeeSystemPrompt,\n assistant: BeeAssistantPrompt,\n user: BeeUserPrompt,\n schemaError: BeeSchemaErrorPrompt,\n toolNotFoundError: BeeToolNotFoundPrompt,\n toolError: BeeToolErrorPrompt,\n toolInputError: BeeToolInputErrorPrompt,\n userEmpty: BeeUserEmptyPrompt,\n toolNoResultError: BeeToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n async llm({ signal, meta, emitter }: BeeRunnerLLMInput): Promise<BeeAgentRunIteration> {\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 }: BeeRunnerToolInput) {\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 }: BeeRunInput) =>\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 }: BeeRunInput): 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 ?? BeeUserEmptyPrompt).render({})\n : (this.templates?.user ?? BeeUserPrompt).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<BeeParserInput>(\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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["runner.spec.ts"],"names":["vi","mock","UnconstrainedMemory","TokenMemory","describe","beforeEach","useRealTimers","it","useFakeTimers","setSystemTime","Date","createMemory","memory","addMany","UserMessage","AssistantMessage","createInstance","prompt","instance","DefaultRunner","llm","expect","any","Function","tools","templates","RunContext","init","memory2","add","createdAt","instance2","messages","toEqual","each","BeeUserPrompt","fork","old","functions","formatMeta","template","user","a","b","zip","filter","msg","role","Role","USER","render","input","text","meta","undefined","toStrictEqual"],"mappings":";;;;;;;;;;;AAyBAA,EA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MAAO,CAAA;AAAEC,QAAAA,KAAAA,EAAOT,CAAEU,CAAAA,IAAAA;QAAMC,IAAMC,EAAAA;AAAU,OAAA,CAAA,CAAA,CAAIC,aAAcZ,CAAAA,CAAAA,CAAES,IAAI,CAAA;AAClF;GACF,CAAA;AACF,CAAA,CAAA","file":"runner.spec.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 { DefaultRunner } from \"@/agents/bee/runners/default/runner.js\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { AssistantMessage, Role, UserMessage } from \"@/backend/message.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { BeeUserPrompt } from \"@/agents/bee/prompts.js\";\nimport { zip } from \"remeda\";\nimport { RunContext } from \"@/context.js\";\nimport { BeeAgent } from \"@/agents/bee/agent.js\";\n\nvi.mock(\"@/memory/tokenMemory.js\", async () => {\n const { UnconstrainedMemory } = await import(\"@/memory/unconstrainedMemory.js\");\n class TokenMemory extends UnconstrainedMemory {}\n return { TokenMemory };\n});\n\nvi.mock(\"@/context.js\");\n\ndescribe(\"Bee Agent Runner\", () => {\n beforeEach(() => {\n vi.useRealTimers();\n });\n\n it(\"Handles different prompt input source\", async () => {\n vi.useFakeTimers();\n vi.setSystemTime(new Date(\"2024-09-10T19:51:46.954Z\"));\n\n const createMemory = async () => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([\n new UserMessage(\"What is your name?\"),\n new AssistantMessage(\"I am Bee\"),\n ]);\n return memory;\n };\n\n const createInstance = async (memory: BaseMemory, prompt: string | null) => {\n const instance = new DefaultRunner(\n {\n llm: expect.any(Function),\n memory,\n tools: [],\n templates: {},\n },\n {},\n new RunContext<BeeAgent, any>({} as any, {} as any),\n );\n await instance.init({ prompt });\n return instance;\n };\n\n const memory = await createMemory();\n const prompt = \"What can you do for me?\";\n const instance = await createInstance(memory, prompt);\n\n const memory2 = await createMemory();\n await memory2.add(new UserMessage(prompt, { createdAt: new Date() }));\n const instance2 = await createInstance(memory2, null);\n expect(instance.memory.messages).toEqual(instance2.memory.messages);\n });\n\n it.each([\n BeeUserPrompt.fork((old) => ({\n ...old,\n functions: { ...old.functions, formatMeta: () => \"\" },\n })),\n BeeUserPrompt.fork((old) => ({ ...old, template: `{{input}}` })),\n BeeUserPrompt.fork((old) => ({ ...old, template: `User: {{input}}` })),\n BeeUserPrompt.fork((old) => ({ ...old, template: `` })),\n ])(\"Correctly formats user input\", async (template: typeof BeeUserPrompt) => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([\n new UserMessage(\"What is your name?\"),\n new AssistantMessage(\"Bee\"),\n new UserMessage(\"Who are you?\"),\n new AssistantMessage(\"I am a helpful assistant.\"),\n ]);\n\n const prompt = \"What can you do for me?\";\n const instance = new DefaultRunner(\n {\n llm: expect.any(Function),\n memory,\n tools: [],\n templates: {\n user: template,\n },\n },\n {},\n new RunContext<BeeAgent, any>({} as any, {} as any),\n );\n await instance.init({ prompt });\n\n for (const [a, b] of zip(\n [...memory.messages.filter((msg) => msg.role === Role.USER), new UserMessage(prompt)],\n instance.memory.messages.filter((msg) => msg.role === Role.USER),\n )) {\n expect(template.render({ input: a.text, meta: undefined })).toStrictEqual(b.text);\n }\n });\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["runner.spec.ts"],"names":["vi","mock","UnconstrainedMemory","TokenMemory","describe","beforeEach","useRealTimers","it","useFakeTimers","setSystemTime","Date","createMemory","memory","addMany","UserMessage","AssistantMessage","createInstance","prompt","instance","DefaultRunner","llm","expect","any","Function","tools","templates","RunContext","init","memory2","add","createdAt","instance2","messages","toEqual","each","BeeUserPrompt","fork","old","functions","formatMeta","template","user","a","b","zip","filter","msg","role","Role","USER","render","input","text","meta","undefined","toStrictEqual"],"mappings":";;;;;;;;;AAyBAA,EAAGC,CAAAA,IAAAA,CAAK,2BAA2B,YAAA;AACjC,EAAA,MAAM,EAAEC,mBAAAA,EAAAA,oBAAAA,EAAwB,GAAA,MAAM,OAAO,2CAAA,CAAA;AAC7C,EAAMC,IAAAA,WAAAA,GAAN,MAAMA,WAAAA,SAAoBD,oBAAAA,CAAAA;IA3B5B;;;AA2BiD,GAAA;AAC/C,EAAO,OAAA;AAAEC,IAAAA;AAAY,GAAA;AACvB,CAAA,CAAA;AAEAH,EAAAA,CAAGC,KAAK,cAAA,CAAA;AAERG,QAAAA,CAAS,oBAAoB,MAAA;AAC3BC,EAAAA,UAAAA,CAAW,MAAA;AACTL,IAAAA,EAAAA,CAAGM,aAAa,EAAA;GAClB,CAAA;AAEAC,EAAAA,EAAAA,CAAG,yCAAyC,YAAA;AAC1CP,IAAAA,EAAAA,CAAGQ,aAAa,EAAA;AAChBR,IAAAA,EAAAA,CAAGS,aAAc,iBAAA,IAAIC,IAAK,CAAA,0BAAA,CAAA,CAAA;AAE1B,IAAA,MAAMC,+BAAe,MAAA,CAAA,YAAA;AACnB,MAAMC,MAAAA,OAAAA,GAAS,IAAIV,mBAAAA,EAAAA;AACnB,MAAA,MAAMU,QAAOC,OAAQ,CAAA;AACnB,QAAA,IAAIC,YAAY,oBAAA,CAAA;AAChB,QAAA,IAAIC,iBAAiB,UAAA;AACtB,OAAA,CAAA;AACD,MAAOH,OAAAA,OAAAA;KANY,EAAA,cAAA,CAAA;AASrB,IAAMI,MAAAA,cAAAA,mBAAwBJ,MAAAA,CAAAA,OAAAA,OAAAA,EAAoBK,OAAAA,KAAAA;AAChD,MAAMC,MAAAA,SAAAA,GAAW,IAAIC,aACnB,CAAA;QACEC,GAAKC,EAAAA,MAAAA,CAAOC,IAAIC,QAAAA,C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CAAO,CAACC,GAAAA,KAAQA,IAAIC,IAASC,KAAAA,IAAAA,CAAKC,IAAI,CAAA,CAC9D,EAAA;AACD5B,MAAAA,MAAAA,CAAOmB,SAASU,MAAO,CAAA;AAAEC,QAAAA,KAAAA,EAAOT,CAAEU,CAAAA,IAAAA;QAAMC,IAAMC,EAAAA;AAAU,OAAA,CAAA,CAAA,CAAIC,aAAcZ,CAAAA,CAAAA,CAAES,IAAI,CAAA;AAClF;GACF,CAAA;AACF,CAAA,CAAA","file":"runner.spec.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 { DefaultRunner } from \"@/agents/bee/runners/default/runner.js\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { AssistantMessage, Role, UserMessage } from \"@/backend/message.js\";\nimport { BaseMemory } from \"@/memory/base.js\";\nimport { BeeUserPrompt } from \"@/agents/bee/prompts.js\";\nimport { zip } from \"remeda\";\nimport { RunContext } from \"@/context.js\";\nimport { BeeAgent } from \"@/agents/bee/agent.js\";\n\nvi.mock(\"@/memory/tokenMemory.js\", async () => {\n const { UnconstrainedMemory } = await import(\"@/memory/unconstrainedMemory.js\");\n class TokenMemory extends UnconstrainedMemory {}\n return { TokenMemory };\n});\n\nvi.mock(\"@/context.js\");\n\ndescribe(\"Bee Agent Runner\", () => {\n beforeEach(() => {\n vi.useRealTimers();\n });\n\n it(\"Handles different prompt input source\", async () => {\n vi.useFakeTimers();\n vi.setSystemTime(new Date(\"2024-09-10T19:51:46.954Z\"));\n\n const createMemory = async () => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([\n new UserMessage(\"What is your name?\"),\n new AssistantMessage(\"I am Bee\"),\n ]);\n return memory;\n };\n\n const createInstance = async (memory: BaseMemory, prompt: string | null) => {\n const instance = new DefaultRunner(\n {\n llm: expect.any(Function),\n memory,\n tools: [],\n templates: {},\n },\n {},\n new RunContext<BeeAgent, any>({} as any, {} as any),\n );\n await instance.init({ prompt });\n return instance;\n };\n\n const memory = await createMemory();\n const prompt = \"What can you do for me?\";\n const instance = await createInstance(memory, prompt);\n\n const memory2 = await createMemory();\n await memory2.add(new UserMessage(prompt, { createdAt: new Date() }));\n const instance2 = await createInstance(memory2, null);\n expect(instance.memory.messages).toEqual(instance2.memory.messages);\n });\n\n it.each([\n BeeUserPrompt.fork((old) => ({\n ...old,\n functions: { ...old.functions, formatMeta: () => \"\" },\n })),\n BeeUserPrompt.fork((old) => ({ ...old, template: `{{input}}` })),\n BeeUserPrompt.fork((old) => ({ ...old, template: `User: {{input}}` })),\n BeeUserPrompt.fork((old) => ({ ...old, template: `` })),\n ])(\"Correctly formats user input\", async (template: typeof BeeUserPrompt) => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([\n new UserMessage(\"What is your name?\"),\n new AssistantMessage(\"Bee\"),\n new UserMessage(\"Who are you?\"),\n new AssistantMessage(\"I am a helpful assistant.\"),\n ]);\n\n const prompt = \"What can you do for me?\";\n const instance = new DefaultRunner(\n {\n llm: expect.any(Function),\n memory,\n tools: [],\n templates: {\n user: template,\n },\n },\n {},\n new RunContext<BeeAgent, any>({} as any, {} as any),\n );\n await instance.init({ prompt });\n\n for (const [a, b] of zip(\n [...memory.messages.filter((msg) => msg.role === Role.USER), new UserMessage(prompt)],\n instance.memory.messages.filter((msg) => msg.role === Role.USER),\n )) {\n expect(template.render({ input: a.text, meta: undefined })).toStrictEqual(b.text);\n }\n });\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["prompts.ts"],"names":["GraniteBeeAssistantPrompt","BeeAssistantPrompt","fork","config","template","GraniteBeeSystemPrompt","BeeSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","GraniteBeeSchemaErrorPrompt","BeeSchemaErrorPrompt","GraniteBeeUserPrompt","BeeUserPrompt","GraniteBeeToolNotFoundPrompt","BeeToolNotFoundPrompt","GraniteBeeToolErrorPrompt","BeeToolErrorPrompt","GraniteBeeToolInputErrorPrompt","BeeToolInputErrorPrompt"],"mappings":";;;;AA0BO,MAAMA,yBAA4BC,GAAAA,8BAAAA,CAAmBC,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAChEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;AACpB,CAAA;AAEO,MAAMC,sBAAyBC,GAAAA,2BAAAA,CAAgBJ,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAC1DA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCpB,CAAA;AAEO,MAAMe,2BAA8BC,GAAAA,gCAAAA,CAAqBlB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACpEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;AAEpB,CAAA;AAEO,MAAMiB,oBAAuBC,GAAAA,yBAAAA,CAAcpB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACtDA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA,SAAA,CAAA;AACpB,CAAA;AAEO,MAAMmB,4BAA+BC,GAAAA,iCAAAA,CAAsBtB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AACtEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;;AAIpB,CAAA;AAEO,MAAMqB,yBAA4BC,GAAAA,8BAAAA,CAAmBxB,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAChEA,EAAAA,MAAAA,CAAOC,QAAW,GAAA,CAAA;;;AAGpB,CAAA;AAEO,MAAMuB,8BAAiCC,GAAAA,mCAAAA,CAAwB1B,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAC1EA,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 BeeAssistantPrompt,\n BeeSchemaErrorPrompt,\n BeeSystemPrompt,\n BeeToolErrorPrompt,\n BeeToolInputErrorPrompt,\n BeeToolNotFoundPrompt,\n BeeUserPrompt,\n} from \"@/agents/bee/prompts.js\";\n\nexport const GraniteBeeAssistantPrompt = BeeAssistantPrompt.fork((config) => {\n config.template = `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Tool Name: {{.}}\\n{{/toolName}}{{#toolInput}}Tool Input: {{.}}\\n{{/toolInput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`;\n});\n\nexport const GraniteBeeSystemPrompt = BeeSystemPrompt.fork((config) => {\n config.defaults.instructions = \"\";\n config.functions.formatDate = function () {\n const date = this.createdAt ? new Date(this.createdAt) : new Date();\n return new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"full\",\n timeStyle: \"medium\",\n }).format(date);\n };\n config.template = `You are an AI assistant.\nWhen the user sends a message figure out a solution and provide a final answer.\n{{#tools.length}}\nYou have access to a set of tools that can be used to retrieve information and perform actions.\nPay close attention to the tool description to determine if a tool is useful in a particular context.\n{{/tools.length}}\n\n# Communication structure\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input', or 'Thought' followed by 'Final Answer'\n\nLine starting 'Thought: ' The assistant's response always starts with a thought, this is a single line where the assistant thinks about the user's message and describes in detail what it should do next.\n{{#tools.length}}\nIn a 'Thought: ', the assistant should determine if a Tool Call is necessary to get more information or perform an action, or if the available information is sufficient to provide the Final Answer.\nIf a tool needs to be called and is available, the assistant will produce a tool call:\nLine starting 'Tool Name: ' name of the tool that you want to use.\nLine starting 'Tool Input: ' JSON formatted tool arguments adhering to the selected tool parameters schema i.e. {\"arg1\":\"value1\", \"arg2\":\"value2\"}.\nAfter a 'Tool Input: ' the next message will contain a tool response. The next output should be a 'Thought: ' where the assistant thinks about the all the information it has available, and what it should do next (e.g. try the same tool with a different input, try a different tool, or proceed with answering the original user question).\n{{/tools.length}}\nOnce enough information is available to provide the Final Answer, the last line in the message needs to be:\nLine starting 'Final Answer: ' followed by a concise and clear answer to the original message.\n\n# Best practices\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n{{#tools.length}}\n- Do not attempt to use a tool that is not listed in available tools. This will cause an error.\n- Make sure that tool input is in the correct format and contains the correct arguments.\n{{/tools.length}}\n- When the message is unclear, respond with a line starting with 'Final Answer:' followed by a request for additional information needed to solve the problem.\n- When the user wants to chitchat instead, always respond politely.\n\n# Date and Time\nThe current date and time is: {{formatDate}}\n{{#tools.length}}\nYou do not need a tool to get the current Date and Time. Use the information available here.\n{{/tools.length}}\n\n{{#instructions}} \n# Additional instructions\n{{.}} \n{{/instructions}}\n`;\n});\n\nexport const GraniteBeeSchemaErrorPrompt = BeeSchemaErrorPrompt.fork((config) => {\n config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input' or 'Thought' followed by 'Final Answer'.`;\n});\n\nexport const GraniteBeeUserPrompt = BeeUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const GraniteBeeToolNotFoundPrompt = BeeToolNotFoundPrompt.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 GraniteBeeToolErrorPrompt = BeeToolErrorPrompt.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 GraniteBeeToolInputErrorPrompt = BeeToolInputErrorPrompt.fork((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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["prompts.ts"],"names":["GraniteBeeAssistantPrompt","BeeAssistantPrompt","fork","config","template","GraniteBeeSystemPrompt","BeeSystemPrompt","defaults","instructions","functions","formatDate","date","createdAt","Date","Intl","DateTimeFormat","dateStyle","timeStyle","format","GraniteBeeSchemaErrorPrompt","BeeSchemaErrorPrompt","GraniteBeeUserPrompt","BeeUserPrompt","GraniteBeeToolNotFoundPrompt","BeeToolNotFoundPrompt","GraniteBeeToolErrorPrompt","BeeToolErrorPrompt","GraniteBeeToolInputErrorPrompt","BeeToolInputErrorPrompt"],"mappings":";;AA0BO,MAAMA,yBAA4BC,GAAAA,kBAAAA,CAAmBC,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAChEA,EAAAA,MAA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,GAAAA,uBAAAA,CAAwB1B,IAAK,CAAA,CAACC,MAAAA,KAAAA;AAC1EA,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 BeeAssistantPrompt,\n BeeSchemaErrorPrompt,\n BeeSystemPrompt,\n BeeToolErrorPrompt,\n BeeToolInputErrorPrompt,\n BeeToolNotFoundPrompt,\n BeeUserPrompt,\n} from \"@/agents/bee/prompts.js\";\n\nexport const GraniteBeeAssistantPrompt = BeeAssistantPrompt.fork((config) => {\n config.template = `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Tool Name: {{.}}\\n{{/toolName}}{{#toolInput}}Tool Input: {{.}}\\n{{/toolInput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`;\n});\n\nexport const GraniteBeeSystemPrompt = BeeSystemPrompt.fork((config) => {\n config.defaults.instructions = \"\";\n config.functions.formatDate = function () {\n const date = this.createdAt ? new Date(this.createdAt) : new Date();\n return new Intl.DateTimeFormat(\"en-US\", {\n dateStyle: \"full\",\n timeStyle: \"medium\",\n }).format(date);\n };\n config.template = `You are an AI assistant.\nWhen the user sends a message figure out a solution and provide a final answer.\n{{#tools.length}}\nYou have access to a set of tools that can be used to retrieve information and perform actions.\nPay close attention to the tool description to determine if a tool is useful in a particular context.\n{{/tools.length}}\n\n# Communication structure\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input', or 'Thought' followed by 'Final Answer'\n\nLine starting 'Thought: ' The assistant's response always starts with a thought, this is a single line where the assistant thinks about the user's message and describes in detail what it should do next.\n{{#tools.length}}\nIn a 'Thought: ', the assistant should determine if a Tool Call is necessary to get more information or perform an action, or if the available information is sufficient to provide the Final Answer.\nIf a tool needs to be called and is available, the assistant will produce a tool call:\nLine starting 'Tool Name: ' name of the tool that you want to use.\nLine starting 'Tool Input: ' JSON formatted tool arguments adhering to the selected tool parameters schema i.e. {\"arg1\":\"value1\", \"arg2\":\"value2\"}.\nAfter a 'Tool Input: ' the next message will contain a tool response. The next output should be a 'Thought: ' where the assistant thinks about the all the information it has available, and what it should do next (e.g. try the same tool with a different input, try a different tool, or proceed with answering the original user question).\n{{/tools.length}}\nOnce enough information is available to provide the Final Answer, the last line in the message needs to be:\nLine starting 'Final Answer: ' followed by a concise and clear answer to the original message.\n\n# Best practices\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n{{#tools.length}}\n- Do not attempt to use a tool that is not listed in available tools. This will cause an error.\n- Make sure that tool input is in the correct format and contains the correct arguments.\n{{/tools.length}}\n- When the message is unclear, respond with a line starting with 'Final Answer:' followed by a request for additional information needed to solve the problem.\n- When the user wants to chitchat instead, always respond politely.\n\n# Date and Time\nThe current date and time is: {{formatDate}}\n{{#tools.length}}\nYou do not need a tool to get the current Date and Time. Use the information available here.\n{{/tools.length}}\n\n{{#instructions}} \n# Additional instructions\n{{.}} \n{{/instructions}}\n`;\n});\n\nexport const GraniteBeeSchemaErrorPrompt = BeeSchemaErrorPrompt.fork((config) => {\n config.template = `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by 'Tool Name' and then 'Tool Input' or 'Thought' followed by 'Final Answer'.`;\n});\n\nexport const GraniteBeeUserPrompt = BeeUserPrompt.fork((config) => {\n config.template = `{{input}}`;\n});\n\nexport const GraniteBeeToolNotFoundPrompt = BeeToolNotFoundPrompt.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 GraniteBeeToolErrorPrompt = BeeToolErrorPrompt.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 GraniteBeeToolInputErrorPrompt = BeeToolInputErrorPrompt.fork((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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["runner.ts"],"names":["GraniteRunner","DefaultRunner","useNativeToolCalling","defaultTemplates","system","GraniteBeeSystemPrompt","assistant","GraniteBeeAssistantPrompt","user","GraniteBeeUserPrompt","schemaError","GraniteBeeSchemaErrorPrompt","toolNotFoundError","GraniteBeeToolNotFoundPrompt","toolError","GraniteBeeToolErrorPrompt","toolInputError","GraniteBeeToolInputErrorPrompt","userEmpty","BeeUserEmptyPrompt","toolNoResultError","BeeToolNoResultsPrompt","register","constructor","input","options","run","emitter","on","update","meta","memory","data","key","add","ToolMessage","type","result","value","toolName","tool_name","isError","success","toolCallId","isBlocking","createParser","tools","parser","fork","nodes","thought","prefix","tool_input","isEnd","next","final_answer","enumerable"],"mappings":";;;;;;;;;;AAcC,SAAA,YAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GAAA,EAAA,IAAA,EAAA;;;;;;AAAA,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA;;;;;AAoBM,MAAMA,sBAAsBC,wBAAAA,CAAAA;EAlCnC;;;EAmCYC,oBAAuB,GAAA,IAAA;AAEjC,EAAA,IACWC,gBAAmB,GAAA;AAC5B,IAAO,OAAA;MACLC,MAAQC,EAAAA,oCAAAA;MACRC,SAAWC,EAAAA,uCAAAA;MACXC,IAAMC,EAAAA,kCAAAA;MACNC,WAAaC,EAAAA,yCAAAA;MACbC,iBAAmBC,EAAAA,0CA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AA,OAAAA;YAASC,MAAQ,EAAA;AAAW,WAAA;UAChDX,SAAW,EAAA;AAAE,YAAA,GAAGS,KAAMT,CAAAA,SAAAA;YAAWW,MAAQ,EAAA;AAAa,WAAA;UACtDC,UAAY,EAAA;AAAE,YAAA,GAAGH,KAAMG,CAAAA,UAAAA;YAAYD,MAAQ,EAAA,aAAA;YAAeE,KAAO,EAAA,IAAA;AAAMC,YAAAA,IAAAA,EAAM;AAAG,WAAA;UAChFC,YAAc,EAAA;AAAE,YAAA,GAAGN,KAAMM,CAAAA,YAAAA;YAAcJ,MAAQ,EAAA;AAAgB;AACjE;OACF,CAAA;AACF,KAAA;AACF;AACF;;;IA/DWK,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 { ToolMessage } from \"@/backend/message.js\";\nimport type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/bee/runners/default/runner.js\";\nimport type { BeeParserInput, BeeRunOptions } from \"@/agents/bee/types.js\";\nimport { BeeAgent, BeeInput } from \"@/agents/bee/agent.js\";\nimport type { GetRunContext } from \"@/context.js\";\nimport {\n GraniteBeeAssistantPrompt,\n GraniteBeeSchemaErrorPrompt,\n GraniteBeeSystemPrompt,\n GraniteBeeToolErrorPrompt,\n GraniteBeeToolInputErrorPrompt,\n GraniteBeeToolNotFoundPrompt,\n GraniteBeeUserPrompt,\n} from \"@/agents/bee/runners/granite/prompts.js\";\nimport { BeeToolNoResultsPrompt, BeeUserEmptyPrompt } from \"@/agents/bee/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\n\nexport class GraniteRunner extends DefaultRunner {\n protected useNativeToolCalling = true;\n\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: GraniteBeeSystemPrompt,\n assistant: GraniteBeeAssistantPrompt,\n user: GraniteBeeUserPrompt,\n schemaError: GraniteBeeSchemaErrorPrompt,\n toolNotFoundError: GraniteBeeToolNotFoundPrompt,\n toolError: GraniteBeeToolErrorPrompt,\n toolInputError: GraniteBeeToolInputErrorPrompt,\n // Note: These are from bee\n userEmpty: BeeUserEmptyPrompt,\n toolNoResultError: BeeToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n constructor(input: BeeInput, options: BeeRunOptions, run: GetRunContext<BeeAgent>) {\n super(input, options, run);\n\n run.emitter.on(\n \"update\",\n async ({ update, meta, memory, data }) => {\n if (update.key === \"tool_output\") {\n await memory.add(\n new ToolMessage(\n {\n type: \"tool-result\",\n result: update.value!,\n toolName: data.tool_name!,\n isError: !meta.success,\n toolCallId: \"DUMMY_ID\",\n },\n { success: meta.success },\n ),\n );\n }\n },\n {\n isBlocking: true,\n },\n );\n }\n\n protected createParser(tools: AnyTool[]) {\n const { parser } = super.createParser(tools);\n\n return {\n parser: parser.fork<BeeParserInput>((nodes, options) => ({\n options,\n nodes: {\n ...nodes,\n thought: { ...nodes.thought, prefix: \"Thought:\" },\n tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n tool_input: { ...nodes.tool_input, prefix: \"Tool Input:\", isEnd: true, next: [] },\n final_answer: { ...nodes.final_answer, prefix: \"Final Answer:\" },\n },\n })),\n };\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["runner.ts"],"names":["GraniteRunner","DefaultRunner","useNativeToolCalling","defaultTemplates","system","GraniteBeeSystemPrompt","assistant","GraniteBeeAssistantPrompt","user","GraniteBeeUserPrompt","schemaError","GraniteBeeSchemaErrorPrompt","toolNotFoundError","GraniteBeeToolNotFoundPrompt","toolError","GraniteBeeToolErrorPrompt","toolInputError","GraniteBeeToolInputErrorPrompt","userEmpty","BeeUserEmptyPrompt","toolNoResultError","BeeToolNoResultsPrompt","register","constructor","input","options","run","emitter","on","update","meta","memory","data","key","add","ToolMessage","type","result","value","toolName","tool_name","isError","success","toolCallId","isBlocking","createParser","tools","parser","fork","nodes","thought","prefix","tool_input","isEnd","next","final_answer","enumerable"],"mappings":";;;;;;;;AAcC,SAAA,YAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GAAA,EAAA,IAAA,EAAA;;;;;;AAAA,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA;;;;;AAoBM,MAAMA,sBAAsBC,aAAAA,CAAAA;EAlCnC;;;EAmCYC,oBAAuB,GAAA,IAAA;AAEjC,EAAA,IACWC,gBAAmB,GAAA;AAC5B,IAAO,OAAA;MACLC,MAAQC,EAAAA,sBAAAA;MACRC,SAAWC,EAAAA,yBAAAA;MACXC,IAAMC,EAAAA,oBAAAA;MACNC,WAAaC,EAAAA,2BAAAA;MACbC,iBAAmBC,EAAAA,4BAAAA;MACnBC,SAAWC,EAAAA,yBAAAA;MACXC,cAAgBC,EAAAA,8BAAAA;;MAEhBC,SAAWC,EAAAA,kBAAAA;MACXC,iBAAmBC,EAAAA;AACrB,KAAA;AACF;EAEA;AACE,IAAA,IAAA,CAAKC,QAAQ,EAAA;AACf;EAEAC,WAAYC,CAAAA,KAAAA,EAAiBC,SAAwBC,GAA8B,EAAA;AACjF,IAAMF,KAAAA,CAAAA,KAAAA,EAAOC,SAASC,GAAAA,CAAAA;AAEtBA,IAAIC,GAAAA,CAAAA,OAAAA,CAAQC,GACV,QACA,EAAA,OAAO,EAAEC,MAAQC,EAAAA,IAAAA,EAAMC,MAAQC,EAAAA,IAAAA,EAAM,KAAA;AACnC,MAAIH,IAAAA,MAAAA,CAAOI,QAAQ,aAAe,EAAA;AAChC,QAAMF,MAAAA,MAAAA,CAAOG,GACX,CAAA,IAAIC,WACF,CAAA;UACEC,IAAM,EAAA,aAAA;AACNC,UAAAA,MAAAA,EAAQR,MAAOS,CAAAA,KAAAA;AACfC,UAAAA,QAAAA,EAAUP,IAAKQ,CAAAA,SAAAA;AACfC,UAAAA,OAAAA,EAAS,CAACX,IAAKY,CAAAA,OAAAA;UACfC,UAAY,EAAA;SAEd,EAAA;AAAED,UAAAA,OAAAA,EAASZ,IAAKY,CAAAA;AAAQ,SAAA,CAAA,CAAA;AAG9B;KAEF,EAAA;MACEE,UAAY,EAAA;KACd,CAAA;AAEJ;AAEUC,EAAAA,YAAAA,CAAaC,KAAkB,EAAA;AACvC,IAAA,MAAM,EAAEC,MAAAA,EAAW,GAAA,KAAA,CAAMF,aAAaC,KAAAA,CAAAA;AAEtC,IAAO,OAAA;AACLC,MAAAA,MAAAA,EAAQA,MAAOC,CAAAA,IAAAA,CAAqB,CAACC,KAAAA,EAAOxB,OAAa,MAAA;AACvDA,QAAAA,OAAAA;QACAwB,KAAO,EAAA;UACL,GAAGA,KAAAA;UACHC,OAAS,EAAA;AAAE,YAAA,GAAGD,KAAMC,CAAAA,OAAAA;YAASC,MAAQ,EAAA;AAAW,WAAA;UAChDX,SAAW,EAAA;AAAE,YAAA,GAAGS,KAAMT,CAAAA,SAAAA;YAAWW,MAAQ,EAAA;AAAa,WAAA;UACtDC,UAAY,EAAA;AAAE,YAAA,GAAGH,KAAMG,CAAAA,UAAAA;YAAYD,MAAQ,EAAA,aAAA;YAAeE,KAAO,EAAA,IAAA;AAAMC,YAAAA,IAAAA,EAAM;AAAG,WAAA;UAChFC,YAAc,EAAA;AAAE,YAAA,GAAGN,KAAMM,CAAAA,YAAAA;YAAcJ,MAAQ,EAAA;AAAgB;AACjE;OACF,CAAA;AACF,KAAA;AACF;AACF;;;IA/DWK,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 { ToolMessage } from \"@/backend/message.js\";\nimport type { AnyTool } from \"@/tools/base.js\";\nimport { DefaultRunner } from \"@/agents/bee/runners/default/runner.js\";\nimport type { BeeParserInput, BeeRunOptions } from \"@/agents/bee/types.js\";\nimport { BeeAgent, BeeInput } from \"@/agents/bee/agent.js\";\nimport type { GetRunContext } from \"@/context.js\";\nimport {\n GraniteBeeAssistantPrompt,\n GraniteBeeSchemaErrorPrompt,\n GraniteBeeSystemPrompt,\n GraniteBeeToolErrorPrompt,\n GraniteBeeToolInputErrorPrompt,\n GraniteBeeToolNotFoundPrompt,\n GraniteBeeUserPrompt,\n} from \"@/agents/bee/runners/granite/prompts.js\";\nimport { BeeToolNoResultsPrompt, BeeUserEmptyPrompt } from \"@/agents/bee/prompts.js\";\nimport { Cache } from \"@/cache/decoratorCache.js\";\n\nexport class GraniteRunner extends DefaultRunner {\n protected useNativeToolCalling = true;\n\n @Cache({ enumerable: false })\n public get defaultTemplates() {\n return {\n system: GraniteBeeSystemPrompt,\n assistant: GraniteBeeAssistantPrompt,\n user: GraniteBeeUserPrompt,\n schemaError: GraniteBeeSchemaErrorPrompt,\n toolNotFoundError: GraniteBeeToolNotFoundPrompt,\n toolError: GraniteBeeToolErrorPrompt,\n toolInputError: GraniteBeeToolInputErrorPrompt,\n // Note: These are from bee\n userEmpty: BeeUserEmptyPrompt,\n toolNoResultError: BeeToolNoResultsPrompt,\n };\n }\n\n static {\n this.register();\n }\n\n constructor(input: BeeInput, options: BeeRunOptions, run: GetRunContext<BeeAgent>) {\n super(input, options, run);\n\n run.emitter.on(\n \"update\",\n async ({ update, meta, memory, data }) => {\n if (update.key === \"tool_output\") {\n await memory.add(\n new ToolMessage(\n {\n type: \"tool-result\",\n result: update.value!,\n toolName: data.tool_name!,\n isError: !meta.success,\n toolCallId: \"DUMMY_ID\",\n },\n { success: meta.success },\n ),\n );\n }\n },\n {\n isBlocking: true,\n },\n );\n }\n\n protected createParser(tools: AnyTool[]) {\n const { parser } = super.createParser(tools);\n\n return {\n parser: parser.fork<BeeParserInput>((nodes, options) => ({\n options,\n nodes: {\n ...nodes,\n thought: { ...nodes.thought, prefix: \"Thought:\" },\n tool_name: { ...nodes.tool_name, prefix: \"Tool Name:\" },\n tool_input: { ...nodes.tool_input, prefix: \"Tool Input:\", isEnd: true, next: [] },\n final_answer: { ...nodes.final_answer, prefix: \"Final Answer:\" },\n },\n })),\n };\n }\n}\n"]}
File without changes
File without changes
File without changes
File without changes