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

34 lines
1.3 KiB
TypeScript

import path from 'path';
import fs from 'fs';
import { ACCOUNTS_DIR } from './shared';
import type { ToolDefinition } from './types';
export const getAccountPrompts: ToolDefinition = {
name: 'get_account_prompts',
description: '获取指定账号的三个提示词模板内容:分镜提示词、图片提示词、视频提示词。这些模板定义了账号的视频风格和创意方向。',
input_schema: {
type: 'object',
properties: {
accountId: { type: 'string', description: '账号ID' },
},
required: ['accountId'],
},
execute: async (params) => {
const { accountId } = params as { accountId: string };
const accountDir = path.join(ACCOUNTS_DIR, accountId);
if (!fs.existsSync(accountDir)) return `账号「${accountId}」不存在`;
const promptsDir = path.join(accountDir, 'prompts');
const promptFiles = ['分镜.md', '图片提示词.md', '视频提示词.md'];
const result: Record<string, string> = {};
for (const file of promptFiles) {
const filePath = path.join(promptsDir, file);
if (fs.existsSync(filePath)) {
result[file] = fs.readFileSync(filePath, 'utf-8');
} else {
result[file] = `(文件不存在: ${filePath})`;
}
}
return JSON.stringify(result, null, 2);
},
};