mirror of
https://github.com/Mintplex-Labs/anything-llm
synced 2026-04-25 17:15:37 +02:00
* Powerpoint File Creation (#5278) * wip * download card * UI for downloading * move to fs system with endpoint to pull files * refactor UI * final-pass * remove save-file-browser skill and refactor * remove fileDownload event * reset * reset file * reset timeout * persist toggle * Txt creation (#5279) * wip * download card * UI for downloading * move to fs system with endpoint to pull files * refactor UI * final-pass * remove save-file-browser skill and refactor * remove fileDownload event * reset * reset file * reset timeout * wip * persist toggle * add arbitrary text creation file * Add PDF document generation with markdown formatting (#5283) add support for branding in bottom right corner refactor core utils and frontend rendering * Xlsx document creation (#5284) add Excel doc & sheet creation * Basic docx creation (#5285) * Basic docx creation * add test theme support + styling and title pages * simplify skill selection * handle TG attachments * send documents over tg * lazy import * pin deps * fix lock * i18n for file creation (#5286) i18n for file-creation connect #5280 * theme overhaul * Add PPTX subagent for better results * forgot files * Add PPTX subagent for better results (#5287) * Add PPTX subagent for better results * forgot files * make sub-agent use proper tool calling if it can and better UI hints
91 lines
3.2 KiB
JavaScript
91 lines
3.2 KiB
JavaScript
const filesystem = require("./lib.js");
|
|
|
|
module.exports.FilesystemWriteTextFile = {
|
|
name: "filesystem-write-text-file",
|
|
plugin: function () {
|
|
return {
|
|
name: "filesystem-write-text-file",
|
|
setup(aibitat) {
|
|
aibitat.function({
|
|
super: aibitat,
|
|
name: this.name,
|
|
description:
|
|
"Create a new text file or completely overwrite an existing text file with new content. " +
|
|
"Use with caution as it will overwrite existing files without warning. " +
|
|
"Only handles text/plaintext content with proper encoding. Only works within allowed directories. " +
|
|
"For binary formats (PDF, DOCX, XLSX, PPTX), use the appropriate document creation tools instead.",
|
|
examples: [
|
|
{
|
|
prompt: "Create a new config file with these settings",
|
|
call: JSON.stringify({
|
|
path: "config.json",
|
|
content: '{"debug": true, "port": 3000}',
|
|
}),
|
|
},
|
|
{
|
|
prompt: "Write a hello world Python script",
|
|
call: JSON.stringify({
|
|
path: "hello.py",
|
|
content: 'print("Hello, World!")',
|
|
}),
|
|
},
|
|
],
|
|
parameters: {
|
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
type: "object",
|
|
properties: {
|
|
path: {
|
|
type: "string",
|
|
description:
|
|
"The path where the file should be created or overwritten.",
|
|
},
|
|
content: {
|
|
type: "string",
|
|
description: "The content to write to the file.",
|
|
},
|
|
},
|
|
required: ["path", "content"],
|
|
additionalProperties: false,
|
|
},
|
|
handler: async function ({ path: filePath = "", content = "" }) {
|
|
try {
|
|
this.super.handlerProps.log(
|
|
`Using the filesystem-write-text-file tool.`
|
|
);
|
|
|
|
const validPath = await filesystem.validatePath(filePath);
|
|
this.super.introspect(
|
|
`${this.caller}: Writing to file ${filePath}`
|
|
);
|
|
|
|
if (this.super.requestToolApproval) {
|
|
const approval = await this.super.requestToolApproval({
|
|
skillName: this.name,
|
|
payload: { path: filePath, content },
|
|
description: "Write content to a file",
|
|
});
|
|
if (!approval.approved) {
|
|
this.super.introspect(
|
|
`${this.caller}: User rejected the ${this.name} request.`
|
|
);
|
|
return approval.message;
|
|
}
|
|
}
|
|
|
|
await filesystem.writeFileContent(validPath, content);
|
|
this.super.introspect(`Successfully wrote to ${filePath}`);
|
|
return `Successfully wrote to ${filePath}`;
|
|
} catch (e) {
|
|
this.super.handlerProps.log(
|
|
`filesystem-write-text-file error: ${e.message}`
|
|
);
|
|
this.super.introspect(`Error: ${e.message}`);
|
|
return `Error writing file: ${e.message}`;
|
|
}
|
|
},
|
|
});
|
|
},
|
|
};
|
|
},
|
|
};
|