005ce566a8
- Provider model_settings (Provider+Model 级别参数配置): DB JSONB → API → GSM → AgentFactory.resolve → 三节点 agent.run 注入 - 新增 data/toolset/regulatory_toolset/: 监管节点专属工具(query_workflow_status / query_task_list / send_file) - send_file 从 interactive_toolset 迁移至 regulatory_toolset,interactive 仅保留 approval - mcp_helper 合入 GlobalPluginManager dispatch tools - 前端 Provider 弹窗参数设置区加 JSON 编辑器(model_settings) - 前端 Plugin 页面新增"重型插件"Tab(HeavyPluginList 占位) - .gitignore 精简:去除系统默认项,修复 data/ 子目录追踪 - data/toolset/ 与 data/plugin/ 首次纳入版本控制 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
32 lines
858 B
Python
32 lines
858 B
Python
import os
|
||
|
||
|
||
async def write_file(file_path: str, content: str) -> str:
|
||
"""将内容写入指定文件(会覆盖已有内容,自动创建目录)。
|
||
|
||
Args:
|
||
file_path: 文件的路径
|
||
content: 要写入的内容
|
||
|
||
Returns:
|
||
操作结果描述
|
||
"""
|
||
from kilostar.utils.sandbox import validate_path, PathViolation
|
||
|
||
try:
|
||
file_path = validate_path(file_path, write=True)
|
||
except PathViolation as e:
|
||
return f"[Sandbox] {e}"
|
||
|
||
try:
|
||
dir_path = os.path.dirname(file_path)
|
||
if dir_path:
|
||
os.makedirs(dir_path, exist_ok=True)
|
||
|
||
with open(file_path, "w", encoding="utf-8") as f:
|
||
f.write(content)
|
||
|
||
return f"已成功写入文件: {file_path}({len(content)} 字符)"
|
||
except Exception as e:
|
||
return f"[Error] 写入文件失败: {e}"
|