UNPKG

koishi-plugin-chatluna-plugin-common

Version:
213 lines (212 loc) 6.7 kB
import { StructuredTool, Tool, ToolParams } from '@langchain/core/tools'; import { Context } from 'koishi'; import { ChatLunaPlugin } from 'koishi-plugin-chatluna/services/chat'; import { Config } from '..'; import z from 'zod'; export declare function apply(ctx: Context, config: Config, plugin: ChatLunaPlugin): Promise<void>; interface BaseFileStore { readFile(path: string): Promise<string>; writeFile(writePath: string, contents: string): Promise<void>; listFiles(path?: string): Promise<string[]>; grep(pattern: string, path?: string, glob?: string, outputMode?: 'content' | 'files_with_matches' | 'count'): Promise<string[] | number>; glob(pattern: string, path?: string): Promise<string[]>; editFile(filePath: string, oldText: string, newText: string): Promise<boolean>; updateFile(filePath: string, oldString: string, newString: string, replaceCount?: number): Promise<{ success: boolean; context: string; replacements: number; }>; rename(oldPath: string, newPath: string): Promise<void>; } interface ReadFileParams extends ToolParams { store: BaseFileStore; } export declare class ReadFileTool extends Tool { name: string; description: string; store: BaseFileStore; constructor({ store }: ReadFileParams); _call(filePath: string): Promise<string>; } interface WriteFileParams extends ToolParams { store: BaseFileStore; } export declare class WriteFileTool extends StructuredTool { name: string; description: string; schema: z.ZodObject<{ filePath: z.ZodString; text: z.ZodString; }, "strip", z.ZodTypeAny, { text?: string; filePath?: string; }, { text?: string; filePath?: string; }>; store: BaseFileStore; constructor({ store, ...rest }: WriteFileParams); _call(input: z.infer<typeof this.schema>): Promise<string>; } interface ListFileParams extends ToolParams { store: BaseFileStore; } export declare class ListFileTool extends StructuredTool { name: string; description: string; schema: z.ZodObject<{ dirPath: z.ZodString; recursive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { dirPath?: string; recursive?: boolean; }, { dirPath?: string; recursive?: boolean; }>; store: BaseFileStore; constructor({ store, ...rest }: ListFileParams); _call(input: z.infer<typeof this.schema>): Promise<string>; } interface GrepParams extends ToolParams { store: BaseFileStore; } export declare class GrepTool extends StructuredTool { name: string; description: string; schema: z.ZodObject<{ pattern: z.ZodString; searchPath: z.ZodString; globPattern: z.ZodOptional<z.ZodString>; outputMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<["content", "files_with_matches", "count"]>>>; }, "strip", z.ZodTypeAny, { pattern?: string; searchPath?: string; globPattern?: string; outputMode?: "content" | "files_with_matches" | "count"; }, { pattern?: string; searchPath?: string; globPattern?: string; outputMode?: "content" | "files_with_matches" | "count"; }>; store: BaseFileStore; constructor({ store, ...rest }: GrepParams); _call(input: z.infer<typeof this.schema>): Promise<string>; } interface GlobParams extends ToolParams { store: BaseFileStore; } export declare class GlobTool extends StructuredTool { name: string; description: string; schema: z.ZodObject<{ pattern: z.ZodString; searchPath: z.ZodString; }, "strip", z.ZodTypeAny, { pattern?: string; searchPath?: string; }, { pattern?: string; searchPath?: string; }>; store: BaseFileStore; constructor({ store, ...rest }: GlobParams); _call(input: z.infer<typeof this.schema>): Promise<string>; } interface RenameParams extends ToolParams { store: BaseFileStore; } export declare class RenameTool extends StructuredTool { name: string; description: string; schema: z.ZodObject<{ oldPath: z.ZodString; newPath: z.ZodString; }, "strip", z.ZodTypeAny, { oldPath?: string; newPath?: string; }, { oldPath?: string; newPath?: string; }>; store: BaseFileStore; constructor({ store, ...rest }: RenameParams); _call(input: z.infer<typeof this.schema>): Promise<string>; } export declare class MultiRenameTool extends StructuredTool { name: string; description: string; schema: z.ZodObject<{ pattern: z.ZodString; replacement: z.ZodString; searchPath: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { pattern?: string; searchPath?: string; replacement?: string; }, { pattern?: string; searchPath?: string; replacement?: string; }>; store: BaseFileStore; constructor({ store, ...rest }: RenameParams); _call(input: z.infer<typeof this.schema>): Promise<string>; } export declare class MultiWriteFileTool extends StructuredTool { name: string; description: string; schema: z.ZodObject<{ files: z.ZodArray<z.ZodObject<{ filePath: z.ZodString; text: z.ZodString; }, "strip", z.ZodTypeAny, { text?: string; filePath?: string; }, { text?: string; filePath?: string; }>, "many">; }, "strip", z.ZodTypeAny, { files?: { text?: string; filePath?: string; }[]; }, { files?: { text?: string; filePath?: string; }[]; }>; store: BaseFileStore; constructor({ store, ...rest }: WriteFileParams); _call(input: z.infer<typeof this.schema>): Promise<string>; } interface UpdateFileParams extends ToolParams { store: BaseFileStore; } export declare class UpdateFileTool extends StructuredTool { name: string; description: string; schema: z.ZodObject<{ filePath: z.ZodString; oldString: z.ZodString; newString: z.ZodString; replaceCount: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { filePath?: string; oldString?: string; newString?: string; replaceCount?: number; }, { filePath?: string; oldString?: string; newString?: string; replaceCount?: number; }>; store: BaseFileStore; constructor({ store, ...rest }: UpdateFileParams); _call(input: z.infer<typeof this.schema>): Promise<string>; } export {};