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

34 lines
1.3 KiB
TypeScript
Raw Normal View History

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