"use strict"; /** * FlowPilot 后端入口 * Hono框架,提供REST API + 飞书事件回调 */ var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DECISION_TEMPLATES = exports.getPendingDecisions = exports.createDecision = exports.handleDecisionCallback = exports.sendDecisionCard = exports.notifyRiskAlert = exports.notifyMilestoneReminder = exports.notifyProjectCreated = exports.sendFeishuMessage = exports.executionApiHandlers = void 0; exports.handleDecompose = handleDecompose; exports.handleFeishuCallback = handleFeishuCallback; var execution_api_1 = require("./execution-api"); Object.defineProperty(exports, "executionApiHandlers", { enumerable: true, get: function () { return execution_api_1.executionApiHandlers; } }); var feishu_1 = require("./feishu"); Object.defineProperty(exports, "sendFeishuMessage", { enumerable: true, get: function () { return feishu_1.sendFeishuMessage; } }); Object.defineProperty(exports, "notifyProjectCreated", { enumerable: true, get: function () { return feishu_1.notifyProjectCreated; } }); Object.defineProperty(exports, "notifyMilestoneReminder", { enumerable: true, get: function () { return feishu_1.notifyMilestoneReminder; } }); Object.defineProperty(exports, "notifyRiskAlert", { enumerable: true, get: function () { return feishu_1.notifyRiskAlert; } }); Object.defineProperty(exports, "sendDecisionCard", { enumerable: true, get: function () { return feishu_1.sendDecisionCard; } }); var decision_cards_1 = require("../lib/decision-cards"); Object.defineProperty(exports, "handleDecisionCallback", { enumerable: true, get: function () { return decision_cards_1.handleDecisionCallback; } }); Object.defineProperty(exports, "createDecision", { enumerable: true, get: function () { return decision_cards_1.createDecision; } }); Object.defineProperty(exports, "getPendingDecisions", { enumerable: true, get: function () { return decision_cards_1.getPendingDecisions; } }); Object.defineProperty(exports, "DECISION_TEMPLATES", { enumerable: true, get: function () { return decision_cards_1.DECISION_TEMPLATES; } }); var hr_manager_1 = require("../lib/hr-manager"); var experience_manager_1 = require("../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 */ function handleDecompose(highLevelTask, context) { var hrManager = new hr_manager_1.HRManager(); var experienceManager = new experience_manager_1.ExperienceManager(); // 1. Decompose var atomicTasks = hrManager.decompose(highLevelTask, context); // 2. Get context for each task var tasksWithContext = atomicTasks.map(function (task) { var ctx = experienceManager.getContext(task.atomicType || hr_manager_1.AtomicTaskType.FILL_TEMPLATE); return __assign(__assign({}, task), { model: task.atomicType ? hrManager.selectModel(task.atomicType) : 'gpt-4o-mini', contextSuggestion: ctx.suggestion }); }); return { highLevelTask: highLevelTask, decomposedCount: tasksWithContext.length, tasks: tasksWithContext, }; } /** * 飞书回调处理 */ function handleFeishuCallback(event) { 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 }; } }