refactor(agent): 将 tools 模块拆分为独立文件并优化导入路径
将 `tools.ts` 拆分为按功能划分的独立文件,并存放于 `tools/` 目录下,同时更新导入路径;优化 agent 系统提示语,移除冗余的「美图 Agent」前缀。
This commit is contained in:
25
web/server/agent/tools/get-manifest.ts
Normal file
25
web/server/agent/tools/get-manifest.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { PROJECT_ROOT, loadJSON } from './shared';
|
||||
import type { ToolDefinition } from './types';
|
||||
|
||||
export const getManifest: ToolDefinition = {
|
||||
name: 'get_manifest',
|
||||
description: '读取指定 manifest.json 的完整内容,返回 JSON 字符串。',
|
||||
input_schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
manifestPath: { type: 'string', description: 'manifest.json 的绝对路径或相对路径' },
|
||||
},
|
||||
required: ['manifestPath'],
|
||||
},
|
||||
execute: async (params) => {
|
||||
const { manifestPath } = params as { manifestPath: string };
|
||||
const resolved = path.isAbsolute(manifestPath)
|
||||
? manifestPath
|
||||
: path.resolve(PROJECT_ROOT, manifestPath);
|
||||
if (!fs.existsSync(resolved)) return `manifest 不存在: ${resolved}`;
|
||||
const manifest = loadJSON(resolved);
|
||||
return JSON.stringify(manifest, null, 2);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user