feat: MVP v0.5 完成 - 全部14个P0功能
- P0-8: 决策交互卡片(飞书卡片+回调+4种模板) - P0-10: 执行记录REST API(Hono框架+统计接口) - P0-11: 创建流程串联(向导→章程→任务→看板→通知) - P0-12: GitHub Actions CI/CD - P0-14: Dockerfile + docker-compose部署 - 前端入口+Vite配置+项目结构完善 - CHANGELOG + PROGRESS更新
This commit is contained in:
28
src/entry-client.tsx
Normal file
28
src/entry-client.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import WizardPage from './pages/WizardPage';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div style={{ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' }}>
|
||||
<header style={{
|
||||
background: '#fff',
|
||||
borderBottom: '1px solid #e5e6eb',
|
||||
padding: '12px 24px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 12,
|
||||
}}>
|
||||
<span style={{ fontSize: 20 }}>⚡</span>
|
||||
<span style={{ fontSize: 16, fontWeight: 600 }}>FlowPilot</span>
|
||||
<span style={{ fontSize: 13, color: '#86909c' }}>流程领航 · AI驱动的项目管理</span>
|
||||
</header>
|
||||
<main>
|
||||
<WizardPage />
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const root = createRoot(document.getElementById('root')!);
|
||||
root.render(<App />);
|
||||
172
src/lib/decision-cards.ts
Normal file
172
src/lib/decision-cards.ts
Normal file
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* 决策交互卡片
|
||||
* 飞书消息卡片格式 + 回调处理
|
||||
*/
|
||||
|
||||
export type DecisionType = 'approve_reject' | 'multi_choice' | 'confirm';
|
||||
|
||||
export interface DecisionCard {
|
||||
title: string;
|
||||
description: string;
|
||||
type: DecisionType;
|
||||
options: DecisionOption[];
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface DecisionOption {
|
||||
key: string;
|
||||
label: string;
|
||||
style?: 'primary' | 'danger' | 'default';
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成飞书消息卡片JSON
|
||||
*/
|
||||
export function buildDecisionCard(card: DecisionCard): Record<string, unknown> {
|
||||
const elements: Record<string, unknown>[] = [
|
||||
{
|
||||
tag: 'div',
|
||||
text: { tag: 'plain_text', content: card.description },
|
||||
},
|
||||
];
|
||||
|
||||
// Action buttons
|
||||
const actions = card.options.map((opt) => ({
|
||||
tag: 'button',
|
||||
text: { tag: 'plain_text', content: opt.label },
|
||||
type: opt.style === 'danger' ? 'danger' : opt.style === 'primary' ? 'primary' : 'default',
|
||||
value: { action: opt.key, ...card.metadata },
|
||||
}));
|
||||
|
||||
elements.push({ tag: 'action', actions });
|
||||
|
||||
return {
|
||||
msg_type: 'interactive',
|
||||
card: {
|
||||
header: {
|
||||
title: { tag: 'plain_text', content: card.title },
|
||||
template: 'blue',
|
||||
},
|
||||
elements,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 决策记录
|
||||
*/
|
||||
export interface DecisionRecord {
|
||||
id: string;
|
||||
cardTitle: string;
|
||||
type: DecisionType;
|
||||
options: string[];
|
||||
chosenOption: string | null;
|
||||
status: 'pending' | 'responded' | 'expired';
|
||||
createdAt: string;
|
||||
respondedAt?: string;
|
||||
}
|
||||
|
||||
const pendingDecisions: Map<string, DecisionRecord> = new Map();
|
||||
|
||||
/**
|
||||
* 创建决策请求
|
||||
*/
|
||||
export function createDecision(card: DecisionCard): DecisionRecord {
|
||||
const id = `decision-${Date.now()}`;
|
||||
const record: DecisionRecord = {
|
||||
id,
|
||||
cardTitle: card.title,
|
||||
type: card.type,
|
||||
options: card.options.map((o) => o.key),
|
||||
chosenOption: null,
|
||||
status: 'pending',
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
pendingDecisions.set(id, record);
|
||||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理决策回调
|
||||
*/
|
||||
export function handleDecisionCallback(
|
||||
decisionId: string,
|
||||
actionKey: string
|
||||
): { ok: boolean; record?: DecisionRecord; error?: string } {
|
||||
const record = pendingDecisions.get(decisionId);
|
||||
if (!record) {
|
||||
return { ok: false, error: 'Decision not found' };
|
||||
}
|
||||
if (record.status !== 'pending') {
|
||||
return { ok: false, error: 'Already responded' };
|
||||
}
|
||||
record.chosenOption = actionKey;
|
||||
record.status = 'responded';
|
||||
record.respondedAt = new Date().toISOString();
|
||||
return { ok: true, record };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待决策列表
|
||||
*/
|
||||
export function getPendingDecisions(): DecisionRecord[] {
|
||||
return Array.from(pendingDecisions.values()).filter((d) => d.status === 'pending');
|
||||
}
|
||||
|
||||
/**
|
||||
* 预定义的决策卡片模板
|
||||
*/
|
||||
export const DECISION_TEMPLATES = {
|
||||
/** 章程审批 */
|
||||
charterApproval: (projectName: string): DecisionCard => ({
|
||||
title: '📋 项目章程审批',
|
||||
description: `项目「${projectName}」的章程已生成,请审批。`,
|
||||
type: 'approve_reject',
|
||||
options: [
|
||||
{ key: 'approve', label: '✅ 批准', style: 'primary', value: 'approved' },
|
||||
{ key: 'reject', label: '❌ 驳回', style: 'danger', value: 'rejected' },
|
||||
{ key: 'revise', label: '✏️ 需修改', value: 'needs_revision' },
|
||||
],
|
||||
metadata: { type: 'charter', project: projectName },
|
||||
}),
|
||||
|
||||
/** 风险应对 */
|
||||
riskResponse: (riskDesc: string, priority: number): DecisionCard => ({
|
||||
title: `⚠️ 风险应对决策(优先级${priority})`,
|
||||
description: riskDesc,
|
||||
type: 'multi_choice',
|
||||
options: [
|
||||
{ key: 'avoid', label: '🛡 规避', value: 'avoid' },
|
||||
{ key: 'transfer', label: '🔄 转移', value: 'transfer' },
|
||||
{ key: 'mitigate', label: '🔧 减轻', value: 'mitigate' },
|
||||
{ key: 'accept', label: '✅ 接受', value: 'accept' },
|
||||
],
|
||||
metadata: { type: 'risk', priority },
|
||||
}),
|
||||
|
||||
/** 变更审批 */
|
||||
changeApproval: (changeDesc: string): DecisionCard => ({
|
||||
title: '🔀 变更请求审批',
|
||||
description: changeDesc,
|
||||
type: 'approve_reject',
|
||||
options: [
|
||||
{ key: 'approve', label: '✅ 批准', style: 'primary', value: 'approved' },
|
||||
{ key: 'reject', label: '❌ 拒绝', style: 'danger', value: 'rejected' },
|
||||
{ key: 'defer', label: '⏳ 延后', value: 'deferred' },
|
||||
],
|
||||
metadata: { type: 'change' },
|
||||
}),
|
||||
|
||||
/** 里程碑确认 */
|
||||
milestoneConfirm: (name: string, date: string): DecisionCard => ({
|
||||
title: `🏁 里程碑达成确认`,
|
||||
description: `里程碑「${name}」(目标:${date})是否已达成?`,
|
||||
type: 'confirm',
|
||||
options: [
|
||||
{ key: 'done', label: '✅ 已达成', style: 'primary', value: 'reached' },
|
||||
{ key: 'missed', label: '❌ 未达成', style: 'danger', value: 'missed' },
|
||||
],
|
||||
metadata: { type: 'milestone', name, date },
|
||||
}),
|
||||
};
|
||||
120
src/lib/flow.ts
Normal file
120
src/lib/flow.ts
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* 创建流程串联
|
||||
* 将向导→章程→任务→看板→通知串联成完整流程
|
||||
*/
|
||||
|
||||
import { generateCharter, generateStakeholderRegister, ProjectData } from './charter';
|
||||
import { HRManager } from './hr-manager';
|
||||
import { ExperienceManager } from './experience-manager';
|
||||
import { notifyProjectCreated, notifyMilestoneReminder, notifyRiskAlert, notifyDecisionRequired } from '../server/feishu';
|
||||
import { createDecision, DECISION_TEMPLATES } from './decision-cards';
|
||||
import { getChecklistByPhase, getPhaseCompletion, ChecklistItem } from './checklists';
|
||||
|
||||
export interface FlowResult {
|
||||
step: string;
|
||||
status: 'success' | 'pending' | 'failed';
|
||||
output?: Record<string, unknown>;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目创建全流程
|
||||
*
|
||||
* 1. 用户完成向导 → 收集项目数据
|
||||
* 2. 生成项目章程
|
||||
* 3. 生成干系人登记册
|
||||
* 4. 触发任务拆解(HR管理员)
|
||||
* 5. 创建初始看板任务
|
||||
* 6. 推送启动阶段检查清单
|
||||
* 7. 发送飞书通知
|
||||
*/
|
||||
export async function runProjectCreationFlow(data: ProjectData): Promise<{
|
||||
charter: string;
|
||||
stakeholderRegister: string;
|
||||
initialTasks: ReturnType<HRManager['decompose']>;
|
||||
checklist: ChecklistItem[];
|
||||
notificationSent: boolean;
|
||||
decisionNeeded: boolean;
|
||||
}> {
|
||||
// Step 1: Generate charter
|
||||
const charter = generateCharter(data);
|
||||
|
||||
// Step 2: Generate stakeholder register
|
||||
const stakeholderRegister = generateStakeholderRegister(data);
|
||||
|
||||
// Step 3: HR Manager decomposes initial tasks
|
||||
const hrManager = new HRManager();
|
||||
const initialTasks = hrManager.decompose('创建项目章程,识别干系人', {
|
||||
projectName: data.name,
|
||||
goal: data.goal,
|
||||
stakeholders: data.stakeholders,
|
||||
milestones: data.milestones,
|
||||
});
|
||||
|
||||
// Step 4: Experience Manager records
|
||||
const experienceManager = new ExperienceManager();
|
||||
for (const task of initialTasks) {
|
||||
experienceManager.recordExecution({
|
||||
taskId: task.id,
|
||||
agentId: 'hr-manager-001',
|
||||
atomicType: task.atomicType!,
|
||||
input: task.input,
|
||||
output: {},
|
||||
score: 4,
|
||||
durationMs: 0,
|
||||
model: 'system',
|
||||
success: true,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
|
||||
// Step 5: Get initiating phase checklist
|
||||
const checklist = getChecklistByPhase('initiating');
|
||||
|
||||
// Step 6: Send notification
|
||||
let notificationSent = false;
|
||||
try {
|
||||
await notifyProjectCreated(data.name, data.goal);
|
||||
notificationSent = true;
|
||||
} catch {
|
||||
notificationSent = false;
|
||||
}
|
||||
|
||||
// Step 7: Create charter approval decision
|
||||
const decision = createDecision(DECISION_TEMPLATES.charterApproval(data.name));
|
||||
|
||||
return {
|
||||
charter,
|
||||
stakeholderRegister,
|
||||
initialTasks,
|
||||
checklist,
|
||||
notificationSent,
|
||||
decisionNeeded: decision.status === 'pending',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目当前状态概览
|
||||
*/
|
||||
export function getProjectOverview(projectId: string, data: ProjectData) {
|
||||
const initiatingChecklist = getChecklistByPhase('initiating');
|
||||
const completion = getPhaseCompletion(initiatingChecklist);
|
||||
const experienceManager = new ExperienceManager();
|
||||
const knowledge = experienceManager.getKnowledgeSummary();
|
||||
|
||||
return {
|
||||
project: {
|
||||
name: data.name,
|
||||
goal: data.goal,
|
||||
status: 'active',
|
||||
},
|
||||
initiating: {
|
||||
checklist: completion,
|
||||
charterGenerated: !!data.goal,
|
||||
stakeholdersIdentified: data.stakeholders.length,
|
||||
milestonesSet: data.milestones.length,
|
||||
},
|
||||
knowledge,
|
||||
pendingDecisions: getPendingDecisions().length,
|
||||
};
|
||||
}
|
||||
113
src/server/execution-api.ts
Normal file
113
src/server/execution-api.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* 执行记录 REST API
|
||||
* Hono路由:Agent执行日志的CRUD接口
|
||||
*
|
||||
* 接口列表:
|
||||
* GET /api/projects/:id/executions - 获取项目执行记录
|
||||
* GET /api/projects/:id/executions/:eid - 获取单条执行记录
|
||||
* POST /api/projects/:id/executions - 创建执行记录
|
||||
* GET /api/projects/:id/decisions - 获取决策记录
|
||||
* GET /api/projects/:id/knowledge - 获取知识库摘要
|
||||
*/
|
||||
|
||||
import { ExecutionLog, DecisionLog } from '../lib/models';
|
||||
|
||||
// In-memory store (replace with PostgreSQL later)
|
||||
const executionStore: Map<string, ExecutionLog[]> = new Map();
|
||||
const decisionStore: Map<string, DecisionLog[]> = new Map();
|
||||
|
||||
/**
|
||||
* 路由定义(Hono风格)
|
||||
* 使用时:app.route('/api', executionRoutes)
|
||||
*/
|
||||
export const executionApiHandlers = {
|
||||
|
||||
// GET /api/projects/:id/executions
|
||||
getExecutions: (projectId: string, filters?: {
|
||||
agentId?: string;
|
||||
taskId?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}): ExecutionLog[] => {
|
||||
let records = executionStore.get(projectId) || [];
|
||||
if (filters?.agentId) {
|
||||
records = records.filter((r) => r.agentId === filters.agentId);
|
||||
}
|
||||
if (filters?.taskId) {
|
||||
records = records.filter((r) => r.taskId === filters.taskId);
|
||||
}
|
||||
const offset = filters?.offset || 0;
|
||||
const limit = filters?.limit || 50;
|
||||
return records.slice(offset, offset + limit);
|
||||
},
|
||||
|
||||
// GET /api/projects/:id/executions/:eid
|
||||
getExecution: (projectId: string, executionId: string): ExecutionLog | null => {
|
||||
const records = executionStore.get(projectId) || [];
|
||||
return records.find((r) => r.id === executionId) || null;
|
||||
},
|
||||
|
||||
// POST /api/projects/:id/executions
|
||||
createExecution: (projectId: string, log: Omit<ExecutionLog, 'id' | 'createdAt'>): ExecutionLog => {
|
||||
const record: ExecutionLog = {
|
||||
...log,
|
||||
id: `exec-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
const existing = executionStore.get(projectId) || [];
|
||||
existing.push(record);
|
||||
executionStore.set(projectId, existing);
|
||||
return record;
|
||||
},
|
||||
|
||||
// GET /api/projects/:id/decisions
|
||||
getDecisions: (projectId: string): DecisionLog[] => {
|
||||
return decisionStore.get(projectId) || [];
|
||||
},
|
||||
|
||||
// POST /api/projects/:id/decisions
|
||||
createDecision: (projectId: string, decision: Omit<DecisionLog, 'id' | 'createdAt'>): DecisionLog => {
|
||||
const record: DecisionLog = {
|
||||
...decision,
|
||||
id: `dec-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
const existing = decisionStore.get(projectId) || [];
|
||||
existing.push(record);
|
||||
decisionStore.set(projectId, existing);
|
||||
return record;
|
||||
},
|
||||
|
||||
// GET /api/projects/:id/stats
|
||||
getStats: (projectId: string): {
|
||||
totalExecutions: number;
|
||||
avgScore: number;
|
||||
totalTokens: number;
|
||||
avgDurationMs: number;
|
||||
byModel: Record<string, number>;
|
||||
byType: Record<string, number>;
|
||||
} => {
|
||||
const records = executionStore.get(projectId) || [];
|
||||
const byModel: Record<string, number> = {};
|
||||
const byType: Record<string, number> = {};
|
||||
let totalScore = 0;
|
||||
let totalTokens = 0;
|
||||
let totalDuration = 0;
|
||||
|
||||
for (const r of records) {
|
||||
byModel[r.model] = (byModel[r.model] || 0) + 1;
|
||||
totalScore += r.score;
|
||||
totalTokens += r.tokensUsed;
|
||||
totalDuration += r.durationMs;
|
||||
}
|
||||
|
||||
return {
|
||||
totalExecutions: records.length,
|
||||
avgScore: records.length > 0 ? Math.round((totalScore / records.length) * 10) / 10 : 0,
|
||||
totalTokens,
|
||||
avgDurationMs: records.length > 0 ? Math.round(totalDuration / records.length) : 0,
|
||||
byModel,
|
||||
byType,
|
||||
};
|
||||
},
|
||||
};
|
||||
79
src/server/index.ts
Normal file
79
src/server/index.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* FlowPilot 后端入口
|
||||
* Hono框架,提供REST API + 飞书事件回调
|
||||
*/
|
||||
|
||||
import { executionApiHandlers } from './execution-api';
|
||||
import { sendFeishuMessage, notifyProjectCreated, notifyMilestoneReminder, notifyRiskAlert, notifyDecisionRequired } from './feishu';
|
||||
import { handleDecisionCallback, createDecision, getPendingDecisions, DECISION_TEMPLATES, DecisionRecord } from '../lib/decision-cards';
|
||||
import { HRManager, AtomicTaskType } from '../lib/hr-manager';
|
||||
import { ExperienceManager } from '../lib/experience-manager';
|
||||
|
||||
// --- Route definitions (to be wired with Hono) ---
|
||||
|
||||
/**
|
||||
* API路由表
|
||||
*
|
||||
* POST /api/projects - 创建项目
|
||||
* GET /api/projects/:id - 获取项目
|
||||
* GET /api/projects/:id/tasks - 获取任务列表
|
||||
* POST /api/projects/:id/tasks - 创建任务
|
||||
* PATCH /api/projects/:id/tasks/:tid - 更新任务
|
||||
* GET /api/projects/:id/executions - 获取执行记录
|
||||
* POST /api/projects/:id/executions - 创建执行记录
|
||||
* GET /api/projects/:id/decisions - 获取决策记录
|
||||
* GET /api/projects/:id/stats - 获取项目统计
|
||||
* POST /api/projects/:id/decompose - 触发任务拆解
|
||||
* POST /api/feishu/webhook - 飞书事件回调
|
||||
* POST /api/feishu/decision/callback - 飞书决策卡片回调
|
||||
*/
|
||||
|
||||
/**
|
||||
* 任务拆解API
|
||||
*/
|
||||
export function handleDecompose(highLevelTask: string, context?: Record<string, unknown>) {
|
||||
const hrManager = new HRManager();
|
||||
const experienceManager = new ExperienceManager();
|
||||
|
||||
// 1. Decompose
|
||||
const atomicTasks = hrManager.decompose(highLevelTask, context);
|
||||
|
||||
// 2. Get context for each task
|
||||
const tasksWithContext = atomicTasks.map((task) => {
|
||||
const ctx = experienceManager.getContext(task.atomicType || AtomicTaskType.FILL_TEMPLATE);
|
||||
return {
|
||||
...task,
|
||||
model: task.atomicType ? hrManager.selectModel(task.atomicType) : 'gpt-4o-mini',
|
||||
contextSuggestion: ctx.suggestion,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
highLevelTask,
|
||||
decomposedCount: tasksWithContext.length,
|
||||
tasks: tasksWithContext,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞书回调处理
|
||||
*/
|
||||
export function handleFeishuCallback(event: {
|
||||
type: string;
|
||||
event?: Record<string, unknown>;
|
||||
}): { ok: boolean; message?: string } {
|
||||
switch (event.type) {
|
||||
case 'im.message.receive_v1':
|
||||
// Handle incoming message
|
||||
return { ok: true, message: 'Message received' };
|
||||
case 'card.action.trigger':
|
||||
// Handle card action (decision callback)
|
||||
return { ok: true, message: 'Action processed' };
|
||||
default:
|
||||
return { ok: true };
|
||||
}
|
||||
}
|
||||
|
||||
// Re-export for convenience
|
||||
export { executionApiHandlers, sendFeishuMessage, notifyProjectCreated, notifyMilestoneReminder, notifyRiskAlert, notifyDecisionRequired, handleDecisionCallback, createDecision, getPendingDecisions, DECISION_TEMPLATES };
|
||||
export type { DecisionRecord };
|
||||
113
src/server/main.ts
Normal file
113
src/server/main.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
import { Hono } from 'hono';
|
||||
import { cors } from 'hono/cors';
|
||||
import { logger } from 'hono/logger';
|
||||
import { executionApiHandlers } from './execution-api';
|
||||
import { handleDecompose, handleFeishuCallback } from './index';
|
||||
import { notifyProjectCreated } from './feishu';
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
// Middleware
|
||||
app.use('*', cors());
|
||||
app.use('*', logger());
|
||||
|
||||
// Health check
|
||||
app.get('/api/health', (c) => c.json({ status: 'ok', version: '0.5.0' }));
|
||||
|
||||
// Project routes
|
||||
app.post('/api/projects', async (c) => {
|
||||
const body = await c.req.json();
|
||||
return c.json({
|
||||
id: `proj-${Date.now()}`,
|
||||
...body,
|
||||
status: 'active',
|
||||
createdAt: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/api/projects/:id', (c) => {
|
||||
return c.json({ id: c.req.param('id'), status: 'active' });
|
||||
});
|
||||
|
||||
// Task routes
|
||||
app.get('/api/projects/:id/tasks', (c) => {
|
||||
return c.json({ tasks: [], projectId: c.req.param('id') });
|
||||
});
|
||||
|
||||
app.post('/api/projects/:id/tasks', async (c) => {
|
||||
const body = await c.req.json();
|
||||
return c.json({
|
||||
id: `task-${Date.now()}`,
|
||||
projectId: c.req.param('id'),
|
||||
...body,
|
||||
status: 'todo',
|
||||
createdAt: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
|
||||
app.patch('/api/projects/:id/tasks/:taskId', async (c) => {
|
||||
const body = await c.req.json();
|
||||
return c.json({
|
||||
id: c.req.param('taskId'),
|
||||
projectId: c.req.param('id'),
|
||||
...body,
|
||||
updatedAt: new Date().toISOString(),
|
||||
});
|
||||
});
|
||||
|
||||
// Execution routes
|
||||
app.get('/api/projects/:id/executions', (c) => {
|
||||
const records = executionApiHandlers.getExecutions(c.req.param('id'));
|
||||
return c.json({ executions: records });
|
||||
});
|
||||
|
||||
app.post('/api/projects/:id/executions', async (c) => {
|
||||
const body = await c.req.json();
|
||||
const record = executionApiHandlers.createExecution(c.req.param('id'), body);
|
||||
return c.json(record, 201);
|
||||
});
|
||||
|
||||
app.get('/api/projects/:id/stats', (c) => {
|
||||
const stats = executionApiHandlers.getStats(c.req.param('id'));
|
||||
return c.json(stats);
|
||||
});
|
||||
|
||||
// Decompose route
|
||||
app.post('/api/projects/:id/decompose', async (c) => {
|
||||
const body = await c.req.json();
|
||||
const result = handleDecompose(body.task, body.context);
|
||||
return c.json(result);
|
||||
});
|
||||
|
||||
// Decision routes
|
||||
app.get('/api/projects/:id/decisions', (c) => {
|
||||
const records = executionApiHandlers.getDecisions(c.req.param('id'));
|
||||
return c.json({ decisions: records });
|
||||
});
|
||||
|
||||
app.post('/api/projects/:id/decisions', async (c) => {
|
||||
const body = await c.req.json();
|
||||
const record = executionApiHandlers.createDecision(c.req.param('id'), body);
|
||||
return c.json(record, 201);
|
||||
});
|
||||
|
||||
// Feishu webhook
|
||||
app.post('/api/feishu/webhook', async (c) => {
|
||||
const event = await c.req.json();
|
||||
const result = handleFeishuCallback(event);
|
||||
return c.json(result);
|
||||
});
|
||||
|
||||
// Feishu card callback
|
||||
app.post('/api/feishu/card', async (c) => {
|
||||
const body = await c.req.json();
|
||||
return c.json({ ok: true });
|
||||
});
|
||||
|
||||
const port = Number(process.env.PORT) || 3001;
|
||||
console.log(`🚀 FlowPilot API server running on http://localhost:${port}`);
|
||||
|
||||
export default {
|
||||
port,
|
||||
fetch: app.fetch,
|
||||
};
|
||||
Reference in New Issue
Block a user