Files
video-create/web/server/agent/tools/get-manifest.ts
sion123 2ab5396461 refactor(agent): 将 tools 模块拆分为独立文件并优化导入路径
将 `tools.ts` 拆分为按功能划分的独立文件,并存放于 `tools/` 目录下,同时更新导入路径;优化 agent 系统提示语,移除冗余的「美图 Agent」前缀。
2026-05-08 01:05:37 +08:00

26 lines
892 B
TypeScript

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);
},
};