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
@@ -56,22 +56,22 @@ declare class MilvusDatabaseTool extends Tool<JSONToolOutput<MilvusSearchToolRes
56
56
  searchOutput: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
57
57
  }, "strip", z.ZodTypeAny, {
58
58
  action: MilvusAction;
59
- filter?: string | undefined;
60
- topK?: number | undefined;
61
59
  metadata?: Record<string, any> | undefined;
60
+ filter?: string | undefined;
62
61
  collectionName?: string | undefined;
63
62
  vector?: number[] | undefined;
64
63
  vectors?: number[][] | undefined;
64
+ topK?: number | undefined;
65
65
  ids?: (string | number)[] | undefined;
66
66
  searchOutput?: string[] | undefined;
67
67
  }, {
68
68
  action: MilvusAction;
69
- filter?: string | undefined;
70
- topK?: number | undefined;
71
69
  metadata?: Record<string, any> | undefined;
70
+ filter?: string | undefined;
72
71
  collectionName?: string | undefined;
73
72
  vector?: number[] | undefined;
74
73
  vectors?: number[][] | undefined;
74
+ topK?: number | undefined;
75
75
  ids?: (string | number)[] | undefined;
76
76
  searchOutput?: string[] | undefined;
77
77
  }>;
package/dist/version.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  exports.Version = "0.0.0";
4
4
  try {
5
- exports.Version = "0.1.7";
5
+ exports.Version = "0.1.9";
6
6
  } catch {
7
7
  }
8
8
  //# sourceMappingURL=version.cjs.map
package/dist/version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  let Version = "0.0.0";
2
2
  try {
3
- Version = "0.1.7";
3
+ Version = "0.1.9";
4
4
  } catch {
5
5
  }
6
6
 
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var agent_cjs = require('../agents/react/agent.cjs');
4
3
  var workflow_cjs = require('./workflow.cjs');
5
4
  var message_cjs = require('../backend/message.cjs');
6
5
  var zod = require('zod');
7
6
  var unconstrainedMemory_cjs = require('../memory/unconstrainedMemory.cjs');
8
7
  var base_cjs = require('../agents/base.cjs');
9
8
  var remeda = require('remeda');
9
+ var agent_cjs = require('../agents/toolCalling/agent.cjs');
10
10
 
11
11
  var __defProp = Object.defineProperty;
12
12
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -15,21 +15,30 @@ class AgentWorkflow {
15
15
  __name(this, "AgentWorkflow");
16
16
  }
17
17
  workflow;
18
- static schema = zod.z.object({
19
- messages: zod.z.array(zod.z.instanceof(message_cjs.Message)).min(1),
18
+ schema = zod.z.object({
19
+ inputs: zod.z.array(zod.z.object({
20
+ prompt: zod.z.string().optional(),
21
+ context: zod.z.string().optional(),
22
+ expectedOutput: zod.z.union([
23
+ zod.z.string(),
24
+ zod.z.instanceof(zod.z.ZodSchema)
25
+ ]).optional()
26
+ })),
20
27
  finalAnswer: zod.z.string().optional(),
21
28
  newMessages: zod.z.array(zod.z.instanceof(message_cjs.Message)).default([])
22
29
  });
23
30
  constructor(name = "AgentWorkflow") {
24
31
  this.workflow = new workflow_cjs.Workflow({
25
32
  name,
26
- schema: AgentWorkflow.schema,
27
- outputSchema: AgentWorkflow.schema.required()
33
+ schema: this.schema,
34
+ outputSchema: this.schema.required()
28
35
  });
29
36
  }
30
- run(messages, options = {}) {
37
+ run(inputs, options = {}) {
31
38
  return this.workflow.run({
32
- messages
39
+ inputs: inputs.map((input) => input instanceof message_cjs.Message ? {
40
+ prompt: input.text
41
+ } : input)
33
42
  }, options);
34
43
  }
35
44
  addAgent(agent) {
@@ -49,12 +58,12 @@ class AgentWorkflow {
49
58
  return this.workflow.delStep(name);
50
59
  }
51
60
  _createFactory(input) {
52
- return (memory) => new agent_cjs.ReActAgent({
61
+ return (memory) => new agent_cjs.ToolCallingAgent({
53
62
  llm: input.llm,
54
63
  tools: input.tools ?? [],
55
64
  memory,
56
65
  meta: {
57
- name: input.name,
66
+ name: input.name || `Agent${remeda.randomString(4)}`,
58
67
  description: input.instructions ?? ""
59
68
  },
60
69
  execution: input.execution,
@@ -62,6 +71,7 @@ class AgentWorkflow {
62
71
  templates: {
63
72
  system: /* @__PURE__ */ __name((template) => template.fork((config) => {
64
73
  config.defaults.instructions = input.instructions || config.defaults.instructions;
74
+ config.defaults.role = input.role || config.defaults.role;
65
75
  }), "system")
66
76
  }
67
77
  }
@@ -70,21 +80,19 @@ class AgentWorkflow {
70
80
  _add(name, factory) {
71
81
  this.workflow.addStep(name, async (state, ctx) => {
72
82
  const memory = new unconstrainedMemory_cjs.UnconstrainedMemory();
73
- await memory.addMany([
74
- ...state.messages,
75
- ...state.newMessages
76
- ]);
83
+ await memory.addMany(state.newMessages);
84
+ const runInput = state.inputs.shift() ?? {
85
+ prompt: void 0
86
+ };
77
87
  const agent = await factory(memory.asReadOnly());
78
- const { result } = await agent.run({
79
- prompt: null
80
- }, {
88
+ const { result } = await agent.run(runInput, {
81
89
  signal: ctx.signal
82
90
  });
83
91
  state.finalAnswer = result.text;
84
- state.newMessages.push(new message_cjs.AssistantMessage([
85
- `Assistant Name: ${name}`,
86
- `Assistant Response: ${result.text}`
87
- ].join("\n")));
92
+ if (runInput.prompt) {
93
+ state.newMessages.push(new message_cjs.UserMessage(runInput.prompt));
94
+ }
95
+ state.newMessages.push(result);
88
96
  });
89
97
  return this;
90
98
  }
@@ -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;;;AA4CqBC,EAAAA,QAAAA;EAEnB,OAAgBC,MAAAA,GAASC,MAAEC,MAAO,CAAA;IAChCC,QAAUF,EAAAA,KAAAA,CAAEG,MAAMH,KAAEI,CAAAA,UAAAA,CAAWC,mBAAAA,CAAAA,CAAAA,CAAUC,IAAI,CAAA,CAAA;IAE7CC,WAAaP,EAAAA,KAAAA,CAAEQ,MAAM,EAAA,CAAGC,QAAQ,EAAA;IAChCC,WAAaV,EAAAA,KAAAA,CAAEG,MAAMH,KAAEI,CAAAA,UAAAA,CAAWC,mBAAAA,CAAAA,CAAAA,CAAUM,OAAQ,CAAA,EAAE;GACxD,CAAA;AAEAC,EAAAA,WAAAA,CAAYC,OAAO,eAAiB,EAAA;AAClC,IAAKf,IAAAA,CAAAA,QAAAA,GAAW,IAAIgB,qBAAS,CAAA;AAC3BD,MAAAA,IAAAA;AACAd,MAAAA,MAAAA,EAAQF,aAAcE,CAAAA,MAAAA;MACtBgB,YAAclB,EAAAA,aAAAA,CAAcE,OAAOiB,QAAQ;KAC7C,CAAA;AACF;EAEAC,GAAIf,CAAAA,QAAAA,EAAqBgB,OAAsC,GAAA,EAAI,EAAA;AACjE,IAAO,OAAA,IAAA,CAAKpB,SAASmB,GACnB,CAAA;AACEf,MAAAA;AACF,KAAA,EACAgB,OAAAA,CAAAA;AAEJ;AAIAC,EAAAA,QAAAA,CAASC,KAA+E,EAAA;AACtF,IAAA,IAAIA,iBAAiBC,kBAAW,EAAA;AAC9B,MAAA,OA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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":";;;;;;;;;;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,GAAIQ,CAAAA;OAAO,CAAA;AAClET,MAAAA,KAAAA,CAAM1C,cAAckD,MAAOrC,CAAAA,IAAAA;AAC3B,MAAA,IAAIiC,SAAStD,MAAQ,EAAA;AACnBkD,QAAAA,KAAAA,CAAMzC,YAAYmD,IAAK,CAAA,IAAIC,uBAAYP,CAAAA,QAAAA,CAAStD,MAAM,CAAA,CAAA;AACxD;AACAkD,MAAMzC,KAAAA,CAAAA,WAAAA,CAAYmD,KAAKF,MAAAA,CAAAA;KACzB,CAAA;AACA,IAAO,OAAA,IAAA;AACT;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 { 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"]}
@@ -5,8 +5,8 @@ import { AnyTool } from '../tools/base.cjs';
5
5
  import { ReadOnlyMemory } from '../memory/base.cjs';
6
6
  import { z } from 'zod';
7
7
  import { a as BaseAgent } from '../base-daM6fHUP.cjs';
8
- import { ReActAgentRunInput, ReActAgentRunOutput, ReActAgentRunOptions, ReActAgentExecutionConfig } from '../agents/react/types.cjs';
9
8
  import { ChatModel } from '../backend/chat.cjs';
9
+ import { ToolCallingAgentRunInput, ToolCallingAgentRunOutput, ToolCallingAgentRunOptions, ToolCallingAgentExecutionConfig } from '../agents/toolCalling/types.cjs';
10
10
  import '../emitter-C9EN5B0j.cjs';
11
11
  import '../internals/types.cjs';
12
12
  import '../internals/helpers/guards.cjs';
@@ -19,143 +19,323 @@ import 'promise-based-task';
19
19
  import '../cache/base.cjs';
20
20
  import '../internals/helpers/schema.cjs';
21
21
  import 'zod-to-json-schema';
22
- import '../agents/react/prompts.cjs';
23
- import '../template.cjs';
24
- import '../parsers/linePrefix.cjs';
25
- import '../parsers/field.cjs';
26
- import '@streamparser/json';
27
- import 'jsonrepair/stream';
28
- import '../parsers/errors.cjs';
29
22
  import '../backend/utils.cjs';
30
23
  import '../backend/constants.cjs';
31
24
  import '@ai-sdk/provider';
25
+ import '../agents/toolCalling/prompts.cjs';
26
+ import '../template.cjs';
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>;