- 添加账号管理详情页(基本信息、提示词、CapCut、参考图标签页) - 重构资产页面,按项目组分开展示图片/视频 - 聊天界面支持深度思考内容折叠展示、复制、删除消息 - 设置页面支持Agent配置(Anthropic/OpenAI协议)和工具配置 - 后端支持OpenAI兼容协议流式输出和DeepSeek思考模式 - 添加对话置顶/删除功能、数据库迁移、资产清单API - 添加账号参考图上传/删除、技能配置持久化、连接测试API
80 lines
2.6 KiB
TypeScript
80 lines
2.6 KiB
TypeScript
import { Router } from 'express';
|
|
import { getDb } from '../db';
|
|
import { execSync } from 'child_process';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
const PROJECT_ROOT = path.resolve(__dirname, '..', '..', '..');
|
|
const PIPELINE_SCRIPT = path.join(PROJECT_ROOT, '.claude', 'skills', 'video-from-script', 'scripts', 'pipeline.js');
|
|
|
|
export const pipelineRouter = Router();
|
|
|
|
pipelineRouter.get('/conversations', (req, res) => {
|
|
const { search } = req.query;
|
|
let sql = 'SELECT * FROM conversations';
|
|
const params: string[] = [];
|
|
if (search) {
|
|
sql += ' WHERE title LIKE ?';
|
|
params.push(`%${search}%`);
|
|
}
|
|
sql += ' ORDER BY pinned DESC, updated_at DESC LIMIT 100';
|
|
const rows = getDb().prepare(sql).all(...params);
|
|
res.json(rows);
|
|
});
|
|
|
|
pipelineRouter.get('/conversations/:id/messages', (req, res) => {
|
|
const rows = getDb().prepare(
|
|
'SELECT * FROM messages WHERE conversation_id = ? ORDER BY created_at'
|
|
).all(req.params.id);
|
|
res.json(rows);
|
|
});
|
|
|
|
pipelineRouter.delete('/conversations/:id', (req, res) => {
|
|
getDb().prepare('DELETE FROM conversations WHERE id = ?').run(req.params.id);
|
|
res.status(204).send();
|
|
});
|
|
|
|
// Update conversation (rename / toggle pin)
|
|
pipelineRouter.patch('/conversations/:id', (req, res) => {
|
|
const { title, pinned } = req.body;
|
|
if (title !== undefined) {
|
|
getDb().prepare(
|
|
'UPDATE conversations SET title = ?, updated_at = datetime(\'now\') WHERE id = ?'
|
|
).run(title, req.params.id);
|
|
}
|
|
if (pinned !== undefined) {
|
|
getDb().prepare(
|
|
'UPDATE conversations SET pinned = ?, updated_at = datetime(\'now\') WHERE id = ?'
|
|
).run(pinned ? 1 : 0, req.params.id);
|
|
}
|
|
res.json({ ok: true });
|
|
});
|
|
|
|
pipelineRouter.get('/status', (req, res) => {
|
|
const { manifest } = req.query;
|
|
if (!manifest) return res.status(400).json({ error: 'manifest path required' });
|
|
try {
|
|
const result = execSync(`node "${PIPELINE_SCRIPT}" status --manifest "${manifest}"`, {
|
|
cwd: PROJECT_ROOT, encoding: 'utf-8',
|
|
});
|
|
res.json({ output: result });
|
|
} catch (e) {
|
|
res.status(500).json({ error: (e as Error).message });
|
|
}
|
|
});
|
|
|
|
pipelineRouter.post('/resume', (req, res) => {
|
|
const { manifest } = req.body;
|
|
if (!manifest) return res.status(400).json({ error: 'manifest path required' });
|
|
try {
|
|
const result = execSync(`node "${PIPELINE_SCRIPT}" run --manifest "${manifest}" --resume`, {
|
|
cwd: PROJECT_ROOT, encoding: 'utf-8',
|
|
});
|
|
res.json({ output: result });
|
|
} catch (e) {
|
|
res.status(500).json({ error: (e as Error).message });
|
|
}
|
|
});
|