beeai-framework 0.1.7 → 0.1.9

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 (118) hide show
  1. package/README.md +56 -43
  2. package/dist/adapters/openai/backend/client.cjs +9 -2
  3. package/dist/adapters/openai/backend/client.cjs.map +1 -1
  4. package/dist/adapters/openai/backend/client.js +9 -2
  5. package/dist/adapters/openai/backend/client.js.map +1 -1
  6. package/dist/agents/base.cjs +1 -4
  7. package/dist/agents/base.cjs.map +1 -1
  8. package/dist/agents/base.js +1 -4
  9. package/dist/agents/base.js.map +1 -1
  10. package/dist/agents/react/prompts.d.cts +4 -4
  11. package/dist/agents/react/prompts.d.ts +4 -4
  12. package/dist/agents/react/runners/deep-think/prompts.d.cts +4 -4
  13. package/dist/agents/react/runners/deep-think/prompts.d.ts +4 -4
  14. package/dist/agents/react/runners/deep-think/runner.d.cts +4 -4
  15. package/dist/agents/react/runners/deep-think/runner.d.ts +4 -4
  16. package/dist/agents/react/runners/default/runner.d.cts +4 -4
  17. package/dist/agents/react/runners/default/runner.d.ts +4 -4
  18. package/dist/agents/react/runners/granite/prompts.d.cts +4 -4
  19. package/dist/agents/react/runners/granite/prompts.d.ts +4 -4
  20. package/dist/agents/react/runners/granite/runner.d.cts +6 -6
  21. package/dist/agents/react/runners/granite/runner.d.ts +6 -6
  22. package/dist/agents/toolCalling/prompts.cjs +3 -4
  23. package/dist/agents/toolCalling/prompts.cjs.map +1 -1
  24. package/dist/agents/toolCalling/prompts.js +3 -4
  25. package/dist/agents/toolCalling/prompts.js.map +1 -1
  26. package/dist/backend/chat.cjs +1 -3
  27. package/dist/backend/chat.cjs.map +1 -1
  28. package/dist/backend/chat.d.cts +2 -2
  29. package/dist/backend/chat.d.ts +2 -2
  30. package/dist/backend/chat.js +2 -4
  31. package/dist/backend/chat.js.map +1 -1
  32. package/dist/backend/embedding.d.cts +1 -1
  33. package/dist/backend/embedding.d.ts +1 -1
  34. package/dist/index.cjs +21 -0
  35. package/dist/index.d.cts +6 -1
  36. package/dist/index.d.ts +6 -1
  37. package/dist/index.js +3 -0
  38. package/dist/tools/base.cjs +1 -3
  39. package/dist/tools/base.cjs.map +1 -1
  40. package/dist/tools/base.js +2 -4
  41. package/dist/tools/base.js.map +1 -1
  42. package/dist/tools/database/milvus.d.cts +4 -4
  43. package/dist/tools/database/milvus.d.ts +4 -4
  44. package/dist/version.cjs +1 -1
  45. package/dist/version.js +1 -1
  46. package/dist/workflows/agent.cjs +28 -20
  47. package/dist/workflows/agent.cjs.map +1 -1
  48. package/dist/workflows/agent.d.cts +221 -41
  49. package/dist/workflows/agent.d.ts +221 -41
  50. package/dist/workflows/agent.js +29 -21
  51. package/dist/workflows/agent.js.map +1 -1
  52. package/package.json +5 -12
  53. package/dist/instrumentation/config.cjs +0 -12
  54. package/dist/instrumentation/config.cjs.map +0 -1
  55. package/dist/instrumentation/config.d.cts +0 -19
  56. package/dist/instrumentation/config.d.ts +0 -19
  57. package/dist/instrumentation/config.js +0 -9
  58. package/dist/instrumentation/config.js.map +0 -1
  59. package/dist/instrumentation/create-telemetry-middleware.cjs +0 -239
  60. package/dist/instrumentation/create-telemetry-middleware.cjs.map +0 -1
  61. package/dist/instrumentation/create-telemetry-middleware.d.cts +0 -26
  62. package/dist/instrumentation/create-telemetry-middleware.d.ts +0 -26
  63. package/dist/instrumentation/create-telemetry-middleware.js +0 -237
  64. package/dist/instrumentation/create-telemetry-middleware.js.map +0 -1
  65. package/dist/instrumentation/helpers/create-span.cjs +0 -36
  66. package/dist/instrumentation/helpers/create-span.cjs.map +0 -1
  67. package/dist/instrumentation/helpers/create-span.d.cts +0 -34
  68. package/dist/instrumentation/helpers/create-span.d.ts +0 -34
  69. package/dist/instrumentation/helpers/create-span.js +0 -34
  70. package/dist/instrumentation/helpers/create-span.js.map +0 -1
  71. package/dist/instrumentation/helpers/get-error-safe.cjs +0 -20
  72. package/dist/instrumentation/helpers/get-error-safe.cjs.map +0 -1
  73. package/dist/instrumentation/helpers/get-error-safe.d.cts +0 -18
  74. package/dist/instrumentation/helpers/get-error-safe.d.ts +0 -18
  75. package/dist/instrumentation/helpers/get-error-safe.js +0 -18
  76. package/dist/instrumentation/helpers/get-error-safe.js.map +0 -1
  77. package/dist/instrumentation/helpers/get-serialized-object-safe.cjs +0 -27
  78. package/dist/instrumentation/helpers/get-serialized-object-safe.cjs.map +0 -1
  79. package/dist/instrumentation/helpers/get-serialized-object-safe.d.cts +0 -18
  80. package/dist/instrumentation/helpers/get-serialized-object-safe.d.ts +0 -18
  81. package/dist/instrumentation/helpers/get-serialized-object-safe.js +0 -25
  82. package/dist/instrumentation/helpers/get-serialized-object-safe.js.map +0 -1
  83. package/dist/instrumentation/helpers/id-name-manager.cjs +0 -34
  84. package/dist/instrumentation/helpers/id-name-manager.cjs.map +0 -1
  85. package/dist/instrumentation/helpers/id-name-manager.d.cts +0 -31
  86. package/dist/instrumentation/helpers/id-name-manager.d.ts +0 -31
  87. package/dist/instrumentation/helpers/id-name-manager.js +0 -32
  88. package/dist/instrumentation/helpers/id-name-manager.js.map +0 -1
  89. package/dist/instrumentation/helpers/trace-serializer.cjs +0 -30
  90. package/dist/instrumentation/helpers/trace-serializer.cjs.map +0 -1
  91. package/dist/instrumentation/helpers/trace-serializer.d.cts +0 -20
  92. package/dist/instrumentation/helpers/trace-serializer.d.ts +0 -20
  93. package/dist/instrumentation/helpers/trace-serializer.js +0 -28
  94. package/dist/instrumentation/helpers/trace-serializer.js.map +0 -1
  95. package/dist/instrumentation/helpers/utils.cjs +0 -14
  96. package/dist/instrumentation/helpers/utils.cjs.map +0 -1
  97. package/dist/instrumentation/helpers/utils.d.cts +0 -40
  98. package/dist/instrumentation/helpers/utils.d.ts +0 -40
  99. package/dist/instrumentation/helpers/utils.js +0 -12
  100. package/dist/instrumentation/helpers/utils.js.map +0 -1
  101. package/dist/instrumentation/logger.cjs +0 -12
  102. package/dist/instrumentation/logger.cjs.map +0 -1
  103. package/dist/instrumentation/logger.d.cts +0 -26
  104. package/dist/instrumentation/logger.d.ts +0 -26
  105. package/dist/instrumentation/logger.js +0 -10
  106. package/dist/instrumentation/logger.js.map +0 -1
  107. package/dist/instrumentation/tracer.cjs +0 -84
  108. package/dist/instrumentation/tracer.cjs.map +0 -1
  109. package/dist/instrumentation/tracer.d.cts +0 -36
  110. package/dist/instrumentation/tracer.d.ts +0 -36
  111. package/dist/instrumentation/tracer.js +0 -76
  112. package/dist/instrumentation/tracer.js.map +0 -1
  113. package/dist/instrumentation/types.cjs +0 -4
  114. package/dist/instrumentation/types.cjs.map +0 -1
  115. package/dist/instrumentation/types.d.cts +0 -39
  116. package/dist/instrumentation/types.d.ts +0 -39
  117. package/dist/instrumentation/types.js +0 -3
  118. package/dist/instrumentation/types.js.map +0 -1
@@ -5,8 +5,8 @@ import { AnyTool } from '../tools/base.js';
5
5
  import { ReadOnlyMemory } from '../memory/base.js';
6
6
  import { z } from 'zod';
7
7
  import { a as BaseAgent } from '../base-mmG-8Pk9.js';
8
- import { ReActAgentRunInput, ReActAgentRunOutput, ReActAgentRunOptions, ReActAgentExecutionConfig } from '../agents/react/types.js';
9
8
  import { ChatModel } from '../backend/chat.js';
9
+ import { ToolCallingAgentRunInput, ToolCallingAgentRunOutput, ToolCallingAgentRunOptions, ToolCallingAgentExecutionConfig } from '../agents/toolCalling/types.js';
10
10
  import '../emitter-BxVxGBbJ.js';
11
11
  import '../internals/types.js';
12
12
  import '../internals/helpers/guards.js';
@@ -19,143 +19,323 @@ import 'promise-based-task';
19
19
  import '../cache/base.js';
20
20
  import '../internals/helpers/schema.js';
21
21
  import 'zod-to-json-schema';
22
- import '../agents/react/prompts.js';
23
- import '../template.js';
24
- import '../parsers/linePrefix.js';
25
- import '../parsers/field.js';
26
- import '@streamparser/json';
27
- import 'jsonrepair/stream';
28
- import '../parsers/errors.js';
29
22
  import '../backend/utils.js';
30
23
  import '../backend/constants.js';
31
24
  import '@ai-sdk/provider';
25
+ import '../agents/toolCalling/prompts.js';
26
+ import '../template.js';
32
27
 
33
- type AgentInstance = BaseAgent<ReActAgentRunInput, ReActAgentRunOutput, ReActAgentRunOptions>;
28
+ type AgentInstance = BaseAgent<ToolCallingAgentRunInput, ToolCallingAgentRunOutput, ToolCallingAgentRunOptions>;
34
29
  type AgentFactory = (memory: ReadOnlyMemory) => AgentInstance | Promise<AgentInstance>;
35
30
  interface AgentFactoryInput {
36
- name: string;
31
+ name?: string;
32
+ role?: string;
37
33
  llm: ChatModel;
38
34
  instructions?: string;
39
35
  tools?: AnyTool[];
40
- execution?: ReActAgentExecutionConfig;
36
+ execution?: ToolCallingAgentExecutionConfig;
41
37
  }
42
38
  declare class AgentWorkflow {
43
39
  protected readonly workflow: Workflow<z.ZodObject<{
44
- messages: z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">;
40
+ inputs: z.ZodArray<z.ZodObject<{
41
+ prompt: z.ZodOptional<z.ZodString>;
42
+ context: z.ZodOptional<z.ZodString>;
43
+ expectedOutput: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
44
+ }, "strip", z.ZodTypeAny, {
45
+ context?: string | undefined;
46
+ prompt?: string | undefined;
47
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
48
+ }, {
49
+ context?: string | undefined;
50
+ prompt?: string | undefined;
51
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
52
+ }>, "many">;
45
53
  finalAnswer: z.ZodOptional<z.ZodString>;
46
54
  newMessages: z.ZodDefault<z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">>;
47
55
  }, "strip", z.ZodTypeAny, {
48
- messages: Message<MessageContentPart, string>[];
56
+ inputs: {
57
+ context?: string | undefined;
58
+ prompt?: string | undefined;
59
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
60
+ }[];
49
61
  newMessages: Message<MessageContentPart, string>[];
50
62
  finalAnswer?: string | undefined;
51
63
  }, {
52
- messages: Message<MessageContentPart, string>[];
64
+ inputs: {
65
+ context?: string | undefined;
66
+ prompt?: string | undefined;
67
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
68
+ }[];
53
69
  finalAnswer?: string | undefined;
54
70
  newMessages?: Message<MessageContentPart, string>[] | undefined;
55
71
  }>, z.ZodObject<{
56
- messages: z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">;
72
+ inputs: z.ZodArray<z.ZodObject<{
73
+ prompt: z.ZodOptional<z.ZodString>;
74
+ context: z.ZodOptional<z.ZodString>;
75
+ expectedOutput: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
76
+ }, "strip", z.ZodTypeAny, {
77
+ context?: string | undefined;
78
+ prompt?: string | undefined;
79
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
80
+ }, {
81
+ context?: string | undefined;
82
+ prompt?: string | undefined;
83
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
84
+ }>, "many">;
57
85
  finalAnswer: z.ZodString;
58
86
  newMessages: z.ZodDefault<z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">>;
59
87
  }, "strip", z.ZodTypeAny, {
60
- messages: Message<MessageContentPart, string>[];
88
+ inputs: {
89
+ context?: string | undefined;
90
+ prompt?: string | undefined;
91
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
92
+ }[];
61
93
  finalAnswer: string;
62
94
  newMessages: Message<MessageContentPart, string>[];
63
95
  }, {
64
- messages: Message<MessageContentPart, string>[];
96
+ inputs: {
97
+ context?: string | undefined;
98
+ prompt?: string | undefined;
99
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
100
+ }[];
65
101
  finalAnswer: string;
66
102
  newMessages?: Message<MessageContentPart, string>[] | undefined;
67
103
  }>, string>;
68
- static readonly schema: z.ZodObject<{
69
- messages: z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">;
104
+ readonly schema: z.ZodObject<{
105
+ inputs: z.ZodArray<z.ZodObject<{
106
+ prompt: z.ZodOptional<z.ZodString>;
107
+ context: z.ZodOptional<z.ZodString>;
108
+ expectedOutput: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
109
+ }, "strip", z.ZodTypeAny, {
110
+ context?: string | undefined;
111
+ prompt?: string | undefined;
112
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
113
+ }, {
114
+ context?: string | undefined;
115
+ prompt?: string | undefined;
116
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
117
+ }>, "many">;
70
118
  finalAnswer: z.ZodOptional<z.ZodString>;
71
119
  newMessages: z.ZodDefault<z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">>;
72
120
  }, "strip", z.ZodTypeAny, {
73
- messages: Message<MessageContentPart, string>[];
121
+ inputs: {
122
+ context?: string | undefined;
123
+ prompt?: string | undefined;
124
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
125
+ }[];
74
126
  newMessages: Message<MessageContentPart, string>[];
75
127
  finalAnswer?: string | undefined;
76
128
  }, {
77
- messages: Message<MessageContentPart, string>[];
129
+ inputs: {
130
+ context?: string | undefined;
131
+ prompt?: string | undefined;
132
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
133
+ }[];
78
134
  finalAnswer?: string | undefined;
79
135
  newMessages?: Message<MessageContentPart, string>[] | undefined;
80
136
  }>;
81
137
  constructor(name?: string);
82
- run(messages: Message[], options?: WorkflowRunOptions<string>): Run<WorkflowRun<z.ZodObject<{
83
- messages: z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">;
138
+ run(inputs: (ToolCallingAgentRunInput | Message)[], options?: WorkflowRunOptions<string>): Run<WorkflowRun<z.ZodObject<{
139
+ inputs: z.ZodArray<z.ZodObject<{
140
+ prompt: z.ZodOptional<z.ZodString>;
141
+ context: z.ZodOptional<z.ZodString>;
142
+ expectedOutput: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
143
+ }, "strip", z.ZodTypeAny, {
144
+ context?: string | undefined;
145
+ prompt?: string | undefined;
146
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
147
+ }, {
148
+ context?: string | undefined;
149
+ prompt?: string | undefined;
150
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
151
+ }>, "many">;
84
152
  finalAnswer: z.ZodOptional<z.ZodString>;
85
153
  newMessages: z.ZodDefault<z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">>;
86
154
  }, "strip", z.ZodTypeAny, {
87
- messages: Message<MessageContentPart, string>[];
155
+ inputs: {
156
+ context?: string | undefined;
157
+ prompt?: string | undefined;
158
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
159
+ }[];
88
160
  newMessages: Message<MessageContentPart, string>[];
89
161
  finalAnswer?: string | undefined;
90
162
  }, {
91
- messages: Message<MessageContentPart, string>[];
163
+ inputs: {
164
+ context?: string | undefined;
165
+ prompt?: string | undefined;
166
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
167
+ }[];
92
168
  finalAnswer?: string | undefined;
93
169
  newMessages?: Message<MessageContentPart, string>[] | undefined;
94
170
  }>, z.ZodObject<{
95
- messages: z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">;
171
+ inputs: z.ZodArray<z.ZodObject<{
172
+ prompt: z.ZodOptional<z.ZodString>;
173
+ context: z.ZodOptional<z.ZodString>;
174
+ expectedOutput: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
175
+ }, "strip", z.ZodTypeAny, {
176
+ context?: string | undefined;
177
+ prompt?: string | undefined;
178
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
179
+ }, {
180
+ context?: string | undefined;
181
+ prompt?: string | undefined;
182
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
183
+ }>, "many">;
96
184
  finalAnswer: z.ZodString;
97
185
  newMessages: z.ZodDefault<z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">>;
98
186
  }, "strip", z.ZodTypeAny, {
99
- messages: Message<MessageContentPart, string>[];
187
+ inputs: {
188
+ context?: string | undefined;
189
+ prompt?: string | undefined;
190
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
191
+ }[];
100
192
  finalAnswer: string;
101
193
  newMessages: Message<MessageContentPart, string>[];
102
194
  }, {
103
- messages: Message<MessageContentPart, string>[];
195
+ inputs: {
196
+ context?: string | undefined;
197
+ prompt?: string | undefined;
198
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
199
+ }[];
104
200
  finalAnswer: string;
105
201
  newMessages?: Message<MessageContentPart, string>[] | undefined;
106
202
  }>, string>, Workflow<z.ZodObject<{
107
- messages: z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">;
203
+ inputs: z.ZodArray<z.ZodObject<{
204
+ prompt: z.ZodOptional<z.ZodString>;
205
+ context: z.ZodOptional<z.ZodString>;
206
+ expectedOutput: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
207
+ }, "strip", z.ZodTypeAny, {
208
+ context?: string | undefined;
209
+ prompt?: string | undefined;
210
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
211
+ }, {
212
+ context?: string | undefined;
213
+ prompt?: string | undefined;
214
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
215
+ }>, "many">;
108
216
  finalAnswer: z.ZodOptional<z.ZodString>;
109
217
  newMessages: z.ZodDefault<z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">>;
110
218
  }, "strip", z.ZodTypeAny, {
111
- messages: Message<MessageContentPart, string>[];
219
+ inputs: {
220
+ context?: string | undefined;
221
+ prompt?: string | undefined;
222
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
223
+ }[];
112
224
  newMessages: Message<MessageContentPart, string>[];
113
225
  finalAnswer?: string | undefined;
114
226
  }, {
115
- messages: Message<MessageContentPart, string>[];
227
+ inputs: {
228
+ context?: string | undefined;
229
+ prompt?: string | undefined;
230
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
231
+ }[];
116
232
  finalAnswer?: string | undefined;
117
233
  newMessages?: Message<MessageContentPart, string>[] | undefined;
118
234
  }>, z.ZodObject<{
119
- messages: z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">;
235
+ inputs: z.ZodArray<z.ZodObject<{
236
+ prompt: z.ZodOptional<z.ZodString>;
237
+ context: z.ZodOptional<z.ZodString>;
238
+ expectedOutput: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
239
+ }, "strip", z.ZodTypeAny, {
240
+ context?: string | undefined;
241
+ prompt?: string | undefined;
242
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
243
+ }, {
244
+ context?: string | undefined;
245
+ prompt?: string | undefined;
246
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
247
+ }>, "many">;
120
248
  finalAnswer: z.ZodString;
121
249
  newMessages: z.ZodDefault<z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">>;
122
250
  }, "strip", z.ZodTypeAny, {
123
- messages: Message<MessageContentPart, string>[];
251
+ inputs: {
252
+ context?: string | undefined;
253
+ prompt?: string | undefined;
254
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
255
+ }[];
124
256
  finalAnswer: string;
125
257
  newMessages: Message<MessageContentPart, string>[];
126
258
  }, {
127
- messages: Message<MessageContentPart, string>[];
259
+ inputs: {
260
+ context?: string | undefined;
261
+ prompt?: string | undefined;
262
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
263
+ }[];
128
264
  finalAnswer: string;
129
265
  newMessages?: Message<MessageContentPart, string>[] | undefined;
130
266
  }>, string>, readonly [{
131
- messages: Message<MessageContentPart, string>[];
267
+ inputs: {
268
+ context?: string | undefined;
269
+ prompt?: string | undefined;
270
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
271
+ }[];
132
272
  finalAnswer?: string | undefined;
133
273
  newMessages?: Message<MessageContentPart, string>[] | undefined;
134
274
  }, WorkflowRunOptions<string>]>;
135
275
  addAgent(agent: AgentFactory | AgentFactoryInput): this;
136
276
  addAgent(agent: AgentInstance): Promise<this>;
137
277
  delAgent(name: string): Workflow<z.ZodObject<{
138
- messages: z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">;
278
+ inputs: z.ZodArray<z.ZodObject<{
279
+ prompt: z.ZodOptional<z.ZodString>;
280
+ context: z.ZodOptional<z.ZodString>;
281
+ expectedOutput: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
282
+ }, "strip", z.ZodTypeAny, {
283
+ context?: string | undefined;
284
+ prompt?: string | undefined;
285
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
286
+ }, {
287
+ context?: string | undefined;
288
+ prompt?: string | undefined;
289
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
290
+ }>, "many">;
139
291
  finalAnswer: z.ZodOptional<z.ZodString>;
140
292
  newMessages: z.ZodDefault<z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">>;
141
293
  }, "strip", z.ZodTypeAny, {
142
- messages: Message<MessageContentPart, string>[];
294
+ inputs: {
295
+ context?: string | undefined;
296
+ prompt?: string | undefined;
297
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
298
+ }[];
143
299
  newMessages: Message<MessageContentPart, string>[];
144
300
  finalAnswer?: string | undefined;
145
301
  }, {
146
- messages: Message<MessageContentPart, string>[];
302
+ inputs: {
303
+ context?: string | undefined;
304
+ prompt?: string | undefined;
305
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
306
+ }[];
147
307
  finalAnswer?: string | undefined;
148
308
  newMessages?: Message<MessageContentPart, string>[] | undefined;
149
309
  }>, z.ZodObject<{
150
- messages: z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">;
310
+ inputs: z.ZodArray<z.ZodObject<{
311
+ prompt: z.ZodOptional<z.ZodString>;
312
+ context: z.ZodOptional<z.ZodString>;
313
+ expectedOutput: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
314
+ }, "strip", z.ZodTypeAny, {
315
+ context?: string | undefined;
316
+ prompt?: string | undefined;
317
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
318
+ }, {
319
+ context?: string | undefined;
320
+ prompt?: string | undefined;
321
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
322
+ }>, "many">;
151
323
  finalAnswer: z.ZodString;
152
324
  newMessages: z.ZodDefault<z.ZodArray<z.ZodType<Message<MessageContentPart, string>, z.ZodTypeDef, Message<MessageContentPart, string>>, "many">>;
153
325
  }, "strip", z.ZodTypeAny, {
154
- messages: Message<MessageContentPart, string>[];
326
+ inputs: {
327
+ context?: string | undefined;
328
+ prompt?: string | undefined;
329
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
330
+ }[];
155
331
  finalAnswer: string;
156
332
  newMessages: Message<MessageContentPart, string>[];
157
333
  }, {
158
- messages: Message<MessageContentPart, string>[];
334
+ inputs: {
335
+ context?: string | undefined;
336
+ prompt?: string | undefined;
337
+ expectedOutput?: string | z.ZodType<unknown, z.ZodTypeDef, unknown> | undefined;
338
+ }[];
159
339
  finalAnswer: string;
160
340
  newMessages?: Message<MessageContentPart, string>[] | undefined;
161
341
  }>, never>;
@@ -1,10 +1,10 @@
1
- import { ReActAgent } from '../agents/react/agent.js';
2
1
  import { Workflow } from './workflow.js';
3
- import { Message, AssistantMessage } from '../backend/message.js';
2
+ import { Message, UserMessage } from '../backend/message.js';
4
3
  import { z } from 'zod';
5
4
  import { UnconstrainedMemory } from '../memory/unconstrainedMemory.js';
6
5
  import { BaseAgent } from '../agents/base.js';
7
6
  import { randomString, isFunction } from 'remeda';
7
+ import { ToolCallingAgent } from '../agents/toolCalling/agent.js';
8
8
 
9
9
  var __defProp = Object.defineProperty;
10
10
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -13,21 +13,30 @@ class AgentWorkflow {
13
13
  __name(this, "AgentWorkflow");
14
14
  }
15
15
  workflow;
16
- static schema = z.object({
17
- messages: z.array(z.instanceof(Message)).min(1),
16
+ schema = z.object({
17
+ inputs: z.array(z.object({
18
+ prompt: z.string().optional(),
19
+ context: z.string().optional(),
20
+ expectedOutput: z.union([
21
+ z.string(),
22
+ z.instanceof(z.ZodSchema)
23
+ ]).optional()
24
+ })),
18
25
  finalAnswer: z.string().optional(),
19
26
  newMessages: z.array(z.instanceof(Message)).default([])
20
27
  });
21
28
  constructor(name = "AgentWorkflow") {
22
29
  this.workflow = new Workflow({
23
30
  name,
24
- schema: AgentWorkflow.schema,
25
- outputSchema: AgentWorkflow.schema.required()
31
+ schema: this.schema,
32
+ outputSchema: this.schema.required()
26
33
  });
27
34
  }
28
- run(messages, options = {}) {
35
+ run(inputs, options = {}) {
29
36
  return this.workflow.run({
30
- messages
37
+ inputs: inputs.map((input) => input instanceof Message ? {
38
+ prompt: input.text
39
+ } : input)
31
40
  }, options);
32
41
  }
33
42
  addAgent(agent) {
@@ -47,12 +56,12 @@ class AgentWorkflow {
47
56
  return this.workflow.delStep(name);
48
57
  }
49
58
  _createFactory(input) {
50
- return (memory) => new ReActAgent({
59
+ return (memory) => new ToolCallingAgent({
51
60
  llm: input.llm,
52
61
  tools: input.tools ?? [],
53
62
  memory,
54
63
  meta: {
55
- name: input.name,
64
+ name: input.name || `Agent${randomString(4)}`,
56
65
  description: input.instructions ?? ""
57
66
  },
58
67
  execution: input.execution,
@@ -60,6 +69,7 @@ class AgentWorkflow {
60
69
  templates: {
61
70
  system: /* @__PURE__ */ __name((template) => template.fork((config) => {
62
71
  config.defaults.instructions = input.instructions || config.defaults.instructions;
72
+ config.defaults.role = input.role || config.defaults.role;
63
73
  }), "system")
64
74
  }
65
75
  }
@@ -68,21 +78,19 @@ class AgentWorkflow {
68
78
  _add(name, factory) {
69
79
  this.workflow.addStep(name, async (state, ctx) => {
70
80
  const memory = new UnconstrainedMemory();
71
- await memory.addMany([
72
- ...state.messages,
73
- ...state.newMessages
74
- ]);
81
+ await memory.addMany(state.newMessages);
82
+ const runInput = state.inputs.shift() ?? {
83
+ prompt: void 0
84
+ };
75
85
  const agent = await factory(memory.asReadOnly());
76
- const { result } = await agent.run({
77
- prompt: null
78
- }, {
86
+ const { result } = await agent.run(runInput, {
79
87
  signal: ctx.signal
80
88
  });
81
89
  state.finalAnswer = result.text;
82
- state.newMessages.push(new AssistantMessage([
83
- `Assistant Name: ${name}`,
84
- `Assistant Response: ${result.text}`
85
- ].join("\n")));
90
+ if (runInput.prompt) {
91
+ state.newMessages.push(new UserMessage(runInput.prompt));
92
+ }
93
+ state.newMessages.push(result);
86
94
  });
87
95
  return this;
88
96
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["agent.ts"],"names":["AgentWorkflow","workflow","schema","z","object","messages","array","instanceof","Message","min","finalAnswer","string","optional","newMessages","default","constructor","name","Workflow","outputSchema","required","run","options","addAgent","agent","BaseAgent","clone","then","factory","memory","_add","meta","randomString","isFunction","_createFactory","delAgent","delStep","input","ReActAgent","llm","tools","description","instructions","execution","templates","system","template","fork","config","defaults","addStep","state","ctx","UnconstrainedMemory","addMany","asReadOnly","result","prompt","signal","text","push","AssistantMessage","join"],"mappings":";;;;;;;;;;AA2CO,MAAMA,aAAAA,CAAAA;EA3Cb;;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B,QAASgD,CAAAA,OAAAA,CAAQjC,IAAM,EAAA,OAAOkC,OAAOC,GAAAA,KAAAA;AACxC,MAAMvB,MAAAA,MAAAA,GAAS,IAAIwB,mBAAAA,EAAAA;AACnB,MAAA,MAAMxB,OAAOyB,OAAQ,CAAA;WAAIH,KAAM7C,CAAAA,QAAAA;WAAa6C,KAAMrC,CAAAA;AAAY,OAAA,CAAA;AAE9D,MAAA,MAAMU,KAAQ,GAAA,MAAMI,OAAQC,CAAAA,MAAAA,CAAO0B,YAAU,CAAA;AAC7C,MAAA,MAAM,EAAEC,MAAAA,EAAW,GAAA,MAAMhC,MAAMH,GAAI,CAAA;QAAEoC,MAAQ,EAAA;OAAQ,EAAA;AAAEC,QAAAA,MAAAA,EAAQN,GAAIM,CAAAA;OAAO,CAAA;AAC1EP,MAAAA,KAAAA,CAAMxC,cAAc6C,MAAOG,CAAAA,IAAAA;AAC3BR,MAAMrC,KAAAA,CAAAA,WAAAA,CAAY8C,IAChB,CAAA,IAAIC,gBACF,CAAA;AAAC,QAAA,CAAA,gBAAA,EAAmB5C,IAAAA,CAAAA,CAAAA;AAAQ,QAAA,CAAA,oBAAA,EAAuBuC,OAAOG,IAAI,CAAA;QAAIG,IAAK,CAAA,IAAA,CAAA,CAAA,CAAA;KAG7E,CAAA;AACA,IAAO,OAAA,IAAA;AACT;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 { ReActAgent } from \"@/agents/react/agent.js\";\nimport { Workflow, WorkflowRunOptions } from \"@/workflows/workflow.js\";\nimport { AssistantMessage, Message } from \"@/backend/message.js\";\nimport { AnyTool } from \"@/tools/base.js\";\nimport { BaseMemory, ReadOnlyMemory } from \"@/memory/base.js\";\nimport { z } from \"zod\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { BaseAgent } from \"@/agents/base.js\";\nimport {\n ReActAgentExecutionConfig,\n ReActAgentRunInput,\n ReActAgentRunOptions,\n ReActAgentRunOutput,\n} from \"@/agents/react/types.js\";\nimport { isFunction, randomString } from \"remeda\";\nimport { ChatModel } from \"@/backend/chat.js\";\n\ntype AgentInstance = BaseAgent<ReActAgentRunInput, ReActAgentRunOutput, ReActAgentRunOptions>;\ntype AgentFactory = (memory: ReadOnlyMemory) => AgentInstance | Promise<AgentInstance>;\ninterface AgentFactoryInput {\n name: string;\n llm: ChatModel;\n instructions?: string;\n tools?: AnyTool[];\n execution?: ReActAgentExecutionConfig;\n}\n\nexport class AgentWorkflow {\n protected readonly workflow;\n\n static readonly schema = z.object({\n messages: z.array(z.instanceof(Message)).min(1),\n\n finalAnswer: z.string().optional(),\n newMessages: z.array(z.instanceof(Message)).default([]),\n });\n\n constructor(name = \"AgentWorkflow\") {\n this.workflow = new Workflow({\n name,\n schema: AgentWorkflow.schema,\n outputSchema: AgentWorkflow.schema.required(),\n });\n }\n\n run(messages: Message[], options: WorkflowRunOptions<string> = {}) {\n return this.workflow.run(\n {\n messages,\n },\n options,\n );\n }\n\n addAgent(agent: AgentFactory | AgentFactoryInput): this;\n addAgent(agent: AgentInstance): Promise<this>;\n addAgent(agent: AgentInstance | AgentFactory | AgentFactoryInput): this | Promise<this> {\n if (agent instanceof BaseAgent) {\n return agent.clone().then((clone) => {\n const factory: AgentFactory = (memory) => {\n clone.memory = memory;\n return clone;\n };\n return this._add(clone.meta.name, factory);\n });\n }\n\n const name = agent.name || `Agent${randomString(4)}`;\n return this._add(name, isFunction(agent) ? agent : this._createFactory(agent));\n }\n\n delAgent(name: string) {\n return this.workflow.delStep(name);\n }\n\n protected _createFactory(input: AgentFactoryInput): AgentFactory {\n return (memory: BaseMemory) =>\n new ReActAgent({\n llm: input.llm,\n tools: input.tools ?? [],\n memory,\n meta: {\n name: input.name,\n description: input.instructions ?? \"\",\n },\n execution: input.execution,\n ...(input.instructions && {\n templates: {\n system: (template) =>\n template.fork((config) => {\n config.defaults.instructions = input.instructions || config.defaults.instructions;\n }),\n },\n }),\n });\n }\n\n protected _add(name: string, factory: AgentFactory) {\n this.workflow.addStep(name, async (state, ctx) => {\n const memory = new UnconstrainedMemory();\n await memory.addMany([...state.messages, ...state.newMessages]);\n\n const agent = await factory(memory.asReadOnly());\n const { result } = await agent.run({ prompt: null }, { signal: ctx.signal });\n state.finalAnswer = result.text;\n state.newMessages.push(\n new AssistantMessage(\n [`Assistant Name: ${name}`, `Assistant Response: ${result.text}`].join(\"\\n\"),\n ),\n );\n });\n return this;\n }\n}\n"]}
1
+ {"version":3,"sources":["agent.ts"],"names":["AgentWorkflow","workflow","schema","z","object","inputs","array","prompt","string","optional","context","expectedOutput","union","instanceof","ZodSchema","finalAnswer","newMessages","Message","default","constructor","name","Workflow","outputSchema","required","run","options","map","input","text","addAgent","agent","BaseAgent","clone","then","factory","memory","_add","meta","randomString","isFunction","_createFactory","delAgent","delStep","ToolCallingAgent","llm","tools","description","instructions","execution","templates","system","template","fork","config","defaults","role","addStep","state","ctx","UnconstrainedMemory","addMany","runInput","shift","undefined","asReadOnly","result","signal","push","UserMessage"],"mappings":";;;;;;;;;;AAgDO,MAAMA,aAAAA,CAAAA;EAhDb;;;AAiDqBC,EAAAA,QAAAA;AAEVC,EAAAA,MAAAA,GAASC,EAAEC,MAAO,CAAA;IACzBC,MAAQF,EAAAA,CAAAA,CAAEG,KACRH,CAAAA,CAAAA,CAAEC,MAAO,CAAA;MACPG,MAAQJ,EAAAA,CAAAA,CAAEK,MAAM,EAAA,CAAGC,QAAQ,EAAA;MAC3BC,OAASP,EAAAA,CAAAA,CAAEK,MAAM,EAAA,CAAGC,QAAQ,EAAA;A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AA,IAAA;AACT;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 { Workflow, WorkflowRunOptions } from \"@/workflows/workflow.js\";\nimport { Message, UserMessage } from \"@/backend/message.js\";\nimport { AnyTool } from \"@/tools/base.js\";\nimport { BaseMemory, ReadOnlyMemory } from \"@/memory/base.js\";\nimport { z } from \"zod\";\nimport { UnconstrainedMemory } from \"@/memory/unconstrainedMemory.js\";\nimport { BaseAgent } from \"@/agents/base.js\";\nimport { isFunction, randomString } from \"remeda\";\nimport { ChatModel } from \"@/backend/chat.js\";\nimport { ToolCallingAgent } from \"@/agents/toolCalling/agent.js\";\nimport {\n ToolCallingAgentExecutionConfig,\n ToolCallingAgentRunInput,\n ToolCallingAgentRunOptions,\n ToolCallingAgentRunOutput,\n} from \"@/agents/toolCalling/types.js\";\n\ntype AgentInstance = BaseAgent<\n ToolCallingAgentRunInput,\n ToolCallingAgentRunOutput,\n ToolCallingAgentRunOptions\n>;\ntype AgentFactory = (memory: ReadOnlyMemory) => AgentInstance | Promise<AgentInstance>;\ninterface AgentFactoryInput {\n name?: string;\n role?: string;\n llm: ChatModel;\n instructions?: string;\n tools?: AnyTool[];\n execution?: ToolCallingAgentExecutionConfig;\n}\n\nexport class AgentWorkflow {\n protected readonly workflow;\n\n readonly schema = z.object({\n inputs: z.array(\n z.object({\n prompt: z.string().optional(),\n context: z.string().optional(),\n expectedOutput: z.union([z.string(), z.instanceof(z.ZodSchema)]).optional(),\n }),\n ),\n\n finalAnswer: z.string().optional(),\n newMessages: z.array(z.instanceof(Message)).default([]),\n });\n\n constructor(name = \"AgentWorkflow\") {\n this.workflow = new Workflow({\n name,\n schema: this.schema,\n outputSchema: this.schema.required(),\n });\n }\n\n run(inputs: (ToolCallingAgentRunInput | Message)[], options: WorkflowRunOptions<string> = {}) {\n return this.workflow.run(\n {\n inputs: inputs.map((input) => (input instanceof Message ? { prompt: input.text } : input)),\n },\n options,\n );\n }\n\n addAgent(agent: AgentFactory | AgentFactoryInput): this;\n addAgent(agent: AgentInstance): Promise<this>;\n addAgent(agent: AgentInstance | AgentFactory | AgentFactoryInput): this | Promise<this> {\n if (agent instanceof BaseAgent) {\n return agent.clone().then((clone) => {\n const factory: AgentFactory = (memory) => {\n clone.memory = memory;\n return clone;\n };\n return this._add(clone.meta.name, factory);\n });\n }\n\n const name = agent.name || `Agent${randomString(4)}`;\n return this._add(name, isFunction(agent) ? agent : this._createFactory(agent));\n }\n\n delAgent(name: string) {\n return this.workflow.delStep(name);\n }\n\n protected _createFactory(input: AgentFactoryInput): AgentFactory {\n return (memory: BaseMemory) =>\n new ToolCallingAgent({\n llm: input.llm,\n tools: input.tools ?? [],\n memory,\n meta: {\n name: input.name || `Agent${randomString(4)}`,\n description: input.instructions ?? \"\",\n },\n execution: input.execution,\n ...(input.instructions && {\n templates: {\n system: (template) =>\n template.fork((config) => {\n config.defaults.instructions = input.instructions || config.defaults.instructions;\n config.defaults.role = input.role || config.defaults.role;\n }),\n },\n }),\n });\n }\n\n protected _add(name: string, factory: AgentFactory) {\n this.workflow.addStep(name, async (state, ctx) => {\n const memory = new UnconstrainedMemory();\n await memory.addMany(state.newMessages);\n\n const runInput = state.inputs.shift() ?? { prompt: undefined };\n const agent = await factory(memory.asReadOnly());\n const { result } = await agent.run(runInput, { signal: ctx.signal });\n state.finalAnswer = result.text;\n if (runInput.prompt) {\n state.newMessages.push(new UserMessage(runInput.prompt));\n }\n state.newMessages.push(result);\n });\n return this;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beeai-framework",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "license": "Apache-2.0",
5
5
  "description": "BeeAI Framework - LLM Agent Framework",
6
6
  "author": "IBM Corp.",
@@ -156,7 +156,6 @@
156
156
  "ts:check": "tsc --noEmit && tsc -p tsconfig.examples.json --noEmit",
157
157
  "start": "tsx --tsconfig tsconfig.examples.json",
158
158
  "start:bee": "yarn start -- examples/agents/bee.ts",
159
- "start:telemetry": "BEE_FRAMEWORK_INSTRUMENTATION_ENABLED=true yarn start --import ./examples/helpers/telemetry.js",
160
159
  "docs:build": "embedme --source-root=. docs/**/*.md && yarn lint:fix docs/ && yarn prettier --write docs/",
161
160
  "docs:check": "embedme --source-root=. docs/**/*.md --verify",
162
161
  "docs:links": "linkinator . --timeout=10000 --retry --markdown --directory-listing --skip node_modules --skip CHANGELOG.md --skip docs/CHANGELOG.md --skip docs/_sidebar.md --skip \"https://ai.meta.com/blog/meta-llama-3-1/\" --include",
@@ -183,9 +182,8 @@
183
182
  },
184
183
  "dependencies": {
185
184
  "@ai-zen/node-fetch-event-source": "^2.1.4",
186
- "@opentelemetry/api": "^1.9.0",
187
185
  "@streamparser/json": "^0.0.22",
188
- "ai": "^4.1.58",
186
+ "ai": "^4.1.61",
189
187
  "ajv": "^8.17.1",
190
188
  "ajv-formats": "^3.0.1",
191
189
  "duck-duck-scrape": "^2.2.7",
@@ -215,11 +213,11 @@
215
213
  "@ai-sdk/azure": "^1.1.2",
216
214
  "@ai-sdk/google-vertex": "^2.1.6",
217
215
  "@ai-sdk/groq": "^1.1.6",
218
- "@ai-sdk/openai": "^1.1.2",
216
+ "@ai-sdk/openai": "^1.2.5",
219
217
  "@aws-sdk/client-bedrock-runtime": "^3.706.0",
220
218
  "@elastic/elasticsearch": "^8.0.0",
221
219
  "@googleapis/customsearch": "^3.2.0",
222
- "@i-am-bee/acp-sdk": "^0.0.4",
220
+ "@i-am-bee/acp-sdk": "^0.0.5",
223
221
  "@langchain/community": ">=0.2.28",
224
222
  "@langchain/core": ">=0.2.27",
225
223
  "@modelcontextprotocol/sdk": "^1.0.4",
@@ -287,7 +285,7 @@
287
285
  "@ai-sdk/azure": "^1.1.2",
288
286
  "@ai-sdk/google-vertex": "^2.1.6",
289
287
  "@ai-sdk/groq": "^1.1.6",
290
- "@ai-sdk/openai": "^1.2.3",
288
+ "@ai-sdk/openai": "^1.2.5",
291
289
  "@commitlint/cli": "^19.7.1",
292
290
  "@commitlint/config-conventional": "^19.7.1",
293
291
  "@elastic/elasticsearch": "^8.16.2",
@@ -301,11 +299,6 @@
301
299
  "@langchain/langgraph": "0.2.55",
302
300
  "@langchain/ollama": "^0.2.0",
303
301
  "@modelcontextprotocol/sdk": "^1.0.4",
304
- "@opentelemetry/instrumentation": "^0.56.0",
305
- "@opentelemetry/resources": "^1.29.0",
306
- "@opentelemetry/sdk-node": "^0.56.0",
307
- "@opentelemetry/sdk-trace-node": "^1.29.0",
308
- "@opentelemetry/semantic-conventions": "^1.28.0",
309
302
  "@release-it/conventional-changelog": "^8.0.2",
310
303
  "@rollup/plugin-commonjs": "^28.0.1",
311
304
  "@stylistic/eslint-plugin-js": "^2.12.1",
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- var env_cjs = require('../internals/env.cjs');
4
- var zod = require('zod');
5
-
6
- const INSTRUMENTATION_ENABLED = env_cjs.parseEnv.asBoolean("BEE_FRAMEWORK_INSTRUMENTATION_ENABLED");
7
- const INSTRUMENTATION_IGNORED_KEYS = env_cjs.parseEnv("BEE_FRAMEWORK_INSTRUMENTATION_IGNORED_KEYS", zod.z.string(), "").split(",").filter(Boolean);
8
-
9
- exports.INSTRUMENTATION_ENABLED = INSTRUMENTATION_ENABLED;
10
- exports.INSTRUMENTATION_IGNORED_KEYS = INSTRUMENTATION_IGNORED_KEYS;
11
- //# sourceMappingURL=config.cjs.map
12
- //# sourceMappingURL=config.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["config.ts"],"names":["INSTRUMENTATION_ENABLED","parseEnv","asBoolean","INSTRUMENTATION_IGNORED_KEYS","z","string","split","filter","Boolean"],"mappings":";;;;;AAmBaA,MAAAA,uBAAAA,GAA0BC,gBAASC,CAAAA,SAAAA,CAAU,uCAAA;AAEnD,MAAMC,4BAA+BF,GAAAA,gBAAAA,CAC1C,4CACAG,EAAAA,KAAAA,CAAEC,MAAM,EAAA,EACR,EAAA,CAAA,CAECC,KAAM,CAAA,GAAA,CACNC,CAAAA,MAAAA,CAAOC,OAAAA","file":"config.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 { parseEnv } from \"@/internals/env.js\";\nimport { z } from \"zod\";\n\nexport const INSTRUMENTATION_ENABLED = parseEnv.asBoolean(\"BEE_FRAMEWORK_INSTRUMENTATION_ENABLED\");\n\nexport const INSTRUMENTATION_IGNORED_KEYS = parseEnv(\n \"BEE_FRAMEWORK_INSTRUMENTATION_IGNORED_KEYS\",\n z.string(),\n \"\",\n)\n .split(\",\")\n .filter(Boolean);\n"]}
@@ -1,19 +0,0 @@
1
- /**
2
- * Copyright 2025 IBM Corp.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- declare const INSTRUMENTATION_ENABLED: boolean;
17
- declare const INSTRUMENTATION_IGNORED_KEYS: string[];
18
-
19
- export { INSTRUMENTATION_ENABLED, INSTRUMENTATION_IGNORED_KEYS };