import type { Callbacks } from '@langchain/core/callbacks/manager'; import { BaseMessage, BaseMessageChunk, HumanMessage } from '@langchain/core/messages'; import { StructuredTool } from '@langchain/core/tools'; import { type ComputedRef } from '@vue/reactivity'; import { type Session } from 'koishi'; import { z } from 'zod'; import type { ChatLunaChatPrompt } from '../chain/prompt'; import type { ChatLunaBaseEmbeddings, ChatLunaChatModel } from 'koishi-plugin-chatluna/llm-core/platform/model'; import type { ChatLunaTool } from 'koishi-plugin-chatluna/llm-core/platform/types'; import type { PresetTemplate } from '../prompt'; import type { AgentRunnerOutput } from './executor'; import type { AgentEvent, MessageQueue, SubagentContext, ToolMask } from './types'; export interface CreateAgentOptions { id?: string; name?: string; description?: string; llm: ComputedRef; embeddings: ChatLunaBaseEmbeddings; tools: ComputedRef; prompt: ChatLunaChatPrompt; mode?: 'tool-calling' | 'react'; maxSteps?: number; handleParsingErrors?: boolean | string | ((e: Error) => string); instructions?: ComputedRef; returnIntermediateSteps?: boolean; toolMask?: ToolMask; } export interface AgentGenerateOptions { prompt: string | HumanMessage; session?: Session; conversationId: string; requestId: string; source?: 'chatluna' | 'character'; history?: BaseMessage[]; variables?: Record; signal?: AbortSignal; maxToken?: number; maxTokenLimit?: number; messageQueue?: MessageQueue; pauseGate?: (signal?: AbortSignal) => Promise; toolMask?: ToolMask; subagentContext?: SubagentContext; onStep?: (event: AgentEvent) => Promise | void; onToken?: (token: string) => Promise | void; onChunk?: (chunk: BaseMessageChunk) => Promise | void; callbacks?: Callbacks; } export interface AgentStream { text: AsyncIterable; steps: AsyncIterable; result: Promise; } export interface AgentToolOptions { name?: string; description?: string; } export interface ChatLunaAgent { id: string; name: string; description: string; generate(input: AgentGenerateOptions): Promise; stream(input: AgentGenerateOptions): Promise; asTool(options?: AgentToolOptions): StructuredTool; } export interface CreateAgentToolOptions extends AgentToolOptions { schema?: z.ZodTypeAny; } export declare function createAgent(options: CreateAgentOptions): ChatLunaAgent; export declare function createAgentTool(agent: ChatLunaAgent, options?: CreateAgentToolOptions): StructuredTool; export declare function createPromptPreset(name: string, system?: string, preset?: ComputedRef): ComputedRef;