mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-01 05:14:25 +00:00
feat(agent): allow create_file tool to create files directly from content
Add an optional 'data' field ({name, content}) to the create_file agent tool
so agents can create files without a local file (e.g. when bash is not
available). The existing 'path' upload mode is preserved; exactly one of
'path' or 'data' must be provided.
Extract mime detection helpers (getFileMimeType, readFileMimeType) into a
new file-mime module, keeping utils/mime.ts free of fs/path imports so it
stays compatible with the Temporal workflow bundle (agent-autofill imports
getProxyType from it). Refactor create_version to reuse the extracted
helpers.
Content uploads reuse s3Service.putObject; mime type is derived from the
filename extension with a text/plain fallback, and the name is sanitized
for the S3 key.
This commit is contained in:
@@ -403,7 +403,7 @@
|
||||
"agent_tool_create_folder_name": "Create Folder",
|
||||
"agent_tool_create_folder_desc": "Allows the agent to create new folders in Shumai.",
|
||||
"agent_tool_create_file_name": "Create File",
|
||||
"agent_tool_create_file_desc": "Allows the agent to create and upload new files to Shumai.",
|
||||
"agent_tool_create_file_desc": "Allows the agent to create files in Shumai, either by uploading a local file or by providing the file name and content directly.",
|
||||
"agent_tool_create_version_name": "Create Version",
|
||||
"agent_tool_create_version_desc": "Allows the agent to upload and stack a new version of an existing file in Shumai.",
|
||||
"enabled": "Enabled",
|
||||
|
||||
@@ -403,7 +403,7 @@
|
||||
"agent_tool_create_folder_name": "创建文件夹",
|
||||
"agent_tool_create_folder_desc": "允许智能体在 Shumai 中创建新文件夹。",
|
||||
"agent_tool_create_file_name": "创建文件",
|
||||
"agent_tool_create_file_desc": "允许智能体创建新文件并上传到 Shumai。",
|
||||
"agent_tool_create_file_desc": "允许智能体在 Shumai 中创建文件,既可以通过上传本地文件,也可以直接提供文件名和内容。",
|
||||
"agent_tool_create_version_name": "创建版本",
|
||||
"agent_tool_create_version_desc": "允许智能体在 Shumai 中为已有文件上传并叠加新版本。",
|
||||
"enabled": "已启用",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Allows the agent to create and upload new files to Shumai." |
|
||||
* | "Allows the agent to create files in Shumai, either by uploading a local file or by providing the file name and content directly." |
|
||||
*
|
||||
* @param {Agent_Tool_Create_File_DescInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
|
||||
@@ -6,17 +6,17 @@ import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
/** @typedef {{}} Agent_Tool_Create_File_DescInputs */
|
||||
|
||||
const en_agent_tool_create_file_desc = /** @type {(inputs: Agent_Tool_Create_File_DescInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Allows the agent to create and upload new files to Shumai.`)
|
||||
return /** @type {LocalizedString} */ (`Allows the agent to create files in Shumai, either by uploading a local file or by providing the file name and content directly.`)
|
||||
};
|
||||
|
||||
const zh_agent_tool_create_file_desc = /** @type {(inputs: Agent_Tool_Create_File_DescInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`允许智能体创建新文件并上传到 Shumai。`)
|
||||
return /** @type {LocalizedString} */ (`允许智能体在 Shumai 中创建文件,既可以通过上传本地文件,也可以直接提供文件名和内容。`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Allows the agent to create and upload new files to Shumai." |
|
||||
* | "Allows the agent to create files in Shumai, either by uploading a local file or by providing the file name and content directly." |
|
||||
*
|
||||
* @param {Agent_Tool_Create_File_DescInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
|
||||
Reference in New Issue
Block a user