{"version":3,"file":"fs.cjs","names":["z","StructuredTool"],"sources":["../../src/tools/fs.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport { StructuredTool, ToolParams } from \"@langchain/core/tools\";\nimport { InferInteropZodOutput } from \"@langchain/core/utils/types\";\nimport { BaseFileStore } from \"../stores/file/base.js\";\n\n/**\n * Interface for parameters required by the ReadFileTool class.\n */\ninterface ReadFileParams extends ToolParams {\n  store: BaseFileStore;\n}\n\nconst readSchema = z.object({\n  file_path: z.string().describe(\"name of file\"),\n});\ntype ReadToolSchema = typeof readSchema;\n\n/**\n * Class for reading files from the disk. Extends the StructuredTool\n * class.\n */\nexport class ReadFileTool extends StructuredTool {\n  static lc_name() {\n    return \"ReadFileTool\";\n  }\n\n  schema = readSchema;\n\n  name = \"read_file\";\n\n  description = \"Read file from disk\";\n\n  store: BaseFileStore;\n\n  constructor({ store }: ReadFileParams) {\n    super(...arguments);\n\n    this.store = store;\n  }\n\n  async _call({ file_path }: InferInteropZodOutput<ReadToolSchema>) {\n    return await this.store.readFile(file_path);\n  }\n}\n\n/**\n * Interface for parameters required by the WriteFileTool class.\n */\ninterface WriteFileParams extends ToolParams {\n  store: BaseFileStore;\n}\n\nconst writeSchema = z.object({\n  file_path: z.string().describe(\"name of file\"),\n  text: z.string().describe(\"text to write to file\"),\n});\ntype WriteToolSchema = typeof writeSchema;\n\n/**\n * Class for writing data to files on the disk. Extends the StructuredTool\n * class.\n */\nexport class WriteFileTool extends StructuredTool {\n  static lc_name() {\n    return \"WriteFileTool\";\n  }\n\n  schema = writeSchema;\n\n  name = \"write_file\";\n\n  description = \"Write file from disk\";\n\n  store: BaseFileStore;\n\n  constructor({ store, ...rest }: WriteFileParams) {\n    super(rest);\n\n    this.store = store;\n  }\n\n  async _call({ file_path, text }: InferInteropZodOutput<WriteToolSchema>) {\n    await this.store.writeFile(file_path, text);\n    return \"File written to successfully.\";\n  }\n}\n"],"mappings":";;;;AAYA,MAAM,aAAaA,OAAAA,EAAE,OAAO,EAC1B,WAAWA,OAAAA,EAAE,QAAQ,CAAC,SAAS,eAAe,EAC/C,CAAC;;;;;AAOF,IAAa,eAAb,cAAkCC,sBAAAA,eAAe;CAC/C,OAAO,UAAU;AACf,SAAO;;CAGT,SAAS;CAET,OAAO;CAEP,cAAc;CAEd;CAEA,YAAY,EAAE,SAAyB;AACrC,QAAM,GAAG,UAAU;AAEnB,OAAK,QAAQ;;CAGf,MAAM,MAAM,EAAE,aAAoD;AAChE,SAAO,MAAM,KAAK,MAAM,SAAS,UAAU;;;AAW/C,MAAM,cAAcD,OAAAA,EAAE,OAAO;CAC3B,WAAWA,OAAAA,EAAE,QAAQ,CAAC,SAAS,eAAe;CAC9C,MAAMA,OAAAA,EAAE,QAAQ,CAAC,SAAS,wBAAwB;CACnD,CAAC;;;;;AAOF,IAAa,gBAAb,cAAmCC,sBAAAA,eAAe;CAChD,OAAO,UAAU;AACf,SAAO;;CAGT,SAAS;CAET,OAAO;CAEP,cAAc;CAEd;CAEA,YAAY,EAAE,OAAO,GAAG,QAAyB;AAC/C,QAAM,KAAK;AAEX,OAAK,QAAQ;;CAGf,MAAM,MAAM,EAAE,WAAW,QAAgD;AACvE,QAAM,KAAK,MAAM,UAAU,WAAW,KAAK;AAC3C,SAAO"}