feat: add admin_exec tool + fix repo_write_file PUT method

This commit is contained in:
bingshuo 2026-05-20 01:31:13 +08:00
parent 6fa14c4978
commit b1a5a1306f

View File

@ -369,6 +369,19 @@ const TOOLS = [
description: '查看铸渊核心大脑状态(快速唤醒上下文摘要)',
inputSchema: { type: 'object', properties: {} },
},
{
name: 'admin_exec',
description: '在广州服务器上执行任意Shell命令管理员工具',
inputSchema: {
type: 'object',
properties: {
command: { type: 'string', description: '要执行的Shell命令' },
},
required: ['command'],
},
},
{
name: 'brain_update_temporal',
description: '更新铸渊时间核心大脑',
@ -425,7 +438,8 @@ async function executeTool(name, args) {
body.sha = checkRes.data.sha; // 更新已有文件需要 SHA
}
const res = await giteaApi('POST', `/api/v1/repos/${CONFIG.giteaOwner}/${CONFIG.giteaRepo}/contents/${encPath}`, body);
const method2 = body.sha ? 'PUT' : 'POST';
const res = await giteaApi(method2, `/api/v1/repos/${CONFIG.giteaOwner}/${CONFIG.giteaRepo}/contents/${encPath}`, body);
if (res.status >= 200 && res.status < 300) {
return `文件已写入: ${filePath} (分支: ${branch}, 提交: ${message})`;
}
@ -704,6 +718,14 @@ async function executeTool(name, args) {
}
}
case 'admin_exec': {
const cmd = args.command || '';
if (!cmd) return '请提供要执行的命令';
const result = gitExec(cmd);
return result.ok ? result.output : '执行失败: ' + result.error;
}
case 'brain_update_temporal': {
const result = gitExec(`node scripts/temporal-clock.js`, CONFIG.repoDir);
return result.ok ? result.output : result.error;