Files
video-create/web/server/agent/tools/get-manifest.ts

26 lines
892 B
TypeScript
Raw Normal View History

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