import { Context, h, Session } from 'koishi'; import { Config } from '../config'; import type { ChatInvocationContext, ConversationResolution } from '../types'; import '../middlewares/system/lifecycle'; export declare class ChatChain { private readonly ctx; private readonly config; readonly _graph: ChatChainDependencyGraph; private readonly _senders; private isSetErrorMessage; constructor(ctx: Context, config: Config); private _createRecallThinkingMessage; receiveMessage(session: Session, ctx?: Context): Promise; receiveCommand(session: Session, command: string, options?: ChainMiddlewareContextOptions, ctx?: Context): Promise; runCommand(session: Session, command: string, options?: ChainMiddlewareContextOptions, ctx?: Context): Promise<{ ok: boolean; context: ChainMiddlewareContext; }>; middleware(name: T, middleware: ChainMiddlewareFunction, ctx?: Context): ChainMiddleware; sender(sender: ChatChainSender): void; private _runMiddleware; private _executeLevel; private _executeMiddleware; private sendMessage; private _handleStopStatus; private _handleMiddlewareError; } declare class ChatChainDependencyGraph { private readonly _tasks; private readonly _rules; private readonly _listeners; private _cachedOrder; private _index; addNode(middleware: ChainMiddleware): void; removeNode(name: string): void; once(name: string, listener: (...args: any[]) => void): void; before(taskA: ChainMiddleware | string, taskB: ChainMiddleware | string): void; after(taskA: ChainMiddleware | string, taskB: ChainMiddleware | string): void; getDependencies(task: string): Set; getDependents(task: string): string[]; build(): ChainMiddleware[][]; private _captureRuleSource; private _formatRule; private _formatSlot; } export declare class ChainMiddleware { readonly name: string; private readonly execute; private readonly graph; constructor(name: string, execute: ChainMiddlewareFunction, graph: ChatChainDependencyGraph); before(name: T): this; after(name: T): this; run(session: Session, options: ChainMiddlewareContext): Promise; } export interface ChainMiddlewareContext { config: Config; ctx: Context; session: Session; message: string | h[] | h[][]; options?: ChainMiddlewareContextOptions; command?: string; recallThinkingMessage?: () => Promise; send: (message: h[][] | h[] | h | string) => Promise; } export interface ChainMiddlewareContextOptions { conversation?: ConversationResolution; invocation?: ChatInvocationContext; deliverySession?: Session; messageName?: string; error?: Error; [key: string]: any; } export interface ChainMiddlewareName { } export type ChainMiddlewareFunction = (session: Session, context: ChainMiddlewareContext) => Promise; export type ChatChainSender = (session: Session, message: (h[] | h | string)[], context?: ChainMiddlewareContext) => Promise; export declare enum ChainMiddlewareRunStatus { SKIPPED = 0, STOP = 1, CONTINUE = 2 } export {};