import { BaseMemory } from '../../memory/base.cjs'; import { Message } from '../../backend/message.cjs'; import { C as Callback } from '../../emitter-D4OcelZ9.cjs'; import { AnyTool, BaseToolRunOptions, ToolOutput, ToolError } from '../../tools/base.cjs'; import { ReActAgentSystemPrompt, ReActAgentAssistantPrompt, ReActAgentUserPrompt, ReActAgentUserEmptyPrompt, ReActAgentToolErrorPrompt, ReActAgentToolInputErrorPrompt, ReActAgentToolNoResultsPrompt, ReActAgentToolNotFoundPrompt, ReActAgentSchemaErrorPrompt } from './prompts.cjs'; import { LinePrefixParser } from '../../parsers/linePrefix.cjs'; import { ZodParserField, JSONParserField } from '../../parsers/field.cjs'; import { NonUndefined } from '../../internals/types.cjs'; import { i as ChatModelOutput } from '../../chat-C20nYj46.cjs'; import '../../errors.cjs'; import '../../internals/helpers/guards.cjs'; import '../../internals/serializable.cjs'; import 'ai'; import 'ajv'; import '../../context.cjs'; import '../../internals/helpers/promise.cjs'; import 'promise-based-task'; import '../../cache/base.cjs'; import '../../internals/helpers/schema.cjs'; import 'zod'; import 'zod-to-json-schema'; import '../../template.cjs'; import 'node_modules/remeda/dist/ToString-DKW-jYvM.js'; import '../../parsers/errors.cjs'; import '@streamparser/json'; import 'jsonrepair/stream'; import '../../backend/constants.cjs'; import '../../logger/logger.cjs'; import 'pino'; /** * Copyright 2025 © BeeAI a Series of LF Projects, LLC * SPDX-License-Identifier: Apache-2.0 */ interface ReActAgentRunInput { prompt: string | null; } interface ReActAgentRunOutput { result: Message; iterations: ReActAgentRunIteration[]; memory: BaseMemory; } interface ReActAgentRunIteration { raw: ChatModelOutput; state: ReActIterationResult; } interface ReActAgentExecutionConfig { totalMaxRetries?: number; maxRetriesPerStep?: number; maxIterations?: number; } interface ReActAgentRunOptions { signal?: AbortSignal; execution?: ReActAgentExecutionConfig; } interface ReActAgentMeta { iteration: number; } interface ReActAgentUpdateMeta extends ReActAgentMeta { success: boolean; } interface ReActAgentCallbacks { start?: Callback<{ meta: ReActAgentMeta; tools: AnyTool[]; memory: BaseMemory; }>; error?: Callback<{ error: Error; meta: ReActAgentMeta; }>; retry?: Callback<{ meta: ReActAgentMeta; }>; success?: Callback<{ data: Message; iterations: ReActAgentRunIteration[]; memory: BaseMemory; meta: ReActAgentMeta; }>; update?: Callback<{ data: ReActIterationResult; update: { key: keyof ReActIterationResult; value: string; parsedValue: unknown; }; meta: ReActAgentUpdateMeta; memory: BaseMemory; }>; partialUpdate?: Callback<{ data: ReActAgentIterationResultPartial; update: { key: keyof ReActIterationResult; value: string; parsedValue: unknown; }; meta: ReActAgentUpdateMeta; }>; toolStart?: Callback<{ data: { tool: AnyTool; input: unknown; options: BaseToolRunOptions; iteration: ReActAgentIterationToolResult; }; meta: ReActAgentMeta; }>; toolSuccess?: Callback<{ data: { tool: AnyTool; input: unknown; options: BaseToolRunOptions; result: ToolOutput; iteration: ReActAgentIterationToolResult; }; meta: ReActAgentMeta; }>; toolError?: Callback<{ data: { tool: AnyTool; input: unknown; options: BaseToolRunOptions; error: ToolError; iteration: ReActAgentIterationToolResult; }; meta: ReActAgentMeta; }>; } interface ReActAgentTemplates { system: typeof ReActAgentSystemPrompt; assistant: typeof ReActAgentAssistantPrompt; user: typeof ReActAgentUserPrompt; userEmpty: typeof ReActAgentUserEmptyPrompt; toolError: typeof ReActAgentToolErrorPrompt; toolInputError: typeof ReActAgentToolInputErrorPrompt; toolNoResultError: typeof ReActAgentToolNoResultsPrompt; toolNotFoundError: typeof ReActAgentToolNotFoundPrompt; schemaError: typeof ReActAgentSchemaErrorPrompt; } type ReActAgentParserInput = LinePrefixParser.define<{ thought: ZodParserField; tool_name: ZodParserField; tool_input: JSONParserField>; tool_output: ZodParserField; final_answer: ZodParserField; }>; type ReActAgentParser = LinePrefixParser; type ReActIterationResult = LinePrefixParser.inferOutput; type ReActAgentIterationResultPartial = LinePrefixParser.inferPartialOutput; type ReActAgentIterationToolResult = NonUndefined; export type { ReActAgentCallbacks, ReActAgentExecutionConfig, ReActAgentIterationResultPartial, ReActAgentIterationToolResult, ReActAgentMeta, ReActAgentParserInput, ReActAgentRunInput, ReActAgentRunIteration, ReActAgentRunOptions, ReActAgentRunOutput, ReActAgentTemplates, ReActAgentUpdateMeta, ReActIterationResult };